[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/dnssd
From:       Tejas Dinkar <tejasdinkar () gmail ! com>
Date:       2008-12-06 16:08:35
Message-ID: 1228579715.311114.8389.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 893440 by dinkar:

Added Support for resolveHostName and getLocalHostName

Currently native via avahi, but can be implemented in mdns

 M  +4 -2      CMakeLists.txt  
 M  +30 -0     avahi-servicebrowser.cpp  
 M  +10 -0     dummy-servicebrowser.cpp  
 M  +11 -0     mdnsd-servicebrowser.cpp  
 M  +16 -0     servicebrowser.h  


--- trunk/KDE/kdelibs/dnssd/CMakeLists.txt #893439:893440
@@ -56,10 +56,12 @@
 
 kde4_add_library(kdnssd SHARED ${kdnssd_LIB_SRCS})
 
+MESSAGE("QT_QTNETWORK_LIBRARY is" ${QT_QTNETWORK_LIBRARY})
+
 if (HAVE_DNSSD)
-  target_link_libraries(kdnssd ${KDE4_KDEUI_LIBS} ${DNSSD_LIBRARIES} )
+  target_link_libraries(kdnssd ${KDE4_KDEUI_LIBS} ${DNSSD_LIBRARIES} \
${QT_QTNETWORK_LIBRARY})  else (HAVE_DNSSD)
-  target_link_libraries(kdnssd ${KDE4_KDEUI_LIBS})
+  target_link_libraries(kdnssd ${KDE4_KDEUI_LIBS} ${QT_QTNETWORK_LIBRARY})
 endif (HAVE_DNSSD)
 
 target_link_libraries(kdnssd  LINK_INTERFACE_LIBRARIES kdecore ${QT_QTCORE_LIBRARY} \
                )
--- trunk/KDE/kdelibs/dnssd/avahi-servicebrowser.cpp #893439:893440
@@ -24,6 +24,7 @@
 #include "avahi_servicebrowser_interface.h"
 #include "avahi_server_interface.h"
 #include <QtCore/QHash>
+#include <QtNetwork/QHostAddress>
 #ifndef KDE_USE_FINAL
 Q_DECLARE_METATYPE(QList<QByteArray>)
 #endif
@@ -149,8 +150,37 @@
 void ServiceBrowser::virtual_hook(int, void*)
 {}
 
+QHostAddress ServiceBrowser::resolveHostName(const QString &hostname)
+{
+	org::freedesktop::Avahi::Server \
s("org.freedesktop.Avahi","/",QDBusConnection::systemBus());  
+	int protocol = 0;
+	QString name;
+	int aprotocol = 0;
+	QString address;
+	uint flags = 0;
+
+	QDBusReply<int> reply = s.ResolveHostName(-1, -1, hostname, 0, (unsigned int ) 0, \
protocol, name, aprotocol, address, flags); +
+	if (reply.isValid())
+		return QHostAddress(address);
+	else
+		return QHostAddress();
 }
 
+QString ServiceBrowser::getLocalHostName()
+{
+	org::freedesktop::Avahi::Server \
s("org.freedesktop.Avahi","/",QDBusConnection::systemBus()); +
+	QDBusReply<QString> reply = s.GetHostName();
+
+	if (reply.isValid())
+		return reply.value();
+	else
+		return QString();
+}
+
+}
+
 #include "servicebrowser.moc"
 #include "avahi-servicebrowser_p.moc"
--- trunk/KDE/kdelibs/dnssd/dummy-servicebrowser.cpp #893439:893440
@@ -56,6 +56,16 @@
 void ServiceBrowser::virtual_hook(int, void*)
 {}
 
+QHostAddress ServiceBrowser::resolveHostName(const QString &hostname)
+{
+	return QHostAddress();
 }
 
+QString ServiceBrowser::getLocalHostName()
+{
+	return QString();
+}
+
+}
+
 #include "servicebrowser.moc"
--- trunk/KDE/kdelibs/dnssd/mdnsd-servicebrowser.cpp #893439:893440
@@ -177,8 +177,19 @@
 	}
 }
 
+// TODO: Please Implement Me - Using a KResolver (if not natively)
+QHostAddress ServiceBrowser::resolveHostName(const QString &hostname)
+{
+	return QHostAddress();
+}
 
+// TODO: Please Implement Me - using a system call (if not natively)
+QString ServiceBrowser::getLocalHostName()
+{
+	return QString();
 }
 
+}
+
 #include "servicebrowser.moc"
 #include "mdnsd-servicebrowser_p.moc"
--- trunk/KDE/kdelibs/dnssd/servicebrowser.h #893439:893440
@@ -22,6 +22,7 @@
 #define DNSSDSERVICEBROWSER_H
 
 #include <QtCore/QObject>
+#include <QHostAddress>
 
 #include <dnssd/remoteservice.h>
 
@@ -127,6 +128,21 @@
 	 */
 	bool isAutoResolving() const;
 
+	/**
+	 * @brief Resolved a hostname via the dnssd service into a dotted decimal IP \
Address +	 *
+	 * The can only be used to resolve an mdns hostname
+	 * @param hostname The hostname to be resolved
+	 * @return A QString containing the IP address. QString() returned if failed
+	 */
+	static QHostAddress resolveHostName(const QString &hostname);
+
+	/**
+	 * @brief This function simply returns the name of this machine's hostname
+	 * @return A QString representing the hostname. Returns QString() if failed
+	 */
+	static QString getLocalHostName();
+
 Q_SIGNALS:
 	/**
 	Emitted when new service is discovered (or resolved


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic