summaryrefslogtreecommitdiffstats
blob: f55e74990550ca6731020f361a57fe2923f8cad9 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (c) 2010-2011 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <boost/shared_ptr.hpp>
#include <vector>

#include <Swiften/Roster/XMPPRosterImpl.h>

enum XMPPRosterEvents {None, Add, Remove, Update};

class XMPPRosterSignalHandler {
public:
	XMPPRosterSignalHandler(Swift::XMPPRoster* roster);

	XMPPRosterEvents getLastEvent() {
		return lastEvent_;
	}

	Swift::JID getLastJID() {
		return lastJID_;
	}

	std::string getLastOldName() {
		return lastOldName_;
	}

	std::vector<std::string> getLastOldGroups() {
		return lastOldGroups_;
	}

	void reset() {
		lastEvent_ = None;
	}

	int getEventCount() const {
		return eventCount;
	}

private:
	void handleJIDAdded(const Swift::JID& jid) {
		lastJID_ = jid;
		lastEvent_ = Add;
		eventCount++;
	}

	void handleJIDRemoved(const Swift::JID& jid) {
		lastJID_ = jid;
		lastEvent_ = Remove;
		eventCount++;
	}

	void handleJIDUpdated(const Swift::JID& jid, const std::string& oldName, const std::vector<std::string>& oldGroups);

	XMPPRosterEvents lastEvent_;
	Swift::JID lastJID_;
	std::string lastOldName_;
	std::vector<std::string> lastOldGroups_;
	int eventCount;
};