[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Btelepathy-chat-handler=5D_/=3A_Re-establish_chat_af?=
From: Francesco Nwokeka <francesco.nwokeka () gmail ! com>
Date: 2011-04-30 17:54:00
Message-ID: 20110430175400.90DB7A60A4 () git ! kde ! org
[Download RAW message or body]
Git commit aaed121605dc91aef945d7852575765c0a1b33f5 by Francesco Nwokeka.
Committed on 30/04/2011 at 20:04.
Pushed by nwokeka into branch 'master'.
Re-establish chat after going offline and back online PART 3 of 3
Final part of bug 270725: An existing chat window/tab stops working when going \
offline and back online. When user goes offline, the chat is invalidated. If the user \
comes back online, and the previous chat window is still open, the chat with that \
contact is re-established.
BUG: 270725
REVIEW: 101260
Reviewed by: David Edmundson
M +17 -3 app/chat-tab.cpp
M +6 -1 app/chat-tab.h
M +6 -5 app/chat-window.cpp
M +2 -2 app/chat-window.h
M +1 -3 app/telepathy-chat-ui.cpp
M +9 -1 lib/chat-widget.cpp
M +4 -1 lib/chat-widget.h
http://commits.kde.org/telepathy-chat-handler/aaed121605dc91aef945d7852575765c0a1b33f5
diff --git a/app/chat-tab.cpp b/app/chat-tab.cpp
index 8f5226e..23c912e 100644
--- a/app/chat-tab.cpp
+++ b/app/chat-tab.cpp
@@ -26,11 +26,17 @@
#include <QStackedWidget>
#include <KDE/KColorScheme>
-ChatTab::ChatTab(const Tp::TextChannelPtr & channel, QWidget *parent)
- : ChatWidget(channel, parent),
- m_tabWidget(0)
+#include <TelepathyQt4/Account>
+#include <TelepathyQt4/TextChannel>
+
+ChatTab::ChatTab(const Tp::TextChannelPtr& channel, const Tp::AccountPtr& account, \
QWidget* parent) + : ChatWidget(channel, account, parent)
+ , m_tabWidget(0)
{
connect(this, SIGNAL(notificationClicked()), SLOT(showOnTop()));
+
+ // connect account connection status
+ connect(account.data(), SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)), \
this, SLOT(onConnectionStatusChanged(Tp::ConnectionStatus))); }
ChatTab::~ChatTab()
@@ -56,3 +62,11 @@ void ChatTab::showOnTop()
activateWindow();
}
+
+void ChatTab::onConnectionStatusChanged(Tp::ConnectionStatus status)
+{
+ // request a new text channel for the chat
+ if (status == Tp::ConnectionStatusConnected) {
+ account()->ensureTextChat(textChannel()->targetId());
+ }
+}
diff --git a/app/chat-tab.h b/app/chat-tab.h
index 17924cc..2175fe2 100644
--- a/app/chat-tab.h
+++ b/app/chat-tab.h
@@ -37,7 +37,7 @@ class ChatTab : public ChatWidget
Q_OBJECT
public:
- explicit ChatTab(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
+ explicit ChatTab(const Tp::TextChannelPtr &channel, const Tp::AccountPtr \
&account, QWidget *parent = 0); virtual ~ChatTab();
void setTabWidget(KTabWidget *tabWidget);
@@ -46,6 +46,11 @@ public:
public slots:
void showOnTop();
+private slots:
+ /** connect account's connection status.
+ * This re-enables open chats if user goes offline and then back online */
+ void onConnectionStatusChanged(Tp::ConnectionStatus);
+
private:
KTabWidget *m_tabWidget;
};
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 7d82066..a456e44 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -37,6 +37,7 @@
#include <KMenuBar>
#include <KLineEdit>
+#include <TelepathyQt4/Account>
#include <TelepathyQt4/TextChannel>
ChatWindow::ChatWindow()
@@ -74,12 +75,12 @@ ChatWindow::~ChatWindow()
{
}
-void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
+void ChatWindow::startChat(const Tp::TextChannelPtr &incomingTextChannel, const \
Tp::AccountPtr &account) {
// 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);
+ createNewChat(incomingTextChannel, account);
return;
}
@@ -118,7 +119,7 @@ void ChatWindow::startChat(Tp::TextChannelPtr \
incomingTextChannel)
// got new chat, create it
if (!duplicateTab) {
- createNewChat(incomingTextChannel);
+ createNewChat(incomingTextChannel, account);
}
}
@@ -262,9 +263,9 @@ void ChatWindow::showNotificationsDialog()
KNotifyConfigWidget::configure(this, "ktelepathy");
}
-void ChatWindow::createNewChat(Tp::TextChannelPtr channelPtr)
+void ChatWindow::createNewChat(const Tp::TextChannelPtr &channelPtr, const \
Tp::AccountPtr &accountPtr) {
- ChatTab *chatTab = new ChatTab(channelPtr, m_tabWidget);
+ ChatTab *chatTab = new ChatTab(channelPtr, accountPtr, m_tabWidget);
setupChatTabSignals(chatTab);
chatTab->setTabWidget(m_tabWidget);
m_tabWidget->addTab(chatTab, chatTab->icon(), chatTab->title());
diff --git a/app/chat-window.h b/app/chat-window.h
index ebbcca9..62ccdd5 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -41,7 +41,7 @@ public:
* chat doesn't already exist
* @param incomingTextChannel new text channel
*/
- void startChat(Tp::TextChannelPtr incomingTextChannel);
+ void startChat(const Tp::TextChannelPtr &incomingTextChannel, const \
Tp::AccountPtr &account); void removeTab(ChatTab *chatWidget);
void setTabText(int index, const QString &newTitle);
void setTabIcon(int index, const KIcon &newIcon);
@@ -68,7 +68,7 @@ private:
/** creats a new chat and adds it to the tab widget
* @param channelPtr pointer to textChannel to use
*/
- void createNewChat(Tp::TextChannelPtr channelPtr);
+ void createNewChat(const Tp::TextChannelPtr &channelPtr, const Tp::AccountPtr \
&account);
/** connects the neccessary chat tab signals with slots in chatwindow
* @param chatTab chatTab object to connect
diff --git a/app/telepathy-chat-ui.cpp b/app/telepathy-chat-ui.cpp
index 5473394..1d013a4 100644
--- a/app/telepathy-chat-ui.cpp
+++ b/app/telepathy-chat-ui.cpp
@@ -54,8 +54,6 @@ void TelepathyChatUi::handleChannels(const \
Tp::MethodInvocationContextPtr<> & co const Tp::AbstractClientHandler::HandlerInfo & \
handlerInfo) {
kDebug();
-
- Q_UNUSED(account);
Q_UNUSED(connection);
Q_UNUSED(requestsSatisfied);
Q_UNUSED(userActionTime);
@@ -72,7 +70,7 @@ void TelepathyChatUi::handleChannels(const \
Tp::MethodInvocationContextPtr<> & co Q_ASSERT(textChannel);
// create new chat
- m_chatWindow->startChat(textChannel);
+ m_chatWindow->startChat(textChannel, account);
m_chatWindow->show();
context->setFinished();
}
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 148f4e4..d8ff9c7 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -37,6 +37,7 @@
#include <KColorScheme>
#include <KLineEdit>
+#include <TelepathyQt4/Account>
#include <TelepathyQt4/Message>
#include <TelepathyQt4/Types>
#include <TelepathyQt4/AvatarData>
@@ -106,6 +107,7 @@ public:
int unreadMessages;
QString title;
Tp::TextChannelPtr channel;
+ Tp::AccountPtr account;
Ui::ChatWidget ui;
KIcon icon;
ChannelContactModel *contactModel;
@@ -121,11 +123,12 @@ KComponentData ChatWidgetPrivate::telepathyComponentData()
return KComponentData(telepathySharedAboutData);
}
-ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent)
+ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr \
&account, QWidget *parent) : QWidget(parent),
d(new ChatWidgetPrivate)
{
d->channel = channel;
+ d->account = account;
d->chatviewlInitialised = false;
d->showFormatToolbarAction = new QAction(i18n("Show format options"), this);
@@ -261,6 +264,11 @@ void ChatWidget::resizeEvent(QResizeEvent *e)
QWidget::resizeEvent(e);
}
+Tp::AccountPtr ChatWidget::account() const
+{
+ return d->account;
+}
+
KIcon ChatWidget::icon() const
{
//normal chat - self and one other person.
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 0a4cb1a..feacc7b 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -41,9 +41,12 @@ class KDE_TELEPATHY_CHAT_EXPORT ChatWidget : public QWidget
Q_OBJECT
public:
- explicit ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
+ explicit ChatWidget(const Tp::TextChannelPtr &channel, const Tp::AccountPtr \
&account, QWidget *parent = 0); virtual ~ChatWidget();
+ /** Returns pointer to account used for chat */
+ Tp::AccountPtr account() const;
+
/** Returns the icon of this chat window */
KIcon icon() const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic