From 60823cd43ea17d8e06f3ae4a06f3c92d71fb00e5 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Mon, 26 Sep 2011 16:06:54 +0100
Subject: Set/Update empty subjects

Resolves: #1000

diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index c61479c..83f66a3 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -509,7 +509,7 @@ void ChatsManager::handleSearchMUCRequest() {
 void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) {
 	JID jid = message->getFrom();
 	boost::shared_ptr<MessageEvent> event(new MessageEvent(message));
-	if (!event->isReadable() && !message->getPayload<ChatState>() && message->getSubject().empty()) {
+	if (!event->isReadable() && !message->getPayload<ChatState>() && !message->hasSubject()) {
 		return;
 	}
 
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index ca1509e..8fcef8c 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -340,7 +340,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes
 	receivedActivity();
 	joined_ = true;
 
-	if (!message->getSubject().empty() && message->getBody().empty()) {
+	if (message->hasSubject() && message->getBody().empty()) {
 		chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject()));;
 		chatWindow_->setSubject(message->getSubject());
 		doneGettingHistory_ = true;
diff --git a/Swiften/Elements/Message.h b/Swiften/Elements/Message.h
index 19e3fbb..3b9145c 100644
--- a/Swiften/Elements/Message.h
+++ b/Swiften/Elements/Message.h
@@ -38,6 +38,10 @@ namespace Swift {
 				updatePayload(boost::make_shared<Subject>(subject));
 			}
 
+			bool hasSubject() {
+				return getPayload<Subject>();
+			}
+
 			std::string getBody() const { 
 				boost::shared_ptr<Body> body(getPayload<Body>());
 				if (body) {
-- 
cgit v0.10.2-6-g49f6