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


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

The following commit has been merged in the master branch:
commit 9935275fd6eb281ebd2970e57037c54b52e0a3ea
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Fri Jul 30 23:40:24 2010 +0000

    Added handling of messages sent before the text channel is initialised
    
    Further work on handling the "header" template in the chat view.
    
    
    svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1157409
---
 chatview.cpp   |  2 +-
 chatwindow.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 chatwindow.h   |  3 +++
 mainwindow.cpp |  6 ++---
 4 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/chatview.cpp b/chatview.cpp
index cebc8f8..a9624c7 100644
--- a/chatview.cpp
+++ b/chatview.cpp
@@ -97,7 +97,6 @@ void ChatView::addMessage(TelepathyChatMessageInfo & message)
     styleHtml.replace("%time%", message.time().toString());
     styleHtml.replace("%userIconPath%", "Outgoing/buddy_icon.png");// this fallback should be done in the messageinfo
 
-    qDebug() << styleHtml;
     chat.appendInside(styleHtml);
 }
 
@@ -114,6 +113,7 @@ QString ChatView::replaceHeaderKeywords(QString htmlTemplate, const TelepathyCha
     htmlTemplate.replace("%timeOpened%", info.timeOpened().toString()); //FIXME use KLocale to get format.
     //FIXME time fields - remember to do both, steal the complicated one from Kopete code.
 
+    qDebug() << htmlTemplate;
 
     return htmlTemplate;
 }
diff --git a/chatwindow.cpp b/chatwindow.cpp
index 5d23737..9ef782c 100644
--- a/chatwindow.cpp
+++ b/chatwindow.cpp
@@ -7,7 +7,8 @@
 ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
         QWidget(parent),
         ui(new Ui::ChatWindow),
-        m_chatConnection(chat)
+        m_chatConnection(chat),
+        m_initialised(false)
 {
     ui->setupUi(this);
     //  //updateEnabledState(m_clientHandler->isChannelReady());
@@ -22,10 +23,8 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
     connect(m_chatConnection->channel().data(), SIGNAL(chatStateChanged(Tp::ContactPtr, ChannelChatState)), SLOT(updateChatStatus(Tp::ContactPtr, ChannelChatState)));
     connect(ui->sendMessageButton, SIGNAL(released()), SLOT(sendMessage()));
 
-    TelepathyChatInfo info;
-    info.setChatName("cheese");
 
-    ui->chatArea->initialise(info);
+
 }
 
 ChatWindow::~ChatWindow()
@@ -50,16 +49,19 @@ void ChatWindow::changeEvent(QEvent *e)
 
 void ChatWindow::handleIncomingMessage(const Tp::ReceivedMessage &message)
 {
-    TelepathyChatMessageInfo messageInfo;
-    messageInfo.setMessage(message.text());
-    //messageInfo.setSenderScreenName(message.sender()->id());
-    messageInfo.setTime(message.received());
-    messageInfo.setMessageDirection("rtl");
-    messageInfo.setSenderDisplayName(message.sender()->alias());
+    if(m_initialised)
+    {
+        TelepathyChatMessageInfo messageInfo;
+        messageInfo.setMessage(message.text());
+        //messageInfo.setSenderScreenName(message.sender()->id());
+        messageInfo.setTime(message.received());
+        messageInfo.setMessageDirection("rtl");
+        messageInfo.setSenderDisplayName(message.sender()->alias());
 
-    ui->chatArea->addMessage(messageInfo);
+        ui->chatArea->addMessage(messageInfo);
 
-    m_chatConnection->channel()->acknowledge(QList<Tp::ReceivedMessage>() << message);
+        m_chatConnection->channel()->acknowledge(QList<Tp::ReceivedMessage>() << message);
+    }
 }
 
 void ChatWindow::handleMessageSent(const Tp::Message &message, Tp::MessageSendingFlags, const QString&) /*Not sure what these other args are for*/
@@ -86,7 +88,51 @@ void ChatWindow::updateChatStatus(Tp::ContactPtr contact, ChannelChatState state
 
 void ChatWindow::updateEnabledState(bool enable)
 {
-    qDebug() << "setting buttons to " << enable;
     ui->sendMessageBox->setEnabled(enable);
     ui->sendMessageButton->setEnabled(enable);
+
+    //set up the initial chat window details.
+    if(enable)
+    {
+        TelepathyChatInfo info;
+        Tp::Contacts allContacts = m_chatConnection->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())
+                {
+                    continue;
+                }
+                else
+                {
+                    info.setDestinationDisplayName(it->alias());
+                    info.setDestinationName(it->id());
+                    info.setChatName(it->alias());
+                    info.setIncomingIconPath(it->avatarToken());
+                }
+            }
+        }
+        else
+        {
+            //some sort of group chat scenario.. Not sure how to create this yet.
+            info.setChatName("Group Chat");
+        }
+
+        //set up anything related to 'self'
+        info.setOutgoingIconPath(m_chatConnection->channel()->groupSelfContact()->avatarToken());
+        info.setTimeOpened(QDateTime::currentDateTime()); //FIXME how do I know when the channel opened? Using current time for now.
+
+        ui->chatArea->initialise(info);
+        m_initialised = true;
+
+        //process any messages we've 'missed' whilst initialising.
+        foreach(Tp::ReceivedMessage message, m_chatConnection->channel()->messageQueue())
+        {
+            handleIncomingMessage(message);
+        }
+    }
 }
diff --git a/chatwindow.h b/chatwindow.h
index 98469c1..d3a61bf 100644
--- a/chatwindow.h
+++ b/chatwindow.h
@@ -42,6 +42,9 @@ protected slots:
 private:
     Ui::ChatWindow *ui;
     ChatConnection* m_chatConnection;
+
+    //mark as true when the chat window has been set up.
+    bool m_initialised;
 };
 
 #endif // CHATWINDOW_H
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 26e49ef..d203823 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -23,9 +23,9 @@ void MainWindow::handleChannels(const MethodInvocationContextPtr<> &context,
                                        const AccountPtr & account,
                                        const ConnectionPtr & connection,
                                        const QList< ChannelPtr > & channels,
-                                       const QList< ChannelRequestPtr > & requestsSatisfied,
-                                       const QDateTime &  userActionTime,
-                                       const QVariantMap & handlerInfo
+                                       const QList< ChannelRequestPtr > & ,
+                                       const QDateTime & ,
+                                       const QVariantMap&
                                       )
 {
     ChatConnection* chatConnection = new ChatConnection(this, account, connection, channels);

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list