1 /* |
|
2 * Copyright (c) 2006-2009 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 #include <e32std.h> |
|
19 #include <s32strm.h> |
|
20 #include <utf.h> |
|
21 #include <ximpdatasubscriptionstate.h> |
|
22 #include <protocolpresenceauthorizationdatahost.h> |
|
23 #include <ximpobjectfactory.h> |
|
24 #include <presenceobjectfactory.h> |
|
25 #include <ximpstatus.h> |
|
26 #include <ximpidentity.h> |
|
27 #include <presencegrantrequestinfo.h> |
|
28 #include <ximpobjectcollection.h> |
|
29 #include <presenceblockinfo.h> |
|
30 #include <presenceinfofilter.h> |
|
31 #include <msimplewinfo.h> |
|
32 #include <msimpleelement.h> |
|
33 |
|
34 #include <presenceinfo.h> |
|
35 #include <presenceinfofieldcollection.h> |
|
36 #include <personpresenceinfo.h> |
|
37 #include <presenceinfofield.h> |
|
38 #include <presenceinfofieldvalueenum.h> |
|
39 #include <avabilitytext.h> |
|
40 |
|
41 #include "presencepluginauthorization.h" |
|
42 #include "presencepluginwinfo.h" |
|
43 #include "presenceplugincommon.h" |
|
44 #include "presencepluginxdmutils.h" |
|
45 #include "presencepluginwatcher.h" |
|
46 #include "presenceplugindata.h" |
|
47 #include "presencepluginutility.h" |
|
48 #include "presenceplugingroup.h" |
|
49 #include "presencepluginvirtualgroup.h" |
|
50 |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CPresencePluginAuthorization::CPresencePluginAuthorization() |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CPresencePluginAuthorization::CPresencePluginAuthorization( |
|
59 MPresencePluginConnectionObs& aObs, |
|
60 CPresencePluginData* aPresenceData ) |
|
61 : CActive( CActive::EPriorityStandard ), |
|
62 iConnObs(aObs), iSubscribed( EFalse ), |
|
63 iOperation( ENoOperation ), |
|
64 iXdmOk( EFalse ), iComplete( EFalse ),iPresenceData( aPresenceData ) |
|
65 { |
|
66 CActiveScheduler::Add(this); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CPresencePluginAuthorization::NewL() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CPresencePluginAuthorization* CPresencePluginAuthorization::NewL( |
|
74 MPresencePluginConnectionObs& aObs, |
|
75 CPresencePluginData* aPresenceData ) |
|
76 { |
|
77 DP_SDA("CPresencePluginAuthorization::NewL "); |
|
78 CPresencePluginAuthorization* self = |
|
79 new( ELeave ) CPresencePluginAuthorization( aObs, aPresenceData ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CPresencePluginAuthorization::~CPresencePluginAuthorization() |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CPresencePluginAuthorization::~CPresencePluginAuthorization() |
|
88 { |
|
89 delete iPresIdentity; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CPresencePluginAuthorization::SetDataHost() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CPresencePluginAuthorization::SetDataHost( |
|
97 MProtocolPresenceAuthorizationDataHost& aDataHost ) |
|
98 { |
|
99 DP_SDA("CPresencePluginAuthorization::SetDataHost "); |
|
100 iDataHost = &aDataHost; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CPresencePluginAuthorization::WinfoTerminatedL() |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CPresencePluginAuthorization::WinfoTerminatedL( TInt aReason ) |
|
108 { |
|
109 DP_SDA("CPresencePluginAuthorization::WinfoTerminatedL "); |
|
110 |
|
111 if ( iSubscribed ) |
|
112 { |
|
113 MXIMPDataSubscriptionState* myState = |
|
114 iConnObs.ObjectFactory().NewDataSubscriptionStateLC(); |
|
115 MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC(); |
|
116 myStatus->SetResultCode( aReason ? aReason : KErrCompletion ); |
|
117 myState->SetSubscriptionStateL( |
|
118 MXIMPDataSubscriptionState::ESubscriptionInactive ); |
|
119 |
|
120 // parameters' OWNERSHIP is taken |
|
121 iDataHost->SetPresenceGrantRequestDataSubscriptionStateL( |
|
122 myState, |
|
123 myStatus ); |
|
124 |
|
125 CleanupStack::Pop( /*myStatus*/ ); |
|
126 CleanupStack::Pop( /*myState*/ ); |
|
127 } |
|
128 |
|
129 DP_SDA("CPresencePluginAuthorization::WinfoTerminatedL end"); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CPresencePluginAuthorization::DoSubscribePresenceGrantRequestListL() |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CPresencePluginAuthorization::DoSubscribePresenceGrantRequestListL( |
|
137 TXIMPRequestId aReqId ) |
|
138 { |
|
139 DP_SDA("DoSubscribePresenceGrantRequestListL "); |
|
140 iConnObs.WinfoHandlerL()->SubscribeWinfoListL( aReqId ); |
|
141 iSubscribed = ETrue; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CPresencePluginAuthorization::DoUnsubscribePresenceGrantRequestListL() |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CPresencePluginAuthorization::DoUnsubscribePresenceGrantRequestListL( |
|
149 TXIMPRequestId aReqId ) |
|
150 { |
|
151 DP_SDA("DoUnsubscribePresenceGrantRequestListL "); |
|
152 iConnObs.WinfoHandlerL()->UnsubscribeWinfoListL( aReqId ); |
|
153 iSubscribed = EFalse; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CPresencePluginAuthorization::DoGrantPresenceForPresentityL() |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CPresencePluginAuthorization::DoGrantPresenceForPresentityL( |
|
161 const MXIMPIdentity& aPresentityId, |
|
162 const MPresenceInfoFilter& /*aPif*/, // notice: pif support |
|
163 TXIMPRequestId aReqId ) |
|
164 { |
|
165 DP_SDA("CPresencePluginAuthorization::DoGrantPresenceForPresentityL "); |
|
166 |
|
167 // Workaround for clients that can only grant when accepting buddy request. |
|
168 // SIMPLE also requires grant + subscribe so do both here even though |
|
169 // it is agains ximp api definitions. |
|
170 |
|
171 _LIT( KDefaultBuddyList, "buddylist" ); |
|
172 |
|
173 iAuthState = EStateAcceptBuddyRequest; |
|
174 MXIMPIdentity* buddyList = iConnObs.ObjectFactory().NewIdentityLC(); |
|
175 buddyList->SetIdentityL( KDefaultBuddyList() ); |
|
176 |
|
177 iConnObs.GroupsL().DoAddPresentityGroupMemberL( *buddyList, aPresentityId, |
|
178 KNullDesC(), aReqId ); |
|
179 CleanupStack::PopAndDestroy( 1 ); // buddyList |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CPresencePluginAuthorization::DoPerformGrantPresenceForPresentityL() |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CPresencePluginAuthorization::DoPerformGrantPresenceForPresentityL( |
|
187 const MXIMPIdentity& aPresentityId, |
|
188 TRequestStatus& aClientStatus ) |
|
189 { |
|
190 DP_SDA("CPresencePluginAuthorization::DoPerformGrantPresenceForPresentityL"); |
|
191 StartXdmOperationL( aPresentityId, |
|
192 EGrantPresenceForPresentity, aClientStatus ); |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CPresencePluginAuthorization::DoUpdatePresenceGrantPifForPresentityL() |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CPresencePluginAuthorization::DoUpdatePresenceGrantPifForPresentityL( |
|
200 const MXIMPIdentity& /*aPresentityId*/, |
|
201 const MPresenceInfoFilter& /*aPif*/, |
|
202 TXIMPRequestId /*aReqId*/ ) |
|
203 { |
|
204 // Notice: later |
|
205 User::Leave( KErrNotSupported ); |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CPresencePluginAuthorization::DoWithdrawPresenceGrantFromPresentityL() |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CPresencePluginAuthorization::DoWithdrawPresenceGrantFromPresentityL( |
|
213 const MXIMPIdentity& aPresentityId, |
|
214 TXIMPRequestId aReqId ) |
|
215 { |
|
216 DP_SDA("CPresencePluginAuth::DoWithdrawPresenceGrantFromPresentityL "); |
|
217 StartXdmOperationL( aPresentityId, aReqId, EWithdrawFromPresentity ); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CPresencePluginAuthorization::DoPerformWithdrawPresGrantFromPresentityL() |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CPresencePluginAuthorization::DoPerformWithdrawPresGrantFromPresentityL( |
|
225 const MXIMPIdentity& aPresentityId, |
|
226 TRequestStatus& aClientStatus ) |
|
227 { |
|
228 DP_SDA("CPresencePluginAuthorization"); |
|
229 DP_SDA(" -> DoPerformWithdrawPresGrantFromPresentityL"); |
|
230 StartXdmOperationL( aPresentityId, |
|
231 EWithdrawFromPresentity, aClientStatus ); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // CPresencePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL() |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 void CPresencePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL( |
|
239 const MXIMPIdentity& /*aGroupId*/, |
|
240 const MPresenceInfoFilter& /*aPif*/, |
|
241 TXIMPRequestId /*aReqId*/ ) |
|
242 { |
|
243 DP_SDA("CPresencePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL -not supported"); |
|
244 |
|
245 User::Leave( KErrNotSupported ); |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // CPresencePluginAuthorization:: |
|
250 // DoUpdatePresenceGrantPifForPresentityGroupMembersL() |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CPresencePluginAuthorization:: |
|
254 DoUpdatePresenceGrantPifForPresentityGroupMembersL( |
|
255 const MXIMPIdentity& /*aGroupId*/, |
|
256 const MPresenceInfoFilter& /*aPif*/, |
|
257 TXIMPRequestId /*aReqId*/ ) |
|
258 { |
|
259 DP_SDA("CPresencePluginAuthorization::DoUpdatePresenceGrantPifForPresentityGroupMembersL -not supported"); |
|
260 |
|
261 User::Leave( KErrNotSupported ); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CPresencePluginAuthorization:: |
|
266 // DoWithdrawPresenceGrantFromPresentityGroupMembersL() |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CPresencePluginAuthorization:: |
|
270 DoWithdrawPresenceGrantFromPresentityGroupMembersL( |
|
271 const MXIMPIdentity& /*aGroupId*/, |
|
272 TXIMPRequestId /*aReqId*/ ) |
|
273 { |
|
274 DP_SDA("CPresencePluginAuthorization::DoWithdrawPresenceGrantFromPresentityGroupMembersL -not supported"); |
|
275 |
|
276 User::Leave( KErrNotSupported ); |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // CPresencePluginAuthorization::DoGrantPresenceForEveryoneL() |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CPresencePluginAuthorization::DoGrantPresenceForEveryoneL( |
|
284 const MPresenceInfoFilter& /*aPif*/, |
|
285 TXIMPRequestId /*aReqId*/ ) |
|
286 { |
|
287 DP_SDA("CPresencePluginAuthorization::DoGrantPresenceForEveryoneL -not supported"); |
|
288 |
|
289 User::Leave( KErrNotSupported ); |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // CPresencePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL() |
|
294 // --------------------------------------------------------------------------- |
|
295 // |
|
296 void CPresencePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL( |
|
297 const MPresenceInfoFilter& /*aPif*/, |
|
298 TXIMPRequestId /*aReqId*/ ) |
|
299 { |
|
300 DP_SDA("CPresencePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL -not supported"); |
|
301 |
|
302 User::Leave( KErrNotSupported ); |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // CPresencePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL() |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CPresencePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL( |
|
310 TXIMPRequestId /*aReqId*/ ) |
|
311 { |
|
312 DP_SDA("CPresencePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL -not supported"); |
|
313 |
|
314 User::Leave( KErrNotSupported ); |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CPresencePluginAuthorization::DoSubscribePresenceBlockListL() |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CPresencePluginAuthorization::DoSubscribePresenceBlockListL( |
|
322 TXIMPRequestId aReqId ) |
|
323 { |
|
324 DP_SDA("CPresencePluginAuthorization::DoSubscribePresenceBlockListL "); |
|
325 MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC(); |
|
326 StartXdmOperationL( *nobody, aReqId, ESubscribeBlockList ); |
|
327 // Cannot PopAndDestroy by name |
|
328 CleanupStack::PopAndDestroy( ); |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // CPresencePluginAuthorization::DoUnsubscribePresenceBlockListL() |
|
333 // --------------------------------------------------------------------------- |
|
334 // |
|
335 void CPresencePluginAuthorization::DoUnsubscribePresenceBlockListL( |
|
336 TXIMPRequestId aReqId ) |
|
337 { |
|
338 DP_SDA("CPresencePluginAuthorization::DoUnsubscribePresenceBlockListL "); |
|
339 MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC(); |
|
340 StartXdmOperationL( *nobody, aReqId, EUnsubscribeBlockList ); |
|
341 // Cannot PopAndDestroy by name |
|
342 CleanupStack::PopAndDestroy(); |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // CPresencePluginAuthorization::DoBlockPresenceForPresentityL() |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 void CPresencePluginAuthorization::DoBlockPresenceForPresentityL( |
|
350 const MXIMPIdentity& aPresentityId, |
|
351 TXIMPRequestId aReqId ) |
|
352 { |
|
353 DP_SDA("CPresencePluginAuthorization::DoBlockPresenceForPresentityL "); |
|
354 StartXdmOperationL( aPresentityId, aReqId, EBlockPresentity ); |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // CPresencePluginAuthorization::DoPerformBlockPresenceForPresentityL() |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 void CPresencePluginAuthorization::DoPerformBlockPresenceForPresentityL( |
|
362 const MXIMPIdentity& aPresentityId, |
|
363 TRequestStatus& aClientStatus ) |
|
364 { |
|
365 DP_SDA( |
|
366 "CPresencePluginAuthorization::DoPerformBlockPresenceForPresentityL"); |
|
367 StartXdmOperationL( aPresentityId, EBlockPresentity, aClientStatus ); |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // CPresencePluginAuthorization::DoCancelPresenceBlockFromPresentityL() |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 void CPresencePluginAuthorization::DoCancelPresenceBlockFromPresentityL( |
|
375 const MXIMPIdentity& aPresentityId, |
|
376 TXIMPRequestId aReqId ) |
|
377 { |
|
378 DP_SDA(" DoCancelPresenceBlockFromPresentityL "); |
|
379 StartXdmOperationL( aPresentityId, aReqId, EUnblockPresentity ); |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // CPresencePluginAuthorization::DoPerformCancelPresenceBlockFromPresentityL() |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CPresencePluginAuthorization::DoPerformCancelPresenceBlockFromPresentityL( |
|
387 const MXIMPIdentity& aPresentityId, |
|
388 TRequestStatus& aClientStatus ) |
|
389 { |
|
390 DP_SDA(" DoPerformCancelPresenceBlockFromPresentityL (list)"); |
|
391 StartXdmOperationL( aPresentityId, EUnblockPresentity, aClientStatus ); |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CPresencePluginAuthorization::DoCancel() |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void CPresencePluginAuthorization::DoCancel( ) |
|
399 { |
|
400 iXdmUtils->Cancel(); |
|
401 } |
|
402 |
|
403 // --------------------------------------------------------------------------- |
|
404 // CPresencePluginAuthorization::RunL() |
|
405 // --------------------------------------------------------------------------- |
|
406 // |
|
407 void CPresencePluginAuthorization::RunL( ) |
|
408 { |
|
409 TInt myStatus = iStatus.Int(); |
|
410 |
|
411 DP_SDA2( "CPresencePluginAuthorization::RunL mystatus %d ", myStatus ); |
|
412 DP_SDA2( "CPresencePluginAuthorization::RunL state %d ",iOperation ); |
|
413 |
|
414 if ( !iXdmOk && !myStatus ) |
|
415 { |
|
416 DP_SDA( "CPresencePluginAuthorization::RunL !iXdmOk && !myStatus" ); |
|
417 iXdmOk = ETrue; |
|
418 CallActualXdmOperationL(); |
|
419 } |
|
420 else if ( iClientStatus ) |
|
421 { |
|
422 DP_SDA( "CPresencePluginAuthorization::RunL - complete client" ); |
|
423 TRequestStatus* s = iClientStatus; |
|
424 User::RequestComplete( s, myStatus ); |
|
425 iClientStatus = NULL; |
|
426 DP_SDA( "CPresencePluginAuthorization::RunL - complete client ok" ); |
|
427 } |
|
428 else if ( !myStatus ) |
|
429 { |
|
430 switch ( iAuthState ) |
|
431 { |
|
432 case EStateDoBlock: |
|
433 { |
|
434 DP_SDA( "CPresencePluginAuthorization::RunL - Block presentity" ); |
|
435 BlockPresentityL(); |
|
436 iAuthState = EStateRemovePresentityFromGranted; |
|
437 } |
|
438 break; |
|
439 |
|
440 case EStateRemovePresentityFromGranted: |
|
441 { |
|
442 DP_SDA( "CPresencePluginAuthorization::RunL - Remove presentity from granted" ); |
|
443 WithdrawFromPresentityL(); |
|
444 iAuthState = EStateBlocked; |
|
445 } |
|
446 break; |
|
447 |
|
448 case EStateBlocked: |
|
449 { |
|
450 SetPresentityBlockedToXIMPL(); |
|
451 iAuthState = EStateIdle; |
|
452 CompleteXIMPReq( myStatus ); |
|
453 } |
|
454 break; |
|
455 |
|
456 case EStateDoUnBlock: |
|
457 { |
|
458 DP_SDA( "CPresencePluginAuthorization::RunL - Grant presence for presentity" ); |
|
459 GrantPresenceForPresentityL(); |
|
460 iAuthState = EStatePresenceGranted; |
|
461 } |
|
462 break; |
|
463 |
|
464 case EStatePresenceGranted: |
|
465 { |
|
466 DP_SDA( "CPresencePluginAuthorization::RunL -Subscribe presentity presence" ); |
|
467 |
|
468 MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
469 identity->SetIdentityL( iPresIdentity->Des() ); |
|
470 iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( *identity, iStatus ); |
|
471 CleanupStack::PopAndDestroy( ); //identity |
|
472 iAuthState = EStateIdle; |
|
473 SetActive(); |
|
474 } |
|
475 break; |
|
476 |
|
477 default: |
|
478 { |
|
479 DP_SDA( "CPresencePluginAuthorization::RunL - default case" ); |
|
480 CompleteXIMPReq( myStatus ); |
|
481 } |
|
482 break; |
|
483 } |
|
484 } |
|
485 else |
|
486 { |
|
487 DP_SDA( "CPresencePluginAuthorization::RunL -error" ); |
|
488 CompleteXIMPReq( myStatus ); |
|
489 } |
|
490 |
|
491 if ( EStateAcceptBuddyRequest == iAuthState && EGrantPresenceForPresentity == iOperation ) |
|
492 { |
|
493 iAuthState = EStateIdle; |
|
494 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity ); |
|
495 CallHandlePresenceGrantRequestObsoletedL( *withoutPrefix ); |
|
496 iConnObs.SubscribedContacts()->HandlePresentityGroupMemberAddedL( *withoutPrefix ); |
|
497 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
498 } |
|
499 |
|
500 DP_SDA( "CPresencePluginAuthorization::RunL - exit" ); |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // CPresencePluginAuthorization::CallActualXdmOperationL() |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 void CPresencePluginAuthorization::CallActualXdmOperationL() |
|
508 { |
|
509 DP_SDA("CPresencePluginAuthorization::CallActualXdmOperationL "); |
|
510 DP_SDA2("CallActualXdmOperationL operation %d", iOperation ); |
|
511 iComplete = EFalse; |
|
512 switch ( iOperation ) |
|
513 { |
|
514 case EGrantPresenceForPresentity: |
|
515 { |
|
516 DP_SDA("CallActualXdmOperationL EGrantPresenceForPresentity"); |
|
517 GrantPresenceForPresentityL(); |
|
518 } |
|
519 break; |
|
520 |
|
521 case EWithdrawFromPresentity: |
|
522 { |
|
523 DP_SDA("CallActualXdmOperationL EWithdrawFromPresentity"); |
|
524 WithdrawFromPresentityL(); |
|
525 } |
|
526 break; |
|
527 |
|
528 case ESubscribeBlockList: |
|
529 { |
|
530 SubscribeBlockListL( ); |
|
531 } |
|
532 break; |
|
533 |
|
534 case EUnsubscribeBlockList: |
|
535 { |
|
536 UnSubscribeBlockListL(); |
|
537 } |
|
538 break; |
|
539 |
|
540 case EBlockPresentity: |
|
541 { |
|
542 DP_SDA( "CallActualXdmOperationL EBlockPresentity" ); |
|
543 |
|
544 TRAPD( error, UnsubscribePresentityPresenceL() ); |
|
545 |
|
546 if( error ) |
|
547 { |
|
548 DP_SDA2( "Unsubscribe presentity FAIL, error = %d" , error ); |
|
549 |
|
550 if ( KErrNotFound != error ) |
|
551 { |
|
552 User::Leave( error ); |
|
553 } |
|
554 BlockPresentityL(); |
|
555 iAuthState = EStateBlocked; |
|
556 } |
|
557 else |
|
558 { |
|
559 iAuthState = EStateDoBlock; |
|
560 } |
|
561 } |
|
562 break; |
|
563 |
|
564 case EUnblockPresentity: |
|
565 { |
|
566 DP_SDA("CallActualXdmOperationL EUnblockPresentity"); |
|
567 UnblockPresentityL(); |
|
568 } |
|
569 break; |
|
570 |
|
571 default: |
|
572 User::Leave( KErrNotSupported ); |
|
573 break; |
|
574 } |
|
575 DP_SDA("CPresencePluginAuthorization::CallActualXdmOperationL end"); |
|
576 } |
|
577 |
|
578 // --------------------------------------------------------------------------- |
|
579 // CPresencePluginAuthorization::RunError() |
|
580 // --------------------------------------------------------------------------- |
|
581 // |
|
582 TInt CPresencePluginAuthorization::RunError( TInt aError ) |
|
583 { |
|
584 // complete the open request |
|
585 CompleteXIMPReq( aError ); |
|
586 return KErrNone; |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // CPresencePluginAuthorization::GetInterface() |
|
591 // --------------------------------------------------------------------------- |
|
592 // |
|
593 TAny* CPresencePluginAuthorization::GetInterface( |
|
594 TInt32 aInterfaceId, |
|
595 TIfGetOps aOptions ) |
|
596 { |
|
597 if ( aInterfaceId == GetInterfaceId() ) |
|
598 { |
|
599 // caller wants this interface |
|
600 return this; |
|
601 } |
|
602 if ( aOptions == MXIMPBase::EPanicIfUnknown ) |
|
603 { |
|
604 User::Panic( KPluginName, KErrExtensionNotSupported ); |
|
605 } |
|
606 return NULL; |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // CPresencePluginAuthorization::GetInterface() const |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 const TAny* CPresencePluginAuthorization::GetInterface( |
|
614 TInt32 aInterfaceId, |
|
615 TIfGetOps aOptions ) const |
|
616 { |
|
617 if ( aInterfaceId == GetInterfaceId() ) |
|
618 { |
|
619 // caller wants this interface |
|
620 return const_cast<CPresencePluginAuthorization*>(this); |
|
621 } |
|
622 if ( aOptions == MXIMPBase::EPanicIfUnknown ) |
|
623 { |
|
624 User::Panic( KPluginName, KErrExtensionNotSupported ); |
|
625 } |
|
626 return NULL; |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // CPresencePluginAuthorization::GetInterfaceId() |
|
631 // --------------------------------------------------------------------------- |
|
632 // |
|
633 TInt32 CPresencePluginAuthorization::GetInterfaceId() const |
|
634 { |
|
635 return MProtocolPresenceAuthorization::KInterfaceId; |
|
636 } |
|
637 |
|
638 // --------------------------------------------------------------------------- |
|
639 // CPresencePluginAuthorization::SetPresIdentityL() |
|
640 // --------------------------------------------------------------------------- |
|
641 // |
|
642 void CPresencePluginAuthorization::SetPresIdentityL( |
|
643 const MXIMPIdentity& aPresentityId, |
|
644 TBool aFormatUri ) |
|
645 { |
|
646 DP_SDA2("CPresencePluginAuthorization::SetPresIdentityL: %S", |
|
647 &aPresentityId.Identity() ); |
|
648 |
|
649 delete iPresIdentity; |
|
650 iPresIdentity = NULL; |
|
651 |
|
652 if ( aFormatUri ) |
|
653 { |
|
654 DP_SDA("CPresencePluginAuthorization::SetPresIdentityL, add prefix"); |
|
655 |
|
656 HBufC8* identityCopy = HBufC8::NewLC( KBufSize255 ); |
|
657 TPtr8 identityCopyPtr( identityCopy->Des() ); |
|
658 identityCopyPtr.Copy( aPresentityId.Identity() ); |
|
659 |
|
660 HBufC8* prefixUri = iPresenceData->CreatePresenceUri8LC( |
|
661 identityCopyPtr ); |
|
662 |
|
663 HBufC* prefixUri16 = HBufC::NewLC( KBufSize255 ); |
|
664 TPtr prefixUri16Ptr( prefixUri16->Des() ); |
|
665 prefixUri16Ptr.Copy( *prefixUri ); |
|
666 |
|
667 iPresIdentity = prefixUri16; |
|
668 CleanupStack::Pop( prefixUri16 ); |
|
669 CleanupStack::PopAndDestroy( prefixUri ); |
|
670 CleanupStack::PopAndDestroy( identityCopy ); |
|
671 } |
|
672 else |
|
673 { |
|
674 DP_SDA(" SetPresIdentityL, use as it is"); |
|
675 iPresIdentity = aPresentityId.Identity().AllocL(); |
|
676 } |
|
677 DP_SDA( "CPresencePluginAuthorization::SetPresIdentityL -exit" ); |
|
678 } |
|
679 |
|
680 // --------------------------------------------------------------------------- |
|
681 // CPresencePluginAuthorization::WinfoNotificationL() |
|
682 // --------------------------------------------------------------------------- |
|
683 // |
|
684 void CPresencePluginAuthorization::WinfoNotificationL( |
|
685 MSimpleWinfo& aWinfo ) |
|
686 { |
|
687 DP_SDA("CPresencePluginAuthorization::WinfoNotificationL"); |
|
688 // Ignore notification if not subscribed |
|
689 using namespace NPresencePlugin::NPresence; |
|
690 |
|
691 RPointerArray<MSimpleElement> elems; |
|
692 CleanupClosePushL( elems ); |
|
693 TInt err = aWinfo.SimpleElementsL( elems ); |
|
694 User::LeaveIfError( err ); |
|
695 TInt count = elems.Count(); |
|
696 |
|
697 DP_SDA2("CPresencePluginAuthorization::WinfoNotificationL count %d", |
|
698 count); |
|
699 |
|
700 if ( !count ) |
|
701 { |
|
702 // stop parsing empty notification |
|
703 DP_SDA("CPresencePluginAuthorization::WinfoNotificationL LEAVE"); |
|
704 User::Leave( KErrArgument ); |
|
705 } |
|
706 |
|
707 const TDesC8* stateVal = aWinfo.AttrValue( KPresenceState8 ); |
|
708 if ( stateVal && !stateVal->CompareF( KPresenceFull8 )) |
|
709 { |
|
710 // Call full list method |
|
711 DP_SDA("CPresencePluginAuthorization::WinfoNotificationL FULL winfo"); |
|
712 HandleFullWinfoNotificationL( aWinfo ); |
|
713 } |
|
714 else |
|
715 { |
|
716 // Indicate changes in WINFO list one by one. |
|
717 DP_SDA("CPresencePluginAuthorization::WinfoNotificationLPARTIAL winfo"); |
|
718 HandlePartialWinfoNotificationL( aWinfo ); |
|
719 } |
|
720 CleanupStack::PopAndDestroy( &elems ); |
|
721 DP_SDA("CPresencePluginAuthorization::WinfoNotificationL end"); |
|
722 } |
|
723 |
|
724 // --------------------------------------------------------------------------- |
|
725 // CPresencePluginAuthorization::StartXdmOperationL() |
|
726 // --------------------------------------------------------------------------- |
|
727 // |
|
728 void CPresencePluginAuthorization::StartXdmOperationL( |
|
729 const MXIMPIdentity& aId, |
|
730 TXIMPRequestId aReqId, |
|
731 TPluginAuthOperation aOperation ) |
|
732 { |
|
733 __ASSERT_DEBUG( !IsActive(), User::Leave( KErrNotReady ) ); |
|
734 DP_SDA("CPresencePluginAuthorization::StartXdmOperationL 2"); |
|
735 SetPresIdentityL( aId, ETrue ); |
|
736 |
|
737 iXIMPId = aReqId; |
|
738 iOperation = aOperation; |
|
739 if ( !iXdmUtils ) |
|
740 { |
|
741 DP_SDA("StartXdmOperationL !iXdmUtils"); |
|
742 iXdmUtils = iConnObs.XdmUtilsL(); |
|
743 } |
|
744 if ( iXdmUtils->CheckXdmDoc() ) |
|
745 { |
|
746 DP_SDA("StartXdmOperationL iXdmOk"); |
|
747 iXdmOk = ETrue; |
|
748 CallActualXdmOperationL(); |
|
749 } |
|
750 else |
|
751 { |
|
752 DP_SDA("StartXdmOperationL else"); |
|
753 iXdmUtils->InitializeXdmL( iStatus ); |
|
754 SetActive(); |
|
755 } |
|
756 DP_SDA("CPresencePluginAuthorization::StartXdmOperationL end"); |
|
757 } |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // CPresencePluginAuthorization::StartXdmOperationL() |
|
761 // --------------------------------------------------------------------------- |
|
762 // |
|
763 void CPresencePluginAuthorization::StartXdmOperationL( |
|
764 const MXIMPIdentity& aId, |
|
765 TPluginAuthOperation aOperation, |
|
766 TRequestStatus& aClientStatus ) |
|
767 { |
|
768 __ASSERT_DEBUG( !IsActive(), User::Leave( KErrNotReady ) ); |
|
769 DP_SDA("CPresencePluginAuthorization::StartXdmOperationL 3 (list)"); |
|
770 |
|
771 SetPresIdentityL( aId, EFalse ); |
|
772 |
|
773 iClientStatus = &aClientStatus; |
|
774 *iClientStatus = KRequestPending; |
|
775 |
|
776 iOperation = aOperation; |
|
777 |
|
778 if ( !iXdmUtils ) |
|
779 { |
|
780 DP_SDA("StartXdmOperationL !iXdmUtils"); |
|
781 iXdmUtils = iConnObs.XdmUtilsL(); |
|
782 } |
|
783 if ( iXdmUtils->CheckXdmDoc() ) |
|
784 { |
|
785 DP_SDA("StartXdmOperationL iXdmOk"); |
|
786 iXdmOk = ETrue; |
|
787 CallActualXdmOperationL(); |
|
788 } |
|
789 else |
|
790 { |
|
791 DP_SDA("StartXdmOperationL else"); |
|
792 iXdmUtils->InitializeXdmL( iStatus ); |
|
793 SetActive(); |
|
794 } |
|
795 DP_SDA("CPresencePluginAuthorization::StartXdmOperationL end"); |
|
796 } |
|
797 |
|
798 // --------------------------------------------------------------------------- |
|
799 // CPresencePluginAuthorization::CompleteXIMPReq() |
|
800 // --------------------------------------------------------------------------- |
|
801 // |
|
802 void CPresencePluginAuthorization::CompleteXIMPReq( TInt aStatus ) |
|
803 { |
|
804 DP_SDA("CPresencePluginAuthorization::CompleteXIMPReq"); |
|
805 iOperation = ENoOperation; |
|
806 iConnObs.CompleteReq( iXIMPId, aStatus ); |
|
807 iXIMPId = TXIMPRequestId(); |
|
808 DP_SDA("CPresencePluginAuthorization::CompleteXIMPReq end"); |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // CPresencePluginAuthorization::SubscribeBlockListL() |
|
813 // --------------------------------------------------------------------------- |
|
814 // |
|
815 void CPresencePluginAuthorization::SubscribeBlockListL() |
|
816 { |
|
817 DP_SDA("CPresencePluginAuthorization::SubscribeBlockList"); |
|
818 |
|
819 RPointerArray<MXIMPIdentity> blocked; |
|
820 CleanupStack::PushL( TCleanupItem( |
|
821 TPresencePluginUtility::ResetAndDestroyIdentities, |
|
822 &blocked ) ); |
|
823 |
|
824 iXdmUtils->SubscribeBlockListL( blocked ); |
|
825 MXIMPObjectCollection* coll = |
|
826 iConnObs.ObjectFactory().NewObjectCollectionLC(); // << coll |
|
827 |
|
828 TInt count = blocked.Count(); |
|
829 for ( TInt i = 0; i < count; i++ ) |
|
830 { |
|
831 MXIMPIdentity* currId = blocked[i]; |
|
832 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( currId->Identity() ); |
|
833 currId->SetIdentityL( *withoutPrefix ); |
|
834 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
835 MPresenceBlockInfo* bInfo = |
|
836 iConnObs.PresenceObjectFactoryOwn().NewPresenceBlockInfoLC(); |
|
837 bInfo->SetBlockedEntityIdL( currId ); // ownership is taken |
|
838 blocked.Remove( i ); // remove currId from blocked |
|
839 blocked.InsertL( NULL, i ); |
|
840 bInfo->SetBlockedEntityDisplayNameL( currId->Identity() ); |
|
841 coll->AddObjectL( bInfo );// ownership is taken |
|
842 CleanupStack::Pop();// >> bInfo |
|
843 } |
|
844 |
|
845 DP_SDA("SubscribeBlockList complete request"); |
|
846 CompleteXIMPReq( KErrNone ); |
|
847 |
|
848 MXIMPDataSubscriptionState* myState = |
|
849 iConnObs.ObjectFactory().NewDataSubscriptionStateLC(); |
|
850 |
|
851 MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC(); |
|
852 |
|
853 // Notice: consider XIMP error codes |
|
854 myStatus->SetResultCode( KErrNone ); |
|
855 myState->SetSubscriptionStateL( |
|
856 MXIMPDataSubscriptionState::ESubscriptionInactive ); |
|
857 |
|
858 iDataHost->SetPresenceBlockDataSubscriptionStateL( |
|
859 myState, myStatus ); |
|
860 |
|
861 iDataHost->HandlePresenceBlockListL( coll ); |
|
862 //Callback for subscription result |
|
863 CleanupStack::Pop( 3 ); // >> myState, myStatus, coll |
|
864 CleanupStack::PopAndDestroy( &blocked ); |
|
865 DP_SDA("CPresencePluginAuthorization::SubscribeBlockList end"); |
|
866 } |
|
867 |
|
868 // --------------------------------------------------------------------------- |
|
869 // CPresencePluginAuthorization::UnSubscribeBlockListL() |
|
870 // --------------------------------------------------------------------------- |
|
871 // |
|
872 void CPresencePluginAuthorization::UnSubscribeBlockListL() |
|
873 { |
|
874 DP_SDA("CPresencePluginAuthorization::UnSubscribeBlockListL"); |
|
875 |
|
876 MXIMPObjectCollection* coll = |
|
877 iConnObs.ObjectFactory().NewObjectCollectionLC(); |
|
878 |
|
879 MXIMPDataSubscriptionState* myState = |
|
880 iConnObs.ObjectFactory().NewDataSubscriptionStateLC(); |
|
881 |
|
882 MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC(); |
|
883 |
|
884 myStatus->SetResultCode( KErrNone ); |
|
885 myState->SetSubscriptionStateL( |
|
886 MXIMPDataSubscriptionState::ESubscriptionInactive ); |
|
887 |
|
888 iDataHost->SetPresenceBlockDataSubscriptionStateL( |
|
889 myState, myStatus ); |
|
890 |
|
891 iDataHost->HandlePresenceBlockListL( coll ); |
|
892 |
|
893 CleanupStack::Pop( 3 ); |
|
894 |
|
895 CompleteXIMPReq( KErrNone ); |
|
896 |
|
897 DP_SDA("CPresencePluginAuthorization::UnSubscribeBlockListL end"); |
|
898 } |
|
899 |
|
900 // --------------------------------------------------------------------------- |
|
901 // CPresencePluginAuthorization::ReturnListSubsState() |
|
902 // --------------------------------------------------------------------------- |
|
903 // |
|
904 TBool CPresencePluginAuthorization::ReturnListSubsState() |
|
905 { |
|
906 return iSubscribed; |
|
907 } |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // CPresencePluginAuthorization::PluginData() |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 CPresencePluginData& CPresencePluginAuthorization::PluginData() |
|
914 { |
|
915 return *iPresenceData; |
|
916 } |
|
917 |
|
918 // --------------------------------------------------------------------------- |
|
919 // CPresencePluginAuthorization::HandleFullWinfoNotificationL |
|
920 // --------------------------------------------------------------------------- |
|
921 // |
|
922 void CPresencePluginAuthorization::HandleFullWinfoNotificationL( |
|
923 MSimpleWinfo& aWinfo ) |
|
924 { |
|
925 using namespace NPresencePlugin::NPresence; |
|
926 |
|
927 RPointerArray<MSimpleElement> elems; |
|
928 CleanupClosePushL( elems ); |
|
929 TInt err = aWinfo.SimpleElementsL( elems ); |
|
930 User::LeaveIfError( err ); |
|
931 TInt count = elems.Count(); |
|
932 |
|
933 MSimpleElement* elem = elems[0]; |
|
934 TPtrC8 p8 = elem->LocalName(); |
|
935 err = p8.CompareF( KPresenceWatcherList8 ); //watcher-list |
|
936 DP_SDA2("HandleFullWinfoNotificationL leave if watcherlist error %d", err); |
|
937 User::LeaveIfError( err ); |
|
938 |
|
939 err = elem->SimpleElementsL( elems ); |
|
940 DP_SDA2("HandleFullWinfoNotificationL error %d", err); |
|
941 User::LeaveIfError( err ); |
|
942 |
|
943 count = elems.Count(); |
|
944 DP_SDA("HandleFullWinfoNotificationL watcher list is valid"); |
|
945 |
|
946 // Search watchers who are pending (status = pending) |
|
947 HBufC* nodeContent = NULL; |
|
948 MXIMPObjectCollection *pendings = |
|
949 iConnObs.ObjectFactory().NewObjectCollectionLC(); |
|
950 |
|
951 TBool pendingFound(EFalse); |
|
952 |
|
953 for ( TInt i = 0; i < count; i++ ) |
|
954 { |
|
955 elem = elems[i]; |
|
956 p8.Set( elem->LocalName()); |
|
957 if (!( p8.CompareF( KPresenceWatcher8 ))) |
|
958 { |
|
959 const TDesC8* pp8 = elem->AttrValue( KPresenceStatus8 ); |
|
960 if ( pp8 && !pp8->CompareF( KPresencePending8 )) |
|
961 { |
|
962 DP_SDA("HandleFullWinfoNotificationL least one pending"); |
|
963 // Build collection of grant requests |
|
964 // Find the child node containing the SIP entity |
|
965 nodeContent = elem->ContentUnicodeL(); |
|
966 CleanupStack::PushL( nodeContent ); |
|
967 // create the collection entry here |
|
968 MPresenceGrantRequestInfo* grInfo = |
|
969 iConnObs.PresenceObjectFactoryOwn(). |
|
970 NewPresenceGrantRequestInfoLC(); |
|
971 MXIMPIdentity* identity = |
|
972 iConnObs.ObjectFactory().NewIdentityLC(); |
|
973 |
|
974 // Remove prefix to keep client side protocol agnostic |
|
975 HBufC16* withoutPrefix = iPresenceData->RemovePrefixLC( |
|
976 *nodeContent ); |
|
977 identity->SetIdentityL( *withoutPrefix ); |
|
978 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
979 |
|
980 grInfo->SetRequestorIdL( identity ); // ownership is taken |
|
981 |
|
982 pendings->AddObjectL( grInfo ); // ownership is taken |
|
983 pendingFound = ETrue; |
|
984 CleanupStack::Pop( 2 ); //grInfo, identity |
|
985 CleanupStack::PopAndDestroy( nodeContent ); |
|
986 } |
|
987 } |
|
988 } |
|
989 |
|
990 if ( pendingFound ) |
|
991 { |
|
992 DP_SDA("HandleFullWinfoNotificationL send pending"); |
|
993 iXIMPIdOwn = iDataHost->HandlePresenceGrantRequestListL( pendings ); |
|
994 CleanupStack::Pop(); // >> pendings |
|
995 } |
|
996 else |
|
997 { |
|
998 DP_SDA("HandleFullWinfoNotificationL pop pending"); |
|
999 CleanupStack::PopAndDestroy( ); // >> pendings |
|
1000 } |
|
1001 |
|
1002 CleanupStack::PopAndDestroy( &elems ); |
|
1003 DP_SDA("CPresencePluginAuthorization::HandleFullWinfoNotificationL END"); |
|
1004 } |
|
1005 |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // CPresencePluginAuthorization::HandlePartialWinfoNotificationL |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CPresencePluginAuthorization::HandlePartialWinfoNotificationL( |
|
1011 MSimpleWinfo& aWinfo ) |
|
1012 { |
|
1013 DP_SDA("CPresencePluginAuthorization::HandlePartialWinfoNotificationL"); |
|
1014 using namespace NPresencePlugin::NPresence; |
|
1015 |
|
1016 RPointerArray<MSimpleElement> elems; |
|
1017 CleanupClosePushL( elems ); |
|
1018 TInt err = aWinfo.SimpleElementsL( elems ); |
|
1019 User::LeaveIfError( err ); |
|
1020 TInt count = elems.Count(); |
|
1021 |
|
1022 MSimpleElement* elem = elems[0]; |
|
1023 TPtrC8 p8 = elem->LocalName(); |
|
1024 err = p8.CompareF( KPresenceWatcherList8 ); |
|
1025 User::LeaveIfError( err ); |
|
1026 |
|
1027 err = elem->SimpleElementsL( elems ); |
|
1028 User::LeaveIfError( err ); |
|
1029 count = elems.Count(); |
|
1030 |
|
1031 HBufC* nodeContent = NULL; |
|
1032 |
|
1033 for ( TInt i = 0; i < count; i++ ) |
|
1034 { |
|
1035 elem = elems[i]; |
|
1036 p8.Set( elem->LocalName()); |
|
1037 if (!( p8.CompareF( KPresenceWatcher8 ))) |
|
1038 { |
|
1039 const TDesC8* pp8 = elem->AttrValue( KPresenceStatus8 ); |
|
1040 if ( pp8 && !pp8->CompareF( KPresencePending8 )) |
|
1041 { |
|
1042 nodeContent = elem->ContentUnicodeL(); |
|
1043 CleanupStack::PushL( nodeContent ); |
|
1044 |
|
1045 // Remove prefix to keep client side protocol agnostic |
|
1046 HBufC16* withoutPrefix = iPresenceData->RemovePrefixLC( |
|
1047 *nodeContent ); |
|
1048 CallHandlePresenceGrantRequestReceivedL( *withoutPrefix ); |
|
1049 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
1050 CleanupStack::PopAndDestroy( nodeContent ); |
|
1051 } |
|
1052 else if ( pp8 && !pp8->CompareF( KPresenceTerminated8 )) |
|
1053 { |
|
1054 nodeContent = elem->ContentUnicodeL(); |
|
1055 CleanupStack::PushL( nodeContent ); |
|
1056 |
|
1057 // Remove prefix to keep client side protocol agnostic |
|
1058 HBufC16* withoutPrefix = iPresenceData->RemovePrefixLC( |
|
1059 *nodeContent ); |
|
1060 CallHandlePresenceGrantRequestObsoletedL( *withoutPrefix ); |
|
1061 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
1062 CleanupStack::PopAndDestroy( nodeContent ); |
|
1063 } |
|
1064 else if ( pp8 && !pp8->CompareF( KPresenceActive8 )) |
|
1065 { |
|
1066 DP_SDA( "CPresencePluginAuthorization::HandlePartialWinfoNotificationL presence active" ); |
|
1067 |
|
1068 nodeContent = elem->ContentUnicodeL(); |
|
1069 CleanupStack::PushL( nodeContent ); |
|
1070 TInt pos( 0 ); |
|
1071 if ( iConnObs.SubscribedContacts()-> |
|
1072 GetVirtualIdentityArray()->Find( *nodeContent, pos ) == 0 ) |
|
1073 { |
|
1074 HBufC8* buffer = HBufC8::NewLC( nodeContent->Length() ); |
|
1075 buffer->Des().Copy( *nodeContent ); |
|
1076 if ( !iConnObs.WatcherHandlerL()->MatchWatcherId( *buffer ) ) |
|
1077 { |
|
1078 DP_SDA( "CPresencePluginAuthorization::HandlePartialWinfoNotificationL -subscribe presence" ); |
|
1079 iConnObs.WatcherHandlerL()->SubscribeL( *nodeContent ); |
|
1080 } |
|
1081 CleanupStack::PopAndDestroy( buffer ); |
|
1082 } |
|
1083 CleanupStack::PopAndDestroy( nodeContent ); |
|
1084 } |
|
1085 } |
|
1086 } |
|
1087 CleanupStack::PopAndDestroy( &elems ); |
|
1088 DP_SDA("CPresencePluginAuthorization::HandlePartialWinfoNotificationL END"); |
|
1089 } |
|
1090 |
|
1091 // --------------------------------------------------------------------------- |
|
1092 // CPresencePluginAuthorization::CallHandlePresenceGrantRequestReceivedL |
|
1093 // --------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CPresencePluginAuthorization::CallHandlePresenceGrantRequestReceivedL( |
|
1096 const TDesC& aUserId ) |
|
1097 { |
|
1098 DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestReceivedL"); |
|
1099 // create the collection entry here |
|
1100 MPresenceGrantRequestInfo* grInfo = |
|
1101 iConnObs.PresenceObjectFactoryOwn().NewPresenceGrantRequestInfoLC(); |
|
1102 MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
1103 identity->SetIdentityL( aUserId ); |
|
1104 grInfo->SetRequestorIdL( identity ); // ownership is taken |
|
1105 CleanupStack::Pop( ); // -identity |
|
1106 |
|
1107 iDataHost->HandlePresenceGrantRequestReceivedL( grInfo );//ownership taken |
|
1108 CleanupStack::Pop( ); // -grInfo |
|
1109 DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestReceivedL END"); |
|
1110 } |
|
1111 |
|
1112 // --------------------------------------------------------------------------- |
|
1113 // CPresencePluginAuthorization::CallHandlePresenceGrantRequestObsoletedL |
|
1114 // --------------------------------------------------------------------------- |
|
1115 // |
|
1116 void CPresencePluginAuthorization::CallHandlePresenceGrantRequestObsoletedL( |
|
1117 const TDesC& aUserId ) |
|
1118 { |
|
1119 DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestObsoletedL"); |
|
1120 MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
1121 identity->SetIdentityL( aUserId ); |
|
1122 iDataHost->HandlePresenceGrantRequestObsoletedL( identity );//taken |
|
1123 CleanupStack::Pop( );// >> identity |
|
1124 DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestObsoletedL END"); |
|
1125 } |
|
1126 |
|
1127 // --------------------------------------------------------------------------- |
|
1128 // CPresencePluginAuthorization::GrantPresenceForPresentityL() |
|
1129 // --------------------------------------------------------------------------- |
|
1130 // |
|
1131 void CPresencePluginAuthorization::GrantPresenceForPresentityL() |
|
1132 { |
|
1133 iXdmUtils->AddEntityToGrantedL( |
|
1134 iPresIdentity->Des(), iStatus ); |
|
1135 SetActive(); |
|
1136 } |
|
1137 |
|
1138 // --------------------------------------------------------------------------- |
|
1139 // CPresencePluginAuthorization::WithdrawFromPresentityL() |
|
1140 // --------------------------------------------------------------------------- |
|
1141 // |
|
1142 void CPresencePluginAuthorization::WithdrawFromPresentityL() |
|
1143 { |
|
1144 iXdmUtils->RemoveEntityFromGrantedL( |
|
1145 iPresIdentity->Des(),iStatus ); |
|
1146 SetActive(); |
|
1147 } |
|
1148 |
|
1149 // --------------------------------------------------------------------------- |
|
1150 // CPresencePluginAuthorization::UnsubscribePresentityPresenceL() |
|
1151 // --------------------------------------------------------------------------- |
|
1152 // |
|
1153 void CPresencePluginAuthorization::UnsubscribePresentityPresenceL() |
|
1154 { |
|
1155 DP_SDA( "CPresencePluginAuthorization::UnsubscribePresentityPresence" ); |
|
1156 |
|
1157 MXIMPIdentity* identity = |
|
1158 iConnObs.ObjectFactory().NewIdentityLC(); |
|
1159 identity->SetIdentityL( iPresIdentity->Des() ); |
|
1160 iConnObs.WatcherHandlerL()-> |
|
1161 DoPerformUnsubscribePresentityPresenceL( *identity, iStatus ); |
|
1162 CleanupStack::PopAndDestroy(); // identity |
|
1163 SetActive(); |
|
1164 |
|
1165 DP_SDA( "CPresencePluginAuthorization::UnsubscribePresentityPresence -Exit" ); |
|
1166 } |
|
1167 |
|
1168 // --------------------------------------------------------------------------- |
|
1169 // CPresencePluginAuthorization::BlockPresentityL() |
|
1170 // --------------------------------------------------------------------------- |
|
1171 // |
|
1172 void CPresencePluginAuthorization::BlockPresentityL() |
|
1173 { |
|
1174 DP_SDA( "CPresencePluginAuthorization::BlockPresentityL" ); |
|
1175 // add entity to block list |
|
1176 iXdmUtils->AddEntityToBlockedL( |
|
1177 iPresIdentity->Des(), iStatus ); |
|
1178 SetActive(); |
|
1179 } |
|
1180 |
|
1181 // --------------------------------------------------------------------------- |
|
1182 // CPresencePluginAuthorization::BlockPresentityL() |
|
1183 // --------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CPresencePluginAuthorization::SetPresentityBlockedToXIMPL() |
|
1186 { |
|
1187 DP_SDA( "CPresencePluginAuthorization::SetPresentityBlockedToXIMPL" ); |
|
1188 |
|
1189 MPresenceBlockInfo* bInfo = |
|
1190 iConnObs.PresenceObjectFactoryOwn().NewPresenceBlockInfoLC(); |
|
1191 MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
1192 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity ); |
|
1193 identity->SetIdentityL( *withoutPrefix ); |
|
1194 bInfo->SetBlockedEntityIdL( identity ); // ownership is taken |
|
1195 // Write blocked state into the presence cache |
|
1196 TBuf<20> buf; |
|
1197 buf.Copy( KBlockedExtensionValue ); |
|
1198 iPresenceData->WriteStatusToCacheL( |
|
1199 *withoutPrefix, |
|
1200 MPresenceBuddyInfo2::EUnknownAvailability, |
|
1201 buf, |
|
1202 KNullDesC() ); |
|
1203 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
1204 iDataHost->HandlePresenceBlockedL( bInfo ); |
|
1205 CleanupStack::Pop();// >> identity |
|
1206 CleanupStack::Pop();// >> bInfo |
|
1207 |
|
1208 DP_SDA( "CPresencePluginAuthorization::SetPresentityBlockedToXIMPL -Exit" ); |
|
1209 } |
|
1210 |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // CPresencePluginAuthorization::UnblockPresentityL() |
|
1213 // --------------------------------------------------------------------------- |
|
1214 // |
|
1215 void CPresencePluginAuthorization::UnblockPresentityL() |
|
1216 { |
|
1217 DP_SDA( "CPresencePluginAuthorization::UnblockPresentityL" ); |
|
1218 |
|
1219 //remove entity from blocked list |
|
1220 iXdmUtils->RemoveEntityFromBlockedL( |
|
1221 iPresIdentity->Des(), iStatus ); |
|
1222 //remove enity from ximp blocked too |
|
1223 MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
1224 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity ); |
|
1225 identity->SetIdentityL( *withoutPrefix ); |
|
1226 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
1227 iDataHost->HandlePresenceBlockCanceledL( identity ); |
|
1228 CleanupStack::Pop();// >> identity |
|
1229 iAuthState = EStateDoUnBlock; |
|
1230 SetActive(); |
|
1231 |
|
1232 DP_SDA( "CPresencePluginAuthorization::UnblockPresentityL -Exit" ); |
|
1233 } |
|
1234 |
|
1235 // End of file |
|