summaryrefslogtreecommitdiffstats
blob: 983bc22bf0d10760a3527f94340187fc44a020e9 (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
/*
 * Copyright (c) 2010-2011 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include <Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h>

#include <boost/bind.hpp>
#include <cassert>

using namespace Swift;

XMPPRosterSignalHandler::XMPPRosterSignalHandler(Swift::XMPPRoster* roster) {
	lastEvent_ = None;
	roster->onJIDAdded.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDAdded, this, _1));
	roster->onJIDRemoved.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDRemoved, this, _1));
	roster->onJIDUpdated.connect(boost::bind(&XMPPRosterSignalHandler::handleJIDUpdated, this, _1, _2, _3));
}

void XMPPRosterSignalHandler::handleJIDUpdated(const Swift::JID& jid, const std::string& oldName, const std::vector<std::string>& oldGroups) {
	assert(lastEvent_ == None);
	lastJID_ = jid;
	lastOldName_ = oldName;
	lastOldGroups_ = oldGroups;
	lastEvent_ = Update;
}