1 /* |
|
2 * Copyright (c) 2007-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: engine class |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "cimcvengine.h" |
|
20 |
|
21 #include "cimcvenginechatcontainer.h" |
|
22 #include "cimcvenginemessagehandler.h" |
|
23 #include "cimcvenginemessagecreator.h" |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> |
|
26 #include <e32property.h> |
|
27 //ximp includes |
|
28 #include <ximpclient.h> |
|
29 #include <ximpcontext.h> |
|
30 #include <ximpobjectfactory.h> |
|
31 #include <ximpidentity.h> |
|
32 #include <ximpstatus.h> |
|
33 #include <ximpcontextstateevent.h> |
|
34 #include <ximprequestcompleteevent.h> |
|
35 #include <ximpcontextstate.h> |
|
36 #include <ximpobjectfactory.h> |
|
37 #include <ximpidentity.h> |
|
38 #include <ximpstatus.h> |
|
39 |
|
40 // local includes |
|
41 #include "cimcvenginecontextobserver.h" |
|
42 #include "cimcvenginechatcontainer.h" |
|
43 #include "imcvlogger.h" |
|
44 #include "imcvuiliterals.h" |
|
45 //settings |
|
46 #include <spsettings.h> |
|
47 #include <spentry.h> |
|
48 #include <spproperty.h> |
|
49 |
|
50 #include "cimcvengineopenchats.h" |
|
51 #include "cimcvenginecchhandler.h" |
|
52 #include "conversations.h" |
|
53 |
|
54 #include <imconnectionproviderconsts.h> |
|
55 //branding related header files |
|
56 #include <mbsaccess.h> |
|
57 #include <mbselement.h> |
|
58 #include <cbsfactory.h> |
|
59 #include <utf.h> |
|
60 #include <gulicon.h> |
|
61 |
|
62 #define KMAX_SMILEY_COUNT 20 |
|
63 |
|
64 // ================= MEMBER FUNCTIONS ======================= |
|
65 |
|
66 // Two-phased constructor. |
|
67 CIMCVEngine* CIMCVEngine::NewL(TInt aServiceId, MIMCVEngineMessageCreator& aMessageCreater, |
|
68 CBSFactory& aBrandingFactory ) |
|
69 { |
|
70 IM_CV_LOGS(TXT("CIMCVAppView::CIMCVEngine::NewL() start") ); |
|
71 CIMCVEngine* self = new ( ELeave ) CIMCVEngine(aServiceId,aBrandingFactory); |
|
72 |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(aMessageCreater ); |
|
75 CleanupStack::Pop( self ); |
|
76 IM_CV_LOGS(TXT("CIMCVAppView::CIMCVEngine::NewL() end") ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CIMCVEngine::~CIMCVEngine() |
|
83 // Note the destruction order of objects. |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 CIMCVEngine::~CIMCVEngine() |
|
87 { |
|
88 IM_CV_LOGS(TXT("CIMCVEngine destructor START") ); |
|
89 if( iWait.IsStarted() ) |
|
90 { |
|
91 iWait.AsyncStop(); |
|
92 } |
|
93 Cancel(); |
|
94 delete iCCHHandler; |
|
95 iAcceptedEventTypes.Reset(); |
|
96 iAcceptedEventTypes.Close(); |
|
97 |
|
98 delete iOwnUserId; |
|
99 delete iServiceName; |
|
100 delete iBrandId; |
|
101 |
|
102 if(iPresenceContext) |
|
103 { |
|
104 iPresenceContext->UnregisterObserver( *iContextEventObserver ); |
|
105 delete iPresenceContext; |
|
106 iPresenceContext = NULL; |
|
107 } |
|
108 if(iClient) |
|
109 { |
|
110 delete iClient; |
|
111 iClient = NULL; |
|
112 } |
|
113 if(iContextEventObserver) |
|
114 { |
|
115 iContextEventObserver->UnRegisterObserver(iMessageHandler); |
|
116 delete iContextEventObserver; |
|
117 iContextEventObserver = NULL; |
|
118 } |
|
119 if(iMessageHandler) |
|
120 { |
|
121 delete iMessageHandler; |
|
122 iMessageHandler = NULL; |
|
123 } |
|
124 delete iChatInterface; |
|
125 |
|
126 if( iBrandingAccess ) |
|
127 { |
|
128 iBrandingAccess->Close(); |
|
129 iBrandingAccess = NULL; |
|
130 } |
|
131 IM_CV_LOGS(TXT("CIMCVEngine destructor END") ); |
|
132 |
|
133 #if 0 |
|
134 if( iSmileyArrayOwned ) |
|
135 { |
|
136 IM_CV_LOGS(TXT("CIMCVEngine::deleting icon STRING array owned") ); |
|
137 iSmileyArray.ResetAndDestroy(); |
|
138 } |
|
139 IM_CV_LOGS(TXT("CIMCVEngine::RESETTING icon STRING array ") ); |
|
140 iSmileyArray.Reset(); |
|
141 |
|
142 if( iSmileyDlgIconArrayOwned ) |
|
143 { |
|
144 IM_CV_LOGS(TXT("CIMCVEngine::deleting icon array owned") ); |
|
145 iSmileyDlgIconArray.ResetAndDestroy(); |
|
146 } |
|
147 IM_CV_LOGS(TXT("CIMCVEngine::deleting icon array ") ); |
|
148 iSmileyDlgIconArray.Reset(); |
|
149 #endif |
|
150 IM_CV_LOGS(TXT("CIMCVAppViewContainer::SendMessageL() start") ); |
|
151 |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CIMCVEngine::CIMCVEngine() |
|
156 // C++ default constructor can NOT contain any code, that |
|
157 // might leave. |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 CIMCVEngine::CIMCVEngine(TInt aServiceId,CBSFactory& aBrandingFactory) : |
|
161 CActive( CActive::EPriorityStandard ), |
|
162 iServiceId( aServiceId ), |
|
163 iBrandingFactory( aBrandingFactory ), |
|
164 iSmileyArrayOwned( ETrue ), |
|
165 iSmileyDlgIconArrayOwned( ETrue ) |
|
166 { |
|
167 iOwnUserId = NULL; |
|
168 CActiveScheduler::Add( this ); |
|
169 } |
|
170 // --------------------------------------------------------- |
|
171 // CIMCVEngine::ConstructL() |
|
172 // Symbian OS default constructor can leave. |
|
173 // --------------------------------------------------------- |
|
174 // |
|
175 void CIMCVEngine::ConstructL(MIMCVEngineMessageCreator& aMessageCreater) |
|
176 { |
|
177 IM_CV_LOGS(TXT("CIMCVAppView::CIMCVEngine::ConstructL() start") ); |
|
178 iClient = MXIMPClient::NewClientL(); |
|
179 //Create new sink to receive ximp context events |
|
180 iContextEventObserver = CIMCVEngineContextObserver::NewL(); |
|
181 |
|
182 iChatInterface = CIMCVEngineChatContainer::NewL( iServiceId ); |
|
183 //Read the logged in status from CCH True/False |
|
184 TBool isCchEnebled = EFalse; |
|
185 iCCHHandler = CIMCVEngineCchHandler::NewL(iServiceId, *this); |
|
186 isCchEnebled = iCCHHandler->IsServiceLoggedIn(); |
|
187 |
|
188 // Read User Id from CCH |
|
189 iOwnUserId = HBufC::NewL(KMAXUSERIDLENGTH); |
|
190 TPtr owndataPtr = iOwnUserId->Des(); |
|
191 GetUserIdL(owndataPtr ) ; |
|
192 |
|
193 //Read Servicename from CCH |
|
194 iServiceName = HBufC::NewL(KMAXUSERIDLENGTH); |
|
195 TPtr srvNamePtr( iServiceName->Des() ); |
|
196 GetServiceNameL( iServiceId, srvNamePtr ); |
|
197 |
|
198 //Read the service state from CCH |
|
199 TCCHSubserviceState serviceState = ECCHUninitialized; |
|
200 TInt error = iCCHHandler->GetServiceState( |
|
201 serviceState ); |
|
202 |
|
203 if ( ECCHEnabled == serviceState || isCchEnebled ) |
|
204 { |
|
205 // register this to prsence context |
|
206 LoginL(); |
|
207 } |
|
208 // Read the BrandId from SPsettings |
|
209 iBrandId = HBufC8::NewL( KVIMPSTUISPSMaxPropertyLength ); |
|
210 TPtr8 brandidPtr(iBrandId->Des()); |
|
211 GetBrandIdL( iServiceId, brandidPtr ); |
|
212 |
|
213 //Read BrandLanguage id from SPsettings |
|
214 iLanguageId = PropertyBrandLanguageL(iServiceId); |
|
215 |
|
216 ConstructBrandL(); |
|
217 |
|
218 if ( ECCHEnabled == serviceState || isCchEnebled ) |
|
219 { |
|
220 iMessageHandler = CIMCVEngineMessageHandler::NewL( *iChatInterface, |
|
221 aMessageCreater, |
|
222 iPresenceContext, |
|
223 iServiceId, |
|
224 owndataPtr ); |
|
225 } |
|
226 else |
|
227 { |
|
228 iMessageHandler = CIMCVEngineMessageHandler::NewL( *iChatInterface, |
|
229 aMessageCreater, |
|
230 NULL, |
|
231 iServiceId, |
|
232 owndataPtr ); |
|
233 |
|
234 } |
|
235 |
|
236 iContextEventObserver->RegisterObserver(iMessageHandler); |
|
237 IM_CV_LOGS(TXT("CIMCVAppView::CIMCVEngine::ConstructL() end") ); |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------- |
|
241 // CIMCVEngine::ConstructBrandL() |
|
242 // --------------------------------------------------------- |
|
243 // |
|
244 void CIMCVEngine::ConstructBrandL() |
|
245 { |
|
246 if(iBrandingAccess) |
|
247 { |
|
248 iBrandingAccess->Close(); |
|
249 iBrandingAccess = NULL; |
|
250 } |
|
251 iBrandingAccess = iBrandingFactory.CreateAccessL( GetBrandId(), (TLanguage)GetLanguageId() ); |
|
252 if(iBrandingAccess) |
|
253 { |
|
254 TInt totalCount = iBrandingAccess->GetIntL(KSmileycount); |
|
255 |
|
256 // Restricting the maximum number of smileys to KMAX_SMILEY_COUNT. |
|
257 if( totalCount > KMAX_SMILEY_COUNT ) |
|
258 totalCount = KMAX_SMILEY_COUNT; |
|
259 HBufC* allSmileyString = iBrandingAccess->GetTextL(KSmileytext); |
|
260 CleanupStack::PushL(allSmileyString); |
|
261 allSmileyString->Des().Delete(0, 1); |
|
262 allSmileyString->Des().Delete(((allSmileyString->Length())-1), 2); |
|
263 ParseAllSmileyStringL(totalCount, *allSmileyString); |
|
264 CleanupStack::PopAndDestroy(allSmileyString); |
|
265 |
|
266 TInt iconCount = iSmileyArray.Count(); |
|
267 CGulIcon* icon = NULL; |
|
268 CFbsBitmap* bitmap = NULL; |
|
269 CFbsBitmap* mask = NULL; |
|
270 HBufC* iconString = NULL; |
|
271 TInt err = KErrNotFound; |
|
272 for( TInt index = 0; index< iconCount; index++ ) |
|
273 { |
|
274 iconString = iSmileyArray[index]; |
|
275 TPtrC iconStringPtr = iconString->Des(); |
|
276 TBuf8<16> aUtf8; // |
|
277 CnvUtfConverter::ConvertFromUnicodeToUtf8(aUtf8, iconStringPtr); |
|
278 iBrandingAccess->GetBitmapL(aUtf8, bitmap, mask ); |
|
279 CleanupStack::PushL( bitmap ); |
|
280 CleanupStack::PushL( mask ); |
|
281 icon = CGulIcon::NewL( bitmap, mask ); |
|
282 CleanupStack::Pop( 2 ); // bitmap ,mask |
|
283 |
|
284 err = iSmileyDlgIconArray.Append( icon ); |
|
285 |
|
286 if( err < 0) |
|
287 { |
|
288 delete icon; |
|
289 icon = NULL; |
|
290 } |
|
291 } |
|
292 } |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------- |
|
296 // CIMCVEngine::GetSmileStringArray() |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 EXPORT_C RPointerArray<HBufC> CIMCVEngine::GetSmileStringArray() |
|
300 { |
|
301 iSmileyArrayOwned = EFalse; |
|
302 return iSmileyArray;// ownership transfered |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------- |
|
306 // CIMCVEngine::ParseAllSmileyStringL() |
|
307 // --------------------------------------------------------- |
|
308 // |
|
309 EXPORT_C RPointerArray<CGulIcon> CIMCVEngine::GetSmileyIconArray( ) |
|
310 { |
|
311 iSmileyDlgIconArrayOwned = EFalse; |
|
312 return iSmileyDlgIconArray; // ownership transfered |
|
313 } |
|
314 // --------------------------------------------------------- |
|
315 // CIMCVEngine::ParseAllSmileyStringL() |
|
316 // --------------------------------------------------------- |
|
317 // |
|
318 void CIMCVEngine::ParseAllSmileyStringL(TInt aTotalCount , const TDesC& aAllSmileyString) |
|
319 { |
|
320 TInt location = KErrNotFound; |
|
321 HBufC* string = aAllSmileyString.AllocLC(); |
|
322 TPtr mainBufferPtr = string->Des(); |
|
323 //make sure everything is fresh |
|
324 iSmileyArray.ResetAndDestroy(); |
|
325 for(TInt i=0; i<aTotalCount; i++) |
|
326 { |
|
327 location = mainBufferPtr.Locate(' '); |
|
328 if(location != KErrNotFound ) |
|
329 { |
|
330 TPtrC smileStringPtr = mainBufferPtr.Left(location); |
|
331 HBufC* smileString = smileStringPtr.AllocL(); |
|
332 iSmileyArray.Append(smileString); |
|
333 mainBufferPtr.Delete(0,location+1); |
|
334 } |
|
335 if( i == (aTotalCount -1 )) |
|
336 { |
|
337 //for last string |
|
338 HBufC* smileString = mainBufferPtr.AllocL(); |
|
339 iSmileyArray.Append(smileString); |
|
340 } |
|
341 } |
|
342 CleanupStack::PopAndDestroy(string); |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------- |
|
346 // CIMCVEngine::ParseAllSmileyStringL() |
|
347 // --------------------------------------------------------- |
|
348 // |
|
349 EXPORT_C CGulIcon* CIMCVEngine::GetPresenceIconL(const TDesC8& aIconid) |
|
350 { |
|
351 CFbsBitmap* bitmap = NULL; |
|
352 CFbsBitmap* mask = NULL; |
|
353 CGulIcon* icon = NULL; |
|
354 iBrandingAccess->GetBitmapL(aIconid, bitmap, mask ); |
|
355 CleanupStack::PushL( bitmap ); |
|
356 CleanupStack::PushL( mask ); |
|
357 icon = CGulIcon::NewL( bitmap, mask ); |
|
358 CleanupStack::Pop( 2 ); // bitmap ,mask |
|
359 return icon; |
|
360 } |
|
361 // --------------------------------------------------------- |
|
362 // CIMCVEngine::CreateConnectionL() |
|
363 // --------------------------------------------------------- |
|
364 // |
|
365 void CIMCVEngine::CreateConnectionL() |
|
366 { |
|
367 iPresenceContext = iClient->NewPresenceContextLC(); |
|
368 // ignore code scanner warning, it gives panic |
|
369 CleanupStack::Pop();// because of LC method |
|
370 // Read the ximpfw adaptation uid from SPsettings |
|
371 TInt protocolUidValue = iCCHHandler->GetAdapterUidL(); ; |
|
372 // filter the event from ximpfw ,interested only login and request complete |
|
373 iAcceptedEventTypes.Reset(); |
|
374 iAcceptedEventTypes.AppendL( MXIMPRequestCompleteEvent::KInterfaceId ); |
|
375 iAcceptedEventTypes.AppendL( MXIMPContextStateEvent::KInterfaceId ); |
|
376 |
|
377 TArray< TInt32 > eventFilterArray = iAcceptedEventTypes.Array(); |
|
378 // register this to prsence context |
|
379 iPresenceContext->RegisterObserverL( *iContextEventObserver, &eventFilterArray ); |
|
380 TUid protocolUid =TUid::Uid( protocolUidValue ); |
|
381 iContextEventObserver->GetConnectedSessionL(*iPresenceContext,iServiceId, protocolUid ); |
|
382 } |
|
383 // --------------------------------------------------------- |
|
384 // CIMCVEngine::ChatInterface() |
|
385 // --------------------------------------------------------- |
|
386 // |
|
387 EXPORT_C MIMCVEngineChatInterface& CIMCVEngine::ChatInterface() const |
|
388 { |
|
389 return *iChatInterface; |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------- |
|
393 // CIMCVEngine::ChatInterface() |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 EXPORT_C MIMCVEngineMessageHandler& CIMCVEngine::MessageHandler() const |
|
397 { |
|
398 return *iMessageHandler; |
|
399 } |
|
400 |
|
401 // --------------------------------------------------------- |
|
402 // CIMCVEngine::ReadyForShutdown() |
|
403 // --------------------------------------------------------- |
|
404 // |
|
405 EXPORT_C TBool CIMCVEngine::ReadyForShutdown() |
|
406 { |
|
407 return !iContextEventObserver->IsLoggedIn(); |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------- |
|
411 // CIMCVEngine::IsLoggedIn() |
|
412 // --------------------------------------------------------- |
|
413 // |
|
414 EXPORT_C TBool CIMCVEngine::IsLoggedIn() const |
|
415 { |
|
416 return iContextEventObserver->IsLoggedIn(); |
|
417 } |
|
418 |
|
419 // --------------------------------------------------------- |
|
420 // CIMCVEngine::GetLoggedInUserId() |
|
421 // --------------------------------------------------------- |
|
422 // |
|
423 EXPORT_C const TDesC& CIMCVEngine::GetLoggedInUserId() |
|
424 { |
|
425 if(iOwnUserId) |
|
426 { |
|
427 return *iOwnUserId; |
|
428 } |
|
429 return KNullDesC; |
|
430 } |
|
431 // --------------------------------------------------------- |
|
432 // CIMCVEngine::ReleaseConnectionL() |
|
433 // --------------------------------------------------------- |
|
434 // |
|
435 EXPORT_C void CIMCVEngine::ReleaseConnectionL() |
|
436 { |
|
437 if (iPresenceContext) |
|
438 { |
|
439 iContextEventObserver->ReleaseConnectionL(*iPresenceContext); |
|
440 } |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------- |
|
444 // CIMCVEngine::DeleteContextL() |
|
445 // --------------------------------------------------------- |
|
446 // |
|
447 void CIMCVEngine::DeleteContextL() |
|
448 { |
|
449 if(iPresenceContext) |
|
450 { |
|
451 iPresenceContext->UnregisterObserver( *iContextEventObserver ); |
|
452 delete iPresenceContext; |
|
453 iPresenceContext = NULL; |
|
454 |
|
455 } |
|
456 |
|
457 } |
|
458 |
|
459 // --------------------------------------------------------- |
|
460 // CIMCVEngine::CreateContextL() |
|
461 // --------------------------------------------------------- |
|
462 // |
|
463 void CIMCVEngine::CreateContextL() |
|
464 { |
|
465 if(!iPresenceContext) |
|
466 { |
|
467 CreateConnectionL(); |
|
468 iMessageHandler->ResetContextL(iPresenceContext); |
|
469 } |
|
470 } |
|
471 // --------------------------------------------------------- |
|
472 // CIMCVEngine::GetLoggedInUserId() |
|
473 // --------------------------------------------------------- |
|
474 // |
|
475 EXPORT_C const TDesC8& CIMCVEngine::GetBrandId() |
|
476 { |
|
477 if(iBrandId) |
|
478 { |
|
479 return *iBrandId; |
|
480 } |
|
481 return KNullDesC8; |
|
482 } |
|
483 // --------------------------------------------------------- |
|
484 // CIMCVEngine::GetLoggedInUserId() |
|
485 // --------------------------------------------------------- |
|
486 // |
|
487 EXPORT_C TInt CIMCVEngine::GetLanguageId() |
|
488 { |
|
489 return iLanguageId; |
|
490 } |
|
491 |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // CIMCVEngine::CCHHandler() |
|
495 // --------------------------------------------------------- |
|
496 // |
|
497 EXPORT_C MIMCVEngineCchHandler& CIMCVEngine::CCHHandler() |
|
498 { |
|
499 return *iCCHHandler; |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------- |
|
503 // CIMCVEngine::ServiceName() |
|
504 // --------------------------------------------------------- |
|
505 // |
|
506 EXPORT_C const TDesC& CIMCVEngine::ServiceName() |
|
507 { |
|
508 return *iServiceName; |
|
509 } |
|
510 |
|
511 |
|
512 // --------------------------------------------------------- |
|
513 // CIMCVEngine::GetLoggedInUserId() |
|
514 // --------------------------------------------------------- |
|
515 // |
|
516 |
|
517 EXPORT_C MIMCVEngineOpenChats& CIMCVEngine::OpenChats() |
|
518 { |
|
519 return iMessageHandler->OpenChats(); |
|
520 } |
|
521 |
|
522 |
|
523 // --------------------------------------------------------- |
|
524 // CIMCVEngine::GetServiceId() |
|
525 // --------------------------------------------------------- |
|
526 // |
|
527 EXPORT_C TInt CIMCVEngine::GetServiceId() |
|
528 { |
|
529 return iServiceId; |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // CIMCVEngine::GetServiceNameL() |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 void CIMCVEngine::GetServiceNameL( |
|
537 TUint32 aServiceId, TDes& aServiceName ) |
|
538 { |
|
539 |
|
540 CSPSettings* settings = CSPSettings::NewLC(); |
|
541 CSPEntry* entry = CSPEntry::NewLC(); |
|
542 TRAPD( err, settings->FindEntryL( aServiceId, *entry ) ); |
|
543 if ( !err ) |
|
544 { |
|
545 aServiceName = entry->GetServiceName(); |
|
546 } |
|
547 |
|
548 CleanupStack::PopAndDestroy( 2 ); |
|
549 } |
|
550 // --------------------------------------------------------------------------- |
|
551 // CIMCVEngine::IsVoipServiceL() |
|
552 // --------------------------------------------------------------------------- |
|
553 // |
|
554 EXPORT_C TBool CIMCVEngine::IsVoipServiceL() |
|
555 { |
|
556 TBool isvoipservice = EFalse; |
|
557 CSPSettings* settings = CSPSettings::NewLC(); |
|
558 CSPProperty* property = CSPProperty::NewLC(); |
|
559 settings->FindPropertyL(iServiceId, ESubPropertyVoIPEnabled, *property); |
|
560 if (property) |
|
561 { |
|
562 isvoipservice = ETrue; |
|
563 } |
|
564 CleanupStack::PopAndDestroy(2); //property,settings |
|
565 return isvoipservice; |
|
566 } |
|
567 |
|
568 |
|
569 |
|
570 // --------------------------------------------------------------------------- |
|
571 // CIMCVEngine::GetBrandIdL() |
|
572 // --------------------------------------------------------------------------- |
|
573 // |
|
574 void CIMCVEngine::GetBrandIdL( |
|
575 TUint32 aServiceId, TDes8& aBrandId ) |
|
576 { |
|
577 HBufC* ret = HBufC::NewL( KVIMPSTUISPSMaxPropertyLength ); |
|
578 CleanupStack::PushL( ret ); |
|
579 TPtr retPtr( ret->Des() ); |
|
580 |
|
581 CSPSettings* settings = CSPSettings::NewLC(); |
|
582 CSPProperty* property = CSPProperty::NewLC(); |
|
583 settings->FindPropertyL( aServiceId, |
|
584 EPropertyBrandId, |
|
585 *property ); |
|
586 if ( property ) |
|
587 { |
|
588 property->GetValue( retPtr ); |
|
589 aBrandId.Copy( retPtr ); |
|
590 } |
|
591 CleanupStack::PopAndDestroy( 3 ); //property,settings,ret |
|
592 } |
|
593 |
|
594 |
|
595 |
|
596 // --------------------------------------------------------------------------- |
|
597 // CIMCVEngine::PropertyBrandLanguageL() |
|
598 // --------------------------------------------------------------------------- |
|
599 // |
|
600 TLanguage CIMCVEngine::PropertyBrandLanguageL( |
|
601 TUint32 aServiceId ) |
|
602 { |
|
603 |
|
604 // default to english |
|
605 TInt brandLanguage = ELangInternationalEnglish; |
|
606 CSPSettings* settings = CSPSettings::NewLC(); |
|
607 CSPProperty* property = CSPProperty::NewLC(); |
|
608 settings->FindPropertyL( aServiceId, |
|
609 EPropertyBrandLanguage, |
|
610 *property ); |
|
611 if ( property ) |
|
612 { |
|
613 property->GetValue( brandLanguage ); |
|
614 } |
|
615 CleanupStack::PopAndDestroy( 2 ); // property,settings |
|
616 |
|
617 return ((TLanguage) (brandLanguage) ); |
|
618 } |
|
619 |
|
620 |
|
621 |
|
622 // --------------------------------------------------------------------------- |
|
623 // CIMCVEngine::PropertySettingsIdL() |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 TInt CIMCVEngine::PropertySettingsIdL( |
|
627 TUint32 aServiceId ) |
|
628 { |
|
629 |
|
630 // default to english |
|
631 TInt settingsId = 0; |
|
632 CSPSettings* settings = CSPSettings::NewLC(); |
|
633 CSPProperty* property = CSPProperty::NewLC(); |
|
634 settings->FindPropertyL( aServiceId, |
|
635 ESubPropertyIMSettingsId, |
|
636 *property ); |
|
637 if ( property ) |
|
638 { |
|
639 property->GetValue( settingsId ); |
|
640 } |
|
641 CleanupStack::PopAndDestroy( 2 ); // property,settings |
|
642 |
|
643 return (settingsId); |
|
644 } |
|
645 |
|
646 |
|
647 // --------------------------------------------------------------------------- |
|
648 // CIMCVEngine::ResolveServiceStateL() |
|
649 // --------------------------------------------------------------------------- |
|
650 // |
|
651 EXPORT_C void CIMCVEngine::ResolveServiceStateL() |
|
652 { |
|
653 |
|
654 if ((!IsLoggedIn()) && (iCCHHandler->IsServiceLoggedIn())) |
|
655 { |
|
656 IM_CV_LOGS(TXT("CIMCVEngine::ResolveServiceState() NOT LOGGED IN") ); |
|
657 iChatInterface->CloseAllContainers(); |
|
658 CreateContextL(); |
|
659 } |
|
660 |
|
661 } |
|
662 // --------------------------------------------------------------------------- |
|
663 // CIMCVEngine::GetUserIdL() |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 void CIMCVEngine::GetUserIdL(TPtr& aUserId ) |
|
667 { |
|
668 |
|
669 HBufC* userId = iCCHHandler->GetUserIdL(); |
|
670 |
|
671 if(userId) |
|
672 { |
|
673 TPtr userIdPtr( userId->Des() ); |
|
674 |
|
675 aUserId.Copy( userIdPtr ); |
|
676 } |
|
677 delete userId; |
|
678 |
|
679 } |
|
680 |
|
681 |
|
682 // --------------------------------------------------------------------------- |
|
683 // CIMCVEngine::LoginL() |
|
684 // --------------------------------------------------------------------------- |
|
685 // |
|
686 EXPORT_C TInt CIMCVEngine::LoginL() |
|
687 { |
|
688 if (!IsLoggedIn()) |
|
689 { |
|
690 iState = ELogin; |
|
691 IssueRequest(); |
|
692 // ignore codescanner warning ignored. |
|
693 if( !iWait.IsStarted() ) |
|
694 { |
|
695 // Code scanner warning "active object called without checking |
|
696 // whether it is active or cancelling it first" ignored because |
|
697 // CActiveSchedulerWait is not an active object |
|
698 iWait.Start(); // CSI: 10 # See above |
|
699 } |
|
700 |
|
701 if ( EOperationInComplete == iState ) |
|
702 { |
|
703 return KErrGeneral; |
|
704 } |
|
705 } |
|
706 return KErrNone; |
|
707 } |
|
708 |
|
709 |
|
710 // -------------------------------------------------------------------------- |
|
711 // CIMCVEngine::RunL |
|
712 // -------------------------------------------------------------------------- |
|
713 // |
|
714 void CIMCVEngine::RunL() |
|
715 { |
|
716 switch( iState ) |
|
717 { |
|
718 case ELogin: |
|
719 { |
|
720 //cch is not logged in |
|
721 if (!iCCHHandler->IsServiceLoggedIn()) |
|
722 { |
|
723 TInt error = iCCHHandler->EnableService(); |
|
724 if (KErrNone != error) |
|
725 { |
|
726 iState = EOperationInComplete; |
|
727 IssueRequest(); |
|
728 } |
|
729 else |
|
730 { |
|
731 iCCHHandler->RegisterObserver(this); |
|
732 } |
|
733 } |
|
734 else |
|
735 { |
|
736 //cch logged in but the ximp context is not logged in |
|
737 if (!IsLoggedIn()) |
|
738 { |
|
739 TRAPD(err,CreateConnectionL()); |
|
740 if(KErrNone == err ) |
|
741 { |
|
742 iState = EOperationComplete; |
|
743 } |
|
744 else |
|
745 { |
|
746 iState = EOperationInComplete; |
|
747 } |
|
748 IssueRequest(); |
|
749 } |
|
750 } |
|
751 break; |
|
752 } |
|
753 |
|
754 case EOperationInComplete: |
|
755 { |
|
756 iCCHHandler->UnRegisterObserver(); |
|
757 if( iWait.IsStarted() ) |
|
758 { |
|
759 iWait.AsyncStop(); |
|
760 } |
|
761 break; |
|
762 } |
|
763 |
|
764 case EOperationComplete: |
|
765 { |
|
766 iCCHHandler->UnRegisterObserver(); |
|
767 if( iWait.IsStarted() ) |
|
768 { |
|
769 iWait.AsyncStop(); |
|
770 } |
|
771 break; |
|
772 } |
|
773 |
|
774 default: |
|
775 { |
|
776 // Do nothing |
|
777 break; |
|
778 } |
|
779 } |
|
780 } |
|
781 |
|
782 // -------------------------------------------------------------------------- |
|
783 // CIMCVEngine::DoCancel |
|
784 // -------------------------------------------------------------------------- |
|
785 // |
|
786 void CIMCVEngine::DoCancel() |
|
787 { |
|
788 } |
|
789 |
|
790 // -------------------------------------------------------------------------- |
|
791 // CIMCVEngine::RunError |
|
792 // -------------------------------------------------------------------------- |
|
793 // |
|
794 TInt CIMCVEngine::RunError( TInt /*aError*/ ) |
|
795 { |
|
796 return KErrNone; |
|
797 } |
|
798 |
|
799 |
|
800 // -------------------------------------------------------------------------- |
|
801 // CIMCVEngine::IssueRequest |
|
802 // -------------------------------------------------------------------------- |
|
803 // |
|
804 void CIMCVEngine::IssueRequest() |
|
805 { |
|
806 if (IsActive()) |
|
807 { |
|
808 Cancel(); |
|
809 } |
|
810 |
|
811 TRequestStatus* status = &iStatus; |
|
812 User::RequestComplete( status, KErrNone ); |
|
813 SetActive(); |
|
814 } |
|
815 |
|
816 |
|
817 // -------------------------------------------------------------------------- |
|
818 // CIMCVEngine::ServiceStatusChanged |
|
819 // -------------------------------------------------------------------------- |
|
820 // |
|
821 void CIMCVEngine::ServiceStatusChanged( TInt /*aServiceId*/, |
|
822 TServiceState aServiceStatus ) |
|
823 { |
|
824 |
|
825 switch(aServiceStatus) |
|
826 { |
|
827 case MIMCVEngineCCHObserver::ENotLoggedIn: |
|
828 { |
|
829 iState = EOperationInComplete; |
|
830 IssueRequest(); |
|
831 break; |
|
832 } |
|
833 case MIMCVEngineCCHObserver::EConnecting: |
|
834 { |
|
835 //Nothing to be done |
|
836 break; |
|
837 } |
|
838 case MIMCVEngineCCHObserver::ELogin: |
|
839 { |
|
840 iState = EOperationComplete; |
|
841 IssueRequest(); |
|
842 break; |
|
843 } |
|
844 case MIMCVEngineCCHObserver::EDisconnecting: |
|
845 { |
|
846 //nothing to be done |
|
847 break; |
|
848 } |
|
849 |
|
850 default: |
|
851 { |
|
852 break; |
|
853 } |
|
854 } |
|
855 } |
|
856 // -------------------------------------------------------------------------- |
|
857 // CIMCVEngine::CloseAllOpenChatsL |
|
858 // -------------------------------------------------------------------------- |
|
859 // |
|
860 void CIMCVEngine::CloseAllOpenChatsL() |
|
861 { |
|
862 IM_CV_LOGS(TXT("CIMCVEngine::CloseAllOpenChatsL() ***************************** START") ); |
|
863 iMessageHandler->CloseAllConversationL(); |
|
864 IM_CV_LOGS(TXT("CIMCVEngine::CloseAllOpenChatsL() ***************************** END") ); |
|
865 } |
|
866 |
|
867 // End of File |
|