187 // only if the actual icons exist. |
192 // only if the actual icons exist. |
188 __ASSERT_DEBUG( iconInfo->Bitmap() && iconInfo->BitmapMask(), |
193 __ASSERT_DEBUG( iconInfo->Bitmap() && iconInfo->BitmapMask(), |
189 Panic( ENlxPanicNoIcons ) ); |
194 Panic( ENlxPanicNoIcons ) ); |
190 __ASSERT_ALWAYS( iconInfo->Bitmap() && iconInfo->BitmapMask(), |
195 __ASSERT_ALWAYS( iconInfo->Bitmap() && iconInfo->BitmapMask(), |
191 User::Leave( KErrGeneral ) ); |
196 User::Leave( KErrGeneral ) ); |
192 CFbsBitmap* newBitmap = CloneBitmapL( *iconInfo->Bitmap() ); |
197 |
193 CFbsBitmap* newBitmapMask = CloneBitmapL( *iconInfo->BitmapMask() ); |
198 CFbsBitmap* newBitmap = NULL; |
|
199 CFbsBitmap* newBitmapMask = NULL; |
|
200 |
|
201 TLanguage brandingLang = FindBrandLanguageIdL(iconInfo->BrandId()); |
|
202 |
|
203 TLanguage userLang = User::Language(); |
|
204 TLanguage defaultLang = ELangInternationalEnglish; |
|
205 CBSFactory* brandingFactory = CBSFactory::NewL(KCPBrandDefaultId, KCPBrandAppId ); |
|
206 CleanupStack::PushL( brandingFactory ); |
|
207 |
|
208 //// |
|
209 //Search for BrandPackage using PhoneLanguage |
|
210 //PhoneLanguage gets the Highest Priority |
|
211 TRAPD( err, GetBitmapFromBrandingServerL( userLang, newBitmap, newBitmapMask, *brandingFactory, iconInfo->BrandId(), iconInfo->ElementId() ) ); |
|
212 |
|
213 if ( err && ( userLang != brandingLang ) ) |
|
214 { |
|
215 //The next priority goes to BrandLanguage set in the SpSettings/service table |
|
216 //during provisioning |
|
217 //Search for BrandPackage using this BrandLanguage |
|
218 TRAP( err, GetBitmapFromBrandingServerL( brandingLang, newBitmap, newBitmapMask, *brandingFactory, iconInfo->BrandId(), iconInfo->ElementId())); |
|
219 } |
|
220 |
|
221 if ( err && ( brandingLang != defaultLang ) && ( userLang != defaultLang ) ) |
|
222 { |
|
223 //The least priority goes to the default language which is ELangInternationalEnglish |
|
224 //Search for BrandPackage using this ELangInternationalEnglish |
|
225 GetBitmapFromBrandingServerL( defaultLang, newBitmap, newBitmapMask, *brandingFactory, iconInfo->BrandId(), iconInfo->ElementId() ) ; |
|
226 } |
|
227 //// |
|
228 CleanupStack::PopAndDestroy( brandingFactory ); |
194 CGulIcon* gulIcon = CGulIcon::NewL( newBitmap, newBitmapMask ); |
229 CGulIcon* gulIcon = CGulIcon::NewL( newBitmap, newBitmapMask ); |
195 CleanupStack::PushL( gulIcon ); |
230 CleanupStack::PushL( gulIcon ); |
196 return gulIcon; |
231 return gulIcon; |
197 } |
232 } |
198 |
233 |
|
234 void CPbk2EcePresenceEngine::GetBitmapFromBrandingServerL( |
|
235 TLanguage aLanguageId, |
|
236 CFbsBitmap*& aBrandedBitmap, |
|
237 CFbsBitmap*& aBrandedMask, |
|
238 CBSFactory& aBSFactory, |
|
239 const TDesC8& aBrandId, |
|
240 const TDesC8& aElementId) |
|
241 { |
|
242 MBSAccess* brandingAccess = aBSFactory.CreateAccessLC( |
|
243 aBrandId, aLanguageId ); |
|
244 |
|
245 if ( aBrandId.Length() ) |
|
246 { |
|
247 brandingAccess->GetBitmapL( aElementId, aBrandedBitmap, aBrandedMask ); |
|
248 } |
|
249 |
|
250 CleanupStack::PopAndDestroy(); //access |
|
251 } |
|
252 |
|
253 |
|
254 TLanguage CPbk2EcePresenceEngine::FindBrandLanguageIdL( const TDesC8& aBrandId ) |
|
255 { |
|
256 const TInt KMaxBufLength = 512; |
|
257 CSPSettings* spSettings = CSPSettings::NewLC(); |
|
258 RIdArray idArray; |
|
259 CleanupClosePushL(idArray); |
|
260 User::LeaveIfError(spSettings->FindServiceIdsL(idArray)); |
|
261 CSPProperty* prop = CSPProperty::NewLC(); |
|
262 HBufC* brandID = HBufC::NewLC(KMaxBufLength); |
|
263 TLanguage servLang = ELangInternationalEnglish; |
|
264 TInt serviceCount = idArray.Count(); |
|
265 |
|
266 //The challenge here is to find the ServiceTable entry using BrandId. |
|
267 //Iterate thro each service id and find the BrandId |
|
268 //for each service and check whether it matches to out Input BrandId. |
|
269 //if it matches we have found the service, and now |
|
270 //get the brandlanguage. |
|
271 //Note : The problem with this logic is that it works only |
|
272 // if all the services brandid is unique. |
|
273 // If not GOD needs to help us. |
|
274 // This logic is a temporary one untill |
|
275 // one of our CR for Changing the Interface, so that you |
|
276 // get the BrandLanguage as part of the StartGetIconInfoL |
|
277 // is approved. |
|
278 // |
|
279 for (TInt index=0; index<serviceCount; index++) |
|
280 { |
|
281 if ( KErrNone == spSettings->FindPropertyL( idArray[index], EPropertyBrandId, *prop ) ) |
|
282 { |
|
283 TPtr des = brandID->Des(); |
|
284 if ( KErrNone == prop->GetValue( des ) ) |
|
285 { |
|
286 TBuf8 <KMaxBufLength> brandIdFromSpSettings; |
|
287 brandIdFromSpSettings.Copy(des); |
|
288 if ( KErrNone == brandIdFromSpSettings.Compare( aBrandId ) ) |
|
289 { |
|
290 if( KErrNone == spSettings->FindPropertyL( |
|
291 idArray[index], EPropertyBrandLanguage, *prop) ) |
|
292 { |
|
293 prop->GetValue( ( TInt& )servLang ); |
|
294 } |
|
295 break; |
|
296 } |
|
297 } |
|
298 } |
|
299 } |
|
300 |
|
301 CleanupStack::PopAndDestroy( 4 ); //brandID, prop, idArray, spSettings |
|
302 |
|
303 return servLang; |
|
304 } |
199 |
305 |
200 void CPbk2EcePresenceEngine::ReceiveIconInfoL( |
306 void CPbk2EcePresenceEngine::ReceiveIconInfoL( |
201 const TDesC8& aPackedLink, const TDesC8& aBrandId, const TDesC8& aElementId ) |
307 const TDesC8& aPackedLink, const TDesC8& aBrandId, const TDesC8& aElementId ) |
202 { |
308 { |
203 __ASSERT_DEBUG( aPackedLink.Length() > 0, Panic( ENlxPanicEmptyPackage) ); |
309 __ASSERT_DEBUG( aPackedLink.Length() > 0, Panic( ENlxPanicEmptyPackage) ); |