Distribution: COMPANY CONFIDENTIAL Project: Java/Shockwave/Browser Issue: 0.10 Author(s): Steve Hunt, Rhodri James, Simon Middleton Date: 04-Sep-96 Last Issue: 0.09
0.01 SAH 02-Apr-96 Started 0.02 SAH 07-Jun-96 Revised message formats 0.03 RMJ 25-Jul-96 Added more messages 0.04 RMJ 30-Jul-96 Inserted message numbers 0.05 SJM 14-Aug-96 Altered message blocks for consistency 0.06 SJM 19-Aug-96 Extended protocol to add stream support 0.07 SJM 27-Aug-96 Opening bits and version numbers 0.08 SJM 28-Aug-96 Parameter file tweaks 0.09 SJM 30-Aug-96 Info on system variables 0.10 SJM 04-Sep-96 STATUS message
The idea of a "plug-in" is to integrate the display of such data into the WWW browser's own window. A number of proposed HTML extensions are being promoted, such as <APPLET> (by Sun for Java), <EMBED> (by Netscape) and <OBJECT> (by W3C).
This model does not fit well with RISC OS practices. We do not have a standard scheme for DLLs, and the alternative - using relocatable modules - is not practical for very large playback engines for systems like Java and Director. Therefore it is proposed to implement plug-ins as separate Wimp tasks, with a special message protocol between the browser and the plug-in to permit communication and control.
In order to display the data inside the browser's own window, the plug-in needs to be made responsible for updating a certain portion of the browser's work area. This could be done by the browser instructing the plug-in to redraw parts of the window. However, this approach is rejected because it introduces significant differences between a plug-in and a normal wimp application. Instead, we utilise a new facililty that is being added to the Wimp, whereby windows can be created "inside" a parent window. The Wimp takes care of event distribution to the plug-in, and also ensures that the "child" window is in a fixed position relative to the work-area of the parent - so the plug-in's display area will be scrolled within the browser window if the user manipulates the browser window's scrollbars.
Just as normal RISC OS apps may be "single document" or "multiple document", a plug-in implementor may choose whether to handle multiple items at once or not. Ideally, plug-ins should be able to cope with multiple pieces of data, potentially owned by multiple client applications. However, for ease of implementation it may sometimes be preferred to restrict each instance of a plug-in to displaying one piece of data. In this case, were two such pieces of data to be displayed at once, it would be necessary to invoke the plug-in twice.
If further data of the same type needs to be displayed, either simultaneously or sequentially, then the browser should repeat the whole process starting with the broadcast.
If the plugin receives a keypress or mouse button click that it does not want to handle, it should pass it on to the browser by means of Wimp_SendMessage. It should set the window handle field of the message to the handle of its parent window. Note that this should be used instead of Wimp_ProcessKey.
If the browser wishes to forcibly resize or reposition the subwindow, it should send a MESSAGE_PLUGIN_RESHAPE message to the plug-in, quoting the plug-in instance handle. The plug-in must honour this request by re-opening itself at the new position. The coordinates in this request are work-area coordinates of the parent window. The parent window handle in this message may be different to the original one. The plugin should be prepeared to check for this, and re-create its window as a child of the new parent if necessary.
If the plugin wishes to alter its size, it cannot simply resize its window. Instead it must send a MESSAGE_PLUGIN_RESHAPE_REQUEST to the browser. The browser should respond by reformatting the page (if necessary) and then replying with a suitable MESSAGE_PLUGIN_RESHAPE. The plugin will act on this in the normal way.
Many of the strings passed around in this protocol are of unspecified size and may, especially in the case of URL's, be larger than could fit within the body of a wimp message. Therefore they are defined in this spec as string_values. These are also used in the Browser spec and are defined as being either offsets from the start of the message body (if less than 256) or as pointers to data held in shared memory (ie the RMA or a dynamic area). It is always the responsibility of the sender to free the memory used for any such pointers. The protocol is defined in such a way that there should always be a reply received or the message will be bounced by the wimp. In either case it is then safe for the sender to free the memory allocated.
However to avoid memory leaks it is recommended that careful track is kept of such pointers so that they can be freed when a plugin instance is closed.
Some plugins may wish the browser to fetch data from the net for them rather than having to implement their own fetching code. A flexible interface is provided for this based, in port, on the API used in the de facto standard plugin API created by Netscape, in order to facilitate porting plugins to the NC.
There are several ways a stream can be instigated, as follows
This is repeated until all data is transferred or an error occurs.
For a plugin yyyy whose file type is xxx the variables set should include
For example eg a sample !Boot file might go something like this
Set Java$Dir <Obey$Dir> Set File$Type_AE4 Java Set PlugIn$Type_AE4 Java SetMacro Alias$@RunType_AE4 /<Java$Dir>.!RunImage -standalone %%*0 SetMacro Alias$@PlugInType_AE4 /<Java$Dir>.!RunImage -plugin %%*0
If a file is embedded with APPLET, EMBED or OBJECT then the Alias$@PlugInType_xxx variable is used to start the application.
If a file is pointer to with an anchor (eg <A HREF="applets/myapplet.class">) then the file will be downloaded and the Alias$@Runtype_xxx variable will be used.
Note that plugins should be able to be launched from an OBJECT tag as well as EMBED or APPLET. When this happens there are some minor differences to the values in the parameter file.
For EMBED
For APPLET
Sent by the browser to create a plugin instance.
R1+16 Message_PlugIn_Open Common fields R1+20 Flags (reserved, must be zero) R1+24 reserved R1+28 Browser instance handle (invented by the browser) R1+32 Parent window handle R1+36 Left (bounding box in parent's R1+40 Bottom work area co-ordinates) R1+44 Right R1+48 Top R1+52 File type R1+56 File name (string_value)
The file specified by "Filename" contains a series of parameters in the form of name-value pairs. This data is the list of attributes and parameters from the APPLET, OBJECT or EMBED tag - see their respective definitions. This data is used by the plugin to understand what is being requested of it - see Data formats for details.
Sent by the plugin task to say an instance has been created.
R1+12 my_ref field from Message_PlugIn_Open R1+16 Message_PlugIn_Opening Common fields R1+20 Flags Bit 0: 1 = plugin can accept input focus 0 = plugin cannot use input focus Bit 1: 1 = plugin wants code resource fetched 0 = plugin will fetch code resource itself Bit 2: 1 = plugin wants data resource fetched 0 = plugin will data code resource itself Bit 3: 1 = plugin will delete the parameter file itself 0 = parent should delete parameter file now R1+24 Plugin instance handle (invented by the plugin) R1+28 Browser instance handle (copied from Message_PlugIn_Open)
R1+16 Message_PlugIn_Close Common fields R1+20 Flags Bit 0: Browser would also like plugin to exit Other bits reserved, must be zero. R1+24 Plugin instance handle to close R1+28 Browser instance handle
R1+12 my_ref field from Message_PlugIn_Close R1+16 Message_PlugIn_Closed Common fields R1+20 Flags Bit 0: Plugin will exit after this message Bit 1: This message is NOT in reply to a Message_PlugIn_Close. Bit 2: Set if there is an error message at R1+32 Other bits reserved, must be zero. R1+24 Plugin instance handle of the closed instance R1+28 Browser instance handle of the closed instance If flags bit 2 is set: R1+32 Error number. R1+36 Zero-terminated message to be displayed by the browser. (NB This message is always embedded here as the plugin may be exiting).
R1+12 my_ref field from Message_PlugIn_Request (if applicable) R1+16 Message_PlugIn_Reshape Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle R1+32 Parent window handle R1+36 Left (bounding box in parent's R1+40 Bottom work area co-ordinates) R1+44 Right R1+48 Top
R1+16 Message_PlugIn_Reshape_Request Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle R1+32 Width (in OS units) R1+36 Height
R1+16 Message_Plugin_Focus Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle
This message is used to transfer the input focus between a plugin and its parent. It can be sent in either direction. If the recipient cannot or does not wish to accept the focus then it just ignores the message. Otherwise it should acknowledge the message with message type 19 to prevent it being bounced back to the originator.
R1+16 Message_Plugin_Unlock Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle R1+32 URL for which to unlock the cache file (string_value)
R1+16 Message_Plugin_StreamNew Common fields R1+20 Flags Bits 0-3: stream type field = 0: normal = 1: seek only = 2: as file = 3: as file only Bit 4: 1 = stream is seekable R1+24 Plugin instance handle R1+28 Browser instance handle Common stream fields R1+32 Plugin stream instance handle R1+36 Browser stream instance handle R1+40 URL of stream source/dest (string_value) R1+44 end of stream in bytes, or 0 if unknown R1+48 last modified data of URL R1+52 notify data R1+56 mime type of URL (string_value) R1+60 window target (string_value)
R1+16 Message_Plugin_StreamDestroy Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle Common stream fields R1+32 Plugin stream instance handle R1+36 Browser stream instance handle R1+40 URL of stream source/dest (string_value) R1+44 end of stream in bytes, or 0 if unknown R1+48 last modified data of URL R1+52 notify data R1+56 Reason
R1+16 Message_Plugin_StreamWrite Common fields R1+20 Flags Bits 0-3: Data type field = 0: string_value = 1: anchor = 2: file handle R1+24 Plugin instance handle R1+28 Browser instance handle Common stream fields R1+32 Plugin stream instance handle R1+36 Browser stream instance handle R1+40 URL of stream source/dest (string_value) R1+44 end of stream in bytes, or 0 if unknown R1+48 last modified data of URL R1+52 notify data R1+56 Logical offset in stream of data R1+60 Length of data R1+64 Data ptr
R1+12 my_ref field from Message_PlugIn_StreamWrite R1+16 Message_Plugin_StreamWritten Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle Common stream fields R1+32 Plugin stream instance handle R1+36 Browser stream instance handle R1+40 URL of stream source/dest (string_value) R1+44 end of stream in bytes, or 0 if unknown R1+48 last modified data of URL R1+52 notify data R1+56 Length of data consumed, < 0 if error
R1+16 Message_Plugin_StreamAsFile Common fields R1+20 Flags (reserved, must be zero) R1+24 Plugin instance handle R1+28 Browser instance handle Common stream fields R1+32 Plugin stream instance handle R1+36 Browser stream instance handle R1+40 URL of stream source/dest (string_value) R1+44 end of stream in bytes, or 0 if unknown R1+48 last modified data of URL R1+52 notify data R1+56 file name of stream data (string_value)
R1+16 Message_Plugin_URLAccess Common fields R1+20 Flags Bit 0: 1 = return a NOTIFY message on completion Bit 1: 1 = POST to the URL 0 = GET from the URL If bit 1 = 1 Bit 2: 1 = POST a file 0 = POST a block of memory R1+24 Plugin instance handle R1+28 Browser instance handle R1+32 URL to access (string_value) R1+36 window target (string_value) R1+40 notify data to be returned R1+44 length of data to be posted If bit 2=1 R1+48 file name (string_value) If bit 2=0 R1+48 ptr to data (string_value)
If the window target is non-null then the url is fetched to the given window name. Otherwise a stream is opened and data is sent to the plugin.
R1+16 Message_Plugin_URLNotify Common fields R1+20 Flags (reserved) R1+24 Plugin instance handle R1+28 Browser instance handle R1+32 URL accessed (string_value) R1+36 reason for notify R1+40 notify data
R1+16 Message_Plugin_Status Common fields R1+20 Flags (reserved) R1+24 Plugin instance handle R1+28 Browser instance handle R1+32 status message (string_value)
Requests that the parent display some information in its status bar or similar. The message should be reasonably short.
The file contains the concatenation of one or more binary records of the form:-
4 bytes type: 0 = terminator (this is the last word in the file) 1 = data from PARAM 2 = URL from PARAM 3 = object ref PARAM 4 = special parameter from browser 5 = data from OBJECT/APPLET 6 = URL from OBJECT/APPLET 4 bytes m = size of record (without header) (4+n+p) + (4+s+q) + (4+t+r) 4 bytes n = size of name (unpadded) n bytes Name p bytes Padding to word boundary 4 bytes s = size of data (unpadded) s bytes Data q bytes Padding to word boundary 4 bytes t = size of mime type (unpadded) t bytes Mime type r bytes Padding to word boundary
Integers are stored in little-endian order.
Flags (parameters with void value whose presence or absence only is significant) are represented by a parameter of type DATA with zero length.
The parameters include:-
These parameters are passed exactly as seen in the HTML without any conversions. The data/url/ref distinction is as given in the DTD (for OBJECT attributes) or in the VALUETYPE attribute of the PARAM element.
See Browser specifications for a list of possible parameters. The plug-in may implement its own URL fetching code, or it may have the Browser fetch URLs on its behalf by issuing a URL_ACCESS message to the browser.
Special parameters are created by the browser (rather than being part of the object element). They are:-
Released versions of this API that plugins should know about are listed below, with the most recent version at the top.