emailuis/nmailui/src/nmviewerserviceinterface.cpp
branchRCL_3
changeset 63 d189ee25cf9d
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
       
     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     : XQServiceProvider(emailFullServiceNameMessage, parent),
       
    35       mApplication(application),
       
    36       mUiEngine(uiEngine),
       
    37       mAsyncReqId(0)
       
    38 {
       
    39     publishAll();
       
    40 }
       
    41 
       
    42 
       
    43 /*!
       
    44     Class desctructor.
       
    45 */
       
    46 NmViewerServiceInterface::~NmViewerServiceInterface()
       
    47 {
       
    48     NM_FUNCTION;
       
    49 }
       
    50 
       
    51 
       
    52 /*!
       
    53     Opens view to the specific message
       
    54  */
       
    55 void NmViewerServiceInterface::viewMessage(QVariant mailboxId, QVariant folderId, QVariant messageId)
       
    56 {
       
    57     NM_FUNCTION;
       
    58 
       
    59     mAsyncReqId = setCurrentRequestAsync();
       
    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 
       
    67 	// Make sure the app stays background if user presses back in viewer view
       
    68 	bool visible = mApplication->updateVisibilityState();
       
    69 
       
    70     NmMessage *message = mUiEngine.message( mailboxNmId, folderNmId, messageNmId );
       
    71     if (message) {
       
    72         // bring application to foreground
       
    73         if (!XQServiceUtil::isEmbedded()) {
       
    74             XQServiceUtil::toBackground(false);
       
    75         }
       
    76         HbMainWindow *mainWindow = mApplication->mainWindow();
       
    77         mainWindow->show();
       
    78 
       
    79         // Launch the message list view.
       
    80         NmUiStartParam *startParam1 = 
       
    81             new NmUiStartParam(NmUiViewMessageList,
       
    82                                mailboxNmId,
       
    83                                folderNmId, // folder id
       
    84                                messageNmId, // message id
       
    85                                NmUiEditorCreateNew, // editor start mode
       
    86                                NULL, // address list
       
    87                                NULL, // attachment list
       
    88                                true); // start as service
       
    89         mApplication->enterNmUiView(startParam1);
       
    90         
       
    91         // Launch the message view.
       
    92         NmUiStartParam *startParam =
       
    93             new NmUiStartParam(NmUiViewMessageViewer,
       
    94                                mailboxNmId,
       
    95                                folderNmId, // folder id
       
    96                                messageNmId, // message id
       
    97                                NmUiEditorCreateNew, // editor start mode
       
    98                                NULL, // address list
       
    99                                NULL, // attachment list
       
   100                                false); // not started as service
       
   101         mApplication->enterNmUiView(startParam);
       
   102 
       
   103         completeRequest(mAsyncReqId,0);
       
   104     }
       
   105     else {
       
   106         // Message was not found
       
   107 
       
   108         // if started as embedded, do not hide the app
       
   109 		if (!XQServiceUtil::isEmbedded() && !visible) {
       
   110 			XQServiceUtil::toBackground(true);
       
   111 		}
       
   112 
       
   113         completeRequest(mAsyncReqId,1);
       
   114 
       
   115         // Close the application if started as service
       
   116         if (XQServiceUtil::isService()) {
       
   117             // Exit the application when the return value is delivered
       
   118             connect(this, SIGNAL(returnValueDelivered()),
       
   119                     mApplication, SLOT(delayedExitApplication()));
       
   120         }
       
   121     }
       
   122 }
       
   123 
       
   124 // End of file.