41
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-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 Policy view
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <aknmessagequerydialog.h>
|
|
22 |
#include <aknnotewrappers.h> // for warning & information notes
|
|
23 |
#include <vpnmanagementuirsc.rsg>
|
|
24 |
#include <cdblen.h>
|
|
25 |
|
|
26 |
#include "vpnuiloader.h"
|
|
27 |
#include "vpnmanagementuipolicyview.h"
|
|
28 |
#include "vpnmanagementuipolicycontainer.h"
|
|
29 |
#include "vpnmanagementui.hrh"
|
|
30 |
#ifdef __SERIES60_HELP
|
|
31 |
#include <hlplch.h> // For HlpLauncher
|
|
32 |
#endif //__SERIES60_HELP
|
|
33 |
|
|
34 |
/** MSK control Id. */
|
|
35 |
const TInt KVpnMSKControlId = 3;
|
|
36 |
|
|
37 |
// ================= MEMBER FUNCTIONS =======================
|
|
38 |
|
|
39 |
// ---------------------------------------------------------
|
|
40 |
// CVpnManagementUiPolicyView::CVpnManagementUiPolicyView
|
|
41 |
// ---------------------------------------------------------
|
|
42 |
//
|
|
43 |
CVpnManagementUiPolicyView::CVpnManagementUiPolicyView(
|
|
44 |
CVpnUiLoader& aLoader ) : iLoader(aLoader)
|
|
45 |
{
|
|
46 |
}
|
|
47 |
|
|
48 |
// ---------------------------------------------------------
|
|
49 |
// CVpnManagementUiPolicyView::~CVpnManagementUiPolicyView()
|
|
50 |
// Destructor
|
|
51 |
// ---------------------------------------------------------
|
|
52 |
//
|
|
53 |
CVpnManagementUiPolicyView::~CVpnManagementUiPolicyView()
|
|
54 |
{
|
|
55 |
if ( iPolicyContainer )
|
|
56 |
{
|
|
57 |
AppUi()->RemoveFromViewStack(*this, iPolicyContainer);
|
|
58 |
delete iPolicyContainer;
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
// CVpnManagementUiPolicyView::NewL
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
//
|
|
66 |
CVpnManagementUiPolicyView* CVpnManagementUiPolicyView::NewL(
|
|
67 |
const TRect& aRect, CVpnUiLoader& aLoader )
|
|
68 |
{
|
|
69 |
CVpnManagementUiPolicyView* self = NewLC( aRect, aLoader );
|
|
70 |
CleanupStack::Pop( self );
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------
|
|
75 |
// CVpnManagementUiPolicyView::NewLC
|
|
76 |
// ---------------------------------------------------------
|
|
77 |
//
|
|
78 |
CVpnManagementUiPolicyView* CVpnManagementUiPolicyView::NewLC(
|
|
79 |
const TRect& /*aRect*/, CVpnUiLoader& aLoader )
|
|
80 |
{
|
|
81 |
CVpnManagementUiPolicyView* self =
|
|
82 |
new ( ELeave ) CVpnManagementUiPolicyView( aLoader );
|
|
83 |
CleanupStack::PushL( self );
|
|
84 |
self->ConstructL();
|
|
85 |
return self;
|
|
86 |
}
|
|
87 |
|
|
88 |
// ---------------------------------------------------------
|
|
89 |
// CVpnManagementUiPolicyView::ConstructL()
|
|
90 |
// EPOC two-phased constructor
|
|
91 |
// ---------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CVpnManagementUiPolicyView::ConstructL()
|
|
94 |
{
|
|
95 |
BaseConstructL( R_VPNUI_POLICIES_VIEW );
|
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------
|
|
99 |
// CVpnManagementUiPolicyView::DynInitMenuPaneL(
|
|
100 |
// TInt aResourceId,CEikMenuPane* aMenuPane)
|
|
101 |
// Updates Options list with correct items depending on
|
|
102 |
// whether the listbox is empty or if it has any marked items
|
|
103 |
// ---------------------------------------------------------
|
|
104 |
//
|
|
105 |
void CVpnManagementUiPolicyView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
|
|
106 |
{
|
|
107 |
if ( aResourceId == R_VPNUI_POLICIES_VIEW_MENU )
|
|
108 |
{
|
|
109 |
TInt currentItem = iPolicyContainer->iListBox->CurrentItemIndex();
|
|
110 |
|
|
111 |
if ( currentItem == -1 )
|
|
112 |
{
|
|
113 |
aMenuPane->SetItemDimmed( EVpnUiCmdPolicyDetails, ETrue );
|
|
114 |
aMenuPane->SetItemDimmed( EVpnUiCmdDeletePolicy, ETrue );
|
|
115 |
|
|
116 |
}
|
|
117 |
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------
|
|
122 |
// CVpnManagementUiPolicyView::Id() const
|
|
123 |
// Returns Authority view id
|
|
124 |
// ---------------------------------------------------------
|
|
125 |
//
|
|
126 |
TUid CVpnManagementUiPolicyView::Id() const
|
|
127 |
{
|
|
128 |
return KVpnManagementUiPolicyViewId;
|
|
129 |
}
|
|
130 |
|
|
131 |
// ---------------------------------------------------------
|
|
132 |
// CVpnManagementUiPolicyView::HandleCommandL(TInt aCommand)
|
|
133 |
// Handles Softkey and Options list commands
|
|
134 |
// ---------------------------------------------------------
|
|
135 |
//
|
|
136 |
void CVpnManagementUiPolicyView::HandleCommandL( TInt aCommand )
|
|
137 |
{
|
|
138 |
switch ( aCommand )
|
|
139 |
{
|
|
140 |
case EAknSoftkeyBack:
|
|
141 |
{
|
|
142 |
iLoader.ChangeViewL( KChangeViewPrevious );
|
|
143 |
break;
|
|
144 |
}
|
|
145 |
case EAknCmdExit:
|
|
146 |
{
|
|
147 |
((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit );
|
|
148 |
break;
|
|
149 |
}
|
|
150 |
|
|
151 |
case EVpnUiCmdPolicyDetails:
|
|
152 |
{
|
|
153 |
// Show details
|
|
154 |
PolicyDetailsL(iPolicyContainer->iListBox->CurrentItemIndex());
|
|
155 |
break;
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
case EVpnUiCmdDeletePolicy:
|
|
160 |
{
|
|
161 |
//confirmation query
|
|
162 |
HBufC* temp;
|
|
163 |
|
|
164 |
TVpnPolicyName policyName;
|
|
165 |
iCurrentPosition = iPolicyContainer->iListBox->CurrentItemIndex();
|
|
166 |
iTopItem = iPolicyContainer->iListBox->TopItemIndex();
|
|
167 |
|
|
168 |
if (NotAssociatedToIapL(iCurrentPosition, policyName))
|
|
169 |
{
|
|
170 |
temp = StringLoader::LoadLC( R_VPN_QUEST_DELETE_POLICY, policyName );
|
|
171 |
}
|
|
172 |
else
|
|
173 |
{
|
|
174 |
temp = StringLoader::LoadLC( R_VPN_QUEST_DELETE_POLICY_ASSOCIATED );
|
|
175 |
}
|
|
176 |
CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
|
|
177 |
TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
|
|
178 |
CleanupStack::PopAndDestroy(); // temp
|
|
179 |
if ( retval )
|
|
180 |
{
|
|
181 |
//Delete policy
|
|
182 |
iLoader.VpnApiWrapperL().DeletePolicyL(iPolicyContainer->iListBox->CurrentItemIndex());
|
|
183 |
//Update listbox
|
|
184 |
iPolicyContainer->UpdateListBoxL(iCurrentPosition);
|
|
185 |
//Update iPolicyList
|
|
186 |
iLoader.VpnApiWrapperL().PolicyListL();
|
|
187 |
iCurrentPosition = iPolicyContainer->iListBox->CurrentItemIndex();
|
|
188 |
}
|
|
189 |
break;
|
|
190 |
}
|
|
191 |
#ifdef __SERIES60_HELP
|
|
192 |
case EAknCmdHelp:
|
|
193 |
{
|
|
194 |
HlpLauncher::LaunchHelpApplicationL(
|
|
195 |
iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
#endif //__SERIES60_HELP
|
|
199 |
|
|
200 |
default:
|
|
201 |
{
|
|
202 |
AppUi()->HandleCommandL( aCommand );
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
// ---------------------------------------------------------
|
|
209 |
// CVpnManagementUiPolicyView::HandleClientRectChange()
|
|
210 |
// ---------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CVpnManagementUiPolicyView::HandleClientRectChange()
|
|
213 |
{
|
|
214 |
if ( iPolicyContainer )
|
|
215 |
{
|
|
216 |
iPolicyContainer->SetRect( ClientRect() );
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|
|
220 |
// ---------------------------------------------------------
|
|
221 |
// CVpnManagementUiPolicyView::DoActivateL
|
|
222 |
// Updates the view when opening it
|
|
223 |
// ---------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CVpnManagementUiPolicyView::DoActivateL(
|
|
226 |
const TVwsViewId& /*aPrevViewId*/,
|
|
227 |
TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
|
|
228 |
{
|
|
229 |
if ( iPolicyContainer )
|
|
230 |
{
|
|
231 |
((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack(
|
|
232 |
*this, iPolicyContainer );
|
|
233 |
}
|
|
234 |
iPolicyContainer = new (ELeave) CVpnManagementUiPolicyContainer(
|
|
235 |
*this, iLoader );
|
|
236 |
|
|
237 |
iPolicyContainer->SetMopParent( this );
|
|
238 |
iPolicyContainer->ConstructL(
|
|
239 |
ClientRect(), iCurrentPosition, iTopItem );
|
|
240 |
iLoader.ActivateTitleL( KViewTitlePolicyView );
|
|
241 |
iLoader.PushDefaultNaviPaneL();
|
|
242 |
|
|
243 |
((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iPolicyContainer );
|
|
244 |
iPolicyContainer->DrawListBoxL( iCurrentPosition, iTopItem );
|
|
245 |
|
|
246 |
SetMiddleSoftKeyL(EFalse);
|
|
247 |
}
|
|
248 |
|
|
249 |
void CVpnManagementUiPolicyView::SetMiddleSoftKeyL(TBool aDrawNow)
|
|
250 |
{
|
|
251 |
if (iPolicyContainer->iListItemCount > 0)
|
|
252 |
{
|
|
253 |
SetMiddleSoftKeyLabelL(R_MSK_VPN_DETAILS, EVpnUiCmdPolicyDetails);
|
|
254 |
}
|
|
255 |
else
|
|
256 |
{
|
|
257 |
SetMiddleSoftKeyLabelL(R_MSK_INSTALL_VPN_POLICIES, EVpnUiCmdInstallPolicies);
|
|
258 |
}
|
|
259 |
|
|
260 |
if (aDrawNow)
|
|
261 |
{
|
|
262 |
if (Cba())
|
|
263 |
Cba()->DrawNow();
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
|
|
268 |
void CVpnManagementUiPolicyView::SetMiddleSoftKeyLabelL(
|
|
269 |
TInt aResourceId, TInt aCommandId)
|
|
270 |
{
|
|
271 |
CEikButtonGroupContainer* cbaGroup = Cba();
|
|
272 |
if (cbaGroup)
|
|
273 |
{
|
|
274 |
HBufC* text = HBufC::NewLC(KMaxLengthTextDetailsBody);
|
|
275 |
ReadResourceL(*text, aResourceId);
|
|
276 |
cbaGroup->RemoveCommandFromStack(
|
|
277 |
KVpnMSKControlId, EVpnUiCmdPolicyDetails);
|
|
278 |
cbaGroup->AddCommandToStackL(
|
|
279 |
KVpnMSKControlId, aCommandId, text->Des());
|
|
280 |
CleanupStack::PopAndDestroy(text);
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
// ---------------------------------------------------------
|
|
285 |
// CVpnManagementUiPolicyView::DoDeactivate()
|
|
286 |
// Saves focus position when closing view
|
|
287 |
// ---------------------------------------------------------
|
|
288 |
//
|
|
289 |
void CVpnManagementUiPolicyView::DoDeactivate()
|
|
290 |
{
|
|
291 |
if ( iPolicyContainer )
|
|
292 |
{
|
|
293 |
AppUi()->RemoveFromViewStack( *this, iPolicyContainer );
|
|
294 |
|
|
295 |
delete iPolicyContainer;
|
|
296 |
iPolicyContainer = NULL;
|
|
297 |
}
|
|
298 |
}
|
|
299 |
|
|
300 |
// ---------------------------------------------------------
|
|
301 |
// CVpnManagementUiPolicyView::Container()
|
|
302 |
// Returns iPolicyContainer
|
|
303 |
// ---------------------------------------------------------
|
|
304 |
//
|
|
305 |
CCoeControl* CVpnManagementUiPolicyView::Container()
|
|
306 |
{
|
|
307 |
return iPolicyContainer;
|
|
308 |
}
|
|
309 |
|
|
310 |
// ---------------------------------------------------------
|
|
311 |
// CVpnManagementUiPolicyView::PolicyDetailsL()
|
|
312 |
// Creates the whole of policy details view
|
|
313 |
// Appends strings from both resources and VPN API to one
|
|
314 |
// message body text and displays it.
|
|
315 |
// ---------------------------------------------------------
|
|
316 |
//
|
|
317 |
void CVpnManagementUiPolicyView::PolicyDetailsL(TInt aIndex)
|
|
318 |
{
|
|
319 |
TVpnPolicyDetails policyDetails;
|
|
320 |
|
|
321 |
iLoader.VpnApiWrapperL().GetPolicyDetailsL(aIndex,policyDetails);
|
|
322 |
HBufC* message = HBufC::NewLC(KMaxLengthTextDetailsBody);
|
|
323 |
|
|
324 |
// Description:
|
|
325 |
ReadResourceL(*message, R_VPN_DETAIL_POLICY_DESCRIPTION );
|
|
326 |
message->Des().Append(KVpnManagementUiEnter);
|
|
327 |
message->Des().Append(policyDetails.iDescription);
|
|
328 |
message->Des().Append(KVpnManagementUiEnterTwice);
|
|
329 |
|
|
330 |
// Policy status:
|
|
331 |
ReadResourceL(*message, R_VPN_DETAIL_POLICY_STATUS );
|
|
332 |
message->Des().Append(KVpnManagementUiEnter);
|
|
333 |
|
|
334 |
if (policyDetails.iUsageStatus == EUsageStatusUnused)
|
|
335 |
ReadResourceL(*message, R_VPN_DETAIL_POLICY_NOT_ASSOCIATED );
|
|
336 |
else if (policyDetails.iUsageStatus == EUsageStatusAssignedToIap)
|
|
337 |
ReadResourceL(*message, R_VPN_DETAIL_POLICY_ASSOCIATED );
|
|
338 |
else if (policyDetails.iUsageStatus == EUsageStatusActive)
|
|
339 |
ReadResourceL(*message, R_VPN_DETAIL_POLICY_ACTIVE );
|
|
340 |
|
|
341 |
message->Des().Append(KVpnManagementUiEnterTwice);
|
|
342 |
|
|
343 |
// Certificate status:
|
|
344 |
ReadResourceL(*message, R_VPN_DETAIL_CERT_STATUS );
|
|
345 |
message->Des().Append(KVpnManagementUiEnter);
|
|
346 |
|
|
347 |
if (policyDetails.iPkiStatus == EPkiStatusReady)
|
|
348 |
ReadResourceL(*message, R_VPN_DETAIL_CERT_STATUS_OK );
|
|
349 |
else if (policyDetails.iPkiStatus == EPkiStatusCertExpired)
|
|
350 |
ReadResourceL(*message, R_VPN_DETAIL_CERT_STATUS_EXPIRED );
|
|
351 |
else if (policyDetails.iPkiStatus == EPkiStatusNoCert)
|
|
352 |
ReadResourceL(*message, R_VPN_DETAIL_CERT_STATUS_MISSING );
|
|
353 |
else if (policyDetails.iPkiStatus == EPkiStatusCertNotValidYet)
|
|
354 |
ReadResourceL(*message, R_VPN_DETAIL_CERT_STATUS_NOT_YET_VALID );
|
|
355 |
|
|
356 |
message->Des().Append(KVpnManagementUiEnterTwice);
|
|
357 |
|
|
358 |
// Policy name:
|
|
359 |
ReadResourceL(*message, R_VPN_DETAIL_POLICY_NAME );
|
|
360 |
message->Des().Append(KVpnManagementUiEnter);
|
|
361 |
message->Des().Append(policyDetails.iName);
|
|
362 |
message->Des().Append(KVpnManagementUiEnterTwice);
|
|
363 |
|
|
364 |
// Header for the message query dialog
|
|
365 |
|
|
366 |
CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*message);
|
|
367 |
dlg->PrepareLC(R_MESSAGE_QUERY_DETAILS_VIEW);
|
|
368 |
dlg->QueryHeading()->SetTextL(policyDetails.iName);
|
|
369 |
dlg->RunLD();
|
|
370 |
|
|
371 |
CleanupStack::PopAndDestroy(); // message
|
|
372 |
}
|
|
373 |
|
|
374 |
TBool CVpnManagementUiPolicyView::NotAssociatedToIapL(TInt aIndex, TVpnPolicyName& aPolicyName)
|
|
375 |
{
|
|
376 |
TVpnPolicyDetails policyDetails;
|
|
377 |
iLoader.VpnApiWrapperL().GetPolicyDetailsL(aIndex,policyDetails);
|
|
378 |
aPolicyName = policyDetails.iName;
|
|
379 |
if (policyDetails.iUsageStatus == EUsageStatusUnused)
|
|
380 |
return ETrue;
|
|
381 |
else
|
|
382 |
return EFalse;
|
|
383 |
}
|
|
384 |
|
|
385 |
// ---------------------------------------------------------
|
|
386 |
// CVpnManagementUiPolicyView::ReadResourceL
|
|
387 |
// Reads text from resource
|
|
388 |
// ---------------------------------------------------------
|
|
389 |
//
|
|
390 |
void CVpnManagementUiPolicyView::ReadResourceL(HBufC& aText, TInt aResource)
|
|
391 |
{
|
|
392 |
HBufC* text = StringLoader::LoadLC( aResource );
|
|
393 |
aText.Des().Append(text->Des());
|
|
394 |
CleanupStack::PopAndDestroy(); // text
|
|
395 |
}
|
|
396 |
|
|
397 |
|
|
398 |
// End of File
|
|
399 |
|