securitysettings/qtconfigutils/eapqtplugininfo/src/eapqtpluginhandle.cpp
changeset 33 938269283a16
parent 22 093cf0757204
child 39 fe6b6762fccd
equal deleted inserted replaced
22:093cf0757204 33:938269283a16
    15  *   Control Panel EAP plugin information
    15  *   Control Panel EAP plugin information
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 /*
    19 /*
    20  * %version: 1 %
    20  * %version: 15 %
    21  */
    21  */
    22 
    22 
    23 #include "eapqtpluginhandle.h"
    23 #include "eapqtpluginhandle.h"
       
    24 #include "eapqtpluginhandle_p.h"
       
    25 
       
    26 struct EapQtPluginHandleMapper
       
    27 {
       
    28     EapQtExpandedEapType::Type mType;
       
    29     int mUid;
       
    30 };
       
    31 
       
    32 static const EapQtPluginHandleMapper handleMapper[EapQtPluginHandle::PluginLast] = { 
       
    33     {EapQtExpandedEapType::TypeUndefined,     0x00000000},
       
    34     {EapQtExpandedEapType::TypeEapAka,        0x102073c2},
       
    35     {EapQtExpandedEapType::TypeEapFast,       0x2000BF12},
       
    36     {EapQtExpandedEapType::TypeEapGtc,        0x101f8e80},
       
    37     {EapQtExpandedEapType::TypeLeap,          0x101f8ea7},
       
    38     {EapQtExpandedEapType::TypeEapMschapv2,   0x101f8e67},
       
    39     {EapQtExpandedEapType::TypePeap,          0x101f8e4e},
       
    40     {EapQtExpandedEapType::TypeEapSim,        0x101f8e4b},
       
    41     {EapQtExpandedEapType::TypeEapTls,        0x101f8e4d},
       
    42     {EapQtExpandedEapType::TypeEapTtls,       0x101f8e4f},
       
    43     {EapQtExpandedEapType::TypePap,           0x2001B2F2},
       
    44     {EapQtExpandedEapType::TypePlainMschapv2, 0x101f8e7b}
       
    45 };
       
    46 
       
    47 static const EapQtPluginHandle::Plugin typeMapper[EapQtExpandedEapType::TypeLast] = {
       
    48     EapQtPluginHandle::PluginUndefined, 
       
    49     EapQtPluginHandle::PluginEapAka,
       
    50     EapQtPluginHandle::PluginEapFast, 
       
    51     EapQtPluginHandle::PluginEapGtc,
       
    52     EapQtPluginHandle::PluginLeap, 
       
    53     EapQtPluginHandle::PluginEapMschapv2,
       
    54     EapQtPluginHandle::PluginPeap, 
       
    55     EapQtPluginHandle::PluginEapSim,
       
    56     EapQtPluginHandle::PluginEapTls, 
       
    57     EapQtPluginHandle::PluginEapTtls,
       
    58     EapQtPluginHandle::PluginUndefined, /* no wps plugin */ 
       
    59     EapQtPluginHandle::PluginPap,
       
    60     EapQtPluginHandle::PluginPlainMschapv2 
       
    61 };
       
    62 
       
    63 
    24 
    64 
    25 //----------------------------------------------------------------------------
    65 //----------------------------------------------------------------------------
    26 //              EapQtPluginHandle
    66 //              EapQtPluginHandle
    27 //----------------------------------------------------------------------------
    67 //----------------------------------------------------------------------------
       
    68 EapQtPluginHandle::EapQtPluginHandle() :
       
    69     d_ptr(new EapQtPluginHandlePrivate(handleMapper[PluginUndefined].mType,
       
    70         handleMapper[PluginUndefined].mUid))
       
    71 {
       
    72 }
    28 
    73 
    29 // stub implementation for now
    74 EapQtPluginHandle::EapQtPluginHandle(Plugin id) :
       
    75     d_ptr(NULL)
       
    76 {
       
    77     Plugin localId;
       
    78     if (id < PluginLast) {
       
    79         localId = id;
       
    80     }
       
    81     else {
       
    82         localId = PluginUndefined;
       
    83     }
       
    84     d_ptr.reset(new EapQtPluginHandlePrivate(handleMapper[localId].mType,
       
    85         handleMapper[localId].mUid));
       
    86 }
    30 
    87 
    31 EapQtPluginHandle::EapQtPluginHandle()
    88 EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type, int uid) :
       
    89     d_ptr(new EapQtPluginHandlePrivate(type, uid))
       
    90 {
       
    91 }
       
    92 
       
    93 EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type) :
       
    94     d_ptr(new EapQtPluginHandlePrivate(type, handleMapper[typeMapper[type.type()]].mUid))
       
    95 {
       
    96 }
       
    97 
       
    98 EapQtPluginHandle::EapQtPluginHandle(const EapQtPluginHandle& handle) :
       
    99     d_ptr(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid()))
    32 {
   100 {
    33 }
   101 }
    34 
   102 
    35 EapQtPluginHandle::~EapQtPluginHandle()
   103 EapQtPluginHandle::~EapQtPluginHandle()
    36 {
   104 {
       
   105     // scoped pointer delete
    37 }
   106 }
       
   107 
       
   108 EapQtExpandedEapType EapQtPluginHandle::type() const
       
   109 {
       
   110     return d_ptr->mType;
       
   111 }
       
   112 
       
   113 int EapQtPluginHandle::protocolImplementationUid() const
       
   114 {
       
   115     return d_ptr->mProtocolImplementationUid;
       
   116 }
       
   117 
       
   118 EapQtPluginHandle::Plugin EapQtPluginHandle::pluginId() const
       
   119 {
       
   120     return typeMapper[d_ptr->mType.type()];
       
   121 }
       
   122 
       
   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)
       
   130 {
       
   131     // check if assigning to myself
       
   132     if (this != &handle) {
       
   133         d_ptr.reset(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid()));
       
   134     }
       
   135     return *this;
       
   136 }
       
   137