|
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: Data accessor for imps engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CImpsDataAccessor_H |
|
20 #define CImpsDataAccessor_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "impsdataaccessorapi.h" |
|
24 #include "impstdataaccessor.h" |
|
25 |
|
26 /** |
|
27 * CImpsDataAccessor |
|
28 */ |
|
29 class CImpsDataAccessor : public CBase, public MImpsDataAccessor |
|
30 { |
|
31 public: // Constructors and destructor |
|
32 |
|
33 /** |
|
34 * Two-phased constructor. |
|
35 * @param is a pointer to aImpsFields class |
|
36 */ |
|
37 IMPORT_C static CImpsDataAccessor* NewL( CImpsFields* aImpsFields ); |
|
38 |
|
39 /** |
|
40 * Two-phased constructor. |
|
41 * @param is a pointer to aImpsFields class |
|
42 */ |
|
43 IMPORT_C static CImpsDataAccessor* NewLC( CImpsFields* aImpsFields ); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 IMPORT_C virtual ~CImpsDataAccessor(); |
|
49 |
|
50 public: // Functions from base classes |
|
51 |
|
52 /** |
|
53 * Accessor creates an instance of MImpsKey entity. |
|
54 * It is NOT deleted by Accessor! You must do that yourself. |
|
55 * @return MImpsKey new key |
|
56 */ |
|
57 inline MImpsKey* NewKeyL(); |
|
58 |
|
59 /** |
|
60 * descriptor value mutator |
|
61 * key is a byte sequence, which defines how value is stored |
|
62 * @param aKey Key |
|
63 * @param aValue Value |
|
64 */ |
|
65 inline void StoreDescL( MImpsKey* aKey, TPtrC aValue ); |
|
66 |
|
67 /** |
|
68 * descriptor8 value mutator |
|
69 * key is a byte sequence, which defines how value is stored |
|
70 * @param aKey Key |
|
71 * @param aValue Value |
|
72 */ |
|
73 inline void StoreDesc8L( MImpsKey* aKey, TPtrC8 aValue ); |
|
74 |
|
75 /** |
|
76 * Integer value mutator |
|
77 * key is a byte sequence, which defines how value is stored |
|
78 * @param aKey Key |
|
79 * @param aValue Value |
|
80 */ |
|
81 inline void StoreIntegerL( MImpsKey* aKey, TInt aValue ); |
|
82 |
|
83 /** |
|
84 * boolean value mutator |
|
85 * key is a byte sequence, which defines how value is stored |
|
86 * @param aKey Key |
|
87 * @param aValue Value |
|
88 */ |
|
89 inline void StoreBooleanL( MImpsKey* aKey, TBool aValue ); |
|
90 |
|
91 /** |
|
92 * key is a byte sequence, which defines how value is stored |
|
93 * empty value mutator |
|
94 * @param aKey Key |
|
95 */ |
|
96 inline void StoreEmptyL( MImpsKey* aKey ); |
|
97 |
|
98 /** |
|
99 * extension attribute mutator |
|
100 * key is a byte sequence, which defines how value is stored |
|
101 * @param aKey Key |
|
102 * @param aName Extension attribute name |
|
103 * @param aValue Extension attribute value |
|
104 */ |
|
105 inline void StoreExtL( MImpsKey* aKey, TPtrC8 aName, TPtrC8 aValue ); |
|
106 |
|
107 /** |
|
108 * descriptor value accessor |
|
109 * aBuf doesn't go out of scope even if we call this function again. |
|
110 * This way there is no need to copy the buffer |
|
111 * @param aKey Key for restore |
|
112 * @param aBuf OUT Pointer to TDesC object |
|
113 * @return ETrue if key is found, EFalse otherwise |
|
114 */ |
|
115 inline TBool RestoreDescL( MImpsKey* aKey, TDesC*& aBuf ); |
|
116 |
|
117 /** |
|
118 * descriptor value accessor |
|
119 * @param aKey Key for restore |
|
120 * @param aDes OUT Pointer to TDesC8 object |
|
121 * @return ETrue if key is found, EFalse otherwise |
|
122 */ |
|
123 inline TBool RestoreDesc8L( MImpsKey* aKey, TDesC8*& aDes ); |
|
124 |
|
125 /** |
|
126 * integer value accessor |
|
127 * @param aKey Key for restore |
|
128 * @param aInt OUT TInt object |
|
129 * @return ETrue if key is found, EFalse otherwise |
|
130 */ |
|
131 inline TBool RestoreIntegerL( MImpsKey* aKey, TInt& aInt ); |
|
132 |
|
133 /** |
|
134 * Boolean value accessor |
|
135 * @param aKey Key for restore |
|
136 * @param aBuf OUT Boolean object |
|
137 * @return ETrue if key is found, EFalse otherwise |
|
138 */ |
|
139 inline TBool RestoreBooleanL( MImpsKey* aKey, TBool& aBool ); |
|
140 |
|
141 /** |
|
142 * empty value accessor |
|
143 * @param aKey Key for restore |
|
144 * @return ETrue if key is found, EFalse otherwise |
|
145 */ |
|
146 inline TBool RestoreEmptyL( MImpsKey* aKey ); |
|
147 |
|
148 /** |
|
149 * extension attribute accessor |
|
150 * @param aKey Key for restore |
|
151 * @param aName OUT Pointer to TDesC8 object |
|
152 * @param aValue OUT Pointer to TDesC8 object |
|
153 * @return ETrue if key is found, EFalse otherwise |
|
154 */ |
|
155 inline TBool RestoreExtL( MImpsKey* aKey, |
|
156 TDesC8*& aName, TDesC8*& aValue ); |
|
157 |
|
158 /** |
|
159 * data type accessor |
|
160 * Leaves with KErrArgument if illegal key not in WV DTD. |
|
161 * return data type. Note that one possible value is "not supported". |
|
162 * @param aKey Key type |
|
163 * @return TImpsDataType Datatype |
|
164 */ |
|
165 inline TImpsDataType KeyTypeL( MImpsKey* aKey ); |
|
166 |
|
167 /** |
|
168 * Finds the alternative key |
|
169 * This function finds if the supplied key has a child in the |
|
170 * datastorage and returns the information of the element. |
|
171 * This is usefull with e.g. TransactionContent |
|
172 * @param aKey key in |
|
173 * @param aEnum Enum value out |
|
174 * @param aIndex index out |
|
175 * @param aType type out |
|
176 * @return ETrue if found, EFalse if not found |
|
177 */ |
|
178 inline TBool RestoreAlternativeL( const MImpsKey* aKey, |
|
179 TInt& aEnum, |
|
180 TInt& aIndex, |
|
181 TImpsKeyType& aType ) const; |
|
182 |
|
183 /** |
|
184 * Checks if the key exists |
|
185 * This function finds if the supplied key exists as it self or with |
|
186 * children and returns ETrue or EFalse |
|
187 * @param aKey key in |
|
188 * @return ETrue if found, EFalse if not found |
|
189 */ |
|
190 inline TBool CheckBranchExistenceL( const MImpsKey* aKey ) const; |
|
191 |
|
192 /** |
|
193 * Returns the number of transactions. This is used in MultiTrans |
|
194 * This function calculates the number of transaction elements which have |
|
195 * different index and returns it. |
|
196 * @return 0 if none found, positive for number of found |
|
197 */ |
|
198 inline TInt NbrOfTransactionsL( ) const; |
|
199 |
|
200 /** |
|
201 * Gets the given transaction. If no transaction is found using the given |
|
202 * index, this function returns EFalse. ETrue if found. |
|
203 * The new transactions index is set to 0. |
|
204 * aFields members are also set accordingly. |
|
205 * @param aIndex Which transaction to get |
|
206 * @param aFields Fields object where the data is copied |
|
207 * If this parameter is NULL then the DataAccessors impsfiels |
|
208 * transactionID and messagetype are set from CImpsdata. |
|
209 * @return ETrue if found, EFalse if not found |
|
210 */ |
|
211 inline TBool GetTransactionL( TInt aIndex, CImpsFields* aFields ) const; |
|
212 |
|
213 /** |
|
214 * Copy specific part of the message to the current message |
|
215 * @param aSource where to copy data elements |
|
216 * @param aKey which part of message is copied. NULL means that all data |
|
217 * is copied. |
|
218 */ |
|
219 void CopyDataL( |
|
220 MImpsDataAccessor& aSource, |
|
221 MImpsKey* aKey = NULL ); |
|
222 |
|
223 /** |
|
224 * impsfields accessor |
|
225 * @return CImpsFields* |
|
226 */ |
|
227 inline CImpsFields* GetImpsFields() const; |
|
228 |
|
229 |
|
230 #ifdef _DEBUG |
|
231 void DumpToFileL( RFs& aFs, const TDesC& aFilename ); |
|
232 #endif |
|
233 |
|
234 private: |
|
235 |
|
236 /** |
|
237 * By default Symbian OS constructor is private. |
|
238 */ |
|
239 CImpsDataAccessor(); |
|
240 |
|
241 /** |
|
242 * Actual construction. |
|
243 * @param aImpsFields is pointer to message data storage class |
|
244 */ |
|
245 void ConstructL( CImpsFields* aImpsFields ); |
|
246 |
|
247 private: // Data |
|
248 TImpsDataAccessor iDataAccessor; |
|
249 |
|
250 }; |
|
251 |
|
252 #include "ImpsDataAccessor.inl" |
|
253 |
|
254 #endif // CImpsDataAccessor_H |
|
255 |
|
256 // End of File |