contentpublishingsrv/contentpublishingutils/pluginvalidator/src/charvesterpluginvalidator.cpp
branchRCL_3
changeset 64 b276298d5729
parent 0 79c6a41cd166
child 101 9e077f9a342c
equal deleted inserted replaced
59:a0713522ab97 64:b276298d5729
     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:
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 #include <e32property.h>
    18 #include <e32property.h>
    19 #include <ecom/ecom.h>
    19 #include <ecom/ecom.h>
    30 
    30 
    31 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    32 //
    32 //
    33 // ----------------------------------------------------------------------------
    33 // ----------------------------------------------------------------------------
    34 //
    34 //
    35 EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewL( TUid aUid, 
    35 EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewL( TUid aUid,
    36                                                    TAny *aParameter )
    36                                                    TAny *aParameter )
    37     {
    37     {
    38     CHarvesterPluginValidator* self = 
    38     CHarvesterPluginValidator* self =
    39 					CHarvesterPluginValidator::NewLC( aUid , aParameter );
    39           CHarvesterPluginValidator::NewLC( aUid , aParameter );
    40     CleanupStack::Pop( self );
    40     CleanupStack::Pop( self );
    41     return self;
    41     return self;
    42     }
    42     }
    43 
    43 
    44 // ----------------------------------------------------------------------------
    44 // ----------------------------------------------------------------------------
    46 // ----------------------------------------------------------------------------
    46 // ----------------------------------------------------------------------------
    47 //
    47 //
    48 EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewLC( TUid aUid,
    48 EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewLC( TUid aUid,
    49                                                     TAny *aParameter )
    49                                                     TAny *aParameter )
    50     {
    50     {
    51     CHarvesterPluginValidator* self = new( ELeave ) 
    51     CHarvesterPluginValidator* self = new( ELeave )
    52 				CHarvesterPluginValidator( aUid, aParameter );
    52         CHarvesterPluginValidator( aUid, aParameter );
    53     CleanupStack::PushL( self );
    53     CleanupStack::PushL( self );
    54     self->ConstructL();
    54     self->ConstructL();
    55     return self;
    55     return self;
    56     }
    56     }
    57 
    57 
    68 
    68 
    69 // ----------------------------------------------------------------------------
    69 // ----------------------------------------------------------------------------
    70 //
    70 //
    71 // ----------------------------------------------------------------------------
    71 // ----------------------------------------------------------------------------
    72 //
    72 //
    73 CHarvesterPluginValidator::CHarvesterPluginValidator( TUid aUid, TAny* aParameter ): 
    73 CHarvesterPluginValidator::CHarvesterPluginValidator(TUid aUid,
    74 											CPluginValidator(aUid, aParameter),
    74     TAny* aParameter) :
    75                                             iStartup( ETrue )
    75     CPluginValidator(aUid, aParameter)
    76     {
    76 {
    77     
    77 
    78     }
    78 }
    79 
    79 
    80 // ----------------------------------------------------------------------------
    80 // ----------------------------------------------------------------------------
    81 //
    81 //
    82 // ----------------------------------------------------------------------------
    82 // ----------------------------------------------------------------------------
    83 //
    83 //
    84 void CHarvesterPluginValidator::ConstructL()
    84 void CHarvesterPluginValidator::ConstructL()
    85     {
    85     {
    86     iBlacklist = CBlacklistHandler::NewL( );    
    86     iBlacklist = CBlacklistHandler::NewL();
    87     CPluginValidator::ConstructL();
    87     CPluginValidator::ConstructL();
    88     }
    88     }
    89 
    89 
    90 
    90 
    91 // ----------------------------------------------------------------------------
    91 // ----------------------------------------------------------------------------
    92 //
    92 //
    93 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
    94 //
    94 //
    95 void CHarvesterPluginValidator::ManagePluginsL()    
    95 void CHarvesterPluginValidator::ManagePluginsL()
    96     {
    96     {
    97     TInt errorCode = iInProgressProperty.Define( TUid::Uid( KHarvesterUid ), 
    97     TInt errorCode = iInProgressProperty.Define( TUid::Uid( KHarvesterUid ),
    98         		KInProgressPropertyKey, RProperty::EInt );
    98             KInProgressPropertyKey, RProperty::EInt );
    99     
    99 
   100     if ( KErrAlreadyExists == errorCode )
   100     if ( KErrAlreadyExists == errorCode )
   101     	{
   101       {
   102     	TInt value(-1);
   102       TInt value(-1);
   103     	iInProgressProperty.Get( TUid::Uid( KHarvesterUid ), 
   103       iInProgressProperty.Get( TUid::Uid( KHarvesterUid ),
   104         		KInProgressPropertyKey, value);
   104             KInProgressPropertyKey, value);
   105     	if ( value == 1 )
   105       if ( value == 1 )
   106     		{
   106         {
   107     		// property value == inprogress
   107         // property value == inprogress
   108     		// there was a panic in the previous startup
   108         // there was a panic in the previous startup
   109     		// so we make unofficial blacklist official
   109         // so we make unofficial blacklist official
   110     		iBlacklist->CopyBlacklistL( EFalse );
   110         iBlacklist->CopyBlacklistL( EFalse );
   111     		}
   111         }
   112     	}
   112       }
   113     else
   113     else
   114     	{
   114       {
   115     	User::LeaveIfError( errorCode );
   115       User::LeaveIfError( errorCode );
   116     	}
   116       }
   117     // copy blacklisted plugins to unoffical blacklist at startup
   117     // copy blacklisted plugins to unoffical blacklist at startup
   118     iBlacklist->CopyBlacklistL( ETrue );
   118     iBlacklist->CopyBlacklistL( ETrue );
   119     
   119 
   120     // set property value to 1 (which means "in progress")
   120     // set property value to 1 (which means "in progress")
   121 	iInProgressProperty.Set( TUid::Uid( KHarvesterUid ), 
   121     iInProgressProperty.Set( TUid::Uid( KHarvesterUid ),
   122     		KInProgressPropertyKey, 1 );
   122         KInProgressPropertyKey, 1 );
   123     
   123 
   124     CPluginValidator::ManagePluginsL();
   124     CPluginValidator::ManagePluginsL();
   125     
   125 
   126     if ( iStartup )
       
   127     	{
       
   128     	RProperty::Set( KPSUidActiveIdle2, 
       
   129     		KActiveIdleCpsPluginsUpdated , EPSAiPluginsUpdated );
       
   130     	iStartup = EFalse;
       
   131     	}
       
   132     // set property value to 0 (which means "finished")
   126     // set property value to 0 (which means "finished")
   133 	iInProgressProperty.Set( TUid::Uid( KHarvesterUid ), 
   127     iInProgressProperty.Set( TUid::Uid( KHarvesterUid ),
   134     		KInProgressPropertyKey, 0 );
   128         KInProgressPropertyKey, 0 );
   135     }
   129     }
   136 
   130 
   137 // ----------------------------------------------------------------------------
   131 // ----------------------------------------------------------------------------
   138 //
   132 //
   139 // ----------------------------------------------------------------------------
   133 // ----------------------------------------------------------------------------
   140 //
   134 //
   141 void CHarvesterPluginValidator::LoadPluginL( TPluginInfo& aPluginInfo )    
   135 void CHarvesterPluginValidator::LoadPluginL( TPluginInfo& aPluginInfo )
   142     {
   136     {
   143     if ( !iBlacklist->IsPresentL( aPluginInfo.iImplementationUid ) )
   137     if ( !iBlacklist->IsPresentL( aPluginInfo.iImplementationUid ) )
   144     	{
   138       {
   145     	//first we append UID to the blacklist
   139       //first we append UID to the blacklist
   146     	iBlacklist->AppendL( aPluginInfo.iImplementationUid );
   140       iBlacklist->AppendL( aPluginInfo.iImplementationUid );
   147     	TAny* plug ( NULL );
   141       TAny* plug ( NULL );
   148     	TInt err( KErrNone );
   142       TInt err( KErrNone );
   149     	TRAP( err, plug = REComSession::CreateImplementationL( 
   143       TRAP( err, plug = REComSession::CreateImplementationL(
   150 										aPluginInfo.iImplementationUid, 
   144                     aPluginInfo.iImplementationUid,
   151 										aPluginInfo.iDtor_ID_Key, iParameter ) );
   145                     aPluginInfo.iDtor_ID_Key, iParameter ) );
   152     	if( err==KErrNone && plug ) 
   146       if( err==KErrNone && plug )
   153     		{
   147         {
   154 			TRAP_IGNORE( 
   148       TRAP_IGNORE(
   155 				CleanupStack::PushL( plug );
   149         CleanupStack::PushL( plug );
   156 				aPluginInfo.iPlugin = plug;
   150         aPluginInfo.iPlugin = plug;
   157 				iPluginArray.AppendL( aPluginInfo );
   151         iPluginArray.AppendL( aPluginInfo );
   158 				CleanupStack::Pop( plug );
   152         CleanupStack::Pop( plug );
   159    				static_cast<CContentHarvesterPlugin*>( plug )->UpdateL()
   153            static_cast<CContentHarvesterPlugin*>( plug )->UpdateL()
   160 						);
   154             );
   161     		}
   155         }
   162     	//no panic during load so we can remove UID from blacklist
   156       //no panic during load so we can remove UID from blacklist
   163     	iBlacklist->RemoveL( aPluginInfo.iImplementationUid );
   157       iBlacklist->RemoveL( aPluginInfo.iImplementationUid );
   164     	}
   158       }
   165     }
   159     }
   166 
   160 
   167 
   161 
   168 
   162 
   169 
   163