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