|
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: Avkon discreet popup ui server handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikcmobs.h> |
|
20 #include <avkon.hrh> |
|
21 #include "akndiscreetpopupserverhandler.h" |
|
22 #include "akndiscreetpopupdata.h" |
|
23 |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CAknDiscreetPopupServerHandler::NewL |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CAknDiscreetPopupServerHandler* CAknDiscreetPopupServerHandler::NewL() |
|
32 { |
|
33 CAknDiscreetPopupServerHandler* self = |
|
34 CAknDiscreetPopupServerHandler::NewLC(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CAknDiscreetPopupServerHandler::NewLC |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CAknDiscreetPopupServerHandler* CAknDiscreetPopupServerHandler::NewLC() |
|
45 { |
|
46 CAknDiscreetPopupServerHandler* self = |
|
47 new ( ELeave ) CAknDiscreetPopupServerHandler(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CAknDiscreetPopupServerHandler::~CAknDiscreetPopupServerHandler |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CAknDiscreetPopupServerHandler::~CAknDiscreetPopupServerHandler() |
|
59 { |
|
60 iLaunchers.ResetAndDestroy(); |
|
61 iUiServer.Close(); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CAknDiscreetPopupServerHandler::LaunchGlobalPopup |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CAknDiscreetPopupServerHandler::LaunchGlobalPopupL( |
|
70 const TDesC& aTitle, |
|
71 const TDesC& aText, |
|
72 const TAknsItemID& aSkinId, |
|
73 const TDesC& aBitmapFile, |
|
74 const TInt& aBitmapId, |
|
75 const TInt& aMaskId, |
|
76 const TInt& aFlags, |
|
77 const TInt& aCommandId, |
|
78 const TInt& aPopupId, |
|
79 MEikCommandObserver* aCommandObserver, |
|
80 const TUid& aAppUid, |
|
81 const TUid& aViewUid ) |
|
82 { |
|
83 CAknDiscreetPopupGlobalParamLauncher* launcher = |
|
84 CAknDiscreetPopupGlobalParamLauncher::NewL( this, |
|
85 aCommandObserver, |
|
86 aCommandId, |
|
87 aPopupId, |
|
88 aAppUid, |
|
89 aViewUid ); |
|
90 CleanupStack::PushL( launcher ); |
|
91 launcher->SetData( |
|
92 aTitle, |
|
93 aText, |
|
94 aSkinId, |
|
95 aBitmapFile, |
|
96 aBitmapId, |
|
97 aMaskId, |
|
98 aFlags ); |
|
99 iLaunchers.AppendL( launcher ); |
|
100 CleanupStack::Pop( launcher ); |
|
101 launcher->LaunchDiscreetPopup(); |
|
102 } |
|
103 |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CAknDiscreetPopupServerHandler::LaunchGlobalPopup |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CAknDiscreetPopupServerHandler::LaunchGlobalPopupL( |
|
110 const TInt aResourceId, |
|
111 const TDesC& aResourceFile, |
|
112 const TInt& aCommandId, |
|
113 const TInt& aPopupId, |
|
114 MEikCommandObserver* aCommandObserver, |
|
115 const TUid& aAppUid, |
|
116 const TUid& aViewUid ) |
|
117 { |
|
118 CAknDiscreetPopupGlobalResourceLauncher* launcher = |
|
119 CAknDiscreetPopupGlobalResourceLauncher::NewL( this, |
|
120 aCommandObserver, |
|
121 aCommandId, |
|
122 aPopupId, |
|
123 aAppUid, |
|
124 aViewUid ); |
|
125 CleanupStack::PushL( launcher ); |
|
126 launcher->SetData( |
|
127 aResourceId, |
|
128 aResourceFile ); |
|
129 iLaunchers.AppendL( launcher ); |
|
130 CleanupStack::Pop( launcher ); |
|
131 launcher->LaunchDiscreetPopup(); |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CAknDiscreetPopupServerHandler::PopupClosed |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CAknDiscreetPopupServerHandler::PopupClosed( |
|
140 CAknDiscreetPopupGlobalLauncher* aLauncher ) |
|
141 { |
|
142 for ( TInt i = 0; i < iLaunchers.Count(); i++ ) |
|
143 { |
|
144 if ( iLaunchers[ i ] == aLauncher ) |
|
145 { |
|
146 iLaunchers.Remove( i ); |
|
147 delete aLauncher; |
|
148 break; |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CAknDiscreetPopupServerHandler::UiServer |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 RAknUiServer* CAknDiscreetPopupServerHandler::UiServer() |
|
159 { |
|
160 return &iUiServer; |
|
161 } |
|
162 |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CAknDiscreetPopupServerHandler::CheckPopupId |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 TInt CAknDiscreetPopupServerHandler::CheckPopupId( const TInt& aPopupId ) |
|
169 { |
|
170 TInt popupId( aPopupId ); |
|
171 while ( PopupIdInUse( popupId ) ) |
|
172 { |
|
173 popupId++; |
|
174 } |
|
175 return popupId; |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CAknDiscreetPopupServerHandler::CAknDiscreetPopupServerHandler |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 CAknDiscreetPopupServerHandler::CAknDiscreetPopupServerHandler() |
|
184 { |
|
185 } |
|
186 |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CAknDiscreetPopupServerHandler::ConstructL |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CAknDiscreetPopupServerHandler::ConstructL() |
|
193 { |
|
194 User::LeaveIfError( iUiServer.Connect() ); |
|
195 } |
|
196 |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // CAknDiscreetPopupServerHandler::PopupIdInUse |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 TBool CAknDiscreetPopupServerHandler::PopupIdInUse( const TInt& aPopupId ) |
|
203 { |
|
204 TInt popupId( 0 ); |
|
205 for ( TInt i = 0; i < iLaunchers.Count(); i++ ) |
|
206 { |
|
207 popupId = static_cast<TAknDiscreetPopupLaunchData*>( |
|
208 iLaunchers[ i ]->PopupData() )->PopupId(); |
|
209 if ( popupId == aPopupId ) |
|
210 { |
|
211 return ETrue; |
|
212 } |
|
213 } |
|
214 return EFalse; |
|
215 } |
|
216 |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CAknDiscreetPopupGlobalLauncher::~CAknDiscreetPopupGlobalLauncher |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 CAknDiscreetPopupGlobalLauncher::~CAknDiscreetPopupGlobalLauncher() |
|
223 { |
|
224 if ( IsActive() && iHandler ) |
|
225 { |
|
226 // Cancel request using status handle |
|
227 TAknDiscreetPopupCancelRequestData cancelData; |
|
228 cancelData.SetStatusHandle( ( TUint ) &iStatus ); |
|
229 iHandler->UiServer()->DoDiscreetPopupAction( &cancelData ); |
|
230 } |
|
231 Cancel(); |
|
232 } |
|
233 |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CAknDiscreetPopupGlobalLauncher::LaunchDiscreetPopup |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CAknDiscreetPopupGlobalLauncher::LaunchDiscreetPopup() |
|
240 { |
|
241 if ( IsActive() ) |
|
242 { |
|
243 return; |
|
244 } |
|
245 RenewRequest(); |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // CAknDiscreetPopupGlobalLauncher::RunL |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CAknDiscreetPopupGlobalLauncher::RunL() |
|
254 { |
|
255 if ( iStatus.Int() != KRequestPending ) |
|
256 { |
|
257 if( iCommandObserver ) |
|
258 { |
|
259 if( iStatus.Int() == KErrCompletion && iCommandId ) |
|
260 { |
|
261 iCommandObserver->ProcessCommandL( iCommandId ); |
|
262 } |
|
263 iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose ); |
|
264 } |
|
265 if ( iHandler ) |
|
266 { |
|
267 iHandler->PopupClosed( this ); |
|
268 } |
|
269 } |
|
270 else |
|
271 { |
|
272 RenewRequest(); |
|
273 } |
|
274 } |
|
275 |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CAknDiscreetPopupGlobalLauncher::DoCancel |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CAknDiscreetPopupGlobalLauncher::DoCancel() |
|
282 { |
|
283 } |
|
284 |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CAknDiscreetPopupGlobalLauncher::CAknDiscreetPopupGlobalLauncher |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 CAknDiscreetPopupGlobalLauncher::CAknDiscreetPopupGlobalLauncher( |
|
291 CAknDiscreetPopupServerHandler* aHandler, |
|
292 MEikCommandObserver* aObserver, |
|
293 const TInt& aCommandId ) |
|
294 : |
|
295 CActive( EPriorityStandard ), |
|
296 iCommandObserver( aObserver ), |
|
297 iCommandId( aCommandId ), |
|
298 iHandler( aHandler ) |
|
299 { |
|
300 } |
|
301 |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // CAknDiscreetPopupGlobalLauncher::ConstructL |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 void CAknDiscreetPopupGlobalLauncher::ConstructL() |
|
308 { |
|
309 CActiveScheduler::Add( this ); |
|
310 } |
|
311 |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // CAknDiscreetPopupGlobalLauncher::RenewRequest |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 void CAknDiscreetPopupGlobalLauncher::RenewRequest() |
|
318 { |
|
319 if ( iHandler ) |
|
320 { |
|
321 iHandler->UiServer()->DoDiscreetPopupAction( PopupData(), &iStatus ); |
|
322 } |
|
323 SetActive(); |
|
324 } |
|
325 |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CAknDiscreetPopupGlobalParamLauncher::~CAknDiscreetPopupGlobalParamLauncher |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 CAknDiscreetPopupGlobalParamLauncher::~CAknDiscreetPopupGlobalParamLauncher() |
|
332 { |
|
333 } |
|
334 |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // CAknDiscreetPopupGlobalParamLauncher::NewL |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 CAknDiscreetPopupGlobalParamLauncher* CAknDiscreetPopupGlobalParamLauncher::NewL( |
|
341 CAknDiscreetPopupServerHandler* aHandler, |
|
342 MEikCommandObserver* aObserver, |
|
343 const TInt& aCommandId, |
|
344 const TInt& aPopupId, |
|
345 const TUid& aAppUid, |
|
346 const TUid& aViewUid ) |
|
347 { |
|
348 CAknDiscreetPopupGlobalParamLauncher* self = |
|
349 new ( ELeave ) CAknDiscreetPopupGlobalParamLauncher( |
|
350 aHandler, aObserver, aCommandId, aPopupId, aAppUid, aViewUid ); |
|
351 CleanupStack::PushL( self ); |
|
352 self->ConstructL(); |
|
353 CleanupStack::Pop( self ); |
|
354 return self; |
|
355 } |
|
356 |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CAknDiscreetPopupGlobalParamLauncher::SetData |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 void CAknDiscreetPopupGlobalParamLauncher::SetData( |
|
363 const TDesC& aTitle, |
|
364 const TDesC& aText, |
|
365 const TAknsItemID& aSkinId, |
|
366 const TDesC& aBitmapFile, |
|
367 const TInt& aBitmapId, |
|
368 const TInt& aMaskId, |
|
369 const TInt& aFlags ) |
|
370 { |
|
371 iPopupData.SetTitleText( aTitle ); |
|
372 iPopupData.SetBodyText( aText ); |
|
373 iPopupData.SetSkinId( aSkinId ); |
|
374 iPopupData.SetBitmapFile( aBitmapFile ); |
|
375 iPopupData.SetBitmapId( aBitmapId ); |
|
376 iPopupData.SetMaskId( aMaskId ); |
|
377 iPopupData.SetFlags( aFlags ); |
|
378 } |
|
379 |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // CAknDiscreetPopupGlobalParamLauncher::CAknDiscreetPopupGlobalParamLauncher |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 CAknDiscreetPopupGlobalParamLauncher::CAknDiscreetPopupGlobalParamLauncher( |
|
386 CAknDiscreetPopupServerHandler* aHandler, |
|
387 MEikCommandObserver* aObserver, |
|
388 const TInt& aCommandId, |
|
389 const TInt& aPopupId, |
|
390 const TUid& aAppUid, |
|
391 const TUid& aViewUid ) |
|
392 : CAknDiscreetPopupGlobalLauncher( aHandler, |
|
393 aObserver, |
|
394 aCommandId ) |
|
395 { |
|
396 iPopupData.SetPopupId( aPopupId ); |
|
397 iPopupData.SetAppUid( aAppUid ); |
|
398 iPopupData.SetViewUid( aViewUid ); |
|
399 if ( aAppUid == TUid::Null() && !aCommandId ) |
|
400 { |
|
401 iPopupData.SetAction( EFalse ); |
|
402 } |
|
403 else |
|
404 { |
|
405 iPopupData.SetAction( ETrue ); |
|
406 } |
|
407 } |
|
408 |
|
409 |
|
410 // --------------------------------------------------------------------------- |
|
411 // CAknDiscreetPopupGlobalParamLauncher::PopupData |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 TAknDiscreetPopupData* CAknDiscreetPopupGlobalParamLauncher::PopupData() |
|
415 { |
|
416 return &iPopupData; |
|
417 } |
|
418 |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // CAknDiscreetPopupGlobalResourceLauncher::~CAknDiscreetPopupGlobalResourceLauncher |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 CAknDiscreetPopupGlobalResourceLauncher::~CAknDiscreetPopupGlobalResourceLauncher() |
|
425 { |
|
426 } |
|
427 |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CAknDiscreetPopupGlobalResourceLauncher::NewL |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 CAknDiscreetPopupGlobalResourceLauncher* CAknDiscreetPopupGlobalResourceLauncher::NewL( |
|
434 CAknDiscreetPopupServerHandler* aHandler, |
|
435 MEikCommandObserver* aObserver, |
|
436 const TInt& aCommandId, |
|
437 const TInt& aPopupId, |
|
438 const TUid& aAppUid, |
|
439 const TUid& aViewUid ) |
|
440 { |
|
441 CAknDiscreetPopupGlobalResourceLauncher* self = |
|
442 new ( ELeave ) CAknDiscreetPopupGlobalResourceLauncher( |
|
443 aHandler, aObserver, aCommandId, aPopupId, aAppUid, aViewUid ); |
|
444 CleanupStack::PushL( self ); |
|
445 self->ConstructL(); |
|
446 CleanupStack::Pop( self ); |
|
447 return self; |
|
448 } |
|
449 |
|
450 |
|
451 // --------------------------------------------------------------------------- |
|
452 // CAknDiscreetPopupGlobalResourceLauncher::SetData |
|
453 // --------------------------------------------------------------------------- |
|
454 // |
|
455 void CAknDiscreetPopupGlobalResourceLauncher::SetData( |
|
456 const TInt aResourceId, |
|
457 const TDesC& aResourceFile ) |
|
458 { |
|
459 iPopupData.SetResourceFile( aResourceFile ); |
|
460 iPopupData.SetResourceId( aResourceId ); |
|
461 } |
|
462 |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // CAknDiscreetPopupGlobalResourceLauncher::CAknDiscreetPopupGlobalResourceLauncher |
|
466 // --------------------------------------------------------------------------- |
|
467 // |
|
468 CAknDiscreetPopupGlobalResourceLauncher::CAknDiscreetPopupGlobalResourceLauncher( |
|
469 CAknDiscreetPopupServerHandler* aHandler, |
|
470 MEikCommandObserver* aObserver, |
|
471 const TInt& aCommandId, |
|
472 const TInt& aPopupId, |
|
473 const TUid& aAppUid, |
|
474 const TUid& aViewUid ) |
|
475 : CAknDiscreetPopupGlobalLauncher( aHandler, |
|
476 aObserver, |
|
477 aCommandId ) |
|
478 { |
|
479 iPopupData.SetPopupId( aPopupId ); |
|
480 iPopupData.SetAppUid( aAppUid ); |
|
481 iPopupData.SetViewUid( aViewUid ); |
|
482 if ( aAppUid == TUid::Null() && !aCommandId ) |
|
483 { |
|
484 iPopupData.SetAction( EFalse ); |
|
485 } |
|
486 else |
|
487 { |
|
488 iPopupData.SetAction( ETrue ); |
|
489 } |
|
490 } |
|
491 |
|
492 |
|
493 // --------------------------------------------------------------------------- |
|
494 // CAknDiscreetPopupGlobalResourceLauncher::PopupData |
|
495 // --------------------------------------------------------------------------- |
|
496 // |
|
497 TAknDiscreetPopupData* CAknDiscreetPopupGlobalResourceLauncher::PopupData() |
|
498 { |
|
499 return &iPopupData; |
|
500 } |
|
501 |