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: IETF SIMPLE Protocol implementation for XIMP Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32svr.h> |
|
20 #include <utf.h> |
|
21 #include <ximpdatasubscriptionstate.h> |
|
22 #include <protocolpresencewatchingdatahost.h> |
|
23 #include <ximpobjectfactory.h> |
|
24 #include <presenceinfo.h> |
|
25 #include <ximpprotocolconnectionhost.h> |
|
26 #include <protocolpresencedatahost.h> |
|
27 #include <presenceobjectfactory.h> |
|
28 #include <ximpstatus.h> |
|
29 #include <ximpidentity.h> |
|
30 #include <simplefactory.h> |
|
31 #include <msimplewatcher.h> |
|
32 #include <msimpledocument.h> |
|
33 #include <msimpleconnection.h> |
|
34 #include <simpleerrors.h> |
|
35 #include <avabilitytext.h> |
|
36 |
|
37 #include "presencepluginentitywatcher.h" |
|
38 #include "presenceplugindata.h" |
|
39 #include "presencepluginwatcher.h" |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CPresencePluginEntityWatcher::CPresencePluginEntityWatcher() |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CPresencePluginEntityWatcher::CPresencePluginEntityWatcher( |
|
48 MPresencePluginConnectionObs& aObs, |
|
49 MSimpleConnection& aConn, |
|
50 CPresencePluginWatcher& aWatcher ) |
|
51 :iConnObs(aObs), iConnection(aConn), |
|
52 iPluginWatcher(aWatcher), iOperation( EPluginIdle ) |
|
53 { |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CPresencePluginEntityWatcher::ConstructL() |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void CPresencePluginEntityWatcher::ConstructL( |
|
61 CPresencePluginData* aPresenceData ) |
|
62 { |
|
63 DP_SDA("CPresencePluginEntityWatcher::ConstructL - begin"); |
|
64 iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this ); |
|
65 iPresenceData = aPresenceData; |
|
66 DP_SDA("CPresencePluginEntityWatcher::ConstructL - end"); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CPresencePluginEntityWatcher::NewL() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CPresencePluginEntityWatcher* CPresencePluginEntityWatcher::NewL( |
|
74 MPresencePluginConnectionObs& aObs, |
|
75 MSimpleConnection& aConn, |
|
76 CPresencePluginWatcher& aWatcher, |
|
77 CPresencePluginData* aPresenceData ) |
|
78 { |
|
79 DP_SDA("CPresencePluginEntityWatcher::NewL"); |
|
80 CPresencePluginEntityWatcher* self = |
|
81 new( ELeave ) CPresencePluginEntityWatcher( aObs, aConn, aWatcher ); |
|
82 CleanupStack::PushL( self ); |
|
83 self->ConstructL( aPresenceData ); |
|
84 CleanupStack::Pop( self ); |
|
85 return self; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CPresencePluginEntityWatcher::~CPresencePluginEntityWatcher() |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 CPresencePluginEntityWatcher::~CPresencePluginEntityWatcher() |
|
93 { |
|
94 DP_SDA("CPresencePluginEntityWatcher::~CPresencePluginEntityWatcher"); |
|
95 if ( iWatcher ) |
|
96 { |
|
97 iWatcher->Close(); |
|
98 } |
|
99 delete iEntityId; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CPresencePluginEntityWatcher::StartSubscribeL() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CPresencePluginEntityWatcher::StartSubscribeL( |
|
107 const TDesC8& aPresentityId ) |
|
108 { |
|
109 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL"); |
|
110 delete iEntityId; |
|
111 iEntityId = NULL; |
|
112 DP_SDA(" StartSubscribeL - entity id deleted"); |
|
113 |
|
114 TRAPD( error, iSimpleId = iWatcher->SubscribeL( |
|
115 aPresentityId, NULL, ETrue, EFalse );); |
|
116 DP_SDA2("StartSubscribeL subscribe error %d",error); |
|
117 |
|
118 if( KErrNone != error ) |
|
119 { |
|
120 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL ERROR"); |
|
121 if( KErrInUse == error ) |
|
122 { |
|
123 DP_SDA(" iWatcher is in use try to close and restart"); |
|
124 iWatcher->Close(); |
|
125 iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this ); |
|
126 DP_SDA("StartSubscribeL Second try after creating iWatcher again"); |
|
127 error = KErrNone; |
|
128 TRAP( error, iSimpleId = iWatcher->GetPresenceL( |
|
129 aPresentityId, NULL, EFalse );); |
|
130 DP_SDA2("iWatcher->GetPresenceL error2 = %d",error ); |
|
131 } |
|
132 } |
|
133 |
|
134 // Save entity id after successful call |
|
135 DP_SDA("StartSubscribeL - allocate entity id"); |
|
136 iEntityId = aPresentityId.AllocL(); |
|
137 DP_SDA("StartSubscribeL - new entity id stored"); |
|
138 |
|
139 iOperation = EPluginStart; |
|
140 |
|
141 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL End"); |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CPresencePluginEntityWatcher::StartSubscribeL() |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CPresencePluginEntityWatcher::StartSubscribeL( |
|
149 const TDesC8& aPresentityId, TRequestStatus& aClientRequst ) |
|
150 { |
|
151 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL 2"); |
|
152 delete iEntityId; |
|
153 iEntityId = NULL; |
|
154 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL - entity id deleted"); |
|
155 |
|
156 iClientStatus = &aClientRequst; |
|
157 *iClientStatus = KRequestPending; // wait for watcher complete |
|
158 iOperation = EPluginStartNotifyClient; |
|
159 |
|
160 TRAPD( error, iSimpleId = iWatcher->SubscribeL( |
|
161 aPresentityId, NULL, ETrue, EFalse );); |
|
162 DP_SDA2("StartSubscribeL subscribe error %d",error); |
|
163 |
|
164 if( KErrInUse == error ) |
|
165 { |
|
166 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL ERROR"); |
|
167 DP_SDA("StartSubscribeL iWatcher is in use try to close and restart"); |
|
168 iWatcher->Close(); |
|
169 iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this ); |
|
170 DP_SDA("StartSubscribeL Second try after creating iWatcher again"); |
|
171 error = KErrNone; |
|
172 TRAP( error, iSimpleId = iWatcher->GetPresenceL( |
|
173 aPresentityId, NULL, EFalse );); |
|
174 DP_SDA2("iWatcher->GetPresenceL error2 = %d",error ); |
|
175 } |
|
176 User::LeaveIfError( error ); |
|
177 |
|
178 // Save entity id after successful call |
|
179 DP_SDA("StartSubscribeL - allocate entity id"); |
|
180 iEntityId = aPresentityId.AllocL(); |
|
181 DP_SDA("StartSubscribeL - new entity id stored"); |
|
182 |
|
183 DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL End"); |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CPresencePluginEntityWatcher::StopSubscribeL() |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CPresencePluginEntityWatcher::StopSubscribeL( |
|
191 TRequestStatus& aClientRequst ) |
|
192 { |
|
193 DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL 2 (list)"); |
|
194 iClientStatus = &aClientRequst; |
|
195 *iClientStatus = KRequestPending; // wait for watcher complete |
|
196 |
|
197 iSimpleId = iWatcher->UnsubscribeL(); |
|
198 iOperation = EPluginStop; |
|
199 DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL 2 end"); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CPresencePluginEntityWatcher::StopSubscribeL() |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 void CPresencePluginEntityWatcher::StopSubscribeL( ) |
|
207 { |
|
208 DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL"); |
|
209 iSimpleId = iWatcher->UnsubscribeL(); |
|
210 iOperation = EPluginStop; |
|
211 DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL end"); |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // CPresencePluginEntityWatcher::WatcherReqCompleteL |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CPresencePluginEntityWatcher::WatcherReqCompleteL( |
|
219 TInt /*aOpId*/, TInt aStatus ) |
|
220 { |
|
221 DP_SDA("CPresencePluginEntityWatcher::WatcherReqCompleteL"); |
|
222 DP_SDA2("WatcherReqCompleteL status %d",aStatus ); |
|
223 TPluginEntityWatcherOperation orig = iOperation; |
|
224 DP_SDA2("WatcherReqCompleteL orig %d",orig ); |
|
225 iOperation = EPluginIdle; |
|
226 |
|
227 if( !aStatus ) |
|
228 { |
|
229 iPluginWatcher.AcceptL( this ); |
|
230 } |
|
231 |
|
232 if ( EPluginStartNotifyClient == orig ) |
|
233 { |
|
234 orig = EPluginStart; |
|
235 DP_SDA(" WatcherReqCompleteL complete client"); |
|
236 CompleteClientReq( aStatus ); |
|
237 } |
|
238 else if ( iClientStatus ) |
|
239 { |
|
240 DP_SDA(" WatcherReqCompleteL complete client 2"); |
|
241 CompleteClientReq( aStatus ); |
|
242 } |
|
243 |
|
244 MSimpleWatcher::TSimpleSipSubscriptionState subscribeStatus = |
|
245 iWatcher->SipSubscriptionState(); |
|
246 DP_SDA2("WatcherReqCompleteL subscribe status %d",subscribeStatus ); |
|
247 |
|
248 if ( aStatus && ( orig == EPluginStop || orig == EPluginStart && |
|
249 MSimpleWatcher::ESimpleStateTerminated != subscribeStatus ) ) |
|
250 { |
|
251 DP_SDA("CPresencePluginEntityWatcher::WatcherReqCompleteL if"); |
|
252 // Delete this entity as useless |
|
253 DP_SDA("WatcherReqCompleteL DELETE WATCHER"); |
|
254 iPluginWatcher.DeleteWatcher( iEntityId->Des() ); |
|
255 //Do not call anything, |
|
256 //since the method call above deletes this instance. |
|
257 } |
|
258 else if( !aStatus && ( MSimpleWatcher::ESimpleStateActive == |
|
259 subscribeStatus && |
|
260 orig == EPluginStop ) ) |
|
261 { |
|
262 DP_SDA(" WatcherReqCompleteL state STOP"); |
|
263 // Delete this entity as useless |
|
264 DP_SDA("WatcherReqCompleteL DELETE WATCHER 2"); |
|
265 iPluginWatcher.DeleteWatcher( iEntityId->Des() ); |
|
266 } |
|
267 else if ( MSimpleWatcher::ESimpleStatePending == subscribeStatus ) |
|
268 { |
|
269 SetPendingToXIMPL(); |
|
270 } |
|
271 DP_SDA("CPresencePluginEntityWatcher::WatcherReqCompleteL end"); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CPresencePluginEntityWatcher::SetPendingToXIMPL |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void CPresencePluginEntityWatcher::SetPendingToXIMPL() |
|
279 { |
|
280 DP_SDA("CPresencePluginEntityWatcher::SetPendingToXIMPL"); |
|
281 //check what is grand request list subscribe state |
|
282 if( iConnObs.GrandListState() ) |
|
283 { |
|
284 DP_SDA("CPresencePluginEntityWatcher::SetPendingToXIMPL True"); |
|
285 MProtocolPresenceWatchingDataHost& watcherHost = |
|
286 iConnObs.ProtocolPresenceHost().WatchingDataHost(); |
|
287 MPresenceInfo* prInfo = |
|
288 iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC(); |
|
289 |
|
290 //Call set to pending |
|
291 iPresenceData->NotifyToPendingToXIMPL( |
|
292 iConnObs.PresenceObjectFactoryOwn(), |
|
293 *prInfo ); |
|
294 |
|
295 MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC(); |
|
296 HBufC* uniBuffer = |
|
297 CnvUtfConverter::ConvertToUnicodeFromUtf8L( iEntityId->Des() ); |
|
298 CleanupStack::PushL( uniBuffer ); |
|
299 |
|
300 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *uniBuffer ); |
|
301 identity2->SetIdentityL( *withoutPrefix ); |
|
302 |
|
303 //Call presence cache writer too |
|
304 TBuf<20> buf; |
|
305 buf.Copy( KPendingRequestExtensionValue ); |
|
306 |
|
307 iPresenceData->WriteStatusToCacheL( *withoutPrefix, |
|
308 MPresenceBuddyInfo2::ENotAvailable, |
|
309 buf, |
|
310 KNullDesC() ); |
|
311 |
|
312 // XIMP Host API callback |
|
313 watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo ); |
|
314 |
|
315 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
316 CleanupStack::PopAndDestroy( uniBuffer ); |
|
317 CleanupStack::Pop(); // >> identity2 |
|
318 CleanupStack::Pop(); // >> prInfo |
|
319 } |
|
320 DP_SDA("CPresencePluginEntityWatcher::SipSubscriptionState end"); |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // CPresencePluginEntityWatcher::SetActiveToXIMPL |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 void CPresencePluginEntityWatcher::SetActiveToXIMPL( const TDesC& aIdentity ) |
|
328 { |
|
329 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, identity"); |
|
330 //check what is grand request list subscribe state |
|
331 if( iConnObs.GrandListState() ) |
|
332 { |
|
333 DP_SDA("CPresencePluginEntityWatcher::SetPendingToXIMPL True"); |
|
334 MProtocolPresenceWatchingDataHost& watcherHost = |
|
335 iConnObs.ProtocolPresenceHost().WatchingDataHost(); |
|
336 MPresenceInfo* prInfo = |
|
337 iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC(); |
|
338 |
|
339 //Call set to pending |
|
340 DP_SDA(" SetPendingToXIMPL, notify active"); |
|
341 iPresenceData->NotifyToActiveToXIMPL( |
|
342 iConnObs.PresenceObjectFactoryOwn(), |
|
343 *prInfo ); |
|
344 |
|
345 DP_SDA(" SetActiveToXIMPL, create new identity"); |
|
346 MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC(); |
|
347 |
|
348 DP_SDA(" SetActiveToXIMPL, strip prefix"); |
|
349 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( aIdentity ); |
|
350 identity2->SetIdentityL( *withoutPrefix ); |
|
351 |
|
352 DP_SDA(" SetActiveToXIMPL, write to cache"); |
|
353 //Call presence cache writer too |
|
354 iPresenceData->WriteStatusToCacheL( *withoutPrefix, |
|
355 MPresenceBuddyInfo2::ENotAvailable, |
|
356 KDefaultAvailableStatus(), |
|
357 KNullDesC() ); |
|
358 |
|
359 DP_SDA(" SetActiveToXIMPL, ximp api callback"); |
|
360 // XIMP Host API callback |
|
361 watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo ); |
|
362 |
|
363 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, cleanup"); |
|
364 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
365 CleanupStack::Pop(); // >> identity2 |
|
366 CleanupStack::Pop(); // >> prInfo |
|
367 } |
|
368 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL end"); |
|
369 } |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // CPresencePluginEntityWatcher::SetTerminatedToXIMPL |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 void CPresencePluginEntityWatcher::SetTerminatedToXIMPL( |
|
376 const TDesC& aIdentity ) |
|
377 { |
|
378 DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL"); |
|
379 DP_SDA2("CPresencePluginEntityWatcher::SetTerminatedToXIMPL, uri: %S", |
|
380 &aIdentity ); |
|
381 //check what is grand request list subscribe state |
|
382 if( iConnObs.GrandListState() ) |
|
383 { |
|
384 DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL True"); |
|
385 MProtocolPresenceWatchingDataHost& watcherHost = |
|
386 iConnObs.ProtocolPresenceHost().WatchingDataHost(); |
|
387 MPresenceInfo* prInfo = |
|
388 iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC(); |
|
389 |
|
390 //Call set to pending |
|
391 iPresenceData->NotifyTerminatedToXIMPL( |
|
392 iConnObs.PresenceObjectFactoryOwn(), |
|
393 *prInfo ); |
|
394 |
|
395 MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC(); |
|
396 |
|
397 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( aIdentity ); |
|
398 identity2->SetIdentityL( *withoutPrefix ); |
|
399 |
|
400 // XIMP Host API callback |
|
401 watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo ); |
|
402 |
|
403 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
404 CleanupStack::Pop(); // >> identity2 |
|
405 CleanupStack::Pop( ); // >> prInfo |
|
406 } |
|
407 DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL end"); |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------------------------- |
|
411 // CPresencePluginEntityWatcher::SetActiveToXIMPL |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 void CPresencePluginEntityWatcher::SetActiveToXIMPL( |
|
415 MSimpleDocument& aDocument ) |
|
416 { |
|
417 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, aDocument"); |
|
418 // No need to check the expiration here since WatcherTerminatedL |
|
419 // is called then too. |
|
420 MProtocolPresenceWatchingDataHost& watcherHost = |
|
421 iConnObs.ProtocolPresenceHost().WatchingDataHost(); |
|
422 MPresenceInfo* prInfo = |
|
423 iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC(); |
|
424 |
|
425 DP_SDA(" SetActiveToXIMPL, call NotifyToPrInfoL"); |
|
426 |
|
427 iPresenceData->NotifyToPrInfoL( |
|
428 iConnObs.ObjectFactory(), |
|
429 iConnObs.PresenceObjectFactoryOwn(), |
|
430 aDocument, *prInfo ); |
|
431 DP_SDA(" SetActiveToXIMPL, NotifyToPrInfoL ok"); |
|
432 |
|
433 // Get variables from presence info object for cache entry |
|
434 MPresenceBuddyInfo2::TAvailabilityValues availability = |
|
435 MPresenceBuddyInfo2::ENotAvailable; |
|
436 |
|
437 HBufC* extendedAvailability = HBufC::NewLC( KBufSize255 ); |
|
438 TPtr extendedAvailabilityPtr( extendedAvailability->Des() ); |
|
439 |
|
440 HBufC* statusMessage = HBufC::NewLC( KBufSize255 ); |
|
441 TPtr statusMessagePtr( statusMessage->Des() ); |
|
442 |
|
443 DP_SDA(" SetActiveToXIMPL, NotifyToPrInfoL ok, get cache entries"); |
|
444 iPresenceData->CacheEntriesFromPrInfo( *prInfo, |
|
445 availability, extendedAvailabilityPtr, statusMessagePtr ); |
|
446 |
|
447 DP_SDA(" SetActiveToXIMPL, create identity"); |
|
448 MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC(); |
|
449 HBufC* uniBuffer = |
|
450 CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
451 *aDocument.EntityURI() ); |
|
452 CleanupStack::PushL( uniBuffer ); |
|
453 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, identity ok"); |
|
454 |
|
455 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, strip prefix"); |
|
456 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *uniBuffer ); |
|
457 identity2->SetIdentityL( *withoutPrefix ); |
|
458 |
|
459 //Call presence cache writer too |
|
460 iPresenceData->WriteStatusToCacheL( *withoutPrefix, availability, |
|
461 extendedAvailabilityPtr, statusMessagePtr ); |
|
462 |
|
463 // XIMP Host API callback |
|
464 watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo ); |
|
465 |
|
466 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
467 CleanupStack::PopAndDestroy( uniBuffer ); |
|
468 CleanupStack::Pop(); // >> identity2 |
|
469 |
|
470 CleanupStack::PopAndDestroy( statusMessage ); |
|
471 CleanupStack::PopAndDestroy( extendedAvailability ); |
|
472 |
|
473 CleanupStack::Pop(); // >> prInfo |
|
474 DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL end"); |
|
475 } |
|
476 |
|
477 // --------------------------------------------------------------------------- |
|
478 // CPresencePluginEntityWatcher::SetTerminatedToXIMPL |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 void CPresencePluginEntityWatcher::SetTerminatedToXIMPL( ) |
|
482 { |
|
483 DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL"); |
|
484 DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL True"); |
|
485 |
|
486 MProtocolPresenceWatchingDataHost& watcherHost = |
|
487 iConnObs.ProtocolPresenceHost().WatchingDataHost(); |
|
488 MPresenceInfo* prInfo = |
|
489 iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC(); |
|
490 |
|
491 //Call set to pending |
|
492 iPresenceData->NotifyTerminatedToXIMPL( |
|
493 iConnObs.PresenceObjectFactoryOwn(), |
|
494 *prInfo ); |
|
495 |
|
496 MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC(); |
|
497 HBufC* uniBuffer = |
|
498 CnvUtfConverter::ConvertToUnicodeFromUtf8L( iEntityId->Des() ); |
|
499 |
|
500 CleanupStack::PushL( uniBuffer ); |
|
501 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *uniBuffer ); |
|
502 identity2->SetIdentityL( *withoutPrefix ); |
|
503 |
|
504 //Call presence cache writer too |
|
505 iPresenceData->WriteStatusToCacheL( *withoutPrefix, |
|
506 MPresenceBuddyInfo2::ENotAvailable, |
|
507 KInvisibleState(), |
|
508 KNullDesC() ); |
|
509 |
|
510 // XIMP Host API callback |
|
511 watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo ); |
|
512 |
|
513 DP_SDA2("SetTerminatedToXIMPL2: ident %S", &identity2->Identity() ); |
|
514 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
515 CleanupStack::PopAndDestroy( uniBuffer ); |
|
516 CleanupStack::Pop(); // >> identity21 |
|
517 CleanupStack::Pop(); // >> prInfo |
|
518 |
|
519 DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL end"); |
|
520 } |
|
521 |
|
522 // --------------------------------------------------------------------------- |
|
523 // CPresencePluginEntityWatcher::WatcherNotificationL() |
|
524 // --------------------------------------------------------------------------- |
|
525 // |
|
526 void CPresencePluginEntityWatcher::WatcherNotificationL( |
|
527 MSimpleDocument& aDocument ) |
|
528 { |
|
529 DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL"); |
|
530 |
|
531 MSimpleWatcher::TSimpleSipSubscriptionState subscribeStatus = |
|
532 iWatcher->SipSubscriptionState(); |
|
533 DP_SDA2("WatcherNotificationL subscribe status %d",subscribeStatus ); |
|
534 |
|
535 //If subscribeStatus = pending |
|
536 if( MSimpleWatcher::ESimpleStatePending == subscribeStatus ) |
|
537 { |
|
538 // Pending |
|
539 DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL PENDING"); |
|
540 SetPendingToXIMPL(); |
|
541 } |
|
542 else if( MSimpleWatcher::ESimpleStateTerminated == subscribeStatus ) |
|
543 { |
|
544 DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL TERMINATED"); |
|
545 SetTerminatedToXIMPL( ); |
|
546 } |
|
547 else |
|
548 { |
|
549 //Active |
|
550 DP_SDA("WatcherNotificationL normal Case"); |
|
551 SetActiveToXIMPL( aDocument ); |
|
552 } |
|
553 DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL end"); |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------------------------- |
|
557 // CPresencePluginEntityWatcher::WatcherListNotificationL() |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 void CPresencePluginEntityWatcher::WatcherListNotificationL( |
|
561 MSimplePresenceList& aList ) |
|
562 { |
|
563 DP_SDA("CPresencePluginEntityWatcher::WatcherListNotificationL"); |
|
564 // call all the necessary callbacks, for new data + teminated ones. |
|
565 |
|
566 MProtocolPresenceWatchingDataHost& watcherHost = |
|
567 iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost(); |
|
568 |
|
569 RPointerArray<MPresenceInfo> entities; |
|
570 RPointerArray<MXIMPIdentity> terminated; |
|
571 RPointerArray<MXIMPIdentity> actives; |
|
572 |
|
573 TRAPD( err, iPresenceData->NotifyListToPrInfoL( |
|
574 iConnObs.ObjectFactory(),iConnObs.PresenceObjectFactoryOwn(), |
|
575 aList, entities, actives, terminated )); |
|
576 if ( err ) |
|
577 { |
|
578 entities.ResetAndDestroy(); |
|
579 terminated.ResetAndDestroy(); |
|
580 actives.ResetAndDestroy(); |
|
581 entities.Close(); |
|
582 terminated.Close(); |
|
583 actives.Close(); |
|
584 return; |
|
585 } |
|
586 |
|
587 // Start to collect data for HandleSubscribedPresentityPresenceL |
|
588 TInt counter = entities.Count(); |
|
589 for ( TInt i = counter-1 ; i>=0; i-- ) |
|
590 { |
|
591 HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( |
|
592 actives[i]->Identity() ); |
|
593 actives[i]->SetIdentityL( *withoutPrefix ); |
|
594 |
|
595 watcherHost.HandleSubscribedPresentityPresenceL( |
|
596 actives[i], entities[i] ); |
|
597 // Owenership is transferred |
|
598 actives.Remove(i); |
|
599 entities.Remove(i); |
|
600 CleanupStack::PopAndDestroy( withoutPrefix ); |
|
601 } |
|
602 |
|
603 entities.ResetAndDestroy(); |
|
604 terminated.ResetAndDestroy(); |
|
605 actives.ResetAndDestroy(); |
|
606 |
|
607 entities.Close(); |
|
608 terminated.Close(); |
|
609 actives.Close(); |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------------------------- |
|
613 // CPresencePluginEntityWatcher::WatcherTerminatedL() |
|
614 // --------------------------------------------------------------------------- |
|
615 // |
|
616 void CPresencePluginEntityWatcher::WatcherTerminatedL( |
|
617 TInt /*aOpId*/, TInt aReason ) |
|
618 { |
|
619 DP_SDA2("CPresencePluginEntityWatcher::WatcherTerminatedL -reason: %d", aReason ); |
|
620 |
|
621 MProtocolPresenceWatchingDataHost& watcherHost = |
|
622 iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost(); |
|
623 |
|
624 MXIMPDataSubscriptionState *state = |
|
625 iConnObs.ObjectFactory().NewDataSubscriptionStateLC(); |
|
626 MXIMPStatus* status = iConnObs.ObjectFactory().NewStatusLC(); |
|
627 state->SetSubscriptionStateL( |
|
628 MXIMPDataSubscriptionState::ESubscriptionInactive ); |
|
629 status->SetResultCode( aReason ); |
|
630 MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); |
|
631 |
|
632 HBufC16* buf16 = HBufC16::NewLC( PresentityId().Length()); |
|
633 buf16->Des().Copy( PresentityId() ); |
|
634 identity->SetIdentityL( buf16->Des() ); |
|
635 |
|
636 //Visualize closed state OpenSer |
|
637 SetTerminatedToXIMPL( buf16->Des() ); |
|
638 |
|
639 CleanupStack::PopAndDestroy( buf16 ); |
|
640 watcherHost.SetPresentityPresenceDataSubscriptionStateL( |
|
641 identity, state, status ); |
|
642 DP_SDA("CPresencePluginEntityWatcher::WatcherTerminatedL pop"); |
|
643 CleanupStack::Pop( 3 ); |
|
644 |
|
645 iPluginWatcher.DeleteWatcher( iEntityId->Des() ); |
|
646 |
|
647 DP_SDA("CPresencePluginEntityWatcher::WatcherTerminatedL end"); |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // CPresencePluginWatcher::CompleteClientReq() |
|
652 // --------------------------------------------------------------------------- |
|
653 // |
|
654 void CPresencePluginEntityWatcher::CompleteClientReq( TInt aStatus ) |
|
655 { |
|
656 DP_SDA("CPresencePluginEntityWatcher::CompleteClientReq"); |
|
657 iOperation = EPluginIdle; |
|
658 TRequestStatus* s = iClientStatus; |
|
659 User::RequestComplete( s, aStatus ); |
|
660 iClientStatus = NULL; |
|
661 DP_SDA("CPresencePluginEntityWatcher::CompleteClientReq out"); |
|
662 } |
|
663 |
|
664 // --------------------------------------------------------------------------- |
|
665 // CPresencePluginEntityWatcher::PresentityId |
|
666 // --------------------------------------------------------------------------- |
|
667 // |
|
668 TPtrC8 CPresencePluginEntityWatcher::PresentityId( ) |
|
669 { |
|
670 DP_SDA("CPresencePluginEntityWatcher::PresentityId"); |
|
671 return iEntityId ? iEntityId->Des() : TPtrC8(); |
|
672 } |
|
673 |
|
674 // --------------------------------------------------------------------------- |
|
675 // CPresencePluginEntityWatcher::XIMPRequestId |
|
676 // --------------------------------------------------------------------------- |
|
677 // |
|
678 TXIMPRequestId CPresencePluginEntityWatcher::XIMPRequestId( ) |
|
679 { |
|
680 return iXIMPId; |
|
681 } |
|
682 |
|
683 // End of file |
|