diff --git a/GPClient/gpclient.cpp b/GPClient/gpclient.cpp index 6137eff9..486aaebb 100644 --- a/GPClient/gpclient.cpp +++ b/GPClient/gpclient.cpp @@ -62,6 +62,7 @@ void GPClient::onSettingsButtonClicked() { settingsDialog->setClientos(settings::get("clientos", "Linux").toString()); settingsDialog->setOsVersion(settings::get("os-version", QSysInfo::prettyProductName()).toString()); + settingsDialog->setSamlUserAgent(settings::get("samlUserAgent", "").toString()); settingsDialog->show(); } @@ -69,6 +70,7 @@ void GPClient::onSettingsAccepted() { settings::save("clientos", settingsDialog->clientos()); settings::save("os-version", settingsDialog->osVersion()); + settings::save("samlUserAgent", settingsDialog->samlUserAgent()); } void GPClient::on_connectButton_clicked() diff --git a/GPClient/gphelper.h b/GPClient/gphelper.h index 634f82ea..2efdfbba 100644 --- a/GPClient/gphelper.h +++ b/GPClient/gphelper.h @@ -31,7 +31,7 @@ namespace gpclient { namespace settings { extern QSettings *_settings; - static const QStringList reservedKeys {"extraArgs", "clientos"}; + static const QStringList reservedKeys {"extraArgs", "clientos", "samlUserAgent"}; QVariant get(const QString &key, const QVariant &defaultValue = QVariant()); QStringList get_all(const QString &key, const QVariant &defaultValue = QVariant()); diff --git a/GPClient/samlloginwindow.cpp b/GPClient/samlloginwindow.cpp index d7b8d161..b42a00d1 100644 --- a/GPClient/samlloginwindow.cpp +++ b/GPClient/samlloginwindow.cpp @@ -4,8 +4,11 @@ #include #include +#include "gphelper.h" #include "samlloginwindow.h" +using namespace gpclient::helper; + SAMLLoginWindow::SAMLLoginWindow(QWidget *parent) : QDialog(parent) , webView(new EnhancedWebView(this)) @@ -42,6 +45,9 @@ void SAMLLoginWindow::closeEvent(QCloseEvent *event) void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest, const QString preloginUrl) { webView->page()->profile()->cookieStore()->deleteSessionCookies(); + const QString& ua = settings::get("samlUserAgent", "").toString(); + if (!ua.isEmpty()) + webView->page()->profile()->setHttpUserAgent(ua); if (samlMethod == "POST") { webView->setHtml(samlRequest, preloginUrl); diff --git a/GPClient/settingsdialog.cpp b/GPClient/settingsdialog.cpp index 51e230fd..eca8a091 100644 --- a/GPClient/settingsdialog.cpp +++ b/GPClient/settingsdialog.cpp @@ -40,3 +40,11 @@ void SettingsDialog::setOsVersion(QString osVersion) { QString SettingsDialog::osVersion() { return ui->osVersionInput->text(); } + +void SettingsDialog::setSamlUserAgent(QString samlUserAgent) { + ui->samlUserAgentInput->setText(samlUserAgent); +} + +QString SettingsDialog::samlUserAgent() { + return ui->samlUserAgentInput->text(); +} \ No newline at end of file diff --git a/GPClient/settingsdialog.h b/GPClient/settingsdialog.h index ab2a607d..4bc45af4 100644 --- a/GPClient/settingsdialog.h +++ b/GPClient/settingsdialog.h @@ -24,6 +24,9 @@ class SettingsDialog : public QDialog void setOsVersion(QString osVersion); QString osVersion(); + void setSamlUserAgent(QString samlUserAgent); + QString samlUserAgent(); + private: Ui::SettingsDialog *ui; }; diff --git a/GPClient/settingsdialog.ui b/GPClient/settingsdialog.ui index ba277428..1246700c 100644 --- a/GPClient/settingsdialog.ui +++ b/GPClient/settingsdialog.ui @@ -7,7 +7,7 @@ 0 0 488 - 220 + 328 @@ -55,7 +55,17 @@ - + + + + os-version: + + + + + + + Qt::Horizontal @@ -65,13 +75,13 @@ - - + + - - + + - os-version: + saml-user-agent: