1 /* |
|
2 * Copyright (c) 2009 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 <QEventLoop> |
|
19 #include <hbdataformmodel.h> |
|
20 #include <hbdataformmodelitem.h> |
|
21 #include <hblineedit.h> |
|
22 #include <hbinputeditorinterface.h> |
|
23 #include <hbcombobox.h> |
|
24 #include <hbdeviceprogressdialog.h> |
|
25 #include <sssettingswrapper.h> |
|
26 #include <psetwrapper.h> |
|
27 #include <hbaction.h> |
|
28 #include <hblistwidget.h> |
|
29 #include <hblistwidgetitem.h> |
|
30 #include <hblabel.h> |
|
31 #include <cpitemdatahelper.h> |
|
32 #include "cpdivertselectionitem.h" |
|
33 #include "cpdivertplugingroup.h" |
|
34 #include "cpplugincommon.h" |
|
35 #include "cpphonenotes.h" |
|
36 #include "cppluginlogging.h" |
|
37 #include "cpdivertitemdata.h" |
|
38 #include "cpdivertselectioncustomitem.h" |
|
39 |
|
40 Q_DECLARE_METATYPE(PsCallDivertingCondition) |
|
41 Q_DECLARE_METATYPE(PsServiceGroup) |
|
42 |
|
43 // CONSTANTS |
|
44 const QString KVoiceMail("voiceMail"); |
|
45 const QString KVideoMail("voiceMail"); |
|
46 const QString KOtherNumber("otherNumber"); |
|
47 |
|
48 /*! |
|
49 CpDivertPluginGroup::CpDivertPluginGroup. |
|
50 */ |
|
51 CpDivertPluginGroup::CpDivertPluginGroup(CpItemDataHelper &helper) |
|
52 : CpSettingFormItemData(HbDataFormModelItem::GroupItem, |
|
53 hbTrId("txt_phone_subhead_call_divert"),0), |
|
54 m_DataItemVoiceAllCalls(NULL), |
|
55 m_DataItemVoiceIfBusy(NULL), |
|
56 m_DataItemVoiceIfNotAnswered(NULL), |
|
57 m_DataItemVoiceIfOutOfReach(NULL), |
|
58 m_DataItemVoiceIfNotAvailable(NULL), |
|
59 m_DataItemVideoAllCalls(NULL), |
|
60 m_DataItemVideoIfBusy(NULL), |
|
61 m_DataItemVideoIfNotAnswered(NULL), |
|
62 m_DataItemVideoIfOutOfReach(NULL), |
|
63 m_DataItemVideoIfNotAvailable(NULL), |
|
64 m_activeNoteId(0), |
|
65 m_activeProgressNoteId(0), |
|
66 m_divertToVoiceMailBox(false), |
|
67 m_helper(helper), |
|
68 m_divertTimeout(0) |
|
69 { |
|
70 DPRINT << ": IN"; |
|
71 |
|
72 // Registration needed, because PsCallDivertingCondition and PsServiceGroup |
|
73 // is used as a custom meta information for barring items. |
|
74 qRegisterMetaType<PsCallDivertingCondition>( |
|
75 "PsCallDivertingCondition"); |
|
76 |
|
77 qRegisterMetaType<PsServiceGroup>( |
|
78 "PsServiceGroup"); |
|
79 |
|
80 m_pSetWrapper = new PSetWrapper; |
|
81 DPRINT << ": PSetWrapper created"; |
|
82 |
|
83 m_ssSettingsWrapper = new SsSettingsWrapper; |
|
84 DPRINT << ": SsSettingsWrapper created"; |
|
85 |
|
86 m_callDivertingWrapper = &m_pSetWrapper->callDivertingWrapper(); |
|
87 QObject::connect( |
|
88 m_callDivertingWrapper, |
|
89 SIGNAL(handleDivertingChanged(const PSCallDivertingCommand&,bool)), |
|
90 this, |
|
91 SLOT(handleDivertingChanged(const PSCallDivertingCommand&,bool))); |
|
92 QObject::connect( |
|
93 m_callDivertingWrapper, |
|
94 SIGNAL(handleDivertingStatus(QList<PSCallDivertingStatus*>&, bool)), |
|
95 this, |
|
96 SLOT(handleDivertingStatus(QList<PSCallDivertingStatus*>&, bool))); |
|
97 QObject::connect( |
|
98 m_callDivertingWrapper, |
|
99 SIGNAL(handleDivertingError(int)), |
|
100 this, |
|
101 SLOT(handleDivertingError(int))); |
|
102 |
|
103 QObject::connect( |
|
104 m_callDivertingWrapper, |
|
105 SIGNAL(requestDone()), |
|
106 this, |
|
107 SLOT(divertRequestProcessed())); |
|
108 |
|
109 // Create custom item prototype |
|
110 m_helper.addItemPrototype(new CpDivertSelectionItem()); |
|
111 |
|
112 // Listen form item visibility change |
|
113 m_helper.connectToForm( |
|
114 SIGNAL(itemShown(QModelIndex)), this, SLOT(itemShown(QModelIndex))); |
|
115 |
|
116 // Create grouped setting items |
|
117 createVoiceCallItems(this); |
|
118 createVideoCallItems(this); |
|
119 |
|
120 m_eventLoop = new QEventLoop(this); |
|
121 |
|
122 DPRINT << ": OUT"; |
|
123 } |
|
124 |
|
125 /*! |
|
126 CpDivertPluginGroup::~CpDivertPluginGroup. |
|
127 */ |
|
128 CpDivertPluginGroup::~CpDivertPluginGroup() |
|
129 { |
|
130 DPRINT << ": IN"; |
|
131 |
|
132 delete m_pSetWrapper; |
|
133 delete m_ssSettingsWrapper; |
|
134 |
|
135 DPRINT << ": OUT"; |
|
136 } |
|
137 |
|
138 /*! |
|
139 CpDivertPluginGroup::createVoiceCallItems. |
|
140 */ |
|
141 void CpDivertPluginGroup::createVoiceCallItems(CpSettingFormItemData *parent) |
|
142 { |
|
143 DPRINT << ": IN"; |
|
144 CpSettingFormItemData *page = new CpSettingFormItemData( |
|
145 HbDataFormModelItem::GroupPageItem, |
|
146 hbTrId("txt_phone_setlabel_service_val_voice_divert")); |
|
147 parent->appendChild(page); |
|
148 |
|
149 m_DataItemVoiceAllCalls = createDivertItem( |
|
150 DivertConditionUnconditional, |
|
151 ServiceGroupVoice, |
|
152 hbTrId("txt_phone_setlabel_all_calls"), |
|
153 hbTrId("txt_phone_setlabel_all_calls"), false, |
|
154 page); |
|
155 |
|
156 m_DataItemVoiceIfBusy = createDivertItem( |
|
157 DivertConditionBusy, |
|
158 ServiceGroupVoice, |
|
159 hbTrId("txt_phone_setlabel_if_busy"), |
|
160 hbTrId("txt_phone_setlabel_if_busy"), false, |
|
161 page); |
|
162 |
|
163 m_DataItemVoiceIfNotAnswered = createDivertItem( |
|
164 DivertConditionNoReply, |
|
165 ServiceGroupVoice, |
|
166 hbTrId("txt_phone_setlabel_if_not_answered"), |
|
167 hbTrId("txt_phone_setlabel_if_not_answered"), true, |
|
168 page); |
|
169 m_DataItemVoiceIfNotAnswered->setContentWidgetData( |
|
170 "timeoutText", hbTrId("txt_phone_setlabel_delay")); |
|
171 |
|
172 m_DataItemVoiceIfOutOfReach = createDivertItem( |
|
173 DivertConditionNotReachable, |
|
174 ServiceGroupVoice, |
|
175 hbTrId("txt_phone_setlabel_if_out_of_reach"), |
|
176 hbTrId("txt_phone_setlabel_if_out_of_reach"), false, |
|
177 page); |
|
178 |
|
179 m_DataItemVoiceIfNotAvailable = createDivertItem( |
|
180 DivertConditionAllConditionalCases, |
|
181 ServiceGroupVoice, |
|
182 hbTrId("txt_phone_setlabel_if_not_available"), |
|
183 hbTrId("txt_phone_setlabel_if_not_available"), true, |
|
184 page); |
|
185 |
|
186 DPRINT << ": OUT"; |
|
187 } |
|
188 |
|
189 /*! |
|
190 CpDivertPluginGroup::createVideoCallItems |
|
191 */ |
|
192 void CpDivertPluginGroup::createVideoCallItems(CpSettingFormItemData *parent) |
|
193 { |
|
194 DPRINT << ": IN"; |
|
195 CpSettingFormItemData *page = new CpSettingFormItemData( |
|
196 HbDataFormModelItem::GroupPageItem, |
|
197 hbTrId("txt_phone_setlabel_service_val_video_divert")); |
|
198 |
|
199 parent->appendChild(page); |
|
200 |
|
201 m_DataItemVideoAllCalls = createDivertItem( |
|
202 DivertConditionUnconditional, |
|
203 ServiceGroupData, |
|
204 hbTrId("txt_phone_setlabel_all_calls"), |
|
205 hbTrId("txt_phone_setlabel_all_calls"), false, |
|
206 page); |
|
207 |
|
208 m_DataItemVideoIfBusy = createDivertItem( |
|
209 DivertConditionBusy, |
|
210 ServiceGroupData, |
|
211 hbTrId("txt_phone_setlabel_if_busy"), |
|
212 hbTrId("txt_phone_setlabel_if_busy"), false, |
|
213 page); |
|
214 |
|
215 m_DataItemVideoIfNotAnswered = createDivertItem( |
|
216 DivertConditionNoReply, |
|
217 ServiceGroupData, |
|
218 hbTrId("txt_phone_setlabel_if_not_answered"), |
|
219 hbTrId("txt_phone_setlabel_if_not_answered"), true, |
|
220 page); |
|
221 m_DataItemVideoIfNotAnswered->setContentWidgetData( |
|
222 "timeoutText", hbTrId("txt_phone_setlabel_delay")); |
|
223 |
|
224 m_DataItemVideoIfOutOfReach = createDivertItem( |
|
225 DivertConditionNotReachable, |
|
226 ServiceGroupData, |
|
227 hbTrId("txt_phone_setlabel_if_out_of_reach"), |
|
228 hbTrId("txt_phone_setlabel_if_out_of_reach"), false, |
|
229 page); |
|
230 |
|
231 m_DataItemVideoIfNotAvailable = createDivertItem( |
|
232 DivertConditionAllConditionalCases, |
|
233 ServiceGroupData, |
|
234 hbTrId("txt_phone_setlabel_if_not_available"), |
|
235 hbTrId("txt_phone_setlabel_if_not_available"), true, |
|
236 page); |
|
237 |
|
238 DPRINT << ": OUT"; |
|
239 } |
|
240 |
|
241 /*! |
|
242 CpDivertPluginGroup::createDivertItem |
|
243 */ |
|
244 CpDivertItemData *CpDivertPluginGroup::createDivertItem( |
|
245 PsCallDivertingCondition condition, |
|
246 PsServiceGroup serviceGroup, |
|
247 const QString &label, |
|
248 const QString &queryLabel, |
|
249 bool needTimeoutInfo, |
|
250 CpSettingFormItemData *parent) |
|
251 { |
|
252 DPRINT << ": IN"; |
|
253 |
|
254 CpDivertItemData *item = new CpDivertItemData( |
|
255 static_cast<HbDataFormModelItem::DataItemType> |
|
256 (CpDivertSelectionItem::CpDivertSelectionItemId), |
|
257 label, |
|
258 m_helper, |
|
259 parent); |
|
260 QVariant conditionVar; |
|
261 conditionVar.setValue(condition); |
|
262 item->setProperty("condition", conditionVar); |
|
263 QVariant serviceGroupVar; |
|
264 serviceGroupVar.setValue(serviceGroup); |
|
265 item->setProperty("serviceGroup", serviceGroupVar); |
|
266 item->setProperty("queryLabel", queryLabel); |
|
267 item->setProperty("needTimeoutInfo", needTimeoutInfo); |
|
268 item->setEnabled(false); |
|
269 |
|
270 // Connect signals |
|
271 QObject::connect( |
|
272 item, SIGNAL(itemClicked(CpDivertItemData&)), |
|
273 this, SLOT(changeDivertingStateRequested(CpDivertItemData&))); |
|
274 |
|
275 parent->appendChild(item); |
|
276 DPRINT << ": OUT"; |
|
277 return item; |
|
278 } |
|
279 |
|
280 /*! |
|
281 CpDivertPluginGroup::itemShown. |
|
282 */ |
|
283 void CpDivertPluginGroup::itemShown(const QModelIndex& item) |
|
284 { |
|
285 DPRINT << ": IN"; |
|
286 DPRINT << "item:" << item; |
|
287 |
|
288 HbDataFormModelItem* modelItem = |
|
289 qobject_cast<const HbDataFormModel*>(item.model())->itemFromIndex(item); |
|
290 |
|
291 if (!modelItem->contentWidgetData("number").isValid() && |
|
292 (static_cast<HbDataFormModelItem::DataItemType> |
|
293 (CpDivertSelectionItem::CpDivertSelectionItemId == modelItem->type()))){ |
|
294 CpDivertItemData *item = static_cast<CpDivertItemData*>(modelItem); |
|
295 if(qvariant_cast<PsCallDivertingCondition>(item->property("condition")) != |
|
296 DivertConditionAllConditionalCases) { |
|
297 addToDivertingRequestQueue(CheckDivertStatus, *item); |
|
298 } |
|
299 } |
|
300 |
|
301 DPRINT << ": OUT"; |
|
302 } |
|
303 |
|
304 /*! |
|
305 CpDivertPluginGroup::addToDivertingRequestQueue. |
|
306 */ |
|
307 void CpDivertPluginGroup::addToDivertingRequestQueue( |
|
308 DivertRequest request, CpDivertItemData &item) |
|
309 { |
|
310 DPRINT << ": IN"; |
|
311 CpDivertRequestQueueItem i; |
|
312 i.request = request; |
|
313 i.item = &item; |
|
314 m_divertRequestQueue.enqueue(i); |
|
315 |
|
316 if (m_divertRequestQueue.count()==1) { |
|
317 // Process if first item was added, process other later |
|
318 try { |
|
319 processDivertingRequestQueue(); |
|
320 } catch(...) { |
|
321 DPRINT << "error!!"; |
|
322 } |
|
323 } |
|
324 |
|
325 |
|
326 DPRINT << ": OUT"; |
|
327 } |
|
328 |
|
329 /*! |
|
330 CpDivertPluginGroup::divertRequestProcessed. |
|
331 */ |
|
332 void CpDivertPluginGroup::divertRequestProcessed() |
|
333 { |
|
334 DPRINT << ": IN"; |
|
335 // Remove previous request and process next one |
|
336 if (!m_divertRequestQueue.isEmpty()) { |
|
337 m_divertRequestQueue.dequeue(); |
|
338 processDivertingRequestQueue(); |
|
339 } |
|
340 |
|
341 if (m_divertRequestQueue.isEmpty()) { |
|
342 // Queue empty so cancel process note |
|
343 CpPhoneNotes::instance()->cancelNote(m_activeProgressNoteId); |
|
344 } |
|
345 |
|
346 DPRINT << ": OUT"; |
|
347 } |
|
348 |
|
349 /*! |
|
350 CpDivertPluginGroup::changeItemData. |
|
351 */ |
|
352 void CpDivertPluginGroup::changeItemData( |
|
353 PsServiceGroup serviceGroup, |
|
354 PsCallDivertingCondition condition, |
|
355 PsCallDivertingStatus status, |
|
356 const QString& number, int timeout) |
|
357 { |
|
358 DPRINT << ": IN"; |
|
359 |
|
360 CpDivertSelectionCustomitem::State itemState = |
|
361 CpDivertSelectionCustomitem::Disabled; |
|
362 if (status == DivertingStatusActive) { |
|
363 itemState = CpDivertSelectionCustomitem::Enabled; |
|
364 } else if (status == DivertingStatusInactive) { |
|
365 itemState = CpDivertSelectionCustomitem::Deactivated; |
|
366 } else { |
|
367 itemState = CpDivertSelectionCustomitem::Disabled; |
|
368 } |
|
369 |
|
370 switch (condition) { |
|
371 case DivertConditionAllConditionalCases: |
|
372 DPRINT << ": DivertConditionAllConditionalCases"; |
|
373 |
|
374 // If not available effects also conditions below |
|
375 changeItemData(serviceGroup, DivertConditionBusy, status, number, timeout); |
|
376 changeItemData(serviceGroup, DivertConditionNoReply, status, number, timeout); |
|
377 changeItemData(serviceGroup, DivertConditionNotReachable, status, number, timeout); |
|
378 // Fall trough |
|
379 case DivertConditionUnconditional: |
|
380 case DivertConditionBusy: |
|
381 case DivertConditionNoReply: |
|
382 case DivertConditionNotReachable: |
|
383 if (serviceGroup & ServiceGroupVoice) { |
|
384 item(ServiceGroupVoice, condition)->setContentWidgetData("number", number); |
|
385 item(ServiceGroupVoice, condition)->setContentWidgetData("timeout", timeout); |
|
386 item(ServiceGroupVoice, condition)->setContentWidgetData("state", itemState); |
|
387 item(ServiceGroupVoice, condition)->setEnabled(true); |
|
388 } |
|
389 |
|
390 if (serviceGroup & ServiceGroupData) { |
|
391 item(ServiceGroupData, condition)->setContentWidgetData("number", number); |
|
392 item(ServiceGroupData, condition)->setContentWidgetData("timeout", timeout); |
|
393 item(ServiceGroupData, condition)->setContentWidgetData("state", itemState); |
|
394 item(ServiceGroupData, condition)->setEnabled(true); |
|
395 } |
|
396 break; |
|
397 case DivertConditionAllCalls: |
|
398 case DivertConditionUnknown: |
|
399 default: |
|
400 break; |
|
401 } |
|
402 } |
|
403 |
|
404 /*! |
|
405 CpDivertPluginGroup::revertItemData. |
|
406 */ |
|
407 void CpDivertPluginGroup::revertItemData( |
|
408 PsServiceGroup serviceGroup, PsCallDivertingCondition condition) |
|
409 { |
|
410 DPRINT << ": IN"; |
|
411 if (serviceGroup & ServiceGroupVoice) { |
|
412 item(ServiceGroupVoice, condition)->setContentWidgetData("state", |
|
413 item(ServiceGroupVoice, condition)->contentWidgetData("state")); |
|
414 } |
|
415 |
|
416 if (serviceGroup & ServiceGroupData) { |
|
417 item(ServiceGroupData, condition)->setContentWidgetData("state", |
|
418 item(ServiceGroupData, condition)->contentWidgetData("state")); |
|
419 } |
|
420 |
|
421 DPRINT << ": OUT"; |
|
422 } |
|
423 |
|
424 /*! |
|
425 CpDivertPluginGroup::item. |
|
426 */ |
|
427 CpSettingFormItemData* CpDivertPluginGroup::item( |
|
428 PsService service, PsCallDivertingCondition condition) |
|
429 { |
|
430 CpSettingFormItemData *ret = 0; |
|
431 switch (condition) { |
|
432 case DivertConditionUnconditional: |
|
433 if (service == ServiceGroupVoice) { |
|
434 ret = m_DataItemVoiceAllCalls; |
|
435 } else { |
|
436 ret = m_DataItemVideoAllCalls; |
|
437 } |
|
438 break; |
|
439 case DivertConditionBusy: |
|
440 if (service == ServiceGroupVoice) { |
|
441 ret = m_DataItemVoiceIfBusy; |
|
442 } else { |
|
443 ret = m_DataItemVideoIfBusy; |
|
444 } |
|
445 break; |
|
446 case DivertConditionNoReply: |
|
447 if (service == ServiceGroupVoice) { |
|
448 ret = m_DataItemVoiceIfNotAnswered; |
|
449 } else { |
|
450 ret = m_DataItemVideoIfNotAnswered; |
|
451 } |
|
452 break; |
|
453 case DivertConditionNotReachable: |
|
454 if (service == ServiceGroupVoice) { |
|
455 ret = m_DataItemVoiceIfOutOfReach; |
|
456 } else { |
|
457 ret = m_DataItemVideoIfOutOfReach; |
|
458 } |
|
459 break; |
|
460 case DivertConditionAllConditionalCases: |
|
461 if (service == ServiceGroupVoice) { |
|
462 ret = m_DataItemVoiceIfNotAvailable; |
|
463 } else { |
|
464 ret = m_DataItemVideoIfNotAvailable; |
|
465 } |
|
466 break; |
|
467 case DivertConditionAllCalls: |
|
468 case DivertConditionUnknown: |
|
469 default: |
|
470 break; |
|
471 } |
|
472 Q_CHECK_PTR(ret); |
|
473 return ret; |
|
474 } |
|
475 |
|
476 /*! |
|
477 CpDivertPluginGroup::processDivertingRequestQueue. |
|
478 */ |
|
479 void CpDivertPluginGroup::processDivertingRequestQueue() |
|
480 { |
|
481 DPRINT << ": IN"; |
|
482 if (m_divertRequestQueue.isEmpty()) { |
|
483 DPRINT << "queue empty : OUT"; |
|
484 return; |
|
485 } |
|
486 CpDivertRequestQueueItem request = m_divertRequestQueue.head(); |
|
487 // Command param |
|
488 PSCallDivertingCommand divertCommand; |
|
489 divertCommand.iServiceGroup = qvariant_cast<PsServiceGroup>( |
|
490 request.item->property("serviceGroup")); |
|
491 divertCommand.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
492 request.item->property("condition")); |
|
493 divertCommand.iStatus = DivertingStatusUnknown; |
|
494 divertCommand.iNumber = ""; |
|
495 divertCommand.iNoReplyTimer = 0; |
|
496 |
|
497 switch (request.request) { |
|
498 case ActivateDivert: { |
|
499 DPRINT << "activate"; |
|
500 divertCommand.iSetting = RegisterDiverting; |
|
501 if (popUpVoiceNumberListQuery( |
|
502 request.item->property("queryLabel").toString(), |
|
503 divertCommand.iNumber, |
|
504 divertCommand.iServiceGroup)) { |
|
505 if (request.item->property("needTimeoutInfo").toBool()) { |
|
506 if (popUpTimerQuery(divertCommand.iNoReplyTimer)) { |
|
507 setCallDiverting(divertCommand); |
|
508 } else { |
|
509 // Query was cancelled |
|
510 revertItemData( |
|
511 divertCommand.iServiceGroup, |
|
512 divertCommand.iCondition); |
|
513 m_divertRequestQueue.clear(); |
|
514 } |
|
515 } else { |
|
516 setCallDiverting(divertCommand); |
|
517 } |
|
518 } else { |
|
519 // Query was cancelled |
|
520 revertItemData( |
|
521 divertCommand.iServiceGroup, |
|
522 divertCommand.iCondition); |
|
523 m_divertRequestQueue.clear(); |
|
524 } |
|
525 } |
|
526 break; |
|
527 case DeactivateDivert: { |
|
528 DPRINT << "deactivate"; |
|
529 divertCommand.iSetting = EraseDiverting; |
|
530 setCallDiverting(divertCommand); |
|
531 } |
|
532 break; |
|
533 case CheckDivertStatus: { |
|
534 DPRINT << "check status"; |
|
535 m_callDivertingWrapper->getCallDivertingStatus( |
|
536 divertCommand.iServiceGroup, |
|
537 divertCommand.iCondition, |
|
538 bscParam(divertCommand.iServiceGroup) ); |
|
539 |
|
540 if (!CpPhoneNotes::instance()->noteShowing()) { |
|
541 CpPhoneNotes::instance()->showGlobalProgressNote( |
|
542 m_activeProgressNoteId, hbTrId("txt_phone_info_requesting")); |
|
543 } |
|
544 } |
|
545 break; |
|
546 default: |
|
547 DPRINT << "Error: unknown enum value"; |
|
548 break; |
|
549 } |
|
550 |
|
551 DPRINT << ": OUT"; |
|
552 } |
|
553 |
|
554 /*! |
|
555 CpDivertPluginGroup::changeDivertingStateRequested. |
|
556 */ |
|
557 void CpDivertPluginGroup::changeDivertingStateRequested( |
|
558 CpDivertItemData &item) |
|
559 { |
|
560 DPRINT << ": IN"; |
|
561 |
|
562 DivertRequest event=ActivateDivert; |
|
563 if (CpDivertSelectionCustomitem::Enabled == |
|
564 item.contentWidgetData("state").toInt()) { |
|
565 event = DeactivateDivert; |
|
566 } else { |
|
567 event = ActivateDivert; |
|
568 } |
|
569 |
|
570 addToDivertingRequestQueue(event, item); |
|
571 DPRINT << ": OUT"; |
|
572 } |
|
573 |
|
574 /*! |
|
575 CpDivertPluginGroup::handleDivertingChanged. |
|
576 */ |
|
577 void CpDivertPluginGroup::handleDivertingChanged( |
|
578 const PSCallDivertingCommand& aSetting, |
|
579 bool aPlural) |
|
580 { |
|
581 DPRINT << ": IN"; |
|
582 |
|
583 CpPhoneNotes::instance()->cancelNote(m_activeNoteId); |
|
584 DPRINT << "aPlural:" << aPlural; |
|
585 DPRINT << "iCondition:" << aSetting.iCondition; |
|
586 DPRINT << "iNoReplyTimer:" << aSetting.iNoReplyTimer; |
|
587 DPRINT << "iNumber:" << aSetting.iNumber; |
|
588 DPRINT << "iServiceGroup:" << aSetting.iServiceGroup; |
|
589 DPRINT << "iSetting:" << aSetting.iSetting; |
|
590 DPRINT << "iStatus:" << aSetting.iStatus; |
|
591 |
|
592 changeItemData( |
|
593 aSetting.iServiceGroup, |
|
594 aSetting.iCondition, aSetting.iStatus, |
|
595 aSetting.iNumber, aSetting.iNoReplyTimer); |
|
596 |
|
597 updateDependentDivertOptions( |
|
598 (DivertConditionUnconditional == aSetting.iCondition) && |
|
599 (DivertingStatusActive != aSetting.iStatus) ); |
|
600 |
|
601 switch(aSetting.iStatus) { |
|
602 case DivertingStatusActive: |
|
603 if (aPlural) { |
|
604 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
605 hbTrId("txt_phone_info_diverts_activated"), |
|
606 HbMessageBox::MessageTypeInformation); |
|
607 } else { |
|
608 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
609 hbTrId("txt_phone_info_divert_activated"), |
|
610 HbMessageBox::MessageTypeInformation); |
|
611 } |
|
612 if (!m_divertToVoiceMailBox) { |
|
613 // Number, except vmbx number, will be added to defaultnumber list |
|
614 m_callDivertingWrapper->setNewDefaultNumber(aSetting.iNumber); |
|
615 } |
|
616 // Diverting calls does not affect Internet calls |
|
617 if (Tools::voipSupported() && |
|
618 (aSetting.iServiceGroup & ServiceGroupVoice)) { |
|
619 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
620 hbTrId("Diverting calls does not affect Internet calls"), |
|
621 HbMessageBox::MessageTypeInformation); |
|
622 } |
|
623 break; |
|
624 case DivertingStatusNotRegistered: |
|
625 case DivertingStatusInactive: |
|
626 if (aPlural) { |
|
627 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
628 hbTrId("txt_phone_info_diverts_deactivated"), |
|
629 HbMessageBox::MessageTypeInformation); |
|
630 } else { |
|
631 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
632 hbTrId("txt_phone_info_divert_deactivated"), |
|
633 HbMessageBox::MessageTypeInformation); |
|
634 } |
|
635 break; |
|
636 case DivertingStatusNotProvisioned: |
|
637 case DivertingStatusUnknown: |
|
638 default: |
|
639 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
640 hbTrId("txt_phone_info_request_not_completed"), |
|
641 HbMessageBox::MessageTypeInformation); |
|
642 } |
|
643 |
|
644 DPRINT << ": OUT"; |
|
645 } |
|
646 |
|
647 /*! |
|
648 CpDivertPluginGroup::handleDivertingStatus. |
|
649 */ |
|
650 void CpDivertPluginGroup::handleDivertingStatus( |
|
651 QList<PSCallDivertingStatus*> &divertList, |
|
652 bool plural) |
|
653 { |
|
654 DPRINT << ": IN"; |
|
655 DPRINT << "divertList.Size():" << divertList.size(); |
|
656 DPRINT << "plural:" << plural; |
|
657 |
|
658 foreach(PSCallDivertingStatus* status, divertList) { |
|
659 DPRINT << status->iCondition; |
|
660 DPRINT << status->iNumber; |
|
661 DPRINT << status->iServiceGroup; |
|
662 DPRINT << status->iStatus; |
|
663 DPRINT << status->iTimeout; |
|
664 changeItemData( |
|
665 status->iServiceGroup, |
|
666 status->iCondition, status->iStatus, |
|
667 status->iNumber, status->iTimeout); |
|
668 |
|
669 } |
|
670 |
|
671 updateDependentDivertOptions(); |
|
672 |
|
673 DPRINT << ": OUT"; |
|
674 } |
|
675 |
|
676 /*! |
|
677 CpDivertPluginGroup::handleDivertingError. |
|
678 */ |
|
679 void CpDivertPluginGroup::handleDivertingError(int aReason) |
|
680 { |
|
681 DPRINT << ": IN : aReason:" << aReason; |
|
682 |
|
683 // Update view item for failed request |
|
684 if (m_divertRequestQueue.count()) { |
|
685 revertItemData( |
|
686 qvariant_cast<PsServiceGroup>( |
|
687 m_divertRequestQueue.head().item->property("serviceGroup")), |
|
688 qvariant_cast<PsCallDivertingCondition>( |
|
689 m_divertRequestQueue.head().item->property("condition"))); |
|
690 } |
|
691 |
|
692 // Clear queue |
|
693 m_divertRequestQueue.clear(); |
|
694 |
|
695 // Cancel previous note |
|
696 CpPhoneNotes::instance()->cancelNote(m_activeNoteId); |
|
697 |
|
698 // Show error note |
|
699 CpPhoneNotes::instance()->showGlobalErrorNote(m_activeNoteId, aReason); |
|
700 |
|
701 DPRINT << ": OUT"; |
|
702 } |
|
703 |
|
704 /*! |
|
705 CpDivertPluginGroup::popUpVoiceNumberListQuery. |
|
706 */ |
|
707 bool CpDivertPluginGroup::popUpVoiceNumberListQuery( |
|
708 const QString& heading, QString& result, PsServiceGroup serviceGroup) |
|
709 { |
|
710 DPRINT << ": IN"; |
|
711 |
|
712 bool requestOK(false); |
|
713 |
|
714 if (!m_eventLoop->isRunning()){ |
|
715 m_divertNumber = ""; |
|
716 m_divertToVoiceMailBox = false; |
|
717 QStringList defNumbers; |
|
718 HbDialog *dialog = createDialog(heading); |
|
719 m_voiceNumberList = new HbListWidget(dialog); |
|
720 if (serviceGroup == ServiceGroupVoice) { |
|
721 addItemToListWidget( |
|
722 m_voiceNumberList, hbTrId("txt_phone_setlabel_voice_mbx"), KVoiceMail ); |
|
723 } else if(serviceGroup == ServiceGroupData) { |
|
724 // TODO: Implement video voicemail |
|
725 } |
|
726 |
|
727 // Add "old" divert number to list |
|
728 m_callDivertingWrapper->getDefaultNumbers(defNumbers); |
|
729 int count(defNumbers.count()); |
|
730 for (int i = 0; i < count; i++) { |
|
731 addItemToListWidget(m_voiceNumberList, defNumbers[i], defNumbers[i]); |
|
732 } |
|
733 addItemToListWidget(m_voiceNumberList, hbTrId("txt_phone_list_enter_number_manually"), KOtherNumber ); |
|
734 dialog->setContentWidget(m_voiceNumberList); |
|
735 |
|
736 // Connect list item activation signal to close the popup |
|
737 QObject::connect(m_voiceNumberList, |
|
738 SIGNAL(activated(HbListWidgetItem*)), |
|
739 dialog, |
|
740 SLOT(close()), |
|
741 Qt::UniqueConnection); |
|
742 |
|
743 // Sets the "Cancel"-action/button |
|
744 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
745 dialog->addAction(cancelAction); |
|
746 QObject::connect(cancelAction, |
|
747 SIGNAL(triggered(bool)), |
|
748 dialog, |
|
749 SLOT(close())); |
|
750 |
|
751 dialog->open(this, SLOT(voiceNumberListQueryClosed(HbAction *))); |
|
752 |
|
753 QPointer<QObject> guard = this; |
|
754 m_eventLoop->exec(); |
|
755 if (guard.isNull()) { |
|
756 requestOK = false; |
|
757 } else if (!m_divertNumber.isEmpty()) { |
|
758 result = m_divertNumber; |
|
759 requestOK = true; |
|
760 } |
|
761 } |
|
762 |
|
763 DPRINT << ": OUT : result:" << result; |
|
764 DPRINT << ": OUT : requestOK :" << requestOK; |
|
765 return requestOK; |
|
766 } |
|
767 |
|
768 /*! |
|
769 CpDivertPluginGroup::voiceNumberListQueryClosed() |
|
770 */ |
|
771 void CpDivertPluginGroup::voiceNumberListQueryClosed(HbAction* action) |
|
772 { |
|
773 DPRINT << ": IN"; |
|
774 |
|
775 bool exitLoop(true); |
|
776 |
|
777 // Enter if cancel wasn't selected |
|
778 if (!action) { |
|
779 // Update the view with selected text |
|
780 QString data = m_voiceNumberList->currentItem()->data().toString(); |
|
781 DPRINT << ": data: " << data; |
|
782 |
|
783 if (data == KVoiceMail) { |
|
784 m_callDivertingWrapper->getVoiceMailBoxNumber(m_divertNumber); |
|
785 if (!m_divertNumber.isEmpty()) { |
|
786 DPRINT << ": voicemailboxnumber found"; |
|
787 } |
|
788 |
|
789 m_eventLoop->quit(); |
|
790 |
|
791 } else if (data == KOtherNumber) { |
|
792 // Event loop is terminated by popUpNumberEditorClosed |
|
793 exitLoop = false; |
|
794 |
|
795 DPRINT << ": open popUpNumberEditor"; |
|
796 popUpNumberEditor(hbTrId("txt_phone_info_number"), m_divertNumber); |
|
797 } else { |
|
798 //TODO if matched contact name not work |
|
799 DPRINT << ": else"; |
|
800 m_divertNumber = data; |
|
801 } |
|
802 |
|
803 } |
|
804 |
|
805 if (exitLoop) { |
|
806 DPRINT << ": quit eventloop"; |
|
807 m_eventLoop->quit(); |
|
808 } |
|
809 |
|
810 DPRINT << ": OUT"; |
|
811 } |
|
812 |
|
813 /*! |
|
814 CpDivertPluginGroup::popUpNumberEditor. |
|
815 */ |
|
816 void CpDivertPluginGroup::popUpNumberEditor( |
|
817 const QString& heading, QString& result) |
|
818 { |
|
819 DPRINT << ": IN"; |
|
820 |
|
821 Q_UNUSED(result); |
|
822 |
|
823 HbDialog *dialog = createDialog(heading); |
|
824 |
|
825 m_voiceNumberEditor = new HbLineEdit(dialog); |
|
826 m_voiceNumberEditor->setInputMethodHints(Qt::ImhDialableCharactersOnly); |
|
827 dialog->setContentWidget(m_voiceNumberEditor); |
|
828 |
|
829 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
|
830 dialog->addAction(okAction); |
|
831 |
|
832 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
833 dialog->addAction(cancelAction); |
|
834 |
|
835 dialog->open(this, SLOT(popUpNumberEditorClosed(HbAction*))); |
|
836 |
|
837 DPRINT << ": OUT"; |
|
838 } |
|
839 |
|
840 /*! |
|
841 CpDivertPluginGroup::popUpNumberEditorClosed. |
|
842 */ |
|
843 void CpDivertPluginGroup::popUpNumberEditorClosed(HbAction* action) |
|
844 { |
|
845 DPRINT << ": IN"; |
|
846 |
|
847 bool cancelled(true); |
|
848 if (action) { |
|
849 if (action->text() == hbTrId("txt_common_button_ok")) |
|
850 { |
|
851 cancelled = false; |
|
852 DPRINT << ": ok selected"; |
|
853 } |
|
854 } |
|
855 |
|
856 if (!cancelled) { |
|
857 m_divertNumber = m_voiceNumberEditor->text(); |
|
858 DPRINT << ": m_divertNumber " |
|
859 << m_divertNumber; |
|
860 if (m_divertNumber.isEmpty()) { |
|
861 CpPhoneNotes::instance()->showGlobalNote(m_activeNoteId, |
|
862 hbTrId("txt_phone_info_invalid_phone_number"), HbMessageBox::MessageTypeWarning); |
|
863 } |
|
864 } |
|
865 |
|
866 if (m_voiceNumberEditor) { |
|
867 delete m_voiceNumberEditor; |
|
868 m_voiceNumberEditor = NULL; |
|
869 } |
|
870 |
|
871 m_eventLoop->quit(); |
|
872 DPRINT << ": OUT"; |
|
873 } |
|
874 |
|
875 /*! |
|
876 CpDivertPluginGroup::setCallDiverting. |
|
877 */ |
|
878 void CpDivertPluginGroup::setCallDiverting(PSCallDivertingCommand& command) |
|
879 { |
|
880 DPRINT << ": IN"; |
|
881 DPRINT << "iCondition:" << command.iCondition; |
|
882 DPRINT << "iNoReplyTimer:" << command.iNoReplyTimer; |
|
883 DPRINT << "iNumber:" << command.iNumber; |
|
884 DPRINT << "iServiceGroup:" << command.iServiceGroup; |
|
885 DPRINT << "iSetting:" << command.iSetting; |
|
886 DPRINT << "iStatus:" << command.iStatus; |
|
887 |
|
888 int result = m_callDivertingWrapper->setCallDiverting( |
|
889 command, bscParam(command.iServiceGroup)); |
|
890 if (0 == result) { |
|
891 if (!CpPhoneNotes::instance()->noteShowing()) { |
|
892 CpPhoneNotes::instance()->showGlobalProgressNote( |
|
893 m_activeProgressNoteId, hbTrId("txt_phone_info_requesting")); |
|
894 } |
|
895 } else { |
|
896 handleDivertingError(result); |
|
897 } |
|
898 |
|
899 DPRINT << ": OUT "; |
|
900 } |
|
901 |
|
902 /*! |
|
903 CpDivertPluginGroup::popUpTimerQuery. |
|
904 */ |
|
905 bool CpDivertPluginGroup::popUpTimerQuery(int &timeout) |
|
906 { |
|
907 DPRINT << ": IN"; |
|
908 Q_UNUSED(timeout); |
|
909 |
|
910 bool requestOK(false); |
|
911 m_divertTimeout = 0; |
|
912 |
|
913 if (!m_eventLoop->isRunning()) { |
|
914 HbDialog *dialog = createDialog(hbTrId("txt_phone_title_delay")); |
|
915 |
|
916 if (m_popupTimerList) { |
|
917 m_popupTimerList = new HbListWidget(dialog); |
|
918 |
|
919 addItemToListWidget(m_popupTimerList, hbTrId("txt_phone_list_5_seconds"), 5 ); |
|
920 addItemToListWidget(m_popupTimerList, hbTrId("txt_phone_list_10_seconds"), 10); |
|
921 addItemToListWidget(m_popupTimerList, hbTrId("txt_phone_list_15_seconds"), 15); |
|
922 addItemToListWidget(m_popupTimerList, hbTrId("txt_phone_list_20_seconds"), 20); |
|
923 addItemToListWidget(m_popupTimerList, hbTrId("txt_phone_list_25_seconds"), 25); |
|
924 addItemToListWidget(m_popupTimerList, hbTrId("txt_phone_list_30_seconds"), 30); |
|
925 |
|
926 // Connect list item activation signal to close the popup |
|
927 QObject::connect( |
|
928 m_popupTimerList, SIGNAL(activated(HbListWidgetItem*)), |
|
929 dialog, SLOT(close()), |
|
930 Qt::UniqueConnection); |
|
931 } |
|
932 |
|
933 // Sets the "Cancel"-action/button |
|
934 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
935 dialog->addAction(cancelAction); |
|
936 dialog->setContentWidget(m_popupTimerList); |
|
937 |
|
938 dialog->open(this, SLOT(popUpTimerQueryClosed(HbAction *))); |
|
939 |
|
940 QPointer<QObject> guard = this; |
|
941 m_eventLoop->exec(); |
|
942 if (guard.isNull()) { |
|
943 requestOK = false; |
|
944 } else if (m_divertTimeout > 0) { |
|
945 requestOK = true; |
|
946 } |
|
947 } |
|
948 |
|
949 DPRINT << ": OUT : requestOK :" << requestOK; |
|
950 return requestOK; |
|
951 } |
|
952 |
|
953 /*! |
|
954 CpDivertPluginGroup::popUpTimerQueryClosed. |
|
955 */ |
|
956 void CpDivertPluginGroup::popUpTimerQueryClosed(HbAction* action) |
|
957 { |
|
958 // If not cancel action selected |
|
959 if (!action) { |
|
960 // Update the view with selected text |
|
961 if (m_popupTimerList->currentItem()) { |
|
962 m_divertTimeout = |
|
963 m_popupTimerList->currentItem()->data().toInt(); |
|
964 } |
|
965 } |
|
966 else { |
|
967 DPRINT << ": Cancel"; |
|
968 } |
|
969 |
|
970 DPRINT << ": quit eventloop"; |
|
971 m_eventLoop->quit(); |
|
972 |
|
973 DPRINT << ": OUT: timeout: " << m_divertTimeout; |
|
974 } |
|
975 |
|
976 |
|
977 /*! |
|
978 CpDivertPluginGroup::bscParam. |
|
979 */ |
|
980 int CpDivertPluginGroup::bscParam(PsServiceGroup serviceGroup) |
|
981 { |
|
982 DPRINT << ": IN"; |
|
983 |
|
984 int bsc = AllTeleAndBearer; |
|
985 |
|
986 if (serviceGroup & ServiceGroupVoice) { |
|
987 int alsLine(AlsNotSupported); |
|
988 m_ssSettingsWrapper->get(Als,alsLine); |
|
989 DPRINT << ": alsLine " << alsLine; |
|
990 |
|
991 if ((alsLine == AlsNotSupported) || (alsLine == AlsPrimary)) { |
|
992 // Etelephony only activates voice service nothing else or causes |
|
993 // voice service status request. |
|
994 bsc = Telephony; |
|
995 } |
|
996 else { // ESSSettingsAlsAlternate |
|
997 // EAltTele only activates alternate service nothing else or causes |
|
998 // alternate service status request. |
|
999 bsc = AltTele; |
|
1000 } |
|
1001 } |
|
1002 |
|
1003 if (serviceGroup & ServiceGroupData) { |
|
1004 bsc = AllBearer; |
|
1005 } |
|
1006 |
|
1007 |
|
1008 |
|
1009 DPRINT << ": OUT : bsc :" << bsc; |
|
1010 return bsc; |
|
1011 } |
|
1012 |
|
1013 /*! |
|
1014 CpDivertPluginGroup::createDialog. |
|
1015 */ |
|
1016 HbDialog* CpDivertPluginGroup::createDialog( const QString& heading ) const |
|
1017 { |
|
1018 DPRINT << ": IN"; |
|
1019 |
|
1020 HbDialog *dialog = new HbDialog(); |
|
1021 dialog->setDismissPolicy(HbDialog::NoDismiss); |
|
1022 dialog->setTimeout(HbDialog::NoTimeout); |
|
1023 dialog->setHeadingWidget(new HbLabel(heading)); |
|
1024 |
|
1025 DPRINT << ": OUT"; |
|
1026 return dialog; |
|
1027 } |
|
1028 |
|
1029 /*! |
|
1030 CpDivertPluginGroup::addItemToListWidget. |
|
1031 */ |
|
1032 void CpDivertPluginGroup::addItemToListWidget(HbListWidget* w, |
|
1033 const QString& item, const QString& data) const |
|
1034 { |
|
1035 DPRINT << ": IN"; |
|
1036 |
|
1037 HbListWidgetItem* o = new HbListWidgetItem(); |
|
1038 o->setText(item); |
|
1039 o->setData(data); |
|
1040 w->addItem(o); |
|
1041 |
|
1042 DPRINT << ": OUT"; |
|
1043 } |
|
1044 |
|
1045 /*! |
|
1046 CpDivertPluginGroup::addItemToListWidget. |
|
1047 */ |
|
1048 void CpDivertPluginGroup::addItemToListWidget(HbListWidget* w, |
|
1049 const QString& item, const int& data) const |
|
1050 { |
|
1051 DPRINT << ": IN"; |
|
1052 |
|
1053 HbListWidgetItem* o = new HbListWidgetItem(); |
|
1054 o->setText(item); |
|
1055 o->setData(data); |
|
1056 w->addItem(o); |
|
1057 |
|
1058 DPRINT << ": OUT"; |
|
1059 } |
|
1060 |
|
1061 /*! |
|
1062 CpDivertPluginGroup::updateDependentDivertOptions. |
|
1063 Updates statuses of diverts which are dependent from the status of some |
|
1064 other divert. Logic for dependent changes are: |
|
1065 1. Activation of all calls divert deactivates other diverts/puts them |
|
1066 into quiescent state. |
|
1067 2. Deactivation of all calls divert enables diverts in quiescent state. |
|
1068 3. Not available option is an abstraction of CFB, CFNry, CFNrc diverts. |
|
1069 Enabling/disabling that options changes all the aforementioned diverts |
|
1070 at once. |
|
1071 */ |
|
1072 void CpDivertPluginGroup::updateDependentDivertOptions(bool fetchFromNetwork) |
|
1073 { |
|
1074 DPRINT << ": IN"; |
|
1075 |
|
1076 // all calls divert activation deactivates automatically other diverts |
|
1077 QVariant itemState = m_DataItemVoiceAllCalls->contentWidgetData("state"); |
|
1078 if ((itemState.isValid()) && |
|
1079 (itemState.toInt() == CpDivertSelectionCustomitem::Enabled)) { |
|
1080 deActivateDependentDivertOption(m_DataItemVoiceIfBusy); |
|
1081 deActivateDependentDivertOption(m_DataItemVoiceIfNotAnswered); |
|
1082 deActivateDependentDivertOption(m_DataItemVoiceIfOutOfReach); |
|
1083 } else { |
|
1084 // Must query data for diverts depending on all calls divert, because |
|
1085 // data may have been lost for registered diverts, which were |
|
1086 // automatically deactivated due to the activation of all calls divert. |
|
1087 activateDependentDivertOption(m_DataItemVoiceIfBusy, fetchFromNetwork); |
|
1088 activateDependentDivertOption(m_DataItemVoiceIfNotAnswered, fetchFromNetwork); |
|
1089 activateDependentDivertOption(m_DataItemVoiceIfOutOfReach, fetchFromNetwork); |
|
1090 } |
|
1091 |
|
1092 // all calls divert activation deactivates automatically other diverts |
|
1093 itemState = m_DataItemVideoAllCalls->contentWidgetData("state"); |
|
1094 if ((itemState.isValid()) && |
|
1095 (itemState.toInt() == CpDivertSelectionCustomitem::Enabled)) { |
|
1096 deActivateDependentDivertOption(m_DataItemVideoIfBusy); |
|
1097 deActivateDependentDivertOption(m_DataItemVideoIfNotAnswered); |
|
1098 deActivateDependentDivertOption(m_DataItemVideoIfOutOfReach); |
|
1099 } else { |
|
1100 // Must query data for diverts depending on all calls divert, because |
|
1101 // data may have been lost for registered diverts, which were |
|
1102 // automatically deactivated due to the activation of all calls divert. |
|
1103 activateDependentDivertOption(m_DataItemVideoIfBusy, fetchFromNetwork); |
|
1104 activateDependentDivertOption(m_DataItemVideoIfNotAnswered, fetchFromNetwork); |
|
1105 activateDependentDivertOption(m_DataItemVideoIfOutOfReach, fetchFromNetwork); |
|
1106 } |
|
1107 |
|
1108 // update not available divert option |
|
1109 updateNotAvailableDivertOption(); |
|
1110 |
|
1111 DPRINT << ": OUT"; |
|
1112 } |
|
1113 |
|
1114 /*! |
|
1115 CpDivertPluginGroup::deActivateDependentDivertOption. |
|
1116 */ |
|
1117 void CpDivertPluginGroup::deActivateDependentDivertOption( |
|
1118 CpDivertItemData* item) const |
|
1119 { |
|
1120 QVariant itemState = item->contentWidgetData("state"); |
|
1121 if ((itemState.isValid()) && |
|
1122 (itemState == CpDivertSelectionCustomitem::Enabled)) { |
|
1123 item->setContentWidgetData( |
|
1124 "state", CpDivertSelectionCustomitem::Deactivated); |
|
1125 } |
|
1126 item->setEnabled(false); |
|
1127 } |
|
1128 |
|
1129 /*! |
|
1130 CpDivertPluginGroup::activateDependentDivertOption. |
|
1131 */ |
|
1132 void CpDivertPluginGroup::activateDependentDivertOption( |
|
1133 CpDivertItemData* item, bool fetchFromNetwork) |
|
1134 { |
|
1135 if ((CpDivertSelectionCustomitem::Deactivated == |
|
1136 item->contentWidgetData("state").toInt()) && |
|
1137 fetchFromNetwork) { |
|
1138 addToDivertingRequestQueue( |
|
1139 CheckDivertStatus, *item); |
|
1140 } |
|
1141 item->setEnabled(true); |
|
1142 } |
|
1143 |
|
1144 /*! |
|
1145 CpDivertPluginGroup::updateNotAvailableDivertOption. |
|
1146 */ |
|
1147 void CpDivertPluginGroup::updateNotAvailableDivertOption() |
|
1148 { |
|
1149 DPRINT << ": IN"; |
|
1150 |
|
1151 // We must check that both states & numbers match amongst CFB, CRNry and |
|
1152 // CFNrc before concluding that not available divert is enabled, because |
|
1153 // some networks may not return divert number for inactive diverts. |
|
1154 int cfbState = |
|
1155 m_DataItemVoiceIfBusy->contentWidgetData("state").toInt(); |
|
1156 int cfnryState = |
|
1157 m_DataItemVoiceIfNotAnswered->contentWidgetData("state").toInt(); |
|
1158 int cfnrcState = |
|
1159 m_DataItemVoiceIfOutOfReach->contentWidgetData("state").toInt(); |
|
1160 QVariant cfbNumber = |
|
1161 m_DataItemVoiceIfBusy->contentWidgetData("number"); |
|
1162 QVariant cfnryNumber = |
|
1163 m_DataItemVoiceIfNotAnswered->contentWidgetData("number"); |
|
1164 QVariant cfnrcNumber = |
|
1165 m_DataItemVoiceIfOutOfReach->contentWidgetData("number"); |
|
1166 |
|
1167 if ((cfbNumber == cfnryNumber) && (cfbNumber == cfnrcNumber) && |
|
1168 (cfbState == cfnryState) && (cfbState == cfnrcState)) { |
|
1169 m_DataItemVoiceIfNotAvailable->setContentWidgetData( |
|
1170 "number", m_DataItemVoiceIfBusy->contentWidgetData("number")); |
|
1171 m_DataItemVoiceIfNotAvailable->setContentWidgetData( |
|
1172 "timeout", m_DataItemVoiceIfNotAnswered->contentWidgetData("timeout")); |
|
1173 m_DataItemVoiceIfNotAvailable->setContentWidgetData( |
|
1174 "state", m_DataItemVoiceIfBusy->contentWidgetData("state")); |
|
1175 } else { |
|
1176 m_DataItemVoiceIfNotAvailable->setContentWidgetData("number", ""); |
|
1177 m_DataItemVoiceIfNotAvailable->setContentWidgetData("timeout", 0); |
|
1178 m_DataItemVoiceIfNotAvailable->setContentWidgetData( |
|
1179 "state", CpDivertSelectionCustomitem::Disabled); |
|
1180 |
|
1181 } |
|
1182 // Item dimming |
|
1183 m_DataItemVoiceIfNotAvailable->setEnabled( |
|
1184 m_DataItemVoiceIfBusy->isEnabled() && |
|
1185 m_DataItemVoiceIfNotAnswered->isEnabled() && |
|
1186 m_DataItemVoiceIfOutOfReach->isEnabled()); |
|
1187 |
|
1188 |
|
1189 // We must check that both states & numbers match amongst CFB, CRNry and |
|
1190 // CFNrc before concluding that not available divert is enabled, because |
|
1191 // some networks may not return divert number for inactive diverts. |
|
1192 cfbState = |
|
1193 m_DataItemVideoIfBusy->contentWidgetData("state").toInt(); |
|
1194 cfnryState = |
|
1195 m_DataItemVideoIfNotAnswered->contentWidgetData("state").toInt(); |
|
1196 cfnrcState = |
|
1197 m_DataItemVideoIfOutOfReach->contentWidgetData("state").toInt(); |
|
1198 cfbNumber = |
|
1199 m_DataItemVideoIfBusy->contentWidgetData("number"); |
|
1200 cfnryNumber = |
|
1201 m_DataItemVideoIfNotAnswered->contentWidgetData("number"); |
|
1202 cfnrcNumber = |
|
1203 m_DataItemVideoIfOutOfReach->contentWidgetData("number"); |
|
1204 |
|
1205 if ((cfbNumber == cfnryNumber) && (cfbNumber == cfnrcNumber) && |
|
1206 (cfbState == cfnryState) && (cfbState == cfnrcState)) { |
|
1207 m_DataItemVideoIfNotAvailable->setContentWidgetData( |
|
1208 "number", m_DataItemVideoIfBusy->contentWidgetData("number")); |
|
1209 m_DataItemVideoIfNotAvailable->setContentWidgetData( |
|
1210 "timeout", m_DataItemVideoIfNotAnswered->contentWidgetData("timeout")); |
|
1211 m_DataItemVideoIfNotAvailable->setContentWidgetData( |
|
1212 "state", m_DataItemVideoIfBusy->contentWidgetData("state")); |
|
1213 } else { |
|
1214 m_DataItemVideoIfNotAvailable->setContentWidgetData("number", ""); |
|
1215 m_DataItemVideoIfNotAvailable->setContentWidgetData("timeout", 0); |
|
1216 m_DataItemVideoIfNotAvailable->setContentWidgetData( |
|
1217 "state", CpDivertSelectionCustomitem::Disabled); |
|
1218 |
|
1219 } |
|
1220 |
|
1221 // Item dimming |
|
1222 m_DataItemVideoIfNotAvailable->setEnabled( |
|
1223 m_DataItemVideoIfBusy->isEnabled() && |
|
1224 m_DataItemVideoIfNotAnswered->isEnabled() && |
|
1225 m_DataItemVideoIfOutOfReach->isEnabled()); |
|
1226 |
|
1227 DPRINT << ": OUT"; |
|
1228 } |
|
1229 |
|
1230 // End of File. |
|