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