[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] Resolve Service address in DNSSD::RemoteService
From: Sebastian =?iso-8859-1?q?Tr=FCg?= <strueg () mandriva ! com>
Date: 2008-03-06 12:03:08
Message-ID: 200803061303.08305.strueg () mandriva ! com
[Download RAW message or body]
Hi all,
please find attached a patch for kdelibs/dnssd which adds handling of service
addresses. ATM we only get the hostname which is completely useless in my
network since I get stuff like "local.local".
Address lookup was disabled via AVAHAI_LOOKUP_NO_ADDRESS. Why, I don't know.
Now the address is resolved and stored in ServiceBasePrivate, accessible via
the new address() method. I know that it would probably make more sense to
only store it in RemoteService but the design sees it only as a trivial
extension to ServiceBase without any new members.
Any objections?
Cheers,
Sebastian
["kdelibs-dnssd-address.patch" (text/x-diff)]
Index: servicebase.h
===================================================================
--- servicebase.h (revision 782189)
+++ servicebase.h (working copy)
@@ -81,6 +81,12 @@
QString hostName() const;
/**
+ * \return The address of the service. Only valid for resolved remote \
services. + * \since 4.1
+ */
+ QString address() const;
+
+ /**
Returns port number. It is only valid for local and resolved remote services.
*/
unsigned short port() const;
Index: avahi-publicservice_p.h
===================================================================
--- avahi-publicservice_p.h (revision 782189)
+++ avahi-publicservice_p.h (working copy)
@@ -38,7 +38,7 @@
Q_OBJECT
public:
PublicServicePrivate(PublicService* parent, const QString& name, const QString& \
type, const QString& domain, unsigned int port) :
- QObject(), ServiceBasePrivate(name, type, domain, QString(), port), \
m_published(false), m_running(false), m_group(0), + QObject(), \
ServiceBasePrivate(name, type, domain, QString(), QString(), port), \
m_published(false), m_running(false), m_group(0), m_server(0), m_collision(false), \
m_parent(parent) {}
~PublicServicePrivate() {
Index: mdnsd-remoteservice.cpp
===================================================================
--- mdnsd-remoteservice.cpp (revision 782189)
+++ mdnsd-remoteservice.cpp (working copy)
@@ -101,6 +101,7 @@
if (event->type() == QEvent::User+SD_RESOLVE) {
ResolveEvent* rev = static_cast<ResolveEvent*>(event);
m_hostName = rev->m_hostname;
+ m_address = rev->m_address;
m_port = rev->m_port;
m_textData = rev->m_txtdata;
m_resolved = true;
Index: avahi-servicebrowser.cpp
===================================================================
--- avahi-servicebrowser.cpp (revision 782189)
+++ avahi-servicebrowser.cpp (working copy)
@@ -27,6 +27,7 @@
#ifndef KDE_USE_FINAL
Q_DECLARE_METATYPE(QList<QByteArray>)
#endif
+
namespace DNSSD
{
Index: servicebase.cpp
===================================================================
--- servicebase.cpp (revision 782189)
+++ servicebase.cpp (working copy)
@@ -29,7 +29,7 @@
ServiceBase::ServiceBase(const QString& name, const QString& type, const QString& \
domain, const QString& host, unsigned short port)
- : d(new ServiceBasePrivate(name,type,domain,host,port))
+ : d(new ServiceBasePrivate(name,type,domain,host,QString(),port))
{}
ServiceBase::ServiceBase(ServiceBasePrivate* const _d)
@@ -61,6 +61,11 @@
return d->m_hostName;
}
+QString ServiceBase::address() const
+{
+ return d->m_address;
+}
+
unsigned short ServiceBase::port() const
{
return d->m_port;
Index: avahi-remoteservice.cpp
===================================================================
--- avahi-remoteservice.cpp (revision 782189)
+++ avahi-remoteservice.cpp (working copy)
@@ -58,9 +58,8 @@
registerTypes();
kDebug() << this << ":Starting resolve of : " << d->m_serviceName << " " << \
d->m_type << " " << d->m_domain << "\n"; org::freedesktop::Avahi::Server \
s("org.freedesktop.Avahi","/",QDBusConnection::systemBus());
- //FIXME: don't use LOOKUP_NO_ADDRESS if NSS unavailable
QDBusReply<QDBusObjectPath> rep=s.ServiceResolverNew(-1, -1, d->m_serviceName, \
d->m_type,
- domainToDNS(d->m_domain), -1, 8 /*AVAHI_LOOKUP_NO_ADDRESS*/);
+ domainToDNS(d->m_domain), \
-1, 0); if (!rep.isValid()) {
emit resolved(false);
return;
@@ -89,10 +88,11 @@
emit m_parent->resolved(false);
}
-void RemoteServicePrivate::gotFound(int, int, const QString &name, const QString &, \
const QString &domain, const QString &host, int, const QString &, ushort port, const \
QList<QByteArray> &txt, uint) +void RemoteServicePrivate::gotFound(int, int, const \
QString &name, const QString &, const QString &domain, const QString &host, int, \
const QString &address, ushort port, const QList<QByteArray> &txt, uint) {
m_serviceName = name;
m_hostName = host;
+ m_address = address;
m_port = port;
m_domain=DNSToDomain(domain);
Q_FOREACH(QByteArray x, txt) {
Index: servicebase_p.h
===================================================================
--- servicebase_p.h (revision 782189)
+++ servicebase_p.h (working copy)
@@ -30,8 +30,10 @@
{
public:
ServiceBasePrivate(const QString& name, const QString& type, const QString& domain, \
- const QString& host, unsigned short port) : m_serviceName(name), m_type(type),
- m_domain(domain), m_hostName(host), m_port(port) {}
+ const QString& host, const QString& address, unsigned \
short port) + : m_serviceName(name), m_type(type),
+ m_domain(domain), m_hostName(host),
+ m_address(address), m_port(port) {}
virtual ~ServiceBasePrivate() {}
@@ -39,6 +41,7 @@
QString m_type;
QString m_domain;
QString m_hostName;
+ QString m_address;
unsigned short m_port;
/**
Index: avahi-remoteservice_p.h
===================================================================
--- avahi-remoteservice_p.h (revision 782189)
+++ avahi-remoteservice_p.h (working copy)
@@ -39,7 +39,7 @@
Q_OBJECT
public:
RemoteServicePrivate(RemoteService* parent, const QString& name, const QString& \
type, const QString& domain) : QObject(),
- ServiceBasePrivate(name, type, domain, QString(), 0), m_resolved(false), \
m_running(false), m_resolver(0), m_parent(parent) + \
ServiceBasePrivate(name, type, domain, QString(), QString(), 0), m_resolved(false), \
m_running(false), m_resolver(0), m_parent(parent) {}
~RemoteServicePrivate() { if (m_resolver) m_resolver->Free(); delete \
m_resolver; } bool m_resolved;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic