|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: SIMPLE Protocol implementation for Presence Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <e32std.h> |
|
22 #include <utf.h> |
|
23 |
|
24 #include <simplefactory.h> |
|
25 #include <msimpleconnection.h> |
|
26 |
|
27 #include <pressettingsapi.h> |
|
28 #include <cpresencexdm.h> |
|
29 #include <rlspresxdmconsts.h> |
|
30 #include <XdmErrors.h> |
|
31 #include <prescondmisc.h> |
|
32 #include <prescondidentityone.h> |
|
33 #include <presenceactionxdm.h> |
|
34 #include <presencetransformxdm.h> |
|
35 #include <crlsxdm.h> |
|
36 |
|
37 #include <XdmEngine.h> |
|
38 #include <XdmDocument.h> |
|
39 #include <XdmProtocolInfo.h> |
|
40 #include <XdmDocumentNode.h> |
|
41 #include <XdmNodeAttribute.h> |
|
42 #include <XdmSettingsApi.h> |
|
43 #include <XdmErrors.h> |
|
44 |
|
45 #include "simpleplugindebugutils.h" |
|
46 #include "simpleplugincommon.h" |
|
47 #include "simplepluginxdmutils.h" |
|
48 #include "simpleplugindata.h" |
|
49 #include "simplepluginvariation.h" |
|
50 #include "msimplepluginsettings.h" |
|
51 |
|
52 // Test suite |
|
53 #include "msimpleplugintestobs.h" |
|
54 |
|
55 // This is for debugging and local test mode oly |
|
56 #include <in_sock.h> |
|
57 |
|
58 // URI prefixies |
|
59 const TInt KMyLenPrefix = 4; |
|
60 _LIT16( KMySip, "sip:" ); |
|
61 _LIT16( KMyTel, "tel:" ); |
|
62 |
|
63 |
|
64 // ======== MEMBER FUNCTIONS ======== |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CSimplePluginXdmUtils::CSimplePluginXdmUtils |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CSimplePluginXdmUtils::CSimplePluginXdmUtils( |
|
71 MSimplePluginSettings& aConnSets, TInt aXmdId ) |
|
72 : CActive( EPriorityStandard ), |
|
73 iConnSets(aConnSets), iSettingsId(aXmdId), |
|
74 iXdmState(EStateIdle), iOperation( ENoOperation), iTestObs( NULL ) |
|
75 { |
|
76 CActiveScheduler::Add( this ); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CSimplePluginXdmUtils::ConstructL |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CSimplePluginXdmUtils::ConstructL( ) |
|
84 { |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CSimplePluginXdmUtils::NewL |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CSimplePluginXdmUtils* CSimplePluginXdmUtils::NewL( |
|
92 MSimplePluginSettings& aConnSets, |
|
93 TInt aXmdId ) |
|
94 { |
|
95 CSimplePluginXdmUtils* self = |
|
96 new( ELeave ) CSimplePluginXdmUtils( aConnSets, aXmdId ); |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL( ); |
|
99 CleanupStack::Pop( self ); |
|
100 #ifdef _DEBUG |
|
101 PluginLogger::Log(_L("PluginXdm: NewL this=%d"), (TInt)self); |
|
102 #endif |
|
103 |
|
104 return self; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CSimplePluginXdmUtils::~CSimplePluginXdmUtils() |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 CSimplePluginXdmUtils::~CSimplePluginXdmUtils() |
|
112 { |
|
113 |
|
114 Cancel(); |
|
115 |
|
116 CancelWrappers(); |
|
117 |
|
118 if ( iXdmDoc && iXdmEngine ) |
|
119 { |
|
120 TRAP_IGNORE( iXdmEngine->DeleteDocumentModelL( iXdmDoc )); |
|
121 } |
|
122 delete iRlsXdm; |
|
123 delete iPresenceXdm; |
|
124 delete iXdmEngine; |
|
125 delete iAuxBuffer; |
|
126 |
|
127 delete iAuxBuffer2; |
|
128 |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CSimplePluginXdmUtils::InitializeXdmL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CSimplePluginXdmUtils::InitializeXdmL( TRequestStatus& aStatus ) |
|
136 { |
|
137 #ifdef _DEBUG |
|
138 PluginLogger::Log(_L("PluginXdm: InitializeXdmL") ); |
|
139 #endif |
|
140 |
|
141 iOperation = EXdmInit; |
|
142 iClientStatus = &aStatus; |
|
143 |
|
144 if ( !iXdmOk ) |
|
145 { |
|
146 GetXdmOMAListsL(); |
|
147 iXdmState = EGetXdmOMALists; |
|
148 *iClientStatus = KRequestPending; |
|
149 } |
|
150 else if ( !iPresXdmOk ) |
|
151 { |
|
152 GetXdmRulesL(); |
|
153 *iClientStatus = KRequestPending; |
|
154 } |
|
155 else |
|
156 { |
|
157 // All is ok |
|
158 *iClientStatus = KRequestPending; |
|
159 CompleteClientReq( KErrNone ); |
|
160 } |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // CSimplePluginXdmUtils::InitializeXdmsOnlyL |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CSimplePluginXdmUtils::InitializeXdmsOnlyL( TRequestStatus& aStatus ) |
|
168 { |
|
169 #ifdef _DEBUG |
|
170 PluginLogger::Log(_L("PluginXdm: InitializeXdmsOnlyL") ); |
|
171 #endif |
|
172 |
|
173 iOperation = EXdmInitXdmsOnly; |
|
174 iClientStatus = &aStatus; |
|
175 |
|
176 if ( !iXdmOk ) |
|
177 { |
|
178 GetXdmOMAListsL(); |
|
179 iXdmState = EGetXdmOMAListsOnly; |
|
180 *iClientStatus = KRequestPending; |
|
181 } |
|
182 else |
|
183 { |
|
184 // All is ok |
|
185 *iClientStatus = KRequestPending; |
|
186 CompleteClientReq( KErrNone ); |
|
187 } |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CSimplePluginXdmUtils::RunL() |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CSimplePluginXdmUtils::RunL( ) |
|
195 { |
|
196 TPluginXdmState origState = iXdmState; |
|
197 iXdmState = EStateIdle; |
|
198 TInt myStatus = iStatus.Int(); |
|
199 |
|
200 #ifdef _DEBUG |
|
201 PluginLogger::Log(_L("PluginXdm: RunL %d"), myStatus ); |
|
202 #endif |
|
203 |
|
204 if ( iTestObs ) |
|
205 { |
|
206 // Test suite |
|
207 iTestObs->TestCallbackInRunL( |
|
208 myStatus, origState, iOperation, KNullDesC ); |
|
209 } |
|
210 |
|
211 #ifdef FAKE_XDM_OK |
|
212 #ifdef _DEBUG |
|
213 // -191 = KErrHostUnreach in_sock.h |
|
214 if ( myStatus == KErrTimedOut || myStatus == KXcapErrorNetworkNotAvailabe || -191 ) |
|
215 { |
|
216 PluginLogger::Log(_L("PluginXdmUtils : RunL FAKE_XDM_OK resets error code %d"), myStatus ); |
|
217 myStatus = 0; |
|
218 } |
|
219 #endif |
|
220 #endif |
|
221 |
|
222 DoXdmRunL( origState, myStatus ); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // CSimplePluginXdmUtils::DoXdmRunL() |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CSimplePluginXdmUtils::DoXdmRunL( TPluginXdmState aOrigState, TInt aStatus ) |
|
230 { |
|
231 |
|
232 switch ( aOrigState ) |
|
233 { |
|
234 case EGetXdmOMALists: |
|
235 case EGetXdmOMAListsOnly: |
|
236 { |
|
237 // no OMA resource-list, let's start to create it. |
|
238 if ( CreateXdmOMAListsIfNeededL() ) |
|
239 { |
|
240 iXdmState = aOrigState == EGetXdmOMALists ? ECreateXdmOMALists : ECreateXdmOMAListsOnly; |
|
241 } |
|
242 else |
|
243 { |
|
244 iXdmOk = ETrue; |
|
245 if ( !iPresXdmOk && aOrigState == EGetXdmOMALists ) |
|
246 { |
|
247 GetXdmRulesL(); |
|
248 } |
|
249 else |
|
250 { |
|
251 CompleteClientReq( KErrNone ); |
|
252 } |
|
253 } |
|
254 } |
|
255 break; |
|
256 case ECreateXdmOMALists: |
|
257 { |
|
258 if ( aStatus ) |
|
259 { |
|
260 CompleteClientReq( aStatus ); |
|
261 } |
|
262 else |
|
263 { |
|
264 iXdmOk = ETrue; |
|
265 GetXdmRulesL(); |
|
266 } |
|
267 } |
|
268 break; |
|
269 case ECreateXdmOMAListsOnly: |
|
270 { |
|
271 if ( !aStatus ) |
|
272 { |
|
273 iXdmOk = ETrue; |
|
274 } |
|
275 CompleteClientReq( aStatus ); |
|
276 } |
|
277 break; |
|
278 default: |
|
279 // complete reqular request |
|
280 CompleteClientReq( aStatus ); |
|
281 break; |
|
282 }; |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // CSimplePluginXdmUtils::CancelWrappers() |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CSimplePluginXdmUtils::CancelWrappers( ) |
|
290 { |
|
291 iOperation = EXdmCancel; |
|
292 |
|
293 // Cancel M-class interface methods that calls callback method. |
|
294 if ( iXdmState == EGetRlsServices || |
|
295 iXdmState == EUpdateRlsServices || |
|
296 iXdmState == EReUpdateRlsServices ) |
|
297 { |
|
298 iXdmState = ECancelDocument; |
|
299 #ifdef _DEBUG |
|
300 PluginLogger::Log(_L("PluginXdm: -> iRlsXdm->Cancel")); |
|
301 #endif |
|
302 // Better call Cancel() instead of CancelUpdateL(). |
|
303 // It works and is easier to implement. Otherwise we should have here |
|
304 // SetActive(); iStatus=KRequestPending; User::WaitForRequest(iStatus) |
|
305 // and we should have implemented HandleRLSUpdateCancelL that completes |
|
306 // own iStatus. |
|
307 iRlsXdm->Cancel(); |
|
308 } |
|
309 else if ( iXdmState == EGetXdmRules || |
|
310 iXdmState == EUpdateXdmRules ) |
|
311 { |
|
312 iXdmState = ECancelDocument; |
|
313 #ifdef _DEBUG |
|
314 PluginLogger::Log(_L("PluginXdm: -> iPresenceXdm->Cancel")); |
|
315 #endif |
|
316 iPresenceXdm->Cancel(); |
|
317 } |
|
318 else |
|
319 { |
|
320 } |
|
321 } |
|
322 // --------------------------------------------------------------------------- |
|
323 // CSimplePluginXdmUtils::DoCancel() |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 void CSimplePluginXdmUtils::DoCancel( ) |
|
327 { |
|
328 #ifdef _DEBUG |
|
329 PluginLogger::Log(_L("PluginXdm: DoCancel")); |
|
330 #endif |
|
331 iOperation = EXdmCancel; |
|
332 |
|
333 if ( iXdmState == EGetXdmOMALists || iXdmState == ECreateXdmOMALists || |
|
334 iXdmState == EGetXdmOMAListsOnly || iXdmState == ECreateXdmOMAListsOnly || |
|
335 iXdmState == EUpdateXdmOMAList ) |
|
336 { |
|
337 // Cancel a request made to XDM Engine. |
|
338 iXdmState = ECancelDocument; |
|
339 #ifdef _DEBUG |
|
340 PluginLogger::Log(_L("PluginXdm: iXdmEngine->CancelUpdate")); |
|
341 #endif |
|
342 iXdmEngine->CancelUpdate( iXdmDoc ); |
|
343 CompleteClientReq( KErrCancel ); |
|
344 } |
|
345 else |
|
346 { |
|
347 // Cancel a request where we have completed our own iStatus. |
|
348 // Very rare posibility that this happens when GetXdmOMALists is not ready. |
|
349 // It's very hard to make it happen in test suite. |
|
350 } |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // CSimplePluginXdmUtils::RunError |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 TInt CSimplePluginXdmUtils::RunError( TInt aError ) |
|
358 { |
|
359 #ifdef _DEBUG |
|
360 PluginLogger::Log(_L("PluginXdm: RunError")); |
|
361 #endif |
|
362 // complete the open request |
|
363 CompleteClientReq( aError ); |
|
364 return KErrNone; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CSimplePluginXdmUtils::FetchRlsL |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CSimplePluginXdmUtils::FetchRlsL( |
|
372 TRequestStatus& aStatus ) |
|
373 { |
|
374 #ifdef _DEBUG |
|
375 PluginLogger::Log(_L("PluginXdm: FetchRlsL")); |
|
376 #endif |
|
377 _LIT( KMyOper, "FetchRlsL"); |
|
378 |
|
379 iClientStatus = &aStatus; |
|
380 |
|
381 iOperation = EXdmRlsFetch; |
|
382 |
|
383 if ( !iRlsXdm ) |
|
384 { |
|
385 iRlsXdm = CRLSXDM::NewL( iSettingsId ); |
|
386 } |
|
387 |
|
388 if ( iTestObs ) |
|
389 { |
|
390 // Test suite |
|
391 iTestObs->TestCallbackAsynchL( |
|
392 KErrNone, iXdmState, iOperation, KMyOper ); |
|
393 } |
|
394 |
|
395 // The following returns in MRLSPresXDMAsyncHandler callback |
|
396 #ifdef _DEBUG |
|
397 PluginLogger::Log(_L("PluginXdm: -> iRlsXdm->UpdateAllFromServerL")); |
|
398 #endif |
|
399 User::LeaveIfError( iRlsXdm->UpdateAllFromServerL( this )); |
|
400 |
|
401 *iClientStatus = KRequestPending; |
|
402 |
|
403 iXdmState = EGetRlsServices; |
|
404 |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // CSimplePluginXdmUtils::AddRlsGroupL |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 void CSimplePluginXdmUtils::AddRlsGroupL( |
|
412 const TDesC& aName ) |
|
413 { |
|
414 #ifdef _DEBUG |
|
415 PluginLogger::Log(_L("PluginXdm: AddRlsGroupL")); |
|
416 #endif |
|
417 iOperation = EXdmRlsAdd; |
|
418 |
|
419 HBufC16* buf = CreateRlsDocumentUri16LC( |
|
420 aName, iConnSets.CurrentSipPresentity(), iConnSets.CurrentDomain() ); |
|
421 |
|
422 // KErrAlreadyExists |
|
423 TInt errx = iRlsXdm->AddServiceURIL( buf->Des() ); |
|
424 if ( errx && errx != KErrAlreadyExists ) |
|
425 { |
|
426 User::Leave( errx ); |
|
427 } |
|
428 User::LeaveIfError( iRlsXdm->SwitchToServiceURIL( buf->Des() )); |
|
429 |
|
430 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
431 CleanupStack::PushL( xcapUri ); // << xcapUri |
|
432 |
|
433 HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aName ); |
|
434 CleanupStack::PushL( listUri ); // << listUri |
|
435 |
|
436 TInt err = iRlsXdm->AddElementL( KPresResourceList, |
|
437 listUri->Des(), aName ); |
|
438 if ( err && err != KErrAlreadyExists ) |
|
439 { |
|
440 User::Leave( err ); |
|
441 } |
|
442 |
|
443 // Save aName for RLS Service URI negoriation handling (HTTP error 409). |
|
444 // Notice: We assume that only one AddRlsGroupL is called between CommitRlsL methods. |
|
445 |
|
446 delete iAuxBuffer; |
|
447 iAuxBuffer = NULL; |
|
448 iAuxBuffer = aName.AllocL(); |
|
449 |
|
450 CleanupStack::PopAndDestroy( listUri ); // >> listUri |
|
451 CleanupStack::PopAndDestroy( xcapUri ); // >> xcapUri |
|
452 CleanupStack::PopAndDestroy( buf ); |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // CSimplePluginXdmUtils::RemoveRlsGroupL |
|
457 // Use RemoveRlsServiceByResourceListL when possible |
|
458 // |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void CSimplePluginXdmUtils::RemoveRlsGroupL( |
|
462 const TDesC& aName ) |
|
463 { |
|
464 #ifdef _DEBUG |
|
465 PluginLogger::Log(_L("PluginXdm: RemoveRlsGroupL")); |
|
466 #endif |
|
467 |
|
468 iOperation = EXdmRlsRemove; |
|
469 |
|
470 HBufC16* buf = CreateRlsDocumentUri16LC( |
|
471 aName, iConnSets.CurrentSipPresentity(), iConnSets.CurrentDomain() ); |
|
472 |
|
473 User::LeaveIfError( iRlsXdm->RemoveServiceURIL( buf->Des())); |
|
474 CleanupStack::PopAndDestroy( buf ); |
|
475 } |
|
476 |
|
477 // --------------------------------------------------------------------------- |
|
478 // CSimplePluginXdmUtils::AddEntityToGrantedL |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 void CSimplePluginXdmUtils::AddEntityToGrantedL( |
|
482 const TDesC& aUri, TRequestStatus& aStatus ) |
|
483 { |
|
484 #ifdef _DEBUG |
|
485 PluginLogger::Log(_L("PluginXdm: AddEntityToGrantedL")); |
|
486 #endif |
|
487 iClientStatus = &aStatus; |
|
488 |
|
489 iOperation = EXdmAddUserToGroup; |
|
490 |
|
491 DoAddUserToListL( iConnSets.Variation().GrantListName(), aUri ); |
|
492 |
|
493 // send to the server and start wait a response |
|
494 UpdateXdmsL(); |
|
495 iXdmState = EUpdateXdmOMAList; |
|
496 |
|
497 *iClientStatus = KRequestPending; |
|
498 } |
|
499 |
|
500 // --------------------------------------------------------------------------- |
|
501 // CSimplePluginXdmUtils::AddEntityToBlockedL |
|
502 // --------------------------------------------------------------------------- |
|
503 // |
|
504 void CSimplePluginXdmUtils::AddEntityToBlockedL( |
|
505 const TDesC& aUri, TRequestStatus& aStatus ) |
|
506 { |
|
507 #ifdef _DEBUG |
|
508 PluginLogger::Log(_L("PluginXdm: AddEntityToBlockedL")); |
|
509 #endif |
|
510 iClientStatus = &aStatus; |
|
511 |
|
512 iOperation = EXdmAddUserToGroup; |
|
513 DoAddUserToListL( KSimpleOMABlockedList, aUri ); |
|
514 |
|
515 // send to the server and start wait a response |
|
516 UpdateXdmsL(); |
|
517 iXdmState = EUpdateXdmOMAList; |
|
518 |
|
519 *iClientStatus = KRequestPending; |
|
520 } |
|
521 |
|
522 // ---------------------------------------------------- |
|
523 // CSimplePluginXdmUtils::DoAddUserToListL |
|
524 // ---------------------------------------------------- |
|
525 // |
|
526 void CSimplePluginXdmUtils::DoAddUserToListL( |
|
527 const TDesC& aList, const TDesC& aUri ) |
|
528 { |
|
529 |
|
530 using namespace NSimplePlugin::NSimpleOma; |
|
531 |
|
532 RPointerArray<CXdmDocumentNode> lists; |
|
533 CleanupClosePushL( lists ); // << lists |
|
534 |
|
535 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
536 CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList ); |
|
537 |
|
538 if ( foundNode ) |
|
539 { |
|
540 if ( foundNode->IsEmptyNode() ) |
|
541 { |
|
542 foundNode->SetEmptyNode( EFalse ); |
|
543 } |
|
544 |
|
545 CXdmDocumentNode* newNode = foundNode->CreateChileNodeL( KSimpleEntry ); |
|
546 CXdmNodeAttribute* attributeEntryUri = newNode->CreateAttributeL( KSimpleUri ); |
|
547 attributeEntryUri->SetAttributeValueL( aUri ); |
|
548 iXdmDoc->AppendL( newNode ); |
|
549 } |
|
550 else |
|
551 { |
|
552 User::Leave( KErrNotFound ); |
|
553 } |
|
554 |
|
555 CleanupStack::PopAndDestroy( &lists ); // >> lists |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------------------------- |
|
559 // CSimplePluginXdmUtils::RemoveEntityFromGrantedL |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 void CSimplePluginXdmUtils::RemoveEntityFromGrantedL( |
|
563 const TDesC& aUri, TRequestStatus& aStatus ) |
|
564 { |
|
565 #ifdef _DEBUG |
|
566 PluginLogger::Log(_L("PluginXdm: RemoveEntityFromGrantedL")); |
|
567 #endif |
|
568 iClientStatus = &aStatus; |
|
569 |
|
570 iOperation = EXdmRemoveUserFromGroup; |
|
571 DoRemoveUserFromListL( iConnSets.Variation().GrantListName(), aUri ); |
|
572 |
|
573 // send to the server and start wait a response |
|
574 UpdateXdmsL(); |
|
575 iXdmState = EUpdateXdmOMAList; |
|
576 |
|
577 *iClientStatus = KRequestPending; |
|
578 } |
|
579 |
|
580 // --------------------------------------------------------------------------- |
|
581 // CSimplePluginXdmUtils::RemoveEntityFromBlockedL |
|
582 // --------------------------------------------------------------------------- |
|
583 // |
|
584 void CSimplePluginXdmUtils::RemoveEntityFromBlockedL( |
|
585 const TDesC& aUri, TRequestStatus& aStatus ) |
|
586 { |
|
587 #ifdef _DEBUG |
|
588 PluginLogger::Log(_L("PluginXdm: RemoveEntityFromBlockedL")); |
|
589 #endif |
|
590 iClientStatus = &aStatus; |
|
591 |
|
592 iOperation = EXdmRemoveUserFromGroup; |
|
593 DoRemoveUserFromListL( KSimpleOMABlockedList, aUri ); |
|
594 |
|
595 // send to the server and start wait a response |
|
596 UpdateXdmsL(); |
|
597 iXdmState = EUpdateXdmOMAList; |
|
598 |
|
599 *iClientStatus = KRequestPending; |
|
600 } |
|
601 |
|
602 // ---------------------------------------------------- |
|
603 // CSimplePluginXdmUtils::DoRemoveUserFromListL |
|
604 // ---------------------------------------------------- |
|
605 // |
|
606 void CSimplePluginXdmUtils::DoRemoveUserFromListL( |
|
607 const TDesC& aList, const TDesC& aUri ) |
|
608 { |
|
609 CXdmNodeAttribute* attr = NULL; |
|
610 |
|
611 using namespace NSimplePlugin::NSimpleOma; |
|
612 |
|
613 RPointerArray<CXdmDocumentNode> lists; |
|
614 CleanupClosePushL( lists ); |
|
615 |
|
616 RPointerArray<CXdmDocumentNode> nodes; |
|
617 CleanupClosePushL( nodes ); |
|
618 |
|
619 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
620 CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList ); |
|
621 if ( foundNode ) |
|
622 { |
|
623 User::LeaveIfError( foundNode->Find( KSimpleEntry, nodes )); |
|
624 TInt nodeCount = nodes.Count(); |
|
625 for ( TInt i = 0; i < nodeCount; i++ ) |
|
626 { |
|
627 CXdmDocumentNode* currNode = nodes[i]; |
|
628 attr = ( currNode )->Attribute( KSimpleUri ); |
|
629 if ( attr && !attr->AttributeValue().CompareF( aUri )) |
|
630 { |
|
631 // This is the user we are looking for deletion. |
|
632 iXdmDoc->DeleteDataL( currNode ); |
|
633 break; |
|
634 } |
|
635 } |
|
636 } |
|
637 else |
|
638 { |
|
639 User::Leave( KErrNotFound ); |
|
640 } |
|
641 |
|
642 CleanupStack::PopAndDestroy( &nodes ); // >>> nodes |
|
643 CleanupStack::PopAndDestroy( &lists ); // >>> lists |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // CSimplePluginXdmUtils::RemoveGroupFromGrantedL |
|
648 // --------------------------------------------------------------------------- |
|
649 // |
|
650 void CSimplePluginXdmUtils::RemoveGroupFromGrantedL( |
|
651 const TDesC& aName, TRequestStatus& aStatus ) |
|
652 { |
|
653 #ifdef _DEBUG |
|
654 PluginLogger::Log(_L("PluginXdm: RemoveGroupFromGrantedL")); |
|
655 #endif |
|
656 iClientStatus = &aStatus; |
|
657 |
|
658 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
659 CleanupStack::PushL( xcapUri ); // << xcapUri |
|
660 |
|
661 HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aName ); |
|
662 CleanupStack::PushL( listUri ); // << listUri |
|
663 |
|
664 DoRemoveListFromGrantRuleL( listUri->Des() ); |
|
665 |
|
666 CleanupStack::PopAndDestroy( listUri ); |
|
667 CleanupStack::PopAndDestroy( xcapUri ); |
|
668 |
|
669 iOperation = EXdmWithdrawGroup; |
|
670 } |
|
671 |
|
672 // ---------------------------------------------------- |
|
673 // CSimplePluginXdmUtils::DoRemoveListFromGrantRuleL |
|
674 // ---------------------------------------------------- |
|
675 // |
|
676 void CSimplePluginXdmUtils::DoRemoveListFromGrantRuleL( |
|
677 const TDesC& aListUri ) |
|
678 { |
|
679 TPresCondMisc misc; |
|
680 misc.Init( iPresenceXdm ); |
|
681 |
|
682 if ( !misc.DeleteExternalListL( iConnSets.Variation().GrantRuleName(), aListUri )) |
|
683 { |
|
684 // update document in the server only if there was a modification. |
|
685 UpdateXdmRulesL(); |
|
686 *iClientStatus = KRequestPending; |
|
687 } |
|
688 else |
|
689 { |
|
690 // Complete without server operation |
|
691 CompleteClientReq( KErrNone ); |
|
692 } |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // CSimplePluginXdmUtils::AddGroupToGrantedL |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 void CSimplePluginXdmUtils::AddGroupToGrantedL( |
|
700 const TDesC& aName, TRequestStatus& aStatus ) |
|
701 { |
|
702 #ifdef _DEBUG |
|
703 PluginLogger::Log(_L("PluginXdm: AddGroupToGrantedL")); |
|
704 #endif |
|
705 |
|
706 iClientStatus = &aStatus; |
|
707 |
|
708 if ( !DoesUserListExistsL( aName ) ) |
|
709 { |
|
710 User::Leave( KErrNotFound ); |
|
711 } |
|
712 |
|
713 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
714 CleanupStack::PushL( xcapUri ); // << xcapUri |
|
715 |
|
716 HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aName ); |
|
717 CleanupStack::PushL( listUri ); // << listUri |
|
718 |
|
719 iOperation = EXdmGrantGroup; |
|
720 |
|
721 DoAddListIntoGrantRuleL( listUri->Des() ); |
|
722 |
|
723 CleanupStack::PopAndDestroy( listUri ); // >> listUri |
|
724 CleanupStack::PopAndDestroy( xcapUri ); // >> xcapUri |
|
725 |
|
726 *iClientStatus = KRequestPending; |
|
727 } |
|
728 |
|
729 // --------------------------------------------------------------------------- |
|
730 // CSimplePluginXdmUtils::DoAddListIntoGrantRuleL |
|
731 // --------------------------------------------------------------------------- |
|
732 // |
|
733 void CSimplePluginXdmUtils::DoAddListIntoGrantRuleL( |
|
734 const TDesC& aListUri) |
|
735 { |
|
736 TPresCondMisc misc; |
|
737 misc.Init( iPresenceXdm ); |
|
738 |
|
739 User::LeaveIfError( misc.AddExternListL( iConnSets.Variation().GrantRuleName(), aListUri )); |
|
740 |
|
741 UpdateXdmRulesL(); |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // CSimplePluginXdmUtils::GrantForEveryoneL |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CSimplePluginXdmUtils::GrantForEveryoneL( TRequestStatus& aStatus ) |
|
749 { |
|
750 #ifdef _DEBUG |
|
751 PluginLogger::Log(_L("PluginXdm: GrantForEveryoneL")); |
|
752 #endif |
|
753 iClientStatus = &aStatus; |
|
754 |
|
755 iOperation = EXdmGrantForAll; |
|
756 DoGrantForAllL(); |
|
757 |
|
758 *iClientStatus = KRequestPending; |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // CSimplePluginXdmUtils::WithdrawFromEveryoneL |
|
763 // --------------------------------------------------------------------------- |
|
764 // |
|
765 void CSimplePluginXdmUtils::WithdrawFromEveryoneL( TRequestStatus& aStatus ) |
|
766 { |
|
767 #ifdef _DEBUG |
|
768 PluginLogger::Log(_L("PluginXdm: WithdrawFromEveryoneL")); |
|
769 #endif |
|
770 iClientStatus = &aStatus; |
|
771 |
|
772 iOperation = EXdmWithdrawFromAll; |
|
773 DoWithdrawFromAllL(); |
|
774 } |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CSimplePluginXdmUtils::SetReactiveAuthL |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 void CSimplePluginXdmUtils::SetReactiveAuthL( TRequestStatus& aStatus ) |
|
781 { |
|
782 #ifdef _DEBUG |
|
783 PluginLogger::Log(_L("PluginXdm: SetReactiveAuthL")); |
|
784 #endif |
|
785 iClientStatus = &aStatus; |
|
786 |
|
787 iOperation = EXdmSetReactiveAuth; |
|
788 DoSetReactiveAuthL(); |
|
789 |
|
790 *iClientStatus = KRequestPending; |
|
791 } |
|
792 |
|
793 // --------------------------------------------------------------------------- |
|
794 // CSimplePluginXdmUtils::SetProactiveAuthL |
|
795 // --------------------------------------------------------------------------- |
|
796 // |
|
797 void CSimplePluginXdmUtils::SetProactiveAuthL( TRequestStatus& aStatus ) |
|
798 { |
|
799 #ifdef _DEBUG |
|
800 PluginLogger::Log(_L("PluginXdm: SetProactiveAuthL")); |
|
801 #endif |
|
802 iClientStatus = &aStatus; |
|
803 |
|
804 iOperation = EXdmSetProactiveAuth; |
|
805 DoSetProactiveAuthL(); |
|
806 } |
|
807 |
|
808 // --------------------------------------------------------------------------- |
|
809 // CSimplePluginXdmUtils::SubscribeBlockListL |
|
810 // --------------------------------------------------------------------------- |
|
811 // |
|
812 void CSimplePluginXdmUtils::SubscribeBlockListL( CPtrCArray& aMembers ) |
|
813 { |
|
814 #ifdef _DEBUG |
|
815 PluginLogger::Log(_L("PluginXdm: SubscribeBlockListL")); |
|
816 #endif |
|
817 iOperation = EXdmGetBlockedList; |
|
818 DoGetListMembersL( KSimpleOMABlockedList, aMembers ); |
|
819 // The cient will call a method GetEntitiesL that access those arrays |
|
820 // Those member arrays will be emptied after the call. + in destrcutor. |
|
821 } |
|
822 |
|
823 // --------------------------------------------------------------------------- |
|
824 // CSimplePluginXdmUtils::UnsubscribeBlockListL |
|
825 // --------------------------------------------------------------------------- |
|
826 // |
|
827 void CSimplePluginXdmUtils::UnsubscribeBlockListL( TRequestStatus& aStatus ) |
|
828 { |
|
829 iClientStatus = &aStatus; |
|
830 *iClientStatus = KRequestPending; |
|
831 // Subscription state is always terminated |
|
832 CompleteClientReq( KErrNone ); |
|
833 } |
|
834 |
|
835 // --------------------------------------------------------------------------- |
|
836 // CSimplePluginXdmUtils::DoGetListMembersL |
|
837 // --------------------------------------------------------------------------- |
|
838 // |
|
839 void CSimplePluginXdmUtils::DoGetListMembersL( |
|
840 const TDesC& aList, CPtrCArray& aMembers ) |
|
841 { |
|
842 using namespace NSimplePlugin::NSimpleOma; |
|
843 |
|
844 aMembers.Reset(); |
|
845 |
|
846 RPointerArray<CXdmDocumentNode> nodes; |
|
847 CleanupClosePushL( nodes ); |
|
848 |
|
849 CXdmNodeAttribute* attr = NULL; |
|
850 |
|
851 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
852 CXdmDocumentNode* foundNode = SearchListUnderParentL( buddylist, aList ); |
|
853 if ( foundNode ) |
|
854 { |
|
855 nodes.Reset(); |
|
856 // Do not leave if there is nobody blocked |
|
857 TRAP_IGNORE( foundNode->Find( KSimpleEntry, nodes )); |
|
858 TInt nodeCount = nodes.Count(); |
|
859 for ( TInt i = 0; i < nodeCount; i++ ) |
|
860 { |
|
861 attr = (nodes[i])->Attribute( KSimpleUri ); |
|
862 if ( attr ) |
|
863 { |
|
864 aMembers.AppendL( attr->AttributeValue() ); |
|
865 } |
|
866 } |
|
867 } |
|
868 |
|
869 CleanupStack::PopAndDestroy( &nodes ); |
|
870 } |
|
871 |
|
872 // --------------------------------------------------------------------------- |
|
873 // CSimplePluginXdmUtils::HandleRLSUpdateDocumentL |
|
874 // RLS Callback |
|
875 // --------------------------------------------------------------------------- |
|
876 // |
|
877 void CSimplePluginXdmUtils::HandleRLSUpdateDocumentL( TInt aErrorCode ) |
|
878 { |
|
879 #ifdef _DEBUG |
|
880 PluginLogger::Log(_L("PluginXdm: HandleRLSUpdateDocumentL %d"), aErrorCode); |
|
881 #ifdef FAKE_XDM_OK |
|
882 |
|
883 if ( aErrorCode == KErrTimedOut || aErrorCode == KXcapErrorNetworkNotAvailabe || aErrorCode == KErrHostUnreach ) |
|
884 { |
|
885 PluginLogger::Log( |
|
886 _L("PluginXdm : HandleRLSUpdateDocumentL FAKE_XDM_OK resets error code %d"), |
|
887 aErrorCode ); |
|
888 aErrorCode = 0; |
|
889 } |
|
890 #endif |
|
891 #endif |
|
892 |
|
893 TRAPD( err, DoHandleRLSUpdateDocumentL( aErrorCode )); |
|
894 if ( err ) |
|
895 { |
|
896 // Complete with ok or error the last initial opreration |
|
897 CompleteClientReq( err ); |
|
898 } |
|
899 } |
|
900 |
|
901 // --------------------------------------------------------------------------- |
|
902 // CSimplePluginXdmUtils::DoHandleRLSUpdateDocumentL |
|
903 // --------------------------------------------------------------------------- |
|
904 // |
|
905 void CSimplePluginXdmUtils::DoHandleRLSUpdateDocumentL( TInt aErrorCode ) |
|
906 { |
|
907 |
|
908 if ( iTestObs ) |
|
909 { |
|
910 // Test suite |
|
911 iTestObs->TestCallbackInRunL( aErrorCode, iXdmState, iOperation, KNullDesC ); |
|
912 } |
|
913 |
|
914 // Resend 409 failed request only if the server sent a preposal for the right URI |
|
915 // and only once, so that this do not remain in endless loop between server and |
|
916 // a client. |
|
917 if ( aErrorCode == KXcapErrorHttpConflict && |
|
918 iOperation == EXdmRlsAdd && |
|
919 iRlsXdm->NegotiatedServiceUri().Length() ) |
|
920 { |
|
921 RlsServiceUriNegotiationL(); |
|
922 return; |
|
923 } |
|
924 |
|
925 switch ( iXdmState ) |
|
926 { |
|
927 case EGetRlsServices: |
|
928 if ( aErrorCode == KXcapErrorHttpNotFound || aErrorCode == KErrNotFound ) |
|
929 { |
|
930 aErrorCode = KErrNone; |
|
931 } |
|
932 break; |
|
933 default: |
|
934 break; |
|
935 } |
|
936 |
|
937 CompleteClientReq( aErrorCode ); |
|
938 } |
|
939 |
|
940 // --------------------------------------------------------------------------- |
|
941 // CSimplePluginXdmUtils::HandleRLSUpdateCancelL |
|
942 // --------------------------------------------------------------------------- |
|
943 // |
|
944 void CSimplePluginXdmUtils::HandleRLSUpdateCancelL( TInt /*aErrorCode*/ ) |
|
945 { |
|
946 // notice: not needed |
|
947 } |
|
948 |
|
949 // --------------------------------------------------------------------------- |
|
950 // CSimplePluginXdmUtils::HandleRLSDeleteAllEmptyListsL |
|
951 // --------------------------------------------------------------------------- |
|
952 // |
|
953 void CSimplePluginXdmUtils::HandleRLSDeleteAllEmptyListsL( TInt /*aErrorCode*/ ) |
|
954 { |
|
955 // Notice: Not needed |
|
956 } |
|
957 |
|
958 // --------------------------------------------------------------------------- |
|
959 // CSimplePluginXdmUtils::HandlePresUpdateDocumentL |
|
960 // --------------------------------------------------------------------------- |
|
961 // |
|
962 void CSimplePluginXdmUtils::HandlePresUpdateDocumentL( TInt aErrorCode ) |
|
963 { |
|
964 #ifdef _DEBUG |
|
965 PluginLogger::Log(_L("PluginXdm: HandlePresUpdateDocumentL %d"), aErrorCode); |
|
966 #ifdef FAKE_XDM_OK |
|
967 if ( aErrorCode == KErrTimedOut || aErrorCode == KXcapErrorNetworkNotAvailabe || aErrorCode == KErrHostUnreach ) |
|
968 { |
|
969 PluginLogger::Log(_L("PluginXdm : HandlePresUpdateDocumentL FAKE_XDM_OK resets error code %d"), aErrorCode ); |
|
970 aErrorCode = 0; |
|
971 } |
|
972 #endif |
|
973 #endif |
|
974 |
|
975 TRAPD( err, DoHandlePresUpdateDocumentL( aErrorCode )); |
|
976 if ( err ) |
|
977 { |
|
978 // Complete with ok or error the last initial opreration |
|
979 CompleteClientReq( err ); |
|
980 } |
|
981 } |
|
982 |
|
983 // --------------------------------------------------------------------------- |
|
984 // CSimplePluginXdmUtils::DoHandlePresUpdateDocumentL |
|
985 // --------------------------------------------------------------------------- |
|
986 // |
|
987 void CSimplePluginXdmUtils::DoHandlePresUpdateDocumentL( TInt aErrorCode ) |
|
988 { |
|
989 |
|
990 if ( iTestObs ) |
|
991 { |
|
992 // Test suite |
|
993 iTestObs->TestCallbackInRunL( |
|
994 aErrorCode, iXdmState, iOperation, KNullDesC ); |
|
995 } |
|
996 |
|
997 if ( iXdmState == EGetXdmRules ) |
|
998 { |
|
999 iXdmState = EStateIdle; |
|
1000 if ( aErrorCode && aErrorCode != KXcapErrorHttpNotFound && |
|
1001 aErrorCode != KErrNotFound ) |
|
1002 { |
|
1003 User::Leave( aErrorCode ); |
|
1004 } |
|
1005 // check and create the rules when needed |
|
1006 MakeInitialXdmsDocumentL(); |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 iPresXdmOk = ETrue; |
|
1011 // Complete with ok or error the last initial opreration |
|
1012 CompleteClientReq( aErrorCode ); |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 // --------------------------------------------------------------------------- |
|
1017 // CSimplePluginXdmUtils::HandlePresUpdateCancelL |
|
1018 // --------------------------------------------------------------------------- |
|
1019 // |
|
1020 void CSimplePluginXdmUtils::HandlePresUpdateCancelL( TInt /*aErrorCode*/ ) |
|
1021 { |
|
1022 // notice: not needed |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // CSimplePluginXdmUtils::GetXdmOMAListsL |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // |
|
1029 void CSimplePluginXdmUtils::GetXdmOMAListsL() |
|
1030 { |
|
1031 #ifdef _DEBUG |
|
1032 PluginLogger::Log(_L("PluginXdm: GetXdmOMAListsL")); |
|
1033 #endif |
|
1034 if ( !iXdmEngine ) |
|
1035 { |
|
1036 // get data from a network if not done so yet |
|
1037 CXdmProtocolInfo* info = CXdmProtocolInfo::NewL( iSettingsId ); |
|
1038 CleanupStack::PushL( info ); |
|
1039 // Notice: we don't use cache for XDM |
|
1040 info->SetCacheUsage( EFalse ); |
|
1041 iXdmEngine = CXdmEngine::NewL( *info ); |
|
1042 CleanupStack::PopAndDestroy( info ); |
|
1043 } |
|
1044 if ( !iXdmOk ) |
|
1045 { |
|
1046 using namespace NSimplePlugin::NSimpleOma; |
|
1047 if ( iXdmDoc ) |
|
1048 { |
|
1049 // Clean a document from s previous failed case. |
|
1050 iXdmEngine->DeleteDocumentModelL( iXdmDoc ); |
|
1051 iXdmDoc = NULL; |
|
1052 } |
|
1053 |
|
1054 // Get data from network |
|
1055 iXdmDoc = iXdmEngine->CreateDocumentModelL( KSimpleIndex, EXdmSharedXdm ); |
|
1056 iXdmDoc->FetchDataL(); |
|
1057 UpdateXdmsL(); |
|
1058 iXdmState = EGetXdmOMALists; |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 // Document already exists, no need to search from a server |
|
1063 iStatus = KRequestPending; |
|
1064 TRequestStatus* s= &iStatus; |
|
1065 User::RequestComplete( s, KErrNone ); |
|
1066 SetActive(); |
|
1067 } |
|
1068 } |
|
1069 |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // CSimplePluginXdmUtils::CreateXdmOMAListsIfNeededL |
|
1072 // Notice: separate CheckXdmOMAListsL method (validity) |
|
1073 // --------------------------------------------------------------------------- |
|
1074 // |
|
1075 TBool CSimplePluginXdmUtils::CreateXdmOMAListsIfNeededL( ) |
|
1076 { |
|
1077 #ifdef _DEBUG |
|
1078 PluginLogger::Log(_L("PluginXdm: CreateXdmOMAListsIfNeededL")); |
|
1079 #endif |
|
1080 |
|
1081 using namespace NSimplePlugin::NSimpleOma; |
|
1082 |
|
1083 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
1084 if ( !root ) |
|
1085 { |
|
1086 root = iXdmDoc->CreateRootL(); |
|
1087 root->SetNameL( KSimpleResourceLists ); |
|
1088 } |
|
1089 |
|
1090 if ( root->IsEmptyNode() ) |
|
1091 { |
|
1092 root->SetEmptyNode( EFalse ); |
|
1093 } |
|
1094 |
|
1095 TInt isCreated = 0; |
|
1096 |
|
1097 // add all the list nodes |
|
1098 |
|
1099 isCreated += CreateXdmOMAListIfNeededL( root, iConnSets.Variation().SharedXdmTop() ); |
|
1100 |
|
1101 isCreated += CreateXdmOMAListIfNeededL( root, KSimpleOMABlockedList ); |
|
1102 |
|
1103 // grant-list name is variable issue |
|
1104 isCreated += CreateXdmOMAListIfNeededL( root, iConnSets.Variation().GrantListName() ); |
|
1105 |
|
1106 if ( !isCreated ) |
|
1107 { |
|
1108 return EFalse; |
|
1109 } |
|
1110 |
|
1111 // send to the server and start wait a response |
|
1112 iXdmDoc->AppendL( root ); |
|
1113 UpdateXdmsL(); |
|
1114 iXdmState = ECreateXdmOMALists; |
|
1115 |
|
1116 return ETrue; |
|
1117 } |
|
1118 |
|
1119 // --------------------------------------------------------------------------- |
|
1120 // CSimplePluginXdmUtils::CreateXdmOMAListIfNeededL |
|
1121 // --------------------------------------------------------------------------- |
|
1122 // |
|
1123 TBool CSimplePluginXdmUtils::CreateXdmOMAListIfNeededL( |
|
1124 CXdmDocumentNode* aRoot, const TDesC& aName ) |
|
1125 { |
|
1126 TBool isCreated( EFalse ); |
|
1127 CXdmDocumentNode* nodeFound = SearchListUnderParentL( aRoot, aName ); |
|
1128 if ( !nodeFound ) |
|
1129 { |
|
1130 CreateResourceListL( aRoot, aName ); |
|
1131 isCreated = ETrue; |
|
1132 } |
|
1133 return isCreated; |
|
1134 } |
|
1135 |
|
1136 // --------------------------------------------------------------------------- |
|
1137 // CSimplePluginXdmUtils::CreateResourceListL |
|
1138 // --------------------------------------------------------------------------- |
|
1139 // |
|
1140 void CSimplePluginXdmUtils::CreateResourceListL( |
|
1141 CXdmDocumentNode* aParent, const TDesC& aName ) |
|
1142 { |
|
1143 #ifdef _DEBUG |
|
1144 PluginLogger::Log(_L("PluginXdm: CreateResourceListL")); |
|
1145 #endif |
|
1146 using namespace NSimplePlugin::NSimpleOma; |
|
1147 CXdmDocumentNode* child1 = aParent->CreateChileNodeL( KSimpleList ); |
|
1148 CXdmNodeAttribute* name = child1->CreateAttributeL( KSimpleName ); |
|
1149 name->SetAttributeValueL( aName ); |
|
1150 } |
|
1151 |
|
1152 // --------------------------------------------------------------------------- |
|
1153 // CSimplePluginXdmUtils::SearchListUnderParentL |
|
1154 // --------------------------------------------------------------------------- |
|
1155 // |
|
1156 CXdmDocumentNode* CSimplePluginXdmUtils::SearchListUnderParentL( |
|
1157 CXdmDocumentNode* aParent, const TDesC& aName ) |
|
1158 { |
|
1159 using namespace NSimplePlugin::NSimpleOma; |
|
1160 |
|
1161 if ( !aParent ) |
|
1162 { |
|
1163 return NULL; |
|
1164 } |
|
1165 |
|
1166 RPointerArray<CXdmDocumentNode> resultArray; |
|
1167 RPointerArray<SXdmAttribute16> attributeArray; |
|
1168 |
|
1169 CleanupClosePushL( resultArray ); // <<< resultArray |
|
1170 CleanupClosePushL( attributeArray ); // <<< attributeArray |
|
1171 |
|
1172 SXdmAttribute16 attr; |
|
1173 attr.iName.Set( KSimpleName ); |
|
1174 attr.iValue.Set( aName ); |
|
1175 attributeArray.Append( &attr ); |
|
1176 |
|
1177 CXdmDocumentNode* currNode = NULL; |
|
1178 |
|
1179 aParent->Find( KSimpleList, resultArray, attributeArray ); |
|
1180 |
|
1181 TInt count = resultArray.Count(); |
|
1182 for ( TInt i=0; i < count; i++ ) |
|
1183 { |
|
1184 currNode = resultArray[i]; |
|
1185 CXdmDocumentNode* parent = currNode->Parent(); |
|
1186 if ( parent == aParent ) |
|
1187 { |
|
1188 break; |
|
1189 } |
|
1190 currNode = NULL; |
|
1191 } |
|
1192 |
|
1193 CleanupStack::PopAndDestroy( &attributeArray); // >>> attributeArray |
|
1194 CleanupStack::PopAndDestroy( &resultArray ); // >>> resultArray |
|
1195 |
|
1196 return currNode; |
|
1197 |
|
1198 } |
|
1199 |
|
1200 // --------------------------------------------------------------------------- |
|
1201 // CSimplePluginXdmUtils::MakeRlsUriL |
|
1202 // --------------------------------------------------------------------------- |
|
1203 // |
|
1204 HBufC* CSimplePluginXdmUtils::MakeRlsUriL( |
|
1205 const TDesC& aXcapUri, const TDesC& aListName ) |
|
1206 { |
|
1207 |
|
1208 #ifdef _DEBUG |
|
1209 PluginLogger::Log(_L("PluginXdm: MakeRlsUriL")); |
|
1210 #endif |
|
1211 |
|
1212 /* example: |
|
1213 "http://XCAP.EXAMPLE.COM/resource-lists/users/ |
|
1214 sip:USER@EXAMPLE.COM/index/~~/resource-lists/list%5b@name=%22oma_blockedlist%22%5d" |
|
1215 */ |
|
1216 |
|
1217 using namespace NSimplePlugin::NSimpleRls; |
|
1218 |
|
1219 TInt myLen = totalSize; |
|
1220 myLen += aXcapUri.Length(); |
|
1221 myLen += aListName.Length(); |
|
1222 myLen += iConnSets.CurrentSipPresentity().Length(); |
|
1223 HBufC* myBuf = HBufC::NewL( myLen ); |
|
1224 |
|
1225 myBuf->Des().Append( KOne ); |
|
1226 myBuf->Des().Append( aXcapUri); |
|
1227 myBuf->Des().Append( KThree ); |
|
1228 myBuf->Des().Append( iConnSets.CurrentSipPresentity() ); |
|
1229 myBuf->Des().Append( KFive ); |
|
1230 myBuf->Des().Append( aListName ); |
|
1231 myBuf->Des().Append( KSeven ); |
|
1232 |
|
1233 return myBuf; |
|
1234 } |
|
1235 |
|
1236 // --------------------------------------------------------------------------- |
|
1237 // CSimplePluginXdmUtils::MakeRlsBuddyUriL |
|
1238 // --------------------------------------------------------------------------- |
|
1239 // |
|
1240 HBufC* CSimplePluginXdmUtils::MakeRlsBuddyUriL( |
|
1241 const TDesC& aXcapUri, const TDesC& aListName ) |
|
1242 { |
|
1243 /* example: |
|
1244 "http://XCAP.EXAMPLE.COM/resource-lists/users/ |
|
1245 sip:USER@EXAMPLE.COM/~~/resource-lists/list%5b@name=%22oma_buddylist%22%5d/ |
|
1246 list5d@name=%22my_friends%22%5d" |
|
1247 */ |
|
1248 |
|
1249 using namespace NSimplePlugin::NSimpleRlsBuddy; |
|
1250 |
|
1251 TInt myLen = totalSize + aXcapUri.Length() + aListName.Length() + |
|
1252 iConnSets.CurrentSipPresentity().Length(); |
|
1253 |
|
1254 HBufC* myBuf = HBufC::NewL( myLen ); |
|
1255 TPtr temp = myBuf->Des(); |
|
1256 |
|
1257 temp.Append( KOne ); |
|
1258 temp.Append( aXcapUri); |
|
1259 temp.Append( KThree ); |
|
1260 temp.Append( iConnSets.CurrentSipPresentity() ); |
|
1261 temp.Append( KFive ); |
|
1262 temp.Append( aListName ); |
|
1263 temp.Append( KSeven ); |
|
1264 |
|
1265 return myBuf; |
|
1266 } |
|
1267 |
|
1268 // --------------------------------------------------------------------------- |
|
1269 // CSimplePluginXdmUtils::GetXdmRulesL |
|
1270 // --------------------------------------------------------------------------- |
|
1271 // |
|
1272 void CSimplePluginXdmUtils::GetXdmRulesL() |
|
1273 { |
|
1274 #ifdef _DEBUG |
|
1275 PluginLogger::Log(_L("PluginXdm: GetXdmRulesL")); |
|
1276 #endif |
|
1277 if ( !iPresenceXdm ) |
|
1278 { |
|
1279 // get data from a network if not done so yet |
|
1280 iPresenceXdm = CPresenceXDM::NewL( iSettingsId ); |
|
1281 } |
|
1282 User::LeaveIfError( iPresenceXdm->UpdateAllFromServerL( this )); |
|
1283 iXdmState = EGetXdmRules; |
|
1284 // The is completed in a callback method, not in RunL |
|
1285 } |
|
1286 |
|
1287 // --------------------------------------------------------------------------- |
|
1288 // CSimplePluginXdmUtils::MakeInitialXdmsDocumentL |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // |
|
1291 void CSimplePluginXdmUtils::MakeInitialXdmsDocumentL() |
|
1292 { |
|
1293 |
|
1294 #ifdef _DEBUG |
|
1295 PluginLogger::Log(_L("PluginXdm: MakeInitialXdmsDocumentL")); |
|
1296 #endif |
|
1297 TBuf<KSimplePluginMaxRuleLength> myRuleId; |
|
1298 |
|
1299 TBool ruleAdded( EFalse ); |
|
1300 |
|
1301 TPresenceActionXDM action; |
|
1302 action.Init( iPresenceXdm ); |
|
1303 |
|
1304 TPresenceTransformXDM transform; |
|
1305 transform.Init( iPresenceXdm ); |
|
1306 |
|
1307 TPresCondMisc misc; |
|
1308 misc.Init( iPresenceXdm ); |
|
1309 |
|
1310 TPresCondIdentityOne one; |
|
1311 one.Init( iPresenceXdm ); |
|
1312 |
|
1313 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
1314 CleanupStack::PushL( xcapUri ); |
|
1315 HBufC* listUri = MakeRlsUriL( xcapUri->Des(), KSimpleOMABlockedList ); |
|
1316 CleanupStack::PushL( listUri ); |
|
1317 |
|
1318 // Default rule |
|
1319 // get the rule id, use run-time variation |
|
1320 myRuleId = iConnSets.Variation().DefaultRuleName(); // KSimpleXdmDefaultRule; |
|
1321 if ( myRuleId.Length() && !iPresenceXdm->IsRuleExist( myRuleId )) |
|
1322 { |
|
1323 // If default rule does not exist in the variation then do not create it. |
|
1324 MakeDefaultRuleL( myRuleId, action, transform, misc ); |
|
1325 ruleAdded = ETrue; |
|
1326 } |
|
1327 |
|
1328 // Block rule |
|
1329 // get the rule id, use run-time variation |
|
1330 myRuleId = iConnSets.Variation().BlockRuleName(); |
|
1331 // ruleCreate = EFalse; |
|
1332 |
|
1333 if ( !iPresenceXdm->IsRuleExist( myRuleId )) |
|
1334 { |
|
1335 iPresenceXdm->CreateNewRuleL( myRuleId ); |
|
1336 ruleAdded = ETrue; |
|
1337 |
|
1338 // use run-time variation for rule action |
|
1339 CSimplePluginVariation::TSimplePluginAuthRule authRule = |
|
1340 iConnSets.Variation().BlockRuleAction(); |
|
1341 |
|
1342 User::LeaveIfError( misc.AddExternListL( myRuleId, listUri->Des() )); |
|
1343 |
|
1344 switch (authRule) |
|
1345 { |
|
1346 case CSimplePluginVariation::ERulePoliteBlock: |
|
1347 User::LeaveIfError( action.AddOrReplaceActionL(myRuleId, KPresPoliteBlock )); |
|
1348 break; |
|
1349 default: |
|
1350 User::LeaveIfError( action.AddOrReplaceActionL(myRuleId, KPresBlock )); |
|
1351 }; |
|
1352 } |
|
1353 |
|
1354 // Grant rule |
|
1355 // get the rule id, use run-time variation |
|
1356 myRuleId = iConnSets.Variation().GrantRuleName(); |
|
1357 if ( !iPresenceXdm->IsRuleExist( myRuleId )) |
|
1358 { |
|
1359 iPresenceXdm->CreateNewRuleL( myRuleId ); |
|
1360 ruleAdded = ETrue; |
|
1361 CleanupStack::PopAndDestroy( listUri ); |
|
1362 listUri = NULL; |
|
1363 listUri = MakeRlsUriL( xcapUri->Des(), iConnSets.Variation().GrantListName() ); |
|
1364 CleanupStack::PushL( listUri ); |
|
1365 User::LeaveIfError( misc.AddExternListL( myRuleId, listUri->Des() )); |
|
1366 User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow )); |
|
1367 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1368 myRuleId, KPresProvideAllAttributes )); |
|
1369 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1370 myRuleId, KPresProvidePersons )); |
|
1371 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1372 myRuleId, KPresProvideDevices )); |
|
1373 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1374 myRuleId, KPresProvideServices )); |
|
1375 } |
|
1376 |
|
1377 // Grant own subscription rule |
|
1378 // get the rule id, use run-time variation |
|
1379 myRuleId = iConnSets.Variation().GrantOwnRuleName(); |
|
1380 if ( !iPresenceXdm->IsRuleExist( myRuleId )) |
|
1381 { |
|
1382 iPresenceXdm->CreateNewRuleL( myRuleId ); |
|
1383 ruleAdded = ETrue; |
|
1384 User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow )); |
|
1385 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1386 myRuleId, KPresProvideAllAttributes )); |
|
1387 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1388 myRuleId, KPresProvidePersons )); |
|
1389 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1390 myRuleId, KPresProvideDevices )); |
|
1391 User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL( |
|
1392 myRuleId, KPresProvideServices )); |
|
1393 // own sip identity |
|
1394 User::LeaveIfError( one.AddIdentityL( |
|
1395 myRuleId, iConnSets.CurrentSipPresentity() )); |
|
1396 } |
|
1397 |
|
1398 // Update into server only when needed. |
|
1399 if ( ruleAdded ) |
|
1400 { |
|
1401 UpdateXdmRulesL(); |
|
1402 } |
|
1403 else |
|
1404 { |
|
1405 iXdmState = EUpdateXdmRules; |
|
1406 iPresXdmOk = ETrue; |
|
1407 // Complete with ok or error the last initial opreration |
|
1408 CompleteClientReq( KErrNone ); |
|
1409 } |
|
1410 |
|
1411 CleanupStack::PopAndDestroy( listUri ); |
|
1412 CleanupStack::PopAndDestroy( xcapUri ); |
|
1413 } |
|
1414 |
|
1415 // --------------------------------------------------------------------------- |
|
1416 // CSimplePluginXdmUtils::DoGrantForAllL |
|
1417 // --------------------------------------------------------------------------- |
|
1418 // |
|
1419 void CSimplePluginXdmUtils::DoGrantForAllL() |
|
1420 { |
|
1421 const TInt KMyPresRuleIDLength(30); |
|
1422 TBuf<KMyPresRuleIDLength> myRuleId; |
|
1423 |
|
1424 TInt err( KErrNone ); |
|
1425 |
|
1426 TPresenceActionXDM action; |
|
1427 action.Init( iPresenceXdm ); |
|
1428 |
|
1429 // Default rule id is searched |
|
1430 myRuleId = iConnSets.Variation().DefaultRuleName(); // KSimpleXdmDefaultRule; |
|
1431 TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) ); |
|
1432 if ( err && err != KErrAlreadyExists ) |
|
1433 { |
|
1434 User::Leave( err ); |
|
1435 } |
|
1436 |
|
1437 // modify the rule in the server. |
|
1438 User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow )); |
|
1439 UpdateXdmRulesL(); |
|
1440 } |
|
1441 |
|
1442 // --------------------------------------------------------------------------- |
|
1443 // CSimplePluginXdmUtils::DoWithdrawFromAllL |
|
1444 // --------------------------------------------------------------------------- |
|
1445 // |
|
1446 void CSimplePluginXdmUtils::DoWithdrawFromAllL() |
|
1447 { |
|
1448 const TInt KMyPresRuleIDLength(30); |
|
1449 TBuf<KMyPresRuleIDLength> myRuleId; |
|
1450 |
|
1451 /* pseudo code: |
|
1452 if current rule is ALLOW then { BLOCK } |
|
1453 otherwise no action. |
|
1454 */ |
|
1455 |
|
1456 #ifdef _DEBUG |
|
1457 PluginLogger::Log(_L("PluginWatcher: DoWithdrawFromAllL TEST COVERS 3")); |
|
1458 #endif |
|
1459 |
|
1460 |
|
1461 TInt err( KErrNone ); |
|
1462 |
|
1463 TPresenceActionXDM action; |
|
1464 action.Init( iPresenceXdm ); |
|
1465 |
|
1466 // Default rule id is searched |
|
1467 myRuleId = iConnSets.Variation().DefaultRuleName(); |
|
1468 TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) ); |
|
1469 if ( err && err != KErrAlreadyExists ) |
|
1470 { |
|
1471 User::Leave( err ); |
|
1472 } |
|
1473 |
|
1474 TBuf<KMyPresRuleIDLength> myActionBuf; |
|
1475 err = action.GetActionL( myRuleId, myActionBuf); |
|
1476 |
|
1477 if ( !myActionBuf.CompareF( KPresAllow ) ) |
|
1478 { |
|
1479 User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresPoliteBlock )); |
|
1480 UpdateXdmRulesL(); |
|
1481 *iClientStatus = KRequestPending; |
|
1482 } |
|
1483 else |
|
1484 { |
|
1485 CompleteClientReq( KErrNone ); |
|
1486 } |
|
1487 } |
|
1488 |
|
1489 // --------------------------------------------------------------------------- |
|
1490 // CSimplePluginXdmUtils::DoSetReactiveAuthL |
|
1491 // --------------------------------------------------------------------------- |
|
1492 // |
|
1493 void CSimplePluginXdmUtils::DoSetReactiveAuthL() |
|
1494 { |
|
1495 #ifdef _DEBUG |
|
1496 PluginLogger::Log( |
|
1497 _L("PluginWatcher: DoSetReactiveAuthL TEST COVERS 5")); |
|
1498 #endif |
|
1499 |
|
1500 // Default rule is modified to CONFIRM |
|
1501 |
|
1502 const TInt KMyPresRuleIDLength(30); |
|
1503 TBuf<KMyPresRuleIDLength> myRuleId; |
|
1504 |
|
1505 TInt err( KErrNone ); |
|
1506 |
|
1507 TPresenceActionXDM action; |
|
1508 action.Init( iPresenceXdm ); |
|
1509 |
|
1510 // Default rule id is searched |
|
1511 myRuleId = iConnSets.Variation().DefaultRuleName(); |
|
1512 TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) ); |
|
1513 if ( err && err != KErrAlreadyExists ) |
|
1514 { |
|
1515 #ifdef _DEBUG |
|
1516 PluginLogger::Log( _L("PluginWatcher: TEST COVERS 5b")); |
|
1517 #endif |
|
1518 User::Leave( err ); |
|
1519 } |
|
1520 |
|
1521 // modify the rule in the server. |
|
1522 User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresConfirm )); |
|
1523 UpdateXdmRulesL(); |
|
1524 } |
|
1525 |
|
1526 // --------------------------------------------------------------------------- |
|
1527 // CSimplePluginXdmUtils::DoSetProactiveAuthL |
|
1528 // --------------------------------------------------------------------------- |
|
1529 // |
|
1530 void CSimplePluginXdmUtils::DoSetProactiveAuthL() |
|
1531 { |
|
1532 #ifdef _DEBUG |
|
1533 PluginLogger::Log( |
|
1534 _L("PluginWatcher: DoSetProactiveAuthL TEST COVERS 6")); |
|
1535 #endif |
|
1536 |
|
1537 /* pseudo code: |
|
1538 if current rule is CONFIRM then { ALLOW } |
|
1539 otherwise no action. |
|
1540 */ |
|
1541 |
|
1542 const TInt KMyPresRuleIDLength(30); |
|
1543 TBuf<KMyPresRuleIDLength> myRuleId; |
|
1544 |
|
1545 TInt err( KErrNone ); |
|
1546 |
|
1547 TPresenceActionXDM action; |
|
1548 action.Init( iPresenceXdm ); |
|
1549 |
|
1550 // Default rule id is searched |
|
1551 myRuleId = iConnSets.Variation().DefaultRuleName(); |
|
1552 TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) ); |
|
1553 if ( err && err != KErrAlreadyExists ) |
|
1554 { |
|
1555 User::Leave( err ); |
|
1556 } |
|
1557 |
|
1558 // modify the rule in the server. |
|
1559 TBuf<KMyPresRuleIDLength> myActionBuf; |
|
1560 err = action.GetActionL( myRuleId, myActionBuf); |
|
1561 |
|
1562 if ( !myActionBuf.CompareF( KPresConfirm ) ) |
|
1563 { |
|
1564 User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow )); |
|
1565 UpdateXdmRulesL(); |
|
1566 *iClientStatus = KRequestPending; |
|
1567 } |
|
1568 else |
|
1569 { |
|
1570 CompleteClientReq( KErrNone ); |
|
1571 } |
|
1572 |
|
1573 } |
|
1574 |
|
1575 // --------------------------------------------------------------------------- |
|
1576 // CSimplePluginXdmUtils::CreateEntityGroupL |
|
1577 // --------------------------------------------------------------------------- |
|
1578 // |
|
1579 void CSimplePluginXdmUtils::CreateEntityGroupL( |
|
1580 const TDesC& aName, const TDesC& aDisplayName ) |
|
1581 { |
|
1582 #ifdef _DEBUG |
|
1583 PluginLogger::Log(_L("PluginXdm: CreateEntityGroupL")); |
|
1584 #endif |
|
1585 iOperation = EXdmCreateGroup; |
|
1586 DoCreateEntityGroupL( aName, aDisplayName ); |
|
1587 } |
|
1588 |
|
1589 // --------------------------------------------------------------------------- |
|
1590 // CSimplePluginXdmUtils::DeleteEntityGroupL |
|
1591 // --------------------------------------------------------------------------- |
|
1592 // |
|
1593 void CSimplePluginXdmUtils::DeleteEntityGroupL( |
|
1594 const TDesC& aName) |
|
1595 { |
|
1596 #ifdef _DEBUG |
|
1597 PluginLogger::Log(_L("PluginXdm: DeleteEntityGroupL")); |
|
1598 #endif |
|
1599 |
|
1600 iOperation = EXdmDeleteGroup; |
|
1601 DoDeleteEntityGroupL( aName ); |
|
1602 } |
|
1603 |
|
1604 // --------------------------------------------------------------------------- |
|
1605 // CSimplePluginXdmUtils::AddPresentityGroupMemberL |
|
1606 // --------------------------------------------------------------------------- |
|
1607 // |
|
1608 void CSimplePluginXdmUtils::AddPresentityGroupMemberL( |
|
1609 const TDesC& aGroup, |
|
1610 const TDesC& aUser, |
|
1611 const TDesC& aDispName, |
|
1612 TRequestStatus& aStatus ) |
|
1613 { |
|
1614 #ifdef _DEBUG |
|
1615 PluginLogger::Log(_L("PluginXdm: AddPresentityGroupMemberL")); |
|
1616 #endif |
|
1617 |
|
1618 iClientStatus = &aStatus; |
|
1619 |
|
1620 iOperation = EXdmAddUserToGroup; |
|
1621 DoAddUserToUserListL( aGroup, aUser, aDispName ); |
|
1622 |
|
1623 // send to the server and start wait a response |
|
1624 UpdateXdmsL(); |
|
1625 |
|
1626 *iClientStatus = KRequestPending; |
|
1627 iXdmState = EUpdateXdmOMAList; |
|
1628 } |
|
1629 |
|
1630 // --------------------------------------------------------------------------- |
|
1631 // CSimplePluginXdmUtils::RemovePresentityGroupMemberL |
|
1632 // --------------------------------------------------------------------------- |
|
1633 // |
|
1634 void CSimplePluginXdmUtils::RemovePresentityGroupMemberL( |
|
1635 const TDesC& aGroup, |
|
1636 const TDesC& aUser, |
|
1637 TRequestStatus& aStatus ) |
|
1638 { |
|
1639 #ifdef _DEBUG |
|
1640 PluginLogger::Log(_L("PluginXdm: RemovePresentityGroupMemberL")); |
|
1641 #endif |
|
1642 |
|
1643 iClientStatus = &aStatus; |
|
1644 |
|
1645 iOperation = EXdmAddUserToGroup; |
|
1646 DoRemoveUserFromUserListL( aGroup, aUser ); |
|
1647 |
|
1648 // send to the server and start wait a response |
|
1649 UpdateXdmsL(); |
|
1650 |
|
1651 *iClientStatus = KRequestPending; |
|
1652 iXdmState = EUpdateXdmOMAList; |
|
1653 } |
|
1654 |
|
1655 // --------------------------------------------------------------------------- |
|
1656 // CSimplePluginXdmUtils::GetUserListsL |
|
1657 // --------------------------------------------------------------------------- |
|
1658 // |
|
1659 void CSimplePluginXdmUtils::GetUserListsL( |
|
1660 CDesCArrayFlat& aIds, CDesCArrayFlat& aDispNames ) |
|
1661 { |
|
1662 #ifdef _DEBUG |
|
1663 PluginLogger::Log(_L("PluginXdm: GetUserListsL")); |
|
1664 #endif |
|
1665 using namespace NSimplePlugin::NSimpleOma; |
|
1666 |
|
1667 aIds.Reset(); |
|
1668 aDispNames.Reset(); |
|
1669 |
|
1670 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
1671 CXdmDocumentNode* entry = NULL; |
|
1672 |
|
1673 RPointerArray<CXdmDocumentNode> lists; |
|
1674 CleanupClosePushL( lists ); // <<< lists |
|
1675 |
|
1676 RPointerArray<CXdmDocumentNode> lists2; |
|
1677 CleanupClosePushL( lists2 ); // <<< lists2 |
|
1678 |
|
1679 buddylist->Find( KSimpleList, lists ); |
|
1680 TInt count = lists.Count(); |
|
1681 for ( TInt i=0; i < count; i++ ) |
|
1682 { |
|
1683 // Name |
|
1684 entry = lists[i]; |
|
1685 CXdmNodeAttribute* attr = entry->Attribute( KSimpleName ); |
|
1686 if ( attr ) |
|
1687 { |
|
1688 aIds.AppendL( attr->AttributeValue() ); |
|
1689 #ifdef _DEBUG |
|
1690 TBuf<200> debug_buffer; |
|
1691 debug_buffer = attr->AttributeValue(); |
|
1692 PluginLogger::Log(_L("PluginXdm: add group id into aIds : %S"), &debug_buffer ); |
|
1693 #endif |
|
1694 } |
|
1695 else |
|
1696 { |
|
1697 continue; |
|
1698 } |
|
1699 // Display name |
|
1700 TInt err = entry->Find( KSimpleDisplayName, lists2 ); |
|
1701 // Notice: assume there is only one display-name. |
|
1702 // Always when an item is added into aIds we have to add an itmem also into aDispNames. |
|
1703 if ( !err ) |
|
1704 { |
|
1705 CXdmDocumentNode* disName = lists2[0]; |
|
1706 if ( !disName->IsEmptyNode() ) |
|
1707 { |
|
1708 // Convert Display-Name to Unicode. |
|
1709 HBufC16* uri16 = NULL; |
|
1710 uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( disName->LeafNodeContent() ); |
|
1711 CleanupStack::PushL( uri16 ); // << uri16 |
|
1712 aDispNames.AppendL( uri16->Des() ); |
|
1713 CleanupStack::PopAndDestroy( uri16 ); // >> uri16 |
|
1714 } |
|
1715 else |
|
1716 { |
|
1717 aDispNames.AppendL( KNullDesC ); |
|
1718 } |
|
1719 } |
|
1720 else |
|
1721 { |
|
1722 aDispNames.AppendL( KNullDesC ); |
|
1723 } |
|
1724 } |
|
1725 |
|
1726 CleanupStack::PopAndDestroy( &lists2 ); // >>> lists2 |
|
1727 CleanupStack::PopAndDestroy( &lists ); // >>> lists |
|
1728 } |
|
1729 |
|
1730 // --------------------------------------------------------------------------- |
|
1731 // CSimplePluginXdmUtils::GetEntitiesInListL |
|
1732 // --------------------------------------------------------------------------- |
|
1733 // |
|
1734 void CSimplePluginXdmUtils::GetEntitiesInListL( |
|
1735 const TDesC& aList, CPtrCArray& aIds, CPtrCArray& aDispNames ) |
|
1736 { |
|
1737 #ifdef _DEBUG |
|
1738 PluginLogger::Log(_L("PluginXdm: GetEntitiesInListL")); |
|
1739 #endif |
|
1740 |
|
1741 using namespace NSimplePlugin::NSimpleOma; |
|
1742 |
|
1743 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
1744 CXdmDocumentNode* target = DoGetUserListL( aList, buddylist ); |
|
1745 |
|
1746 // make a collection of MPresentityGroupMemberInfo |
|
1747 RPointerArray<CXdmDocumentNode> entries; |
|
1748 CleanupClosePushL(entries); // <<< entries |
|
1749 |
|
1750 RPointerArray<CXdmDocumentNode> nodes; |
|
1751 CleanupClosePushL(nodes); // <<< nodes |
|
1752 |
|
1753 target->Find( KSimpleEntry, entries ); |
|
1754 TInt count = entries.Count(); |
|
1755 for ( TInt i=0; i < count; i++ ) |
|
1756 { |
|
1757 // ID |
|
1758 CXdmDocumentNode* entry = entries[i]; |
|
1759 CXdmNodeAttribute* attr = entry->Attribute( KSimpleUri ); |
|
1760 if ( attr ) |
|
1761 { |
|
1762 aIds.AppendL( attr->AttributeValue() ); |
|
1763 #ifdef _DEBUG |
|
1764 TBuf<200> debug_buffer; |
|
1765 debug_buffer = attr->AttributeValue(); |
|
1766 PluginLogger::Log(_L("PluginXdm: add member into collection : %S"), &debug_buffer ); |
|
1767 #endif |
|
1768 } |
|
1769 else |
|
1770 { |
|
1771 continue; |
|
1772 } |
|
1773 |
|
1774 // Display name |
|
1775 TInt err = entry->Find( KSimpleDisplayName, nodes ); |
|
1776 // Notice: assume there is only one display-name |
|
1777 if ( !err ) |
|
1778 { |
|
1779 CXdmDocumentNode* disName = nodes[0]; |
|
1780 HBufC16* uri16 = NULL; |
|
1781 uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( disName->LeafNodeContent() ); |
|
1782 CleanupStack::PushL( uri16 ); // << uri16 |
|
1783 aDispNames.AppendL( uri16->Des() ); |
|
1784 CleanupStack::PopAndDestroy( uri16 ); // >> uri16 |
|
1785 } |
|
1786 else |
|
1787 { |
|
1788 aDispNames.AppendL( TPtrC() ); |
|
1789 } |
|
1790 } |
|
1791 |
|
1792 CleanupStack::PopAndDestroy( &nodes ); // >>> nodes |
|
1793 CleanupStack::PopAndDestroy( &entries ); // >>> entries |
|
1794 } |
|
1795 |
|
1796 // --------------------------------------------------------------------------- |
|
1797 // CSimplePluginXdmUtils::CommitXdmL |
|
1798 // --------------------------------------------------------------------------- |
|
1799 // |
|
1800 void CSimplePluginXdmUtils::CommitXdmL( TRequestStatus& aStatus ) |
|
1801 { |
|
1802 #ifdef _DEBUG |
|
1803 PluginLogger::Log(_L("PluginXdm: CommitXdmL")); |
|
1804 #endif |
|
1805 iClientStatus = &aStatus; |
|
1806 |
|
1807 UpdateXdmsL(); |
|
1808 |
|
1809 *iClientStatus = KRequestPending; |
|
1810 iXdmState = EUpdateXdmOMAList; |
|
1811 } |
|
1812 |
|
1813 // --------------------------------------------------------------------------- |
|
1814 // CSimplePluginXdmUtils::CommitRlsL |
|
1815 // --------------------------------------------------------------------------- |
|
1816 // |
|
1817 void CSimplePluginXdmUtils::CommitRlsL( TRequestStatus& aStatus ) |
|
1818 { |
|
1819 #ifdef _DEBUG |
|
1820 PluginLogger::Log(_L("PluginXdm: CommitRlsL")); |
|
1821 #endif |
|
1822 iClientStatus = &aStatus; |
|
1823 *iClientStatus = KRequestPending; |
|
1824 UpdateRlsL(); |
|
1825 |
|
1826 iXdmState = EUpdateRlsServices; |
|
1827 } |
|
1828 |
|
1829 // ---------------------------------------------------- |
|
1830 // CSimplePluginXdmUtils::DoCreateEntityGroupL |
|
1831 // ---------------------------------------------------- |
|
1832 // |
|
1833 void CSimplePluginXdmUtils::DoCreateEntityGroupL( |
|
1834 const TDesC& aList, const TDesC& aDisName ) |
|
1835 { |
|
1836 using namespace NSimplePlugin::NSimpleOma; |
|
1837 |
|
1838 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
1839 if ( buddylist->IsEmptyNode() ) |
|
1840 { |
|
1841 buddylist->SetEmptyNode( EFalse ); |
|
1842 } |
|
1843 |
|
1844 CXdmDocumentNode* foundNode = SearchListUnderParentL( |
|
1845 buddylist, aDisName ); |
|
1846 |
|
1847 if ( foundNode ) |
|
1848 { |
|
1849 User::Leave( KErrAlreadyExists ); |
|
1850 } |
|
1851 |
|
1852 CXdmDocumentNode* newNode = buddylist->CreateChileNodeL( KSimpleList ); |
|
1853 CXdmNodeAttribute* attributeName = newNode->CreateAttributeL( KSimpleName ); |
|
1854 attributeName->SetAttributeValueL( aList ); |
|
1855 |
|
1856 // Display name |
|
1857 CXdmDocumentNode* displayName = newNode->CreateChileNodeL( KSimpleDisplayName ); |
|
1858 displayName->SetLeafNode( ETrue ); |
|
1859 displayName->SetLeafNodeContentL( aDisName ); |
|
1860 |
|
1861 iXdmDoc->AppendL( newNode ); |
|
1862 } |
|
1863 |
|
1864 // ---------------------------------------------------- |
|
1865 // CSimplePluginXdmUtils::DoDeleteEntityGroupL |
|
1866 // ---------------------------------------------------- |
|
1867 // |
|
1868 void CSimplePluginXdmUtils::DoDeleteEntityGroupL( |
|
1869 const TDesC& aList ) |
|
1870 { |
|
1871 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
1872 CXdmDocumentNode* target = DoGetUserListL( aList, buddylist ); |
|
1873 iXdmDoc->DeleteDataL( target ); |
|
1874 // iXdmEngine is asked to be updated to a server by CSimplePlugingGroups later. |
|
1875 } |
|
1876 |
|
1877 // ---------------------------------------------------- |
|
1878 // CSimplePluginXdmUtils::DoAddUserToUserListL |
|
1879 // ---------------------------------------------------- |
|
1880 // |
|
1881 void CSimplePluginXdmUtils::DoAddUserToUserListL( |
|
1882 const TDesC& aList, const TDesC& aUser, const TDesC& aDisName ) |
|
1883 { |
|
1884 RPointerArray<CXdmDocumentNode> resultArray; |
|
1885 RPointerArray<SXdmAttribute16> attributeArray; |
|
1886 |
|
1887 CleanupClosePushL( resultArray ); // << resultArray |
|
1888 CleanupClosePushL( attributeArray ); // << attributeArray |
|
1889 |
|
1890 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
1891 CXdmDocumentNode* target = DoGetUserListL( aList, buddylist ); |
|
1892 |
|
1893 if ( target->IsEmptyNode() ) |
|
1894 { |
|
1895 target->SetEmptyNode( EFalse ); |
|
1896 } |
|
1897 |
|
1898 using namespace NSimplePlugin::NSimpleOma; |
|
1899 |
|
1900 SXdmAttribute16 attr; |
|
1901 attr.iName.Set( KSimpleUri ); |
|
1902 attr.iValue.Set( aUser ); |
|
1903 attributeArray.Append( &attr ); |
|
1904 |
|
1905 // If member already exists then leave |
|
1906 target->Find( KSimpleEntry, resultArray, attributeArray ); |
|
1907 if ( resultArray.Count() > 0 ) |
|
1908 { |
|
1909 User::Leave( KErrAlreadyExists ); |
|
1910 } |
|
1911 |
|
1912 CXdmDocumentNode* newNode = target->CreateChileNodeL( KSimpleEntry ); |
|
1913 CXdmNodeAttribute* attributeName = newNode->CreateAttributeL( KSimpleUri ); |
|
1914 attributeName->SetAttributeValueL( aUser ); |
|
1915 |
|
1916 // Display name |
|
1917 CXdmDocumentNode* displayName = newNode->CreateChileNodeL( KSimpleDisplayName ); |
|
1918 displayName->SetLeafNode( ETrue ); |
|
1919 displayName->SetLeafNodeContentL( aDisName ); |
|
1920 |
|
1921 iXdmDoc->AppendL( newNode ); |
|
1922 |
|
1923 CleanupStack::PopAndDestroy( &attributeArray ); |
|
1924 CleanupStack::PopAndDestroy( &resultArray ); |
|
1925 } |
|
1926 |
|
1927 // ---------------------------------------------------- |
|
1928 // CSimplePluginXdmUtils::DoRemoveUserFromUserListL |
|
1929 // ---------------------------------------------------- |
|
1930 // |
|
1931 void CSimplePluginXdmUtils::DoRemoveUserFromUserListL( |
|
1932 const TDesC& aList, const TDesC& aUri ) |
|
1933 { |
|
1934 CXdmNodeAttribute* attr = NULL; |
|
1935 TBool myFound( EFalse ); |
|
1936 |
|
1937 using namespace NSimplePlugin::NSimpleOma; |
|
1938 |
|
1939 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
1940 CXdmDocumentNode* target = DoGetUserListL( aList, buddylist ); |
|
1941 |
|
1942 RPointerArray<CXdmDocumentNode> entries; |
|
1943 CleanupClosePushL( entries ); // <<< entries |
|
1944 |
|
1945 User::LeaveIfError( target->Find( KSimpleEntry, entries )); |
|
1946 TInt nodeCount = entries.Count(); |
|
1947 for ( TInt i = 0; i < nodeCount; i++ ) |
|
1948 { |
|
1949 CXdmDocumentNode* currNode = entries[i]; |
|
1950 attr = currNode->Attribute( KSimpleUri ); |
|
1951 if ( attr && !attr->AttributeValue().CompareF( aUri )) |
|
1952 { |
|
1953 // This is the user we are looking for deletion. |
|
1954 iXdmDoc->DeleteDataL( currNode ); |
|
1955 myFound = ETrue; |
|
1956 break; |
|
1957 } |
|
1958 } |
|
1959 |
|
1960 CleanupStack::PopAndDestroy( &entries ); // >>> entries |
|
1961 |
|
1962 if ( !myFound ) |
|
1963 { |
|
1964 // If the member is not found then leave |
|
1965 User::Leave( KErrNotFound ); |
|
1966 } |
|
1967 } |
|
1968 |
|
1969 // --------------------------------------------------------------------------- |
|
1970 // CSimplePluginXdmUtils::DoGetBuddyListL |
|
1971 // --------------------------------------------------------------------------- |
|
1972 // |
|
1973 CXdmDocumentNode* CSimplePluginXdmUtils::DoGetBuddyListL() |
|
1974 { |
|
1975 CXdmDocumentNode* root = iXdmDoc->DocumentRoot(); |
|
1976 CXdmDocumentNode* ret = SearchListUnderParentL( root, iConnSets.Variation().SharedXdmTop() ); |
|
1977 if ( !ret ) |
|
1978 { |
|
1979 User::Leave( KErrNotFound ); |
|
1980 } |
|
1981 return ret; |
|
1982 } |
|
1983 |
|
1984 // --------------------------------------------------------------------------- |
|
1985 // CSimplePluginXdmUtils::DoGetUserListL |
|
1986 // --------------------------------------------------------------------------- |
|
1987 // |
|
1988 CXdmDocumentNode* CSimplePluginXdmUtils::DoGetUserListL( |
|
1989 const TDesC& aList, CXdmDocumentNode* aBuddyList ) |
|
1990 { |
|
1991 CXdmDocumentNode* listNode = NULL; |
|
1992 CXdmNodeAttribute* attr = NULL; |
|
1993 TBool found( EFalse ); |
|
1994 |
|
1995 using namespace NSimplePlugin::NSimpleOma; |
|
1996 |
|
1997 RPointerArray<CXdmDocumentNode> lists; |
|
1998 CleanupClosePushL( lists ); |
|
1999 |
|
2000 User::LeaveIfError( aBuddyList->Find( KSimpleList, lists )); |
|
2001 TInt count = lists.Count(); |
|
2002 for ( TInt i=0; i < count; i++ ) |
|
2003 { |
|
2004 listNode = lists[i]; |
|
2005 attr = listNode->Attribute( KSimpleName ); |
|
2006 if ( attr && !attr->AttributeValue().CompareF( aList )) |
|
2007 { |
|
2008 // List is found |
|
2009 found = ETrue; |
|
2010 break; |
|
2011 } |
|
2012 } |
|
2013 if ( !found ) |
|
2014 { |
|
2015 User::Leave( KErrNotFound ); |
|
2016 } |
|
2017 |
|
2018 CleanupStack::PopAndDestroy( &lists ); |
|
2019 return listNode; |
|
2020 } |
|
2021 |
|
2022 // --------------------------------------------------------------------------- |
|
2023 // CSimplePluginXdmUtils::UpdateXdmRulesL |
|
2024 // --------------------------------------------------------------------------- |
|
2025 // |
|
2026 void CSimplePluginXdmUtils::UpdateXdmRulesL() |
|
2027 { |
|
2028 _LIT( KMyOper, "UpdateXdmRulesL"); |
|
2029 if ( iTestObs ) |
|
2030 { |
|
2031 // Test suite |
|
2032 iTestObs->TestCallbackAsynchL( |
|
2033 KErrNone, iXdmState, iOperation, KMyOper ); |
|
2034 } |
|
2035 |
|
2036 #ifdef _DEBUG |
|
2037 PluginLogger::Log(_L("PluginXdm: UpdateXdmRulesL -> iPresenceXdm->UpdateToServerL")); |
|
2038 #endif |
|
2039 User::LeaveIfError( iPresenceXdm->UpdateToServerL( this )); |
|
2040 iXdmState = EUpdateXdmRules; |
|
2041 } |
|
2042 |
|
2043 // --------------------------------------------------------------------------- |
|
2044 // CSimplePluginXdmUtils::UpdateXdmsL |
|
2045 // --------------------------------------------------------------------------- |
|
2046 // |
|
2047 void CSimplePluginXdmUtils::UpdateXdmsL() |
|
2048 { |
|
2049 _LIT( KMyOper, "UpdateXdmsL"); |
|
2050 if ( iTestObs ) |
|
2051 { |
|
2052 // Test suite |
|
2053 iTestObs->TestCallbackAsynchL( |
|
2054 KErrNone, iXdmState, iOperation, KMyOper ); |
|
2055 } |
|
2056 |
|
2057 #ifdef _DEBUG |
|
2058 PluginLogger::Log(_L("PluginXdm: UpdateXdmsL -> iXdmEngine->UpdateToServerL")); |
|
2059 #endif |
|
2060 iXdmEngine->UpdateL( iXdmDoc, iStatus ); |
|
2061 SetActive(); |
|
2062 } |
|
2063 |
|
2064 // --------------------------------------------------------------------------- |
|
2065 // CSimplePluginXdmUtils::UpdateRlsL |
|
2066 // --------------------------------------------------------------------------- |
|
2067 // |
|
2068 void CSimplePluginXdmUtils::UpdateRlsL() |
|
2069 { |
|
2070 _LIT( KMyOper, "UpdateRlsL"); |
|
2071 |
|
2072 if ( iTestObs ) |
|
2073 { |
|
2074 // Test suite |
|
2075 iTestObs->TestCallbackAsynchL( |
|
2076 KErrNone, iXdmState, iOperation, KMyOper ); |
|
2077 } |
|
2078 #ifdef _DEBUG |
|
2079 PluginLogger::Log(_L("PluginXdm: -> iRlsXdm->UpdateToServerL")); |
|
2080 #endif |
|
2081 User::LeaveIfError( iRlsXdm->UpdateToServerL( this )); |
|
2082 } |
|
2083 |
|
2084 // --------------------------------------------------------------------------- |
|
2085 // CSimplePluginXdmUtils::SetTestObserver |
|
2086 // --------------------------------------------------------------------------- |
|
2087 // |
|
2088 void CSimplePluginXdmUtils::SetTestObserver( MSimplePluginTestObs* aObs ) |
|
2089 { |
|
2090 iTestObs = aObs; |
|
2091 } |
|
2092 |
|
2093 // --------------------------------------------------------------------------- |
|
2094 // CSimplePluginXdmUtils::CreateRlsDocumentUri16LC |
|
2095 // --------------------------------------------------------------------------- |
|
2096 // |
|
2097 HBufC16* CSimplePluginXdmUtils::CreateRlsDocumentUri16LC( |
|
2098 const TDesC16& aGroup, |
|
2099 const TDesC16& aPresentityUri, |
|
2100 const TDesC16& aDomain ) |
|
2101 { |
|
2102 |
|
2103 TPtrC uriTemplate( iConnSets.Variation().RlsGroupUriTemplate() ); |
|
2104 |
|
2105 // Calculate URI length |
|
2106 TInt uriSize = uriTemplate.Length() + KMyLenPrefix; |
|
2107 if ( uriTemplate.Find( KSimpleGroupTag ) != KErrNotFound ) |
|
2108 { |
|
2109 TPtrC p8( KSimpleGroupTag ); |
|
2110 uriSize = uriSize - p8.Length() + aGroup.Length(); |
|
2111 } |
|
2112 if ( uriTemplate.Find( KSimpleUserTag ) != KErrNotFound ) |
|
2113 { |
|
2114 TPtrC p8( KSimpleUserTag ); |
|
2115 uriSize = uriSize - p8.Length() + aPresentityUri.Length(); |
|
2116 } |
|
2117 if ( uriTemplate.Find( KSimpleDomainTag ) != KErrNotFound ) |
|
2118 { |
|
2119 TPtrC p8( KSimpleDomainTag ); |
|
2120 uriSize = uriSize - p8.Length() + aDomain.Length(); |
|
2121 } |
|
2122 |
|
2123 // allocate new buffer for URI |
|
2124 // Temporarily the buffer might need more space then the final URI length |
|
2125 // (when tags are longer than the real values replacing them). |
|
2126 if ( uriSize < uriTemplate.Length() + KMyLenPrefix ) |
|
2127 { |
|
2128 uriSize = uriTemplate.Length() + KMyLenPrefix + |
|
2129 aGroup.Length() + aPresentityUri.Length() + aDomain.Length(); |
|
2130 } |
|
2131 HBufC16* buf = HBufC16::NewLC( uriSize ); |
|
2132 TPtr16 pBuf(buf->Des()); |
|
2133 |
|
2134 // Append "sip:" prefix |
|
2135 pBuf.Append( KMySip ); |
|
2136 |
|
2137 // Append template |
|
2138 pBuf.Append( uriTemplate ); |
|
2139 |
|
2140 // Replace tags in URI template with the real values. |
|
2141 ReplaceGroupTag( buf, aGroup ); |
|
2142 ReplaceDomainTag( buf, aDomain ); |
|
2143 ReplaceUserTag( buf, aPresentityUri ); |
|
2144 |
|
2145 return buf; |
|
2146 } |
|
2147 |
|
2148 // --------------------------------------------------------------------------- |
|
2149 // CSimplePluginXdmUtils::DoesUserListExistsL |
|
2150 // --------------------------------------------------------------------------- |
|
2151 // |
|
2152 TBool CSimplePluginXdmUtils::DoesUserListExistsL( const TDesC& aName ) |
|
2153 { |
|
2154 CXdmDocumentNode* buddylist = DoGetBuddyListL(); |
|
2155 CXdmDocumentNode* foundNode = SearchListUnderParentL( buddylist, aName ); |
|
2156 return foundNode ? ETrue : EFalse; |
|
2157 } |
|
2158 |
|
2159 // --------------------------------------------------------------------------- |
|
2160 // CSimplePluginXdmUtils::AuxBuffer |
|
2161 // --------------------------------------------------------------------------- |
|
2162 // |
|
2163 TPtrC CSimplePluginXdmUtils::AuxBuffer( ) |
|
2164 { |
|
2165 return iAuxBuffer ? iAuxBuffer->Des() : TPtrC(); |
|
2166 } |
|
2167 |
|
2168 // --------------------------------------------------------------------------- |
|
2169 // CSimplePluginXdmUtils::RemoveRlsServiceByResourceListL |
|
2170 // --------------------------------------------------------------------------- |
|
2171 // |
|
2172 void CSimplePluginXdmUtils::RemoveRlsServiceByResourceListL( |
|
2173 const TDesC& aGroup, TRequestStatus& aStatus ) |
|
2174 { |
|
2175 |
|
2176 #ifdef _DEBUG |
|
2177 PluginLogger::Log(_L("PluginXdm: RemoveRlsServiceByResourceListL")); |
|
2178 #endif |
|
2179 |
|
2180 TBool ret( EFalse ); |
|
2181 |
|
2182 iOperation = EXdmRlsRemove; |
|
2183 iClientStatus = &aStatus; |
|
2184 |
|
2185 // convert a Group into resource-list value |
|
2186 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
2187 CleanupStack::PushL( xcapUri ); // << xcapUri |
|
2188 |
|
2189 HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aGroup ); |
|
2190 CleanupStack::PushL( listUri ); // << listUri |
|
2191 |
|
2192 // remove service-uri in the rls-services document |
|
2193 ret = DoRemoveRlsServiceByResourceListL( listUri->Des() ); |
|
2194 |
|
2195 CleanupStack::PopAndDestroy( listUri ); |
|
2196 CleanupStack::PopAndDestroy( xcapUri ); |
|
2197 |
|
2198 *iClientStatus = KRequestPending; |
|
2199 |
|
2200 if ( ret ) |
|
2201 { |
|
2202 // Update RLS document when needed. |
|
2203 UpdateRlsL(); |
|
2204 iXdmState = EUpdateRlsServices; |
|
2205 } |
|
2206 else |
|
2207 { |
|
2208 CompleteClientReq( KErrNone ); |
|
2209 } |
|
2210 } |
|
2211 |
|
2212 // --------------------------------------------------------------------------- |
|
2213 // CSimplePluginXdmUtils::DoRemoveRlsServiceByResourceListL |
|
2214 // --------------------------------------------------------------------------- |
|
2215 // |
|
2216 TBool CSimplePluginXdmUtils::DoRemoveRlsServiceByResourceListL( const TDesC& aResourceList ) |
|
2217 { |
|
2218 TBool ret( EFalse ); |
|
2219 |
|
2220 CDesC16Array* myArray = new (ELeave) CDesC16ArraySeg(10); |
|
2221 CleanupStack::PushL( myArray ); |
|
2222 |
|
2223 CDesC16Array* myValues = new (ELeave) CDesC16ArraySeg(10); |
|
2224 CleanupStack::PushL( myValues ); |
|
2225 |
|
2226 iRlsXdm->GetServiceUrisL( *myArray ); |
|
2227 TInt myCount = myArray->MdcaCount(); |
|
2228 |
|
2229 for ( TInt i=0; i < myCount && !ret; i++ ) |
|
2230 { |
|
2231 iRlsXdm->SwitchToServiceURIL( myArray->MdcaPoint( i )); |
|
2232 iRlsXdm->GetElementsL( KPresResourceList, *myValues); |
|
2233 TInt myValuesCount = myValues->MdcaCount(); |
|
2234 for ( TInt j=0; j < myValuesCount; j++ ) |
|
2235 { |
|
2236 if ( !myValues->MdcaPoint( i ).Compare( aResourceList ) ) |
|
2237 { |
|
2238 // delete service with the URI |
|
2239 iRlsXdm->RemoveServiceURIL( myArray->MdcaPoint( i ) ); |
|
2240 ret = ETrue; |
|
2241 break; |
|
2242 } |
|
2243 } |
|
2244 } |
|
2245 |
|
2246 CleanupStack::PopAndDestroy( myValues ); |
|
2247 CleanupStack::PopAndDestroy( myArray ); |
|
2248 |
|
2249 return ret; |
|
2250 } |
|
2251 |
|
2252 // --------------------------------------------------------------------------- |
|
2253 // CSimplePluginXdmUtils::RlsServiceByResourceListL |
|
2254 // --------------------------------------------------------------------------- |
|
2255 // |
|
2256 HBufC* CSimplePluginXdmUtils::RlsServiceByResourceListLC( |
|
2257 const TDesC& aGroup ) |
|
2258 { |
|
2259 |
|
2260 #ifdef _DEBUG |
|
2261 PluginLogger::Log(_L("PluginXdm: :RlsServiceByResourceListLC")); |
|
2262 #endif |
|
2263 |
|
2264 HBufC* myRet = NULL; |
|
2265 |
|
2266 // convert a Group into resource-list value |
|
2267 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
2268 CleanupStack::PushL( xcapUri ); // << xcapUri |
|
2269 |
|
2270 HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aGroup ); |
|
2271 CleanupStack::PushL( listUri ); // << listUri |
|
2272 |
|
2273 // remove service-uri in the rls-services document |
|
2274 myRet = DoGetRlsServiceByResourceListL( listUri->Des() ); |
|
2275 |
|
2276 CleanupStack::PopAndDestroy( listUri ); |
|
2277 CleanupStack::PopAndDestroy( xcapUri ); |
|
2278 |
|
2279 CleanupStack::PushL( myRet ); |
|
2280 |
|
2281 return myRet; |
|
2282 } |
|
2283 |
|
2284 // --------------------------------------------------------------------------- |
|
2285 // CSimplePluginXdmUtils::DoGetRlsServiceByResourceListL |
|
2286 // --------------------------------------------------------------------------- |
|
2287 // |
|
2288 HBufC* CSimplePluginXdmUtils::DoGetRlsServiceByResourceListL( const TDesC& aResourceList ) |
|
2289 { |
|
2290 |
|
2291 HBufC* ret = NULL; |
|
2292 |
|
2293 CDesC16Array* myArray = new (ELeave) CDesC16ArraySeg(10); |
|
2294 CleanupStack::PushL( myArray ); |
|
2295 |
|
2296 CDesC16Array* myValues = new (ELeave) CDesC16ArraySeg(10); |
|
2297 CleanupStack::PushL( myValues ); |
|
2298 |
|
2299 iRlsXdm->GetServiceUrisL( *myArray ); |
|
2300 TInt myCount = myArray->MdcaCount(); |
|
2301 |
|
2302 for ( TInt i=0; i < myCount && !ret; i++ ) |
|
2303 { |
|
2304 iRlsXdm->SwitchToServiceURIL( myArray->MdcaPoint( i )); |
|
2305 iRlsXdm->GetElementsL( KPresResourceList, *myValues); |
|
2306 TInt myValuesCount = myValues->MdcaCount(); |
|
2307 for ( TInt j=0; j < myValuesCount; j++ ) |
|
2308 { |
|
2309 if ( !myValues->MdcaPoint( i ).Compare( aResourceList ) ) |
|
2310 { |
|
2311 // save the URI |
|
2312 ret = myArray->MdcaPoint( i ).AllocL(); |
|
2313 break; |
|
2314 } |
|
2315 } |
|
2316 } |
|
2317 |
|
2318 CleanupStack::PopAndDestroy( myValues ); |
|
2319 CleanupStack::PopAndDestroy( myArray ); |
|
2320 |
|
2321 if ( !ret ) |
|
2322 { |
|
2323 User::Leave( KErrNotFound ); |
|
2324 } |
|
2325 return ret; |
|
2326 } |
|
2327 |
|
2328 // --------------------------------------------------------------------------- |
|
2329 // CSimplePluginXdmUtils::RlsServiceUriNegotiationL |
|
2330 // --------------------------------------------------------------------------- |
|
2331 // |
|
2332 void CSimplePluginXdmUtils::RlsServiceUriNegotiationL() |
|
2333 { |
|
2334 #ifdef _DEBUG |
|
2335 PluginLogger::Log(_L("PluginXdm: :RlsServiceUriNegotiationL")); |
|
2336 #endif |
|
2337 // Handle RLS Service URI negotiation |
|
2338 |
|
2339 HBufC16* buf = CreateRlsDocumentUri16LC( |
|
2340 AuxBuffer(), iConnSets.CurrentSipPresentity(), iConnSets.CurrentDomain() ); |
|
2341 |
|
2342 TRAP_IGNORE( iRlsXdm->RemoveServiceURIL( buf->Des() )); |
|
2343 |
|
2344 TInt errx = iRlsXdm->AddServiceURIL( iRlsXdm->NegotiatedServiceUri() ); |
|
2345 if ( errx && errx != KErrAlreadyExists ) |
|
2346 { |
|
2347 User::Leave( errx ); |
|
2348 } |
|
2349 User::LeaveIfError( iRlsXdm->SwitchToServiceURIL( iRlsXdm->NegotiatedServiceUri() )); |
|
2350 |
|
2351 HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri ); |
|
2352 CleanupStack::PushL( xcapUri ); // << xcapUri |
|
2353 |
|
2354 HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), AuxBuffer() ); |
|
2355 CleanupStack::PushL( listUri ); // << listUri |
|
2356 |
|
2357 TInt err = iRlsXdm->AddElementL( KPresResourceList, listUri->Des(), AuxBuffer() ); |
|
2358 if ( err && err != KErrAlreadyExists ) |
|
2359 { |
|
2360 User::Leave( err ); |
|
2361 } |
|
2362 |
|
2363 CleanupStack::PopAndDestroy( listUri ); // >> listUri |
|
2364 CleanupStack::PopAndDestroy( xcapUri ); // >> xcapUri |
|
2365 CleanupStack::PopAndDestroy( buf ); |
|
2366 |
|
2367 delete iAuxBuffer; |
|
2368 iAuxBuffer = NULL; |
|
2369 iAuxBuffer = iRlsXdm->NegotiatedServiceUri().AllocL(); |
|
2370 |
|
2371 UpdateRlsL(); |
|
2372 iXdmState = EReUpdateRlsServices; |
|
2373 } |
|
2374 |
|
2375 // --------------------------------------------------------------------------- |
|
2376 // CSimplePluginXdmUtils::MakeDefaultRuleL |
|
2377 // --------------------------------------------------------------------------- |
|
2378 // |
|
2379 void CSimplePluginXdmUtils::MakeDefaultRuleL( |
|
2380 TDes& aRuleId, |
|
2381 TPresenceActionXDM& aAction, |
|
2382 TPresenceTransformXDM& aTransform, |
|
2383 TPresCondMisc& aMisc ) |
|
2384 { |
|
2385 |
|
2386 #ifdef _DEBUG |
|
2387 PluginLogger::Log(_L("PluginXdm: :MakeDefaultRuleL")); |
|
2388 #endif |
|
2389 |
|
2390 iPresenceXdm->CreateNewRuleL( aRuleId ); |
|
2391 User::LeaveIfError( aMisc.AddOtherIdentityL(aRuleId) ); |
|
2392 |
|
2393 // use run-time variation for rule action |
|
2394 CSimplePluginVariation::TSimplePluginAuthRule authRule = |
|
2395 iConnSets.Variation().DefaultRuleAction(); |
|
2396 |
|
2397 switch (authRule) |
|
2398 { |
|
2399 case CSimplePluginVariation::ERuleConfirm: |
|
2400 User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresConfirm )); |
|
2401 break; |
|
2402 case CSimplePluginVariation::ERulePoliteBlock: |
|
2403 User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresPoliteBlock )); |
|
2404 break; |
|
2405 case CSimplePluginVariation::ERuleBlock: |
|
2406 User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresBlock )); |
|
2407 break; |
|
2408 default: |
|
2409 User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresAllow )); |
|
2410 }; |
|
2411 User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL( |
|
2412 aRuleId, KPresProvideAllAttributes )); |
|
2413 User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL( |
|
2414 aRuleId, KPresProvidePersons )); |
|
2415 User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL( |
|
2416 aRuleId, KPresProvideDevices )); |
|
2417 User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL( |
|
2418 aRuleId, KPresProvideServices )); |
|
2419 } |
|
2420 |
|
2421 // --------------------------------------------------------------------------- |
|
2422 // CSimplePluginXdmUtils::ReplaceGroupTag |
|
2423 // --------------------------------------------------------------------------- |
|
2424 // |
|
2425 void CSimplePluginXdmUtils::ReplaceGroupTag( HBufC16* aBuf, const TDesC16& aGroup ) |
|
2426 { |
|
2427 // Replace group if found |
|
2428 TPtr pBuf( aBuf->Des() ); |
|
2429 TInt pos = pBuf.Find( KSimpleGroupTag ); |
|
2430 if ( pos != KErrNotFound ) |
|
2431 { |
|
2432 TPtrC p8( KSimpleGroupTag ); |
|
2433 pBuf.Replace( pos, p8.Length(), aGroup ); |
|
2434 } |
|
2435 else |
|
2436 { |
|
2437 // No tag |
|
2438 } |
|
2439 } |
|
2440 |
|
2441 // --------------------------------------------------------------------------- |
|
2442 // CSimplePluginXdmUtils::ReplaceDomainTag |
|
2443 // --------------------------------------------------------------------------- |
|
2444 // |
|
2445 void CSimplePluginXdmUtils::ReplaceDomainTag( HBufC16* aBuf, const TDesC16& aDomain ) |
|
2446 { |
|
2447 // Replace domain if found |
|
2448 TPtr pBuf( aBuf->Des() ); |
|
2449 TInt pos = pBuf.Find( KSimpleDomainTag ); |
|
2450 if ( pos != KErrNotFound ) |
|
2451 { |
|
2452 // remove leading "@" |
|
2453 TPtrC p8( KSimpleDomainTag ); |
|
2454 if ( aDomain[0] == '@') |
|
2455 { |
|
2456 pBuf.Replace( pos, p8.Length(), aDomain.Mid( 1 )); |
|
2457 } |
|
2458 else |
|
2459 { |
|
2460 pBuf.Replace( pos, p8.Length(), aDomain ); |
|
2461 } |
|
2462 } |
|
2463 else |
|
2464 { |
|
2465 // No tag |
|
2466 } |
|
2467 } |
|
2468 |
|
2469 // --------------------------------------------------------------------------- |
|
2470 // CSimplePluginXdmUtils::ReplaceUserTag |
|
2471 // --------------------------------------------------------------------------- |
|
2472 // |
|
2473 void CSimplePluginXdmUtils::ReplaceUserTag( |
|
2474 HBufC16* aBuf, const TDesC16& aPresentityUri ) |
|
2475 { |
|
2476 TPtr pBuf( aBuf->Des() ); |
|
2477 TInt presentityUriLen = aPresentityUri.Length(); |
|
2478 // Replace user if found |
|
2479 TInt pos = pBuf.Find( KSimpleUserTag ); |
|
2480 if ( pos != KErrNotFound ) |
|
2481 { |
|
2482 TPtrC p8( KSimpleUserTag ); |
|
2483 |
|
2484 // Remove leading "sip:" or "tel:" prefix and strip off domain part from aPresentityUri. |
|
2485 TInt domainPos = presentityUriLen; |
|
2486 TInt userIdPos = 0; |
|
2487 |
|
2488 if ( !aPresentityUri.Left( KMyLenPrefix ).CompareF( KMySip ) || |
|
2489 !aPresentityUri.Left( KMyLenPrefix ).CompareF( KMyTel )) |
|
2490 { |
|
2491 userIdPos = KMyLenPrefix; |
|
2492 } |
|
2493 |
|
2494 for ( TInt i = userIdPos; i < presentityUriLen; i++ ) |
|
2495 { |
|
2496 if ( aPresentityUri[i] == '@' ) |
|
2497 { |
|
2498 domainPos = i; |
|
2499 break; |
|
2500 } |
|
2501 } |
|
2502 |
|
2503 TPtrC userId( aPresentityUri.Mid( userIdPos, domainPos - userIdPos )); |
|
2504 pBuf.Replace( pos, p8.Length(), userId ); |
|
2505 } |
|
2506 } |
|
2507 |
|
2508 // --------------------------------------------------------------------------- |
|
2509 // CSimplePluginXdmUtils::CompleteClientReq |
|
2510 // --------------------------------------------------------------------------- |
|
2511 // |
|
2512 void CSimplePluginXdmUtils::CompleteClientReq( TInt aStatus ) |
|
2513 { |
|
2514 iXdmState = EStateIdle; |
|
2515 iOperation = ENoOperation; |
|
2516 TRequestStatus* s = iClientStatus; |
|
2517 User::RequestComplete( s, aStatus ); |
|
2518 } |
|
2519 |
|
2520 |
|
2521 // End of file |
|
2522 |