Add settings to enable and disable in and outgoing mail accounts.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41077 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2011-03-22 10:28:22 +00:00
parent 37ffb53fb4
commit 08606d49da
3 changed files with 62 additions and 4 deletions
+8
View File
@@ -164,6 +164,11 @@ class BMailAccountSettings
bool HasInbound(); bool HasInbound();
bool HasOutbound(); bool HasOutbound();
void SetInboundEnabled(bool enabled = true);
bool IsInboundEnabled() const;
void SetOutboundEnabled(bool enabled = true);
bool IsOutboundEnabled() const;
status_t Reload(); status_t Reload();
status_t Save(); status_t Save();
status_t Delete(); status_t Delete();
@@ -186,6 +191,9 @@ private:
MailAddonSettings fInboundSettings; MailAddonSettings fInboundSettings;
MailAddonSettings fOutboundSettings; MailAddonSettings fOutboundSettings;
bool fInboundEnabled;
bool fOutboundEnabled;
bool fModified; bool fModified;
}; };
+40
View File
@@ -611,6 +611,8 @@ MailAddonSettings::HasBeenModified()
BMailAccountSettings::BMailAccountSettings() BMailAccountSettings::BMailAccountSettings()
: :
fStatus(B_OK), fStatus(B_OK),
fInboundEnabled(true),
fOutboundEnabled(true),
fModified(true) fModified(true)
{ {
fAccountID = real_time_clock(); 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 status_t
BMailAccountSettings::Reload() BMailAccountSettings::Reload()
{ {
@@ -796,6 +828,11 @@ BMailAccountSettings::Reload()
settings.FindMessage("outbound", &outboundSettings); settings.FindMessage("outbound", &outboundSettings);
fOutboundSettings.Load(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; fModified = false;
return B_OK; return B_OK;
} }
@@ -819,6 +856,9 @@ BMailAccountSettings::Save()
fOutboundSettings.Save(outboundSettings); fOutboundSettings.Save(outboundSettings);
settings.AddMessage("outbound", &outboundSettings); settings.AddMessage("outbound", &outboundSettings);
settings.AddBool("inbound_enabled", fInboundEnabled);
settings.AddBool("outbound_enabled", fOutboundEnabled);
status_t status = _CreateAccountFilePath(); status_t status = _CreateAccountFilePath();
if (status != B_OK) if (status != B_OK)
return status; return status;
+14 -4
View File
@@ -223,8 +223,13 @@ void
MailDaemonApp::_InitAccount(BMailAccountSettings& settings) MailDaemonApp::_InitAccount(BMailAccountSettings& settings)
{ {
account_protocols account; account_protocols account;
account.inboundProtocol = _CreateInboundProtocol(settings, // inbound
account.inboundImage); if (settings.IsInboundEnabled()) {
account.inboundProtocol = _CreateInboundProtocol(settings,
account.inboundImage);
} else {
account.inboundProtocol = NULL;
}
if (account.inboundProtocol) { if (account.inboundProtocol) {
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true, DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), true,
fErrorLogWindow, fMailStatusWindow); fErrorLogWindow, fMailStatusWindow);
@@ -235,8 +240,13 @@ MailDaemonApp::_InitAccount(BMailAccountSettings& settings)
account.inboundThread->Run(); account.inboundThread->Run();
} }
account.outboundProtocol = _CreateOutboundProtocol(settings, // outbound
account.outboundImage); if (settings.IsOutboundEnabled()) {
account.outboundProtocol = _CreateOutboundProtocol(settings,
account.outboundImage);
} else {
account.outboundProtocol = NULL;
}
if (account.outboundProtocol) { if (account.outboundProtocol) {
DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false, DefaultNotifier* notifier = new DefaultNotifier(settings.Name(), false,
fErrorLogWindow, fMailStatusWindow); fErrorLogWindow, fMailStatusWindow);