Mail daemon notifications, round 2:
* Use the proper identifier for each notification window : 2 per account for sending/receiving, and a global one to show the "n message received" message. * Use the mail daemon icon on the windows instead of the default ones * Shuffle the text in the windows a bit so it makes more sense * Use the settings from the mail preflet for showing or not the window. The meaning of "always" changes a bit, since it is not possible to have a "forever" timeout with the notification server (and that would be rather annoying). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43077 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c0691021f7
commit
244a545018
|
@ -19,6 +19,7 @@
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <fs_index.h>
|
#include <fs_index.h>
|
||||||
|
#include <IconUtils.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
#include <Notification.h>
|
#include <Notification.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
@ -150,8 +151,6 @@ MailDaemonApp::ReadyToRun()
|
||||||
fNewMessages = 0;
|
fNewMessages = 0;
|
||||||
|
|
||||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
while (roster.GetNextVolume(&volume) == B_OK) {
|
||||||
//{char name[255];volume.GetName(name);printf("Volume: %s\n",name);}
|
|
||||||
|
|
||||||
BQuery* query = new BQuery;
|
BQuery* query = new BQuery;
|
||||||
|
|
||||||
query->SetTarget(this);
|
query->SetTarget(this);
|
||||||
|
@ -192,8 +191,16 @@ MailDaemonApp::ReadyToRun()
|
||||||
fCentralBeep = false;
|
fCentralBeep = false;
|
||||||
|
|
||||||
fNotification = new BNotification(B_INFORMATION_NOTIFICATION);
|
fNotification = new BNotification(B_INFORMATION_NOTIFICATION);
|
||||||
fNotification->SetApplication("Mail daemon");
|
fNotification->SetApplication(B_TRANSLATE("Mail status"));
|
||||||
fNotification->SetTitle(string);
|
fNotification->SetTitle(string);
|
||||||
|
fNotification->SetMessageID("daemon_status");
|
||||||
|
|
||||||
|
app_info info;
|
||||||
|
be_roster->GetAppInfo(B_MAIL_DAEMON_SIGNATURE, &info);
|
||||||
|
BBitmap icon(BRect(0, 0, 32, 32), B_RGBA32);
|
||||||
|
BNode node(&info.ref);
|
||||||
|
BIconUtils::GetVectorIcon(&node, "BEOS:ICON", &icon);
|
||||||
|
fNotification->SetIcon(&icon);
|
||||||
|
|
||||||
fLEDAnimation = new LEDAnimation;
|
fLEDAnimation = new LEDAnimation;
|
||||||
SetPulseRate(1000000);
|
SetPulseRate(1000000);
|
||||||
|
@ -203,8 +210,6 @@ MailDaemonApp::ReadyToRun()
|
||||||
void
|
void
|
||||||
MailDaemonApp::RefsReceived(BMessage* message)
|
MailDaemonApp::RefsReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
be_roster->Notify(*fNotification, 3);
|
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
|
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
|
||||||
BNode node(&ref);
|
BNode node(&ref);
|
||||||
|
@ -260,12 +265,12 @@ MailDaemonApp::MessageReceived(BMessage* msg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgSetStatusWindowMode: // when to show the status window
|
case kMsgSetStatusWindowMode: // when to show the status window
|
||||||
{/*
|
{
|
||||||
int32 mode;
|
int32 mode;
|
||||||
if (msg->FindInt32("ShowStatusWindow", &mode) == B_OK)
|
if (msg->FindInt32("ShowStatusWindow", &mode) == B_OK)
|
||||||
fMailStatusWindow->SetShowCriterion(mode);
|
fNotifyMode = mode;
|
||||||
break;
|
break;
|
||||||
*/}
|
}
|
||||||
|
|
||||||
case kMsgMarkMessageAsRead:
|
case kMsgMarkMessageAsRead:
|
||||||
{
|
{
|
||||||
|
@ -384,6 +389,8 @@ MailDaemonApp::MessageReceived(BMessage* msg)
|
||||||
string << B_TRANSLATE("No new messages.");
|
string << B_TRANSLATE("No new messages.");
|
||||||
|
|
||||||
fNotification->SetTitle(string.String());
|
fNotification->SetTitle(string.String());
|
||||||
|
if (fNotifyMode != B_MAIL_SHOW_STATUS_WINDOW_NEVER)
|
||||||
|
be_roster->Notify(*fNotification);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +652,7 @@ MailDaemonApp::_InitAccount(BMailAccountSettings& settings)
|
||||||
}
|
}
|
||||||
if (account.inboundProtocol) {
|
if (account.inboundProtocol) {
|
||||||
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true,
|
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true,
|
||||||
fErrorLogWindow);
|
fErrorLogWindow, fNotifyMode);
|
||||||
account.inboundProtocol->SetMailNotifier(notifier);
|
account.inboundProtocol->SetMailNotifier(notifier);
|
||||||
|
|
||||||
account.inboundThread = new InboundProtocolThread(
|
account.inboundThread = new InboundProtocolThread(
|
||||||
|
@ -662,7 +669,7 @@ MailDaemonApp::_InitAccount(BMailAccountSettings& settings)
|
||||||
}
|
}
|
||||||
if (account.outboundProtocol) {
|
if (account.outboundProtocol) {
|
||||||
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false,
|
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false,
|
||||||
fErrorLogWindow);
|
fErrorLogWindow, fNotifyMode);
|
||||||
account.outboundProtocol->SetMailNotifier(notifier);
|
account.outboundProtocol->SetMailNotifier(notifier);
|
||||||
|
|
||||||
account.outboundThread = new OutboundProtocolThread(
|
account.outboundThread = new OutboundProtocolThread(
|
||||||
|
|
|
@ -112,6 +112,7 @@ private:
|
||||||
|
|
||||||
ErrorLogWindow* fErrorLogWindow;
|
ErrorLogWindow* fErrorLogWindow;
|
||||||
BNotification* fNotification;
|
BNotification* fNotification;
|
||||||
|
uint32 fNotifyMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <IconUtils.h>
|
||||||
|
#include <MailDaemon.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
|
||||||
#include "Notifier.h"
|
#include "Notifier.h"
|
||||||
|
@ -15,12 +18,13 @@
|
||||||
|
|
||||||
|
|
||||||
DefaultNotifier::DefaultNotifier(const char* accountName, bool inbound,
|
DefaultNotifier::DefaultNotifier(const char* accountName, bool inbound,
|
||||||
ErrorLogWindow* errorWindow)
|
ErrorLogWindow* errorWindow, uint32& showMode)
|
||||||
:
|
:
|
||||||
fAccountName(accountName),
|
fAccountName(accountName),
|
||||||
fIsInbound(inbound),
|
fIsInbound(inbound),
|
||||||
fErrorWindow(errorWindow),
|
fErrorWindow(errorWindow),
|
||||||
fNotification(B_PROGRESS_NOTIFICATION),
|
fNotification(B_PROGRESS_NOTIFICATION),
|
||||||
|
fShowMode(showMode),
|
||||||
fTotalItems(0),
|
fTotalItems(0),
|
||||||
fItemsDone(0),
|
fItemsDone(0),
|
||||||
fTotalSize(0),
|
fTotalSize(0),
|
||||||
|
@ -34,10 +38,19 @@ DefaultNotifier::DefaultNotifier(const char* accountName, bool inbound,
|
||||||
desc.ReplaceFirst("%name", fAccountName);
|
desc.ReplaceFirst("%name", fAccountName);
|
||||||
|
|
||||||
BString identifier;
|
BString identifier;
|
||||||
identifier << (int)this;
|
identifier << accountName << inbound;
|
||||||
// This should get us an unique value for each notifier running
|
// Two windows for each acocunt : one for sending and the other for
|
||||||
|
// receiving mails
|
||||||
fNotification.SetMessageID(identifier);
|
fNotification.SetMessageID(identifier);
|
||||||
fNotification.SetApplication("Mail daemon");
|
fNotification.SetApplication(B_TRANSLATE("Mail Status"));
|
||||||
|
fNotification.SetTitle(desc);
|
||||||
|
|
||||||
|
app_info info;
|
||||||
|
be_roster->GetAppInfo(B_MAIL_DAEMON_SIGNATURE, &info);
|
||||||
|
BBitmap icon(BRect(0, 0, 32, 32), B_RGBA32);
|
||||||
|
BNode node(&info.ref);
|
||||||
|
BIconUtils::GetVectorIcon(&node, "BEOS:ICON", &icon);
|
||||||
|
fNotification.SetIcon(&icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +62,7 @@ DefaultNotifier::~DefaultNotifier()
|
||||||
MailNotifier*
|
MailNotifier*
|
||||||
DefaultNotifier::Clone()
|
DefaultNotifier::Clone()
|
||||||
{
|
{
|
||||||
return new DefaultNotifier(fAccountName, fIsInbound, fErrorWindow);
|
return new DefaultNotifier(fAccountName, fIsInbound, fErrorWindow, fShowMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,19 +111,23 @@ DefaultNotifier::ReportProgress(int bytes, int messages, const char* message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fItemsDone += messages;
|
fItemsDone += messages;
|
||||||
|
|
||||||
BString progress;
|
BString progress;
|
||||||
|
|
||||||
|
progress << message << "\t";
|
||||||
|
|
||||||
if (fTotalItems > 0)
|
if (fTotalItems > 0)
|
||||||
progress << fItemsDone << "/" << fTotalItems;
|
progress << fItemsDone << "/" << fTotalItems;
|
||||||
|
|
||||||
fNotification.SetContent(progress);
|
fNotification.SetContent(progress);
|
||||||
|
|
||||||
if (message != NULL)
|
|
||||||
fNotification.SetTitle(message);
|
|
||||||
|
|
||||||
int timeout = 0; // Default timeout
|
int timeout = 0; // Default timeout
|
||||||
if (fItemsDone == fTotalItems && fTotalItems != 0)
|
if (fItemsDone == fTotalItems && fTotalItems != 0)
|
||||||
timeout = 1; // We're done, make the window go away faster
|
timeout = 1; // We're done, make the window go away faster
|
||||||
be_roster->Notify(fNotification, timeout);
|
|
||||||
|
if ((!fIsInbound && fShowMode | B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING)
|
||||||
|
|| (fIsInbound && fShowMode | B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE))
|
||||||
|
be_roster->Notify(fNotification, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,6 +136,6 @@ DefaultNotifier::ResetProgress(const char* message)
|
||||||
{
|
{
|
||||||
fNotification.SetProgress(0);
|
fNotification.SetProgress(0);
|
||||||
if (message != NULL)
|
if (message != NULL)
|
||||||
fNotification.SetContent(message);
|
fNotification.SetTitle(message);
|
||||||
be_roster->Notify(fNotification, 0);
|
be_roster->Notify(fNotification, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
class DefaultNotifier : public MailNotifier {
|
class DefaultNotifier : public MailNotifier {
|
||||||
public:
|
public:
|
||||||
DefaultNotifier(const char* accountName,
|
DefaultNotifier(const char* accountName,
|
||||||
bool inbound, ErrorLogWindow* errorWindow);
|
bool inbound, ErrorLogWindow* errorWindow,
|
||||||
|
uint32& showMode);
|
||||||
~DefaultNotifier();
|
~DefaultNotifier();
|
||||||
|
|
||||||
MailNotifier* Clone();
|
MailNotifier* Clone();
|
||||||
|
@ -38,6 +39,7 @@ private:
|
||||||
bool fIsInbound;
|
bool fIsInbound;
|
||||||
ErrorLogWindow* fErrorWindow;
|
ErrorLogWindow* fErrorWindow;
|
||||||
BNotification fNotification;
|
BNotification fNotification;
|
||||||
|
uint32& fShowMode;
|
||||||
|
|
||||||
int fTotalItems;
|
int fTotalItems;
|
||||||
int fItemsDone;
|
int fItemsDone;
|
||||||
|
|
Loading…
Reference in New Issue