summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-07-01 08:50:37 (GMT)
committerCătălin Badea <catalin.badea392@gmail.com>2012-08-11 15:52:57 (GMT)
commite9c0208eb6800538eeb9664737cf88c9dae933e0 (patch)
tree8a7e0ef377ab83bb8cd960a537c070810762993f
parente117ec6c534e1b6bc3f1bcd18dadf2005672c38b (diff)
downloadswift-contrib-e9c0208eb6800538eeb9664737cf88c9dae933e0.zip
swift-contrib-e9c0208eb6800538eeb9664737cf88c9dae933e0.tar.bz2
Don't log outgoing MUC messages
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp6
-rw-r--r--Swift/Controllers/Chat/ChatController.h1
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp11
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.h3
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp7
-rw-r--r--Swift/Controllers/Chat/MUCController.h1
6 files changed, 20 insertions, 9 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index e81cfe9..b0413af 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -353,4 +353,10 @@ boost::optional<boost::posix_time::ptime> ChatController::getMessageTimestamp(bo
return message->getTimestamp();
}
+void ChatController::logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) {
+ if (historyController_) {
+ historyController_->addMessage(message, fromJID, toJID, timeStamp);
+ }
+}
+
}
diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h
index ffb989c..daf687d 100644
--- a/Swift/Controllers/Chat/ChatController.h
+++ b/Swift/Controllers/Chat/ChatController.h
@@ -35,6 +35,7 @@ namespace Swift {
protected:
void cancelReplaces();
JID getBaseJID();
+ void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming);
private:
void handlePresenceChange(boost::shared_ptr<Presence> newPresence);
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index 9d797e0..4dc4006 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -30,7 +30,6 @@
#include <Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h>
#include <Swiften/Avatars/AvatarManager.h>
#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h>
-#include <Swift/Controllers/HistoryController.h>
namespace Swift {
@@ -147,10 +146,7 @@ void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool
postSendMessage(message->getBody(), boost::dynamic_pointer_cast<Stanza>(message));
onActivity(message->getBody());
- // log message
- if (historyController_) {
- historyController_->addMessage(body, selfJID_, toJID_, now);
- }
+ logMessage(body, selfJID_, toJID_, now, false);
}
void ChatControllerBase::handleSecurityLabelsCatalogResponse(boost::shared_ptr<SecurityLabelsCatalog> catalog, ErrorPayload::ref error) {
@@ -257,10 +253,9 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m
}
else {
lastMessagesUIID_[from] = addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), label, std::string(avatarManager_->getAvatarPath(from).string()), timeStamp);
- if (historyController_) {
- historyController_->addMessage(body, from, selfJID_, timeStamp);
- }
}
+
+ logMessage(body, from, selfJID_, timeStamp, true);
}
chatWindow_->show();
chatWindow_->setUnreadMessageCount(unreadMessages_.size());
diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h
index aa3246e..4e7a1da 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.h
+++ b/Swift/Controllers/Chat/ChatControllerBase.h
@@ -27,6 +27,7 @@
#include "Swiften/Presence/PresenceOracle.h"
#include "Swiften/Queries/IQRouter.h"
#include "Swiften/Base/IDGenerator.h"
+#include <Swift/Controllers/HistoryController.h>
namespace Swift {
class IQRouter;
@@ -37,7 +38,6 @@ namespace Swift {
class UIEventStream;
class EventController;
class EntityCapsProvider;
- class HistoryController;
class ChatControllerBase : public boost::bsignals::trackable {
public:
@@ -79,6 +79,7 @@ namespace Swift {
virtual void cancelReplaces() = 0;
/** JID any iq for account should go to - bare except for PMs */
virtual JID getBaseJID();
+ virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) = 0;
private:
IDGenerator idGenerator_;
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index af5559e..222fb01 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -780,4 +780,11 @@ void MUCController::handleAffiliationListReceived(MUCOccupant::Affiliation affil
chatWindow_->setAffiliations(affiliation, jids);
}
+void MUCController::logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) {
+ // log only incoming messages
+ if (isIncoming && historyController_) {
+ historyController_->addMessage(message, fromJID, toJID, timeStamp);
+ }
+}
+
}
diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h
index 1348064..41393cd 100644
--- a/Swift/Controllers/Chat/MUCController.h
+++ b/Swift/Controllers/Chat/MUCController.h
@@ -64,6 +64,7 @@ namespace Swift {
void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>);
void postHandleIncomingMessage(boost::shared_ptr<MessageEvent>);
void cancelReplaces();
+ void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming);
private:
void setAvailableRoomActions(const MUCOccupant::Affiliation& affiliation, const MUCOccupant::Role& role);