summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-02-16 09:05:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-02-17 08:05:08 (GMT)
commit5a334fd9b676564a8915baad312d92bd86358eec (patch)
treeaaecbbccd9cddcb843c126b8c022f1d1e667efde /Swiften/Chat/ChatStateMessageSender.cpp
parent231c2cb6d00061e70860626467107f4c63f359a0 (diff)
downloadswift-contrib-5a334fd9b676564a8915baad312d92bd86358eec.zip
swift-contrib-5a334fd9b676564a8915baad312d92bd86358eec.tar.bz2
Preliminary Chat State Notifications support.
Only covers Active and Composing (Which is very possibly all we care about).
Diffstat (limited to 'Swiften/Chat/ChatStateMessageSender.cpp')
-rw-r--r--Swiften/Chat/ChatStateMessageSender.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Swiften/Chat/ChatStateMessageSender.cpp b/Swiften/Chat/ChatStateMessageSender.cpp
index d053cb5..ad1495f 100644
--- a/Swiften/Chat/ChatStateMessageSender.cpp
+++ b/Swiften/Chat/ChatStateMessageSender.cpp
@@ -1,5 +1,22 @@
#include "Swiften/Chat/ChatStateMessageSender.h"
+#include <boost/bind.hpp>
+
+#include "Swiften/Client/StanzaChannel.h"
+
namespace Swift {
+ChatStateMessageSender::ChatStateMessageSender(ChatStateNotifier* notifier, StanzaChannel* stanzaChannel, const JID& contact) : contact_(contact) {
+ notifier_ = notifier;
+ stanzaChannel_ = stanzaChannel;
+ notifier_->onChatStateChanged.connect(boost::bind(&ChatStateMessageSender::handleChatStateChanged, this, _1));
+}
+
+void ChatStateMessageSender::handleChatStateChanged(ChatState::ChatStateType state) {
+ boost::shared_ptr<Message> message(new Message());
+ message->setTo(contact_);
+ message->addPayload(boost::shared_ptr<Payload>(new ChatState(state)));
+ stanzaChannel_->sendMessage(message);
+}
+
}