132 data.setValue(OutgoingPassword, XQConversions::s60Desc8ToQString(mSmtpSettings->Password())); |
141 data.setValue(OutgoingPassword, XQConversions::s60Desc8ToQString(mSmtpSettings->Password())); |
133 data.setValue(UseOutgoingAuthentication, mSmtpSettings->SMTPAuth()); |
142 data.setValue(UseOutgoingAuthentication, mSmtpSettings->SMTPAuth()); |
134 data.setValue(OutgoingMailUsesAuthentication, mSmtpSettings->SMTPAuth()); |
143 data.setValue(OutgoingMailUsesAuthentication, mSmtpSettings->SMTPAuth()); |
135 data.setValue(OutgoingSecureSockets, mSmtpSettings->SecureSockets()); |
144 data.setValue(OutgoingSecureSockets, mSmtpSettings->SecureSockets()); |
136 data.setValue(OutgoingSSLWrapper, mSmtpSettings->SSLWrapper()); |
145 data.setValue(OutgoingSSLWrapper, mSmtpSettings->SSLWrapper()); |
137 data.setValue(OutgoingMailSecurityType, XQConversions::s60Desc8ToQString(mSmtpSettings->TlsSslDomain())); |
146 data.setValue(OutgoingMailSecurityType, security(*mSmtpSettings)); |
138 return true; |
147 } |
139 } |
148 |
140 |
149 /*! |
141 bool NmApiSettingsManagerPrivate::readCenRepSetting(NmApiMailboxSettingsData &data) |
150 Returns the Central Repository setting. Sets given boolen parameter to <false> |
142 { |
151 if error happens. If no error happens boolean status is not changed. |
143 bool ret = true; |
152 \param cenRepKey Central repository key |
144 QVariant tmp; |
153 \param success Boolean which is set to <false> if some other error than |
145 data.setValue(DownloadPictures, readFromCenRep(IpsServices::EmailKeyPreferenceDownloadPictures)); |
154 XQSettingsManager::NotFoundError occurs. |
146 data.setValue(MessageDivider, readFromCenRep(IpsServices::EmailKeyPreferenceMessageDivider)); |
155 Note! Variable is never set to <true>. |
147 |
156 \return QVariant The settings value for the given key. |
148 tmp = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile); |
157 */ |
149 switch(tmp.toInt()){ |
158 QVariant NmApiSettingsManagerPrivate::readFromCenRep(quint32 key, |
150 case 0: |
159 bool &success) const |
151 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetKUTD); |
160 { |
152 break; |
161 QVariant setting = readFromCenRep(key); |
153 case 1: |
162 |
154 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetSE); |
163 /* |
155 break; |
164 XQSettingsManager::NotFoundError occurs if some setting is not found from the cenrep. |
156 case 2: |
165 This is a valid case since all accounts doesn't neccessarily have all possible settings. |
157 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetMF); |
166 All other errors are "real" errors and those are indicated to the API user. |
158 break; |
167 */ |
159 case 3: |
168 if (setting.isNull() |
160 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetUD); |
169 && mQSettingsManager->error() != XQSettingsManager::NotFoundError) { |
161 break; |
170 success = false; |
162 default: |
171 } |
163 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetKUTD); |
172 |
164 break; |
173 return setting; |
165 }; |
174 } |
166 |
175 |
167 data.setValue(ReceptionUserDefinedProfile, readFromCenRep(IpsServices::EmailKeyReceptionUserDefinedProfile)); |
176 bool NmApiSettingsManagerPrivate::readCenRepSettings(NmApiMailboxSettingsData &data) |
|
177 { |
|
178 bool retVal = true; |
|
179 |
|
180 data.setValue(DownloadPictures, |
|
181 readFromCenRep(IpsServices::EmailKeyPreferenceDownloadPictures, retVal)); |
|
182 data.setValue(MessageDivider, |
|
183 readFromCenRep(IpsServices::EmailKeyPreferenceMessageDivider, retVal)); |
|
184 |
|
185 QVariant activeProfileSetting = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile, retVal); |
|
186 |
|
187 if (!activeProfileSetting.isNull()) { |
|
188 switch (activeProfileSetting.toInt()) { |
|
189 case IpsServices::EmailSyncProfileKeepUpToDate: |
|
190 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetKUTD); |
|
191 break; |
|
192 case IpsServices::EmailSyncProfileSaveEnergy: |
|
193 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetSE); |
|
194 break; |
|
195 case IpsServices::EmailSyncProfileManualFetch: |
|
196 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetMF); |
|
197 break; |
|
198 case IpsServices::EmailSyncProfileUserDefined: |
|
199 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetUD); |
|
200 break; |
|
201 default: |
|
202 data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetKUTD); |
|
203 break; |
|
204 } |
|
205 } |
|
206 |
|
207 data.setValue(ReceptionUserDefinedProfile, readFromCenRep( |
|
208 IpsServices::EmailKeyReceptionUserDefinedProfile, retVal)); |
168 data.setValue(ReceptionInboxSyncWindow, readFromCenRep(mActiveProfileOffset |
209 data.setValue(ReceptionInboxSyncWindow, readFromCenRep(mActiveProfileOffset |
169 + IpsServices::EmailKeyReceptionInboxSyncWindow)); |
210 + IpsServices::EmailKeyReceptionInboxSyncWindow, retVal)); |
170 data.setValue(ReceptionGenericSyncWindowInMessages, readFromCenRep(mActiveProfileOffset |
211 data.setValue(ReceptionGenericSyncWindowInMessages, readFromCenRep(mActiveProfileOffset |
171 + IpsServices::EmailKeyReceptionGenericSyncWindowInMessages)); |
212 + IpsServices::EmailKeyReceptionGenericSyncWindowInMessages, retVal)); |
172 data.setValue(ReceptionWeekDays, readFromCenRep(mActiveProfileOffset |
213 data.setValue(ReceptionWeekDays, readFromCenRep(mActiveProfileOffset |
173 + IpsServices::EmailKeyReceptionWeekDays)); |
214 + IpsServices::EmailKeyReceptionWeekDays, retVal)); |
174 data.setValue(ReceptionDayStartTime, readFromCenRep(mActiveProfileOffset |
215 data.setValue(ReceptionDayStartTime, readFromCenRep(mActiveProfileOffset |
175 + IpsServices::EmailKeyReceptionDayStartTime)); |
216 + IpsServices::EmailKeyReceptionDayStartTime, retVal)); |
176 data.setValue(ReceptionDayEndTime, readFromCenRep(mActiveProfileOffset |
217 data.setValue(ReceptionDayEndTime, readFromCenRep(mActiveProfileOffset |
177 + IpsServices::EmailKeyReceptionDayEndTime)); |
218 + IpsServices::EmailKeyReceptionDayEndTime, retVal)); |
178 data.setValue(ReceptionRefreshPeriodDayTime, readFromCenRep(mActiveProfileOffset |
219 data.setValue(ReceptionRefreshPeriodDayTime, readFromCenRep(mActiveProfileOffset |
179 + IpsServices::EmailKeyReceptionRefreshPeriodDayTime)); |
220 + IpsServices::EmailKeyReceptionRefreshPeriodDayTime, retVal)); |
180 data.setValue(ReceptionRefreshPeriodOther, readFromCenRep(mActiveProfileOffset |
221 data.setValue(ReceptionRefreshPeriodOther, readFromCenRep(mActiveProfileOffset |
181 + IpsServices::EmailKeyReceptionRefreshPeriodOther)); |
222 + IpsServices::EmailKeyReceptionRefreshPeriodOther, retVal)); |
182 data.setValue(UserNameHidden, readFromCenRep(IpsServices::EmailKeyUserNameHidden)); |
223 data.setValue(UserNameHidden, readFromCenRep(IpsServices::EmailKeyUserNameHidden, retVal)); |
183 data.setValue(EmailNotificationState, readFromCenRep(IpsServices::EmailKeyEMNState)); |
224 data.setValue(EmailNotificationState, readFromCenRep(IpsServices::EmailKeyEMNState, retVal)); |
184 data.setValue(FirstEmnReceived, readFromCenRep(IpsServices::EmailKeyFirstEmnReceived)); |
225 data.setValue(FirstEmnReceived, readFromCenRep(IpsServices::EmailKeyFirstEmnReceived, retVal)); |
185 data.setValue(EmnReceivedNotSynced, readFromCenRep(IpsServices::EmailKeyEmnReceivedNotSynced)); |
226 data.setValue(EmnReceivedNotSynced, readFromCenRep( |
186 |
227 IpsServices::EmailKeyEmnReceivedNotSynced, retVal)); |
187 QString aolState = alwaysOnlineState(); |
228 data.setValue(AlwaysOnlineState, alwaysOnlineState(retVal)); |
188 if(aolState.length()>0) |
229 |
189 data.setValue(AlwaysOnlineState, aolState); |
230 data.setValue(AoLastSuccessfulUpdate, readFromCenRep( |
190 |
231 IpsServices::EmailKeyAoLastSuccessfulUpdateL, retVal)); |
191 data.setValue(AoLastSuccessfulUpdate, readFromCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateL)); |
232 data.setValue(AoLastUpdateFailed, readFromCenRep( |
192 data.setValue(AoLastUpdateFailed, readFromCenRep(IpsServices::EmailKeyAoLastUpdateFailed)); |
233 IpsServices::EmailKeyAoLastUpdateFailed, retVal)); |
193 data.setValue(AoUpdateSuccessfulWithCurSettings, readFromCenRep(IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings)); |
234 data.setValue(AoUpdateSuccessfulWithCurSettings, readFromCenRep( |
194 return ret; |
235 IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings, retVal)); |
|
236 return retVal; |
|
237 } |
|
238 |
|
239 void NmApiSettingsManagerPrivate::fillImapSettingDataL(const NmApiMailboxSettingsData &data) |
|
240 { |
|
241 int key = -1; |
|
242 QVariant settingValue; |
|
243 QList<int> keylist = data.listSettings(); |
|
244 |
|
245 for (int i = 0; i < keylist.size(); i++) { |
|
246 key = keylist[i]; |
|
247 if (data.getValue(key, settingValue) && !settingValue.isNull()) { |
|
248 switch (key) { |
|
249 case IncomingLoginName: |
|
250 mImap4Settings->SetLoginNameL(*StringToS60HBufC8LC(settingValue.toString())); |
|
251 CleanupStack::PopAndDestroy(); |
|
252 break; |
|
253 case IncomingPassword: |
|
254 mImap4Settings->SetPasswordL(*StringToS60HBufC8LC(settingValue.toString())); |
|
255 CleanupStack::PopAndDestroy(); |
|
256 break; |
|
257 case MailboxName: |
|
258 mImap4Account.iImapAccountName.Copy(StringToS60TPtrC(settingValue.toString())); |
|
259 break; |
|
260 case IncomingMailServer: |
|
261 mImap4Settings->SetServerAddressL(StringToS60TPtrC(settingValue.toString())); |
|
262 break; |
|
263 case IncomingMailUsesAuthentication: |
|
264 #if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT) |
|
265 mImap4Settings->SetIAMP4Auth(settingValue.toBool()); |
|
266 #endif |
|
267 break; |
|
268 case FolderPath: |
|
269 mImap4Settings->SetFolderPathL(*StringToS60HBufC8LC(settingValue.toString())); |
|
270 CleanupStack::PopAndDestroy(); |
|
271 break; |
|
272 case IncomingMailSecurityType: |
|
273 setSecurity(*mImap4Settings, settingValue.toString()); |
|
274 break; |
|
275 case IncomingPort: |
|
276 mImap4Settings->SetPort(settingValue.toInt()); |
|
277 break; |
|
278 case IncomingSecureSockets: |
|
279 mImap4Settings->SetSecureSockets(settingValue.toBool()); |
|
280 break; |
|
281 case IncomingSSLWrapper: |
|
282 mImap4Settings->SetSSLWrapper(settingValue.toBool()); |
|
283 break; |
|
284 default: |
|
285 fillSmtpSettingDataL(data, settingValue, key); |
|
286 break; |
|
287 } |
|
288 } |
|
289 } |
|
290 } |
|
291 |
|
292 void NmApiSettingsManagerPrivate::fillPopSettingDataL(const NmApiMailboxSettingsData &data) |
|
293 { |
|
294 int key = -1; |
|
295 QVariant settingValue; |
|
296 QList<int> keylist = data.listSettings(); |
|
297 |
|
298 for (int i = 0; i < keylist.size(); i++) { |
|
299 key = keylist[i]; |
|
300 if (data.getValue(key, settingValue) && !settingValue.isNull()) { |
|
301 switch (key) { |
|
302 case IncomingLoginName: |
|
303 mPop3Settings->SetLoginNameL(*StringToS60HBufC8LC(settingValue.toString())); |
|
304 CleanupStack::PopAndDestroy(); |
|
305 break; |
|
306 case IncomingPassword: |
|
307 mPop3Settings->SetPasswordL(*StringToS60HBufC8LC(settingValue.toString())); |
|
308 CleanupStack::PopAndDestroy(); |
|
309 break; |
|
310 case MailboxName: |
|
311 mPop3Account.iPopAccountName.Copy(StringToS60TPtrC(settingValue.toString())); |
|
312 break; |
|
313 case IncomingMailServer: |
|
314 mPop3Settings->SetServerAddressL(StringToS60TPtrC(settingValue.toString())); |
|
315 break; |
|
316 case IncomingMailUsesAuthentication: |
|
317 #if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT) |
|
318 mPop3Settings->SetPOP3Auth(settingValue.toBool()); |
|
319 #endif |
|
320 break; |
|
321 case IncomingMailSecurityType: |
|
322 setSecurity(*mPop3Settings, settingValue.toString()); |
|
323 break; |
|
324 case IncomingPort: |
|
325 mPop3Settings->SetPort(settingValue.toInt()); |
|
326 break; |
|
327 case IncomingSecureSockets: |
|
328 mPop3Settings->SetSecureSockets(settingValue.toBool()); |
|
329 break; |
|
330 case IncomingSSLWrapper: |
|
331 mPop3Settings->SetSSLWrapper(settingValue.toBool()); |
|
332 break; |
|
333 default: |
|
334 fillSmtpSettingDataL(data, settingValue, key); |
|
335 break; |
|
336 } |
|
337 } |
|
338 } |
|
339 } |
|
340 |
|
341 void NmApiSettingsManagerPrivate::fillSmtpSettingDataL(const NmApiMailboxSettingsData &data, |
|
342 const QVariant settingValue, const int key) |
|
343 { |
|
344 switch (key) { |
|
345 case EmailAddress: |
|
346 mSmtpSettings->SetEmailAddressL(StringToS60TPtrC(settingValue.toString())); |
|
347 break; |
|
348 case ReplyAddress: |
|
349 mSmtpSettings->SetReplyToAddressL(StringToS60TPtrC(settingValue.toString())); |
|
350 break; |
|
351 case EmailAlias: |
|
352 mSmtpSettings->SetEmailAliasL(StringToS60TPtrC(settingValue.toString())); |
|
353 break; |
|
354 case MyName: |
|
355 // If EmailAlias is not set already |
|
356 if(mSmtpSettings->EmailAlias().Length() == 0) { |
|
357 mSmtpSettings->SetEmailAliasL(StringToS60TPtrC(settingValue.toString())); |
|
358 } |
|
359 break; |
|
360 case OutgoingMailServer: |
|
361 mSmtpSettings->SetServerAddressL(StringToS60TPtrC(settingValue.toString())); |
|
362 break; |
|
363 case OutgoingLoginName: |
|
364 mSmtpSettings->SetLoginNameL(*StringToS60HBufC8LC(settingValue.toString())); |
|
365 CleanupStack::PopAndDestroy(); |
|
366 break; |
|
367 case OutgoingPassword: |
|
368 mSmtpSettings->SetPasswordL(*StringToS60HBufC8LC(settingValue.toString())); |
|
369 CleanupStack::PopAndDestroy(); |
|
370 break; |
|
371 case UseOutgoingAuthentication: |
|
372 // fall through |
|
373 case OutgoingMailUsesAuthentication: |
|
374 mSmtpSettings->SetSMTPAuth(settingValue.toBool()); |
|
375 break; |
|
376 case OutgoingSecureSockets: |
|
377 mSmtpSettings->SetSecureSockets(settingValue.toBool()); |
|
378 break; |
|
379 case OutgoingSSLWrapper: |
|
380 mSmtpSettings->SetSSLWrapper(settingValue.toBool()); |
|
381 break; |
|
382 case OutgoingMailSecurityType: |
|
383 setSecurity(*mSmtpSettings, settingValue.toString()); |
|
384 break; |
|
385 case OutgoingPort: |
|
386 mSmtpSettings->SetPort(settingValue.toInt()); |
|
387 break; |
|
388 default: |
|
389 break; |
|
390 } |
195 } |
391 } |
196 |
392 |
197 /*! |
393 /*! |
198 Writes POP3/IMAP4 specific settings. |
394 Writes POP3/IMAP4 specific settings. |
199 \param data consists of keys and values of settings. |
395 \param data consists of keys and values of settings. |
200 */ |
396 */ |
201 bool NmApiSettingsManagerPrivate::writeSettingL(const NmApiMailboxSettingsData &data) |
397 void NmApiSettingsManagerPrivate::writeSettingL(const NmApiMailboxSettingsData &data) |
202 { |
398 { |
203 HBufC *tmp = 0; |
399 if (mMailboxType == NmApiMailboxTypePop) { |
204 HBufC8 *tmp8 = 0; |
400 fillPopSettingDataL(data); |
205 bool ret(false); |
401 mAccount->SavePopSettingsL(mPop3Account, *mPop3Settings); |
206 int key; |
402 } |
207 QVariant settingValue; |
403 else if (mMailboxType == NmApiMailboxTypeImap) { |
208 QList<int> keylist; |
404 fillImapSettingDataL(data); |
209 bool aliasSet = false; |
405 mAccount->SaveImapSettingsL(mImap4Account, *mImap4Settings); |
210 |
406 } |
211 keylist = data.listSettings(); |
407 mAccount->SaveSmtpSettingsL(mSmtpAccount, *mSmtpSettings); |
212 for (int i = 0; i < keylist.size(); i++) { |
408 } |
213 key = keylist[i]; |
409 |
214 data.getValue(key, settingValue); |
410 /*! |
215 switch (key) { |
411 Writes settings to central repository. |
216 case IncomingLoginName: { |
412 \param data consists of keys and values of settings. |
217 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
218 if (mMailboxType == NmApiMailboxTypePop) { |
|
219 mPop3Settings->SetLoginNameL(*tmp8); |
|
220 } |
|
221 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
222 mImap4Settings->SetLoginNameL(*tmp8); |
|
223 } |
|
224 delete tmp8; |
|
225 break; |
|
226 } |
|
227 case IncomingPassword: { |
|
228 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
229 if (mMailboxType == NmApiMailboxTypePop) { |
|
230 mPop3Settings->SetPasswordL(*tmp8); |
|
231 } |
|
232 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
233 mImap4Settings->SetPasswordL(*tmp8); |
|
234 } |
|
235 delete tmp8; |
|
236 break; |
|
237 } |
|
238 case MailboxName: { |
|
239 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
240 if (mMailboxType == NmApiMailboxTypePop) { |
|
241 mPop3Account.iPopAccountName.Copy(*tmp); |
|
242 } |
|
243 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
244 mImap4Account.iImapAccountName.Copy(*tmp); |
|
245 } |
|
246 delete tmp; |
|
247 break; |
|
248 } |
|
249 case IncomingMailServer: { |
|
250 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
251 |
|
252 if (mMailboxType == NmApiMailboxTypePop) { |
|
253 mPop3Settings->SetServerAddressL(*tmp); |
|
254 } |
|
255 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
256 mImap4Settings->SetServerAddressL(*tmp); |
|
257 } |
|
258 delete tmp; |
|
259 break; |
|
260 } |
|
261 case IncomingMailUsesAuthentication: { |
|
262 #if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT) |
|
263 |
|
264 if (mMailboxType == NmApiMailboxTypePop) { |
|
265 mPop3Settings->SetPOP3Auth(settingValue.toBool()); |
|
266 } |
|
267 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
268 mImap4Settings->SetIAMP4Auth(settingValue.toBool()); |
|
269 } |
|
270 #endif |
|
271 break; |
|
272 } |
|
273 case IncomingMailSecurityType: { |
|
274 setSecurity(settingValue.toString()); |
|
275 break; |
|
276 } |
|
277 case IncomingPort: { |
|
278 if (mMailboxType == NmApiMailboxTypePop) { |
|
279 mPop3Settings->SetPort(settingValue.toInt()); |
|
280 } |
|
281 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
282 mImap4Settings->SetPort(settingValue.toInt()); |
|
283 } |
|
284 break; |
|
285 } |
|
286 case OutgoingPort: { |
|
287 mSmtpSettings->SetPort(settingValue.toInt()); |
|
288 break; |
|
289 } |
|
290 case IncomingSecureSockets: { |
|
291 if (mMailboxType == NmApiMailboxTypePop) { |
|
292 mPop3Settings->SetSecureSockets(settingValue.toBool()); |
|
293 } |
|
294 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
295 mImap4Settings->SetSecureSockets(settingValue.toBool()); |
|
296 } |
|
297 break; |
|
298 } |
|
299 case IncomingSSLWrapper: { |
|
300 if (mMailboxType == NmApiMailboxTypePop) { |
|
301 mPop3Settings->SetSSLWrapper(settingValue.toBool()); |
|
302 } |
|
303 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
304 mImap4Settings->SetSSLWrapper(settingValue.toBool()); |
|
305 } |
|
306 break; |
|
307 } |
|
308 case EmailAddress: { |
|
309 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
310 mSmtpSettings->SetEmailAddressL(*tmp); |
|
311 break; |
|
312 } |
|
313 case ReplyAddress: { |
|
314 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
315 mSmtpSettings->SetReplyToAddressL(*tmp); |
|
316 break; |
|
317 } |
|
318 case EmailAlias: { |
|
319 QVariant tmpName; |
|
320 if(data.getValue(MyName,tmpName)) { |
|
321 if(tmpName.toString() |
|
322 ==XQConversions::s60DescToQString(mSmtpSettings->EmailAlias())) { |
|
323 aliasSet = true; |
|
324 } |
|
325 } |
|
326 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
327 mSmtpSettings->SetEmailAliasL(*tmp); |
|
328 break; |
|
329 } |
|
330 case MyName: { |
|
331 if(!aliasSet) { |
|
332 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
333 mSmtpSettings->SetEmailAliasL(*tmp); |
|
334 } |
|
335 break; |
|
336 } |
|
337 case OutgoingMailServer: { |
|
338 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
|
339 mSmtpSettings->SetServerAddressL(*tmp); |
|
340 break; |
|
341 } |
|
342 case OutgoingLoginName: { |
|
343 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
344 mSmtpSettings->SetLoginNameL(*tmp8); |
|
345 break; |
|
346 } |
|
347 case OutgoingPassword: { |
|
348 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
349 mSmtpSettings->SetPasswordL(*tmp8); |
|
350 break; |
|
351 } |
|
352 case UseOutgoingAuthentication: |
|
353 case OutgoingMailUsesAuthentication: { |
|
354 mSmtpSettings->SetSMTPAuth(settingValue.toBool()); |
|
355 break; |
|
356 } |
|
357 case OutgoingSecureSockets: { |
|
358 mSmtpSettings->SetSecureSockets(settingValue.toBool()); |
|
359 break; |
|
360 } |
|
361 case OutgoingSSLWrapper: { |
|
362 mSmtpSettings->SetSSLWrapper(settingValue.toBool()); |
|
363 break; |
|
364 } |
|
365 case OutgoingMailSecurityType: { |
|
366 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
367 mSmtpSettings->SetTlsSslDomainL(*tmp8); |
|
368 break; |
|
369 } |
|
370 case FolderPath: { |
|
371 tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString()); |
|
372 mImap4Settings->SetFolderPathL(*tmp8); |
|
373 break; |
|
374 } |
|
375 default: { |
|
376 break; |
|
377 } |
|
378 }; |
|
379 } |
|
380 ret = saveSettings(); |
|
381 return ret; |
|
382 } |
|
383 |
|
384 /*! |
|
385 Writes settings to central repository. |
|
386 \param data consists of keys and values of settings. |
|
387 */ |
413 */ |
388 bool NmApiSettingsManagerPrivate::writeSettingToCenRep( |
414 bool NmApiSettingsManagerPrivate::writeSettingToCenRep( |
389 const NmApiMailboxSettingsData &data) |
415 const NmApiMailboxSettingsData &data) |
390 { |
416 { |
391 int key; |
417 int key = -1; |
392 QVariant settingValue; |
418 QVariant settingValue; |
393 QList<int> keylist; |
419 QList<int> keylist = data.listSettings(); |
394 |
|
395 keylist = data.listSettings(); |
|
396 bool ret = false; |
420 bool ret = false; |
397 if(keylist.contains(ReceptionActiveProfile)) { |
421 |
398 data.getValue(ReceptionActiveProfile,settingValue); |
422 if (data.getValue(ReceptionActiveProfile, settingValue) && !settingValue.isNull()) { |
399 QVariant profileOffset = 0; |
423 QVariant profileOffset = 0; |
400 if(settingValue.toString() == EmailClientApi::EmailProfileOffsetKUTD) { |
424 if(settingValue.toString() == EmailClientApi::EmailProfileOffsetKUTD) { |
401 profileOffset=0; |
425 profileOffset = 0; |
402 } else if(settingValue.toString() == EmailClientApi::EmailProfileOffsetSE){ |
426 } else if(settingValue.toString() == EmailClientApi::EmailProfileOffsetSE){ |
403 profileOffset = 1; |
427 profileOffset = 1; |
404 } else if (settingValue.toString() == EmailClientApi::EmailProfileOffsetMF){ |
428 } else if (settingValue.toString() == EmailClientApi::EmailProfileOffsetMF){ |
405 profileOffset = 2; |
429 profileOffset = 2; |
406 } else if (settingValue.toString() == EmailClientApi::EmailProfileOffsetUD) { |
430 } else if (settingValue.toString() == EmailClientApi::EmailProfileOffsetUD) { |
407 profileOffset = 3; |
431 profileOffset = 3; |
408 } |
432 } |
409 ret = writeToCenRep(IpsServices::EmailKeyReceptionActiveProfile, profileOffset); |
433 ret = writeToCenRep(IpsServices::EmailKeyReceptionActiveProfile, profileOffset); |
410 if(ret) { |
434 if(ret) { |
411 calculateActiveProfileOffset(); |
435 ret = calculateActiveProfileOffset(); |
412 } |
436 } |
413 } |
437 } |
414 if (ret) { |
438 if (ret) { |
|
439 bool cenRepSuccess = true; |
415 for (int i = 0; i < keylist.size(); i++) { |
440 for (int i = 0; i < keylist.size(); i++) { |
416 key = keylist[i]; |
441 key = keylist[i]; |
417 data.getValue(key, settingValue); |
442 if (data.getValue(key, settingValue) && !settingValue.isNull()) { |
418 switch (key) { |
443 switch (key) { |
419 case DownloadPictures: { |
444 case DownloadPictures: |
420 ret = writeToCenRep(IpsServices::EmailKeyPreferenceDownloadPictures, |
445 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyPreferenceDownloadPictures, |
421 settingValue); |
446 settingValue); |
422 break; |
447 break; |
|
448 case MessageDivider: |
|
449 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyPreferenceMessageDivider, |
|
450 settingValue); |
|
451 break; |
|
452 case ReceptionUserDefinedProfile: |
|
453 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyReceptionUserDefinedProfile, |
|
454 settingValue); |
|
455 break; |
|
456 case ReceptionInboxSyncWindow: |
|
457 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
458 + IpsServices::EmailKeyReceptionInboxSyncWindow, settingValue); |
|
459 break; |
|
460 case ReceptionGenericSyncWindowInMessages: |
|
461 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
462 + IpsServices::EmailKeyReceptionGenericSyncWindowInMessages, |
|
463 settingValue); |
|
464 break; |
|
465 case ReceptionWeekDays: |
|
466 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
467 + IpsServices::EmailKeyReceptionWeekDays, settingValue); |
|
468 break; |
|
469 case ReceptionDayStartTime: |
|
470 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
471 + IpsServices::EmailKeyReceptionDayStartTime, settingValue); |
|
472 break; |
|
473 case ReceptionDayEndTime: |
|
474 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
475 + IpsServices::EmailKeyReceptionDayEndTime, settingValue); |
|
476 break; |
|
477 case ReceptionRefreshPeriodDayTime: |
|
478 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
479 + IpsServices::EmailKeyReceptionRefreshPeriodDayTime, settingValue); |
|
480 break; |
|
481 case ReceptionRefreshPeriodOther: |
|
482 cenRepSuccess = writeToCenRep(mActiveProfileOffset |
|
483 + IpsServices::EmailKeyReceptionRefreshPeriodOther, settingValue); |
|
484 break; |
|
485 case UserNameHidden: |
|
486 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyUserNameHidden, |
|
487 settingValue); |
|
488 break; |
|
489 case EmailNotificationState: |
|
490 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyEMNState, |
|
491 settingValue); |
|
492 break; |
|
493 case FirstEmnReceived: |
|
494 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyFirstEmnReceived, |
|
495 settingValue); |
|
496 break; |
|
497 case EmnReceivedNotSynced: |
|
498 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyEmnReceivedNotSynced, |
|
499 settingValue); |
|
500 break; |
|
501 case AlwaysOnlineState: |
|
502 cenRepSuccess = setAlwaysOnlineState(settingValue); |
|
503 break; |
|
504 case AoLastSuccessfulUpdate: |
|
505 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateL, |
|
506 settingValue); |
|
507 break; |
|
508 case AoLastUpdateFailed: |
|
509 cenRepSuccess = writeToCenRep(IpsServices::EmailKeyAoLastUpdateFailed, |
|
510 settingValue); |
|
511 break; |
|
512 case AoUpdateSuccessfulWithCurSettings: |
|
513 cenRepSuccess = writeToCenRep( |
|
514 IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings, |
|
515 settingValue); |
|
516 break; |
|
517 case ReceptionActiveProfile: |
|
518 // fall through |
|
519 default: |
|
520 break; |
423 } |
521 } |
424 case MessageDivider: { |
522 |
425 ret = writeToCenRep(IpsServices::EmailKeyPreferenceMessageDivider, settingValue); |
523 if (!cenRepSuccess) { |
426 break; |
524 ret = false; // ret is false if even one of the cenrep operations fails |
427 } |
525 } |
428 case ReceptionUserDefinedProfile: { |
526 } |
429 ret = writeToCenRep(IpsServices::EmailKeyReceptionUserDefinedProfile, |
|
430 settingValue); |
|
431 break; |
|
432 } |
|
433 case ReceptionInboxSyncWindow: { |
|
434 ret = writeToCenRep(mActiveProfileOffset |
|
435 + IpsServices::EmailKeyReceptionInboxSyncWindow, settingValue); |
|
436 break; |
|
437 } |
|
438 case ReceptionGenericSyncWindowInMessages: { |
|
439 ret = writeToCenRep(mActiveProfileOffset |
|
440 + IpsServices::EmailKeyReceptionGenericSyncWindowInMessages, settingValue); |
|
441 break; |
|
442 } |
|
443 case ReceptionWeekDays: { |
|
444 ret = writeToCenRep(mActiveProfileOffset + IpsServices::EmailKeyReceptionWeekDays, |
|
445 settingValue); |
|
446 break; |
|
447 } |
|
448 case ReceptionDayStartTime: { |
|
449 ret = writeToCenRep(mActiveProfileOffset + IpsServices::EmailKeyReceptionDayStartTime, |
|
450 settingValue); |
|
451 break; |
|
452 } |
|
453 case ReceptionDayEndTime: { |
|
454 ret = writeToCenRep(mActiveProfileOffset + IpsServices::EmailKeyReceptionDayEndTime, |
|
455 settingValue); |
|
456 break; |
|
457 } |
|
458 case ReceptionRefreshPeriodDayTime: { |
|
459 ret = writeToCenRep(mActiveProfileOffset |
|
460 + IpsServices::EmailKeyReceptionRefreshPeriodDayTime, settingValue); |
|
461 break; |
|
462 } |
|
463 case ReceptionRefreshPeriodOther: { |
|
464 ret = writeToCenRep(mActiveProfileOffset |
|
465 + IpsServices::EmailKeyReceptionRefreshPeriodOther, settingValue); |
|
466 break; |
|
467 } |
|
468 case UserNameHidden: { |
|
469 ret = writeToCenRep(IpsServices::EmailKeyUserNameHidden, settingValue); |
|
470 break; |
|
471 } |
|
472 case EmailNotificationState: { |
|
473 ret = writeToCenRep(IpsServices::EmailKeyEMNState, settingValue); |
|
474 break; |
|
475 } |
|
476 case FirstEmnReceived: { |
|
477 ret = writeToCenRep(IpsServices::EmailKeyFirstEmnReceived, settingValue); |
|
478 break; |
|
479 } |
|
480 case EmnReceivedNotSynced: { |
|
481 ret = writeToCenRep(IpsServices::EmailKeyEmnReceivedNotSynced, settingValue); |
|
482 break; |
|
483 } |
|
484 case AlwaysOnlineState: { |
|
485 setAlwaysOnlineState(settingValue); |
|
486 break; |
|
487 } |
|
488 case AoLastSuccessfulUpdate: { |
|
489 ret = writeToCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateL, settingValue); |
|
490 break; |
|
491 } |
|
492 case AoLastUpdateFailed: { |
|
493 ret = writeToCenRep(IpsServices::EmailKeyAoLastUpdateFailed, settingValue); |
|
494 break; |
|
495 } |
|
496 case AoUpdateSuccessfulWithCurSettings: { |
|
497 ret = writeToCenRep(IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings, |
|
498 settingValue); |
|
499 break; |
|
500 } |
|
501 case ReceptionActiveProfile: |
|
502 default: { |
|
503 break; |
|
504 } |
|
505 }; |
|
506 } |
|
507 } |
|
508 return ret; |
|
509 } |
|
510 /*! |
|
511 Stores the POP3/IMAP4 specific settings. |
|
512 \return bool <true> when the settings were succesfully written, otherwise <false>. |
|
513 */ |
|
514 bool NmApiSettingsManagerPrivate::saveSettings() |
|
515 { |
|
516 bool ret(false); |
|
517 if (mMailboxType == NmApiMailboxTypePop) { |
|
518 TRAPD(err, mAccount->SavePopSettingsL(mPop3Account, *mPop3Settings)); |
|
519 if (err == KErrNone) { |
|
520 ret = true; |
|
521 } |
|
522 } |
|
523 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
524 TRAPD(err, mAccount->SaveImapSettingsL(mImap4Account, *mImap4Settings)); |
|
525 if (err == KErrNone) { |
|
526 ret = true; |
|
527 } |
527 } |
528 } |
528 } |
529 return ret; |
529 return ret; |
530 } |
530 } |
531 |
531 |
532 /*! |
532 /*! |
533 Reads a key value from the Central Repository. |
533 Reads a key value from the Central Repository. |
534 \param key Key identifier. |
534 \param key Key identifier. |
535 \return the settings value for the given key. |
535 \return QVariant The settings value for the given key. |
536 */ |
536 */ |
537 QVariant NmApiSettingsManagerPrivate::readFromCenRep(quint32 key) const |
537 QVariant NmApiSettingsManagerPrivate::readFromCenRep(quint32 key) const |
538 { |
538 { |
539 XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository, |
539 XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository, |
540 mMailboxOffset + key); |
540 mMailboxOffset + key); |
543 |
543 |
544 /*! |
544 /*! |
545 Writes a key value to the Central Repository. |
545 Writes a key value to the Central Repository. |
546 \param key Key identifier. |
546 \param key Key identifier. |
547 \param value The settings value for the given key. |
547 \param value The settings value for the given key. |
548 \return Returns <true> if the value was succesfully written, <false> if not. |
548 \return bool Returns <true> if the value was succesfully written, <false> if not. |
549 */ |
549 */ |
550 bool NmApiSettingsManagerPrivate::writeToCenRep(quint32 key, const QVariant &value) const |
550 bool NmApiSettingsManagerPrivate::writeToCenRep(quint32 key, const QVariant &value) const |
551 { |
551 { |
552 XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository, |
552 XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository, |
553 mMailboxOffset + key); |
553 mMailboxOffset + key); |
554 return mQSettingsManager->writeItemValue(settingKey, value); |
554 return mQSettingsManager->writeItemValue(settingKey, value); |
555 } |
555 } |
556 |
556 |
557 void NmApiSettingsManagerPrivate::setSecurity(QString securityType) |
557 void NmApiSettingsManagerPrivate::setSecurity(CImBaseEmailSettings &settings, |
558 { |
558 QString securityType) |
559 if (securityType == NmApiStartTls) { |
559 { |
560 if (mMailboxType == NmApiMailboxTypePop) { |
560 settings.SetSecureSockets(securityType == NmApiStartTls ? ETrue : EFalse ); |
561 mPop3Settings->SetSecureSockets(ETrue); |
561 settings.SetSSLWrapper(securityType == NmApiSSLTls ? ETrue : EFalse ); |
562 mPop3Settings->SetSSLWrapper(EFalse); |
562 } |
563 } |
563 |
564 else { |
564 QString NmApiSettingsManagerPrivate::security(CImBaseEmailSettings &settings) const |
565 mImap4Settings->SetSecureSockets(ETrue); |
565 { |
566 mImap4Settings->SetSSLWrapper(EFalse); |
566 bool ss(settings.SecureSockets()); |
567 } |
567 bool sslWrapper(settings.SSLWrapper()); |
568 } |
568 QString securityType(NmApiSecurityOff); |
569 else if (securityType == NmApiSSLTls) { |
569 |
570 if (mMailboxType == NmApiMailboxTypePop) { |
570 if (ss == true && sslWrapper == false) { |
571 mPop3Settings->SetSecureSockets(EFalse); |
|
572 mPop3Settings->SetSSLWrapper(ETrue); |
|
573 } |
|
574 else { |
|
575 mImap4Settings->SetSecureSockets(EFalse); |
|
576 mImap4Settings->SetSSLWrapper(ETrue); |
|
577 } |
|
578 } |
|
579 else { |
|
580 if (mMailboxType == NmApiMailboxTypePop) { |
|
581 mPop3Settings->SetSecureSockets(EFalse); |
|
582 mPop3Settings->SetSSLWrapper(EFalse); |
|
583 } |
|
584 else { |
|
585 mImap4Settings->SetSecureSockets(EFalse); |
|
586 mImap4Settings->SetSSLWrapper(EFalse); |
|
587 } |
|
588 } |
|
589 } |
|
590 |
|
591 QString NmApiSettingsManagerPrivate::security() const |
|
592 { |
|
593 bool ss(false); |
|
594 bool sslw(false); |
|
595 QString securityType(""); |
|
596 |
|
597 if (mMailboxType == NmApiMailboxTypePop) { |
|
598 ss = mPop3Settings->SecureSockets(); |
|
599 sslw = mPop3Settings->SSLWrapper(); |
|
600 } |
|
601 else { |
|
602 ss = mImap4Settings->SecureSockets(); |
|
603 sslw = mImap4Settings->SSLWrapper(); |
|
604 } |
|
605 |
|
606 if (ss == true && sslw == false) { |
|
607 securityType = NmApiStartTls; |
571 securityType = NmApiStartTls; |
608 } |
572 } |
609 else if (ss == false && sslw == true) { |
573 else if (ss == false && sslWrapper == true) { |
610 securityType = NmApiSSLTls; |
574 securityType = NmApiSSLTls; |
611 } |
575 } |
612 else { |
576 |
613 securityType = NmApiSecurityOff; |
|
614 } |
|
615 return securityType; |
577 return securityType; |
616 } |
578 } |
617 |
579 |
618 /*! |
580 /*! |
619 |
581 Function for getting online state. |
620 */ |
582 \param success Boolean variable for informing if operation fails. |
621 QString NmApiSettingsManagerPrivate::alwaysOnlineState() const |
583 Note! If success is already <false> it is not set to <true>. |
622 { |
584 \return QString Online state. |
623 TInt profile = IpsServices::EmailSyncProfileManualFetch; |
585 */ |
624 QString ret = NmApiOff; |
586 QString NmApiSettingsManagerPrivate::alwaysOnlineState(bool &success) const |
625 |
587 { |
626 QVariant state; |
588 QString ret = NmApiOff; |
627 TInt settingValue = -1; |
589 int settingValue = -1; |
628 state = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile); |
590 bool cenRepSuccess = true; |
629 settingValue = state.toInt(); |
591 QVariant state = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile, |
630 |
592 cenRepSuccess); |
631 if (settingValue >= 0) { |
593 |
632 profile = settingValue; |
594 if (cenRepSuccess) { |
633 if (profile != IpsServices::EmailSyncProfileManualFetch) { |
595 settingValue = state.toInt(); |
|
596 if (settingValue != IpsServices::EmailSyncProfileManualFetch) { |
634 ret = NmApiAlways; |
597 ret = NmApiAlways; |
635 } |
598 } |
636 } |
599 } |
|
600 else { // If cenrep read fails it is informed via parameter |
|
601 success = cenRepSuccess; |
|
602 } |
|
603 |
637 return ret; |
604 return ret; |
638 } |
605 } |
639 |
606 |
640 /*! |
607 /*! |
641 |
608 Function for setting online state off. It is not allowed to change it on. |
642 */ |
609 \return bool Return <true> if operation was successful otherwise <false>. |
643 void NmApiSettingsManagerPrivate::setAlwaysOnlineState(const QVariant state) |
610 */ |
644 { |
611 bool NmApiSettingsManagerPrivate::setAlwaysOnlineState(const QVariant &state) |
645 //only allowed to switch state off, not on. |
612 { |
|
613 bool retVal = true; |
646 if (state.toString() == NmApiOff) { |
614 if (state.toString() == NmApiOff) { |
647 writeToCenRep(IpsServices::EmailKeyReceptionActiveProfile, |
615 retVal = writeToCenRep(IpsServices::EmailKeyReceptionActiveProfile, |
648 IpsServices::EmailSyncProfileManualFetch); |
616 IpsServices::EmailSyncProfileManualFetch); |
649 } |
617 } |
650 } |
618 return retVal; |
651 |
619 } |
652 void NmApiSettingsManagerPrivate::calculateMailboxOffset() |
620 |
|
621 /*! |
|
622 Function for calculating mailbox offset. |
|
623 \return bool Returns <true> if operation was successfull otherwise returns <false>. |
|
624 */ |
|
625 bool NmApiSettingsManagerPrivate::calculateMailboxOffset() |
653 { |
626 { |
654 // Find all the keys that match the criteria 0xZZZZZ000, where Z=don't care. |
627 // Find all the keys that match the criteria 0xZZZZZ000, where Z=don't care. |
655 // This will give us all the keys that hold the mailbox ids, e.g. 0x00001000, 0x00002000, etc. |
628 // This will give us all the keys that hold the mailbox ids, e.g. 0x00001000, 0x00002000, etc. |
656 quint32 partialKey(0x00000000); |
629 quint32 partialKey(0x00000000); |
657 quint32 bitMask(0x00000FFF); |
630 quint32 bitMask(0x00000FFF); |
658 XQCentralRepositorySearchCriteria criteria(IpsServices::EmailMailboxSettingRepository, |
631 XQCentralRepositorySearchCriteria criteria(IpsServices::EmailMailboxSettingRepository, |
659 partialKey, bitMask); |
632 partialKey, bitMask); |
660 // Set the mailbox id is value criteria for the search. |
633 // Set the mailbox id is value criteria for the search. |
661 criteria.setValueCriteria((int) mMailboxId); |
634 criteria.setValueCriteria((static_cast<int>(mMailboxId))); |
662 |
635 |
663 // Find the keys. |
636 // Find the keys. |
664 XQCentralRepositoryUtils utils(*mQSettingsManager); |
637 XQCentralRepositoryUtils utils(*mQSettingsManager); |
665 QList<XQCentralRepositorySettingsKey> foundKeys = utils.findKeys(criteria); |
638 QList<XQCentralRepositorySettingsKey> foundKeys = utils.findKeys(criteria); |
666 |
639 |
|
640 bool retVal = true; |
667 // We should only get one key as a result. |
641 // We should only get one key as a result. |
668 if (foundKeys.count() == 1) { |
642 if (foundKeys.count() == 1) { |
669 mMailboxOffset = foundKeys[0].key(); |
643 mMailboxOffset = foundKeys[0].key(); |
670 calculateActiveProfileOffset(); |
644 retVal = calculateActiveProfileOffset(); |
671 } |
645 } |
672 else { |
646 else { |
673 mActiveProfileOffset = -1; |
647 mActiveProfileOffset = KUndefinedOffset; |
674 mMailboxOffset = -1; |
648 mMailboxOffset = KUndefinedOffset; |
675 } |
649 retVal = false; |
676 } |
650 } |
677 |
651 return retVal; |
678 /*! |
652 } |
679 Calculates the active reception schedule profile offset. |
653 |
680 */ |
654 /*! |
681 void NmApiSettingsManagerPrivate::calculateActiveProfileOffset() |
655 Calculates the Active profile offset. |
682 { |
656 \return bool Returns <true> if operation was successfull otherwise <false>. |
683 QVariant activeProfile = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile); |
657 */ |
684 mActiveProfileOffset = convertToProfileOffset(activeProfile.toInt()); |
658 bool NmApiSettingsManagerPrivate::calculateActiveProfileOffset() |
685 } |
659 { |
686 |
660 bool retVal = true; |
687 /*! |
661 QVariant activeProfile = readFromCenRep( |
688 |
662 IpsServices::EmailKeyReceptionActiveProfile, retVal); |
689 */ |
663 if (retVal) { |
690 qint32 NmApiSettingsManagerPrivate::convertToProfileOffset(int profile) const |
664 switch (activeProfile.toInt()) { |
691 { |
665 case 0: |
692 quint32 profileOffset(0); |
666 mActiveProfileOffset = IpsServices::EmailProfileOffsetKUTD; |
693 // Possible values are defined in ipssettingkeys.h |
667 break; |
694 switch (profile) { |
668 case 1: |
695 case 0: { |
669 mActiveProfileOffset = IpsServices::EmailProfileOffsetSE; |
696 profileOffset = IpsServices::EmailProfileOffsetKUTD; |
670 break; |
697 break; |
671 case 2: |
698 } |
672 mActiveProfileOffset = IpsServices::EmailProfileOffsetMF; |
699 case 1: { |
673 break; |
700 profileOffset = IpsServices::EmailProfileOffsetSE; |
674 case 3: |
701 break; |
675 mActiveProfileOffset = IpsServices::EmailProfileOffsetUD; |
702 } |
676 break; |
703 case 2: { |
677 default: |
704 profileOffset = IpsServices::EmailProfileOffsetMF; |
678 mActiveProfileOffset = IpsServices::EmailProfileOffsetKUTD; |
705 break; |
679 break; |
706 } |
680 } |
707 case 3: { |
681 } |
708 profileOffset = IpsServices::EmailProfileOffsetUD; |
682 return retVal; |
709 break; |
683 } |
710 } |
684 |
711 default: { |
685 /*! |
712 break; |
686 Function for checking account type. |
713 } |
687 \return bool Returns <true> If account type was identified. <false> if not. |
714 }; |
688 */ |
715 |
689 bool NmApiSettingsManagerPrivate::checkAccountTypeL() |
716 return profileOffset; |
|
717 } |
|
718 |
|
719 bool NmApiSettingsManagerPrivate::checkAccountType() |
|
720 { |
690 { |
721 bool identified = false; |
691 bool identified = false; |
722 |
|
723 RArray<TImapAccount> imapAccounts; |
692 RArray<TImapAccount> imapAccounts; |
724 CleanupClosePushL(imapAccounts); |
693 CleanupClosePushL(imapAccounts); |
725 TRAPD(err, mAccount->GetImapAccountsL(imapAccounts)); |
694 |
726 if (err == KErrNone) { |
695 mAccount->GetImapAccountsL(imapAccounts); |
727 for (int i=0; i < imapAccounts.Count(); ++i) { |
696 for (int i=0; i < imapAccounts.Count(); ++i) { |
728 TImapAccount account = imapAccounts[i]; |
697 TImapAccount account = imapAccounts[i]; |
729 if (account.iImapService == mMailboxId) { |
698 if (account.iImapService == mMailboxId) { |
730 mImap4Account = account; |
699 mImap4Account = account; |
731 mMailboxType = NmApiMailboxTypeImap; |
700 mMailboxType = NmApiMailboxTypeImap; |
732 identified = true; |
701 identified = true; |
733 break; |
702 break; |
734 } |
|
735 } |
703 } |
736 } |
704 } |
737 CleanupStack::PopAndDestroy(&imapAccounts); |
705 CleanupStack::PopAndDestroy(&imapAccounts); |
738 |
706 |
739 if (!identified) { |
707 if (!identified) { |
740 RArray<TPopAccount> popAccounts; |
708 RArray<TPopAccount> popAccounts; |
741 CleanupClosePushL(popAccounts); |
709 CleanupClosePushL(popAccounts); |
742 TRAPD(err, mAccount->GetPopAccountsL(popAccounts)); |
710 mAccount->GetPopAccountsL(popAccounts); |
743 if (err == KErrNone) { |
711 for (int i = 0; i < popAccounts.Count(); ++i) { |
744 for (int i = 0; i < popAccounts.Count(); ++i) { |
712 TPopAccount account = popAccounts[i]; |
745 TPopAccount account = popAccounts[i]; |
713 if (popAccounts[i].iPopService == mMailboxId) { |
746 if (popAccounts[i].iPopService == mMailboxId) { |
714 mPop3Account = account; |
747 mPop3Account = account; |
715 mMailboxType = NmApiMailboxTypePop; |
748 mMailboxType = NmApiMailboxTypePop; |
716 identified = true; |
749 identified = true; |
717 break; |
750 break; |
|
751 } |
|
752 } |
718 } |
753 } |
719 } |
754 CleanupStack::PopAndDestroy(&popAccounts); |
720 CleanupStack::PopAndDestroy(&popAccounts); |
755 } |
721 } |
756 |
|
757 return identified; |
722 return identified; |
758 } |
723 } |
759 |
724 |
|
725 /*! |
|
726 Function for initializing account information. |
|
727 */ |
760 void NmApiSettingsManagerPrivate::initAccountL() |
728 void NmApiSettingsManagerPrivate::initAccountL() |
761 { |
729 { |
762 if (mMailboxType == NmApiMailboxTypePop) { |
730 mAccount = CEmailAccounts::NewL(); |
|
731 |
|
732 if (!checkAccountTypeL()) { |
|
733 User::Leave(KErrNotSupported); // Account type was not identified |
|
734 } |
|
735 |
|
736 if (mMailboxType == NmApiMailboxTypePop) { |
763 mPop3Settings = new(ELeave) CImPop3Settings(); |
737 mPop3Settings = new(ELeave) CImPop3Settings(); |
764 mAccount->LoadPopSettingsL(mPop3Account, *mPop3Settings); |
738 mAccount->LoadPopSettingsL(mPop3Account, *mPop3Settings); |
765 } |
739 mAccount->GetSmtpAccountL(mPop3Account.iSmtpService, mSmtpAccount); |
766 else if (mMailboxType == NmApiMailboxTypeImap) { |
740 } |
|
741 else if (mMailboxType == NmApiMailboxTypeImap) { |
767 mImap4Settings = new(ELeave) CImImap4Settings(); |
742 mImap4Settings = new(ELeave) CImImap4Settings(); |
768 mAccount->LoadImapSettingsL(mImap4Account, *mImap4Settings); |
743 mAccount->LoadImapSettingsL(mImap4Account, *mImap4Settings); |
|
744 mAccount->GetSmtpAccountL(mImap4Account.iSmtpService, mSmtpAccount); |
|
745 } |
|
746 else { |
|
747 User::Leave(KErrNotSupported); |
769 } |
748 } |
770 |
749 |
771 mSmtpSettings = new(ELeave) CImSmtpSettings(); |
750 mSmtpSettings = new(ELeave) CImSmtpSettings(); |
772 |
|
773 if (mMailboxType == NmApiMailboxTypePop) { |
|
774 mAccount->GetSmtpAccountL(mPop3Account.iSmtpService, mSmtpAccount); |
|
775 } |
|
776 else if (mMailboxType == NmApiMailboxTypeImap) { |
|
777 mAccount->GetSmtpAccountL(mImap4Account.iSmtpService, mSmtpAccount); |
|
778 } |
|
779 mAccount->LoadSmtpSettingsL(mSmtpAccount, *mSmtpSettings); |
751 mAccount->LoadSmtpSettingsL(mSmtpAccount, *mSmtpSettings); |
|
752 |
|
753 QT_TRYCATCH_LEAVING(mQSettingsManager = new XQSettingsManager()); |
|
754 calculateMailboxOffset(); |
780 } |
755 } |
781 |
756 |
782 } // end namespace |
757 } // end namespace |