コード例 #1
0
QVariantMap WirelessSecurityDbus::toSecretsMap()
{
    QVariantMap map;
    Knm::WirelessSecuritySetting *setting = static_cast<Knm::WirelessSecuritySetting *>(m_setting);
    if (setting->securityType() != Knm::WirelessSecuritySetting::EnumSecurityType::None)
        // don't return anything if there is no security
    {
        if (setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::StaticWep ||
                setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::DynamicWep)
        {
            if (setting->wepKeyType() == Knm::WirelessSecuritySetting::Hex)
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), 1);
            else
                if (setting->wepKeyType() == Knm::WirelessSecuritySetting::Passphrase)
                    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), 2);
                else
                    qWarning() << "Wep key type is not set!";
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), setting->weptxkeyindex());
            if (!setting->wepkey0().isEmpty())
            {
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), setting->wepkey0());
            }
            if (!setting->wepkey1().isEmpty())
            {
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), setting->wepkey1());
            }
            if (!setting->wepkey2().isEmpty())
            {
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), setting->wepkey2());
            }
            if (!setting->wepkey3().isEmpty())
            {
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), setting->wepkey3());
            }
        }
        else
            if (setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::WpaPsk || setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::Wpa2Psk)
            {
                if (!setting->psk().isEmpty())
                {
                    map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), setting->psk());
                }
            }
            else
                if (setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::Leap)
                {
                    if (!setting->leappassword().isEmpty())
                    {
                        map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), setting->leappassword());
                    }
                }



    } // end of if not clear
    return map;
}
コード例 #2
0
QVariantMap WirelessSecurityDbus::toMap()
{
    QVariantMap map;
    Knm::WirelessSecuritySetting *setting = static_cast<Knm::WirelessSecuritySetting *>(m_setting);

    if (setting->securityType() != Knm::WirelessSecuritySetting::EnumSecurityType::None)
        // don't return anything if there is no security
    {
        switch (setting->keymgmt())
        {
            case Knm::WirelessSecuritySetting::EnumKeymgmt::None:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "none");
                qDebug() << "Adding key-mgmt: none";
                break;
            case Knm::WirelessSecuritySetting::EnumKeymgmt::Ieee8021x:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "ieee8021x");
                qDebug() << "Adding key-mgmt: ieee8021x";
                break;
            case Knm::WirelessSecuritySetting::EnumKeymgmt::WPANone:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-none");
                qDebug() << "Adding key-mgmt: wpa-none";
                break;
            case Knm::WirelessSecuritySetting::EnumKeymgmt::WPAPSK:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-psk");
                qDebug() << "Adding key-mgmt: wpa-psk";
                break;
            case Knm::WirelessSecuritySetting::EnumKeymgmt::WPAEAP:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap");
                qDebug() << "Adding key-mgmt: wpa-eap";
                break;
        }
        switch (setting->authalg())
        {
            case Knm::WirelessSecuritySetting::EnumAuthalg::none:
                // the none auth alg is internal
                break;
            case Knm::WirelessSecuritySetting::EnumAuthalg::open:
                // the default
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "open");
                break;
            case Knm::WirelessSecuritySetting::EnumAuthalg::shared:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "shared");
                break;
            case Knm::WirelessSecuritySetting::EnumAuthalg::leap:
                map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "leap");
                break;
        }
        if (!setting->proto().isEmpty())
        {
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO), setting->proto());
        }
        if (!setting->pairwise().isEmpty())
        {
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE), setting->pairwise());
        }
        if (!setting->group().isEmpty())
        {
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP), setting->group());
        }
        if (!setting->leapusername().isEmpty())
        {
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), setting->leapusername());
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), (int)setting->leappasswordflags());
        }

        map.unite(toSecretsMap());

        if (!setting->wepkey0().isEmpty() || !setting->wepkey1().isEmpty() ||  !setting->wepkey2().isEmpty() || !setting->wepkey3().isEmpty())
        {
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), (int)setting->wepkeyflags());
        }
        if (!setting->psk().isEmpty())
        {
            map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), (int)setting->pskflags());
        }

    } // end of if not setting->clear()
    return map;
}