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