|
1 /* |
|
2 * Copyright (c) 2003 - 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 * Handles commands given through the UI for maintaining policy servers. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <aknmessagequerydialog.h> |
|
23 #include <aknnotewrappers.h> // for warning & information notes |
|
24 #include <vpnmanagementuirsc.rsg> |
|
25 #include "vpnuiloader.h" |
|
26 #include "vpnmanagementuiserverview.h" |
|
27 #include "vpnmanagementuiservercontainer.h" |
|
28 #include "vpnmanagementui.hrh" |
|
29 #ifdef __SERIES60_HELP |
|
30 #include <hlplch.h> // For HlpLauncher |
|
31 #endif //__SERIES60_HELP |
|
32 |
|
33 /** MSK control Id. */ |
|
34 const TInt KVpnMSKControlId = 3; |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CVpnManagementUiServerView::CVpnManagementUiServerView(CVpnUiLoader& aLoader) |
|
40 // : iLoader(aLoader) |
|
41 // Constructor |
|
42 // --------------------------------------------------------- |
|
43 // |
|
44 CVpnManagementUiServerView::CVpnManagementUiServerView( CVpnUiLoader& aLoader ) |
|
45 : iLoader(aLoader) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CVpnManagementUiServerView::~CVpnManagementUiServerView() |
|
51 // Destructor |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 CVpnManagementUiServerView::~CVpnManagementUiServerView() |
|
55 { |
|
56 if ( iServerContainer ) |
|
57 { |
|
58 AppUi()->RemoveFromViewStack(*this, iServerContainer); |
|
59 delete iServerContainer; |
|
60 } |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CVpnManagementUiServerView* CVpnManagementUiServerView::NewL( |
|
65 // const TRect& /*aRect*/, CVpnUiLoader& aLoader) |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 CVpnManagementUiServerView* CVpnManagementUiServerView::NewL( |
|
69 const TRect& /*aRect*/, CVpnUiLoader& aLoader ) |
|
70 { |
|
71 CVpnManagementUiServerView* self = |
|
72 new ( ELeave ) CVpnManagementUiServerView( aLoader ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop(); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CVpnManagementUiServerView* CVpnManagementUiServerView::NewLC( |
|
81 // const TRect& /*aRect*/, CVpnUiLoader& aLoader) |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 CVpnManagementUiServerView* CVpnManagementUiServerView::NewLC( |
|
85 const TRect& /*aRect*/, CVpnUiLoader& aLoader ) |
|
86 { |
|
87 CVpnManagementUiServerView* self = |
|
88 new ( ELeave ) CVpnManagementUiServerView( aLoader ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CVpnManagementUiServerView::ConstructL() |
|
96 // CVpnUiView::ConstructL(const TRect& aRect) |
|
97 // EPOC two-phased constructor |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 void CVpnManagementUiServerView::ConstructL() |
|
101 { |
|
102 BaseConstructL( R_VPNUI_POLICY_SERVERS_VIEW ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CVpnManagementUiServerView::DynInitMenuPaneL( |
|
107 // TInt aResourceId,CEikMenuPane* aMenuPane) |
|
108 // Updates Options list with correct items depending on |
|
109 // whether the listbox is empty or if it has any marked items |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CVpnManagementUiServerView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
113 { |
|
114 |
|
115 if ( aResourceId == R_VPNUI_POLICY_SERVERS_VIEW_MENU ) |
|
116 { |
|
117 TInt currentItem = iServerContainer->iListBox->CurrentItemIndex(); |
|
118 |
|
119 // the policy server list is empty all except Add new server, Help and Exit is dimmed |
|
120 if ( currentItem == -1 ) |
|
121 { |
|
122 aMenuPane->SetItemDimmed( EVpnUiCmdEditServer, ETrue ); |
|
123 aMenuPane->SetItemDimmed( EVpnUiCmdSynchronise, ETrue ); |
|
124 aMenuPane->SetItemDimmed( EVpnUiCmdDeleteServer, ETrue ); |
|
125 } |
|
126 } |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CVpnManagementUiServerView::Id() const |
|
131 // Returns Authority view id |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 TUid CVpnManagementUiServerView::Id() const |
|
135 { |
|
136 return KVpnManagementUiServerViewId; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CVpnManagementUiServerView::HandleCommandL(TInt aCommand) |
|
141 // Handles Softkey and Options list commands |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 void CVpnManagementUiServerView::HandleCommandL( TInt aCommand ) |
|
145 { |
|
146 TBool ffsLow; |
|
147 |
|
148 switch ( aCommand ) |
|
149 { |
|
150 case EAknSoftkeyBack: |
|
151 { |
|
152 iLoader.ChangeViewL( KChangeViewPrevious ); |
|
153 break; |
|
154 } |
|
155 case EAknCmdExit: |
|
156 { |
|
157 ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit ); |
|
158 break; |
|
159 } |
|
160 |
|
161 case EVpnUiCmdEditServer: |
|
162 { |
|
163 ffsLow = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 ); |
|
164 if (!ffsLow) |
|
165 { |
|
166 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
167 iLoader.ChangeViewL(KChangeViewSettings, iCurrentPosition); |
|
168 } |
|
169 break; |
|
170 } |
|
171 |
|
172 case EVpnUiCmdAddServer: |
|
173 { |
|
174 ffsLow = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 ); |
|
175 if(!ffsLow) |
|
176 { |
|
177 iLoader.ChangeViewL(KChangeViewSettings); |
|
178 } |
|
179 break; |
|
180 } |
|
181 case EVpnUiCmdSynchronise: |
|
182 { |
|
183 ffsLow = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 ); |
|
184 if(!ffsLow) |
|
185 { |
|
186 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
187 iServerContainer->SynchroniseServerL(iCurrentPosition); |
|
188 } |
|
189 break; |
|
190 } |
|
191 |
|
192 case EVpnUiCmdDeleteServer: |
|
193 { |
|
194 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
195 iServerContainer->DeleteServerL(iCurrentPosition); |
|
196 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
197 break; |
|
198 } |
|
199 |
|
200 #ifdef __SERIES60_HELP |
|
201 case EAknCmdHelp: |
|
202 { |
|
203 HlpLauncher::LaunchHelpApplicationL( |
|
204 iEikonEnv->WsSession(), AppUi()->AppHelpContextL() ); |
|
205 break; |
|
206 } |
|
207 #endif //__SERIES60_HELP |
|
208 |
|
209 default: |
|
210 { |
|
211 AppUi()->HandleCommandL( aCommand ); |
|
212 break; |
|
213 } |
|
214 } |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------- |
|
218 // CVpnManagementUiServerView::HandleClientRectChange() |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 void CVpnManagementUiServerView::HandleClientRectChange() |
|
222 { |
|
223 if ( iServerContainer ) |
|
224 { |
|
225 iServerContainer->SetRect( ClientRect() ); |
|
226 } |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------- |
|
230 // CVpnManagementUiServerView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
231 // TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
232 // Updates the view when opening it |
|
233 // --------------------------------------------------------- |
|
234 // |
|
235 void CVpnManagementUiServerView::DoActivateL( |
|
236 const TVwsViewId& /*aPrevViewId*/, |
|
237 TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
238 { |
|
239 if ( iServerContainer ) |
|
240 { |
|
241 ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( |
|
242 *this, iServerContainer ); |
|
243 } |
|
244 iServerContainer = new (ELeave) CVpnManagementUiServerContainer( |
|
245 *this, iLoader ); |
|
246 |
|
247 iServerContainer->SetMopParent( this ); |
|
248 iServerContainer->ConstructL( |
|
249 ClientRect(), iCurrentPosition, iTopItem ); |
|
250 iLoader.ActivateTitleL( KViewTitleServerView ); |
|
251 iLoader.PushDefaultNaviPaneL(); |
|
252 |
|
253 ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iServerContainer ); |
|
254 iServerContainer->DrawListBoxL( iCurrentPosition, iTopItem ); |
|
255 |
|
256 // Add MiddleSoftKey |
|
257 SetMiddleSoftKeyL(EFalse); |
|
258 } |
|
259 |
|
260 void CVpnManagementUiServerView::SetMiddleSoftKeyL(TBool aDrawNow) |
|
261 { |
|
262 if (iServerContainer->iListItemCount > 0) |
|
263 { |
|
264 SetMiddleSoftKeyLabelL(R_MSK_EDIT, EVpnUiCmdEditServer); |
|
265 } |
|
266 else |
|
267 { |
|
268 SetMiddleSoftKeyLabelL(R_MSK_ADD_VPN_SERVER, EVpnUiCmdAddServer); |
|
269 } |
|
270 |
|
271 if (aDrawNow) |
|
272 { |
|
273 if (Cba()) |
|
274 Cba()->DrawNow(); |
|
275 } |
|
276 } |
|
277 |
|
278 |
|
279 void CVpnManagementUiServerView::SetMiddleSoftKeyLabelL(TInt aResourceId, TInt aCommandId) |
|
280 { |
|
281 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
282 if (cbaGroup) |
|
283 { |
|
284 cbaGroup->RemoveCommandFromStack(KVpnMSKControlId, EVpnUiCmdEditServer); |
|
285 cbaGroup->RemoveCommandFromStack(KVpnMSKControlId, EVpnUiCmdAddServer); |
|
286 HBufC* text = StringLoader::LoadLC(aResourceId); |
|
287 cbaGroup->AddCommandToStackL(KVpnMSKControlId, aCommandId, text->Des()); |
|
288 CleanupStack::PopAndDestroy(text); |
|
289 } |
|
290 } |
|
291 |
|
292 |
|
293 // --------------------------------------------------------- |
|
294 // CVpnManagementUiServerView::DoDeactivate() |
|
295 // Saves focus position when closing view |
|
296 // --------------------------------------------------------- |
|
297 // |
|
298 void CVpnManagementUiServerView::DoDeactivate() |
|
299 { |
|
300 if ( iServerContainer ) |
|
301 { |
|
302 AppUi()->RemoveFromViewStack( *this, iServerContainer ); |
|
303 |
|
304 delete iServerContainer; |
|
305 iServerContainer = NULL; |
|
306 } |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------- |
|
310 // CVpnManagementUiServerView::Container() |
|
311 // Returns iServerContainer |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 CCoeControl* CVpnManagementUiServerView::Container() |
|
315 { |
|
316 return iServerContainer; |
|
317 } |
|
318 |
|
319 // End of File |
|
320 |