[gnio: 6/7] Port to final gresolver API; this now builds against glib master
- From: Ryan Lortie <ryanl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnio: 6/7] Port to final gresolver API; this now builds against glib master
- Date: Sun, 26 Apr 2009 01:10:43 -0400 (EDT)
commit 486cbb68cdb900ba0704fd4faa71905b4b409c04
Author: Dan Winship <danw gnome org>
Date: Sat Apr 25 14:00:17 2009 -0400
Port to final gresolver API; this now builds against glib master
---
configure.ac | 4 ++--
gio/gsocketclient.c | 38 +++++++++++++++++++++-----------------
2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2e05596..f86a3df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,8 +14,8 @@ PKG_CHECK_MODULES(gnutls, gnutls)
PKG_CHECK_MODULES(gio, gio-unix-2.0)
gnio_saved_libs="$LIBS"
LIBS="$LIBS $gio_LIBS"
-AC_CHECK_FUNC(g_inet_address_get_is_any,,
- AC_MSG_ERROR([gnio requires the gresolver branch of glib (git://git.desrt.ca/glib)]))
+AC_CHECK_FUNC(g_socket_connectable_enumerate,,
+ AC_MSG_ERROR([gnio requires a new glib (git://git.gnome.org/glib)]))
LIBS="$gnio_saved_libs"
diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c
index 8c4002b..c93d218 100644
--- a/gio/gsocketclient.c
+++ b/gio/gsocketclient.c
@@ -22,6 +22,7 @@
#include "gsocketclient.h"
+#include <gio/gsocketaddressenumerator.h>
#include <gio/gsocketconnectable.h>
#include <gio/gsimpleasyncresult.h>
#include <gio/gcancellable.h>
@@ -57,22 +58,24 @@ g_socket_client_connect (GSocketClient *client,
{
GSocketConnection *connection = NULL;
GSocketClientClass *class;
+ GSocketAddressEnumerator *enumerator;
class = G_SOCKET_CLIENT_GET_CLASS (client);
+ enumerator = g_socket_connectable_enumerate (connectable);
while (!connection && !g_cancellable_is_cancelled (cancellable))
{
GSocketAddress *address;
GSocket *socket;
address =
- g_socket_connectable_get_next (connectable, cancellable, error);
+ g_socket_address_enumerator_next (enumerator, cancellable, error);
if (address == NULL)
{
g_assert (error == NULL || *error != NULL);
- return NULL;
+ break;
}
/* clear error from previous attempt */
@@ -89,6 +92,7 @@ g_socket_client_connect (GSocketClient *client,
g_object_unref (socket);
}
+ g_object_unref (enumerator);
return connection;
}
@@ -99,7 +103,7 @@ typedef struct
GCancellable *cancellable;
GSocketClient *client;
- GSocketConnectable *connectable;
+ GSocketAddressEnumerator *enumerator;
GSocket *current_socket;
GError *last_error;
@@ -134,9 +138,9 @@ g_socket_client_async_connect_complete (GSocketClientAsyncConnectData *data)
static void
-g_socket_client_connectable_callback (GObject *object,
- GAsyncResult *result,
- gpointer user_data);
+g_socket_client_enumerator_callback (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data);
static gboolean
g_socket_client_socket_callback (GSocketClientAsyncConnectData *data,
@@ -159,8 +163,8 @@ g_socket_client_socket_callback (GSocketClientAsyncConnectData *data,
data->current_socket = NULL;
/* try next one */
- g_socket_connectable_get_next_async (data->connectable,
- data->cancellable, g_socket_client_connectable_callback, data);
+ g_socket_address_enumerator_next_async (data->enumerator,
+ data->cancellable, g_socket_client_enumerator_callback, data);
return FALSE;
}
@@ -180,9 +184,9 @@ g_socket_client_socket_callback (GSocketClientAsyncConnectData *data,
}
static void
-g_socket_client_connectable_callback (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
+g_socket_client_enumerator_callback (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
GSocketClientAsyncConnectData *data = user_data;
GSocketAddress *address;
@@ -190,8 +194,8 @@ g_socket_client_connectable_callback (GObject *object,
{
GError *tmp_error = NULL;
- address = g_socket_connectable_get_next_finish (data->connectable,
- result, &tmp_error);
+ address = g_socket_address_enumerator_next_finish (data->enumerator,
+ result, &tmp_error);
if ((address || tmp_error) && data->last_error)
g_clear_error (&data->last_error);
@@ -267,11 +271,11 @@ g_socket_client_connect_async (GSocketClient *client,
else
data->cancellable = NULL;
data->last_error = NULL;
- data->connectable = g_object_ref (connectable);
+ data->enumerator = g_socket_connectable_enumerate (connectable);
- g_socket_connectable_get_next_async (connectable, cancellable,
- g_socket_client_connectable_callback,
- data);
+ g_socket_address_enumerator_next_async (data->enumerator, cancellable,
+ g_socket_client_enumerator_callback,
+ data);
}
GSocketConnection *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]