|
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: Implementation of detailsview contact brand data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpstdetailsviewbrandhandler.h" |
|
21 |
|
22 #include "vimpstdetailsview.hrh" |
|
23 #include "vimpstui.h" |
|
24 #include "conversations.h" |
|
25 #include "tvimpstconsts.h" |
|
26 #include <vimpstui.mbg> |
|
27 #include <conversations.mbg> |
|
28 // branding server |
|
29 #include <cbsfactory.h> |
|
30 #include <mbsaccess.h> |
|
31 #include <mbselement.h> |
|
32 // system includes |
|
33 #include <AknIconUtils.h> |
|
34 // settings |
|
35 #include <spsettings.h> |
|
36 #include <spentry.h> |
|
37 #include <spproperty.h> |
|
38 |
|
39 #include <cch.h> |
|
40 |
|
41 |
|
42 #include "uiservicetabtracer.h" |
|
43 |
|
44 _LIT8(KAppIdForBrand,"xsp"); |
|
45 _LIT8(KDefaultBrandIdForBrand,"xsp"); |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 // --------------------------------------------------------------------------- |
|
49 // CVIMPSTDetailsViewBrandHandler::CVIMPSTDetailsViewBrandHandler() |
|
50 // --------------------------------------------------------------------------- |
|
51 // Two-phased constructor. |
|
52 CVIMPSTDetailsViewBrandHandler* CVIMPSTDetailsViewBrandHandler::NewL(TInt aServiceId ) |
|
53 { |
|
54 CVIMPSTDetailsViewBrandHandler* self = new (ELeave) CVIMPSTDetailsViewBrandHandler( aServiceId); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CVIMPSTDetailsViewBrandHandler::~CVIMPSTDetailsViewBrandHandler() |
|
63 // --------------------------------------------------------------------------- |
|
64 // Destructor |
|
65 CVIMPSTDetailsViewBrandHandler::~CVIMPSTDetailsViewBrandHandler() |
|
66 { |
|
67 if(iBrandingAccess) |
|
68 { |
|
69 iBrandingAccess->Close(); |
|
70 } |
|
71 delete iBrandingFactory; |
|
72 iBrandingFactory = NULL; |
|
73 delete iBrandId; |
|
74 delete iSettings; |
|
75 delete iServiceStoreUri; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CVIMPSTDetailsViewBrandHandler::CVIMPSTDetailsViewBrandHandler() |
|
80 // --------------------------------------------------------------------------- |
|
81 // C++ default constructor can NOT contain any code, that |
|
82 // might leave. |
|
83 // |
|
84 CVIMPSTDetailsViewBrandHandler::CVIMPSTDetailsViewBrandHandler(TInt aServiceId) : |
|
85 iAppId(KAppIdForBrand), |
|
86 iServiceId( aServiceId) |
|
87 { |
|
88 iBrandingAccess = NULL; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CVIMPSTDetailsViewBrandHandler::ConstructL() |
|
93 // --------------------------------------------------------------------------- |
|
94 // Symbian OS default constructor can leave. |
|
95 void CVIMPSTDetailsViewBrandHandler::ConstructL() |
|
96 { |
|
97 TRACER_AUTO; |
|
98 iBrandId = HBufC8::NewL( KVIMPSTUISPSMaxPropertyLength ); |
|
99 TPtr8 brandIdPtr( iBrandId->Des() ); |
|
100 |
|
101 TInt version = 1 ; // default |
|
102 |
|
103 iSettings = CSPSettings::NewL(); |
|
104 |
|
105 // ELangInternationalEnglish is selected as Default Brand Language Id. |
|
106 iLanguageId = ELangInternationalEnglish; |
|
107 |
|
108 GetBrandInfoL(iLanguageId, version, brandIdPtr); |
|
109 |
|
110 iBrandingFactory = CBSFactory::NewL( KDefaultBrandIdForBrand, iAppId ); |
|
111 |
|
112 |
|
113 //Get the default MBM path |
|
114 Dll::FileName(iDefaultMbmPath); //get the location of the dll |
|
115 |
|
116 TDriveName drive( TParsePtrC( iDefaultMbmPath ).Drive( ) ); // solve drive |
|
117 |
|
118 // leave to stack, LC method |
|
119 HBufC* resourceFilePath = HBufC::NewLC( KMaxResourcePathLength ); |
|
120 TPtr ptr( resourceFilePath->Des() ); |
|
121 ptr.Append( KDefaultIconFile() ); // without drive |
|
122 ptr.Insert( 0, drive ); // insert drive |
|
123 |
|
124 // NearestLanguageFile takes only TFileName |
|
125 iDefaultMbmPath.Zero(); |
|
126 iDefaultMbmPath.Append( *resourceFilePath ); |
|
127 |
|
128 CleanupStack::PopAndDestroy();//resourceFilePath |
|
129 |
|
130 // Leaves if no brand for service, therefore trap |
|
131 PrepareBrandingAccess(); |
|
132 |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CVIMPSTDetailsViewBrandHandler::PrepareBrandingAccess() |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 TInt CVIMPSTDetailsViewBrandHandler::PrepareBrandingAccess() |
|
140 { |
|
141 |
|
142 TRAPD(err, iBrandingAccess = iBrandingFactory->CreateAccessL( *iBrandId, iLanguageId )); |
|
143 |
|
144 return err; |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // CVIMPSTDetailsViewBrandHandler::LoadIconsLC |
|
150 // Loads necessary icons |
|
151 // (other items were commented in a header). |
|
152 // --------------------------------------------------------- |
|
153 // |
|
154 CAknIconArray* CVIMPSTDetailsViewBrandHandler::LoadIconsLC( ) |
|
155 { |
|
156 //Fetching bitmaps from the server. |
|
157 if( !iBrandingAccess ) |
|
158 { |
|
159 if( KErrNone != PrepareBrandingAccess() ) |
|
160 //brand was not found so load the default data |
|
161 { |
|
162 return LoadDefaultIconsLC(iDefaultMbmPath); |
|
163 } |
|
164 } |
|
165 //brand data is available |
|
166 return LoadBrandIconsLC(); |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CVIMPSTDetailsViewBrandHandler::LoadBitMapL |
|
171 // Loads necessary icons |
|
172 // (other items were commented in a header). |
|
173 // --------------------------------------------------------- |
|
174 // |
|
175 void CVIMPSTDetailsViewBrandHandler::LoadBitMapLC(CFbsBitmap*& aBitmap, |
|
176 CFbsBitmap*& aMask, |
|
177 TInt aBitmapId, |
|
178 TInt aMaskId ) |
|
179 { |
|
180 if( !iBrandingAccess ) |
|
181 { |
|
182 if( KErrNone != PrepareBrandingAccess() ) |
|
183 //brand was not found so load the default data |
|
184 { |
|
185 AknIconUtils::CreateIconLC( aBitmap,aMask, iDefaultMbmPath, aBitmapId, aMaskId ); |
|
186 return; |
|
187 } |
|
188 } |
|
189 //brand data is available |
|
190 CGulIcon* icon = NULL; |
|
191 icon = LoadBrandBitmapL( KEMbmConversationsQgnpropservicedefaultavatar ); |
|
192 aBitmap = icon->Bitmap(); |
|
193 aMask = icon->Mask(); |
|
194 // this is remove the memory leak |
|
195 icon->SetBitmapsOwnedExternally( ETrue ); |
|
196 delete icon ; |
|
197 CleanupStack::PushL( aBitmap ); |
|
198 CleanupStack::PushL( aMask ); |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------- |
|
202 // CVIMPSTDetailsViewBrandHandler::LoadBrandIconsLC |
|
203 // Loads necessary icons |
|
204 // (other items were commented in a header). |
|
205 // --------------------------------------------------------- |
|
206 // |
|
207 CAknIconArray* CVIMPSTDetailsViewBrandHandler::LoadBrandIconsLC( ) |
|
208 { |
|
209 // array granularity is 12, because 12 icons are added to array |
|
210 CAknIconArray* icons = new( ELeave )CAknIconArray( 12); |
|
211 CleanupStack::PushL( icons ); |
|
212 |
|
213 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendoff) );//0 |
|
214 |
|
215 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendon) );//1 |
|
216 |
|
217 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendaway ) );//2 |
|
218 |
|
219 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendbusy ) );//3 |
|
220 |
|
221 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendinvisible ) );//4 |
|
222 |
|
223 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimimsg ) );//5 |
|
224 |
|
225 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimimsgnew ) );//6 |
|
226 |
|
227 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropservicedefaultavatar ) );//7 |
|
228 |
|
229 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropservicefriendrequestreceived ) );//8 |
|
230 |
|
231 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropservicefriendrequestsent ) );//9 |
|
232 |
|
233 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropserviceofffriendrequestreceived ) );//10 |
|
234 |
|
235 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropserviceofffriendrequestsent ) );//11 |
|
236 |
|
237 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimuserblocked ) );//12 |
|
238 |
|
239 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendonmobile ) );//13 |
|
240 |
|
241 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimusercallforward ) );//14 |
|
242 |
|
243 return icons; |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CVIMPSTDetailsViewBrandHandler::LoadBrandBitmapL |
|
248 // (other items were commented in a header). |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 CGulIcon* CVIMPSTDetailsViewBrandHandler::LoadBrandBitmapL( const TDesC8& aId ) |
|
252 { |
|
253 |
|
254 CFbsBitmap* bitmap = NULL; |
|
255 CFbsBitmap* mask = NULL; |
|
256 |
|
257 //Fetching bitmaps from the server. |
|
258 if(!iBrandingAccess) |
|
259 { |
|
260 PrepareBrandingAccess(); |
|
261 } |
|
262 iBrandingAccess->GetBitmapL( aId, bitmap, mask ); |
|
263 CleanupStack::PushL( bitmap ); |
|
264 CleanupStack::PushL( mask ); |
|
265 // bitmap, mask ownership passed to gulIcon |
|
266 CGulIcon* icon = CGulIcon::NewL(bitmap, mask); |
|
267 icon->SetBitmapsOwnedExternally( EFalse ); |
|
268 CleanupStack::Pop(2); // bitmap, mask |
|
269 return icon; |
|
270 } |
|
271 |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // CVIMPSTDetailsViewBrandHandler::LoadDefaultIconsLC |
|
275 // Loads necessary icons |
|
276 // (other items were commented in a header). |
|
277 // --------------------------------------------------------- |
|
278 // |
|
279 CAknIconArray* CVIMPSTDetailsViewBrandHandler::LoadDefaultIconsLC( const TDesC& aMbmFile) |
|
280 { |
|
281 // array granularity is 5 |
|
282 CAknIconArray* icons = new( ELeave )CAknIconArray( 5); |
|
283 CleanupStack::PushL( icons ); |
|
284 |
|
285 icons->AppendL( LoadDefaultBitmapL( // 0 |
|
286 EMbmVimpstuiQgn_prop_im_friend_off, |
|
287 EMbmVimpstuiQgn_prop_im_friend_off_mask, |
|
288 aMbmFile ) ); |
|
289 icons->AppendL( LoadDefaultBitmapL( // 1 |
|
290 EMbmVimpstuiQgn_prop_im_friend_on, |
|
291 EMbmVimpstuiQgn_prop_im_friend_on_mask, |
|
292 aMbmFile ) ); |
|
293 |
|
294 icons->AppendL( LoadDefaultBitmapL( // 2 |
|
295 EMbmVimpstuiQgn_prop_im_friend_away, |
|
296 EMbmVimpstuiQgn_prop_im_friend_away_mask, |
|
297 aMbmFile ) ); |
|
298 icons->AppendL( LoadDefaultBitmapL( // 3 |
|
299 EMbmVimpstuiQgn_prop_im_friend_busy, |
|
300 EMbmVimpstuiQgn_prop_im_friend_busy_mask, |
|
301 aMbmFile ) ); |
|
302 icons->AppendL( LoadDefaultBitmapL( // 4 |
|
303 EMbmVimpstuiQgn_prop_im_friend_invisible, |
|
304 EMbmVimpstuiQgn_prop_im_friend_invisible_mask, |
|
305 aMbmFile ) ); |
|
306 icons->AppendL( LoadDefaultBitmapL( // 5 |
|
307 EMbmVimpstuiQgn_prop_im_imsg, |
|
308 EMbmVimpstuiQgn_prop_im_imsg_mask, |
|
309 aMbmFile ) ); |
|
310 icons->AppendL( LoadDefaultBitmapL( // 6 |
|
311 EMbmVimpstuiQgn_prop_im_imsg_new, |
|
312 EMbmVimpstuiQgn_prop_im_imsg_new_mask, |
|
313 aMbmFile ) ); |
|
314 icons->AppendL( LoadDefaultBitmapL( // 7 |
|
315 EMbmVimpstuiQgn_prop_service_default_avatar, |
|
316 EMbmVimpstuiQgn_prop_service_default_avatar_mask, |
|
317 aMbmFile ) ); |
|
318 icons->AppendL( LoadDefaultBitmapL( // 8 |
|
319 EMbmVimpstuiQgn_prop_service_friend_request_received, |
|
320 EMbmVimpstuiQgn_prop_service_friend_request_received_mask, |
|
321 aMbmFile ) ); |
|
322 icons->AppendL( LoadDefaultBitmapL( // 9 |
|
323 EMbmVimpstuiQgn_prop_service_friend_request_sent, |
|
324 EMbmVimpstuiQgn_prop_service_friend_request_sent_mask, |
|
325 aMbmFile ) ); |
|
326 icons->AppendL( LoadDefaultBitmapL( // 10 |
|
327 EMbmVimpstuiQgn_prop_service_off_friend_request_received, |
|
328 EMbmVimpstuiQgn_prop_service_off_friend_request_received_mask, |
|
329 aMbmFile ) ); |
|
330 icons->AppendL( LoadDefaultBitmapL( // 11 |
|
331 EMbmVimpstuiQgn_prop_service_off_friend_request_sent, |
|
332 EMbmVimpstuiQgn_prop_service_off_friend_request_sent_mask, |
|
333 aMbmFile ) ); |
|
334 icons->AppendL( LoadDefaultBitmapL( // 12 |
|
335 EMbmVimpstuiQgn_servtab_avatar_blocked, |
|
336 EMbmVimpstuiQgn_servtab_avatar_blocked_mask, |
|
337 aMbmFile ) ); //12 |
|
338 |
|
339 icons->AppendL( LoadDefaultBitmapL( // 13 |
|
340 EMbmVimpstuiQgn_prop_im_friend_on_mobile, |
|
341 EMbmVimpstuiQgn_prop_im_friend_on_mobile_mask, |
|
342 aMbmFile ) ); |
|
343 |
|
344 return icons; |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // CVIMPSTDetailsViewBrandHandler::LoadDefaultBitmapL |
|
349 // (other items were commented in a header). |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 CGulIcon* CVIMPSTDetailsViewBrandHandler::LoadDefaultBitmapL( TInt aBitmapId, TInt aMaskId, |
|
353 const TDesC& aFullPath ) |
|
354 { |
|
355 CFbsBitmap* bitmap = NULL; |
|
356 CFbsBitmap* mask = NULL; |
|
357 AknIconUtils::CreateIconLC( bitmap,mask, aFullPath,aBitmapId,aMaskId ); |
|
358 // bitmap, mask ownership passed to gulIcon |
|
359 CGulIcon* gulIcon = CGulIcon::NewL( bitmap, mask ); |
|
360 CleanupStack::Pop( 2 ); // bitmap, mask |
|
361 return gulIcon; |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CVIMPSTDetailsViewBrandHandler::PropertyBrandVersionL() |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 void CVIMPSTDetailsViewBrandHandler::PropertyReadBrandL( TUint32 aServiceId ,TInt &aBrand, TServicePropertyName aPropertyName ) |
|
369 { |
|
370 TRACER_AUTO; |
|
371 CSPProperty* property = CSPProperty::NewLC(); |
|
372 iSettings->FindPropertyL( aServiceId, |
|
373 aPropertyName, |
|
374 *property ); |
|
375 if ( property ) |
|
376 { |
|
377 property->GetValue( aBrand ); |
|
378 } |
|
379 CleanupStack::PopAndDestroy( property ); |
|
380 |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------- |
|
384 // CVIMPSTDetailsViewBrandHandler::GetBrandInfo |
|
385 // |
|
386 // --------------------------------------------------------- |
|
387 TInt CVIMPSTDetailsViewBrandHandler::GetBrandInfoL(TLanguage& aBrandLanguage, |
|
388 TInt &aBrandVersion, TDes8& aBrandId) |
|
389 |
|
390 { |
|
391 |
|
392 CSPProperty* property = CSPProperty::NewLC(); |
|
393 iSettings->FindPropertyL( iServiceId, |
|
394 EPropertyBrandId, |
|
395 *property ); |
|
396 if ( property ) |
|
397 { |
|
398 HBufC* brandId = HBufC::NewLC( KVIMPSTUISPSMaxPropertyLength ); |
|
399 TPtr brandIdPtr( brandId->Des() ); |
|
400 property->GetValue( brandIdPtr ); |
|
401 aBrandId.Copy(brandIdPtr); |
|
402 CleanupStack::PopAndDestroy( brandId ); |
|
403 } |
|
404 CleanupStack::PopAndDestroy( property ); |
|
405 |
|
406 TInt language = ELangInternationalEnglish; |
|
407 PropertyReadBrandL( iServiceId, language , EPropertyBrandLanguage ); |
|
408 aBrandLanguage = ( TLanguage) language; |
|
409 |
|
410 PropertyReadBrandL( iServiceId, aBrandVersion , EPropertyBrandVersion) ; |
|
411 |
|
412 return KErrNone; |
|
413 } |
|
414 |
|
415 // --------------------------------------------------------------------------- |
|
416 // CVIMPSTDetailsViewBrandHandler::GetServiceNameL() |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 void CVIMPSTDetailsViewBrandHandler::GetServiceNameL( TDes& aServiceName ) |
|
420 { |
|
421 TRACER_AUTO; |
|
422 CSPEntry* entry = CSPEntry::NewLC(); |
|
423 TRAPD( err, iSettings->FindEntryL( iServiceId, *entry ) ); |
|
424 if ( !err ) |
|
425 { |
|
426 aServiceName = entry->GetServiceName(); |
|
427 } |
|
428 CleanupStack::PopAndDestroy( entry ); |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------------------------- |
|
432 // CVIMPSTDetailsViewBrandHandler::ServiceStoreUriL() |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 const TDesC& CVIMPSTDetailsViewBrandHandler::ServiceStoreUriL() |
|
436 { |
|
437 TRACER_AUTO; |
|
438 if( !iServiceStoreUri ) |
|
439 { |
|
440 iServiceStoreUri = HBufC::NewL( KVIMPST_MAX_LENGTH ); |
|
441 TPtr serviceStorePtr( iServiceStoreUri->Des() ); |
|
442 |
|
443 CSPProperty* property = CSPProperty::NewLC(); |
|
444 iSettings->FindPropertyL( iServiceId, |
|
445 EPropertyContactStoreId, |
|
446 *property ); |
|
447 |
|
448 property->GetValue( serviceStorePtr ); |
|
449 CleanupStack::PopAndDestroy( property ); |
|
450 } |
|
451 return *iServiceStoreUri; |
|
452 } |
|
453 // --------------------------------------------------------------------------- |
|
454 // CVIMPSTDetailsViewBrandHandler::ServiceSupportedL( ) |
|
455 // --------------------------------------------------------------------------- |
|
456 // |
|
457 TBool CVIMPSTDetailsViewBrandHandler::ServiceSupportedL( ) |
|
458 { |
|
459 TRACER_AUTO; |
|
460 TBool ret = EFalse; |
|
461 CCch* cchClient = CCch::NewLC(); |
|
462 if (cchClient) |
|
463 { |
|
464 CCchService* service = cchClient->GetService( iServiceId ); |
|
465 TCchServiceStatus status; |
|
466 status.SetState(ECCHUninitialized); |
|
467 TInt err = service->GetStatus( TCCHSubserviceType(ECCHPresenceSub), status ); |
|
468 if (KErrNone == err) |
|
469 { |
|
470 ret = ETrue; |
|
471 } |
|
472 CleanupStack::PopAndDestroy(); // cchClient |
|
473 } |
|
474 return ret; |
|
475 } |
|
476 // End of File |