summaryrefslogtreecommitdiffstats
path: root/dnssd/remoteservice.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-22 00:43:26 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-22 00:43:26 +0000
commit856eea7169f7a4605aed28392857e6c5c80c644c (patch)
treeef60da2c0582e3d606699d8bb9f98317531362a3 /dnssd/remoteservice.cpp
parent847c48556bc8f7c17bd201ced9381e2fbb2d5d09 (diff)
downloadtdelibs-856eea7169f7a4605aed28392857e6c5c80c644c.tar.gz
tdelibs-856eea7169f7a4605aed28392857e6c5c80c644c.zip
Remaining Avahi fixes
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1152787 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'dnssd/remoteservice.cpp')
-rw-r--r--dnssd/remoteservice.cpp20
1 files changed, 18 insertions, 2 deletions
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 <sys/types.h>
#endif
#include <netinet/in.h>
+#ifdef HAVE_DNSSD
#include <avahi-client/client.h>
#include <avahi-common/strlst.h>
#ifdef AVAHI_API_0_6
#include <avahi-client/lookup.h>
#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;
}
@@ -117,9 +129,9 @@ void RemoteService::resolveAsync()
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<ServiceBase&>(a)));
s >> resolved;