|
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 * ExtensionManager extension factory. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CExtensionManagerFactory.h" |
|
22 |
|
23 // System includes |
|
24 #include <coemain.h> |
|
25 #include <coeutils.h> |
|
26 #include <bautils.h> |
|
27 #include <aknViewAppUi.h> |
|
28 #include <aknsconstants.hrh> |
|
29 |
|
30 // phonebook includes |
|
31 #include <Pbk2Commands.hrh> |
|
32 #include <CPbk2UIExtensionInformation.h> |
|
33 #include <PbkUID.h> |
|
34 |
|
35 // internal includes |
|
36 #include "CxSPViewManager.h" |
|
37 #include "MxSPFactory.h" |
|
38 #include "CxSPAppUiManager.h" |
|
39 #include "CxSPLoader.h" |
|
40 #include "ExtensionManager.hrh" |
|
41 #include <ExtensionManagerRes.rsg> |
|
42 #include "CxSPViewIdChanger.h" |
|
43 #include "ExtensionManagerIcons.hrh" |
|
44 #include "CxSPViewInfo.h" |
|
45 #include "ExtensionManagerUID.H" |
|
46 #include "CxSPBaseView.h" |
|
47 |
|
48 #include "CxSPSortNamesListViewExtension.h" |
|
49 #include "CxSPSortView.h" |
|
50 #include "CxSPContactManager.h" |
|
51 #include "CxSPCommand.h" |
|
52 |
|
53 /// Unnamed namespace for local definitions |
|
54 namespace { |
|
55 |
|
56 // CONSTANTS |
|
57 const TInt KExtensionGranularity = 1; |
|
58 const TInt KFactoryGranularity = 2; |
|
59 |
|
60 } |
|
61 |
|
62 |
|
63 // ================= MEMBER FUNCTIONS ======================= |
|
64 |
|
65 inline CExtensionManagerFactory::CExtensionManagerFactory() : |
|
66 iFactories( KFactoryGranularity ), |
|
67 iExtensions( KExtensionGranularity ), |
|
68 iSortView( EFalse ) |
|
69 { |
|
70 } |
|
71 |
|
72 void CExtensionManagerFactory::ConstructL() |
|
73 { |
|
74 // Scan for extensions but only for Phonebook2 process. For other processes |
|
75 //(at the moment ccaapp.exe and Pbk2ServerApp.exe) we skip reloading |
|
76 //extensions again. This is fix for RCHN-7LAAQB as some of extensions |
|
77 //loaded cause problems when reloaded again in other processes. |
|
78 if( RProcess().SecureId().iId == KPbkUID3 ) |
|
79 { |
|
80 ScanExtensionsL(); |
|
81 } |
|
82 |
|
83 /// change view ids |
|
84 iViewIdChanger = CxSPViewIdChanger::NewL(); |
|
85 iViewIdChanger->ChangeViewIdsL( iFactories ); |
|
86 // if ScanExtensionsL does not called,iFactories.Count()==0. |
|
87 if (iFactories.Count() > 0) |
|
88 { |
|
89 iViewIdChanger->WriteTabViewNamesToRepositoryL(); |
|
90 } |
|
91 iViewIdChanger->ChangeManagerViewIdsL(); |
|
92 |
|
93 CreatePbkViewExtensionL(); |
|
94 |
|
95 // don't leave if view activator server is already running |
|
96 TRAPD( err, iViewActivator = CxSPViewActivator::NewL( iViewIdChanger ) ); |
|
97 if( err != KErrAlreadyExists ) |
|
98 { |
|
99 User::LeaveIfError( err ); |
|
100 } |
|
101 } |
|
102 |
|
103 CExtensionManagerFactory* CExtensionManagerFactory::NewL() |
|
104 { |
|
105 CExtensionManagerFactory* self = new (ELeave) CExtensionManagerFactory; |
|
106 CleanupStack::PushL(self); |
|
107 self->ConstructL(); |
|
108 CleanupStack::Pop(self); |
|
109 return self; |
|
110 } |
|
111 |
|
112 CExtensionManagerFactory::~CExtensionManagerFactory() |
|
113 { |
|
114 delete iViewManager; |
|
115 delete iViewIdChanger; |
|
116 delete iContactManager; |
|
117 iFactories.Reset(); |
|
118 iExtensions.ResetAndDestroy(); |
|
119 delete iScanner; |
|
120 delete iViewActivator; |
|
121 } |
|
122 |
|
123 void CExtensionManagerFactory::AppendL( MxSPFactory* aFactory ) |
|
124 { |
|
125 iFactories.AppendL( aFactory ); |
|
126 } |
|
127 |
|
128 void CExtensionManagerFactory::CreatePbkViewExtensionL() |
|
129 { |
|
130 iViewManager = CxSPViewManager::NewL(); |
|
131 const TInt count = iFactories.Count(); |
|
132 for( TInt i = 0; i < count; ++i ) |
|
133 { |
|
134 MxSPView* viewExt = iFactories[i]->CreatePbkViewExtensionL(); |
|
135 if( viewExt ) |
|
136 { |
|
137 CleanupStack::PushL( viewExt ); |
|
138 iViewManager->AppendL( viewExt, iFactories[i]->Id() ); |
|
139 CleanupStack::Pop( viewExt ); |
|
140 } |
|
141 } |
|
142 |
|
143 TInt tabViews; |
|
144 TInt otherViews; |
|
145 iViewIdChanger->GetViewCount( tabViews, otherViews ); |
|
146 |
|
147 // Create also extension for "sorting" menu, but only if there's more than 1 tab view |
|
148 if( tabViews > 1 ) |
|
149 { |
|
150 MxSPView* viewExt = CxSPSortNamesListViewExtension::NewL(); |
|
151 CleanupStack::PushL(viewExt); |
|
152 iViewManager->AppendL(viewExt, KEXTENSIONMANAGERIMPLEMENTATIONUID); |
|
153 CleanupStack::Pop(viewExt); |
|
154 } |
|
155 } |
|
156 |
|
157 MPbk2UIExtensionView* CExtensionManagerFactory::CreateExtensionViewL |
|
158 ( TUid aViewId, CPbk2UIExtensionView& aView ) |
|
159 { |
|
160 if ( aViewId.iUid == EExtensionManagerSortViewId ) |
|
161 { |
|
162 CxSPBaseView* view = CxSPSortView::NewL( *iViewIdChanger, |
|
163 *iContactManager, |
|
164 aView, |
|
165 iExtensions ); |
|
166 return view; |
|
167 } |
|
168 |
|
169 const TInt count = iFactories.Count(); |
|
170 for (TInt i=0; i<count; ++i) |
|
171 { |
|
172 CxSPBaseView* view = iFactories[i]->CreateViewL( aViewId, aView ); |
|
173 if( view ) |
|
174 { |
|
175 return view; |
|
176 } |
|
177 } |
|
178 return NULL; |
|
179 } |
|
180 |
|
181 |
|
182 void CExtensionManagerFactory::DynInitMenuPaneL(TInt aResourceId, |
|
183 CEikMenuPane* aMenuPane, MPbk2ContactUiControl& /*aControl*/ ) |
|
184 { |
|
185 iViewManager->DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
186 } |
|
187 |
|
188 |
|
189 void CExtensionManagerFactory::UpdateStorePropertiesL |
|
190 ( CPbk2StorePropertyArray& aPropertyArray ) |
|
191 { |
|
192 const TInt count = iFactories.Count(); |
|
193 for( TInt i = 0; i < count; i++ ) |
|
194 { |
|
195 iFactories[i]->UpdateStorePropertiesL( aPropertyArray ); |
|
196 } |
|
197 } |
|
198 |
|
199 |
|
200 MPbk2ContactEditorExtension* |
|
201 CExtensionManagerFactory::CreatePbk2ContactEditorExtensionL |
|
202 ( CVPbkContactManager& /*aContactManager*/, |
|
203 MVPbkStoreContact& /*aContact*/, |
|
204 MPbk2ContactEditorControl& /*aEditorControl*/ ) |
|
205 { |
|
206 // Do nothing |
|
207 return NULL; |
|
208 } |
|
209 |
|
210 |
|
211 MPbk2ContactUiControlExtension* |
|
212 CExtensionManagerFactory::CreatePbk2UiControlExtensionL |
|
213 ( CVPbkContactManager& /*aContactManager*/ ) |
|
214 { |
|
215 // Do nothing |
|
216 return NULL; |
|
217 } |
|
218 |
|
219 |
|
220 MPbk2SettingsViewExtension* |
|
221 CExtensionManagerFactory::CreatePbk2SettingsViewExtensionL |
|
222 ( CVPbkContactManager& /*aContactManager */ ) |
|
223 { |
|
224 // Do nothing |
|
225 return NULL; |
|
226 } |
|
227 |
|
228 MPbk2AppUiExtension* CExtensionManagerFactory::CreatePbk2AppUiExtensionL |
|
229 ( CVPbkContactManager& aContactManager ) |
|
230 { |
|
231 const TInt count = iFactories.Count(); |
|
232 for( TInt i = 0; i < count; ++i ) |
|
233 { |
|
234 iFactories[i]->SetVPbkContactManager( aContactManager ); |
|
235 } |
|
236 |
|
237 if( !iContactManager ) |
|
238 { |
|
239 iContactManager = CxSPContactManager::NewL( iFactories, aContactManager ); |
|
240 } |
|
241 if( !iAppUiManager ) |
|
242 { |
|
243 iAppUiManager = CxSPAppUiManager::NewL( iFactories, *iViewIdChanger ); |
|
244 } |
|
245 return iAppUiManager; |
|
246 } |
|
247 |
|
248 |
|
249 MPbk2Command* CExtensionManagerFactory::CreatePbk2CommandForIdL |
|
250 ( TInt aCommandId, MPbk2ContactUiControl& aUiControl ) const |
|
251 { |
|
252 // check if this is an extension command |
|
253 const TInt count = iFactories.Count(); |
|
254 TInt err( KErrNotFound ); |
|
255 |
|
256 TInt dummy; |
|
257 // try first the manager itself |
|
258 err = iViewManager->GetOldCommand( KEXTENSIONMANAGERIMPLEMENTATIONUID, |
|
259 aCommandId, |
|
260 dummy ); |
|
261 for( TInt i = 0; i < count && err; i++ ) |
|
262 { |
|
263 err = iViewManager->GetOldCommand( iFactories[i]->Id(), aCommandId, dummy ); |
|
264 } |
|
265 |
|
266 MPbk2Command* command = NULL; |
|
267 if( !err ) |
|
268 { |
|
269 command = CxSPCommand::NewL( aCommandId, aUiControl, *iViewManager ); |
|
270 } |
|
271 return command; |
|
272 } |
|
273 |
|
274 MPbk2AiwInterestItem* CExtensionManagerFactory::CreatePbk2AiwInterestForIdL |
|
275 ( TInt /*aInterestId*/, |
|
276 CAiwServiceHandler& /*aServiceHandler*/ ) const |
|
277 { |
|
278 // Do nothing |
|
279 return NULL; |
|
280 } |
|
281 |
|
282 TBool CExtensionManagerFactory::GetHelpContextL |
|
283 ( TCoeHelpContext& /*aContext*/, const CPbk2AppViewBase& /*aView*/, |
|
284 MPbk2ContactUiControl& /*aUiControl*/ ) |
|
285 { |
|
286 return EFalse; |
|
287 } |
|
288 |
|
289 |
|
290 void CExtensionManagerFactory::ApplyDynamicViewGraphChangesL( |
|
291 CPbk2ViewGraph& aViewGraph ) |
|
292 { |
|
293 if( !iAppUiManager ) |
|
294 { |
|
295 iAppUiManager = CxSPAppUiManager::NewL( iFactories, *iViewIdChanger ); |
|
296 } |
|
297 |
|
298 iAppUiManager->ApplyExtensionViewGraphChangesL( aViewGraph ); |
|
299 } |
|
300 |
|
301 |
|
302 void CExtensionManagerFactory::ApplyDynamicPluginInformationDataL( |
|
303 CPbk2UIExtensionInformation& aUiExtensionInformation ) |
|
304 { |
|
305 TInt tabViews = 0; |
|
306 TInt otherViews = 0; |
|
307 iViewIdChanger->GetViewCount( tabViews, otherViews ); |
|
308 |
|
309 TInt currentId = EExtensionManagerTabViewStartId; |
|
310 for( TInt i=0; (i<tabViews) && (currentId <= EExtensionManagerTabViewMaxId); i++) |
|
311 { |
|
312 // create TPbk2UIExtensionViewId structures |
|
313 TPbk2UIExtensionViewId viewId(TUid::Uid(currentId), R_EXTENSION_MANAGER_BASICVIEW ); |
|
314 |
|
315 // add the view id structures to aUiExtensionInformation |
|
316 aUiExtensionInformation.AddViewIdL(viewId); |
|
317 currentId++; |
|
318 } |
|
319 |
|
320 currentId = EExtensionManagerViewStartId; |
|
321 for( TInt i=0; (i<otherViews) && (currentId <= EExtensionManagerViewMaxId); i++) |
|
322 { |
|
323 // create TPbk2UIExtensionViewId structures |
|
324 TPbk2UIExtensionViewId viewId(TUid::Uid(currentId), R_EXTENSION_MANAGER_BASICVIEW ); |
|
325 |
|
326 // add the view id structures to aUiExtensionInformation |
|
327 aUiExtensionInformation.AddViewIdL(viewId); |
|
328 currentId++; |
|
329 } |
|
330 } |
|
331 |
|
332 |
|
333 void CExtensionManagerFactory::ScanExtensionsL() |
|
334 { |
|
335 iExtensions.ResetAndDestroy(); |
|
336 iFactories.Reset(); |
|
337 |
|
338 iScanner = CxSPScanner::NewL( iExtensions ); |
|
339 iScanner->ScanL(); |
|
340 |
|
341 const TInt count = iExtensions.Count(); |
|
342 for (TInt i=0; i<count; ++i) |
|
343 { |
|
344 AppendL(iExtensions.At(i)->ExtensionFactory()); |
|
345 } |
|
346 } |
|
347 |
|
348 // End of File |