summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-02-10 11:14:50 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-02-10 11:14:50 (GMT)
commit4d0c1d3b8a40cb74cfb30ed27a294afaa6ced56f (patch)
tree63ce3df61e88f27ed183d373e3496d8f56af7fb1 /Swift/Controllers/ChatController.cpp
parent936f7ff9b80aca95040301a4b3cfcd2a248e3334 (diff)
downloadswift-4d0c1d3b8a40cb74cfb30ed27a294afaa6ced56f.zip
swift-4d0c1d3b8a40cb74cfb30ed27a294afaa6ced56f.tar.bz2
Move the Chat stuff in Controllers into Chat folder.
It was starting to get a bit unwieldly in Controllers/
Diffstat (limited to 'Swift/Controllers/ChatController.cpp')
-rw-r--r--Swift/Controllers/ChatController.cpp72
1 files changed, 0 insertions, 72 deletions
diff --git a/Swift/Controllers/ChatController.cpp b/Swift/Controllers/ChatController.cpp
deleted file mode 100644
index c4f45d8..0000000
--- a/Swift/Controllers/ChatController.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "Swift/Controllers/ChatController.h"
-
-#include <boost/bind.hpp>
-
-#include "Swiften/Avatars/AvatarManager.h"
-#include "Swift/Controllers/UIInterfaces/ChatWindow.h"
-#include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h"
-#include "Swift/Controllers/NickResolver.h"
-
-namespace Swift {
-
-/**
- * The controller does not gain ownership of the stanzaChannel, nor the factory.
- */
-ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager)
- : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, contact, presenceOracle, avatarManager) {
- nickResolver_ = nickResolver;
- presenceOracle_->onPresenceChange.connect(boost::bind(&ChatController::handlePresenceChange, this, _1, _2));
- chatWindow_->setName(nickResolver_->jidToNick(toJID_));
-}
-
-bool ChatController::isIncomingMessageFromMe(boost::shared_ptr<Message>) {
- return false;
-}
-
-void ChatController::preHandleIncomingMessage(boost::shared_ptr<Message> message) {
- JID from = message->getFrom();
- if (!from.equals(toJID_, JID::WithResource)) {
- if (toJID_.equals(from, JID::WithoutResource) && toJID_.isBare()){
- toJID_ = from;
- }
- }
-}
-
-void ChatController::postSendMessage(const String& body) {
- addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), String(avatarManager_->getAvatarPath(selfJID_).string()));
-}
-
-String ChatController::senderDisplayNameFromMessage(const JID& from) {
- return nickResolver_->jidToNick(from);
-}
-
-String ChatController::getStatusChangeString(boost::shared_ptr<Presence> presence) {
- String nick = senderDisplayNameFromMessage(presence->getFrom());
- if (presence->getType() == Presence::Unavailable) {
- return nick + " has gone offline.";
- } else if (presence->getType() == Presence::Available) {
- StatusShow::Type show = presence->getShow();
- if (show == StatusShow::Online || show == StatusShow::FFC) {
- return nick + " has become available.";
- } else if (show == StatusShow::Away || show == StatusShow::XA) {
- return nick + " has gone away.";
- } else if (show == StatusShow::DND) {
- return nick + " is now busy.";
- }
- }
-
- return "";
-}
-
-void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> previousPresence) {
- if (!(toJID_.isBare() && newPresence->getFrom().equals(toJID_, JID::WithoutResource)) && newPresence->getFrom() != toJID_) {
- return;
- }
- String newStatusChangeString = getStatusChangeString(newPresence);
- if (!previousPresence || newStatusChangeString != getStatusChangeString(previousPresence)) {
- chatWindow_->addSystemMessage(newStatusChangeString);
- }
-}
-
-
-}