Exemplo n.º 1
0
/**
* This controller needs the parameter 'machine' with the name of the machine
*
* \param[in] params The parameter map
*/
void InfoController::setParams(const QStringMap& params)
{
	if( !params.contains("machine") || !params.contains("machine"))
	{
		std::cerr << "InfoController: Required parameter not found" << std::endl;
		return;
	}

	_machine = params["machine"];
	_model.setDatabaseFile( params["db"] );
}
void VpncSettingWidget::readConfig()
{
    Q_D(VpncSettingWidget);
    // General settings
    QStringMap dataMap = d->setting->data();
    //   gateway
    QString gateway = dataMap[NM_VPNC_KEY_GATEWAY];
    if (!gateway.isEmpty()) {
        d->ui.leGateway->setText(gateway);
    }
    //   username
    QString user = dataMap[NM_VPNC_KEY_XAUTH_USER];
    if (!user.isEmpty()) {
        d->ui.leUserName->setText(user);
    }
    //   group name
    QString group = dataMap[NM_VPNC_KEY_ID];
    if (!group.isEmpty()) {
        d->ui.leGroupName->setText(group);
    }
    // hybrid auth
    if (dataMap[NM_VPNC_KEY_AUTHMODE] == QLatin1String("hybrid")) {
        d->ui.cbUseHybridAuth->setChecked(true);
        d->ui.leCaCertPath->setUrl(KUrl(dataMap[NM_VPNC_KEY_CA_FILE]));
    }
    // password storage type is set in readSecrets

    // Optional settings
    //   domain
    QString domain = dataMap[NM_VPNC_KEY_DOMAIN];
    if (!domain.isEmpty()) {
        d->ui.leDomain->setText(domain);
    }

    //   encryption
    if (dataMap[NM_VPNC_KEY_SINGLE_DES] == QLatin1String("yes")) {
        d->ui.cboEncryptionMethod->setCurrentIndex(VpncSettingWidgetPrivate::EnumEncryptionMethod::Weak);
    } else if (dataMap[NM_VPNC_KEY_NO_ENCRYPTION] == QLatin1String("yes")) {
        d->ui.cboEncryptionMethod->setCurrentIndex(VpncSettingWidgetPrivate::EnumEncryptionMethod::None);
    }

    //   nat traversal
    if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_NATT)
        d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::NattIfAvail);
    else if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_NATT_ALWAYS)
        d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::Force);
    else if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_CISCO)
        d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::CiscoUdp);
    else if (dataMap[NM_VPNC_KEY_NAT_TRAVERSAL_MODE] == NM_VPNC_NATT_MODE_NONE)
        d->ui.cboNatTraversal->setCurrentIndex(VpncSettingWidgetPrivate::EnumNatt::Disabled);

    //   dead peer detection
    if (dataMap.contains(NM_VPNC_KEY_DPD_IDLE_TIMEOUT)) {
        uint dpdTimeout = dataMap.value(NM_VPNC_KEY_DPD_IDLE_TIMEOUT).toUInt();
        if (dpdTimeout == 0) {
            d->ui.chkDeadPeerDetection->setChecked(false);
            d->dpdTimeout = dpdTimeout;
        }
    }
    //   dh group
    if (dataMap.contains(NM_VPNC_KEY_DHGROUP)) {
        QString dhGroup = dataMap.value(NM_VPNC_KEY_DHGROUP);
        if (dhGroup == NM_VPNC_DHGROUP_DH1) {
            // DH Group 1
            d->ui.cboDHGroup->setCurrentIndex(VpncSettingWidgetPrivate::EnumDh::Dh1);
        } else if (dhGroup == NM_VPNC_DHGROUP_DH2) {
            // DH Group 2
            d->ui.cboDHGroup->setCurrentIndex(VpncSettingWidgetPrivate::EnumDh::Dh2);
        } else if (dhGroup == NM_VPNC_DHGROUP_DH5) {
            // DH Group 5
            d->ui.cboDHGroup->setCurrentIndex(VpncSettingWidgetPrivate::EnumDh::Dh5);
        }
    }

    // Perfect Forward Secrecy
    if (dataMap.contains(NM_VPNC_KEY_PERFECT_FORWARD)) {
        QString forwardSecrecy = dataMap.value(NM_VPNC_KEY_PERFECT_FORWARD);
        if (forwardSecrecy == QLatin1String("nopfs")) {
            d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::NoPfs);
        } else if (forwardSecrecy == QLatin1String("server")) {
            d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Server);
        } else if (forwardSecrecy == QLatin1String("dh1")) {
            d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Dh1);
        } else if (forwardSecrecy == QLatin1String("dh2")) {
            d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Dh2);
        } else if (forwardSecrecy == QLatin1String("dh5")) {
            d->ui.cboPerfectForwardSecrecy->setCurrentIndex(VpncSettingWidgetPrivate::EnumPerfectForwardSecrecy::Dh5);
        }
    }

    // Vendor
    if (dataMap.contains(NM_VPNC_KEY_VENDOR)) {
        QString vendor = dataMap.value(NM_VPNC_KEY_VENDOR);
        if (vendor == QLatin1String("cisco")) {
            d->ui.cboVendor->setCurrentIndex(VpncSettingWidgetPrivate::EnumVendor::Cisco);
        } else if (vendor == QLatin1String("netscreen")) {
            d->ui.cboVendor->setCurrentIndex(VpncSettingWidgetPrivate::EnumVendor::Netscreen);
        }
    }

    // Application Version
    if (dataMap.contains(NM_VPNC_KEY_APP_VERSION)) {
        d->ui.leApplicationVersion->setText(dataMap.value(NM_VPNC_KEY_APP_VERSION));
    }

    // Local Port
    if (dataMap.contains(NM_VPNC_KEY_LOCAL_PORT)) {
        d->ui.spbLocalPort->setValue(dataMap.value(NM_VPNC_KEY_LOCAL_PORT).toInt());
    }

    // Cisco UDP Encapsulation Port
    if (dataMap.contains(NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT)) {
        d->ui.spbCiscoUdpEncPort->setValue(dataMap.value(NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT).toInt());
    }
}