summaryrefslogtreecommitdiffstats
blob: 879b286142394889d7e9d45fdaeeba0b1dca6c1a (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
#pragma once

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

#include "Swiften/Base/String.h"
#include "Swiften/LinkLocal/DNSSDService.h"
#include "Swiften/LinkLocal/DNSSDServiceFactory.h"
#include "Swiften/LinkLocal/LinkLocalService.h"

namespace Swift {
	class HostAddress;

	class LinkLocalServiceBrowser {
		public:
			LinkLocalServiceBrowser(DNSSDServiceFactory*);

			std::vector<LinkLocalService> getServices() const;

			boost::signal<void (const LinkLocalServiceID&)> onServiceAdded;
			boost::signal<void (const LinkLocalServiceID&)> onServiceChanged;
			boost::signal<void (const LinkLocalServiceID&)> onServiceRemoved;

		private:
			void handleServiceAdded(const LinkLocalServiceID&);
			void handleServiceRemoved(const LinkLocalServiceID&);
			void handleServiceResolved(const LinkLocalServiceID& service, const DNSSDService::ResolveResult& result);

		private:
			boost::shared_ptr<DNSSDService> dnsSDService;
			typedef std::map<LinkLocalServiceID, DNSSDService::ResolveResult> ServiceMap;
			ServiceMap services;
	};
}