|
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 status icons handler |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "cservicewidgetbrandhandler.h" |
|
21 |
|
22 #include "servicewidgetcpglobals.h" |
|
23 #include "swpdebugtrace.h" |
|
24 // branding server |
|
25 #include <cbsfactory.h> |
|
26 #include <mbsaccess.h> |
|
27 #include <cbsbitmap.h> |
|
28 #include <fbs.h> |
|
29 //icons |
|
30 #include <gulicon.h> |
|
31 #include <bautils.h> |
|
32 #include <AknIconUtils.h> |
|
33 #include <spsettings.h> |
|
34 #include <spentry.h> |
|
35 #include <spproperty.h> |
|
36 |
|
37 #include "conversations.h" |
|
38 |
|
39 _LIT8(KAppIdForBrand,"xsp"); |
|
40 _LIT8(KDefaultBrandIdForBrand,"xsp"); |
|
41 |
|
42 // Taken as conversation.h gile doesn't have it. |
|
43 _LIT8( KEMbmConversationsQgnDefaultImage, "default_brand_image"); |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CServiceWidgetBrandHandler::CServiceWidgetBrandHandler |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CServiceWidgetBrandHandler::CServiceWidgetBrandHandler(TInt aServiceId ): |
|
50 iAppId(KAppIdForBrand), |
|
51 iServiceId( aServiceId ) |
|
52 { |
|
53 TRACE_SWP(TXT("CServiceWidgetBrandHandler::CServiceWidgetBrandHandler()") ); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CServiceWidgetBrandHandler::NewL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CServiceWidgetBrandHandler* CServiceWidgetBrandHandler::NewL(TInt aServiceId ) |
|
61 { |
|
62 TRACE_SWP(TXT("CServiceWidgetBrandHandler::NewL() start" ) ); |
|
63 CServiceWidgetBrandHandler* self = NewLC(aServiceId); |
|
64 CleanupStack::Pop(self); |
|
65 TRACE_SWP(TXT("CServiceWidgetBrandHandler::NewL() end" ) ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CServiceWidgetBrandHandler::NewLC |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CServiceWidgetBrandHandler* CServiceWidgetBrandHandler::NewLC(TInt aServiceId) |
|
74 { |
|
75 TRACE_SWP(TXT("CServiceWidgetBrandHandler::NewLC() start" ) ); |
|
76 CServiceWidgetBrandHandler* self = |
|
77 new (ELeave) CServiceWidgetBrandHandler(aServiceId); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 TRACE_SWP(TXT("CServiceWidgetBrandHandler::NewLC() end" ) ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CServiceWidgetBrandHandler::ConstructL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CServiceWidgetBrandHandler::ConstructL() |
|
89 { |
|
90 iBrandId = HBufC8::NewL( KSW_RESOURCE_MAX_LENGTH ); |
|
91 TPtr8 brandIdPtr( iBrandId->Des() ); |
|
92 TInt version = 1 ; // default |
|
93 |
|
94 iLanguageId = ELangInternationalEnglish; |
|
95 GetBrandInfoL(iLanguageId, version, brandIdPtr); |
|
96 |
|
97 iBrandingFactory = CBSFactory::NewL( KDefaultBrandIdForBrand, iAppId ); |
|
98 |
|
99 // Leaves if no brand for service, therefore trap |
|
100 PrepareBrandingAccess(); |
|
101 |
|
102 LoadBrandingBitmapsL(); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CServiceWidgetBrandHandler::GetBrandInfo |
|
107 // |
|
108 // --------------------------------------------------------- |
|
109 TInt CServiceWidgetBrandHandler::GetBrandInfoL(TLanguage& aBrandLanguage, |
|
110 TInt &aBrandVersion, TDes8& aBrandId) |
|
111 |
|
112 { |
|
113 CSPSettings* settings = CSPSettings::NewLC(); |
|
114 |
|
115 ////////////// brand id///////////////////// |
|
116 CSPProperty* property = CSPProperty::NewLC(); |
|
117 settings->FindPropertyL( iServiceId, |
|
118 EPropertyBrandId, |
|
119 *property ); |
|
120 if ( property ) |
|
121 { |
|
122 HBufC* brandId = HBufC::NewLC( 100 ); |
|
123 TPtr brandIdPtr( brandId->Des() ); |
|
124 property->GetValue( brandIdPtr ); |
|
125 aBrandId.Copy(brandIdPtr); |
|
126 CleanupStack::PopAndDestroy( brandId ); |
|
127 } |
|
128 CleanupStack::PopAndDestroy( property ); |
|
129 |
|
130 /////////// langauge ////////////////// |
|
131 TInt language = ELangInternationalEnglish; |
|
132 property = CSPProperty::NewLC(); |
|
133 settings->FindPropertyL( iServiceId, |
|
134 EPropertyBrandLanguage, |
|
135 *property ); |
|
136 if ( property ) |
|
137 { |
|
138 property->GetValue( language ); |
|
139 } |
|
140 CleanupStack::PopAndDestroy(property); |
|
141 aBrandLanguage = ( TLanguage) language; |
|
142 |
|
143 /////////// version //////////////// |
|
144 property = CSPProperty::NewLC(); |
|
145 settings->FindPropertyL( iServiceId, |
|
146 EPropertyBrandVersion, |
|
147 *property ); |
|
148 if ( property ) |
|
149 { |
|
150 property->GetValue( aBrandVersion ); |
|
151 } |
|
152 CleanupStack::PopAndDestroy( property ); |
|
153 ////////////////////////////////////// |
|
154 CleanupStack::PopAndDestroy( settings ); |
|
155 return KErrNone; |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CServiceWidgetBrandHandler::PrepareBrandingAccess() |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CServiceWidgetBrandHandler::PrepareBrandingAccess() |
|
163 { |
|
164 TRAPD(err, iBrandingAccess = iBrandingFactory->CreateAccessL( *iBrandId, iLanguageId )); |
|
165 return err; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CServiceWidgetBrandHandler::~CServiceWidgetBrandHandler |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 CServiceWidgetBrandHandler::~CServiceWidgetBrandHandler() |
|
173 { |
|
174 TRACE_SWP(TXT("CServiceWidgetBrandHandler::~CServiceWidgetBrandHandler() start" ) ); |
|
175 |
|
176 iBrandIcons.ResetAndDestroy(); |
|
177 if(iBrandingAccess) |
|
178 { |
|
179 iBrandingAccess->Close(); |
|
180 } |
|
181 delete iBrandingFactory; |
|
182 delete iBrandId; |
|
183 TRACE_SWP(TXT("CServiceWidgetBrandHandler::~CServiceWidgetBrandHandler() end" ) ); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CServiceWidgetBrandHandler::LoadBrandBitmapL |
|
188 // (other items were commented in a header). |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 |
|
192 void CServiceWidgetBrandHandler::LoadBrandingBitmapsL() |
|
193 { |
|
194 CGulIcon* gulIcon = NULL ; |
|
195 //Fetching bitmaps from the server. |
|
196 if(!iBrandingAccess) |
|
197 { |
|
198 PrepareBrandingAccess(); |
|
199 } |
|
200 |
|
201 // EWSonline has to be at 0th in enums |
|
202 for(TInt index = EWSOnline; index < EWSLast; index++ ) |
|
203 { |
|
204 gulIcon = LoadBitmapL(index) ; |
|
205 iBrandIcons.Append(gulIcon) ; |
|
206 } |
|
207 } |
|
208 |
|
209 CGulIcon* CServiceWidgetBrandHandler::LoadBitmapL(TInt aIndex) |
|
210 { |
|
211 CFbsBitmap* bitmap = NULL; |
|
212 CFbsBitmap* mask = NULL; |
|
213 CGulIcon* gulIcon = NULL ; |
|
214 |
|
215 switch(aIndex) |
|
216 { |
|
217 case EWSOnline: |
|
218 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendon, bitmap, mask); |
|
219 break; |
|
220 case EWSAway: |
|
221 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendaway, bitmap, mask); |
|
222 break; |
|
223 case EWSbusy: |
|
224 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendbusy, bitmap, mask); |
|
225 break; |
|
226 case EWSDoNotDisturb: |
|
227 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendbusy, bitmap, mask); |
|
228 break; |
|
229 case EWSOffline: |
|
230 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendoff, bitmap, mask); |
|
231 break; |
|
232 case EWSOnPhone: |
|
233 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendonmobile, bitmap, mask); |
|
234 break; |
|
235 case EWSBlocked: |
|
236 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimuserblocked, bitmap, mask); |
|
237 break; |
|
238 case EWSNewMessage: |
|
239 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimimsgnew, bitmap, mask); |
|
240 break; |
|
241 case EWSServiceIcon: |
|
242 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnDefaultImage, bitmap, mask); |
|
243 break; |
|
244 case EWSInvisible: // show offline icon for invisible state |
|
245 iBrandingAccess->GetBitmapL(KEMbmConversationsQgnpropimfriendoff, bitmap, mask); |
|
246 break; |
|
247 } |
|
248 |
|
249 if(bitmap && mask) |
|
250 { |
|
251 CleanupStack::PushL(bitmap); |
|
252 CleanupStack::PushL(mask); |
|
253 // to solve the handle zero issue |
|
254 TSize size ; |
|
255 AknIconUtils::GetContentDimensions(bitmap, size); |
|
256 if ( aIndex == EWSServiceIcon ) |
|
257 { |
|
258 size.iWidth = 200; |
|
259 size.iHeight = 200; |
|
260 } |
|
261 AknIconUtils::SetSize(bitmap, size); |
|
262 gulIcon = CGulIcon::NewL(bitmap, mask); |
|
263 gulIcon->SetBitmapsOwnedExternally(EFalse) ;// give ownership to gulicon |
|
264 CleanupStack::Pop(mask); |
|
265 CleanupStack::Pop(bitmap); |
|
266 } |
|
267 return gulIcon ; |
|
268 } |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CServiceWidgetBrandHandler::GetStatusBitmapPath |
|
271 // (other items were commented in a header). |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 void CServiceWidgetBrandHandler::GetStatusBitmapL(TWSPresenceStatus aIndex, TInt& aBitmapHandle, TInt& aMaskHandle) |
|
275 { |
|
276 CGulIcon *gulIcon = NULL ; |
|
277 |
|
278 if(aIndex < EWSOnline || aIndex >= EWSLast) |
|
279 return ; |
|
280 |
|
281 gulIcon = iBrandIcons[aIndex] ; |
|
282 if(gulIcon) |
|
283 { |
|
284 aBitmapHandle = gulIcon->Bitmap()->Handle(); |
|
285 aMaskHandle = gulIcon->Mask()->Handle(); |
|
286 } |
|
287 } |
|
288 // end of file |