wlanutilities/wlanwizard/tsrc/stubs/eapqtconfig_stub.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     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  *   STUB: EAPWIZARD: EAP method QT configuration
       
    16  *
       
    17  */
       
    18 
       
    19 /*
       
    20  * %version: 4 %
       
    21  */
       
    22 
       
    23 #include "eapqtconfig.h"
       
    24 #include <eapqtpluginhandle.h>
       
    25 #include "eapqtcertificateinfo.h"
       
    26 #include <QDebug>
       
    27 
       
    28 //----------------------------------------------------------------------------
       
    29 //              EapQtConfig                
       
    30 //----------------------------------------------------------------------------
       
    31 
       
    32 EapQtConfig::EapQtConfig()
       
    33 {
       
    34 }
       
    35 
       
    36 EapQtConfig::EapQtConfig(const EapQtConfig &other)
       
    37 {
       
    38     mSettings = other.mSettings;
       
    39 }
       
    40 
       
    41 EapQtConfig::~EapQtConfig()
       
    42 {
       
    43     // scoped pointer deleted automatically
       
    44 }
       
    45 
       
    46 QVariant EapQtConfig::value(const SettingsId id) const
       
    47 {
       
    48     // check for valid range, otherwise memory is consumed for no reason
       
    49     if(id >= SettingsIdLast) {
       
    50         qDebug("ERROR: EapQtConfig::value - invalid id!");
       
    51         return QVariant::Invalid;
       
    52     }
       
    53     return mSettings[id];
       
    54 }
       
    55 
       
    56 void EapQtConfig::setValue(const SettingsId id, const QVariant &newValue)
       
    57 {
       
    58     // check for valid range, otherwise memory is consumed for no reason
       
    59     if(id < SettingsIdLast) {
       
    60         mSettings[id] = newValue;
       
    61     } else {
       
    62         qDebug("ERROR: EapQtConfig::setValue - invalid id!");
       
    63     }
       
    64     return;
       
    65 }
       
    66 
       
    67 void EapQtConfig::clear() {
       
    68     mSettings.clear();
       
    69     return;
       
    70 }
       
    71 
       
    72 bool EapQtConfig::operator==(const EapQtConfig & rhs ) const
       
    73 {
       
    74     bool ret = true;
       
    75     if (mSettings.size() != rhs.mSettings.size()) {
       
    76         qWarning("EapQtConfig::operator==(): size: expect %d, actual %d ",
       
    77             mSettings.size(),
       
    78             rhs.mSettings.size() );
       
    79         ret = false;
       
    80     }
       
    81     QHashIterator<int, QVariant> i(mSettings);
       
    82     
       
    83     while (i.hasNext()) {
       
    84         i.next();
       
    85         if (!rhs.mSettings.contains(i.key())){
       
    86             qWarning("EapQtConfig::operator==(): key not found: %d", i.key());
       
    87             ret = false;
       
    88             
       
    89         }
       
    90         if (i.key() == EapQtConfig::InnerType) {
       
    91             QList<QVariant> list1(mSettings[i.key()].toList());
       
    92             QList<QVariant> list2(rhs.mSettings[i.key()].toList());
       
    93             
       
    94             if (list1.length() != 1 || list1.length() != list2.length()){
       
    95                 qWarning("Invalid length in EapQtConfig::InnerType");
       
    96                 ret = false;
       
    97             } else {
       
    98                 EapQtPluginHandle handle1 = list1.at(0).value<EapQtPluginHandle> ();
       
    99                 EapQtPluginHandle handle2 = list2.at(0).value<EapQtPluginHandle> ();
       
   100                 if (handle1.pluginId() != handle2.pluginId()){
       
   101                     qWarning("Outer: %d", handle1.pluginId());
       
   102                     qWarning("Outer: %d", handle2.pluginId());
       
   103                     ret = false;
       
   104                 }
       
   105             }
       
   106         }
       
   107         else if (i.key() == EapQtConfig::OuterType) {
       
   108             EapQtPluginHandle handle = mSettings[i.key()].value<EapQtPluginHandle> ();
       
   109             EapQtPluginHandle handle2 = rhs.mSettings[i.key()].value<EapQtPluginHandle> ();
       
   110             if (handle.pluginId() != handle2.pluginId()){
       
   111                 qWarning("Outer: %d", handle.pluginId());
       
   112                 qWarning("Outer: %d", handle2.pluginId());
       
   113                 ret = false;
       
   114             }
       
   115         }
       
   116         else if (i.key() == EapQtConfig::AuthorityCertificate ||
       
   117                  i.key() == EapQtConfig::UserCertificate) {
       
   118             QList<QVariant> list1(mSettings[i.key()].toList());
       
   119             QList<QVariant> list2(rhs.mSettings[i.key()].toList());
       
   120             
       
   121             if (list1.length() != 1 || list1.length() != list2.length()) {
       
   122                 qWarning("Invalid length Certs %d", i.key());
       
   123                 ret = false;
       
   124             } else {
       
   125                 EapQtCertificateInfo cert1 = list1.at(0).value<EapQtCertificateInfo>();
       
   126                 EapQtCertificateInfo cert2 = list2.at(0).value<EapQtCertificateInfo>();
       
   127                 
       
   128                 if (!(cert1 == cert2)) {
       
   129                     ret = false;
       
   130                     qWarning("Invalid certs %d", i.key());
       
   131                 }
       
   132             }
       
   133         }
       
   134         else {
       
   135             if (i.value() != rhs.mSettings[i.key()]){
       
   136                 qWarning("EapQtConfig::operator==(): values does not match %d", i.key());
       
   137                 qDebug() << "Expect: " << i.value();
       
   138                 qDebug() << "Actual: " << rhs.mSettings[i.key()];
       
   139                 ret = false;
       
   140             }
       
   141         }
       
   142     }
       
   143     return ret;
       
   144 }
       
   145 
       
   146