mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Added possibility to save and retrieve proxy passwords
This commit is contained in:
parent
13b3bc0409
commit
41dba7068a
|
@ -433,39 +433,61 @@ void NetworkManager::ftpAuthentication(const QUrl &url, QAuthenticator* auth)
|
||||||
|
|
||||||
void NetworkManager::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator* auth)
|
void NetworkManager::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator* auth)
|
||||||
{
|
{
|
||||||
QDialog* dialog = new QDialog();
|
QString userName = "";
|
||||||
dialog->setWindowTitle(tr("Proxy authorisation required"));
|
QString password = "";
|
||||||
|
QVector<PasswordEntry> psws = MainApplication::getInstance()->autoFill()->getFormData(QUrl(proxy.hostName()));
|
||||||
|
|
||||||
QFormLayout* formLa = new QFormLayout(dialog);
|
if(psws.isEmpty())
|
||||||
|
{
|
||||||
|
QDialog* dialog = new QDialog();
|
||||||
|
dialog->setWindowTitle(tr("Proxy authorisation required"));
|
||||||
|
|
||||||
QLabel* label = new QLabel(dialog);
|
QFormLayout* formLa = new QFormLayout(dialog);
|
||||||
QLabel* userLab = new QLabel(dialog);
|
|
||||||
QLabel* passLab = new QLabel(dialog);
|
|
||||||
userLab->setText(tr("Username: "));
|
|
||||||
passLab->setText(tr("Password: "));
|
|
||||||
|
|
||||||
QLineEdit* user = new QLineEdit(dialog);
|
QLabel* label = new QLabel(dialog);
|
||||||
QLineEdit* pass = new QLineEdit(dialog);
|
QLabel* userLab = new QLabel(dialog);
|
||||||
pass->setEchoMode(QLineEdit::Password);
|
QLabel* passLab = new QLabel(dialog);
|
||||||
|
userLab->setText(tr("Username: "));
|
||||||
|
passLab->setText(tr("Password: "));
|
||||||
|
|
||||||
QDialogButtonBox* box = new QDialogButtonBox(dialog);
|
QLineEdit* user = new QLineEdit(dialog);
|
||||||
box->addButton(QDialogButtonBox::Ok);
|
QLineEdit* pass = new QLineEdit(dialog);
|
||||||
box->addButton(QDialogButtonBox::Cancel);
|
pass->setEchoMode(QLineEdit::Password);
|
||||||
connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
|
|
||||||
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
|
|
||||||
|
|
||||||
label->setText(tr("A username and password are being requested by proxy %1. ").arg(proxy.hostName()));
|
QDialogButtonBox* box = new QDialogButtonBox(dialog);
|
||||||
formLa->addRow(label);
|
box->addButton(QDialogButtonBox::Ok);
|
||||||
formLa->addRow(userLab, user);
|
box->addButton(QDialogButtonBox::Cancel);
|
||||||
formLa->addRow(passLab, pass);
|
connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
|
||||||
formLa->addWidget(box);
|
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
|
||||||
|
|
||||||
if (dialog->exec() != QDialog::Accepted) {
|
QCheckBox *rememberCheck = new QCheckBox("Remember username and password for this proxy.", dialog);
|
||||||
return;
|
|
||||||
|
label->setText(tr("A username and password are being requested by proxy %1. ").arg(proxy.hostName()));
|
||||||
|
formLa->addRow(label);
|
||||||
|
formLa->addRow(userLab, user);
|
||||||
|
formLa->addRow(passLab, pass);
|
||||||
|
formLa->addRow(rememberCheck);
|
||||||
|
formLa->addWidget(box);
|
||||||
|
|
||||||
|
if (dialog->exec() != QDialog::Accepted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rememberCheck->isChecked()) {
|
||||||
|
MainApplication::getInstance()->autoFill()->addEntry(QUrl(proxy.hostName()), user->text(), pass->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
userName = user->text();
|
||||||
|
password = pass->text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userName = psws.at(0).username;
|
||||||
|
password = psws.at(0).password;
|
||||||
}
|
}
|
||||||
|
|
||||||
auth->setUser(user->text());
|
auth->setUser(userName);
|
||||||
auth->setPassword(pass->text());
|
auth->setPassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
|
QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user