diff options
author | Daniel Molkentin <danimo@owncloud.com> | 2013-11-07 21:47:38 +0400 |
---|---|---|
committer | Daniel Molkentin <danimo@owncloud.com> | 2013-11-07 21:47:38 +0400 |
commit | 60b6f520e7a468bb995b9fef918560b4fa143c05 (patch) | |
tree | 1119492b0a39efe82eb33c492f328968469bd225 /src/creds/shibboleth | |
parent | 8d0d5b407713ad3fb6794c7774f337b3b7ac9134 (diff) |
Make Shibboleth browser aware of Accounts
Needed for SSL error handling. It's also more consistent.
Diffstat (limited to 'src/creds/shibboleth')
-rw-r--r-- | src/creds/shibboleth/shibbolethwebview.cpp | 38 | ||||
-rw-r--r-- | src/creds/shibboleth/shibbolethwebview.h | 9 |
2 files changed, 34 insertions, 13 deletions
diff --git a/src/creds/shibboleth/shibbolethwebview.cpp b/src/creds/shibboleth/shibbolethwebview.cpp index d1eeb0e6a..be45c4dc1 100644 --- a/src/creds/shibboleth/shibbolethwebview.cpp +++ b/src/creds/shibboleth/shibbolethwebview.cpp @@ -16,17 +16,25 @@ #include <QNetworkCookie> #include <QWebFrame> #include <QWebPage> +#include <QMessageBox> #include "creds/shibboleth/shibbolethcookiejar.h" #include "creds/shibboleth/shibbolethwebview.h" +#include "mirall/account.h" #include "mirall/mirallaccessmanager.h" +#include "mirall/theme.h" namespace Mirall { -void ShibbolethWebView::setup(const QUrl& url, ShibbolethCookieJar* jar) +void ShibbolethWebView::setup(Account *account, ShibbolethCookieJar* jar) { MirallAccessManager* nm = new MirallAccessManager(this); + // we need our own QNAM, but the we offload the SSL error handling to + // the account object, which already can do this + connect(nm, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), + account, SLOT(slotHandleErrors(QNetworkReply*,QList<QSslError>))); + QWebPage* page = new QWebPage(this); jar->setParent(this); @@ -35,18 +43,19 @@ void ShibbolethWebView::setup(const QUrl& url, ShibbolethCookieJar* jar) connect(page, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(page, SIGNAL(loadFinished(bool)), - this, SLOT(slotLoadFinished())); + this, SLOT(slotLoadFinished(bool))); nm->setCookieJar(jar); page->setNetworkAccessManager(nm); - page->mainFrame ()->load (url); - this->setPage (page); + page->mainFrame()->load(account->url()); + this->setPage(page); + setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI())); } -ShibbolethWebView::ShibbolethWebView(const QUrl& url, QWidget* parent) +ShibbolethWebView::ShibbolethWebView(Account* account, QWidget* parent) : QWebView(parent) { - setup(url, new ShibbolethCookieJar(this)); + setup(account, new ShibbolethCookieJar(this)); } ShibbolethWebView::~ShibbolethWebView() @@ -54,10 +63,10 @@ ShibbolethWebView::~ShibbolethWebView() slotLoadFinished(); } -ShibbolethWebView::ShibbolethWebView(const QUrl& url, ShibbolethCookieJar* jar, QWidget* parent) +ShibbolethWebView::ShibbolethWebView(Account* account, ShibbolethCookieJar* jar, QWidget* parent) : QWebView(parent) { - setup(url, jar); + setup(account, jar); } void ShibbolethWebView::onNewCookiesForUrl (const QList<QNetworkCookie>& cookieList, const QUrl& url) @@ -96,9 +105,20 @@ void ShibbolethWebView::slotLoadStarted() QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); } -void ShibbolethWebView::slotLoadFinished() +void ShibbolethWebView::slotLoadFinished(bool success) { QApplication::restoreOverrideCursor(); + + if (!title().isNull()) { + setWindowTitle(tr("%1 - %2").arg(Theme::instance()->appNameGUI(), title())); + } + + if (!success) { + QMessageBox::critical(this, tr("Error loading IdP login page"), + tr("Could not load Shibboleth login page to log you in.\n" + "Please ensure that your network connection is working.")); + + } } } // ns Mirall diff --git a/src/creds/shibboleth/shibbolethwebview.h b/src/creds/shibboleth/shibbolethwebview.h index f0e43816d..ec574d80f 100644 --- a/src/creds/shibboleth/shibbolethwebview.h +++ b/src/creds/shibboleth/shibbolethwebview.h @@ -24,14 +24,15 @@ namespace Mirall { class ShibbolethCookieJar; +class Account; class ShibbolethWebView : public QWebView { Q_OBJECT public: - ShibbolethWebView(const QUrl& url, QWidget* parent = 0); - ShibbolethWebView(const QUrl& url, ShibbolethCookieJar* jar, QWidget* parent = 0); + ShibbolethWebView(Account *account, QWidget* parent = 0); + ShibbolethWebView(Account *account, ShibbolethCookieJar* jar, QWidget* parent = 0); ~ShibbolethWebView(); protected: @@ -45,10 +46,10 @@ Q_SIGNALS: private Q_SLOTS: void onNewCookiesForUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url); void slotLoadStarted(); - void slotLoadFinished(); + void slotLoadFinished(bool success = true); private: - void setup(const QUrl& url, ShibbolethCookieJar* jar); + void setup(Account *account, ShibbolethCookieJar* jar); }; } // ns Mirall |