bug: 55004
r=ashuk a=edburns This fix makes it so bookmarks work with the tip of the branch as of 11/01/00. This fix removes the necessity to modify xpcom/base/nsDebug.cpp to remove the thread safety assertions. This fix primarily does two things: 1. Make nsActionEvents for all bookmarks/rdf actions 2. Remove the synchronized(this.browserControlCanvas.getTreeLock()) call around nativeProcessEvents() in NativeEventThread.run(). Files in this fix: M classes_spec/org/mozilla/webclient/test/EMWindow.java M classes_spec/org/mozilla/webclient/wrapper_native/BookmarkEntryImpl.java M classes_spec/org/mozilla/webclient/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java M classes_spec/org/mozilla/webclient/wrapper_native/RDFEnumeration.java M classes_spec/org/mozilla/webclient/wrapper_native/RDFTreeNode.java M src_moz/BookmarksImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp M src_moz/nsActions.cpp M src_moz/nsActions.h M src_moz/motif/NativeLoaderStub.cpp git-svn-id: svn://10.0.0.236/trunk@82262 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "ns_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
@@ -39,64 +40,63 @@ Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeAddBookmark
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeGetBookmarks
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
|
||||
rv = rdf_InitRDFUtils();
|
||||
if (NS_FAILED(rv)) {
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetBookmarks");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't initialize RDF Utils");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (jint) kNC_BookmarksRoot.get();
|
||||
|
||||
wsInitBookmarksEvent *actionEvent = new wsInitBookmarksEvent(initContext);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode
|
||||
(JNIEnv *env, jobject obj, jstring urlString, jboolean isFolder)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString,
|
||||
jboolean isFolder)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> newNode;
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
nsCAutoString uri("NC:BookmarksRoot");
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
const char *url = ::util_GetStringUTFChars(env, urlString);
|
||||
uri.Append("#$");
|
||||
uri.Append(url);
|
||||
PRUnichar *uriUni = uri.ToNewUnicode();
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeNewRDFNode");
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = gRDF->GetUnicodeResource(uriUni, getter_AddRefs(newNode));
|
||||
nsCRT::free(uriUni);
|
||||
::util_ReleaseStringUTFChars(env, urlString, url);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create new nsIRDFResource.");
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't get new RDFNode");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (isFolder) {
|
||||
rv = gRDFCU->MakeSeq(gBookmarksDataSource, newNode, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: unable to make new folder as a sequence.");
|
||||
return result;
|
||||
}
|
||||
rv = gBookmarksDataSource->Assert(newNode, kRDF_type,
|
||||
kNC_Folder, PR_TRUE);
|
||||
if (rv != NS_OK) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: unable to mark new folder as folder.");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *url = ::util_GetStringUTFChars(env, urlString);
|
||||
if (!url) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't get new RDFNode, can't create url string");
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
* Do the AddRef here.
|
||||
|
||||
*/
|
||||
|
||||
result = (jint)newNode.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
|
||||
|
||||
wsNewRDFNodeEvent *actionEvent = new wsNewRDFNodeEvent(initContext,
|
||||
url,
|
||||
(PRBool) isFolder);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
|
||||
::util_ReleaseStringUTFChars(env, urlString, url);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "rdf_util.h"
|
||||
#include "rdf_progids.h"
|
||||
#include "ns_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@@ -35,218 +36,92 @@
|
||||
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
|
||||
//
|
||||
// Local function prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* pull the int for the field nativeEnum from the java object obj.
|
||||
|
||||
*/
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode);
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeHasMoreElements
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
{
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRBool prResult = PR_FALSE;
|
||||
// assert -1 != nativeRDFNode
|
||||
jint nativeEnum;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jboolean result = JNI_FALSE;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeIsContainer");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't see if isContainer");
|
||||
return result;
|
||||
}
|
||||
wsRDFHasMoreElementsEvent *actionEvent =
|
||||
new wsRDFHasMoreElementsEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(void *) obj);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (0 != voidResult) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
if (-1 == (nativeEnum = getNativeEnumFromJava(env, obj, nativeRDFNode))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't get nativeEnum from nativeRDFNode.");
|
||||
return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
|
||||
rv = enumerator->HasMoreElements(&prResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't ask nsISimpleEnumerator->HasMoreElements().");
|
||||
return result;
|
||||
}
|
||||
result = (PR_FALSE == prResult) ? JNI_FALSE : JNI_TRUE;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
{
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
PRBool hasMoreElements = PR_FALSE;
|
||||
// assert -1 != nativeRDFNode
|
||||
jint nativeEnum;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsCOMPtr<nsIRDFNode> nodeResult;
|
||||
|
||||
if (-1 == (nativeEnum = getNativeEnumFromJava(env, obj, nativeRDFNode))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't get nativeEnum from nativeRDFNode.");
|
||||
return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
|
||||
rv = enumerator->HasMoreElements(&hasMoreElements);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't ask nsISimpleEnumerator->HasMoreElements().");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!hasMoreElements) {
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = enumerator->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("Exception: nativeNextElement: Can't get next from enumerator.\n"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// make sure it's an RDFNode
|
||||
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFNode),
|
||||
getter_AddRefs(nodeResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("Exception: nativeNextElement: next from enumerator is not an nsIRDFNode.\n"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (jint)nodeResult.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
return result;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jint result = -1;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeIsContainer");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't see if isContainer");
|
||||
return result;
|
||||
}
|
||||
wsRDFNextElementEvent *actionEvent =
|
||||
new wsRDFNextElementEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(void *) obj);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
(JNIEnv *env, jobject obj)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jint nativeEnum, nativeContainer;
|
||||
|
||||
// release the nsISimpleEnumerator
|
||||
if (-1 == (nativeEnum =
|
||||
::util_GetIntValueFromInstance(env, obj, "nativeEnum"))) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeFinalize: Can't get fieldID for nativeEnum.\n"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator =
|
||||
(nsISimpleEnumerator *) nativeEnum;
|
||||
((nsISupports *)enumerator.get())->Release();
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
// release the nsIRDFContainer
|
||||
if (-1 == (nativeContainer =
|
||||
::util_GetIntValueFromInstance(env, obj, "nativeContainer"))) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeFinalize: Can't get fieldID for nativeContainerFieldID.\n"));
|
||||
}
|
||||
return;
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeFinalize");
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't finalize");
|
||||
}
|
||||
nsCOMPtr<nsIRDFContainer> container =
|
||||
(nsIRDFContainer *) nativeContainer;
|
||||
((nsISupports *)container.get())->Release();
|
||||
|
||||
wsRDFFinalizeEvent *actionEvent =
|
||||
new wsRDFFinalizeEvent((void *) obj);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
if (NS_FAILED((nsresult) voidResult)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't Finalize");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
|
||||
result = ::util_GetIntValueFromInstance(env, obj, "nativeEnum");
|
||||
|
||||
// if the field has been initialized, just return the value
|
||||
if (-1 != result) {
|
||||
// NORMAL EXIT 1
|
||||
return result;
|
||||
}
|
||||
|
||||
// else, we need to create the enum
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
// get a container in order to get the enum
|
||||
rv = gComponentManager->CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("recursiveResourceTraversal: can't get a new container\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, nodeResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Can't Init container.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Can't get enumeration from container.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// IMPORTANT: Store the enum back into java
|
||||
::util_SetIntValueForInstance(env,obj,"nativeEnum",(jint)enumerator.get());
|
||||
// IMPORTANT: make sure it doesn't get deleted when it goes out of scope
|
||||
((nsISupports *)enumerator.get())->AddRef();
|
||||
|
||||
// PENDING(edburns): I'm not sure if we need to keep the
|
||||
// nsIRDFContainer from being destructed in order to maintain the
|
||||
// validity of the nsISimpleEnumerator that came from the container.
|
||||
// Just to be safe, I'm doing so.
|
||||
::util_SetIntValueForInstance(env, obj, "nativeContainer",
|
||||
(jint) container.get());
|
||||
((nsISupports *)container.get())->AddRef();
|
||||
|
||||
// NORMAL EXIT 2
|
||||
result = (jint)enumerator.get();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,12 @@
|
||||
#include "rdf_util.h"
|
||||
#include "rdf_progids.h"
|
||||
#include "ns_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
|
||||
#include "nsRDFCID.h" // for NS_RDFCONTAINER_CID
|
||||
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
|
||||
//
|
||||
// Local function prototypes
|
||||
@@ -43,48 +41,56 @@ static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
//
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsLeaf
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsresult rv;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jint childCount = -1;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRInt32 count;
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildCount");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildAt");
|
||||
return result;
|
||||
}
|
||||
wsRDFGetChildCountEvent *actionEvent =
|
||||
new wsRDFGetChildCountEvent(initContext,
|
||||
(PRUint32) nativeRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeIsLeaf: nativeRDFNode is not an RDFResource.");
|
||||
return result;
|
||||
}
|
||||
rv = rdf_getChildCount(nodeResource, &count);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeIsLeaf: can't get child count from nativeRDFNode.");
|
||||
return result;
|
||||
}
|
||||
result = (0 == count) ? JNI_TRUE : JNI_FALSE;
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
childCount = (jint) voidResult;
|
||||
result = (childCount == 0) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsContainer
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsresult rv;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRBool prBool;
|
||||
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeIsContainer: nativeRDFNode is not an RDFResource.");
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeIsContainer");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't see if isContainer");
|
||||
return result;
|
||||
}
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, nodeResource,
|
||||
&prBool);
|
||||
result = (prBool == PR_FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
wsRDFIsContainerEvent *actionEvent = new wsRDFIsContainerEvent(initContext,
|
||||
(PRUint32) nativeRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (0 != voidResult) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -93,198 +99,146 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNod
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode, jint childIndex)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode,
|
||||
jint childIndex)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jint result = -1;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> child;
|
||||
|
||||
rv = rdf_getChildAt(childIndex, parent, getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildAt: Can't get child.");
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildAt");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildAt");
|
||||
return result;
|
||||
}
|
||||
result = (jint)child.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
wsRDFGetChildAtEvent *actionEvent =
|
||||
new wsRDFGetChildAtEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(PRUint32) childIndex);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jint result = -1;
|
||||
PRInt32 count;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
|
||||
rv = rdf_getChildCount(parent, &count);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildCount: Can't get child count.");
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildCount");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildAt");
|
||||
return result;
|
||||
}
|
||||
result = (jint)count;
|
||||
wsRDFGetChildCountEvent *actionEvent =
|
||||
new wsRDFGetChildCountEvent(initContext,
|
||||
(PRUint32) nativeRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode, jint childRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode,
|
||||
jint childRDFNode)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jint result = -1;
|
||||
PRInt32 index;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> child = (nsIRDFResource *) childRDFNode;
|
||||
|
||||
rv = rdf_getIndexOfChild(parent, child, &index);
|
||||
result = (jint) index;
|
||||
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeGetChildIndex");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't getChildIndex");
|
||||
return result;
|
||||
}
|
||||
wsRDFGetChildIndexEvent *actionEvent =
|
||||
new wsRDFGetChildIndexEvent(initContext,
|
||||
(PRUint32) nativeRDFNode,
|
||||
(PRUint32) childRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jint) voidResult;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> currentResource =
|
||||
(nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
jstring result = nsnull;
|
||||
PRBool isContainer = PR_FALSE;
|
||||
nsresult rv;
|
||||
const PRUnichar *textForNode = nsnull;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, currentResource,
|
||||
&isContainer);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeToString: Can't tell if RDFResource is container.");
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeToString");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't toString");
|
||||
return result;
|
||||
}
|
||||
wsRDFToStringEvent *actionEvent =
|
||||
new wsRDFToStringEvent(initContext,
|
||||
(PRUint32) nativeRDFNode);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
if (isContainer) {
|
||||
// It's a bookmarks folder
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_Name, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
// get the name of the folder
|
||||
if (rv == 0) {
|
||||
// if so, make sure it's an nsIRDFLiteral
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
getter_AddRefs(literal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = literal->GetValueConst(&textForNode);
|
||||
}
|
||||
else {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node is not an nsIRDFLiteral.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It's a bookmark or a Separator
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_URL, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
// See if it has a Name
|
||||
if (0 != rv) {
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_Name, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
}
|
||||
|
||||
if (0 == rv) {
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
getter_AddRefs(literal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// get the value of the literal
|
||||
rv = literal->GetValueConst(&textForNode);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node doesn't have a value.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdf_printArcLabels(currentResource);
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node is not an nsIRDFLiteral.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdf_printArcLabels(currentResource);
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node doesn't have a URL.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
result = (jstring) voidResult;
|
||||
|
||||
if (nsnull != textForNode) {
|
||||
nsString * string = new nsString(textForNode);
|
||||
int length = 0;
|
||||
if (nsnull != string) {
|
||||
length = string->Length();
|
||||
}
|
||||
|
||||
result = ::util_NewString(env, (const jchar *) textForNode, length);
|
||||
}
|
||||
else {
|
||||
result = ::util_NewStringUTF(env, "");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
|
||||
(JNIEnv *env, jobject obj, jint parentRDFNode,
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint parentRDFNode,
|
||||
jint childRDFNode, jint childIndex)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) parentRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> newChild = (nsIRDFResource *) childRDFNode;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsresult rv;
|
||||
PRBool isContainer;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
|
||||
&isContainer);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: RDFResource is not a container.");
|
||||
return;
|
||||
}
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
// get a container in order to create a child
|
||||
rv = gComponentManager->CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create container.");
|
||||
return;
|
||||
}
|
||||
rv = container->Init(gBookmarksDataSource, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create container.");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = container->InsertElementAt(newChild, childIndex, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't insert element into parent container.");
|
||||
return;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeInsertElementAt");
|
||||
}
|
||||
|
||||
if (!initContext->initComplete) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't InsertElementAt");
|
||||
}
|
||||
wsRDFInsertElementAtEvent *actionEvent =
|
||||
new wsRDFInsertElementAtEvent(initContext,
|
||||
(PRUint32) parentRDFNode,
|
||||
(PRUint32) childRDFNode,
|
||||
(PRUint32) childIndex);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
if (NS_FAILED((nsresult) voidResult)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't InsertElementAt");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ void (* nativeInitialize) (JNIEnv *, jobject, jint);
|
||||
void (* nativeProcessEvents) (JNIEnv *, jobject, jint);
|
||||
// from BookmarksImpl.h
|
||||
jint (* nativeGetBookmarks) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeNewRDFNode) (JNIEnv *, jobject, jstring, jboolean);
|
||||
jint (* nativeNewRDFNode) (JNIEnv *, jobject, jint, jstring, jboolean);
|
||||
// from CurrentPageImpl.h
|
||||
void (* nativeCopyCurrentSelectionToSystemClipboard) (JNIEnv *, jobject, jint);
|
||||
void (* nativeFindInPage) (JNIEnv *, jobject, jint, jstring, jboolean, jboolean);
|
||||
@@ -143,17 +143,17 @@ void (* nativeLoadURL) (JNIEnv *, jobject, jint, jstring);
|
||||
void (* nativeRefresh) (JNIEnv *, jobject, jint, jlong);
|
||||
void (* nativeStop) (JNIEnv *, jobject, jint);
|
||||
// from RDFEnumeration.h
|
||||
void (* nativeFinalize) (JNIEnv *, jobject);
|
||||
jboolean (* nativeHasMoreElements) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeNextElement) (JNIEnv *, jobject, jint);
|
||||
void (* nativeFinalize) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeHasMoreElements) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeNextElement) (JNIEnv *, jobject, jint, jint);
|
||||
// from RDFTreeNode.h
|
||||
jint (* nativeGetChildAt) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeGetChildCount) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeGetIndex) (JNIEnv *, jobject, jint, jint);
|
||||
void (* nativeInsertElementAt) (JNIEnv *, jobject, jint, jint, jint);
|
||||
jboolean (* nativeIsContainer) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeIsLeaf) (JNIEnv *, jobject, jint);
|
||||
jstring (* nativeToString) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeGetChildAt) (JNIEnv *, jobject, jint, jint, jint);
|
||||
jint (* nativeGetChildCount) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeGetIndex) (JNIEnv *, jobject, jint, jint, jint);
|
||||
void (* nativeInsertElementAt) (JNIEnv *, jobject, jint, jint, jint, jint);
|
||||
jboolean (* nativeIsContainer) (JNIEnv *, jobject, jint, jint);
|
||||
jboolean (* nativeIsLeaf) (JNIEnv *, jobject, jint, jint);
|
||||
jstring (* nativeToString) (JNIEnv *, jobject, jint, jint);
|
||||
// from WindowControlImpl.h
|
||||
jint (* nativeCreateInitContext) (JNIEnv *, jobject, jint, jint, jint, jint, jint, jobject);
|
||||
void (* nativeMoveWindowTo) (JNIEnv *, jobject, jint, jint, jint);
|
||||
@@ -216,44 +216,44 @@ void locateBrowserControlStubFunctions(void * dll) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
nativeGetChildAt = (jint (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt");
|
||||
nativeGetChildAt = (jint (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt");
|
||||
if (!nativeGetChildAt) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeGetChildCount = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount");
|
||||
nativeGetChildCount = (jint (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount");
|
||||
if (!nativeGetChildCount) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeGetIndex = (jint (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex");
|
||||
nativeGetIndex = (jint (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex");
|
||||
if (!nativeGetIndex) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeInsertElementAt = (void (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt");
|
||||
nativeInsertElementAt = (void (*) (JNIEnv *, jobject, jint, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt");
|
||||
if (!nativeInsertElementAt) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeIsContainer = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsContainer");
|
||||
nativeIsContainer = (jboolean (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsContainer");
|
||||
if (!nativeIsContainer) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeIsLeaf = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsLeaf");
|
||||
nativeIsLeaf = (jboolean (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsLeaf");
|
||||
if (!nativeIsLeaf) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeToString = (jstring (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString");
|
||||
nativeToString = (jstring (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString");
|
||||
if (!nativeToString) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
nativeFinalize = (void (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize");
|
||||
nativeFinalize = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize");
|
||||
if (!nativeFinalize) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeHasMoreElements = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeHasMoreElements");
|
||||
nativeHasMoreElements = (jboolean (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeHasMoreElements");
|
||||
if (!nativeHasMoreElements) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeNextElement = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement");
|
||||
nativeNextElement = (jint (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement");
|
||||
if (!nativeNextElement) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
@@ -375,7 +375,7 @@ void locateBrowserControlStubFunctions(void * dll) {
|
||||
if (!nativeGetBookmarks) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeNewRDFNode = (jint (*) (JNIEnv *, jobject, jstring, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode");
|
||||
nativeNewRDFNode = (jint (*) (JNIEnv *, jobject, jint, jstring, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode");
|
||||
if (!nativeNewRDFNode) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
@@ -484,8 +484,8 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode
|
||||
(JNIEnv * env, jobject obj, jstring url, jboolean isFolder) {
|
||||
return (* nativeNewRDFNode) (env, obj, url, isFolder);
|
||||
(JNIEnv * env, jobject obj, jint webShellPtr, jstring url, jboolean isFolder) {
|
||||
return (* nativeNewRDFNode) (env, obj, webShellPtr, url, isFolder);
|
||||
}
|
||||
|
||||
|
||||
@@ -783,8 +783,8 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
(JNIEnv *env, jobject obj) {
|
||||
(* nativeFinalize) (env, obj);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr) {
|
||||
(* nativeFinalize) (env, obj, webShellPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -794,8 +794,8 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeHasMoreElements
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode) {
|
||||
return (* nativeHasMoreElements) (env, obj, nativeRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode) {
|
||||
return (* nativeHasMoreElements) (env, obj, webShellPtr, nativeRDFNode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -805,8 +805,8 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeHasMoreElements
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode) {
|
||||
return (* nativeNextElement) (env, obj, nativeRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode) {
|
||||
return (* nativeNextElement) (env, obj, webShellPtr, nativeRDFNode);
|
||||
}
|
||||
|
||||
|
||||
@@ -819,8 +819,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode, jint childIndex) {
|
||||
return (* nativeGetChildAt) (env, obj, nativeRDFNode, childIndex);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode,
|
||||
jint childIndex) {
|
||||
return (* nativeGetChildAt) (env, obj, webShellPtr, nativeRDFNode,
|
||||
childIndex);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -830,8 +832,8 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode) {
|
||||
return (* nativeGetChildCount) (env, obj, nativeRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode) {
|
||||
return (* nativeGetChildCount) (env, obj, webShellPtr, nativeRDFNode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -841,8 +843,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode, jint childRDFNode) {
|
||||
return (* nativeGetIndex) (env, obj, nativeRDFNode, childRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode,
|
||||
jint childRDFNode) {
|
||||
return (* nativeGetIndex) (env, obj, webShellPtr, nativeRDFNode,
|
||||
childRDFNode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -852,8 +856,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
|
||||
(JNIEnv *env, jobject obj, jint parentRDFNode, jint childRDFNode, jint childIndex) {
|
||||
(* nativeInsertElementAt) (env, obj, parentRDFNode, childRDFNode, childIndex);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint parentRDFNode,
|
||||
jint childRDFNode, jint childIndex) {
|
||||
(* nativeInsertElementAt) (env, obj, webShellPtr, parentRDFNode,
|
||||
childRDFNode, childIndex);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -862,8 +868,8 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsContainer
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode) {
|
||||
return (* nativeIsContainer) (env, obj, nativeRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode) {
|
||||
return (* nativeIsContainer) (env, obj, webShellPtr, nativeRDFNode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -872,8 +878,8 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNod
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsLeaf
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode) {
|
||||
return (* nativeIsLeaf) (env, obj, nativeRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode) {
|
||||
return (* nativeIsLeaf) (env, obj, webShellPtr, nativeRDFNode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -883,8 +889,8 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNod
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode) {
|
||||
return (* nativeToString) (env, obj, nativeRDFNode);
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint nativeRDFNode) {
|
||||
return (* nativeToString) (env, obj, webShellPtr, nativeRDFNode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,9 +44,26 @@
|
||||
#include "nsIContentViewerEdit.h"
|
||||
|
||||
#include "ns_util.h"
|
||||
#include "rdf_util.h"
|
||||
|
||||
#include "nsEmbedAPI.h" // for NS_TermEmbedding
|
||||
|
||||
#include "nsRDFCID.h" // for NS_RDFCONTAINER_CID
|
||||
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
|
||||
//
|
||||
// Local function prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* pull the int for the field nativeEnum from the java object obj.
|
||||
|
||||
*/
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode);
|
||||
|
||||
void * handleEvent (PLEvent * event);
|
||||
void destroyEvent (PLEvent * event);
|
||||
|
||||
@@ -753,7 +770,125 @@ wsDeallocateInitContextEvent::handleEvent ()
|
||||
return (void *) NS_OK;
|
||||
} // handleEvent()
|
||||
|
||||
wsInitBookmarksEvent::wsInitBookmarksEvent(WebShellInitContext* yourInitContext) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsInitBookmarksEvent::handleEvent ()
|
||||
{
|
||||
void *result = nsnull;
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsresult rv;
|
||||
rv = rdf_InitRDFUtils();
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't initialize RDF Utils");
|
||||
return (void *) result;
|
||||
}
|
||||
result = (void *) kNC_BookmarksRoot.get();
|
||||
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
wsNewRDFNodeEvent::wsNewRDFNodeEvent(WebShellInitContext* yourInitContext,
|
||||
const char * yourUrlString,
|
||||
PRBool yourIsFolder) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mUrlString(yourUrlString),
|
||||
mIsFolder(yourIsFolder)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsNewRDFNodeEvent::handleEvent ()
|
||||
{
|
||||
void *result = nsnull;
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> newNode;
|
||||
nsCAutoString uri("NC:BookmarksRoot");
|
||||
JNIEnv *env = (JNIEnv*) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
const char *url = mUrlString;
|
||||
uri.Append("#$");
|
||||
uri.Append(url);
|
||||
PRUnichar *uriUni = uri.ToNewUnicode();
|
||||
|
||||
rv = gRDF->GetUnicodeResource(uriUni, getter_AddRefs(newNode));
|
||||
nsCRT::free(uriUni);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create new nsIRDFResource.");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (mIsFolder) {
|
||||
rv = gRDFCU->MakeSeq(gBookmarksDataSource, newNode, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: unable to make new folder as a sequence.");
|
||||
return result;
|
||||
}
|
||||
rv = gBookmarksDataSource->Assert(newNode, kRDF_type,
|
||||
kNC_Folder, PR_TRUE);
|
||||
if (rv != NS_OK) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: unable to mark new folder as folder.");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
* Do the AddRef here.
|
||||
|
||||
*/
|
||||
|
||||
result = (void *)newNode.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
wsRDFIsContainerEvent::wsRDFIsContainerEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFIsContainerEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) mNativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRBool prBool;
|
||||
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeIsContainer: nativeRDFNode is not an RDFResource.");
|
||||
return nsnull;
|
||||
}
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, nodeResource,
|
||||
&prBool);
|
||||
result = (prBool == PR_FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
|
||||
return (void *) result;
|
||||
} // handleEvent()
|
||||
|
||||
void *
|
||||
wsFindEvent::handleEvent ()
|
||||
@@ -775,6 +910,94 @@ wsFindEvent::wsFindEvent(nsIFindComponent * findcomponent, nsISearchContext * sr
|
||||
{
|
||||
}
|
||||
|
||||
wsRDFGetChildAtEvent::wsRDFGetChildAtEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode,
|
||||
PRUint32 yourChildIndex) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
|
||||
mChildIndex(yourChildIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFGetChildAtEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
jint result = -1;
|
||||
nsresult rv;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mNativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> child;
|
||||
|
||||
rv = rdf_getChildAt(mChildIndex, parent, getter_AddRefs(child));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildAt: Can't get child.");
|
||||
return nsnull;
|
||||
}
|
||||
result = (jint)child.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
return (void *) result;
|
||||
} // handleEvent()
|
||||
|
||||
wsRDFGetChildCountEvent::wsRDFGetChildCountEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFGetChildCountEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
jint result = -1;
|
||||
PRInt32 count;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mNativeRDFNode;
|
||||
|
||||
rv = rdf_getChildCount(parent, &count);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildCount: Can't get child count.");
|
||||
return nsnull;
|
||||
}
|
||||
result = (jint)count;
|
||||
return (void *) result;
|
||||
} // handleEvent()
|
||||
|
||||
wsRDFGetChildIndexEvent::wsRDFGetChildIndexEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode,
|
||||
PRUint32 yourChildRDFNode) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
|
||||
mChildRDFNode(yourChildRDFNode)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFGetChildIndexEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
jint result = -1;
|
||||
PRInt32 index;
|
||||
nsresult rv;
|
||||
// PENDING(edburns): assert rdf_InitRDFUtils()
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mNativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> child = (nsIRDFResource *) mChildRDFNode;
|
||||
|
||||
rv = rdf_getIndexOfChild(parent, child, &index);
|
||||
result = (jint) index;
|
||||
|
||||
return (void *) result;
|
||||
} // handleEvent()
|
||||
|
||||
void *
|
||||
wsSelectAllEvent::handleEvent ()
|
||||
@@ -794,6 +1017,274 @@ wsSelectAllEvent::wsSelectAllEvent(nsIContentViewerEdit * contentViewerEdit) :
|
||||
{
|
||||
}
|
||||
|
||||
wsRDFToStringEvent::wsRDFToStringEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFToStringEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsCOMPtr<nsIRDFResource> currentResource =
|
||||
(nsIRDFResource *) mNativeRDFNode;
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
jstring result = nsnull;
|
||||
PRBool isContainer = PR_FALSE;
|
||||
nsresult rv;
|
||||
const PRUnichar *textForNode = nsnull;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, currentResource,
|
||||
&isContainer);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeToString: Can't tell if RDFResource is container.");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (isContainer) {
|
||||
// It's a bookmarks folder
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_Name, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
// get the name of the folder
|
||||
if (rv == 0) {
|
||||
// if so, make sure it's an nsIRDFLiteral
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
getter_AddRefs(literal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = literal->GetValueConst(&textForNode);
|
||||
}
|
||||
else {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node is not an nsIRDFLiteral.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It's a bookmark or a Separator
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_URL, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
// See if it has a Name
|
||||
if (0 != rv) {
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_Name, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
}
|
||||
|
||||
if (0 == rv) {
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
getter_AddRefs(literal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// get the value of the literal
|
||||
rv = literal->GetValueConst(&textForNode);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node doesn't have a value.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node is not an nsIRDFLiteral.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeToString: node doesn't have a URL.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != textForNode) {
|
||||
nsString * string = new nsString(textForNode);
|
||||
int length = 0;
|
||||
if (nsnull != string) {
|
||||
length = string->Length();
|
||||
}
|
||||
|
||||
result = ::util_NewString(env, (const jchar *) textForNode, length);
|
||||
}
|
||||
else {
|
||||
result = ::util_NewStringUTF(env, "");
|
||||
}
|
||||
|
||||
return (void *) result;
|
||||
} // handleEvent()
|
||||
|
||||
wsRDFInsertElementAtEvent::wsRDFInsertElementAtEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourParentRDFNode,
|
||||
PRUint32 yourChildRDFNode,
|
||||
PRUint32 yourChildIndex) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mParentRDFNode(yourParentRDFNode),
|
||||
mChildRDFNode(yourChildRDFNode), mChildIndex(yourChildIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFInsertElementAtEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mParentRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> newChild = (nsIRDFResource *) mChildRDFNode;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsresult rv;
|
||||
PRBool isContainer;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
|
||||
&isContainer);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: RDFResource is not a container.");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
// get a container in order to create a child
|
||||
rv = gComponentManager->CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create container.");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
rv = container->Init(gBookmarksDataSource, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create container.");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
rv = container->InsertElementAt(newChild, mChildIndex, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't insert element into parent container.");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return (void *) NS_OK;
|
||||
} // handleEvent()
|
||||
|
||||
wsRDFHasMoreElementsEvent::wsRDFHasMoreElementsEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode,
|
||||
void *yourJobject) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
|
||||
mJobject(yourJobject)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFHasMoreElementsEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRBool prResult = PR_FALSE;
|
||||
// assert -1 != nativeRDFNode
|
||||
jint nativeEnum;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
if (-1 == (nativeEnum = getNativeEnumFromJava(env, (jobject) mJobject,
|
||||
mNativeRDFNode))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't get nativeEnum from nativeRDFNode.");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
|
||||
rv = enumerator->HasMoreElements(&prResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't ask nsISimpleEnumerator->HasMoreElements().");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
result = (PR_FALSE == prResult) ? JNI_FALSE : JNI_TRUE;
|
||||
|
||||
return (void *) result;
|
||||
|
||||
} // handleEvent()
|
||||
|
||||
wsRDFNextElementEvent::wsRDFNextElementEvent(WebShellInitContext* yourInitContext,
|
||||
PRUint32 yourNativeRDFNode,
|
||||
void *yourJobject) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
|
||||
mJobject(yourJobject)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsRDFNextElementEvent::handleEvent ()
|
||||
{
|
||||
if (!mInitContext) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
PRBool hasMoreElements = PR_FALSE;
|
||||
// assert -1 != nativeRDFNode
|
||||
jint nativeEnum;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsCOMPtr<nsIRDFNode> nodeResult;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
if (-1 == (nativeEnum = getNativeEnumFromJava(env, (jobject) mJobject,
|
||||
mNativeRDFNode))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't get nativeEnum from nativeRDFNode.");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
|
||||
rv = enumerator->HasMoreElements(&hasMoreElements);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't ask nsISimpleEnumerator->HasMoreElements().");
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!hasMoreElements) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
rv = enumerator->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("Exception: nativeNextElement: Can't get next from enumerator.\n"));
|
||||
}
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// make sure it's an RDFNode
|
||||
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFNode),
|
||||
getter_AddRefs(nodeResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("Exception: nativeNextElement: next from enumerator is not an nsIRDFNode.\n"));
|
||||
}
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
result = (jint)nodeResult.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
return (void *) result;
|
||||
} // handleEvent()
|
||||
|
||||
void *
|
||||
wsCopySelectionEvent::handleEvent ()
|
||||
@@ -813,6 +1304,132 @@ wsCopySelectionEvent::wsCopySelectionEvent(nsIContentViewerEdit * contentViewerE
|
||||
{
|
||||
}
|
||||
|
||||
wsRDFFinalizeEvent::wsRDFFinalizeEvent(void *yourJobject) :
|
||||
nsActionEvent(),
|
||||
mJobject(yourJobject)
|
||||
{
|
||||
}
|
||||
|
||||
// EOF
|
||||
void *
|
||||
wsRDFFinalizeEvent::handleEvent ()
|
||||
{
|
||||
if (!mJobject) {
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
jint nativeEnum, nativeContainer;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
// release the nsISimpleEnumerator
|
||||
if (-1 == (nativeEnum =
|
||||
::util_GetIntValueFromInstance(env, (jobject) mJobject,
|
||||
"nativeEnum"))) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeFinalize: Can't get fieldID for nativeEnum.\n"));
|
||||
}
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator =
|
||||
(nsISimpleEnumerator *) nativeEnum;
|
||||
((nsISupports *)enumerator.get())->Release();
|
||||
|
||||
// release the nsIRDFContainer
|
||||
if (-1 == (nativeContainer =
|
||||
::util_GetIntValueFromInstance(env, (jobject) mJobject,
|
||||
"nativeContainer"))) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("nativeFinalize: Can't get fieldID for nativeContainerFieldID.\n"));
|
||||
}
|
||||
return (void *) NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
nsCOMPtr<nsIRDFContainer> container =
|
||||
(nsIRDFContainer *) nativeContainer;
|
||||
((nsISupports *)container.get())->Release();
|
||||
|
||||
return (void *) NS_OK;
|
||||
} // handleEvent()
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
|
||||
result = ::util_GetIntValueFromInstance(env, obj, "nativeEnum");
|
||||
|
||||
// if the field has been initialized, just return the value
|
||||
if (-1 != result) {
|
||||
// NORMAL EXIT 1
|
||||
return result;
|
||||
}
|
||||
|
||||
// else, we need to create the enum
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(nodeResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
// get a container in order to get the enum
|
||||
rv = gComponentManager->CreateInstance(kRDFContainerCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("recursiveResourceTraversal: can't get a new container\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, nodeResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Can't Init container.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("getNativeEnumFromJava: Can't get enumeration from container.\n"));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// IMPORTANT: Store the enum back into java
|
||||
::util_SetIntValueForInstance(env,obj,"nativeEnum",(jint)enumerator.get());
|
||||
// IMPORTANT: make sure it doesn't get deleted when it goes out of scope
|
||||
((nsISupports *)enumerator.get())->AddRef();
|
||||
|
||||
// PENDING(edburns): I'm not sure if we need to keep the
|
||||
// nsIRDFContainer from being destructed in order to maintain the
|
||||
// validity of the nsISimpleEnumerator that came from the container.
|
||||
// Just to be safe, I'm doing so.
|
||||
::util_SetIntValueForInstance(env, obj, "nativeContainer",
|
||||
(jint) container.get());
|
||||
((nsISupports *)container.get())->AddRef();
|
||||
|
||||
// NORMAL EXIT 2
|
||||
result = (jint)enumerator.get();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -359,6 +359,15 @@ protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
};
|
||||
|
||||
class wsInitBookmarksEvent : public nsActionEvent {
|
||||
public:
|
||||
wsInitBookmarksEvent(WebShellInitContext *yourInitContext);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
};
|
||||
|
||||
class wsFindEvent : public nsActionEvent {
|
||||
public:
|
||||
wsFindEvent(nsIFindComponent *findComponent,
|
||||
@@ -370,6 +379,28 @@ protected:
|
||||
nsISearchContext * mSearchContext;
|
||||
};
|
||||
|
||||
class wsNewRDFNodeEvent : public nsActionEvent {
|
||||
public:
|
||||
wsNewRDFNodeEvent(WebShellInitContext *yourInitContext,
|
||||
const char *yourUrlString, PRBool yourIsFolder);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
const char *mUrlString;
|
||||
PRBool mIsFolder;
|
||||
};
|
||||
|
||||
class wsRDFIsContainerEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFIsContainerEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 yourNativeRDFNode);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
};
|
||||
|
||||
class wsSelectAllEvent : public nsActionEvent {
|
||||
public:
|
||||
@@ -380,6 +411,28 @@ protected:
|
||||
nsIContentViewerEdit * mContentViewerEdit;
|
||||
};
|
||||
|
||||
class wsRDFGetChildAtEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFGetChildAtEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 yourNativeRDFNode, PRUint32 childIndex);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
PRUint32 mChildIndex;
|
||||
};
|
||||
|
||||
class wsRDFGetChildCountEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFGetChildCountEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 yourNativeRDFNode);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
};
|
||||
|
||||
class wsCopySelectionEvent : public nsActionEvent {
|
||||
public:
|
||||
@@ -390,6 +443,80 @@ protected:
|
||||
nsIContentViewerEdit * mContentViewerEdit;
|
||||
};
|
||||
|
||||
class wsRDFGetChildIndexEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFGetChildIndexEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 yourNativeRDFNode,
|
||||
PRUint32 yourChildRDFNode);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
PRUint32 mChildRDFNode;
|
||||
};
|
||||
|
||||
class wsRDFToStringEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFToStringEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 yourNativeRDFNode);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
};
|
||||
|
||||
class wsRDFInsertElementAtEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFInsertElementAtEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 yourParentRDFNode,
|
||||
PRUint32 yourChildRDFNode,
|
||||
PRUint32 yourChildIndex);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mParentRDFNode;
|
||||
PRUint32 mChildRDFNode;
|
||||
PRUint32 mChildIndex;
|
||||
};
|
||||
|
||||
class wsRDFHasMoreElementsEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFHasMoreElementsEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 mNativeRDFNode,
|
||||
void *yourJobject);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
void *mJobject;
|
||||
};
|
||||
|
||||
class wsRDFNextElementEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFNextElementEvent(WebShellInitContext *yourInitContext,
|
||||
PRUint32 mNativeRDFNode,
|
||||
void *yourJobject);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
PRUint32 mNativeRDFNode;
|
||||
void *mJobject;
|
||||
};
|
||||
|
||||
class wsRDFFinalizeEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRDFFinalizeEvent(void *yourJobject);
|
||||
void * handleEvent(void);
|
||||
|
||||
protected:
|
||||
void *mJobject;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsActions_h___ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user