29
|
1 |
/*
|
70
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
29
|
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: BtDeviceDialogPlugin class implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "btdevicedialogplugin.h"
|
|
20 |
#include "btdevicedialogplugintrace.h"
|
|
21 |
#include <bluetoothdevicedialogs.h>
|
|
22 |
#include <QtPlugin>
|
|
23 |
#include <hbdevicedialog.h>
|
|
24 |
#include "btdevicedialoginputwidget.h"
|
|
25 |
#include "btdevicedialogquerywidget.h"
|
|
26 |
#include "btdevicedialognotifwidget.h"
|
42
|
27 |
#include "btrecvprgrsdialogwidget.h"
|
29
|
28 |
|
|
29 |
#include "btdevicedialogpluginerrors.h"
|
|
30 |
#include "btdevicesearchdialogwidget.h"
|
31
|
31 |
#include "btmoredevicesdialogwidget.h"
|
|
32 |
#include "btsenddialogwidget.h"
|
42
|
33 |
#include "btdevicedialogrecvquerywidget.h"
|
47
|
34 |
#include "btrecvcompleteddialogwidget.h"
|
57
|
35 |
#include "btdeviceinfowidget.h"
|
70
|
36 |
#include "btdevicedialogwaitingwidget.h"
|
|
37 |
#include "btdeviceokonlydialogwidget.h"
|
42
|
38 |
#include <hbtranslator.h>
|
29
|
39 |
|
|
40 |
Q_EXPORT_PLUGIN2(btdevicedialogplugin, BtDeviceDialogPlugin)
|
|
41 |
|
42
|
42 |
const char* BTDIALOG_TRANSLATION = "btdialogs";
|
57
|
43 |
const char* BTVIEW_TRANSLATION = "btviews";
|
|
44 |
const char* COMMON_ERRORS_TRANSLATION = "common_errors";
|
71
|
45 |
const char* COMMON_TRANSLATION = "common";
|
42
|
46 |
|
29
|
47 |
// This plugin implements one device dialog type
|
|
48 |
static const struct {
|
|
49 |
const char *mTypeString;
|
|
50 |
} noteInfos[] = {
|
|
51 |
{"com.nokia.hb.btdevicedialog/1.0"}
|
|
52 |
};
|
|
53 |
|
|
54 |
class BtDeviceDialogPluginPrivate
|
|
55 |
{
|
|
56 |
public:
|
|
57 |
BtDeviceDialogPluginPrivate();
|
|
58 |
public:
|
|
59 |
int mError;
|
|
60 |
};
|
|
61 |
/*!
|
|
62 |
BtDeviceDialogPluginPrivate Constructor
|
|
63 |
*/
|
|
64 |
BtDeviceDialogPluginPrivate::BtDeviceDialogPluginPrivate()
|
|
65 |
{
|
|
66 |
mError = NoError;
|
|
67 |
}
|
|
68 |
|
|
69 |
/*!
|
|
70 |
BtDeviceDialogPlugin Constructor
|
|
71 |
*/
|
42
|
72 |
BtDeviceDialogPlugin::BtDeviceDialogPlugin():
|
71
|
73 |
mDialogTranslator(0),mViewTranslator(0),mCommonErrorsTranslator(0), mCommonTranslator(0)
|
29
|
74 |
{
|
|
75 |
d = new BtDeviceDialogPluginPrivate;
|
|
76 |
}
|
|
77 |
|
|
78 |
/*!
|
|
79 |
Destructor
|
|
80 |
*/
|
|
81 |
BtDeviceDialogPlugin::~BtDeviceDialogPlugin()
|
|
82 |
{
|
|
83 |
delete d;
|
42
|
84 |
delete mDialogTranslator;
|
|
85 |
delete mViewTranslator;
|
57
|
86 |
delete mCommonErrorsTranslator;
|
71
|
87 |
delete mCommonTranslator;
|
29
|
88 |
}
|
|
89 |
|
|
90 |
/*!
|
|
91 |
Check if client is allowed to use device dialog widget
|
|
92 |
*/
|
|
93 |
bool BtDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType,
|
|
94 |
const QVariantMap ¶meters, const QVariantMap &securityInfo) const
|
|
95 |
{
|
|
96 |
Q_UNUSED(deviceDialogType)
|
|
97 |
Q_UNUSED(parameters)
|
|
98 |
Q_UNUSED(securityInfo)
|
|
99 |
|
|
100 |
// This plugin doesn't perform operations that may compromise security.
|
|
101 |
// All clients are allowed to use.
|
|
102 |
return true;
|
|
103 |
}
|
|
104 |
|
|
105 |
/*!
|
|
106 |
From interface class.
|
|
107 |
Use the dialog type in the parameter to create widget.
|
|
108 |
*/
|
|
109 |
HbDeviceDialogInterface *BtDeviceDialogPlugin::createDeviceDialog(
|
|
110 |
const QString &deviceDialogType, const QVariantMap ¶meters)
|
|
111 |
{
|
|
112 |
d->mError = NoError;
|
|
113 |
|
|
114 |
int i;
|
42
|
115 |
|
|
116 |
if(!mDialogTranslator)
|
|
117 |
{
|
|
118 |
mDialogTranslator = new HbTranslator(BTDIALOG_TRANSLATION);
|
|
119 |
}
|
|
120 |
if(!mViewTranslator)
|
|
121 |
{
|
|
122 |
mViewTranslator = new HbTranslator(BTVIEW_TRANSLATION);
|
|
123 |
}
|
57
|
124 |
if(!mCommonErrorsTranslator)
|
|
125 |
{
|
|
126 |
mCommonErrorsTranslator = new HbTranslator(COMMON_ERRORS_TRANSLATION);
|
|
127 |
}
|
71
|
128 |
if(!mCommonTranslator)
|
|
129 |
{
|
|
130 |
mCommonTranslator = new HbTranslator(COMMON_TRANSLATION);
|
|
131 |
}
|
57
|
132 |
|
29
|
133 |
// verify that requested dialog type is supported
|
|
134 |
const int numTypes = sizeof(noteInfos) / sizeof(noteInfos[0]);
|
|
135 |
for(i = 0; i < numTypes; i++) {
|
|
136 |
if (noteInfos[i].mTypeString == deviceDialogType) {
|
|
137 |
break;
|
|
138 |
}
|
|
139 |
}
|
|
140 |
// dialog type was found
|
|
141 |
if (i < numTypes) {
|
|
142 |
return checkDialogType( parameters );
|
|
143 |
}
|
|
144 |
else {
|
|
145 |
// unknown dialog type, return error
|
|
146 |
d->mError = UnknownDeviceDialogError;
|
|
147 |
return 0;
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
/*!
|
|
152 |
Return information of device dialog the plugin creates
|
|
153 |
Currently only supporting 1 device dialog type, so no need to check the type.
|
|
154 |
*/
|
|
155 |
bool BtDeviceDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
|
|
156 |
const QVariantMap ¶meters, DeviceDialogInfo *info) const
|
|
157 |
{
|
71
|
158 |
|
29
|
159 |
Q_UNUSED(deviceDialogType)
|
|
160 |
// set return values
|
71
|
161 |
// Construct the key of EDialogType
|
|
162 |
QString keyStr;
|
|
163 |
keyStr.setNum( TBluetoothDialogParams::EDialogType );
|
|
164 |
// Find the const iterator with key EDialogType
|
|
165 |
QVariantMap::const_iterator i = parameters.constFind( keyStr );
|
|
166 |
|
|
167 |
// item with key EDialogType is not found
|
|
168 |
if ( i == parameters.constEnd() ) {
|
|
169 |
d->mError = UnknownDeviceDialogError;
|
|
170 |
return false;
|
|
171 |
}
|
|
172 |
int type = i.value().toInt();
|
|
173 |
if(type == TBluetoothDialogParams::EGlobalNotif ||
|
|
174 |
type == TBluetoothDialogParams::ENote ||
|
|
175 |
type == TBluetoothDialogParams::bt_054_d_entered_popup)
|
|
176 |
{
|
|
177 |
info->group = DeviceNotificationDialogGroup;
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
info->group = GenericDeviceDialogGroup;
|
|
182 |
}
|
29
|
183 |
info->flags = NoDeviceDialogFlags;
|
|
184 |
info->priority = DefaultPriority;
|
|
185 |
return true;
|
|
186 |
}
|
|
187 |
|
|
188 |
/*!
|
|
189 |
Return device dialog types this plugin implements
|
|
190 |
Function will work fine (unchanged) when new dialogs are added.
|
|
191 |
*/
|
|
192 |
QStringList BtDeviceDialogPlugin::deviceDialogTypes() const
|
|
193 |
{
|
|
194 |
QStringList types;
|
|
195 |
// read supported types from noteInfos
|
|
196 |
const int numTypes = sizeof(noteInfos) / sizeof(noteInfos[0]);
|
|
197 |
for(int i = 0; i < numTypes; i++) {
|
|
198 |
types.append(noteInfos[i].mTypeString);
|
|
199 |
}
|
|
200 |
return types;
|
|
201 |
}
|
|
202 |
|
|
203 |
/*!
|
|
204 |
Return plugin flags
|
|
205 |
*/
|
|
206 |
HbDeviceDialogPlugin::PluginFlags BtDeviceDialogPlugin::pluginFlags() const
|
|
207 |
{
|
|
208 |
return NoPluginFlags;
|
|
209 |
}
|
|
210 |
|
|
211 |
/*!
|
|
212 |
Return last error
|
|
213 |
*/
|
|
214 |
int BtDeviceDialogPlugin::error() const
|
|
215 |
{
|
|
216 |
return d->mError;
|
|
217 |
}
|
|
218 |
|
|
219 |
/*!
|
|
220 |
Check the device dialog type to decide which widget to be used.
|
|
221 |
And create the specified widget.
|
|
222 |
*/
|
|
223 |
HbDeviceDialogInterface *BtDeviceDialogPlugin::checkDialogType( const QVariantMap ¶meters )
|
|
224 |
{
|
|
225 |
// Construct the key of EDialogType
|
|
226 |
QString keyStr;
|
|
227 |
keyStr.setNum( TBluetoothDialogParams::EDialogType );
|
|
228 |
// Find the const iterator with key EDialogType
|
|
229 |
QVariantMap::const_iterator i = parameters.constFind( keyStr );
|
|
230 |
|
|
231 |
// item with key EDialogType is not found
|
|
232 |
if ( i == parameters.constEnd() ) {
|
|
233 |
d->mError = UnknownDeviceDialogError;
|
|
234 |
return NULL;
|
|
235 |
}
|
|
236 |
|
|
237 |
// item with key EDialogType is found
|
|
238 |
// generate specified widget based on the dialog type value.
|
|
239 |
HbDeviceDialogInterface *deviceDialog = NULL;
|
|
240 |
switch ( i.value().toInt() ) {
|
|
241 |
case TBluetoothDialogParams::ENote:
|
70
|
242 |
case TBluetoothDialogParams::bt_054_d_entered_popup:
|
29
|
243 |
deviceDialog =
|
42
|
244 |
new BtDeviceDialogNotifWidget(parameters);
|
29
|
245 |
break;
|
|
246 |
case TBluetoothDialogParams::EQuery:
|
|
247 |
deviceDialog =
|
47
|
248 |
new BtDeviceDialogQueryWidget(HbMessageBox::MessageTypeWarning,parameters);
|
29
|
249 |
break;
|
|
250 |
case TBluetoothDialogParams::EInput:
|
|
251 |
deviceDialog = new BtDeviceDialogInputWidget(parameters);
|
|
252 |
break;
|
31
|
253 |
case TBluetoothDialogParams::EMoreDevice:
|
|
254 |
deviceDialog = new BTMoreDevicesDialogWidget(parameters);
|
|
255 |
break;
|
29
|
256 |
case TBluetoothDialogParams::EDeviceSearch:
|
|
257 |
deviceDialog = new BTDeviceSearchDialogWidget(parameters);
|
|
258 |
break;
|
31
|
259 |
case TBluetoothDialogParams::ESend:
|
|
260 |
deviceDialog = new BTSendDialogWidget(parameters);
|
|
261 |
break;
|
29
|
262 |
case TBluetoothDialogParams::EGlobalNotif:
|
|
263 |
deviceDialog = new BtDeviceDialogNotifWidget(parameters);
|
|
264 |
break;
|
42
|
265 |
case TBluetoothDialogParams::EUserAuthorization:
|
|
266 |
deviceDialog = new BTRecvQueryDialogWidget(parameters);
|
|
267 |
break;
|
|
268 |
case TBluetoothDialogParams::EReceiveProgress:
|
|
269 |
deviceDialog = new BTRecvPrgrsDialogWidget(parameters);
|
|
270 |
break;
|
47
|
271 |
case TBluetoothDialogParams::EReceiveDone:
|
|
272 |
deviceDialog = new BTRecvcompletedDialogWidget(parameters);
|
|
273 |
break;
|
57
|
274 |
case TBluetoothDialogParams::EInformationDialog:
|
|
275 |
deviceDialog = new BtDeviceInfoWidget(parameters);
|
|
276 |
break;
|
70
|
277 |
case TBluetoothDialogParams::bt_052_d_entering:
|
|
278 |
deviceDialog = new BtDeviceDialogWaitingWidget(parameters);
|
|
279 |
break;
|
|
280 |
case TBluetoothDialogParams::bt_053_d_unable_to_use_no_sim:
|
|
281 |
case TBluetoothDialogParams::bt_053_d_unable_to_use:
|
|
282 |
deviceDialog =
|
|
283 |
new BtDeviceOkOnlyDialogWidget(HbMessageBox::MessageTypeWarning,parameters);
|
|
284 |
break;
|
29
|
285 |
default:
|
|
286 |
d->mError = UnknownDeviceDialogError;
|
|
287 |
break;
|
|
288 |
}
|
|
289 |
if ( deviceDialog ) {
|
|
290 |
// verify no error has occurred
|
|
291 |
d->mError = deviceDialog->deviceDialogError();
|
|
292 |
if ( d->mError ) {
|
|
293 |
// Do not continue if an error occurred
|
|
294 |
delete deviceDialog;
|
|
295 |
deviceDialog = NULL;
|
|
296 |
}
|
|
297 |
}
|
|
298 |
return deviceDialog;
|
|
299 |
}
|