Author: phoudoin Date: 2011-01-21 16:37:19 +0100 (Fri, 21 Jan 2011) New Revision: 40258 Changeset: http://dev.haiku-os.org/changeset/40258 Ticket: http://dev.haiku-os.org/ticket/7134 Modified: haiku/trunk/src/apps/mail/MailWindow.cpp Log: Applied patch (with small cosmetic changes) by jalopeura (see #7134): search e-mail addresses in every volume, not just boot one. Thanks! Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2011-01-20 20:55:45 UTC (rev 40257) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2011-01-21 15:37:19 UTC (rev 40258) @@ -1283,21 +1283,32 @@ case M_SAVE: { - char *str; - if (msg->FindString("address", (const char **)&str) == B_NO_ERROR) { - char *arg = (char *)malloc(strlen("META:email ") - + strlen(str) + 1); - BVolumeRoster volumeRoster; - BVolume volume; - volumeRoster.GetBootVolume(&volume); + const char* address; + if (msg->FindString("address", (const char**)&address) != B_NO_ERROR) + break; - BQuery query; + BVolumeRoster volumeRoster; + BVolume 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; + query.SetVolume(&volume); - sprintf(arg, "META:email=%s", str); + // query.PushAttr("META:email"); + // query.PushString(address); + // query.PushOp(B_EQ); query.SetPredicate(arg); query.Fetch(); - BEntry entry; if (query.GetNextEntry(&entry) == B_NO_ERROR) { BMessenger tracker("application/x-vnd.Be-TRAK"); if (tracker.IsValid()) { @@ -1307,20 +1318,31 @@ BMessage open(B_REFS_RECEIVED); open.AddRef("refs", &ref); tracker.SendMessage(&open); + foundEntry = true; + break; } - } else { - sprintf(arg, "META:email %s", str); - status_t result = be_roster->Launch("application/x-person", - 1, &arg); + } + // Try next volume, if any + query.Clear(); + } - 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(); + 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); + } + + free(arg); break; }