|
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: |
|
15 * util classes for imps data accessor. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef TImpsDataUtils_H |
|
21 #define TImpsDataUtils_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> |
|
26 #include "impsdataaccessorapi.h" |
|
27 #include "impsdataaccessor.h" |
|
28 #include "impsservercommon.h" |
|
29 #include "impscommonenums.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 const TImpsContent KTransContentElements[] = |
|
34 { EImpsKeySession, |
|
35 EImpsKeyTransaction, |
|
36 EImpsKeyTransactionContent |
|
37 }; |
|
38 |
|
39 const TImpsContent KNewMessageElements[] = |
|
40 { EImpsKeySession, |
|
41 EImpsKeyTransaction, |
|
42 EImpsKeyTransactionContent, |
|
43 EImpsKeyNewMessage |
|
44 }; |
|
45 |
|
46 const TImpsContent KSendMessageElements[] = |
|
47 { EImpsKeySession, |
|
48 EImpsKeyTransaction, |
|
49 EImpsKeyTransactionContent, |
|
50 EImpsKeySendMessage_Request |
|
51 }; |
|
52 |
|
53 //Client capability request |
|
54 const TImpsContent KClientCapabilityReqElements[] = |
|
55 { EImpsKeySession, |
|
56 EImpsKeyTransaction, |
|
57 EImpsKeyTransactionContent, |
|
58 EImpsKeyClientCapability_Request |
|
59 }; |
|
60 |
|
61 const TImpsContent KClientServiceReqElements[] = |
|
62 { EImpsKeySession, |
|
63 EImpsKeyTransaction, |
|
64 EImpsKeyTransactionContent, |
|
65 EImpsKeyService_Request |
|
66 }; |
|
67 |
|
68 const TImpsContent KClientCapabilityResElements[] = |
|
69 { EImpsKeySession, |
|
70 EImpsKeyTransaction, |
|
71 EImpsKeyTransactionContent, |
|
72 EImpsKeyClientCapability_Response |
|
73 }; |
|
74 |
|
75 const TImpsContent KClientServiceResElements[] = |
|
76 { EImpsKeySession, |
|
77 EImpsKeyTransaction, |
|
78 EImpsKeyTransactionContent, |
|
79 EImpsKeyService_Response |
|
80 }; |
|
81 |
|
82 const TImpsContent KTransModeElements[] = |
|
83 { EImpsKeySession, |
|
84 EImpsKeyTransaction, |
|
85 EImpsKeyTransactionDescriptor, |
|
86 EImpsKeyTransactionMode |
|
87 }; |
|
88 |
|
89 const TImpsContent KKeepAliveReq[] = |
|
90 { EImpsKeySession, |
|
91 EImpsKeyTransaction, |
|
92 EImpsKeyTransactionContent, |
|
93 EImpsKeyKeepAlive_Request |
|
94 }; |
|
95 |
|
96 const TImpsContent KGet12PollElements[] = |
|
97 { EImpsKeySession, |
|
98 EImpsKeyPoll |
|
99 }; |
|
100 |
|
101 const TImpsContent KGetPollElements[] = |
|
102 { EImpsKeySession, |
|
103 EImpsKeyTransaction, |
|
104 EImpsKeyTransactionDescriptor, |
|
105 EImpsKeyPoll |
|
106 }; |
|
107 |
|
108 const TImpsContent KSetResultCodeElements[] = |
|
109 { EImpsKeySession, |
|
110 EImpsKeyTransaction, |
|
111 EImpsKeyTransactionContent, |
|
112 EImpsKeyStatus, |
|
113 EImpsKeyResult, |
|
114 EImpsKeyCode |
|
115 }; |
|
116 |
|
117 const TImpsContent KGetCIRElements[] = |
|
118 { EImpsKeySession, |
|
119 EImpsKeyCIR |
|
120 }; |
|
121 |
|
122 // FORWARD DECLARATIONS |
|
123 class MImpsKey; |
|
124 class TImpsDataUtils; |
|
125 |
|
126 |
|
127 // CLASS DECLARATION |
|
128 |
|
129 /** |
|
130 * A set of static methods that get certain data elements from data accessor. |
|
131 */ |
|
132 class TImpsDataUtils |
|
133 { |
|
134 public: // Constructors and destructor |
|
135 |
|
136 /** |
|
137 * C++ default constructor. |
|
138 */ |
|
139 IMPORT_C TImpsDataUtils(); |
|
140 |
|
141 |
|
142 public: // New functions |
|
143 |
|
144 /** |
|
145 * Add multiple key elements at once |
|
146 */ |
|
147 IMPORT_C static void AddValuesFromArrayL( |
|
148 MImpsKey* aImpsKey, |
|
149 const TImpsContent* aElementArray, |
|
150 TInt aSize ); |
|
151 |
|
152 |
|
153 /** |
|
154 * Get sender from internal data (C-S) |
|
155 * @param aPredecessor, element array, |
|
156 * parent node of particular Recipient element |
|
157 * @param aAc data accessor |
|
158 * @param aSender UserID or SName output, |
|
159 * Sender(User(UserID) or ScreenName if a GroupID |
|
160 * @param aGroup GroupID output, |
|
161 * Sender(ScreenName(SName, GroupID)) |
|
162 * @param aUsers UserIDs output |
|
163 */ |
|
164 IMPORT_C static void GetSenderL( |
|
165 MImpsKey* aPredecessor, |
|
166 MImpsDataAccessor* aAc, |
|
167 TPtrC& aSender, |
|
168 TPtrC& aGroup ); |
|
169 |
|
170 /** |
|
171 * Set recipients data (C-S) |
|
172 * @param aPredecessor key element path so far |
|
173 * @param aAc message data |
|
174 * @param @aSender UserID or SName |
|
175 * @param aGroupId ScreenName( GroupdID) |
|
176 */ |
|
177 IMPORT_C static void SetSenderL( |
|
178 MImpsKey* aPredecessor, |
|
179 MImpsDataAccessor* aAc, |
|
180 const TDesC* aSender, |
|
181 const TDesC* aGroupId ); |
|
182 |
|
183 |
|
184 /** |
|
185 * Set ContentData (C-S) |
|
186 * @param aKey, key that will be initialized! |
|
187 * @param aAc data accessor |
|
188 * @param ContentData, |
|
189 * notice: converted to UTF-8 in Message Interpreter in this rel. |
|
190 */ |
|
191 IMPORT_C static void SetContentDataL( |
|
192 MImpsKey* aKey, |
|
193 MImpsDataAccessor* aAc, |
|
194 const TDesC& aContent |
|
195 ); |
|
196 |
|
197 /** |
|
198 * Get ContentData (C-S) |
|
199 * @param aKey, key that will be initialized! |
|
200 * @param aAc data accessor |
|
201 * @param ContentData, |
|
202 * notice: converted to UTF-8 in Message Interpreter in this rel. |
|
203 */ |
|
204 IMPORT_C static void GetContentDataL( |
|
205 MImpsKey* aKey, |
|
206 MImpsDataAccessor* aAc, |
|
207 TPtrC& aContent |
|
208 ); |
|
209 |
|
210 /** |
|
211 * Set Result code value |
|
212 * @param aKey, key that will be initialized! |
|
213 * @param aAc data accessor |
|
214 * @param aCode result code to set |
|
215 */ |
|
216 IMPORT_C static void SetResultStatusL( |
|
217 MImpsKey* aKey, |
|
218 MImpsDataAccessor* aAc, |
|
219 TInt aCode ); |
|
220 |
|
221 /** |
|
222 * Get Result code value (C-S) |
|
223 * @param aKey, key that will be initialized! |
|
224 * @param aAc data accessor |
|
225 * @param aCode result code back |
|
226 * @return ETrue if found, else EFalse |
|
227 */ |
|
228 IMPORT_C static TBool GetResultStatusL( |
|
229 MImpsKey* aKey, |
|
230 MImpsDataAccessor* aAc, |
|
231 TInt& aCode ); |
|
232 |
|
233 /** |
|
234 * Get NewMessage::MessageInfo:MessageId (C-S) |
|
235 * @param aKey, key that will be initialized! |
|
236 * @param aAc data accessor |
|
237 * @param aID MessageID |
|
238 * @return ETrue if found, else EFalse |
|
239 */ |
|
240 IMPORT_C static TBool GetNewMessageIdL( |
|
241 MImpsKey* aKey, |
|
242 MImpsDataAccessor* aAc, |
|
243 TPtrC& aId ); |
|
244 |
|
245 /** |
|
246 * CreateClientIdL (I) |
|
247 * @param aKey, key to the ClientID. |
|
248 * ClientID is inserted, |
|
249 * The Key is in the original state after this function |
|
250 * @param aAc data accessor |
|
251 * @param aClientId ClientID |
|
252 */ |
|
253 IMPORT_C static void CreateClientIdL( |
|
254 MImpsKey* aKey, |
|
255 MImpsDataAccessor* aAc, |
|
256 const TDesC& aClientId ); |
|
257 |
|
258 /** |
|
259 * GetMessageTypeL (C-S) |
|
260 * @param aAc data accessor |
|
261 * @return messagetype integer |
|
262 */ |
|
263 IMPORT_C static TInt GetMessageTypeL( MImpsDataAccessor* aAc ); |
|
264 |
|
265 /** |
|
266 * GetTransactionIDL (S-I) |
|
267 * @param aAc data accessor |
|
268 * @param aID, KNullDesc if not found, TransactionID otherwise |
|
269 */ |
|
270 IMPORT_C static void GetTransactionIDL( MImpsDataAccessor* aAc, |
|
271 TPtrC& aID ); |
|
272 |
|
273 /** |
|
274 * SetTransactionIDL (I) |
|
275 * @param aAc data accessor |
|
276 * @param aID |
|
277 */ |
|
278 IMPORT_C static void SetTransactionIDL( MImpsDataAccessor* aAc, |
|
279 const TDesC& aID ); |
|
280 |
|
281 /** |
|
282 * GetSessionIDL (I) |
|
283 * @param aAc data accessor |
|
284 * @param aID, KNullDesc if not found, SessionID otherwise |
|
285 */ |
|
286 IMPORT_C static void GetSessionIDL( MImpsDataAccessor* aAc, |
|
287 TPtrC& aID ); |
|
288 |
|
289 /** |
|
290 * SetSessionIDL (S-I) |
|
291 * @param aAc data accessor |
|
292 * @param aID |
|
293 */ |
|
294 IMPORT_C static void SetSessionIDL( MImpsDataAccessor* aAc, |
|
295 const TDesC& aID ); |
|
296 |
|
297 /** |
|
298 * GetSessionTypeL (I) |
|
299 * @param aAc data accessor |
|
300 * @param aType, EImpsUndefSes if not found, type otherwise |
|
301 */ |
|
302 IMPORT_C static void GetSessionTypeL( |
|
303 MImpsDataAccessor* aAc, |
|
304 TImpsSessionType& aType ); |
|
305 |
|
306 /** |
|
307 * SetSessionTypeL (S-I) |
|
308 * @param aAc data accessor |
|
309 * @param aType session type |
|
310 */ |
|
311 IMPORT_C static void SetSessionTypeL( |
|
312 MImpsDataAccessor* aAc, const TImpsSessionType aType ); |
|
313 |
|
314 /** |
|
315 * GetPollL |
|
316 * @param aKey, empty in the beginning! |
|
317 * @param aAc data accessor |
|
318 * @param TBool, ETrue if poll is on, EFalse if off |
|
319 * @return ETrue if found, else EFalse |
|
320 */ |
|
321 IMPORT_C static TBool GetPollL( MImpsKey* aKey, |
|
322 MImpsDataAccessor* aAc, |
|
323 TBool& aBool ); |
|
324 |
|
325 /** |
|
326 * Copy specific part of the message to the current message |
|
327 * @param aSource where to copy data elements |
|
328 * @param aDestination |
|
329 */ |
|
330 IMPORT_C static void CopyNewUsersL( MImpsDataAccessor& aSource, |
|
331 MImpsDataAccessor& aDestination ); |
|
332 |
|
333 /** |
|
334 * Copy specific part of the message to the current message |
|
335 * @param aSource where to copy data elements |
|
336 * @param aDestination |
|
337 */ |
|
338 IMPORT_C static void CopyLeftUsersL( MImpsDataAccessor& aSource, |
|
339 MImpsDataAccessor& aDestination ); |
|
340 |
|
341 /** |
|
342 * Copy specific part of the message to the current message |
|
343 * @param aSource where to copy data elements |
|
344 * @param aDestination |
|
345 */ |
|
346 IMPORT_C static void CopyGroupPropertiesL( MImpsDataAccessor& aSource, |
|
347 MImpsDataAccessor& aDestination ); |
|
348 |
|
349 /** |
|
350 * Copy specific part of the message to the current message |
|
351 * @param aSource where to copy data elements |
|
352 * @param aDestination |
|
353 */ |
|
354 IMPORT_C static void CopyOwnPropertiesL( MImpsDataAccessor& aSource, |
|
355 MImpsDataAccessor& aDestination ); |
|
356 |
|
357 /** |
|
358 * Get value from central repository |
|
359 * Leaves, if the repository or the id not found |
|
360 * @param aRepositoryUid uid of the repository |
|
361 * @param aId id of the wanted key |
|
362 * @return value of the wanted key |
|
363 */ |
|
364 IMPORT_C static TInt GetCenRepIntValueL( TUid aRepositoryUid, |
|
365 TUint32 aId ); |
|
366 |
|
367 /** |
|
368 * Get value from central repository |
|
369 * Leaves, if the repository or the id not found |
|
370 * @param aRepositoryUid uid of the repository |
|
371 * @param aId id of the wanted key |
|
372 * @return value of the wanted key |
|
373 */ |
|
374 IMPORT_C static TReal GetCenRepRealValueL( TUid aRepositoryUid, |
|
375 TUint32 aId ); |
|
376 |
|
377 |
|
378 /** |
|
379 * Set ContentData (C-S) |
|
380 * @param aKey, key that will be initialized! |
|
381 * @param aAc data accessor |
|
382 * @param ContentData |
|
383 */ |
|
384 IMPORT_C static void SetBinaryContentDataL( |
|
385 MImpsKey* aKey, |
|
386 MImpsDataAccessor* aAc, |
|
387 const TDesC8& aContent |
|
388 ); |
|
389 |
|
390 /** |
|
391 * Get ContentType from NewMessage(C-S) |
|
392 * @param aAc data accessor |
|
393 * @param ContentType |
|
394 */ |
|
395 |
|
396 IMPORT_C static void GetContentTypeL( |
|
397 MImpsDataAccessor* aAc, |
|
398 TPtrC& aContentType ); |
|
399 |
|
400 /** |
|
401 * Get ContentData datatype |
|
402 * @param aAc data accessor |
|
403 * @param aIndex index of the transaction |
|
404 * @return data type of ContentData |
|
405 */ |
|
406 |
|
407 IMPORT_C static TImpsDataType GetContentDataTypeL( |
|
408 MImpsDataAccessor* aAc, TInt aIndex ); |
|
409 |
|
410 |
|
411 private: |
|
412 |
|
413 |
|
414 }; |
|
415 |
|
416 #endif |
|
417 |
|
418 // End of File |