diff options
author | Tobias Markmann <tm@ayena.de> | 2013-08-13 17:17:40 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2013-08-13 17:40:43 (GMT) |
commit | 437e70ff9d254b11a30a4926010a91543d7f282c (patch) | |
tree | 123ef9476d89ad32643356ea11c52d212d2d03ad /Swiften/Network/UnboundDomainNameResolver.h | |
parent | 3eefe28a2f6cc1e33d9d2b0bad7f9c6f2146352f (diff) | |
download | swift-437e70ff9d254b11a30a4926010a91543d7f282c.zip swift-437e70ff9d254b11a30a4926010a91543d7f282c.tar.bz2 |
Adding basic support for Android and Unbound (No IPv6 yet).
Change-Id: I1d74324515b20e0dc3d0ef4aa2f556fea7b4bee3
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.s
Diffstat (limited to 'Swiften/Network/UnboundDomainNameResolver.h')
-rwxr-xr-x | Swiften/Network/UnboundDomainNameResolver.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Swiften/Network/UnboundDomainNameResolver.h b/Swiften/Network/UnboundDomainNameResolver.h new file mode 100755 index 0000000..0db8a66 --- /dev/null +++ b/Swiften/Network/UnboundDomainNameResolver.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013 Tobias Markmann + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <Swiften/Network/DomainNameResolver.h> +#include <Swiften/Network/Timer.h> +#include <Swiften/EventLoop/EventOwner.h> + +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> +#include <boost/asio.hpp> + +struct ub_ctx; +struct ub_result; + +namespace Swift { + class EventLoop; + class TimerFactory; + + class UnboundDomainNameResolver; + class UnboundQuery; + + class UnboundDomainNameResolver : public DomainNameResolver, public EventOwner, public boost::enable_shared_from_this<UnboundDomainNameResolver> { + public: + UnboundDomainNameResolver(boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop); + virtual ~UnboundDomainNameResolver(); + + virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& name); + virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const std::string& name); + + static void unbound_callback_wrapper(void* data, int err, ub_result* result); + + private: + void unbound_callback(boost::shared_ptr<UnboundQuery> query, int err, ub_result* result); + + void handleUBSocketReadable(boost::system::error_code); + void processData(); + + private: + boost::shared_ptr<EventOwner> eventOwner; + boost::shared_ptr<boost::asio::io_service> ioService; + boost::asio::posix::stream_descriptor ubDescriptior; + EventLoop* eventLoop; + ub_ctx* ubContext; + }; + +} |