[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:04 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=89fa4d8
The following commit has been merged in the master branch:
commit 89fa4d8c8195fd0840d22ac090fab9a8b86c2204
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sat Aug 7 17:37:38 2010 +0000
handle message state changes
svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1160299
---
app/mainwindow.cpp | 1 -
config/CMakeLists.txt | 2 +-
config/mainwindow.cpp | 3 +--
lib/chatview.cpp | 12 ++++++----
lib/chatwindow.cpp | 48 +++++++++++++++++++++++++++++-----------
lib/chatwindow.h | 11 +++++----
lib/chatwindow.ui | 2 +-
lib/chatwindowstyle.cpp | 10 ---------
lib/telepathychatmessageinfo.cpp | 3 ++-
lib/telepathychatmessageinfo.h | 35 ++++++++++++++++++++++++-----
10 files changed, 84 insertions(+), 43 deletions(-)
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index 5e4055b..06facc2 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -37,7 +37,6 @@ MainWindow::MainWindow() :
{
}
-
void MainWindow::handleChannels(const MethodInvocationContextPtr<> &context,
const AccountPtr & account,
const ConnectionPtr & connection,
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index ba92b1e..f9f2192 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/chatwindowstyle.cpp
../lib/chatwindowstylemanager.cpp
+ ../lib/chatwindowstyle.cpp
../lib/chatview.cpp
../lib/telepathychatmessageinfo.cpp
../lib/telepathychatinfo.cpp
diff --git a/config/mainwindow.cpp b/config/mainwindow.cpp
index 938eb90..888098c 100644
--- a/config/mainwindow.cpp
+++ b/config/mainwindow.cpp
@@ -34,9 +34,8 @@ MainWindow::MainWindow(QWidget *parent) :
//add a fake message
//in my head Bob Marley is quite a chatty friendly guy...
- TelepathyChatMessageInfo message;
+ TelepathyChatMessageInfo message(TelepathyChatMessageInfo::RemoteToLocal);
message.setMessage("Hello, how are things?");
- message.setMessageDirection("rtl");
message.setSenderDisplayName("BobMarley at yahoo.com");
message.setSenderScreenName("Bob Marley");
message.setService("Jabber");
diff --git a/lib/chatview.cpp b/lib/chatview.cpp
index 45584c6..ac75630 100644
--- a/lib/chatview.cpp
+++ b/lib/chatview.cpp
@@ -100,13 +100,17 @@ void ChatView::addMessage(TelepathyChatMessageInfo & message)
//Gone with the Kopete way, but the Adium way is probably worth at least considering. (the latter allows for sexy theme animations)
QString styleHtml;
- if(message.messageDirection() == QString("rtl")) //such a hack.. put some sort of enum in the chatmessageinfoclass for type
+ switch(message.type())
{
+ case TelepathyChatMessageInfo::RemoteToLocal:
styleHtml= m_chatStyle->getIncomingHtml();
- }
- else
- {
+ break;
+ case TelepathyChatMessageInfo::LocalToRemote:
styleHtml = m_chatStyle->getOutgoingHtml();
+ break;
+ case TelepathyChatMessageInfo::Status:
+ styleHtml = m_chatStyle->getStatusHtml();
+ break;
}
QString messageHtml = m_emoticons.theme().parseEmoticons(message.message());
diff --git a/lib/chatwindow.cpp b/lib/chatwindow.cpp
index d445c67..8bf76dd 100644
--- a/lib/chatwindow.cpp
+++ b/lib/chatwindow.cpp
@@ -28,10 +28,11 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
QWidget(parent),
ui(new Ui::ChatWindow),
m_chatConnection(chat),
- m_initialised(false)
+ m_channelInitialised(false)
{
- ui->setupUi(this);
- // //updateEnabledState(m_clientHandler->isChannelReady());
+ ui->setupUi(this);
+ ui->statusLabel->setText("");
+
updateEnabledState(false);
//chat connection lifespan should be same as the chatwindow
@@ -71,29 +72,25 @@ void ChatWindow::changeEvent(QEvent *e)
void ChatWindow::handleIncomingMessage(const Tp::ReceivedMessage &message)
{
- if(m_initialised)
+ if(m_channelInitialised)
{
- TelepathyChatMessageInfo messageInfo;
+ TelepathyChatMessageInfo messageInfo(TelepathyChatMessageInfo::RemoteToLocal);
messageInfo.setMessage(message.text());
- //messageInfo.setSenderScreenName(message.sender()->id());
+ messageInfo.setSenderScreenName(message.sender()->id());
messageInfo.setTime(message.received());
- messageInfo.setMessageDirection("rtl");
messageInfo.setSenderDisplayName(message.sender()->alias());
ui->chatArea->addMessage(messageInfo);
-
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*/
{
- TelepathyChatMessageInfo messageInfo;
+ TelepathyChatMessageInfo messageInfo(TelepathyChatMessageInfo::LocalToRemote);
messageInfo.setMessage(message.text());
messageInfo.setTime(message.sent());
- messageInfo.setMessageDirection("ltr");
messageInfo.setSenderDisplayName(m_chatConnection->account()->displayName());
-// messageInfo.setSenderDisplayName(m_chatConnection->connection()->selfContact()->alias()); // selfConect() can return 0 watch out for that.
ui->chatArea->addMessage(messageInfo);
}
@@ -108,7 +105,28 @@ void ChatWindow::sendMessage()
void ChatWindow::updateChatStatus(Tp::ContactPtr contact, ChannelChatState state)
{
- qDebug() << contact->alias() << state;
+ switch (state)
+ {
+ case ChannelChatStateGone:
+ {
+ TelepathyChatMessageInfo statusMessage(TelepathyChatMessageInfo::Status);
+ statusMessage.setMessage(i18n("%1 has left the chat").arg(contact->alias()));
+ ui->chatArea->addMessage(statusMessage);
+ }
+ break;
+ case ChannelChatStateInactive:
+ //FIXME send a 'chat timed out' message to chatview
+ break;
+ case ChannelChatStateActive:
+ //This is the normal state.
+ ui->statusLabel->setText("");
+ case ChannelChatStatePaused:
+ //not sure what this means..safest to do nothing.
+ break;
+ case ChannelChatStateComposing:
+ ui->statusLabel->setText(i18n("%1 is typing a message").arg(contact->alias()));
+ }
+
}
void ChatWindow::updateEnabledState(bool enable)
@@ -138,6 +156,7 @@ void ChatWindow::updateEnabledState(bool enable)
info.setDestinationName(it->id());
info.setChatName(it->alias());
info.setIncomingIconPath(it->avatarToken());
+
}
}
}
@@ -152,7 +171,10 @@ void ChatWindow::updateEnabledState(bool enable)
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;
+ m_channelInitialised = true;
+
+ //inform anyone using the class of the new name for this chat.
+ Q_EMIT titleChanged(info.chatName());
//process any messages we've 'missed' whilst initialising.
foreach(Tp::ReceivedMessage message, m_chatConnection->channel()->messageQueue())
diff --git a/lib/chatwindow.h b/lib/chatwindow.h
index f97c7b7..d7908a8 100644
--- a/lib/chatwindow.h
+++ b/lib/chatwindow.h
@@ -60,8 +60,6 @@ protected slots:
/** Show the message sent in the chat window*/
void handleMessageSent(const Tp::Message &message, Tp::MessageSendingFlags flags, const QString &sentMessageToken);
- /** If state == composing, update status bar*/
-
/** send the text in the text area widget to the client handler*/
void sendMessage();
@@ -70,12 +68,17 @@ protected slots:
void updateChatStatus(Tp::ContactPtr contact, ChannelChatState state);
+signals:
+ void titleChanged(QString title);
+
private:
Ui::ChatWindow *ui;
ChatConnection* m_chatConnection;
- //mark as true when the chat window has been set up.
- bool m_initialised;
+ /** Stores whether the channel is ready with all contacts upgraded*/
+ bool m_channelInitialised;
+
+
MessageBoxEventFilter* messageBoxEventFilter;
};
diff --git a/lib/chatwindow.ui b/lib/chatwindow.ui
index 437f053..0dc4ddf 100644
--- a/lib/chatwindow.ui
+++ b/lib/chatwindow.ui
@@ -28,7 +28,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="statusLabel">
<property name="text">
<string>TextLabel</string>
</property>
diff --git a/lib/chatwindowstyle.cpp b/lib/chatwindowstyle.cpp
index ebdd006..3e1a8fb 100644
--- a/lib/chatwindowstyle.cpp
+++ b/lib/chatwindowstyle.cpp
@@ -264,7 +264,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->headerHtml = headerStream.readAll();
- kDebug(14000) << "Header HTML: " << d->headerHtml;
fileAccess.close();
}
// Load Footer file
@@ -275,7 +274,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->footerHtml = headerStream.readAll();
- kDebug(14000) << "Footer HTML: " << d->footerHtml;
fileAccess.close();
}
// Load incoming file
@@ -286,7 +284,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->incomingHtml = headerStream.readAll();
- kDebug(14000) << "Incoming HTML: " << d->incomingHtml;
fileAccess.close();
}
// Load next Incoming file
@@ -297,7 +294,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->nextIncomingHtml = headerStream.readAll();
- kDebug(14000) << "NextIncoming HTML: " << d->nextIncomingHtml;
fileAccess.close();
}
// Load outgoing file
@@ -308,7 +304,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->outgoingHtml = headerStream.readAll();
- kDebug(14000) << "Outgoing HTML: " << d->outgoingHtml;
fileAccess.close();
}
// Load next outgoing file
@@ -319,7 +314,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->nextOutgoingHtml = headerStream.readAll();
- kDebug(14000) << "NextOutgoing HTML: " << d->nextOutgoingHtml;
fileAccess.close();
}
// Load status file
@@ -330,7 +324,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->statusHtml = headerStream.readAll();
- kDebug(14000) << "Status HTML: " << d->statusHtml;
fileAccess.close();
}
@@ -342,7 +335,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->actionIncomingHtml = headerStream.readAll();
- kDebug(14000) << "ActionIncoming HTML: " << d->actionIncomingHtml;
fileAccess.close();
}
// Load Action Outgoing file
@@ -353,7 +345,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->actionOutgoingHtml = headerStream.readAll();
- kDebug(14000) << "ActionOutgoing HTML: " << d->actionOutgoingHtml;
fileAccess.close();
}
// Load FileTransfer Incoming file
@@ -364,7 +355,6 @@ void ChatWindowStyle::readStyleFiles()
QTextStream headerStream(&fileAccess);
headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
d->fileTransferIncomingHtml = headerStream.readAll();
- kDebug(14000) << "fileTransferIncoming HTML: " << d->fileTransferIncomingHtml;
fileAccess.close();
}
diff --git a/lib/telepathychatmessageinfo.cpp b/lib/telepathychatmessageinfo.cpp
index 3b95820..5f53c12 100644
--- a/lib/telepathychatmessageinfo.cpp
+++ b/lib/telepathychatmessageinfo.cpp
@@ -21,6 +21,7 @@
//can probably delete this file. I put it all in the header.
-TelepathyChatMessageInfo::TelepathyChatMessageInfo()
+TelepathyChatMessageInfo::TelepathyChatMessageInfo(MessageType type)
{
+ m_type = type;
}
diff --git a/lib/telepathychatmessageinfo.h b/lib/telepathychatmessageinfo.h
index 4f67d00..a9c0837 100644
--- a/lib/telepathychatmessageinfo.h
+++ b/lib/telepathychatmessageinfo.h
@@ -36,10 +36,25 @@
class TelepathyChatMessageInfo
{
+
+
public:
- TelepathyChatMessageInfo();
+ enum MessageType
+ {
+ RemoteToLocal,
+ LocalToRemote,
+ Status
+ };
+
+ TelepathyChatMessageInfo(MessageType);
+
+
+ //FIXME HTML escape all QString returns.
//bother. I've documented the private stuff. I meant to do the getters + setters. Can't be bothered to move it now. I'm too sleepy.
+
+ MessageType type() const {return m_type;}
+
QString message() const {return m_message;}
void setMessage(const QString message) {m_message = message;}
@@ -55,8 +70,17 @@ public:
QString senderScreenName() const {return m_senderScreenName;}
void setSenderScreenName(const QString senderScreenName) {m_senderScreenName = senderScreenName;}
- QString messageDirection() const {return m_messageDirection;}
- void setMessageDirection(const QString messageDirection) {m_messageDirection = messageDirection;}
+ /** The text direction of the message (either rtl or ltr) */
+ QString messageDirection() const {
+ if (m_type == LocalToRemote)
+ {
+ return "ltr";
+ }
+ else
+ {
+ return "rtl";
+ }
+ }
QString senderDisplayName() const {return m_senderDisplayName;}
void setSenderDisplayName(const QString senderDisplayName) {m_senderDisplayName = senderDisplayName;}
@@ -69,6 +93,8 @@ private:
//both status messages and regular messages
+ MessageType m_type;
+
/** The message itself of the message/status*/
QString m_message;
@@ -102,9 +128,6 @@ private:
/** The path to the status icon of the sender (available, away, etc...) */
QUrl m_senderStatusIcon;
- //FIXME enum this.
- QString m_messageDirection;
-
/** The serverside (remotely set) name of the sender, such as an MSN display name.*/
QString m_senderDisplayName;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list