|
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: service manager for a specific service |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "cservicewidgetservicemanager.h" |
|
21 |
|
22 #include "cservicewidgetcontentpublisher.h" |
|
23 #include "cservicewidgetbrandhandler.h" |
|
24 #include "cservicewidgetmessagehandler.h" |
|
25 #include "cservicewidgetcchhandler.h" |
|
26 #include "cservicewidgetpresencehandler.h" |
|
27 #include "cservicewidgettimer.h" |
|
28 #include "servicewidgetcpglobals.h" |
|
29 #include "servicewidgetutils.h" |
|
30 #include "swpdebugtrace.h" |
|
31 #include <eikenv.h> |
|
32 #include <servicewidgetpluginres.rsg> |
|
33 #include <cchtypes.h> |
|
34 |
|
35 #include <cvimpstsettingsstore.h> |
|
36 #include <imcvlauncher.h> |
|
37 #include <xSPViewServices.h> |
|
38 #include <eikappui.h> |
|
39 |
|
40 #include <spsettings.h> |
|
41 #include <spentry.h> |
|
42 #include <spproperty.h> |
|
43 |
|
44 #include <s32mem.h> //For Stream writing |
|
45 //--------------------------------------------------------------------------- |
|
46 // CServiceWidgetServiceManager::NewL |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CServiceWidgetServiceManager* CServiceWidgetServiceManager::NewL(TUint32 aServiceId, |
|
50 CServiceWidgetContentPublisher& aContentPublisher, |
|
51 MVIMPSTSettingsStore& aSettingStore ) |
|
52 { |
|
53 TRACE_SWP(TXT("CServiceWidgetServiceManager::NewL() start") ); |
|
54 CServiceWidgetServiceManager* self = new( ELeave )CServiceWidgetServiceManager( aServiceId, aContentPublisher , aSettingStore); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop( self ); |
|
58 TRACE_SWP(TXT("CServiceWidgetServiceManager::NewL() end") ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CServiceWidgetServiceManager::CServiceWidgetServiceManager |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CServiceWidgetServiceManager::CServiceWidgetServiceManager(TUint32 aServiceId, |
|
67 CServiceWidgetContentPublisher& aContentPublisher, |
|
68 MVIMPSTSettingsStore& aSettingStore ) |
|
69 :iServiceId( aServiceId ), |
|
70 iContentPublisher( aContentPublisher ), |
|
71 iSettingStore( aSettingStore ), |
|
72 iExecuteOperation( ESWAUnknown ) |
|
73 { |
|
74 TRACE_SWP(TXT("CServiceWidgetServiceManager::CServiceWidgetServiceManager() start") ); |
|
75 TRACE_SWP(TXT("CServiceWidgetServiceManager::CServiceWidgetServiceManager() start") ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CServiceWidgetServiceManager::ConstructL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CServiceWidgetServiceManager::ConstructL() |
|
83 { |
|
84 TRACE_SWP(TXT("CServiceWidgetServiceManager::ConstructL() start") ); |
|
85 CSPSettings* settings = CSPSettings::NewLC(); |
|
86 // read service name |
|
87 CSPEntry* entry = CSPEntry::NewLC(); |
|
88 settings->FindEntryL( iServiceId, *entry ) ; |
|
89 // set the service name to presence cache updater |
|
90 iServiceName = entry->GetServiceName().AllocL() ; |
|
91 |
|
92 //KThemeUid appended to iServiceName for making service name unique from serivces |
|
93 //published by other applications |
|
94 iServiceName = iServiceName->ReAllocL(iServiceName->Des().Length() + KThemeUid().Length()); |
|
95 iServiceName->Des().Append(KThemeUid); |
|
96 CleanupStack::PopAndDestroy(2); // entry,settings |
|
97 |
|
98 iBrandHandler = CServiceWidgetBrandHandler::NewL(iServiceId); |
|
99 TRACE_SWP(TXT("CServiceWidgetServiceManager::ConstructL() end") ); |
|
100 } |
|
101 // --------------------------------------------------------------------------- |
|
102 // CServiceWidgetServiceManager::ActivateWidgetL |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CServiceWidgetServiceManager::ActivateWidgetL(TDesC& aInstId) |
|
106 { |
|
107 TRACE_SWP(TXT("CServiceWidgetServiceManager::ActivateWidget() start") ); |
|
108 iEnv = CEikonEnv::Static(); |
|
109 //CCH handler initialize |
|
110 iCchHandler = CServiceWidgetCchHandler::NewL( iServiceId, *this ); |
|
111 TRACE_SWP(TXT("CServiceWidgetServiceManager::ActivateWidget() iBrandHandler created") ); |
|
112 iServiceState = iCchHandler->ParseGetServiceState(); |
|
113 iServiceviewId = iCchHandler->GetServiceViewIdL( iServiceTabUid ); |
|
114 CreateHandlersL(); |
|
115 //Initialize instance id of corresponding widget |
|
116 iInstId = aInstId.AllocL(); |
|
117 iExecuteOperation = ESWALaunchServiceTab; |
|
118 |
|
119 TRACE_SWP(TXT("CServiceWidgetServiceManager::ActivateWidget() end") ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CServiceWidgetServiceManager::DeactivateWidgetL |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CServiceWidgetServiceManager::DeactivateWidgetL(TDesC& aInstId) |
|
127 { |
|
128 TRACE_SWP(TXT("CServiceWidgetServiceManager::DeactivateWidgetL() start") ); |
|
129 |
|
130 iContentPublisher.RemoveWidgetDataL(*iServiceName,aInstId ); |
|
131 |
|
132 delete iMessageHandler; |
|
133 iMessageHandler = NULL; |
|
134 |
|
135 if( iPresenceHandler) |
|
136 { |
|
137 iPresenceHandler->ReleaseConnectionL() ; |
|
138 delete iPresenceHandler ; |
|
139 iPresenceHandler = NULL; |
|
140 } |
|
141 if( iWidgetTimer ) |
|
142 { |
|
143 iWidgetTimer->StopListening(); |
|
144 delete iWidgetTimer; |
|
145 iWidgetTimer = NULL; |
|
146 } |
|
147 |
|
148 delete iCchHandler; |
|
149 iCchHandler = NULL; |
|
150 |
|
151 delete iInstId; |
|
152 iInstId = NULL; |
|
153 |
|
154 iIsWidgetSuspended = EFalse; |
|
155 iExecuteOperation = ESWAUnknown; |
|
156 TRACE_SWP(TXT("CServiceWidgetServiceManager::DeactivateWidgetL() end") ); |
|
157 } |
|
158 // --------------------------------------------------------------------------- |
|
159 // CServiceWidgetServiceManager::WidgetSuspended |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 void CServiceWidgetServiceManager::WidgetSuspended( TBool aIsWidgetSuspended ) |
|
163 { |
|
164 iIsWidgetSuspended = aIsWidgetSuspended; |
|
165 } |
|
166 // --------------------------------------------------------------------------- |
|
167 // CServiceWidgetServiceManager::~CServiceWidgetServiceManager |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 CServiceWidgetServiceManager::~CServiceWidgetServiceManager() |
|
171 { |
|
172 TRACE_SWP(TXT("CServiceWidgetServiceManager::~CServiceWidgetServiceManager() start") ); |
|
173 delete iMessageHandler; |
|
174 if( iPresenceHandler) |
|
175 { |
|
176 TRAP_IGNORE( iPresenceHandler->ReleaseConnectionL() ); |
|
177 delete iPresenceHandler ; |
|
178 iPresenceHandler = NULL; |
|
179 } |
|
180 delete iCchHandler; |
|
181 |
|
182 delete iServiceName; |
|
183 |
|
184 if( iWidgetTimer ) |
|
185 { |
|
186 iWidgetTimer->StopListening(); |
|
187 delete iWidgetTimer; |
|
188 } |
|
189 delete iBrandHandler; |
|
190 |
|
191 delete iInstId; |
|
192 |
|
193 TRACE_SWP(TXT("CServiceWidgetServiceManager::~CServiceWidgetServiceManager() end") ); |
|
194 } |
|
195 // --------------------------------------------------------------------------- |
|
196 // CServiceWidgetServiceManager::UpdateContentsL |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void CServiceWidgetServiceManager::UpdateContentsL() |
|
200 { |
|
201 TRACE_SWP(TXT("CServiceWidgetServiceManager::UpdateContentsL() start") ); |
|
202 if( !iIsWidgetSuspended ) |
|
203 { |
|
204 SetCurrentTextDataL(); // to set the data in box 2 and 4 : Own id and new message or invite or presence |
|
205 } |
|
206 TRACE_SWP(TXT("CServiceWidgetServiceManager::UpdateContentsL() end") ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CServiceWidgetServiceManager::SetCurrentTextDataL |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void CServiceWidgetServiceManager::SetCurrentTextDataL() |
|
214 { |
|
215 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() start") ); |
|
216 iServiceState = iCchHandler->ParseGetServiceState(); |
|
217 |
|
218 TWSPresenceStatus showIcon = EWSLast; |
|
219 iExecuteOperation = ESWALaunchServiceTab; |
|
220 |
|
221 TBuf<KIMWCP_FIRSTTEXT_SIZE> firstText( KNullDesC ); |
|
222 TBuf<KIMWCP_SECONDTEXT_SIZE> SecondText( KNullDesC); |
|
223 |
|
224 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() service is complete") ); |
|
225 // service configured correctly |
|
226 TPtrC serviceNameWithUID = iServiceName->Left( KIMWCP_FIRSTTEXT_SIZE ); |
|
227 |
|
228 //serviceName is retrieved by removing KThemeUID. This text is displayed in first line of |
|
229 //home screen widget when iServiceState state is ESWSNotRegistered state. |
|
230 TPtrC serviceName = serviceNameWithUID.Left( serviceNameWithUID.Length() - KThemeUid().Length() ); |
|
231 |
|
232 TPtrC ownUser = ServiceWidgetUtils::DisplayId( iCchHandler->OwnUserIdL().Left( KIMWCP_FIRSTTEXT_SIZE ) ); |
|
233 switch( iServiceState ) |
|
234 { |
|
235 case ESWSNetworkConnecting: |
|
236 { |
|
237 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() Connecting") ); |
|
238 firstText.Append(ownUser); |
|
239 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_CONNECTING,iEnv ); |
|
240 if( str ) |
|
241 { |
|
242 SecondText.Append( *str ); |
|
243 CleanupStack::PopAndDestroy(str); //str |
|
244 } |
|
245 break; |
|
246 } |
|
247 case ESWSUpdatingContacts: |
|
248 case ESWSRegistered: |
|
249 { |
|
250 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() Enabled") ); |
|
251 firstText.Append(ownUser ); |
|
252 TWServiceOperationId operationId = EWSOperationUnknown; |
|
253 HBufC* tempValue = NULL; |
|
254 if( iPresenceHandler ) |
|
255 { |
|
256 // presence service supported |
|
257 // take the ongoing operation |
|
258 showIcon = iPresenceHandler->GetOwnStatus(); |
|
259 operationId = iPresenceHandler->GetOngoingOperationId(); |
|
260 if( operationId != EWSOperationComplete ) |
|
261 { |
|
262 // fetching is on going |
|
263 tempValue = ServiceWidgetUtils::LoadResourceLC(R_QTN_SERVTAB_WIDGET_UPDATING ,iEnv ); |
|
264 } |
|
265 } |
|
266 if( !tempValue) |
|
267 { |
|
268 // second row data is empty ,read it |
|
269 tempValue = GetSecondRowDataLC(); |
|
270 } |
|
271 if( tempValue ) |
|
272 { |
|
273 TPtrC tempValuePtr( tempValue->Des() ); |
|
274 SecondText.Append( tempValuePtr ); |
|
275 CleanupStack::PopAndDestroy(tempValue); // tempValue |
|
276 } |
|
277 break; |
|
278 } |
|
279 case ESWSNetworkDisConnecting: |
|
280 { |
|
281 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() Disconnecting") ); |
|
282 firstText.Append(ownUser ); |
|
283 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_LOGGINGOUT ,iEnv); |
|
284 if( str ) |
|
285 { |
|
286 SecondText.Append( *str ); |
|
287 CleanupStack::PopAndDestroy(str); //str |
|
288 } |
|
289 break; |
|
290 } |
|
291 case ESWSWaitingForNetwork: |
|
292 { |
|
293 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() Waiting for connection") ); |
|
294 // waiting for network connection mostly for service which has ALR support |
|
295 firstText.Append(ownUser ); |
|
296 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_WAITING ,iEnv); |
|
297 if( str ) |
|
298 { |
|
299 SecondText.Append( *str ); |
|
300 CleanupStack::PopAndDestroy(str); //str |
|
301 } |
|
302 break; |
|
303 } |
|
304 case ESWSNotRegistered: |
|
305 default : |
|
306 { |
|
307 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() ECCHDisabled || default ") ); |
|
308 firstText.Append(serviceName ); |
|
309 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_LOGIN ,iEnv ); |
|
310 if( str ) |
|
311 { |
|
312 SecondText.Append( *str ); |
|
313 CleanupStack::PopAndDestroy(str); //str |
|
314 } |
|
315 iExecuteOperation = ESWALaunchSTAutoLogin; |
|
316 TInt isSuccessfullLogin = KErrNone; |
|
317 iSettingStore.GetL(iServiceId, EServiceSuccessfullLogin, isSuccessfullLogin ); |
|
318 if( isSuccessfullLogin ) |
|
319 { |
|
320 iExecuteOperation = ESWAStartLogin; |
|
321 } |
|
322 break; |
|
323 } |
|
324 } |
|
325 //Data to publish service Icon |
|
326 TInt sericonbitmapHandle = 0 ; |
|
327 TInt sericonmaskHandle = 0 ; |
|
328 iBrandHandler->GetStatusBitmapL( EWSServiceIcon, sericonbitmapHandle, sericonmaskHandle ) ; |
|
329 //data to publish presence icon |
|
330 TInt bitmapHandle = 0; |
|
331 TInt maskHandle = 0 ; |
|
332 iBrandHandler->GetStatusBitmapL( showIcon, bitmapHandle, maskHandle ) ; |
|
333 // publish the data to widget |
|
334 iContentPublisher.PublishDataWithActionL( *iServiceName, |
|
335 *iInstId, |
|
336 firstText, |
|
337 SecondText, |
|
338 bitmapHandle, |
|
339 maskHandle, |
|
340 sericonbitmapHandle, |
|
341 sericonmaskHandle |
|
342 ); |
|
343 TRACE_SWP(TXT("CServiceWidgetServiceManager::SetCurrentTextDataL() end") ); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // CServiceWidgetServiceManager::GetSecondRowDataLC |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 HBufC* CServiceWidgetServiceManager::GetSecondRowDataLC() |
|
351 { |
|
352 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() start ") ); |
|
353 HBufC* text = HBufC::NewLC(KIMWCP_SECONDTEXT_SIZE); |
|
354 TPtr textPtr( text->Des() ); |
|
355 TInt unreadCount = 0; |
|
356 TInt inviteCount = 0; |
|
357 HBufC* str = NULL; |
|
358 |
|
359 if( iMessageHandler) |
|
360 { |
|
361 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() iMessageHandler ") ); |
|
362 unreadCount = iMessageHandler->GetUnreadMessageCountL(); |
|
363 } |
|
364 if( iPresenceHandler) |
|
365 { |
|
366 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() iPresenceHandler ") ); |
|
367 inviteCount = iPresenceHandler->GetInviteCounts(); |
|
368 } |
|
369 if( ( static_cast<TIMWidgetContentPriority>( iPriority ) == EIMNewMessage) |
|
370 && unreadCount ) // match the priority |
|
371 { |
|
372 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() unreadCount %d "), unreadCount ); |
|
373 if( iMessageHandler->IsSingleMessageSender() ) |
|
374 { |
|
375 // single sender launch conversation view |
|
376 iExecuteOperation = ESWALaunchConverView ; |
|
377 } |
|
378 if( unreadCount == 1 ) |
|
379 { |
|
380 // exactly one message show singular form |
|
381 str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_ONENEWMSG , iEnv); |
|
382 } |
|
383 else |
|
384 { |
|
385 // more than one message show plural form |
|
386 str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_NEWMSGS, unreadCount, iEnv ); |
|
387 } |
|
388 if( str ) |
|
389 { |
|
390 textPtr.Append( *str ); |
|
391 CleanupStack::PopAndDestroy(str); //str |
|
392 } |
|
393 } |
|
394 else if( ( static_cast<TIMWidgetContentPriority>( ++iPriority ) == EIMFriendInvite ) |
|
395 && inviteCount ) |
|
396 // match the priority |
|
397 { |
|
398 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() inviteCount %d "), inviteCount ); |
|
399 if( inviteCount == 1 ) |
|
400 { |
|
401 // exactly one request show singular form |
|
402 str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_ONEPENDREQ ,iEnv ); |
|
403 } |
|
404 else |
|
405 { |
|
406 // more than one request show plural form |
|
407 str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_PENDREQ, inviteCount, iEnv ); |
|
408 } |
|
409 if( str ) |
|
410 { |
|
411 textPtr.Append( *str ); |
|
412 CleanupStack::PopAndDestroy(str); //str |
|
413 } |
|
414 } |
|
415 else if( iPresenceHandler )// this is next priority |
|
416 { |
|
417 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() iPresenceHandler ") ); |
|
418 TInt totalCount = iPresenceHandler->AllBuddyCount(); |
|
419 TInt onlineCount = iPresenceHandler->OnlineBuddyCount(); |
|
420 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() totalCount %d "), totalCount); |
|
421 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() onlineCount %d "), onlineCount); |
|
422 // array to append online / totlal counts |
|
423 CArrayFix<TInt>* intArray = new ( ELeave ) CArrayFixFlat<TInt>( 2 ); |
|
424 CleanupStack::PushL( intArray ); |
|
425 intArray->AppendL( onlineCount ); |
|
426 intArray->AppendL( totalCount ); |
|
427 str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_ONLINESTATUS, *intArray , iEnv ); |
|
428 if( str ) |
|
429 { |
|
430 textPtr.Append( *str ); |
|
431 CleanupStack::PopAndDestroy(str); //str |
|
432 } |
|
433 CleanupStack::PopAndDestroy(intArray); //intArray |
|
434 } |
|
435 else |
|
436 { |
|
437 // nothing to show in online case ,show "You are online" |
|
438 str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_AVAILABLE ,iEnv ); |
|
439 if( str ) |
|
440 { |
|
441 textPtr.Append( *str ); |
|
442 CleanupStack::PopAndDestroy(str); //str |
|
443 } |
|
444 } |
|
445 ResetPriority(); // reset to high again |
|
446 TRACE_SWP(TXT("CServiceWidgetServiceManager::GetSecondRowDataLC() end ") ); |
|
447 return text; // ownership to caller |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 // CServiceWidgetServiceManager::HandleNewMessageL |
|
452 // --------------------------------------------------------------------------- |
|
453 // |
|
454 void CServiceWidgetServiceManager::HandleNewMessageL(const TDesC& aSenderId ,const TDesC& aMessageText) |
|
455 { |
|
456 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleNewMessageL() start ") ); |
|
457 if( !iIsWidgetSuspended ) |
|
458 { |
|
459 TBuf<KIMWCP_FIRSTTEXT_SIZE> firstText; |
|
460 TBuf<KIMWCP_SECONDTEXT_SIZE> secondText; |
|
461 TBuf<KIMWCP_ADD_DATA_SIZE> additionalData( KNullDesC); |
|
462 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_FRIEND, |
|
463 ServiceWidgetUtils::DisplayId( aSenderId ), |
|
464 iEnv ); |
|
465 if( str ) |
|
466 { |
|
467 TPtr strPtr( str->Des() ); |
|
468 firstText.Append( strPtr.Left( KIMWCP_FIRSTTEXT_SIZE ) ); |
|
469 CleanupStack::PopAndDestroy(str); //str |
|
470 } |
|
471 secondText.Append( aMessageText.Left( KIMWCP_SECONDTEXT_SIZE ) ); |
|
472 |
|
473 additionalData.Append( aSenderId.Left( KIMWCP_ADD_DATA_SIZE ) ) ; |
|
474 |
|
475 //Data to be published for service icon |
|
476 TInt sericonbitmapHandle = 0 ; |
|
477 TInt sericonmaskHandle = 0 ; |
|
478 iBrandHandler->GetStatusBitmapL( EWSServiceIcon, sericonbitmapHandle, sericonmaskHandle ) ; |
|
479 |
|
480 TInt bitmapHandle = 0; |
|
481 TInt maskHandle = 0 ; |
|
482 iBrandHandler->GetStatusBitmapL( EWSNewMessage, bitmapHandle, maskHandle ) ; |
|
483 // publish the new message icon with all other data |
|
484 iContentPublisher.PublishDataWithActionL( *iServiceName, |
|
485 *iInstId, |
|
486 firstText, |
|
487 secondText , |
|
488 bitmapHandle, |
|
489 maskHandle, |
|
490 sericonbitmapHandle, |
|
491 sericonmaskHandle |
|
492 ); |
|
493 iExecuteOperation = ESWALaunchConverView; |
|
494 if( iWidgetTimer ) |
|
495 { |
|
496 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleNewMessageL() timer started ") ); |
|
497 iWidgetTimer->StopListening(); |
|
498 iWidgetTimer->StartListening( KTimerInterval ); |
|
499 } |
|
500 } |
|
501 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleNewMessageL() end ") ); |
|
502 } |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // CServiceWidgetServiceManager::HandleAddRequestL |
|
506 // --------------------------------------------------------------------------- |
|
507 // |
|
508 void CServiceWidgetServiceManager::HandleAddRequestL(const TDesC& aRequesterId ) |
|
509 { |
|
510 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleAddRequestL() start ") ); |
|
511 if( !iIsWidgetSuspended ) |
|
512 { |
|
513 TBuf<KIMWCP_FIRSTTEXT_SIZE> firstText; |
|
514 TBuf<KIMWCP_SECONDTEXT_SIZE> secondText; |
|
515 |
|
516 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_INVITE ,iEnv ); |
|
517 if( str ) |
|
518 { |
|
519 TPtr strPtr( str->Des() ); |
|
520 firstText.Append( strPtr.Left( KIMWCP_FIRSTTEXT_SIZE ) ); |
|
521 CleanupStack::PopAndDestroy(str); //str |
|
522 } |
|
523 secondText.Append( ServiceWidgetUtils::DisplayId( aRequesterId ).Left( KIMWCP_SECONDTEXT_SIZE ) ); |
|
524 // publish the last icon which is empty |
|
525 TBuf<KIMWCP_ADD_DATA_SIZE> additionalData( KNullDesC); |
|
526 //Data to be published for service icon |
|
527 TInt sericonbitmapHandle = 0 ; |
|
528 TInt sericonmaskHandle = 0 ; |
|
529 iBrandHandler->GetStatusBitmapL( EWSServiceIcon, sericonbitmapHandle, sericonmaskHandle ) ; |
|
530 |
|
531 TInt bitmapHandle = 0; |
|
532 TInt maskHandle = 0 ; |
|
533 iBrandHandler->GetStatusBitmapL( EWSLast, bitmapHandle, maskHandle ) ; |
|
534 //Publish all data |
|
535 iContentPublisher.PublishDataWithActionL(*iServiceName, |
|
536 *iInstId, |
|
537 firstText, |
|
538 secondText, |
|
539 bitmapHandle, |
|
540 maskHandle, |
|
541 sericonbitmapHandle, |
|
542 sericonmaskHandle |
|
543 ); |
|
544 iExecuteOperation = ESWALaunchServiceTab; |
|
545 if( iWidgetTimer ) |
|
546 { |
|
547 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleAddRequestL() timer started ") ); |
|
548 iWidgetTimer->StopListening(); |
|
549 iWidgetTimer->StartListening( KTimerInterval ); |
|
550 } |
|
551 } |
|
552 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleAddRequestL() start ") ); |
|
553 } |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // CServiceWidgetServiceManager::HandleCountChangedL |
|
557 // --------------------------------------------------------------------------- |
|
558 // |
|
559 void CServiceWidgetServiceManager::HandleCountChangedL() |
|
560 { |
|
561 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleCountChangedL() start ") ); |
|
562 UpdateContentsL(); // set new data |
|
563 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleCountChangedL() end ") ); |
|
564 } |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // CServiceWidgetServiceManager::HandleChangeL |
|
568 // --------------------------------------------------------------------------- |
|
569 // |
|
570 void CServiceWidgetServiceManager::HandleChangeL() |
|
571 { |
|
572 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleChangeL() start ") ); |
|
573 UpdateContentsL(); // new data |
|
574 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleChangeL() end ") ); |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // CServiceWidgetServiceManager::HandleBuddyPresenceChangeL |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 void CServiceWidgetServiceManager::HandleBuddyPresenceChangeL(const TDesC& aBuddyId, |
|
582 TWSPresenceStatus aStatus, |
|
583 const TDesC& aStatusText ) |
|
584 { |
|
585 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleBuddyPresenceChangeL() start ") ); |
|
586 if( !iIsWidgetSuspended ) |
|
587 { |
|
588 TBuf<KIMWCP_FIRSTTEXT_SIZE> firstText; |
|
589 TBuf<KIMWCP_SECONDTEXT_SIZE> secondText; |
|
590 HBufC* str = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_FRIEND, |
|
591 ServiceWidgetUtils::DisplayId( aBuddyId ), |
|
592 iEnv ); |
|
593 if( str ) |
|
594 { |
|
595 TPtr strPtr( str->Des() ); |
|
596 firstText.Append( strPtr.Left( KIMWCP_FIRSTTEXT_SIZE ) ); |
|
597 CleanupStack::PopAndDestroy(str); //str |
|
598 } |
|
599 HBufC* statusText = NULL; |
|
600 HBufC* status = NULL; |
|
601 if( aStatusText.Length() ) |
|
602 { |
|
603 statusText = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_STATUS, |
|
604 ServiceWidgetUtils::DisplayId( aStatusText ), |
|
605 iEnv ); |
|
606 } |
|
607 else |
|
608 { |
|
609 TInt statusResId = R_QTN_SERVTAB_WIDGET_OFFLINE; |
|
610 switch( aStatus ) |
|
611 { |
|
612 case EWSOnline: |
|
613 { |
|
614 statusResId = R_QTN_SERVTAB_WIDGET_ONLINE; |
|
615 break; |
|
616 } |
|
617 case EWSAway: |
|
618 { |
|
619 statusResId = R_QTN_SERVTAB_WIDGET_AWAY; |
|
620 break; |
|
621 } |
|
622 case EWSbusy: |
|
623 { |
|
624 statusResId = R_QTN_SERVTAB_WIDGET_BUSY; |
|
625 break; |
|
626 } |
|
627 |
|
628 case EWSDoNotDisturb: |
|
629 { |
|
630 statusResId = R_QTN_SERVTAB_WIDGET_DND; |
|
631 break; |
|
632 } |
|
633 case EWSOnPhone: |
|
634 { |
|
635 statusResId = R_QTN_SERVTAB_WIDGET_ONTHEPHONE; |
|
636 break; |
|
637 } |
|
638 case EWSOffline: |
|
639 default: |
|
640 { |
|
641 statusResId = R_QTN_SERVTAB_WIDGET_OFFLINE; |
|
642 } |
|
643 } |
|
644 status = ServiceWidgetUtils::LoadResourceLC( statusResId, iEnv ); |
|
645 if( status ) |
|
646 { |
|
647 statusText = ServiceWidgetUtils::LoadResourceLC( R_QTN_SERVTAB_WIDGET_STATUS, |
|
648 *status, |
|
649 iEnv ); |
|
650 } |
|
651 } |
|
652 if( statusText ) |
|
653 { |
|
654 TPtr statusTextPtr( statusText->Des() ); |
|
655 secondText.Append( statusTextPtr.Left( KIMWCP_SECONDTEXT_SIZE ) ); |
|
656 CleanupStack::PopAndDestroy(); //statusText |
|
657 if( status ) |
|
658 { |
|
659 CleanupStack::PopAndDestroy(status); //status |
|
660 } |
|
661 |
|
662 } |
|
663 //Data to be published for service Icon |
|
664 TInt sericonbitmapHandle = 0 ; |
|
665 TInt sericonmaskHandle = 0 ; |
|
666 iBrandHandler->GetStatusBitmapL( EWSServiceIcon, sericonbitmapHandle, sericonmaskHandle ) ; |
|
667 ////////////////////////////////////////// |
|
668 TInt bitmapHandle = 0; |
|
669 TInt maskHandle = 0 ; |
|
670 iBrandHandler->GetStatusBitmapL( aStatus, bitmapHandle, maskHandle ) ; |
|
671 TBuf<KIMWCP_ADD_DATA_SIZE> additionalData( KNullDesC); |
|
672 iContentPublisher.PublishDataWithActionL(*iServiceName, |
|
673 *iInstId, |
|
674 firstText, |
|
675 secondText, |
|
676 bitmapHandle, |
|
677 maskHandle, |
|
678 sericonbitmapHandle, |
|
679 sericonmaskHandle |
|
680 ); |
|
681 iExecuteOperation = ESWALaunchServiceTab; |
|
682 if( iWidgetTimer ) |
|
683 { |
|
684 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleBuddyPresenceChangeL() timer started ") ); |
|
685 iWidgetTimer->StopListening(); |
|
686 iWidgetTimer->StartListening( KTimerInterval ); |
|
687 } |
|
688 } |
|
689 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleBuddyPresenceChangeL() end ") ); |
|
690 } |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // CServiceWidgetServiceManager::HandleOwnStatusChangeL |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 void CServiceWidgetServiceManager::HandleOwnStatusChangeL( TWSPresenceStatus /*aStatus*/ ) |
|
697 { |
|
698 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleOwnStatusChangeL() start ") ); |
|
699 UpdateContentsL(); |
|
700 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleOwnStatusChangeL() end ") ); |
|
701 } |
|
702 // --------------------------------------------------------------------------- |
|
703 // CServiceWidgetServiceManager::HandleServiceStatusChangedL |
|
704 // --------------------------------------------------------------------------- |
|
705 // |
|
706 void CServiceWidgetServiceManager::HandleServiceStatusChangedL( TSWSTRegistrationState aState ) |
|
707 { |
|
708 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleServiceStatusChangedL() start ") ); |
|
709 iServiceState = aState ; |
|
710 CreateHandlersL(); |
|
711 UpdateContentsL(); |
|
712 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleServiceStatusChangedL() end ") ); |
|
713 } |
|
714 |
|
715 // --------------------------------------------------------------------------- |
|
716 // CServiceWidgetServiceManager::HandleTimerExpiredL |
|
717 // --------------------------------------------------------------------------- |
|
718 // |
|
719 void CServiceWidgetServiceManager::HandleTimerExpiredL() |
|
720 { |
|
721 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleTimerExpiredL() start ") ); |
|
722 UpdateContentsL(); // once timer expired show the current data based on availabity |
|
723 TRACE_SWP(TXT("CServiceWidgetServiceManager::HandleTimerExpiredL() end ") ); |
|
724 } |
|
725 |
|
726 // --------------------------------------------------------------------------- |
|
727 // CServiceWidgetServiceManager::CreateHandlersL |
|
728 // --------------------------------------------------------------------------- |
|
729 // |
|
730 void CServiceWidgetServiceManager::CreateHandlersL() |
|
731 { |
|
732 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() start ") ); |
|
733 if( iServiceState == ESWSRegistered || iServiceState == ESWSUpdatingContacts ) |
|
734 { |
|
735 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() ECCHEnabled ") ); |
|
736 // once logged in create all interfaces |
|
737 // please note this is boot blugin so keep lesser memory use |
|
738 if( !iPresenceHandler && iCchHandler->IsSubServiceSupported( ECCHPresenceSub ) ) |
|
739 { |
|
740 TPtrC ownId = iCchHandler->OwnUserIdL(); |
|
741 TPtrC str = iServiceName->Des().Left(iServiceName->Des().Length()-KThemeUid().Length()); |
|
742 iPresenceHandler = CServiceWidgetPresenceHandler::NewL(*this,str,ownId ); |
|
743 iPresenceHandler->GetConnectedSessionL( iCchHandler->XimpAdaptationUidL(), iServiceId ); |
|
744 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() iPresenceHandler cretaed ") ); |
|
745 } |
|
746 if( !iMessageHandler && iCchHandler->IsSubServiceSupported( ECCHIMSub ) ) |
|
747 { |
|
748 TPtrC ownId = iCchHandler->OwnUserIdL(); |
|
749 iMessageHandler = CServiceWidgetMessageHandler::NewL( *this, iServiceId, ownId); |
|
750 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() iMessageHandler created ") ); |
|
751 } |
|
752 if( !iWidgetTimer && ( iPresenceHandler || iMessageHandler ) ) |
|
753 { |
|
754 // create the timer only if required |
|
755 iWidgetTimer = CServiceWidgetTimer::NewL(*this) ; |
|
756 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() iWidgetTimer created ") ); |
|
757 } |
|
758 } |
|
759 else if( iServiceState == ESWSNotRegistered ) |
|
760 { |
|
761 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() ECCHDisabled ") ); |
|
762 // once disconnecting off delete all interfaces |
|
763 if( iWidgetTimer ) |
|
764 { |
|
765 delete iWidgetTimer; |
|
766 iWidgetTimer = NULL; |
|
767 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() iWidgetTimer deleted ") ); |
|
768 } |
|
769 if(iMessageHandler ) |
|
770 { |
|
771 delete iMessageHandler; |
|
772 iMessageHandler = NULL; |
|
773 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() iMessageHandler deleted ") ); |
|
774 } |
|
775 if( iPresenceHandler) |
|
776 { |
|
777 iPresenceHandler->ReleaseConnectionL(); |
|
778 delete iPresenceHandler ; |
|
779 iPresenceHandler = NULL; |
|
780 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() iPresenceHandler deleted ") ); |
|
781 } |
|
782 } |
|
783 TRACE_SWP(TXT("CServiceWidgetServiceManager::CreateHandlersL() end ") ); |
|
784 } |
|
785 |
|
786 // --------------------------------------------------------------------------- |
|
787 // CServiceWidgetServiceManager::ServiceId |
|
788 // --------------------------------------------------------------------------- |
|
789 // |
|
790 TInt CServiceWidgetServiceManager::ServiceId() |
|
791 { |
|
792 TRACE_SWP(TXT("CServiceWidgetServiceManager::ServiceId() Manager") ); |
|
793 return iServiceId; |
|
794 } |
|
795 |
|
796 // --------------------------------------------------------------------------- |
|
797 // CServiceWidgetServiceManager::ServiceName |
|
798 // --------------------------------------------------------------------------- |
|
799 // |
|
800 const TDesC& CServiceWidgetServiceManager::ServiceName() |
|
801 { |
|
802 TRACE_SWP(TXT("CServiceWidgetServiceManager::ServiceName() Manager") ); |
|
803 return *iServiceName; |
|
804 } |
|
805 // --------------------------------------------------------------------------- |
|
806 // CServiceWidgetServiceManager::UnregisterWidgetL |
|
807 // --------------------------------------------------------------------------- |
|
808 // |
|
809 void CServiceWidgetServiceManager::UnregisterWidgetL() |
|
810 { |
|
811 TRACE_SWP(TXT("CServiceWidgetServiceManager::UnregisterWidgetL() Manager") ); |
|
812 |
|
813 iContentPublisher.UnregisterWidgetL(*iServiceName); |
|
814 } |
|
815 |
|
816 // --------------------------------------------------------------------------- |
|
817 // CServiceWidgetServiceManager::RegisterWidgetL |
|
818 // --------------------------------------------------------------------------- |
|
819 // |
|
820 void CServiceWidgetServiceManager::RegisterWidgetL() |
|
821 { |
|
822 TRACE_SWP(TXT("CServiceWidgetServiceManager::RegisterWidgetL() Manager") ); |
|
823 TInt bitmapHandle = 0 ; |
|
824 TInt maskHandle = 0 ; |
|
825 iBrandHandler->GetStatusBitmapL( EWSServiceIcon, bitmapHandle, maskHandle ) ; |
|
826 iContentPublisher.RegisterWidgetL(*iServiceName,bitmapHandle, maskHandle); |
|
827 } |
|
828 |
|
829 // --------------------------------------------------------------------------- |
|
830 // CServiceWidgetServiceManager::ExecuteActionL |
|
831 // --------------------------------------------------------------------------- |
|
832 // |
|
833 void CServiceWidgetServiceManager::ExecuteActionL() |
|
834 { |
|
835 TRACE_SWP(TXT("CServiceWidgetServiceManager::ExecuteActionL() Manager") ); |
|
836 switch( iExecuteOperation ) |
|
837 { |
|
838 case ESWALaunchServiceTab: |
|
839 { |
|
840 RxSPViewServices viewServices; |
|
841 TInt err = viewServices.Activate( iServiceTabUid, |
|
842 iServiceviewId ) ; |
|
843 TRACE_SWP(TXT("CServiceWidgetServiceManager::ExecuteActionL() Activate = %d"), err), |
|
844 User::LeaveIfError( err ); |
|
845 |
|
846 break; |
|
847 } |
|
848 case ESWALaunchConverView: |
|
849 { |
|
850 if( iMessageHandler && iEnv ) |
|
851 { |
|
852 TRACE_SWP(TXT("CServiceWidgetServiceManager::ExecuteActionL() launch cv") ); |
|
853 TVwsViewId activeViewId; |
|
854 CCoeAppUi* appui = iEnv->AppUi(); |
|
855 appui->GetActiveViewId( activeViewId ); |
|
856 IMCVLauncher::LaunchImConversationViewL(activeViewId, |
|
857 iServiceId, |
|
858 iMessageHandler->GetUnreadSenderId() ) ; |
|
859 } |
|
860 break; |
|
861 } |
|
862 case ESWALaunchSTAutoLogin : |
|
863 { |
|
864 /* |
|
865 * First pack version number followed by service id. |
|
866 * PhoneBook first read till EEnd and then it goes to service tab |
|
867 * get the custom info in this call CVIMPSTUiTabbedView::DoActivateViewL |
|
868 * aCustomMessageId is CPbk2ViewState::Uid() |
|
869 * In service tab (tabbedview) we need to unpack dataPtr in similar reverse pattern |
|
870 * |
|
871 */ |
|
872 HBufC8* data = HBufC8::NewLC( 20 ); |
|
873 TPtr8 dataPtr( data->Des() ); |
|
874 RDesWriteStream stream( dataPtr ); |
|
875 stream.PushL(); |
|
876 stream.WriteInt8L(1); // version number |
|
877 stream.WriteInt8L( 0 ); //EEnd |
|
878 stream.WriteInt32L( iServiceId ); //Service Id |
|
879 stream.CommitL(); |
|
880 |
|
881 RxSPViewServices viewServices; |
|
882 TInt err = viewServices.Activate( iServiceTabUid, |
|
883 iServiceviewId , dataPtr ); |
|
884 TRACE_SWP(TXT("CServiceWidgetServiceManager::ExecuteActionL() Activate = %d"), err), |
|
885 User::LeaveIfError( err ); |
|
886 CleanupStack::PopAndDestroy(); |
|
887 CleanupStack::PopAndDestroy( data );// data |
|
888 break; |
|
889 } |
|
890 case ESWAStartLogin: |
|
891 { |
|
892 iCchHandler->EnableServiceL(); |
|
893 break; |
|
894 } |
|
895 default : |
|
896 { |
|
897 // do nothing |
|
898 } |
|
899 } // end of switch |
|
900 |
|
901 }//End ExecuteActionL |
|
902 // End of File |