ipsservices/nmipssettings/src/nmipssettingshelper.cpp
changeset 76 38bf5461e270
parent 74 6c59112cfd31
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
    42 
    42 
    43 #include "nmipssettingshelper.h"
    43 #include "nmipssettingshelper.h"
    44 #include "nmipssettingsmanagerbase.h"
    44 #include "nmipssettingsmanagerbase.h"
    45 #include "nmipssettingscustomitem.h"
    45 #include "nmipssettingscustomitem.h"
    46 #include "nmipsextendedsettingsmanager.h"
    46 #include "nmipsextendedsettingsmanager.h"
       
    47 #include "nmipssettingsdeletemailboxop.h"
    47 
    48 
    48 // CONSTANTS
    49 // CONSTANTS
    49 
    50 
    50 // Dynamic receiving schedule items.
    51 // Dynamic receiving schedule items.
    51 static const IpsServices::SettingItem NmIpsSettingsReceivingScheduleItems[] = {
    52 static const IpsServices::SettingItem NmIpsSettingsReceivingScheduleItems[] = {
    98   mFolderPathInputDialog(NULL),
    99   mFolderPathInputDialog(NULL),
    99   mOutgoingPortInputDialog(NULL),
   100   mOutgoingPortInputDialog(NULL),
   100   mOutgoingPortInputValidator(NULL),
   101   mOutgoingPortInputValidator(NULL),
   101   mDestinationDialog(NULL),
   102   mDestinationDialog(NULL),
   102   mServerInfoDynamicItemsVisible(false),
   103   mServerInfoDynamicItemsVisible(false),
   103   mAbortDynamicRSItemHandling(false)
   104   mAbortDynamicRSItemHandling(false),
       
   105   mDeleteOp(NULL)
   104 {
   106 {
   105     QVariant inboxValue;
   107     QVariant inboxValue;
   106     mSettingsManager.readSetting(IpsServices::ReceptionInboxSyncWindow, inboxValue);
   108     mSettingsManager.readSetting(IpsServices::ReceptionInboxSyncWindow, inboxValue);
   107     mPrevInboxCount = inboxValue.toInt();
   109     mPrevInboxCount = inboxValue.toInt();
   108 }
   110 }
   111     Destructor of NmIpsSettingsHelper.
   113     Destructor of NmIpsSettingsHelper.
   112 */
   114 */
   113 NmIpsSettingsHelper::~NmIpsSettingsHelper()
   115 NmIpsSettingsHelper::~NmIpsSettingsHelper()
   114 {
   116 {
   115     mContentItems.clear();
   117     mContentItems.clear();
       
   118     delete mDeleteOp;
   116     delete mDeleteConfirmationDialog;
   119     delete mDeleteConfirmationDialog;
   117     delete mIncomingPortInputDialog;
   120     delete mIncomingPortInputDialog;
   118     delete mIncomingPortInputValidator;
   121     delete mIncomingPortInputValidator;
   119     delete mFolderPathInputDialog;
   122     delete mFolderPathInputDialog;
   120     delete mOutgoingPortInputDialog;
   123     delete mOutgoingPortInputDialog;
   203 
   206 
   204                     formItemData->setData(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1,
   207                     formItemData->setData(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1,
   205                         weekdayItemValues);
   208                         weekdayItemValues);
   206 
   209 
   207                     formItemData->setContentWidgetData("heading",
   210                     formItemData->setContentWidgetData("heading",
   208                         hbTrId("txt_mailips_dialog_heading_receiving_weekdays"));
   211                         hbTrId("txt_mailips_dialog_heading_receiving_days"));
   209 
   212 
   210                     formItemData->setContentWidgetData("items", weekdayItems);
   213                     formItemData->setContentWidgetData("items", weekdayItems);
   211 
   214 
   212                     mDataForm.addConnection(formItemData, SIGNAL(editingFinished()),
   215                     mDataForm.addConnection(formItemData, SIGNAL(editingFinished()),
   213                         this, SLOT(receivingWeekdaysModified()));
   216                         this, SLOT(receivingWeekdaysModified()));
   595 /*!
   598 /*!
   596     Shows the confirmation dialog for user.
   599     Shows the confirmation dialog for user.
   597 */
   600 */
   598 void NmIpsSettingsHelper::deleteButtonPress()
   601 void NmIpsSettingsHelper::deleteButtonPress()
   599 {
   602 {
   600     if(!mDeleteConfirmationDialog) {
   603     if( !mDeleteOp ) {
   601         mDeleteConfirmationDialog =
   604         mDeleteOp = new NmIpsSettingsDeleteMailboxOp( mSettingsManager );
   602             new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   605         connect( mDeleteOp, SIGNAL(goOffline(const NmId &)), this, SIGNAL(goOffline(const NmId &)));
   603         mDeleteConfirmationDialog->setText(
   606         connect( mDeleteOp, SIGNAL(operationComplete(int,int)), 
   604             hbTrId("txt_mail_dialog_do_you_want_to_delete_the_mailbox"));
   607             this, SLOT(deleteOpComplete(int,int)));
   605         mDeleteConfirmationDialog->setTimeout(HbMessageBox::NoTimeout);
   608         mDeleteOp->startOperation();
   606         mDeleteConfirmationDialog->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
   609     }
   607     }
   610     
   608     mDeleteConfirmationDialog->open(this, SLOT(handleMailboxDelete(HbAction *)));
       
   609 }
       
   610 
       
   611 /*!
       
   612     Deletes mailbox and displays the proper notes.
       
   613 */
       
   614 void NmIpsSettingsHelper::handleMailboxDelete(HbAction *action)
       
   615 {
       
   616     if (action == mDeleteConfirmationDialog->actions().at(0)) {
       
   617         emit goOffline(mSettingsManager.mailboxId());
       
   618         mEmitOnline = false;
       
   619 
       
   620         QVariant mailboxName;
       
   621         mSettingsManager.readSetting(IpsServices::MailboxName, mailboxName);
       
   622 
       
   623         // Display the progress note. Before display the note, remove the cancel
       
   624         // button.
       
   625         HbProgressDialog progressNote(HbProgressDialog::WaitDialog);
       
   626         progressNote.setText(hbTrId("txt_common_info_deleting"));
       
   627         progressNote.removeAction(progressNote.actions().at(0));
       
   628         progressNote.delayedShow();
       
   629 
       
   630         if (!mSettingsManager.deleteMailbox()) {
       
   631             // The mailbox was deleted successfully.
       
   632 
       
   633             // Delete the mailbox also from AppLib.
       
   634             updateAppLib(UnregisterMailbox);
       
   635 
       
   636             // Hide the progress note and display the "mailbox deleted" dialog.
       
   637             progressNote.close();
       
   638 
       
   639             HbNotificationDialog *note = new HbNotificationDialog();
       
   640             QString noteText = hbTrId("txt_mail_dialog_1_deleted").arg(mailboxName.toString());
       
   641             note->setTitle(noteText);
       
   642             note->setAttribute(Qt::WA_DeleteOnClose);
       
   643             note->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *)));
       
   644         } else {
       
   645             // Failed to delete the mailbox!
       
   646             progressNote.close();
       
   647         }
       
   648     }
       
   649 }
   611 }
   650 
   612 
   651 /*!
   613 /*!
   652     Handles the event after the mailbox delete information dialog has been dismissed.
   614     Handles the event after the mailbox delete information dialog has been dismissed.
   653 */
   615 */
   654 void NmIpsSettingsHelper::handleMailboxDeleteUpdate(HbAction *action)
   616 void NmIpsSettingsHelper::handleMailboxDeleteUpdate(HbAction *action)
   655 {
   617 {
   656     Q_UNUSED(action);
   618     Q_UNUSED(action);
       
   619 
       
   620     delete mDeleteOp;
       
   621     mDeleteOp = NULL;
       
   622     
   657     // Emit the signal to update the UI.
   623     // Emit the signal to update the UI.
   658     emit mailboxListChanged(mSettingsManager.mailboxId(),
   624     emit mailboxListChanged(mSettingsManager.mailboxId(),
   659                             NmSettings::MailboxDeleted);
   625                             NmSettings::MailboxDeleted);
   660 }
   626 }
   661 
   627 
   676     }
   642     }
   677 
   643 
   678     // Read receiving schedule item values and
   644     // Read receiving schedule item values and
   679     // 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.
   680     mAbortDynamicRSItemHandling = false;
   646     mAbortDynamicRSItemHandling = false;
   681     for (int index(0); (index < NmIpsSettingsReceivingScheduleItemCount) &&
   647     for (int i(0); (i < NmIpsSettingsReceivingScheduleItemCount) &&
   682              !mAbortDynamicRSItemHandling; ++index) {
   648              !mAbortDynamicRSItemHandling; ++i) {
   683 
   649 
   684         // Read setting value from active profile
   650         // Read setting value from active profile
   685         QVariant setting;
   651         QVariant setting;
   686         IpsServices::SettingItem item(NmIpsSettingsReceivingScheduleItems[index]);
   652         IpsServices::SettingItem item(NmIpsSettingsReceivingScheduleItems[i]);
   687         mSettingsManager.readSetting(item, setting);
   653         mSettingsManager.readSetting(item, setting);
   688 
   654 
   689         // If setting value is not valid (-1=N/A) then remove setting item.
   655         // If setting value is not valid (-1=N/A) then remove setting item.
   690         if (setting.toInt() != NmIpsSettingsRecevingScheduleItemNotFound) {
   656         if (setting.toInt() != NmIpsSettingsRecevingScheduleItemNotFound) {
   691             createOrUpdateReceivingScheduleGroupDynamicItem(item);
   657             createOrUpdateReceivingScheduleGroupDynamicItem(item);
  1539 	if (selectedValue != previouslySelectedValue.toInt()) {
  1505 	if (selectedValue != previouslySelectedValue.toInt()) {
  1540 		handleReceivingScheduleSettingChange(IpsServices::ReceptionRefreshPeriodDayTime,
  1506 		handleReceivingScheduleSettingChange(IpsServices::ReceptionRefreshPeriodDayTime,
  1541 			selectedValue);
  1507 			selectedValue);
  1542 	}
  1508 	}
  1543 }
  1509 }
       
  1510 
       
  1511 void NmIpsSettingsHelper::deleteOpComplete( int result, int error)
       
  1512 {
       
  1513     Q_UNUSED(error);
       
  1514     if( result == DeleteMbResultSuccess ) {
       
  1515         // Show notification that mailbox has been deleted
       
  1516         QVariant mailboxName;
       
  1517         mSettingsManager.readSetting(IpsServices::MailboxName, mailboxName);
       
  1518 
       
  1519         HbNotificationDialog *note = new HbNotificationDialog();
       
  1520         QString noteText = hbTrId("txt_mail_dialog_1_deleted").arg(mailboxName.toString());
       
  1521         note->setTitle(noteText);
       
  1522         note->setAttribute(Qt::WA_DeleteOnClose);
       
  1523         note->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *)));
       
  1524     } else {
       
  1525         // Add error note here to be shown if delete operation has failed
       
  1526 
       
  1527         // delete operation
       
  1528         delete mDeleteOp;
       
  1529         mDeleteOp = NULL;
       
  1530     }
       
  1531 }
       
  1532