|
1 /* |
|
2 * Copyright (c) 2010 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 #ifndef JAVAAPPLICATIONSETTINGSVIEW_P_H |
|
18 #define JAVAAPPLICATIONSETTINGSVIEW_P_H |
|
19 |
|
20 #include <QVector> |
|
21 #include <QList> |
|
22 #include <QTranslator> |
|
23 #include <QModelIndex> |
|
24 #include <QEventLoop> |
|
25 #include <memory> |
|
26 #include <cmapplsettingsui.h> |
|
27 #include "javaapplicationsettings.h" |
|
28 #include "javastorage.h" |
|
29 |
|
30 class HbWidget; |
|
31 class HbPushButton; |
|
32 class HbDataForm; |
|
33 class HbDataFormModel; |
|
34 class HbDataFormModelItem; |
|
35 class HbAction; |
|
36 |
|
37 namespace java |
|
38 { |
|
39 namespace settings |
|
40 { |
|
41 |
|
42 // constants used for retrieving the translations of different texts via hbTrId function |
|
43 const char* const ID_BLANKET = "txt_java_sett_setlabel_permission_val_blanket"; |
|
44 const char* const ID_SESSION = "txt_java_sett_setlabel_permission_val_session"; |
|
45 const char* const ID_ONESHOT = "txt_java_sett_setlabel_permission_val_oneshot"; |
|
46 const char* const ID_DENIED = "txt_java_sett_setlabel_permission_val_no"; |
|
47 const char* const ID_SECURITY_LEVEL = "txt_java_sett_setlabel_security_level"; |
|
48 const char* const ID_USER_DEFINED = "txt_java_sett_setlabel_security_level_val_user_defined"; |
|
49 const char* const ID_SENSITIVE_SETTINGS = "txt_java_sett_info_query_perm_sec"; |
|
50 const char* const ID_SENSITIVE_SETTINGS_NET_USAGE = "txt_java_sett_info_query_perm_net"; |
|
51 const char* const ID_MUTUALLY_EXCLUSIVE_SETTINGS = "txt_java_sett_info_query_perm_warn"; |
|
52 const char* const ID_OK = "txt_java_sett_button_settings_ok"; |
|
53 const char* const ID_CANCEL = "txt_java_sett_button_settings_cancel"; |
|
54 const char* const ID_SECURITY_WARNING_TITLE = "txt_java_sett_title_note_security_warn"; |
|
55 const char* const ID_NET_ACCESS = "txt_java_sett_setlabel_net_access"; |
|
56 const char* const ID_LOW_LEVEL_NET_ACCESS = "txt_java_sett_setlabel_low_level_net_access"; |
|
57 const char* const ID_NETWORK_CONNECTION = "txt_occ_title_network_connection"; |
|
58 const char* const ID_SETTINGS_TITLE = "txt_java_sett_title_settings"; |
|
59 const char* const ID_SETTINGS_NOT_AVAILABLE = "txt_java_sett_info_settings_not_available"; |
|
60 const char* const ID_GENERAL_GROUP_TITLE = "txt_java_sett_subtitle_general"; |
|
61 const char* const ID_SECURITY_GROUP_TITLE = "txt_java_sett_subtitle_security"; |
|
62 const char* const ID_OSK_NO = "txt_java_sett_setlabel_osk_val_no"; |
|
63 const char* const ID_OSK_GAME = "txt_java_sett_setlabel_osk_val_game"; |
|
64 const char* const ID_OSK_NAVIGATION = "txt_java_sett_setlabel_osk_val_navigation"; |
|
65 const char* const ID_OSK = "txt_java_sett_setlabel_osk"; |
|
66 const char* const ID_SECURITY_LEVEL_DEFAULT = "txt_java_sett_setlabel_security_level_val_default"; |
|
67 const char* const ID_MESSAGING = "txt_java_sett_setlabel_messaging"; |
|
68 const char* const ID_RESTRICTED_MESSAGING = "txt_java_sett_setlabel_restricted_messaging"; |
|
69 const char* const ID_CALL_CONTROL = "txt_java_sett_setlabel_call_control"; |
|
70 const char* const ID_LOCAL_CONNECTIVITY = "txt_java_sett_setlabel_local_conn"; |
|
71 const char* const ID_MULTIMEDIA_RECORDING = "txt_java_sett_setlabel_mm_record"; |
|
72 const char* const ID_WRITE_USER_DATA_ACCESS = "txt_java_sett_setlabel_write_data"; |
|
73 const char* const ID_READ_USER_DATA_ACCESS = "txt_java_sett_setlabel_read_data"; |
|
74 const char* const ID_LOCATION = "txt_java_sett_setlabel_location"; |
|
75 const char* const ID_LANDMARK = "txt_java_sett_setlabel_landmarks"; |
|
76 const char* const ID_AUTHENTICATION = "txt_java_sett_setlabel_auth"; |
|
77 const char* const ID_SMART_CARD_COMMUNICATION = "txt_java_sett_setlabel_smartcard"; |
|
78 const char* const ID_APPLICATION_AUTO_INVOCATION = "txt_java_sett_setlabel_app_auto_invoc"; |
|
79 const char* const ID_BROADCAST = "txt_java_sett_setlabel_broadcast"; |
|
80 const char* const ID_NFC_WRITE_ACCESS = "txt_java_sett_setlabel_nfc_write_access"; |
|
81 const char* const ID_URL_START = "txt_java_sett_setlabel_url_start"; |
|
82 |
|
83 class JavaApplicationSettingsView; |
|
84 |
|
85 // this structures are used for ensuring the settings are always |
|
86 // displayed in same order: each setting has associated an index |
|
87 // - the lower the index is the higher in the list the setting is |
|
88 // displayed |
|
89 enum SettingsIndexes |
|
90 { |
|
91 NET_ACCESS_SETTINGS_INDEX, |
|
92 LOW_LEVEL_NET_ACCESS_SETTINGS_INDEX, |
|
93 MESSAGING_SETTINGS_INDEX, |
|
94 RESTRICTED_MESSAGING_SETTINGS_INDEX, |
|
95 CALL_CONTROL_SETTINGS_INDEX, |
|
96 LOCAL_CONNECTIVITY_SETTINGS_INDEX, |
|
97 MULTIMEDIA_RECORDING_SETTINGS_INDEX, |
|
98 WRITE_USER_DATA_ACCESS_SETTINGS_INDEX, |
|
99 READ_USER_DATA_ACCESS_SETTINGS_INDEX, |
|
100 LOCATION_SETTINGS_INDEX, |
|
101 LANDMARK_SETTINGS_INDEX, |
|
102 AUTHENTICATION_SETTINGS_INDEX, |
|
103 SMART_CARD_COMMUNICATION_SETTINGS_INDEX, |
|
104 APPLICATION_AUTO_INVOCATION_SETTINGS_INDEX, |
|
105 BROADCAST_SETTINGS_INDEX, |
|
106 NFC_WRITE_ACCESS_SETTINGS_INDEX, |
|
107 URL_START_SETTINGS_INDEX, |
|
108 LAST_SETTINGS_INDEX, |
|
109 }; |
|
110 struct IndexedSettingsName |
|
111 { |
|
112 std::wstring name; |
|
113 int index; |
|
114 }; |
|
115 struct AscendingSort |
|
116 { |
|
117 bool operator()(const IndexedSettingsName& i1, const IndexedSettingsName& i2) |
|
118 { |
|
119 return i1.index < i2.index; |
|
120 } |
|
121 }; |
|
122 |
|
123 /** |
|
124 * The Ui is build around the Orbit's HbDataForm, with one group for the general settings |
|
125 * (including network settings and On screen keypad settings) and another group for |
|
126 * security settings (including the security warnings mode and the actual security settings). |
|
127 * The items inside the group are either of type tooglebutton (network settings and security |
|
128 * warnings mode) or of type combobox. When the plugin is instantiated the two groups are |
|
129 * created and the settings are read from storage. When the plugin receives an initialization |
|
130 * signal the HbDataModel's (associated to the main HbDataForm) itemShown signal is connected |
|
131 * to the plugin's slot _q_dataItemDisplayed. While the groups become visible they are populated |
|
132 * with dataitems of either type tooglebutton or combobox. After being added to their parent's |
|
133 * group the dataitems's currentIndexChanged signal is connected to the plugin's _q_settingsChanged |
|
134 * slot where the settings changes are handled. |
|
135 */ |
|
136 class JavaApplicationSettingsViewPrivate: public QObject |
|
137 { |
|
138 Q_OBJECT |
|
139 |
|
140 public: |
|
141 JavaApplicationSettingsViewPrivate(const QString& aJavaAppUid); |
|
142 virtual ~JavaApplicationSettingsViewPrivate(); |
|
143 void init(JavaApplicationSettingsView* aPublicView); |
|
144 |
|
145 // slots |
|
146 void _q_settingsChanged(const QString& aNewValue); |
|
147 void _q_settingsChanged(bool aNewValue); |
|
148 void _q_dataItemDisplayed(const QModelIndex aDataItemIndex); |
|
149 |
|
150 private slots: |
|
151 void netConnSelected(uint aNetConnSelectionStatus); |
|
152 void securityWarningDismissed(HbAction* aDismissAction); |
|
153 |
|
154 private: |
|
155 void init(); |
|
156 void initGeneralSettings(); |
|
157 void initSecuritySettings(); |
|
158 void readAllSettings(); |
|
159 void initSettings(QVector<JavaApplicationSettings>& aSettings, HbDataFormModelItem * aParent); |
|
160 void writeSettings(JavaApplicationSettings& aSettings, const QString &aNewValue); |
|
161 void securityWarningsChanged(const QString& aNewValue); |
|
162 bool isBlanketAllowed(const JavaApplicationSettings& aSettings); |
|
163 HbWidget * itemToWidget(const HbDataFormModelItem * aItem); |
|
164 JavaApplicationSettings* findSettings(HbWidget* aId); |
|
165 JavaApplicationSettings* findSettings(HbWidget* aId, QVector<JavaApplicationSettings>& aAllSettings); |
|
166 void readFromStorage(JavaApplicationSettings& aSettings); |
|
167 void writeToStorage(JavaApplicationSettings& aSettings); |
|
168 bool isInStorage(const std::wstring& aColumnName, const std::wstring& aColumnFilterName, const std::wstring& aColumnFilterValue, const std::string& aTableName); |
|
169 std::wstring readFromStorage(const std::wstring& aColumnName, const std::wstring& aColumnFilterName, const std::wstring& aColumnFilterValue, const std::string& aTableName); |
|
170 std::vector<IndexedSettingsName> readFromStorage(const std::wstring& aColumnName, const std::string& aPrimaryTableName, const std::string& aSecondaryTableName); |
|
171 void filterSecuritySettings(JavaApplicationSettings& aSettings); |
|
172 void findEntry(const java::storage::JavaStorageApplicationList_t& aQueryResult, const std::wstring& aName, std::wstring& aValue); |
|
173 void readSuiteUid(const QString& aAppUid); |
|
174 bool isSecurityWarningAccepted(const QString& aText, const QString& aAcceptActionLabel, const QString& aRejectActionLabel, const QString& aHeadingText); |
|
175 void handleNetworkSettings(); |
|
176 void readNetworkConnectionName(); |
|
177 void initNetworkConnection(); |
|
178 void configureList(QList<JavaApplicationSettings*>& aList, const QStringList& aSettingsNames, const QHash<QString, int>& aSettingsIndexes); |
|
179 void attachList(const QString& aSettingsName, const QList<JavaApplicationSettings*>& aList, const QHash<QString, int>& aSettingsIndexes, bool isHighRiskList = true); |
|
180 void configureLists(); |
|
181 void installTranslator(const QString& aTranslationFileName); |
|
182 |
|
183 private: |
|
184 HbDataForm * mMainForm; |
|
185 HbDataFormModel *mModel; |
|
186 HbDataFormModelItem * mGeneralSettingsGroup; |
|
187 HbDataFormModelItem * mSecuritySettingsGroup; |
|
188 QVector<JavaApplicationSettings> mGeneralSettings; |
|
189 QVector<JavaApplicationSettings> mSecuritySettings; |
|
190 QVector<JavaApplicationSettings> mExtraSettings; |
|
191 JavaApplicationSettingsView* mPublicView; |
|
192 std::auto_ptr<java::storage::JavaStorage> mStorage; |
|
193 std::wstring mSuiteUid; |
|
194 // licalized strings used more than once: the translation is |
|
195 // retrieved only once |
|
196 QString TXT_BLANKET,TXT_SESSION,TXT_ONESHOT,TXT_DENIED,TXT_SECURITY_LEVEL,TXT_USER_DEFINED,TXT_SENSITIVE_SETTINGS,TXT_SENSITIVE_SETTINGS_NET_USAGE,TXT_MUTUALLY_EXCLUSIVE_SETTINGS,TXT_OK,TXT_CANCEL,TXT_SECURITY_WARNING_TITLE,TXT_NET_ACCESS,TXT_LOW_LEVEL_NET_ACCESS,TXT_NETWORK_CONNECTION,TXT_NETWORK_CONNECTION_CHANGE,TXT_SETTINGS_TITLE,TXT_SETTINGS_NOT_AVAILABLE; |
|
197 CmApplSettingsUi* mNetConnSettingsUi; |
|
198 CmApplSettingsUi::SettingSelection mNetConnSelection; |
|
199 JavaApplicationSettings::NetworkConnection mNetConn; |
|
200 int mNetSettIndex; |
|
201 // own event loop used for "translating" asynchronous calls into |
|
202 // synchronous calls |
|
203 QEventLoop* mAsyncToSyncCallEventLoop; |
|
204 // boolean for carying the user's input in between two async calls |
|
205 bool mSecWarningAccepted; |
|
206 // the default network connection used if user did not specify one |
|
207 // or the user specified network connection became invalid |
|
208 // (e.g. after removing the user defined snap) |
|
209 int mDefaultConnId; |
|
210 // list of installed translators: settings view uses own |
|
211 // translator ("javaruntimeapplicationsettings") |
|
212 // and for network settings it uses the cmmanager's translators: |
|
213 // "cmapplsettingsui" and "cmmanager" |
|
214 QList<QTranslator *> mTranslators; |
|
215 QHash<QString, QString> mLocalizedSettingsNames; |
|
216 // hash for associating settings names with indexes within |
|
217 // vectors (mGeneralSettings, mSecuritySettings) |
|
218 QHash<QString, int> mSettingsIndexes; |
|
219 // hash for associating settings names with display indexes: |
|
220 // a settings with lower index is shown before a settings |
|
221 // with a higher index |
|
222 QHash<QString, int> mSettingsNamesIndexes; |
|
223 }; |
|
224 |
|
225 } // namespace settings |
|
226 } // namespace java |
|
227 |
|
228 |
|
229 #endif // JAVAAPPLICATIONSETTINGSVIEW_P_H |