ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp
changeset 23 2dc6caa42ec3
parent 18 578830873419
child 27 9ba4404ef423
child 38 b4618f2cf6ac
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    31 
    31 
    32 /*!
    32 /*!
    33     Constructs a new NmPopClientPlugin.
    33     Constructs a new NmPopClientPlugin.
    34  */
    34  */
    35 NmPopClientPlugin::NmPopClientPlugin()
    35 NmPopClientPlugin::NmPopClientPlugin()
       
    36 : mSettingsViewLauncher(NULL),
       
    37 mListOptionsMenuRequest(NULL)
    36 {
    38 {
    37     NMLOG("NmPopClientPlugin::NmPopClientPlugin()-->");
    39     NMLOG("NmPopClientPlugin::NmPopClientPlugin()-->");
    38     NMLOG("<--NmPopClientPlugin::NmPopClientPlugin()");
    40     NMLOG("<--NmPopClientPlugin::NmPopClientPlugin()");
    39 }
    41 }
    40 
    42 
    42     Destructor.
    44     Destructor.
    43  */
    45  */
    44 NmPopClientPlugin::~NmPopClientPlugin()
    46 NmPopClientPlugin::~NmPopClientPlugin()
    45 {
    47 {
    46     NMLOG("NmPopClientPlugin::~NmPopClientPlugin()-->");
    48     NMLOG("NmPopClientPlugin::~NmPopClientPlugin()-->");
       
    49     delete mSettingsViewLauncher;
    47     NMLOG("<--NmPopClientPlugin::~NmPopClientPlugin()");
    50     NMLOG("<--NmPopClientPlugin::~NmPopClientPlugin()");
    48 }
    51 }
    49 
    52 
    50 
    53 
    51 /*!
    54 /*!
    69     ) {
    72     ) {
    70         NMLOG("NmPopClientPlugin::getActions(): PluginId incorrect.");
    73         NMLOG("NmPopClientPlugin::getActions(): PluginId incorrect.");
    71         NMLOG(QString("request.mailboxId().pluginId32()=%1").arg(request.mailboxId().pluginId32()));
    74         NMLOG(QString("request.mailboxId().pluginId32()=%1").arg(request.mailboxId().pluginId32()));
    72         return;
    75         return;
    73     }
    76     }
    74 	
    77 
    75     // Get the NmBaseClientPlugin implementation of the UI actions.
    78     // Get the NmBaseClientPlugin implementation of the UI actions.
    76     NmBaseClientPlugin::getActions(request, actionList);
    79     NmBaseClientPlugin::getActions(request, actionList);
       
    80 
       
    81     // Append POP plugin specific actions
       
    82     switch (request.menuType()) {
       
    83     case NmActionOptionsMenu:
       
    84         {
       
    85         if (request.contextView()==NmActionContextViewMessageList){
       
    86             mListOptionsMenuRequest = request;
       
    87             // Create sub-menu for standard folders selection
       
    88             HbMenu *standardFolders = new HbMenu();
       
    89             NmAction *inboxAction = new NmAction(0);
       
    90             inboxAction->setObjectName("popclientplugin_folders_inbox");
       
    91             inboxAction->setText(hbTrId("txt_mail_opt_folders_inbox"));
       
    92             inboxAction->setCheckable(true);
       
    93             connect(inboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderInbox()));
       
    94             standardFolders->addAction(inboxAction);
       
    95             NmAction *outboxAction = new NmAction(0);
       
    96             outboxAction->setObjectName("popclientplugin_folders_outbox");
       
    97             outboxAction->setText(hbTrId("txt_mail_opt_folders_outbox"));
       
    98             outboxAction->setCheckable(true);
       
    99             connect(outboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderOutbox()));
       
   100             standardFolders->addAction(outboxAction);
       
   101             NmAction *draftsAction = new NmAction(0);
       
   102             draftsAction->setObjectName("popclientplugin_folders_drafts");
       
   103             draftsAction->setText(hbTrId("txt_mail_opt_folders_drafts"));
       
   104             draftsAction->setCheckable(true);
       
   105             connect(draftsAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderDrafts()));
       
   106             standardFolders->addAction(draftsAction);
       
   107             NmAction *sentAction = new NmAction(0);
       
   108             sentAction->setObjectName("popclientplugin_folders_sent");
       
   109             sentAction->setText(hbTrId("txt_mail_opt_folders_sent"));
       
   110             sentAction->setCheckable(true);
       
   111             connect(sentAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderSent()));
       
   112             standardFolders->addAction(sentAction);
       
   113             // Set active action
       
   114             NmFolderType curFolderType(NmFolderOther);
       
   115             if (mUiEngine) {
       
   116                 curFolderType = mUiEngine->folderTypeById(request.mailboxId(),request.folderId());
       
   117             }
       
   118             switch (curFolderType){
       
   119                 case NmFolderInbox: {
       
   120                     inboxAction->setChecked(true);
       
   121                     break;
       
   122                 }
       
   123                 case NmFolderOutbox: {
       
   124                     outboxAction->setChecked(true);
       
   125                     break;
       
   126                 }
       
   127                 case NmFolderDrafts: {
       
   128                     draftsAction->setChecked(true);
       
   129                     break;
       
   130                 }
       
   131                 case NmFolderSent: {
       
   132                     sentAction->setChecked(true);
       
   133                     break;
       
   134                 }
       
   135             }
       
   136 
       
   137             // Add folders selection with sub-menu
       
   138             NmAction *foldersAction = new NmAction(0);
       
   139             foldersAction->setObjectName("baseclientplugin_folders");
       
   140             foldersAction->setText(hbTrId("txt_mail_opt_folders"));
       
   141             foldersAction->setMenu(standardFolders);
       
   142             actionList.append(foldersAction);
       
   143             }
       
   144         }
       
   145         break;
       
   146     default:
       
   147         break;
       
   148     }
       
   149 
    77     NMLOG("<--NmPopClientPlugin::getActions()");
   150     NMLOG("<--NmPopClientPlugin::getActions()");
       
   151 }
       
   152 
       
   153 /*!
       
   154     Slot connected to options menu settings NmAction.
       
   155     Opens mailbox settings.
       
   156  */
       
   157 void NmPopClientPlugin::settings()
       
   158 {
       
   159     NMLOG("NmPopClientPlugin::settings()-->");
       
   160 
       
   161     const NmId &id = mMenuRequest.mailboxId();
       
   162     NmMailboxMetaData *mailbox = mUiEngine->mailboxById(id);
       
   163 
       
   164     if (mailbox) {
       
   165         if (!mSettingsViewLauncher) {
       
   166             mSettingsViewLauncher = new NmSettingsViewLauncher();
       
   167 
       
   168             connect(mSettingsViewLauncher,
       
   169                 SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
       
   170                 this, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
       
   171 
       
   172             connect(mSettingsViewLauncher,
       
   173                 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
       
   174                 this, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
       
   175 
       
   176             connect(mSettingsViewLauncher,
       
   177                 SIGNAL(goOnline(const NmId &)),
       
   178                 this, SLOT(goOnline(const NmId &)));
       
   179 
       
   180             connect(mSettingsViewLauncher,
       
   181                 SIGNAL(goOffline(const NmId &)),
       
   182                 this, SLOT(goOffline(const NmId &)));
       
   183         }
       
   184 
       
   185         mSettingsViewLauncher->launchSettingsView(id, mailbox->name());
       
   186     }
       
   187 
       
   188     NMLOG("<--NmPopClientPlugin::settings()");
       
   189 }
       
   190 
       
   191 /*!
       
   192     Private slot to switch message list contents
       
   193     to standard folder inbox
       
   194 */
       
   195 void NmPopClientPlugin::switchToStandardFolderInbox()
       
   196 {
       
   197     if (mListOptionsMenuRequest.observer()){
       
   198         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderInbox);
       
   199         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   200                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   201                                   folderId);
       
   202         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   203     }
       
   204 }
       
   205 
       
   206 /*!
       
   207     Private slot to switch message list contents
       
   208     to standard folder outbox
       
   209 */
       
   210 void NmPopClientPlugin::switchToStandardFolderOutbox()
       
   211 {
       
   212     if (mListOptionsMenuRequest.observer()){
       
   213         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderOutbox);
       
   214         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   215                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   216                                   folderId);
       
   217         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   218     }
       
   219 }
       
   220 
       
   221 /*!
       
   222     Private slot to switch message list contents
       
   223     to standard folder drafts
       
   224 */
       
   225 void NmPopClientPlugin::switchToStandardFolderDrafts()
       
   226 {
       
   227     if (mListOptionsMenuRequest.observer()){
       
   228         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderDrafts);
       
   229         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   230                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   231                                   folderId);
       
   232         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   233     }
       
   234 }
       
   235 
       
   236 /*!
       
   237     Private slot to switch message list contents
       
   238     to standard folder sent
       
   239 */
       
   240 void NmPopClientPlugin::switchToStandardFolderSent()
       
   241 {
       
   242     if (mListOptionsMenuRequest.observer()){
       
   243         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderSent);
       
   244         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   245                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   246                                   folderId);
       
   247         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   248     }
    78 }
   249 }
    79 
   250 
    80 /*!
   251 /*!
    81     Provide id of plugin.
   252     Provide id of plugin.
    82     Implementation of NmUiExtensionInterface.
   253     Implementation of NmUiExtensionInterface.