diff options
Diffstat (limited to 'Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp')
-rw-r--r-- | Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp index 0ba4dbb..f7dfa11 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp @@ -48,20 +48,13 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) MainEventLoop::postEvent(boost::bind(boost::ref(registerQuery->onRegisterFinished), service), shared_from_this()); } else if (boost::shared_ptr<FakeDNSSDResolveHostnameQuery> resolveHostnameQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveHostnameQuery>(query)) { - std::map<String,HostAddress>::const_iterator i = addresses.find(resolveHostnameQuery->hostname); + std::map<String,boost::optional<HostAddress> >::const_iterator i = addresses.find(resolveHostnameQuery->hostname); if (i != addresses.end()) { MainEventLoop::postEvent( boost::bind( boost::ref(resolveHostnameQuery->onHostnameResolved), i->second), shared_from_this()); } - else { - MainEventLoop::postEvent( - boost::bind( - boost::ref(resolveHostnameQuery->onHostnameResolved), - boost::optional<HostAddress>()), - shared_from_this()); - } } } @@ -118,8 +111,14 @@ void FakeDNSSDQuerier::setRegisterError() { } } -void FakeDNSSDQuerier::setAddress(const String& hostname, const HostAddress& address) { +void FakeDNSSDQuerier::setAddress(const String& hostname, boost::optional<HostAddress> address) { addresses[hostname] = address; + foreach(const boost::shared_ptr<FakeDNSSDResolveHostnameQuery>& query, getQueries<FakeDNSSDResolveHostnameQuery>()) { + if (query->hostname == hostname) { + MainEventLoop::postEvent(boost::bind( + boost::ref(query->onHostnameResolved), address), shared_from_this()); + } + } } } |