summaryrefslogtreecommitdiffstats
blob: 3ba33526e75c431557b096850d30043b82cc6f07 (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
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include <boost/shared_ptr.hpp>
#include <map>
#include <vector>
#include <Swiften/Base/boost_bsignals.h>

#include <Swiften/Elements/SearchPayload.h>
#include <Swiften/Base/String.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/DiscoItems.h>
#include <Swiften/Elements/ErrorPayload.h>

namespace Swift {
	class UIEventStream;
	class UIEvent;
	class UserSearchWindow;
	class UserSearchWindowFactory;
	class IQRouter;
	class DiscoServiceWalker;

	class UserSearchResult {
		public:
			UserSearchResult(const JID& jid, const std::map<String, String>& fields) : jid_(jid), fields_(fields) {}
			const JID& getJID() const {return jid_;}
			const std::map<String, String>& getFields() const {return fields_;}
		private:
			JID jid_;
			std::map<String, String> fields_;
	};

	class UserSearchController {
		public:
			UserSearchController(const JID& jid, UIEventStream* uiEventStream, UserSearchWindowFactory* userSearchWindowFactory, IQRouter* iqRouter);
			~UserSearchController();
		private:
			void handleUIEvent(boost::shared_ptr<UIEvent> event);
			void handleFormRequested(const JID& service);
			void handleDiscoServiceFound(const JID& jid, boost::shared_ptr<DiscoInfo> info, DiscoServiceWalker* walker);
			void handleDiscoWalkFinished(DiscoServiceWalker* walker);
			void handleFormResponse(boost::shared_ptr<SearchPayload> items, ErrorPayload::ref error, const JID& jid);
			void handleSearch(boost::shared_ptr<SearchPayload> fields, const JID& jid);
			void handleSearchResponse(boost::shared_ptr<SearchPayload> results, ErrorPayload::ref error, const JID& jid);
			UIEventStream* uiEventStream_;
			UserSearchWindow* window_;
			UserSearchWindowFactory* factory_;
			boost::bsignals::scoped_connection uiEventConnection_;
			IQRouter* iqRouter_;
			JID jid_;
			DiscoServiceWalker* discoWalker_;
	};
}