[Swfdec] 3 commits - libswfdec-gtk/swfdec_gtk_loader.c
Benjamin Otte
company at kemper.freedesktop.org
Sun Aug 19 08:53:31 PDT 2007
libswfdec-gtk/swfdec_gtk_loader.c | 57 +++++++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 16 deletions(-)
New commits:
diff-tree 5d29f9261756c094b4d0f9a80da05fb6892094bf (from 58fb9a2cd750b3fb08db924a7c2e52d38b766630)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Aug 19 17:53:43 2007 +0200
disconnect signal handlers before dispose
Also make the finished function a signal handler, so we can disconnect it
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index 65897bc..c98f029 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -68,19 +68,6 @@ struct _SwfdecGtkLoaderClass {
G_DEFINE_TYPE (SwfdecGtkLoader, swfdec_gtk_loader, SWFDEC_TYPE_FILE_LOADER)
static void
-swfdec_gtk_loader_dispose (GObject *object)
-{
- SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (object);
-
- if (gtk->message) {
- g_object_unref (gtk->message);
- gtk->message = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_gtk_loader_parent_class)->dispose (object);
-}
-
-static void
swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
{
char *real_uri;
@@ -123,7 +110,7 @@ swfdec_gtk_loader_headers (SoupMessage *
}
static void
-swfdec_gtk_loader_finish (SoupMessage *msg, gpointer loader)
+swfdec_gtk_loader_finished (SoupMessage *msg, gpointer loader)
{
if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
swfdec_gtk_loader_ensure_open (loader);
@@ -136,6 +123,22 @@ swfdec_gtk_loader_finish (SoupMessage *m
}
static void
+swfdec_gtk_loader_dispose (GObject *object)
+{
+ SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (object);
+
+ if (gtk->message) {
+ g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_push, gtk);
+ g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_headers, gtk);
+ g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_finished, gtk);
+ g_object_unref (gtk->message);
+ gtk->message = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_gtk_loader_parent_class)->dispose (object);
+}
+
+static void
swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
SwfdecLoaderRequest request, const char *data, gsize data_len)
{
@@ -153,11 +156,12 @@ swfdec_gtk_loader_load (SwfdecLoader *lo
soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk);
g_signal_connect (gtk->message, "got-headers", G_CALLBACK (swfdec_gtk_loader_headers), gtk);
+ g_signal_connect (gtk->message, "finished", G_CALLBACK (swfdec_gtk_loader_finished), gtk);
if (data)
soup_message_set_request (gtk->message, "appliation/x-www-urlencoded",
SOUP_BUFFER_USER_OWNED, (char *) data, data_len);
g_object_ref (gtk->message);
- soup_session_queue_message (klass->session, gtk->message, swfdec_gtk_loader_finish, gtk);
+ soup_session_queue_message (klass->session, gtk->message, NULL, NULL);
}
}
diff-tree 58fb9a2cd750b3fb08db924a7c2e52d38b766630 (from c46107bbab094d82091c60aa7abb04c61eb17140)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Aug 19 17:34:37 2007 +0200
implement swfdec_loader_set_size() by reading Content-Length header
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index 415d418..65897bc 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -22,6 +22,8 @@
#endif
#include <libsoup/soup.h>
+#include <errno.h>
+#include <stdlib.h>
#include <string.h>
#include "swfdec_gtk_loader.h"
@@ -105,6 +107,22 @@ swfdec_gtk_loader_push (SoupMessage *msg
}
static void
+swfdec_gtk_loader_headers (SoupMessage *msg, gpointer loader)
+{
+ const char *s = soup_message_get_header (msg->response_headers, "Content-Length");
+ unsigned long l;
+ char *end;
+
+ if (s == NULL)
+ return;
+
+ errno = 0;
+ l = strtoul (s, &end, 10);
+ if (errno == 0 && *end == 0)
+ swfdec_loader_set_size (loader, l);
+}
+
+static void
swfdec_gtk_loader_finish (SoupMessage *msg, gpointer loader)
{
if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
@@ -134,6 +152,7 @@ swfdec_gtk_loader_load (SwfdecLoader *lo
swfdec_url_get_url (url));
soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk);
+ g_signal_connect (gtk->message, "got-headers", G_CALLBACK (swfdec_gtk_loader_headers), gtk);
if (data)
soup_message_set_request (gtk->message, "appliation/x-www-urlencoded",
SOUP_BUFFER_USER_OWNED, (char *) data, data_len);
diff-tree c46107bbab094d82091c60aa7abb04c61eb17140 (from 5307f431c31026bf25f1abe9e642bb26256b3a5a)
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Aug 19 16:58:45 2007 +0200
print a useful error message
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index aff6da1..415d418 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -111,7 +111,9 @@ swfdec_gtk_loader_finish (SoupMessage *m
swfdec_gtk_loader_ensure_open (loader);
swfdec_loader_eof (loader);
} else {
- swfdec_loader_error (loader, "FIXME: make useful error message");
+ char *s = g_strdup_printf ("%u %s", msg->status_code, msg->reason_phrase);
+ swfdec_loader_error (loader, s);
+ g_free (s);
}
}
More information about the Swfdec
mailing list