epoc32/include/SmlDataFormat.h
branchSymbian3
changeset 4 837f303aceeb
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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: For adding content to be synchronized.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __SMLDATAFORMAT_H__
       
    20 #define __SMLDATAFORMAT_H__
       
    21 //
       
    22 #include <e32base.h>
       
    23 #include <s32strm.h>
       
    24 #include <barsread.h>
       
    25 #include <stringpool.h>
       
    26 #include <SyncMLDef.h>
       
    27 //
       
    28 
       
    29 /**
       
    30 @publishedPartner
       
    31 
       
    32 Data Store Format.
       
    33 Used by Data Provider implementations to specify the format and capabilities of their Data Stores.
       
    34 See also SmlDataFormat.rh and SmlDataFormat.hrh for resource definitions.
       
    35 
       
    36 Used by the Sync Engine to generate SyncML DevInf.
       
    37 */
       
    38 
       
    39 
       
    40 
       
    41 /**
       
    42 A bitmask of sync types. Used to specify sync types supported by a Data Store.
       
    43 */
       
    44 class TSmlSyncTypeMask
       
    45 	{
       
    46 public:
       
    47 	inline TSmlSyncTypeMask()                           : iMask(0U) {}
       
    48 	inline void SetSupported(TSmlSyncType aType)        { iMask |= TypeMask(aType); }
       
    49 	inline void SetNotSupported(TSmlSyncType aType)     { iMask &= ~TypeMask(aType); }
       
    50 	inline TBool IsSupported(TSmlSyncType aType) const  { return iMask & TypeMask(aType); }
       
    51 private:
       
    52 	inline TUint16 TypeMask(TSmlSyncType aType) const   { return TUint16(1 << TInt(aType)); }
       
    53 private:
       
    54 	TUint16 iMask;
       
    55 	};
       
    56 
       
    57 
       
    58 /**
       
    59 Holds data defining a property value or property parameter value.
       
    60 This includes Name, display name, and data type - including any enumerations.
       
    61 */
       
    62 class CSmlDataField : public CBase
       
    63 	{
       
    64 public:
       
    65 	IMPORT_C static CSmlDataField* NewLC();
       
    66 	IMPORT_C static CSmlDataField* NewLC(const RStringPool& aStringPool, TResourceReader& aReader);
       
    67 	IMPORT_C static CSmlDataField* NewLC(const RStringPool& aStringPool, RReadStream& aStream);
       
    68 	IMPORT_C virtual ~CSmlDataField();
       
    69 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
    70 
       
    71 	IMPORT_C RString Name() const;
       
    72 	// Method takes ownership of parameter and closes it 
       
    73 	IMPORT_C void SetNameL(RString& aName);
       
    74 	IMPORT_C const TDesC& DisplayName() const;
       
    75 	// Method takes ownership of parameter and closes it 
       
    76 	IMPORT_C void SetDisplayNameL(TDesC& aDisplayName);
       
    77 	IMPORT_C RString DataType() const;
       
    78 	// Method takes ownership of parameter and closes it 
       
    79 	IMPORT_C void SetDataTypeL(RString& aDataType);
       
    80 	IMPORT_C TInt EnumValueCount() const;
       
    81 	IMPORT_C RString EnumValue(TInt aIndex) const;
       
    82 	// Method takes ownership of parameter and closes it 
       
    83 	IMPORT_C void SetEnumValuesL(RArray<RString>& aEnumValues);
       
    84 	
       
    85 protected:
       
    86 	HBufC* iDisplayName;
       
    87 	RString iName;
       
    88 	RString iDataType;
       
    89 	RArray<RString> iEnumValues;
       
    90 	};
       
    91 
       
    92 
       
    93 /**
       
    94 Property Parameter.
       
    95 Sub-type of property.
       
    96 */
       
    97 class CSmlDataPropertyParam : public CBase
       
    98 	{
       
    99 public:
       
   100 	IMPORT_C static CSmlDataPropertyParam* NewLC();
       
   101 	IMPORT_C static CSmlDataPropertyParam* NewLC(const RStringPool& aStringPool, TResourceReader& aReader);
       
   102 	IMPORT_C static CSmlDataPropertyParam* NewLC(const RStringPool& aStringPool, RReadStream& aStream);
       
   103 	IMPORT_C virtual ~CSmlDataPropertyParam();
       
   104 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   105 
       
   106 	IMPORT_C const CSmlDataField& Field() const;
       
   107 	// Method takes ownership of data field
       
   108 	IMPORT_C void SetDataFieldL(CSmlDataField& aDataField);
       
   109 
       
   110 protected:
       
   111 	CSmlDataField* iField;
       
   112 	};
       
   113 
       
   114 
       
   115 /**
       
   116 Property.
       
   117 A field in the Data Store.
       
   118 */
       
   119 class CSmlDataProperty : public CBase
       
   120 	{
       
   121 public:
       
   122 	enum TOption
       
   123 		{
       
   124 		EOptionHasMaxSize,
       
   125 		EOptionHasMaxOccur,
       
   126 		EOptionNoTruncate
       
   127 		};
       
   128 public:
       
   129 	IMPORT_C static CSmlDataProperty* NewLC();
       
   130 	IMPORT_C static CSmlDataProperty* NewLC(const RStringPool& aStringPool, TResourceReader& aReader);
       
   131 	IMPORT_C static CSmlDataProperty* NewLC(const RStringPool& aStringPool, RReadStream& aStream);
       
   132 	IMPORT_C virtual ~CSmlDataProperty();
       
   133 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   134 
       
   135 	IMPORT_C const CSmlDataField& Field() const;
       
   136 	// Method takes ownership of data field
       
   137 	IMPORT_C void SetDataFieldL(CSmlDataField& aDataField);
       
   138 
       
   139 	IMPORT_C TInt ParamCount() const;
       
   140 	IMPORT_C const CSmlDataPropertyParam& Param(TInt aIndex) const;
       
   141 	// Method takes ownership of params
       
   142 	IMPORT_C void SetPropertyParamsL(RPointerArray<CSmlDataPropertyParam>& aParams);
       
   143 
       
   144 	IMPORT_C TBool IsSupported(TOption aOption) const;
       
   145 	IMPORT_C void SetSupportedOptions(TUint32 aFlags);
       
   146 
       
   147 	IMPORT_C TBool HasMaxSize() const;
       
   148 	IMPORT_C TBool HasMaxOccur() const;
       
   149 	IMPORT_C TInt MaxSize() const;
       
   150 	IMPORT_C TInt MaxOccur() const;
       
   151 	IMPORT_C void SetMaxSize(TUint16 aMaxSize);
       
   152 	IMPORT_C void SetMaxOccur(TUint16 aMaxOccur);
       
   153 
       
   154 protected:
       
   155 	CSmlDataField* iField;
       
   156 	RPointerArray<CSmlDataPropertyParam> iParams;
       
   157 	TUint16 iMaxSize;
       
   158 	TUint16 iMaxOccur;
       
   159 	TUint32 iFlags;
       
   160 	};
       
   161 
       
   162 
       
   163 /**
       
   164 Filter Capability
       
   165 */
       
   166 class CSmlFilterCapability : public CBase
       
   167 	{
       
   168 public:
       
   169 	IMPORT_C static CSmlFilterCapability* NewLC();
       
   170 	IMPORT_C static CSmlFilterCapability* NewLC(const RStringPool& aStringPool, TResourceReader& aReader);
       
   171 	IMPORT_C static CSmlFilterCapability* NewLC(const RStringPool& aStringPool, RReadStream& aStream);
       
   172 	IMPORT_C virtual ~CSmlFilterCapability();
       
   173 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   174 
       
   175 	IMPORT_C RStringF MimeType() const;
       
   176 	// Method takes ownership of parameter and closes it 
       
   177 	IMPORT_C void SetMimeTypeL(RStringF& aMimeType);
       
   178 	IMPORT_C RStringF MimeVersion() const;
       
   179 	// Method takes ownership of parameter and closes it
       
   180 	IMPORT_C void SetMimeVersionL(RStringF& aMimeVersion);
       
   181 
       
   182 	IMPORT_C TInt KeywordCount() const;
       
   183 	IMPORT_C RString Keyword(TInt aIndex) const;
       
   184 	// Method takes ownership of keywords
       
   185 	IMPORT_C void SetKeyWordListL(RArray<RString>& aKeywordList);
       
   186 
       
   187 	IMPORT_C TInt PropertyCount() const;
       
   188 	IMPORT_C RString PropertyName(TInt aIndex) const;
       
   189 	// Method takes ownership of properties and closes them
       
   190 	IMPORT_C void SetPropertiesListL(RArray<RString>& aPropertyList);
       
   191 	
       
   192 protected:
       
   193 	RStringF iMimeType;
       
   194 	RStringF iMimeVersion;
       
   195 	RArray<RString> iKeywordList;
       
   196 	RArray<RString> iPropertyList;
       
   197 	};
       
   198 
       
   199 
       
   200 
       
   201 /**
       
   202 The format of a specific mime type.
       
   203 */
       
   204 class CSmlMimeFormat : public CBase
       
   205 	{
       
   206 public:
       
   207 	IMPORT_C static CSmlMimeFormat* NewLC();
       
   208 	IMPORT_C static CSmlMimeFormat* NewLC(const RStringPool& aStringPool, TResourceReader& aReader);
       
   209 	IMPORT_C static CSmlMimeFormat* NewLC(const RStringPool& aStringPool, RReadStream& aStream);
       
   210 	IMPORT_C virtual ~CSmlMimeFormat();
       
   211 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   212 
       
   213 	IMPORT_C RStringF MimeType() const;
       
   214 	// Method takes ownership of parameter and closes it
       
   215 	IMPORT_C void SetMimeTypeL(RStringF& aMimeType);
       
   216 	IMPORT_C RStringF MimeVersion() const;
       
   217 	// Method takes ownership of parameter and closes it
       
   218 	IMPORT_C void SetMimeVersionL(RStringF& aMimeVersion);
       
   219 
       
   220 	IMPORT_C TInt PropertyCount() const;
       
   221 	IMPORT_C const CSmlDataProperty& Property(TInt aIndex) const;
       
   222 	// Method takes ownership of properties
       
   223 	IMPORT_C void SetDataPropertiesL(RPointerArray<CSmlDataProperty>& aProperties);
       
   224 
       
   225 	IMPORT_C TBool FieldLevel() const;
       
   226 	IMPORT_C void SetFieldLevel(TBool aFieldLevel);
       
   227 
       
   228 protected:
       
   229 	RStringF iMimeType;
       
   230 	RStringF iMimeVersion;
       
   231 	RPointerArray<CSmlDataProperty> iProperties;
       
   232 	TBool iFieldLevel;
       
   233 	};
       
   234 
       
   235 
       
   236 
       
   237 /**
       
   238 The format and capabilities of Data Stores of a specific type.
       
   239 */
       
   240 class CSmlDataStoreFormat : public CBase
       
   241 	{
       
   242 public:
       
   243 	enum TOption
       
   244 		{
       
   245 		EOptionHasMaxSize,
       
   246 		EOptionHasMaxItems,
       
   247 		EOptionHierarchial
       
   248 		};
       
   249 public:
       
   250 	IMPORT_C static CSmlDataStoreFormat* NewLC();
       
   251 	IMPORT_C static CSmlDataStoreFormat* NewLC(const RStringPool& aStringPool, TResourceReader& aReader);
       
   252 	IMPORT_C static CSmlDataStoreFormat* NewLC(const RStringPool& aStringPool, RReadStream& aStream);
       
   253 	IMPORT_C virtual ~CSmlDataStoreFormat();
       
   254 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   255 
       
   256 	IMPORT_C const TDesC& DisplayName() const;
       
   257 	IMPORT_C void SetDisplayNameL(TDesC& aDisplayName);
       
   258 
       
   259 	IMPORT_C TSmlSyncTypeMask SyncTypes() const;
       
   260 	IMPORT_C void SetSyncTypeMask(TSmlSyncTypeMask aSyncTypeMask);
       
   261 
       
   262 	IMPORT_C TInt MimeFormatCount() const;
       
   263 	IMPORT_C const CSmlMimeFormat& MimeFormat(TInt aIndex) const;
       
   264 	// Method takes ownership of mime formats
       
   265 	IMPORT_C void SetMimeFormatsL(RPointerArray<CSmlMimeFormat>& aMimeFormats);
       
   266 	IMPORT_C TInt MimeFormatRxPref() const;
       
   267 	IMPORT_C void SetMimeFormatRxPref(TInt aRxPref);
       
   268 	IMPORT_C TInt MimeFormatTxPref() const;
       
   269 	IMPORT_C void SetMimeFormatTxPref(TInt aTxPref);
       
   270 
       
   271 	IMPORT_C TBool IsSupported(TOption aOption) const;
       
   272 	IMPORT_C void SetSupportedOptions(TUint32 aFlags);
       
   273 
       
   274 	IMPORT_C TInt FolderPropertyCount() const;
       
   275 	IMPORT_C const CSmlDataProperty& FolderProperty(TInt aIndex) const;
       
   276 	// Method takes ownership of folder properties
       
   277 	IMPORT_C void SetFolderPropertiesL(RPointerArray<CSmlDataProperty>& aFolderProperties);
       
   278 
       
   279 	IMPORT_C TInt FilterCapabilityCount() const;
       
   280 	IMPORT_C const CSmlFilterCapability& FilterCapability(TInt aIndex) const;
       
   281 	// Method takes ownership of filter capabilities
       
   282 	IMPORT_C void SetFilterCapabilitiesL(RPointerArray<CSmlFilterCapability>& aFilterCapabilities);
       
   283 
       
   284 	IMPORT_C TBool HasMaxSize() const;
       
   285 	IMPORT_C TBool HasMaxItems() const;
       
   286 	IMPORT_C TInt MaxSize() const;
       
   287 	IMPORT_C TInt MaxItems() const;
       
   288 	IMPORT_C void SetMaxSize(TUint16 aMaxSize);
       
   289 	IMPORT_C void SetMaxItems(TUint16 aMaxItems);
       
   290 
       
   291 protected:
       
   292 	HBufC* iDisplayName;
       
   293 	TSmlSyncTypeMask iSyncTypeMask;
       
   294 	RPointerArray<CSmlDataProperty> iFolderProperties;
       
   295 	RPointerArray<CSmlFilterCapability> iFilterCapabilities;
       
   296 	TUint16 iMaxSize;
       
   297 	TUint16 iMaxItems;
       
   298 	TUint32 iFlags;
       
   299   RPointerArray<CSmlMimeFormat> iMimeFormats;
       
   300   TInt iRxPref;
       
   301   TInt iTxPref;
       
   302 	};
       
   303 
       
   304 
       
   305 ///////////////////////////////////////////////////////////////////////////////
       
   306 ///////////////////////////////////////////////////////////////////////////////
       
   307 ///////////////////////////////////////////////////////////////////////////////
       
   308 #endif