[Rhythmbox-devel] [patch] libsoup related bug in audioscrobbler plugin
- From: Claudio Saavedra <csaavedra alumnos utalca cl>
- To: Rhythmbox-devel list <rhythmbox-devel gnome org>
- Subject: [Rhythmbox-devel] [patch] libsoup related bug in audioscrobbler plugin
- Date: Sat, 22 Mar 2008 00:13:36 -0300
Hi all,
I found out that when rb saves songs to AS queue, later they get
scrobbled in a URI fashion encoding, like this:
Jerry%20Cantrell – Breaks%20my%20Back
instead of
Jerry Cantrell – Breaks my Back
I did some research and found out that this is due to some changes in
the libsoup API during the 2.3 cycle:
2008-01-14 Dan Winship <danw gnome org>
[...]
(soup_uri_decode, soup_uri_normalize): Change these to return the
decoded/normalized string rather than modifying it in place.
[...]
So, I cooked a patch to fix this, while keeping compatibility with
libsoup 2.2. Patch is attached. It is worth noting that this also caused
some memory leaks.
Ok to commit?
Claudio
--
Claudio Saavedra <csaavedra alumnos utalca cl>
Index: plugins/audioscrobbler/rb-audioscrobbler.c
===================================================================
--- plugins/audioscrobbler/rb-audioscrobbler.c (revisión: 5639)
+++ plugins/audioscrobbler/rb-audioscrobbler.c (copia de trabajo)
@@ -1456,6 +1456,22 @@ void audioscrobbler_encoded_entry_free (
g_free (entry);
}
+/* This function wraps the call to soup_decode_string(), to avoid
+ having tons of ifdef everywhere. */
+
+static gchar *
+rb_audioscrobbler_decode_string (const gchar *uri)
+{
+ gchar *decoded;
+
+#ifdef HAVE_LIBSOUP_2_2
+ decoded = g_strdup (uri);
+ soup_uri_decode (decoded);
+#else
+ decoded = soup_uri_decode (uri);
+#endif
+ return decoded;
+}
/* Queue functions: */
@@ -1477,23 +1493,19 @@ rb_audioscrobbler_load_entry_from_string
if (breaks2[0] != NULL && breaks2[1] != NULL) {
if (g_str_has_prefix (breaks2[0], "a")) {
g_free (entry->artist);
- entry->artist = g_strdup (breaks2[1]);
- soup_uri_decode (entry->artist);
+ entry->artist = rb_audioscrobbler_decode_string (breaks2[1]);
}
if (g_str_has_prefix (breaks2[0], "t")) {
g_free (entry->title);
- entry->title = g_strdup (breaks2[1]);
- soup_uri_decode (entry->title);
+ entry->title = rb_audioscrobbler_decode_string (breaks2[1]);
}
if (g_str_has_prefix (breaks2[0], "b")) {
g_free (entry->album);
- entry->album = g_strdup (breaks2[1]);
- soup_uri_decode (entry->album);
+ entry->album = rb_audioscrobbler_decode_string (breaks2[1]);
}
if (g_str_has_prefix (breaks2[0], "m")) {
g_free (entry->mbid);
- entry->mbid = g_strdup (breaks2[1]);
- soup_uri_decode (entry->mbid);
+ entry->mbid = rb_audioscrobbler_decode_string (breaks2[1]);
}
if (g_str_has_prefix (breaks2[0], "l")) {
entry->length = atoi (breaks2[1]);
Index: ChangeLog
===================================================================
--- ChangeLog (revisión: 5641)
+++ ChangeLog (copia de trabajo)
@@ -1,3 +1,11 @@
+2008-03-22 Claudio Saavedra <csaavedra gnome org>
+
+ * plugins/audioscrobbler/rb-audioscrobbler.c:
+ (+rb_audioscrobbler_decode_string),
+ (rb_audioscrobbler_load_entry_from_string): Wrap calls to
+ soup_uri_decode, depending on libsoup version, to avoid scrobbling
+ encoded strings.
+
2008-03-22 Jonathan Matthew <jonathan d14n org>
* doc/reference/rhythmbox-sections.txt:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]