contentpublishingsrv/contentharvester/contentharvesterserver/src/contentharvesterengine.cpp
changeset 93 82b66994846c
parent 92 782e3408c2ab
child 94 dbb8300717f7
equal deleted inserted replaced
92:782e3408c2ab 93:82b66994846c
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Content Harvester Engine
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // for CleanupResetAndDestroyPushL
       
    20 #include <mmf/common/mmfcontrollerpluginresolver.h>
       
    21 #include <contentharvesterplugin.h> // harvesting plugin
       
    22 #include <liwservicehandler.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 #include "charvesterpluginvalidator.h"
       
    26 #include "contentharvesterpluginuids.hrh"
       
    27 #include "cpglobals.h"
       
    28 #include "cpdebug.h"
       
    29 #include "contentharvesterengine.h"
       
    30 
       
    31 // LOCAL CONSTANTS
       
    32 const TInt KADatFactorySettingsServerPluginUid( 0x102830EF);
       
    33 
       
    34 
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 // -----------------------------------------------------------------------------
       
    38 // CContentHarvesterEngine::CContentHarvesterEngine
       
    39 // C++ default constructor can NOT contain any code, that
       
    40 // might leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CContentHarvesterEngine::CContentHarvesterEngine()
       
    44     {
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CContentHarvesterEngine::ConstructL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CContentHarvesterEngine::ConstructL()
       
    53     {
       
    54     CP_DEBUG(_L8("Create Engine" ));
       
    55 
       
    56     CP_DEBUG(_L8("Start delayed update" ));
       
    57     // start updating process
       
    58 
       
    59     iServiceHandler = CLiwServiceHandler::NewL( );
       
    60     // for convinience keep pointers to Service Handler param lists
       
    61     CLiwGenericParamList* inParamList = &iServiceHandler->InParamListL( );
       
    62     CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL( );
       
    63 
       
    64     RCriteriaArray criteriaArray;
       
    65     CleanupResetAndDestroyPushL( criteriaArray );
       
    66 
       
    67     // create Liw criteria
       
    68     CLiwCriteriaItem* criterion = CLiwCriteriaItem::NewLC( KLiwCmdAsStr,
       
    69         KCPInterface, KCPService );
       
    70     criterion->SetServiceClass( TUid::Uid( KLiwClassBase ) );
       
    71 
       
    72     criteriaArray.AppendL( criterion );
       
    73     CleanupStack::Pop( criterion );
       
    74 
       
    75     // attach Liw criteria
       
    76     iServiceHandler->AttachL( criteriaArray );
       
    77     // get BS Service interface
       
    78     iServiceHandler->ExecuteServiceCmdL( *criterion, *inParamList,
       
    79         *outParamList );
       
    80 
       
    81     CleanupStack::PopAndDestroy( &criteriaArray );
       
    82 
       
    83     TInt pos( 0);
       
    84     outParamList->FindFirst( pos, KCPInterface );
       
    85     if ( pos != KErrNotFound )
       
    86         {
       
    87         iCPSInterface = (*outParamList)[pos].Value().AsInterface( );
       
    88         }
       
    89     
       
    90     iPluginManager = CHarvesterPluginValidator::NewL( 
       
    91                                     TUid::Uid( KContentHarvesterPluginUid ),
       
    92                                     iCPSInterface );
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CContentHarvesterEngine::~CContentHarvesterEngine
       
    97 // Destructor.
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CContentHarvesterEngine::~CContentHarvesterEngine()
       
   101     {
       
   102     if ( iCPSInterface )
       
   103         {
       
   104         iCPSInterface->Close( );
       
   105         }
       
   106     delete iServiceHandler;
       
   107     delete iPluginManager;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CContentHarvesterEngine::NewL
       
   112 // Two-phased constructor.
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 CContentHarvesterEngine* CContentHarvesterEngine::NewL()
       
   116     {
       
   117     CContentHarvesterEngine* self = CContentHarvesterEngine::NewLC( );
       
   118     CleanupStack::Pop( self ) ;
       
   119     return self;
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CContentHarvesterEngine::NewLC
       
   124 // Two-phased constructor.
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 CContentHarvesterEngine* CContentHarvesterEngine::NewLC()
       
   128     {
       
   129     CContentHarvesterEngine* self = new ( ELeave ) CContentHarvesterEngine();
       
   130     CleanupStack::PushL( self );
       
   131     self->ConstructL( ) ;
       
   132     return self;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CContentHarvesterEngine::Update
       
   137 // Pass request for update to all installed plugins
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CContentHarvesterEngine::Update()
       
   141     {
       
   142     CP_DEBUG(_L8("CContentHarvesterEngine::Update" ));
       
   143     CContentHarvesterPlugin*    plugin( NULL );
       
   144     CContentHarvesterPlugin*    fsplugin = 
       
   145                                 static_cast<CContentHarvesterPlugin*>
       
   146                                 ( iPluginManager->GetImplementation( 
       
   147                                 TUid::Uid( KADatFactorySettingsServerPluginUid) ) );
       
   148 								
       
   149 	if (fsplugin)
       
   150 		{							
       
   151 		TRAP_IGNORE( fsplugin->UpdateL() );
       
   152 		}
       
   153 	
       
   154 	for ( TInt i = 0; i < iPluginManager->GetCount(); i++ )
       
   155 		{
       
   156 		plugin = static_cast<CContentHarvesterPlugin*>
       
   157                                ( iPluginManager->GetImplementation( i ) );
       
   158 		if( plugin!= fsplugin )
       
   159 			{
       
   160 			TRAP_IGNORE( plugin->UpdateL() );    
       
   161 			}
       
   162 		}	
       
   163     }
       
   164 
       
   165 // End of File
       
   166 
       
   167