Пример #1
0
void NetworkManager::Ipv4Setting::fromMap(const QVariantMap &setting)
{
    if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD))) {
        const QString methodType = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD)).toString();

        if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_AUTO)) {
            setMethod(Automatic);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) {
            setMethod(LinkLocal);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
            setMethod(Manual);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_SHARED)) {
            setMethod(Shared);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
            setMethod(Disabled);
        } else {
            setMethod(Automatic);
        }
    }

    if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS))) {
        QList<QHostAddress> dbusDns;
        QList<uint> temp;
        if (setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).canConvert<QDBusArgument>()) {
            QDBusArgument dnsArg = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value<QDBusArgument>();
            temp = qdbus_cast<QList<uint> >(dnsArg);
        } else {
            temp = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value<QList<uint> >();
        }

        Q_FOREACH (const uint utmp, temp) {
            QHostAddress tmpHost(ntohl(utmp));
            dbusDns << tmpHost;
        }
Пример #2
0
void Ipv6Dbus::fromMap(const QVariantMap &map)
{
    /*qDebug() << "IPv6 map: ";
    foreach(const QString &key, map.keys())
        qDebug() << key << " : " << map.value(key);*/

    Knm::Ipv6Setting *setting = static_cast<Knm::Ipv6Setting *>(m_setting);

    if (map.contains(QLatin1String(NM_SETTING_IP6_CONFIG_METHOD)))
    {
        setting->setMethod(methodStringToEnum(map.value(QLatin1String(NM_SETTING_IP6_CONFIG_METHOD)).value<QString>()));
    }

    if (map.contains(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)))
    {
        QList<QHostAddress> dbusDns;
        QList<QByteArray> temp;
        if (map.value(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)).canConvert<QDBusArgument>())
        {
            QDBusArgument dnsArg = map.value(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)).value< QDBusArgument>();
            temp = qdbus_cast<QList<QByteArray> >(dnsArg);
        }
        else
        {
            temp = map.value(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)).value<QList<QByteArray> >();
        }

        foreach (const QByteArray & utmp, temp)
        {
            Q_IPV6ADDR tmp;
            for (int i = 0; i < 16; i++)
            {
                tmp[i] = utmp[i];
            }
            QHostAddress tmpHost(tmp);
            dbusDns << tmpHost;
        }