--- a/securitysettings/cpwlansecurityuiplugins/cpwpa2ui/src/cpwpa2ui.cpp Thu May 13 22:51:27 2010 +0300
+++ b/securitysettings/cpwlansecurityuiplugins/cpwpa2ui/src/cpwpa2ui.cpp Mon May 24 20:32:47 2010 +0300
@@ -16,23 +16,21 @@
*/
/*
- * %version: 17 %
+ * %version: 22 %
*/
// User includes
#include "cpwpa2ui.h"
#include "cpwpacmnui.h"
-#include "wpa2keyvalidator.h"
// System includes
-#include <HbDeviceNotificationDialog>
#include <cmmanagerdefines_shim.h>
#include <cmconnectionmethod_shim.h>
#include <eapqtconfiginterface.h>
#include <QStringList>
-#include <QLocale>
-#include <QCoreApplication>
+#include <HbTranslator>
+//Trace Definition
#include "OstTraceDefinitions.h"
#ifdef OST_TRACE_COMPILER_IN_USE
#include "cpwpa2uiTraces.h"
@@ -42,7 +40,7 @@
// Constants
//The order in which WPA2 only mode appears in the list of available
//security mode
-const int UI_ORDER_WPA2_ONLY = 50;
+const int UI_ORDER_WPA2_ONLY = 30;
/*!
\class CpWpa2Ui
@@ -50,26 +48,26 @@
Security Settings Control Panel Plugin,
which will allow viewing/editing of WPA2 only Security Settings.
*/
-//Contructs WPA2 object
+/*!
+ * Constructor
+ *
+ */
CpWpa2Ui::CpWpa2Ui() :
- mUi(NULL), mCmCM(NULL), mEapQtConfigInterface(NULL),
- mWpa2Ui(NULL)
+ mUi(NULL),
+ mTranslator(new HbTranslator("cpwlansecsettingsplugin")),
+ mCmCM(NULL),
+ mEapQtConfigInterface(NULL),
+ mWpa2Ui(NULL)
{
- mTranslator = new QTranslator(this);
- mTranslator->load(":/loc/wlan_en_GB.qm");
-
- qApp->installTranslator(mTranslator);
-
- /*mTranslator = QSharedPointer<HbTranslator> (
- new HbTranslator("wlan_en_GB"));*/
}
-//Deletes all objects WPA2 owns
+//Destructor
CpWpa2Ui::~CpWpa2Ui()
{
OstTraceFunctionEntry1(CPWPA2UI_CPWPA2UI_ENTRY,this);
- //delete mEapQtConfigInterface;
+ delete mEapQtConfigInterface;
+ delete mTranslator;
OstTraceFunctionExit1(CPWPA2UI_CPWPA2UI_EXIT,this);
}
@@ -82,8 +80,8 @@
*/
CMManagerShim::WlanSecMode CpWpa2Ui::securityMode() const
{
- OstTraceFunctionEntry1(CPWPA2UI_MODE_ENTRY,this);
- OstTraceFunctionExit1(CPWPA2UI_MODE_EXIT,this);
+ OstTraceFunctionEntry1(CPWPA2UI_SECURITYMODE_ENTRY,this);
+ OstTraceFunctionExit1(CPWPA2UI_SECURITYMODE_EXIT,this);
//return security mode
return CMManagerShim::WlanSecModeWpa2;
}
@@ -97,28 +95,25 @@
*/
QString CpWpa2Ui::securityModeTextId() const
{
- OstTraceFunctionEntry1(CPWPA2UI_LOCALIZATIONID_ENTRY,this);
- OstTraceFunctionExit1(CPWPA2UI_LOCALIZATIONID_EXIT,this);
+ OstTraceFunctionEntry1(CPWPA2UI_SECURITYMODETEXTID_ENTRY,this);
+ OstTraceFunctionExit1(CPWPA2UI_SECURITYMODETEXTID_EXIT,this);
return "txt_occ_setlabel_wlan_security_mode_val_wpa2_only";
}
/*!
- Sets the database reference (WLAN Service Table ID).
+ Sets the database reference IAP id.
\param id Database reference
*/
void CpWpa2Ui::setReference(CmConnectionMethodShim *cmCm, uint id)
{
OstTraceFunctionEntry1(CPWPA2UI_SETREFERENCE_ENTRY,this);
- // Assuming that id is the connection method Id/IAP Id.
-
- mCmId = id;
-
- /*if (!mEapQtConfigInterface) {
+ if (!mEapQtConfigInterface) {
mEapQtConfigInterface = new EapQtConfigInterface(
- EapQtConfigInterface::EapBearerTypeWlan, mCmId);
- //fix, hangs
- }*/
+ EapQtConfigInterface::EapBearerTypeWlan, id);
+ } else {
+ mEapQtConfigInterface->setConfigurationReference(id);
+ }
//mCmCM is not deleted assuming mCmManager owns it.
mCmCM = cmCm;
@@ -148,160 +143,30 @@
{
OstTraceFunctionEntry1(CPWPA2UI_UIINSTANCE_ENTRY,this);
- //reset the Common Ui Ptr
+ //reset the Common Ui Ptr
mWpa2Ui.reset(new CpWpaCmnUi(CMManagerShim::WlanSecModeWpa2, dataHelpper));
mUi = mWpa2Ui->createUi(mEapQtConfigInterface, mCmCM);
-
- connect(mWpa2Ui.data(), SIGNAL(keyChanged(QString&)), this,
- SLOT(pskKeyChanged(QString&)));
-
- connect(mWpa2Ui.data(), SIGNAL(pskEapModeToggled(int)), this,
- SLOT(wpaTypeChanged(int)));
-
- connect(mWpa2Ui.data(), SIGNAL(eapPluginChanged(int)), this,
- SLOT(currentEapPlugin(int)));
-
+
OstTraceFunctionExit1(CPWPA2UI_UIINSTANCE_EXIT,this);
return mUi;
}
-// ======== LOCAL FUNCTIONS ========
/*!
- Slot to handle change in wpa mode :- PSK /EAP
-
- \param pskEnable the current mode chosen
- */
-/*void CpWpa2Ui::wpaTypeChanged(int pskEnable)
-{
- int err;
- OstTraceFunctionEntry1(CPWPA2UI_WPATYPECHANGED_ENTRY,this);
-
- bool PskEnable = pskEnable ? ETrue : EFalse;
-
- QT_TRYCATCH_ERROR(err,mCmCM->setBoolAttribute(CMManagerShim::WlanEnableWpaPsk, PskEnable));
-
- if(err !=KErrNone) {
- OstTrace1( TRACE_ERROR, CPWPA2UI_WPATYPECHANGED, "ERROR WPA2 only:wpatypereturned returned %d", err );
- }
- tryUpdate();
- OstTraceFunctionExit1(CPWPA2UI_WPATYPECHANGED_EXIT,this);
-}*/
-
-/*!
- Slot to handle change in pre-shared key string
-
- \param key changed string for PSK
- */
-void CpWpa2Ui::pskKeyChanged(QString &key)
-{
- int err;
- OstTraceFunctionEntry1(CPWPA2UI_PSKKEYCHANGED_ENTRY,this);
-
- //Check for Validity of Pre-shared Key
- Wpa2KeyValidator::KeyStatus keystatus = Wpa2KeyValidator::validateWpa2Key(key);
-
- if (keystatus == Wpa2KeyValidator::KeyStatusOk) {
- QT_TRYCATCH_ERROR(err, mCmCM->setString8Attribute(CMManagerShim::WlanWpaPreSharedKey, key));
- if(err !=KErrNone) {
- OstTrace1( TRACE_ERROR, CPWPA2UI_PSKKEYCHANGED, "ERROR WPA2 only: pskKeyChanged returned %d", err );
- }
- tryUpdate();
- }
-
- else {
- showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId(
- "txt_occ_info_invalid_input"));
- }
- OstTraceFunctionExit1(CPWPA2UI_PSKKEYCHANGED_EXIT,this);
-}
-
-/*!
- Slot to handle change in eap method in use
- \param currentplugin plugin number to indicate the
- eap method in use
- */
-/*void CpWpa2Ui::currentEapPlugin(int currentPlugin )
-{
- OstTraceFunctionEntry1(CPWPA2UI_CURRENTEAPPLUGIN_ENTRY,this);
-
- // define enum to store the current EAP type
- //mCmCM->setIntAttribute( use appropriate enum to get the eap plugin index );
- OstTraceFunctionExit1(CPWPA2UI_CURRENTEAPPLUGIN_EXIT,this);
-}*/
+ Validates current security settings. This function is called whenever
+ user tries to exit from the settings view. If the plugin determines
+ that some settings need editing before considered valid, it shall
+ return false. A dialog will be shown to the user indicating that
+ settings are still incomplete and asking if he/she wishes to exit
+ anyway.
-bool CpWpa2Ui::tryUpdate()
-{
- OstTraceFunctionEntry1(CPWPA2UI_TRYUPDATE_ENTRY,this);
-
- // Try update
- try {
- mCmCM->update();
- }
- catch (const std::exception&) {
- // Handle error
- handleUpdateError();
-
- OstTraceFunctionExit1(CPWPA2UI_TRYUPDATE_EXIT,this);
- return false;
- }
-
- OstTraceFunctionExit1(DUP1_CPWPA2UI_TRYUPDATE_EXIT,this);
- return true;
-}
-
-/*!
- Handles failed CommsDat update.
- */
-void CpWpa2Ui::handleUpdateError()
+ \return True if security settings for WPA2 only are valid, false if not.
+*/
+bool CpWpa2Ui::validateSettings()
{
- OstTraceFunctionEntry1(CPWPA2UI_HANDLEUPDATEERROR_ENTRY,this);
-
- // Show error note to user
- showMessageBox(
- HbMessageBox::MessageTypeWarning,
- hbTrId("txt_occ_info_unable_to_save_setting"));
- // Reload settings from CommsDat and update UI
- try {
- mCmCM->refresh();
- }
- catch (const std::exception&) {
- // Ignore error from refresh. Most likely this will not happen, but
- // if it does, there isn't very much we can do.
- OstTrace0(
- TRACE_ERROR,
- CPWPA2UI_HANDLEUPDATEERROR,
- "Refresh failed");
- };
- updateWpaSettings();
-
- OstTraceFunctionExit1(CPWPA2UI_HANDLEUPDATEERROR_EXIT,this);
-}
-
-/*!
- Shows message box with "OK" button using given text.
-*/
-void CpWpa2Ui::showMessageBox(
- HbMessageBox::MessageBoxType type,
- const QString &text)
-{
- OstTraceFunctionEntry1(CPWPA2UI_SHOWMESSAGEBOX_ENTRY,this);
-
- // Create a message box
- mMessageBox = QSharedPointer<HbMessageBox>(new HbMessageBox(type));
- mMessageBox->setText(text);
- mMessageBox->open();
-
- OstTraceFunctionExit1(CPWPA2UI_SHOWMESSAGEBOX_EXIT,this);
+ return mWpa2Ui->validateSettings();
}
-void CpWpa2Ui::updateWpaSettings()
- {
- OstTraceFunctionEntry1(CPWPA2UI_UPDATEWPASETTINGS_ENTRY,this);
- mWpa2Ui->reset();
- OstTraceFunctionExit1(CPWPA2UI_UPDATEWPASETTINGS_EXIT,this);
- }
-
Q_EXPORT_PLUGIN2(CpWpa2Ui, CpWpa2Ui)
;