|
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 #include "mainview.h" |
|
18 #include <hbmenu.h> |
|
19 #include <hbaction.h> |
|
20 #include <qcoreapplication.h> |
|
21 #include <cppluginlauncher.h> |
|
22 #include <QStringList> |
|
23 #include <cpbasesettingview.h> |
|
24 #include <hbmessagebox.h> |
|
25 #include <xqaiwrequest.h> |
|
26 #include <XQServiceRequest.h> |
|
27 #include <QTimer> |
|
28 |
|
29 MainView::MainView(QGraphicsItem *parent/* = 0*/) |
|
30 : HbView(parent),mRequest(0) |
|
31 { |
|
32 init(); |
|
33 } |
|
34 |
|
35 MainView::~MainView() |
|
36 { |
|
37 delete mRequest; |
|
38 } |
|
39 |
|
40 void MainView::init() |
|
41 { |
|
42 setTitle(tr("CpPlugin Launcher")); |
|
43 |
|
44 HbMenu *menu = new HbMenu(); |
|
45 setMenu(menu); |
|
46 |
|
47 HbAction *action = menu->addAction(tr("Launch View(in process)")); |
|
48 connect(action, SIGNAL(triggered()), this, SLOT(launchInProcessProfileView())); |
|
49 |
|
50 action = menu->addAction(tr("Launch View(QtHighway)")); |
|
51 connect(action, SIGNAL(triggered()), this, SLOT(launchQtHighwayProfileView())); |
|
52 } |
|
53 |
|
54 void MainView::launchInProcessProfileView() |
|
55 { |
|
56 CpBaseSettingView *settingView = CpPluginLauncher::launchSettingView("cppersonalizationplugin.dll","profile_view"); |
|
57 if (settingView) { |
|
58 connect(settingView,SIGNAL(returnValueDelivered(QVariant)),this,SLOT(handleReturnValue(QVariant))); |
|
59 } |
|
60 } |
|
61 |
|
62 void MainView::launchQtHighwayProfileView() |
|
63 { |
|
64 if (mRequest) { |
|
65 delete mRequest; |
|
66 mRequest = 0; |
|
67 } |
|
68 |
|
69 mRequest = mAppMgr.create("com.nokia.symbian.ICpPluginLauncher", "launchSettingView(QString,QVariant)", true); |
|
70 |
|
71 if (!mRequest) |
|
72 { |
|
73 return; |
|
74 } |
|
75 else |
|
76 { |
|
77 connect(mRequest, SIGNAL(requestOk(QVariant)), SLOT(handleReturnValue(QVariant))); |
|
78 connect(mRequest, SIGNAL(requestError(int,QString)), SLOT(handleError(int,QString))); |
|
79 } |
|
80 |
|
81 |
|
82 // Set arguments for request |
|
83 QList<QVariant> args; |
|
84 args << QVariant( "cppersonalizationplugin.dll" ); |
|
85 args << QVariant ( "profile_view" ); |
|
86 mRequest->setArguments(args); |
|
87 |
|
88 mRequest->setSynchronous(false); |
|
89 |
|
90 QTimer::singleShot(20* 1000, this, SLOT(closeSettingView())); |
|
91 |
|
92 // Make the request |
|
93 if (!mRequest->send()) |
|
94 { |
|
95 //report error |
|
96 } |
|
97 |
|
98 } |
|
99 |
|
100 void MainView::handleReturnValue(const QVariant &returnValue) |
|
101 { |
|
102 HbMessageBox::information( QString("Return value:") + returnValue.toString()); |
|
103 } |
|
104 |
|
105 void MainView::handleError(int errorCode,const QString &errorMessage) |
|
106 { |
|
107 HbMessageBox::information( QString("handle error:") + errorMessage); |
|
108 } |
|
109 |
|
110 void MainView::closeSettingView() |
|
111 { |
|
112 if (mRequest) { |
|
113 delete mRequest; |
|
114 mRequest = 0; |
|
115 } |
|
116 } |
|
117 |
|
118 //End of File |