mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h
changeset 0 d0791faffa3f
child 2 4843bb5893b6
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef CMTPIMAGEDPOBJECTPROPERTYMGR_H
       
    23 #define CMTPIMAGEDPOBJECTPROPERTYMGR_H
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <f32file.h>
       
    27 #include <e32std.h>
       
    28 
       
    29 #include <mdesession.h>
       
    30 #include <mtp/mtpprotocolconstants.h>
       
    31 #include <mtp/mtpprotocolconstants.h>
       
    32 #include <mtp/tmtptypeuint32.h>
       
    33 
       
    34 #include "mtpimagedpconst.h"
       
    35 
       
    36 class MMTPObjectMgr;
       
    37 class MMTPPuidMgr;
       
    38 class TMTPTypeUint128;
       
    39 class CMTPTypeString;
       
    40 class MMTPDataProviderFramework;
       
    41 class CFileStore;
       
    42 class CMTPTypeString;
       
    43 class CMTPObjectMetaData;
       
    44 
       
    45 /** 
       
    46 Manage picture object properties
       
    47 
       
    48 @internalTechnology
       
    49 @released
       
    50 */
       
    51 class CMTPImageDpObjectPropertyMgr : public CBase, public MMdESessionObserver
       
    52    {    
       
    53    
       
    54 public:
       
    55     static CMTPImageDpObjectPropertyMgr* NewL(MMTPDataProviderFramework& aFramework);
       
    56     ~CMTPImageDpObjectPropertyMgr();
       
    57     void SetCurrentObjectL(CMTPObjectMetaData& aObjectInfo, TBool aRequireForModify, TBool aSaveToCache = EFalse);
       
    58     
       
    59     void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint8 aValue);
       
    60     void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint16 aValue);
       
    61     void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint32 aValue);
       
    62     void SetPropertyL(TMTPObjectPropertyCode aProperty, const TUint64 aValue);
       
    63     void SetPropertyL(TMTPObjectPropertyCode aProperty, const TDesC& aValue);
       
    64     
       
    65     void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint8& aValue);
       
    66     void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint16& aValue);
       
    67     void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32& aValue);
       
    68     void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint64& aValue);
       
    69     void GetPropertyL(TMTPObjectPropertyCode aProperty, TMTPTypeUint128& aValue);
       
    70     void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeString& aValue);    
       
    71     
       
    72     //clear the cache
       
    73     void ClearCacheL();
       
    74     void ConvertMTPTimeStr2TTimeL(const TDesC& aTimeString, TTime& aModifiedTime) const;
       
    75     
       
    76 public:
       
    77     void SetMdeSessionError(TInt aError);
       
    78     CMdESession& MdeSession();
       
    79     
       
    80     // from MMdESessionObserver
       
    81     void HandleSessionOpened(CMdESession& aSession, TInt aError);
       
    82     void HandleSessionError(CMdESession& aSession, TInt aError);
       
    83    
       
    84 private:
       
    85     CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework);
       
    86     void ConstructL(MMTPDataProviderFramework& aFramework);
       
    87     
       
    88     TBool GetYear(const TDesC& aDateString, TInt& aYear) const;
       
    89     TBool GetMonth(const TDesC& aDateString, TMonth& aMonth) const;
       
    90     TBool GetDay(const TDesC& aDateString, TInt& aDay) const;
       
    91     TBool GetHour(const TDesC& aDateString, TInt& aHour) const;
       
    92     TBool GetMinute(const TDesC& aDateString, TInt& aMinute) const;
       
    93     TBool GetSecond(const TDesC& aDateString, TInt& aSecond) const;
       
    94     TBool GetTenthSecond(const TDesC& aDateString, TInt& aTenthSecond) const;     
       
    95     
       
    96     void SetProperty2CacheL(TMTPObjectPropertyCode aProperty, TAny* aValue);
       
    97     void GetPropertyFromMdsL(TMTPObjectPropertyCode aProperty, TAny* aValue);
       
    98 
       
    99     TUint32 ParseImageFileL(const TDesC& aUri, TMTPObjectPropertyCode aPropCode);
       
   100     void RemoveProperty(CMdEObject& aObject, CMdEPropertyDef& aPropDef);
       
   101     
       
   102 private:
       
   103     
       
   104     //define property cache object
       
   105     class CMTPImagePropertiesCache : public CBase
       
   106     {
       
   107     public:
       
   108         /**
       
   109         MTP image cache properites identifiers.
       
   110         */      
       
   111         enum TElementId
       
   112             {        
       
   113             EImagePixWidth        = 0,
       
   114             EImagePixHeight       = 1,
       
   115             EImageBitDepth        = 2,
       
   116             EDateCreated          = 3,
       
   117             
       
   118             /**
       
   119             The number of elements.        
       
   120             */
       
   121             ENumProperties,
       
   122             };
       
   123         
       
   124     public:
       
   125         static CMTPImagePropertiesCache* NewL();
       
   126         virtual ~CMTPImagePropertiesCache();
       
   127         
       
   128         void ResetL();
       
   129         
       
   130         const TDesC& DesC(TUint aId) const;
       
   131         TUint Uint(TUint aId) const;
       
   132         TUint ObjectHandle() const;
       
   133         
       
   134         void SetDesCL(TUint aId, const TDesC& aValue);
       
   135         void SetUint(TUint aId, TUint aValue);  
       
   136         void SetObjectHandle(TUint aObjectHandle);
       
   137         
       
   138     private:
       
   139         
       
   140         enum TType
       
   141             {
       
   142             EUint       = 0,
       
   143             EDesC       = 1,
       
   144             };
       
   145         
       
   146         struct TElementMetaData
       
   147             {
       
   148             TUint   iOffset;
       
   149             TType   iType;
       
   150             };                
       
   151         
       
   152     private:        
       
   153         CMTPImagePropertiesCache(const TElementMetaData* aElements, TUint aCount);
       
   154         void ConstructL();
       
   155         
       
   156     private:
       
   157         /**
       
   158         The element meta-data.
       
   159         */        
       
   160         const RArray<TElementMetaData>  iElements;
       
   161         
       
   162         /**
       
   163         The DesC element data.
       
   164         */
       
   165         RPointerArray<HBufC>            iElementsDesC;
       
   166         
       
   167         /**
       
   168         The Uint element data.
       
   169         */
       
   170         RArray<TUint>                   iElementsUint;
       
   171         
       
   172         /**
       
   173         The object handle of owner
       
   174         */
       
   175         TUint                           iObjectHandle;
       
   176         
       
   177         static const TElementMetaData   KElements[];        
       
   178     };
       
   179     
       
   180 private:
       
   181     /**
       
   182     FLOGGER debug trace member variable.
       
   183     */    
       
   184     __FLOG_DECLARATION_MEMBER_MUTABLE;
       
   185     
       
   186     CActiveSchedulerWait*       iActiveSchedulerWait;
       
   187     CMdESession*                iMetaDataSession;
       
   188     TInt                        iMdeSessionError;
       
   189     CMdEObject*                 iObject;
       
   190 
       
   191     RFs&                        iFs;
       
   192     MMTPObjectMgr&              iObjectMgr;
       
   193     CMTPObjectMetaData*         iObjectInfo;  //not owned
       
   194     TBool                       iCacheHit;//flag to indicate cache is available
       
   195     
       
   196     /**
       
   197      * Cache the latest image properties which PC send to device,
       
   198      * it can optimize synce/reverse-sync performance due to reduction of object properties generation
       
   199      */
       
   200     CMTPImagePropertiesCache*     iPropertiesCache; 
       
   201     };
       
   202    
       
   203 #endif // CMTPIMAGEDPOBJECTPROPERTYMGR_H