|
1 /* |
|
2 * Copyright (c) 2003-2008 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: CAppMngr2MidletSettingsView implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknViewAppUi.h> // CAknViewAppUi |
|
21 #include <aknradiobuttonsettingpage.h> // CAknRadioButtonSettingPage |
|
22 #include <featmgr.h> // FeatureManager |
|
23 #include <StringLoader.h> // StringLoader |
|
24 #include <akntitle.h> // CAknTitlePane |
|
25 #include <aknmessagequerydialog.h> // CAknMessageQueryDialog |
|
26 #include <AknUtils.h> // AknLayoutUtils |
|
27 #include <hlplch.h> // HlpLauncher |
|
28 #include "javaapplicationsettings.hlp.hrh" |
|
29 |
|
30 #include <javaapplicationsettings.rsg> // Midlet resource IDs |
|
31 #include <cmapplicationsettingsui.h> // CCmApplicationSettingsUi |
|
32 |
|
33 #include "appmngr2midletsettingscontainer.h" // CAppMngr2MidletSettingsContainer |
|
34 #include "appmngr2midletsettingsview.h" // CAppMngr2MidletSettingsView |
|
35 #include "javaapplicationsettings.hrh" // Midlet command IDs |
|
36 #include "appmngr2midletsettingshandler.h" |
|
37 #include "javasymbianoslayer.h" // STL <-- --> Symbian conv. |
|
38 #include "securitystoragedatadefs.h" |
|
39 #include "connectionmanager.h" // ConnectionManager. |
|
40 #include "javacommonutils.h" |
|
41 #include "logger.h" // LOG |
|
42 #include "appmngr2midletresourcehandler.h" // CAppMngr2MidletResourceHandler |
|
43 |
|
44 #include <vector> |
|
45 #include <algorithm> |
|
46 |
|
47 using namespace std; |
|
48 using namespace java::util; |
|
49 |
|
50 const int SECURITY_WARNINGS_MODE_PAGE = 1; |
|
51 const int SECURITY_SETTINGS_PAGE = 2; |
|
52 const int ON_SCREEN_KEYPAD_PAGE = 3; |
|
53 |
|
54 const int SENSIBLE_FUNCTION_GROUPS = 9; |
|
55 const int NET_ACCESS_SETTINGS_INDEX = 0; |
|
56 const int LOW_LEVEL_NET_ACCESS_SETTINGS_INDEX = 1; |
|
57 const int CALL_CONTROL_SETTINGS_INDEX = 2; |
|
58 const int MESSAGING_SETTINGS_INDEX = 3; |
|
59 const int RESTRICTED_MESSAGING_SETTINGS_INDEX = 4; |
|
60 const int APPLICATION_AUTO_INVOCATION_SETTINGS_INDEX = 5; |
|
61 const int LOCAL_CONNECTIVITY_SETTINGS_INDEX = 6; |
|
62 const int MULTIMEDIA_RECORDING_SETTINGS_INDEX = 7; |
|
63 const int READ_USER_DATA_ACCESS_SETTINGS_INDEX = 8; |
|
64 |
|
65 const TUid KOwnUid = { 0x20016BF7 }; // Own Uid, used with help |
|
66 |
|
67 // ================= MEMBER FUNCTIONS ======================= |
|
68 |
|
69 CAppMngr2MidletSettingsView* CAppMngr2MidletSettingsView::NewL( |
|
70 const TDesC& aMidletSuiteName, |
|
71 TUid aMidletSuiteUid, |
|
72 CAppMngr2MidletResourceHandler& aResourceHandler) |
|
73 { |
|
74 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::NewL "); |
|
75 CAppMngr2MidletSettingsView* self |
|
76 = new(ELeave) CAppMngr2MidletSettingsView(aResourceHandler); |
|
77 CleanupStack::PushL(self); |
|
78 self->ConstructL(aMidletSuiteName, aMidletSuiteUid); |
|
79 CleanupStack::Pop(self); |
|
80 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::NewL "); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CAppMngr2MidletSettingsView::CAppMngr2MidletSettingsView |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 CAppMngr2MidletSettingsView::CAppMngr2MidletSettingsView(CAppMngr2MidletResourceHandler& aResourceHandler) |
|
89 : iContainer(NULL), iSettingsHandler(NULL), iOnscreenKeypadSettingsVisible(EFalse), iSecuritySettingsVisible(EFalse), iResourceFileOffset(0), iResourceHandler(aResourceHandler) |
|
90 { |
|
91 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::CAppMngr2MidletSettingsView "); |
|
92 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::CAppMngr2MidletSettingsView "); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CAppMngr2MidletSettingsView::ConstructL(const TRect& aRect) |
|
97 // EPOC two-phased constructor |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 void CAppMngr2MidletSettingsView::ConstructL(const TDesC& aMidletSuiteName,TUid aMidletSuiteUid) |
|
101 { |
|
102 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::ConstructL "); |
|
103 iResourceFileOffset = iResourceHandler.AddResourceFileL(); |
|
104 BaseConstructL(R_APPMNGR_VIEW_CONTEXT_SPECIFIC); |
|
105 InitL(aMidletSuiteName,aMidletSuiteUid); |
|
106 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::ConstructL "); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // CAppMngr2MidletSettingsView::~CAppMngr2MidletSettingsView() |
|
111 // Class destructor |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 CAppMngr2MidletSettingsView::~CAppMngr2MidletSettingsView() |
|
115 { |
|
116 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::~CAppMngr2MidletSettingsView "); |
|
117 if (iContainer) |
|
118 { |
|
119 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
120 } |
|
121 delete iSettingsHandler; |
|
122 delete iContainer; |
|
123 delete[] iBlanketSettings; |
|
124 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::~CAppMngr2MidletSettingsView "); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // TUid CAppMngr2MidletSettingsView::Id() |
|
129 // Return settings view id |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 TUid CAppMngr2MidletSettingsView::Id() const |
|
133 { |
|
134 LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletSettingsView::Id "); |
|
135 return KMidletSuiteSettingsViewId; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // CAppMngr2MidletSettingsView::HandleClientRectChange() |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CAppMngr2MidletSettingsView::HandleClientRectChange() |
|
143 { |
|
144 LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletSettingsView::HandleClientRectChange "); |
|
145 if (iContainer) |
|
146 { |
|
147 iContainer->SetRect(ClientRect()); |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CAppMngr2MidletSettingsView::DoActivateL(...) |
|
153 // Activates the view |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 void CAppMngr2MidletSettingsView::DoActivateL( |
|
157 const TVwsViewId& aPrevViewId, TUid /*aCustomMessageId*/, |
|
158 const TDesC8& /*aCustomMessage*/) |
|
159 { |
|
160 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::DoActivateL "); |
|
161 iPrevViewId = aPrevViewId; |
|
162 iContainer->MakeVisible(ETrue); |
|
163 iContainer->SetRect(ClientRect()); |
|
164 iContainer->ActivateL(); |
|
165 iContainer->ListBox()->SetListBoxObserver(this); |
|
166 iContainer->ListBox()->DrawNow(); |
|
167 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::DoActivateL "); |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CAppMngr2MidletSettingsView::HandleCommandL(TInt aCommand) |
|
172 // --------------------------------------------------------------------------- |
|
173 void CAppMngr2MidletSettingsView::HandleCommandL(TInt aCommand) |
|
174 { |
|
175 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::HandleCommand "); |
|
176 switch (aCommand) |
|
177 { |
|
178 case EAknSoftkeyChange: |
|
179 case EAppMngrCmdOkPressed: |
|
180 case EAknSoftkeySelect: |
|
181 { |
|
182 HandleSettingsL(); |
|
183 break; |
|
184 } |
|
185 case EAknSoftkeyBack: |
|
186 { |
|
187 AppUi()->ActivateLocalViewL(iPrevViewId.iViewUid); |
|
188 break; |
|
189 } |
|
190 case EAknSoftkeyExit: |
|
191 { |
|
192 static_cast<MEikCommandObserver*>(AppUi())->ProcessCommandL(EAknCmdExit); |
|
193 break; |
|
194 } |
|
195 case EAknCmdHelp: |
|
196 if (FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
197 { |
|
198 CArrayFix<TCoeHelpContext>* contexts = |
|
199 new(ELeave) CArrayFixFlat<TCoeHelpContext>(1); |
|
200 CleanupStack::PushL(contexts); |
|
201 TCoeHelpContext context; |
|
202 context.iMajor = KOwnUid; |
|
203 context.iContext = HLP_JAVA_APPLICATION_SETTINGS; |
|
204 contexts->AppendL(context); |
|
205 CleanupStack::Pop(contexts); |
|
206 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), contexts); |
|
207 } |
|
208 break; |
|
209 default: |
|
210 { |
|
211 AppUi()->HandleCommandL(aCommand); |
|
212 break; |
|
213 } |
|
214 } |
|
215 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::HandleCommand "); |
|
216 } |
|
217 |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CAppMngr2MidletSettingsView::HandleListBoxEventL |
|
221 // |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CAppMngr2MidletSettingsView::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
225 TListBoxEvent aEventType) |
|
226 { |
|
227 LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletSettingsView::HandleListBoxEventL "); |
|
228 switch (aEventType) |
|
229 { |
|
230 case EEventEnterKeyPressed: |
|
231 case EEventItemDoubleClicked: |
|
232 case EEventItemSingleClicked: |
|
233 HandleSettingsL(); |
|
234 break; |
|
235 default: |
|
236 break; |
|
237 } |
|
238 } |
|
239 |
|
240 void CAppMngr2MidletSettingsView::HandleSettingsL() |
|
241 { |
|
242 switch (iContainer->ListBox()->CurrentItemIndex()) |
|
243 { |
|
244 case 0: |
|
245 ShowAccessPointPageL(); |
|
246 break; |
|
247 case 1: |
|
248 if (iOnscreenKeypadSettingsVisible) |
|
249 { |
|
250 ShowPageL(ON_SCREEN_KEYPAD_PAGE); |
|
251 } |
|
252 else if (iSecuritySettingsVisible) |
|
253 { |
|
254 ShowPageL(SECURITY_WARNINGS_MODE_PAGE); |
|
255 } |
|
256 break; |
|
257 case 2: |
|
258 if (iOnscreenKeypadSettingsVisible && iSecuritySettingsVisible) |
|
259 { |
|
260 ShowPageL(SECURITY_WARNINGS_MODE_PAGE); |
|
261 break; |
|
262 } |
|
263 default: |
|
264 ShowPageL(SECURITY_SETTINGS_PAGE); |
|
265 } |
|
266 } |
|
267 |
|
268 /** |
|
269 * Start settings page |
|
270 */ |
|
271 void CAppMngr2MidletSettingsView::ShowAccessPointPageL() |
|
272 { |
|
273 TUint32 snapId = JavaCommonUtils::wstringToInt(iContainer->GetListBoxItem(0).getValue().getId()); |
|
274 |
|
275 // show the dialog |
|
276 CCmApplicationSettingsUi* handler = CCmApplicationSettingsUi::NewLC(); |
|
277 TUint listItems = CMManager::EShowAlwaysAsk |
|
278 | CMManager::EShowDefaultConnection |
|
279 | CMManager::EShowDestinations; |
|
280 TBearerFilterArray filter; |
|
281 TCmSettingSelection selection; |
|
282 switch (snapId) |
|
283 { |
|
284 case(TUint)KAlwaysAskId: |
|
285 selection.iResult = CMManager::EAlwaysAsk; |
|
286 break; |
|
287 case(TUint)KJavaNetworkAccessNotSpecified: |
|
288 case(TUint)KDefaultConnection: |
|
289 selection.iResult = CMManager::EDefaultConnection; |
|
290 break; |
|
291 default: // User defined SNAP |
|
292 selection.iResult = CMManager::EDestination; |
|
293 } |
|
294 selection.iId = snapId; |
|
295 TBool ret = handler->RunApplicationSettingsL(selection, listItems, filter); |
|
296 CleanupStack::PopAndDestroy(handler); |
|
297 if (ret) |
|
298 { |
|
299 switch (selection.iResult) |
|
300 { |
|
301 case CMManager::EAlwaysAsk: |
|
302 snapId = (TUint)KAlwaysAskId; |
|
303 break; |
|
304 case CMManager::EDestination: |
|
305 snapId = selection.iId; |
|
306 break; |
|
307 case CMManager::EDefaultConnection: |
|
308 snapId = (TUint)KDefaultConnection; |
|
309 break; |
|
310 default: |
|
311 User::Leave(KErrNotSupported); |
|
312 } |
|
313 CAppMngr2SuiteSnapItem* snap = new(ELeave) CAppMngr2SuiteSnapItem; |
|
314 CleanupStack::PushL(snap); |
|
315 snap->iId = snapId; |
|
316 iSettingsHandler->SetSnapL(*snap); |
|
317 CleanupStack::PopAndDestroy(snap); |
|
318 CAppMngr2SuiteSnapItem* newSnap = iSettingsHandler->GetSnapL(); |
|
319 CleanupStack::PushL(newSnap); |
|
320 iContainer->RefreshListBoxContentL(0, 0, AppMngr2MidletSettingsUtil::SnapToListItem(*newSnap, true /* enabled */)); |
|
321 CleanupStack::PopAndDestroy(newSnap); |
|
322 } |
|
323 |
|
324 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsHandler::ShowSuiteSnapSelectDialogL "); |
|
325 } |
|
326 |
|
327 /** |
|
328 * Start page |
|
329 */ |
|
330 void CAppMngr2MidletSettingsView::ShowPageL(int pageId) |
|
331 { |
|
332 TInt listBoxContentCurrentItemIndex = iContainer->ListBox()->CurrentItemIndex(); |
|
333 if (!iOnscreenKeypadSettingsVisible) |
|
334 { |
|
335 listBoxContentCurrentItemIndex++; |
|
336 } |
|
337 ListItem currentItem = iContainer->GetListBoxItem(listBoxContentCurrentItemIndex); |
|
338 TInt selectionIndex = currentItem.getCurrentValue(); |
|
339 int currentSelection = currentItem.getCurrentValue(); |
|
340 vector<LocalizedString> values = currentItem.getValues(); |
|
341 |
|
342 if (values.size() == 1) |
|
343 { |
|
344 // stop right here |
|
345 return; |
|
346 } |
|
347 |
|
348 if (values.size() == 2) |
|
349 { |
|
350 // if there are only two values, then do a quick selection (change to the other one) |
|
351 selectionIndex = (currentSelection == 0 ? 1 : 0); |
|
352 } |
|
353 else |
|
354 { |
|
355 // if there are more than two values, go on show the list |
|
356 CDesCArrayFlat* itemArray = new(ELeave) CDesCArrayFlat(values.size()); |
|
357 CleanupStack::PushL(itemArray); |
|
358 for (int i=0; i<values.size(); i++) |
|
359 { |
|
360 wstring value = values[i].getValue(); |
|
361 TPtr ptr((unsigned short*)value.c_str(), value.size()); |
|
362 ptr.SetLength(value.size()); |
|
363 itemArray->AppendL(ptr); |
|
364 } |
|
365 CAknSettingPage* dlg = new(ELeave) CAknRadioButtonSettingPage( |
|
366 AppMngr2MidletSettingsUtil::GetLocalizedSettingsName( |
|
367 currentItem.getName().getId()), |
|
368 selectionIndex, itemArray); |
|
369 |
|
370 // execute the setting page and check if the setting value was changed: |
|
371 dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
372 CleanupStack::PopAndDestroy(itemArray); |
|
373 } |
|
374 // handle the selection |
|
375 if (currentSelection != selectionIndex) |
|
376 { |
|
377 iContainer->SetListBoxItemValue( |
|
378 listBoxContentCurrentItemIndex, |
|
379 selectionIndex); |
|
380 int err = KErrNone; |
|
381 MidletSuiteSecuritySettings settings; |
|
382 switch (pageId) |
|
383 { |
|
384 case SECURITY_WARNINGS_MODE_PAGE: |
|
385 err = iSettingsHandler->SetSecurityWarningsMode( |
|
386 (selectionIndex == 0 ? SECURITY_WARNINGS_DEFAULT_MODE:SECURITY_WARNINGS_USER_DEFINED_MODE)); |
|
387 if (err == KErrNone) |
|
388 { |
|
389 iContainer->RefreshListBoxContentL( |
|
390 listBoxContentCurrentItemIndex, |
|
391 selectionIndex, |
|
392 (selectionIndex == 1) /* aAllEnabled*/); |
|
393 } |
|
394 break; |
|
395 case SECURITY_SETTINGS_PAGE: |
|
396 settings = AppMngr2MidletSettingsUtil::ListItemToSettings( |
|
397 iContainer->GetListBoxItem(listBoxContentCurrentItemIndex)); |
|
398 if (!CheckBlanketSettingsL(settings)) |
|
399 { |
|
400 err = KErrNotFound; |
|
401 break; |
|
402 } |
|
403 err = iSettingsHandler->SetSecuritySettings( |
|
404 settings.getName(), settings.getCurrentInteractionMode()); |
|
405 if (err == KErrNone) |
|
406 { |
|
407 if (settings.getCurrentInteractionMode() == BLANKET_INTERACTION_MODE) |
|
408 { |
|
409 // "blanket mode, if selected by the user, MUST NOT result in any |
|
410 // additional prompts" (MIDP spec) -> mark down that the prompt |
|
411 // in blanket mode was shown |
|
412 iSettingsHandler->SetUserSecuritySettingsPromptFlag( |
|
413 settings.getName(), |
|
414 true /* prompt is blanket mode was shown */); |
|
415 } |
|
416 // do the refresh |
|
417 iContainer->RefreshListBoxContentL( |
|
418 listBoxContentCurrentItemIndex, selectionIndex); |
|
419 } |
|
420 break; |
|
421 case ON_SCREEN_KEYPAD_PAGE: |
|
422 err = iSettingsHandler->SetOnScreenKeypadValueL( |
|
423 iContainer->GetListBoxItem(listBoxContentCurrentItemIndex) |
|
424 .getValue().getId()); |
|
425 if (err == KErrNone) |
|
426 { |
|
427 iContainer->RefreshListBoxContentL( |
|
428 listBoxContentCurrentItemIndex, selectionIndex); |
|
429 } |
|
430 break; |
|
431 } |
|
432 if (err != KErrNone) |
|
433 { |
|
434 // roll back to the original selection for the value |
|
435 iContainer->SetListBoxItemValue( |
|
436 listBoxContentCurrentItemIndex, currentSelection); |
|
437 } |
|
438 } |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------- |
|
442 // CAppMngr2MidletSettingsView::DoDeactivate() |
|
443 // Deactivate this view |
|
444 // --------------------------------------------------------- |
|
445 // |
|
446 void CAppMngr2MidletSettingsView::DoDeactivate() |
|
447 { |
|
448 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::DoDeactivate "); |
|
449 if (iContainer) |
|
450 { |
|
451 iContainer->MakeVisible(EFalse); |
|
452 } |
|
453 if (iResourceFileOffset > 0) |
|
454 { |
|
455 iResourceHandler.DeleteResourceFile(iResourceFileOffset); |
|
456 iResourceFileOffset = 0; |
|
457 } |
|
458 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::DoDeactivate "); |
|
459 } |
|
460 |
|
461 // --------------------------------------------------------- |
|
462 // CAppMngr2MidletSettingsView::ShowWarningSecDlgL() |
|
463 // high risk (net acces, messaging, call control, local connectivity) + (multimedia, read user data) |
|
464 // --------------------------------------------------------- |
|
465 // |
|
466 bool CAppMngr2MidletSettingsView::ShowWarningSecDlgL(bool networkUsage) |
|
467 { |
|
468 HBufC* header = StringLoader::LoadLC(R_JAVA_SEC_HEADER); |
|
469 HBufC* warning_sec = NULL; |
|
470 if (networkUsage) |
|
471 { |
|
472 warning_sec = StringLoader::LoadLC(R_JAVA_QUERY_MIDLET_PERM_NET); |
|
473 } |
|
474 else |
|
475 { |
|
476 warning_sec = StringLoader::LoadLC(R_JAVA_QUERY_MIDLET_PERM_SEC); |
|
477 } |
|
478 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*warning_sec); |
|
479 CleanupStack::PushL(dlg); |
|
480 dlg->PrepareLC(R_APPMNGR_QUERY_DIALOG_OK_CANCEL); |
|
481 dlg->QueryHeading()->SetTextL(*header); |
|
482 dlg->QueryHeading()->SetLayout(CAknPopupHeadingPane::EQueryHeadingPane); |
|
483 CleanupStack::Pop(dlg); |
|
484 bool ret = (dlg->RunLD() == EAknSoftkeyOk); |
|
485 CleanupStack::PopAndDestroy(warning_sec); |
|
486 CleanupStack::PopAndDestroy(header); |
|
487 return ret; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------- |
|
491 // CAppMngr2MidletSettingsView::ShowWarningExclDlgL() |
|
492 // mutually exclusive auto invocation + net access |
|
493 // --------------------------------------------------------- |
|
494 // |
|
495 bool CAppMngr2MidletSettingsView::ShowWarningExclDlgL() |
|
496 { |
|
497 HBufC* header = StringLoader::LoadLC(R_JAVA_SEC_HEADER); |
|
498 HBufC* warning_excl = StringLoader::LoadLC(R_JAVA_QUERY_MIDLET_PERM_EXCL); |
|
499 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*warning_excl); |
|
500 CleanupStack::PushL(dlg); |
|
501 dlg->PrepareLC(R_APPMNGR_QUERY_DIALOG_OK_CANCEL); |
|
502 dlg->QueryHeading()->SetTextL(*header); |
|
503 dlg->QueryHeading()->SetLayout(CAknPopupHeadingPane::EQueryHeadingPane); |
|
504 CleanupStack::Pop(dlg); |
|
505 bool ret = (dlg->RunLD() == EAknSoftkeyOk); |
|
506 CleanupStack::PopAndDestroy(warning_excl); |
|
507 CleanupStack::PopAndDestroy(header); |
|
508 return ret; |
|
509 } |
|
510 |
|
511 /** |
|
512 */ |
|
513 void CAppMngr2MidletSettingsView::InitSettings(const std::vector<MidletSuiteSecuritySettings>& aAllSettings) |
|
514 { |
|
515 iBlanketSettings = new bool[SENSIBLE_FUNCTION_GROUPS]; |
|
516 for (int i=0; i<SENSIBLE_FUNCTION_GROUPS; i++) |
|
517 { |
|
518 iBlanketSettings[i] = false; |
|
519 } |
|
520 for (int i=0; i<aAllSettings.size(); i++) |
|
521 { |
|
522 if (aAllSettings[i].getName() == NET_ACCESS_SETTINGS) |
|
523 { |
|
524 iMutuallyExclusiveSettings.push_back(aAllSettings[i]); |
|
525 iBlanketSettings[NET_ACCESS_SETTINGS_INDEX] = |
|
526 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
527 } |
|
528 else if (aAllSettings[i].getName() == LOW_LEVEL_NET_ACCESS_SETTINGS) |
|
529 { |
|
530 iBlanketSettings[LOW_LEVEL_NET_ACCESS_SETTINGS_INDEX] = |
|
531 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
532 } |
|
533 else if (aAllSettings[i].getName() == MESSAGING_SETTINGS) |
|
534 { |
|
535 iBlanketSettings[MESSAGING_SETTINGS_INDEX] = |
|
536 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
537 } |
|
538 else if (aAllSettings[i].getName() == RESTRICTED_MESSAGING_SETTINGS) |
|
539 { |
|
540 iBlanketSettings[RESTRICTED_MESSAGING_SETTINGS_INDEX] = |
|
541 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
542 } |
|
543 else if (aAllSettings[i].getName() == CALL_CONTROL_SETTINGS) |
|
544 { |
|
545 iBlanketSettings[CALL_CONTROL_SETTINGS_INDEX] = |
|
546 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
547 } |
|
548 else if (aAllSettings[i].getName() == LOCAL_CONNECTIVITY_SETTINGS) |
|
549 { |
|
550 iBlanketSettings[LOCAL_CONNECTIVITY_SETTINGS_INDEX] = |
|
551 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
552 } |
|
553 else if (aAllSettings[i].getName() == MULTIMEDIA_RECORDING_SETTINGS) |
|
554 { |
|
555 iBlanketSettings[MULTIMEDIA_RECORDING_SETTINGS_INDEX] = |
|
556 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
557 } |
|
558 else if (aAllSettings[i].getName() == READ_USER_DATA_ACCESS_SETTINGS) |
|
559 { |
|
560 iBlanketSettings[READ_USER_DATA_ACCESS_SETTINGS_INDEX] = |
|
561 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
562 } |
|
563 else if (aAllSettings[i].getName() == APPLICATION_AUTO_INVOCATION_SETTINGS) |
|
564 { |
|
565 iMutuallyExclusiveSettings.push_back(aAllSettings[i]); |
|
566 iBlanketSettings[APPLICATION_AUTO_INVOCATION_SETTINGS_INDEX] = |
|
567 (aAllSettings[i].getCurrentInteractionMode() == BLANKET_INTERACTION_MODE); |
|
568 } |
|
569 } |
|
570 } |
|
571 |
|
572 void CAppMngr2MidletSettingsView::UpdateBlanketSettings(const MidletSuiteSecuritySettings& aSettings, bool aBlanket) |
|
573 { |
|
574 if (aSettings.getName() == NET_ACCESS_SETTINGS) |
|
575 { |
|
576 iBlanketSettings[NET_ACCESS_SETTINGS_INDEX] = aBlanket; |
|
577 } |
|
578 else if (aSettings.getName() == LOW_LEVEL_NET_ACCESS_SETTINGS) |
|
579 { |
|
580 iBlanketSettings[LOW_LEVEL_NET_ACCESS_SETTINGS_INDEX] = aBlanket; |
|
581 } |
|
582 else if (aSettings.getName() == MESSAGING_SETTINGS) |
|
583 { |
|
584 iBlanketSettings[MESSAGING_SETTINGS_INDEX] = aBlanket; |
|
585 } |
|
586 else if (aSettings.getName() == RESTRICTED_MESSAGING_SETTINGS) |
|
587 { |
|
588 iBlanketSettings[RESTRICTED_MESSAGING_SETTINGS_INDEX] = aBlanket; |
|
589 } |
|
590 else if (aSettings.getName() == CALL_CONTROL_SETTINGS) |
|
591 { |
|
592 iBlanketSettings[CALL_CONTROL_SETTINGS_INDEX] = aBlanket; |
|
593 } |
|
594 else if (aSettings.getName() == LOCAL_CONNECTIVITY_SETTINGS) |
|
595 { |
|
596 iBlanketSettings[LOCAL_CONNECTIVITY_SETTINGS_INDEX] = aBlanket; |
|
597 } |
|
598 else if (aSettings.getName() == MULTIMEDIA_RECORDING_SETTINGS) |
|
599 { |
|
600 iBlanketSettings[MULTIMEDIA_RECORDING_SETTINGS_INDEX] = aBlanket; |
|
601 } |
|
602 else if (aSettings.getName() == READ_USER_DATA_ACCESS_SETTINGS) |
|
603 { |
|
604 iBlanketSettings[READ_USER_DATA_ACCESS_SETTINGS_INDEX] = aBlanket; |
|
605 } |
|
606 else if (aSettings.getName() == APPLICATION_AUTO_INVOCATION_SETTINGS) |
|
607 { |
|
608 iBlanketSettings[APPLICATION_AUTO_INVOCATION_SETTINGS_INDEX] = aBlanket; |
|
609 } |
|
610 } |
|
611 |
|
612 bool CAppMngr2MidletSettingsView::CheckBlanketSettingsL(const MidletSuiteSecuritySettings& aSettings) |
|
613 { |
|
614 if (aSettings.getCurrentInteractionMode() != BLANKET_INTERACTION_MODE) |
|
615 { |
|
616 UpdateBlanketSettings(aSettings, false); |
|
617 return true; |
|
618 } |
|
619 if ((aSettings.getName() == NET_ACCESS_SETTINGS |
|
620 && iBlanketSettings[APPLICATION_AUTO_INVOCATION_SETTINGS_INDEX]) |
|
621 || (aSettings.getName() == APPLICATION_AUTO_INVOCATION_SETTINGS |
|
622 && iBlanketSettings[NET_ACCESS_SETTINGS_INDEX])) |
|
623 { |
|
624 bool accept = ShowWarningExclDlgL(); |
|
625 if (accept) |
|
626 { |
|
627 UpdateBlanketSettings(aSettings, true); |
|
628 // change the other setting to the next maximum allowed |
|
629 HandleMutuallyExclusiveSettingsL(aSettings); |
|
630 } |
|
631 return accept; |
|
632 } |
|
633 if (((aSettings.getName() == NET_ACCESS_SETTINGS |
|
634 || aSettings.getName() == LOW_LEVEL_NET_ACCESS_SETTINGS |
|
635 || aSettings.getName() == MESSAGING_SETTINGS |
|
636 || aSettings.getName() == RESTRICTED_MESSAGING_SETTINGS |
|
637 || aSettings.getName() == CALL_CONTROL_SETTINGS |
|
638 || aSettings.getName() == LOCAL_CONNECTIVITY_SETTINGS) |
|
639 && (iBlanketSettings[MULTIMEDIA_RECORDING_SETTINGS_INDEX] |
|
640 || iBlanketSettings[READ_USER_DATA_ACCESS_SETTINGS_INDEX])) |
|
641 || ((aSettings.getName() == MULTIMEDIA_RECORDING_SETTINGS |
|
642 || aSettings.getName() == READ_USER_DATA_ACCESS_SETTINGS) |
|
643 && (iBlanketSettings[NET_ACCESS_SETTINGS_INDEX] |
|
644 || iBlanketSettings[LOW_LEVEL_NET_ACCESS_SETTINGS_INDEX] |
|
645 || iBlanketSettings[MESSAGING_SETTINGS_INDEX] |
|
646 || iBlanketSettings[RESTRICTED_MESSAGING_SETTINGS_INDEX] |
|
647 || iBlanketSettings[CALL_CONTROL_SETTINGS_INDEX] |
|
648 || iBlanketSettings[LOCAL_CONNECTIVITY_SETTINGS_INDEX]))) |
|
649 { |
|
650 bool accept = ShowWarningSecDlgL( |
|
651 (aSettings.getName() != LOCAL_CONNECTIVITY_SETTINGS |
|
652 && !iBlanketSettings[LOCAL_CONNECTIVITY_SETTINGS_INDEX])); |
|
653 if (accept) |
|
654 { |
|
655 UpdateBlanketSettings(aSettings, true); |
|
656 } |
|
657 return accept; |
|
658 } |
|
659 else if (aSettings.getCurrentInteractionMode() == BLANKET_INTERACTION_MODE) |
|
660 { |
|
661 UpdateBlanketSettings(aSettings, true); |
|
662 } |
|
663 return true; |
|
664 } |
|
665 |
|
666 void CAppMngr2MidletSettingsView::InitL(const TDesC& aMidletSuiteName,TUid aMidletSuiteUid) |
|
667 { |
|
668 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletSettingsView::InitL "); |
|
669 |
|
670 // init the settings handler |
|
671 iSettingsHandler = CAppMngr2MidletSettingsHandler::NewL(aMidletSuiteName,aMidletSuiteUid, iResourceHandler); |
|
672 // Show on-screen Keypad settings only in devices having touch display |
|
673 iOnscreenKeypadSettingsVisible = AknLayoutUtils::PenEnabled(); |
|
674 // Construct the container and make it visible |
|
675 iContainer = new(ELeave) CAppMngr2MidletSettingsContainer(*this); |
|
676 // Set the MObjectProvider parent for the container window |
|
677 iContainer->SetMopParent(this); |
|
678 iContainer->ConstructL(ClientRect()); |
|
679 HBufC* jamSetTitle = StringLoader::LoadLC(R_JAVA_SET_TITLE, aMidletSuiteName); |
|
680 CEikStatusPane* statusPane = StatusPane(); |
|
681 CAknTitlePane* titlePane; |
|
682 titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); |
|
683 titlePane->SetTextL(jamSetTitle->Des()); |
|
684 CleanupStack::PopAndDestroy(jamSetTitle); |
|
685 // fill in the list items |
|
686 std::vector<ListItem> listBoxItems; |
|
687 // access point |
|
688 CAppMngr2SuiteSnapItem* snap = iSettingsHandler->GetSnapL(); |
|
689 CleanupStack::PushL(snap); |
|
690 listBoxItems.push_back(AppMngr2MidletSettingsUtil::SnapToListItem( |
|
691 *snap, true /* enabled */)); |
|
692 CleanupStack::PopAndDestroy(snap); |
|
693 // on screen Keypad |
|
694 wstring onScreenKeypad = iSettingsHandler->GetOnScreenKeypadValueL(); |
|
695 if (iSettingsHandler->OnScreenKeypadValuePreDefinedL()) |
|
696 { |
|
697 iOnscreenKeypadSettingsVisible = EFalse; |
|
698 } |
|
699 listBoxItems.push_back(AppMngr2MidletSettingsUtil::OnScreenKeypadToListItem( |
|
700 onScreenKeypad, iOnscreenKeypadSettingsVisible)); |
|
701 // security warnings mode |
|
702 vector<MidletSuiteSecuritySettings> settings; |
|
703 iSettingsHandler->GetSecuritySettings(settings); |
|
704 iSecuritySettingsVisible = (settings.size() > 0); |
|
705 wstring securityWarningsMode = iSettingsHandler->GetSecurityWarningsMode(); |
|
706 listBoxItems.push_back(AppMngr2MidletSettingsUtil::SecurityWarningsModeToListItem( |
|
707 securityWarningsMode, iSecuritySettingsVisible)); |
|
708 // blanket settings |
|
709 InitSettings(settings); |
|
710 // function groups |
|
711 for (int i=0; i<settings.size(); i++) |
|
712 { |
|
713 listBoxItems.push_back(AppMngr2MidletSettingsUtil::SettingsToListItem( |
|
714 settings[i], |
|
715 (iSecuritySettingsVisible && securityWarningsMode == SECURITY_WARNINGS_USER_DEFINED_MODE))); |
|
716 } |
|
717 // sort the vector |
|
718 std::sort(listBoxItems.begin(), listBoxItems.end(), |
|
719 AppMngr2MidletSettingsUtil::AscendingListItemSort()); |
|
720 iContainer->InitListBoxContentL(listBoxItems); |
|
721 AppUi()->AddToStackL(*this, iContainer); |
|
722 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletSettingsView::InitL "); |
|
723 } |
|
724 |
|
725 void CAppMngr2MidletSettingsView::HandleMutuallyExclusiveSettingsL(const MidletSuiteSecuritySettings& aSettings) |
|
726 { |
|
727 for (int i=0; i<iMutuallyExclusiveSettings.size(); i++) |
|
728 { |
|
729 if (iMutuallyExclusiveSettings[i].getName() != aSettings.getName()) |
|
730 { |
|
731 TInt allowedInteractionModes = JavaCommonUtils::wstringToInt( |
|
732 iMutuallyExclusiveSettings[i].getAllowedInteractionModes()); |
|
733 wstring currentInteractionMode = iMutuallyExclusiveSettings[i] |
|
734 .getCurrentInteractionMode(); |
|
735 if ((allowedInteractionModes & INTERACTION_MODE_SESSION) > 0) |
|
736 { |
|
737 currentInteractionMode = SESSION_INTERACTION_MODE; |
|
738 } |
|
739 else if ((allowedInteractionModes & INTERACTION_MODE_ONESHOT) > 0) |
|
740 { |
|
741 currentInteractionMode = ONESHOT_INTERACTION_MODE; |
|
742 } |
|
743 else if ((allowedInteractionModes & INTERACTION_MODE_DENIED) > 0) |
|
744 { |
|
745 currentInteractionMode = DENIED_INTERACTION_MODE; |
|
746 } |
|
747 int err = iSettingsHandler->SetSecuritySettings( |
|
748 iMutuallyExclusiveSettings[i].getName(), currentInteractionMode); |
|
749 if (err == KErrNone) |
|
750 { |
|
751 UpdateBlanketSettings(iMutuallyExclusiveSettings[i], false); |
|
752 // do the refresh |
|
753 ListItem listItem1 = AppMngr2MidletSettingsUtil::SettingsToListItem( |
|
754 iMutuallyExclusiveSettings[i], true); |
|
755 ListItem listItem2(listItem1); |
|
756 std::vector<LocalizedString> values = listItem1.getValues(); |
|
757 for (int j=0; j<values.size(); j++) |
|
758 { |
|
759 if (values[j].getId() == currentInteractionMode) |
|
760 { |
|
761 listItem2.setCurrentValue(j); |
|
762 break; |
|
763 } |
|
764 } |
|
765 iContainer->RefreshListBoxContentL(listItem1, listItem2); |
|
766 } |
|
767 } |
|
768 } |
|
769 } |
|
770 |
|
771 // End of File |
|
772 |