clfwrapper/ClientSrc/CCLFServerProxy.h
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CCLFSERVERPROXY_H
       
    20 #define CCLFSERVERPROXY_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <badesca.h>
       
    25 #include <f32file.h>
       
    26 #include <mdesession.h>
       
    27 #include <mdeobjectquery.h>
       
    28 #include <harvesterclient.h>
       
    29 #include <CLFContentListing.h>
       
    30 #include "CLFConsts.h"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CActiveSchedulerWait;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 *  Abstract base class for handling different types of UpdateItems requests.
       
    39 *
       
    40 *  @lib ContentListingFramework.lib
       
    41 *  @since Series 60 5.0
       
    42 */
       
    43 NONSHARABLE_CLASS( CUpdateItemsHandler ) : public CBase
       
    44     {
       
    45     public:
       
    46         virtual void StartHandlingL() = 0;
       
    47         
       
    48         virtual void HandleObjectNotification( TItemId aId, TObserverNotificationType aType ) = 0;
       
    49 
       
    50         virtual TBool WasNotificationHandled() const;
       
    51 
       
    52         virtual TBool AllDone() const = 0;
       
    53 
       
    54         virtual void StartScheduler();
       
    55 
       
    56         virtual void AsyncStopScheduler();
       
    57         
       
    58         virtual void SetRemoveObserverFlag( TBool aRemove );
       
    59 
       
    60     public:
       
    61 
       
    62         /**
       
    63          * Destructor.
       
    64          */
       
    65         virtual ~CUpdateItemsHandler() {}
       
    66 
       
    67     protected:
       
    68 
       
    69         /**
       
    70          * C++ default constructor.
       
    71          */
       
    72         inline CUpdateItemsHandler();
       
    73 
       
    74     protected:
       
    75         // Ref.
       
    76         CActiveSchedulerWait iScheduler;
       
    77         // Own.
       
    78         TBool iWasNotificationHandled;
       
    79         // Ref.
       
    80         MMdEObjectObserver* iParentObserver;
       
    81         // Ref.
       
    82         MMdEObjectPresentObserver* iParentPresentObserver;
       
    83         // Own
       
    84         TBool iRemoveObserver;
       
    85     };
       
    86 
       
    87 /**
       
    88 *  ID-based UpdateItems request handler.
       
    89 *
       
    90 *  @lib ContentListingFramework.lib
       
    91 *  @since Series 60 5.0
       
    92 */
       
    93 NONSHARABLE_CLASS( CUpdateIDsHandler ) : public CUpdateItemsHandler
       
    94     {
       
    95     public: // Constructors and destructor
       
    96 
       
    97         /**
       
    98          * Two-phased constructor.
       
    99          */
       
   100         static CUpdateIDsHandler* NewL( const TArray< TCLFItemId >& aItemIDArray );
       
   101 
       
   102         /**
       
   103          * Destructor.
       
   104          */
       
   105         virtual ~CUpdateIDsHandler();
       
   106 
       
   107     protected: // Functions from base classes
       
   108 
       
   109         /**
       
   110          * From CUpdateItemsHandler
       
   111          */
       
   112         virtual void StartHandlingL();
       
   113         
       
   114         /**
       
   115          * From CUpdateItemsHandler
       
   116          */
       
   117         void HandleObjectNotification( TItemId aId, TObserverNotificationType aType );
       
   118 
       
   119         /**
       
   120          * From CUpdateItemsHandler
       
   121          */
       
   122         TBool AllDone() const;
       
   123 
       
   124     private:
       
   125 
       
   126         /**
       
   127          * C++ default constructor.
       
   128          */
       
   129         inline CUpdateIDsHandler( const TArray< TCLFItemId >& aItemIDArray );
       
   130 
       
   131     private:
       
   132         // Own.
       
   133         RArray< TCLFItemId > iIdsPendingUpdate;
       
   134     };
       
   135 
       
   136 /**
       
   137 *  UpdateItems request handler for requests with KCLFItemsDeletedSemanticId.
       
   138 *
       
   139 *  @lib ContentListingFramework.lib
       
   140 *  @since Series 60 5.0
       
   141 */
       
   142 NONSHARABLE_CLASS( CItemsDeletedHandler ) : public CUpdateItemsHandler
       
   143     {
       
   144     public: // Constructors and destructor
       
   145 
       
   146         /**
       
   147          * Two-phased constructor.
       
   148          */
       
   149         static CItemsDeletedHandler* NewL( CMdESession& aMdESession, 
       
   150                                                                 const CDesCArray& aUriArray, 
       
   151                                                                 MMdEObjectObserver* aParentObserver,
       
   152                                                                 MMdEObjectPresentObserver* aParentPresentObserver );
       
   153 
       
   154         /**
       
   155          * Destructor.
       
   156          */
       
   157         virtual ~CItemsDeletedHandler();
       
   158 
       
   159     protected: // Functions from base classes
       
   160 
       
   161         /**
       
   162          * From CUpdateItemsHandler
       
   163          */
       
   164         virtual void StartHandlingL();
       
   165 
       
   166         /**
       
   167          * From CUpdateItemsHandler
       
   168          */
       
   169         void HandleObjectNotification( TItemId aId, TObserverNotificationType aType );
       
   170 
       
   171         /**
       
   172          * From CUpdateItemsHandler
       
   173          */
       
   174         TBool AllDone() const;
       
   175 
       
   176     private:
       
   177 
       
   178         /**
       
   179          * C++ default constructor.
       
   180          */
       
   181         inline CItemsDeletedHandler( CMdESession& aMdESession );
       
   182 
       
   183         /**
       
   184          * By default Symbian 2nd phase constructor is private.
       
   185          */
       
   186         inline void ConstructL( const CDesCArray& aUriArray, 
       
   187                                              MMdEObjectObserver* aParentObserver,
       
   188                                              MMdEObjectPresentObserver* aParentPresentObserver );
       
   189 
       
   190     private:
       
   191         // Own.
       
   192         RPointerArray< CMdEObject > iObjectsPendingRemoval;
       
   193         // Own.
       
   194         RArray< TCLFItemId > iIdsPendingRemoval;
       
   195         // Ref.
       
   196         CMdESession& iMdESession;
       
   197     };
       
   198 
       
   199 /**
       
   200 *  UpdateItems request handler for requests with KCLFUpdateFoldersSemanticId.
       
   201 *
       
   202 *  @lib ContentListingFramework.lib
       
   203 *  @since Series 60 5.0
       
   204 */
       
   205 NONSHARABLE_CLASS( CUpdateFoldersHandler ) : public CUpdateItemsHandler,
       
   206                                              public MMdEQueryObserver,
       
   207                                              public MHarvestObserver
       
   208     {
       
   209     public: // Constructors and destructor
       
   210 
       
   211         /**
       
   212         * Two-phased constructor.
       
   213         */
       
   214         static CUpdateFoldersHandler* NewL( CMdESession& aMdESession, 
       
   215                                                                  const CDesCArray& aUriArray,
       
   216                                                                  MMdEObjectObserver* aParentObserver,
       
   217                                                                  MMdEObjectPresentObserver* aParentPresentObserver,
       
   218                                                                  RFs& aFs,
       
   219                                                                  RHarvesterClient& aHarvester,
       
   220                                                                  CDesCArray* aSupportedTypes );
       
   221 
       
   222         /**
       
   223         * Destructor.
       
   224         */
       
   225         virtual ~CUpdateFoldersHandler();
       
   226 
       
   227     protected: // Functions from base classes
       
   228 
       
   229         /**
       
   230          * From CUpdateItemsHandler
       
   231          */
       
   232         virtual void StartHandlingL();
       
   233 
       
   234         /**
       
   235          * From CUpdateItemsHandler
       
   236          */
       
   237         void HandleObjectNotification( TItemId aId, TObserverNotificationType aType );
       
   238 
       
   239         /**
       
   240          * From CUpdateItemsHandler
       
   241          */
       
   242         TBool AllDone() const;
       
   243 
       
   244         /**
       
   245          * From MMdEQueryObserver
       
   246          */
       
   247         void HandleQueryNewResults( CMdEQuery& aQuery, TInt aFirstNewItemIndex, TInt aNewItemCount );
       
   248 
       
   249         /**
       
   250          * From MMdEQueryObserver
       
   251          */
       
   252         void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError );
       
   253 
       
   254     private:
       
   255 
       
   256         /**
       
   257         * C++ default constructor.
       
   258         */
       
   259         inline CUpdateFoldersHandler( CMdESession& aMdESession, 
       
   260                                                          RFs& aFs, 
       
   261                                                          RHarvesterClient& aHarvester,
       
   262                                                          CDesCArray* aSupportedTypes );
       
   263 
       
   264         /**
       
   265         * By default Symbian 2nd phase constructor is private.
       
   266         */
       
   267         inline void ConstructL( const CDesCArray& aUriArray, 
       
   268                                              MMdEObjectObserver* aParentObserver, 
       
   269                                              MMdEObjectPresentObserver* aParentPresentObserver );
       
   270 
       
   271         void ScanNodeForUrisL( const TDesC16& aNodeName, CDesCArray& aUriArray, CDesCArray& aFolderArray );
       
   272 
       
   273         void DetermineIdsToRemoveL ( const CMdEObjectQuery& aQuery );
       
   274 
       
   275         void DetermineIdsToUpdateL ( const CDesCArray& aUriArray );
       
   276 
       
   277         void DoQueryL( CMdEObjectQuery*& aQuery, const CDesCArray& aFolderArray );
       
   278 
       
   279         void DoHarvestL( const TDesC& aUri );
       
   280 
       
   281         void HarvestingComplete( TDesC& aURI, TInt aError );
       
   282         
       
   283         TBool IsSupportedType( const TDesC& aExtension );
       
   284 
       
   285     private:
       
   286         // Ref.
       
   287         RFs iFs;
       
   288         // Own.
       
   289         CDesCArraySeg iUrisFound;
       
   290         // Own.
       
   291         CDesCArraySeg iFoldersFound;
       
   292         // Own.
       
   293         RArray< TCLFItemId > iIdsPendingRemoval;
       
   294         // Own
       
   295         RArray< TCLFItemId >  iIdsPendingUpdate;
       
   296         // Own
       
   297         RArray< TCLFItemId > iIdsHandled;
       
   298         // Ref.
       
   299         CMdESession& iMdESession;
       
   300         // Ref.
       
   301         RHarvesterClient iHarvester;
       
   302         // Own.
       
   303         TFileName iHarvestingFile;
       
   304         // Own.
       
   305         TInt iHarvestError;
       
   306         // Own
       
   307         TBool iStartingHandling;
       
   308         // Not owned.
       
   309         CDesCArray* iExtensionArray;
       
   310         
       
   311         TBool iHarvestingOngoing;
       
   312     };
       
   313 
       
   314 /**
       
   315 *  Client-side proxy class for simulating the CLF server.
       
   316 *
       
   317 *  @lib ContentListingFramework.lib
       
   318 *  @since Series 60 5.0
       
   319 */
       
   320 NONSHARABLE_CLASS( CCLFServerProxy ) : public CBase,
       
   321                                        public MMdEObjectObserver,
       
   322                                        public MHarvesterEventObserver,//clf_wrapper_improve add
       
   323                                        public MMdEObjectPresentObserver
       
   324     {
       
   325     public: // Constructors and destructor
       
   326 
       
   327         /**
       
   328         * Two-phased constructor.
       
   329         */
       
   330         static CCLFServerProxy* NewL( CMdESession& aMdESession );
       
   331 
       
   332         /**
       
   333         * Destructor.
       
   334         */
       
   335         virtual ~CCLFServerProxy();
       
   336 
       
   337     public:
       
   338 
       
   339         void GetUpdateEndEvent( TRequestStatus& aRequestStatus );
       
   340 
       
   341         TInt CancelGetEvent();
       
   342 
       
   343         void GetUpdateStartEvent( TRequestStatus& aRequestStatus );
       
   344 
       
   345         TInt CancelGetUpdateStartEvent();
       
   346 
       
   347         TInt FetchItemListData( RArray< TCLFItemId >& aItemIDArray );
       
   348 
       
   349         TInt UpdateItemsL( const TArray< TCLFItemId >& aItemIDArray );
       
   350 
       
   351         TInt UpdateItemsL( TInt aSemanticId, const TDesC8& aOpaqueData );
       
   352 
       
   353         TInt UpdateAllItemsL();
       
   354 
       
   355         /**
       
   356          * From MMdEObjectObserver
       
   357          */
       
   358          void HandleObjectNotification( CMdESession& aSession,
       
   359                                         TObserverNotificationType aType,
       
   360                                         const RArray<TItemId>& aObjectIdArray );
       
   361          
       
   362          /**
       
   363           * From MMdEObjectPresentObserver
       
   364           */
       
   365           void HandleObjectPresentNotification( CMdESession& aSession, 
       
   366                                                                          TBool aPresent, 
       
   367                                                                          const RArray<TItemId>& aObjectIdArray );
       
   368         // clf_wrapper_improve add
       
   369       	void HarvestingUpdated( 
       
   370       				HarvesterEventObserverType aHEObserverType, 
       
   371       				HarvesterEventState aHarvesterEventState,
       
   372       				TInt aItemsLeft );
       
   373       	// clf_wrapper_improve end
       
   374     private:
       
   375         /**
       
   376         * C++ default constructor.
       
   377         */
       
   378         inline CCLFServerProxy( CMdESession& aMdESession );
       
   379 
       
   380         /**
       
   381         * By default Symbian 2nd phase constructor is private.
       
   382         */
       
   383         inline void ConstructL();
       
   384 
       
   385         void StartHandlingL( CUpdateItemsHandler* aHandler );
       
   386 
       
   387          void NotifyUpdateEvent( const TCLFServerOpCodes aOpCode );
       
   388 
       
   389          void DeSerializeL( const TDesC8& aData, CDesCArray& aDataArray );
       
   390 
       
   391          void ProcessObjectId( const CMdEObject* aObject );
       
   392 
       
   393          void GetEvent( TRequestStatus& aRequestStatus, TCLFServerOpCodes aOpcode );
       
   394 
       
   395          void CancelGetEvent( TCLFServerOpCodes aOpcode );
       
   396          
       
   397          void PopulateSupportedExtensionL();
       
   398 
       
   399     private: // Data
       
   400         // Own.
       
   401         RPointerArray< TRequestStatus > iStatusArray;
       
   402         // Own.
       
   403         RArray< TCLFServerOpCodes > iOpCodeArray;
       
   404         // Own.
       
   405         RArray< TCLFItemId > iUpdatedIds;
       
   406         // Own.
       
   407         RPointerArray< CUpdateItemsHandler > iUpdateItemsHandlerArray;
       
   408         // Ref.
       
   409         CMdESession& iMdESession;
       
   410         // Own.
       
   411         CDesCArray* iUriArray;
       
   412         // Own.
       
   413         CDesCArray* iExtensionArray;
       
   414         // Own.
       
   415         RFs iFs;
       
   416 
       
   417         RHarvesterClient iHC;
       
   418         
       
   419         TBool iHEStateFinished;
       
   420         
       
   421         TBool iNeedNotifyCLFGetUpdateEvent;
       
   422         
       
   423         TInt iDelayNotifyCLFGetUpdateEventCount;
       
   424     };
       
   425 
       
   426 #endif // CCLFSERVERPROXY_H
       
   427 
       
   428 // End of File