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

#include "vpndbus.h"

#include "vpn.h"

VpnDbus::VpnDbus(Knm::VpnSetting * setting) : SettingDbus(setting)
{
}

VpnDbus::~VpnDbus()
{
}

void VpnDbus::fromMap(const QVariantMap & map)
{
  Knm::VpnSetting * setting = static_cast<Knm::VpnSetting *>(m_setting);
  if (map.contains(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE))) {
    setting->setServiceType(map.value(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE)).value<QString>());
  }
  if (map.contains(QLatin1String(NM_SETTING_VPN_DATA))) {
    setting->setData(map.value(QLatin1String(NM_SETTING_VPN_DATA)).value<QStringMap>());
  }
  if (map.contains(QLatin1String(NM_SETTING_VPN_USER_NAME))) {
    setting->setUserName(map.value(QLatin1String(NM_SETTING_VPN_USER_NAME)).value<QString>());
  }
  // SECRET
  if (map.contains(QLatin1String(NM_SETTING_VPN_SECRETS))) {
    setting->setVpnSecrets(map.value(QLatin1String(NM_SETTING_VPN_SECRETS)).value<QVariantMap>());
  }
}

QVariantMap VpnDbus::toMap()
{
  QVariantMap map;
  Knm::VpnSetting * setting = static_cast<Knm::VpnSetting *>(m_setting);
  map.insert(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE), setting->serviceType());
  if (!setting->data().isEmpty())
      map.insert(QLatin1String(NM_SETTING_VPN_DATA), QVariant::fromValue(setting->data()));
  map.insert(QLatin1String(NM_SETTING_VPN_SECRETS), QVariant::fromValue(QStringMap()));
  if (!setting->userName().isEmpty())
      map.insert(QLatin1String(NM_SETTING_VPN_USER_NAME), setting->userName());
  return map;
}

QVariantMap VpnDbus::toSecretsMap()
{
  //assume that the settings's vpnSecrets are ready to go
  Knm::VpnSetting * setting = static_cast<Knm::VpnSetting *>(m_setting);
  return setting->vpnSecrets();
}

