|
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: Brand handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpstuibranddata.h" |
|
21 #include "conversations.h" |
|
22 #include <AknIconArray.h> |
|
23 #include <cbsfactory.h> |
|
24 #include <mbsaccess.h> |
|
25 #include <mbselement.h> |
|
26 #include <cbsbitmap.h> |
|
27 #include "vimpstdebugprint.h" |
|
28 |
|
29 #include <AknIconUtils.h> |
|
30 #include <AknIconArray.h> |
|
31 #include <eikclbd.h> |
|
32 #include <bautils.h> |
|
33 |
|
34 #include <AknIconUtils.h> |
|
35 #include <AknsUtils.h> |
|
36 |
|
37 #include "mvimpstengine.h" |
|
38 #include "tvimpstconsts.h" |
|
39 #include <vimpstui.mbg> |
|
40 #include <conversations.mbg> |
|
41 #include <avkon.mbg> |
|
42 #include <StringLoader.h> |
|
43 |
|
44 |
|
45 //App Id is used by MeCo and ece to access branding icons and this name should be generic to both applications, so it needs to be changed later. |
|
46 _LIT8(KAppIdForBrand,"xsp"); |
|
47 _LIT8(KDefaultBrandIdForBrand,"xsp"); |
|
48 _LIT(KZDrive,"Z:\\resource\\"); |
|
49 _LIT(KCDrive,"C:\\resource\\"); |
|
50 _LIT(KTOU,"TOU.r"); |
|
51 _LIT(KUnderScore,"_"); |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 |
|
55 // Two-phased constructor. |
|
56 CVIMPSTUiBrandData* CVIMPSTUiBrandData::NewL(MVIMPSTEngine& aEngine) |
|
57 { |
|
58 CVIMPSTUiBrandData* self = new (ELeave) CVIMPSTUiBrandData; |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(aEngine); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // Destructor |
|
66 CVIMPSTUiBrandData::~CVIMPSTUiBrandData() |
|
67 { |
|
68 delete iIconsArray; |
|
69 if(iBrandingAccess) |
|
70 { |
|
71 iBrandingAccess->Close(); |
|
72 } |
|
73 |
|
74 delete iBrandingFactory; |
|
75 iBrandingFactory = NULL; |
|
76 |
|
77 delete iBrandId; |
|
78 } |
|
79 |
|
80 // C++ default constructor can NOT contain any code, that |
|
81 // might leave. |
|
82 // |
|
83 CVIMPSTUiBrandData::CVIMPSTUiBrandData() : |
|
84 iAppId(KAppIdForBrand) |
|
85 { |
|
86 } |
|
87 |
|
88 // Symbian OS default constructor can leave. |
|
89 void CVIMPSTUiBrandData::ConstructL(MVIMPSTEngine& aEngine) |
|
90 { |
|
91 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::ConstructL") ); |
|
92 |
|
93 iBrandId = HBufC8::NewL( 100 ); |
|
94 TPtr8 brandIdPtr( iBrandId->Des() ); |
|
95 |
|
96 TInt version; |
|
97 |
|
98 aEngine.GetBrandInfoL(iLanguageId, version, brandIdPtr); |
|
99 |
|
100 iBrandingFactory = CBSFactory::NewL( KDefaultBrandIdForBrand, iAppId ); |
|
101 |
|
102 |
|
103 //Get the default MBM path |
|
104 Dll::FileName(iDefaultMbmPath); //get the location of the dll |
|
105 |
|
106 TDriveName drive( TParsePtrC( iDefaultMbmPath ).Drive( ) ); // solve drive |
|
107 |
|
108 // leave to stack, LC method |
|
109 HBufC* resourceFilePath = HBufC::NewLC( KMaxResourcePathLength ); |
|
110 TPtr ptr( resourceFilePath->Des() ); |
|
111 ptr.Append( KDefaultIconFile() ); // without drive |
|
112 ptr.Insert( 0, drive ); // insert drive |
|
113 |
|
114 // NearestLanguageFile takes only TFileName |
|
115 iDefaultMbmPath.Zero(); |
|
116 iDefaultMbmPath.Append( *resourceFilePath ); |
|
117 |
|
118 CleanupStack::PopAndDestroy(); |
|
119 |
|
120 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::ConstructL, prepare branding access") ); |
|
121 // Leaves if no brand for service, therefore trap |
|
122 PrepareBrandingAccess(); |
|
123 |
|
124 |
|
125 LoadIconsL();// load the existing icons |
|
126 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::ConstructL out") ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CVIMPSTUiBrandData::PrepareBrandingAccess() |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 TInt CVIMPSTUiBrandData::PrepareBrandingAccess() |
|
134 { |
|
135 |
|
136 TRAPD(err, iBrandingAccess = iBrandingFactory->CreateAccessL( *iBrandId, iLanguageId )); |
|
137 |
|
138 return err; |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CVIMPSTUiBrandData::LoadIconsLC |
|
144 // Loads necessary icons |
|
145 // (other items were commented in a header). |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 CAknIconArray* CVIMPSTUiBrandData::LoadIconsLC( ) |
|
149 { |
|
150 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadIconsLC start") ); |
|
151 CAknIconArray* copyArray = new( ELeave )CAknIconArray( 4); |
|
152 CleanupStack::PushL( copyArray ); |
|
153 |
|
154 TInt count = iIconsArray->Count(); |
|
155 CGulIcon* newIcon = NULL; |
|
156 CGulIcon* icon = NULL; |
|
157 |
|
158 for( TInt i=0; i<count;i++) |
|
159 { |
|
160 icon = (*iIconsArray)[i]; |
|
161 // bitmap and mask are still valid in iIconsArray array |
|
162 // because of SetBitmapsOwnedExternally |
|
163 newIcon = CGulIcon::NewL( icon->Bitmap(),icon->Mask() ); |
|
164 newIcon->SetBitmapsOwnedExternally( ETrue ); |
|
165 copyArray->AppendL( newIcon ); // takes the ownership of newIcon |
|
166 } |
|
167 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadIconsLC end") ); |
|
168 return copyArray; // on cleanup stack |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------- |
|
172 // CVIMPSTUiBrandData::LoadIconsL |
|
173 // Loads necessary icons |
|
174 // (other items were commented in a header). |
|
175 // --------------------------------------------------------- |
|
176 // |
|
177 CAknIconArray* CVIMPSTUiBrandData::LoadIconsL() |
|
178 { |
|
179 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadIconsLC") ); |
|
180 //brand data is available |
|
181 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadIconsLC - do load") ); |
|
182 return LoadBrandIconsL(); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // CVIMPSTUiBrandData::LoadBrandIconsLC |
|
187 // Loads necessary icons |
|
188 // (other items were commented in a header). |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 CAknIconArray* CVIMPSTUiBrandData::LoadBrandIconsL( ) |
|
192 { |
|
193 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandIconsLC - IN") ); |
|
194 delete iIconsArray; |
|
195 iIconsArray = NULL; |
|
196 |
|
197 iIconsArray = new( ELeave )CAknIconArray( 4); |
|
198 // array granularity is 3, because 3 icons are added to array |
|
199 |
|
200 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimfriendoff") ); |
|
201 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendoff) );//0 |
|
202 |
|
203 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimfriendon") ); |
|
204 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendon) );//1 |
|
205 |
|
206 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimfriendaway") ); |
|
207 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendaway ) );//2 |
|
208 |
|
209 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimfriendbusy") ); |
|
210 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendbusy ) );//3 |
|
211 |
|
212 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimfriendinvisible") ); |
|
213 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendinvisible ) );//4 |
|
214 |
|
215 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimimsg") ); |
|
216 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimimsg ) );//5 |
|
217 |
|
218 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimimsgnew") ); |
|
219 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimimsgnew ) );//6 |
|
220 |
|
221 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropservicedefaultavatar") ); |
|
222 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropservicedefaultavatar ) );//7 |
|
223 |
|
224 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropservicefriendrequestreceived") ); |
|
225 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropservicefriendrequestreceived ) );//8 |
|
226 |
|
227 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropservicefriendrequestsent") ); |
|
228 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropservicefriendrequestsent ) );//9 |
|
229 |
|
230 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropserviceofffriendrequestreceived") ); |
|
231 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropserviceofffriendrequestreceived ) );//10 |
|
232 |
|
233 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropserviceofffriendrequestsent") ); |
|
234 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropserviceofffriendrequestsent ) );//11 |
|
235 |
|
236 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnpropimfriendonmobile") ); |
|
237 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendonmobile ) );//12 |
|
238 |
|
239 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnservtabavatarblocked") ); |
|
240 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimuserblocked ) );//13 |
|
241 |
|
242 CHAT_DP( D_CHAT_LIT(" -> KEMbmConversationsQgnservtabavatarblocked") ); |
|
243 iIconsArray->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimusercallforward ) );//14 |
|
244 |
|
245 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandIconsLC - OUT") ); |
|
246 return iIconsArray; |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CVIMPSTUiBrandData::LoadBrandBitmapL |
|
251 // (other items were commented in a header). |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 CGulIcon* CVIMPSTUiBrandData::LoadBrandBitmapL( const TDesC8& aId ) |
|
255 { |
|
256 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandBitmapL - IN") ); |
|
257 |
|
258 CFbsBitmap* bitmap = NULL; |
|
259 CFbsBitmap* mask = NULL; |
|
260 |
|
261 //EASY WAY TO DO THINGS.. :) |
|
262 //Fetching bitmaps from the server. |
|
263 if(!iBrandingAccess) |
|
264 { |
|
265 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandBitmapL - create access") ); |
|
266 PrepareBrandingAccess(); |
|
267 } |
|
268 TRAPD(err_bitmap, iBrandingAccess->GetBitmapL( aId, bitmap, mask )); |
|
269 if(KErrNone != err_bitmap) |
|
270 { |
|
271 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandBitmapL - err") ); |
|
272 User::Leave( err_bitmap ); |
|
273 } |
|
274 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandBitmapL - create icon") ); |
|
275 CGulIcon* icon = CGulIcon::NewL(bitmap, mask); |
|
276 icon->SetBitmapsOwnedExternally( EFalse ); |
|
277 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadBrandBitmapL - return icon") ); |
|
278 return icon; |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CVIMPSTUiBrandData::LoadDefaultBitmapL |
|
283 // (other items were commented in a header). |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 CGulIcon* CVIMPSTUiBrandData::LoadDefaultBitmapL( TInt aBitmapId, TInt aMaskId, |
|
287 const TDesC& aFullPath ) |
|
288 { |
|
289 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::LoadDefaultBitmapL IN") ); |
|
290 |
|
291 CFbsBitmap* bitmap = NULL; |
|
292 CFbsBitmap* mask = NULL; |
|
293 AknIconUtils::CreateIconLC( bitmap,mask, aFullPath,aBitmapId,aMaskId ); |
|
294 CGulIcon* gulIcon = CGulIcon::NewL( bitmap, mask ); |
|
295 CleanupStack::Pop( 2 ); // bitmap, mask |
|
296 return gulIcon; |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------- |
|
300 // CVIMPSTUiBrandData::LoadOwnStatusIconsLC |
|
301 // Loads necessary icons |
|
302 // (other items were commented in a header). |
|
303 // --------------------------------------------------------- |
|
304 // |
|
305 CAknIconArray* CVIMPSTUiBrandData::LoadOwnStatusIconsLC( ) |
|
306 { |
|
307 //EASY WAY TO DO THINGS.. :) |
|
308 //Fetching bitmaps from the server. |
|
309 if(!iBrandingAccess) |
|
310 { |
|
311 if (KErrNone != PrepareBrandingAccess()) |
|
312 //brand was not found so load the default data |
|
313 { |
|
314 return LoadDefaultOwnStatusIconsLC(iDefaultMbmPath); |
|
315 } |
|
316 } |
|
317 //brand data is available |
|
318 return LoadBrandOwnStatusIconsLC(); |
|
319 } |
|
320 // --------------------------------------------------------- |
|
321 // CVIMPSTUiBrandData::LoadBrandOwnStatusIconsLC |
|
322 // Loads necessary icons |
|
323 // (other items were commented in a header). |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 CAknIconArray* CVIMPSTUiBrandData::LoadBrandOwnStatusIconsLC( ) |
|
327 { |
|
328 // array granularity is 3, because 3 icons are added to array |
|
329 CAknIconArray* icons = new( ELeave )CAknIconArray( 5); |
|
330 CleanupStack::PushL( icons ); |
|
331 |
|
332 // online |
|
333 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendon) );//0 |
|
334 |
|
335 //away |
|
336 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendaway) );//1 |
|
337 |
|
338 //busy |
|
339 icons->AppendL( LoadBrandBitmapL( KEMbmConversationsQgnpropimfriendbusy) );//2 |
|
340 |
|
341 //invisible |
|
342 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendinvisible) );//3 |
|
343 |
|
344 //invisible |
|
345 icons->AppendL( LoadBrandBitmapL(KEMbmConversationsQgnpropimfriendoff) );//4 |
|
346 |
|
347 return icons; |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------- |
|
351 // CVIMPSTUiBrandData::LoadDefaultOwnStatusIconsLC |
|
352 // Loads necessary icons |
|
353 // (other items were commented in a header). |
|
354 // --------------------------------------------------------- |
|
355 // |
|
356 CAknIconArray* CVIMPSTUiBrandData::LoadDefaultOwnStatusIconsLC( const TDesC& aMbmFile) |
|
357 { |
|
358 // array granularity is 4, because 4 icons are added to array |
|
359 CAknIconArray* icons = new( ELeave )CAknIconArray( 5); |
|
360 CleanupStack::PushL( icons ); |
|
361 |
|
362 |
|
363 icons->AppendL( LoadDefaultBitmapL( // 0 |
|
364 EMbmVimpstuiQgn_prop_im_friend_on, |
|
365 EMbmVimpstuiQgn_prop_im_friend_on_mask, |
|
366 aMbmFile ) ); |
|
367 icons->AppendL( LoadDefaultBitmapL( // 1 |
|
368 EMbmVimpstuiQgn_prop_im_friend_away, |
|
369 EMbmVimpstuiQgn_prop_im_friend_away_mask, |
|
370 aMbmFile ) ); |
|
371 icons->AppendL( LoadDefaultBitmapL( // 2 |
|
372 EMbmVimpstuiQgn_prop_im_friend_busy, |
|
373 EMbmVimpstuiQgn_prop_im_friend_busy_mask, |
|
374 aMbmFile ) ); |
|
375 icons->AppendL( LoadDefaultBitmapL( // 3 |
|
376 EMbmVimpstuiQgn_prop_im_friend_invisible, |
|
377 EMbmVimpstuiQgn_prop_im_friend_invisible_mask, |
|
378 aMbmFile ) ); |
|
379 icons->AppendL( LoadDefaultBitmapL( // 4 |
|
380 EMbmVimpstuiQgn_prop_im_friend_off, |
|
381 EMbmVimpstuiQgn_prop_im_friend_off_mask, |
|
382 aMbmFile ) ); |
|
383 return icons; |
|
384 } |
|
385 // --------------------------------------------------------- |
|
386 // CVIMPSTUiBrandData::GetTitlePaneBrandBitmapL |
|
387 // (other items were commented in a header). |
|
388 // --------------------------------------------------------- |
|
389 // |
|
390 |
|
391 TInt CVIMPSTUiBrandData::GetBrandBitmapsL( CFbsBitmap **aBitmap, CFbsBitmap **aMask) |
|
392 { |
|
393 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::GetBrandBitmapsL") ); |
|
394 TInt error =KErrNone; |
|
395 if ( !iBrandingAccess && KErrNone != PrepareBrandingAccess()) |
|
396 { |
|
397 //load default icon |
|
398 AknIconUtils::CreateIconLC( *aBitmap, *aMask, |
|
399 iDefaultMbmPath, EMbmVimpstuiQgn_prop_im_friend_off, |
|
400 EMbmVimpstuiQgn_prop_im_friend_off_mask ); |
|
401 CleanupStack::Pop(2);//aBitmap,aMask. |
|
402 } |
|
403 else |
|
404 { |
|
405 TRAP(error, iBrandingAccess->GetBitmapL( KEMbmConversationsQgnpropimfriendon, *aBitmap, *aMask )); |
|
406 } |
|
407 CHAT_DP( D_CHAT_LIT("CVIMPSTUiBrandData::GetBrandBitmapsL returns: %d"), error ); |
|
408 return error; |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------- |
|
412 // --------------------------------------------------------- |
|
413 // CVIMPSTUiBrandData::GetToUBrandedStringL |
|
414 // (other items were commented in a header). |
|
415 // --------------------------------------------------------- |
|
416 // |
|
417 HBufC* CVIMPSTUiBrandData::GetToUBrandedStringL() |
|
418 { |
|
419 HBufC* prompt= NULL; |
|
420 if(iBrandingAccess || KErrNone == PrepareBrandingAccess()) |
|
421 { |
|
422 TRAP_IGNORE(prompt = iBrandingAccess->GetTextL( KToumessage )); |
|
423 } |
|
424 return prompt; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------- |
|
428 // CVIMPSTUiBrandData::IsBrandingSupported |
|
429 // (other items were commented in a header). |
|
430 // --------------------------------------------------------- |
|
431 // |
|
432 TBool CVIMPSTUiBrandData::IsBrandingSupported() |
|
433 { |
|
434 TBool ret = EFalse; |
|
435 if(iBrandingAccess) |
|
436 { |
|
437 ret = ETrue; |
|
438 } |
|
439 return ret; |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CVIMPSTUiBrandData::GetToUStringL() |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 HBufC* CVIMPSTUiBrandData::GetToUStringL() |
|
447 { |
|
448 HBufC* TouDes = NULL; |
|
449 const TInt KLangBufLength = 2; |
|
450 const TInt KLeadingZero = 0; |
|
451 TBuf<KLangBufLength> langBuf; |
|
452 |
|
453 // To get two or more digit language id. |
|
454 if( iLanguageId < 10 ) |
|
455 { |
|
456 langBuf.AppendNum( KLeadingZero ); |
|
457 } |
|
458 langBuf.AppendNum( iLanguageId ); |
|
459 |
|
460 // Number 2 is used in the below equation because |
|
461 // it is multiplied with the length of the underscore |
|
462 // to calculate the over all length of the string. |
|
463 TInt length = KCDrive().Length() + iAppId.Length() + iBrandId->Length() |
|
464 + KTOU().Length() + langBuf.Length() + 2 * KUnderScore().Length(); |
|
465 |
|
466 HBufC* fileName = HBufC::NewLC( length ); |
|
467 TPtr brandFileName( fileName->Des() ); |
|
468 |
|
469 // Converting the HBufC8 iAppId to HBufC appId |
|
470 HBufC* appId = HBufC::NewL( iAppId.Length() ); |
|
471 appId->Des().Copy( iAppId ); |
|
472 |
|
473 // Converting the HBufC8 iBrandId to HBufC brandId |
|
474 HBufC* brandId = HBufC::NewL( iBrandId->Length() ); |
|
475 brandId->Des().Copy( *iBrandId ); |
|
476 |
|
477 //Formation of filename. |
|
478 brandFileName.Append( *appId ); |
|
479 brandFileName.Append( KUnderScore ); |
|
480 brandFileName.Append( *brandId ); |
|
481 brandFileName.Append( KUnderScore ); |
|
482 brandFileName.Append( KTOU ); |
|
483 brandFileName.Append( langBuf ); |
|
484 |
|
485 TFileName temp(KCDrive); |
|
486 |
|
487 HBufC* targetFile = ConcatLC( temp, brandFileName ); |
|
488 |
|
489 // for getting the access to the file. |
|
490 RFs fsSession; |
|
491 RFile file; |
|
492 User::LeaveIfError(fsSession.Connect()); |
|
493 |
|
494 TFileName fullPtr( targetFile->Des() ); |
|
495 BaflUtils::NearestLanguageFile( fsSession, fullPtr ); |
|
496 TInt err = file.Open(fsSession, fullPtr, EFileRead); |
|
497 CleanupStack::PopAndDestroy(); // targetFile |
|
498 |
|
499 if( KErrNone != err ) |
|
500 { |
|
501 temp = KZDrive; |
|
502 targetFile = ConcatLC( temp, brandFileName ); |
|
503 //brandFileName = targetFile->Des(); |
|
504 fullPtr = targetFile->Des(); |
|
505 BaflUtils::NearestLanguageFile( fsSession, fullPtr ); |
|
506 err = file.Open(fsSession, fullPtr, EFileRead); |
|
507 CleanupStack::PopAndDestroy(); // targetFile |
|
508 } |
|
509 |
|
510 // Calculates the size of the file. |
|
511 if( !err ) |
|
512 { |
|
513 err = file.Size( length ); |
|
514 } |
|
515 |
|
516 if( ! err ) |
|
517 { |
|
518 HBufC8* readBuf = HBufC8::NewL( length ); |
|
519 TPtr8 readBufPtr = readBuf->Des(); |
|
520 file.Read( readBufPtr ); |
|
521 TouDes = HBufC::NewL( readBuf->Length() ); |
|
522 TouDes->Des().Copy( *readBuf ); |
|
523 delete readBuf; |
|
524 } |
|
525 file.Close(); |
|
526 fsSession.Close(); |
|
527 CleanupStack::PopAndDestroy(); // fileName |
|
528 delete appId; |
|
529 delete brandId; |
|
530 return TouDes; |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CVIMPSTUiBrandData::GetToUStringL() |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 HBufC* CVIMPSTUiBrandData::ConcatLC( TDesC& aDesc1, TDesC& aDesc2 ) |
|
538 { |
|
539 HBufC* resultDesc = HBufC::NewLC( aDesc1.Length() + aDesc2.Length() ); |
|
540 resultDesc->Des().Append( aDesc1 ); |
|
541 resultDesc->Des().Append( aDesc2 ); |
|
542 return resultDesc; |
|
543 } |
|
544 |
|
545 // End of File |