photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/inc/glxdatasourcemds.h
changeset 0 4e91876724a2
child 14 ce1c7ad1f18b
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-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: The data source mds class   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @author Simon Brooks, Alex Birkett
       
    23  */
       
    24 
       
    25 /**
       
    26  * @internal reviewed 10/07/2007 by M Byrne
       
    27  */
       
    28 
       
    29 #ifndef _C_GLXDATASOURCEMDS_H_
       
    30 #define _C_GLXDATASOURCEMDS_H_
       
    31 
       
    32 // INCLUDES
       
    33 #include <e32base.h>
       
    34 #include <w32std.h>
       
    35 #include <e32property.h> 
       
    36 
       
    37 #include <e32cmn.h>
       
    38 #include <f32file.h>
       
    39 
       
    40 #include <mdesession.h>
       
    41 
       
    42 #include <harvesterclient.h>
       
    43 #include <harvestereventenum.h>
       
    44 
       
    45 #include <mglxtnstorage.h>
       
    46 #include <mpxcollectionmessagedefs.h>
       
    47 
       
    48 #ifdef USE_S60_TNM
       
    49 #include <thumbnailmanager.h>
       
    50 #include <thumbnailmanagerobserver.h>
       
    51 #include <thumbnaildata.h>
       
    52 #include <thumbnailobjectsource.h>
       
    53 
       
    54 #include "mthumbnailfetchrequestobserver.h"
       
    55 #endif
       
    56 #include "glxdatasource.h"
       
    57 
       
    58 // FORWARD DECLARATIONS
       
    59 class CGlxRequest;
       
    60 #ifndef USE_S60_TNM
       
    61 class CGlxtnThumbnailCreator;
       
    62 class CGlxtnThumbnailDatabase;
       
    63 #endif
       
    64 class CGlxDataSourceMde ;
       
    65 
       
    66 // Use this till MDS bug is fixed. Then KMdSPSShutdown is to be used.   
       
    67 const TUid KHarvesterPSShutdown = { 0x200009F5 } ;
       
    68 //const TUid KMdSPSShutdown   = { 0x20022E94 };
       
    69 const TInt KMdSShutdown     = 0x00000002; // values 1 = shutdown, 0 = restart, normal state
       
    70 
       
    71 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
    72 static _LIT_SECURITY_POLICY_C1(KPowerMgmtPolicy,ECapabilityPowerMgmt);
       
    73 
       
    74 /**
       
    75  * PSCW Listener Observer interface for signaling that MDS has Shutdown/restarted
       
    76  */
       
    77 class MGlxMDSShutdownObserver
       
    78     {
       
    79 public:
       
    80 
       
    81     virtual void ShutdownNotification(TInt aShutdownState) = 0;
       
    82     };
       
    83 
       
    84 /**
       
    85  *  Active object for observing P&S keys
       
    86  *
       
    87  *  @since S60 v5.0
       
    88  */
       
    89 class CGlxMDSShutdownObserver: public CActive
       
    90     {
       
    91 public:
       
    92 
       
    93     /**
       
    94      * Two-phased constructor.
       
    95      *
       
    96      * @since S60 v5.0
       
    97      * @return Instance of CGlxMDSShutdownObserver.
       
    98      */
       
    99     static CGlxMDSShutdownObserver* NewL( MGlxMDSShutdownObserver& aObserver, const TUid& aKeyCategory,
       
   100                                       const TInt aPropertyKey, TBool aDefineKey);
       
   101 
       
   102     /**
       
   103      * Destructor
       
   104      *
       
   105      * @since S60 v5.0
       
   106      */
       
   107     virtual ~CGlxMDSShutdownObserver();
       
   108     
       
   109 protected:
       
   110 
       
   111     /**
       
   112      * Handles an active object's request completion event.
       
   113      *
       
   114      * @since S60 v5.0
       
   115      */
       
   116     void RunL();
       
   117 
       
   118     /**
       
   119      * Implements cancellation of an outstanding request.
       
   120      *
       
   121      * @since S60 v5.0
       
   122      */
       
   123     void DoCancel();
       
   124 
       
   125 private:
       
   126 
       
   127     /**
       
   128      * C++ default constructor
       
   129      *
       
   130      * @since S60 v5.0
       
   131      * @return Instance of CGlxMDSShutdownObserver.
       
   132      */
       
   133     CGlxMDSShutdownObserver( MGlxMDSShutdownObserver& aObserver, const TUid& aKeyCategory,
       
   134                          const TInt iPropertyKey, TBool aDefineKey);
       
   135 
       
   136     /**
       
   137      * Symbian 2nd phase constructor can leave.
       
   138      *
       
   139      * @since S60 v5.0
       
   140      */
       
   141     void ConstructL();
       
   142 
       
   143 private:
       
   144     
       
   145     // not own
       
   146     MGlxMDSShutdownObserver& iObserver;
       
   147     
       
   148     const TUid& iKeyCategory;
       
   149     RProperty iProperty;
       
   150     TInt iPropertyKey;
       
   151     
       
   152     TBool iDefineKey;
       
   153 };
       
   154 
       
   155 
       
   156 
       
   157 // CONSTANTS
       
   158 
       
   159 // CLASS DECLARATION
       
   160 
       
   161 /**
       
   162  *  CGlxDataSourceMde class 
       
   163  *
       
   164  *  Data Source Mde is a Meta Data Data Source.
       
   165  *  @lib GlxDataSourceMde.lib
       
   166  *  @ingroup collection_component_design
       
   167  */
       
   168 class CGlxDataSourceMde : public CGlxDataSource,
       
   169                           public MMdESessionObserver,
       
   170                           public MGlxMDSShutdownObserver,
       
   171                           public MMdEObjectObserver,
       
   172                           public MMdEObjectPresentObserver,
       
   173                           public MMdERelationObserver,
       
   174                           public MMdERelationPresentObserver,
       
   175                           public MHarvesterEventObserver
       
   176 #ifdef USE_S60_TNM
       
   177 						, public MThumbnailManagerObserver
       
   178 #else
       
   179                         , public MGlxtnThumbnailStorageObserver
       
   180 #endif
       
   181     {
       
   182 public:
       
   183     static CGlxDataSourceMde* NewL();
       
   184 
       
   185 private:
       
   186     ~CGlxDataSourceMde();
       
   187     
       
   188     CGlxDataSourceMde();
       
   189     
       
   190     void ConstructL();
       
   191 
       
   192 public:
       
   193     // from CGlxDataSource
       
   194     CGlxDataSourceTask* CreateTaskL(CGlxRequest* aRequest,
       
   195             MGlxDataSourceRequestObserver& aObserver);
       
   196 public:
       
   197     // from MHarvesterEventObserver
       
   198     void HarvestingUpdated( 
       
   199                 HarvesterEventObserverType aHEObserverType, 
       
   200                 HarvesterEventState aHarvesterEventState,
       
   201                 TInt aItemsLeft );
       
   202 
       
   203 #ifdef USE_S60_TNM
       
   204 public:
       
   205 	void FetchThumbnailL(CGlxRequest* aRequest, 
       
   206 	        MThumbnailFetchRequestObserver& aObserver);
       
   207 	TInt CancelFetchThumbnail();
       
   208 #else
       
   209 private: 
       
   210     // from MGlxtnThumbnailStorageObserver
       
   211     /**
       
   212     * Notify that a given thumbnail is available in storage.
       
   213     * @param aId Media item ID.
       
   214     * @param aSize Requested thumbnail size.
       
   215     */
       
   216     void ThumbnailAvailable(const TGlxMediaId& aId, const TSize& aSize);
       
   217     /**
       
   218     * Notify that a given thumbnail is available in storage.
       
   219     * @param aId Media item ID.
       
   220     * @param aSize Thumbnail size.
       
   221     */
       
   222     void BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError);
       
   223 #endif
       
   224 
       
   225 private: 
       
   226     /**
       
   227     *  from MMdESessionObserver
       
   228     */
       
   229     void HandleSessionOpened(CMdESession& aSession, TInt aError);
       
   230     
       
   231     void HandleSessionError(CMdESession& aSession, TInt aError);
       
   232 
       
   233 private: // MMdEObjectObserver
       
   234 	/**
       
   235 	 * See @ref MMdEObjectObserver::HandleObjectNotification
       
   236 	 */
       
   237 	void HandleObjectNotification(CMdESession& aSession, 
       
   238 						TObserverNotificationType aType,
       
   239 						const RArray<TItemId>& aObjectIdArray);
       
   240 
       
   241 private: // MMdEObjectPresentObserver
       
   242 	/**
       
   243 	 * See @ref MMdEObjectPresentObserver::HandleObjectPresentNotification
       
   244 	 */
       
   245 	void HandleObjectPresentNotification(CMdESession& aSession, 
       
   246 			TBool aPresent, const RArray<TItemId>& aObjectIdArray);
       
   247 
       
   248 private: // MMdERelationObserver
       
   249 	/**
       
   250 	 * See @ref MMdERelationObserver::HandleRelationNotification
       
   251 	 */
       
   252 	void HandleRelationNotification(CMdESession& aSession, 
       
   253 			TObserverNotificationType aType,
       
   254 			const RArray<TItemId>& aRelationIdArray);
       
   255 	    
       
   256 private: //MMdERelationPresentObserver
       
   257 	/**
       
   258 	 * See @ref MMdERelationPresentObserver::HandleRelationPresentNotification
       
   259 	 */
       
   260 	void HandleRelationPresentNotification(CMdESession& aSession,
       
   261 			TBool aPresent, const RArray<TItemId>& aRelationIdArray);
       
   262 
       
   263 #ifdef USE_S60_TNM
       
   264     // from MThumbnailManagerObserver
       
   265     void ThumbnailPreviewReady( MThumbnailData& aThumbnail,
       
   266         TThumbnailRequestId aId );
       
   267     
       
   268     void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail,
       
   269         TThumbnailRequestId aId );
       
   270 #endif
       
   271 		
       
   272 private:
       
   273     void BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, 
       
   274             TInt aError);
       
   275 
       
   276     void DoSessionInitL();
       
   277 
       
   278     void AddMdEObserversL();
       
   279 
       
   280     void ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType,
       
   281             TBool aIsObject);
       
   282 
       
   283     void ProcessItemUpdateL();
       
   284 
       
   285     static TInt ProcessItemUpdate(TAny* aPtr);
       
   286     void CreateSessionL();
       
   287 
       
   288     static TInt CreateSession(TAny* aPtr);
       
   289 
       
   290     void PrepareMonthsL();
       
   291     void TaskCompletedL();
       
   292 
       
   293     void TaskStartedL();
       
   294     
       
   295 #ifdef USE_S60_TNM
       
   296     /*
       
   297      * This function doesnt add up any value, added to reduce compiler warnings
       
   298      */
       
   299     void ThumbnailReadyL( TInt aError, MThumbnailData& aThumbnail,
       
   300         TThumbnailRequestId aId, TBool aQuality );
       
   301 #endif
       
   302     
       
   303 public:
       
   304 
       
   305     void CreateSession();
       
   306     
       
   307     inline CMdESession& Session() const;
       
   308     
       
   309 #ifndef USE_S60_TNM
       
   310     inline CGlxtnThumbnailCreator& ThumbnailCreator() const;
       
   311 
       
   312     inline CGlxtnThumbnailDatabase& ThumbnailDatabase() const;
       
   313 #endif
       
   314 
       
   315     inline RFs& FileServerSession();
       
   316 
       
   317     inline const TGlxMediaId& CameraAlbumId() const;
       
   318 
       
   319     inline const TGlxMediaId& FavoritesId() const;
       
   320 
       
   321     inline CMdENamespaceDef* NamespaceDef() const;
       
   322 
       
   323     inline CMdEObjectDef& ObjectDef() const;
       
   324 
       
   325     inline CMdEObjectDef& ImageDef() const;
       
   326 
       
   327     inline CMdEObjectDef& VideoDef() const;
       
   328     
       
   329     inline CMdEObjectDef& AlbumDef() const;
       
   330     
       
   331     inline CMdEObjectDef& MediaDef() const;
       
   332     inline CMdEObjectDef& TagDef() const;
       
   333     
       
   334     /**
       
   335      * Return object definition used to describe months.
       
   336      * @return object definition used to describe months.
       
   337      */
       
   338     inline CMdEObjectDef& MonthDef() const;
       
   339     
       
   340     inline CMdERelationDef& ContainsDef() const;
       
   341     
       
   342     inline CMdERelationDef& ContainsLocationDef() const;
       
   343 
       
   344     /**
       
   345      * Get the location definition.
       
   346      * @return location definition.
       
   347      */
       
   348     inline CMdEObjectDef& LocationDef() const;
       
   349     
       
   350     TContainerType ContainerType(CMdEObject* aObject);
       
   351     
       
   352     TContainerType ContainerType(CMdEObjectDef* aObjectDef);
       
   353     
       
   354     TItemType ItemType(CMdEObject* aObject);
       
   355  
       
   356     const TGlxMediaId GetMonthIdL(const TTime& aMonth);
       
   357 
       
   358     TBool SameMonth(const TTime& aOldDate, const TTime& aNewDate);
       
   359      
       
   360 	TBool ContainerIsLeft(CMdEObjectDef& aObjectDef);    
       
   361 	
       
   362 	// from MGlxMDSShutdownObserver
       
   363     void ShutdownNotification(TInt aShutdownState);
       
   364 
       
   365 private:
       
   366 #ifdef USE_S60_TNM
       
   367 	MThumbnailFetchRequestObserver* iTnFetchObserver; 
       
   368     CThumbnailManager* iTnEngine;
       
   369     CFbsBitmap* iTnThumbnail;
       
   370     CFbsBitmap* iThumbnail;
       
   371     TThumbnailRequestId iTnThumbnailCbId;
       
   372     TBool iTnRequestInProgress;
       
   373     TInt iTnHandle;
       
   374     TGlxMediaId iMediaId;
       
   375     
       
   376 #else
       
   377     CGlxtnThumbnailCreator*   iThumbnailCreator;
       
   378     CGlxtnThumbnailDatabase*  iThumbnailDatabase;
       
   379 #endif
       
   380 
       
   381     CMdESession*              iSession;
       
   382     RFs iFs;
       
   383     TBool                     iSessionOpen;
       
   384     TGlxMediaId               iCameraAlbumId;
       
   385     TGlxMediaId               iFavoritesId;
       
   386     
       
   387     CMdENamespaceDef* iNameSpaceDef;
       
   388     CMdEObjectDef* iObjectDef;
       
   389     CMdEObjectDef* iImageDef;
       
   390     CMdEObjectDef* iVideoDef;
       
   391     CMdEObjectDef* iAlbumDef;
       
   392     CMdEObjectDef* iMediaDef;
       
   393     CMdEObjectDef* iTagDef;
       
   394     CMdEObjectDef* iMonthDef;
       
   395     /**
       
   396      * Location object definition.
       
   397      */
       
   398     CMdEObjectDef* iLocationDef;
       
   399     CMdERelationDef* iContainsDef;
       
   400     CMdERelationDef* iContainsLocationDef;
       
   401     
       
   402     RArray<TTime> iMonthArray;
       
   403     RArray<TGlxMediaId> iMonthList;
       
   404     RArray<TItemId> iAddedItems;
       
   405     
       
   406     TTime iFirstMonth;
       
   407     TTime iLastMonth;
       
   408     
       
   409     CAsyncCallBack* iUpdateCallback;
       
   410     
       
   411     CAsyncCallBack* iCreateSessionCallback;
       
   412     
       
   413     struct TUpdateData
       
   414         {
       
   415         TItemId iId;
       
   416         TMPXChangeEventType iType;
       
   417         TBool iIsObject;
       
   418         };
       
   419     
       
   420     RArray<TUpdateData> iUpdateData;
       
   421 	TBool iPauseUpdate;
       
   422     TInt iDeletedCount;
       
   423     
       
   424     RHarvesterClient iHC;
       
   425     TBool iHarvestingOngoing;
       
   426 
       
   427     CGlxMDSShutdownObserver* iMDSShutdownObserver;
       
   428 
       
   429 #ifdef _DEBUG
       
   430     TTime iStartTime;
       
   431     TTime iStopTime;
       
   432 #endif    
       
   433     };
       
   434 
       
   435 #include "glxdatasourcemds.inl"
       
   436 
       
   437 #endif //_C_GLXDATASOURCEMDE_H_