[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:58:47 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-auth-handler.git;a=commitdiff;h=3fc2555

The following commit has been merged in the master branch:
commit 3fc25555c6a12930233ae61b2687758690315881
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Aug 6 22:35:46 2012 +0100

    Updated to new WalletInterface
    
    REVIEW:105899
---
 sasl-auth-op.cpp                        | 23 ++++++++++++++++++-----
 sasl-auth-op.h                          |  6 ++++++
 x-messenger-oauth2-auth-operation.cpp   | 22 ++++++++++++----------
 x-messenger-oauth2-auth-operation.h     |  9 ++++++++-
 x-telepathy-password-auth-operation.cpp | 18 ++++++++++--------
 x-telepathy-password-auth-operation.h   |  4 ++++
 x-telepathy-password-prompt.cpp         |  8 ++++----
 x-telepathy-password-prompt.h           |  7 ++++++-
 8 files changed, 68 insertions(+), 29 deletions(-)

diff --git a/sasl-auth-op.cpp b/sasl-auth-op.cpp
index 09de944..b745234 100644
--- a/sasl-auth-op.cpp
+++ b/sasl-auth-op.cpp
@@ -27,17 +27,18 @@
 #include <KDebug>
 #include <KLocalizedString>
 
+#include <KTp/wallet-interface.h>
+#include <KTp/pending-wallet.h>
 
 SaslAuthOp::SaslAuthOp(const Tp::AccountPtr &account,
         const Tp::ChannelPtr &channel)
     : Tp::PendingOperation(channel),
+      m_walletInterface(0),
       m_account(account),
       m_channel(channel),
       m_saslIface(channel->interface<Tp::Client::ChannelInterfaceSASLAuthenticationInterface>())
 {
-    connect(m_saslIface->requestAllProperties(),
-            SIGNAL(finished(Tp::PendingOperation*)),
-            SLOT(gotProperties(Tp::PendingOperation*)));
+    connect(KTp::WalletInterface::openWallet(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onOpenWalletOperationFinished(Tp::PendingOperation*)));
 }
 
 SaslAuthOp::~SaslAuthOp()
@@ -61,7 +62,7 @@ void SaslAuthOp::gotProperties(Tp::PendingOperation *op)
     if (mechanisms.contains(QLatin1String("X-TELEPATHY-PASSWORD"))) {
         // everything ok, we can return from handleChannels now
         Q_EMIT ready(this);
-        XTelepathyPasswordAuthOperation *authop = new XTelepathyPasswordAuthOperation(m_account, m_saslIface, qdbus_cast<bool>(props.value(QLatin1String("CanTryAgain"))));
+        XTelepathyPasswordAuthOperation *authop = new XTelepathyPasswordAuthOperation(m_account, m_saslIface, m_walletInterface, qdbus_cast<bool>(props.value(QLatin1String("CanTryAgain"))));
         connect(authop,
                 SIGNAL(finished(Tp::PendingOperation*)),
                 SLOT(onAuthOperationFinished(Tp::PendingOperation*)));
@@ -72,7 +73,7 @@ void SaslAuthOp::gotProperties(Tp::PendingOperation *op)
     } else if (mechanisms.contains(QLatin1String("X-MESSENGER-OAUTH2"))) {
         // everything ok, we can return from handleChannels now
         Q_EMIT ready(this);
-        XMessengerOAuth2AuthOperation *authop = new XMessengerOAuth2AuthOperation(m_account, m_saslIface);
+        XMessengerOAuth2AuthOperation *authop = new XMessengerOAuth2AuthOperation(m_account, m_saslIface, m_walletInterface);
         connect(authop,
                 SIGNAL(finished(Tp::PendingOperation*)),
                 SLOT(onAuthOperationFinished(Tp::PendingOperation*)));
@@ -89,6 +90,18 @@ void SaslAuthOp::gotProperties(Tp::PendingOperation *op)
     }
 }
 
+void SaslAuthOp::onOpenWalletOperationFinished(Tp::PendingOperation *op)
+{
+    KTp::PendingWallet *walletOp = qobject_cast<KTp::PendingWallet*>(op);
+    Q_ASSERT(walletOp);
+
+    m_walletInterface = walletOp->walletInterface();
+
+    connect(m_saslIface->requestAllProperties(),
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(gotProperties(Tp::PendingOperation*)));
+}
+
 void SaslAuthOp::onAuthOperationFinished(Tp::PendingOperation *op)
 {
     m_channel->requestClose();
diff --git a/sasl-auth-op.h b/sasl-auth-op.h
index aed300d..5e02e65 100644
--- a/sasl-auth-op.h
+++ b/sasl-auth-op.h
@@ -27,6 +27,10 @@
 #include <TelepathyQt/PendingOperation>
 #include <TelepathyQt/Types>
 
+namespace KTp {
+    class WalletInterface;
+}
+
 class SaslAuthOp : public Tp::PendingOperation
 {
     Q_OBJECT
@@ -41,9 +45,11 @@ Q_SIGNALS:
 
 private Q_SLOTS:
     void gotProperties(Tp::PendingOperation *op);
+    void onOpenWalletOperationFinished(Tp::PendingOperation *op);
     void onAuthOperationFinished(Tp::PendingOperation *op);
 
 private:
+    KTp::WalletInterface *m_walletInterface;
     Tp::AccountPtr m_account;
     Tp::ChannelPtr m_channel;
     Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
diff --git a/x-messenger-oauth2-auth-operation.cpp b/x-messenger-oauth2-auth-operation.cpp
index 59c318d..e949729 100644
--- a/x-messenger-oauth2-auth-operation.cpp
+++ b/x-messenger-oauth2-auth-operation.cpp
@@ -29,16 +29,18 @@ const QLatin1String XMessengerOAuth2RefreshTokenWalletEntry("refresh_token");
 
 XMessengerOAuth2AuthOperation::XMessengerOAuth2AuthOperation(
         const Tp::AccountPtr &account,
-        Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface) :
+        Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
+        KTp::WalletInterface *walletInterface) :
     Tp::PendingOperation(account),
     m_account(account),
-    m_saslIface(saslIface)
+    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 (KTp::WalletInterface::hasEntry(m_account, QLatin1String("token"))) {
-        KTp::WalletInterface::removeEntry(m_account, QLatin1String("token"));
+    if (m_walletInterface->hasEntry(m_account, QLatin1String("token"))) {
+        m_walletInterface->removeEntry(m_account, QLatin1String("token"));
     }
 
     connect(m_saslIface,
@@ -55,9 +57,9 @@ void XMessengerOAuth2AuthOperation::onSASLStatusChanged(uint status, const QStri
 {
     switch (status) {
     case Tp::SASLStatusNotStarted :
-        if (KTp::WalletInterface::hasEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry)) {
+        if (m_walletInterface->hasEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry)) {
             m_saslIface->StartMechanismWithData(QLatin1String("X-MESSENGER-OAUTH2"),
-                                                QByteArray::fromBase64(KTp::WalletInterface::entry(m_account, XMessengerOAuth2AccessTokenWalletEntry).toLatin1()));
+                                                QByteArray::fromBase64(m_walletInterface->entry(m_account, XMessengerOAuth2AccessTokenWalletEntry).toLatin1()));
             return;
         }
 
@@ -87,7 +89,7 @@ void XMessengerOAuth2AuthOperation::onSASLStatusChanged(uint status, const QStri
     case Tp::SASLStatusServerFailed:
     {
         kDebug() << "Error authenticating - reason:" << reason << "- details:" << details;
-        if (KTp::WalletInterface::hasEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry)) {
+        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
@@ -96,7 +98,7 @@ void XMessengerOAuth2AuthOperation::onSASLStatusChanged(uint status, const QStri
             // 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.
-            KTp::WalletInterface::removeEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry);
+            m_walletInterface->removeEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry);
             Tp::Presence requestedPresence = m_account->requestedPresence();
             m_account->setRequestedPresence(requestedPresence);
         }
@@ -124,8 +126,8 @@ void XMessengerOAuth2AuthOperation::onDialogFinished(int result)
         return;
     case QDialog::Accepted:
         kDebug() << QLatin1String(m_dialog.data()->accessToken());
-        KTp::WalletInterface::setEntry(m_account, XMessengerOAuth2AccessTokenWalletEntry, QLatin1String(m_dialog.data()->accessToken().toBase64()));
-        KTp::WalletInterface::setEntry(m_account, XMessengerOAuth2RefreshTokenWalletEntry, QLatin1String(m_dialog.data()->refreshToken().toBase64()));
+        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();
diff --git a/x-messenger-oauth2-auth-operation.h b/x-messenger-oauth2-auth-operation.h
index d47a20f..d34ff38 100644
--- a/x-messenger-oauth2-auth-operation.h
+++ b/x-messenger-oauth2-auth-operation.h
@@ -25,6 +25,11 @@
 
 #include "x-messenger-oauth2-prompt.h"
 
+namespace KTp
+{
+    class WalletInterface;
+}
+
 class XMessengerOAuth2AuthOperation : public Tp::PendingOperation
 {
     Q_OBJECT
@@ -33,7 +38,8 @@ class XMessengerOAuth2AuthOperation : public Tp::PendingOperation
 public:
     explicit XMessengerOAuth2AuthOperation(
             const Tp::AccountPtr &account,
-            Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface);
+            Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
+            KTp::WalletInterface *walletInterface);
     ~XMessengerOAuth2AuthOperation();
 
 private Q_SLOTS:
@@ -43,6 +49,7 @@ private Q_SLOTS:
 private:
     Tp::AccountPtr m_account;
     Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
+    KTp::WalletInterface *m_walletInterface;
     QWeakPointer<XMessengerOAuth2Prompt> m_dialog;
 
     friend class SaslAuthOp;
diff --git a/x-telepathy-password-auth-operation.cpp b/x-telepathy-password-auth-operation.cpp
index 47fa630..e2c8826 100644
--- a/x-telepathy-password-auth-operation.cpp
+++ b/x-telepathy-password-auth-operation.cpp
@@ -30,10 +30,12 @@
 XTelepathyPasswordAuthOperation::XTelepathyPasswordAuthOperation(
         const Tp::AccountPtr &account,
         Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
+        KTp::WalletInterface *walletInterface,
         bool canTryAgain) :
     Tp::PendingOperation(account),
     m_account(account),
     m_saslIface(saslIface),
+    m_walletInterface(walletInterface),
     m_canTryAgain(canTryAgain)
 {
     connect(m_saslIface,
@@ -50,14 +52,14 @@ void XTelepathyPasswordAuthOperation::onSASLStatusChanged(uint status, const QSt
 {
     if (status == Tp::SASLStatusNotStarted) {
         kDebug() << "Requesting password";
-        promptUser(m_canTryAgain || !KTp::WalletInterface::hasEntry(m_account, QLatin1String("lastLoginFailed")));
+        promptUser(m_canTryAgain || !m_walletInterface->hasEntry(m_account, QLatin1String("lastLoginFailed")));
     } else if (status == Tp::SASLStatusServerSucceeded) {
         kDebug() << "Authentication handshake";
         m_saslIface->AcceptSASL();
     } else if (status == Tp::SASLStatusSucceeded) {
         kDebug() << "Authentication succeeded";
-        if (KTp::WalletInterface::hasEntry(m_account, QLatin1String("lastLoginFailed"))) {
-            KTp::WalletInterface::removeEntry(m_account, QLatin1String("lastLoginFailed"));
+        if (m_walletInterface->hasEntry(m_account, QLatin1String("lastLoginFailed"))) {
+            m_walletInterface->removeEntry(m_account, QLatin1String("lastLoginFailed"));
         }
         setFinished();
     } else if (status == Tp::SASLStatusInProgress) {
@@ -70,7 +72,7 @@ void XTelepathyPasswordAuthOperation::onSASLStatusChanged(uint status, const QSt
             promptUser(false);
         } else {
             kWarning() << "Authentication failed and cannot try again";
-            KTp::WalletInterface::setEntry(m_account, QLatin1String("lastLoginFailed"), QLatin1String("true"));
+            m_walletInterface->setEntry(m_account, QLatin1String("lastLoginFailed"), QLatin1String("true"));
             // We cannot try again, but we can request again to set the account
             // online. A new channel will be created, but since we set the
             // lastLoginFailed entry, next time we will prompt for password
@@ -86,11 +88,11 @@ void XTelepathyPasswordAuthOperation::onSASLStatusChanged(uint status, const QSt
 
 void XTelepathyPasswordAuthOperation::promptUser(bool isFirstRun)
 {
-    if (KTp::WalletInterface::hasPassword(m_account) && isFirstRun) {
+    if (m_walletInterface->hasPassword(m_account) && isFirstRun) {
         m_saslIface->StartMechanismWithData(QLatin1String("X-TELEPATHY-PASSWORD"),
-                                            KTp::WalletInterface::password(m_account).toUtf8());
+                                            m_walletInterface->password(m_account).toUtf8());
     } else {
-        m_dialog = new XTelepathyPasswordPrompt(m_account);
+        m_dialog = new XTelepathyPasswordPrompt(m_account, m_walletInterface);
         connect(m_dialog.data(),
                 SIGNAL(finished(int)),
                 SLOT(onDialogFinished(int)));
@@ -114,7 +116,7 @@ void XTelepathyPasswordAuthOperation::onDialogFinished(int result)
         if (!m_dialog.isNull()) {
             if (m_dialog.data()->savePassword()) {
                 kDebug() << "Saving password in wallet";
-                KTp::WalletInterface::setPassword(m_account, m_dialog.data()->password());
+                m_walletInterface->setPassword(m_account, m_dialog.data()->password());
             }
             m_saslIface->StartMechanismWithData(QLatin1String("X-TELEPATHY-PASSWORD"), m_dialog.data()->password().toUtf8());
             m_dialog.data()->deleteLater();
diff --git a/x-telepathy-password-auth-operation.h b/x-telepathy-password-auth-operation.h
index 4438823..cf05acd 100644
--- a/x-telepathy-password-auth-operation.h
+++ b/x-telepathy-password-auth-operation.h
@@ -24,6 +24,8 @@
 #include <TelepathyQt/Types>
 #include "x-telepathy-password-prompt.h"
 
+#include <KTp/wallet-interface.h>
+
 class XTelepathyPasswordAuthOperation : public Tp::PendingOperation
 {
     Q_OBJECT
@@ -33,6 +35,7 @@ public:
     explicit XTelepathyPasswordAuthOperation(
             const Tp::AccountPtr &account,
             Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
+            KTp::WalletInterface *walletInterface,
             bool canTryAgain);
     ~XTelepathyPasswordAuthOperation();
 
@@ -45,6 +48,7 @@ private:
 
     Tp::AccountPtr m_account;
     Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
+    KTp::WalletInterface *m_walletInterface;
     bool m_canTryAgain;
     QWeakPointer<XTelepathyPasswordPrompt> m_dialog;
 
diff --git a/x-telepathy-password-prompt.cpp b/x-telepathy-password-prompt.cpp
index c24079c..7f2be81 100644
--- a/x-telepathy-password-prompt.cpp
+++ b/x-telepathy-password-prompt.cpp
@@ -24,7 +24,7 @@
 #include <KIcon>
 #include <KDebug>
 
-XTelepathyPasswordPrompt::XTelepathyPasswordPrompt(const Tp::AccountPtr &account, QWidget *parent)
+XTelepathyPasswordPrompt::XTelepathyPasswordPrompt(const Tp::AccountPtr &account, KTp::WalletInterface *walletInterface, QWidget *parent)
     : KDialog(parent),
       ui(new Ui::XTelepathyPasswordPrompt)
 {
@@ -36,10 +36,10 @@ XTelepathyPasswordPrompt::XTelepathyPasswordPrompt(const Tp::AccountPtr &account
     ui->accountIcon->setPixmap(KIcon(QLatin1String("dialog-password")).pixmap(60, 60));
     ui->title->setPixmap(KIcon(account->iconName()).pixmap(22, 22));
 
-    if (KTp::WalletInterface::isOpen()) {
+    if (walletInterface->isOpen()) {
         ui->savePassword->setChecked(true);
-        if (KTp::WalletInterface::hasPassword(account)) {
-            ui->passwordLineEdit->setText(KTp::WalletInterface::password(account));
+        if (walletInterface->hasPassword(account)) {
+            ui->passwordLineEdit->setText(walletInterface->password(account));
         }
     } else {
         ui->savePassword->setDisabled(true);
diff --git a/x-telepathy-password-prompt.h b/x-telepathy-password-prompt.h
index 4200cc3..76d9993 100644
--- a/x-telepathy-password-prompt.h
+++ b/x-telepathy-password-prompt.h
@@ -28,12 +28,17 @@ namespace Ui
     class XTelepathyPasswordPrompt;
 }
 
+namespace KTp
+{
+    class WalletInterface;
+}
+
 class XTelepathyPasswordPrompt : public KDialog
 {
     Q_OBJECT
 
 public:
-    explicit XTelepathyPasswordPrompt(const Tp::AccountPtr &account, QWidget *parent = 0);
+    explicit XTelepathyPasswordPrompt(const Tp::AccountPtr &account, KTp::WalletInterface *walletInterface, QWidget *parent=0);
     ~XTelepathyPasswordPrompt();
 
     QString password() const;

-- 
ktp-auth-handler packaging



More information about the pkg-kde-commits mailing list