|
1 /* |
|
2 * Copyright (c) 2005-2009 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: VPN management main view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknViewAppUi.h> |
|
22 #include <avkon.hrh> |
|
23 #include <vpnmanagementuirsc.rsg> |
|
24 #include <settingsinternalcrkeys.h> |
|
25 #include <centralrepository.h> |
|
26 #include <bautils.h> |
|
27 #include <vpnmanagementui.mbg> |
|
28 #include "vpnmanagementui.hrh" |
|
29 #include "vpnuiloader.h" |
|
30 #include "vpnmanagementuiview.h" |
|
31 #include "vpnmanagementuicontainer.h" |
|
32 #include "vpnmanagementuiviewid.h" |
|
33 #include "log_vpnmanagementui.h" |
|
34 |
|
35 /** MSK control Id. */ |
|
36 const TInt KVpnMSKControlId = 3; |
|
37 |
|
38 |
|
39 // ROM folder |
|
40 |
|
41 // Name of the MBM file containing icons |
|
42 _LIT( KFileIcons, "vpnmanagementui.mbm"); |
|
43 |
|
44 // Constants |
|
45 enum TVpnUiCommands |
|
46 { |
|
47 KVpnUiPolicyViewListItemId, |
|
48 KVpnUiLogViewListItemId |
|
49 }; |
|
50 |
|
51 // ================= MEMBER FUNCTIONS ======================= |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CVpnManagementUiView::CVpnManagementUiView() |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CVpnManagementUiView::CVpnManagementUiView() |
|
58 { |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CVpnManagementUiView::~CVpnManagementUiView() |
|
63 // Destructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CVpnManagementUiView::~CVpnManagementUiView() |
|
67 { |
|
68 LOG_("CVpnManagementUiView::~CVpnManagementUiView entered"); |
|
69 if ( iContainer ) |
|
70 { |
|
71 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
72 delete iContainer; |
|
73 } |
|
74 delete iLoader; |
|
75 LOG_("CVpnManagementUiView::~CVpnManagementUiView() exited"); |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CVpnManagementUiView::NewL() |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CVpnManagementUiView* CVpnManagementUiView::NewL() |
|
84 { |
|
85 LOG_("CVpnManagementUiView::NewL() entered"); |
|
86 CVpnManagementUiView* self = NewLC(); |
|
87 CleanupStack::Pop(); |
|
88 LOG_("CVpnManagementUiView::NewL() exited"); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CVpnManagementUiView::NewLC() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CVpnManagementUiView* CVpnManagementUiView::NewLC() |
|
97 { |
|
98 LOG_("CVpnManagementUiView::NewLC() entered"); |
|
99 CVpnManagementUiView* self = new ( ELeave ) CVpnManagementUiView(); |
|
100 CleanupStack::PushL( self ); |
|
101 self->ConstructL(); |
|
102 return self; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CVpnManagementUiView::ConstructL() |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CVpnManagementUiView::ConstructL() |
|
111 { |
|
112 LOG_("CVpnManagementUiView::ConstructL() entered"); |
|
113 iLoader = CVpnUiLoader::NewL(iAvkonViewAppUi->ClientRect(), |
|
114 KVpnManagementPluginUid, this ); |
|
115 BaseConstructL( R_VPNUI_MANAGEMENT_VIEW ); |
|
116 iLoader->ReleaseResource(); |
|
117 LOG_("CVpnManagementUiView::ConstructL() exited"); |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // void CVpnManagementUiView::GetCaptionL( TDes& aCaption ) const |
|
122 // --------------------------------------------------------------------------- |
|
123 void CVpnManagementUiView::GetCaptionL( TDes& aCaption ) const |
|
124 { |
|
125 LOG_("CVpnManagementUiView::GetCaptionL() entered"); |
|
126 iLoader->AddResourceFileL(); |
|
127 StringLoader::Load( aCaption, R_VPN_MANAGEMENT_TITLE_BUF ); |
|
128 iLoader->ReleaseResource(); |
|
129 LOG_("CVpnManagementUiView::GetCaptionL() exited"); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // TUid CVpnManagementUiView::Id() |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 TUid CVpnManagementUiView::Id() const |
|
137 { |
|
138 LOG_("CVpnManagementUiView::Id called"); |
|
139 return KVpnManagementPluginUid; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CVpnManagementUiView::HandleCommandL() |
|
144 // Handles commands directed to this class. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CVpnManagementUiView::HandleCommandL(TInt aCommand) |
|
148 { |
|
149 LOG_1("CVpnManagementUiView::HandleCommandL():%d", aCommand); |
|
150 switch ( aCommand ) |
|
151 { |
|
152 case EAknSoftkeyBack: |
|
153 { |
|
154 iLoader->ChangeViewL( KChangeViewBack ); |
|
155 break; |
|
156 } |
|
157 case EAknCmdExit: |
|
158 { |
|
159 ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit ); |
|
160 break; |
|
161 } |
|
162 case EVpnUiCmdOpen: |
|
163 { |
|
164 HandleListBoxSelectionL(); |
|
165 break; |
|
166 } |
|
167 |
|
168 #ifdef __SERIES60_HELP |
|
169 case EAknCmdHelp: |
|
170 { |
|
171 HlpLauncher::LaunchHelpApplicationL( |
|
172 iEikonEnv->WsSession(), AppUi()->AppHelpContextL() ); |
|
173 break; |
|
174 } |
|
175 #endif //__SERIES60_HELP |
|
176 |
|
177 default: |
|
178 { |
|
179 AppUi()->HandleCommandL( aCommand ); |
|
180 break; |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CVpnManagementUiView::HandleClientRectChange() |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CVpnManagementUiView::HandleClientRectChange() |
|
192 { |
|
193 if ( iContainer ) |
|
194 { |
|
195 iContainer->SetRect( ClientRect() ); |
|
196 } |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CVpnManagementUiView::DoActivateL() |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CVpnManagementUiView::DoActivateL( |
|
204 const TVwsViewId& aPrevViewId,TUid /*aCustomMessageId*/, |
|
205 const TDesC8& /*aCustomMessage*/) |
|
206 { |
|
207 LOG_("CVpnManagementUiView::DoActivateL() entered"); |
|
208 iLoader->AddResourceFileL(ETrue); |
|
209 if ( iLoader->GSViewId().iViewUid.iUid == 0 ) |
|
210 { |
|
211 //must be prepared to application switch, so it stores |
|
212 //only the parent view (General Settings Main View) |
|
213 iLoader->SetGSViewId( aPrevViewId ); |
|
214 |
|
215 } |
|
216 if ( iContainer ) |
|
217 { |
|
218 ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( |
|
219 *this, iContainer ); |
|
220 } |
|
221 iContainer = new (ELeave) CVpnManagementUiContainer( |
|
222 *this, *iLoader ); |
|
223 |
|
224 iContainer->SetMopParent( this ); |
|
225 iContainer->ConstructL( ClientRect() ); |
|
226 iLoader->ActivateTitleL( KViewTitleManagementView ); |
|
227 iLoader->PushDefaultNaviPaneL(); |
|
228 |
|
229 ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iContainer ); |
|
230 iContainer->DrawListBoxL( iCurrentItem, iTopItemIndex ); |
|
231 |
|
232 //Listbox observer is set here, instead create listbox |
|
233 iContainer->iListBox->SetListBoxObserver(this); |
|
234 |
|
235 // Add MiddleSoftKey |
|
236 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
237 if (cbaGroup) |
|
238 { |
|
239 HBufC* text = StringLoader::LoadLC(R_MSK_OPEN); |
|
240 cbaGroup->AddCommandToStackL( |
|
241 KVpnMSKControlId, EVpnUiCmdOpen, text->Des()); |
|
242 CleanupStack::PopAndDestroy(text); |
|
243 } |
|
244 LOG_("CVpnManagementUiView::DoActivateL() exited"); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CVpnManagementUiView::HandleCommandL() |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 void CVpnManagementUiView::DoDeactivate() |
|
252 { |
|
253 LOG_("CVpnManagementUiView::DoDeactivate() entered"); |
|
254 if ( iContainer ) |
|
255 { |
|
256 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
257 |
|
258 delete iContainer; |
|
259 iContainer = NULL; |
|
260 } |
|
261 LOG_("CVpnManagementUiView::DoDeactivate() exited"); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CVpnManagementUiView::HandleListBoxEventL |
|
266 // --------------------------------------------------------------------------- |
|
267 |
|
268 void CVpnManagementUiView::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
269 TListBoxEvent aEventType) |
|
270 { |
|
271 switch (aEventType) |
|
272 { |
|
273 case EEventEnterKeyPressed: |
|
274 case EEventItemSingleClicked: |
|
275 HandleListBoxSelectionL(); |
|
276 break; |
|
277 default: |
|
278 break; |
|
279 } |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CVpnManagementUiView::HandleListBoxSelectionL() |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 void CVpnManagementUiView::HandleListBoxSelectionL() |
|
287 { |
|
288 ASSERT(iContainer && iContainer->iListBox && iLoader); |
|
289 iCurrentItem = iContainer->iListBox->CurrentItemIndex(); |
|
290 iTopItemIndex = iContainer->iListBox->TopItemIndex(); |
|
291 switch (iCurrentItem) |
|
292 { |
|
293 case KVpnUiPolicyViewListItemId: |
|
294 iLoader->ChangeViewL(KChangeViewPolicy); |
|
295 break; |
|
296 |
|
297 /*** NSSM support is discontinued. The code is left here in comments |
|
298 because the server view might be used for another purpose in |
|
299 future. |
|
300 case KVpnUiServerViewListItemId: |
|
301 iLoader->ChangeViewL(KChangeViewServer); |
|
302 break; |
|
303 ***/ |
|
304 |
|
305 case KVpnUiLogViewListItemId: |
|
306 iLoader->ChangeViewL(KChangeViewLog); |
|
307 break; |
|
308 |
|
309 default: |
|
310 LOG_("CVpnManagementUiView::HandleListBoxSelectionL default"); |
|
311 break; |
|
312 } |
|
313 } |
|
314 |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CVpnManagementUiView::NotifyPolicyImportComplete() |
|
318 // --------------------------------------------------------------------------- |
|
319 void CVpnManagementUiView::NotifyPolicyImportComplete(TInt aResult) |
|
320 { |
|
321 if ( aResult != KErrNone) |
|
322 LOG_1("CVpnManagementUiView::NotifyPolicyImportComplete:%d", aResult); |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CVpnManagementUiView::HasBitmap |
|
327 // --------------------------------------------------------------------------- |
|
328 TBool CVpnManagementUiView::HasBitmap() const |
|
329 { |
|
330 LOG_("CVpnManagementUiView::HasBitmap() called"); |
|
331 return EFalse; |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // CVpnManagementUiView::GetBitmapL |
|
336 // --------------------------------------------------------------------------- |
|
337 void CVpnManagementUiView::GetBitmapL( CFbsBitmap* /*aBitmap*/, |
|
338 CFbsBitmap* /*aMask*/ ) const |
|
339 { |
|
340 LOG_("CVpnManagementUiView::GetBitmapL() entered"); |
|
341 //no bitmap |
|
342 User::Leave( KErrNotFound ); |
|
343 LOG_("CVpnManagementUiView::GetBitmapL() exited"); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // CVpnManagementUiView::PluginProviderCategory |
|
348 // --------------------------------------------------------------------------- |
|
349 TInt CVpnManagementUiView::PluginProviderCategory() const |
|
350 { |
|
351 LOG_("CVpnManagementUiView::PluginProviderCategory() called"); |
|
352 return EGSPluginProviderOEM; |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CVpnManagementUiView::CreateIconL |
|
357 // --------------------------------------------------------------------------- |
|
358 CGulIcon* CVpnManagementUiView::CreateIconL( const TUid aIconType ) |
|
359 { |
|
360 LOG_("CVpnManagementUiView::CreateIconL() entered"); |
|
361 |
|
362 TFileName iconsFileName; |
|
363 TFileName dllName; |
|
364 Dll::FileName(dllName); |
|
365 TBuf<2> drive = dllName.Left(2); |
|
366 iconsFileName.Insert(0, drive); |
|
367 |
|
368 |
|
369 iconsFileName.Append( KDC_APP_BITMAP_DIR ); |
|
370 iconsFileName.Append( KFileIcons ); |
|
371 |
|
372 CGulIcon* icon; |
|
373 |
|
374 if( aIconType == KGSIconTypeLbxItem ) |
|
375 { |
|
376 icon = AknsUtils::CreateGulIconL( |
|
377 AknsUtils::SkinInstance(), |
|
378 KAknsIIDQgnPropSetConnVpn, |
|
379 iconsFileName, |
|
380 EMbmVpnmanagementuiQgn_prop_set_conn_vpn, |
|
381 EMbmVpnmanagementuiQgn_prop_set_conn_vpn_mask ); |
|
382 } |
|
383 else |
|
384 { |
|
385 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
386 } |
|
387 LOG_("CVpnManagementUiView::CreateIconL() exited"); |
|
388 return icon; |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // CVpnManagementUiView::Visible |
|
393 // --------------------------------------------------------------------------- |
|
394 TBool CVpnManagementUiView::Visible() const |
|
395 { |
|
396 LOG_("CVpnManagementUiView::Visible() entered"); |
|
397 TInt vpnSupported( 0 ); |
|
398 TInt readError(0); |
|
399 TRAPD(loadError, |
|
400 { |
|
401 CRepository* repository = CRepository::NewL(KCRUidCommunicationSettings); |
|
402 readError = repository->Get(KSettingsVPNSupported, vpnSupported); |
|
403 delete repository; |
|
404 }); |
|
405 LOG_1("CVpnManagementUiView::Visible():%d exited", vpnSupported); |
|
406 return (vpnSupported && !readError && !loadError) ? ETrue : EFalse; |
|
407 } |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // CVpnManagementUiView::PluginUid |
|
411 // --------------------------------------------------------------------------- |
|
412 TUid CVpnManagementUiView::PluginUid() const |
|
413 { |
|
414 LOG_("CVpnManagementUiView::PluginUid() called"); |
|
415 return KVpnManagementPluginUid; |
|
416 } |
|
417 |
|
418 // End of File |
|
419 |