Beispiel #1
0
bool
xplayerNPObject::CheckArgv (const NPVariant* argv,
                          uint32_t argc,
                          uint32_t expectedArgc,
                          ...)
{
  if (!CheckArgc (argc, expectedArgc, expectedArgc))
    return false;

  va_list type_args;
  va_start (type_args, expectedArgc);

  for (uint32_t i = 0; i < argc; ++i) {
    NPVariantType type = NPVariantType (va_arg (type_args, int /* promotion */));

    if (!CheckArgType (argv[i].type, type)) {
      va_end (type_args);
      return false;
    }
  }

  va_end (type_args);

  return true;
}
Beispiel #2
0
bool
xplayerNPObject::CheckArg (const NPVariant *argv,
                         uint32_t argc,
                         uint32_t argNum,
                         NPVariantType type)
{
  if (!CheckArgc (argc, argNum + 1))
    return false;

  return CheckArgType (argv[argNum].type, type, argNum);
}
Beispiel #3
0
bool
totemConePlaylist::InvokeByIndex (int aIndex,
                                  const NPVariant *argv,
                                  uint32_t argc,
                                  NPVariant *_result)
{
  TOTEM_LOG_INVOKE (aIndex, totemConePlaylist);

  switch (Methods (aIndex)) {
    case eAdd: {
      /* long add (in AUTF8String MRL, [in AUTF8String name, in AUTF8String options]); */
      if (!CheckArgc (argc, 1, 3))
        return false;

      NPString mrl;
      if (!GetNPStringFromArguments (argv, argc, 0, mrl))
        return false;

      NPString title;
      if (argc != 3 || !GetNPStringFromArguments (argv, argc, 1, title))
        title.UTF8Characters = NULL;

      NPString options;
      if (argc != 3 || !GetNPStringFromArguments (argv, argc, 2, options))
        options.UTF8Characters = NULL;
      //FIXME handle options as array
      //http://wiki.videolan.org/Documentation:WebPlugin#Playlist_object
      char *subtitle = NULL;
      if (options.UTF8Characters && options.UTF8Length) {
        char *str, **items;
        guint i;

        str = g_strndup (options.UTF8Characters, options.UTF8Length);
        items = g_strsplit (str, " ", -1);
        g_free (str);

        for (i = 0; items[i] != NULL; i++) {
          if (g_str_has_prefix (items[i], ":sub-file=")) {
            subtitle = g_strdup (items[i] + strlen (":sub-file="));
	    break;
	  }
	}
	g_strfreev (items);
      }

      Plugin()->AddItem (mrl, title, subtitle);
      g_free (subtitle);
      //FIXME we're supposed to return a unique number here
      return Int32Variant (_result, 1);
    }

    case ePlay:
      Plugin()->Command (TOTEM_COMMAND_PLAY);
      return VoidVariant (_result);

    case eStop:
      Plugin()->Command (TOTEM_COMMAND_STOP);
      return VoidVariant (_result);

    case eTogglePause:
      if (Plugin()->State() == TOTEM_STATE_PLAYING) {
	Plugin()->Command (TOTEM_COMMAND_PAUSE);
      } else if (Plugin()->State() == TOTEM_STATE_PAUSED) {
	Plugin()->Command (TOTEM_COMMAND_PLAY);
      }
      return VoidVariant (_result);

    case eNext:
    case ePlayItem:
    case ePrev:
    case eRemoveItem:
      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemConePlaylist);
      return VoidVariant (_result);
  }

  return false;
}