diff -r 093cf0757204 -r 938269283a16 securitysettings/cpwlansecurityuiplugins/cpwpacmnui/src/cpwpacmnui.cpp --- a/securitysettings/cpwlansecurityuiplugins/cpwpacmnui/src/cpwpacmnui.cpp Fri May 14 15:54:13 2010 +0300 +++ b/securitysettings/cpwlansecurityuiplugins/cpwpacmnui/src/cpwpacmnui.cpp Fri Jun 11 13:40:22 2010 +0300 @@ -17,19 +17,23 @@ */ /* - * %version: 17 % + * %version: tr1cfwln#22 % */ // System includes #include -#include +#include +#include +#include #include -#include +#include +#include // User includes #include "cpwpacmnui.h" -//#include "cpwpacmneapui.h" +#include "cpwpacmnui_p.h" +// Trace Definition #include "OstTraceDefinitions.h" #ifdef OST_TRACE_COMPILER_IN_USE #include "cpwpacmnuiTraces.h" @@ -42,12 +46,10 @@ which will allow viewing/editing of WPA/WPA2/802.1x/WPA2 Security Settings. */ //Contructs Common Ui (WPA/WPA2/802.1x/WPA2only) object -CpWpaCmnUi::CpWpaCmnUi(CMManagerShim::WlanSecMode securityMode, CpItemDataHelper &dataHelpper) : - mCmnUi(NULL), mDataHelper(dataHelpper), mPskKeyText(NULL), mEapPlugins( - NULL), mWpaEapItem(NULL), mEapEntry(NULL) +CpWpaCmnUi::CpWpaCmnUi(CMManagerShim::WlanSecMode securityMode, CpItemDataHelper &dataHelpper) + { - mSecurityMode = securityMode; - mEnablePskMode = true; + d_ptr = new CpWpaCmnUiPrivate(securityMode,dataHelpper); } //Deletes objects owned by Common Ui CpWpaCmnUi::~CpWpaCmnUi() @@ -55,11 +57,9 @@ //delete all dynamically allocated objects OstTraceFunctionEntry1(CPWPACMNUI_CPWPACMNUI_ENTRY,this); - mCmnUi = NULL; + delete d_ptr; - mConnMethod = NULL; - - OstTraceFunctionExit1(CPWPACMNUI_CPWPACMNUI_EXIT,this); + OstTraceFunctionExit1(CPWPACMNUI_CPWPACMNUI_EXIT,this); } // ======== MEMBER FUNCTIONS ======== @@ -78,371 +78,28 @@ EapQtConfigInterface *eapQtConfigInterface, CmConnectionMethodShim *cmCM) { - OstTraceFunctionEntry1(CPWPACMNUI_CREATEUI_ENTRY,this); - int err; - - mConnMethod = cmCM; - - //Read values From CommsDatbase - QT_TRYCATCH_ERROR(err, ( readValues())); - if(err !=KErrNone) { - OstTrace1( TRACE_ERROR, CPWPACMNUI_CREATEUI, "CPWPACMNUI ReadValues returned %d", err ); - } - - mCmnUi = new CpSettingFormItemData(HbDataFormModelItem::GroupItem, - hbTrId("txt_occ_subhead_security_settings")); - - mEapQtConfigInterface = eapQtConfigInterface; - //mPlugins.append(mEapQtConfigInterface->supportedOuterTypes()); - - //PSK / EAP ? - mWpaEapItem = new CpSettingFormItemData( - HbDataFormModelItem::ComboBoxItem, hbTrId( - "txt_occ_setlabel_wpawpa2"),mCmnUi); - QStringList wpatype; - //wpatype.append(hbTrId("txt_occ_setlabel_wpawpa2_val_eap")); - wpatype.append(hbTrId("txt_occ_setlabel_wpawpa2_val_preshared_key")); - - mWpaEapItem->setContentWidgetData("items", wpatype); - mWpaEapItem->setContentWidgetData("currentIndex",0/*To use mEnablePskMode when both modes are available*/); - - mDataHelper.addConnection(mWpaEapItem, - SIGNAL(currentIndexChanged(int)), this, - SLOT(wpaTypeChanged(int))); - - //1.Pre-Shared Key - mPskKeyText = new CpSettingFormItemData( - HbDataFormModelItem::TextItem, hbTrId( - "txt_occ_setlabel_preshared_key"),mCmnUi); - - mPskKeyText->setContentWidgetData("text", mKeyData); - mPskKeyText->setContentWidgetData("echoMode", 2); - - mPskKeyText->setContentWidgetData("smileysEnabled", "false"); - mDataHelper.addConnection(mPskKeyText, SIGNAL( editingFinished ()), - this, SLOT(pskKeyChanged() )); - - //2.EAP - /* mEapPlugins = new CpSettingFormItemData( - HbDataFormModelItem::ComboBoxItem, hbTrId( - "txt_occ_setlabel_eap_type")); - - QStringList items; - for (int i = 0; i < mPlugins.length(); ++i) - { - items << mPlugins.at(i)->localizationId(); - } - mPluginCurrent = 0; - mEapPlugins->setContentWidgetData("items", items); - //Set the last EAP chosen , by reading from CommsDb - mDataHelper.addConnection(mEapPlugins, - SIGNAL(currentIndexChanged(int)), this, - SLOT(eapTypeChanged(int))); - - mEapEntry = new EapEntyItemData(this, mDataHelper, hbTrId( - "txt_occ_button_eap_type_settings"), QString(""));*/ - - mUnencryptedConnection = new CpSettingFormItemData( - HbDataFormModelItem::CheckBoxItem, hbTrId( - "txt_occ_setlabel_unencrypted_connection"),mCmnUi); - - mUnencryptedConnection->setContentWidgetData("text", hbTrId( - "txt_occ_setlabel_unencrypted_connection_val_allowe")); - - //Kept Unchecked by default , but to be read from Comms DB - mUnencryptedConnection->setContentWidgetData("checkState", - "Unchecked"); - - mDataHelper.addConnection(mUnencryptedConnection, - SIGNAL( stateChanged(int)), this, - SLOT(unencryptConnStateChanged(int))); - - //LoadUi based on the security mode - loadUi(); - - OstTraceFunctionExit1(CPWPACMNUI_CREATEUI_EXIT,this); - return mCmnUi; - + OstTraceFunctionExit1(CPWPACMNUI_CREATEUI_EXIT,this); + return d_ptr->createUi(eapQtConfigInterface,cmCM); } -// ======== LOCAL FUNCTIONS ======== - -/*! - Load the CpSettingFormItemData components, based on the security - mode chosen. Only those components that are required by that security - mode are loaded - */ -void CpWpaCmnUi::loadUi() -{ - OstTraceFunctionEntry1(CPWPACMNUI_LOADUI_ENTRY,this); - int secMode = mSecurityMode; - switch (secMode) - { - case CMManagerShim::WlanSecModeWpa: - case CMManagerShim::WlanSecModeWpa2: - { - if (mEnablePskMode) { - mCmnUi->appendChild(mWpaEapItem); - mCmnUi->appendChild(mPskKeyText); - } - /*else { - //do nothing, no EAP - mCmnUi->appendChild(mWpaEapItem); - mCmnUi->appendChild(mEapPlugins); - mCmnUi->appendChild(mEapEntry); - }*/ - - } - break; - - /*case CMManagerShim::WlanSecMode802_1x: - { - mCmnUi->appendChild(mEapPlugins); - mCmnUi->appendChild(mEapEntry); - mCmnUi->appendChild(mUnencryptedConnection); - } - break;*/ - default: - break; - } - OstTraceFunctionExit1(CPWPACMNUI_LOADUI_EXIT,this); -} - -/*! - Load the CpSettingFormItemData components,for the - Pre-Shared key mode - */ -/*void CpWpaCmnUi::loadWPAPskView() -{ - OstTraceFunctionEntry1(CPWPACMNUI_LOADWPAPSKVIEW_ENTRY,this); - mCmnUi->appendChild(mPskKeyText); - OstTraceFunctionExit1(CPWPACMNUI_LOADWPAPSKVIEW_EXIT,this); -}*/ - -/*! - Load the CpSettingFormItemData components,for the - EAP mode - */ -/*void CpWpaCmnUi::loadWPAEapView() -{ - OstTraceFunctionEntry1(CPWPACMNUI_LOADWPAEAPVIEW_ENTRY,this); - mCmnUi->appendChild(mEapPlugins); - mCmnUi->appendChild(mEapEntry); - OstTraceFunctionExit1(CPWPACMNUI_LOADWPAEAPVIEW_EXIT,this); -}*/ - -/*! - Load the CpSettingFormItemData components,for the - EAP mode - */ -/*CpBaseSettingView* CpWpaCmnUi::eapUiInstance() -{ - OstTraceFunctionEntry1(CPWPACMNUI_EAPUIINSTANCE_ENTRY,this); - OstTraceFunctionExit1(CPWPACMNUI_EAPUIINSTANCE_EXIT,this); - - return mEapQtConfigInterface->uiInstance( - mPlugins.at(mPluginCurrent)->pluginHandle()); - return NULL; -}*/ /*! - Slot to handle change in wpa mode :- PSK /EAP - Emits a mode change signal to the security plugin - to indicate the change - - \param pskEnable the current mode chosen - */ -/*void CpWpaCmnUi::wpaTypeChanged(int pskEnable) -{ - OstTraceFunctionEntry1(CPWPACMNUI_WPATYPECHANGED_ENTRY,this); - switch (pskEnable) - { - case 0: - { - RemovePskView(); - LoadWPAEapView(); - } - break; - - case 1: - { - RemoveEapView(); - LoadWPAPskView(); - } - break; - } //do nothing , only PSK mode, no EAP - OstTraceFunctionExit1(CPWPACMNUI_WPATYPECHANGED_EXIT,this); - //Emit signal back to plugin - emit pskEapModeToggled(pskEnable); -}*/ - -/*! - * Unload components related to Pre-Shared key mode - */ -/*void CpWpaCmnUi::removePskView() -{ - OstTraceFunctionEntry1(CPWPACMNUI_REMOVEPSKVIEW_ENTRY,this); - int indexOfPsk = mCmnUi->indexOf(mPskKeyText); - mCmnUi->removeChild(indexOfPsk); - OstTraceFunctionExit1(CPWPACMNUI_REMOVEPSKVIEW_EXIT,this); -}*/ - -/*! - * Unload components related to EAP mode - */ -/*void CpWpaCmnUi::removeEapView() -{ - OstTraceFunctionEntry1(CPWPACMNUI_REMOVEEAPVIEW_ENTRY,this); - int indexOfEapPlugin = mCmnUi->indexOf(mEapPlugins); - mCmnUi->removeChild(indexOfEapPlugin); - - int indexOfEapEntry = mCmnUi->indexOf(mEapEntry); - mCmnUi->removeChild(indexOfEapEntry); - OstTraceFunctionExit1(CPWPACMNUI_REMOVEEAPVIEW_EXIT,this); -}*/ - -/*! - Slot to handle change in eap method in use. - Emits signal back to the security plugin to indicate - the change - \param currentplugin plugin number to indicate the - eap method in use - */ -/*void CpWpaCmnUi::eapTypeChanged(int eapPlugin) -{ - OstTraceFunctionEntry1(CPWPACMNUI_EAPTYPECHANGED_ENTRY,this); - mPluginCurrent = eapPlugin; - OstTraceFunctionExit1(CPWPACMNUI_EAPTYPECHANGED_EXIT,this); - emit eapPluginChanged(mPluginCurrent); -}*/ - -/*! - Slot to handle change in pre-shared key string - Emits signal back to the security plugin to indicate - the change - - */ -void CpWpaCmnUi::pskKeyChanged() -{ - OstTraceFunctionEntry1(CPWPACMNUI_PSKKEYCHANGED_ENTRY,this); - QVariant keyValue = mPskKeyText->contentWidgetData("text"); - QString keyString = keyValue.toString(); - OstTraceFunctionExit1(CPWPACMNUI_PSKKEYCHANGED_EXIT,this); - //Emit signal back to plugin - emit keyChanged(keyString); -} + 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. -/*! - Slot to handle change in the state of unencrypted connection; - to indicate if such a connection is allowed. - Emits signal back to the security plugin to indicate - the change - \param state checked-Allowed / Unchecked-Not allowed - */ -/*void CpWpaCmnUi::unencryptConnStateChanged(int state) -{ - OstTraceFunctionEntry1(CPWPACMNUI_UNENCRYPTCONNSTATECHANGED_ENTRY,this); emit - connectionStateChanged(state); - OstTraceFunctionExit1(CPWPACMNUI_UNENCRYPTCONNSTATECHANGED_EXIT,this); -}*/ - -/*! - * Reads the wlan security fields from CommsDb - */ -void CpWpaCmnUi::readValues() -{ - OstTraceFunctionEntry1(CPWPACMNUI_READVALUES_ENTRY,this); - switch (mSecurityMode) - { - case CMManagerShim::WlanSecModeWpa: - case CMManagerShim::WlanSecModeWpa2: - { - loadWPA_WPA2Fields(); - } - break; - - /* case CMManagerShim::WlanSecMode802_1x: - { - load802Dot1xFields(); - } - break;*/ - - default: - break; - } - OstTraceFunctionExit1(CPWPACMNUI_READVALUES_EXIT,this); -} - -/*! - * Reads the wlan security wpa/wpa2 related fields from CommsDb - */ -void CpWpaCmnUi::loadWPA_WPA2Fields() -{ - OstTraceFunctionEntry1(CPWPACMNUI_LOADWPAFIELDS_ENTRY,this); - /*mEnablePskMode = mConnMethod->getIntAttribute( - CMManagerShim::WlanEnableWpaPsk);*/ - - //only PSK mode enabled(temporary);to be read from Comms later - mEnablePskMode = true ; - - //set the same to Comms(temporary) ; the mode to be set , depends on what user chooses - //between PSK & EAP - mConnMethod->setBoolAttribute(CMManagerShim::WlanEnableWpaPsk,mEnablePskMode); - - if (mEnablePskMode) { - mKeyData = mConnMethod->getString8Attribute( - CMManagerShim::WlanWpaPreSharedKey); - } - /* else { - //mcurrentEapPlugin = mCMExtShim->GetIntAttribute( use appropriate enum to get the eap plugin index ); - } */ - OstTraceFunctionExit1(CPWPACMNUI_LOADWPAFIELDS_EXIT,this); -} - -/*! - * Reads the wlan security eap related fields from CommsDb - */ -/*void CpWpaCmnUi::load802Dot1xFields() -{ - OstTraceFunctionEntry1(CPWPACMNUI_LOAD802DOT1XFIELDS_ENTRY,this); - //mcurrentEapPlugin = mCMExtShim->GetIntAttribute(use appropriate enum to get the eap plugin index); - - //unencryptStateChanged = mConnMethod->getIntAttribute(CMManagerShim::EWlan802_1xAllowUnencrypted); - OstTraceFunctionExit1(CPWPACMNUI_LOAD802DOT1XFIELDS_EXIT,this); -}*/ - -/*! - * Reset the values on the corresponding Ui elements - */ -void CpWpaCmnUi::reset() + \return True if security settings are valid, false if not. +*/ +bool CpWpaCmnUi::validateSettings() { - OstTraceFunctionEntry1(CPWPACMNUI_RESET_ENTRY,this); - //Read values from Comms and update the Ui items - readValues(); - - switch (mSecurityMode) - { - case CMManagerShim::WlanSecModeWpa: - case CMManagerShim::WlanSecModeWpa2: - { - if(mEnablePskMode) { - mPskKeyText->setContentWidgetData("text", mKeyData); - } - } - break; - - /*case CMManagerShim::WlanSecMode802_1x: - { - //Set appropriate value in widget for 802.1x - if(mEnablePskMode) { - mPskKeyText->setContentWidgetData("checkState", mKeyData); - } - break;*/ - - default: - break; - } - OstTraceFunctionExit1(CPWPACMNUI_RESET_EXIT,this); + return d_ptr->validateSettings(); } + + + +