[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:07:57 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=9b73801

The following commit has been merged in the master branch:
commit 9b73801aa57fb43c612df0e1268b31d1e01a5890
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Tue Dec 24 00:32:08 2013 +0100

    Set accountUniqueIdentifier on contacts
    
    Tp::Connection has no method to get the holding Tp::AccountPtr
    
    This makes it difficult to work out which account a contact belongs to.
    This can't be fixed in TpQt in 0.9.x
    
    Instead create a KTp::Account which sets a property on connection
    whenever the connection chanages.
    
    This is exposed from KTp::Contact
    
    REVIEW: 114643
---
 KTp/CMakeLists.txt      |  1 +
 KTp/account-factory.cpp | 57 +++++++++++++++++++++++++++++++++++++
 KTp/account-factory_p.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
 KTp/contact.cpp         |  7 +++++
 KTp/contact.h           |  4 +++
 KTp/core.cpp            |  3 +-
 6 files changed, 145 insertions(+), 1 deletion(-)

diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index 29ee1ab..e427a2e 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -4,6 +4,7 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}
 set (ktp_common_internals_private_SRCS
      ${KTP_GLOBAL_SOURCES}
      abstract-message-filter.cpp
+     account-factory.cpp
      actions.cpp
      capabilities-hack-private.cpp
      contact-info-dialog.cpp
diff --git a/KTp/account-factory.cpp b/KTp/account-factory.cpp
new file mode 100644
index 0000000..bc1008f
--- /dev/null
+++ b/KTp/account-factory.cpp
@@ -0,0 +1,57 @@
+/*
+* Copyright (C) 2013 David Edmundson <kde at davidedmundson.co.uk>
+*
+* 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 "account-factory_p.h"
+
+KTp::AccountFactory::AccountFactory(const QDBusConnection &bus, const Tp::Features &features):
+    Tp::AccountFactory::AccountFactory(bus, features)
+{
+}
+
+Tp::AccountFactoryPtr KTp::AccountFactory::create(const QDBusConnection &bus, const Tp::Features &features) {
+    return Tp::AccountFactoryPtr(new KTp::AccountFactory(bus, features));
+}
+
+Tp::AccountPtr KTp::AccountFactory::construct(const QString &busName, const QString &objectPath, const Tp::ConnectionFactoryConstPtr &connFactory, const Tp::ChannelFactoryConstPtr &chanFactory, const Tp::ContactFactoryConstPtr &contactFactory) const
+{
+    return KTp::Account::create(QDBusConnection::sessionBus(), busName, objectPath, connFactory, chanFactory, contactFactory);
+}
+
+
+
+//account
+
+
+
+Tp::AccountPtr KTp::Account::create(const QDBusConnection &bus, const QString &busName, const QString &objectPath, const Tp::ConnectionFactoryConstPtr &connectionFactory, const Tp::ChannelFactoryConstPtr &channelFactory, const Tp::ContactFactoryConstPtr &contactFactory)
+{
+    return Tp::AccountPtr(new KTp::Account(bus, busName, objectPath, connectionFactory, channelFactory, contactFactory, Tp::Account::FeatureCore));
+}
+
+KTp::Account::Account(const QDBusConnection &bus, const QString &busName, const QString &objectPath, const Tp::ConnectionFactoryConstPtr &connectionFactory, const Tp::ChannelFactoryConstPtr &channelFactory, const Tp::ContactFactoryConstPtr &contactFactory, const Tp::Feature &coreFeature):
+    Tp::Account(bus, busName, objectPath, connectionFactory, channelFactory, contactFactory, coreFeature)
+{
+    connect(this, SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onConnectionChanged(Tp::ConnectionPtr)));
+}
+
+void KTp::Account::onConnectionChanged(const Tp::ConnectionPtr &connection)
+{
+    if (connection) {
+        connection->setProperty("accountUID", uniqueIdentifier());
+    }
+}
diff --git a/KTp/account-factory_p.h b/KTp/account-factory_p.h
new file mode 100644
index 0000000..479fc99
--- /dev/null
+++ b/KTp/account-factory_p.h
@@ -0,0 +1,74 @@
+/*
+* Copyright (C) 2013 David Edmundson <kde at davidedmundson.co.uk>
+*
+* 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 KTP_ACCOUNT_FACTORY_H
+#define KTP_ACCOUNT_FACTORY_H
+
+#include <TelepathyQt/AccountFactory>
+#include <TelepathyQt/Account>
+
+#include <TelepathyQt/Types>
+
+#include <KTp/ktp-export.h>
+
+/*
+ * This class is part of a hack that fixes the following problem:
+ *  Connection has no way to access the account that owns it
+ *  This means contacts have no way to know where they are from
+ *  For KPeople (and in other cases) we need the account UID from a contact
+ *
+ *
+ * This class subclasses account and sets a property Connection whenever it is
+ * created.
+ */
+
+namespace KTp {
+class AccountFactory : public Tp::AccountFactory
+{
+public:
+    static Tp::AccountFactoryPtr create(const QDBusConnection &bus, const Tp::Features &features=Tp::Features());
+protected:
+    AccountFactory(const QDBusConnection& bus, const Tp::Features& features);
+    virtual Tp::AccountPtr construct(const QString& busName,
+                                     const QString& objectPath,
+                                     const Tp::ConnectionFactoryConstPtr& connFactory,
+                                     const Tp::ChannelFactoryConstPtr& chanFactory,
+                                     const Tp::ContactFactoryConstPtr& contactFactory) const;
+};
+
+class Account: public Tp::Account
+{
+    Q_OBJECT
+public:
+    static Tp::AccountPtr create (const QDBusConnection &bus, const QString &busName, const QString &objectPath, const Tp::ConnectionFactoryConstPtr &connectionFactory, const Tp::ChannelFactoryConstPtr &channelFactory, const Tp::ContactFactoryConstPtr &contactFactory=Tp::ContactFactory::create());
+protected:
+    Account (const QDBusConnection &bus,
+             const QString &busName,
+             const QString &objectPath,
+             const Tp::ConnectionFactoryConstPtr &connectionFactory,
+             const Tp::ChannelFactoryConstPtr &channelFactory,
+             const Tp::ContactFactoryConstPtr &contactFactory,
+             const Tp::Feature &coreFeature);
+
+private Q_SLOTS:
+    void onConnectionChanged(const Tp::ConnectionPtr &connection);
+};
+}
+
+
+#endif // CONTACTFACTORY_H
diff --git a/KTp/contact.cpp b/KTp/contact.cpp
index 52a4f58..8e00589 100644
--- a/KTp/contact.cpp
+++ b/KTp/contact.cpp
@@ -37,12 +37,19 @@
 KTp::Contact::Contact(Tp::ContactManager *manager, const Tp::ReferencedHandles &handle, const Tp::Features &requestedFeatures, const QVariantMap &attributes)
     : Tp::Contact(manager, handle, requestedFeatures, attributes)
 {
+    m_accountUniqueIdentifier = manager->connection()->property("accountUID").toString();
+
     connect(manager->connection().data(), SIGNAL(destroyed()), SIGNAL(invalidated()));
     connect(manager->connection().data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)), SIGNAL(invalidated()));
     connect(this, SIGNAL(avatarTokenChanged(QString)), SLOT(invalidateAvatarCache()));
     connect(this, SIGNAL(avatarDataChanged(Tp::AvatarData)), SLOT(invalidateAvatarCache()));
 }
 
+QString KTp::Contact::accountUniqueIdentifier() const
+{
+    return m_accountUniqueIdentifier;
+}
+
 KTp::Presence KTp::Contact::presence() const
 {
     return KTp::Presence(Tp::Contact::presence());
diff --git a/KTp/contact.h b/KTp/contact.h
index f33a762..053d082 100644
--- a/KTp/contact.h
+++ b/KTp/contact.h
@@ -56,6 +56,8 @@ public:
     /** Returns the pixmap of an avatar desaturated to gray if contact is offline*/
     QPixmap avatarPixmap();
 
+    QString accountUniqueIdentifier() const;
+
 Q_SIGNALS:
     void invalidated();
 
@@ -68,6 +70,8 @@ private:
     QString keyCache() const;
     QString buildAvatarPath(const QString &avatarToken);
 
+    QString m_accountUniqueIdentifier;
+
 };
 
 
diff --git a/KTp/core.cpp b/KTp/core.cpp
index a221e68..1cb1081 100644
--- a/KTp/core.cpp
+++ b/KTp/core.cpp
@@ -30,6 +30,7 @@
 #include <TelepathyQt/AccountManager>
 #include <KTp/global-contact-manager.h>
 #include "contact-factory.h"
+#include "account-factory_p.h"
 
 class CorePrivate
 {
@@ -54,7 +55,7 @@ CorePrivate::CorePrivate()
     m_kPeopleEnabled = true;
     #endif
 
-    m_accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
+    m_accountFactory = KTp::AccountFactory::create(QDBusConnection::sessionBus(),
                                                                     Tp::Features() << Tp::Account::FeatureCore
                                                                                    << Tp::Account::FeatureProfile);
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list