|
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 <cpservicemainwindow.h> |
|
20 #include <cplauncherinterface.h> |
|
21 #include <cppluginloader.h> |
|
22 #include <cpbasesettingview.h> |
|
23 #include "cpsplogger.h" |
|
24 |
|
25 CpLauncherService::CpLauncherService(HbMainWindow *mainWindow /* = 0*/) |
|
26 : XQServiceProvider("com.nokia.services.cpserviceprovider.Launcher",mainWindow), |
|
27 mMainWindow(mainWindow), |
|
28 mAsyncRequestIndex(-1), |
|
29 mReturnValue(false) |
|
30 { |
|
31 CPSP_LOG("CpLauncherService Constructing..."); |
|
32 publishAll(); |
|
33 } |
|
34 |
|
35 CpLauncherService::~CpLauncherService() |
|
36 { |
|
37 CPSP_LOG("CpLauncherService Destructing..."); |
|
38 } |
|
39 |
|
40 void CpLauncherService::complete() |
|
41 { |
|
42 CPSP_LOG( QString("CpLauncherService::complete() mAsyncRequestIndex = %1, mReturnValue = %2").arg( |
|
43 mAsyncRequestIndex).arg(mReturnValue.toBool()) ); |
|
44 completeRequest(mAsyncRequestIndex, mReturnValue); |
|
45 } |
|
46 |
|
47 |
|
48 bool CpLauncherService::launchSettingView(const QString &pluginFile,const QVariant &hint) |
|
49 { |
|
50 CPSP_LOG("Entering CpLauncherService::launchSettingView"); |
|
51 |
|
52 mAsyncRequestIndex = setCurrentRequestAsync(); |
|
53 mReturnValue.setValue(false); |
|
54 |
|
55 if (mMainWindow) { |
|
56 mMainWindow->show(); |
|
57 CpLauncherInterface *plugin = CpPluginLoader::loadCpLauncherInterface(pluginFile); |
|
58 if (plugin) { |
|
59 CpBaseSettingView *view = plugin->createSettingView(hint); |
|
60 if (view) { |
|
61 connect(view, SIGNAL(aboutToClose()), mMainWindow, SLOT(quit())); |
|
62 mMainWindow->addView(view); |
|
63 mMainWindow->setCurrentView(view); |
|
64 |
|
65 mReturnValue.setValue(true); |
|
66 } |
|
67 else { |
|
68 CPSP_LOG("Create setting view failed."); |
|
69 } |
|
70 } |
|
71 else { |
|
72 CPSP_LOG(QLatin1String("Load plugin interface(CpLauncherInterface) failed: ") + pluginFile); |
|
73 } |
|
74 |
|
75 if (!mReturnValue.toBool()) { |
|
76 qobject_cast<CpServiceMainWindow*>(mMainWindow)->quit(); |
|
77 } |
|
78 } |
|
79 |
|
80 CPSP_LOG("Leaving CpLauncherService::launchSettingView"); |
|
81 |
|
82 return mReturnValue.toBool(); |
|
83 } |
|
84 |
|
85 //End of File |