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 // qt |
|
19 #include <QAction> |
|
20 #include <QTimer> |
|
21 #include <QtDebug> |
|
22 // hb |
|
23 #include <hbmessagebox.h> |
|
24 #include <hbprogressdialog.h> |
|
25 #include <hbdevicemessagebox.h> |
|
26 #include <hblabel.h> |
|
27 #include <hbaction.h> |
|
28 // satapp |
|
29 #include "satapppopupprovider.h" |
|
30 #include "satappconstant.h" |
|
31 #include "satappaction.h" |
|
32 |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // SatAppPopupProvider::SatAppPopupProvider |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 SatAppPopupProvider::SatAppPopupProvider( QObject *parent) |
|
39 : QObject(parent), mDisplayText(0), mWaitDialog(0), |
|
40 mWaitDeviceDialog(0), mAction(0) |
|
41 { |
|
42 qDebug("SATAPP: SatAppPopupProvider::SatAppPopupProvider"); |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // SatAppPopupProvider::~SatAppPopupProvider |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 SatAppPopupProvider::~SatAppPopupProvider() |
|
50 { |
|
51 qDebug("SATAPP: SatAppPopupProvider::~SatAppPopupProvider >"); |
|
52 |
|
53 if (mWaitDialog) { |
|
54 qDebug("SATAPP: SatAppPopupProvider::~SatAppPopupProvider wait note"); |
|
55 mWaitDialog->close(); |
|
56 delete mWaitDialog; |
|
57 mWaitDialog = NULL; |
|
58 } |
|
59 |
|
60 if (mWaitDeviceDialog) { |
|
61 qDebug("SATAPP: SatAppPopupProvider::~SatAppPopupProvider device note"); |
|
62 mWaitDeviceDialog->close(); |
|
63 delete mWaitDeviceDialog; |
|
64 mWaitDeviceDialog = NULL; |
|
65 } |
|
66 |
|
67 if (mDisplayText){ |
|
68 qDebug( "SatAppPopupProvider::~SatAppPopupProvider DisplayText" ); |
|
69 delete mDisplayText; |
|
70 mDisplayText = 0; |
|
71 } |
|
72 qDebug("SATAPP: SatAppPopupProvider::~SatAppPopupProvider <"); |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // SatAppPopupProvider::displayText |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 void SatAppPopupProvider::displayText(SatAppAction& action) |
|
80 { |
|
81 qDebug("SATAPP: SatAppPopupProvider::displayText >"); |
|
82 mAction = &action; |
|
83 delete mDisplayText; |
|
84 mDisplayText = 0; |
|
85 QString heading = action.value(KeyApplicationName).toString(); |
|
86 if (heading.isEmpty()) { |
|
87 heading = hbTrId("txt_simatk_dialog_sim_services"); |
|
88 } |
|
89 qDebug() << "SATAPP: displayText: heading=" << heading; |
|
90 |
|
91 // text |
|
92 QString text = action.value(KeyText).toString(); |
|
93 |
|
94 // some flags |
|
95 bool sustainedText = action.value(KeySustainedText).toBool(); |
|
96 bool waitUserToClear = action.value(KeyWaitUserToClear).toBool(); |
|
97 |
|
98 // duration |
|
99 int duration = action.value(KeyDuration).toInt(); |
|
100 if (duration==0) { |
|
101 duration = KDisplayTxtDefaultduration; |
|
102 if (waitUserToClear) { |
|
103 duration = KDisplayTxtUserClearTimeout; |
|
104 } |
|
105 } |
|
106 if ( !(!sustainedText || |
|
107 action.value(KeyDuration).toInt() || |
|
108 !waitUserToClear) ) { |
|
109 duration = 0; |
|
110 } |
|
111 qDebug("SATAPP: displayText: duration=%d",duration); |
|
112 |
|
113 // Show DisplayText dialog |
|
114 mDisplayText = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
115 |
|
116 // Set the label as heading widget |
|
117 HbLabel *label = new HbLabel(heading, mDisplayText); |
|
118 mDisplayText->setHeadingWidget(label); |
|
119 mDisplayText->setText(text); |
|
120 mDisplayText->setIconVisible(false); |
|
121 mDisplayText->setStandardButtons(HbMessageBox::Ok | HbMessageBox::Cancel); |
|
122 // ok pressed -> complete action with KSatSuccess |
|
123 SAT_ASSERT(connect(mDisplayText->actions().at(0), SIGNAL(triggered()), |
|
124 &action, SLOT(completeWithSuccess()))); |
|
125 // cancel pressed -> complete action with ESatBackwardModeRequestedByUser |
|
126 SAT_ASSERT(connect(mDisplayText->actions().at(1), SIGNAL(triggered()), |
|
127 &action, SLOT(completeWithBackRequested()))); |
|
128 SAT_ASSERT(connect(mAction, SIGNAL(actionCompleted(SatAppAction *)), |
|
129 this, SLOT(resetState()))); |
|
130 if (duration) { |
|
131 if (waitUserToClear && !sustainedText) { |
|
132 // in timeout, complete action with ESatNoResponseFromUser |
|
133 QTimer::singleShot(duration, |
|
134 &action, SLOT(completeWithNoResponse())); |
|
135 } else { |
|
136 QTimer::singleShot(duration, |
|
137 &action, SLOT(completeWithSuccess())); |
|
138 } |
|
139 mDisplayText->setTimeout(duration); |
|
140 } |
|
141 |
|
142 // open the popup. |
|
143 mDisplayText->open(); |
|
144 |
|
145 qDebug("SATAPP: SatAppPopupProvider::displayText <"); |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // SatAppPopupProvider::notification |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void SatAppPopupProvider::notification(SatAppAction& action) |
|
153 { |
|
154 qDebug("SATAPP: SatAppPopupProvider::notification >"); |
|
155 // some flags |
|
156 int commandId = action.value(KeyCommandId).toInt(); |
|
157 int alphaIdStatus = action.value(KeyAlphaIdStatus).toInt(); |
|
158 // reset mAction |
|
159 mAction = 0; |
|
160 qDebug("SATAPP: notification id=%d alphaSt=%d", |
|
161 commandId, alphaIdStatus); |
|
162 |
|
163 switch (commandId) |
|
164 { |
|
165 case ESatSSendDataNotify: |
|
166 case ESatSReceiveDataNotify: |
|
167 { |
|
168 qDebug("SATAPP: Notifying BIP Send/Receive"); |
|
169 // need to complete action with success when use don't prees cancel |
|
170 mAction = &action; |
|
171 showBIPWaitNote(action); |
|
172 break; |
|
173 } |
|
174 case ESatSCloseChannelNotify: |
|
175 { |
|
176 qDebug("SATAPP: Notifying BIP CloseChannel"); |
|
177 showCloseChannelWaitNote(action); |
|
178 break; |
|
179 } |
|
180 case ESatSMoSmControlNotify: |
|
181 { |
|
182 qDebug("SATAPP: Notifying MoSmControl"); |
|
183 if (ESatAlphaIdNotNull == alphaIdStatus) { |
|
184 showMoSmControlNote(action); |
|
185 } else { |
|
186 showSatInfoNote(action); |
|
187 } |
|
188 break; |
|
189 } |
|
190 case ESatSCallControlNotify: |
|
191 { |
|
192 qDebug("SATAPP: Notifying CallControl"); |
|
193 showCallControlNote(action); |
|
194 break; |
|
195 } |
|
196 case ESatSSendUssdNotify: // fall through |
|
197 case ESatSSendSsNotify: |
|
198 { |
|
199 qDebug("SATAPP: Notifying SendSs / SendUssd"); |
|
200 showSsWaitNote(action); |
|
201 break; |
|
202 } |
|
203 case ESatSSendDtmfNotify: |
|
204 { |
|
205 qDebug("SATAPP: Notifying SendDtmf"); |
|
206 // need to complete action with success when use don't prees cancel |
|
207 mAction = &action; |
|
208 showDtmfWaitNote(action); |
|
209 break; |
|
210 } |
|
211 case ESatSSendSmsNotify: |
|
212 { |
|
213 qDebug("SATAPP: Notifying SendSms"); |
|
214 showSmsWaitNote(action); |
|
215 break; |
|
216 } |
|
217 default: |
|
218 { |
|
219 qDebug("SATAPP: Unkown notification"); |
|
220 action.completeWithFailure(); |
|
221 break; |
|
222 } |
|
223 } |
|
224 qDebug("SATAPP: SatAppPopupProvider::notification <"); |
|
225 } |
|
226 |
|
227 // ---------------------------------------------------------------------------- |
|
228 // SatAppPopupProvider::stopShowWaitNote |
|
229 // ---------------------------------------------------------------------------- |
|
230 // |
|
231 void SatAppPopupProvider::stopShowWaitNote() |
|
232 { |
|
233 qDebug("SATAPP:SatAppPopupProvider::stopShowWaitNote: >mWaitDialog = %x", |
|
234 mWaitDialog ); |
|
235 if (mWaitDialog) { |
|
236 mWaitDialog->close(); |
|
237 delete mWaitDialog; |
|
238 mWaitDialog = NULL; |
|
239 if (mAction) { |
|
240 qDebug("SATAPP: stopShowWaitNote: mAction"); |
|
241 int commandId = mAction->value(KeyCommandId).toInt(); |
|
242 if (ESatSSendDataNotify == commandId |
|
243 || ESatSReceiveDataNotify == commandId |
|
244 || ESatSSendDtmfNotify == commandId) { |
|
245 mAction->completeWithSuccess(); |
|
246 } |
|
247 } |
|
248 } |
|
249 |
|
250 qDebug("SATAPP: stopShowWaitNote: mWaitDeviceDialog=%x", |
|
251 mWaitDeviceDialog); |
|
252 if (mWaitDeviceDialog) { |
|
253 mWaitDeviceDialog->close(); |
|
254 delete mWaitDeviceDialog; |
|
255 mWaitDeviceDialog = NULL; |
|
256 } |
|
257 |
|
258 qDebug("SATAPP:SatAppPopupProvider::stopShowWaitNote: <" ); |
|
259 } |
|
260 |
|
261 // ---------------------------------------------------------------------------- |
|
262 // SatAppPopupProvider::defaultAlphaId |
|
263 // provides a default text in case it is empty |
|
264 // ---------------------------------------------------------------------------- |
|
265 // |
|
266 QString SatAppPopupProvider::alphaId(SatAppAction& action) |
|
267 { |
|
268 QString alpha = action.value(KeyText).toString(); |
|
269 qDebug() << "SATAPP: SatAppPopupProvider::alphaId" << alpha; |
|
270 |
|
271 int commandId = action.value(KeyCommandId).toInt(); |
|
272 int controlResult = action.value(KeyControlResult).toInt(); |
|
273 |
|
274 if (!alpha.isEmpty()) { |
|
275 qDebug("SATAPP:SatAppPopupProvider::alphaId not empty<"); |
|
276 return alpha; |
|
277 } |
|
278 switch (commandId) |
|
279 { |
|
280 case ESatSSendDataNotify: // SendData |
|
281 { |
|
282 alpha = hbTrId("txt_simatk_dialog_sendingdata"); |
|
283 break; |
|
284 } |
|
285 case ESatSReceiveDataNotify: // ReceiveData |
|
286 { |
|
287 alpha = hbTrId("txt_simatk_dialog_receivingdata"); |
|
288 break; |
|
289 } |
|
290 case ESatSCloseChannelNotify: // CloseChannel |
|
291 { |
|
292 alpha = hbTrId("txt_simatk_dialog_connectionclosed"); |
|
293 break; |
|
294 } |
|
295 case ESatSMoSmControlNotify: // MoSmControl |
|
296 { |
|
297 if (ESatNotAllowed == controlResult) { |
|
298 alpha = hbTrId("txt_simatk_dpopinfo_request_not_allowed"); |
|
299 } else if (ESatAllowedWithModifications == controlResult) { |
|
300 alpha = hbTrId("txt_simatk_dpopinfo_request_modified"); |
|
301 } else { |
|
302 alpha = hbTrId(""); // Allowed, default alpha -> no info |
|
303 } |
|
304 break; |
|
305 } |
|
306 case ESatSCallControlNotify: // CallControl |
|
307 { |
|
308 if (ESatNotAllowed == controlResult) { |
|
309 alpha= hbTrId("txt_simatk_dpopinfo_request_not_allowed"); |
|
310 } else if (ESatAllowedWithModifications == controlResult) { |
|
311 alpha = hbTrId("txt_simatk_dpopinfo_request_modified"); |
|
312 } else { |
|
313 alpha = hbTrId(""); // Allowed, default alpha -> no info |
|
314 } |
|
315 break; |
|
316 } |
|
317 case ESatSSendSmsNotify: // fall through |
|
318 case ESatSSendDtmfNotify: // fall through |
|
319 case ESatSSendUssdNotify: // fall through |
|
320 case ESatSSendSsNotify: // fall through |
|
321 { |
|
322 // alpha id is empty, set a default string |
|
323 alpha = hbTrId("txt_common_info_processing"); |
|
324 break; |
|
325 } |
|
326 default: |
|
327 break; |
|
328 } |
|
329 qDebug("SATAPP:SatAppPopupProvider::alphaId <"); |
|
330 return alpha; |
|
331 } |
|
332 |
|
333 // ---------------------------------------------------------------------------- |
|
334 // SatAppPopupProvider::showBIPWaitNote |
|
335 // ---------------------------------------------------------------------------- |
|
336 // |
|
337 void SatAppPopupProvider::showBIPWaitNote(SatAppAction& action) |
|
338 { |
|
339 qDebug("SATAPP: SatAppPopupProvider::showBIPWaitNote >"); |
|
340 |
|
341 QString text = alphaId(action); |
|
342 // this is a new SEND DATA action |
|
343 delete mWaitDialog; |
|
344 mWaitDialog = 0; |
|
345 HbProgressDialog *pd = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
346 pd->setText(text); |
|
347 // cancel -> complete with ESatBackwardModeRequestedByUser |
|
348 SAT_ASSERT(connect(pd->actions().at(0),SIGNAL(triggered()), |
|
349 &action,SLOT(completeWithBackRequested()))); |
|
350 |
|
351 // open dialog |
|
352 pd->open(); |
|
353 mWaitDialog = pd; |
|
354 |
|
355 qDebug("SATAPP: SatAppPopupProvider::showBIPWaitNote <"); |
|
356 } |
|
357 |
|
358 // ---------------------------------------------------------------------------- |
|
359 // SatAppPopupProvider::showCloseChannelWaitNote |
|
360 // ---------------------------------------------------------------------------- |
|
361 // |
|
362 void SatAppPopupProvider::showCloseChannelWaitNote(SatAppAction& action) |
|
363 { |
|
364 qDebug("SATAPP: SatAppPopupProvider::showCloseChannelWaitNote >"); |
|
365 HbProgressDialog *pd = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
366 pd->clearActions(); |
|
367 pd->setText(alphaId(action)); |
|
368 pd->open(); |
|
369 mWaitDialog = pd; |
|
370 qDebug("SATAPP: SatAppPopupProvider::showCloseChannelWaitNote <"); |
|
371 } |
|
372 |
|
373 // ---------------------------------------------------------------------------- |
|
374 // SatAppPopupProvider::showMoSmControlNote |
|
375 // ---------------------------------------------------------------------------- |
|
376 // |
|
377 void SatAppPopupProvider::showMoSmControlNote(SatAppAction& action) |
|
378 { |
|
379 qDebug("SATAPP: SatAppPopupProvider::showMoSmControlNote >"); |
|
380 HbMessageBox *mb = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
381 mb->clearActions(); |
|
382 mb->setText(alphaId(action)); |
|
383 mb->open(); |
|
384 mWaitDialog = mb; |
|
385 qDebug("SATAPP: SatAppPopupProvider::showMoSmControlNote <"); |
|
386 } |
|
387 |
|
388 // ---------------------------------------------------------------------------- |
|
389 // SatAppPopupProvider::showSatInfoNote |
|
390 // |
|
391 // ---------------------------------------------------------------------------- |
|
392 // |
|
393 void SatAppPopupProvider::showSatInfoNote(SatAppAction& action) |
|
394 { |
|
395 qDebug("SATAPP: SatAppPopupProvider::showSatInfoNote >"); |
|
396 HbMessageBox *mb = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
397 mb->setText(alphaId(action)); |
|
398 mb->open(); |
|
399 mWaitDialog = mb; |
|
400 qDebug("SATAPP: SatAppPopupProvider::showSatInfoNote <"); |
|
401 } |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 // SatAppPopupProvider::showCallControlNote |
|
405 // ---------------------------------------------------------------------------- |
|
406 // |
|
407 void SatAppPopupProvider::showCallControlNote(SatAppAction& action) |
|
408 { |
|
409 qDebug("SATAPP: SatAppPopupProvider::showCallControlNote >"); |
|
410 HbDeviceMessageBox *dmb = new HbDeviceMessageBox(HbMessageBox::MessageTypeInformation); |
|
411 // No cancel key |
|
412 dmb->setText(alphaId(action)); |
|
413 dmb->show(); |
|
414 mWaitDeviceDialog = dmb; |
|
415 |
|
416 qDebug("SATAPP: SatAppPopupProvider::showCallControlNote <"); |
|
417 } |
|
418 |
|
419 // ---------------------------------------------------------------------------- |
|
420 // SatAppPopupProvider::showSsWaitNote |
|
421 // Displays a wait note to indicate SS sending. |
|
422 // ---------------------------------------------------------------------------- |
|
423 // |
|
424 void SatAppPopupProvider::showSsWaitNote(SatAppAction& action) |
|
425 { |
|
426 qDebug("SATAPP: SatAppPopupProvider::showSsWaitNote >"); |
|
427 HbProgressDialog *pd = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
428 pd->clearActions(); |
|
429 pd->setText(alphaId(action)); |
|
430 pd->show(); |
|
431 mWaitDialog = pd; |
|
432 qDebug("SATAPP: SatAppPopupProvider::showSsWaitNote <"); |
|
433 } |
|
434 |
|
435 // ---------------------------------------------------------------------------- |
|
436 // SatAppPopupProvider::showDtmfWaitNote |
|
437 // ---------------------------------------------------------------------------- |
|
438 // |
|
439 void SatAppPopupProvider::showDtmfWaitNote(SatAppAction& action) |
|
440 { |
|
441 qDebug("SATAPP: SatAppPopupProvider::showDtmfWaitNote >"); |
|
442 HbProgressDialog *pd = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
443 // cancel -> complete action with ESatBackwardModeRequestedByUser |
|
444 SAT_ASSERT(connect(pd->actions().at(0), SIGNAL(triggered()), |
|
445 &action, SLOT(completeWithBackRequested()))); |
|
446 pd->setText(alphaId(action)); |
|
447 pd->open(); |
|
448 mWaitDialog = pd; |
|
449 qDebug("SATAPP: SatAppPopupProvider::showDtmfWaitNote <"); |
|
450 } |
|
451 |
|
452 |
|
453 // ---------------------------------------------------------------------------- |
|
454 // SatAppPopupProvider::showDtmfWaitNote |
|
455 // ---------------------------------------------------------------------------- |
|
456 // |
|
457 void SatAppPopupProvider::showSmsWaitNote(SatAppAction& action) |
|
458 { |
|
459 qDebug("SATAPP: SatAppPopupProvider::showSmsWaitNote >"); |
|
460 HbProgressDialog *pd = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
461 //remove the default cancel softkey |
|
462 pd->clearActions(); |
|
463 pd->setText(alphaId(action)); |
|
464 pd->open(); |
|
465 mWaitDialog = pd; |
|
466 qDebug("SATAPP: SatAppPopupProvider::showSmsWaitNote <"); |
|
467 } |
|
468 |
|
469 // ---------------------------------------------------------------------------- |
|
470 // SatAppPopupProvider::stopShowWaitNote |
|
471 // ---------------------------------------------------------------------------- |
|
472 // |
|
473 void SatAppPopupProvider::showSsErrorNote() |
|
474 { |
|
475 qDebug("SATAPP: SatAppPopupProvider::showSsErrorNote >"); |
|
476 HbMessageBox *mb = new HbMessageBox(HbMessageBox::MessageTypeWarning); |
|
477 mb->setText(hbTrId("txt_sat_sendss_error_note")); |
|
478 mb->open(); |
|
479 mWaitDialog = mb; |
|
480 qDebug("SATAPP: SatAppPopupProvider::showSsErrorNote <"); |
|
481 } |
|
482 |
|
483 // ---------------------------------------------------------------------------- |
|
484 // SatAppPopupProvider::clearScreen |
|
485 // terminates all ongoing UI actions |
|
486 // ---------------------------------------------------------------------------- |
|
487 // |
|
488 void SatAppPopupProvider::clearScreen() |
|
489 { |
|
490 qDebug( "SATAPP: SatAppPopupProvider::clearScreen >" ); |
|
491 stopShowWaitNote(); |
|
492 if (mDisplayText){ |
|
493 qDebug( "SatAppPopupProvider::clearScreen DisplayText" ); |
|
494 delete mDisplayText; |
|
495 mDisplayText = 0; |
|
496 if (mAction) { |
|
497 qDebug( "SatAppPopupProvider::clearScreen mAction" ); |
|
498 SAT_ASSERT(disconnect(mAction, SIGNAL(actionCompleted(SatAppAction *)), |
|
499 this, SLOT(resetState()))); |
|
500 mAction->completeWithNoResponse(); |
|
501 mAction = 0; |
|
502 } |
|
503 qDebug( "SatAppPopupProvider::clearScreen DisplayText <" ); |
|
504 } |
|
505 qDebug( "SATAPP: SatAppToneProvider::clearScreen <" ); |
|
506 } |
|
507 |
|
508 // ---------------------------------------------------------------------------- |
|
509 // SatAppPopupProvider::resetState |
|
510 // reset |
|
511 // ---------------------------------------------------------------------------- |
|
512 // |
|
513 void SatAppPopupProvider::resetState() |
|
514 { |
|
515 qDebug( "SATAPP: SatAppPopupProvider::resetState >" ); |
|
516 mAction = 0; |
|
517 qDebug( "SATAPP: SatAppPopupProvider::resetState <" ); |
|
518 } |
|
519 |
|
520 //End of file |
|