omads/omadsextensions/datamod/inc/NSmlDataModBase.h
branchRCL_3
changeset 12 4d5e9526124e
parent 11 3f1ffafb31ec
child 13 a564f66a2339
equal deleted inserted replaced
11:3f1ffafb31ec 12:4d5e9526124e
     1 /*
       
     2 * Copyright (c) 2005 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:  Stripper and merger base class for versit data and 
       
    15 *				 implementation for vCard and vCalendar stripping and merging.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __NSMLDATABASE_H__
       
    21 #define __NSMLDATABASE_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <vprop.h>
       
    26 #include <SmlDataFormat.h>
       
    27 
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 * Class that is inherited from CParserProperty to make it possible to handle parameters.
       
    33 *
       
    34 * @lib nsmldatamod.lib
       
    35 */
       
    36 class CNSmlProperty : public CParserProperty
       
    37 	{
       
    38 	public:
       
    39 		/**
       
    40 	    * Creates new property based on given parameters.
       
    41 	    * @param aPropertyValue. 	Value of property.
       
    42 	    * @param aName. 			Name of property.
       
    43 	    * @param aArrayOfParams. 	Parameters of property.
       
    44 	    * @return 					New instance of this class.
       
    45 	    */
       
    46 		static CNSmlProperty* NewL( CParserPropertyValue& aPropertyValue, const TDesC8& aName, CArrayPtr<CParserParam>* aArrayOfParams );
       
    47 		
       
    48 		/**
       
    49 	    * Returns paramaters of property.
       
    50 	    * @return	Parameters of property.
       
    51 	    */
       
    52 		CArrayPtr<CParserParam>* Parameters() const;
       
    53 		
       
    54 		/**
       
    55 	    * Returns count of paramaters.
       
    56 	    * @return	Count of paramaters.
       
    57 	    */
       
    58 		TInt ParamCount() const;
       
    59 		
       
    60 		/**
       
    61 	    * Compares names of two properties
       
    62 	    * @param aFirst. 	First property to compare.
       
    63 	    * @param aSecond. 	Second property to compare.
       
    64 	    * @return 			Returns 0 if names are equal.
       
    65 	    */
       
    66 		static TInt Compare( const CNSmlProperty& aFirst, const CNSmlProperty& aSecond );
       
    67 		
       
    68 	protected:
       
    69 		/**
       
    70 	    * Basic constructor of class
       
    71 	    */
       
    72 		CNSmlProperty( CParserPropertyValue& aPropertyValue, CArrayPtr<CParserParam>* aArrayOfParams );
       
    73 	};
       
    74 
       
    75 /**
       
    76 * Base class for Calendar and Contacts Data Modifications.
       
    77 *
       
    78 * @lib nsmldatamod.lib
       
    79 */
       
    80 class CNSmlDataModBase : public CBase
       
    81 	{
       
    82 	public:
       
    83 	    /**
       
    84 	    * C++ destructor.
       
    85 	    */
       
    86 		IMPORT_C virtual ~CNSmlDataModBase();
       
    87 		
       
    88 		/**
       
    89 	    * Sets own database format.
       
    90 	    * @param aOwnStoreFormat.	Own database format.
       
    91 	    */
       
    92 		IMPORT_C void SetOwnStoreFormat( CSmlDataStoreFormat& aOwnStoreFormat );
       
    93 
       
    94 		/**
       
    95 	    * Sets remote database format.
       
    96 	    * @param aRemoteStoreFormat.	Remote database format.
       
    97 	    */
       
    98 		IMPORT_C void SetPartnerStoreFormat( CSmlDataStoreFormat& aRemoteStoreFormat );
       
    99 
       
   100 		/**
       
   101 	    * Sets mime type that is used for sending and receiving.
       
   102 	    * This method can be called separately before every item.
       
   103 	    * @param aMimeType.		Mime type.
       
   104 	    * @param aMimeVersion.	Mime type version.
       
   105 	    * @return				KErrNone if partnerStoreFormat is passed and same mime type with same version
       
   106 	    *						can be found. Otherwise KErrNotFound is returned.
       
   107 	    */
       
   108 		IMPORT_C TInt SetUsedMimeType( const RStringF aMimeType, const RStringF aMimeVersion );
       
   109 		
       
   110 		/**
       
   111 	    * Strips data that is to be transmitted to the sync partner.
       
   112 	    * @param aItem	Item's data. On returns this data may have changed due to stripping.
       
   113 	    */
       
   114 		IMPORT_C void StripTxL( CBufBase& aItem );
       
   115 
       
   116 		/**
       
   117 	    * Merges received item with item in exported from the local database.
       
   118 	    * @param aNewItem 	Received item. On return aItem contains merged item.
       
   119 		* @param aOldItem 	Item exported from the local database with which aNewItem is merged.
       
   120 	    */
       
   121 		IMPORT_C void MergeRxL( CBufBase& aNewItem, CBufBase& aOldItem, TBool aFieldLevel = EFalse );
       
   122 
       
   123 		/**
       
   124 	    * Checks whether merging is needed or not.
       
   125 		* @return	ETrue if mergins is needed EFalse otherwise.
       
   126 	    */
       
   127 		IMPORT_C TBool NeedsMerge();
       
   128 
       
   129 	protected:
       
   130 		/**
       
   131 	    * Basic constructor of class.
       
   132 	    */
       
   133 		CNSmlDataModBase();
       
   134 		
       
   135 		/**
       
   136 	    * Creates correct type of parser for each Data Modifications.
       
   137 		* @return	Correct type of versit parser.
       
   138 	    */
       
   139 		virtual CVersitParser* ChildCreateParserLC() = 0;
       
   140 
       
   141 		/**
       
   142 	    * Strips data that is to be transmitted to the sync partner.
       
   143 	    * @param aItem	Item's data. On returns this data may have changed due to stripping.
       
   144 	    */
       
   145 		void StripL( TDes8& aItem );
       
   146 		
       
   147 		/**
       
   148 	    * Strips data that is to be transmitted to the sync partner from entity.
       
   149 	    * @param aEntity	Item's data. On returns this data may have changed due to stripping.
       
   150 	    * @param aModified	If item's data is modified then this is ETrue at return. Otherwise EFalse.
       
   151 	    */
       
   152 		void StripEntityL( CVersitParser* aEntity, TBool& aModified ) const;
       
   153 		
       
   154 		/**
       
   155 	    * Strips all data from entity that is supported by remote server.
       
   156 	    * @param aEntity			Item's data. On returns this data may have changed due to stripping.
       
   157 	    * @param aModified			If item's data is modified then this is ETrue at return. Otherwise EFalse.
       
   158 	    * @param aParamLevelCheck	This is used to decide if parameters are compared when properties are stripped or not.
       
   159 	    */
       
   160 		void StripAllOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck = ETrue ) const;
       
   161 		
       
   162 		/**
       
   163 	    * Strips all data from entity that is not supported by remote server.
       
   164 	    * @param aEntity			Item's data. On returns this data may have changed due to stripping.
       
   165 	    * @param aModified			If item's data is modified then this is ETrue at return. Otherwise EFalse.
       
   166 	    * @param aParamLevelCheck	This is used to decide if parameters are compared when properties are stripped or not.
       
   167 	    */
       
   168 		void StripAllNotOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck = ETrue ) const;
       
   169 		
       
   170 		/**
       
   171 	    * Merges data from old item to new item.
       
   172 	    * @param aNewItem		Data of receive item. On returns this data may have changed due to merging.
       
   173 	    * @param aOldData		Data of old item.
       
   174 	    * @param aFieldLevel	This is used to decide if operation is field level update or not. Are all supported
       
   175 	    *						properties updated or just received properties.
       
   176 	    */
       
   177 		void MergeL( TDes8& aNewItem, const TDesC8& aOldItem,TBool aFieldLevel );
       
   178 		
       
   179 		/**
       
   180 	    * Merges data from old entity to new entity.
       
   181 	    * @param aNewEntity		Data of receive entity. On returns this data may have changed due to merging.
       
   182 	    * @param aOldEntity		Data of old entity.
       
   183 	    * @param aModified		If aNewEntity is modified then this is ETrue at return. Otherwise EFalse.
       
   184 	    * @param aFieldLevel	This is used to decide if operation is field level update or not. Are all supported
       
   185 	    *						properties updated or just received properties.
       
   186 	    */
       
   187 		void MergeEntityL( CVersitParser* aNewEntity, CVersitParser* aOldEntity, TBool& aModified, TBool aFieldLevel ) const;
       
   188 
       
   189 	private:
       
   190 		CSmlDataStoreFormat* iOwnStoreFormat;
       
   191 		CSmlDataStoreFormat* iRemoteStoreFormat;
       
   192 		TInt iUsedOwnMimeType;
       
   193 		TInt iUsedRemoteMimeType;
       
   194 		RStringF iMimeType;
       
   195 		RStringF iMimeVersion;
       
   196 	};
       
   197 
       
   198 
       
   199 /**
       
   200 * Data Modifications for Calendar.
       
   201 *
       
   202 * @lib nsmldatamod.lib
       
   203 */
       
   204 class CNSmlVCalMod : public CNSmlDataModBase
       
   205 	{
       
   206 	public:
       
   207 		/**
       
   208 	    * Constuctor
       
   209 	    */
       
   210 		IMPORT_C CNSmlVCalMod();
       
   211 		
       
   212 	protected:
       
   213 		/**
       
   214 	    * Creates correct type of parser for Calendar Data Modifications.
       
   215 		* @return	Correct type of versit parser.
       
   216 	    */
       
   217 		CVersitParser* ChildCreateParserLC();
       
   218 	};
       
   219 
       
   220 /**
       
   221 * Data Modifications for Contacts.
       
   222 *
       
   223 * @lib nsmldatamod.lib
       
   224 */
       
   225 class CNSmlVCardMod : public CNSmlDataModBase
       
   226 	{
       
   227 	public:
       
   228 		/**
       
   229 	    * Constuctor
       
   230 	    */
       
   231 		IMPORT_C CNSmlVCardMod();
       
   232 		
       
   233 	protected:
       
   234 		/**
       
   235 	    * Creates correct type of parser for Contacts Data Modifications.
       
   236 		* @return	Correct type of versit parser.
       
   237 	    */
       
   238 		CVersitParser* ChildCreateParserLC();
       
   239 	};
       
   240 
       
   241 
       
   242 #endif // __NSMLDATABASE_H__
       
   243 
       
   244 // End of file