Bugfixes 5.0 SF1 in (Bug #300542)

This commit is contained in:
pollmann 1998-07-13 23:57:14 +00:00
parent d07b526a93
commit 9509ad5eca
3 changed files with 295 additions and 135 deletions

View File

@ -28,15 +28,13 @@
* npapi.h).
*
* dp Suresh <dp@netscape.com>
* updated 5/1998 <pollmann@netscape.com>
*
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include "npapi.h"
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include "npapi.h"
#include "nullplugin.h"
/***********************************************************************
@ -52,7 +50,7 @@ NPP_GetMIMEDescription(void)
}
NPError
NPP_GetValue(void *future, NPPVariable variable, void *value)
NPP_GetValue(void *instance, NPPVariable variable, void *value)
{
NPError err = NPERR_NO_ERROR;
@ -86,7 +84,6 @@ NPP_Shutdown(void)
{
}
NPError
NPP_New(NPMIMEType pluginType,
NPP instance,
@ -115,24 +112,28 @@ NPP_New(NPMIMEType pluginType,
This->instance = instance;
This->pluginsPageUrl = NULL;
/* Parse argument list passed to plugin instance */
/* We are interested in these arguments
* PLUGINSPAGE = <url>
*/
/* Parse argument list passed to plugin instance. */
while (argc > 0)
{
if (argv[argc-1] != NULL)
{
if (!strcasecmp(argn[argc-1], "PLUGINSPAGE"))
This->pluginsPageUrl = strdup(argv[argc-1]);
else if (!strcasecmp(argn[argc-1], "PLUGINURL"))
This->pluginsFileUrl = strdup(argv[argc-1]);
else if (!strcasecmp(argn[argc-1], "CODEBASE"))
This->pluginsPageUrl = strdup(argv[argc-1]);
else if (!strcasecmp(argn[argc-1], "CLASSID"))
This->pluginsFileUrl = strdup(argv[argc-1]);
}
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"));
}
}
if (This->pluginsHidden)
{
showPluginDialog(NULL, (XtPointer)This, NULL);
}
return NPERR_NO_ERROR;
@ -158,7 +159,22 @@ NPP_Destroy(NPP instance, NPSavedData** save)
if (This->pluginsPageUrl)
NPN_MemFree(This->pluginsPageUrl);
if (This->pluginsFileUrl)
NPN_MemFree(This->pluginsFileUrl);
NPN_MemFree(This->pluginsFileUrl);
if (This->refreshing) {
if (This->action == GET) {
XtRemoveCallback (This->button, XmNactivateCallback,
showPluginDialog, (XtPointer)This);
} else if (This->action == REFRESH) {
XtRemoveCallback (This->button, XmNactivateCallback,
refreshPluginList, (XtPointer)This);
}
This->exists = FALSE;
} else {
if (This->dialog) {
XtDestroyWidget(This->dialog);
This->dialog = NULL;
}
}
NPN_MemFree(instance->pdata);
instance->pdata = NULL;
}
@ -167,7 +183,6 @@ NPP_Destroy(NPP instance, NPSavedData** save)
}
NPError
NPP_SetWindow(NPP instance, NPWindow* window)
{
@ -180,67 +195,31 @@ NPP_SetWindow(NPP instance, NPWindow* window)
This = (PluginInstance*) instance->pdata;
ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
if (window->window == NULL) {
/* 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.
*/
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");
#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->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;
{
Widget netscape_widget;
Widget form;
Arg av[20];
int ac;
XmString xmstr = XmStringCreateLtoR("Download Plugin", XmSTRING_DEFAULT_CHARSET);
netscape_widget = XtWindowToWidget(This->display, This->window);
ac = 0;
XtSetArg(av[ac], XmNx, 0); ac++;
XtSetArg(av[ac], XmNy, 0); ac++;
XtSetArg(av[ac], XmNwidth, This->width); ac++;
XtSetArg(av[ac], XmNheight, This->height); ac++;
XtSetArg(av[ac], XmNborderWidth, 0); ac++;
XtSetArg(av[ac], XmNnoResize, True); ac++;
form = XmCreateForm(netscape_widget, "pluginForm",
av, ac);
ac = 0;
XtSetArg(av[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
XtSetArg(av[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
XtSetArg(av[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
XtSetArg(av[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
XtSetArg (av[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
XtSetArg (av[ac], XmNlabelString, xmstr); ac++;
This->button = XmCreatePushButton (form, "pluginButton", av, ac);
XtAddCallback (This->button, XmNactivateCallback, showPluginDialog,
(XtPointer)This);
XtManageChild(This->button);
XtManageChild(form);
/* Popup the pluginDialog if this is the first time we encounter
this MimeType */
if (addToList(&head, This->type))
showPluginDialog(This->button, (XtPointer) This, NULL);
XmStringFree(xmstr);
This->exists = FALSE;
This->refreshing = FALSE;
makeWidget(This);
}
return NPERR_NO_ERROR;
@ -254,28 +233,27 @@ NPP_NewStream(NPP instance,
NPBool seekable,
uint16 *stype)
{
PluginInstance* This;
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
This = (PluginInstance*) instance->pdata;
return NPERR_NO_ERROR;
}
int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
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) */
* write call (since we ignore it)
*/
int32
NPP_WriteReady(NPP instance, NPStream *stream)
{
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
/*
* PluginInstance* This;
* if (instance != NULL)
* This = (PluginInstance*) instance->pdata;
*/
/* Number of bytes ready to accept in NPP_Write() */
return STREAMBUFSIZE;
}
@ -284,13 +262,14 @@ NPP_WriteReady(NPP instance, NPStream *stream)
int32
NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
else
return len;
/*
* PluginInstance* This;
*
* if (instance != NULL)
* This = (PluginInstance*) instance->pdata;
* else
* return len;
*/
return len; /* The number of bytes accepted */
}
@ -298,12 +277,14 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
NPError
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
{
PluginInstance* This;
/*
* PluginInstance* This;
*/
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
This = (PluginInstance*) instance->pdata;
/*
* This = (PluginInstance*) instance->pdata;
*/
return NPERR_NO_ERROR;
}
@ -311,9 +292,11 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
void
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
{
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
/*
* PluginInstance* This;
* if (instance != NULL)
* This = (PluginInstance*) instance->pdata;
*/
}
@ -324,7 +307,9 @@ NPP_Print(NPP instance, NPPrint* printInfo)
return;
if (instance != NULL) {
PluginInstance* This = (PluginInstance*) instance->pdata;
/*
* PluginInstance* This = (PluginInstance*) instance->pdata;
*/
if (printInfo->mode == NP_FULL) {
/*
@ -342,13 +327,13 @@ NPP_Print(NPP instance, NPPrint* printInfo)
* Windows, platformPrint is a structure
* (defined in npapi.h) containing the printer name, port,
* etc.
*/
void* platformPrint =
printInfo->print.fullPrint.platformPrint;
NPBool printOne =
printInfo->print.fullPrint.printOne;
*
*
* void* platformPrint =
* printInfo->print.fullPrint.platformPrint;
* NPBool printOne =
* printInfo->print.fullPrint.printOne;
*/
/* Do the default*/
printInfo->print.fullPrint.pluginPrinted = FALSE;
}
@ -363,12 +348,13 @@ NPP_Print(NPP instance, NPPrint* printInfo)
* Macintosh, platformPrint is the printer port; on
* Windows, platformPrint is the handle to the printing
* device context.
*
*
* NPWindow* printWindow =
* &(printInfo->print.embedPrint.window);
* void* platformPrint =
* printInfo->print.embedPrint.platformPrint;
*/
NPWindow* printWindow =
&(printInfo->print.embedPrint.window);
void* platformPrint =
printInfo->print.embedPrint.platformPrint;
}
}
}

View File

@ -21,11 +21,13 @@
* Implementation of the null plugins for Unix.
*
* dp <dp@netscape.com>
* updated 5/1998 <pollmann@netscape.com>
*
*/
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/MessageB.h>
#include "npapi.h"
#include "nullplugin.h"
@ -48,7 +50,8 @@ nullPlugin_cb(Widget widget, XtPointer closure, XtPointer call_data)
switch (cb->reason) {
case XmCR_OK:
XtUnmanageChild(This->dialog);
XtDestroyWidget(This->dialog);
This->dialog = NULL; /* Don't reuse deleted dialog */
if (This->pluginsFileUrl != NULL)
{
@ -59,7 +62,7 @@ nullPlugin_cb(Widget widget, XtPointer closure, XtPointer call_data)
{
/* Insert the file URL into the JavaScript command */
sprintf(url, buf, This->pluginsFileUrl);
NPN_GetURL(This->instance, url, "_current");
NPN_GetURL(This->instance, url, TARGET);
NPN_MemFree(url);
}
}
@ -68,28 +71,40 @@ nullPlugin_cb(Widget widget, XtPointer closure, XtPointer call_data)
/* If necessary, get the default plug-ins page resource */
char* address = This->pluginsPageUrl;
if (address == NULL)
address = PLUGINSPAGE_URL;
{
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);
NPN_GetURL(This->instance, url, "PluginRegistry");
NPN_GetURL(This->instance, url, TARGET);
NPN_MemFree(url);
}
/* Update the button label and callbacks */
setAction(This, REFRESH);
}
break;
break;
case XmCR_CANCEL:
XtUnmanageChild(This->dialog);
XtDestroyWidget(This->dialog);
This->dialog = NULL; /* Don't reuse deleted dialog */
break;
}
}
void
refreshPluginList(Widget widget, XtPointer closure, XtPointer call_data)
{
PluginInstance* This = (PluginInstance*) closure;
if (!This) return;
This->refreshing = TRUE;
NPN_ReloadPlugins(TRUE);
/*
* NPN_GetURL(This->instance, REFRESH_PLUGIN_LIST, "_self");
*/
}
void
showPluginDialog(Widget widget, XtPointer closure, XtPointer call_data)
@ -119,17 +134,27 @@ showPluginDialog(Widget widget, XtPointer closure, XtPointer call_data)
xmstr = XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET);
ac = 0;
XtSetArg (av[ac], XmNvisual, This->visual); ac++;
XtSetArg (av[ac], XmNdepth, This->depth); ac++;
XtSetArg (av[ac], XmNcolormap, This->colormap); ac++;
/* Copy button attributes unless hidden (no attributes) */
if (This->visual)
{
XtSetArg (av[ac], XmNvisual, This->visual); ac++;
XtSetArg (av[ac], XmNdepth, This->depth); ac++;
XtSetArg (av[ac], XmNcolormap, This->colormap); ac++;
}
XtSetArg (av[ac], XmNallowShellResize, TRUE); ac++;
XtSetArg (av[ac], XmNdialogStyle, XmDIALOG_MODELESS); ac++;
XtSetArg (av[ac], XmNdialogType, XmDIALOG_QUESTION); ac++;
XtSetArg (av[ac], XmNdeleteResponse, XmUNMAP); ac++;
XtSetArg (av[ac], XmNautoUnmanage, False); ac++;
XtSetArg (av[ac], XmNmessageString, xmstr); ac++;
dialog = XmCreateMessageDialog(This->button, "nullpluginDialog",
av, ac);
if (!widget)
{
widget = FE_GetToplevelWidget();
}
if (!widget) return; /* This should never happen! */
dialog = XmCreateMessageDialog(widget, "nullpluginDialog", av, ac);
UnmanageChild_safe (XmMessageBoxGetChild (dialog,
XmDIALOG_HELP_BUTTON));
@ -143,6 +168,135 @@ showPluginDialog(Widget widget, XtPointer closure, XtPointer call_data)
XtManageChild(dialog);
}
/* Create the X-Motif button widget */
void
makeWidget(PluginInstance *This)
{
Widget netscape_widget;
Widget form;
Arg av[20];
int ac;
if (!This) return;
netscape_widget = XtWindowToWidget(This->display, This->window);
ac = 0;
XtSetArg(av[ac], XmNx, 0); ac++;
XtSetArg(av[ac], XmNy, 0); ac++;
XtSetArg(av[ac], XmNwidth, This->width); ac++;
XtSetArg(av[ac], XmNheight, This->height); ac++;
XtSetArg(av[ac], XmNborderWidth, 0); ac++;
XtSetArg(av[ac], XmNnoResize, True); ac++;
form = XmCreateForm(netscape_widget, "pluginForm", av, ac);
ac = 0;
XtSetArg(av[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
XtSetArg(av[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
XtSetArg(av[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
XtSetArg(av[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
XtSetArg (av[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
/* XtSetArg (av[ac], XmNlabelString, xmstr); ac++; */
This->button = XmCreatePushButton (form, "pluginButton", av, ac);
if (!This->action) This->action = GET;
setAction(This, This->action);
XtManageChild(This->button);
XtManageChild(form);
/* Popup the pluginDialog if this is the first time *
* we encounter this MimeType */
if (addToList(&head, This->type))
showPluginDialog(This->button, (XtPointer) This, NULL);
}
/* Update the button label and callbacks (unless hidden) */
void
setAction(PluginInstance *This, int action)
{
int ac;
Arg av[20];
XmString xmstr;
if (!This) return;
This->action = action;
if (action == GET)
This->message = CLICK_TO_GET;
else if (action == REFRESH)
This->message = CLICK_WHEN_DONE;
if (!This->button) return;
xmstr = XmStringCreateLtoR(This->message, XmSTRING_DEFAULT_CHARSET);
/* Update the message on the button */
ac = 0;
XtSetArg (av[ac], XmNlabelString, xmstr); ac++;
XtSetValues(This->button, av, ac);
/* Restore the original size of the button *
* NOTE: This MUST be done in a separate call *
* after the message change or else it will *
* not work. Also, note that width/height is *
* is used only because XmNXXXAtachment *
* parameters do not work */
ac = 0;
XtSetArg(av[ac], XmNheight, This->height); ac++;
XtSetArg(av[ac], XmNwidth, This->width); ac++;
XtSetValues(This->button, av, ac);
if (action == GET)
{
if (This->exists)
XtRemoveCallback (This->button, XmNactivateCallback,
refreshPluginList, (XtPointer)This);
XtAddCallback (This->button, XmNactivateCallback,
showPluginDialog, (XtPointer)This);
}
else if (action == REFRESH)
{
if (This->exists)
XtRemoveCallback (This->button, XmNactivateCallback,
showPluginDialog, (XtPointer)This);
XtAddCallback (This->button, XmNactivateCallback,
refreshPluginList, (XtPointer)This);
}
if (!This->exists) {
XtAddEventHandler (This->button, EnterWindowMask, False,
(XtEventHandler)showStatus, (XtPointer)This);
XtAddEventHandler (This->button, LeaveWindowMask, False,
(XtEventHandler)clearStatus, (XtPointer)This);
This->exists = TRUE;
}
XmStringFree(xmstr);
}
void
showStatus(Widget widget, XtPointer closure, XtPointer call_data)
{
PluginInstance *This = (PluginInstance *) closure;
if (!This) return;
if (!This->instance) return;
NPN_Status(This->instance, This->message);
}
void
clearStatus(Widget widget, XtPointer closure, XtPointer call_data)
{
PluginInstance *This = (PluginInstance *) closure;
if (!This) return;
if (!This->instance) return;
NPN_Status(This->instance, "");
}
/* MIMETypeList maintenance routines */
static Boolean

View File

@ -21,20 +21,28 @@
* Implementation of the null plugins for Unix.
*
* dp <dp@netscape.com>
* updated 5/1998 <pollmann@netscape.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 PLUGINSPAGE_URL "http://cgi.netscape.com/eng/mozilla/2.0/extensions/info.cgi"
#define MESSAGE "\
#define REFRESH_PLUGIN_LIST "javascript:navigator.plugins.refresh(true)"
#define PLUGINSPAGE_URL "http://cgi.netscape.com/cgi-bin/plug-in_finder.cgi"
#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
typedef struct _PluginInstance
{
uint16 mode;
@ -43,15 +51,22 @@ typedef struct _PluginInstance
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;
Widget button;
Widget dialog;
NPBool exists; /* Does the widget already exist? */
NPBool refreshing; /* Are we refreshing the plugin list? */
int action; /* What action should we take? (GET or REFRESH) */
} PluginInstance;
@ -66,6 +81,11 @@ extern MimeTypeElement *head;
/* Extern functions */
extern void showPluginDialog(Widget, XtPointer, XtPointer);
extern void showStatus(Widget, XtPointer, XtPointer);
extern void clearStatus(Widget, XtPointer, XtPointer);
extern void refreshPluginList(Widget, XtPointer, XtPointer);
extern int addToList(MimeTypeElement **typelist, NPMIMEType type);
extern NPMIMEType dupMimeType(NPMIMEType type);
extern Widget FE_GetToplevelWidget(void);
extern void setAction(PluginInstance *This, int action);
extern void makeWidget(PluginInstance *This);