engine/collectionframework/datasource/plugins/glxdatasourcemde2.5/inc/glxdatasourcemds.h
changeset 23 74c9f037fd5d
child 24 99ad1390cd33
equal deleted inserted replaced
5:f7f0874bfe7d 23:74c9f037fd5d
       
     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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  * @author Simon Brooks, Alex Birkett
       
    22  */
       
    23 
       
    24 /**
       
    25  * @internal reviewed 10/07/2007 by M Byrne
       
    26  */
       
    27 
       
    28 #ifndef _C_GLXDATASOURCEMDS_H_
       
    29 #define _C_GLXDATASOURCEMDS_H_
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32cmn.h>
       
    33 #include <f32file.h>
       
    34 
       
    35 #include <mdesession.h>
       
    36 #include <mglxtnstorage.h>
       
    37 #include <mpxcollectionmessagedefs.h>
       
    38 
       
    39 #ifdef USE_S60_TNM
       
    40 #include <thumbnailmanager.h>
       
    41 #include <thumbnailmanagerobserver.h>
       
    42 #include <thumbnaildata.h>
       
    43 #include <thumbnailobjectsource.h>
       
    44 
       
    45 #include "mthumbnailfetchrequestobserver.h"
       
    46 #endif
       
    47 
       
    48 #include "glxdatasource.h"
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 class CGlxRequest;
       
    52 
       
    53 #ifndef USE_S60_TNM
       
    54 class CGlxtnThumbnailCreator;
       
    55 class CGlxtnThumbnailDatabase;
       
    56 #endif
       
    57 
       
    58 // CONSTANTS
       
    59 
       
    60 // CLASS DECLARATION
       
    61 
       
    62 /**
       
    63  *  CGlxDataSourceMde class 
       
    64  *
       
    65  *  Data Source Mde is a Meta Data Data Source.
       
    66  *  @lib GlxDataSourceMde.lib
       
    67  *  @ingroup collection_component_design
       
    68  */
       
    69 class CGlxDataSourceMde : public CGlxDataSource,
       
    70                           public MMdESessionObserver,
       
    71                           public MMdEObjectObserver,
       
    72                           public MMdEObjectPresentObserver,
       
    73                           public MMdERelationObserver,
       
    74                           public MMdERelationPresentObserver
       
    75 #ifdef USE_S60_TNM
       
    76 						, public MThumbnailManagerObserver
       
    77 #else
       
    78                         , public MGlxtnThumbnailStorageObserver
       
    79 #endif
       
    80     {
       
    81 public:
       
    82     static CGlxDataSourceMde* NewL();
       
    83 
       
    84 private:
       
    85     ~CGlxDataSourceMde();
       
    86     
       
    87     CGlxDataSourceMde();
       
    88     
       
    89     void ConstructL();
       
    90 
       
    91 public:
       
    92     // from CGlxDataSource
       
    93     CGlxDataSourceTask* CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver);
       
    94 
       
    95 #ifdef USE_S60_TNM
       
    96 public:
       
    97 	void FetchThumbnailL(CGlxRequest* aRequest, MThumbnailFetchRequestObserver& aObserver);
       
    98 	TInt CancelFetchThumbnail();
       
    99 #else
       
   100 private: 
       
   101     // from MGlxtnThumbnailStorageObserver
       
   102     /**
       
   103     * Notify that a given thumbnail is available in storage.
       
   104     * @param aId Media item ID.
       
   105     * @param aSize Requested thumbnail size.
       
   106     */
       
   107     void ThumbnailAvailable(const TGlxMediaId& aId, const TSize& aSize);
       
   108     /**
       
   109     * Notify that a given thumbnail is available in storage.
       
   110     * @param aId Media item ID.
       
   111     * @param aSize Thumbnail size.
       
   112     */
       
   113     void BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError);
       
   114 #endif
       
   115 
       
   116 private: 
       
   117     /**
       
   118     *  from MMdESessionObserver
       
   119     */
       
   120     void HandleSessionOpened(CMdESession& aSession, TInt aError);
       
   121     
       
   122     void HandleSessionError(CMdESession& aSession, TInt aError);
       
   123 
       
   124 private: // MMdEObjectObserver
       
   125 	/**
       
   126 	 * See @ref MMdEObjectObserver::HandleObjectNotification
       
   127 	 */
       
   128 	void HandleObjectNotification(CMdESession& aSession, 
       
   129 						TObserverNotificationType aType,
       
   130 						const RArray<TItemId>& aObjectIdArray);
       
   131 
       
   132 private: // MMdEObjectPresentObserver
       
   133 	/**
       
   134 	 * See @ref MMdEObjectPresentObserver::HandleObjectPresentNotification
       
   135 	 */
       
   136 	void HandleObjectPresentNotification(CMdESession& aSession, 
       
   137 			TBool aPresent, const RArray<TItemId>& aObjectIdArray);
       
   138 
       
   139 private: // MMdERelationObserver
       
   140 	/**
       
   141 	 * See @ref MMdERelationObserver::HandleRelationNotification
       
   142 	 */
       
   143 	void HandleRelationNotification(CMdESession& aSession, 
       
   144 			TObserverNotificationType aType,
       
   145 			const RArray<TItemId>& aRelationIdArray);
       
   146 	    
       
   147 private: //MMdERelationPresentObserver
       
   148 	/**
       
   149 	 * See @ref MMdERelationPresentObserver::HandleRelationPresentNotification
       
   150 	 */
       
   151 	void HandleRelationPresentNotification(CMdESession& aSession,
       
   152 			TBool aPresent, const RArray<TItemId>& aRelationIdArray);
       
   153 
       
   154 #ifdef USE_S60_TNM
       
   155     // from MThumbnailManagerObserver
       
   156     void ThumbnailPreviewReady( MThumbnailData& aThumbnail,
       
   157         TThumbnailRequestId aId );
       
   158     
       
   159     void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail,
       
   160         TThumbnailRequestId aId );
       
   161 #endif
       
   162 		
       
   163 private:
       
   164     void BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError);
       
   165 
       
   166     void DoSessionInitL();
       
   167 
       
   168     void AddMdEObserversL();
       
   169 
       
   170     void ProcessUpdateArray(const RArray<TItemId>& aArray, TMPXChangeEventType aType, TBool aIsObject);
       
   171 
       
   172     void ProcessItemUpdateL();
       
   173 
       
   174     static TInt ProcessItemUpdate(TAny* aPtr);
       
   175     void CreateSessionL();
       
   176 
       
   177     static TInt CreateSession(TAny* aPtr);
       
   178 
       
   179     void PrepareMonthsL();
       
   180     void TaskCompletedL();
       
   181 
       
   182     void TaskStartedL();
       
   183 
       
   184 public:
       
   185     inline CMdESession& Session() const;
       
   186     
       
   187 #ifndef USE_S60_TNM
       
   188     inline CGlxtnThumbnailCreator& ThumbnailCreator() const;
       
   189 
       
   190     inline CGlxtnThumbnailDatabase& ThumbnailDatabase() const;
       
   191 #endif
       
   192 
       
   193     inline RFs& FileServerSession();
       
   194 
       
   195     inline const TGlxMediaId& CameraAlbumId() const;
       
   196 
       
   197     inline const TGlxMediaId& FavoritesId() const;
       
   198 
       
   199     inline CMdENamespaceDef* NamespaceDef() const;
       
   200 
       
   201     inline CMdEObjectDef& ObjectDef() const;
       
   202 
       
   203     inline CMdEObjectDef& ImageDef() const;
       
   204 
       
   205     inline CMdEObjectDef& VideoDef() const;
       
   206     
       
   207     inline CMdEObjectDef& AlbumDef() const;
       
   208     
       
   209     inline CMdEObjectDef& MediaDef() const;
       
   210     inline CMdEObjectDef& TagDef() const;
       
   211     
       
   212     /**
       
   213      * Return object definition used to describe months.
       
   214      * @return object definition used to describe months.
       
   215      */
       
   216     inline CMdEObjectDef& MonthDef() const;
       
   217     
       
   218     inline CMdERelationDef& ContainsDef() const;
       
   219     
       
   220     inline CMdERelationDef& ContainsLocationDef() const;
       
   221 
       
   222     /**
       
   223      * Get the location definition.
       
   224      * @return location definition.
       
   225      */
       
   226     inline CMdEObjectDef& LocationDef() const;
       
   227     
       
   228     TContainerType ContainerType(CMdEObject* aObject);
       
   229     
       
   230     TContainerType ContainerType(CMdEObjectDef* aObjectDef);
       
   231     
       
   232     TItemType ItemType(CMdEObject* aObject);
       
   233  
       
   234     const TGlxMediaId GetMonthIdL(const TTime& aMonth);
       
   235 
       
   236     TBool SameMonth(const TTime& aOldDate, const TTime& aNewDate);
       
   237      
       
   238 	TBool ContainerIsLeft(CMdEObjectDef& aObjectDef);    
       
   239 
       
   240 private:
       
   241 #ifdef USE_S60_TNM
       
   242 	MThumbnailFetchRequestObserver* iTnFetchObserver; 
       
   243     CThumbnailManager* iTnEngine;
       
   244     CFbsBitmap* iTnThumbnail;
       
   245     CFbsBitmap* iThumbnail;
       
   246     TThumbnailRequestId iTnThumbnailCbId;
       
   247     TBool iTnRequestInProgress;
       
   248     TInt iTnHandle;
       
   249     TGlxMediaId iMediaId;
       
   250     
       
   251 	TTime iStartTime;
       
   252 	TTime iStopTime;
       
   253 #else
       
   254     CGlxtnThumbnailCreator*   iThumbnailCreator;
       
   255     CGlxtnThumbnailDatabase*  iThumbnailDatabase;
       
   256 #endif
       
   257 
       
   258     CMdESession*              iSession;
       
   259     RFs iFs;
       
   260     TBool                     iSessionOpen;
       
   261     TGlxMediaId               iCameraAlbumId;
       
   262     TGlxMediaId               iFavoritesId;
       
   263     
       
   264     CMdENamespaceDef* iNameSpaceDef;
       
   265     CMdEObjectDef* iObjectDef;
       
   266     CMdEObjectDef* iImageDef;
       
   267     CMdEObjectDef* iVideoDef;
       
   268     CMdEObjectDef* iAlbumDef;
       
   269     CMdEObjectDef* iMediaDef;
       
   270     CMdEObjectDef* iTagDef;
       
   271     CMdEObjectDef* iMonthDef;
       
   272     /**
       
   273      * Location object definition.
       
   274      */
       
   275     CMdEObjectDef* iLocationDef;
       
   276     CMdERelationDef* iContainsDef;
       
   277     CMdERelationDef* iContainsLocationDef;
       
   278     
       
   279     RArray<TTime> iMonthArray;
       
   280     RArray<TGlxMediaId> iMonthList;
       
   281     TTime iFirstMonth;
       
   282     TTime iLastMonth;
       
   283     
       
   284     CAsyncCallBack* iUpdateCallback;
       
   285     
       
   286     CAsyncCallBack* iCreateSessionCallback;
       
   287     
       
   288     struct TUpdateData
       
   289         {
       
   290         TItemId iId;
       
   291         TMPXChangeEventType iType;
       
   292         TBool iIsObject;
       
   293         };
       
   294     
       
   295     RArray<TUpdateData> iUpdateData;
       
   296 	TBool iPauseUpdate;
       
   297     TInt iDeletedCount;
       
   298     };
       
   299 
       
   300 #include "glxdatasourcemds.inl"
       
   301 
       
   302 #endif //_C_GLXDATASOURCEMDE_H_