summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-09-18 20:58:48 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-01 11:38:56 (GMT)
commit5a91a3ef54c00a6d4d960725f2ff84b5e0c43cab (patch)
treede73910e121edc91f6eec2a9af863b7be8d352e3 /Swift/Controllers/Chat/ChatController.cpp
parent5166d2def025a4fb1e3c4a723d90dc82669b36ee (diff)
downloadswift-5a91a3ef54c00a6d4d960725f2ff84b5e0c43cab.zip
swift-5a91a3ef54c00a6d4d960725f2ff84b5e0c43cab.tar.bz2
Use caps for enabling chat state notifications.
Resolves: #93
Diffstat (limited to 'Swift/Controllers/Chat/ChatController.cpp')
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 7fbf677..90ca7f8 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -7,12 +7,14 @@
#include "Swift/Controllers/Chat/ChatController.h"
#include <boost/bind.hpp>
+#include <stdio.h>
#include "Swiften/Avatars/AvatarManager.h"
#include "Swiften/Chat/ChatStateNotifier.h"
#include "Swiften/Chat/ChatStateMessageSender.h"
#include "Swiften/Chat/ChatStateTracker.h"
#include "Swiften/Client/StanzaChannel.h"
+#include "Swiften/Disco/EntityCapsManager.h"
#include "Swift/Controllers/UIInterfaces/ChatWindow.h"
#include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h"
#include "Swift/Controllers/NickResolver.h"
@@ -23,11 +25,14 @@ 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, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, TimerFactory* timerFactory)
+ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, TimerFactory* timerFactory, EntityCapsManager* entityCapsManager)
: ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, contact, presenceOracle, avatarManager, useDelayForLatency, eventStream, eventController, timerFactory) {
isInMUC_ = isInMUC;
lastWasPresence_ = false;
+ entityCapsManager_ = entityCapsManager;
chatStateNotifier_ = new ChatStateNotifier();
+ entityCapsManager_->onCapsChanged.connect(boost::bind(&ChatController::handleCapsChanged, this, _1));
+ handleCapsChanged(toJID_);
chatStateMessageSender_ = new ChatStateMessageSender(chatStateNotifier_, stanzaChannel, contact);
chatStateTracker_ = new ChatStateTracker();
nickResolver_ = nickResolver;
@@ -62,9 +67,19 @@ ChatController::~ChatController() {
delete chatStateTracker_;
}
+void ChatController::handleCapsChanged(const JID& jid) {
+ if (jid == toJID_) {
+ DiscoInfo::ref caps = entityCapsManager_->getCaps(toJID_);
+ bool hasCSN = caps && caps->hasFeature(ChatState::getFeatureNamespace());
+ chatStateNotifier_->setContactHas85Caps(hasCSN);
+ }
+}
+
void ChatController::setToJID(const JID& jid) {
+ chatStateNotifier_->contactJIDHasChanged();
chatStateMessageSender_->setContact(jid);
ChatControllerBase::setToJID(jid);
+ handleCapsChanged(jid);
}
bool ChatController::isIncomingMessageFromMe(boost::shared_ptr<Message>) {
@@ -77,7 +92,7 @@ void ChatController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> me
JID from = message->getFrom();
if (!from.equals(toJID_, JID::WithResource)) {
if (toJID_.equals(from, JID::WithoutResource) && toJID_.isBare()){
- toJID_ = from;
+ setToJID(from);
}
}
chatStateNotifier_->receivedMessageFromContact(message->getPayload<ChatState>());