38 Creates the NmIpsSettingsManagerBase for loading and saving mailbox specific settings. |
38 Creates the NmIpsSettingsManagerBase for loading and saving mailbox specific settings. |
39 Finds and loads the SMTP account and settings linked to the given POP3 or IMAP account. |
39 Finds and loads the SMTP account and settings linked to the given POP3 or IMAP account. |
40 \param mailboxId Mailbox identifier. |
40 \param mailboxId Mailbox identifier. |
41 \param account CEmailAccounts created by the settings manager factory. Takes ownership after |
41 \param account CEmailAccounts created by the settings manager factory. Takes ownership after |
42 successful construction. |
42 successful construction. |
43 */ |
43 \param accountType AccountType identifier. |
44 NmIpsSettingsManagerBase::NmIpsSettingsManagerBase(const NmId &mailboxId, CEmailAccounts *account) |
44 */ |
45 : mMailboxId(mailboxId.id()) |
45 NmIpsSettingsManagerBase::NmIpsSettingsManagerBase(const NmId &mailboxId, CEmailAccounts *account, |
|
46 IpsServices::TIpsSetAccountTypes accountType) |
|
47 : mAccountType(accountType), |
|
48 mMailboxId(mailboxId.id()) |
46 { |
49 { |
47 QScopedPointer<NmIpsExtendedSettingsManager> extendedSettings(new NmIpsExtendedSettingsManager(mailboxId)); |
50 QScopedPointer<NmIpsExtendedSettingsManager> extendedSettings(new NmIpsExtendedSettingsManager(mailboxId)); |
48 |
51 |
49 QT_TRAP_THROWING(mSmtpSettings = new(ELeave) CImSmtpSettings()); |
52 QT_TRAP_THROWING(mSmtpSettings = new(ELeave) CImSmtpSettings()); |
50 |
53 |
71 \return bool <true> when the setting item was found otherwise <false>. |
74 \return bool <true> when the setting item was found otherwise <false>. |
72 */ |
75 */ |
73 bool NmIpsSettingsManagerBase::readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue) |
76 bool NmIpsSettingsManagerBase::readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue) |
74 { |
77 { |
75 bool found(false); |
78 bool found(false); |
|
79 |
76 switch (settingItem) { |
80 switch (settingItem) { |
77 case IpsServices::EmailAlias: |
81 case IpsServices::EmailAlias: |
78 settingValue = XQConversions::s60DescToQString(mSmtpSettings->EmailAlias()); |
82 settingValue = XQConversions::s60DescToQString(mSmtpSettings->EmailAlias()); |
79 found = true; |
83 found = true; |
80 break; |
84 break; |
84 break; |
88 break; |
85 case IpsServices::ReplyAddress: |
89 case IpsServices::ReplyAddress: |
86 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ReplyToAddress()); |
90 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ReplyToAddress()); |
87 found = true; |
91 found = true; |
88 break; |
92 break; |
|
93 case IpsServices::OutgoingMailServer: |
|
94 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ServerAddress()); |
|
95 found = true; |
|
96 break; |
|
97 case IpsServices::OutgoingPort: |
|
98 settingValue = mSmtpSettings->Port(); |
|
99 found = true; |
|
100 break; |
|
101 case IpsServices::OutgoingLoginName: |
|
102 settingValue = XQConversions::s60Desc8ToQString(mSmtpSettings->LoginName()); |
|
103 found = true; |
|
104 break; |
|
105 case IpsServices::OutgoingPassword: |
|
106 settingValue = XQConversions::s60Desc8ToQString(mSmtpSettings->Password()); |
|
107 found = true; |
|
108 break; |
|
109 case IpsServices::SMTPAuthentication: |
|
110 settingValue = mSmtpSettings->SMTPAuth(); |
|
111 found = true; |
|
112 break; |
|
113 case IpsServices::OutgoingSecureSockets: |
|
114 settingValue = mSmtpSettings->SecureSockets(); |
|
115 found = true; |
|
116 break; |
|
117 case IpsServices::OutgoingSSLWrapper: |
|
118 settingValue = mSmtpSettings->SSLWrapper(); |
|
119 found = true; |
|
120 break; |
89 default: |
121 default: |
90 found = mExtendedSettingsManager->readSetting(settingItem, settingValue); |
122 found = mExtendedSettingsManager->readSetting(settingItem, settingValue); |
91 break; |
123 break; |
92 } |
124 } |
93 return found; |
125 return found; |
100 \return bool <true> when the setting item was succesfully written, otherwise <false>. |
132 \return bool <true> when the setting item was succesfully written, otherwise <false>. |
101 */ |
133 */ |
102 bool NmIpsSettingsManagerBase::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue) |
134 bool NmIpsSettingsManagerBase::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue) |
103 { |
135 { |
104 HBufC *tmp = 0; |
136 HBufC *tmp = 0; |
105 |
137 HBufC8 *tmp8 = 0; |
|
138 |
106 bool ret(false); |
139 bool ret(false); |
107 TInt err(KErrNone); |
140 TInt err(KErrNone); |
108 |
141 |
109 switch (settingItem) { |
142 switch (settingItem) { |
110 case IpsServices::EmailAlias: |
143 case IpsServices::EmailAlias: |
129 delete tmp; |
162 delete tmp; |
130 if (err==KErrNone) { |
163 if (err==KErrNone) { |
131 ret = saveSettings(); |
164 ret = saveSettings(); |
132 } |
165 } |
133 break; |
166 break; |
|
167 case IpsServices::OutgoingMailServer: |
|
168 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
169 TRAP(err, mSmtpSettings->SetServerAddressL(*tmp)); |
|
170 delete tmp; |
|
171 if (err==KErrNone) { |
|
172 ret = saveSettings(); |
|
173 } |
|
174 break; |
|
175 case IpsServices::OutgoingPort: |
|
176 mSmtpSettings->SetPort(settingValue.toInt()); |
|
177 ret = saveSettings(); |
|
178 break; |
|
179 case IpsServices::OutgoingLoginName: |
|
180 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
181 TRAP(err, mSmtpSettings->SetLoginNameL(*tmp8)); |
|
182 delete tmp8; |
|
183 if (err==KErrNone) { |
|
184 ret = saveSettings(); |
|
185 } |
|
186 break; |
|
187 case IpsServices::OutgoingPassword: |
|
188 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
189 TRAP(err, mSmtpSettings->SetPasswordL(*tmp8)); |
|
190 delete tmp8; |
|
191 if (err==KErrNone) { |
|
192 ret = saveSettings(); |
|
193 } |
|
194 break; |
|
195 case IpsServices::SMTPAuthentication: |
|
196 mSmtpSettings->SetSMTPAuth((settingValue.toBool())); |
|
197 ret = saveSettings(); |
|
198 break; |
|
199 case IpsServices::OutgoingSecureSockets: |
|
200 mSmtpSettings->SetSecureSockets(settingValue.toBool()); |
|
201 ret = saveSettings(); |
|
202 break; |
|
203 case IpsServices::OutgoingSSLWrapper: |
|
204 mSmtpSettings->SetSSLWrapper(settingValue.toBool()); |
|
205 ret = saveSettings(); |
|
206 break; |
134 default: |
207 default: |
135 ret = mExtendedSettingsManager->writeSetting(settingItem, settingValue); |
208 ret = mExtendedSettingsManager->writeSetting(settingItem, settingValue); |
136 break; |
209 break; |
137 } |
210 } |
138 return ret; |
211 return ret; |
164 } |
237 } |
165 |
238 |
166 /*! |
239 /*! |
167 NmId for the mailbox. |
240 NmId for the mailbox. |
168 */ |
241 */ |
169 NmId& NmIpsSettingsManagerBase::mailboxId() |
242 NmId NmIpsSettingsManagerBase::mailboxId() const |
170 { |
243 { |
171 return mMailboxId; |
244 return mMailboxId; |
172 } |
245 } |
|
246 |
|
247 /*! |
|
248 Mailbox account type. |
|
249 */ |
|
250 IpsServices::TIpsSetAccountTypes NmIpsSettingsManagerBase::accountType() const |
|
251 { |
|
252 return mAccountType; |
|
253 } |
|
254 |
|
255 /*! |
|
256 Determine the default port for the outgoing mail server based on the security settings |
|
257 |
|
258 \return int the port number to use |
|
259 */ |
|
260 int NmIpsSettingsManagerBase::determineDefaultOutgoingPort() |
|
261 { |
|
262 int port = 0; |
|
263 bool sslTls = mSmtpSettings->SSLWrapper(); |
|
264 if (sslTls) { |
|
265 port = IpsServices::secureSmtpPort; |
|
266 } else { |
|
267 port = IpsServices::standardSmtpPort; |
|
268 } |
|
269 return port; |
|
270 } |
|
271 |
|
272 /*! |
|
273 |
|
274 */ |
|
275 NmIpsExtendedSettingsManager &NmIpsSettingsManagerBase::extendedSettingsManager() const |
|
276 { |
|
277 return *mExtendedSettingsManager; |
|
278 } |
|
279 |