TQNPInstance Class Reference
The TQNPInstance class provides a TQObject that is a web browser plugin.
More...
This class is part of the TQt Netscape Extension.
#include <tqnp.h>
Inherits TQObject.
List of all member functions.
Public Members
- ~TQNPInstance ()
- int argc () const
- const char * argn ( int i ) const
- const char * argv ( int i ) const
- enum Reason { ReasonDone = 0, ReasonBreak = 1, ReasonError = 2, ReasonUnknown = -1 }
- const char * arg ( const char * name ) const
- enum InstanceMode { Embed = 1, Full = 2, Background = 3 }
- InstanceMode mode () const
- const char * userAgent () const
- virtual TQNPWidget * newWindow ()
- TQNPWidget * widget ()
- enum StreamMode { Normal = 1, Seek = 2, AsFile = 3, AsFileOnly = 4 }
- virtual bool newStreamCreated ( TQNPStream *, StreamMode & smode )
- virtual int writeReady ( TQNPStream * )
- virtual int write ( TQNPStream *, int offset, int len, void * buffer )
- virtual void streamDestroyed ( TQNPStream * )
- void status ( const char * msg )
- void getURLNotify ( const char * url, const char * window = 0, void * data = 0 )
- void getURL ( const char * url, const char * window = 0 )
- void postURL ( const char * url, const char * window, uint len, const char * buf, bool file )
- TQNPStream * newStream ( const char * mimetype, const char * window, bool as_file = FALSE )
- virtual void streamAsFile ( TQNPStream *, const char * fname )
- void * getJavaPeer () const
- virtual void notifyURL ( const char * url, Reason r, void * notifyData )
- virtual bool printFullPage ()
- virtual void print ( TQPainter * )
Protected Members
Detailed Description
This class is defined in the TQt Netscape Extension, which can be found in the qt/extensions directory. It is not included in the main TQt API.
The TQNPInstance class provides a TQObject that is a web browser plugin.
Deriving from TQNPInstance creates an object that represents a
single <EMBED> tag in an HTML document.
The TQNPInstance is responsible for creating an appropriate
TQNPWidget 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 guarantee regarding the order
in which functions are called. Sometimes the browser will call
newWindow() first, at other times, newStreamCreated() will be
called first (assuming the <EMBED> tag has a SRC parameter).
None of TQt's GUI functionality may be used until after the
first call to newWindow(). This includes any use of TQPaintDevice
(i.e. TQPixmap, TQWidget, and all subclasses), TQApplication, anything
related to TQPainter (TQBrush, etc.), fonts, TQMovie, TQToolTip, etc.
Useful classes which specifically can be used are TQImage,
TQFile, and TQBuffer.
This restriction can easily be accommodated by structuring your
plugin so that the task of the TQNPInstance is to gather data,
while the task of the TQNPWidget is to provide a graphical
interface to that data.
Member Type Documentation
TQNPInstance::InstanceMode
This enum type provides TQt-style names for three #defines in
npapi.h:
- TQNPInstance::Embed - corresponds to NP_EMBED
- TQNPInstance::Full - corresponds to NP_FULL
- TQNPInstance::Background - corresponds to NP_BACKGROUND
TQNPInstance::Reason
- TQNPInstance::ReasonDone
- TQNPInstance::ReasonBreak
- TQNPInstance::ReasonError
- TQNPInstance::ReasonUnknown
TQNPInstance::StreamMode
- TQNPInstance::Normal
- TQNPInstance::Seek
- TQNPInstance::AsFile
- TQNPInstance::AsFileOnly
Member Function Documentation
TQNPInstance::TQNPInstance () [protected]
Creates a TQNPInstance.
Can only be called from within a derived class created within
TQNPlugin::newInstance().
TQNPInstance::~TQNPInstance ()
Called when the plugin instance is about to be deleted.
const char * TQNPInstance::arg ( const char * name ) const
Returns the value of the named arguments, or 0 if no argument
called 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:
Tag | Result
|
<EMBED ...> | arg("FOO") == 0
|
<EMBED FOO ...> | arg("FOO") == ""
|
<EMBED FOO=BAR ...> | arg("FOO") == "BAR"
|
int TQNPInstance::argc () const
Returns the number of arguments to the instance. Note that you
should not normally rely on the ordering of arguments, and
note that the SGML specification does not permit multiple
arguments with the same name.
See also arg() and argn().
const char * TQNPInstance::argn ( int i ) const
Returns the name of the i-th argument.
See also argc() and argv().
const char * TQNPInstance::argv ( int i ) const
Returns the value of the i-th argument.
\as argc(), arg()
void * TQNPInstance::getJavaPeer () const
Returns the Java object associated with the plugin instance, an
object of the plugin'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 TQNPlugin::getJavaClass() and TQNPlugin::getJavaEnv().
void TQNPInstance::getURL ( const char * url, const char * window = 0 )
Requests that the url be retrieved and sent to the named window. See Netscape's JavaScript documentation for an explanation
of window names.
void TQNPInstance::getURLNotify ( const char * url, const char * window = 0, void * data = 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. Passes the arguments including data to NPN_GetURLNotify.
Netscape: NPN_GetURLNotify method
InstanceMode TQNPInstance::mode () const
Returns the mode of the plugin.
TQNPStream * TQNPInstance::newStream ( const char * mimetype, const char * window, bool as_file = FALSE )
This function is under development and is subject to change.
This function is not tested.
Requests the creation of a new data stream from the plugin.
The MIME type and window are passed in mimetype and window.
as_file holds the AsFileOnly flag. It is an interface to the
NPN_NewStream function of the Netscape Plugin API.
bool TQNPInstance::newStreamCreated ( TQNPStream *, 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 returned
by the most recent call to writeReady().
Note that the AsFileOnly method is not supported by Netscape
2.0 and MSIE 3.0.
The default implementation accepts any stream.
TQNPWidget * TQNPInstance::newWindow () [virtual]
Called at most once, at some time after the TQNPInstance is
created. If the plugin requires a window, this function should
return a derived class of TQNPWidget that provides the required
interface.
Example: grapher/grapher.cpp.
void TQNPInstance::notifyURL ( const char * url, Reason r, void * notifyData ) [virtual]
This function is under development and is subject to change.
This function is not tested.
Called whenever a url is notified after a call to
NPN_GetURLNotify with notifyData. The reason is given in r.
It is an encapsulation of the NPP_URLNotify function of the
Netscape Plugin API.
See also:
Netscape: NPP_URLNotify method
void TQNPInstance::postURL ( const char * url, const char * window, uint len, const char * buf, bool file )
This function is under development and is subject to change.
This function is not tested.
It is an interface to the NPN_PostURL function of the Netscape
Plugin API.
Passes url, window, buf, len, and file to
NPN_PostURL.
void TQNPInstance::print ( TQPainter * ) [virtual]
This function is under development and is subject to change.
This function is not tested.
Print the instance embedded in a page.
It is an encapsulation of the NPP_Print function of the Netscape
Plugin API.
bool TQNPInstance::printFullPage () [virtual]
This function is under development and is subject to change.
This function is not tested.
It is an encapsulation of the NPP_Print function of the Netscape
Plugin API.
void TQNPInstance::status ( const char * msg )
Sets the status message in the browser containing this instance to
msg.
void TQNPInstance::streamAsFile ( TQNPStream *, const char * fname ) [virtual]
Called when a stream is delivered as a single file called fname
rather than as chunks. This may be simpler for a plugin to deal
with, but precludes any incremental behavior.
Note that the AsFileOnly method is not supported by Netscape
2.0 and MSIE 3.0.
See also newStreamCreated() and newStream().
void TQNPInstance::streamDestroyed ( TQNPStream * ) [virtual]
Called when a stream is destroyed. At this point, 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.
const char * TQNPInstance::userAgent () const
Returns the user agent (browser name) containing this instance.
TQNPWidget * TQNPInstance::widget ()
Returns the plugin window created by newWindow(), if any.
int TQNPInstance::write ( TQNPStream *, 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.
Example: grapher/grapher.cpp.
int TQNPInstance::writeReady ( TQNPStream * ) [virtual]
Returns the minimum amount of data the instance is willing to
receive from the given stream.
The default returns a very large value.
This file is part of the TQt toolkit.
Copyright © 1995-2007
Trolltech. All Rights Reserved.