// This file is generated by kconfig_compiler from cdma.kcfg.
// All changes you do to this file will be lost.

#include "cdmadbus.h"

#include "cdma.h"

CdmaDbus::CdmaDbus(Knm::CdmaSetting * setting) : SettingDbus(setting)
{
}

CdmaDbus::~CdmaDbus()
{
}

void CdmaDbus::fromMap(const QVariantMap & map)
{
    Knm::CdmaSetting * setting = static_cast<Knm::CdmaSetting *>(m_setting);
    if (map.contains(QLatin1String(NM_SETTING_CDMA_NUMBER))) {
        setting->setNumber(map.value(QLatin1String(NM_SETTING_CDMA_NUMBER)).value<QString>());
    }
    if (map.contains(QLatin1String(NM_SETTING_CDMA_USERNAME))) {
        setting->setUsername(map.value(QLatin1String(NM_SETTING_CDMA_USERNAME)).value<QString>());
    }
    // SECRET
    if (map.contains(QLatin1String(NM_SETTING_CDMA_PASSWORD))) {
        setting->setPassword(map.value(QLatin1String(NM_SETTING_CDMA_PASSWORD)).value<QString>());
    }
    setting->setPasswordflags((Knm::Setting::secretsTypes)map.value(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS)).value<int>());
}

QVariantMap CdmaDbus::toMap()
{
    QVariantMap map;
    Knm::CdmaSetting * setting = static_cast<Knm::CdmaSetting *>(m_setting);
    map.insert(QLatin1String(NM_SETTING_CDMA_NUMBER), setting->number());
    map.insert(QLatin1String(NM_SETTING_CDMA_USERNAME), setting->username());
    map.unite(toSecretsMap());
    if (!setting->password().isEmpty())
        map.insert(QLatin1String(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS)), (int)setting->passwordflags());
    return map;
}

QVariantMap CdmaDbus::toSecretsMap()
{
    QVariantMap map;
    Knm::CdmaSetting * setting = static_cast<Knm::CdmaSetting *>(m_setting);
    if (!setting->password().isEmpty())
        map.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD), setting->password());
    return map;
}

