[rhythmbox] daap: Fix “Host” HTTP header on manual daap (bug #584927)
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Subject: [rhythmbox] daap: Fix “Host” HTTP header on manual daap (bug #584927)
- Date: Wed, 10 Jun 2009 04:50:19 -0400 (EDT)
commit b6c3b13f7a4cb6a909c495c41a9eb2d66635ee71
Author: Jean-Philippe Garcia Ballester <giga le-pec org>
Date: Sat Jun 6 08:53:20 2009 +0200
daap: Fix â??Hostâ?? HTTP header on manual daap (bug #584927)
Do not resolve DAAP server hostname when adding a new DAAP share, but
instead store the hostname in the RBSource object.
Resolve the hostname only when necessary, i.e. when connecting with
â??socketâ?? and â??connectâ??.
---
plugins/daap/rb-daap-plugin.c | 81 +++++++++--------------------------------
plugins/daap/rb-daap-src.c | 13 ++++++-
2 files changed, 29 insertions(+), 65 deletions(-)
diff --git a/plugins/daap/rb-daap-plugin.c b/plugins/daap/rb-daap-plugin.c
index 62f394c..52edc7c 100644
--- a/plugins/daap/rb-daap-plugin.c
+++ b/plugins/daap/rb-daap-plugin.c
@@ -622,45 +622,6 @@ rb_daap_plugin_cmd_disconnect (GtkAction *action,
}
}
-typedef struct {
- RBDaapPlugin *plugin;
- char *service_name;
- char *location;
-} RBDaapShareResolveData;
-
-static void
-new_daap_share_resolve_cb (SoupAddress *addr,
- guint status,
- RBDaapShareResolveData *data)
-{
- GDK_THREADS_ENTER ();
-
- if (status == SOUP_STATUS_OK) {
- rb_debug ("adding manually specified DAAP share at %s", data->location);
- mdns_service_added (NULL,
- data->service_name,
- data->location,
- soup_address_get_physical (addr),
- soup_address_get_port (addr),
- FALSE,
- data->plugin);
- } else {
- rb_debug ("unable to resolve DAAP share address %s",
- data->location);
- rb_error_dialog (NULL, _("Could not connect to shared music"),
- _("Unable to resolve hostname %s"),
- data->location);
- }
-
- g_object_unref (data->plugin);
- g_free (data->service_name);
- g_free (data->location);
- g_free (data);
- g_object_unref (addr);
-
- GDK_THREADS_LEAVE ();
-}
-
static void
new_daap_share_location_added_cb (RBURIDialog *dialog,
const char *location,
@@ -669,13 +630,6 @@ new_daap_share_location_added_cb (RBURIDialog *dialog,
char *host;
char *p;
int port = 3689;
- SoupAddress *addr;
- RBDaapShareResolveData *data;
-
- data = g_new0 (RBDaapShareResolveData, 1);
- data->plugin = g_object_ref (plugin);
- data->service_name = g_strdup (location);
- data->location = g_strdup (location);
host = g_strdup (location);
p = strrchr (host, ':');
@@ -684,13 +638,17 @@ new_daap_share_location_added_cb (RBURIDialog *dialog,
*p = '\0';
}
- addr = soup_address_new (host, port);
+ rb_debug ("adding manually specified DAAP share at %s", location);
+ mdns_service_added (NULL,
+ g_strdup (location),
+ g_strdup (location),
+ g_strdup (host),
+ port,
+ FALSE,
+ plugin);
+
g_free (host);
- soup_address_resolve_async (addr,
- NULL, NULL,
- (SoupAddressCallback) new_daap_share_resolve_cb,
- data);
}
static void
@@ -944,25 +902,20 @@ impl_create_configure_dialog (RBPlugin *bplugin)
gboolean
rb_daap_add_source (RBDaapPlugin *plugin, gchar *service_name, gchar *host, unsigned int port, GError **error)
{
- SoupAddress *addr;
- RBDaapShareResolveData *data;
if (plugin->priv->shutdown)
return FALSE;
rb_debug ("Add DAAP source %s (%s:%d)", service_name, host, port);
- data = g_new0 (RBDaapShareResolveData, 1);
- data->plugin = g_object_ref (plugin);
- data->service_name = g_strdup (service_name);
- data->location = g_strdup (service_name);
-
- addr = soup_address_new (host, port);
-
- soup_address_resolve_async (addr,
- NULL, NULL,
- (SoupAddressCallback) new_daap_share_resolve_cb,
- data);
+ rb_debug ("adding manually specified DAAP share at %s", service_name);
+ mdns_service_added (NULL,
+ g_strdup (service_name),
+ g_strdup (service_name),
+ g_strdup (host),
+ port,
+ FALSE,
+ plugin);
return TRUE;
}
diff --git a/plugins/daap/rb-daap-src.c b/plugins/daap/rb-daap-src.c
index 66c37f2..e217c15 100644
--- a/plugins/daap/rb-daap-src.c
+++ b/plugins/daap/rb-daap-src.c
@@ -448,6 +448,7 @@ rb_daap_src_open (RBDAAPSrc *src)
guint http_status;
gchar *http_status_phrase = NULL;
gboolean parse_result;
+ SoupAddress *addr;
if (src->buffer_base) {
g_free (src->buffer_base);
@@ -467,9 +468,17 @@ rb_daap_src_open (RBDAAPSrc *src)
_split_uri (src->daap_uri, &host, &port, &path);
+ GST_DEBUG_OBJECT (src, "resolving server %s", host);
+ addr = soup_address_new (host, port);
+ if (soup_address_resolve_sync (addr, NULL) != SOUP_STATUS_OK) {
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
+ ("Resolving %s failed", host));
+ return FALSE;
+ }
+
server.sin_family = AF_INET;
server.sin_port = htons (port);
- server.sin_addr.s_addr = inet_addr (host);
+ server.sin_addr.s_addr = inet_addr (soup_address_get_physical (addr));
memset (&server.sin_zero, 0, sizeof (server.sin_zero));
GST_DEBUG_OBJECT (src, "connecting to server %s:%d", host, port);
@@ -489,6 +498,8 @@ rb_daap_src_open (RBDAAPSrc *src)
return FALSE;
}
+ g_object_unref (addr);
+
/* construct request */
source = rb_daap_plugin_find_source_for_uri (daap_plugin, src->daap_uri);
if (source == NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]