ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp
changeset 23 2dc6caa42ec3
parent 18 578830873419
child 27 9ba4404ef423
child 38 b4618f2cf6ac
--- a/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Mon May 03 12:23:15 2010 +0300
+++ b/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Fri May 14 15:41:10 2010 +0300
@@ -33,6 +33,8 @@
     Constructs a new NmPopClientPlugin.
  */
 NmPopClientPlugin::NmPopClientPlugin()
+: mSettingsViewLauncher(NULL),
+mListOptionsMenuRequest(NULL)
 {
     NMLOG("NmPopClientPlugin::NmPopClientPlugin()-->");
     NMLOG("<--NmPopClientPlugin::NmPopClientPlugin()");
@@ -44,6 +46,7 @@
 NmPopClientPlugin::~NmPopClientPlugin()
 {
     NMLOG("NmPopClientPlugin::~NmPopClientPlugin()-->");
+    delete mSettingsViewLauncher;
     NMLOG("<--NmPopClientPlugin::~NmPopClientPlugin()");
 }
 
@@ -71,13 +74,181 @@
         NMLOG(QString("request.mailboxId().pluginId32()=%1").arg(request.mailboxId().pluginId32()));
         return;
     }
-	
+
     // Get the NmBaseClientPlugin implementation of the UI actions.
     NmBaseClientPlugin::getActions(request, actionList);
+
+    // Append POP plugin specific actions
+    switch (request.menuType()) {
+    case NmActionOptionsMenu:
+        {
+        if (request.contextView()==NmActionContextViewMessageList){
+            mListOptionsMenuRequest = request;
+            // Create sub-menu for standard folders selection
+            HbMenu *standardFolders = new HbMenu();
+            NmAction *inboxAction = new NmAction(0);
+            inboxAction->setObjectName("popclientplugin_folders_inbox");
+            inboxAction->setText(hbTrId("txt_mail_opt_folders_inbox"));
+            inboxAction->setCheckable(true);
+            connect(inboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderInbox()));
+            standardFolders->addAction(inboxAction);
+            NmAction *outboxAction = new NmAction(0);
+            outboxAction->setObjectName("popclientplugin_folders_outbox");
+            outboxAction->setText(hbTrId("txt_mail_opt_folders_outbox"));
+            outboxAction->setCheckable(true);
+            connect(outboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderOutbox()));
+            standardFolders->addAction(outboxAction);
+            NmAction *draftsAction = new NmAction(0);
+            draftsAction->setObjectName("popclientplugin_folders_drafts");
+            draftsAction->setText(hbTrId("txt_mail_opt_folders_drafts"));
+            draftsAction->setCheckable(true);
+            connect(draftsAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderDrafts()));
+            standardFolders->addAction(draftsAction);
+            NmAction *sentAction = new NmAction(0);
+            sentAction->setObjectName("popclientplugin_folders_sent");
+            sentAction->setText(hbTrId("txt_mail_opt_folders_sent"));
+            sentAction->setCheckable(true);
+            connect(sentAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderSent()));
+            standardFolders->addAction(sentAction);
+            // Set active action
+            NmFolderType curFolderType(NmFolderOther);
+            if (mUiEngine) {
+                curFolderType = mUiEngine->folderTypeById(request.mailboxId(),request.folderId());
+            }
+            switch (curFolderType){
+                case NmFolderInbox: {
+                    inboxAction->setChecked(true);
+                    break;
+                }
+                case NmFolderOutbox: {
+                    outboxAction->setChecked(true);
+                    break;
+                }
+                case NmFolderDrafts: {
+                    draftsAction->setChecked(true);
+                    break;
+                }
+                case NmFolderSent: {
+                    sentAction->setChecked(true);
+                    break;
+                }
+            }
+
+            // Add folders selection with sub-menu
+            NmAction *foldersAction = new NmAction(0);
+            foldersAction->setObjectName("baseclientplugin_folders");
+            foldersAction->setText(hbTrId("txt_mail_opt_folders"));
+            foldersAction->setMenu(standardFolders);
+            actionList.append(foldersAction);
+            }
+        }
+        break;
+    default:
+        break;
+    }
+
     NMLOG("<--NmPopClientPlugin::getActions()");
 }
 
 /*!
+    Slot connected to options menu settings NmAction.
+    Opens mailbox settings.
+ */
+void NmPopClientPlugin::settings()
+{
+    NMLOG("NmPopClientPlugin::settings()-->");
+
+    const NmId &id = mMenuRequest.mailboxId();
+    NmMailboxMetaData *mailbox = mUiEngine->mailboxById(id);
+
+    if (mailbox) {
+        if (!mSettingsViewLauncher) {
+            mSettingsViewLauncher = new NmSettingsViewLauncher();
+
+            connect(mSettingsViewLauncher,
+                SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
+                this, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
+
+            connect(mSettingsViewLauncher,
+                SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
+                this, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
+
+            connect(mSettingsViewLauncher,
+                SIGNAL(goOnline(const NmId &)),
+                this, SLOT(goOnline(const NmId &)));
+
+            connect(mSettingsViewLauncher,
+                SIGNAL(goOffline(const NmId &)),
+                this, SLOT(goOffline(const NmId &)));
+        }
+
+        mSettingsViewLauncher->launchSettingsView(id, mailbox->name());
+    }
+
+    NMLOG("<--NmPopClientPlugin::settings()");
+}
+
+/*!
+    Private slot to switch message list contents
+    to standard folder inbox
+*/
+void NmPopClientPlugin::switchToStandardFolderInbox()
+{
+    if (mListOptionsMenuRequest.observer()){
+        NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderInbox);
+        NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
+                                  NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
+                                  folderId);
+        mListOptionsMenuRequest.observer()->handleActionCommand(response);
+    }
+}
+
+/*!
+    Private slot to switch message list contents
+    to standard folder outbox
+*/
+void NmPopClientPlugin::switchToStandardFolderOutbox()
+{
+    if (mListOptionsMenuRequest.observer()){
+        NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderOutbox);
+        NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
+                                  NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
+                                  folderId);
+        mListOptionsMenuRequest.observer()->handleActionCommand(response);
+    }
+}
+
+/*!
+    Private slot to switch message list contents
+    to standard folder drafts
+*/
+void NmPopClientPlugin::switchToStandardFolderDrafts()
+{
+    if (mListOptionsMenuRequest.observer()){
+        NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderDrafts);
+        NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
+                                  NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
+                                  folderId);
+        mListOptionsMenuRequest.observer()->handleActionCommand(response);
+    }
+}
+
+/*!
+    Private slot to switch message list contents
+    to standard folder sent
+*/
+void NmPopClientPlugin::switchToStandardFolderSent()
+{
+    if (mListOptionsMenuRequest.observer()){
+        NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderSent);
+        NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
+                                  NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
+                                  folderId);
+        mListOptionsMenuRequest.observer()->handleActionCommand(response);
+    }
+}
+
+/*!
     Provide id of plugin.
     Implementation of NmUiExtensionInterface.
  */