|
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 //System includes |
|
19 #include <QtPlugin> |
|
20 #include <hbdevicedialog.h> |
|
21 |
|
22 //user includes |
|
23 #include "hbdevicepowermenuplugin_p.h" |
|
24 #include "hbdevicepowermenuwidegt_p.h" |
|
25 #include "hbdevicepowermenupluginerrors_p.h" |
|
26 |
|
27 //SysAp's Secure UID |
|
28 const quint32 KSecureUid = 0x100058F3; |
|
29 |
|
30 Q_EXPORT_PLUGIN2(devicepowermenuplugin, HbDevicePowerMenuPlugin) |
|
31 |
|
32 // This plugin implements a device dialog type |
|
33 static const struct |
|
34 { |
|
35 const char *mTypeString; |
|
36 } dialogInfos[] = {{"com.nokia.hb.devicepowermenu/1.0"}}; |
|
37 |
|
38 class HbDevicePowerMenuPluginPrivate |
|
39 { |
|
40 public: |
|
41 HbDevicePowerMenuPluginPrivate() {mError = NoError;} |
|
42 int mError; |
|
43 }; |
|
44 |
|
45 /** |
|
46 * Constructor |
|
47 */ |
|
48 HbDevicePowerMenuPlugin::HbDevicePowerMenuPlugin() |
|
49 { |
|
50 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Constructor:Begin") ) ); |
|
51 d = new HbDevicePowerMenuPluginPrivate; |
|
52 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Constructor:End") ) ); |
|
53 } |
|
54 |
|
55 /** |
|
56 * Destructor |
|
57 */ |
|
58 HbDevicePowerMenuPlugin::~HbDevicePowerMenuPlugin() |
|
59 { |
|
60 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Destructor:Begin") ) ); |
|
61 delete d; |
|
62 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Destructor:End") ) ); |
|
63 } |
|
64 |
|
65 /** |
|
66 * This method is Pure Virtual in HbDeviceDialogPlugin |
|
67 * Checks if client is allowed to use device dialog widget |
|
68 * Its a customized widget for Sysap, and allows only Sysap to use this plugin |
|
69 */ |
|
70 bool HbDevicePowerMenuPlugin::accessAllowed(const QString &deviceDialogType, const QVariantMap ¶meters, const QVariantMap &securityInfo) const |
|
71 { |
|
72 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::accessAllowed:Begin") ) ); |
|
73 Q_UNUSED(deviceDialogType) |
|
74 Q_UNUSED(parameters) |
|
75 TBool secured(false); |
|
76 quint32 secUid = static_cast<quint32>(securityInfo.value("sym-secureId").toInt()); |
|
77 if (secUid == KSecureUid ) |
|
78 { |
|
79 secured = true; |
|
80 } |
|
81 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::accessAllowed:End") ) ); |
|
82 return secured; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Creates device dialog widget |
|
87 */ |
|
88 HbDeviceDialogInterface *HbDevicePowerMenuPlugin::createDeviceDialog(const QString &deviceDialogType, const QVariantMap ¶meters) |
|
89 { |
|
90 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::createDeviceDialog:Begin") ) ); |
|
91 d->mError = NoError; |
|
92 |
|
93 HbDeviceDialogInterface *ret(NULL); |
|
94 if (dialogInfos[0].mTypeString == deviceDialogType) |
|
95 { |
|
96 QVariantMap params = parameters; |
|
97 HbDevicePowerMenuWidget *powMenu = new HbDevicePowerMenuWidget(params); |
|
98 d->mError = powMenu->deviceDialogError(); |
|
99 if (d->mError != NoError) |
|
100 { |
|
101 delete powMenu; |
|
102 powMenu = NULL; |
|
103 } |
|
104 ret = powMenu; |
|
105 } |
|
106 else |
|
107 { |
|
108 d->mError = UnknownDeviceDialogError; |
|
109 ret = NULL; |
|
110 } |
|
111 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::createDeviceDialog:End") ) ); |
|
112 return ret; |
|
113 } |
|
114 |
|
115 /** |
|
116 * Return information of device dialog the plugin creates |
|
117 */ |
|
118 bool HbDevicePowerMenuPlugin::deviceDialogInfo(const QString &deviceDialogType, const QVariantMap ¶meters, DeviceDialogInfo *info) const |
|
119 { |
|
120 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogInfo:Begin") ) ); |
|
121 Q_UNUSED(parameters) |
|
122 Q_UNUSED(deviceDialogType) |
|
123 |
|
124 info->group = GenericDeviceDialogGroup; |
|
125 info->flags = SecurityCheck; |
|
126 info->priority = DefaultPriority; |
|
127 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogInfo:End") ) ); |
|
128 return true; |
|
129 } |
|
130 |
|
131 /** |
|
132 * Return device dialog types this plugin implements |
|
133 */ |
|
134 QStringList HbDevicePowerMenuPlugin::deviceDialogTypes() const |
|
135 { |
|
136 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogTypes:Begin") ) ); |
|
137 QStringList types; |
|
138 const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]); |
|
139 for(int i = 0; i < numTypes; i++) |
|
140 { |
|
141 types.append(dialogInfos[i].mTypeString); |
|
142 } |
|
143 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogTypes:End") ) ); |
|
144 return types; |
|
145 } |
|
146 |
|
147 /** |
|
148 * Return plugin flags |
|
149 */ |
|
150 HbDeviceDialogPlugin::PluginFlags HbDevicePowerMenuPlugin::pluginFlags() const |
|
151 { |
|
152 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::pluginFlags:Begin") ) ); |
|
153 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::pluginFlags:End") ) ); |
|
154 return NoPluginFlags; |
|
155 } |
|
156 |
|
157 /** |
|
158 * Return last error |
|
159 */ |
|
160 int HbDevicePowerMenuPlugin::error() const |
|
161 { |
|
162 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::error:Begin") ) ); |
|
163 TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::error:End") ) ); |
|
164 return d->mError; |
|
165 } |
|
166 |