[Swfdec] 4 commits - libswfdec-gtk/swfdec_gtk_loader.c libswfdec/swfdec_file_loader.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h player/swfdec_slow_loader.c

Benjamin Otte company at kemper.freedesktop.org
Thu Aug 2 05:00:49 PDT 2007


 libswfdec-gtk/swfdec_gtk_loader.c |   12 +++++++-----
 libswfdec/swfdec_file_loader.c    |   19 ++++++++++---------
 libswfdec/swfdec_loader.c         |   30 +++++++++++++++++++++++-------
 libswfdec/swfdec_loader.h         |    3 ++-
 player/swfdec_slow_loader.c       |    2 +-
 5 files changed, 43 insertions(+), 23 deletions(-)

New commits:
diff-tree 013119a40898e8308caba54d3921d3c477f239c8 (from f39100edec77edb7207f67dea4182f8c78ac0ed0)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Aug 2 14:01:21 2007 +0200

    pass the parent loader to SwfdecLoader->load()

diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index d2ec771..bc3894a 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -116,14 +116,14 @@ swfdec_gtk_loader_finish (SoupMessage *m
 }
 
 static void
-swfdec_gtk_loader_load (SwfdecLoader *loader,
+swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
     SwfdecLoaderRequest request, const char *data, gsize data_len)
 {
   const SwfdecURL *url = swfdec_loader_get_url (loader);
 
   if (g_ascii_strcasecmp (swfdec_url_get_protocol (url), "http") != 0 &&
       g_ascii_strcasecmp (swfdec_url_get_protocol (url), "https") != 0) {
-    SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader, request, data, data_len);
+    SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader, parent, request, data, data_len);
   } else {
     SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
     SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
@@ -179,6 +179,6 @@ swfdec_gtk_loader_new (const char *uri)
   url = swfdec_url_new (uri);
   loader = g_object_new (SWFDEC_TYPE_GTK_LOADER, "url", url, NULL);
   swfdec_url_free (url);
-  swfdec_gtk_loader_load (loader, SWFDEC_LOADER_REQUEST_DEFAULT, NULL, 0);
+  swfdec_gtk_loader_load (loader, NULL, SWFDEC_LOADER_REQUEST_DEFAULT, NULL, 0);
   return loader;
 }
diff --git a/libswfdec/swfdec_file_loader.c b/libswfdec/swfdec_file_loader.c
index 1eb29fc..9bbb635 100644
--- a/libswfdec/swfdec_file_loader.c
+++ b/libswfdec/swfdec_file_loader.c
@@ -39,7 +39,7 @@
 G_DEFINE_TYPE (SwfdecFileLoader, swfdec_file_loader, SWFDEC_TYPE_LOADER)
 
 static void
-swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoaderRequest request, 
+swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent, SwfdecLoaderRequest request, 
     const char *data, gsize data_len)
 {
   const SwfdecURL *url;
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index 7a22b34..9193f0b 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -254,7 +254,7 @@ swfdec_loader_load (SwfdecLoader *loader
   url = swfdec_url_new_relative (loader->url, url_string);
   ret = g_object_new (G_OBJECT_CLASS_TYPE (klass), "url", url, NULL);
   swfdec_url_free (url);
-  klass->load (ret, request, data, data_len);
+  klass->load (ret, loader, request, data, data_len);
   return ret;
 }
 
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
index 3f5db15..f0bd717 100644
--- a/libswfdec/swfdec_loader.h
+++ b/libswfdec/swfdec_loader.h
@@ -70,8 +70,9 @@ struct _SwfdecLoaderClass
 {
   GObjectClass		object_class;
 
-  /* iitializes the loader. The URL will be set already. */
+  /* initialize the loader. The URL will be set already. */
   void			(* load)	(SwfdecLoader *			loader, 
+					 SwfdecLoader *			parent,
 					 SwfdecLoaderRequest		request,
 					 const char *			data,
 					 gsize				data_len);
diff --git a/player/swfdec_slow_loader.c b/player/swfdec_slow_loader.c
index 603627a..4983052 100644
--- a/player/swfdec_slow_loader.c
+++ b/player/swfdec_slow_loader.c
@@ -111,7 +111,7 @@ swfdec_slow_loader_initialize (SwfdecSlo
 }
 
 static void
-swfdec_slow_loader_load (SwfdecLoader *loader,
+swfdec_slow_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
     SwfdecLoaderRequest request, const char *data, gsize data_len)
 {
   SwfdecSlowLoader *slow = SWFDEC_SLOW_LOADER (loader);
diff-tree f39100edec77edb7207f67dea4182f8c78ac0ed0 (from bc7a31d8af9989ba3e42d9bd9431989f713cd847)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Aug 2 13:32:20 2007 +0200

    notify when URL changes

diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index 4be84d1..7a22b34 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -353,6 +353,7 @@ swfdec_loader_open (SwfdecLoader *loader
   if (url) {
     swfdec_url_free (loader->url);
     loader->url = swfdec_url_new (url);
+    g_object_notify (G_OBJECT (loader), "url");
   }
   if (loader->player)
     swfdec_player_add_external_action (loader->player, loader, swfdec_loader_perform_open, NULL);
diff-tree bc7a31d8af9989ba3e42d9bd9431989f713cd847 (from 8e84cd0b6b34869ad07ff61bb44869ad201dea8c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Aug 2 13:31:29 2007 +0200

    make url a construct-only property

diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index fa2cf44..d2ec771 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -172,11 +172,13 @@ SwfdecLoader *
 swfdec_gtk_loader_new (const char *uri)
 {
   SwfdecLoader *loader;
+  SwfdecURL *url;
 
   g_return_val_if_fail (uri != NULL, NULL);
 
-  loader = g_object_new (SWFDEC_TYPE_GTK_LOADER, NULL);
-  loader->url = swfdec_url_new (uri);
+  url = swfdec_url_new (uri);
+  loader = g_object_new (SWFDEC_TYPE_GTK_LOADER, "url", url, NULL);
+  swfdec_url_free (url);
   swfdec_gtk_loader_load (loader, SWFDEC_LOADER_REQUEST_DEFAULT, NULL, 0);
   return loader;
 }
diff --git a/libswfdec/swfdec_file_loader.c b/libswfdec/swfdec_file_loader.c
index 54308c8..1eb29fc 100644
--- a/libswfdec/swfdec_file_loader.c
+++ b/libswfdec/swfdec_file_loader.c
@@ -49,7 +49,7 @@ swfdec_file_loader_load (SwfdecLoader *l
 
   url = swfdec_loader_get_url (loader);
   if (!g_str_equal (swfdec_url_get_protocol (url), "file")) {
-    swfdec_loader_error (loader, "Don't know how to handle other protocols than file");
+    swfdec_loader_error (loader, "Don't know how to handle this protocol");
     return;
   }
   if (swfdec_url_get_host (url)) {
@@ -99,27 +99,28 @@ swfdec_file_loader_new (const char *file
   SwfdecBuffer *buf;
   SwfdecLoader *loader;
   GError *error = NULL;
-  char *url;
+  char *url_string;
+  SwfdecURL *url;
 
   g_return_val_if_fail (filename != NULL, NULL);
 
   buf = swfdec_buffer_new_from_file (filename, &error);
 
   if (g_path_is_absolute (filename)) {
-    url = g_strconcat ("file://", filename, NULL);
+    url_string = g_strconcat ("file://", filename, NULL);
   } else {
     char *abs, *cur;
     cur = g_get_current_dir ();
     abs = g_build_filename (cur, filename, NULL);
     g_free (cur);
-    url = g_strconcat ("file://", abs, NULL);
+    url_string = g_strconcat ("file://", abs, NULL);
     g_free (abs);
   }
 
-  loader = g_object_new (SWFDEC_TYPE_FILE_LOADER, NULL);
-  loader->url = swfdec_url_new (url);
-  g_assert (loader->url);
-  g_free (url);
+  url = swfdec_url_new (url_string);
+  g_free (url_string);
+  loader = g_object_new (SWFDEC_TYPE_FILE_LOADER, "url", url, NULL);
+  swfdec_url_free (url);
   if (buf == NULL) {
     swfdec_loader_error (loader, error->message);
     g_error_free (error);
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index ae4992d..4be84d1 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -89,7 +89,8 @@ enum {
   PROP_EOF,
   PROP_DATA_TYPE,
   PROP_SIZE,
-  PROP_LOADED
+  PROP_LOADED,
+  PROP_URL
 };
 
 G_DEFINE_ABSTRACT_TYPE (SwfdecLoader, swfdec_loader, G_TYPE_OBJECT)
@@ -116,6 +117,9 @@ swfdec_loader_get_property (GObject *obj
     case PROP_LOADED:
       g_value_set_ulong (value, swfdec_loader_get_loaded (loader));
       break;
+    case PROP_URL:
+      g_value_set_boxed (value, loader->url);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -136,6 +140,13 @@ swfdec_loader_set_property (GObject *obj
       if (loader->size == 0 && g_value_get_ulong (value) > 0)
 	swfdec_loader_set_size (loader, g_value_get_ulong (value));
       break;
+    case PROP_URL:
+      loader->url = g_value_dup_boxed (value);
+      if (loader->url == NULL) {
+	g_warning ("must set a valid URL");
+	loader->url = swfdec_url_new ("");
+      }
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -180,6 +191,9 @@ swfdec_loader_class_init (SwfdecLoaderCl
   g_object_class_install_property (object_class, PROP_LOADED,
       g_param_spec_ulong ("loaded", "loaded", "bytes already loaded",
 	  0, G_MAXULONG, 0, G_PARAM_READWRITE));
+  g_object_class_install_property (object_class, PROP_URL,
+      g_param_spec_boxed ("url", "url", "URL for this file",
+	  SWFDEC_TYPE_URL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
@@ -224,11 +238,12 @@ swfdec_loader_perform_push (gpointer loa
 }
 
 SwfdecLoader *
-swfdec_loader_load (SwfdecLoader *loader, const char *url,
+swfdec_loader_load (SwfdecLoader *loader, const char *url_string,
     SwfdecLoaderRequest request, const char *data, gsize data_len)
 {
   SwfdecLoader *ret;
   SwfdecLoaderClass *klass;
+  SwfdecURL *url;
 
   g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
   g_return_val_if_fail (url != NULL, NULL);
@@ -236,9 +251,9 @@ swfdec_loader_load (SwfdecLoader *loader
 
   klass = SWFDEC_LOADER_GET_CLASS (loader);
   g_return_val_if_fail (klass->load != NULL, NULL);
-  ret = g_object_new (G_OBJECT_CLASS_TYPE (klass), NULL);
-  ret->url = swfdec_url_new_relative (loader->url, url);
-  g_assert (ret->url);
+  url = swfdec_url_new_relative (loader->url, url_string);
+  ret = g_object_new (G_OBJECT_CLASS_TYPE (klass), "url", url, NULL);
+  swfdec_url_free (url);
   klass->load (ret, request, data, data_len);
   return ret;
 }
diff-tree 8e84cd0b6b34869ad07ff61bb44869ad201dea8c (from 91a700e70f6215216fa03f166f37ded1d7e62afd)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Aug 2 13:14:24 2007 +0200

    use right property enum value

diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index 9e8a9a5..ae4992d 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -177,7 +177,7 @@ swfdec_loader_class_init (SwfdecLoaderCl
   g_object_class_install_property (object_class, PROP_SIZE,
       g_param_spec_ulong ("size", "size", "amount of bytes in loader",
 	  0, G_MAXULONG, 0, G_PARAM_READWRITE));
-  g_object_class_install_property (object_class, PROP_SIZE,
+  g_object_class_install_property (object_class, PROP_LOADED,
       g_param_spec_ulong ("loaded", "loaded", "bytes already loaded",
 	  0, G_MAXULONG, 0, G_PARAM_READWRITE));
 }


More information about the Swfdec mailing list