phoneapp/phoneuiqtviewadapter/src/phoneapplauncher.cpp
branchRCL_3
changeset 61 41a7f70b3818
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <devicelockaccessapi.h>
       
    19 #include <xqservicerequest.h>
       
    20 #include <xqappmgr.h>
       
    21 #include <xqrequestinfo.h>
       
    22 #include <xqaiwdecl.h>
       
    23 
       
    24 #include "phoneapplauncher.h"
       
    25 #include "qtphonelog.h"
       
    26 
       
    27 /*!
       
    28     PhoneAppLauncher::PhoneAppLauncher.
       
    29  */
       
    30 PhoneAppLauncher::PhoneAppLauncher(QObject *parent)
       
    31     : QObject(parent)
       
    32 {
       
    33     PHONE_TRACE;
       
    34 }
       
    35 
       
    36 
       
    37 /*!
       
    38     PhoneAppLauncher::~PhoneAppLauncher.
       
    39  */
       
    40 PhoneAppLauncher::~PhoneAppLauncher()
       
    41 {
       
    42     PHONE_TRACE;
       
    43 }
       
    44 
       
    45 /*!
       
    46     PhoneAppLauncher::launchMessaging.
       
    47  */
       
    48 void PhoneAppLauncher::launchMessaging(
       
    49         const QString &toField,
       
    50         const QString &name,
       
    51         const QString &messageBody)
       
    52 {
       
    53     QList<QVariant> arguments;
       
    54     arguments.append(QVariant(toField));
       
    55     arguments.append(QVariant(name));
       
    56     arguments.append(QVariant(messageBody));
       
    57     sendServiceRequest(
       
    58         "com.nokia.services.hbserviceprovider",
       
    59         "conversationview",
       
    60         "send(QString,QString,QString)",
       
    61         arguments,
       
    62         true);
       
    63 }
       
    64 
       
    65 /*!
       
    66     PhoneAppLauncher::launchContacts.
       
    67  */
       
    68 void PhoneAppLauncher::launchContacts()
       
    69 {
       
    70     QList<QVariant> arguments;
       
    71     sendServiceRequest(
       
    72         "com.nokia.services.phonebookappservices",
       
    73         "Launch",
       
    74         "launch()",
       
    75         arguments,
       
    76         true);
       
    77 }
       
    78 
       
    79 /*!
       
    80     PhoneAppLauncher::launchLogs.
       
    81  */
       
    82 void PhoneAppLauncher::launchLogs(
       
    83         int activatedView,
       
    84         bool showDialpad,
       
    85         const QString &dialpadText)
       
    86 {
       
    87     QVariantMap map;
       
    88     map.insert(XQLOGS_VIEW_INDEX, QVariant(activatedView));
       
    89     map.insert(XQLOGS_SHOW_DIALPAD, QVariant(showDialpad));
       
    90     map.insert(XQLOGS_DIALPAD_TEXT, QVariant(dialpadText));
       
    91     QList<QVariant> args;
       
    92     args.append(QVariant(map));
       
    93     sendServiceRequest(
       
    94         "logs",
       
    95         XQI_LOGS_VIEW,
       
    96         XQOP_LOGS_SHOW,
       
    97         args,
       
    98         false);
       
    99 }
       
   100 
       
   101 /*!
       
   102     PhoneAppLauncher::sendServiceRequest.
       
   103  */
       
   104 void PhoneAppLauncher::sendServiceRequest(
       
   105         const QString &service, 
       
   106         const QString &interface,
       
   107         const QString &operation,
       
   108         const QList<QVariant> &arguments, 
       
   109         const bool foreground)
       
   110 {
       
   111     int err = -1;
       
   112     TRAP_IGNORE(
       
   113         // Allow application launch only when device is unlocked
       
   114         // If locked ask devicelock query
       
   115         CDevicelockAccessApi *devicelockAccessApi = CDevicelockAccessApi::NewL();
       
   116         err = devicelockAccessApi->DisableDevicelock();
       
   117         delete devicelockAccessApi;
       
   118     )
       
   119     
       
   120     if ((err == KErrNone) || (err == KErrAlreadyExists)) {
       
   121         PHONE_TRACE3(service, operation, arguments);
       
   122         XQApplicationManager appManager;
       
   123         QScopedPointer<XQAiwRequest> request( 
       
   124             service.isEmpty() ? 
       
   125             appManager.create(interface, operation, false) :
       
   126             appManager.create(service, interface, operation, false) );
       
   127         if (request == NULL) {
       
   128             PHONE_TRACE1("service not found");
       
   129             return;
       
   130         }
       
   131 
       
   132         if (foreground) {
       
   133             XQRequestInfo info;
       
   134             info.setForeground(true);
       
   135             request->setInfo(info);
       
   136         }
       
   137         
       
   138         request->setArguments(arguments);
       
   139         QVariant retValue(-1);
       
   140         if (!request->send(retValue)) {
       
   141             int error = request->lastError();
       
   142             PHONE_TRACE2("send failed, error %d", request->lastError());
       
   143         }
       
   144     }
       
   145 }
       
   146 
       
   147 // end of file
       
   148