securitysettings/qtconfigutils/eapqtplugininfo/src/eapqtpluginhandle.cpp
changeset 39 fe6b6762fccd
parent 33 938269283a16
child 52 c23bdf5a328a
equal deleted inserted replaced
38:7a0216d033ac 39:fe6b6762fccd
     1 /*
     1 /*
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of the License "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8  *
     8  *
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description: 
    14  * Description: 
    15  *   Control Panel EAP plugin information
    15  *   Handle to EAP plugin information
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 /*
    19 /*
    20  * %version: 15 %
    20  * %version: 16 %
    21  */
    21  */
    22 
    22 
    23 #include "eapqtpluginhandle.h"
    23 // System includes
       
    24 #include <eapqtpluginhandle.h>
       
    25 
       
    26 // User includes
    24 #include "eapqtpluginhandle_p.h"
    27 #include "eapqtpluginhandle_p.h"
       
    28 
       
    29 /*!
       
    30  *  \class EapQtPluginHandle
       
    31  *  \brief Public implementation of handle to EAP plugin information
       
    32  */
       
    33 
       
    34 // External function prototypes
       
    35 
       
    36 // Local constants
    25 
    37 
    26 struct EapQtPluginHandleMapper
    38 struct EapQtPluginHandleMapper
    27 {
    39 {
    28     EapQtExpandedEapType::Type mType;
    40     EapQtExpandedEapType::Type mType;
    29     int mUid;
    41     int mUid;
    30 };
    42 };
    31 
    43 
       
    44 // mapper from EapQtPluginHandle::Plugin to default
       
    45 // EapQtExpandedEapType & protocol plugin implementation UID pair
    32 static const EapQtPluginHandleMapper handleMapper[EapQtPluginHandle::PluginLast] = { 
    46 static const EapQtPluginHandleMapper handleMapper[EapQtPluginHandle::PluginLast] = { 
    33     {EapQtExpandedEapType::TypeUndefined,     0x00000000},
    47     {EapQtExpandedEapType::TypeUndefined,     0x00000000},
    34     {EapQtExpandedEapType::TypeEapAka,        0x102073c2},
    48     {EapQtExpandedEapType::TypeEapAka,        0x102073c2},
    35     {EapQtExpandedEapType::TypeEapFast,       0x2000BF12},
    49     {EapQtExpandedEapType::TypeEapFast,       0x2000BF12},
    36     {EapQtExpandedEapType::TypeEapGtc,        0x101f8e80},
    50     {EapQtExpandedEapType::TypeEapGtc,        0x101f8e80},
    42     {EapQtExpandedEapType::TypeEapTtls,       0x101f8e4f},
    56     {EapQtExpandedEapType::TypeEapTtls,       0x101f8e4f},
    43     {EapQtExpandedEapType::TypePap,           0x2001B2F2},
    57     {EapQtExpandedEapType::TypePap,           0x2001B2F2},
    44     {EapQtExpandedEapType::TypePlainMschapv2, 0x101f8e7b}
    58     {EapQtExpandedEapType::TypePlainMschapv2, 0x101f8e7b}
    45 };
    59 };
    46 
    60 
       
    61 // mapper from EapQtExpandedEapType::Type to EapQtPluginHandle::Plugin
    47 static const EapQtPluginHandle::Plugin typeMapper[EapQtExpandedEapType::TypeLast] = {
    62 static const EapQtPluginHandle::Plugin typeMapper[EapQtExpandedEapType::TypeLast] = {
    48     EapQtPluginHandle::PluginUndefined, 
    63     EapQtPluginHandle::PluginUndefined, 
    49     EapQtPluginHandle::PluginEapAka,
    64     EapQtPluginHandle::PluginEapAka,
    50     EapQtPluginHandle::PluginEapFast, 
    65     EapQtPluginHandle::PluginEapFast, 
    51     EapQtPluginHandle::PluginEapGtc,
    66     EapQtPluginHandle::PluginEapGtc,
    53     EapQtPluginHandle::PluginEapMschapv2,
    68     EapQtPluginHandle::PluginEapMschapv2,
    54     EapQtPluginHandle::PluginPeap, 
    69     EapQtPluginHandle::PluginPeap, 
    55     EapQtPluginHandle::PluginEapSim,
    70     EapQtPluginHandle::PluginEapSim,
    56     EapQtPluginHandle::PluginEapTls, 
    71     EapQtPluginHandle::PluginEapTls, 
    57     EapQtPluginHandle::PluginEapTtls,
    72     EapQtPluginHandle::PluginEapTtls,
    58     EapQtPluginHandle::PluginUndefined, /* no wps plugin */ 
    73     EapQtPluginHandle::PluginUndefined, /* wps does not have a plugin */
    59     EapQtPluginHandle::PluginPap,
    74     EapQtPluginHandle::PluginPap,
    60     EapQtPluginHandle::PluginPlainMschapv2 
    75     EapQtPluginHandle::PluginPlainMschapv2 
    61 };
    76 };
    62 
    77 
       
    78 // ======== LOCAL FUNCTIONS ========
    63 
    79 
       
    80 // ======== MEMBER FUNCTIONS ========
    64 
    81 
    65 //----------------------------------------------------------------------------
       
    66 //              EapQtPluginHandle
       
    67 //----------------------------------------------------------------------------
       
    68 EapQtPluginHandle::EapQtPluginHandle() :
    82 EapQtPluginHandle::EapQtPluginHandle() :
    69     d_ptr(new EapQtPluginHandlePrivate(handleMapper[PluginUndefined].mType,
    83     d_ptr(new EapQtPluginHandlePrivate(handleMapper[PluginUndefined].mType,
    70         handleMapper[PluginUndefined].mUid))
    84         handleMapper[PluginUndefined].mUid))
    71 {
    85 {
    72 }
    86 }
    73 
    87 
    74 EapQtPluginHandle::EapQtPluginHandle(Plugin id) :
    88 EapQtPluginHandle::EapQtPluginHandle(const Plugin id) :
    75     d_ptr(NULL)
    89     d_ptr(NULL)
    76 {
    90 {
    77     Plugin localId;
    91     Plugin localId;
    78     if (id < PluginLast) {
    92     if (id < PluginLast) {
    79         localId = id;
    93         localId = id;
    83     }
    97     }
    84     d_ptr.reset(new EapQtPluginHandlePrivate(handleMapper[localId].mType,
    98     d_ptr.reset(new EapQtPluginHandlePrivate(handleMapper[localId].mType,
    85         handleMapper[localId].mUid));
    99         handleMapper[localId].mUid));
    86 }
   100 }
    87 
   101 
    88 EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type, int uid) :
   102 EapQtPluginHandle::EapQtPluginHandle(const EapQtExpandedEapType& type, const int uid) :
    89     d_ptr(new EapQtPluginHandlePrivate(type, uid))
   103     d_ptr(new EapQtPluginHandlePrivate(type, uid))
    90 {
   104 {
    91 }
   105 }
    92 
   106 
    93 EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type) :
   107 EapQtPluginHandle::EapQtPluginHandle(const EapQtExpandedEapType& type) :
    94     d_ptr(new EapQtPluginHandlePrivate(type, handleMapper[typeMapper[type.type()]].mUid))
   108     d_ptr(new EapQtPluginHandlePrivate(type, handleMapper[typeMapper[type.type()]].mUid))
    95 {
   109 {
    96 }
   110 }
    97 
   111 
    98 EapQtPluginHandle::EapQtPluginHandle(const EapQtPluginHandle& handle) :
   112 EapQtPluginHandle::EapQtPluginHandle(const EapQtPluginHandle& handle) :
   118 EapQtPluginHandle::Plugin EapQtPluginHandle::pluginId() const
   132 EapQtPluginHandle::Plugin EapQtPluginHandle::pluginId() const
   119 {
   133 {
   120     return typeMapper[d_ptr->mType.type()];
   134     return typeMapper[d_ptr->mType.type()];
   121 }
   135 }
   122 
   136 
   123 bool EapQtPluginHandle::operator==(const EapQtPluginHandle &other) const
       
   124 {
       
   125     return (other.d_ptr->mProtocolImplementationUid == d_ptr->mProtocolImplementationUid)
       
   126         && (other.d_ptr->mType == d_ptr->mType);
       
   127 }
       
   128 
       
   129 EapQtPluginHandle& EapQtPluginHandle::operator=(const EapQtPluginHandle &handle)
   137 EapQtPluginHandle& EapQtPluginHandle::operator=(const EapQtPluginHandle &handle)
   130 {
   138 {
   131     // check if assigning to myself
   139     // check if assigning to myself
   132     if (this != &handle) {
   140     if (this != &handle) {
   133         d_ptr.reset(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid()));
   141         d_ptr.reset(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid()));
   134     }
   142     }
   135     return *this;
   143     return *this;
   136 }
   144 }
   137 
   145 
       
   146 bool EapQtPluginHandle::operator ==(const EapQtPluginHandle &right_type_value) const
       
   147 {
       
   148     return (right_type_value.d_ptr->mProtocolImplementationUid == d_ptr->mProtocolImplementationUid)
       
   149         && (right_type_value.d_ptr->mType == d_ptr->mType);
       
   150 }
       
   151 
       
   152 bool EapQtPluginHandle::operator !=(const EapQtPluginHandle &right_type_value) const
       
   153 {
       
   154     return (right_type_value.d_ptr->mProtocolImplementationUid != d_ptr->mProtocolImplementationUid)
       
   155         || (right_type_value.d_ptr->mType != d_ptr->mType);
       
   156 }