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


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

The following commit has been merged in the master branch:
commit 4e4496b5f8cb5a00fa98f2d08842325e04ee4c92
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Wed Aug 11 21:03:25 2010 +0000

    Show presence changes of contacts in the chat
    Added hidden HTML debug mode.
    
    
    svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1162333
---
 app/CMakeLists.txt         |  3 +++
 app/mainwindow.cpp         |  2 +-
 config/CMakeLists.txt      |  2 +-
 data/CMakeLists.txt        |  2 +-
 lib/channelcontactlist.cpp | 35 +++++++++++++++++++++++++++++++++
 lib/channelcontactlist.h   | 46 +++++++++++++++++++++++++++++++++++++++++++
 lib/chatview.cpp           | 22 ++++++++++++++++-----
 lib/chatview.h             |  2 ++
 lib/chatwindow.cpp         | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/chatwindow.h           |  1 +
 10 files changed, 156 insertions(+), 8 deletions(-)

diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 5cbe05c..221d6ae 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -8,11 +8,14 @@ set(telepathy_chat_handler_SRCS
         ../lib/chatconnection.cpp
         ../lib/chatwindow.cpp
         ../lib/chatwindowstyle.cpp
+        ../lib/chatwindowstylemanager.cpp
         ../lib/chatview.cpp
         ../lib/telepathychatmessageinfo.cpp
         ../lib/telepathychatinfo.cpp
+        ../lib/channelcontactlist.cpp
 )
 
+
 set(telepathy_chat_handler_UI
     ../lib/chatwindow.ui
 )
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index ca0b03f..01583ad 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -49,7 +49,7 @@ void MainWindow::handleChannels(const MethodInvocationContextPtr<> &context,
     ChatConnection* chatConnection = new ChatConnection(this, account, connection, channels);
     ChatWindow* newWindow = new ChatWindow(chatConnection, this);
 
-    connect(newWindow,SIGNAL(titleChanged(QString)),SLOT(updateTabText(QString)));
+    connect(newWindow, SIGNAL(titleChanged(QString)), SLOT(updateTabText(QString)));
     addTab(newWindow, "");
     resize(newWindow->sizeHint());// FUDGE
 
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index f9f2192..ba92b1e 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -5,8 +5,8 @@ include_directories(../lib/)
 set(telepathy_chat_config_SRCS
         main.cpp
         mainwindow.cpp
-        ../lib/chatwindowstylemanager.cpp
         ../lib/chatwindowstyle.cpp
+        ../lib/chatwindowstylemanager.cpp
         ../lib/chatview.cpp
         ../lib/telepathychatmessageinfo.cpp
         ../lib/telepathychatinfo.cpp
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index d30e960..4d9070c 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,2 +1,2 @@
 install(FILES template.html
-        DESTINATION ${DATA_INSTALL_DIR}/ktelepathy)
\ No newline at end of file
+        DESTINATION ${DATA_INSTALL_DIR}/ktelepathy)
diff --git a/lib/channelcontactlist.cpp b/lib/channelcontactlist.cpp
new file mode 100644
index 0000000..d1f897a
--- /dev/null
+++ b/lib/channelcontactlist.cpp
@@ -0,0 +1,35 @@
+#include "channelcontactlist.h"
+
+
+/** reif This class provides an abstracted way of getting presence changes from a contact
+  * It was needed to be able to pair up a contact changing, with the name of the contact.
+  * It gives a single signal for the calling code to handle for every contact, and
+  * also safetly handles connect and disconnecting slots as contacts enter and leave a channel (future).
+*/
+
+/** Internal private class*/
+
+ChannelContactListContact::ChannelContactListContact(Tp::ContactPtr contact, QObject *parent)
+        : QObject(parent)
+{
+    m_contact = contact;
+    connect(m_contact.data(), SIGNAL(simplePresenceChanged(const QString, uint, const QString)), SLOT(onSimplePresenceChanged(QString, uint)));
+}
+
+void ChannelContactListContact::onSimplePresenceChanged(const QString &status, uint type)
+{
+    Q_UNUSED(status);
+    Q_EMIT contactPresenceChanged(m_contact, type);
+}
+
+
+ChannelContactList::ChannelContactList(Tp::TextChannelPtr channel, QObject *parent) :
+        QObject(parent)
+{
+    foreach(Tp::ContactPtr contact, channel->groupContacts()) {
+        //FIXME move this to a slot called "addContact" - also call this when chat gains a person.
+        ChannelContactListContact*  contactProxy = new ChannelContactListContact(contact, this);
+        connect(contactProxy, SIGNAL(contactPresenceChanged(Tp::ContactPtr, uint)), SIGNAL(contactPresenceChanged(Tp::ContactPtr, uint)));
+    }
+}
+
diff --git a/lib/channelcontactlist.h b/lib/channelcontactlist.h
new file mode 100644
index 0000000..d358b7d
--- /dev/null
+++ b/lib/channelcontactlist.h
@@ -0,0 +1,46 @@
+#ifndef CHANNELCONTACTLIST_H
+#define CHANNELCONTACTLIST_H
+
+#include <QObject>
+#include <TelepathyQt4/TextChannel>
+#include <TelepathyQt4/Contact>
+
+
+class ChannelContactListContact: public QObject
+{
+    Q_OBJECT
+public:
+    explicit ChannelContactListContact(Tp::ContactPtr, QObject *parent);
+
+signals:
+    void contactPresenceChanged(Tp::ContactPtr contact, uint type);
+
+private slots:
+    void onSimplePresenceChanged(const QString &status, uint type);
+
+private:
+    Tp::ContactPtr m_contact;
+};
+
+
+
+
+class ChannelContactList : public QObject
+{
+    Q_OBJECT
+public:
+    explicit ChannelContactList(Tp::TextChannelPtr, QObject *parent = 0);
+
+signals:
+    void contactPresenceChanged(Tp::ContactPtr contact, uint type);
+
+public slots:
+
+};
+
+
+
+
+
+
+#endif // CHANNELCONTACTLIST_H
diff --git a/lib/chatview.cpp b/lib/chatview.cpp
index 5961b85..0b1862f 100644
--- a/lib/chatview.cpp
+++ b/lib/chatview.cpp
@@ -24,6 +24,8 @@
 #include <QFile>
 #include <QTextCodec>
 #include <QTextDocument> //needed for Qt::escape
+#include <QWebInspector>
+#include <QWebSettings>
 
 #include <KDebug>
 #include <KEmoticonsTheme>
@@ -43,21 +45,20 @@ ChatView::ChatView(QWidget *parent) :
     KConfig config(KGlobal::dirs()->findResource("config", "kopeterc"));
     KConfigGroup appearanceConfig = config.group("Appearance");
 
-    qDebug() << QString("Loading ") << appearanceConfig.readEntry("styleName");
-
-    m_chatStyle = new ChatWindowStyle(appearanceConfig.readEntry("styleName")); //FIXME this gets leaked !!! //FIXME hardcoded style
+    m_chatStyle = new ChatWindowStyle(appearanceConfig.readEntry("styleName")); //FIXME this gets leaked !!!
     if (!m_chatStyle->isValid()) {
         KMessageBox::error(this, "Failed to load a valid Kopete theme. Note this current version reads chat window settings from your Kopete config file.");
     }
 
     m_variantPath = appearanceConfig.readEntry("styleVariant");
+
+    //special HTML debug mode. Debugging/Profiling only (or theme creating) should have no visible way to turn this flag on.
+    m_webInspector = appearanceConfig.readEntry("debug", false);
 }
 
 void ChatView::initialise(const TelepathyChatInfo &chatInfo)
 {
     QString templateHtml;
-
-
     QString templateFileName(KGlobal::dirs()->findResource("data", "ktelepathy/template.html"));
 
     if (! templateFileName.isEmpty() && QFile::exists(templateFileName)) {
@@ -85,6 +86,17 @@ void ChatView::initialise(const TelepathyChatInfo &chatInfo)
     templateHtml.replace("%footer%", m_chatStyle->getFooterHtml());
 
     setHtml(templateHtml);
+
+
+    //hidden HTML debugging mode. Should have no visible way to turn it on.
+    if (m_webInspector) {
+        QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+        QWebInspector* inspector = new QWebInspector(0);
+        inspector->setPage(page());
+        inspector->show();
+    }
+
+
 }
 
 
diff --git a/lib/chatview.h b/lib/chatview.h
index 5446773..8513436 100644
--- a/lib/chatview.h
+++ b/lib/chatview.h
@@ -51,6 +51,8 @@ private:
 
     void appendNewMessage(QString);
     void appendNextMessage(QString);
+
+    bool m_webInspector;
 };
 
 #endif // CHATVIEW_H
diff --git a/lib/chatwindow.cpp b/lib/chatwindow.cpp
index 8bc5f36..a9f7235 100644
--- a/lib/chatwindow.cpp
+++ b/lib/chatwindow.cpp
@@ -21,6 +21,8 @@
 #include "ui_chatwindow.h"
 #include "telepathychatmessageinfo.h"
 #include "telepathychatinfo.h"
+#include "channelcontactlist.h"
+
 #include <QKeyEvent>
 
 
@@ -38,6 +40,7 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
     //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)));
@@ -136,11 +139,57 @@ void ChatWindow::updateChatStatus(Tp::ContactPtr contact, ChannelChatState state
     case ChannelChatStateComposing:
         ui->statusLabel->setText(i18n("%1 is typing a message").arg(contact->alias()));
     }
+}
+
+
+
+void ChatWindow::onContactPresenceChange(Tp::ContactPtr contact, uint type)
+{
+    QString message;
+    bool isYou = (contact.data() == m_chatConnection->channel()->groupSelfContact().data());
+
+    switch (type) {
+    case Tp::ConnectionPresenceTypeOffline:
+        if (! isYou) {
+            message = i18n("%1 is offline").arg(contact->alias());
+        } else {
+            message = i18n("You are now marked as offline");
+        }
+        break;
+    case Tp::ConnectionPresenceTypeAvailable:
+        if (! isYou) {
+            message = i18n("%1 is online").arg(contact->alias());
+        } else {
+            message = i18n("You are now marked as online");
+        }
+        break;
+    case Tp::ConnectionPresenceTypeAway:
+        if (! isYou) {
+            message = i18n("%1 is busy").arg(contact->alias());
+        } else {
+            message = i18n("You are now marked as busy");
+        }
+        break;
+    default:
+        /*Do nothing*/
+        ;
+    }
+
+    if (!message.isNull()) {
+        TelepathyChatMessageInfo statusMessage(TelepathyChatMessageInfo::Status);
+        statusMessage.setMessage(message);
+        ui->chatArea->addMessage(statusMessage);
+    }
 
 }
 
 void ChatWindow::updateEnabledState(bool enable)
 {
+    //channel is now valid, start keeping track of contacts.
+    ChannelContactList* contactList = new ChannelContactList(m_chatConnection->channel(), this);
+    connect(contactList, SIGNAL(contactPresenceChanged(Tp::ContactPtr, uint)), SLOT(onContactPresenceChange(Tp::ContactPtr, uint)));
+
+    //update GUI
     ui->sendMessageBox->setEnabled(enable);
     ui->sendMessageButton->setEnabled(enable);
 
diff --git a/lib/chatwindow.h b/lib/chatwindow.h
index 605a205..ed8c48c 100644
--- a/lib/chatwindow.h
+++ b/lib/chatwindow.h
@@ -68,6 +68,7 @@ protected slots:
 
     void updateChatStatus(Tp::ContactPtr contact, ChannelChatState state);
 
+    void onContactPresenceChange(Tp::ContactPtr, uint type);
 
     void chatViewReady();
 

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list