Mail server: fix disabling notifications
* The default notifier didn't always take the setting into account. * The mail server was not using the setting from the settings file and instead waiting for a message that wasn't sent anywhere. Fixes #10852.
This commit is contained in:
@@ -22,7 +22,6 @@ const uint32 kMsgCheckMessage = 'mnow';
|
|||||||
const uint32 kMsgSendMessages = 'msnd';
|
const uint32 kMsgSendMessages = 'msnd';
|
||||||
const uint32 kMsgSettingsUpdated = 'mrrs';
|
const uint32 kMsgSettingsUpdated = 'mrrs';
|
||||||
const uint32 kMsgAccountsChanged = 'macc';
|
const uint32 kMsgAccountsChanged = 'macc';
|
||||||
const uint32 kMsgSetStatusWindowMode = 'shst';
|
|
||||||
const uint32 kMsgCountNewMessages = 'mnum';
|
const uint32 kMsgCountNewMessages = 'mnum';
|
||||||
const uint32 kMsgMarkMessageAsRead = 'mmar';
|
const uint32 kMsgMarkMessageAsRead = 'mmar';
|
||||||
const uint32 kMsgFetchBody = 'mfeb';
|
const uint32 kMsgFetchBody = 'mfeb';
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
DefaultNotifier::DefaultNotifier(const char* accountName, bool inbound,
|
DefaultNotifier::DefaultNotifier(const char* accountName, bool inbound,
|
||||||
ErrorLogWindow* errorWindow, uint32& showMode)
|
ErrorLogWindow* errorWindow, uint32 showMode)
|
||||||
:
|
:
|
||||||
fAccountName(accountName),
|
fAccountName(accountName),
|
||||||
fIsInbound(inbound),
|
fIsInbound(inbound),
|
||||||
@@ -131,11 +131,7 @@ DefaultNotifier::ReportProgress(uint32 messages, uint64 bytes,
|
|||||||
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
|
||||||
|
|
||||||
if ((!fIsInbound
|
_NotifyIfAllowed(timeout);
|
||||||
&& (fShowMode & B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING) != 0)
|
|
||||||
|| (fIsInbound
|
|
||||||
&& (fShowMode & B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE) != 0))
|
|
||||||
fNotification.Send(timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,5 +141,19 @@ DefaultNotifier::ResetProgress(const char* message)
|
|||||||
fNotification.SetProgress(0);
|
fNotification.SetProgress(0);
|
||||||
if (message != NULL)
|
if (message != NULL)
|
||||||
fNotification.SetTitle(message);
|
fNotification.SetTitle(message);
|
||||||
fNotification.Send(0);
|
_NotifyIfAllowed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DefaultNotifier::_NotifyIfAllowed(int timeout)
|
||||||
|
{
|
||||||
|
int32 flag;
|
||||||
|
if (fIsInbound)
|
||||||
|
flag = B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE;
|
||||||
|
else
|
||||||
|
flag = B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING;
|
||||||
|
|
||||||
|
if ((fShowMode & flag) != 0)
|
||||||
|
fNotification.Send(timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class DefaultNotifier : public BMailNotifier {
|
|||||||
public:
|
public:
|
||||||
DefaultNotifier(const char* accountName,
|
DefaultNotifier(const char* accountName,
|
||||||
bool inbound, ErrorLogWindow* errorWindow,
|
bool inbound, ErrorLogWindow* errorWindow,
|
||||||
uint32& showMode);
|
uint32 showMode);
|
||||||
~DefaultNotifier();
|
~DefaultNotifier();
|
||||||
|
|
||||||
BMailNotifier* Clone();
|
BMailNotifier* Clone();
|
||||||
@@ -34,6 +34,9 @@ public:
|
|||||||
const char* message = NULL);
|
const char* message = NULL);
|
||||||
void ResetProgress(const char* message = NULL);
|
void ResetProgress(const char* message = NULL);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _NotifyIfAllowed(int timeout = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fAccountName;
|
BString fAccountName;
|
||||||
bool fIsInbound;
|
bool fIsInbound;
|
||||||
|
|||||||
@@ -305,14 +305,6 @@ MailDaemonApplication::MessageReceived(BMessage* msg)
|
|||||||
_ReloadAccounts(msg);
|
_ReloadAccounts(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgSetStatusWindowMode: // when to show the status window
|
|
||||||
{
|
|
||||||
int32 mode;
|
|
||||||
if (msg->FindInt32("ShowStatusWindow", &mode) == B_OK)
|
|
||||||
fNotifyMode = mode;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kMsgMarkMessageAsRead:
|
case kMsgMarkMessageAsRead:
|
||||||
{
|
{
|
||||||
int32 account = msg->FindInt32("account");
|
int32 account = msg->FindInt32("account");
|
||||||
@@ -413,7 +405,8 @@ MailDaemonApplication::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
_UpdateNewMessagesNotification();
|
_UpdateNewMessagesNotification();
|
||||||
|
|
||||||
if (fNotifyMode != B_MAIL_SHOW_STATUS_WINDOW_NEVER)
|
if (fSettingsFile.ShowStatusWindow()
|
||||||
|
!= B_MAIL_SHOW_STATUS_WINDOW_NEVER)
|
||||||
fNotification->Send();
|
fNotification->Send();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -654,7 +647,7 @@ MailDaemonApplication::_InitAccount(BMailAccountSettings& settings)
|
|||||||
}
|
}
|
||||||
if (account.inboundProtocol != NULL) {
|
if (account.inboundProtocol != NULL) {
|
||||||
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true,
|
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true,
|
||||||
fErrorLogWindow, fNotifyMode);
|
fErrorLogWindow, fSettingsFile.ShowStatusWindow());
|
||||||
account.inboundProtocol->SetMailNotifier(notifier);
|
account.inboundProtocol->SetMailNotifier(notifier);
|
||||||
account.inboundProtocol->Run();
|
account.inboundProtocol->Run();
|
||||||
}
|
}
|
||||||
@@ -666,7 +659,7 @@ MailDaemonApplication::_InitAccount(BMailAccountSettings& settings)
|
|||||||
}
|
}
|
||||||
if (account.outboundProtocol != NULL) {
|
if (account.outboundProtocol != NULL) {
|
||||||
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false,
|
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false,
|
||||||
fErrorLogWindow, fNotifyMode);
|
fErrorLogWindow, fSettingsFile.ShowStatusWindow());
|
||||||
account.outboundProtocol->SetMailNotifier(notifier);
|
account.outboundProtocol->SetMailNotifier(notifier);
|
||||||
account.outboundProtocol->Run();
|
account.outboundProtocol->Run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ private:
|
|||||||
|
|
||||||
ErrorLogWindow* fErrorLogWindow;
|
ErrorLogWindow* fErrorLogWindow;
|
||||||
BNotification* fNotification;
|
BNotification* fNotification;
|
||||||
uint32 fNotifyMode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user