OLE Automation in Netscape
03/22/95
Table of Context
About this document
This document pertains to the Windows Netscape Navigator version 1.1. All information in this
document will also remain valid with future revisions of Netscape for compatibility purposes.
OLE (Object Linking and Embedding) Automation is Netscape's preferred mechanism for interprocess
communication under all versions of the Windows operating system. Other forms of interprocess
communication, such as DDE (Dynamic Data Exchange), are available depending on an applicaiton's
specific needs.
This document describes the OLE Automation implementation that Netscape follows. This document assumes
that the reader has knowledge on how to implement an OLE Automation application and/or understands
OLE Automation concepts and terminology.
The NCAPI Secure Newsgroup for Windows
A secure newsgroup for the Netscape Navigator for Windows NCAPI is available.
If you have any need to discuss Windows NCAPI issues, please post your comments to the newsgroup.
The URL for the newsgroup is snews://secnews.netscape.com/netscape.ncapi.windows.
Implementation Details
Netscape automation objects follow a naming convention. Your OLE automation application does not need to follow
this convention, but Netscape's convention is listed here for informational purposes. The automation object names
are entered in the system registry as Application.Purpose.Version, where:
- Application is Netscape.
- Purpose is a word indicating the general purpose of the automation object.
- Version is the revision number of the automation object. You will need to explicity use the version of the
automation object to ensure the properties and methods of the object are consistent with what your application
expects.
All listed automation object methods and properties are declared in the Visual C++ language. This does not imply
that the methods and properties can not be accessed in a language other than Visual C++. It is assumed that the
reader has the knowledge of how to interpret the declarations or the ODL file for use in their native programming
language. The actual object description language (.odl) files used by Netscape can be found at the end of this
document to aid in your correct interpretation of the Netscape automation objects.
A type library (.tlb) is shipped with Netscape and resides in the Netscape installation directory along with the Netscape
binary. A type library generally increases the speed at which you can implement communication with the Netscape
automation objects if you are using a programming environment that utilizies type libraries.
The Netscape automation object names are currently not inserted into the system registry at installation time. A user
of Netscape will need to execute the Netscape binary at least once prior to any usage of the Netscape automation objects
by other applications.
Netscape.Network.1 Automation Object
Netscape.Network.1 provides network access and file retrieval to other applications. In short, an application using
this automation object will be able to access network data through the same mechansisms Netscape uses; including
the SSL security procotol, proxy support, SOCKS support, cache support, and the numerous Internet protocols which
Netscape natively speaks.
The methods and properties of Netscape.Network.1 are:
- short BytesReady();
- void Close();
- CString GetContentEncoding();
- long GetContentLength();
- CString GetContentType();
- CString GetErrorMessage();
- CString GetExpires();
- BOOL GetFlagFancyFTP();
- BOOL GetFlagFancyNews();
- BOOL GetFlagShowAllNews();
- CString GetLastModified();
- CString GetPassword();
- short GetServerStatus();
- long GetStatus();
- CString GetUsername();
- BOOL IsFinished();
- BOOL Open(LPCTSTR pURL, short iMethod, LPCTSTR pPostData, long lPostDataSize, LPCTSTR pPostHeaders);
- short Read(BSTR* pBuffer, short iAmount);
- CString Resolve(LPCTSTR pBase, LPCTSTR pRelative);
- void SetFlagFancyFTP(BOOL);
- void SetFlagFancyNews(BOOL);
- void SetFlagShowAllNews(BOOL);
- void SetPassword(LPCTSTR);
- void SetUsername(LPCTSTR);
Netscape.Registry.1 Automation Object
Netscape.Registry.1 is meant to provide a unified interface for external applications to register themselves with
Netscape as a viewer for a particular MIME type and/or as a handler of a particular protocol access type. Once an
application uses this automation object to register itself with Netscape, the registration is persistant over sessions of
Netscape. All registered viewers and protocol handlers must become an OLE Automation server by
implementing automation objects that are in turn used by Netscape to send the appropriate data to the viewer/protocol
handler; the exact requirements of these automation objects are listed in the sections Implementing External Streaming
Viewers and Implementing External Protocol Handlers.
The methods of Netscape.Registry.1 are:
- BOOL RegisterViewer(LPCTSTR pMimeType, LPCTSTR pRegistryName);
- BOOL RegisterProtocol(LPCTSTR pProtcol, LPCTSTR pRegistryName);
Implementing External Streaming Veiwers
External streaming viewers are applications external to Netscape which implement a special automation object which is
made known to Netscape through Netscape.Registry.1's member RegisterViewer. After this automation object has been
registered with Netscape, Netscape can then stream data of the appropriate MIME type to that object while downloading the
data from the network. Below is a description of the members which the automation object must support, and at the end
of this document you will find an example ODL file to give you the more intimate details regarding the OLE aspects of the
implementation.
Netscape will create the automation object when it has data to stream to the object. In usual OLE Automation
applications, the application will attempt to hide itself if not previously visible (not already running), and this
may or may not be the behavior you wish your application to exhibit. Also, when Netscape is finished streaming data
to the automation object, Netscape will release the object. The usual behavior would be to shut down the application if
no other OLE locks are present, which may or may not be the behavior you wish your application to exhibit.
Such details are left up to you so that you may correctly handle the specific needs of your application.
The methods of a streaming viewer are:
- void Close(short iStatus);
- short Initialize(LPCTSTR pMimeType, LPCTSTR pUrl);
- long Ready();
- void Write(BSTR* pData, long lBytes);
Implementing External Protocol Handlers
External protocol handlers are applications external to Netscape which implement a special automation object which
is made known to Netscape through Netscape.Registry.1's member RegisterProtocol. After this automation object has been
registered with Netscape, Netscape can then tell the external protocol handler to open a URL with a particular protocol
(access type; i.e. http, gopher, ftp, news, mailto, and others). Available protocol types need not stay within the bounds of
the Netscape internally handled protocol types. Please be aware that Netscape will not be able to handle the unknown
protocol type internally without the aid and registration of your external protocol handler(s). If no such registration
is present, the user will receive an invalid URL error message. Bleow is a description of the members which the
automation object must support, and at the end of this document you will find an example ODL file to give you the
more intimate details regarding the OLE implementation aspects of the object.
Netscape will create the automation object when it has a URL of the protocol type which is handled by the object. In
usual OLE Automation applications, the applciation will attempt to hide itself if not previously visible (not already
running), and this may or may not be the behavior you wish your applciation to exhibit. Also, when Netscape has
handed the URL over to the automation object, the object will be released by Netscape. The usual behavior would be to
shut down the applciation if no other OLE locks are present, which will almost certainly not be the behavior you wish
your applciation to exhibit. Such details are left up to you so that you may correctly handle the specific needs of
your applciation.
The mehtods of a protocol handler are:
- short Initialize(LPCTSTR pProtocol, LPCTSTR pUrl);
- void Open(LPCTSTR pUrl);
Object Description Language Files
- NETSCAPE.ODL
- The file used to generate the type library for the Netscape Navigator showing the exact UUIDs, OLE data types,
dispatch interfaces, method and property names, etc.
- VIEWER.ODL
- An example file which should give you the details needed for a correct implementation of an
external streaming viewer.
- PROTOCOL.ODL
- An example file which should give you the details needed for a correct implementation of an
external protocol handler.
NETSCAPE.ODL
[ uuid(41453471-3850-11CE-8193-0020AF18F905), version(1.0) ]
library netscape
{
// For the Windows 16 bit Version of Netscape, the following line should be
// importlib("stdole.tlb");
importlib("stdole32.tlb");
[ uuid(EF5F7051-385A-11CE-8193-0020AF18F905) ]
dispinterface INetwork
{
properties:
[id(1)] BSTR Username;
[id(2)] BSTR Password;
[id(3)] boolean FlagShowAllNews;
[id(4)] boolean FlagFancyFTP;
[id(5)] boolean FlagFancyNews;
methods:
[id(6)] void Close();
[id(7)] short Read(BSTR* pBuffer, short iAmount);
[id(8)] long GetStatus();
[id(9)] boolean Open(BSTR pURL, short iMethod, BSTR pPostData, long lPostDataSize, BSTR pPostHeaders);
[id(10)] BSTR GetErrorMessage();
[id(11)] short GetServerStatus();
[id(12)] long GetContentLength();
[id(13)] BSTR GetContentType();
[id(14)] BSTR GetContentEncoding();
[id(15)] BSTR GetExpires();
[id(16)] BSTR GetLastModified();
[id(17)] BSTR Resolve(BSTR pBase, BSTR pRelative);
[id(18)] boolean IsFinished();
[id(19)] short BytesReady();
};
[ uuid(EF5F7050-385A-11CE-8193-0020AF18F905) ]
coclass CNetwork
{
[default] dispinterface INetwork;
};
[ uuid(E67D6A11-4438-11CE-8CE4-0020AF18F905) ]
dispinterface IOleRegistry
{
properties:
methods:
[id(1)] boolean RegisterViewer(BSTR pMimeType, BSTR pRegistryName);
[id(2)] boolean RegisterProtocol(BSTR pProtocol, BSTR pRegistryName);
};
[ uuid(E67D6A10-4438-11CE-8CE4-0020AF18F905) ]
coclass COleRegistry
{
[default] dispinterface IOleRegistry;
};
};
VIEWER.ODL
[ uuid(00000000-0000-0000-0000-000000000000), version(1.0) ]
library OleExampleViewer
{
// For the Windows 16 bit Version, the following line should be
// importlib("stdole.tlb");
importlib("stdole32.tlb");
[ uuid(00000000-0000-0000-0000-000000000000) ]
dispinterface IExampleViewer1
{
properties:
methods:
[id(1)] void Close(short iStatus);
[id(2)] short Initialize(BSTR pMimeType, BSTR pUrl);
[id(3)] long Ready();
[id(4)] void Write(BSTR* pData, long lBytes);
};
[ uuid(00000000-0000-0000-0000-000000000000) ]
coclass ExampleViewer1
{
[default] dispinterface IExampleViewer1;
};
};
PROTOCOL.ODL
[ uuid(00000000-0000-0000-0000-000000000000), version(1.0) ]
library OleExampleProtocolHandler
{
// For the Windows 16 bit Version, the following line should be
// importlib("stdole.tlb");
importlib("stdole32.tlb");
[ uuid(00000000-0000-0000-0000-000000000000) ]
dispinterface IExampleProtocolHandler1
{
properties:
methods:
[id(1)] short Initialize(BSTR pProtocol, BSTR pUrl);
[id(2)] void Open(BSTR pUrl);
};
[ uuid(00000000-0000-0000-0000-000000000000) ]
coclass ExampleProtocolHandler1
{
[default] dispinterface IExampleProtocolHandler1;
};
};
Copyright © 1995 Netscape Communications Corporation.