30 */ |
31 */ |
31 |
32 |
32 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
33 |
34 |
34 /*! |
35 /*! |
35 Constructor |
36 Constructor. |
36 Creates the CImPop4Settings instance for loading and saving the POP3 settings. |
37 Creates the CImPop4Settings instance for loading and saving the POP3 settings. |
37 Finds and loads the SMTP account and settings linked to the POP3 account. |
38 Finds and loads the SMTP account and settings linked to the POP3 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. |
63 Finds and returns settings for the account. |
64 Finds and returns settings for the account. |
64 \param settingItem SettingItem enum of the setting to return. |
65 \param settingItem SettingItem enum of the setting to return. |
65 \param QVariant SettingValue of the found setting value. |
66 \param QVariant SettingValue of the found setting value. |
66 \return <true> when the setting item was found otherwise <false>. |
67 \return <true> when the setting item was found otherwise <false>. |
67 */ |
68 */ |
68 bool NmIpsPop3SettingsManager::readSetting(IpsServices::SettingItem settingItem, QVariant &value) |
69 bool NmIpsPop3SettingsManager::readSetting(IpsServices::SettingItem settingItem, |
|
70 QVariant &settingValue) |
69 { |
71 { |
70 bool found(false); |
72 bool found(false); |
71 switch (settingItem) { |
73 switch (settingItem) { |
72 case IpsServices::IncomingLoginName: |
74 case IpsServices::IncomingLoginName: |
73 value = XQConversions::s60Desc8ToQString(mPop3Settings->LoginName()); |
75 settingValue = XQConversions::s60Desc8ToQString(mPop3Settings->LoginName()); |
74 found = true; |
76 found = true; |
75 break; |
77 break; |
76 case IpsServices::IncomingPassword: |
78 case IpsServices::IncomingPassword: |
77 value = XQConversions::s60Desc8ToQString(mPop3Settings->Password()); |
79 settingValue = XQConversions::s60Desc8ToQString(mPop3Settings->Password()); |
78 found = true; |
80 found = true; |
79 break; |
81 break; |
80 case IpsServices::MailboxName: |
82 case IpsServices::MailboxName: |
81 value = XQConversions::s60DescToQString(mPop3Account.iPopAccountName); |
83 settingValue = XQConversions::s60DescToQString(mPop3Account.iPopAccountName); |
82 found = true; |
84 found = true; |
83 break; |
85 break; |
84 case IpsServices::IncomingMailServer: |
86 case IpsServices::IncomingMailServer: |
85 value = XQConversions::s60DescToQString(mPop3Settings->ServerAddress()); |
87 settingValue = XQConversions::s60DescToQString(mPop3Settings->ServerAddress()); |
86 found = true; |
88 found = true; |
87 break; |
89 break; |
88 case IpsServices::IncomingPort: |
90 case IpsServices::IncomingPort: |
89 value = mPop3Settings->Port(); |
91 settingValue = mPop3Settings->Port(); |
90 found = true; |
92 found = true; |
91 break; |
93 break; |
92 case IpsServices::IncomingSecureSockets: |
94 case IpsServices::IncomingSecureSockets: |
93 value = mPop3Settings->SecureSockets(); |
95 settingValue = mPop3Settings->SecureSockets(); |
94 found = true; |
96 found = true; |
95 break; |
97 break; |
96 case IpsServices::IncomingSSLWrapper: |
98 case IpsServices::IncomingSSLWrapper: |
97 value = mPop3Settings->SSLWrapper(); |
99 settingValue = mPop3Settings->SSLWrapper(); |
98 found = true; |
100 found = true; |
99 break; |
101 break; |
100 default: |
102 default: |
101 found = NmIpsSettingsManagerBase::readSetting(settingItem, value); |
103 found = NmIpsSettingsManagerBase::readSetting(settingItem, settingValue); |
102 break; |
104 break; |
103 } |
105 } |
104 return found; |
106 return found; |
105 } |
107 } |
106 |
108 |
107 /*! |
109 /*! |
108 Writes POP3 specific settings or passes SMTP and extended settings to the base class. |
110 Writes POP3 specific settings or passes SMTP and extended settings to the base class. |
109 \param settingItem SettingItem enum of the setting to replace. |
111 \param settingItem SettingItem enum of the setting to replace. |
110 \param settingValue QVariant of the new setting value. |
112 \param settingValue QVariant of the new setting value. |
111 */ |
113 */ |
112 bool NmIpsPop3SettingsManager::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue) |
114 bool NmIpsPop3SettingsManager::writeSetting(IpsServices::SettingItem settingItem, |
|
115 const QVariant &settingValue) |
113 { |
116 { |
114 HBufC *tmp = 0; |
117 HBufC *tmp = 0; |
115 HBufC8 *tmp8 = 0; |
118 HBufC8 *tmp8 = 0; |
116 |
119 |
117 bool ret(false); |
120 bool ret(false); |
157 ret = saveSettings(); |
160 ret = saveSettings(); |
158 break; |
161 break; |
159 case IpsServices::IncomingSSLWrapper: |
162 case IpsServices::IncomingSSLWrapper: |
160 mPop3Settings->SetSSLWrapper(settingValue.toBool()); |
163 mPop3Settings->SetSSLWrapper(settingValue.toBool()); |
161 ret = saveSettings(); |
164 ret = saveSettings(); |
162 break; |
165 break; |
|
166 case IpsServices::Connection: |
|
167 ret = saveIAPSettings(settingValue.toUInt()); |
|
168 // Fallthrough so SMTP IAP settings are also updated accordingly. |
163 default: |
169 default: |
164 ret = NmIpsSettingsManagerBase::writeSetting(settingItem, settingValue); |
170 ret = NmIpsSettingsManagerBase::writeSetting(settingItem, settingValue); |
165 break; |
171 break; |
166 } |
172 } |
167 return ret; |
173 return ret; |
168 } |
174 } |
169 |
175 |
170 /*! |
176 /*! |
171 Deletes the POP3 mailbox. |
177 Deletes the POP3 mailbox. |
172 |
|
173 \return Error code <code>0</code> if mailbox deletion was successful, otherwise error |
178 \return Error code <code>0</code> if mailbox deletion was successful, otherwise error |
174 code is returned. |
179 code is returned. |
175 */ |
180 */ |
176 int NmIpsPop3SettingsManager::deleteMailbox() |
181 int NmIpsPop3SettingsManager::deleteMailbox() |
177 { |
182 { |
183 NMLOG(QString("NmIpsPop3SettingsManager::deleteMailbox status %1").arg(error)); |
188 NMLOG(QString("NmIpsPop3SettingsManager::deleteMailbox status %1").arg(error)); |
184 return error; |
189 return error; |
185 } |
190 } |
186 |
191 |
187 /*! |
192 /*! |
|
193 Determines the default port for the incoming mail server based on the security settings. |
|
194 \return The port number to use. |
|
195 */ |
|
196 int NmIpsPop3SettingsManager::determineDefaultIncomingPort() |
|
197 { |
|
198 int port(IpsServices::standardPop3Port); |
|
199 if (mPop3Settings->SSLWrapper()) { |
|
200 port = IpsServices::securePop3Port; |
|
201 } |
|
202 return port; |
|
203 } |
|
204 |
|
205 /*! |
188 Stores the POP3 specific settings. |
206 Stores the POP3 specific settings. |
189 \return bool <true> when the POP3 settings were succesfully written, otherwise <false>. |
207 \return bool <true> when the POP3 settings were succesfully written, otherwise <false>. |
190 */ |
208 */ |
191 bool NmIpsPop3SettingsManager::saveSettings() |
209 bool NmIpsPop3SettingsManager::saveSettings() |
192 { |
210 { |
194 NMLOG(QString("NmIpsPop3SettingsManager::saveSettings rval %1").arg(err)); |
212 NMLOG(QString("NmIpsPop3SettingsManager::saveSettings rval %1").arg(err)); |
195 return (err==KErrNone); |
213 return (err==KErrNone); |
196 } |
214 } |
197 |
215 |
198 /*! |
216 /*! |
199 Determine the default port for the incoming mail server based on the security settings |
217 Stores the POP3 specific IAP settings. |
200 |
218 \return bool <true> when the POP3 IAP settings were succesfully written, otherwise <false>. |
201 \return int the port number to use |
219 */ |
202 */ |
220 bool NmIpsPop3SettingsManager::saveIAPSettings(uint snapId) |
203 int NmIpsPop3SettingsManager::determineDefaultIncomingPort() |
221 { |
204 { |
222 TRAPD(err, |
205 int port = 0; |
223 CImIAPPreferences *prefs = CImIAPPreferences::NewLC(); |
206 bool sslTls = mPop3Settings->SSLWrapper(); |
224 mAccount->LoadPopIapSettingsL(mPop3Account, *prefs); |
207 if (sslTls) { |
225 prefs->SetSNAPL(snapId); |
208 port = IpsServices::securePop3Port; |
226 mAccount->SavePopIapSettingsL(mPop3Account, *prefs); |
209 } else { |
227 CleanupStack::PopAndDestroy(prefs); |
210 port = IpsServices::standardPop3Port; |
228 ); |
211 } |
229 return (err==KErrNone); |
212 return port; |
230 } |
213 } |
|