webengine/wrtharvester/src/wrtharvester.cpp
branchRCL_3
changeset 35 1f3c3f2f5b0a
parent 27 6297cdf66332
child 36 c711bdda59f4
equal deleted inserted replaced
34:220a17280356 35:1f3c3f2f5b0a
    23 #include "wrtharvesterpublisherobserver.h"
    23 #include "wrtharvesterpublisherobserver.h"
    24 
    24 
    25 #include "wrtharvesterconst.h"
    25 #include "wrtharvesterconst.h"
    26 #include <widgetregistryconstants.h>
    26 #include <widgetregistryconstants.h>
    27 #include <wrtharvester.rsg>
    27 #include <wrtharvester.rsg>
    28 
    28 #include <startupdomainpskeys.h>
    29 #include <ecom/implementationproxy.h>
    29 #include <ecom/implementationproxy.h>
    30 
    30 
    31 #include <LiwServiceHandler.h>
    31 #include <LiwServiceHandler.h>
    32 #include <LiwVariant.h>
    32 #include <LiwVariant.h>
    33 #include <LiwGenericParam.h>
    33 #include <LiwGenericParam.h>
   223 // ----------------------------------------------------------------------------
   223 // ----------------------------------------------------------------------------
   224 //
   224 //
   225 void CWrtHarvester::ConstructL()
   225 void CWrtHarvester::ConstructL()
   226     {
   226     {
   227     User::LeaveIfError( iApaSession.Connect() );
   227     User::LeaveIfError( iApaSession.Connect() );
       
   228     	
       
   229     iSystemShutdown = EFalse;
   228     iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState );
   230     iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState );
   229     iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered );
   231     iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered );
       
   232     iWidgetSystemShutdownListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetSystemShutdown );
   230     
   233     
   231     User::LeaveIfError( iFs.Connect() );
   234     User::LeaveIfError( iFs.Connect() );
   232     iWidgetUsbListener = CWrtUsbHandler::NewL( this, iFs );
   235     iWidgetUsbListener = CWrtUsbHandler::NewL( this, iFs );
   233     
   236     
   234     iWidgetUsbListener->Start();
   237     iWidgetUsbListener->Start();
   285     iWidgetStateArray.ResetAll();
   288     iWidgetStateArray.ResetAll();
   286     delete iWidgetUIListener;
   289     delete iWidgetUIListener;
   287     delete iWidgetRegListener;
   290     delete iWidgetRegListener;
   288     delete iWidgetMMCListener;
   291     delete iWidgetMMCListener;
   289     delete iWidgetUsbListener;
   292     delete iWidgetUsbListener;
       
   293     delete iWidgetSystemShutdownListener;
   290     if(iAsyncCallBack)
   294     if(iAsyncCallBack)
   291         {
   295         {
   292         iAsyncCallBack->Cancel();       
   296         iAsyncCallBack->Cancel();       
   293         }
   297         }
   294     delete iAsyncCallBack;
   298     delete iAsyncCallBack;
   314 //  
   318 //  
   315 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
   319 void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger )
   316     {
   320     {
   317     
   321     
   318     //Do not send the Operations to the Widgets when in Mass storage mode.. . .  
   322     //Do not send the Operations to the Widgets when in Mass storage mode.. . .  
   319     if( IsInMSMode() == 1 )
       
   320         {
       
   321          if(aTrigger == KDeActive)
       
   322          RemovePublisherAndObserverL(aContentId);
       
   323          return;              
       
   324         }
       
   325    
       
   326     TUid uid( WidgetUid( aContentId ) );
   323     TUid uid( WidgetUid( aContentId ) );
       
   324     
       
   325     
       
   326     if(iSystemShutdown && aTrigger == KDeActive )
       
   327     	{
       
   328     	return ;
       
   329     	}
       
   330     if( IsInMSMode() == 1 && aTrigger == KDeActive)
       
   331       {
       
   332       RemovePublisherAndObserverL(aContentId);
       
   333       
       
   334       if(!iSystemShutdown)
       
   335           {
       
   336           RWidgetRegistryClientSession session;
       
   337           CleanupClosePushL( session );
       
   338           User::LeaveIfError( session.Connect() );
       
   339           session.SetBlanketPermissionL( uid, EBlanketUnknown );
       
   340           CleanupStack::PopAndDestroy( &session );
       
   341           }
       
   342       return; 
       
   343       }
       
   344              
   327     TWidgetOperations operation( Uninitialized );
   345     TWidgetOperations operation( Uninitialized );
   328     if( aTrigger == KActive )
   346     if( aTrigger == KActive )
   329         {
   347         {
   330         HBufC* temp = aContentId.Alloc();
   348         HBufC* temp = aContentId.Alloc();
   331         iHSWidgets.Append( temp );
   349         iHSWidgets.Append( temp );
   355             {
   373             {
   356             iHSWidgets.Remove(i);
   374             iHSWidgets.Remove(i);
   357             break;
   375             break;
   358             }
   376             }
   359           }
   377           }
   360         delete temp;        
   378         delete temp;
   361         }
   379         
       
   380         // Removing . Miniview, shall remove full view as well. For blanket permissions
       
   381         // will be revoked for miniview
       
   382          
       
   383       	if(!iSystemShutdown)
       
   384       	    {        
       
   385             RWidgetRegistryClientSession session;
       
   386             CleanupClosePushL( session );
       
   387             User::LeaveIfError( session.Connect() );
       
   388             session.SetBlanketPermissionL( uid, EBlanketUnknown );
       
   389             CleanupStack::PopAndDestroy( &session );
       
   390             }
       
   391       }
   362     else if( aTrigger == KSuspend )
   392     else if( aTrigger == KSuspend )
   363         {
   393         {
   364         operation = WidgetSuspend;
   394         operation = WidgetSuspend;
   365         }
   395         }
   366     else if( aTrigger == KResume )
   396     else if( aTrigger == KResume )
   500             variant.Reset();
   530             variant.Reset();
   501              
   531              
   502             if( publisherMap && publisherMap->FindL( KContentId , variant ))
   532             if( publisherMap && publisherMap->FindL( KContentId , variant ))
   503                 {
   533                 {
   504                  HBufC* bundleId = variant.AsDes().AllocLC();
   534                  HBufC* bundleId = variant.AsDes().AllocLC();
   505                  publishers.AppendL( bundleId );
   535                  variant.Reset();
   506                  CleanupStack::Pop( bundleId );
   536                  TBool isNokiaWidget = EFalse;
       
   537                  if ( publisherMap->FindL( KDataMap, variant) )
       
   538                      {
       
   539                      CLiwDefaultMap* dataMap = CLiwDefaultMap::NewLC();
       
   540                      variant.Get( *dataMap );
       
   541                      variant.Reset();
       
   542                      if ( dataMap->FindL( KWidgetInfo, variant ) )
       
   543                          {
       
   544                          CLiwDefaultMap* widgetInfoMap = CLiwDefaultMap::NewLC();
       
   545                          variant.Get( *widgetInfoMap );
       
   546                          if ( widgetInfoMap->FindL( KWidgetType, variant ) )
       
   547                              {
       
   548                              if ( KS60Widget == variant.AsTInt32())
       
   549                                  {
       
   550                                  isNokiaWidget = ETrue;
       
   551                                  }
       
   552                              }
       
   553                          CleanupStack::PopAndDestroy( widgetInfoMap );
       
   554                          }
       
   555                      CleanupStack::PopAndDestroy( dataMap );
       
   556                      }
       
   557                  
       
   558                  if (isNokiaWidget )
       
   559                      {
       
   560                      publishers.AppendL( bundleId );
       
   561                      CleanupStack::Pop( bundleId );
       
   562                      }
       
   563                  else
       
   564                      {
       
   565                      CleanupStack::PopAndDestroy( bundleId );
       
   566                      }
   507                  }
   567                  }
   508              CleanupStack::PopAndDestroy( publisherMap );     
   568              CleanupStack::PopAndDestroy( publisherMap );     
   509              }
   569              }
   510             
   570             
   511         variant.Reset();
   571         variant.Reset();
   552         // Widget info map
   612         // Widget info map
   553     	  CLiwDefaultMap* widgetInfo = CLiwDefaultMap::NewLC();
   613     	  CLiwDefaultMap* widgetInfo = CLiwDefaultMap::NewLC();
   554 		    widgetInfo->InsertL( KTemplateType, TLiwVariant( KTemplateName ));
   614 		    widgetInfo->InsertL( KTemplateType, TLiwVariant( KTemplateName ));
   555 		    widgetInfo->InsertL( KWidgetName, TLiwVariant( wrtInfo.iDisplayName ));
   615 		    widgetInfo->InsertL( KWidgetName, TLiwVariant( wrtInfo.iDisplayName ));
   556 		    widgetInfo->InsertL( KWidgetIcon, TLiwVariant( wrtuid));  // uid(0x12345678) This is the expected format 
   616 		    widgetInfo->InsertL( KWidgetIcon, TLiwVariant( wrtuid));  // uid(0x12345678) This is the expected format 
       
   617             widgetInfo->InsertL( KWidgetType, TLiwVariant( TInt32 (wrtInfo.iType ) ));
   557 
   618 
   558 		    datamap->InsertL( KWidgetInfo , TLiwVariant( widgetInfo ));
   619 		    datamap->InsertL( KWidgetInfo , TLiwVariant( widgetInfo ));
   559 		    CleanupStack::PopAndDestroy( widgetInfo );
   620 		    CleanupStack::PopAndDestroy( widgetInfo );
   560         
   621         
   561 		    // Take dynamic menu items into use
   622 		    // Take dynamic menu items into use