Applied patch (with small cosmetic changes) by jalopeura (see #7134):
search e-mail addresses in every volume, not just boot one. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40258 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1283,21 +1283,32 @@ TMailWindow::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
case M_SAVE:
|
case M_SAVE:
|
||||||
{
|
{
|
||||||
char *str;
|
const char* address;
|
||||||
if (msg->FindString("address", (const char **)&str) == B_NO_ERROR) {
|
if (msg->FindString("address", (const char**)&address) != B_NO_ERROR)
|
||||||
char *arg = (char *)malloc(strlen("META:email ")
|
break;
|
||||||
+ strlen(str) + 1);
|
|
||||||
BVolumeRoster volumeRoster;
|
BVolumeRoster volumeRoster;
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
volumeRoster.GetBootVolume(&volume);
|
BQuery query;
|
||||||
|
BEntry entry;
|
||||||
|
bool foundEntry = false;
|
||||||
|
|
||||||
|
char* arg = (char*)malloc(strlen("META:email=")
|
||||||
|
+ strlen(address) + 1);
|
||||||
|
sprintf(arg, "META:email=%s", address);
|
||||||
|
|
||||||
|
// Search a Person file with this email address
|
||||||
|
while (volumeRoster.GetNextVolume(&volume) == B_NO_ERROR) {
|
||||||
|
if (!volume.KnowsQuery())
|
||||||
|
continue;
|
||||||
|
|
||||||
BQuery query;
|
|
||||||
query.SetVolume(&volume);
|
query.SetVolume(&volume);
|
||||||
sprintf(arg, "META:email=%s", str);
|
// query.PushAttr("META:email");
|
||||||
|
// query.PushString(address);
|
||||||
|
// query.PushOp(B_EQ);
|
||||||
query.SetPredicate(arg);
|
query.SetPredicate(arg);
|
||||||
query.Fetch();
|
query.Fetch();
|
||||||
|
|
||||||
BEntry entry;
|
|
||||||
if (query.GetNextEntry(&entry) == B_NO_ERROR) {
|
if (query.GetNextEntry(&entry) == B_NO_ERROR) {
|
||||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||||
if (tracker.IsValid()) {
|
if (tracker.IsValid()) {
|
||||||
@@ -1307,20 +1318,31 @@ TMailWindow::MessageReceived(BMessage *msg)
|
|||||||
BMessage open(B_REFS_RECEIVED);
|
BMessage open(B_REFS_RECEIVED);
|
||||||
open.AddRef("refs", &ref);
|
open.AddRef("refs", &ref);
|
||||||
tracker.SendMessage(&open);
|
tracker.SendMessage(&open);
|
||||||
|
foundEntry = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sprintf(arg, "META:email %s", str);
|
|
||||||
status_t result = be_roster->Launch("application/x-person",
|
|
||||||
1, &arg);
|
|
||||||
|
|
||||||
if (result != B_NO_ERROR)
|
|
||||||
(new BAlert("", B_TRANSLATE(
|
|
||||||
"Sorry, could not find an application that "
|
|
||||||
"supports the 'Person' data type."),
|
|
||||||
B_TRANSLATE("OK")))->Go();
|
|
||||||
}
|
}
|
||||||
free(arg);
|
// Try next volume, if any
|
||||||
|
query.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!foundEntry) {
|
||||||
|
// None found.
|
||||||
|
// Ask to open a new Person file with this address pre-filled
|
||||||
|
|
||||||
|
status_t result = be_roster->Launch("application/x-person",
|
||||||
|
1, &arg);
|
||||||
|
|
||||||
|
if (result != B_NO_ERROR) {
|
||||||
|
(new BAlert("", B_TRANSLATE(
|
||||||
|
"Sorry, could not find an application that "
|
||||||
|
"supports the 'Person' data type."),
|
||||||
|
B_TRANSLATE("OK")))->Go();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
free(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user