|
1 /* |
|
2 * Copyright (c) 2005-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: This defines the engine class for Location settings Ui |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Include |
|
20 #include <aknViewAppUi.h> |
|
21 |
|
22 // User Include |
|
23 #include "locsettingsuiengine.h" |
|
24 #include "locsettingsuiecomnotifier.h" |
|
25 #include "locationsettings.h" |
|
26 #include "locsettingsuipluginloader.h" |
|
27 #include "locsettingsui.h" |
|
28 #include "locsettingsuiparams.h" |
|
29 |
|
30 // ========================= MEMBER FUNCTIONS ================================ |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CLocSettingsUiEngine::CLocSettingsUiEngine |
|
34 // Overloaded Constructor |
|
35 // |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CLocSettingsUiEngine::CLocSettingsUiEngine( CAknViewAppUi& aAppUi ) |
|
39 :iAppUi( aAppUi ) |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CLocationSystemUiView::~CLocSettingsUiEngine |
|
45 // Destructor |
|
46 // |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CLocSettingsUiEngine::~CLocSettingsUiEngine() |
|
50 { |
|
51 |
|
52 // Delete the Settings UI Descriptions |
|
53 while ( iSettingsArray.Count() > 0 ) |
|
54 { |
|
55 // Remove the first item |
|
56 CLocationSettings* item = iSettingsArray[0]; |
|
57 iSettingsArray.Remove( 0 ); |
|
58 |
|
59 // Delete the element |
|
60 delete item; |
|
61 item = NULL; |
|
62 } |
|
63 iSettingsArray.Reset(); |
|
64 iSettingsArray.Close(); |
|
65 |
|
66 // Delete the Plug-in Loader |
|
67 delete iPluginLoader; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CLocSettingsUiEngine* CLocSettingsUiEngine::NewL |
|
72 // Two Phase Constructor. |
|
73 // |
|
74 // @param aAppUi Reference to the Application UI class that |
|
75 // launched the Settings Application |
|
76 // @return CLocSettingsUiEngine* Reference to the created object |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C CLocSettingsUiEngine* CLocSettingsUiEngine::NewL( CAknViewAppUi& aAppUi ) |
|
80 { |
|
81 CLocSettingsUiEngine* self = CLocSettingsUiEngine::NewLC( aAppUi ); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CLocSettingsUiEngine* CLocSettingsUiEngine::NewLC |
|
88 // Two Phase Constructor. |
|
89 // |
|
90 // @param aAppUi Reference to the Application UI class that |
|
91 // launched the Settings Application |
|
92 // @return CLocSettingsUiEngine* Reference to the created object |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C CLocSettingsUiEngine* CLocSettingsUiEngine::NewLC( CAknViewAppUi& aAppUi ) |
|
96 { |
|
97 CLocSettingsUiEngine* self = new(ELeave) CLocSettingsUiEngine( aAppUi ); |
|
98 CleanupStack::PushL( self ); |
|
99 self->ConstructL(); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // void CLocSettingsUiDesc::ConstructL |
|
105 // Second Phase of the two phase constructor. The caption string is copied into |
|
106 // |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CLocSettingsUiEngine::ConstructL() |
|
110 { |
|
111 |
|
112 // Construct the Plug-In Loader |
|
113 iPluginLoader = CLocSettingsUiPluginLoader::NewL( iAppUi ); |
|
114 |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CLocationSettings* CLocSettingsUiEngine::CreateSettingsUiL |
|
119 // |
|
120 // Creates a single Settings UI Object. |
|
121 // In case the object already exists, then a reference to the existing object is |
|
122 // returned and no new object is created. In either case, the class retains the |
|
123 // ownership of the created object. |
|
124 // |
|
125 // @param aImplementationUid The Implementation UID of the plug-in that |
|
126 // has to be created. |
|
127 // @return CLocationSettings* Reference to the created object. |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 EXPORT_C CLocationSettings* CLocSettingsUiEngine::CreateSettingsUiL( |
|
131 TUid aImplementationUid ) |
|
132 { |
|
133 // Scan through the existing list of Settings UIs. Incase, a UI with the |
|
134 // same UID exists then return the same. If not create a new implmentation |
|
135 // and return a reference to it |
|
136 |
|
137 TInt index = KErrNotFound; |
|
138 |
|
139 // Iterate through the Settings UI array |
|
140 for ( TInt count = 0; count < iSettingsArray.Count(); count++ ) |
|
141 { |
|
142 CLocationSettings* currentItem = iSettingsArray[count]; |
|
143 // If the Settings object for the Implementation UID already |
|
144 // exisits then dont do anything |
|
145 if ( aImplementationUid == currentItem->ImplementationUid()) |
|
146 { |
|
147 index = count; |
|
148 break; |
|
149 } |
|
150 } |
|
151 |
|
152 if( KErrNotFound != index ) |
|
153 { |
|
154 // A Settings UI corresponding to the UID already exists. Return a |
|
155 // reference to the same. |
|
156 return iSettingsArray[index]; |
|
157 } |
|
158 else |
|
159 { |
|
160 // Settings UI does not exist. Create a new implementation and |
|
161 // return the same |
|
162 return &( iPluginLoader->CreateSettingsUiL( aImplementationUid, |
|
163 iSettingsArray )); |
|
164 |
|
165 } |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // RPointerArray<CLocationSettings>& CLocSettingsUiEngine::CreateAvailableSettingsUiL |
|
170 // |
|
171 // Creates all the available settings UI. This function call performs |
|
172 // an ECom discovery of all the possible ECom plugins that are |
|
173 // available and creates the Settings UI components as well as the |
|
174 // plug-in UI. The ownership of the created objects is not transferred |
|
175 // to the callee but retained with the Engine class. This function needs |
|
176 // that No settings UIs have been already created. Incase, there exists |
|
177 // any Settings UIs then the function leaves with KErrAlreadyExists. |
|
178 // |
|
179 // @return RPointerArray<CLocationSettings>& Reference to the array of Settings |
|
180 // objects. |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 RPointerArray<CLocationSettings>& CLocSettingsUiEngine::CreateAvailableSettingsUiL() |
|
184 { |
|
185 |
|
186 // The function expects that there are no existing Settings UI elements |
|
187 // present. Hence, the need to check |
|
188 if( iSettingsArray.Count()) |
|
189 { |
|
190 User::Leave( KErrAlreadyExists ); |
|
191 } |
|
192 |
|
193 // Create the Settings UIs |
|
194 iPluginLoader->CreateAvailableSettingsUisL( iSettingsArray ); |
|
195 |
|
196 // Return a reference to the created Settings UI structures |
|
197 return iSettingsArray; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // PointerArray<CLocationSettings>& CLocSettingsUiEngine::UpdateAvailableSettingsUisL() |
|
202 // |
|
203 // Updates the list of available UIs. The new list would contain all the |
|
204 // latest additions to the list of UIs in addition to the existing |
|
205 // UIs. The interface does not delete any instances if they are not in |
|
206 // the current implementation list. |
|
207 // |
|
208 // @return RPointerArray<CLocationSettings>& Reference to the array of Settings |
|
209 // objects. |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 RPointerArray<CLocationSettings>& CLocSettingsUiEngine::UpdateAvailableSettingsUisL() |
|
213 { |
|
214 |
|
215 // Create the Settings UIs |
|
216 iPluginLoader->CreateAvailableSettingsUisL( iSettingsArray ); |
|
217 |
|
218 // Return a reference to the created Settings UI structures |
|
219 return iSettingsArray; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // RPointerArray<CLocationSettings>& CLocSettingsUiEngine::SettingsUiArray |
|
224 // |
|
225 // Accessor function to obtain the Settings UI structures. The ownership of the |
|
226 // internal objects is not transferred. |
|
227 // |
|
228 // @return RPointerArray<CLocationSettings>& Reference to the array of Settings |
|
229 // objects. |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 RPointerArray<CLocationSettings>& CLocSettingsUiEngine::SettingsUiArray() |
|
233 { |
|
234 return iSettingsArray; |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // void CLocSettingsUiEngine::StartSettingsEComNotification |
|
239 // Starts the Ecom notification for observing loading and unloading of the |
|
240 // underlying sub-settings plug-ins |
|
241 // |
|
242 // @param aSettingsNotifer Notifier for communication of changes in the |
|
243 // Ecom loading and unloading for sub-settings |
|
244 // plug-ins |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CLocSettingsUiEngine::StartSettingsEComNotificationL( |
|
248 MLocSettingsUiEcomNotifer* aNotifier ) |
|
249 { |
|
250 iPluginLoader->StartEComNotifyL( aNotifier ); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // void CLocSettingsUiEngine::StopSettingsEComNotification |
|
255 // Stops ECom notification. Does nothing in case there was no outstanding |
|
256 // request |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CLocSettingsUiEngine::StopSettingsEComNotification() |
|
260 { |
|
261 iPluginLoader->StopEComNotify(); |
|
262 } |