mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
implementation of the null plugin for unix
checking in on behalf of stephen mak <smak@sun.com> b=48483 r=pollmann@netscape.com a=brendan@mozilla.org
This commit is contained in:
parent
133dabf9c1
commit
2319351207
@ -341,6 +341,7 @@ modules/plugin/public/Makefile
|
||||
modules/plugin/src/Makefile
|
||||
modules/plugin/test/Makefile
|
||||
modules/plugin/SanePlugin/Makefile
|
||||
modules/plugin/default/unix/Makefile
|
||||
"
|
||||
|
||||
MAKEFILES_netwerk="
|
||||
|
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public nglsrc
|
||||
DIRS = public nglsrc default/unix
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
|
||||
|
67
modules/plugin/default/unix/Makefile.in
Normal file
67
modules/plugin/default/unix/Makefile.in
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
#MODULE = plugin
|
||||
LIBRARY_NAME = nullplugin
|
||||
#IS_COMPONENT = 1
|
||||
|
||||
CSRCS = \
|
||||
npshell.c\
|
||||
nullplugin.c\
|
||||
npunix.c\
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_PLUGIN
|
||||
|
||||
#CFLAGS += `gtk-config --cflags`
|
||||
#
|
||||
#LIBS = \
|
||||
# `gtk-config --libs`\
|
||||
# $(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif
|
||||
|
||||
install-plugin: libnullplugin.so
|
||||
$(INSTALL) libnullplugin.so $(DIST)/bin/plugins
|
||||
install:: install-plugin
|
||||
|
||||
|
371
modules/plugin/default/unix/npshell.c
Normal file
371
modules/plugin/default/unix/npshell.c
Normal file
@ -0,0 +1,371 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* npshell.c
|
||||
*
|
||||
* Netscape Client Plugin API
|
||||
* - Function that need to be implemented by plugin developers
|
||||
*
|
||||
* This file defines a "shell" plugin that plugin developers can use
|
||||
* as the basis for a real plugin. This shell just provides empty
|
||||
* implementations of all functions that the plugin can implement
|
||||
* that will be called by Netscape (the NPP_xxx methods defined in
|
||||
* npapi.h).
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* need to define these in order to avoid conflict with those
|
||||
defined in obsolete/prototypes.h (included from prtypes.h), see npapi.h */
|
||||
#define _UINT16
|
||||
#define _UINT32
|
||||
#define _INT16
|
||||
#define _INT32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "npapi.h"
|
||||
#include "nullplugin.h"
|
||||
#include "strings.h"
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Implementations of plugin API functions
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
char*
|
||||
NPP_GetMIMEDescription(void)
|
||||
{
|
||||
return(MIME_TYPES_HANDLED);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_GetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
switch (variable) {
|
||||
case NPPVpluginNameString:
|
||||
*((char **)value) = PLUGIN_NAME;
|
||||
break;
|
||||
case NPPVpluginDescriptionString:
|
||||
*((char **)value) = PLUGIN_DESCRIPTION;
|
||||
break;
|
||||
default:
|
||||
err = NPERR_GENERIC_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_Initialize(void)
|
||||
{
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
jref
|
||||
NPP_GetJavaClass()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
NPP_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_New(NPMIMEType pluginType,
|
||||
NPP instance,
|
||||
uint16 mode,
|
||||
int16 argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
instance->pdata = NPN_MemAlloc(sizeof(PluginInstance));
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This == NULL)
|
||||
{
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
memset(This, 0, sizeof(PluginInstance));
|
||||
|
||||
/* mode is NP_EMBED, NP_FULL, or NP_BACKGROUND (see npapi.h) */
|
||||
This->mode = mode;
|
||||
This->type = dupMimeType(pluginType);
|
||||
This->instance = instance;
|
||||
This->pluginsPageUrl = NULL;
|
||||
|
||||
/* Parse argument list passed to plugin instance */
|
||||
/* We are interested in these arguments
|
||||
* PLUGINSPAGE = <url>
|
||||
*/
|
||||
while (argc > 0)
|
||||
{
|
||||
argc --;
|
||||
if (argv[argc] != NULL)
|
||||
{
|
||||
if (!strcasecmp(argn[argc], "PLUGINSPAGE"))
|
||||
This->pluginsPageUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "PLUGINURL"))
|
||||
This->pluginsFileUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "CODEBASE"))
|
||||
This->pluginsPageUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "CLASSID"))
|
||||
This->pluginsFileUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "HIDDEN"))
|
||||
This->pluginsHidden = (!strcasecmp(argv[argc],
|
||||
"TRUE"));
|
||||
}
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This != NULL) {
|
||||
if (This->type)
|
||||
NPN_MemFree(This->type);
|
||||
if (This->pluginsPageUrl)
|
||||
NPN_MemFree(This->pluginsPageUrl);
|
||||
if (This->pluginsFileUrl)
|
||||
NPN_MemFree(This->pluginsFileUrl);
|
||||
NPN_MemFree(instance->pdata);
|
||||
instance->pdata = NULL;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
PluginInstance* This;
|
||||
NPSetWindowCallbackStruct *ws_info;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
|
||||
|
||||
if (This->window == (Window) window->window) {
|
||||
/* The page with the plugin is being resized.
|
||||
Save any UI information because the next time
|
||||
around expect a SetWindow with a new window
|
||||
id.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Nullplugin: plugin received window resize.\n");
|
||||
fprintf(stderr, "Window=(%i)\n", (int)window);
|
||||
if (window) {
|
||||
fprintf(stderr, "W=(%i) H=(%i)\n",
|
||||
(int)window->width, (int)window->height);
|
||||
}
|
||||
#endif
|
||||
return NPERR_NO_ERROR;
|
||||
} else {
|
||||
|
||||
This->window = (Window) window->window;
|
||||
This->x = window->x;
|
||||
This->y = window->y;
|
||||
This->width = window->width;
|
||||
This->height = window->height;
|
||||
This->display = ws_info->display;
|
||||
This->visual = ws_info->visual;
|
||||
This->depth = ws_info->depth;
|
||||
This->colormap = ws_info->colormap;
|
||||
This->exists = FALSE;
|
||||
makeWidget(This);
|
||||
|
||||
}
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_NewStream(NPP instance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16 *stype)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
|
||||
* mode so we can take any size stream in our
|
||||
* write call (since we ignore it) */
|
||||
|
||||
int32
|
||||
NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
{
|
||||
/***** Insert NPP_WriteReady code here *****\
|
||||
PluginInstance* This;
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\*******************************************/
|
||||
|
||||
/* Number of bytes ready to accept in NPP_Write() */
|
||||
return STREAMBUFSIZE;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
{
|
||||
/***** Insert NPP_Write code here *****\
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\**************************************/
|
||||
|
||||
return len; /* The number of bytes accepted */
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
/***** Insert NPP_DestroyStream code here *****\
|
||||
PluginInstance* This;
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\**********************************************/
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
/***** Insert NPP_StreamAsFile code here *****\
|
||||
PluginInstance* This;
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\*********************************************/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
{
|
||||
if(printInfo == NULL)
|
||||
return;
|
||||
|
||||
if (instance != NULL) {
|
||||
/***** Insert NPP_Print code here *****\
|
||||
PluginInstance* This = (PluginInstance*) instance->pdata;
|
||||
\**************************************/
|
||||
|
||||
if (printInfo->mode == NP_FULL) {
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
* If your plugin would like to take over
|
||||
* printing completely when it is in full-screen mode,
|
||||
* set printInfo->pluginPrinted to TRUE and print your
|
||||
* plugin as you see fit. If your plugin wants Netscape
|
||||
* to handle printing in this case, set
|
||||
* printInfo->pluginPrinted to FALSE (the default) and
|
||||
* do nothing. If you do want to handle printing
|
||||
* yourself, printOne is true if the print button
|
||||
* (as opposed to the print menu) was clicked.
|
||||
* On the Macintosh, platformPrint is a THPrint; on
|
||||
* Windows, platformPrint is a structure
|
||||
* (defined in npapi.h) containing the printer name, port,
|
||||
* etc.
|
||||
*/
|
||||
|
||||
/***** Insert NPP_Print code here *****\
|
||||
void* platformPrint =
|
||||
printInfo->print.fullPrint.platformPrint;
|
||||
NPBool printOne =
|
||||
printInfo->print.fullPrint.printOne;
|
||||
\**************************************/
|
||||
|
||||
/* Do the default*/
|
||||
printInfo->print.fullPrint.pluginPrinted = FALSE;
|
||||
}
|
||||
else { /* If not fullscreen, we must be embedded */
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
* If your plugin is embedded, or is full-screen
|
||||
* but you returned false in pluginPrinted above, NPP_Print
|
||||
* will be called with mode == NP_EMBED. The NPWindow
|
||||
* in the printInfo gives the location and dimensions of
|
||||
* the embedded plugin on the printed page. On the
|
||||
* Macintosh, platformPrint is the printer port; on
|
||||
* Windows, platformPrint is the handle to the printing
|
||||
* device context.
|
||||
*/
|
||||
|
||||
/***** Insert NPP_Print code here *****\
|
||||
NPWindow* printWindow =
|
||||
&(printInfo->print.embedPrint.window);
|
||||
void* platformPrint =
|
||||
printInfo->print.embedPrint.platformPrint;
|
||||
\**************************************/
|
||||
}
|
||||
}
|
||||
}
|
490
modules/plugin/default/unix/npunix.c
Normal file
490
modules/plugin/default/unix/npunix.c
Normal file
@ -0,0 +1,490 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* npunix.c
|
||||
*
|
||||
* Netscape Client Plugin API
|
||||
* - Wrapper function to interface with the Netscape Navigator
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* PLUGIN DEVELOPERS:
|
||||
* YOU WILL NOT NEED TO EDIT THIS FILE.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define XP_UNIX 1
|
||||
|
||||
/* need to define these in order to avoid conflict with those
|
||||
defined in obsolete/prototypes.h (included from prtypes.h), see npapi.h */
|
||||
#define _UINT16
|
||||
#define _UINT32
|
||||
#define _INT16
|
||||
#define _INT32
|
||||
|
||||
#include <stdio.h>
|
||||
#include "npapi.h"
|
||||
#include "npupp.h"
|
||||
|
||||
/*
|
||||
* Define PLUGIN_TRACE to have the wrapper functions print
|
||||
* messages to stderr whenever they are called.
|
||||
*/
|
||||
|
||||
#ifdef PLUGIN_TRACE
|
||||
#include <stdio.h>
|
||||
#define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
|
||||
#else
|
||||
#define PLUGINDEBUGSTR(msg)
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Globals
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
static NPNetscapeFuncs gNetscapeFuncs; /* Netscape Function table */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Wrapper functions : plugin calling Netscape Navigator
|
||||
*
|
||||
* These functions let the plugin developer just call the APIs
|
||||
* as documented and defined in npapi.h, without needing to know
|
||||
* about the function table and call macros in npupp.h.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
void
|
||||
NPN_Version(int* plugin_major, int* plugin_minor,
|
||||
int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
|
||||
/* Major version is in high byte */
|
||||
*netscape_major = gNetscapeFuncs.version >> 8;
|
||||
/* Minor version is in low byte */
|
||||
*netscape_minor = gNetscapeFuncs.version & 0xFF;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
|
||||
{
|
||||
return CallNPN_GetValueProc(gNetscapeFuncs.getvalue,
|
||||
instance, variable, r_value);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return CallNPN_SetValueProc(gNetscapeFuncs.setvalue,
|
||||
instance, variable, value);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetURL(NPP instance, const char* url, const char* window)
|
||||
{
|
||||
return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
|
||||
{
|
||||
return CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURL(NPP instance, const char* url, const char* window,
|
||||
uint32 len, const char* buf, NPBool file)
|
||||
{
|
||||
return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance,
|
||||
url, window, len, buf, file);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len,
|
||||
const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify,
|
||||
instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return CallNPN_RequestReadProc(gNetscapeFuncs.requestread,
|
||||
stream, rangeList);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
|
||||
NPStream** stream_ptr)
|
||||
{
|
||||
return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance,
|
||||
type, window, stream_ptr);
|
||||
}
|
||||
|
||||
int32
|
||||
NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
|
||||
{
|
||||
return CallNPN_WriteProc(gNetscapeFuncs.write, instance,
|
||||
stream, len, buffer);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream,
|
||||
instance, stream, reason);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_Status(NPP instance, const char* message)
|
||||
{
|
||||
CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
|
||||
}
|
||||
|
||||
const char*
|
||||
NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
|
||||
}
|
||||
|
||||
void*
|
||||
NPN_MemAlloc(uint32 size)
|
||||
{
|
||||
return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
|
||||
}
|
||||
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
|
||||
}
|
||||
|
||||
uint32 NPN_MemFlush(uint32 size)
|
||||
{
|
||||
return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
|
||||
}
|
||||
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
|
||||
}
|
||||
|
||||
JRIEnv* NPN_GetJavaEnv()
|
||||
{
|
||||
return CallNPN_GetJavaEnvProc(gNetscapeFuncs.getJavaEnv);
|
||||
}
|
||||
|
||||
jref NPN_GetJavaPeer(NPP instance)
|
||||
{
|
||||
return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer,
|
||||
instance);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
|
||||
{
|
||||
CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance,
|
||||
invalidRect);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
|
||||
{
|
||||
CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance,
|
||||
invalidRegion);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_ForceRedraw(NPP instance)
|
||||
{
|
||||
CallNPN_ForceRedrawProc(gNetscapeFuncs.forceredraw, instance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Wrapper functions : Netscape Navigator -> plugin
|
||||
*
|
||||
* These functions let the plugin developer just create the APIs
|
||||
* as documented and defined in npapi.h, without needing to
|
||||
* install those functions in the function table or worry about
|
||||
* setting up globals for 68K plugins.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
NPError
|
||||
Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
|
||||
int16 argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
NPError ret;
|
||||
PLUGINDEBUGSTR("New");
|
||||
ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
return ret;
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
PLUGINDEBUGSTR("Destroy");
|
||||
return NPP_Destroy(instance, save);
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("SetWindow");
|
||||
err = NPP_SetWindow(instance, window);
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
|
||||
NPBool seekable, uint16* stype)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("NewStream");
|
||||
err = NPP_NewStream(instance, type, stream, seekable, stype);
|
||||
return err;
|
||||
}
|
||||
|
||||
int32
|
||||
Private_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
unsigned int result;
|
||||
PLUGINDEBUGSTR("WriteReady");
|
||||
result = NPP_WriteReady(instance, stream);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32
|
||||
Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
|
||||
void* buffer)
|
||||
{
|
||||
unsigned int result;
|
||||
PLUGINDEBUGSTR("Write");
|
||||
result = NPP_Write(instance, stream, offset, len, buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
PLUGINDEBUGSTR("StreamAsFile");
|
||||
NPP_StreamAsFile(instance, stream, fname);
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("DestroyStream");
|
||||
err = NPP_DestroyStream(instance, stream, reason);
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
Private_URLNotify(NPP instance, const char* url,
|
||||
NPReason reason, void* notifyData)
|
||||
|
||||
{
|
||||
PLUGINDEBUGSTR("URLNotify");
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
Private_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
PLUGINDEBUGSTR("Print");
|
||||
NPP_Print(instance, platformPrint);
|
||||
}
|
||||
|
||||
JRIGlobalRef
|
||||
Private_GetJavaClass(void)
|
||||
{
|
||||
jref clazz = NPP_GetJavaClass();
|
||||
if (clazz) {
|
||||
JRIEnv* env = NPN_GetJavaEnv();
|
||||
return JRI_NewGlobalRef(env, clazz);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* These functions are located automagically by netscape.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/*
|
||||
* NP_GetMIMEDescription
|
||||
* - Netscape needs to know about this symbol
|
||||
* - Netscape uses the return value to identify when an object instance
|
||||
* of this plugin should be created.
|
||||
*/
|
||||
char *
|
||||
NP_GetMIMEDescription(void)
|
||||
{
|
||||
return NPP_GetMIMEDescription();
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_GetValue [optional]
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - Interfaces with plugin to get values for predefined variables
|
||||
* that the navigator needs.
|
||||
*/
|
||||
NPError
|
||||
NP_GetValue(NPP future, NPPVariable variable, void *value)
|
||||
{
|
||||
return NPP_GetValue(future, variable, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_Initialize
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - It calls this function after looking up its symbol before it
|
||||
* is about to create the first ever object of this kind.
|
||||
*
|
||||
* PARAMETERS
|
||||
* nsTable - The netscape function table. If developers just use these
|
||||
* wrappers, they dont need to worry about all these function
|
||||
* tables.
|
||||
* RETURN
|
||||
* pluginFuncs
|
||||
* - This functions needs to fill the plugin function table
|
||||
* pluginFuncs and return it. Netscape Navigator plugin
|
||||
* library will use this function table to call the plugin.
|
||||
*
|
||||
*/
|
||||
NPError
|
||||
NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
|
||||
{
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
PLUGINDEBUGSTR("NP_Initialize");
|
||||
|
||||
/* validate input parameters */
|
||||
|
||||
if ((nsTable == NULL) || (pluginFuncs == NULL))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
/*
|
||||
* Check the major version passed in Netscape's function table.
|
||||
* We won't load if the major version is newer than what we expect.
|
||||
* Also check that the function tables passed in are big enough for
|
||||
* all the functions we need (they could be bigger, if Netscape added
|
||||
* new APIs, but that's OK with us -- we'll just ignore them).
|
||||
*
|
||||
*/
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
if (nsTable->size < sizeof(NPNetscapeFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
if (pluginFuncs->size < sizeof(NPPluginFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
/*
|
||||
* Copy all the fields of Netscape function table into our
|
||||
* copy so we can call back into Netscape later. Note that
|
||||
* we need to copy the fields one by one, rather than assigning
|
||||
* the whole structure, because the Netscape function table
|
||||
* could actually be bigger than what we expect.
|
||||
*/
|
||||
gNetscapeFuncs.version = nsTable->version;
|
||||
gNetscapeFuncs.size = nsTable->size;
|
||||
gNetscapeFuncs.posturl = nsTable->posturl;
|
||||
gNetscapeFuncs.geturl = nsTable->geturl;
|
||||
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
|
||||
gNetscapeFuncs.requestread = nsTable->requestread;
|
||||
gNetscapeFuncs.newstream = nsTable->newstream;
|
||||
gNetscapeFuncs.write = nsTable->write;
|
||||
gNetscapeFuncs.destroystream = nsTable->destroystream;
|
||||
gNetscapeFuncs.status = nsTable->status;
|
||||
gNetscapeFuncs.uagent = nsTable->uagent;
|
||||
gNetscapeFuncs.memalloc = nsTable->memalloc;
|
||||
gNetscapeFuncs.memfree = nsTable->memfree;
|
||||
gNetscapeFuncs.memflush = nsTable->memflush;
|
||||
gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
|
||||
gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
|
||||
gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
|
||||
gNetscapeFuncs.getvalue = nsTable->getvalue;
|
||||
|
||||
/*
|
||||
* Set up the plugin function table that Netscape will use to
|
||||
* call us. Netscape needs to know about our version and size
|
||||
* and have a UniversalProcPointer for every function we
|
||||
* implement.
|
||||
*/
|
||||
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
||||
pluginFuncs->size = sizeof(NPPluginFuncs);
|
||||
pluginFuncs->newp = NewNPP_NewProc(Private_New);
|
||||
pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
|
||||
pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
|
||||
pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
|
||||
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
|
||||
pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
|
||||
pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
|
||||
pluginFuncs->write = NewNPP_WriteProc(Private_Write);
|
||||
pluginFuncs->print = NewNPP_PrintProc(Private_Print);
|
||||
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
|
||||
pluginFuncs->event = NULL;
|
||||
pluginFuncs->javaClass = Private_GetJavaClass();
|
||||
|
||||
err = NPP_Initialize();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_Shutdown [optional]
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - It calls this function after looking up its symbol after
|
||||
* the last object of this kind has been destroyed.
|
||||
*
|
||||
*/
|
||||
NPError
|
||||
NP_Shutdown(void)
|
||||
{
|
||||
PLUGINDEBUGSTR("NP_Shutdown");
|
||||
NPP_Shutdown();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
240
modules/plugin/default/unix/nullplugin.c
Normal file
240
modules/plugin/default/unix/nullplugin.c
Normal file
@ -0,0 +1,240 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* nullplugin.c
|
||||
*
|
||||
* Implementation of the null plugins for Unix.
|
||||
*
|
||||
* dp <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* need to define these in order to avoid conflict with those
|
||||
defined in obsolete/prototypes.h (included from prtypes.h), see npapi.h */
|
||||
#define _UINT16
|
||||
#define _UINT32
|
||||
#define _INT16
|
||||
#define _INT32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "npapi.h"
|
||||
#include "nullplugin.h"
|
||||
|
||||
/* Global data */
|
||||
static MimeTypeElement *head = NULL;
|
||||
|
||||
/* this function is used to clear the mime type cache list
|
||||
whenever the dialog box is closed. We need to clear the
|
||||
list in order to have the dialog box pop up again when
|
||||
the page is reload. (it's because there is no puzzle
|
||||
icon in unix to let the people actively forward to netscape
|
||||
page) */
|
||||
static void
|
||||
clearList(MimeTypeElement **typelist)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
MimeTypeElement *ele2;
|
||||
|
||||
if (typelist == NULL)
|
||||
return;
|
||||
|
||||
/* follow the head to free the list */
|
||||
ele = *typelist;
|
||||
while (ele != NULL) {
|
||||
ele2 = ele->next;
|
||||
if (ele->value != NULL)
|
||||
NPN_MemFree(ele->value);
|
||||
NPN_MemFree(ele);
|
||||
ele = ele2;
|
||||
}
|
||||
*typelist = ele;
|
||||
return;
|
||||
}
|
||||
|
||||
/* callback function for the OK button */
|
||||
static void
|
||||
DialogOKClicked (GtkButton *button, gpointer data)
|
||||
{
|
||||
PluginInstance* This = (PluginInstance*) data;
|
||||
char *url;
|
||||
|
||||
if (This->pluginsFileUrl != NULL)
|
||||
{
|
||||
/* Get the JavaScript command string */
|
||||
static const char buf[] =
|
||||
"javascript:netscape.softupdate.Trigger.StartSoftwareUpdate(\"%s\")";
|
||||
|
||||
url = NPN_MemAlloc(strlen(This->pluginsFileUrl) + (sizeof(buf) - 2));
|
||||
if (url != NULL)
|
||||
{
|
||||
/* Insert the file URL into the JavaScript command */
|
||||
sprintf(url, buf, This->pluginsFileUrl);
|
||||
NPN_GetURL(This->instance, url, TARGET);
|
||||
NPN_MemFree(url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If necessary, get the default plug-ins page resource */
|
||||
char* address = This->pluginsPageUrl;
|
||||
if (address == NULL)
|
||||
{
|
||||
address = PLUGINSPAGE_URL;
|
||||
}
|
||||
|
||||
url = NPN_MemAlloc(strlen(address) + 1 + strlen(This->type)+1);
|
||||
if (url != NULL)
|
||||
{
|
||||
/* Append the MIME type to the URL */
|
||||
sprintf(url, "%s?%s", address, This->type);
|
||||
if (strcmp (This->type, JVM_MINETYPE) == 0)
|
||||
{
|
||||
NPN_GetURL(This->instance, JVM_SMARTUPDATE_URL , TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
NPN_GetURL(This->instance, url, TARGET);
|
||||
}
|
||||
NPN_MemFree(url);
|
||||
}
|
||||
}
|
||||
gtk_widget_destroy (This->dialogBox);
|
||||
clearList(&head);
|
||||
}
|
||||
|
||||
/* the call back function for cancel button */
|
||||
static void
|
||||
DialogCancelClicked (GtkButton *button, gpointer data)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET(data));
|
||||
clearList(&head);
|
||||
}
|
||||
|
||||
/* a handy procedure to add a widget and pack it as well */
|
||||
static GtkWidget *
|
||||
AddWidget (GtkWidget *widget, GtkWidget *packingbox)
|
||||
{
|
||||
gtk_box_pack_start(GTK_BOX(packingbox), widget, TRUE, TRUE, 2);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* MIMETypeList maintenance routines */
|
||||
|
||||
static gboolean
|
||||
isEqual(NPMIMEType t1, NPMIMEType t2)
|
||||
{
|
||||
return(strcmp(t1, t2) == 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
isExist(MimeTypeElement **typelist, NPMIMEType type)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
|
||||
if (typelist == NULL) return FALSE;
|
||||
|
||||
ele = *typelist;
|
||||
while (ele != NULL) {
|
||||
if (isEqual(ele->value, type))
|
||||
return TRUE;
|
||||
ele = ele->next;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NPMIMEType
|
||||
dupMimeType(NPMIMEType type)
|
||||
{
|
||||
NPMIMEType mimetype = NPN_MemAlloc(strlen(type)+1);
|
||||
if (mimetype)
|
||||
strcpy(mimetype, type);
|
||||
return(mimetype);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
addToList(MimeTypeElement **typelist, NPMIMEType type)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
|
||||
if (!typelist) return(FALSE);
|
||||
|
||||
if (isExist(typelist, type)) return(FALSE);
|
||||
|
||||
ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement));
|
||||
ele->value = dupMimeType(type);
|
||||
ele->next = *typelist;
|
||||
*typelist = ele;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* create and display the dialog box */
|
||||
void
|
||||
makeWidget(PluginInstance *This)
|
||||
{
|
||||
GtkWidget *dialogWindow;
|
||||
GtkWidget *dialogMessage;
|
||||
GtkWidget *okButton;
|
||||
GtkWidget *cancelButton;
|
||||
char message[1024];
|
||||
|
||||
if (!This) return;
|
||||
|
||||
dialogWindow = gtk_dialog_new();
|
||||
This->dialogBox = dialogWindow;
|
||||
gtk_window_set_title(GTK_WINDOW(dialogWindow), PLUGIN_NAME);
|
||||
/* gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER); */
|
||||
gtk_window_set_modal(GTK_WINDOW(dialogWindow), TRUE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 0);
|
||||
|
||||
PR_snprintf(message, sizeof(message) - 1, MESSAGE, This->type);
|
||||
dialogMessage = AddWidget(gtk_label_new (message),
|
||||
GTK_DIALOG(dialogWindow)->vbox);
|
||||
|
||||
okButton= AddWidget(gtk_button_new_with_label (OK_BUTTON),
|
||||
GTK_DIALOG(dialogWindow)->action_area);
|
||||
|
||||
cancelButton= AddWidget(gtk_button_new_with_label (CANCEL_BUTTON),
|
||||
GTK_DIALOG(dialogWindow)->action_area);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(okButton), "clicked",
|
||||
GTK_SIGNAL_FUNC(DialogOKClicked), This);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(cancelButton), "clicked",
|
||||
GTK_SIGNAL_FUNC(DialogCancelClicked), dialogWindow);
|
||||
|
||||
|
||||
/* need to check whether we already pop up a dialog box for previous
|
||||
minetype in the same web page. It's require otherwise there will
|
||||
be 2 dialog boxes pop if there are 2 plugin in the same web page */
|
||||
if (addToList(&head, This->type)) {
|
||||
gtk_widget_show_all(dialogWindow);
|
||||
}
|
||||
}
|
||||
|
91
modules/plugin/default/unix/nullplugin.h
Normal file
91
modules/plugin/default/unix/nullplugin.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* nullplugin.h
|
||||
*
|
||||
* Implementation of the null plugins for Unix.
|
||||
*
|
||||
* dp <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#define TARGET "_blank"
|
||||
#define MIME_TYPES_HANDLED "*:.*:All types"
|
||||
#define PLUGIN_NAME "Netscape Default Plugin"
|
||||
#define PLUGIN_DESCRIPTION "The default plugin handles plugin data for mimetypes and extensions that are not specified and facilitates downloading of new plugins."
|
||||
#define CLICK_TO_GET "Click here to get the plugin"
|
||||
#define CLICK_WHEN_DONE "Click here after installing the plugin"
|
||||
|
||||
#define REFRESH_PLUGIN_LIST "javascript:navigator.plugins.refresh(true)"
|
||||
#define PLUGINSPAGE_URL "http://cgi.netscape.com/cgi-bin/plug-in_finder.cgi"
|
||||
#define OK_BUTTON "OK"
|
||||
#define CANCEL_BUTTON "CANCEL"
|
||||
#define JVM_SMARTUPDATE_URL "http://home.netscape.com/plugins/jvm.html"
|
||||
#define JVM_MINETYPE "application/x-java-vm"
|
||||
#define MESSAGE "\
|
||||
This page contains information of a type (%s) that can\n\
|
||||
only be viewed with the appropriate Plug-in.\n\
|
||||
\n\
|
||||
Click OK to download Plugin."
|
||||
|
||||
#define GET 1
|
||||
#define REFRESH 2
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _PluginInstance
|
||||
{
|
||||
uint16 mode;
|
||||
Window window;
|
||||
Display *display;
|
||||
uint32 x, y;
|
||||
uint32 width, height;
|
||||
NPMIMEType type;
|
||||
char *message;
|
||||
|
||||
NPP instance;
|
||||
char *pluginsPageUrl;
|
||||
char *pluginsFileUrl;
|
||||
NPBool pluginsHidden;
|
||||
Visual* visual;
|
||||
Colormap colormap;
|
||||
unsigned int depth;
|
||||
GtkWidget* dialogBox;
|
||||
|
||||
NPBool exists; /* Does the widget already exist? */
|
||||
int action; /* What action should we take? (GET or REFRESH) */
|
||||
|
||||
} PluginInstance;
|
||||
|
||||
|
||||
typedef struct _MimeTypeElement
|
||||
{
|
||||
NPMIMEType value;
|
||||
struct _MimeTypeElement *next;
|
||||
} MimeTypeElement;
|
||||
|
||||
/* Extern functions */
|
||||
extern void makeWidget(PluginInstance *This);
|
||||
extern NPMIMEType dupMimeType(NPMIMEType type);
|
67
modules/plugin/samples/default/unix/Makefile.in
Normal file
67
modules/plugin/samples/default/unix/Makefile.in
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
#MODULE = plugin
|
||||
LIBRARY_NAME = nullplugin
|
||||
#IS_COMPONENT = 1
|
||||
|
||||
CSRCS = \
|
||||
npshell.c\
|
||||
nullplugin.c\
|
||||
npunix.c\
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_PLUGIN
|
||||
|
||||
#CFLAGS += `gtk-config --cflags`
|
||||
#
|
||||
#LIBS = \
|
||||
# `gtk-config --libs`\
|
||||
# $(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif
|
||||
|
||||
install-plugin: libnullplugin.so
|
||||
$(INSTALL) libnullplugin.so $(DIST)/bin/plugins
|
||||
install:: install-plugin
|
||||
|
||||
|
371
modules/plugin/samples/default/unix/npshell.c
Normal file
371
modules/plugin/samples/default/unix/npshell.c
Normal file
@ -0,0 +1,371 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* npshell.c
|
||||
*
|
||||
* Netscape Client Plugin API
|
||||
* - Function that need to be implemented by plugin developers
|
||||
*
|
||||
* This file defines a "shell" plugin that plugin developers can use
|
||||
* as the basis for a real plugin. This shell just provides empty
|
||||
* implementations of all functions that the plugin can implement
|
||||
* that will be called by Netscape (the NPP_xxx methods defined in
|
||||
* npapi.h).
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* need to define these in order to avoid conflict with those
|
||||
defined in obsolete/prototypes.h (included from prtypes.h), see npapi.h */
|
||||
#define _UINT16
|
||||
#define _UINT32
|
||||
#define _INT16
|
||||
#define _INT32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "npapi.h"
|
||||
#include "nullplugin.h"
|
||||
#include "strings.h"
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Implementations of plugin API functions
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
char*
|
||||
NPP_GetMIMEDescription(void)
|
||||
{
|
||||
return(MIME_TYPES_HANDLED);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_GetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
switch (variable) {
|
||||
case NPPVpluginNameString:
|
||||
*((char **)value) = PLUGIN_NAME;
|
||||
break;
|
||||
case NPPVpluginDescriptionString:
|
||||
*((char **)value) = PLUGIN_DESCRIPTION;
|
||||
break;
|
||||
default:
|
||||
err = NPERR_GENERIC_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_Initialize(void)
|
||||
{
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
jref
|
||||
NPP_GetJavaClass()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
NPP_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_New(NPMIMEType pluginType,
|
||||
NPP instance,
|
||||
uint16 mode,
|
||||
int16 argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
instance->pdata = NPN_MemAlloc(sizeof(PluginInstance));
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This == NULL)
|
||||
{
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
memset(This, 0, sizeof(PluginInstance));
|
||||
|
||||
/* mode is NP_EMBED, NP_FULL, or NP_BACKGROUND (see npapi.h) */
|
||||
This->mode = mode;
|
||||
This->type = dupMimeType(pluginType);
|
||||
This->instance = instance;
|
||||
This->pluginsPageUrl = NULL;
|
||||
|
||||
/* Parse argument list passed to plugin instance */
|
||||
/* We are interested in these arguments
|
||||
* PLUGINSPAGE = <url>
|
||||
*/
|
||||
while (argc > 0)
|
||||
{
|
||||
argc --;
|
||||
if (argv[argc] != NULL)
|
||||
{
|
||||
if (!strcasecmp(argn[argc], "PLUGINSPAGE"))
|
||||
This->pluginsPageUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "PLUGINURL"))
|
||||
This->pluginsFileUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "CODEBASE"))
|
||||
This->pluginsPageUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "CLASSID"))
|
||||
This->pluginsFileUrl = strdup(argv[argc]);
|
||||
else if (!strcasecmp(argn[argc], "HIDDEN"))
|
||||
This->pluginsHidden = (!strcasecmp(argv[argc],
|
||||
"TRUE"));
|
||||
}
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This != NULL) {
|
||||
if (This->type)
|
||||
NPN_MemFree(This->type);
|
||||
if (This->pluginsPageUrl)
|
||||
NPN_MemFree(This->pluginsPageUrl);
|
||||
if (This->pluginsFileUrl)
|
||||
NPN_MemFree(This->pluginsFileUrl);
|
||||
NPN_MemFree(instance->pdata);
|
||||
instance->pdata = NULL;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
PluginInstance* This;
|
||||
NPSetWindowCallbackStruct *ws_info;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
|
||||
|
||||
if (This->window == (Window) window->window) {
|
||||
/* The page with the plugin is being resized.
|
||||
Save any UI information because the next time
|
||||
around expect a SetWindow with a new window
|
||||
id.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Nullplugin: plugin received window resize.\n");
|
||||
fprintf(stderr, "Window=(%i)\n", (int)window);
|
||||
if (window) {
|
||||
fprintf(stderr, "W=(%i) H=(%i)\n",
|
||||
(int)window->width, (int)window->height);
|
||||
}
|
||||
#endif
|
||||
return NPERR_NO_ERROR;
|
||||
} else {
|
||||
|
||||
This->window = (Window) window->window;
|
||||
This->x = window->x;
|
||||
This->y = window->y;
|
||||
This->width = window->width;
|
||||
This->height = window->height;
|
||||
This->display = ws_info->display;
|
||||
This->visual = ws_info->visual;
|
||||
This->depth = ws_info->depth;
|
||||
This->colormap = ws_info->colormap;
|
||||
This->exists = FALSE;
|
||||
makeWidget(This);
|
||||
|
||||
}
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_NewStream(NPP instance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16 *stype)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
|
||||
* mode so we can take any size stream in our
|
||||
* write call (since we ignore it) */
|
||||
|
||||
int32
|
||||
NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
{
|
||||
/***** Insert NPP_WriteReady code here *****\
|
||||
PluginInstance* This;
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\*******************************************/
|
||||
|
||||
/* Number of bytes ready to accept in NPP_Write() */
|
||||
return STREAMBUFSIZE;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
{
|
||||
/***** Insert NPP_Write code here *****\
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\**************************************/
|
||||
|
||||
return len; /* The number of bytes accepted */
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
/***** Insert NPP_DestroyStream code here *****\
|
||||
PluginInstance* This;
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\**********************************************/
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
/***** Insert NPP_StreamAsFile code here *****\
|
||||
PluginInstance* This;
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\*********************************************/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
{
|
||||
if(printInfo == NULL)
|
||||
return;
|
||||
|
||||
if (instance != NULL) {
|
||||
/***** Insert NPP_Print code here *****\
|
||||
PluginInstance* This = (PluginInstance*) instance->pdata;
|
||||
\**************************************/
|
||||
|
||||
if (printInfo->mode == NP_FULL) {
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
* If your plugin would like to take over
|
||||
* printing completely when it is in full-screen mode,
|
||||
* set printInfo->pluginPrinted to TRUE and print your
|
||||
* plugin as you see fit. If your plugin wants Netscape
|
||||
* to handle printing in this case, set
|
||||
* printInfo->pluginPrinted to FALSE (the default) and
|
||||
* do nothing. If you do want to handle printing
|
||||
* yourself, printOne is true if the print button
|
||||
* (as opposed to the print menu) was clicked.
|
||||
* On the Macintosh, platformPrint is a THPrint; on
|
||||
* Windows, platformPrint is a structure
|
||||
* (defined in npapi.h) containing the printer name, port,
|
||||
* etc.
|
||||
*/
|
||||
|
||||
/***** Insert NPP_Print code here *****\
|
||||
void* platformPrint =
|
||||
printInfo->print.fullPrint.platformPrint;
|
||||
NPBool printOne =
|
||||
printInfo->print.fullPrint.printOne;
|
||||
\**************************************/
|
||||
|
||||
/* Do the default*/
|
||||
printInfo->print.fullPrint.pluginPrinted = FALSE;
|
||||
}
|
||||
else { /* If not fullscreen, we must be embedded */
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
* If your plugin is embedded, or is full-screen
|
||||
* but you returned false in pluginPrinted above, NPP_Print
|
||||
* will be called with mode == NP_EMBED. The NPWindow
|
||||
* in the printInfo gives the location and dimensions of
|
||||
* the embedded plugin on the printed page. On the
|
||||
* Macintosh, platformPrint is the printer port; on
|
||||
* Windows, platformPrint is the handle to the printing
|
||||
* device context.
|
||||
*/
|
||||
|
||||
/***** Insert NPP_Print code here *****\
|
||||
NPWindow* printWindow =
|
||||
&(printInfo->print.embedPrint.window);
|
||||
void* platformPrint =
|
||||
printInfo->print.embedPrint.platformPrint;
|
||||
\**************************************/
|
||||
}
|
||||
}
|
||||
}
|
490
modules/plugin/samples/default/unix/npunix.c
Normal file
490
modules/plugin/samples/default/unix/npunix.c
Normal file
@ -0,0 +1,490 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* npunix.c
|
||||
*
|
||||
* Netscape Client Plugin API
|
||||
* - Wrapper function to interface with the Netscape Navigator
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* PLUGIN DEVELOPERS:
|
||||
* YOU WILL NOT NEED TO EDIT THIS FILE.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define XP_UNIX 1
|
||||
|
||||
/* need to define these in order to avoid conflict with those
|
||||
defined in obsolete/prototypes.h (included from prtypes.h), see npapi.h */
|
||||
#define _UINT16
|
||||
#define _UINT32
|
||||
#define _INT16
|
||||
#define _INT32
|
||||
|
||||
#include <stdio.h>
|
||||
#include "npapi.h"
|
||||
#include "npupp.h"
|
||||
|
||||
/*
|
||||
* Define PLUGIN_TRACE to have the wrapper functions print
|
||||
* messages to stderr whenever they are called.
|
||||
*/
|
||||
|
||||
#ifdef PLUGIN_TRACE
|
||||
#include <stdio.h>
|
||||
#define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
|
||||
#else
|
||||
#define PLUGINDEBUGSTR(msg)
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Globals
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
static NPNetscapeFuncs gNetscapeFuncs; /* Netscape Function table */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Wrapper functions : plugin calling Netscape Navigator
|
||||
*
|
||||
* These functions let the plugin developer just call the APIs
|
||||
* as documented and defined in npapi.h, without needing to know
|
||||
* about the function table and call macros in npupp.h.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
void
|
||||
NPN_Version(int* plugin_major, int* plugin_minor,
|
||||
int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
|
||||
/* Major version is in high byte */
|
||||
*netscape_major = gNetscapeFuncs.version >> 8;
|
||||
/* Minor version is in low byte */
|
||||
*netscape_minor = gNetscapeFuncs.version & 0xFF;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
|
||||
{
|
||||
return CallNPN_GetValueProc(gNetscapeFuncs.getvalue,
|
||||
instance, variable, r_value);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return CallNPN_SetValueProc(gNetscapeFuncs.setvalue,
|
||||
instance, variable, value);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetURL(NPP instance, const char* url, const char* window)
|
||||
{
|
||||
return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
|
||||
{
|
||||
return CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURL(NPP instance, const char* url, const char* window,
|
||||
uint32 len, const char* buf, NPBool file)
|
||||
{
|
||||
return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance,
|
||||
url, window, len, buf, file);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len,
|
||||
const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify,
|
||||
instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return CallNPN_RequestReadProc(gNetscapeFuncs.requestread,
|
||||
stream, rangeList);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
|
||||
NPStream** stream_ptr)
|
||||
{
|
||||
return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance,
|
||||
type, window, stream_ptr);
|
||||
}
|
||||
|
||||
int32
|
||||
NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
|
||||
{
|
||||
return CallNPN_WriteProc(gNetscapeFuncs.write, instance,
|
||||
stream, len, buffer);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream,
|
||||
instance, stream, reason);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_Status(NPP instance, const char* message)
|
||||
{
|
||||
CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
|
||||
}
|
||||
|
||||
const char*
|
||||
NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
|
||||
}
|
||||
|
||||
void*
|
||||
NPN_MemAlloc(uint32 size)
|
||||
{
|
||||
return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
|
||||
}
|
||||
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
|
||||
}
|
||||
|
||||
uint32 NPN_MemFlush(uint32 size)
|
||||
{
|
||||
return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
|
||||
}
|
||||
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
|
||||
}
|
||||
|
||||
JRIEnv* NPN_GetJavaEnv()
|
||||
{
|
||||
return CallNPN_GetJavaEnvProc(gNetscapeFuncs.getJavaEnv);
|
||||
}
|
||||
|
||||
jref NPN_GetJavaPeer(NPP instance)
|
||||
{
|
||||
return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer,
|
||||
instance);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
|
||||
{
|
||||
CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance,
|
||||
invalidRect);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
|
||||
{
|
||||
CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance,
|
||||
invalidRegion);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_ForceRedraw(NPP instance)
|
||||
{
|
||||
CallNPN_ForceRedrawProc(gNetscapeFuncs.forceredraw, instance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Wrapper functions : Netscape Navigator -> plugin
|
||||
*
|
||||
* These functions let the plugin developer just create the APIs
|
||||
* as documented and defined in npapi.h, without needing to
|
||||
* install those functions in the function table or worry about
|
||||
* setting up globals for 68K plugins.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
NPError
|
||||
Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
|
||||
int16 argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
NPError ret;
|
||||
PLUGINDEBUGSTR("New");
|
||||
ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
return ret;
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
PLUGINDEBUGSTR("Destroy");
|
||||
return NPP_Destroy(instance, save);
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("SetWindow");
|
||||
err = NPP_SetWindow(instance, window);
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
|
||||
NPBool seekable, uint16* stype)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("NewStream");
|
||||
err = NPP_NewStream(instance, type, stream, seekable, stype);
|
||||
return err;
|
||||
}
|
||||
|
||||
int32
|
||||
Private_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
unsigned int result;
|
||||
PLUGINDEBUGSTR("WriteReady");
|
||||
result = NPP_WriteReady(instance, stream);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32
|
||||
Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
|
||||
void* buffer)
|
||||
{
|
||||
unsigned int result;
|
||||
PLUGINDEBUGSTR("Write");
|
||||
result = NPP_Write(instance, stream, offset, len, buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
PLUGINDEBUGSTR("StreamAsFile");
|
||||
NPP_StreamAsFile(instance, stream, fname);
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("DestroyStream");
|
||||
err = NPP_DestroyStream(instance, stream, reason);
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
Private_URLNotify(NPP instance, const char* url,
|
||||
NPReason reason, void* notifyData)
|
||||
|
||||
{
|
||||
PLUGINDEBUGSTR("URLNotify");
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
Private_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
PLUGINDEBUGSTR("Print");
|
||||
NPP_Print(instance, platformPrint);
|
||||
}
|
||||
|
||||
JRIGlobalRef
|
||||
Private_GetJavaClass(void)
|
||||
{
|
||||
jref clazz = NPP_GetJavaClass();
|
||||
if (clazz) {
|
||||
JRIEnv* env = NPN_GetJavaEnv();
|
||||
return JRI_NewGlobalRef(env, clazz);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* These functions are located automagically by netscape.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/*
|
||||
* NP_GetMIMEDescription
|
||||
* - Netscape needs to know about this symbol
|
||||
* - Netscape uses the return value to identify when an object instance
|
||||
* of this plugin should be created.
|
||||
*/
|
||||
char *
|
||||
NP_GetMIMEDescription(void)
|
||||
{
|
||||
return NPP_GetMIMEDescription();
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_GetValue [optional]
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - Interfaces with plugin to get values for predefined variables
|
||||
* that the navigator needs.
|
||||
*/
|
||||
NPError
|
||||
NP_GetValue(NPP future, NPPVariable variable, void *value)
|
||||
{
|
||||
return NPP_GetValue(future, variable, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_Initialize
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - It calls this function after looking up its symbol before it
|
||||
* is about to create the first ever object of this kind.
|
||||
*
|
||||
* PARAMETERS
|
||||
* nsTable - The netscape function table. If developers just use these
|
||||
* wrappers, they dont need to worry about all these function
|
||||
* tables.
|
||||
* RETURN
|
||||
* pluginFuncs
|
||||
* - This functions needs to fill the plugin function table
|
||||
* pluginFuncs and return it. Netscape Navigator plugin
|
||||
* library will use this function table to call the plugin.
|
||||
*
|
||||
*/
|
||||
NPError
|
||||
NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
|
||||
{
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
PLUGINDEBUGSTR("NP_Initialize");
|
||||
|
||||
/* validate input parameters */
|
||||
|
||||
if ((nsTable == NULL) || (pluginFuncs == NULL))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
/*
|
||||
* Check the major version passed in Netscape's function table.
|
||||
* We won't load if the major version is newer than what we expect.
|
||||
* Also check that the function tables passed in are big enough for
|
||||
* all the functions we need (they could be bigger, if Netscape added
|
||||
* new APIs, but that's OK with us -- we'll just ignore them).
|
||||
*
|
||||
*/
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
if (nsTable->size < sizeof(NPNetscapeFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
if (pluginFuncs->size < sizeof(NPPluginFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
/*
|
||||
* Copy all the fields of Netscape function table into our
|
||||
* copy so we can call back into Netscape later. Note that
|
||||
* we need to copy the fields one by one, rather than assigning
|
||||
* the whole structure, because the Netscape function table
|
||||
* could actually be bigger than what we expect.
|
||||
*/
|
||||
gNetscapeFuncs.version = nsTable->version;
|
||||
gNetscapeFuncs.size = nsTable->size;
|
||||
gNetscapeFuncs.posturl = nsTable->posturl;
|
||||
gNetscapeFuncs.geturl = nsTable->geturl;
|
||||
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
|
||||
gNetscapeFuncs.requestread = nsTable->requestread;
|
||||
gNetscapeFuncs.newstream = nsTable->newstream;
|
||||
gNetscapeFuncs.write = nsTable->write;
|
||||
gNetscapeFuncs.destroystream = nsTable->destroystream;
|
||||
gNetscapeFuncs.status = nsTable->status;
|
||||
gNetscapeFuncs.uagent = nsTable->uagent;
|
||||
gNetscapeFuncs.memalloc = nsTable->memalloc;
|
||||
gNetscapeFuncs.memfree = nsTable->memfree;
|
||||
gNetscapeFuncs.memflush = nsTable->memflush;
|
||||
gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
|
||||
gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
|
||||
gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
|
||||
gNetscapeFuncs.getvalue = nsTable->getvalue;
|
||||
|
||||
/*
|
||||
* Set up the plugin function table that Netscape will use to
|
||||
* call us. Netscape needs to know about our version and size
|
||||
* and have a UniversalProcPointer for every function we
|
||||
* implement.
|
||||
*/
|
||||
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
||||
pluginFuncs->size = sizeof(NPPluginFuncs);
|
||||
pluginFuncs->newp = NewNPP_NewProc(Private_New);
|
||||
pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
|
||||
pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
|
||||
pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
|
||||
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
|
||||
pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
|
||||
pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
|
||||
pluginFuncs->write = NewNPP_WriteProc(Private_Write);
|
||||
pluginFuncs->print = NewNPP_PrintProc(Private_Print);
|
||||
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
|
||||
pluginFuncs->event = NULL;
|
||||
pluginFuncs->javaClass = Private_GetJavaClass();
|
||||
|
||||
err = NPP_Initialize();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_Shutdown [optional]
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - It calls this function after looking up its symbol after
|
||||
* the last object of this kind has been destroyed.
|
||||
*
|
||||
*/
|
||||
NPError
|
||||
NP_Shutdown(void)
|
||||
{
|
||||
PLUGINDEBUGSTR("NP_Shutdown");
|
||||
NPP_Shutdown();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
240
modules/plugin/samples/default/unix/nullplugin.c
Normal file
240
modules/plugin/samples/default/unix/nullplugin.c
Normal file
@ -0,0 +1,240 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* nullplugin.c
|
||||
*
|
||||
* Implementation of the null plugins for Unix.
|
||||
*
|
||||
* dp <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* need to define these in order to avoid conflict with those
|
||||
defined in obsolete/prototypes.h (included from prtypes.h), see npapi.h */
|
||||
#define _UINT16
|
||||
#define _UINT32
|
||||
#define _INT16
|
||||
#define _INT32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "npapi.h"
|
||||
#include "nullplugin.h"
|
||||
|
||||
/* Global data */
|
||||
static MimeTypeElement *head = NULL;
|
||||
|
||||
/* this function is used to clear the mime type cache list
|
||||
whenever the dialog box is closed. We need to clear the
|
||||
list in order to have the dialog box pop up again when
|
||||
the page is reload. (it's because there is no puzzle
|
||||
icon in unix to let the people actively forward to netscape
|
||||
page) */
|
||||
static void
|
||||
clearList(MimeTypeElement **typelist)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
MimeTypeElement *ele2;
|
||||
|
||||
if (typelist == NULL)
|
||||
return;
|
||||
|
||||
/* follow the head to free the list */
|
||||
ele = *typelist;
|
||||
while (ele != NULL) {
|
||||
ele2 = ele->next;
|
||||
if (ele->value != NULL)
|
||||
NPN_MemFree(ele->value);
|
||||
NPN_MemFree(ele);
|
||||
ele = ele2;
|
||||
}
|
||||
*typelist = ele;
|
||||
return;
|
||||
}
|
||||
|
||||
/* callback function for the OK button */
|
||||
static void
|
||||
DialogOKClicked (GtkButton *button, gpointer data)
|
||||
{
|
||||
PluginInstance* This = (PluginInstance*) data;
|
||||
char *url;
|
||||
|
||||
if (This->pluginsFileUrl != NULL)
|
||||
{
|
||||
/* Get the JavaScript command string */
|
||||
static const char buf[] =
|
||||
"javascript:netscape.softupdate.Trigger.StartSoftwareUpdate(\"%s\")";
|
||||
|
||||
url = NPN_MemAlloc(strlen(This->pluginsFileUrl) + (sizeof(buf) - 2));
|
||||
if (url != NULL)
|
||||
{
|
||||
/* Insert the file URL into the JavaScript command */
|
||||
sprintf(url, buf, This->pluginsFileUrl);
|
||||
NPN_GetURL(This->instance, url, TARGET);
|
||||
NPN_MemFree(url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If necessary, get the default plug-ins page resource */
|
||||
char* address = This->pluginsPageUrl;
|
||||
if (address == NULL)
|
||||
{
|
||||
address = PLUGINSPAGE_URL;
|
||||
}
|
||||
|
||||
url = NPN_MemAlloc(strlen(address) + 1 + strlen(This->type)+1);
|
||||
if (url != NULL)
|
||||
{
|
||||
/* Append the MIME type to the URL */
|
||||
sprintf(url, "%s?%s", address, This->type);
|
||||
if (strcmp (This->type, JVM_MINETYPE) == 0)
|
||||
{
|
||||
NPN_GetURL(This->instance, JVM_SMARTUPDATE_URL , TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
NPN_GetURL(This->instance, url, TARGET);
|
||||
}
|
||||
NPN_MemFree(url);
|
||||
}
|
||||
}
|
||||
gtk_widget_destroy (This->dialogBox);
|
||||
clearList(&head);
|
||||
}
|
||||
|
||||
/* the call back function for cancel button */
|
||||
static void
|
||||
DialogCancelClicked (GtkButton *button, gpointer data)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET(data));
|
||||
clearList(&head);
|
||||
}
|
||||
|
||||
/* a handy procedure to add a widget and pack it as well */
|
||||
static GtkWidget *
|
||||
AddWidget (GtkWidget *widget, GtkWidget *packingbox)
|
||||
{
|
||||
gtk_box_pack_start(GTK_BOX(packingbox), widget, TRUE, TRUE, 2);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* MIMETypeList maintenance routines */
|
||||
|
||||
static gboolean
|
||||
isEqual(NPMIMEType t1, NPMIMEType t2)
|
||||
{
|
||||
return(strcmp(t1, t2) == 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
isExist(MimeTypeElement **typelist, NPMIMEType type)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
|
||||
if (typelist == NULL) return FALSE;
|
||||
|
||||
ele = *typelist;
|
||||
while (ele != NULL) {
|
||||
if (isEqual(ele->value, type))
|
||||
return TRUE;
|
||||
ele = ele->next;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NPMIMEType
|
||||
dupMimeType(NPMIMEType type)
|
||||
{
|
||||
NPMIMEType mimetype = NPN_MemAlloc(strlen(type)+1);
|
||||
if (mimetype)
|
||||
strcpy(mimetype, type);
|
||||
return(mimetype);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
addToList(MimeTypeElement **typelist, NPMIMEType type)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
|
||||
if (!typelist) return(FALSE);
|
||||
|
||||
if (isExist(typelist, type)) return(FALSE);
|
||||
|
||||
ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement));
|
||||
ele->value = dupMimeType(type);
|
||||
ele->next = *typelist;
|
||||
*typelist = ele;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* create and display the dialog box */
|
||||
void
|
||||
makeWidget(PluginInstance *This)
|
||||
{
|
||||
GtkWidget *dialogWindow;
|
||||
GtkWidget *dialogMessage;
|
||||
GtkWidget *okButton;
|
||||
GtkWidget *cancelButton;
|
||||
char message[1024];
|
||||
|
||||
if (!This) return;
|
||||
|
||||
dialogWindow = gtk_dialog_new();
|
||||
This->dialogBox = dialogWindow;
|
||||
gtk_window_set_title(GTK_WINDOW(dialogWindow), PLUGIN_NAME);
|
||||
/* gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER); */
|
||||
gtk_window_set_modal(GTK_WINDOW(dialogWindow), TRUE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 0);
|
||||
|
||||
PR_snprintf(message, sizeof(message) - 1, MESSAGE, This->type);
|
||||
dialogMessage = AddWidget(gtk_label_new (message),
|
||||
GTK_DIALOG(dialogWindow)->vbox);
|
||||
|
||||
okButton= AddWidget(gtk_button_new_with_label (OK_BUTTON),
|
||||
GTK_DIALOG(dialogWindow)->action_area);
|
||||
|
||||
cancelButton= AddWidget(gtk_button_new_with_label (CANCEL_BUTTON),
|
||||
GTK_DIALOG(dialogWindow)->action_area);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(okButton), "clicked",
|
||||
GTK_SIGNAL_FUNC(DialogOKClicked), This);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(cancelButton), "clicked",
|
||||
GTK_SIGNAL_FUNC(DialogCancelClicked), dialogWindow);
|
||||
|
||||
|
||||
/* need to check whether we already pop up a dialog box for previous
|
||||
minetype in the same web page. It's require otherwise there will
|
||||
be 2 dialog boxes pop if there are 2 plugin in the same web page */
|
||||
if (addToList(&head, This->type)) {
|
||||
gtk_widget_show_all(dialogWindow);
|
||||
}
|
||||
}
|
||||
|
91
modules/plugin/samples/default/unix/nullplugin.h
Normal file
91
modules/plugin/samples/default/unix/nullplugin.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* nullplugin.h
|
||||
*
|
||||
* Implementation of the null plugins for Unix.
|
||||
*
|
||||
* dp <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#define TARGET "_blank"
|
||||
#define MIME_TYPES_HANDLED "*:.*:All types"
|
||||
#define PLUGIN_NAME "Netscape Default Plugin"
|
||||
#define PLUGIN_DESCRIPTION "The default plugin handles plugin data for mimetypes and extensions that are not specified and facilitates downloading of new plugins."
|
||||
#define CLICK_TO_GET "Click here to get the plugin"
|
||||
#define CLICK_WHEN_DONE "Click here after installing the plugin"
|
||||
|
||||
#define REFRESH_PLUGIN_LIST "javascript:navigator.plugins.refresh(true)"
|
||||
#define PLUGINSPAGE_URL "http://cgi.netscape.com/cgi-bin/plug-in_finder.cgi"
|
||||
#define OK_BUTTON "OK"
|
||||
#define CANCEL_BUTTON "CANCEL"
|
||||
#define JVM_SMARTUPDATE_URL "http://home.netscape.com/plugins/jvm.html"
|
||||
#define JVM_MINETYPE "application/x-java-vm"
|
||||
#define MESSAGE "\
|
||||
This page contains information of a type (%s) that can\n\
|
||||
only be viewed with the appropriate Plug-in.\n\
|
||||
\n\
|
||||
Click OK to download Plugin."
|
||||
|
||||
#define GET 1
|
||||
#define REFRESH 2
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _PluginInstance
|
||||
{
|
||||
uint16 mode;
|
||||
Window window;
|
||||
Display *display;
|
||||
uint32 x, y;
|
||||
uint32 width, height;
|
||||
NPMIMEType type;
|
||||
char *message;
|
||||
|
||||
NPP instance;
|
||||
char *pluginsPageUrl;
|
||||
char *pluginsFileUrl;
|
||||
NPBool pluginsHidden;
|
||||
Visual* visual;
|
||||
Colormap colormap;
|
||||
unsigned int depth;
|
||||
GtkWidget* dialogBox;
|
||||
|
||||
NPBool exists; /* Does the widget already exist? */
|
||||
int action; /* What action should we take? (GET or REFRESH) */
|
||||
|
||||
} PluginInstance;
|
||||
|
||||
|
||||
typedef struct _MimeTypeElement
|
||||
{
|
||||
NPMIMEType value;
|
||||
struct _MimeTypeElement *next;
|
||||
} MimeTypeElement;
|
||||
|
||||
/* Extern functions */
|
||||
extern void makeWidget(PluginInstance *This);
|
||||
extern NPMIMEType dupMimeType(NPMIMEType type);
|
@ -208,6 +208,7 @@ bin/chrome/blue.jar
|
||||
bin/defaults/pref/*
|
||||
; this is only here if you have plugins -blizzard
|
||||
; bin/plugins/*
|
||||
bin/plugins/libnullplugin.so
|
||||
bin/res/entityTables/*
|
||||
bin/defaults/wallet/FieldSchema.tbl
|
||||
bin/defaults/wallet/SchemaConcat.tbl
|
||||
|
Loading…
Reference in New Issue
Block a user