Back to index

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

#include <CSecureEnv.h>

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

List of all members.

Public Member Functions

NS_IMETHOD NewObject (jclass clazz, jmethodID methodID, jvalue *args, jobject *result, nsISecurityContext *ctx=NULL)
 Create new Java object in LiveConnect.
NS_IMETHOD CallMethod (jni_type type, jobject obj, jmethodID methodID, jvalue *args, jvalue *result, nsISecurityContext *ctx=NULL)
 Invoke method on Java object in LiveConnect.
NS_IMETHOD CallNonvirtualMethod (jni_type type, jobject obj, jclass clazz, jmethodID methodID, jvalue *args, jvalue *result, nsISecurityContext *ctx=NULL)
 Invoke non-virtual method on Java object in LiveConnect.
NS_IMETHOD GetField (jni_type type, jobject obj, jfieldID fieldID, jvalue *result, nsISecurityContext *ctx=NULL)
 Get a field on Java object in LiveConnect.
NS_IMETHOD SetField (jni_type type, jobject obj, jfieldID fieldID, jvalue val, nsISecurityContext *ctx=NULL)
 Set a field on Java object in LiveConnect.
NS_IMETHOD CallStaticMethod (jni_type type, jclass clazz, jmethodID methodID, jvalue *args, jvalue *result, nsISecurityContext *ctx=NULL)
 Invoke static method on Java object in LiveConnect.
NS_IMETHOD GetStaticField (jni_type type, jclass clazz, jfieldID fieldID, jvalue *result, nsISecurityContext *ctx=NULL)
 Get a static field on Java object in LiveConnect.
NS_IMETHOD SetStaticField (jni_type type, jclass clazz, jfieldID fieldID, jvalue val, nsISecurityContext *ctx=NULL)
 Set a static field on Java object in LiveConnect.
NS_IMETHOD GetVersion (jint *version)
NS_IMETHOD DefineClass (const char *name, jobject loader, const jbyte *buf, jsize len, jclass *clazz)
NS_IMETHOD FindClass (const char *name, jclass *clazz)
NS_IMETHOD GetSuperclass (jclass sub, jclass *super)
NS_IMETHOD IsAssignableFrom (jclass sub, jclass super, jboolean *result)
NS_IMETHOD Throw (jthrowable obj, jint *result)
NS_IMETHOD ThrowNew (jclass clazz, const char *msg, jint *result)
NS_IMETHOD ExceptionOccurred (jthrowable *result)
NS_IMETHOD ExceptionDescribe (void)
NS_IMETHOD ExceptionClear (void)
NS_IMETHOD FatalError (const char *msg)
NS_IMETHOD NewGlobalRef (jobject lobj, jobject *result)
 To give proper "local" refs, need to run this in the true thread.
NS_IMETHOD DeleteGlobalRef (jobject gref)
 This should be safe to call from any thread, since global refs are thread independent.
NS_IMETHOD DeleteLocalRef (jobject obj)
NS_IMETHOD IsSameObject (jobject obj1, jobject obj2, jboolean *result)
NS_IMETHOD AllocObject (jclass clazz, jobject *result)
NS_IMETHOD GetObjectClass (jobject obj, jclass *result)
NS_IMETHOD IsInstanceOf (jobject obj, jclass clazz, jboolean *result)
NS_IMETHOD GetMethodID (jclass clazz, const char *name, const char *sig, jmethodID *id)
NS_IMETHOD GetFieldID (jclass clazz, const char *name, const char *sig, jfieldID *id)
NS_IMETHOD GetStaticMethodID (jclass clazz, const char *name, const char *sig, jmethodID *id)
NS_IMETHOD GetStaticFieldID (jclass clazz, const char *name, const char *sig, jfieldID *id)
NS_IMETHOD NewString (const jchar *unicode, jsize len, jstring *result)
 To give proper "local" refs, need to run this in the true thread.
NS_IMETHOD GetStringLength (jstring str, jsize *result)
NS_IMETHOD GetStringChars (jstring str, jboolean *isCopy, const jchar **result)
NS_IMETHOD ReleaseStringChars (jstring str, const jchar *chars)
NS_IMETHOD NewStringUTF (const char *utf, jstring *result)
NS_IMETHOD GetStringUTFLength (jstring str, jsize *result)
NS_IMETHOD GetStringUTFChars (jstring str, jboolean *isCopy, const char **result)
NS_IMETHOD ReleaseStringUTFChars (jstring str, const char *chars)
NS_IMETHOD GetArrayLength (jarray array, jsize *result)
NS_IMETHOD NewObjectArray (jsize len, jclass clazz, jobject init, jobjectArray *result)
NS_IMETHOD GetObjectArrayElement (jobjectArray array, jsize index, jobject *result)
NS_IMETHOD SetObjectArrayElement (jobjectArray array, jsize index, jobject val)
NS_IMETHOD NewArray (jni_type element_type, jsize len, jarray *result)
NS_IMETHOD GetArrayElements (jni_type type, jarray array, jboolean *isCopy, void *result)
NS_IMETHOD ReleaseArrayElements (jni_type type, jarray array, void *elems, jint mode)
NS_IMETHOD GetArrayRegion (jni_type type, jarray array, jsize start, jsize len, void *buf)
NS_IMETHOD SetArrayRegion (jni_type type, jarray array, jsize start, jsize len, void *buf)
NS_IMETHOD RegisterNatives (jclass clazz, const JNINativeMethod *methods, jint nMethods, jint *result)
NS_IMETHOD UnregisterNatives (jclass clazz, jint *result)
NS_IMETHOD MonitorEnter (jobject obj, jint *result)
NS_IMETHOD MonitorExit (jobject obj, jint *result)
NS_IMETHOD GetJavaVM (JavaVM **vm, jint *result)
NS_IMETHOD Run ()
 Runs the server thread for LiveConnect upcalls from spontaneous Java threads.
 CSecureEnv (MRJPlugin *plugin, JNIEnv *proxyEnv, JNIEnv *javaEnv=NULL)
virtual ~CSecureEnv (void)
void initialize (JNIEnv *javaEnv, jboolean *isRunning, JavaMessageQueue *javaQueue, JavaMessageQueue *nativeQueue)
 Called by the native run method, to connect the thread and the secure env.
jboolean isInitialized ()
void setProxyEnv (JNIEnv *proxyEnv)
JNIEnvgetProxyEnv ()
void setJavaEnv (JNIEnv *javaEnv)
JNIEnvgetJavaEnv ()
MRJSessiongetSession ()
nsIThreadManagergetThreadManager ()
void getMessageQueues (JavaMessageQueue *&javaQueue, JavaMessageQueue *&nativeQueue)
void sendMessageToJava (JavaMessage *msg)
 Used to send a message from Native to Java threads.
void sendMessageFromJava (JNIEnv *javaEnv, JavaMessage *msg, Boolean busyWaiting=false)
 Used to send a message from Java to Native threads.
void messageLoop (JNIEnv *env, JavaMessage *msgToSend, JavaMessageQueue *sendQueue, JavaMessageQueue *receiveQueue, Boolean busyWaiting=false)
 Runs a message loop.
NS_IMETHOD NewObject (jclass clazz, jmethodID methodID, jvalue *args, jobject *result, nsISecurityContext *ctx=NULL)
 Create new Java object in LiveConnect.
NS_IMETHOD CallMethod (jni_type type, jobject obj, jmethodID methodID, jvalue *args, jvalue *result, nsISecurityContext *ctx=NULL)
 Invoke method on Java object in LiveConnect.
NS_IMETHOD CallNonvirtualMethod (jni_type type, jobject obj, jclass clazz, jmethodID methodID, jvalue *args, jvalue *result, nsISecurityContext *ctx=NULL)
 Invoke non-virtual method on Java object in LiveConnect.
NS_IMETHOD GetField (jni_type type, jobject obj, jfieldID fieldID, jvalue *result, nsISecurityContext *ctx=NULL)
 Get a field on Java object in LiveConnect.
NS_IMETHOD SetField (jni_type type, jobject obj, jfieldID fieldID, jvalue val, nsISecurityContext *ctx=NULL)
 Set a field on Java object in LiveConnect.
NS_IMETHOD CallStaticMethod (jni_type type, jclass clazz, jmethodID methodID, jvalue *args, jvalue *result, nsISecurityContext *ctx=NULL)
 Invoke static method on Java object in LiveConnect.
NS_IMETHOD GetStaticField (jni_type type, jclass clazz, jfieldID fieldID, jvalue *result, nsISecurityContext *ctx=NULL)
 Get a static field on Java object in LiveConnect.
NS_IMETHOD SetStaticField (jni_type type, jclass clazz, jfieldID fieldID, jvalue val, nsISecurityContext *ctx=NULL)
 Set a static field on Java object in LiveConnect.
NS_IMETHOD GetVersion (jint *version)
NS_IMETHOD DefineClass (const char *name, jobject loader, const jbyte *buf, jsize len, jclass *clazz)
NS_IMETHOD FindClass (const char *name, jclass *clazz)
NS_IMETHOD GetSuperclass (jclass sub, jclass *super)
NS_IMETHOD IsAssignableFrom (jclass sub, jclass super, jboolean *result)
NS_IMETHOD Throw (jthrowable obj, jint *result)
NS_IMETHOD ThrowNew (jclass clazz, const char *msg, jint *result)
NS_IMETHOD ExceptionOccurred (jthrowable *result)
NS_IMETHOD ExceptionDescribe (void)
NS_IMETHOD ExceptionClear (void)
NS_IMETHOD FatalError (const char *msg)
NS_IMETHOD NewGlobalRef (jobject lobj, jobject *result)
NS_IMETHOD DeleteGlobalRef (jobject gref)
NS_IMETHOD DeleteLocalRef (jobject obj)
NS_IMETHOD IsSameObject (jobject obj1, jobject obj2, jboolean *result)
NS_IMETHOD AllocObject (jclass clazz, jobject *result)
NS_IMETHOD GetObjectClass (jobject obj, jclass *result)
NS_IMETHOD IsInstanceOf (jobject obj, jclass clazz, jboolean *result)
NS_IMETHOD GetMethodID (jclass clazz, const char *name, const char *sig, jmethodID *id)
NS_IMETHOD GetFieldID (jclass clazz, const char *name, const char *sig, jfieldID *id)
NS_IMETHOD GetStaticMethodID (jclass clazz, const char *name, const char *sig, jmethodID *id)
NS_IMETHOD GetStaticFieldID (jclass clazz, const char *name, const char *sig, jfieldID *id)
NS_IMETHOD NewString (const jchar *unicode, jsize len, jstring *result)
NS_IMETHOD GetStringLength (jstring str, jsize *result)
NS_IMETHOD GetStringChars (jstring str, jboolean *isCopy, const jchar **result)
NS_IMETHOD ReleaseStringChars (jstring str, const jchar *chars)
NS_IMETHOD NewStringUTF (const char *utf, jstring *result)
NS_IMETHOD GetStringUTFLength (jstring str, jsize *result)
NS_IMETHOD GetStringUTFChars (jstring str, jboolean *isCopy, const char **result)
NS_IMETHOD ReleaseStringUTFChars (jstring str, const char *chars)
NS_IMETHOD GetArrayLength (jarray array, jsize *result)
NS_IMETHOD NewObjectArray (jsize len, jclass clazz, jobject init, jobjectArray *result)
NS_IMETHOD GetObjectArrayElement (jobjectArray array, jsize index, jobject *result)
NS_IMETHOD SetObjectArrayElement (jobjectArray array, jsize index, jobject val)
NS_IMETHOD NewArray (jni_type element_type, jsize len, jarray *result)
NS_IMETHOD GetArrayElements (jni_type type, jarray array, jboolean *isCopy, void *result)
NS_IMETHOD ReleaseArrayElements (jni_type type, jarray array, void *elems, jint mode)
NS_IMETHOD GetArrayRegion (jni_type type, jarray array, jsize start, jsize len, void *buf)
NS_IMETHOD SetArrayRegion (jni_type type, jarray array, jsize start, jsize len, void *buf)
NS_IMETHOD RegisterNatives (jclass clazz, const JNINativeMethod *methods, jint nMethods, jint *result)
NS_IMETHOD UnregisterNatives (jclass clazz, jint *result)
NS_IMETHOD MonitorEnter (jobject obj, jint *result)
NS_IMETHOD MonitorExit (jobject obj, jint *result)
NS_IMETHOD GetJavaVM (JavaVM **vm, jint *result)
NS_IMETHOD Run ()
 Defines an entry point for a newly created thread.
 CSecureEnv (MRJPlugin *plugin, JNIEnv *proxyEnv, JNIEnv *javaEnv=NULL)
virtual ~CSecureEnv (void)
void initialize (JNIEnv *javaEnv, jboolean *isRunning, JavaMessageQueue *javaQueue, JavaMessageQueue *nativeQueue)
 Called by the native run method, to connect the thread and the secure env.
jboolean isInitialized ()
void setProxyEnv (JNIEnv *proxyEnv)
JNIEnvgetProxyEnv ()
void setJavaEnv (JNIEnv *javaEnv)
JNIEnvgetJavaEnv ()
MRJSessiongetSession ()
nsIThreadManagergetThreadManager ()
void getMessageQueues (JavaMessageQueue *&javaQueue, JavaMessageQueue *&nativeQueue)
void sendMessageToJava (JavaMessage *msg)
void sendMessageFromJava (JNIEnv *javaEnv, JavaMessage *msg, Boolean busyWaiting=false)
void messageLoop (JNIEnv *env, JavaMessage *msgToSend, JavaMessageQueue *sendQueue, JavaMessageQueue *receiveQueue, Boolean busyWaiting=false)
void savePendingException (JNIEnv *env)
jthrowable getPendingException (JNIEnv *env)
void clearPendingException (JNIEnv *env)
void run ()

Static Public Member Functions

static DECL_SUPPORTS_MIXIN
NS_METHOD 
Create (MRJPlugin *plugin, JNIEnv *proxyEnv, const nsIID &aIID, void **aInstancePtr)
static DECL_SUPPORTS_MIXIN
NS_METHOD 
Create (MRJPlugin *plugin, JNIEnv *proxyEnv, const nsIID &aIID, void **aInstancePtr)

Protected Attributes

MRJPluginmPlugin
JNIEnvmProxyEnv
MRJSessionmSession
nsIThreadManagermThreadManager
JNIEnvmJavaEnv
jbooleanmIsRunning
JavaMessageQueuemJavaQueue
JavaMessageQueuemNativeQueue
jthrowable mPendingException
nsIScriptSecurityManagermScriptSecurityManager
nsIPrincipalmScriptPrincipal
jclass mLiveConnectProxy

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)

Static Private Attributes

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

Detailed Description

Definition at line 61 of file CSecureEnv.h.


Constructor & Destructor Documentation

CSecureEnv::CSecureEnv ( MRJPlugin plugin,
JNIEnv proxyEnv,
JNIEnv javaEnv = NULL 
)

=--------------------------------------------------------------------------=

Definition at line 362 of file CSecureEnv.cpp.

       :      SupportsMixin(this, sInterfaces, kInterfaceCount),
              mPlugin(plugin), mProxyEnv(proxyEnv), mJavaEnv(javaEnv),
              mSession(plugin->getSession()), mThreadManager(plugin->getThreadManager()),
              mIsRunning(NULL), mJavaQueue(NULL), mNativeQueue(NULL)
{
       // need to create the JNIThread for communicating with Java.
       if (mJavaEnv != NULL)
              CreateNativeThread(this);
       else
           CreateJNIThread(this);
}

Here is the call graph for this function:

Here is the caller graph for this function:

CSecureEnv::~CSecureEnv ( void  ) [virtual]

=--------------------------------------------------------------------------=

Definition at line 388 of file CSecureEnv.cpp.

{
       // Tell the Java thread to die.
       if (mIsRunning != NULL) {
              *mIsRunning = false;
              mJavaQueue->notify();
       }
}

Here is the call graph for this function:

CSecureEnv::CSecureEnv ( MRJPlugin plugin,
JNIEnv proxyEnv,
JNIEnv javaEnv = NULL 
)
virtual CSecureEnv::~CSecureEnv ( void  ) [virtual]

Member Function Documentation

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]

Here is the caller graph for this function:

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]
NS_IMETHOD CSecureEnv::AllocObject ( jclass  clazz,
jobject result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::AllocObject ( jclass  clazz,
jobject result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1353 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    *result = mJavaEnv->AllocObject(clazz);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::CallMethod ( jni_type  type,
jobject  obj,
jmethodID  methodID,
jvalue args,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Invoke method on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
methodID-- method id
args-- arguments for invoking the constructor.
result-- return result of invocation.
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::CallMethod ( jni_type  type,
jobject  obj,
jmethodID  methodID,
jvalue args,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Invoke method on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
methodID-- method id
args-- arguments for invoking the constructor.
result-- return result of invocation.
ctx-- security context

Implements nsISecureEnv.

Definition at line 554 of file CSecureEnv.cpp.

{
    if (obj == NULL || methodID == NULL)
        return NS_ERROR_NULL_POINTER;

       // Call method on Java side
       // return CallJavaMethod(obj, method, args, ctx, result);
       CallMethodMessage msg(type, obj, methodID, args, result);
       sendMessageToJava(&msg);
       
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::CallNonvirtualMethod ( jni_type  type,
jobject  obj,
jclass  clazz,
jmethodID  methodID,
jvalue args,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Invoke non-virtual method on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
clazz-- Class object
methodID-- method id
args-- arguments for invoking the constructor.
ctx-- security context
result-- return result of invocation.

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::CallNonvirtualMethod ( jni_type  type,
jobject  obj,
jclass  clazz,
jmethodID  methodID,
jvalue args,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Invoke non-virtual method on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
clazz-- Class object
methodID-- method id
args-- arguments for invoking the constructor.
ctx-- security context
result-- return result of invocation.

Implements nsISecureEnv.

Definition at line 641 of file CSecureEnv.cpp.

{
    if (obj == NULL || clazz == NULL || methodID == NULL)
        return NS_ERROR_NULL_POINTER;

       // Call non-virtual method on Java side
       // return CallJavaMethod(obj, method, args, ctx, result);
       CallNonvirtualMethodMessage msg(type, obj, clazz, methodID, args, result);
       sendMessageToJava(&msg);
       
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::CallStaticMethod ( jni_type  type,
jclass  clazz,
jmethodID  methodID,
jvalue args,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Invoke static method on Java object in LiveConnect.

Parameters:
type-- Return type
clazz-- Class object.
methodID-- method id
args-- arguments for invoking the constructor.
result-- return result of invocation.
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::CallStaticMethod ( jni_type  type,
jclass  clazz,
jmethodID  methodID,
jvalue args,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Invoke static method on Java object in LiveConnect.

Parameters:
type-- Return type
clazz-- Class object.
methodID-- method id
args-- arguments for invoking the constructor.
result-- return result of invocation.
ctx-- security context

Implements nsISecureEnv.

Definition at line 895 of file CSecureEnv.cpp.

{
    if (clazz == NULL || methodID == NULL)
        return NS_ERROR_NULL_POINTER;

       // Call method on Java side
       // return CallJavaMethod(NULL, method, args, ctx, result);
       CallStaticMethodMessage msg(type, clazz, methodID, args, result);
       sendMessageToJava(&msg);

       return NS_OK;
}

Here is the call graph for this function:

Definition at line 3120 of file CSecureEnv.cpp.

Here is the caller graph for this function:

static DECL_SUPPORTS_MIXIN NS_METHOD CSecureEnv::Create ( MRJPlugin plugin,
JNIEnv proxyEnv,
const nsIID aIID,
void **  aInstancePtr 
) [static]
NS_METHOD CSecureEnv::Create ( MRJPlugin plugin,
JNIEnv proxyEnv,
const nsIID aIID,
void **  aInstancePtr 
) [static]

=--------------------------------------------------------------------------=

Definition at line 418 of file CSecureEnv.cpp.

{
       CSecureEnv* secureEnv = new CSecureEnv(plugin, proxyEnv);
       if (secureEnv == NULL)
           return NS_ERROR_OUT_OF_MEMORY;
       nsresult result = secureEnv->QueryInterface(aIID, aInstancePtr);
       if (result != NS_OK) {
              delete secureEnv;
              return result;
       }
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::DefineClass ( const char *  name,
jobject  loader,
const jbyte buf,
jsize  len,
jclass clazz 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::DefineClass ( const char *  name,
jobject  loader,
const jbyte buf,
jsize  len,
jclass clazz 
) [virtual]

Implements nsISecureEnv.

Definition at line 1120 of file CSecureEnv.cpp.

{
    if (clazz == NULL)
        return NS_ERROR_NULL_POINTER;
    
    DefineClassMessage msg(name, loader, buf, len, clazz);
    sendMessageToJava(&msg);

    return NS_OK;
}

Here is the call graph for this function:

Implements nsISecureEnv.

This should be safe to call from any thread, since global refs are thread independent.

Implements nsISecureEnv.

Definition at line 1310 of file CSecureEnv.cpp.

{
       JNIEnv* env = mSession->getCurrentEnv();
    env->DeleteGlobalRef(globalRef);
    return NS_OK;
}

Here is the call graph for this function:

Implements nsISecureEnv.

Implements nsISecureEnv.

Definition at line 1334 of file CSecureEnv.cpp.

Implements nsISecureEnv.

Implements nsISecureEnv.

Definition at line 1263 of file CSecureEnv.cpp.

{
    mJavaEnv->ExceptionClear();

    return NS_OK;
}

Implements nsISecureEnv.

Implements nsISecureEnv.

Definition at line 1252 of file CSecureEnv.cpp.

Implements nsISecureEnv.

Implements nsISecureEnv.

Definition at line 1242 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::FatalError ( const char *  msg) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::FatalError ( const char *  msg) [virtual]

Implements nsISecureEnv.

Definition at line 1271 of file CSecureEnv.cpp.

{
    mJavaEnv->FatalError(msg);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::FindClass ( const char *  name,
jclass clazz 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::FindClass ( const char *  name,
jclass clazz 
) [virtual]

Implements nsISecureEnv.

Definition at line 1154 of file CSecureEnv.cpp.

{
    if (clazz == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // JNIEnv* env = mSession->getCurrentEnv();
       // *clazz = env->FindClass(name);
       FindClassMessage msg(name, clazz);
       sendMessageToJava(&msg);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::GetArrayElements ( jni_type  type,
jarray  array,
jboolean isCopy,
void result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetArrayElements ( jni_type  type,
jarray  array,
jboolean isCopy,
void result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1676 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

    switch (type) {
       case jboolean_type:
           result = (void*) mJavaEnv->GetBooleanArrayElements((jbooleanArray)array, isCopy);
           break;
       case jbyte_type:
           result = (void*) mJavaEnv->GetByteArrayElements((jbyteArray)array, isCopy);
           break;
       case jchar_type:
           result = (void*) mJavaEnv->GetCharArrayElements((jcharArray)array, isCopy);
           break;
       case jshort_type:
           result = (void*) mJavaEnv->GetShortArrayElements((jshortArray)array, isCopy);
           break;
       case jint_type:
           result = (void*) mJavaEnv->GetIntArrayElements((jintArray)array, isCopy);
           break;
       case jlong_type:
           result = (void*) mJavaEnv->GetLongArrayElements((jlongArray)array, isCopy);
           break;
       case jfloat_type:
           result = (void*) mJavaEnv->GetFloatArrayElements((jfloatArray)array, isCopy);
           break;
       case jdouble_type:
           result = (void*) mJavaEnv->GetDoubleArrayElements((jdoubleArray)array, isCopy);
           break;
       default:
           return NS_ERROR_FAILURE;
       }

    return NS_OK;
}
NS_IMETHOD CSecureEnv::GetArrayLength ( jarray  array,
jsize result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetArrayLength ( jarray  array,
jsize result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1587 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::GetArrayRegion ( jni_type  type,
jarray  array,
jsize  start,
jsize  len,
void buf 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetArrayRegion ( jni_type  type,
jarray  array,
jsize  start,
jsize  len,
void buf 
) [virtual]

Implements nsISecureEnv.

Definition at line 1758 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::GetField ( jni_type  type,
jobject  obj,
jfieldID  fieldID,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Get a field on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
fieldID-- field id
result-- return field value
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetField ( jni_type  type,
jobject  obj,
jfieldID  fieldID,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Get a field on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
fieldID-- field id
result-- return field value
ctx-- security context

Implements nsISecureEnv.

Definition at line 723 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || obj == NULL || fieldID == NULL)
        return NS_ERROR_NULL_POINTER;

    // Get field on Java side
    // return GetJavaField(obj, field, ctx, result);
    
       JNIEnv* env = mJavaEnv;
       switch (type) {
       case jobject_type:
              result->l = env->GetObjectField(obj, fieldID);
              break;
       case jboolean_type:
              result->z = env->GetBooleanField(obj, fieldID);
              break;
       case jbyte_type:
              result->b = env->GetByteField(obj, fieldID);
              break;
       case jchar_type:
              result->c = env->GetCharField(obj, fieldID);
              break;
       case jshort_type:
              result->s = env->GetShortField(obj, fieldID);
              break;
       case jint_type:
              result->i = env->GetIntField(obj, fieldID);
              break;
       case jlong_type:
              result->j = env->GetLongField(obj, fieldID);
              break;
       case jfloat_type:
              result->f = env->GetFloatField(obj, fieldID);
              break;
       case jdouble_type:
              result->d = env->GetDoubleField(obj, fieldID);
              break;
       }
       
       return NS_OK;
}
NS_IMETHOD CSecureEnv::GetFieldID ( jclass  clazz,
const char *  name,
const char *  sig,
jfieldID id 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetFieldID ( jclass  clazz,
const char *  name,
const char *  sig,
jfieldID id 
) [virtual]

Implements nsISecureEnv.

Definition at line 1406 of file CSecureEnv.cpp.

{
    if (result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    // run this on the *CURRENT* thread.
    JNIEnv* env = mSession->getCurrentEnv();
    *result = env->GetFieldID(clazz, name, sig);

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 383 of file CSecureEnv.h.

{ return mJavaEnv; }

Definition at line 386 of file CSecureEnv.h.

{ return mJavaEnv; }
NS_IMETHOD CSecureEnv::GetJavaVM ( JavaVM **  vm,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetJavaVM ( JavaVM **  vm,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1923 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

    *result = mJavaEnv->GetJavaVM(vm);

    return NS_OK;
}
void CSecureEnv::getMessageQueues ( JavaMessageQueue *&  javaQueue,
JavaMessageQueue *&  nativeQueue 
) [inline]

Definition at line 388 of file CSecureEnv.h.

    {
        javaQueue = mJavaQueue;
        nativeQueue = mNativeQueue;
    }
void CSecureEnv::getMessageQueues ( JavaMessageQueue *&  javaQueue,
JavaMessageQueue *&  nativeQueue 
) [inline]

Definition at line 391 of file CSecureEnv.h.

       {
              javaQueue = mJavaQueue;
              nativeQueue = mNativeQueue;
       }
NS_IMETHOD CSecureEnv::GetMethodID ( jclass  clazz,
const char *  name,
const char *  sig,
jmethodID id 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetMethodID ( jclass  clazz,
const char *  name,
const char *  sig,
jmethodID id 
) [virtual]

Implements nsISecureEnv.

Definition at line 1390 of file CSecureEnv.cpp.

{
    if (result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    // run this on the *CURRENT* thread.
    JNIEnv* env = mSession->getCurrentEnv();
    *result = env->GetMethodID(clazz, name, sig);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::GetObjectArrayElement ( jobjectArray  array,
jsize  index,
jobject result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetObjectArrayElement ( jobjectArray  array,
jsize  index,
jobject result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1611 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::GetObjectClass ( jobject  obj,
jclass result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetObjectClass ( jobject  obj,
jclass result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1365 of file CSecureEnv.cpp.

Definition at line 3113 of file CSecureEnv.cpp.

{
    if (mPendingException)
        return (jthrowable) env->NewLocalRef(mPendingException);
    return NULL;
}

Here is the caller graph for this function:

Definition at line 380 of file CSecureEnv.h.

{ return mProxyEnv; }

Definition at line 383 of file CSecureEnv.h.

{ return mProxyEnv; }

Definition at line 385 of file CSecureEnv.h.

{ return mSession; }

Definition at line 388 of file CSecureEnv.h.

{ return mSession; }

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::GetStaticField ( jni_type  type,
jclass  clazz,
jfieldID  fieldID,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Get a static field on Java object in LiveConnect.

Parameters:
type-- Return type
clazz-- Class object.
fieldID-- field id
result-- return field value
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStaticField ( jni_type  type,
jclass  clazz,
jfieldID  fieldID,
jvalue result,
nsISecurityContext ctx = NULL 
) [virtual]

Get a static field on Java object in LiveConnect.

Parameters:
type-- Return type
clazz-- Class object.
fieldID-- field id
result-- return field value
ctx-- security context

Implements nsISecureEnv.

Definition at line 977 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || clazz == NULL || fieldID == NULL)
        return NS_ERROR_NULL_POINTER;

    // Get static field on Java side
       // return GetJavaField(NULL, field, ctx, result);
       // GetStaticFieldMessage msg(type, clazz, fieldID, result);
       // sendMessageToJava(&msg);

       // should be able to perform in Java env.
       JNIEnv* env = mJavaEnv;
       switch (type) {
       case jobject_type:
              result->l = env->GetStaticObjectField(clazz, fieldID);
              break;
       case jboolean_type:
              result->z = env->GetStaticBooleanField(clazz, fieldID);
              break;
       case jbyte_type:
              result->b = env->GetStaticByteField(clazz, fieldID);
              break;
       case jchar_type:
              result->c = env->GetStaticCharField(clazz, fieldID);
              break;
       case jshort_type:
              result->s = env->GetStaticShortField(clazz, fieldID);
              break;
       case jint_type:
              result->i = env->GetStaticIntField(clazz, fieldID);
              break;
       case jlong_type:
              result->j = env->GetStaticLongField(clazz, fieldID);
              break;
       case jfloat_type:
              result->f = env->GetStaticFloatField(clazz, fieldID);
              break;
       case jdouble_type:
              result->d = env->GetStaticDoubleField(clazz, fieldID);
              break;
       }
       
       return NS_OK;
}
NS_IMETHOD CSecureEnv::GetStaticFieldID ( jclass  clazz,
const char *  name,
const char *  sig,
jfieldID id 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStaticFieldID ( jclass  clazz,
const char *  name,
const char *  sig,
jfieldID id 
) [virtual]

Implements nsISecureEnv.

Definition at line 1438 of file CSecureEnv.cpp.

{
    if (result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    // run this on the *CURRENT* thread.
    JNIEnv* env = mSession->getCurrentEnv();
    *result = env->GetStaticFieldID(clazz, name, sig);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::GetStaticMethodID ( jclass  clazz,
const char *  name,
const char *  sig,
jmethodID id 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStaticMethodID ( jclass  clazz,
const char *  name,
const char *  sig,
jmethodID id 
) [virtual]

Implements nsISecureEnv.

Definition at line 1422 of file CSecureEnv.cpp.

{
    if (result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    // run this on the *CURRENT* thread.
    JNIEnv* env = mSession->getCurrentEnv();
    *result = env->GetStaticMethodID(clazz, name, sig);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::GetStringChars ( jstring  str,
jboolean isCopy,
const jchar **  result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStringChars ( jstring  str,
jboolean isCopy,
const jchar **  result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1497 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    *result = mJavaEnv->GetStringChars(str, isCopy);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::GetStringLength ( jstring  str,
jsize result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStringLength ( jstring  str,
jsize result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1486 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::GetStringUTFChars ( jstring  str,
jboolean isCopy,
const char **  result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStringUTFChars ( jstring  str,
jboolean isCopy,
const char **  result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1562 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    *result = mJavaEnv->GetStringUTFChars(str, isCopy);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::GetStringUTFLength ( jstring  str,
jsize result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetStringUTFLength ( jstring  str,
jsize result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1550 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::GetSuperclass ( jclass  sub,
jclass super 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetSuperclass ( jclass  sub,
jclass super 
) [virtual]

Implements nsISecureEnv.

Definition at line 1187 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || super == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // GetSuperclassMessage msg(sub, super);
       // sendMessageToJava(&msg);
       *super = mJavaEnv->GetSuperclass(sub);

    return NS_OK;
}

Definition at line 386 of file CSecureEnv.h.

{ return mThreadManager; }

Definition at line 389 of file CSecureEnv.h.

{ return mThreadManager; }

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::GetVersion ( jint version) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::GetVersion ( jint version) [virtual]

Implements nsISecureEnv.

Definition at line 1084 of file CSecureEnv.cpp.

{
    if (version == NULL)
        return NS_ERROR_NULL_POINTER;
    
       JNIEnv* env = mSession->getCurrentEnv();
       *version = env->GetVersion();

    return NS_OK;
}

Here is the call graph for this function:

void CSecureEnv::initialize ( JNIEnv javaEnv,
jboolean isRunning,
JavaMessageQueue javaQueue,
JavaMessageQueue nativeQueue 
)

Called by the native run method, to connect the thread and the secure env.

void CSecureEnv::initialize ( JNIEnv javaEnv,
jboolean isRunning,
JavaMessageQueue javaQueue,
JavaMessageQueue nativeQueue 
)

Called by the native run method, to connect the thread and the secure env.

Definition at line 397 of file CSecureEnv.cpp.

{
       mJavaEnv = javaEnv;
       mIsRunning = isRunning;
       mJavaQueue = javaQueue;
       mNativeQueue = nativeQueue;
}

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::IsAssignableFrom ( jclass  sub,
jclass  super,
jboolean result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::IsAssignableFrom ( jclass  sub,
jclass  super,
jboolean result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1201 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // JNIEnv* env = mSession->getCurrentEnv();
       // *result = env->IsAssignableFrom(sub, super);
       *result = mJavaEnv->IsAssignableFrom(sub, super);

    return NS_OK;
}

Definition at line 377 of file CSecureEnv.h.

{ return mJavaQueue != NULL; }

Definition at line 380 of file CSecureEnv.h.

{ return mJavaQueue != NULL; }

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::IsInstanceOf ( jobject  obj,
jclass  clazz,
jboolean result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::IsInstanceOf ( jobject  obj,
jclass  clazz,
jboolean result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1377 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    *result = mJavaEnv->IsInstanceOf(obj, clazz);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::IsSameObject ( jobject  obj1,
jobject  obj2,
jboolean result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::IsSameObject ( jobject  obj1,
jobject  obj2,
jboolean result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1340 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    *result = mJavaEnv->IsSameObject(obj1, obj2);

    return NS_OK;
}
void CSecureEnv::messageLoop ( JNIEnv env,
JavaMessage msgToSend,
JavaMessageQueue sendQueue,
JavaMessageQueue receiveQueue,
Boolean  busyWaiting = false 
)
void CSecureEnv::messageLoop ( JNIEnv env,
JavaMessage msg,
JavaMessageQueue sendQueue,
JavaMessageQueue receiveQueue,
Boolean  busyWaiting = false 
)

Runs a message loop.

Puts the message in the sendQueue, then waits on the receiveQueue for the reply.

Definition at line 1938 of file CSecureEnv.cpp.

{
       // put the message in the send queue, and wait for a reply.
       sendQueue->putMessage(msg);
       sendQueue->notify();
       JavaMessage* replyMsg = receiveQueue->getMessage();
       for (;;) {
              // Fully synchronized approach.
              if (replyMsg != NULL) {
                     if (replyMsg == msg)
                            break;
                     // must be a message that needs executing.
                     replyMsg->execute(env);
                     sendQueue->putMessage(replyMsg);
                     sendQueue->notify();
                     // notify can cause a yield, so look again.
                     replyMsg = receiveQueue->getMessage();
                     if (replyMsg != NULL)
                            continue;
              }
              // when busy waiting, must give time to browser between timed waits.
              if (busyWaiting) {
                     receiveQueue->wait(kDefaultJMTime);
                     replyMsg = receiveQueue->getMessage();
                     if (replyMsg != NULL)
                            continue;
                     // mSession->lock();
                     mThreadManager->Sleep();
                     // mSession->unlock();
              } else {
                     // wait for a message to arrive.
                     receiveQueue->wait();
              }
              replyMsg = receiveQueue->getMessage();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::MonitorEnter ( jobject  obj,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::MonitorEnter ( jobject  obj,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1868 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

       // *result = mJavaEnv->MonitorEnter(obj);
       class MonitorEnterMessage : public JavaMessage {
              jobject obj;
              jint* result;
       public:
              MonitorEnterMessage(jobject obj, jint* result)
              {
                     this->obj = obj;
                     this->result = result;
              }

              virtual void execute(JNIEnv* env)
              {
                     *result = env->MonitorEnter(obj);
              }
       } msg(obj, result);
       sendMessageToJava(&msg);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::MonitorExit ( jobject  obj,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::MonitorExit ( jobject  obj,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1896 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

       // *result = mJavaEnv->MonitorExit(obj);
       class MonitorExitMessage : public JavaMessage {
              jobject obj;
              jint* result;
       public:
              MonitorExitMessage(jobject obj, jint* result)
              {
                     this->obj = obj;
                     this->result = result;
              }

              virtual void execute(JNIEnv* env)
              {
                     *result = env->MonitorExit(obj);
              }
       } msg(obj, result);
       sendMessageToJava(&msg);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::NewArray ( jni_type  element_type,
jsize  len,
jarray result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::NewArray ( jni_type  element_type,
jsize  len,
jarray result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1636 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

    switch (element_type) {
    case jboolean_type:
        result = (jarray*) mJavaEnv->NewBooleanArray(len);
        break;
    case jbyte_type:
        result = (jarray*) mJavaEnv->NewByteArray(len);
        break;
    case jchar_type:
        result = (jarray*) mJavaEnv->NewCharArray(len);
        break;
    case jshort_type:
        result = (jarray*) mJavaEnv->NewShortArray(len);
        break;
    case jint_type:
        result = (jarray*) mJavaEnv->NewIntArray(len);
        break;
    case jlong_type:
        result = (jarray*) mJavaEnv->NewLongArray(len);
        break;
    case jfloat_type:
        result = (jarray*) mJavaEnv->NewFloatArray(len);
        break;
    case jdouble_type:
        result = (jarray*) mJavaEnv->NewDoubleArray(len);
        break;
    default:
        return NS_ERROR_FAILURE;
    }

    return NS_OK;
}
NS_IMETHOD CSecureEnv::NewGlobalRef ( jobject  lobj,
jobject result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::NewGlobalRef ( jobject  lobj,
jobject result 
) [virtual]

To give proper "local" refs, need to run this in the true thread.

Implements nsISecureEnv.

Definition at line 1282 of file CSecureEnv.cpp.

{
    if (result == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // *result = mJavaEnv->NewGlobalRef(localRef);
       class NewGlobalRefMessage : public JavaMessage {
              jobject localRef;
              jobject* result;
       public:
              NewGlobalRefMessage(jobject localRef, jobject* result)
              {
                     this->localRef = localRef;
                     this->result = result;
              }

              virtual void execute(JNIEnv* env)
              {
                     *result = env->NewGlobalRef(localRef);
              }
       } msg(localRef, result);
       sendMessageToJava(&msg);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::NewObject ( jclass  clazz,
jmethodID  methodID,
jvalue args,
jobject result,
nsISecurityContext ctx = NULL 
) [virtual]

Create new Java object in LiveConnect.

Parameters:
clazz-- Java Class object.
methodID-- Method id
args-- arguments for invoking the constructor.
result-- return new Java object.
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::NewObject ( jclass  clazz,
jmethodID  methodID,
jvalue args,
jobject result,
nsISecurityContext ctx = NULL 
) [virtual]

Create new Java object in LiveConnect.

Parameters:
clazz-- Java Class object.
methodID-- Method id
args-- arguments for invoking the constructor.
result-- return new Java object.
ctx-- security context

Implements nsISecureEnv.

Definition at line 470 of file CSecureEnv.cpp.

{
    if (clazz == NULL || methodID == NULL)
        return NS_ERROR_NULL_POINTER;

    // Call method on Java side
    NewObjectMessage msg(clazz, methodID, args, result);
    sendMessageToJava(&msg);
       // *result = m_env->NewObjectA(clazz, methodID, args);
       
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::NewObjectArray ( jsize  len,
jclass  clazz,
jobject  init,
jobjectArray result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::NewObjectArray ( jsize  len,
jclass  clazz,
jobject  init,
jobjectArray result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1598 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

    *result = mJavaEnv->NewObjectArray(len, clazz, init);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::NewString ( const jchar unicode,
jsize  len,
jstring result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::NewString ( const jchar unicode,
jsize  len,
jstring result 
) [virtual]

To give proper "local" refs, need to run this in the true thread.

Implements nsISecureEnv.

Definition at line 1456 of file CSecureEnv.cpp.

{
    if (result == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // *result = mJavaEnv->NewString(unicode, len);
       class NewStringMessage : public JavaMessage {
              const jchar* unicode;
              jsize len;
              jstring* result;
       public:
              NewStringMessage(const jchar* unicode, jsize len, jstring* result)
              {
                     this->unicode = unicode;
                     this->len = len;
                     this->result = result;
              }

              virtual void execute(JNIEnv* env)
              {
              *result = env->NewString(unicode, len);
              }
       } msg(unicode, len, result);
    sendMessageToJava(&msg);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD CSecureEnv::NewStringUTF ( const char *  utf,
jstring result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::NewStringUTF ( const char *  utf,
jstring result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1522 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // *result = mJavaEnv->NewStringUTF(utf);
       class NewStringUTFMessage : public JavaMessage {
              const char *utf;
              jstring* result;
       public:
              NewStringUTFMessage(const char *utf, jstring* result)
              {
                     this->utf = utf;
                     this->result = result;
              }

              virtual void execute(JNIEnv* env)
              {
              *result = env->NewStringUTF(utf);
              }
       } msg(utf, result);
    sendMessageToJava(&msg);

    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]
NS_IMETHOD CSecureEnv::RegisterNatives ( jclass  clazz,
const JNINativeMethod methods,
jint  nMethods,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::RegisterNatives ( jclass  clazz,
const JNINativeMethod methods,
jint  nMethods,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1842 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

    *result = mJavaEnv->RegisterNatives(clazz, methods, nMethods);

    return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::ReleaseArrayElements ( jni_type  type,
jarray  array,
void elems,
jint  mode 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::ReleaseArrayElements ( jni_type  type,
jarray  array,
void elems,
jint  mode 
) [virtual]

Implements nsISecureEnv.

Definition at line 1717 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::ReleaseStringChars ( jstring  str,
const jchar chars 
) [virtual]

Implements nsISecureEnv.

Implements nsISecureEnv.

Definition at line 1510 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::ReleaseStringUTFChars ( jstring  str,
const char *  chars 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::ReleaseStringUTFChars ( jstring  str,
const char *  chars 
) [virtual]

Implements nsISecureEnv.

Definition at line 1575 of file CSecureEnv.cpp.

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

Defines an entry point for a newly created thread.

Implements nsIRunnable.

Runs the server thread for LiveConnect upcalls from spontaneous Java threads.

Implements nsIRunnable.

Definition at line 256 of file CSecureEnv.cpp.

{
       jboolean isRunning = true;
       NativeMonitor requestMonitor(mSession, mThreadManager);
       MRJMonitor replyMonitor(mSession);
       JavaMessageQueue requests(&requestMonitor), replies(&replyMonitor);
       // initialize(env, self, &isRunning, &requests, &replies);
       
       // we have to create the Proxy JNI here, so it associated with this thread.
       nsIJVMManager* manager = mPlugin->getManager();
       manager->CreateProxyJNI(this, &mProxyEnv);
       
       mIsRunning = &isRunning;
       mNativeQueue = &requests;
       mJavaQueue = &replies;
       
       // when this thread is running, no other thread can enter the request queue monitor.
       requests.enter();
       
       while (isRunning) {
              // the protocol for now is dead simple:  get a message from the
              // requests message queue, process it, and then put it back in
              // the replies queue. This will get more elaborate to handle
              // upcall requests. 
              JavaMessage* msg = requests.getMessage();
              if (msg != NULL) {
                     msg->execute(mProxyEnv);
                     replies.putMessage(msg);
                     replies.notify();
              } else {
                     // should we do sleep, timed wait, or what?
                     // env->CallStaticVoidMethod(clazz, yieldMethod);
                     // env->CallStaticVoidMethod(clazz, sleepMethod, jlong(kDefaultJMTime));
                     requests.wait();
              }
       }
       
       requests.exit();

       return NS_OK;
}

Here is the call graph for this function:

Definition at line 3095 of file CSecureEnv.cpp.

{
    // first off, always restore the env to a known state.
    jthrowable pendingException = env->ExceptionOccurred();
    if (pendingException) {
#if USE_LIVECONNECT_PROXY    
        env->ExceptionDescribe();
#endif
        env->ExceptionClear();
        
        if (mPendingException)
            env->DeleteGlobalRef(mPendingException);

        mPendingException = (jthrowable) env->NewGlobalRef(pendingException);
        env->DeleteLocalRef(pendingException);
    }
}

Here is the caller graph for this function:

void CSecureEnv::sendMessageFromJava ( JNIEnv javaEnv,
JavaMessage msg,
Boolean  busyWaiting = false 
)
void CSecureEnv::sendMessageFromJava ( JNIEnv javaEnv,
JavaMessage msg,
Boolean  busyWaiting = false 
)

Used to send a message from Java to Native threads.

Definition at line 309 of file CSecureEnv.cpp.

{
       messageLoop(javaEnv, msg, mNativeQueue, mJavaQueue, busyWaiting);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Used to send a message from Native to Java threads.

Definition at line 301 of file CSecureEnv.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::SetArrayRegion ( jni_type  type,
jarray  array,
jsize  start,
jsize  len,
void buf 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::SetArrayRegion ( jni_type  type,
jarray  array,
jsize  start,
jsize  len,
void buf 
) [virtual]

Implements nsISecureEnv.

Definition at line 1800 of file CSecureEnv.cpp.

NS_IMETHOD CSecureEnv::SetField ( jni_type  type,
jobject  obj,
jfieldID  fieldID,
jvalue  val,
nsISecurityContext ctx = NULL 
) [virtual]

Set a field on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
fieldID-- field id
val-- field value to set
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::SetField ( jni_type  type,
jobject  obj,
jfieldID  fieldID,
jvalue  val,
nsISecurityContext ctx = NULL 
) [virtual]

Set a field on Java object in LiveConnect.

Parameters:
type-- Return type
obj-- Java object.
fieldID-- field id
val-- field value to set
ctx-- security context

=--------------------------------------------------------------------------=

Implements nsISecureEnv.

Definition at line 781 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || obj == NULL || fieldID == NULL)
        return NS_ERROR_NULL_POINTER;

    // Set field on Java side
    // return SetJavaField(obj, field, val, ctx);

       JNIEnv* env = mJavaEnv;
       switch (type) {
       case jobject_type:
              env->SetObjectField(obj, fieldID, val.l);
              break;
       case jboolean_type:
              env->SetBooleanField(obj, fieldID, val.z);
              break;
       case jbyte_type:
              env->SetByteField(obj, fieldID, val.b);
              break;
       case jchar_type:
              env->SetCharField(obj, fieldID, val.c);
              break;
       case jshort_type:
              env->SetShortField(obj, fieldID, val.s);
              break;
       case jint_type:
              env->SetIntField(obj, fieldID, val.i);
              break;
       case jlong_type:
              env->SetLongField(obj, fieldID, val.j);
              break;
       case jfloat_type:
              env->SetFloatField(obj, fieldID, val.f);
              break;
       case jdouble_type:
              env->SetDoubleField(obj, fieldID, val.d);
              break;
       }
       
       return NS_OK;
}
void CSecureEnv::setJavaEnv ( JNIEnv javaEnv) [inline]

Definition at line 382 of file CSecureEnv.h.

{ mJavaEnv = javaEnv; }
void CSecureEnv::setJavaEnv ( JNIEnv javaEnv) [inline]

Definition at line 385 of file CSecureEnv.h.

{ mJavaEnv = javaEnv; }

Here is the caller graph for this function:

NS_IMETHOD CSecureEnv::SetObjectArrayElement ( jobjectArray  array,
jsize  index,
jobject  val 
) [virtual]

Implements nsISecureEnv.

Implements nsISecureEnv.

Definition at line 1624 of file CSecureEnv.cpp.

void CSecureEnv::setProxyEnv ( JNIEnv proxyEnv) [inline]

Definition at line 379 of file CSecureEnv.h.

void CSecureEnv::setProxyEnv ( JNIEnv proxyEnv) [inline]

Definition at line 382 of file CSecureEnv.h.

NS_IMETHOD CSecureEnv::SetStaticField ( jni_type  type,
jclass  clazz,
jfieldID  fieldID,
jvalue  val,
nsISecurityContext ctx = NULL 
) [virtual]

Set a static field on Java object in LiveConnect.

Parameters:
type-- Return type
clazz-- Class object.
fieldID-- field id
val-- field value to set
ctx-- security context

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::SetStaticField ( jni_type  type,
jclass  clazz,
jfieldID  fieldID,
jvalue  val,
nsISecurityContext ctx = NULL 
) [virtual]

Set a static field on Java object in LiveConnect.

Parameters:
type-- Return type
clazz-- Class object.
fieldID-- field id
val-- field value to set
ctx-- security context

=--------------------------------------------------------------------------=

Implements nsISecureEnv.

Definition at line 1037 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || clazz == NULL || fieldID == NULL)
        return NS_ERROR_NULL_POINTER;

       // Set static field on Java side
       // return SetJavaField(NULL, field, val, ctx);

       JNIEnv* env = mJavaEnv;
       switch (type) {
       case jobject_type:
              env->SetStaticObjectField(clazz, fieldID, val.l);
              break;
       case jboolean_type:
              env->SetStaticBooleanField(clazz, fieldID, val.z);
              break;
       case jbyte_type:
              env->SetStaticByteField(clazz, fieldID, val.b);
              break;
       case jchar_type:
              env->SetStaticCharField(clazz, fieldID, val.c);
              break;
       case jshort_type:
              env->SetStaticShortField(clazz, fieldID, val.s);
              break;
       case jint_type:
              env->SetStaticIntField(clazz, fieldID, val.i);
              break;
       case jlong_type:
              env->SetStaticLongField(clazz, fieldID, val.j);
              break;
       case jfloat_type:
              env->SetStaticFloatField(clazz, fieldID, val.f);
              break;
       case jdouble_type:
              env->SetStaticDoubleField(clazz, fieldID, val.d);
              break;
       }
       
       return NS_OK;
}
NS_IMETHOD CSecureEnv::Throw ( jthrowable  obj,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::Throw ( jthrowable  obj,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1216 of file CSecureEnv.cpp.

{
       if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
       // Huh? This doesn't really make sense.
    
    *result = mJavaEnv->Throw(obj);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::ThrowNew ( jclass  clazz,
const char *  msg,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::ThrowNew ( jclass  clazz,
const char *  msg,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1229 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;
    
    *result = mJavaEnv->ThrowNew(clazz, msg);

    return NS_OK;
}
NS_IMETHOD CSecureEnv::UnregisterNatives ( jclass  clazz,
jint result 
) [virtual]

Implements nsISecureEnv.

NS_IMETHODIMP CSecureEnv::UnregisterNatives ( jclass  clazz,
jint result 
) [virtual]

Implements nsISecureEnv.

Definition at line 1856 of file CSecureEnv.cpp.

{
    if (mJavaEnv == NULL || result == NULL)
        return NS_ERROR_NULL_POINTER;

    *result = mJavaEnv->UnregisterNatives(clazz);

    return NS_OK;
}

Member Data Documentation

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

Definition at line 416 of file CSecureEnv.h.

Definition at line 409 of file CSecureEnv.h.

Definition at line 408 of file CSecureEnv.h.

Definition at line 410 of file CSecureEnv.h.

Definition at line 417 of file CSecureEnv.h.

Definition at line 411 of file CSecureEnv.h.

Definition at line 413 of file CSecureEnv.h.

Definition at line 403 of file CSecureEnv.h.

Definition at line 404 of file CSecureEnv.h.

Definition at line 416 of file CSecureEnv.h.

Definition at line 415 of file CSecureEnv.h.

Definition at line 405 of file CSecureEnv.h.

Definition at line 406 of file CSecureEnv.h.

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

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