Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 802-1x 可以修改 identity 字段 #315

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion dnetwork-secret-dialog/networkdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,32 @@ bool NetworkDialog::exec(const QJsonDocument &doc)
device = array.first().toString();
}
QString connName = obj.value("connId").toString();
if (!connName.isEmpty() && (1 == obj.value("secrets").toArray().size())) {
QJsonObject propsObj = obj.value("props").toObject();
QString password;
static const char* identity = "identity";
bool needIdentity = false;
int count = 0;
for (auto secret : obj.value("secrets").toArray()) {
const QString& key = secret.toString();
if (key == identity) {
needIdentity = true;
continue;
}
count++;
if (propsObj.contains(key)) {
password = propsObj.value(key).toString();
}
}
if (!connName.isEmpty() && 1 == count) {
m_key = connName;
QJsonObject json;
json.insert("dev", device);
json.insert("ssid", m_key);
json.insert("wait", true);
if (needIdentity) {
json.insert(identity, propsObj.value(identity).toString());
}
json.insert("password", password);
QJsonDocument doc;
doc.setObject(json);
m_data = "\nconnect:" + doc.toJson(QJsonDocument::Compact) + "\n";
Expand Down
19 changes: 16 additions & 3 deletions dnetwork-secret-dialog/networksecretdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ NetworkSecretDialog::NetworkSecretDialog(QJsonDocument jsonDoc, QWidget *parent)
{ "IPSec secret", tr("Password") },
{ "Xauth password", tr("Group Password") },
})
, m_propMap({ { "identity", tr("Username") }, })
{
m_allInputValid = false;

Expand All @@ -67,6 +68,7 @@ void NetworkSecretDialog::parseJsonData(const QJsonDocument &jsonDoc)
m_connName = m_jsonObj.value("connId").toString();
m_connType = m_jsonObj.value("connType").toString();
m_connSettingName = m_jsonObj.value("settingName").toString();
m_propsObj = m_jsonObj.value("props").toObject();
for (auto secret : m_jsonObj.value("secrets").toArray()) {
m_secretKeyList.append(secret.toString());
}
Expand Down Expand Up @@ -107,11 +109,22 @@ void NetworkSecretDialog::initUI()

for (int row = 0; row < m_secretKeyList.size(); ++row) {
const QString &secret = m_secretKeyList.at(row);
DPasswordEdit *lineEdit = new DPasswordEdit();

DLineEdit *lineEdit;
QString label;
if (m_propMap.contains(secret)) {
lineEdit = new DLineEdit();
label = m_propMap.value(secret);
} else {
lineEdit = new DPasswordEdit();
label = m_secretKeyStrMap.value(secret);
}
if (m_propsObj.contains(secret))
lineEdit->setText(m_propsObj.value(secret).toString());
lineEdit->setClearButtonEnabled(true);
lineEdit->setCopyEnabled(false);
lineEdit->setCutEnabled(false);
gridLayout->addWidget(new QLabel(m_secretKeyStrMap.value(secret) + ":"), row, 0);
gridLayout->addWidget(new QLabel(label + ":"), row, 0);
gridLayout->addWidget(lineEdit, row, 1);
m_lineEditList.append(lineEdit);

Expand Down Expand Up @@ -168,7 +181,7 @@ void NetworkSecretDialog::checkInputValid()

m_lineEditList.at(0)->hideAlertMessage();
for (int i = 0; i < m_secretKeyList.size(); ++i) {
DPasswordEdit * const lineEdit = m_lineEditList.at(i);
DLineEdit * const lineEdit = m_lineEditList.at(i);
if (!passwordIsValid(lineEdit->text(), m_secretKeyList.at(i))) {
allValid = false;
lineEdit->setAlert(true);
Expand Down
4 changes: 3 additions & 1 deletion dnetwork-secret-dialog/networksecretdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ private slots:
private:
QJsonObject m_jsonObj;
const QMap<QString, QString> m_secretKeyStrMap;
const QMap<QString, QString> m_propMap;
QString m_connName;
QString m_connType;
QString m_connSettingName;
QStringList m_secretKeyList;
QJsonObject m_propsObj;

QList<Dtk::Widget::DPasswordEdit *> m_lineEditList;
QList<Dtk::Widget::DLineEdit *> m_lineEditList;

bool m_allInputValid;
};
Expand Down