1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 #include <hbmessagebox.h> |
|
18 #include <hbdataformviewitem.h> |
|
19 #include <hbcombobox.h> |
|
20 #include <hbpushbutton.h> |
|
21 #include <hbdataform.h> |
|
22 #include <hbdataformmodel.h> |
|
23 #include <hbdataformmodelitem.h> |
|
24 #include <hblabel.h> |
|
25 #include <hbaction.h> |
|
26 #include <QApplication> |
|
27 #include <QTranslator> |
|
28 #include <qnetworkconfigmanager.h> |
|
29 #include <qnetworkconfiguration.h> |
|
30 #include <algorithm> |
|
31 |
|
32 #include "javaapplicationsettings.h" |
|
33 #include "javaapplicationsettingsview.h" |
|
34 #include "javaapplicationsettingsview_p.h" |
|
35 #include "connectionmanager.h" |
|
36 #include "javacommonutils.h" |
|
37 |
|
38 #include "securitystoragedatadefs.h" |
|
39 #include "javastoragenames.h" |
|
40 |
|
41 QTM_USE_NAMESPACE |
|
42 |
|
43 using namespace java::storage; |
|
44 using namespace java::util; |
|
45 using namespace std; |
|
46 |
|
47 const wchar_t ON_SCREEN_KEYPAD_VALUE_NO[] = L"0"; |
|
48 const wchar_t ON_SCREEN_KEYPAD_VALUE_GAMEACTIONS[] = L"1"; |
|
49 const wchar_t ON_SCREEN_KEYPAD_VALUE_NAVIGATION[] = L"2"; |
|
50 |
|
51 JavaApplicationSettingsViewPrivate::JavaApplicationSettingsViewPrivate(const QString& aJavaAppUid): |
|
52 mainForm(0), model(0), generalSettingsGroup(0), securitySettingsGroup(0), netConnSettingsUi(0), asyncToSyncCallEventLoop(0), secWarningAccepted(false), defaultConnId(0) |
|
53 { |
|
54 // init storage |
|
55 iStorage.reset(JavaStorage::createInstance()); |
|
56 try |
|
57 { |
|
58 iStorage->open(); |
|
59 } |
|
60 catch (JavaStorageException& aJse) {} |
|
61 |
|
62 QTranslator translator; |
|
63 // load the correct translation of the localized strings for the cmmanager. |
|
64 // Load this one first since it contains the smallest amount of strings |
|
65 // (so it's ok to be searched last) |
|
66 installTranslator("cmapplsettingsui"); |
|
67 installTranslator("cmmanager"); |
|
68 // load the correct translation of the localized strings for the java settings |
|
69 // Current solution reads it from Z only (this does not work with IAD) |
|
70 // -> check if translator can handle path without drive letter (e.g. the resource |
|
71 // is loaded from the same drive where the DLL is loaded) |
|
72 installTranslator("javaruntimeapplicationsettings"); |
|
73 // init strings |
|
74 BLANKET = QString(hbTrId("txt_java_sett_setlabel_permission_val_blanket")); |
|
75 SESSION = QString(hbTrId("txt_java_sett_setlabel_permission_val_session")); |
|
76 ONESHOT = QString(hbTrId("txt_java_sett_setlabel_permission_val_oneshot")); |
|
77 DENIED = QString(hbTrId("txt_java_sett_setlabel_permission_val_no")); |
|
78 SECURITY_LEVEL = QString(hbTrId("txt_java_sett_setlabel_security_level")); |
|
79 USER_DEFINED = QString(hbTrId("txt_java_sett_setlabel_security_level_val_user_defined")); |
|
80 SENSITIVE_SETTINGS = QString(hbTrId("txt_java_sett_info_query_perm_sec")); |
|
81 SENSITIVE_SETTINGS_NET_USAGE = QString(hbTrId("txt_java_sett_info_query_perm_net")); |
|
82 MUTUALLY_EXCLUSIVE_SETTINGS = QString(hbTrId("txt_java_sett_info_query_perm_warn")); |
|
83 OK = QString(hbTrId("txt_java_sett_button_settings_ok")); |
|
84 CANCEL = QString(hbTrId("txt_java_sett_button_settings_cancel")); |
|
85 SECURITY_WARNING_TITLE = QString(hbTrId("txt_java_sett_title_note_security_warn")); |
|
86 NET_ACCESS = QString(hbTrId("txt_java_sett_setlabel_net_access")); |
|
87 LOW_LEVEL_NET_ACCESS = QString(hbTrId("txt_java_sett_setlabel_low_level_net_access")); |
|
88 NETWORK_CONNECTION = QString(hbTrId("txt_occ_title_network_connection")); |
|
89 SETTINGS_TITLE = QString(hbTrId("txt_java_sett_title_settings")); |
|
90 SETTINGS_NOT_AVAILABLE = QString(hbTrId("txt_java_sett_info_settings_not_available")); |
|
91 |
|
92 // init the suite UID from the application UID |
|
93 readSuiteUid(aJavaAppUid); |
|
94 if (iSuiteUid.size() <= 0) |
|
95 { |
|
96 return; |
|
97 } |
|
98 |
|
99 // init access point settings ui |
|
100 netConnSettingsUi = new CmApplSettingsUi(this); |
|
101 asyncToSyncCallEventLoop = new QEventLoop(); |
|
102 |
|
103 // read all settings |
|
104 readAllSettings(); |
|
105 |
|
106 // init form |
|
107 mainForm = new HbDataForm(); |
|
108 mainForm->setHeading(QString::fromStdWString(readFromStorage(PACKAGE_NAME, L"", L"", APPLICATION_PACKAGE_TABLE))); |
|
109 model = new HbDataFormModel(); |
|
110 |
|
111 // init settings |
|
112 generalSettingsGroup = model->appendDataFormGroup( |
|
113 QString(hbTrId("txt_java_sett_subtitle_general")), model->invisibleRootItem()); |
|
114 initSettings(generalSettings, generalSettingsGroup); |
|
115 // append the security settings only if there are any user settings |
|
116 if (extraSettings.size() > 0) |
|
117 { |
|
118 securitySettingsGroup = model->appendDataFormGroup( |
|
119 QString(hbTrId("txt_java_sett_subtitle_security")), model->invisibleRootItem()); |
|
120 initSettings(securitySettings, securitySettingsGroup); |
|
121 |
|
122 // if security warnings is user defined -> add the extra settings, expand |
|
123 if (securitySettings[0].getCurrentValue() == 1) |
|
124 { |
|
125 securityWarningsChanged(USER_DEFINED); |
|
126 } |
|
127 } |
|
128 |
|
129 // link form and model |
|
130 mainForm->setModel(model); |
|
131 mainForm->setExpanded(model->indexFromItem(generalSettingsGroup), true); |
|
132 if (extraSettings.size() > 0) |
|
133 { |
|
134 mainForm->setExpanded(model->indexFromItem(securitySettingsGroup), (securitySettings[0].getCurrentValue() == 1)); |
|
135 } |
|
136 } |
|
137 |
|
138 void JavaApplicationSettingsViewPrivate::init(JavaApplicationSettingsView* aPublicView) |
|
139 { |
|
140 iPublicView = aPublicView; |
|
141 |
|
142 if (mainForm) |
|
143 { |
|
144 // do the connect for the main form |
|
145 iPublicView->connect(mainForm, SIGNAL(itemShown(const QModelIndex)), |
|
146 iPublicView, SLOT(_q_dataItemDisplayed(const QModelIndex))); |
|
147 |
|
148 // set the form as view's widget |
|
149 iPublicView->setWidget(mainForm); |
|
150 } |
|
151 else |
|
152 { |
|
153 // no settings available |
|
154 HbLabel* label = new HbLabel(SETTINGS_NOT_AVAILABLE, iPublicView); |
|
155 label->setAlignment(Qt::AlignVCenter); |
|
156 } |
|
157 |
|
158 // set title |
|
159 iPublicView->setTitle(SETTINGS_TITLE); |
|
160 } |
|
161 |
|
162 JavaApplicationSettingsViewPrivate::~JavaApplicationSettingsViewPrivate() |
|
163 { |
|
164 delete mainForm; |
|
165 delete model; |
|
166 delete netConnSettingsUi; |
|
167 delete asyncToSyncCallEventLoop; |
|
168 foreach (QTranslator *translator, translators) { |
|
169 qApp->removeTranslator(translator); |
|
170 } |
|
171 qDeleteAll(translators); |
|
172 translators.clear(); |
|
173 } |
|
174 |
|
175 void JavaApplicationSettingsViewPrivate::readAllSettings() |
|
176 { |
|
177 // general settings |
|
178 QStringList settingsValues; |
|
179 vector<wstring> storageValues; |
|
180 if (!findFromStorage(VALUE, NAME, L"Nokia-MIDlet-On-Screen-Keypad", APPLICATION_PACKAGE_ATTRIBUTES_TABLE)) |
|
181 { |
|
182 // if the on screen keypad is predefined, it should not be changable by user |
|
183 // -> right now it is not added to settings list. It should be changed so that |
|
184 // the setting should not be editable by user |
|
185 settingsValues<<QString(hbTrId("txt_java_sett_setlabel_osk_val_no"))<<QString(hbTrId("txt_java_sett_setlabel_osk_val_game"))<<QString(hbTrId("txt_java_sett_setlabel_osk_val_navigation")); |
|
186 storageValues.push_back(ON_SCREEN_KEYPAD_VALUE_NO); |
|
187 storageValues.push_back(ON_SCREEN_KEYPAD_VALUE_GAMEACTIONS); |
|
188 storageValues.push_back(ON_SCREEN_KEYPAD_VALUE_NAVIGATION); |
|
189 generalSettings.append(JavaApplicationSettings(QString(hbTrId("txt_java_sett_setlabel_osk")), settingsValues, ON_SCREEN_KEYPAD, MIDP_PACKAGE_TABLE, storageValues)); |
|
190 readFromStorage(generalSettings[0]); |
|
191 } |
|
192 settingsValues = QStringList(); |
|
193 initNetworkConnection(); |
|
194 settingsValues<<netConn.name; |
|
195 generalSettings.append(JavaApplicationSettings(NETWORK_CONNECTION, settingsValues)); |
|
196 netSettIndex = generalSettings.size() - 1; |
|
197 |
|
198 // security settings |
|
199 settingsValues = QStringList(); |
|
200 storageValues.clear(); |
|
201 settingsValues<<QString(hbTrId("txt_java_sett_setlabel_security_level_val_default"))<<USER_DEFINED; |
|
202 storageValues.push_back(SECURITY_WARNINGS_DEFAULT_MODE); |
|
203 storageValues.push_back(SECURITY_WARNINGS_USER_DEFINED_MODE); |
|
204 securitySettings.append(JavaApplicationSettings(SECURITY_LEVEL, settingsValues, SECURITY_WARNINGS, MIDP_PACKAGE_TABLE, storageValues)); |
|
205 readFromStorage(securitySettings[0]); |
|
206 |
|
207 // extra settings |
|
208 settingsValues = QStringList(); |
|
209 storageValues.clear(); |
|
210 settingsValues<<ONESHOT<<SESSION<<BLANKET<<DENIED; |
|
211 storageValues.push_back(ONESHOT_INTERACTION_MODE); |
|
212 storageValues.push_back(SESSION_INTERACTION_MODE); |
|
213 storageValues.push_back(BLANKET_INTERACTION_MODE); |
|
214 storageValues.push_back(DENIED_INTERACTION_MODE); |
|
215 // init the known localized settings names |
|
216 QHash<QString, QString> localizedSettingsNames; |
|
217 localizedSettingsNames[QString::fromStdWString(NET_ACCESS_SETTINGS)] = NET_ACCESS; |
|
218 localizedSettingsNames[QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS)] = LOW_LEVEL_NET_ACCESS; |
|
219 localizedSettingsNames[QString::fromStdWString(MESSAGING_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_messaging")); |
|
220 localizedSettingsNames[QString::fromStdWString(RESTRICTED_MESSAGING_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_restricted_messaging")); |
|
221 localizedSettingsNames[QString::fromStdWString(CALL_CONTROL_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_call_control")); |
|
222 localizedSettingsNames[QString::fromStdWString(LOCAL_CONNECTIVITY_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_local_conn")); |
|
223 localizedSettingsNames[QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_mm_record")); |
|
224 localizedSettingsNames[QString::fromStdWString(WRITE_USER_DATA_ACCESS_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_write_data")); |
|
225 localizedSettingsNames[QString::fromStdWString(READ_USER_DATA_ACCESS_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_read_data")); |
|
226 localizedSettingsNames[QString::fromStdWString(LOCATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_location")); |
|
227 localizedSettingsNames[QString::fromStdWString(LANDMARK_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_landmarks")); |
|
228 localizedSettingsNames[QString::fromStdWString(AUTHENTICATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_auth")); |
|
229 localizedSettingsNames[QString::fromStdWString(SMART_CARD_COMMUNICATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_smartcard")); |
|
230 localizedSettingsNames[QString::fromStdWString(APPLICATION_AUTO_INVOCATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_app_auto_invoc")); |
|
231 localizedSettingsNames[QString::fromStdWString(BROADCAST_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_broadcast")); |
|
232 localizedSettingsNames[QString::fromStdWString(NFC_WRITE_ACCESS_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_nfc_write_access")); |
|
233 localizedSettingsNames[QString::fromStdWString(URL_START_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_url_start")); |
|
234 vector<IndexedSettingsName> allSecuritySettings = readFromStorage(FUNCTION_GROUP, MIDP_FUNC_GRP_SETTINGS_TABLE, MIDP_PERMISSIONS_TABLE); |
|
235 // sort the security settings according to how they should be displayed |
|
236 std::sort(allSecuritySettings.begin(), allSecuritySettings.end(), AscendingSort()); |
|
237 QHash<QString, int> settingsIndexes; |
|
238 for(int i=0; i<allSecuritySettings.size(); i++) |
|
239 { |
|
240 QString rawSettingsName = QString::fromStdWString(allSecuritySettings[i].name); |
|
241 QString localizedSettingsName = rawSettingsName; |
|
242 if (localizedSettingsNames.contains(rawSettingsName)) |
|
243 localizedSettingsName = localizedSettingsNames.value(rawSettingsName); |
|
244 extraSettings.append(JavaApplicationSettings( |
|
245 localizedSettingsName, settingsValues, CURRENT_SETTING, |
|
246 MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, |
|
247 allSecuritySettings[i].name, ALLOWED_SETTINGS)); |
|
248 readFromStorage(extraSettings[i]); |
|
249 settingsIndexes[rawSettingsName] = i; |
|
250 } |
|
251 |
|
252 // configure the high risk lists |
|
253 QList<JavaApplicationSettings*> highRiskList; |
|
254 QStringList highRiskSettingsNames; |
|
255 highRiskSettingsNames |
|
256 <<QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS) |
|
257 <<QString::fromStdWString(READ_USER_DATA_ACCESS_SETTINGS); |
|
258 configureList(highRiskList, highRiskSettingsNames, settingsIndexes); |
|
259 // net access with multimedia and read user data |
|
260 attachList(QString::fromStdWString(NET_ACCESS_SETTINGS),highRiskList, settingsIndexes); |
|
261 // low level net access with multimedia and read user data |
|
262 attachList(QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS),highRiskList, settingsIndexes); |
|
263 // messaging with multimedia and read user data |
|
264 attachList(QString::fromStdWString(MESSAGING_SETTINGS),highRiskList, settingsIndexes); |
|
265 // restricted messaging with multimedia and read user data |
|
266 attachList(QString::fromStdWString(RESTRICTED_MESSAGING_SETTINGS),highRiskList, settingsIndexes); |
|
267 // call control with multimedia and read user data |
|
268 attachList(QString::fromStdWString(CALL_CONTROL_SETTINGS),highRiskList, settingsIndexes); |
|
269 // local connectivity with multimedia and read user data |
|
270 attachList(QString::fromStdWString(LOCAL_CONNECTIVITY_SETTINGS),highRiskList, settingsIndexes); |
|
271 // multimedia with net access, low level net access, messaging, |
|
272 // restricted messaging, call control and local connectivity |
|
273 highRiskList.clear(); |
|
274 highRiskSettingsNames.clear(); |
|
275 highRiskSettingsNames |
|
276 <<QString::fromStdWString(NET_ACCESS_SETTINGS) |
|
277 <<QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS) |
|
278 <<QString::fromStdWString(MESSAGING_SETTINGS) |
|
279 <<QString::fromStdWString(RESTRICTED_MESSAGING_SETTINGS) |
|
280 <<QString::fromStdWString(CALL_CONTROL_SETTINGS) |
|
281 <<QString::fromStdWString(LOCAL_CONNECTIVITY_SETTINGS) |
|
282 <<QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS); |
|
283 configureList(highRiskList, highRiskSettingsNames, settingsIndexes); |
|
284 attachList(QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS),highRiskList, settingsIndexes); |
|
285 // read user data with net access, low level net access, messaging, |
|
286 // restricted messaging, call control and local connectivity |
|
287 attachList(QString::fromStdWString(READ_USER_DATA_ACCESS_SETTINGS),highRiskList, settingsIndexes); |
|
288 |
|
289 // configure the mutually exclusive list |
|
290 QList<JavaApplicationSettings*> mutuallyExclusiveList; |
|
291 QStringList mutuallyExclusiveSettingsNames; |
|
292 mutuallyExclusiveSettingsNames |
|
293 <<QString::fromStdWString(APPLICATION_AUTO_INVOCATION_SETTINGS); |
|
294 configureList(mutuallyExclusiveList, mutuallyExclusiveSettingsNames, settingsIndexes); |
|
295 //net access with application auto invocation |
|
296 attachList(QString::fromStdWString(NET_ACCESS_SETTINGS),mutuallyExclusiveList, settingsIndexes, false /* is high risk list */); |
|
297 //low level net access with application auto invocation |
|
298 attachList(QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS),mutuallyExclusiveList, settingsIndexes, false /* is high risk list */); |
|
299 //application auto invocation with net access and low level net access |
|
300 mutuallyExclusiveList.clear(); |
|
301 mutuallyExclusiveSettingsNames.clear(); |
|
302 mutuallyExclusiveSettingsNames |
|
303 <<QString::fromStdWString(NET_ACCESS_SETTINGS) |
|
304 <<QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS); |
|
305 configureList(mutuallyExclusiveList, mutuallyExclusiveSettingsNames, settingsIndexes); |
|
306 attachList(QString::fromStdWString(APPLICATION_AUTO_INVOCATION_SETTINGS),mutuallyExclusiveList, settingsIndexes, false /* is high risk list */); |
|
307 } |
|
308 |
|
309 void JavaApplicationSettingsViewPrivate::initSettings(QVector<JavaApplicationSettings>& settings, HbDataFormModelItem * parent) |
|
310 { |
|
311 for (int i=0; i<settings.size(); i++) |
|
312 { |
|
313 HbDataFormModelItem * appSettings = NULL; |
|
314 int currentValue = 0; |
|
315 switch(settings[i].getValues().size()) |
|
316 { |
|
317 case 1: |
|
318 appSettings = model->appendDataFormItem( |
|
319 HbDataFormModelItem::ToggleValueItem, |
|
320 settings[i].getName(), parent); |
|
321 appSettings->setContentWidgetData(QString("text"), settings[i].getValues()[0]); |
|
322 appSettings->setContentWidgetData(QString("additionalText"), settings[i].getValues()[0]); |
|
323 break; |
|
324 case 2: |
|
325 appSettings = model->appendDataFormItem( |
|
326 HbDataFormModelItem::ToggleValueItem, |
|
327 settings[i].getName(), parent); |
|
328 currentValue = settings[i].getCurrentValue(); |
|
329 if (currentValue < 0) |
|
330 { |
|
331 currentValue = 0; |
|
332 } |
|
333 // make it a toogle button (-> get rid of the "pressed" ui effect) |
|
334 appSettings->setContentWidgetData(QString("text"), settings[i].getValues()[currentValue]); |
|
335 appSettings->setContentWidgetData(QString("additionalText"),settings[i].getValues()[1 - currentValue]); |
|
336 break; |
|
337 default: |
|
338 appSettings = model->appendDataFormItem( |
|
339 HbDataFormModelItem::ComboBoxItem, |
|
340 settings[i].getName(), parent); |
|
341 appSettings->setContentWidgetData(QString("items"), settings[i].getValues()); |
|
342 appSettings->setContentWidgetData(QString("currentIndex"),settings[i].getCurrentValue()); |
|
343 } |
|
344 settings[i].setId(appSettings); |
|
345 } |
|
346 } |
|
347 |
|
348 void JavaApplicationSettingsViewPrivate::writeSettings(JavaApplicationSettings& settings, const QString &aNewValue) |
|
349 { |
|
350 QStringList values = settings.getValues(); |
|
351 int currentValue = settings.getCurrentValue(); |
|
352 int newValue = settings.getValue(aNewValue); |
|
353 if (newValue != -1 && currentValue != newValue) |
|
354 { |
|
355 // handle blanket settings |
|
356 if (aNewValue == BLANKET) |
|
357 { |
|
358 // check blanket settings |
|
359 if (!blanketAllowed(settings)) |
|
360 { |
|
361 // change back to the old value |
|
362 HbComboBox * settingsCombo = static_cast<HbComboBox*>(itemToWidget(settings.getId())); |
|
363 settingsCombo->setCurrentIndex(currentValue); |
|
364 return; |
|
365 } |
|
366 } |
|
367 settings.setCurrentValue(newValue); |
|
368 writeToStorage(settings); |
|
369 } |
|
370 } |
|
371 |
|
372 bool JavaApplicationSettingsViewPrivate::blanketAllowed(const JavaApplicationSettings &settings) |
|
373 { |
|
374 // handle the high risk items |
|
375 QList<JavaApplicationSettings*> highRiskList = settings.getHighRiskList(); |
|
376 if (highRiskList.size() > 0) |
|
377 { |
|
378 // go through the list and see if any of the setings are in blanket |
|
379 for (int i=0; i<highRiskList.size(); i++) |
|
380 { |
|
381 if (highRiskList[i]->getValue(highRiskList[i]->getCurrentValue()) |
|
382 == BLANKET) |
|
383 { |
|
384 QString secWarning = SENSITIVE_SETTINGS; |
|
385 QString LOCAL_CONNECTIVITY = QString(hbTrId("txt_java_sett_setlabel_local_conn")); |
|
386 if (settings.getName() != LOCAL_CONNECTIVITY |
|
387 && highRiskList[i]->getName() != LOCAL_CONNECTIVITY) |
|
388 { |
|
389 secWarning = SENSITIVE_SETTINGS_NET_USAGE; |
|
390 } |
|
391 if (!securityWarningAccepted( |
|
392 secWarning,OK,CANCEL ,SECURITY_WARNING_TITLE)) |
|
393 { |
|
394 return false; |
|
395 } |
|
396 break; |
|
397 } |
|
398 } |
|
399 } |
|
400 // handle the mutually exclusive rules |
|
401 QList<JavaApplicationSettings*> mutuallyExclusiveList = settings |
|
402 .getMutuallyExclusiveList(); |
|
403 if (mutuallyExclusiveList.size() > 0) |
|
404 { |
|
405 // go through the list and see if any of the setings are in blanket |
|
406 for (int i=0; i<mutuallyExclusiveList.size(); i++) |
|
407 { |
|
408 if (mutuallyExclusiveList[i]->getValue( |
|
409 mutuallyExclusiveList[i]->getCurrentValue()) == BLANKET) |
|
410 { |
|
411 bool isBlanketAllowed = securityWarningAccepted( |
|
412 MUTUALLY_EXCLUSIVE_SETTINGS, OK, CANCEL, SECURITY_WARNING_TITLE); |
|
413 if (isBlanketAllowed) |
|
414 { |
|
415 // change the current value to the maximum allowed |
|
416 bool isBlanket = true; |
|
417 do |
|
418 { |
|
419 if (isBlanket) |
|
420 { |
|
421 QStringList allowedValues = mutuallyExclusiveList[i]->getValues(); |
|
422 int selectedValue = mutuallyExclusiveList[i]->getCurrentValue(); |
|
423 // select the maximum allowed value |
|
424 for (int j=0; j<allowedValues.size(); j++) |
|
425 { |
|
426 if (allowedValues[j] == SESSION) |
|
427 { |
|
428 selectedValue = j; |
|
429 break; |
|
430 } |
|
431 if (allowedValues[j] == ONESHOT) |
|
432 { |
|
433 selectedValue = j; |
|
434 } |
|
435 else if (allowedValues[j] == DENIED |
|
436 && allowedValues[selectedValue] == BLANKET) |
|
437 { |
|
438 selectedValue = j; |
|
439 } |
|
440 } |
|
441 // set the maximum allowed value |
|
442 mutuallyExclusiveList[i]->setCurrentValue(selectedValue); |
|
443 HbComboBox * settingsCombo = static_cast<HbComboBox*>(itemToWidget( |
|
444 mutuallyExclusiveList[i]->getId())); |
|
445 settingsCombo->setCurrentIndex(selectedValue); |
|
446 writeToStorage(*mutuallyExclusiveList[i]); |
|
447 } |
|
448 i++; |
|
449 // end of list? |
|
450 if (i >= mutuallyExclusiveList.size()) |
|
451 { |
|
452 break; |
|
453 } |
|
454 // move on into the list |
|
455 isBlanket = (mutuallyExclusiveList[i]->getValue( |
|
456 mutuallyExclusiveList[i]->getCurrentValue()) == BLANKET); |
|
457 } |
|
458 while (true); |
|
459 } |
|
460 return isBlanketAllowed; |
|
461 } |
|
462 } |
|
463 } |
|
464 return true; |
|
465 } |
|
466 |
|
467 void JavaApplicationSettingsViewPrivate::_q_settingsChanged(bool) |
|
468 { |
|
469 HbPushButton * sender = static_cast<HbPushButton*>(iPublicView->sender()); |
|
470 if (sender) |
|
471 { |
|
472 JavaApplicationSettings* settings = findSettings(sender); |
|
473 if (settings->getName() == SECURITY_LEVEL) |
|
474 { |
|
475 QString newValue = settings->getValue(1 - settings->getCurrentValue()); |
|
476 securityWarningsChanged(newValue); |
|
477 writeSettings(*settings, newValue); |
|
478 } |
|
479 else if (settings->getName() == NETWORK_CONNECTION) |
|
480 { |
|
481 handleNetworkSettings(); |
|
482 } |
|
483 } |
|
484 } |
|
485 void JavaApplicationSettingsViewPrivate::_q_settingsChanged(const QString &newValue) |
|
486 { |
|
487 HbComboBox * sender = static_cast<HbComboBox*>(iPublicView->sender()); |
|
488 if (sender) |
|
489 { |
|
490 JavaApplicationSettings* settings = findSettings(sender); |
|
491 if (settings != NULL) |
|
492 { |
|
493 // any other settings are treated same |
|
494 writeSettings(*settings, newValue); |
|
495 } |
|
496 } |
|
497 } |
|
498 |
|
499 void JavaApplicationSettingsViewPrivate::securityWarningsChanged(const QString &newValue) |
|
500 { |
|
501 if (newValue == USER_DEFINED) |
|
502 { |
|
503 // append the extra settings and values |
|
504 for (int i=0; i<extraSettings.size(); i++) |
|
505 { |
|
506 if (extraSettings[i].getCurrentValue() >= 0 && extraSettings[i].getId() == 0) |
|
507 { |
|
508 HbDataFormModelItem * appSettings = model->appendDataFormItem( |
|
509 HbDataFormModelItem::ComboBoxItem, |
|
510 extraSettings[i].getName(), securitySettingsGroup); |
|
511 extraSettings[i].setId(appSettings); |
|
512 // when settings the items, the settingsChanged signal gets emitted with the first value |
|
513 // as being the current value. This signal should be discarded (the first value is just |
|
514 // an intermediate value towards the actual current value which gets set shortly). |
|
515 // Therefore set the first value as the current value (this way the settingsChanged |
|
516 // signal gets discarded) and change the current value back to the real current value |
|
517 int currentValue = extraSettings[i].getCurrentValue(); |
|
518 extraSettings[i].setCurrentValue(0); |
|
519 appSettings->setContentWidgetData(QString("items"), extraSettings[i].getValues()); |
|
520 extraSettings[i].setCurrentValue(currentValue); |
|
521 appSettings->setContentWidgetData(QString("currentIndex"),extraSettings[i].getCurrentValue()); |
|
522 } |
|
523 } |
|
524 } |
|
525 else |
|
526 { |
|
527 // remove the extra settings |
|
528 for (int i=0; i<extraSettings.size(); i++) |
|
529 { |
|
530 if (extraSettings[i].getId()) |
|
531 { |
|
532 HbComboBox * extraSettingsId = static_cast<HbComboBox*>(itemToWidget(extraSettings[i].getId())); |
|
533 if (extraSettingsId) |
|
534 { |
|
535 iPublicView->disconnect(extraSettingsId, 0, 0, 0); |
|
536 model->removeItem(model->indexFromItem(extraSettings[i].getId())); |
|
537 extraSettings[i].setId(0); |
|
538 extraSettings[i].disconnectFromUi(); |
|
539 } |
|
540 } |
|
541 } |
|
542 } |
|
543 } |
|
544 |
|
545 void JavaApplicationSettingsViewPrivate::handleNetworkSettings() |
|
546 { |
|
547 // init flags to show destinations and connection methods |
|
548 QFlags<CmApplSettingsUi::SelectionDialogItems> listItems; |
|
549 listItems |= CmApplSettingsUi::ShowDestinations; |
|
550 listItems |= CmApplSettingsUi::ShowConnectionMethods; |
|
551 |
|
552 // empty filter -> all bearer types included |
|
553 QSet<CmApplSettingsUi::BearerTypeFilter> filter; |
|
554 // reset the result |
|
555 netConnSelection.result = netConn.type; |
|
556 netConnSelection.id = netConn.id; |
|
557 // init settings ui with destinations, filter and initial selection |
|
558 netConnSettingsUi->setOptions(listItems, filter); |
|
559 netConnSettingsUi->setSelection(netConnSelection); |
|
560 // Connect the setting ui's signal with own slot where the netConnSelection is stored |
|
561 connect(netConnSettingsUi, SIGNAL(finished(uint)), this, SLOT(netConnSelected(uint))); |
|
562 // launch the setting ui |
|
563 netConnSettingsUi->open(); |
|
564 } |
|
565 |
|
566 void JavaApplicationSettingsViewPrivate::_q_dataItemDisplayed(const QModelIndex dataItemIndex) |
|
567 { |
|
568 HbDataFormModelItem *item = static_cast<HbDataFormModel*>( |
|
569 mainForm->model())->itemFromIndex(dataItemIndex); |
|
570 int itemType = item->data(HbDataFormModelItem::ItemTypeRole).toInt(); |
|
571 HbComboBox * comboBox = NULL; |
|
572 HbPushButton * pushButton = NULL; |
|
573 HbWidget * widget = (qobject_cast<HbDataFormViewItem *> |
|
574 (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget(); |
|
575 JavaApplicationSettings* settings = findSettings(widget); |
|
576 if (settings == NULL) |
|
577 { |
|
578 // stop right here |
|
579 return; |
|
580 } |
|
581 switch(HbDataFormModelItem::DataItemType(itemType)) |
|
582 { |
|
583 case HbDataFormModelItem::ComboBoxItem: |
|
584 comboBox = static_cast<HbComboBox*>(widget); |
|
585 if (settings->isConnectedToUi()) |
|
586 { |
|
587 // need to do a reconnect: disconnect followed by a connect |
|
588 iPublicView->disconnect(comboBox, |
|
589 SIGNAL(currentIndexChanged(const QString &)), |
|
590 iPublicView, |
|
591 SLOT(_q_settingsChanged(const QString &))); |
|
592 } |
|
593 iPublicView->connect(comboBox, |
|
594 SIGNAL(currentIndexChanged(const QString &)), |
|
595 iPublicView, SLOT(_q_settingsChanged(const QString &)), |
|
596 Qt::UniqueConnection); |
|
597 break; |
|
598 case HbDataFormModelItem::ToggleValueItem: |
|
599 pushButton = static_cast< HbPushButton*>(widget); |
|
600 if (settings->isConnectedToUi()) |
|
601 { |
|
602 // need to do a reconnect: disconnect followed by a connect |
|
603 iPublicView->disconnect(pushButton, |
|
604 SIGNAL(clicked(bool)), |
|
605 iPublicView, |
|
606 SLOT(_q_settingsChanged(bool))); |
|
607 } |
|
608 iPublicView->connect(pushButton, |
|
609 SIGNAL(clicked(bool)), |
|
610 iPublicView, SLOT(_q_settingsChanged(bool)), |
|
611 Qt::UniqueConnection); |
|
612 break; |
|
613 } |
|
614 settings->connectToUi(); |
|
615 } |
|
616 |
|
617 void JavaApplicationSettingsViewPrivate::netConnSelected(uint netConnSelectionStatus) |
|
618 { |
|
619 if (netConnSelectionStatus == CmApplSettingsUi::ApplSettingsErrorNone) |
|
620 { |
|
621 netConnSelection = netConnSettingsUi->selection(); |
|
622 // store the selection |
|
623 if (netConnSelection.id != netConn.id |
|
624 && netConnSelection.id != defaultConnId) |
|
625 { |
|
626 TRAPD(err, |
|
627 switch(netConnSelection.result) |
|
628 { |
|
629 case CmApplSettingsUi::SelectionTypeDestination: |
|
630 ConnectionManager::setDestinationNetworkIdL(iSuiteUid, netConnSelection.id); |
|
631 break; |
|
632 case CmApplSettingsUi::SelectionTypeConnectionMethod: |
|
633 ConnectionManager::setApnIdL(iSuiteUid, netConnSelection.id); |
|
634 break; |
|
635 } |
|
636 ); |
|
637 if (err == KErrNone) |
|
638 { |
|
639 netConn.id = netConnSelection.id; |
|
640 netConn.type = netConnSelection.result; |
|
641 readNetworkConnectionName(); |
|
642 generalSettings[netSettIndex].getId()->setContentWidgetData(QString("text"), netConn.name); |
|
643 generalSettings[netSettIndex].getId()->setContentWidgetData(QString("additionalText"), netConn.name); |
|
644 } |
|
645 } |
|
646 } |
|
647 } |
|
648 |
|
649 void JavaApplicationSettingsViewPrivate::securityWarningDismissed(HbAction* action) |
|
650 { |
|
651 HbMessageBox *dlg = static_cast<HbMessageBox*>(sender()); |
|
652 secWarningAccepted = (action == dlg->actions().at(0)); |
|
653 asyncToSyncCallEventLoop->exit(); |
|
654 } |
|
655 |
|
656 void JavaApplicationSettingsViewPrivate::initNetworkConnection() |
|
657 { |
|
658 TRAP_IGNORE( |
|
659 netConn.id = ConnectionManager::getDestinationNetworkIdL(iSuiteUid); |
|
660 if (netConn.id == (uint)KJavaNetworkAccessNotSpecified) |
|
661 { |
|
662 netConn.id = ConnectionManager::getApnIdL(iSuiteUid); |
|
663 } |
|
664 ); |
|
665 QNetworkConfigurationManager manager; |
|
666 QNetworkConfiguration defaultCfg = manager.defaultConfiguration(); |
|
667 defaultConnId = defaultCfg.identifier().toInt(); |
|
668 QNetworkConfiguration cfg = manager.configurationFromIdentifier( |
|
669 QString::number(netConn.id)); |
|
670 if (!cfg.isValid()) |
|
671 { |
|
672 cfg = defaultCfg; |
|
673 } |
|
674 netConn.name = QString(hbTrId(cfg.name().toUtf8())); |
|
675 } |
|
676 |
|
677 void JavaApplicationSettingsViewPrivate::readNetworkConnectionName() |
|
678 { |
|
679 QNetworkConfigurationManager manager; |
|
680 QNetworkConfiguration cfg = manager.configurationFromIdentifier( |
|
681 QString::number(netConn.id)); |
|
682 if (!cfg.isValid()) |
|
683 { |
|
684 cfg = manager.defaultConfiguration(); |
|
685 } |
|
686 netConn.name = QString(hbTrId(cfg.name().toUtf8())); |
|
687 } |
|
688 |
|
689 JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbWidget* id) |
|
690 { |
|
691 JavaApplicationSettings* settings = findSettings(id, generalSettings); |
|
692 if (settings == NULL) |
|
693 { |
|
694 settings = findSettings(id, securitySettings); |
|
695 if (settings == NULL) |
|
696 { |
|
697 settings = findSettings(id, extraSettings); |
|
698 } |
|
699 } |
|
700 return settings; |
|
701 } |
|
702 |
|
703 JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbWidget* id, QVector<JavaApplicationSettings>& allSettings) |
|
704 { |
|
705 for (int i=0; i<allSettings.size(); i++) |
|
706 { |
|
707 if (itemToWidget(allSettings[i].getId()) == id) |
|
708 { |
|
709 return &allSettings[i]; |
|
710 } |
|
711 } |
|
712 return NULL; |
|
713 } |
|
714 |
|
715 HbWidget * JavaApplicationSettingsViewPrivate::itemToWidget(const HbDataFormModelItem * item) |
|
716 { |
|
717 HbDataFormViewItem * viewItem = qobject_cast<HbDataFormViewItem *> (mainForm->itemByIndex( |
|
718 model->indexFromItem(item))); |
|
719 if (viewItem) |
|
720 { |
|
721 return static_cast<HbWidget*>(viewItem->dataItemContentWidget()); |
|
722 } |
|
723 return NULL; |
|
724 } |
|
725 |
|
726 bool JavaApplicationSettingsViewPrivate::securityWarningAccepted(const QString& text, const QString& acceptActionLabel, const QString& rejectActionLabel, const QString& headingText) |
|
727 { |
|
728 HbMessageBox securityWarning(HbMessageBox::MessageTypeQuestion); |
|
729 securityWarning.setDismissPolicy(HbDialog::NoDismiss); |
|
730 securityWarning.setTimeout(HbDialog::NoTimeout); |
|
731 securityWarning.setIconVisible(false); |
|
732 securityWarning.setText(text); |
|
733 securityWarning.addAction(new HbAction( |
|
734 acceptActionLabel, &securityWarning)); |
|
735 securityWarning.addAction(new HbAction( |
|
736 rejectActionLabel, &securityWarning)); |
|
737 securityWarning.setHeadingWidget(new HbLabel(headingText)); |
|
738 securityWarning.open(this, SLOT(securityWarningDismissed(HbAction*))); |
|
739 asyncToSyncCallEventLoop->exec(); |
|
740 return secWarningAccepted; |
|
741 } |
|
742 |
|
743 void JavaApplicationSettingsViewPrivate::configureList(QList<JavaApplicationSettings*>& list, const QStringList& settingsNames, const QHash<QString, int>& settingsIndexes) |
|
744 { |
|
745 for(int i=0; i<settingsNames.size(); i++) |
|
746 { |
|
747 if (settingsIndexes.contains(settingsNames[i])) |
|
748 { |
|
749 list << &(extraSettings[settingsIndexes.value(settingsNames[i])]); |
|
750 } |
|
751 } |
|
752 } |
|
753 |
|
754 void JavaApplicationSettingsViewPrivate::attachList(const QString& settingsName, const QList<JavaApplicationSettings*>& list, const QHash<QString, int>& settingsIndexes, bool isHighRiskList) |
|
755 { |
|
756 if (settingsIndexes.contains(settingsName)) |
|
757 { |
|
758 if (isHighRiskList) |
|
759 { |
|
760 extraSettings[settingsIndexes.value(settingsName)].setHighRiskList(list); |
|
761 } |
|
762 else |
|
763 { |
|
764 extraSettings[settingsIndexes.value(settingsName)].setMutuallyExclusiveList(list); |
|
765 } |
|
766 } |
|
767 } |
|
768 |
|
769 void JavaApplicationSettingsViewPrivate::installTranslator(const QString& translationFileName) |
|
770 { |
|
771 QTranslator* translator = new QTranslator; |
|
772 |
|
773 // load the correct translation of the localized strings for the java settings |
|
774 // Current solution reads it from Z only (this does not work with IAD) |
|
775 // -> check if translator can handle path without drive letter (e.g. the resource |
|
776 // is loaded from the same drive where the DLL is loaded) |
|
777 if (translator->load("z:/resource/qt/translations/" |
|
778 + translationFileName + "_" + QLocale::system().name())) |
|
779 { |
|
780 translators.append(translator); |
|
781 qApp->installTranslator(translator); |
|
782 } |
|
783 else |
|
784 { |
|
785 delete translator; |
|
786 translator = NULL; |
|
787 } |
|
788 } |
|
789 |
|
790 void JavaApplicationSettingsViewPrivate::readFromStorage(JavaApplicationSettings& settings) |
|
791 { |
|
792 if (settings.getColumnName().size() > 0 |
|
793 && settings.getTableName().size() > 0) |
|
794 { |
|
795 wstring value = L""; |
|
796 |
|
797 JavaStorageApplicationEntry_t query; |
|
798 JavaStorageApplicationList_t queryResult; |
|
799 JavaStorageEntry attr; |
|
800 attr.setEntry(ID, iSuiteUid); |
|
801 query.insert(attr); |
|
802 if (settings.getFilterColumnName().size() > 0) |
|
803 { |
|
804 attr.setEntry(settings.getFilterColumnName(), settings.getFilterColumnValue()); |
|
805 query.insert(attr); |
|
806 } |
|
807 attr.setEntry(settings.getColumnName(), L""); |
|
808 query.insert(attr); |
|
809 if (settings.getValuesColumnName().size() > 0) |
|
810 { |
|
811 attr.setEntry(settings.getValuesColumnName(), L""); |
|
812 query.insert(attr); |
|
813 } |
|
814 |
|
815 try |
|
816 { |
|
817 iStorage->search(settings.getTableName(), query, queryResult); |
|
818 } |
|
819 catch (JavaStorageException& aJse) |
|
820 { |
|
821 // Don't leave. Set defaults. |
|
822 } |
|
823 |
|
824 if (settings.getValuesColumnName().size() > 0) |
|
825 { |
|
826 findEntry(queryResult, settings.getValuesColumnName(), value); |
|
827 if (value.size() > 0) |
|
828 { |
|
829 settings.setStorageValuesFilter(value); |
|
830 filterSecuritySettings(settings); |
|
831 } |
|
832 } |
|
833 |
|
834 value = L""; |
|
835 findEntry(queryResult, settings.getColumnName(), value); |
|
836 |
|
837 if (value.size() > 0) |
|
838 { |
|
839 vector<wstring> storageValues = settings.getStorageValues(); |
|
840 for (int i=0; i<storageValues.size(); i++) |
|
841 { |
|
842 if (storageValues[i] == value) |
|
843 { |
|
844 settings.setCurrentValue(i); |
|
845 break; |
|
846 } |
|
847 } |
|
848 } |
|
849 } |
|
850 } |
|
851 |
|
852 void JavaApplicationSettingsViewPrivate::filterSecuritySettings(JavaApplicationSettings& settings) |
|
853 { |
|
854 std::wstring allowedModes = settings.getStorageValuesFilter(); |
|
855 if (allowedModes.size() <= 0) |
|
856 { |
|
857 return; |
|
858 } |
|
859 // The allowed modes info is stored as a 4-bit constant: |
|
860 // X(oneshot)X(session)X(blanket)X(no) |
|
861 // e.g. 1011 (=11) means that oneshot, blanket and no are allowed. |
|
862 // The following constants are used to encode/decode the allowed modes |
|
863 // into/from a 4-bit number |
|
864 int INTERACTION_MODE_DENIED = 1; |
|
865 int INTERACTION_MODE_BLANKET = 2; |
|
866 int INTERACTION_MODE_SESSION = 4; |
|
867 int INTERACTION_MODE_ONESHOT = 8; |
|
868 TInt allowedInteractionModes = JavaCommonUtils::wstringToInt(allowedModes); |
|
869 int index = 0; |
|
870 int tmp = allowedInteractionModes & INTERACTION_MODE_ONESHOT; |
|
871 if (tmp <= 0) |
|
872 { |
|
873 settings.removeValue(index); |
|
874 index--; |
|
875 } |
|
876 index++; |
|
877 tmp = allowedInteractionModes & INTERACTION_MODE_SESSION; |
|
878 if (tmp <= 0) |
|
879 { |
|
880 settings.removeValue(index); |
|
881 index--; |
|
882 } |
|
883 index++; |
|
884 tmp = allowedInteractionModes & INTERACTION_MODE_BLANKET; |
|
885 if (tmp <= 0) |
|
886 { |
|
887 settings.removeValue(index); |
|
888 index--; |
|
889 } |
|
890 index++; |
|
891 tmp = allowedInteractionModes & INTERACTION_MODE_DENIED; |
|
892 if (tmp <= 0) |
|
893 { |
|
894 settings.removeValue(index); |
|
895 } |
|
896 } |
|
897 |
|
898 void JavaApplicationSettingsViewPrivate::writeToStorage(JavaApplicationSettings& settings) |
|
899 { |
|
900 if (settings.getTableName().size() <= 0 |
|
901 || settings.getColumnName().size() <= 0) |
|
902 { |
|
903 // storage details are not provided -> no point in going further |
|
904 return; |
|
905 } |
|
906 JavaStorageApplicationEntry_t oldEntry; |
|
907 JavaStorageEntry attr; |
|
908 attr.setEntry(ID, iSuiteUid); |
|
909 oldEntry.insert(attr); |
|
910 JavaStorageApplicationEntry_t entry; |
|
911 if (settings.getFilterColumnName().size() > 0) |
|
912 { |
|
913 attr.setEntry(settings.getFilterColumnName(), settings.getFilterColumnValue()); |
|
914 oldEntry.insert(attr); |
|
915 } |
|
916 attr.setEntry(settings.getColumnName(), settings.getStorageValues()[settings.getCurrentValue()]); |
|
917 entry.insert(attr); |
|
918 |
|
919 try |
|
920 { |
|
921 iStorage->update(settings.getTableName(), entry, oldEntry); |
|
922 } |
|
923 catch (JavaStorageException& aJse) |
|
924 { |
|
925 } |
|
926 } |
|
927 |
|
928 void JavaApplicationSettingsViewPrivate::findEntry(const JavaStorageApplicationList_t& queryResult, |
|
929 const std::wstring& eName, |
|
930 std::wstring& eValue) |
|
931 { |
|
932 if (queryResult.size() > 0) |
|
933 { |
|
934 JavaStorageApplicationEntry_t entry = queryResult.front(); |
|
935 JavaStorageEntry findPattern; |
|
936 findPattern.setEntry(eName, L""); |
|
937 JavaStorageApplicationEntry_t::const_iterator findIterator = |
|
938 entry.find(findPattern); |
|
939 if (findIterator != entry.end()) |
|
940 { |
|
941 eValue = findIterator->entryValue(); |
|
942 } |
|
943 } |
|
944 } |
|
945 |
|
946 bool JavaApplicationSettingsViewPrivate::findFromStorage(const std::wstring& aColumnName, const std::wstring& aColumnFilterName, const std::wstring& aColumnFilterValue, const std::string& aTableName) |
|
947 { |
|
948 wstring value = readFromStorage(aColumnName, aColumnFilterName, aColumnFilterValue, aTableName); |
|
949 |
|
950 return (value.size() > 0); |
|
951 } |
|
952 |
|
953 wstring JavaApplicationSettingsViewPrivate::readFromStorage(const std::wstring& aColumnName, const std::wstring& aColumnFilterName, const std::wstring& aColumnFilterValue, const std::string& aTableName) |
|
954 { |
|
955 wstring value = L""; |
|
956 |
|
957 JavaStorageApplicationEntry_t query; |
|
958 JavaStorageApplicationList_t queryResult; |
|
959 JavaStorageEntry attr; |
|
960 attr.setEntry(ID, iSuiteUid); |
|
961 query.insert(attr); |
|
962 if (aColumnFilterName.size() > 0) |
|
963 { |
|
964 attr.setEntry(aColumnFilterName, aColumnFilterValue); |
|
965 query.insert(attr); |
|
966 } |
|
967 attr.setEntry(aColumnName, L""); |
|
968 query.insert(attr); |
|
969 |
|
970 try |
|
971 { |
|
972 iStorage->search(aTableName, query, queryResult); |
|
973 } |
|
974 catch (JavaStorageException& aJse) |
|
975 { |
|
976 // Don't leave. Set defaults. |
|
977 } |
|
978 |
|
979 findEntry(queryResult, aColumnName, value); |
|
980 |
|
981 return value; |
|
982 } |
|
983 |
|
984 vector<IndexedSettingsName> JavaApplicationSettingsViewPrivate::readFromStorage(const std::wstring& aColumnName, const std::string& aPrimaryTableName, const std::string& aSecondaryTableName) |
|
985 { |
|
986 vector<IndexedSettingsName> values; |
|
987 |
|
988 // hash for associating settings names with display indexes: |
|
989 // a settings with lower index is shown before a settings |
|
990 // with a higher index |
|
991 QHash<QString, int> settingsNamesIndexes; |
|
992 settingsNamesIndexes[QString::fromStdWString(NET_ACCESS_SETTINGS)] = 0; |
|
993 settingsNamesIndexes[QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS)] = 1; |
|
994 settingsNamesIndexes[QString::fromStdWString(MESSAGING_SETTINGS)] = 2; |
|
995 settingsNamesIndexes[QString::fromStdWString(RESTRICTED_MESSAGING_SETTINGS)] = 3; |
|
996 settingsNamesIndexes[QString::fromStdWString(CALL_CONTROL_SETTINGS)] = 4; |
|
997 settingsNamesIndexes[QString::fromStdWString(LOCAL_CONNECTIVITY_SETTINGS)] = 5; |
|
998 settingsNamesIndexes[QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS)] = 6; |
|
999 settingsNamesIndexes[QString::fromStdWString(WRITE_USER_DATA_ACCESS_SETTINGS)] = 7; |
|
1000 settingsNamesIndexes[QString::fromStdWString(READ_USER_DATA_ACCESS_SETTINGS)] = 8; |
|
1001 settingsNamesIndexes[QString::fromStdWString(LOCATION_SETTINGS)] = 9; |
|
1002 settingsNamesIndexes[QString::fromStdWString(LANDMARK_SETTINGS)] = 10; |
|
1003 settingsNamesIndexes[QString::fromStdWString(AUTHENTICATION_SETTINGS)] = 11; |
|
1004 settingsNamesIndexes[QString::fromStdWString(SMART_CARD_COMMUNICATION_SETTINGS)] = 12; |
|
1005 settingsNamesIndexes[QString::fromStdWString(APPLICATION_AUTO_INVOCATION_SETTINGS)] = 13; |
|
1006 settingsNamesIndexes[QString::fromStdWString(BROADCAST_SETTINGS)] = 14; |
|
1007 settingsNamesIndexes[QString::fromStdWString(NFC_WRITE_ACCESS_SETTINGS)] = 15; |
|
1008 settingsNamesIndexes[QString::fromStdWString(URL_START_SETTINGS)] = 16; |
|
1009 int last_index = 16; |
|
1010 |
|
1011 JavaStorageApplicationEntry_t query; |
|
1012 JavaStorageApplicationList_t queryResult; |
|
1013 JavaStorageEntry attr; |
|
1014 attr.setEntry(ID, iSuiteUid); |
|
1015 query.insert(attr); |
|
1016 attr.setEntry(aColumnName, L""); |
|
1017 query.insert(attr); |
|
1018 |
|
1019 try |
|
1020 { |
|
1021 iStorage->search(aPrimaryTableName, query, queryResult); |
|
1022 |
|
1023 JavaStorageApplicationList_t::const_iterator iterator; |
|
1024 JavaStorageApplicationList_t secondaryQueryResult; |
|
1025 for (iterator = queryResult.begin(); iterator != queryResult.end(); iterator++) |
|
1026 { |
|
1027 std::wstring name = L""; |
|
1028 JavaStorageApplicationEntry_t entry = (*iterator); |
|
1029 JavaStorageEntry findPattern; |
|
1030 findPattern.setEntry(aColumnName, L""); |
|
1031 JavaStorageApplicationEntry_t::const_iterator findIterator = |
|
1032 entry.find(findPattern); |
|
1033 if (findIterator != entry.end()) |
|
1034 { |
|
1035 name = findIterator->entryValue(); |
|
1036 } |
|
1037 if (name.size() > 0) |
|
1038 { |
|
1039 entry.clear(); |
|
1040 query.clear(); |
|
1041 attr.setEntry(ID, iSuiteUid); |
|
1042 query.insert(attr); |
|
1043 attr.setEntry(aColumnName, name); |
|
1044 query.insert(attr); |
|
1045 secondaryQueryResult.clear(); |
|
1046 iStorage->search(aSecondaryTableName, query, secondaryQueryResult); |
|
1047 if (secondaryQueryResult.size() > 0) |
|
1048 { |
|
1049 IndexedSettingsName value; |
|
1050 value.name = name; |
|
1051 value.index = last_index + 1; |
|
1052 if (settingsNamesIndexes.contains(QString::fromStdWString(name))) |
|
1053 { |
|
1054 value.index = settingsNamesIndexes.value(QString::fromStdWString(name)); |
|
1055 } |
|
1056 values.push_back(value); |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 } |
|
1061 catch (JavaStorageException& aJse) |
|
1062 { |
|
1063 // Don't leave. Set defaults. |
|
1064 } |
|
1065 |
|
1066 return values; |
|
1067 } |
|
1068 |
|
1069 void JavaApplicationSettingsViewPrivate::readSuiteUid(const QString& aAppUid) |
|
1070 { |
|
1071 iSuiteUid = L""; |
|
1072 bool ok; |
|
1073 int tmp = aAppUid.toInt( &ok, 10 ); |
|
1074 if (!ok) |
|
1075 { |
|
1076 return; |
|
1077 } |
|
1078 wstring appUid = L""; |
|
1079 appUid.append(L"[").append(QString("%1").arg(tmp, 0, 16).toStdWString()).append(L"]"); |
|
1080 |
|
1081 JavaStorageApplicationEntry_t query; |
|
1082 JavaStorageApplicationList_t queryResult; |
|
1083 JavaStorageEntry attr; |
|
1084 attr.setEntry(ID, appUid); |
|
1085 query.insert(attr); |
|
1086 attr.setEntry(PACKAGE_ID, L""); |
|
1087 query.insert(attr); |
|
1088 try |
|
1089 { |
|
1090 iStorage->search(APPLICATION_TABLE, query, queryResult); |
|
1091 } |
|
1092 catch (JavaStorageException& aJse) |
|
1093 { |
|
1094 // Don't leave. Set defaults. |
|
1095 } |
|
1096 findEntry(queryResult, PACKAGE_ID, iSuiteUid); |
|
1097 } |
|
1098 |
|
1099 |
|
1100 #ifdef WIN32 |
|
1101 #include "./moc/moc_javaapplicationsettingsview.cpp" |
|
1102 #else |
|
1103 #include "moc_javaapplicationsettingsview.cpp" |
|
1104 #endif |
|