diff options
author | Olli Salli <olli.salli@collabora.co.uk> | 2012-02-22 21:19:00 +0200 |
---|---|---|
committer | Olli Salli <olli.salli@collabora.co.uk> | 2012-02-22 21:29:37 +0200 |
commit | dc721271f31a487de11f05f9b580a0c2760bd971 (patch) | |
tree | ddf50b90ca21bddf6f2488b7ec3d0a7d4cb219f8 | |
parent | 44cc9454696cf5e3f1d21fc1d51b46500f2f78e5 (diff) | |
parent | efa82fa6e961b2119fbb51513e9410d9237e8a12 (diff) |
Merge branch 'build-with-dummy-on-windows'
Reviewed-by: Olli Salli (oggis) <olli.salli@collabora.co.uk>
Reviewed-by: Simon McVittie (smcv) <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | configure.ac | 40 | ||||
-rw-r--r-- | data/Makefile.am | 4 | ||||
-rw-r--r-- | lib/gibber/Makefile.am | 5 | ||||
-rw-r--r-- | lib/gibber/gibber-listener.c | 2 | ||||
-rw-r--r-- | lib/gibber/gibber-multicast-transport.c | 24 | ||||
-rw-r--r-- | lib/gibber/gibber-sockets-win32.h | 4 | ||||
-rw-r--r-- | lib/gibber/gibber-util.c | 4 | ||||
-rw-r--r-- | src/Makefile.am | 18 | ||||
-rw-r--r-- | src/connection.c | 4 | ||||
-rw-r--r-- | src/contact.h | 12 | ||||
-rw-r--r-- | src/file-transfer-channel.c | 12 | ||||
-rw-r--r-- | src/im-channel.c | 7 | ||||
-rw-r--r-- | src/muc-channel.c | 2 | ||||
-rw-r--r-- | src/muc-manager.c | 3 | ||||
-rw-r--r-- | src/protocol.c | 11 | ||||
-rw-r--r-- | src/roomlist-manager.c | 2 | ||||
-rw-r--r-- | src/salut.c | 13 | ||||
-rw-r--r-- | src/self.c | 4 | ||||
-rw-r--r-- | src/tube-stream.c | 23 | ||||
-rw-r--r-- | src/tubes-channel.c | 6 |
20 files changed, 168 insertions, 32 deletions
diff --git a/configure.ac b/configure.ac index 5ff7bdc4..fc8204ca 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,21 @@ SALUT_ARG_DEBUG SALUT_ARG_VALGRIND SALUT_ARG_COVERAGE +dnl Detect Windows Verion +AC_MSG_CHECKING([for operating system]) +case "$host" in + *-*-*mingw*|*-*-*cygwin*) + platform=win32 + ;; + *) + platform=generic + ;; +esac + +AC_MSG_RESULT($platform) + +AM_CONDITIONAL([OS_WINDOWS], [test "$platform" = "win32"]) + dnl decide error flags ifelse(salut_nano_version, 0, [ official_release=yes ], @@ -127,7 +142,6 @@ AM_CONDITIONAL(ENABLE_OLPC, test "x$enable_olpc" = "xyes") AC_SUBST(ENABLE_OLPC) - AC_HEADER_STDC([]) AC_C_INLINE @@ -185,10 +199,28 @@ PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib >= 0.17.1]) AC_SUBST(TELEPATHY_GLIB_CFLAGS) AC_SUBST(TELEPATHY_GLIB_LIBS) +dnl check the backend to use +AC_ARG_WITH(backend, + AC_HELP_STRING([--with-backend=[avahi/no]], + [Zeroconf backend to use]), + [], [with_backend=avahi]) + +AM_CONDITIONAL(USE_BACKEND_DUMMY, [test "x$with_backend" = "xno"]) +AM_CONDITIONAL(USE_BACKEND_AVAHI, [test "x$with_backend" = "xavahi"]) + dnl Check for Avahi -PKG_CHECK_MODULES(AVAHI, [avahi-gobject, avahi-client]) -AC_SUBST(AVAHI_CFLAGS) -AC_SUBST(AVAHI_LIBS) +if test x$with_backend = xavahi; then + PKG_CHECK_MODULES(AVAHI, [avahi-gobject, avahi-client]) + AC_DEFINE(USE_BACKEND_AVAHI, [], [Use Avahi backend]) + AC_SUBST(AVAHI_CFLAGS) + AC_SUBST(AVAHI_LIBS) + AC_SUBST(USE_BACKEND_AVAHI) +fi + +if test x$with_backend = xno; then + AC_DEFINE(USE_BACKEND_DUMMY, [], [Use dummy backend]) + AC_SUBST(USE_BACKEND_DUMMY) +fi dnl Check for libsoup PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4]) diff --git a/data/Makefile.am b/data/Makefile.am index 6bc592c3..e0002ab6 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -16,7 +16,7 @@ org.freedesktop.Telepathy.ConnectionManager.salut.service: salut.service.in \ CLEANFILES = $(service_DATA) $(manager_DATA) $(manager_DATA): always-build - $(MAKE) -C ../src write-mgr-file - $(AM_V_GEN)../src/write-mgr-file > $@ + $(MAKE) -C ../src write-mgr-file$(EXEEXT) + $(AM_V_GEN)../src/write-mgr-file$(EXEEXT) > $@ .PHONY: always-build diff --git a/lib/gibber/Makefile.am b/lib/gibber/Makefile.am index d036c72d..d4425318 100644 --- a/lib/gibber/Makefile.am +++ b/lib/gibber/Makefile.am @@ -93,6 +93,11 @@ AM_CFLAGS = $(ERROR_CFLAGS) $(GCOV_CFLAGS) @GLIB_CFLAGS@ @LIBXML2_CFLAGS@ @WOCKY AM_LDFLAGS = $(GCOV_LIBS) @GLIB_LIBS@ @LIBXML2_LIBS@ @WOCKY_LIBS@ @LIBSOUP_LIBS@ +# Required for getnameinfo to work when cross compiling +if OS_WINDOWS + AM_CFLAGS += -D_WIN32_WINNT=0x0501 +endif + # rules for making the glib enum objects %-enumtypes.h: %.h Makefile.in $(AM_V_GEN)glib-mkenums \ diff --git a/lib/gibber/gibber-listener.c b/lib/gibber/gibber-listener.c index 40d4610d..a885294c 100644 --- a/lib/gibber/gibber-listener.c +++ b/lib/gibber/gibber-listener.c @@ -259,7 +259,7 @@ add_listener (GibberListener *self, int family, int type, int protocol, goto error; } - ret = setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof (int)); + ret = setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (char *) &yes, sizeof (int)); if (ret == -1) { gibber_socket_set_error (error, "setsockopt failed", diff --git a/lib/gibber/gibber-multicast-transport.c b/lib/gibber/gibber-multicast-transport.c index d593c44c..fd146d40 100644 --- a/lib/gibber/gibber-multicast-transport.c +++ b/lib/gibber/gibber-multicast-transport.c @@ -150,7 +150,7 @@ _channel_io_in (GIOChannel *source, GIOCondition condition, gpointer data) int ret; socklen_t len = sizeof (struct sockaddr_storage); - ret = recvfrom (priv->fd, buf, BUFSIZE, 0, (struct sockaddr *)&from, &len); + ret = recvfrom (priv->fd, (char *) buf, BUFSIZE, 0, (struct sockaddr *) &from, &len); if (ret < 0) { @@ -214,25 +214,25 @@ _open_multicast (GibberMulticastTransport *self, GError **error) goto err; } - SETSOCKOPT (fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof (yes)); + SETSOCKOPT (fd, SOL_SOCKET, SO_REUSEADDR, (char *) &yes, sizeof (yes)); #ifdef SO_REUSEPORT SETSOCKOPT (fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof (yes)); #endif - SETSOCKOPT (fd, IPPROTO_IP, IP_MULTICAST_LOOP, &yes, sizeof (yes)); - SETSOCKOPT (fd, IPPROTO_IP, IP_MULTICAST_TTL, &one, sizeof (one)); + SETSOCKOPT (fd, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &yes, sizeof (yes)); + SETSOCKOPT (fd, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &one, sizeof (one)); mreq.imr_multiaddr = ((struct sockaddr_in *) &(priv->address))->sin_addr; mreq.imr_interface.s_addr = htonl (INADDR_ANY); - SETSOCKOPT (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof (mreq)); + SETSOCKOPT (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof (mreq)); memset (&baddr, 0, sizeof (baddr)); baddr.sin_family = AF_INET; baddr.sin_addr.s_addr = htonl (INADDR_ANY); - baddr.sin_port = ((struct sockaddr_in *)&(priv->address))->sin_port; + baddr.sin_port = ((struct sockaddr_in *) &(priv->address))->sin_port; - if (bind (fd, (struct sockaddr *)&baddr, sizeof (baddr)) != 0) + if (bind (fd, (struct sockaddr *) &baddr, sizeof (baddr)) != 0) { DEBUG("Failed to bind to socket: %s", strerror (errno)); g_set_error (error, GIBBER_MULTICAST_TRANSPORT_ERROR, @@ -256,13 +256,13 @@ _open_multicast (GibberMulticastTransport *self, GError **error) } mreq6.ipv6mr_multiaddr = - ((struct sockaddr_in6 *)&priv->address)->sin6_addr; + ((struct sockaddr_in6 *) &priv->address)->sin6_addr; mreq6.ipv6mr_interface = 0; - SETSOCKOPT (fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, + SETSOCKOPT (fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &mreq6, sizeof (mreq6)); - if (bind (fd, (struct sockaddr *)&(priv->address), priv->addrlen) + if (bind (fd, (struct sockaddr *) &(priv->address), priv->addrlen) != 0) { DEBUG("Failed to bind to socket: %s", strerror(errno)); @@ -466,8 +466,8 @@ gibber_multicast_transport_send (GibberTransport *transport, return FALSE; } - if (sendto (priv->fd, data, size, 0, - (struct sockaddr *)&(priv->address), + if (sendto (priv->fd, (const char *) data, size, 0, + (struct sockaddr *) &(priv->address), sizeof (struct sockaddr_storage)) < 0) { DEBUG("send failed: %s", strerror (errno)); diff --git a/lib/gibber/gibber-sockets-win32.h b/lib/gibber/gibber-sockets-win32.h index d35e3cbd..e61e2845 100644 --- a/lib/gibber/gibber-sockets-win32.h +++ b/lib/gibber/gibber-sockets-win32.h @@ -22,8 +22,8 @@ #include <winsock2.h> #include <ws2tcpip.h> -#include <Windows.h> -#include <Winbase.h> +#include <windows.h> +#include <winbase.h> /* Winsock makes some inappropriately-namespaced definitions */ #undef ERROR #undef interface diff --git a/lib/gibber/gibber-util.c b/lib/gibber/gibber-util.c index b1cf93aa..ff49ed10 100644 --- a/lib/gibber/gibber-util.c +++ b/lib/gibber/gibber-util.c @@ -38,8 +38,8 @@ gibber_normalize_address (struct sockaddr_storage *addr) if (s6->sin6_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED (&(s6->sin6_addr))) { /* Normalize to ipv4 address */ - u_int32_t addr_big_endian; - u_int16_t port; + guint32 addr_big_endian; + guint16 port; memcpy (&addr_big_endian, s6->sin6_addr.s6_addr + 12, 4); port = s6->sin6_port; diff --git a/src/Makefile.am b/src/Makefile.am index 7be84120..be4bf617 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -80,8 +80,6 @@ CORE_SOURCES = \ util.h \ util.c \ $(top_srcdir)/salut/util.h \ - debug.c \ - debug.h \ protocol.c \ $(top_srcdir)/salut/protocol.h \ plugin-loader.c \ @@ -132,6 +130,10 @@ libsalut_plugins_la_LDFLAGS = \ -no-undefined \ -avoid-version +libsalut_plugins_la_LIBADD = \ + @TELEPATHY_GLIB_LIBS@ \ + @WOCKY_LIBS@ + libsalut_plugins_la_SOURCES = \ $(top_srcdir)/salut/plugin.h \ plugin.c \ @@ -139,13 +141,19 @@ libsalut_plugins_la_SOURCES = \ plugin-connection.c \ $(top_srcdir)/salut/capability-set.h \ capability-set.c \ + debug.h \ + debug.c \ $(top_srcdir)/salut/sidecar.h \ sidecar.c libsalut_convenience_la_LIBADD = libsalut-plugins.la libsalut_convenience_la_SOURCES = $(CORE_SOURCES) $(BUILT_SOURCES) \ - $(SHA1_SOURCES) $(AVAHI_BACKEND_SOURCES) $(DUMMY_BACKEND_SOURCES) + $(SHA1_SOURCES) $(DUMMY_BACKEND_SOURCES) + +if USE_BACKEND_AVAHI + libsalut_convenience_la_SOURCES += $(AVAHI_BACKEND_SOURCES) +endif write_mgr_file_SOURCES = write-mgr-file.c write_mgr_file_LDADD = libsalut-convenience.la \ @@ -201,6 +209,10 @@ AM_CFLAGS = \ @LIBSOUP_CFLAGS@ \ $(NULL) +if OS_WINDOWS + AM_CFLAGS += -D_WIN32_WINNT=0x0501 +endif + AM_LDFLAGS = \ $(GCOV_LIBS) \ @LIBXML2_LIBS@ \ diff --git a/src/connection.c b/src/connection.c index a6d326da..f2e92793 100644 --- a/src/connection.c +++ b/src/connection.c @@ -19,6 +19,8 @@ #include "connection.h" +#include <config.h> + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -43,7 +45,9 @@ #include <salut/caps-channel-manager.h> #include <salut/plugin-connection.h> +#ifdef USE_BACKEND_AVAHI #include "avahi-discovery-client.h" +#endif #include "capabilities.h" #include "caps-hash.h" #include "connection-contact-info.h" diff --git a/src/contact.h b/src/contact.h index 4317a708..b2be40b1 100644 --- a/src/contact.h +++ b/src/contact.h @@ -20,7 +20,6 @@ #ifndef __SALUT_CONTACT_H__ #define __SALUT_CONTACT_H__ -#include <netinet/in.h> #include <glib-object.h> #include <telepathy-glib/handle-repo.h> @@ -32,6 +31,17 @@ #include "olpc-activity.h" #endif +#ifdef G_OS_WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#include <windows.h> + +/* Winsock makes some inappropriately-namespaced definitions */ +#undef interface +#else +#include <netinet/in.h> +#endif + #include <wocky/wocky.h> G_BEGIN_DECLS diff --git a/src/file-transfer-channel.c b/src/file-transfer-channel.c index 25f7f707..cd4f0ccf 100644 --- a/src/file-transfer-channel.c +++ b/src/file-transfer-channel.c @@ -27,9 +27,15 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> + +#ifdef G_OS_WIN32 +#include <windows.h> +#undef interface +#else #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> +#endif #define DEBUG_FLAG DEBUG_FT #include "debug.h" @@ -1563,6 +1569,7 @@ file_transfer_iface_init (gpointer g_iface, #undef IMPLEMENT } +#ifdef G_OS_UNIX static gchar * get_local_unix_socket_path (SalutFileTransferChannel *self) { @@ -1692,10 +1699,14 @@ accept_local_socket_connection (GIOChannel *source, return FALSE; } +#endif static gboolean setup_local_socket (SalutFileTransferChannel *self) { +#ifdef G_OS_WIN32 + return FALSE; +#else GIOChannel *io_channel; io_channel = get_socket_channel (self); @@ -1709,6 +1720,7 @@ setup_local_socket (SalutFileTransferChannel *self) g_io_channel_unref (io_channel); return TRUE; +#endif } static WockyDataForm * diff --git a/src/im-channel.c b/src/im-channel.c index 72a2abde..75346f87 100644 --- a/src/im-channel.c +++ b/src/im-channel.c @@ -21,11 +21,16 @@ #include "im-channel.h" #include <errno.h> -#include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + +#include <glib.h> + +#ifdef G_OS_UNIX #include <sys/socket.h> +#include <netdb.h> +#endif #include <dbus/dbus-glib.h> #include <telepathy-glib/channel-iface.h> diff --git a/src/muc-channel.c b/src/muc-channel.c index 0ddcc0aa..40e60090 100644 --- a/src/muc-channel.c +++ b/src/muc-channel.c @@ -21,7 +21,9 @@ #include <dbus/dbus-glib.h> #include <stdio.h> #include <stdlib.h> +#ifdef G_OS_UNIX #include <arpa/inet.h> +#endif #include <string.h> diff --git a/src/muc-manager.c b/src/muc-manager.c index 259680ee..46647fe7 100644 --- a/src/muc-manager.c +++ b/src/muc-manager.c @@ -21,7 +21,10 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +#ifdef G_OS_UNIX #include <arpa/inet.h> +#endif #include "muc-manager.h" diff --git a/src/protocol.c b/src/protocol.c index 986d12e2..0ce20186 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -19,6 +19,8 @@ #include "protocol.h" +#include <config.h> + #include <dbus/dbus-glib.h> #include <dbus/dbus-protocol.h> #include <telepathy-glib/base-connection-manager.h> @@ -31,7 +33,12 @@ #include "muc-manager.h" #include "roomlist-manager.h" #include "tubes-manager.h" + +#ifdef USE_BACKEND_AVAHI #include "avahi-discovery-client.h" +#elif defined (USE_BACKEND_DUMMY) +#include "dummy-discovery-client.h" +#endif /* there is no appropriate vCard field for this protocol */ #define VCARD_FIELD_NAME "" @@ -229,7 +236,11 @@ salut_protocol_set_property (GObject *object, GType type = g_value_get_gtype (value); if (type == G_TYPE_NONE) +#ifdef USE_BACKEND_AVAHI type = SALUT_TYPE_AVAHI_DISCOVERY_CLIENT; +#elif defined (USE_BACKEND_DUMMY) + type = SALUT_TYPE_DUMMY_DISCOVERY_CLIENT; +#endif self->priv->backend_type = type; } diff --git a/src/roomlist-manager.c b/src/roomlist-manager.c index d07e7a83..b1e57bb6 100644 --- a/src/roomlist-manager.c +++ b/src/roomlist-manager.c @@ -21,7 +21,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef G_OS_UNIX #include <arpa/inet.h> +#endif #include "roomlist-manager.h" diff --git a/src/salut.c b/src/salut.c index f2574147..d893df32 100644 --- a/src/salut.c +++ b/src/salut.c @@ -6,7 +6,13 @@ #include <telepathy-glib/debug.h> #include "connection-manager.h" + +#ifdef USE_BACKEND_AVAHI #include "avahi-discovery-client.h" +#elif defined (USE_BACKEND_DUMMY) +#include "dummy-discovery-client.h" +#endif + #include "debug.h" #include "plugin-loader.h" #include "symbol-hacks.h" @@ -16,7 +22,12 @@ salut_create_connection_manager (void) { return TP_BASE_CONNECTION_MANAGER ( g_object_new (SALUT_TYPE_CONNECTION_MANAGER, - "backend-type", SALUT_TYPE_AVAHI_DISCOVERY_CLIENT, + "backend-type", +#ifdef USE_BACKEND_AVAHI + SALUT_TYPE_AVAHI_DISCOVERY_CLIENT, +#elif defined (USE_BACKEND_DUMMY) + SALUT_TYPE_DUMMY_DISCOVERY_CLIENT, +#endif NULL)); } @@ -22,9 +22,13 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> + +#ifdef G_OS_UNIX #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> +#endif + #include <errno.h> #include "self.h" diff --git a/src/tube-stream.c b/src/tube-stream.c index 6ddac459..3d9bb127 100644 --- a/src/tube-stream.c +++ b/src/tube-stream.c @@ -22,6 +22,15 @@ #include <stdlib.h> #include <string.h> #include <time.h> + +#include <glib.h> + +#ifdef G_OS_WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#include <windows.h> +#include <winbase.h> +#else #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> @@ -29,8 +38,8 @@ #include <fcntl.h> #include <errno.h> #include <netdb.h> +#endif -#include <glib.h> #include <glib/gstdio.h> #include <telepathy-glib/gtypes.h> @@ -99,8 +108,10 @@ static const gchar * const salut_tube_stream_channel_allowed_properties[] = { * not guaranteed to be big enough for AF_UNIX addresses */ typedef union { +#ifdef GIBBER_TYPE_UNIX_TRANSPORT /* we'd call this unix, but gcc predefines that. Thanks, gcc */ struct sockaddr_un un; +#endif struct sockaddr_in ipv4; struct sockaddr_in6 ipv6; } SockAddr; @@ -767,6 +778,7 @@ new_connection_to_socket (SalutTubeStream *self, g_assert (priv->initiator == priv->self_handle); +#ifdef GIBBER_TYPE_UNIX_TRANSPORT if (priv->address_type == TP_SOCKET_ADDRESS_TYPE_UNIX) { GArray *array; @@ -777,7 +789,9 @@ new_connection_to_socket (SalutTubeStream *self, gibber_unix_transport_connect (GIBBER_UNIX_TRANSPORT (transport), array->data, NULL); } - else if (priv->address_type == TP_SOCKET_ADDRESS_TYPE_IPV4 || + else +#endif + if (priv->address_type == TP_SOCKET_ADDRESS_TYPE_IPV4 || priv->address_type == TP_SOCKET_ADDRESS_TYPE_IPV6) { gchar *ip; @@ -2010,6 +2024,7 @@ salut_tube_stream_add_bytestream (SalutTubeIface *tube, } } +#ifdef GIBBER_TYPE_UNIX_TRANSPORT static gboolean check_unix_params (TpSocketAddressType address_type, const GValue *address, @@ -2087,6 +2102,7 @@ check_unix_params (TpSocketAddressType address_type, return TRUE; } +#endif static gboolean check_ip_params (TpSocketAddressType address_type, @@ -2171,10 +2187,11 @@ salut_tube_stream_check_params (TpSocketAddressType address_type, { switch (address_type) { +#ifdef GIBBER_TYPE_UNIX_TRANSPORT case TP_SOCKET_ADDRESS_TYPE_UNIX: return check_unix_params (address_type, address, access_control, access_control_param, error); - +#endif case TP_SOCKET_ADDRESS_TYPE_IPV4: case TP_SOCKET_ADDRESS_TYPE_IPV6: return check_ip_params (address_type, address, access_control, diff --git a/src/tubes-channel.c b/src/tubes-channel.c index a7e31380..0058eb05 100644 --- a/src/tubes-channel.c +++ b/src/tubes-channel.c @@ -21,8 +21,14 @@ #include <stdio.h> #include <stdlib.h> + +#include <glib.h> + +#ifdef G_OS_UNIX #include <sys/socket.h> #include <netdb.h> +#endif + #include <errno.h> #include <string.h> |