securitysettings/cpwlansecurityuiplugins/cpwpaui/src/cpwpaui.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     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  *    Control Panel QT UI for WPA/WPA2 configuration
       
    16  *
       
    17  */
       
    18 
       
    19 /*
       
    20  * %version: tr1cfwln#28 %
       
    21  */
       
    22 //User Includes
       
    23 #include "cpwpaui.h"
       
    24 #include "cpwpacmnui.h"
       
    25 
       
    26 // System includes
       
    27 #include <QStringList>
       
    28 #include <cmconnectionmethod_shim.h>
       
    29 #include <cmmanagerdefines_shim.h>
       
    30 #include <eapqtconfiginterface.h>
       
    31 #include <HbTranslator>
       
    32 
       
    33 //Trace Definition
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "cpwpauiTraces.h"
       
    37 #endif
       
    38 
       
    39 //Constants
       
    40 //The order in which WPA/WPA2 only mode appears in the list of available 
       
    41 //security modes
       
    42 const int UI_ORDER_WPA_WPA2 = 20;
       
    43 /*!
       
    44  \class CpWpaUi
       
    45  \brief CpWpaUi implements the common Ui for WPA/WPA2 
       
    46  Security Settings Control Panel Plugins,
       
    47  which will allow viewing/editing of WPA/WPA2 Security Settings.
       
    48  */
       
    49 /*!
       
    50  * Constructor
       
    51  */
       
    52 CpWpaUi::CpWpaUi() :
       
    53    mUi(NULL), 
       
    54    mTranslator(new HbTranslator("cpwlansecsettingsplugin")),
       
    55    mCmCM(NULL),
       
    56    mEapQtConfigInterface(NULL),
       
    57    mWpaUi(NULL)
       
    58 {
       
    59     
       
    60 
       
    61 }
       
    62 
       
    63 //Destructor
       
    64 CpWpaUi::~CpWpaUi()
       
    65 {
       
    66     OstTraceFunctionEntry1(CPWPAUI_CPWPAUI_ENTRY,this);
       
    67     delete mEapQtConfigInterface;
       
    68     delete mTranslator;
       
    69     OstTraceFunctionExit1(CPWPAUI_CPWPAUI_EXIT,this);
       
    70 }
       
    71 
       
    72 // ======== MEMBER FUNCTIONS ========
       
    73 
       
    74 /*!
       
    75  Getter for security mode.
       
    76 
       
    77  \return Security mode identifier
       
    78  */
       
    79 CMManagerShim::WlanSecMode CpWpaUi::securityMode() const
       
    80 {
       
    81     OstTraceFunctionEntry1(CPWPAUI_SECURITYMODE_ENTRY,this);
       
    82     OstTraceFunctionExit1(CPWPAUI_SECURITYMODE_EXIT,this);
       
    83     //return security mode
       
    84     return CMManagerShim::WlanSecModeWpa;
       
    85 }
       
    86 
       
    87 /*!
       
    88  Getter for localization text identifier for the security mode,
       
    89  f.ex. "txt_occ_setlabel_wlan_security_mode_val_wpawpa2". This localized
       
    90  text will be shown in the UI.
       
    91  
       
    92  \return Localization text ID
       
    93  */
       
    94 QString CpWpaUi::securityModeTextId() const
       
    95 {
       
    96     OstTraceFunctionEntry1( CPWPAUI_SECURITYMODETEXTID_ENTRY, this );
       
    97     OstTraceFunctionExit1( CPWPAUI_SECURITYMODETEXTID_EXIT, this );
       
    98     return "txt_occ_setlabel_wlan_security_mode_val_wpawpa2";
       
    99 }
       
   100 
       
   101 /*! 
       
   102  Sets the database reference IAP id.
       
   103 
       
   104  \param id Database reference
       
   105  */
       
   106 void CpWpaUi::setReference(CmConnectionMethodShim *cmCm, uint id)
       
   107 {
       
   108     OstTraceFunctionEntry1(CPWPAUI_SETREFERENCE_ENTRY,this);
       
   109     if (!mEapQtConfigInterface) {
       
   110        mEapQtConfigInterface = new EapQtConfigInterface(
       
   111                EapQtConfigInterface::EapBearerTypeWlan, id);
       
   112     } 
       
   113     else {
       
   114        mEapQtConfigInterface->setConfigurationReference(id);     
       
   115     }
       
   116 
       
   117     //mCmCM is not deleted assuming mCmManager owns it.
       
   118     mCmCM = cmCm;
       
   119     OstTraceFunctionExit1(CPWPAUI_SETREFERENCE_EXIT,this);
       
   120 }
       
   121 
       
   122 /*!
       
   123  Getter for order number. This order number is used by the client of
       
   124  this interface to put the security modes in correct order in the list.
       
   125 
       
   126  \return An order number
       
   127  */
       
   128 int CpWpaUi::orderNumber() const
       
   129 {
       
   130     OstTraceFunctionEntry1(CPWPAUI_ORDERNUMBER_ENTRY,this); 
       
   131     OstTraceFunctionExit1(CPWPAUI_ORDERNUMBER_EXIT,this);
       
   132     return UI_ORDER_WPA_WPA2;
       
   133 }
       
   134 
       
   135 /*!
       
   136  Creates an UI instance. Caller owns the object.
       
   137  
       
   138  \param dataHelper Item data helper
       
   139  \return Pointer to an UI object
       
   140  */
       
   141 CpSettingFormItemData* CpWpaUi::uiInstance(CpItemDataHelper &dataHelper)
       
   142 {
       
   143     OstTraceFunctionEntry1(CPWPAUI_UIINSTANCE_ENTRY,this);
       
   144 
       
   145 		//reset the Common Ui Ptr
       
   146     mWpaUi.reset(new CpWpaCmnUi(CMManagerShim::WlanSecModeWpa, dataHelper));
       
   147 
       
   148     mUi = mWpaUi->createUi(mEapQtConfigInterface, mCmCM);
       
   149     
       
   150     OstTraceFunctionExit1(CPWPAUI_UIINSTANCE_EXIT,this);
       
   151     return mUi;
       
   152 }
       
   153 
       
   154 /*!
       
   155    Validates current security settings. This function is called whenever
       
   156    user tries to exit from the settings view. If the plugin determines
       
   157    that some settings need editing before considered valid, it shall
       
   158    return false. A dialog will be shown to the user indicating that
       
   159    settings are still incomplete and asking if he/she wishes to exit
       
   160    anyway.
       
   161 
       
   162    \return True if security settings for WPA/WPA2 are valid, false if not.
       
   163 */
       
   164 bool CpWpaUi::validateSettings()
       
   165 {
       
   166     return mWpaUi->validateSettings();
       
   167 }
       
   168 
       
   169 Q_EXPORT_PLUGIN2(CpWpaUi, CpWpaUi)
       
   170 ;