|
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 else |
|
127 aMenuPane->SetItemDimmed( EVpnUiCmdAddServer, ETrue ); |
|
128 } |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // CVpnManagementUiServerView::Id() const |
|
133 // Returns Authority view id |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 TUid CVpnManagementUiServerView::Id() const |
|
137 { |
|
138 return KVpnManagementUiServerViewId; |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CVpnManagementUiServerView::HandleCommandL(TInt aCommand) |
|
143 // Handles Softkey and Options list commands |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CVpnManagementUiServerView::HandleCommandL( TInt aCommand ) |
|
147 { |
|
148 TBool ffsLow; |
|
149 |
|
150 switch ( aCommand ) |
|
151 { |
|
152 case EAknSoftkeyBack: |
|
153 { |
|
154 iLoader.ChangeViewL( KChangeViewPrevious ); |
|
155 break; |
|
156 } |
|
157 case EAknCmdExit: |
|
158 { |
|
159 ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit ); |
|
160 break; |
|
161 } |
|
162 |
|
163 case EVpnUiCmdEditServer: |
|
164 { |
|
165 ffsLow = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 ); |
|
166 if (!ffsLow) |
|
167 { |
|
168 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
169 iLoader.ChangeViewL(KChangeViewSettings, iCurrentPosition); |
|
170 } |
|
171 break; |
|
172 } |
|
173 |
|
174 case EVpnUiCmdAddServer: |
|
175 { |
|
176 ffsLow = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 ); |
|
177 if(!ffsLow) |
|
178 { |
|
179 iLoader.ChangeViewL(KChangeViewSettings); |
|
180 } |
|
181 break; |
|
182 } |
|
183 case EVpnUiCmdSynchronise: |
|
184 { |
|
185 ffsLow = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 ); |
|
186 if(!ffsLow) |
|
187 { |
|
188 iServerContainer->SynchroniseServerL(); |
|
189 } |
|
190 break; |
|
191 } |
|
192 |
|
193 case EVpnUiCmdDeleteServer: |
|
194 { |
|
195 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
196 iServerContainer->DeleteServerL(iCurrentPosition); |
|
197 iCurrentPosition = iServerContainer->iListBox->CurrentItemIndex(); |
|
198 break; |
|
199 } |
|
200 |
|
201 #ifdef __SERIES60_HELP |
|
202 case EAknCmdHelp: |
|
203 { |
|
204 HlpLauncher::LaunchHelpApplicationL( |
|
205 iEikonEnv->WsSession(), AppUi()->AppHelpContextL() ); |
|
206 break; |
|
207 } |
|
208 #endif //__SERIES60_HELP |
|
209 |
|
210 default: |
|
211 { |
|
212 AppUi()->HandleCommandL( aCommand ); |
|
213 break; |
|
214 } |
|
215 } |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CVpnManagementUiServerView::HandleClientRectChange() |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CVpnManagementUiServerView::HandleClientRectChange() |
|
223 { |
|
224 if ( iServerContainer ) |
|
225 { |
|
226 iServerContainer->SetRect( ClientRect() ); |
|
227 } |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------- |
|
231 // CVpnManagementUiServerView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
232 // TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
233 // Updates the view when opening it |
|
234 // --------------------------------------------------------- |
|
235 // |
|
236 void CVpnManagementUiServerView::DoActivateL( |
|
237 const TVwsViewId& /*aPrevViewId*/, |
|
238 TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
239 { |
|
240 if ( iServerContainer ) |
|
241 { |
|
242 ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( |
|
243 *this, iServerContainer ); |
|
244 } |
|
245 iServerContainer = new (ELeave) CVpnManagementUiServerContainer( |
|
246 *this, iLoader ); |
|
247 |
|
248 iServerContainer->SetMopParent( this ); |
|
249 iServerContainer->ConstructL( |
|
250 ClientRect(), iCurrentPosition, iTopItem ); |
|
251 iLoader.ActivateTitleL( KViewTitleServerView ); |
|
252 iLoader.PushDefaultNaviPaneL(); |
|
253 |
|
254 ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iServerContainer ); |
|
255 iServerContainer->DrawListBoxL( iCurrentPosition, iTopItem ); |
|
256 |
|
257 // Add MiddleSoftKey |
|
258 SetMiddleSoftKeyL(EFalse); |
|
259 } |
|
260 |
|
261 void CVpnManagementUiServerView::SetMiddleSoftKeyL(TBool aDrawNow) |
|
262 { |
|
263 if (iServerContainer->iListItemCount > 0) |
|
264 { |
|
265 SetMiddleSoftKeyLabelL(R_MSK_EDIT, EVpnUiCmdEditServer); |
|
266 } |
|
267 else |
|
268 { |
|
269 SetMiddleSoftKeyLabelL(R_MSK_ADD_VPN_SERVER, EVpnUiCmdAddServer); |
|
270 } |
|
271 |
|
272 if (aDrawNow) |
|
273 { |
|
274 if (Cba()) |
|
275 Cba()->DrawNow(); |
|
276 } |
|
277 } |
|
278 |
|
279 |
|
280 void CVpnManagementUiServerView::SetMiddleSoftKeyLabelL(TInt aResourceId, TInt aCommandId) |
|
281 { |
|
282 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
283 if (cbaGroup) |
|
284 { |
|
285 cbaGroup->RemoveCommandFromStack(KVpnMSKControlId, EVpnUiCmdEditServer); |
|
286 cbaGroup->RemoveCommandFromStack(KVpnMSKControlId, EVpnUiCmdAddServer); |
|
287 HBufC* text = StringLoader::LoadLC(aResourceId); |
|
288 cbaGroup->AddCommandToStackL(KVpnMSKControlId, aCommandId, text->Des()); |
|
289 CleanupStack::PopAndDestroy(text); |
|
290 } |
|
291 } |
|
292 |
|
293 |
|
294 // --------------------------------------------------------- |
|
295 // CVpnManagementUiServerView::DoDeactivate() |
|
296 // Saves focus position when closing view |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 void CVpnManagementUiServerView::DoDeactivate() |
|
300 { |
|
301 if ( iServerContainer ) |
|
302 { |
|
303 AppUi()->RemoveFromViewStack( *this, iServerContainer ); |
|
304 |
|
305 delete iServerContainer; |
|
306 iServerContainer = NULL; |
|
307 } |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // CVpnManagementUiServerView::Container() |
|
312 // Returns iServerContainer |
|
313 // --------------------------------------------------------- |
|
314 // |
|
315 CCoeControl* CVpnManagementUiServerView::Container() |
|
316 { |
|
317 return iServerContainer; |
|
318 } |
|
319 |
|
320 // End of File |
|
321 |