controlpanelui/src/cpserviceprovider/src/cplauncherservice.cpp
branchRCL_3
changeset 13 90fe62538f66
equal deleted inserted replaced
12:3fec62e6e7fc 13:90fe62538f66
       
     1 /*
       
     2 * Copyright (c) 2009 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 "cplauncherservice.h"
       
    19 #include <QCoreApplication>
       
    20 #include <cpservicemainwindow.h>
       
    21 #include <cplauncherinterface.h>
       
    22 #include <cppluginloader.h>
       
    23 #include <cpbasesettingview.h>
       
    24 #include "cpsplogger.h"
       
    25 
       
    26 CpLauncherService::CpLauncherService(HbMainWindow *mainWindow /* = 0*/)
       
    27 : XQServiceProvider("cpserviceprovider.com.nokia.symbian.ICpPluginLauncher",mainWindow),
       
    28   mMainWindow(mainWindow),
       
    29   mAsyncRequestIndex(-1),
       
    30   mReturnValue(false)
       
    31 {
       
    32     CPSP_LOG_FUNC_ENTRY("CpLauncherService::CpLauncherService")
       
    33     
       
    34     publishAll();
       
    35     connect(this,SIGNAL(clientDisconnected()),this,SLOT(handleClientDisconnected()));
       
    36 }
       
    37 
       
    38 CpLauncherService::~CpLauncherService()
       
    39 {
       
    40     CPSP_LOG_FUNC_ENTRY("CpLauncherService::~CpLauncherService")
       
    41 }
       
    42 
       
    43 bool CpLauncherService::complete()
       
    44 {
       
    45     CPSP_LOG_FUNC_ENTRY("CpLauncherService::complete")
       
    46     
       
    47     CPSP_LOG( QString("CpLauncherService::complete() mAsyncRequestIndex = %1, mReturnValue = %2").arg(
       
    48             mAsyncRequestIndex).arg(mReturnValue.toBool()) )
       
    49     
       
    50     bool ret = completeRequest(mAsyncRequestIndex, mReturnValue);
       
    51     mAsyncRequestIndex = -1;
       
    52     return ret;
       
    53 }
       
    54 
       
    55 void CpLauncherService::setReturnValue(const QVariant &returnValue)
       
    56 {
       
    57     CPSP_LOG_FUNC_ENTRY("CpLauncherService::setReturnValue")
       
    58     
       
    59     mReturnValue = returnValue;
       
    60 }
       
    61 
       
    62 bool CpLauncherService::launchSettingView(const QString &pluginFile,const QVariant &hint)
       
    63 {
       
    64     CPSP_LOG_FUNC_ENTRY("CpLauncherService::launchSettingView");
       
    65    
       
    66     mAsyncRequestIndex = setCurrentRequestAsync();
       
    67     
       
    68     bool succeed = false;
       
    69        
       
    70     if (mMainWindow) {
       
    71         mMainWindow->show();
       
    72         CpLauncherInterface *plugin = CpPluginLoader::loadCpLauncherInterface(pluginFile);
       
    73         if (plugin) {
       
    74             CpBaseSettingView *settingView = plugin->createSettingView(hint);
       
    75             if (settingView) {
       
    76                 connect(settingView, SIGNAL(returnValueDelivered(QVariant)),this,SLOT(setReturnValue(QVariant)));
       
    77                 (static_cast<CpServiceMainWindow*>(mMainWindow))->setSettingView(settingView);                
       
    78                 succeed = true;
       
    79             }
       
    80             else {
       
    81                 CPSP_LOG("Create setting view failed.");
       
    82             }
       
    83         }
       
    84         else {
       
    85             CPSP_LOG(QLatin1String("Load plugin interface(CpLauncherInterface) failed: ") + pluginFile);
       
    86         }
       
    87         
       
    88         if (!succeed) {
       
    89             qApp->quit();  //quit application if loading plugin failed or creating setting view failed.
       
    90         }
       
    91     }
       
    92     
       
    93     return succeed;
       
    94 }
       
    95 
       
    96 void CpLauncherService::handleClientDisconnected()
       
    97 {
       
    98     CPSP_LOG_FUNC_ENTRY("CpLauncherService::handleClientDisconnected")
       
    99         
       
   100     qApp->quit();
       
   101 }
       
   102 
       
   103 //End of File