Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Static Public Attributes | Package Functions | Private Attributes | Static Private Attributes
MRJPlugin Class Reference

#include <MRJPlugin.h>

Inheritance diagram for MRJPlugin:
Inheritance graph
[legend]
Collaboration diagram for MRJPlugin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MRJPlugin ()
virtual ~MRJPlugin ()
void operator delete (void *ptr)
NS_IMETHOD QueryInterface (const nsIID &aIID, void **aInstancePtr)
 MRJPlugin aggregates MRJConsole, so that it can be QI'd to be an nsIJVMConsole.
 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
NS_IMETHOD CreateInstance (nsISupports *aOuter, const nsIID &aIID, void **aResult)
NS_IMETHOD LockFactory (PRBool aLock)
NS_IMETHOD CreatePluginInstance (nsISupports *aOuter, REFNSIID aIID, const char *aPluginMIMEType, void **aResult)
 Creates a new plugin instance, based on the MIME type.
NS_IMETHOD Initialize (void)
 Initializes the plugin and will be called before any new instances are created.
NS_IMETHOD Shutdown (void)
 Called when the browser is done with the plugin factory, or when the plugin is disabled by the user.
NS_IMETHOD GetMIMEDescription (const char **result)
 Returns the MIME description for the plugin.
NS_IMETHOD GetValue (nsPluginVariable variable, void *value)
 Returns the value of a variable associated with the plugin.
NS_IMETHOD SetValue (nsPluginVariable variable, void *value)
NS_IMETHOD StartupJVM (void)
NS_IMETHOD ShutdownJVM (PRBool fullShutdown)
NS_IMETHOD AddToClassPath (const char *dirPath)
NS_IMETHOD RemoveFromClassPath (const char *dirPath)
NS_IMETHOD GetClassPath (const char **result)
NS_IMETHOD GetJavaWrapper (JNIEnv *env, jint jsobj, jobject *jobj)
NS_IMETHOD GetJavaVM (JavaVM **result)
 GetJNIEnv (JNIEnv **result)
 ReleaseJNIEnv (JNIEnv *env)
NS_IMETHOD CreateSecureEnv (JNIEnv *proxyEnv, nsISecureEnv **outSecureEnv)
 This creates a new secure communication channel with Java.
NS_IMETHOD SpendTime (PRUint32 timeMillis)
 Gives time to the JVM from the main event loop of the browser.
NS_IMETHOD Run ()
 The Run method gives time to the JVM periodically.
MRJSessiongetSession ()
nsIJVMManagergetManager ()
nsIThreadManagergetThreadManager ()
MRJPluginInstancegetPluginInstance (jobject applet)
MRJPluginInstancegetPluginInstance (JNIEnv *jenv)
Boolean inPluginThread ()
NS_IMETHOD UnwrapJavaWrapper (JNIEnv *jenv, jobject jobj, jint *obj)
native Object getField (String name, String signature)
native void setField (String name, String signature, Object value)
native Object callMethod (String name, String signature, Object[] args)
 MRJPlugin ()
virtual ~MRJPlugin ()
NS_IMETHOD QueryInterface (const nsIID &aIID, void **aInstancePtr)
 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
NS_IMETHOD CreateInstance (nsISupports *aOuter, const nsIID &aIID, void **aResult)
NS_IMETHOD LockFactory (PRBool aLock)
NS_IMETHOD CreatePluginInstance (nsISupports *aOuter, REFNSIID aIID, const char *aPluginMIMEType, void **aResult)
 Creates a new plugin instance, based on the MIME type.
NS_IMETHOD Initialize (void)
 Initializes the plugin and will be called before any new instances are created.
NS_IMETHOD Shutdown (void)
 Called when the browser is done with the plugin factory, or when the plugin is disabled by the user.
NS_IMETHOD GetMIMEDescription (const char **result)
 Returns the MIME description for the plugin.
NS_IMETHOD GetValue (nsPluginVariable variable, void *value)
 Returns the value of a variable associated with the plugin.
nsresult StartupJVM (void)
NS_IMETHOD AddToClassPath (const char *dirPath)
NS_IMETHOD RemoveFromClassPath (const char *dirPath)
NS_IMETHOD GetClassPath (const char **result)
NS_IMETHOD GetJavaWrapper (JNIEnv *env, jint jsobj, jobject *jobj)
NS_IMETHOD CreateSecureEnv (JNIEnv *proxyEnv, nsISecureEnv **outSecureEnv)
 This creates a new secure communication channel with Java.
NS_IMETHOD SpendTime (PRUint32 timeMillis)
 Gives time to the JVM from the main event loop of the browser.
NS_IMETHOD UnwrapJavaWrapper (JNIEnv *jenv, jobject jobj, jint *obj)
NS_IMETHOD Show (void)
 Poor Man's Mac OS X Java Console implementation.
NS_IMETHOD Hide (void)
NS_IMETHOD IsVisible (PRBool *result)
NS_IMETHOD Print (const char *msg, const char *encodingName=NULL)
NS_IMETHOD Run ()
 The Run method gives time to the JVM periodically.
MRJSessiongetSession ()
nsIJVMManagergetManager ()
nsIThreadManagergetThreadManager ()
MRJPluginInstancegetPluginInstance (jobject applet)
MRJPluginInstancegetPluginInstance (JNIEnv *jenv)
Boolean inPluginThread ()
void createPluginInstance (in nsISupports aOuter, in nsIIDRef aIID, in string aPluginMIMEType,[retval, iid_is(aIID)] out nsQIResult aResult)
 Creates a new plugin instance, based on a MIME type.
void initialize ()
 Initializes the plugin and will be called before any new instances are created.
void shutdown ()
 Called when the browser is done with the plugin factory, or when the plugin is disabled by the user.
void getMIMEDescription (out constCharPtr aMIMEDescription)
 Returns the MIME description for the plugin.
void getValue (in nsPluginVariable aVariable, in voidPtr aValue)
 Returns the value of a variable associated with the plugin.
void createInstance (in nsISupports aOuter, in nsIIDRef iid,[retval, iid_is(iid)] out nsQIResult result)
 Creates an instance of a component.
void lockFactory (in PRBool lock)
 LockFactory provides the client a way to keep the component in memory until it is finished with it.
void run ()
nsresult queryInterface (const nsIID &aIID, void **aInstancePtr)
 The lowercase implementations of queryInterface, addRef, and release all act locally on the current object, regardless of aggregation.
nsresult queryInterface (const nsIID &aIID, void **aInstancePtr)
nsrefcnt addRef (void)
nsrefcnt addRef (void)
nsrefcnt release (void)
nsrefcnt release (void)

Static Public Member Functions

static nsresult GetService (const nsCID &aCID, const nsIID &aIID, void **aService)
static nsresult GetService (const char *aContractID, const nsIID &aIID, void **aService)
static nsresult GetService (const nsCID &aCID, const nsIID &aIID, void **aService)
static nsresult GetService (const char *aContractID, const nsIID &aIID, void **aService)

Static Public Attributes

static const char * PLUGIN_VERSION = "eerieQuarkDoll.v.b1"

Package Functions

 MRJPlugin ()

Private Attributes

nsIJVMManagermManager
nsIThreadManagermThreadManager
MRJSessionmSession
MRJConsolemConsole
nsPluginThreadmPluginThreadID
Boolean mIsEnabled

Static Private Attributes

static const InterfaceInfo sInterfaces []
static const UInt32 kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo)

Detailed Description

Definition at line 65 of file MRJPlugin.h.


Constructor & Destructor Documentation

Definition at line 207 of file MRJPlugin.cpp.

       :      SupportsMixin(this, sInterfaces, kInterfaceCount),
              mManager(NULL), mThreadManager(NULL), mSession(NULL), mConsole(NULL), mIsEnabled(false), mPluginThreadID(NULL)
{
    // make this singleton instance visible.
    ::thePlugin = this;
}
MRJPlugin::~MRJPlugin ( ) [virtual]

Definition at line 215 of file MRJPlugin.cpp.

{
    // make sure the plugin is no longer visible.
    ::thePlugin = NULL;

    // Release the console.
    NS_IF_RELEASE(mConsole);

    // tear down the MRJ session, if it exists.
    delete mSession;

    // Release the manager?
    NS_IF_RELEASE(mManager);
    NS_IF_RELEASE(mThreadManager);
}
MRJPlugin.MRJPlugin ( ) [inline, package]

Definition at line 44 of file MRJPlugin.java.

{}
virtual MRJPlugin::~MRJPlugin ( ) [virtual]

Member Function Documentation

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]

Here is the caller graph for this function:

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]
NS_IMETHOD MRJPlugin::AddToClassPath ( const char *  dirPath) [virtual]

Implements nsIJVMPlugin.

NS_METHOD MRJPlugin::AddToClassPath ( const char *  dirPath) [virtual]

Implements nsIJVMPlugin.

Definition at line 442 of file MRJPlugin.cpp.

{
       if (mSession != NULL) {
              mSession->addToClassPath(dirPath);
              return NS_OK;
       }
       return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

native Object MRJPlugin.callMethod ( String  name,
String  signature,
Object[]  args 
)
void nsIFactory::createInstance ( in nsISupports  aOuter,
in nsIIDRef  iid,
[retval, iid_is(iid)] out nsQIResult  result 
) [inherited]

Creates an instance of a component.

Parameters:
aOuterPointer to a component that wishes to be aggregated in the resulting instance. This will be nsnull if no aggregation is requested.
iidThe IID of the interface being requested in the component which is being currently created.
result[out] Pointer to the newly created instance, if successful.
Returns:
NS_OK - Component successfully created and the interface being requested was successfully returned in result. NS_NOINTERFACE - Interface not accessible. NS_ERROR_NO_AGGREGATION - if an 'outer' object is supplied, but the component is not aggregatable. NS_ERROR* - Method failure.
NS_METHOD MRJPlugin::CreateInstance ( nsISupports *  aOuter,
const nsIID aIID,
void **  aResult 
)

Definition at line 250 of file MRJPlugin.cpp.

{
       nsresult result = StartupJVM();
       if (result == NS_OK) {
              MRJPluginInstance* instance = new MRJPluginInstance(this);
              if (instance == nsnull)
                     return NS_ERROR_OUT_OF_MEMORY;
              result = instance->QueryInterface(aIID, aResult);
              if (result != NS_OK)
                     delete instance;
       }
       return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD MRJPlugin::CreateInstance ( nsISupports *  aOuter,
const nsIID aIID,
void **  aResult 
)
void nsIPlugin::createPluginInstance ( in nsISupports  aOuter,
in nsIIDRef  aIID,
in string  aPluginMIMEType,
[retval, iid_is(aIID)] out nsQIResult  aResult 
) [inherited]

Creates a new plugin instance, based on a MIME type.

This allows different impelementations to be created depending on the specified MIME type.

NS_METHOD MRJPlugin::CreatePluginInstance ( nsISupports *  aOuter,
REFNSIID  aIID,
const char *  aPluginMIMEType,
void **  aResult 
)

Creates a new plugin instance, based on the MIME type.

This allows different impelementations to be created depending on the specified MIME type.

Definition at line 266 of file MRJPlugin.cpp.

{
    nsresult result = NS_NOINTERFACE;

    if (::strcmp(aPluginMIMEType, "application/x-java-frame") == 0) {
        // create a special plugin instance that manages an embedded frame.
        EmbeddedFramePluginInstance* instance = new EmbeddedFramePluginInstance();
        if (!instance)
            return NS_ERROR_OUT_OF_MEMORY;
            
        nsresult result = instance->QueryInterface(aIID, aResult);
        if (result != NS_OK)
            delete instance;
    } else {
        // assume it's some kind of an applet.
        result = CreateInstance(aOuter, aIID, aResult);
    }
    return result;
}

Here is the call graph for this function:

NS_IMETHOD MRJPlugin::CreatePluginInstance ( nsISupports *  aOuter,
REFNSIID  aIID,
const char *  aPluginMIMEType,
void **  aResult 
)

Creates a new plugin instance, based on the MIME type.

This allows different impelementations to be created depending on the specified MIME type.

NS_IMETHOD MRJPlugin::CreateSecureEnv ( JNIEnv proxyEnv,
nsISecureEnv **  outSecureEnv 
) [virtual]

This creates a new secure communication channel with Java.

The second parameter, nativeEnv, if non-NULL, will be the actual thread for Java communication. Otherwise, a new thread should be created.

Parameters:
proxyEnvthe env to be used by all clients on the browser side
Returns:
outSecureEnv the secure environment used by the proxyEnv

Implements nsIJVMPlugin.

NS_METHOD MRJPlugin::CreateSecureEnv ( JNIEnv proxyEnv,
nsISecureEnv **  outSecureEnv 
) [virtual]

This creates a new secure communication channel with Java.

The second parameter, nativeEnv, if non-NULL, will be the actual thread for Java communication. Otherwise, a new thread should be created.

Parameters:
proxyEnvthe env to be used by all clients on the browser side
Returns:
outSecureEnv the secure environment used by the proxyEnv

Implements nsIJVMPlugin.

Definition at line 504 of file MRJPlugin.cpp.

{
       *outSecureEnv = NULL;
       nsresult rv = StartupJVM();
       if (rv == NS_OK) {
              // Need to spawn a new JVM communication thread here.
              NS_DEFINE_IID(kISecureEnvIID, NS_ISECUREENV_IID);
              rv = CSecureEnv::Create(this, proxyEnv, kISecureEnvIID, (void**)outSecureEnv);
       }
       return rv;
}

Here is the call graph for this function:

NS_IMETHOD MRJPlugin::GetClassPath ( const char **  result) [virtual]

Implements nsIJVMPlugin.

NS_METHOD MRJPlugin::GetClassPath ( const char **  result) [virtual]

Implements nsIJVMPlugin.

Definition at line 451 of file MRJPlugin.cpp.

{
       char* classPath = mSession->getProperty("java.class.path");
       *result = classPath;
       return (classPath != NULL ? NS_OK : NS_ERROR_FAILURE);
}

Here is the call graph for this function:

native Object MRJPlugin.getField ( String  name,
String  signature 
)

Definition at line 471 of file MRJPlugin.cpp.

{
       *result = NULL;
       if (StartupJVM() == NS_OK) {
              *result = mSession->getJavaVM();
              return NS_OK;
       }
       return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

NS_IMETHOD MRJPlugin::GetJavaWrapper ( JNIEnv env,
jint  jsobj,
jobject jobj 
) [virtual]

Implements nsIJVMPlugin.

NS_METHOD MRJPlugin::GetJavaWrapper ( JNIEnv env,
jint  jsobj,
jobject jobj 
) [virtual]

Implements nsIJVMPlugin.

Definition at line 458 of file MRJPlugin.cpp.

{
       // use jsobj as key into a table.
       // if not in the table, then create a new netscape.javascript.JSObject that references this.
       *jobj = Wrap_JSObject(env, jsobj);
       return NS_OK;
}

Here is the call graph for this function:

Definition at line 481 of file MRJPlugin.cpp.

{
       JNIEnv* env = NULL;
       if (StartupJVM() == NS_OK) {
#if 1
              env = mSession->getCurrentEnv();
#else
              JDK1_1AttachArgs args;
              JavaVM* vm = mSession->getJavaVM();
              jint result = vm->AttachCurrentThread(&env, &args);
              if (result != 0)
                     env = NULL;
#endif
       }
       *result = env;
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 363 of file MRJPlugin.cpp.

{
       return mManager;
}

Here is the caller graph for this function:

void nsIPlugin::getMIMEDescription ( out constCharPtr  aMIMEDescription) [inherited]

Returns the MIME description for the plugin.

The MIME description is a colon-separated string containg the plugin MIME type, plugin data file extension, and plugin name, e.g.:

"application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"

(Corresponds to NPP_GetMIMEDescription.)

Parameters:
aMIMEDescription- the resulting MIME description
Returns:
- NS_OK if this operation was successful

Returns the MIME description for the plugin.

The MIME description is a colon-separated string containg the plugin MIME type, plugin data file extension, and plugin name, e.g.:

"application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"

(Corresponds to NPP_GetMIMEDescription.)

Parameters:
resultingDesc- the resulting MIME description
Returns:
- NS_OK if this operation was successful

Definition at line 341 of file MRJPlugin.cpp.

{
       *result = NS_JVM_MIME_TYPE;
       return NS_OK;
}

Returns the MIME description for the plugin.

The MIME description is a colon-separated string containg the plugin MIME type, plugin data file extension, and plugin name, e.g.:

"application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"

(Corresponds to NPP_GetMIMEDescription.)

Parameters:
resultingDesc- the resulting MIME description
Returns:
- NS_OK if this operation was successful

Definition at line 538 of file MRJPlugin.cpp.

{
       JNIEnv* env = mSession->getCurrentEnv();
       MRJPluginInstance* instance = MRJPluginInstance::getInstances();
       while (instance != NULL) {
              jobject object = NULL;
              if (instance->GetJavaObject(&object) == NS_OK && env->IsSameObject(applet, object)) {
                     instance->AddRef();
                     return instance;
              }
              instance = instance->getNextInstance();
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 553 of file MRJPlugin.cpp.

{
       // Apple will provide an API that maps a JNIEnv to an JMAWTContextRef. We can map this to the MRJContext/Applet/Instance.
       MRJPluginInstance* instance = MRJPluginInstance::getInstances();
       if (&::JMJNIToAWTContext != NULL) {
              JMAWTContextRef contextRef = ::JMJNIToAWTContext(mSession->getSessionRef(), jenv);
              if (contextRef != NULL) {
                     while (instance != NULL) {
                            if (instance->getContext()->getContextRef() == contextRef) {
                                   instance->AddRef();
                                   return instance;
                            }
                            instance = instance->getNextInstance();
                     }
              }
       } else {
              if (instance != NULL) {
                     instance->AddRef();
                     return instance;
              }
       }
       return NULL;
}

Here is the call graph for this function:

nsresult MRJPlugin::GetService ( const nsCID aCID,
const nsIID aIID,
void **  aService 
) [static]

Definition at line 94 of file MRJPlugin.cpp.

{
    if (theServiceManager)
        return theServiceManager->GetService(aCID, aIID, aService);
    if (theServiceManagerObsolete)
        return theServiceManagerObsolete->GetService(aCID, aIID, (nsISupports **)aService);
    return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult MRJPlugin::GetService ( const char *  aContractID,
const nsIID aIID,
void **  aService 
) [static]

Definition at line 103 of file MRJPlugin.cpp.

{
    if (theServiceManager)
        return theServiceManager->GetServiceByContractID(aContractID, aIID, aService);
    if (theServiceManagerObsolete)
        return theServiceManagerObsolete->GetService(aContractID, aIID, (nsISupports **)aService);
    return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

static nsresult MRJPlugin::GetService ( const nsCID aCID,
const nsIID aIID,
void **  aService 
) [static]
static nsresult MRJPlugin::GetService ( const char *  aContractID,
const nsIID aIID,
void **  aService 
) [static]

Definition at line 357 of file MRJPlugin.cpp.

{
       StartupJVM();
       return mSession;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 368 of file MRJPlugin.cpp.

{
       return mThreadManager;
}
void nsIPlugin::getValue ( in nsPluginVariable  aVariable,
in voidPtr  aValue 
) [inherited]

Returns the value of a variable associated with the plugin.

(Corresponds to NPP_GetValue.)

Parameters:
aVariable- the plugin variable to get
aValue- the address of where to store the resulting value
Returns:
- NS_OK if this operation was successful
NS_METHOD MRJPlugin::GetValue ( nsPluginVariable  variable,
void value 
)

Returns the value of a variable associated with the plugin.

(Corresponds to NPP_GetValue.)

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

Definition at line 347 of file MRJPlugin.cpp.

NS_IMETHOD MRJPlugin::GetValue ( nsPluginVariable  variable,
void value 
)

Returns the value of a variable associated with the plugin.

(Corresponds to NPP_GetValue.)

Parameters:
variable- the plugin variable to get
value- the address of where to store the resulting value
Returns:
- NS_OK if this operation was successful
NS_METHOD MRJPlugin::Hide ( void  ) [virtual]

Implements nsIJVMConsole.

Definition at line 556 of file MRJPlugin.cpp.

{
    // Hide system console?
    return NS_OK;
}
void nsIPlugin::initialize ( ) [inherited]

Initializes the plugin and will be called before any new instances are created.

It is passed browserInterfaces on which QueryInterface may be used to obtain an nsIPluginManager, and other interfaces.

Parameters:
browserInterfaces- an object that allows access to other browser interfaces via QueryInterface
Returns:
- NS_OK if this operation was successful

Initializes the plugin and will be called before any new instances are created.

This separates out the phase when a plugin is loaded just to query for its mime type from the phase when a plugin is used for real. The plugin should load up any resources at this point.

Returns:
- NS_OK if this operation was successful

Definition at line 286 of file MRJPlugin.cpp.

{
    nsresult result = NS_OK;

    // try to get a plugin manager.
    if (thePluginManager == NULL) {
        result = MRJPlugin::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager), (void**)&thePluginManager);
        if (result != NS_OK || thePluginManager == NULL)
            return NS_ERROR_FAILURE;
    }

    // see if the enhanced plugin manager exists.
    if (thePluginManager2 == NULL) {
        if (thePluginManager->QueryInterface(NS_GET_IID(nsIPluginManager2), (void**)&thePluginManager2) != NS_OK)
            thePluginManager2 = NULL;
    }

    // try to get a JVM manager. we have to be able to run without one.
    if (MRJPlugin::GetService(kJVMManagerCID, NS_GET_IID(nsIJVMManager), (void**)&mManager) != NS_OK)
        mManager = NULL;
    
    // try to get a Thread manager.
    if (mManager != NULL) {
        if (mManager->QueryInterface(NS_GET_IID(nsIThreadManager), (void**)&mThreadManager) != NS_OK)
            mThreadManager = NULL;

        if (mThreadManager != NULL)
            mThreadManager->GetCurrentThread(&mPluginThreadID);
    }

    // create a console, only if there's user interface for it.
    if (thePluginManager2 != NULL) {
        mConsole = new MRJConsole(this);
        NS_IF_ADDREF(mConsole);
    }

    return result;
}

Here is the call graph for this function:

Initializes the plugin and will be called before any new instances are created.

This separates out the phase when a plugin is loaded just to query for its mime type from the phase when a plugin is used for real. The plugin should load up any resources at this point.

Returns:
- NS_OK if this operation was successful

Definition at line 577 of file MRJPlugin.cpp.

{
       Boolean result = false;
       nsPluginThread *currentThreadID = NULL;
       
       if (mThreadManager != NULL)
              mThreadManager->GetCurrentThread(&currentThreadID);
       if ((NULL != currentThreadID) && (NULL != mPluginThreadID)) {
              if (currentThreadID == mPluginThreadID) {
                     result = true;
              }
       }
       
       return result;
}

Here is the call graph for this function:

NS_METHOD MRJPlugin::IsVisible ( PRBool result) [virtual]

Implements nsIJVMConsole.

Definition at line 562 of file MRJPlugin.cpp.

{
    // *result = IsConsoleRunning();
    *result = PR_FALSE;
    return NS_OK;
}
void nsIFactory::lockFactory ( in PRBool  lock) [inherited]

LockFactory provides the client a way to keep the component in memory until it is finished with it.

The client can call LockFactory(PR_TRUE) to lock the factory and LockFactory(PR_FALSE) to release the factory.

Parameters:
lock- Must be PR_TRUE or PR_FALSE
Returns:
NS_OK - If the lock operation was successful. NS_ERROR* - Method failure.

Definition at line 104 of file MRJPlugin.h.

Definition at line 106 of file MRJPlugin.h.

Definition at line 81 of file MRJPlugin.h.

{ return addRef(); }

Here is the call graph for this function:

Definition at line 82 of file MRJPlugin.h.

{ return release(); }

Here is the call graph for this function:

Definition at line 82 of file MRJPlugin.h.

{ return addRef(); }

Here is the call graph for this function:

Definition at line 83 of file MRJPlugin.h.

{ return release(); }

Here is the call graph for this function:

void MRJPlugin::operator delete ( void ptr) [inline]

Definition at line 77 of file MRJPlugin.h.

{}
NS_METHOD MRJPlugin::Print ( const char *  msg,
const char *  encodingName = NULL 
) [virtual]

Implements nsIJVMConsole.

Definition at line 569 of file MRJPlugin.cpp.

{
    // printf onto the console.
    return NS_OK;
}
NS_IMETHODIMP SupportsMixin::queryInterface ( const nsIID aIID,
void **  aInstancePtr 
) [inherited]

The lowercase implementations of queryInterface, addRef, and release all act locally on the current object, regardless of aggregation.

They are meant to be called by aggregating outer objects.

Definition at line 129 of file SupportsMixin.cpp.

{
       if (aInstancePtr == NULL) {
              return NS_ERROR_NULL_POINTER;
       }
       // first check to see if it's one of our known interfaces.
       // need to solve the non-left inheritance graph case.
       const InterfaceInfo* interfaces = mInterfaces;
       UInt32 count = mInterfaceCount;
       for (UInt32 i = 0; i < count; i++) {
              if (aIID.Equals(interfaces[i].mIID)) {
                     *aInstancePtr = (void*) (UInt32(mInstance) + interfaces[i].mOffset);
                     addRef();
                     return NS_OK;
              }
       }
       // finally, does the interface match nsISupports?
       static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
       if (aIID.Equals(kISupportsIID)) {
              *aInstancePtr = (void*) mInstance;
              addRef();
              return NS_OK;
       }
       return NS_NOINTERFACE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult SupportsMixin::queryInterface ( const nsIID aIID,
void **  aInstancePtr 
) [inherited]
NS_METHOD MRJPlugin::QueryInterface ( const nsIID aIID,
void **  instancePtr 
)

MRJPlugin aggregates MRJConsole, so that it can be QI'd to be an nsIJVMConsole.

To save code size, we use the SupportsMixin class instead of the macros in nsAgg.h. SupportsMixin::queryInterface, addRef, and release are all local operations, regardless of aggregation. The capitalized versions take aggregation into account.

Definition at line 238 of file MRJPlugin.cpp.

{
    nsresult result = queryInterface(aIID, instancePtr);
    if (result == NS_NOINTERFACE) {
        if (!mConsole)
            return NS_ERROR_NOT_AVAILABLE;

        result = mConsole->queryInterface(aIID, instancePtr);
    }
    return result;
}

Here is the call graph for this function:

NS_IMETHOD MRJPlugin::QueryInterface ( const nsIID aIID,
void **  aInstancePtr 
)

Here is the caller graph for this function:

Definition at line 499 of file MRJPlugin.cpp.

{
       return 0;
}

Here is the caller graph for this function:

NS_IMETHOD MRJPlugin::RemoveFromClassPath ( const char *  dirPath) [inline, virtual]

Implements nsIJVMPlugin.

Definition at line 185 of file MRJPlugin.h.

NS_IMETHOD MRJPlugin::RemoveFromClassPath ( const char *  dirPath) [inline, virtual]

Implements nsIJVMPlugin.

Definition at line 194 of file MRJPlugin.h.

void nsIRunnable::run ( ) [inherited]
NS_IMETHOD MRJPlugin::Run ( ) [virtual]

The Run method gives time to the JVM periodically.

This makes SpendTIme() obsolete.

Implements nsIRunnable.

NS_METHOD MRJPlugin::Run ( void  ) [virtual]

The Run method gives time to the JVM periodically.

This makes SpendTIme() obsolete.

Implements nsIRunnable.

Definition at line 529 of file MRJPlugin.cpp.

{
       while (mSession != NULL) {
              mSession->idle();
              mThreadManager->Sleep();
       }
       return NS_OK;
}

Here is the call graph for this function:

native void MRJPlugin.setField ( String  name,
String  signature,
Object  value 
)
NS_METHOD MRJPlugin::SetValue ( nsPluginVariable  variable,
void value 
)

Definition at line 352 of file MRJPlugin.cpp.

{
       return NS_ERROR_FAILURE;
}
NS_METHOD MRJPlugin::Show ( void  ) [virtual]

Poor Man's Mac OS X Java Console implementation.

MRJSession::open() opens ~/Library/Logs/JavaConsole.log, and redirects all output from System.out and System.err to this file. Rather than implementing a Java based console, just take advantage of Mac OS X's /Applications/Utilities/Console.app capability of showing log files. The following simply uses Launch Services to open whatever application normally opens ".log" files. A more sophisticated implementation would launch Console.app with the log file, but this works just fine for now.

Implements nsIJVMConsole.

Definition at line 543 of file MRJPlugin.cpp.

{
    // Launch the system console application.
    char consolePath[512];
    getJavaConsolePath(consolePath, sizeof(consolePath));
    CFURLRef consoleURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8*)consolePath, strlen(consolePath), false);
    if (consoleURL) {
        LSOpenCFURLRef(consoleURL, NULL);
        CFRelease(consoleURL);
    }
    return NS_OK;
}

Here is the call graph for this function:

void nsIPlugin::shutdown ( ) [inherited]

Called when the browser is done with the plugin factory, or when the plugin is disabled by the user.

(Corresponds to NPP_Shutdown.)

Returns:
- NS_OK if this operation was successful

Called when the browser is done with the plugin factory, or when the plugin is disabled by the user.

(Corresponds to NPP_Shutdown.)

Returns:
- NS_OK if this operation was successful

Definition at line 325 of file MRJPlugin.cpp.

{
    // shutdown LiveConnect.
    ShutdownLiveConnectSupport();

    // release our reference to the plugin manager(s).
    NS_IF_RELEASE(thePluginManager2);
    NS_IF_RELEASE(thePluginManager);

    // release our reference to the service manager.
    NS_IF_RELEASE(theServiceManager);
    NS_IF_RELEASE(theServiceManagerObsolete);
    
    return NS_OK;
}

Here is the call graph for this function:

Called when the browser is done with the plugin factory, or when the plugin is disabled by the user.

(Corresponds to NPP_Shutdown.)

Returns:
- NS_OK if this operation was successful

Definition at line 429 of file MRJPlugin.cpp.

{
       if (fullShutdown) {
        nsresult rv = ShutdownLiveConnectSupport();
       
              if (mSession != NULL) {
                     delete mSession;
                     mSession = NULL;
              }
       }
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD MRJPlugin::SpendTime ( PRUint32  timeMillis) [virtual]

Gives time to the JVM from the main event loop of the browser.

This is necessary when there aren't any plugin instances around, but Java threads exist.

Implements nsIJVMPlugin.

NS_METHOD MRJPlugin::SpendTime ( PRUint32  timeMillis) [virtual]

Gives time to the JVM from the main event loop of the browser.

This is necessary when there aren't any plugin instances around, but Java threads exist.

Implements nsIJVMPlugin.

Definition at line 516 of file MRJPlugin.cpp.

{
       nsresult result = NS_OK;
       // Only do this if there aren't any plugin instances.
       if (MRJPluginInstance::getInstances() == NULL) {
           if (mSession == NULL)
              result = StartupJVM();
       if (mSession != NULL)
              mSession->idle(timeMillis);
       }
       return result;
}

Here is the call graph for this function:

Definition at line 373 of file MRJPlugin.cpp.

{
       if (mSession == NULL) {
              // start a session with MRJ.
              mSession = new MRJSession();
              if (mSession->getStatus() != noErr) {
                     // how can we signal an error?
                     delete mSession;
                     mSession = NULL;
                     return NS_ERROR_FAILURE;
              }
#if 0
              // Apply the initialization args.
              if (initArgs != NULL && initArgs->version >= nsJVMInitArgs_Version) {
                     const char* classPathAdditions = initArgs->classpathAdditions;
                     if (classPathAdditions != NULL) {
                            // what format will this be in? UNIX paths, separated by ':' characters.
                            char* paths = new char[1 + strlen(classPathAdditions)];
                            if (paths != NULL) {
                                   strcpy(paths, classPathAdditions);
                                   char* path = strtok(paths, ":");
                                   while (path != NULL) {
                                          static char urlPrefix[] = { "file://" };
                                          char* fileURL = new char[sizeof(urlPrefix) + strlen(path)];
                                          if (fileURL != NULL) {
                                                 strcat(strcpy(fileURL, urlPrefix), path);
                                                 mSession->addURLToClassPath(fileURL);
                                                 delete[] fileURL;
                                          }
                                          path = strtok(NULL, ":");
                                   }
                                   delete[] paths;
                            }
                     }
              }
#endif

              // Add "MRJPlugin.jar" to the class path.
              FSSpec jarFileSpec = { thePluginSpec.vRefNum, thePluginSpec.parID, "\pMRJPlugin.jar" };
              mSession->addToClassPath(jarFileSpec);

              InitLiveConnectSupport(this);

#if 0
              // start our idle thread.
              if (mThreadManager != NULL) {
                     PRUint32 threadID;
                     mThreadManager->CreateThread(&threadID, this);
              }
#endif

              mIsEnabled = true;
       }
       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD MRJPlugin::UnwrapJavaWrapper ( JNIEnv jenv,
jobject  jobj,
jint obj 
) [virtual]

Implements nsIJVMPlugin.

NS_METHOD MRJPlugin::UnwrapJavaWrapper ( JNIEnv jenv,
jobject  jobj,
jint obj 
) [virtual]

Implements nsIJVMPlugin.

Definition at line 466 of file MRJPlugin.cpp.


Member Data Documentation

static const UInt32 MRJPlugin::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo) [static, private]

Definition at line 268 of file MRJPlugin.h.

Definition at line 262 of file MRJPlugin.h.

Definition at line 264 of file MRJPlugin.h.

Definition at line 259 of file MRJPlugin.h.

Definition at line 263 of file MRJPlugin.h.

Definition at line 261 of file MRJPlugin.h.

Definition at line 260 of file MRJPlugin.h.

const char * MRJPlugin::PLUGIN_VERSION = "eerieQuarkDoll.v.b1" [static]

Definition at line 74 of file MRJPlugin.h.

static const InterfaceInfo MRJPlugin::sInterfaces [static, private]

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