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