securitysettings/qtconfigutils/eapqtplugininfo/src/eapqtpluginhandle.cpp
changeset 26 9abfd4f00d37
parent 22 093cf0757204
child 27 9660a5eb236f
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
    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: 14 %
    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 };
    24 
    62 
    25 //----------------------------------------------------------------------------
    63 //----------------------------------------------------------------------------
    26 //              EapQtPluginHandle
    64 //              EapQtPluginHandle
    27 //----------------------------------------------------------------------------
    65 //----------------------------------------------------------------------------
       
    66 EapQtPluginHandle::EapQtPluginHandle() :
       
    67     d_ptr(new EapQtPluginHandlePrivate(handleMapper[PluginUndefined].mType,
       
    68         handleMapper[PluginUndefined].mUid))
       
    69 {
       
    70 }
    28 
    71 
    29 // stub implementation for now
    72 EapQtPluginHandle::EapQtPluginHandle(Plugin id) :
       
    73     d_ptr(NULL)
       
    74 {
       
    75     Plugin local_id;
       
    76     if (id < PluginLast) {
       
    77         local_id = id;
       
    78     }
       
    79     else {
       
    80         local_id = PluginUndefined;
       
    81     }
       
    82     d_ptr.reset(new EapQtPluginHandlePrivate(handleMapper[local_id].mType,
       
    83         handleMapper[local_id].mUid));
       
    84 }
    30 
    85 
    31 EapQtPluginHandle::EapQtPluginHandle()
    86 EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type, int uid) :
       
    87     d_ptr(new EapQtPluginHandlePrivate(type, uid))
       
    88 {
       
    89 }
       
    90 
       
    91 EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type) :
       
    92     d_ptr(new EapQtPluginHandlePrivate(type, handleMapper[typeMapper[type.type()]].mUid))
       
    93 {
       
    94 }
       
    95 
       
    96 EapQtPluginHandle::EapQtPluginHandle(const EapQtPluginHandle& handle) :
       
    97     d_ptr(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid()))
    32 {
    98 {
    33 }
    99 }
    34 
   100 
    35 EapQtPluginHandle::~EapQtPluginHandle()
   101 EapQtPluginHandle::~EapQtPluginHandle()
    36 {
   102 {
       
   103     // scoped pointer delete
    37 }
   104 }
       
   105 
       
   106 EapQtExpandedEapType EapQtPluginHandle::type() const
       
   107 {
       
   108     return d_ptr->mType;
       
   109 }
       
   110 
       
   111 int EapQtPluginHandle::protocolImplementationUid() const
       
   112 {
       
   113     return d_ptr->mProtocolImplementationUid;
       
   114 }
       
   115 
       
   116 EapQtPluginHandle::Plugin EapQtPluginHandle::pluginId() const
       
   117 {
       
   118     return typeMapper[d_ptr->mType.type()];
       
   119 }
       
   120 
       
   121 bool EapQtPluginHandle::operator==(const EapQtPluginHandle &other) const
       
   122 {
       
   123     return (other.d_ptr->mProtocolImplementationUid == d_ptr->mProtocolImplementationUid)
       
   124         && (other.d_ptr->mType == d_ptr->mType);
       
   125 }
       
   126 
       
   127 EapQtPluginHandle& EapQtPluginHandle::operator=(const EapQtPluginHandle &handle)
       
   128 {
       
   129     // check if assigning to myself
       
   130     if (this != &handle) {
       
   131         d_ptr.reset(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid()));
       
   132     }
       
   133     return *this;
       
   134 }
       
   135