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


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

The following commit has been merged in the master branch:
commit 7d5aab343a86569d8e305836a5604198ff34554a
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Apr 15 01:30:04 2013 +0100

    Create a class that manages all Tp::AccountManager
    
    This also handles Tp Actions and Tp::ClientRegistrar
    This simplifies all our DeclarativeCode into something sharable and more flexible
    
    REVIEW: 110020
---
 KTp/Declarative/CMakeLists.txt              |   5 +-
 KTp/Declarative/contact-list.cpp            |  93 -----------------
 KTp/Declarative/contact-list.h              |  50 ---------
 KTp/Declarative/conversations-model.h       |   2 +-
 KTp/Declarative/declarative-ktp-actions.cpp |  55 ----------
 KTp/Declarative/declarative-ktp-actions.h   |  56 -----------
 KTp/Declarative/messages-model.cpp          |   2 +-
 KTp/Declarative/qml-plugins.cpp             |  27 ++---
 KTp/Declarative/qml-plugins.h               |   1 +
 KTp/Declarative/telepathy-manager.cpp       | 151 ++++++++++++++++++++++++++++
 KTp/Declarative/telepathy-manager.h         | 138 +++++++++++++++++++++++++
 KTp/Declarative/telepathy-text-observer.cpp |  89 ----------------
 KTp/Declarative/telepathy-text-observer.h   |  48 ---------
 KTp/Models/contacts-filter-model.cpp        |   6 +-
 KTp/Models/contacts-model.h                 |   2 +-
 tests/CMakeLists.txt                        |  22 ----
 tests/pinned-contacts-model-view-main.cpp   |  68 -------------
 17 files changed, 312 insertions(+), 503 deletions(-)

diff --git a/KTp/Declarative/CMakeLists.txt b/KTp/Declarative/CMakeLists.txt
index ebe4c19..7208fd2 100644
--- a/KTp/Declarative/CMakeLists.txt
+++ b/KTp/Declarative/CMakeLists.txt
@@ -5,18 +5,15 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}
 
 set (ktp_qml_plugin_SRCS
     ${KTP_GLOBAL_SOURCES}
-    contact-list.cpp
     conversation-target.cpp
     conversation.cpp
     conversations-model.cpp
     hide-window-component.cpp
     messages-model.cpp
-    telepathy-text-observer.cpp
     pinned-contacts-model.cpp
     filtered-pinned-contacts-proxy-model.cpp
     contact-pin.cpp
-    declarative-ktp-actions.cpp
-
+    telepathy-manager.cpp
     qml-plugins.cpp
 )
 
diff --git a/KTp/Declarative/contact-list.cpp b/KTp/Declarative/contact-list.cpp
deleted file mode 100644
index d469f2c..0000000
--- a/KTp/Declarative/contact-list.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-    Copyright (C) 2011  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 Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#include "contact-list.h"
-
-#include <TelepathyQt/AccountFactory>
-#include <TelepathyQt/ConnectionFactory>
-#include <TelepathyQt/AccountManager>
-#include <TelepathyQt/PendingReady>
-#include <TelepathyQt/PendingChannelRequest>
-
-#include <KDebug>
-
-#include <KTp/contact-factory.h>
-
-#include <KTp/actions.h>
-#include <Models/contacts-model.h>
-#include <Models/contacts-list-model.h>
-
-ContactList::ContactList(QObject *parent)
-    : QObject(parent),
-      m_filterModel(new KTp::ContactsModel(this))
-{
-    Tp::registerTypes();
-
-    // Start setting up the Telepathy AccountManager.
-    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
-                                                                       Tp::Features() << Tp::Account::FeatureCore
-                                                                       << Tp::Account::FeatureAvatar
-                                                                       << Tp::Account::FeatureCapabilities
-                                                                       << Tp::Account::FeatureProtocolInfo
-                                                                       << Tp::Account::FeatureProfile);
-
-    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
-                                                                               Tp::Features() << Tp::Connection::FeatureCore
-                                                                               << Tp::Connection::FeatureRosterGroups
-                                                                               << Tp::Connection::FeatureRoster
-                                                                               << Tp::Connection::FeatureSelfContact);
-
-    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
-                                                                      << Tp::Contact::FeatureAvatarData
-                                                                      << Tp::Contact::FeatureSimplePresence
-                                                                      << Tp::Contact::FeatureCapabilities);
-
-
-
-    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
-
-    Tp::AccountManagerPtr accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus(),
-                                                  accountFactory,
-                                                  connectionFactory,
-                                                  channelFactory,
-                                                  contactFactory);
-
-    m_filterModel->setAccountManager(accountManager);
-}
-
-KTp::ContactsModel* ContactList::filterModel() const
-{
-    return m_filterModel;
-}
-
-void ContactList::startChat(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
-{
-    kDebug() << "Requesting chat for contact" << contact->alias();
-    kDebug() << "account is" << account->normalizedName();
-
-    Tp::PendingOperation *op = KTp::Actions::startChat(account, contact, false);
-    connect(op, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onGenericOperationFinished(Tp::PendingOperation*)));
-}
-
-void ContactList::onGenericOperationFinished(Tp::PendingOperation *op)
-{
-    if (op->isError()) {
-        kDebug() << op->errorName();
-        kDebug() << op->errorMessage();
-    }
-}
diff --git a/KTp/Declarative/contact-list.h b/KTp/Declarative/contact-list.h
deleted file mode 100644
index ff8fc1b..0000000
--- a/KTp/Declarative/contact-list.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-    Copyright (C) 2011  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 Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef CONTACT_LIST_H
-#define CONTACT_LIST_H
-
-#include <KTp/contact.h>
-
-#include <TelepathyQt/Types>
-
-namespace KTp {
-class ContactsModel;
-}
-
-/** Exposes general contact list stuff to QML*/
-class ContactList : public QObject
-{
-    Q_OBJECT
-    Q_PROPERTY(KTp::ContactsModel* model READ filterModel CONSTANT)
-
-  public:
-    ContactList(QObject *parent=0);
-    KTp::ContactsModel* filterModel() const;
-
-  public Q_SLOTS:
-    void startChat(const Tp::AccountPtr &account, const KTp::ContactPtr &contact);
-
-  private Q_SLOTS:
-    void onGenericOperationFinished(Tp::PendingOperation *op);
-
-  private:
-    KTp::ContactsModel* m_filterModel;
-};
-
-#endif
diff --git a/KTp/Declarative/conversations-model.h b/KTp/Declarative/conversations-model.h
index 3708250..2f6d6d5 100644
--- a/KTp/Declarative/conversations-model.h
+++ b/KTp/Declarative/conversations-model.h
@@ -33,7 +33,7 @@ class ConversationsModel : public QAbstractListModel, public Tp::AbstractClientH
     Q_PROPERTY(int totalUnreadCount READ totalUnreadCount NOTIFY totalUnreadCountChanged)
 
   public:
-    explicit ConversationsModel(QObject *parent);
+    explicit ConversationsModel(QObject *parent=0);
     virtual ~ConversationsModel();
 
     virtual QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const;
diff --git a/KTp/Declarative/declarative-ktp-actions.cpp b/KTp/Declarative/declarative-ktp-actions.cpp
deleted file mode 100644
index 46d9c24..0000000
--- a/KTp/Declarative/declarative-ktp-actions.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-    Copyright (C) 2013 Aleix Pol <aleixpol 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 "declarative-ktp-actions.h"
-#include <KTp/actions.h>
-
-void DeclarativeKTpActions::openLogViewer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
-{
-    KTp::Actions::openLogViewer(account, contact);
-}
-
-Tp::PendingChannelRequest* DeclarativeKTpActions::startAudioCall(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
-{
-    return KTp::Actions::startAudioCall(account, contact);
-}
-
-Tp::PendingChannelRequest* DeclarativeKTpActions::startAudioVideoCall(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
-{
-    return KTp::Actions::startAudioVideoCall(account, contact);
-}
-
-Tp::PendingChannelRequest* DeclarativeKTpActions::startChat(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, bool delegateToPreferredHandler)
-{
-    return KTp::Actions::startChat(account, contact, delegateToPreferredHandler);
-}
-
-Tp::PendingChannelRequest* DeclarativeKTpActions::startDesktopSharing(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
-{
-    return KTp::Actions::startDesktopSharing(account, contact);
-}
-
-Tp::PendingChannelRequest* DeclarativeKTpActions::startFileTransfer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, const QString &filePath)
-{
-    return KTp::Actions::startFileTransfer(account, contact, filePath);
-}
-
-Tp::PendingOperation* DeclarativeKTpActions::startFileTransfer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, const QUrl &url)
-{
-    return KTp::Actions::startFileTransfer(account, contact, url);
-}
diff --git a/KTp/Declarative/declarative-ktp-actions.h b/KTp/Declarative/declarative-ktp-actions.h
deleted file mode 100644
index 186d421..0000000
--- a/KTp/Declarative/declarative-ktp-actions.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-    Copyright (C) 2013 Aleix Pol <aleixpol 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 DECLARATIVEKTPACTIONS_H
-#define DECLARATIVEKTPACTIONS_H
-
-#include <QObject>
-#include <TelepathyQt/Types>
-#include <KTp/contact.h>
-
-namespace Tp { class PendingChannelRequest; }
-
-class DeclarativeKTpActions : public QObject
-{
-    Q_OBJECT
-    public Q_SLOTS:
-        Tp::PendingChannelRequest* startChat(const Tp::AccountPtr &account,
-                                                    const KTp::ContactPtr &contact,
-                                                    bool delegateToPreferredHandler = true);
-
-        Tp::PendingChannelRequest* startAudioCall(const Tp::AccountPtr &account,
-                                                            const KTp::ContactPtr &contact);
-
-        Tp::PendingChannelRequest* startAudioVideoCall(const Tp::AccountPtr &account,
-                                                                const KTp::ContactPtr &contact);
-
-        Tp::PendingChannelRequest* startDesktopSharing(const Tp::AccountPtr &account,
-                                                                const KTp::ContactPtr &contact);
-
-        Tp::PendingOperation* startFileTransfer(const Tp::AccountPtr &account,
-                                                const KTp::ContactPtr &contact,
-                                                const QUrl& url);
-
-        Tp::PendingChannelRequest* startFileTransfer(const Tp::AccountPtr &account,
-                                                                const KTp::ContactPtr &contact,
-                                                                const QString &filePath);
-
-        void openLogViewer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact);
-};
-
-#endif // DECLARATIVEKTPACTIONS_H
diff --git a/KTp/Declarative/messages-model.cpp b/KTp/Declarative/messages-model.cpp
index 8078241..4e7327f 100644
--- a/KTp/Declarative/messages-model.cpp
+++ b/KTp/Declarative/messages-model.cpp
@@ -196,7 +196,7 @@ QVariant MessagesModel::data(const QModelIndex &index, int role) const
             break;
         case SenderAvatarRole:
             if (message.sender()) {
-                result = QVariant::fromValue(message.sender()->avatarData());
+                result = QVariant::fromValue(message.sender()->avatarPixmap());
             }
             break;
         };
diff --git a/KTp/Declarative/qml-plugins.cpp b/KTp/Declarative/qml-plugins.cpp
index ec7c8af..1ba3ef2 100644
--- a/KTp/Declarative/qml-plugins.cpp
+++ b/KTp/Declarative/qml-plugins.cpp
@@ -22,40 +22,43 @@
 #include "qml-plugins.h"
 
 #include <QtDeclarative/QDeclarativeItem>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeContext>
+
 
-#include "contact-list.h"
 #include "conversation.h"
 #include "conversations-model.h"
 #include "conversation-target.h"
 #include "hide-window-component.h"
 #include "messages-model.h"
-#include "telepathy-text-observer.h"
 #include "pinned-contacts-model.h"
 #include "contact-pin.h"
 #include "filtered-pinned-contacts-proxy-model.h"
-#include "declarative-ktp-actions.h"
+#include "telepathy-manager.h"
+
+#include "KTp/types.h"
+#include "KTp/Models/contacts-filter-model.h"
+#include "KTp/Models/contacts-model.h"
 
-#include "Models/contacts-filter-model.h"
-#include <Models/contacts-model.h>
+void QmlPlugins::initializeEngine(QDeclarativeEngine *engine, const char *uri)
+{
+    engine->rootContext()->setContextProperty(QLatin1String("telepathyManager"), new TelepathyManager(engine));
+}
 
 void QmlPlugins::registerTypes(const char *uri)
 {
-    qmlRegisterType<ContactList> (uri, 0, 1, "ContactList");
-    qmlRegisterType<TelepathyTextObserver> (uri, 0, 1, "TelepathyTextObserver");
+    qmlRegisterType<KTp::ContactsModel> (uri, 0, 1, "ContactsModel");
+    qmlRegisterType<ConversationsModel> (uri, 0, 1, "ConversationsModel");
     qmlRegisterType<Conversation>(uri, 0, 1, "Conversation");
     qmlRegisterType<HideWindowComponent>(uri, 0, 1, "HideWindowComponent");
     qmlRegisterType<PinnedContactsModel>(uri, 0, 1, "PinnedContactsModel");
     qmlRegisterType<ContactPin>(uri, 0, 1, "ContactPin");
     qmlRegisterType<FilteredPinnedContactsProxyModel>(uri, 0, 1, "FilteredPinnedContactsProxyModel");
-    qmlRegisterType<DeclarativeKTpActions>(uri, 0, 1, "DeclarativeKTpActions");
 
-    qmlRegisterUncreatableType<KTp::ContactsFilterModel> (uri, 0, 1, "AccountsFilterModel",
-        QLatin1String("Filter cannot be created. Access through ContactList.filter"));
     qmlRegisterUncreatableType<MessagesModel> (uri, 0, 1, "MessagesModel",
         QLatin1String("It will be created once the conversation is created"));
-    qmlRegisterUncreatableType<KTp::ContactsModel> (uri, 0, 1, "ContactsModel",
-        QLatin1String("It will be created through ContactList"));
 
+    qmlRegisterType<TelepathyManager>();
     qmlRegisterType<ConversationTarget>();
     qmlRegisterType<ConversationsModel>();
     qRegisterMetaType<Tp::AccountManagerPtr>();
diff --git a/KTp/Declarative/qml-plugins.h b/KTp/Declarative/qml-plugins.h
index 5efc4fd..e2e2b1a 100644
--- a/KTp/Declarative/qml-plugins.h
+++ b/KTp/Declarative/qml-plugins.h
@@ -25,6 +25,7 @@
 class QmlPlugins : public QDeclarativeExtensionPlugin
 {
     public:
+        virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri);
         virtual void registerTypes(const char *uri);
 };
 
diff --git a/KTp/Declarative/telepathy-manager.cpp b/KTp/Declarative/telepathy-manager.cpp
new file mode 100644
index 0000000..79f47b3
--- /dev/null
+++ b/KTp/Declarative/telepathy-manager.cpp
@@ -0,0 +1,151 @@
+/*
+    Copyright (C) 2013 David Edmundson <davidedmundson at kde.org>
+    Copyright (C) 2013 Aleix Pol <aleixpol 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 "telepathy-manager.h"
+#include <KTp/actions.h>
+
+#include <TelepathyQt/Account>
+
+#include <TelepathyQt/AccountManager>
+#include <TelepathyQt/ClientRegistrar>
+#include <TelepathyQt/AbstractClient>
+#include <TelepathyQt/TextChannel>
+
+TelepathyManager::TelepathyManager(QObject *parent)
+    : QObject(parent)
+{
+    Tp::registerTypes();
+
+    m_accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
+                                                  Tp::Features() << Tp::Account::FeatureCore
+                                                  << Tp::Account::FeatureProfile);
+
+    m_connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
+                                                        Tp::Features() << Tp::Connection::FeatureCore);
+
+    m_contactFactory = KTp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
+                                                   << Tp::Contact::FeatureSimplePresence
+                                                   << Tp::Contact::FeatureCapabilities);
+
+    m_channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
+
+    m_accountManager = Tp::AccountManager::create(m_accountFactory, m_connectionFactory, m_channelFactory, m_contactFactory);
+}
+
+TelepathyManager::~TelepathyManager()
+{
+}
+
+Tp::AccountManagerPtr TelepathyManager::accountManager()
+{
+    return m_accountManager;
+}
+
+void TelepathyManager::becomeReady()
+{
+    m_accountManager->becomeReady();
+}
+
+bool TelepathyManager::registerClient(QObject *client, const QString &name)
+{
+    Tp::AbstractClient* abstractClient = dynamic_cast<Tp::AbstractClient*>(client);
+    if (!abstractClient) {
+        return false;
+    }
+
+    if (! m_clientRegistrar) {
+        m_clientRegistrar = Tp::ClientRegistrar::create(m_accountManager);
+    }
+
+    return m_clientRegistrar->registerClient(Tp::AbstractClientPtr(abstractClient), name);
+}
+
+void TelepathyManager::addTextChatFeatures()
+{
+    m_connectionFactory->addFeatures(Tp::Features() << Tp::Connection::FeatureSelfContact);
+
+    Tp::Features textFeatures = Tp::Features() << Tp::TextChannel::FeatureMessageQueue
+                                            << Tp::TextChannel::FeatureMessageSentSignal
+                                            << Tp::TextChannel::FeatureChatState
+                                            << Tp::TextChannel::FeatureMessageCapabilities;
+
+    m_contactFactory->addFeatures(Tp::Features() << Tp::Contact::FeatureAlias
+                                  << Tp::Contact::FeatureSimplePresence
+                                  << Tp::Contact::FeatureCapabilities
+                                  << Tp::Contact::FeatureAvatarData);
+
+    m_channelFactory->addFeaturesForTextChats(textFeatures);
+    m_channelFactory->addFeaturesForTextChatrooms(textFeatures);
+}
+
+void TelepathyManager::addContactListFeatures()
+{
+    m_connectionFactory->addFeatures(Tp::Features() << Tp::Connection::FeatureRosterGroups
+                                     << Tp::Connection::FeatureRoster
+                                     << Tp::Connection::FeatureSelfContact);
+
+    m_contactFactory->addFeatures(Tp::Features() << Tp::Contact::FeatureAlias
+                                  << Tp::Contact::FeatureSimplePresence
+                                  << Tp::Contact::FeatureCapabilities
+                                  << Tp::Contact::FeatureAvatarData);
+
+    //used for optionally keeping track of unread message count/icon in contact list
+    Tp::Features textFeatures = Tp::Features() << Tp::TextChannel::FeatureMessageQueue;
+    m_channelFactory->addFeaturesForTextChats(textFeatures);
+}
+
+void TelepathyManager::addAllFeatures()
+{
+    addTextChatFeatures();
+    addContactListFeatures();
+}
+
+void TelepathyManager::openLogViewer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
+{
+    KTp::Actions::openLogViewer(account, contact);
+}
+
+Tp::PendingChannelRequest* TelepathyManager::startAudioCall(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
+{
+    return KTp::Actions::startAudioCall(account, contact);
+}
+
+Tp::PendingChannelRequest* TelepathyManager::startAudioVideoCall(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
+{
+    return KTp::Actions::startAudioVideoCall(account, contact);
+}
+
+Tp::PendingChannelRequest* TelepathyManager::startChat(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, bool delegateToPreferredHandler)
+{
+    return KTp::Actions::startChat(account, contact, delegateToPreferredHandler);
+}
+
+Tp::PendingChannelRequest *TelepathyManager::startChat(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, const QString &preferredHandler)
+{
+    return account->ensureTextChat(contact, QDateTime::currentDateTime(), preferredHandler);
+}
+
+Tp::PendingOperation* TelepathyManager::startFileTransfer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, const QUrl &url)
+{
+    return KTp::Actions::startFileTransfer(account, contact, url);
+}
+
+
+
+
diff --git a/KTp/Declarative/telepathy-manager.h b/KTp/Declarative/telepathy-manager.h
new file mode 100644
index 0000000..492f09c
--- /dev/null
+++ b/KTp/Declarative/telepathy-manager.h
@@ -0,0 +1,138 @@
+/*
+    Copyright (C) 2013 David Edmundson <davidedmundson at kde.org>
+    Copyright (C) 2013 Aleix Pol <aleixpol 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 TELEPATHYMANAGER_H
+#define TELEPATHYMANAGER_H
+
+#include <QObject>
+#include <TelepathyQt/Types>
+
+#include <KTp/contact.h>
+#include <KTp/contact-factory.h>
+
+#include <KTp/types.h>
+
+namespace Tp {
+class PendingChannelRequest;
+}
+
+
+class TelepathyManager : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(Tp::AccountManagerPtr accountManager READ accountManager CONSTANT)
+
+public:
+    TelepathyManager(QObject *parent=0);
+    virtual ~TelepathyManager();
+
+    /** Returns the account manager*/
+    Tp::AccountManagerPtr accountManager();
+
+    /** Add features to ObjectFactories that allow for all TextChannel features
+     * This must be called before becomeReady()
+     */
+    Q_INVOKABLE void addTextChatFeatures();
+
+    /** Add features to ObjectFactories that allow for all features needed for a contact list
+     * This must be called before becomeReady()
+     */
+    Q_INVOKABLE void addContactListFeatures();
+
+    /** Add all useful ObjectFactory features
+     * This must be called before becomeReady()
+     */
+    Q_INVOKABLE void addAllFeatures();
+
+    /** Call Tp::AccountManager::becomeReady
+     */
+    Q_INVOKABLE void becomeReady();
+
+    /** Register an abstractClient to clientRegistrar
+     * @arg client. Clients must subclass AbstractClient and QObject in their implementation to be used in QML
+     *
+     * @arg clientName
+     * The client name MUST be a non-empty string of ASCII digits, letters, dots and/or underscores, starting with a letter, and without sets of two consecutive dots or a dot followed by a digit.
+     *
+     * See ClientRegistrar::registerClient for details
+     *
+     * @return whether registration was successful
+     *
+     */
+    Q_INVOKABLE bool registerClient(QObject *client, const QString &clientName);
+
+public Q_SLOTS:
+    /** Start a text chat using the default KTp text application
+        @arg account the account to start the channel from
+        @arg contact the contact to start the channel with
+        @arg delegateToPreferredHandler whether any existing handlers should release handling the channel and pass control to the requested handler
+     */
+    Tp::PendingChannelRequest* startChat(const Tp::AccountPtr &account,
+                                         const KTp::ContactPtr &contact,
+                                         bool delegateToPreferredHandler = true);
+
+    /** Start a text chat using the preffered client
+        @arg account the account to start the channel from
+        @arg contact the contact to start the channel with
+        @arg preferredHandler the preferred client
+    */
+    Tp::PendingChannelRequest* startChat(const Tp::AccountPtr &account,
+                                         const KTp::ContactPtr &contact,
+                                         const QString &preferredHandler);
+
+    /** Start an audio call using the default KTp call application
+        @arg account the account to start the channel from
+        @arg contact the contact to start the channel with
+    */
+    Tp::PendingChannelRequest* startAudioCall(const Tp::AccountPtr &account,
+                                              const KTp::ContactPtr &contact);
+
+    /** Start an audio call using the default KTp call application
+        @arg account the account to start the channel from
+        @arg contact the contact to start the channel with
+    */
+    Tp::PendingChannelRequest* startAudioVideoCall(const Tp::AccountPtr &account,
+                                                   const KTp::ContactPtr &contact);
+
+    /** Start a file transfer using the default KTp file transfer application
+        @arg account the account to start the channel from
+        @arg contact the contact to start the channel with
+    */
+    Tp::PendingOperation* startFileTransfer(const Tp::AccountPtr &account,
+                                            const KTp::ContactPtr &contact,
+                                            const QUrl& url);
+
+    /** Open logs using the default KTp log application
+        @arg account the account to start the channel from
+        @arg contact the contact to start the channel with
+    */
+    void openLogViewer(const Tp::AccountPtr &account, const KTp::ContactPtr &contact);
+
+private:
+    Tp::AccountManagerPtr m_accountManager;
+    Tp::ClientRegistrarPtr m_clientRegistrar;
+
+    Tp::AccountFactoryPtr m_accountFactory;
+    Tp::ContactFactoryPtr m_contactFactory;
+    Tp::ConnectionFactoryPtr m_connectionFactory;
+    Tp::ChannelFactoryPtr m_channelFactory;
+
+};
+
+#endif // DECLARATIVEKTPACTIONS_H
diff --git a/KTp/Declarative/telepathy-text-observer.cpp b/KTp/Declarative/telepathy-text-observer.cpp
deleted file mode 100644
index a44e5a1..0000000
--- a/KTp/Declarative/telepathy-text-observer.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-    Copyright (C) 2011  Lasath Fernando <kde at lasath.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 "telepathy-text-observer.h"
-#include "conversation.h"
-
-#include <KDebug>
-
-#include <TelepathyQt/AccountFactory>
-#include <TelepathyQt/ConnectionFactory>
-#include <TelepathyQt/ClientRegistrar>
-
-#include <KTp/contact-factory.h>
-
-
-TelepathyTextObserver::TelepathyTextObserver(QObject *parent) :
-    QObject(parent),
-    m_handler(new ConversationsModel(this))
-{
-    kDebug();
-    Tp::registerTypes();
-    Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
-                                                                    Tp::Account::FeatureCore);
-
-    Tp::ConnectionFactoryPtr  connectionFactory = Tp::ConnectionFactory::create(
-        QDBusConnection::sessionBus(),
-        Tp::Features() << Tp::Connection::FeatureSelfContact
-                       << Tp::Connection::FeatureCore
-                       << Tp::Connection::FeatureConnected
-    );
-
-    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
-    channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);
-
-    Tp::Features textFeatures = Tp::Features() << Tp::TextChannel::FeatureMessageQueue
-                                            << Tp::TextChannel::FeatureMessageSentSignal
-                                            << Tp::TextChannel::FeatureChatState
-                                            << Tp::TextChannel::FeatureMessageCapabilities;
-    channelFactory->addFeaturesForTextChats(textFeatures);
-    channelFactory->addFeaturesForTextChatrooms(textFeatures);
-
-    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
-        Tp::Features() << Tp::Contact::FeatureAlias
-                    << Tp::Contact::FeatureAvatarToken
-                    << Tp::Contact::FeatureAvatarData
-                    << Tp::Contact::FeatureCapabilities
-                    << Tp::Contact::FeatureSimplePresence
-    );
-
-    //TODO: check these to make sure I'm only requesting features I actually use.
-    m_registrar = Tp::ClientRegistrar::create(accountFactory, connectionFactory,
-                                            channelFactory, contactFactory);
-    m_registrar->registerClient(m_handler, QLatin1String("KDE.TextUi.ConversationWatcher")); //KTp.ChatPlasmoid
-
-    m_accountManager = Tp::AccountManager::create(accountFactory, connectionFactory, channelFactory, contactFactory);
-    m_accountManager->becomeReady();
-}
-
-TelepathyTextObserver::~TelepathyTextObserver()
-{
-    kDebug() << "deleting text observer";
-}
-
-ConversationsModel* TelepathyTextObserver::conversationModel() const
-{
-    Q_ASSERT(!m_handler.isNull());
-    return m_handler.data();
-}
-
-Tp::AccountManagerPtr TelepathyTextObserver::accountManager() const
-{
-    return m_accountManager;
-}
diff --git a/KTp/Declarative/telepathy-text-observer.h b/KTp/Declarative/telepathy-text-observer.h
deleted file mode 100644
index 3fa20f8..0000000
--- a/KTp/Declarative/telepathy-text-observer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-    Copyright (C) 2011  Lasath Fernando <kde at lasath.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 TELEPATHY_TEXT_OBSERVER_H
-#define TELEPATHY_TEXT_OBSERVER_H
-
-#include "conversations-model.h"
-#include "KTp/types.h"
-
-#include <TelepathyQt/AbstractClientHandler>
-
-class TelepathyTextObserver : public QObject
-{
-    Q_OBJECT
-
-Q_PROPERTY(ConversationsModel *conversations READ conversationModel CONSTANT)
-Q_PROPERTY(Tp::AccountManagerPtr accountManager READ accountManager CONSTANT)
-
-  public:
-    TelepathyTextObserver(QObject *parent = 0);
-    ~TelepathyTextObserver();
-
-    ConversationsModel* conversationModel() const;
-    Tp::AccountManagerPtr accountManager() const;
-
-  private:
-    Tp::SharedPtr<ConversationsModel> m_handler;
-    Tp::ClientRegistrarPtr m_registrar;
-    Tp::AccountManagerPtr m_accountManager;
-};
-
-#endif // CONVERSATION_WATCHER_H
diff --git a/KTp/Models/contacts-filter-model.cpp b/KTp/Models/contacts-filter-model.cpp
index 49166aa..8483e18 100644
--- a/KTp/Models/contacts-filter-model.cpp
+++ b/KTp/Models/contacts-filter-model.cpp
@@ -952,14 +952,14 @@ QModelIndexList ContactsFilterModel::match(const QModelIndex &start, int role,
 
 void ContactsFilterModel::setSortRoleString(const QString &role)
 {
-    Q_ASSERT(!roleNames().keys(role.toUtf8()).isEmpty());
     setSortRole(roleNames().key(role.toUtf8()));
 }
 
 QString ContactsFilterModel::sortRoleString() const
 {
-    Q_ASSERT(roleNames().contains(sortRole()));
-    return QString::fromUtf8(roleNames().value(sortRole()));
+//    Q_ASSERT(roleNames().contains(sortRole()));
+//    return QString::fromUtf8(roleNames().value(sortRole()));
+    return QString();
 }
 
 #include "contacts-filter-model.moc"
diff --git a/KTp/Models/contacts-model.h b/KTp/Models/contacts-model.h
index 41c1cb3..345378b 100644
--- a/KTp/Models/contacts-model.h
+++ b/KTp/Models/contacts-model.h
@@ -52,7 +52,7 @@ public:
         GroupGrouping
     };
 
-    ContactsModel(QObject *parent);
+    ContactsModel(QObject *parent=0);
 
     virtual ~ContactsModel();
 
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 20d6aea..dcd774d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -29,25 +29,3 @@ target_link_libraries(ktp_contact_list_model_view
   ktpmodelsprivate
 )
 
-###
-
-kde4_add_executable(ktp_pinned-contact_list_model_view
-    ${model_view_SRCS}
-    pinned-contacts-model-view-main.cpp
-    ../KTp/Declarative/pinned-contacts-model.cpp
-    ../KTp/Declarative/telepathy-text-observer.cpp
-    ../KTp/Declarative/conversations-model.cpp
-    ../KTp/Declarative/conversation-target.cpp
-    ../KTp/Declarative/contact-pin.cpp
-    ../KTp/Declarative/messages-model.cpp
-    ../KTp/Declarative/conversation.cpp
-)
-
-target_link_libraries(ktp_pinned-contact_list_model_view
-  ${QT_QTTEST_LIBRARY}
-  ${KDE4_KDECORE_LIBS}
-  ${KDE4_KDEUI_LIBS}
-  ${TELEPATHY_QT4_LIBRARIES}
-  ktpcommoninternalsprivate
-  ktpmodelsprivate
-)
diff --git a/tests/pinned-contacts-model-view-main.cpp b/tests/pinned-contacts-model-view-main.cpp
deleted file mode 100644
index e94de01..0000000
--- a/tests/pinned-contacts-model-view-main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of telepathy-kde-models-test-ui
- *
- * Copyright (C) 2011 Collabora Ltd. <info at collabora.co.uk>
- *   @Author George Goldberg <george.goldberg at collabora.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 "model-view.h"
-
-#include <KAboutData>
-#include <KCmdLineArgs>
-#include <KDebug>
-#include <KApplication>
-
-#include <TelepathyQt/Types>
-#include <TelepathyQt/Debug>
-
-#include "KTp/Declarative/telepathy-text-observer.h"
-#include "KTp/Declarative/conversations-model.h"
-#include "KTp/Declarative/pinned-contacts-model.h"
-
-int main(int argc, char *argv[])
-{
-    KAboutData aboutData("telepathy-kde-models-test-ui",
-                         0,
-                         ki18n("Telepathy KDE Models Test UI"),
-                         "0.1",
-                         ki18n("Telepathy KDE Models Test UI"),
-                         KAboutData::License_LGPL,
-                         ki18n("(C) 2011 Collabora Ltd"));
-
-    KCmdLineArgs::init(argc, argv, &aboutData);
-
-    KApplication app;
-
-    Tp::registerTypes();
-    Tp::enableDebug(false);
-    Tp::enableWarnings(true);
-
-    
-    PinnedContactsModel *model = new PinnedContactsModel(&app);
-    
-    TelepathyTextObserver *observer = new TelepathyTextObserver(&app);
-    model->setAccountManager(observer->accountManager());
-    model->setConversationsModel(observer->conversationModel());
-    
-    // Set up and show the main widget
-    ModelView *mainWidget = new ModelView(model, 0);
-    mainWidget->show();
-
-    // Start event loop.
-    app.exec();
-}
-

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list