Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes
SimplePluginInstance Class Reference
Inheritance diagram for SimplePluginInstance:
Inheritance graph
[legend]
Collaboration diagram for SimplePluginInstance:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISCRIPTABLEPLUGIN
NS_DECL_NSISIMPLEPLUGININSTANCE
NS_IMETHOD 
HandleEvent (nsPluginEvent *event, PRBool *handled)
NS_IMETHOD Initialize (nsIPluginInstancePeer *peer)
NS_IMETHOD GetPeer (nsIPluginInstancePeer **result)
NS_IMETHOD Start (void)
NS_IMETHOD Stop (void)
NS_IMETHOD Destroy (void)
NS_IMETHOD SetWindow (nsPluginWindow *window)
NS_IMETHOD NewStream (nsIPluginStreamListener **listener)
NS_IMETHOD Print (nsPluginPrint *platformPrint)
NS_IMETHOD GetValue (nsPluginInstanceVariable variable, void *value)
 SimplePluginInstance (void)
virtual ~SimplePluginInstance (void)
void PlatformNew (void)
nsresult PlatformDestroy (void)
nsresult PlatformSetWindow (nsPluginWindow *window)
PRInt16 PlatformHandleEvent (nsPluginEvent *event)
void SetMode (nsPluginMode mode)
void initialize (in nsIPluginInstancePeer aPeer)
 Initializes a newly created plugin instance, passing to it the plugin instance peer which it should use for all communication back to the browser.
void start ()
 Called to instruct the plugin instance to start.
void stop ()
 Called to instruct the plugin instance to stop, thereby suspending its state.
void destroy ()
 Called to instruct the plugin instance to destroy itself.
void setWindow (in nsPluginWindowPtr aWindow)
 Called when the window containing the plugin instance changes.
void newStream (out nsIPluginStreamListener aListener)
 Called to tell the plugin that the initial src/data stream is ready.
void print (in nsPluginPrintPtr aPlatformPrint)
 Called to instruct the plugin instance to print itself to a printer.
void getValue (in nsPluginInstanceVariable aVariable, in voidPtr aValue)
 Returns the value of a variable associated with the plugin instance.
void handleEvent (in nsPluginEventPtr aEvent, out boolean aHandled)
 Handles an event.

Static Public Member Functions

static NS_METHOD Create (nsISupports *aOuter, REFNSIID aIID, void **aResult)
static NS_METHOD RegisterSelf (nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aRegistryLocation, const char *aComponentType, const nsModuleComponentInfo *info)
static NS_METHOD UnregisterSelf (nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aRegistryLocation, const nsModuleComponentInfo *info)

Public Attributes

char * fText
readonly attribute
nsIPluginInstancePeer 
peer
 Returns a reference back to the plugin instance peer.
readonly attribute nsQIResult scriptablePeer
 The object to be wrapped and exposed to JavaScript.
readonly attribute nsIIDPtr scriptableInterface
 The interface that XPConnect should use when exposing the peer object to JavaScript.
attribute string text

Protected Attributes

nsIPluginInstancePeerfPeer
nsPluginWindowfWindow
nsPluginMode fMode
PlatformInstance fPlatform

Detailed Description

Definition at line 188 of file npsimple.cpp.


Constructor & Destructor Documentation

Definition at line 514 of file npsimple.cpp.

    : fText(NULL), fPeer(NULL), fWindow(NULL), fMode(nsPluginMode_Embedded)
{
    static const char text[] = "Hello World!";
    fText = (char*) nsMemory::Clone(text, sizeof(text));

#ifdef XP_UNIX
    fPlatform.moz_box = nsnull;
    fPlatform.superwin = nsnull;
    fPlatform.label = nsnull;
#endif

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 528 of file npsimple.cpp.

{
    if(fText)
        nsMemory::Free(fText);
    PlatformDestroy(); // Perform platform specific cleanup
}

Here is the call graph for this function:


Member Function Documentation

NS_METHOD SimplePluginInstance::Create ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 431 of file npsimple.cpp.

{
    NS_PRECONDITION(aOuter == nsnull, "no aggregation");
    if (aOuter)
        return NS_ERROR_NO_AGGREGATION;

    SimplePluginInstance* plugin = new SimplePluginInstance();
    if (! plugin)
        return NS_ERROR_OUT_OF_MEMORY;

    nsresult rv;
    NS_ADDREF(plugin);
    rv = plugin->QueryInterface(aIID, aResult);
    NS_RELEASE(plugin);
    return rv;
}

Here is the call graph for this function:

Called to instruct the plugin instance to destroy itself.

This is called when it become no longer possible to return to the plugin instance, either because the browser window's history list of pages is being trimmed, or because the window containing this page in the history is being closed.

Returns:
- NS_OK if this operation was successful

Definition at line 625 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::Destroy\n");
#endif

    return NS_OK;
}

Definition at line 593 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::GetPeer\n");
#endif

    fPeer->AddRef();
    *result = fPeer;
    return NS_OK;
}
void nsIPluginInstance::getValue ( in nsPluginInstanceVariable  aVariable,
in voidPtr  aValue 
) [inherited]

Returns the value of a variable associated with the plugin instance.

Parameters:
aVariable- the plugin instance variable to get
aValue- the address of where to store the resulting value
Returns:
- NS_OK if this operation was successful

Definition at line 813 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::GetValue\n");
#endif

    return NS_ERROR_FAILURE;
}
void nsIPluginInstance::handleEvent ( in nsPluginEventPtr  aEvent,
out boolean  aHandled 
) [inherited]

Handles an event.

An nsIEventHandler can also get registered with with nsIPluginManager2::RegisterWindow and will be called whenever an event comes in for that window.

Note that for Unix and Mac the nsPluginEvent structure is different from the old NPEvent structure -- it's no longer the native event record, but is instead a struct. This was done for future extensibility, and so that the Mac could receive the window argument too. For Windows and OS2, it's always been a struct, so there's no change for them.

(Corresponds to NPP_HandleEvent.)

Parameters:
aEvent- the event to be handled
aHandled- set to PR_TRUE if event was handled
Returns:
- NS_OK if this operation was successful

Definition at line 802 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::HandleEvent\n");
#endif

    *handled = (PRBool)PlatformHandleEvent(event);
    return NS_OK;
}

Here is the call graph for this function:

Initializes a newly created plugin instance, passing to it the plugin instance peer which it should use for all communication back to the browser.

Parameters:
aPeer- the corresponding plugin instance peer
Returns:
- NS_OK if this operation was successful

Definition at line 552 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::Initialize\n");
#endif
    
    NS_ASSERTION(peer != NULL, "null peer");

    fPeer = peer;
    nsIPluginTagInfo* taginfo;
    const char* const* names = nsnull;
    const char* const* values = nsnull;
    PRUint16 count = 0;
    nsresult result;

    peer->AddRef();
    result = peer->GetMode(&fMode);
    if (NS_FAILED(result)) return result;

   result = peer->QueryInterface(NS_GET_IID(nsIPluginTagInfo), (void **)&taginfo);

    if (NS_SUCCEEDED(result))
    {
        taginfo->GetAttributes(count, names, values);
        NS_IF_RELEASE(taginfo);
    }

#ifdef NS_DEBUG
    printf("Attribute count = %d\n", count);

    for (int i = 0; i < count; i++)
    {
        printf("plugin param=%s, value=%s\n", names[i], values[i]);
    }
#endif

    PlatformNew();   /* Call Platform-specific initializations */
    return NS_OK;
}

Called to tell the plugin that the initial src/data stream is ready.

Expects the plugin to return a nsIPluginStreamListener.

(Corresponds to NPP_NewStream.)

Parameters:
aListener- listener the browser will use to give the plugin the data
Returns:
- NS_OK if this operation was successful

Definition at line 670 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::NewStream\n");
#endif

    if(listener != NULL)
    {
        SimplePluginStreamListener* sl = 
                new SimplePluginStreamListener(this, "http://www.mozilla.org");
        if(!sl)
            return NS_ERROR_UNEXPECTED;
        sl->AddRef();
        *listener = sl;
    }
    
    return NS_OK;
}

Definition at line 1386 of file npsimple.cpp.

Here is the caller graph for this function:

Definition at line 1398 of file npsimple.cpp.

{
    int16 eventHandled = FALSE;
    return eventHandled;
}

Here is the caller graph for this function:

Definition at line 1381 of file npsimple.cpp.

{
}

Definition at line 1392 of file npsimple.cpp.

Here is the caller graph for this function:

void nsIPluginInstance::print ( in nsPluginPrintPtr  aPlatformPrint) [inherited]

Called to instruct the plugin instance to print itself to a printer.

(Corresponds to NPP_Print.)

Parameters:
aPlatformPrint- platform-specific printing information
Returns:
- NS_OK if this operation was successful

Definition at line 745 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::Print\n");
#endif

    if (printInfo == NULL)
        return NS_ERROR_FAILURE;

    if (printInfo->mode == nsPluginMode_Full) {
        /*
         * PLUGIN DEVELOPERS:
         *    If your plugin would like to take over
         *    printing completely when it is in full-screen mode,
         *    set printInfo->pluginPrinted to TRUE and print your
         *    plugin as you see fit.  If your plugin wants Netscape
         *    to handle printing in this case, set
         *    printInfo->pluginPrinted to FALSE (the default) and
         *    do nothing.  If you do want to handle printing
         *    yourself, printOne is true if the print button
         *    (as opposed to the print menu) was clicked.
         *    On the Macintosh, platformPrint is a THPrint; on
         *    Windows, platformPrint is a structure
         *    (defined in npapi.h) containing the printer name, port,
         *    etc.
         */

        /* Do the default*/
        printInfo->print.fullPrint.pluginPrinted = PR_FALSE;
    }
    else {    /* If not fullscreen, we must be embedded */
        /*
         * PLUGIN DEVELOPERS:
         *    If your plugin is embedded, or is full-screen
         *    but you returned false in pluginPrinted above, NPP_Print
         *    will be called with mode == nsPluginMode_Embedded.  The nsPluginWindow
         *    in the printInfo gives the location and dimensions of
         *    the embedded plugin on the printed page.  On the
         *    Macintosh, platformPrint is the printer port; on
         *    Windows, platformPrint is the handle to the printing
         *    device context.
         */
    }
    return NS_OK;
}
NS_METHOD SimplePluginInstance::RegisterSelf ( nsIComponentManager aCompMgr,
nsIFile aPath,
const char *  aRegistryLocation,
const char *  aComponentType,
const nsModuleComponentInfo info 
) [static]

Definition at line 449 of file npsimple.cpp.

{
    nsresult rv;

    nsIServiceManager *svcMgr;
    rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
                                  NS_REINTERPRET_CAST(void**, &svcMgr));
    if (NS_FAILED(rv))
        return rv;

    nsIPluginManager* pm;
    rv = svcMgr->GetService(kPluginManagerCID,
                            NS_GET_IID(nsIPluginManager),
                            NS_REINTERPRET_CAST(void**, &pm));
    NS_RELEASE(svcMgr);

    if (NS_SUCCEEDED(rv)) {
        rv = pm->RegisterPlugin(kSimplePluginCID,
                                kPluginName,
                                kPluginDescription,
                                kMimeTypes,
                                kMimeDescriptions,
                                kFileExtensions,
                                kNumMimeTypes);

        NS_RELEASE(pm);
    }

    return rv;
}

Here is the call graph for this function:

Definition at line 285 of file npsimple.cpp.

{ fMode = mode; }

Called when the window containing the plugin instance changes.

(Corresponds to NPP_SetWindow.)

Parameters:
aWindow- the plugin window structure
Returns:
- NS_OK if this operation was successful

Definition at line 649 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::SetWindow\n");
#endif

    nsresult result;

    /*
     * PLUGIN DEVELOPERS:
     * Before setting window to point to the
     * new window, you may wish to compare the new window
     * info to the previous window (if any) to note window
     * size changes, etc.
     */
    result = PlatformSetWindow(window);
    fWindow = window;
    return result;
}

Here is the call graph for this function:

void nsIPluginInstance::start ( ) [inherited]

Called to instruct the plugin instance to start.

This will be called after the plugin is first created and initialized, and may be called after the plugin is stopped (via the Stop method) if the plugin instance is returned to in the browser window's history.

Returns:
- NS_OK if this operation was successful

Definition at line 605 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::Start\n");
#endif

    return NS_OK;
}
void nsIPluginInstance::stop ( ) [inherited]

Called to instruct the plugin instance to stop, thereby suspending its state.

This method will be called whenever the browser window goes on to display another page and the page containing the plugin goes into the window's history list.

Returns:
- NS_OK if this operation was successful

Definition at line 615 of file npsimple.cpp.

{
#ifdef NS_DEBUG
    printf("SimplePluginInstance::Stop\n");
#endif

    return NS_OK;
}
NS_METHOD SimplePluginInstance::UnregisterSelf ( nsIComponentManager aCompMgr,
nsIFile aPath,
const char *  aRegistryLocation,
const nsModuleComponentInfo info 
) [static]

Definition at line 486 of file npsimple.cpp.

{
    nsresult rv;

    nsIServiceManager *svcMgr;
    rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
                                  NS_REINTERPRET_CAST(void**, &svcMgr));
    if (NS_FAILED(rv))
        return rv;

    nsIPluginManager* pm;
    rv = svcMgr->GetService(kPluginManagerCID,
                            NS_GET_IID(nsIPluginManager),
                            NS_REINTERPRET_CAST(void**, &pm));
    NS_RELEASE(svcMgr);

    if (NS_SUCCEEDED(rv)) {
        rv = pm->UnregisterPlugin(kSimplePluginCID);
        NS_RELEASE(pm);
    }

    return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 301 of file npsimple.cpp.

Definition at line 299 of file npsimple.cpp.

Definition at line 302 of file npsimple.cpp.

Definition at line 296 of file npsimple.cpp.

Definition at line 300 of file npsimple.cpp.

Returns a reference back to the plugin instance peer.

This method is used whenever the browser needs to obtain the peer back from a plugin instance. The implementation of this method should be sure to increment the reference count on the peer by calling AddRef.

Parameters:
aPeer- the resulting plugin instance peer
Returns:
- NS_OK if this operation was successful

Definition at line 96 of file nsIPluginInstance.idl.

readonly attribute nsIIDPtr nsIScriptablePlugin::scriptableInterface [inherited]

The interface that XPConnect should use when exposing the peer object to JavaScript.

All scriptable methods on the interface will be available to JavaScript.

Definition at line 58 of file nsIScriptablePlugin.idl.

readonly attribute nsQIResult nsIScriptablePlugin::scriptablePeer [inherited]

The object to be wrapped and exposed to JavaScript.

It should be an XPCOM object, and it can be the same object as the plugin.

Definition at line 51 of file nsIScriptablePlugin.idl.

Definition at line 48 of file nsISimplePluginInstance.idl.


The documentation for this class was generated from the following file: