summaryrefslogtreecommitdiffstats
blob: e150d2999b1c5cc7513f79722cd92365ff46b7e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#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);
}

}