emailuis/nmailui/src/nmviewerserviceinterface.cpp
changeset 18 578830873419
child 20 ecc8def7944a
equal deleted inserted replaced
4:e7aa27f58ae1 18:578830873419
       
     1 /*
       
     2  * Copyright (c) 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: NMail application service interface used for viewing a mail
       
    15  *              according to given id. The service utilizes the Qt highway framework.
       
    16  */
       
    17 
       
    18 //  INCLUDES
       
    19 #include "nmuiheaders.h" // Includes also the class header.
       
    20 
       
    21 
       
    22 /*!
       
    23     \class NmViewerServiceInterface
       
    24     \brief A service interface for displaying the message according to given id.
       
    25 */
       
    26 
       
    27 
       
    28 /*!
       
    29     Class constructor.
       
    30 */
       
    31 NmViewerServiceInterface::NmViewerServiceInterface(QObject *parent,
       
    32         NmApplication *application,
       
    33         NmUiEngine &uiEngine)
       
    34 #ifndef NM_WINS_ENV
       
    35     : XQServiceProvider(QLatin1String("com.nokia.symbian.IEmailMessageView"), parent),
       
    36 #else
       
    37     : QObject(parent),
       
    38 #endif
       
    39       mApplication(application),
       
    40       mUiEngine(uiEngine),
       
    41       mAsyncReqId(0)
       
    42 {
       
    43 #ifndef NM_WINS_ENV
       
    44     publishAll();
       
    45 #endif
       
    46 }
       
    47 
       
    48 
       
    49 /*!
       
    50     Class desctructor.
       
    51 */
       
    52 NmViewerServiceInterface::~NmViewerServiceInterface()
       
    53 {
       
    54 }
       
    55 
       
    56 
       
    57 /*!
       
    58     Opens view to the specific message
       
    59  */
       
    60 void NmViewerServiceInterface::viewMessage(QVariant mailboxId, QVariant folderId, QVariant messageId)
       
    61 {
       
    62     NMLOG("NmViewerServiceInterface::viewMessage()");
       
    63 #ifndef NM_WINS_ENV
       
    64     mAsyncReqId = setCurrentRequestAsync();
       
    65 
       
    66     NmId mailboxNmId(mailboxId.toULongLong());
       
    67     NmId messageNmId(messageId.toULongLong());
       
    68     NmId folderNmId(folderId.toULongLong());
       
    69 
       
    70     NmMessage *message = mUiEngine.message( mailboxNmId, folderNmId, messageNmId );
       
    71     if (message) {
       
    72         // bring application to foreground
       
    73         XQServiceUtil::toBackground(false);
       
    74 
       
    75         // Launch the message list view.
       
    76         NmUiStartParam *startParam =
       
    77             new NmUiStartParam(NmUiViewMessageViewer,
       
    78                                mailboxNmId,
       
    79                                folderNmId, // folder id
       
    80                                messageNmId, // message id
       
    81                                NmUiEditorCreateNew, // editor start mode
       
    82                                NULL, // address list
       
    83                                NULL, // attachment list
       
    84                                true); // start as service
       
    85         mApplication->enterNmUiView(startParam);
       
    86 
       
    87         completeRequest(mAsyncReqId,0);
       
    88     }
       
    89     else {
       
    90         // Message was not found
       
    91 
       
    92         // if started as embedded, do not hide the app
       
    93 		if (!XQServiceUtil::isEmbedded()) {
       
    94 			XQServiceUtil::toBackground(true);
       
    95 		}
       
    96 
       
    97         completeRequest(mAsyncReqId,1);
       
    98 
       
    99         // Close the application if started as service
       
   100         if (XQServiceUtil::isService()) {
       
   101             // Exit the application when the return value is delivered
       
   102             connect(this, SIGNAL(returnValueDelivered()),
       
   103                     mApplication, SLOT(delayedExitApplication()));
       
   104         }
       
   105     }
       
   106 #endif
       
   107 }
       
   108 
       
   109 // End of file.