I was sick of the mail_daemon deskbar replicant always showing the wrong count
of new messages so I added a new menu item to refresh the new mail query. I wrapped the addition of the menu item in an #ifdef since it should not be needed on Haiku. While testing this I saw some pretty crazy behavior which I can only assume means the R5 query notification is really, really buggy. Or the mail_daemon is doing something weird. Unlike the others this menu item does not have a Japanese translation and probably doesn't need one, but if someone really wants to add it feel free :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19656 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7f77e4bd76
commit
1f2e7f93df
@ -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)
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user