--- a/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.cpp Fri May 14 15:47:24 2010 +0300
+++ b/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.cpp Thu May 27 12:49:31 2010 +0300
@@ -17,21 +17,30 @@
#include <hbmessagebox.h>
#include <hbdataformviewitem.h>
#include <hbcombobox.h>
+#include <hbpushbutton.h>
#include <hbdataform.h>
#include <hbdataformmodel.h>
#include <hbdataformmodelitem.h>
#include <hblabel.h>
+#include <hbaction.h>
#include <QApplication>
#include <QTranslator>
+#include <qnetworkconfigmanager.h>
+#include <qnetworkconfiguration.h>
#include "javaapplicationsettings.h"
#include "javaapplicationsettingsview.h"
#include "javaapplicationsettingsview_p.h"
+#include "connectionmanager.h"
+#include "javacommonutils.h"
#include "securitystoragedatadefs.h"
#include "javastoragenames.h"
+QTM_USE_NAMESPACE
+
using namespace java::storage;
+using namespace java::util;
using namespace std;
const wchar_t ON_SCREEN_KEYPAD_VALUE_NO[] = L"0";
@@ -39,10 +48,39 @@
const wchar_t ON_SCREEN_KEYPAD_VALUE_NAVIGATION[] = L"2";
JavaApplicationSettingsViewPrivate::JavaApplicationSettingsViewPrivate(const QString& aJavaAppUid):
- mainForm(0), model(0), generalSettingsGroup(0), securitySettingsGroup(0), iJavaAppUid(aJavaAppUid.toStdWString())
+ mainForm(0), model(0), generalSettingsGroup(0), securitySettingsGroup(0)
{
- // load the correct translation of the localized strings
+ // init access point settings ui
+ netConnSettingsUi = new CmApplSettingsUi(this);
+
+ // init storage
+ iStorage.reset(JavaStorage::createInstance());
+ try
+ {
+ iStorage->open();
+ }
+ catch (JavaStorageException& aJse) {}
+
+ // init the suite UID from the application UID
+ readSuiteUid(aJavaAppUid);
+ if (iSuiteUid.size() <= 0)
+ {
+ // TODO: display a no settings available message
+ return;
+ }
QTranslator translator;
+ // load the correct translation of the localized strings for the cmmanager.
+ // Load this one first since it contains the smallest amount of strings
+ // (so it's ok to be searched last)
+ if (translator.load("z:/resource/qt/translations/cmapplsettingsui_" + QLocale::system().name()))
+ {
+ qApp->installTranslator(&translator);
+ }
+ if (translator.load("z:/resource/qt/translations/cmmanager_" + QLocale::system().name()))
+ {
+ qApp->installTranslator(&translator);
+ }
+ // load the correct translation of the localized strings for the java settings
// Current solution reads it from Z only (this does not work with IAD)
// -> check if translator can handle path without drive letter (e.g. the resource
// is loaded from the same drive where the DLL is loaded)
@@ -65,14 +103,7 @@
SECURITY_WARNING_TITLE = hbTrId("txt_java_sett_title_note_security_warn");
NET_ACCESS = hbTrId("txt_java_sett_setlabel_net_access");
LOW_LEVEL_NET_ACCESS = hbTrId("txt_java_sett_setlabel_low_level_net_access");
-
- // storage
- iStorage.reset(JavaStorage::createInstance());
- try
- {
- iStorage->open();
- }
- catch (JavaStorageException& aJse) {}
+ NETWORK_CONNECTION = hbTrId("txt_occ_title_network_connection");
// read all settings
readAllSettings();
@@ -121,6 +152,7 @@
{
delete mainForm;
delete model;
+ delete netConnSettingsUi;
}
void JavaApplicationSettingsViewPrivate::readAllSettings()
@@ -138,74 +170,79 @@
storageValues.push_back(ON_SCREEN_KEYPAD_VALUE_GAMEACTIONS);
storageValues.push_back(ON_SCREEN_KEYPAD_VALUE_NAVIGATION);
generalSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_osk"), settingsValues, ON_SCREEN_KEYPAD, MIDP_PACKAGE_TABLE, storageValues));
+ readFromStorage(generalSettings[0]);
}
settingsValues = QStringList();
- settingsValues<<hbTrId("txt_java_sett_setlabel_network_conn_val_default")<<hbTrId("txt_java_sett_setlabel_network_conn_val_ask_user");
- generalSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_network_conn"), settingsValues));
+ netConn.id = ConnectionManager::getDestinationNetworkIdL(iSuiteUid);
+ readNetworkConnectionName();
+ settingsValues<<netConn.name;
+ generalSettings.append(JavaApplicationSettings(NETWORK_CONNECTION, settingsValues));
+ netSettIndex = generalSettings.size() - 1;
// security settings
settingsValues = QStringList();
storageValues.clear();
- settingsValues<<hbTrId("txt_java_sett_setlabel_security_level_val_default")<<hbTrId("txt_java_sett_setlabel_security_level_val_user_defined");
+ settingsValues<<hbTrId("txt_java_sett_setlabel_security_level_val_default")<<USER_DEFINED;
storageValues.push_back(SECURITY_WARNINGS_DEFAULT_MODE);
storageValues.push_back(SECURITY_WARNINGS_USER_DEFINED_MODE);
- securitySettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_security_level"), settingsValues, SECURITY_WARNINGS, MIDP_PACKAGE_TABLE, storageValues));
+ securitySettings.append(JavaApplicationSettings(SECURITY_LEVEL, settingsValues, SECURITY_WARNINGS, MIDP_PACKAGE_TABLE, storageValues));
+ readFromStorage(securitySettings[0]);
// extra settings
int i=0;
settingsValues = QStringList();
storageValues.clear();
- settingsValues<<hbTrId("txt_java_sett_setlabel_permission_val_oneshot")<<hbTrId("txt_java_sett_setlabel_permission_val_session")<<hbTrId("txt_java_sett_setlabel_permission_val_blanket")<<hbTrId("txt_java_sett_setlabel_permission_val_no");
+ settingsValues<<ONESHOT<<SESSION<<BLANKET<<DENIED;
storageValues.push_back(ONESHOT_INTERACTION_MODE);
storageValues.push_back(SESSION_INTERACTION_MODE);
storageValues.push_back(BLANKET_INTERACTION_MODE);
storageValues.push_back(DENIED_INTERACTION_MODE);
- extraSettings.append(JavaApplicationSettings(NET_ACCESS, settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, NET_ACCESS_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(NET_ACCESS, settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, NET_ACCESS_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(LOW_LEVEL_NET_ACCESS, settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LOW_LEVEL_NET_ACCESS_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(LOW_LEVEL_NET_ACCESS, settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LOW_LEVEL_NET_ACCESS_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_messaging"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, MESSAGING_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_messaging"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, MESSAGING_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_restricted_messaging"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, RESTRICTED_MESSAGING_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_restricted_messaging"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, RESTRICTED_MESSAGING_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_call_control"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, CALL_CONTROL_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_call_control"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, CALL_CONTROL_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_local_conn"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LOCAL_CONNECTIVITY_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_local_conn"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LOCAL_CONNECTIVITY_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_mm_record"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, MULTIMEDIA_RECORDING_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_mm_record"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, MULTIMEDIA_RECORDING_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_write_data"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, WRITE_USER_DATA_ACCESS_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_write_data"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, WRITE_USER_DATA_ACCESS_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_read_data"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, READ_USER_DATA_ACCESS_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_read_data"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, READ_USER_DATA_ACCESS_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_location"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LOCATION_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_location"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LOCATION_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_landmarks"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LANDMARK_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_landmarks"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, LANDMARK_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_auth"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, AUTHENTICATION_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_auth"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, AUTHENTICATION_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_smartcard"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, SMART_CARD_COMMUNICATION_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_smartcard"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, SMART_CARD_COMMUNICATION_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_app_auto_invoc"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, APPLICATION_AUTO_INVOCATION_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_app_auto_invoc"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, APPLICATION_AUTO_INVOCATION_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_broadcast"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, BROADCAST_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_broadcast"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, BROADCAST_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
- extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_nfc_write_access"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, NFC_WRITE_ACCESS_SETTINGS));
+ extraSettings.append(JavaApplicationSettings(hbTrId("txt_java_sett_setlabel_nfc_write_access"), settingsValues, CURRENT_SETTING, MIDP_FUNC_GRP_SETTINGS_TABLE, storageValues, FUNCTION_GROUP, NFC_WRITE_ACCESS_SETTINGS, ALLOWED_SETTINGS));
readFromStorage(extraSettings[i]);
i++;
@@ -252,12 +289,39 @@
{
for (int i=0; i<settings.size(); i++)
{
- HbDataFormModelItem * appSettings = model->appendDataFormItem(
- HbDataFormModelItem::ComboBoxItem,
- settings[i].getName(), parent);
+ HbDataFormModelItem * appSettings = NULL;
+ int storageValue = 0;
+ int currentValue = 0;
+ switch(settings[i].getValues().size())
+ {
+ case 1:
+ appSettings = model->appendDataFormItem(
+ HbDataFormModelItem::ToggleValueItem,
+ settings[i].getName(), parent);
+ appSettings->setContentWidgetData(QString("text"), settings[i].getValues()[0]);
+ appSettings->setContentWidgetData(QString("additionalText"), settings[i].getValues()[0]);
+ break;
+ case 2:
+ appSettings = model->appendDataFormItem(
+ HbDataFormModelItem::ToggleValueItem,
+ settings[i].getName(), parent);
+ storageValue = readFromStorage(settings[i]);
+ if (storageValue >= 0)
+ {
+ currentValue = storageValue;
+ }
+ // make it a toogle button (-> get rid of the "pressed" ui effect)
+ appSettings->setContentWidgetData(QString("text"), settings[i].getValues()[settings[i].getCurrentValue()]);
+ appSettings->setContentWidgetData(QString("additionalText"),settings[i].getValues()[1 - currentValue]);
+ break;
+ default:
+ appSettings = model->appendDataFormItem(
+ HbDataFormModelItem::ComboBoxItem,
+ settings[i].getName(), parent);
+ appSettings->setContentWidgetData(QString("items"), settings[i].getValues());
+ appSettings->setContentWidgetData(QString("currentIndex"),settings[i].getCurrentValue());
+ }
settings[i].setId(appSettings);
- appSettings->setContentWidgetData(QString("items"), settings[i].getValues());
- appSettings->setContentWidgetData(QString("currentIndex"),readFromStorage(settings[i]));
}
}
@@ -275,7 +339,7 @@
if (!blanketAllowed(settings))
{
// change back to the old value
- HbComboBox * settingsCombo = itemToComboBox(settings.getId());
+ HbComboBox * settingsCombo = static_cast<HbComboBox*>(itemToWidget(settings.getId()));
settingsCombo->setCurrentIndex(currentValue);
return;
}
@@ -305,11 +369,11 @@
{
secWarning = SENSITIVE_SETTINGS_NET_USAGE;
}
- /*if (!(HbMessageBox::launchQuestionMessageBox(
- secWarning,OK,CANCEL ,new HbLabel(SECURITY_WARNING_TITLE))))
+ if (!securityWarningAccepted(
+ secWarning,OK,CANCEL ,SECURITY_WARNING_TITLE))
{
return false;
- }*/
+ }
break;
}
}
@@ -325,8 +389,8 @@
if (mutuallyExclusiveList[i]->getValue(
mutuallyExclusiveList[i]->getCurrentValue()) == BLANKET)
{
- bool isBlanketAllowed = true /*(HbMessageBox::launchQuestionMessageBox(
- MUTUALLY_EXCLUSIVE_SETTINGS,OK,CANCEL, new HbLabel(SECURITY_WARNING_TITLE)))*/;
+ bool isBlanketAllowed = securityWarningAccepted(
+ MUTUALLY_EXCLUSIVE_SETTINGS, OK, CANCEL, SECURITY_WARNING_TITLE);
if (isBlanketAllowed)
{
// change the current value to the maximum allowed
@@ -357,8 +421,8 @@
}
// set the maximum allowed value
mutuallyExclusiveList[i]->setCurrentValue(selectedValue);
- HbComboBox * settingsCombo = itemToComboBox(
- mutuallyExclusiveList[i]->getId());
+ HbComboBox * settingsCombo = static_cast<HbComboBox*>(itemToWidget(
+ mutuallyExclusiveList[i]->getId()));
settingsCombo->setCurrentIndex(selectedValue);
writeToStorage(*mutuallyExclusiveList[i]);
}
@@ -381,6 +445,24 @@
return true;
}
+void JavaApplicationSettingsViewPrivate::_q_settingsChanged(bool)
+{
+ HbPushButton * sender = static_cast<HbPushButton*>(iPublicView->sender());
+ if (sender)
+ {
+ JavaApplicationSettings* settings = findSettings(sender);
+ if (settings->getName() == SECURITY_LEVEL)
+ {
+ QString newValue = settings->getValue(1 - settings->getCurrentValue());
+ securityWarningsChanged(newValue);
+ writeSettings(*settings, newValue);
+ }
+ else if (settings->getName() == NETWORK_CONNECTION)
+ {
+ handleNetworkSettings();
+ }
+ }
+}
void JavaApplicationSettingsViewPrivate::_q_settingsChanged(const QString &newValue)
{
HbComboBox * sender = static_cast<HbComboBox*>(iPublicView->sender());
@@ -389,12 +471,6 @@
JavaApplicationSettings* settings = findSettings(sender);
if (settings != NULL)
{
- // security warnings
- if (settings->getName() == SECURITY_LEVEL)
- {
- securityWarningsChanged(newValue);
-// return;
- }
// any other settings are treated same
writeSettings(*settings, newValue);
}
@@ -408,12 +484,21 @@
// append the extra settings and values
for (int i=0; i<extraSettings.size(); i++)
{
- if (extraSettings[i].getCurrentValue() >= 0)
+ if (extraSettings[i].getCurrentValue() >= 0 && extraSettings[i].getId() == 0)
{
HbDataFormModelItem * appSettings = model->appendDataFormItem(
HbDataFormModelItem::ComboBoxItem,
extraSettings[i].getName(), securitySettingsGroup);
extraSettings[i].setId(appSettings);
+ // when settings the items, the settingsChanged signal gets emitted with the first value
+ // as being the current value. This signal should be discarded (the first value is just
+ // an intermediate value towards the actual current value which gets set shortly).
+ // Therefore set the first value as the current value (this way the settingsChanged
+ // signal gets discarded) and change the current value back to the real current value
+ int currentValue = extraSettings[i].getCurrentValue();
+ extraSettings[i].setCurrentValue(0);
+ appSettings->setContentWidgetData(QString("items"), extraSettings[i].getValues());
+ extraSettings[i].setCurrentValue(currentValue);
appSettings->setContentWidgetData(QString("currentIndex"),extraSettings[i].getCurrentValue());
}
}
@@ -425,10 +510,10 @@
{
if (extraSettings[i].getId())
{
- HbComboBox * extraSettingsId = itemToComboBox(extraSettings[i].getId());
+ HbComboBox * extraSettingsId = static_cast<HbComboBox*>(itemToWidget(extraSettings[i].getId()));
if (extraSettingsId)
{
- JavaApplicationSettingsView::disconnect(extraSettingsId, 0, 0, 0);
+ iPublicView->disconnect(extraSettingsId, 0, 0, 0);
model->removeItem(model->indexFromItem(extraSettings[i].getId()));
extraSettings[i].setId(0);
}
@@ -437,37 +522,94 @@
}
}
+void JavaApplicationSettingsViewPrivate::handleNetworkSettings()
+{
+ // init flags to show destinations and connection methods
+ QFlags<CmApplSettingsUi::SelectionDialogItems> listItems;
+ listItems |= CmApplSettingsUi::ShowDestinations;
+ listItems |= CmApplSettingsUi::ShowConnectionMethods;
+
+ // empty filter -> all bearer types included
+ QSet<CmApplSettingsUi::BearerTypeFilter> filter;
+ // reset the result
+ netConnSelection.result = CmApplSettingsUi::SelectionTypeDestination;
+ netConnSelection.id = netConn.id;
+ // init settings ui with destinations, filter and initial selection
+ netConnSettingsUi->setOptions(listItems, filter);
+ netConnSettingsUi->setSelection(netConnSelection);
+ // Connect the setting ui's signal with own slot where the netConnSelection is stored
+ connect(netConnSettingsUi, SIGNAL(finished(uint)), this, SLOT(netConnSelected(uint)));
+ // launch the setting ui
+ netConnSettingsUi->open();
+}
+
void JavaApplicationSettingsViewPrivate::_q_dataItemDisplayed(const QModelIndex dataItemIndex)
{
HbDataFormModelItem *item = static_cast<HbDataFormModel*>(
mainForm->model())->itemFromIndex(dataItemIndex);
int itemType = item->data(HbDataFormModelItem::ItemTypeRole).toInt();
- if (HbDataFormModelItem::DataItemType(itemType)
- == HbDataFormModelItem::ComboBoxItem)
+ HbComboBox * comboBox = NULL;
+ HbPushButton * pushButton = NULL;
+ switch(HbDataFormModelItem::DataItemType(itemType))
{
- HbComboBox * comboBox = static_cast<HbComboBox*>(
- (qobject_cast<HbDataFormViewItem *>
- (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget());
- // add the extra settings values
- for (int i=0; i<extraSettings.size(); i++)
- {
- if (extraSettings[i].getId() == item)
- {
- if (comboBox->count() == 0)
- {
- comboBox->addItems(extraSettings[i].getValues());
- }
- comboBox->setCurrentIndex(extraSettings[i].getCurrentValue());
- break;
- }
- }
- iPublicView->connect(comboBox,
- SIGNAL(currentIndexChanged(const QString &)),
- iPublicView, SLOT(_q_settingsChanged(const QString &)));
+ case HbDataFormModelItem::ComboBoxItem:
+ comboBox = static_cast<HbComboBox*>(
+ (qobject_cast<HbDataFormViewItem *>
+ (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget());
+ iPublicView->connect(comboBox,
+ SIGNAL(currentIndexChanged(const QString &)),
+ iPublicView, SLOT(_q_settingsChanged(const QString &)),
+ Qt::UniqueConnection);
+ break;
+ case HbDataFormModelItem::ToggleValueItem:
+ pushButton = static_cast< HbPushButton*>(
+ (qobject_cast<HbDataFormViewItem *>
+ (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget());
+ iPublicView->connect(pushButton,
+ SIGNAL(clicked(bool)),
+ iPublicView, SLOT(_q_settingsChanged(bool)),
+ Qt::UniqueConnection);
+ break;
}
}
-JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbComboBox* id)
+void JavaApplicationSettingsViewPrivate::netConnSelected(uint netConnSelectionStatus)
+{
+ if (netConnSelectionStatus == CmApplSettingsUi::ApplSettingsErrorNone)
+ {
+ netConnSelection = netConnSettingsUi->selection();
+ // store the selection
+ if (netConnSelection.id != netConn.id)
+ {
+ ConnectionManager::setDestinationNetworkIdL(iSuiteUid, netConnSelection.id);
+ netConn.id = netConnSelection.id;
+ readNetworkConnectionName();
+ generalSettings[netSettIndex].getId()->setContentWidgetData(QString("text"), netConn.name);
+ generalSettings[netSettIndex].getId()->setContentWidgetData(QString("additionalText"), netConn.name);
+ }
+ }
+}
+
+void JavaApplicationSettingsViewPrivate::readNetworkConnectionName()
+{
+ QNetworkConfigurationManager manager;
+ QNetworkConfiguration cfg;
+ if (netConn.id == 0)
+ {
+ // figure out the default configuration
+ cfg = manager.defaultConfiguration();
+ }
+ else
+ {
+ cfg = manager.configurationFromIdentifier(QString::number(netConn.id));
+ }
+ if (cfg.isValid())
+ {
+ netConn.name = hbTrId(cfg.name().toUtf8());
+ }
+}
+
+JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbWidget* id)
{
JavaApplicationSettings* settings = findSettings(id, generalSettings);
if (settings == NULL)
@@ -481,11 +623,11 @@
return settings;
}
-JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbComboBox* id, QVector<JavaApplicationSettings>& allSettings)
+JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbWidget* id, QVector<JavaApplicationSettings>& allSettings)
{
for (int i=0; i<allSettings.size(); i++)
{
- if (itemToComboBox(allSettings[i].getId()) == id)
+ if (itemToWidget(allSettings[i].getId()) == id)
{
return &allSettings[i];
}
@@ -493,29 +635,46 @@
return NULL;
}
-HbComboBox * JavaApplicationSettingsViewPrivate::itemToComboBox(const HbDataFormModelItem * item)
+HbWidget * JavaApplicationSettingsViewPrivate::itemToWidget(const HbDataFormModelItem * item)
{
-
HbDataFormViewItem * viewItem = qobject_cast<HbDataFormViewItem *> (mainForm->itemByIndex(
model->indexFromItem(item)));
if (viewItem)
{
- return static_cast<HbComboBox*>(viewItem->dataItemContentWidget());
+ return static_cast<HbWidget*>(viewItem->dataItemContentWidget());
}
return NULL;
}
+bool JavaApplicationSettingsViewPrivate::securityWarningAccepted(const QString& text, const QString& acceptActionLabel, const QString& rejectActionLabel, const QString& headingText)
+{
+ return true;
+/* HbMessageBox securityWarning(HbMessageBox::MessageTypeQuestion);
+ securityWarning.setDismissPolicy(HbDialog::NoDismiss);
+ securityWarning.setTimeout(HbDialog::NoTimeout);
+ securityWarning.setIconVisible(false);
+ securityWarning.setText(text);
+ securityWarning.addAction(new HbAction(
+ acceptActionLabel, &securityWarning));
+ securityWarning.addAction(new HbAction(
+ rejectActionLabel, &securityWarning));
+ securityWarning.setHeadingWidget(new HbLabel(headingText));
+ HbAction *selected = securityWarning.exec();
+ return (selected == securityWarning.primaryAction());*/
+}
+
int JavaApplicationSettingsViewPrivate::readFromStorage(JavaApplicationSettings& settings)
{
int currentValue = -1;
- if (settings.getColumnName().size() > 0 && settings.getTableName().size() > 0)
+ if (settings.getColumnName().size() > 0
+ && settings.getTableName().size() > 0)
{
wstring value = L"";
JavaStorageApplicationEntry_t query;
JavaStorageApplicationList_t queryResult;
JavaStorageEntry attr;
- attr.setEntry(ID, iJavaAppUid);
+ attr.setEntry(ID, iSuiteUid);
query.insert(attr);
if (settings.getFilterColumnName().size() > 0)
{
@@ -524,6 +683,11 @@
}
attr.setEntry(settings.getColumnName(), L"");
query.insert(attr);
+ if (settings.getValuesColumnName().size() > 0)
+ {
+ attr.setEntry(settings.getValuesColumnName(), L"");
+ query.insert(attr);
+ }
try
{
@@ -534,6 +698,17 @@
// Don't leave. Set defaults.
}
+ if (settings.getValuesColumnName().size() > 0)
+ {
+ findEntry(queryResult, settings.getValuesColumnName(), value);
+ if (value.size() > 0)
+ {
+ settings.setStorageValuesFilter(value);
+ filterSecuritySettings(settings);
+ }
+ }
+
+ value = L"";
findEntry(queryResult, settings.getColumnName(), value);
if (value.size() > 0)
@@ -554,11 +729,63 @@
return currentValue;
}
+void JavaApplicationSettingsViewPrivate::filterSecuritySettings(JavaApplicationSettings& settings)
+{
+ std::wstring allowedModes = settings.getStorageValuesFilter();
+ if (allowedModes.size() <= 0)
+ {
+ return;
+ }
+ // The allowed modes info is stored as a 4-bit constant:
+ // X(oneshot)X(session)X(blanket)X(no)
+ // e.g. 1011 (=11) means that oneshot, blanket and no are allowed.
+ // The following constants are used to encode/decode the allowed modes
+ // into/from a 4-bit number
+ int INTERACTION_MODE_DENIED = 1;
+ int INTERACTION_MODE_BLANKET = 2;
+ int INTERACTION_MODE_SESSION = 4;
+ int INTERACTION_MODE_ONESHOT = 8;
+ TInt allowedInteractionModes = JavaCommonUtils::wstringToInt(allowedModes);
+ int index = 0;
+ int tmp = allowedInteractionModes & INTERACTION_MODE_ONESHOT;
+ if (tmp <= 0)
+ {
+ settings.removeValue(index);
+ index--;
+ }
+ index++;
+ tmp = allowedInteractionModes & INTERACTION_MODE_SESSION;
+ if (tmp <= 0)
+ {
+ settings.removeValue(index);
+ index--;
+ }
+ index++;
+ tmp = allowedInteractionModes & INTERACTION_MODE_BLANKET;
+ if (tmp <= 0)
+ {
+ settings.removeValue(index);
+ index--;
+ }
+ index++;
+ tmp = allowedInteractionModes & INTERACTION_MODE_DENIED;
+ if (tmp <= 0)
+ {
+ settings.removeValue(index);
+ }
+}
+
void JavaApplicationSettingsViewPrivate::writeToStorage(JavaApplicationSettings& settings)
{
+ if (settings.getTableName().size() <= 0
+ || settings.getColumnName().size() <= 0)
+ {
+ // storage details are not provided -> no point in going further
+ return;
+ }
JavaStorageApplicationEntry_t oldEntry;
JavaStorageEntry attr;
- attr.setEntry(ID, iJavaAppUid);
+ attr.setEntry(ID, iSuiteUid);
oldEntry.insert(attr);
JavaStorageApplicationEntry_t entry;
if (settings.getFilterColumnName().size() > 0)
@@ -610,7 +837,7 @@
JavaStorageApplicationEntry_t query;
JavaStorageApplicationList_t queryResult;
JavaStorageEntry attr;
- attr.setEntry(ID, iJavaAppUid);
+ attr.setEntry(ID, iSuiteUid);
query.insert(attr);
if (aColumnFilterName.size() > 0)
{
@@ -634,6 +861,36 @@
return value;
}
+void JavaApplicationSettingsViewPrivate::readSuiteUid(const QString& aAppUid)
+{
+ iSuiteUid = L"";
+ bool ok;
+ int tmp = aAppUid.toInt( &ok, 10 );
+ if (!ok)
+ {
+ return;
+ }
+ wstring appUid = L"";
+ appUid.append(L"[").append(QString("%1").arg(tmp, 0, 16).toStdWString()).append(L"]");
+
+ JavaStorageApplicationEntry_t query;
+ JavaStorageApplicationList_t queryResult;
+ JavaStorageEntry attr;
+ attr.setEntry(ID, appUid);
+ query.insert(attr);
+ attr.setEntry(PACKAGE_ID, L"");
+ query.insert(attr);
+ try
+ {
+ iStorage->search(APPLICATION_TABLE, query, queryResult);
+ }
+ catch (JavaStorageException& aJse)
+ {
+ // Don't leave. Set defaults.
+ }
+ findEntry(queryResult, PACKAGE_ID, iSuiteUid);
+}
+
#ifdef WIN32
#include "./moc/moc_javaapplicationsettingsview.cpp"