ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp
branchRCL_3
changeset 63 d189ee25cf9d
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "nmpopclientpluginheaders.h"
       
    19 #ifdef Q_OS_SYMBIAN
       
    20 #include <e32base.h>
       
    21 #endif
       
    22 
       
    23 Q_EXPORT_PLUGIN(NmPopClientPlugin)
       
    24 
       
    25 
       
    26 /*!
       
    27  \class NmPopClientPlugin
       
    28 
       
    29  \brief The NmPopClientPlugin plugin provides ui services for POP mail protocol.
       
    30 */
       
    31 
       
    32 /*!
       
    33     Constructs a new NmPopClientPlugin.
       
    34  */
       
    35 NmPopClientPlugin::NmPopClientPlugin()
       
    36 : mListOptionsMenuRequest(NULL),
       
    37 mSettingsViewLauncher(NULL)
       
    38 {
       
    39     NMLOG("NmPopClientPlugin::NmPopClientPlugin()-->");
       
    40     NMLOG("<--NmPopClientPlugin::NmPopClientPlugin()");
       
    41 }
       
    42 
       
    43 /*!
       
    44     Destructor.
       
    45  */
       
    46 NmPopClientPlugin::~NmPopClientPlugin()
       
    47 {
       
    48     NMLOG("NmPopClientPlugin::~NmPopClientPlugin()-->");
       
    49     delete mSettingsViewLauncher;
       
    50     NMLOG("<--NmPopClientPlugin::~NmPopClientPlugin()");
       
    51 }
       
    52 
       
    53 
       
    54 /*!
       
    55     Provides list of supported NmActions.
       
    56     Implementation of NmUiExtensionInterface.
       
    57     Parameter \a request controls list of request services.
       
    58     Parameter \a actionList is updated by supported NmActions.
       
    59 
       
    60  */
       
    61 void NmPopClientPlugin::getActions(
       
    62       const NmActionRequest &request,
       
    63       QList<NmAction*> &actionList)
       
    64 {
       
    65     NMLOG("NmPopClientPlugin::getActions()-->");
       
    66     // check if this request is for POP protocol.
       
    67     quint32 pluginId = this->pluginId();
       
    68     if (request.mailboxId().pluginId32() != pluginId
       
    69 #ifdef USE_POPIMAP_TESTPLUGIN
       
    70         && request.mailboxId().pluginId32() != POPTESTPLUGINID
       
    71 #endif
       
    72     ) {
       
    73         NMLOG("NmPopClientPlugin::getActions(): PluginId incorrect.");
       
    74         NMLOG(QString("request.mailboxId().pluginId32()=%1").arg(request.mailboxId().pluginId32()));
       
    75         return;
       
    76     }
       
    77 
       
    78     // Get the NmBaseClientPlugin implementation of the UI actions.
       
    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_folder_sub_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_folder_sub_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_folder_sub_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_folder_sub_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_change_folder"));
       
   141             foldersAction->setMenu(standardFolders);
       
   142             actionList.append(foldersAction);
       
   143             }
       
   144         }
       
   145         break;
       
   146     default:
       
   147         break;
       
   148     }
       
   149 
       
   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         handleRequest(NmActionResponseCommandSettings, mMenuRequest);
       
   186         mSettingsViewLauncher->launchSettingsView(id, mailbox->name());
       
   187     }
       
   188 
       
   189     NMLOG("<--NmPopClientPlugin::settings()");
       
   190 }
       
   191 
       
   192 /*!
       
   193     Private slot to switch message list contents
       
   194     to standard folder inbox
       
   195 */
       
   196 void NmPopClientPlugin::switchToStandardFolderInbox()
       
   197 {
       
   198     if (mListOptionsMenuRequest.observer()){
       
   199         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderInbox);
       
   200         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   201                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   202                                   folderId);
       
   203         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   204     }
       
   205 }
       
   206 
       
   207 /*!
       
   208     Private slot to switch message list contents
       
   209     to standard folder outbox
       
   210 */
       
   211 void NmPopClientPlugin::switchToStandardFolderOutbox()
       
   212 {
       
   213     if (mListOptionsMenuRequest.observer()){
       
   214         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderOutbox);
       
   215         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   216                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   217                                   folderId);
       
   218         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   219     }
       
   220 }
       
   221 
       
   222 /*!
       
   223     Private slot to switch message list contents
       
   224     to standard folder drafts
       
   225 */
       
   226 void NmPopClientPlugin::switchToStandardFolderDrafts()
       
   227 {
       
   228     if (mListOptionsMenuRequest.observer()){
       
   229         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderDrafts);
       
   230         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   231                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   232                                   folderId);
       
   233         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   234     }
       
   235 }
       
   236 
       
   237 /*!
       
   238     Private slot to switch message list contents
       
   239     to standard folder sent
       
   240 */
       
   241 void NmPopClientPlugin::switchToStandardFolderSent()
       
   242 {
       
   243     if (mListOptionsMenuRequest.observer()){
       
   244         NmId folderId=mUiEngine->standardFolderId(mListOptionsMenuRequest.mailboxId(),NmFolderSent);
       
   245         NmActionResponse response(NmActionResponseCommandSwitchFolder, NmActionOptionsMenu,
       
   246                                   NmActionContextViewNone, mListOptionsMenuRequest.mailboxId(),
       
   247                                   folderId);
       
   248         mListOptionsMenuRequest.observer()->handleActionCommand(response);
       
   249     }
       
   250 }
       
   251 
       
   252 /*!
       
   253     Provide id of plugin.
       
   254     Implementation of NmUiExtensionInterface.
       
   255  */
       
   256 quint32 NmPopClientPlugin::pluginId()
       
   257 {
       
   258     NMLOG("NmPopClientPlugin::pluginId()-->");
       
   259     return IPSSOSPOP3PLUGIN_IMPLEMENTATION_UID;
       
   260 }