[SCM] ktp-auth-handler packaging branch, master, updated. debian/15.12.1-2-282-g080758e
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:59:40 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-auth-handler.git;a=commitdiff;h=5ad92cc
The following commit has been merged in the master branch:
commit 5ad92cc1feb66c89b7781af388db40a8a988eda2
Author: Martin Klapetek <mklapetek at kde.org>
Date: Fri Nov 14 13:28:09 2014 +0100
MSN Messenger has died, RIP
---
CMakeLists.txt | 4 -
conference-auth-op.cpp | 1 -
sasl-auth-op.cpp | 1 -
x-messenger-oauth2-auth-operation.cpp | 142 --------------------
x-messenger-oauth2-auth-operation.h | 59 ---------
x-messenger-oauth2-prompt.cpp | 237 ----------------------------------
x-messenger-oauth2-prompt.h | 64 ---------
7 files changed, 508 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 356ae54..a435636 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,8 +59,6 @@ set(ktp_auth_handler_SRCS
x-telepathy-password-prompt.cpp
x-telepathy-sso-facebook-operation.cpp
x-telepathy-sso-google-operation.cpp
- x-messenger-oauth2-auth-operation.cpp
- x-messenger-oauth2-prompt.cpp
conference-auth-op.cpp
conference-auth-observer.cpp
)
@@ -76,10 +74,8 @@ set(ktp_auth_handler_LIBS
KF5::I18n
KF5::KIOCore
KF5::KIOWidgets
- KF5::WebKit
Qt5::Core
Qt5::DBus
- Qt5::Network
)
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
diff --git a/conference-auth-op.cpp b/conference-auth-op.cpp
index e642a54..f8882cb 100644
--- a/conference-auth-op.cpp
+++ b/conference-auth-op.cpp
@@ -18,7 +18,6 @@
#include "conference-auth-op.h"
#include "x-telepathy-password-auth-operation.h"
-#include "x-messenger-oauth2-auth-operation.h"
#include <TelepathyQt/PendingVariantMap>
diff --git a/sasl-auth-op.cpp b/sasl-auth-op.cpp
index 1b251e0..bdd5927 100644
--- a/sasl-auth-op.cpp
+++ b/sasl-auth-op.cpp
@@ -21,7 +21,6 @@
#include "sasl-auth-op.h"
#include "x-telepathy-password-auth-operation.h"
-#include "x-messenger-oauth2-auth-operation.h"
#include "x-telepathy-sso-facebook-operation.h"
#include "x-telepathy-sso-google-operation.h"
diff --git a/x-messenger-oauth2-auth-operation.cpp b/x-messenger-oauth2-auth-operation.cpp
deleted file mode 100644
index 21de0b4..0000000
--- a/x-messenger-oauth2-auth-operation.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "x-messenger-oauth2-auth-operation.h"
-
-#include <QDebug>
-
-#include <KLocalizedString>
-#include <TelepathyQt/Account>
-#include <KTp/wallet-interface.h>
-
-const QLatin1String XMessengerOAuth2AccessTokenWalletEntry("access_token");
-const QLatin1String XMessengerOAuth2RefreshTokenWalletEntry("refresh_token");
-
-XMessengerOAuth2AuthOperation::XMessengerOAuth2AuthOperation(
- const Tp::AccountPtr &account,
- Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
- KTp::WalletInterface *walletInterface) :
- Tp::PendingOperation(account),
- m_account(account),
- m_saslIface(saslIface),
- m_walletInterface(walletInterface)
-{
- // NOTE Remove old "token" wallet entry
- // This entry was used in ktp 0.3, and it is now replaced by "access_token"
- // FIXME We might want to remove this in a later ktp version
- if (m_walletInterface->hasEntry(m_account, QLatin1String("token"))) {
- m_walletInterface->removeEntry(m_account, QLatin1String("token"));
- }
-
- connect(m_saslIface,
- SIGNAL(SASLStatusChanged(uint,QString,QVariantMap)),
- SLOT(onSASLStatusChanged(uint,QString,QVariantMap)));
-}
-
-XMessengerOAuth2AuthOperation::~XMessengerOAuth2AuthOperation()
-{
-}
-
-void XMessengerOAuth2AuthOperation::onSASLStatusChanged(uint status, const QString &reason,
- const QVariantMap &details)
-{
- switch (status) {
- case Tp::SASLStatusNotStarted :
- if (m_walletInterface->hasEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry)) {
- m_saslIface->StartMechanismWithData(QLatin1String("X-MESSENGER-OAUTH2"),
- QByteArray::fromBase64(m_walletInterface->entry(m_account, XMessengerOAuth2AccessTokenWalletEntry).toLatin1()));
- return;
- }
-
- qDebug() << "Requesting password";
- m_dialog = new XMessengerOAuth2Prompt();
-
- connect(m_dialog.data(),
- SIGNAL(finished(int)),
- SLOT(onDialogFinished(int)));
- // Show the dialog only when the login page is loaded
- connect(m_dialog.data(),
- SIGNAL(loginPageLoaded(bool)),
- m_dialog.data(),
- SLOT(show()));
- break;
- case Tp::SASLStatusServerSucceeded:
- qDebug() << "Authentication handshake";
- m_saslIface->AcceptSASL();
- break;
- case Tp::SASLStatusSucceeded:
- qDebug() << "Authentication succeeded";
- setFinished();
- break;
- case Tp::SASLStatusInProgress:
- qDebug() << "Authenticating...";
- break;
- case Tp::SASLStatusServerFailed:
- {
- qDebug() << "Error authenticating - reason:" << reason << "- details:" << details;
- if (m_walletInterface->hasEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry)) {
- // We cannot try again (TODO canTryAgain seems to be always false for
- // X-MESSENGER-OAUTH but we should insert a check here)
- // but we can remove the token and request again to set the account
- // online like we do for X-TELEPATHY-PASSWORD.
- // A new channel will be created, but since we deleted the token entry,
- // next time we will prompt for password and the user won't see any
- // difference except for an authentication error notification
- // TODO There should be a way to renew the token if it is expired.
- m_walletInterface->removeEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry);
- Tp::Presence requestedPresence = m_account->requestedPresence();
- m_account->setRequestedPresence(requestedPresence);
- }
- QString errorMessage = details[QLatin1String("server-message")].toString();
- setFinishedWithError(reason, errorMessage.isEmpty() ? i18n("Authentication error") : errorMessage);
- break;
- }
- default:
- qWarning() << "Unhandled status" << status;
- Q_ASSERT(false);
- break;
- }
-}
-
-void XMessengerOAuth2AuthOperation::onDialogFinished(int result)
-{
- switch (result) {
- case QDialog::Rejected:
- qDebug() << "Authentication cancelled";
- m_saslIface->AbortSASL(Tp::SASLAbortReasonUserAbort, i18n("User cancelled auth"));
- setFinished();
- if (!m_dialog.isNull()) {
- m_dialog.data()->deleteLater();
- }
- return;
- case QDialog::Accepted:
- qDebug() << QLatin1String(m_dialog.data()->accessToken());
- m_walletInterface->setEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry, QLatin1String(m_dialog.data()->accessToken().toBase64()));
- m_walletInterface->setEntry(m_account, XMessengerOAuth2RefreshTokenWalletEntry, QLatin1String(m_dialog.data()->refreshToken().toBase64()));
- m_saslIface->StartMechanismWithData(QLatin1String("X-MESSENGER-OAUTH2"), m_dialog.data()->accessToken());
- if (!m_dialog.isNull()) {
- m_dialog.data()->deleteLater();
- }
- return;
- default:
- Q_ASSERT(false);
- break;
- }
-}
-
-#include "x-messenger-oauth2-auth-operation.moc"
diff --git a/x-messenger-oauth2-auth-operation.h b/x-messenger-oauth2-auth-operation.h
deleted file mode 100644
index ac28daa..0000000
--- a/x-messenger-oauth2-auth-operation.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef X_MESSENGER_OAUTH2_AUTH_OPERATION_H
-#define X_MESSENGER_OAUTH2_AUTH_OPERATION_H
-
-#include <TelepathyQt/PendingOperation>
-#include <TelepathyQt/Channel>
-#include <TelepathyQt/Types>
-
-#include "x-messenger-oauth2-prompt.h"
-
-namespace KTp
-{
- class WalletInterface;
-}
-
-class XMessengerOAuth2AuthOperation : public Tp::PendingOperation
-{
- Q_OBJECT
- Q_DISABLE_COPY(XMessengerOAuth2AuthOperation)
-
-public:
- explicit XMessengerOAuth2AuthOperation(
- const Tp::AccountPtr &account,
- Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
- KTp::WalletInterface *walletInterface);
- ~XMessengerOAuth2AuthOperation();
-
-private Q_SLOTS:
- void onSASLStatusChanged(uint status, const QString &reason, const QVariantMap &details);
- void onDialogFinished(int result);
-
-private:
- Tp::AccountPtr m_account;
- Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
- KTp::WalletInterface *m_walletInterface;
- QPointer<XMessengerOAuth2Prompt> m_dialog;
-
- friend class SaslAuthOp;
-};
-
-
-#endif // X_MESSENGER_OAUTH2_AUTH_OPERATION_H
diff --git a/x-messenger-oauth2-prompt.cpp b/x-messenger-oauth2-prompt.cpp
deleted file mode 100644
index 13a2f2d..0000000
--- a/x-messenger-oauth2-prompt.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2011, 2012 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "x-messenger-oauth2-prompt.h"
-
-#include <KToolInvocation>
-#include <KWebView>
-#include <KWebPage>
-
-#include <QIcon>
-#include <QUrl>
-#include <QUrlQuery>
-#include <QDebug>
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QProgressBar>
-#include <QBoxLayout>
-#include <QLayout>
-#include <QDialogButtonBox>
-#include <QNetworkReply>
-
-#include <QWebSettings>
-#include <QWebFrame>
-
-const QLatin1String msnClientID("000000004C070A47");
-const QLatin1String scopes("wl.messenger wl.offline_access");
-const QLatin1String redirectUri("https://oauth.live.com/desktop");
-const QLatin1String tokenUri("https://oauth.live.com/token");
-
-const QLatin1String authorizeRequest("https://oauth.live.com/authorize?client_id=%1&scope=%2&response_type=code&redirect_uri=%3");
-const QLatin1String tokenRequest("https://oauth.live.com/token?client_id=%1&redirect_uri=%2&code=%3&grant_type=authorization_code");
-
-const QLatin1String codeParameter("code");
-const QLatin1String accessTokenParameter("access_token");
-const QLatin1String refreshTokenParameter("refresh_token");
-
-XMessengerOAuth2Prompt::XMessengerOAuth2Prompt(QWidget* parent) :
- QDialog(parent),
- m_webView(new KWebView()),
- m_ProgressBar(new QProgressBar()),
- m_loginPageLoaded(false)
-{
- // TODO Use .ui file
- m_webView->setContextMenuPolicy(Qt::NoContextMenu);
- m_webView->setAcceptDrops(false);
-// QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
- m_ProgressBar->setRange(0, 100);
-
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(m_webView);
- layout->addWidget(m_ProgressBar);
-
- QWidget *widget = new QWidget(this);
- widget->setLayout(layout);
- widget->setContentsMargins(0, 0, 0, 0);
-
- setWindowIcon(QIcon::fromTheme(QLatin1String("telepathy-kde")));
-
- QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
- connect(dbb, SIGNAL(rejected()), this, SIGNAL(rejected()));
-
- // connect progress bar
- connect(m_webView,
- SIGNAL(loadFinished(bool)),
- m_ProgressBar,
- SLOT(hide()));
- connect(m_webView,
- SIGNAL(loadStarted()),
- m_ProgressBar,
- SLOT(show()));
- connect(m_webView,
- SIGNAL(loadProgress(int)),
- m_ProgressBar,
- SLOT(setValue(int)));
-
- connect(m_webView,
- SIGNAL(urlChanged(QUrl)),
- SLOT(onUrlChanged(QUrl)));
- connect(m_webView,
- SIGNAL(loadFinished(bool)),
- SLOT(onLoadFinished(bool)));
-
- connect(m_webView,
- SIGNAL(linkClicked(QUrl)),
- SLOT(onLinkClicked(QUrl)));
-
- KWebPage *page = qobject_cast<KWebPage*>(m_webView->page());
-
- page->setLinkDelegationPolicy(QWebPage::DontDelegateLinks);
- page->setForwardUnsupportedContent(true);
-
- connect(page,
- SIGNAL(unsupportedContent(QNetworkReply*)),
- SLOT(onUnsupportedContent(QNetworkReply*)));
-
- // start loading the login URL
- QUrl url(QString(authorizeRequest).arg(msnClientID).arg(scopes).arg(redirectUri));
- m_webView->load(url);
-}
-
-XMessengerOAuth2Prompt::~XMessengerOAuth2Prompt()
-{
-}
-
-QByteArray XMessengerOAuth2Prompt::accessToken() const
-{
- return m_accessToken;
-}
-
-QByteArray XMessengerOAuth2Prompt::refreshToken() const
-{
- return m_refreshToken;
-}
-
-QSize XMessengerOAuth2Prompt::sizeHint() const
-{
- return QSize(500, 600);
-}
-
-void XMessengerOAuth2Prompt::onUrlChanged(const QUrl &url)
-{
- qDebug() << url;
- if (url.toString().indexOf(redirectUri) != 0) {
- // This is not the url containing the token
- return;
- }
- qDebug() << "This is the url we are waiting for";
- extractCode(url);
-}
-
-void XMessengerOAuth2Prompt::onLinkClicked(const QUrl& url)
-{
- qDebug() << url;
- KToolInvocation::invokeBrowser(url.toString());
-}
-
-void XMessengerOAuth2Prompt::onLoadFinished(bool ok)
-{
- if (!m_loginPageLoaded) {
- m_loginPageLoaded = true;
- Q_EMIT loginPageLoaded(ok);
- }
- if (m_webView->url().toString().indexOf(tokenUri) != 0) {
- // This is not the url containing the token
- return;
- }
- extractTokens(m_webView->page()->currentFrame()->toPlainText());
-
-}
-
-void XMessengerOAuth2Prompt::onUnsupportedContent(QNetworkReply* reply)
-{
- // With QtWebkit < 2.2, for some reason the request for the token is
- // unsupported, but we can extract the token from the url of the failing
- // request
- // FIXME: In the future this might want to remove this
- QUrl url = reply->url();
- qDebug() << url;
- if (url.toString().indexOf(redirectUri) != 0) {
- // This is not the url containing the token
- return;
- }
- extractCode(url);
-}
-
-void XMessengerOAuth2Prompt::extractCode(const QUrl &url)
-{
- qDebug() << url;
- QString code = QUrlQuery(url).queryItemValue(codeParameter);
-
- if (code.isEmpty()) {
- // Could not find the access token
- qWarning() << "Code not found";
- return;
- }
-
- qDebug() << "Code found:" << code;
-
- // start loading the login URL
- QUrl tokenUrl(QString(tokenRequest).arg(msnClientID).arg(redirectUri).arg(code));
- m_webView->load(tokenUrl);
-}
-
-
-void XMessengerOAuth2Prompt::extractTokens(const QString &text)
-{
- qDebug() << text;
-
- QJsonParseError error;
- QJsonDocument parser = QJsonDocument::fromJson(text.toUtf8(), &error);
- QVariantMap result = parser.object().toVariantMap();
-
- if (error.error == QJsonParseError::NoError) {
- qWarning() << "An error occured during parsing reply";
- return;
- }
-
- if (!result.contains(refreshTokenParameter)) {
- // Could not find the refresh token
- qWarning() << "Refresh token not found";
- return;
- }
-
- m_refreshToken = result[refreshTokenParameter].toByteArray();
- Q_EMIT refreshTokenTaken(m_refreshToken);
-
- if (!result.contains(accessTokenParameter)) {
- // Could not find the access token
- qWarning() << "Access token not found";
- return;
- }
-
- // Wocky will base64 encode, but token actually already is base64, so we
- // decode now and it will be re-encoded.
- m_accessToken = QByteArray::fromBase64(QByteArray::fromPercentEncoding(result[accessTokenParameter].toByteArray()));
- Q_EMIT accessTokenTaken(m_accessToken);
-
- accept();
-}
-
-#include "x-messenger-oauth2-prompt.moc"
diff --git a/x-messenger-oauth2-prompt.h b/x-messenger-oauth2-prompt.h
deleted file mode 100644
index 5e7d452..0000000
--- a/x-messenger-oauth2-prompt.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011, 2012 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef X_MESSENGER_OAUTH2_PROMPT_H
-#define X_MESSENGER_OAUTH2_PROMPT_H
-
-#include <QDialog>
-
-class KWebView;
-class QProgressBar;
-class QNetworkReply;
-
-class XMessengerOAuth2Prompt : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit XMessengerOAuth2Prompt(QWidget *parent = 0);
- ~XMessengerOAuth2Prompt();
-
- QByteArray accessToken() const;
- QByteArray refreshToken() const;
-
-protected:
- virtual QSize sizeHint() const;
-
-Q_SIGNALS:
- void loginPageLoaded(bool ok);
- void accessTokenTaken(const QByteArray &accessToken);
- void refreshTokenTaken(const QByteArray &refreshToken);
-
-private Q_SLOTS:
- void onUrlChanged(const QUrl &url);
- void onLinkClicked(const QUrl &url);
- void onLoadFinished(bool);
- void onUnsupportedContent(QNetworkReply* reply);
-
-private:
- void extractCode(const QUrl &url);
- void extractTokens(const QString &text);
-
- KWebView *m_webView;
- QProgressBar *m_ProgressBar;
- bool m_loginPageLoaded;
- QByteArray m_accessToken;
- QByteArray m_refreshToken;
-};
-
-#endif // X_MESSENGER_OAUTH2_PROMPT_H
--
ktp-auth-handler packaging
More information about the pkg-kde-commits
mailing list