syncmlfw/dm/treemodule/inc/nsmldmcommandbuffer.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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:  DM tree etc.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLDMCOMMANDBUFFER_H
       
    20 #define __NSMLDMCOMMANDBUFFER_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <smldmadapter.h>
       
    25 #include <nsmldmtreedbclient.h>
       
    26 #include "nsmldmtreedtd.h"
       
    27 
       
    28 class MNSmlDmModuleCallBack;
       
    29 class CNSmlDmModule;
       
    30 class CNSmlDmLinkCallback;
       
    31 class CNSmlDmDDF;
       
    32 
       
    33 _LIT8(KNSmlDmProperty, "?prop=" );
       
    34 
       
    35 // ===========================================================================
       
    36 // Commands
       
    37 // ===========================================================================
       
    38 /**
       
    39 * Container class for a DM command buffering.
       
    40 * This class is instantiated for each command
       
    41 * inside the atomic. The elements are in linked list
       
    42 *
       
    43 *  @since 
       
    44 */
       
    45 class CNSmlDmCommands : public CBase
       
    46 	{
       
    47 	
       
    48 	public:
       
    49 	/**
       
    50 	* Pointer to next elelmnt
       
    51 	*/
       
    52 	CNSmlDmCommands *iNext;
       
    53 	
       
    54 	/**
       
    55 	* URI of the command
       
    56 	*/
       
    57 	HBufC8* iURI;
       
    58 	
       
    59 	/**
       
    60 	* Target URI of the command in case of copy
       
    61 	*/
       
    62 	HBufC8* iTargetURI;
       
    63 
       
    64 	/**
       
    65 	* Mime type of the item
       
    66 	*/
       
    67 	HBufC8* iType;
       
    68 
       
    69 	/**
       
    70 	* Data of the item in case of add, replace or execute
       
    71 	*/
       
    72 	HBufC8* iObject;
       
    73 
       
    74 	/**
       
    75 	* Type of command (Add,Get,...)
       
    76 	*/
       
    77 	TNSmlDmCmdType iCmdType;
       
    78 
       
    79 	/**
       
    80 	* Reference to status element
       
    81 	*/
       
    82 	TInt iStatusRef;
       
    83 
       
    84 	/**
       
    85 	* Reference to result element
       
    86 	*/
       
    87 	TInt iResultsRef;
       
    88 
       
    89 	/**
       
    90 	* Status code
       
    91 	*/
       
    92 	TInt iStatusCode;
       
    93 
       
    94 	/**
       
    95 	* Result
       
    96 	*/
       
    97 	CBufBase* iResult;
       
    98 	
       
    99 	/**
       
   100 	* Format
       
   101 	*/
       
   102 	HBufC8* iFormat;
       
   103 
       
   104 	/**
       
   105 	* Indicates that the status is got to current command
       
   106 	*/
       
   107 	TBool iGotStatus;
       
   108 
       
   109 	/**
       
   110 	* Pointer to callback
       
   111 	*/
       
   112 	CNSmlDmLinkCallback *iCallback;
       
   113 
       
   114 	public:
       
   115 	
       
   116 	/**
       
   117 	* Constructor
       
   118 	*/
       
   119 	CNSmlDmCommands();
       
   120 
       
   121 	/**
       
   122 	* Destructor
       
   123 	*/
       
   124 	virtual ~CNSmlDmCommands();
       
   125 	};
       
   126 
       
   127 
       
   128 // ===========================================================================
       
   129 // CNSmlDmCommandBuffer
       
   130 // ===========================================================================
       
   131 /**
       
   132 * Class for handling bufered commands inside the atomic
       
   133 *
       
   134 *  @since 
       
   135 */
       
   136 class CNSmlDmCommandBuffer : public CBase
       
   137 	{
       
   138 	public:
       
   139 
       
   140 	/**
       
   141 	* Two-phased constructor.
       
   142 	* @return						Pointer to newly created module instance
       
   143 	*/
       
   144 	static CNSmlDmCommandBuffer* NewL(CNSmlDmModule& aDmModule); 
       
   145 
       
   146 	/**
       
   147 	* Destructor
       
   148 	*/
       
   149 	virtual ~CNSmlDmCommandBuffer();
       
   150 	
       
   151 
       
   152 	/**
       
   153 	* Add operation in DM protocoll for buffering
       
   154 	* @param	aURI			Target URI in command
       
   155 	* @param	aObject			Data
       
   156 	* @param	aType			Mime type
       
   157 	* @param	aStatusRef		Reference to status element
       
   158 	*/
       
   159 	void AddObjectL(const TDesC8& aURI, const TDesC8& aObject,
       
   160 		const TDesC8& aType, TInt aStatusRef );
       
   161 		
       
   162 	/**
       
   163 	* Replace operation in DM protocoll for buffering
       
   164 	* @param	aURI			Target URI in command
       
   165 	* @param	aObject			Data
       
   166 	* @param	aType			Mime type
       
   167 	* @param	aStatusRef		Reference to status element
       
   168 	*							or not
       
   169 	*/
       
   170 	void UpdateObjectL( const TDesC8& aURI, const TDesC8& aObject,
       
   171 		const TDesC8& aType, TInt aStatusRef);
       
   172 
       
   173 	/**
       
   174 	* Delete operation in DM protocoll for buffering
       
   175 	* @param	aURI			Target URI in command
       
   176 	* @param	aStatusRef		Reference to status element
       
   177 	*/
       
   178 	void DeleteObjectL(const TDesC8& aURI, TInt aStatusRef );
       
   179 	
       
   180 	/**
       
   181 	* Get operation in DM protocoll for buffering
       
   182 	* @param	aURI			Target URI in command
       
   183 	* @param	aType			Mime type
       
   184 	* @param	aResultsRef		Reference to result element
       
   185 	* @param	aStatusRef		Reference to status element
       
   186 	*/
       
   187 	void FetchObjectL(const TDesC8& aURI, const TDesC8& aType,
       
   188 		TInt aResultsRef, TInt aStatusRef );
       
   189 		
       
   190 	/**
       
   191 	* Execute operation in DM protocoll for buffering
       
   192 	* @param	aURI			Target URI in command
       
   193 	* @param	aObject			Data
       
   194 	* @param	aType			Mime type
       
   195 	* @param	aStatusRef		Reference to status element
       
   196 	*/
       
   197 	void ExecuteObjectL( const TDesC8& aURI, const TDesC8& aObject,
       
   198 		const TDesC8& aType, TInt aStatusRef);
       
   199 		
       
   200 	/**
       
   201 	* Copy operation in DM protocoll for buffering
       
   202 	* @param	aTargetURI		Target URI in command
       
   203 	* @param	aSourceURI		Source URI in command
       
   204 	* @param	aType			Mime type
       
   205 	* @param	aStatusRef		Reference to status element
       
   206 	*/
       
   207 	void CopyObjectL( const TDesC8& aTargetURI,const TDesC8& aSourceURI,
       
   208 		const TDesC8& aType, TInt aStatusRef);
       
   209 		
       
   210 
       
   211 	/**
       
   212 	* Commits the atomic, i.e. executed the commands in the buffer
       
   213 	* @param	aDDF		Reference to DDF module
       
   214 	*/
       
   215 	void CommitL( CNSmlDmDDF& aDDF);
       
   216 
       
   217 	/**
       
   218 	* Rollbacks the atomic, i.e. rollbacks the commands in the buffer
       
   219 	* @param	aDDF		Reference to DDF module
       
   220 	*/
       
   221 	void RollBackL(CNSmlDmDDF& aDDF);
       
   222 	
       
   223 	/**
       
   224 	* Check if this command has came inside atomic
       
   225 	* @param	aStatusRef		Reference to status element
       
   226 	* @return					ETrue if status ref is found from buffer
       
   227 	*/
       
   228 	TBool CheckStatusRef(TInt aStatusRef);
       
   229 
       
   230 	/**
       
   231 	* Check if this command has came inside atomic
       
   232 	* @param	aResultRef		Reference to result element
       
   233 	* @return					ETrue if resultref is found from buffer
       
   234 	*/
       
   235 	TBool CheckResultsRef(TInt aResultsRef);
       
   236 
       
   237 	/**
       
   238 	* Sets the status of command pointed by aStatusRef
       
   239 	* @param	aStatusRef		Reference to status element
       
   240 	* @param	aStatusCode		Status code to be set
       
   241 	*/
       
   242 	void SetStatus(TInt aStatusRef, TInt aStatusCode);
       
   243 	
       
   244 	/**
       
   245 	* Sets the result of command pointed by aResultRef
       
   246 	* @param	aResultRef		Reference to result element
       
   247 	* @param	aObject			Result data to be set
       
   248 	* @param	aType			Mime type of the object
       
   249 	* @param	aFormat			Format of the node
       
   250 	*/
       
   251 	void SetResultsL(TInt aResultsRef, const CBufBase& aObject,
       
   252 		const TDesC8& aType, const TDesC8& aFormat );
       
   253 	
       
   254 	/**
       
   255 	* check    whether the atomic command is with Get
       
   256 	* @param	 None
       
   257 	* @return	ETrue if the atomic command is with Get or else EFalse
       
   258 	*/	
       
   259 	TBool IsGetWithAtomic();
       
   260 	
       
   261 	private:
       
   262 	
       
   263 	/**
       
   264 	* Sends the statuses and results to caller from the command buffer.
       
   265 	*/
       
   266 	void SendStatusAndResultCodesL();
       
   267 
       
   268 	/**
       
   269 	* Check if parent node is deleted because of failure in atomic
       
   270 	* @param	aURI		URI of the node
       
   271 	* @return				ETrue if parent of node is deleted 
       
   272 	*/
       
   273 	TBool ParentNodeDeletedL(const TDesC8& aURI);
       
   274 
       
   275 	/**
       
   276 	* Constructor
       
   277 	* @param	aDmModule		Reference to caller
       
   278 	*/
       
   279 	CNSmlDmCommandBuffer(CNSmlDmModule& aDmModule);
       
   280 
       
   281 	/**
       
   282 	* Atomic failure checking
       
   283 	* @return	ETrue if some command failed or status missing 
       
   284 	*/
       
   285 	TBool AtomicFailed();
       
   286 
       
   287 	/**
       
   288 	* Change statuses to correct atomic statuses.
       
   289 	*/
       
   290 	void ChangeAtomicStatuses();
       
   291 
       
   292 	private:
       
   293 	CNSmlDmModule& iDmModule;
       
   294 	CNSmlDmCommands* iCommandBuffer;
       
   295 	TBool iAtomicFailed;
       
   296 	};
       
   297 
       
   298 
       
   299 
       
   300 
       
   301 
       
   302 #endif // __NSMLDMCOMMANDCUFFER_H