|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * Composite AppUi extension. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CxSPAppUiManager.h" |
|
22 |
|
23 // System includes |
|
24 #include <coemain.h> |
|
25 #include <barsread.h> |
|
26 #include <aknsconstants.hrh> |
|
27 #include <AknsUtils.h> |
|
28 #include <aknnavide.h> |
|
29 #include <akntabgrp.h> |
|
30 |
|
31 // From Phonebook2 |
|
32 #include <CPbk2ViewGraph.h> |
|
33 #include <MPbk2StartupMonitor.h> |
|
34 #include <Pbk2ViewId.hrh> |
|
35 #include <Pbk2ViewInfo.hrh> |
|
36 #include <CPbk2IconInfoContainer.h> |
|
37 #include <CPbk2IconInfo.h> |
|
38 #include <TPbk2IconId.h> |
|
39 #include <Pbk2UID.h> |
|
40 #include <MPbk2ApplicationServices2.h> |
|
41 #include <MPbk2ApplicationServices.h> |
|
42 #include <CPbk2ServiceManager.h> |
|
43 #include <MPbk2AppUi.h> |
|
44 |
|
45 // internal |
|
46 #include <ExtensionManagerRes.rsg> |
|
47 #include "ExtensionManager.hrh" |
|
48 #include "CxSPViewInfo.h" |
|
49 #include "CxSPViewIdChanger.h" |
|
50 #include "MxSPFactory.h" |
|
51 |
|
52 // ==================== MEMBER FUNCTIONS ==================== |
|
53 CxSPAppUiManager::CxSPAppUiManager( CArrayPtrFlat<MxSPFactory>& aFactories, |
|
54 CxSPViewIdChanger& aViewIdChanger ) : |
|
55 iFactories(aFactories), |
|
56 iViewIdChanger(aViewIdChanger) |
|
57 { |
|
58 } |
|
59 |
|
60 CxSPAppUiManager::~CxSPAppUiManager() |
|
61 { |
|
62 } |
|
63 |
|
64 void CxSPAppUiManager::DoRelease() |
|
65 { |
|
66 delete this; |
|
67 } |
|
68 |
|
69 void CxSPAppUiManager::ConstructL() |
|
70 { |
|
71 iViewIdChanger.GetViewCount( iTabViews, iOtherViews ); |
|
72 } |
|
73 |
|
74 CxSPAppUiManager* CxSPAppUiManager::NewL( CArrayPtrFlat<MxSPFactory>& aFactories, |
|
75 CxSPViewIdChanger& aViewIdChanger ) |
|
76 { |
|
77 CxSPAppUiManager* self = new (ELeave) CxSPAppUiManager( aFactories, aViewIdChanger ); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop(self); |
|
81 return self; |
|
82 } |
|
83 |
|
84 void CxSPAppUiManager::ExtensionStartupL(MPbk2StartupMonitor& aStartupMonitor) |
|
85 { |
|
86 aStartupMonitor.HandleStartupComplete(); |
|
87 } |
|
88 |
|
89 void CxSPAppUiManager::ApplyExtensionViewGraphChangesL |
|
90 (CPbk2ViewGraph& aViewGraph) |
|
91 { |
|
92 if( iTabViews < 0 ) //sanity check |
|
93 { |
|
94 return; |
|
95 } |
|
96 |
|
97 TInt currentId = EExtensionManagerTabViewStartId; |
|
98 TUint currentOrdering = EExtensionManagerTabOrderingStart; |
|
99 TResourceReader reader; |
|
100 for( TInt i=0; (i<iTabViews) && (currentId <= EExtensionManagerTabViewMaxId); i++) |
|
101 { |
|
102 CCoeEnv::Static()->CreateResourceReaderLC( reader, |
|
103 R_EXTENSION_MANAGER_BASIC_VIEWGRAPH ); |
|
104 |
|
105 CPbk2ViewNode* node = CPbk2ViewNode::NewL( |
|
106 TUid::Uid(currentId), |
|
107 TUid::Uid(EPbk2ExitViewId), |
|
108 EFalse, |
|
109 EPbk2MainTabGroup, |
|
110 (TPbk2TabGroupOrdering)currentOrdering, |
|
111 0, // No tabs |
|
112 reader); |
|
113 |
|
114 CleanupStack::PushL( node ); |
|
115 aViewGraph.AddViewNodeL( node ); |
|
116 CleanupStack::Pop( node ); |
|
117 currentId++; |
|
118 currentOrdering++; |
|
119 CleanupStack::PopAndDestroy(); //reader |
|
120 } |
|
121 |
|
122 currentId = EExtensionManagerViewStartId; |
|
123 for( TInt i=0; (i<iOtherViews) && (currentId <= EExtensionManagerViewMaxId); i++) |
|
124 { |
|
125 CCoeEnv::Static()->CreateResourceReaderLC( reader, |
|
126 R_EXTENSION_MANAGER_BASIC_VIEWGRAPH ); |
|
127 |
|
128 CPbk2ViewNode* node = CPbk2ViewNode::NewL( |
|
129 TUid::Uid(currentId), |
|
130 TUid::Uid(EPbk2ExitViewId), |
|
131 EFalse, |
|
132 (TPbk2TabGroupId)0, |
|
133 (TPbk2TabGroupOrdering)0, |
|
134 0, |
|
135 reader); |
|
136 |
|
137 CleanupStack::PushL( node ); |
|
138 aViewGraph.AddViewNodeL( node ); |
|
139 currentId++; |
|
140 CleanupStack::Pop( node ); |
|
141 CleanupStack::PopAndDestroy(); //reader |
|
142 } |
|
143 } |
|
144 |
|
145 |
|
146 |
|
147 void CxSPAppUiManager::ApplyDynamicPluginTabGroupContainerChangesL( |
|
148 const CPbk2ViewNode& aNode, |
|
149 CAknTabGroup& aAknTabGroup, |
|
150 CPbk2IconInfoContainer& aTabIcons, |
|
151 TInt /*aViewCount*/ ) |
|
152 { |
|
153 |
|
154 // First, load all view infos that contain the icons |
|
155 RPointerArray<CxSPViewInfo> infoArray; |
|
156 CleanupClosePushL( infoArray ); |
|
157 const TInt count = iFactories.Count(); |
|
158 for( TInt i = 0; i < count; i++ ) |
|
159 { |
|
160 iViewIdChanger.GetTabViewInfoL( iFactories[i]->Id(), infoArray ); |
|
161 } |
|
162 |
|
163 // pre-set default skin & color values |
|
164 TAknsItemID skin; |
|
165 skin.Set( EAknsMajorGeneric, EAknsMinorQgnGrafTab22 ); |
|
166 TAknsItemID color; |
|
167 color.Set( EAknsMajorNone, EAknsMinorNone ); |
|
168 |
|
169 // is the aNode from this extension |
|
170 // loop through tab view nodes |
|
171 for( TInt currentId = EExtensionManagerTabViewStartId; |
|
172 currentId <= EExtensionManagerTabViewMaxId; currentId++ ) |
|
173 { |
|
174 if (aNode.ViewId().iUid == currentId) |
|
175 { |
|
176 for( TInt i = 0; i < infoArray.Count(); i++ ) |
|
177 { |
|
178 CxSPViewInfo* info = infoArray[i]; |
|
179 if( info->NewViewId() == currentId ) |
|
180 { |
|
181 TBool isMonochrome = ETrue; |
|
182 CPbk2IconInfo* iconInfo (NULL); |
|
183 CFbsBitmap* bitmap = NULL; |
|
184 CFbsBitmap* mask = NULL; |
|
185 TPbk2IconId iconInfoId( TUid::Uid(KPbk2UID3), currentId ); |
|
186 //info->Name() denotes the ServiceName of the Service in SpSettings |
|
187 //PBK2 ServiceManager has the brandicons of all the services installed |
|
188 //to the device. |
|
189 //So iterate thro the PBK2ServiceManager, to find the service which matches |
|
190 //the info->Name() |
|
191 //If matches use this icon else use the default icon for the tabs |
|
192 //get the XSP ServiceName |
|
193 |
|
194 // CPbk2ServiceManager stores all the brandinfo |
|
195 // related to the services configured to the phone |
|
196 // use this to show uniform icon throughout PhoneBook |
|
197 MPbk2ApplicationServices2* servicesExtension = |
|
198 reinterpret_cast<MPbk2ApplicationServices2*> |
|
199 ( Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
200 MPbk2ApplicationServicesExtension( |
|
201 KMPbk2ApplicationServicesExtension2Uid ) ); |
|
202 CPbk2ServiceManager& servMan = servicesExtension->ServiceManager(); |
|
203 const CPbk2ServiceManager::RServicesArray& services = servMan.Services(); |
|
204 for ( TInt i = 0; i < services.Count(); i++ ) |
|
205 { |
|
206 const CPbk2ServiceManager::TService& service = services[i]; |
|
207 //Found the appropriate service info |
|
208 if ( service.iName == info->Name() ) |
|
209 { |
|
210 if ( service.iBitmap && service.iMask ) |
|
211 { |
|
212 |
|
213 // Check if the bitmap is monochrome here |
|
214 // before compression happen |
|
215 if ( !service.iBitmap->IsMonochrome()) |
|
216 { |
|
217 isMonochrome = EFalse; |
|
218 } |
|
219 |
|
220 TSize size( 25, 25 ); //default size used in PB |
|
221 |
|
222 AknIconUtils::SetSize( |
|
223 service.iBitmap, |
|
224 size ); |
|
225 AknIconUtils::SetSize( |
|
226 service.iMask, |
|
227 size ); |
|
228 |
|
229 bitmap = new (ELeave) CFbsBitmap; |
|
230 CleanupStack::PushL( bitmap ); |
|
231 bitmap->Duplicate( service.iBitmap->Handle() ); |
|
232 |
|
233 mask = new (ELeave) CFbsBitmap; |
|
234 CleanupStack::PushL( mask ); |
|
235 mask->Duplicate( service.iMask->Handle() ); |
|
236 |
|
237 iconInfo = CPbk2IconInfo::NewLC( |
|
238 iconInfoId, |
|
239 bitmap, |
|
240 mask, |
|
241 size ); |
|
242 } |
|
243 break; |
|
244 } |
|
245 } |
|
246 |
|
247 if ( !iconInfo ) |
|
248 { |
|
249 //load default icons using mif file |
|
250 //Branded icon was not found |
|
251 iconInfo = CPbk2IconInfo::NewLC( |
|
252 iconInfoId, |
|
253 (TInt)info->TabIconId(), |
|
254 (TInt)info->TabMaskId(), |
|
255 info->TabIconFile(), |
|
256 skin, color, 0, 0 ); |
|
257 |
|
258 AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), |
|
259 skin, |
|
260 bitmap, |
|
261 mask, |
|
262 info->TabIconFile(), |
|
263 info->TabIconId(), |
|
264 info->TabMaskId() ); |
|
265 |
|
266 AknIconUtils::ExcludeFromCache( bitmap ); |
|
267 AknIconUtils::ExcludeFromCache( mask ); |
|
268 } |
|
269 |
|
270 aTabIcons.AppendIconL( iconInfo ); |
|
271 aAknTabGroup.AddTabL( currentId, bitmap, mask ); |
|
272 |
|
273 // Set color mode only for colored icon, |
|
274 // not for monochrome icon |
|
275 if ( !isMonochrome ) |
|
276 { |
|
277 aAknTabGroup.SetTabMultiColorMode( currentId, ETrue ); |
|
278 } |
|
279 |
|
280 //The POP is synchroze the number of items pushed |
|
281 //the order of the item might change. Please have a glance on the items pushed |
|
282 CleanupStack::Pop( 3 ); // iconInfo,bitmap,mask |
|
283 break; |
|
284 } |
|
285 } |
|
286 } |
|
287 } |
|
288 CleanupStack::PopAndDestroy(); // infoArray |
|
289 } |
|
290 |
|
291 // End of File |