diff --git a/src/servers/mail/deskbarview.cpp b/src/servers/mail/deskbarview.cpp index a3c3dfb19c..d2b9c710ed 100644 --- a/src/servers/mail/deskbarview.cpp +++ b/src/servers/mail/deskbarview.cpp @@ -102,37 +102,7 @@ void DeskbarView::AttachedToWindow() { if (be_roster->IsRunning("application/x-vnd.Be-POST")) { - BVolumeRoster volumes; - BVolume volume; - fNewMessages = 0; - - while (volumes.GetNextVolume(&volume) == B_OK) { - BQuery *fNewMailQuery = new BQuery; - - fNewMailQuery->SetTarget(this); - fNewMailQuery->SetVolume(&volume); - fNewMailQuery->PushAttr(B_MAIL_ATTR_STATUS); - fNewMailQuery->PushString("New"); - fNewMailQuery->PushOp(B_EQ); - fNewMailQuery->PushAttr("BEOS:TYPE"); - fNewMailQuery->PushString("text/x-email"); - fNewMailQuery->PushOp(B_EQ); - fNewMailQuery->PushAttr("BEOS:TYPE"); - fNewMailQuery->PushString("text/x-partial-email"); - fNewMailQuery->PushOp(B_EQ); - fNewMailQuery->PushOp(B_OR); - fNewMailQuery->PushOp(B_AND); - fNewMailQuery->Fetch(); - - BEntry entry; - while (fNewMailQuery->GetNextEntry(&entry) == B_OK) - if (entry.InitCheck() == B_OK) - fNewMessages++; - - fNewMailQueries.AddItem(fNewMailQuery); - } - - ChangeIcon((fNewMessages > 0) ? NEW_MAIL : NO_MAIL); + RefreshMailQuery(); } else { @@ -141,6 +111,41 @@ void DeskbarView::AttachedToWindow() } } +void DeskbarView::RefreshMailQuery() +{ + BVolumeRoster volumes; + BVolume volume; + fNewMessages = 0; + + while (volumes.GetNextVolume(&volume) == B_OK) { + BQuery *newMailQuery = new BQuery; + + newMailQuery->SetTarget(this); + newMailQuery->SetVolume(&volume); + newMailQuery->PushAttr(B_MAIL_ATTR_STATUS); + newMailQuery->PushString("New"); + newMailQuery->PushOp(B_EQ); + newMailQuery->PushAttr("BEOS:TYPE"); + newMailQuery->PushString("text/x-email"); + newMailQuery->PushOp(B_EQ); + newMailQuery->PushAttr("BEOS:TYPE"); + newMailQuery->PushString("text/x-partial-email"); + newMailQuery->PushOp(B_EQ); + newMailQuery->PushOp(B_OR); + newMailQuery->PushOp(B_AND); + newMailQuery->Fetch(); + + BEntry entry; + while (newMailQuery->GetNextEntry(&entry) == B_OK) + if (entry.InitCheck() == B_OK) + fNewMessages++; + + fNewMailQueries.AddItem(newMailQuery); + } + + ChangeIcon((fNewMessages > 0) ? NEW_MAIL : NO_MAIL); +} + DeskbarView* DeskbarView::Instantiate(BMessage *data) { if (!validate_instantiation(data, "DeskbarView")) @@ -220,6 +225,10 @@ DeskbarView::MessageReceived(BMessage *message) be_roster->Launch("application/x-vnd.Haiku-Mail"); break; + case MD_REFRESH_QUERY: + RefreshMailQuery(); + break; + case B_QUERY_UPDATE: { int32 what; @@ -467,6 +476,12 @@ DeskbarView::BuildMenu() menu->AddSeparatorItem(); } + // Hack for R5's buggy Query Notification + #ifdef HAIKU_TARGET_PLATFORM_BEOS + menu->AddItem(new BMenuItem("Refresh New Mail Query", + new BMessage(MD_REFRESH_QUERY))); + #endif + // The New E-mail query if (fNewMessages > 0) diff --git a/src/servers/mail/deskbarview.h b/src/servers/mail/deskbarview.h index f38049fd29..9f0de85216 100644 --- a/src/servers/mail/deskbarview.h +++ b/src/servers/mail/deskbarview.h @@ -20,7 +20,8 @@ enum MDDeskbarMessages { MD_CHECK_FOR_MAILS, MD_SEND_MAILS, MD_OPEN_NEW, - MD_OPEN_PREFS + MD_OPEN_PREFS, + MD_REFRESH_QUERY }; class BPopUpMenu; @@ -48,6 +49,7 @@ class _EXPORT DeskbarView : public BView { void ChangeIcon(int32 icon); private: + void RefreshMailQuery(); bool CreateMenuLinks(BDirectory &,BPath &); void CreateNewMailQuery(BEntry &); BPopUpMenu *BuildMenu();