예제 #1
0
void
swfdec_load_object_create (SwfdecAsObject *target, const char *url,
    SwfdecBuffer *data, guint header_count, char **header_names,
    char **header_values, SwfdecLoadObjectProgress progress,
    SwfdecLoadObjectFinish finish)
{
  SwfdecPlayer *player;
  SwfdecLoadObject *load;

  g_return_if_fail (SWFDEC_IS_AS_OBJECT (target));
  g_return_if_fail (url != NULL);
  g_return_if_fail (header_count == 0 || header_names != NULL);
  g_return_if_fail (header_count == 0 || header_values != NULL);
  g_return_if_fail (finish != NULL);

  player = SWFDEC_PLAYER (swfdec_gc_object_get_context (target));
  load = g_object_new (SWFDEC_TYPE_LOAD_OBJECT, NULL);
  swfdec_player_root_full (player, load, swfdec_load_object_mark, g_object_unref);

  load->target = target;
  load->url = url;
  load->buffer = data;
  load->header_count = header_count;
  load->header_names = header_names;
  load->header_values = header_values;
  load->progress = progress;
  load->finish = finish;
  /* get the current security */
  g_assert (SWFDEC_AS_CONTEXT (player)->frame);
  load->sandbox = SWFDEC_SANDBOX (SWFDEC_AS_CONTEXT (player)->global);
  load->version = SWFDEC_AS_CONTEXT (player)->version;
  swfdec_player_request_resource (player, swfdec_load_object_request, load, NULL);
}
예제 #2
0
static void
swfdec_load_object_stream_target_close (SwfdecStreamTarget *target,
    SwfdecStream *stream)
{
  SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
  char *text;

  // get text
  text = swfdec_buffer_queue_pull_text (swfdec_stream_get_queue (stream), load_object->version);

  /* break reference to the loader */
  swfdec_stream_set_target (stream, NULL);
  load_object->loader = NULL;
  g_object_unref (stream);

  /* call finish */
  swfdec_sandbox_use (load_object->sandbox);
  if (text != NULL) {
    load_object->finish (load_object->target, 
	swfdec_as_context_give_string (swfdec_gc_object_get_context (load_object->target), text));
  } else {
    load_object->finish (load_object->target, SWFDEC_AS_STR_EMPTY);
  }
  swfdec_sandbox_unuse (load_object->sandbox);

  /* unroot */
  swfdec_player_unroot (SWFDEC_PLAYER (
	swfdec_gc_object_get_context (load_object->sandbox)), load_object);
}
static SwfdecXmlSocket *
swfdec_xml_socket_get (SwfdecAsObject *object)
{
  SwfdecXmlSocket *xml;
  SwfdecPlayer *player;
  GSList *walk;

  if (object == NULL) {
    SWFDEC_WARNING ("no object to get xml socket from");
    return NULL;
  }

  player = SWFDEC_PLAYER (object->context);
  for (walk = player->priv->xml_sockets; walk; walk = walk->next) {
    xml = walk->data;

    if (xml->target == object) {
      if (xml->socket == NULL) {
	SWFDEC_WARNING ("xml socket not open");
	return NULL;
      }
      return xml;
    }
  }

  SWFDEC_WARNING ("no xml socket on object");
  return NULL;
}
void
swfdec_system_security_get_sandboxType (SwfdecAsContext *cx,
    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
    SwfdecAsValue *ret)
{
  switch (swfdec_sandbox_get (SWFDEC_PLAYER (cx))->type) {
    case SWFDEC_SANDBOX_REMOTE:
      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_remote);
      break;

    case SWFDEC_SANDBOX_LOCAL_FILE:
      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localWithFile);
      break;

    case SWFDEC_SANDBOX_LOCAL_NETWORK:
      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localWithNetwork);
      break;

    case SWFDEC_SANDBOX_LOCAL_TRUSTED:
      SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localTrusted);
      break;

    case SWFDEC_SANDBOX_NONE:
    default:
      g_return_if_reached ();
  }
}
예제 #5
0
static void
swfdec_morph_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
{
  SwfdecRect rect;
  
  swfdec_rect_transform (&rect, &movie->original_extents, matrix);
  swfdec_player_invalidate (SWFDEC_PLAYER (swfdec_gc_object_get_context (movie)), &rect);
}
void
swfdec_mouse_hide (SwfdecAsContext *cx, SwfdecAsObject *object,
    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
  SwfdecPlayer *player = SWFDEC_PLAYER (cx);

  *retval = swfdec_as_value_from_integer (cx, player->priv->mouse_visible ? 1 : 0);
  player->priv->mouse_visible = FALSE;
}
예제 #7
0
static void
swfdec_video_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
{
  SwfdecVideo *org = SWFDEC_VIDEO (movie->graphic);
  SwfdecRect rect = { 0, 0, 
    SWFDEC_TWIPS_SCALE_FACTOR * org->width, 
    SWFDEC_TWIPS_SCALE_FACTOR * org->height };

  swfdec_rect_transform (&rect, &rect, matrix);
  swfdec_player_invalidate (SWFDEC_PLAYER (swfdec_gc_object_get_context (movie)), &rect);
}
void
swfdec_system_query (SwfdecAsContext *cx, SwfdecAsObject *object,
    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
{
  SwfdecPlayer *player = SWFDEC_PLAYER (cx);
  SwfdecAsValue val;
  guint i;
  GString *server;

  if (object == NULL) {
    SWFDEC_WARNING ("no this object in Query()");
    return;
  }

  server = g_string_new ("");
  for (i = 0; i < G_N_ELEMENTS (queries); i++) {
    queries[i].get (player, &val);
    swfdec_as_object_set_variable (object, queries[i].name, &val);
    if (queries[i].name == SWFDEC_AS_STR_screenResolutionY) {
      g_string_append_printf (server, "x%d", (int) SWFDEC_AS_VALUE_GET_NUMBER (val));
    } else if (queries[i].name == SWFDEC_AS_STR_pixelAspectRatio) {
      char buffer[10];
      g_ascii_formatd (buffer, sizeof (buffer), "%.1f",
	  SWFDEC_AS_VALUE_GET_NUMBER (val));
      g_string_append (server, "&AR=");
      g_string_append (server, buffer);
    } else if (queries[i].name == SWFDEC_AS_STR_manufacturer) {
      char *s = swfdec_as_string_escape (cx, player->priv->system->server_manufacturer);
      g_string_append_printf (server, "&M=%s", s);
      g_free (s);
    } else {
      g_assert (queries[i].server_string);
      if (i > 0)
	g_string_append_c (server, '&');
      g_string_append (server, queries[i].server_string);
      g_string_append_c (server, '=');
      if (SWFDEC_AS_VALUE_IS_BOOLEAN (val)) {
	g_string_append_c (server, SWFDEC_AS_VALUE_GET_BOOLEAN (val) ? 't' : 'f');
      } else if (SWFDEC_AS_VALUE_IS_NUMBER (val)) {
	g_string_append_printf (server, "%d", (int) SWFDEC_AS_VALUE_GET_NUMBER (val));
      } else if (SWFDEC_AS_VALUE_IS_STRING (val)) {
	char *s = swfdec_as_string_escape (cx, SWFDEC_AS_VALUE_GET_STRING (val));
	g_string_append (server, s);
	g_free (s);
      } else {
	g_assert_not_reached ();
      }
    }
  }
  SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_string_free (server, FALSE)));
  swfdec_as_object_set_variable (object, SWFDEC_AS_STR_serverString, &val);
}
static void
swfdec_xml_socket_ensure_closed (SwfdecXmlSocket *xml)
{
  SwfdecPlayer *player = SWFDEC_PLAYER (swfdec_gc_object_get_context (xml));

  if (xml->socket == NULL)
    return;

  swfdec_buffer_queue_clear (xml->send_queue);
  swfdec_stream_set_target (SWFDEC_STREAM (xml->socket), NULL);
  g_object_unref (xml->socket);
  xml->socket = NULL;
  player->priv->xml_sockets = g_slist_remove (player->priv->xml_sockets, xml);
}
void
swfdec_xml_socket_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
  const char *host;
  int port;

  SWFDEC_AS_CHECK (0, NULL, "si", &host, &port);

  if (object == NULL || object->movie)
    return;

  swfdec_xml_socket_create (object, swfdec_sandbox_get (SWFDEC_PLAYER (cx)), host, port);
}
예제 #11
0
static void
swfdec_bitmap_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
{
  SwfdecBitmapMovie *bitmap = SWFDEC_BITMAP_MOVIE (movie);
  SwfdecRect rect = { 0, 0, 0, 0 };

  if (bitmap->bitmap->surface == NULL)
    return;

  rect.x1 = cairo_image_surface_get_width (bitmap->bitmap->surface) * SWFDEC_TWIPS_SCALE_FACTOR;
  rect.y1 = cairo_image_surface_get_height (bitmap->bitmap->surface) * SWFDEC_TWIPS_SCALE_FACTOR;

  swfdec_rect_transform (&rect, &rect, matrix);
  swfdec_player_invalidate (SWFDEC_PLAYER (swfdec_gc_object_get_context (movie)), &rect);
}
void
swfdec_system_security_loadPolicyFile (SwfdecAsContext *cx,
    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
    SwfdecAsValue *ret)
{
  SwfdecPlayer *player;
  const char *url_string;
  SwfdecURL *url;

  SWFDEC_AS_CHECK (0, NULL, "s", &url_string);

  player = SWFDEC_PLAYER (cx);
  url = swfdec_player_create_url (player, url_string);
  swfdec_player_request_resource (player, swfdec_system_security_do_loadPolicyFile, 
      url, (GDestroyNotify) swfdec_url_free);
}
예제 #13
0
static void
swfdec_load_object_stream_target_error (SwfdecStreamTarget *target,
    SwfdecStream *stream)
{
  SwfdecLoader *loader = SWFDEC_LOADER (stream);
  SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);

  /* break reference to the loader */
  swfdec_stream_set_target (SWFDEC_STREAM (loader), NULL);
  load_object->loader = NULL;
  g_object_unref (loader);

  /* call finish */
  swfdec_sandbox_use (load_object->sandbox);
  load_object->finish (load_object->target, NULL);
  swfdec_sandbox_unuse (load_object->sandbox);

  /* unroot */
  swfdec_player_unroot (SWFDEC_PLAYER (
	swfdec_gc_object_get_context (load_object->sandbox)), load_object);
}
static SwfdecXmlSocket *
swfdec_xml_socket_create (SwfdecAsObject *target, SwfdecSandbox *sandbox, const char *hostname, guint port)
{
  SwfdecPlayer *player = SWFDEC_PLAYER (target->context);
  SwfdecXmlSocket *xml;
  SwfdecSocket *sock;

  SWFDEC_FIXME ("implement security checks please");
  sock = swfdec_player_create_socket (player, hostname, port);
  if (sock == NULL)
    return NULL;

  xml = g_object_new (SWFDEC_TYPE_XML_SOCKET, "context", player, NULL);
  /* we prepend here, so send etc find the newest socket */
  player->priv->xml_sockets = g_slist_prepend (player->priv->xml_sockets, xml);

  xml->target = target;
  xml->socket = sock;
  xml->sandbox = sandbox;
  swfdec_stream_set_target (SWFDEC_STREAM (sock), SWFDEC_STREAM_TARGET (xml));

  return xml;
}
static SwfdecPlayer *
swfdec_xml_socket_stream_target_get_player (SwfdecStreamTarget *target)
{
  return SWFDEC_PLAYER (swfdec_gc_object_get_context (target));
}
예제 #16
0
static SwfdecPlayer *
swfdec_load_object_stream_target_get_player (SwfdecStreamTarget *target)
{
  return SWFDEC_PLAYER (swfdec_gc_object_get_context (SWFDEC_LOAD_OBJECT (target)->target));
}
예제 #17
0
void
swfdec_bitmap_data_draw (SwfdecAsContext *cx, SwfdecAsObject *object,
    guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
  SwfdecAsObject *o, *matrix = NULL, *trans = NULL;
  cairo_t *cr;
  SwfdecColorTransform ctrans;
  SwfdecBitmapData *bitmap;
  SwfdecRenderer *renderer;
  cairo_matrix_t mat;

  SWFDEC_AS_CHECK (SWFDEC_TYPE_BITMAP_DATA, &bitmap, "o|OO", &o, &matrix, &trans);

  if (bitmap->surface == NULL)
    return;

  if (argc >= 2) {
    if (matrix == NULL || !swfdec_matrix_from_as_object (&mat, matrix))
      return;
  } else {
    cairo_matrix_init_identity (&mat);
  }
  if (SWFDEC_IS_COLOR_TRANSFORM_AS (trans)) {
    swfdec_color_transform_get_transform (SWFDEC_COLOR_TRANSFORM_AS (trans), &ctrans);
  } else {
    swfdec_color_transform_init_identity (&ctrans);
  }

  if (argc > 3) {
    SWFDEC_FIXME ("only the first 3 arguments to Bitmap.draw() are implemented");
  }

  cr = cairo_create (bitmap->surface);
  /* FIXME: Do we have a better renderer? */
  renderer = SWFDEC_PLAYER (cx)->priv->renderer;
  swfdec_renderer_attach (renderer, cr);
  cairo_transform (cr, &mat);

  if (SWFDEC_IS_BITMAP_DATA (o)) {
    SwfdecBitmapData *src = SWFDEC_BITMAP_DATA (o);
    if (src->surface) {
      if (swfdec_color_transform_is_identity (&ctrans)) {
	cairo_set_source_surface (cr, SWFDEC_BITMAP_DATA (o)->surface, 0, 0);
      } else {
	cairo_surface_t *transformed = swfdec_renderer_transform (renderer,
	    SWFDEC_BITMAP_DATA (o)->surface, &ctrans);
	SWFDEC_FIXME ("unmodified pixels will be treated as -1, not as 0 as in our "
	    "transform code, but we don't know if a pixel is unmodified.");
	cairo_set_source_surface (cr, transformed, 0, 0);
	cairo_surface_destroy (transformed);
      }
      cairo_paint (cr);
    }
  } else if (SWFDEC_IS_MOVIE (o)) {
    SwfdecMovie *movie = SWFDEC_MOVIE (o);
    swfdec_movie_update (movie);
    cairo_scale (cr, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR);
    cairo_transform (cr, &movie->inverse_matrix);
    swfdec_movie_render (movie, cr, &ctrans);
  } else {
    SWFDEC_FIXME ("BitmapData.draw() with a %s?", G_OBJECT_TYPE_NAME (o));
  }

  cairo_destroy (cr);
}