Back to index

lightning-sunbird  0.9+nobinonly
Functions
npshell.c File Reference
#include <stdio.h>
#include <string.h>
#include "npapi.h"
#include "printplugin.h"
#include "strings.h"
#include "plstr.h"

Go to the source code of this file.

Functions

char * NPP_GetMIMEDescription (void)
NPError NPP_GetValue (NPP instance, NPPVariable variable, void *value)
NPError NPP_Initialize (void)
void NPP_Shutdown (void)
NPError NPP_New (NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
NPError NPP_Destroy (NPP instance, NPSavedData **save)
NPError NPP_SetWindow (NPP instance, NPWindow *window)
NPError NPP_NewStream (NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
int32 NPP_WriteReady (NPP instance, NPStream *stream)
int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
void NPP_StreamAsFile (NPP instance, NPStream *stream, const char *fname)
void NPP_URLNotify (NPP instance, const char *url, NPReason reason, void *notifyData)
void NPP_Print (NPP instance, NPPrint *printInfo)

Function Documentation

NPError NPP_Destroy ( NPP  instance,
NPSavedData **  save 
)

Definition at line 169 of file npshell.c.

{

    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->pluginsPrintMessage)
            NPN_MemFree(This->pluginsPrintMessage);
        NPN_MemFree(instance->pdata);
        instance->pdata = NULL;
    }

    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

NPError NPP_DestroyStream ( NPP  instance,
NPStream stream,
NPError  reason 
)

Definition at line 285 of file npshell.c.

{
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    /***** Insert NPP_DestroyStream code here *****\
    PluginInstance* This;
    This = (PluginInstance*) instance->pdata;
    \**********************************************/

    return NPERR_NO_ERROR;
}

Definition at line 73 of file npshell.c.

{
    return(MIME_TYPES_HANDLED);
}
NPError NPP_GetValue ( NPP  instance,
NPPVariable  variable,
void value 
)

Definition at line 79 of file npshell.c.

{
    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;
}

Definition at line 97 of file npshell.c.

{
    return NPERR_NO_ERROR;
}
NPError NPP_New ( NPMIMEType  pluginType,
NPP  instance,
uint16  mode,
int16  argc,
char *  argn[],
char *  argv[],
NPSavedData saved 
)

Definition at line 116 of file npshell.c.

{

    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->pluginsPrintMessage = NULL;
    This->exists = FALSE;

    /* Parse argument list passed to plugin instance */
    /* We are interested in these arguments
     *  PLUGINSPAGE = <url>
     */
    while (argc > 0)
    {
        argc --;
        if (argv[argc] != NULL)
        {
        if (!PL_strcasecmp(argn[argc], "PRINTMSG"))
            This->pluginsPrintMessage = strdup(argv[argc]);
        else if (!PL_strcasecmp(argn[argc], "HIDDEN"))
            This->pluginsHidden = (!PL_strcasecmp(argv[argc],
            "TRUE"));
        }
    }

    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

NPError NPP_NewStream ( NPP  instance,
NPMIMEType  type,
NPStream stream,
NPBool  seekable,
uint16 stype 
)

Definition at line 244 of file npshell.c.

{
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    return NPERR_NO_ERROR;
}
void NPP_Print ( NPP  instance,
NPPrint printInfo 
)

Definition at line 323 of file npshell.c.

{
    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;
    \**************************************/
            PluginInstance* This;
            NPPrintCallbackStruct* platformPrint;
            FILE *output;

            platformPrint =
                (NPPrintCallbackStruct *)(printInfo->print.embedPrint.platformPrint);

            output = (FILE*)(platformPrint->fp);
            if (output == NULL)
                return;

            
            This =  (PluginInstance*) instance->pdata;
            if (This == NULL)
                return;

            printEPSMessage(This, output, printInfo->print.embedPrint.window);

        }
    }
}

Here is the call graph for this function:

NPError NPP_SetWindow ( NPP  instance,
NPWindow window 
)

Definition at line 193 of file npshell.c.

{
    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;

#ifdef MOZ_X11
    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, "Printplugin: 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;
      printScreenMessage(This);
    }
#endif  /* #ifdef MOZ_X11 */

    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

Definition at line 111 of file npshell.c.

{
}
void NPP_StreamAsFile ( NPP  instance,
NPStream stream,
const char *  fname 
)

Definition at line 300 of file npshell.c.

{
    /***** Insert NPP_StreamAsFile code here *****\
    PluginInstance* This;
    if (instance != NULL)
        This = (PluginInstance*) instance->pdata;
    \*********************************************/
}
void NPP_URLNotify ( NPP  instance,
const char *  url,
NPReason  reason,
void notifyData 
)

Definition at line 311 of file npshell.c.

{
    /***** Insert NPP_URLNotify code here *****\
    PluginInstance* This;
    if (instance != NULL)
        This = (PluginInstance*) instance->pdata;
    \*********************************************/
}
int32 NPP_Write ( NPP  instance,
NPStream stream,
int32  offset,
int32  len,
void buffer 
)

Definition at line 272 of file npshell.c.

{
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    /* We don't want any data, kill the stream */
    NPN_DestroyStream(instance, stream, NPRES_DONE);

    return -1L;   /* don't accept any bytes in NPP_Write() */
}

Here is the call graph for this function:

int32 NPP_WriteReady ( NPP  instance,
NPStream stream 
)

Definition at line 258 of file npshell.c.

{
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    /* We don't want any data, kill the stream */
    NPN_DestroyStream(instance, stream, NPRES_DONE);

    /* Number of bytes ready to accept in NPP_Write() */
    return -1L;   /* don't accept any bytes in NPP_Write() */
}

Here is the call graph for this function: