1 /* |
|
2 * Copyright (c) 2006-2010 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 #include <e32std.h> |
|
20 #include <ximpdatasubscriptionstate.h> |
|
21 #include <protocolpresentitygroupsdatahost.h> |
|
22 #include <protocolpresencedatahost.h> |
|
23 #include <ximpobjectfactory.h> |
|
24 #include <presenceobjectfactory.h> |
|
25 #include <ximpstatus.h> |
|
26 #include <ximpidentity.h> |
|
27 #include <ximpobjectcollection.h> |
|
28 #include <xdmerrors.h> |
|
29 #include <presentitygroupinfo.h> |
|
30 #include <presentitygroupmemberinfo.h> |
|
31 #include <utf.h> |
|
32 #include <avabilitytext.h> |
|
33 |
|
34 #include "mpresencepluginconnectionobs.h" |
|
35 #include "presenceplugingroup.h" |
|
36 #include "presencepluginxdmutils.h" |
|
37 #include "presenceplugincommon.h" |
|
38 #include "presencepluginvirtualgroup.h" |
|
39 #include "presenceplugindata.h" |
|
40 #include "presencepluginwatcher.h" |
|
41 #include "presencepluginauthorization.h" |
|
42 |
|
43 // ======== MEMBER FUNCTIONS ======== |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CPresencePluginGroups::CPresencePluginGroups |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CPresencePluginGroups::CPresencePluginGroups( |
|
50 MPresencePluginConnectionObs& aObs, |
|
51 CPresencePluginVirtualGroup* aSubscribedBuddies, |
|
52 CPresencePluginData* aPresenceData ): |
|
53 CActive( CActive::EPriorityStandard ), |
|
54 iConnObs(aObs), |
|
55 iOperation( ENoOperation), |
|
56 iState( EPluginIdle ), iCompleted( ETrue ), |
|
57 iSubscribedBuddies( aSubscribedBuddies ), |
|
58 iPresenceData( aPresenceData ) |
|
59 { |
|
60 CActiveScheduler::Add( this ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CPresencePluginGroups::NewL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CPresencePluginGroups* CPresencePluginGroups::NewL( |
|
68 MPresencePluginConnectionObs& aObs, |
|
69 CPresencePluginVirtualGroup* aSubscribedBuddies, |
|
70 CPresencePluginData* aPresenceData ) |
|
71 { |
|
72 CPresencePluginGroups* self = |
|
73 CPresencePluginGroups::NewLC( |
|
74 aObs, |
|
75 aSubscribedBuddies, |
|
76 aPresenceData ); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CPresencePluginGroups::NewLC |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CPresencePluginGroups* CPresencePluginGroups::NewLC( |
|
86 MPresencePluginConnectionObs& aObs, |
|
87 CPresencePluginVirtualGroup* aSubscribedBuddies, |
|
88 CPresencePluginData* aPresenceData ) |
|
89 { |
|
90 CPresencePluginGroups* self = |
|
91 new( ELeave ) CPresencePluginGroups( |
|
92 aObs, |
|
93 aSubscribedBuddies, |
|
94 aPresenceData ); |
|
95 CleanupStack::PushL( self ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CPresencePluginGroups::~CPresencePluginGroups |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CPresencePluginGroups::~CPresencePluginGroups() |
|
104 { |
|
105 DP_SDA("CPresencePluginGroups::~CPresencePluginGroups"); |
|
106 Cancel(); |
|
107 delete iPresIdentity; |
|
108 delete iDisplayName; |
|
109 DP_SDA("CPresencePluginGroups::~CPresencePluginGroups end"); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CPresencePluginGroups::DoSubscribePresentityGroupListL |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CPresencePluginGroups::DoSubscribePresentityGroupListL( |
|
117 TXIMPRequestId aReqId ) |
|
118 { |
|
119 DP_SDA("CPresencePluginGroups::DoSubscribePresentityGroupListL"); |
|
120 iCompleted = EFalse; |
|
121 // List of lists under buddylist |
|
122 StartXdmOperationL( aReqId, EGetListOfLists ); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CPresencePluginGroups::DoUnsubscribePresentityGroupListL |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CPresencePluginGroups::DoUnsubscribePresentityGroupListL( |
|
130 TXIMPRequestId /*aReqId*/ ) |
|
131 { |
|
132 User::Leave( KErrNotSupported ); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CPresencePluginGroups::DoCreatePresentityGroupL |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CPresencePluginGroups::DoCreatePresentityGroupL( |
|
140 const MXIMPIdentity& /*aGroupId*/, |
|
141 const TDesC16& /*aDisplayName*/, |
|
142 TXIMPRequestId /*aReqId*/ ) |
|
143 { |
|
144 User::Leave( KErrNotSupported ); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CPresencePluginGroups::DoDeletePresentityGroupL |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CPresencePluginGroups::DoDeletePresentityGroupL( |
|
152 const MXIMPIdentity& /*aGroupId*/, |
|
153 TXIMPRequestId /*aReqId*/ ) |
|
154 { |
|
155 User::Leave( KErrNotSupported ); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CPresencePluginGroups::DoUpdatePresentityGroupDisplayNameL |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 void CPresencePluginGroups::DoUpdatePresentityGroupDisplayNameL( |
|
163 const MXIMPIdentity& /*aGroupId*/, |
|
164 const TDesC16& /*aDisplayName*/, |
|
165 TXIMPRequestId /*aReqId*/ ) |
|
166 { |
|
167 // Notice: later |
|
168 User::Leave( KErrNotSupported ); |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CPresencePluginGroups::DoSubscribePresentityGroupContentL |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CPresencePluginGroups::DoSubscribePresentityGroupContentL( |
|
176 const MXIMPIdentity& aGroupId, |
|
177 TXIMPRequestId aReqId ) |
|
178 { |
|
179 DP_SDA("CPresencePluginGroups::DoSubscribePresentityGroupContentL"); |
|
180 iCompleted = EFalse; |
|
181 // List of lists under buddylist |
|
182 StartXdmOperationL( aGroupId, aReqId, EGetListContent ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CPresencePluginGroups::DoUnsubscribePresentityGroupContentL |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CPresencePluginGroups::DoUnsubscribePresentityGroupContentL( |
|
190 const MXIMPIdentity& /*aGroupId*/, |
|
191 TXIMPRequestId aReqId ) |
|
192 { |
|
193 DP_SDA("CPresencePluginGroups::DoUnsubscribePresentityGroupContentL"); |
|
194 |
|
195 iXIMPId = aReqId; |
|
196 iConnObs.WatcherHandlerL()->UnSubscribeAllL(); |
|
197 iCompleted = EFalse; |
|
198 CompleteXIMPReq( KErrNone ); |
|
199 DP_SDA("CPresencePluginGroups::DoUnsubscribePresentityGroupContentL out"); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CPresencePluginGroups::DoAddPresentityGroupMemberL |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 void CPresencePluginGroups::DoAddPresentityGroupMemberL( |
|
207 const MXIMPIdentity& aGroupId, |
|
208 const MXIMPIdentity& aMemberId, |
|
209 const TDesC16& /*aMemberDisplayName*/, |
|
210 TXIMPRequestId aReqId ) |
|
211 { |
|
212 DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL"); |
|
213 __ASSERT_ALWAYS( !IsActive(), User::Leave( KErrNotReady ) ); |
|
214 |
|
215 SetPresIdentityL( aMemberId, ETrue ); |
|
216 |
|
217 iCompleted = EFalse; |
|
218 iXIMPId = aReqId; |
|
219 |
|
220 if( !aGroupId.Identity().Compare( KPresenceBuddyList ) ) |
|
221 { |
|
222 DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - buddylist"); |
|
223 iOperation = EAddPresentityGroupMember; |
|
224 |
|
225 // write pending to presence cache |
|
226 TBuf<20> buf; |
|
227 buf.Copy( KPendingRequestExtensionValue ); |
|
228 |
|
229 iPresenceData->WriteStatusToCacheL( aMemberId.Identity(), |
|
230 MPresenceBuddyInfo2::ENotAvailable, |
|
231 buf, |
|
232 KNullDesC() ); |
|
233 |
|
234 iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( |
|
235 aMemberId, iStatus ); |
|
236 SetActive(); |
|
237 } |
|
238 else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) ) |
|
239 { |
|
240 DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - blockedlist"); |
|
241 iOperation = EBlockPresentityGroupMember; |
|
242 iConnObs.InternalPresenceAuthorization(). |
|
243 DoPerformBlockPresenceForPresentityL( aMemberId, iStatus ); |
|
244 SetActive(); |
|
245 } |
|
246 else |
|
247 { |
|
248 DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - unknown, leave"); |
|
249 User::Leave( KErrNotSupported ); |
|
250 } |
|
251 |
|
252 DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL out"); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // CPresencePluginGroups::DoRemovePresentityGroupMemberL |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CPresencePluginGroups::DoRemovePresentityGroupMemberL( |
|
260 const MXIMPIdentity& aGroupId, |
|
261 const MXIMPIdentity& aMemberId, |
|
262 TXIMPRequestId aReqId ) |
|
263 { |
|
264 DP_SDA("CPresencePluginGroups::DoRemovePresentityGroupMemberL"); |
|
265 __ASSERT_ALWAYS( !IsActive(), User::Leave( KErrNotReady ) ); |
|
266 |
|
267 SetPresIdentityL( aMemberId, ETrue ); |
|
268 |
|
269 iCompleted = EFalse; |
|
270 iXIMPId = aReqId; |
|
271 iOperation = ERemovePresentityGroupMember; |
|
272 |
|
273 if( !aGroupId.Identity().Compare( KPresenceBuddyList ) ) |
|
274 { |
|
275 DP_SDA(" DoRemovePresentityGroupMemberL - buddylist"); |
|
276 iConnObs.WatcherHandlerL()->DoPerformUnsubscribePresentityPresenceL( |
|
277 aMemberId, iStatus ); |
|
278 SetActive(); |
|
279 } |
|
280 else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) ) |
|
281 { |
|
282 DP_SDA(" DoRemovePresentityGroupMemberL - blockedlist"); |
|
283 iOperation = EUnblockPresentityGroupMember; |
|
284 iConnObs.InternalPresenceAuthorization(). |
|
285 DoPerformCancelPresenceBlockFromPresentityL( aMemberId, iStatus ); |
|
286 SetActive(); |
|
287 } |
|
288 else |
|
289 { |
|
290 DP_SDA("DoRemovePresentityGroupMemberL - unknown, leave"); |
|
291 User::Leave( KErrNotSupported ); |
|
292 } |
|
293 |
|
294 DP_SDA("CPresencePluginGroups::DoRemovePresentityGroupMemberL out"); |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // CPresencePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CPresencePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL( |
|
302 const MXIMPIdentity& /*aGroupId*/, |
|
303 const MXIMPIdentity& /*aMemberId*/, |
|
304 const TDesC16& /*aMemberDisplayName*/, |
|
305 TXIMPRequestId /*aReqId*/ ) |
|
306 { |
|
307 DP_SDA("CPresencePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL"); |
|
308 // Notice: Later |
|
309 User::Leave( KErrNotSupported ); |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // CPresencePluginGroups::DoCancel() |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 void CPresencePluginGroups::DoCancel( ) |
|
317 { |
|
318 if ( iOperation != ENoOperation ) |
|
319 { |
|
320 iXdmUtils->Cancel(); |
|
321 } |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // CPresencePluginGroups::RunL() |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 void CPresencePluginGroups::RunL() |
|
329 { |
|
330 DP_SDA("CPresencePluginGroups::RunL"); |
|
331 TInt myStatus = iStatus.Int(); |
|
332 DP_SDA2("CPresencePluginGroups::RunL myStatus %d", myStatus ); |
|
333 |
|
334 if ( !myStatus && !iCompleted ) |
|
335 { |
|
336 DP_SDA("CPresencePluginGroups::RunL !myStatus"); |
|
337 // OK response |
|
338 CallActualXdmOperationL( myStatus ); |
|
339 } |
|
340 else if ( !myStatus && iCompleted ) |
|
341 { |
|
342 DP_SDA("CPresencePluginGroups::RunL SEND COMPLETE"); |
|
343 CompleteXIMPReq( myStatus ); |
|
344 } |
|
345 else |
|
346 { |
|
347 if ( iOperation == EDeletePresentityGroup && iState == |
|
348 EPluginCommitRls ) |
|
349 { |
|
350 DP_SDA("CPresencePluginGroups::RunL CallActualXdmOperation"); |
|
351 CallActualXdmOperationL( myStatus ); |
|
352 } |
|
353 else |
|
354 { |
|
355 DP_SDA("CPresencePluginGroups::RunL SEND COMPLETE 2"); |
|
356 // Other errors terminated the show |
|
357 CompleteXIMPReq( myStatus ); |
|
358 } |
|
359 } |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // CPresencePluginGroups::CallActualXdmOperationL |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CPresencePluginGroups::CallActualXdmOperationL( TInt aCompleteStatus ) |
|
367 { |
|
368 DP_SDA("CPresencePluginGroups::CallActualXdmOperationL"); |
|
369 |
|
370 DP_SDA2("CallActualXdmOperationL iOperation %d", iOperation); |
|
371 switch ( iOperation ) |
|
372 { |
|
373 case EGetListOfLists: |
|
374 { |
|
375 DP_SDA("PluginGroups::CallActualXdmOperationL EGetListOfLists"); |
|
376 iOperation = EGetListOfLists; |
|
377 GetListOfListsL(); |
|
378 } |
|
379 break; |
|
380 |
|
381 case EGetListContent: |
|
382 { |
|
383 DP_SDA("PluginGroups::CallActualXdmOperationL EGetListContent"); |
|
384 iOperation = EGetListContent; |
|
385 GetListContentL(); |
|
386 } |
|
387 break; |
|
388 |
|
389 case EAddPresentityGroupMember: |
|
390 { |
|
391 DP_SDA(" CallActualXdmOperationL EAddPresentityGroupMember"); |
|
392 |
|
393 iOperation = EGrantPresentityGroupMember; |
|
394 MXIMPIdentity* newIdentity = |
|
395 iConnObs.ObjectFactory().NewIdentityLC(); |
|
396 newIdentity->SetIdentityL( *iPresIdentity ); |
|
397 |
|
398 iConnObs.InternalPresenceAuthorization(). |
|
399 DoPerformGrantPresenceForPresentityL( *newIdentity, iStatus ); |
|
400 CleanupStack::PopAndDestroy(); // >> newIdentity |
|
401 SetActive(); |
|
402 } |
|
403 break; |
|
404 |
|
405 case ERemovePresentityGroupMember: |
|
406 { |
|
407 DP_SDA(" CallActualXdmOperationL ERemovePresentityGroupMember"); |
|
408 iOperation = EWithdrawGrantFromMember; |
|
409 MXIMPIdentity* newIdentity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
410 newIdentity->SetIdentityL( *iPresIdentity ); |
|
411 iConnObs.InternalPresenceAuthorization(). |
|
412 DoPerformWithdrawPresGrantFromPresentityL( |
|
413 *newIdentity, iStatus ); |
|
414 CleanupStack::PopAndDestroy(); // >> newIdentity |
|
415 SetActive(); |
|
416 } |
|
417 break; |
|
418 |
|
419 case EGrantPresentityGroupMember: |
|
420 { |
|
421 DP_SDA(" CallActualXdmOperationL EGrantPresentityGroupMember"); |
|
422 CompleteXIMPReq( aCompleteStatus ); |
|
423 } |
|
424 break; |
|
425 |
|
426 case EWithdrawGrantFromMember: |
|
427 { |
|
428 DP_SDA(" CallActualXdmOperationL EWithdrawGrantFromMember"); |
|
429 if ( !aCompleteStatus ) |
|
430 { |
|
431 DP_SDA(" -> succesfully unblocked, store to cache"); |
|
432 DeletePersonCacheL(); |
|
433 DP_SDA(" -> store info to cache done"); |
|
434 } |
|
435 CompleteXIMPReq( aCompleteStatus ); |
|
436 } |
|
437 break; |
|
438 |
|
439 case EBlockPresentityGroupMember: |
|
440 { |
|
441 DP_SDA(" CallActualXdmOperationL EBlockPresentityGroupMember"); |
|
442 if ( !aCompleteStatus ) |
|
443 { |
|
444 DP_SDA(" -> succesfully blocked, store to cache"); |
|
445 |
|
446 DP_SDA(" -> strip prefix from uri"); |
|
447 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( |
|
448 *iPresIdentity ); |
|
449 DP_SDA(" -> store info to cache"); |
|
450 |
|
451 TBuf<20> buf; |
|
452 buf.Copy( KBlockedExtensionValue ); |
|
453 |
|
454 iPresenceData->WriteStatusToCacheL( *withoutPrefix, |
|
455 MPresenceBuddyInfo2::EUnknownAvailability, |
|
456 buf, |
|
457 KNullDesC() ); |
|
458 |
|
459 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
460 DP_SDA(" -> store info to cache done"); |
|
461 } |
|
462 CompleteXIMPReq( aCompleteStatus ); |
|
463 } |
|
464 break; |
|
465 |
|
466 case EUnblockPresentityGroupMember: |
|
467 { |
|
468 DP_SDA(" CallActualXdmOperationL EUnblockPresentityGroupMember"); |
|
469 if ( !aCompleteStatus ) |
|
470 { |
|
471 DP_SDA(" -> succesfully unblocked, store to cache"); |
|
472 DeletePersonCacheL(); |
|
473 DP_SDA(" -> store info to cache done"); |
|
474 } |
|
475 CompleteXIMPReq( aCompleteStatus ); |
|
476 } |
|
477 break; |
|
478 |
|
479 default: |
|
480 User::Leave( KErrNotSupported ); |
|
481 break; |
|
482 } |
|
483 DP_SDA("CPresencePluginGroups::CallActualXdmOperationL end"); |
|
484 } |
|
485 |
|
486 // --------------------------------------------------------------------------- |
|
487 // CPresencePluginGroups::RunError |
|
488 // --------------------------------------------------------------------------- |
|
489 // |
|
490 TInt CPresencePluginGroups::RunError( TInt aError ) |
|
491 { |
|
492 DP_SDA("CPresencePluginGroups::RunError SEND COMPLETE"); |
|
493 // complete the open request |
|
494 CompleteXIMPReq( aError ); |
|
495 return KErrNone; |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // CPresencePluginGroups::GetInterface() |
|
500 // --------------------------------------------------------------------------- |
|
501 // |
|
502 TAny* CPresencePluginGroups::GetInterface( |
|
503 TInt32 aInterfaceId, |
|
504 TIfGetOps aOptions ) |
|
505 { |
|
506 if ( aInterfaceId == GetInterfaceId() ) |
|
507 { |
|
508 // caller wants this interface |
|
509 MProtocolPresentityGroups* myIf = this; |
|
510 return myIf; |
|
511 } |
|
512 if ( aOptions == MXIMPBase::EPanicIfUnknown ) |
|
513 { |
|
514 User::Panic( KPluginName, KErrExtensionNotSupported ); |
|
515 } |
|
516 return NULL; |
|
517 } |
|
518 |
|
519 // --------------------------------------------------------------------------- |
|
520 // CPresencePluginGroups::GetInterface() |
|
521 // --------------------------------------------------------------------------- |
|
522 // |
|
523 const TAny* CPresencePluginGroups::GetInterface( |
|
524 TInt32 aInterfaceId, |
|
525 TIfGetOps aOptions ) const |
|
526 { |
|
527 if ( aInterfaceId == GetInterfaceId() ) |
|
528 { |
|
529 // caller wants this interface |
|
530 const MProtocolPresentityGroups* myIf = this; |
|
531 return myIf; |
|
532 } |
|
533 if ( aOptions == MXIMPBase::EPanicIfUnknown ) |
|
534 { |
|
535 User::Panic( KPluginName, KErrExtensionNotSupported ); |
|
536 } |
|
537 return NULL; |
|
538 } |
|
539 |
|
540 // --------------------------------------------------------------------------- |
|
541 // CPresencePluginGroups::GetInterfaceId() |
|
542 // --------------------------------------------------------------------------- |
|
543 // |
|
544 TInt32 CPresencePluginGroups::GetInterfaceId() const |
|
545 { |
|
546 return MProtocolPresentityGroups::KInterfaceId; |
|
547 } |
|
548 |
|
549 // --------------------------------------------------------------------------- |
|
550 // CPresencePluginGroups::SetPresIdentityL() |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 void CPresencePluginGroups::SetPresIdentityL( |
|
554 const MXIMPIdentity& aPresentityId, |
|
555 TBool aFormatUri ) |
|
556 { |
|
557 DP_SDA2("CPresencePluginGroups::SetPresIdentityL: %S", |
|
558 &aPresentityId.Identity() ); |
|
559 |
|
560 delete iPresIdentity; |
|
561 iPresIdentity = NULL; |
|
562 |
|
563 if ( aFormatUri ) |
|
564 { |
|
565 DP_SDA("CPresencePluginGroups::SetPresIdentityL, format uri"); |
|
566 |
|
567 HBufC8* identityCopy = HBufC8::NewLC( KBufSize255 ); |
|
568 TPtr8 identityCopyPtr( identityCopy->Des() ); |
|
569 identityCopyPtr.Copy( aPresentityId.Identity() ); |
|
570 |
|
571 HBufC8* prefixUri = iPresenceData->CreatePresenceUri8LC( |
|
572 identityCopyPtr ); |
|
573 |
|
574 HBufC* prefixUri16 = HBufC::NewLC( KBufSize255 ); |
|
575 TPtr prefixUri16Ptr( prefixUri16->Des() ); |
|
576 prefixUri16Ptr.Copy( *prefixUri ); |
|
577 |
|
578 iPresIdentity = prefixUri16; |
|
579 CleanupStack::Pop( prefixUri16 ); |
|
580 CleanupStack::PopAndDestroy( prefixUri ); |
|
581 CleanupStack::PopAndDestroy( identityCopy ); |
|
582 } |
|
583 else |
|
584 { |
|
585 DP_SDA("CPresencePluginGroups::SetPresIdentityL, use as it is"); |
|
586 iPresIdentity = aPresentityId.Identity().AllocL(); |
|
587 } |
|
588 } |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // CPresencePluginGroups::StartXdmOperationL |
|
592 // --------------------------------------------------------------------------- |
|
593 // |
|
594 void CPresencePluginGroups::StartXdmOperationL( |
|
595 TXIMPRequestId aReqId, |
|
596 TPluginGroupsOperation aOperation ) |
|
597 { |
|
598 DP_SDA("StartXdmOperationL StartXdmOperationL two param"); |
|
599 __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) ); |
|
600 iXIMPId = aReqId; |
|
601 iOperation = aOperation; |
|
602 StartXdmOperationL(); |
|
603 DP_SDA("StartXdmOperationL StartXdmOperationL two param end"); |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------------------------- |
|
607 // CPresencePluginGroups::StartXdmOperationL |
|
608 // --------------------------------------------------------------------------- |
|
609 // |
|
610 void CPresencePluginGroups::StartXdmOperationL( |
|
611 const MXIMPIdentity& aId, |
|
612 TXIMPRequestId aReqId, |
|
613 TPluginGroupsOperation aOperation ) |
|
614 { |
|
615 DP_SDA("StartXdmOperationL StartXdmOperationL three param"); |
|
616 __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) ); |
|
617 SetPresIdentityL( aId, EFalse ); |
|
618 iXIMPId = aReqId; |
|
619 iOperation = aOperation; |
|
620 StartXdmOperationL(); |
|
621 } |
|
622 |
|
623 // --------------------------------------------------------------------------- |
|
624 // CPresencePluginGroups::StartXdmOperationL |
|
625 // --------------------------------------------------------------------------- |
|
626 // |
|
627 void CPresencePluginGroups::StartXdmOperationL() |
|
628 { |
|
629 if ( !iXdmUtils ) |
|
630 { |
|
631 DP_SDA("CPresencePluginGroups::StartXdmOperationL Get xdmUtils"); |
|
632 iXdmUtils = iConnObs.XdmUtilsL(); |
|
633 } |
|
634 DP_SDA("CPresencePluginGroups::StartXdmOperationL StartXdmOperationL"); |
|
635 |
|
636 iXdmUtils->InitializeXdmL( iStatus ); |
|
637 iState = EPluginInitXdm; |
|
638 DP_SDA("CPresencePluginGroups::StartXdmOperationL SetActive"); |
|
639 SetActive(); |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // CPresencePluginGroups::GetListOfListsL |
|
644 // --------------------------------------------------------------------------- |
|
645 // |
|
646 void CPresencePluginGroups::GetListOfListsL() |
|
647 { |
|
648 DP_SDA("CPresencePluginGroups::GetListOfListsL"); |
|
649 |
|
650 RPointerArray<MXIMPIdentity> subscribed; |
|
651 CleanupClosePushL( subscribed ); |
|
652 |
|
653 iXdmUtils->SubscribeBuddyListL( subscribed ); |
|
654 DP_SDA("CPresencePluginGroups::GetListOfListsL SubscribeBudyList Ready"); |
|
655 |
|
656 MXIMPObjectCollection* coll = |
|
657 iConnObs.ObjectFactory().NewObjectCollectionLC(); // << coll |
|
658 |
|
659 TInt count = subscribed.Count(); |
|
660 DP_SDA2("CPresencePluginGroups::GetListOfListsL soul count %d", count); |
|
661 |
|
662 for ( TInt i = 0; i < count; i++ ) |
|
663 { |
|
664 MXIMPIdentity* currId = subscribed[i]; |
|
665 MPresentityGroupInfo* sInfo = |
|
666 iConnObs.PresenceObjectFactoryOwn().NewPresentityGroupInfoLC(); |
|
667 sInfo->SetGroupIdL( currId ); // ownership is taken |
|
668 sInfo->SetGroupDisplayNameL( currId->Identity() ); |
|
669 |
|
670 coll->AddObjectL( sInfo ); // ownership is taken |
|
671 CleanupStack::Pop(); // >> bInfo |
|
672 } |
|
673 DP_SDA("SubscribeBudyList For ready SEND COMPLETE continue"); |
|
674 |
|
675 CompleteXIMPReq( KErrNone ); |
|
676 |
|
677 // Callback for subscription state (terminated). |
|
678 MXIMPDataSubscriptionState* myState = |
|
679 iConnObs.ObjectFactory().NewDataSubscriptionStateLC(); |
|
680 |
|
681 MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC(); |
|
682 |
|
683 // Notice: consider XIMP error codes |
|
684 myStatus->SetResultCode( KErrNone ); |
|
685 myState->SetSubscriptionStateL( |
|
686 MXIMPDataSubscriptionState::ESubscriptionInactive ); |
|
687 |
|
688 MProtocolPresentityGroupsDataHost& dataHost = |
|
689 iConnObs.ProtocolPresenceHost().GroupsDataHost(); |
|
690 |
|
691 dataHost.SetPresentityGroupListDataSubscriptionStateL( |
|
692 myState, myStatus ); |
|
693 |
|
694 dataHost.HandlePresentityGroupListL( coll ); |
|
695 |
|
696 CleanupStack::Pop( 3 ); // >> myState, myStatus, coll |
|
697 CleanupStack::Pop( &subscribed ); |
|
698 DP_SDA("CPresencePluginGroups::GetListOfListsL end"); |
|
699 } |
|
700 |
|
701 // --------------------------------------------------------------------------- |
|
702 // CPresencePluginGroups::GetListContentL |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 void CPresencePluginGroups::GetListContentL() |
|
706 { |
|
707 DP_SDA("CPresencePluginGroups::GetListContentL"); |
|
708 |
|
709 if( !iPresIdentity->Compare( KPresenceBuddyList ) ) |
|
710 { |
|
711 DP_SDA("CPresencePluginGroups::GetListContentL - get buddies"); |
|
712 DoGetSubscribedBuddyListL(); |
|
713 |
|
714 // Consider waiting complete for each subscribe before completing |
|
715 CompleteXIMPReq( KErrNone ); |
|
716 } |
|
717 else if( !iPresIdentity->Compare( KPresenceSubcribedBuddys ) ) |
|
718 { |
|
719 //Subscribe subscribed buddyes virtual group |
|
720 DP_SDA("GetListContentL KPresenceSubcribedBuddys"); |
|
721 DoGetSubscribedBuddyListL(); |
|
722 } |
|
723 else |
|
724 { |
|
725 DP_SDA("CPresencePluginGroups::GetListContentL Wrong list name"); |
|
726 User::Leave( KErrNotFound ); |
|
727 } |
|
728 } |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // CPresencePluginGroups::DoGetBuddyListL() |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 void CPresencePluginGroups::DoGetBuddyListL() |
|
735 { |
|
736 DP_SDA("CPresencePluginGroups::DoGetBuddyListL KPresenceBuddyList"); |
|
737 MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory(); |
|
738 MProtocolPresentityGroupsDataHost& dataHost = |
|
739 iConnObs.ProtocolPresenceHost().GroupsDataHost(); |
|
740 |
|
741 MXIMPObjectCollection* entities = |
|
742 myFactory.NewObjectCollectionLC(); // << entities |
|
743 iXdmUtils->GetEntitiesInListL( iPresIdentity->Des(), *entities ); |
|
744 DP_SDA("DoGetBuddyListL entities get ready SEND COMPLETE"); |
|
745 |
|
746 // callback for data |
|
747 DP_SDA("CPresencePluginGroups::DoGetBuddyListL callback data"); |
|
748 MXIMPIdentity* id = myFactory.NewIdentityLC(); // << id |
|
749 id->SetIdentityL( iPresIdentity->Des() ); |
|
750 dataHost.HandlePresentityGroupContentL( id, entities ); |
|
751 CleanupStack::Pop();// >> id |
|
752 CleanupStack::Pop();// >> entities |
|
753 DP_SDA("CPresencePluginGroups::DoGetBuddyListL callback ready"); |
|
754 |
|
755 // Callback for subscription state (terminated). |
|
756 DP_SDA("CPresencePluginGroups::DoGetBuddyListL terminated "); |
|
757 id = myFactory.NewIdentityLC(); // << id |
|
758 id->SetIdentityL( iPresIdentity->Des() ); |
|
759 MXIMPDataSubscriptionState* myState = |
|
760 myFactory.NewDataSubscriptionStateLC(); |
|
761 MXIMPStatus* myStatus = myFactory.NewStatusLC(); |
|
762 // Notice: consider XIMP error codes |
|
763 myStatus->SetResultCode( KErrNone ); |
|
764 myState->SetSubscriptionStateL( |
|
765 MXIMPDataSubscriptionState::ESubscriptionInactive ); |
|
766 |
|
767 dataHost.SetPresentityGroupContentDataSubscriptionStateL( |
|
768 id, myState, myStatus ); |
|
769 |
|
770 DP_SDA("CPresencePluginGroups::DoGetBuddyListL Pop"); |
|
771 CleanupStack::Pop( 3 ); |
|
772 |
|
773 DP_SDA("CPresencePluginGroups::DoGetBuddyListL end"); |
|
774 } |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CPresencePluginGroups::DoGetSubscribedBuddyListL() |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 void CPresencePluginGroups::DoGetSubscribedBuddyListL() |
|
781 { |
|
782 DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL"); |
|
783 MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory(); |
|
784 MProtocolPresentityGroupsDataHost& dataHost = |
|
785 iConnObs.ProtocolPresenceHost().GroupsDataHost(); |
|
786 |
|
787 // Get internal list content |
|
788 MXIMPObjectCollection* entities = |
|
789 myFactory.NewObjectCollectionLC(); // << entities |
|
790 iXdmUtils->GetEntitiesInListL( iPresIdentity->Des(), *entities ); |
|
791 DP_SDA("DoGetBuddyListL entities get ready SEND COMPLETE"); |
|
792 CleanupStack::PopAndDestroy(); // entities |
|
793 |
|
794 // start getting virtualEntities |
|
795 MXIMPObjectCollection* virtualEntities = |
|
796 myFactory.NewObjectCollectionLC();// << virtualEntities |
|
797 |
|
798 iSubscribedBuddies->GetVirtualEntitiesL( *virtualEntities ); |
|
799 |
|
800 DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL - subscribe all"); |
|
801 iConnObs.WatcherHandlerL()->SubscribeAllL(); |
|
802 DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL - subscribe all ok"); |
|
803 |
|
804 // callback for data |
|
805 DP_SDA("DoGetSubscribedBuddyListL callback data"); |
|
806 MXIMPIdentity* id = myFactory.NewIdentityLC(); // << id |
|
807 id->SetIdentityL( iPresIdentity->Des() ); |
|
808 dataHost.HandlePresentityGroupContentL( id, virtualEntities ); |
|
809 CleanupStack::Pop(); // >> id |
|
810 CleanupStack::Pop(); // >> entities |
|
811 DP_SDA("DoGetSubscribedBuddyListL callback ready"); |
|
812 |
|
813 // Callback for subscription state (terminated). |
|
814 DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL terminated"); |
|
815 id = myFactory.NewIdentityLC(); // << id |
|
816 id->SetIdentityL( iPresIdentity->Des() ); |
|
817 MXIMPDataSubscriptionState* myState = |
|
818 myFactory.NewDataSubscriptionStateLC(); |
|
819 MXIMPStatus* myStatus = myFactory.NewStatusLC(); |
|
820 // Notice: consider XIMP error codes |
|
821 myStatus->SetResultCode( KErrNone ); |
|
822 myState->SetSubscriptionStateL( |
|
823 MXIMPDataSubscriptionState::ESubscriptionActive ); |
|
824 dataHost.SetPresentityGroupContentDataSubscriptionStateL( |
|
825 id, myState, myStatus ); |
|
826 |
|
827 CleanupStack::Pop( 3 ); |
|
828 |
|
829 DP_SDA("DoGetSubscribedBuddyListL - KPresenceOnlineBuddy case end"); |
|
830 } |
|
831 |
|
832 // --------------------------------------------------------------------------- |
|
833 // CPresencePluginGroups::CompleteXIMPReq |
|
834 // --------------------------------------------------------------------------- |
|
835 // |
|
836 void CPresencePluginGroups::CompleteXIMPReq( TInt aStatus ) |
|
837 { |
|
838 DP_SDA("CPresencePluginGroups::CompleteXIMPReq"); |
|
839 if ( iCompleted ) |
|
840 { |
|
841 DP_SDA("CPresencePluginGroups::CompleteXIMPReq return"); |
|
842 return; |
|
843 } |
|
844 |
|
845 iCompleted = ETrue; |
|
846 iOperation = ENoOperation; |
|
847 iConnObs.CompleteReq( iXIMPId, aStatus ); |
|
848 iXIMPId = TXIMPRequestId(); |
|
849 DP_SDA("CPresencePluginGroups::CompleteXIMPReq end"); |
|
850 } |
|
851 |
|
852 // --------------------------------------------------------------------------- |
|
853 // CPresencePluginGroups::DeletePersonCacheL |
|
854 // --------------------------------------------------------------------------- |
|
855 // |
|
856 void CPresencePluginGroups::DeletePersonCacheL() |
|
857 { |
|
858 DP_SDA("CPresencePluginGroups::DeletePersonCacheL"); |
|
859 DP_SDA(" -> strip prefix from uri"); |
|
860 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity ); |
|
861 iPresenceData->DeletePresenceL( *withoutPrefix ); |
|
862 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
863 DP_SDA("CPresencePluginGroups::DeletePersonCacheL out"); |
|
864 } |
|
865 |
|
866 // End of file |
|