Back to index

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

#include <nsLiveConnect.h>

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

List of all members.

Public Member Functions

DECL_SUPPORTS_MIXIN nsLiveconnect ()
virtual ~nsLiveconnect ()
NS_IMETHOD GetMember (JNIEnv *env, jsobject jsobj, const jchar *name, jsize length, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
 get member of a Native JSObject for a given name.
NS_IMETHOD GetSlot (JNIEnv *env, jsobject jsobj, jint slot, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
 get member of a Native JSObject for a given index.
NS_IMETHOD SetMember (JNIEnv *env, jsobject jsobj, const jchar *name, jsize length, jobject jobj, void *principalsArray[], int numPrincipals, nsISupports *securitySupports)
 set member of a Native JSObject for a given name.
NS_IMETHOD SetSlot (JNIEnv *env, jsobject jsobj, jint slot, jobject jobj, void *principalsArray[], int numPrincipals, nsISupports *securitySupports)
 set member of a Native JSObject for a given index.
NS_IMETHOD RemoveMember (JNIEnv *env, jsobject jsobj, const jchar *name, jsize length, void *principalsArray[], int numPrincipals, nsISupports *securitySupports)
 remove member of a Native JSObject for a given name.
NS_IMETHOD Call (JNIEnv *env, jsobject jsobj, const jchar *name, jsize length, jobjectArray jobjArr, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)
 call a method of Native JSObject.
NS_IMETHOD Eval (JNIEnv *env, jsobject obj, const jchar *script, jsize length, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *outResult)
 Evaluate a script with a Native JS Object representing scope.
NS_IMETHOD GetWindow (JNIEnv *env, void *pJavaObject, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jsobject *pobj)
 Get the window object for a plugin instance.
NS_IMETHOD FinalizeJSObject (JNIEnv *env, jsobject jsobj)
 Finalize a JSObject instance.
NS_IMETHOD ToString (JNIEnv *env, jsobject obj, jstring *pjstring)
 Convert a JSObject to a string.
NS_IMETHOD OnStartBinding (nsIPluginStreamInfo *pluginInfo)
 Notify the observer that the URL has started to load.
NS_IMETHOD OnDataAvailable (nsIPluginStreamInfo *pluginInfo, nsIInputStream *input, PRUint32 length)
 Notify the client that data is available in the input stream.
NS_IMETHOD OnFileAvailable (nsIPluginStreamInfo *pluginInfo, const char *fileName)
NS_IMETHOD OnStopBinding (nsIPluginStreamInfo *pluginInfo, nsresult status)
 Notify the observer that the URL has finished loading.
NS_IMETHOD GetStreamType (nsPluginStreamType *result)
 What is this method supposed to do?
NS_IMETHOD GetMember (JNIEnv *jEnv, lcjsobject jsobj, const jchar *name, jsize length, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)=0
 get member of a Native JSObject for a given name.
NS_IMETHOD GetSlot (JNIEnv *jEnv, lcjsobject jsobj, jint slot, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)=0
 get member of a Native JSObject for a given index.
NS_IMETHOD SetMember (JNIEnv *jEnv, lcjsobject jsobj, const jchar *name, jsize length, jobject jobj, void *principalsArray[], int numPrincipals, nsISupports *securitySupports)=0
 set member of a Native JSObject for a given name.
NS_IMETHOD SetSlot (JNIEnv *jEnv, lcjsobject jsobj, jint slot, jobject jobj, void *principalsArray[], int numPrincipals, nsISupports *securitySupports)=0
 set member of a Native JSObject for a given index.
NS_IMETHOD RemoveMember (JNIEnv *jEnv, lcjsobject jsobj, const jchar *name, jsize length, void *principalsArray[], int numPrincipals, nsISupports *securitySupports)=0
 remove member of a Native JSObject for a given name.
NS_IMETHOD Call (JNIEnv *jEnv, lcjsobject jsobj, const jchar *name, jsize length, jobjectArray jobjArr, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)=0
 call a method of Native JSObject.
NS_IMETHOD Eval (JNIEnv *jEnv, lcjsobject obj, const jchar *script, jsize length, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, jobject *pjobj)=0
 Evaluate a script with a Native JS Object representing scope.
NS_IMETHOD GetWindow (JNIEnv *jEnv, void *pJavaObject, void *principalsArray[], int numPrincipals, nsISupports *securitySupports, lcjsobject *pobj)=0
 Get the window object for a plugin instance.
NS_IMETHOD FinalizeJSObject (JNIEnv *jEnv, lcjsobject jsobj)=0
 Get the window object for a plugin instance.
NS_IMETHOD ToString (JNIEnv *jEnv, lcjsobject obj, jstring *pjstring)=0
 Get the window object for a plugin instance.
void onStartBinding (in nsIPluginStreamInfo aPluginInfo)
 Notify the observer that the URL has started to load.
void onDataAvailable (in nsIPluginStreamInfo aPluginInfo, in nsIInputStream aInputStream, in unsigned long aLength)
 Notify the client that data is available in the input stream.
void onFileAvailable (in nsIPluginStreamInfo aPluginInfo, in string aFileName)
 Notify the client that data is available in the file.
void onStopBinding (in nsIPluginStreamInfo aPluginInfo, in nsresult aStatus)
 Notify the observer that the URL has finished loading.

Public Attributes

readonly attribute
nsPluginStreamType 
streamType
 Gets the type of the stream.

Private Member Functions

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)

Private Attributes

MRJMonitormJavaScriptMonitor
char * mScript
char * mResult

Static Private Attributes

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

Detailed Description

Definition at line 49 of file nsLiveConnect.h.


Constructor & Destructor Documentation

Definition at line 62 of file nsLiveConnect.cpp.

{
    delete mJavaScriptMonitor;
}

Member Function Documentation

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]

Here is the caller graph for this function:

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]
NS_IMETHOD nsLiveconnect::Call ( JNIEnv env,
jsobject  jsobj,
const jchar name,
jsize  length,
jobjectArray  jobjArr,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [inline]

call a method of Native JSObject.

Parameters:
obj- A Native JS Object.
name- Name of a method.
jobjArr- Array of jobjects representing parameters of method being caled.
pjobj- return value.

Definition at line 144 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::Call ( JNIEnv jEnv,
lcjsobject  jsobj,
const jchar name,
jsize  length,
jobjectArray  jobjArr,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [pure virtual, inherited]

call a method of Native JSObject.

Parameters:
obj- A Native JS Object.
name- Name of a method.
jobjArr- Array of jobjects representing parameters of method being caled.
pjobj- return value.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsILiveconnect::Eval ( JNIEnv jEnv,
lcjsobject  obj,
const jchar script,
jsize  length,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [pure virtual, inherited]

Evaluate a script with a Native JS Object representing scope.

Parameters:
obj- A Native JS Object.
principalsArray- Array of principals to be used to compare privileges.
numPrincipals- Number of principals being passed.
script- Script to be executed.
pjobj- return value.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_METHOD nsLiveconnect::Eval ( JNIEnv env,
jsobject  obj,
const jchar script,
jsize  length,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject outResult 
)

Evaluate a script with a Native JS Object representing scope.

Parameters:
obj- A Native JS Object.
principalsArray- Array of principals to be used to compare privileges.
numPrincipals- Number of principals being passed.
script- Script to be executed.
pjobj- return value.

Definition at line 83 of file nsLiveConnect.cpp.

{
    MRJPluginInstance* pluginInstance = (MRJPluginInstance*) obj;
    nsIPluginStreamListener* listener = this;

    if (!mJavaScriptMonitor) {
        mJavaScriptMonitor = new MRJMonitor(pluginInstance->getSession());
        if (!mJavaScriptMonitor)
            return NS_ERROR_OUT_OF_MEMORY;
    }

    mJavaScriptMonitor->enter();

    while (mScript != NULL) {
        // some other thread is evaluating a script.
        mJavaScriptMonitor->wait();
    }

    nsresult rv = NS_OK;    
    // convert the script to ASCII, construct a "javascript:" URL.
    char* cscript = u2c(script, length);
    if (!cscript) {
        rv = NS_ERROR_OUT_OF_MEMORY;
    } else {
        mScript = new char[strlen(kJavaScriptPrefix) + length + 1];
        if (!mScript) {
            rv = NS_ERROR_OUT_OF_MEMORY;
        } else {
            strcpy(mScript, kJavaScriptPrefix);
            strcat(mScript, cscript);
            delete[] cscript;
            rv = thePluginManager->GetURL((nsIPluginInstance*)pluginInstance, mScript, NULL, listener);

            // need to block until the result is ready.
            mJavaScriptMonitor->wait();

            // default result is NULL, in case JavaScript returns undefined value.
            *outResult = NULL;

            // result should now be ready, convert it to a Java string and return.
            if (mResult != NULL) {
                *outResult = env->NewStringUTF(mResult);
                delete[] mResult;
                mResult = NULL;
            }

            delete[] mScript;
            mScript = NULL;
        }
    }

    mJavaScriptMonitor->notifyAll();

    mJavaScriptMonitor->exit();

    return rv;
}

Here is the call graph for this function:

NS_IMETHOD nsILiveconnect::FinalizeJSObject ( JNIEnv jEnv,
lcjsobject  jsobj 
) [pure virtual, inherited]

Get the window object for a plugin instance.

Parameters:
jEnv- JNIEnv on which the call is being made.
obj- A Native JS Object.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::FinalizeJSObject ( JNIEnv env,
jsobject  jsobj 
) [inline]

Finalize a JSObject instance.

Parameters:
env- JNIEnv on which the call is being made.
obj- A Native JS Object.

Definition at line 186 of file nsLiveConnect.h.

NS_IMETHOD nsLiveconnect::GetMember ( JNIEnv env,
jsobject  jsobj,
const jchar name,
jsize  length,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [inline]

get member of a Native JSObject for a given name.

Parameters:
obj- A Native JS Object.
name- Name of a member.
pjobj- return parameter as a java object representing the member. If it is a basic data type it is converted to a corresponding java type. If it is a NJSObject, then it is wrapped up as java wrapper netscape.javascript.JSObject.

Definition at line 69 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::GetMember ( JNIEnv jEnv,
lcjsobject  jsobj,
const jchar name,
jsize  length,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [pure virtual, inherited]

get member of a Native JSObject for a given name.

Parameters:
obj- A Native JS Object.
name- Name of a member.
pjobj- return parameter as a java object representing the member. If it is a basic data type it is converted to a corresponding java type. If it is a NJSObject, then it is wrapped up as java wrapper netscape.javascript.JSObject.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::GetSlot ( JNIEnv env,
jsobject  jsobj,
jint  slot,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [inline]

get member of a Native JSObject for a given index.

Parameters:
obj- A Native JS Object.
slot- Index of a member.
pjobj- return parameter as a java object representing the member.

Definition at line 84 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::GetSlot ( JNIEnv jEnv,
lcjsobject  jsobj,
jint  slot,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jobject pjobj 
) [pure virtual, inherited]

get member of a Native JSObject for a given index.

Parameters:
obj- A Native JS Object.
slot- Index of a member.
pjobj- return parameter as a java object representing the member.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

What is this method supposed to do?

Definition at line 256 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::GetWindow ( JNIEnv jEnv,
void pJavaObject,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
lcjsobject pobj 
) [pure virtual, inherited]

Get the window object for a plugin instance.

Parameters:
pJavaObject- Either a jobject or a pointer to a plugin instance representing the java object.
pjobj- return value. This is a native js object representing the window object of a frame in which a applet/bean resides.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::GetWindow ( JNIEnv env,
void pJavaObject,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports,
jsobject pobj 
) [inline]

Get the window object for a plugin instance.

Parameters:
pJavaObject- Either a jobject or a pointer to a plugin instance representing the java object.
pjobj- return value. This is a native js object representing the window object of a frame in which a applet/bean resides.

Definition at line 173 of file nsLiveConnect.h.

void nsIPluginStreamListener::onDataAvailable ( in nsIPluginStreamInfo  aPluginInfo,
in nsIInputStream  aInputStream,
in unsigned long  aLength 
) [inherited]

Notify the client that data is available in the input stream.

This method is called whenver data is written into the input stream by the networking library...

Parameters:
aPluginInfo- plugin stream info
aInputStream- the input stream containing the data. This stream can be either a blocking or non-blocking stream.
aLength- the amount of data that was just pushed into the stream.
Returns:
- the return value is currently ignored.

Notify the client that data is available in the input stream.

This method is called whenver data is written into the input stream by the networking library...

Parameters:
aIStreamThe input stream containing the data. This stream can be either a blocking or non-blocking stream.
lengthThe amount of data that was just pushed into the stream.
Returns:
The return value is currently ignored.

Definition at line 142 of file nsLiveConnect.cpp.

{
    // hopefully all our data is available.
    mResult = new char[length + 1];
    if (mResult != NULL) {
        if (input->Read(mResult, length, &length) == NS_OK) {
            // We've delayed processing the applet tag, because we
            // don't know the location of the current document yet.
            mResult[length] = '\0';
        }
    }
    return NS_OK;
}
void nsIPluginStreamListener::onFileAvailable ( in nsIPluginStreamInfo  aPluginInfo,
in string  aFileName 
) [inherited]

Notify the client that data is available in the file.

Parameters:
aPluginInfo- plugin stream info
aFileName- the name of the file containing the data
Returns:
- the return value is currently ignored.
NS_IMETHOD nsLiveconnect::OnFileAvailable ( nsIPluginStreamInfo pluginInfo,
const char *  fileName 
) [inline]

Definition at line 233 of file nsLiveConnect.h.

Notify the observer that the URL has started to load.

This method is called only once, at the beginning of a URL load.

Parameters:
aPluginInfo- plugin stream info
Returns:
- the return value is currently ignored, in the future it may be used to cancel the URL load..

Notify the observer that the URL has started to load.

This method is called only once, at the beginning of a URL load.

Returns:
The return value is currently ignored. In the future it may be used to cancel the URL load..

Definition at line 214 of file nsLiveConnect.h.

    {
        return NS_OK;
    }
void nsIPluginStreamListener::onStopBinding ( in nsIPluginStreamInfo  aPluginInfo,
in nsresult  aStatus 
) [inherited]

Notify the observer that the URL has finished loading.

This method is called once when the networking library has finished processing the URL transaction initiatied via the nsINetService::Open(...) call.

This method is called regardless of whether the URL loaded successfully.

Parameters:
aPluginInfo- plugin stream info
aStatus- reason why the stream has been terminated
Returns:
- the return value is currently ignored.

Notify the observer that the URL has finished loading.

This method is called once when the networking library has finished processing the URL transaction initiatied via the nsINetService::Open(...) call.

This method is called regardless of whether the URL loaded successfully.

Parameters:
statusStatus code for the URL load.
msgA text string describing the error.
Returns:
The return value is currently ignored.

Definition at line 156 of file nsLiveConnect.cpp.

{
    // the stream has been closed, notify any waiting Java threads.
    mJavaScriptMonitor->notifyAll();
    return NS_OK;
}

Here is the call graph for this function:

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]

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::RemoveMember ( JNIEnv env,
jsobject  jsobj,
const jchar name,
jsize  length,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports 
) [inline]

remove member of a Native JSObject for a given name.

Parameters:
obj- A Native JS Object.
name- Name of a member.

Definition at line 129 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::RemoveMember ( JNIEnv jEnv,
lcjsobject  jsobj,
const jchar name,
jsize  length,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports 
) [pure virtual, inherited]

remove member of a Native JSObject for a given name.

Parameters:
obj- A Native JS Object.
name- Name of a member.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::SetMember ( JNIEnv env,
jsobject  jsobj,
const jchar name,
jsize  length,
jobject  jobj,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports 
) [inline]

set member of a Native JSObject for a given name.

Parameters:
obj- A Native JS Object.
name- Name of a member.
jobj- Value to set. If this is a basic data type, it is converted using standard JNI calls but if it is a wrapper to a JSObject then a internal mapping is consulted to convert to a NJSObject.

Definition at line 100 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::SetMember ( JNIEnv jEnv,
lcjsobject  jsobj,
const jchar name,
jsize  length,
jobject  jobj,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports 
) [pure virtual, inherited]

set member of a Native JSObject for a given name.

Parameters:
obj- A Native JS Object.
name- Name of a member.
jobj- Value to set. If this is a basic data type, it is converted using standard JNI calls but if it is a wrapper to a JSObject then a internal mapping is consulted to convert to a NJSObject.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::SetSlot ( JNIEnv env,
jsobject  jsobj,
jint  slot,
jobject  jobj,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports 
) [inline]

set member of a Native JSObject for a given index.

Parameters:
obj- A Native JS Object.
index- Index of a member.
jobj- Value to set. If this is a basic data type, it is converted using standard JNI calls but if it is a wrapper to a JSObject then a internal mapping is consulted to convert to a NJSObject.

Definition at line 116 of file nsLiveConnect.h.

NS_IMETHOD nsILiveconnect::SetSlot ( JNIEnv jEnv,
lcjsobject  jsobj,
jint  slot,
jobject  jobj,
void principalsArray[],
int  numPrincipals,
nsISupports *  securitySupports 
) [pure virtual, inherited]

set member of a Native JSObject for a given index.

Parameters:
obj- A Native JS Object.
index- Index of a member.
jobj- Value to set. If this is a basic data type, it is converted using standard JNI calls but if it is a wrapper to a JSObject then a internal mapping is consulted to convert to a NJSObject.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsILiveconnect::ToString ( JNIEnv jEnv,
lcjsobject  obj,
jstring pjstring 
) [pure virtual, inherited]

Get the window object for a plugin instance.

Parameters:
jEnv- JNIEnv on which the call is being made.
obj- A Native JS Object.
jstring- Return value as a jstring representing a JS object.

Implemented in nsCLiveconnect.

Here is the caller graph for this function:

NS_IMETHOD nsLiveconnect::ToString ( JNIEnv env,
jsobject  obj,
jstring pjstring 
) [inline]

Convert a JSObject to a string.

Parameters:
env- JNIEnv on which the call is being made.
obj- A Native JS Object.
jstring- Return value as a jstring representing a JS object.

Definition at line 199 of file nsLiveConnect.h.


Member Data Documentation

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

Definition at line 269 of file nsLiveConnect.h.

Definition at line 263 of file nsLiveConnect.h.

char* nsLiveconnect::mResult [private]

Definition at line 265 of file nsLiveConnect.h.

char* nsLiveconnect::mScript [private]

Definition at line 264 of file nsLiveConnect.h.

Initial value:

Definition at line 268 of file nsLiveConnect.h.

Gets the type of the stream.

Parameters:
aStreamType- the type of the stream

Definition at line 118 of file nsIPluginStreamListener.idl.


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