diff options
author | Benjamin Otte <otte@gnome.org> | 2007-10-17 22:28:52 +0200 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2007-10-17 22:28:52 +0200 |
commit | 9d8262b31d4e3049462528c0ffce33ceb8f27a32 (patch) | |
tree | 7ad43f56c7b397bcf967adeddb11e47d2bfbf7fb | |
parent | 01bc1a4f6f6ee518b86fad561bd1887c53b3c35e (diff) |
add a SwfdecSecurity object to the SwfdecPlayer
-rw-r--r-- | libswfdec/swfdec_flash_security.c | 17 | ||||
-rw-r--r-- | libswfdec/swfdec_flash_security.h | 3 | ||||
-rw-r--r-- | libswfdec/swfdec_player.c | 23 | ||||
-rw-r--r-- | libswfdec/swfdec_player_internal.h | 2 |
4 files changed, 35 insertions, 10 deletions
diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c index 0b6d07c5..1a885349 100644 --- a/libswfdec/swfdec_flash_security.c +++ b/libswfdec/swfdec_flash_security.c @@ -82,6 +82,8 @@ swfdec_flash_security_init (SwfdecFlashSecurity *sec) /** * swfdec_flash_security_new: + * @allow_local: %TRUE to allow playback of local files + * @allow_remote: %TRUE to allow playback of remote files * * Creates a new Security object that allows everything. These objects are used * by default when no other security object is in use. This is particularly @@ -91,15 +93,12 @@ swfdec_flash_security_init (SwfdecFlashSecurity *sec) * Returns: a new #SwfdecSecurity object **/ SwfdecSecurity * -swfdec_flash_security_new (void) +swfdec_flash_security_new (gboolean allow_local, gboolean allow_remote) { - static SwfdecSecurity *singleton = NULL; + SwfdecFlashSecurity *ret; - /* FIXME: not threadsafe */ - if (singleton) - return g_object_ref (singleton); - - singleton = g_object_new (SWFDEC_TYPE_FLASH_SECURITY, NULL); - g_object_add_weak_pointer (G_OBJECT (singleton), (gpointer) &singleton); - return singleton; + ret = g_object_new (SWFDEC_TYPE_FLASH_SECURITY, NULL); + ret->allow_local = allow_local; + ret->allow_remote = allow_remote; + return SWFDEC_SECURITY (ret); } diff --git a/libswfdec/swfdec_flash_security.h b/libswfdec/swfdec_flash_security.h index 3cbb7cbb..00dd14fc 100644 --- a/libswfdec/swfdec_flash_security.h +++ b/libswfdec/swfdec_flash_security.h @@ -49,7 +49,8 @@ struct _SwfdecFlashSecurityClass GType swfdec_flash_security_get_type (void); -SwfdecSecurity * swfdec_flash_security_new (void); +SwfdecSecurity * swfdec_flash_security_new (gboolean allow_local, + gboolean allow_remote); G_END_DECLS diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index 80379279..e4e8eee2 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -36,6 +36,7 @@ #include "swfdec_debug.h" #include "swfdec_enums.h" #include "swfdec_event.h" +#include "swfdec_flash_security.h" #include "swfdec_initialize.h" #include "swfdec_internal.h" #include "swfdec_loader_internal.h" @@ -803,6 +804,10 @@ swfdec_player_dispose (GObject *object) g_object_unref (player->loader); player->loader = NULL; } + if (player->security) { + g_object_unref (player->security); + player->security = NULL; + } if (player->system) { g_object_unref (player->system); player->system = NULL; @@ -1745,6 +1750,23 @@ swfdec_player_launch (SwfdecPlayer *player, SwfdecLoaderRequest request, const c g_signal_emit (player, signals[LAUNCH], 0, request, url, target, data); } +static void +swfdec_player_create_security (SwfdecPlayer *player, guint version) +{ + const SwfdecURL *url; + gboolean allow_local, allow_remote; + + url = swfdec_loader_get_url (player->loader); + if (version > 7) { + allow_local = FALSE; + allow_remote = swfdec_url_has_protocol (url, "http"); + } else { + allow_local = swfdec_url_has_protocol (url, "file"); + allow_remote = TRUE; + } + player->security = swfdec_flash_security_new (allow_local, allow_remote); +} + /** * swfdec_player_initialize: * @player: a #SwfdecPlayer @@ -1787,6 +1809,7 @@ swfdec_player_initialize (SwfdecPlayer *player, guint version, } } SWFDEC_INFO ("initializing player to size %ux%u", width, height); + swfdec_player_create_security (player, version); player->rate = rate; player->width = width; player->height = height; diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index f5c25577..fa34f683 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -25,6 +25,7 @@ #include <libswfdec/swfdec_audio.h> #include <libswfdec/swfdec_rect.h> #include <libswfdec/swfdec_ringbuffer.h> +#include <libswfdec/swfdec_security.h> #include <libswfdec/swfdec_system.h> G_BEGIN_DECLS @@ -62,6 +63,7 @@ struct _SwfdecPlayer gboolean bgcolor_set; /* TRUE if the background color has been set */ SwfdecColor bgcolor; /* background color */ SwfdecLoader * loader; /* initial loader */ + SwfdecSecurity * security; /* the default security */ /* stage properties */ guint internal_width; /* width used by the scripting engine */ guint internal_height; /* height used by the scripting engine */ |