|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Profile plug-in publisher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include <ecom/implementationproxy.h> |
|
21 #include <aicontentobserver.h> |
|
22 #include <aiutility.h> |
|
23 #include <aipspropertyobserver.h> |
|
24 #include <PUAcodes.hrh> |
|
25 #include <aipluginsettings.h> |
|
26 #include <badesca.h> |
|
27 #include <fbs.h> |
|
28 #include <gulicon.h> |
|
29 #include <AknsSkinInstance.h> |
|
30 #include <AknsUtils.h> |
|
31 #include <AknsConstants.h> |
|
32 #include <e32property.h> |
|
33 #include <activeidle2domainpskeys.h> |
|
34 |
|
35 #include "sapidatapluginconst.h" |
|
36 #include "sapidatapluginuids.hrh" |
|
37 #include "sapidataplugin.h" |
|
38 #include "sapidata.h" |
|
39 |
|
40 // CONST CLASS VARIABLES |
|
41 const TImplementationProxy KImplementationTable[] = |
|
42 { |
|
43 IMPLEMENTATION_PROXY_ENTRY( KImplUidDataPlugin, CSapiDataPlugin::NewL ) |
|
44 }; |
|
45 |
|
46 // ======== MEMBER FUNCTIONS ======== |
|
47 // --------------------------------------------------------------------------- |
|
48 // Constructs and returns an application object. |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount ) |
|
52 { |
|
53 aTableCount = sizeof( KImplementationTable ) / |
|
54 sizeof( TImplementationProxy ); |
|
55 return KImplementationTable; |
|
56 } |
|
57 |
|
58 // ======== MEMBER FUNCTIONS ======== |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Symbian 2nd phase constructor can leave |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CSapiDataPlugin* CSapiDataPlugin::NewL() |
|
65 { |
|
66 CSapiDataPlugin* self = new (ELeave) CSapiDataPlugin; |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Default constructor |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CSapiDataPlugin::CSapiDataPlugin() |
|
78 { |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Symbian 2nd phase constructor can leave |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CSapiDataPlugin::ConstructL() |
|
86 { |
|
87 iInfo.iUid.iUid = SAPIDP_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_DATAPLUGIN; |
|
88 iPluginState = ENone; |
|
89 iHSForeGround = EFalse; |
|
90 iNetworkStatus = EUnknown; |
|
91 iData = CSapiData::NewL(this); |
|
92 |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Destructor |
|
97 // Deletes all data created to heap |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CSapiDataPlugin::~CSapiDataPlugin() |
|
101 { |
|
102 // deactivate the publishers |
|
103 if( iData ) |
|
104 { |
|
105 TRAP_IGNORE(iData->DeActivateL()); |
|
106 delete iData; |
|
107 } |
|
108 iObservers.Close(); |
|
109 Release( iContent ); |
|
110 iDataArray.ResetAndDestroy(); |
|
111 |
|
112 if( iContentModel) |
|
113 { |
|
114 for( TInt i = iDataCount-1;i>=0 ; i-- ) |
|
115 { |
|
116 User::Free((TAny*)iContentModel[i].cid); |
|
117 } |
|
118 delete []iContentModel; |
|
119 } |
|
120 iIconArray.Reset(); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // From class CAiContentPublisher |
|
125 // Plug-ins take ownership of the settings array, so it must either |
|
126 // store it in a member or free it. |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CSapiDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
|
130 { |
|
131 if( iDataCount > 0 ) |
|
132 { |
|
133 // We own the array so destroy it |
|
134 aSettings.ResetAndDestroy(); |
|
135 return; |
|
136 } |
|
137 |
|
138 RAiSettingsItemArray contentItemsArr; |
|
139 RAiSettingsItemArray configurationItemsArr; |
|
140 |
|
141 TInt count = aSettings.Count(); |
|
142 for(TInt i = 0; i < count; i++ ) |
|
143 { |
|
144 MAiPluginSettings* pluginSetting = aSettings[i]; |
|
145 if( pluginSetting->AiPluginItemType() == EAiPluginContentItem ) |
|
146 { |
|
147 contentItemsArr.Append(pluginSetting); |
|
148 } |
|
149 else if( pluginSetting->AiPluginItemType() == EAiPluginConfigurationItem ) |
|
150 { |
|
151 configurationItemsArr.Append(pluginSetting); |
|
152 } |
|
153 } |
|
154 iDataCount = contentItemsArr.Count(); |
|
155 if(iDataCount > 0 ) |
|
156 { |
|
157 // Create the content Model |
|
158 HBufC* contentId = HBufC::NewLC( KAiContentIdMaxLength + KAiPluginNameMaxLength ); |
|
159 iContentModel = new TAiContentItem[iDataCount]; |
|
160 for(TInt i = 0; i < iDataCount; i++) |
|
161 { |
|
162 MAiPluginContentItem& contentItem = (contentItemsArr[i])->AiPluginContentItem(); |
|
163 iContentModel[i].id = i; |
|
164 if( contentItem.Type() == KText() || contentItem.Type() == KNewsTicker() ) |
|
165 { |
|
166 // text |
|
167 iContentModel[i].type = KAiContentTypeText; |
|
168 } |
|
169 if( contentItem.Type() == KImage() ) |
|
170 { |
|
171 // image |
|
172 iContentModel[i].type = KAiContentTypeBitmap; |
|
173 } |
|
174 |
|
175 contentId->Des().Copy(contentItem.Name()); |
|
176 contentId->Des().Delete(0, contentId->Des().LocateReverse(KPluginNameSeprator) +1); |
|
177 |
|
178 TInt sizeOfContentId = contentId->Des().Size()+sizeof(wchar_t); |
|
179 iContentModel[i].cid = static_cast<const wchar_t*>( User::Alloc( sizeOfContentId ) ); |
|
180 Mem::Copy((TAny*)iContentModel[i].cid, contentId->Des().PtrZ(), sizeOfContentId); |
|
181 |
|
182 contentId->Des().Delete( 0, contentId->Des().Length()); |
|
183 } |
|
184 |
|
185 CleanupStack::PopAndDestroy( contentId ); |
|
186 iContent = AiUtility::CreateContentItemArrayIteratorL( iContentModel, iDataCount ); |
|
187 // Configurations |
|
188 iData->ConfigureL(configurationItemsArr); |
|
189 |
|
190 // Activate the publisher |
|
191 iData->ActivateL(); |
|
192 |
|
193 // Register for notifications |
|
194 iData->RegisterPublisherObserverL(); |
|
195 |
|
196 PublishL(); |
|
197 |
|
198 iPluginState = ESuspend; |
|
199 iData->RegisterContentObserverL(); |
|
200 } |
|
201 contentItemsArr.Reset(); |
|
202 configurationItemsArr.Reset(); |
|
203 // We own the array so destroy it |
|
204 aSettings.ResetAndDestroy(); |
|
205 // publish the initial data |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // Publishes widget's texts and images |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CSapiDataPlugin::PublishL() |
|
213 { |
|
214 TInt err( KErrNone ); |
|
215 User::LeaveIfError( iRfs.Connect() ); |
|
216 |
|
217 TInt observers( iObservers.Count() ); |
|
218 TInt transactionId = reinterpret_cast<TInt>( this ); |
|
219 |
|
220 for ( int i = 0; i < observers; i++ ) |
|
221 { |
|
222 MAiContentObserver* observer = iObservers[i]; |
|
223 |
|
224 if ( observer->StartTransaction( transactionId ) == KErrNone ) |
|
225 { |
|
226 // Publish all the data |
|
227 iData->PublishL(observer, KAll ); |
|
228 observer->Commit( transactionId ); |
|
229 } |
|
230 |
|
231 // Release memory of the published text |
|
232 iDataArray.ResetAndDestroy(); |
|
233 // Release memory of the published icons |
|
234 iIconArray.Reset(); |
|
235 |
|
236 } |
|
237 iRfs.Close(); |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // Publish a specific text of the widget |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CSapiDataPlugin::PublishTextL(MAiContentObserver* aObserver, |
|
245 TInt& aContentId, TDesC& aContentValue) |
|
246 { |
|
247 if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) |
|
248 { |
|
249 if( aContentValue.Length() > 0 ) |
|
250 { |
|
251 HBufC* contentText = HBufC::NewLC(aContentValue.Size()); |
|
252 TPtr cDes = contentText->Des(); |
|
253 cDes.Copy(aContentValue); |
|
254 aObserver->Publish( *this, aContentId, cDes, aContentId ); |
|
255 iDataArray.AppendL( contentText ); |
|
256 CleanupStack::Pop( contentText ); |
|
257 } |
|
258 else |
|
259 { |
|
260 aObserver->Clean( *this, aContentId, aContentId ); |
|
261 } |
|
262 } |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // Publish a specific image of the widget |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver, |
|
270 TInt aContentId, TDesC& aPath ) |
|
271 { |
|
272 TInt err = KErrNone; |
|
273 TAknsItemID iconId; |
|
274 iconId.iMajor=0; |
|
275 iconId.iMinor=0; |
|
276 TInt bitmapId(0); |
|
277 TInt maskId(0); |
|
278 TFileName fileName; |
|
279 CGulIcon* icon = NULL; |
|
280 CFbsBitmap* bitmap = NULL; |
|
281 CFbsBitmap* mask = NULL; |
|
282 |
|
283 if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) |
|
284 { |
|
285 TBool inSkin = iData->ResolveSkinIdAndMifId( aPath, iconId, bitmapId, maskId, fileName ); |
|
286 if ( inSkin ) |
|
287 { |
|
288 // Load from skin |
|
289 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
290 if ( iconId.iMajor != 0 && iconId.iMajor!=0 ) |
|
291 { |
|
292 // Create icon with fall back |
|
293 TRAP_IGNORE(AknsUtils::CreateIconL( |
|
294 skin, |
|
295 iconId, |
|
296 bitmap, |
|
297 mask, |
|
298 fileName, /* backup filename */ |
|
299 bitmapId, /* backup bit map id */ |
|
300 maskId)); /* backup mask id */ |
|
301 } |
|
302 else if( bitmapId !=0 ) |
|
303 { |
|
304 if ( maskId!=0 ) |
|
305 { |
|
306 // Create icon from Mif filename , bitmap id and mask id |
|
307 TRAP_IGNORE(icon = AknsUtils::CreateGulIconL( |
|
308 skin, |
|
309 iconId, |
|
310 fileName, |
|
311 bitmapId, |
|
312 maskId) ); |
|
313 } |
|
314 else |
|
315 { |
|
316 TRAP_IGNORE(AknsUtils::CreateIconL( |
|
317 skin, |
|
318 iconId, |
|
319 bitmap, |
|
320 fileName, /* backup filename */ |
|
321 bitmapId)); /* backup bit map id */ |
|
322 } |
|
323 } |
|
324 |
|
325 if ( icon == NULL && bitmap != NULL ) |
|
326 { |
|
327 icon = CGulIcon::NewL( bitmap, mask ); |
|
328 } |
|
329 |
|
330 if ( icon != NULL ) // Syntax correct but icon not found |
|
331 { |
|
332 aObserver->PublishPtr( *this, aContentId, icon , aContentId ); |
|
333 iIconArray.Append(icon); |
|
334 } |
|
335 else |
|
336 { |
|
337 err = KErrNotFound; |
|
338 aObserver->Clean( *this, aContentId, aContentId ); |
|
339 } |
|
340 } |
|
341 else // Interpret as File path |
|
342 { |
|
343 RFile* iconFile = new (ELeave) RFile(); |
|
344 err = iconFile->Open( iRfs, aPath, EFileShareReadersOnly | EFileRead ); |
|
345 if( err == KErrNone ) |
|
346 { |
|
347 aObserver->Publish( *this, aContentId, *iconFile, aContentId ); |
|
348 } |
|
349 else |
|
350 { |
|
351 aObserver->Clean( *this, aContentId, aContentId ); |
|
352 } |
|
353 iconFile->Close(); |
|
354 delete iconFile; |
|
355 iconFile = NULL; |
|
356 } |
|
357 } |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // Publish a image of the widget |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 void CSapiDataPlugin::PublishImageL(MAiContentObserver* aObserver, |
|
365 TInt& aContentId, TInt aHandle, TInt aMaskHandle ) |
|
366 { |
|
367 if ( aObserver->CanPublish( *this, aContentId , aContentId ) ) |
|
368 { |
|
369 if( aHandle != KErrBadHandle ) |
|
370 { |
|
371 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
|
372 if( KErrNone == bitmap->Duplicate( aHandle) ) |
|
373 { |
|
374 // Take the ownership |
|
375 CGulIcon* icon = CGulIcon::NewL(bitmap); |
|
376 if( aMaskHandle != KErrBadHandle ) |
|
377 { |
|
378 CFbsBitmap* mask = new (ELeave) CFbsBitmap(); |
|
379 if (KErrNone == mask->Duplicate( aMaskHandle) ) |
|
380 { |
|
381 icon->SetMask( mask ); |
|
382 } |
|
383 } |
|
384 aObserver->PublishPtr( *this, aContentId, icon , aContentId ); |
|
385 iIconArray.Append(icon); |
|
386 } |
|
387 else |
|
388 { |
|
389 delete bitmap; |
|
390 bitmap = NULL; |
|
391 aObserver->Clean( *this, aContentId, aContentId ); |
|
392 } |
|
393 } |
|
394 } |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // Gets the id of a content |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 TInt CSapiDataPlugin::GetIdL( TDesC& aObjectId) |
|
402 { |
|
403 TInt id = KErrNotFound; |
|
404 for( TInt i = 0;i< iDataCount; i++ ) |
|
405 { |
|
406 if( aObjectId == ContentCid(iContentModel[i] ) ) |
|
407 { |
|
408 id = iContentModel[i].id; |
|
409 break; |
|
410 } |
|
411 } |
|
412 return id; |
|
413 } |
|
414 |
|
415 |
|
416 // --------------------------------------------------------------------------- |
|
417 // Gets type of a content |
|
418 // --------------------------------------------------------------------------- |
|
419 // |
|
420 const TDesC& CSapiDataPlugin::GetTypeL(TDesC& aObjectId ) |
|
421 { |
|
422 for( TInt i = 0;i< iDataCount; i++ ) |
|
423 { |
|
424 if( aObjectId == ContentCid(iContentModel[i]) ) |
|
425 { |
|
426 if( iContentModel[i].type == KAiContentTypeText) |
|
427 { |
|
428 return KText(); |
|
429 } |
|
430 else if( iContentModel[i].type == KAiContentTypeBitmap) |
|
431 { |
|
432 return KImage(); |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 return KNullDesC(); |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------------------------- |
|
441 //Refresh a specific image of text in the widget |
|
442 // --------------------------------------------------------------------------- |
|
443 // |
|
444 void CSapiDataPlugin::RefreshL(TDesC& aContentType, TDesC& aOperation) |
|
445 { |
|
446 TInt err( KErrNone ); |
|
447 User::LeaveIfError( iRfs.Connect() ); |
|
448 TInt observers( iObservers.Count() ); |
|
449 TInt transactionId = reinterpret_cast<TInt>( this ); |
|
450 |
|
451 for ( TInt obsIndex = 0; obsIndex < observers; obsIndex++ ) |
|
452 { |
|
453 MAiContentObserver* observer = iObservers[obsIndex]; |
|
454 |
|
455 if ( observer->StartTransaction( transactionId ) == KErrNone ) |
|
456 { |
|
457 if ( aOperation != KOperationDelete ) |
|
458 { |
|
459 iData->PublishL( observer, aContentType ); |
|
460 } |
|
461 else |
|
462 { |
|
463 iData->RemoveL( observer, aContentType ); |
|
464 } |
|
465 |
|
466 observer->Commit( transactionId ); |
|
467 } |
|
468 |
|
469 // Relese memory of the published text |
|
470 iDataArray.ResetAndDestroy(); |
|
471 iIconArray.Reset(); |
|
472 } |
|
473 iRfs.Close(); |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------------------------- |
|
477 // Cleans a data from the widget |
|
478 // --------------------------------------------------------------------------- |
|
479 // |
|
480 void CSapiDataPlugin::Clean(MAiContentObserver* aObserver, |
|
481 TInt& aContentId ) |
|
482 { |
|
483 if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
|
484 { |
|
485 aObserver->Clean( *this, aContentId, aContentId ); |
|
486 } |
|
487 |
|
488 } |
|
489 // --------------------------------------------------------------------------- |
|
490 // From class CAiContentPublisher |
|
491 // Plug-in is requested to unload its engines due backup operation |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 void CSapiDataPlugin::Stop( TAiTransitionReason aReason ) |
|
495 { |
|
496 if( iPluginState == EResume ) |
|
497 { |
|
498 Suspend( aReason ); |
|
499 } |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // From class CAiContentPublisher |
|
504 // Plug-in is instructed that it is allowed to consume CPU resources |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 void CSapiDataPlugin::Resume( TAiTransitionReason aReason ) |
|
508 { |
|
509 TRAP_IGNORE( DoResumeL( aReason ) ); |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // From class CAiContentPublisher |
|
514 // Plug-in is instructed that it is not allowed to consume CPU resources |
|
515 // --------------------------------------------------------------------------- |
|
516 // |
|
517 void CSapiDataPlugin::Suspend( TAiTransitionReason aReason ) |
|
518 { |
|
519 switch( aReason ) |
|
520 { |
|
521 case EAiKeylockDisabled: |
|
522 case EAiKeylockEnabled: |
|
523 { |
|
524 // handled in resume |
|
525 break; |
|
526 } |
|
527 default : |
|
528 { |
|
529 iPluginState = ESuspend; |
|
530 TRAP_IGNORE ( iData->SuspendL() ); |
|
531 } |
|
532 } |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // From class CAiContentPublisher |
|
537 // The plug-in MUST maintain a registry of subscribers and send |
|
538 // notification to all of them whenever the state changes or new content |
|
539 // is available |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 void CSapiDataPlugin::SubscribeL( MAiContentObserver& aObserver ) |
|
543 { |
|
544 iObservers.AppendL( &aObserver ); |
|
545 } |
|
546 |
|
547 |
|
548 // --------------------------------------------------------------------------- |
|
549 // From class CAiContentPublisher |
|
550 // Returns the extension interface. Actual type depends on the passed |
|
551 // aUid argument. |
|
552 // --------------------------------------------------------------------------- |
|
553 // |
|
554 TAny* CSapiDataPlugin::Extension( TUid aUid ) |
|
555 { |
|
556 if ( aUid == KExtensionUidProperty ) |
|
557 { |
|
558 return static_cast<MAiPropertyExtension*>( this ); |
|
559 } |
|
560 else if (aUid == KExtensionUidEventHandler) |
|
561 { |
|
562 return static_cast<MAiEventHandlerExtension*>( this ); |
|
563 } |
|
564 else |
|
565 { |
|
566 return NULL; |
|
567 } |
|
568 } |
|
569 |
|
570 // --------------------------------------------------------------------------- |
|
571 // From class MAiPropertyExtension |
|
572 // Read property of publisher plug-in. |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 TAny* CSapiDataPlugin::GetPropertyL( TInt aProperty ) |
|
576 { |
|
577 TAny* property = NULL; |
|
578 |
|
579 switch ( aProperty ) |
|
580 { |
|
581 case EAiPublisherInfo: |
|
582 { |
|
583 property = static_cast<TAiPublisherInfo*>( &iInfo ); |
|
584 break; |
|
585 } |
|
586 |
|
587 case EAiPublisherContent: |
|
588 { |
|
589 property = static_cast<MAiContentItemIterator*>( iContent ); |
|
590 break; |
|
591 } |
|
592 default: |
|
593 break; |
|
594 } |
|
595 |
|
596 return property; |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------------------------- |
|
600 // From class MAiPropertyExtension |
|
601 // Write property value to optimize the content model. |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 void CSapiDataPlugin::SetPropertyL( TInt aProperty, TAny* aValue ) |
|
605 { |
|
606 if( aProperty == EAiPublisherInfo ) |
|
607 { |
|
608 ASSERT( aValue ); |
|
609 |
|
610 const TAiPublisherInfo* info( |
|
611 static_cast<const TAiPublisherInfo*>( aValue ) ); |
|
612 |
|
613 iInfo = *info; |
|
614 |
|
615 iData->SetContentIdL( info->iNamespace ); |
|
616 } |
|
617 } |
|
618 |
|
619 // --------------------------------------------------------------------------- |
|
620 // From class MAiEventHandlerExtension. |
|
621 // Handles an event sent by the AI framework. |
|
622 // --------------------------------------------------------------------------- |
|
623 // |
|
624 void CSapiDataPlugin::HandleEvent( TInt /*aEvent*/, const TDesC& /*aParam*/ ) |
|
625 { |
|
626 // This is not as there is no event id to retrieve in this dynamic plugin. |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // From class MAiEventHandlerExtension. |
|
631 // Handles an event sent by the AI framework. |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 void CSapiDataPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam ) |
|
635 { |
|
636 // We have no way of reporting errors to framework so just ignore them. |
|
637 TRAP_IGNORE(iData->ExecuteActionL( aEventName , aParam ) ); |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------------------------- |
|
641 // From class MAiEventHandlerExtension. |
|
642 // Invoked by the framework for querying if plugin has menu item |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 TBool CSapiDataPlugin::HasMenuItem( const TDesC& aMenuItem ) |
|
646 { |
|
647 return iData->HasMenuItem ( aMenuItem ); |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // From class CAiContentPublisher |
|
652 // framework instructs plug-in that it is allowed to consume CPU resources |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 void CSapiDataPlugin::DoResumeL( TAiTransitionReason aReason ) |
|
656 { |
|
657 //update in startup phase and idle is on foreground. |
|
658 switch ( aReason ) |
|
659 { |
|
660 case EAiIdleOnLine: |
|
661 { |
|
662 iNetworkStatus = EOnline; |
|
663 iData->OnLineL(); |
|
664 break; |
|
665 } |
|
666 case EAiIdleOffLine: |
|
667 { |
|
668 iNetworkStatus = EOffline; |
|
669 iData->OffLineL(); |
|
670 break; |
|
671 } |
|
672 case EAiIdlePageSwitch: |
|
673 { |
|
674 if ( iPluginState == EResume ) |
|
675 { |
|
676 iData->SuspendL(); |
|
677 } |
|
678 iPluginState = EInActive; |
|
679 iData->InActiveL(); |
|
680 } |
|
681 break; |
|
682 case EAiSystemStartup: |
|
683 case EAiIdleForeground: |
|
684 { |
|
685 iHSForeGround = ETrue; |
|
686 } |
|
687 case EAiBacklightOn: |
|
688 { |
|
689 if ( iPluginState == ESuspend ) |
|
690 { |
|
691 iPluginState = EResume; |
|
692 iData->ResumeL(); |
|
693 } |
|
694 break; |
|
695 } |
|
696 case EAiKeylockDisabled: |
|
697 { |
|
698 // Key lock events considered only if HS is in foreground |
|
699 if ( iHSForeGround && iPluginState == ESuspend ) |
|
700 { |
|
701 iPluginState = EResume; |
|
702 iData->ResumeL(); |
|
703 } |
|
704 break; |
|
705 } |
|
706 case EAiKeylockEnabled: |
|
707 { |
|
708 // Key lock events considered only if HS is in foreground |
|
709 if ( iHSForeGround && iPluginState == EResume ) |
|
710 { |
|
711 iPluginState = ESuspend ; |
|
712 iData->SuspendL(); |
|
713 } |
|
714 break; |
|
715 } |
|
716 case EAiScreenLayoutChanged: |
|
717 { |
|
718 // ignore events |
|
719 break; |
|
720 } |
|
721 case EAiGeneralThemeChanged: |
|
722 { |
|
723 // ignore event |
|
724 break; |
|
725 } |
|
726 case EAiIdleBackground: |
|
727 { |
|
728 iHSForeGround = EFalse; |
|
729 } |
|
730 default : |
|
731 { |
|
732 if ( iPluginState == EResume ) |
|
733 { |
|
734 iPluginState = ESuspend; |
|
735 iData->SuspendL(); |
|
736 } |
|
737 break; |
|
738 } |
|
739 } |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------------------------- |
|
743 // Is plugin active to publish the data |
|
744 // --------------------------------------------------------------------------- |
|
745 // |
|
746 TBool CSapiDataPlugin::IsActive() |
|
747 { |
|
748 return (iPluginState == EResume ); |
|
749 } |