mtpfws/mtpfw/datatypes/interface/cmtptypeserviceproplist.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-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  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #ifndef CMTPTYPESERVICEPROPLIST_H_
       
    23 #define CMTPTYPESERVICEPROPLIST_H_
       
    24 
       
    25 #include <e32std.h>
       
    26 #include <mtp/rmtptype.h>
       
    27 #include <mtp/cmtptypecompoundbase.h>
       
    28 
       
    29 class CMTPTypeServicePropListElement;
       
    30 
       
    31 /** 
       
    32 Defines the MTP ObjectPropList dataset. The ObjectPropList dataset provides
       
    33 optimised access to object properties without needing to individually query 
       
    34 each object/property pair. It also provides a more flexible querying mechanism 
       
    35 for object properties in general. This dataset is used in the 
       
    36 GetObjectPropList, SetObjectPropList, and SendObjectPropList requests.
       
    37 @publishedPartner
       
    38 @released 
       
    39 */ 
       
    40 class CMTPTypeServicePropList : public CMTPTypeCompoundBase
       
    41     {
       
    42 public:
       
    43     
       
    44     IMPORT_C static CMTPTypeServicePropList* NewL();
       
    45     IMPORT_C static CMTPTypeServicePropList* NewLC();
       
    46 
       
    47     IMPORT_C virtual ~CMTPTypeServicePropList();  
       
    48     
       
    49     IMPORT_C void AppendL(CMTPTypeServicePropListElement* aElement);
       
    50     IMPORT_C void AppendDataObjectL(MMTPType& aDataObject);
       
    51     
       
    52     IMPORT_C TUint32 NumberOfElements() const;
       
    53     IMPORT_C CMTPTypeServicePropListElement& Element(TUint aIndex) const; 
       
    54     IMPORT_C MMTPType& DataObjectL() const;
       
    55      
       
    56 public: // From CMTPTypeCompoundBase
       
    57 
       
    58     IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
       
    59     IMPORT_C TInt NextWriteChunk(TPtr8& aChunk);
       
    60     IMPORT_C TUint Type() const;
       
    61     IMPORT_C TBool CommitRequired() const;
       
    62     IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); 
       
    63         
       
    64 private: // From CMTPTypeCompoundBase
       
    65     
       
    66     const TElementInfo& ElementInfo(TInt aElementId) const;
       
    67     TInt ValidateChunkCount() const;
       
    68     
       
    69 private:
       
    70 
       
    71     CMTPTypeServicePropList();
       
    72     void ConstructL();
       
    73     
       
    74     void AppendElementChunkL(CMTPTypeServicePropListElement* aElement);
       
    75     TInt UpdateWriteSequenceErr(TInt aErr);
       
    76 
       
    77 private: // Owned
       
    78 
       
    79     /**
       
    80     The write data stream states.
       
    81     */
       
    82     enum TReadWriteSequenceState
       
    83         {
       
    84         /**
       
    85         Data stream is inactive.
       
    86         */
       
    87         EIdle,
       
    88         
       
    89         /**
       
    90         Elements data stream is in progress.
       
    91         */
       
    92         EElementChunks,
       
    93         
       
    94         /**
       
    95         Optional object data stream is in progress.
       
    96         */
       
    97         EDataObjectChunk            
       
    98         };
       
    99 
       
   100     /**
       
   101     The write data stream error state. 
       
   102     */
       
   103     TUint                                           iWriteSequenceErr;
       
   104 
       
   105     /**
       
   106     The write data stream state variable. 
       
   107     */
       
   108     TUint                                           iWriteSequenceState;
       
   109     
       
   110     /**
       
   111     The NumberOfElements element metadata content.
       
   112     */
       
   113     CMTPTypeCompoundBase::TElementInfo              iInfoNumberOfElements;
       
   114     
       
   115     /**
       
   116     The Element array metadata content. Note that this is declared mutable 
       
   117     to allow state updates while processing a read data stream.
       
   118     */
       
   119     mutable CMTPTypeCompoundBase::TElementInfo      iInfoElement;
       
   120     
       
   121     /**
       
   122     The NumberOfElements element data chunk ID.
       
   123     */
       
   124     static const TUint                              KNumberOfElementsChunk;
       
   125     
       
   126     /**
       
   127     The Element array starting data chuck ID.
       
   128     */
       
   129     static const TUint                              KElementChunks;
       
   130     
       
   131     /**
       
   132     The NumberOfElements element data chunk.
       
   133     */
       
   134     TMTPTypeUint32                                  iChunkNumberOfElements;
       
   135     
       
   136     /**
       
   137     The Element array data chunks.
       
   138     */
       
   139     RPointerArray<CMTPTypeServicePropListElement>    iChunksElement;
       
   140     
       
   141 private: // Not owned
       
   142     
       
   143     /**
       
   144     The (optional) MTP data object chunk.
       
   145     */
       
   146     MMTPType*                                       iChunkDataObject;
       
   147     };
       
   148 
       
   149 /**
       
   150 Defines the MTP ObjectPropList element dataset. The ObjectPropList element 
       
   151 dataset describes an object property with a meta data triplet and a value. It
       
   152 is a  component element of the ObjectPropList dataset.
       
   153 */
       
   154 class CMTPTypeServicePropListElement : public CMTPTypeCompoundBase
       
   155     {
       
   156 
       
   157 public:
       
   158 
       
   159     /**
       
   160     MTP ObjectPropList property quadruple dataset element identifiers.
       
   161     */
       
   162     enum TMTPObjectPropListElement
       
   163         {
       
   164         /**
       
   165         The ObjectHandle of the object to which the property applies.
       
   166         */
       
   167         EObjectHandle,
       
   168         
       
   169         /**
       
   170         The ObjectPropDesc property identifier datacode (read-only).
       
   171         */
       
   172         EPropertyCode,
       
   173         
       
   174         /**
       
   175         The datatype code of the property (read-only).
       
   176         */
       
   177         EDatatype,
       
   178         
       
   179         /**
       
   180         The value of the property.
       
   181         */
       
   182         EValue,
       
   183 
       
   184         /**
       
   185         The number of dataset elements.
       
   186         */
       
   187         ENumElements,
       
   188         };
       
   189 
       
   190 public:
       
   191     
       
   192     IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint16 aPropertyCode);
       
   193     IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint16 aPropertyCode);
       
   194     
       
   195     IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint32 aObjectHandle, TUint16 aPropertyCode, const MMTPType& aValue);
       
   196     IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint32 aObjectHandle, TUint16 aPropertyCode, const MMTPType& aValue);
       
   197 
       
   198     IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint16 aPropertyCode, TUint16 aDataType);
       
   199     IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint16 aPropertyCode, TUint16 aDataType);
       
   200     
       
   201     IMPORT_C static CMTPTypeServicePropListElement* NewL(TUint32 aObjectHandle, TUint16 aPropertyCode, TUint16 aDataType, const MMTPType& aValue);
       
   202     IMPORT_C static CMTPTypeServicePropListElement* NewLC(TUint32 aObjectHandle, TUint16 aPropertyCode, TUint16 aDataType, const MMTPType& aValue);
       
   203     
       
   204     IMPORT_C virtual ~CMTPTypeServicePropListElement(); 
       
   205      
       
   206 public: // From CMTPTypeCompoundBase
       
   207 
       
   208     IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk);
       
   209     IMPORT_C TUint Type() const;
       
   210     IMPORT_C TBool CommitRequired() const;
       
   211     IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); 
       
   212         
       
   213 private: // From CMTPTypeCompoundBase
       
   214     
       
   215     const TElementInfo& ElementInfo(TInt aElementId) const;
       
   216     TBool WriteableElementL(TInt aElementId) const;
       
   217     
       
   218 private:
       
   219 
       
   220     friend MMTPType* CMTPTypeServicePropList::CommitChunkL(TPtr8& aChunk);
       
   221     static CMTPTypeServicePropListElement* NewLC();
       
   222 
       
   223     CMTPTypeServicePropListElement();
       
   224     void ConstructL();
       
   225     void ConstructL(TUint16 aPropertyCode, TUint16 aDataType, const TUint32* aObjectHandle, const MMTPType* aValue);
       
   226 
       
   227     void DestroyChunks();
       
   228 
       
   229 private: // Owned
       
   230 
       
   231     /**
       
   232     The write data stream states.
       
   233     */
       
   234     enum TWriteSequenceState
       
   235         {
       
   236         /**
       
   237         Data stream is inactive.
       
   238         */
       
   239         EIdle,
       
   240         
       
   241         /**
       
   242         Streaming the property descriptor triplet dataset data chunk.
       
   243         */
       
   244         EFlatChunk,
       
   245         
       
   246         /**
       
   247         Streaming the property value data chunk.
       
   248         */
       
   249         EValueChunk 
       
   250         };
       
   251         
       
   252     /**
       
   253     Data chunk identifiers.
       
   254     */
       
   255     enum TChunkIds
       
   256         {
       
   257         /**
       
   258         The flat data chunk ID.
       
   259         */
       
   260         EIdFlatChunk,
       
   261         
       
   262         /**
       
   263         The EValue element data chunk ID.
       
   264         */
       
   265         EIdValueChunk,
       
   266         
       
   267         /**
       
   268         The number of data chunks.
       
   269         */
       
   270         EIdNumChunks
       
   271         };
       
   272 
       
   273     /**
       
   274     The write data stream state variable. 
       
   275     */
       
   276     TUint                                           iWriteSequenceState;
       
   277     
       
   278     /**
       
   279     The dataset element metadata table content.
       
   280     */
       
   281     static const TElementInfo                       iElementMetaData[];
       
   282     
       
   283     /**
       
   284     The dataset element metadata table.
       
   285     */
       
   286     const TFixedArray<TElementInfo, ENumElements>   iElementInfo;
       
   287 
       
   288     /**
       
   289     The initialised flag indicating if construction is complete and that 
       
   290     read-only elements can no longer be modified.
       
   291     */
       
   292     TBool                                           iInitialised;
       
   293     
       
   294     /**
       
   295     The property meta data triplet flat data chunk size in bytes.
       
   296     */
       
   297     static const TUint                              KFlatChunkSize;
       
   298     
       
   299     /**
       
   300     The property meta data flat data chunk, comprising elements EObjectHandle 
       
   301     to EDatatype.
       
   302     */
       
   303     RMTPTypeCompoundFlatChunk                       iChunkFlat;
       
   304     
       
   305     /**
       
   306     The EValue data chunk.
       
   307     */
       
   308     RMTPType                                        iChunkValue;
       
   309     };
       
   310 
       
   311 #endif // CMTPTYPESERVICEPROPLIST_H_