[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:53 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-auth-handler.git;a=commitdiff;h=0ecb0a6
The following commit has been merged in the master branch:
commit 0ecb0a62cfa580a399e3928f13b04edcc42a6cc3
Author: Rohan Garg <rohangarg at kubuntu.org>
Date: Mon Dec 3 13:41:04 2012 +0530
Implement password protected room handling
REVIEW: 107089
---
CMakeLists.txt | 6 ++
KTp.ConfAuthObserver.client | 7 ++
conference-auth-observer.cpp | 83 +++++++++++++++
sasl-handler.h => conference-auth-observer.h | 39 +++----
conference-auth-op.cpp | 114 +++++++++++++++++++++
sasl-auth-op.h => conference-auth-op.h | 32 +++---
main.cpp | 9 ++
...elepathy.Client.KTp.ConfAuthObserver.service.in | 2 +-
8 files changed, 251 insertions(+), 41 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 09ffb1b..d8c9653 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,8 @@ set(ktp_auth_handler_SRCS
x-telepathy-password-prompt.cpp
x-messenger-oauth2-auth-operation.cpp
x-messenger-oauth2-prompt.cpp
+ conference-auth-op.cpp
+ conference-auth-observer.cpp
${ktp_common_internals_SRCS}
)
@@ -66,11 +68,15 @@ configure_file(org.freedesktop.Telepathy.Client.KTp.SASLHandler.service.in
#configure_file(org.freedesktop.Telepathy.Client.KTp.TLSHandler.service.in
# ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.TLSHandler.service)
+configure_file(org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver.service.in
+ ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver.service)
install(TARGETS ktp-auth-handler DESTINATION ${LIBEXEC_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.SASLHandler.service
+ ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver.service
DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.KTp.TLSHandler.service
# DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
install(FILES KTp.SASLHandler.client DESTINATION ${SHARE_INSTALL_PREFIX}/telepathy/clients/)
#install(FILES KTp.TLSHandler.client DESTINATION ${SHARE_INSTALL_PREFIX}/telepathy/clients/)
+install(FILES KTp.ConfAuthObserver.client DESTINATION ${SHARE_INSTALL_PREFIX}/telepathy/clients/)
diff --git a/KTp.ConfAuthObserver.client b/KTp.ConfAuthObserver.client
new file mode 100644
index 0000000..61a1196
--- /dev/null
+++ b/KTp.ConfAuthObserver.client
@@ -0,0 +1,7 @@
+[org.freedesktop.Telepathy.Client]
+Interfaces=org.freedesktop.Telepathy.Client.Observer;
+
+[org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 0]
+org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text
+org.freedesktop.Telepathy.Channel.TargetHandleType u=2
+
diff --git a/conference-auth-observer.cpp b/conference-auth-observer.cpp
new file mode 100644
index 0000000..b21add5
--- /dev/null
+++ b/conference-auth-observer.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.org>
+ *
+ * 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 "conference-auth-observer.h"
+
+#include "conference-auth-op.h"
+
+#include <KTp/telepathy-handler-application.h>
+
+#include <QDBusConnection>
+
+#include <TelepathyQt/Channel>
+#include <TelepathyQt/ChannelDispatchOperation>
+#include <TelepathyQt/MethodInvocationContext>
+
+#include <KDebug>
+
+ConferenceAuthObserver::ConferenceAuthObserver(const Tp::ChannelClassSpecList &channelFilter)
+ : Tp::AbstractClientObserver(channelFilter)
+{
+}
+
+ConferenceAuthObserver::~ConferenceAuthObserver()
+{
+}
+
+void ConferenceAuthObserver::observeChannels(const Tp::MethodInvocationContextPtr<> &context,
+ const Tp::AccountPtr &account,
+ const Tp::ConnectionPtr &connection,
+ const QList<Tp::ChannelPtr> &channels,
+ const Tp::ChannelDispatchOperationPtr &dispatchOperation,
+ const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
+ const Tp::AbstractClientObserver::ObserverInfo &observerInfo)
+{
+ Q_UNUSED(connection);
+ Q_UNUSED(requestsSatisfied);
+ Q_UNUSED(observerInfo);
+ Q_UNUSED(dispatchOperation)
+
+ Q_FOREACH (Tp::ChannelPtr channel, channels) {
+ if (!channel->hasInterface(TP_QT_IFACE_CHANNEL_INTERFACE_PASSWORD)) {
+ kDebug() << "Channel does not have password interface, exiting ...";
+ continue;
+ }
+
+ KTp::TelepathyHandlerApplication::newJob();
+ ConferenceAuthOp *auth = new ConferenceAuthOp(
+ account, channel);
+ connect(auth,
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onAuthFinished(Tp::PendingOperation*)));
+ }
+
+ context->setFinished();
+
+}
+
+void ConferenceAuthObserver::onAuthFinished(Tp::PendingOperation *op)
+{
+ if (op->isError()) {
+ kWarning() << "Error in conference room auth:" << op->errorName() << "-" << op->errorMessage();
+ }
+
+ KTp::TelepathyHandlerApplication::jobFinished();
+}
+
+#include "conference-auth-observer.moc"
diff --git a/sasl-handler.h b/conference-auth-observer.h
similarity index 52%
copy from sasl-handler.h
copy to conference-auth-observer.h
index 5e1e1fb..f4b7547 100644
--- a/sasl-handler.h
+++ b/conference-auth-observer.h
@@ -1,7 +1,5 @@
/*
- * Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
- * @author Andre Moreira Magalhaes <andre.magalhaes at collabora.co.uk>
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ * Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,44 +16,39 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef SASLHANDLER_H
-#define SASLHANDLER_H
+#ifndef CONFERENCEAUTHHANDLER_H
+#define CONFERENCEAUTHHANDLER_H
#include <QObject>
-#include <TelepathyQt/AbstractClientHandler>
+#include <TelepathyQt/AbstractClientObserver>
namespace Tp
{
class PendingOperation;
};
-class SaslAuthOp;
-
-class SaslHandler : public QObject, public Tp::AbstractClientHandler
+class ConferenceAuthObserver : public QObject, public Tp::AbstractClientObserver
{
Q_OBJECT
-
public:
- explicit SaslHandler();
- ~SaslHandler();
+ explicit ConferenceAuthObserver(const Tp::ChannelClassSpecList &channelFilter);
+ ~ConferenceAuthObserver();
- bool bypassApproval() const;
-
- void handleChannels(const Tp::MethodInvocationContextPtr<> &context,
- const Tp::AccountPtr &account,
- const Tp::ConnectionPtr &connection,
- const QList<Tp::ChannelPtr> &channels,
- const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
- const QDateTime &userActionTime,
- const Tp::AbstractClientHandler::HandlerInfo &handlerInfo);
+ void observeChannels(const Tp::MethodInvocationContextPtr<> &context,
+ const Tp::AccountPtr &account,
+ const Tp::ConnectionPtr &connection,
+ const QList<Tp::ChannelPtr> &channels,
+ const Tp::ChannelDispatchOperationPtr &dispatchOperation,
+ const QList<Tp::ChannelRequestPtr> &requestsSatisfied,
+ const Tp::AbstractClientObserver::ObserverInfo &observerInfo);
private Q_SLOTS:
- void onAuthReady(Tp::PendingOperation *op);
void onAuthFinished(Tp::PendingOperation *op);
private:
QHash<Tp::PendingOperation *, Tp::MethodInvocationContextPtr<> > mAuthContexts;
+
};
-#endif
+#endif // CONFERENCEAUTHHANDLER_H
diff --git a/conference-auth-op.cpp b/conference-auth-op.cpp
new file mode 100644
index 0000000..32c0161
--- /dev/null
+++ b/conference-auth-op.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.org>
+ *
+ * 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 "conference-auth-op.h"
+#include "x-telepathy-password-auth-operation.h"
+#include "x-messenger-oauth2-auth-operation.h"
+
+#include <TelepathyQt/PendingVariantMap>
+
+#include <KDebug>
+#include <KLocalizedString>
+#include <KPasswordDialog>
+
+#include <KTp/wallet-interface.h>
+#include <KTp/pending-wallet.h>
+
+ConferenceAuthOp::ConferenceAuthOp(const Tp::AccountPtr &account,
+ const Tp::ChannelPtr &channel)
+ : Tp::PendingOperation(channel),
+ m_walletInterface(0),
+ m_account(account),
+ m_channel(channel),
+ m_passwordIface(channel->interface<Tp::Client::ChannelInterfacePasswordInterface>())
+{
+ connect(KTp::WalletInterface::openWallet(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onOpenWalletOperationFinished(Tp::PendingOperation*)));
+}
+
+ConferenceAuthOp::~ConferenceAuthOp()
+{
+}
+
+void ConferenceAuthOp::onOpenWalletOperationFinished(Tp::PendingOperation *op)
+{
+ KTp::PendingWallet *walletOp = qobject_cast<KTp::PendingWallet*>(op);
+ Q_ASSERT(walletOp);
+
+ m_walletInterface = walletOp->walletInterface();
+
+ kDebug() << "Wallet is open :" << m_walletInterface->isOpen();
+
+ QDBusPendingReply<uint> reply = m_passwordIface->GetPasswordFlags();
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ SLOT(passwordFlagOperationFinished(QDBusPendingCallWatcher*)));
+
+}
+
+void ConferenceAuthOp::passwordFlagOperationFinished(QDBusPendingCallWatcher *watcher)
+{
+ QDBusPendingReply<uint> reply = *watcher;
+ if (reply.isError()) {
+ kWarning() << "Reply is a error. ABORT!";
+ return;
+ }
+
+
+ if (reply.argumentAt<0>() == Tp::ChannelPasswordFlagProvide) {
+ if (m_walletInterface->hasEntry(m_account, m_channel->targetId())) {
+ providePassword(m_walletInterface->entry(m_account, m_channel->targetId()));
+ } else {
+ passwordDialog();
+ }
+ }
+}
+
+void ConferenceAuthOp::providePassword(const QString &password)
+{
+ m_password = password;
+ QDBusPendingReply<bool> reply = m_passwordIface->ProvidePassword(m_password);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
+ connect (watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ SLOT(onPasswordProvided(QDBusPendingCallWatcher*)));
+}
+
+void ConferenceAuthOp::passwordDialog()
+{
+ KPasswordDialog *passwordDialog = new KPasswordDialog;
+ passwordDialog->setAttribute(Qt::WA_DeleteOnClose);
+ passwordDialog->setPrompt(i18n("Please provide a password for the chat room %1", m_channel->targetId()));
+ passwordDialog->show();
+
+ connect(passwordDialog, SIGNAL(gotPassword(QString,bool)),
+ SLOT(providePassword(QString)));
+
+}
+
+void ConferenceAuthOp::onPasswordProvided(QDBusPendingCallWatcher *watcher)
+{
+ QDBusPendingReply<bool> reply = *watcher;
+ if (reply.argumentAt<0>()) {
+ m_walletInterface->setEntry(m_account,m_channel->targetId(), m_password);
+ setFinished();
+ } else {
+ kDebug() << "Password was incorrect, enter again";
+ passwordDialog();
+ }
+}
+
+#include "conference-auth-op.moc"
diff --git a/sasl-auth-op.h b/conference-auth-op.h
similarity index 62%
copy from sasl-auth-op.h
copy to conference-auth-op.h
index 6e0e5ef..9017422 100644
--- a/sasl-auth-op.h
+++ b/conference-auth-op.h
@@ -1,7 +1,5 @@
/*
- * Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
- * @author Andre Moreira Magalhaes <andre.magalhaes at collabora.co.uk>
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ * Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,8 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef SASL_AUTH_OP_H
-#define SASL_AUTH_OP_H
+#ifndef CONFERENCEAUTHOP_H
+#define CONFERENCEAUTHOP_H
#include <TelepathyQt/Connection>
#include <TelepathyQt/PendingOperation>
@@ -29,28 +27,28 @@ namespace KTp {
class WalletInterface;
}
-class SaslAuthOp : public Tp::PendingOperation
+class ConferenceAuthOp : public Tp::PendingOperation
{
Q_OBJECT
-
public:
- SaslAuthOp(const Tp::AccountPtr &account,
- const Tp::ChannelPtr &channel);
- ~SaslAuthOp();
-
-Q_SIGNALS:
- void ready(Tp::PendingOperation *self);
+ ConferenceAuthOp(const Tp::AccountPtr &account,
+ const Tp::ChannelPtr &channel);
+ ~ConferenceAuthOp();
private Q_SLOTS:
- void gotProperties(Tp::PendingOperation *op);
void onOpenWalletOperationFinished(Tp::PendingOperation *op);
- void onAuthOperationFinished(Tp::PendingOperation *op);
+ void providePassword(const QString &password);
+ void passwordFlagOperationFinished(QDBusPendingCallWatcher* watcher);
+ void onPasswordProvided(QDBusPendingCallWatcher* watcher);
private:
KTp::WalletInterface *m_walletInterface;
Tp::AccountPtr m_account;
Tp::ChannelPtr m_channel;
- Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
+ Tp::Client::ChannelInterfacePasswordInterface *m_passwordIface;
+ QString m_password;
+ void passwordDialog();
+
};
-#endif // SASL_AUTH_OP_H
+#endif // CONFERENCEAUTHOP_H
diff --git a/main.cpp b/main.cpp
index 65d4172..3350658 100644
--- a/main.cpp
+++ b/main.cpp
@@ -34,6 +34,7 @@
#include "sasl-handler.h"
#include "tls-handler.h"
+#include "conference-auth-observer.h"
#include "version.h"
#include <KTp/telepathy-handler-application.h>
@@ -75,6 +76,14 @@ int main(int argc, char *argv[])
handlers -= 1;
}
+ Tp::ChannelClassSpecList confAuthFilter = Tp::ChannelClassSpecList() << Tp::ChannelClassSpec::textChatroom();
+ Tp::SharedPtr<ConferenceAuthObserver> confAuthObserver = Tp::SharedPtr<ConferenceAuthObserver>(new ConferenceAuthObserver(confAuthFilter));
+ if (!clientRegistrar->registerClient(
+ Tp::AbstractClientPtr(confAuthObserver), QLatin1String("KTp.ConfAuthObserver"))) {
+ kWarning() << "Could not register the room auth observer!";
+ }
+
+
#if 0
Tp::SharedPtr<TlsHandler> tlsHandler = Tp::SharedPtr<TlsHandler>(new TlsHandler);
if (!clientRegistrar->registerClient(
diff --git a/org.freedesktop.Telepathy.Client.KTp.SASLHandler.service.in b/org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver.service.in
similarity index 50%
copy from org.freedesktop.Telepathy.Client.KTp.SASLHandler.service.in
copy to org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver.service.in
index fa3bbc3..170d54a 100644
--- a/org.freedesktop.Telepathy.Client.KTp.SASLHandler.service.in
+++ b/org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver.service.in
@@ -1,3 +1,3 @@
[D-BUS Service]
-Name=org.freedesktop.Telepathy.Client.KTp.SASLHandler
+Name=org.freedesktop.Telepathy.Client.KTp.ConfAuthObserver
Exec=@LIBEXEC_INSTALL_DIR@/ktp-auth-handler
--
ktp-auth-handler packaging
More information about the pkg-kde-commits
mailing list