VpnProxySection::VpnProxySection(NetworkManager::VpnSetting::Ptr vpnSetting, QFrame *parent)
    : AbstractSection(tr("VPN Proxy"), parent),
      m_vpnSetting(vpnSetting),
    m_proxyTypeChooser(new ComboBoxWidget(this)),
    m_server(new LineEditWidget(this)),
    m_port(new SpinBoxWidget(this)),
    m_retry(new SwitchWidget(this)),
    m_userName(new LineEditWidget(this)),
    m_password(new PasswdEditWidget(this))
{
    m_dataMap = vpnSetting->data();
    m_secretMap = vpnSetting->secrets();

    initStrMaps();
    initUI();
    initConnection();

    onProxyTypeChanged(m_currentProxyType);
}
예제 #2
0
void L2tpPPPWidget::loadConfig(const NetworkManager::VpnSetting::Ptr &setting)
{
    // General settings
    const NMStringMap dataMap = setting->data();

    // Authentication options
    const QString yesString = QLatin1String("yes");
    bool refuse_pap = (dataMap[NM_L2TP_KEY_REFUSE_PAP] == yesString);
    bool refuse_chap = (dataMap[NM_L2TP_KEY_REFUSE_CHAP] == yesString);
    bool refuse_mschap = (dataMap[NM_L2TP_KEY_REFUSE_MSCHAP] == yesString);
    bool refuse_mschapv2 = (dataMap[NM_L2TP_KEY_REFUSE_MSCHAPV2] == yesString);
    bool refuse_eap = (dataMap[NM_L2TP_KEY_REFUSE_EAP] == yesString);

    QListWidgetItem * item = 0;
    item = m_ui->listWidget->item(0); // PAP
    item->setCheckState(refuse_pap ? Qt::Unchecked : Qt::Checked);
    item = m_ui->listWidget->item(1); // CHAP
    item->setCheckState(refuse_chap ? Qt::Unchecked : Qt::Checked);
    item = m_ui->listWidget->item(2); // MSCHAP
    item->setCheckState(refuse_mschap ? Qt::Unchecked : Qt::Checked);
    item = m_ui->listWidget->item(3); // MSCHAPv2
    item->setCheckState(refuse_mschapv2 ? Qt::Unchecked : Qt::Checked);
    item = m_ui->listWidget->item(4); // EAP
    item->setCheckState(refuse_eap ? Qt::Unchecked : Qt::Checked);

    // Cryptography and compression
    const bool mppe = (dataMap[NM_L2TP_KEY_REQUIRE_MPPE] == yesString);
    const bool mppe40 = (dataMap[NM_L2TP_KEY_REQUIRE_MPPE_40] == yesString);
    const bool mppe128 = (dataMap[NM_L2TP_KEY_REQUIRE_MPPE_128] == yesString);
    const bool mppe_stateful = (dataMap[NM_L2TP_KEY_MPPE_STATEFUL] == yesString);

    if (mppe || mppe40 || mppe128) { // If MPPE is use
        m_ui->gbMPPE->setChecked(mppe || mppe40 || mppe128);
        if (mppe128) {
            m_ui->cbMPPECrypto->setCurrentIndex(1); // 128 bit
        } else if (mppe40) {
            m_ui->cbMPPECrypto->setCurrentIndex(2); // 40 bit
        } else {
            m_ui->cbMPPECrypto->setCurrentIndex(0); // Any
        }
        m_ui->cbstatefulEncryption->setChecked(mppe_stateful);
    }

    const bool nobsd = (dataMap[NM_L2TP_KEY_NOBSDCOMP] == yesString);
    m_ui->cbBSD->setChecked(!nobsd);

    const bool nodeflate = (dataMap[NM_L2TP_KEY_NODEFLATE] == yesString);
    m_ui->cbdeflate->setChecked(!nodeflate);

    const bool novjcomp = (dataMap[NM_L2TP_KEY_NO_VJ_COMP] == yesString);
    m_ui->cbTCPheaders->setChecked(!novjcomp);

    const bool nopcomp = (dataMap[NM_L2TP_KEY_NO_PCOMP] == yesString);
    m_ui->cbCompressionNegotiation->setChecked(!nopcomp);

    const bool noaccomp = (dataMap[NM_L2TP_KEY_NO_ACCOMP] == yesString);
    m_ui->cbAddressControlCompression->setChecked(!noaccomp);

    // Echo
    const int lcp_echo_interval = QString(dataMap[NM_L2TP_KEY_LCP_ECHO_INTERVAL]).toInt();
    m_ui->cbsendEcho->setChecked(lcp_echo_interval > 0);

    if (dataMap.contains(QLatin1String(NM_L2TP_KEY_MTU))) {
        m_ui->sbMTU->setValue(QString(dataMap[NM_L2TP_KEY_MTU]).toInt());
    }

    if (dataMap.contains(QLatin1String(NM_L2TP_KEY_MTU))) {
        m_ui->sbMRU->setValue(QString(dataMap[NM_L2TP_KEY_MRU]).toInt());
    }
}