wlanutilities/wlanwizard/tsrc/stubs/wlanqtutilsap_stub.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     1 /*
       
     2  * Copyright (c) 2009 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  * This is the source file for WlanQtUtilsAp class.
       
    16  */
       
    17 
       
    18 #include <QString>
       
    19 #include <QHash>
       
    20 #include <QVariant>
       
    21 #include <QDebug>
       
    22 #include "wlanqtutilscommon.h"
       
    23 #include "wlanqtutilsap.h"
       
    24 
       
    25 class WlanQtUtilsApPrivate
       
    26 {
       
    27     friend class WlanQtUtilsAp;
       
    28 
       
    29 private:
       
    30     QHash<int, QVariant> mConfigurations;
       
    31 };
       
    32 
       
    33 WlanQtUtilsAp::WlanQtUtilsAp() :
       
    34     d_ptr(new WlanQtUtilsApPrivate())
       
    35 {
       
    36 }
       
    37 
       
    38 WlanQtUtilsAp::WlanQtUtilsAp(const WlanQtUtilsAp &ref) :
       
    39     d_ptr(new WlanQtUtilsApPrivate())
       
    40 {
       
    41     d_ptr->mConfigurations = ref.d_ptr->mConfigurations;
       
    42 }
       
    43 
       
    44 WlanQtUtilsAp::~WlanQtUtilsAp()
       
    45 {
       
    46     d_ptr->mConfigurations.clear();
       
    47     delete d_ptr;
       
    48 }
       
    49 
       
    50 QVariant WlanQtUtilsAp::value(int identifier) const
       
    51 {
       
    52     return d_ptr->mConfigurations[identifier];
       
    53 }
       
    54 
       
    55 void WlanQtUtilsAp::setValue(int identifier, QVariant value)
       
    56 {
       
    57     d_ptr->mConfigurations[identifier] = value;
       
    58 }
       
    59 
       
    60 bool WlanQtUtilsAp::operator==(const WlanQtUtilsAp & rhs ) const
       
    61 {
       
    62     bool ret = true;
       
    63     if (d_ptr->mConfigurations.size() != rhs.d_ptr->mConfigurations.size()) {
       
    64         qWarning("WlanQtUtilsAp::operator==(): size: expect %d, actual %d ",
       
    65             d_ptr->mConfigurations.size(),
       
    66             rhs.d_ptr->mConfigurations.size() );
       
    67         ret = false;
       
    68     }
       
    69     QHashIterator<int, QVariant> i(d_ptr->mConfigurations);
       
    70     
       
    71     while (i.hasNext()) {
       
    72         i.next();
       
    73         if (!rhs.d_ptr->mConfigurations.contains(i.key())){
       
    74             qWarning("WlanQtUtilsAp::operator==(): key not found: %d", i.key());
       
    75             ret = false;
       
    76             
       
    77         }
       
    78         if (i.value() != rhs.d_ptr->mConfigurations[i.key()]){
       
    79             qWarning("WlanQtUtilsAp::operator==(): values not match %d", i.key());
       
    80             qDebug() << "Expect: " << i.value();
       
    81             qDebug() << "Actual: " << rhs.d_ptr->mConfigurations[i.key()];
       
    82             ret = false;
       
    83         }
       
    84     }
       
    85     return ret;
       
    86 }
       
    87 
       
    88 /*!
       
    89     AP comparison function.
       
    90 
       
    91     @param [in] ap1 First AP to compare.
       
    92     @param [in] ap2 Second AP to compare.
       
    93 
       
    94     @return Zero(0), if APs are considered to be same.
       
    95 */
       
    96 
       
    97 int WlanQtUtilsAp::compare(
       
    98     const WlanQtUtilsAp *ap1,
       
    99     const WlanQtUtilsAp *ap2)
       
   100 {
       
   101     int equal = 1; // Not equal
       
   102     
       
   103     // SSID (case sensitive) and security mode (with or without PSK)
       
   104     // are the values, which identify a unique access point.
       
   105     if (ap1->value(WlanQtUtilsAp::ConfIdSsid) ==
       
   106         ap2->value(WlanQtUtilsAp::ConfIdSsid)
       
   107         && ap1->value(WlanQtUtilsAp::ConfIdSecurityMode) == 
       
   108            ap2->value(WlanQtUtilsAp::ConfIdSecurityMode)
       
   109            && ap1->value(WlanQtUtilsAp::ConfIdWpaPskUse) ==
       
   110               ap2->value(WlanQtUtilsAp::ConfIdWpaPskUse)) {
       
   111         equal = 0; // Equal
       
   112     }
       
   113     
       
   114     return equal;
       
   115 }
       
   116 
       
   117