1 /*! |
1 /*! |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
13 * |
13 * |
14 * Description: Handles phone notes. |
14 * Description: Handles phone notes. |
15 */ |
15 */ |
16 |
16 |
17 #include "phoneglobalnotes.h" |
17 #include "phoneglobalnotes.h" |
18 #include "tphonecmdparamglobalnote.h" |
|
19 #include "tphonecmdparamquery.h" |
18 #include "tphonecmdparamquery.h" |
20 #include "phoneresourceadapter.h" |
19 #include "phoneresourceadapter.h" |
21 #include "qtphonelog.h" |
20 #include "qtphonelog.h" |
22 #include <QSignalMapper> |
21 #include <QSignalMapper> |
23 #include <QTimer> |
22 #include <QTimer> |
24 #include <hbaction.h> |
23 #include <hbaction.h> |
25 #include <phoneappcommands.hrh> |
24 #include <phoneappcommands.hrh> |
26 #include <hbstringutil.h> |
25 #include <hbstringutil.h> |
|
26 #include <xqsystemtoneservice.h> |
|
27 |
27 #include <restricted/hbdevicedialogsextensionsymbian_r.h> |
28 #include <restricted/hbdevicedialogsextensionsymbian_r.h> |
28 |
29 |
29 const TInt KCriticalLevel = 2; |
30 const TInt KCriticalLevel = 2; |
30 |
31 |
31 PhoneGlobalNotes::PhoneGlobalNotes(QObject *parent) : |
32 PhoneGlobalNotes::PhoneGlobalNotes(QObject *parent) : |
32 QObject(parent), |
33 QObject(parent), |
33 m_timer(0), |
34 m_timer(0), |
|
35 m_toneService(0), |
34 m_queryCanceledCommand(-1), |
36 m_queryCanceledCommand(-1), |
35 m_timeoutCommand(-1), |
37 m_timeoutCommand(-1), |
36 iProgressDialog(0) |
38 iProgressDialog(0) |
37 { |
39 { |
38 PHONE_TRACE |
40 PHONE_TRACE |
|
41 m_toneService = new XQSystemToneService(this); |
|
42 |
39 m_timer = new QTimer(this); |
43 m_timer = new QTimer(this); |
40 m_timer->setSingleShot(true); |
44 m_timer->setSingleShot(true); |
41 connect(m_timer, SIGNAL(timeout()), SLOT(queryTimeout())); |
45 connect(m_timer, SIGNAL(timeout()), SLOT(queryTimeout())); |
42 } |
46 } |
43 |
47 |
78 ret = QString::fromUtf16(globalNoteParam->Text().Ptr(), |
82 ret = QString::fromUtf16(globalNoteParam->Text().Ptr(), |
79 globalNoteParam->Text().Length()); |
83 globalNoteParam->Text().Length()); |
80 } |
84 } |
81 |
85 |
82 return ret; |
86 return ret; |
|
87 } |
|
88 |
|
89 void PhoneGlobalNotes::playToneIfNeeded(TPhoneNotificationToneType aTone) |
|
90 { |
|
91 PHONE_TRACE |
|
92 |
|
93 if (aTone != EPhoneNoTone) { |
|
94 XQSystemToneService::ToneType toneType; |
|
95 switch( aTone ) { |
|
96 case EPhoneInformationTone: |
|
97 toneType = XQSystemToneService::InformationBeepTone; |
|
98 break; |
|
99 case EPhoneConfirmationTone: |
|
100 toneType = XQSystemToneService::ConfirmationBeepTone; |
|
101 break; |
|
102 case EPhoneWarningTone: |
|
103 toneType = XQSystemToneService::WarningBeepTone; |
|
104 break; |
|
105 case EPhoneErrorTone: |
|
106 default: |
|
107 toneType = XQSystemToneService::ErrorBeepTone; |
|
108 break; |
|
109 } |
|
110 |
|
111 m_toneService->playTone(toneType); |
|
112 } |
83 } |
113 } |
84 |
114 |
85 void PhoneGlobalNotes::showGlobalWaitNote(TPhoneCmdParamQuery* params) |
115 void PhoneGlobalNotes::showGlobalWaitNote(TPhoneCmdParamQuery* params) |
86 { |
116 { |
87 PHONE_TRACE |
117 PHONE_TRACE |
123 for (int i = 0; i < iMessageBoxList.count(); ++i) { |
153 for (int i = 0; i < iMessageBoxList.count(); ++i) { |
124 // Do not show same note/text several times, e.g when user hits |
154 // Do not show same note/text several times, e.g when user hits |
125 // the end button several times we should show only one "not allowed" |
155 // the end button several times we should show only one "not allowed" |
126 // note. |
156 // note. |
127 if (noteString == QString::fromUtf16( |
157 if (noteString == QString::fromUtf16( |
128 iMessageBoxList.at(i)->Text().Ptr(), |
158 iMessageBoxList.at(i)->m_messageBox->Text().Ptr(), |
129 iMessageBoxList.at(i)->Text().Length())) { |
159 iMessageBoxList.at(i)->m_messageBox->Text().Length())) { |
130 showNote = false; |
160 showNote = false; |
131 break; |
161 break; |
132 } |
162 } |
133 } |
163 } |
134 |
164 |
166 for (int i = 0; i < iNotificationList.count(); ++i) { |
197 for (int i = 0; i < iNotificationList.count(); ++i) { |
167 // Do not show same note/text several times, e.g when user hits |
198 // Do not show same note/text several times, e.g when user hits |
168 // the end button several times we should show only one "not allowed" |
199 // the end button several times we should show only one "not allowed" |
169 // note. |
200 // note. |
170 if (noteString == QString::fromUtf16( |
201 if (noteString == QString::fromUtf16( |
171 iNotificationList.at(i)->Title().Ptr(), |
202 iNotificationList.at(i)->m_notificationDialog->Title().Ptr(), |
172 iNotificationList.at(i)->Title().Length())) { |
203 iNotificationList.at(i)->m_notificationDialog->Title().Length())) { |
173 showNote = false; |
204 showNote = false; |
174 break; |
205 break; |
175 } |
206 } |
176 } |
207 } |
177 |
208 |
178 if (showNote) { |
209 if (showNote) { |
179 TRAP_IGNORE( |
210 TRAP_IGNORE( |
180 ShowDeviceNotificationDialogL( |
211 ShowDeviceNotificationDialogL( |
181 TPtrC16(noteString.utf16()), |
212 TPtrC16(noteString.utf16()), |
182 params->Timeout()); |
213 params->Timeout(), |
|
214 params->ToneType()); |
183 ); |
215 ); |
184 } |
216 } |
185 } |
217 } |
186 } |
218 } |
187 |
219 |
202 } |
234 } |
203 |
235 |
204 void PhoneGlobalNotes::ShowDeviceMessageBoxL( |
236 void PhoneGlobalNotes::ShowDeviceMessageBoxL( |
205 CHbDeviceMessageBoxSymbian::TType aType, |
237 CHbDeviceMessageBoxSymbian::TType aType, |
206 const TDesC16& aText, |
238 const TDesC16& aText, |
207 TInt aTimeout) |
239 TInt aTimeout, |
|
240 TPhoneNotificationToneType aTone |
|
241 ) |
208 { |
242 { |
209 CHbDeviceMessageBoxSymbian *d = CHbDeviceMessageBoxSymbian::NewL( |
243 CHbDeviceMessageBoxSymbian *d = CHbDeviceMessageBoxSymbian::NewL( |
210 aType, this); |
244 aType, this); |
211 CleanupStack::PushL(d); |
245 CleanupStack::PushL(d); |
212 |
246 |
213 // Show top of security |
247 // Show top of security |
214 HbDeviceDialogsExtensionSymbian::SetShowLevel(d, KCriticalLevel); |
248 HbDeviceDialogsExtensionSymbian::SetShowLevel(d, KCriticalLevel); |
215 |
249 |
216 d->SetTextL(aText); |
250 d->SetTextL(aText); |
217 |
251 |
220 // Default value is HbPopup::StandardTimeout (3000 ms) |
254 // Default value is HbPopup::StandardTimeout (3000 ms) |
221 d->SetTimeout(aTimeout); |
255 d->SetTimeout(aTimeout); |
222 } |
256 } |
223 |
257 |
224 if (iMessageBoxList.count() == 0) { |
258 if (iMessageBoxList.count() == 0) { |
|
259 playToneIfNeeded(aTone); |
225 // Show dialog only when there is no notifications ongoing. |
260 // Show dialog only when there is no notifications ongoing. |
226 // Delete dialog if show fails. |
261 // Delete dialog if show fails. |
227 d->ShowL(); |
262 d->ShowL(); |
228 } |
263 } |
229 |
264 |
230 iMessageBoxList.append(d); |
265 MessageBoxData* data = NULL; |
|
266 QT_TRYCATCH_LEAVING(data = new MessageBoxData()); |
|
267 data->m_messageBox = d; |
|
268 data->m_tone = aTone; |
|
269 |
|
270 iMessageBoxList.append(data); |
231 CleanupStack::Pop(d); |
271 CleanupStack::Pop(d); |
232 } |
272 } |
233 |
273 |
234 |
274 |
235 void PhoneGlobalNotes::ShowDeviceNotificationDialogL( |
275 void PhoneGlobalNotes::ShowDeviceNotificationDialogL( |
236 const TDesC16& aTitle, TInt aTimeout) |
276 const TDesC16& aTitle, TInt aTimeout, TPhoneNotificationToneType aTone) |
237 { |
277 { |
238 CHbDeviceNotificationDialogSymbian *d = CHbDeviceNotificationDialogSymbian::NewL(this); |
278 CHbDeviceNotificationDialogSymbian *d = CHbDeviceNotificationDialogSymbian::NewL(this); |
239 CleanupStack::PushL(d); |
279 CleanupStack::PushL(d); |
240 |
280 |
241 // Show top of security |
281 // Show top of security |
248 // Default value is HbPopup::StandardTimeout (3000 ms) |
288 // Default value is HbPopup::StandardTimeout (3000 ms) |
249 d->SetTimeout(aTimeout); |
289 d->SetTimeout(aTimeout); |
250 } |
290 } |
251 |
291 |
252 if (iNotificationList.count() == 0) { |
292 if (iNotificationList.count() == 0) { |
|
293 playToneIfNeeded(aTone); |
253 // Show dialog only when there is no notifications ongoing. |
294 // Show dialog only when there is no notifications ongoing. |
254 // Delete dialog if show fails. |
295 // Delete dialog if show fails. |
255 d->ShowL(); |
296 d->ShowL(); |
256 } |
297 } |
257 |
298 |
258 iNotificationList.append(d); |
299 NotificationDialogData* data = NULL; |
|
300 QT_TRYCATCH_LEAVING(data = new NotificationDialogData()); |
|
301 data->m_notificationDialog = d; |
|
302 data->m_tone = aTone; |
|
303 iNotificationList.append(data); |
259 CleanupStack::Pop(d); |
304 CleanupStack::Pop(d); |
260 } |
305 } |
261 |
306 |
262 void PhoneGlobalNotes::removeGlobalWaitNote() |
307 void PhoneGlobalNotes::removeGlobalWaitNote() |
263 { |
308 { |
292 |
337 |
293 void PhoneGlobalNotes::NotificationDialogClosed( |
338 void PhoneGlobalNotes::NotificationDialogClosed( |
294 const CHbDeviceNotificationDialogSymbian* aDialog, TInt ) |
339 const CHbDeviceNotificationDialogSymbian* aDialog, TInt ) |
295 { |
340 { |
296 PHONE_TRACE |
341 PHONE_TRACE |
297 CHbDeviceNotificationDialogSymbian *notification = iNotificationList.takeFirst(); |
342 NotificationDialogData *notification = iNotificationList.takeFirst(); |
298 Q_ASSERT( notification == aDialog ); |
343 Q_ASSERT( notification->m_notificationDialog == aDialog ); |
|
344 Q_UNUSED(aDialog); |
|
345 delete notification->m_notificationDialog; |
299 delete notification; |
346 delete notification; |
300 |
347 |
301 if ( 0 < iNotificationList.size() ) { |
348 if ( 0 < iNotificationList.size() ) { |
302 PHONE_DEBUG("PhoneGlobalNotes::show pending note"); |
349 PHONE_DEBUG("PhoneGlobalNotes::show pending note"); |
303 CHbDeviceNotificationDialogSymbian *notificationTemp = iNotificationList[0]; |
350 NotificationDialogData *notificationTemp = iNotificationList[0]; |
304 TRAP_IGNORE( notificationTemp->ShowL() ); |
351 TRAP_IGNORE( notificationTemp->m_notificationDialog->ShowL() ); |
305 } |
352 } |
306 } |
353 } |
307 |
354 |
308 void PhoneGlobalNotes::MessageBoxClosed(const CHbDeviceMessageBoxSymbian* aMessageBox, |
355 void PhoneGlobalNotes::MessageBoxClosed(const CHbDeviceMessageBoxSymbian* aMessageBox, |
309 CHbDeviceMessageBoxSymbian::TButtonId ) |
356 CHbDeviceMessageBoxSymbian::TButtonId ) |
310 { |
357 { |
311 PHONE_TRACE |
358 PHONE_TRACE |
312 CHbDeviceMessageBoxSymbian *messageBox = iMessageBoxList.takeFirst(); |
359 MessageBoxData *messageBox = iMessageBoxList.takeFirst(); |
313 Q_ASSERT( messageBox == aMessageBox ); |
360 Q_ASSERT( messageBox->m_messageBox == aMessageBox ); |
|
361 Q_UNUSED(aMessageBox); |
|
362 delete messageBox->m_messageBox; |
314 delete messageBox; |
363 delete messageBox; |
315 |
364 |
316 if ( 0 < iMessageBoxList.size() ) { |
365 if ( 0 < iMessageBoxList.size() ) { |
317 PHONE_DEBUG("PhoneGlobalNotes::show pending note"); |
366 PHONE_DEBUG("PhoneGlobalNotes::show pending note"); |
318 CHbDeviceMessageBoxSymbian *messageBoxTemp = iMessageBoxList[0]; |
367 MessageBoxData *messageBoxTemp = iMessageBoxList[0]; |
319 TRAP_IGNORE( messageBoxTemp->ShowL() ); |
368 TRAP_IGNORE( messageBoxTemp->m_messageBox->ShowL() ); |
320 } |
369 } |
321 } |
370 } |
322 |
371 |
323 void PhoneGlobalNotes::ProgressDialogCancelled( |
372 void PhoneGlobalNotes::ProgressDialogCancelled( |
324 const CHbDeviceProgressDialogSymbian* ) |
373 const CHbDeviceProgressDialogSymbian* ) |