idlefw/plugins/wrtdataplugin/src/wrtdataplugin.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 3 ff572005ac23
child 51 15e4dd19031c
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description: WRT data plug-in publisher
    15 * Profile plug-in publisher
    15 * 
    16 *
       
    17 */
    16 */
    18 
    17 
    19 
    18 // System includes
    20 
       
    21 // INCLUDE FILES
       
    22 #include <ecom/ecom.h>
    19 #include <ecom/ecom.h>
    23 #include <ecom/implementationproxy.h>
    20 #include <ecom/implementationproxy.h>
    24 #include <aicontentobserver.h>
       
    25 #include <aiutility.h>
       
    26 #include <aipspropertyobserver.h>
       
    27 #include <PUAcodes.hrh>
    21 #include <PUAcodes.hrh>
    28 #include <aipluginsettings.h>
       
    29 #include <badesca.h>
    22 #include <badesca.h>
    30 #include <fbs.h>
    23 #include <fbs.h>
    31 #include <gulicon.h>
    24 #include <gulicon.h>
    32 #include <AknsSkinInstance.h> 
    25 #include <AknsSkinInstance.h> 
    33 #include <AknsUtils.h> 
    26 #include <AknsUtils.h> 
    34 #include <AknsConstants.h>
    27 #include <AknsConstants.h>
    35 #include <e32property.h>
    28 #include <e32property.h>
       
    29 
       
    30 // User includes
       
    31 #include <hspublisherinfo.h>
       
    32 #include <aicontentobserver.h>
       
    33 #include <aiutility.h>
       
    34 #include <aipspropertyobserver.h>
       
    35 #include <aipluginsettings.h>
    36 #include <activeidle2domainpskeys.h>
    36 #include <activeidle2domainpskeys.h>
    37 
    37 
    38 #include "wrtdatapluginconst.h"
    38 #include "wrtdatapluginconst.h"
    39 #include "wrtdatapluginuids.hrh"
    39 #include "wrtdatapluginuids.hrh"
    40 #include "wrtdataplugin.h"
    40 #include "wrtdataplugin.h"
    41 #include "wrtdata.h"
    41 #include "wrtdata.h"
    42 
    42 
    43 // CONST CLASS VARIABLES
    43 // Constants
    44 const TImplementationProxy KImplementationTable[] =
    44 const TImplementationProxy KImplementationTable[] =
    45     {
    45     {
    46     IMPLEMENTATION_PROXY_ENTRY( KImplUidDataPlugin, CWrtDataPlugin::NewL ) 
    46     IMPLEMENTATION_PROXY_ENTRY( KImplUidDataPlugin, CWrtDataPlugin::NewL ) 
    47     };
    47     };
    48 
    48 
    49 // ======== MEMBER FUNCTIONS ========
    49 // ======== MEMBER FUNCTIONS ========
    50 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    51 // Constructs and returns an application object.
    51 // ImplementationGroupProxy
    52 // ---------------------------------------------------------------------------
    52 //
    53 //
    53 // ---------------------------------------------------------------------------
    54 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount )
    54 //
       
    55 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
       
    56     TInt& aTableCount )
    55     {
    57     {
    56     aTableCount = sizeof( KImplementationTable ) /
    58     aTableCount = sizeof( KImplementationTable ) /
    57         sizeof( TImplementationProxy );
    59         sizeof( TImplementationProxy );
    58     return KImplementationTable;
    60     return KImplementationTable;
    59     }
    61     }
    60 
    62 
    61 // ======== MEMBER FUNCTIONS ========
    63 // ======== MEMBER FUNCTIONS ========
    62 
    64 // ----------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    65 // CWrtDataPlugin::NewL()
    64 // Symbian 2nd phase constructor can leave
    66 //
    65 // ---------------------------------------------------------------------------
    67 // ----------------------------------------------------------------------------
    66 //
    68 //
    67 CWrtDataPlugin* CWrtDataPlugin::NewL()
    69 CWrtDataPlugin* CWrtDataPlugin::NewL()
    68     {
    70     {
    69     CWrtDataPlugin* self = new (ELeave) CWrtDataPlugin;
    71     CWrtDataPlugin* self = new (ELeave) CWrtDataPlugin;
    70     CleanupStack::PushL( self );
    72     CleanupStack::PushL( self );
    71     self->ConstructL();
    73     self->ConstructL();
    72     CleanupStack::Pop( self );
    74     CleanupStack::Pop( self );
    73     return self;
    75     return self;
    74     }
    76     }
    75     
    77     
    76 // ---------------------------------------------------------------------------
    78 // ----------------------------------------------------------------------------
    77 // Default constructor
    79 // CWrtDataPlugin::CWrtDataPlugin()
    78 // ---------------------------------------------------------------------------
    80 //
       
    81 // ----------------------------------------------------------------------------
    79 //
    82 //
    80 CWrtDataPlugin::CWrtDataPlugin()
    83 CWrtDataPlugin::CWrtDataPlugin()
    81     {
    84     : iNetworkStatus( EUnknown ), iPluginState( ENone ) 
    82     }
    85     {
    83     
    86     }
    84 // ---------------------------------------------------------------------------
    87     
    85 // Symbian 2nd phase constructor can leave
    88 // ----------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    89 // CWrtDataPlugin::ConstructL()
       
    90 //
       
    91 // ----------------------------------------------------------------------------
    87 //
    92 //
    88 void CWrtDataPlugin::ConstructL()
    93 void CWrtDataPlugin::ConstructL()
    89     { 
    94     {
    90     iInfo.iUid.iUid = WRTDP_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_DATAPLUGIN; 
    95     User::LeaveIfError( iRfs.Connect() );
    91     iPluginState = ENone;
    96     
    92     iHSForeGround = EFalse;
    97     iData = CWrtData::NewL( this );
    93     iKeyLockOn = EFalse;
       
    94     iNetworkStatus = EUnknown;
       
    95     iData = CWrtData::NewL(this);
       
    96 
       
    97     }
    98     }
    98     
    99     
    99 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
   100 // Destructor
   101 // Destructor
   101 // Deletes all data created to heap
   102 // Deletes all data created to heap
   102 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   103 //
   104 //
   104 CWrtDataPlugin::~CWrtDataPlugin()
   105 CWrtDataPlugin::~CWrtDataPlugin()
   105     {
   106     {
   106     // deactivate the publishers
   107     delete iData;
   107     if( iData )
       
   108         {
       
   109         if ( iPluginState != EInActive )
       
   110         	{
       
   111         	TRAP_IGNORE(iData->DeActivateL());
       
   112         	}
       
   113         delete iData;
       
   114         }
       
   115     iObservers.Close();
   108     iObservers.Close();
   116     Release( iContent );
   109     Release( iContent );
   117     iDataArray.ResetAndDestroy();
   110     iDataArray.ResetAndDestroy();
   118 
   111 
   119     if( iContentModel)
   112     if( iContentModel)
   123             User::Free((TAny*)iContentModel[i].cid);   
   116             User::Free((TAny*)iContentModel[i].cid);   
   124             }
   117             }
   125         delete []iContentModel;
   118         delete []iContentModel;
   126         }
   119         }
   127     iIconArray.Reset();
   120     iIconArray.Reset();
   128     }
   121     
   129 
   122     iRfs.Close();
   130 // ---------------------------------------------------------------------------
   123     }
   131 // From class CAiContentPublisher
   124 
   132 // Plug-in is requested to unload its engines due backup operation
   125 // ----------------------------------------------------------------------------
   133 // ---------------------------------------------------------------------------
   126 // CWrtDataPlugin::Start
   134 //
   127 //
   135 void CWrtDataPlugin::Stop( TAiTransitionReason aReason )
   128 // ----------------------------------------------------------------------------
   136     {
   129 //
   137     if( iPluginState == EResume )
   130 void CWrtDataPlugin::Start( TStartReason aReason )
   138         {
   131     {
   139         Suspend( aReason );
   132     if( aReason == ESystemStartup || 
   140         }
   133         aReason == EPluginStartup )
   141     }
   134         {
   142 
   135         // publish the initial data
   143 // ---------------------------------------------------------------------------
   136         TRAP_IGNORE( PublishL());
   144 // From class CAiContentPublisher
   137         }
   145 // Plug-in is instructed that it is allowed to consume CPU resources
   138     }
   146 // ---------------------------------------------------------------------------
   139 
   147 //
   140 // ----------------------------------------------------------------------------
   148 void CWrtDataPlugin::Resume( TAiTransitionReason aReason )
   141 // CWrtDataPlugin::Stop
   149     {
   142 //
   150     TRAP_IGNORE( DoResumeL( aReason ) ); 
   143 // ----------------------------------------------------------------------------
   151     }
   144 //
   152     
   145 void CWrtDataPlugin::Stop( TStopReason aReason )
   153 // ---------------------------------------------------------------------------
   146     {
   154 // From class CAiContentPublisher
   147     if( aReason == EPluginShutdown ||
   155 // Plug-in is instructed that it is not allowed to consume CPU resources
   148         aReason == ESystemShutdown )
   156 // ---------------------------------------------------------------------------
   149         {
   157 //
   150         TRAP_IGNORE(iData->DeActivateL());
   158 void CWrtDataPlugin::Suspend( TAiTransitionReason aReason )
   151         }
   159     {
   152     }
   160     switch( aReason )
   153 
   161         {
   154 // ----------------------------------------------------------------------------
   162         case EAiKeylockDisabled:
   155 // CWrtDataPlugin::Resume
   163         case EAiKeylockEnabled:
   156 //
   164             {
   157 // ----------------------------------------------------------------------------
   165             // handled in resume 
   158 //
   166             break;
   159 void CWrtDataPlugin::Resume( TResumeReason aReason )
   167             }
   160     {
   168         default :
   161     if ( aReason == EForeground )
   169             {
   162         {
   170             iPluginState = ESuspend;
   163         iPluginState = EResume;
   171             TRAP_IGNORE ( iData->SuspendL() );
   164 
   172             }
   165         TRAP_IGNORE( iData->ResumeL() );        
   173         }
   166         }    
   174     }
   167     }
   175 
   168 
   176 // ---------------------------------------------------------------------------
   169 // ----------------------------------------------------------------------------
   177 // From class CAiContentPublisher
   170 // CWrtDataPlugin::Suspend
   178 // The plug-in MUST maintain a registry of subscribers and send 
   171 //
   179 // notification to all of them whenever the state changes or new content
   172 // ----------------------------------------------------------------------------
   180 // is available
   173 //
   181 // ---------------------------------------------------------------------------
   174 void CWrtDataPlugin::Suspend( TSuspendReason aReason )
       
   175     {    
       
   176     if ( aReason == EBackground )
       
   177         {
       
   178         iPluginState = ESuspend;
       
   179         
       
   180         TRAP_IGNORE ( iData->SuspendL() );        
       
   181         }        
       
   182     }
       
   183 
       
   184 // ----------------------------------------------------------------------------
       
   185 // CWrtDataPlugin::SetOnline
       
   186 //
       
   187 // ----------------------------------------------------------------------------
       
   188 //
       
   189 void CWrtDataPlugin::SetOnline()
       
   190     {    
       
   191     if ( iNetworkStatus != EOnline )
       
   192         {
       
   193         iNetworkStatus = EOnline;
       
   194         
       
   195         TRAP_IGNORE( iData->OnLineL() );            
       
   196         }    
       
   197     }
       
   198 
       
   199 // ----------------------------------------------------------------------------
       
   200 // CWrtDataPlugin::SetOffline
       
   201 //
       
   202 // ----------------------------------------------------------------------------
       
   203 //
       
   204 void CWrtDataPlugin::SetOffline()
       
   205     {
       
   206     if ( iNetworkStatus != EOffline )
       
   207         {
       
   208         iNetworkStatus = EOffline;
       
   209         
       
   210         TRAP_IGNORE( iData->OffLineL() );            
       
   211         }    
       
   212     }
       
   213 
       
   214 // ----------------------------------------------------------------------------
       
   215 // CWrtDataPlugin::SubscribeL
       
   216 //
       
   217 // ----------------------------------------------------------------------------
   182 //
   218 //
   183 void CWrtDataPlugin::SubscribeL( MAiContentObserver& aObserver )
   219 void CWrtDataPlugin::SubscribeL( MAiContentObserver& aObserver )
   184     { 
   220     {
   185     iObservers.AppendL( &aObserver );
   221     iObservers.AppendL( &aObserver );
   186     }
   222     }
   187  
   223 
   188 // ---------------------------------------------------------------------------
   224 // ----------------------------------------------------------------------------
   189 // From class CAiContentPublisher
   225 // CWrtDataPlugin::ConfigureL
   190 // Plug-ins take ownership of the settings array, so it must either
   226 //
   191 // store it in a member or free it.
   227 // ----------------------------------------------------------------------------
   192 // ---------------------------------------------------------------------------
       
   193 //
   228 //
   194 void CWrtDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
   229 void CWrtDataPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
   195     {
   230     {
   196     if( iDataCount > 0 )
   231     if( iDataCount > 0 )
   197         {
   232         {
   202     
   237     
   203     RAiSettingsItemArray contentItemsArr;
   238     RAiSettingsItemArray contentItemsArr;
   204     RAiSettingsItemArray configurationItemsArr;
   239     RAiSettingsItemArray configurationItemsArr;
   205     RAiSettingsItemArray settingItemsArr;
   240     RAiSettingsItemArray settingItemsArr;
   206     
   241     
   207     TInt count = aSettings.Count();
   242     TInt count( aSettings.Count() );
   208     for(TInt i = 0; i < count; i++ )
   243     
   209         {
   244     for ( TInt i = 0; i < count; i++ )
   210         MAiPluginSettings* pluginSetting = aSettings[i];
   245         {
   211         if( pluginSetting->AiPluginItemType() == EAiPluginContentItem )
   246         MAiPluginSettings* setting( aSettings[i] );
   212             {
   247         
   213             contentItemsArr.Append(pluginSetting);
   248         if( setting->AiPluginItemType() == EAiPluginContentItem )
   214             }
   249             {
   215         else if( pluginSetting->AiPluginItemType() == EAiPluginConfigurationItem )
   250             contentItemsArr.Append( setting );
   216             {
   251             }
   217             configurationItemsArr.Append(pluginSetting);
   252         else if( setting->AiPluginItemType() == EAiPluginConfigurationItem )
       
   253             {
       
   254             configurationItemsArr.Append( setting );
   218             }
   255             }
   219         else 
   256         else 
   220             {
   257             {
   221             settingItemsArr.Append(pluginSetting);
   258             settingItemsArr.Append( setting );
   222             }
   259             }
   223         }
   260         }
   224     
   261     
   225     iDataCount = contentItemsArr.Count();
   262     iDataCount = contentItemsArr.Count();
   226     if(iDataCount > 0 )
   263     
       
   264     if ( iDataCount > 0 )
   227         {
   265         {
   228         // Create the content Model
   266         // Create the content Model
   229         HBufC16* contentId = HBufC16::NewLC( KAiContentIdMaxLength + KAiPluginNameMaxLength );
   267         HBufC16* contentId = HBufC16::NewLC( 
       
   268             KAiContentIdMaxLength + KAiPluginNameMaxLength );
       
   269         
   230         iContentModel = new TAiContentItem[iDataCount];
   270         iContentModel = new TAiContentItem[iDataCount];
   231         for(TInt i = 0; i < iDataCount; i++)
   271         
   232             {
   272         for( TInt i = 0; i < iDataCount; i++ )
   233             MAiPluginContentItem& contentItem = (contentItemsArr[i])->AiPluginContentItem();
   273             {
       
   274             MAiPluginContentItem& contentItem( 
       
   275                 contentItemsArr[i]->AiPluginContentItem() );
       
   276             
   234             iContentModel[i].id = i;
   277             iContentModel[i].id = i;
   235             if( contentItem.Type() == KText() )
   278             if( contentItem.Type() == KText() )
   236                 {
   279                 {
   237                 // text
   280                 // text
   238                 iContentModel[i].type = KAiContentTypeText;
   281                 iContentModel[i].type = KAiContentTypeText;
   239                 }
   282                 }
   240             if( contentItem.Type() == KImage() || 
   283             if( contentItem.Type() == KImage() || 
   241                     contentItem.Type() == KAnimation() )
   284         		contentItem.Type() == KAnimation() )
   242                 {
   285                 {
   243                 // image
   286                 // image
   244                 iContentModel[i].type = KAiContentTypeBitmap;
   287                 iContentModel[i].type = KAiContentTypeBitmap;
   245                 }
   288                 }
   246             
   289             
   247             contentId->Des().Copy(contentItem.Name());
   290             contentId->Des().Copy( contentItem.Name() );
   248             contentId->Des().Delete(0, contentId->Des().LocateReverse(KPluginNameSeprator) +1);
   291             contentId->Des().Delete( 0, 
       
   292                 contentId->Des().LocateReverse( KPluginNameSeprator ) + 1 );
   249   
   293   
   250             TInt sizeOfContentId = contentId->Des().Size()+sizeof(wchar_t);
   294             TInt sizeOfContentId( contentId->Des().Size()+sizeof( wchar_t ) );
   251             iContentModel[i].cid = static_cast<const wchar_t*>( User::Alloc( sizeOfContentId ) );
       
   252             Mem::Copy((TAny*)iContentModel[i].cid, contentId->Des().PtrZ(), sizeOfContentId);
       
   253             
   295             
   254             contentId->Des().Delete( 0, contentId->Des().Length());
   296             iContentModel[i].cid = 
       
   297                 static_cast< const wchar_t* >( User::Alloc( sizeOfContentId ) );
       
   298                 
       
   299             Mem::Copy( ( TAny* )iContentModel[i].cid, 
       
   300                 contentId->Des().PtrZ(), sizeOfContentId );
       
   301             
       
   302             contentId->Des().Delete( 0, contentId->Des().Length() );
   255             }    
   303             }    
   256         
   304         
   257         CleanupStack::PopAndDestroy( contentId );
   305         CleanupStack::PopAndDestroy( contentId );
   258         iContent = AiUtility::CreateContentItemArrayIteratorL( iContentModel, iDataCount );
   306         iContent = AiUtility::CreateContentItemArrayIteratorL( 
       
   307                 iContentModel, iDataCount );
       
   308                        
   259         // Configurations 
   309         // Configurations 
   260         iData->ConfigureL(configurationItemsArr);
   310         iData->ConfigureL( configurationItemsArr );
   261 
   311 
   262         iPluginState = ESuspend;
   312         iPluginState = ESuspend;
       
   313 
   263         // Register for notifications
   314         // Register for notifications
   264         iData->RegisterL();
   315         iData->RegisterL();
   265         
   316         
   266         // Activate the publisher 
   317         // Activate the publisher 
   267         iData->ActivateL();
   318         iData->ActivateL();
   268         }
   319         }
   269     
   320     
   270     settingItemsArr.Reset();
   321     settingItemsArr.Reset();
   271     contentItemsArr.Reset();
   322     contentItemsArr.Reset();
   272     configurationItemsArr.Reset();
   323     configurationItemsArr.Reset();
       
   324     
   273        // We own the array so destroy it
   325        // We own the array so destroy it
   274     aSettings.ResetAndDestroy();
   326     aSettings.ResetAndDestroy();
   275     // publish the initial data
   327     }
   276     PublishL();
   328 
   277     }
   329 // ----------------------------------------------------------------------------
   278 
   330 // CWrtDataPlugin::GetProperty
   279 // ---------------------------------------------------------------------------
   331 //
   280 // From class CAiContentPublisher
   332 // ----------------------------------------------------------------------------
   281 // Returns the extension interface. Actual type depends on the passed 
   333 //
   282 // aUid argument.
   334 TAny* CWrtDataPlugin::GetProperty( TProperty aProperty )
   283 // ---------------------------------------------------------------------------
   335     {
   284 //
   336     if ( aProperty == EPublisherContent )
   285 TAny* CWrtDataPlugin::Extension( TUid aUid )
   337         {
   286     {    
   338         return static_cast< MAiContentItemIterator* >( iContent );      
   287     if ( aUid == KExtensionUidProperty )
   339         }
   288         {
   340     
   289         return static_cast<MAiPropertyExtension*>( this );
   341     return NULL;
   290         }
   342     }
   291     else if (aUid == KExtensionUidEventHandler)
   343 
   292         {
   344 // ----------------------------------------------------------------------------
   293         return static_cast<MAiEventHandlerExtension*>( this );
   345 // CWrtDataPlugin::HandleEvent
   294         }
   346 //
   295     else
   347 // ----------------------------------------------------------------------------
   296         {   
   348 //
   297         return NULL;
   349 void CWrtDataPlugin::HandleEvent( const TDesC& aEventName, 
   298         }
   350     const TDesC& aParam )
   299     }
   351     {
   300 
   352     TRAP_IGNORE( iData->ExecuteActionL( aEventName , aParam ) );    
   301 // ---------------------------------------------------------------------------
   353     }
   302 // From class MAiPropertyExtension
   354 
   303 // Read property of publisher plug-in.
   355 // ----------------------------------------------------------------------------
   304 // ---------------------------------------------------------------------------
   356 // CWrtDataPlugin::HasMenuItem
   305 //
   357 //
   306 TAny* CWrtDataPlugin::GetPropertyL( TInt aProperty )
   358 // ----------------------------------------------------------------------------
   307     {
   359 //
   308     TAny* property = NULL;
   360 TBool CWrtDataPlugin::HasMenuItem( const TDesC& aMenuItem )
   309     
   361     {
   310     switch ( aProperty )
   362     return iData->HasMenuItem ( aMenuItem );
   311         {
   363     }
   312     case EAiPublisherInfo:
   364 
   313         {
   365 // ----------------------------------------------------------------------------
   314          property = static_cast<TAiPublisherInfo*>( &iInfo );
   366 // CWrtDataPlugin::IsActive
   315         break;  
   367 //
   316         }       
   368 // ----------------------------------------------------------------------------
   317 
   369 //
   318     case EAiPublisherContent:
   370 TBool CWrtDataPlugin::IsActive() const
   319         {
   371     {
   320         property = static_cast<MAiContentItemIterator*>( iContent );
   372     return iPluginState == EResume;
   321         break;    
   373     }
   322         }        
   374 
   323     default:
   375 // ----------------------------------------------------------------------------
   324         break;
   376 // CWrtDataPlugin::Data
   325         }
   377 //
   326 
   378 // ----------------------------------------------------------------------------
   327     return property;
   379 //
   328     }
   380 CWrtData* CWrtDataPlugin::Data() const
   329 
   381     {
   330 // ---------------------------------------------------------------------------
   382     return iData;
   331 // From class MAiPropertyExtension
   383     }
   332 // Write property value to optimize the content model.
   384 
   333 // ---------------------------------------------------------------------------
   385 // ----------------------------------------------------------------------------
   334 //
   386 // CWrtDataPlugin::NetworkStatus
   335 void CWrtDataPlugin::SetPropertyL( TInt aProperty, TAny* aValue )
   387 //
   336     {  
   388 // ----------------------------------------------------------------------------
   337     switch ( aProperty )
   389 //
   338         {
   390 CWrtDataPlugin::TPluginNetworkStatus CWrtDataPlugin::NetworkStatus() const
   339         case EAiPublisherInfo:
   391     {
   340             {
   392     return iNetworkStatus;
   341             if( aValue )
   393     }
   342                 {
   394 
   343                 const TAiPublisherInfo* info = static_cast<const TAiPublisherInfo*>( aValue );
   395 // ---------------------------------------------------------------------------
   344                 iInfo.iName.Copy( info->iName );
   396 // CWrtDataPlugin::GetIdL
   345                 iInfo.iNamespace.Copy( info->iNamespace );
       
   346                 }
       
   347             break;
       
   348             }
       
   349         default:
       
   350             break;         
       
   351         }
       
   352     }
       
   353  
       
   354 // ---------------------------------------------------------------------------
       
   355 // From class MAiEventHandlerExtension.
       
   356 // Handles an event sent by the AI framework.
       
   357 // ---------------------------------------------------------------------------
       
   358 //
       
   359 void CWrtDataPlugin::HandleEvent( TInt /*aEvent*/, const TDesC& /*aParam*/ )
       
   360     {
       
   361     // This is not as there is no event id to retrieve in this dynamic plugin. 
       
   362     } 
       
   363     
       
   364 // ---------------------------------------------------------------------------
       
   365 // From class MAiEventHandlerExtension.
       
   366 // Handles an event sent by the AI framework.
       
   367 // ---------------------------------------------------------------------------
       
   368 //
       
   369 void CWrtDataPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam )
       
   370     {
       
   371     // We have no way of reporting errors to framework so just ignore them.
       
   372     TRAP_IGNORE(iData->ExecuteActionL( aEventName , aParam ) );
       
   373     }
       
   374 
       
   375 // ---------------------------------------------------------------------------
       
   376 // From class MAiEventHandlerExtension.
       
   377 // Invoked by the framework for querying if plugin has menu item
       
   378 // ---------------------------------------------------------------------------
       
   379 //
       
   380 TBool CWrtDataPlugin::HasMenuItem( const TDesC16& aMenuItem )
       
   381     { 
       
   382     return iData->HasMenuItem ( aMenuItem );  
       
   383     }
       
   384 
       
   385 // ---------------------------------------------------------------------------
       
   386 // Gets the id of a content  
   397 // Gets the id of a content  
   387 // ---------------------------------------------------------------------------
   398 // ---------------------------------------------------------------------------
   388 //
   399 //
   389 TInt CWrtDataPlugin::GetIdL( TDesC16& aObjectId)
   400 TInt CWrtDataPlugin::GetIdL( TDesC16& aObjectId)
   390     {
   401     {
   403     return id;
   414     return id;
   404     }
   415     }
   405  
   416  
   406 
   417 
   407 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
       
   419 // CWrtDataPlugin::GetTypeL
   408 // Gets type of a content
   420 // Gets type of a content
   409 // ---------------------------------------------------------------------------
   421 // ---------------------------------------------------------------------------
   410 //
   422 //
   411 void CWrtDataPlugin::GetTypeL(TDesC16& aObjectId, TDes16& aType )
   423 void CWrtDataPlugin::GetTypeL(TDesC16& aObjectId, TDes16& aType )
   412     {
   424     {
   462         // Relese memory of the published text
   474         // Relese memory of the published text
   463         iDataArray.ResetAndDestroy();
   475         iDataArray.ResetAndDestroy();
   464         // Release memory of the published icons
   476         // Release memory of the published icons
   465         iIconArray.Reset();
   477         iIconArray.Reset();
   466         }
   478         }
   467     }
       
   468 
       
   469 // ---------------------------------------------------------------------------
       
   470 // Is plugin active to publish the data 
       
   471 // ---------------------------------------------------------------------------
       
   472 //
       
   473 TBool CWrtDataPlugin::IsActive()
       
   474     {
       
   475     return (iPluginState == EResume );
       
   476     }
   479     }
   477 
   480 
   478 // ---------------------------------------------------------------------------
   481 // ---------------------------------------------------------------------------
   479 // Publish a specific text of the widget  
   482 // Publish a specific text of the widget  
   480 // ---------------------------------------------------------------------------
   483 // ---------------------------------------------------------------------------
   575               err = KErrNotFound;   
   578               err = KErrNotFound;   
   576               aObserver->Clean( *this, aContentId, aContentId );
   579               aObserver->Clean( *this, aContentId, aContentId );
   577               }
   580               }
   578           }
   581           }
   579       else  // Interpret as File path
   582       else  // Interpret as File path
   580           {
   583           {                   
   581           RFs rfs;
   584           RFile iconFile;
   582           User::LeaveIfError( rfs.Connect() );
   585           
   583           RFile* iconFile = new (ELeave) RFile();
   586           err = iconFile.Open( iRfs, aPath, EFileShareReadersOnly |  EFileRead );
   584           err = iconFile->Open( rfs, aPath, EFileShareReadersOnly |  EFileRead );
   587           
   585           if( err == KErrNone )
   588           if( err == KErrNone )
   586             {
   589             {
   587              aObserver->Publish( *this, aContentId, *iconFile, aContentId );
   590              aObserver->Publish( *this, aContentId, iconFile, aContentId );
   588             }
   591             }
   589           else
   592           else
   590               {
   593               {
   591               aObserver->Clean( *this, aContentId, aContentId );
   594               aObserver->Clean( *this, aContentId, aContentId );
   592               }
   595               }
   593           iconFile->Close();
   596           
   594           delete iconFile;
   597           iconFile.Close();
   595           iconFile = NULL;
       
   596           rfs.Close();
       
   597           }
   598           }
   598         }
   599         }
   599     }
   600     }
   600 
   601 
   601 // ---------------------------------------------------------------------------
   602 // ---------------------------------------------------------------------------
   690         iDataArray.ResetAndDestroy();
   691         iDataArray.ResetAndDestroy();
   691         // Release memory of the published icons
   692         // Release memory of the published icons
   692         iIconArray.Reset();
   693         iIconArray.Reset();
   693         }
   694         }
   694 
   695 
   695     }
       
   696 
       
   697 // ---------------------------------------------------------------------------
       
   698 // From class CAiContentPublisher
       
   699 // framework instructs plug-in that it is allowed to consume CPU resources
       
   700 // ---------------------------------------------------------------------------
       
   701 //
       
   702 void CWrtDataPlugin::DoResumeL( TAiTransitionReason aReason )
       
   703     {
       
   704     //update in startup phase and idle is on foreground.
       
   705     switch ( aReason )
       
   706         {
       
   707         case EAiIdleOnLine:
       
   708             {
       
   709             iNetworkStatus = EOnline;
       
   710             iData->OnLineL();
       
   711             break;
       
   712             }
       
   713         case EAiIdleOffLine:
       
   714             {
       
   715             iNetworkStatus = EOffline;
       
   716             iData->OffLineL();
       
   717             break;
       
   718             }
       
   719         case EAiIdlePageSwitch:
       
   720             {
       
   721             if ( iPluginState == EResume )
       
   722                 {
       
   723                 iData->SuspendL();
       
   724                 }
       
   725             iPluginState = EInActive;
       
   726             iData->InActiveL();
       
   727             }
       
   728             break;
       
   729         case EAiSystemStartup:
       
   730         case EAiIdleForeground:
       
   731             {
       
   732             iHSForeGround = ETrue;
       
   733             }
       
   734         case EAiBacklightOn:            
       
   735             {
       
   736             if ( iPluginState == ESuspend  && !iKeyLockOn )
       
   737                 {
       
   738                 iPluginState = EResume;
       
   739                 iData->ResumeL();
       
   740                 }
       
   741             break;
       
   742             }
       
   743         case EAiKeylockDisabled:
       
   744             {
       
   745             iKeyLockOn = EFalse;
       
   746             // Key lock events considered only if HS is in foreground  
       
   747             if ( iHSForeGround && iPluginState == ESuspend )
       
   748                 {
       
   749                 iPluginState = EResume;
       
   750                 iData->ResumeL();
       
   751                 }
       
   752             break;
       
   753             }
       
   754         case EAiKeylockEnabled:
       
   755             {
       
   756             iKeyLockOn = ETrue;
       
   757             // Key lock events considered only if HS is in foreground
       
   758             if ( iHSForeGround && iPluginState == EResume )
       
   759                 {
       
   760                 iPluginState = ESuspend ;
       
   761                 iData->SuspendL();
       
   762                 }
       
   763             break;
       
   764             }
       
   765         case EAiScreenLayoutChanged:
       
   766             {
       
   767             // ignore events
       
   768             break;
       
   769             }
       
   770       case EAiGeneralThemeChanged:
       
   771           {
       
   772           // ignore event
       
   773           break;
       
   774           }
       
   775         case EAiIdleBackground: 
       
   776             {
       
   777             iHSForeGround = EFalse;
       
   778             }
       
   779         default :
       
   780             {
       
   781             if ( iPluginState == EResume )
       
   782                 {
       
   783                 iPluginState = ESuspend;
       
   784                 iData->SuspendL();
       
   785                 }
       
   786             break;
       
   787             }
       
   788         }
       
   789     }
   696     }
   790 
   697 
   791 // ---------------------------------------------------------------------------
   698 // ---------------------------------------------------------------------------
   792 // ResolveSkinItemId
   699 // ResolveSkinItemId
   793 // ---------------------------------------------------------------------------
   700 // ---------------------------------------------------------------------------
   864                }
   771                }
   865            }
   772            }
   866        }
   773        }
   867    return (error == KErrNone );
   774    return (error == KErrNone );
   868    }
   775    }
       
   776 
       
   777 // End of file