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