65
|
1 |
/*!
|
76
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
65
|
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: Handles phone notes.
|
|
15 |
*/
|
|
16 |
|
|
17 |
#include "phoneglobalnotes.h"
|
|
18 |
#include "tphonecmdparamquery.h"
|
|
19 |
#include "phoneresourceadapter.h"
|
|
20 |
#include "qtphonelog.h"
|
|
21 |
#include <QSignalMapper>
|
|
22 |
#include <QTimer>
|
|
23 |
#include <hbaction.h>
|
|
24 |
#include <phoneappcommands.hrh>
|
|
25 |
#include <hbstringutil.h>
|
76
|
26 |
#include <xqsystemtoneservice.h>
|
|
27 |
|
65
|
28 |
#include <restricted/hbdevicedialogsextensionsymbian_r.h>
|
|
29 |
|
|
30 |
const TInt KCriticalLevel = 2;
|
|
31 |
|
78
|
32 |
PhoneGlobalNotes::PhoneGlobalNotes(XQSystemToneService& toneservice,
|
|
33 |
QObject *parent) :
|
|
34 |
QObject(parent),
|
65
|
35 |
m_timer(0),
|
78
|
36 |
m_toneService(&toneservice),
|
65
|
37 |
m_queryCanceledCommand(-1),
|
|
38 |
m_timeoutCommand(-1),
|
|
39 |
iProgressDialog(0)
|
78
|
40 |
|
65
|
41 |
{
|
|
42 |
PHONE_TRACE
|
76
|
43 |
|
65
|
44 |
m_timer = new QTimer(this);
|
|
45 |
m_timer->setSingleShot(true);
|
|
46 |
connect(m_timer, SIGNAL(timeout()), SLOT(queryTimeout()));
|
|
47 |
}
|
|
48 |
|
|
49 |
PhoneGlobalNotes::~PhoneGlobalNotes()
|
|
50 |
{
|
|
51 |
PHONE_TRACE
|
|
52 |
}
|
|
53 |
|
|
54 |
QString PhoneGlobalNotes::globalNoteText(
|
|
55 |
TPhoneCommandParam *commandParam)
|
|
56 |
{
|
|
57 |
PHONE_TRACE
|
|
58 |
TPhoneCmdParamGlobalNote* globalNoteParam =
|
|
59 |
static_cast<TPhoneCmdParamGlobalNote*>( commandParam );
|
|
60 |
|
|
61 |
QString ret;
|
|
62 |
|
|
63 |
if ( globalNoteParam->TextResourceId() &&
|
|
64 |
KErrNone != globalNoteParam->Text().Compare( KNullDesC() ) ) {
|
|
65 |
// resource and text exists
|
|
66 |
ret = PhoneResourceAdapter::Instance()->convertToStringWithParam(
|
|
67 |
globalNoteParam->TextResourceId(),
|
|
68 |
QString::fromUtf16(globalNoteParam->Text().Ptr(),
|
|
69 |
globalNoteParam->Text().Length()) );
|
|
70 |
} else if ( globalNoteParam->TextResourceId() ) {
|
|
71 |
// resource exists
|
|
72 |
QString causeCode;
|
|
73 |
if (-1 != globalNoteParam->CauseCode()) {
|
|
74 |
causeCode.setNum(globalNoteParam->CauseCode());
|
|
75 |
causeCode = HbStringUtil::convertDigits(causeCode);
|
|
76 |
}
|
|
77 |
|
|
78 |
ret = PhoneResourceAdapter::Instance()->convertToString(
|
|
79 |
globalNoteParam->TextResourceId(), causeCode);
|
|
80 |
|
|
81 |
} else if ( KErrNone != globalNoteParam->Text().Compare( KNullDesC() ) ) {
|
|
82 |
// text exists
|
|
83 |
ret = QString::fromUtf16(globalNoteParam->Text().Ptr(),
|
|
84 |
globalNoteParam->Text().Length());
|
|
85 |
}
|
|
86 |
|
|
87 |
return ret;
|
|
88 |
}
|
|
89 |
|
76
|
90 |
void PhoneGlobalNotes::playToneIfNeeded(TPhoneNotificationToneType aTone)
|
|
91 |
{
|
|
92 |
PHONE_TRACE
|
|
93 |
|
|
94 |
if (aTone != EPhoneNoTone) {
|
|
95 |
XQSystemToneService::ToneType toneType;
|
|
96 |
switch( aTone ) {
|
|
97 |
case EPhoneInformationTone:
|
|
98 |
toneType = XQSystemToneService::InformationBeepTone;
|
|
99 |
break;
|
|
100 |
case EPhoneConfirmationTone:
|
|
101 |
toneType = XQSystemToneService::ConfirmationBeepTone;
|
|
102 |
break;
|
|
103 |
case EPhoneWarningTone:
|
|
104 |
toneType = XQSystemToneService::WarningBeepTone;
|
|
105 |
break;
|
|
106 |
case EPhoneErrorTone:
|
|
107 |
default:
|
|
108 |
toneType = XQSystemToneService::ErrorBeepTone;
|
|
109 |
break;
|
|
110 |
}
|
|
111 |
|
|
112 |
m_toneService->playTone(toneType);
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
65
|
116 |
void PhoneGlobalNotes::showGlobalWaitNote(TPhoneCmdParamQuery* params)
|
|
117 |
{
|
|
118 |
PHONE_TRACE
|
|
119 |
if (!iProgressDialog) {
|
|
120 |
m_queryCanceledCommand = params->CbaCommandMapping(EAknSoftkeyCancel);
|
|
121 |
|
|
122 |
TPtrC16 text = KNullDesC();
|
|
123 |
if (params->QueryPrompt().Length()) {
|
|
124 |
text.Set(params->QueryPrompt());
|
|
125 |
} else if (0 != params->DataText()) {
|
|
126 |
text.Set(*params->DataText());
|
|
127 |
}
|
|
128 |
|
|
129 |
TRAP_IGNORE(
|
|
130 |
// Timeout even when global note showing fails
|
|
131 |
if (params->TimeOut() != 0) {
|
|
132 |
m_timeoutCommand = -1;
|
|
133 |
int customCommand;
|
|
134 |
if (-1 != params->GetCustomCommandForTimeOut(customCommand)) {
|
|
135 |
m_timeoutCommand = customCommand;
|
|
136 |
}
|
|
137 |
|
|
138 |
m_timer->start(params->TimeOut());
|
|
139 |
}
|
|
140 |
|
|
141 |
ShowGlobalWaitNoteL(text);
|
|
142 |
);
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
void PhoneGlobalNotes::showDeviceMessageBox(
|
|
147 |
TPhoneCmdParamGlobalNote* params)
|
|
148 |
{
|
|
149 |
PHONE_TRACE
|
|
150 |
QString noteString = globalNoteText(params);
|
|
151 |
|
|
152 |
if (false == noteString.isNull()) {
|
|
153 |
bool showNote(true);
|
|
154 |
for (int i = 0; i < iMessageBoxList.count(); ++i) {
|
|
155 |
// Do not show same note/text several times, e.g when user hits
|
|
156 |
// the end button several times we should show only one "not allowed"
|
|
157 |
// note.
|
|
158 |
if (noteString == QString::fromUtf16(
|
76
|
159 |
iMessageBoxList.at(i)->m_messageBox->Text().Ptr(),
|
|
160 |
iMessageBoxList.at(i)->m_messageBox->Text().Length())) {
|
65
|
161 |
showNote = false;
|
|
162 |
break;
|
|
163 |
}
|
|
164 |
}
|
|
165 |
|
|
166 |
if (showNote) {
|
|
167 |
CHbDeviceMessageBoxSymbian::TType type;
|
|
168 |
switch( params->Type() ) {
|
|
169 |
case EPhoneMessageBoxInformation:
|
|
170 |
type = CHbDeviceMessageBoxSymbian::EInformation;
|
|
171 |
break;
|
|
172 |
case EPhoneMessageBoxWarning:
|
|
173 |
default:
|
|
174 |
type = CHbDeviceMessageBoxSymbian::EWarning;
|
|
175 |
break;
|
|
176 |
}
|
76
|
177 |
|
65
|
178 |
TRAP_IGNORE(
|
|
179 |
ShowDeviceMessageBoxL(
|
|
180 |
type,
|
|
181 |
TPtrC16(noteString.utf16()),
|
76
|
182 |
params->Timeout(),
|
|
183 |
params->ToneType());
|
65
|
184 |
);
|
|
185 |
}
|
|
186 |
}
|
|
187 |
}
|
|
188 |
|
|
189 |
void PhoneGlobalNotes::showDeviceNotificationDialog(
|
|
190 |
TPhoneCmdParamGlobalNote* params)
|
|
191 |
{
|
|
192 |
PHONE_TRACE
|
|
193 |
|
|
194 |
QString noteString = globalNoteText(params);
|
|
195 |
|
|
196 |
if (false == noteString.isNull()) {
|
|
197 |
bool showNote(true);
|
|
198 |
for (int i = 0; i < iNotificationList.count(); ++i) {
|
|
199 |
// Do not show same note/text several times, e.g when user hits
|
|
200 |
// the end button several times we should show only one "not allowed"
|
|
201 |
// note.
|
|
202 |
if (noteString == QString::fromUtf16(
|
76
|
203 |
iNotificationList.at(i)->m_notificationDialog->Title().Ptr(),
|
|
204 |
iNotificationList.at(i)->m_notificationDialog->Title().Length())) {
|
65
|
205 |
showNote = false;
|
|
206 |
break;
|
|
207 |
}
|
|
208 |
}
|
|
209 |
|
|
210 |
if (showNote) {
|
|
211 |
TRAP_IGNORE(
|
|
212 |
ShowDeviceNotificationDialogL(
|
|
213 |
TPtrC16(noteString.utf16()),
|
76
|
214 |
params->Timeout(),
|
|
215 |
params->ToneType());
|
65
|
216 |
);
|
|
217 |
}
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
void PhoneGlobalNotes::ShowGlobalWaitNoteL(
|
|
222 |
const TDesC16& aText)
|
|
223 |
{
|
|
224 |
CHbDeviceProgressDialogSymbian *d = CHbDeviceProgressDialogSymbian::NewL(
|
|
225 |
CHbDeviceProgressDialogSymbian::EWaitDialog);
|
|
226 |
CleanupStack::PushL(d);
|
|
227 |
|
|
228 |
// Show top of security
|
|
229 |
HbDeviceDialogsExtensionSymbian::SetShowLevel(d, KCriticalLevel);
|
|
230 |
|
|
231 |
d->SetTextL(aText);
|
|
232 |
d->ShowL();
|
|
233 |
iProgressDialog = d; // Note is about to be shown
|
|
234 |
CleanupStack::Pop(d);
|
|
235 |
}
|
|
236 |
|
|
237 |
void PhoneGlobalNotes::ShowDeviceMessageBoxL(
|
|
238 |
CHbDeviceMessageBoxSymbian::TType aType,
|
|
239 |
const TDesC16& aText,
|
76
|
240 |
TInt aTimeout,
|
|
241 |
TPhoneNotificationToneType aTone
|
|
242 |
)
|
65
|
243 |
{
|
|
244 |
CHbDeviceMessageBoxSymbian *d = CHbDeviceMessageBoxSymbian::NewL(
|
|
245 |
aType, this);
|
|
246 |
CleanupStack::PushL(d);
|
76
|
247 |
|
65
|
248 |
// Show top of security
|
|
249 |
HbDeviceDialogsExtensionSymbian::SetShowLevel(d, KCriticalLevel);
|
|
250 |
|
|
251 |
d->SetTextL(aText);
|
|
252 |
|
|
253 |
if (aTimeout > 0) {
|
|
254 |
// If timeout not set we use default timeout.
|
|
255 |
// Default value is HbPopup::StandardTimeout (3000 ms)
|
|
256 |
d->SetTimeout(aTimeout);
|
|
257 |
}
|
|
258 |
|
|
259 |
if (iMessageBoxList.count() == 0) {
|
76
|
260 |
playToneIfNeeded(aTone);
|
65
|
261 |
// Show dialog only when there is no notifications ongoing.
|
|
262 |
// Delete dialog if show fails.
|
|
263 |
d->ShowL();
|
|
264 |
}
|
|
265 |
|
76
|
266 |
MessageBoxData* data = NULL;
|
|
267 |
QT_TRYCATCH_LEAVING(data = new MessageBoxData());
|
|
268 |
data->m_messageBox = d;
|
|
269 |
data->m_tone = aTone;
|
|
270 |
|
|
271 |
iMessageBoxList.append(data);
|
65
|
272 |
CleanupStack::Pop(d);
|
|
273 |
}
|
|
274 |
|
|
275 |
|
|
276 |
void PhoneGlobalNotes::ShowDeviceNotificationDialogL(
|
76
|
277 |
const TDesC16& aTitle, TInt aTimeout, TPhoneNotificationToneType aTone)
|
65
|
278 |
{
|
|
279 |
CHbDeviceNotificationDialogSymbian *d = CHbDeviceNotificationDialogSymbian::NewL(this);
|
|
280 |
CleanupStack::PushL(d);
|
|
281 |
|
|
282 |
// Show top of security
|
|
283 |
HbDeviceDialogsExtensionSymbian::SetShowLevel(d, KCriticalLevel);
|
|
284 |
|
|
285 |
d->SetTitleL(aTitle);
|
|
286 |
|
|
287 |
if (aTimeout > 0) {
|
|
288 |
// If timeout not set we use default timeout.
|
|
289 |
// Default value is HbPopup::StandardTimeout (3000 ms)
|
|
290 |
d->SetTimeout(aTimeout);
|
|
291 |
}
|
|
292 |
|
|
293 |
if (iNotificationList.count() == 0) {
|
76
|
294 |
playToneIfNeeded(aTone);
|
65
|
295 |
// Show dialog only when there is no notifications ongoing.
|
|
296 |
// Delete dialog if show fails.
|
|
297 |
d->ShowL();
|
|
298 |
}
|
|
299 |
|
76
|
300 |
NotificationDialogData* data = NULL;
|
|
301 |
QT_TRYCATCH_LEAVING(data = new NotificationDialogData());
|
|
302 |
data->m_notificationDialog = d;
|
|
303 |
data->m_tone = aTone;
|
|
304 |
iNotificationList.append(data);
|
65
|
305 |
CleanupStack::Pop(d);
|
|
306 |
}
|
|
307 |
|
|
308 |
void PhoneGlobalNotes::removeGlobalWaitNote()
|
|
309 |
{
|
|
310 |
PHONE_TRACE
|
|
311 |
m_timeoutCommand = -1;
|
|
312 |
m_timer->stop();
|
|
313 |
|
|
314 |
if (iProgressDialog) {
|
|
315 |
m_queryCanceledCommand = -1;
|
|
316 |
iProgressDialog->Close();
|
|
317 |
}
|
|
318 |
}
|
|
319 |
|
|
320 |
void PhoneGlobalNotes::queryTimeout()
|
|
321 |
{
|
|
322 |
PHONE_TRACE
|
|
323 |
int sendCommand = m_timeoutCommand;
|
|
324 |
if (iProgressDialog) {
|
|
325 |
m_queryCanceledCommand = -1;
|
|
326 |
iProgressDialog->Close();
|
|
327 |
}
|
|
328 |
if (sendCommand != -1) {
|
|
329 |
emit command(sendCommand);
|
|
330 |
}
|
|
331 |
}
|
|
332 |
|
|
333 |
void PhoneGlobalNotes::NotificationDialogActivated(
|
|
334 |
const CHbDeviceNotificationDialogSymbian* )
|
|
335 |
{
|
|
336 |
PHONE_TRACE
|
|
337 |
}
|
|
338 |
|
|
339 |
void PhoneGlobalNotes::NotificationDialogClosed(
|
|
340 |
const CHbDeviceNotificationDialogSymbian* aDialog, TInt )
|
|
341 |
{
|
|
342 |
PHONE_TRACE
|
76
|
343 |
NotificationDialogData *notification = iNotificationList.takeFirst();
|
|
344 |
Q_ASSERT( notification->m_notificationDialog == aDialog );
|
|
345 |
Q_UNUSED(aDialog);
|
|
346 |
delete notification->m_notificationDialog;
|
65
|
347 |
delete notification;
|
|
348 |
|
|
349 |
if ( 0 < iNotificationList.size() ) {
|
|
350 |
PHONE_DEBUG("PhoneGlobalNotes::show pending note");
|
76
|
351 |
NotificationDialogData *notificationTemp = iNotificationList[0];
|
|
352 |
TRAP_IGNORE( notificationTemp->m_notificationDialog->ShowL() );
|
65
|
353 |
}
|
|
354 |
}
|
|
355 |
|
|
356 |
void PhoneGlobalNotes::MessageBoxClosed(const CHbDeviceMessageBoxSymbian* aMessageBox,
|
|
357 |
CHbDeviceMessageBoxSymbian::TButtonId )
|
|
358 |
{
|
|
359 |
PHONE_TRACE
|
76
|
360 |
MessageBoxData *messageBox = iMessageBoxList.takeFirst();
|
|
361 |
Q_ASSERT( messageBox->m_messageBox == aMessageBox );
|
|
362 |
Q_UNUSED(aMessageBox);
|
|
363 |
delete messageBox->m_messageBox;
|
65
|
364 |
delete messageBox;
|
|
365 |
|
|
366 |
if ( 0 < iMessageBoxList.size() ) {
|
|
367 |
PHONE_DEBUG("PhoneGlobalNotes::show pending note");
|
76
|
368 |
MessageBoxData *messageBoxTemp = iMessageBoxList[0];
|
|
369 |
TRAP_IGNORE( messageBoxTemp->m_messageBox->ShowL() );
|
65
|
370 |
}
|
|
371 |
}
|
|
372 |
|
|
373 |
void PhoneGlobalNotes::ProgressDialogCancelled(
|
|
374 |
const CHbDeviceProgressDialogSymbian* )
|
|
375 |
{
|
|
376 |
PHONE_TRACE
|
|
377 |
if (iProgressDialog) {
|
|
378 |
delete iProgressDialog;
|
|
379 |
iProgressDialog = 0;
|
|
380 |
}
|
|
381 |
|
|
382 |
m_timer->stop();
|
|
383 |
|
|
384 |
if (m_queryCanceledCommand != -1) {
|
|
385 |
emit command(m_queryCanceledCommand);
|
|
386 |
}
|
|
387 |
m_queryCanceledCommand = -1;
|
|
388 |
m_timeoutCommand = -1;
|
|
389 |
}
|
|
390 |
|
|
391 |
void PhoneGlobalNotes::ProgressDialogClosed(
|
|
392 |
const CHbDeviceProgressDialogSymbian* )
|
|
393 |
{
|
|
394 |
PHONE_TRACE
|
|
395 |
if (iProgressDialog) {
|
|
396 |
delete iProgressDialog;
|
|
397 |
iProgressDialog = 0;
|
|
398 |
}
|
|
399 |
}
|
|
400 |
|
|
401 |
|