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