engine/collectionframework/datasource/plugins/glxdatasourcemde2.5/inc/glxdatasourcemds.h
changeset 36 6481344a6d67
parent 24 99ad1390cd33
child 71 27f2d7aec52a
equal deleted inserted replaced
33:1ee2af37811f 36:6481344a6d67
     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: The data source mds class   
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 
    27 
    27 
    28 #ifndef _C_GLXDATASOURCEMDS_H_
    28 #ifndef _C_GLXDATASOURCEMDS_H_
    29 #define _C_GLXDATASOURCEMDS_H_
    29 #define _C_GLXDATASOURCEMDS_H_
    30 
    30 
    31 // INCLUDES
    31 // INCLUDES
       
    32 #include <e32base.h>
       
    33 #include <w32std.h>
       
    34 #include <e32property.h> 
       
    35 
    32 #include <e32cmn.h>
    36 #include <e32cmn.h>
    33 #include <f32file.h>
    37 #include <f32file.h>
    34 
    38 
    35 #include <mdesession.h>
    39 #include <mdesession.h>
       
    40 
       
    41 #include <harvesterclient.h>
       
    42 #include <harvestereventenum.h>
       
    43 
    36 #include <mglxtnstorage.h>
    44 #include <mglxtnstorage.h>
    37 #include <mpxcollectionmessagedefs.h>
    45 #include <mpxcollectionmessagedefs.h>
    38 
    46 
    39 #ifdef USE_S60_TNM
    47 #ifdef USE_S60_TNM
    40 #include <thumbnailmanager.h>
    48 #include <thumbnailmanager.h>
    42 #include <thumbnaildata.h>
    50 #include <thumbnaildata.h>
    43 #include <thumbnailobjectsource.h>
    51 #include <thumbnailobjectsource.h>
    44 
    52 
    45 #include "mthumbnailfetchrequestobserver.h"
    53 #include "mthumbnailfetchrequestobserver.h"
    46 #endif
    54 #endif
    47 
       
    48 #include "glxdatasource.h"
    55 #include "glxdatasource.h"
    49 
    56 
    50 // FORWARD DECLARATIONS
    57 // FORWARD DECLARATIONS
    51 class CGlxRequest;
    58 class CGlxRequest;
    52 
       
    53 #ifndef USE_S60_TNM
    59 #ifndef USE_S60_TNM
    54 class CGlxtnThumbnailCreator;
    60 class CGlxtnThumbnailCreator;
    55 class CGlxtnThumbnailDatabase;
    61 class CGlxtnThumbnailDatabase;
    56 #endif
    62 #endif
       
    63 class CGlxDataSourceMde ;
       
    64 
       
    65 const TUid KHarvesterPSShutdown = { 0x200009F5 } ;
       
    66 const TInt KMdSShutdown     = 0x00000002; // values 1 = shutdown, 0 = restart, normal state
       
    67 
       
    68 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
    69 static _LIT_SECURITY_POLICY_C1(KPowerMgmtPolicy,ECapabilityPowerMgmt);
       
    70 
       
    71 /**
       
    72  * PSCW Listener Observer interface for signaling that MDS has Shutdown/restarted
       
    73  */
       
    74 class MGlxMDSShutdownObserver
       
    75     {
       
    76 public:
       
    77 
       
    78     virtual void ShutdownNotification(TInt aShutdownState) = 0;
       
    79     };
       
    80 
       
    81 /**
       
    82  *  Active object for observing P&S keys
       
    83  *
       
    84  *  @since S60 v5.0
       
    85  */
       
    86 class CGlxMDSShutdownObserver: public CActive
       
    87     {
       
    88 public:
       
    89 
       
    90     /**
       
    91      * Two-phased constructor.
       
    92      *
       
    93      * @since S60 v5.0
       
    94      * @return Instance of CGlxMDSShutdownObserver.
       
    95      */
       
    96     static CGlxMDSShutdownObserver* NewL( MGlxMDSShutdownObserver& aObserver, const TUid& aKeyCategory,
       
    97                                       const TInt aPropertyKey, TBool aDefineKey);
       
    98 
       
    99     /**
       
   100      * Destructor
       
   101      *
       
   102      * @since S60 v5.0
       
   103      */
       
   104     virtual ~CGlxMDSShutdownObserver();
       
   105     
       
   106 protected:
       
   107 
       
   108     /**
       
   109      * Handles an active object's request completion event.
       
   110      *
       
   111      * @since S60 v5.0
       
   112      */
       
   113     void RunL();
       
   114 
       
   115     /**
       
   116      * Implements cancellation of an outstanding request.
       
   117      *
       
   118      * @since S60 v5.0
       
   119      */
       
   120     void DoCancel();
       
   121 
       
   122 private:
       
   123 
       
   124     /**
       
   125      * C++ default constructor
       
   126      *
       
   127      * @since S60 v5.0
       
   128      * @return Instance of CGlxMDSShutdownObserver.
       
   129      */
       
   130     CGlxMDSShutdownObserver( MGlxMDSShutdownObserver& aObserver, const TUid& aKeyCategory,
       
   131                          const TInt iPropertyKey, TBool aDefineKey);
       
   132 
       
   133     /**
       
   134      * Symbian 2nd phase constructor can leave.
       
   135      *
       
   136      * @since S60 v5.0
       
   137      */
       
   138     void ConstructL();
       
   139 
       
   140 private:
       
   141     
       
   142     // not own
       
   143     MGlxMDSShutdownObserver& iObserver;
       
   144     
       
   145     const TUid& iKeyCategory;
       
   146     RProperty iProperty;
       
   147     TInt iPropertyKey;
       
   148     
       
   149     TBool iDefineKey;
       
   150 };
       
   151 
       
   152 
    57 
   153 
    58 // CONSTANTS
   154 // CONSTANTS
    59 
   155 
    60 // CLASS DECLARATION
   156 // CLASS DECLARATION
    61 
   157 
    66  *  @lib GlxDataSourceMde.lib
   162  *  @lib GlxDataSourceMde.lib
    67  *  @ingroup collection_component_design
   163  *  @ingroup collection_component_design
    68  */
   164  */
    69 class CGlxDataSourceMde : public CGlxDataSource,
   165 class CGlxDataSourceMde : public CGlxDataSource,
    70                           public MMdESessionObserver,
   166                           public MMdESessionObserver,
       
   167                           public MGlxMDSShutdownObserver,
    71                           public MMdEObjectObserver,
   168                           public MMdEObjectObserver,
    72                           public MMdEObjectPresentObserver,
   169                           public MMdEObjectPresentObserver,
    73                           public MMdERelationObserver,
   170                           public MMdERelationObserver,
    74                           public MMdERelationPresentObserver
   171                           public MMdERelationPresentObserver,
       
   172                           public MHarvesterEventObserver
    75 #ifdef USE_S60_TNM
   173 #ifdef USE_S60_TNM
    76 						, public MThumbnailManagerObserver
   174 						, public MThumbnailManagerObserver
    77 #else
   175 #else
    78                         , public MGlxtnThumbnailStorageObserver
   176                         , public MGlxtnThumbnailStorageObserver
    79 #endif
   177 #endif
    88     
   186     
    89     void ConstructL();
   187     void ConstructL();
    90 
   188 
    91 public:
   189 public:
    92     // from CGlxDataSource
   190     // from CGlxDataSource
    93     CGlxDataSourceTask* CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver);
   191     CGlxDataSourceTask* CreateTaskL(CGlxRequest* aRequest,
    94 
   192             MGlxDataSourceRequestObserver& aObserver);
    95 #ifdef USE_S60_TNM
   193 public:
    96 public:
   194     // from MHarvesterEventObserver
    97 	void FetchThumbnailL(CGlxRequest* aRequest, MThumbnailFetchRequestObserver& aObserver);
   195     void HarvestingUpdated( 
       
   196                 HarvesterEventObserverType aHEObserverType, 
       
   197                 HarvesterEventState aHarvesterEventState,
       
   198                 TInt aItemsLeft );
       
   199 
       
   200 #ifdef USE_S60_TNM
       
   201 public:
       
   202 	void FetchThumbnailL(CGlxRequest* aRequest, 
       
   203 	        MThumbnailFetchRequestObserver& aObserver);
    98 	TInt CancelFetchThumbnail();
   204 	TInt CancelFetchThumbnail();
    99 #else
   205 #else
   100 private: 
   206 private: 
   101     // from MGlxtnThumbnailStorageObserver
   207     // from MGlxtnThumbnailStorageObserver
   102     /**
   208     /**
   159     void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail,
   265     void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail,
   160         TThumbnailRequestId aId );
   266         TThumbnailRequestId aId );
   161 #endif
   267 #endif
   162 		
   268 		
   163 private:
   269 private:
   164     void BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError);
   270     void BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, 
       
   271             TInt aError);
   165 
   272 
   166     void DoSessionInitL();
   273     void DoSessionInitL();
   167 
   274 
   168     void AddMdEObserversL();
   275     void AddMdEObserversL();
   169 
   276 
   170     void ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType, TBool aIsObject);
   277     void ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType,
       
   278             TBool aIsObject);
   171 
   279 
   172     void ProcessItemUpdateL();
   280     void ProcessItemUpdateL();
   173 
   281 
   174     static TInt ProcessItemUpdate(TAny* aPtr);
   282     static TInt ProcessItemUpdate(TAny* aPtr);
   175     void CreateSessionL();
   283     void CreateSessionL();
   178 
   286 
   179     void PrepareMonthsL();
   287     void PrepareMonthsL();
   180     void TaskCompletedL();
   288     void TaskCompletedL();
   181 
   289 
   182     void TaskStartedL();
   290     void TaskStartedL();
   183 
   291     
   184 public:
   292 #ifdef USE_S60_TNM
       
   293     /*
       
   294      * This function doesnt add up any value, added to reduce compiler warnings
       
   295      */
       
   296     void ThumbnailReadyL( TInt aError, MThumbnailData& aThumbnail,
       
   297         TThumbnailRequestId aId, TBool aQuality );
       
   298 #endif
       
   299     
       
   300 public:
       
   301 
       
   302     void CreateSession();
       
   303     
   185     inline CMdESession& Session() const;
   304     inline CMdESession& Session() const;
   186     
   305     
   187 #ifndef USE_S60_TNM
   306 #ifndef USE_S60_TNM
   188     inline CGlxtnThumbnailCreator& ThumbnailCreator() const;
   307     inline CGlxtnThumbnailCreator& ThumbnailCreator() const;
   189 
   308 
   234     const TGlxMediaId GetMonthIdL(const TTime& aMonth);
   353     const TGlxMediaId GetMonthIdL(const TTime& aMonth);
   235 
   354 
   236     TBool SameMonth(const TTime& aOldDate, const TTime& aNewDate);
   355     TBool SameMonth(const TTime& aOldDate, const TTime& aNewDate);
   237      
   356      
   238 	TBool ContainerIsLeft(CMdEObjectDef& aObjectDef);    
   357 	TBool ContainerIsLeft(CMdEObjectDef& aObjectDef);    
       
   358 	
       
   359 	// from MGlxMDSShutdownObserver
       
   360     void ShutdownNotification(TInt aShutdownState);
   239 
   361 
   240 private:
   362 private:
   241 #ifdef USE_S60_TNM
   363 #ifdef USE_S60_TNM
   242 	MThumbnailFetchRequestObserver* iTnFetchObserver; 
   364 	MThumbnailFetchRequestObserver* iTnFetchObserver; 
   243     CThumbnailManager* iTnEngine;
   365     CThumbnailManager* iTnEngine;
   245     CFbsBitmap* iThumbnail;
   367     CFbsBitmap* iThumbnail;
   246     TThumbnailRequestId iTnThumbnailCbId;
   368     TThumbnailRequestId iTnThumbnailCbId;
   247     TBool iTnRequestInProgress;
   369     TBool iTnRequestInProgress;
   248     TInt iTnHandle;
   370     TInt iTnHandle;
   249     TGlxMediaId iMediaId;
   371     TGlxMediaId iMediaId;
   250 #ifdef _DEBUG   
   372     
   251 	TTime iStartTime;
       
   252 	TTime iStopTime;
       
   253 #endif
       
   254 #else
   373 #else
   255     CGlxtnThumbnailCreator*   iThumbnailCreator;
   374     CGlxtnThumbnailCreator*   iThumbnailCreator;
   256     CGlxtnThumbnailDatabase*  iThumbnailDatabase;
   375     CGlxtnThumbnailDatabase*  iThumbnailDatabase;
   257 #endif
   376 #endif
   258 
   377 
   277     CMdERelationDef* iContainsDef;
   396     CMdERelationDef* iContainsDef;
   278     CMdERelationDef* iContainsLocationDef;
   397     CMdERelationDef* iContainsLocationDef;
   279     
   398     
   280     RArray<TTime> iMonthArray;
   399     RArray<TTime> iMonthArray;
   281     RArray<TGlxMediaId> iMonthList;
   400     RArray<TGlxMediaId> iMonthList;
       
   401     RArray<TItemId> iAddedItems;
       
   402     
   282     TTime iFirstMonth;
   403     TTime iFirstMonth;
   283     TTime iLastMonth;
   404     TTime iLastMonth;
   284     
   405     
   285     CAsyncCallBack* iUpdateCallback;
   406     CAsyncCallBack* iUpdateCallback;
   286     
   407     
   294         };
   415         };
   295     
   416     
   296     RArray<TUpdateData> iUpdateData;
   417     RArray<TUpdateData> iUpdateData;
   297 	TBool iPauseUpdate;
   418 	TBool iPauseUpdate;
   298     TInt iDeletedCount;
   419     TInt iDeletedCount;
       
   420     
       
   421     RHarvesterClient iHC;
       
   422     TBool iHarvestingOngoing;
       
   423 
       
   424     CGlxMDSShutdownObserver* iMDSShutdownObserver;
       
   425 
       
   426 #ifdef _DEBUG
       
   427     TTime iStartTime;
       
   428     TTime iStopTime;
       
   429 #endif    
   299     };
   430     };
   300 
   431 
   301 #include "glxdatasourcemds.inl"
   432 #include "glxdatasourcemds.inl"
   302 
   433 
   303 #endif //_C_GLXDATASOURCEMDE_H_
   434 #endif //_C_GLXDATASOURCEMDE_H_