webengine/wrtharvester/src/wrtharvester.cpp
changeset 11 c8a366e56285
parent 10 a359256acfc6
child 15 60c5402cb945
equal deleted inserted replaced
10:a359256acfc6 11:c8a366e56285
   220 void CWrtHarvester::ConstructL()
   220 void CWrtHarvester::ConstructL()
   221     {
   221     {
   222     User::LeaveIfError( iApaSession.Connect() );
   222     User::LeaveIfError( iApaSession.Connect() );
   223     iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState );
   223     iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState );
   224     iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered );
   224     iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered );
   225     iWidgetMMCListener =  CWrtHarvesterPSNotifier::NewL( this, EWidgetMMCAltered );
   225     
   226     iWidgetUsbListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetMassStorageMode );
   226     User::LeaveIfError( iFs.Connect() );
       
   227     iWidgetUsbListener = CWidgetMMCHandler::NewL( this, iFs );
       
   228     
       
   229     iWidgetUsbListener->Start();
       
   230     SetMSMode(0);
   227     
   231     
   228     TFileName resourceFileName;  
   232     TFileName resourceFileName;  
   229     TParse parse;    
   233     TParse parse;    
   230     Dll::FileName (resourceFileName);           
   234     Dll::FileName (resourceFileName);           
   231     parse.Set(KResourceFileName, &resourceFileName, NULL); 
   235     parse.Set(KResourceFileName, &resourceFileName, NULL); 
   273     delete iWidgetUIListener;
   277     delete iWidgetUIListener;
   274     delete iWidgetRegListener;
   278     delete iWidgetRegListener;
   275     delete iWidgetMMCListener;
   279     delete iWidgetMMCListener;
   276     delete iWidgetUsbListener;
   280     delete iWidgetUsbListener;
   277     iWidgetOperations.Close();
   281     iWidgetOperations.Close();
       
   282     iHSWidgets.ResetAndDestroy();
   278     iApaSession.Close();
   283     iApaSession.Close();
   279     }
   284     }
   280     
   285     
   281 // ----------------------------------------------------------------------------
   286 // ----------------------------------------------------------------------------
   282 // Is called by Content Harvester server
   287 // Is called by Content Harvester server
   291 // Is called when Homescreen sends events to publisher
   296 // Is called when Homescreen sends events to publisher
   292 // ----------------------------------------------------------------------------
   297 // ----------------------------------------------------------------------------
   293 //  
   298 //  
   294 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
   299 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
   295     {
   300     {
       
   301     
       
   302     //Do not send the Operations to the Widgets when in Mass storage mode.. . .  
       
   303     if( IsInMSMode() == 1 )
       
   304         {
       
   305          if(aTrigger == KDeActive)
       
   306          RemovePublisherAndObserverL(aContentId);
       
   307          return;              
       
   308         }
       
   309    
   296     TUid uid( WidgetUid( aContentId ) );
   310     TUid uid( WidgetUid( aContentId ) );
   297     TWidgetOperations operation( Uninitialized );
   311     TWidgetOperations operation( Uninitialized );
   298     if( aTrigger == KActive )
   312     if( aTrigger == KActive )
   299         {
   313         {
       
   314         HBufC* temp = aContentId.Alloc();
       
   315         iHSWidgets.Append( temp );
   300         iHSCount++;	
   316         iHSCount++;	
   301         // queue the activated state event only for network accessing widgets
   317         // queue the activated state event only for network accessing widgets
   302         if ( CheckNetworkAccessL( uid) )
   318         if ( CheckNetworkAccessL( uid) )
   303             {
   319             {
   304             TWrtState* widgetState = NULL;
   320             TWrtState* widgetState = NULL;
   313         }
   329         }
   314     else if ( aTrigger == KDeActive )
   330     else if ( aTrigger == KDeActive )
   315         {
   331         {
   316         iHSCount--;
   332         iHSCount--;
   317         operation = Deactivate;
   333         operation = Deactivate;
       
   334         HBufC *temp = aContentId.Alloc();
       
   335         TPtr ptr (temp->Des());
       
   336         for( TInt i=0; i<iHSWidgets.Count(); i++ )
       
   337           {
       
   338           if( ! ptr.Compare(iHSWidgets[i]->Des()))
       
   339             {
       
   340             iHSWidgets.Remove(i);
       
   341             break;
       
   342             }
       
   343           }
       
   344         delete temp;        
   318         }
   345         }
   319     else if( aTrigger == KSuspend )
   346     else if( aTrigger == KSuspend )
   320         {
   347         {
   321         operation = WidgetSuspend;
   348         operation = WidgetSuspend;
   322         }
   349         }
   562 // 
   589 // 
   563 // ----------------------------------------------------------------------------
   590 // ----------------------------------------------------------------------------
   564 //
   591 //
   565 void CWrtHarvester::RemovePublisherAndObserverL( const TDesC& aBundleId )
   592 void CWrtHarvester::RemovePublisherAndObserverL( const TDesC& aBundleId )
   566     {
   593     {
       
   594     
       
   595     if( IsInMSMode() == 1 )
       
   596       {
       
   597       HBufC *temp = aBundleId.Alloc();
       
   598       TPtr ptr (temp->Des());
       
   599       for( TInt i=0; i<iHSWidgets.Count(); i++ )
       
   600         {
       
   601 
       
   602         if( ptr.Compare(iHSWidgets[i]->Des()) == 0)
       
   603           {
       
   604            return;
       
   605           }
       
   606         }
       
   607 
       
   608       }   
       
   609               
   567     RemoveObserver( aBundleId );
   610     RemoveObserver( aBundleId );
   568     
   611     
   569     __UHEAP_MARK;
   612     __UHEAP_MARK;
   570     if( iCPSInterface )
   613     if( iCPSInterface )
   571         {
   614         {
   950                                 aMessage,
   993                                 aMessage,
   951                                 aSoftkeys);
   994                                 aSoftkeys);
   952     }
   995     }
   953 
   996 
   954  //  End of File
   997  //  End of File
   955