73 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
74 // Default constructor |
77 // Default constructor |
75 // --------------------------------------------------------------------------- |
78 // --------------------------------------------------------------------------- |
76 // |
79 // |
77 CSapiDataPlugin::CSapiDataPlugin() |
80 CSapiDataPlugin::CSapiDataPlugin() |
|
81 : iNetworkStatus( EUnknown ), iPluginState( ENone ) |
78 { |
82 { |
79 } |
83 } |
80 |
84 |
81 // --------------------------------------------------------------------------- |
85 // --------------------------------------------------------------------------- |
82 // Symbian 2nd phase constructor can leave |
86 // Symbian 2nd phase constructor can leave |
83 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
84 // |
88 // |
85 void CSapiDataPlugin::ConstructL() |
89 void CSapiDataPlugin::ConstructL() |
86 { |
90 { |
87 iInfo.iUid.iUid = SAPIDP_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_DATAPLUGIN; |
91 User::LeaveIfError( iRfs.Connect() ); |
88 iPluginState = ENone; |
92 |
89 iHSForeGround = EFalse; |
93 iData = CSapiData::NewL( this ); |
90 iKeyLockOn = EFalse; |
|
91 iNetworkStatus = EUnknown; |
|
92 iData = CSapiData::NewL(this); |
|
93 |
|
94 } |
94 } |
95 |
95 |
96 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
97 // Destructor |
97 // Destructor |
98 // Deletes all data created to heap |
98 // Deletes all data created to heap |
99 // --------------------------------------------------------------------------- |
99 // --------------------------------------------------------------------------- |
100 // |
100 // |
101 CSapiDataPlugin::~CSapiDataPlugin() |
101 CSapiDataPlugin::~CSapiDataPlugin() |
102 { |
102 { |
103 // deactivate the publishers |
103 // deactivate the publishers |
104 if( iData ) |
104 if ( iData ) |
105 { |
105 { |
106 TRAP_IGNORE(iData->DeActivateL()); |
106 TRAP_IGNORE( iData->ChangePublisherStatusL( KDeActive )); |
|
107 |
107 delete iData; |
108 delete iData; |
108 } |
109 } |
|
110 |
109 iObservers.Close(); |
111 iObservers.Close(); |
110 Release( iContent ); |
112 Release( iContent ); |
|
113 |
111 iDataArray.ResetAndDestroy(); |
114 iDataArray.ResetAndDestroy(); |
112 |
115 |
113 if( iContentModel) |
116 if ( iContentModel ) |
114 { |
117 { |
115 for( TInt i = iDataCount-1;i>=0 ; i-- ) |
118 for ( TInt i = iDataCount - 1; i >= 0 ; i-- ) |
116 { |
119 { |
117 User::Free((TAny*)iContentModel[i].cid); |
120 User::Free((TAny*)iContentModel[i].cid); |
118 } |
121 } |
119 delete []iContentModel; |
122 |
120 } |
123 delete [] iContentModel; |
|
124 } |
|
125 |
121 iIconArray.Reset(); |
126 iIconArray.Reset(); |
122 } |
127 |
123 |
128 iRfs.Close(); |
124 // --------------------------------------------------------------------------- |
129 } |
125 // From class CAiContentPublisher |
130 |
126 // Plug-ins take ownership of the settings array, so it must either |
|
127 // store it in a member or free it. |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CSapiDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
|
131 { |
|
132 if( iDataCount > 0 ) |
|
133 { |
|
134 // We own the array so destroy it |
|
135 aSettings.ResetAndDestroy(); |
|
136 return; |
|
137 } |
|
138 |
|
139 RAiSettingsItemArray contentItemsArr; |
|
140 RAiSettingsItemArray configurationItemsArr; |
|
141 |
|
142 TInt count = aSettings.Count(); |
|
143 for(TInt i = 0; i < count; i++ ) |
|
144 { |
|
145 MAiPluginSettings* pluginSetting = aSettings[i]; |
|
146 if( pluginSetting->AiPluginItemType() == EAiPluginContentItem ) |
|
147 { |
|
148 contentItemsArr.Append(pluginSetting); |
|
149 } |
|
150 else if( pluginSetting->AiPluginItemType() == EAiPluginConfigurationItem ) |
|
151 { |
|
152 configurationItemsArr.Append(pluginSetting); |
|
153 } |
|
154 } |
|
155 iDataCount = contentItemsArr.Count(); |
|
156 if(iDataCount > 0 ) |
|
157 { |
|
158 // Create the content Model |
|
159 HBufC* contentId = HBufC::NewLC( KAiContentIdMaxLength + KAiPluginNameMaxLength ); |
|
160 iContentModel = new TAiContentItem[iDataCount]; |
|
161 for(TInt i = 0; i < iDataCount; i++) |
|
162 { |
|
163 MAiPluginContentItem& contentItem = (contentItemsArr[i])->AiPluginContentItem(); |
|
164 iContentModel[i].id = i; |
|
165 if( contentItem.Type() == KText() || contentItem.Type() == KNewsTicker() ) |
|
166 { |
|
167 // text |
|
168 iContentModel[i].type = KAiContentTypeText; |
|
169 } |
|
170 if( contentItem.Type() == KImage() ) |
|
171 { |
|
172 // image |
|
173 iContentModel[i].type = KAiContentTypeBitmap; |
|
174 } |
|
175 |
|
176 contentId->Des().Copy(contentItem.Name()); |
|
177 contentId->Des().Delete(0, contentId->Des().LocateReverse(KPluginNameSeprator) +1); |
|
178 |
|
179 TInt sizeOfContentId = contentId->Des().Size()+sizeof(wchar_t); |
|
180 iContentModel[i].cid = static_cast<const wchar_t*>( User::Alloc( sizeOfContentId ) ); |
|
181 Mem::Copy((TAny*)iContentModel[i].cid, contentId->Des().PtrZ(), sizeOfContentId); |
|
182 |
|
183 contentId->Des().Delete( 0, contentId->Des().Length()); |
|
184 } |
|
185 |
|
186 CleanupStack::PopAndDestroy( contentId ); |
|
187 iContent = AiUtility::CreateContentItemArrayIteratorL( iContentModel, iDataCount ); |
|
188 // Configurations |
|
189 iData->ConfigureL(configurationItemsArr); |
|
190 |
|
191 // Activate the publisher |
|
192 iData->ActivateL(); |
|
193 |
|
194 // Register for notifications |
|
195 iData->RegisterPublisherObserverL(); |
|
196 |
|
197 PublishL(); |
|
198 |
|
199 iPluginState = ESuspend; |
|
200 iData->RegisterContentObserverL(); |
|
201 } |
|
202 contentItemsArr.Reset(); |
|
203 configurationItemsArr.Reset(); |
|
204 // We own the array so destroy it |
|
205 aSettings.ResetAndDestroy(); |
|
206 // publish the initial data |
|
207 } |
|
208 |
131 |
209 // --------------------------------------------------------------------------- |
132 // --------------------------------------------------------------------------- |
210 // Publishes widget's texts and images |
133 // Publishes widget's texts and images |
211 // --------------------------------------------------------------------------- |
134 // --------------------------------------------------------------------------- |
212 // |
135 // |
213 void CSapiDataPlugin::PublishL() |
136 void CSapiDataPlugin::PublishL() |
214 { |
137 { |
215 User::LeaveIfError( iRfs.Connect() ); |
|
216 |
|
217 TInt observers( iObservers.Count() ); |
138 TInt observers( iObservers.Count() ); |
218 TInt transactionId = reinterpret_cast<TInt>( this ); |
139 TInt transactionId = reinterpret_cast<TInt>( this ); |
219 |
140 |
220 for ( int i = 0; i < observers; i++ ) |
141 for ( TInt i = 0; i < observers; i++ ) |
221 { |
142 { |
222 MAiContentObserver* observer = iObservers[i]; |
143 MAiContentObserver* observer = iObservers[i]; |
223 |
144 |
224 if ( observer->StartTransaction( transactionId ) == KErrNone ) |
145 if ( observer->StartTransaction( transactionId ) == KErrNone ) |
225 { |
146 { |
481 { |
400 { |
482 if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
401 if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
483 { |
402 { |
484 aObserver->Clean( *this, aContentId, aContentId ); |
403 aObserver->Clean( *this, aContentId, aContentId ); |
485 } |
404 } |
486 |
|
487 } |
405 } |
488 // --------------------------------------------------------------------------- |
406 |
489 // From class CAiContentPublisher |
407 // ---------------------------------------------------------------------------- |
490 // Plug-in is requested to unload its engines due backup operation |
408 // CSapiDataPlugin::Start |
491 // --------------------------------------------------------------------------- |
409 // |
492 // |
410 // ---------------------------------------------------------------------------- |
493 void CSapiDataPlugin::Stop( TAiTransitionReason aReason ) |
411 // |
494 { |
412 void CSapiDataPlugin::Start( TStartReason aReason ) |
495 if( iPluginState == EResume ) |
413 { |
496 { |
414 if( aReason == ESystemStartup ) |
497 Suspend( aReason ); |
415 { |
498 } |
416 TRAP_IGNORE( iData->SetStartupReasonL( KSystemStartup )); |
499 } |
417 } |
500 |
418 else if( aReason == EPageStartup ) |
501 // --------------------------------------------------------------------------- |
419 { |
502 // From class CAiContentPublisher |
420 TRAP_IGNORE( iData->SetStartupReasonL( KPageStartup )); |
503 // Plug-in is instructed that it is allowed to consume CPU resources |
421 } |
504 // --------------------------------------------------------------------------- |
422 else if( aReason == EPluginStartup ) |
505 // |
423 { |
506 void CSapiDataPlugin::Resume( TAiTransitionReason aReason ) |
424 TRAP_IGNORE( iData->SetStartupReasonL( KPluginStartup)); |
507 { |
425 } |
508 TRAP_IGNORE( DoResumeL( aReason ) ); |
426 } |
509 } |
427 |
510 |
428 // ---------------------------------------------------------------------------- |
511 // --------------------------------------------------------------------------- |
429 // CSapiDataPlugin::Stop |
512 // From class CAiContentPublisher |
430 // |
513 // Plug-in is instructed that it is not allowed to consume CPU resources |
431 // ---------------------------------------------------------------------------- |
514 // --------------------------------------------------------------------------- |
432 // |
515 // |
433 void CSapiDataPlugin::Stop( TStopReason aReason ) |
516 void CSapiDataPlugin::Suspend( TAiTransitionReason aReason ) |
434 { |
517 { |
435 if( aReason == ESystemShutdown ) |
518 switch( aReason ) |
436 { |
519 { |
437 TRAP_IGNORE( iData->ChangePublisherStatusL( KSystemShutdown )); |
520 case EAiKeylockDisabled: |
438 } |
521 case EAiKeylockEnabled: |
439 else if( aReason == EPageShutdown ) |
522 { |
440 { |
523 // handled in resume |
441 TRAP_IGNORE( iData->ChangePublisherStatusL( KPageShutdown )); |
524 TRAP_IGNORE( DoResumeL( aReason ) ); |
442 } |
525 break; |
443 else if( aReason == EPluginShutdown ) |
526 } |
444 { |
527 default : |
445 TRAP_IGNORE( iData->ChangePublisherStatusL( KPluginShutdown )); |
528 { |
446 } |
529 iPluginState = ESuspend; |
447 } |
530 TRAP_IGNORE ( iData->SuspendL() ); |
448 |
531 } |
449 // ---------------------------------------------------------------------------- |
532 } |
450 // CSapiDataPlugin::Resume |
533 } |
451 // |
534 |
452 // ---------------------------------------------------------------------------- |
535 // --------------------------------------------------------------------------- |
453 // |
536 // From class CAiContentPublisher |
454 void CSapiDataPlugin::Resume( TResumeReason aReason ) |
537 // The plug-in MUST maintain a registry of subscribers and send |
455 { |
538 // notification to all of them whenever the state changes or new content |
456 if ( aReason == EForeground ) |
539 // is available |
457 { |
540 // --------------------------------------------------------------------------- |
458 iPluginState = EResume; |
|
459 TRAP_IGNORE( iData->ChangePublisherStatusL( KResume )); |
|
460 } |
|
461 } |
|
462 |
|
463 // ---------------------------------------------------------------------------- |
|
464 // CSapiDataPlugin::Suspend |
|
465 // |
|
466 // ---------------------------------------------------------------------------- |
|
467 // |
|
468 void CSapiDataPlugin::Suspend( TSuspendReason aReason ) |
|
469 { |
|
470 if ( aReason == EBackground ) |
|
471 { |
|
472 iPluginState = ESuspend; |
|
473 TRAP_IGNORE( iData->ChangePublisherStatusL( KSuspend )); |
|
474 } |
|
475 } |
|
476 |
|
477 // ---------------------------------------------------------------------------- |
|
478 // CSapiDataPlugin::SetOnline |
|
479 // |
|
480 // ---------------------------------------------------------------------------- |
|
481 // |
|
482 void CSapiDataPlugin::SetOnline() |
|
483 { |
|
484 if ( iNetworkStatus != EOnline ) |
|
485 { |
|
486 iNetworkStatus = EOnline; |
|
487 TRAP_IGNORE( iData->ChangePublisherStatusL( KOnLine )); |
|
488 } |
|
489 } |
|
490 |
|
491 // ---------------------------------------------------------------------------- |
|
492 // CSapiDataPlugin::SetOffline |
|
493 // |
|
494 // ---------------------------------------------------------------------------- |
|
495 // |
|
496 void CSapiDataPlugin::SetOffline() |
|
497 { |
|
498 if ( iNetworkStatus != EOffline ) |
|
499 { |
|
500 iNetworkStatus = EOffline; |
|
501 TRAP_IGNORE( iData->ChangePublisherStatusL( KOffLine )); |
|
502 } |
|
503 } |
|
504 |
|
505 // ---------------------------------------------------------------------------- |
|
506 // CSapiDataPlugin::SubscribeL |
|
507 // |
|
508 // ---------------------------------------------------------------------------- |
541 // |
509 // |
542 void CSapiDataPlugin::SubscribeL( MAiContentObserver& aObserver ) |
510 void CSapiDataPlugin::SubscribeL( MAiContentObserver& aObserver ) |
543 { |
511 { |
544 iObservers.AppendL( &aObserver ); |
512 iObservers.AppendL( &aObserver ); |
545 } |
513 } |
546 |
514 |
547 |
515 // ---------------------------------------------------------------------------- |
548 // --------------------------------------------------------------------------- |
516 // CSapiDataPlugin::ConfigureL |
549 // From class CAiContentPublisher |
517 // |
550 // Returns the extension interface. Actual type depends on the passed |
518 // ---------------------------------------------------------------------------- |
551 // aUid argument. |
519 // |
552 // --------------------------------------------------------------------------- |
520 void CSapiDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
553 // |
521 { |
554 TAny* CSapiDataPlugin::Extension( TUid aUid ) |
522 if ( iDataCount > 0 ) |
|
523 { |
|
524 // We own the array so destroy it |
|
525 aSettings.ResetAndDestroy(); |
|
526 return; |
|
527 } |
|
528 |
|
529 RAiSettingsItemArray contentItemsArr; |
|
530 RAiSettingsItemArray configurationItemsArr; |
|
531 |
|
532 TInt count( aSettings.Count() ); |
|
533 |
|
534 for ( TInt i = 0; i < count; i++ ) |
|
535 { |
|
536 MAiPluginSettings* setting( aSettings[i] ); |
|
537 |
|
538 if ( setting->AiPluginItemType() == EAiPluginContentItem ) |
|
539 { |
|
540 contentItemsArr.Append( setting ); |
|
541 } |
|
542 else if ( setting->AiPluginItemType() == EAiPluginConfigurationItem ) |
|
543 { |
|
544 configurationItemsArr.Append( setting ); |
|
545 } |
|
546 } |
|
547 |
|
548 iDataCount = contentItemsArr.Count(); |
|
549 |
|
550 if ( iDataCount > 0 ) |
|
551 { |
|
552 // Create the content Model |
|
553 HBufC* contentId = HBufC::NewLC( |
|
554 KAiContentIdMaxLength + KAiPluginNameMaxLength ); |
|
555 |
|
556 iContentModel = new TAiContentItem[iDataCount]; |
|
557 |
|
558 for ( TInt i = 0; i < iDataCount; i++ ) |
|
559 { |
|
560 MAiPluginContentItem& contentItem( |
|
561 contentItemsArr[i]->AiPluginContentItem() ); |
|
562 |
|
563 iContentModel[i].id = i; |
|
564 |
|
565 if( contentItem.Type() == KText() || |
|
566 contentItem.Type() == KNewsTicker() || |
|
567 contentItem.Type() == KTextEditor() ) |
|
568 { |
|
569 // text |
|
570 iContentModel[i].type = KAiContentTypeText; |
|
571 } |
|
572 if( contentItem.Type() == KImage() ) |
|
573 { |
|
574 // image |
|
575 iContentModel[i].type = KAiContentTypeBitmap; |
|
576 } |
|
577 |
|
578 contentId->Des().Copy( contentItem.Name() ); |
|
579 contentId->Des().Delete( 0, |
|
580 contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 ); |
|
581 |
|
582 TInt sizeOfContentId( contentId->Des().Size() + sizeof( wchar_t ) ); |
|
583 |
|
584 iContentModel[i].cid = |
|
585 static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) ); |
|
586 |
|
587 Mem::Copy( ( TAny* )iContentModel[i].cid, |
|
588 contentId->Des().PtrZ(), sizeOfContentId ); |
|
589 |
|
590 contentId->Des().Delete( 0, contentId->Des().Length() ); |
|
591 } |
|
592 |
|
593 CleanupStack::PopAndDestroy( contentId ); |
|
594 |
|
595 iContent = AiUtility::CreateContentItemArrayIteratorL( |
|
596 iContentModel, iDataCount ); |
|
597 |
|
598 iData->SetContentIdL( PublisherInfo().Namespace() ); |
|
599 |
|
600 // Configurations |
|
601 iData->ConfigureL( configurationItemsArr ); |
|
602 |
|
603 // Activate the publisher |
|
604 iData->ChangePublisherStatusL( KActive ); |
|
605 |
|
606 // Register for notifications |
|
607 iData->RegisterPublisherObserverL(); |
|
608 |
|
609 PublishL(); |
|
610 |
|
611 iPluginState = ESuspend; |
|
612 |
|
613 iData->RegisterContentObserverL(); |
|
614 } |
|
615 |
|
616 contentItemsArr.Reset(); |
|
617 configurationItemsArr.Reset(); |
|
618 |
|
619 // We own the array so destroy it |
|
620 aSettings.ResetAndDestroy(); |
|
621 } |
|
622 |
|
623 // ---------------------------------------------------------------------------- |
|
624 // CSapiDataPlugin::GetProperty |
|
625 // |
|
626 // ---------------------------------------------------------------------------- |
|
627 // |
|
628 TAny* CSapiDataPlugin::GetProperty( TProperty aProperty ) |
555 { |
629 { |
556 if ( aUid == KExtensionUidProperty ) |
630 if ( aProperty == EPublisherContent ) |
557 { |
631 { |
558 return static_cast<MAiPropertyExtension*>( this ); |
632 return static_cast< MAiContentItemIterator* >( iContent ); |
559 } |
633 } |
560 else if (aUid == KExtensionUidEventHandler) |
634 |
561 { |
635 return NULL; |
562 return static_cast<MAiEventHandlerExtension*>( this ); |
636 } |
563 } |
637 |
564 else |
638 // ---------------------------------------------------------------------------- |
565 { |
639 // CSapiDataPlugin::HandleEvent |
566 return NULL; |
640 // |
567 } |
641 // ---------------------------------------------------------------------------- |
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 // |
642 // |
634 void CSapiDataPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam ) |
643 void CSapiDataPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam ) |
635 { |
644 { |
636 // We have no way of reporting errors to framework so just ignore them. |
645 TRAP_IGNORE( iData->ExecuteActionL( aEventName , aParam ) ); |
637 TRAP_IGNORE(iData->ExecuteActionL( aEventName , aParam ) ); |
646 } |
638 } |
647 |
639 |
648 // ---------------------------------------------------------------------------- |
640 // --------------------------------------------------------------------------- |
649 // CSapiDataPlugin::HasMenuItem |
641 // From class MAiEventHandlerExtension. |
650 // |
642 // Invoked by the framework for querying if plugin has menu item |
651 // ---------------------------------------------------------------------------- |
643 // --------------------------------------------------------------------------- |
652 // |
644 // |
653 TBool CSapiDataPlugin::HasMenuItem( const TDesC16& aMenuItem ) |
645 TBool CSapiDataPlugin::HasMenuItem( const TDesC& aMenuItem ) |
654 { |
646 { |
655 return iData->HasMenuItem ( aMenuItem ); |
647 return iData->HasMenuItem ( aMenuItem ); |
656 } |
648 } |
657 |
649 |
658 // ---------------------------------------------------------------------------- |
650 // --------------------------------------------------------------------------- |
659 // CSapiDataPlugin::IsActive |
651 // From class CAiContentPublisher |
660 // |
652 // framework instructs plug-in that it is allowed to consume CPU resources |
661 // ---------------------------------------------------------------------------- |
653 // --------------------------------------------------------------------------- |
662 // |
654 // |
663 TBool CSapiDataPlugin::IsActive() const |
655 void CSapiDataPlugin::DoResumeL( TAiTransitionReason aReason ) |
664 { |
656 { |
665 return iPluginState == EResume; |
657 //update in startup phase and idle is on foreground. |
666 } |
658 switch ( aReason ) |
667 |
659 { |
668 // ---------------------------------------------------------------------------- |
660 case EAiIdleOnLine: |
669 // CSapiDataPlugin::Data |
661 { |
670 // |
662 iNetworkStatus = EOnline; |
671 // ---------------------------------------------------------------------------- |
663 iData->OnLineL(); |
672 // |
664 break; |
673 CSapiData* CSapiDataPlugin::Data() const |
665 } |
674 { |
666 case EAiIdleOffLine: |
675 return iData; |
667 { |
676 } |
668 iNetworkStatus = EOffline; |
677 |
669 iData->OffLineL(); |
678 // ---------------------------------------------------------------------------- |
670 break; |
679 // CSapiDataPlugin::NetworkStatus |
671 } |
680 // |
672 case EAiIdlePageSwitch: |
681 // ---------------------------------------------------------------------------- |
673 { |
682 // |
674 if ( iPluginState == EResume ) |
683 CSapiDataPlugin::TPluginNetworkStatus CSapiDataPlugin::NetworkStatus() const |
675 { |
684 { |
676 iData->SuspendL(); |
685 return iNetworkStatus; |
677 } |
686 } |
678 iPluginState = EInActive; |
687 |
679 iData->InActiveL(); |
688 // End of file |
680 } |
|
681 break; |
|
682 case EAiSystemStartup: |
|
683 case EAiIdleForeground: |
|
684 { |
|
685 iHSForeGround = ETrue; |
|
686 } |
|
687 case EAiBacklightOn: |
|
688 { |
|
689 if ( iPluginState == ESuspend && !iKeyLockOn ) |
|
690 { |
|
691 iPluginState = EResume; |
|
692 iData->ResumeL(); |
|
693 } |
|
694 break; |
|
695 } |
|
696 case EAiKeylockDisabled: |
|
697 { |
|
698 iKeyLockOn = EFalse; |
|
699 // Key lock events considered only if HS is in foreground |
|
700 if ( iHSForeGround && iPluginState == ESuspend ) |
|
701 { |
|
702 iPluginState = EResume; |
|
703 iData->ResumeL(); |
|
704 } |
|
705 break; |
|
706 } |
|
707 case EAiKeylockEnabled: |
|
708 { |
|
709 iKeyLockOn = ETrue; |
|
710 // Key lock events considered only if HS is in foreground |
|
711 if ( iHSForeGround && iPluginState == EResume ) |
|
712 { |
|
713 iPluginState = ESuspend ; |
|
714 iData->SuspendL(); |
|
715 } |
|
716 break; |
|
717 } |
|
718 case EAiScreenLayoutChanged: |
|
719 { |
|
720 // ignore events |
|
721 break; |
|
722 } |
|
723 case EAiGeneralThemeChanged: |
|
724 { |
|
725 // ignore event |
|
726 break; |
|
727 } |
|
728 case EAiIdleBackground: |
|
729 { |
|
730 iHSForeGround = EFalse; |
|
731 } |
|
732 default : |
|
733 { |
|
734 if ( iPluginState == EResume ) |
|
735 { |
|
736 iPluginState = ESuspend; |
|
737 iData->SuspendL(); |
|
738 } |
|
739 break; |
|
740 } |
|
741 } |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // Is plugin active to publish the data |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 TBool CSapiDataPlugin::IsActive() |
|
749 { |
|
750 return (iPluginState == EResume ); |
|
751 } |
|