1 /* |
|
2 * Copyright (c) 2008 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: Class that capsulates single service data members |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "cvimpstengine.h" |
|
21 |
|
22 #include "cvimpstengineservicetablefetcher.h" |
|
23 #include <e32std.h> |
|
24 #include <barsc.h> |
|
25 #include <gulutil.h> |
|
26 #include <coemain.h> |
|
27 #include <e32base.h> |
|
28 |
|
29 #include "tvimpstconsts.h" |
|
30 #include "cvimpstenginevoipsubservice.h" |
|
31 #include "cvimpstengineimsubservice.h" |
|
32 #include "cvimpstenginepresencesubservice.h" |
|
33 #include "cvimpstenginecchhandler.h" |
|
34 //storage |
|
35 #include "cvimpststoragemanagerfactory.h" |
|
36 #include "cvimpstenginesessioncntxtobserver.h" |
|
37 #include "mvimpststorageserviceview.h" |
|
38 #include "mvimpststoragevpbkstorehandler.h" |
|
39 |
|
40 #include "tvimpstenums.h" |
|
41 |
|
42 #include "mvimpstengineextentionfeatures.h" |
|
43 #include "mvimpstengineservicestateeventobserver.h" |
|
44 |
|
45 //extention features |
|
46 #include "cvimpstenginesearchmgrextention.h" |
|
47 #include "cvimpstenginecontactmgmtextention.h" |
|
48 #include "cvimpstblockedlistmanager.h" |
|
49 |
|
50 #include "mvimpststoragecontactlist.h" |
|
51 #include <cvimpstsettingsstore.h> |
|
52 #include "vimpstdebugtrace.h" |
|
53 |
|
54 // Constants |
|
55 _LIT( KListNameAllBuddy ,"buddylist" ); |
|
56 |
|
57 // ================= MEMBER FUNCTIONS ======================= |
|
58 // --------------------------------------------------------- |
|
59 // CVIMPSTEngine::NewL |
|
60 // |
|
61 // --------------------------------------------------------- |
|
62 CVIMPSTEngine* CVIMPSTEngine::NewL( |
|
63 TUint32 aServiceId, |
|
64 CVIMPSTEngineServiceTableFetcher& aTableFetcher ) |
|
65 { |
|
66 TRACE( T_LIT("CVIMPSTEngine::NewL start") ); |
|
67 TRACE( T_LIT("NewL() ServiceId: %d"), aServiceId ); |
|
68 |
|
69 |
|
70 CVIMPSTEngine* self = CVIMPSTEngine::NewLC( aServiceId, |
|
71 aTableFetcher ); |
|
72 CleanupStack::Pop( self ); |
|
73 |
|
74 TRACE( T_LIT("CVIMPSTEngine::NewL end") ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CVIMPSTEngine::NewLC |
|
81 // |
|
82 // --------------------------------------------------------- |
|
83 |
|
84 CVIMPSTEngine* CVIMPSTEngine::NewLC( |
|
85 TUint32 aServiceId, |
|
86 CVIMPSTEngineServiceTableFetcher& aTableFetcher ) |
|
87 { |
|
88 TRACE( T_LIT("CVIMPSTEngine::NewLC start") ); |
|
89 TRACE( T_LIT("NewLC() ServiceId: %d"), aServiceId ); |
|
90 |
|
91 CVIMPSTEngine* self = new (ELeave) CVIMPSTEngine( |
|
92 aServiceId, |
|
93 aTableFetcher ); |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL( aServiceId ); |
|
96 |
|
97 TRACE( T_LIT("CVIMPSTEngine::NewLC end") ); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CVIMPSTEngine::~CVIMPSTEngine |
|
103 // |
|
104 // --------------------------------------------------------- |
|
105 |
|
106 CVIMPSTEngine::~CVIMPSTEngine() |
|
107 { |
|
108 TRACE( T_LIT("CVIMPSTEngine::~CVIMPSTEngine start") ); |
|
109 |
|
110 iObserverArray.Reset(); |
|
111 iObserverArray.Close(); |
|
112 |
|
113 iSubService.ResetAndDestroy(); |
|
114 iSubService.Close(); |
|
115 // Delete this after sub services, those might use it in destructor! |
|
116 delete iSessionCntxtObserver; |
|
117 delete iServiceName; |
|
118 |
|
119 iExtentionFeatures.ResetAndDestroy(); |
|
120 iExtentionFeatures.Close(); |
|
121 |
|
122 delete iCchHandler; |
|
123 iCchHandler = NULL; |
|
124 |
|
125 TRACE( T_LIT("CVIMPSTEngine::~CVIMPSTEngine end") ); |
|
126 } |
|
127 |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CVIMPSTEngine::ConstructL |
|
131 // |
|
132 // --------------------------------------------------------- |
|
133 |
|
134 void CVIMPSTEngine::ConstructL( TUint32 aServiceId ) |
|
135 { |
|
136 TRACE( T_LIT("CVIMPSTEngine::ConstructL start") ); |
|
137 TRACE( T_LIT("ConstructL() - ServiceId: %d"), aServiceId ); |
|
138 |
|
139 iServiceName = HBufC::NewL( KVIMPSTUISPSMaxPropertyLength ); |
|
140 |
|
141 // construct the service state by passing the array of subservices. |
|
142 iCchHandler = CVIMPSTEngineCchHandler::NewL(iServiceId,*this); |
|
143 |
|
144 //construct eventobserver only if there are any adaptations. |
|
145 TInt ximpAdapterUid = iTableFetcher.XimpAdapterUidL(aServiceId); |
|
146 |
|
147 |
|
148 TBool requireXimp = EFalse; |
|
149 TBool presenceSupported = IsSubServiceSupportedInternal(TVIMPSTEnums::EPresence); |
|
150 TBool imSupported = IsSubServiceSupportedInternal(TVIMPSTEnums::EIM); |
|
151 |
|
152 requireXimp |= presenceSupported; |
|
153 requireXimp |= imSupported; |
|
154 |
|
155 //if either of Presence/IM Subservice supported then we need |
|
156 //to bind to XIMP context. |
|
157 if ( KErrNotFound != ximpAdapterUid && requireXimp ) |
|
158 { |
|
159 iSessionCntxtObserver = CVIMPSTEngineSessionCntxtObserver::NewL(aServiceId); |
|
160 } |
|
161 |
|
162 TPtr serviceIdPtr( iServiceName->Des() ); |
|
163 iTableFetcher.GetServiceNameL(aServiceId, serviceIdPtr); |
|
164 |
|
165 |
|
166 // iterate the service array |
|
167 for ( TInt index = TVIMPSTEnums::EVoip; index < TVIMPSTEnums::ELast ; index++ ) |
|
168 { |
|
169 //create the subservice |
|
170 switch(index) |
|
171 { |
|
172 case TVIMPSTEnums::EVoip: |
|
173 { |
|
174 if(IsSubServiceSupportedInternal(TVIMPSTEnums::EVoip)) |
|
175 { |
|
176 CVIMPSTEngineVOIPSubService* item = |
|
177 CVIMPSTEngineVOIPSubService::NewL(aServiceId, *iCchHandler, |
|
178 iTableFetcher, *this); |
|
179 iSubService.Append(item); |
|
180 } |
|
181 break; |
|
182 } |
|
183 case TVIMPSTEnums::EPresence: |
|
184 { |
|
185 if(presenceSupported) |
|
186 { |
|
187 if (iSessionCntxtObserver) |
|
188 { |
|
189 CVIMPSTEnginePresenceSubService* item = CVIMPSTEnginePresenceSubService::NewL( |
|
190 aServiceId,*iCchHandler,iTableFetcher, |
|
191 *iSessionCntxtObserver,*this |
|
192 ); |
|
193 iSubService.Append(item); |
|
194 iSessionCntxtObserver->RegisterObserver(item); |
|
195 } |
|
196 } |
|
197 break; |
|
198 } |
|
199 case TVIMPSTEnums::EIM: |
|
200 { |
|
201 if(imSupported) |
|
202 { |
|
203 CVIMPSTEngineIMSubService* item = |
|
204 CVIMPSTEngineIMSubService::NewL(aServiceId, *iCchHandler, |
|
205 iTableFetcher,*this); |
|
206 iSubService.Append(item); |
|
207 } |
|
208 break; |
|
209 } |
|
210 default: |
|
211 { |
|
212 break; |
|
213 } |
|
214 |
|
215 } |
|
216 } |
|
217 |
|
218 //Create the required extention mgrs |
|
219 CreateExtentionFeaturesL(); |
|
220 iState = ParseGetServiceState(); |
|
221 //if cch is already logged in, and the callback's servicestatuschanged() stopped |
|
222 RetriveContextIfCChEnabledL(); |
|
223 TRACE( T_LIT("CVIMPSTEngine::ConstructL end") ); |
|
224 } |
|
225 |
|
226 |
|
227 // --------------------------------------------------------- |
|
228 // CVIMPSTEngine::CVIMPSTEngine |
|
229 // |
|
230 // --------------------------------------------------------- |
|
231 |
|
232 CVIMPSTEngine::CVIMPSTEngine( TUint32 aServiceId, |
|
233 CVIMPSTEngineServiceTableFetcher& aTableFetcher ) : |
|
234 iServiceId(aServiceId), |
|
235 iTableFetcher(aTableFetcher) |
|
236 { |
|
237 |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------- |
|
241 // CVIMPSTEngine::RetriveContextIfCChEnabledL |
|
242 // |
|
243 // --------------------------------------------------------- |
|
244 void CVIMPSTEngine::RetriveContextIfCChEnabledL() |
|
245 { |
|
246 TRACE( T_LIT("CVIMPSTEngine::RetriveContextIfCChEnabledL start") ); |
|
247 if ( (iSessionCntxtObserver) && |
|
248 (TVIMPSTEnums::ESVCEUpdatingContacts == iState || TVIMPSTEnums::ESVCERegistered == iState ) |
|
249 && ( TVIMPSTEnums::EVIMPSTBindNotDone == iSessionCntxtObserver->ContextBindStatus() ) ) |
|
250 { |
|
251 TInt ximpAdapterUid = iTableFetcher.XimpAdapterUidL(iServiceId); |
|
252 TInt err = iSessionCntxtObserver->ServerBindL(TUid::Uid( ximpAdapterUid )); |
|
253 if(KErrNone != err) |
|
254 { |
|
255 //should never reache here; |
|
256 iCchHandler->DisableService(); |
|
257 User::LeaveIfError(err); |
|
258 } |
|
259 SetExtentionFeaturesSupportedL(); |
|
260 } |
|
261 TRACE( T_LIT("CVIMPSTEngine::RetriveContextIfCChEnabledL end")); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CVIMPSTEngine::LoginL |
|
266 // |
|
267 // --------------------------------------------------------- |
|
268 TInt CVIMPSTEngine::Login() |
|
269 { |
|
270 TRACE( T_LIT("CVIMPSTEngine::ConstructL start") ); |
|
271 TRACE( T_LIT("Login() - ServiceId: %d"), iServiceId ); |
|
272 |
|
273 TInt error = KErrNotFound; |
|
274 if(iCchHandler) |
|
275 { |
|
276 TRACE( T_LIT("Login() - EnableService Called")); |
|
277 error = iCchHandler->EnableService(); |
|
278 } |
|
279 |
|
280 TRACE( T_LIT("Login - error: %d"), error ); |
|
281 TRACE( T_LIT("CVIMPSTEngine::Login")); |
|
282 |
|
283 return error; |
|
284 } |
|
285 |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // CVIMPSTEngine::Logout |
|
289 // |
|
290 // --------------------------------------------------------- |
|
291 void CVIMPSTEngine::LogoutL() |
|
292 { |
|
293 TRACE( T_LIT("CVIMPSTEngine::Logout")); |
|
294 TRACE( T_LIT("Logout() - ServiceId: %d"), iServiceId ); |
|
295 |
|
296 if(iCchHandler) |
|
297 { |
|
298 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
299 if (subService) |
|
300 { |
|
301 //Get Presence SubService |
|
302 MVIMPSTEnginePresenceSubService& presenceSubService = |
|
303 MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
304 if (TVIMPSTEnums::ESVCERegistered == subService->SubServiceState() || |
|
305 TVIMPSTEnums::ESVCEUpdatingContacts == subService->SubServiceState() ) |
|
306 { |
|
307 // Unsubscribe all lists here to get whole list contents when doing a new bind. |
|
308 // Trap here to avoid unbind not being done if list operations should leave |
|
309 TRAP_IGNORE( presenceSubService.UnsubscribeListsL() ); |
|
310 } |
|
311 } |
|
312 //if either of Presence/IM Subservice supported then we need |
|
313 //to unbind to XIMP context. |
|
314 if( iSessionCntxtObserver ) |
|
315 { |
|
316 TRACE( T_LIT("Logout() - ServerUnBindL Called")); |
|
317 iSessionCntxtObserver->ServerUnBindL(ETrue); |
|
318 } |
|
319 TRACE( T_LIT("Logout() - DisableService Called")); |
|
320 iCchHandler->DisableService(); |
|
321 } |
|
322 TRACE( T_LIT("CVIMPSTEngine::Logout")); |
|
323 } |
|
324 |
|
325 |
|
326 // --------------------------------------------------------- |
|
327 // CVIMPSTEngine::ServiceId |
|
328 // |
|
329 // --------------------------------------------------------- |
|
330 TUint32 CVIMPSTEngine::ServiceId() const |
|
331 { |
|
332 TRACE( T_LIT("ServiceId() - ServiceId: %d"), iServiceId ); |
|
333 return iServiceId; |
|
334 } |
|
335 |
|
336 |
|
337 // --------------------------------------------------------- |
|
338 // CVIMPSTEngine::ServiceName |
|
339 // |
|
340 // --------------------------------------------------------- |
|
341 const TDesC& CVIMPSTEngine::ServiceName() const |
|
342 { |
|
343 TPtr serviceNamePtr = iServiceName->Des(); |
|
344 TRACE( T_LIT("ServiceName() - ServiceName: '%S'"), &serviceNamePtr ); |
|
345 return *iServiceName; |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------- |
|
349 // CVIMPSTEngine::ServiceState |
|
350 // |
|
351 // --------------------------------------------------------- |
|
352 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEngine::ServiceState() const |
|
353 { |
|
354 TRACE( T_LIT("ServiceState() - ServiceState: %d"), iState ); |
|
355 return iState; |
|
356 } |
|
357 |
|
358 |
|
359 // --------------------------------------------------------- |
|
360 // CVIMPSTEngine::GetBrandInfo |
|
361 // |
|
362 // --------------------------------------------------------- |
|
363 TInt CVIMPSTEngine::GetBrandInfoL(TLanguage& aBrandLanguage, |
|
364 TInt &aBrandVersion, TDes8& aBrandId) const |
|
365 |
|
366 { |
|
367 TRACE( T_LIT("CVIMPSTEngine::GetBrandInfoL start")); |
|
368 TRACE( T_LIT("GetBrandInfoL() - ServiceId: %d"), iServiceId ); |
|
369 |
|
370 iTableFetcher.GetBrandIdL(iServiceId, aBrandId); |
|
371 aBrandLanguage = iTableFetcher.PropertyBrandLanguageL(iServiceId); |
|
372 aBrandVersion = iTableFetcher.PropertyBrandVersionL(iServiceId); |
|
373 TRACE( T_LIT("CVIMPSTEngine::GetBrandInfoL end")); |
|
374 return KErrNone; |
|
375 } |
|
376 |
|
377 |
|
378 // --------------------------------------------------------- |
|
379 // CVIMPSTEngine::IsSubServiceSupportedL |
|
380 // |
|
381 // --------------------------------------------------------- |
|
382 TBool CVIMPSTEngine::IsSubServiceSupportedL(TVIMPSTEnums::SubServiceType aType) const |
|
383 { |
|
384 |
|
385 TRACE( T_LIT("CVIMPSTEngine::IsSubServiceSupportedL start")); |
|
386 TRACE( T_LIT ("IsSubServiceSupportedL() - ServiceId: %d"), iServiceId); |
|
387 TRACE( T_LIT ("IsSubServiceSupportedL() - SubServiceType: %d"), aType); |
|
388 |
|
389 TBool support = EFalse; |
|
390 |
|
391 MVIMPSTEngineSubService* subService = SubService(aType); |
|
392 if (subService) |
|
393 { |
|
394 support = ETrue; |
|
395 } |
|
396 |
|
397 TRACE( T_LIT("IsSubServiceSupportedL() - support: %d"), support ); |
|
398 TRACE( T_LIT("CVIMPSTEngine::IsSubServiceSupportedL end")); |
|
399 return support; |
|
400 |
|
401 } |
|
402 |
|
403 |
|
404 // --------------------------------------------------------- |
|
405 // CVIMPSTEngine::IsSubServiceEnabled |
|
406 // |
|
407 // --------------------------------------------------------- |
|
408 TBool CVIMPSTEngine::IsSubServiceEnabled(TVIMPSTEnums::SubServiceType aType) const |
|
409 { |
|
410 |
|
411 TRACE( T_LIT("CVIMPSTEngine::IsSubServiceEnabled start")); |
|
412 TRACE( T_LIT("IsSubServiceEnabled() - ServiceId: %d"), iServiceId ); |
|
413 TRACE( T_LIT("IsSubServiceEnabled() - SubServiceType: %d"), aType ); |
|
414 |
|
415 MVIMPSTEngineSubService* subService = SubService(aType); |
|
416 TBool enabled = EFalse; |
|
417 |
|
418 if (subService) |
|
419 { |
|
420 if ( TVIMPSTEnums::ESVCERegistered == subService->SubServiceState() ) |
|
421 { |
|
422 enabled = ETrue; |
|
423 } |
|
424 } |
|
425 TRACE( T_LIT("IsSubServiceEnabled() - enabled: %d"), enabled ); |
|
426 TRACE( T_LIT("CVIMPSTEngine::IsSubServiceEnabled end") ); |
|
427 return enabled; |
|
428 } |
|
429 |
|
430 // --------------------------------------------------------- |
|
431 // CVIMPSTEngine::GetContactStoreIdL |
|
432 // |
|
433 // --------------------------------------------------------- |
|
434 void CVIMPSTEngine::ContactStoreIdL (TDes& aContactStoreId ) const |
|
435 { |
|
436 TRACE( T_LIT("CVIMPSTEngine::ContactStoreIdL start")); |
|
437 TRACE( T_LIT("ContactStoreIdL() - ServiceId: %d"), iServiceId ); |
|
438 iTableFetcher.GetContactStoreIdL(iServiceId, aContactStoreId); |
|
439 TRACE( T_LIT("CVIMPSTEngine::ContactStoreIdL end")); |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // CVIMPSTEngine::RegisterServiceSessionObserver() |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 void CVIMPSTEngine::RegisterServiceSessionObserverL |
|
447 (MVIMPSTEngineServiceStateEventObserver* aObserver) |
|
448 { |
|
449 __ASSERT_ALWAYS(aObserver,User::Leave(KErrArgument)); |
|
450 TRACE( T_LIT("CVIMPSTEngine::RegisterServiceSessionObserverL start")); |
|
451 TInt index = iObserverArray.Find(aObserver); |
|
452 if( index == KErrNotFound ) |
|
453 { |
|
454 iObserverArray.Append( aObserver ); |
|
455 } |
|
456 TRACE( T_LIT("CVIMPSTEngine::RegisterServiceSessionObserverL end")); |
|
457 } |
|
458 |
|
459 // --------------------------------------------------------------------------- |
|
460 // CVIMPSTEngine::UnRegisterServiceSessionObserver() |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 void CVIMPSTEngine::UnRegisterServiceSessionObserver |
|
464 (MVIMPSTEngineServiceStateEventObserver* aObserver) |
|
465 { |
|
466 TRACE( T_LIT("CVIMPSTEngine::UnRegisterServiceSessionObserverL start")); |
|
467 if(aObserver) |
|
468 { |
|
469 TInt index = iObserverArray.Find(aObserver); |
|
470 if( index >=0 ) |
|
471 { |
|
472 iObserverArray.Remove( index ); |
|
473 iObserverArray.Compress(); |
|
474 } |
|
475 } |
|
476 TRACE( T_LIT("CVIMPSTEngine::UnRegisterServiceSessionObserverL end")); |
|
477 } |
|
478 // --------------------------------------------------------- |
|
479 // CVIMPSTEngine::IntializeStorage |
|
480 // |
|
481 // --------------------------------------------------------- |
|
482 void CVIMPSTEngine::IntializeStorageL() |
|
483 { |
|
484 TRACE( T_LIT("CVIMPSTEngine::IntializeStorageL")); |
|
485 TRACE( T_LIT("IntializeStorageL() - ServiceId: %d"), iServiceId ); |
|
486 iContactInterface = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); |
|
487 if(iContactInterface) |
|
488 { |
|
489 iContactInterface->AddObserverL( this ); |
|
490 MVIMPSTSettingsStore* store = CVIMPSTSettingsStore::NewLC(); |
|
491 RBuf lastUserName; |
|
492 lastUserName.CreateL( KPropertyMaxLength ); |
|
493 CleanupClosePushL( lastUserName ); |
|
494 store->GetL( iServiceId, EServiceLastUserName, lastUserName ); |
|
495 if( lastUserName.Length() == 0 ) |
|
496 { |
|
497 HBufC* userId = GetOwnUserIdFromCChOrStorageL(); |
|
498 CleanupStack::PushL( userId ); |
|
499 store->SetL(iServiceId, EServiceLastUserName,*userId); |
|
500 iContactInterface->SetOwnUserIdL(*userId ); |
|
501 CleanupStack::PopAndDestroy(); //userId |
|
502 } |
|
503 else |
|
504 { |
|
505 iContactInterface->SetOwnUserIdL(lastUserName ); |
|
506 } |
|
507 CleanupStack::PopAndDestroy(&lastUserName); //lastUserName |
|
508 CleanupStack::PopAndDestroy(); //store |
|
509 } |
|
510 TRACE( T_LIT("CVIMPSTEngine::IntializeStorageL") ); |
|
511 } |
|
512 // --------------------------------------------------------- |
|
513 // CVIMPSTEngine::UnIntializeStorage |
|
514 // |
|
515 // --------------------------------------------------------- |
|
516 void CVIMPSTEngine::UnIntializeStorage() |
|
517 { |
|
518 TRACE( T_LIT("CVIMPSTEngine::UnIntializeStorage start")); |
|
519 TRACE( T_LIT("UnIntializeStorage() - ServiceId: %d"), iServiceId ); |
|
520 if(iContactInterface) |
|
521 { |
|
522 iContactInterface->RemoveObserver( this ); |
|
523 } |
|
524 TRACE( T_LIT("CVIMPSTEngine::UnIntializeStorage end")); |
|
525 } |
|
526 |
|
527 //----------------------------------------------------------------------------- |
|
528 // CVIMPSTEngine::SetOwnUserIdIfChangedL |
|
529 // ( Other items commented in header ) |
|
530 //----------------------------------------------------------------------------- |
|
531 void CVIMPSTEngine::SetOwnUserIdIfChangedL(const TDesC& aUserId) |
|
532 { |
|
533 TRACE( T_LIT("CVIMPSTEngine::SetOwnUserIdL")); |
|
534 MVIMPSTSettingsStore* store = CVIMPSTSettingsStore::NewLC(); |
|
535 RBuf lastUserName; |
|
536 lastUserName.CreateL( KPropertyMaxLength ); |
|
537 CleanupClosePushL( lastUserName ); |
|
538 store->GetL( iServiceId, EServiceLastUserName, lastUserName ); |
|
539 //first time when cenrep is not set with any value. set current as lastusername |
|
540 if( lastUserName.Compare( aUserId ) != 0 ) |
|
541 { |
|
542 store->SetL(iServiceId, EServiceLastUserName,aUserId); |
|
543 iContactInterface->SetOwnUserIdL(aUserId ); |
|
544 } |
|
545 CleanupStack::PopAndDestroy(&lastUserName); //lastUserName |
|
546 CleanupStack::PopAndDestroy(); //store |
|
547 TRACE( T_LIT("CVIMPSTEngine::SetOwnUserIdL")); |
|
548 } |
|
549 |
|
550 //----------------------------------------------------------------------------- |
|
551 // CVIMPSTEngine::GetOwnUserIdFromCChOrStorageL |
|
552 // ( Other items commented in header ) |
|
553 //----------------------------------------------------------------------------- |
|
554 HBufC* CVIMPSTEngine::GetOwnUserIdFromCChOrStorageL() const |
|
555 { |
|
556 TRACE( T_LIT("CVIMPSTEngine::GetOwnUserIdFromCChL")); |
|
557 TRACE( T_LIT("GetOwnUserIdFromCChL() - ServiceId: %d"), iServiceId ); |
|
558 HBufC* buffer = NULL; |
|
559 if(iCchHandler) |
|
560 { |
|
561 // Set userid |
|
562 buffer = iCchHandler->GetConParametersL(ECchUsername); |
|
563 CleanupStack::PushL( buffer ); |
|
564 } |
|
565 if (!buffer) |
|
566 { |
|
567 buffer = KNullDesC().AllocLC(); |
|
568 } |
|
569 CleanupStack::Pop();//buffer |
|
570 return buffer; |
|
571 } |
|
572 |
|
573 //----------------------------------------------------------------------------- |
|
574 // CVIMPSTEngine::SubService |
|
575 // ( Other items commented in header ) |
|
576 //----------------------------------------------------------------------------- |
|
577 MVIMPSTEngineSubService* CVIMPSTEngine::SubService(TVIMPSTEnums::SubServiceType aType) const |
|
578 { |
|
579 TRACE( T_LIT("CVIMPSTEngine::SubService start")); |
|
580 TRACE( T_LIT("SubService() - ServiceId: %d"), iServiceId ); |
|
581 TRACE( T_LIT("SubService() - SubServiceType: %d"), aType ); |
|
582 |
|
583 TInt subServiceCount = iSubService.Count(); |
|
584 MVIMPSTEngineSubService* subService = NULL; |
|
585 |
|
586 // iterate the service array |
|
587 for ( TInt index = 0; index < subServiceCount ; index++ ) |
|
588 { |
|
589 |
|
590 if (aType == iSubService[index]->Type()) |
|
591 { |
|
592 subService = iSubService[index]; |
|
593 TRACE( T_LIT("SubService() - SubService Found") ); |
|
594 break; |
|
595 } |
|
596 } |
|
597 |
|
598 TRACE( T_LIT("CVIMPSTEngine::SubService end")); |
|
599 return subService; |
|
600 } |
|
601 |
|
602 |
|
603 //----------------------------------------------------------------------------- |
|
604 // CVIMPSTEngine::ExtentionFeatures |
|
605 // ( Other items commented in header ) |
|
606 //----------------------------------------------------------------------------- |
|
607 MVIMPSTEngineExtentionFeatures* CVIMPSTEngine::ExtentionFeatures(TVIMPSTEnums::ExtentionType aType) const |
|
608 { |
|
609 TRACE( T_LIT("CVIMPSTEngine::ExtentionFeatures start")); |
|
610 TRACE( T_LIT("ExtentionFeatures() - ServiceId: %d"), iServiceId ); |
|
611 TRACE( T_LIT("ExtentionFeatures() - ExtentionType: %d"), aType ); |
|
612 |
|
613 TInt fetaureCount = iExtentionFeatures.Count(); |
|
614 MVIMPSTEngineExtentionFeatures* feature = NULL; |
|
615 |
|
616 // iterate the service array |
|
617 for ( TInt index = 0; index < fetaureCount ; index++ ) |
|
618 { |
|
619 |
|
620 if (aType == iExtentionFeatures[index]->Type()) |
|
621 { |
|
622 feature = iExtentionFeatures[index]; |
|
623 TRACE( T_LIT("SubService() - ExtentionFeatures Found") ); |
|
624 break; |
|
625 } |
|
626 } |
|
627 |
|
628 TRACE( T_LIT("CVIMPSTEngine::ExtentionFeatures")); |
|
629 return feature; |
|
630 } |
|
631 |
|
632 |
|
633 |
|
634 //----------------------------------------------------------------------------- |
|
635 // CVIMPSTEngine::AddExtentionFeaturesL |
|
636 // ( Other items commented in header ) |
|
637 //----------------------------------------------------------------------------- |
|
638 void CVIMPSTEngine::AddExtentionFeaturesL(MVIMPSTEngineExtentionFeatures* aFeature) |
|
639 { |
|
640 __ASSERT_ALWAYS(aFeature,User::Leave(KErrArgument)); |
|
641 |
|
642 TRACE( T_LIT("CVIMPSTEngine::AddExtentionFeaturesL")); |
|
643 TRACE( T_LIT("AddExtentionFeaturesL() - ServiceId: %d"), iServiceId ); |
|
644 |
|
645 if (aFeature) |
|
646 { |
|
647 TRACE( T_LIT("AddExtentionFeaturesL() - ExtentionType: %d"), aFeature->Type() ); |
|
648 iExtentionFeatures.Append(aFeature); |
|
649 TRACE( T_LIT("AddExtentionFeaturesL() - Append Done") ); |
|
650 } |
|
651 |
|
652 TRACE( T_LIT("CVIMPSTEngine::AddExtentionFeaturesL")); |
|
653 |
|
654 } |
|
655 |
|
656 |
|
657 //----------------------------------------------------------------------------- |
|
658 // CVIMPSTEngine::RemoveExtentionFeatures |
|
659 // ( Other items commented in header ) |
|
660 //----------------------------------------------------------------------------- |
|
661 void CVIMPSTEngine::RemoveExtentionFeatures(TVIMPSTEnums::ExtentionType aType) |
|
662 { |
|
663 |
|
664 TRACE( T_LIT("CVIMPSTEngine::RemoveExtentionFeatures")); |
|
665 TRACE( T_LIT("RemoveExtentionFeatures() - ServiceId: %d"), iServiceId ); |
|
666 |
|
667 TInt fetaureCount = iExtentionFeatures.Count(); |
|
668 |
|
669 // iterate the service array |
|
670 for ( TInt index = 0; index < fetaureCount ; index++ ) |
|
671 { |
|
672 |
|
673 if (aType == iExtentionFeatures[index]->Type()) |
|
674 { |
|
675 TRACE( T_LIT("RemoveExtentionFeatures() Found - ExtentionType: %d"), aType ); |
|
676 iExtentionFeatures.Remove(index); |
|
677 iExtentionFeatures.Compress(); |
|
678 TRACE( T_LIT("RemoveExtentionFeatures() - Remove Done") ); |
|
679 break; |
|
680 } |
|
681 } |
|
682 |
|
683 TRACE( T_LIT("CVIMPSTEngine::RemoveExtentionFeatures end")); |
|
684 |
|
685 } |
|
686 |
|
687 |
|
688 |
|
689 //----------------------------------------------------------------------------- |
|
690 // CVIMPSTEngine::HandleServceConnectionEventL |
|
691 // ( Other items commented in header ) |
|
692 //----------------------------------------------------------------------------- |
|
693 void CVIMPSTEngine::HandleServceConnectionEventL() |
|
694 { |
|
695 TRACE( T_LIT("CVIMPSTEngine::HandleServceConnectionEventL")); |
|
696 TRACE( T_LIT("HandleServceConnectionEventL() - ServiceId: %d"), iServiceId ); |
|
697 |
|
698 TVIMPSTEnums::TVIMPSTRegistrationState previousState = iState; |
|
699 iState = ParseGetServiceState(); |
|
700 |
|
701 if(TVIMPSTEnums::ESVCENotRegistered == iState) |
|
702 { |
|
703 CVIMPSTEnginePresenceSubService* presSubService = |
|
704 dynamic_cast<CVIMPSTEnginePresenceSubService*> |
|
705 (SubService(TVIMPSTEnums::EPresence)); |
|
706 if(presSubService) |
|
707 { |
|
708 presSubService->ResetBlockedListManagerL(); |
|
709 } |
|
710 } |
|
711 TRACE( T_LIT("HandleServceConnectionEventL() - PreviousState: %d, CurrentState:%d"), previousState, iState ); |
|
712 //Only send observer notifications if there is any change in the Service State |
|
713 //Otherwise not required |
|
714 if (previousState != iState) |
|
715 { |
|
716 //Presence Service needs to Register for the XIMP Events once when |
|
717 //the context gets binded |
|
718 //Get Presence SubService |
|
719 CVIMPSTEnginePresenceSubService* presSubService = |
|
720 dynamic_cast<CVIMPSTEnginePresenceSubService*>(SubService(TVIMPSTEnums::EPresence)); |
|
721 TInt count = iObserverArray.Count(); |
|
722 for (TInt index=0; index<count; index++) |
|
723 { |
|
724 TRACE( T_LIT("HandleServceConnectionEventL()calling HandleServiceEventL") ); |
|
725 iObserverArray[index]->HandleServiceEventL(iState, KErrNone); |
|
726 } |
|
727 TInt ximpAdapterUid = iTableFetcher.XimpAdapterUidL(iServiceId); |
|
728 if ( (iSessionCntxtObserver) && (KErrNotFound != ximpAdapterUid ) ) |
|
729 { |
|
730 |
|
731 if ( ( TVIMPSTEnums::ESVCEUpdatingContacts == iState || |
|
732 TVIMPSTEnums::ESVCERegistered == iState ) && |
|
733 TVIMPSTEnums::EVIMPSTBindNotDone == iSessionCntxtObserver->ContextBindStatus() ) |
|
734 { |
|
735 TInt error = iSessionCntxtObserver->ServerBindL(TUid::Uid( ximpAdapterUid )); |
|
736 if(KErrNone != error) |
|
737 { |
|
738 //should never reache here; |
|
739 iCchHandler->DisableService(); |
|
740 User::LeaveIfError(error); |
|
741 } |
|
742 SetExtentionFeaturesSupportedL(); |
|
743 } |
|
744 else if (TVIMPSTEnums::ESVCENotRegistered == iState ) |
|
745 { |
|
746 MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); |
|
747 if( storage ) |
|
748 { |
|
749 MVIMPSTStorageContact& ownContact = storage->OwnContactL(); |
|
750 TPtrC ownUserId = ownContact.UserId(); |
|
751 if( ownUserId.Length() && presSubService ) |
|
752 { |
|
753 presSubService->UnSubscribePresenceOfSingleContactL( ownUserId ); |
|
754 } |
|
755 MVIMPSTStorageContactList* list = storage->FindContactList(KIMContactListId) ; |
|
756 if ( list ) |
|
757 { |
|
758 TInt count = list->Count(); |
|
759 for(TInt i = 0;i < count; i++) |
|
760 { |
|
761 MVIMPSTStorageContact* contact = &(list->operator[](i)); |
|
762 if(contact) |
|
763 { |
|
764 if(presSubService) |
|
765 { |
|
766 if( contact->UserId().Length() ) |
|
767 { |
|
768 TRAP_IGNORE( presSubService->UnSubscribePresenceOfSingleContactL( contact->UserId() ) ); |
|
769 } |
|
770 if(!(contact->UserId().Length())) // if no XspId |
|
771 { |
|
772 contact->SetOnlineStatus(TVIMPSTEnums::EUnknown); |
|
773 } |
|
774 else if(TVIMPSTEnums::EPending != contact->OnlineStatus()) |
|
775 { |
|
776 contact->SetOnlineStatus(TVIMPSTEnums::EOffline); |
|
777 }// end of if |
|
778 }// end of for |
|
779 } // end of if(contact) |
|
780 }// end of for |
|
781 storage->Sort(KIMContactListId); |
|
782 } |
|
783 } |
|
784 ReSetExtentionFeaturesSupportedL(); |
|
785 } //end of else if |
|
786 }// end of isessioncontextobserver and ximpadapteruid. |
|
787 }// end of if(previousstate != iState) |
|
788 TRACE( T_LIT("CVIMPSTEngine::HandleServceConnectionEventL end") ); |
|
789 } |
|
790 |
|
791 //----------------------------------------------------------------------------- |
|
792 // CVIMPSTEngine::ParseGetServiceState |
|
793 // ( Other items commented in header ) |
|
794 //----------------------------------------------------------------------------- |
|
795 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEngine::ParseGetServiceState() |
|
796 { |
|
797 |
|
798 TInt subServiceCount = iSubService.Count(); |
|
799 TInt serviceState = 0; |
|
800 |
|
801 //Find the cumulative of the ServiceStates of all subservices |
|
802 // iterate the service array |
|
803 for ( TInt index = 0; index < subServiceCount ; index++ ) |
|
804 { |
|
805 serviceState |= iSubService[index]->SubServiceState(); |
|
806 } |
|
807 |
|
808 //ServiceState |
|
809 TVIMPSTEnums::TVIMPSTRegistrationState state = TVIMPSTEnums::ESVCENotRegistered; |
|
810 |
|
811 //The logic below is that, if any one subservice not enabled for us the service is not enabled |
|
812 //So to do this we assign priority for each service state |
|
813 //Connecting gets the High Priority, when copmared to Waiting for Connection, |
|
814 //Disconnecting, Registered, UnRegistered. |
|
815 //By this way the Sevice Tab will be more usable and atleast we can perform operations |
|
816 //related to the the logged in subservice |
|
817 //its upto the connection handlers to do the job properly, whether to provide connectivity to all |
|
818 //sub services or not.. |
|
819 |
|
820 //Start parsing and decide the state of the ServiceTab |
|
821 if ( serviceState & TVIMPSTEnums::ESVCENetworkConnecting ) |
|
822 { |
|
823 //Connecting |
|
824 state = TVIMPSTEnums::ESVCENetworkConnecting; |
|
825 } |
|
826 else if ( serviceState & TVIMPSTEnums::ESVCEWaitingForNetwork ) |
|
827 { |
|
828 //Waiting for Connection |
|
829 state = TVIMPSTEnums::ESVCEWaitingForNetwork; |
|
830 } |
|
831 else if ( serviceState & TVIMPSTEnums::ESVCEUpdatingContacts ) |
|
832 { |
|
833 //Waiting for Connection |
|
834 state = TVIMPSTEnums::ESVCEUpdatingContacts; |
|
835 } |
|
836 else if ( serviceState & TVIMPSTEnums::ESVCENetworkDisConnecting ) |
|
837 { |
|
838 //disconnecting |
|
839 state = TVIMPSTEnums::ESVCENetworkDisConnecting; |
|
840 } |
|
841 else if ( serviceState & TVIMPSTEnums::ESVCERegistered ) |
|
842 { |
|
843 //Enabled |
|
844 state = TVIMPSTEnums::ESVCERegistered; |
|
845 } |
|
846 |
|
847 return state; |
|
848 } |
|
849 |
|
850 //----------------------------------------------------------------------------- |
|
851 // CVIMPSTEngine::HandleContactFetchedL |
|
852 // ( Other items commented in header ) |
|
853 //----------------------------------------------------------------------------- |
|
854 void CVIMPSTEngine::HandleContactFetchedL() |
|
855 { |
|
856 TRACE( T_LIT("CVIMPSTEngine::HandleContactFetchedL")); |
|
857 |
|
858 if (TVIMPSTEnums::ESVCERegistered == iState || |
|
859 TVIMPSTEnums::ESVCEUpdatingContacts == iState ) |
|
860 { |
|
861 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
862 if (subService) |
|
863 { |
|
864 //Get Presence SubService |
|
865 MVIMPSTEnginePresenceSubService& presenceSubService = |
|
866 MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
867 |
|
868 if (TVIMPSTEnums::ESVCERegistered == subService->SubServiceState() || |
|
869 TVIMPSTEnums::ESVCEUpdatingContacts == subService->SubServiceState() ) |
|
870 { |
|
871 presenceSubService.FetchPresenceFromCache(); |
|
872 } |
|
873 presenceSubService.UpdatePresenceStateL(); |
|
874 } |
|
875 // this is added here as for xmpp subscribeforsearchkeys needs to be done only |
|
876 // after the contactts are fetched from the server, |
|
877 // SetExtensionFeaturesSupported is moved to immediately after login. |
|
878 // as for sip case it would never come to this line if there are not contacts in it. |
|
879 MVIMPSTEngineExtentionFeatures* feature = ExtentionFeatures( |
|
880 TVIMPSTEnums::ESearch); |
|
881 if (feature) |
|
882 { |
|
883 MVIMPSTEngineSearchMgrExtention& searchFeature = |
|
884 MVIMPSTEngineSearchMgrExtention::Cast(*feature); |
|
885 //subscribe for search keys, since this is a server feature |
|
886 if(TVIMPSTEnums::ESupportUnKnown == searchFeature.IsSupported()) |
|
887 { |
|
888 searchFeature.SubscribeForSearchKeysL(); |
|
889 } |
|
890 } |
|
891 } |
|
892 TRACE( T_LIT("CVIMPSTEngine::HandleContactFetchedL end")); |
|
893 } |
|
894 |
|
895 // -------------------------------------------------------------------------- |
|
896 // CVIMPSTEngine::HandleStorageChangeL |
|
897 // -------------------------------------------------------------------------- |
|
898 // |
|
899 void CVIMPSTEngine::HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
|
900 MVIMPSTStorageContactList* /*aList*/, |
|
901 MVIMPSTStorageContact* aContact, |
|
902 TInt /*aContactIndex*/ ) |
|
903 { |
|
904 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL begin")); |
|
905 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL iState = %d"), iState); |
|
906 if (TVIMPSTEnums::ESVCERegistered == iState || TVIMPSTEnums::ESVCEUpdatingContacts == iState ) |
|
907 { |
|
908 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL Inside IF")); |
|
909 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL aEventType : %d"), aEventType); |
|
910 switch( aEventType ) |
|
911 { |
|
912 case TVIMPSTEnums::EStorageContactReadComplete: |
|
913 case TVIMPSTEnums::EStorageContactFetchComplete: |
|
914 { |
|
915 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL aEventType EStorageContactFetchComplete")); |
|
916 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
917 if( subService ) |
|
918 { |
|
919 TRACE( T_LIT("HandleStorageChangeL::EStorageContactFetchComplete Inside IF subService")); |
|
920 MVIMPSTEnginePresenceSubService& presenceSubService = MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
921 |
|
922 MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); |
|
923 if( storage ) |
|
924 { |
|
925 MVIMPSTStorageContact& ownContact = storage->OwnContactL(); |
|
926 TPtrC ownUserId = ownContact.UserId(); |
|
927 if( ownUserId.Length() ) |
|
928 { |
|
929 presenceSubService.SubscribePresenceOfSingleContactL( ownUserId ); |
|
930 } |
|
931 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL inside if storage")); |
|
932 MVIMPSTStorageContactList* list = storage->FindContactList(KIMContactListId) ; |
|
933 if ( list ) |
|
934 { |
|
935 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL inside if list")); |
|
936 TInt count = list->Count(); |
|
937 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL inside count = %d"), count); |
|
938 for(TInt i = 0;i < count; i++) |
|
939 { |
|
940 MVIMPSTStorageContact* contact = &(list->operator[](i)); |
|
941 if(contact) |
|
942 { |
|
943 if( contact->UserId().Length() ) |
|
944 { |
|
945 TPtrC userId = contact->UserId(); |
|
946 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL inside userId = %S"), &userId); |
|
947 presenceSubService.SubscribePresenceOfSingleContactL( contact->UserId() ); |
|
948 } |
|
949 } // end of if(contact) |
|
950 }// end of for |
|
951 } |
|
952 } |
|
953 |
|
954 } |
|
955 HandleContactFetchedL(); |
|
956 |
|
957 break; |
|
958 } |
|
959 case TVIMPSTEnums::EStorageEventOwnUserChanged: |
|
960 case TVIMPSTEnums::EStorageEventContactAddition: |
|
961 case TVIMPSTEnums::EStorageContactSynchronizing: |
|
962 case TVIMPSTEnums::EStorageContactReading: |
|
963 case TVIMPSTEnums::EStorageContactFetchExistInStore: |
|
964 { |
|
965 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL aEventType : %d"), aEventType); |
|
966 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
967 if( subService && aContact && |
|
968 aContact->UserId().Length() && |
|
969 TVIMPSTEnums::ESVCERegistered == iState ) |
|
970 { |
|
971 MVIMPSTEnginePresenceSubService& presenceSubService = MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
972 presenceSubService.SubscribePresenceOfSingleContactL( aContact->UserId() ); |
|
973 presenceSubService.FetchPresenceOfSingleContactL(aContact->UserId()); |
|
974 } |
|
975 break; |
|
976 } |
|
977 case TVIMPSTEnums::EStorageEventUserIdPreChange: |
|
978 case TVIMPSTEnums::EStorageEventDeleteFromPbk: |
|
979 { |
|
980 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL EStorageEventUserIdPreChange/EStorageEventDeleteFromPbk")); |
|
981 if( aContact && aContact->UserId().Length() ) |
|
982 { |
|
983 TPtrC userId = aContact->UserId(); |
|
984 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
985 // incase of delete from phonebook delete from server and close conversation if exist |
|
986 // mostly applicable for local store cases |
|
987 if( subService ) |
|
988 { |
|
989 MVIMPSTEnginePresenceSubService& presenceSubService = MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
990 presenceSubService.UnSubscribePresenceOfSingleContactL( userId ) ; |
|
991 } |
|
992 MVIMPSTEngineExtentionFeatures* feature = ExtentionFeatures(TVIMPSTEnums::EContactManagement); |
|
993 if (feature ) |
|
994 { |
|
995 MVIMPSTEngineContactMgmtExtention& contactMgr = MVIMPSTEngineContactMgmtExtention::Cast(*feature); |
|
996 contactMgr.DeleteServerContactL(KNullDesC,userId) ; |
|
997 } |
|
998 MVIMPSTEngineSubService* imService = SubService(TVIMPSTEnums::EIM) ; |
|
999 if(imService) |
|
1000 { |
|
1001 MVIMPSTEngineIMSubService& imSubService = MVIMPSTEngineIMSubService::Cast (*imService); |
|
1002 imSubService.CloseConversationL( userId ); |
|
1003 } |
|
1004 } |
|
1005 break; |
|
1006 } |
|
1007 case TVIMPSTEnums::EStorageEventUserIdPostChange: |
|
1008 { |
|
1009 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL EStorageEventUserIdPostChange")); |
|
1010 if( aContact && aContact->UserId().Length() ) |
|
1011 { |
|
1012 TPtrC userId = aContact->UserId(); |
|
1013 // incase of delete from phonebook delete from server and close conversation if exist |
|
1014 // mostly applicable for local store cases |
|
1015 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
1016 if( subService ) |
|
1017 { |
|
1018 MVIMPSTEnginePresenceSubService& presenceSubService = MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
1019 presenceSubService.SubscribePresenceOfSingleContactL( userId ); |
|
1020 } |
|
1021 MVIMPSTEngineExtentionFeatures* feature = ExtentionFeatures(TVIMPSTEnums::EContactManagement); |
|
1022 if (feature ) |
|
1023 { |
|
1024 MVIMPSTEngineContactMgmtExtention& contactMgr = MVIMPSTEngineContactMgmtExtention::Cast(*feature); |
|
1025 contactMgr.AddServerContactL(KListNameAllBuddy,userId, aContact->Name(), EFalse ); |
|
1026 } |
|
1027 } |
|
1028 break; |
|
1029 } |
|
1030 default: |
|
1031 { |
|
1032 break; |
|
1033 } |
|
1034 } |
|
1035 } |
|
1036 TRACE( T_LIT("CVIMPSTEngine::HandleStorageChangeL end")); |
|
1037 } |
|
1038 |
|
1039 //----------------------------------------------------------------------------- |
|
1040 // CVIMPSTEngine::CreateExtentionFeaturesL |
|
1041 // ( Other items commented in header ) |
|
1042 //----------------------------------------------------------------------------- |
|
1043 void CVIMPSTEngine::CreateExtentionFeaturesL() |
|
1044 { |
|
1045 TRACE( T_LIT("CVIMPSTEngine::CreateExtentionFeaturesL start")); |
|
1046 if (!iSessionCntxtObserver) |
|
1047 { |
|
1048 return; |
|
1049 } |
|
1050 |
|
1051 //create all the features |
|
1052 //first find whether we have the extention already created |
|
1053 //in the extention manager list |
|
1054 |
|
1055 //first find whether we have the extention already created |
|
1056 //in the extention manager list |
|
1057 MVIMPSTEngineExtentionFeatures* contactMgtFeature = ExtentionFeatures( |
|
1058 TVIMPSTEnums::EContactManagement); |
|
1059 |
|
1060 if (!contactMgtFeature) |
|
1061 { |
|
1062 CVIMPSTEngineContactMgmtExtention* contactItem = |
|
1063 CVIMPSTEngineContactMgmtExtention::NewL( |
|
1064 iSessionCntxtObserver->XimpPresenceContextL(), |
|
1065 iSessionCntxtObserver->XimpPresentityGroupsL(), |
|
1066 *iSessionCntxtObserver->GetRequestMapper()); |
|
1067 |
|
1068 AddExtentionFeaturesL(contactItem); |
|
1069 //Unregister is done by session context when the presence context gets |
|
1070 //unbinded |
|
1071 iSessionCntxtObserver->RegisterObserver(contactItem); |
|
1072 } |
|
1073 |
|
1074 |
|
1075 //first find whether we have the extention already created |
|
1076 //in the extention manager list |
|
1077 MVIMPSTEngineExtentionFeatures* searchFeature = ExtentionFeatures( |
|
1078 TVIMPSTEnums::ESearch); |
|
1079 if (!searchFeature) |
|
1080 { |
|
1081 CVIMPSTEngineSearchMgrExtention* searchitem = |
|
1082 CVIMPSTEngineSearchMgrExtention::NewL( |
|
1083 iSessionCntxtObserver->XimpPresenceContextL(), |
|
1084 *iSessionCntxtObserver->GetRequestMapper()); |
|
1085 |
|
1086 AddExtentionFeaturesL(searchitem); |
|
1087 |
|
1088 //Unregister is done by session context when the presence context gets |
|
1089 //unbinded |
|
1090 iSessionCntxtObserver->RegisterObserver(searchitem); |
|
1091 } |
|
1092 TRACE( T_LIT("CVIMPSTEngine::CreateExtentionFeaturesL end")); |
|
1093 } |
|
1094 |
|
1095 //----------------------------------------------------------------------------- |
|
1096 // CVIMPSTEngine::SetExtentionFeaturesSupportedL |
|
1097 // ( Other items commented in header ) |
|
1098 //----------------------------------------------------------------------------- |
|
1099 void CVIMPSTEngine::SetExtentionFeaturesSupportedL() |
|
1100 { |
|
1101 TRACE( T_LIT("CVIMPSTEngine::SetExtentionFeaturesSupportedL start")); |
|
1102 if (!iSessionCntxtObserver) |
|
1103 { |
|
1104 return; |
|
1105 } |
|
1106 |
|
1107 //We would have got the supported features |
|
1108 //iterate and create the required extentionmgr |
|
1109 TInt supportedFeatures = iSessionCntxtObserver->GetSupportedFeatures(); |
|
1110 |
|
1111 if ( !(EVIMPSTFeatureSearch & supportedFeatures) ) |
|
1112 { |
|
1113 //first find whether we have the extention already created |
|
1114 //in the extention manager list |
|
1115 MVIMPSTEngineExtentionFeatures* feature = ExtentionFeatures( |
|
1116 TVIMPSTEnums::ESearch); |
|
1117 if (feature) |
|
1118 { |
|
1119 MVIMPSTEngineSearchMgrExtention& searchFeature = |
|
1120 MVIMPSTEngineSearchMgrExtention::Cast(*feature); |
|
1121 searchFeature.SetSupported(TVIMPSTEnums::ENotSupported); |
|
1122 //subscribe for search keys is done once the contacts are fetched from the server. |
|
1123 //check HandleContactFetchCOmpletedL(). |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 if (( EVIMPSTFeatureAddContact & supportedFeatures ) || |
|
1128 ( EVIMPSTFeatureDeleteContact & supportedFeatures )) |
|
1129 { |
|
1130 //first find whether we have the extention already created |
|
1131 //in the extention manager list |
|
1132 MVIMPSTEngineExtentionFeatures* feature = ExtentionFeatures( |
|
1133 TVIMPSTEnums::EContactManagement); |
|
1134 if (feature) |
|
1135 { |
|
1136 MVIMPSTEngineContactMgmtExtention& contactMgmtFeature = |
|
1137 CVIMPSTEngineContactMgmtExtention::Cast(*feature); |
|
1138 contactMgmtFeature.SetSupported(TVIMPSTEnums::ESupported); |
|
1139 } |
|
1140 |
|
1141 } |
|
1142 |
|
1143 if ( EVIMPSTFeatureAvatar & supportedFeatures ) |
|
1144 { |
|
1145 //first find whether we have the extention already created |
|
1146 //in the extention manager list |
|
1147 MVIMPSTEngineSubService* subService = SubService( |
|
1148 TVIMPSTEnums::EPresence); |
|
1149 if (subService) |
|
1150 { |
|
1151 MVIMPSTEnginePresenceSubService& avatarFeature = |
|
1152 CVIMPSTEnginePresenceSubService::Cast(*subService); |
|
1153 avatarFeature.SetAvatarSupported(ETrue); |
|
1154 } |
|
1155 } |
|
1156 TRACE( T_LIT("CVIMPSTEngine::SetExtentionFeaturesSupportedL end")); |
|
1157 } |
|
1158 |
|
1159 |
|
1160 //----------------------------------------------------------------------------- |
|
1161 // CVIMPSTEngine::ReSetExtentionFeaturesSupportedL |
|
1162 // ( Other items commented in header ) |
|
1163 //----------------------------------------------------------------------------- |
|
1164 void CVIMPSTEngine::ReSetExtentionFeaturesSupportedL() |
|
1165 { |
|
1166 //first find whether we have the extention already created |
|
1167 //in the extention manager list |
|
1168 MVIMPSTEngineExtentionFeatures* feature = ExtentionFeatures( |
|
1169 TVIMPSTEnums::ESearch); |
|
1170 if (feature) |
|
1171 { |
|
1172 MVIMPSTEngineSearchMgrExtention& searchFeature = |
|
1173 MVIMPSTEngineSearchMgrExtention::Cast(*feature); |
|
1174 searchFeature.SetSupported(TVIMPSTEnums::ESupportUnKnown); |
|
1175 } |
|
1176 |
|
1177 //first find whether we have the extention already created |
|
1178 //in the extention manager list |
|
1179 MVIMPSTEngineExtentionFeatures* feature1 = ExtentionFeatures( |
|
1180 TVIMPSTEnums::EContactManagement); |
|
1181 if (feature1) |
|
1182 { |
|
1183 MVIMPSTEngineContactMgmtExtention& contactMgmtFeature = |
|
1184 CVIMPSTEngineContactMgmtExtention::Cast(*feature1); |
|
1185 contactMgmtFeature.SetSupported(TVIMPSTEnums::ESupportUnKnown); |
|
1186 } |
|
1187 |
|
1188 //first find whether we have the extention already created |
|
1189 //in the extention manager list |
|
1190 MVIMPSTEngineSubService* subService = SubService( |
|
1191 TVIMPSTEnums::EPresence ); |
|
1192 if (subService) |
|
1193 { |
|
1194 MVIMPSTEnginePresenceSubService& avatarFeature = |
|
1195 CVIMPSTEnginePresenceSubService::Cast(*subService); |
|
1196 avatarFeature.SetAvatarSupported(EFalse); |
|
1197 } |
|
1198 |
|
1199 } |
|
1200 |
|
1201 |
|
1202 // --------------------------------------------------------- |
|
1203 // CVIMPSTEngine::DefaultDomainNameL |
|
1204 // |
|
1205 // --------------------------------------------------------- |
|
1206 void CVIMPSTEngine::DefaultDomainNameL( TDes& aDefaultDomainName ) const |
|
1207 { |
|
1208 TRACE( T_LIT("CVIMPSTEngine::DefaultDomainName start")); |
|
1209 TRACE( T_LIT("DefaultDomainNameL() - ServiceId: %d"), iServiceId ); |
|
1210 iTableFetcher.GetDefaultDomainNameL(iServiceId, aDefaultDomainName); |
|
1211 TRACE( T_LIT("CVIMPSTEngine::DefaultDomainNameL end")); |
|
1212 } |
|
1213 |
|
1214 |
|
1215 // --------------------------------------------------------- |
|
1216 // CVIMPSTEngine::IsSubServiceSupportedInternal |
|
1217 // |
|
1218 // --------------------------------------------------------- |
|
1219 TBool CVIMPSTEngine::IsSubServiceSupportedInternal(TVIMPSTEnums::SubServiceType aType) const |
|
1220 { |
|
1221 |
|
1222 TRACE( T_LIT("CVIMPSTEngine::IsSubServiceSupportedL")); |
|
1223 TRACE( T_LIT("IsSubServiceSupportedL() - ServiceId: %d"), iServiceId ); |
|
1224 TRACE( T_LIT("IsSubServiceSupportedL() - SubServiceType: %d"), aType ); |
|
1225 |
|
1226 TInt err = KErrNotFound; |
|
1227 TBool support = EFalse; |
|
1228 TCCHSubserviceState aCCHState(ECCHUninitialized); |
|
1229 |
|
1230 switch(aType) |
|
1231 { |
|
1232 case TVIMPSTEnums::EVoip: |
|
1233 { |
|
1234 err = iCchHandler->GetServiceState(iServiceId, ECCHVoIPSub, aCCHState); |
|
1235 break; |
|
1236 } |
|
1237 case TVIMPSTEnums::EPresence: |
|
1238 { |
|
1239 err = iCchHandler->GetServiceState(iServiceId, ECCHPresenceSub, aCCHState); |
|
1240 break; |
|
1241 } |
|
1242 case TVIMPSTEnums::EIM: |
|
1243 { |
|
1244 err = iCchHandler->GetServiceState(iServiceId, ECCHIMSub, aCCHState); |
|
1245 break; |
|
1246 } |
|
1247 default: |
|
1248 { |
|
1249 break; |
|
1250 } |
|
1251 |
|
1252 } |
|
1253 |
|
1254 if (KErrNone == err) |
|
1255 { |
|
1256 support = ETrue; |
|
1257 } |
|
1258 |
|
1259 TRACE( T_LIT("IsSubServiceSupportedL() - support: %d"), support ); |
|
1260 TRACE( T_LIT("CVIMPSTEngine::IsSubServiceSupportedL end")); |
|
1261 return support; |
|
1262 } |
|
1263 |
|
1264 |
|
1265 // --------------------------------------------------------- |
|
1266 // CVIMPSTEngine::ChangeConnectionL |
|
1267 // |
|
1268 // --------------------------------------------------------- |
|
1269 TInt CVIMPSTEngine::ChangeConnectionL() |
|
1270 { |
|
1271 TRACE( T_LIT("CVIMPSTEngine::ChangeConnectionL")); |
|
1272 TRACE( T_LIT("ChangeConnectionL() - ServiceId: %d"), iServiceId ); |
|
1273 |
|
1274 TInt error = KErrNotFound; |
|
1275 if(iCchHandler) |
|
1276 { |
|
1277 TRACE( T_LIT("ChangeConnectionL() Called") ); |
|
1278 error = iCchHandler->ChangeConnectionL(); |
|
1279 } |
|
1280 |
|
1281 TRACE( T_LIT("ChangeConnectionL - error: %d"), error ); |
|
1282 TRACE( T_LIT("CVIMPSTEngine::ChangeConnectionL end") ); |
|
1283 |
|
1284 return error; |
|
1285 } |
|
1286 |
|
1287 // --------------------------------------------------------- |
|
1288 // CVIMPSTEngine::IsBlockSupportedL |
|
1289 // |
|
1290 // --------------------------------------------------------- |
|
1291 |
|
1292 TBool CVIMPSTEngine::IsBlockSupportedL() |
|
1293 { |
|
1294 TBool isBlockSupported = EFalse; |
|
1295 //We would have got the supported features |
|
1296 if(iSessionCntxtObserver && (TVIMPSTEnums::ESVCERegistered == ParseGetServiceState())) |
|
1297 { |
|
1298 TInt supportedFeatures = iSessionCntxtObserver->GetSupportedFeatures(); |
|
1299 if ( (EVIMPSTFeatureBlock & supportedFeatures) && (EVIMPSTFeatureUnBlock & supportedFeatures) ) |
|
1300 { |
|
1301 isBlockSupported = ETrue; |
|
1302 } |
|
1303 } |
|
1304 return isBlockSupported; |
|
1305 } |
|
1306 |
|
1307 // --------------------------------------------------------- |
|
1308 // CVIMPSTEngine::IsPasswordAvailable |
|
1309 // returns True if password is present in the settings else returns false |
|
1310 // --------------------------------------------------------- |
|
1311 TBool CVIMPSTEngine::IsPasswordAvailableL() |
|
1312 { |
|
1313 TRACE( T_LIT("CVIMPSTEngine::IsPasswordAvailable start - End")); |
|
1314 return(iCchHandler->IsPasswordAvailable(ECchPasswordSet)); |
|
1315 } |
|
1316 |
|
1317 // --------------------------------------------------------- |
|
1318 // CVIMPSTEngine::DeleteDataBase |
|
1319 // --------------------------------------------------------- |
|
1320 void CVIMPSTEngine::DeleteDataBaseL() |
|
1321 { |
|
1322 MVIMPSTStorageServiceView* storage = |
|
1323 CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId); |
|
1324 if( storage ) |
|
1325 { |
|
1326 //delete cdb file. |
|
1327 storage->DeleteDatabaseL(); |
|
1328 } |
|
1329 } |
|
1330 |
|
1331 // --------------------------------------------------------------------------- |
|
1332 // CVIMPSTEnginePresenceSubService::GetPreseceSubService |
|
1333 // --------------------------------------------------------------------------- |
|
1334 // |
|
1335 MVIMPSTEnginePresenceSubService* CVIMPSTEngine::GetPreseceSubService() |
|
1336 { |
|
1337 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
1338 if (subService) |
|
1339 { |
|
1340 //Get Presence SubService |
|
1341 MVIMPSTEnginePresenceSubService& presenceSubService = |
|
1342 MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
1343 return &presenceSubService ; |
|
1344 } |
|
1345 return NULL; |
|
1346 } |
|
1347 |
|
1348 // --------------------------------------------------------------------------- |
|
1349 // CVIMPSTEngine::FetchBlockedList |
|
1350 // --------------------------------------------------------------------------- |
|
1351 // |
|
1352 void CVIMPSTEngine::FetchBlockedListL() |
|
1353 { |
|
1354 MVIMPSTEnginePresenceSubService* subService = GetPreseceSubService(); |
|
1355 if( subService ) |
|
1356 { |
|
1357 //fetch the blocked list from server |
|
1358 subService->FetchBlockedListFromServerL(iBlockListObs); |
|
1359 } |
|
1360 } |
|
1361 |
|
1362 // --------------------------------------------------------------------------- |
|
1363 // CVIMPSTEngine::RegisterBlockedListObserver |
|
1364 // --------------------------------------------------------------------------- |
|
1365 // |
|
1366 void CVIMPSTEngine::RegisterBlockedListObserver( |
|
1367 MVIMPSTEngineBlockedListFetchEventObserver* aOb) |
|
1368 { |
|
1369 iBlockListObs = aOb; |
|
1370 } |
|
1371 |
|
1372 // --------------------------------------------------------------------------- |
|
1373 // CVIMPSTEngine::HandleChangeConnectionEventL |
|
1374 // --------------------------------------------------------------------------- |
|
1375 // |
|
1376 void CVIMPSTEngine::HandleChangeConnectionEventL() |
|
1377 { |
|
1378 MVIMPSTEngineSubService* subService = SubService(TVIMPSTEnums::EPresence); |
|
1379 if (subService) |
|
1380 { |
|
1381 //Get Presence SubService |
|
1382 MVIMPSTEnginePresenceSubService& presenceSubService = |
|
1383 MVIMPSTEnginePresenceSubService::Cast(*subService); |
|
1384 if (TVIMPSTEnums::ESVCERegistered == subService->SubServiceState() || |
|
1385 TVIMPSTEnums::ESVCEUpdatingContacts == subService->SubServiceState() ) |
|
1386 { |
|
1387 // Unsubscribe all lists here to get whole list contents when doing a new bind. |
|
1388 // Trap here to avoid unbind not being done if list operations should leave |
|
1389 TRAP_IGNORE( presenceSubService.UnsubscribeListsL() ); |
|
1390 } |
|
1391 } |
|
1392 |
|
1393 if( iSessionCntxtObserver ) |
|
1394 { |
|
1395 iSessionCntxtObserver->ServerUnBindL(ETrue); |
|
1396 } |
|
1397 |
|
1398 } |
|
1399 // End of File |
|