зеркало из https://github.com/mozilla/gecko-dev.git
a=edburns
r=ashuk bug=2069 Native code for spec compliant webclient impl.
This commit is contained in:
Родитель
d60593aad0
Коммит
bb161e49d0
|
@ -0,0 +1,101 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "BookmarksImpl.h"
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "jni_util.h"
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeAddBookmark
|
||||
(JNIEnv *, jobject, jint, jobject)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't initialize RDF Utils");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (jint) kNC_BookmarksRoot.get();
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode
|
||||
(JNIEnv *env, jobject obj, jstring urlString, jboolean isFolder)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> newNode;
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
nsAutoString uri("NC:BookmarksRoot");
|
||||
|
||||
const char *url = env->GetStringUTFChars(urlString, NULL);
|
||||
uri.Append("#$");
|
||||
uri.Append(url);
|
||||
printf("debug: edburns: nativeNewRDFNode: url: %s\n", url);
|
||||
|
||||
rv = gRDF->GetUnicodeResource(uri.GetUnicode(), getter_AddRefs(newNode));
|
||||
env->ReleaseStringUTFChars(urlString, url);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create new nsIRDFResource.");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
* Do the AddRef here.
|
||||
|
||||
*/
|
||||
|
||||
result = (jint)newNode.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
/*
|
||||
* CurrentPageImpl.cpp
|
||||
*/
|
||||
|
||||
#include "CurrentPageImpl.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsresult rv;
|
||||
|
||||
rv = initContext->docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kHistoryWebShellError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't Copy to Clipboard");
|
||||
return;
|
||||
}
|
||||
|
||||
presShell->DoCopy();
|
||||
|
||||
/***
|
||||
|
||||
This looks like the right way to do it, but as of 01/13/00, it
|
||||
doesn't work. See a post on n.p.m.embedding:
|
||||
|
||||
Message-ID: <85ll4n$nli$1@nnrp1.deja.com>
|
||||
|
||||
|
||||
**/
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeFindInPage
|
||||
* Signature: (Ljava/lang/String;ZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindInPage
|
||||
(JNIEnv *, jobject, jstring, jboolean, jboolean)
|
||||
{
|
||||
|
||||
/****
|
||||
|
||||
As of 01/13/00, Find is blocked on this post to n.p.m.embedding:
|
||||
|
||||
Message-ID: <85ln9l$p97$1@nnrp1.deja.com>
|
||||
|
||||
|
||||
***/
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeFindNextInPage
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindNextInPage
|
||||
(JNIEnv *, jobject, jboolean)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetCurrentURL
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetCurrentURL
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
char * charResult = nsnull;
|
||||
jstring urlString = nsnull;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetURL");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
nsISessionHistory *yourHistory;
|
||||
nsresult rv;
|
||||
|
||||
rv = initContext->webShell->GetSessionHistory(yourHistory);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't get SessionHistory from webshell");
|
||||
return urlString;
|
||||
}
|
||||
|
||||
wsGetURLEvent * actionEvent = new wsGetURLEvent(yourHistory);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
charResult = (char *) ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
if (charResult != nsnull) {
|
||||
urlString = env->NewStringUTF((const char *) charResult);
|
||||
}
|
||||
else {
|
||||
::util_ThrowExceptionToJava(env, "raptorWebShellGetURL Exception: GetURL() returned NULL");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCRT::free(charResult);
|
||||
}
|
||||
|
||||
return urlString;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetSource
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSource
|
||||
(JNIEnv *, jobject)
|
||||
{
|
||||
jstring result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetSourceBytes
|
||||
* Signature: ()[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes
|
||||
(JNIEnv *, jobject)
|
||||
{
|
||||
jbyteArray result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeResetFind
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeResetFind
|
||||
(JNIEnv *, jobject)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeSelectAll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeSelectAll
|
||||
(JNIEnv *, jobject)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
#include<stdio.h>
|
||||
#include "jni_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
// PENDING(edburns): take this out
|
||||
#include "winbase.h"
|
||||
// end of take this out
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
||||
|
||||
jlong DocumentLoaderObserverImpl::maskValues[] = { -1L };
|
||||
|
||||
char *DocumentLoaderObserverImpl::maskNames[] = {
|
||||
"START_DOCUMENT_LOAD_EVENT_MASK",
|
||||
"END_DOCUMENT_LOAD_EVENT_MASK",
|
||||
"START_URL_LOAD_EVENT_MASK",
|
||||
"END_URL_LOAD_EVENT_MASK",
|
||||
"PROGRESS_URL_LOAD_EVENT_MASK",
|
||||
"STATUS_URL_LOAD_EVENT_MASK",
|
||||
"UNKNOWN_CONTENT_EVENT_MASK",
|
||||
"FETCH_INTERRUPT_EVENT_MASK",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/*************
|
||||
NS_IMETHODIMP_(nsrefcnt) DocumentLoaderObserverImpl::AddRef(void)
|
||||
{
|
||||
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
|
||||
++mRefCnt;
|
||||
return mRefCnt;
|
||||
}
|
||||
**************/
|
||||
|
||||
NS_IMPL_ADDREF(DocumentLoaderObserverImpl);
|
||||
NS_IMPL_RELEASE(DocumentLoaderObserverImpl);
|
||||
|
||||
DocumentLoaderObserverImpl::DocumentLoaderObserverImpl(){
|
||||
}
|
||||
|
||||
DocumentLoaderObserverImpl::DocumentLoaderObserverImpl(JNIEnv *env,
|
||||
WebShellInitContext *yourInitContext,
|
||||
jobject yourTarget) :
|
||||
mJNIEnv(env), mInitContext(yourInitContext), mTarget(yourTarget)
|
||||
{
|
||||
if (NULL == gVm) { // declared in jni_util.h
|
||||
env->GetJavaVM(&gVm); // save this vm reference away for the callback!
|
||||
}
|
||||
|
||||
#ifdef XP_PC
|
||||
// debug: edburns:
|
||||
DWORD nativeThreadID = GetCurrentThreadId();
|
||||
printf("debug: edburns: DocumentLoaderObserverImpl ctor nativeThreadID: %d\n",
|
||||
nativeThreadID);
|
||||
#endif
|
||||
|
||||
char *currentThreadName = NULL;
|
||||
|
||||
if (NULL != (currentThreadName = util_GetCurrentThreadName(env))) {
|
||||
printf("debug: edburns: DocumentLoaderObserverImpl ctor threadName: %s\n",
|
||||
currentThreadName);
|
||||
delete currentThreadName;
|
||||
}
|
||||
|
||||
if (-1 == maskValues[0]) {
|
||||
InitializeMaskValues();
|
||||
}
|
||||
mRefCnt = 1; // PENDING(edburns): not sure about how right this is to do.
|
||||
}
|
||||
|
||||
void DocumentLoaderObserverImpl::InitializeMaskValues()
|
||||
{
|
||||
// if we don't have a VM, do nothing
|
||||
if (NULL == gVm) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
|
||||
if (NULL == env) {
|
||||
return;
|
||||
}
|
||||
|
||||
jclass documentLoadEventClass = env->FindClass("org/mozilla/webclient/DocumentLoadEvent");
|
||||
|
||||
if (NULL == documentLoadEventClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
jfieldID fieldID;
|
||||
|
||||
while (NULL != maskNames[i]) {
|
||||
fieldID = env->GetStaticFieldID(documentLoadEventClass, maskNames[i],
|
||||
"J");
|
||||
|
||||
if (NULL == fieldID) {
|
||||
return;
|
||||
}
|
||||
|
||||
maskValues[i] = env->GetStaticLongField(documentLoadEventClass, fieldID);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::QueryInterface(REFNSIID aIID, void** aInstance)
|
||||
{
|
||||
if (NULL == aInstance)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstance = NULL;
|
||||
|
||||
|
||||
if (aIID.Equals(kIDocumentLoaderObserverIID)) {
|
||||
*aInstance = (void*) ((nsIDocumentLoaderObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
/* nsIDocumentLoaderObserver methods */
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIURI* aURL,
|
||||
const char* aCommand)
|
||||
{
|
||||
printf("DocumentLoaderObserverImpl.cpp: OnStartDocumentLoad\n");
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[START_DOCUMENT_LOAD_EVENT_MASK]);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
nsresult aStatus)
|
||||
{
|
||||
printf("!!DocumentLoaderObserverImpl.cpp: OnEndDocumentLoad\n");
|
||||
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[END_DOCUMENT_LOAD_EVENT_MASK]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel)
|
||||
{
|
||||
printf("!DocumentLoaderObserverImpl: OnStartURLLoad\n");
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[START_URL_LOAD_EVENT_MASK]);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnProgressURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
PRUint32 aProgress,
|
||||
PRUint32 aProgressMax)
|
||||
{
|
||||
printf("!DocumentLoaderObserverImpl: OnProgressURLLoad\n");
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[PROGRESS_URL_LOAD_EVENT_MASK]);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnStatusURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
nsString& aMsg)
|
||||
{
|
||||
printf("!DocumentLoaderObserverImpl: OnStatusURLLoad\n");
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[STATUS_URL_LOAD_EVENT_MASK]);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
nsresult aStatus)
|
||||
{
|
||||
printf("!DocumentLoaderObserverImpl: OnEndURLLoad\n");
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[END_URL_LOAD_EVENT_MASK]);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::HandleUnknownContentType(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
const char *aContentType,
|
||||
const char *aCommand)
|
||||
{
|
||||
printf("!DocumentLoaderObserverImpl: HandleUnknownContentType\n");
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[UNKNOWN_CONTENT_EVENT_MASK]);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#ifndef DocumentLoaderObserverImpl_h
|
||||
#define DocumentLoaderObserverImpl_h
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
/**
|
||||
|
||||
* This class is the shim between the mozilla listener event system for
|
||||
* document load events and the java DocumentLoadListener interface.
|
||||
* For each of the On* methods, we call the appropriate method in java.
|
||||
* See the implementation of OnEndDocumentLoad for an example.
|
||||
|
||||
*/
|
||||
|
||||
class DocumentLoaderObserverImpl : public nsIDocumentLoaderObserver {
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
START_DOCUMENT_LOAD_EVENT_MASK = 0,
|
||||
END_DOCUMENT_LOAD_EVENT_MASK,
|
||||
START_URL_LOAD_EVENT_MASK,
|
||||
END_URL_LOAD_EVENT_MASK,
|
||||
PROGRESS_URL_LOAD_EVENT_MASK,
|
||||
STATUS_URL_LOAD_EVENT_MASK,
|
||||
UNKNOWN_CONTENT_EVENT_MASK,
|
||||
FETCH_INTERRUPT_EVENT_MASK,
|
||||
NUMBER_OF_MASK_NAMES
|
||||
} EVENT_MASK_NAMES;
|
||||
|
||||
static jlong maskValues [DocumentLoaderObserverImpl::EVENT_MASK_NAMES::NUMBER_OF_MASK_NAMES];
|
||||
static char *maskNames [];
|
||||
|
||||
DocumentLoaderObserverImpl(JNIEnv *yourJNIEnv,
|
||||
WebShellInitContext *yourInitContext,
|
||||
jobject yourTarget);
|
||||
|
||||
DocumentLoaderObserverImpl();
|
||||
|
||||
/* nsIDocumentLoaderObserver methods */
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIURI* aURL,
|
||||
const char* aCommand);
|
||||
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
nsresult aStatus);
|
||||
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel);
|
||||
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
PRUint32 aProgress,
|
||||
PRUint32 aProgressMax);
|
||||
|
||||
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
nsString& aMsg);
|
||||
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
nsresult aStatus);
|
||||
|
||||
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
const char *aContentType,
|
||||
const char *aCommand);
|
||||
|
||||
protected:
|
||||
|
||||
static void InitializeMaskValues(void);
|
||||
|
||||
JNIEnv *mJNIEnv;
|
||||
WebShellInitContext *mInitContext;
|
||||
jobject mTarget;
|
||||
|
||||
};
|
||||
|
||||
#endif // DocumentLoaderObserverImpl_h
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "EventRegistration.h"
|
||||
|
||||
#include "nsActions.h"
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
|
||||
void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
jobject listener)
|
||||
{
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null initContext passed toaddDocumentLoadListener");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
// Assert (NULL != initContext->nativeEventThread)
|
||||
|
||||
// create the c++ "peer" for the DocumentLoadListener, which is an
|
||||
// nsIDocumentLoaderObserver.
|
||||
DocumentLoaderObserverImpl *observerImpl =
|
||||
new DocumentLoaderObserverImpl(env, initContext, listener);
|
||||
|
||||
wsAddDocLoaderObserverEvent *actionEvent =
|
||||
new wsAddDocLoaderObserverEvent(initContext->docShell,
|
||||
observerImpl);
|
||||
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#ifndef EventRegistration_h
|
||||
#define EventRegistration_h
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
/**
|
||||
|
||||
* This file contains methods to add and remove listeners.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* This function creates an instance of DocumentLoaderObserverImpl,
|
||||
* which is the shim between the mozilla nsIDocumentLoaderObserver class
|
||||
* and the Java DocumentLoadListener interface. See
|
||||
* DocumentLoaderObserverImpl.h
|
||||
|
||||
* PENDING(): implement removeDocumentLoadListener
|
||||
|
||||
* PENDING(): implement the ability to have multiple listener instances
|
||||
* per listener types, all of which get notified.
|
||||
|
||||
*/
|
||||
|
||||
void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
jobject listener);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,318 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "HistoryImpl.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
#include "nsActions.h"
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellBack");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsBackEvent * actionEvent =
|
||||
new wsBackEvent(initContext->sessionHistory, initContext->webShell);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
#ifdef XP_PC
|
||||
// debug: edburns:
|
||||
DWORD nativeThreadID = GetCurrentThreadId();
|
||||
printf("debug: edburns: HistoryImpl_nativeBack() nativeThreadID: %d\n",
|
||||
nativeThreadID);
|
||||
#endif
|
||||
|
||||
char *currentThreadName = NULL;
|
||||
|
||||
if (NULL != (currentThreadName = util_GetCurrentThreadName(env))) {
|
||||
printf("debug: edburns: HistoryImpl_nativeBack() java threadName: %s\n",
|
||||
currentThreadName);
|
||||
delete currentThreadName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
::util_PostSynchronousEvent(initContext, event);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean
|
||||
JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanBack
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jboolean result = JNI_FALSE;
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
void * voidResult;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellCanBack");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsCanBackEvent * actionEvent =
|
||||
new wsCanBackEvent(initContext->sessionHistory);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
result = (PR_FALSE == ((PRBool) voidResult)) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetBackList
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jobjectArray result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeClearHistory
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeForward
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellForward");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsForwardEvent * actionEvent =
|
||||
new wsForwardEvent(initContext->sessionHistory,
|
||||
initContext->webShell);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostSynchronousEvent(initContext, event);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanForward
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jboolean result = JNI_FALSE;
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
void * voidResult;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellCanForward");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsCanForwardEvent * actionEvent =
|
||||
new wsCanForwardEvent(initContext->sessionHistory);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
result = (PR_FALSE == ((PRBool) voidResult)) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetForwardList
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jobjectArray result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistory
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jobjectArray result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryEntry
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
jobject result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
void * voidResult = nsnull;
|
||||
jint result = -1;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryIndex");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsGetHistoryIndexEvent * actionEvent =
|
||||
new wsGetHistoryIndexEvent(initContext->sessionHistory);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
result = (jint) voidResult;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetCurrentHistoryIndex");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsGoToEvent * actionEvent =
|
||||
new wsGoToEvent(initContext->sessionHistory,
|
||||
initContext->webShell, historyIndex);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryLength
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
void * voidResult = nsnull;
|
||||
jint result = -1;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryLength");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsGetHistoryLengthEvent * actionEvent =
|
||||
new wsGetHistoryLengthEvent(initContext->sessionHistory);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
result = (jint) voidResult;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetURLForIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
char * charResult = nsnull;
|
||||
jstring urlString = nsnull;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetURL");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsGetURLForIndexEvent * actionEvent =
|
||||
new wsGetURLForIndexEvent(initContext->sessionHistory,
|
||||
historyIndex);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
charResult = (char *) ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
if (charResult != nsnull) {
|
||||
urlString = env->NewStringUTF((const char *) charResult);
|
||||
}
|
||||
else {
|
||||
::util_ThrowExceptionToJava(env, "raptorWebShellGetURL Exception: GetURL() returned NULL");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCRT::free(charResult);
|
||||
}
|
||||
|
||||
return urlString;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "ISupportsPeer.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_ISupportsPeer_nativeAddRef
|
||||
(JNIEnv *env, jobject obj, jint nativeISupportsImpl)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = (nsISupports *) nativeISupportsImpl;
|
||||
((nsISupports *)supports.get())->AddRef();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_ISupportsPeer_nativeRelease
|
||||
(JNIEnv *env, jobject obj, jint nativeISupportsImpl)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = (nsISupports *) nativeISupportsImpl;
|
||||
((nsISupports *)supports.get())->Release();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = webclient
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MODULE=webclient
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\jni_util.obj \
|
||||
.\$(OBJDIR)\rdf_util.obj \
|
||||
.\$(OBJDIR)\nsActions.obj \
|
||||
.\$(OBJDIR)\BookmarksImpl.obj \
|
||||
.\$(OBJDIR)\CurrentPageImpl.obj \
|
||||
.\$(OBJDIR)\DocumentLoaderObserverImpl.obj \
|
||||
.\$(OBJDIR)\EventRegistration.obj \
|
||||
.\$(OBJDIR)\HistoryImpl.obj \
|
||||
.\$(OBJDIR)\WrapperFactoryImpl.obj \
|
||||
.\$(OBJDIR)\WindowControlImpl.obj \
|
||||
.\$(OBJDIR)\NavigationImpl.obj \
|
||||
.\$(OBJDIR)\NativeEventThread.obj \
|
||||
.\$(OBJDIR)\RDFEnumeration.obj \
|
||||
.\$(OBJDIR)\RDFTreeNode.obj \
|
||||
.\$(OBJDIR)\ISupportsPeer.obj \
|
||||
.\$(OBJDIR)\nsSetupRegistry.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = \
|
||||
-I$(JDKHOME)\include \
|
||||
-I$(JDKHOME)\include\win32 \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
-DDEBUG_RAPTOR_CANVAS \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\gkweb.lib \
|
||||
$(DIST)\lib\raptorbasewidget_s.lib \
|
||||
$(DIST)\lib\gkwidget.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(DIST)\lib\nsreg.lib \
|
||||
$(DIST)\lib\nspr3.lib \
|
||||
$(DIST)\lib\plds3.lib \
|
||||
# $(DEPTH)\xpfe\bootstrap\$(OBJDIR)\nsSetupRegistry.obj \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS = \
|
||||
version.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
include <$(DEPTH)\java\config\localdefs.mak>
|
||||
|
||||
!CMDSWITCHES -S
|
||||
|
||||
# generate the jni header
|
||||
export:: BookmarksImpl.h CurrentPageImpl.h HistoryImpl.h WrapperFactoryImpl.h WindowControlImpl.h NavigationImpl.h NativeEventThread.h RDFEnumeration.h RDFTreeNode.h ISupportsPeer.h nsSetupRegistry.cpp
|
||||
|
||||
BookmarksImpl.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.BookmarksImpl is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.BookmarksImpl
|
||||
|
||||
CurrentPageImpl.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.CurrentPageImpl is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.CurrentPageImpl
|
||||
|
||||
HistoryImpl.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.HistoryImpl is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.HistoryImpl
|
||||
|
||||
WrapperFactoryImpl.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.WrapperFactoryImpl is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.WrapperFactoryImpl
|
||||
|
||||
NavigationImpl.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.NavigationImpl is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.NavigationImpl
|
||||
|
||||
RDFEnumeration.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.RDFEnumeration is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.RDFEnumeration
|
||||
|
||||
RDFTreeNode.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.RDFTreeNode is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.RDFTreeNode
|
||||
|
||||
ISupportsPeer.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.ISupportsPeer is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.ISupportsPeer
|
||||
|
||||
WindowControlImpl.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.WindowControlImpl is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.WindowControlImpl
|
||||
|
||||
NativeEventThread.h:
|
||||
@echo Assuming class org.mozilla.webclient.wrapper_native.NativeEventThread is in $(JAVAH_FLAGS)
|
||||
$(JAVAH) $(JAVAH_FLAGS) -o $@ org.mozilla.webclient.wrapper_native.NativeEventThread
|
||||
|
||||
nsSetupRegistry.cpp:
|
||||
copy $(MOZ_SRC)\mozilla\xpfe\bootstrap\nsSetupRegistry.cpp
|
||||
|
||||
buildRunems:
|
||||
@echo +++ Creating $(MOZ_SRC)\mozilla\java\webclient\src\$(OBJDIR)\runem.bat. Use this to run the test browser.
|
||||
@echo set PATH=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin;$(PATH) > .\$(OBJDIR)\runem.bat
|
||||
@echo $(JAVA) -Djava.library.path=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin -classpath $(JAVAC_CLASSPATH) org.mozilla.webclient.test.EmbeddedMozilla $(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin %1% >> .\$(OBJDIR)\runem.bat
|
||||
@echo +++ Creating $(MOZ_SRC)\mozilla\java\webclient\src\$(OBJDIR)\swingem.bat. Use this to run the swing based test browser.
|
||||
@echo set PATH=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin;$(PATH) > .\$(OBJDIR)\swingem.bat
|
||||
@echo $(JAVA) -Djava.library.path=$(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin -classpath $(JAVAC_CLASSPATH) org.mozilla.webclient.test.swing.SwingEmbeddedMozilla $(MOZ_SRC)\mozilla\dist\$(OBJDIR)\bin %1% >> .\$(OBJDIR)\swingem.bat
|
||||
|
||||
install:: $(DLL) buildRunems
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
|
||||
clobber_all:: clobber
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
rm -f BookmarksImpl.h
|
||||
rm -f CurrentPageImpl.h
|
||||
rm -f HistoryImpl.h
|
||||
rm -f WrapperFactoryImpl.h
|
||||
rm -f NavigationImpl.h
|
||||
rm -f WindowControlImpl.h
|
||||
rm -f NativeEventThread.h
|
||||
rm -f RDFEnumeration.h
|
||||
rm -f RDFTreeNode.h
|
||||
rm -f ISupportsPeer.h
|
||||
rm -f nsSetupRegistry.cpp
|
||||
rm -f .\$(OBJDIR)\runem.bat
|
||||
rm -f .\$(OBJDIR)\swingem.bat
|
|
@ -0,0 +1,450 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "NativeEventThread.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
#include "EventRegistration.h" // event callbacks
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "nsAppShellCIDs.h" // for NS_SESSIONHISTORY_CID
|
||||
#include "nsIBaseWindow.h" // to get methods like SetVisibility
|
||||
#include "nsCOMPtr.h" // to get nsIBaseWindow from webshell
|
||||
//nsIDocShell is included in jni_util.h
|
||||
#include "nsIEventQueueService.h" // for PLEventQueue
|
||||
#include "nsIPref.h" // for preferences
|
||||
#include "nsRepository.h"
|
||||
#include "nsIServiceManager.h" // for nsServiceManager::GetService
|
||||
#include "nsISessionHistory.h" // for history
|
||||
#include "nsIThread.h" // for PRThread
|
||||
//nsIWebShell is included in jni_util.h
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
static NS_DEFINE_IID(kISessionHistoryIID, NS_ISESSIONHISTORY_IID);
|
||||
static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID);
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Called from InitMozillaStuff().
|
||||
|
||||
*/
|
||||
|
||||
int processEventLoop(WebShellInitContext * initContext);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java nativeInitialize to create the webshell, history,
|
||||
* prefs, and other mozilla things, then start the event loop.
|
||||
|
||||
*/
|
||||
|
||||
nsresult InitMozillaStuff (WebShellInitContext * arg);
|
||||
|
||||
//
|
||||
// Local data
|
||||
//
|
||||
|
||||
static nsISessionHistory *gHistory = NULL;
|
||||
|
||||
char * errorMessages[] = {
|
||||
"No Error",
|
||||
"Could not obtain the event queue service.",
|
||||
"Unable to create the WebShell instance.",
|
||||
"Unable to initialize the WebShell instance.",
|
||||
"Unable to show the WebShell."
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
* a null terminated array of listener interfaces we support.
|
||||
|
||||
* PENDING(): this should probably live in EventRegistration.h
|
||||
|
||||
*/
|
||||
|
||||
const char *gSupportedListenerInterfaces[] = {
|
||||
"org/mozilla/webclient/DocumentLoadListener",
|
||||
NULL
|
||||
};
|
||||
|
||||
// these index into the gSupportedListenerInterfaces array, this should
|
||||
// also live in EventRegistration.h
|
||||
|
||||
typedef enum {
|
||||
DOCUMENT_LOAD_LISTENER = 0,
|
||||
LISTENER_NOT_FOUND
|
||||
} LISTENER_CLASSES;
|
||||
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeInitialize
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (NULL == initContext) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL webShellPtr passed to nativeInitialize.");
|
||||
return;
|
||||
}
|
||||
if (NULL == gVm) { // declared in jni_util.h
|
||||
env->GetJavaVM(&gVm); // save this vm reference
|
||||
}
|
||||
|
||||
rv = InitMozillaStuff(initContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
errorMessages[initContext->initFailCode]);
|
||||
return;
|
||||
}
|
||||
|
||||
while (initContext->initComplete == FALSE) {
|
||||
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
if (initContext->initFailCode != 0) {
|
||||
::util_ThrowExceptionToJava(initContext->env, errorMessages[initContext->initFailCode]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeProcessEvents
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (NULL == initContext) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL webShellPtr passed to nativeProcessEvents.");
|
||||
return;
|
||||
}
|
||||
processEventLoop(initContext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <P> This method takes the typedListener, which is a
|
||||
* WebclientEventListener java subclass, figures out what type of
|
||||
* subclass it is, using the gSupportedListenerInterfaces array, and
|
||||
* calls the appropriate add*Listener local function. </P>
|
||||
|
||||
*<P> PENDING(): we could do away with the switch statement using
|
||||
* function pointers, or some other mechanism. </P>
|
||||
|
||||
* <P>the NewGlobalRef call is very important, since the argument
|
||||
* typedListener is used to call back into java, at another time, as a
|
||||
* result of the a mozilla event being fired.</P>
|
||||
|
||||
* PENDING(): implement nativeRemoveListener, which must call
|
||||
* RemoveGlobalRef.
|
||||
|
||||
* See the comments for EventRegistration.h:addDocumentLoadListener
|
||||
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeAddListener
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null initContext passed tonativeAddListener");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NULL == initContext->nativeEventThread) {
|
||||
// store the java EventRegistrationImpl class in the initContext
|
||||
initContext->nativeEventThread = obj; // VERY IMPORTANT!!
|
||||
// This enables the listener to call back into java
|
||||
}
|
||||
|
||||
jclass clazz = NULL;
|
||||
int listenerType = 0;
|
||||
|
||||
while (NULL != gSupportedListenerInterfaces[listenerType]) {
|
||||
if (NULL ==
|
||||
(clazz =
|
||||
env->FindClass(gSupportedListenerInterfaces[listenerType]))) {
|
||||
return;
|
||||
}
|
||||
if (env->IsInstanceOf(typedListener, clazz)) {
|
||||
// We've got a winner!
|
||||
break;
|
||||
}
|
||||
listenerType++;
|
||||
}
|
||||
|
||||
if (LISTENER_NOT_FOUND == (LISTENER_CLASSES) listenerType) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't find listener \n\tclass for argument");
|
||||
return;
|
||||
}
|
||||
|
||||
jobject globalRef = NULL;
|
||||
|
||||
// PENDING(edburns): make sure do DeleteGlobalRef on the removeListener
|
||||
if (NULL == (globalRef = env->NewGlobalRef(typedListener))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't create NewGlobalRef\n\tfor argument");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(listenerType) {
|
||||
case DOCUMENT_LOAD_LISTENER:
|
||||
addDocumentLoadListener(env, initContext, globalRef);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This function processes methods inserted into WebShellInitContext's
|
||||
* actionQueue. It is called once during the initialization of the
|
||||
* NativeEventThread java thread, and infinitely in
|
||||
* NativeEventThread.run()'s event loop. The call to PL_HandleEvent
|
||||
* below, ends up calling the nsActionEvent subclass's handleEvent()
|
||||
* method. After which it calls nsActionEvent::destroyEvent().
|
||||
|
||||
*/
|
||||
|
||||
int processEventLoop(WebShellInitContext * initContext)
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
while(gtk_events_pending()) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
#else
|
||||
// PENDING(mark): Does this work on the Mac?
|
||||
MSG msg;
|
||||
|
||||
if (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||
if (::GetMessage(&msg, NULL, 0, 0)) {
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
if ((initContext->initComplete) && (initContext->actionQueue)) {
|
||||
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue);
|
||||
|
||||
if (::PL_EventAvailable(initContext->actionQueue)) {
|
||||
|
||||
PLEvent * event = ::PL_GetEvent(initContext->actionQueue);
|
||||
|
||||
if (event != NULL) {
|
||||
::PL_HandleEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue);
|
||||
|
||||
}
|
||||
if (initContext->stopThread) {
|
||||
initContext->stopThread++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
{
|
||||
nsIEventQueueService * aEventQService = nsnull;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
PRBool allowPlugins = PR_FALSE;
|
||||
|
||||
//TODO Add tracing from nspr.
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", initContext);
|
||||
#endif
|
||||
|
||||
// Create the Event Queue for the UI thread...
|
||||
rv = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||
kIEventQueueServiceIID,
|
||||
(nsISupports **) &aEventQService);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kEventQueueError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create the event queue.
|
||||
rv = aEventQService->CreateThreadEventQueue();
|
||||
|
||||
initContext->embeddedThread = PR_GetCurrentThread();
|
||||
|
||||
// Create the action queue
|
||||
if (initContext->embeddedThread) {
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): embeddedThread != NULL\n", initContext);
|
||||
#endif
|
||||
if (initContext->actionQueue == NULL) {
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
|
||||
#endif
|
||||
// We need to do something different for Unix
|
||||
nsIEventQueue * EQueue = nsnull;
|
||||
|
||||
rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread,
|
||||
&EQueue);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
gdk_input_add(EQueue->GetEventQueueSelectFD(),
|
||||
GDK_INPUT_READ,
|
||||
event_processor_callback,
|
||||
EQueue);
|
||||
#endif
|
||||
|
||||
PLEventQueue * plEventQueue = nsnull;
|
||||
|
||||
EQueue->GetPLEventQueue(&plEventQueue);
|
||||
initContext->actionQueue = plEventQueue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): Create the WebShell...\n", initContext);
|
||||
#endif
|
||||
// Create the WebShell.
|
||||
rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&initContext->webShell);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): Init the WebShell...\n", initContext);
|
||||
#endif
|
||||
|
||||
rv = initContext->webShell->Init((nsNativeWidget *)initContext->parentHWnd,
|
||||
initContext->x, initContext->y, initContext->w, initContext->h);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kInitWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): Install Prefs in the Webshell...\n", initContext);
|
||||
#endif
|
||||
|
||||
nsIPref *prefs;
|
||||
|
||||
rv = nsServiceManager::GetService(kPrefCID,
|
||||
nsIPref::GetIID(),
|
||||
(nsISupports **)&prefs);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Set the prefs in the outermost webshell.
|
||||
initContext->webShell->SetPrefs(prefs);
|
||||
nsServiceManager::ReleaseService(kPrefCID, prefs);
|
||||
}
|
||||
|
||||
if (NULL == gHistory) {
|
||||
rv = nsComponentManager::CreateInstance(kSessionHistoryCID, nsnull, kISessionHistoryIID,
|
||||
(void**)&gHistory);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kHistoryWebShellError;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
initContext->webShell->SetSessionHistory(gHistory);
|
||||
|
||||
// set the sessionHistory in the initContexn
|
||||
initContext->sessionHistory = gHistory;
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): Show the WebShell...\n", initContext);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kShowWebShellError;
|
||||
return rv;
|
||||
}
|
||||
rv = baseWindow->SetVisibility(PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kShowWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// set the docShell
|
||||
rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIDocShell),
|
||||
getter_AddRefs(initContext->docShell));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kHistoryWebShellError;
|
||||
::util_ThrowExceptionToJava(initContext->env,
|
||||
"Exception: Can't get DocShell from nsIWebShell");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
initContext->initComplete = TRUE;
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
printf("InitMozillaStuff(%lx): enter event loop\n", initContext);
|
||||
#endif
|
||||
|
||||
// Just need to loop once to clear out events before returning
|
||||
processEventLoop(initContext);
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "NavigationImpl.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
#include "nsActions.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeLoadURL
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString)
|
||||
{
|
||||
jobject jobj = obj;
|
||||
const char * urlChars = (char *) env->GetStringUTFChars(urlString, 0);
|
||||
|
||||
printf("Native URL = \"%s\"\n", urlChars);
|
||||
env->ReleaseStringUTFChars(urlString, urlChars);
|
||||
|
||||
PRUnichar * urlStringChars = (PRUnichar *) env->GetStringChars(urlString, 0);
|
||||
|
||||
if (env->ExceptionOccurred()) {
|
||||
::util_ThrowExceptionToJava(env, "raptorWebShellLoadURL Exception: unable to extract Java string");
|
||||
if (urlStringChars != NULL)
|
||||
env->ReleaseStringChars(urlString, urlStringChars);
|
||||
return;
|
||||
}
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellLoadURL");
|
||||
if (urlStringChars != NULL)
|
||||
env->ReleaseStringChars(urlString, urlStringChars);
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsLoadURLEvent * actionEvent = new wsLoadURLEvent(initContext->webShell, urlStringChars);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
|
||||
env->ReleaseStringChars(urlString, urlStringChars);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeRefresh
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jlong loadFlags)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
void * voidResult = nsnull;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRefresh");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsRefreshEvent * actionEvent = new wsRefreshEvent(initContext->webShell, (long) loadFlags);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
voidResult = ::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeStop
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellStop");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsStopEvent * actionEvent = new wsStopEvent(initContext->webShell);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "RDFEnumeration.h"
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "jni_util.h"
|
||||
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRBool prResult = PR_FALSE;
|
||||
// assert -1 != nativeRDFNode
|
||||
jint nativeEnum;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement
|
||||
(JNIEnv *env, jobject obj, 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)) {
|
||||
printf("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)) {
|
||||
printf("Exception: nativeNextElement: next from enumerator is not an nsIRDFNode.\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (jint)nodeResult.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize
|
||||
(JNIEnv *env, jobject obj)
|
||||
{
|
||||
jclass objClass;
|
||||
jfieldID nativeEnumFieldID;
|
||||
jfieldID nativeContainerFieldID;
|
||||
jint nativeEnum, nativeContainer;
|
||||
|
||||
objClass = env->GetObjectClass(obj);
|
||||
if (NULL == objClass) {
|
||||
printf("nativeFinalize: Can't get object class for RDFEnumeration.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// release the nsISimpleEnumerator
|
||||
nativeEnumFieldID = env->GetFieldID(objClass, "nativeEnum", "I");
|
||||
if (NULL == nativeEnumFieldID) {
|
||||
printf("nativeFinalize: Can't get fieldID for nativeEnum.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nativeEnum = env->GetIntField(obj, nativeEnumFieldID);
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator =
|
||||
(nsISimpleEnumerator *) nativeEnum;
|
||||
((nsISupports *)enumerator.get())->Release();
|
||||
|
||||
// release the nsIRDFContainer
|
||||
nativeContainerFieldID = env->GetFieldID(objClass, "nativeContainer", "I");
|
||||
if (NULL == nativeContainerFieldID) {
|
||||
printf("nativeFinalize: Can't get fieldID for nativeContainer.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nativeContainer = env->GetIntField(obj, nativeContainerFieldID);
|
||||
nsCOMPtr<nsIRDFContainer> container =
|
||||
(nsIRDFContainer *) nativeContainer;
|
||||
((nsISupports *)container.get())->Release();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsresult rv;
|
||||
jint result = -1;
|
||||
jclass objClass;
|
||||
jfieldID nativeEnumFieldID;
|
||||
jfieldID nativeContainerFieldID;
|
||||
|
||||
objClass = env->GetObjectClass(obj);
|
||||
if (NULL == objClass) {
|
||||
printf("getNativeEnumFromJava: Can't get object class for RDFEnumeration.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nativeEnumFieldID = env->GetFieldID(objClass, "nativeEnum", "I");
|
||||
if (NULL == nativeEnumFieldID) {
|
||||
printf("getNativeEnumFromJava: Can't get fieldID for nativeEnum.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = env->GetIntField(obj, nativeEnumFieldID);
|
||||
|
||||
// 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)) {
|
||||
printf("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get a container in order to get the enum
|
||||
rv = nsComponentManager::CreateInstance(NS_IRDFCONTAINER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: can't get a new container\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, nodeResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("getNativeEnumFromJava: Can't Init container.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("getNativeEnumFromJava: Can't get enumeration from container.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// IMPORTANT: Store the enum back into java
|
||||
env->SetIntField(obj, nativeEnumFieldID, (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.
|
||||
nativeContainerFieldID = env->GetFieldID(objClass, "nativeContainer", "I");
|
||||
if (NULL == nativeContainerFieldID) {
|
||||
printf("getNativeEnumFromJava: Can't get fieldID for nativeContainer.\n");
|
||||
return -1;
|
||||
}
|
||||
env->SetIntField(obj, nativeContainerFieldID, (jint) container.get());
|
||||
((nsISupports *)container.get())->AddRef();
|
||||
|
||||
// NORMAL EXIT 2
|
||||
result = (jint)enumerator.get();
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,275 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "RDFTreeNode.h"
|
||||
|
||||
#include "rdf_util.h"
|
||||
#include "jni_util.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
//
|
||||
// Local function prototypes
|
||||
//
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsLeaf
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFResource> nodeResource;
|
||||
nsresult rv;
|
||||
jboolean result = JNI_FALSE;
|
||||
PRInt32 count;
|
||||
|
||||
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;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeIsContainer
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
|
||||
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 result;
|
||||
}
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, nodeResource,
|
||||
&prBool);
|
||||
result = (prBool == PR_FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildAt
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode, jint childIndex)
|
||||
{
|
||||
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.");
|
||||
return result;
|
||||
}
|
||||
result = (jint)child.get();
|
||||
((nsISupports *)result)->AddRef();
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetChildCount
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
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.");
|
||||
return result;
|
||||
}
|
||||
result = (jint)count;
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeGetIndex
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode, jint childRDFNode)
|
||||
{
|
||||
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;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
|
||||
(JNIEnv *env, jobject obj, jint nativeRDFNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> currentResource =
|
||||
(nsIRDFResource *) nativeRDFNode;
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
jstring result = NULL;
|
||||
PRBool isContainer = PR_FALSE;
|
||||
nsresult rv;
|
||||
const PRUnichar *textForNode = NULL;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, currentResource,
|
||||
&isContainer);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeToString: Can't tell if RDFResource is container.");
|
||||
return result;
|
||||
}
|
||||
|
||||
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 {
|
||||
printf("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)) {
|
||||
printf("nativeToString: node doesn't have a value.\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdf_printArcLabels(currentResource);
|
||||
printf("nativeToString: node is not an nsIRDFLiteral.\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdf_printArcLabels(currentResource);
|
||||
printf("nativeToString: node doesn't have a URL.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != textForNode) {
|
||||
nsString * string = new nsString(textForNode);
|
||||
int length = 0;
|
||||
if (NULL != string) {
|
||||
length = string->Length();
|
||||
}
|
||||
|
||||
result = env->NewString(textForNode, length);
|
||||
}
|
||||
else {
|
||||
result = env->NewStringUTF("");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
|
||||
(JNIEnv *env, jobject obj, 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;
|
||||
}
|
||||
|
||||
// get a container in order to create a child
|
||||
rv = nsComponentManager::CreateInstance(NS_IRDFCONTAINER_PROGID,
|
||||
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;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
|
@ -0,0 +1,208 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "WindowControlImpl.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#include "nsIThread.h" // for PRThread
|
||||
|
||||
#include "nsCOMPtr.h" // to get nsIBaseWindow from webshell
|
||||
#include "nsIBaseWindow.h" // to get methods like SetVisibility
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetBounds
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint x, jint y, jint w, jint h)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetBounds");
|
||||
return;
|
||||
}
|
||||
if (initContext->initComplete) {
|
||||
wsResizeEvent * actionEvent =
|
||||
new wsResizeEvent(initContext->webShell, x, y, w, h);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeCreateInitContext
|
||||
(JNIEnv *env, jobject obj, jint windowPtr, jint x, jint y,
|
||||
jint width, jint height)
|
||||
{
|
||||
jobject jobj = obj;
|
||||
#ifdef XP_MAC
|
||||
WindowPtr pWindow = (WindowPtr) windowPtr;
|
||||
Rect webRect = pWindow->portRect;
|
||||
// nsIWidget * pWidget = (nsIWidget *) widgetPtr;
|
||||
#elif defined(XP_PC)
|
||||
// elif defined(XP_WIN)
|
||||
HWND parentHWnd = (HWND)windowPtr;
|
||||
#elif defined(XP_UNIX)
|
||||
GtkWidget * parentHWnd = (GtkWidget *) windowPtr;
|
||||
#endif
|
||||
|
||||
if (parentHWnd == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null window handle passed to raptorWebShellCreate");
|
||||
return (jint) 0;
|
||||
}
|
||||
WebShellInitContext* initContext = new WebShellInitContext;
|
||||
|
||||
initContext->initComplete = FALSE;
|
||||
initContext->initFailCode = 0;
|
||||
initContext->parentHWnd = parentHWnd;
|
||||
initContext->webShell = NULL;
|
||||
initContext->embeddedThread = NULL;
|
||||
initContext->sessionHistory = NULL;
|
||||
initContext->actionQueue = NULL;
|
||||
initContext->nativeEventThread = NULL;
|
||||
initContext->env = env;
|
||||
initContext->stopThread = FALSE;
|
||||
initContext->x = x;
|
||||
initContext->y = y;
|
||||
initContext->w = width;
|
||||
initContext->h = height;
|
||||
|
||||
return (jint) initContext;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeMoveWindowTo
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint x, jint y)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellMoveTo");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsMoveToEvent * actionEvent = new wsMoveToEvent(initContext->webShell, x, y);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeRemoveFocus
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRemoveFocus");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsRemoveFocusEvent * actionEvent = new wsRemoveFocusEvent(initContext->webShell);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeRepaint
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean forceRepaint)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRepaint");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsRepaintEvent * actionEvent = new wsRepaintEvent(initContext->webShell, (PRBool) forceRepaint);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetVisible
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean newState)
|
||||
{
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
nsresult rv;
|
||||
|
||||
rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kShowWebShellError;
|
||||
return;
|
||||
}
|
||||
rv = baseWindow->SetVisibility(JNI_TRUE == newState ? PR_TRUE : PR_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kShowWebShellError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't SetVisibility");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetFocus
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellSetFocus");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
wsSetFocusEvent * actionEvent = new wsSetFocusEvent(initContext->webShell);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "WrapperFactoryImpl.h"
|
||||
|
||||
#include "nsIServiceManager.h" // for NS_InitXPCOM
|
||||
#include "nsAppShellCIDs.h" // for NS_SESSIONHISTORY_CID
|
||||
#include "nsCRT.h" // for nsCRT::strcmp
|
||||
|
||||
static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID);
|
||||
|
||||
#ifdef XP_PC
|
||||
|
||||
// All this stuff is needed to initialize the history
|
||||
|
||||
#define APPSHELL_DLL "appshell.dll"
|
||||
#define BROWSER_DLL "nsbrowser.dll"
|
||||
#define EDITOR_DLL "ender.dll"
|
||||
|
||||
#else
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
#define APPSHELL_DLL "APPSHELL_DLL"
|
||||
#define EDITOR_DLL "ENDER_DLL"
|
||||
|
||||
#else
|
||||
|
||||
// XP_UNIX || XP_BEOS
|
||||
#define APPSHELL_DLL "libnsappshell"MOZ_DLL_SUFFIX
|
||||
#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX
|
||||
#define EDITOR_DLL "libender"MOZ_DLL_SUFFIX
|
||||
|
||||
#endif // XP_MAC
|
||||
|
||||
#endif // XP_PC
|
||||
|
||||
|
||||
static nsFileSpec gBinDir;
|
||||
|
||||
const char *gImplementedInterfaces[] = {
|
||||
"webclient.WindowControl",
|
||||
"webclient.Navigation",
|
||||
"webclient.CurrentPage",
|
||||
"webclient.History",
|
||||
"webclient.EventRegistration",
|
||||
"webclient.Bookmarks",
|
||||
NULL
|
||||
};
|
||||
|
||||
extern "C" void NS_SetupRegistry();
|
||||
extern nsresult NS_AutoregisterComponents();
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeInitialize(
|
||||
JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath)
|
||||
{
|
||||
JNIEnv * pEnv = env;
|
||||
jobject jobj = obj;
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
if (gFirstTime) {
|
||||
const char *nativePath = (const char *) env->GetStringUTFChars(verifiedBinDirAbsolutePath, 0);
|
||||
gBinDir = nativePath;
|
||||
|
||||
NS_InitXPCOM(NULL, &gBinDir);
|
||||
NS_SetupRegistry();
|
||||
nsComponentManager::RegisterComponentLib(kSessionHistoryCID, NULL,
|
||||
NULL, APPSHELL_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
NS_AutoregisterComponents();
|
||||
gFirstTime = PR_FALSE;
|
||||
env->ReleaseStringUTFChars(verifiedBinDirAbsolutePath, nativePath);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeTerminate
|
||||
(JNIEnv *, jobject)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeDoesImplement
|
||||
(JNIEnv *env, jobject obj, jstring interfaceName)
|
||||
{
|
||||
const char *iName = (const char *) env->GetStringUTFChars(interfaceName,
|
||||
0);
|
||||
jboolean result = JNI_FALSE;
|
||||
|
||||
int i = 0;
|
||||
|
||||
if (NULL == iName) {
|
||||
return result;
|
||||
}
|
||||
|
||||
while (NULL != gImplementedInterfaces[i]) {
|
||||
if (0 == nsCRT::strcmp(gImplementedInterfaces[i++], iName)) {
|
||||
result = JNI_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
env->ReleaseStringUTFChars(interfaceName, iName);
|
||||
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
JavaVM *gVm = NULL;
|
||||
|
||||
void util_ThrowExceptionToJava (JNIEnv * env, const char * message)
|
||||
{
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionClear();
|
||||
}
|
||||
jclass excCls = env->FindClass("java/lang/Exception");
|
||||
|
||||
if (excCls == 0) { // Unable to find the exception class, give up.
|
||||
if (env->ExceptionOccurred())
|
||||
env->ExceptionClear();
|
||||
return;
|
||||
}
|
||||
|
||||
// Throw the exception with the error code and description
|
||||
jmethodID jID = env->GetMethodID(excCls, "<init>", "(Ljava/lang/String;)V"); // void Exception(String)
|
||||
|
||||
if (jID != NULL) {
|
||||
jstring exceptionString = env->NewStringUTF(message);
|
||||
jthrowable newException = (jthrowable) env->NewObject(excCls, jID, exceptionString);
|
||||
|
||||
if (newException != NULL) {
|
||||
env->Throw(newException);
|
||||
}
|
||||
else {
|
||||
if (env->ExceptionOccurred())
|
||||
env->ExceptionClear();
|
||||
}
|
||||
} else {
|
||||
if (env->ExceptionOccurred())
|
||||
env->ExceptionClear();
|
||||
}
|
||||
} // ThrowExceptionToJava()
|
||||
|
||||
void util_PostEvent(WebShellInitContext * initContext, PLEvent * event)
|
||||
{
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue);
|
||||
|
||||
::PL_PostEvent(initContext->actionQueue, event);
|
||||
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue);
|
||||
} // PostEvent()
|
||||
|
||||
|
||||
void *util_PostSynchronousEvent(WebShellInitContext * initContext, PLEvent * event)
|
||||
{
|
||||
void * voidResult = nsnull;
|
||||
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue);
|
||||
|
||||
voidResult = ::PL_PostSynchronousEvent(initContext->actionQueue, event);
|
||||
|
||||
PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue);
|
||||
|
||||
return voidResult;
|
||||
} // PostSynchronousEvent()
|
||||
|
||||
|
||||
void util_SendEventToJava(JNIEnv *yourEnv, jobject nativeEventThread,
|
||||
jobject webclientEventListener,
|
||||
jlong eventType)
|
||||
{
|
||||
if (NULL == gVm) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
|
||||
if (NULL == env) {
|
||||
return;
|
||||
}
|
||||
|
||||
jthrowable exception;
|
||||
|
||||
if (NULL != (exception = env->ExceptionOccurred())) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
jclass clazz = env->GetObjectClass(nativeEventThread);
|
||||
jmethodID mid = env->GetMethodID(clazz, "nativeEventOccurred",
|
||||
"(Lorg/mozilla/webclient/WebclientEventListener;J)V");
|
||||
if ( mid != NULL) {
|
||||
env->CallVoidMethod(nativeEventThread, mid, webclientEventListener,
|
||||
eventType);
|
||||
} else {
|
||||
printf("cannot call the Java Method!\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* @return: the string name of the current java thread. Must be freed!
|
||||
|
||||
*/
|
||||
|
||||
char *util_GetCurrentThreadName(JNIEnv *env)
|
||||
{
|
||||
jclass threadClass = env->FindClass("java/lang/Thread");
|
||||
jobject currentThread;
|
||||
jstring name;
|
||||
char *result = NULL;
|
||||
const char *cstr;
|
||||
jboolean isCopy;
|
||||
|
||||
if (NULL != threadClass) {
|
||||
jmethodID currentThreadID =
|
||||
env->GetStaticMethodID(threadClass,"currentThread",
|
||||
"()Ljava/lang/Thread;");
|
||||
currentThread = env->CallStaticObjectMethod(threadClass,
|
||||
currentThreadID);
|
||||
if (NULL != currentThread) {
|
||||
jmethodID getNameID = env->GetMethodID(threadClass,
|
||||
"getName",
|
||||
"()Ljava/lang/String;");
|
||||
name = (jstring) env->CallObjectMethod(currentThread, getNameID,
|
||||
NULL);
|
||||
result = strdup(cstr = env->GetStringUTFChars(name, &isCopy));
|
||||
if (JNI_TRUE == isCopy) {
|
||||
env->ReleaseStringUTFChars(name, cstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
void util_DumpJavaStack(JNIEnv *env)
|
||||
{
|
||||
jclass threadClass = env->FindClass("java/lang/Thread");
|
||||
if (NULL != threadClass) {
|
||||
jmethodID dumpStackID = env->GetStaticMethodID(threadClass,
|
||||
"dumpStack",
|
||||
"()V");
|
||||
env->CallStaticVoidMethod(threadClass, dumpStackID);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jvalue JNICALL
|
||||
JNU_CallMethodByName(JNIEnv *env,
|
||||
jboolean *hasException,
|
||||
jobject obj,
|
||||
const char *name,
|
||||
const char *signature,
|
||||
...)
|
||||
{
|
||||
jvalue result;
|
||||
va_list args;
|
||||
|
||||
va_start(args, signature);
|
||||
result = JNU_CallMethodByNameV(env, hasException, obj, name, signature,
|
||||
args);
|
||||
va_end(args);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jvalue JNICALL
|
||||
JNU_CallMethodByNameV(JNIEnv *env,
|
||||
jboolean *hasException,
|
||||
jobject obj,
|
||||
const char *name,
|
||||
const char *signature,
|
||||
va_list args)
|
||||
{
|
||||
jclass clazz;
|
||||
jmethodID mid;
|
||||
jvalue result;
|
||||
const char *p = signature;
|
||||
printf("jni_util: call method by name if 0");
|
||||
/* find out the return type */
|
||||
while (*p && *p != ')')
|
||||
p++;
|
||||
p++;
|
||||
|
||||
result.i = 0;
|
||||
|
||||
if (env->EnsureLocalCapacity(3) < 0)
|
||||
goto done2;
|
||||
printf("jni_util: call method by name if 1");
|
||||
clazz = env->GetObjectClass(obj);
|
||||
printf("jni_util: call method by name 2");
|
||||
mid = env->GetMethodID(clazz, name, signature);
|
||||
printf("jni_util: call method by name 3");
|
||||
if (mid == 0)
|
||||
goto done1;
|
||||
printf("jni_util: call method by name if 4");
|
||||
switch (*p) {
|
||||
case 'V':
|
||||
env->CallVoidMethodV(obj, mid, args);
|
||||
break;
|
||||
case '[':
|
||||
case 'L':
|
||||
result.l = env->CallObjectMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'Z':
|
||||
result.z = env->CallBooleanMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'B':
|
||||
result.b = env->CallByteMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'C':
|
||||
result.c = env->CallCharMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'S':
|
||||
result.s = env->CallShortMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'I':
|
||||
result.i = env->CallIntMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'J':
|
||||
result.j = env->CallLongMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'F':
|
||||
result.f = env->CallFloatMethodV(obj, mid, args);
|
||||
break;
|
||||
case 'D':
|
||||
result.d = env->CallDoubleMethodV(obj, mid, args);
|
||||
break;
|
||||
default:
|
||||
env->FatalError("JNU_CallMethodByNameV: illegal signature");
|
||||
}
|
||||
done1:
|
||||
env->DeleteLocalRef(clazz);
|
||||
done2:
|
||||
if (hasException) {
|
||||
*hasException = env->ExceptionCheck();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void * JNICALL
|
||||
JNU_GetEnv(JavaVM *vm, jint version)
|
||||
{
|
||||
// void *result;
|
||||
//vm->GetEnv(&result, version);
|
||||
|
||||
JNIEnv *result = NULL;
|
||||
vm->AttachCurrentThread((void **)&result, (void *) version);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Util methods
|
||||
|
||||
*/
|
||||
|
||||
#ifndef jni_util_h
|
||||
#define jni_util_h
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "nsCOMPtr.h" // so we can save the docShell
|
||||
#include "nsIDocShell.h" // so we can save our nsIDocShell
|
||||
#include "nsISessionHistory.h" // so we can save our nsISessionHistory
|
||||
#include "nsIThread.h" // for PRThread
|
||||
#include "nsIWebShell.h" // for nsIWebShell
|
||||
#include "nsIEventQueueService.h" // for PLEventQueue
|
||||
|
||||
//
|
||||
// local classes
|
||||
//
|
||||
|
||||
// PENDING(edburns): this should be a class, and we should define a
|
||||
// constructor and destructor for it.
|
||||
|
||||
struct WebShellInitContext {
|
||||
#ifdef XP_UNIX
|
||||
GtkWidget * parentHWnd;
|
||||
#else
|
||||
// PENDING(mark): Don't we need something for Mac?
|
||||
HWND parentHWnd;
|
||||
#endif
|
||||
nsIWebShell * webShell;
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsISessionHistory* sessionHistory;
|
||||
PLEventQueue * actionQueue;
|
||||
PRThread * embeddedThread;
|
||||
JNIEnv * env;
|
||||
jobject nativeEventThread;
|
||||
int stopThread;
|
||||
int initComplete;
|
||||
int initFailCode;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
enum {
|
||||
kEventQueueError = 1,
|
||||
kCreateWebShellError,
|
||||
kInitWebShellError,
|
||||
kShowWebShellError,
|
||||
kHistoryWebShellError,
|
||||
kClipboardWebShellError
|
||||
};
|
||||
|
||||
extern JavaVM *gVm;
|
||||
|
||||
void util_ThrowExceptionToJava (JNIEnv * env, const char * message);
|
||||
|
||||
/**
|
||||
|
||||
* This method calls PL_PostEvent(),
|
||||
|
||||
* http://lxr.mozilla.org/mozilla/source/xpcom/threads/plevent.c#248
|
||||
|
||||
* which simply uses nice monitors to insert the event into the provided
|
||||
* event queue, which is from WebShellInitContext->actionQueue, which is
|
||||
* created in NativeEventThread.cpp:InitMozillaStuff(). The events are
|
||||
* processed in NativeEventThread.cpp:processEventLoop, which is called
|
||||
* from the Java NativeEventThread.run(). See the code and comments for
|
||||
* processEventLoop in NativeEventThread.cpp.
|
||||
|
||||
*/
|
||||
|
||||
void util_PostEvent (WebShellInitContext * initContext, PLEvent * event);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* This method calls PL_PostSynchronousEvent(),
|
||||
|
||||
* http://lxr.mozilla.org/mozilla/source/xpcom/threads/plevent.c#278
|
||||
|
||||
* which, instead of putting the event in the queue, as in
|
||||
* util_PostEvent(), either calls the event's handler directly, or puts
|
||||
* it in the queue and waits for it to be processed so it can return the
|
||||
* result.
|
||||
|
||||
*/
|
||||
|
||||
void * util_PostSynchronousEvent (WebShellInitContext * initContext, PLEvent * event);
|
||||
|
||||
/**
|
||||
|
||||
* simply call the java method nativeEventOccurred on
|
||||
* eventRegistrationImpl, passing webclientEventListener and eventType
|
||||
* as arguments.
|
||||
|
||||
*/
|
||||
|
||||
void util_SendEventToJava(JNIEnv *env, jobject eventRegistrationImpl,
|
||||
jobject webclientEventListener,
|
||||
jlong eventType);
|
||||
|
||||
char *util_GetCurrentThreadName(JNIEnv *env);
|
||||
|
||||
void util_DumpJavaStack(JNIEnv *env);
|
||||
|
||||
//
|
||||
// Functions from secret JDK files
|
||||
//
|
||||
|
||||
JNIEXPORT jvalue JNICALL
|
||||
JNU_CallMethodByName(JNIEnv *env,
|
||||
jboolean *hasException,
|
||||
jobject obj,
|
||||
const char *name,
|
||||
const char *signature,
|
||||
...);
|
||||
|
||||
JNIEXPORT jvalue JNICALL
|
||||
JNU_CallMethodByNameV(JNIEnv *env,
|
||||
jboolean *hasException,
|
||||
jobject obj,
|
||||
const char *name,
|
||||
const char *signature,
|
||||
va_list args);
|
||||
|
||||
JNIEXPORT void * JNICALL
|
||||
JNU_GetEnv(JavaVM *vm, jint version);
|
||||
|
||||
#endif // jni_util_h
|
|
@ -0,0 +1,854 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
* BrowserControlNativeShimStub.cpp
|
||||
*/
|
||||
|
||||
// PENDING(mark): I suppose this is where I need to go into my explaination of why
|
||||
// this file is needed...
|
||||
|
||||
// For loading DLL
|
||||
#include <dlfcn.h>
|
||||
// JNI...yada, yada, yada
|
||||
#include <jni.h>
|
||||
// JNI Header
|
||||
#include "../BrowserControlNativeShim.h"
|
||||
// JNI Header
|
||||
#include "NativeEventThread.h"
|
||||
|
||||
// allow code in webclientstub.so to load us
|
||||
#include "BrowserControlNativeShimStub.h"
|
||||
|
||||
// Global reference to webclient dll
|
||||
void * webClientDll;
|
||||
|
||||
extern void locateMotifBrowserControlStubFunctions(void *);
|
||||
|
||||
void (* nativeInitialize) (JNIEnv *, jobject, jstring);
|
||||
void (* nativeTerminate) (JNIEnv *, jobject);
|
||||
void (* nativeSendKeyDownEvent) (JNIEnv *, jobject, jint, jchar, jint, jint, jint);
|
||||
void (* nativeSendKeyUpEvent) (JNIEnv *, jobject, jint, jchar, jint, jint, jint);
|
||||
void (* nativeSendMouseEvent) (JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint);
|
||||
void (* nativeIdleEvent) (JNIEnv *, jobject, jint, jint);
|
||||
void (* nativeUpdateEvent) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeWidgetCreate) (JNIEnv *, jobject, jint, jint, jint, jint, jint);
|
||||
void (* nativeWidgetDelete) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWidgetResize) (JNIEnv *, jobject, jint, jint, jint, jint, jint, jboolean);
|
||||
void (* nativeWidgetEnable) (JNIEnv *, jobject, jint, jboolean);
|
||||
void (* nativeWidgetShow) (JNIEnv *, jobject, jint, jboolean);
|
||||
void (* nativeWidgetInvalidate) (JNIEnv *, jobject, jint, jboolean);
|
||||
void (* nativeWidgetUpdate) (JNIEnv *, jobject, jint);
|
||||
void (* nativeProcessEvents) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeWebShellCreate) (JNIEnv *, jobject, jint, jint, jint, jint, jint);
|
||||
void (* nativeWebShellDelete) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWebShellLoadURL) (JNIEnv *, jobject, jint, jstring);
|
||||
void (* nativeWebShellStop) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWebShellShow) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWebShellHide) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWebShellSetBounds) (JNIEnv *, jobject, jint, jint, jint, jint, jint);
|
||||
void (* nativeWebShellMoveTo) (JNIEnv *, jobject, jint, jint, jint);
|
||||
void (* nativeWebShellSetFocus) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWebShellRemoveFocus) (JNIEnv *, jobject, jint);
|
||||
void (* nativeWebShellRepaint) (JNIEnv *, jobject, jint, jboolean);
|
||||
jboolean (* nativeWebShellCanBack) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeWebShellCanForward) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeWebShellBack) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeWebShellForward) (JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeWebShellGoTo) (JNIEnv *, jobject, jint, jint);
|
||||
jint (* nativeWebShellGetHistoryLength) (JNIEnv *, jobject, jint);
|
||||
jint (* nativeWebShellGetHistoryIndex) (JNIEnv *, jobject, jint);
|
||||
jstring (* nativeWebShellGetURL) (JNIEnv *, jobject, jint, jint);
|
||||
// added by Mark Goddard OTMP 9/2/1999
|
||||
jboolean (* nativeWebShellRefresh)(JNIEnv *, jobject, jint);
|
||||
jboolean (* nativeWebShellAddDocListener) (JNIEnv *, jobject, jint, jobject);
|
||||
void (* processNativeEventQueue) (JNIEnv *, jobject, jint);
|
||||
|
||||
|
||||
void locateBrowserControlStubFunctions(void * dll) {
|
||||
nativeInitialize = (void (*) (JNIEnv *, jobject, jstring)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeInitialize");
|
||||
if (!nativeInitialize) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeTerminate = (void (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeTerminate");
|
||||
if (!nativeTerminate) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeSendKeyDownEvent = (void (*) (JNIEnv *, jobject, jint, jchar, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendKeyDownEvent");
|
||||
if (!nativeSendKeyDownEvent) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeSendKeyUpEvent = (void (*) (JNIEnv *, jobject, jint, jchar, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendKeyUpEvent");
|
||||
if (!nativeSendKeyUpEvent) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeSendMouseEvent = (void (*) (JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jint, jint,jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendMouseEvent");
|
||||
if (!nativeSendMouseEvent) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeIdleEvent = (void (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeIdleEvent");
|
||||
if (!nativeIdleEvent) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeUpdateEvent = (void (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeUpdateEvent");
|
||||
if (!nativeUpdateEvent) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetCreate = (jint (*) (JNIEnv *, jobject, jint, jint, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetCreate");
|
||||
if (!nativeWidgetCreate) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetDelete = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetDelete");
|
||||
if (!nativeWidgetDelete) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetResize = (void (*) (JNIEnv *, jobject, jint, jint, jint, jint, jint, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetResize");
|
||||
if (!nativeWidgetResize) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetEnable = (void (*) (JNIEnv *, jobject, jint, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetEnable");
|
||||
if (!nativeWidgetEnable) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetShow = (void (*) (JNIEnv *, jobject, jint, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetShow");
|
||||
if (!nativeWidgetShow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetInvalidate = (void (*) (JNIEnv *, jobject, jint, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetInvalidate");
|
||||
if (!nativeWidgetInvalidate) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWidgetUpdate = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetUpdate");
|
||||
if (!nativeWidgetUpdate) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeProcessEvents = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeProcessEvents");
|
||||
if (!nativeProcessEvents) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellCreate = (jint (*) (JNIEnv *, jobject, jint, jint, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCreate");
|
||||
if (!nativeWebShellCreate) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellDelete = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellDelete");
|
||||
if (!nativeWebShellDelete) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellLoadURL = (void (*) (JNIEnv *, jobject, jint, jstring)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellLoadURL");
|
||||
if (!nativeWebShellLoadURL) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellStop = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellStop");
|
||||
if (!nativeWebShellStop) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellShow = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellShow");
|
||||
if (!nativeWebShellShow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellHide = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellHide");
|
||||
if (!nativeWebShellHide) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellSetBounds = (void (*) (JNIEnv *, jobject, jint, jint, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellSetBounds");
|
||||
if (!nativeWebShellSetBounds) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellMoveTo = (void (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellMoveTo");
|
||||
if (!nativeWebShellMoveTo) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellSetFocus = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellSetFocus");
|
||||
if (!nativeWebShellSetFocus) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellRemoveFocus = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRemoveFocus");
|
||||
if (!nativeWebShellRemoveFocus) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellRepaint = (void (*) (JNIEnv *, jobject, jint, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRepaint");
|
||||
if (!nativeWebShellRepaint) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellCanBack = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCanBack");
|
||||
if (!nativeWebShellCanBack) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellCanForward = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCanForward");
|
||||
if (!nativeWebShellCanForward) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellBack = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellBack");
|
||||
if (!nativeWebShellBack) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellForward = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellForward");
|
||||
if (!nativeWebShellForward) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellGoTo = (jboolean (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGoTo");
|
||||
if (!nativeWebShellGoTo) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellGetHistoryLength = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetHistoryLength");
|
||||
if (!nativeWebShellGetHistoryLength) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellGetHistoryIndex = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetHistoryIndex");
|
||||
if (!nativeWebShellGetHistoryIndex) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
nativeWebShellGetURL = (jstring (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetURL");
|
||||
if (!nativeWebShellGetURL) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
// added by Mark Goddard OTMP 9/2/1999
|
||||
nativeWebShellRefresh = (jboolean (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRefresh");
|
||||
if (!nativeWebShellRefresh) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
nativeWebShellAddDocListener = (jboolean (*) (JNIEnv *, jobject, jint, jobject)) dlsym(dll, "Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellAddDocListener");
|
||||
if (!nativeWebShellAddDocListener) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
|
||||
processNativeEventQueue = (void (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_impl_wrapper_1native_motif_NativeEventThread_processNativeEventQueue");
|
||||
if (!processNativeEventQueue) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifNativeEventQueue
|
||||
* Method: processNativeEventQueue
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_NativeEventThread_processNativeEventQueue
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr) {
|
||||
(* processNativeEventQueue) (env, obj, gtkWinPtr);
|
||||
}
|
||||
|
||||
void loadMainDll(void)
|
||||
{
|
||||
webClientDll = dlopen("libwebclient.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
|
||||
if (webClientDll) {
|
||||
locateBrowserControlStubFunctions(webClientDll);
|
||||
locateMotifBrowserControlStubFunctions(webClientDll);
|
||||
} else {
|
||||
printf("Got Error: %s\n", dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorInitialize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeInitialize (
|
||||
JNIEnv * env,
|
||||
jobject obj, jstring verifiedBinDirAbsolutePath)
|
||||
{
|
||||
(* nativeInitialize) (env, obj, verifiedBinDirAbsolutePath);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeInitialize()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorTerminate
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeTerminate (
|
||||
JNIEnv * env,
|
||||
jobject obj)
|
||||
{
|
||||
(* nativeTerminate) (env, obj);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeTerminate()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorSendKeyDownEvent
|
||||
* Signature: (ICIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendKeyDownEvent (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr,
|
||||
jchar keyChar,
|
||||
jint keyCode,
|
||||
jint modifiers,
|
||||
jint eventTime)
|
||||
{
|
||||
(* nativeSendKeyDownEvent) (env, obj, widgetPtr, keyChar, keyCode, modifiers, eventTime);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendKeyDownEvent()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorSendKeyUpEvent
|
||||
* Signature: (ICIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendKeyUpEvent (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr,
|
||||
jchar keyChar,
|
||||
jint keyCode,
|
||||
jint modifiers,
|
||||
jint eventTime)
|
||||
{
|
||||
(* nativeSendKeyUpEvent) (env, obj, widgetPtr, keyChar, keyCode, modifiers, eventTime);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendKeyUpEvent()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorSendMouseEvent
|
||||
* Signature: (IIIIIIIIIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendMouseEvent (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint windowPtr,
|
||||
jint widgetPtr,
|
||||
jint widgetX,
|
||||
jint widgetY,
|
||||
jint windowX,
|
||||
jint windowY,
|
||||
jint mouseMessage,
|
||||
jint numClicks,
|
||||
jint modifiers,
|
||||
jint eventTime)
|
||||
{
|
||||
(* nativeSendMouseEvent) (env, obj, windowPtr, widgetPtr, widgetX, widgetY, windowX, windowY, mouseMessage, numClicks, modifiers, eventTime);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeSendMouseEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorIdleEvent
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeIdleEvent (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint windowPtr,
|
||||
jint eventTime)
|
||||
{
|
||||
(* nativeIdleEvent) (env, obj, windowPtr, eventTime);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeIdleEvent()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorUpdateEvent
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeUpdateEvent (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint windowPtr,
|
||||
jint eventTime)
|
||||
{
|
||||
(* nativeUpdateEvent) (env, obj, windowPtr, eventTime);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeUpdateEvent()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetCreate
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetCreate (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint windowPtr,
|
||||
jint x,
|
||||
jint y,
|
||||
jint width,
|
||||
jint height)
|
||||
{
|
||||
return (* nativeWidgetCreate) (env, obj, windowPtr, x, y, width, height);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetCreate()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetDelete
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetDelete (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr)
|
||||
{
|
||||
(* nativeWidgetDelete) (env, obj, widgetPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetDelete()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetResize
|
||||
* Signature: (IIIZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetResize (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr,
|
||||
jint x,
|
||||
jint y,
|
||||
jint width,
|
||||
jint height,
|
||||
jboolean repaint)
|
||||
{
|
||||
(* nativeWidgetResize) (env, obj, widgetPtr, x, y, width, height, repaint);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetResize()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetEnable
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetEnable (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr,
|
||||
jboolean enable)
|
||||
{
|
||||
(* nativeWidgetEnable) (env, obj, widgetPtr, enable);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetEnable()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetShow
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetShow (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr,
|
||||
jboolean show)
|
||||
{
|
||||
(* nativeWidgetShow) (env, obj, widgetPtr, show);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetShow()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetInvalidate
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetInvalidate (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr,
|
||||
jboolean isSynchronous)
|
||||
{
|
||||
(* nativeWidgetInvalidate) (env, obj, widgetPtr, isSynchronous);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetInvalidate()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWidgetUpdate
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetUpdate (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint widgetPtr)
|
||||
{
|
||||
(* nativeWidgetUpdate) (env, obj, widgetPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWidgetUpdate()
|
||||
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeProcessEvents (
|
||||
JNIEnv* env,
|
||||
jobject obj,
|
||||
jint theWebShell)
|
||||
{
|
||||
(* nativeProcessEvents) (env, obj, theWebShell);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellCreate
|
||||
* Signature: (IIIIII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCreate (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint windowPtr,
|
||||
jint x,
|
||||
jint y,
|
||||
jint width,
|
||||
jint height)
|
||||
{
|
||||
return (* nativeWebShellCreate) (env, obj, windowPtr, x, y, width, height);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCreate()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellDelete
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellDelete (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
(* nativeWebShellDelete) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellDelete()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellLoadURL
|
||||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellLoadURL (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jstring urlString)
|
||||
{
|
||||
(* nativeWebShellLoadURL) (env, obj, webShellPtr, urlString);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellLoadURL()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellStop
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellStop (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
(* nativeWebShellStop) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellStop()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellShow
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellShow (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
(* nativeWebShellShow) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellShow()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellHide
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellHide (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
(* nativeWebShellHide) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellHide()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellSetBounds
|
||||
* Signature: (IIIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellSetBounds (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jint x,
|
||||
jint y,
|
||||
jint width,
|
||||
jint height)
|
||||
{
|
||||
(* nativeWebShellSetBounds) (env, obj, webShellPtr, x, y, width, height);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellSetBounds()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellMoveTo
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellMoveTo (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jint x,
|
||||
jint y)
|
||||
{
|
||||
(* nativeWebShellMoveTo) (env, obj, webShellPtr, x, y);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellMoveTo()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellSetFocus
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellSetFocus (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
(* nativeWebShellSetFocus) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellSetFocus()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellRemoveFocus
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRemoveFocus (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
(* nativeWebShellRemoveFocus) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRemoveFocus()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellRepaint
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRepaint (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jboolean forceRepaint)
|
||||
{
|
||||
(* nativeWebShellRepaint) (env, obj, webShellPtr, forceRepaint);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRepaint()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellCanBack
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCanBack (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellCanBack) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCanBack()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellCanForward
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCanForward (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellCanForward) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellCanForward()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellBack
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellBack (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellBack) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellBack()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellForward
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellForward (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellForward) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellForward()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellGoTo
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGoTo (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jint historyIndex)
|
||||
{
|
||||
return (* nativeWebShellGoTo) (env, obj, webShellPtr, historyIndex);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGoTo()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellGetHistoryLength
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetHistoryLength (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellGetHistoryLength) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetHistoryLength()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellGetHistoryIndex
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetHistoryIndex (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellGetHistoryIndex) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetHistoryIndex()
|
||||
|
||||
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellGetURL
|
||||
* Signature: (II)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetURL (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jint historyIndex)
|
||||
{
|
||||
return (* nativeWebShellGetURL) (env, obj, webShellPtr, historyIndex);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellGetURL()
|
||||
|
||||
// added by Mark Goddard OTMP 9/2/1999
|
||||
/*
|
||||
* Class: MozWebShellNativeShim
|
||||
* Method: raptorWebShellRefresh
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRefresh (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr)
|
||||
{
|
||||
return (* nativeWebShellRefresh) (env, obj, webShellPtr);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellRefresh()
|
||||
|
||||
|
||||
/*
|
||||
* Class: BrowserControlNativeShimStub
|
||||
* Method: nativeWebShellAddDocListener
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellAddDocListener (
|
||||
JNIEnv * env,
|
||||
jobject obj,
|
||||
jint webShellPtr,
|
||||
jobject listener)
|
||||
{
|
||||
return (* nativeWebShellAddDocListener) (env, obj, webShellPtr, listener);
|
||||
} // Java_org_mozilla_webclient_BrowserControlNativeShim_nativeWebShellAddDocListener()
|
||||
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
* BrowserControlNativeShimStub.h
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
* This file exports a function that allows the code in
|
||||
* MotifBrowserControlCanvasStub to load the real webclient dll.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Called by loadMainDll() in MotifBrowserControlCanvasStub.cpp
|
||||
|
||||
* simply loads the webclient dll and copies all the right function
|
||||
* pointers.
|
||||
|
||||
*/
|
||||
|
||||
void loadMainDll(void);
|
|
@ -0,0 +1,169 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* MotifBrowserControlCanvas.cpp
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "MotifBrowserControlCanvas.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtkmozilla.h"
|
||||
#include "gtkmozarea.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsGtkEventHandler.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
extern "C" void NS_SetupRegistry();
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: createTopLevelWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_createTopLevelWindow
|
||||
(JNIEnv * env, jobject obj) {
|
||||
static GtkWidget *mShell = NULL;
|
||||
|
||||
/* Initialise GTK */
|
||||
gtk_set_locale ();
|
||||
|
||||
gtk_init (0, NULL);
|
||||
|
||||
gdk_event_handler_set (handle_gdk_event, NULL, NULL);
|
||||
|
||||
gdk_rgb_init();
|
||||
|
||||
mShell = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_default_size(GTK_WINDOW(mShell), 300, 300);
|
||||
gtk_window_set_title(GTK_WINDOW(mShell), "Simple browser");
|
||||
|
||||
return (jint) mShell;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: createContainerWindow
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_createContainerWindow
|
||||
(JNIEnv * env, jobject obj, jint parent, jint screenWidth, jint screenHeight) {
|
||||
GtkWidget * window = (GtkWidget *) parent;
|
||||
GtkWidget *mMozArea = NULL;
|
||||
|
||||
mMozArea = gtk_mozarea_new();
|
||||
gtk_container_add(GTK_CONTAINER(window), mMozArea);
|
||||
gtk_widget_realize(GTK_WIDGET(mMozArea));
|
||||
|
||||
// HACK: javaMake sure this window doesn't appear onscreen!!!!
|
||||
gtk_widget_set_uposition(window, screenWidth + 20, screenHeight + 20);
|
||||
gtk_widget_show(mMozArea);
|
||||
|
||||
gtk_widget_show(window);
|
||||
|
||||
//gtk_main();
|
||||
|
||||
return (jint) mMozArea;
|
||||
}
|
||||
|
||||
int getWinID(GtkWidget * gtkWidgetPtr) {
|
||||
//GdkWindow * gdkWindow = gtk_widget_get_parent_window(gtkWidgetPtr);
|
||||
GdkWindow * gdkWindow = gtkWidgetPtr->window;
|
||||
int gtkwinid = GDK_WINDOW_XWINDOW(gdkWindow);
|
||||
|
||||
return gtkwinid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: getGTKWinID
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_getGTKWinID
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr) {
|
||||
GtkWidget * gtkWidgetPtr = (GtkWidget *) gtkWinPtr;
|
||||
|
||||
return getWinID(gtkWidgetPtr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: reparentWindow
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_reparentWindow (JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
XReparentWindow(GDK_DISPLAY(), childID, parentID, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: processEvents
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_processEvents
|
||||
(JNIEnv * env, jobject obj) {
|
||||
//printf("process events....\n");
|
||||
//processEventLoopIntelligently();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: setGTKWindowSize
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_setGTKWindowSize
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr, jint width, jint height) {
|
||||
if (gtkWinPtr != 0) {
|
||||
GtkWidget * gtkWidgetPtr = (GtkWidget *) gtkWinPtr;
|
||||
|
||||
if (gtkWidgetPtr) {
|
||||
gtk_widget_set_usize(gtkWidgetPtr, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: loadMainDll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_loadMainDll
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
printf("incorrect loadMainDll called\n\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // End extern "C"
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* MotifBrowserControlCanvasStub.cpp
|
||||
*/
|
||||
|
||||
// PENDING(mark): I suppose this is where I need to go into my explaination of why
|
||||
// this file is needed...
|
||||
|
||||
#include <jni.h>
|
||||
#include "MotifBrowserControlCanvas.h"
|
||||
|
||||
#include "BrowserControlMozillaShimStub.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
extern void locateBrowserControlStubFunctions(void *);
|
||||
|
||||
jint (* createTopLevelWindow) (JNIEnv *, jobject);
|
||||
jint (* createContainerWindow) (JNIEnv *, jobject, jint, jint, jint);
|
||||
jint (* getGTKWinID) (JNIEnv *, jobject, jint);
|
||||
void (* reparentWindow) (JNIEnv *, jobject, jint, jint);
|
||||
void (* processEvents) (JNIEnv *, jobject);
|
||||
void (* setGTKWindowSize) (JNIEnv *, jobject, jint, jint, jint);
|
||||
|
||||
void locateMotifBrowserControlStubFunctions(void * dll) {
|
||||
createTopLevelWindow = (jint (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_createTopLevelWindow");
|
||||
if (!createTopLevelWindow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
createContainerWindow = (jint (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_createContainerWindow");
|
||||
if (!createContainerWindow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
reparentWindow = (void (*) (JNIEnv *, jobject, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_reparentWindow");
|
||||
if (!reparentWindow) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
processEvents = (void (*) (JNIEnv *, jobject)) dlsym(dll, "Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_processEvents");
|
||||
if (!processEvents) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
setGTKWindowSize = (void (*) (JNIEnv *, jobject, jint, jint, jint)) dlsym(dll, "Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_setGTKWindowSize");
|
||||
if (!setGTKWindowSize) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
|
||||
getGTKWinID = (jint (*) (JNIEnv *, jobject, jint)) dlsym(dll, "Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_getGTKWinID");
|
||||
if (!getGTKWinID) {
|
||||
printf("got dlsym error %s\n", dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: createTopLevelWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_createTopLevelWindow (JNIEnv * env, jobject obj) {
|
||||
return (* createTopLevelWindow) (env, obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: createContainerWindow
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_createContainerWindow (JNIEnv * env, jobject obj, jint parent, jint width, jint height) {
|
||||
return (* createContainerWindow) (env, obj, parent, width, height);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: getGTKWinID
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_getGTKWinID
|
||||
(JNIEnv * env, jobject obj, jint gtkWinPtr) {
|
||||
return (* getGTKWinID) (env, obj, gtkWinPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: reparentWindow
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_reparentWindow
|
||||
(JNIEnv * env, jobject obj, jint childID, jint parentID) {
|
||||
(* reparentWindow) (env, obj, childID, parentID);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: processEvents
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_processEvents
|
||||
(JNIEnv * env, jobject obj) {
|
||||
(* processEvents) (env, obj);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: setGTKWindowSize
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_setGTKWindowSize
|
||||
(JNIEnv * env, jobject obj, jint xwinID, jint width, jint height) {
|
||||
(* setGTKWindowSize) (env, obj, xwinID, width, height);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_motif_MotifBrowserControlCanvas
|
||||
* Method: loadMainDll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_motif_MotifBrowserControlCanvas_loadMainDll
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
loadMainDll();
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "MPL"); you may not use this file except in
|
||||
* compliance with the MPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Alexander. Portions
|
||||
* created by Alexander Larsson are Copyright (C) 1999
|
||||
* Alexander Larsson. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* gtkmozilla.cpp
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtkmozilla.h"
|
||||
|
||||
static void gtk_mozilla_realize(GtkWidget *widget);
|
||||
static void gtk_mozilla_finalize (GtkObject *object);
|
||||
|
||||
typedef gboolean (*GtkSignal_BOOL__POINTER_INT) (GtkObject * object,
|
||||
gpointer arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
|
||||
extern "C" void
|
||||
gtk_mozilla_marshal_BOOL__POINTER_INT (GtkObject * object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg * args)
|
||||
{
|
||||
GtkSignal_BOOL__POINTER_INT rfunc;
|
||||
gboolean *return_val;
|
||||
return_val = GTK_RETLOC_BOOL (args[2]);
|
||||
rfunc = (GtkSignal_BOOL__POINTER_INT) func;
|
||||
*return_val = (*rfunc) (object,
|
||||
GTK_VALUE_POINTER (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
}
|
||||
|
||||
static GtkLayoutClass *parent_class = 0;
|
||||
|
||||
static void
|
||||
gtk_mozilla_class_init (GtkMozillaClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
widget_class = (GtkWidgetClass*) klass;
|
||||
|
||||
parent_class = (GtkLayoutClass *)gtk_type_class (GTK_TYPE_LAYOUT);
|
||||
|
||||
object_class->finalize = gtk_mozilla_finalize;
|
||||
widget_class->realize = gtk_mozilla_realize;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_mozilla_realize (GtkWidget *widget)
|
||||
{
|
||||
//printf("gtk_mozilla_realize()\n");
|
||||
GtkMozilla *moz = GTK_MOZILLA(widget);
|
||||
|
||||
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
||||
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_mozilla_init (GtkMozilla *moz)
|
||||
{
|
||||
//printf("gtk_mozilla_init()\n");
|
||||
|
||||
gtk_layout_set_hadjustment (GTK_LAYOUT (moz), 0);
|
||||
gtk_layout_set_vadjustment (GTK_LAYOUT (moz), 0);
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (GTK_WIDGET(moz), GTK_CAN_FOCUS);
|
||||
}
|
||||
|
||||
GtkType
|
||||
gtk_mozilla_get_type (void)
|
||||
{
|
||||
static GtkType mozilla_type = 0;
|
||||
|
||||
if (!mozilla_type) {
|
||||
static const GtkTypeInfo mozilla_info = {
|
||||
"GtkMozilla",
|
||||
sizeof (GtkMozilla),
|
||||
sizeof (GtkMozillaClass),
|
||||
(GtkClassInitFunc) gtk_mozilla_class_init,
|
||||
(GtkObjectInitFunc) gtk_mozilla_init,
|
||||
(GtkArgSetFunc) NULL,
|
||||
(GtkArgGetFunc) NULL,
|
||||
};
|
||||
mozilla_type = gtk_type_unique (GTK_TYPE_LAYOUT, &mozilla_info);
|
||||
}
|
||||
|
||||
return mozilla_type;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_mozilla_new (void)
|
||||
{
|
||||
GtkMozilla *moz;
|
||||
|
||||
moz = GTK_MOZILLA(gtk_type_new(GTK_TYPE_MOZILLA));
|
||||
|
||||
return GTK_WIDGET (moz);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_mozilla_finalize (GtkObject *object)
|
||||
{
|
||||
GtkMozilla *moz;
|
||||
|
||||
g_return_if_fail(object != NULL);
|
||||
g_return_if_fail(GTK_IS_MOZILLA(object));
|
||||
|
||||
moz = GTK_MOZILLA(object);
|
||||
|
||||
GTK_OBJECT_CLASS(parent_class)->finalize (object);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Alexander
|
||||
* Larsson. Portions created by Alexander Larsson are
|
||||
* Copyright (C) 1999 Alexander Larsson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
* gtkmozilla.h
|
||||
*/
|
||||
|
||||
#ifndef GTKMOZILLA_H
|
||||
#define GTKMOZILLA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <gtk/gtklayout.h>
|
||||
|
||||
#define GTK_TYPE_MOZILLA (gtk_mozilla_get_type ())
|
||||
#define GTK_MOZILLA(obj) GTK_CHECK_CAST ((obj), GTK_TYPE_MOZILLA, GtkMozilla)
|
||||
#define GTK_MOZILLA_CLASS(klass) GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZILLA, GtkMozillaClass)
|
||||
#define GTK_IS_MOZILLA(obj) GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZILLA)
|
||||
#define GTK_IS_MOZILLA_CLASS(klass) GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZILLA)
|
||||
|
||||
|
||||
typedef struct _GtkMozilla GtkMozilla;
|
||||
typedef struct _GtkMozillaClass GtkMozillaClass;
|
||||
|
||||
struct _GtkMozilla
|
||||
{
|
||||
GtkLayout layout;
|
||||
};
|
||||
|
||||
struct _GtkMozillaClass
|
||||
{
|
||||
GtkLayoutClass parent_class;
|
||||
};
|
||||
|
||||
extern GtkType gtk_mozilla_get_type(void);
|
||||
extern GtkWidget* gtk_mozilla_new(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* GTKMOZILLA_H */
|
|
@ -0,0 +1,761 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* nsActions.cpp
|
||||
*/
|
||||
|
||||
#include "nsActions.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
|
||||
|
||||
void * handleEvent (PLEvent * event);
|
||||
void destroyEvent (PLEvent * event);
|
||||
|
||||
|
||||
void *
|
||||
handleEvent (PLEvent * event)
|
||||
{
|
||||
nsActionEvent * actionEvent = (nsActionEvent*) event->owner;
|
||||
void * result = nsnull;
|
||||
|
||||
result = actionEvent->handleEvent();
|
||||
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
void
|
||||
destroyEvent (PLEvent * event)
|
||||
{
|
||||
nsActionEvent * actionEvent = (nsActionEvent*) event->owner;
|
||||
|
||||
if (actionEvent != NULL) {
|
||||
actionEvent->destroyEvent();
|
||||
}
|
||||
} // destroyEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* nsActionEvent
|
||||
*/
|
||||
|
||||
nsActionEvent::nsActionEvent ()
|
||||
{
|
||||
PL_InitEvent(&mEvent, this,
|
||||
(PLHandleEventProc ) ::handleEvent,
|
||||
(PLDestroyEventProc) ::destroyEvent);
|
||||
}
|
||||
|
||||
wsHistoryActionEvent::wsHistoryActionEvent(nsISessionHistory *yourHistory)
|
||||
{
|
||||
mHistory = yourHistory;
|
||||
}
|
||||
|
||||
/*
|
||||
* wsResizeEvent
|
||||
*/
|
||||
|
||||
wsResizeEvent::wsResizeEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell),
|
||||
mLeft(x),
|
||||
mBottom(y),
|
||||
mWidth(w),
|
||||
mHeight(h)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsResizeEvent::handleEvent ()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(resize(x = %d y = %d w = %d h = %d))\n", mLeft, mBottom, mWidth, mHeight);
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NULL;
|
||||
}
|
||||
rv = baseWindow->SetPositionAndSize(mLeft, mBottom, mWidth, mHeight,
|
||||
PR_TRUE);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
return (void *) rv;
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsLoadURLEvent
|
||||
*/
|
||||
|
||||
wsLoadURLEvent::wsLoadURLEvent(nsIWebShell* webShell, PRUnichar * urlString) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell),
|
||||
mURL(nsnull)
|
||||
{
|
||||
mURL = new nsString(urlString);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsLoadURLEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell && mURL) {
|
||||
|
||||
printf("handleEvent(loadURL))\n");
|
||||
|
||||
nsresult rv = mWebShell->LoadURL(mURL->GetUnicode());
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
wsLoadURLEvent::~wsLoadURLEvent ()
|
||||
{
|
||||
if (mURL != nsnull)
|
||||
delete mURL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsStopEvent
|
||||
*/
|
||||
|
||||
wsStopEvent::wsStopEvent(nsIWebShell* webShell) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsStopEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(Stop))\n");
|
||||
|
||||
nsresult rv = mWebShell->Stop();
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsShowEvent
|
||||
*/
|
||||
|
||||
wsShowEvent::wsShowEvent(nsIWebShell* webShell) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsShowEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(Show))\n");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NULL;
|
||||
}
|
||||
baseWindow->SetVisibility(PR_TRUE);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsHideEvent
|
||||
*/
|
||||
|
||||
wsHideEvent::wsHideEvent(nsIWebShell* webShell) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsHideEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(Hide))\n");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NULL;
|
||||
}
|
||||
baseWindow->SetVisibility(PR_FALSE);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsMoveToEvent
|
||||
*/
|
||||
|
||||
wsMoveToEvent::wsMoveToEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell),
|
||||
mX(x),
|
||||
mY(y)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsMoveToEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(MoveTo(%ld, %ld))\n", mX, mY);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NULL;
|
||||
}
|
||||
rv = baseWindow->SetPosition(mX, mY);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
/*
|
||||
* wsSetFocusEvent
|
||||
*/
|
||||
|
||||
wsSetFocusEvent::wsSetFocusEvent(nsIWebShell* webShell) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsSetFocusEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(SetFocus())\n");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NULL;
|
||||
}
|
||||
rv = baseWindow->SetFocus();
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsRemoveFocusEvent
|
||||
*/
|
||||
|
||||
wsRemoveFocusEvent::wsRemoveFocusEvent(nsIWebShell* webShell) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsRemoveFocusEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(RemoveFocus())\n");
|
||||
|
||||
nsresult rv = mWebShell->RemoveFocus();
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsRepaintEvent
|
||||
*/
|
||||
|
||||
wsRepaintEvent::wsRepaintEvent(nsIWebShell* webShell, PRBool forceRepaint) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell),
|
||||
mForceRepaint(forceRepaint)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsRepaintEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(Repaint(%d))\n", mForceRepaint);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
|
||||
rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow),
|
||||
getter_AddRefs(baseWindow));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NULL;
|
||||
}
|
||||
rv = baseWindow->Repaint(mForceRepaint);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsCanBackEvent
|
||||
*/
|
||||
|
||||
wsCanBackEvent::wsCanBackEvent(nsISessionHistory* yourSessionHistory) :
|
||||
wsHistoryActionEvent(yourSessionHistory)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void *
|
||||
wsCanBackEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory) {
|
||||
nsresult rv;
|
||||
PRBool canGoBack;
|
||||
|
||||
printf("handleEvent(CanBack()): ");
|
||||
rv = mHistory->CanGoBack(&canGoBack);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (void *)canGoBack;
|
||||
|
||||
if (PR_TRUE == canGoBack) {
|
||||
printf("result: true\n");
|
||||
}
|
||||
else {
|
||||
printf("result: false\n");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
/*
|
||||
* wsCanForwardEvent
|
||||
*/
|
||||
|
||||
wsCanForwardEvent::wsCanForwardEvent(nsISessionHistory* yourSessionHistory) :
|
||||
wsHistoryActionEvent(yourSessionHistory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsCanForwardEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory) {
|
||||
nsresult rv;
|
||||
PRBool canGoForward;
|
||||
|
||||
printf("handleEvent(CanForward()): ");
|
||||
rv = mHistory->CanGoForward(&canGoForward);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (void *)canGoForward;
|
||||
|
||||
if (PR_TRUE == canGoForward) {
|
||||
printf("result: true\n");
|
||||
}
|
||||
else {
|
||||
printf("result: false\n");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsBackEvent
|
||||
*/
|
||||
|
||||
wsBackEvent::wsBackEvent(nsISessionHistory* yourSessionHistory,
|
||||
nsIWebShell *yourWebShell) :
|
||||
wsHistoryActionEvent(yourSessionHistory), mWebShell(yourWebShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsBackEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory && mWebShell) {
|
||||
printf("handleEvent(Back())\n");
|
||||
|
||||
nsresult rv = mHistory->GoBack(mWebShell);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
result = (void *) rv;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsForwardEvent
|
||||
*/
|
||||
|
||||
wsForwardEvent::wsForwardEvent(nsISessionHistory *yourSessionHistory,
|
||||
nsIWebShell* webShell) :
|
||||
wsHistoryActionEvent(yourSessionHistory),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsForwardEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory && mWebShell) {
|
||||
|
||||
printf("handleEvent(Forward())\n");
|
||||
|
||||
nsresult rv = mHistory->GoForward(mWebShell);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
result = (void *) rv;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsGoToEvent
|
||||
*/
|
||||
|
||||
wsGoToEvent::wsGoToEvent(nsISessionHistory *yourSessionHistory,
|
||||
nsIWebShell* webShell, PRInt32 historyIndex) :
|
||||
wsHistoryActionEvent(yourSessionHistory),
|
||||
mWebShell(webShell), mHistoryIndex(historyIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsGoToEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory && mWebShell) {
|
||||
|
||||
printf("handleEvent(GoTo(%ld))\n", mHistoryIndex);
|
||||
|
||||
nsresult rv = mHistory->Goto(mHistoryIndex, mWebShell, PR_TRUE);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
result = (void *) rv;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsGetHistoryLengthEvent
|
||||
*/
|
||||
|
||||
wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(nsISessionHistory* yourSessionHistory) :
|
||||
wsHistoryActionEvent(yourSessionHistory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsGetHistoryLengthEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory) {
|
||||
|
||||
printf("handleEvent(wsGetHistoryLengthEvent())\n");
|
||||
|
||||
PRInt32 historyLength = 0;
|
||||
|
||||
nsresult rv = mHistory->GetHistoryLength(&historyLength);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
result = (void *) historyLength;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsGetHistoryIndexEvent
|
||||
*/
|
||||
|
||||
wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(nsISessionHistory *yourSessionHistory) :
|
||||
wsHistoryActionEvent(yourSessionHistory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsGetHistoryIndexEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory) {
|
||||
|
||||
printf("handleEvent(wsGetHistoryIndexEvent())\n");
|
||||
|
||||
PRInt32 historyIndex = 0;
|
||||
|
||||
nsresult rv = mHistory->GetCurrentIndex(&historyIndex);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
result = (void *) historyIndex;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* wsGetURLEvent
|
||||
*/
|
||||
|
||||
wsGetURLEvent::wsGetURLEvent(nsISessionHistory* yourSessionHistory) :
|
||||
wsHistoryActionEvent(yourSessionHistory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsGetURLEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory) {
|
||||
|
||||
|
||||
PRInt32 currentIndex;
|
||||
char *currentURL = NULL;
|
||||
nsresult rv;
|
||||
|
||||
rv = mHistory->GetCurrentIndex(¤tIndex);
|
||||
printf("handleEvent(wsGetURLEvent(%ld))\n", currentIndex);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// THIS STRING NEEDS TO BE deleted!!!!!!
|
||||
rv = mHistory->GetURLForIndex(currentIndex, ¤tURL);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
printf("wsGetURLEvent: currentIndex: %ld, currentURL: %s\n",
|
||||
currentIndex, currentURL);
|
||||
|
||||
result = (void *) currentURL;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
/*
|
||||
* wsGetURLForIndexEvent
|
||||
*/
|
||||
|
||||
wsGetURLForIndexEvent::wsGetURLForIndexEvent(nsISessionHistory *yourSessionHistory,
|
||||
PRInt32 historyIndex) :
|
||||
wsHistoryActionEvent(yourSessionHistory),
|
||||
mHistoryIndex(historyIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsGetURLForIndexEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
if (mHistory) {
|
||||
nsresult rv;
|
||||
char *indexURL = NULL;
|
||||
|
||||
printf("handleEvent(GetURLForIndex(%ld))\n", mHistoryIndex);
|
||||
|
||||
rv = mHistory->GetURLForIndex(mHistoryIndex, &indexURL);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
printf("wsGetURLForIndexEvent: index: %ld, indexURL: %s\n",
|
||||
mHistoryIndex, indexURL);
|
||||
|
||||
result = (void *) indexURL;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
|
||||
|
||||
// Added by Mark Goddard OTMP 9/2/1999
|
||||
|
||||
/*
|
||||
* wsRefreshEvent
|
||||
*/
|
||||
|
||||
wsRefreshEvent::wsRefreshEvent(nsIWebShell* webShell, long yourLoadFlags) :
|
||||
nsActionEvent(),
|
||||
mWebShell(webShell)
|
||||
{
|
||||
loadFlags = (nsLoadFlags) yourLoadFlags;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
wsRefreshEvent::handleEvent ()
|
||||
{
|
||||
if (mWebShell) {
|
||||
|
||||
printf("handleEvent(Refresh())\n");
|
||||
|
||||
nsresult rv = mWebShell->Reload(loadFlags);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
return (void *) rv;
|
||||
}
|
||||
return NULL;
|
||||
} // handleEvent()
|
||||
|
||||
wsAddDocLoaderObserverEvent::wsAddDocLoaderObserverEvent(nsIDocShell* yourDocShell,
|
||||
nsIDocumentLoaderObserver *yourObserver) :
|
||||
nsActionEvent(),
|
||||
mDocShell(yourDocShell), mDocObserver(yourObserver)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
wsAddDocLoaderObserverEvent::handleEvent ()
|
||||
{
|
||||
void *result = NULL;
|
||||
|
||||
if (mDocShell && mDocObserver) {
|
||||
printf("handleEvent(AddDocLoaderObserver())\n");
|
||||
|
||||
nsresult rv = mDocShell->SetDocLoaderObserver(mDocObserver);
|
||||
|
||||
printf("result = %lx\n", rv);
|
||||
|
||||
result = (void *) rv;
|
||||
}
|
||||
return result;
|
||||
} // handleEvent()
|
||||
|
||||
// EOF
|
||||
|
|
@ -0,0 +1,323 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Kirk Baker <kbaker@eb.com>
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* nsActions.h
|
||||
*/
|
||||
|
||||
#ifndef nsActions_h___
|
||||
#define nsActions_h___
|
||||
|
||||
#ifndef XP_UNIX
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsISessionHistory.h"
|
||||
#include "nsString.h"
|
||||
#include "plevent.h"
|
||||
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
|
||||
/**
|
||||
|
||||
* Concrete subclasses of nsActionEvent are used to safely convey an
|
||||
* action from Java to mozilla.
|
||||
|
||||
* This class is kind of like a subclass of the C based PLEvent struct,
|
||||
* defined in
|
||||
* <http://lxr.mozilla.org/mozilla/source/xpcom/threads/plevent.h#455>.
|
||||
|
||||
* Lifecycle
|
||||
|
||||
* nsActionEvent subclass instances are usually created in a JNI method
|
||||
* implementation, such as
|
||||
* Java_org_mozilla*NavigationImpl_nativeLoadURL(). In nativeLoadURL(),
|
||||
* we create an instance of wsLoadURLEvent, which is a subclass of
|
||||
* nsActionEvent, passing in the nsIWebShell instance, and the url
|
||||
* string. The arguments to the nsActionEvent constructor vary from one
|
||||
* subclass to the next, but they all have the property that they
|
||||
* provide information used in the subclass's handleEvent()
|
||||
* method.
|
||||
|
||||
* The nsActionEvent subclass is then cast to a PLEvent struct, and
|
||||
* passed into either util_PostEvent() or util_PostSynchronous event,
|
||||
* declared in jni_util.h. See the comments for those functions for
|
||||
* information on how they deal with the nsActionEvent, cast as a
|
||||
* PLEvent.
|
||||
|
||||
* During event processing in util_Post*Event, the subclass's
|
||||
* handleEvent() method is called. This is where the appropriate action
|
||||
* for that subclass takes place. For example for wsLoadURLEvent,
|
||||
* handleEvent calls nsIWebShell::LoadURL().
|
||||
|
||||
* The life of an nsActionEvent subclass ends shortly after the
|
||||
* handleEvent() method is called. This happens when mozilla calls
|
||||
* nsActionEvent::destroyEvent(), which simply deletes the instance.
|
||||
|
||||
*/
|
||||
|
||||
class nsActionEvent {
|
||||
public:
|
||||
nsActionEvent ();
|
||||
virtual ~nsActionEvent () {};
|
||||
virtual void * handleEvent (void) = 0; //{ return NULL;};
|
||||
void destroyEvent (void) { delete this; };
|
||||
operator PLEvent* () { return &mEvent; };
|
||||
|
||||
protected:
|
||||
PLEvent mEvent;
|
||||
};
|
||||
|
||||
class wsHistoryActionEvent : public nsActionEvent {
|
||||
public:
|
||||
wsHistoryActionEvent(nsISessionHistory *yourHistory);
|
||||
virtual ~wsHistoryActionEvent() {};
|
||||
|
||||
protected:
|
||||
nsISessionHistory *mHistory;
|
||||
};
|
||||
|
||||
class wsResizeEvent : public nsActionEvent {
|
||||
public:
|
||||
wsResizeEvent (nsIWebShell* webShell, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
PRInt32 mLeft;
|
||||
PRInt32 mBottom;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
};
|
||||
|
||||
|
||||
class wsLoadURLEvent : public nsActionEvent {
|
||||
public:
|
||||
wsLoadURLEvent (nsIWebShell* webShell, PRUnichar * urlString);
|
||||
~wsLoadURLEvent ();
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
nsString * mURL;
|
||||
};
|
||||
|
||||
|
||||
class wsStopEvent : public nsActionEvent {
|
||||
public:
|
||||
wsStopEvent (nsIWebShell* webShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsShowEvent : public nsActionEvent {
|
||||
public:
|
||||
wsShowEvent (nsIWebShell* webShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsHideEvent : public nsActionEvent {
|
||||
public:
|
||||
wsHideEvent (nsIWebShell* webShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsMoveToEvent : public nsActionEvent {
|
||||
public:
|
||||
wsMoveToEvent (nsIWebShell* webShell, PRInt32 x, PRInt32 y);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
PRInt32 mX;
|
||||
PRInt32 mY;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsSetFocusEvent : public nsActionEvent {
|
||||
public:
|
||||
wsSetFocusEvent(nsIWebShell* webShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsRemoveFocusEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRemoveFocusEvent(nsIWebShell* webShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsRepaintEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRepaintEvent (nsIWebShell* webShell, PRBool forceRepaint);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
PRBool mForceRepaint;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsCanBackEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsCanBackEvent (nsISessionHistory* yourSessionHistory);
|
||||
void * handleEvent (void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsCanForwardEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsCanForwardEvent(nsISessionHistory* yourSessionHistory);
|
||||
void * handleEvent (void);
|
||||
};
|
||||
|
||||
|
||||
class wsBackEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsBackEvent (nsISessionHistory* yourSessionHistory,
|
||||
nsIWebShell *yourWebShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell *mWebShell;
|
||||
};
|
||||
|
||||
|
||||
class wsForwardEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsForwardEvent (nsISessionHistory* yourSessionHistory,
|
||||
nsIWebShell *yourWebShell);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell *mWebShell;
|
||||
};
|
||||
|
||||
|
||||
class wsGoToEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsGoToEvent (nsISessionHistory *yourSessionHistory,
|
||||
nsIWebShell* webShell,
|
||||
PRInt32 historyIndex);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
PRInt32 mHistoryIndex;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsGetHistoryLengthEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsGetHistoryLengthEvent(nsISessionHistory* yourSessionHistory);
|
||||
void * handleEvent (void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsGetHistoryIndexEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsGetHistoryIndexEvent (nsISessionHistory *yourSessionHistory);
|
||||
void * handleEvent (void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wsGetURLEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsGetURLEvent (nsISessionHistory* yourSessionHistory);
|
||||
void * handleEvent (void);
|
||||
};
|
||||
|
||||
class wsGetURLForIndexEvent : public wsHistoryActionEvent {
|
||||
public:
|
||||
wsGetURLForIndexEvent(nsISessionHistory *yourSessionHistory,
|
||||
PRInt32 historyIndex);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
PRInt32 mHistoryIndex;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// added by Mark Goddard OTMP 9/2/1999
|
||||
class wsRefreshEvent : public nsActionEvent {
|
||||
public:
|
||||
wsRefreshEvent (nsIWebShell* webShell,
|
||||
long yourLoadFlags);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIWebShell * mWebShell;
|
||||
nsLoadFlags loadFlags;
|
||||
};
|
||||
|
||||
class wsAddDocLoaderObserverEvent : public nsActionEvent {
|
||||
public:
|
||||
wsAddDocLoaderObserverEvent(nsIDocShell *yourDocShell,
|
||||
nsIDocumentLoaderObserver *yourObserver);
|
||||
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
nsIDocShell *mDocShell;
|
||||
nsIDocumentLoaderObserver *mDocObserver;
|
||||
};
|
||||
|
||||
#endif /* nsActions_h___ */
|
||||
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,510 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "rdf_util.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
static PRBool rdf_inited = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIRDFContainerUtils> gRDFCU = NULL;
|
||||
nsCOMPtr<nsIRDFService> gRDF = NULL;
|
||||
nsCOMPtr<nsIBookmarksService> gBookmarks = NULL;
|
||||
nsCOMPtr<nsIRDFDataSource> gBookmarksDataSource = NULL;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> kNC_BookmarksRoot = NULL;
|
||||
nsCOMPtr<nsIRDFResource> kNC_Name = NULL;
|
||||
nsCOMPtr<nsIRDFResource> kNC_URL = NULL;
|
||||
nsCOMPtr<nsIRDFResource> kNC_Folder = NULL;
|
||||
nsCOMPtr<nsIRDFResource> kRDF_type = NULL;
|
||||
|
||||
nsresult rdf_InitRDFUtils()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (rdf_inited) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Init the global instances
|
||||
|
||||
if (NULL == gBookmarks) {
|
||||
// Get the bookmarks service
|
||||
rv = nsServiceManager::GetService(NS_IBOOKMARKSSERVICE_PROGID,
|
||||
NS_GET_IID(nsIBookmarksService),
|
||||
getter_AddRefs(gBookmarks));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == gBookmarksDataSource) {
|
||||
// get the bookmarks service as an RDFDataSource
|
||||
rv = gBookmarks->QueryInterface(NS_GET_IID(nsIRDFDataSource),
|
||||
getter_AddRefs(gBookmarksDataSource));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == gRDF) {
|
||||
// get the RDF service
|
||||
rv = nsServiceManager::GetService(NS_IRDFSERVICE_PROGID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
getter_AddRefs(gRDF));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == gRDFCU) {
|
||||
// get the RDF service
|
||||
rv = nsServiceManager::GetService(NS_ICONTAINERUTILS_PROGID,
|
||||
NS_GET_IID(nsIRDFContainerUtils),
|
||||
getter_AddRefs(gRDFCU));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// init the properties
|
||||
// find the nsIRDFResource for the bookmarks
|
||||
if (NULL == kNC_BookmarksRoot) {
|
||||
rv = gRDF->GetResource(BOOKMARKS_URI,
|
||||
getter_AddRefs(kNC_BookmarksRoot));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == kNC_Name) {
|
||||
rv = gRDF->GetResource("http://home.netscape.com/NC-rdf#Name",
|
||||
getter_AddRefs(kNC_Name));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == kNC_URL) {
|
||||
rv = gRDF->GetResource("http://home.netscape.com/NC-rdf#URL",
|
||||
getter_AddRefs(kNC_URL));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == kNC_Folder) {
|
||||
rv = gRDF->GetResource("http://home.netscape.com/NC-rdf#Folder",
|
||||
getter_AddRefs(kNC_Folder));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == kRDF_type) {
|
||||
rv = gRDF->GetResource("http://home.netscape.com/NC-rdf#type",
|
||||
getter_AddRefs(kRDF_type));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rdf_inited = PR_TRUE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool result;
|
||||
const PRUnichar *textForNode = NULL;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
nsCOMPtr<nsIRDFResource> childResource;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsISimpleEnumerator> elements;
|
||||
|
||||
// ASSERT(NULL != gRDFCU)
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, currentResource,
|
||||
&result);
|
||||
|
||||
if (result) {
|
||||
// It's a folder
|
||||
|
||||
printf("FOLDER:\n");
|
||||
rdf_printArcLabels(currentResource);
|
||||
|
||||
// see if it has a name target
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_Name, true,
|
||||
getter_AddRefs(node));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// 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);
|
||||
printf("folder: %S\n", textForNode);
|
||||
}
|
||||
else {
|
||||
printf("recursiveResourceTraversal: node is not an nsIRDFLiteral.\n");
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
printf("recursiveResourceTraversal: can't get name from currentResource.\n");
|
||||
}
|
||||
|
||||
// get a container in order to recurr
|
||||
rv = nsComponentManager::CreateInstance(NS_IRDFCONTAINER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: can't get a new container\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, currentResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: can't init container\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// go over my children
|
||||
rv = container->GetElements(getter_AddRefs(elements));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: can't get elements from folder\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = elements->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: folder %s has no children.\n",
|
||||
textForNode);
|
||||
return;
|
||||
}
|
||||
while (result) {
|
||||
rv = elements->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Exception: Can't get next from enumerator.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure it's an RDFResource
|
||||
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(childResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Exception: next from enumerator is not an nsIRDFResource.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rdf_recursiveResourceTraversal(childResource);
|
||||
|
||||
rv = elements->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Exception: can't tell if we have more elements.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It's a bookmark
|
||||
printf("BOOKMARK:\n");
|
||||
rdf_printArcLabels(currentResource);
|
||||
|
||||
// see if it has a URL target
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_URL, true,
|
||||
getter_AddRefs(node));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: can't get url from currentResource\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// if so, make sure it's an nsIRDFLiteral
|
||||
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
|
||||
getter_AddRefs(literal));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: node is not an nsIRDFLiteral.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// get the value of the literal
|
||||
rv = literal->GetValueConst(&textForNode);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("recursiveResourceTraversal: node doesn't have a value.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\turl: %S\n", textForNode);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rdf_printArcLabels(nsCOMPtr<nsIRDFResource> currentResource)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> labels;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsCOMPtr<nsIRDFResource> resourceResult;
|
||||
nsresult rv;
|
||||
PRBool result;
|
||||
const char *arcLabel;
|
||||
const char *currentResourceValue;
|
||||
|
||||
rv = currentResource->GetValueConst(¤tResourceValue);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
printf("resource: %s\n", currentResourceValue);
|
||||
}
|
||||
else {
|
||||
printf("printArcLabels: can't get value from current resource.\n");
|
||||
}
|
||||
|
||||
rv = gBookmarksDataSource->ArcLabelsOut(currentResource,
|
||||
getter_AddRefs(labels));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("printArcLabels: currentResource has no outgoing arcs.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = labels->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("printArcLabels: can't get elements from currentResource's enum.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while (result) {
|
||||
rv = labels->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("printArcLabels: Can't get next arc from enumerator.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure it's an RDFResource
|
||||
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(resourceResult));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = resourceResult->GetValueConst(&arcLabel);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
printf("\tarc label: %s\n", arcLabel);
|
||||
}
|
||||
else {
|
||||
printf("printArcLabels: can't get value from current arc.\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("printArcLabels: next arc from enumerator is not an nsIRDFResource.\n");
|
||||
}
|
||||
rv = labels->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("printArcLabels: can't get elements from currentResource's enum.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rdf_getChildAt(int index, nsIRDFResource *theParent,
|
||||
nsIRDFResource **retval)
|
||||
{
|
||||
// Since there's no getChildAt type thing in RDF, we just get an
|
||||
// enumeration and get the indexth child.
|
||||
nsCOMPtr<nsIRDFResource> parent = theParent;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsISimpleEnumerator> elements;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsCOMPtr<nsIRDFResource> childResource;
|
||||
nsresult rv;
|
||||
PRBool result, hasChildAtIndex = PR_FALSE;
|
||||
*retval = NULL;
|
||||
PRInt32 i = 0;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
|
||||
&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (PR_FALSE == result) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = nsComponentManager::CreateInstance(NS_IRDFCONTAINER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(elements));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = elements->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
while (result) {
|
||||
rv = elements->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (index == i) {
|
||||
hasChildAtIndex = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
rv = elements->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
if (hasChildAtIndex) {
|
||||
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFResource),
|
||||
getter_AddRefs(childResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
*retval = childResource;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rdf_getChildCount(nsIRDFResource *theParent, PRInt32 *count)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> parent = theParent;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
PRBool result;
|
||||
*count = 0;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
|
||||
&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (PR_FALSE == result) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = nsComponentManager::CreateInstance(NS_IRDFCONTAINER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
rv = container->GetCount(count);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rdf_getIndexOfChild(nsIRDFResource *theParent,
|
||||
nsIRDFResource *theChild,
|
||||
PRInt32 *index)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> parent = theParent;
|
||||
nsCOMPtr<nsIRDFResource> child = theChild;
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsCOMPtr<nsISimpleEnumerator> elements;
|
||||
nsCOMPtr<nsISupports> supportsResult;
|
||||
nsresult rv;
|
||||
PRBool result;
|
||||
*index = -1;
|
||||
PRInt32 i = 0;
|
||||
|
||||
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
|
||||
&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (PR_FALSE == result) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = nsComponentManager::CreateInstance(NS_IRDFCONTAINER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = container->Init(gBookmarksDataSource, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(elements));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = elements->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
while (result) {
|
||||
rv = elements->GetNext(getter_AddRefs(supportsResult));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (supportsResult == child) {
|
||||
*index = i;
|
||||
rv = NS_OK;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
rv = elements->HasMoreElements(&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#ifndef rdf_util_h
|
||||
#define rdf_util_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsIBookmarksService.h"
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* This file contains references to global RDF resources
|
||||
|
||||
*/
|
||||
|
||||
static const char *NS_IRDFSERVICE_PROGID = "component://netscape/rdf/rdf-service";
|
||||
static const char *NS_ICONTAINERUTILS_PROGID = "component://netscape/rdf/container-utils";
|
||||
static const char *NS_IBOOKMARKSSERVICE_PROGID = "component://netscape/browser/bookmarks-service";
|
||||
static const char *NS_IRDFCONTAINER_PROGID = "component://netscape/rdf/container";
|
||||
static const char *BOOKMARKS_URI = "NC:BookmarksRoot";
|
||||
extern nsCOMPtr<nsIRDFContainerUtils> gRDFCU;
|
||||
extern nsCOMPtr<nsIRDFService> gRDF;
|
||||
extern nsCOMPtr<nsIBookmarksService> gBookmarks;
|
||||
extern nsCOMPtr<nsIRDFDataSource> gBookmarksDataSource;
|
||||
|
||||
extern nsCOMPtr<nsIRDFResource> kNC_BookmarksRoot;
|
||||
extern nsCOMPtr<nsIRDFResource> kNC_Name;
|
||||
extern nsCOMPtr<nsIRDFResource> kNC_URL;
|
||||
extern nsCOMPtr<nsIRDFResource> kNC_Folder;
|
||||
extern nsCOMPtr<nsIRDFResource> kRDF_type;
|
||||
|
||||
nsresult rdf_InitRDFUtils();
|
||||
void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource);
|
||||
void rdf_printArcLabels(nsCOMPtr<nsIRDFResource> currentResource);
|
||||
|
||||
nsresult rdf_getChildAt(int index, nsIRDFResource *parent,
|
||||
nsIRDFResource **_retval);
|
||||
nsresult rdf_getChildCount(nsIRDFResource *parent, PRInt32 *count);
|
||||
nsresult rdf_getIndexOfChild(nsIRDFResource *parent,
|
||||
nsIRDFResource *child,
|
||||
PRInt32 *index);
|
||||
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче