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


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

The following commit has been merged in the master branch:
commit 253d5ca6273b599550d24ff49b29209fed3a947e
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Fri Apr 29 14:25:04 2011 +0200

    Re-establish chat after going offline and back online part 1
    
    this patch is in preparation for closing bug #270725.
    I basically created some setup methods for connecting the signals and slots for the textchannels, chat tab
    and the contact model of chatwidget.
    Plus the search for duplicate tabs is no longer done by matching the incomingTextChannel, but the targetId
    of the channel.
---
 app/chat-window.cpp | 65 ++++++++++++++++++++++++++++++++++++-----------------
 app/chat-window.h   | 10 +++++++++
 lib/chat-widget.cpp | 57 +++++++++++++++++++++++++++-------------------
 lib/chat-widget.h   | 13 +++++++----
 4 files changed, 97 insertions(+), 48 deletions(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index ca1778a..3d14909 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -76,43 +76,42 @@ ChatWindow::~ChatWindow()
 
 void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
 {
+    // if targetHandle is None, targetId is also "", so create new chat
+    if (incomingTextChannel->targetHandleType() == Tp::HandleTypeNone) {
+        kDebug() << "ChatWindow::startChat target handle type is HandleTypeNone";
+        createNewChat(incomingTextChannel);
+        return;
+    }
+
     bool duplicateTab = false;
 
     // check that the tab requested isn't already open
-    for(int index = 0; index < m_tabWidget->count() && !duplicateTab; index++) {
+    for (int index = 0; index < m_tabWidget->count() && !duplicateTab; ++index) {
 
         // get chatWidget object
         ChatTab *auxChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
 
         // this should never happen
-        if(!auxChatTab)
+        if (!auxChatTab) {
             return;
+        }
 
-        if(auxChatTab->textChannel() == incomingTextChannel) {   // got duplicate tab
+        // check for 1on1 duplicate chat
+        if (auxChatTab->textChannel()->targetId() == incomingTextChannel->targetId()
+        && auxChatTab->textChannel()->targetHandleType() == incomingTextChannel->targetHandleType()) {
             duplicateTab = true;
-            m_tabWidget->setCurrentIndex(index);                    // set focus on selected tab
+            m_tabWidget->setCurrentIndex(index);    // set focus on selected tab
+        } else if (auxChatTab->textChannel()->targetId() == incomingTextChannel->targetId()
+          && auxChatTab->textChannel()->targetHandleType() == Tp::HandleTypeContact) {
+            // got duplicate group chat. Wait for group handling to be sorted out
+            ///TODO sort this out once group chats are supported
+            kDebug() << "ChatWindow::startChat TODO need to implement when group chat is supported";
         }
     }
 
     // got new chat, create it
     if(!duplicateTab) {
-        ChatTab *chatTab = new ChatTab(incomingTextChannel, m_tabWidget);
-        chatTab->setTabWidget(m_tabWidget);
-        connect(chatTab, SIGNAL(titleChanged(QString)), this, SLOT(onTabTextChanged(QString)));
-        connect(chatTab, SIGNAL(iconChanged(KIcon)), this, SLOT(onTabIconChanged(KIcon)));
-        connect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onTabStateChanged()));
-        connect(chatTab, SIGNAL(unreadMessagesChanged(int)), this, SLOT(onTabStateChanged()));
-        connect(chatTab, SIGNAL(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
-        connect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
-
-        m_tabWidget->addTab(chatTab, chatTab->icon(), chatTab->title());
-        m_tabWidget->setCurrentWidget(chatTab);
-
-        if(m_tabWidget->isTabBarHidden()) {
-            if(m_tabWidget->count() > 1) {
-                m_tabWidget->setTabBarHidden(false);
-            }
-        }
+        createNewChat(incomingTextChannel);
     }
 }
 
@@ -256,4 +255,28 @@ void ChatWindow::showNotificationsDialog()
     KNotifyConfigWidget::configure(this, "ktelepathy");
 }
 
+void ChatWindow::createNewChat(Tp::TextChannelPtr channelPtr)
+{
+    ChatTab *chatTab = new ChatTab(channelPtr, m_tabWidget);
+    setupChatTabSignals(chatTab);
+    chatTab->setTabWidget(m_tabWidget);
+    m_tabWidget->addTab(chatTab, chatTab->icon(), chatTab->title());
+    m_tabWidget->setCurrentWidget(chatTab);
+
+    if (m_tabWidget->isTabBarHidden()) {
+        if (m_tabWidget->count() > 1) {
+            m_tabWidget->setTabBarHidden(false);
+        }
+    }
+}
+
+void ChatWindow::setupChatTabSignals(ChatTab *chatTab)
+{
+    connect(chatTab, SIGNAL(titleChanged(QString)), this, SLOT(onTabTextChanged(QString)));
+    connect(chatTab, SIGNAL(iconChanged(KIcon)), this, SLOT(onTabIconChanged(KIcon)));
+    connect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onTabStateChanged()));
+    connect(chatTab, SIGNAL(unreadMessagesChanged(int)), this, SLOT(onTabStateChanged()));
+    connect(chatTab, SIGNAL(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
+    connect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
+}
 #include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index 8a55655..ebbcca9 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -65,6 +65,16 @@ protected slots:
     void showNotificationsDialog();
 
 private:
+    /** creats a new chat and adds it to the tab widget
+     * @param channelPtr pointer to textChannel to use
+     */
+    void createNewChat(Tp::TextChannelPtr channelPtr);
+
+    /** connects the neccessary chat tab signals with slots in chatwindow
+     * @param chatTab chatTab object to connect
+     */
+    void setupChatTabSignals(ChatTab *chatTab);
+
     KTabWidget *m_tabWidget;
 };
 
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index b483436..ef4927c 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -108,6 +108,7 @@ public:
     Tp::TextChannelPtr channel;
     Ui::ChatWidget ui;
     KIcon icon;
+    ChannelContactModel *contactModel;
 
     KComponentData telepathyComponentData();
 };
@@ -147,14 +148,14 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent)
     d->ui.insertEmoticon->setText(QString());
     d->ui.insertEmoticon->setIcon(KIcon("face-smile"));
 
-    //channel is now valid, start keeping track of contacts.
-    ChannelContactModel* contactList = new ChannelContactModel(d->channel, this);
-    connect(contactList, SIGNAL(contactPresenceChanged(Tp::ContactPtr,Tp::Presence)),
-            SLOT(onContactPresenceChange(Tp::ContactPtr,Tp::Presence)));
-    connect(contactList, SIGNAL(contactAliasChanged(Tp::ContactPtr,QString)),
-            SLOT(onContactAliasChanged(Tp::ContactPtr,QString)));
+    // connect channel signals
+    setupChannelSignals();
+
+    // create contactModel and start keeping track of contacts.
+    d->contactModel = new ChannelContactModel(d->channel, this);
+    setupContactModelSignals();
 
-    d->ui.contactsView->setModel(contactList);
+    d->ui.contactsView->setModel(d->contactModel);
 
     AdiumThemeHeaderInfo info;
     Tp::Contacts allContacts = d->channel->groupContacts();
@@ -209,21 +210,6 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent)
     connect(d->ui.formatItalic, SIGNAL(toggled(bool)), d->ui.sendMessageBox, SLOT(setFontItalic(bool)));
     connect(d->ui.formatUnderline, SIGNAL(toggled(bool)), d->ui.sendMessageBox, SLOT(setFontUnderline(bool)));
 
-    connect(d->channel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)),
-            SLOT(handleIncomingMessage(Tp::ReceivedMessage)));
-    connect(d->channel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)),
-            SLOT(notifyAboutIncomingMessage(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,Tp::ChannelChatState)),
-            SLOT(onChatStatusChanged(Tp::ContactPtr,Tp::ChannelChatState)));
-    connect(d->channel->connection().data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
-            this, SLOT(onChannelInvalidated()));
-
-    if (d->channel->hasChatStateInterface()) {
-        connect(d->ui.sendMessageBox, SIGNAL(textChanged()), SLOT(onInputBoxChanged()));
-    }
-
     // make the sendMessageBox a focus proxy for the chatview
     d->ui.chatArea->setFocusProxy(d->ui.sendMessageBox);
 
@@ -378,6 +364,32 @@ void ChatWidget::toggleSearchBar() const
     }
 }
 
+void ChatWidget::setupChannelSignals()
+{
+    connect(d->channel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)),
+            SLOT(handleIncomingMessage(Tp::ReceivedMessage)));
+    connect(d->channel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)),
+            SLOT(notifyAboutIncomingMessage(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,Tp::ChannelChatState)),
+            SLOT(onChatStatusChanged(Tp::ContactPtr,Tp::ChannelChatState)));
+    connect(d->channel->connection().data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
+            this, SLOT(onChannelInvalidated()));
+
+    if (d->channel->hasChatStateInterface()) {
+        connect(d->ui.sendMessageBox, SIGNAL(textChanged()), SLOT(onInputBoxChanged()));
+    }
+}
+
+void ChatWidget::setupContactModelSignals()
+{
+    connect(d->contactModel, SIGNAL(contactPresenceChanged(Tp::ContactPtr,Tp::Presence)),
+            SLOT(onContactPresenceChange(Tp::ContactPtr,Tp::Presence)));
+    connect(d->contactModel, SIGNAL(contactAliasChanged(Tp::ContactPtr,QString)),
+            SLOT(onContactAliasChanged(Tp::ContactPtr,QString)));
+}
+
 void ChatWidget::incrementUnreadMessageCount()
 {
     kDebug();
@@ -406,7 +418,6 @@ void ChatWidget::resetUnreadMessageCount()
     }
 }
 
-
 bool ChatWidget::isOnTop() const
 {
     kDebug() << ( isActiveWindow() && isVisible() );
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index f357aea..f7d08d3 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -53,10 +53,10 @@ public:
     /** Returns the text channel pointer of the chatWidget */
     Tp::TextChannelPtr textChannel() const;
 
-    /** Returns the name of this chat window*/
+    /** Returns the name of this chat window */
     QString title() const;
 
-    /** Returns the suggested color for the title of the window*/
+    /** Returns the suggested color for the title of the window */
     QColor titleColor() const;
 
     int unreadMessageCount() const;
@@ -130,9 +130,14 @@ private slots:
     void windowActivated();
 
 private:
-    void resetUnreadMessageCount();
-    void incrementUnreadMessageCount();
+    /** connects neccessary signals for the channel */
+    void setupChannelSignals();
+
+    /** connects neccessary signals for the contactModel */
+    void setupContactModelSignals();
 
+    void incrementUnreadMessageCount();
+    void resetUnreadMessageCount();
     virtual bool isOnTop() const;
 
     //FIXME this should be in the ktelepathy lib

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list