|
1 /* |
|
2 * Copyright (c) 2002-2008 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: AVKON global confirmation query. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknNotifyStd.h> |
|
19 #include <avkon.rsg> |
|
20 #include <eikbtgpc.h> |
|
21 #include <eikenv.h> |
|
22 #include <avkon.hrh> |
|
23 #include <bautils.h> |
|
24 #include <aknnotpi.rsg> |
|
25 #include <AknQueryDialog.h> |
|
26 #include <aknQueryControl.h> |
|
27 #include "aknsystemconfirmationpopup.h" |
|
28 #include <s32mem.h> |
|
29 #include <uikon/eiksrvui.h> |
|
30 #include <AknNotifySignature.h> |
|
31 #include <AknsUtils.h> |
|
32 #include <aknconsts.h> |
|
33 |
|
34 #include "AknAppsKeyCleanup.inl" |
|
35 |
|
36 #include <AknMediatorFacade.h> |
|
37 #include <aknSDData.h> |
|
38 #include <SecondaryDisplay/AknSecondaryDisplayDefs.h> |
|
39 |
|
40 const TInt KCharsInTInt = 4; // TInt32 takes 4 chars. |
|
41 |
|
42 // ============================================================================= |
|
43 // Confirmation query dialog. |
|
44 // ============================================================================= |
|
45 |
|
46 CAknQueryNotificationDialog::CAknQueryNotificationDialog( |
|
47 MAknQueryNotificationCallback* aCallBack, |
|
48 CAknQueryNotificationDialog** aSelfPtr, |
|
49 TInt aSoftkeys, |
|
50 TInt aAnimation, |
|
51 CEikImage* aImage, |
|
52 const TTone aTone, |
|
53 TBool aEveryKeyDismisses, |
|
54 TInt aImageId, |
|
55 TInt aMaskId) |
|
56 : CAknQueryDialog(aTone), |
|
57 iSoftkeys(aSoftkeys), |
|
58 iAnimation(aAnimation), |
|
59 iImage(aImage), |
|
60 iCallBack(aCallBack), |
|
61 iSelfPtr(aSelfPtr), |
|
62 iEveryKeyDismisses(aEveryKeyDismisses), |
|
63 iImageId(aImageId), |
|
64 iMaskId(aMaskId) |
|
65 { |
|
66 } |
|
67 |
|
68 void CAknQueryNotificationDialog::PostLayoutDynInitL() |
|
69 { |
|
70 if (iSoftkeys) |
|
71 { |
|
72 // If softkeys are given, the resource id must point to a valid resource. |
|
73 // Trying to use invalid softkeys can cause panic. |
|
74 if (!(iCoeEnv->IsResourceAvailableL(iSoftkeys))) |
|
75 { |
|
76 User::Leave(KErrArgument); |
|
77 } |
|
78 |
|
79 ButtonGroupContainer().SetCommandSetL(iSoftkeys); |
|
80 } |
|
81 |
|
82 if (iImage || iAnimation) |
|
83 { |
|
84 CAknQueryControl* control = STATIC_CAST(CAknQueryControl*, ControlOrNull(EGeneralQuery)); |
|
85 if (control && iImage) |
|
86 { |
|
87 control->SetImageL(iImage); |
|
88 iImage = 0; // Ownership to query. |
|
89 } |
|
90 else if (control && iAnimation) |
|
91 { |
|
92 control->SetAnimationL(iAnimation); |
|
93 } |
|
94 else if (control && iImageId) |
|
95 { |
|
96 // Bitmaps from avkon skinned in query. |
|
97 control->SetImageL(KAvkonBitmapFile, iImageId, iMaskId); |
|
98 } |
|
99 } |
|
100 CAknQueryDialog::PostLayoutDynInitL(); |
|
101 } |
|
102 |
|
103 CAknQueryNotificationDialog::~CAknQueryNotificationDialog() |
|
104 { |
|
105 if (iImage && iImage->IsPictureOwnedExternally()) |
|
106 { |
|
107 delete ((CApaMaskedBitmap*) iImage->Bitmap()); |
|
108 } |
|
109 |
|
110 delete iImage; |
|
111 |
|
112 if (iSelfPtr) |
|
113 { |
|
114 *iSelfPtr = NULL; |
|
115 } |
|
116 } |
|
117 |
|
118 TKeyResponse CAknQueryNotificationDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
119 TEventCode aType) |
|
120 { |
|
121 |
|
122 if (aType != EEventKey) |
|
123 { |
|
124 if (aKeyEvent.iScanCode == EStdKeyYes) |
|
125 { |
|
126 return EKeyWasConsumed; |
|
127 } |
|
128 else |
|
129 { |
|
130 return EKeyWasNotConsumed; |
|
131 } |
|
132 } |
|
133 |
|
134 if (iEveryKeyDismisses) |
|
135 { |
|
136 TryExitL(EEikBidCancel); |
|
137 return EKeyWasConsumed; |
|
138 } |
|
139 |
|
140 if (aKeyEvent.iScanCode == EStdKeyYes) |
|
141 { |
|
142 return EKeyWasConsumed; |
|
143 } |
|
144 |
|
145 TInt code = aKeyEvent.iCode; |
|
146 |
|
147 switch (code) |
|
148 { |
|
149 case EKeyOK: |
|
150 { |
|
151 // If left softkey is empty, disable ok key. |
|
152 TInt cmd = ButtonGroupContainer().ButtonGroup()->CommandId(0); |
|
153 if (cmd) |
|
154 { |
|
155 TryExitL(cmd); |
|
156 return EKeyWasConsumed; |
|
157 } |
|
158 } |
|
159 } |
|
160 |
|
161 return CAknQueryDialog::OfferKeyEventL(aKeyEvent, aType); |
|
162 } |
|
163 |
|
164 TBool CAknQueryNotificationDialog::OkToExitL(TInt aButtonId) |
|
165 { |
|
166 if (!iEveryKeyDismisses && aButtonId == EAknSoftkeyEmpty) |
|
167 { |
|
168 return EFalse; // R_AKN_SOFTKEYS_EMPTY uses ids :( |
|
169 } |
|
170 |
|
171 TInt ret = -1; |
|
172 if (aButtonId != EAknSoftkeyCancel) |
|
173 { |
|
174 ret = aButtonId; |
|
175 } |
|
176 iCallBack->QueryDismissedL(ret); |
|
177 return ETrue; |
|
178 } |
|
179 |
|
180 void CAknQueryNotificationDialog::CEikDialog_Reserved_1() |
|
181 { |
|
182 } |
|
183 |
|
184 void CAknQueryNotificationDialog::CEikDialog_Reserved_2() |
|
185 { |
|
186 } |
|
187 |
|
188 void CAknQueryNotificationDialog::CAknDialog_Reserved() |
|
189 { |
|
190 } |
|
191 |
|
192 void CAknQueryNotificationDialog::CAknQueryDialog_Reserved() |
|
193 { |
|
194 } |
|
195 |
|
196 // ============================================================================= |
|
197 // Confirmation query subject. |
|
198 // ============================================================================= |
|
199 |
|
200 CAknGlobalConfirmationQuerySubject* CAknGlobalConfirmationQuerySubject::NewL() |
|
201 { |
|
202 CAknGlobalConfirmationQuerySubject* self = new (ELeave) CAknGlobalConfirmationQuerySubject(); |
|
203 CleanupStack::PushL(self); |
|
204 self->ConstructL(); |
|
205 CleanupStack::Pop(self); |
|
206 return self; |
|
207 } |
|
208 |
|
209 CAknGlobalConfirmationQuerySubject::CAknGlobalConfirmationQuerySubject() |
|
210 : iPending(EFalse) |
|
211 { |
|
212 iStoredEikonEnv = CEikonEnv::Static(); |
|
213 } |
|
214 |
|
215 void CAknGlobalConfirmationQuerySubject::ConstructL() |
|
216 { |
|
217 } |
|
218 |
|
219 CAknGlobalConfirmationQuerySubject::~CAknGlobalConfirmationQuerySubject() |
|
220 { |
|
221 //delete iDlg; |
|
222 Cancel(); |
|
223 |
|
224 // Complete the RMessage if we need to. |
|
225 if (iPending) |
|
226 { |
|
227 iMessage.Complete(KErrDied); |
|
228 } |
|
229 } |
|
230 |
|
231 void CAknGlobalConfirmationQuerySubject::Release() |
|
232 { |
|
233 delete this; |
|
234 } |
|
235 |
|
236 CAknGlobalConfirmationQuerySubject::TNotifierInfo CAknGlobalConfirmationQuerySubject::RegisterL() |
|
237 { |
|
238 iInfo.iUid = KAknGlobalConfirmationQueryUid; |
|
239 iInfo.iChannel = EAknNotifierChannelConfirmationQuery; |
|
240 iInfo.iPriority = ENotifierPriorityHigh; |
|
241 return iInfo; |
|
242 } |
|
243 |
|
244 CAknGlobalConfirmationQuerySubject::TNotifierInfo CAknGlobalConfirmationQuerySubject::Info() const |
|
245 { |
|
246 return iInfo; |
|
247 } |
|
248 |
|
249 TPtrC8 CAknGlobalConfirmationQuerySubject::StartL(const TDesC8& /*aBuffer*/) |
|
250 { |
|
251 return KNullDesC8(); |
|
252 } |
|
253 |
|
254 void CAknGlobalConfirmationQuerySubject::StartL(const TDesC8& aBuffer, TInt /*aReplySlot*/, |
|
255 const RMessagePtr2& aMessage) |
|
256 { |
|
257 if (iPending) |
|
258 { |
|
259 aMessage.Complete(KErrInUse); |
|
260 return; |
|
261 } |
|
262 |
|
263 RDesReadStream readStream(aBuffer); |
|
264 |
|
265 if (aBuffer.Length() < KCharsInTInt || readStream.ReadInt32L() != KAKNNOTIFIERSIGNATURE) |
|
266 { |
|
267 User::Leave(KErrArgument); |
|
268 } |
|
269 |
|
270 iMessage = aMessage; |
|
271 |
|
272 TBool everyKeyDismisses = readStream.ReadInt8L(); |
|
273 TInt softkeys = readStream.ReadInt32L(); |
|
274 TInt animation = readStream.ReadInt32L(); |
|
275 TInt imageId = readStream.ReadInt16L(); |
|
276 TInt imageMaskId = readStream.ReadInt16L(); |
|
277 TInt tone = readStream.ReadInt16L(); |
|
278 |
|
279 TInt textLength = readStream.ReadInt16L(); |
|
280 HBufC* text = HBufC::NewLC(textLength); |
|
281 TPtr textPtr = text->Des(); |
|
282 readStream >> textPtr; |
|
283 |
|
284 TInt imageFileLength = readStream.ReadInt16L(); |
|
285 TFileName imageFile; |
|
286 if (imageFileLength) |
|
287 { |
|
288 readStream >> imageFile; |
|
289 } |
|
290 |
|
291 TInt skinsMajor = readStream.ReadInt32L(); |
|
292 TInt skinsMinor = readStream.ReadInt32L(); |
|
293 |
|
294 CAknSDData* sddata = 0; |
|
295 if (readStream.ReadInt8L()) |
|
296 { |
|
297 sddata = new (ELeave) CAknSDData(); |
|
298 CleanupStack::PushL(sddata); |
|
299 readStream >> *sddata; |
|
300 } |
|
301 |
|
302 CEikImage* image = new (ELeave) CEikImage; |
|
303 CleanupStack::PushL(image); |
|
304 |
|
305 TAknsItemID id; |
|
306 id.Set(skinsMajor, skinsMinor); |
|
307 |
|
308 CFbsBitmap* bitmap = NULL; |
|
309 CFbsBitmap* mask = NULL; |
|
310 |
|
311 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
312 |
|
313 TRAPD(err, AknsUtils::CreateIconL( |
|
314 skin,id, |
|
315 bitmap, mask, |
|
316 imageFile, |
|
317 imageId, imageMaskId)); |
|
318 |
|
319 if (!err) |
|
320 { |
|
321 image->SetPicture(bitmap, mask); |
|
322 } |
|
323 else |
|
324 { |
|
325 CleanupStack::PopAndDestroy(image); |
|
326 image = 0; |
|
327 } |
|
328 |
|
329 delete iDlg; |
|
330 iDlg = NULL; |
|
331 |
|
332 // iDlg takes ownership of text buffers. |
|
333 iDlg = new (ELeave) CAknQueryNotificationDialog( |
|
334 this, |
|
335 &iDlg, |
|
336 softkeys, |
|
337 animation, |
|
338 image, |
|
339 (CAknQueryDialog::TTone)tone, |
|
340 everyKeyDismisses, |
|
341 imageId, |
|
342 imageMaskId); |
|
343 |
|
344 if (image) |
|
345 { |
|
346 CleanupStack::Pop(image); |
|
347 } |
|
348 |
|
349 if (sddata) |
|
350 { |
|
351 iDlg->PublishDialogL(sddata->iDialogIdx, sddata->iCategory); |
|
352 if (sddata->iAdditionalData) |
|
353 { |
|
354 CAknMediatorFacade* cover_info = AknMediatorFacade(iDlg); |
|
355 if (cover_info) |
|
356 { |
|
357 cover_info->BufStream() << *(sddata->iAdditionalData); |
|
358 cover_info->BufStream().CommitL(); |
|
359 } |
|
360 } |
|
361 CleanupStack::PopAndDestroy(sddata); |
|
362 } |
|
363 else |
|
364 { |
|
365 // If secondary display data hasn't been defined, then the unidentified |
|
366 // confirmation note identifier is published to the secondary display. |
|
367 iDlg->PublishDialogL(EAknUnidentifiedConfirmationNote, KAknSecondaryDisplayCategory); |
|
368 } |
|
369 |
|
370 if (!iAppsKeySuppressed) |
|
371 { |
|
372 ((CAknNotifierAppServerAppUi*)(iStoredEikonEnv->EikAppUi()))->SuppressAppSwitching(ETrue); |
|
373 } |
|
374 |
|
375 CleanupStack::PushL(TCleanupItem(ReleaseAppsKey, 0)); |
|
376 |
|
377 iDlg->ExecuteLD(R_GLOBAL_CONFIRMATION_QUERY, *text); |
|
378 |
|
379 CleanupStack::Pop(); // Apps key cleanup. |
|
380 CleanupStack::PopAndDestroy(text); |
|
381 |
|
382 iAppsKeySuppressed = ETrue; |
|
383 iPending = ETrue; |
|
384 } |
|
385 |
|
386 void CAknGlobalConfirmationQuerySubject::Cancel() |
|
387 { |
|
388 delete iDlg; |
|
389 iDlg = NULL; |
|
390 TRAP_IGNORE(QueryDismissedL(EAknSoftkeyCancel)); |
|
391 } |
|
392 |
|
393 TPtrC8 CAknGlobalConfirmationQuerySubject::UpdateL(const TDesC8& aBuffer) |
|
394 { |
|
395 if (!iDlg) |
|
396 { |
|
397 return KNullDesC8(); |
|
398 } |
|
399 |
|
400 // Get parameters. |
|
401 SAknNotifierPackage<SAknGlobalMsgQueryParams>* params |
|
402 = (SAknNotifierPackage<SAknGlobalMsgQueryParams>*)aBuffer.Ptr(); |
|
403 |
|
404 if (aBuffer.Length() < 0 |
|
405 || (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknGlobalMsgQueryParams>) |
|
406 || params->iSignature != KAKNNOTIFIERSIGNATURE) |
|
407 { |
|
408 User::Leave(KErrArgument); |
|
409 } |
|
410 |
|
411 if (params->iParamData.iCmd == EAknCancelGlobalQuery) |
|
412 { |
|
413 delete iDlg; |
|
414 iDlg = NULL; |
|
415 QueryDismissedL(EAknSoftkeyCancel); |
|
416 } |
|
417 else |
|
418 { |
|
419 // Update softkeys, but only if the resource id points to a valid resource. |
|
420 // Trying to use invalid softkeys can cause panic. |
|
421 if (iStoredEikonEnv->IsResourceAvailableL(params->iParamData.iSoftkeys)) |
|
422 { |
|
423 iDlg->ButtonGroupContainer().SetCommandSetL(params->iParamData.iSoftkeys); |
|
424 iDlg->ButtonGroupContainer().DrawNow(); |
|
425 |
|
426 CAknMediatorFacade* coverData = AknMediatorFacade(iDlg); |
|
427 if (coverData) |
|
428 { |
|
429 SAknIntegerUpdate s = |
|
430 { |
|
431 EAknGlobalNotifierUpdateSoftkeys, |
|
432 params->iParamData.iSoftkeys |
|
433 }; |
|
434 |
|
435 TPckg<SAknIntegerUpdate> pck(s); |
|
436 coverData->ResetBuffer(); |
|
437 coverData->BufStream() << pck; |
|
438 coverData->BufStream().CommitL(); |
|
439 coverData->PostUpdatedDataL(); |
|
440 } |
|
441 } |
|
442 else |
|
443 { |
|
444 // Invalid softkeys, dismiss query with error code. |
|
445 QueryDismissedL(KErrArgument); |
|
446 } |
|
447 } |
|
448 |
|
449 return KNullDesC8(); |
|
450 } |
|
451 |
|
452 void CAknGlobalConfirmationQuerySubject::QueryDismissedL(TInt aResult) |
|
453 { |
|
454 if (iPending) |
|
455 { |
|
456 iMessage.Complete(aResult); |
|
457 } |
|
458 |
|
459 iPending = EFalse; |
|
460 iReturnVal = NULL; |
|
461 |
|
462 if (iAppsKeySuppressed) |
|
463 { |
|
464 ((CAknNotifierAppServerAppUi*)(iStoredEikonEnv->EikAppUi()))->SuppressAppSwitching(EFalse); |
|
465 } |
|
466 iAppsKeySuppressed = EFalse; |
|
467 } |
|
468 |
|
469 // End of file |