61 : mCurrentLineEditChanged(false), |
63 : mCurrentLineEditChanged(false), |
62 mEmitOnline(false), |
64 mEmitOnline(false), |
63 mSettingsManager(settingsManager), |
65 mSettingsManager(settingsManager), |
64 mDataForm(dataForm), |
66 mDataForm(dataForm), |
65 mDataFormModel(dataFormModel), |
67 mDataFormModel(dataFormModel), |
66 mDynamicItemsVisible(false), |
68 mDeleteConfirmationDialog(0), |
|
69 mDeleteInformationDialog(0), |
|
70 mIncomingPortInputDialog(0), |
|
71 mIncomingPortInputValidator(0), |
|
72 mFolderPathInputDialog(0), |
|
73 mOutgoingPortInputDialog(0), |
|
74 mOutgoingPortInputValidator(0), |
|
75 mServerInfoDynamicItemsVisible(false), |
67 mRadioButtonPreviousIndex(0) |
76 mRadioButtonPreviousIndex(0) |
68 { |
77 { |
69 } |
78 } |
70 |
79 |
71 /*! |
80 /*! |
72 Destructor of NmIpsSettingsHelper. |
81 Destructor of NmIpsSettingsHelper. |
73 */ |
82 */ |
74 NmIpsSettingsHelper::~NmIpsSettingsHelper() |
83 NmIpsSettingsHelper::~NmIpsSettingsHelper() |
75 { |
84 { |
76 mContentItems.clear(); |
85 mContentItems.clear(); |
|
86 delete mDeleteConfirmationDialog; |
|
87 delete mDeleteInformationDialog; |
|
88 delete mIncomingPortInputDialog; |
|
89 delete mIncomingPortInputValidator; |
|
90 delete mFolderPathInputDialog; |
|
91 delete mOutgoingPortInputDialog; |
77 } |
92 } |
78 |
93 |
79 /*! |
94 /*! |
80 Inserts content item pointers into map, which then can be used to access the widgets data. |
95 Inserts content item pointers into map, which then can be used to access the widgets data. |
81 \param IpsServices::SettingItem. Key that can be used to access the value from map. |
96 \param IpsServices::SettingItem. Key that can be used to access the value from map. |
82 \param CpSettingFormItemData *. Pointer to the content item. |
97 \param HbDataFormModelItem *. Pointer to the content item. |
83 */ |
98 */ |
84 void NmIpsSettingsHelper::insertContentItem(IpsServices::SettingItem key, |
99 void NmIpsSettingsHelper::insertContentItem(IpsServices::SettingItem key, |
85 HbDataFormModelItem *value) |
100 HbDataFormModelItem *value) |
86 { |
101 { |
87 mContentItems.insert(key, value); |
102 mContentItems.insert(key, value); |
88 } |
103 } |
89 |
104 |
90 /*! |
105 /*! |
91 |
106 Returns a content item from contentitem map. |
92 */ |
107 */ |
93 HbDataFormModelItem *NmIpsSettingsHelper::contentItem(IpsServices::SettingItem key) const |
108 HbDataFormModelItem *NmIpsSettingsHelper::contentItem(IpsServices::SettingItem key) const |
94 { |
109 { |
95 return mContentItems.value(key); |
110 return mContentItems.value(key); |
96 } |
111 } |
121 case IpsServices::ReceptionWeekDays: |
145 case IpsServices::ReceptionWeekDays: |
122 { |
146 { |
123 // If not exist, create one |
147 // If not exist, create one |
124 if (!formItemData) { |
148 if (!formItemData) { |
125 formItemData = |
149 formItemData = |
126 new CpSettingFormItemData(HbDataFormModelItem::MultiselectionItem, |
150 new CpSettingFormItemData( |
127 hbTrId("txt_mailips_setlabel_receiving_weekdays")); |
151 static_cast<HbDataFormModelItem::DataItemType>(NmIpsSettingsCustomItem::MultiSelectionItem), |
|
152 hbTrId("txt_mailips_setlabel_receiving_weekdays")); |
128 |
153 |
129 insertContentItem(IpsServices::ReceptionWeekDays, formItemData); |
154 insertContentItem(IpsServices::ReceptionWeekDays, formItemData); |
130 mReceivingScheduleGroupItem->appendChild(formItemData); |
155 mReceivingScheduleGroupItem->appendChild(formItemData); |
131 QStringList weekdayItems; |
156 QStringList weekdayItems; |
|
157 |
132 weekdayItems << hbTrId("txt_mailips_setlabel_download_images_val_mon") |
158 weekdayItems << hbTrId("txt_mailips_setlabel_download_images_val_mon") |
133 << hbTrId("txt_mailips_setlabel_download_images_val_tue") |
159 << hbTrId("txt_mailips_setlabel_download_images_val_tue") |
134 << hbTrId("txt_mailips_setlabel_download_images_val_wed") |
160 << hbTrId("txt_mailips_setlabel_download_images_val_wed") |
135 << hbTrId("txt_mailips_setlabel_download_images_val_thu") |
161 << hbTrId("txt_mailips_setlabel_download_images_val_thu") |
136 << hbTrId("txt_mailips_setlabel_download_images_val_fri") |
162 << hbTrId("txt_mailips_setlabel_download_images_val_fri") |
137 << hbTrId("txt_mailips_setlabel_download_images_val_sat") |
163 << hbTrId("txt_mailips_setlabel_download_images_val_sat") |
138 << hbTrId("txt_mailips_setlabel_download_images_val_sun") |
164 << hbTrId("txt_mailips_setlabel_download_images_val_sun"); |
139 << hbTrId("txt_mailips_setlabel_download_images_val_every_day"); |
|
140 |
165 |
141 QList<QVariant> weekdayItemValues; |
166 QList<QVariant> weekdayItemValues; |
142 weekdayItemValues << 0x01 |
167 weekdayItemValues << 0x01 |
143 << 0x02 |
168 << 0x02 |
144 << 0x04 |
169 << 0x04 |
145 << 0x08 |
170 << 0x08 |
146 << 0x10 |
171 << 0x10 |
147 << 0x20 |
172 << 0x20 |
148 << 0x40 |
173 << 0x40; |
149 << 0x7F; |
|
150 |
174 |
151 formItemData->setData(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1, |
175 formItemData->setData(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1, |
152 weekdayItemValues); |
176 weekdayItemValues); |
|
177 |
|
178 formItemData->setContentWidgetData(QString("heading"), |
|
179 hbTrId("txt_mailips_dialog_heading_receiving_weekdays")); |
|
180 |
153 formItemData->setContentWidgetData(QString("items"), weekdayItems); |
181 formItemData->setContentWidgetData(QString("items"), weekdayItems); |
154 formItemData->setEnabled(false); |
182 |
155 // mDataForm.addConnection(formItemData, SIGNAL(finished(HbAction *)), |
183 mDataForm.addConnection(formItemData, SIGNAL(editingFinished()), |
156 // this, SLOT(receivingWeekdaysModified(HbAction *))); |
184 this, SLOT(receivingWeekdaysModified())); |
157 } |
185 } |
158 |
186 |
159 // Update data |
187 // Update data |
160 QVariant value; |
188 QVariant value; |
161 mSettingsManager.readSetting(item, value); |
189 mSettingsManager.readSetting(item, value); |
162 QList<QVariant> selectedDays; |
190 QList<QVariant> selectedDays; |
163 selectedDays.clear(); |
191 selectedDays.clear(); |
164 int days(value.toInt()); |
192 int days(value.toInt()); |
165 if (days == 0x7f) { |
193 |
166 // Every weekday selected |
194 // 0-6 Individual weekdays selected |
167 selectedDays.append(7); |
195 for (int i=0; i<=6; ++i) { |
168 } else { |
196 if (days & (1 << i)) { |
169 // 0-6 Individual weekdays selected |
197 selectedDays.append(i); |
170 for (int i=0; i<=6; ++i) { |
|
171 if (days & (1 << i)) { |
|
172 selectedDays.append(i); |
|
173 } |
|
174 } |
198 } |
175 } |
199 } |
|
200 |
176 formItemData->setContentWidgetData(QString("selectedItems"), selectedDays); |
201 formItemData->setContentWidgetData(QString("selectedItems"), selectedDays); |
|
202 |
|
203 // Every weekday selected |
|
204 if (days == 0x7f) { |
|
205 formItemData->setContentWidgetData(QString("text"), |
|
206 hbTrId("txt_mailips_setlabel_download_images_val_every_day")); |
|
207 } |
|
208 |
177 break; |
209 break; |
178 } |
210 } |
179 |
211 |
180 // 4. Day start time |
212 // 4. Day start time |
181 case IpsServices::ReceptionDayStartTime: |
213 case IpsServices::ReceptionDayStartTime: |
182 { |
214 { |
183 // If not exist, create one |
215 // If not exist, create one |
184 if (!formItemData) { |
216 if (!formItemData) { |
185 QString format(timeFormat()); |
|
186 formItemData = new CpSettingFormItemData( |
217 formItemData = new CpSettingFormItemData( |
187 static_cast< HbDataFormModelItem::DataItemType >(NmIpsSettingsCustomItem::TimeEditor), |
218 static_cast<HbDataFormModelItem::DataItemType>(NmIpsSettingsCustomItem::TimeEditor), |
188 hbTrId("txt_mailips_setlabel_day_start_time")); |
219 hbTrId("txt_mailips_setlabel_day_start_time")); |
189 |
220 |
190 insertContentItem(IpsServices::ReceptionDayStartTime, formItemData); |
221 insertContentItem(IpsServices::ReceptionDayStartTime, formItemData); |
191 formItemData->setEnabled(true); |
222 formItemData->setContentWidgetData(QString("heading"), |
192 formItemData->setContentWidgetData(QString("displayFormat"), format); |
223 hbTrId("txt_mailips_dialog_heading_start_time")); |
193 mReceivingScheduleGroupItem->appendChild(formItemData); |
224 mReceivingScheduleGroupItem->appendChild(formItemData); |
194 mDataForm.addConnection(formItemData, SIGNAL(editingFinished()), |
225 mDataForm.addConnection(formItemData, SIGNAL(timeChanged(QTime)), |
195 this, SLOT(startTimeModified())); |
226 this, SLOT(startTimeModified(QTime))); |
196 |
227 |
197 } |
228 } |
198 |
229 |
199 // Update data |
230 // Update data |
200 QVariant startTime; |
231 QVariant startTime; |
201 mSettingsManager.readSetting(item, startTime); |
232 mSettingsManager.readSetting(item, startTime); |
202 QDateTime startDateTime(QDate(2010, 1, 1), QTime(startTime.toInt(),0)); |
233 int startHour(startTime.toInt() / 60); |
203 formItemData->setContentWidgetData("dateTime", startDateTime); |
234 int startMinute(startTime.toInt() % 60); |
|
235 formItemData->setContentWidgetData("time", QTime(startHour, startMinute)); |
204 break; |
236 break; |
205 } |
237 } |
206 |
238 |
207 // 5. Day end time |
239 // 5. Day end time |
208 case IpsServices::ReceptionDayEndTime: |
240 case IpsServices::ReceptionDayEndTime: |
209 { |
241 { |
210 // If not exist, create one |
242 // If not exist, create one |
211 if (!formItemData) { |
243 if (!formItemData) { |
212 QString format(timeFormat()); |
|
213 formItemData = new CpSettingFormItemData( |
244 formItemData = new CpSettingFormItemData( |
214 static_cast<HbDataFormModelItem::DataItemType> (NmIpsSettingsCustomItem::TimeEditor), |
245 static_cast<HbDataFormModelItem::DataItemType> (NmIpsSettingsCustomItem::TimeEditor), |
215 hbTrId("txt_mailips_setlabel_day_end_time")); |
246 hbTrId("txt_mailips_setlabel_day_end_time")); |
216 |
247 |
217 insertContentItem(IpsServices::ReceptionDayEndTime, formItemData); |
248 insertContentItem(IpsServices::ReceptionDayEndTime, formItemData); |
218 formItemData->setEnabled(true); |
249 formItemData->setContentWidgetData(QString("heading"), |
219 formItemData->setContentWidgetData(QString("displayFormat"), format); |
250 hbTrId("txt_mailips_dialog_heading_end_time")); |
220 mReceivingScheduleGroupItem->appendChild(formItemData); |
251 mReceivingScheduleGroupItem->appendChild(formItemData); |
221 } |
252 } |
222 |
253 |
223 // Update data |
254 // Update data |
224 QVariant endTime; |
255 QVariant endTime; |
225 mSettingsManager.readSetting(item, endTime); |
256 mSettingsManager.readSetting(item, endTime); |
226 QDateTime endDateTime(QDate(2010, 1, 1), QTime(endTime.toInt(),0)); |
257 int endHour(endTime.toInt() / 60); |
227 formItemData->setContentWidgetData("dateTime", endDateTime); |
258 int endMinute(endTime.toInt() % 60); |
228 mDataForm.addConnection(formItemData, SIGNAL(editingFinished()), |
259 formItemData->setContentWidgetData("time", QTime(endHour, endMinute)); |
229 this, SLOT(endTimeModified())); |
260 mDataForm.addConnection(formItemData, SIGNAL(timeChanged(QTime)), |
|
261 this, SLOT(endTimeModified(QTime))); |
230 break; |
262 break; |
231 } |
263 } |
232 |
264 |
233 // 6. Refresh mail interval |
265 // 6. Refresh mail interval |
234 case IpsServices::ReceptionRefreshPeriodDayTime: |
266 case IpsServices::ReceptionRefreshPeriodDayTime: |
280 } |
312 } |
281 } |
313 } |
282 } |
314 } |
283 |
315 |
284 /*! |
316 /*! |
|
317 Creates the setting items under the Serverinfo group items user authentication. |
|
318 */ |
|
319 void NmIpsSettingsHelper::createServerInfoGroupDynamicItems() |
|
320 { |
|
321 HbDataFormModelItem *item = mContentItems.value(IpsServices::SMTPAuthentication); |
|
322 int insertIndex = mServerInfoGroupItem->indexOf(item) + 1; |
|
323 |
|
324 // Username |
|
325 QVariant username; |
|
326 mSettingsManager.readSetting(IpsServices::OutgoingLoginName, username); |
|
327 CpSettingFormItemData *usernameItem = new CpSettingFormItemData( |
|
328 HbDataFormModelItem::TextItem, hbTrId("txt_mailips_setlabel_username")); |
|
329 insertContentItem(IpsServices::OutgoingLoginName, usernameItem); |
|
330 usernameItem->setContentWidgetData(QString("text"), username); |
|
331 mDataForm.addConnection(usernameItem, SIGNAL(editingFinished()), |
|
332 this, SLOT(saveOutgoingUserName())); |
|
333 mDataForm.addConnection(usernameItem, SIGNAL(textChanged(QString)), |
|
334 this, SLOT(outgoingUserNameTextChange(QString))); |
|
335 mServerInfoGroupItem->insertChild(insertIndex, usernameItem); |
|
336 |
|
337 // Password |
|
338 QVariant password; |
|
339 mSettingsManager.readSetting(IpsServices::OutgoingPassword, password); |
|
340 CpSettingFormItemData *passwordItem = new CpSettingFormItemData( |
|
341 HbDataFormModelItem::TextItem, hbTrId("txt_mailips_setlabel_password")); |
|
342 insertContentItem(IpsServices::OutgoingPassword, passwordItem); |
|
343 passwordItem->setContentWidgetData(QString("text"), password); |
|
344 passwordItem->setContentWidgetData(QString("echoMode"), HbLineEdit::PasswordEchoOnEdit); |
|
345 mDataForm.addConnection(passwordItem, SIGNAL(editingFinished()), |
|
346 this, SLOT(saveOutgoingPassword())); |
|
347 mServerInfoGroupItem->insertChild(insertIndex + 1, passwordItem); |
|
348 |
|
349 mServerInfoDynamicItemsVisible = true; |
|
350 } |
|
351 |
|
352 /*! |
285 Saves the My Name value into database if user has changed the value. |
353 Saves the My Name value into database if user has changed the value. |
286 */ |
354 */ |
287 void NmIpsSettingsHelper::saveMyName() |
355 void NmIpsSettingsHelper::saveMyName() |
288 { |
356 { |
289 if (mCurrentLineEditChanged) { |
357 if (mCurrentLineEditChanged) { |
308 /*! |
376 /*! |
309 Saves the Mailbox name value into database if user has changed the value. |
377 Saves the Mailbox name value into database if user has changed the value. |
310 */ |
378 */ |
311 void NmIpsSettingsHelper::saveMailboxName() |
379 void NmIpsSettingsHelper::saveMailboxName() |
312 { |
380 { |
|
381 bool ok = true; |
313 if (mCurrentLineEditChanged) { |
382 if (mCurrentLineEditChanged) { |
314 HbDataFormModelItem *item = mContentItems.value(IpsServices::MailboxName); |
383 HbDataFormModelItem *item = mContentItems.value(IpsServices::MailboxName); |
315 QVariant data = item->contentWidgetData(QString("text")); |
384 QVariant data = item->contentWidgetData(QString("text")); |
316 // Only save mailbox name if it's length is greater than zero. CEmailAccounts does not |
385 // Only save mailbox name if it's length is greater than zero. CEmailAccounts does not |
317 // allow zero-length mailbox names. |
386 // allow zero-length mailbox names. |
318 if (data.toString().length() > 0) { |
387 if (data.toString().length() > 0) { |
319 mSettingsManager.writeSetting(IpsServices::MailboxName, data); |
388 ok = mSettingsManager.writeSetting(IpsServices::MailboxName, data); |
|
389 |
|
390 // If failed, try again when the plugin is set to offline |
|
391 if (!ok) { |
|
392 NMLOG("NmIpsSettingsHelper::saveMailboxName failed"); |
|
393 emit goOffline(mSettingsManager.mailboxId()); |
|
394 mEmitOnline = true; |
|
395 ok = mSettingsManager.writeSetting(IpsServices::MailboxName, data); |
|
396 } |
|
397 |
320 QVariant property(NmSettings::MailboxName); |
398 QVariant property(NmSettings::MailboxName); |
321 emit mailboxPropertyChanged(mSettingsManager.mailboxId(), property, data); |
399 emit mailboxPropertyChanged(mSettingsManager.mailboxId(), property, data); |
322 } |
400 } |
323 else { |
401 else { |
324 if (mSettingsManager.readSetting(IpsServices::MailboxName, data)) { |
402 if (mSettingsManager.readSetting(IpsServices::MailboxName, data)) { |
366 Q_UNUSED(text); |
444 Q_UNUSED(text); |
367 mCurrentLineEditChanged = true; |
445 mCurrentLineEditChanged = true; |
368 } |
446 } |
369 |
447 |
370 /*! |
448 /*! |
371 Saves the Username value into database if user has changed the value. |
449 Saves the Incoming username value into database if user has changed the value. |
372 */ |
450 */ |
373 void NmIpsSettingsHelper::saveUserName() |
451 void NmIpsSettingsHelper::saveIncomingUserName() |
374 { |
452 { |
375 if (mCurrentLineEditChanged) { |
453 if (mCurrentLineEditChanged) { |
376 emit goOffline(mSettingsManager.mailboxId()); |
454 emit goOffline(mSettingsManager.mailboxId()); |
377 mEmitOnline = true; |
455 mEmitOnline = true; |
378 HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingLoginName); |
456 HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingLoginName); |
|
457 QVariant username = item->contentWidgetData(QString("text")); |
|
458 mSettingsManager.writeSetting(IpsServices::IncomingLoginName, username); |
|
459 // Outgoing username needs to be updated if it is set as Same as Incoming. |
|
460 item = mContentItems.value(IpsServices::SMTPAuthentication); |
|
461 QVariant selected = item->contentWidgetData(QString("selected")); |
|
462 if (selected.toInt() == IpsServices::EMailAuthSameAsIncoming) { |
|
463 mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, username); |
|
464 } |
|
465 } |
|
466 mCurrentLineEditChanged = false; |
|
467 } |
|
468 |
|
469 /*! |
|
470 Saves the Outgoing username value into database if user has changed the value. |
|
471 */ |
|
472 void NmIpsSettingsHelper::saveOutgoingUserName() |
|
473 { |
|
474 if (mCurrentLineEditChanged) { |
|
475 emit goOffline(mSettingsManager.mailboxId()); |
|
476 mEmitOnline = true; |
|
477 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingLoginName); |
379 QVariant data = item->contentWidgetData(QString("text")); |
478 QVariant data = item->contentWidgetData(QString("text")); |
380 mSettingsManager.writeSetting(IpsServices::IncomingLoginName, data); |
479 mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, data); |
381 } |
480 } |
382 mCurrentLineEditChanged = false; |
481 mCurrentLineEditChanged = false; |
383 } |
482 } |
384 |
483 |
385 /*! |
484 /*! |
386 Sets the edit changed flag to indicate that user has edited the field |
485 Sets the edit changed flag to indicate that user has edited the field |
387 |
486 |
388 \param text Reference to the text value in the line edit box. |
487 \param text Reference to the text value in the line edit box. |
389 */ |
488 */ |
390 void NmIpsSettingsHelper::userNameTextChange(const QString &text) |
489 void NmIpsSettingsHelper::incomingUserNameTextChange(const QString &text) |
391 { |
490 { |
392 Q_UNUSED(text); |
491 Q_UNUSED(text); |
393 mCurrentLineEditChanged = true; |
492 mCurrentLineEditChanged = true; |
394 } |
493 } |
395 |
494 |
396 /*! |
495 /*! |
397 Saves the Password value into database |
496 Sets the edit changed flag to indicate that user has edited the field |
398 */ |
497 |
399 void NmIpsSettingsHelper::savePassword() |
498 \param text Reference to the text value in the line edit box. |
|
499 */ |
|
500 |
|
501 void NmIpsSettingsHelper::outgoingUserNameTextChange(const QString &text) |
|
502 { |
|
503 Q_UNUSED(text); |
|
504 mCurrentLineEditChanged = true; |
|
505 } |
|
506 |
|
507 /*! |
|
508 Saves the Incoming password value into database |
|
509 */ |
|
510 void NmIpsSettingsHelper::saveIncomingPassword() |
400 { |
511 { |
401 emit goOffline(mSettingsManager.mailboxId()); |
512 emit goOffline(mSettingsManager.mailboxId()); |
402 mEmitOnline = true; |
513 mEmitOnline = true; |
403 HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPassword); |
514 HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPassword); |
|
515 QVariant password = item->contentWidgetData(QString("text")); |
|
516 mSettingsManager.writeSetting(IpsServices::IncomingPassword, password); |
|
517 // Outgoing password needs to be updated if it is set as Same as Incoming. |
|
518 item = mContentItems.value(IpsServices::SMTPAuthentication); |
|
519 QVariant selected = item->contentWidgetData(QString("selected")); |
|
520 if (selected.toInt() == IpsServices::EMailAuthSameAsIncoming) { |
|
521 mSettingsManager.writeSetting(IpsServices::OutgoingPassword, password); |
|
522 } |
|
523 } |
|
524 |
|
525 /*! |
|
526 Saves the Outgoing password value into database |
|
527 */ |
|
528 void NmIpsSettingsHelper::saveOutgoingPassword() |
|
529 { |
|
530 emit goOffline(mSettingsManager.mailboxId()); |
|
531 mEmitOnline = true; |
|
532 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPassword); |
404 QVariant data = item->contentWidgetData(QString("text")); |
533 QVariant data = item->contentWidgetData(QString("text")); |
405 mSettingsManager.writeSetting(IpsServices::IncomingPassword, data); |
534 mSettingsManager.writeSetting(IpsServices::OutgoingPassword, data); |
406 } |
535 } |
407 |
|
408 /*! |
536 /*! |
409 Saves the Reply to value into database if user has changed the value. |
537 Saves the Reply to value into database if user has changed the value. |
410 */ |
538 */ |
411 void NmIpsSettingsHelper::saveReplyTo() |
539 void NmIpsSettingsHelper::saveReplyTo() |
412 { |
540 { |
428 Q_UNUSED(text); |
556 Q_UNUSED(text); |
429 mCurrentLineEditChanged = true; |
557 mCurrentLineEditChanged = true; |
430 } |
558 } |
431 |
559 |
432 /*! |
560 /*! |
|
561 Shows the confirmation dialog for user. |
|
562 */ |
|
563 void NmIpsSettingsHelper::deleteButtonPress() |
|
564 { |
|
565 if(!mDeleteConfirmationDialog) { |
|
566 mDeleteConfirmationDialog = |
|
567 new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
568 mDeleteConfirmationDialog->setText( |
|
569 hbTrId("txt_mail_dialog_do_you_want_to_delete_the_mailbox")); |
|
570 mDeleteConfirmationDialog->setTimeout(HbMessageBox::NoTimeout); |
|
571 } |
|
572 mDeleteConfirmationDialog->open(this, SLOT(handleMailboxDelete(HbAction *))); |
|
573 } |
|
574 |
|
575 /*! |
433 Deletes mailbox and displays the proper notes. |
576 Deletes mailbox and displays the proper notes. |
434 */ |
577 */ |
435 void NmIpsSettingsHelper::deleteButtonPress() |
578 void NmIpsSettingsHelper::handleMailboxDelete(HbAction *action) |
436 { |
579 { |
437 HbMessageBox confirmationDialog(HbMessageBox::MessageTypeQuestion); |
580 if (action == mDeleteConfirmationDialog->primaryAction()) { |
438 confirmationDialog.setText(hbTrId("txt_mail_dialog_do_you_want_to_delete_the_mailbox")); |
581 |
439 confirmationDialog.setModal(true); |
582 emit goOffline(mSettingsManager.mailboxId()); |
440 confirmationDialog.setTimeout(HbMessageBox::NoTimeout); |
583 mEmitOnline = false; |
441 |
584 |
442 HbAction *action = confirmationDialog.exec(); |
585 QVariant mailboxName; |
443 |
586 mSettingsManager.readSetting(IpsServices::MailboxName, mailboxName); |
444 if (action != confirmationDialog.primaryAction()) { |
587 |
445 // The user did not confirm the deletion. |
588 // Display the progress note. Before display the note, remove the cancel |
446 return; |
589 // button. |
447 } |
590 HbProgressDialog progressNote(HbProgressDialog::WaitDialog); |
448 |
591 progressNote.setText(hbTrId("txt_common_info_deleting")); |
449 emit goOffline(mSettingsManager.mailboxId()); |
592 action = progressNote.primaryAction(); |
450 mEmitOnline = false; |
593 progressNote.removeAction(action); |
451 |
594 progressNote.delayedShow(); |
452 QVariant mailboxName; |
595 |
453 mSettingsManager.readSetting(IpsServices::MailboxName, mailboxName); |
596 if (!mSettingsManager.deleteMailbox()) { |
454 |
597 // The mailbox was deleted successfully. Hide the progress note and |
455 // Display the progress note. Before display the note, remove the cancel |
598 // display the "mailbox deleted" dialog. |
456 // button. |
599 progressNote.close(); |
457 HbProgressDialog progressNote(HbProgressDialog::WaitDialog); |
600 |
458 progressNote.setText(hbTrId("txt_common_info_deleting")); |
601 if (!mDeleteInformationDialog) { |
459 action = progressNote.primaryAction(); |
602 mDeleteInformationDialog = |
460 progressNote.removeAction(action); |
603 new HbMessageBox(HbMessageBox::MessageTypeInformation); |
461 progressNote.delayedShow(); |
604 mDeleteInformationDialog->setText( |
462 |
605 hbTrId("txt_mail_dpophead _1_deleted").arg(mailboxName.toString())); |
463 if (!mSettingsManager.deleteMailbox()) { |
606 mDeleteInformationDialog->setTimeout(HbMessageBox::NoTimeout); |
464 // The mailbox was deleted successfully. Hide the progress note and |
607 } |
465 // display the "mailbox deleted" dialog. |
608 mDeleteInformationDialog->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *))); |
466 progressNote.close(); |
609 |
467 |
610 } else { |
468 HbMessageBox infoDialog(HbMessageBox::MessageTypeInformation); |
611 // Failed to delete the mailbox! |
469 infoDialog.setText( |
612 progressNote.close(); |
470 hbTrId("txt_mail_dpophead _1_deleted").arg(mailboxName.toString())); |
613 } |
471 infoDialog.setModal(true); |
614 } |
472 HbAction *action = infoDialog.exec(); |
615 } |
473 |
616 |
474 // Emit the signal to update the UI. |
617 /*! |
475 emit mailboxListChanged(mSettingsManager.mailboxId(), |
618 Handels the event after the mailbox delete information dialog has been dismissed. |
476 NmSettings::MailboxDeleted); |
619 */ |
477 } else { |
620 void NmIpsSettingsHelper::handleMailboxDeleteUpdate(HbAction *action) |
478 // Failed to delete the mailbox! |
621 { |
479 progressNote.close(); |
622 Q_UNUSED(action); |
480 } |
623 // Emit the signal to update the UI. |
|
624 emit mailboxListChanged(mSettingsManager.mailboxId(), |
|
625 NmSettings::MailboxDeleted); |
481 } |
626 } |
482 |
627 |
483 /*! |
628 /*! |
484 Saves the selected receiving schedule setting. |
629 Saves the selected receiving schedule setting. |
485 \index Selected receiving schedule. |
630 \param index Selected receiving schedule. |
486 */ |
631 */ |
487 void NmIpsSettingsHelper::receivingScheduleChange(int index) |
632 void NmIpsSettingsHelper::receivingScheduleChange(int index) |
488 { |
633 { |
489 mSettingsManager.writeSetting(IpsServices::ReceptionActiveProfile, QVariant(index)); |
634 mSettingsManager.writeSetting(IpsServices::ReceptionActiveProfile, QVariant(index)); |
|
635 |
|
636 // Remove text property to avoid old data to be copied from model to widget. |
|
637 HbDataFormModelItem *item = contentItem(IpsServices::ReceptionWeekDays); |
|
638 if (item) { |
|
639 QHash<QString, QVariant> data = item->contentWidgetData(); |
|
640 data.remove("text"); |
|
641 item->setData(HbDataFormModelItem::PropertyRole, data); |
|
642 } |
490 |
643 |
491 // Read receiving schedule dynamic group item values and |
644 // Read receiving schedule dynamic group item values and |
492 // make a decision based on those if item should be visible or not. |
645 // make a decision based on those if item should be visible or not. |
493 const int dynamicGroupItemsCount( |
646 const int dynamicGroupItemsCount( |
494 sizeof(NmIpsSettingsReceivingSchedule) / sizeof(NmIpsSettingsReceivingSchedule[0])); |
647 sizeof(NmIpsSettingsReceivingSchedule) / sizeof(NmIpsSettingsReceivingSchedule[0])); |
554 mContentItems.remove(item); |
707 mContentItems.remove(item); |
555 } |
708 } |
556 } |
709 } |
557 |
710 |
558 /*! |
711 /*! |
559 Returns locale specific formatting string for hours and minutes. |
712 Deletes the dynamic setting items under the serverinfo group item. |
560 \return Time format string. |
713 */ |
561 */ |
714 void NmIpsSettingsHelper::deleteServerInfoGroupDynamicItems() |
562 QString NmIpsSettingsHelper::timeFormat() |
715 { |
563 { |
716 if(mServerInfoDynamicItemsVisible) { |
564 // Set the correct time format string based on locale. |
717 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingLoginName); |
565 HbExtendedLocale locale = HbExtendedLocale::system(); |
718 mDataForm.removeConnection(item, SIGNAL(editingFinished()), |
566 QString timeFormat("h:mm ap"); |
719 this, SLOT(saveOutgoingUserName())); |
567 if (HbExtendedLocale::Time24 == locale.timeStyle()) { |
720 mDataForm.removeConnection(item, SIGNAL(textChanged(QString)), |
568 timeFormat = QString("h:mm"); |
721 this, SLOT(outgoingUserNameTextChange(QString))); |
569 } |
722 int index = mServerInfoGroupItem->indexOf(item); |
570 // Set the separator between hours and minutes. |
723 mServerInfoGroupItem->removeChild(index); |
571 timeFormat.replace(QString(":"), locale.timeSeparator(1)); |
724 mContentItems.remove(IpsServices::OutgoingLoginName); |
572 |
725 |
573 return timeFormat; |
726 item = mContentItems.value(IpsServices::OutgoingPassword); |
574 } |
727 mDataForm.removeConnection(item, SIGNAL(editingFinished()), |
|
728 this, SLOT(saveOutgoingPassword())); |
|
729 index = mServerInfoGroupItem->indexOf(item); |
|
730 mServerInfoGroupItem->removeChild(index); |
|
731 mContentItems.remove(IpsServices::OutgoingPassword); |
|
732 mServerInfoDynamicItemsVisible = false; |
|
733 } |
|
734 } |
|
735 |
575 /*! |
736 /*! |
576 Saves the incoming mailserver value into database if user has changed the value. |
737 Saves the incoming mailserver value into database if user has changed the value. |
577 */ |
738 */ |
578 void NmIpsSettingsHelper::saveIncomingMailServer() |
739 void NmIpsSettingsHelper::saveIncomingMailServer() |
579 { |
740 { |
635 emit goOffline(mSettingsManager.mailboxId()); |
796 emit goOffline(mSettingsManager.mailboxId()); |
636 mEmitOnline = true; |
797 mEmitOnline = true; |
637 int port = mSettingsManager.determineDefaultIncomingPort(); |
798 int port = mSettingsManager.determineDefaultIncomingPort(); |
638 mSettingsManager.writeSetting(IpsServices::IncomingPort, port); |
799 mSettingsManager.writeSetting(IpsServices::IncomingPort, port); |
639 } else if (index == IpsServices::NmIpsSettingsUserDefined) { |
800 } else if (index == IpsServices::NmIpsSettingsUserDefined) { |
640 QVariant port; |
801 showIncomingPortInputDialog(); |
641 mSettingsManager.readSetting(IpsServices::IncomingPort, port); |
802 } |
642 bool changed = false; |
803 } |
643 int changedPort = showIncomingPortInputDialog(port.toInt(), changed); |
804 |
644 if (changed) { |
805 /*! |
645 emit goOffline(mSettingsManager.mailboxId()); |
806 Show a input dialog for allowing the user to specify a incoming port. |
646 mEmitOnline = true; |
807 */ |
647 mSettingsManager.writeSetting(IpsServices::IncomingPort, changedPort); |
808 void NmIpsSettingsHelper::showIncomingPortInputDialog() |
648 } else { |
809 { |
649 //set selected value back if user canceled. |
810 // User can open the dialog multiple times, so delete the old ones first. |
650 HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPort); |
811 delete mIncomingPortInputDialog; |
651 item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex); |
812 mIncomingPortInputDialog = 0; |
652 } |
813 delete mIncomingPortInputValidator; |
|
814 mIncomingPortInputValidator = 0; |
|
815 |
|
816 mIncomingPortInputDialog = new HbInputDialog(); |
|
817 mIncomingPortInputDialog->setInputMode(HbInputDialog::IntInput); |
|
818 QVariant currentPort; |
|
819 mSettingsManager.readSetting(IpsServices::IncomingPort, currentPort); |
|
820 mIncomingPortInputValidator = new HbValidator(); |
|
821 mIncomingPortInputValidator->addField(new QIntValidator(0, 65535, 0), |
|
822 HbStringUtil::convertDigits(QString::number(currentPort.toInt()))); |
|
823 mIncomingPortInputDialog->setValidator(mIncomingPortInputValidator); |
|
824 mIncomingPortInputDialog->setPromptText( |
|
825 hbTrId("txt_mailips_setlabel_incoming_port_user_defined")); |
|
826 |
|
827 mIncomingPortInputDialog->open(this, SLOT(handleUserDefinedIncomingPortInput(HbAction *))); |
|
828 } |
|
829 |
|
830 /*! |
|
831 Handels the saving of the port new value. |
|
832 */ |
|
833 void NmIpsSettingsHelper::handleUserDefinedIncomingPortInput(HbAction *action) |
|
834 { |
|
835 if (action == mIncomingPortInputDialog->primaryAction()) { |
|
836 QVariant newPort = mIncomingPortInputDialog->value(); |
|
837 emit goOffline(mSettingsManager.mailboxId()); |
|
838 mEmitOnline = true; |
|
839 mSettingsManager.writeSetting(IpsServices::IncomingPort, newPort); |
|
840 } else { |
|
841 //set selected value back if user canceled. |
|
842 HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPort); |
|
843 item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex); |
653 } |
844 } |
654 } |
845 } |
655 |
846 |
656 /*! |
847 /*! |
657 Used for getting the index to display in the port radio button list |
848 Used for getting the index to display in the port radio button list |
787 } |
950 } |
788 |
951 |
789 /*! |
952 /*! |
790 Saves the folderpath value into database if user has changed the value. |
953 Saves the folderpath value into database if user has changed the value. |
791 */ |
954 */ |
792 void NmIpsSettingsHelper::inboxPathChange(int index) |
955 void NmIpsSettingsHelper::folderPathChange(int index) |
793 { |
956 { |
794 if (mRadioButtonPreviousIndex != index && index == IpsServices::NmIpsSettingsDefault) { |
957 if (mRadioButtonPreviousIndex != index && index == IpsServices::NmIpsSettingsDefault) { |
795 // Empty string sets the folder path to default. |
958 // Empty string sets the folder path to default. |
796 mSettingsManager.writeSetting(IpsServices::FolderPath, QString("")); |
959 mSettingsManager.writeSetting(IpsServices::FolderPath, QString("")); |
797 } else if (index == IpsServices::NmIpsSettingsUserDefined) { |
960 } else if (index == IpsServices::NmIpsSettingsUserDefined) { |
798 bool changed = false; |
961 showFolderPathInputDialog(); |
799 HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath); |
962 } |
800 QString changedPath = showFolderPathInputDialog(changed); |
963 } |
801 if (changed) { |
964 |
802 mSettingsManager.writeSetting(IpsServices::FolderPath, changedPath); |
965 /*! |
803 //set selected index to default if user inputed empty string. |
966 Show a input dialog for allowing the user to specify a folder path. |
804 if (changedPath.isEmpty()) { |
967 */ |
805 item->setContentWidgetData(QString("selected"), IpsServices::NmIpsSettingsDefault); |
968 void NmIpsSettingsHelper::showFolderPathInputDialog() |
806 } |
969 { |
807 } else { |
970 // User can open the dialog multiple times, so delete the old one first. |
808 //set selected value back if user canceled. |
971 delete mFolderPathInputDialog; |
809 item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex); |
972 mFolderPathInputDialog = 0; |
810 } |
973 |
811 } |
|
812 } |
|
813 |
|
814 /*! |
|
815 Show a input dialog for allowing the user to specify a folder path |
|
816 \param bool Reference used for marking if the value really changed |
|
817 \return QString The user defined folder path |
|
818 */ |
|
819 QString NmIpsSettingsHelper::showFolderPathInputDialog(bool &changed) |
|
820 { |
|
821 QVariant folderPath; |
974 QVariant folderPath; |
822 mSettingsManager.readSetting(IpsServices::FolderPath, folderPath); |
975 mSettingsManager.readSetting(IpsServices::FolderPath, folderPath); |
823 |
976 |
824 HbInputDialog inputDialog; |
977 mFolderPathInputDialog = new HbInputDialog(); |
825 inputDialog.setInputMode(HbInputDialog::TextInput); |
978 mFolderPathInputDialog->setInputMode(HbInputDialog::TextInput); |
826 inputDialog.setPromptText(hbTrId("txt_mailips_setlabel_inbox_path_user_defined")); |
979 mFolderPathInputDialog->setPromptText(hbTrId("txt_mailips_setlabel_folder_path_user_defined")); |
827 inputDialog.setValue(folderPath.toString()); |
980 mFolderPathInputDialog->setValue(folderPath.toString()); |
828 |
981 |
829 HbAction *action = inputDialog.exec(); |
982 mFolderPathInputDialog->open(this, SLOT(handleUserDefinedFolderPathInput(HbAction *))); |
830 if (action == inputDialog.primaryAction()) { |
983 } |
831 folderPath = inputDialog.value(); |
984 |
832 changed = true; |
985 /*! |
833 } |
986 Handels the saving of the folder path new value. |
834 |
987 */ |
835 return folderPath.toString(); |
988 void NmIpsSettingsHelper::handleUserDefinedFolderPathInput(HbAction *action) |
836 } |
989 { |
837 |
990 HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath); |
838 /*! |
991 |
839 Sets the previous index value to indicate that user has edited the field |
992 if (action == mFolderPathInputDialog->primaryAction()) { |
|
993 QVariant newFolderPath = mFolderPathInputDialog->value(); |
|
994 mSettingsManager.writeSetting(IpsServices::FolderPath, newFolderPath); |
|
995 //set selected index to default if user inputed empty string. |
|
996 if (newFolderPath.toString().isEmpty()) { |
|
997 item->setContentWidgetData(QString("selected"), IpsServices::NmIpsSettingsDefault); |
|
998 } |
|
999 } else { |
|
1000 //set selected value back if user canceled. |
|
1001 item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex); |
|
1002 } |
|
1003 } |
|
1004 |
|
1005 /*! |
|
1006 Sets the previous index value to indicate that user has edited the field. |
840 |
1007 |
841 \param text Reference to the item in the radio button list. |
1008 \param text Reference to the item in the radio button list. |
842 */ |
1009 */ |
843 void NmIpsSettingsHelper::inboxPathPressed(const QModelIndex &index) |
1010 void NmIpsSettingsHelper::folderPathPress(const QModelIndex &index) |
844 { |
1011 { |
845 Q_UNUSED(index); |
1012 Q_UNUSED(index); |
846 HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath); |
1013 HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath); |
847 QVariant data = item->contentWidgetData(QString("selected")); |
1014 QVariant data = item->contentWidgetData(QString("selected")); |
848 mRadioButtonPreviousIndex = data.toInt(); |
1015 mRadioButtonPreviousIndex = data.toInt(); |
849 } |
1016 } |
850 |
1017 |
851 /*! |
1018 /*! |
852 |
1019 Handles weekdays modifications. |
853 */ |
1020 */ |
854 void NmIpsSettingsHelper::receivingWeekdaysModified(HbAction *action) |
1021 void NmIpsSettingsHelper::receivingWeekdaysModified() |
855 { |
1022 { |
856 Q_UNUSED(action) |
|
857 HbDataFormModelItem *item = mContentItems.value(IpsServices::ReceptionWeekDays); |
1023 HbDataFormModelItem *item = mContentItems.value(IpsServices::ReceptionWeekDays); |
858 QVariant widgetData = item->contentWidgetData(QString("selectedItems")); |
1024 QVariant widgetData = item->contentWidgetData(QString("selectedItems")); |
859 QList< QVariant > selectedItems = widgetData.value< QList< QVariant > >(); |
1025 QList<QVariant> selectedIndexes = widgetData.value< QList<QVariant> >(); |
860 |
1026 QVariant itemData = item->data(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1); |
861 foreach (QVariant selection, selectedItems) { |
1027 QList<QVariant> itemValues = itemData.value< QList<QVariant> >(); |
862 int value = selection.toInt(); |
1028 |
863 } |
1029 int days(0); |
864 } |
1030 foreach (QVariant selectedIndex, selectedIndexes) { |
865 |
1031 days |= itemValues.at(selectedIndex.toInt()).toInt(); |
866 /*! |
1032 } |
867 |
1033 |
868 */ |
1034 handleReceivingScheduleSettingChange(IpsServices::ReceptionWeekDays, days); |
869 void NmIpsSettingsHelper::startTimeModified() |
1035 |
870 { |
1036 // Every weekday selected. |
871 HbDataFormModelItem *item = mContentItems.value(IpsServices::ReceptionDayStartTime); |
1037 if (days == 0x7f) { |
872 QVariant data = item->contentWidgetData(QString("dateTime")); |
1038 item->setContentWidgetData(QString("text"), |
873 QDateTime dateTime = data.value< QDateTime >(); |
1039 hbTrId("txt_mailips_setlabel_download_images_val_every_day")); |
874 int startHour(dateTime.time().hour()); |
1040 } |
875 handleReceivingScheduleSettingChange(IpsServices::ReceptionDayStartTime, startHour); |
1041 } |
876 } |
1042 |
877 |
1043 /*! |
878 /*! |
1044 Handles start time modifications. |
879 |
1045 |
|
1046 \param time Modified start time. |
|
1047 */ |
|
1048 void NmIpsSettingsHelper::startTimeModified(QTime time) |
|
1049 { |
|
1050 int startTime(time.hour()*60 + time.minute()); |
|
1051 handleReceivingScheduleSettingChange(IpsServices::ReceptionDayStartTime, startTime); |
|
1052 } |
|
1053 |
|
1054 /*! |
|
1055 Handles refresh period modifications. |
|
1056 |
|
1057 \param index selected item index. |
880 */ |
1058 */ |
881 void NmIpsSettingsHelper::refreshPeriodModified(int index) |
1059 void NmIpsSettingsHelper::refreshPeriodModified(int index) |
882 { |
1060 { |
883 HbDataFormModelItem* item = mContentItems.value(IpsServices::ReceptionRefreshPeriodDayTime); |
1061 HbDataFormModelItem* item = mContentItems.value(IpsServices::ReceptionRefreshPeriodDayTime); |
884 QVariant itemData = item->data(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1); |
1062 QVariant itemData = item->data(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1); |
885 int selectedValue = itemData.value< QList< QVariant > >().at(index).toInt(); |
1063 int selectedValue = itemData.value< QList< QVariant > >().at(index).toInt(); |
886 handleReceivingScheduleSettingChange(IpsServices::ReceptionRefreshPeriodDayTime, selectedValue); |
1064 handleReceivingScheduleSettingChange(IpsServices::ReceptionRefreshPeriodDayTime, selectedValue); |
887 } |
1065 } |
888 |
1066 |
889 /*! |
1067 /*! |
890 |
1068 Handles end time modifications. |
891 */ |
1069 |
892 void NmIpsSettingsHelper::endTimeModified() |
1070 \param time Modified start time. |
893 { |
1071 */ |
894 HbDataFormModelItem *item = mContentItems.value(IpsServices::ReceptionDayEndTime); |
1072 void NmIpsSettingsHelper::endTimeModified(QTime time) |
895 QVariant data = item->contentWidgetData(QString("dateTime")); |
1073 { |
896 QDateTime dateTime = data.value< QDateTime >(); |
1074 int endTime(time.hour()*60 + time.minute()); |
897 int endHour(dateTime.time().hour()); |
1075 handleReceivingScheduleSettingChange(IpsServices::ReceptionDayEndTime, endTime); |
898 handleReceivingScheduleSettingChange(IpsServices::ReceptionDayEndTime, endHour); |
|
899 } |
1076 } |
900 |
1077 |
901 /*! |
1078 /*! |
902 Used for getting the index to display in the inbox path radio button list |
1079 Used for getting the index to display in the inbox path radio button list |
903 |
1080 |
980 emit goOffline(mSettingsManager.mailboxId()); |
1164 emit goOffline(mSettingsManager.mailboxId()); |
981 mEmitOnline = true; |
1165 mEmitOnline = true; |
982 int port = mSettingsManager.determineDefaultOutgoingPort(); |
1166 int port = mSettingsManager.determineDefaultOutgoingPort(); |
983 mSettingsManager.writeSetting(IpsServices::OutgoingPort, port); |
1167 mSettingsManager.writeSetting(IpsServices::OutgoingPort, port); |
984 } else if (index == IpsServices::NmIpsSettingsUserDefined) { |
1168 } else if (index == IpsServices::NmIpsSettingsUserDefined) { |
985 QVariant port; |
1169 showOutgoingPortInputDialog(); |
986 mSettingsManager.readSetting(IpsServices::OutgoingPort, port); |
1170 } |
987 bool changed = false; |
1171 } |
988 int changedPort = showOutgoingPortInputDialog(port.toInt(), changed); |
1172 |
989 if (changed) { |
1173 /*! |
990 emit goOffline(mSettingsManager.mailboxId()); |
1174 Show a input dialog for allowing the user to specify a outgoing port. |
991 mEmitOnline = true; |
1175 |
992 mSettingsManager.writeSetting(IpsServices::OutgoingPort, changedPort); |
1176 */ |
993 } else { |
1177 void NmIpsSettingsHelper::showOutgoingPortInputDialog() |
994 //set selected value back if user canceled. |
1178 { |
995 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort); |
1179 // User can open the dialog multiple times, so delete the old ones first. |
996 item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex); |
1180 delete mOutgoingPortInputDialog; |
997 } |
1181 mOutgoingPortInputDialog = 0; |
|
1182 delete mOutgoingPortInputValidator; |
|
1183 mOutgoingPortInputValidator = 0; |
|
1184 |
|
1185 mOutgoingPortInputDialog = new HbInputDialog(); |
|
1186 mOutgoingPortInputDialog->setInputMode(HbInputDialog::IntInput); |
|
1187 QVariant currentPort; |
|
1188 mSettingsManager.readSetting(IpsServices::OutgoingPort, currentPort); |
|
1189 mOutgoingPortInputValidator = new HbValidator(); |
|
1190 mOutgoingPortInputValidator->addField(new QIntValidator(0, 65535, 0), |
|
1191 HbStringUtil::convertDigits(QString::number(currentPort.toInt()))); |
|
1192 mOutgoingPortInputDialog->setValidator(mOutgoingPortInputValidator); |
|
1193 mOutgoingPortInputDialog->setPromptText( |
|
1194 hbTrId("txt_mailips_setlabel_incoming_port_user_defined")); |
|
1195 |
|
1196 mOutgoingPortInputDialog->open(this, SLOT(handleUserDefinedOutgoingPortInput(HbAction *))); |
|
1197 } |
|
1198 |
|
1199 /*! |
|
1200 Handels the saving of the port new value. |
|
1201 */ |
|
1202 void NmIpsSettingsHelper::handleUserDefinedOutgoingPortInput(HbAction *action) |
|
1203 { |
|
1204 if (action == mOutgoingPortInputDialog->primaryAction()) { |
|
1205 QVariant newPort = mOutgoingPortInputDialog->value(); |
|
1206 emit goOffline(mSettingsManager.mailboxId()); |
|
1207 mEmitOnline = true; |
|
1208 mSettingsManager.writeSetting(IpsServices::OutgoingPort, newPort); |
|
1209 } else { |
|
1210 //set selected value back if user canceled. |
|
1211 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort); |
|
1212 item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex); |
998 } |
1213 } |
999 } |
1214 } |
1000 |
1215 |
1001 /*! |
1216 /*! |
1002 Sets the previous index value to indicate that user has edited the field |
1217 Sets the previous index value to indicate that user has edited the field |
1003 |
1218 |
1004 \param index Reference to the item in the radio button list. |
1219 \param index Reference to the item in the radio button list. |
1005 */ |
1220 */ |
1006 void NmIpsSettingsHelper::outgoingPortPressed(const QModelIndex &index) |
1221 void NmIpsSettingsHelper::outgoingPortPress(const QModelIndex &index) |
1007 { |
1222 { |
1008 Q_UNUSED(index); |
1223 Q_UNUSED(index); |
1009 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort); |
1224 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort); |
1010 QVariant data = item->contentWidgetData(QString("selected")); |
1225 QVariant data = item->contentWidgetData(QString("selected")); |
1011 mRadioButtonPreviousIndex = data.toInt(); |
1226 mRadioButtonPreviousIndex = data.toInt(); |
1012 } |
|
1013 |
|
1014 /*! |
|
1015 Show a input dialog for allowing the user to specify a outgoing port |
|
1016 \param int The current port stored in the settings |
|
1017 \param bool Reference used for marking if the value really changed |
|
1018 \return int The user defined port |
|
1019 */ |
|
1020 int NmIpsSettingsHelper::showOutgoingPortInputDialog(int currentPort, bool &changed) |
|
1021 { |
|
1022 QVariant newPort; |
|
1023 |
|
1024 HbInputDialog inputDialog; |
|
1025 inputDialog.setInputMode(HbInputDialog::IntInput); |
|
1026 HbValidator *validator = new HbValidator(); |
|
1027 validator->addField(new QIntValidator(0, 65535, 0), |
|
1028 HbStringUtil::convertDigits(QString::number(currentPort))); |
|
1029 inputDialog.setValidator(validator); |
|
1030 inputDialog.setPromptText(hbTrId("txt_mailips_setlabel_incoming_port_user_defined")); |
|
1031 |
|
1032 HbAction *action = inputDialog.exec(); |
|
1033 if (action == inputDialog.primaryAction()) { |
|
1034 newPort = inputDialog.value(); |
|
1035 changed = true; |
|
1036 } |
|
1037 delete validator; |
|
1038 |
|
1039 return newPort.toInt(); |
|
1040 } |
1227 } |
1041 |
1228 |
1042 /*! |
1229 /*! |
1043 Used for getting the index to display in the outgoing port radio button list |
1230 Used for getting the index to display in the outgoing port radio button list |
1044 |
1231 |
1055 } |
1242 } |
1056 return index; |
1243 return index; |
1057 } |
1244 } |
1058 |
1245 |
1059 /*! |
1246 /*! |
|
1247 Used for getting the index to display in the outgoing authentication radio button list |
|
1248 |
|
1249 \return index Used to set the selected value |
|
1250 */ |
|
1251 int NmIpsSettingsHelper::getCorrectOutgoingAuthenticationRadioButtonIndex() |
|
1252 { |
|
1253 int index(IpsServices::EMailAuthNone); |
|
1254 QVariant temp; |
|
1255 bool outgoingAuthentication; |
|
1256 QString outgoingLoginName; |
|
1257 QString outgoingPassword; |
|
1258 QString incomingLoginName; |
|
1259 QString incomingPassword; |
|
1260 mSettingsManager.readSetting(IpsServices::SMTPAuthentication, temp); |
|
1261 outgoingAuthentication = temp.toBool(); |
|
1262 mSettingsManager.readSetting(IpsServices::OutgoingLoginName, temp); |
|
1263 outgoingLoginName = temp.toString(); |
|
1264 mSettingsManager.readSetting(IpsServices::OutgoingPassword, temp); |
|
1265 outgoingPassword = temp.toString(); |
|
1266 mSettingsManager.readSetting(IpsServices::IncomingLoginName, temp); |
|
1267 incomingLoginName = temp.toString(); |
|
1268 mSettingsManager.readSetting(IpsServices::IncomingPassword, temp); |
|
1269 incomingPassword = temp.toString(); |
|
1270 |
|
1271 if (outgoingAuthentication) { |
|
1272 if (outgoingLoginName == incomingLoginName && outgoingPassword == incomingPassword) { |
|
1273 index = IpsServices::EMailAuthSameAsIncoming; |
|
1274 } else { |
|
1275 index = IpsServices::EMailAuthUserAuthentication; |
|
1276 } |
|
1277 } |
|
1278 return index; |
|
1279 } |
|
1280 |
|
1281 /*! |
1060 Saves the outgoing secure connection value into database if user has changed the value. |
1282 Saves the outgoing secure connection value into database if user has changed the value. |
1061 */ |
1283 */ |
1062 void NmIpsSettingsHelper::outgoingSecureConnectionItemChange(int index) |
1284 void NmIpsSettingsHelper::outgoingSecureConnectionItemChange(int index) |
1063 { |
1285 { |
1064 if (mRadioButtonPreviousIndex != index) { |
1286 if (mRadioButtonPreviousIndex != index) { |
1065 emit goOffline(mSettingsManager.mailboxId()); |
1287 emit goOffline(mSettingsManager.mailboxId()); |
1066 mEmitOnline = true; |
1288 mEmitOnline = true; |
1067 switch (index) { |
1289 switch (index) { |
1068 case IpsServices::EMailStartTls: // On (Start TLS) |
1290 case IpsServices::EMailStartTls: // On (Start TLS) |
1069 mSettingsManager.writeSetting(IpsServices::OutgoingSecureSockets, ETrue); |
1291 mSettingsManager.writeSetting(IpsServices::OutgoingSecureSockets, true); |
1070 mSettingsManager.writeSetting(IpsServices::OutgoingSSLWrapper, EFalse); |
1292 mSettingsManager.writeSetting(IpsServices::OutgoingSSLWrapper, false); |
1071 break; |
1293 break; |
1072 |
1294 |
1073 case IpsServices::EMailSslTls: // On (SSL/TLS) |
1295 case IpsServices::EMailSslTls: // On (SSL/TLS) |
1074 mSettingsManager.writeSetting(IpsServices::OutgoingSecureSockets, EFalse); |
1296 mSettingsManager.writeSetting(IpsServices::OutgoingSecureSockets, false); |
1075 mSettingsManager.writeSetting(IpsServices::OutgoingSSLWrapper, ETrue); |
1297 mSettingsManager.writeSetting(IpsServices::OutgoingSSLWrapper, true); |
1076 break; |
1298 break; |
1077 |
1299 |
1078 case IpsServices::EMailSecurityOff: // Off |
1300 case IpsServices::EMailSecurityOff: // Off |
1079 mSettingsManager.writeSetting(IpsServices::OutgoingSecureSockets, EFalse); |
1301 mSettingsManager.writeSetting(IpsServices::OutgoingSecureSockets, false); |
1080 mSettingsManager.writeSetting(IpsServices::OutgoingSSLWrapper, EFalse); |
1302 mSettingsManager.writeSetting(IpsServices::OutgoingSSLWrapper, false); |
1081 break; |
1303 break; |
1082 |
1304 |
1083 default: |
1305 default: |
1084 break; |
1306 break; |
1085 } |
1307 } |
1097 /*! |
1319 /*! |
1098 Sets the previous index value to indicate that user has edited the field |
1320 Sets the previous index value to indicate that user has edited the field |
1099 |
1321 |
1100 \param text Reference to the item in the radio button list. |
1322 \param text Reference to the item in the radio button list. |
1101 */ |
1323 */ |
1102 void NmIpsSettingsHelper::outgoingSecureConnectionPressed(const QModelIndex &index) |
1324 void NmIpsSettingsHelper::outgoingSecureConnectionPress(const QModelIndex &index) |
1103 { |
1325 { |
1104 Q_UNUSED(index); |
1326 Q_UNUSED(index); |
1105 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingSecureSockets); |
1327 HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingSecureSockets); |
1106 QVariant data = item->contentWidgetData(QString("selected")); |
1328 QVariant data = item->contentWidgetData(QString("selected")); |
1107 mRadioButtonPreviousIndex = data.toInt(); |
1329 mRadioButtonPreviousIndex = data.toInt(); |
1108 } |
1330 } |
1109 |
1331 |
|
1332 /*! |
|
1333 Saves the outgoing authetication value into database if user has changed the value and |
|
1334 updates dynamic group items. |
|
1335 */ |
|
1336 void NmIpsSettingsHelper::outgoingAuthenticationChange(int index) |
|
1337 { |
|
1338 if (mRadioButtonPreviousIndex != index) { |
|
1339 QVariant loginName; |
|
1340 QVariant loginPassword; |
|
1341 emit goOffline(mSettingsManager.mailboxId()); |
|
1342 mEmitOnline = true; |
|
1343 switch (index) { |
|
1344 case IpsServices::EMailAuthNone: // No authentication |
|
1345 deleteServerInfoGroupDynamicItems(); |
|
1346 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, false); |
|
1347 break; |
|
1348 |
|
1349 case IpsServices::EMailAuthSameAsIncoming: // Same as Incoming |
|
1350 deleteServerInfoGroupDynamicItems(); |
|
1351 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true); |
|
1352 |
|
1353 mSettingsManager.readSetting(IpsServices::IncomingLoginName, loginName); |
|
1354 mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, loginName); |
|
1355 |
|
1356 mSettingsManager.readSetting(IpsServices::IncomingPassword, loginPassword); |
|
1357 mSettingsManager.writeSetting(IpsServices::OutgoingPassword, loginPassword); |
|
1358 break; |
|
1359 |
|
1360 case IpsServices::EMailAuthUserAuthentication: // User authentication |
|
1361 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true); |
|
1362 createServerInfoGroupDynamicItems(); |
|
1363 break; |
|
1364 |
|
1365 default: |
|
1366 break; |
|
1367 } |
|
1368 } |
|
1369 } |
|
1370 |
|
1371 /*! |
|
1372 Sets the previous index value to indicate that user has edited the field |
|
1373 |
|
1374 \param text Reference to the item in the radio button list. |
|
1375 */ |
|
1376 void NmIpsSettingsHelper::outgoingAuthenticationPress(const QModelIndex &index) |
|
1377 { |
|
1378 Q_UNUSED(index); |
|
1379 HbDataFormModelItem *item = mContentItems.value(IpsServices::SMTPAuthentication); |
|
1380 QVariant data = item->contentWidgetData(QString("selected")); |
|
1381 mRadioButtonPreviousIndex = data.toInt(); |
|
1382 } |
|
1383 |