Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIEVENTSSAMPLEINSTANCE
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)
 EventsPluginInstance ()
virtual ~EventsPluginInstance ()
void PlatformNew (void)
nsresult PlatformDestroy (void)
void PlatformResetWindow ()
PRInt16 PlatformHandleEvent (nsPluginEvent *event)
void PlatformResizeWindow (nsPluginWindow *window)
nsresult PlatformCreateWindow (nsPluginWindow *window)
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

readonly attribute
nsIPluginInstancePeer 
peer
 Returns a reference back to the plugin instance peer.
attribute string val

Protected Member Functions

nsresult DoSetWindow (nsPluginWindow *window)

Protected Attributes

nsCOMPtr< nsIPluginInstancePeerfPeer
nsPluginWindowfWindow
nsPluginMode fMode
PlatformInstance fPlatform
WinID wMain
WinID wChild

Detailed Description

Definition at line 129 of file npevents.cpp.


Constructor & Destructor Documentation

Definition at line 371 of file npevents.cpp.

Definition at line 377 of file npevents.cpp.

                                                {
}

Member Function Documentation

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

Definition at line 280 of file npevents.cpp.

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

    EventsPluginInstance* plugin = new EventsPluginInstance();
    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 434 of file npevents.cpp.

                                            {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::Destroy\n");
#endif 

       PlatformDestroy(); // Perform platform specific cleanup
       return NS_OK;
}

Here is the call graph for this function:

Definition at line 467 of file npevents.cpp.

                                                                 {
       /*
        * 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.
        */
        nsresult result = NS_OK;
       if ( fWindow != NULL ) {
              // If we already have a window, clean it up 
              // before working with the new window
              if ( window && window->window && wMain == (WinID)window->window ) {
                     /* The new window is the same as the old one. Exit now. */
                     PlatformResizeWindow(window);
                     return NS_OK;
              }
              // Otherwise, just reset the window ready for the new one.
              PlatformResetWindow();
       }
       else if ( (window == NULL) || ( window->window == NULL ) ) {
              /* We can just get out of here if there is no current
               * window and there is no new window to use. */ 
              return NS_OK;
       }
       if (window && window->window) {
              // Remember our main parent window.
              wMain = (WinID)window->window;
              // And create the child window.
              result = PlatformCreateWindow(window);
       }
       return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 408 of file npevents.cpp.

                                                                      {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::GetPeer\n");
#endif 

       *result = fPeer;
       NS_IF_ADDREF(*result);
       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 581 of file npevents.cpp.

                                                                             {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::GetValue\n");
#endif 

       return NS_ERROR_FAILURE;
}

Definition at line 572 of file npevents.cpp.

                                                                                 {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::HandleEvent\n");
#endif 

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

Here is the call graph for this function:

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

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 381 of file npevents.cpp.

                                                                      {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::Initialize\n");
#endif 

       NS_ASSERTION(peer != NULL, "null peer");

       fPeer = peer;
       nsCOMPtr<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;

       taginfo = do_QueryInterface(peer, &result);
       if (NS_SUCCEEDED(result)) {
              taginfo->GetAttributes(count, names, values);
       }

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

Here is the call graph for this function:

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 501 of file npevents.cpp.

                                                                            {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::NewStream\n");
#endif 

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

       return NS_OK;
}

Here is the caller graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

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 518 of file npevents.cpp.

                                                              {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::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 EventsPluginInstance::RegisterSelf ( nsIComponentManager aCompMgr,
nsIFile aPath,
const char *  aRegistryLocation,
const char *  aComponentType,
const nsModuleComponentInfo info 
) [static]

Definition at line 298 of file npevents.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(kEventsPluginCID,
                                kPluginName,
                                kPluginDescription,
                                kMimeTypes,
                                kMimeDescriptions,
                                kFileExtensions,
                                kNumMimeTypes);

        NS_RELEASE(pm);
    }

    return rv;
}

Here is the call graph for this function:

Definition at line 195 of file npevents.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 456 of file npevents.cpp.

                                                                {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::SetWindow\n");
#endif 

       nsresult result;
       result = DoSetWindow(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 418 of file npevents.cpp.

                                          {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::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 426 of file npevents.cpp.

                                         {
#ifdef EVENTSPLUGIN_DEBUG
       printf("EventsPluginInstance::Stop\n");
#endif 

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

Definition at line 335 of file npevents.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(kEventsPluginCID);
        NS_RELEASE(pm);
    }

    return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 205 of file npevents.cpp.

Definition at line 203 of file npevents.cpp.

Definition at line 206 of file npevents.cpp.

Definition at line 204 of file npevents.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.

Definition at line 44 of file nsIEventsPluginInstance.idl.

WinID EventsPluginInstance::wChild [protected]

Definition at line 209 of file npevents.cpp.

WinID EventsPluginInstance::wMain [protected]

Definition at line 208 of file npevents.cpp.


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