[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:18:33 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=d256e86

The following commit has been merged in the master branch:
commit d256e8645f6dd062f5efb8fdec3c4cae58acfc26
Author: George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
Date:   Fri Jan 28 15:17:07 2011 +0200

    Remove the ChatConnection class and use tp-qt4 factories instead.
---
 app/main.cpp           | 38 ++++++++++++++++++++-------
 app/mainwindow.cpp     | 13 +++++++---
 app/mainwindow.h       |  2 --
 lib/CMakeLists.txt     |  1 -
 lib/chatconnection.cpp | 69 --------------------------------------------------
 lib/chatconnection.h   | 66 -----------------------------------------------
 lib/chatwindow.cpp     | 59 ++++++++++++++++++++----------------------
 lib/chatwindow.h       |  5 ++--
 8 files changed, 68 insertions(+), 185 deletions(-)

diff --git a/app/main.cpp b/app/main.cpp
index 9f572a6..ca0d585 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -43,15 +43,35 @@ int main(int argc, char *argv[])
     registerTypes();
 
 
-    AccountFactoryPtr  accountFactory = AccountFactory::create(QDBusConnection::sessionBus(),
-                                                               Features() << Account::FeatureCore);
-
-    ConnectionFactoryPtr  connectionFactory = ConnectionFactory::create(QDBusConnection::sessionBus(),
-                                                               Features() <<  Connection::FeatureSelfContact
-                                                               << Connection::FeatureCore);
-
-
-    ClientRegistrarPtr registrar = ClientRegistrar::create(accountFactory, connectionFactory);
+    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::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 = Tp::ContactFactory::create(
+        Tp::Features() << Tp::Contact::FeatureAlias
+                       << Tp::Contact::FeatureAvatarToken
+                       << Tp::Contact::FeatureAvatarData
+                       << Tp::Contact::FeatureCapabilities
+                       << Tp::Contact::FeatureSimplePresence
+    );
+
+    Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create(accountFactory, connectionFactory,
+                                                                   channelFactory, contactFactory);
     MainWindow* mainWindow = new MainWindow();
 
     AbstractClientPtr handler = AbstractClientPtr::dynamicCast(SharedPtr<MainWindow>(mainWindow));
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index 98647c9..87e9c1a 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -50,11 +50,18 @@ void MainWindow::handleChannels(const MethodInvocationContextPtr<> &context,
         const QDateTime &userActionTime,
         const AbstractClientHandler::HandlerInfo &handlerInfo)
 {
+    Tp::TextChannelPtr textChannel;
+    foreach(const Tp::ChannelPtr & channel, channels) {
+        textChannel = Tp::TextChannelPtr::dynamicCast(channel);
+        if (textChannel) {
+            break;
+        }
+    }
+    Q_ASSERT(textChannel);
 
-    ChatConnection* chatConnection = new ChatConnection(this, account, connection, channels);
-    ChatWindow* newWindow = new ChatWindow(chatConnection, this);
+    ChatWindow* newWindow = new ChatWindow(textChannel, this);
 
-    addTab(newWindow,KIcon("user-online"),"");
+    addTab(newWindow, KIcon("user-online"), newWindow->title());
 
     connect(newWindow, SIGNAL(titleChanged(QString)), SLOT(updateTabText(QString)));
     connect(newWindow,SIGNAL(iconChanged(KIcon)), SLOT(updateTabIcon(KIcon)));
diff --git a/app/mainwindow.h b/app/mainwindow.h
index bffa829..55153a5 100644
--- a/app/mainwindow.h
+++ b/app/mainwindow.h
@@ -20,8 +20,6 @@
 #ifndef REALCLIENTHANDLER_H
 #define REALCLIENTHANDLER_H
 
-#include "chatconnection.h"
-
 #include <KTabWidget>
 #include <KIcon>
 
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 2ea0a3a..890dcc5 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -1,5 +1,4 @@
 set(telepathy_chat_handler_lib_SRCS
-        chatconnection.cpp
         chatwindow.cpp
         chatwindowstyle.cpp
         chatwindowstylemanager.cpp
diff --git a/lib/chatconnection.cpp b/lib/chatconnection.cpp
deleted file mode 100644
index 07521fa..0000000
--- a/lib/chatconnection.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by David Edmundson <kde at davidedmundson.co.uk>      *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program 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 General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "chatconnection.h"
-#include <TelepathyQt4/PendingReady>
-#include <TelepathyQt4/PendingContacts>
-#include <TelepathyQt4/ContactManager>
-
-ChatConnection::ChatConnection(QObject *parent, const AccountPtr account, const ConnectionPtr connection,  QList<ChannelPtr> channels)
-        : QObject(parent),
-        m_account(account),
-        m_connection(connection)
-{
-    //FIXME loop through, find text channel
-    if (channels.length() == 1) {
-        m_channel = Tp::TextChannelPtr::dynamicCast(channels[0]);
-        PendingReady* op = m_channel->becomeReady(Features() << TextChannel::FeatureMessageQueue
-                           << TextChannel::FeatureMessageSentSignal
-                           << TextChannel::FeatureChatState
-                           << TextChannel::FeatureMessageCapabilities
-                           << Channel::FeatureCore);
-
-
-        connect(op, SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onChannelReady(Tp::PendingOperation*)));
-    } else {
-        qDebug() << "more than one channel?"; // I don't understand channels yet.
-    }
-
-}
-
-
-//Private slots
-
-void ChatConnection::onChannelReady(Tp::PendingOperation* op)
-{
-    qDebug() << "done";
-    PendingContacts* p = m_connection->contactManager()->upgradeContacts(QList<ContactPtr>::fromSet(m_channel->groupContacts()),
-                         Features() << Contact::FeatureAlias
-                         << Contact::FeatureAvatarToken
-                         << Contact::FeatureAvatarData
-                         << Contact::FeatureCapabilities
-                         << Contact::FeatureSimplePresence);
-    connect(p, SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onPendingContactsReady(Tp::PendingOperation*)));
-    qDebug() << "channel ready";
-
-}
-
-void ChatConnection::onPendingContactsReady(Tp::PendingOperation*)
-{
-    qDebug() << "contacts ready";
-    //m_isChannelReady = true;
-    emit(channelReadyStateChanged(true));
-}
diff --git a/lib/chatconnection.h b/lib/chatconnection.h
deleted file mode 100644
index 70ddcdc..0000000
--- a/lib/chatconnection.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by David Edmundson <kde at davidedmundson.co.uk>      *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program 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 General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef CHATCONNECTION_H
-#define CHATCONNECTION_H
-
-#include <QObject>
-#include <TelepathyQt4/Account>
-#include <TelepathyQt4/Connection>
-#include <TelepathyQt4/TextChannel>
-
-using namespace Tp;
-
-class ChatConnection : public QObject
-{
-    Q_OBJECT
-public:
-    explicit ChatConnection(QObject *parent, const AccountPtr, const ConnectionPtr,  QList<ChannelPtr>);
-
-    const AccountPtr account() {
-        return m_account;
-    };
-    const ConnectionPtr connection() {
-        return m_connection;
-    };
-    const TextChannelPtr channel() {
-        return m_channel;
-    };
-
-
-signals:
-    void channelReadyStateChanged(bool newState);
-
-public slots:
-
-
-
-private:
-    AccountPtr m_account;
-    ConnectionPtr m_connection;
-    TextChannelPtr m_channel;
-
-private slots:
-    void onChannelReady(Tp::PendingOperation*);
-    void onPendingContactsReady(Tp::PendingOperation*);
-};
-
-#endif // CHATCONNECTION_H
-
-
diff --git a/lib/chatwindow.cpp b/lib/chatwindow.cpp
index 92e7a53..68ae783 100644
--- a/lib/chatwindow.cpp
+++ b/lib/chatwindow.cpp
@@ -42,6 +42,7 @@
 #include <TelepathyQt4/Message>
 #include <TelepathyQt4/Types>
 #include <TelepathyQt4/AvatarData>
+#include <TelepathyQt4/Connection>
 
 class ChatWindowPrivate
 {
@@ -52,6 +53,7 @@ public:
     QAction* showFormatToolbarAction;
     bool isGroupChat;
     QString title;
+    Tp::TextChannelPtr channel;
 
     KComponentData telepathyComponentData();
 };
@@ -64,15 +66,12 @@ KComponentData ChatWindowPrivate::telepathyComponentData()
     return KComponentData(telepathySharedAboutData);
 }
 
-//FIXME once TP::Factory stuff is in, remove all of ChatConnection, replace this with
-//ChatWindow::ChatWindow(ConnectionPtr,TextChannelPtr, QWidget* parent) :...
-ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
+ChatWindow::ChatWindow(const Tp::TextChannelPtr & channel, QWidget *parent) :
         QWidget(parent),
         ui(new Ui::ChatWindow),
-        m_chatConnection(chat),
         d(new ChatWindowPrivate)
 {
-
+    d->channel = channel;
     d->chatviewlInitialised = false;
     d->showFormatToolbarAction = new QAction(i18n("Show format options"), this);
     d->isGroupChat = false;
@@ -94,7 +93,7 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
     ui->insertEmoticon->setText("");
     ui->insertEmoticon->setIcon(KIcon("face-smile"));
 
-    updateEnabledState(false);
+    updateEnabledState(true); //FIXME
 
     //format toolbar visibility
     d->showFormatToolbarAction->setCheckable(true);
@@ -112,13 +111,9 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
     connect(ui->formatItalic, SIGNAL(toggled(bool)), ui->sendMessageBox, SLOT(setFontItalic(bool)));
     connect(ui->formatUnderline, SIGNAL(toggled(bool)), ui->sendMessageBox, SLOT(setFontUnderline(bool)));
 
-    //chat connection lifespan should be same as the chatwindow
-    m_chatConnection->setParent(this);
-
-    connect(m_chatConnection, SIGNAL(channelReadyStateChanged(bool)), SLOT(updateEnabledState(bool)));
-    connect(m_chatConnection->channel().data(), SIGNAL(messageReceived(Tp::ReceivedMessage)), SLOT(handleIncomingMessage(Tp::ReceivedMessage)));
-    connect(m_chatConnection->channel().data(), SIGNAL(messageSent(Tp::Message, Tp::MessageSendingFlags, QString)), SLOT(handleMessageSent(Tp::Message, Tp::MessageSendingFlags, QString)));
-    connect(m_chatConnection->channel().data(), SIGNAL(chatStateChanged(Tp::ContactPtr, ChannelChatState)), SLOT(onChatStatusChanged(Tp::ContactPtr, ChannelChatState)));
+    connect(d->channel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)), SLOT(handleIncomingMessage(Tp::ReceivedMessage)));
+    connect(d->channel.data(), SIGNAL(messageSent(Tp::Message, Tp::MessageSendingFlags, QString)), SLOT(handleMessageSent(Tp::Message, Tp::MessageSendingFlags, QString)));
+    connect(d->channel.data(), SIGNAL(chatStateChanged(Tp::ContactPtr, ChannelChatState)), SLOT(onChatStatusChanged(Tp::ContactPtr, ChannelChatState)));
     connect(ui->chatArea, SIGNAL(loadFinished(bool)), SLOT(chatViewReady()));
 
     connect(ui->sendMessageBox, SIGNAL(textChanged()), SLOT(onInputBoxChanged()));
@@ -176,7 +171,7 @@ void ChatWindow::handleIncomingMessage(const Tp::ReceivedMessage &message)
         messageInfo.setSenderScreenName(message.sender()->id());
 
         ui->chatArea->addContentMessage(messageInfo);
-        m_chatConnection->channel()->acknowledge(QList<Tp::ReceivedMessage>() << message);
+        d->channel->acknowledge(QList<Tp::ReceivedMessage>() << message);
 
         emit messageReceived();
 
@@ -192,7 +187,7 @@ void ChatWindow::handleIncomingMessage(const Tp::ReceivedMessage &message)
 
         //if the message text contains sender name, it's a "highlighted message"
         //TODO DrDanz suggested this could be a configurable list of words that make it highlighted.(seems like a good idea to me)
-        if(message.text().contains(m_chatConnection->connection()->selfContact()->alias())) {
+        if(message.text().contains(d->channel->connection()->selfContact()->alias())) {
             notificationType = QLatin1String("kde_telepathy_contact_highlight");
         } else if(message.messageType() == Tp::ChannelTextMessageTypeNotice) {
             notificationType = QLatin1String("kde_telepathy_info_event");
@@ -231,7 +226,7 @@ void ChatWindow::handleMessageSent(const Tp::Message &message, Tp::MessageSendin
     messageInfo.setMessage(message.text());
     messageInfo.setTime(message.sent());
 
-    Tp::ContactPtr sender = m_chatConnection->connection()->selfContact();
+    Tp::ContactPtr sender = d->channel->connection()->selfContact();
     messageInfo.setSenderDisplayName(sender->alias());
     messageInfo.setSenderScreenName(sender->id());
     messageInfo.setUserIconPath(sender->avatarData().fileName);
@@ -256,7 +251,7 @@ void ChatWindow::chatViewReady()
     d->chatviewlInitialised = true;
 
     //process any messages we've 'missed' whilst initialising.
-    foreach(Tp::ReceivedMessage message, m_chatConnection->channel()->messageQueue()) {
+    foreach(Tp::ReceivedMessage message, d->channel->messageQueue()) {
         handleIncomingMessage(message);
     }
 }
@@ -265,7 +260,7 @@ void ChatWindow::chatViewReady()
 void ChatWindow::sendMessage()
 {
     if (!ui->sendMessageBox->toPlainText().isEmpty()) {
-        m_chatConnection->channel()->send(ui->sendMessageBox->toPlainText());
+        d->channel->send(ui->sendMessageBox->toPlainText());
         ui->sendMessageBox->clear();
     }
 }
@@ -273,7 +268,7 @@ void ChatWindow::sendMessage()
 void ChatWindow::onChatStatusChanged(Tp::ContactPtr contact, ChannelChatState state)
 {
     //don't show our own status changes.
-    if (contact == m_chatConnection->connection()->selfContact())
+    if (contact == d->channel->connection()->selfContact())
     {
         return;
     }
@@ -284,7 +279,7 @@ void ChatWindow::onChatStatusChanged(Tp::ContactPtr contact, ChannelChatState st
     case ChannelChatStateGone: {
         AdiumThemeStatusInfo statusMessage;
         statusMessage.setMessage(i18n("%1 has left the chat", contact->alias()));
-        statusMessage.setService(m_chatConnection->connection()->protocolName());
+        statusMessage.setService(d->channel->connection()->protocolName());
         statusMessage.setStatus("away");
         statusMessage.setTime(QDateTime::currentDateTime());
         ui->chatArea->addStatusMessage(statusMessage);
@@ -307,14 +302,14 @@ void ChatWindow::onChatStatusChanged(Tp::ContactPtr contact, ChannelChatState st
     {
         //In a multiperson chat just because this user is no longer typing it doesn't mean that no-one is.
         //loop through each contact, check no-one is in composing mode.
-        foreach (Tp::ContactPtr contact, m_chatConnection->channel()->groupContacts())
+        foreach (Tp::ContactPtr contact, d->channel->groupContacts())
         {
-            if (contact == m_chatConnection->connection()->selfContact())
+            if (contact == d->channel->connection()->selfContact())
             {
                 continue;
             }
 
-            if (m_chatConnection->channel()->chatState(contact) == ChannelChatStateComposing)
+            if (d->channel->chatState(contact) == ChannelChatStateComposing)
             {
                 contactIsTyping = true;
             }
@@ -329,7 +324,7 @@ void ChatWindow::onChatStatusChanged(Tp::ContactPtr contact, ChannelChatState st
 void ChatWindow::onContactPresenceChange(Tp::ContactPtr contact, uint type)
 {
     QString message;
-    bool isYou = (contact.data() == m_chatConnection->channel()->groupSelfContact().data());
+    bool isYou = (contact.data() == d->channel->groupSelfContact().data());
 
     switch (type) {
     case Tp::ConnectionPresenceTypeOffline:
@@ -362,7 +357,7 @@ void ChatWindow::onContactPresenceChange(Tp::ContactPtr contact, uint type)
         AdiumThemeStatusInfo statusMessage;
         statusMessage.setMessage(message);
         statusMessage.setStatus("");
-        statusMessage.setService(m_chatConnection->connection()->protocolName());
+        statusMessage.setService(d->channel->connection()->protocolName());
         statusMessage.setTime(QDateTime::currentDateTime());
         ui->chatArea->addStatusMessage(statusMessage);
     }
@@ -384,16 +379,16 @@ void ChatWindow::updateEnabledState(bool enable)
     //set up the initial chat window details.
     if (enable) {
         //channel is now valid, start keeping track of contacts.
-        ChannelContactList* contactList = new ChannelContactList(m_chatConnection->channel(), this);
+        ChannelContactList* contactList = new ChannelContactList(d->channel, this);
         connect(contactList, SIGNAL(contactPresenceChanged(Tp::ContactPtr, uint)), SLOT(onContactPresenceChange(Tp::ContactPtr, uint)));
 
         AdiumThemeHeaderInfo info;
-        Tp::Contacts allContacts = m_chatConnection->channel()->groupContacts();
+        Tp::Contacts allContacts = d->channel->groupContacts();
         //normal chat - self and one other person.
         if (allContacts.size() == 2) {
             //find the other contact which isn't self.
             foreach(Tp::ContactPtr it, allContacts) {
-                if (it.data() == m_chatConnection->channel()->groupSelfContact().data()) {
+                if (it.data() == d->channel->groupSelfContact().data()) {
                     continue;
                 } else {
                     info.setDestinationDisplayName(it->alias());
@@ -408,10 +403,10 @@ void ChatWindow::updateEnabledState(bool enable)
             d->isGroupChat = true;
         }
 
-        info.setSourceName(m_chatConnection->connection()->protocolName());
+        info.setSourceName(d->channel->connection()->protocolName());
 
         //set up anything related to 'self'
-        info.setOutgoingIconPath(m_chatConnection->channel()->groupSelfContact()->avatarData().fileName);
+        info.setOutgoingIconPath(d->channel->groupSelfContact()->avatarData().fileName);
         info.setTimeOpened(QDateTime::currentDateTime());
         ui->chatArea->initialise(info);
 
@@ -432,11 +427,11 @@ void ChatWindow::onInputBoxChanged()
     //FIXME check spec (with olly) as to whether we have to handle idle state etc.
     if(currentlyTyping)
     {
-        m_chatConnection->channel()->requestChatState(Tp::ChannelChatStateComposing);
+        d->channel->requestChatState(Tp::ChannelChatStateComposing);
     }
     else
     {
-        m_chatConnection->channel()->requestChatState(Tp::ChannelChatStateActive);
+        d->channel->requestChatState(Tp::ChannelChatStateActive);
     }
 }
 
diff --git a/lib/chatwindow.h b/lib/chatwindow.h
index 434ece2..0abc322 100644
--- a/lib/chatwindow.h
+++ b/lib/chatwindow.h
@@ -25,8 +25,8 @@
 #include <KIcon>
 
 #include <TelepathyQt4/ReceivedMessage>
-#include "chatconnection.h"
 
+using namespace Tp;
 
 namespace Ui
 {
@@ -52,7 +52,7 @@ class ChatWindow : public QWidget
     Q_OBJECT
 
 public:
-    explicit ChatWindow(ChatConnection* chat, QWidget *parent = 0);
+    explicit ChatWindow(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
     ~ChatWindow();
 
 
@@ -106,7 +106,6 @@ private:
     KIcon iconForPresence(uint presence);
 
     Ui::ChatWindow *ui;
-    ChatConnection* m_chatConnection; //FIXME deprecate this whole class when factories is finished.
     ChatWindowPrivate *d;
 
 };

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list