controlpanelui/src/cpserviceprovider/src/cplauncherservice.cpp
changeset 19 36aa4756ee82
parent 12 624337f114fe
child 22 a5692c68d772
equal deleted inserted replaced
12:624337f114fe 19:36aa4756ee82
    14 * Description:  
    14 * Description:  
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cplauncherservice.h"
    18 #include "cplauncherservice.h"
       
    19 #include <QCoreApplication>
    19 #include <cpservicemainwindow.h>
    20 #include <cpservicemainwindow.h>
    20 #include <cplauncherinterface.h>
    21 #include <cplauncherinterface.h>
    21 #include <cppluginloader.h>
    22 #include <cppluginloader.h>
    22 #include <cpbasesettingview.h>
    23 #include <cpbasesettingview.h>
    23 #include "cpsplogger.h"
    24 #include "cpsplogger.h"
    24 
    25 
    25 CpLauncherService::CpLauncherService(HbMainWindow *mainWindow /* = 0*/)
    26 CpLauncherService::CpLauncherService(HbMainWindow *mainWindow /* = 0*/)
    26 : XQServiceProvider("com.nokia.services.cpserviceprovider.Launcher",mainWindow),
    27 : XQServiceProvider("cpserviceprovider.com.nokia.symbian.ICpPluginLauncher",mainWindow),
    27   mMainWindow(mainWindow),
    28   mMainWindow(mainWindow),
    28   mAsyncRequestIndex(-1),
    29   mAsyncRequestIndex(-1),
    29   mReturnValue(false)
    30   mReturnValue(false)
    30 {
    31 {
    31     CPSP_LOG("CpLauncherService Constructing...");
    32     CPSP_LOG("CpLauncherService Constructing...");
    42     CPSP_LOG( QString("CpLauncherService::complete() mAsyncRequestIndex = %1, mReturnValue = %2").arg(
    43     CPSP_LOG( QString("CpLauncherService::complete() mAsyncRequestIndex = %1, mReturnValue = %2").arg(
    43             mAsyncRequestIndex).arg(mReturnValue.toBool()) );
    44             mAsyncRequestIndex).arg(mReturnValue.toBool()) );
    44     completeRequest(mAsyncRequestIndex, mReturnValue);
    45     completeRequest(mAsyncRequestIndex, mReturnValue);
    45 }
    46 }
    46 
    47 
       
    48 void CpLauncherService::setReturnValue(const QVariant &returnValue)
       
    49 {
       
    50     mReturnValue = returnValue;
       
    51 }
    47 
    52 
    48 bool CpLauncherService::launchSettingView(const QString &pluginFile,const QVariant &hint)
    53 bool CpLauncherService::launchSettingView(const QString &pluginFile,const QVariant &hint)
    49 {
    54 {
    50     CPSP_LOG("Entering CpLauncherService::launchSettingView");
    55     CPSP_LOG("Entering CpLauncherService::launchSettingView");
    51    
    56    
    52     mAsyncRequestIndex = setCurrentRequestAsync();
    57     mAsyncRequestIndex = setCurrentRequestAsync();
    53     mReturnValue.setValue(false);
    58     
       
    59     bool succeed = false;
    54        
    60        
    55     if (mMainWindow) {
    61     if (mMainWindow) {
    56         mMainWindow->show();
    62         mMainWindow->show();
    57         CpLauncherInterface *plugin = CpPluginLoader::loadCpLauncherInterface(pluginFile);
    63         CpLauncherInterface *plugin = CpPluginLoader::loadCpLauncherInterface(pluginFile);
    58         if (plugin) {
    64         if (plugin) {
    59             CpBaseSettingView *view = plugin->createSettingView(hint);
    65             CpBaseSettingView *settingView = plugin->createSettingView(hint);
    60             if (view) {
    66             if (settingView) {
    61                 connect(view, SIGNAL(aboutToClose()), mMainWindow, SLOT(quit()));
    67                 connect(settingView, SIGNAL(returnValueDelivered(QVariant)),this,SLOT(setReturnValue(QVariant)));
    62                 mMainWindow->addView(view);
    68                 (static_cast<CpServiceMainWindow*>(mMainWindow))->setSettingView(settingView);                
    63                 mMainWindow->setCurrentView(view);
    69                 succeed = true;
    64                 
       
    65                 mReturnValue.setValue(true);
       
    66             }
    70             }
    67             else {
    71             else {
    68                 CPSP_LOG("Create setting view failed.");
    72                 CPSP_LOG("Create setting view failed.");
    69             }
    73             }
    70         }
    74         }
    71         else {
    75         else {
    72             CPSP_LOG(QLatin1String("Load plugin interface(CpLauncherInterface) failed: ") + pluginFile);
    76             CPSP_LOG(QLatin1String("Load plugin interface(CpLauncherInterface) failed: ") + pluginFile);
    73         }
    77         }
    74         
    78         
    75         if (!mReturnValue.toBool()) {
    79         if (!succeed) {
    76             qobject_cast<CpServiceMainWindow*>(mMainWindow)->quit();
    80             qApp->quit();  //quit application if loading plugin failed or creating setting view failed.
    77         }
    81         }
    78     }
    82     }
    79        
    83        
    80     CPSP_LOG("Leaving CpLauncherService::launchSettingView");
    84     CPSP_LOG("Leaving CpLauncherService::launchSettingView");
    81     
    85     
    82     return mReturnValue.toBool();
    86     return succeed;
    83 }
    87 }
    84 
    88 
    85 //End of File
    89 //End of File