1 /* |
|
2 * Copyright (c) 2006 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: IETF SIMPLE Protocol implementation for XIMP Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_PRESENCEPLUGINDATA_H |
|
20 #define C_PRESENCEPLUGINDATA_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <presenceinfo.h> |
|
25 #include <mpresencebuddyinfo2.h> |
|
26 |
|
27 #include "mpresencepluginconnectionobs.h" |
|
28 #include "presencelogger.h" |
|
29 |
|
30 class MXIMPObjectFactory; |
|
31 class MPresenceObjectFactory; |
|
32 class MSimpleDocument; |
|
33 class MPresenceInfo; |
|
34 class MSimplePresenceList; |
|
35 class MPresenceInfoFieldCollection; |
|
36 class MXIMPObjectCollection; |
|
37 class MPersonPresenceInfo; |
|
38 class MPresenceInfoField; |
|
39 class MSimpleElement; |
|
40 class MPresenceCacheWriter2; |
|
41 |
|
42 /** |
|
43 * CPresencePluginData |
|
44 * |
|
45 * @lib presenceplugin.dll |
|
46 * @since S60 v3.2 |
|
47 */ |
|
48 NONSHARABLE_CLASS( CPresencePluginData ): public CBase |
|
49 { |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * |
|
55 * @param none |
|
56 * @param none |
|
57 */ |
|
58 static CPresencePluginData* NewL( |
|
59 MPresencePluginConnectionObs& aObs, |
|
60 TInt aServiceId ); |
|
61 |
|
62 /** |
|
63 * Two-phased constructor. |
|
64 * |
|
65 * @param none |
|
66 * @param none |
|
67 */ |
|
68 static CPresencePluginData* NewLC( |
|
69 MPresencePluginConnectionObs& aObs, |
|
70 TInt aServiceId ); |
|
71 |
|
72 /** |
|
73 * Standard C++ destructor |
|
74 */ |
|
75 virtual ~CPresencePluginData(); |
|
76 |
|
77 /** |
|
78 * Convert to engine notification to MXIMPPresenceInfo |
|
79 * |
|
80 * @since S60 5.0 |
|
81 * @param aPresenceFactory object factory |
|
82 * @param aPrInfo ximp info structure [out] |
|
83 * @param aUnicodeNoteContent note field content [out] |
|
84 */ |
|
85 void NotifyToBlockedToXIMPL( |
|
86 MPresenceObjectFactory& aPresenceFactory, |
|
87 MPresenceInfo& aPrInfo, |
|
88 const TDesC& aUnicodeNoteContent = KNullDesC ); |
|
89 |
|
90 /** |
|
91 * Convert to engine notification to MXIMPPresenceInfo |
|
92 * |
|
93 * @since S60 3.2 |
|
94 * @param aFactory ximp Factory |
|
95 * @param aPrInfo ximp info structure [out] |
|
96 * @param aUnicodeNoteContent note field content [out] |
|
97 */ |
|
98 void NotifyToPendingToXIMPL( |
|
99 MPresenceObjectFactory& aPresenceFactory, |
|
100 MPresenceInfo& aPrInfo, |
|
101 const TDesC& aUnicodeNoteContent = KNullDesC ); |
|
102 |
|
103 /** |
|
104 * Convert to engine notification to MXIMPPresenceInfo |
|
105 * |
|
106 * @since S60 3.2 |
|
107 * @param aFactory ximp Factory |
|
108 * @param aPrInfo ximp info structure [out] |
|
109 * @param aUnicodeNoteContent note field content [out] |
|
110 */ |
|
111 void NotifyTerminatedToXIMPL( |
|
112 MPresenceObjectFactory& aPresenceFactory, |
|
113 MPresenceInfo& aPrInfo, |
|
114 const TDesC& aUnicodeNoteContent = KNullDesC ); |
|
115 |
|
116 /** |
|
117 * Convert to engine notification to MXIMPPresenceInfo |
|
118 * |
|
119 * @since S60 3.2 |
|
120 * @param aFactory ximp Factory |
|
121 * @param aPrInfo ximp info structure [out] |
|
122 * @param aUnicodeNoteContent note field content [out] |
|
123 * @param aAvailability availability value for cache entry [out] |
|
124 */ |
|
125 void NotifyToActiveToXIMPL( |
|
126 MPresenceObjectFactory& aPresenceFactory, |
|
127 MPresenceInfo& aPrInfo, |
|
128 const TDesC& aUnicodeNoteContent = KNullDesC, |
|
129 NPresenceInfo::TAvailabilityValues aAvailability = |
|
130 NPresenceInfo::EAvailable ); |
|
131 |
|
132 /** |
|
133 * Convert to engine notification to MximpPresenceInfo |
|
134 * |
|
135 * @since S60 3.2 |
|
136 * @param aFactory ximp Factory |
|
137 * @param aDocument notification |
|
138 * @param aPrInfo ximp info structure [out] |
|
139 */ |
|
140 void NotifyToPrInfoL( |
|
141 MXIMPObjectFactory& aFactory, |
|
142 MPresenceObjectFactory& aPresenceFactory, |
|
143 MSimpleDocument& aDocument, |
|
144 MPresenceInfo& aPrInfo ); |
|
145 |
|
146 /** |
|
147 * Extracts cache data entries from presence info object. |
|
148 * |
|
149 * @since S60 5.0 |
|
150 * @param aPrInfo ximp info structure |
|
151 * @param aAvailability will store cache availability |
|
152 * @param aExtendedAvailability will store extended availability |
|
153 * @param aStatusMessage will store custom status message |
|
154 */ |
|
155 void CacheEntriesFromPrInfo( |
|
156 MPresenceInfo& aPrInfo, |
|
157 MPresenceBuddyInfo2::TAvailabilityValues& aAvailability, |
|
158 TPtr& aExtendedAvailability, |
|
159 TPtr& aStatusMessage ); |
|
160 |
|
161 /** |
|
162 * Convert to engine list notification to MximpPresenceInfo elements |
|
163 * |
|
164 * @since S60 3.2 |
|
165 * @param aFactory ximp Factory |
|
166 * @param aList notification |
|
167 * @param aEntities array of ximp info structure [out] |
|
168 * @param aTerminated array of ximp info structure for |
|
169 * terminated entities [out] |
|
170 */ |
|
171 void NotifyListToPrInfoL( |
|
172 MXIMPObjectFactory& aFactory, |
|
173 MPresenceObjectFactory& aPresenceFactory, |
|
174 MSimplePresenceList& aList, |
|
175 RPointerArray<MPresenceInfo>& aEntities, |
|
176 RPointerArray<MXIMPIdentity>& aActives, |
|
177 RPointerArray<MXIMPIdentity>& aTerminated ); |
|
178 |
|
179 /** |
|
180 * AddPrPersToSimpleDocumentL |
|
181 * |
|
182 * @since S60 3.2 |
|
183 * Add subscribed or blocked person to document |
|
184 * @param aInfo, presence info |
|
185 * @param aDocument, xml document |
|
186 * @param aSipId, sip identity |
|
187 * @param aTupleId, client tupleId |
|
188 */ |
|
189 void AddPrPersToSimpleDocumentL( |
|
190 const MPersonPresenceInfo* aInfo, |
|
191 MSimpleDocument& aDocument, |
|
192 const TDesC8& aSipId, |
|
193 TInt aTupleId ); |
|
194 |
|
195 /** |
|
196 * Creates document. |
|
197 * |
|
198 * @since S60 3.2 |
|
199 * @param aDocument XDM document |
|
200 * @param aSipId SIP profile id |
|
201 * @param aStatusField, status enum field |
|
202 * @param aMessageField, message field |
|
203 */ |
|
204 void DoCreateDocumentL( |
|
205 MSimpleDocument& aDocument, |
|
206 const TDesC8& aSipId, |
|
207 const MPresenceInfoField* aStatusField, |
|
208 const MPresenceInfoField* aMessageField ); |
|
209 |
|
210 /** |
|
211 * DoCheckBasicStatusValueL |
|
212 * |
|
213 * @since S60 3.2 |
|
214 * @param aField |
|
215 * @return TPtrC basic status value |
|
216 */ |
|
217 TPtrC DoCheckBasicStatusValueL( |
|
218 const MPresenceInfoField& aField ); |
|
219 |
|
220 /** |
|
221 * DoCheckActivitiesValueL |
|
222 * |
|
223 * @since S60 3.2 |
|
224 * @param aField |
|
225 * @return TPtrC activities value |
|
226 */ |
|
227 TPtrC8 DoCheckActivitiesValueL( |
|
228 const MPresenceInfoField& aField ); |
|
229 |
|
230 /** |
|
231 * DoCheckNoteValueL |
|
232 * |
|
233 * @since S60 3.2 |
|
234 * @param aField |
|
235 * @return TPtrC activities value |
|
236 */ |
|
237 TPtrC DoCheckNoteValueL( |
|
238 const MPresenceInfoField& aField ); |
|
239 |
|
240 /** |
|
241 * CreatePresenceUri8LC |
|
242 * |
|
243 * @since S60 3.2 |
|
244 * @param aPresentityUri |
|
245 * @return presence URI |
|
246 */ |
|
247 HBufC8* CreatePresenceUri8LC( |
|
248 const TDesC8& aPresentityUri ); |
|
249 |
|
250 /** |
|
251 * GenerateTupleId() |
|
252 * Generate Tuple id for status document |
|
253 * |
|
254 * @since S60 3.2 |
|
255 * @param none |
|
256 * @return TInt, tupleid |
|
257 */ |
|
258 TInt GenerateTupleId(); |
|
259 |
|
260 |
|
261 /** |
|
262 * Removes prefix from uri. |
|
263 * |
|
264 * @since S60 3.2 |
|
265 * @param aPresentityUri, presentity url |
|
266 * @return HBufC16, URL without prefix |
|
267 */ |
|
268 HBufC16* RemovePrefixLC( |
|
269 const TDesC& aPresentityUri ); |
|
270 |
|
271 /** |
|
272 * Returns service id. |
|
273 * |
|
274 * @since S60 5.0 |
|
275 * @return TInt, service id related to this data instance |
|
276 */ |
|
277 TInt ServiceId(); |
|
278 |
|
279 /** |
|
280 * Writes status to presence cache |
|
281 * |
|
282 * @since S60 5.0 |
|
283 * @param aPresentityId, identity of status |
|
284 * @param aAvailability, availability value to set |
|
285 * @param aAvailabilityText, text for extended states |
|
286 * @param aStatusMessage, status message from remote party |
|
287 * @return None |
|
288 */ |
|
289 void WriteStatusToCacheL( |
|
290 const TDesC& aPresentityId, |
|
291 MPresenceBuddyInfo2::TAvailabilityValues aAvailability, |
|
292 const TDesC& aAvailabilityText, |
|
293 const TDesC& aStatusMessage ); |
|
294 |
|
295 /** |
|
296 * Removes cache entries for this service. |
|
297 * |
|
298 * @since S60 5.0 |
|
299 * @return None |
|
300 */ |
|
301 void RemoveCacheL(); |
|
302 |
|
303 /** |
|
304 * Removes cache entries for certain person. |
|
305 * |
|
306 * @since S60 5.0 |
|
307 * @param aIdentity, identity of presence entry |
|
308 * @return None |
|
309 */ |
|
310 void DeletePresenceL( const TDesC& aIdentity ); |
|
311 |
|
312 /** |
|
313 * Stores own presence values to permanent storage. |
|
314 * |
|
315 * @since S60 5.0 |
|
316 * @param aServiceId, service id |
|
317 * @param aAvailability, availability enumeration |
|
318 * @param aStatusMessage, custom status message |
|
319 * @return None |
|
320 */ |
|
321 void StorePresenceOwnPresenceL( |
|
322 const TUint aServiceId, |
|
323 NPresenceInfo::TAvailabilityValues aAvailability, |
|
324 const TDesC& aStatusMessage ); |
|
325 |
|
326 /** |
|
327 * Stores own presence document id to permanent storage. |
|
328 * |
|
329 * @since S60 5.0 |
|
330 * @param aServiceId, service id |
|
331 * @param aAvailability, availability enumeration |
|
332 * @param aDocumentId, document id |
|
333 * @return None |
|
334 */ |
|
335 void StoreDocumentIdL( |
|
336 const TUint aServiceId, |
|
337 const TDesC8& aDocumentId ); |
|
338 |
|
339 /** |
|
340 * Reads document id from permanent storage. |
|
341 * |
|
342 * @since S60 5.0 |
|
343 * @param aServiceId, service id |
|
344 * @param aDocumentId, document id |
|
345 * @return None |
|
346 */ |
|
347 void ReadDocumentIdL( |
|
348 const TInt aServiceId, |
|
349 TDes8& aDocumentId ); |
|
350 |
|
351 /** |
|
352 * Deletes permanent data from storage |
|
353 * |
|
354 * @since S60 5.0 |
|
355 * @param aServiceId, service id |
|
356 * @return None |
|
357 */ |
|
358 void DeletePresenceVariablesL( const TInt aServiceId ); |
|
359 |
|
360 private: |
|
361 |
|
362 /** |
|
363 * Standard C++ constructor |
|
364 */ |
|
365 CPresencePluginData( |
|
366 MPresencePluginConnectionObs& aObs, |
|
367 TInt aServiceId ); |
|
368 |
|
369 /** |
|
370 * Standard C++ constructor |
|
371 */ |
|
372 void ConstructL(); |
|
373 |
|
374 /** |
|
375 * UserNoteToXIMPL |
|
376 * |
|
377 * @since S60 3.2 |
|
378 * This method not yet used |
|
379 * @param aPresenceFactory ximp Factory |
|
380 * @param aElement Simple elemnt |
|
381 * @param aCollection Field Collection |
|
382 */ |
|
383 void UserNoteToXIMPL( |
|
384 MPresenceObjectFactory& aPresenceFactory, |
|
385 MSimpleElement* aElement, |
|
386 MPresenceInfoFieldCollection& aCollection ); |
|
387 |
|
388 /** |
|
389 * SingleUserStatusToXIMPL |
|
390 * |
|
391 * @since S60 3.2 |
|
392 * @param aPresenceFactory ximp Factory |
|
393 * @param aElement Simple element |
|
394 * @param aActivitiesElement Simple element |
|
395 * @param aNoteElement Simple element for note elems (can be null) |
|
396 * @param aCollection Field Collection |
|
397 */ |
|
398 void SingleUserStatusToXIMPL( |
|
399 MPresenceObjectFactory& aPresenceFactory, |
|
400 MSimpleElement* aBasicElement, |
|
401 MSimpleElement* aActivitiesElement, |
|
402 MSimpleElement* aNoteElement, |
|
403 MPresenceInfoFieldCollection& aCollection ); |
|
404 |
|
405 private: // data |
|
406 |
|
407 /** |
|
408 * Generated tuple/person id |
|
409 * Own. |
|
410 */ |
|
411 TInt iNumBuf; |
|
412 |
|
413 /** |
|
414 * ximp Plugin connection observer |
|
415 * Not Own. |
|
416 */ |
|
417 MPresencePluginConnectionObs& iConnObs; |
|
418 |
|
419 /** |
|
420 * Stores service id. |
|
421 */ |
|
422 TInt iServiceId; |
|
423 |
|
424 /** |
|
425 * Writes service status to presence cache. |
|
426 * Own. |
|
427 */ |
|
428 MPresenceCacheWriter2* iPresenceCacheWriter; |
|
429 |
|
430 SIMPLE_UNIT_TEST( T_CPresencePluginData ) |
|
431 }; |
|
432 |
|
433 #endif //C_PRESENCEPLUGINDATA_H |
|