emailuis/nmailui/src/nmviewerserviceinterface.cpp
changeset 72 64e38f08e49c
parent 65 478bc57ad291
child 68 83cc6bae1de8
equal deleted inserted replaced
65:478bc57ad291 72:64e38f08e49c
    27 
    27 
    28 /*!
    28 /*!
    29     Class constructor.
    29     Class constructor.
    30 */
    30 */
    31 NmViewerServiceInterface::NmViewerServiceInterface(QObject *parent,
    31 NmViewerServiceInterface::NmViewerServiceInterface(QObject *parent,
    32         NmApplication *application,
    32                                                    NmApplication *application,
    33         NmUiEngine &uiEngine)
    33                                                    NmUiEngine &uiEngine)
    34     : XQServiceProvider(emailFullServiceNameMessage, parent),
    34 : XQServiceProvider(emailFullServiceNameMessage, parent),
    35       mApplication(application),
    35   mApplication(application),
    36       mUiEngine(uiEngine),
    36   mUiEngine(uiEngine),
    37       mAsyncReqId(0)
    37   mAsyncReqId(0)
    38 {
    38 {
    39     publishAll();
    39     publishAll();
    40 }
    40 }
    41 
    41 
    42 
    42 
    48     NM_FUNCTION;
    48     NM_FUNCTION;
    49 }
    49 }
    50 
    50 
    51 
    51 
    52 /*!
    52 /*!
    53     Opens view to the specific message
    53     This has the soon to be DEPRICATED three argument interface!!!
    54  */
    54     Use viewMessage(QVariant idList, QVariant flags) instead!!!
    55 void NmViewerServiceInterface::viewMessage(QVariant mailboxId, QVariant folderId, QVariant messageId)
    55 */
       
    56 void NmViewerServiceInterface::viewMessage(QVariant mailboxId,
       
    57                                            QVariant folderId,
       
    58                                            QVariant messageId)
       
    59 {
       
    60     QVariantList idList;
       
    61     idList.append(mailboxId);
       
    62     idList.append(folderId);
       
    63     idList.append(messageId);
       
    64     QVariant idListAsVariant = QVariant::fromValue(idList);
       
    65     viewMessage(idListAsVariant, QVariant());
       
    66 }
       
    67 
       
    68 
       
    69 /*!
       
    70     Opens the message view according to the given IDs.
       
    71 
       
    72     \param idList A list containing the required IDs for locating the wanted
       
    73                   message. The ID are the following (and should be placed in
       
    74                   the following order): mailbox ID, folder ID and message ID.
       
    75     \param flags Will contain EmailBackReturnsToMessageList if the message
       
    76                  list view should be added into the view stack.
       
    77 */
       
    78 void NmViewerServiceInterface::viewMessage(QVariant idList, QVariant flags)
    56 {
    79 {
    57     NM_FUNCTION;
    80     NM_FUNCTION;
       
    81     
       
    82     mAsyncReqId = setCurrentRequestAsync();
    58 
    83 
    59     mAsyncReqId = setCurrentRequestAsync();
    84     NmId mailboxId(0), folderId(0), messageId(0);
    60     NmId mailboxNmId(0);
       
    61     mailboxNmId = mailboxId.toULongLong();   
       
    62     NmId messageNmId(0);
       
    63     messageNmId = messageId.toULongLong(); 
       
    64     NmId folderNmId(0);
       
    65     folderNmId = folderId.toULongLong();
       
    66 
    85 
    67 	// Make sure the app stays background if user presses back in viewer view
    86     // Check the given arguments.
       
    87     if (idList.canConvert(QVariant::List)) {
       
    88         QList<QVariant> ids = idList.toList();
       
    89         
       
    90         if (ids.count() >= 3) {
       
    91             mailboxId = ids[0].toULongLong();
       
    92             folderId = ids[1].toULongLong();
       
    93             messageId = ids[2].toLongLong();
       
    94         }
       
    95     }
       
    96 
       
    97     quint64 flag(EmailNoFlags);
       
    98 
       
    99     if (flags.canConvert(QVariant::ULongLong)) {
       
   100         flag = flags.toULongLong();
       
   101     }
       
   102 
       
   103     bool addMessageListViewToStack(false);
       
   104 
       
   105     if (flag & EmailBackReturnsToMessageList) {
       
   106         addMessageListViewToStack = true;
       
   107     }
       
   108 
       
   109 	// Make sure the app stays on the background if the user presses back button
       
   110     // in the viewer view.
    68 	bool visible = mApplication->updateVisibilityState();
   111 	bool visible = mApplication->updateVisibilityState();
    69 
   112 
    70     NmMessage *message = mUiEngine.message( mailboxNmId, folderNmId, messageNmId );
   113     NmMessage *message = mUiEngine.message(mailboxId, folderId, messageId);
       
   114 
    71     if (message) {
   115     if (message) {
    72         // bring application to foreground
   116         // Bring the application to the foreground.
    73         if (!XQServiceUtil::isEmbedded()) {
   117         if (!XQServiceUtil::isEmbedded()) {
    74             XQServiceUtil::toBackground(false);
   118             XQServiceUtil::toBackground(false);
    75         }
   119         }
       
   120 
    76         HbMainWindow *mainWindow = mApplication->mainWindow();
   121         HbMainWindow *mainWindow = mApplication->mainWindow();
    77         mainWindow->show();
   122         mainWindow->show();
    78 
   123 
    79         // Launch the message list view.
   124         if (addMessageListViewToStack) {
    80         NmUiStartParam *startParam1 = 
   125             // Launch the message list view.
    81             new NmUiStartParam(NmUiViewMessageList,
   126             NmUiStartParam *startParam1 = 
    82                                mailboxNmId,
   127                 new NmUiStartParam(NmUiViewMessageList,
    83                                folderNmId, // folder id
   128                                    mailboxId,
    84                                messageNmId, // message id
   129                                    folderId,
    85                                NmUiEditorCreateNew, // editor start mode
   130                                    messageId,
    86                                NULL, // address list
   131                                    NmUiEditorCreateNew, // editor start mode
    87                                NULL, // attachment list
   132                                    NULL, // address list
    88                                true); // start as service
   133                                    NULL, // attachment list
    89         mApplication->enterNmUiView(startParam1);
   134                                    true); // start as service
       
   135 
       
   136             mApplication->enterNmUiView(startParam1);
       
   137         }
    90         
   138         
    91         // Launch the message view.
   139         // Launch the message view.
    92         NmUiStartParam *startParam =
   140         NmUiStartParam *startParam =
    93             new NmUiStartParam(NmUiViewMessageViewer,
   141             new NmUiStartParam(NmUiViewMessageViewer,
    94                                mailboxNmId,
   142                                mailboxId,
    95                                folderNmId, // folder id
   143                                folderId, // folder id
    96                                messageNmId, // message id
   144                                messageId, // message id
    97                                NmUiEditorCreateNew, // editor start mode
   145                                NmUiEditorCreateNew, // editor start mode
    98                                NULL, // address list
   146                                NULL, // address list
    99                                NULL, // attachment list
   147                                NULL, // attachment list
   100                                false); // not started as service
   148                                !addMessageListViewToStack); // start as service?
       
   149 
   101         mApplication->enterNmUiView(startParam);
   150         mApplication->enterNmUiView(startParam);
   102 
   151 
   103         completeRequest(mAsyncReqId,0);
   152         completeRequest(mAsyncReqId, 0);
   104     }
   153     }
   105     else {
   154     else {
   106         // Message was not found
   155         // The message was not found!
   107 
   156 
   108         // if started as embedded, do not hide the app
   157         // If started as embedded, do not hide the app.
   109 		if (!XQServiceUtil::isEmbedded() && !visible) {
   158 		if (!XQServiceUtil::isEmbedded() && !visible) {
   110 			XQServiceUtil::toBackground(true);
   159 			XQServiceUtil::toBackground(true);
   111 		}
   160 		}
   112 
   161 
   113         completeRequest(mAsyncReqId,1);
   162         completeRequest(mAsyncReqId, 1);
   114 
   163 
   115         // Close the application if started as service
   164         // Close the application if started as a service.
   116         if (XQServiceUtil::isService()) {
   165         if (XQServiceUtil::isService()) {
   117             // Exit the application when the return value is delivered
   166             // Exit the application when the return value is delivered.
   118             connect(this, SIGNAL(returnValueDelivered()),
   167             connect(this, SIGNAL(returnValueDelivered()),
   119                     mApplication, SLOT(delayedExitApplication()));
   168                     mApplication, SLOT(delayedExitApplication()));
   120         }
   169         }
   121     }
   170     }
   122 }
   171 }
   123 
   172 
       
   173 
   124 // End of file.
   174 // End of file.