From 6bd98defd08449a933cf4ecfe0ae82ce39d719de Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Wed, 5 Apr 2000 21:38:27 +0000 Subject: [PATCH] bug: http://bugzilla.mozilla.org/show_bug.cgi?id=34665 This change replaces all printfs in src_moz with calls to PR_LOG. No printfs should appear in src_moz anymore. You won't see any console output from native code unless you define NSPR_LOG_MODULES=webclient:3 in your environment. Furthermore, if you want PR_LOG statements in webclient to go to a file instead, define WEBCLIENT_LOG_FILE=C:\VALIDDIR\filename.txt in your environment. This file will get created fresh each time, since PR_LOG uses fopen(filename, "w"). New Files: I've created ns_globals.h, included from jni_util.h. ns_globals.h holds an extern * to a struct used in the PR_LOG calls. Significant changes: WrapperFactoryImpl.cpp nativeAppInitialize(){ Added: #if DEBUG_RAPTOR_CANVAS prLogModuleInfo = PR_NewLogModule("webclient"); const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE"); if (nsnull != webclientLogFile) { PR_SetLogFile(webclientLogFile); // If this fails, it just goes to stdout/stderr } #endif } All the other files in this checkin follow the this pattern: Before checkin: printf("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", initContext); After checkin: if (prLogModuleInfo) { PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", initContext)); } See http://lxr.mozilla.org/mozilla/source/nsprpub/pr/include/prlog.h#190 for the definition of PR_LOG git-svn-id: svn://10.0.0.236/trunk@65380 18797224-902f-48f8-a5cc-f745e15eee43 --- .../java/webclient/src_moz/BookmarksImpl.cpp | 1 - .../src_moz/DocumentLoaderObserverImpl.cpp | 49 ++++++-- .../java/webclient/src_moz/HistoryImpl.cpp | 17 --- .../webclient/src_moz/NativeEventThread.cpp | 48 +++++-- .../java/webclient/src_moz/NavigationImpl.cpp | 9 +- .../java/webclient/src_moz/RDFEnumeration.cpp | 40 ++++-- .../java/webclient/src_moz/RDFTreeNode.cpp | 20 ++- .../webclient/src_moz/WrapperFactoryImpl.cpp | 11 ++ mozilla/java/webclient/src_moz/jni_util.cpp | 33 +++-- mozilla/java/webclient/src_moz/jni_util.h | 4 +- .../webclient/src_moz/jni_util_export.cpp | 12 +- mozilla/java/webclient/src_moz/nsActions.cpp | 104 --------------- mozilla/java/webclient/src_moz/ns_globals.h | 37 ++++++ mozilla/java/webclient/src_moz/rdf_util.cpp | 119 ++++++++++++++---- 14 files changed, 311 insertions(+), 193 deletions(-) create mode 100644 mozilla/java/webclient/src_moz/ns_globals.h diff --git a/mozilla/java/webclient/src_moz/BookmarksImpl.cpp b/mozilla/java/webclient/src_moz/BookmarksImpl.cpp index 5fd9810fc77..d5d3014f31f 100644 --- a/mozilla/java/webclient/src_moz/BookmarksImpl.cpp +++ b/mozilla/java/webclient/src_moz/BookmarksImpl.cpp @@ -64,7 +64,6 @@ Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode const char *url = ::util_GetStringUTFChars(env, urlString); uri.Append("#$"); uri.Append(url); - printf("debug: edburns: nativeNewRDFNode: url: %s\n", url); rv = gRDF->GetUnicodeResource(uri.GetUnicode(), getter_AddRefs(newNode)); ::util_ReleaseStringUTFChars(env, urlString, url); diff --git a/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp b/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp index b4e6e434f9c..69b2935065a 100644 --- a/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp +++ b/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp @@ -147,7 +147,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartDocumentLoad(nsIDocumentLoader* nsIURI* aURL, const char* aCommand) { - printf("DocumentLoaderObserverImpl.cpp: OnStartDocumentLoad\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("DocumentLoaderObserverImpl.cpp: OnStartDocumentLoad\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, maskValues[START_DOCUMENT_LOAD_EVENT_MASK]); @@ -159,7 +164,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndDocumentLoad(nsIDocumentLoader* l nsIChannel* channel, nsresult aStatus) { - printf("!!DocumentLoaderObserverImpl.cpp: OnEndDocumentLoad\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("!!DocumentLoaderObserverImpl.cpp: OnEndDocumentLoad\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, @@ -170,7 +180,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndDocumentLoad(nsIDocumentLoader* l NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel) { - printf("!DocumentLoaderObserverImpl: OnStartURLLoad\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("!DocumentLoaderObserverImpl: OnStartURLLoad\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, maskValues[START_URL_LOAD_EVENT_MASK]); @@ -182,7 +197,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnProgressURLLoad(nsIDocumentLoader* l PRUint32 aProgress, PRUint32 aProgressMax) { - printf("!DocumentLoaderObserverImpl: OnProgressURLLoad\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("!DocumentLoaderObserverImpl: OnProgressURLLoad\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, maskValues[PROGRESS_URL_LOAD_EVENT_MASK]); @@ -194,7 +214,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnStatusURLLoad(nsIDocumentLoader* loa nsIChannel* channel, nsString& aMsg) { - printf("!DocumentLoaderObserverImpl: OnStatusURLLoad\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("!DocumentLoaderObserverImpl: OnStatusURLLoad\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, maskValues[STATUS_URL_LOAD_EVENT_MASK]); @@ -206,7 +231,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndURLLoad(nsIDocumentLoader* loader nsIChannel* channel, nsresult aStatus) { - printf("!DocumentLoaderObserverImpl: OnEndURLLoad\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("!DocumentLoaderObserverImpl: OnEndURLLoad\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, maskValues[END_URL_LOAD_EVENT_MASK]); @@ -218,7 +248,12 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::HandleUnknownContentType(nsIDocumentLo const char *aContentType, const char *aCommand) { - printf("!DocumentLoaderObserverImpl: HandleUnknownContentType\n"); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("!DocumentLoaderObserverImpl: HandleUnknownContentType\n")); + } +#endif util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, maskValues[UNKNOWN_CONTENT_EVENT_MASK]); diff --git a/mozilla/java/webclient/src_moz/HistoryImpl.cpp b/mozilla/java/webclient/src_moz/HistoryImpl.cpp index e8f26f1e81d..bd30cd7d855 100644 --- a/mozilla/java/webclient/src_moz/HistoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/HistoryImpl.cpp @@ -50,23 +50,6 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack 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 = nsnull; - - if (nsnull != (currentThreadName = util_GetCurrentThreadName(env))) { - printf("debug: edburns: HistoryImpl_nativeBack() java threadName: %s\n", - currentThreadName); - delete currentThreadName; - } - - - ::util_PostSynchronousEvent(initContext, event); } diff --git a/mozilla/java/webclient/src_moz/NativeEventThread.cpp b/mozilla/java/webclient/src_moz/NativeEventThread.cpp index b1b7cc4833a..56b64db60bf 100644 --- a/mozilla/java/webclient/src_moz/NativeEventThread.cpp +++ b/mozilla/java/webclient/src_moz/NativeEventThread.cpp @@ -313,12 +313,17 @@ static void event_processor_callback(gpointer data, gint source, GdkInputCondition condition) { #if DEBUG_RAPTOR_CANVAS - printf("EventHandler: event_processor_callback()\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + "EventHandler: event_processor_callback()\n"); + } #endif nsIEventQueue *eventQueue = (nsIEventQueue*)data; eventQueue->ProcessPendingEvents(); #if DEBUG_RAPTOR_CANVAS - printf("EventHandler: Done processing pending events\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, "EventHandler: Done processing pending events\n"); + } #endif } #endif @@ -333,7 +338,11 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) //TODO Add tracing from nspr. #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", + initContext)); + } #endif // Create the Event Queue for the UI thread... @@ -355,11 +364,15 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) if (initContext->embeddedThread) { #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): embeddedThread != nsnull\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): embeddedThread != nsnull\n", initContext)); + } #endif if (initContext->actionQueue == nsnull) { #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): Create the action queue\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): Create the action queue\n", initContext)); + } #endif // We need to do something different for Unix nsIEventQueue * EQueue = nsnull; @@ -390,7 +403,10 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) } #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): Create the WebShell...\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): Create the WebShell...\n", initContext)); + } #endif // Create the WebShell. rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, getter_AddRefs(initContext->webShell)); @@ -400,7 +416,10 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) } #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): Init the WebShell...\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): Init the WebShell...\n", initContext)); + } #endif #ifdef XP_UNIX @@ -420,7 +439,10 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) } #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): Install Prefs in the Webshell...\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): Install Prefs in the Webshell...\n", initContext)); + } #endif nsIPref *prefs; @@ -451,7 +473,10 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) initContext->sessionHistory = gHistory; #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): Show the WebShell...\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): Show the WebShell...\n", initContext)); + } #endif nsCOMPtr baseWindow; @@ -482,7 +507,10 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) initContext->initComplete = TRUE; #if DEBUG_RAPTOR_CANVAS - printf("InitMozillaStuff(%lx): enter event loop\n", initContext); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): enter event loop\n", initContext)); + } #endif // Just need to loop once to clear out events before returning diff --git a/mozilla/java/webclient/src_moz/NavigationImpl.cpp b/mozilla/java/webclient/src_moz/NavigationImpl.cpp index a82429d60c5..4d6c754ea0a 100644 --- a/mozilla/java/webclient/src_moz/NavigationImpl.cpp +++ b/mozilla/java/webclient/src_moz/NavigationImpl.cpp @@ -35,11 +35,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl (JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString) { jobject jobj = obj; + +#if DEBUG_RAPTOR_CANVAS const char * urlChars = (char *) ::util_GetStringUTFChars(env, urlString); - - printf("Native URL = \"%s\"\n", urlChars); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("Native URL = \"%s\"\n", urlChars)); + } ::util_ReleaseStringUTFChars(env, urlString, urlChars); +#endif PRUnichar * urlStringChars = (PRUnichar *) ::util_GetStringChars(env, urlString); diff --git a/mozilla/java/webclient/src_moz/RDFEnumeration.cpp b/mozilla/java/webclient/src_moz/RDFEnumeration.cpp index b46c5c3a736..604a17f0fe6 100644 --- a/mozilla/java/webclient/src_moz/RDFEnumeration.cpp +++ b/mozilla/java/webclient/src_moz/RDFEnumeration.cpp @@ -100,7 +100,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement rv = enumerator->GetNext(getter_AddRefs(supportsResult)); if (NS_FAILED(rv)) { - printf("Exception: nativeNextElement: Can't get next from enumerator.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("Exception: nativeNextElement: Can't get next from enumerator.\n")); + } return result; } @@ -108,7 +111,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeNextElement 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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("Exception: nativeNextElement: next from enumerator is not an nsIRDFNode.\n")); + } return result; } @@ -126,7 +132,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize // release the nsISimpleEnumerator if (-1 == (nativeEnum = ::util_GetIntValueFromInstance(env, obj, "nativeEnum"))) { - printf("nativeFinalize: Can't get fieldID for nativeEnum.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("nativeFinalize: Can't get fieldID for nativeEnum.\n")); + } return; } nsCOMPtr enumerator = @@ -136,7 +145,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFEnumeration_nativeFinalize // release the nsIRDFContainer if (-1 == (nativeContainer = ::util_GetIntValueFromInstance(env, obj, "nativeContainer"))) { - printf("nativeFinalize: Can't get fieldID for nativeContainerFieldID.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("nativeFinalize: Can't get fieldID for nativeContainerFieldID.\n")); + } return; } nsCOMPtr container = @@ -174,7 +186,10 @@ jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode) rv = node->QueryInterface(NS_GET_IID(nsIRDFResource), getter_AddRefs(nodeResource)); if (NS_FAILED(rv)) { - printf("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n")); + } return -1; } @@ -184,19 +199,28 @@ jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode) NS_GET_IID(nsIRDFContainer), getter_AddRefs(container)); if (NS_FAILED(rv)) { - printf("recursiveResourceTraversal: can't get a new container\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("recursiveResourceTraversal: can't get a new container\n")); + } return -1; } rv = container->Init(gBookmarksDataSource, nodeResource); if (NS_FAILED(rv)) { - printf("getNativeEnumFromJava: Can't Init container.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("getNativeEnumFromJava: Can't get enumeration from container.\n")); + } return -1; } diff --git a/mozilla/java/webclient/src_moz/RDFTreeNode.cpp b/mozilla/java/webclient/src_moz/RDFTreeNode.cpp index 55856eb38fd..cfbc7c3cae9 100644 --- a/mozilla/java/webclient/src_moz/RDFTreeNode.cpp +++ b/mozilla/java/webclient/src_moz/RDFTreeNode.cpp @@ -174,7 +174,10 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString rv = literal->GetValueConst(&textForNode); } else { - printf("nativeToString: node is not an nsIRDFLiteral.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("nativeToString: node is not an nsIRDFLiteral.\n")); + } } } } @@ -197,17 +200,26 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString // get the value of the literal rv = literal->GetValueConst(&textForNode); if (NS_FAILED(rv)) { - printf("nativeToString: node doesn't have a value.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("nativeToString: node doesn't have a value.\n")); + } } } else { rdf_printArcLabels(currentResource); - printf("nativeToString: node is not an nsIRDFLiteral.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("nativeToString: node is not an nsIRDFLiteral.\n")); + } } } else { rdf_printArcLabels(currentResource); - printf("nativeToString: node doesn't have a URL.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("nativeToString: node doesn't have a URL.\n")); + } } } diff --git a/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp b/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp index ebab2cf9253..6946655f130 100644 --- a/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp @@ -33,6 +33,8 @@ #include "nsAppShellCIDs.h" // for NS_SESSIONHISTORY_CID #include "nsCRT.h" // for nsCRT::strcmp +#include "prenv.h" + static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID); #ifdef XP_PC @@ -64,6 +66,8 @@ static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID); static nsFileSpec gBinDir; +PRLogModuleInfo *prLogModuleInfo = NULL; // declared in jni_util.h + const char *gImplementedInterfaces[] = { "webclient.WindowControl", "webclient.Navigation", @@ -91,6 +95,13 @@ Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitializ NS_InitXPCOM(nsnull, &gBinDir); NS_SetupRegistry(); + prLogModuleInfo = PR_NewLogModule("webclient"); + const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE"); + if (nsnull != webclientLogFile) { + PR_SetLogFile(webclientLogFile); + // If this fails, it just goes to stdout/stderr + } + nsComponentManager::RegisterComponentLib(kSessionHistoryCID, nsnull, nsnull, APPSHELL_DLL, PR_FALSE, PR_FALSE); diff --git a/mozilla/java/webclient/src_moz/jni_util.cpp b/mozilla/java/webclient/src_moz/jni_util.cpp index 2820127726d..b8de333b9a4 100644 --- a/mozilla/java/webclient/src_moz/jni_util.cpp +++ b/mozilla/java/webclient/src_moz/jni_util.cpp @@ -27,7 +27,8 @@ #include "jni_util.h" -JavaVM *gVm = nsnull; +JavaVM *gVm = nsnull; // declared in ns_globals.h, which is included in + // jni_util.h void util_ThrowExceptionToJava (JNIEnv * env, const char * message) { @@ -113,7 +114,10 @@ void util_SendEventToJava(JNIEnv *yourEnv, jobject nativeEventThread, env->CallVoidMethod(nativeEventThread, mid, webclientEventListener, eventType); } else { - printf("cannot call the Java Method!\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("cannot call the Java Method!\n")); + } } } @@ -293,13 +297,19 @@ jint util_GetIntValueFromInstance(JNIEnv *env, jobject obj, #else jclass objClass = env->GetObjectClass(obj); if (nsnull == objClass) { - printf("util_GetIntValueFromInstance: Can't get object class from instance.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("util_GetIntValueFromInstance: Can't get object class from instance.\n")); + } return result; } jfieldID theFieldID = env->GetFieldID(objClass, fieldName, "I"); if (nsnull == theFieldID) { - printf("util_GetIntValueFromInstance: Can't get fieldID for fieldName.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("util_GetIntValueFromInstance: Can't get fieldID for fieldName.\n")); + } return result; } @@ -315,13 +325,19 @@ void util_SetIntValueForInstance(JNIEnv *env, jobject obj, #else jclass objClass = env->GetObjectClass(obj); if (nsnull == objClass) { - printf("util_SetIntValueForInstance: Can't get object class from instance.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("util_SetIntValueForInstance: Can't get object class from instance.\n")); + } return; } jfieldID fieldID = env->GetFieldID(objClass, fieldName, "I"); if (nsnull == fieldID) { - printf("util_SetIntValueForInstance: Can't get fieldID for fieldName.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("util_SetIntValueForInstance: Can't get fieldID for fieldName.\n")); + } return; } @@ -362,7 +378,6 @@ JNU_CallMethodByNameV(JNIEnv *env, 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++; @@ -372,14 +387,10 @@ JNU_CallMethodByNameV(JNIEnv *env, 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); diff --git a/mozilla/java/webclient/src_moz/jni_util.h b/mozilla/java/webclient/src_moz/jni_util.h index 649f6bcf8da..e27c242e94c 100644 --- a/mozilla/java/webclient/src_moz/jni_util.h +++ b/mozilla/java/webclient/src_moz/jni_util.h @@ -44,6 +44,8 @@ #include "nsIWebShell.h" // for nsIWebShell #include "nsIEventQueueService.h" // for PLEventQueue +#include "ns_globals.h" + // Ashu #ifdef XP_UNIX #include "nsIWidget.h" // for GTKWidget @@ -91,7 +93,7 @@ enum { kClipboardWebShellError }; -extern JavaVM *gVm; +extern JavaVM *gVm; // defined in jni_util.cpp void util_ThrowExceptionToJava (JNIEnv * env, const char * message); diff --git a/mozilla/java/webclient/src_moz/jni_util_export.cpp b/mozilla/java/webclient/src_moz/jni_util_export.cpp index be7894d1b8e..dfd2b62e7d5 100644 --- a/mozilla/java/webclient/src_moz/jni_util_export.cpp +++ b/mozilla/java/webclient/src_moz/jni_util_export.cpp @@ -27,6 +27,8 @@ #include "nscore.h" // for nsnull +#include "ns_globals.h" // for prLogModuleInfo + JNIEXPORT const char * JNICALL util_GetStringUTFChars(JNIEnv *env, jstring inString) { @@ -101,7 +103,10 @@ JNIEXPORT void JNICALL util_DeleteStringUTF(JNIEnv *env, jstring toDelete) #ifdef BAL_INTERFACE util_DeleteString(env, toDelete); #else - printf("This shouldn't get called in a non-BAL context!\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("This shouldn't get called in a non-BAL context!\n")); + } #endif } @@ -123,7 +128,10 @@ JNIEXPORT void JNICALL util_DeleteString(JNIEnv *env, jstring toDelete) #ifdef BAL_INTERFACE bal_jstring_release(toDelete); #else - printf("This shouldn't get called in a non-BAL context!\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("This shouldn't get called in a non-BAL context!\n")); + } #endif } diff --git a/mozilla/java/webclient/src_moz/nsActions.cpp b/mozilla/java/webclient/src_moz/nsActions.cpp index 563b6f464aa..8dedfcbeca1 100644 --- a/mozilla/java/webclient/src_moz/nsActions.cpp +++ b/mozilla/java/webclient/src_moz/nsActions.cpp @@ -99,7 +99,6 @@ 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 baseWindow; rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), @@ -111,7 +110,6 @@ wsResizeEvent::handleEvent () rv = baseWindow->SetPositionAndSize(mLeft, mBottom, mWidth, mHeight, PR_TRUE); - printf("result = %lx\n", rv); return (void *) rv; } @@ -139,11 +137,7 @@ wsLoadURLEvent::handleEvent () { if (mWebShell && mURL) { - printf("handleEvent(loadURL))\n"); - nsresult rv = mWebShell->LoadURL(mURL->GetUnicode()); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -172,12 +166,7 @@ void * wsStopEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(Stop))\n"); - nsresult rv = mWebShell->Stop(); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -199,9 +188,6 @@ void * wsShowEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(Show))\n"); - nsresult rv; nsCOMPtr baseWindow; @@ -212,8 +198,6 @@ wsShowEvent::handleEvent () return nsnull; } baseWindow->SetVisibility(PR_TRUE); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -235,9 +219,6 @@ void * wsHideEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(Hide))\n"); - nsresult rv; nsCOMPtr baseWindow; @@ -248,8 +229,6 @@ wsHideEvent::handleEvent () return nsnull; } baseWindow->SetVisibility(PR_FALSE); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -273,9 +252,6 @@ void * wsMoveToEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(MoveTo(%ld, %ld))\n", mX, mY); - nsresult rv; nsCOMPtr baseWindow; @@ -286,8 +262,6 @@ wsMoveToEvent::handleEvent () return nsnull; } rv = baseWindow->SetPosition(mX, mY); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -308,9 +282,6 @@ void * wsSetFocusEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(SetFocus())\n"); - nsresult rv; nsCOMPtr baseWindow; @@ -321,8 +292,6 @@ wsSetFocusEvent::handleEvent () return nsnull; } rv = baseWindow->SetFocus(); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -344,12 +313,7 @@ void * wsRemoveFocusEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(RemoveFocus())\n"); - nsresult rv = mWebShell->RemoveFocus(); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -372,9 +336,6 @@ void * wsRepaintEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(Repaint(%d))\n", mForceRepaint); - nsresult rv; nsCOMPtr baseWindow; @@ -385,8 +346,6 @@ wsRepaintEvent::handleEvent () return nsnull; } rv = baseWindow->Repaint(mForceRepaint); - - printf("result = %lx\n", rv); } return nsnull; } // handleEvent() @@ -411,7 +370,6 @@ wsCanBackEvent::handleEvent () nsresult rv; PRBool canGoBack; - printf("handleEvent(CanBack()): "); rv = mHistory->CanGoBack(&canGoBack); if (NS_FAILED(rv)) { @@ -419,13 +377,6 @@ wsCanBackEvent::handleEvent () } result = (void *)canGoBack; - - if (PR_TRUE == canGoBack) { - printf("result: true\n"); - } - else { - printf("result: false\n"); - } } return result; } // handleEvent() @@ -448,7 +399,6 @@ wsCanForwardEvent::handleEvent () nsresult rv; PRBool canGoForward; - printf("handleEvent(CanForward()): "); rv = mHistory->CanGoForward(&canGoForward); if (NS_FAILED(rv)) { @@ -457,12 +407,6 @@ wsCanForwardEvent::handleEvent () result = (void *)canGoForward; - if (PR_TRUE == canGoForward) { - printf("result: true\n"); - } - else { - printf("result: false\n"); - } } return result; } // handleEvent() @@ -485,12 +429,8 @@ wsBackEvent::handleEvent () { void *result = nsnull; if (mHistory && mWebShell) { - printf("handleEvent(Back())\n"); - nsresult rv = mHistory->GoBack(mWebShell); - printf("result = %lx\n", rv); - result = (void *) rv; } return result; @@ -516,12 +456,7 @@ wsForwardEvent::handleEvent () void *result = nsnull; if (mHistory && mWebShell) { - printf("handleEvent(Forward())\n"); - nsresult rv = mHistory->GoForward(mWebShell); - - printf("result = %lx\n", rv); - result = (void *) rv; } return result; @@ -546,13 +481,7 @@ wsGoToEvent::handleEvent () { void *result = nsnull; 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; @@ -575,15 +504,9 @@ wsGetHistoryLengthEvent::handleEvent () { void *result = nsnull; if (mHistory) { - - printf("handleEvent(wsGetHistoryLengthEvent())\n"); - PRInt32 historyLength = 0; nsresult rv = mHistory->GetHistoryLength(&historyLength); - - printf("result = %lx\n", rv); - result = (void *) historyLength; } return result; @@ -606,15 +529,9 @@ wsGetHistoryIndexEvent::handleEvent () { void *result = nsnull; if (mHistory) { - - printf("handleEvent(wsGetHistoryIndexEvent())\n"); - PRInt32 historyIndex = 0; nsresult rv = mHistory->GetCurrentIndex(&historyIndex); - - printf("result = %lx\n", rv); - result = (void *) historyIndex; } return result; @@ -644,7 +561,6 @@ wsGetURLEvent::handleEvent () nsresult rv; rv = mHistory->GetCurrentIndex(¤tIndex); - printf("handleEvent(wsGetURLEvent(%ld))\n", currentIndex); if (NS_FAILED(rv)) { return result; @@ -657,9 +573,6 @@ wsGetURLEvent::handleEvent () return result; } - printf("wsGetURLEvent: currentIndex: %ld, currentURL: %s\n", - currentIndex, currentURL); - result = (void *) currentURL; } return result; @@ -684,18 +597,11 @@ wsGetURLForIndexEvent::handleEvent () if (mHistory) { nsresult rv; char *indexURL = nsnull; - - 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; @@ -721,13 +627,7 @@ void * wsRefreshEvent::handleEvent () { if (mWebShell) { - - printf("handleEvent(Refresh())\n"); - nsresult rv = mWebShell->Reload(loadFlags); - - printf("result = %lx\n", rv); - return (void *) rv; } return nsnull; @@ -746,12 +646,8 @@ wsAddDocLoaderObserverEvent::handleEvent () void *result = nsnull; if (mDocShell && mDocObserver) { - printf("handleEvent(AddDocLoaderObserver())\n"); nsresult rv = mDocShell->SetDocLoaderObserver(mDocObserver); - - printf("result = %lx\n", rv); - result = (void *) rv; } return result; diff --git a/mozilla/java/webclient/src_moz/ns_globals.h b/mozilla/java/webclient/src_moz/ns_globals.h new file mode 100644 index 00000000000..a590e8a5b8a --- /dev/null +++ b/mozilla/java/webclient/src_moz/ns_globals.h @@ -0,0 +1,37 @@ +/* -*- 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 + * + */ + + +/** + + * Global data + + */ + +#ifndef ns_globals_h +#define ns_globals_h + +#include "prlog.h" +extern PRLogModuleInfo *prLogModuleInfo; // defined in WrapperFactory.cpp + +#endif // ns_globals_h diff --git a/mozilla/java/webclient/src_moz/rdf_util.cpp b/mozilla/java/webclient/src_moz/rdf_util.cpp index cfd28ad9181..199b4198773 100644 --- a/mozilla/java/webclient/src_moz/rdf_util.cpp +++ b/mozilla/java/webclient/src_moz/rdf_util.cpp @@ -22,6 +22,8 @@ #include "rdf_util.h" +#include "ns_globals.h" // for prLogModuleInfo + #include "nsIServiceManager.h" static PRBool rdf_inited = PR_FALSE; @@ -152,7 +154,6 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) if (result) { // It's a folder - printf("FOLDER:\n"); rdf_printArcLabels(currentResource); // see if it has a name target @@ -168,15 +169,20 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) 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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("recursiveResourceTraversal: node is not an nsIRDFLiteral.\n")); + } } } else { - printf("recursiveResourceTraversal: can't get name from currentResource.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("recursiveResourceTraversal: can't get name from currentResource.\n")); + } } // get a container in order to recurr @@ -185,13 +191,19 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) NS_GET_IID(nsIRDFContainer), getter_AddRefs(container)); if (NS_FAILED(rv)) { - printf("recursiveResourceTraversal: can't get a new container\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("recursiveResourceTraversal: can't init container\n")); + } return; } @@ -199,20 +211,29 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) rv = container->GetElements(getter_AddRefs(elements)); if (NS_FAILED(rv)) { - printf("recursiveResourceTraversal: can't get elements from folder\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("Exception: Can't get next from enumerator.\n")); + } return; } @@ -220,7 +241,10 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFResource), getter_AddRefs(childResource)); if (NS_FAILED(rv)) { - printf("Exception: next from enumerator is not an nsIRDFResource.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("Exception: next from enumerator is not an nsIRDFResource.\n")); + } return; } @@ -228,14 +252,16 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) rv = elements->HasMoreElements(&result); if (NS_FAILED(rv)) { - printf("Exception: can't tell if we have more elements.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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 @@ -245,7 +271,10 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) kNC_URL, PR_TRUE, getter_AddRefs(node)); if (NS_FAILED(rv)) { - printf("recursiveResourceTraversal: can't get url from currentResource\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("recursiveResourceTraversal: can't get url from currentResource\n")); + } return; } @@ -253,18 +282,29 @@ void rdf_recursiveResourceTraversal(nsCOMPtr currentResource) rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(literal)); if (NS_FAILED(rv)) { - printf("recursiveResourceTraversal: node is not an nsIRDFLiteral.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("recursiveResourceTraversal: node doesn't have a value.\n")); + } return; } - printf("\turl: %S\n", textForNode); +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("\turl: %S\n", textForNode)); + } +#endif } @@ -282,30 +322,45 @@ void rdf_printArcLabels(nsCOMPtr currentResource) rv = currentResource->GetValueConst(¤tResourceValue); if (NS_SUCCEEDED(rv)) { - printf("resource: %s\n", currentResourceValue); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("resource: %s\n", currentResourceValue)); + } } else { - printf("printArcLabels: can't get value from current resource.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("printArcLabels: Can't get next arc from enumerator.\n")); + } return; } @@ -315,18 +370,30 @@ void rdf_printArcLabels(nsCOMPtr currentResource) if (NS_SUCCEEDED(rv)) { rv = resourceResult->GetValueConst(&arcLabel); if (NS_SUCCEEDED(rv)) { - printf("\tarc label: %s\n", arcLabel); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("\tarc label: %s\n", arcLabel)); + } } else { - printf("printArcLabels: can't get value from current arc.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("printArcLabels: can't get value from current arc.\n")); + } } } else { - printf("printArcLabels: next arc from enumerator is not an nsIRDFResource.\n"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("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"); + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 3, + ("printArcLabels: can't get elements from currentResource's enum.\n")); + } return; } }