NPN_MemAlloc |
NPN_MemFlush |
NPN_MemFree |
|
Three methods, from the Netscape group of Plug-in API methods, handle memory in plug-ins. See Chapter 7, "Memory," for information about using these methods. [Top] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
Allocates memory from Communicator's memory space
#include <npapi.h> void *NPN_MemAlloc (uint32 size);
size |
Size of memory, in bytes, to allocate in Communicator's memory space. |
Since Communicator and plug-ins share the same memory space, NPN_MemAlloc allows plug-ins to take advantage of any customized memory allocation scheme the application may have, and allows the application to manage its memory more flexibly and efficiently.
NPN_MemFlush, NPN_MemFree"Allocating and Freeing Memory"
[Top] [Memory Methods] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
Requests that Communicator free a specified amount of memory
#include <npapi.h> uint32 NPN_MemFlush(uint32 size);
size |
Size of memory, in bytes, to free in the Communicator's memory space. |
On Mac OS, you can use this method to free memory before calling memory-intensive Mac Toolbox calls.
In general, plug-ins should use NPN_MemAlloc to allocate memory in Communicator's memory space, since this function automatically frees cached data if necessary to fulfill the request.
With Communicator 4.x on Mac OS, NPN_MemFlush is not necessary for the Mac OS platform. NPN_MemAlloc now performs memory flushing internally. Existing calls to NPN_MemFlush have no effect.
NPN_MemFlush, NPN_MemFree"Flushing Memory (Mac OS only)"
[Top] [Memory Methods] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
#include <npapi.h> void NPN_MemFree (void* ptr);
ptr |
Block of memory previously allocated using NPN_MemAlloc. |
NPN_MemAlloc, NPN_MemFlush"Allocating and Freeing Memory"
[Top] [Memory Methods] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
NPN_ReloadPlugins |
NPN_UserAgent |
NPN_Status |
NPN_Version |
Netscape Communicator provides a variety of services to the plug-in through the Netscape method group. The functions in this section provide status line messages to the user, help identify the browser and the version of the Plug-in API that is currently in use, and reload plug-ins without restarting Communicator.
See Chapter 8, "Version, UI, and Status Information," for information about using these methods.
[Top] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
Reloads all plug-ins in the Plugins directory
#include <npapi.h> void NPN_ReloadPlugins(NPBool reloadPages);
reloadPages |
Whether to reload pages. Values: |
Communicator knows about all installed plug-ins at start-up. If you add or remove any plug-ins, Communicator does not see them until you restart it. NPN_ReloadPlugins allows you to install a new plug-in and load it, or to remove a plug-in, without having to restart Communicator. You could use this function as part of the plug-in's SmartUpdate process.
NPN_Version[Top] [Utility Methods] [Plug-in API Methods: Functional Subgroups] [API Organization: Netscape and Plug-in Methods]
#include <npapi.h> void NPN_Status(NPP instance, const char* message);
instance |
Pointer to the current plug-in instance. |
message |
Pointer the buffer that contains the status message string to display. |
Communicator always displays the last status line message it receives, regardless of the message source. Your message is always displayed, but you have no control over how long it stays in the status line before another message replaces it.
NPN_UserAgent, NPP"Displaying a Status Line Message"
[Top] [Utility Methods] [Plug-in API Methods: Functional Subgroups] [API Organization: Netscape and Plug-in Methods]
#include <npapi.h> const char* NPN_UserAgent(NPP instance);
instance |
Pointer to the current plug-in instance. |
NPN_Status, NPN_Version"Getting Agent Information"
[Top] [Utility Methods] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
#include <npapi.h> void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor);
You can use NPN_Version to inquire on version constants (NPVERS constants), which represent particular Communicator features. Once the plug-in obtains a version number, it can inquire on a version constant to find out if the feature it represents exists in this version. For example, the plug-in could inquire on the constant NPVERS_HAS_WINDOWLESS to see if it is running in a version of Communicator that supports windowless functionality. For more information and an example, see "Finding Out if a Feature Exists." For a listing of version constants defined in the Plug-in API, see "Version Feature Constants."
NOTE: Platform-specific code in the Plug-in API files npwin.cpp, npmac.cpp, or npunix.c checks version numbers automatically. A plug-in whose major version is less than the major version of Communicator is not loaded. §
NPN_UserAgent, NPP_Initialize"Getting the Current Version," "Finding Out if a Feature Exists," "Version Feature Constants"
[Top] [Utility Methods] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
NPP_GetJavaClass |
NPN_GetJavaPeer |
NPN_GetJavaEnv |
|
Communicating with Java and JavaScript offers many advantages to the plug-in, including improved handling of sound, graphics, and video and using Java and JavaScript controls. By using a Netscape LiveConnect connection (new with Communicator 3.0), a plug-in can communicate directly with Java and, through Java, with JavaScript. These Netscape and Plug-in methods associate the Java class and environment with the plug-in.
For an introduction to these methods, see "Communicating with Java." For a discussion of all the issues involved in creating LiveConnected plug-ins, see LiveConnecting Plug-ins with Java.
[Top] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
Returns the Java class associated with the plug-in
#include <npapi.h> jref NPP_GetJavaClass(void);
If you want a plug-in to communicate with Java and, through Java, with JavaScript, you must define a Java class for it. This class allows Java to call plug-in methods. Depending on the purpose of the plug-in, you can use Java's Plugin (the default plug-in class), or subclass from Plugin.
Call NPP_GetJavaClass during plug-in initialization to find the plug-in's associated Java class. If the plug-in does not have one, it should return null. Otherwise, use the javah-generated "use_" function to both initialize your class and return it. If the plug-in class can't be found, "use_" sends an error that is displayed to the user.
This method is used only to allow the plug-in to communicate with Java, for example, when using LiveConnect, and is not necessary for basic Plug-in API support. For more information and instructions, read about calling plug-in native methods from Java in LiveConnecting Plug-ins with Java.
NPN_GetJavaEnv, NPN_GetJavaPeerLiveConnecting Plug-ins with Java.
[Top] [Methods for Communicating with Java] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
Returns a pointer to the Java execution environment
#include <npapi.h> JRIEnv* NPN_GetJavaEnv(void);
In order to invoke Java methods from native code, the plug-in must pass its Java execution environment in any JRI calls it makes. The environment is a handle on the Java interpreter; it serves both as a dispatching mechanism to call JRI operations and an encapsulation of the current Java execution thread. The first time you call NPN_GetJavaEnv, allow time as the interpreter may have to initialize itself.
This method is used only to allow the plug-in to communicate with Java, for example, when using LiveConnect, and is not necessary for basic Plug-in API support. For more information and instructions, read about accessing Java methods from plug-ins in LiveConnecting Plug-ins with Java.
NPP_GetJavaClass, NPN_GetJavaPeerLiveConnecting Plug-ins with Java
[Top] [Methods for Communicating with Java] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]
Returns the Java object associated with the plug-in instance
#include <npapi.h> jref NPN_GetJavaPeer(NPP instance);
instance |
Pointer to the current plug-in instance. |
Before using NPN_GetJavaPeer, you must provide a Java class for the plug-in and implement NPN_GetJavaClass to return that class.
The Java object is created only when NPN_GetJavaPeer is called for the first time. This way, you do not start the Java interpreter unless you need the plug-in. However, JavaScript may call this method in order to talk to a plug-in on a web page.
This method is used only to allow the plug-in to communicate with Java, for example, when using LiveConnect, and is not necessary for basic Plug-in API support. For more information and instructions, read about calling plug-in methods from Java in LiveConnecting Plug-ins with Java.
NPP_GetJavaClass, NPN_GetJavaEnvLiveConnecting Plug-ins with Java
[Top] [Methods for Communicating with Java] [Reference to Functions by Functional Group] [API Organization: Netscape and Plug-in Methods]