fix for OS where avahi is not present

Change-Id: Ib3e21b786821baa7c3c47755de5125e1de566c39
This commit is contained in:
Siqi
2013-07-25 17:59:30 +02:00
parent 9a44e90c2c
commit d1a6a00ab8
3 changed files with 24 additions and 6 deletions

View File

@@ -72,13 +72,21 @@ $(eval $(call gb_CppunitTest_use_system_darwin_frameworks,sd_uimpress,\
endif
ifeq ($(OS), LINUX)
$(eval $(call gb_CppunitTest_use_externals,sd_uimpress,\
boost_headers \
gtk \
dbus \
avahi \
ifeq ($(ENABLE_AVAHI),TRUE)
$(eval $(call gb_Library_use_externals,sd,\
boost_headers \
gtk \
dbus \
avahi \
))
else
$(eval $(call gb_Library_use_externals,sd,\
boost_headers \
gtk \
dbus \
))
endif
else
$(eval $(call gb_CppunitTest_use_externals,sd_uimpress,\
boost_headers \
gtk \

View File

@@ -95,6 +95,7 @@ $(eval $(call gb_Library_use_libraries,sd,\
))
ifeq ($(OS), LINUX)
ifeq ($(ENABLE_AVAHI),TRUE)
$(eval $(call gb_Library_use_externals,sd,\
boost_headers \
libxml2 \
@@ -108,6 +109,13 @@ $(eval $(call gb_Library_use_externals,sd,\
dbus \
))
endif
else
$(eval $(call gb_Library_use_externals,sd,\
boost_headers \
libxml2 \
dbus \
))
endif
ifeq ($(OS),WNT)
$(eval $(call gb_Library_use_system_win32_libs,sd,\

View File

@@ -10,7 +10,6 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <algorithm>
#include <vector>
#include <iostream>
@@ -29,6 +28,7 @@
#include <ws2tcpip.h>
typedef int socklen_t;
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -58,12 +58,14 @@ DiscoveryService::DiscoveryService()
zService = new OSXNetworkService();
#endif
#ifdef LINUX
#ifdef ENABLE_AVAHI
// Avahi for Linux
char hostname[1024];
hostname[1023] = '\0';
gethostname(hostname, 1023);
zService = new AvahiNetworkService(hostname);
#endif
#endif
zService->setup();