From 856eea7169f7a4605aed28392857e6c5c80c644c Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 22 Jul 2010 00:43:26 +0000 Subject: Remaining Avahi fixes git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1152787 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- dnssd/remoteservice.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'dnssd/remoteservice.cpp') diff --git a/dnssd/remoteservice.cpp b/dnssd/remoteservice.cpp index 8205aea00..865c3be7f 100644 --- a/dnssd/remoteservice.cpp +++ b/dnssd/remoteservice.cpp @@ -27,11 +27,13 @@ #include #endif #include +#ifdef HAVE_DNSSD #include #include #ifdef AVAHI_API_0_6 #include #endif +#endif #include "remoteservice.h" #include "responder.h" #include "sdevent.h" @@ -53,15 +55,21 @@ void resolve_callback(AvahiServiceResolver*, AvahiIfIndex, AvahiProtocol proto, class RemoteServicePrivate : public Responder { public: - RemoteServicePrivate() : m_resolved(false), m_running(false), m_resolver(0) {} + RemoteServicePrivate() : m_resolved(false), m_running(false) +#ifdef HAVE_DNSSD + , m_resolver(0) +#endif + {} bool m_resolved; bool m_running; +#ifdef HAVE_DNSSD AvahiServiceResolver* m_resolver; void stop() { m_running = false; if (m_resolver) avahi_service_resolver_free(m_resolver); m_resolver=0; } +#endif }; RemoteService::RemoteService(const QString& label) @@ -91,7 +99,9 @@ RemoteService::RemoteService(const KURL& url) RemoteService::~RemoteService() { +#ifdef HAVE_DNSSD if (d->m_resolver) avahi_service_resolver_free(d->m_resolver); +#endif delete d; } @@ -99,7 +109,9 @@ bool RemoteService::resolve() { resolveAsync(); while (d->m_running && !d->m_resolved) Responder::self().process(); +#ifdef HAVE_DNSSD d->stop(); +#endif return d->m_resolved; } @@ -116,10 +128,10 @@ void RemoteService::resolveAsync() #else d->m_resolver = avahi_service_resolver_new(Responder::self().client(),AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, m_serviceName.utf8(), m_type.ascii(), m_domain.utf8(), AVAHI_PROTO_UNSPEC, resolve_callback, this); -#endif #endif if (d->m_resolver) d->m_running=true; else emit resolved(false); +#endif } bool RemoteService::isResolved() const @@ -130,7 +142,9 @@ bool RemoteService::isResolved() const void RemoteService::customEvent(QCustomEvent* event) { if (event->type() == QEvent::User+SD_ERROR) { +#ifdef HAVE_DNSSD d->stop(); +#endif d->m_resolved=false; emit resolved(false); } @@ -160,7 +174,9 @@ QDataStream & operator<< (QDataStream & s, const RemoteService & a) QDataStream & operator>> (QDataStream & s, RemoteService & a) { // stop any possible resolve going on +#ifdef HAVE_DNSSD a.d->stop(); +#endif Q_INT8 resolved; operator>>(s,(static_cast(a))); s >> resolved; -- cgit v1.2.1