1 /* |
|
2 * Copyright (c) 2005-2006 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: Shortcut plug-in shortcut extensions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aicontentobserver.h> |
|
20 #include <gulicon.h> |
|
21 #include <fbs.h> |
|
22 #include <e32property.h> |
|
23 |
|
24 #include "caiscutshortcutext.h" |
|
25 #include "aiscutcontentmodel.h" |
|
26 #include "caiscuttarget.h" |
|
27 #include "caiscutengineext.h" |
|
28 #include "PopupFSM.h" |
|
29 #include "cpopupeventhandler.h" |
|
30 #include "maiscutextdata.h" |
|
31 #include "activeidle2domainpskeys.h" |
|
32 |
|
33 #include "debug.h" |
|
34 |
|
35 |
|
36 // P&S access policies |
|
37 _LIT_SECURITY_POLICY_C1( KAiScutReadPolicy, ECapabilityReadDeviceData ); |
|
38 _LIT_SECURITY_POLICY_C1( KAiScutWritePolicy, ECapabilityWriteDeviceData ); |
|
39 |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CAiScutShortcutExt* CAiScutShortcutExt::NewL( |
|
48 TInt aId, const TDesC& aTarget, CAiScutEngine& aEngine ) |
|
49 { |
|
50 CAiScutShortcutExt* self = CAiScutShortcutExt::NewLC( |
|
51 aId, aTarget, aEngine ); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CAiScutShortcutExt* CAiScutShortcutExt::NewLC( |
|
61 TInt aId, const TDesC& aTarget, CAiScutEngine& aEngine ) |
|
62 { |
|
63 CAiScutShortcutExt* self = new( ELeave ) CAiScutShortcutExt( |
|
64 aId, aEngine ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL( aTarget ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CAiScutShortcutExt::~CAiScutShortcutExt() |
|
75 { |
|
76 delete iPopupEventHandler; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CAiScutShortcutExt::CAiScutShortcutExt( TInt aId, CAiScutEngine& aEngine ) |
|
84 : CAiScutShortcut( aId, aEngine )//, |
|
85 //iPublishLineArray( EFalse ) |
|
86 { |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CAiScutShortcutExt::ConstructL( const TDesC& aTarget ) |
|
94 { |
|
95 iPopupEventHandler = CPopupEventHandler::NewL( *this ); |
|
96 CAiScutShortcut::ConstructL( aTarget ); |
|
97 |
|
98 RProperty::Define( |
|
99 KPSUidAiInformation, |
|
100 KActiveIdleThemeSupportsXsp, |
|
101 RProperty::EInt, |
|
102 KAiScutReadPolicy, |
|
103 KAiScutWritePolicy ); |
|
104 RProperty::Set( KPSUidAiInformation, KActiveIdleThemeSupportsXsp, EPSAiXspNotSupported ); |
|
105 } |
|
106 |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 TPtrC CAiScutShortcutExt::ActiveTargetDefinition() const |
|
113 { |
|
114 if( iActiveTarget ) |
|
115 { |
|
116 return iActiveTarget->Definition(); |
|
117 } |
|
118 return KNullDesC(); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CAiScutShortcutExt::HandleAIEventL( TInt aEvent ) |
|
126 { |
|
127 switch ( aEvent ) |
|
128 { |
|
129 case EAiScutEventLoseFocus: |
|
130 { |
|
131 iPopupEventHandler->PopupFSM().HandleLostFocus(); |
|
132 break; |
|
133 } |
|
134 case EAiScutEventGainFocus: |
|
135 { |
|
136 iPopupEventHandler->PopupFSM().HandleGotFocus(); |
|
137 break; |
|
138 } |
|
139 default: |
|
140 { |
|
141 break; |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CAiScutShortcutExt::HandleResumed( TAiTransitionReason aResumeReason ) |
|
151 { |
|
152 switch( aResumeReason ) |
|
153 { |
|
154 case EAiIdleBackground: |
|
155 { |
|
156 iPopupEventHandler->PopupFSM().HandleBackground(); |
|
157 break; |
|
158 } |
|
159 case EAiIdleForeground: |
|
160 { |
|
161 // Handleforeground() calls unnecessary publishes in case nothing |
|
162 // has changed. |
|
163 if ( iTextChanged || iIconChanged ) |
|
164 { |
|
165 iPopupEventHandler->PopupFSM().HandleForeground(); |
|
166 } |
|
167 break; |
|
168 } |
|
169 default: |
|
170 { |
|
171 break; |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 void CAiScutShortcutExt::SetAiScutExtData( |
|
181 const MAiScutExtData* aAiScutExtData ) |
|
182 { |
|
183 iAiScutExtData = aAiScutExtData; |
|
184 |
|
185 const MDesCArray* newPopupLineArray = |
|
186 aAiScutExtData ? aAiScutExtData->PopupLineArray() : NULL; |
|
187 const CGulIcon* newIcon = |
|
188 aAiScutExtData ? aAiScutExtData->Icon() : NULL; |
|
189 |
|
190 if( iPreviousPopupLineArray != newPopupLineArray && |
|
191 newPopupLineArray ) |
|
192 { |
|
193 iTextChanged = ETrue; |
|
194 iPopupEventHandler->PopupFSM().HandleUpdate(); |
|
195 } |
|
196 else if( iPreviousPopupLineArray && !newPopupLineArray ) |
|
197 { |
|
198 iTextChanged = ETrue; |
|
199 iPopupEventHandler->PopupFSM().HandleReset(); |
|
200 } |
|
201 |
|
202 if( iPreviousIcon != newIcon ) |
|
203 { |
|
204 iIconChanged = ETrue; |
|
205 CAiScutEngineExt& engine = static_cast< CAiScutEngineExt& > ( iEngine ); |
|
206 engine.CheckAccessAndPublish( *this ); |
|
207 } |
|
208 |
|
209 iPreviousPopupLineArray = newPopupLineArray; |
|
210 iPreviousIcon = newIcon; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 void CAiScutShortcutExt::PublishL( |
|
218 MAiPropertyExtension& aPlugin, MAiContentObserver& aObserver ) |
|
219 { |
|
220 if( iLastPublishedTarget && iActiveTarget && |
|
221 iLastPublishedTarget->Definition() != iActiveTarget->Definition() ) |
|
222 { |
|
223 iAiScutExtData = NULL; |
|
224 iPopupEventHandler->PopupFSM().HandleReset(); |
|
225 } |
|
226 |
|
227 if( aObserver.CanPublish( |
|
228 aPlugin, KAiScutContent[EAiScutContentPopupTextFirstLine].id, iId) && |
|
229 aObserver.CanPublish( |
|
230 aPlugin, KAiScutContent[EAiScutContentPopupTextSecondLine].id, iId) && |
|
231 aObserver.CanPublish( |
|
232 aPlugin, KAiScutContent[EAiScutContentPopupTextThirdLine].id, iId) ) |
|
233 { |
|
234 PublishPopupText( aPlugin, aObserver ); |
|
235 RProperty::Set( KPSUidAiInformation, KActiveIdleThemeSupportsXsp, EPSAiXspIsSupported ); |
|
236 } |
|
237 |
|
238 CAiScutShortcut::PublishL( aPlugin, aObserver ); |
|
239 iTextChanged = EFalse; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 TInt CAiScutShortcutExt::PublishCaption( |
|
247 MAiPropertyExtension& aPlugin, MAiContentObserver& aObserver, |
|
248 TInt aCaptionContentId ) const |
|
249 { |
|
250 if( iPopupEventHandler->PublishCaption() ) |
|
251 { |
|
252 if( !iPopupEventHandler->CaptionVisible() ) |
|
253 { |
|
254 return aObserver.Clean( aPlugin, aCaptionContentId, iId ); |
|
255 } |
|
256 else |
|
257 { |
|
258 return CAiScutShortcut::PublishCaption( |
|
259 aPlugin, aObserver, aCaptionContentId ); |
|
260 } |
|
261 } |
|
262 else |
|
263 { |
|
264 return CAiScutShortcut::PublishCaption( |
|
265 aPlugin, aObserver, aCaptionContentId ); |
|
266 } |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 void CAiScutShortcutExt::PublishPopupText( |
|
274 MAiPropertyExtension& aPlugin, MAiContentObserver& aObserver ) const |
|
275 { |
|
276 if( iPopupEventHandler->PublishPopup() ) |
|
277 { |
|
278 TAiScutContentIds popupTextContentIds[] = |
|
279 { |
|
280 EAiScutContentPopupTextFirstLine, |
|
281 EAiScutContentPopupTextSecondLine, |
|
282 EAiScutContentPopupTextThirdLine |
|
283 }; |
|
284 const TInt idCount = |
|
285 sizeof( popupTextContentIds ) / sizeof( TAiScutContentIds ); |
|
286 |
|
287 TInt err = KErrNone; |
|
288 |
|
289 //iLineArray is set or reset via xSP API. iPublishLineArray is controlled |
|
290 //by state machine in iPopupEventHandler |
|
291 if( iAiScutExtData && iAiScutExtData->PopupLineArray() && |
|
292 iPopupEventHandler->PopupVisible() ) |
|
293 { |
|
294 //Publish caption line in popup text box |
|
295 TPtrC captionDes; |
|
296 TInt captionResId = iActiveTarget->GetCaption( captionDes, EAiScutLongTitle ); |
|
297 |
|
298 if ( captionResId == 0 ) |
|
299 { |
|
300 // Publish descriptor |
|
301 err = aObserver.Publish( aPlugin, |
|
302 KAiScutContent[ EAiScutContentPopupTextCaptionLine ].id, |
|
303 captionDes, iId ); |
|
304 if( err != KErrNone ) |
|
305 { |
|
306 __PRINT( __DBG_FORMAT( "XAI: publish Popup caption text err = %d" ), err ); |
|
307 } |
|
308 } |
|
309 else if ( captionResId > 0 ) |
|
310 { |
|
311 // Publish resource |
|
312 err = aObserver.Publish( aPlugin, |
|
313 KAiScutContent[ EAiScutContentPopupTextCaptionLine ].id, |
|
314 captionResId, iId ); |
|
315 if( err != KErrNone ) |
|
316 { |
|
317 __PRINT( __DBG_FORMAT( "XAI: publish Popup caption text (resource) err = %d" ), err ); |
|
318 } |
|
319 } |
|
320 |
|
321 const MDesCArray& lineArray = *iAiScutExtData->PopupLineArray(); |
|
322 TInt numberOfLines = lineArray.MdcaCount(); |
|
323 //Iterate each popup text content and either publish or clean it |
|
324 //depending on the number or lines in iLineArray |
|
325 for( TInt i = 0; i < idCount; i++ ) |
|
326 { |
|
327 if( numberOfLines > i ) |
|
328 { |
|
329 err = aObserver.Publish( aPlugin, |
|
330 KAiScutContent[ popupTextContentIds[ i ] ].id, |
|
331 lineArray.MdcaPoint( i ), iId ); |
|
332 if( err != KErrNone ) |
|
333 { |
|
334 __PRINT( __DBG_FORMAT( "XAI: publish Popup text err = %d" ), err ); |
|
335 } |
|
336 } |
|
337 else |
|
338 { |
|
339 err = aObserver.Clean( aPlugin, |
|
340 KAiScutContent[ popupTextContentIds[ i ] ].id, iId ); |
|
341 if( err != KErrNone ) |
|
342 { |
|
343 __PRINT( __DBG_FORMAT( "XAI: clean Popup text err = %d" ), err ); |
|
344 } |
|
345 } |
|
346 } |
|
347 } |
|
348 else |
|
349 { |
|
350 //Clean each popup text content |
|
351 for( TInt i = 0; i < idCount; i++ ) |
|
352 { |
|
353 err = aObserver.Clean( aPlugin, |
|
354 KAiScutContent[ popupTextContentIds[ i ] ].id, iId ); |
|
355 if ( err != KErrNone ) |
|
356 { |
|
357 __PRINT( __DBG_FORMAT( "XAI: clean Popup text err = %d" ), err ); |
|
358 } |
|
359 } |
|
360 } |
|
361 } |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 TInt CAiScutShortcutExt::PublishIcon( MAiPropertyExtension& aPlugin, |
|
369 MAiContentObserver& aObserver, TInt aIconContentId ) |
|
370 { |
|
371 if( aIconContentId == KAiScutContent[EAiScutContentShortcutIcon].id && |
|
372 iAiScutExtData && iAiScutExtData->Icon() ) |
|
373 { |
|
374 const CGulIcon& icon = *iAiScutExtData->Icon(); |
|
375 CGulIcon* duplicatedIcon = NULL; |
|
376 TRAP_IGNORE( |
|
377 CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap(); |
|
378 CleanupStack::PushL( bitmap ); |
|
379 CFbsBitmap* mask = new( ELeave ) CFbsBitmap(); |
|
380 CleanupStack::PushL( mask ); |
|
381 |
|
382 User::LeaveIfError( bitmap->Duplicate( icon.Bitmap()->Handle() ) ); |
|
383 User::LeaveIfError( mask->Duplicate( icon.Mask()->Handle() ) ); |
|
384 |
|
385 duplicatedIcon = CGulIcon::NewL( bitmap, mask ); |
|
386 |
|
387 CleanupStack::Pop( 2, bitmap ); |
|
388 ); |
|
389 |
|
390 if( duplicatedIcon ) |
|
391 { |
|
392 TInt err = aObserver.PublishPtr( aPlugin, |
|
393 aIconContentId, duplicatedIcon, iId ); |
|
394 if( err != KErrNone ) |
|
395 { |
|
396 delete duplicatedIcon; |
|
397 } |
|
398 return err; |
|
399 } |
|
400 } |
|
401 |
|
402 TInt err = CAiScutShortcut::PublishIcon( aPlugin, aObserver, aIconContentId ); |
|
403 iIconChanged = EFalse; |
|
404 return err; |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 void CAiScutShortcutExt::IssuePublishShortcut() |
|
412 { |
|
413 // iPublishLineArray = aVisiblePopup; |
|
414 CAiScutEngineExt& engine = static_cast< CAiScutEngineExt& >( iEngine ); |
|
415 engine.CheckAccessAndPublish( *this ); |
|
416 } |
|
417 |
|
418 |
|
419 // End of File. |
|