emailuis/nmailuiengine/src/nmbaseclientplugin.cpp
branchRCL_3
changeset 63 d189ee25cf9d
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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 "nmuiengineheaders.h"
       
    19 
       
    20 /*!
       
    21  \class NmBaseClientPlugin
       
    22 
       
    23  \brief The NmBaseClientPlugin plugin provides ui services for IMAP/POP mail protocols.
       
    24 
       
    25  The NmBaseClientPlugin contains the following services:
       
    26  \li get actions
       
    27  \li refresh mailbox
       
    28  \li create new email
       
    29  \li open settings
       
    30  \li send email
       
    31  \li delete email
       
    32  \li open email
       
    33  \li reply email
       
    34  \li reply all email
       
    35  \li forward email
       
    36  \li search emails
       
    37 
       
    38  The plugin provides a list of supported UI services as NmAction objects. Actions are connected to
       
    39  different public slots and when they are triggered plugin will handle action by itself directly to
       
    40  NmUiEngine or by using NmActionResponse to inform user of service.
       
    41 
       
    42 */
       
    43 
       
    44 /*!
       
    45     \fn void NmBaseClientPlugin::getActions(const NmActionRequest &request, QList<NmAction*> &actionList)
       
    46     Implementation of NmUiExtension interface. The plugin provides to caller supported actions for email protocol.
       
    47     \a request contains NmActionRequest with needed request data.
       
    48     \a actionList QList array will be filled by action supported protocol and controlled by NmActionRequest.
       
    49 */
       
    50 
       
    51 /*!
       
    52     \fn void NmBaseClientPlugin::openMessage()
       
    53     When open action is triggered this slot is called to open message.
       
    54 */
       
    55 
       
    56 /*!
       
    57     \fn void NmBaseClientPlugin::deleteMessage()
       
    58     When delete action is triggered this slot is called to delete message.
       
    59 */
       
    60 
       
    61 /*!
       
    62     \fn void NmBaseClientPlugin::refresh()
       
    63     When refresh action is triggered this slot is called to start refreshing the mailbox.
       
    64 */
       
    65 
       
    66 /*!
       
    67     \fn void NmBaseClientPlugin::createNewMail()
       
    68     When create new action is triggered this slot is called to notify responce observer
       
    69     with NmActionResponseCommandNewMail enum.
       
    70 */
       
    71 
       
    72 /*!
       
    73     \fn void NmBaseClientPlugin::settings()
       
    74     When settings action is triggered this slot is called to open settings.
       
    75 */
       
    76 
       
    77 /*!
       
    78     \fn void NmBaseClientPlugin::sendMail()
       
    79     When send mail action is triggered this slot is called to send an email.
       
    80 */
       
    81 
       
    82 /*!
       
    83     \fn void NmBaseClientPlugin::replyMail()
       
    84     When reply mail action is triggered this slot is called to reply an email.
       
    85 */
       
    86 
       
    87 /*!
       
    88     \fn void NmBaseClientPlugin::replyAllMail()
       
    89     When reply all mail action is triggered this slot is called to reply all an email.
       
    90 */
       
    91 
       
    92 /*!
       
    93     \fn void NmBaseClientPlugin::forwardMail()
       
    94     When forward mail action is triggered this slot is called to forward an email.
       
    95 */
       
    96 
       
    97 /*!
       
    98     Constructs a new NmBaseClientPlugin.
       
    99 */
       
   100 NmBaseClientPlugin::NmBaseClientPlugin()
       
   101 :mMenuRequest(NULL),
       
   102 mUiEngine(NULL),
       
   103 mEditorToolBarRequest(NULL),
       
   104 mViewerToolBarRequest(NULL),
       
   105 mViewerViewRequest(NULL)
       
   106 {
       
   107     NM_FUNCTION;
       
   108     
       
   109     mUiEngine = NmUiEngine::instance();
       
   110 }
       
   111 
       
   112 /*!
       
   113     Destructor.
       
   114 */
       
   115 NmBaseClientPlugin::~NmBaseClientPlugin()
       
   116 {
       
   117     NM_FUNCTION;
       
   118     
       
   119     NmUiEngine::releaseInstance(mUiEngine);
       
   120     mUiEngine = NULL;
       
   121 }
       
   122 
       
   123 
       
   124 /*!
       
   125     Provides a list of supported NmActions.
       
   126     Implementation of NmUiExtensionInterface.
       
   127 
       
   128     Parameter \a request controls list of request services.
       
   129     Parameter \a actionList is updated by supported NmActions.
       
   130 */
       
   131 void NmBaseClientPlugin::getActions(const NmActionRequest &request,
       
   132                                     QList<NmAction *> &actionList)
       
   133 {
       
   134     NM_FUNCTION;
       
   135     
       
   136     if (request.observer()) {
       
   137         switch (request.contextView()) {
       
   138             case NmActionContextViewMessageList:
       
   139             case NmActionContextViewMessageSearchList:
       
   140             {
       
   141                 createMessageListCommands(request, actionList);
       
   142                 break;
       
   143             }
       
   144             case NmActionContextViewViewer:
       
   145             {
       
   146                 createViewerViewCommands(request, actionList);
       
   147                 break;
       
   148             }
       
   149             case NmActionContextViewEditor:
       
   150             {
       
   151                 createEditorViewCommands(request, actionList);
       
   152                 break;
       
   153             }
       
   154             default:
       
   155             {
       
   156                 NM_COMMENT(QString("NmBaseClientPlugin::getActions(): unknown contextView()=%1").arg(request.contextView()));
       
   157                 break;
       
   158             }
       
   159         }
       
   160     }
       
   161 }
       
   162 
       
   163 
       
   164 /*!
       
   165     Public slot connected to options menu refresh NmAction.
       
   166     Refreshes mailbox using the NmUiEngine instance.
       
   167 */
       
   168 void NmBaseClientPlugin::refresh()
       
   169 {
       
   170     NM_FUNCTION;
       
   171     
       
   172     int err = mUiEngine->refreshMailbox(mMenuRequest.mailboxId());
       
   173 
       
   174     if (NmNoError != err) {
       
   175         // Failed to refresh the mailbox!
       
   176         NM_ERROR(1,QString("NmBaseClientPlugin::refresh(): failed err=%1").arg(err));
       
   177     }
       
   178 }
       
   179 
       
   180 /*!
       
   181     Public slot connected to triggered() signal of open message action instance.
       
   182     The method sends an open response command to the action observer.
       
   183 */
       
   184 void NmBaseClientPlugin::openMessage()
       
   185 {
       
   186     NM_FUNCTION;
       
   187     
       
   188     handleRequest(NmActionResponseCommandOpen, mMenuRequest);
       
   189 }
       
   190 
       
   191 /*!
       
   192     Public slot connected to delete message. Method asks UI engine to delete messages
       
   193 */
       
   194 void NmBaseClientPlugin::deleteMessage()
       
   195 {
       
   196     NM_FUNCTION;
       
   197     
       
   198     QList<NmId> messageList;
       
   199     messageList.append(mMenuRequest.messageId());
       
   200 
       
   201     int err = mUiEngine->deleteMessages(mMenuRequest.mailboxId(),
       
   202                                         mMenuRequest.folderId(),
       
   203                                         messageList);
       
   204     if (NmNoError != err) {
       
   205         // Failed to delete the messages!
       
   206         NM_ERROR(1,QString("NmBaseClientPlugin::deleteMessage(): failed err=%1").arg(err));
       
   207     }
       
   208     messageList.clear();
       
   209 }
       
   210 
       
   211 /*!
       
   212     Public slot connected to triggered() signal of delete action instance.
       
   213     The method sends a delete mail command to the action observer.
       
   214 */
       
   215 void NmBaseClientPlugin::deleteMessageFromViewerView()
       
   216 {
       
   217     NM_FUNCTION;
       
   218     
       
   219     handleRequest(NmActionResponseCommandDeleteMail, mViewerViewRequest);
       
   220 }
       
   221 
       
   222 /*!
       
   223     Public slot connected to triggered() signal of create mail action instance.
       
   224     The method sends a new mail command to the action observer.
       
   225 */
       
   226 void NmBaseClientPlugin::createNewMailViewerToolBar()
       
   227 {
       
   228     NM_FUNCTION;
       
   229     
       
   230     handleRequest(NmActionResponseCommandNewMail, mViewerToolBarRequest);
       
   231 }
       
   232 
       
   233 /*!
       
   234     Public slot for handling the event of menu request for creating a new email.
       
   235     The method sends a new mail command to the action observer of the menu request.
       
   236 */
       
   237 void NmBaseClientPlugin::createNewMail()
       
   238 {
       
   239     NM_FUNCTION;
       
   240     
       
   241     handleRequest(NmActionResponseCommandNewMail, mMenuRequest);
       
   242 }
       
   243 
       
   244 /*!
       
   245     Public slot connected to options menu settings NmAction.
       
   246     Opens mailbox settings.
       
   247 */
       
   248 void NmBaseClientPlugin::settings()
       
   249 {
       
   250     NM_FUNCTION;
       
   251     
       
   252     handleRequest(NmActionResponseCommandSettings, mMenuRequest);
       
   253 }
       
   254 
       
   255 /*!
       
   256     Public slot connected to triggered() signal of send mail action instance.
       
   257     Sends the send mail command to the action observer.
       
   258 */
       
   259 void NmBaseClientPlugin::sendMail()
       
   260 {
       
   261     NM_FUNCTION;
       
   262     
       
   263     handleRequest(NmActionResponseCommandSendMail, mEditorToolBarRequest);
       
   264 }
       
   265 
       
   266 /*!
       
   267     Public slot connected to triggered() signal of reply action instance of the
       
   268     toolbar. Sends a reply mail command to the action observer.
       
   269 */
       
   270 
       
   271 void NmBaseClientPlugin::replyMail()
       
   272 {
       
   273     NM_FUNCTION;
       
   274     
       
   275     handleRequest(NmActionResponseCommandReply, mViewerViewRequest);
       
   276 }
       
   277 
       
   278 /*!
       
   279     Public slot connected to triggered signal of reply all action instance of
       
   280     the toolbar. Sends a reply all mail command to the action observer.
       
   281 */
       
   282 
       
   283 void NmBaseClientPlugin::replyAllMail()
       
   284 {
       
   285     NM_FUNCTION;
       
   286     
       
   287     handleRequest(NmActionResponseCommandReplyAll, mViewerViewRequest);
       
   288 }
       
   289 
       
   290 /*!
       
   291     Public slot connected to triggered() signal of forward action instance of
       
   292     the toolbar. Sends a forward mail command to the action observer.
       
   293 */
       
   294 void NmBaseClientPlugin::forwardMail()
       
   295 {
       
   296     NM_FUNCTION;
       
   297     
       
   298     handleRequest(NmActionResponseCommandForward, mViewerViewRequest);
       
   299 }
       
   300 
       
   301 /*!
       
   302     Public slot connected to set high priority toolbar action.
       
   303 */
       
   304 void NmBaseClientPlugin::setPriorityHigh()
       
   305 {
       
   306     NM_FUNCTION;
       
   307     
       
   308     handleRequest(NmActionResponseCommandPriorityHigh, mMenuRequest);
       
   309 }
       
   310 
       
   311 /*!
       
   312     Public slot connected to set normal priority toolbar action.
       
   313 */
       
   314 void NmBaseClientPlugin::setPriorityNormal()
       
   315 {
       
   316     NM_FUNCTION;
       
   317     
       
   318     handleRequest(NmActionResponseCommandNone, mMenuRequest);
       
   319 }
       
   320 
       
   321 /*!
       
   322     Public slot connected to set low priority toolbar action.
       
   323 */
       
   324 void NmBaseClientPlugin::setPriorityLow()
       
   325 {
       
   326     NM_FUNCTION;
       
   327     
       
   328     handleRequest(NmActionResponseCommandPriorityLow, mMenuRequest);
       
   329 }
       
   330 
       
   331 /*!
       
   332     Public slot connected to attach toolbar action.
       
   333 */
       
   334 void NmBaseClientPlugin::attach()
       
   335 {
       
   336     NM_FUNCTION;
       
   337     
       
   338     handleRequest(NmActionResponseCommandAttach, mEditorToolBarRequest);
       
   339 }
       
   340 
       
   341 /*!
       
   342     Public slot connected to remove attachment context menu action
       
   343 */
       
   344 void NmBaseClientPlugin::removeAttachment()
       
   345 {
       
   346     NM_FUNCTION;
       
   347     
       
   348     handleRequest(NmActionResponseCommandRemoveAttachment, mMenuRequest);
       
   349 }
       
   350 
       
   351 /*!
       
   352     Public slot connected to open attachment context menu action
       
   353 */
       
   354 void NmBaseClientPlugin::openAttachment()
       
   355 {
       
   356     NM_FUNCTION;
       
   357     
       
   358     handleRequest(NmActionResponseCommandOpenAttachment, mMenuRequest);
       
   359 }
       
   360 
       
   361 /*!
       
   362     Requests the handling of the search action.
       
   363     This public slot gets called when the search button in a toolbar is clicked.
       
   364 */
       
   365 void NmBaseClientPlugin::search()
       
   366 {
       
   367     NM_FUNCTION;
       
   368     
       
   369     handleRequest(NmActionResponseCommandSearch, mViewerToolBarRequest);
       
   370 }
       
   371 
       
   372 /*!
       
   373     Private slot connected to settings view launcher.
       
   374 
       
   375     \param mailboxId Id of mailbox.
       
   376     \param type type of change.
       
   377 */
       
   378 void NmBaseClientPlugin::mailboxListChanged(const NmId &mailboxId,
       
   379     NmSettings::MailboxEventType type)
       
   380 {
       
   381     NM_FUNCTION;
       
   382     
       
   383     Q_UNUSED(mailboxId)
       
   384     Q_UNUSED(type)
       
   385     handleRequest(NmActionResponseCommandMailboxDeleted, mMenuRequest);
       
   386 }
       
   387 
       
   388 /*!
       
   389     Private slot connected to settings view launcher.
       
   390 
       
   391     \param mailboxId Id of mailbox.
       
   392     \param property
       
   393     \param value
       
   394 */
       
   395 void NmBaseClientPlugin::mailboxPropertyChanged(const NmId &mailboxId, QVariant property,
       
   396     QVariant value)
       
   397 {
       
   398     NM_FUNCTION;
       
   399     
       
   400     Q_UNUSED(property)
       
   401     Q_UNUSED(value)
       
   402 
       
   403     NmActionObserver *observer = mMenuRequest.observer();
       
   404     if (observer) {
       
   405         // Force model item to be updated, because framework adapter sends it too slowly.
       
   406         mUiEngine->mailboxListModel().refreshModelItem(mailboxId);
       
   407 
       
   408         // Notify view of changes.
       
   409         NmActionResponse response(NmActionResponseCommandUpdateMailboxName, mMenuRequest);
       
   410         observer->handleActionCommand(response);
       
   411     }
       
   412 }
       
   413 
       
   414 /*!
       
   415     Private slot connected to settings view launcher.
       
   416     \param mailboxId Id of mailbox.
       
   417 */
       
   418 void NmBaseClientPlugin::goOnline(const NmId &mailboxId)
       
   419 {
       
   420     NM_FUNCTION;
       
   421     
       
   422 		(void) mUiEngine->refreshMailbox(mailboxId);
       
   423 }
       
   424 /*!
       
   425     Private slot connected to settings view launcher.
       
   426     \param mailboxId Id of mailbox.
       
   427 */
       
   428 void NmBaseClientPlugin::goOffline(const NmId &mailboxId)
       
   429 {
       
   430     NM_FUNCTION;
       
   431     
       
   432         mUiEngine->goOffline(mailboxId);
       
   433 }
       
   434 
       
   435 /*!
       
   436     Create messagelist command actions.
       
   437     Internal helper method.
       
   438     Parameter \a request is used to identify requested menu type.
       
   439     Parameter \a actionList is updated by supported NmActions for message list.
       
   440 */
       
   441 void NmBaseClientPlugin::createMessageListCommands(
       
   442     const NmActionRequest &request,
       
   443     QList<NmAction *> &actionList)
       
   444 {
       
   445     NM_FUNCTION;
       
   446     
       
   447     switch (request.menuType()) {
       
   448         case NmActionOptionsMenu:
       
   449         {
       
   450             mMenuRequest = request;
       
   451 
       
   452             NmAction *refreshAction = new NmAction(0);
       
   453             refreshAction->setObjectName("baseclientplugin_refresh");
       
   454             refreshAction->setText(hbTrId("txt_mail_opt_send_and_receive_now"));
       
   455             connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
       
   456             actionList.append(refreshAction);
       
   457 
       
   458             NmAction *settingsAction = new NmAction(0);
       
   459             settingsAction->setObjectName("baseclientplugin_settings");
       
   460             settingsAction->setText(hbTrId("txt_common_opt_settings"));
       
   461             connect(settingsAction, SIGNAL(triggered()), this, SLOT(settings()));
       
   462             actionList.append(settingsAction);
       
   463             break;
       
   464         }
       
   465         case NmActionToolbar:
       
   466         {
       
   467             // Create the search button.
       
   468             NmAction *mailSearchAction = new NmAction(0);
       
   469             mailSearchAction->setObjectName("baseclientplugin_mailsearchaction");
       
   470             mailSearchAction->setText(hbTrId("txt_mail_list_search"));
       
   471             mailSearchAction->setIcon(HbIcon("qtg_mono_search"));
       
   472             connect(mailSearchAction, SIGNAL(triggered()), this, SLOT(search()));
       
   473             actionList.append(mailSearchAction);
       
   474 
       
   475             // Create new mail button.
       
   476             mViewerToolBarRequest = request;
       
   477             NmAction *createMailAction = new NmAction(0);
       
   478             createMailAction->setObjectName("baseclientplugin_createmailaction");
       
   479             createMailAction->setText(hbTrId("txt_mail_button_new_mail"));
       
   480             createMailAction->setIcon(NmIcons::getIcon(NmIcons::NmIconNewEmail));
       
   481             connect(createMailAction, SIGNAL(triggered()),
       
   482                     this, SLOT(createNewMailViewerToolBar()));
       
   483             actionList.append(createMailAction);
       
   484             break;
       
   485         }
       
   486         case NmActionContextMenu:
       
   487         {
       
   488             if (request.contextDataType() == NmActionContextDataMessage){
       
   489                 mMenuRequest = request;
       
   490 
       
   491                 NmFolderType folderType(NmFolderInbox);
       
   492                 if (mUiEngine){
       
   493                     folderType = mUiEngine->folderTypeById(request.mailboxId(),request.folderId());                
       
   494                 }
       
   495                 
       
   496                 if (folderType!=NmFolderOutbox){
       
   497                     // Open message
       
   498                     NmAction* openAction = new NmAction(0);
       
   499                     openAction->setObjectName("baseclientplugin_openaction");
       
   500                     openAction->setText(hbTrId("txt_common_menu_open"));
       
   501                     connect(openAction, SIGNAL(triggered()), this, SLOT(openMessage()));
       
   502                     actionList.append(openAction);                
       
   503                 }                
       
   504 
       
   505                 // Delete message
       
   506                 NmAction* deleteAction = new NmAction(0);
       
   507                 deleteAction->setObjectName("baseclientplugin_deleteaction");
       
   508                 deleteAction->setText(hbTrId("txt_common_menu_delete"));
       
   509                 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteMessage()));
       
   510                 actionList.append(deleteAction);
       
   511 
       
   512                 if (folderType!=NmFolderOutbox &&
       
   513                     folderType!=NmFolderDrafts ){
       
   514                     NmMessageEnvelope *envelope =
       
   515                         request.requestData().value<NmMessageEnvelope*>();    
       
   516                     if (envelope){
       
   517                         if (envelope->isRead()){
       
   518                             NM_COMMENT("nmailui: envelope is read");
       
   519                             NmAction* unreadAction = new NmAction(0);
       
   520                             unreadAction->setObjectName("baseclientplugin_unreadaction");
       
   521                             unreadAction->setText(hbTrId("txt_mail_menu_mark_as_unread"));
       
   522     
       
   523                             connect(unreadAction,
       
   524                                 SIGNAL(triggered()),
       
   525                                 this,
       
   526                                 SLOT(markAsUnread()));
       
   527     
       
   528                             actionList.append(unreadAction);
       
   529                         }
       
   530                         else {
       
   531                             NM_COMMENT("nmailui: envelope is unread");
       
   532                             NmAction* readAction = new NmAction(0);
       
   533                             readAction->setObjectName("baseclientplugin_readaction");
       
   534                             readAction->setText(hbTrId("txt_mail_menu_mark_as_read"));
       
   535     
       
   536                             connect(readAction,
       
   537                                 SIGNAL(triggered()),
       
   538                                 this,
       
   539                                 SLOT(markAsRead()));
       
   540     
       
   541                             actionList.append(readAction);
       
   542                         }
       
   543                     }
       
   544                 }
       
   545             }
       
   546             break;
       
   547         }
       
   548         default:
       
   549         {
       
   550             NM_COMMENT(QString("NmBaseClientPlugin::createMessageListCommands(): unknown menuType()=%1").arg(request.menuType()));
       
   551             break;
       
   552         }
       
   553     }
       
   554 }
       
   555 
       
   556 /*!
       
   557     Create Viewer view command actions.
       
   558     Internal helper method.
       
   559     Parameter \a request is used to identify requested menu type.
       
   560     Parameter \a actionList is updated by supported NmActions for message list.
       
   561 */
       
   562 void NmBaseClientPlugin::createViewerViewCommands(
       
   563     const NmActionRequest &request,
       
   564     QList<NmAction *> &actionList)
       
   565 {
       
   566     NM_FUNCTION;
       
   567     
       
   568     switch (request.menuType()) {
       
   569     	case NmActionOptionsMenu:
       
   570 		{
       
   571 			mViewerViewRequest = request;
       
   572 
       
   573 			// Options menu Reply action
       
   574 			NmAction *replyAction = new NmAction(0);
       
   575 			replyAction->setObjectName("baseclientplugin_reply");
       
   576 			replyAction->setText(hbTrId("txt_mail_viewer_opt_reply"));
       
   577 			connect(replyAction, SIGNAL(triggered()), this, SLOT(replyMail()));
       
   578 			actionList.append(replyAction);
       
   579 
       
   580 			// Options menu Reply all action
       
   581 			NmAction *replyAllAction = new NmAction(0);
       
   582 			replyAllAction->setObjectName("baseclientplugin_reply_all");
       
   583 			replyAllAction->setText(hbTrId("txt_mail_viewer_opt_reply_all"));
       
   584 			connect(replyAllAction, SIGNAL(triggered()), this, SLOT(replyAllMail()));
       
   585 			actionList.append(replyAllAction);
       
   586 
       
   587 			// Options menu Forward action
       
   588 			NmAction *forwardAction = new NmAction(0);
       
   589 			forwardAction->setObjectName("baseclientplugin_forward");
       
   590 			forwardAction->setText(hbTrId("txt_mail_viewer_opt_forward"));
       
   591 			connect(forwardAction, SIGNAL(triggered()), this, SLOT(forwardMail()));
       
   592 			actionList.append(forwardAction);
       
   593 
       
   594 			// Options menu Delete action
       
   595 			NmAction *deleteAction = new NmAction(0);
       
   596 			deleteAction->setObjectName("baseclientplugin_delete");
       
   597 			deleteAction->setText(hbTrId("txt_mail_viewer_opt_delete"));
       
   598 			connect(deleteAction, SIGNAL(triggered()),
       
   599 					this, SLOT(deleteMessageFromViewerView()));
       
   600 			actionList.append(deleteAction);
       
   601 			break;
       
   602 		}
       
   603         case NmActionToolbar:
       
   604         {
       
   605             mViewerViewRequest = request;
       
   606 			Qt::Orientation orientation = Qt::Horizontal;
       
   607 			HbMainWindow *mainWindow = static_cast<HbMainWindow*>(HbApplication::activeWindow());
       
   608 			if( mainWindow ) {
       
   609             	orientation = mainWindow->orientation();
       
   610 			}
       
   611 
       
   612             // ToolBar Reply action
       
   613             NmAction *replyAction = new NmAction(0);
       
   614             if (Qt::Horizontal == orientation) {
       
   615                 replyAction->setText(hbTrId("txt_mail_button_reply"));
       
   616             }
       
   617             replyAction->setToolTip(hbTrId("txt_mail_button_reply"));
       
   618             replyAction->setIcon(NmIcons::getIcon(NmIcons::NmIconReply));
       
   619             replyAction->setObjectName("baseclientplugin_reply");
       
   620             connect(replyAction, SIGNAL(triggered()), this, SLOT(replyMail()));
       
   621             actionList.append(replyAction);
       
   622 
       
   623             // ToolBar Reply all action
       
   624             NmAction *replyAllAction = new NmAction(0);
       
   625             if (Qt::Horizontal == orientation) {
       
   626                 replyAllAction->setText(hbTrId("txt_mail_button_reply_all"));
       
   627             }
       
   628             replyAllAction->setToolTip(hbTrId("txt_mail_button_reply_all"));
       
   629             replyAllAction->setIcon(NmIcons::getIcon(NmIcons::NmIconReplyAll));
       
   630             replyAllAction->setObjectName("baseclientplugin_reply_all");
       
   631             connect(replyAllAction, SIGNAL(triggered()), this, SLOT(replyAllMail()));
       
   632             actionList.append(replyAllAction);
       
   633 
       
   634             // ToolBar Forward action
       
   635             NmAction *forwardAction = new NmAction(0);
       
   636             if (Qt::Horizontal == orientation) {
       
   637                 forwardAction->setText(hbTrId("txt_mail_button_forward"));
       
   638             }
       
   639             forwardAction->setToolTip(hbTrId("txt_mail_button_forward"));
       
   640             forwardAction->setIcon(NmIcons::getIcon(NmIcons::NmIconForward));
       
   641             forwardAction->setObjectName("baseclientplugin_forward");
       
   642             connect(forwardAction, SIGNAL(triggered()), this, SLOT(forwardMail()));
       
   643             actionList.append(forwardAction);
       
   644 
       
   645             // ToolBar Delete action
       
   646             NmAction *deleteAction = new NmAction(0);
       
   647             if (Qt::Horizontal == orientation) {
       
   648                 deleteAction->setText(hbTrId("txt_mail_button_delete"));
       
   649             }
       
   650             deleteAction->setToolTip(hbTrId("txt_mail_button_delete"));
       
   651             deleteAction->setIcon(NmIcons::getIcon(NmIcons::NmIconDelete));
       
   652             deleteAction->setObjectName("baseclientplugin_delete");
       
   653             connect(deleteAction, SIGNAL(triggered()),
       
   654                     this, SLOT(deleteMessageFromViewerView()));
       
   655             actionList.append(deleteAction);
       
   656             break;
       
   657         }
       
   658         default:
       
   659         {
       
   660             NM_COMMENT(QString("NmBaseClientPlugin::createViewerViewCommands(): unknown menuType()=%1").arg(request.menuType()));
       
   661             break;
       
   662         }
       
   663     }
       
   664 
       
   665 }
       
   666 
       
   667 /*!
       
   668     Create Editor view command actions.
       
   669     Internal helper method.
       
   670     Parameter \a request is used to identify requested menu type.
       
   671     Parameter \a actionList is updated by supported NmActions for message list.
       
   672 */
       
   673 void NmBaseClientPlugin::createEditorViewCommands(
       
   674     const NmActionRequest &request,
       
   675     QList<NmAction *> &actionList)
       
   676 {
       
   677     NM_FUNCTION;
       
   678     
       
   679     switch (request.menuType()) {
       
   680         case NmActionToolbar:
       
   681         {
       
   682             mEditorToolBarRequest = request;
       
   683 
       
   684             // ToolBar Attach action
       
   685             NmAction *attachAction = new NmAction(0);
       
   686             attachAction->setObjectName("baseclientplugin_attachaction");
       
   687             attachAction->setText(hbTrId("txt_mail_button_attach"));
       
   688             attachAction->setIcon(NmIcons::getIcon(NmIcons::NmIconAttach));
       
   689             // Action only available when attachment can be added
       
   690             attachAction->setAvailabilityCondition(NmAction::NmAttachable);
       
   691             // connect action/add toolbar extensions
       
   692             connect(attachAction, SIGNAL(triggered()), this, SLOT(attach()));
       
   693             actionList.append(attachAction);
       
   694 
       
   695             // ToolBar Send action
       
   696             NmAction *sendAction = new NmAction(0);
       
   697             sendAction->setObjectName("baseclientplugin_sendaction");
       
   698             sendAction->setText(hbTrId("txt_common_button_send"));
       
   699             sendAction->setIcon(NmIcons::getIcon(NmIcons::NmIconSend));
       
   700             // Action only available when the message related to it can be sent.
       
   701             sendAction->setAvailabilityCondition(NmAction::NmSendable);
       
   702             connect(sendAction, SIGNAL(triggered()), this, SLOT(sendMail()));
       
   703             actionList.append(sendAction);
       
   704             break;
       
   705         }
       
   706         case NmActionOptionsMenu:
       
   707         {
       
   708             mMenuRequest = request;
       
   709 
       
   710             NmAction *action = new NmAction(0);
       
   711             action->setObjectName("baseclientplugin_highpriorityaction");
       
   712             action->setText(hbTrId("txt_mail_opt_add_priority_sub_high"));
       
   713             connect(action, SIGNAL(triggered()), this, SLOT(setPriorityHigh()));
       
   714             actionList.append(action);
       
   715 
       
   716             action = new NmAction(0);
       
   717             action->setObjectName("baseclientplugin_normalpriorityaction");
       
   718             action->setText(hbTrId("txt_mail_opt_add_priority_sub_normal"));
       
   719             connect(action, SIGNAL(triggered()), this, SLOT(setPriorityNormal()));
       
   720             actionList.append(action);
       
   721 
       
   722             action = new NmAction(0);
       
   723             action->setObjectName("baseclientplugin_lowpriorityaction");
       
   724             action->setText(hbTrId("txt_mail_opt_add_priority_sub_low"));
       
   725             connect(action, SIGNAL(triggered()), this, SLOT(setPriorityLow()));
       
   726             actionList.append(action);
       
   727             break;
       
   728         }
       
   729         case NmActionContextMenu:
       
   730         {
       
   731             mMenuRequest = request;
       
   732 
       
   733             NmAction *action = new NmAction(0);
       
   734             action->setObjectName("baseclientplugin_removeattachmentaction");
       
   735             action->setText(hbTrId("txt_common_menu_remove"));
       
   736             connect(action, SIGNAL(triggered()), this, SLOT(removeAttachment()));
       
   737             actionList.append(action);
       
   738 
       
   739             action = new NmAction(0);
       
   740             action->setObjectName("baseclientplugin_openattachmentaction");
       
   741             action->setText(hbTrId("txt_common_menu_open"));
       
   742             connect(action, SIGNAL(triggered()), this, SLOT(openAttachment()));
       
   743             actionList.append(action);
       
   744             break;
       
   745         }
       
   746         case NmActionVKB:
       
   747         {
       
   748             mMenuRequest = request;
       
   749 
       
   750             // Virtual Keyboard Send action
       
   751             NmAction *sendAction = new NmAction(0);
       
   752             sendAction->setObjectName("baseclientplugin_vblsendaction");
       
   753             sendAction->setText(hbTrId("txt_common_button_send"));
       
   754             // Action only available when the message related to it can be sent.
       
   755             sendAction->setAvailabilityCondition(NmAction::NmSendable);
       
   756             connect(sendAction, SIGNAL(triggered()), this, SLOT(sendMail()));
       
   757             actionList.append(sendAction);
       
   758             break;
       
   759         }
       
   760         default:
       
   761         {
       
   762             NM_COMMENT(QString("NmBaseClientPlugin::createEditorViewCommands(): unknown menuType()=%1").arg(request.menuType()));
       
   763             break;
       
   764         }
       
   765     }
       
   766 }
       
   767 
       
   768 /*!
       
   769     Marks the message as read.
       
   770 */
       
   771 void NmBaseClientPlugin::markAsRead()
       
   772 {
       
   773     NM_FUNCTION;
       
   774     
       
   775     updateEnvelopeProperty(MarkAsRead);
       
   776 }
       
   777 
       
   778 /*!
       
   779     Marks the message as unread.
       
   780 */
       
   781 void NmBaseClientPlugin::markAsUnread()
       
   782 {
       
   783     NM_FUNCTION;
       
   784     
       
   785     updateEnvelopeProperty(MarkAsUnread);
       
   786 }
       
   787 
       
   788 /*!
       
   789     Handles requests.
       
   790 */
       
   791 void NmBaseClientPlugin::handleRequest(NmActionResponseCommand command, const NmActionRequest &request)
       
   792 {
       
   793     NM_FUNCTION;
       
   794     
       
   795     NmActionObserver *observer = request.observer();
       
   796     if (observer) {
       
   797         NmActionResponse response(command, request);
       
   798         observer->handleActionCommand(response);
       
   799     }
       
   800 }
       
   801 /*!
       
   802     Store envelope property.
       
   803 */
       
   804 void NmBaseClientPlugin::updateEnvelopeProperty(NmEnvelopeProperties property)
       
   805 {
       
   806     NM_FUNCTION;
       
   807     
       
   808     QList<const NmMessageEnvelope*> envelopeList;
       
   809     NmMessageEnvelope *envelope =
       
   810             mMenuRequest.requestData().value<NmMessageEnvelope*>();
       
   811 
       
   812     if (envelope) {
       
   813         envelopeList.append(envelope);
       
   814 
       
   815         QPointer<NmStoreEnvelopesOperation> op =
       
   816                 mUiEngine->setEnvelopes(mMenuRequest.mailboxId(),
       
   817                                         mMenuRequest.folderId(),
       
   818                                         property,
       
   819                                         envelopeList);
       
   820     }
       
   821     envelopeList.clear();
       
   822 }