1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804 |
- g_print ("GCJ PLUGIN: thread %p: %s\n", g_thread_self (), message)
- g_print ("GCJ PLUGIN: thread %p: %s %s\n", g_thread_self (), \
- first, second)
- g_printerr ("%s:%d: thread %p: Error: %s\n", __FILE__, __LINE__, \
- g_thread_self (), message)
- g_printerr ("%s:%d: thread %p: Error: %s: %s\n", __FILE__, __LINE__, \
- g_thread_self (), first, second)
- g_printerr ("%s:%d: thread %p: Error: %s: %s: %s\n", __FILE__, \
- __LINE__, g_thread_self (), first, second, third)
- "application/x-java-vm:class,jar:GCJ;" \
- "application/x-java-applet:class,jar:GCJ;" \
- "application/x-java-applet;version=1.1:class,jar:GCJ;" \
- "application/x-java-applet;version=1.1.1:class,jar:GCJ;" \
- "application/x-java-applet;version=1.1.2:class,jar:GCJ;" \
- "application/x-java-applet;version=1.1.3:class,jar:GCJ;" \
- "application/x-java-applet;version=1.2:class,jar:GCJ;" \
- "application/x-java-applet;version=1.2.1:class,jar:GCJ;" \
- "application/x-java-applet;version=1.2.2:class,jar:GCJ;" \
- "application/x-java-applet;version=1.3:class,jar:GCJ;" \
- "application/x-java-applet;version=1.3.1:class,jar:GCJ;" \
- "application/x-java-applet;version=1.4:class,jar:GCJ;" \
- "application/x-java-applet;version=1.4.1:class,jar:GCJ;" \
- "application/x-java-applet;version=1.4.2:class,jar:GCJ;" \
- "application/x-java-applet;jpi-version=1.4.2_01:class,jar:GCJ;" \
- "application/x-java-bean:class,jar:GCJ;" \
- "application/x-java-bean;version=1.1:class,jar:GCJ;" \
- "application/x-java-bean;version=1.1.1:class,jar:GCJ;" \
- "application/x-java-bean;version=1.1.2:class,jar:GCJ;" \
- "application/x-java-bean;version=1.1.3:class,jar:GCJ;" \
- "application/x-java-bean;version=1.2:class,jar:GCJ;" \
- "application/x-java-bean;version=1.2.1:class,jar:GCJ;" \
- "application/x-java-bean;version=1.2.2:class,jar:GCJ;" \
- "application/x-java-bean;version=1.3:class,jar:GCJ;" \
- "application/x-java-bean;version=1.3.1:class,jar:GCJ;" \
- "application/x-java-bean;version=1.4:class,jar:GCJ;" \
- "application/x-java-bean;version=1.4.1:class,jar:GCJ;" \
- "application/x-java-bean;version=1.4.2:class,jar:GCJ;" \
- "application/x-java-bean;jpi-version=1.4.2_01:class,jar:GCJ;"
- "%s wants to load an applet.\n" \
- "GNU Classpath's security implementation is not complete.\n" \
- "HOSTILE APPLETS WILL STEAL AND/OR DESTROY YOUR DATA!\n"
- "Click \"Cancel\" if you do not trust the source of this applet.\n" \
- "Click \"Trust Applet\" to load and run this applet now.\n" \
- "Click \"Trust Applet and Add To Whitelist\" to always load" \
- " and run this applet from now on, without asking.\n" \
- "The whitelist is a list of the URLs from which you trust" \
- " applets.\n" \
- "Your whitelist file is \" %s \"."
- "This page wants to load an applet.\n" \
- "The appletviewer is missing or not installed properly in \"" \
- APPLETVIEWER_EXECUTABLE "\"."
- static NS_DEFINE_IID (kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
- static NPNetscapeFuncs browserFunctions;
- static gchar* data_directory;
- static gchar* whitelist_filename;
- gboolean initialized = false;
- struct GCJPluginData
- {
-
- gchar* instance_string;
-
- gchar* in_pipe_name;
-
- GIOChannel* in_from_appletviewer;
-
- gint in_watch_source;
-
- gchar* out_pipe_name;
-
- GIOChannel* out_to_appletviewer;
-
- gint out_watch_source;
-
- GMutex* appletviewer_mutex;
-
-
- NPP owner;
-
-
-
- gboolean appletviewer_alive;
-
-
- gpointer window_handle;
-
- guint32 window_width;
-
- guint32 window_height;
- };
- typedef union
- {
- void** void_field;
- nsIPluginTagInfo2** info_field;
- } info_union;
- static void plugin_data_new (GCJPluginData** data);
- static gchar* plugin_get_documentbase (NPP instance);
- static bool plugin_failed ();
- static bool plugin_user_trusts_documentbase (char* documentbase);
- static bool plugin_ask_user_about_documentbase (char* documentbase);
- static void plugin_add_documentbase_to_whitelist (char* documentbase);
- static gboolean plugin_in_pipe_callback (GIOChannel* source,
- GIOCondition condition,
- gpointer plugin_data);
- static gboolean plugin_out_pipe_callback (GIOChannel* source,
- GIOCondition condition,
- gpointer plugin_data);
- static NPError plugin_start_appletviewer (GCJPluginData* data);
- static gchar* plugin_create_applet_tag (int16 argc, char* argn[],
- char* argv[]);
- static void plugin_send_message_to_appletviewer (GCJPluginData* data,
- gchar const* message);
- static void plugin_stop_appletviewer (GCJPluginData* data);
- static void plugin_data_destroy (GCJPluginData** data);
- static GMutex* plugin_instance_mutex = NULL;
- static gulong plugin_instance_counter = 0;
- static GIOChannel* whitelist_file = NULL;
- static GError* channel_error = NULL;
- NPError
- GCJ_New (NPMIMEType pluginType, NPP instance, uint16 mode,
- int16 argc, char* argn[], char* argv[],
- NPSavedData* saved)
- {
- PLUGIN_DEBUG ("GCJ_New");
- NPError np_error = NPERR_NO_ERROR;
- GCJPluginData* data = NULL;
- gchar* documentbase = NULL;
- gchar* read_message = NULL;
- gchar* applet_tag = NULL;
- gchar* tag_message = NULL;
- if (!instance)
- {
- PLUGIN_ERROR ("Browser-provided instance pointer is NULL.");
- np_error = NPERR_INVALID_INSTANCE_ERROR;
- goto cleanup_done;
- }
-
- plugin_data_new (&data);
- if (data == NULL)
- {
- PLUGIN_ERROR ("Failed to allocate plugin data.");
- np_error = NPERR_OUT_OF_MEMORY_ERROR;
- goto cleanup_done;
- }
-
-
-
-
-
-
-
- g_mutex_lock (plugin_instance_mutex);
-
- data->instance_string = g_strdup_printf ("instance-%d-%ld",
- getpid (),
- plugin_instance_counter++);
- g_mutex_unlock (plugin_instance_mutex);
-
- data->appletviewer_mutex = g_mutex_new ();
-
- documentbase = plugin_get_documentbase (instance);
- if (!documentbase)
- {
- PLUGIN_ERROR ("Documentbase retrieval failed."
- " Browser not Mozilla-based?");
- goto cleanup_appletviewer_mutex;
- }
-
-
- whitelist_file = g_io_channel_new_file (whitelist_filename,
- "a+", &channel_error);
- if (!whitelist_file)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_THREE ("Failed to open whitelist file",
- whitelist_filename,
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR_TWO ("Failed to open whitelist file",
- whitelist_filename);
- return NPERR_GENERIC_ERROR;
- }
-
- if (!plugin_user_trusts_documentbase (documentbase))
- {
- PLUGIN_ERROR ("User does not trust applet.");
- np_error = NPERR_GENERIC_ERROR;
- goto cleanup_appletviewer_mutex;
- }
-
-
-
-
- data->in_pipe_name = g_strdup_printf ("%s/gcj-%s-appletviewer-to-plugin",
- data_directory, data->instance_string);
- if (!data->in_pipe_name)
- {
- PLUGIN_ERROR ("Failed to create input pipe name.");
- np_error = NPERR_OUT_OF_MEMORY_ERROR;
-
-
- goto cleanup_in_pipe_name;
- }
- if (mkfifo (data->in_pipe_name, 0700) == -1 && errno != EEXIST)
- {
- PLUGIN_ERROR_TWO ("Failed to create input pipe", strerror (errno));
- np_error = NPERR_GENERIC_ERROR;
- goto cleanup_in_pipe_name;
- }
-
-
-
- data->out_pipe_name = g_strdup_printf ("%s/gcj-%s-plugin-to-appletviewer",
- data_directory, data->instance_string);
- if (!data->out_pipe_name)
- {
- PLUGIN_ERROR ("Failed to create output pipe name.");
- np_error = NPERR_OUT_OF_MEMORY_ERROR;
- goto cleanup_out_pipe_name;
- }
- if (mkfifo (data->out_pipe_name, 0700) == -1 && errno != EEXIST)
- {
- PLUGIN_ERROR_TWO ("Failed to create output pipe", strerror (errno));
- np_error = NPERR_GENERIC_ERROR;
- goto cleanup_out_pipe_name;
- }
-
-
-
-
-
-
-
- g_mutex_lock (data->appletviewer_mutex);
-
- np_error = plugin_start_appletviewer (data);
-
-
-
- if (np_error != NPERR_NO_ERROR)
- {
- if (plugin_failed ())
- goto cleanup_applet_failure;
- }
-
-
-
-
- data->out_to_appletviewer = g_io_channel_new_file (data->out_pipe_name,
- "w", &channel_error);
- if (!data->out_to_appletviewer)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to create output channel",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to create output channel");
-
- np_error = NPERR_GENERIC_ERROR;
- goto cleanup_out_to_appletviewer;
- }
-
- data->out_watch_source =
- g_io_add_watch (data->out_to_appletviewer,
- (GIOCondition) (G_IO_ERR | G_IO_HUP),
- plugin_out_pipe_callback, (gpointer) data);
-
-
-
- data->in_from_appletviewer = g_io_channel_new_file (data->in_pipe_name,
- "r", &channel_error);
- if (!data->in_from_appletviewer)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to create input channel",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to create input channel");
-
- np_error = NPERR_GENERIC_ERROR;
- goto cleanup_in_from_appletviewer;
- }
-
- data->in_watch_source =
- g_io_add_watch (data->in_from_appletviewer,
- (GIOCondition) (G_IO_IN | G_IO_ERR | G_IO_HUP),
- plugin_in_pipe_callback, (gpointer) data);
-
-
- if (g_io_channel_read_line (data->in_from_appletviewer,
- &read_message, NULL, NULL,
- &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Receiving confirmation from appletviewer failed",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Receiving confirmation from appletviewer failed");
-
- np_error = NPERR_GENERIC_ERROR;
- goto cleanup_in_watch_source;
- }
- PLUGIN_DEBUG ("GCJ_New: got confirmation that appletviewer is running.");
- data->appletviewer_alive = TRUE;
-
- applet_tag = plugin_create_applet_tag (argc, argn, argv);
- tag_message = g_strconcat ("tag ", documentbase, " ", applet_tag, NULL);
- plugin_send_message_to_appletviewer (data, data->instance_string);
- plugin_send_message_to_appletviewer (data, tag_message);
- g_mutex_unlock (data->appletviewer_mutex);
-
-
-
-
- data->owner = instance;
- instance->pdata = data;
- goto cleanup_done;
-
-
- cleanup_in_watch_source:
-
-
- g_source_remove (data->in_watch_source);
- data->in_watch_source = 0;
- cleanup_in_from_appletviewer:
- if (data->in_from_appletviewer)
- g_io_channel_unref (data->in_from_appletviewer);
- data->in_from_appletviewer = NULL;
-
- g_source_remove (data->out_watch_source);
- data->out_watch_source = 0;
- cleanup_out_to_appletviewer:
- if (data->out_to_appletviewer)
- g_io_channel_unref (data->out_to_appletviewer);
- data->out_to_appletviewer = NULL;
-
-
- unlink (data->out_pipe_name);
-
- cleanup_applet_failure:
- cleanup_out_pipe_name:
- g_free (data->out_pipe_name);
- data->out_pipe_name = NULL;
-
-
- unlink (data->in_pipe_name);
- cleanup_in_pipe_name:
- g_free (data->in_pipe_name);
- data->in_pipe_name = NULL;
- cleanup_appletviewer_mutex:
- g_free (data->appletviewer_mutex);
- data->appletviewer_mutex = NULL;
-
- g_free (data->instance_string);
- data->instance_string = NULL;
-
-
- data->owner = NULL;
- (*browserFunctions.memfree) (data);
- data = NULL;
-
-
- instance->pdata = NULL;
- cleanup_done:
- g_free (tag_message);
- tag_message = NULL;
- g_free (applet_tag);
- applet_tag = NULL;
- g_free (read_message);
- read_message = NULL;
- g_free (documentbase);
- documentbase = NULL;
- PLUGIN_DEBUG ("GCJ_New return");
- return np_error;
- }
- NPError
- GCJ_GetValue (NPP instance, NPPVariable variable, void* value)
- {
- PLUGIN_DEBUG ("GCJ_GetValue");
- NPError np_error = NPERR_NO_ERROR;
- switch (variable)
- {
-
- case NPPVpluginNeedsXEmbed:
- {
- PLUGIN_DEBUG ("GCJ_GetValue: returning TRUE for NeedsXEmbed.");
- PRBool* bool_value = (PRBool*) value;
- *bool_value = PR_TRUE;
- }
- break;
- default:
- PLUGIN_ERROR ("Unknown plugin value requested.");
- np_error = NPERR_GENERIC_ERROR;
- break;
- }
- PLUGIN_DEBUG ("GCJ_GetValue return");
- return np_error;
- }
- NPError
- GCJ_Destroy (NPP instance, NPSavedData** save)
- {
- PLUGIN_DEBUG ("GCJ_Destroy");
- GCJPluginData* data = (GCJPluginData*) instance->pdata;
- if (data)
- {
-
- g_mutex_lock (data->appletviewer_mutex);
-
- plugin_send_message_to_appletviewer (data, "destroy");
-
- plugin_stop_appletviewer (data);
- g_mutex_unlock (data->appletviewer_mutex);
-
- plugin_data_destroy (&data);
- }
- PLUGIN_DEBUG ("GCJ_Destroy return");
- return NPERR_NO_ERROR;
- }
- NPError
- GCJ_SetWindow (NPP instance, NPWindow* window)
- {
- PLUGIN_DEBUG ("GCJ_SetWindow");
- if (instance == NULL)
- {
- PLUGIN_ERROR ("Invalid instance.");
- return NPERR_INVALID_INSTANCE_ERROR;
- }
- GCJPluginData* data = (GCJPluginData*) instance->pdata;
-
- if ((window == NULL) || (window->window == NULL))
- {
- PLUGIN_DEBUG ("GCJ_SetWindow: got NULL window.");
- return NPERR_NO_ERROR;
- }
- if (data->window_handle)
- {
-
- if (data->window_handle == window->window)
- {
-
- PLUGIN_DEBUG ("GCJ_SetWindow: window already exists.");
-
-
- g_mutex_lock (data->appletviewer_mutex);
- if (data->appletviewer_alive)
- {
-
-
- if (window->width != data->window_width)
- {
- PLUGIN_DEBUG ("GCJ_SetWindow: window width changed.");
-
-
- plugin_send_message_to_appletviewer (data,
- data->instance_string);
- gchar* width_message = g_strdup_printf ("width %d",
- window->width);
- plugin_send_message_to_appletviewer (data, width_message);
- g_free (width_message);
- width_message = NULL;
-
- data->window_width = window->width;
- }
- if (window->height != data->window_height)
- {
- PLUGIN_DEBUG ("GCJ_SetWindow: window height changed.");
-
-
- plugin_send_message_to_appletviewer (data,
- data->instance_string);
- gchar* height_message = g_strdup_printf ("height %d",
- window->height);
- plugin_send_message_to_appletviewer (data, height_message);
- g_free (height_message);
- height_message = NULL;
-
- data->window_height = window->height;
- }
- }
- else
- {
-
- PLUGIN_DEBUG ("GCJ_SetWindow: appletviewer is not running.");
- }
- g_mutex_unlock (data->appletviewer_mutex);
- }
- else
- {
-
-
- PLUGIN_DEBUG ("GCJ_SetWindow: parent window changed.");
- }
- }
- else
- {
- PLUGIN_DEBUG ("GCJ_SetWindow: setting window.");
-
- g_mutex_lock (data->appletviewer_mutex);
- plugin_send_message_to_appletviewer (data, data->instance_string);
- gchar *window_message = g_strdup_printf ("handle %ld",
- (gulong) window->window);
- plugin_send_message_to_appletviewer (data, window_message);
- g_free (window_message);
- window_message = NULL;
- g_mutex_unlock (data->appletviewer_mutex);
-
- data->window_handle = window->window;
- }
- PLUGIN_DEBUG ("GCJ_SetWindow return");
- return NPERR_NO_ERROR;
- }
- NPError
- GCJ_NewStream (NPP instance, NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stype)
- {
- PLUGIN_DEBUG ("GCJ_NewStream");
- PLUGIN_DEBUG ("GCJ_NewStream return");
- return NPERR_NO_ERROR;
- }
- void
- GCJ_StreamAsFile (NPP instance, NPStream* stream, const char* filename)
- {
- PLUGIN_DEBUG ("GCJ_StreamAsFile");
- PLUGIN_DEBUG ("GCJ_StreamAsFile return");
- }
- NPError
- GCJ_DestroyStream (NPP instance, NPStream* stream, NPReason reason)
- {
- PLUGIN_DEBUG ("GCJ_DestroyStream");
- PLUGIN_DEBUG ("GCJ_DestroyStream return");
- return NPERR_NO_ERROR;
- }
- int32
- GCJ_WriteReady (NPP instance, NPStream* stream)
- {
- PLUGIN_DEBUG ("GCJ_WriteReady");
- PLUGIN_DEBUG ("GCJ_WriteReady return");
- return 0;
- }
- int32
- GCJ_Write (NPP instance, NPStream* stream, int32 offset, int32 len,
- void* buffer)
- {
- PLUGIN_DEBUG ("GCJ_Write");
- PLUGIN_DEBUG ("GCJ_Write return");
- return 0;
- }
- void
- GCJ_Print (NPP instance, NPPrint* platformPrint)
- {
- PLUGIN_DEBUG ("GCJ_Print");
- PLUGIN_DEBUG ("GCJ_Print return");
- }
- int16
- GCJ_HandleEvent (NPP instance, void* event)
- {
- PLUGIN_DEBUG ("GCJ_HandleEvent");
- PLUGIN_DEBUG ("GCJ_HandleEvent return");
- return 0;
- }
- void
- GCJ_URLNotify (NPP instance, const char* url, NPReason reason,
- void* notifyData)
- {
- PLUGIN_DEBUG ("GCJ_URLNotify");
- PLUGIN_DEBUG ("GCJ_URLNotify return");
- }
- jref
- void*
- GCJ_GetJavaClass (void)
- {
- PLUGIN_DEBUG ("GCJ_GetJavaClass");
- PLUGIN_DEBUG ("GCJ_GetJavaClass return");
- return 0;
- }
- static void
- plugin_data_new (GCJPluginData** data)
- {
- PLUGIN_DEBUG ("plugin_data_new");
- *data = (GCJPluginData*)
- (*browserFunctions.memalloc) (sizeof (struct GCJPluginData));
-
- if (*data)
- memset (*data, 0, sizeof (struct GCJPluginData));
- PLUGIN_DEBUG ("plugin_data_new return");
- }
- static gchar*
- plugin_get_documentbase (NPP instance)
- {
- PLUGIN_DEBUG ("plugin_get_documentbase");
- nsIPluginInstance* xpcom_instance = NULL;
- nsIPluginInstancePeer* peer = NULL;
- nsresult result = 0;
- nsIPluginTagInfo2* pluginTagInfo2 = NULL;
- info_union u = { NULL };
- char const* documentbase = NULL;
- gchar* documentbase_copy = NULL;
- xpcom_instance = (nsIPluginInstance*) (instance->ndata);
- if (!xpcom_instance)
- {
- PLUGIN_ERROR ("xpcom_instance is NULL.");
- goto cleanup_done;
- }
- xpcom_instance->GetPeer (&peer);
- if (!peer)
- {
- PLUGIN_ERROR ("peer is NULL.");
- goto cleanup_done;
- }
- u.info_field = &pluginTagInfo2;
- result = peer->QueryInterface (kIPluginTagInfo2IID,
- u.void_field);
- if (result || !pluginTagInfo2)
- {
- PLUGIN_ERROR ("pluginTagInfo2 retrieval failed.");
- goto cleanup_peer;
- }
- pluginTagInfo2->GetDocumentBase (&documentbase);
- if (!documentbase)
- {
- PLUGIN_ERROR ("documentbase is NULL.");
- goto cleanup_plugintaginfo2;
- }
- documentbase_copy = g_strdup (documentbase);
-
- cleanup_plugintaginfo2:
- NS_RELEASE (pluginTagInfo2);
- cleanup_peer:
- NS_RELEASE (peer);
- cleanup_done:
- PLUGIN_DEBUG ("plugin_get_documentbase return");
- return documentbase_copy;
- }
- static bool
- plugin_failed ()
- {
- GtkWidget* dialog = NULL;
- GtkWidget* ok_button = NULL;
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- FAILURE_MESSAGE);
- ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_OK,
- GTK_RESPONSE_OK);
- gtk_widget_show_all (dialog);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- gtk_widget_destroy (dialog);
- return true;
- }
- return false;
- }
- static bool
- plugin_user_trusts_documentbase (char* documentbase)
- {
- bool applet_in_whitelist = false;
-
- while (true)
- {
- gchar* whitelist_entry = NULL;
- gchar* newline_documentbase = NULL;
-
-
- if (g_io_channel_read_line (whitelist_file, &whitelist_entry,
- NULL, NULL, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to read line from whitelist file",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to read line from whitelist file.");
- g_free (whitelist_entry);
- whitelist_entry = NULL;
- break;
- }
- newline_documentbase = g_strdup_printf ("%s\n", documentbase);
- if (!strcmp (newline_documentbase, whitelist_entry))
- {
- applet_in_whitelist = true;
- g_free (newline_documentbase);
- newline_documentbase = NULL;
- g_free (whitelist_entry);
- whitelist_entry = NULL;
- break;
- }
- g_free (whitelist_entry);
- whitelist_entry = NULL;
- g_free (newline_documentbase);
- newline_documentbase = NULL;
- }
- return applet_in_whitelist ? true
- : plugin_ask_user_about_documentbase (documentbase);
- }
- static void
- plugin_add_documentbase_to_whitelist (char* documentbase)
- {
- gsize bytes_written = 0;
- char* newline_documentbase = NULL;
- GIOStatus status = G_IO_STATUS_NORMAL;
- newline_documentbase = g_strdup_printf ("%s\n", documentbase);
- status = g_io_channel_write_chars (whitelist_file,
- newline_documentbase, -1, &bytes_written,
- &channel_error);
- g_free (newline_documentbase);
- newline_documentbase = NULL;
- if (status != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Error writing to whitelist file",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Error writing to whitelist file.");
- }
- if (g_io_channel_flush (whitelist_file, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to write whitelist file",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to write whitelist file.");
- }
- if (g_io_channel_shutdown (whitelist_file, TRUE, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to close whitelist file",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to close whitelist file.");
- }
- }
- static bool
- plugin_ask_user_about_documentbase (char* documentbase)
- {
- GtkWidget* dialog = NULL;
- GtkWidget* ok_button = NULL;
- GtkWidget* cancel_button = NULL;
- GtkWidget* whitelist_button = NULL;
- gint dialog_response = GTK_RESPONSE_NONE;
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- SECURITY_WARNING,
- documentbase);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- SECURITY_DESCRIPTION, whitelist_filename);
- cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
- ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- RESPONSE_TRUST_APPLET,
- GTK_RESPONSE_OK);
- whitelist_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- RESPONSE_TRUST_APPLET_ADD_TO_LIST,
- GTK_RESPONSE_APPLY);
- gtk_widget_grab_focus (cancel_button);
- gtk_widget_show_all (dialog);
- dialog_response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (dialog_response == GTK_RESPONSE_CANCEL)
- {
-
- return false;
- }
- else if (dialog_response == GTK_RESPONSE_APPLY)
- {
-
-
- plugin_add_documentbase_to_whitelist (documentbase);
- }
-
- return true;
- }
- static gboolean
- plugin_in_pipe_callback (GIOChannel* source,
- GIOCondition condition,
- gpointer plugin_data)
- {
- PLUGIN_DEBUG ("plugin_in_pipe_callback");
- GCJPluginData* data = (GCJPluginData*) plugin_data;
- gboolean keep_installed = TRUE;
-
-
-
-
- if (data)
- {
-
- g_mutex_lock (data->appletviewer_mutex);
- if (condition & G_IO_IN)
- {
- gchar* message = NULL;
- if (g_io_channel_read_line (data->in_from_appletviewer,
- &message, NULL, NULL,
- &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to read line from input channel",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to read line from input channel");
- }
- else
- {
- if (g_str_has_prefix (message, "url "))
- {
- gchar** parts = g_strsplit (message, " ", 3);
- PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
- " opening URL", parts[1]);
- PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
- " URL target", parts[2]);
-
- NPError np_error =
- (*browserFunctions.geturl) (data->owner, parts[1], parts[2]);
- if (np_error != NPERR_NO_ERROR)
- PLUGIN_ERROR ("Failed to load URL.");
- g_strfreev (parts);
- parts = NULL;
- }
- else if (g_str_has_prefix (message, "status "))
- {
- gchar** parts = g_strsplit (message, " ", 2);
- PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
- " setting status", parts[1]);
- (*browserFunctions.status) (data->owner, parts[1]);
- g_strfreev (parts);
- parts = NULL;
- }
- g_print (" PIPE: plugin read %s\n", message);
- }
- g_free (message);
- message = NULL;
- keep_installed = TRUE;
- }
- if (condition & (G_IO_ERR | G_IO_HUP))
- {
- PLUGIN_DEBUG ("appletviewer has stopped.");
- data->appletviewer_alive = FALSE;
- keep_installed = FALSE;
- }
- g_mutex_unlock (data->appletviewer_mutex);
- }
- PLUGIN_DEBUG ("plugin_in_pipe_callback return");
- return keep_installed;
- }
- static gboolean
- plugin_out_pipe_callback (GIOChannel* source,
- GIOCondition condition,
- gpointer plugin_data)
- {
- PLUGIN_DEBUG ("plugin_out_pipe_callback");
- GCJPluginData* data = (GCJPluginData*) plugin_data;
-
-
-
-
- if (data)
- {
-
- g_mutex_lock (data->appletviewer_mutex);
- PLUGIN_DEBUG ("plugin_out_pipe_callback: appletviewer has stopped.");
- data->appletviewer_alive = FALSE;
- g_mutex_unlock (data->appletviewer_mutex);
- }
- PLUGIN_DEBUG ("plugin_out_pipe_callback return");
- return FALSE;
- }
- static NPError
- plugin_start_appletviewer (GCJPluginData* data)
- {
- PLUGIN_DEBUG ("plugin_start_appletviewer");
- NPError error = NPERR_NO_ERROR;
-
- if (!data->appletviewer_alive)
- {
- gchar* command_line[3] = { NULL, NULL, NULL };
- command_line[0] = g_strdup (APPLETVIEWER_EXECUTABLE);
-
-
- command_line[1] = g_strdup_printf ("--plugin=%s,%s",
- data->out_pipe_name,
- data->in_pipe_name);
- command_line[2] = NULL;
- if (!g_spawn_async (NULL, command_line, NULL, (GSpawnFlags) 0,
- NULL, NULL, NULL, &channel_error))
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to spawn applet viewer",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to spawn applet viewer");
- error = NPERR_GENERIC_ERROR;
- goto cleanup;
- }
- cleanup:
- g_free (command_line[0]);
- command_line[0] = NULL;
- g_free (command_line[1]);
- command_line[1] = NULL;
- g_free (command_line[2]);
- command_line[2] = NULL;
- }
- PLUGIN_DEBUG ("plugin_start_appletviewer return");
- return error;
- }
- static gchar*
- plugin_create_applet_tag (int16 argc, char* argn[], char* argv[])
- {
- PLUGIN_DEBUG ("plugin_create_applet_tag");
- gchar* applet_tag = g_strdup ("<EMBED ");
- gchar* parameters = g_strdup ("");
- for (int16 i = 0; i < argc; i++)
- {
- if (!g_ascii_strcasecmp (argn[i], "code"))
- {
- gchar* code = g_strdup_printf ("CODE=\"%s\" ", argv[i]);
- applet_tag = g_strconcat (applet_tag, code, NULL);
- g_free (code);
- code = NULL;
- }
- else if (!g_ascii_strcasecmp (argn[i], "codebase"))
- {
- gchar* codebase = g_strdup_printf ("CODEBASE=\"%s\" ", argv[i]);
- applet_tag = g_strconcat (applet_tag, codebase, NULL);
- g_free (codebase);
- codebase = NULL;
- }
- else if (!g_ascii_strcasecmp (argn[i], "archive"))
- {
- gchar* archive = g_strdup_printf ("ARCHIVE=\"%s\" ", argv[i]);
- applet_tag = g_strconcat (applet_tag, archive, NULL);
- g_free (archive);
- archive = NULL;
- }
- else if (!g_ascii_strcasecmp (argn[i], "width"))
- {
- gchar* width = g_strdup_printf ("WIDTH=\"%s\" ", argv[i]);
- applet_tag = g_strconcat (applet_tag, width, NULL);
- g_free (width);
- width = NULL;
- }
- else if (!g_ascii_strcasecmp (argn[i], "height"))
- {
- gchar* height = g_strdup_printf ("HEIGHT=\"%s\" ", argv[i]);
- applet_tag = g_strconcat (applet_tag, height, NULL);
- g_free (height);
- height = NULL;
- }
- else
- {
-
-
- if (argv[i] != '\0')
- {
- gchar* escaped = NULL;
- escaped = g_strescape (argv[i], NULL);
- parameters = g_strconcat (parameters, "<PARAM NAME=\"", argn[i],
- "\" VALUE=\"", escaped, "\">", NULL);
- g_free (escaped);
- escaped = NULL;
- }
- }
- }
- applet_tag = g_strconcat (applet_tag, ">", parameters, "</EMBED>", NULL);
- g_free (parameters);
- parameters = NULL;
- PLUGIN_DEBUG ("plugin_create_applet_tag return");
- return applet_tag;
- }
- static void
- plugin_send_message_to_appletviewer (GCJPluginData* data, gchar const* message)
- {
- PLUGIN_DEBUG ("plugin_send_message_to_appletviewer");
- if (data->appletviewer_alive)
- {
- gchar* newline_message = NULL;
- gsize bytes_written = 0;
-
- newline_message = g_strdup_printf ("%s\n", message);
-
-
-
- if (g_io_channel_write_chars (data->out_to_appletviewer,
- newline_message, -1, &bytes_written,
- &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to write bytes to output channel",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to write bytes to output channel");
- }
- if (g_io_channel_flush (data->out_to_appletviewer, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to flush bytes to output channel",
- channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to flush bytes to output channel");
- }
- g_free (newline_message);
- newline_message = NULL;
- g_print (" PIPE: plugin wrote %s\n", message);
- }
- PLUGIN_DEBUG ("plugin_send_message_to_appletviewer return");
- }
- static void
- plugin_stop_appletviewer (GCJPluginData* data)
- {
- PLUGIN_DEBUG ("plugin_stop_appletviewer");
- if (data->appletviewer_alive)
- {
-
- gsize bytes_written = 0;
- if (data->out_to_appletviewer)
- {
- if (g_io_channel_write_chars (data->out_to_appletviewer, "shutdown",
- -1, &bytes_written, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
- " appletviewer", channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to write shutdown message to");
- }
- if (g_io_channel_flush (data->out_to_appletviewer, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
- " appletviewer", channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to write shutdown message to");
- }
- if (g_io_channel_shutdown (data->out_to_appletviewer,
- TRUE, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
- " output channel", channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to shut down appletviewer");
- }
- }
- if (data->in_from_appletviewer)
- {
- if (g_io_channel_shutdown (data->in_from_appletviewer,
- TRUE, &channel_error)
- != G_IO_STATUS_NORMAL)
- {
- if (channel_error)
- {
- PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
- " input channel", channel_error->message);
- g_error_free (channel_error);
- channel_error = NULL;
- }
- else
- PLUGIN_ERROR ("Failed to shut down appletviewer");
- }
- }
- }
- PLUGIN_DEBUG ("plugin_stop_appletviewer return");
- }
- static void
- plugin_data_destroy (GCJPluginData** data)
- {
- PLUGIN_DEBUG ("plugin_data_destroy");
- GCJPluginData* tofree = *data;
- tofree->window_handle = NULL;
- tofree->window_height = 0;
- tofree->window_width = 0;
-
-
-
-
- g_source_remove (tofree->in_watch_source);
- tofree->in_watch_source = 0;
-
- if (tofree->in_from_appletviewer)
- g_io_channel_unref (tofree->in_from_appletviewer);
- tofree->in_from_appletviewer = NULL;
-
- g_source_remove (tofree->out_watch_source);
- tofree->out_watch_source = 0;
-
- if (tofree->out_to_appletviewer)
- g_io_channel_unref (tofree->out_to_appletviewer);
- tofree->out_to_appletviewer = NULL;
-
-
- unlink (tofree->out_pipe_name);
-
- g_free (tofree->out_pipe_name);
- tofree->out_pipe_name = NULL;
-
-
- unlink (tofree->in_pipe_name);
-
- g_free (tofree->in_pipe_name);
- tofree->in_pipe_name = NULL;
-
- g_free (tofree->appletviewer_mutex);
- tofree->appletviewer_mutex = NULL;
-
- g_free (tofree->instance_string);
- tofree->instance_string = NULL;
-
-
- tofree->owner = NULL;
- (*browserFunctions.memfree) (tofree);
- tofree = NULL;
- PLUGIN_DEBUG ("plugin_data_destroy return");
- }
- NPError
- NP_Initialize (NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
- {
- PLUGIN_DEBUG ("NP_Initialize");
-
- if (initialized)
- return NPERR_NO_ERROR;
- else if ((browserTable == NULL) || (pluginTable == NULL))
- {
- PLUGIN_ERROR ("Browser or plugin function table is NULL.");
- return NPERR_INVALID_FUNCTABLE_ERROR;
- }
-
-
-
-
- if ((browserTable->version >> 8) > NP_VERSION_MAJOR)
- {
- PLUGIN_ERROR ("Incompatible version.");
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
-
-
- if (pluginTable->size < sizeof (NPPluginFuncs))
- {
- PLUGIN_ERROR ("Invalid plugin function table.");
- return NPERR_INVALID_FUNCTABLE_ERROR;
- }
-
-
- if (browserTable->size < sizeof (NPNetscapeFuncs))
- {
- PLUGIN_ERROR ("Invalid browser function table.");
- return NPERR_INVALID_FUNCTABLE_ERROR;
- }
- data_directory = g_strconcat(getenv("HOME"), "/.gcjwebplugin", NULL);
- whitelist_filename = g_strconcat (data_directory, "/whitelist.txt", NULL);
-
-
- if (!g_file_test (data_directory,
- (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
- {
- int file_error = 0;
- file_error = g_mkdir (data_directory, 0700);
- if (file_error != 0)
- {
- PLUGIN_ERROR_THREE ("Failed to create data directory",
- data_directory,
- strerror (errno));
- return NPERR_GENERIC_ERROR;
- }
- }
-
- browserFunctions.version = browserTable->version;
- browserFunctions.size = browserTable->size;
- browserFunctions.posturl = browserTable->posturl;
- browserFunctions.geturl = browserTable->geturl;
- browserFunctions.geturlnotify = browserTable->geturlnotify;
- browserFunctions.requestread = browserTable->requestread;
- browserFunctions.newstream = browserTable->newstream;
- browserFunctions.write = browserTable->write;
- browserFunctions.destroystream = browserTable->destroystream;
- browserFunctions.status = browserTable->status;
- browserFunctions.uagent = browserTable->uagent;
- browserFunctions.memalloc = browserTable->memalloc;
- browserFunctions.memfree = browserTable->memfree;
- browserFunctions.memflush = browserTable->memflush;
- browserFunctions.reloadplugins = browserTable->reloadplugins;
- browserFunctions.getvalue = browserTable->getvalue;
-
- pluginTable->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
- pluginTable->size = sizeof (NPPluginFuncs);
- pluginTable->newp = NewNPP_NewProc (GCJ_New);
- pluginTable->destroy = NewNPP_DestroyProc (GCJ_Destroy);
- pluginTable->setwindow = NewNPP_SetWindowProc (GCJ_SetWindow);
- pluginTable->newstream = NewNPP_NewStreamProc (GCJ_NewStream);
- pluginTable->destroystream = NewNPP_DestroyStreamProc (GCJ_DestroyStream);
- pluginTable->asfile = NewNPP_StreamAsFileProc (GCJ_StreamAsFile);
- pluginTable->writeready = NewNPP_WriteReadyProc (GCJ_WriteReady);
- pluginTable->write = NewNPP_WriteProc (GCJ_Write);
- pluginTable->print = NewNPP_PrintProc (GCJ_Print);
- pluginTable->urlnotify = NewNPP_URLNotifyProc (GCJ_URLNotify);
- pluginTable->getvalue = NewNPP_GetValueProc (GCJ_GetValue);
- pluginTable->newp = (NPP_NewProcPtr) (GCJ_New);
- pluginTable->destroy = (NPP_DestroyProcPtr) (GCJ_Destroy);
- pluginTable->setwindow = (NPP_SetWindowProcPtr) (GCJ_SetWindow);
- pluginTable->newstream = (NPP_NewStreamProcPtr) (GCJ_NewStream);
- pluginTable->destroystream = (NPP_DestroyStreamProcPtr) (GCJ_DestroyStream);
- pluginTable->asfile = (NPP_StreamAsFileProcPtr) (GCJ_StreamAsFile);
- pluginTable->writeready = (NPP_WriteReadyProcPtr) (GCJ_WriteReady);
- pluginTable->write = (NPP_WriteProcPtr) (GCJ_Write);
- pluginTable->print = (NPP_PrintProcPtr) (GCJ_Print);
- pluginTable->urlnotify = (NPP_URLNotifyProcPtr) (GCJ_URLNotify);
- pluginTable->getvalue = (NPP_GetValueProcPtr) (GCJ_GetValue);
-
- initialized = true;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
- plugin_instance_mutex = g_mutex_new ();
- PLUGIN_DEBUG ("NP_Initialize: using " APPLETVIEWER_EXECUTABLE ".");
- PLUGIN_DEBUG ("NP_Initialize return");
- return NPERR_NO_ERROR;
- }
- char*
- NP_GetMIMEDescription (void)
- {
- PLUGIN_DEBUG ("NP_GetMIMEDescription");
- PLUGIN_DEBUG ("NP_GetMIMEDescription return");
- return (char*) PLUGIN_MIME_DESC;
- }
- NPError
- NP_GetValue (void* future, NPPVariable variable, void* value)
- {
- PLUGIN_DEBUG ("NP_GetValue");
- NPError result = NPERR_NO_ERROR;
- gchar** char_value = (gchar**) value;
- switch (variable)
- {
- case NPPVpluginNameString:
- PLUGIN_DEBUG ("NP_GetValue: returning plugin name.");
- *char_value = g_strdup (PLUGIN_NAME " " PACKAGE_VERSION);
- break;
- case NPPVpluginDescriptionString:
- PLUGIN_DEBUG ("NP_GetValue: returning plugin description.");
- *char_value = g_strdup (PLUGIN_DESC);
- break;
- default:
- PLUGIN_ERROR ("Unknown plugin value requested.");
- result = NPERR_GENERIC_ERROR;
- break;
- }
- PLUGIN_DEBUG ("NP_GetValue return");
- return result;
- }
- NPError
- NP_Shutdown (void)
- {
- PLUGIN_DEBUG ("NP_Shutdown");
-
- if (plugin_instance_mutex)
- {
- g_mutex_free (plugin_instance_mutex);
- plugin_instance_mutex = NULL;
- }
- if (whitelist_file)
- {
- g_io_channel_close (whitelist_file);
- whitelist_file = NULL;
- }
-
- if (data_directory)
- {
- g_free (data_directory);
- data_directory = NULL;
- }
-
- if (whitelist_filename)
- {
- g_free (whitelist_filename);
- whitelist_filename = NULL;
- }
-
- initialized = false;
-
- PLUGIN_DEBUG ("NP_Shutdown return");
- return NPERR_NO_ERROR;
- }
|