diff --git a/headers/os/mail/MailSettings.h b/headers/os/mail/MailSettings.h index fa8834fd80..c6816ad2a1 100644 --- a/headers/os/mail/MailSettings.h +++ b/headers/os/mail/MailSettings.h @@ -164,6 +164,11 @@ class BMailAccountSettings bool HasInbound(); bool HasOutbound(); + void SetInboundEnabled(bool enabled = true); + bool IsInboundEnabled() const; + void SetOutboundEnabled(bool enabled = true); + bool IsOutboundEnabled() const; + status_t Reload(); status_t Save(); status_t Delete(); @@ -186,6 +191,9 @@ private: MailAddonSettings fInboundSettings; MailAddonSettings fOutboundSettings; + bool fInboundEnabled; + bool fOutboundEnabled; + bool fModified; }; diff --git a/src/kits/mail/MailSettings.cpp b/src/kits/mail/MailSettings.cpp index 4ba7027a9b..3d75f67eee 100644 --- a/src/kits/mail/MailSettings.cpp +++ b/src/kits/mail/MailSettings.cpp @@ -611,6 +611,8 @@ MailAddonSettings::HasBeenModified() BMailAccountSettings::BMailAccountSettings() : fStatus(B_OK), + fInboundEnabled(true), + fOutboundEnabled(true), fModified(true) { fAccountID = real_time_clock(); @@ -772,6 +774,36 @@ BMailAccountSettings::HasOutbound() } +void +BMailAccountSettings::SetInboundEnabled(bool enabled) +{ + fInboundEnabled = enabled; + fModified = true; +} + + +bool +BMailAccountSettings::IsInboundEnabled() const +{ + return fInboundEnabled; +} + + +void +BMailAccountSettings::SetOutboundEnabled(bool enabled) +{ + fOutboundEnabled = enabled; + fModified = true; +} + + +bool +BMailAccountSettings::IsOutboundEnabled() const +{ + return fOutboundEnabled; +} + + status_t BMailAccountSettings::Reload() { @@ -796,6 +828,11 @@ BMailAccountSettings::Reload() settings.FindMessage("outbound", &outboundSettings); fOutboundSettings.Load(outboundSettings); + if (settings.FindBool("inbound_enabled", &fInboundEnabled) != B_OK) + fInboundEnabled = true; + if (settings.FindBool("outbound_enabled", &fOutboundEnabled) != B_OK) + fOutboundEnabled = true; + fModified = false; return B_OK; } @@ -819,6 +856,9 @@ BMailAccountSettings::Save() fOutboundSettings.Save(outboundSettings); settings.AddMessage("outbound", &outboundSettings); + settings.AddBool("inbound_enabled", fInboundEnabled); + settings.AddBool("outbound_enabled", fOutboundEnabled); + status_t status = _CreateAccountFilePath(); if (status != B_OK) return status; diff --git a/src/servers/mail/MailDaemon.cpp b/src/servers/mail/MailDaemon.cpp index f121213b08..e3c78f489e 100644 --- a/src/servers/mail/MailDaemon.cpp +++ b/src/servers/mail/MailDaemon.cpp @@ -223,8 +223,13 @@ void MailDaemonApp::_InitAccount(BMailAccountSettings& settings) { account_protocols account; - account.inboundProtocol = _CreateInboundProtocol(settings, - account.inboundImage); + // inbound + if (settings.IsInboundEnabled()) { + account.inboundProtocol = _CreateInboundProtocol(settings, + account.inboundImage); + } else { + account.inboundProtocol = NULL; + } if (account.inboundProtocol) { DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true, fErrorLogWindow, fMailStatusWindow); @@ -235,8 +240,13 @@ MailDaemonApp::_InitAccount(BMailAccountSettings& settings) account.inboundThread->Run(); } - account.outboundProtocol = _CreateOutboundProtocol(settings, - account.outboundImage); + // outbound + if (settings.IsOutboundEnabled()) { + account.outboundProtocol = _CreateOutboundProtocol(settings, + account.outboundImage); + } else { + account.outboundProtocol = NULL; + } if (account.outboundProtocol) { DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false, fErrorLogWindow, fMailStatusWindow);