Benjamin Otte
2007-Oct-17 21:31 UTC
[Swfdec] 28 commits - configure.ac debian/changelog debian/control debian/copyright debian/.gitignore debian/libswfdec0.dirs debian/libswfdec0.files debian/libswfdec0.shlibs debian/libswfdec-dev.dirs debian/libswfdec-dev.files debian/rules debian/swf-player.dirs debian/swf-player.files doc/Makefile.am doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_function.c libswfdec/swfdec_as_function.h libswfdec/swfdec_as_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_object.c libswfdec/swfdec_flash_security.c libswfdec/swfdec_flash_security.h libswfdec/swfdec_load_object_as.c libswfdec/swfdec_load_object.c libswfdec/swfdec_load_object.h libswfdec/swfdec_marshal.list libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h libswfdec/swfdec_security_allow.c libswfdec/swfdec_security_allow.h libswfdec/swfdec_security.c libswfdec/swfdec_security.h libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_sprite_movie.h libswfdec/swfdec_swf_decoder.h libswfdec/swfdec_swf_instance.c libswfdec/swfdec_tag.c libswfdec/swfdec_types.h libswfdec/swfdec_url.c libswfdec/swfdec_url.h libswfdec/swfdec_utils.c libswfdec/swfdec_utils.h Makefile.am swfdec.spec.in test/dump.c
Makefile.am | 1 configure.ac | 1 debian/.gitignore | 1 debian/changelog | 54 ----------- debian/control | 36 ------- debian/copyright | 10 -- debian/libswfdec-dev.dirs | 2 debian/libswfdec-dev.files | 5 - debian/libswfdec0.dirs | 1 debian/libswfdec0.files | 1 debian/libswfdec0.shlibs | 1 debian/rules | 112 ------------------------ debian/swf-player.dirs | 3 debian/swf-player.files | 5 - doc/Makefile.am | 4 doc/swfdec-sections.txt | 1 libswfdec/Makefile.am | 6 + libswfdec/swfdec_as_context.c | 6 + libswfdec/swfdec_as_frame.c | 37 ++++++++ libswfdec/swfdec_as_frame_internal.h | 4 libswfdec/swfdec_as_function.c | 20 ++++ libswfdec/swfdec_as_function.h | 2 libswfdec/swfdec_as_internal.h | 7 + libswfdec/swfdec_as_interpret.c | 79 ++++++++++++----- libswfdec/swfdec_as_object.c | 33 +++++-- libswfdec/swfdec_flash_security.c | 104 ++++++++++++++++++++++ libswfdec/swfdec_flash_security.h | 57 ++++++++++++ libswfdec/swfdec_load_object.c | 10 +- libswfdec/swfdec_load_object.h | 4 libswfdec/swfdec_load_object_as.c | 2 libswfdec/swfdec_marshal.list | 1 libswfdec/swfdec_movie.c | 60 ------------- libswfdec/swfdec_movie.h | 8 - libswfdec/swfdec_net_stream.c | 3 libswfdec/swfdec_player.c | 159 +++++++++++++++++++++++++++++++++-- libswfdec/swfdec_player_internal.h | 20 +++- libswfdec/swfdec_security.c | 87 +++++++++++++++++++ libswfdec/swfdec_security.h | 62 +++++++++++++ libswfdec/swfdec_security_allow.c | 79 +++++++++++++++++ libswfdec/swfdec_security_allow.h | 53 +++++++++++ libswfdec/swfdec_sprite_movie.c | 42 +++++++++ libswfdec/swfdec_sprite_movie.h | 8 + libswfdec/swfdec_swf_decoder.h | 2 libswfdec/swfdec_swf_instance.c | 26 +++++ libswfdec/swfdec_tag.c | 10 +- libswfdec/swfdec_types.h | 1 libswfdec/swfdec_url.c | 22 ++++ libswfdec/swfdec_url.h | 3 libswfdec/swfdec_utils.c | 28 ++++++ libswfdec/swfdec_utils.h | 8 + swfdec.spec.in | 92 -------------------- test/dump.c | 12 +- 52 files changed, 943 insertions(+), 452 deletions(-) New commits: commit f1ed8d1217c79d57d94ed690eea4ee19bd0cc65e Merge: 6eaa4d5... 2e79c95... Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 23:26:18 2007 +0200 Merge branch 'master' of ssh://company at git.freedesktop.org/git/swfdec/swfdec commit 6eaa4d583a246c55db75dbf84e7e0b5f35a7aa7a Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 23:22:33 2007 +0200 actually implement the use_network flag diff --git a/libswfdec/swfdec_swf_instance.c b/libswfdec/swfdec_swf_instance.c index 4523f05..97e8460 100644 --- a/libswfdec/swfdec_swf_instance.c +++ b/libswfdec/swfdec_swf_instance.c @@ -29,6 +29,7 @@ #include "swfdec_character.h" #include "swfdec_debug.h" #include "swfdec_decoder.h" +#include "swfdec_flash_security.h" #include "swfdec_flv_decoder.h" #include "swfdec_loader_internal.h" #include "swfdec_loadertarget.h" @@ -52,6 +53,21 @@ swfdec_swf_instance_loader_target_get_player (SwfdecLoaderTarget *target) } static void +swfdec_swf_instance_allow_network (SwfdecPlayer *player) +{ + SwfdecFlashSecurity *sec; + + g_print ("enabling network access for %s\n", + swfdec_url_get_url (swfdec_loader_get_url (player->loader))); + SWFDEC_INFO ("enabling network access for %s", + swfdec_url_get_url (swfdec_loader_get_url (player->loader))); + + sec = SWFDEC_FLASH_SECURITY (player->security); + sec->allow_remote = TRUE; + sec->allow_local = FALSE; +} + +static void swfdec_swf_instance_loader_target_image (SwfdecSwfInstance *instance) { SwfdecSpriteMovie *movie = instance->movie; @@ -60,9 +76,15 @@ swfdec_swf_instance_loader_target_image (SwfdecSwfInstance *instance) return; if (SWFDEC_IS_SWF_DECODER (instance->decoder)) { - movie->sprite = SWFDEC_SWF_DECODER (instance->decoder)->main_sprite; - + SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); + SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (instance->decoder); + movie->sprite = dec->main_sprite; swfdec_movie_invalidate (SWFDEC_MOVIE (movie)); + + /* if first instance */ + if (player->loader == instance->loader && dec->use_network && + swfdec_url_has_protocol (swfdec_loader_get_url (instance->loader), "file")) + swfdec_swf_instance_allow_network (player); } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) { /* nothing to do, please move along */ } else { commit d9a24da2aab39932a3eb75f5e8507176a61f99de Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 22:57:43 2007 +0200 save results from the FileAttributes tag diff --git a/libswfdec/swfdec_swf_decoder.h b/libswfdec/swfdec_swf_decoder.h index 3cd43eb..ab88628 100644 --- a/libswfdec/swfdec_swf_decoder.h +++ b/libswfdec/swfdec_swf_decoder.h @@ -82,6 +82,8 @@ struct _SwfdecSwfDecoder GArray ** root_actions; /* actions to be executed by the root sprite */ GHashTable * scripts; /* buffer -> script mapping for all scripts */ + gboolean use_network; /* allow network or local access */ + gboolean has_metadata; /* TRUE if this file contains metadata */ gboolean protection; /* TRUE is this file is protected and may not be edited */ char * password; /* MD5'd password to open for editing or NULL if may not be opened */ diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c index c7ef45f..c9ce1a6 100644 --- a/libswfdec/swfdec_tag.c +++ b/libswfdec/swfdec_tag.c @@ -509,17 +509,17 @@ tag_func_define_button (SwfdecSwfDecoder * s, guint tag) static int tag_func_file_attributes (SwfdecSwfDecoder *s, guint tag) { - int has_metadata, use_network; - if (swfdec_bits_getbits (&s->b, 3)) SWFDEC_INFO ("reserved bits (1) aren't 0"); - has_metadata = swfdec_bits_getbit (&s->b); + s->has_metadata = swfdec_bits_getbit (&s->b); + SWFDEC_LOG (" has metadata: %d", s->has_metadata); if (swfdec_bits_getbits (&s->b, 3)) SWFDEC_INFO ("reserved bits (2) aren't 0"); - use_network = swfdec_bits_getbit (&s->b); - /* FIXME: do something useful with this data */ + s->use_network = swfdec_bits_getbit (&s->b); + SWFDEC_LOG (" use network: %d", s->use_network); if (swfdec_bits_getbits (&s->b, 24)) SWFDEC_INFO ("reserved bits (3) aren't 0"); + /* initialize default security if it wasn't initialized yet */ return SWFDEC_STATUS_OK; } commit 9d8262b31d4e3049462528c0ffce33ceb8f27a32 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 22:28:52 2007 +0200 add a SwfdecSecurity object to the SwfdecPlayer diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c index 0b6d07c..1a88534 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 3cbb7cb..00dd14f 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 8037927..e4e8eee 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 f5c2557..fa34f68 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 */ commit 01bc1a4f6f6ee518b86fad561bd1887c53b3c35e Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 20:17:07 2007 +0200 spec files deserve to die, too diff --git a/Makefile.am b/Makefile.am index a9cb6fc..27849d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,6 @@ EXTRA_DIST=depcomp \ ChangeLog \ autogen.sh \ gtk-doc.make \ - swfdec.spec \ m4/as-compiler-flag.m4 \ m4/ax_create_stdint_h.m4 \ m4/gtk-doc.m4 diff --git a/configure.ac b/configure.ac index 75e5a0a..fd4e7f3 100644 --- a/configure.ac +++ b/configure.ac @@ -333,7 +333,6 @@ vivified/dock/Makefile vivified/ui/Makefile swfdec.pc swfdec-gtk.pc -swfdec.spec ) AC_OUTPUT diff --git a/swfdec.spec.in b/swfdec.spec.in deleted file mode 100644 index bcbccec..0000000 --- a/swfdec.spec.in +++ /dev/null @@ -1,92 +0,0 @@ -Name: swfdec -Version: @VERSION@ -Release: gst.2 -Summary: Flash animations redering library - -Group: Libraries/Multimedia -License: LGPL -URL: http://swfdec.sourceforge.net/ -Vendor: GStreamer Backpackers Team <package at gstreamer.net> -Source: http://swfdec.sourceforge.net/download/%{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-root -BuildRequires: mozilla-devel -BuildRequires: gtk2-devel => 2.2.0 -Requires: gtk2 => 2.2.0 -Prereq: /sbin/ldconfig - -%description -Libswfdec is a library for rendering Flash animations. Currently it handles mostFlash 3 animations and some Flash 4. No interactivity is supported yet. - -%package devel -Summary: swfdec development files and static libraries. -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description devel -swfdec-devel contains the files needed to build packages that depend on swfdec. - -%package mozilla -Summary: Mozilla plugin for Flash rendering -Group: Applications/Internet -Requires: %{name} = %{version}-%{release} -Requires: mozilla - -%description mozilla -Mozilla plugin for rendering of Flash animations based on swfdec library - -%prep -%setup -q - -%build -CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --enable-shared -make - -%install -[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT - -%makeinstall -# Clean out files that should not be part of the rpm. -# This is the recommended way of dealing with it for RH8 -rm -f $RPM_BUILD_ROOT%{_libdir}/mozilla/plugins/*.la -rm -f $RPM_BUILD_ROOT%{_libdir}/*.la -rm -f $RPM_BUILD_ROOT%{_libdir}/gtk-2.0/2.2.0/loaders/swf_loader.la -rm -f $RPM_BUILD_ROOT%{_sysconfdir}/gtk-2.0/gdk-pixbuf.loaders -%clean -[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT - -%post -/sbin/ldconfig -mkdir -p %{_sysconfdir}/gtk-2.0 -gdk-pixbuf-query-loaders > %{_sysconfdir}/gtk-2.0/gdk-pixbuf.loaders - -%postun -/sbin/ldconfig -gdk-pixbuf-query-loaders > %{_sysconfdir}/gtk-2.0/gdk-pixbuf.loaders - - -%files -%defattr(-,root,root) -%doc AUTHORS COPYING NEWS README TODO -%{_bindir}/swf_play -%{_libdir}/libswfdec.so.* -%{_libdir}/gtk-2.0/2.2.0/loaders/swf_loader.so - -%files devel -%defattr(-,root,root) -%{_libdir}/libswfdec.a -%{_libdir}/libswfdec.so -%{_libdir}/pkgconfig/swfdec.pc -%{_includedir}/swfdec/swf.h -%{_includedir}/swfdec/swfdec.h -%{_libdir}/gtk-2.0/2.2.0/loaders/swf_loader.a - -%files mozilla -%defattr(-,root,root) -%{_libdir}/mozilla/plugins/libmozswfdec.so* -%{_libdir}/mozilla/plugins/libmozswfdec.a - -%changelog -* Wed Feb 05 2003 Christian F.K. Schaller <Uraeus at linuxrising.org> -- Update spec to handle pixbuf loader -* Sat Oct 26 2002 Christian F.K. Schaller <Uraeus at linuxrising.org> -- First attempt at spec commit a15bfb5e6edc48d2720017b239c1873ae109be10 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 20:15:53 2007 +0200 remove debian dir This should have been dead for ages diff --git a/debian/.gitignore b/debian/.gitignore deleted file mode 100644 index 7ac83b2..0000000 --- a/debian/.gitignore +++ /dev/null @@ -1 +0,0 @@ -CVS diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 409b62e..0000000 --- a/debian/changelog +++ /dev/null @@ -1,54 +0,0 @@ -swfdec (0.2.0-2) unstable; urgency=low - - * Remove installation of (empty) changelong (Closes: #179227) - * Fix swfdec.pc file and package dependency (Closes: #179223) - * Add workaround for mozilla-snapshot not loading plug-ins - from /usr/lib/mozilla/plugins. (might fix 169404) - - -- David Schleef <ds at schleef.org> Fri, 31 Jan 2003 11:23:07 -0800 - -swfdec (0.2.0-1) unstable; urgency=low - - * New upstream release - - Fixes image rendering (Closes: #170243) - - -- David Schleef <ds at schleef.org> Thu, 23 Jan 2003 01:29:59 -0800 - -swfdec (0.1.3-1) unstable; urgency=low - - * New upstream release - - -- David Schleef <ds at schleef.org> Thu, 21 Nov 2002 01:37:53 -0800 - -swfdec (0.1.2-3) unstable; urgency=low - - * debian/control: Add depends on libart2.0-dev, since the headers - pull in libart (this fixes an upstream bug) - - -- David Schleef <ds at schleef.org> Mon, 11 Nov 2002 14:36:09 -0800 - -swfdec (0.1.2-2) unstable; urgency=low - - * debian/copyright: fix download location (Closes: #167906) - * debian/rules: actually install docs - - -- David Schleef <ds at schleef.org> Tue, 05 Nov 2002 17:22:57 -0800 - -swfdec (0.1.2-1) unstable; urgency=low - - * new release - - -- David Schleef <ds at schleef.org> Fri, 01 Nov 2002 14:56:46 -0800 - -libswfdec (0.1.1-1) unstable; urgency=low - - * new release - - -- David Schleef <ds at schleef.org> Sat, 14 Sep 2002 16:44:26 -0700 - -swfdec (0.1.0-1) unstable; urgency=low - - * Initial Release. - - -- David Schleef <ds at schleef.org> Fri, 13 Sep 2002 19:00:10 -0700 - diff --git a/debian/control b/debian/control deleted file mode 100644 index 09e946a..0000000 --- a/debian/control +++ /dev/null @@ -1,36 +0,0 @@ -Source: swfdec -Priority: optional -Maintainer: David Schleef <ds at schleef.org> -Build-Depends: debhelper (>> 3.0.0), libgtk2.0-dev, mozilla-dev, libart-2.0-dev, zlib1g-dev, libmad0-dev, libsdl1.2-dev -Standards-Version: 3.5.6 - -Package: libswfdec-dev -Section: libdevel -Architecture: any -Depends: libswfdec0 (= ${Source-Version}), libglib2.0-dev -Description: SWF (Macromedia Flash) decoder libaray - A decoder library for Macromedia Flash animations, which are often - found on web sites. This is the development portion of the library, - intended to be installed if you intend to compile or develop - applications that use the library. - -Package: libswfdec0 -Section: libs -Architecture: any -Depends: ${shlibs:Depends} -Description: SWF (Macromedia Flash) decoder libaray - A decoder library for Macromedia Flash animations, which are often - found on web sites. This is the run-time portion of the library. - -Package: swf-player -Section: utils -Architecture: any -Depends: ${shlibs:Depends} -Description: SWF (Macromedia Flash) player - A GTK+ and SDL based player for Macromedia Flash animations. Includes - a Mozilla plugin, that embeds the player into Mozilla-based browsers, - in order to allow seamless viewing of Flash animations in web - pages. Includes a GdkPixbuf loader, so that SWF animations can be - used seamlessly as images in Gtk+ applications. - - diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 3d0dbfd..0000000 --- a/debian/copyright +++ /dev/null @@ -1,10 +0,0 @@ -This package was debianized by David Schleef <ds at schleef.org> on -Fri, 13 Sep 2002 19:00:10 -0700. - -It was downloaded from http://swfdec.sourceforge.net/. - -Upstream Author(s): David Schleef <ds at schleef.org> - -Copyright: - -LGPL diff --git a/debian/libswfdec-dev.dirs b/debian/libswfdec-dev.dirs deleted file mode 100644 index 4418816..0000000 --- a/debian/libswfdec-dev.dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib -usr/include diff --git a/debian/libswfdec-dev.files b/debian/libswfdec-dev.files deleted file mode 100644 index 2164966..0000000 --- a/debian/libswfdec-dev.files +++ /dev/null @@ -1,5 +0,0 @@ -usr/include/* -usr/lib/lib*.a -usr/lib/lib*.so -usr/lib/lib*.sa -usr/lib/pkgconfig/*.pc diff --git a/debian/libswfdec0.dirs b/debian/libswfdec0.dirs deleted file mode 100644 index 6845771..0000000 --- a/debian/libswfdec0.dirs +++ /dev/null @@ -1 +0,0 @@ -usr/lib diff --git a/debian/libswfdec0.files b/debian/libswfdec0.files deleted file mode 100644 index d0dbfd1..0000000 --- a/debian/libswfdec0.files +++ /dev/null @@ -1 +0,0 @@ -usr/lib/lib*.so.* diff --git a/debian/libswfdec0.shlibs b/debian/libswfdec0.shlibs deleted file mode 100644 index 87ab9a4..0000000 --- a/debian/libswfdec0.shlibs +++ /dev/null @@ -1 +0,0 @@ -libswfdec 0 libswfdec0 (>= 0.1.2) diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 86d0ffe..0000000 --- a/debian/rules +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/make -f -# Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# This is the debhelper compatibility version to use. -export DH_COMPAT=3 - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - - -ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) - CFLAGS += -g -endif -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_PROGRAM += -s -endif - -# shared library versions, option 1 -version=2.0.5 -major=2 -# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so -#version=`ls src/.libs/lib*.so.* | \ -# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'` -#major=`ls src/.libs/lib*.so.* | \ -# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'` - -config.status: configure - dh_testdir - # Add here commands to configure the package. - ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info - - -build: build-stamp -build-stamp: config.status - dh_testdir - - # Add here commands to compile the package. - $(MAKE) - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - # Add here commands to clean up after the build process. - -$(MAKE) distclean - -test -r /usr/share/misc/config.sub && \ - cp -f /usr/share/misc/config.sub config.sub - -test -r /usr/share/misc/config.guess && \ - cp -f /usr/share/misc/config.guess config.guess - - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/tmp - $(MAKE) install prefix=$(CURDIR)/debian/tmp/usr - - mkdir -p debian/tmp/usr/lib/mozilla-snapshot/plugins - cd debian/tmp/usr/lib/mozilla-snapshot/plugins && ln -s ../../mozilla/plugins/libmozswfdec.so . - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_movefiles - -# dh_installdebconf - dh_installdocs -A README TODO - dh_installexamples - dh_installmenu -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_installinit - dh_installcron - dh_installman - dh_installinfo -# dh_undocumented - dh_installchangelogs - dh_link - dh_strip - dh_compress - dh_fixperms - dh_makeshlibs - dh_installdeb -# dh_perl - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install diff --git a/debian/swf-player.dirs b/debian/swf-player.dirs deleted file mode 100644 index e742ee4..0000000 --- a/debian/swf-player.dirs +++ /dev/null @@ -1,3 +0,0 @@ -usr/bin -usr/lib/mozilla/plugins -usr/lib/mozilla-snapshot/plugins diff --git a/debian/swf-player.files b/debian/swf-player.files deleted file mode 100644 index 6c53087..0000000 --- a/debian/swf-player.files +++ /dev/null @@ -1,5 +0,0 @@ -usr/bin/* -usr/lib/mozilla/plugins/*.so -usr/lib/gtk-2.0/*/loaders/*.so -usr/lib/gtk-2.0/*/loaders/*.la -usr/lib/mozilla-snapshot/plugins/*.so commit dca4a26e7bbbb1d524ea1dd9e94628cbae4e2056 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 20:10:12 2007 +0200 add the first signs of the flash security model diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am index 771440a..3bab53b 100644 --- a/libswfdec/Makefile.am +++ b/libswfdec/Makefile.am @@ -65,6 +65,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \ swfdec_file_loader.c \ swfdec_filter.c \ swfdec_filter_as.c \ + swfdec_flash_security.c \ swfdec_flv_decoder.c \ swfdec_font.c \ swfdec_graphic.c \ @@ -195,6 +196,7 @@ noinst_HEADERS = \ swfdec_text_field_movie.h \ swfdec_event.h \ swfdec_filter.h \ + swfdec_flash_security.h \ swfdec_flv_decoder.h \ swfdec_font.h \ swfdec_graphic.h \ diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c new file mode 100644 index 0000000..0b6d07c --- /dev/null +++ b/libswfdec/swfdec_flash_security.c @@ -0,0 +1,105 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> +#include "swfdec_flash_security.h" +#include "swfdec_debug.h" +#include "swfdec_security_allow.h" + + +G_DEFINE_TYPE (SwfdecFlashSecurity, swfdec_flash_security, SWFDEC_TYPE_SECURITY) + +static SwfdecSecurity * +swfdec_flash_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key) +{ + if (SWFDEC_IS_SECURITY_ALLOW (key)) { + return g_object_ref (guard); + } else if (SWFDEC_IS_FLASH_SECURITY (key)) { + SwfdecFlashSecurity *fguard, *fkey, *ret; + fguard = SWFDEC_FLASH_SECURITY (guard); + fkey = SWFDEC_FLASH_SECURITY (key); + + ret = g_object_new (SWFDEC_TYPE_FLASH_SECURITY, NULL); + ret->allow_local = fguard->allow_local && fkey->allow_local; + ret->allow_remote = fguard->allow_remote && fkey->allow_remote; + return SWFDEC_SECURITY (ret); + } else { + SWFDEC_ERROR ("unknown security %s, denying access", G_OBJECT_TYPE_NAME (key)); + return NULL; + } +} + +static gboolean +swfdec_flash_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url) +{ + SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (guard); + + if (swfdec_url_has_protocol (url, "http")) { + return sec->allow_remote; + } else if (swfdec_url_has_protocol (url, "file")) { + return sec->allow_local; + } else { + SWFDEC_ERROR ("unknown protocol %s, denying access", swfdec_url_get_protocol (url)); + return FALSE; + } +} + +static void +swfdec_flash_security_class_init (SwfdecFlashSecurityClass *klass) +{ + SwfdecSecurityClass *security_class = SWFDEC_SECURITY_CLASS (klass); + + security_class->allow = swfdec_flash_security_allow; + security_class->allow_url = swfdec_flash_security_allow_url; +} + +static void +swfdec_flash_security_init (SwfdecFlashSecurity *sec) +{ + sec->allow_local = TRUE; + sec->allow_remote = TRUE; +} + +/** + * swfdec_flash_security_new: + * + * 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 + * useful for script engines that are not security sensitive or code injection + * via debugging. + * + * Returns: a new #SwfdecSecurity object + **/ +SwfdecSecurity * +swfdec_flash_security_new (void) +{ + static SwfdecSecurity *singleton = NULL; + + /* 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; +} diff --git a/libswfdec/swfdec_flash_security.h b/libswfdec/swfdec_flash_security.h new file mode 100644 index 0000000..3cbb7cb --- /dev/null +++ b/libswfdec/swfdec_flash_security.h @@ -0,0 +1,56 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef _SWFDEC_FLASH_SECURITY_H_ +#define _SWFDEC_FLASH_SECURITY_H_ + +#include <libswfdec/swfdec_security.h> + +G_BEGIN_DECLS + +typedef struct _SwfdecFlashSecurity SwfdecFlashSecurity; +typedef struct _SwfdecFlashSecurityClass SwfdecFlashSecurityClass; + +#define SWFDEC_TYPE_FLASH_SECURITY (swfdec_flash_security_get_type()) +#define SWFDEC_IS_FLASH_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FLASH_SECURITY)) +#define SWFDEC_IS_FLASH_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FLASH_SECURITY)) +#define SWFDEC_FLASH_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FLASH_SECURITY, SwfdecFlashSecurity)) +#define SWFDEC_FLASH_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FLASH_SECURITY, SwfdecFlashSecurityClass)) +#define SWFDEC_FLASH_SECURITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FLASH_SECURITY, SwfdecFlashSecurityClass)) + +struct _SwfdecFlashSecurity +{ + SwfdecSecurity security; + + gboolean allow_local; /* TRUE to allow access to local ressources */ + gboolean allow_remote; /* TRUE to allow access to remote resources */ +}; + +struct _SwfdecFlashSecurityClass +{ + SwfdecSecurityClass security_class; +}; + +GType swfdec_flash_security_get_type (void); + +SwfdecSecurity * swfdec_flash_security_new (void); + + +G_END_DECLS +#endif commit 292929cb6f3edaa413de648e0a1d11bae5229735 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 19:38:39 2007 +0200 add security files diff --git a/doc/Makefile.am b/doc/Makefile.am index f846b32..68cc5ac 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -90,6 +90,7 @@ IGNORE_HFILES= \ swfdec_event.h \ swfdec_filter.h \ swfdec_flv_decoder.h \ + swfdec_flash_security.h \ swfdec_font.h \ swfdec_graphic.h \ swfdec_graphic_movie.h \ @@ -117,6 +118,7 @@ IGNORE_HFILES= \ swfdec_script.h \ swfdec_script_internal.h \ swfdec_security.h \ + swfdec_security_allow.h \ swfdec_shape.h \ swfdec_shape_parser.h \ swfdec_sound.h \ commit 0f8f1d32c3ec70001b0a451b9ee091c2b6cec620 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 19:38:19 2007 +0200 add swfdec_url_has_protocol() diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index e269718..0c22165 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -58,6 +58,7 @@ swfdec_url_free swfdec_url_get_host swfdec_url_get_path swfdec_url_get_protocol +swfdec_url_has_protocol swfdec_url_get_query swfdec_url_get_url swfdec_url_new diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c index 2d01827..cb5db48 100644 --- a/libswfdec/swfdec_url.c +++ b/libswfdec/swfdec_url.c @@ -138,7 +138,7 @@ swfdec_url_new_relative (const SwfdecURL *url, const char *string) g_string_append (str, "://"); if (url->host) g_string_append (str, url->host); - if (string[0] == '/' && !g_str_equal (swfdec_url_get_protocol (url), "file")) { + if (string[0] == '/' && !swfdec_url_has_protocol (url, "file")) { /* absolute URL */ g_string_append (str, string); } else { @@ -242,6 +242,24 @@ swfdec_url_get_protocol (const SwfdecURL *url) } /** + * swfdec_url_has_protocol: + * @url: a url + * @protocol: protocol name to check for + * + * Checks if the given @url references the given @protocol + * + * Returns: %TRUE if both protocols match, %FALSE otherwise + **/ +gboolean +swfdec_url_has_protocol (const SwfdecURL *url, const char *protocol) +{ + g_return_val_if_fail (url != NULL, FALSE); + g_return_val_if_fail (protocol != NULL, FALSE); + + return g_str_equal (url->protocol, protocol); +} + +/** * swfdec_url_get_host: * @url: a #SwfdecURL * diff --git a/libswfdec/swfdec_url.h b/libswfdec/swfdec_url.h index d3c4e24..6bf46fc 100644 --- a/libswfdec/swfdec_url.h +++ b/libswfdec/swfdec_url.h @@ -40,6 +40,9 @@ const char * swfdec_url_get_protocol (const SwfdecURL * url); const char * swfdec_url_get_host (const SwfdecURL * url); const char * swfdec_url_get_path (const SwfdecURL * url); const char * swfdec_url_get_query (const SwfdecURL * url); + +gboolean swfdec_url_has_protocol (const SwfdecURL * url, + const char * protocol); G_END_DECLS commit 6d60bb9a31ef13b22e9785316678d04c1f3f0960 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 19:26:39 2007 +0200 add swfdec_as_object_run_with_security() diff --git a/libswfdec/swfdec_as_internal.h b/libswfdec/swfdec_as_internal.h index df7e70a..ee49ef2 100644 --- a/libswfdec/swfdec_as_internal.h +++ b/libswfdec/swfdec_as_internal.h @@ -66,6 +66,10 @@ void swfdec_as_object_decode (SwfdecAsObject * obj, SwfdecAsObject * swfdec_as_object_prototype_for_version (SwfdecAsObject *object, guint version, gboolean check7); +void swfdec_as_object_run_with_security + (SwfdecAsObject * object, + SwfdecScript * script, + SwfdecSecurity * sec); G_END_DECLS diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index 0ff384b..765a56c 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -33,6 +33,7 @@ #include "swfdec_as_strings.h" #include "swfdec_debug.h" #include "swfdec_movie.h" +#include "swfdec_security_allow.h" #define SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT 256 @@ -1013,26 +1014,22 @@ swfdec_as_object_add_constructor (SwfdecAsObject *object, const char *name, GTyp return function; } -/** - * swfdec_as_object_run: - * @object: a #SwfdecAsObject - * @script: script to execute - * - * Executes the given @script with @object as this pointer. - **/ void -swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script) +swfdec_as_object_run_with_security (SwfdecAsObject *object, SwfdecScript *script, + SwfdecSecurity *sec) { SwfdecAsContext *context; SwfdecAsFrame *frame; g_return_if_fail (SWFDEC_IS_AS_OBJECT (object)); g_return_if_fail (script != NULL); + g_return_if_fail (SWFDEC_IS_SECURITY (sec)); context = object->context; frame = swfdec_as_frame_new (context, script); if (frame == NULL) return; + swfdec_as_frame_set_security (frame, sec); swfdec_as_frame_set_this (frame, object); swfdec_as_frame_preload (frame); swfdec_as_context_run (context); @@ -1040,6 +1037,26 @@ swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script) } /** + * swfdec_as_object_run: + * @object: a #SwfdecAsObject + * @script: script to execute + * + * Executes the given @script with @object as this pointer. + **/ +void +swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script) +{ + SwfdecSecurity *sec; + + g_return_if_fail (SWFDEC_IS_AS_OBJECT (object)); + g_return_if_fail (script != NULL); + + sec = swfdec_security_allow_new (); + swfdec_as_object_run_with_security (object, script, sec); + g_object_unref (sec); +} + +/** * swfdec_as_object_call: * @object: a #SwfdecAsObject * @name: garbage-collected string naming the function to call. commit a00874ae40d7168a215891695cc170a83b4469d2 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 19:21:10 2007 +0200 make functions have a security context associated with them diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c index 1596041..5582f2b 100644 --- a/libswfdec/swfdec_as_frame.c +++ b/libswfdec/swfdec_as_frame.c @@ -856,3 +856,30 @@ swfdec_as_frame_get_this (SwfdecAsFrame *frame) return frame->thisp; } + +/** + * swfdec_as_frame_set_security: + * @frame: the frame to be executed + * @guard: the security guarding this frame + * + * Checks that @guard allows executing the frame. The frame's security will + * be set to what @guard returns. By default, a frame has the security of + * its parent frame. If it's the first frame, it's allowed everything. + **/ +void +swfdec_as_frame_set_security (SwfdecAsFrame *frame, SwfdecSecurity *guard) +{ + SwfdecSecurity *old; + + g_return_if_fail (SWFDEC_IS_AS_FRAME (frame)); + g_return_if_fail (SWFDEC_IS_SECURITY (guard)); + + /* execution is not allowed anyway */ + if (frame->security == NULL) + return; + + old = frame->security; + frame->security = swfdec_security_allow (guard, old); + g_object_unref (old); +} + diff --git a/libswfdec/swfdec_as_frame_internal.h b/libswfdec/swfdec_as_frame_internal.h index 4088f3d..b09fb9c 100644 --- a/libswfdec/swfdec_as_frame_internal.h +++ b/libswfdec/swfdec_as_frame_internal.h @@ -70,6 +70,8 @@ SwfdecAsFrame * swfdec_as_frame_new_native (SwfdecAsContext * context); void swfdec_as_frame_return (SwfdecAsFrame * frame, SwfdecAsValue * return_value); +void swfdec_as_frame_set_security (SwfdecAsFrame * frame, + SwfdecSecurity * guard); void swfdec_as_frame_set_this (SwfdecAsFrame * frame, SwfdecAsObject * thisp); void swfdec_as_frame_preload (SwfdecAsFrame * frame); diff --git a/libswfdec/swfdec_as_function.c b/libswfdec/swfdec_as_function.c index 1178b0c..18970b1 100644 --- a/libswfdec/swfdec_as_function.c +++ b/libswfdec/swfdec_as_function.c @@ -134,6 +134,8 @@ swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guin /* FIXME: figure out what to do in these situations */ if (frame == NULL) return; + if (function->priv) + swfdec_as_frame_set_security (frame, function->priv); /* second check especially for super object */ if (thisp != NULL && frame->thisp == NULL) swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp)); @@ -254,3 +256,21 @@ swfdec_as_function_init_context (SwfdecAsContext *context, guint version) &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT); } +/** + * swfdec_as_function_set_security: + * @fun: a #SwfdecFunction + * @sec: the security guarding calls to this function + * + * Sets the security object guarding execution of this function. This function + * may only be called once per #SwfdecAsFunction. + **/ +void +swfdec_as_function_set_security (SwfdecAsFunction *fun, SwfdecSecurity *sec) +{ + g_return_if_fail (SWFDEC_IS_AS_FUNCTION (fun)); + g_return_if_fail (SWFDEC_IS_SECURITY (sec)); + g_return_if_fail (fun->priv == NULL); + + fun->priv = g_object_ref (sec); +} + diff --git a/libswfdec/swfdec_as_function.h b/libswfdec/swfdec_as_function.h index 534aad5..ab2c364 100644 --- a/libswfdec/swfdec_as_function.h +++ b/libswfdec/swfdec_as_function.h @@ -39,6 +39,8 @@ typedef struct _SwfdecAsFunctionClass SwfdecAsFunctionClass; struct _SwfdecAsFunction { /*< private >*/ SwfdecAsObject object; + + gpointer priv; /* currently only contains the security context or NULL for any */ }; struct _SwfdecAsFunctionClass { diff --git a/libswfdec/swfdec_as_internal.h b/libswfdec/swfdec_as_internal.h index 98189a5..df7e70a 100644 --- a/libswfdec/swfdec_as_internal.h +++ b/libswfdec/swfdec_as_internal.h @@ -22,6 +22,7 @@ #include <libswfdec/swfdec_as_object.h> #include <libswfdec/swfdec_as_types.h> +#include <libswfdec/swfdec_security.h> G_BEGIN_DECLS @@ -34,6 +35,8 @@ G_BEGIN_DECLS void swfdec_as_function_set_constructor (SwfdecAsFunction * fun); +void swfdec_as_function_set_security (SwfdecAsFunction * fun, + SwfdecSecurity * sec); void swfdec_as_function_init_context (SwfdecAsContext * context, guint version); commit 9b0856c41716622156c11e3982234f721b713ca7 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 19:06:55 2007 +0200 add a SwfdecSecurity to every frame diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c index cf80c9a..dd276fc 100644 --- a/libswfdec/swfdec_as_context.c +++ b/libswfdec/swfdec_as_context.c @@ -741,6 +741,12 @@ start: swfdec_as_context_abort (context, "Stack overflow"); return; } + /* if security is NULL, the function may not be called */ + if (frame->security == NULL) { + SWFDEC_WARNING ("insufficient right to call %s", frame->function_name); + swfdec_as_frame_return (frame, NULL); + goto start; + } if (SWFDEC_IS_AS_NATIVE_FUNCTION (frame->function)) { SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (frame->function); SwfdecAsValue rval = { 0, }; diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c index 619811c..1596041 100644 --- a/libswfdec/swfdec_as_frame.c +++ b/libswfdec/swfdec_as_frame.c @@ -29,6 +29,7 @@ #include "swfdec_as_strings.h" #include "swfdec_as_super.h" #include "swfdec_debug.h" +#include "swfdec_security_allow.h" /** * SECTION:SwfdecAsFrame @@ -269,6 +270,10 @@ swfdec_as_frame_dispose (GObject *object) SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object); g_slice_free1 (sizeof (SwfdecAsValue) * frame->n_registers, frame->registers); + if (frame->security) { + g_object_unref (frame->security); + frame->security = NULL; + } if (frame->constant_pool) { swfdec_constant_pool_free (frame->constant_pool); frame->constant_pool = NULL; @@ -374,6 +379,11 @@ swfdec_as_frame_load (SwfdecAsFrame *frame) { SwfdecAsContext *context = SWFDEC_AS_OBJECT (frame)->context; + if (context->frame) { + frame->security = g_object_ref (context->frame->security); + } else { + frame->security = swfdec_security_allow_new (); + } frame->stack_begin = context->cur; context->base = frame->stack_begin; frame->next = context->frame; diff --git a/libswfdec/swfdec_as_frame_internal.h b/libswfdec/swfdec_as_frame_internal.h index 7213be3..4088f3d 100644 --- a/libswfdec/swfdec_as_frame_internal.h +++ b/libswfdec/swfdec_as_frame_internal.h @@ -22,6 +22,7 @@ #include <libswfdec/swfdec_as_types.h> #include <libswfdec/swfdec_script_internal.h> +#include <libswfdec/swfdec_security.h> G_BEGIN_DECLS @@ -38,6 +39,7 @@ struct _SwfdecAsFrame { SwfdecAsValue * return_value; /* pointer to where to store the return value */ guint argc; /* number of arguments */ const SwfdecAsValue * argv; /* arguments or %NULL if taken from stack */ + SwfdecSecurity * security; /* security for this frame or %NULL if not allowed to call */ /* debugging */ const char * function_name; /* name of function */ /* script execution */ commit 74443bb75583af3250be76709dbdc87ba17855b0 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 19:06:44 2007 +0200 make it compile without warnings diff --git a/libswfdec/swfdec_security_allow.c b/libswfdec/swfdec_security_allow.c index fafc258..98d915e 100644 --- a/libswfdec/swfdec_security_allow.c +++ b/libswfdec/swfdec_security_allow.c @@ -74,6 +74,6 @@ swfdec_security_allow_new (void) return g_object_ref (singleton); singleton = g_object_new (SWFDEC_TYPE_SECURITY_ALLOW, NULL); - g_object_add_weak_pointer (singleton, &singleton); + g_object_add_weak_pointer (G_OBJECT (singleton), (gpointer) &singleton); return singleton; } commit 2d32b67327c47a2421388da869cef6ffb5d18f4f Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 18:49:27 2007 +0200 document swfdec_security_allow_new() and make it a singleton diff --git a/libswfdec/swfdec_security_allow.c b/libswfdec/swfdec_security_allow.c index 035a44c..fafc258 100644 --- a/libswfdec/swfdec_security_allow.c +++ b/libswfdec/swfdec_security_allow.c @@ -54,9 +54,26 @@ swfdec_security_allow_init (SwfdecSecurityAllow *security_allow) { } +/** + * swfdec_security_allow_new: + * + * 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 + * useful for script engines that are not security sensitive or code injection + * via debugging. + * + * Returns: a new #SwfdecSecurity object + **/ SwfdecSecurity * swfdec_security_allow_new (void) { + static SwfdecSecurity *singleton = NULL; - return g_object_new (SWFDEC_TYPE_SECURITY_ALLOW, NULL); + /* FIXME: not threadsafe */ + if (singleton) + return g_object_ref (singleton); + + singleton = g_object_new (SWFDEC_TYPE_SECURITY_ALLOW, NULL); + g_object_add_weak_pointer (singleton, &singleton); + return singleton; } commit e8a153927b99cfe9a660d804a215e8f65f1b7983 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 18:39:42 2007 +0200 add swfdec_security_allow.[ch] - a Security that is totally not secure diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am index c042086..771440a 100644 --- a/libswfdec/Makefile.am +++ b/libswfdec/Makefile.am @@ -97,6 +97,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \ swfdec_ringbuffer.c \ swfdec_script.c \ swfdec_security.c \ + swfdec_security_allow.c \ swfdec_shape.c \ swfdec_shape_parser.c \ swfdec_sound.c \ @@ -218,6 +219,7 @@ noinst_HEADERS = \ swfdec_ringbuffer.h \ swfdec_script_internal.h \ swfdec_security.h \ + swfdec_security_allow.h \ swfdec_shape.h \ swfdec_shape_parser.h \ swfdec_sound.h \ diff --git a/libswfdec/swfdec_security_allow.c b/libswfdec/swfdec_security_allow.c new file mode 100644 index 0000000..035a44c --- /dev/null +++ b/libswfdec/swfdec_security_allow.c @@ -0,0 +1,62 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> +#include "swfdec_security_allow.h" +#include "swfdec_debug.h" + + +G_DEFINE_TYPE (SwfdecSecurityAllow, swfdec_security_allow, SWFDEC_TYPE_SECURITY) + +static SwfdecSecurity * +swfdec_security_allow_allow (SwfdecSecurity *guard, SwfdecSecurity *key) +{ + return g_object_ref (key); +} + +static gboolean +swfdec_security_allow_allow_url (SwfdecSecurity *guard, const SwfdecURL *url) +{ + return TRUE; +} + +static void +swfdec_security_allow_class_init (SwfdecSecurityAllowClass *klass) +{ + SwfdecSecurityClass *security_class = SWFDEC_SECURITY_CLASS (klass); + + security_class->allow = swfdec_security_allow_allow; + security_class->allow_url = swfdec_security_allow_allow_url; +} + +static void +swfdec_security_allow_init (SwfdecSecurityAllow *security_allow) +{ +} + +SwfdecSecurity * +swfdec_security_allow_new (void) +{ + + return g_object_new (SWFDEC_TYPE_SECURITY_ALLOW, NULL); +} diff --git a/libswfdec/swfdec_security_allow.h b/libswfdec/swfdec_security_allow.h new file mode 100644 index 0000000..108ed72 --- /dev/null +++ b/libswfdec/swfdec_security_allow.h @@ -0,0 +1,53 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef _SWFDEC_SECURITY_ALLOW_H_ +#define _SWFDEC_SECURITY_ALLOW_H_ + +#include <libswfdec/swfdec_security.h> + +G_BEGIN_DECLS + +typedef struct _SwfdecSecurityAllow SwfdecSecurityAllow; +typedef struct _SwfdecSecurityAllowClass SwfdecSecurityAllowClass; + +#define SWFDEC_TYPE_SECURITY_ALLOW (swfdec_security_allow_get_type()) +#define SWFDEC_IS_SECURITY_ALLOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SECURITY_ALLOW)) +#define SWFDEC_IS_SECURITY_ALLOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SECURITY_ALLOW)) +#define SWFDEC_SECURITY_ALLOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SECURITY_ALLOW, SwfdecSecurityAllow)) +#define SWFDEC_SECURITY_ALLOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SECURITY_ALLOW, SwfdecSecurityAllowClass)) +#define SWFDEC_SECURITY_ALLOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SECURITY_ALLOW, SwfdecSecurityAllowClass)) + +struct _SwfdecSecurityAllow +{ + SwfdecSecurity security; +}; + +struct _SwfdecSecurityAllowClass +{ + SwfdecSecurityClass security_class; +}; + +GType swfdec_security_allow_get_type (void); + +SwfdecSecurity * swfdec_security_allow_new (void); + + +G_END_DECLS +#endif commit 679cb09a4b8cb37151cd84cdd0609db49c0d51f3 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 18:18:42 2007 +0200 that function doesn't actually exist diff --git a/libswfdec/swfdec_security.h b/libswfdec/swfdec_security.h index aeda8ae..1bfaf3f 100644 --- a/libswfdec/swfdec_security.h +++ b/libswfdec/swfdec_security.h @@ -52,8 +52,6 @@ struct _SwfdecSecurityClass GType swfdec_security_get_type (void); -SwfdecSecurity * swfdec_security_new_default (SwfdecSecurity * sec); - SwfdecSecurity * swfdec_security_allow (SwfdecSecurity * guard, SwfdecSecurity * key); gboolean swfdec_security_allow_url (SwfdecSecurity * guard, commit a66af9e1a3ab9c7e9eb6d30508484b3739ab7bbd Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 18:18:28 2007 +0200 fix header diff --git a/libswfdec/swfdec_security.c b/libswfdec/swfdec_security.c index bbe8c6e..dfd66b3 100644 --- a/libswfdec/swfdec_security.c +++ b/libswfdec/swfdec_security.c @@ -24,7 +24,6 @@ #include <string.h> #include "swfdec_security.h" #include "swfdec_debug.h" -#include "swfdec_decoder.h" G_DEFINE_ABSTRACT_TYPE (SwfdecSecurity, swfdec_security, G_TYPE_OBJECT) commit 231a35360a01d04cb478430c494db54384bcf2b9 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 17:47:31 2007 +0200 add SwfdecSecurity object diff --git a/doc/Makefile.am b/doc/Makefile.am index bb67895..f846b32 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -116,7 +116,7 @@ IGNORE_HFILES= \ swfdec_root_sprite.h \ swfdec_script.h \ swfdec_script_internal.h \ - swfdec_scriptable.h \ + swfdec_security.h \ swfdec_shape.h \ swfdec_shape_parser.h \ swfdec_sound.h \ diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am index 0c2e2a6..c042086 100644 --- a/libswfdec/Makefile.am +++ b/libswfdec/Makefile.am @@ -96,6 +96,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \ swfdec_rectangle.c \ swfdec_ringbuffer.c \ swfdec_script.c \ + swfdec_security.c \ swfdec_shape.c \ swfdec_shape_parser.c \ swfdec_sound.c \ @@ -216,6 +217,7 @@ noinst_HEADERS = \ swfdec_rect.h \ swfdec_ringbuffer.h \ swfdec_script_internal.h \ + swfdec_security.h \ swfdec_shape.h \ swfdec_shape_parser.h \ swfdec_sound.h \ diff --git a/libswfdec/swfdec_security.c b/libswfdec/swfdec_security.c new file mode 100644 index 0000000..bbe8c6e --- /dev/null +++ b/libswfdec/swfdec_security.c @@ -0,0 +1,88 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> +#include "swfdec_security.h" +#include "swfdec_debug.h" +#include "swfdec_decoder.h" + + +G_DEFINE_ABSTRACT_TYPE (SwfdecSecurity, swfdec_security, G_TYPE_OBJECT) + +static void +swfdec_security_class_init (SwfdecSecurityClass *klass) +{ +} + +static void +swfdec_security_init (SwfdecSecurity *security) +{ +} + +/** + * swfdec_security_allow: + * @guard: security guarding an operation + * @key: security available + * + * Asks @guard to check if the given @key allows accessing it. If so, a + * key for accessing the operation is returned. + * + * Returns: %NULL if access was not granted, otherwise the new security + * priviliges for accessing the operation. Use g_object_unref() after + * use. + **/ +SwfdecSecurity * +swfdec_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key) +{ + SwfdecSecurityClass *klass; + + g_return_val_if_fail (SWFDEC_IS_SECURITY (guard), NULL); + g_return_val_if_fail (SWFDEC_IS_SECURITY (key), NULL); + + klass = SWFDEC_SECURITY_GET_CLASS (guard); + g_return_val_if_fail (klass->allow, NULL); + return klass->allow (guard, key); +} + +/** + * swfdec_security_allow_url: + * @guard: security that is in effect + * @url: URL that should be accessed + * + * Asks @guard to check if the given @url may be accessed. + * + * Returns: %TRUE if @url may be accessed. + **/ +gboolean +swfdec_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url) +{ + SwfdecSecurityClass *klass; + + g_return_val_if_fail (SWFDEC_IS_SECURITY (guard), FALSE); + g_return_val_if_fail (url != NULL, FALSE); + + klass = SWFDEC_SECURITY_GET_CLASS (guard); + g_return_val_if_fail (klass->allow_url, FALSE); + return klass->allow_url (guard, url); +} + diff --git a/libswfdec/swfdec_security.h b/libswfdec/swfdec_security.h new file mode 100644 index 0000000..aeda8ae --- /dev/null +++ b/libswfdec/swfdec_security.h @@ -0,0 +1,64 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef _SWFDEC_SECURITY_H_ +#define _SWFDEC_SECURITY_H_ + +#include <glib-object.h> +#include <libswfdec/swfdec_url.h> + +G_BEGIN_DECLS + +typedef struct _SwfdecSecurity SwfdecSecurity; +typedef struct _SwfdecSecurityClass SwfdecSecurityClass; + +#define SWFDEC_TYPE_SECURITY (swfdec_security_get_type()) +#define SWFDEC_IS_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SECURITY)) +#define SWFDEC_IS_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SECURITY)) +#define SWFDEC_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SECURITY, SwfdecSecurity)) +#define SWFDEC_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SECURITY, SwfdecSecurityClass)) +#define SWFDEC_SECURITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SECURITY, SwfdecSecurityClass)) + +struct _SwfdecSecurity +{ + GObject object; +}; + +struct _SwfdecSecurityClass +{ + GObjectClass object_class; + + SwfdecSecurity * (* allow) (SwfdecSecurity * guard, + SwfdecSecurity * from); + gboolean (* allow_url) (SwfdecSecurity * guard, + const SwfdecURL * url); +}; + +GType swfdec_security_get_type (void); + +SwfdecSecurity * swfdec_security_new_default (SwfdecSecurity * sec); + +SwfdecSecurity * swfdec_security_allow (SwfdecSecurity * guard, + SwfdecSecurity * key); +gboolean swfdec_security_allow_url (SwfdecSecurity * guard, + const SwfdecURL * url); + + +G_END_DECLS +#endif commit 12f7efbe515ea4c777e6cc80f89e1f6e2b408af7 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 16:26:01 2007 +0200 lowercase the protocol and make absolute file URLs be relative anyway diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c index 5b99d94..2d01827 100644 --- a/libswfdec/swfdec_url.c +++ b/libswfdec/swfdec_url.c @@ -89,7 +89,7 @@ swfdec_url_new (const char *string) SWFDEC_ERROR ("URL %s has no protocol", string); return url; } - url->protocol = g_strndup (string, s - string); + url->protocol = g_utf8_strdown (string, s - string); string = s + 3; s = strchr (string, '/'); if (s == NULL) { @@ -138,7 +138,7 @@ swfdec_url_new_relative (const SwfdecURL *url, const char *string) g_string_append (str, "://"); if (url->host) g_string_append (str, url->host); - if (string[0] == '/') { + if (string[0] == '/' && !g_str_equal (swfdec_url_get_protocol (url), "file")) { /* absolute URL */ g_string_append (str, string); } else { commit b7edf7393bfb21ebb30405c16efa1a5352ca96f0 Merge: 77f5f65... 429ccc9... Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 13:57:06 2007 +0200 Merge branch 'master' of ssh://company at git.freedesktop.org/git/swfdec/swfdec commit 77f5f65999fd094fdca5033c757cb38b414ed3d7 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 11:50:29 2007 +0200 don't call initialize on the movies anymore diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index 1f7faaf..7236572 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1151,12 +1151,7 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu } else { SwfdecSpriteMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE); if (movie) { - if (SWFDEC_MOVIE (movie)->swf == NULL) { - swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); - swfdec_movie_initialize (SWFDEC_MOVIE (movie)); - } else { - swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); - } + swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); } else { swfdec_player_launch (SWFDEC_PLAYER (cx), SWFDEC_LOADER_REQUEST_DEFAULT, url, target, NULL); @@ -1210,12 +1205,7 @@ swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, g } else if (variables) { swfdec_movie_load_variables (SWFDEC_MOVIE (movie), url, method, NULL); } else { - if (SWFDEC_MOVIE (movie)->swf == NULL) { - swfdec_sprite_movie_load (movie, url, method, NULL); - swfdec_movie_initialize (SWFDEC_MOVIE (movie)); - } else { - swfdec_sprite_movie_load (movie, url, method, NULL); - } + swfdec_sprite_movie_load (movie, url, method, NULL); } } else { /* load an external file */ commit 5007f2aedb6e97a53c7a1d391de27d58a359a04e Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 11:34:45 2007 +0200 Ha, we don't need case sensitivity options. I can't read tests... diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index d0814fd..1f7faaf 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1149,7 +1149,7 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) { /* nothing to do here */ } else { - SwfdecSpriteMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE, TRUE); + SwfdecSpriteMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE); if (movie) { if (SWFDEC_MOVIE (movie)->swf == NULL) { swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); @@ -1198,7 +1198,7 @@ swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, g } else if (internal || variables) { SwfdecSpriteMovie *movie; /* FIXME: This code looks wrong - figure out how levels are handled */ - movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE, !variables); + movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, !variables); if (movie == NULL) { movie = (SwfdecSpriteMovie *) swfdec_player_get_movie_from_string ( SWFDEC_PLAYER (cx), target); diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index ace4c45..8037927 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -1573,8 +1573,6 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect) * swfdec_player_get_level: * @player: a #SwfdecPlayer * @name: name of the level to request - * @ignore_case: %TRUE to always be case insensitive, otherwise use the version - * to determine case sensitivity * @create: %TRUE to create if it doesn't exist * * This function is used to look up root movies in the given @player. The @@ -1588,8 +1586,7 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect) * fully initialized (yes, this function sucks). **/ SwfdecSpriteMovie * -swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean ignore_case, - gboolean create) +swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create) { SwfdecSpriteMovie *movie; GList *walk; @@ -1602,7 +1599,7 @@ swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean ignore g_return_val_if_fail (name != NULL, NULL); /* check name starts with "_level" */ - if (swfdec_strncmp (ignore_case ? 6 : SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0) + if (swfdec_strncmp (SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0) return NULL; name += 6; /* extract depth from rest string (or fail if it's not a depth) */ diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index f25f782..f5c2557 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -198,7 +198,6 @@ void swfdec_player_stop_all_sounds (SwfdecPlayer * player); SwfdecSpriteMovie * swfdec_player_get_level (SwfdecPlayer * player, const char * name, - gboolean ignore_case, gboolean create); SwfdecMovie * swfdec_player_add_level_from_loader (SwfdecPlayer * player, commit 42f1dcc0e604d0ddba306039b0b5e566d8ed3561 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 11:34:03 2007 +0200 reset n_frames, too diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c index 11c1bf4..74dd86e 100644 --- a/libswfdec/swfdec_sprite_movie.c +++ b/libswfdec/swfdec_sprite_movie.c @@ -703,6 +703,7 @@ swfdec_sprite_movie_unload (SwfdecSpriteMovie *movie) swfdec_sprite_movie_clear (SWFDEC_AS_OBJECT (movie)->context, SWFDEC_AS_OBJECT (movie), 0, NULL, &hack); movie->frame = 0; + movie->n_frames = 0; movie->sprite = NULL; } commit b261e561ce60ccbb362ddb71378f8608ff249898 Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 09:36:19 2007 +0200 loadMovie() changes... diff --git a/test/dump.c b/test/dump.c index 5b8ecea..47fb1ea 100644 --- a/test/dump.c +++ b/test/dump.c @@ -421,14 +421,20 @@ main (int argc, char *argv[]) } /* FIXME: HACK! */ swfdec_player_advance (player, 0); - s = (SwfdecSwfDecoder *) SWFDEC_MOVIE (player->roots->data)->swf->decoder; - if (swfdec_player_get_rate (player) == 0 || - !SWFDEC_IS_SWF_DECODER (s)) { + if (swfdec_player_is_initialized (player)) { g_printerr ("File \"%s\" is not a SWF file\n", argv[1]); g_object_unref (player); player = NULL; return 1; } + s = (SwfdecSwfDecoder *) SWFDEC_MOVIE (player->roots->data)->swf->decoder; + /* FIXME: can happen after a _root.loadMovie() call */ + if (!SWFDEC_IS_SWF_DECODER (s)) { + g_printerr ("Movie already unloaded from \"%s\"\n", argv[1]); + g_object_unref (player); + player = NULL; + return 1; + } g_print ("file:\n"); g_print (" version: %d\n", s->version); commit 6a98b904013e0c5b1855a1cd7f91313c5ee34aab Author: Benjamin Otte <otte at gnome.org> Date: Wed Oct 17 09:24:26 2007 +0200 more random breakage on the loadMovie front I should stop getting from one fix to another one to yet another one without ever committing diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index 4a80a75..d0814fd 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -1149,13 +1149,13 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) { /* nothing to do here */ } else { - SwfdecMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE); + SwfdecSpriteMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE, TRUE); if (movie) { - if (movie->swf == NULL) { - swfdec_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); - swfdec_movie_initialize (movie); + if (SWFDEC_MOVIE (movie)->swf == NULL) { + swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); + swfdec_movie_initialize (SWFDEC_MOVIE (movie)); } else { - swfdec_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); + swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); } } else { swfdec_player_launch (SWFDEC_PLAYER (cx), SWFDEC_LOADER_REQUEST_DEFAULT, @@ -1195,24 +1195,26 @@ swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, g SWFDEC_ERROR ("GetURL2 action requires a SwfdecPlayer"); } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) { /* nothing to do here */ - } else if (internal) { - SwfdecMovie *movie; + } else if (internal || variables) { + SwfdecSpriteMovie *movie; /* FIXME: This code looks wrong - figure out how levels are handled */ - movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, !variables); - if (movie) { - if (movie->swf == NULL) { - swfdec_movie_load (movie, url, method, NULL); - swfdec_movie_initialize (movie); - } - } else { - movie = swfdec_player_get_movie_from_string ( + movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE, !variables); + if (movie == NULL) { + movie = (SwfdecSpriteMovie *) swfdec_player_get_movie_from_string ( SWFDEC_PLAYER (cx), target); - if (movie == NULL) { - /* swfdec_player_get_movie_from_value() should have warned already */ - } else if (variables) { - swfdec_movie_load_variables (movie, url, method, NULL); + if (!SWFDEC_IS_SPRITE_MOVIE (movie)) + movie = NULL; + } + if (movie == NULL) { + /* swfdec_player_get_movie_from_value() should have warned already */ + } else if (variables) { + swfdec_movie_load_variables (SWFDEC_MOVIE (movie), url, method, NULL); + } else { + if (SWFDEC_MOVIE (movie)->swf == NULL) { + swfdec_sprite_movie_load (movie, url, method, NULL); + swfdec_movie_initialize (SWFDEC_MOVIE (movie)); } else { - swfdec_movie_load (movie, url, method, NULL); + swfdec_sprite_movie_load (movie, url, method, NULL); } } } else { diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c index de4ec28..7e888b4 100644 --- a/libswfdec/swfdec_movie.c +++ b/libswfdec/swfdec_movie.c @@ -1368,30 +1368,16 @@ swfdec_movie_load_variables (SwfdecMovie *movie, const char *url, return; } + context = SWFDEC_AS_OBJECT (movie)->context; loader = swfdec_as_object_new_empty (context); swfdec_as_object_add_function (loader, SWFDEC_AS_STR_onData, 0, swfdec_movie_load_variables_on_data, 0); + SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (movie)); swfdec_as_object_set_variable (loader, SWFDEC_AS_STR_target, &val); swfdec_load_object_new (loader, url, request, data); } -void -swfdec_movie_load (SwfdecMovie *movie, const char *url, SwfdecLoaderRequest request, - SwfdecBuffer *data) -{ - SwfdecLoader *loader; - - g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie)); - g_return_if_fail (url != NULL); - - /* FIXME: load relative to other movie? */ - loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), - url, request, data); - swfdec_swf_instance_new (SWFDEC_SPRITE_MOVIE (movie), loader, NULL); - g_object_unref (loader); -} - char * swfdec_movie_get_path (SwfdecMovie *movie, gboolean dot) { diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h index 7848d52..40605db 100644 --- a/libswfdec/swfdec_movie.h +++ b/libswfdec/swfdec_movie.h @@ -238,10 +238,6 @@ void swfdec_movie_load_variables (SwfdecMovie * movie, const char * url, SwfdecLoaderRequest request, SwfdecBuffer * data); -void swfdec_movie_load (SwfdecMovie * movie, - const char * url, - SwfdecLoaderRequest request, - SwfdecBuffer * data); int swfdec_movie_compare_depths (gconstpointer a, gconstpointer b); diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index fc43ef3..ace4c45 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -1573,6 +1573,8 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect) * swfdec_player_get_level: * @player: a #SwfdecPlayer * @name: name of the level to request + * @ignore_case: %TRUE to always be case insensitive, otherwise use the version + * to determine case sensitivity * @create: %TRUE to create if it doesn't exist * * This function is used to look up root movies in the given @player. The @@ -1585,10 +1587,11 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect) * movie exists. Note that if a new movie is created, it will not be * fully initialized (yes, this function sucks). **/ -SwfdecMovie * -swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create) +SwfdecSpriteMovie * +swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean ignore_case, + gboolean create) { - SwfdecMovie *movie; + SwfdecSpriteMovie *movie; GList *walk; const char *s; char *end; @@ -1599,7 +1602,7 @@ swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create g_return_val_if_fail (name != NULL, NULL); /* check name starts with "_level" */ - if (swfdec_strncmp (SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0) + if (swfdec_strncmp (ignore_case ? 6 : SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0) return NULL; name += 6; /* extract depth from rest string (or fail if it's not a depth) */ @@ -1610,11 +1613,11 @@ swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create depth = l - 16384; /* find movie */ for (walk = player->roots; walk; walk = walk->next) { - movie = walk->data; - if (movie->depth < depth) + SwfdecMovie *cur = walk->data; + if (cur->depth < depth) continue; - if (movie->depth == depth) - return movie; + if (cur->depth == depth) + return SWFDEC_SPRITE_MOVIE (cur); break; } /* bail if create isn't set*/ @@ -1622,8 +1625,8 @@ swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create return NULL; /* create new root movie */ s = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%lu", l)); - movie = swfdec_movie_new (player, depth, NULL, NULL, s); - movie->name = SWFDEC_AS_STR_EMPTY; + movie = SWFDEC_SPRITE_MOVIE (swfdec_movie_new (player, depth, NULL, NULL, s)); + SWFDEC_MOVIE (movie)->name = SWFDEC_AS_STR_EMPTY; return movie; } diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index 0f717cb..f25f782 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -195,8 +195,10 @@ void swfdec_player_stop_sounds (SwfdecPlayer * player, SwfdecAudioRemoveFunc func, gpointer data); void swfdec_player_stop_all_sounds (SwfdecPlayer * player); -SwfdecMovie * swfdec_player_get_level (SwfdecPlayer * player, +SwfdecSpriteMovie * + swfdec_player_get_level (SwfdecPlayer * player, const char * name, + gboolean ignore_case, gboolean create); SwfdecMovie * swfdec_player_add_level_from_loader (SwfdecPlayer * player, diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c index 130ed4e..11c1bf4 100644 --- a/libswfdec/swfdec_sprite_movie.c +++ b/libswfdec/swfdec_sprite_movie.c @@ -683,3 +683,44 @@ swfdec_sprite_movie_init (SwfdecSpriteMovie * movie) movie->playing = TRUE; } +/* cute little hack */ +extern void +swfdec_sprite_movie_clear (SwfdecAsContext *cx, SwfdecAsObject *object, + guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval); +/** + * swfdec_sprite_movie_unload: + * @movie: a #SwfdecMovie + * + * Unloads all contents from the given movie. + **/ +void +swfdec_sprite_movie_unload (SwfdecSpriteMovie *movie) +{ + SwfdecAsValue hack; + + g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie)); + + swfdec_sprite_movie_clear (SWFDEC_AS_OBJECT (movie)->context, + SWFDEC_AS_OBJECT (movie), 0, NULL, &hack); + movie->frame = 0; + movie->sprite = NULL; +} + +void +swfdec_sprite_movie_load (SwfdecSpriteMovie *movie, const char *url, SwfdecLoaderRequest request, + SwfdecBuffer *data) +{ + SwfdecLoader *loader; + + g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie)); + g_return_if_fail (url != NULL); + + swfdec_sprite_movie_unload (movie); + + /* FIXME: load relative to other movie? */ + loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), + url, request, data); + swfdec_swf_instance_new (movie, loader, NULL); + g_object_unref (loader); +} + diff --git a/libswfdec/swfdec_sprite_movie.h b/libswfdec/swfdec_sprite_movie.h index 6f1b570..0573d92 100644 --- a/libswfdec/swfdec_sprite_movie.h +++ b/libswfdec/swfdec_sprite_movie.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS -typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie; +//typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie; typedef struct _SwfdecSpriteMovieClass SwfdecSpriteMovieClass; #define SWFDEC_TYPE_SPRITE_MOVIE (swfdec_sprite_movie_get_type()) @@ -66,6 +66,12 @@ GType swfdec_sprite_movie_get_type (void); void swfdec_sprite_movie_goto (SwfdecSpriteMovie * movie, guint goto_frame); +void swfdec_sprite_movie_unload (SwfdecSpriteMovie * movie); +void swfdec_sprite_movie_load (SwfdecSpriteMovie * movie, + const char * url, + SwfdecLoaderRequest request, + SwfdecBuffer * data); + G_END_DECLS #endif diff --git a/libswfdec/swfdec_types.h b/libswfdec/swfdec_types.h index cee815a..37a89ea 100644 --- a/libswfdec/swfdec_types.h +++ b/libswfdec/swfdec_types.h @@ -55,6 +55,7 @@ typedef struct _SwfdecSound SwfdecSound; typedef struct _SwfdecSoundChunk SwfdecSoundChunk; typedef struct _SwfdecSprite SwfdecSprite; typedef struct _SwfdecSpriteFrame SwfdecSpriteFrame; +typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie; typedef struct _SwfdecSwfDecoder SwfdecSwfDecoder; typedef struct _SwfdecSwfInstance SwfdecSwfInstance; typedef struct _SwfdecText SwfdecText; commit a25766bd236cb0e9120d66916f265793ac8f73e0 Author: Benjamin Otte <otte at gnome.org> Date: Tue Oct 16 15:08:13 2007 +0200 big reorg patch for GetURL and GetURL2 fixage diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index e11397f..4a80a75 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -548,14 +548,24 @@ swfdec_player_get_movie_from_value (SwfdecPlayer *player, SwfdecAsValue *val) { SwfdecAsContext *cx; const char *s; - SwfdecAsObject *ret; g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL); - g_return_val_if_fail (val != NULL, NULL); + g_return_val_if_fail (SWFDEC_IS_AS_VALUE (val), NULL); cx = SWFDEC_AS_CONTEXT (player); s = swfdec_as_value_to_string (cx, val); - ret = swfdec_action_lookup_object (cx, NULL, s, s + strlen (s)); + return swfdec_player_get_movie_from_string (player, s); +} + +SwfdecMovie * +swfdec_player_get_movie_from_string (SwfdecPlayer *player, const char *s) +{ + SwfdecAsObject *ret; + + g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL); + g_return_val_if_fail (s != NULL, NULL); + + ret = swfdec_action_lookup_object (SWFDEC_AS_CONTEXT (player), NULL, s, s + strlen (s)); if (!SWFDEC_IS_MOVIE (ret)) { SWFDEC_WARNING ("\"%s\" does not reference a movie", s); return NULL; @@ -1134,11 +1144,24 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu if (swfdec_bits_left (&bits)) { SWFDEC_WARNING ("leftover bytes in GetURL action"); } - if (SWFDEC_IS_MOVIE (cx->frame->target)) - swfdec_movie_load (SWFDEC_MOVIE (cx->frame->target), url, target, - SWFDEC_LOADER_REQUEST_DEFAULT, NULL, 0); - else - SWFDEC_WARNING ("no movie to load"); + if (!SWFDEC_IS_PLAYER (cx)) { + SWFDEC_ERROR ("GetURL without a SwfdecPlayer"); + } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) { + /* nothing to do here */ + } else { + SwfdecMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE); + if (movie) { + if (movie->swf == NULL) { + swfdec_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); + swfdec_movie_initialize (movie); + } else { + swfdec_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); + } + } else { + swfdec_player_launch (SWFDEC_PLAYER (cx), SWFDEC_LOADER_REQUEST_DEFAULT, + url, target, NULL); + } + } g_free (url); g_free (target); } @@ -1147,38 +1170,54 @@ static void swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len) { const char *target, *url; - guint method; + guint method, internal, variables; if (len != 1) { SWFDEC_ERROR ("GetURL2 requires 1 byte of data, not %u", len); return; } - target = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1)); - url = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2)); method = data[0] & 3; - if (method == 3) { SWFDEC_ERROR ("GetURL method 3 invalid"); method = 0; } + internal = data[0] & 64; + variables = data[0] & 128; + if (method == 1 || method == 2) { + SWFDEC_FIXME ("encode variables"); + } - // FIXME: What difference should LoadTarget flag (data[0] & 64) do? + target = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1)); + url = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2)); - if (data[0] & 128) { - if (SWFDEC_IS_MOVIE (cx->frame->target)) { - swfdec_movie_load_variables (SWFDEC_MOVIE (cx->frame->target), url, - target, method); + if (!SWFDEC_IS_PLAYER (cx)) { + SWFDEC_ERROR ("GetURL2 action requires a SwfdecPlayer"); + } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) { + /* nothing to do here */ + } else if (internal) { + SwfdecMovie *movie; + /* FIXME: This code looks wrong - figure out how levels are handled */ + movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, !variables); + if (movie) { + if (movie->swf == NULL) { + swfdec_movie_load (movie, url, method, NULL); + swfdec_movie_initialize (movie); + } } else { - SWFDEC_WARNING ("no movie to load"); + movie = swfdec_player_get_movie_from_string ( + SWFDEC_PLAYER (cx), target); + if (movie == NULL) { + /* swfdec_player_get_movie_from_value() should have warned already */ + } else if (variables) { + swfdec_movie_load_variables (movie, url, method, NULL); + } else { + swfdec_movie_load (movie, url, method, NULL); + } } } else { - if (SWFDEC_IS_MOVIE (cx->frame->target)) { - swfdec_movie_load (SWFDEC_MOVIE (cx->frame->target), url, target, method, - NULL, 0); - } else { - SWFDEC_WARNING ("no movie to load"); - } + /* load an external file */ + swfdec_player_launch (SWFDEC_PLAYER (cx), method, url, target, NULL); } swfdec_as_stack_pop_n (cx, 2); diff --git a/libswfdec/swfdec_load_object.c b/libswfdec/swfdec_load_object.c index 5c9003e..7174aa2 100644 --- a/libswfdec/swfdec_load_object.c +++ b/libswfdec/swfdec_load_object.c @@ -182,7 +182,8 @@ swfdec_load_object_init (SwfdecLoadObject *load_object) } static void -swfdec_load_object_load (SwfdecLoadObject *load_object, const char *url) +swfdec_load_object_load (SwfdecLoadObject *load_object, const char *url, + SwfdecLoaderRequest request, SwfdecBuffer *data) { SwfdecAsValue val; @@ -191,7 +192,7 @@ swfdec_load_object_load (SwfdecLoadObject *load_object, const char *url) swfdec_load_object_reset (load_object); load_object->loader = swfdec_player_load ( - SWFDEC_PLAYER (SWFDEC_AS_OBJECT (load_object)->context), url); + SWFDEC_PLAYER (SWFDEC_AS_OBJECT (load_object)->context), url, request, data); swfdec_loader_set_target (load_object->loader, SWFDEC_LOADER_TARGET (load_object)); swfdec_loader_set_data_type (load_object->loader, SWFDEC_LOADER_DATA_TEXT); @@ -209,7 +210,8 @@ swfdec_load_object_load (SwfdecLoadObject *load_object, const char *url) } SwfdecAsObject * -swfdec_load_object_new (SwfdecAsObject *target, const char *url) +swfdec_load_object_new (SwfdecAsObject *target, const char *url, + SwfdecLoaderRequest request, SwfdecBuffer *data) { SwfdecAsObject *load_object; @@ -227,7 +229,7 @@ swfdec_load_object_new (SwfdecAsObject *target, const char *url) SWFDEC_PLAYER (target->context)->load_objects g_list_append (SWFDEC_PLAYER (target->context)->load_objects, load_object); - swfdec_load_object_load (SWFDEC_LOAD_OBJECT (load_object), url); + swfdec_load_object_load (SWFDEC_LOAD_OBJECT (load_object), url, request, data); return load_object; } diff --git a/libswfdec/swfdec_load_object.h b/libswfdec/swfdec_load_object.h index 9a07b59..071ab4d 100644 --- a/libswfdec/swfdec_load_object.h +++ b/libswfdec/swfdec_load_object.h @@ -51,7 +51,9 @@ struct _SwfdecLoadObjectClass { GType swfdec_load_object_get_type (void); SwfdecAsObject *swfdec_load_object_new (SwfdecAsObject * target, - const char * url); + const char * url, + SwfdecLoaderRequest request, + SwfdecBuffer * data); G_END_DECLS diff --git a/libswfdec/swfdec_load_object_as.c b/libswfdec/swfdec_load_object_as.c index 57d91e8..335bf6b 100644 --- a/libswfdec/swfdec_load_object_as.c +++ b/libswfdec/swfdec_load_object_as.c @@ -42,7 +42,7 @@ swfdec_load_object_load (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, } url = swfdec_as_value_to_string (cx, &argv[0]); - swfdec_load_object_new (obj, url); + swfdec_load_object_new (obj, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL); SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE); } diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c index 0771c3e..de4ec28 100644 --- a/libswfdec/swfdec_movie.c +++ b/libswfdec/swfdec_movie.c @@ -1354,7 +1354,7 @@ swfdec_movie_load_variables_on_data (SwfdecAsContext *cx, void swfdec_movie_load_variables (SwfdecMovie *movie, const char *url, - const char *target, SwfdecLoaderRequest request) + SwfdecLoaderRequest request, SwfdecBuffer *data) { SwfdecAsObject *loader; SwfdecAsContext *context; @@ -1362,16 +1362,6 @@ swfdec_movie_load_variables (SwfdecMovie *movie, const char *url, g_return_if_fail (SWFDEC_IS_MOVIE (movie)); g_return_if_fail (url != NULL); - g_return_if_fail (target != NULL); - - context = SWFDEC_AS_OBJECT (movie)->context; - - swfdec_as_context_eval (context, SWFDEC_AS_OBJECT (movie), target, &val); - if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) || - !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (&val))) { - SWFDEC_WARNING ("Target not a movie"); - return; - } if (request != SWFDEC_LOADER_REQUEST_DEFAULT) { SWFDEC_FIXME ("loadVariables: Different request-modes not supported"); @@ -1383,52 +1373,23 @@ swfdec_movie_load_variables (SwfdecMovie *movie, const char *url, swfdec_movie_load_variables_on_data, 0); swfdec_as_object_set_variable (loader, SWFDEC_AS_STR_target, &val); - swfdec_load_object_new (loader, url); + swfdec_load_object_new (loader, url, request, data); } void -swfdec_movie_load (SwfdecMovie *movie, const char *url, const char *target, - SwfdecLoaderRequest request, const char *data, gsize data_len) +swfdec_movie_load (SwfdecMovie *movie, const char *url, SwfdecLoaderRequest request, + SwfdecBuffer *data) { - SwfdecPlayer *player; - guint version; + SwfdecLoader *loader; - g_return_if_fail (SWFDEC_IS_MOVIE (movie)); + g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie)); g_return_if_fail (url != NULL); - g_return_if_fail (target != NULL); - - player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context); - version = SWFDEC_AS_CONTEXT (player)->version; - /* yay for the multiple uses of GetURL - one of the crappier Flash things */ - if (g_ascii_strncasecmp (url, "FSCommand:", strlen ("FSCommand:")) != 0 && - ((version >= 7 && g_str_has_prefix (target, "_level")) || - (version < 7 && - g_ascii_strncasecmp (target, "_level", strlen ("_level")) == 0))) - { - const char *nr = target + strlen ("_level"); - char *end; - guint depth; - - errno = 0; - depth = strtoul (nr, &end, 10); - if (errno == 0 && *end == '\0') { - if (url[0] == '\0') { - swfdec_player_remove_level (player, depth); - } else { - SwfdecLoader *loader = swfdec_loader_load (movie->swf->loader, url, - request, data, data_len); - g_assert (loader); - swfdec_player_add_level_from_loader (player, depth, loader, NULL); - } - } else { - SWFDEC_ERROR ("%s does not specify a valid level", target); - } - /* FIXME: what do we do here? Is returning correct?*/ - return; - } - /* FIXME: add data */ - swfdec_player_launch (player, request, url, target, NULL); + /* FIXME: load relative to other movie? */ + loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), + url, request, data); + swfdec_swf_instance_new (SWFDEC_SPRITE_MOVIE (movie), loader, NULL); + g_object_unref (loader); } char * diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h index 3b41d2f..7848d52 100644 --- a/libswfdec/swfdec_movie.h +++ b/libswfdec/swfdec_movie.h @@ -236,14 +236,12 @@ void swfdec_movie_set_variables (SwfdecMovie * movie, const char * variables); void swfdec_movie_load_variables (SwfdecMovie * movie, const char * url, - const char * target, - SwfdecLoaderRequest request); + SwfdecLoaderRequest request, + SwfdecBuffer * data); void swfdec_movie_load (SwfdecMovie * movie, const char * url, - const char * target, SwfdecLoaderRequest request, - const char * data, - gsize data_len); + SwfdecBuffer * data); int swfdec_movie_compare_depths (gconstpointer a, gconstpointer b); diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c index 41a6c42..59cb836 100644 --- a/libswfdec/swfdec_net_stream.c +++ b/libswfdec/swfdec_net_stream.c @@ -482,7 +482,8 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, const char *url) g_return_if_fail (url != NULL); /* FIXME: use the connection once connections are implemented */ - loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context), url); + loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context), url, + SWFDEC_LOADER_REQUEST_DEFAULT, NULL); swfdec_net_stream_set_loader (stream, loader); g_object_unref (loader); } diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index e844181..fc43ef3 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -21,6 +21,7 @@ #include "config.h" #endif +#include <errno.h> #include <math.h> #include <string.h> #include <stdlib.h> @@ -43,6 +44,7 @@ #include "swfdec_script_internal.h" #include "swfdec_sprite_movie.h" #include "swfdec_swf_instance.h" +#include "swfdec_utils.h" /*** gtk-doc ***/ @@ -1417,9 +1419,9 @@ swfdec_player_class_init (SwfdecPlayerClass *klass) /** * SwfdecPlayer::fscommand: * @player: the #SwfdecPlayer affected - * @command: the command to execute - * @paramter: parameter to pass to the command. The parameter depends on the - * function. + * @command: the command to execute. This is a lower case string. + * @parameter: parameter to pass to the command. The parameter depends on the + * function. * * This signal is emited whenever a Flash script command (also known as * fscommand) is encountered. This method is ued by the Flash file to @@ -1567,6 +1569,64 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect) player->invalidations->len); } +/** + * swfdec_player_get_level: + * @player: a #SwfdecPlayer + * @name: name of the level to request + * @create: %TRUE to create if it doesn't exist + * + * This function is used to look up root movies in the given @player. The + * algorithm used is like this: First, check that @name actually references a + * root level movie. If it does not, return %NULL. If the movie for the given + * level already exists, return it. If it does not, create it when @create was + * set to %TRUE and return the newly created movie. Otherwise return %NULL. + * + * Returns: the #SwfdecMovie referenced by the given @name or %NULL if no such + * movie exists. Note that if a new movie is created, it will not be + * fully initialized (yes, this function sucks). + **/ +SwfdecMovie * +swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create) +{ + SwfdecMovie *movie; + GList *walk; + const char *s; + char *end; + int depth; + gulong l; + + g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL); + g_return_val_if_fail (name != NULL, NULL); + + /* check name starts with "_level" */ + if (swfdec_strncmp (SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0) + return NULL; + name += 6; + /* extract depth from rest string (or fail if it's not a depth) */ + errno = 0; + l = strtoul (name, &end, 10); + if (errno != 0 || *end != 0 || l > G_MAXINT) + return NULL; + depth = l - 16384; + /* find movie */ + for (walk = player->roots; walk; walk = walk->next) { + movie = walk->data; + if (movie->depth < depth) + continue; + if (movie->depth == depth) + return movie; + break; + } + /* bail if create isn't set*/ + if (!create) + return NULL; + /* create new root movie */ + s = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%lu", l)); + movie = swfdec_movie_new (player, depth, NULL, NULL, s); + movie->name = SWFDEC_AS_STR_EMPTY; + return movie; +} + SwfdecMovie * swfdec_player_add_level_from_loader (SwfdecPlayer *player, guint depth, SwfdecLoader *loader, const char *variables) @@ -1608,13 +1668,65 @@ swfdec_player_remove_level (SwfdecPlayer *player, guint depth) } SwfdecLoader * -swfdec_player_load (SwfdecPlayer *player, const char *url) +swfdec_player_load (SwfdecPlayer *player, const char *url, + SwfdecLoaderRequest request, SwfdecBuffer *buffer) { g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL); g_return_val_if_fail (url != NULL, NULL); g_assert (player->loader); - return swfdec_loader_load (player->loader, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL, 0); + if (buffer) { + return swfdec_loader_load (player->loader, url, request, + (const char *) buffer->data, buffer->length); + } else { + return swfdec_loader_load (player->loader, url, request, NULL, 0); + } +} + +static gboolean +is_ascii (const char *s) +{ + while (*s) { + if (*s & 0x80) + return FALSE; + s++; + } + return TRUE; +} + +/** + * swfdec_player_fscommand: + * @player: a #SwfdecPlayer + * @command: the command to parse + * @value: the value passed to the command + * + * Checks if @command is an FSCommand and if so, emits the + * SwfdecPlayer::fscommand signal. + * + * Returns: %TRUE if an fscommand was found and the signal emitted, %FALSE + * otherwise. + **/ +gboolean +swfdec_player_fscommand (SwfdecPlayer *player, const char *command, const char *value) +{ + char *real_command; + + g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE); + g_return_val_if_fail (command != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + if (g_ascii_strncasecmp (command, "FSCommand:", 10) != 0) + return FALSE; + + command += 10; + if (!is_ascii (command)) { + SWFDEC_ERROR ("command \"%s\" are not ascii, skipping fscommand", command); + return TRUE; + } + real_command = g_ascii_strdown (command, -1); + g_signal_emit (player, signals[FSCOMMAND], 0, real_command, value); + g_free (real_command); + return TRUE; } void diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index 80af913..0f717cb 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -195,6 +195,9 @@ void swfdec_player_stop_sounds (SwfdecPlayer * player, SwfdecAudioRemoveFunc func, gpointer data); void swfdec_player_stop_all_sounds (SwfdecPlayer * player); +SwfdecMovie * swfdec_player_get_level (SwfdecPlayer * player, + const char * name, + gboolean create); SwfdecMovie * swfdec_player_add_level_from_loader (SwfdecPlayer * player, guint depth, @@ -202,8 +205,13 @@ SwfdecMovie * swfdec_player_add_level_from_loader const char * variables); void swfdec_player_remove_level (SwfdecPlayer * player, guint depth); +gboolean swfdec_player_fscommand (SwfdecPlayer * player, + const char * command, + const char * value); SwfdecLoader * swfdec_player_load (SwfdecPlayer * player, - const char * url); + const char * url, + SwfdecLoaderRequest request, + SwfdecBuffer * buffer); void swfdec_player_launch (SwfdecPlayer * player, SwfdecLoaderRequest request, const char * url, @@ -219,6 +227,9 @@ void swfdec_player_global_to_stage (SwfdecPlayer * player, SwfdecMovie * swfdec_player_get_movie_from_value (SwfdecPlayer * player, SwfdecAsValue * val); +SwfdecMovie * swfdec_player_get_movie_from_string + (SwfdecPlayer * player, + const char * s); G_END_DECLS commit 034c310b5e4595310441f6082aa93b932de23146 Author: Benjamin Otte <otte at gnome.org> Date: Tue Oct 16 12:42:51 2007 +0200 add swfdec_strcmp() and swfdec_strncmp() This function to version-dependant string matching as is done in Actionscript diff --git a/libswfdec/swfdec_utils.c b/libswfdec/swfdec_utils.c index b809a2f..a6dc0db 100644 --- a/libswfdec/swfdec_utils.c +++ b/libswfdec/swfdec_utils.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include <string.h> + #include "swfdec_utils.h" gboolean @@ -44,3 +46,29 @@ swfdec_str_case_hash (gconstpointer v) return h; } +int +swfdec_strcmp (guint version, const char *s1, const char *s2) +{ + g_return_val_if_fail (s1 != NULL, 0); + g_return_val_if_fail (s2 != NULL, 0); + + if (version < 7) { + return g_ascii_strcasecmp (s1, s2); + } else { + return strcmp (s1, s2); + } +} + +int +swfdec_strncmp (guint version, const char *s1, const char *s2, guint n) +{ + g_return_val_if_fail (s1 != NULL, 0); + g_return_val_if_fail (s2 != NULL, 0); + + if (version < 7) { + return g_ascii_strncasecmp (s1, s2, n); + } else { + return strncmp (s1, s2, n); + } +} + diff --git a/libswfdec/swfdec_utils.h b/libswfdec/swfdec_utils.h index f208651..fc57a5d 100644 --- a/libswfdec/swfdec_utils.h +++ b/libswfdec/swfdec_utils.h @@ -27,6 +27,14 @@ gboolean swfdec_str_case_equal (gconstpointer v1, gconstpointer v2); guint swfdec_str_case_hash (gconstpointer v); +int swfdec_strcmp (guint version, + const char * s1, + const char * s2); +int swfdec_strncmp (guint version, + const char * s1, + const char * s2, + guint n); + G_END_DECLS #endif commit e623c50e0564d1871dd1d7d1c6e9183f74945f7a Author: Benjamin Otte <otte at gnome.org> Date: Tue Oct 16 08:36:03 2007 +0200 change swfdec_player_launch() and LAUNCH signal to take request type and data diff --git a/libswfdec/swfdec_marshal.list b/libswfdec/swfdec_marshal.list index 9357834..5aeeb44 100644 --- a/libswfdec/swfdec_marshal.list +++ b/libswfdec/swfdec_marshal.list @@ -1,5 +1,6 @@ BOOLEAN:DOUBLE,DOUBLE,INT BOOLEAN:UINT,UINT,BOOLEAN VOID:BOXED,POINTER,UINT +VOID:ENUM,STRING,STRING,BOXED VOID:STRING,STRING VOID:ULONG,UINT diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c index 3d8bade..0771c3e 100644 --- a/libswfdec/swfdec_movie.c +++ b/libswfdec/swfdec_movie.c @@ -1427,7 +1427,8 @@ swfdec_movie_load (SwfdecMovie *movie, const char *url, const char *target, /* FIXME: what do we do here? Is returning correct?*/ return; } - swfdec_player_launch (player, url, target); + /* FIXME: add data */ + swfdec_player_launch (player, request, url, target, NULL); } char * diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index 4980b21..e844181 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -1447,8 +1447,12 @@ swfdec_player_class_init (SwfdecPlayerClass *klass) /** * SwfdecPlayer::launch: * @player: the #SwfdecPlayer affected + * @request: the type of request * @url: URL to open * @target: target to load the URL into + * @data: optional data to pass on with the request. Will be of mime type + * application/x-www-form-urlencoded. Can be %NULL indicating no data + * should be passed. * * Emitted whenever the @player encounters an URL that should be loaded into * a target the Flash player does not recognize. In most cases this happens @@ -1457,8 +1461,9 @@ swfdec_player_class_init (SwfdecPlayerClass *klass) * The effect of calling any swfdec functions on the emitting @player is undefined. */ signals[LAUNCH] = g_signal_new ("launch", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__ENUM_STRING_STRING_BOXED, + G_TYPE_NONE, 4, SWFDEC_TYPE_LOADER_REQUEST, G_TYPE_STRING, G_TYPE_STRING, + SWFDEC_TYPE_BUFFER); context_class->mark = swfdec_player_mark; context_class->get_time = swfdec_player_get_time; @@ -1613,7 +1618,8 @@ swfdec_player_load (SwfdecPlayer *player, const char *url) } void -swfdec_player_launch (SwfdecPlayer *player, const char *url, const char *target) +swfdec_player_launch (SwfdecPlayer *player, SwfdecLoaderRequest request, const char *url, + const char *target, SwfdecBuffer *data) { g_return_if_fail (SWFDEC_IS_PLAYER (player)); g_return_if_fail (url != NULL); @@ -1624,7 +1630,7 @@ swfdec_player_launch (SwfdecPlayer *player, const char *url, const char *target) g_signal_emit (player, signals[FSCOMMAND], 0, command, target); return; } - g_signal_emit (player, signals[LAUNCH], 0, url, target); + g_signal_emit (player, signals[LAUNCH], 0, request, url, target, data); } /** diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index 182acd0..80af913 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -205,8 +205,10 @@ void swfdec_player_remove_level (SwfdecPlayer * player, SwfdecLoader * swfdec_player_load (SwfdecPlayer * player, const char * url); void swfdec_player_launch (SwfdecPlayer * player, + SwfdecLoaderRequest request, const char * url, - const char * target); + const char * target, + SwfdecBuffer * data); void swfdec_player_stage_to_global (SwfdecPlayer * player, double * x, double * y);
Maybe Matching Threads
- 18 commits - doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_button_movie.c libswfdec/swfdec_event.c libswfdec/swfdec_event.h libswfdec/swfdec_flash_security.c
- 2 commits - libswfdec/swfdec_flash_security.c libswfdec/swfdec_flash_security.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_resource_request.c libswfdec/swfdec_resource_request.h libswfdec/swfdec_security.h
- 6 commits - libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_interpret.h libswfdec/swfdec_as_object.c libswfdec/swfdec_as_script_function.c libswfdec/swfdec_flash_security.c
- 3 commits - libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader_internal.h libswfdec/swfdec_load_object_as.c libswfdec/swfdec_load_object.c libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c
- 70 commits - configure.ac libswfdec-gtk/Makefile.am libswfdec-gtk/swfdec-gtk.h libswfdec-gtk/swfdec_gtk_loader.c libswfdec-gtk/swfdec_gtk_player.c libswfdec-gtk/swfdec_gtk_socket.c libswfdec-gtk/swfdec_gtk_socket.h libswfdec-gtk/swfdec_playback_alsa.c