1 /* |
|
2 * Copyright (c) 2007 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 CVmBSHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <mbsaccess.h> |
|
20 #include <cbsfactory.h> |
|
21 #include <mbselement.h> |
|
22 #include <cbsbitmap.h> |
|
23 #include <coemain.h> |
|
24 #include <AknsItemID.h> |
|
25 #include <AknsSkinInstance.h> |
|
26 #include <AknsUtils.h> |
|
27 |
|
28 #include "vmsettingsuiiconfileprovider.h" |
|
29 #include "vmbshandler.h" |
|
30 #include "vmblogger.h" |
|
31 |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 // None |
|
34 |
|
35 // EXTERNAL FUNCTION PROTOTYPES |
|
36 // None |
|
37 |
|
38 // CONSTANTS |
|
39 // Branding server & data constants. |
|
40 const TInt KVmSettingsUiBrandingIconSize = 21; // icon size |
|
41 |
|
42 _LIT8( KVmSettingsUiBSApplicationId, "xsp" ); // application id |
|
43 _LIT8( KVmSettingsUiBSIconId, "service_active_image_small" ); // icon id |
|
44 |
|
45 // MACROS |
|
46 // None |
|
47 |
|
48 // LOCAL CONSTANTS AND MACROS |
|
49 // None |
|
50 |
|
51 // MODULE DATA STRUCTURES |
|
52 // None |
|
53 |
|
54 // LOCAL FUNCTION PROTOTYPES |
|
55 // None |
|
56 |
|
57 // FORWARD DECLARATIONS |
|
58 // None |
|
59 |
|
60 // ============================= LOCAL FUNCTIONS ============================= |
|
61 |
|
62 // ============================ MEMBER FUNCTIONS ============================= |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CVmBSHandler::CVmBSHandler |
|
66 // C++ default constructor can NOT contain any code, that might leave. |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CVmBSHandler::CVmBSHandler() |
|
70 { |
|
71 // No implementation required |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CVmBSHandler::ConstructL |
|
76 // Symbian 2nd phase constructor can leave. |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CVmBSHandler::ConstructL() |
|
80 { |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CVmBSHandler::NewL |
|
85 // Two-phased constructor. |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 CVmBSHandler* CVmBSHandler::NewL( ) |
|
89 { |
|
90 CVmBSHandler* self = CVmBSHandler::NewLC(); |
|
91 CleanupStack::Pop( self ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CVmBSHandler::NewLC |
|
97 // Two-phased constructor. |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CVmBSHandler* CVmBSHandler::NewLC() |
|
101 { |
|
102 CVmBSHandler* self = new (ELeave) CVmBSHandler(); |
|
103 CleanupStack::PushL( self ); |
|
104 self->ConstructL(); |
|
105 return self; |
|
106 } |
|
107 |
|
108 // Destructor |
|
109 CVmBSHandler::~CVmBSHandler() |
|
110 { |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CVmBSHandler::GetBrandedIconL |
|
115 // (other items were commented in a header). |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CVmBSHandler::GetBrandedIconL( |
|
119 const TDesC8& aBrandingId, |
|
120 CFbsBitmap*& aBrandedBitmap, |
|
121 CFbsBitmap*& aBrandedBitmapMask ) const |
|
122 { |
|
123 VMBLOGSTRING( "VMBX: CVmBSHandler::CreateBrandedBitmapL: =>" ); |
|
124 |
|
125 // Create branding server factory and access to branding data. |
|
126 CBSFactory* factory = CBSFactory::NewL( |
|
127 aBrandingId, KVmSettingsUiBSApplicationId ); |
|
128 CleanupStack::PushL( factory ); |
|
129 |
|
130 MBSAccess* access = factory->CreateAccessL( |
|
131 aBrandingId, ELangInternationalEnglish ); |
|
132 CleanupClosePushL( *access ); |
|
133 |
|
134 // Get structure which contains bitmap information. |
|
135 MBSElement* element = access->GetStructureL( KVmSettingsUiBSIconId ); |
|
136 CleanupClosePushL( *element ); |
|
137 const CBSBitmap& bitmap = element->BitmapDataL(); |
|
138 |
|
139 // Open file which contains branded bitmaps. |
|
140 RFile file; |
|
141 CleanupClosePushL( file ); |
|
142 access->GetFileL( bitmap.BitmapFileId(), file ); |
|
143 |
|
144 // Try to load a skinned bitmap. |
|
145 if ( CCoeEnv::Static() ) |
|
146 { |
|
147 TAknsItemID itemId; |
|
148 itemId.Set( bitmap.SkinIdMajor(), bitmap.SkinIdMinor() ); |
|
149 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
150 TRAP_IGNORE( ( aBrandedBitmap = |
|
151 AknsUtils::CreateBitmapL( skin, itemId ) ) ); |
|
152 } |
|
153 |
|
154 // If skinned bitmaps was not found, try to load bitmaps manually. |
|
155 if ( !aBrandedBitmap ) |
|
156 { |
|
157 CVmSettingsUiIconFileProvider* ifp = |
|
158 CVmSettingsUiIconFileProvider::NewL( file ); |
|
159 |
|
160 AknIconUtils::CreateIconL( |
|
161 aBrandedBitmap, |
|
162 aBrandedBitmapMask, |
|
163 *ifp, |
|
164 bitmap.BitmapId(), |
|
165 bitmap.BitmapMaskId() ); |
|
166 } |
|
167 |
|
168 // Set sizes. |
|
169 const TInt iconSize( KVmSettingsUiBrandingIconSize ); |
|
170 AknIconUtils::SetSize( aBrandedBitmap, TSize( iconSize, iconSize ) ); |
|
171 AknIconUtils::SetSize( aBrandedBitmapMask, TSize( iconSize, iconSize ) ); |
|
172 |
|
173 // Destroy some items. |
|
174 CleanupStack::PopAndDestroy( &file ); |
|
175 CleanupStack::PopAndDestroy( element ); |
|
176 CleanupStack::PopAndDestroy( access ); |
|
177 CleanupStack::PopAndDestroy( factory ); |
|
178 |
|
179 VMBLOGSTRING( "VMBX: CVmBSHandler::CreateBrandedBitmapL: <=" ); |
|
180 } |
|
181 |
|
182 // ========================== OTHER EXPORTED FUNCTIONS ======================= |
|
183 |
|
184 // End of File |
|