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: Presence Settings UI setting view implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <bautils.h> |
|
23 #include <psuigspluginrsc.rsg> |
|
24 #include <StringLoader.h> |
|
25 #include <AknQueryDialog.h> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <aknViewAppUi.h> |
|
28 #include <featmgr.h> |
|
29 #include <hlplch.h> |
|
30 #include "psuigsplugin.h" |
|
31 #include "psuigspluginsettingview.h" |
|
32 #include "psuigspluginmodel.h" |
|
33 #include "psuigspluginsettingviewcontainer.h" |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // ========================= MEMBER FUNCTIONS ================================ |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CPSUIGSPluginSettingView::CPSUIGSPluginSettingView() |
|
41 // C++ default constructor can NOT contain any code, that |
|
42 // might leave. |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CPSUIGSPluginSettingView::CPSUIGSPluginSettingView( CPSUIGSPlugin* aMainView ) |
|
46 : iMainView ( aMainView ) |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CPSUIGSPluginSettingView::~CPSUIGSPluginSettingView() |
|
52 // Destructor |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CPSUIGSPluginSettingView::~CPSUIGSPluginSettingView() |
|
56 { |
|
57 // iAppUi, iMainView deleted elsewhere |
|
58 if ( iPSUIContainer && iAppUi ) |
|
59 { |
|
60 iAppUi->RemoveFromViewStack( *this, iPSUIContainer ); |
|
61 delete iPSUIContainer; |
|
62 iPSUIContainer = NULL; |
|
63 } |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CPSUIGSPluginSettingView::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CPSUIGSPluginSettingView::ConstructL() |
|
72 { |
|
73 // base construct |
|
74 iAppUi = AppUi(); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CPSUIGSPluginSettingView::NewL() |
|
79 // Two-phased constructor. |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CPSUIGSPluginSettingView* CPSUIGSPluginSettingView::NewL( CPSUIGSPlugin* aMainView ) |
|
83 { |
|
84 CPSUIGSPluginSettingView* self = new( ELeave ) CPSUIGSPluginSettingView( aMainView ); |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL(); |
|
87 CleanupStack::Pop( self ); |
|
88 return self; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CPSUIGSPluginSettingView::Id() |
|
93 // See header for details. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TUid CPSUIGSPluginSettingView::Id() const |
|
97 { |
|
98 return KPreSettingViewId; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CPSUIGSPluginSettingView::HandleViewRectChange() |
|
103 // See header for details. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CPSUIGSPluginSettingView::HandleViewRectChange() |
|
107 { |
|
108 if ( iPSUIContainer && iPSUIContainer->ListBox() ) |
|
109 { |
|
110 iPSUIContainer->SetRect( ClientRect() ); |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CPSUIGSPluginSettingView::DoActivateL() |
|
116 // See header for details. |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 void CPSUIGSPluginSettingView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
120 TUid /*aCustomMessageId*/, |
|
121 const TDesC8& /*aCustomMessage*/ ) |
|
122 { |
|
123 iPrevViewId = aPrevViewId; |
|
124 |
|
125 CreateContainerL(); |
|
126 iAppUi->AddToViewStackL( *this, iPSUIContainer ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CPSUIGSPluginSettingView::DoDeactivate() |
|
131 // See header for details. |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CPSUIGSPluginSettingView::DoDeactivate() |
|
135 { |
|
136 if ( iPSUIContainer ) |
|
137 { |
|
138 iAppUi->RemoveFromViewStack( *this, iPSUIContainer ); |
|
139 delete iPSUIContainer; |
|
140 iPSUIContainer = NULL; |
|
141 } |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CPSUIGSPluginSettingView::HandleCommandL() |
|
146 // See header for details. |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CPSUIGSPluginSettingView::HandleCommandL( TInt aCommand ) |
|
150 { |
|
151 switch ( aCommand ) |
|
152 { |
|
153 case EAknSoftkeyBack: |
|
154 { |
|
155 HandleBackKeyL(); |
|
156 break; |
|
157 } |
|
158 case EPSUICmdChange: |
|
159 { |
|
160 iPSUIContainer->EditCurrentItemL(); |
|
161 break; |
|
162 } |
|
163 case EAknCmdHelp: |
|
164 { |
|
165 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
166 { |
|
167 HlpLauncher::LaunchHelpApplicationL( |
|
168 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
169 } |
|
170 break; |
|
171 } |
|
172 default: |
|
173 { |
|
174 if ( EEikCmdExit == aCommand ) |
|
175 { |
|
176 HandleMenuExitL(); |
|
177 } |
|
178 |
|
179 iAppUi->HandleCommandL( aCommand ); |
|
180 break; |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CPSUIGSPluginSettingView::CreateContainerL() |
|
187 // See header for details. |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CPSUIGSPluginSettingView::CreateContainerL() |
|
191 { |
|
192 // delete container if present |
|
193 if( iPSUIContainer ) |
|
194 { |
|
195 iAppUi->RemoveFromViewStack( *this, iPSUIContainer ); |
|
196 delete iPSUIContainer; |
|
197 iPSUIContainer = NULL; |
|
198 } |
|
199 |
|
200 // check the data |
|
201 iMainView->PSModel()->ClearInvalidSIPAndXDMSettingsL(); |
|
202 |
|
203 // create container |
|
204 iPSUIContainer = new ( ELeave ) CPSUIGSPluginSettingViewContainer( this ); |
|
205 iPSUIContainer->SetMopParent( this ); |
|
206 iPSUIContainer->ConstructL( ClientRect() ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CPSUIGSPluginSettingView::HandleBackKeyL() |
|
211 // See header for details. |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CPSUIGSPluginSettingView::HandleBackKeyL() |
|
215 { |
|
216 CPSUIGSPluginModel* psModel = iMainView->PSModel();// not owned |
|
217 |
|
218 TBool okToGoBack = ETrue; |
|
219 TBool okToSave = ETrue; |
|
220 psModel->ClearInvalidSIPAndXDMSettingsL(); |
|
221 const TInt id = psModel->SettingsId(); |
|
222 |
|
223 // compulsory-field handling |
|
224 if ( !psModel->AllCompulsoryFieldsFilled()) |
|
225 {// empty compulsory fields found |
|
226 okToSave = EFalse; |
|
227 } |
|
228 |
|
229 // same name checking |
|
230 if ( okToSave && HandleDuplicatePSNamesL() ) |
|
231 {// same name found |
|
232 okToGoBack = EFalse; |
|
233 okToSave = EFalse; |
|
234 iPSUIContainer->EditItemL( EPSUIServerNameId, ETrue ); |
|
235 } |
|
236 |
|
237 if ( okToSave ) |
|
238 {// save settings |
|
239 psModel->SaveSettingsL(); |
|
240 } |
|
241 else if ( !okToSave && okToGoBack && id ) |
|
242 {// old settings, delete and go back |
|
243 psModel->DeleteSettingsL( id, EFalse ); |
|
244 } |
|
245 if ( okToGoBack ) |
|
246 {// go back, no save or delete |
|
247 iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid ); |
|
248 } |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CPSUIGSPluginSettingView::HandleMenuExitL() |
|
253 // See header for details. |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 void CPSUIGSPluginSettingView::HandleMenuExitL() |
|
257 { |
|
258 CPSUIGSPluginModel* psModel = iMainView->PSModel();// not owned |
|
259 if ( !psModel ) |
|
260 {// no model, can't do anything |
|
261 // (leaving would stop exiting, so just return) |
|
262 return; |
|
263 } |
|
264 |
|
265 if ( psModel->AllCompulsoryFieldsFilled() ) |
|
266 {// needed fields filled, proceed saving |
|
267 if ( psModel->IsItDuplicatePSName() ) |
|
268 {// a dupe name -> change name |
|
269 HBufC* newName = psModel->CreateSettingNameLC( |
|
270 psModel->SettingsSet().iSetName.AllocL() ); |
|
271 psModel->SettingsSet().iSetName.Copy( newName->Des() ); |
|
272 CleanupStack::PopAndDestroy( newName ); |
|
273 } |
|
274 // save settings |
|
275 psModel->SaveSettingsL(); |
|
276 } |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // CPSUIGSPluginSettingView::HandleDuplicatePSNamesL() |
|
281 // See header for details. |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 TBool CPSUIGSPluginSettingView::HandleDuplicatePSNamesL() |
|
285 { |
|
286 TBool found = iMainView->PSModel()->IsItDuplicatePSName(); |
|
287 return found; |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // CPSUIGSPluginSettingView::MainView() |
|
292 // See header for details. |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 CPSUIGSPlugin* CPSUIGSPluginSettingView::MainView() |
|
296 { |
|
297 return iMainView; |
|
298 } |
|
299 |
|
300 // End of file |
|