summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-07-25 20:15:31 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-07-25 20:15:31 (GMT)
commit719127a8772f921fdba3169b449a4407143c8c45 (patch)
tree143db01c914c14d5f5261393a8f2de4ecc18866b
parent501989d4b371c850a1c5a0350ca3f1c4900305f4 (diff)
downloadswift-719127a8772f921fdba3169b449a4407143c8c45.zip
swift-719127a8772f921fdba3169b449a4407143c8c45.tar.bz2
Preparation for merging presences in the chat log.
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp2
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp4
-rw-r--r--Swift/Controllers/UIInterfaces/ChatWindow.h1
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h1
-rw-r--r--Swift/QtUI/QtChatWindow.cpp20
-rw-r--r--Swift/QtUI/QtChatWindow.h2
6 files changed, 26 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 3012377..d9524da 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -113,7 +113,7 @@ void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresenc
chatStateTracker_->handlePresenceChange(newPresence, previousPresence);
String newStatusChangeString = getStatusChangeString(newPresence);
if (!previousPresence || newStatusChangeString != getStatusChangeString(previousPresence)) {
- chatWindow_->addSystemMessage(newStatusChangeString);
+ chatWindow_->addPresenceMessage(newStatusChangeString);
}
}
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 405272e..1ea0ad1 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -178,7 +178,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) {
}
joinString += ".";
- chatWindow_->addSystemMessage(joinString);
+ chatWindow_->addPresenceMessage(joinString);
}
if (avatarManager_ != NULL) {
handleAvatarChanged(jid, "dummy");
@@ -266,7 +266,7 @@ void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::Leaving
partMessage += " (" + reason + ")";
}
partMessage += ".";
- chatWindow_->addSystemMessage(partMessage);
+ chatWindow_->addPresenceMessage(partMessage);
if (occupant.getNick() != nick_) {
roster_->removeContact(JID(toJID_.getNode(), toJID_.getDomain(), occupant.getNick()));
} else {
diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h
index 50a0b39..79c7d65 100644
--- a/Swift/Controllers/UIInterfaces/ChatWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatWindow.h
@@ -31,6 +31,7 @@ namespace Swift {
virtual void addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) = 0;
virtual void addAction(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) = 0;
virtual void addSystemMessage(const String& message) = 0;
+ virtual void addPresenceMessage(const String& message) = 0;
virtual void addErrorMessage(const String& message) = 0;
virtual void setContactChatState(ChatState::ChatStateType state) = 0;
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index ff61bf6..4985cbb 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -18,6 +18,7 @@ namespace Swift {
virtual void addAction(const String& message, const String& /*senderName*/, bool /*senderIsSelf*/, const boost::optional<SecurityLabel>& /*label*/, const String& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message;};
virtual void addSystemMessage(const String& /*message*/) {};
virtual void addErrorMessage(const String& /*message*/) {};
+ virtual void addPresenceMessage(const String& /*message*/) {};
virtual void setContactChatState(ChatState::ChatStateType /*state*/) {};
virtual void setName(const String& name) {name_ = name;};
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index fdf1ebc..a0b25a9 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -28,7 +28,7 @@
#include <QUrl>
namespace Swift {
-QtChatWindow::QtChatWindow(const QString &contact, UIEventStream* eventStream) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageWasSystem_(false), eventStream_(eventStream) {
+QtChatWindow::QtChatWindow(const QString &contact, UIEventStream* eventStream) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageWasSystem_(false), previousMessageWasPresence_(false), eventStream_(eventStream) {
unreadCount_ = 0;
inputEnabled_ = true;
completer_ = NULL;
@@ -268,6 +268,7 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b
previousMessageWasSelf_ = senderIsSelf;
previousSenderName_ = P2QSTRING(senderName);
previousMessageWasSystem_ = false;
+ previousMessageWasPresence_ = false;
}
int QtChatWindow::getCount() {
@@ -289,6 +290,7 @@ void QtChatWindow::addErrorMessage(const String& errorMessage) {
previousMessageWasSelf_ = false;
previousMessageWasSystem_ = true;
+ previousMessageWasPresence_ = false;
}
void QtChatWindow::addSystemMessage(const String& message) {
@@ -302,8 +304,24 @@ void QtChatWindow::addSystemMessage(const String& message) {
previousMessageWasSelf_ = false;
previousMessageWasSystem_ = true;
+ previousMessageWasPresence_ = false;
}
+void QtChatWindow::addPresenceMessage(const String& message) {
+ if (isWidgetSelected()) {
+ onAllMessagesRead();
+ }
+
+ QString messageHTML(Qt::escape(P2QSTRING(message)));
+ messageHTML.replace("\n","<br/>");
+ messageLog_->addMessage(SystemMessageSnippet(messageHTML, QDateTime::currentDateTime(),previousMessageWasPresence_));
+
+ previousMessageWasSelf_ = false;
+ previousMessageWasSystem_ = false;
+ previousMessageWasPresence_ = true;
+}
+
+
void QtChatWindow::returnPressed() {
if (!inputEnabled_) {
return;
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index f68ff1c..1770186 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -30,6 +30,7 @@ namespace Swift {
void addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time);
void addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time);
void addSystemMessage(const String& message);
+ void addPresenceMessage(const String& message);
void addErrorMessage(const String& errorMessage);
void show();
void activate();
@@ -81,6 +82,7 @@ namespace Swift {
std::vector<SecurityLabel> availableLabels_;
bool previousMessageWasSelf_;
bool previousMessageWasSystem_;
+ bool previousMessageWasPresence_;
QString previousSenderName_;
bool inputClearing_;
UIEventStream* eventStream_;