/* returns true if this instance can run windowless */ static gboolean plugin_try_windowless (NPP instance) { PRBool b = PR_FALSE; /* Check if the plugin can do windowless. * See http://bugzilla.mozilla.org/show_bug.cgi?id=386537 */ if (CallNPN_GetValueProc(mozilla_funcs.getvalue, instance, NPNVSupportsWindowless, (void *) &b) || b != PR_TRUE) return FALSE; /* Try making us windowless */ if (CallNPN_SetValueProc (mozilla_funcs.setvalue, instance, NPPVpluginWindowBool, (void *) PR_FALSE)) return FALSE; return TRUE; }
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value) { NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value); return rv; }
gboolean plugin_get_value (NPP instance, NPNVariable var, gpointer data) { return CallNPN_GetValueProc(mozilla_funcs.getvalue, instance, var, data) == NPERR_NO_ERROR; }
static NPError plugin_new (NPMIMEType mime_type, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData * saved) { SwfdecPlayer *player; int i; gboolean windowless = FALSE, opaque = FALSE; NPNToolkitType toolkit = 0; if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; /* we must be GTK 2 */ if (CallNPN_GetValueProc(mozilla_funcs.getvalue, instance, NPNVToolkit, (void *) &toolkit) || toolkit != NPNVGtk2) return NPERR_INCOMPATIBLE_VERSION_ERROR; if (!swfdec_mozilla_make_sure_this_thing_stays_in_memory ()) { g_printerr ("Ensuring the plugin stays in memory did not work.\n" "This happens when the plugin was copied from its installed location at " PLUGIN_FILE ".\n" "Please use the --with-plugin-dir configure option to install it into a different place.\n"); return NPERR_INVALID_INSTANCE_ERROR; } /* Init functioncalling (even g_type_init) gets postponed until we know we * won't be unloaded, i.e. NPPVpluginKeepLibraryInMemory was successful */ swfdec_init (); #ifndef DISABLE_WINDOWLESS /* parse pre-creation properties */ for (i = 0; i < argc; i++) { if (g_ascii_strcasecmp (argn[i], "wmode") == 0) { if (g_ascii_strcasecmp (argv[i], "transparent") == 0) { windowless = plugin_try_windowless (instance); opaque = FALSE; } else if (g_ascii_strcasecmp (argv[i], "opaque") == 0) { windowless = plugin_try_windowless (instance); if (windowless) { CallNPN_SetValueProc (mozilla_funcs.setvalue, instance, NPPVpluginTransparentBool, (void *) PR_FALSE); opaque = TRUE; } } } } #endif instance->pdata = player = swfmoz_player_new (instance, windowless, opaque); /* set the properties we support */ /* FIXME: figure out how variables override each other */ for (i = 0; i < argc; i++) { if (argn[i] == NULL) continue; if (g_ascii_strcasecmp (argn[i], "flashvars") == 0) { if (argv[i]) swfdec_player_set_variables (player, argv[i]); } else if (g_ascii_strcasecmp (argn[i], "scale") == 0) { SwfdecScaleMode scale; if (g_ascii_strcasecmp (argv[i], "noborder") == 0) { scale = SWFDEC_SCALE_NO_BORDER; } else if (g_ascii_strcasecmp (argv[i], "exactfit") == 0) { scale = SWFDEC_SCALE_EXACT_FIT; } else if (g_ascii_strcasecmp (argv[i], "noscale") == 0) { scale = SWFDEC_SCALE_NONE; } else { scale = SWFDEC_SCALE_SHOW_ALL; } swfdec_player_set_scale_mode (player, scale); } else if (g_ascii_strcasecmp (argn[i], "salign") == 0) { struct { const char * name; SwfdecAlignment align; } possibilities[] = { { "t", SWFDEC_ALIGNMENT_TOP }, { "l", SWFDEC_ALIGNMENT_LEFT }, { "r", SWFDEC_ALIGNMENT_RIGHT }, { "b", SWFDEC_ALIGNMENT_BOTTOM }, { "tl", SWFDEC_ALIGNMENT_TOP_LEFT }, { "tr", SWFDEC_ALIGNMENT_TOP_RIGHT }, { "bl", SWFDEC_ALIGNMENT_BOTTOM_LEFT }, { "br", SWFDEC_ALIGNMENT_BOTTOM_RIGHT } }; SwfdecAlignment align = SWFDEC_ALIGNMENT_CENTER; guint j; for (j = 0; j < G_N_ELEMENTS (possibilities); j++) { if (g_ascii_strcasecmp (argv[i], possibilities[j].name) == 0) { align = possibilities[j].align; break; } } swfdec_player_set_alignment (player, align); } } return NPERR_NO_ERROR; }
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value) { return CallNPN_GetValueProc(gNPNFuncs.getvalue, instance, variable, value); }