account for nsIDocumentLoaderObserver API changes.

This commit is contained in:
edburns%acm.org 2000-01-05 20:25:29 +00:00
Родитель 272a6b85db
Коммит 234aee233c
2 изменённых файлов: 0 добавлений и 260 удалений

Просмотреть файл

@ -1,156 +0,0 @@
#include "nsString.h"
#include "DocumentObserver.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsISupportsUtils.h"
#include<stdio.h>
#include "jni_util.h"
#include <jni.h>
void fireDocumentLoadEvent(char *);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_IID);
NS_IMPL_ADDREF(DocumentObserver);
NS_IMPL_RELEASE(DocumentObserver);
jobject peer;
JavaVM *vm = NULL;
DocumentObserver::DocumentObserver(){
}
DocumentObserver::DocumentObserver(JNIEnv *env, jobject obj,
jint webShellPtr,
jobject doclistener) {
env->GetJavaVM(&vm); // save this vm reference away for the callback!
peer = env->NewGlobalRef(doclistener);
}
NS_IMETHODIMP DocumentObserver::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 DocumentObserver::OnStartDocumentLoad(nsIDocumentLoader* loader,
nsIURI* aURL,
const char* aCommand)
{
printf("DocumentObserver.cpp: OnStartDocumentLoad\n");
fireDocumentLoadEvent("startdocumentload");
return NS_OK;
}
NS_IMETHODIMP DocumentObserver::OnEndDocumentLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus,
#else
nsIURI* aURL,
PRInt32 aStatus,
#endif
nsIDocumentLoaderObserver* aObserver) {
printf("!!DocumentObserver.cpp: OnEndDocumentLoad\n");
fireDocumentLoadEvent("enddocumentload");
return NS_OK;
}
void fireDocumentLoadEvent(char *eventname) {
JNIEnv *env = (JNIEnv *) JNU_GetEnv(vm, JNI_VERSION_1_2);
if (env == NULL) {
return;
}
jclass clazz = env->GetObjectClass(peer);
jmethodID mid = env->GetMethodID(clazz, "docEventPerformed", "(Ljava/lang/String;)V");
jstring testmsg = env->NewStringUTF(eventname);
if ( mid != NULL) {
env->CallVoidMethod(peer, mid, testmsg);
} else {
printf("cannot call the Java Method!\n");
}
}
NS_IMETHODIMP DocumentObserver::OnStartURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
const char* aContentType,
#endif
nsIContentViewer* aViewer) {
printf("!DocumentObserver: OnStartURLLoad\n");
fireDocumentLoadEvent("startURLload");
return NS_OK;}
NS_IMETHODIMP DocumentObserver::OnProgressURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
#endif
PRUint32 aProgress,
PRUint32 aProgressMax) {
printf("!DocumentObserver: OnProgressURLLoad\n");
fireDocumentLoadEvent("progressURLload");
return NS_OK;}
NS_IMETHODIMP DocumentObserver::OnStatusURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
#endif
nsString& aMsg) {
printf("!DocumentObserver: OnStatusURLLoad\n");
fireDocumentLoadEvent("statusURLload");
return NS_OK;}
NS_IMETHODIMP DocumentObserver::OnEndURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus) {
printf("!DocumentObserver: OnEndURLLoad\n");
fireDocumentLoadEvent("onendURLload");
return NS_OK;}
#else
nsIURI* aURL,
PRInt32 aStatus) {return NS_OK;}
#endif
NS_IMETHODIMP DocumentObserver::HandleUnknownContentType(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
#endif
const char *aContentType,
const char *aCommand) {
printf("!DocumentObserver: HandleUnknownContentType\n");
fireDocumentLoadEvent("handleunknown content");
return NS_OK;}

Просмотреть файл

@ -1,104 +0,0 @@
/*
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):
*/
#include "nsISupports.h"
#include "nsISupportsUtils.h"
#include "nsString.h"
#include "nsIDocumentLoaderObserver.h"
#include "jni.h"
class nsIURI;
class DocumentObserver : public nsIDocumentLoaderObserver {
NS_DECL_ISUPPORTS
public:
DocumentObserver::DocumentObserver(JNIEnv *env, jobject obj,
jint webShellPtr,
jobject doclistener);
DocumentObserver::DocumentObserver();
/* nsIDocumentLoaderObserver methods */
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
nsIURI* aURL,
const char* aCommand);
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus,
#else
nsIURI* aURL,
PRInt32 aStatus,
#endif
nsIDocumentLoaderObserver* aObserver);
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
const char* aContentType,
#endif
nsIContentViewer* aViewer);
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
#endif
PRUint32 aProgress,
PRUint32 aProgressMax);
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
#endif
nsString& aMsg);
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus);
#else
nsIURI* aURL,
PRInt32 aStatus);
#endif
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
#else
nsIURI* aURL,
#endif
const char *aContentType,
const char *aCommand);
};