QNPInstance(3qt)

NAME
QNPInstance - A QObject that is a Web-browser plugin [Qt NSPlugin Extension]

SYNOPSIS

#include <qnp.h>

Inherits QObject.

  Public Members
~QNPInstance ()
int argc () const
const char* argn ( int ) const
const char* argv ( int ) const
const char* arg ( const char * name ) const
InstanceMode mode () const
const char* userAgent () const
virtual QNPWidget* newWindow ()
QNPWidget* widget ()
virtual bool newStreamCreated ( QNPStream *, StreamMode & smode )
virtual int writeReady ( QNPStream * )
virtual int write ( QNPStream *, int offset, int len, void * buffer )
virtual void streamDestroyed ( QNPStream * )
void status ( const char * msg )
void getURL ( const char * url, const char * window=0 )
void postURL ( const char * url, const char * window, uint len, const char * buf, bool file )
QNPStream* newStream ( const char * mimetype, const char * window, bool as_file=FALSE )
virtual void streamAsFile ( QNPStream *, const char * fname )
void* getJavaPeer () const
virtual bool printFullPage ()
virtual void print ( QPainter * )

  Protected Members
QNPInstance ()

DESCRIPTION
This class is defined in the Qt NSPlugin Extension, which can be found in the qt/extensions directory. It is not included in the main Qt API.

a QObject that is a Web-browser plugin

Deriving from QNPInstance creates an object that represents a single <EMBED> tag in an HTML document.

The QNPInstance is responsible for creating an appropriate window if required (not all plugins have windows), and for interacting with the input/output facilities intrinsic to plugins.

Note that there is absolutely no garrantee as to the order in which functions are called. Sometimes the browser will call setWindow() first, at other times, newStreamCreated() will be called first (assuming the <EMBED> tag has a SRC parameter).

No GUI functionality of Qt may be used until the first call to setWindow(). This includes any use of QPaintDevice (ie. QPixmap, QWidget, and all subclasses), QApplication, anything related to QPainter (QBrush, etc.), fonts, QMovie, QToolTip, etc. Useful classes which specifically can be used are QImage, QFile, and QBuffer.

By structuring your plugin so that the task of the QNPInstance is to gather data, while the task of the QNPWidget is to provide a graphical interface to that data, this restriction can be easily accommodated.

Examples: qtimage/qtimage.cpp grapher/grapher.cpp trivial/trivial.cpp

MEMBER FUNCTION DOCUMENTATION

QNPInstance::QNPInstance () [protected]
Creates a QNPInstance. Can only be called from within a derived class created within QNPlugin::newInstance().

QNPInstance::~QNPInstance ()
Called when the plugin instance is about to disappear.

const char* QNPInstance::arg ( const char * name ) const
Returns the value of the named arguments, or 0 if no argument with that name appears in the <EMBED> tag of this instance. If the argument appears, but has no value assigned, the empty string is returned. In summary:

<EMBED ...> - arg("FOO") == 0

<EMBED FOO ...> - arg("FOO") == ""

<EMBED FOO=BAR ...> - arg("FOO") == "BAR"

int QNPInstance::argc () const
Returns the number of arguments to the instance. Note that you should not normally rely on the ordering of arguments, and also note that the SGML specification does not permit multiple arguments with the same name.

See also: arg().

const char* QNPInstance::argn ( int i ) const
Returns the name of the ith argument. See notes of argc().

const char* QNPInstance::argv ( int i ) const
Returns the value of the ith argument. See notes of argc().

void* QNPInstance::getJavaPeer () const
Returns the Java object associated with the plug-in instance, an object of the plug-in's Java class, or 0 if the plug-in does not have a Java class, Java is disabled, or an error occurred .

The return value is actually a jref we use void* so as to avoid burdening plugins which do not require Java.

See also: QNPlugin::getJavaClass(), QNPlugin::getJavaEnv(), getJavaPeer() and Netscape: NPN_GetJavaPeer

void QNPInstance::getURL ( const char * url, const char * window=0 )
Requests that the given URL be retrieved and sent to the named window. See Netscape's JavaScript documentation for an explanation of window names.

See also: Netscape: NPN_GetURL method

Examples: grapher/grapher.cpp

QNPInstance::InstanceMode QNPInstance::mode() const
Returns the mode of the plugin.

QNPStream* QNPInstance::newStream ( const char * mimetype, const char * window, bool as_file=FALSE )
Requests the creation of a new data stream from the plug-in. This function is not tested. It is an interface to the NPN_NewStream function of the Netscape Plugin API.

See also: Netscape: NPN_NewStream method

bool QNPInstance::newStreamCreated ( QNPStream *, StreamMode & smode ) [virtual]
This function is called when a new stream has been created. The instance should return TRUE if it accepts the processing of the stream. If the instance requires the stream as a file, it should set smode to AsFileOnly, in which case the data will be delivered some time later to the streamAsFile() function. Otherwise, the data will be delivered in chunks to the write() function which must consume at least as much data as was returned by the most recent call to writeReady().

Note that the AsFileOnly method is not supported by Netscape 2.0 and MS-Explorer 3.0. A future version of Qt will hide this problem.

See also: Netscape: NPP_NewStream method

QNPWidget* QNPInstance::newWindow () [virtual]
Called at most once, at some time after the QNPInstance is created. If the plugin requires a window, this function should return a derived class of QNPWidget that provides the required interface.

void QNPInstance::postURL ( const char * url, const char * window, uint len, const char * buf, bool file )
This function is not tested. It is an interface to the NPN_PostURL function of the Netscape Plugin API.

See also: Netscape: NPN_PostURL method

void QNPInstance::print ( QPainter * ) [virtual]
Print the instance embedded in a page.

This function is not tested. It is an encapsulation of the NPP_Print function of the Netscape Plugin API.

See also: Netscape: NPP_Print method

bool QNPInstance::printFullPage () [virtual]
Print the instance full-page. By default, this returns FALSE, causing the browser to call the (embedded) print() function instead.

This function is not tested. It is an encapsulation of the NPP_Print function of the Netscape Plugin API.

See also: Netscape: NPP_Print method

void QNPInstance::status ( const char * msg )
Sets the status message in the browser containing this instance.

See also: Netscape: NPN_Status method

void QNPInstance::streamAsFile ( QNPStream *, const char * ) [virtual]
Called when a stream is delivered as a single file rather than as chunks. This may be simpler for a plugin to deal with, but precludes any incremental behaviour.

See also: newStreamCreated(), newStream(), Note, that, the, AsFileOnly, method, is, not, supported, by, Netscape, 2.0, MS-Explorer, 3.0., See, also: and Netscape: NPP_StreamAsFile method

void QNPInstance::streamDestroyed ( QNPStream * ) [virtual]
Called when a stream is destroyed. At this this, the stream may be complete() and okay(). If it is not okay(), then an error has occurred. If it is okay(), but not complete(), then the user has cancelled the transmission - do not give an error message in this case.

See also: Netscape: NPP_DestroyStream method

const char* QNPInstance::userAgent () const
Returns the user agent (browser name) containing this instance.

See also: Netscape: NPN_UserAgent method

QNPWidget* QNPInstance::widget ()
Returns the plugin window created at newWindow(), if any.

Examples: grapher/grapher.cpp

int QNPInstance::write ( QNPStream *, int offset, int len, void * buffer ) [virtual]
Called when incoming data is available for processing by the instance. The instance must consume at least the amount that it returned in the most recent call to writeReady(), but it may consume up to the amount given by len. buffer is the data available for consumption. The offset argument is merely an informational value indicating the total amount of data that has been consumed in prior calls.

This function should return the amount of data actually consumed.

See also: Netscape: NPP_NewStream method

int QNPInstance::writeReady ( QNPStream * ) [virtual]
Called to inquire the minimum amount of data the instance is willing to receive from the given stream.

The default returns a very large value.

See also: Netscape: NPP_WriteReady method

SEE ALSO
http://www.troll.no/qt/qnpinstance.html

COPYRIGHT
Copyright 1992-1997 Troll Tech AS. See the LICENSE file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.