<commit_before>/* Swfdec
 * Copyright (C) 2008 <NAME> <<EMAIL>>
 *
 * 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 "swfdec_test_plugin.h"
#include <swfdec/swfdec.h>
#include "swfdec_test_test.h"
#include "swfdec_test_swfdec_socket.h"

static void
swfdec_test_plugin_swfdec_advance (SwfdecTestPlugin *plugin, unsigned int msecs)
{
  while (plugin->data && msecs > 0) {
    long next_event = swfdec_player_get_next_event (plugin->data);
    if (next_event < 0)
      break;
    next_event = MIN (next_event, (long) msecs);
    msecs -= swfdec_player_advance (plugin->data, next_event);
  }
  while (plugin->data && swfdec_player_get_next_event (plugin->data) == 0) {
    swfdec_player_advance (plugin->data, 0);
  }
}

static void
swfdec_test_plugin_swfdec_screenshot (SwfdecTestPlugin *plugin, unsigned char *data,
    guint x, guint y, guint width, guint height)
{
  cairo_surface_t *surface;
  cairo_t *cr;
  guint background;

  surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, 
      width, height, width * 4);
  cr = cairo_create (surface);
  background  = swfdec_player_get_background_color (plugin->data);
  cairo_set_source_rgb (cr, 
      ((background >> 16) & 0xFF) / 255.0,
      ((background >> 8) & 0xFF) / 255.0,
      (background & 0xFF) / 255.0);
  cairo_paint (cr);

  cairo_translate (cr, -x, -y);
  swfdec_player_render (plugin->data, cr, x, y, width, height);
  cairo_destroy (cr);
  cairo_surface_destroy (surface);
}

static void
swfdec_test_plugin_swfdec_mouse_move (SwfdecTestPlugin *plugin, double x, double y)
{
  swfdec_player_mouse_move (plugin->data, x, y);
}

static void
swfdec_test_plugin_swfdec_mouse_press (SwfdecTestPlugin *plugin, double x, double y, guint button)
{
  swfdec_player_mouse_press (plugin->data, x, y, button);
}

static void
swfdec_test_plugin_swfdec_mouse_release (SwfdecTestPlugin *plugin, double x, double y, guint button)
{
  swfdec_player_mouse_release (plugin->data, x, y, button);
}

static void
swfdec_test_plugin_swfdec_finish (SwfdecTestPlugin *plugin)
{
  if (plugin->data) {
    g_object_unref (plugin->data);
    plugin->data = NULL;
  }
}

static void
swfdec_test_plugin_swfdec_trace (SwfdecPlayer *player, const char *message, 
    SwfdecTestPlugin *plugin)
{
  plugin->trace (plugin, message);
}

static void
swfdec_test_plugin_swfdec_launch (SwfdecPlayer *player, const char *url,
    const char *target, SwfdecBuffer *data, SwfdecTestPlugin *plugin)
{
  plugin->launch (plugin, url);
}

static void
swfdec_test_plugin_swfdec_fscommand (SwfdecPlayer *player, const char *command, 
    const char *para, SwfdecTestPlugin *plugin)
{
  if (g_ascii_strcasecmp (command, "quit") == 0) {
    plugin->quit (plugin);<commit_msg>Update swfdec_test_plugin_swfdec_launch to match the new launch signal<commit_after>/* Swfdec
 * Copyright (C) 2008 <NAME> <<EMAIL>>
 *
 * 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 "swfdec_test_plugin.h"
#include <swfdec/swfdec.h>
#include "swfdec_test_test.h"
#include "swfdec_test_swfdec_socket.h"

static void
swfdec_test_plugin_swfdec_advance (SwfdecTestPlugin *plugin, unsigned int msecs)
{
  while (plugin->data && msecs > 0) {
    long next_event = swfdec_player_get_next_event (plugin->data);
    if (next_event < 0)
      break;
    next_event = MIN (next_event, (long) msecs);
    msecs -= swfdec_player_advance (plugin->data, next_event);
  }
  while (plugin->data && swfdec_player_get_next_event (plugin->data) == 0) {
    swfdec_player_advance (plugin->data, 0);
  }
}

static void
swfdec_test_plugin_swfdec_screenshot (SwfdecTestPlugin *plugin, unsigned char *data,
    guint x, guint y, guint width, guint height)
{
  cairo_surface_t *surface;
  cairo_t *cr;
  guint background;

  surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, 
      width, height, width * 4);
  cr = cairo_create (surface);
  background  = swfdec_player_get_background_color (plugin->data);
  cairo_set_source_rgb (cr, 
      ((background >> 16) & 0xFF) / 255.0,
      ((background >> 8) & 0xFF) / 255.0,
      (background & 0xFF) / 255.0);
  cairo_paint (cr);

  cairo_translate (cr, -x, -y);
  swfdec_player_render (plugin->data, cr, x, y, width, height);
  cairo_destroy (cr);
  cairo_surface_destroy (surface);
}

static void
swfdec_test_plugin_swfdec_mouse_move (SwfdecTestPlugin *plugin, double x, double y)
{
  swfdec_player_mouse_move (plugin->data, x, y);
}

static void
swfdec_test_plugin_swfdec_mouse_press (SwfdecTestPlugin *plugin, double x, double y, guint button)
{
  swfdec_player_mouse_press (plugin->data, x, y, button);
}

static void
swfdec_test_plugin_swfdec_mouse_release (SwfdecTestPlugin *plugin, double x, double y, guint button)
{
  swfdec_player_mouse_release (plugin->data, x, y, button);
}

static void
swfdec_test_plugin_swfdec_finish (SwfdecTestPlugin *plugin)
{
  if (plugin->data) {
    g_object_unref (plugin->data);
    plugin->data = NULL;
  }
}

static void
swfdec_test_plugin_swfdec_trace (SwfdecPlayer *player, const char *message, 
    SwfdecTestPlugin *plugin)
{
  plugin->trace (plugin, message);
}

static void
swfdec_test_plugin_swfdec_launch (SwfdecPlayer *player, const char *url,
    const char *target, SwfdecBuffer *data, guint header_count,
    const char **header_names, const char **header_values,
    SwfdecTestPlugin *plugin)
{
  plugin->launch (plugin, url);
}

static void
swfdec_test_plugin_swfdec_fscommand (SwfdecPlayer *player, const char *command, 
    const char *para, SwfdecTestPlugin *plugin)
{
  if (g_ascii_strcasecmp (command, "quit") == 0) {
    plugin->quit (plugin);
{'fraction_non_alphanumeric': 0.09974604966139955, 'fraction_numerical': 0.012133182844243792, 'mean_word_length': 4.644108280254777, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '88663', 'n_tokens_mistral': 2539, 'n_tokens_neox': 2439, 'n_words': 706}