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: GSFW implementation for Presence Settings UI GS plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <bautils.h> |
|
23 #include <psuigspluginrsc.rsg> |
|
24 #include <psuigsplugin.mbg> |
|
25 #include <eiktxlbx.h> |
|
26 #include <eikmenup.h> |
|
27 #include <eiktxlbm.h> |
|
28 #include <featmgr.h> |
|
29 #include <hlplch.h> |
|
30 #include <coeaui.h> |
|
31 #include <aknlists.h> |
|
32 #include <aknPopup.h> |
|
33 #include <StringLoader.h> |
|
34 #include <AknQueryDialog.h> |
|
35 |
|
36 #include "psuigsplugin.h" |
|
37 #include "psuigsplugin.hrh" |
|
38 #include "psuigsplugincontainer.h" |
|
39 #include "psuigspluginids.hrh" |
|
40 #include "psuigspluginmodel.h" |
|
41 #include "psuigspluginsettingview.h" |
|
42 |
|
43 // CONSTANTS |
|
44 |
|
45 #ifdef __SCALABLE_ICONS |
|
46 // bitmap |
|
47 #else //__SCALABLE_ICONS |
|
48 // svg file |
|
49 _LIT( KPSUIGSPluginIconFileName, "\\resource\\apps\\psuigsplugin.mbm"); |
|
50 #endif //__SCALABLE_ICONS |
|
51 |
|
52 // ========================= MEMBER FUNCTIONS ================================ |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CPSUIGSPlugin::CPSUIGSPlugin() |
|
56 // C++ default constructor can NOT contain any code, that |
|
57 // might leave. |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CPSUIGSPlugin::CPSUIGSPlugin() |
|
61 : iClosing ( EFalse ) |
|
62 { |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CPSUIGSPlugin::~CPSUIGSPlugin() |
|
67 // Destructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CPSUIGSPlugin::~CPSUIGSPlugin() |
|
71 { |
|
72 delete iPSModel; |
|
73 FeatureManager::UnInitializeLib(); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CPSUIGSPlugin::ConstructL |
|
78 // Symbian 2nd phase constructor can leave. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CPSUIGSPlugin::ConstructL() |
|
82 { |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CPSUIGSPlugin::NewL() |
|
87 // Two-phased constructor. |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CPSUIGSPlugin* CPSUIGSPlugin::NewL( TAny* /*aAppUi*/ ) |
|
91 { |
|
92 CPSUIGSPlugin* self = new( ELeave ) CPSUIGSPlugin(); |
|
93 CleanupStack::PushL( self ); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop( self ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CPSUIGSPlugin::Id() |
|
101 // See header for details. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 TUid CPSUIGSPlugin::Id() const |
|
105 { |
|
106 return TUid::Uid( PSUIGSPluginImplUid ); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CPSUIGSPlugin::DoActivateL() |
|
111 // See header for details. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CPSUIGSPlugin::DoActivateL( const TVwsViewId& aPrevViewId, |
|
115 TUid /*aCustomMessageId*/, |
|
116 const TDesC8& /*aCustomMessage*/ ) |
|
117 { |
|
118 if ( KPreSettingViewId != aPrevViewId.iViewUid ) |
|
119 { |
|
120 iPSUIGSPrevViewId = aPrevViewId; |
|
121 } |
|
122 |
|
123 // model & observer constructed only when needed |
|
124 if ( !iPSModel ) |
|
125 { |
|
126 iPSModel = CPSUIGSPluginModel::NewL(); |
|
127 } |
|
128 |
|
129 const TInt id = iPSModel->SettingsId(); |
|
130 if ( id ) |
|
131 {// readjust the focus |
|
132 } |
|
133 |
|
134 iClosing = EFalse; |
|
135 UpdateMSK(); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CPSUIGSPlugin::DoDeactivate() |
|
140 // See header for details. |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CPSUIGSPlugin::DoDeactivate() |
|
144 { |
|
145 if ( iClosing ) |
|
146 {// PSUI plugin is going to be closed so it is safe to free some memory |
|
147 delete iPSModel; |
|
148 iPSModel = NULL; |
|
149 } |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CPSUIGSPlugin::HandleViewDeactivation() |
|
154 // See header for details. |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CPSUIGSPlugin::HandleViewDeactivation( |
|
158 const TVwsViewId& aViewIdToBeDeactivated, |
|
159 const TVwsViewId& aNewlyActivatedViewId) |
|
160 { |
|
161 if ( TUid::Uid( PSUIGSPluginImplUid ) == aViewIdToBeDeactivated.iViewUid && |
|
162 iPSUIGSPrevViewId.iViewUid == aNewlyActivatedViewId.iViewUid ) |
|
163 { |
|
164 iClosing = ETrue; |
|
165 } |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CPSUIGSPlugin::HandleCommandL() |
|
170 // See header for details. |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 void CPSUIGSPlugin::HandleCommandL( TInt aCommand ) |
|
174 { |
|
175 switch ( aCommand ) |
|
176 { |
|
177 case EAknSoftkeyBack: |
|
178 { |
|
179 RemoveSettingView(); |
|
180 break; |
|
181 } |
|
182 case EPSUICmdEdit: |
|
183 { |
|
184 break; |
|
185 } |
|
186 case EPSUICmdDelete: |
|
187 { |
|
188 DeleteSettingsL(); |
|
189 break; |
|
190 } |
|
191 case EPSUICmdNewSettingsDefault: |
|
192 { |
|
193 CreateNewDefaultSettingsL(); |
|
194 break; |
|
195 } |
|
196 case EPSUICmdNewSettingsExisting: |
|
197 { |
|
198 CreateCopyOfExistingSettingsL(); |
|
199 break; |
|
200 } |
|
201 case EAknCmdHelp: |
|
202 { |
|
203 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
204 { |
|
205 } |
|
206 break; |
|
207 } |
|
208 default: |
|
209 { |
|
210 break; |
|
211 } |
|
212 } |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CPSUIGSPlugin::SettingCountAndIndex() |
|
217 // See header for details. |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 TInt CPSUIGSPlugin::SettingCountAndIndex( TInt& /*aIndex*/ ) |
|
221 { |
|
222 return KErrNone; |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // CPSUIGSPlugin::DeleteSettingsL() |
|
227 // See header for details. |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CPSUIGSPlugin::DeleteSettingsL() |
|
231 { |
|
232 TInt index = KErrNotFound; |
|
233 TInt count = SettingCountAndIndex( index ); |
|
234 if ( count ) |
|
235 { |
|
236 if ( AcceptDeletionL( count, index )) |
|
237 { |
|
238 iPSModel->DeleteSettingsL( index, ETrue ); |
|
239 UpdateMSK(); |
|
240 } |
|
241 } |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CPSUIGSPlugin::AcceptDeletionL() |
|
246 // See header for details. |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 TBool CPSUIGSPlugin::AcceptDeletionL( TInt aCount, TInt aIndex ) |
|
250 { |
|
251 HBufC* currentName = iPSModel->SettingNameLC( aIndex ); |
|
252 if ( aCount == 1 ) |
|
253 { |
|
254 } |
|
255 else |
|
256 { |
|
257 } |
|
258 |
|
259 CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone ); |
|
260 TInt ok = KErrNone; |
|
261 |
|
262 CleanupStack::PopAndDestroy( 2, currentName );//currentName, string |
|
263 |
|
264 return ( ok ); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CPSUIGSPlugin::DynInitMenuPaneL() |
|
269 // See header for details. |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CPSUIGSPlugin::DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane */*aMenuPane*/ ) |
|
273 { |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // CPSUIGSPlugin::PSModel() |
|
278 // See header for details. |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 CPSUIGSPluginModel* CPSUIGSPlugin::PSModel() |
|
282 { |
|
283 __ASSERT_DEBUG( iPSModel,User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound )); |
|
284 return iPSModel; |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CPSUIGSPlugin::ConstructSettingViewL() |
|
289 // See header for details. |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CPSUIGSPlugin::ConstructSettingViewL() |
|
293 { |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // CPSUIGSPlugin::RemoveSettingView() |
|
298 // See header for details. |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CPSUIGSPlugin::RemoveSettingView() |
|
302 { |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // CPSUIGSPlugin::CreateNewDefaultSettingsL() |
|
307 // See header for details. |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void CPSUIGSPlugin::CreateNewDefaultSettingsL() |
|
311 { |
|
312 iPSModel->CreateDefaultSettingsL(); |
|
313 ConstructSettingViewL(); |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CPSUIGSPlugin::CreateCopyOfExistingSettingsL() |
|
318 // See header for details. |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CPSUIGSPlugin::CreateCopyOfExistingSettingsL() |
|
322 { |
|
323 CAknSinglePopupMenuStyleListBox* list = |
|
324 new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
325 CleanupStack::PushL( list ); |
|
326 |
|
327 CAknPopupList* popupList = |
|
328 CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL ); |
|
329 CleanupStack::PushL( popupList ); |
|
330 |
|
331 |
|
332 list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect ); |
|
333 list->CreateScrollBarFrameL( ETrue ); |
|
334 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
335 CEikScrollBarFrame::EOff, |
|
336 CEikScrollBarFrame::EAuto ); |
|
337 |
|
338 CTextListBoxModel* model = list->Model(); |
|
339 model->SetItemTextArray( iPSModel->SettingNames() );// setting names not owned |
|
340 model->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
341 list->HandleItemAdditionL(); |
|
342 |
|
343 CleanupStack::Pop( popupList ); |
|
344 TInt keyPress = popupList->ExecuteLD(); |
|
345 |
|
346 if ( keyPress ) |
|
347 { |
|
348 iPSModel->DuplicateExistingSettingsL( list->CurrentItemIndex() ); |
|
349 ConstructSettingViewL(); |
|
350 } |
|
351 |
|
352 CleanupStack::PopAndDestroy( list ); |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CPSUIGSPlugin::UpdateMSK() |
|
357 // See header for details. |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 void CPSUIGSPlugin::UpdateMSK() |
|
361 { |
|
362 } |
|
363 |
|
364 // End of file |
|