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