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