1 /* |
|
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: IETF SIMPLE Protocol implementation for XIMP Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <utf.h> |
|
21 #include <e32test.h> |
|
22 #include <ximpobjectfactory.h> |
|
23 #include <presenceobjectfactory.h> |
|
24 #include <ximpidentity.h> |
|
25 #include <ximpobjectcollection.h> |
|
26 #include <presentitygroupinfo.h> |
|
27 #include <presentitygroupmemberinfo.h> |
|
28 #include <XdmEngine.h> |
|
29 #include <XdmDocument.h> |
|
30 #include <XdmProtocolInfo.h> |
|
31 #include <XdmDocumentNode.h> |
|
32 #include <XdmNodeAttribute.h> |
|
33 #include <XdmErrors.h> |
|
34 #include <pressettingsapi.h> //for TPresSettingsSet |
|
35 #include <XdmSettingsApi.h> |
|
36 #include <XdmProtocolUidList.h> |
|
37 #include <avabilitytext.h> |
|
38 |
|
39 #include "presencepluginxdmpresrules.h" |
|
40 #include "mpresencepluginconnectionobs.h" |
|
41 #include "presenceplugincommon.h" |
|
42 #include "presencepluginxdmutils.h" |
|
43 #include "presencepluginvirtualgroup.h" |
|
44 #include "presencepluginauthorization.h" |
|
45 #include "presenceplugindata.h" |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CPresencePluginXdmUtils::CPresencePluginXdmUtils() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CPresencePluginXdmUtils::CPresencePluginXdmUtils( |
|
54 MPresencePluginConnectionObs& aObs , TInt aXmdId, TBool aLocalmode ) |
|
55 : CActive( CActive::EPriorityStandard ), |
|
56 iConnObs(aObs), iSettingsId(aXmdId), |
|
57 iXdmState(EStateIdle), iOperation( ENoOperation ), |
|
58 iPresXdmOk( EFalse ), iXdmOk( EFalse ), |
|
59 iRulesUpdateState(EStateNoOperation), iLocalMode( aLocalmode ) |
|
60 { |
|
61 CActiveScheduler::Add( this ); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CPresencePluginXdmUtils::ConstructL() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CPresencePluginXdmUtils::ConstructL( ) |
|
69 { |
|
70 |
|
71 //If we are in normalmode we need presence rules too |
|
72 if ( !iLocalMode ) |
|
73 { |
|
74 DP_SDA("CPresencePluginXdmUtils::ConstructL NormalMode"); |
|
75 iXdmPresRules = CPresencePluginXdmPresRules::NewL( |
|
76 iSettingsId, EFalse ); |
|
77 } |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CPresencePluginXdmUtils::NewL() |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CPresencePluginXdmUtils* CPresencePluginXdmUtils::NewL( |
|
85 MPresencePluginConnectionObs& aObs, TInt aXmdId, TBool aLocalmode ) |
|
86 { |
|
87 CPresencePluginXdmUtils* self = |
|
88 new( ELeave ) CPresencePluginXdmUtils( aObs, aXmdId, aLocalmode ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL( ); |
|
91 CleanupStack::Pop( self ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CPresencePluginXdmUtils::~CPresencePluginXdmUtils() |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CPresencePluginXdmUtils::~CPresencePluginXdmUtils() |
|
100 { |
|
101 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils"); |
|
102 if ( iXdmDoc ) |
|
103 { |
|
104 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 1"); |
|
105 if (iXdmEngine) |
|
106 { |
|
107 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils del doc"); |
|
108 TRAP_IGNORE( iXdmEngine->DeleteDocumentModelL( iXdmDoc )); |
|
109 } |
|
110 } |
|
111 |
|
112 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 3"); |
|
113 delete iXdmEngine; |
|
114 iXdmEngine = NULL; |
|
115 |
|
116 |
|
117 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 4"); |
|
118 delete iXdmPresRules; |
|
119 iXdmPresRules = NULL; |
|
120 |
|
121 |
|
122 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 5"); |
|
123 delete iEntityUri; |
|
124 iEntityUri = NULL; |
|
125 |
|
126 iBlockedContacts.ResetAndDestroy(); |
|
127 |
|
128 DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils end"); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CPresencePluginXdmUtils::InitializeXdmL() |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CPresencePluginXdmUtils::InitializeXdmL( TRequestStatus& aStatus ) |
|
136 { |
|
137 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL"); |
|
138 |
|
139 aStatus = KRequestPending; |
|
140 iClientStatus = &aStatus; |
|
141 |
|
142 // if resource-list not ready |
|
143 if ( !iXdmOk ) |
|
144 { |
|
145 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL !iXdmOk"); |
|
146 if ( !iLocalMode ) |
|
147 { |
|
148 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL NormalMode"); |
|
149 GetXdmListsL( ETrue, EFalse ); |
|
150 } |
|
151 else |
|
152 { |
|
153 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL LocalMode"); |
|
154 GetXdmListsL( ETrue, ETrue ); |
|
155 } |
|
156 } |
|
157 else if ( !iPresXdmOk && !iLocalMode ) |
|
158 { |
|
159 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL !iPresXdmOk"); |
|
160 GetXdmRulesL(); |
|
161 } |
|
162 else |
|
163 { |
|
164 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL All is OK "); |
|
165 // All is ok |
|
166 DP_SDA("CPresencePluginXdmUtils::InitializeXdmL SEND COMPLETE") |
|
167 CompleteClientReq( KErrNone ); |
|
168 } |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CPresencePluginXdmUtils::InitializeXdmL() |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CPresencePluginXdmUtils::InitializePresRulesL( ) |
|
176 { |
|
177 DP_SDA("CPresencePluginXdmUtils:: MakeInitialRules"); |
|
178 iXdmState = ECreateXdmRules; |
|
179 iRulesUpdateState = EStateInitializeRules; |
|
180 iXdmPresRules->MakeInitialRulesDocumentL( this ); |
|
181 UpdateXdmRulesL(); |
|
182 DP_SDA("CPresencePluginXdmUtils:: MakeInitialRules done"); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CPresencePluginXdmUtils::GetXdmRulesL() |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CPresencePluginXdmUtils::GetXdmRulesL() |
|
190 { |
|
191 DP_SDA("CPresencePluginXdmUtils:: GetXdmRulesL"); |
|
192 |
|
193 if ( !iXdmPresRules ) |
|
194 { |
|
195 // get data from a network if not done so yet |
|
196 if ( !iLocalMode ) |
|
197 { |
|
198 iXdmPresRules = CPresencePluginXdmPresRules::NewL( |
|
199 iSettingsId, EFalse ); |
|
200 } |
|
201 else |
|
202 { |
|
203 /*localmode*/ |
|
204 //iXdmPresRules |
|
205 //= CPresencePluginXdmPresRules::NewL( iSettingsId, ETrue ); |
|
206 } |
|
207 } |
|
208 |
|
209 if( !iLocalMode && iXdmPresRules ) |
|
210 { |
|
211 User::LeaveIfError( iXdmPresRules->UpdateFromServerL( this )); |
|
212 } |
|
213 iXdmState = EGetXdmRules; |
|
214 DP_SDA("CPresencePluginXdmUtils:: GetXdmRulesL done"); |
|
215 DP_SDA("CPresencePluginXdmUtils::GetXdmRulesL - add buddies to virtual"); |
|
216 AddIdentityToVirtualListL( KPresenceBuddyList ); |
|
217 |
|
218 DP_SDA("CPresencePluginXdmUtils::GetXdmRulesL - add blocked to virtual"); |
|
219 AddIdentityToVirtualListL( KPresenceBlockedList ); |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CPresencePluginXdmUtils::InitializeXdmsOnlyL() |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 void CPresencePluginXdmUtils::InitializeXdmsOnlyL( TRequestStatus& aStatus ) |
|
227 { |
|
228 DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL"); |
|
229 aStatus = KRequestPending; |
|
230 iClientStatus = &aStatus; |
|
231 |
|
232 if ( !iXdmOk ) |
|
233 { |
|
234 DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL 1"); |
|
235 GetXdmListsL( EFalse, EFalse ); |
|
236 } |
|
237 else |
|
238 { |
|
239 DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL all ok"); |
|
240 // All is ok |
|
241 DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL SEND COMPLETE") |
|
242 CompleteClientReq( KErrNone ); |
|
243 } |
|
244 DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL end"); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CPresencePluginXdmUtils::CheckXdmDoc() |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 TBool CPresencePluginXdmUtils::CheckXdmDoc() |
|
252 { |
|
253 DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc"); |
|
254 |
|
255 if ( iXdmDoc ) |
|
256 { |
|
257 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
258 DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc2"); |
|
259 if( root ) |
|
260 { |
|
261 TInt count = root->NodeCount(); |
|
262 DP_SDA2("CPresencePluginXdmUtils::CheckXdmDoc count %d", count); |
|
263 if ( !count ) |
|
264 { |
|
265 DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc NotFound"); |
|
266 iXdmOk = EFalse; |
|
267 } |
|
268 else |
|
269 { |
|
270 DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc file ok"); |
|
271 iXdmOk = ETrue; |
|
272 } |
|
273 } |
|
274 } |
|
275 else |
|
276 { |
|
277 DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc file False"); |
|
278 iXdmOk = EFalse; |
|
279 } |
|
280 |
|
281 return iXdmOk; |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // CPresencePluginXdmUtils::CheckIfError |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CPresencePluginXdmUtils::CheckIfErrorL( TInt aMyStatus ) |
|
289 { |
|
290 TInt myStatus = aMyStatus; |
|
291 DP_SDA2("CPresencePluginXdmUtils::CheckIfError ErrorCode %d ", myStatus); |
|
292 if ( myStatus == KErrTimedOut ) |
|
293 { |
|
294 DP_SDA("CPresencePluginXdmUtils::CheckIfError TimeOut error"); |
|
295 myStatus = KErrTimedOut; |
|
296 User::Leave( KErrTimedOut ); |
|
297 } |
|
298 else if ( myStatus == KErrCouldNotConnect || |
|
299 myStatus == KXcapErrorNetworkNotAvailabe ) |
|
300 { |
|
301 DP_SDA("CheckIfError KErrCouldNotConnect error"); |
|
302 myStatus = aMyStatus; |
|
303 } |
|
304 else if ( myStatus == KXcapErrorHttpNotFound ) |
|
305 { |
|
306 DP_SDA("CheckIfError KXcapErrorHttpNotFound"); |
|
307 myStatus = aMyStatus; |
|
308 } |
|
309 else if ( myStatus == KXcapErrorAuthentication ) |
|
310 { |
|
311 DP_SDA("CPresencePluginXdmUtils::CheckIfError auth error"); |
|
312 myStatus = aMyStatus; |
|
313 } |
|
314 else if ( myStatus == KXcapErrorTooManyOccurencies ) |
|
315 { |
|
316 DP_SDA("CPresencePluginXdmUtils KXcapErrorTooManyOccurencies"); |
|
317 myStatus = 0; |
|
318 } |
|
319 else if( myStatus == KErrDisconnected ) |
|
320 { |
|
321 myStatus = aMyStatus; |
|
322 User::Leave( KErrCancel ); |
|
323 } |
|
324 else if( myStatus == KXcapErrorHttpPrecondFailed ) |
|
325 { |
|
326 DP_SDA("CheckIfError KXcapErrorHttpPrecondFailed"); |
|
327 myStatus = aMyStatus; |
|
328 } |
|
329 else if ( KErrNoMemory == myStatus ) |
|
330 { |
|
331 DP_SDA("CheckIfError KErrNoMemory"); |
|
332 User::Leave( KErrNoMemory ); |
|
333 } |
|
334 else |
|
335 { |
|
336 DP_SDA("CPresencePluginXdmUtils::CheckIfError ERROR"); |
|
337 myStatus = aMyStatus; |
|
338 } |
|
339 return myStatus; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CPresencePluginXdmUtils::RunL() |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CPresencePluginXdmUtils::RunL( ) |
|
347 { |
|
348 DP_SDA("CPresencePluginXdmUtils::RunL"); |
|
349 TPluginXdmState origState = iXdmState; |
|
350 iXdmState = EStateIdle; |
|
351 TInt myStatus = iStatus.Int(); |
|
352 |
|
353 DP_SDA2("CPresencePluginXdmUtils::RunL mystatus %d ", myStatus); |
|
354 DP_SDA2("CPresencePluginXdmUtils::RunL state %d ", origState); |
|
355 DP_SDA2("CPresencePluginXdmUtils:: ClientStatus %d",iClientStatus->Int() ); |
|
356 |
|
357 if ( myStatus == KErrCancel ) |
|
358 { |
|
359 DP_SDA("CPresencePluginXdmUtils::RunL CANCEL SEND COMPLETE") |
|
360 CompleteClientReq( KErrCancel ); |
|
361 } |
|
362 |
|
363 switch ( origState ) |
|
364 { |
|
365 case EGetXdmLists: |
|
366 case EGetXdmListsOnly: |
|
367 { |
|
368 DoGetXdmListsL( myStatus, origState ); |
|
369 } |
|
370 break; |
|
371 |
|
372 case ECreateXdmLists: |
|
373 { |
|
374 DoCreateXdmListsL( myStatus, origState, EFalse ); |
|
375 } |
|
376 break; |
|
377 |
|
378 case ECreateXdmListsOnly: |
|
379 { |
|
380 DoCreateXdmListsL( myStatus, origState, ETrue ); |
|
381 } |
|
382 break; |
|
383 |
|
384 case EGetXdmBlockList: |
|
385 { |
|
386 DP_SDA("RunL EGetXdmBlockList SEND COMPLETE"); |
|
387 CompleteClientReq( KErrNone ); |
|
388 } |
|
389 break; |
|
390 |
|
391 case EUpdateXdmList: |
|
392 { |
|
393 DoUpdateXdmListsL( myStatus, origState ); |
|
394 } |
|
395 break; |
|
396 |
|
397 case EUpdateBlockedContactPresenceCache: |
|
398 DoUpdateBlockedContactPresenceCacheL( myStatus ); |
|
399 break; |
|
400 |
|
401 default: |
|
402 { |
|
403 DP_SDA("CPresencePluginXdmUtils::RunL last else"); |
|
404 //check myStatus error |
|
405 myStatus = CheckIfErrorL( myStatus ); |
|
406 |
|
407 if ( myStatus ) |
|
408 { |
|
409 // complete reqular request |
|
410 DP_SDA("CPresencePluginXdmUtils::RunL SEND LAST COMPLETE"); |
|
411 CompleteClientReq( myStatus ); |
|
412 } |
|
413 DP_SDA("CPresencePluginXdmUtils::RunL default end") |
|
414 } |
|
415 break; |
|
416 |
|
417 } |
|
418 DP_SDA("CPresencePluginXdmUtils::RunL end"); |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // CPresencePluginXdmUtils::DoUpdateXdmLists() |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 void CPresencePluginXdmUtils::DoUpdateXdmListsL( |
|
426 TInt aMyStatus, |
|
427 TPluginXdmState /*aOrigState*/) |
|
428 { |
|
429 DP_SDA("CPresencePluginXdmUtils::DoUpdateXdmLists EUpdateXdmList"); |
|
430 if ( !iLocalMode ) |
|
431 { |
|
432 DP_SDA("CPresencePluginXdmUtils::DoUpdateXdmLists updaterules"); |
|
433 if( aMyStatus ) |
|
434 { |
|
435 DP_SDA("DoUpdateXdmLists updaterules error"); |
|
436 aMyStatus = CheckIfErrorL( aMyStatus ); |
|
437 CompleteClientReq( aMyStatus ); |
|
438 } |
|
439 else |
|
440 { |
|
441 DP_SDA("DoUpdateXdmLists updaterules else"); |
|
442 UpdateXdmRulesL(); |
|
443 } |
|
444 } |
|
445 else |
|
446 { |
|
447 DP_SDA("EUpdateXdmList LOCALMODE SEND COMPLETE"); |
|
448 aMyStatus = CheckIfErrorL( aMyStatus ); |
|
449 CompleteClientReq( aMyStatus ); |
|
450 } |
|
451 iRulesUpdateState = EStateNoOperation; |
|
452 DP_SDA("CPresencePluginXdmUtils::DoUpdateXdmLists EUpdateXdmList end"); |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // CPresencePluginXdmUtils::DoCreateXdmLists() |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 void CPresencePluginXdmUtils::DoCreateXdmListsL( |
|
460 TInt aMyStatus, |
|
461 TPluginXdmState /*aOrigState*/, |
|
462 TBool aOnlyResourceList ) |
|
463 { |
|
464 DP_SDA("CPresencePluginXdmUtils::DoCreateXdmListsL ECreateXdmLists"); |
|
465 //check myStatus error |
|
466 aMyStatus = CheckIfErrorL( aMyStatus ); |
|
467 if( !aOnlyResourceList ) |
|
468 { |
|
469 if ( aMyStatus ) |
|
470 { |
|
471 DP_SDA("DoCreateXdmLists ECreateXdmLists SEND COMPLETE"); |
|
472 CompleteClientReq( aMyStatus ); |
|
473 } |
|
474 else if ( !iLocalMode ) |
|
475 { |
|
476 DP_SDA("ECreateXdmLists !myStatus GetXdmRules"); |
|
477 iXdmOk = ETrue; |
|
478 GetXdmRulesL(); |
|
479 } |
|
480 else if ( iLocalMode ) |
|
481 { |
|
482 DP_SDA("DoCreateXdmLists ECreateXdmLists SEND COMPLETE 2"); |
|
483 iXdmOk = ETrue; |
|
484 CompleteClientReq( aMyStatus ); |
|
485 } |
|
486 } |
|
487 else |
|
488 { |
|
489 //check myStatus error |
|
490 aMyStatus = CheckIfErrorL( aMyStatus ); |
|
491 if ( aMyStatus == KErrTimedOut ) |
|
492 { |
|
493 DP_SDA("DoCreateXdmLists EGetXdmListsOnly 1"); |
|
494 aMyStatus = 0; |
|
495 } |
|
496 if ( !aMyStatus ) |
|
497 { |
|
498 DP_SDA("DoCreateXdmLists EGetXdmListsOnly 2"); |
|
499 iXdmOk = ETrue; |
|
500 } |
|
501 |
|
502 if( !(KXcapErrorNetworkNotAvailabe == aMyStatus || |
|
503 KErrCouldNotConnect == aMyStatus ) ) |
|
504 { |
|
505 DP_SDA("DoCreateXdmLists EGetXdmListsOnly SEND COMPLETE"); |
|
506 CompleteClientReq( aMyStatus ); |
|
507 } |
|
508 } |
|
509 DP_SDA("CPresencePluginXdmUtils::DoCreateXdmListsL ECreateXdmLists end"); |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // CPresencePluginXdmUtils::DoGetXdmLists() |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 void CPresencePluginXdmUtils::DoGetXdmListsL( |
|
517 TInt aMyStatus, |
|
518 TPluginXdmState aOrigState ) |
|
519 { |
|
520 DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists EGetXdmLists"); |
|
521 //check myStatus error |
|
522 aMyStatus = CheckIfErrorL( aMyStatus ); |
|
523 |
|
524 if ( aMyStatus )//Check is file includes nodes |
|
525 { |
|
526 DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists CreateXDM"); |
|
527 // no resource-list, let's start to create it. |
|
528 CreateXdmListsL( ETrue ); |
|
529 } |
|
530 else |
|
531 { |
|
532 DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists EGetXdmLists else"); |
|
533 if( iLocalMode ) |
|
534 { |
|
535 //Check if document empty |
|
536 TBool empty = CheckXdmDoc(); |
|
537 if( !empty ) |
|
538 { |
|
539 CreateXdmListsL( ETrue ); |
|
540 } |
|
541 else |
|
542 { |
|
543 iXdmOk = ETrue; |
|
544 DP_SDA("DoGetXdmLists Localmode SEND COMPLETE"); |
|
545 CompleteClientReq( KErrNone ); |
|
546 } |
|
547 } |
|
548 else |
|
549 { |
|
550 iXdmOk = ETrue; |
|
551 if ( !iPresXdmOk && !iLocalMode && aOrigState == EGetXdmLists ) |
|
552 { |
|
553 DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists GetXDM"); |
|
554 GetXdmRulesL(); |
|
555 } |
|
556 else |
|
557 { |
|
558 DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists SEND COMPLETE"); |
|
559 CompleteClientReq( KErrNone ); |
|
560 } |
|
561 } |
|
562 } |
|
563 DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists end"); |
|
564 } |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // CPresencePluginXdmUtils::DoCancel() |
|
568 // --------------------------------------------------------------------------- |
|
569 // |
|
570 void CPresencePluginXdmUtils::DoCancel( ) |
|
571 { |
|
572 DP_SDA("CPresencePluginXdmUtils::DoCancel"); |
|
573 iOperation = EXdmCancel; |
|
574 |
|
575 if ( iXdmState == EGetXdmLists || iXdmState == ECreateXdmLists || |
|
576 iXdmState == EUpdateXdmRules || iXdmState == EUpdateXdmList || |
|
577 iXdmState == EGetXdmBlockList || iXdmState == ECreateXdmRules || |
|
578 iXdmState == ESubsBlockList || |
|
579 iXdmState == EGetResourceListFromServer || |
|
580 iXdmState == EGetXdmListsOnly || iXdmState == ECreateXdmListsOnly ) |
|
581 { |
|
582 DP_SDA("CPresencePluginXdmUtils::DoCancel list get or create"); |
|
583 iXdmState = ECancelDocument; |
|
584 iXdmEngine->CancelUpdate( iXdmDoc ); |
|
585 // cancel presrules too |
|
586 iXdmPresRules->Cancel(); |
|
587 } |
|
588 else |
|
589 { |
|
590 iStatus = KRequestPending; |
|
591 TRequestStatus* s= &iStatus; |
|
592 DP_SDA("CPresencePluginXdmUtils::DoCancel SEND COMPLETE"); |
|
593 User::RequestComplete( s, KErrCancel ); |
|
594 } |
|
595 } |
|
596 |
|
597 // --------------------------------------------------------------------------- |
|
598 // CPresencePluginXdmUtils::RunError() |
|
599 // --------------------------------------------------------------------------- |
|
600 // |
|
601 TInt CPresencePluginXdmUtils::RunError( TInt aError ) |
|
602 { |
|
603 DP_SDA("CPresencePluginXdmUtils::RunError"); |
|
604 // complete the open request |
|
605 CompleteClientReq( aError ); |
|
606 return KErrNone; |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // CPresencePluginXdmUtils::AddEntityToGrantedL() |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 void CPresencePluginXdmUtils::AddEntityToGrantedL( |
|
614 const TDesC& aUri, |
|
615 TRequestStatus& aStatus ) |
|
616 { |
|
617 DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL"); |
|
618 DP_SDA2("CPresencePluginXdmUtils::AddEntityToGrantedL, uri: %S", &aUri ); |
|
619 |
|
620 TRAPD( err, iEntityUri = aUri.AllocL() ); |
|
621 DP_SDA2(" AddEntityToGrantedL, uri alloc err: %d", err ); |
|
622 |
|
623 //Add entity to virtualGroup |
|
624 iConnObs.SubscribedContacts()->AddEntityL( iEntityUri->Des() ); |
|
625 |
|
626 if ( !err ) |
|
627 { |
|
628 DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL !err"); |
|
629 iXdmState = EUpdateXdmList; |
|
630 iClientStatus = &aStatus; |
|
631 iOperation = EXdmAddUserToGroup; |
|
632 iRulesUpdateState = EStateAddToWhiteList; |
|
633 |
|
634 //add user to resouce-list list |
|
635 DoAddUserToListL( KPresenceBuddyList, aUri ); |
|
636 DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL 1"); |
|
637 UpdateXdmsL(); |
|
638 |
|
639 *iClientStatus = KRequestPending; |
|
640 DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL end"); |
|
641 } |
|
642 else |
|
643 { |
|
644 DP_SDA("AddEntityToGrantedL else error SEND COMPLETE"); |
|
645 //If error we can complete request |
|
646 CompleteClientReq( KErrNone ); |
|
647 } |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // CPresencePluginXdmUtils::AddEntityToBlockedL() |
|
652 // --------------------------------------------------------------------------- |
|
653 // |
|
654 void CPresencePluginXdmUtils::AddEntityToBlockedL( |
|
655 const TDesC& aUri, |
|
656 TRequestStatus& aStatus ) |
|
657 { |
|
658 DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL"); |
|
659 iClientStatus = &aStatus; |
|
660 |
|
661 if( iLocalMode ) |
|
662 { |
|
663 //Block is not used in localmode |
|
664 DP_SDA("AddEntityToBlockedL localmode rules not support"); |
|
665 CompleteClientReq( KErrNotSupported ); |
|
666 } |
|
667 else |
|
668 { |
|
669 DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL !localmode"); |
|
670 TRAPD(err, iEntityUri = aUri.AllocL() ); |
|
671 //Remove entity form subscribed virtual group |
|
672 iConnObs.SubscribedContacts()->RemoveEntityL( iEntityUri->Des() ); |
|
673 |
|
674 if ( !err ) |
|
675 { |
|
676 DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL no error"); |
|
677 iXdmState = EUpdateXdmList; |
|
678 iOperation = EXdmAddUserToGroup; |
|
679 iRulesUpdateState = EStateAddToBlockList; |
|
680 |
|
681 DoAddUserToListL( KPresenceBlockedList, aUri ); |
|
682 UpdateXdmsL(); |
|
683 |
|
684 *iClientStatus = KRequestPending; |
|
685 DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL ready"); |
|
686 } |
|
687 else |
|
688 { |
|
689 //If error we can complete request |
|
690 DP_SDA("AddEntityToBlockedL SEND COMPLETE"); |
|
691 CompleteClientReq( KErrNone ); |
|
692 } |
|
693 } |
|
694 DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL end"); |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // CPresencePluginXdmUtils::DoAddUserToListL() |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 void CPresencePluginXdmUtils::DoAddUserToListL( |
|
702 const TDesC& aList, |
|
703 const TDesC& aUri ) |
|
704 { |
|
705 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL"); |
|
706 DP_SDA2("CPresencePluginXdmUtils::DoAddUserToListL aList: %S", &aList); |
|
707 DP_SDA2("CPresencePluginXdmUtils::DoAddUserToListL aUri: %S", &aUri); |
|
708 |
|
709 using namespace NPresencePlugin::NPresence; |
|
710 |
|
711 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
712 CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList ); |
|
713 |
|
714 if ( foundNode ) |
|
715 { |
|
716 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL found"); |
|
717 if ( !CheckIfEnityExistL( aList, aUri ) ) |
|
718 { |
|
719 DP_SDA("DoAddUserToListL entity not exist"); |
|
720 if ( foundNode->IsEmptyNode() ) |
|
721 { |
|
722 DP_SDA("DoAddUserToListL IsEmptyNode"); |
|
723 foundNode->SetEmptyNode( EFalse ); |
|
724 } |
|
725 |
|
726 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL newNode"); |
|
727 CXdmDocumentNode* newNode = |
|
728 foundNode->CreateChileNodeL( KPresenceEntry ); |
|
729 DP_SDA("DoAddUserToListL entry attribute"); |
|
730 CXdmNodeAttribute* attributeEntryUri = |
|
731 newNode->CreateAttributeL( KPresenceUri ); |
|
732 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL set entry"); |
|
733 attributeEntryUri->SetAttributeValueL( aUri ); |
|
734 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL Append"); |
|
735 iXdmDoc->AppendL( ); |
|
736 } |
|
737 } |
|
738 else |
|
739 { |
|
740 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL leave"); |
|
741 User::Leave( KErrNotFound ); |
|
742 } |
|
743 DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL end"); |
|
744 } |
|
745 |
|
746 // --------------------------------------------------------------------------- |
|
747 // CPresencePluginXdmUtils::CheckIfEnityExistL |
|
748 // --------------------------------------------------------------------------- |
|
749 // |
|
750 TBool CPresencePluginXdmUtils::CheckIfEnityExistL( |
|
751 const TDesC& aList, |
|
752 const TDesC& aUri ) |
|
753 { |
|
754 DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist"); |
|
755 |
|
756 using namespace NPresencePlugin::NPresence; |
|
757 |
|
758 CXdmNodeAttribute* attr = NULL; |
|
759 RPointerArray<CXdmDocumentNode> nodes; |
|
760 CleanupClosePushL( nodes ); |
|
761 TBool state( EFalse ); |
|
762 |
|
763 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
764 CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList ); |
|
765 |
|
766 if ( foundNode ) |
|
767 { |
|
768 DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist check nodes"); |
|
769 TInt findErr = foundNode->Find( KPresenceEntry, nodes ); |
|
770 DP_SDA2("CheckIfEnityExist - findErr: %d", findErr ); |
|
771 |
|
772 if ( findErr ) |
|
773 { |
|
774 DP_SDA("CheckIfEnityExist Enity not exist "); |
|
775 state = EFalse; |
|
776 } |
|
777 else |
|
778 { |
|
779 DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist Else"); |
|
780 TInt nodeCount = nodes.Count(); |
|
781 for ( TInt i = 0; i < nodeCount; i++ ) |
|
782 { |
|
783 CXdmDocumentNode* currNode = nodes[i]; |
|
784 attr = ( currNode )->Attribute( KPresenceUri ); |
|
785 |
|
786 TBool uriMatch( EFalse ); |
|
787 uriMatch = CompareUriWithoutPrefixL( |
|
788 aUri, attr->AttributeValue() ); |
|
789 |
|
790 if ( attr && uriMatch ) |
|
791 { |
|
792 DP_SDA("CheckIfEnityExist entity exists"); |
|
793 //Enity is exist |
|
794 state = ETrue; |
|
795 break; |
|
796 } |
|
797 } |
|
798 } |
|
799 } |
|
800 DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist Destroy nodes"); |
|
801 CleanupStack::PopAndDestroy( &nodes ); // >>> nodes |
|
802 return state; |
|
803 } |
|
804 |
|
805 // --------------------------------------------------------------------------- |
|
806 // CPresencePluginXdmUtils::SearchListUnderParentL |
|
807 // --------------------------------------------------------------------------- |
|
808 // |
|
809 CXdmDocumentNode* CPresencePluginXdmUtils::SearchListUnderParentL( |
|
810 CXdmDocumentNode* aParent, |
|
811 const TDesC& aName ) |
|
812 { |
|
813 DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL"); |
|
814 |
|
815 using namespace NPresencePlugin::NPresence; |
|
816 |
|
817 if ( !aParent ) |
|
818 { |
|
819 DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL return NULL"); |
|
820 return NULL; |
|
821 } |
|
822 |
|
823 RPointerArray<CXdmDocumentNode> resultArray; |
|
824 RPointerArray<SXdmAttribute16> attributeArray; |
|
825 |
|
826 CleanupClosePushL( resultArray ); // <<< resultArray |
|
827 CleanupClosePushL( attributeArray ); // <<< attributeArray |
|
828 |
|
829 SXdmAttribute16 attr; |
|
830 attr.iName.Set( KPresenceName ); |
|
831 attr.iValue.Set( aName ); |
|
832 attributeArray.AppendL( &attr ); |
|
833 |
|
834 CXdmDocumentNode* currNode = NULL; |
|
835 |
|
836 aParent->Find( KPresenceList, resultArray, attributeArray ); |
|
837 |
|
838 TInt count = resultArray.Count(); |
|
839 DP_SDA2("SearchListUnderParentL node count %d",count); |
|
840 for ( TInt i=0; i < count; i++ ) |
|
841 { |
|
842 currNode = resultArray[i]; |
|
843 CXdmDocumentNode* parent = currNode->Parent(); |
|
844 if ( parent == aParent ) |
|
845 { |
|
846 DP_SDA("SearchListUnderParentL parent MATCH"); |
|
847 break; |
|
848 } |
|
849 currNode = NULL; |
|
850 } |
|
851 |
|
852 CleanupStack::PopAndDestroy( &attributeArray); // >>> attributeArray |
|
853 CleanupStack::PopAndDestroy( &resultArray ); // >>> resultArray |
|
854 DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL return"); |
|
855 return currNode; |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // CPresencePluginXdmUtils::RemoveEntityFromGrantedL() |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 void CPresencePluginXdmUtils::RemoveEntityFromGrantedL( |
|
863 const TDesC& aUri, |
|
864 TRequestStatus& aStatus ) |
|
865 { |
|
866 DP_SDA("CPresencePluginXdmUtils::RemoveEntityFromGrantedL"); |
|
867 |
|
868 iEntityUri = aUri.AllocL(); |
|
869 iConnObs.SubscribedContacts()->RemoveEntityL( iEntityUri->Des() ); |
|
870 |
|
871 iClientStatus = &aStatus; |
|
872 *iClientStatus = KRequestPending; |
|
873 |
|
874 iRulesUpdateState = EStateRemoveFromWhiteList; |
|
875 iOperation = EXdmRemoveUserFromGroup; |
|
876 |
|
877 TRAPD( err, DoRemoveUserFromListL( KPresenceBuddyList, aUri ) ); |
|
878 |
|
879 if ( !err ) |
|
880 { |
|
881 // send to the server and start wait a response |
|
882 UpdateXdmsL(); |
|
883 iXdmState = EUpdateXdmList; |
|
884 } |
|
885 else |
|
886 { |
|
887 //complete request with error |
|
888 DP_SDA2( "RemoveEntityFromGrantedL -DoRemoveUserFromListL error = %d", err ); |
|
889 CompleteClientReq( err ); |
|
890 } |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------------------------- |
|
894 // CPresencePluginXdmUtils::RemoveEntityFromBlockedL() |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 void CPresencePluginXdmUtils::RemoveEntityFromBlockedL( |
|
898 const TDesC& aUri, |
|
899 TRequestStatus& aStatus ) |
|
900 { |
|
901 DP_SDA("CPresencePluginXdmUtils::RemoveEntityFromBlockedL"); |
|
902 TRAPD(err, iEntityUri = aUri.AllocL() ); |
|
903 |
|
904 if ( !err ) |
|
905 { |
|
906 iClientStatus = &aStatus; |
|
907 iRulesUpdateState = EStateRemoveFromBlackList; |
|
908 iOperation = EXdmRemoveUserFromGroup; |
|
909 |
|
910 DoRemoveUserFromListL( KPresenceBlockedList, aUri ); |
|
911 // send to the server and start wait a response |
|
912 UpdateXdmsL(); |
|
913 iXdmState = EUpdateXdmList; |
|
914 *iClientStatus = KRequestPending; |
|
915 } |
|
916 else |
|
917 { |
|
918 //If error we can complete request |
|
919 DP_SDA("RemoveEntityFromBlockedL SEND COMPLETE"); |
|
920 CompleteClientReq( KErrNone ); |
|
921 } |
|
922 } |
|
923 |
|
924 // --------------------------------------------------------------------------- |
|
925 // CPresencePluginXdmUtils::DoRemoveUserFromListL() |
|
926 // --------------------------------------------------------------------------- |
|
927 // |
|
928 void CPresencePluginXdmUtils::DoRemoveUserFromListL( |
|
929 const TDesC& aList, |
|
930 const TDesC& aUri ) |
|
931 { |
|
932 DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL"); |
|
933 CXdmNodeAttribute* attr = NULL; |
|
934 |
|
935 using namespace NPresencePlugin::NPresence; |
|
936 |
|
937 RPointerArray<CXdmDocumentNode> lists; |
|
938 CleanupClosePushL( lists ); |
|
939 |
|
940 RPointerArray<CXdmDocumentNode> nodes; |
|
941 CleanupClosePushL( nodes ); |
|
942 |
|
943 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
944 CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList ); |
|
945 if ( foundNode ) |
|
946 { |
|
947 DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL Node Found"); |
|
948 User::LeaveIfError( foundNode->Find( KPresenceEntry, nodes )); |
|
949 TInt nodeCount = nodes.Count(); |
|
950 for ( TInt i = 0; i < nodeCount; i++ ) |
|
951 { |
|
952 CXdmDocumentNode* currNode = nodes[i]; |
|
953 attr = ( currNode )->Attribute( KPresenceUri ); |
|
954 |
|
955 TBool uriMatch( EFalse ); |
|
956 uriMatch = CompareUriWithoutPrefixL( |
|
957 aUri, attr->AttributeValue() ); |
|
958 |
|
959 if ( attr && uriMatch ) |
|
960 { |
|
961 DP_SDA(" DoRemoveUserFromListL Node Found, do delete"); |
|
962 |
|
963 // This is the user we are looking for deletion. |
|
964 //First remove currNode form model |
|
965 iXdmDoc->RemoveFromModelL( currNode ); |
|
966 // Update model to server |
|
967 iXdmDoc->AppendL(); |
|
968 break; |
|
969 } |
|
970 } |
|
971 } |
|
972 else |
|
973 { |
|
974 DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL Leave"); |
|
975 User::Leave( KErrNotFound ); |
|
976 } |
|
977 |
|
978 CleanupStack::PopAndDestroy( &nodes ); // >>> nodes |
|
979 CleanupStack::PopAndDestroy( &lists ); // >>> lists |
|
980 DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL END"); |
|
981 } |
|
982 |
|
983 // --------------------------------------------------------------------------- |
|
984 // CPresencePluginXdmUtils::SubscribeBuddyListL() |
|
985 // --------------------------------------------------------------------------- |
|
986 // |
|
987 void CPresencePluginXdmUtils::SubscribeBuddyListL( |
|
988 RPointerArray<MXIMPIdentity>& aMembers ) |
|
989 { |
|
990 DP_SDA("CPresencePluginXdmUtils::SubscribeBuddyListL"); |
|
991 |
|
992 iOperation = EXdmGetBuddyList; |
|
993 DoGetListMembersL( KPresenceBuddyList, aMembers ); |
|
994 |
|
995 DP_SDA("CPresencePluginXdmUtils::SubscribeBuddyListL end"); |
|
996 } |
|
997 |
|
998 // --------------------------------------------------------------------------- |
|
999 // CPresencePluginXdmUtils::SubscribeBlockListL() |
|
1000 // --------------------------------------------------------------------------- |
|
1001 // |
|
1002 void CPresencePluginXdmUtils::SubscribeBlockListL( |
|
1003 RPointerArray<MXIMPIdentity>& aMembers ) |
|
1004 { |
|
1005 DP_SDA("CPresencePluginXdmUtils::SubscribeBlockListL"); |
|
1006 |
|
1007 if ( !iLocalMode ) |
|
1008 { |
|
1009 DP_SDA("CPresencePluginXdmUtils::SubscribeBlockListL !iLocalMode"); |
|
1010 iOperation = EXdmGetBlockedList; |
|
1011 DoGetListMembersL( KPresenceBlockedList, aMembers ); |
|
1012 } |
|
1013 DP_SDA("CPresencePluginXdmUtils::SubscribeBlockListL end"); |
|
1014 } |
|
1015 |
|
1016 // --------------------------------------------------------------------------- |
|
1017 // CPresencePluginXdmUtils::DoGetListMembersL() |
|
1018 // --------------------------------------------------------------------------- |
|
1019 // |
|
1020 void CPresencePluginXdmUtils::DoGetListMembersL( |
|
1021 const TDesC& aList, |
|
1022 RPointerArray<MXIMPIdentity>& aMembers ) |
|
1023 { |
|
1024 DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL"); |
|
1025 using namespace NPresencePlugin::NPresence; |
|
1026 |
|
1027 aMembers.Reset(); |
|
1028 |
|
1029 RPointerArray<CXdmDocumentNode> nodes; |
|
1030 CleanupClosePushL( nodes ); |
|
1031 |
|
1032 CXdmDocumentNode* listNode = NULL; |
|
1033 CXdmNodeAttribute* attr = NULL; |
|
1034 |
|
1035 TBool found(EFalse); |
|
1036 |
|
1037 if ( iXdmDoc ) |
|
1038 { |
|
1039 DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL iXdmDoc"); |
|
1040 User::LeaveIfError( iXdmDoc->Find( KPresenceList, nodes ) ); |
|
1041 DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL find ready"); |
|
1042 TInt count = nodes.Count(); |
|
1043 DP_SDA2("DoGetListMembersL find Count %d", count); |
|
1044 for ( TInt i=0; i < count; i++ ) |
|
1045 { |
|
1046 listNode = nodes[i]; |
|
1047 attr = listNode->Attribute( KPresenceName ); |
|
1048 if ( attr && !attr->AttributeValue().CompareF( aList )) |
|
1049 { |
|
1050 // That's the right list |
|
1051 DP_SDA("DoGetListMembersL Target found"); |
|
1052 found = ETrue; |
|
1053 break; |
|
1054 } |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 if ( found ) |
|
1059 { |
|
1060 DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL found"); |
|
1061 MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory(); |
|
1062 nodes.Reset(); |
|
1063 TInt err = listNode->Find( KPresenceEntry, nodes ); |
|
1064 DP_SDA2("CPresencePluginXdmUtils::DoGetListMembersL err %d", err); |
|
1065 if( !err ) |
|
1066 { |
|
1067 DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL Entry found"); |
|
1068 TInt nodeCount = nodes.Count(); |
|
1069 for ( TInt i = 0; i < nodeCount; i++ ) |
|
1070 { |
|
1071 attr = (nodes[i])->Attribute( KPresenceUri ); |
|
1072 if ( attr ) |
|
1073 { |
|
1074 DP_SDA("DoGetListMembersL attr check"); |
|
1075 MXIMPIdentity* entity = |
|
1076 myFactory.NewIdentityLC(); // << entity |
|
1077 entity->SetIdentityL( attr->AttributeValue() ); |
|
1078 aMembers.AppendL( entity ); |
|
1079 CleanupStack::Pop(); // >> entity |
|
1080 } |
|
1081 } |
|
1082 } |
|
1083 } |
|
1084 CleanupStack::PopAndDestroy( &nodes ); |
|
1085 DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL end"); |
|
1086 } |
|
1087 |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // CPresencePluginXdmUtils::GetXdmListsL() |
|
1090 // --------------------------------------------------------------------------- |
|
1091 // |
|
1092 void CPresencePluginXdmUtils::GetXdmListsL( |
|
1093 TBool aCreateRules, |
|
1094 TBool aLocalMode ) |
|
1095 { |
|
1096 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL"); |
|
1097 //Normal Mode start |
|
1098 if ( !iXdmEngine && !aLocalMode ) |
|
1099 { |
|
1100 DP_SDA2("!iXdmEngine settingID = %d", iSettingsId); |
|
1101 |
|
1102 #ifdef _DEBUG |
|
1103 //Get xdmSettings |
|
1104 HBufC* accesPoint = TXdmSettingsApi::PropertyL( |
|
1105 iSettingsId, EXdmPropToNapId ); |
|
1106 CleanupStack::PushL( accesPoint ); |
|
1107 DP_SDA2("CPresencePluginXdmUtils::GetXdmListsL accesPoint %S", |
|
1108 accesPoint); |
|
1109 #endif |
|
1110 |
|
1111 // get data from a network if not done so yet |
|
1112 CXdmProtocolInfo* info = CXdmProtocolInfo::NewL( iSettingsId ); |
|
1113 CleanupStack::PushL( info ); |
|
1114 |
|
1115 // Notice: we do not use cache for XDM |
|
1116 info->SetCacheUsage( EFalse ); //False in normal case |
|
1117 |
|
1118 iXdmEngine = CXdmEngine::NewL( *info ); |
|
1119 CleanupStack::PopAndDestroy( info ); |
|
1120 #ifdef _DEBUG |
|
1121 CleanupStack::PopAndDestroy( accesPoint ); |
|
1122 #endif |
|
1123 } |
|
1124 //LocalMode Start, !!! THERE IS LIMIT !!! |
|
1125 //Only one settings can use localmode |
|
1126 else if ( !iXdmEngine && aLocalMode ) |
|
1127 { |
|
1128 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL aLocalMode"); |
|
1129 CXdmProtocolInfo* info = |
|
1130 CXdmProtocolInfo::NewL( 0, KLocalProtocol, KNullDesC ); |
|
1131 CleanupStack::PushL( info ); |
|
1132 |
|
1133 iXdmEngine = CXdmEngine::NewL( *info ); |
|
1134 CleanupStack::PopAndDestroy( info ); |
|
1135 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL aLocalMode end"); |
|
1136 } |
|
1137 if ( !iXdmOk ) |
|
1138 { |
|
1139 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL !XdmOK "); |
|
1140 using namespace NPresencePlugin::NPresence; |
|
1141 // Get data from network |
|
1142 DP_SDA("GetXdmListsL Create Document Model "); |
|
1143 |
|
1144 iXdmDoc = iXdmEngine->CreateDocumentModelL( |
|
1145 KPresenceResourceList, EXdmResourceLists ); |
|
1146 |
|
1147 |
|
1148 DP_SDA("Create Document Model FetchData"); |
|
1149 iXdmDoc->FetchDataL(); |
|
1150 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL !XdmOK SETACTIVE "); |
|
1151 UpdateXdmsL(); |
|
1152 iXdmState = aCreateRules ? EGetXdmLists : EGetXdmListsOnly; |
|
1153 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL !XdmOK END"); |
|
1154 } |
|
1155 else |
|
1156 { |
|
1157 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL else"); |
|
1158 // Document already exists, no need to search from a server |
|
1159 iStatus = KRequestPending; |
|
1160 TRequestStatus* s= &iStatus; |
|
1161 DP_SDA("CPresencePluginXdmUtils::GetXdmListsL SEND COMPLETE"); |
|
1162 User::RequestComplete( s, KErrNone ); |
|
1163 iXdmState = aCreateRules ? EGetXdmLists : EGetXdmListsOnly; |
|
1164 SetActive(); |
|
1165 } |
|
1166 } |
|
1167 |
|
1168 // --------------------------------------------------------------------------- |
|
1169 // CPresencePluginXdmUtils::CreateXdmListsL() |
|
1170 // --------------------------------------------------------------------------- |
|
1171 // |
|
1172 void CPresencePluginXdmUtils::CreateXdmListsL( TBool aCreateRules ) |
|
1173 { |
|
1174 DP_SDA("CPresencePluginXdmUtils::CreateXdmListsL"); |
|
1175 |
|
1176 CXdmDocumentNode* root = iXdmDoc->CreateRootL(); |
|
1177 CleanupStack::PushL( root ); |
|
1178 |
|
1179 using namespace NPresencePlugin::NPresence; |
|
1180 root->SetNameL( KPresenceResourceLists ); |
|
1181 |
|
1182 // add all the list nodes |
|
1183 // buddylist |
|
1184 using namespace NPresencePlugin::NPresence; |
|
1185 if ( root->IsEmptyNode() ) |
|
1186 { |
|
1187 root->SetEmptyNode( EFalse ); |
|
1188 } |
|
1189 //buddy list |
|
1190 CXdmDocumentNode* child1 = root->CreateChileNodeL( KPresenceList ); |
|
1191 CleanupStack::PushL( child1 ); |
|
1192 CXdmNodeAttribute* name = child1->CreateAttributeL( KPresenceName ); |
|
1193 CleanupStack::PushL( name ); |
|
1194 name->SetAttributeValueL( KPresenceBuddyList ); |
|
1195 |
|
1196 // blockedcontacts |
|
1197 CXdmDocumentNode* child2 = root->CreateChileNodeL( KPresenceList ); |
|
1198 CleanupStack::PushL( child2 ); |
|
1199 CXdmNodeAttribute* name2 = child2->CreateAttributeL( KPresenceName ); |
|
1200 CleanupStack::PushL( name2 ); |
|
1201 name2->SetAttributeValueL( KPresenceBlockedList ); |
|
1202 |
|
1203 // send to the server and start wait a response |
|
1204 iXdmDoc->AppendL(); |
|
1205 UpdateXdmsL(); |
|
1206 iXdmState = aCreateRules ? ECreateXdmLists : ECreateXdmListsOnly; |
|
1207 |
|
1208 CleanupStack::Pop( name2 ); |
|
1209 CleanupStack::Pop( child2 ); |
|
1210 CleanupStack::Pop( name ); |
|
1211 CleanupStack::Pop( child1 ); |
|
1212 CleanupStack::Pop( root ); |
|
1213 DP_SDA("CPresencePluginXdmUtils::CreateXdmListsL end"); |
|
1214 } |
|
1215 |
|
1216 // --------------------------------------------------------------------------- |
|
1217 // CPresencePluginXdmUtils::GetEntitiesInListL() |
|
1218 // --------------------------------------------------------------------------- |
|
1219 // |
|
1220 void CPresencePluginXdmUtils::GetEntitiesInListL( |
|
1221 const TDesC& aList, |
|
1222 MXIMPObjectCollection& aColl ) |
|
1223 { |
|
1224 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL "); |
|
1225 using namespace NPresencePlugin::NPresence; |
|
1226 |
|
1227 CXdmDocumentNode* buddylist = DoGetBuddyListL( aList ); |
|
1228 |
|
1229 // make a collection of MXIMPPresentityGroupMemberInfo |
|
1230 RPointerArray<CXdmDocumentNode> entries; |
|
1231 CleanupClosePushL(entries); // <<< entries |
|
1232 |
|
1233 RPointerArray<CXdmDocumentNode> nodes; |
|
1234 CleanupClosePushL(nodes); // <<< nodes |
|
1235 |
|
1236 buddylist->Find( KPresenceEntry, entries ); |
|
1237 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL entries"); |
|
1238 TInt count = entries.Count(); |
|
1239 DP_SDA2("GetEntitiesInListL entries count %d",count); |
|
1240 for ( TInt i=0; i < count; i++ ) |
|
1241 { |
|
1242 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL 1"); |
|
1243 // create here MXIMPPresentityGroupMemberInfo |
|
1244 MPresentityGroupMemberInfo* info = |
|
1245 iConnObs.PresenceObjectFactoryOwn(). |
|
1246 NewPresentityGroupMemberInfoLC(); |
|
1247 |
|
1248 // ID |
|
1249 CXdmDocumentNode* entry = entries[i]; |
|
1250 CXdmNodeAttribute* attr = entry->Attribute( KPresenceUri ); |
|
1251 if ( attr ) |
|
1252 { |
|
1253 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL 2"); |
|
1254 MXIMPIdentity* id = |
|
1255 iConnObs.ObjectFactory().NewIdentityLC();//<< id |
|
1256 id->SetIdentityL( attr->AttributeValue() ); |
|
1257 info->SetGroupMemberIdL( id ); |
|
1258 CleanupStack::Pop(); // >> id |
|
1259 } |
|
1260 |
|
1261 // Display name |
|
1262 TInt err = entry->Find( KPresenceDisplayName, nodes ); |
|
1263 // Notice: assume there is only one display-name |
|
1264 if ( !err ) |
|
1265 { |
|
1266 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL display name"); |
|
1267 CXdmDocumentNode* disName = nodes[0]; |
|
1268 HBufC16* uri16 = NULL; |
|
1269 uri16 = |
|
1270 CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
1271 disName->LeafNodeContent() ); |
|
1272 |
|
1273 CleanupStack::PushL( uri16 ); // << uri16 |
|
1274 info->SetGroupMemberDisplayNameL( uri16->Des() ); |
|
1275 CleanupStack::PopAndDestroy( uri16 ); // >> uri16 |
|
1276 } |
|
1277 |
|
1278 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL 3"); |
|
1279 aColl.AddObjectL( info ); |
|
1280 |
|
1281 //if contact is from buddylist add it to virtual subscribed list too |
|
1282 if( !aList.CompareF( KPresenceBuddyList ) ) |
|
1283 { |
|
1284 DP_SDA("GetEntitiesInListL add virtualgroup"); |
|
1285 //Add identity to virtual list |
|
1286 iConnObs.SubscribedContacts()->AddEntityL( |
|
1287 info->GroupMemberId().Identity() ); |
|
1288 } |
|
1289 |
|
1290 CleanupStack::Pop(); // >> info |
|
1291 } |
|
1292 |
|
1293 CleanupStack::PopAndDestroy( &nodes ); // >>> nodes |
|
1294 CleanupStack::PopAndDestroy( &entries ); // >>> entries*/ |
|
1295 DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL end"); |
|
1296 } |
|
1297 |
|
1298 // --------------------------------------------------------------------------- |
|
1299 // CPresencePluginXdmUtils::AddIdentityToVirtualListL() |
|
1300 // --------------------------------------------------------------------------- |
|
1301 // |
|
1302 void CPresencePluginXdmUtils::AddIdentityToVirtualListL( const TDesC& aList ) |
|
1303 { |
|
1304 DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL "); |
|
1305 using namespace NPresencePlugin::NPresence; |
|
1306 |
|
1307 if ( aList.Compare( KPresenceBlockedList ) == NULL ) |
|
1308 { |
|
1309 iBlockedContacts.ResetAndDestroy(); |
|
1310 } |
|
1311 |
|
1312 CXdmDocumentNode* buddylist = DoGetBuddyListL( aList ); |
|
1313 |
|
1314 // make a collection of MXIMPPresentityGroupMemberInfo |
|
1315 RPointerArray<CXdmDocumentNode> entries; |
|
1316 CleanupClosePushL(entries); // <<< entries |
|
1317 |
|
1318 buddylist->Find( KPresenceEntry, entries ); |
|
1319 DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL entries"); |
|
1320 TInt count = entries.Count(); |
|
1321 DP_SDA2("AddIdentityToVirtualListL entries count %d",count); |
|
1322 for ( TInt i=0; i < count; i++ ) |
|
1323 { |
|
1324 DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL 1"); |
|
1325 // ID |
|
1326 CXdmDocumentNode* entry = entries[i]; |
|
1327 CXdmNodeAttribute* attr = entry->Attribute( KPresenceUri ); |
|
1328 if ( attr ) |
|
1329 { |
|
1330 if( !aList.CompareF( KPresenceBuddyList ) ) |
|
1331 { |
|
1332 DP_SDA("AddIdentityToVirtualListL add to buddies"); |
|
1333 //Add identity to virtual list |
|
1334 iConnObs.SubscribedContacts()->AddEntityL( |
|
1335 attr->AttributeValue() ); |
|
1336 } |
|
1337 else if ( !aList.CompareF( KPresenceBlockedList ) ) |
|
1338 { |
|
1339 DP_SDA("AddIdentityToVirtualListL add to blocked"); |
|
1340 HBufC* withoutPrefix = |
|
1341 iConnObs.InternalPresenceAuthorization(). |
|
1342 PluginData().RemovePrefixLC( attr->AttributeValue() ); |
|
1343 CleanupStack::Pop( withoutPrefix ); |
|
1344 iBlockedContacts.AppendL( withoutPrefix ); |
|
1345 } |
|
1346 } |
|
1347 } |
|
1348 CleanupStack::PopAndDestroy( &entries ); // >>> entries |
|
1349 DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL end"); |
|
1350 } |
|
1351 |
|
1352 // --------------------------------------------------------------------------- |
|
1353 // CPresencePluginXdmUtils::DoGetBuddyListL() |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // |
|
1356 CXdmDocumentNode* CPresencePluginXdmUtils::DoGetBuddyListL( |
|
1357 const TDesC& aParent ) |
|
1358 { |
|
1359 DP_SDA("CPresencePluginXdmUtils::DoGetBuddyListL"); |
|
1360 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
1361 |
|
1362 CXdmDocumentNode* ret = SearchListUnderParentL( root, aParent ); |
|
1363 if ( !ret ) |
|
1364 { |
|
1365 DP_SDA("CPresencePluginXdmUtils::DoGetBuddyListL !found"); |
|
1366 User::Leave( KErrNotFound ); |
|
1367 } |
|
1368 return ret; |
|
1369 } |
|
1370 |
|
1371 // --------------------------------------------------------------------------- |
|
1372 // CPresencePluginXdmUtils::DoGetUserListL() |
|
1373 // --------------------------------------------------------------------------- |
|
1374 // |
|
1375 CXdmDocumentNode* CPresencePluginXdmUtils::DoGetUserListL( |
|
1376 const TDesC& aList, CXdmDocumentNode* aBuddyList ) |
|
1377 { |
|
1378 DP_SDA("CPresencePluginXdmUtils::DoGetUserListL"); |
|
1379 CXdmDocumentNode* listNode = NULL; |
|
1380 CXdmNodeAttribute* attr = NULL; |
|
1381 TBool found( EFalse ); |
|
1382 |
|
1383 using namespace NPresencePlugin::NPresence; |
|
1384 |
|
1385 RPointerArray<CXdmDocumentNode> lists; |
|
1386 CleanupClosePushL( lists ); |
|
1387 |
|
1388 User::LeaveIfError( aBuddyList->Find( KPresenceEntry, lists )); |
|
1389 TInt count = lists.Count(); |
|
1390 DP_SDA2("CPresencePluginXdmUtils::DoGetUserListL count %d",count); |
|
1391 for ( TInt i=0; i < count; i++ ) |
|
1392 { |
|
1393 listNode = lists[i]; |
|
1394 attr = listNode->Attribute( KPresenceUri ); |
|
1395 if ( attr && !attr->AttributeValue().CompareF( aList )) |
|
1396 { |
|
1397 // List is found |
|
1398 found = ETrue; |
|
1399 break; |
|
1400 } |
|
1401 } |
|
1402 if ( !found ) |
|
1403 { |
|
1404 DP_SDA("CPresencePluginXdmUtils::DoGetUserListL !found"); |
|
1405 User::Leave( KErrNotFound ); |
|
1406 } |
|
1407 |
|
1408 CleanupStack::PopAndDestroy( &lists ); |
|
1409 DP_SDA("CPresencePluginXdmUtils::DoGetUserListL end"); |
|
1410 return listNode; |
|
1411 } |
|
1412 |
|
1413 // --------------------------------------------------------------------------- |
|
1414 // CPresencePluginXdmUtils::UpdateXdmsL() |
|
1415 // --------------------------------------------------------------------------- |
|
1416 // |
|
1417 void CPresencePluginXdmUtils::UpdateXdmsL() |
|
1418 { |
|
1419 DP_SDA("CPresencePluginXdmUtils::UpdateXdmsL"); |
|
1420 iXdmEngine->UpdateL( iXdmDoc, iStatus ); |
|
1421 if ( !IsActive() ) |
|
1422 { |
|
1423 DP_SDA("CPresencePluginXdmUtils::UpdateXdmsL SetActive"); |
|
1424 SetActive(); |
|
1425 } |
|
1426 DP_SDA("CPresencePluginXdmUtils::UpdateXdmsL end"); |
|
1427 } |
|
1428 |
|
1429 // --------------------------------------------------------------------------- |
|
1430 // CPresencePluginXdmUtils::UpdateXdmRulesL() |
|
1431 // --------------------------------------------------------------------------- |
|
1432 // |
|
1433 void CPresencePluginXdmUtils::UpdateXdmRulesL() |
|
1434 { |
|
1435 DP_SDA("CPresencePluginXdmUtils::UpdateXdmRulesL"); |
|
1436 iXdmState = EUpdateXdmRules; |
|
1437 |
|
1438 if( iRulesUpdateState == EStateInitializeRules ) |
|
1439 { |
|
1440 User::LeaveIfError( iXdmPresRules->UpdateXdmRulesL( this )); |
|
1441 } |
|
1442 //Add entity to presrules too |
|
1443 if ( iRulesUpdateState == EStateAddToWhiteList ) |
|
1444 { |
|
1445 DP_SDA("EStateAddToWhiteList"); |
|
1446 iXdmPresRules->AddEntityToWhiteListL( |
|
1447 iEntityUri->Des(), this ); |
|
1448 } |
|
1449 if ( iRulesUpdateState == EStateAddToBlockList ) |
|
1450 { |
|
1451 DP_SDA("EStateAddToBlockList"); |
|
1452 iXdmPresRules->AddEntityToBlockedRulesL( |
|
1453 iEntityUri->Des(), this ); |
|
1454 } |
|
1455 if ( iRulesUpdateState == EStateRemoveFromWhiteList) |
|
1456 { |
|
1457 DP_SDA("EStateRemoveFromWhiteList"); |
|
1458 iXdmPresRules->RemoveEntityFromWhiteListL( |
|
1459 iEntityUri->Des(), this ); |
|
1460 } |
|
1461 if ( iRulesUpdateState == EStateRemoveFromBlackList) |
|
1462 { |
|
1463 DP_SDA("EStateRemoveFromBlackList"); |
|
1464 iXdmPresRules->RemoveEntityBlockedRulesL( |
|
1465 iEntityUri->Des(), this ); |
|
1466 } |
|
1467 DP_SDA("CPresencePluginXdmUtils::UpdateXdmRulesL end"); |
|
1468 } |
|
1469 |
|
1470 // --------------------------------------------------------------------------- |
|
1471 // CPresencePluginXdmUtils::DoHandlePresUpdateDocumentL() |
|
1472 // --------------------------------------------------------------------------- |
|
1473 // |
|
1474 void CPresencePluginXdmUtils::DoHandlePresUpdateDocumentL( TInt aErrorCode ) |
|
1475 { |
|
1476 DP_SDA("CPresencePluginXdmUtils::DoHandlePresUpdateDocumentL"); |
|
1477 |
|
1478 // check if error |
|
1479 CheckIfErrorL( aErrorCode ); |
|
1480 |
|
1481 if ( iXdmState == EGetXdmRules ) |
|
1482 { |
|
1483 DP_SDA("DoHandlePresUpdateDocumentL EGetXdmRules"); |
|
1484 iXdmState = EStateIdle; |
|
1485 if ( aErrorCode && aErrorCode == KXcapErrorHttpNotFound ) |
|
1486 { |
|
1487 DP_SDA("DoHandlePresUpdateDocumentL EGetXdmRules ini rules ERROR"); |
|
1488 InitializePresRulesL(); |
|
1489 } |
|
1490 else |
|
1491 { |
|
1492 DP_SDA("DoHandlePresUpdateDocumentL EGetXdmRules SEND COMPLETE "); |
|
1493 // Complete with ok or error the last initial opreration |
|
1494 |
|
1495 // update presence cache if needed before complete client req. |
|
1496 iPresXdmOk = ETrue; |
|
1497 |
|
1498 if ( iBlockedContacts.Count() > 0 ) |
|
1499 { |
|
1500 iConnObs.InternalPresenceAuthorization(). |
|
1501 IsBlockedContactFriendRequestL( |
|
1502 *iBlockedContacts[ iBlockedContacts.Count() - 1 ], |
|
1503 *this, iStatus ); |
|
1504 |
|
1505 iXdmState = EUpdateBlockedContactPresenceCache; |
|
1506 SetActive(); |
|
1507 } |
|
1508 else |
|
1509 { |
|
1510 CompleteClientReq( aErrorCode ); |
|
1511 } |
|
1512 } |
|
1513 } |
|
1514 else if ( iXdmState == EUpdateXdmRules ) |
|
1515 { |
|
1516 DP_SDA("DoHandlePresUpdateDocumentL EUpdateXdmRules SEND COMPLETE "); |
|
1517 // Complete with ok or error the last initial opreration |
|
1518 CompleteClientReq( aErrorCode ); |
|
1519 } |
|
1520 else if ( iXdmState == ECreateXdmRules ) |
|
1521 { |
|
1522 DP_SDA("DoHandlePresUpdateDocumentL ECreateXdmRules SEND COMPLETE "); |
|
1523 iPresXdmOk = ETrue; |
|
1524 CompleteClientReq( aErrorCode ); |
|
1525 } |
|
1526 |
|
1527 else if ( iXdmState == EUpdateXdmList) |
|
1528 { |
|
1529 DP_SDA("DoHandlePresUpdateDocumentL EUpdateXdmList SEND COMPLETE"); |
|
1530 CompleteClientReq( aErrorCode ); |
|
1531 } |
|
1532 } |
|
1533 |
|
1534 // --------------------------------------------------------------------------- |
|
1535 // CPresencePluginXdmUtils::CompleteClientReq() |
|
1536 // --------------------------------------------------------------------------- |
|
1537 // |
|
1538 void CPresencePluginXdmUtils::CompleteClientReq( TInt aStatus ) |
|
1539 { |
|
1540 DP_SDA("CPresencePluginXdmUtils::CompleteClientReq"); |
|
1541 DP_SDA2("CPresencePluginXdmUtils::CompleteClientReq status %d ", aStatus); |
|
1542 iXdmState = EStateIdle; |
|
1543 iOperation = ENoOperation; |
|
1544 TRequestStatus* s = iClientStatus; |
|
1545 User::RequestComplete( s, aStatus ); |
|
1546 DP_SDA("CPresencePluginXdmUtils::CompleteClientReq end"); |
|
1547 } |
|
1548 |
|
1549 // --------------------------------------------------------------------------- |
|
1550 // CPresencePluginXdmUtils::HandlePresUpdateDocumentL() |
|
1551 // --------------------------------------------------------------------------- |
|
1552 // |
|
1553 void CPresencePluginXdmUtils::HandlePresUpdateDocumentL( |
|
1554 TInt aErrorCode ) |
|
1555 { |
|
1556 #ifdef _DEBUG |
|
1557 DP_SDA2("HandlePresUpdateDocumentL errorCode %d ", aErrorCode ); |
|
1558 DP_SDA2("HandlePresUpdateDocumentL mystatus %d ", iStatus.Int()); |
|
1559 DP_SDA2("HandlePresUpdateDocumentL state %d ", iXdmState); |
|
1560 DP_SDA2("HandlePresUpdateDocumentL ClientStatus %d",iClientStatus->Int() ); |
|
1561 #endif |
|
1562 |
|
1563 DP_SDA("CPresencePluginXdmUtils::HandlePresUpdateDocumentL"); |
|
1564 if ( aErrorCode == KErrTimedOut ) |
|
1565 { |
|
1566 DP_SDA("CPresencePluginXdmUtils::HandlePresUpdateDocumentL TimeOut"); |
|
1567 aErrorCode = 0; |
|
1568 } |
|
1569 |
|
1570 TRAPD( err, DoHandlePresUpdateDocumentL( aErrorCode )); |
|
1571 if ( err ) |
|
1572 { |
|
1573 DP_SDA("CPresencePluginXdmUtils::HandlePresUpdateDocumentL complete"); |
|
1574 // Complete with ok or error the last initial opreration |
|
1575 CompleteClientReq( err ); |
|
1576 } |
|
1577 } |
|
1578 |
|
1579 // --------------------------------------------------------------------------- |
|
1580 // CPresencePluginXdmUtils::SearchListUnderParentL |
|
1581 // --------------------------------------------------------------------------- |
|
1582 // |
|
1583 TBool CPresencePluginXdmUtils::CompareUriWithoutPrefixL( |
|
1584 const TDesC& aUri, const TDesC& aAttribute ) |
|
1585 { |
|
1586 DP_SDA("CPresencePluginXdmUtils::CompareUriWithoutPrefixL"); |
|
1587 |
|
1588 TBool match( EFalse ); |
|
1589 |
|
1590 RBuf uriWithoutPrefix; |
|
1591 CleanupClosePushL( uriWithoutPrefix ); |
|
1592 uriWithoutPrefix.CreateL( aUri ); |
|
1593 TInt prefixLocation = uriWithoutPrefix.Locate( ':' ); |
|
1594 |
|
1595 if ( KErrNotFound != prefixLocation ) |
|
1596 { |
|
1597 uriWithoutPrefix.Delete( 0, ( prefixLocation + 1 ) ); |
|
1598 } |
|
1599 |
|
1600 RBuf attributeWithoutprefix; |
|
1601 CleanupClosePushL( attributeWithoutprefix ); |
|
1602 attributeWithoutprefix.CreateL( aAttribute ); |
|
1603 prefixLocation = attributeWithoutprefix.Locate( ':' ); |
|
1604 |
|
1605 if ( KErrNotFound != prefixLocation ) |
|
1606 { |
|
1607 attributeWithoutprefix.Delete( 0, ( prefixLocation + 1 ) ); |
|
1608 } |
|
1609 |
|
1610 DP_SDA2(" --> uri without prefix=%S", &uriWithoutPrefix ); |
|
1611 DP_SDA2(" --> attribute without prefix=%S", &attributeWithoutprefix ); |
|
1612 |
|
1613 if ( uriWithoutPrefix.Compare( attributeWithoutprefix ) == 0 ) |
|
1614 { |
|
1615 match = ETrue; |
|
1616 } |
|
1617 |
|
1618 CleanupStack::PopAndDestroy( &attributeWithoutprefix ); |
|
1619 CleanupStack::PopAndDestroy( &uriWithoutPrefix ); |
|
1620 |
|
1621 return match; |
|
1622 } |
|
1623 |
|
1624 |
|
1625 // --------------------------------------------------------------------------- |
|
1626 // CPresencePluginXdmUtils::DoUpdateBlockedContactPresenceCacheL() |
|
1627 // --------------------------------------------------------------------------- |
|
1628 // |
|
1629 void CPresencePluginXdmUtils::DoUpdateBlockedContactPresenceCacheL( |
|
1630 TInt aMyStatus ) |
|
1631 { |
|
1632 DP_SDA( "CPresencePluginXdmUtils::DoUpdateBlockedContactPresenceCache" ); |
|
1633 |
|
1634 const TInt KTextBufferSize = 10; |
|
1635 TInt contactsCount = iBlockedContacts.Count(); |
|
1636 |
|
1637 if ( contactsCount > 0 ) |
|
1638 { |
|
1639 if ( iPresenceContactsAsyncReqResult ) |
|
1640 { |
|
1641 DP_SDA(" RunL -write blocked status to cache" ); |
|
1642 TBuf<KTextBufferSize> buf; |
|
1643 buf.Copy( KBlockedExtensionValue ); |
|
1644 iConnObs.InternalPresenceAuthorization().PluginData(). |
|
1645 WriteStatusToCacheL( *iBlockedContacts[ contactsCount - 1 ], |
|
1646 MPresenceBuddyInfo2::EUnknownAvailability, |
|
1647 buf, |
|
1648 KNullDesC() ); |
|
1649 } |
|
1650 delete iBlockedContacts[ contactsCount - 1 ]; |
|
1651 iBlockedContacts.Remove( contactsCount - 1 ); |
|
1652 |
|
1653 if ( iBlockedContacts.Count() > 0 ) |
|
1654 { |
|
1655 iConnObs.InternalPresenceAuthorization(). |
|
1656 IsBlockedContactFriendRequestL( |
|
1657 *iBlockedContacts[ iBlockedContacts.Count() - 1 ], |
|
1658 *this, iStatus ); |
|
1659 |
|
1660 iXdmState = EUpdateBlockedContactPresenceCache; |
|
1661 SetActive(); |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 CompleteClientReq( aMyStatus ); |
|
1666 } |
|
1667 } |
|
1668 } |
|
1669 |
|
1670 |
|
1671 // --------------------------------------------------------------------------- |
|
1672 // From MPresencePluginContactsObs |
|
1673 // CPresencePluginXdmUtils::RequestComplete |
|
1674 // --------------------------------------------------------------------------- |
|
1675 // |
|
1676 void CPresencePluginXdmUtils::RequestComplete( TAny* aResult, |
|
1677 TPresenceContactsOperation /*aOperation*/, TInt aError ) |
|
1678 { |
|
1679 iPresenceContactsAsyncReqResult = EFalse; |
|
1680 if ( NULL != aResult && KErrNone == aError ) |
|
1681 { |
|
1682 iPresenceContactsAsyncReqResult = |
|
1683 *static_cast<TBool*>( aResult ); |
|
1684 } |
|
1685 } |
|
1686 |
|
1687 // End of file |
|