diff --git a/lib/gibber/gibber-fd-transport.h b/lib/gibber/gibber-fd-transport.h index 28727aa..920712e 100644 --- a/lib/gibber/gibber-fd-transport.h +++ b/lib/gibber/gibber-fd-transport.h @@ -23,9 +23,26 @@ #include +#ifdef HAVE_SYS_SOCKET_H #include +#endif + +#ifdef HAVE_NETDB_H #include +#endif + +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#ifdef HAVE_NETINET_IN_H #include +#endif #include "gibber-transport.h" diff --git a/lib/gibber/gibber-listener.c b/lib/gibber/gibber-listener.c index 87a10c6..dea337f 100644 --- a/lib/gibber/gibber-listener.c +++ b/lib/gibber/gibber-listener.c @@ -23,10 +23,26 @@ #include #include #include + +#ifdef HAVE_SYS_SOCKET_H #include +#endif +#ifdef HAVE_SYS_UN_H #include +#endif +#ifdef HAVE_NETDB_H #include +#endif + +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#endif + +#ifdef HAVE_NETINET_IN_H #include +#endif + #include #include diff --git a/lib/gibber/gibber-resolver.c b/lib/gibber/gibber-resolver.c index 627e308..31e4ba9 100644 --- a/lib/gibber/gibber-resolver.c +++ b/lib/gibber/gibber-resolver.c @@ -22,15 +22,41 @@ #include #include + +#include "config.h" + +#ifdef HAVE_NETINET_IN_H #include +#endif + +#ifdef HAVE_ARPA_NAMESER_H #include +#endif + +#ifdef HAVE_RESOLV_H #include +#endif + #include + +#ifdef HAVE_NETDB.H #include +#endif + +#ifdef HAVE_WINSOCK2_H +#include +#endif +#ifdef HAVE_WINDNS_H +#include +#endif + +#ifdef WIN32 +#include "structs-for-win32.h" +#endif #include -#include "config.h" + #include "gibber-resolver.h" #ifdef HAVE_LIBASYNCNS @@ -657,6 +683,8 @@ gibber_resolver_nameinfo_result (GibberResolver *resolver, #define ANSWER_BUFSIZE 10240 + +#ifdef HAVE_RES_QUERY GList * gibber_resolver_res_query_to_list (guchar *answer, int length) { @@ -712,6 +740,39 @@ failed: gibber_resolver_srv_list_free (list); return NULL; } +#endif + +#ifdef HAVE_DNSQUERY_A +GList * +gibber_resolver_res_query_to_list (PDNS_RECORD answer) +{ + GList *list = NULL; + char name[256]; + guint16 port; + guint16 priority; + guint16 weight; + PDNS_RECORD tmp; + + for (tmp = answer; tmp != NULL; tmp = tmp->pNext) + { + //struct osip_srv_entry *srventry; + DNS_SRV_DATA * data; + if (tmp->wType != DNS_TYPE_SRV) + continue; + + strcpy(name, tmp->pName); // don't know if this is safe or right, or should use the + // snprintf(name, 256, "%s", tmp->Data.SRV.pNameTarget); + // be used, feel free to fix it + port = tmp->Data.SRV.wPort; + priority = tmp->Data.SRV.wPriority; + weight = tmp->Data.SRV.wWeight; + + list = g_list_prepend (list, + gibber_resolver_srv_record_new (name, port, priority, weight)); + } + return list; +} +#endif GError * gibber_resolver_gai_error_to_g_error (int error) @@ -788,6 +849,11 @@ resolver_resolv_srv (GibberResolver *resolver, const char *service, GibberResolverServiceType type) { +#ifdef HAVE_DNSQUERY_A + DNS_STATUS dns_status; + PDNS_RECORD dns_record; +#endif + gchar *srv_str; int ret; GList *entries = NULL; @@ -797,6 +863,7 @@ resolver_resolv_srv (GibberResolver *resolver, srv_str = g_strdup_printf ("_%s._%s.%s", service, type == GIBBER_RESOLVER_SERVICE_TYPE_TCP ? "tcp" : "udp", service_name); +#ifdef HAVE_RES_QUERY ret = res_query (srv_str, C_IN, T_SRV, answer, ANSWER_BUFSIZE); if (ret < 0) @@ -808,6 +875,21 @@ resolver_resolv_srv (GibberResolver *resolver, error = g_error_new (GIBBER_RESOLVER_ERROR, GIBBER_RESOLVER_ERROR_RESOLVE_FAILURE, "Invalid reply received"); } +#endif + +#ifdef HAVE_DNSQUERY_A + dns_status = DnsQuery_A(srv_str, DNS_TYPE_SRV, DNS_QUERY_BYPASS_CACHE, NULL, &dns_record, NULL); + if (dns_status != NO_ERROR) { + error = gibber_resolver_h_error_to_g_error (dns_record); + } else { + // convert dns_record list to GList entries + entries = gibber_resolver_res_query_to_list (dns_record); + if (entries == NULL) + error = g_error_new (GIBBER_RESOLVER_ERROR, + GIBBER_RESOLVER_ERROR_RESOLVE_FAILURE, + "Invalid reply received"); + } +#endif gibber_resolver_srv_result (resolver, id, entries, error); diff --git a/lib/gibber/gibber-resolver.h b/lib/gibber/gibber-resolver.h index 4046756..abab104 100644 --- a/lib/gibber/gibber-resolver.h +++ b/lib/gibber/gibber-resolver.h @@ -23,8 +23,17 @@ #include +#ifdef HAVE_SYS_SOCKET_H #include +#endif + +#ifdef HAVE_NETDB_H #include +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif G_BEGIN_DECLS diff --git a/lib/gibber/gibber-tcp-transport.c b/lib/gibber/gibber-tcp-transport.c index 12f98a0..c46a991 100644 --- a/lib/gibber/gibber-tcp-transport.c +++ b/lib/gibber/gibber-tcp-transport.c @@ -38,6 +38,10 @@ #include "errno.h" +#ifdef WIN32 +#include "errno-win32-extend.h" +#endif + G_DEFINE_TYPE(GibberTCPTransport, gibber_tcp_transport, GIBBER_TYPE_FD_TRANSPORT) diff --git a/lib/gibber/gibber-transport.c b/lib/gibber/gibber-transport.c index 82ad73b..e9d2bc4 100644 --- a/lib/gibber/gibber-transport.c +++ b/lib/gibber/gibber-transport.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include diff --git a/lib/gibber/gibber-transport.h b/lib/gibber/gibber-transport.h index cf9b435..8e5db78 100644 --- a/lib/gibber/gibber-transport.h +++ b/lib/gibber/gibber-transport.h @@ -23,7 +23,20 @@ #include +#ifdef HAVE_SYS_SOCKET_H #include +#endif + +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#undef ERROR +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif + G_BEGIN_DECLS diff --git a/lib/gibber/gibber-util.c b/lib/gibber/gibber-util.c index 6f5c572..5e443f0 100644 --- a/lib/gibber/gibber-util.c +++ b/lib/gibber/gibber-util.c @@ -27,6 +27,18 @@ # include #endif +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#ifdef WIN32 +#include "structs-for-win32.h" +#endif + #include "gibber-util.h" void diff --git a/lib/gibber/gibber-util.h b/lib/gibber/gibber-util.h index c6a4e75..386536f 100644 --- a/lib/gibber/gibber-util.h +++ b/lib/gibber/gibber-util.h @@ -20,9 +20,20 @@ #ifndef __GIBBER_UTIL_H__ #define __GIBBER_UTIL_H__ +#ifdef HAVE_NETDB_H #include +#endif + +#ifdef HAVE_NETINET_IN_H #include +#endif +#ifdef HAVE_SYS_SOCKET_H #include +#endif +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#endif #include diff --git a/src/bytestream-socks5.c b/src/bytestream-socks5.c index 548408b..32db9a9 100644 --- a/src/bytestream-socks5.c +++ b/src/bytestream-socks5.c @@ -21,16 +21,42 @@ #include "config.h" #include "bytestream-socks5.h" +#ifdef HAVE_ARPA_INET_H #include +#endif + #include + +#ifdef HAVE_FCNTL_H #include +#endif + +#ifdef HAVE_NETDB_H #include +#endif + +#ifdef HAVE_NET_IF_H #include +#endif + +#ifdef HAVE_NETINET_IN_H #include +#endif + #include + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + +#ifdef HAVE_SYS_SOCKET_H #include +#endif + +#ifdef HAVE_SYS_TYPES_H #include +#endif + #ifdef HAVE_UNISTD_H # include #endif @@ -39,6 +65,20 @@ #include #endif +/* win32 environment */ +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#ifdef WIN32 +#include "structs-for-win32.h" +#endif + #include #include #include diff --git a/src/ft-channel.c b/src/ft-channel.c index b7d7993..73fc7b5 100644 --- a/src/ft-channel.c +++ b/src/ft-channel.c @@ -27,9 +27,12 @@ #include #include #include +#ifdef HAVE_SYS_SOCKET_H #include +#endif +#ifdef HAVE_SYS_UN_H #include - +#endif #ifdef HAVE_UNISTD_H # include #endif diff --git a/src/ft-manager.c b/src/ft-manager.c index c47f97c..76f93bb 100644 --- a/src/ft-manager.c +++ b/src/ft-manager.c @@ -585,6 +585,7 @@ gabble_ft_manager_new (GabbleConnection *connection) NULL); } +#ifdef GIBBER_TYPE_UNIX_TRANSPORT const gchar * gabble_ft_manager_get_tmp_dir (GabbleFtManager *self) { @@ -599,6 +600,7 @@ gabble_ft_manager_get_tmp_dir (GabbleFtManager *self) return self->priv->tmp_dir; } +#endif static void add_file_transfer_channel_class (GPtrArray *arr, diff --git a/src/ft-manager.h b/src/ft-manager.h index 5424c3c..a7428c7 100644 --- a/src/ft-manager.h +++ b/src/ft-manager.h @@ -66,7 +66,9 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self, GabbleBytestreamIface *bytestream, TpHandle handle, const gchar *stream_id, LmMessage *msg); +#ifndef GIBBER_TYPE_UNIX_TRANSPORT const gchar * gabble_ft_manager_get_tmp_dir (GabbleFtManager *self); +#endif G_END_DECLS diff --git a/src/tube-stream.c b/src/tube-stream.c index f859d10..357071e 100644 --- a/src/tube-stream.c +++ b/src/tube-stream.c @@ -22,16 +22,37 @@ #include #include + +#ifdef HAVE_SYS_SOCKET_H #include +#endif +#ifdef HAVE_SYS_UN_H #include +#endif #include #include +#ifdef HAVE_NETDB_H #include +#endif #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_WINSOCK2_H +#include +#undef interface +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif +#ifdef HAVE_WINDOWS_H +#include +#endif +#ifdef HAVE_WINBASE_H +#include +#endif + #include #include #include diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py old mode 100644 new mode 100755