diff -r e03a3db4489e -r 9abfd4f00d37 securitysettings/qtconfigutils/eapqtplugininfo/src/eapqtpluginhandle.cpp --- a/securitysettings/qtconfigutils/eapqtplugininfo/src/eapqtpluginhandle.cpp Thu May 13 22:51:27 2010 +0300 +++ b/securitysettings/qtconfigutils/eapqtplugininfo/src/eapqtpluginhandle.cpp Mon May 24 20:32:47 2010 +0300 @@ -17,21 +17,119 @@ */ /* - * %version: 1 % + * %version: 14 % */ #include "eapqtpluginhandle.h" +#include "eapqtpluginhandle_p.h" + +struct EapQtPluginHandleMapper +{ + EapQtExpandedEapType::Type mType; + int mUid; +}; + +static const EapQtPluginHandleMapper handleMapper[EapQtPluginHandle::PluginLast] = { + {EapQtExpandedEapType::TypeUndefined, 0x00000000}, + {EapQtExpandedEapType::TypeEapAka, 0x102073c2}, + {EapQtExpandedEapType::TypeEapFast, 0x2000BF12}, + {EapQtExpandedEapType::TypeEapGtc, 0x101f8e80}, + {EapQtExpandedEapType::TypeLeap, 0x101f8ea7}, + {EapQtExpandedEapType::TypeEapMschapv2, 0x101f8e67}, + {EapQtExpandedEapType::TypePeap, 0x101f8e4e}, + {EapQtExpandedEapType::TypeEapSim, 0x101f8e4b}, + {EapQtExpandedEapType::TypeEapTls, 0x101f8e4d}, + {EapQtExpandedEapType::TypeEapTtls, 0x101f8e4f}, + {EapQtExpandedEapType::TypePap, 0x2001B2F2}, + {EapQtExpandedEapType::TypePlainMschapv2, 0x101f8e7b} +}; + +static const EapQtPluginHandle::Plugin typeMapper[EapQtExpandedEapType::TypeLast] = { + EapQtPluginHandle::PluginUndefined, + EapQtPluginHandle::PluginEapAka, + EapQtPluginHandle::PluginEapFast, + EapQtPluginHandle::PluginEapGtc, + EapQtPluginHandle::PluginLeap, + EapQtPluginHandle::PluginEapMschapv2, + EapQtPluginHandle::PluginPeap, + EapQtPluginHandle::PluginEapSim, + EapQtPluginHandle::PluginEapTls, + EapQtPluginHandle::PluginEapTtls, + EapQtPluginHandle::PluginUndefined, /* no wps plugin */ + EapQtPluginHandle::PluginPap, + EapQtPluginHandle::PluginPlainMschapv2 +}; //---------------------------------------------------------------------------- // EapQtPluginHandle //---------------------------------------------------------------------------- +EapQtPluginHandle::EapQtPluginHandle() : + d_ptr(new EapQtPluginHandlePrivate(handleMapper[PluginUndefined].mType, + handleMapper[PluginUndefined].mUid)) +{ +} -// stub implementation for now +EapQtPluginHandle::EapQtPluginHandle(Plugin id) : + d_ptr(NULL) +{ + Plugin local_id; + if (id < PluginLast) { + local_id = id; + } + else { + local_id = PluginUndefined; + } + d_ptr.reset(new EapQtPluginHandlePrivate(handleMapper[local_id].mType, + handleMapper[local_id].mUid)); +} -EapQtPluginHandle::EapQtPluginHandle() +EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type, int uid) : + d_ptr(new EapQtPluginHandlePrivate(type, uid)) +{ +} + +EapQtPluginHandle::EapQtPluginHandle(EapQtExpandedEapType type) : + d_ptr(new EapQtPluginHandlePrivate(type, handleMapper[typeMapper[type.type()]].mUid)) +{ +} + +EapQtPluginHandle::EapQtPluginHandle(const EapQtPluginHandle& handle) : + d_ptr(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid())) { } EapQtPluginHandle::~EapQtPluginHandle() { + // scoped pointer delete } + +EapQtExpandedEapType EapQtPluginHandle::type() const +{ + return d_ptr->mType; +} + +int EapQtPluginHandle::protocolImplementationUid() const +{ + return d_ptr->mProtocolImplementationUid; +} + +EapQtPluginHandle::Plugin EapQtPluginHandle::pluginId() const +{ + return typeMapper[d_ptr->mType.type()]; +} + +bool EapQtPluginHandle::operator==(const EapQtPluginHandle &other) const +{ + return (other.d_ptr->mProtocolImplementationUid == d_ptr->mProtocolImplementationUid) + && (other.d_ptr->mType == d_ptr->mType); +} + +EapQtPluginHandle& EapQtPluginHandle::operator=(const EapQtPluginHandle &handle) +{ + // check if assigning to myself + if (this != &handle) { + d_ptr.reset(new EapQtPluginHandlePrivate(handle.type(), handle.protocolImplementationUid())); + } + return *this; +} +