libsoup r1012 - in branches/libsoup-2.4: . libsoup
- From: danw svn gnome org
- To: svn-commits-list gnome org
- Subject: libsoup r1012 - in branches/libsoup-2.4: . libsoup
- Date: Sun, 6 Jan 2008 22:16:12 +0000 (GMT)
Author: danw
Date: Sun Jan 6 22:16:11 2008
New Revision: 1012
URL: http://svn.gnome.org/viewvc/libsoup?rev=1012&view=rev
Log:
* libsoup/soup-address.c: remove the "dns_result" signal, which
was just an implementation detail of soup_address_resolve_async().
Modified:
branches/libsoup-2.4/ChangeLog
branches/libsoup-2.4/libsoup/soup-address.c
branches/libsoup-2.4/libsoup/soup-address.h
Modified: branches/libsoup-2.4/ChangeLog
==============================================================================
--- branches/libsoup-2.4/ChangeLog (original)
+++ branches/libsoup-2.4/ChangeLog Sun Jan 6 22:16:11 2008
@@ -1,5 +1,10 @@
2008-01-06 Dan Winship <danw gnome org>
+ * libsoup/soup-address.c: remove the "dns_result" signal, which
+ was just an implementation detail of soup_address_resolve_async().
+
+2008-01-06 Dan Winship <danw gnome org>
+
* libsoup/*.c: misc documentation updates/gtk-doc fixes
* libsoup/soup-server.c: finally start documenting this properly.
Modified: branches/libsoup-2.4/libsoup/soup-address.c
==============================================================================
--- branches/libsoup-2.4/libsoup/soup-address.c (original)
+++ branches/libsoup-2.4/libsoup/soup-address.c Sun Jan 6 22:16:11 2008
@@ -15,7 +15,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#include <signal.h>
#include "soup-address.h"
#include "soup-dns.h"
@@ -99,13 +98,6 @@
memcpy (SOUP_ADDRESS_GET_DATA (priv), data, length)
-enum {
- DNS_RESULT,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
G_DEFINE_TYPE (SoupAddress, soup_address, G_TYPE_OBJECT)
static void
@@ -146,26 +138,6 @@
/* virtual method override */
object_class->finalize = finalize;
- /* signals */
-
- /**
- * SoupAddress::dns-result:
- * @addr: the #SoupAddress
- * @status: the DNS status code
- *
- * Emitted when an address resolution completes. (This is used
- * internally by soup_address_resolve_async() itself.)
- **/
- signals[DNS_RESULT] =
- g_signal_new ("dns_result",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (SoupAddressClass, dns_result),
- NULL, NULL,
- soup_marshal_NONE__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
#ifdef G_OS_WIN32
/* This hopefully is a good place to call WSAStartup */
{
@@ -363,22 +335,53 @@
static void
-update_address (SoupDNSLookup *lookup, gboolean success, gpointer user_data)
+update_address (SoupAddress *addr, SoupDNSLookup *lookup)
{
- SoupAddress *addr = user_data;
SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
- if (success) {
- if (!priv->name)
- priv->name = soup_dns_lookup_get_hostname (lookup);
-
- if (!priv->sockaddr) {
- priv->sockaddr = soup_dns_lookup_get_address (lookup);
- SOUP_ADDRESS_SET_PORT (priv, htons (priv->port));
- }
+ if (!priv->name)
+ priv->name = soup_dns_lookup_get_hostname (lookup);
+
+ if (!priv->sockaddr) {
+ priv->sockaddr = soup_dns_lookup_get_address (lookup);
+ SOUP_ADDRESS_SET_PORT (priv, htons (priv->port));
}
+}
- g_signal_emit (addr, signals[DNS_RESULT], 0, success ? SOUP_STATUS_OK : SOUP_STATUS_CANT_RESOLVE);
+typedef struct {
+ SoupAddress *addr;
+ SoupAddressCallback callback;
+ gpointer callback_data;
+} SoupAddressResolveAsyncData;
+
+static void
+free_res_data (gpointer res_data, GObject *ex_addr)
+{
+ g_free (res_data);
+}
+
+static void
+lookup_resolved (SoupDNSLookup *lookup, gboolean success, gpointer user_data)
+{
+ SoupAddressResolveAsyncData *res_data = user_data;
+ SoupAddress *addr;
+ SoupAddressCallback callback;
+ gpointer callback_data;
+ guint status;
+
+ addr = res_data->addr;
+ callback = res_data->callback;
+ callback_data = res_data->callback_data;
+ g_object_weak_unref (G_OBJECT (addr), free_res_data, res_data);
+ g_free (res_data);
+
+ if (success)
+ update_address (addr, lookup);
+
+ if (callback) {
+ status = success ? SOUP_STATUS_OK : SOUP_STATUS_CANT_RESOLVE;
+ callback (addr, status, callback_data);
+ }
}
/**
@@ -400,16 +403,18 @@
gpointer user_data)
{
SoupAddressPrivate *priv;
+ SoupAddressResolveAsyncData *res_data;
g_return_if_fail (SOUP_IS_ADDRESS (addr));
priv = SOUP_ADDRESS_GET_PRIVATE (addr);
- if (callback) {
- soup_signal_connect_once (addr, "dns_result",
- G_CALLBACK (callback), user_data);
- }
+ res_data = g_new (SoupAddressResolveAsyncData, 1);
+ res_data->addr = addr;
+ res_data->callback = callback;
+ res_data->callback_data = user_data;
- soup_dns_lookup_resolve_async (priv->lookup, async_context, update_address, addr);
+ g_object_weak_ref (G_OBJECT (addr), free_res_data, res_data);
+ soup_dns_lookup_resolve_async (priv->lookup, async_context, lookup_resolved, res_data);
}
/**
@@ -431,6 +436,7 @@
priv = SOUP_ADDRESS_GET_PRIVATE (addr);
success = soup_dns_lookup_resolve (priv->lookup);
- update_address (priv->lookup, success, addr);
+ if (success)
+ update_address (addr, priv->lookup);
return success ? SOUP_STATUS_OK : SOUP_STATUS_CANT_RESOLVE;
}
Modified: branches/libsoup-2.4/libsoup/soup-address.h
==============================================================================
--- branches/libsoup-2.4/libsoup/soup-address.h (original)
+++ branches/libsoup-2.4/libsoup/soup-address.h Sun Jan 6 22:16:11 2008
@@ -28,8 +28,6 @@
typedef struct {
GObjectClass parent_class;
- /* signals */
- void (*dns_result) (SoupAddress *addr, guint status);
} SoupAddressClass;
/* gtk-doc gets confused if there's an #ifdef inside the typedef */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]