[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:06:31 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=0608ebe
The following commit has been merged in the master branch:
commit 0608ebe8df5f169cafbe52d59af8e43b79dfb0d5
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Fri Mar 1 21:56:57 2013 +0000
Add a class that keeps the latest Tp::ContactPtr for a given contact ID even across reconnections
---
KTp/CMakeLists.txt | 2 ++
KTp/persistent-contact.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++
KTp/persistent-contact.h | 61 ++++++++++++++++++++++++++++++++++
3 files changed, 145 insertions(+)
diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index a8c86fa..4484255 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -22,6 +22,7 @@ set (ktp_common_internals_private_SRCS
message-filter-config-manager.cpp
message-processor.cpp
message-url-filter.cpp
+ persistent-contact.cpp
presence.cpp
service-availability-checker.cpp
telepathy-handler-application.cpp
@@ -47,6 +48,7 @@ set (ktp_common_internals_private_HDRS
message.h
message-context.h
message-processor.h
+ persistent-contact.h
presence.h
service-availability-checker.h
telepathy-handler-application.h
diff --git a/KTp/persistent-contact.cpp b/KTp/persistent-contact.cpp
new file mode 100644
index 0000000..763e9cf
--- /dev/null
+++ b/KTp/persistent-contact.cpp
@@ -0,0 +1,82 @@
+/*
+ Copyright (C) 2013 David Edmundson <davidedmundson at kde.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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "persistent-contact.h"
+
+#include <TelepathyQt/Account>
+#include <TelepathyQt/PendingContacts>
+#include <TelepathyQt/ContactManager>
+
+namespace KTp
+{
+class PersistentContact::Private
+{
+public:
+ QString contactId;
+ QString accountId;
+ KTp::ContactPtr contact;
+};
+}
+
+KTp::PersistentContact::PersistentContact(const QString &accountId, const QString contactId, KTp::GlobalContactManager *globalContactManager)
+ : QObject(globalContactManager)
+{
+ d->contactId = contactId;
+ d->accountId = accountId;
+
+ const Tp::AccountPtr account = globalContactManager->accountForAccountId(accountId);
+ if (account) {
+ connect(account.data(), SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onAccountConnectionChanged()));
+ onAccountConnectionChanged(account->connection());
+ }
+}
+
+QString KTp::PersistentContact::contactId() const
+{
+ return d->contactId;
+}
+
+QString KTp::PersistentContact::accountId() const
+{
+ return d->accountId;
+}
+
+KTp::ContactPtr KTp::PersistentContact::contact() const
+{
+ return d->contact;
+}
+
+
+void KTp::PersistentContact::onAccountConnectionChanged(const Tp::ConnectionPtr &connection)
+{
+ if (connection) {
+ Tp::ContactManagerPtr manager = connection->contactManager();
+ connect(manager->contactsForIdentifiers(QStringList() << d->contactId), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onPendingContactsFinished(Tp::PendingContacts*)));
+ }
+}
+
+void KTp::PersistentContact::onPendingContactsFinished(Tp::PendingContacts *op)
+{
+ Tp::PendingContacts* pendingContactsOp = qobject_cast<Tp::PendingContacts*>(op);
+ Q_ASSERT(pendingContactsOp);
+
+ if (pendingContactsOp->contacts().size() == 1) {
+ d->contact = KTp::ContactPtr::qObjectCast(pendingContactsOp->contacts()[0]);
+ Q_EMIT contactChanged(d->contact);
+ }
+}
diff --git a/KTp/persistent-contact.h b/KTp/persistent-contact.h
new file mode 100644
index 0000000..8fbfc4a
--- /dev/null
+++ b/KTp/persistent-contact.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2013 David Edmundson <davidedmundson at kde.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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef KTP_PERSISTENTCONTACT_H
+#define KTP_PERSISTENTCONTACT_H
+
+#include <QObject>
+
+#include "KTp/global-contact-manager.h"
+#include "KTp/contact.h"
+
+namespace KTp {
+
+/** Object monitors a specific account/contact identifier and will populate it with the most up-to-date contact as connections get destroyed/created
+ *
+ */
+class PersistentContact : public QObject
+{
+ Q_OBJECT
+public:
+ explicit PersistentContact(const QString &accountId, const QString contactId, KTp::GlobalContactManager *globalContactManager);
+
+ QString contactId() const;
+ QString accountId() const;
+
+ /** The contact object for these ID
+ @warning This may be null
+ */
+ KTp::ContactPtr contact() const;
+ Tp::AccountPtr account() const;
+
+Q_SIGNALS:
+ /** Signals that the contact object has been replaced*/
+ void contactChanged(KTp::ContactPtr);
+
+private Q_SLOTS:
+ void onAccountConnectionChanged(const Tp::ConnectionPtr &connection);
+ void onPendingContactsFinished(Tp::PendingContacts*);
+
+private:
+ class Private;
+ Private *d;
+};
+
+}
+#endif // PERSISTENTCONTACT_H
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list