Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsAppFileLocProviderProxy.cpp File Reference
#include "nsAppFileLocProviderProxy.h"
#include "nsJavaXPCOMBindingUtils.h"
#include "nsILocalFile.h"
#include "nsISimpleEnumerator.h"

Go to the source code of this file.

Classes

class  DirectoryEnumerator

Functions

 NS_IMPL_ISUPPORTS2 (nsAppFileLocProviderProxy, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2) NS_IMETHODIMP nsAppFileLocProviderProxy
nsresult NS_NewAppFileLocProviderProxy (jobject aJavaLocProvider, nsIDirectoryServiceProvider **aResult)

Function Documentation

Definition at line 54 of file nsAppFileLocProviderProxy.cpp.

{
  // Setup params for calling Java function
  JNIEnv* env = GetJNIEnv();
  jstring prop = env->NewStringUTF(aProp);
  if (!prop)
    return NS_ERROR_OUT_OF_MEMORY;
  jbooleanArray persistant = env->NewBooleanArray(1);
  if (!persistant)
    return NS_ERROR_OUT_OF_MEMORY;

  // Create method ID
  jmethodID mid = nsnull;
  jclass clazz = env->GetObjectClass(mJavaLocProvider);
  if (clazz) {
    mid = env->GetMethodID(clazz, "getFile",
                           "(Ljava/lang/String;[Z)Ljava/io/File;");
  }
  if (!mid)
    return NS_ERROR_FAILURE;

  // Call Java function
  jobject javaFile = nsnull;
  javaFile = env->CallObjectMethod(mJavaLocProvider, mid, prop, persistant);
  if (javaFile == nsnull || env->ExceptionCheck())
    return NS_ERROR_FAILURE;

  // Set boolean output value
  env->GetBooleanArrayRegion(persistant, 0, 1, (jboolean*) aIsPersistant);

  // Set nsIFile result value
  nsCOMPtr<nsILocalFile> localFile;
  nsresult rv = File_to_nsILocalFile(env, javaFile, getter_AddRefs(localFile));
  if (NS_SUCCEEDED(rv)) {
    return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)aResult);
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 241 of file nsAppFileLocProviderProxy.cpp.

{
  nsAppFileLocProviderProxy* provider =
            new nsAppFileLocProviderProxy(aJavaLocProvider);
  if (provider == nsnull)
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(provider);

  *aResult = provider;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: