45
|
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 |
#include "devicemanagementnotifierutils.h"
|
|
19 |
#include <hbdocumentloader.h>
|
|
20 |
#include <hbdialog.h>
|
|
21 |
#include <hblabel.h>
|
|
22 |
#include <hbmessagebox.h>
|
|
23 |
#include <hbaction.h>
|
|
24 |
#include <e32property.h>
|
|
25 |
#include <qdebug.h>
|
|
26 |
#include "SyncMLNotifierParams.h"
|
|
27 |
#include "pnputillogger.h"
|
|
28 |
#include "omacppinquerydialog.h"
|
|
29 |
#include "devicemanagementnotifierwidget_p.h"
|
|
30 |
enum TSyncmlHbNotifierKeys
|
|
31 |
{
|
|
32 |
|
|
33 |
EHbSOSNotifierKeyStatus = 11, // status set will complete the client subscribe
|
|
34 |
EHbSOSNotifierKeyStatusReturn = 12, // Return the content of actual status value accepted from UI
|
|
35 |
|
|
36 |
EHbDMSyncNotifierKeyStatus = 13,
|
|
37 |
EHbDMSyncNotifierKeyStatusReturn = 14
|
|
38 |
};
|
|
39 |
|
|
40 |
|
|
41 |
devicemanagementnotifierutils::devicemanagementnotifierutils(devicemanagementnotifierwidget* ptr,
|
|
42 |
const QVariantMap ¶meters)
|
|
43 |
{
|
|
44 |
qDebug("devicemanagementnotifierutils");
|
|
45 |
LOGSTRING("devicemanagementnotifierutils");
|
|
46 |
|
|
47 |
QVariantMap::const_iterator i = parameters.constBegin();
|
|
48 |
int notifiertolaunch = 0;
|
|
49 |
while (i != parameters.constEnd())
|
|
50 |
{
|
|
51 |
if (i.key().toAscii() == "syncmlfw")
|
|
52 |
{
|
|
53 |
|
|
54 |
notifiertolaunch = i.value().toInt();
|
|
55 |
// profileidenabled = true;
|
|
56 |
}
|
|
57 |
++i;
|
|
58 |
}
|
|
59 |
if(notifiertolaunch == 1000001 )// Connecting dialog
|
|
60 |
{
|
|
61 |
connectDialog = new syncmlConnectNotifier(ptr);
|
|
62 |
connectDialog->launchDialog(parameters);
|
|
63 |
notifier = NULL;
|
|
64 |
}
|
|
65 |
|
|
66 |
else
|
|
67 |
{
|
|
68 |
notifier = new syncmlnotifier(ptr);
|
|
69 |
notifier->launchDialog(parameters);
|
|
70 |
connectDialog = NULL;
|
|
71 |
}
|
|
72 |
}
|
|
73 |
devicemanagementnotifierutils::~devicemanagementnotifierutils()
|
|
74 |
{
|
|
75 |
qDebug("devicemanagementnotifierutils::~devicemanagementnotifierutils");
|
|
76 |
if(notifier)
|
|
77 |
delete notifier;
|
|
78 |
if(connectDialog)
|
|
79 |
delete connectDialog;
|
|
80 |
}
|
|
81 |
|
|
82 |
syncmlnotifier::syncmlnotifier(devicemanagementnotifierwidget* ptr)
|
|
83 |
{
|
|
84 |
iPtr = ptr;
|
|
85 |
qDebug("devicemanagementnotifierutils syncmlnotifier");
|
|
86 |
QTranslator *translator = new QTranslator();
|
|
87 |
QString lang = QLocale::system().name();
|
|
88 |
QString path = "Z:/resource/qt/translations/";
|
|
89 |
bool fine = translator->load("deviceupdates_en.qm", path);
|
|
90 |
if (fine)
|
|
91 |
qApp->installTranslator(translator);
|
|
92 |
|
|
93 |
QTranslator *commontranslator = new QTranslator();
|
|
94 |
|
|
95 |
fine = commontranslator->load("common_" + lang, path);
|
|
96 |
if (fine)
|
|
97 |
qApp->installTranslator(commontranslator);
|
|
98 |
|
|
99 |
msymnotifier = new syncmlnotifierprivate();
|
|
100 |
|
|
101 |
}
|
|
102 |
|
|
103 |
void syncmlnotifier::launchDialog(const QVariantMap ¶meters)
|
|
104 |
{
|
|
105 |
|
|
106 |
QVariantMap::const_iterator i = parameters.constBegin();
|
|
107 |
qDebug("devicemanagementnotifierutils syncmlnotifier launchDialog");
|
|
108 |
//i++;
|
|
109 |
|
|
110 |
bool profileidenabled = false;
|
|
111 |
bool uiserverinteraction = false;
|
|
112 |
bool serverpushinformativeenabled = false;
|
|
113 |
bool serverpushinteractiveenabled = false;
|
|
114 |
|
|
115 |
int profileid = 0;
|
|
116 |
int uimode = 0;
|
|
117 |
|
|
118 |
QString serverpushinformmessage;
|
|
119 |
QString serverpushconfirmmessage;
|
|
120 |
|
|
121 |
QString serverdispname;
|
|
122 |
|
|
123 |
while (i != parameters.constEnd())
|
|
124 |
{
|
|
125 |
if (i.key().toAscii() == "profileid")
|
|
126 |
{
|
|
127 |
|
|
128 |
profileid = i.value().toInt();
|
|
129 |
profileidenabled = true;
|
|
130 |
}
|
|
131 |
|
|
132 |
if (i.key().toAscii() == "uimode")
|
|
133 |
{
|
|
134 |
uiserverinteraction = true;
|
|
135 |
uimode = i.value().toInt();
|
|
136 |
}
|
|
137 |
|
|
138 |
if (i.key().toAscii() == "serverpushinformative")
|
|
139 |
{
|
|
140 |
qDebug("server push informative enabled");
|
|
141 |
serverpushinformativeenabled = true;
|
|
142 |
serverpushinformmessage = i.value().toString();
|
|
143 |
}
|
|
144 |
|
|
145 |
if (i.key().toAscii() == "serverpushconfirmative")
|
|
146 |
{
|
|
147 |
LOGSTRING("Server Push Confirmative");
|
|
148 |
serverpushinteractiveenabled = true;
|
|
149 |
serverpushconfirmmessage = i.value().toString();
|
|
150 |
}
|
|
151 |
|
|
152 |
if (i.key().toAscii() == "serverdisplayname")
|
|
153 |
{
|
|
154 |
serverdispname = i.value().toString();
|
|
155 |
}
|
|
156 |
|
|
157 |
++i;
|
|
158 |
}
|
|
159 |
|
|
160 |
if (profileidenabled && uiserverinteraction)
|
|
161 |
{
|
|
162 |
qDebug("server interaction packet 0 enabled ");
|
|
163 |
qDebug()<<EHbSOSNotifierKeyStatus;
|
|
164 |
msymnotifier->setnotifierorigin(EHbSOSNotifierKeyStatus);
|
|
165 |
createserverinitnotifier(profileid, uimode, serverdispname);
|
|
166 |
}
|
|
167 |
else if (serverpushinformativeenabled)
|
|
168 |
{
|
|
169 |
qDebug("server push informative enabled ");
|
|
170 |
qDebug()<<EHbDMSyncNotifierKeyStatus;
|
|
171 |
msymnotifier->setnotifierorigin(EHbDMSyncNotifierKeyStatus);
|
|
172 |
createserveralertinformative(serverpushinformmessage);
|
|
173 |
}
|
|
174 |
else if (serverpushinteractiveenabled)
|
|
175 |
{
|
|
176 |
qDebug("server push informative enabled ");
|
|
177 |
qDebug()<<EHbDMSyncNotifierKeyStatus;
|
|
178 |
msymnotifier->setnotifierorigin(EHbDMSyncNotifierKeyStatus);
|
|
179 |
createserveralertconfirmative(serverpushconfirmmessage);
|
|
180 |
}
|
|
181 |
|
|
182 |
}
|
|
183 |
|
|
184 |
void syncmlnotifier::createserverinitnotifier(int profileid, int uimode,
|
|
185 |
QString& servername)
|
|
186 |
{
|
|
187 |
|
|
188 |
int inittype = msymnotifier->serverinittype(uimode);
|
|
189 |
qDebug("Notification type");
|
|
190 |
qDebug()<<inittype;
|
|
191 |
|
|
192 |
LOGSTRING2("Init value = %d", inittype);
|
|
193 |
|
|
194 |
/*For testing purpose*/
|
|
195 |
//inittype = ESANUserInteractive;
|
|
196 |
|
|
197 |
if (inittype == ESANUserInteractive)
|
|
198 |
{
|
|
199 |
HbDocumentLoader loader;
|
|
200 |
bool ok = false;
|
|
201 |
loader.load(":/xml/resources/dialog.docml", &ok);
|
|
202 |
if (!ok)
|
|
203 |
{
|
|
204 |
return;
|
|
205 |
}
|
|
206 |
HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget(
|
|
207 |
"dialog"));
|
|
208 |
|
|
209 |
//set heading content
|
|
210 |
HbLabel *contentheading = qobject_cast<HbLabel *> (loader.findWidget(
|
|
211 |
"qtl_dialog_pri_heading"));
|
|
212 |
QString heading = hbTrId("txt_device_update_title_update_available");
|
|
213 |
contentheading->setPlainText(heading);
|
|
214 |
|
|
215 |
//set body content
|
|
216 |
HbLabel *contentbody = qobject_cast<HbLabel *> (loader.findWidget(
|
|
217 |
"qtl_dialog_pri5"));
|
|
218 |
QString serverinitmessage = hbTrId(
|
|
219 |
"txt_device_update_info_recommended_update_is_avail").arg(
|
|
220 |
servername);
|
|
221 |
contentbody->setPlainText(serverinitmessage);
|
|
222 |
|
|
223 |
//set softkeys
|
|
224 |
HbAction *primaryAction = (HbAction *) dialog->actions().first();
|
|
225 |
QString softkeyok = hbTrId("txt_common_button_ok");
|
|
226 |
primaryAction->setText(softkeyok);
|
|
227 |
|
|
228 |
HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
|
|
229 |
QString softkeyCancel = hbTrId("txt_common_button_cancel");
|
|
230 |
secondaryAction->setText(softkeyCancel);
|
|
231 |
|
|
232 |
//set dialog properties
|
|
233 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
234 |
|
|
235 |
//load appropriate icon from svg file
|
|
236 |
HbLabel* label1 = qobject_cast<HbLabel*> (loader.findWidget("icon"));
|
|
237 |
HbIcon* icon1 = new HbIcon(":/devman_icon/resources/iconnotifier.svg");
|
|
238 |
label1->setIcon(*icon1);
|
|
239 |
//label1->setMode(QIcon::Normal);
|
|
240 |
//label1->setState(QIcon::Off);
|
|
241 |
label1->setToolTip("Mode=Normal, State=Off");
|
|
242 |
|
|
243 |
QObject::connect(primaryAction, SIGNAL(triggered()), this,
|
|
244 |
SLOT(okSelected()));
|
|
245 |
|
|
246 |
QObject::connect(secondaryAction, SIGNAL(triggered()), this,
|
|
247 |
SLOT(cancelSelected()));
|
|
248 |
|
|
249 |
if (dialog)
|
|
250 |
dialog->show();
|
|
251 |
}
|
|
252 |
else if (inittype == ESANUserInformative)
|
|
253 |
{
|
|
254 |
HbDocumentLoader loader;
|
|
255 |
bool ok = false;
|
|
256 |
loader.load(":/xml/resources/dialoginformative.docml", &ok);
|
|
257 |
if (!ok)
|
|
258 |
{
|
|
259 |
return;
|
|
260 |
}
|
|
261 |
|
|
262 |
//hbTrId("qtl_dialog_pri_heading");
|
|
263 |
|
|
264 |
HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget(
|
|
265 |
"dialog"));
|
|
266 |
|
|
267 |
HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
|
|
268 |
"qtl_dialog_pri5"));
|
|
269 |
|
|
270 |
QString serverinitmessage = hbTrId(
|
|
271 |
"txt_device_update_info_update_serverpush_informative").arg(
|
|
272 |
servername);
|
|
273 |
|
|
274 |
//getserverspecifictexttodisplay(profileid, uimode, serverinitmessage);
|
|
275 |
content->setPlainText(serverinitmessage);
|
|
276 |
|
|
277 |
//get string here /*TODO*/ /*QTranslations*/
|
|
278 |
|
|
279 |
dialog->setTimeout(3000);
|
|
280 |
|
|
281 |
//msymnotifier->setstatus(0);
|
|
282 |
|
|
283 |
if (dialog)
|
|
284 |
dialog->show();
|
|
285 |
|
|
286 |
QObject::connect(dialog, SIGNAL(aboutToClose()), this,
|
|
287 |
SLOT(okSelected()));
|
|
288 |
|
|
289 |
}
|
|
290 |
else if (inittype == ESANSilent)
|
|
291 |
{
|
|
292 |
msymnotifier->setstatus(0);
|
|
293 |
}
|
|
294 |
|
|
295 |
}
|
|
296 |
|
|
297 |
void syncmlnotifier::createserveralertinformative(const QString &string)
|
|
298 |
{
|
|
299 |
qDebug("createserveralertinformative start");
|
|
300 |
LOGSTRING("createserveralertinformative start");
|
|
301 |
HbDocumentLoader loader;
|
|
302 |
bool ok = false;
|
|
303 |
loader.load(":/xml/resources/dialoginformative.docml", &ok);
|
|
304 |
if (!ok)
|
|
305 |
{
|
|
306 |
return;
|
|
307 |
}
|
|
308 |
HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
309 |
|
|
310 |
HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
|
|
311 |
"qtl_dialog_pri5"));
|
|
312 |
|
|
313 |
// No translations required
|
|
314 |
content->setPlainText(string);
|
|
315 |
|
|
316 |
dialog->setTimeout(3000);
|
|
317 |
|
|
318 |
if (dialog)
|
|
319 |
dialog->show();
|
|
320 |
|
|
321 |
QObject::connect(dialog, SIGNAL(aboutToClose()), this, SLOT(infoNoteOkSelected()));
|
|
322 |
|
|
323 |
qDebug("createserveralertinformative end");
|
|
324 |
|
|
325 |
}
|
|
326 |
|
|
327 |
void syncmlnotifier::createserveralertconfirmative(const QString &string)
|
|
328 |
{
|
|
329 |
HbDocumentLoader loader;
|
|
330 |
bool ok = false;
|
|
331 |
loader.load(":/xml/resources/dialogserverpushconfirm.docml", &ok);
|
|
332 |
if (!ok)
|
|
333 |
{
|
|
334 |
return;
|
|
335 |
}
|
|
336 |
HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
337 |
|
|
338 |
//set heading content
|
|
339 |
HbLabel *contentheading = qobject_cast<HbLabel *> (loader.findWidget(
|
|
340 |
"qtl_dialog_pri_heading"));
|
|
341 |
QString heading = hbTrId("txt_device_update_title_server_message");
|
|
342 |
contentheading->setPlainText(heading);
|
|
343 |
|
|
344 |
//set body content
|
|
345 |
HbLabel *contentbody = qobject_cast<HbLabel *> (loader.findWidget(
|
|
346 |
"qtl_dialog_pri5"));
|
|
347 |
|
|
348 |
contentbody->setPlainText(string);
|
|
349 |
|
|
350 |
//set softkeys
|
|
351 |
HbAction *primaryAction = (HbAction *) dialog->actions().first();
|
|
352 |
QString softkeyok = hbTrId("txt_common_button_yes");
|
|
353 |
primaryAction->setText(softkeyok);
|
|
354 |
|
|
355 |
HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
|
|
356 |
QString softkeyCancel = hbTrId("txt_common_button_no");
|
|
357 |
secondaryAction->setText(softkeyCancel);
|
|
358 |
|
|
359 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
360 |
|
|
361 |
QObject::connect(primaryAction, SIGNAL(triggered()), this,
|
|
362 |
SLOT(conirmNoteOkSelected()));
|
|
363 |
|
|
364 |
QObject::connect(secondaryAction, SIGNAL(triggered()), this,
|
|
365 |
SLOT(conirmNoteCancelSelected()));
|
|
366 |
|
|
367 |
if (dialog)
|
|
368 |
dialog->show();
|
|
369 |
}
|
|
370 |
|
|
371 |
void syncmlnotifier::okSelected()
|
|
372 |
{
|
|
373 |
qDebug("ok selected");
|
|
374 |
//msymnotifier->setstatus(0);
|
|
375 |
|
|
376 |
iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EServerAlertNote,0);
|
|
377 |
}
|
|
378 |
void syncmlnotifier::infoNoteOkSelected()
|
|
379 |
{
|
|
380 |
iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EInformativeNote,0);
|
|
381 |
}
|
|
382 |
|
|
383 |
void syncmlnotifier::conirmNoteOkSelected()
|
|
384 |
{
|
|
385 |
iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EConfirmativeNote,0);
|
|
386 |
}
|
|
387 |
void syncmlnotifier::conirmNoteCancelSelected()
|
|
388 |
{
|
|
389 |
iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EConfirmativeNote,-3);
|
|
390 |
}
|
|
391 |
|
|
392 |
void syncmlnotifier::cancelSelected()
|
|
393 |
{
|
|
394 |
qDebug("cancel selected");
|
|
395 |
//msymnotifier->setstatus(-3);
|
|
396 |
iPtr->dmDevdialogDismissed(devicemanagementnotifierwidget::EServerAlertNote,-3);
|
|
397 |
|
|
398 |
}
|
|
399 |
|
|
400 |
syncmlnotifier::~syncmlnotifier()
|
|
401 |
{
|
|
402 |
qDebug("syncmlnotifier::~syncmlnotifier");
|
|
403 |
qDebug("syncmlnotifier::~syncmlnotifier end");
|
|
404 |
}
|
|
405 |
|