OS/2 Differences, Steps, Files
Differences in an OS/2 Plug-In
The OS/2 interface to plug-ins differs from the Windows documentation in
the following ways:
- Coordinates passed in
NPP_SetWindow
and
NPP_Print
are based on the origin
being bottom-left with height extending upwards and width extending to the right.
- The window passed by
NPP_SetWindow
is of class "Netscape Plugin Window" and has
a class style of CS_MOVENOTIFY.
- The platformPrint field in the
NPFullPrint
and
NPEmbedPrint
data structures passed by
NPP_Print
is an HPS.
-
Netscape methods
(NPN_*) should always be made on thread 1.
- Returning FALSE from
NPP_Print
with a full-page embed will allow Navigator to print the plug-in on your behalf.
The plug-in data is reloaded for the display window as a result of this.
- For a plug-in to receive keystrokes that the Navigator uses for accelerator keys, like CTRL and SHIFT,
you must subclass the "Netscape Plugin Window" and return FALSE on WM_TRANSLATEACCEL messages.
- For
Windowless plug-ins the platform-specific drawable is an HPS.
Creating an OS/2 Plug-In
In order to create an OS/2 plug-in you need a C++ compiler, such as
IBM's Visual Age C++ version 3.0 compiler.
- Create a directory on your hard drive for the plug-in project. For
example, you might call this directory OS2PLUG.
- Download the OS/2 Plug-in Software Development Kit to the directory
you created for the plug-in project.
- The download file is compressed and needs to be decompressed.
If you are using pkunzip to decompress the
file, use the -d flag to maintain the directory structure stored in
the zip file. A readme file is placed in the directory. The following
directory structure is created:
-
\common
contains common build files NPOS2.CPP
-
\doc
contains this documentation
-
\include
contains header files NPAPI.H and NPUPP.H
-
\sample\npclock
directory contains a plug-in that displays a clock. The clock plug-in responds
to an additional attributes in the
EMBED
tag named TRANSPARENCY. The two valid values are ON and OFF.
-
\sample\npdraw
directory contains a plug-in that streams a drawing. A random draw data file
can be generated by building and running the GENDATA.EXE program.
-
\sample\npshell
directory contains a template of the files you use to create a new plug-in
-
\sample\npsimple
directory contains a template of the files you use to create a new plug-in
-
\test
contains test HTML files for the plug-in samples
- Create a new subdirectory to work in. For example,
C:\OS2PLUG\SAMPLES\MYPLUG.
- Copy all the directories and files in the \sample\npshell directory into
your new working directory. In addition, copy into this directory any
auxiliary plug-in specific files you have created. For example, you
may have written code to implement window handling functionality.
- Using your compiler, open the existing makefile in your working
directory.
- Edit the resource file NPSHELL.RC
to include the correct information. You must change the MIME type and
the file extension values. For example, if you were creating the NPDRAW
plug-in, your resource file would look like this:
#include "npapi.h"
RCDATA NP_INFO_ProductVersion { 1,0,0,1, }
RCDATA NP_INFO_MIMEType {"Sample/Draw"}
RCDATA NP_INFO_FileExtents {"drw"}
RCDATA NP_INFO_FileOpenName {"OS/2 Streaming Draw Plugin"}
NOTE: There is a problem in the OS/2 resource compiler that causes
an error if the '}'
is appended to the first RCDATA type (NP_INFO_ProductVersion in the above
example) without
the extra comma. You can also move the last brace to the next line to
avoid the compile error.
- To include multiple MIME types in the plug-in, use a vertical bar to
delimit each value in the MIME type. For example, VALUE "MIMEType",
"sample/bmp|sample/gif". MIME types must be paired with file extensions
and descriptions.
For the previous example, the extensions should be "bmp|gif" and the file
descriptions would be "bitmap files|gif files".
- Save the resource file. The resource file allows Netscape to query
the plug-in without having to load it in memory.
- Open the file npshell.cpp. This is a compilable shell file that
provides the framework for creating a plug-in. By working in
npshell.cpp, you simply fill in the necessary code for basic plug-in
functionality.
- In npshell.cpp, write the code for the functions needed for your
plug-in. The Plug-In Application Programming Interface provides a
detailed description of each function. You may want to take a look at
the other samples.
- Save the npshell.cpp file.
- Using your compiler, build the project. The file npshell.dll is created.
You can get a debug version by specifying
OPT=DEBUG
on the command line and a dynamically-linked DLL by specifying
CRT=DYNAMIC.
- Copy the dll file (npshell.dll) into the PLUGINS
subdirectory of Navigator. If the plug-in has associated
files, create a separate subdirectory and places the files there.
NOTE: The Simple.class file of the npsimple.dll plugin
must be copied to the plugins directory or into a directory found in the
CLASSPATH=.
- Restart Navigator. When Netscape Navigator starts up, it looks in
the PLUGINS subdirectory for plug-in modules in that directory and any subdirectories.
- From the Help menu of Navigator, choose About Plug-ins. A list of
all plug-ins in the directory is displayed. You should see your Mime
type listed.
- Test your plug-in by creating an HTML document.
- Navigator will only accept plug-in dlls with file names begining with 'np'.
OS/2 Files
When you unzip the OS/2 Plug-in Software Development Kit, several subdirectories
are automatically created in your working directory.
The contents of each directory include:
\common Directory
- npos2.cpp - Passes plug-in function pointers to Netscape for
communication and contains shell functions for Navigator entry
points. This file also implements version checking. You should not
need to change this file.
\include Directory
- npapi.h - Plug-in header file for plug-in entry points and callback to
Netscape.
- npupp.h - Function pointer tables and DLL entry point definitions.
- jni.h - Java Netscape Interface include
- jni_md.h - Java Netscape Interface include
- jri.h - Java Runtime Interface include
- jri_md.h - Java Runtime Interface include
- jritypes.h - Java Runtime Interface include
\sample\npclock Directory
- build.cmd - Sets up environment for building with IBM VisualAge C++ 3.0
- npclock.cpp - main line for plug-in
- clock.h - constants for resource
- clock.hpp - class header for Clock class
- clock.cpp - class implementation for Clock class
- npclock.rc - resources
- npclock.def - def file
- makefile - A IBM VisualAge C++ 3.0 make file for plug-ins.
\sample\npdraw Directory
- build.cmd - Sets up environment for building with IBM VisualAge C++ 3.0
- npdraw.cpp - main line for plug-in
- npdraw.h - constants
- npdraw.rc - resources
- npdraw.def - def file
- makefile - A IBM VisualAge C++ 3.0 make file for plug-ins.
- gendata.cpp - source to generate random data
- gendata.def - def file for GENDATA.EXE
- gendata.mak - Makefile for GENDATA.EXE
\samples\npshell Directory
- build.cmd - Sets up environment for building with IBM VisualAge C++ 3.0
- npshell.cpp - Shell implementation of all plug-in methods. This
file also includes suggestions (as comments) on plug-in development
as applicable to a specific method. You use this file to create your
own plug-in.
- npshell.rc - resources
- npshell.def - Used by the linker to resolve export symbols for
plug-in entry points. You should not need to change this file.
- makefile - A IBM VisualAge C++ 3.0 make file for plug-ins.
\samples\npsimple Directory
- build.cmd - Sets up environment for building with IBM VisualAge C++ 3.0 and
any version of Java that is supported by this browser that is in c:\java11
- npsimple.cpp - Simple LiveConnect Sample Plug-in. This
file also includes suggestions (as comments) on plug-in development
as applicable to a specific method. You use this file to create your
own plug-in.
- simple.j - Java code to perform Live-Connect.(needs to be renamed to Simple.java)
- npsimple.rc - resources
- npsimple.def - Used by the linker to resolve export symbols for
plug-in entry points. You should not need to change this file.
- makefile - A IBM VisualAge C++ 3.0 and Java make file for plug-ins.
\test Directory
- clock.clk - data file for clock plug-in
- clock.htm - HTML to display clock plug-in
- draw.lst - data file for draw plug-in
- draw.htm - HTML to display draw plug-in
- npshell.htm - HTML for shell plug-in
- npshell.smp - data file for shell plug-in
- npsimple.htm - HTML for simple plug-in
- npsimple.sim - data file for simple plug-in