omadm/omadmextensions/adapters/email/tsrc/inc/dmatest.h
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implementation of DM adapter test component
       
    15 * 	This is part of omadmextensions/adapter test application.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 #ifndef __DMA_TEST_H__
       
    25 #define __DMA_TEST_H__
       
    26 
       
    27 //  INCLUDES
       
    28 #include <StifLogger.h>
       
    29 #include <TestScripterInternal.h>
       
    30 #include <StifTestModule.h>
       
    31 #include <apmstd.h>
       
    32 #include <smldmadapter.h>
       
    33 #include "nsmldmemailadapter.h"
       
    34 
       
    35 class Cdmatest;
       
    36 
       
    37 
       
    38 struct TMapping
       
    39 	{
       
    40 	TBuf8<256> iURI;
       
    41 	TBuf8<64> iLuid;
       
    42 	TMapping( const TDesC8 &aURI, const TDesC8 &aLuid )  : iURI( aURI ), iLuid( aLuid )
       
    43 	{
       
    44 		
       
    45 		}
       
    46 	};
       
    47 	
       
    48 typedef RArray<TMapping> RMappingArray;
       
    49 
       
    50 typedef void (Cdmatest::* ResultsFunction)( TInt , CBufBase& , const TDesC8&  ) ; 
       
    51 
       
    52 
       
    53 // CLASS DECLARATION
       
    54 
       
    55 /**
       
    56 *  ?one_line_short_description.
       
    57 *  ?other_description_lines
       
    58 *
       
    59 *  @lib ?library
       
    60 *  @since Series ?XX ?SeriesXX_version
       
    61 */
       
    62 class Cdmatest : public CScriptBase, public MSmlDmCallback
       
    63     {
       
    64     
       
    65     public:  // Constructors and destructor
       
    66         
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         virtual ~Cdmatest();
       
    71 
       
    72     public: // Functions from base classes
       
    73 
       
    74         /**
       
    75         * From CScriptBase Runs a script line.
       
    76         * @since ?Series60_version
       
    77         * @param aItem Script line containing method name and parameters
       
    78         * @return Symbian OS error code
       
    79         */
       
    80         virtual TInt RunMethodL( CStifItemParser& aItem ) = 0;
       
    81     
       
    82 
       
    83 	public:
       
    84 		/**
       
    85 		The function is used to return the data in case of FetchLeafObjectL(),
       
    86 		FetchLeafObjectSizeL() and ChildURIListL() functions. It should not be
       
    87 		called where the DM command has failed, i.e. the error code returned in
       
    88 		SetStatusL is something other than EOk.
       
    89 		@param aResultsRef	Reference to correct command
       
    90 		@param aObject		The data which should be returned
       
    91 		@param aType			MIME type of the object
       
    92 		@publishedPartner
       
    93 		@prototype
       
    94 		*/
       
    95 		void SetResultsL( TInt aResultsRef, CBufBase& aObject,
       
    96 								  const TDesC8& aType );
       
    97 		
       
    98 		/**
       
    99 		The function is used to return the data in case of FetchLeafObjectL() and
       
   100 		ChildURIListL() functions, where the size of the data being returned is
       
   101 		large enough for the Adapter to stream it. This function should not be
       
   102 		called when command was failed, i.e. the error code returned in SetStatusL
       
   103 		is something other than EOk.
       
   104 		@param aResultsRef	Reference to correct command
       
   105 		@param aStream		Large data which should be returned, DM engine
       
   106 								closes stream when it has read all the data
       
   107 		@param aType			MIME type of the object
       
   108 		@publishedPartner
       
   109 		@prototype
       
   110 		*/
       
   111 		void SetResultsL( TInt /*aResultsRef*/, RReadStream*& /*aStream*/,
       
   112 								  const TDesC8& /*aType*/ ) 
       
   113 		{
       
   114 			
       
   115 		}
       
   116 
       
   117 		/**
       
   118 		The function returns information about the Add,Update,Delete and Fetch
       
   119 		commands success to DM engine. The reference to correct command must be
       
   120 		used when calling the SetStatusL function, the reference is got from the
       
   121 		argument of the command functions. The SetStatusL function must be called
       
   122 		separately for every single command.
       
   123 		@param aStatusRef	Reference to correct command
       
   124 		@param aErrorCode	Information about the command success
       
   125 		@publishedPartner
       
   126 		@prototype
       
   127 		*/
       
   128 		void SetStatusL( TInt aStatusRef,
       
   129 								 MSmlDmAdapter::TError aErrorCode ) ;
       
   130 
       
   131 		/**
       
   132 		The function passes map information to DM Module. This function is called
       
   133 		for a new management object, both for node objects and for leaf objects.
       
   134 		In addition if ChildURIListL() function has returned new objects a mapping
       
   135 		information of the new objects must be passed. A mapping is treated as
       
   136 		inheritable. If the mapping is not set with this function, the mapping
       
   137 		LUID of the parent object is passed in following commands to the object.
       
   138 		@param aURI	URI of the object. 
       
   139 		@param aLUID	LUID of the object. LUID must contain the all information,
       
   140 						which is needed for retrieve the invidual object from the
       
   141 						database. Typically it is ID for the database table. In
       
   142 						more complicated structures it can be combination of IDs,
       
   143 						which represent path to the object.
       
   144 		@publishedPartner
       
   145 		@prototype
       
   146 		*/
       
   147 		void SetMappingL( const TDesC8& aURI, const TDesC8& aLUID );
       
   148 
       
   149 		/**
       
   150 		The function is used to make a fetch to other adapters. The most common
       
   151 		use is to make a fetch to the AP adapter, because when managing the access
       
   152 		points, the data comes as URI. For example, there are ToNAPId field in
       
   153 		some adapters, and data to it can be something like AP/IAPidx, and then
       
   154 		the link to AP adapter is needed.
       
   155 		Using FetchLinkL causes the DM Framework to make a Get request to the
       
   156 		appropriate DM adapter.  The receiving adapter MUST complete the Get
       
   157 		request synchronously.
       
   158 		@param aURI		URI of the object. 
       
   159 		@param aData		Reference to data, i.e. data is returned here
       
   160 		@param aStatus	The status of fetch command is returned here
       
   161 		@publishedPartner
       
   162 		@prototype
       
   163 		*/
       
   164 		void FetchLinkL( const TDesC8& /*aURI*/, CBufBase& /*aData*/,
       
   165 								 MSmlDmAdapter::TError& /*aStatus*/ ) 
       
   166 			{
       
   167 				
       
   168 			}
       
   169 
       
   170 		/**
       
   171 		The function returns the LUID which is mapped to aURI. If LUID is not
       
   172 		found, the function allocates a null length string, i.e. the function
       
   173 		allocates memory in every case.
       
   174 		@param aURI	URI of the object. 
       
   175 		@publishedPartner
       
   176 		@prototype
       
   177 		*/
       
   178 		HBufC8* GetLuidAllocL( const TDesC8& aURI ) ;
       
   179 
       
   180 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   181     
       
   182     void GetMappingInfoListL( const TDesC8& aURI,
       
   183 								CArrayFix<TSmlDmMappingInfo>& aSegmentList );
       
   184 
       
   185 #else
       
   186 // nothing
       
   187 #endif
       
   188 		        
       
   189     protected:  // New functions
       
   190 
       
   191         
       
   192 		void FetchNodeResultsL( TInt aResultsRef, CBufBase& aObject,
       
   193 							  const TDesC8& aType );
       
   194 		void SaveDataL( TInt aResultsRef, CBufBase& aObject,
       
   195 							  const TDesC8& aType ) ;
       
   196 							  
       
   197 		TPtrC8 LastURISeg( const TDesC8& aURI );
       
   198 		TPtrC8 RemoveLastURISeg( const TDesC8& aURI );
       
   199 		TPtrC RemoveLastURISeg( const TDesC& aURI );
       
   200 		void SetURIL( const TDesC& aURI );
       
   201 		void SetURIL( const TDesC8& aURI );
       
   202 		void SetURIL( HBufC8* aURI );		
       
   203 		HBufC8 *LoadFileLC( const TDesC &aFileName, TDataType &aType );
       
   204 		HBufC8 *LoadFileLC( const TDesC8 &aFileName, TDataType &aType );
       
   205 		HBufC8 *GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName );
       
   206 		HBufC8* GetLuidAllocLC( const TDesC8& aURI ) ;
       
   207 		TPtrC8 RemoveLastSeg(const TDesC8& aURI);
       
   208 		
       
   209 		TInt FetchNodeL( CStifItemParser& aItem ) ;
       
   210 		TInt FetchLeafL( CStifItemParser& aItem ) ;
       
   211 		TInt AddNodeL( CStifItemParser& aItem );
       
   212 		TInt DeleteObjectL( CStifItemParser& aItem );	
       
   213 		TInt UpdateLeafL( CStifItemParser& aItem )	;
       
   214 		TInt UpdateLeafDataL( CStifItemParser& aItem ) ;
       
   215 		TInt UpdateLeafDataURLL( CStifItemParser& aItem ) ;
       
   216 		
       
   217 		TInt ExecuteLeafL ( CStifItemParser& aItem ) ;
       
   218 		TInt ExecuteLeafDataL ( CStifItemParser& aItem ) ;
       
   219 		TInt StartAtomicL( CStifItemParser& aItem )	;
       
   220 		TInt CommitAtomicL( CStifItemParser& aItem )	;
       
   221 		TInt RollbackAtomicL( CStifItemParser& aItem )	;
       
   222 		TInt CompleteCommandsL( CStifItemParser& aItem );
       
   223 		TInt DDFStructureL( CStifItemParser& aItem )	;
       
   224 //        TInt DeliverL( CStifItemParser& aItem ) ;
       
   225 //        TInt DetailsL( CStifItemParser& aItem ) ;
       
   226 //		TInt InstallL( CStifItemParser& aItem ) ;
       
   227 //		TInt BareInstallL( CStifItemParser& aItem ) ;		
       
   228 
       
   229     protected:
       
   230 
       
   231         /**
       
   232         * C++ default constructor.
       
   233         */
       
   234         Cdmatest( CTestModuleIf& aTestModuleIf, TUid aUid );
       
   235 
       
   236         /**
       
   237         * By default Symbian 2nd phase constructor is private.
       
   238         */
       
   239         void ConstructL();
       
   240 
       
   241         // Prohibit copy constructor if not deriving from CBase.
       
   242         // Cdmatest( const Cdmatest& );
       
   243         // Prohibit assigment operator if not deriving from CBase.
       
   244         // Cdmatest& operator=( const Cdmatest& );
       
   245 
       
   246 		/**
       
   247         * Frees all resources allocated from test methods.
       
   248         * @since ?Series60_version
       
   249         */
       
   250         virtual void Delete();
       
   251         void LoadMappingsL();
       
   252         void SaveMappingsL();
       
   253     public:     // Data
       
   254         // ?one_line_short_description_of_data
       
   255         //?data_declaration;
       
   256     
       
   257     protected:  // Data
       
   258         // ?one_line_short_description_of_data
       
   259         //?data_declaration;
       
   260 		MSmlDmAdapter::TError iStatus ;
       
   261         ResultsFunction iResultsFunction;
       
   262         //CSmlDmAdapter *iAdapter ;
       
   263         CNSmlDmEmailAdapter *iAdapter ;
       
   264         HBufC8 *iURI; 
       
   265         CArrayFix<TSmlDmMappingInfo> *iEmptyMappingInfoArray;
       
   266 		TFileName iSaveFileName;
       
   267 		RMappingArray iMappingTable;
       
   268 		TUid iUid;
       
   269 		TInt iCounter;
       
   270 		//class CNSmlDmMgmtTree* iMgmtTree;
       
   271 		class CNSmlDmMgmtTree* iMgmtTree;
       
   272 		CNSmlDmEmailAdapter *Adapter() ;
       
   273     };
       
   274 
       
   275 #endif      // __DMA_TEST_H__
       
   276             
       
   277 // End of File