|
1 /* |
|
2 * Copyright (c) 2002 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: Header file for data accessor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TImpsDataAccessor_H |
|
20 #define TImpsDataAccessor_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "impsdataaccessorapi.h" |
|
24 |
|
25 // DATA TYPES |
|
26 // Data types for the utility class |
|
27 enum TAccessorDataType |
|
28 { |
|
29 EStringType = 0, |
|
30 EString8Type, |
|
31 EIntegerType, |
|
32 EBooleanType, |
|
33 EEmptyType, |
|
34 EExtensionType |
|
35 }; |
|
36 |
|
37 |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class CImpsFields; |
|
41 class CImpsKey; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 // This is a utility class for accessor |
|
46 class TAccessorData |
|
47 { |
|
48 public: |
|
49 TDesC* iValuePointer; |
|
50 TDesC8* iValuePointer8; |
|
51 TPtrC iValue; |
|
52 TPtrC8 iValue8; |
|
53 TInt iValueInt; |
|
54 TBool iValueBool; |
|
55 TAccessorDataType iType; |
|
56 }; |
|
57 |
|
58 |
|
59 /** |
|
60 * TImpsDataAccessor |
|
61 */ |
|
62 class TImpsDataAccessor : public CBase, public MImpsDataAccessor |
|
63 { |
|
64 public: // Constructors and destructor |
|
65 |
|
66 /** |
|
67 * C++ default constructor. |
|
68 * If this constructor is used, the member variable must be |
|
69 * set by using method SetImpsFields( CImpsFields* aImpsFields ) |
|
70 */ |
|
71 IMPORT_C TImpsDataAccessor( ); |
|
72 |
|
73 /** |
|
74 * C++ default constructor. |
|
75 */ |
|
76 IMPORT_C TImpsDataAccessor( CImpsFields* aImpsFields ); |
|
77 |
|
78 /** |
|
79 * Set the member variable |
|
80 */ |
|
81 IMPORT_C void SetImpsFields( CImpsFields* aImpsFields ); |
|
82 |
|
83 /** |
|
84 * Get the member variable |
|
85 */ |
|
86 IMPORT_C CImpsFields* GetImpsFields( ) const; |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 IMPORT_C virtual ~TImpsDataAccessor(); |
|
92 |
|
93 public: // Functions from base classes |
|
94 |
|
95 /** |
|
96 * Accessor creates an instance of MImpsKey entity. |
|
97 * It is NOT deleted by Accessor! You must do that yourself. |
|
98 * @return MImpsKey new key |
|
99 */ |
|
100 IMPORT_C MImpsKey* NewKeyL(); |
|
101 |
|
102 /** |
|
103 * descriptor value mutator |
|
104 * key is a byte sequence, which defines how value is stored |
|
105 * @param aKey Key |
|
106 * @param aValue Value |
|
107 */ |
|
108 IMPORT_C void StoreDescL( MImpsKey* aKey, TPtrC aValue ); |
|
109 |
|
110 /** |
|
111 * descriptor8 value mutator |
|
112 * key is a byte sequence, which defines how value is stored |
|
113 * @param aKey Key |
|
114 * @param aValue Value |
|
115 */ |
|
116 IMPORT_C void StoreDesc8L( MImpsKey* aKey, TPtrC8 aValue ); |
|
117 |
|
118 /** |
|
119 * Integer value mutator |
|
120 * key is a byte sequence, which defines how value is stored |
|
121 * @param aKey Key |
|
122 * @param aValue Value |
|
123 */ |
|
124 IMPORT_C void StoreIntegerL( MImpsKey* aKey, TInt aValue ); |
|
125 |
|
126 /** |
|
127 * boolean value mutator |
|
128 * key is a byte sequence, which defines how value is stored |
|
129 * @param aKey Key |
|
130 * @param aValue Value |
|
131 */ |
|
132 IMPORT_C void StoreBooleanL( MImpsKey* aKey, TBool aValue ); |
|
133 |
|
134 /** |
|
135 * key is a byte sequence, which defines how value is stored |
|
136 * empty value mutator |
|
137 * @param aKey Key |
|
138 */ |
|
139 IMPORT_C void StoreEmptyL( MImpsKey* aKey ); |
|
140 |
|
141 /** |
|
142 * extension attribute mutator |
|
143 * key is a byte sequence, which defines how value is stored |
|
144 * @param aKey Key |
|
145 * @param aName Extension attribute name |
|
146 * @param aValue Extension attribute value |
|
147 */ |
|
148 IMPORT_C void StoreExtL( MImpsKey* aKey, TPtrC8 aName, TPtrC8 aValue ); |
|
149 |
|
150 /** |
|
151 * descriptor value accessor |
|
152 * aBuf doesn't go out of scope even if we call this function again. |
|
153 * This way there is no need to copy the buffer |
|
154 * @param aKey Key for restore |
|
155 * @param aBuf OUT Pointer to TDesC object |
|
156 * @return EFalse if key is not found |
|
157 * ETrue if key is found |
|
158 */ |
|
159 IMPORT_C TBool RestoreDescL( MImpsKey* aKey, TDesC*& aBuf ); |
|
160 |
|
161 /** |
|
162 * descriptor value accessor |
|
163 * This way there is no need to copy the buffer |
|
164 * @param aKey Key for restore |
|
165 * @param aDes OUT Pointer to TDesC8 object |
|
166 * @return EFalse if key is not found |
|
167 * ETrue if key is found |
|
168 */ |
|
169 IMPORT_C TBool RestoreDesc8L( MImpsKey* aKey, TDesC8*& aDes ); |
|
170 |
|
171 /** |
|
172 * integer value accessor |
|
173 * @param aKey Key for restore |
|
174 * @param aInt OUT |
|
175 * @return EFalse if key is not found |
|
176 * ETrue if key is found |
|
177 */ |
|
178 IMPORT_C TBool RestoreIntegerL( MImpsKey* aKey, TInt& aInt ); |
|
179 |
|
180 /** |
|
181 * Boolean value accessor |
|
182 * @param aKey Key for restore |
|
183 * @param aBool OUT Boolean object |
|
184 * @return EFalse if key is not found |
|
185 * ETrue if key is found |
|
186 */ |
|
187 IMPORT_C TBool RestoreBooleanL( MImpsKey* aKey, TBool& aBool ); |
|
188 |
|
189 /** |
|
190 * empty value accessor |
|
191 * @param aKey Key for restore |
|
192 * @return EFalse if key is not found |
|
193 * ETrue if key is found |
|
194 */ |
|
195 IMPORT_C TBool RestoreEmptyL( MImpsKey* aKey ); |
|
196 |
|
197 /** |
|
198 * extension attribute accessor |
|
199 * @param aKey Key for restore |
|
200 * @param aName OUT Pointer to TDesC8 object |
|
201 * @param aValue OUT Pointer to TDesC8 object |
|
202 * @return EFalse if key is not found |
|
203 * ETrue if key is found |
|
204 */ |
|
205 IMPORT_C TBool RestoreExtL( MImpsKey* aKey, |
|
206 TDesC8*& aName, TDesC8*& aValue ); |
|
207 |
|
208 /** |
|
209 * data type accessor |
|
210 * Leaves with KErrArgument if illegal key not in WV DTD. |
|
211 * return data type. Note that one possible value is "not supported". |
|
212 * @param aKey Key type |
|
213 * @return TImpsDataType Datatype |
|
214 */ |
|
215 IMPORT_C TImpsDataType KeyTypeL( MImpsKey* aKey ); |
|
216 |
|
217 /** |
|
218 * Finds the alternative key |
|
219 * This function finds if the supplied key has |
|
220 * a child in the datastorage |
|
221 * and returns the information of the element. |
|
222 * This is usefull with e.g. TransactionContent |
|
223 * @param aKey key in |
|
224 * @param aEnum Enum value out |
|
225 * @param aIndex index out |
|
226 * @param aType type out |
|
227 * @return ETrue if found, EFalse if not found |
|
228 */ |
|
229 IMPORT_C TBool RestoreAlternativeL( const MImpsKey* aKey, |
|
230 TInt& aEnum, TInt& aIndex, TImpsKeyType& aType ) const; |
|
231 |
|
232 /** |
|
233 * Checks if the key exists |
|
234 * This function finds if the supplied key exists |
|
235 * as it self or with children |
|
236 * and returns ETrue or EFalse |
|
237 * @param aKey key in |
|
238 * @return ETrue if found, EFalse if not found |
|
239 */ |
|
240 IMPORT_C TBool CheckBranchExistenceL( const MImpsKey* aKey ) const; |
|
241 |
|
242 /** |
|
243 * Returns the number of transactions. This is used in MultiTrans |
|
244 * This function calculates the number of transaction elements which |
|
245 * have different index and returns it. |
|
246 * @return 0 if none found, positive for number of found |
|
247 */ |
|
248 IMPORT_C TInt NbrOfTransactionsL( ) const; |
|
249 |
|
250 /** |
|
251 * Gets the given transaction. If no transaction is found using the |
|
252 * given index, this function returns EFalse. ETrue if found. |
|
253 * The new transactions index is set to 0. |
|
254 * aFields members are also set accordingly. |
|
255 * @param aIndex Which transaction to get |
|
256 * @param aFields Fields object where the data is copied |
|
257 * If this parameter is NULL then the DataAccessors impsfiels |
|
258 * transactionID and messagetype are set from CImpsdata. |
|
259 * @return ETrue if found, EFalse if not found |
|
260 */ |
|
261 IMPORT_C TBool GetTransactionL( TInt aIndex, |
|
262 CImpsFields* aFields ) const; |
|
263 |
|
264 /** |
|
265 * Copy specific part of the message to the current message |
|
266 * @param aSource where to copy data elements |
|
267 * @param aKey which part of message is copied. NULL means that all data |
|
268 * is copied. |
|
269 */ |
|
270 IMPORT_C void CopyDataL( |
|
271 MImpsDataAccessor& aSource, |
|
272 MImpsKey* aKey ); |
|
273 |
|
274 void DumpToFileL( RFs& aFs, const TDesC& aFilename ); |
|
275 private: |
|
276 |
|
277 |
|
278 /** |
|
279 * Main storing function |
|
280 * @param Key to store |
|
281 */ |
|
282 void DoStoreL( const CImpsKey* aKey ); |
|
283 |
|
284 /** |
|
285 * Store headers |
|
286 * @param Key to store |
|
287 */ |
|
288 void StoreHeadersL( const CImpsKey* aKey ); |
|
289 |
|
290 /** |
|
291 * Main restoring function |
|
292 * @param Key to search |
|
293 * @return ETrue if found, EFalse otherwise |
|
294 */ |
|
295 TBool DoRestoreL( const CImpsKey* aKey ); |
|
296 |
|
297 /** |
|
298 * Restore headers |
|
299 * @param Key to search |
|
300 * @return ETrue if found, EFalse otherwise |
|
301 */ |
|
302 TBool RestoreHeadersL( const CImpsKey* aKey ); |
|
303 |
|
304 // By default, prohibit copy constructor |
|
305 TImpsDataAccessor( const TImpsDataAccessor& ); |
|
306 |
|
307 // Prohibit assigment operator |
|
308 TImpsDataAccessor& operator= ( const TImpsDataAccessor& ); |
|
309 |
|
310 private: // Data |
|
311 CImpsFields* iImpsFields; |
|
312 TAccessorData iData; |
|
313 }; |
|
314 |
|
315 #endif // TImpsDataAccessor_H |
|
316 |
|
317 // End of File |