Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsJavaInterfaces.h File Reference
#include "jni.h"
#include "nscore.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MOZILLA_NATIVE(func)   Java_org_mozilla_xpcom_internal_MozillaImpl_##func
#define GRE_NATIVE(func)   Java_org_mozilla_xpcom_internal_GREImpl_##func
#define XPCOM_NATIVE(func)   Java_org_mozilla_xpcom_internal_XPCOMImpl_##func
#define JAVAPROXY_NATIVE(func)   Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_##func
#define LOCKPROXY_NATIVE(func)   Java_org_mozilla_xpcom_ProfileLock_##func
#define JXUTILS_NATIVE(func)   Java_org_mozilla_xpcom_internal_JavaXPCOMMethods_##func

Functions

NS_EXPORT void JNICALL
MOZILLA_NATIVE() 
initialize (JNIEnv *env, jobject)
NS_EXPORT void JNICALL GRE_NATIVE() initEmbedding (JNIEnv *env, jobject, jobject aLibXULDirectory, jobject aAppDirectory, jobject aAppDirProvider)
NS_EXPORT void JNICALL GRE_NATIVE() termEmbedding (JNIEnv *env, jobject)
NS_EXPORT jobject JNICALL
GRE_NATIVE() 
lockProfileDirectory (JNIEnv *, jobject, jobject aDirectory)
NS_EXPORT void JNICALL GRE_NATIVE() notifyProfile (JNIEnv *env, jobject)
NS_EXPORT jobject JNICALL
XPCOM_NATIVE() 
initXPCOM (JNIEnv *env, jobject, jobject aMozBinDirectory, jobject aAppFileLocProvider)
NS_EXPORT void JNICALL
XPCOM_NATIVE() 
shutdownXPCOM (JNIEnv *env, jobject, jobject aServMgr)
NS_EXPORT jobject JNICALL
XPCOM_NATIVE() 
newLocalFile (JNIEnv *env, jobject, jstring aPath, jboolean aFollowLinks)
NS_EXPORT jobject JNICALL
XPCOM_NATIVE() 
getComponentManager (JNIEnv *env, jobject)
NS_EXPORT jobject JNICALL
XPCOM_NATIVE() 
getComponentRegistrar (JNIEnv *env, jobject)
NS_EXPORT jobject JNICALL
XPCOM_NATIVE() 
getServiceManager (JNIEnv *env, jobject)
NS_EXPORT jobject JNICALL
JAVAPROXY_NATIVE() 
callXPCOMMethod (JNIEnv *env, jclass that, jobject aJavaProxy, jstring aMethodName, jobjectArray aParams)
 org.mozilla.xpcom.XPCOMJavaProxy.internal.callXPCOMMethod
NS_EXPORT void JNICALL
JAVAPROXY_NATIVE() 
finalizeProxy (JNIEnv *env, jclass that, jobject aJavaProxy)
 org.mozilla.xpcom.internal.XPCOMJavaProxy.finalizeProxy
NS_EXPORT jboolean JNICALL
JAVAPROXY_NATIVE() 
isSameXPCOMObject (JNIEnv *env, jclass that, jobject aProxy1, jobject aProxy2)
 org.mozilla.xpcom.XPCOMJavaProxy.isSameXPCOMObject
NS_EXPORT void JNICALL
LOCKPROXY_NATIVE() 
release (JNIEnv *env, jclass that, jlong aLockObject)
 org.mozilla.xpcom.ProfileLock.release
NS_EXPORT jlong JNICALL
MOZILLA_NATIVE() 
getNativeHandleFromAWT (JNIEnv *env, jobject, jobject widget)
NS_EXPORT jlong JNICALL
JXUTILS_NATIVE() 
wrapJavaObject (JNIEnv *env, jobject, jobject aJavaObject, jstring aIID)
NS_EXPORT jobject JNICALL
JXUTILS_NATIVE() 
wrapXPCOMObject (JNIEnv *env, jobject, jlong aXPCOMObject, jstring aIID)

Define Documentation

#define GRE_NATIVE (   func)    Java_org_mozilla_xpcom_internal_GREImpl_##func

Definition at line 44 of file nsJavaInterfaces.h.

#define JAVAPROXY_NATIVE (   func)    Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_##func

Definition at line 46 of file nsJavaInterfaces.h.

#define JXUTILS_NATIVE (   func)    Java_org_mozilla_xpcom_internal_JavaXPCOMMethods_##func

Definition at line 49 of file nsJavaInterfaces.h.

#define LOCKPROXY_NATIVE (   func)    Java_org_mozilla_xpcom_ProfileLock_##func

Definition at line 48 of file nsJavaInterfaces.h.

#define MOZILLA_NATIVE (   func)    Java_org_mozilla_xpcom_internal_MozillaImpl_##func

Definition at line 43 of file nsJavaInterfaces.h.

#define XPCOM_NATIVE (   func)    Java_org_mozilla_xpcom_internal_XPCOMImpl_##func

Definition at line 45 of file nsJavaInterfaces.h.


Function Documentation

NS_EXPORT jobject JNICALL JAVAPROXY_NATIVE() callXPCOMMethod ( JNIEnv env,
jclass  that,
jobject  aJavaProxy,
jstring  aMethodName,
jobjectArray  aParams 
)

org.mozilla.xpcom.XPCOMJavaProxy.internal.callXPCOMMethod

Definition at line 1466 of file nsJavaWrapper.cpp.

{
  nsresult rv;

  // Get native XPCOM instance
  void* xpcom_obj;
  rv = GetXPCOMInstFromProxy(env, aJavaProxy, &xpcom_obj);
  if (NS_FAILED(rv)) {
    ThrowException(env, 0, "Failed to get matching XPCOM object");
    return nsnull;
  }
  JavaXPCOMInstance* inst = NS_STATIC_CAST(JavaXPCOMInstance*, xpcom_obj);

  // Get method info
  PRUint16 methodIndex;
  const nsXPTMethodInfo* methodInfo;
  nsIInterfaceInfo* iinfo = inst->InterfaceInfo();
  const char* methodName = env->GetStringUTFChars(aMethodName, nsnull);
  rv = QueryMethodInfo(iinfo, methodName, &methodIndex, &methodInfo);
  env->ReleaseStringUTFChars(aMethodName, methodName);

  if (NS_FAILED(rv)) {
    ThrowException(env, rv, "GetMethodInfoForName failed");
    return nsnull;
  }

#ifdef DEBUG_JAVAXPCOM
  const char* ifaceName;
  iinfo->GetNameShared(&ifaceName);
  LOG(("===> (XPCOM) %s::%s()\n", ifaceName, methodInfo->GetName()));
#endif

  // Convert the Java params
  PRUint8 paramCount = methodInfo->GetParamCount();
  nsXPTCVariant* params = nsnull;
  if (paramCount)
  {
    params = new nsXPTCVariant[paramCount];
    if (!params) {
      ThrowException(env, NS_ERROR_OUT_OF_MEMORY, "Can't create params array");
      return nsnull;
    }
    memset(params, 0, paramCount * sizeof(nsXPTCVariant));

    PRBool foundDependentParam = PR_FALSE;
    for (PRUint8 i = 0; i < paramCount && NS_SUCCEEDED(rv); i++)
    {
      LOG(("\t Param %d: ", i));
      const nsXPTParamInfo &paramInfo = methodInfo->GetParam(i);
      params[i].type = paramInfo.GetType();

      if (params[i].type.IsDependent() && paramInfo.IsIn()) {
        foundDependentParam = PR_TRUE;
        continue;
      }
      
      if (paramInfo.IsIn()) {
        PRUint8 type = params[i].type.TagPart();

        // get IID for interface params
        nsID iid;
        if (type == nsXPTType::T_INTERFACE) {
          rv = GetIIDForMethodParam(iinfo, methodInfo, paramInfo, type,
                                    methodIndex, params, PR_TRUE, iid);
        }

        if (NS_SUCCEEDED(rv)) {
          jobject param = nsnull;
          if (aParams && !paramInfo.IsRetval()) {
            param = env->GetObjectArrayElement(aParams, i);
          }
          rv = SetupParams(env, param, type, paramInfo.IsOut(), iid, 0, 0,
                           PR_FALSE, 0, params[i]);
        }
      } else {
        LOG(("out/retval\n"));
        params[i].ptr = &(params[i].val);
        params[i].SetPtrIsData();
      }
    }
    
    // Handle any dependent params by doing a second pass
    if (foundDependentParam) {
      
      for (PRUint8 j = 0; j < paramCount && NS_SUCCEEDED(rv); j++) {
        
        const nsXPTParamInfo &paramInfo = methodInfo->GetParam(j);
        params[j].type = paramInfo.GetType();

        if (!params[j].type.IsDependent())
          continue;

        if (paramInfo.IsIn()) {
          PRUint8 type = params[j].type.TagPart();

          // is paramater an array or sized string?
          PRUint8 arrayType = 0;
          PRUint32 arraySize = 0;
          PRBool isArray = params[j].type.IsArray();
          PRBool isSizedString = isArray ? PR_FALSE :
                   type == nsXPTType::T_PSTRING_SIZE_IS ||
                   type == nsXPTType::T_PWSTRING_SIZE_IS;

          if (isArray) {
            // get array type
            nsXPTType xpttype;
            rv = iinfo->GetTypeForParam(methodIndex, &paramInfo, 1, &xpttype);
            if (NS_FAILED(rv))
              break;
            arrayType = xpttype.TagPart();
            // IDL 'octet' arrays are not 'promoted' to short, but kept as 'byte';
            // therefore, treat as a signed 8bit value
            if (arrayType == nsXPTType::T_U8)
              arrayType = nsXPTType::T_I8;
          }

          if (isArray || isSizedString) {
            // get size of array or string
            PRUint8 argnum;
            rv = iinfo->GetSizeIsArgNumberForParam(methodIndex, &paramInfo, 0,
                                                   &argnum);
            if (NS_FAILED(rv))
              break;
            arraySize = params[argnum].val.u32;
          }

          // get IID for interface params
          nsID iid;
          if (type == nsXPTType::T_INTERFACE_IS ||
              type == nsXPTType::T_ARRAY &&
                (arrayType == nsXPTType::T_INTERFACE ||
                 arrayType == nsXPTType::T_INTERFACE_IS))
          {
            PRUint8 paramType = type == nsXPTType::T_ARRAY ? arrayType : type;
            rv = GetIIDForMethodParam(iinfo, methodInfo, paramInfo, paramType,
                                      methodIndex, params, PR_TRUE, iid);
          }

          if (NS_SUCCEEDED(rv)) {
            jobject param = nsnull;
            if (aParams && !paramInfo.IsRetval()) {
              param = env->GetObjectArrayElement(aParams, j);
            }
            rv = SetupParams(env, param, type, paramInfo.IsOut(), iid, arrayType,
                             arraySize, PR_FALSE, 0, params[j]);
          }
        }
      }
    }
    
    if (NS_FAILED(rv)) {
      ThrowException(env, rv, "SetupParams failed");
      return nsnull;
    }
  }

  // Call the XPCOM method
  const nsIID* iid;
  iinfo->GetIIDShared(&iid);
  nsISupports* realObject;
  rv = inst->GetInstance()->QueryInterface(*iid, (void**) &realObject);
  if (NS_FAILED(rv)) {
    ThrowException(env, rv, "Failed to get real XPCOM object");
    return nsnull;
  }
  nsresult invokeResult = XPTC_InvokeByIndex(realObject, methodIndex,
                                             paramCount, params);
  NS_RELEASE(realObject);

  // Clean up params
  jobject result = nsnull;
  for (PRUint8 i = 0; i < paramCount && NS_SUCCEEDED(rv); i++)
  {
    const nsXPTParamInfo &paramInfo = methodInfo->GetParam(i);
    PRUint8 type = paramInfo.GetType().TagPart();

    // is paramater an array or sized string?
    PRUint8 arrayType = 0;
    PRUint32 arraySize = 0;
    PRBool isArray = params[i].type.IsArray();
    PRBool isSizedString = isArray ? PR_FALSE :
             type == nsXPTType::T_PSTRING_SIZE_IS ||
             type == nsXPTType::T_PWSTRING_SIZE_IS;

    if (isArray) {
      // get array type
      nsXPTType array_xpttype;
      rv = iinfo->GetTypeForParam(methodIndex, &paramInfo, 1, &array_xpttype);
      if (NS_FAILED(rv))
        break;
      arrayType = array_xpttype.TagPart();
      // IDL 'octet' arrays are not 'promoted' to short, but kept as 'byte';
      // therefore, treat as a signed 8bit value
      if (arrayType == nsXPTType::T_U8)
        arrayType = nsXPTType::T_I8;
    }

    if (isArray || isSizedString) {
      // get size of array
      PRUint8 argnum;
      rv = iinfo->GetSizeIsArgNumberForParam(methodIndex, &paramInfo, 0,
                                             &argnum);
      if (NS_FAILED(rv))
        break;
      arraySize = params[argnum].val.u32;
    }

    // get IID for interface params
    nsID iid;
    if (type == nsXPTType::T_INTERFACE || type == nsXPTType::T_INTERFACE_IS ||
        type == nsXPTType::T_ARRAY && (arrayType == nsXPTType::T_INTERFACE ||
                                       arrayType == nsXPTType::T_INTERFACE_IS))
    {
      PRUint8 paramType = type == nsXPTType::T_ARRAY ? arrayType : type;
      rv = GetIIDForMethodParam(iinfo, methodInfo, paramInfo, paramType,
                                methodIndex, params, PR_TRUE, iid);
      if (NS_FAILED(rv))
        break;
    }

    jobject* javaElement;
    if (!paramInfo.IsRetval()) {
      jobject element = env->GetObjectArrayElement(aParams, i);
      javaElement = &element;
    } else {
      javaElement = &result;
    }
    rv = FinalizeParams(env, paramInfo, type, params[i], iid, PR_FALSE,
                        arrayType, arraySize, 0, invokeResult, javaElement);
  }

  // Normally, we would delete any created nsID object in the above loop.
  // However, GetIIDForMethodParam may need some of the nsID params when it's
  // looking for the IID of an INTERFACE_IS.  Therefore, we can't delete it
  // until we've gone through the 'Finalize' loop once and created the result.
  for (PRUint8 j = 0; j < paramCount; j++)
  {
    const nsXPTParamInfo &paramInfo = methodInfo->GetParam(j);
    const nsXPTType &type = paramInfo.GetType();
    if (type.TagPart() == nsXPTType::T_IID) {
      nsID* iid = (nsID*) params[j].val.p;
      delete iid;
    }
  }

  if (params) {
    delete params;
  }

  // If the XPCOM method invocation failed, we don't immediately throw an
  // exception and return so that we can clean up any parameters.
  if (NS_FAILED(invokeResult)) {
    nsCAutoString message("The function \"");
    message.AppendASCII(methodInfo->GetName());
    message.AppendLiteral("\" returned an error condition");
    ThrowException(env, invokeResult, message.get());
  }
  if (NS_FAILED(rv)) {
    ThrowException(env, rv, "FinalizeParams failed");
    return nsnull;
  }

  LOG(("<=== (XPCOM) %s::%s()\n", ifaceName, methodInfo->GetName()));
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT void JNICALL JAVAPROXY_NATIVE() finalizeProxy ( JNIEnv env,
jclass  that,
jobject  aJavaProxy 
)

org.mozilla.xpcom.internal.XPCOMJavaProxy.finalizeProxy

Definition at line 1837 of file nsJavaWrapper.cpp.

{
#ifdef DEBUG_JAVAXPCOM
  PRUint32 xpcom_addr = 0;
#endif

  // Due to Java's garbage collection, this finalize statement may get called
  // after FreeJavaGlobals().  So check to make sure that everything is still
  // initialized.
  if (gJavaXPCOMLock) {
    nsAutoLock lock(gJavaXPCOMLock);

    // If may be possible for the lock to be acquired here when FreeGlobals is
    // in the middle of running.  If so, then this thread will sleep until
    // FreeGlobals releases its lock.  At that point, we resume this thread
    // here, but JavaXPCOM may no longer be initialized.  So we need to check
    // that everything is legit after acquiring the lock.
    if (gJavaXPCOMInitialized) {
      // Get native XPCOM instance
      void* xpcom_obj;
      nsresult rv = GetXPCOMInstFromProxy(env, aJavaProxy, &xpcom_obj);
      if (NS_SUCCEEDED(rv)) {
        JavaXPCOMInstance* inst = NS_STATIC_CAST(JavaXPCOMInstance*, xpcom_obj);
#ifdef DEBUG_JAVAXPCOM
        xpcom_addr = NS_REINTERPRET_CAST(PRUint32, inst->GetInstance());
#endif
        nsIID* iid;
        rv = inst->InterfaceInfo()->GetInterfaceIID(&iid);
        if (NS_SUCCEEDED(rv)) {
          rv = gNativeToJavaProxyMap->Remove(env, inst->GetInstance(), *iid);
          nsMemory::Free(iid);
        }
        NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to RemoveJavaProxy");
        // Release gJavaXPCOMLock before deleting inst (see bug 340022)
        lock.unlock();
        delete inst;
      }
    }
  }

#ifdef DEBUG_JAVAXPCOM
  LOG(("- Finalize (Java=%08x | XPCOM=%08x)\n",
       (PRUint32) env->CallStaticIntMethod(systemClass, hashCodeMID,
                                           aJavaProxy),
       xpcom_addr));
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 336 of file nsJavaInterfaces.cpp.

{
  // Call XPCOM method
  nsCOMPtr<nsIComponentManager> cm;
  nsresult rv = NS_GetComponentManager(getter_AddRefs(cm));

  if (NS_SUCCEEDED(rv)) {
    jobject javaProxy;
    rv = GetNewOrUsedJavaObject(env, cm, NS_GET_IID(nsIComponentManager),
                                nsnull, &javaProxy);
    if (NS_SUCCEEDED(rv))
      return javaProxy;
  }

  ThrowException(env, rv, "Failure in getComponentManager");
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 355 of file nsJavaInterfaces.cpp.

{
  // Call XPCOM method
  nsCOMPtr<nsIComponentRegistrar> cr;
  nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(cr));

  if (NS_SUCCEEDED(rv)) {
    jobject javaProxy;
    rv = GetNewOrUsedJavaObject(env, cr, NS_GET_IID(nsIComponentRegistrar),
                                nsnull, &javaProxy);
    if (NS_SUCCEEDED(rv))
      return javaProxy;
  }

  ThrowException(env, rv, "Failure in getComponentRegistrar");
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 397 of file nsJavaInterfaces.cpp.

{
  PRUint64 handle = 0;

#ifdef XP_MACOSX
  JAWT awt;
  awt.version = JAWT_VERSION_1_4;
  jboolean result = JAWT_GetAWT(env, &awt);
  if (result == JNI_FALSE)
    return 0;
    
  JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, widget);
  if (ds != nsnull) {
    jint lock = ds->Lock(ds);
    if (!(lock & JAWT_LOCK_ERROR)) {
      JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
      if (dsi) {
        handle = GetPlatformHandle(dsi);
        ds->FreeDrawingSurfaceInfo(dsi);
      }

      ds->Unlock(ds);
    }

    awt.FreeDrawingSurface(ds);
  }
#else
  NS_WARNING("getNativeHandleFromAWT JNI method not implemented");
#endif

  return handle;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 374 of file nsJavaInterfaces.cpp.

{
  // Call XPCOM method
  nsCOMPtr<nsIServiceManager> sm;
  nsresult rv = NS_GetServiceManager(getter_AddRefs(sm));

  if (NS_SUCCEEDED(rv)) {
    jobject javaProxy;
    rv = GetNewOrUsedJavaObject(env, sm, NS_GET_IID(nsIServiceManager),
                                nsnull, &javaProxy);
    if (NS_SUCCEEDED(rv))
      return javaProxy;
  }

  ThrowException(env, rv, "Failure in getServiceManager");
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT void JNICALL GRE_NATIVE() initEmbedding ( JNIEnv env,
jobject  ,
jobject  aLibXULDirectory,
jobject  aAppDirectory,
jobject  aAppDirProvider 
)

Definition at line 124 of file nsJavaInterfaces.cpp.

{
  nsresult rv = InitEmbedding_Impl(env, aLibXULDirectory, aAppDirectory,
                                   aAppDirProvider);

  if (NS_FAILED(rv)) {
    ThrowException(env, rv, "Failure in initEmbedding");
    FreeJavaGlobals(env);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file nsJavaInterfaces.cpp.

{
  if (!InitializeJavaGlobals(env)) {
    jclass clazz =
        env->FindClass("org/mozilla/xpcom/XPCOMInitializationException");
    if (clazz) {
      env->ThrowNew(clazz, "Failed to initialize JavaXPCOM");
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT jobject JNICALL XPCOM_NATIVE() initXPCOM ( JNIEnv env,
jobject  ,
jobject  aMozBinDirectory,
jobject  aAppFileLocProvider 
)

Definition at line 266 of file nsJavaInterfaces.cpp.

{
  jobject servMan;
  nsresult rv = InitXPCOM_Impl(env, aMozBinDirectory, aAppFileLocProvider,
                               &servMan);
  if (NS_SUCCEEDED(rv))
    return servMan;

  ThrowException(env, rv, "Failure in initXPCOM");
  FreeJavaGlobals(env);
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT jboolean JNICALL JAVAPROXY_NATIVE() isSameXPCOMObject ( JNIEnv env,
jclass  that,
jobject  aProxy1,
jobject  aProxy2 
)

org.mozilla.xpcom.XPCOMJavaProxy.isSameXPCOMObject

Definition at line 1889 of file nsJavaWrapper.cpp.

{
  void* xpcom_obj1;
  nsresult rv = GetXPCOMInstFromProxy(env, aProxy1, &xpcom_obj1);
  if (NS_SUCCEEDED(rv)) {
    void* xpcom_obj2;
    rv = GetXPCOMInstFromProxy(env, aProxy2, &xpcom_obj2);
    if (NS_SUCCEEDED(rv)) {
      JavaXPCOMInstance* inst1 = NS_STATIC_CAST(JavaXPCOMInstance*, xpcom_obj1);
      JavaXPCOMInstance* inst2 = NS_STATIC_CAST(JavaXPCOMInstance*, xpcom_obj2);
      if (inst1->GetInstance() == inst2->GetInstance()) {
        return JNI_TRUE;
      }
    }
  }
  return JNI_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file nsJavaInterfaces.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;

  if (aDirectory) {
    nsCOMPtr<nsILocalFile> profileDir;
    rv = File_to_nsILocalFile(env, aDirectory, getter_AddRefs(profileDir));

    if (NS_SUCCEEDED(rv)) {
      nsIProfileLock* lock;
      rv = NS_LockProfilePath(profileDir, nsnull, nsnull, &lock);

      if (NS_SUCCEEDED(rv)) {
        jclass clazz =
            env->FindClass("org/mozilla/xpcom/ProfileLock");
        if (clazz) {
          jmethodID mid = env->GetMethodID(clazz, "<init>", "(J)V");
          if (mid) {
            return env->NewObject(clazz, mid, NS_REINTERPRET_CAST(jlong, lock));
          }
        }

        // if we get here, then something failed
        rv = NS_ERROR_FAILURE;
      }
    }
  }

  ThrowException(env, rv, "Failure in lockProfileDirectory");
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT jobject JNICALL XPCOM_NATIVE() newLocalFile ( JNIEnv env,
jobject  ,
jstring  aPath,
jboolean  aFollowLinks 
)

Definition at line 305 of file nsJavaInterfaces.cpp.

{
  // Create a Mozilla string from the jstring
  const PRUnichar* buf = nsnull;
  if (aPath) {
    buf = env->GetStringChars(aPath, nsnull);
    if (!buf)
      return nsnull;  // exception already thrown
  }

  nsAutoString path_str(buf);
  env->ReleaseStringChars(aPath, buf);

  // Make call to given function
  nsCOMPtr<nsILocalFile> file;
  nsresult rv = NS_NewLocalFile(path_str, aFollowLinks, getter_AddRefs(file));

  if (NS_SUCCEEDED(rv)) {
    jobject javaProxy;
    rv = GetNewOrUsedJavaObject(env, file, NS_GET_IID(nsILocalFile),
                                nsnull, &javaProxy);
    if (NS_SUCCEEDED(rv))
      return javaProxy;
  }

  ThrowException(env, rv, "Failure in newLocalFile");
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 211 of file nsJavaInterfaces.cpp.

{
  if (!profileNotified) {
    nsCOMPtr<nsIObserverService> obsSvc
      (do_GetService("@mozilla.org/observer-service;1"));

    if (obsSvc) {
      profileNotified = PR_TRUE;

      static const PRUnichar kStartup[] = {'s','t','a','r','t','u','p','\0'};
      obsSvc->NotifyObservers(nsnull, "profile-do-change", kStartup);
      obsSvc->NotifyObservers(nsnull, "profile-after-change", kStartup);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT void JNICALL LOCKPROXY_NATIVE() release ( JNIEnv env,
jclass  that,
jlong  aLockObject 
)

org.mozilla.xpcom.ProfileLock.release

Definition at line 1912 of file nsJavaWrapper.cpp.

{
  // Need to release object on the main thread.
  nsCOMPtr<nsIEventQueue> eventQ;
  nsresult rv = NS_GetMainEventQ(getter_AddRefs(eventQ));
  if (NS_SUCCEEDED(rv)) {
    rv = NS_ProxyRelease(eventQ, NS_REINTERPRET_CAST(nsISupports*, aLockObject));
  }
  NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to release using NS_ProxyRelease");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 281 of file nsJavaInterfaces.cpp.

{
  nsresult rv;
  nsIServiceManager* servMgr = nsnull;
  if (aServMgr) {
    // Get native XPCOM instance
    rv = GetNewOrUsedXPCOMObject(env, aServMgr, NS_GET_IID(nsIServiceManager),
                                 (nsISupports**) &servMgr);
    NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get XPCOM obj for ServiceMgr.");

    // Even if we failed to get the matching xpcom object, we don't abort this
    // function.  Just call NS_ShutdownXPCOM with a null service manager.
  }

  // Free globals before calling NS_ShutdownXPCOM(), since we need some
  // XPCOM services.
  FreeJavaGlobals(env);

  rv = NS_ShutdownXPCOM(servMgr);
  if (NS_FAILED(rv))
    ThrowException(env, rv, "NS_ShutdownXPCOM failed");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 137 of file nsJavaInterfaces.cpp.

{
  if (profileNotified) {
    nsCOMPtr<nsIObserverService> obssvc
      (do_GetService("@mozilla.org/observer-service;1"));
    NS_ASSERTION(obssvc, "No observer service?");
    if (obssvc) {
      nsCOMPtr<nsIProfileChangeStatus> cs = new ProfileChangeStatusImpl();
      static const PRUnichar kShutdownPersist[] =
        {'s','h','u','t','d','o','w','n','-','p','e','r','s','i','s','t','\0'};
      obssvc->NotifyObservers(cs, "profile-change-net-teardown",
                              kShutdownPersist);
      obssvc->NotifyObservers(cs, "profile-change-teardown", kShutdownPersist);

      // Now that things are torn down, force JS GC so that things
      // which depend on resources which are about to go away in
      // "profile-before-change" are destroyed first.
      nsCOMPtr<nsIThreadJSContextStack> stack
        (do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
      if (stack)
      {
        JSContext *cx = nsnull;
        stack->GetSafeJSContext(&cx);
        if (cx)
          ::JS_GC(cx);
      }

      // Notify observers of a profile change
      obssvc->NotifyObservers(cs, "profile-before-change", kShutdownPersist);
    }
    profileNotified = PR_FALSE;
  }

  // Free globals before calling XRE_TermEmbedding(), since we need some
  // XPCOM services.
  FreeJavaGlobals(env);

  XRE_TermEmbedding();
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT jlong JNICALL JXUTILS_NATIVE() wrapJavaObject ( JNIEnv env,
jobject  ,
jobject  aJavaObject,
jstring  aIID 
)

Definition at line 432 of file nsJavaInterfaces.cpp.

{
  nsresult rv;
  nsISupports* xpcomObject = nsnull;

  if (!aJavaObject || !aIID) {
    rv = NS_ERROR_NULL_POINTER;
  } else {
    const char* str = env->GetStringUTFChars(aIID, nsnull);
    if (!str) {
      rv = NS_ERROR_OUT_OF_MEMORY;
    } else {
      nsID iid;
      if (iid.Parse(str)) {
        rv = GetNewOrUsedXPCOMObject(env, aJavaObject, iid, &xpcomObject);
      } else {
        rv = NS_ERROR_INVALID_ARG;
      }

      env->ReleaseStringUTFChars(aIID, str);
    }
  }

  if (NS_FAILED(rv)) {
    ThrowException(env, rv, "Failed to create XPCOM proxy for Java object");
  }
  return NS_REINTERPRET_CAST(jlong, xpcomObject);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT jobject JNICALL JXUTILS_NATIVE() wrapXPCOMObject ( JNIEnv env,
jobject  ,
jlong  aXPCOMObject,
jstring  aIID 
)

Definition at line 463 of file nsJavaInterfaces.cpp.

{
  nsresult rv;
  jobject javaObject = nsnull;
  nsISupports* xpcomObject = NS_REINTERPRET_CAST(nsISupports*, aXPCOMObject);

  if (!xpcomObject || !aIID) {
    rv = NS_ERROR_NULL_POINTER;
  } else {
    const char* str = env->GetStringUTFChars(aIID, nsnull);
    if (!str) {
      rv = NS_ERROR_OUT_OF_MEMORY;
    } else {
      nsID iid;
      if (iid.Parse(str)) {
        // XXX Should we be passing something other than NULL for aObjectLoader?
        rv = GetNewOrUsedJavaObject(env, xpcomObject, iid, nsnull, &javaObject);
      } else {
        rv = NS_ERROR_INVALID_ARG;
      }

      env->ReleaseStringUTFChars(aIID, str);
    }
  }

  if (NS_FAILED(rv)) {
    ThrowException(env, rv, "Failed to create XPCOM proxy for Java object");
  }
  return javaObject;
}

Here is the call graph for this function:

Here is the caller graph for this function: