equal
deleted
inserted
replaced
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QVariant> |
18 #include <QVariant> |
19 #include <imapset.h> |
19 #include <imapset.h> |
|
20 #include <iapprefs.h> |
20 #include <cemailaccounts.h> |
21 #include <cemailaccounts.h> |
21 #include <xqconversions.h> |
22 #include <xqconversions.h> |
22 |
23 |
23 #include "nmipsimap4settingsmanager.h" |
24 #include "nmipsimap4settingsmanager.h" |
24 #include "nmipsextendedsettingsmanager.h" |
25 #include "nmipsextendedsettingsmanager.h" |
30 */ |
31 */ |
31 |
32 |
32 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
33 |
34 |
34 /*! |
35 /*! |
35 Constructor |
36 Constructor. |
36 Creates the CImImap4Settings instance for loading and saving the IMAP4 settings. |
37 Creates the CImImap4Settings instance for loading and saving the IMAP4 settings. |
37 Finds and loads the SMTP account and settings linked to the IMAP4 account. |
38 Finds and loads the SMTP account and settings linked to the IMAP4 account. |
38 \param mailboxId Mailbox identifier. |
39 \param mailboxId Mailbox identifier. |
39 \param account CEmailAccounts created by the settings manager factory. Takes ownership. |
40 \param account CEmailAccounts created by the settings manager factory. Takes ownership. |
40 \param imapAccount TImapAccount of the mailbox. |
41 \param imapAccount TImapAccount of the mailbox. |
51 TRAP_IGNORE(mAccount->GetSmtpAccountL(mImap4Account.iSmtpService, mSmtpAccount)); |
52 TRAP_IGNORE(mAccount->GetSmtpAccountL(mImap4Account.iSmtpService, mSmtpAccount)); |
52 TRAP_IGNORE(mAccount->LoadSmtpSettingsL(mSmtpAccount, *mSmtpSettings)); |
53 TRAP_IGNORE(mAccount->LoadSmtpSettingsL(mSmtpAccount, *mSmtpSettings)); |
53 } |
54 } |
54 |
55 |
55 /*! |
56 /*! |
56 Destructor |
57 Destructor. |
57 */ |
58 */ |
58 NmIpsImap4SettingsManager::~NmIpsImap4SettingsManager() |
59 NmIpsImap4SettingsManager::~NmIpsImap4SettingsManager() |
59 { |
60 { |
60 delete mImap4Settings; |
61 delete mImap4Settings; |
61 } |
62 } |
64 Finds and returns settings for the account. |
65 Finds and returns settings for the account. |
65 \param settingItem SettingItem enum of the setting to return. |
66 \param settingItem SettingItem enum of the setting to return. |
66 \param QVariant SettingValue of the found setting value. |
67 \param QVariant SettingValue of the found setting value. |
67 \return <true> when the setting item was found otherwise <false>. |
68 \return <true> when the setting item was found otherwise <false>. |
68 */ |
69 */ |
69 bool NmIpsImap4SettingsManager::readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue) |
70 bool NmIpsImap4SettingsManager::readSetting(IpsServices::SettingItem settingItem, |
|
71 QVariant &settingValue) |
70 { |
72 { |
71 bool found(false); |
73 bool found(false); |
72 switch (settingItem) { |
74 switch (settingItem) { |
73 case IpsServices::IncomingLoginName: |
75 case IpsServices::IncomingLoginName: |
74 settingValue = XQConversions::s60Desc8ToQString(mImap4Settings->LoginName()); |
76 settingValue = XQConversions::s60Desc8ToQString(mImap4Settings->LoginName()); |
99 found = true; |
101 found = true; |
100 break; |
102 break; |
101 case IpsServices::IncomingSSLWrapper: |
103 case IpsServices::IncomingSSLWrapper: |
102 settingValue = mImap4Settings->SSLWrapper(); |
104 settingValue = mImap4Settings->SSLWrapper(); |
103 found = true; |
105 found = true; |
104 break; |
106 break; |
105 default: |
107 default: |
106 found = NmIpsSettingsManagerBase::readSetting(settingItem, settingValue); |
108 found = NmIpsSettingsManagerBase::readSetting(settingItem, settingValue); |
107 break; |
109 break; |
108 } |
110 } |
109 return found; |
111 return found; |
113 Writes IMAP4 specific settings or passes SMTP and extended settings to the base class. |
115 Writes IMAP4 specific settings or passes SMTP and extended settings to the base class. |
114 \param settingItem SettingItem enum of the setting to replace. |
116 \param settingItem SettingItem enum of the setting to replace. |
115 \param settingValue QVariant of the new setting value. |
117 \param settingValue QVariant of the new setting value. |
116 \return bool <true> when the setting item was succesfully written, otherwise <false>. |
118 \return bool <true> when the setting item was succesfully written, otherwise <false>. |
117 */ |
119 */ |
118 bool NmIpsImap4SettingsManager::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue) |
120 bool NmIpsImap4SettingsManager::writeSetting(IpsServices::SettingItem settingItem, |
|
121 const QVariant &settingValue) |
119 { |
122 { |
120 HBufC *tmp = 0; |
123 HBufC *tmp = 0; |
121 HBufC8 *tmp8 = 0; |
124 HBufC8 *tmp8 = 0; |
122 |
125 |
123 bool ret(false); |
126 bool ret(false); |
172 break; |
175 break; |
173 case IpsServices::IncomingSSLWrapper: |
176 case IpsServices::IncomingSSLWrapper: |
174 mImap4Settings->SetSSLWrapper(settingValue.toBool()); |
177 mImap4Settings->SetSSLWrapper(settingValue.toBool()); |
175 ret = saveSettings(); |
178 ret = saveSettings(); |
176 break; |
179 break; |
|
180 case IpsServices::Connection: |
|
181 ret = saveIAPSettings(settingValue.toUInt()); |
|
182 // Fallthrough so SMTP IAP settings are also updated accordingly. |
177 default: |
183 default: |
178 ret = NmIpsSettingsManagerBase::writeSetting(settingItem, settingValue); |
184 ret = NmIpsSettingsManagerBase::writeSetting(settingItem, settingValue); |
179 break; |
185 break; |
180 } |
186 } |
181 return ret; |
187 return ret; |
182 } |
188 } |
183 |
189 |
184 /*! |
190 /*! |
185 Deletes the IMAP4 mailbox. |
191 Deletes the IMAP4 mailbox. |
186 |
|
187 \return Error code <code>0</code> if mailbox deletion was successful, otherwise error |
192 \return Error code <code>0</code> if mailbox deletion was successful, otherwise error |
188 code is returned. |
193 code is returned. |
189 */ |
194 */ |
190 int NmIpsImap4SettingsManager::deleteMailbox() |
195 int NmIpsImap4SettingsManager::deleteMailbox() |
191 { |
196 { |
196 |
201 |
197 NMLOG(QString("NmIpsImap4SettingsManager::deleteMailbox status %1").arg(error)); |
202 NMLOG(QString("NmIpsImap4SettingsManager::deleteMailbox status %1").arg(error)); |
198 return error; |
203 return error; |
199 } |
204 } |
200 |
205 |
|
206 |
|
207 /*! |
|
208 Determines the default port for the incoming mail server based on the security settings. |
|
209 \return The port number to use. |
|
210 */ |
|
211 int NmIpsImap4SettingsManager::determineDefaultIncomingPort() |
|
212 { |
|
213 int port(IpsServices::standardImap4Port); |
|
214 if (mImap4Settings->SSLWrapper()) { |
|
215 port = IpsServices::imap4OverSslPort; |
|
216 } |
|
217 return port; |
|
218 } |
|
219 |
201 /*! |
220 /*! |
202 Stores the IMAP4 specific settings. |
221 Stores the IMAP4 specific settings. |
203 \return bool <true> when the IMAP4 settings were succesfully written, otherwise <false>. |
222 \return bool <true> when the IMAP4 settings were succesfully written, otherwise <false>. |
204 */ |
223 */ |
205 bool NmIpsImap4SettingsManager::saveSettings() |
224 bool NmIpsImap4SettingsManager::saveSettings() |
208 NMLOG(QString("NmIpsImap4SettingsManager::saveSettings rval %1").arg(err)); |
227 NMLOG(QString("NmIpsImap4SettingsManager::saveSettings rval %1").arg(err)); |
209 return (err==KErrNone); |
228 return (err==KErrNone); |
210 } |
229 } |
211 |
230 |
212 /*! |
231 /*! |
213 Determine the default port for the incoming mail server based on the security settings |
232 Stores the IMAP4 specific IAP settings. |
214 |
233 \return bool <true> when the IMAP4 IAP settings were succesfully written, otherwise <false>. |
215 \return int the port number to use |
234 */ |
216 */ |
235 bool NmIpsImap4SettingsManager::saveIAPSettings(uint snapId) |
217 int NmIpsImap4SettingsManager::determineDefaultIncomingPort() |
236 { |
218 { |
237 TRAPD(err, |
219 int port = 0; |
238 CImIAPPreferences *prefs = CImIAPPreferences::NewLC(); |
220 bool sslTls = mImap4Settings->SSLWrapper(); |
239 mAccount->LoadImapIapSettingsL(mImap4Account, *prefs); |
221 if (sslTls) { |
240 prefs->SetSNAPL(snapId); |
222 port = IpsServices::imap4OverSslPort; |
241 mAccount->SaveImapIapSettingsL(mImap4Account, *prefs); |
223 } else { |
242 CleanupStack::PopAndDestroy(prefs); |
224 port = IpsServices::standardImap4Port; |
243 ); |
225 } |
244 return (err==KErrNone); |
226 return port; |
245 } |
227 } |
|