diff --git a/Makefile b/Makefile index 39c1eb359ac8..e45f6214ef7a 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ ifndef NO_MOCHA DIRS_JS = js endif -DIRS = config coreconf $(NSPRDIR) jpeg dbm xpcom network +DIRS = config coreconf $(NSPRDIR) jpeg dbm xpcom base network caps ifdef MOZ_NETCAST DIRS += netcast @@ -53,7 +53,7 @@ endif include $(DEPTH)/config/rules.mk -export:: $(OBJS) +export:: envirocheck $(OBJS) # Running this rule assembles all the SDK source pieces into dist/sdk. # You'll need to run this rule on every platform to get all the diff --git a/base/tests/makefile.win b/base/tests/makefile.win index e8e163a5eb15..257b9c288194 100644 --- a/base/tests/makefile.win +++ b/base/tests/makefile.win @@ -23,14 +23,18 @@ PROG1 = .\$(OBJDIR)\TestAtoms.exe PROG2 = .\$(OBJDIR)\CvtURL.exe PROG3 = .\$(OBJDIR)\TestCRT.exe RESFILE = timer.res -PROGRAMS = $(PROG0) $(PROG1) $(PROG2) $(PROG3) +PROGRAMS = $(PROG0) $(PROG1) \ +!ifdef MODULAR_NETLIB + $(PROG2) $(PROG3) \ +!endif + $(NULL) LINCS=-I..\src -I$(PUBLIC)\xpcom -I$(PUBLIC)\netlib LLIBS= \ $(DIST)\lib\xpcom32.lib \ $(DIST)\lib\raptorbase.lib \ - $(DIST)\lib\netlib.lib \ + $(DIST)\lib\network.lib \ $(LIBNSPR) \ $(DIST)\lib\libplc21.lib \ $(RESFILE) @@ -40,14 +44,18 @@ include <$(DEPTH)\config\rules.mak> install:: $(PROGRAMS) $(MAKE_INSTALL) $(PROG0) $(DIST)\bin $(MAKE_INSTALL) $(PROG1) $(DIST)\bin +!ifdef MODULAR_NETLIB $(MAKE_INSTALL) $(PROG2) $(DIST)\bin $(MAKE_INSTALL) $(PROG3) $(DIST)\bin +!endif clobber:: rm -f $(DIST)\bin\TimerTest.exe rm -f $(DIST)\bin\TestAtoms.exe +!ifdef MODULAR_NETLIB rm -f $(DIST)\bin\CvtURL.exe rm -f $(DIST)\bin\TestCRT.exe +!endif # Move this into config/obj.inc when it's allowed .cpp{.\$(OBJDIR)\}.exe: @@ -72,4 +80,3 @@ $(PROG1): $(OBJDIR) TestAtoms.cpp $(PROG2): $(OBJDIR) CvtURL.cpp $(PROG2): $(OBJDIR) TestCRT.cpp - diff --git a/build/build_number b/build/build_number index ea9fa2f691d7..e2ec611f46aa 100644 --- a/build/build_number +++ b/build/build_number @@ -1 +1 @@ -5009808600 +5009821211 diff --git a/build/mac/BuildList.pm b/build/mac/BuildList.pm index 9312bec931c3..b4c206258f28 100644 --- a/build/mac/BuildList.pm +++ b/build/mac/BuildList.pm @@ -102,6 +102,9 @@ sub BuildMozilla() BuildProject(":mozilla:js:macbuild:JavaScriptPPC.mcp", "JavaScript$D.shlb"); MakeAlias(":mozilla:js:macbuild:JavaScript$D.shlb", "$dist_dir"); + BuildProject(":mozilla:js:macbuild:LiveConnect.mcp", "LiveConnect$D.shlb"); + MakeAlias(":mozilla:js:macbuild:LiveConnect$D.shlb", "$dist_dir"); + BuildProject(":mozilla:nav-java:stubs:macbuild:NavJavaStubs.mcp", "NavJava$D.shlb"); MakeAlias(":mozilla:nav-java:stubs:macbuild:NavJava$D.shlb", "$dist_dir"); @@ -119,6 +122,7 @@ sub BuildMozilla() BuildProject(":mozilla:modules:security:freenav:macbuild:NoSecurity.mcp", "Security.o"); BuildProject(":mozilla:modules:libfont:macbuild:FontBroker.mcp", "FontBroker$D.o"); + BuildProject(":mozilla:modules:oji:macbuild:oji.mcp", "oji$D.o"); BuildProject(":mozilla:lib:libmocha:macbuild:LibMocha.mcp", "LibMocha$D.o"); if ( $main::MOZ_DARK == 1 ) @@ -129,6 +133,7 @@ sub BuildMozilla() { BuildProject(":mozilla:network:macbuild:network.mcp", "Network$D.o"); } + BuildProject(":mozilla:caps:macbuild:Caps.mcp", "Caps$D.o"); BuildProject(":mozilla:modules:libimg:macbuild:png.mcp", "png$D.o"); BuildProject(":mozilla:modules:libimg:macbuild:libimg.mcp", "libimg$D.o"); @@ -227,6 +232,9 @@ sub DistMozilla() #JS InstallFromManifest(":mozilla:js:src:MANIFEST", ":mozilla:dist:js:"); + #LIVECONNECT + InstallFromManifest(":mozilla:js:src:liveconnect:MANIFEST", ":mozilla:dist:liveconnect:"); + #RDF InstallFromManifest(":mozilla:modules:rdf:include:MANIFEST", ":mozilla:dist:rdf:"); @@ -291,7 +299,8 @@ sub DistMozilla() InstallFromManifest(":mozilla:lib:libstyle:MANIFEST", ":mozilla:dist:libstyle:"); #PLUGIN - InstallFromManifest(":mozilla:lib:plugin:MANIFEST", ":mozilla:dist:plugin:"); + InstallFromManifest(":mozilla:modules:plugin:public:MANIFEST", ":mozilla:dist:plugin:"); + InstallFromManifest(":mozilla:modules:plugin:src:MANIFEST", ":mozilla:dist:plugin:"); #LIBHOOK InstallFromManifest(":mozilla:modules:libhook:public:MANIFEST", ":mozilla:dist:libhook:"); @@ -318,8 +327,18 @@ sub DistMozilla() #SUN_JAVA InstallFromManifest(":mozilla:sun-java:stubs:include:MANIFEST", ":mozilla:dist:sun-java:"); InstallFromManifest(":mozilla:sun-java:stubs:macjri:MANIFEST", ":mozilla:dist:sun-java:"); + + #OJI + InstallFromManifest(":mozilla:modules:oji:public:MANIFEST", ":mozilla:dist:oji:"); + InstallFromManifest(":mozilla:modules:oji:src:MANIFEST", ":mozilla:dist:oji:"); + + #CAPS + InstallFromManifest(":mozilla:caps:include:MANIFEST", ":mozilla:dist:caps:"); + + #BASE + InstallFromManifest(":mozilla:base:public:MANIFEST", ":mozilla:dist:base:"); + InstallFromManifest(":mozilla:base:src:MANIFEST", ":mozilla:dist:base:"); } 1; - diff --git a/caps/include/MANIFEST b/caps/include/MANIFEST index 5c394d5bfc62..911424708072 100644 --- a/caps/include/MANIFEST +++ b/caps/include/MANIFEST @@ -11,3 +11,5 @@ nsUserDialogHelper.h nsZip.h nsLoadZig.h admin.h +nsCaps.h +nsCapsEnums.h diff --git a/caps/include/Makefile b/caps/include/Makefile index d5c268a7a76f..2284e30b5f9a 100755 --- a/caps/include/Makefile +++ b/caps/include/Makefile @@ -18,7 +18,7 @@ MODULE = caps DEPTH = ../.. -EXPORTS = nsZip.h nsZig.h nsLoadZig.h nsPrincipal.h nsPrivilege.h nsPrivilegeManager.h nsPrivilegeTable.h nsSystemPrivilegeTable.h nsTarget.h nsUserTarget.h jpermission.h nsUserDialogHelper.h admin.h +EXPORTS = nsZip.h nsZig.h nsLoadZig.h nsPrincipal.h nsPrivilege.h nsPrivilegeManager.h nsPrivilegeTable.h nsSystemPrivilegeTable.h nsTarget.h nsUserTarget.h jpermission.h nsUserDialogHelper.h admin.h nsCaps.h nsCapsEnums.h include $(DEPTH)/config/rules.mk diff --git a/caps/include/makefile.win b/caps/include/makefile.win index 822cdccbdade..f1da9c7f48f8 100755 --- a/caps/include/makefile.win +++ b/caps/include/makefile.win @@ -28,7 +28,7 @@ IGNORE_MANIFEST=1 MODULE=caps DEPTH=..\.. -EXPORTS=nsZip.h nsZig.h nsLoadZig.h nsPrincipal.h nsPrivilege.h nsPrivilegeManager.h nsPrivilegeTable.h nsSystemPrivilegeTable.h nsTarget.h nsUserTarget.h jpermission.h nsUserDialogHelper.h admin.h +EXPORTS=nsZip.h nsZig.h nsLoadZig.h nsPrincipal.h nsPrivilege.h nsPrivilegeManager.h nsPrivilegeTable.h nsSystemPrivilegeTable.h nsTarget.h nsUserTarget.h jpermission.h nsUserDialogHelper.h admin.h nsCaps.h nsCapsEnums.h include <$(DEPTH)/config/rules.mak> diff --git a/caps/include/nsPrincipal.h b/caps/include/nsPrincipal.h index 994903afd1a2..c56420dc90d9 100755 --- a/caps/include/nsPrincipal.h +++ b/caps/include/nsPrincipal.h @@ -22,23 +22,13 @@ #include "prtypes.h" #include "nsHashtable.h" #include "nsVector.h" -#include "nsZig.h" -#include "nsCom.h" - -/* The following should match what is in nsJVM plugin's java security code */ -typedef enum nsPrincipalType { - nsPrincipalType_Unknown=-1, - nsPrincipalType_CodebaseExact=10, - nsPrincipalType_CodebaseRegexp, - nsPrincipalType_Cert, - nsPrincipalType_CertFingerPrint, - nsPrincipalType_CertKey -} nsPrincipalType; +#include "nsCaps.h" +#include "nsCapsEnums.h" typedef nsVector nsPrincipalArray; -class nsPrincipal { +struct nsPrincipal { public: @@ -48,7 +38,7 @@ public: nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len); nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len, char *stringRep); virtual ~nsPrincipal(); - nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len, nsZig *zigObject); + nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len, void *zigObject); PRBool equals(nsPrincipal *principal); @@ -97,7 +87,7 @@ private: /* Private Field Accessors */ nsPrincipalType itsType; - nsZig * itsZig; + void * itsZig; char * itsKey; diff --git a/caps/include/nsPrivilege.h b/caps/include/nsPrivilege.h index b8f4acfda45d..e3be7e993861 100755 --- a/caps/include/nsPrivilege.h +++ b/caps/include/nsPrivilege.h @@ -20,33 +20,12 @@ #define _NS_PRIVILEGE_H_ #include "prtypes.h" -#include "nsCom.h" - - -/** - * number of possible permissions (allowed, forbidden, or blank) - */ -typedef enum nsPermissionState { - nsPermissionState_Forbidden = 0, - nsPermissionState_Allowed, - nsPermissionState_Blank, - nsPermissionState_NumberOfPermissions -} nsPermissionState; - - -/** - * number of possible durations (scope, session, or forever) - */ -typedef enum nsDurationState { - nsDurationState_Scope=0, - nsDurationState_Session, - nsDurationState_Forever, - nsDurationState_NumberOfDurations -} nsDurationState; +#include "nsCaps.h" +#include "nsCapsEnums.h" PRBool nsPrivilegeInitialize(void); -class nsPrivilege { +struct nsPrivilege { public: /* Public Field Accessors */ diff --git a/caps/include/nsPrivilegeManager.h b/caps/include/nsPrivilegeManager.h index 0a396bea041e..6e01a1906387 100755 --- a/caps/include/nsPrivilegeManager.h +++ b/caps/include/nsPrivilegeManager.h @@ -25,18 +25,13 @@ #include "nsHashtable.h" #include "nsVector.h" +#include "nsCaps.h" #include "nsTarget.h" #include "nsPrincipal.h" #include "nsPrivilege.h" #include "nsPrivilegeTable.h" #include "nsSystemPrivilegeTable.h" -#include "nsCom.h" - -typedef enum nsSetComparisonType { - nsSetComparisonType_ProperSubset=-1, - nsSetComparisonType_Equal=0, - nsSetComparisonType_NoSubset=1 -} nsSetComparisonType; +#include "nsCapsEnums.h" extern PRBool nsCaps_lock(void); extern void nsCaps_unlock(void); @@ -45,39 +40,9 @@ PR_BEGIN_EXTERN_C PRBool CMGetBoolPref(char * pref_name); PR_END_EXTERN_C -struct NSJSJavaFrameWrapper; - -void -setNewNSJSJavaFrameWrapperCallback(struct NSJSJavaFrameWrapper * (*fp)(void)); - -void -setFreeNSJSJavaFrameWrapperCallback(void (*fp)(struct NSJSJavaFrameWrapper *)); - -void -setGetStartFrameCallback(void (*fp)(struct NSJSJavaFrameWrapper *)); - -void -setIsEndOfFrameCallback(PRBool (*fp)(struct NSJSJavaFrameWrapper *)); - -void -setIsValidFrameCallback(PRBool (*fp)(struct NSJSJavaFrameWrapper *)); - -void -setGetNextFrameCallback(void * (*fp)(struct NSJSJavaFrameWrapper *, int *)); - -void -setOJIGetPrincipalArrayCallback(void * (*fp)(struct NSJSJavaFrameWrapper *)); - -void -setOJIGetAnnotationCallback(void * (*fp)(struct NSJSJavaFrameWrapper *)); - -void -setOJISetAnnotationCallback(void * (*fp)(struct NSJSJavaFrameWrapper *, void *)); - - PRBool nsPrivilegeManagerInitialize(void); -class nsPrivilegeManager { +struct nsPrivilegeManager { public: /* Public Methods */ diff --git a/caps/include/nsPrivilegeTable.h b/caps/include/nsPrivilegeTable.h index d29841dd331d..55a194f9fe7f 100755 --- a/caps/include/nsPrivilegeTable.h +++ b/caps/include/nsPrivilegeTable.h @@ -21,12 +21,11 @@ #include "prtypes.h" #include "nsHashtable.h" +#include "nsCaps.h" #include "nsTarget.h" #include "nsPrivilege.h" -#include "nsCom.h" - -class nsPrivilegeTable { +struct nsPrivilegeTable { public: diff --git a/caps/include/nsTarget.h b/caps/include/nsTarget.h index c548e4e669d2..865f0fe8621a 100755 --- a/caps/include/nsTarget.h +++ b/caps/include/nsTarget.h @@ -23,11 +23,11 @@ #include "prtypes.h" #include "plhash.h" -#include "nsPrincipal.h" -#include "nsPrivilege.h" #include "nsHashtable.h" #include "nsVector.h" -#include "nsCom.h" +#include "nsCaps.h" +#include "nsPrincipal.h" +#include "nsPrivilege.h" #include "nsUserDialogHelper.h" typedef nsVector nsTargetArray; @@ -43,7 +43,7 @@ extern int CAPS_TARGET_RISK_COLOR_HIGH; extern PRBool CreateSystemTargets(nsPrincipal *sysPrin); -class nsTarget { +struct nsTarget { public: diff --git a/caps/macbuild/Caps.mcp b/caps/macbuild/Caps.mcp index 1231adf474ba..36c13addccf7 100644 Binary files a/caps/macbuild/Caps.mcp and b/caps/macbuild/Caps.mcp differ diff --git a/caps/src/Makefile b/caps/src/Makefile index 2a6bf5ce6152..b353bfb39a83 100755 --- a/caps/src/Makefile +++ b/caps/src/Makefile @@ -36,6 +36,7 @@ CSRCS = \ jpermission.c \ nsUserTarget.c \ admin.c \ + nsCaps.c \ $(NULL) include $(DEPTH)/config/rules.mk diff --git a/caps/src/admin.cpp b/caps/src/admin.cpp index 38bbbdbb028a..abf4b52dd043 100644 --- a/caps/src/admin.cpp +++ b/caps/src/admin.cpp @@ -41,7 +41,6 @@ extern "C" { PR_PUBLIC_API(const char *) java_netscape_security_getPrincipals(const char *charSetName) { -#ifdef DEBUG_raman nsPrivilegeManager *nsPrivManager = nsPrivilegeManager::getPrivilegeManager(); const char *prins = nsPrivManager->getAllPrincipalsString(); PRBool test_admin_api = PR_FALSE; @@ -54,20 +53,13 @@ java_netscape_security_getPrincipals(const char *charSetName) java_netscape_security_removePrincipal(NULL, "raman tenneti"); } return prins; -#else - return NULL; -#endif /* DEBUG_raman */ } PR_PUBLIC_API(PRBool) java_netscape_security_removePrincipal(const char *charSetName, char *prinName) { -#ifdef DEBUG_raman nsPrivilegeManager *nsPrivManager = nsPrivilegeManager::getPrivilegeManager(); return nsPrivManager->removePrincipal(prinName); -#else - return PR_FALSE; -#endif /* DEBUG_raman */ } PR_PUBLIC_API(void) @@ -75,22 +67,16 @@ java_netscape_security_getPrivilegeDescs(const char *charSetName, char *prinName char** forever, char** session, char **denied) { -#ifdef DEBUG_raman nsPrivilegeManager *nsPrivManager = nsPrivilegeManager::getPrivilegeManager(); nsPrivManager->getTargetsWithPrivileges(prinName, forever, session, denied); -#endif /* DEBUG_raman */ } PR_PUBLIC_API(PRBool) java_netscape_security_removePrivilege(const char *charSetName, char *prinName, char *targetName) { -#ifdef DEBUG_raman nsPrivilegeManager *nsPrivManager = nsPrivilegeManager::getPrivilegeManager(); return nsPrivManager->removePrincipalsPrivilege(prinName, targetName); -#else - return PR_FALSE; -#endif /* DEBUG_raman */ } diff --git a/caps/src/makefile.win b/caps/src/makefile.win index 4633ace8cc23..e8f81f7f8e9d 100755 --- a/caps/src/makefile.win +++ b/caps/src/makefile.win @@ -63,6 +63,7 @@ OBJS= \ .\$(OBJDIR)\jpermission.obj \ .\$(OBJDIR)\nsUserTarget.obj \ .\$(OBJDIR)\admin.obj \ + .\$(OBJDIR)\nsCaps.obj \ $(NULL) diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp index 2c2b933f6c20..e316d3693b47 100755 --- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -144,7 +144,7 @@ nsPrincipal::nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len) init(type, key, key_len); } -nsPrincipal::nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len, nsZig *zigObject) +nsPrincipal::nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len, void *zigObject) { init(type, key, key_len); itsZig = zigObject; @@ -158,9 +158,9 @@ nsPrincipal::nsPrincipal(nsPrincipalType type, void * key, PRUint32 key_len, cha nsPrincipal::~nsPrincipal(void) { -#ifdef DEBUG_RAMAN +#ifdef DEBUG_raman fprintf(stderr, "Deleting principal %s\n", itsKey); -#endif /* DEBUG_RAMAN */ +#endif /* DEBUG_raman */ if (itsKey) { delete []itsKey; } @@ -215,6 +215,29 @@ char * nsPrincipal::getVendor(void) } } +// XXX copyied from ns/lib/libjar/zig.h +#ifndef ZIG_C_COMPANY +#define ZIG_C_COMPANY 1 +#endif +#ifndef ZIG_C_CA +#define ZIG_C_CA 2 +#endif +#ifndef ZIG_C_SERIAL +#define ZIG_C_SERIAL 3 +#endif +#ifndef ZIG_C_EXPIRES +#define ZIG_C_EXPIRES 4 +#endif +#ifndef ZIG_C_NICKNAME +#define ZIG_C_NICKNAME 5 +#endif +#ifndef ZIG_C_FP +#define ZIG_C_FP 6 +#endif +#ifndef ZIG_C_JAVA +#define ZIG_C_JAVA 100 +#endif + char * nsPrincipal::getCompanyName(void) { if (itsCompanyName == NULL) @@ -434,9 +457,9 @@ void nsPrincipal::init(nsPrincipalType type, void * key, PRUint32 key_len) itsKey = new char[key_len+1]; memcpy(itsKey, key, key_len); itsKey[key_len] = '\0'; -#ifdef DEBUG_RAMAN +#ifdef DEBUG_raman fprintf(stderr, "Creating principal %d, %s\n", type, itsKey); -#endif /* DEBUG_RAMAN */ +#endif /* DEBUG_raman */ itsKeyLen = key_len; itsHashCode = computeHashCode(); itsZig = NULL; @@ -484,7 +507,7 @@ char * nsPrincipal::saveCert(void) return NULL; } - result = SOB_stash_cert((ZIG *)itsZig->GetZig(), itsKeyLen, itsKey); + result = SOB_stash_cert((ZIG *)itsZig, itsKeyLen, itsKey); if (result < 0) { return SOB_get_error(result); } @@ -501,7 +524,7 @@ nsPrincipal::getCertAttribute(int attrib) ZIG *zig = NULL; if (itsZig != NULL) { - zig = (ZIG *)itsZig->GetZig(); + zig = (ZIG *)itsZig; } if (SOB_cert_attribute(attrib, zig, diff --git a/caps/src/nsPrivilegeManager.cpp b/caps/src/nsPrivilegeManager.cpp index 1310ae6749e6..2ce8b001a47e 100755 --- a/caps/src/nsPrivilegeManager.cpp +++ b/caps/src/nsPrivilegeManager.cpp @@ -26,12 +26,7 @@ #include "jpermission.h" #include "rdf.h" -#ifdef DEBUG_raman -/* ifdef'ed out ADMIN UI until we merge changes with rdf branch. - * All these changes are under DEBUG_raman - */ #include "jsec2rdf.h" -#endif /* DEBUG_raman */ static nsPrivilegeManager * thePrivilegeManager = NULL; @@ -58,10 +53,7 @@ nsPrivilegeTable *gPrivilegeTable; static PRBool getPrincipalString(nsHashKey *aKey, void *aData); -#ifdef DEBUG_raman static nsPrincipal *RDF_getPrincipal(JSec_Principal jsec_pr); -#endif /* DEBUG_raman */ - static PRBool RDF_RemovePrincipal(nsPrincipal *prin); static PRBool RDF_RemovePrincipalsPrivilege(nsPrincipal *prin, nsTarget *target); @@ -661,6 +653,8 @@ nsPrivilegeManager::intersectPrincipalArray(nsPrincipalArray* p1, PRBool nsPrivilegeManager::canExtendTrust(nsPrincipalArray* from, nsPrincipalArray* to) { + if ((from == NULL) || (to == NULL)) + return PR_FALSE; nsPrincipalArray * intersect = intersectPrincipalArray(from, to); if (intersect->GetSize() == from->GetSize()) return PR_TRUE; @@ -981,87 +975,6 @@ nsPrivilegeManager::isPermissionGranted(nsTarget *target, } } -/* The following method should call native code */ - -static struct NSJSJavaFrameWrapper * (*NewNSJSJavaFrameWrapperCallback)(void); - -void -setNewNSJSJavaFrameWrapperCallback(struct NSJSJavaFrameWrapper * (*fp)(void)) -{ - NewNSJSJavaFrameWrapperCallback = fp; -} - - -static void (*FreeNSJSJavaFrameWrapperCallback)(struct NSJSJavaFrameWrapper *); - -void -setFreeNSJSJavaFrameWrapperCallback(void (*fp)(struct NSJSJavaFrameWrapper *)) -{ - FreeNSJSJavaFrameWrapperCallback = fp; -} - - -static void (*GetStartFrameCallback)(struct NSJSJavaFrameWrapper *); - -void -setGetStartFrameCallback(void (*fp)(struct NSJSJavaFrameWrapper *)) -{ - GetStartFrameCallback = fp; -} - - -static PRBool (*IsEndOfFrameCallback)(struct NSJSJavaFrameWrapper *); - -void -setIsEndOfFrameCallback(PRBool (*fp)(struct NSJSJavaFrameWrapper *)) -{ - IsEndOfFrameCallback = fp; -} - - -static PRBool (*IsValidFrameCallback)(struct NSJSJavaFrameWrapper *); - -void -setIsValidFrameCallback(PRBool (*fp)(struct NSJSJavaFrameWrapper *)) -{ - IsValidFrameCallback = fp; -} - - -static void * (*GetNextFrameCallback)(struct NSJSJavaFrameWrapper *, int *); - -void -setGetNextFrameCallback(void * (*fp)(struct NSJSJavaFrameWrapper *, int *)) -{ - GetNextFrameCallback = fp; -} - - -static void * (*GetPrincipalArrayCallback)(struct NSJSJavaFrameWrapper *); - -void -setOJIGetPrincipalArrayCallback(void * (*fp)(struct NSJSJavaFrameWrapper *)) -{ - GetPrincipalArrayCallback = fp; -} - - -static void * (*GetAnnotationCallback)(struct NSJSJavaFrameWrapper *); - -void -setOJIGetAnnotationCallback(void * (*fp)(struct NSJSJavaFrameWrapper *)) -{ - GetAnnotationCallback = fp; -} - - -static void * (*SetAnnotationCallback)(struct NSJSJavaFrameWrapper *, void *); - -void -setOJISetAnnotationCallback(void * (*fp)(struct NSJSJavaFrameWrapper *, void *)) -{ - SetAnnotationCallback = fp; -} char * nsPrivilegeManager::checkPrivilegeEnabled(nsTargetArray * targetArray, @@ -1087,18 +1000,21 @@ nsPrivilegeManager::checkPrivilegeEnabled(nsTargetArray * targetArray, return "internal error - null target array"; } - wrapper = (*NewNSJSJavaFrameWrapperCallback)(); + if (*nsCapsNewNSJSJavaFrameWrapperCallback == NULL) { + return NULL; + } + wrapper = (*nsCapsNewNSJSJavaFrameWrapperCallback)(); if (wrapper == NULL) { return NULL; } noOfTargets = targetArray->GetSize(); - for ((*GetStartFrameCallback)(wrapper); - (!(*IsEndOfFrameCallback)(wrapper)); + for ((*nsCapsGetStartFrameCallback)(wrapper); + (!(*nsCapsIsEndOfFrameCallback)(wrapper)); ) { - if ((*IsValidFrameCallback)(wrapper)) { + if ((*nsCapsIsValidFrameCallback)(wrapper)) { if (depth >= callerDepth) { scopePerm = nsPermissionState_Blank; prinPerm = nsPermissionState_Blank; @@ -1109,8 +1025,8 @@ nsPrivilegeManager::checkPrivilegeEnabled(nsTargetArray * targetArray, goto done; } - annotation = (nsPrivilegeTable *) (*GetAnnotationCallback)(wrapper); - prinArray = (nsPrincipalArray *) (*GetPrincipalArrayCallback)(wrapper); + annotation = (nsPrivilegeTable *) (*nsCapsGetAnnotationCallback)(wrapper); + prinArray = (nsPrincipalArray *) (*nsCapsGetPrincipalArrayCallback)(wrapper); /* * frame->annotation holds a PrivilegeTable, describing * the scope privileges of this frame. We'll check @@ -1168,7 +1084,7 @@ nsPrivilegeManager::checkPrivilegeEnabled(nsTargetArray * targetArray, } } } - if (!(*GetNextFrameCallback)(wrapper, &depth)) + if (!(*nsCapsGetNextFrameCallback)(wrapper, &depth)) break; } /* @@ -1186,7 +1102,7 @@ nsPrivilegeManager::checkPrivilegeEnabled(nsTargetArray * targetArray, errMsg = "access to target forbidden. Target was not enabled on stack (stack included only system code)"; done: - (*FreeNSJSJavaFrameWrapperCallback)(wrapper); + (*nsCapsFreeNSJSJavaFrameWrapperCallback)(wrapper); return errMsg; } @@ -1198,23 +1114,26 @@ nsPrivilegeManager::getClassPrincipalsFromStack(PRInt32 callerDepth) int depth = 0; struct NSJSJavaFrameWrapper *wrapper = NULL; - wrapper = (*NewNSJSJavaFrameWrapperCallback)(); + if (*nsCapsNewNSJSJavaFrameWrapperCallback == NULL) { + return NULL; + } + wrapper = (*nsCapsNewNSJSJavaFrameWrapperCallback)(); if (wrapper == NULL) return NULL; - for ((*GetStartFrameCallback)(wrapper) ; - (!(*IsEndOfFrameCallback)(wrapper)) ; + for ((*nsCapsGetStartFrameCallback)(wrapper) ; + (!(*nsCapsIsEndOfFrameCallback)(wrapper)) ; ) { - if ((*IsValidFrameCallback)(wrapper)) { + if ((*nsCapsIsValidFrameCallback)(wrapper)) { if (depth >= callerDepth) { - principalArray = (nsPrincipalArray *) (*GetPrincipalArrayCallback)(wrapper); + principalArray = (nsPrincipalArray *) (*nsCapsGetPrincipalArrayCallback)(wrapper); break; } } - if (!(*GetNextFrameCallback)(wrapper, &depth)) + if (!(*nsCapsGetNextFrameCallback)(wrapper, &depth)) break; } - (*FreeNSJSJavaFrameWrapperCallback)(wrapper); + (*nsCapsFreeNSJSJavaFrameWrapperCallback)(wrapper); return principalArray; } @@ -1228,14 +1147,17 @@ nsPrivilegeManager::getPrivilegeTableFromStack(PRInt32 callerDepth, struct NSJSJavaFrameWrapper *wrapper = NULL; nsPrivilegeTable *annotation; - wrapper = (*NewNSJSJavaFrameWrapperCallback)(); + if (*nsCapsNewNSJSJavaFrameWrapperCallback == NULL) { + return NULL; + } + wrapper = (*nsCapsNewNSJSJavaFrameWrapperCallback)(); if (wrapper == NULL) return NULL; - for ((*GetStartFrameCallback)(wrapper) ; - (!(*IsEndOfFrameCallback)(wrapper)) ; + for ((*nsCapsGetStartFrameCallback)(wrapper) ; + (!(*nsCapsIsEndOfFrameCallback)(wrapper)) ; ) { - if ((*IsValidFrameCallback)(wrapper)) { + if ((*nsCapsIsValidFrameCallback)(wrapper)) { if (depth >= callerDepth) { /* * it's possible for the annotation to be NULL, meaning @@ -1244,7 +1166,7 @@ nsPrivilegeManager::getPrivilegeTableFromStack(PRInt32 callerDepth, * default "blank forever" privileges), assign that * to the annotation, and return it. */ - annotation = (nsPrivilegeTable *) (*GetAnnotationCallback)(wrapper); + annotation = (nsPrivilegeTable *) (*nsCapsGetAnnotationCallback)(wrapper); if (createIfNull && annotation == NULL) { privTable = new nsPrivilegeTable(); if (privTable == NULL) { @@ -1255,22 +1177,21 @@ nsPrivilegeManager::getPrivilegeTableFromStack(PRInt32 callerDepth, break; } PR_ASSERT(privTable != NULL); - (*SetAnnotationCallback)(wrapper, privTable); + (*nsCapsSetAnnotationCallback)(wrapper, privTable); } else { privTable = annotation; } break; } } - if (!(*GetNextFrameCallback)(wrapper, &depth)) + if (!(*nsCapsGetNextFrameCallback)(wrapper, &depth)) break; } - (*FreeNSJSJavaFrameWrapperCallback)(wrapper); + (*nsCapsFreeNSJSJavaFrameWrapperCallback)(wrapper); return privTable; } -#ifdef DEBUG_raman -JSec_Principal +static JSec_Principal RDF_CreatePrincipal(nsPrincipal *prin) { /* For certificate principals we should convert the key into string, because @@ -1342,7 +1263,7 @@ RDF_getPrincipal(JSec_Principal jsec_pr) return prin; } -JSec_Target +static JSec_Target RDF_CreateTarget(nsTarget *target) { char *targetName = target->getName(); @@ -1351,7 +1272,7 @@ RDF_CreateTarget(nsTarget *target) return RDFJSec_NewTarget(targetName, pr); } -nsTarget * +static nsTarget * RDF_getTarget(JSec_Target jsec_target) { char *targetName = RDFJSec_GetTargetName(jsec_target); @@ -1410,7 +1331,6 @@ RDF_RemovePrincipalsPrivilege(nsPrincipal *prin, nsTarget *target) nsCaps_unlock(); return found; } -#endif /* DEBUG_raman */ /* The following methods are used to save and load the persistent store */ @@ -1423,7 +1343,6 @@ void nsPrivilegeManager::save(nsPrincipal *prin, if (prin->equals(getSystemPrincipal())) { return; } -#ifdef DEBUG_raman nsCaps_lock(); RDFJSec_InitPrivilegeDB(); JSec_Principal pr = RDF_CreatePrincipal(prin); @@ -1433,7 +1352,6 @@ void nsPrivilegeManager::save(nsPrincipal *prin, RDFJSec_AddPrincipalUse(pr, prUse); nsCaps_unlock(); -#endif /* DEBUG_raman */ } /* The following routine should be called after setting up the system targets @@ -1441,7 +1359,6 @@ void nsPrivilegeManager::save(nsPrincipal *prin, */ void nsPrivilegeManager::load(void) { -#ifdef DEBUG_raman nsCaps_lock(); RDFJSec_InitPrivilegeDB(); RDF_Cursor prin_cursor = RDFJSec_ListAllPrincipals(); @@ -1479,7 +1396,6 @@ void nsPrivilegeManager::load(void) RDFJSec_ReleaseCursor(prin_cursor); nsCaps_unlock(); -#endif /* DEBUG_raman */ } @@ -1502,12 +1418,8 @@ PRBool nsPrivilegeManagerInitialize(void) theUnknownPrincipalArray->Add(theUnknownPrincipal); thePrivilegeManager = new nsPrivilegeManager(); -#ifdef DEBUG_raman RDFJSec_InitPrivilegeDB(); return PR_FALSE; -#endif /* DEBUG_raman */ } PRBool nsPrivilegeManager::theInited = nsPrivilegeManagerInitialize(); - - diff --git a/caps/src/nsUserTarget.cpp b/caps/src/nsUserTarget.cpp index 2415ae02690a..c5cc7a4deb17 100755 --- a/caps/src/nsUserTarget.cpp +++ b/caps/src/nsUserTarget.cpp @@ -28,6 +28,8 @@ extern "C" { #include "jpermission.h" +static PRBool displayUI=PR_FALSE; + static nsPermState displayPermissionDialog(char *prinStr, char *targetStr, char *riskStr, PRBool isCert) { @@ -60,10 +62,12 @@ nsPrivilege * nsUserTarget::enablePrivilege(nsPrincipal *prin, void *data) PRBool isCert = (prin->isCodebase()) ? PR_FALSE : PR_TRUE; nsPermState permState = nsPermState_AllowedSession; - nsCaps_lock(); - /* comment the above line, uncomment the following line to disable UI */ - permState = displayPermissionDialog(prinStr, targetStr, riskStr, isCert); - nsCaps_unlock(); + /* set displayUI to TRUE, to enable UI */ + if (displayUI) { + nsCaps_lock(); + permState = displayPermissionDialog(prinStr, targetStr, riskStr, isCert); + nsCaps_unlock(); + } nsPermissionState permVal; nsDurationState durationVal; diff --git a/caps/src/nsZig.cpp b/caps/src/nsZig.cpp index c4deb224f3da..426c1032de55 100755 --- a/caps/src/nsZig.cpp +++ b/caps/src/nsZig.cpp @@ -16,9 +16,15 @@ * Reserved. */ +#include "prtypes.h" + +PR_BEGIN_EXTERN_C + #include "nsZig.h" #include "zig.h" +PR_END_EXTERN_C + // // PUBLIC METHODS // diff --git a/cmd/xfe/Makefile b/cmd/xfe/Makefile index 60aaebc147d8..6baccb37b1f1 100644 --- a/cmd/xfe/Makefile +++ b/cmd/xfe/Makefile @@ -93,7 +93,8 @@ REQUIRES =\ plds \ nspr20 \ parse \ - plug \ + plugin \ + plugimpl \ hook \ pref \ rdf \ @@ -118,7 +119,12 @@ REQUIRES += \ $(NULL) ifdef MOZ_FULLCIRCLE -REQUIRES += fullsoft +REQUIRES += fullsoft +endif + +ifdef OJI +REQUIRES += oji \ + ojiimpl endif CSRCS = \ @@ -185,6 +191,7 @@ GUESS_CONFIG := $(shell $(DEPTH)/config/config.guess | sed 's/i[23456]86/x86/') CCLD = $(CCC) LDFLAGS = $(CFLAGS) NOMD_LDFLAGS = $(NOMD_CFLAGS) +BASIC_DSOS = -L$(DIST)/bin ifdef MOZILLA_GPROF CSRCS += gmon.c @@ -219,10 +226,21 @@ DTWIDGETS_LIB = $(DIST)/lib/libDtWidgets.a XFE_WIDGETS_LIB = $(DIST)/lib/libXfeWidgets.a XFE_WIDGETS_BM_LIB = $(DIST)/lib/libXfeBm.a +DYNAMIC_SYMBOLS_F = -rdynamic # default +ifeq ($(OS_ARCH),SunOS) +ifdef NS_USE_NATIVE +DYNAMIC_SYMBOLS_F = -Bdynamic +else +DYNAMIC_SYMBOLS_F = # nothing for gcc +endif +endif + ifeq ($(OS_ARCH),AIX) NSPR_LIB = else -NSPR_LIB = $(DIST)/lib/libplds21.a $(DIST)/lib/libplc21.a $(DIST)/lib/libmsgc21.a $(DIST)/lib/libnspr21.a +# XXX To a DSO... +#NSPR_LIB = $(DIST)/lib/libplds21.a $(DIST)/lib/libplc21.a $(DIST)/lib/libmsgc21.a $(DIST)/lib/libnspr21.a +BASIC_DSOS += -lplds21 -lplc21 -lmsgc21 -lnspr21 endif ifdef DBMALLOC @@ -282,7 +300,7 @@ ifdef MOZ_LOC_INDEP BASIC_LIBS += $(DIST)/lib/libli.a endif -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM JAVA_JMC = $(DIST)/lib/libjmc.a # XXX To be removed... endif @@ -302,6 +320,8 @@ BASIC_LIBS += \ BASIC_LIBS_2 = \ $(DIST)/lib/lib$(LITE_PREFIX)xp.a \ $(DIST)/lib/libdbm.a \ + $(DIST)/lib/libcaps.a \ + $(DIST)/lib/lib$(LITE_PREFIX)rdf.a \ $(NULL) ifdef MOZ_MAIL_NEWS @@ -379,15 +399,18 @@ ifndef NO_LAYERS BASIC_LIBS += $(DIST)/lib/liblayer.a endif -BASIC_LIBS += $(DIST)/lib/libxpcom.a +BASIC_LIBS += $(DIST)/lib/libxpcom.a \ + $(DIST)/lib/libcaps.a -ifdef JAVA_OR_OJI - -BASIC_LIBS += $(DIST)/lib/libcaps.a +######################################################################## +# Java +# ifdef MOZ_JAVA - +# # Monolithic Java +# + BASIC_LIBS += \ $(DIST)/lib/lib$(LITE_PREFIX)applet.a \ $(DIST)/lib/libjrt.a \ @@ -423,35 +446,52 @@ endif BASIC_LIBS += $(DIST)/lib/libjrt.a -else # MOZ_JAVA +else # !MOZ_JAVA +# # OJI +# + +ifdef MOZ_OJI + BASIC_LIBS += $(DIST)/lib/liboji.a +ifdef NSJVM + ifdef EDITOR BASIC_LIBS += $(DIST)/lib/libedtplug.a endif +BASIC_LIBS += $(DIST)/lib/libsoftupdate.a +else # !NSJVM +BASIC_LIBS += \ + $(DIST)/lib/libstubsj.a \ + $(DIST)/lib/libstubnj.a \ + $(NULL) +endif # !NSJVM -BASIC_LIBS += $(DIST)/lib/libsoftupdate.a \ - $(DIST)/lib/libprgrss.a \ +BASIC_LIBS += $(DIST)/lib/libprgrss.a \ $(NULL) -endif # MOZ_JAVA - -else # JAVA_OR_OJI - +else # !MOZ_OJI # No Monolithic Java, no OJI, just stubs. + BASIC_LIBS += \ $(DIST)/lib/libstubsj.a \ $(DIST)/lib/libstubnj.a \ $(NULL) -endif # JAVA_OR_OJI +endif # !MOZ_OJI +endif # !MOZ_JAVA -BASIC_LIBS += $(DIST)/lib/libzlib.a +# XXX To a DSO... +#BASIC_LIBS += $(DIST)/lib/libzlib.a +BASIC_DSOS += -lzlib ifndef NO_MOCHA -BASIC_LIBS += $(DIST)/lib/libjs.a $(DIST)/lib/libjsj.a $(DIST)/lib/libmocha.a +# XXX To a DSO... +#BASIC_LIBS += $(DIST)/lib/libjs.a $(DIST)/lib/libjsj.a +BASIC_DSOS += -ljs -ljsj +BASIC_LIBS += $(DIST)/lib/libmocha.a endif # Post-Java libs @@ -460,11 +500,7 @@ BASIC_LIBS += $(DIST)/lib/libstyle.a ifdef MOZ_SECURITY BASIC_LIBS += $(DIST)/lib/libjar.a else -EXPORT_LIB = $(DIST)/lib/libhtmldlgs.a -endif - -ifndef MOZ_SECURITY -EXPORT_LIB += $(DIST)/lib/libsecfree.a +EXPORT_LIB = $(DIST)/lib/libhtmldlgs.a $(DIST)/lib/libsecfree.a endif LOCALES = $(LOCALE_MAP) $(MAIL_IM_HACK) $(NEWS_IM_HACK) @@ -573,7 +609,7 @@ MCS_CMD = true # Only IRIX 5.x uses this. EXTRA_POST_LINK_CMD = echo -EXPORT_LDFLAGS = $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) $(OTHER_LIBS) $(NSPR_LIB) +EXPORT_LDFLAGS = $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) $(BASIC_DSOS) $(OTHER_LIBS) $(NSPR_LIB) EXPORT_DEPLIBS = $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) $(NSPR_LIB) DSO_EX_LIBS = $(EXPORT_LDFLAGS:$(DIST)/lib/lib%.a=-l%) @@ -878,7 +914,7 @@ endif EXPORT_LDFLAGS = -z defs -L$(MOTIF)/lib -L$(USRLIBDIR) -R$(MOTIF)/lib \ -R$(USRLIBDIR) $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) \ - $(OTHER_LIBS) $(NSPR_LIB) + $(BASIC_DSOS) $(OTHER_LIBS) $(NSPR_LIB) endif endif @@ -1011,7 +1047,7 @@ $(OBJDIR)/$(DSO_PROGNAME)-export.quantify: $(OBJS) $(EXPORT_OBJS) $(EXPORT_DEPLI $(OBJDIR)/$(XFE_PROGNAME)-export: $(OBJS) $(EXPORT_OBJS) $(EXPORT_DEPLIBS) @$(MAKE_OBJDIR) rm -f $@ - $(CCLD) -o $@ $(LDFLAGS) $(OBJS) $(EXPORT_OBJS) $(EXPORT_LDFLAGS) $(DNS_LIB) + $(CCLD) -o $@ $(DYNAMIC_SYMBOLS_F) $(LDFLAGS) $(OBJS) $(EXPORT_OBJS) $(EXPORT_LDFLAGS) $(DNS_LIB) @$(EXTRA_POST_LINK_CMD) $@ $(OBJDIR)/$(XFE_PROGNAME)-export.pure: $(OBJS) $(EXPORT_OBJS) $(EXPORT_DEPLIBS) diff --git a/cmd/xfe/icons/Makefile b/cmd/xfe/icons/Makefile index 161a5ba2190b..55965a602129 100644 --- a/cmd/xfe/icons/Makefile +++ b/cmd/xfe/icons/Makefile @@ -126,7 +126,7 @@ ICONLIST = $(OBJDIR)/icon.list ICONANIMLIST = $(OBJDIR)/iconanim.list MKICONS_EXE = $(OBJDIR)/mkicons -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM JAVA_JMC = $(DIST)/lib/libjmc.a # XXX To be removed... else JAVA_JMC = $(DIST)/lib/libstubsj.a diff --git a/cmd/xfe/src/Makefile b/cmd/xfe/src/Makefile index 35e5592f795a..f29811250657 100644 --- a/cmd/xfe/src/Makefile +++ b/cmd/xfe/src/Makefile @@ -53,10 +53,17 @@ REQUIRES =\ rdf \ progress \ xpcom \ + plugin \ + plugimpl \ + raptor \ netcnvts \ msg \ - progress \ - plug + progress + +ifdef OJI +REQUIRES += oji \ + ojiimpl +endif CPPSRCS = \ plugin.cpp \ diff --git a/cmd/xfe/src/plugin.cpp b/cmd/xfe/src/plugin.cpp index 2c9520391b34..c051747d37c1 100644 --- a/cmd/xfe/src/plugin.cpp +++ b/cmd/xfe/src/plugin.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -924,28 +924,40 @@ FE_LoadPlugin(void *pdesc, NPNetscapeFuncs *funcs, np_handle* handle) return NULL; } - NP_CREATEPLUGIN npCreatePlugin = -#ifndef NSPR20 - (NP_CREATEPLUGIN)PR_FindSymbol("NP_CreatePlugin", plugin->dlopen_obj); -#else - (NP_CREATEPLUGIN)PR_FindSymbol(plugin->dlopen_obj, "NP_CreatePlugin"); -#endif - if (npCreatePlugin != NULL) { + nsFactoryProc nsGetFactory = + (nsFactoryProc)PR_FindSymbol(plugin->dlopen_obj, "NSGetFactory"); + + if (nsGetFactory != NULL) { + // XXX Figure out where this should go: this seems a + // little late in the game to be creating the plugin + // manager... if (thePluginManager == NULL) { - static NS_DEFINE_IID(kIPluginManagerIID, NP_IPLUGINMANAGER_IID); + static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); if (nsPluginManager::Create(NULL, kIPluginManagerIID, (void**)&thePluginManager) != NS_OK) return NULL; } - NPIPlugin* userPlugin = NULL; - NPPluginError err = npCreatePlugin(thePluginManager, &userPlugin); + + PR_ASSERT(thePluginManager != NULL); + + static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID); + nsIPlugin* userPlugin = NULL; + nsresult err = nsGetFactory(kIPluginIID, (nsIFactory**)&userPlugin); + handle->userPlugin = userPlugin; plugin->handle = handle; - if (err != NPPluginError_NoError || userPlugin == NULL) { - int err = PR_UnloadLibrary(plugin->dlopen_obj); - PR_ASSERT(err == 0); + + if ((err != NS_OK) + || (userPlugin == NULL) + || (userPlugin->Initialize((nsIPluginManager*)thePluginManager) != NS_OK)) { + PR_UnloadLibrary(plugin->dlopen_obj); plugin->dlopen_obj = NULL; return NULL; } + +#ifdef LATER // XXX coming soon... + // add the plugin directory if successful + JVM_AddToClassPathRecursively(csPluginDir); +#endif } else { #ifndef NSPR20 @@ -998,7 +1010,10 @@ FE_UnloadPlugin(void *pdesc, struct _np_handle* handle) if (plugin->handle) { if (plugin->handle->userPlugin) { - NPIPlugin* userPlugin = (NPIPlugin*)plugin->handle->userPlugin; + nsIPlugin* userPlugin = (nsIPlugin*)plugin->handle->userPlugin; + // XXX We should be calling userPlugin->Shutdown() here, + // and then we should ping the lib's NSCanUnload() + // function before actually unloading the library. XP_VERIFY(userPlugin->Release() == 0); plugin->handle = NULL; } diff --git a/config/Linux.mk b/config/Linux.mk index 7a44bc97795f..1baf970ff8f6 100644 --- a/config/Linux.mk +++ b/config/Linux.mk @@ -104,6 +104,7 @@ PORT_FLAGS += -DNO_INT64_T PLATFORM_FLAGS += -DLINUX2_0 BUILD_UNIX_PLUGINS = 1 MKSHLIB = $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) +DSO_BIND_REFERENCES = -Wl,-Bsymbolic ifdef BUILD_OPT OPTIMIZER = -O2 endif diff --git a/config/SunOS5.mk b/config/SunOS5.mk index ac580de67054..14f8adca4c1c 100644 --- a/config/SunOS5.mk +++ b/config/SunOS5.mk @@ -171,6 +171,7 @@ FC_PLATFORM_DIR = SunOS5_sparc endif MKSHLIB = $(LD) $(DSO_LDOPTS) +DSO_BIND_REFERENCES = -Bsymbolic DSO_LDOPTS = -G -L$(MOTIF)/lib -L/usr/openwin/lib DSO_LDFLAGS = diff --git a/config/config.mk b/config/config.mk index 3536dbb4135d..6119b90a947f 100644 --- a/config/config.mk +++ b/config/config.mk @@ -499,6 +499,11 @@ ifdef MOZ_OJI error You can't define both MOZ_JAVA and MOZ_OJI anymore. endif JAVA_OR_OJI = 1 +JAVA_OR_NSJVM = 1 +endif + +ifdef NSJVM +JAVA_OR_NSJVM = 1 endif ifdef MOZ_OJI @@ -506,7 +511,7 @@ DEFINES += -DOJI JAVA_OR_OJI = 1 endif -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM # XXX fix -- su can't depend on java MOZ_SMARTUPDATE = 1 endif diff --git a/config/rules.mk b/config/rules.mk index 728aee1936ae..2acbcf4efb0c 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -59,6 +59,9 @@ # JRI_GEN -- files to run through javah to generate headers and stubs # (output goes into the _jri sub-dir) # j) +# JNI_GEN -- files to run through javah to generate headers and stubs +# (output goes into the _jni sub-dir) +# k) # JMC_GEN -- files to run through jmc to generate headers and stubs # (output goes into the _jmc sub-dir) # @@ -167,7 +170,7 @@ ifndef PACKAGE PACKAGE = . endif -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM ALL_TRASH = $(TARGETS) $(OBJS) $(OBJDIR) LOGS TAGS $(GARBAGE) \ $(NOSUCHFILE) $(JDK_HEADER_CFILES) $(JDK_STUB_CFILES) \ $(JRI_HEADER_CFILES) $(JRI_STUB_CFILES) $(JMC_STUBS) \ @@ -182,13 +185,13 @@ ALL_TRASH = $(TARGETS) $(OBJS) $(OBJDIR) LOGS TAGS $(GARBAGE) \ _gen _stubs $(wildcard gts_tmp_*) endif -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM ifdef JDIRS ALL_TRASH += $(addprefix $(JAVA_DESTPATH)/,$(JDIRS)) endif endif -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM JMC_SUBDIR = _jmc else JMC_SUBDIR = $(LOCAL_JMC_SUBDIR) @@ -198,11 +201,13 @@ ifdef NSBUILDROOT JDK_GEN_DIR = $(XPDIST)/_gen JMC_GEN_DIR = $(XPDIST)/$(JMC_SUBDIR) JRI_GEN_DIR = $(XPDIST)/_jri +JNI_GEN_DIR = $(XPDIST)/_jni JDK_STUB_DIR = $(XPDIST)/_stubs else JDK_GEN_DIR = _gen JMC_GEN_DIR = $(JMC_SUBDIR) JRI_GEN_DIR = _jri +JNI_GEN_DIR = _jni JDK_STUB_DIR = _stubs endif @@ -483,7 +488,7 @@ $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE) $(JMCSRCDIR):: ### JSRCS -- for compiling java files ifneq ($(JSRCS),) -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE) list=`$(PERL) $(DEPTH)/config/outofdate.pl $(PERLARG) \ -d $(JAVA_DESTPATH)/$(PACKAGE) $(JSRCS)`; \ @@ -508,7 +513,7 @@ endif # some builds to run out of memory # ifdef JDIRS -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE) @for d in $(JDIRS); do \ if test -d $$d; then \ @@ -536,7 +541,7 @@ endif # Generate JDK Headers and Stubs into the '_gen' and '_stubs' directory # ifneq ($(JDK_GEN),) -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM ifdef NSBUILDROOT INCLUDES += -I$(JDK_GEN_DIR) -I$(XPDIST) else @@ -568,7 +573,7 @@ ifdef MOZ_GENMAC @echo Generating/Updating JDK stubs for the Mac $(JAVAH) -mac -stubs -d $(DEPTH)/lib/mac/Java/_stubs $(JDK_PACKAGE_CLASSES) endif -endif # JAVA_OR_OJI +endif # JAVA_OR_NSJVM endif # @@ -577,7 +582,7 @@ endif # Generate JRI Headers and Stubs into the 'jri' directory # ifneq ($(JRI_GEN),) -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM ifdef NSBUILDROOT INCLUDES += -I$(JRI_GEN_DIR) -I$(XPDIST) else @@ -609,14 +614,53 @@ ifdef MOZ_GENMAC @echo Generating/Updating JRI stubs for the Mac $(JAVAH) -jri -mac -stubs -d $(DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES) endif -endif # JAVA_OR_OJI +endif # JAVA_OR_NSJVM endif + + +# +# JNI_GEN -- for generating JNI native methods +# +# Generate JNI Headers and Stubs into the 'jni' directory +# +ifneq ($(JNI_GEN),) +ifdef JAVA_OR_NSJVM +ifdef NSBUILDROOT +INCLUDES += -I$(JNI_GEN_DIR) -I$(XPDIST) +else +INCLUDES += -I$(JNI_GEN_DIR) +endif +JNI_PACKAGE_CLASSES = $(JNI_GEN) +JNI_PATH_CLASSES = $(subst .,/,$(JNI_PACKAGE_CLASSES)) +JNI_HEADER_CLASSFILES = $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JNI_PATH_CLASSES)) +JNI_HEADER_CFILES = $(patsubst %,$(JNI_GEN_DIR)/%.h,$(JNI_GEN)) +JNI_STUB_CFILES = $(patsubst %,$(JNI_GEN_DIR)/%.c,$(JNI_GEN)) + +$(JNI_HEADER_CFILES): $(JNI_HEADER_CLASSFILES) + +export:: + @echo Generating/Updating JNI headers + $(JAVAH) -jni -d $(JNI_GEN_DIR) $(JNI_PACKAGE_CLASSES) +ifdef MOZ_GENMAC + @if test ! -d $(DEPTH)/lib/mac/Java/; then \ + echo "!!! You need to have a ns/lib/mac/Java directory checked out."; \ + echo "!!! This allows us to automatically update generated files for the mac."; \ + echo "!!! If you see any modified files there, please check them in."; \ + fi + @echo Generating/Updating JNI headers for the Mac + $(JAVAH) -jni -mac -d $(DEPTH)/lib/mac/Java/_jni $(JNI_PACKAGE_CLASSES) +endif +endif # JAVA_OR_NSJVM +endif # JNI_GEN + + + # # JMC_EXPORT -- for declaring which java classes are to be exported for jmc # ifneq ($(JMC_EXPORT),) -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM JMC_EXPORT_PATHS = $(subst .,/,$(JMC_EXPORT)) JMC_EXPORT_FILES = $(patsubst %,$(JAVA_DESTPATH)/$(PACKAGE)/%.class,$(JMC_EXPORT_PATHS)) @@ -627,7 +671,7 @@ JMC_EXPORT_FILES = $(patsubst %,$(JAVA_DESTPATH)/$(PACKAGE)/%.class,$(JMC_EXPORT # export:: $(JMC_EXPORT_FILES) $(JMCSRCDIR) $(NSINSTALL) -t -m 444 $(JMC_EXPORT_FILES) $(JMCSRCDIR) -endif # JAVA_OR_OJI +endif # JAVA_OR_NSJVM endif # @@ -637,7 +681,7 @@ endif # ifneq ($(JMC_GEN),) INCLUDES += -I$(JMC_GEN_DIR) -I. -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM JMC_HEADERS = $(patsubst %,$(JMC_GEN_DIR)/%.h,$(JMC_GEN)) JMC_STUBS = $(patsubst %,$(JMC_GEN_DIR)/%.c,$(JMC_GEN)) JMC_OBJS = $(patsubst %,$(OBJDIR)/%.o,$(JMC_GEN)) @@ -657,7 +701,7 @@ else endif export:: $(JMC_HEADERS) $(JMC_STUBS) -endif # JAVA_OR_OJI +endif # JAVA_OR_NSJVM endif # @@ -791,3 +835,14 @@ endif # .PHONY: all all_platforms alltags boot clean clobber clobber_all export install libs realclean $(OBJDIR) $(DIRS) +envirocheck:: + @echo ----------------------------------- + @echo "Enviro-Check (tm)" + @echo ----------------------------------- + @echo "MOZILLA_CLIENT = $(MOZILLA_CLIENT)" + @echo "NO_MDUPDATE = $(NO_MDUPDATE)" + @echo "BUILD_OPT = $(BUILD_OPT)" + @echo "MOZ_LITE = $(MOZ_LITE)" + @echo "MOZ_MEDIUM = $(MOZ_MEDIUM)" + @echo ----------------------------------- + diff --git a/include/MANIFEST b/include/MANIFEST index a1359446c21c..b54898329ef5 100644 --- a/include/MANIFEST +++ b/include/MANIFEST @@ -53,8 +53,10 @@ m_cvstrm.h ncompat.h net.h np.h +np2.h npapi.h npassoc.h +npupp.h nsldap.h nslocks.h ntos.h diff --git a/include/libmocha.h b/include/libmocha.h index 60629224ef63..35e7480e6347 100644 --- a/include/libmocha.h +++ b/include/libmocha.h @@ -213,7 +213,12 @@ typedef void (PR_CALLBACK *JSLockReleaseFunc)(void * data); +#ifdef OJI +extern JSBool PR_CALLBACK LM_LockJS(char **errp); +#else extern void PR_CALLBACK LM_LockJS(void); +#endif + extern void PR_CALLBACK LM_UnlockJS(void); extern JSBool PR_CALLBACK LM_AttemptLockJS(JSLockReleaseFunc fn, void * data); extern JSBool PR_CALLBACK LM_ClearAttemptLockJS(JSLockReleaseFunc fn, void * data); diff --git a/include/lo_ele.h b/include/lo_ele.h index 215e0d8e7f14..2aea2bcb3e8f 100644 --- a/include/lo_ele.h +++ b/include/lo_ele.h @@ -983,6 +983,7 @@ struct LO_CommonPluginStruct_struct { #ifdef MOCHA struct JSObject *mocha_object; #endif + int16 sub_type; }; struct LO_BuiltinStruct_struct { @@ -1001,12 +1002,12 @@ struct LO_BuiltinStruct_struct { void * FE_Data; void *session_data; PA_Block builtin_src; -#ifndef OJI +#if defined(OJI) + struct lo_NVList attributes; +#else int32 attribute_cnt; char **attribute_list; char **value_list; -#else - lo_NVList attributes; #endif /* OJI */ int32 alignment; int32 border_width; diff --git a/include/net.h b/include/net.h index 3347606fd3ea..7856e5cd8cff 100644 --- a/include/net.h +++ b/include/net.h @@ -658,7 +658,6 @@ typedef struct _mdata { #define APPLICATION_WWW_FORM_URLENCODED "application/x-www-form-urlencoded" #define APPLICATION_OLEOBJECT "application/oleobject" #define APPLICATION_OLEOBJECT2 "application/x-oleobject" -#define APPLICATION_JAVAVM "application/java-vm" #define APPLICATION_JAVAARCHIVE "application/java-archive" #define APPLICATION_MARIMBA "application/marimba" #define APPLICATION_XMARIMBA "application/x-marimba" diff --git a/include/np.h b/include/np.h index 70f5f349b744..a04a75f7906b 100644 --- a/include/np.h +++ b/include/np.h @@ -18,7 +18,7 @@ /* - * np.h $Revision: 3.3 $ + * np.h $Revision: 3.4 $ * Prototypes for functions exported by libplugin and called by the FEs or other XP libs. * Prototypes for functions exported by the FEs and called by libplugin are in nppg.h. */ @@ -129,7 +129,17 @@ extern NPError NPL_RegisterAppletType(NPMIMEType type); #endif /* ANTHRAX */ PR_EXTERN(void) NPL_SetPluginWindow(void *data); -PR_EXTERN(struct NPIPlugin*) NPL_LoadPluginByType(const char* typeAttribute); +PR_EXTERN(struct nsIPlugin*) NPL_LoadPluginByType(const char* typeAttribute); + +/* + * This callback is installed by the FE to handle the nsIPluginManager2::ProcessNextEvent + * operation. The result parameter should return PR_TRUE if called on the mozilla thread + * (unlike the old nsn_TickleHookProcPtr which returned false (I think)). + */ +typedef PRBool (PR_CALLBACK* NPL_ProcessNextEventProc)(void* data); + +PR_EXTERN(void) +NPL_InstallProcessNextEventProc(NPL_ProcessNextEventProc proc, void* data); XP_END_PROTOS diff --git a/include/np2.h b/include/np2.h index 959202533ce5..7b41fcea9f2b 100644 --- a/include/np2.h +++ b/include/np2.h @@ -18,7 +18,6 @@ /* - * np2.h $Revision: 3.1 $ * Prototypes for functions exported by OJI based libplugin and called by the FEs or other XP libs. */ @@ -37,7 +36,7 @@ PR_EXTERN(const char *) NPL_GetText(struct nsIPluginInstance *); PR_EXTERN(jobject) NPL_GetJavaObject(struct nsIPluginInstance *); PR_EXTERN(void ) NPL_Release(struct nsISupports *); PR_EXTERN(XP_Bool) NPL_IsJVMAndMochaPrefsEnabled(void); -PR_EXTERN(void)NPL_JSJInit(void); +PR_EXTERN(PRBool)NPL_JSJInit(void); PR_EXTERN(JNIEnv *)NPL_EnsureJNIExecEnv(PRThread* thread); #endif /* _NP2_H */ diff --git a/include/npapi.h b/include/npapi.h index 208b089cd7a5..98a741acb8b5 100644 --- a/include/npapi.h +++ b/include/npapi.h @@ -18,7 +18,7 @@ /* - * npapi.h $Revision: 3.2 $ + * npapi.h $Revision: 3.3 $ * Netscape client plug-in API spec */ @@ -133,22 +133,29 @@ RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" } #ifndef _UINT16 typedef unsigned short uint16; #endif + #ifndef _UINT32 -#if defined(__alpha) +# ifndef NSPR20 +# if defined(__alpha) typedef unsigned int uint32; -#else /* __alpha */ +# else /* __alpha */ typedef unsigned long uint32; -#endif /* __alpha */ +# endif /* __alpha */ +# endif /* NSPR20 */ #endif + #ifndef _INT16 typedef short int16; #endif + #ifndef _INT32 -#if defined(__alpha) +# ifndef NSPR20 +# if defined(__alpha) typedef int int32; -#else /* __alpha */ +# else /* __alpha */ typedef long int32; -#endif /* __alpha */ +# endif /* __alpha */ +# endif /* NSPR20 */ #endif #ifndef FALSE @@ -513,11 +520,11 @@ void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint); int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event); void NP_LOADDS NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData); -jref NP_LOADDS NPP_GetJavaClass(void); -NPError NP_LOADDS NPP_GetValue(void *instance, NPPVariable variable, - void *value); -NPError NP_LOADDS NPP_SetValue(void *instance, NPNVariable variable, - void *value); +jref NP_LOADDS NPP_GetJavaClass(void); +NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, + void *value); +NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, + void *value); /* * NPN_* functions are provided by the navigator and called by the plugin. diff --git a/js/Makefile b/js/Makefile index efdae8b4b1f0..588681b1fc40 100644 --- a/js/Makefile +++ b/js/Makefile @@ -34,6 +34,13 @@ DEPTH = .. # See top-level makefile for details # -DIRS = src jsj tests +ifndef MOZ_OJI +DIRS = src \ + jsj \ + tests +else +DIRS = src \ + tests +endif include $(DEPTH)/config/rules.mk diff --git a/js/jsj/stubs.c b/js/jsj/stubs.c index 17cd3b686528..0578b01c3be4 100644 --- a/js/jsj/stubs.c +++ b/js/jsj/stubs.c @@ -23,6 +23,7 @@ !!! HEED THE WARNING. */ +#if !defined(XP_MAC) #if defined (JAVA) || defined(OJI) #define IMPLEMENT_netscape_javascript_JSObject #define IMPLEMENT_netscape_javascript_JSException @@ -40,3 +41,4 @@ void _java_javascript_init(void) { } #endif /* defined (JAVA) */ +#endif /* !defined(XP_MAC) */ diff --git a/js/makefile.win b/js/makefile.win index d6812555e1f1..51ec71dd6d60 100644 --- a/js/makefile.win +++ b/js/makefile.win @@ -16,7 +16,10 @@ DEPTH=.. DIRS=src \ - jsj +!ifdef MOZ_JAVA + jsj \ +!endif +$(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/js/src/MANIFEST b/js/src/MANIFEST index 629537726903..2b198c54ee07 100644 --- a/js/src/MANIFEST +++ b/js/src/MANIFEST @@ -2,6 +2,7 @@ # jsapi.h +jspubtd.h jsarray.h jsatom.h jsbool.h diff --git a/js/src/Makefile b/js/src/Makefile index b2efa5bba4f6..15a8d6d78d32 100644 --- a/js/src/Makefile +++ b/js/src/Makefile @@ -16,6 +16,8 @@ DEPTH = ../.. +DIRS = liveconnect + LIBRARY_NAME = js ifeq ($(subst /,_,$(shell uname -s)),OS2) @@ -101,8 +103,6 @@ endif include $(DEPTH)/config/rules.mk -export:: install - ifndef BUILD_OPT MOCHAFILE = 1 endif diff --git a/js/src/jsobj.c b/js/src/jsobj.c index 52812c0ba746..ef246403f565 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -63,6 +63,10 @@ js_DropProperty(JSContext *cx, JSObject *obj, JSProperty *prop); #define NATIVE_DROP_PROPERTY NULL #endif +#ifdef XP_MAC +#pragma export on +#endif + JS_FRIEND_DATA(JSObjectOps) js_ObjectOps = { js_NewObjectMap, js_DestroyObjectMap, #if defined JS_THREADSAFE && defined DEBUG @@ -79,6 +83,10 @@ JS_FRIEND_DATA(JSObjectOps) js_ObjectOps = { NULL, js_HasInstance }; +#ifdef XP_MAC +#pragma export off +#endif + JSClass js_ObjectClass = { js_Object_str, 0, diff --git a/js/src/jsopcode.c b/js/src/jsopcode.c index d6d8a4f4ed0f..db71cbe1fe93 100644 --- a/js/src/jsopcode.c +++ b/js/src/jsopcode.c @@ -1915,7 +1915,7 @@ js_DecompileFunction(JSPrinter *jp, JSFunction *fun, JSBool newlines) } if (atom == NULL) break; - js_printf(jp, (i > 0 ? ", %s" : "%s"), ATOM_BYTES(atom)); + js_printf(jp, (i > 0 ? ", %s" : "%s"), ATOM_BYTES(atom)); } } js_puts(jp, ") {\n"); diff --git a/js/src/jsscan.c b/js/src/jsscan.c index a83619678b38..8867d0757797 100644 --- a/js/src/jsscan.c +++ b/js/src/jsscan.c @@ -300,11 +300,11 @@ GetChar(JSTokenStream *ts) int32 c; ptrdiff_t len, olen; jschar *nl; - + if (ts->ungetpos != 0) { c = ts->ungetbuf[--ts->ungetpos]; } else { - if (ts->linebuf.ptr == ts->linebuf.limit) { + if (ts->linebuf.ptr == ts->linebuf.limit) { len = PTRDIFF(ts->userbuf.limit, ts->userbuf.ptr, jschar); if (len <= 0) { #ifdef JSFILE diff --git a/js/src/jsstddef.h b/js/src/jsstddef.h index 698ba9353b98..2fbed06db006 100644 --- a/js/src/jsstddef.h +++ b/js/src/jsstddef.h @@ -1,4 +1,26 @@ -/*stddef inclusion here to first declare ptrdif as a signed long instead of a signed int*/ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (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 Communicator client 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. + */ + +/* + * stddef inclusion here to first declare ptrdif as a signed long instead of a + * signed int. + */ #ifdef _WINDOWS # ifndef XP_WIN @@ -33,7 +55,7 @@ typedef long ptrdiff_t; #define PTRDIFF(p1, p2, type) \ ((p1) - (p2)) - + #endif #include diff --git a/js/src/liveconnect/Makefile b/js/src/liveconnect/Makefile index 655872511eda..93dd6cc201ae 100644 --- a/js/src/liveconnect/Makefile +++ b/js/src/liveconnect/Makefile @@ -27,12 +27,13 @@ DIRS = classes endif endif +ifdef MOZ_OJI + MODULE = java LIBRARY_NAME = jsj REQUIRES = java js applet nspr img util layer -ifdef MOZ_OJI CSRCS = jsj.c \ jsj_JSObject.c \ jsj_JavaArray.c \ @@ -46,11 +47,7 @@ CSRCS = jsj.c \ jsj_hash.c \ jsj_method.c \ jsj_utils.c -else -CSRCS = \ - jsjava.c \ - jsStubs.c \ - $(NULL) + endif ifdef MOZ_OJI @@ -96,8 +93,6 @@ else $(OBJDIR)/stubs.o: endif -export:: install - ifndef REGENERATE export:: jsj10.jar diff --git a/js/src/liveconnect/jsj.c b/js/src/liveconnect/jsj.c index 75fc8f075dcc..5a2a5fcdf9a4 100644 --- a/js/src/liveconnect/jsj.c +++ b/js/src/liveconnect/jsj.c @@ -374,7 +374,7 @@ JSJ_ConnectToJavaVM(JavaVM *java_vm_arg, const char *user_classpath) return NULL; } } -#ifndef OJI +#if !defined(OJI) && !defined(XP_MAC) else { /* No Java VM supplied, so create our own */ JDK1_1InitArgs vm_args; diff --git a/js/src/liveconnect/jsj10.jar b/js/src/liveconnect/jsj10.jar index 0a850ad2ea82..657ba9fc0284 100644 Binary files a/js/src/liveconnect/jsj10.jar and b/js/src/liveconnect/jsj10.jar differ diff --git a/js/src/liveconnect/jsj_JavaClass.c b/js/src/liveconnect/jsj_JavaClass.c index 5a46df1d79b2..a5f3c15b9f0c 100644 --- a/js/src/liveconnect/jsj_JavaClass.c +++ b/js/src/liveconnect/jsj_JavaClass.c @@ -236,7 +236,7 @@ JavaClass_finalize(JSContext *cx, JSObject *obj) if (!jEnv) return; - printf("Finalizing %s\n", class_descriptor->name); + /* printf("Finalizing %s\n", class_descriptor->name); */ jsj_ReleaseJavaClassDescriptor(cx, jEnv, class_descriptor); } diff --git a/js/src/liveconnect/jsj_JavaObject.c b/js/src/liveconnect/jsj_JavaObject.c index 04004f841132..c28cd44d3add 100644 --- a/js/src/liveconnect/jsj_JavaObject.c +++ b/js/src/liveconnect/jsj_JavaObject.c @@ -582,7 +582,7 @@ static JSBool JavaObject_defaultValue(JSContext *cx, JSObject *obj, JSType type, jsval *vp) { /* printf("In JavaObject_defaultValue()\n"); */ - return JavaObject_convert(cx, obj, JSTYPE_STRING, vp); + return JavaObject_convert(cx, obj, type, vp); } static JSBool diff --git a/js/src/makefile.win b/js/src/makefile.win index d862992d358d..5a03571e17c3 100644 --- a/js/src/makefile.win +++ b/js/src/makefile.win @@ -21,6 +21,8 @@ #//------------------------------------------------------------------------ DEPTH=..\.. +DIRS = liveconnect + #//------------------------------------------------------------------------ #// #// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...) diff --git a/js/src/prarena.c b/js/src/prarena.c index db075291f192..b1543c05da7a 100644 --- a/js/src/prarena.c +++ b/js/src/prarena.c @@ -21,6 +21,7 @@ * "Fast Allocation and Deallocation of Memory Based on Object Lifetimes" * David R. Hanson, Software -- Practice and Experience, Vol. 20(1). */ +#include "jsstddef.h" #include #include #include "prtypes.h" diff --git a/js/src/prdtoa.c b/js/src/prdtoa.c index 796fd375d000..c0402c0941cb 100644 --- a/js/src/prdtoa.c +++ b/js/src/prdtoa.c @@ -1,11 +1,25 @@ -/* -*- Mode: C; tab-width: 8 -*- - * Copyright © 1996, 1997, 1998 Netscape Communications Corporation, - * All Rights Reserved. +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. 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 this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. */ /* * Portable double to alphanumeric string and back converters. */ +#include "jsstddef.h" #include "prtypes.h" #include "prdtoa.h" #include "prprf.h" @@ -2538,7 +2552,7 @@ PR_cnvtf(char *buf,int bufsz, int prcsn,double fval) if(decpt == 9999){ while((*bufp++ = *nump++) != 0) ; - return; + goto done; } if(decpt > (prcsn+1) || decpt < -(prcsn-1) || decpt < -5){ diff --git a/js/src/prdtoa.h b/js/src/prdtoa.h index 44cb42bd9e77..c7fb6943e5f0 100644 --- a/js/src/prdtoa.h +++ b/js/src/prdtoa.h @@ -1,6 +1,19 @@ -/* -*- Mode: C; tab-width: 8 -*- - * Copyright © 1996, 1997, 1998 Netscape Communications Corporation, - * All Rights Reserved. +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. 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 this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. */ #ifndef prdtoa_h___ diff --git a/lib/Makefile b/lib/Makefile index 74e3626d320d..48273b9985a2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -35,7 +35,7 @@ ifdef MOZ_NEO DIRS += libneo endif -DIRS += libparse plugin xlate xp +DIRS += libparse xlate xp ifdef MOZ_MAIL_NEWS DIRS += libaddr libmime diff --git a/lib/layout/laybuiltin.c b/lib/layout/laybuiltin.c index 8d365dcd8db9..24d4964c4bab 100644 --- a/lib/layout/laybuiltin.c +++ b/lib/layout/laybuiltin.c @@ -39,6 +39,20 @@ void lo_FillInBuiltinGeometry(lo_DocState *state, LO_BuiltinStruct *builtin, void lo_UpdateStateAfterBuiltinLayout (lo_DocState *state, LO_BuiltinStruct *builtin, int32 line_inc, int32 baseline_inc); +/** + * Some accessor macros, to manage the OJI changes. + */ + +#if defined(OJI) +#define BUILTIN_ATTRIBUTE_COUNT(builtin) (builtin)->attributes.n +#define BUILTIN_ATTRIBUTE_NAMES(builtin) (builtin)->attributes.names +#define BUILTIN_ATTRIBUTE_VALUES(builtin) (builtin)->attributes.values +#else +#define BUILTIN_ATTRIBUTE_COUNT(builtin) (builtin)->attribute_cnt +#define BUILTIN_ATTRIBUTE_NAMES(builtin) (builtin)->attribute_list +#define BUILTIN_ATTRIBUTE_VALUES(builtin) (builtin)->value_list +#endif + void lo_FormatBuiltin (MWContext *context, lo_DocState *state, PA_Tag *tag) { @@ -74,12 +88,13 @@ lo_FormatBuiltin (MWContext *context, lo_DocState *state, PA_Tag *tag) builtin->height = 0; builtin->next = NULL; builtin->prev = NULL; - builtin->attribute_cnt = 0; - builtin->attribute_list = NULL; - builtin->value_list = NULL; - - builtin->attribute_cnt = PA_FetchAllNameValues (tag, - &(builtin->attribute_list), &(builtin->value_list), CS_FE_ASCII); + + BUILTIN_ATTRIBUTE_COUNT(builtin) = 0; + BUILTIN_ATTRIBUTE_NAMES(builtin) = NULL; + BUILTIN_ATTRIBUTE_VALUES(builtin) = NULL; + + BUILTIN_ATTRIBUTE_COUNT(builtin) = PA_FetchAllNameValues (tag, + &BUILTIN_ATTRIBUTE_NAMES(builtin), &BUILTIN_ATTRIBUTE_VALUES(builtin), CS_FE_ASCII); lo_FormatBuiltinInternal (context, state, tag, builtin, FALSE, FALSE); } @@ -87,18 +102,18 @@ lo_FormatBuiltin (MWContext *context, lo_DocState *state, PA_Tag *tag) void lo_appendParams (LO_BuiltinStruct *builtin, uint32 param_count, char **param_names, char **param_values) { - int32 newcount = builtin->attribute_cnt + param_count; - int32 n = builtin->attribute_cnt; - builtin->attribute_list = (char**)XP_REALLOC(builtin->attribute_list, + int32 newcount = BUILTIN_ATTRIBUTE_COUNT(builtin) + param_count; + int32 n = BUILTIN_ATTRIBUTE_COUNT(builtin); + BUILTIN_ATTRIBUTE_NAMES(builtin) = (char**)XP_REALLOC(BUILTIN_ATTRIBUTE_NAMES(builtin), newcount * sizeof(char*)); - builtin->value_list = (char**)XP_REALLOC(builtin->value_list, + BUILTIN_ATTRIBUTE_VALUES(builtin) = (char**)XP_REALLOC(BUILTIN_ATTRIBUTE_VALUES(builtin), newcount * sizeof(char*)); while (n < newcount) { - *(builtin->attribute_list + n) = XP_STRDUP(*(param_names + n - builtin->attribute_cnt)); - *(builtin->value_list + n) = XP_STRDUP(*(param_values + n - builtin->attribute_cnt)); + *(BUILTIN_ATTRIBUTE_NAMES(builtin) + n) = XP_STRDUP(*(param_names + n - BUILTIN_ATTRIBUTE_COUNT(builtin))); + *(BUILTIN_ATTRIBUTE_VALUES(builtin) + n) = XP_STRDUP(*(param_values + n - BUILTIN_ATTRIBUTE_COUNT(builtin))); n++; } - builtin->attribute_cnt = builtin->attribute_cnt + param_count; + BUILTIN_ATTRIBUTE_COUNT(builtin) = BUILTIN_ATTRIBUTE_COUNT(builtin) + param_count; } @@ -115,12 +130,12 @@ lo_FormatBuiltinObject (MWContext *context, lo_DocState* state, printf ("lo_FormatBuiltinObject\n"); #endif - builtin->attribute_cnt = 0; - builtin->attribute_list = NULL; - builtin->value_list = NULL; + BUILTIN_ATTRIBUTE_COUNT(builtin) = 0; + BUILTIN_ATTRIBUTE_NAMES(builtin) = NULL; + BUILTIN_ATTRIBUTE_VALUES(builtin) = NULL; - builtin->attribute_cnt = PA_FetchAllNameValues (tag, - &(builtin->attribute_list), &(builtin->value_list), CS_FE_ASCII); + BUILTIN_ATTRIBUTE_COUNT(builtin) = PA_FetchAllNameValues (tag, + &(BUILTIN_ATTRIBUTE_NAMES(builtin)), &(BUILTIN_ATTRIBUTE_VALUES(builtin)), CS_FE_ASCII); if (param_count > 0) lo_appendParams(builtin, param_count, param_names, param_values); lo_FormatBuiltinInternal (context, state, tag, builtin, TRUE, streamStarted); @@ -206,7 +221,7 @@ lo_FormatBuiltinInternal (MWContext *context, lo_DocState *state, PA_Tag *tag, builtin->ele_attrmask |= LO_ELE_STREAM_STARTED; /* Convert any js in the values */ - lo_ConvertAllValues (context, builtin->value_list, builtin->attribute_cnt, + lo_ConvertAllValues (context, BUILTIN_ATTRIBUTE_VALUES(builtin), BUILTIN_ATTRIBUTE_COUNT(builtin), tag->newline_count); /* double-counting builtins? XXX */ diff --git a/lib/layout/layembed.c b/lib/layout/layembed.c index bfc8fc6b552e..5e66bd95add7 100644 --- a/lib/layout/layembed.c +++ b/lib/layout/layembed.c @@ -23,6 +23,7 @@ #include "layout.h" #include "laylayer.h" #include "np.h" +#include "np2.h" #include "laystyle.h" #include "layers.h" @@ -290,7 +291,13 @@ lo_FormatEmbedObject(MWContext* context, lo_DocState* state, #endif #ifdef OJI - /* XXX */ + for (count = 0; count < (uint32)embed->attributes.n; count++) + { + if ( (XP_STRCASECMP(embed->attributes.names[count], PARAM_MAYSCRIPT) == 0) + &&(embed->attributes.values[count] == NULL) ) { + StrAllocCopy(embed->attributes.values[count], "true"); + } + } #else /* * Look through the parameters and replace "id" @@ -755,57 +762,70 @@ lo_FormatEmbedInternal(MWContext *context, lo_DocState *state, PA_Tag *tag, } /* - * Put the embed onto the embed list for later - * possible reflection. + * Put embed onto the embed list and applets into applet list + * for later possible reflection. */ - doc_lists = lo_GetCurrentDocLists(state); - if (state->in_relayout) { - int32 i, count; - LO_EmbedStruct *prev_embed, *cur_embed; + { + int32 i, count, *pDoclistCount; + LO_EmbedStruct *prev_embed, *cur_embed; + LO_CommonPluginStruct **ppDoclistList; + doc_lists = lo_GetCurrentDocLists(state); + if( embed->objTag.sub_type == LO_JAVA ) + { + cur_embed = (LO_EmbedStruct *)doc_lists->applet_list; + pDoclistCount = &doc_lists->applet_list_count; + ppDoclistList = (LO_CommonPluginStruct **)&doc_lists->applet_list; + } + else + { + cur_embed = doc_lists->embed_list; + pDoclistCount = &doc_lists->embed_list_count; + ppDoclistList = (LO_CommonPluginStruct **)&doc_lists->embed_list; + } + if (state->in_relayout) { - /* - * In the interest of changing as little as possible, I'm not - * going to change the embed_list to be in the order of layout - * (it is currently in reverse order). Instead, we do what - * everybody else does - iterate till the end of the list to get - * find an element with the correct index. - * If we're in table relayout, we need to replace the element - * of the same index in this list with the new layout element - * to prevent multiple reflection. - */ - count = 0; - cur_embed = doc_lists->embed_list; - while (cur_embed) { - cur_embed = cur_embed->nextEmbed; - count++; - } + /* + * In the interest of changing as little as possible, I'm not + * going to change the embed_list to be in the order of layout + * (it is currently in reverse order). Instead, we do what + * everybody else does - iterate till the end of the list to get + * find an element with the correct index. + * If we're in table relayout, we need to replace the element + * of the same index in this list with the new layout element + * to prevent multiple reflection. + */ + count = 0; - /* reverse order... */ - prev_embed = NULL; - cur_embed = doc_lists->embed_list; - for (i = count-1; i >= 0; i--) { - if (i == doc_lists->embed_list_count) { - /* Copy over the mocha object (it might not exist) */ - embed->objTag.mocha_object = cur_embed->objTag.mocha_object; + /* reverse order... */ + prev_embed = NULL; + while (cur_embed) { + cur_embed = cur_embed->nextEmbed; + count++; + } + for (i = count-1; i >= 0; i--) { + if (i == *pDoclistCount) { + /* Copy over the mocha object (it might not exist) */ + embed->objTag.mocha_object = cur_embed->objTag.mocha_object; - embed->nextEmbed = cur_embed->nextEmbed; + embed->nextEmbed = cur_embed->nextEmbed; - /* Replace the old embed with the new one */ - if (prev_embed == NULL) - doc_lists->embed_list = embed; - else - prev_embed->nextEmbed = embed; - doc_lists->embed_list_count++; - break; - } - prev_embed = cur_embed; - cur_embed = cur_embed->nextEmbed; - } - } - else { - embed->nextEmbed = doc_lists->embed_list; - doc_lists->embed_list = embed; - doc_lists->embed_list_count++; + /* Replace the old embed with the new one */ + if (prev_embed == NULL) + *ppDoclistList = (LO_CommonPluginStruct *)embed; + else + prev_embed->nextEmbed = embed; + (*pDoclistCount)++; + break; + } + prev_embed = cur_embed; + cur_embed = cur_embed->nextEmbed; + } + } + else { + embed->nextEmbed = (LO_EmbedStruct *)*ppDoclistList; + *ppDoclistList = (LO_CommonPluginStruct *)embed; + (*pDoclistCount)++; + } } /* diff --git a/lib/layout/layform.c b/lib/layout/layform.c index 0adb38771c2a..0493059bf854 100644 --- a/lib/layout/layform.c +++ b/lib/layout/layform.c @@ -2885,7 +2885,7 @@ lo_get_form_element_data(MWContext *context, type = (uint8)form_data->type; } break; -#ifdef JAVA +#if defined(JAVA ) || defined(OJI) case FORM_TYPE_OBJECT: { lo_FormElementObjectData *form_data; @@ -2897,7 +2897,27 @@ lo_get_form_element_data(MWContext *context, char *vstr; name = lo_dup_block(form_data->name); +#ifdef OJI + { +#include "np.h" +#include "np2.h" + NPEmbeddedApp *embed = (NPEmbeddedApp*) form_data->object->objTag.FE_Data; + if (embed) { + struct nsIPluginInstance *pNPI = NPL_GetOJIPluginInstance(embed); + object_value = NPL_GetText(pNPI); + NPL_Release((struct nsISupports *)pNPI); + } + } + if (object_value != NULL) + { + value = PA_ALLOC(XP_STRLEN(object_value) + 1); + PA_LOCK(vstr, char *, value); + XP_STRCPY(vstr, object_value); + PA_UNLOCK(value); + XP_FREE(object_value); + } +#else object_value = LJ_Applet_GetText(form_data->object->objTag.session_data); value = PA_ALLOC(XP_STRLEN(object_value) + 1); if (value != NULL) @@ -2907,6 +2927,7 @@ lo_get_form_element_data(MWContext *context, PA_UNLOCK(value); } XP_FREE(object_value); +#endif type = (uint8)form_data->type; } diff --git a/lib/layout/laymocha.c b/lib/layout/laymocha.c index 1a2539e5712a..2c8ef9449836 100644 --- a/lib/layout/laymocha.c +++ b/lib/layout/laymocha.c @@ -26,8 +26,11 @@ #include "laylayer.h" #include "pa_parse.h" #include "libevent.h" -#ifdef JAVA +#if defined (JAVA) #include "jsjava.h" +#elif defined (OJI) +#include "jsjava.h" +#include "np2.h" #endif #include "layers.h" @@ -557,7 +560,7 @@ LO_EnumerateLinks(MWContext *context, int32 layer_id) return count; } -#ifdef JAVA +#if defined(JAVA) || defined (OJI) LO_JavaAppStruct * LO_GetAppletByIndex(MWContext *context, int32 layer_id, uint index) { @@ -566,9 +569,15 @@ LO_GetAppletByIndex(MWContext *context, int32 layer_id, uint index) int i, count; lo_DocLists *doc_lists; + +#ifdef OJI + if (!NPL_IsJVMAndMochaPrefsEnabled()) + return NULL; +#else /* XXX */ if (!JSJ_IsEnabled()) return NULL; +#endif top_state = lo_GetTopState(context); if (top_state == NULL) @@ -604,9 +613,15 @@ LO_EnumerateApplets(MWContext *context, int32 layer_id) LO_JavaAppStruct *applet; lo_DocLists *doc_lists; +#ifdef OJI + if (!NPL_IsJVMAndMochaPrefsEnabled()) + return NULL; +#else /* XXX */ if (!JSJ_IsEnabled()) - return 0; + return NULL; +#endif + top_state = lo_GetMochaTopState(context); if (top_state == NULL) @@ -643,9 +658,15 @@ LO_GetEmbedByIndex(MWContext *context, int32 layer_id, uint index) int i, count; lo_DocLists *doc_lists; +#ifdef OJI + if (!NPL_IsJVMAndMochaPrefsEnabled()) + return NULL; +#else /* XXX */ if (!JSJ_IsEnabled()) - return NULL; + return 0; +#endif + top_state = lo_GetTopState(context); if (top_state == NULL) @@ -681,9 +702,14 @@ LO_EnumerateEmbeds(MWContext *context, int32 layer_id) LO_EmbedStruct *embed; lo_DocLists *doc_lists; +#ifdef OJI + if (!NPL_IsJVMAndMochaPrefsEnabled()) + return NULL; +#else /* XXX */ if (!JSJ_IsEnabled()) - return 0; + return NULL; +#endif top_state = lo_GetMochaTopState(context); if (top_state == NULL) diff --git a/lib/layout/layobj.c b/lib/layout/layobj.c index 20fbbd83bdc7..b7766d853a61 100644 --- a/lib/layout/layobj.c +++ b/lib/layout/layobj.c @@ -55,6 +55,7 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag) LO_ObjectStruct* object; PA_Block buff; int16 type = LO_NONE; + int16 sub_type = LO_NONE; char* str; char* pluginName; @@ -191,7 +192,10 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag) /* It's a Java class */ #ifdef OJI if (type == LO_NONE) - type = LO_EMBED; + { + type = LO_EMBED; + sub_type = LO_JAVA; + } else if (type != LO_EMBED) /* XXX */ #else if (type == LO_NONE) @@ -229,10 +233,19 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag) PA_LOCK(str, char *, buff); if ((pluginName = NPL_FindPluginEnabledForType(str)) != NULL) { - XP_FREE(pluginName); + XP_FREE(pluginName); /* It's a plug-in */ if (type == LO_NONE) + { type = LO_EMBED; +#ifdef OJI +#define JAVA_PLUGIN_MIMETYPE "application/x-java-vm" + if (XP_STRCMP(JAVA_PLUGIN_MIMETYPE, str)==0) + { + sub_type = LO_JAVA; + } +#endif + } else if (type != LO_EMBED) type = LO_UNKNOWN; } @@ -328,6 +341,10 @@ lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag) if (type == LO_EMBED) { object->lo_element.lo_plugin.type = LO_EMBED; + if(sub_type == LO_JAVA) + { + object->lo_element.lo_plugin.sub_type = LO_JAVA; + } } else if (type == LO_BUILTIN) { @@ -883,20 +900,20 @@ lo_ProcessObjectTag(MWContext* context, lo_DocState* state, PA_Tag* tag, XP_Bool if (object->lo_element.lo_plugin.type == LO_EMBED) { lo_FormatEmbedObject(context, - state, - top->clone_tag, - (LO_EmbedStruct*) object, - FALSE, /* Stream not started */ + state, + top->clone_tag, + (LO_EmbedStruct*) object, + FALSE, /* Stream not started */ #ifdef OJI - top->parameters.n, - top->parameters.names, - top->parameters.values); - top->formatted_object = TRUE; - LO_NVList_Init( &top->parameters ); + top->parameters.n, + top->parameters.names, + top->parameters.values); + top->formatted_object = TRUE; + LO_NVList_Init( &top->parameters ); #else - top->param_count, - top->param_names, - top->param_values); + top->param_count, + top->param_names, + top->param_values); top->formatted_object = TRUE; top->param_count = 0; top->param_names = NULL; diff --git a/lib/layout/laytags.c b/lib/layout/laytags.c index ef27a883527a..925675c34b09 100644 --- a/lib/layout/laytags.c +++ b/lib/layout/laytags.c @@ -6794,7 +6794,6 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type)); if(buff) { PA_LOCK(str, char *, buff); - lo_AddParam(tag, "DATA", str); lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE); PA_UNLOCK(buff); diff --git a/lib/libmocha/Makefile b/lib/libmocha/Makefile index 9e6ce7705282..e93a23fa3e4e 100644 --- a/lib/libmocha/Makefile +++ b/lib/libmocha/Makefile @@ -23,7 +23,7 @@ MODULE = mocha LIBRARY_NAME = mocha REQUIRES = lay parse img js style layer applet dbm nspr security \ - htmldlgs util jtools pref java libreg softupdt jsdebug netcache network httpurl + htmldlgs util jtools pref caps java libreg softupdt jsdebug netcache network httpurl plugin plugimpl ifdef MOZ_SECURITY REQUIRES += jar @@ -68,14 +68,13 @@ include $(DEPTH)/config/rules.mk DEFINES += -DDLL_SUFFIX=\"$(DLL_SUFFIX)\" -EMBED_CFLAGS = $(CFLAGS) -I$(DEPTH)/lib/plugin TAINT_CFLAGS = $(CFLAGS) -I$(DEPTH)/lib/libjar -I$(DEPTH)/sun-java/netscape/security/_jri \ -I$(DEPTH)/dist/public/security ifneq ($(OS_ARCH),OS2) $(OBJDIR)/lm_embed.o: lm_embed.c @$(MAKE_OBJDIR) - $(CC) -o $@ -c $(EMBED_CFLAGS) $< + $(CC) -o $@ -c $(CFLAGS) $< $(OBJDIR)/lm_taint.o: lm_taint.c @$(MAKE_OBJDIR) @@ -84,7 +83,7 @@ $(OBJDIR)/lm_taint.o: lm_taint.c else $(OBJDIR)/lm_embed.o: lm_embed.c @$(MAKE_OBJDIR) - $(CC) -Fo$@ -c $(EMBED_CFLAGS) $< + $(CC) -Fo$@ -c $(CFLAGS) $< $(OBJDIR)/lm_taint.o: lm_taint.c @$(MAKE_OBJDIR) diff --git a/lib/libmocha/et_mocha.c b/lib/libmocha/et_mocha.c index dbcba2095c23..1d750fd40a28 100644 --- a/lib/libmocha/et_mocha.c +++ b/lib/libmocha/et_mocha.c @@ -751,13 +751,14 @@ et_reflect_handler(Reflect_Event * e) switch(e->type) { case LM_APPLETS: -#ifdef JAVA +#if defined(JAVA) || defined(OJI) + LM_ReflectApplet(e->ce.context, (LO_JavaAppStruct *) e->lo_ele, e->pa_tag, e->layer_id, e->index); #endif break; case LM_EMBEDS: -#ifdef JAVA +#if defined(JAVA) || defined(OJI) LM_ReflectEmbed(e->ce.context, e->lo_ele, e->pa_tag, e->layer_id, e->index); #endif @@ -2193,7 +2194,13 @@ et_FinishMochaHandler(JSEvent * e) lm_crippled_decoder = 0; } -#ifdef JAVA +#if defined(OJI) + /* + =-= sudu Ask scott about this. +PR_PUBLIC_API(void) +JSJ_DisconnectFromJavaVM(JSJavaVM *); +*/ +#elif defined (JAVA) JSJ_Finish(); #endif #ifdef DEBUG @@ -2286,7 +2293,11 @@ et_SubEventLoop(QueueStackElement * qse) /* can't be interrupted yet */ lm_InterruptCurrentOp = JS_FALSE; +#ifdef OJI + LM_LockJS(NULL); +#else LM_LockJS(); +#endif /* need to interlock the getting of an event with ET_Interrupt */ PR_EnterMonitor(lm_queue_monitor); pEvent = PR_GetEvent(qse->queue); diff --git a/lib/libmocha/et_moz.c b/lib/libmocha/et_moz.c index 9be066529a23..307fcf54372c 100644 --- a/lib/libmocha/et_moz.c +++ b/lib/libmocha/et_moz.c @@ -27,6 +27,7 @@ #include "net.h" #include "structs.h" #include "prthread.h" +#include "prtypes.h" #include "prmem.h" #include "ds.h" /* XXX required by htmldlgs.h */ #include "htmldlgs.h" @@ -2883,7 +2884,7 @@ typedef struct { char* prin; char* target; char* risk; - int isCert; + PRBool isCert; } MozillaEvent_signedAppletPrivileges; PR_STATIC_CALLBACK(void) @@ -2904,7 +2905,7 @@ et_DestroyEvent_signedAppletPrivileges(MozillaEvent_signedAppletPrivileges* e) void ET_PostSignedAppletPrivileges - (MWContext* context, char* prin, char* target, char* risk, int isCert) + (MWContext* context, char* prin, char* target, char* risk, PRBool isCert) { MozillaEvent_signedAppletPrivileges* event = PR_NEW(MozillaEvent_signedAppletPrivileges); diff --git a/lib/libmocha/lm_applt.c b/lib/libmocha/lm_applt.c index f57cda903611..6fa6d24676f7 100644 --- a/lib/libmocha/lm_applt.c +++ b/lib/libmocha/lm_applt.c @@ -23,10 +23,11 @@ /* Please leave outside of ifdef for windows precompiled headers */ #include "lm.h" -#ifdef JAVA +#if defined(JAVA) || defined(OJI) #include "xp.h" #include "layout.h" +#if defined(JAVA) #include "java.h" #include "lj.h" /* for LJ_InvokeMethod */ #define IMPLEMENT_netscape_applet_MozillaAppletContext @@ -38,6 +39,10 @@ #include "netscape_applet_MozillaAppletContext.h" #include "netscape_applet_EmbeddedObjectNatives.h" #endif +#elif defined(OJI) +#include "np2.h" +#include "jni.h" +#endif /* OJI */ #include "jsjava.h" #include "jsobj.h" #include "prlog.h" @@ -192,6 +197,7 @@ lm_GetAppletArray(MochaDecoder *decoder, JSObject *document) return obj; } + static JSObject * lm_ReallyReflectApplet(MWContext *context, LO_JavaAppStruct *lo_applet, int32 layer_id, uint32 index) @@ -199,10 +205,17 @@ lm_ReallyReflectApplet(MWContext *context, LO_JavaAppStruct *lo_applet, JSObject *obj; MochaDecoder *decoder; JSContext *cx; +#ifdef JAVA LJAppletData *ad; - jref japplet; + jref javaobject; +#endif lo_TopState *top_state; PRHashTable *map; +#ifdef OJI + NPEmbeddedApp* embed; + LO_CommonPluginStruct *lo_embed = (LO_CommonPluginStruct *)lo_applet; + jobject javaobject; +#endif /* OJI */ PR_LOG(Moja, debug, ("really reflect applet 0x%x\n", lo_applet)); @@ -212,7 +225,7 @@ lm_ReallyReflectApplet(MWContext *context, LO_JavaAppStruct *lo_applet, decoder = LM_GetMochaDecoder(context); if (!decoder) - return NULL; + return NULL; cx = decoder->js_context; top_state = lo_GetMochaTopState(context); @@ -228,6 +241,35 @@ lm_ReallyReflectApplet(MWContext *context, LO_JavaAppStruct *lo_applet, } } +#ifdef OJI + { + if (! NPL_IsJVMAndMochaPrefsEnabled()) { + return lo_embed->mocha_object = lm_DummyObject; + } + + embed = (NPEmbeddedApp*) lo_embed->FE_Data; + if (embed) { + struct nsIPluginInstance *pNPI = NULL; + JNIEnv *jniEnv = NULL; + jsval val; + + pNPI = NPL_GetOJIPluginInstance(embed); + javaobject = NPL_GetJavaObject(pNPI); + NPL_Release((struct nsISupports *)pNPI); + +#if 0 + jniEnv = NPL_EnsureJNIExecEnv(NULL); + obj = JSJ_WrapJavaObject(decoder->js_context, + jniEnv, + javaobject, + (*jniEnv)->GetObjectClass(jniEnv, javaobject)); +#else + if (JSJ_ConvertJavaObjectToJSValue(decoder->js_context, javaobject, &val)) + obj = JSVAL_TO_OBJECT(val); +#endif + } + } +#else /* set the element to something bad if we can't get the java obj */ if (!JSJ_IsEnabled()) { PR_LOG(Moja, debug, ("reflected applet 0x%x as null\n", @@ -241,44 +283,63 @@ lm_ReallyReflectApplet(MWContext *context, LO_JavaAppStruct *lo_applet, /* MozillaAppletContext.reflectApplet gets the java applet * object out of a hash table given the AppletData pointer * as an integer */ - if (ad->selector_type != LO_JAVA_SELECTOR_APPLET) - japplet = LJ_InvokeMethod(classEmbeddedObjectNatives, - methodID_netscape_applet_EmbeddedObjectNatives_reflectObject, - ad->docID, ad); - else - japplet = LJ_InvokeMethod(classMozillaAppletContext, - methodID_netscape_applet_MozillaAppletContext_reflectApplet_1, - ad->docID, ad); + if (ad->selector_type != LO_JAVA_SELECTOR_APPLET) + javaobject = LJ_InvokeMethod(classEmbeddedObjectNatives, + methodID_netscape_applet_EmbeddedObjectNatives_reflectObject, + ad->docID, ad); + else + javaobject = LJ_InvokeMethod(classMozillaAppletContext, + methodID_netscape_applet_MozillaAppletContext_reflectApplet_1, + ad->docID, ad); + obj = js_ReflectJObjectToJSObject(decoder->js_context, + (HObject *)javaobject); + } +#endif /* !OJI */ - obj = js_ReflectJObjectToJSObject(decoder->js_context, - (HObject *)japplet); - - map = lm_GetIdToObjectMap(decoder); - if (map) - PR_HashTableAdd(map, - LM_GET_MAPPING_KEY(LM_APPLETS, layer_id, index), - obj); - - /* - lj_mozilla_ee->js_context = saved_context; - */ - - PR_LOG(Moja, debug, ("reflected applet 0x%x (java 0x%x) to 0x%x ok\n", - lo_applet, japplet, obj)); - - if (obj) - lm_java_clasp = JS_GetClass(obj); - return lo_applet->objTag.mocha_object = obj; - } else { + if( obj == NULL ) + { PR_LOG(Moja, warn, ("failed to reflect applet 0x%x\n", lo_applet)); return NULL; } + map = lm_GetIdToObjectMap(decoder); + if (map) + PR_HashTableAdd(map, + LM_GET_MAPPING_KEY(LM_APPLETS, layer_id, index), + obj); + + /* + lj_mozilla_ee->js_context = saved_context; + */ + + PR_LOG(Moja, debug, ("reflected applet 0x%x (java 0x%x) to 0x%x ok\n", + lo_applet, javaobject, obj)); + + if (obj) + lm_java_clasp = JS_GetClass(obj); + return lo_applet->objTag.mocha_object = obj; } /* XXX what happens if this is called before java starts up? * or if java is disabled? */ +#if defined(OJI) + +static char* getValue(struct lo_NVList* nvlist, const char* name) +{ + int i; + char** names = nvlist->names; + char** values = nvlist->values; + + for (i = nvlist->n - 1; i >= 0; --i) + if (XP_STRCASECMP(names[i], name) == 0) + return values[i]; + + return NULL; +} + +#endif + JSObject * LM_ReflectApplet(MWContext *context, LO_JavaAppStruct *applet_data, PA_Tag * tag, int32 layer_id, uint index) @@ -287,6 +348,9 @@ LM_ReflectApplet(MWContext *context, LO_JavaAppStruct *applet_data, MochaDecoder *decoder; JSContext *cx; char *name; +#ifdef OJI + LO_EmbedStruct *embed = (LO_EmbedStruct *)applet_data; +#endif obj = applet_data->objTag.mocha_object; if (obj) @@ -297,12 +361,19 @@ LM_ReflectApplet(MWContext *context, LO_JavaAppStruct *applet_data, return NULL; cx = decoder->js_context; +#ifdef OJI + /* this is really skanky, but we don't really have a LO_JavaAppStruct, but instead a LO_EmbedStruct. */ + name = getValue(&embed->attributes, "NAME"); + if (name != NULL) + name = JS_strdup(cx, name); +#else /* get the name */ if (applet_data->attr_name) { name = JS_strdup(cx, (char *) applet_data->attr_name); } else { name = 0; } +#endif /* Get the document object that will hold this applet */ document = lm_GetDocumentFromLayerId(decoder, layer_id); @@ -364,4 +435,4 @@ LM_ReflectNamedApplet(MWContext *context, lo_NameList *name_rec, void *lm_java_clasp = NULL; -#endif /* JAVA */ +#endif /* !JAVA && !OJI */ diff --git a/lib/libmocha/lm_doc.c b/lib/libmocha/lm_doc.c index f58e112e07e2..77ed86bef3ee 100644 --- a/lib/libmocha/lm_doc.c +++ b/lib/libmocha/lm_doc.c @@ -38,8 +38,11 @@ #include "libstyle.h" #include "prthread.h" #include "np.h" -#ifdef JAVA +#if defined (JAVA) #include "jsjava.h" +#elif defined (OJI) +#include "jsjava.h" +#include "np2.h" #endif #ifndef DOM @@ -233,7 +236,7 @@ doc_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_TRUE; case DOC_APPLETS: -#ifdef JAVA +#if defined(JAVA) || defined(OJI) if (LM_MOJA_OK != ET_InitMoja(context)) { LO_UnlockLayout(); return JS_FALSE; @@ -252,7 +255,7 @@ doc_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) #endif case DOC_EMBEDS: -#ifdef JAVA +#if defined(JAVA) || defined(OJI) if (LM_MOJA_OK != ET_InitMoja(context)) { LO_UnlockLayout(); return JS_FALSE; @@ -623,7 +626,7 @@ doc_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return doc_getProperty(cx, obj, id, vp); } -#ifdef JAVA +#if defined(JAVA) || defined(OJI) static void lm_reflect_stuff_eagerly(MWContext * context, int32 layer_id) { @@ -677,13 +680,12 @@ lm_reflect_stuff_eagerly(MWContext * context, int32 layer_id) LO_UnlockLayout(); } -#endif /* JAVA */ +#endif /* JAVA || OJI*/ PR_STATIC_CALLBACK(JSBool) doc_list_properties(JSContext *cx, JSObject *obj) { -#ifdef JAVA - +#if defined(JAVA) || defined(OJI) /* reflect applets eagerly, anything else? */ JSDocument *doc; MWContext *context; @@ -726,11 +728,24 @@ doc_list_properties(JSContext *cx, JSObject *obj) if(bDoInitMoja) { if (LM_MOJA_OK != ET_InitMoja(context)) return JS_FALSE; + +#ifdef OJI + { + PRBool jvmMochaPrefsEnabled = PR_FALSE; + if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { + jvmMochaPrefsEnabled = PR_TRUE; + } + if (jvmMochaPrefsEnabled == PR_FALSE) { + return JS_TRUE; + } + lm_reflect_stuff_eagerly(context, doc->layer_id); + } +#else if (JSJ_IsEnabled()) lm_reflect_stuff_eagerly(context, doc->layer_id); +#endif /* !OJI */ } - -#endif +#endif /* JAVA || OJI */ return JS_TRUE; } diff --git a/lib/libmocha/lm_embed.c b/lib/libmocha/lm_embed.c index b562ea9735d2..bbbb2e58e9b2 100644 --- a/lib/libmocha/lm_embed.c +++ b/lib/libmocha/lm_embed.c @@ -25,13 +25,18 @@ /* Please leave outside of ifdef for windows precompiled headers */ #include "lm.h" -#ifdef JAVA +#if defined(JAVA) || defined(OJI) #include "xp.h" #include "layout.h" #include "np.h" #include "nppriv.h" +#ifdef OJI +#include "jni.h" +#include "np2.h" +#else #include "jri.h" +#endif #include "jsjava.h" #include "jsobj.h" #include "prlog.h" @@ -177,6 +182,8 @@ lm_GetEmbedArray(MochaDecoder *decoder, JSObject *document) return obj; } + + /* this calls MozillaEmbedContext to reflect the embed by * calling into mocha... yow! */ static JSObject * @@ -213,13 +220,26 @@ lm_ReallyReflectEmbed(MWContext *context, LO_EmbedStruct *lo_embed, } } +#ifdef OJI + { + PRBool jvmMochaPrefsEnabled = PR_FALSE; + if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { + jvmMochaPrefsEnabled = PR_TRUE; + } + if (jvmMochaPrefsEnabled == PR_FALSE) { + PR_LOG(Moja, debug, ("reflected embed 0x%x as null\n", + lo_embed)); + return lo_embed->objTag.mocha_object = lm_DummyObject; + } + } +#else /* set the element to something bad if we can't get the java obj */ if (!JSJ_IsEnabled()) { PR_LOG(Moja, debug, ("reflected embed 0x%x as null\n", lo_embed)); return lo_embed->objTag.mocha_object = lm_DummyObject; } - +#endif /* !OJI */ embed = (NPEmbeddedApp*) lo_embed->objTag.FE_Data; if (embed) { np_data *ndata = (np_data*) embed->np_data; @@ -235,11 +255,28 @@ lm_ReallyReflectEmbed(MWContext *context, LO_EmbedStruct *lo_embed, return NULL; } instance = ndata->instance; - if (!instance) return NULL; + if (!instance) return NULL; jembed = npn_getJavaPeer(instance->npp); +#ifdef OJI + { +#if 0 + JNIEnv *jniEnv = NULL; + jniEnv = NPL_EnsureJNIExecEnv(NULL); + obj = JSJ_WrapJavaObject(decoder->js_context, + jniEnv, + jembed, + (*jniEnv)->GetObjectClass(jniEnv, jembed)); +#else + jsval val; + if (JSJ_ConvertJavaObjectToJSValue(decoder->js_context, jembed, &val)) + obj = JSVAL_TO_OBJECT(val); +#endif + } +#else obj = js_ReflectJObjectToJSObject(decoder->js_context, (HObject *)jembed); +#endif /* !OJI */ PR_LOG(Moja, debug, ("reflected embed 0x%x (java 0x%x) to 0x%x ok\n", lo_embed, jembed, obj)); @@ -293,7 +330,7 @@ LM_ReflectEmbed(MWContext *context, LO_EmbedStruct *lo_embed, break; } } -#endif +#endif /* !OJI */ /* Get the document object that will hold this applet */ document = lm_GetDocumentFromLayerId(decoder, layer_id); @@ -347,4 +384,4 @@ LM_ReflectNamedEmbed(MWContext *context, lo_NameList *name_rec, return NULL; } -#endif /* JAVA */ +#endif /* JAVA || OJI */ diff --git a/lib/libmocha/lm_init.c b/lib/libmocha/lm_init.c index 560c17d77911..fbe4efab02d4 100644 --- a/lib/libmocha/lm_init.c +++ b/lib/libmocha/lm_init.c @@ -35,11 +35,16 @@ #include "private/pprthred.h" #endif +#if defined (JAVA) #include "jri.h" #include "jriext.h" -#ifdef JAVA #include "java.h" +#elif defined (OJI) +#include "jni.h" +#include "np2.h" +#include "jsjava.h" #endif + #include "prefapi.h" #include "libi18n.h" #include "intl_csi.h" @@ -123,7 +128,11 @@ MochaDecoder *lm_crippled_decoder; JSContext *lm_crippled_context; /* exported to jsStubs.c */ PRThread *lm_InterpretThread; /* interpreter now in its own thread */ +#ifdef OJI +JNIEnv *lm_JSEnv; /* Java env for lm_InterpretThread */ +#elif defined(JAVA) JRIEnv *lm_JSEnv; /* Java env for lm_InterpretThread */ +#endif /* ! (OJI || JAVA) */ PREventQueue *lm_InterpretQueue; /* for "normal" event messages */ PREventQueue *lm_PriorityQueue; /* for stop and death messages */ @@ -531,7 +540,7 @@ lm_new_decoder(JSRuntime *rt, JSClass *clasp) XP_DELETE(decoder); return NULL; } - + decoder->forw_count = 1; decoder->js_context = cx; JS_SetBranchCallback(cx, lm_BranchCallback); @@ -655,10 +664,6 @@ lm_PrefChangedFunc(const char *pref, void *data) static JSBool mochaInited = JS_FALSE; -/* nix, where is this */ -extern void -JSJ_InitContext(JSContext *context, JSObject *obj); - /* * create the mocha thread, event queues, and stream converters */ @@ -687,7 +692,19 @@ lm_ReallyInitMocha(void) lm_crippled_decoder = lm_new_decoder(lm_runtime, &lm_dummy_class); lm_crippled_context = lm_crippled_decoder->js_context; -#ifdef JAVA +#ifdef OJI + { + PRBool jvmMochaPrefsEnabled = PR_FALSE; + if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { + jvmMochaPrefsEnabled = NPL_JSJInit(); + } + + if (jvmMochaPrefsEnabled == PR_TRUE) + { + JSJ_InitJSContext(lm_crippled_context, JS_GetGlobalObject(lm_crippled_context), NULL); + } + } +#elif defined (JAVA) LJ_JSJ_Init(); /* @@ -819,8 +836,16 @@ LM_InitMoja() * called on the moz thread we can do it the easy way */ if (lm_moja_initialized != LM_MOJA_UNINITIALIZED) return lm_moja_initialized; +#if defined(OJI) + lm_JSEnv = NPL_EnsureJNIExecEnv(lm_InterpretThread); + if (lm_JSEnv == NULL) { + lm_moja_initialized = LM_MOJA_JAVA_FAILED; + return lm_moja_initialized; + } -#ifdef JAVA + lm_moja_initialized = LM_MOJA_OK; + +#elif defined(JAVA) /* initialize the java env associated with the mocha thread */ lm_JSEnv = LJ_EnsureJavaEnv(lm_InterpretThread); if (lm_JSEnv == NULL) { @@ -908,8 +933,13 @@ LM_WaitForJSLock(void) /* * Wait until we get the JSLock */ +#ifdef OJI +JSBool PR_CALLBACK +LM_LockJS(char **errp) +#else void PR_CALLBACK LM_LockJS() +#endif { PRThread *t = PR_CurrentThread(); @@ -942,6 +972,9 @@ LM_LockJS() } lm_owner_count++; PR_ExitMonitor(lm_owner_mon); +#ifdef OJI + return( PR_TRUE ); +#endif } /* diff --git a/lib/libmocha/lm_taint.c b/lib/libmocha/lm_taint.c index 9245d4459d0e..6559b5e58052 100644 --- a/lib/libmocha/lm_taint.c +++ b/lib/libmocha/lm_taint.c @@ -30,8 +30,10 @@ #include "jsapi.h" #include "jsdbgapi.h" #include "jscntxt.h" /* XXX - needed for charSetName */ -#include "zip.h" +#include "nsZip.h" #include "zig.h" +#include "nsLoadZig.h" +#include "nsCaps.h" #include "jri.h" #include "jsjava.h" #ifdef JAVA @@ -41,27 +43,10 @@ #include "jsatom.h" #include "jsscope.h" -#ifdef JAVA -/* Needed to access private method; making method public would be - security hole */ -#define IMPLEMENT_netscape_security_PrivilegeManager - -#include "netscape_security_Principal.h" -#include "netscape_security_Zig.h" -#ifdef XP_MAC - #include "n_security_PrivilegeManager.h" - #include "n_security_PrivilegeTable.h" -#else - #include "netscape_security_PrivilegeManager.h" - #include "netscape_security_PrivilegeTable.h" -#endif /* XP_MAC */ -#include "netscape_security_Privilege.h" -#include "netscape_security_Target.h" -#endif +#include "nsCaps.h" extern JRIEnv * LJ_JSJ_CurrentEnv(JSContext * cx); extern char *LJ_GetAppletScriptOrigin(JRIEnv *env); -extern struct java_lang_String *makeJavaString(const char *, int); char lm_unknown_origin_str[] = "[unknown origin]"; @@ -75,6 +60,84 @@ static char container_error_message[] = #define FILE_URL_PREFIX_LEN (sizeof file_url_prefix - 1) #define WYSIWYG_TYPE_LEN 10 /* wysiwyg:// */ +/* XXX: raman: We should set this when JS console is ready */ +PRBool lm_console_is_ready = PR_FALSE; + +static void lm_PrintToConsole(const char *data); +static void setupJSCapsCallbacks(); + +static void +lm_PrintToConsole(const char *data) +{ + if (lm_console_is_ready) { + /* XXX: raman: We should write to JS console when it is ready */ + /* JS_PrintToConsole(data); */ + } else { + MWContext* someRandomContext = XP_FindSomeContext(); + FE_Alert(someRandomContext, data); + } +} + +PR_PUBLIC_API(int) +LM_PrintZigError(int status, void *zigPtr, const char *metafile, + char *pathname, char *errortext) +{ + ZIG *zig = (ZIG *) zigPtr; + char* data; + char* error_fmt = "# Error: %s (%d)\n#\tjar file: %s\n#\tpath: %s\n"; + char* zig_name = NULL; + int len; + + PR_ASSERT(errortext); + + if (zig) { + zig_name = SOB_get_url(zig); + } + + if (!zig_name) { + zig_name = "unknown"; + } + + if (!pathname) { + pathname = ""; + } + + /* Add 16 slop bytes */ + len = strlen(error_fmt) + strlen(zig_name) + strlen(pathname) + + strlen(errortext) + 32; + + if ((data = malloc(len)) == 0) { + return 0; + } + sprintf(data, error_fmt, errortext, status, zig_name, pathname); + + lm_PrintToConsole(data); + XP_FREE(data); + + return 0; +} + +PR_PUBLIC_API(char *) +LM_LoadFromZipFile(void *zip, char *fn) +{ + struct stat st; + char* data; + + if (!ns_zip_stat((ns_zip_t *)zip, fn, &st)) { + return NULL; + } + if ((data = malloc((size_t)st.st_size + 1)) == 0) { + return NULL; + } + if (!ns_zip_get((ns_zip_t *)zip, fn, data, st.st_size)) { + XP_FREE(data); + return NULL; + } + data[st.st_size] = '\0'; + return data; +} + + const char * LM_StripWysiwygURLPrefix(const char *url_string) { @@ -388,6 +451,8 @@ lm_GetPrincipalsFromStackFrame(JSContext *cx) } } #ifdef JAVA + /* =-= sudu: What do we do here for OJI? Ask raman. + */ if (JSJ_IsCalledFromJava(cx)) { return LM_GetJSPrincipalsFromJavaCaller(cx, 0); } @@ -449,69 +514,42 @@ lm_GetSubjectOriginURL(JSContext *cx) * them is so expensive. */ typedef struct SharedZig { -#ifdef JAVA ZIG *zig; -#endif int32 refCount; - JRIGlobalRef zigObjectRef; } SharedZig; static SharedZig * -newSharedZig(JRIEnv *env, zip_t *zip) +newSharedZig(ns_zip_t *zip) { -#ifdef JAVA ZIG *zig; SharedZig *result; - struct netscape_security_Zig *zigObject = NULL; - JRIGlobalRef zigObjectRef; - zig = LJ_InitializeZig(zip); + zig = nsInitializeZig(zip, + (int (*) (int, ZIG *, const char *, + char *, char *)) LM_PrintZigError); if (zig == NULL) return NULL; - zigObject = ns_createZigObject(env, zig); - if (zigObject == NULL) { - SOB_destroy(zig); - return NULL; - } - - /* - * From this point on, Java will call SOB_destroy, when java ref - * count goes to zero. - */ - zigObjectRef = JRI_NewGlobalRef(env, zigObject); - if (zigObjectRef == NULL) { - return NULL; - } - result = (SharedZig *) XP_ALLOC(sizeof(SharedZig)); if (result == NULL) { - JRI_DisposeGlobalRef(env, zigObjectRef); + SOB_destroy(zig); return NULL; } result->zig = zig; result->refCount = 0; - result->zigObjectRef = zigObjectRef; return result; -#else - return NULL; -#endif } static void -destroySharedZig(JRIEnv *env, SharedZig *sharedZig) +destroySharedZig(SharedZig *sharedZig) { -#ifdef JAVA - /* ZigObject will call SOB_destroy when java reference count goes to zero */ - JRI_DisposeGlobalRef(env, sharedZig->zigObjectRef); + SOB_destroy(sharedZig->zig); XP_FREE(sharedZig); -#endif } static SharedZig * -holdZig(JRIEnv *env, SharedZig *sharedZig) +holdZig(SharedZig *sharedZig) { -#ifdef JAVA if (sharedZig) { XP_ASSERT(sharedZig->refCount >= 0); /* XXX: Why are you checking this again */ @@ -519,22 +557,17 @@ holdZig(JRIEnv *env, SharedZig *sharedZig) sharedZig->refCount++; } return sharedZig; -#else - return NULL; -#endif } static void -dropZig(JRIEnv *env, SharedZig *sharedZig) +dropZig(SharedZig *sharedZig) { -#ifdef JAVA if (sharedZig) { XP_ASSERT(sharedZig->refCount > 0); if (--sharedZig->refCount == 0) { - destroySharedZig(env, sharedZig); + destroySharedZig(sharedZig); } } -#endif } struct JSPrincipalsList { @@ -570,7 +603,7 @@ typedef struct JSPrincipalsData { JRIGlobalRef principalsArrayRef; URL_Struct *url_struct; char *name; - zip_t *zip; + ns_zip_t *zip; uint32 externalCapturePrincipalsCount; char *untransformed; char *transformed; @@ -594,9 +627,6 @@ getPrincipalArray(JSContext *cx, struct JSPrincipals *principals); PR_STATIC_CALLBACK(JSBool) globalPrivilegesEnabled(JSContext *cx, JSPrincipals *principals); -static struct netscape_security_PrivilegeManager * -getPrivilegeManager(JRIEnv *env); - static JSPrincipalsData unknownPrincipals = { { lm_unknown_origin_str, @@ -652,7 +682,9 @@ LM_NewJSPrincipals(URL_Struct *archive, char *id, const char *codebase) { JSPrincipalsData *result; JSBool needUnlock = JS_FALSE; - zip_t *zip = NULL; + ns_zip_t *zip = NULL; + + setupJSCapsCallbacks(); if (archive) { char *fn = NULL; @@ -670,22 +702,18 @@ LM_NewJSPrincipals(URL_Struct *archive, char *id, const char *codebase) if (fn) { #ifdef XP_MAC /* - * Unfortunately, zip_open wants a Unix-style name. Convert Mac path + * Unfortunately, ns_zip_open wants a Unix-style name. Convert Mac path * to a Unix-style path. This code is copied from appletStubs.c. */ OSErr ConvertMacPathToUnixPath(const char *macPath, char **unixPath); char *unixPath = NULL; if (ConvertMacPathToUnixPath(fn, &unixPath) == 0) { - zip = zip_open(unixPath); + zip = ns_zip_open(unixPath); } XP_FREEIF(unixPath); #else -#ifdef OJI // XXX hack - zip = NULL; -#else - zip = zip_open(fn); -#endif + zip = ns_zip_open(fn); #endif XP_FREE(fn); } @@ -733,33 +761,23 @@ destroyJSPrincipals(JSContext *cx, JSPrincipals *principals) principals != (JSPrincipals *) &unknownPrincipals) { JSPrincipalsData *data = (JSPrincipalsData *) principals; -#ifdef JAVA - JRIEnv *env = NULL; - if (data->sharedZig || data->principalsArrayRef) { - /* Avoid starting Java if "env" not needed */ - env = LJ_JSJ_CurrentEnv(cx); - } -#endif /* JAVA */ #ifdef DEBUG_norris XP_TRACE(("JSPrincipals #%.4d released\n", data->serial)); #endif XP_FREEIF(principals->codebase); -#ifdef JAVA - if (env && data->sharedZig) { - dropZig(env, data->sharedZig); + if (data->sharedZig) { + dropZig(data->sharedZig); } - if (env && (data->principalsArrayRef != NULL)) { - JRI_DisposeGlobalRef(env, data->principalsArrayRef); + if (data->principalsArrayRef != NULL) { + /* XXX: raman: Should we free up the principals that are in that array also? */ + nsCapsFreePrincipalArray(data->principalsArrayRef); } -#endif /* JAVA */ XP_FREEIF(data->name); XP_FREEIF(data->untransformed); XP_FREEIF(data->transformed); -#ifndef OJI // XXX hack if (data->zip) - zip_close(data->zip); -#endif + ns_zip_close(data->zip); if (data->needUnlock) NET_ChangeCacheFileLock(data->url_struct, FALSE); if (data->url_struct) @@ -781,68 +799,45 @@ globalPrivilegesEnabled(JSContext *cx, JSPrincipals *principals) static void printPrincipalsToConsole(JSContext *cx, JSPrincipals *principals) { -#ifdef JAVA - JRIEnv *env; - jobjectArray principalsArray; - struct netscape_security_Principal *principal; - struct java_lang_String *javaString; + void *principalsArray; + struct nsPrincipal *principal; + const char *vendor; uint32 i, count; static char emptyStr[] = "\n"; - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return; - } - principalsArray = principals->getPrincipalArray(cx, principals); if (principalsArray == NULL) { - PrintToConsole(emptyStr); + lm_PrintToConsole(emptyStr); return; } - PrintToConsole("[\n"); - count = JRI_GetObjectArrayLength(env, principalsArray); + lm_PrintToConsole("[\n"); + count = nsCapsGetPrincipalArraySize(principalsArray); for (i = 0; i < count; i++) { - principal = JRI_GetObjectArrayElement(env, principalsArray, i); - javaString = netscape_security_Principal_getVendor(env, principal); - if (javaString) { - const char *s = JRI_GetStringPlatformChars(env, javaString, - NULL, 0); - - /* XXX - temporarily replace arguments so we can compile - (const jbyte *) cx->charSetName, - (jint) cx->charSetNameLength); - */ - if (s == NULL) { - JS_ReportOutOfMemory(cx); - return; - } - PrintToConsole(s); + principal = nsCapsGetPrincipalArrayElement(principalsArray, i); + vendor = nsCapsPrincipalGetVendor(principal); + if (vendor == NULL) { + JS_ReportOutOfMemory(cx); + return; } - PrintToConsole(",\n"); + lm_PrintToConsole(vendor); + lm_PrintToConsole(",\n"); } - PrintToConsole("]\n"); -#endif /* JAVA */ + lm_PrintToConsole("]\n"); } extern void lm_InvalidateCertPrincipals(MochaDecoder *decoder, JSPrincipals *principals) { JSPrincipalsData *data = (JSPrincipalsData *) principals; -#ifdef JAVA - JRIEnv *env; if (data->principalsArrayRef) { - PrintToConsole("Invalidating certificate principals in "); + lm_PrintToConsole("Invalidating certificate principals in "); printPrincipalsToConsole(decoder->js_context, principals); - env = LJ_JSJ_CurrentEnv(decoder->js_context); - if (env != NULL) { - JRI_DisposeGlobalRef(env, data->principalsArrayRef); - } + nsCapsFreePrincipalArray(data->principalsArrayRef); data->principalsArrayRef = NULL; } -#endif /* JAVA */ data->signedness = HAS_UNSIGNED_SCRIPTS; } @@ -864,16 +859,10 @@ lm_SetDocumentDomain(JSContext *cx, JSPrincipals *principals, JS_ReportOutOfMemory(cx); return JS_FALSE; } -#ifdef JAVA if (data->principalsArrayRef != NULL) { - JRIEnv *env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return JS_FALSE; - } - JRI_DisposeGlobalRef(env, data->principalsArrayRef); + nsCapsFreePrincipalArray(data->principalsArrayRef); data->principalsArrayRef = NULL; } -#endif /* JAVA */ return JS_TRUE; } @@ -967,29 +956,14 @@ JSBool lm_CheckSetParentSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp) static JSBool canExtendTrust(JSContext *cx, void *from, void *to) { -#ifdef JAVA - JRIEnv *env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return JS_FALSE; - } if (from == NULL || to == NULL) { return JS_FALSE; } - return (from == to) || - (JSBool)netscape_security_PrivilegeManager_canExtendTrust( - env, - getPrivilegeManager(env), - from, - to); -#else - /* should never be called without signed scripts */ - XP_ASSERT(0); - return JS_FALSE; -#endif /* JAVA */ + return (from == to) || (JSBool)nsCapsCanExtendTrust(from, to); } static JSPrincipals * -newJSPrincipalsFromArray(JSContext *cx, jobjectArray principalsArray); +newJSPrincipalsFromArray(JSContext *cx, void *principalsArray); extern JSBool lm_CheckContainerAccess(JSContext *cx, JSObject *obj, MochaDecoder *decoder, @@ -997,7 +971,6 @@ lm_CheckContainerAccess(JSContext *cx, JSObject *obj, MochaDecoder *decoder, { JSPrincipals *principals; JSPrincipalsData *data; - JRIEnv *env; JSStackFrame *fp; JSScript *script; JSPrincipals *subjPrincipals; @@ -1007,7 +980,7 @@ lm_CheckContainerAccess(JSContext *cx, JSObject *obj, MochaDecoder *decoder, if(decoder->principals) { principals = lm_GetInnermostPrincipals(decoder->js_context, obj, NULL); } else { - principals = NULL; + principals = NULL; } if (principals == NULL) { @@ -1066,18 +1039,6 @@ lm_CheckContainerAccess(JSContext *cx, JSObject *obj, MochaDecoder *decoder, * We have signed scripts. Must check that the object principals are * a subset of the the subject principals. */ -#ifdef OJI // XXX hack - env = NULL; -#else -#ifdef JAVA - env = LJ_JSJ_CurrentEnv(cx); -#else - env = NULL; -#endif -#endif - if (env == NULL) { - return JS_FALSE; - } fp = NULL; fp = JS_FrameIterator(cx, &fp); if (fp == NULL || (script = JS_GetFrameScript(cx, fp)) == NULL) { @@ -1095,16 +1056,12 @@ lm_CheckContainerAccess(JSContext *cx, JSObject *obj, MochaDecoder *decoder, fn = lm_GetSubjectOriginURL(cx); if (!fn) return JS_FALSE; -#ifndef OJI // XXX hack -#ifdef JAVA if (subjPrincipals && principals) { - PrintToConsole("Principals of script: "); + lm_PrintToConsole("Principals of script: "); printPrincipalsToConsole(cx, subjPrincipals); - PrintToConsole("Principals of signed container: "); + lm_PrintToConsole("Principals of signed container: "); printPrincipalsToConsole(cx, principals); } -#endif /* JAVA */ -#endif /* !OJI */ JS_ReportError(cx, container_error_message, fn); return JS_FALSE; } @@ -1130,8 +1087,8 @@ checkEarlyAccess(MochaDecoder *decoder, JSPrincipals *principals) for (p = (JSPrincipalsList *) decoder->early_access_list; p; p = p->next) { if (data->signedness == HAS_SIGNED_SCRIPTS) { if (!canExtendTrust(cx, - principals->getPrincipalArray(cx, principals), - p->principals->getPrincipalArray(cx, + principals->getPrincipalArray(cx, principals), + p->principals->getPrincipalArray(cx, p->principals))) { JS_ReportError(cx, container_error_message, @@ -1141,14 +1098,14 @@ checkEarlyAccess(MochaDecoder *decoder, JSPrincipals *principals) } } else { if (!sameOrigins(cx, p->principals->codebase, - principals->codebase)) + principals->codebase)) { /* * Check to see if early access violated the cross-origin * container check. */ JS_ReportError(cx, access_error_message, - p->principals->codebase); + p->principals->codebase); ok = JS_FALSE; break; } @@ -1170,12 +1127,8 @@ intersectPrincipals(MochaDecoder *decoder, JSPrincipals *principals, JSPrincipalsData *data = (JSPrincipalsData *) principals; JSPrincipalsData *newData = (JSPrincipalsData *) newPrincipals; JSContext *cx; -#ifdef JAVA - JRIEnv *env; - struct netscape_security_PrivilegeManager *privilegeManager; - jobjectArray principalArray, newPrincipalArray; - JRIGlobalRef principalsArrayRef; -#endif /* JAVA */ + void *principalArray; + void *newPrincipalArray; XP_ASSERT(data->signedness != HAS_NO_SCRIPTS); XP_ASSERT(newData->signedness != HAS_NO_SCRIPTS); @@ -1199,69 +1152,45 @@ intersectPrincipals(MochaDecoder *decoder, JSPrincipals *principals, lm_InvalidateCertPrincipals(decoder, principals); return JS_TRUE; } -#ifdef JAVA /* Compute the intersection. */ - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - lm_InvalidateCertPrincipals(decoder, principals); - return globalPrivilegesEnabled(cx, principals); - } - privilegeManager = getPrivilegeManager(env); principalArray = getPrincipalArray(cx, principals); newPrincipalArray = getPrincipalArray(cx, newPrincipals); - if (privilegeManager == NULL || principalArray == NULL + if (principalArray == NULL || newPrincipalArray == NULL) { lm_InvalidateCertPrincipals(decoder, principals); return JS_TRUE; } - principalArray = netscape_security_PrivilegeManager_intersectPrincipalArray( - env, privilegeManager, principalArray, newPrincipalArray); - principalsArrayRef = JRI_NewGlobalRef(env, principalArray); + principalArray = nsCapsIntersectPrincipalArray( + principalArray, newPrincipalArray); if (principalArray == NULL) { lm_InvalidateCertPrincipals(decoder, principals); return JS_TRUE; } - JRI_DisposeGlobalRef(env, data->principalsArrayRef); - data->principalsArrayRef = principalsArrayRef; + data->principalsArrayRef = principalArray; return JS_TRUE; -#else - XP_ASSERT(0); /* should never get here without signed scripts */ - return JS_FALSE; -#endif /* JAVA */ } static uint32 getPrincipalsCount(JSContext *cx, JSPrincipals *principals) { -#ifdef JAVA - JRIEnv *env; - jref principalArray; - - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return 0; - } + void *principalArray; /* Get array of principals */ principalArray = getPrincipalArray(cx, principals); - return principalArray ? JRI_GetObjectArrayLength(env, principalArray) : 0; -#else - return 0; -#endif /* JAVA */ + return principalArray ? nsCapsGetPrincipalArraySize(principalArray) : 0; } static JSBool principalsEqual(JSContext *cx, JSPrincipals *a, JSPrincipals *b) { -#ifdef JAVA JSPrincipalsData *dataA, *dataB; - jobjectArray arrayA, arrayB; - JRIEnv *env; + void *arrayA; + void *arrayB; if (a == b) return JS_TRUE; @@ -1275,46 +1204,29 @@ principalsEqual(JSContext *cx, JSPrincipals *a, JSPrincipals *b) arrayA = getPrincipalArray(cx, a); arrayB = getPrincipalArray(cx, b); - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return JS_FALSE; - } - - return (JSBool)(netscape_security_PrivilegeManager_comparePrincipalArray(env, - getPrivilegeManager(env), - arrayA, - arrayB) - == netscape_security_PrivilegeManager_EQUAL); -#else - /* Shouldn't get here without signed scripts */ - XP_ASSERT(0); - return JS_FALSE; -#endif /* JAVA */ + return (JSBool)(nsCapsComparePrincipalArray(arrayA, arrayB) + == nsSetComparisonType_Equal); } /* * createPrincipalsArray takes ZIG file information and returns a - * reference to a Java array of Java Principal objects. - * It also registers the principals with the PrivilegeManager. + * pointer to an array of nsPrincipal objects. + * It also registers the principals with the nsPrivilegeManager. */ static jref -createPrincipalsArray(JRIEnv *env, - struct netscape_security_PrivilegeManager *privilegeManager, - JSPrincipals *principals) +createPrincipalsArray(JSPrincipals *principals) { -#ifdef JAVA JSPrincipalsData *data = (JSPrincipalsData *) principals; JSBool hasCodebase; SOBITEM *item; int i; ZIG *zig; - struct java_lang_Class *principalClass; unsigned count; - jref result; - jref byteArray; - struct netscape_security_Principal *principal; + void *result; + struct nsPrincipal *principal; ZIG_Context * zig_cx = NULL; - void *zigObj; + + setupJSCapsCallbacks(); if (principals == (JSPrincipals *) &unknownPrincipals) return NULL; @@ -1349,8 +1261,7 @@ createPrincipalsArray(JRIEnv *env, } /* Now allocate the array */ - principalClass = class_netscape_security_Principal(env); - result = JRI_NewObjectArray(env, count, principalClass, NULL); + result = nsCapsNewPrincipalArray(count); if (result == NULL) { return NULL; } @@ -1360,28 +1271,18 @@ createPrincipalsArray(JRIEnv *env, } i = 0; - if (zig) { - zigObj = JRI_GetGlobalRef(env, data->sharedZig->zigObjectRef); - } while (zig && SOB_find_next(zig_cx, &item) >= 0) { FINGERZIG *fingPrint; fingPrint = (FINGERZIG *) item->data; - /* call java: new Principal(CERT_KEY, fingPrint->key) */ - byteArray = JRI_NewByteArray(env, fingPrint->length, - fingPrint->key); - - principal = netscape_security_Principal_new_5(env, - principalClass, - netscape_security_Principal_CERT_KEY, - byteArray, - (struct netscape_security_Zig *)zigObj); - - netscape_security_PrivilegeManager_registerPrincipal(env, - privilegeManager, principal); - - JRI_SetObjectArrayElement(env, result, i++, principal); + /* create a new nsPrincipal(CERT_KEY, fingPrint->key) */ + principal = nsCapsNewPrincipal(nsPrincipalType_CertKey, + fingPrint->key, + fingPrint->length, + zig); + nsCapsRegisterPrincipal(principal); + nsCapsSetPrincipalArrayElement(result, i++, principal); } if (zig) { SOB_find_end(zig_cx); @@ -1393,27 +1294,18 @@ createPrincipalsArray(JRIEnv *env, javaCodebase = getJavaCodebaseFromOrigin(principals->codebase); if (javaCodebase == NULL) return NULL; - byteArray = JRI_NewByteArray(env, - XP_STRLEN(javaCodebase), - javaCodebase); - principal = netscape_security_Principal_new_3(env, - principalClass, - netscape_security_Principal_CODEBASE_EXACT, - byteArray); - netscape_security_PrivilegeManager_registerPrincipal(env, - privilegeManager, principal); - JRI_SetObjectArrayElement(env, result, i++, principal); + principal = nsCapsNewPrincipal(nsPrincipalType_CodebaseExact, + javaCodebase, + XP_STRLEN(javaCodebase), + NULL); + nsCapsRegisterPrincipal(principal); + nsCapsSetPrincipalArrayElement(result, i++, principal); XP_FREE(javaCodebase); } - data->principalsArrayRef = JRI_NewGlobalRef(env, result); + data->principalsArrayRef = result; return result; -#else - /* This should never be called without signed scripts. */ - XP_ASSERT(0); - return NULL; -#endif /* JAVA */ } static JSBool @@ -1471,18 +1363,6 @@ static char *targetStrings[] = { /* See Target.java for more targets */ }; -/* get PrivilegeManager object: call static PrivilegeManager.getPrivilegeManager() */ -static struct netscape_security_PrivilegeManager * -getPrivilegeManager(JRIEnv *env) -{ -#ifdef JAVA - return netscape_security_PrivilegeManager_getPrivilegeManager(env, - JRI_FindClass(env, - classname_netscape_security_PrivilegeManager)); -#else - return NULL; -#endif -} /* ** If given principals can access the given target, return true. Otherwise return false. @@ -1491,32 +1371,20 @@ getPrivilegeManager(JRIEnv *env) static JSBool principalsCanAccessTarget(JSContext *cx, JSTarget target) { -#ifdef JAVA - JRIEnv *env; - struct netscape_security_PrivilegeManager *privilegeManager; - struct netscape_security_PrivilegeTable *annotation; - struct netscape_security_Privilege *privilege; - struct netscape_security_Target *javaTarget; - struct java_lang_String *javaString; - struct java_lang_Class *targetClass; - jint perm; + struct nsPrivilegeTable *annotation; + struct nsPrivilege *privilege; + struct nsTarget *capsTarget; + nsPermissionState perm; JSStackFrame *fp; - jglobal annotationRef; + void *annotationRef; void *principalArray = NULL; - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return JS_FALSE; - } + setupJSCapsCallbacks(); - privilegeManager = getPrivilegeManager(env); - - /* Map JSTarget to netscape_security_Target */ + /* Map JSTarget to nsTarget */ XP_ASSERT(target >= 0); XP_ASSERT(target < sizeof(targetStrings)/sizeof(targetStrings[0])); - targetClass = JRI_FindClass(env, classname_netscape_security_Target); - javaString = makeJavaString(targetStrings[target], strlen(targetStrings[target])); - javaTarget = netscape_security_Target_findTarget(env, targetClass, javaString); + capsTarget = nsCapsFindTarget(targetStrings[target]); /* Find annotation */ annotationRef = NULL; @@ -1530,97 +1398,81 @@ principalsCanAccessTarget(JSContext *cx, JSTarget target) if (current == NULL) { return JS_FALSE; } - annotationRef = (jglobal) JS_GetFrameAnnotation(cx, fp); + annotationRef = (void *) JS_GetFrameAnnotation(cx, fp); if (annotationRef) { if (principalArray && - !netscape_security_PrivilegeManager_canExtendTrust( - env, privilegeManager, current, principalArray)) + !nsCapsCanExtendTrust(current, principalArray)) { return JS_FALSE; } break; } principalArray = principalArray - ? netscape_security_PrivilegeManager_intersectPrincipalArray( - env, privilegeManager, principalArray, current) + ? nsCapsIntersectPrincipalArray(principalArray, current) : current; } if (annotationRef) { - annotation = (struct netscape_security_PrivilegeTable *) - JRI_GetGlobalRef(env, annotationRef); - } else if (JSJ_IsCalledFromJava(cx)) { - /* - * Call from Java into JS. Just call the Java routine for checking - * privileges. - */ - if (principalArray) { - /* - * Must check that the principals that signed the Java applet are - * a subset of the principals that signed this script. - */ - jobjectArray javaPrincipals; - - javaPrincipals = - netscape_security_PrivilegeManager_getClassPrincipalsFromStack( - env, - privilegeManager, - 0); - if (!canExtendTrust(cx, javaPrincipals, principalArray)) { - return JS_FALSE; - } - } - return (JSBool)netscape_security_PrivilegeManager_isPrivilegeEnabled( - env, privilegeManager, javaTarget, 0); + annotation = (struct nsPrivilegeTable *)annotationRef; } else { +#ifdef JAVA + if (JSJ_IsCalledFromJava(cx)) { + /* + * Call from Java into JS. Just call the Java routine for checking + * privileges. + */ + if (principalArray) { + /* + * Must check that the principals that signed the Java applet are + * a subset of the principals that signed this script. + */ + void *javaPrincipals = NULL; + + /* XXX: The following is a LiveConnect call. We need to find + * out from the VM who the principal is (may be get the + * certificate from VM and create a principal from it). + * Pass that principal to canExtendTrust call. Until this is + * fixed deny the privileged operations from Java to JS. + */ + /* XXX: raman: We need to fix this with LiveConnect integration. + * javaPrincipals = nsCapsGetClassPrincipalsFromStack(0); + */ + if (!canExtendTrust(cx, javaPrincipals, principalArray)) { + return JS_FALSE; + } + } + return (JSBool)nsCapsIsPrivilegeEnabled(capsTarget, 0); + } +#endif /* JAVA */ /* No annotation in stack */ return JS_FALSE; } /* Now find permission for (annotation, target) pair. */ - privilege = netscape_security_PrivilegeTable_get_1(env, - annotation, - (struct java_lang_Object *)javaTarget); - if (JRI_ExceptionOccurred(env)) { + privilege = nsCapsGetPrivilege(annotation, capsTarget); + if (privilege == NULL) { return JS_FALSE; } XP_ASSERT(privilege); - perm = netscape_security_Privilege_getPermission(env, - privilege); - XP_ASSERT(!JRI_ExceptionOccurred(env)); + perm = nsCapsGetPermission(privilege); - return (JSBool)(perm == netscape_security_Privilege_ALLOWED); -#else - return JS_FALSE; -#endif /* JAVA */ + return (JSBool)(perm == nsPermissionState_Allowed); } PR_STATIC_CALLBACK(void *) getPrincipalArray(JSContext *cx, struct JSPrincipals *principals) { -#ifdef JAVA JSPrincipalsData *data = (JSPrincipalsData *) principals; - struct netscape_security_PrivilegeManager *privilegeManager; - JRIEnv *env; - - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return NULL; - } /* Get array of principals */ if (data->principalsArrayRef == NULL) { - privilegeManager = getPrivilegeManager(env); - if (createPrincipalsArray(env, privilegeManager, principals) == NULL) + if (createPrincipalsArray(principals) == NULL) return NULL; } - return JRI_GetGlobalRef(env, data->principalsArrayRef); -#else - return NULL; -#endif + return data->principalsArrayRef; } @@ -1631,11 +1483,7 @@ LM_ExtractFromPrincipalsArchive(JSPrincipals *principals, char *name, JSPrincipalsData *data = (JSPrincipalsData *) principals; char *result = NULL; -#ifndef OJI // XXX hack -#ifdef JAVA - result = LJ_LoadFromZipFile(data->zip, name); -#endif -#endif + result = LM_LoadFromZipFile(data->zip, name); *length = result ? XP_STRLEN(result) : 0; return result; @@ -1660,70 +1508,44 @@ LM_SetUntransformedSource(JSPrincipals *principals, char *original, JSPrincipals * PR_CALLBACK LM_GetJSPrincipalsFromJavaCaller(JSContext *cx, int callerDepth) { -#ifdef JAVA - JRIEnv *env; - jobjectArray principalsArray; + void *principalsArray; - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return NULL; - } + setupJSCapsCallbacks(); - principalsArray = native_netscape_security_PrivilegeManager_getClassPrincipalsFromStackUnsafe( - env, - getPrivilegeManager(env), - callerDepth); + principalsArray = nsCapsGetClassPrincipalsFromStack(callerDepth); if (principalsArray == NULL) return NULL; return newJSPrincipalsFromArray(cx, principalsArray); -#else - return NULL; -#endif } static JSPrincipals * -newJSPrincipalsFromArray(JSContext *cx, jobjectArray principalsArray) +newJSPrincipalsFromArray(JSContext *cx, void *principalsArray) { -#ifdef JAVA - JRIEnv *env; JSPrincipals *result; - struct netscape_security_Principal *principal; - struct java_lang_String *javaString; + struct nsPrincipal *principal; const char *codebase; JSPrincipalsData *data; uint32 i, count; - env = LJ_JSJ_CurrentEnv(cx); - if (env == NULL) { - return NULL; - } + setupJSCapsCallbacks(); - count = JRI_GetObjectArrayLength(env, principalsArray); + count = nsCapsGetPrincipalArraySize(principalsArray); if (count == 0) { JS_ReportError(cx, "No principals found for Java caller"); return NULL; } - javaString = NULL; + codebase = NULL; for (i = count; i > 0; i--) { - principal = JRI_GetObjectArrayElement(env, principalsArray, i-1); - if (netscape_security_Principal_isCodebaseExact(env, principal)) { - javaString = netscape_security_Principal_toString(env, principal); + principal = nsCapsGetPrincipalArrayElement(principalsArray, i-1); + if (nsCapsIsCodebaseExact(principal)) { + codebase = nsCapsPrincipalToString(principal); break; } } - codebase = javaString - ? JRI_GetStringPlatformChars(env, javaString, - NULL, 0) - - /* XXX - temporarily replace arguments so we can compile - (const jbyte *) cx->charSetName, - (jint) cx->charSetNameLength); - */ - : NULL; result = LM_NewJSPrincipals(NULL, NULL, (char *) codebase); if (result == NULL) { JS_ReportOutOfMemory(cx); @@ -1731,17 +1553,12 @@ newJSPrincipalsFromArray(JSContext *cx, jobjectArray principalsArray) } data = (JSPrincipalsData *) result; - data->principalsArrayRef = JRI_NewGlobalRef(env, principalsArray); + data->principalsArrayRef = principalsArray; data->signedness = count == 1 && codebase ? HAS_UNSIGNED_SCRIPTS : HAS_SIGNED_SCRIPTS; return result; -#else - /* Should not get here without signed scripts */ - XP_ASSERT(0); - return NULL; -#endif /* JAVA */ } static JSBool @@ -1749,18 +1566,16 @@ verifyPrincipals(MochaDecoder *decoder, JSPrincipals *containerPrincipals, JSPrincipals *principals, char *name, char *src, uint srcSize, JSBool implicitName) { -#ifdef JAVA JSPrincipalsData *data = (JSPrincipalsData *) principals; ZIG *zig; DIGESTS *dig = NULL; JSBool sameName = JS_FALSE; int ret; JSPrincipalsData *containerData; - zip_t *containerZip; + ns_zip_t *containerZip; JSBool verified; SOBITEM *item; ZIG_Context * zig_cx; - JRIEnv *env; if (data->signedness == HAS_UNSIGNED_SCRIPTS) return JS_FALSE; @@ -1788,29 +1603,23 @@ verifyPrincipals(MochaDecoder *decoder, JSPrincipals *containerPrincipals, */ verified = JS_FALSE; - /* Start Java since errors may need to be printed to the console. */ - env = LJ_JSJ_CurrentEnv(decoder->js_context); - if (env == NULL) { - return JS_FALSE; - } - if (containerData == NULL) { /* First script seen; initialize zig. */ - data->sharedZig = holdZig(env, newSharedZig(env, data->zip)); + data->sharedZig = holdZig(newSharedZig(data->zip)); } else if (data == containerData) { /* Already have a zig if there is one; nothing more to do. */ } else if (data->zip == NULL) { /* "Inherit" data->sharedZig from container data. */ - data->sharedZig = holdZig(env, containerData->sharedZig); + data->sharedZig = holdZig(containerData->sharedZig); } else if (containerData->url_struct && XP_STRCMP(data->url_struct->address, containerData->url_struct->address) == 0) { /* Two identical zips. Share the zigs. */ - data->sharedZig = holdZig(env, containerData->sharedZig); + data->sharedZig = holdZig(containerData->sharedZig); } else { /* Different zips. Must create a new zig. */ - data->sharedZig = holdZig(env, newSharedZig(env, data->zip)); + data->sharedZig = holdZig(newSharedZig(data->zip)); } if (data->sharedZig == NULL) @@ -1835,15 +1644,12 @@ verifyPrincipals(MochaDecoder *decoder, JSPrincipals *containerPrincipals, return JS_FALSE; } } else if (!implicitName || ret != ZIG_ERR_PNF) { - LJ_PrintZigError(ret, zig, "", name, SOB_get_error(ret)); + LM_PrintZigError(ret, zig, "", name, SOB_get_error(ret)); } if (zig_cx) { SOB_find_end(zig_cx); } return verified; -#else - return JS_FALSE; -#endif /* JAVA */ } @@ -2016,25 +1822,17 @@ LM_RegisterPrincipals(MochaDecoder *decoder, JSPrincipals *principals, * Intersect principals and container principals, * modifying the container principals. */ -#ifndef OJI // XXX hack -#ifdef JAVA - PrintToConsole("Intersecting principals "); + lm_PrintToConsole("Intersecting principals "); printPrincipalsToConsole(cx, containerPrincipals); - PrintToConsole("with "); + lm_PrintToConsole("with "); printPrincipalsToConsole(cx, principals); -#endif -#endif if (!intersectPrincipals(decoder, containerPrincipals, principals)) { return NULL; } -#ifndef OJI // XXX hack -#ifdef JAVA - PrintToConsole("yielding "); + lm_PrintToConsole("yielding "); printPrincipalsToConsole(cx, containerPrincipals); -#endif -#endif } else { /* * Store the disjoint set of principals in the @@ -2048,3 +1846,221 @@ LM_RegisterPrincipals(MochaDecoder *decoder, JSPrincipals *principals, return containerPrincipals; } + +/******************************************************************************* + * Glue code for JS stack crawling callbacks + ******************************************************************************/ + +typedef struct JSFrameIterator { + JSStackFrame *fp; + JSContext *cx; + JRIEnv *env; + void *intersect; + PRBool sawEmptyPrincipals; +} JSFrameIterator; + +static JSFrameIterator * +lm_NewJSFrameIterator() +{ + JSContext *cx = NULL; + char *errorString; + JSFrameIterator *result; + void *array; + JRIEnv *env = NULL; + + result = XP_ALLOC(sizeof(JSFrameIterator)); + if (result == NULL) { + return NULL; + } + + /* XXX: raman: Is this correct? How do we get the Context?? */ +#ifdef JAVA + env = JRI_GetCurrentEnv(); + cx = JSJ_CurrentContext(env, &errorString); +#endif /* JAVA */ + if (cx == NULL) { + return NULL; + } + + result->env = env; + result->fp = NULL; + result->cx = cx; + result->fp = JS_FrameIterator(cx, &result->fp); + array = result->fp + ? JS_GetFramePrincipalArray(cx, result->fp) + : NULL; + result->intersect = array; + result->sawEmptyPrincipals = + (result->intersect == NULL && result->fp && + JS_GetFrameScript(cx, result->fp)) + ? PR_TRUE : PR_FALSE; + + return result; +} + + +static PRBool +lm_NextJSJavaFrame(struct JSFrameIterator *iterator) +{ + void *current; + void *previous; + + if (iterator->fp == 0) { + return PR_FALSE; + } + + current = JS_GetFramePrincipalArray(iterator->cx, iterator->fp); + if (current == NULL) { + if (JS_GetFrameScript(iterator->cx, iterator->fp)) + iterator->sawEmptyPrincipals = PR_TRUE; + } else { + if (iterator->intersect) { + previous = iterator->intersect; + current = nsCapsIntersectPrincipalArray(current, previous); + /* XXX: raman: should we do a free the previous principal Array */ + nsCapsFreePrincipalArray(iterator->intersect); + } + iterator->intersect = current; + } + iterator->fp = JS_FrameIterator(iterator->cx, &iterator->fp); + return iterator->fp != NULL; +} + +static PRBool +nextJSFrame(struct JSFrameIterator **iteratorp) +{ + JSFrameIterator *iterator = *iteratorp; + PRBool result = lm_NextJSJavaFrame(iterator); + if (!result) { + if (iterator->intersect) + nsCapsFreePrincipalArray(iterator->intersect); + XP_FREE(iterator); + *iteratorp = NULL; + } + return result; +} + +/* + * + * CALLBACKS to walk the stack + * + */ + +typedef struct NSJSJavaFrameWrapper { + struct JSFrameIterator *iterator; +} NSJSJavaFrameWrapper; + +struct NSJSJavaFrameWrapper * +lm_NewNSJSJavaFrameWrapperCB(void) +{ + struct NSJSJavaFrameWrapper *result; + JRIEnv *env; + + result = (struct NSJSJavaFrameWrapper *)PR_CALLOC(sizeof(struct NSJSJavaFrameWrapper)); + if (result == NULL) { + return NULL; + } + + result->iterator = lm_NewJSFrameIterator(); + return result; +} + +void lm_FreeNSJSJavaFrameWrapperCB(struct NSJSJavaFrameWrapper *wrapper) +{ + PR_FREEIF(wrapper); +} + +void lm_GetStartFrameCB(struct NSJSJavaFrameWrapper *wrapper) +{ +} + +PRBool lm_IsEndOfFrameCB(struct NSJSJavaFrameWrapper *wrapper) +{ + if ((wrapper == NULL) || (wrapper->iterator == NULL)) + return PR_TRUE; + return PR_FALSE; +} + +PRBool lm_IsValidFrameCB(struct NSJSJavaFrameWrapper *wrapper) +{ + if (wrapper->iterator == NULL) { + return PR_FALSE; + } else { + return PR_TRUE; + } +} + +void *lm_GetNextFrameCB(struct NSJSJavaFrameWrapper *wrapper, int *depth) +{ + if ((wrapper->iterator == NULL) || + (!nextJSFrame(&(wrapper->iterator)))) { + return NULL; + } + (*depth)++; + return wrapper->iterator; +} + +void * lm_GetPrincipalArrayCB(struct NSJSJavaFrameWrapper *wrapper) +{ + JSFrameIterator *iterator; + if (wrapper->iterator == NULL) + return NULL; + iterator = wrapper->iterator; + return JS_GetFramePrincipalArray(iterator->cx, iterator->fp); +} + +void * lm_GetAnnotationCB(struct NSJSJavaFrameWrapper *wrapper) +{ + JSFrameIterator *iterator; + void *annotaion; + void *current; + + if (wrapper->iterator == NULL) { + return NULL; + } + iterator = wrapper->iterator; + + annotaion = JS_GetFrameAnnotation(iterator->cx, iterator->fp); + if (annotaion == NULL) + return NULL; + + current = JS_GetFramePrincipalArray(iterator->cx, iterator->fp); + + if (iterator->sawEmptyPrincipals || current == NULL || + (iterator->intersect && + !canExtendTrust(iterator->cx, current, iterator->intersect))) + return NULL; + + return annotaion; +} + +void * lm_SetAnnotationCB(struct NSJSJavaFrameWrapper *wrapper, void *privTable) +{ + if (wrapper->iterator) { + JSFrameIterator *iterator = wrapper->iterator; + JS_SetFrameAnnotation(iterator->cx, iterator->fp, privTable); + } + return privTable; +} + +/* End of Callbacks */ + +static PRBool privManagerInited = PR_FALSE; + +static void +setupJSCapsCallbacks() +{ + if (privManagerInited) return; + privManagerInited = TRUE; + + setNewNSJSJavaFrameWrapperCallback(lm_NewNSJSJavaFrameWrapperCB); + setFreeNSJSJavaFrameWrapperCallback(lm_FreeNSJSJavaFrameWrapperCB); + setGetStartFrameCallback(lm_GetStartFrameCB); + setIsEndOfFrameCallback(lm_IsEndOfFrameCB); + setIsValidFrameCallback(lm_IsValidFrameCB); + setGetNextFrameCallback(lm_GetNextFrameCB); + setOJIGetPrincipalArrayCallback(lm_GetPrincipalArrayCB); + setOJIGetAnnotationCallback(lm_GetAnnotationCB); + setOJISetAnnotationCallback(lm_SetAnnotationCB); +} + diff --git a/lib/libmocha/lm_win.c b/lib/libmocha/lm_win.c index 4d6eab384a27..ff310c693606 100644 --- a/lib/libmocha/lm_win.c +++ b/lib/libmocha/lm_win.c @@ -39,7 +39,10 @@ #include "libimg.h" /* Image Library public API. */ #include "prthread.h" -#ifdef JAVA +#if defined(JAVA) +#include "jsjava.h" +#elif defined (OJI) +#include "np2.h" #include "jsjava.h" #endif @@ -3222,7 +3225,20 @@ lm_InitWindowContent(MochaDecoder *decoder) if (!JS_InitStandardClasses(cx, obj)) return JS_FALSE; -#ifdef JAVA +#if defined(OJI) + { + PRBool jvmMochaPrefsEnabled = PR_FALSE; + if (NPL_IsJVMAndMochaPrefsEnabled() == PR_TRUE) { + jvmMochaPrefsEnabled = NPL_JSJInit(); + } + if ( (jvmMochaPrefsEnabled == PR_TRUE) + &&(!JSJ_InitJSContext(cx, obj, NULL)) + ) + { + return JS_FALSE; + } + } +#elif defined(JAVA) if (JSJ_IsEnabled() && !JSJ_InitContext(cx, obj)) return JS_FALSE; #endif diff --git a/lib/libmocha/macbuild/LibMocha.mcp b/lib/libmocha/macbuild/LibMocha.mcp index 7ccf69c9e34f..74862b0cef80 100644 Binary files a/lib/libmocha/macbuild/LibMocha.mcp and b/lib/libmocha/macbuild/LibMocha.mcp differ diff --git a/lib/plugin/Makefile b/lib/plugin/Makefile index 3ee3434e4ec9..6d8b3e3466e0 100644 --- a/lib/plugin/Makefile +++ b/lib/plugin/Makefile @@ -1,46 +1 @@ -#!gmake -# -# The contents of this file are subject to the Netscape Public License -# Version 1.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. 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 this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. - -DEPTH = ../.. - -MODULE = plug -LIBRARY_NAME = plug - -CSRCS = npassoc.c - -CPPSRCS = nsplugin.cpp - -EXPORTS = nppg.h npupp.h nsIPlug.h nsILCPlg.h npglue.h nppriv.h - -REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom netcnvts oji - -ifeq ($(subst /,_,$(shell uname -s)),OS2) -CPPSRCS = npwplat.cpp -REQUIRES += xp libfont os2font jtools -endif - -CPPSRCS += npglue.cpp - -include $(DEPTH)/config/rules.mk - -ifeq ($(subst /,_,$(shell uname -s)),OS2) -INCLUDES += -I$(DEPTH)/cmd/os2fe/nfc/include -I$(DEPTH)/cmd/os2fe -I$(DEPTH)/cmd/winfe -endif - -INCLUDES += -I. - -$(LIBRARY): $(OBJS) +Use the version in mozilla/modules/plugin/src now. diff --git a/lib/plugin/javap.c b/lib/plugin/javap.c deleted file mode 100644 index c896cb0de4e4..000000000000 --- a/lib/plugin/javap.c +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. 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 this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#include "npapi.h" - -#include -#include -#include -#include - -#if defined(__sun) -# include "sunos4.h" -#endif /* __sun */ - -#ifdef DEBUG -extern int np_debug; -static void -nptrace (const char* message, ...) -{ - int len; - char buf[2048]; - va_list stack; - - va_start (stack, message); - len = vsprintf (buf, message, stack); - va_end (stack); - len = strlen(buf); - fwrite("\t\tjp: ", 1, 6, stderr); - fwrite(buf, 1, len, stderr); - if (buf[len-1] != '\n') - fwrite("\n", 1, 1, stderr); -} -#define NPTRACE(l,t) { if(np_debug>l){nptrace t;}} -#else -#define NPTRACE(l,t) {} -#endif - -#include "npupp.h" -extern NPNetscapeFuncs *np_nfuncs; - -static int inum = 1; - -static NPError -javap_new(void *j, NPP npp, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved) -{ - if(mode==NP_EMBED) { - NPTRACE(0,("new embed")); - } else { - NPTRACE(0,("new full")); - } - return 0; -} - -static NPError -javap_destroy(NPP instance, NPSavedData **save) -{ - NPTRACE(0,("destroy")); - return 0; -} - -static NPError -javap_setwindow(NPP instance, NPWindow *window) -{ - NPTRACE(0,("setwindow x %d y %d w %d h %d", window->x, window->y, window->width, window->height)); - return 0; -} - -static NPError -javap_newstream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype) -{ - NPTRACE(0,("new stream")); - - switch(inum) - { - case 1: - { - NPByteRange a, b; - *stype = NP_SEEK; - a.offset = 0; - a.length = 60; - b.offset = 252525; - b.length = 10; - a.next = &b; - b.next = 0; - np_nfuncs->requestread(stream, &a); - } - break; - - case 2: - *stype = NP_ASFILE; - break; - - case 3: - { - np_nfuncs->geturl(instance, "about:", "_current"); - } - break; - } - inum++; - - np_nfuncs->status(instance, "wow"); - - return 0; -} - -static int32 -javap_write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) -{ - char buf[64]; - NPTRACE(0,("got %d bytes at %d", len, offset)); - - return 0; - strncpy(buf, (const char *)buffer, 63); - buf[63]=0; - NPTRACE(0,("\"%s\"", (char *)buf)); - fwrite(buffer, len, 1, stream->pdata); - return 0; -} - -static NPError -javap_closestream(NPP instance, NPStream *stream, NPError reason) -{ - NPTRACE(0,("sclose")); - pclose(stream->pdata); - return 0; -} - -static void -javap_asfile(NPP instance, NPStream *stream, const char *fname) -{ - NPTRACE(0,("fname: \"%s\"", fname)); -} - - -NPPluginFuncs javap_funcs = { - javap_new, - javap_destroy, - javap_setwindow, - javap_newstream, - javap_closestream, - javap_asfile, - NULL, - javap_write, - NULL, - NULL -}; - -NPPluginFuncs *j_pfncs = &javap_funcs; diff --git a/modules/Makefile b/modules/Makefile index 55188d2f6dcd..567408e2dcf9 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -20,20 +20,20 @@ DEPTH = .. include $(DEPTH)/config/config.mk -DIRS = \ +DIRS = \ libhook \ - libreg \ + libreg \ libpref \ libutil \ libimg \ libfont \ - libreg \ rdf \ xml \ schedulr \ - zlib \ - li \ - progress \ + zlib \ + li \ + progress \ + plugin \ $(NULL) ifndef MOZ_SECURITY @@ -50,9 +50,9 @@ endif ifdef EDITOR -ifdef JAVA_OR_OJI +ifdef JAVA_OR_NSJVM # change later to JAVA_OR_OJI DIRS += edtplug -endif # JAVA_OR_OJI +endif # JAVA_OR_NSJVM DIRS += spellchk endif # EDITOR diff --git a/modules/edtplug/classes/Makefile b/modules/edtplug/classes/Makefile index 5e2a3d27800d..e77bacfbfe36 100644 --- a/modules/edtplug/classes/Makefile +++ b/modules/edtplug/classes/Makefile @@ -16,6 +16,9 @@ # DEPTH = ../../.. +ifdef JAVA_OR_NSJVM DIRS = netscape +else +endif include $(DEPTH)/config/rules.mk diff --git a/modules/edtplug/classes/makefile.win b/modules/edtplug/classes/makefile.win index dbda41bb1777..bfb1c4c28edc 100644 --- a/modules/edtplug/classes/makefile.win +++ b/modules/edtplug/classes/makefile.win @@ -20,6 +20,16 @@ IGNORE_MANIFEST=1 # DEPTH=..\..\.. + +!ifdef NSJVM + DIRS=netscape +!else + +export:: + + +!endif + include <$(DEPTH)\config\rules.mak> diff --git a/modules/libfont/public/Makefile b/modules/libfont/public/Makefile index f1d628849390..a57f406bf05a 100644 --- a/modules/libfont/public/Makefile +++ b/modules/libfont/public/Makefile @@ -19,7 +19,7 @@ DEPTH = ../../.. include $(DEPTH)/config/config.mk -ifndef JAVA_OR_OJI +ifndef JAVA_OR_NSJVM LOCAL_JMC_SUBDIR = ../jmcgen/include endif diff --git a/modules/libfont/public/makefile.win b/modules/libfont/public/makefile.win index ee97c3ba3f6f..36b439c1211d 100644 --- a/modules/libfont/public/makefile.win +++ b/modules/libfont/public/makefile.win @@ -20,7 +20,7 @@ IGNORE_MANIFEST=1 DEPTH=..\..\.. !include $(DEPTH)\config\config.mak -!ifndef JAVA_OR_OJI +!ifndef JAVA_OR_NSJVM LOCAL_JMC_SUBDIR = ..\jmcgen\include !endif @@ -32,7 +32,7 @@ EXPORTS=$(JMC_GEN_DIR)\Mnfdoer.h $(JMC_GEN_DIR)\Mnff.h \ $(JMC_GEN_DIR)\Mnffbu.h $(JMC_GEN_DIR)\Mnffmi.h \ $(JMC_GEN_DIR)\Mnffp.h $(JMC_GEN_DIR)\Mnfrc.h $(JMC_GEN_DIR)\Mnfrf.h \ $(JMC_GEN_DIR)\Mnfstrm.h $(JMC_GEN_DIR)\Mnfdlm.h -!if !defined(JAVA_OR_OJI) +!if !defined(JAVA_OR_NSJVM) EXPORTS=$(EXPORTS) $(JMC_GEN_DIR)\Mwinfp.h !endif diff --git a/modules/libfont/src/Makefile b/modules/libfont/src/Makefile index 11eeb9de2684..9dfad78be349 100644 --- a/modules/libfont/src/Makefile +++ b/modules/libfont/src/Makefile @@ -19,7 +19,7 @@ DEPTH = ../../.. include $(DEPTH)/config/config.mk -ifndef JAVA_OR_OJI +ifndef JAVA_OR_NSJVM LOCAL_JMC_SUBDIR = ../jmcgen/include LOCAL_JMC_SRC_SUBDIR = ../jmcgen/src endif @@ -64,7 +64,7 @@ SDK_TARGET = producer-sdk SDK_NAME = FontProducer-sdk-v1.0 SDK_DIR = $(OBJDIR)/$(SDK_TARGET) -ifndef JAVA_OR_OJI +ifndef JAVA_OR_NSJVM export:: @echo "Copying JMC src files from $(LOCAL_JMC_SRC_SUBDIR)/*.c to cwd" @for FILE in $(LOCAL_JMC_SRC_SUBDIR)/*.c ;\ diff --git a/modules/libfont/src/makefile.win b/modules/libfont/src/makefile.win index 11a628f471c5..da4319dba6e9 100644 --- a/modules/libfont/src/makefile.win +++ b/modules/libfont/src/makefile.win @@ -65,14 +65,14 @@ LINCS=-I$(XPDIST)\public\libfont -I$(XPDIST)\public\java \ -I$(XPDIST)\public\htmldlgs -I$(XPDIST)\public\security !endif -!if !defined (JAVA_OR_OJI) +!if !defined (JAVA_OR_NSJVM) LOCAL_JMC_SUBDIR = ..\jmcgen\include LOCAL_JMC_SRC_SUBDIR = ..\jmcgen\src !endif !include $(DEPTH)\config\rules.mak -!if !defined (JAVA_OR_OJI) +!if !defined (JAVA_OR_NSJVM) export:: @echo +++ make: Copying JMC src files from $(LOCAL_JMC_SRC_SUBDIR)/*.c to cwd -for %f in ($(LOCAL_JMC_SRC_SUBDIR)\*.c) do $(MAKE_INSTALL) %f . diff --git a/modules/libfont/src/wfStream.cpp b/modules/libfont/src/wfStream.cpp index 9096d39a8bdd..1fcb85d1f383 100644 --- a/modules/libfont/src/wfStream.cpp +++ b/modules/libfont/src/wfStream.cpp @@ -80,7 +80,7 @@ extern "C" int wfWrite(NET_StreamClass *stream, const unsigned char *str, int32 len) { struct stream_data *data = (struct stream_data *) stream->data_object; - return ((int)nfstrm_Write((nfstrm *)data->fpStream, (char *)str, (jint)len, NULL)); + return ((int)nfstrm_Write((nfstrm *)data->fpStream, (jbyte *)str, (jint)len, NULL)); } #ifndef XP_OS2 diff --git a/modules/oji/Makefile b/modules/oji/Makefile index 2d147bd70d51..46dc9f6fe3a2 100644 --- a/modules/oji/Makefile +++ b/modules/oji/Makefile @@ -20,7 +20,7 @@ DEPTH=../.. #// DIRS - There are subdirectories to process #// #//------------------------------------------------------------------------ -DIRS= src +DIRS= public src #//------------------------------------------------------------------------ #// diff --git a/modules/oji/macbuild/oji.mcp b/modules/oji/macbuild/oji.mcp index 7229e74abda7..3c93bc434f93 100644 Binary files a/modules/oji/macbuild/oji.mcp and b/modules/oji/macbuild/oji.mcp differ diff --git a/modules/oji/makefile.win b/modules/oji/makefile.win index 75c6c7f488f9..b4dccf752740 100644 --- a/modules/oji/makefile.win +++ b/modules/oji/makefile.win @@ -20,7 +20,7 @@ DEPTH=..\.. #// DIRS - There are subdirectories to process #// #//------------------------------------------------------------------------ -DIRS= src +DIRS= public src #//------------------------------------------------------------------------ #// diff --git a/modules/oji/public/MANIFEST b/modules/oji/public/MANIFEST index ef22c26bfc7a..d4589c41e85e 100644 --- a/modules/oji/public/MANIFEST +++ b/modules/oji/public/MANIFEST @@ -25,3 +25,6 @@ nsIJVMManager.h nsIJVMPlugin.h nsIJVMPluginInstance.h nsIJVMPluginTagInfo.h +nsISymantecDebugger.h +nsISymantecDebugManager.h +nsjvm.h diff --git a/modules/oji/public/nsIJRIPlugin.h b/modules/oji/public/nsIJRIPlugin.h index 0df2d1f3f0f1..9db77953c9ff 100644 --- a/modules/oji/public/nsIJRIPlugin.h +++ b/modules/oji/public/nsIJRIPlugin.h @@ -43,8 +43,8 @@ public: // Find or create a JRIEnv for the current thread. // Returns NULL if an error occurs. - NS_IMETHOD_(JRIEnv*) - GetJRIEnv(void) = 0; + NS_IMETHOD_(nsrefcnt) + GetJRIEnv(JRIEnv* *result) = 0; // This method must be called when the caller is done using the JRIEnv. // This decrements a refcount associated with it may free it. diff --git a/modules/oji/public/nsIJVMConsole.h b/modules/oji/public/nsIJVMConsole.h index 709d6ddb8739..3e1ec09c65c5 100644 --- a/modules/oji/public/nsIJVMConsole.h +++ b/modules/oji/public/nsIJVMConsole.h @@ -41,19 +41,19 @@ public: // QueryInterface on nsIJVMPlugin to get this. - NS_IMETHOD_(void) + NS_IMETHOD ShowConsole(void) = 0; - NS_IMETHOD_(void) + NS_IMETHOD HideConsole(void) = 0; - NS_IMETHOD_(PRBool) - IsConsoleVisible(void) = 0; + NS_IMETHOD + IsConsoleVisible(PRBool *result) = 0; // Prints a message to the Java console. The encodingName specifies the // encoding of the message, and if NULL, specifies the default platform // encoding. - NS_IMETHOD_(void) + NS_IMETHOD Print(const char* msg, const char* encodingName = NULL) = 0; }; diff --git a/modules/oji/public/nsIJVMManager.h b/modules/oji/public/nsIJVMManager.h index 8cb264e1f12a..525bdffa2370 100644 --- a/modules/oji/public/nsIJVMManager.h +++ b/modules/oji/public/nsIJVMManager.h @@ -29,20 +29,18 @@ #ifndef nsIJVMManager_h___ #define nsIJVMManager_h___ -#include "nsplugin.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// #define NPJVM_MIME_TYPE "application/x-java-vm" // XXX application/java -enum nsJVMError { - nsJVMError_Ok = nsPluginError_NoError, - nsJVMError_Base = 0x1000, - nsJVMError_InternalError = nsJVMError_Base, - nsJVMError_NoClasses, - nsJVMError_WrongClasses, - nsJVMError_JavaError, - nsJVMError_NoDebugger +enum { + NS_JVM_ERROR_BASE = NS_ERROR_BASE + 0x10000, + NS_JVM_ERROR_NO_CLASSES, + NS_JVM_ERROR_WRONG_CLASSES, + NS_JVM_ERROR_JAVA_ERROR, + NS_JVM_ERROR_NO_DEBUGGER }; //////////////////////////////////////////////////////////////////////////////// @@ -55,12 +53,6 @@ class nsIJVMPlugin; class nsIJVMManager : public nsISupports { public: - // This method may be called by the JVM to indicate that an error has - // occurred, e.g. that the JVM has failed or is shutting down spontaneously. - // This allows the browser to clean up any JVM-specific state. - NS_IMETHOD_(void) - NotifyJVMStatusChange(nsJVMError error) = 0; - }; #define NS_IJVMMANAGER_IID \ diff --git a/modules/oji/public/nsIJVMPlugin.h b/modules/oji/public/nsIJVMPlugin.h index 834ec95826bf..953ab7be531c 100644 --- a/modules/oji/public/nsIJVMPlugin.h +++ b/modules/oji/public/nsIJVMPlugin.h @@ -38,11 +38,17 @@ // to implement in order to implement a Java virtual machine plugin. struct nsJVMInitArgs { - jint version; + PRUint32 version; const char* classpathAdditions; // appended to the JVM's classpath + // other fields may be added here for version numbers beyond 0x00010000 }; -#define nsJVMInitArgs_Version 0x00010000 +/** + * nsJVMInitArgs_Version is the current version number for the nsJVMInitArgs + * struct specified above. The nsVersionOk macro should be used when comparing + * a supplied nsJVMInitArgs struct against this version. + */ +#define nsJVMInitArgs_Version 0x00010000L class nsIJVMPlugin : public nsIPlugin { public: @@ -52,43 +58,43 @@ public: // Note that calling this method is distinctly separate from // initializing the nsIJVMPlugin object (done by the Initialize // method). - NS_IMETHOD_(nsJVMError) + NS_IMETHOD StartupJVM(nsJVMInitArgs* initargs) = 0; // This method us used to stop the Java virtual machine. // It tears down any global state necessary to host Java programs. // The fullShutdown flag specifies whether the browser is quitting // (PR_TRUE) or simply whether the JVM is being shut down (PR_FALSE). - NS_IMETHOD_(nsJVMError) - ShutdownJVM(PRBool fullShutdown) = 0; + NS_IMETHOD + ShutdownJVM(PRBool fullShutdown = PR_FALSE) = 0; // Causes the JVM to append a new directory to its classpath. // If the JVM doesn't support this operation, an error is returned. - NS_IMETHOD_(nsJVMError) + NS_IMETHOD AddToClassPath(const char* dirPath) = 0; // Causes the JVM to remove a directory from its classpath. // If the JVM doesn't support this operation, an error is returned. - NS_IMETHOD_(nsJVMError) + NS_IMETHOD RemoveFromClassPath(const char* dirPath) = 0; // Returns the current classpath in use by the JVM. - NS_IMETHOD_(const char*) - GetClassPath(void) = 0; + NS_IMETHOD + GetClassPath(const char* *result) = 0; - NS_IMETHOD_(nsIPluginInstance*) - GetPluginInstance(jobject javaObject) = 0; + NS_IMETHOD + GetPluginInstance(jobject javaObject, nsIPluginInstance* *result) = 0; - NS_IMETHOD_(nsIPluginInstance*) - GetPluginInstance(JNIEnv* jenv) = 0; + NS_IMETHOD + GetPluginInstance(JNIEnv* jenv, nsIPluginInstance* *result) = 0; - NS_IMETHOD_(JavaVM *) - GetJavaVM(void) = 0; + NS_IMETHOD + GetJavaVM(JavaVM* *result) = 0; // Find or create a JNIEnv for the current thread. // Returns NULL if an error occurs. - NS_IMETHOD_(JNIEnv*) - GetJNIEnv(void) = 0; + NS_IMETHOD_(nsrefcnt) + GetJNIEnv(JNIEnv* *result) = 0; // This method must be called when the caller is done using the JNIEnv. // This decrements a refcount associated with it may free it. diff --git a/modules/oji/public/nsIJVMPluginInstance.h b/modules/oji/public/nsIJVMPluginInstance.h index 26ead59330e8..3849834342d6 100644 --- a/modules/oji/public/nsIJVMPluginInstance.h +++ b/modules/oji/public/nsIJVMPluginInstance.h @@ -39,15 +39,11 @@ public: // This method is called when LiveConnect wants to find the Java object // associated with this plugin instance, e.g. the Applet or JavaBean object. - NS_IMETHOD_(jobject) - GetJavaObject(void) = 0; + NS_IMETHOD + GetJavaObject(jobject *result) = 0; - /* =-= sudu: Ask Eric Bina, what is GetText used for in layform.c - Check to see if this should be more general api applicaple to - applets/beans and plugins. - */ - NS_IMETHOD_(const char*) - GetText(void) = 0; + NS_IMETHOD + GetText(const char* *result) = 0; }; #define NS_IJVMPLUGININSTANCE_IID \ diff --git a/modules/oji/public/nsIJVMPluginTagInfo.h b/modules/oji/public/nsIJVMPluginTagInfo.h index 404512ebd337..ff414ccea486 100644 --- a/modules/oji/public/nsIJVMPluginTagInfo.h +++ b/modules/oji/public/nsIJVMPluginTagInfo.h @@ -39,20 +39,20 @@ class nsIJVMPluginTagInfo : public nsISupports { public: - NS_IMETHOD_(const char *) - GetCode(void) = 0; + NS_IMETHOD + GetCode(const char* *result) = 0; - NS_IMETHOD_(const char *) - GetCodeBase(void) = 0; + NS_IMETHOD + GetCodeBase(const char* *result) = 0; - NS_IMETHOD_(const char *) - GetArchive(void) = 0; + NS_IMETHOD + GetArchive(const char* *result) = 0; - NS_IMETHOD_(const char *) - GetName(void) = 0; + NS_IMETHOD + GetName(const char* *result) = 0; - NS_IMETHOD_(PRBool) - GetMayScript(void) = 0; + NS_IMETHOD + GetMayScript(PRBool *result) = 0; }; diff --git a/modules/oji/public/nsISymantecDebugManager.h b/modules/oji/public/nsISymantecDebugManager.h index 6f200f2f7660..62d3a3f2d64a 100644 --- a/modules/oji/public/nsISymantecDebugManager.h +++ b/modules/oji/public/nsISymantecDebugManager.h @@ -38,7 +38,7 @@ class nsISymantecDebugManager : public nsISupports { public: - NS_IMETHOD_(PRBool) + NS_IMETHOD SetDebugAgentPassword(PRInt32 pwd) = 0; }; diff --git a/modules/oji/public/nsISymantecDebugger.h b/modules/oji/public/nsISymantecDebugger.h index a0b6cc73cf81..0505ac10501d 100644 --- a/modules/oji/public/nsISymantecDebugger.h +++ b/modules/oji/public/nsISymantecDebugger.h @@ -44,7 +44,7 @@ enum nsSymantecDebugPort { class nsISymantecDebugger : public nsISupports { public: - NS_IMETHOD_(nsJVMError) + NS_IMETHOD StartDebugger(nsSymantecDebugPort port) = 0; }; diff --git a/modules/oji/public/nsjvm.h b/modules/oji/public/nsjvm.h index 11dff556b8c1..8c08d12d9e5b 100644 --- a/modules/oji/public/nsjvm.h +++ b/modules/oji/public/nsjvm.h @@ -29,6 +29,7 @@ #ifndef nsjvm_h___ #define nsjvm_h___ +#include "nsplugin.h" #include "nsIJRIPlugin.h" #include "nsIJVMConsole.h" #include "nsIJVMManager.h" diff --git a/modules/oji/src/MANIFEST b/modules/oji/src/MANIFEST index 165e19d556c7..29f995b004b9 100644 --- a/modules/oji/src/MANIFEST +++ b/modules/oji/src/MANIFEST @@ -3,5 +3,3 @@ # jvmmgr.h -nsjvm.h -nsscd.h diff --git a/modules/oji/src/Makefile b/modules/oji/src/Makefile index 9ee24c439620..c99a0099ed88 100644 --- a/modules/oji/src/Makefile +++ b/modules/oji/src/Makefile @@ -6,19 +6,18 @@ DEPTH = ../../.. -MODULE = oji +MODULE = ojiimpl ifdef MOZ_OJI LIBRARY_NAME = oji CPPSRCS = jvmmgr.cpp \ - jvmpeer.cpp \ scd.cpp -REQUIRES = img java js lay layer plug pref style util xpcom +REQUIRES = img java js lay layer plugin plugimpl pref style util xpcom raptor oji endif # MOZ_OJI -EXPORTS = nsjvm.h jvmmgr.h nsscd.h +EXPORTS = jvmmgr.h include $(DEPTH)/config/rules.mk diff --git a/modules/oji/src/jvmmgr.cpp b/modules/oji/src/jvmmgr.cpp index fa96ab0d7464..098f7572649a 100644 --- a/modules/oji/src/jvmmgr.cpp +++ b/modules/oji/src/jvmmgr.cpp @@ -21,12 +21,22 @@ //////////////////////////////////////////////////////////////////////////////// #include "jvmmgr.h" +#include "npglue.h" #include "xp.h" #include "net.h" #include "prefapi.h" #include "xp_str.h" #include "libmocha.h" #include "np.h" +#include "prio.h" +#include "prmem.h" +#include "plstr.h" +#include "jni.h" +#include "jsjava.h" +#ifdef MOCHA +#include "libmocha.h" +#include "libevent.h" +#endif #include "xpgetstr.h" extern "C" int XP_PROGRESS_STARTING_JAVA; @@ -45,61 +55,78 @@ void stopAsyncCursors(void); } #endif // XP_MAC +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIJVMManagerIID, NS_IJVMMANAGER_IID); +static NS_DEFINE_IID(kIJVMPluginIID, NS_IJVMPLUGIN_IID); +static NS_DEFINE_IID(kISymantecDebugManagerIID, NS_ISYMANTECDEBUGMANAGER_IID); +static NS_DEFINE_IID(kIJVMPluginInstanceIID, NS_IJVMPLUGININSTANCE_IID); +static NS_DEFINE_IID(kIJVMPluginTagInfoIID, NS_IJVMPLUGINTAGINFO_IID); +static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID); +static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); +static NS_DEFINE_IID(kIJVMConsoleIID, NS_IJVMCONSOLE_IID); +static NS_DEFINE_IID(kISymantecDebuggerIID, NS_ISYMANTECDEBUGGER_IID); + //////////////////////////////////////////////////////////////////////////////// -NS_IMPL_AGGREGATED(JVMMgr); - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIJVMPluginManagerIID, NP_IJVMPLUGINMANAGER_IID); -static NS_DEFINE_IID(kIJVMPluginIID, NP_IJVMPLUGIN_IID); -static NS_DEFINE_IID(kISymantecDebugManagerIID, NP_ISYMANTECDEBUGMANAGER_IID); +NS_IMPL_AGGREGATED(nsJVMMgr); NS_METHOD -JVMMgr::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) +nsJVMMgr::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) { if (outer && !aIID.Equals(kISupportsIID)) return NS_NOINTERFACE; // XXX right error? - JVMMgr* jvmMgr = new JVMMgr(outer); - nsresult result = jvmMgr->QueryInterface(aIID, aInstancePtr); + nsJVMMgr* jvmmgr = new nsJVMMgr(outer); + nsresult result = jvmmgr->QueryInterface(aIID, aInstancePtr); if (result != NS_OK) { - delete jvmMgr; + delete jvmmgr; } return result; } -NPIJVMPlugin* -JVMMgr::GetJVM(void) +nsIJVMPlugin* +nsJVMMgr::GetJVMPlugin(void) { - if (fJVM) { + // lazily loads the JVM plugin. + if (fJVM == NULL) { + nsIPlugin* plugin = NPL_LoadPluginByType(NPJVM_MIME_TYPE); + if (plugin != NULL) { + nsresult rslt = plugin->QueryInterface(kIJVMPluginIID, (void**)&fJVM); + if (rslt != NS_OK) fJVM = NULL; + } + } + // always add an additional reference. + if (fJVM != NULL) { fJVM->AddRef(); return fJVM; } - NPIPlugin* plugin = NPL_LoadPluginByType(NPJVM_MIME_TYPE); - if (plugin) { - nsresult rslt = plugin->QueryInterface(kIJVMPluginIID, (void**)&fJVM); - if (rslt == NS_OK) return fJVM; - } return NULL; } -JVMMgr::JVMMgr(nsISupports* outer) - : fJVM(NULL), fWaiting(0), fOldCursor(NULL), fProgramPath(NULL) +nsJVMMgr::nsJVMMgr(nsISupports* outer) + : fJVM(NULL), fStatus(nsJVMStatus_Enabled), + fRegisteredJavaPrefChanged(PR_FALSE), fDebugManager(NULL), fJSJavaVM(NULL), + fClassPathAdditions(new nsVector()) { NS_INIT_AGGREGATED(outer); } -JVMMgr::~JVMMgr() +nsJVMMgr::~nsJVMMgr() { + int count = fClassPathAdditions->GetSize(); + for (int i = 0; i < count; i++) { + PR_Free((*fClassPathAdditions)[i]); + } + delete fClassPathAdditions; if (fJVM) { - nsrefcnt c = fJVM->Release(); // Release for QueryInterface in GetJVM + /*nsrefcnt c =*/ fJVM->Release(); // Release for QueryInterface in GetJVM // XXX unload plugin if c == 1 ? (should this be done inside Release?) } } NS_METHOD -JVMMgr::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) +nsJVMMgr::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) { - if (aIID.Equals(kIJVMPluginManagerIID)) { + if (aIID.Equals(kIJVMManagerIID)) { *aInstancePtr = this; AddRef(); return NS_OK; @@ -119,190 +146,313 @@ JVMMgr::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) } //////////////////////////////////////////////////////////////////////////////// - -NS_METHOD_(void) -JVMMgr::BeginWaitCursor(void) -{ - if (fWaiting == 0) { -#ifdef XP_PC - fOldCursor = (void*)GetCursor(); - HCURSOR newCursor = LoadCursor(NULL, IDC_WAIT); - if (newCursor) - SetCursor(newCursor); -#endif -#ifdef XP_MAC - startAsyncCursors(); -#endif - } - fWaiting++; -} - -NS_METHOD_(void) -JVMMgr::EndWaitCursor(void) -{ - fWaiting--; - if (fWaiting == 0) { -#ifdef XP_PC - if (fOldCursor) - SetCursor((HCURSOR)fOldCursor); -#endif -#ifdef XP_MAC - stopAsyncCursors(); -#endif - fOldCursor = NULL; - } -} - +// LiveConnect callbacks //////////////////////////////////////////////////////////////////////////////// -NS_METHOD_(const char*) -JVMMgr::GetProgramPath(void) +template +class ThreadLocalStorage { +public: + ThreadLocalStorage(PRThreadPrivateDTOR dtor) : mIndex(0), mValid(PR_FALSE) + { + mValid = (PR_NewThreadPrivateIndex(&mIndex, dtor) == PR_SUCCESS); + } + + void set(T value) + { + if (mValid) PR_SetThreadPrivate(mIndex, value); + } + + T get() + { + return (T) (mValid ? PR_GetThreadPrivate(mIndex) : 0); + } + +private: + PRUintn mIndex; + PRBool mValid; +}; + +PR_BEGIN_EXTERN_C + +#include "jscntxt.h" + +#ifdef MOCHA + +PR_EXTERN(JSContext*) map_jsj_thread_to_js_context_impl(JNIEnv *env, char **errp); +PR_EXTERN(JSJavaThreadState*) map_js_context_to_jsj_thread_impl(JSContext *cx, char **errp); +PR_EXTERN(JSObject*) map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp); +PR_EXTERN(JavaVM*) get_java_vm_impl(char **errp); + +PR_EXTERN_DATA(JSContext*) lm_crippled_context; /* XXX kill me */ + +PR_IMPLEMENT(JSContext *) +map_jsj_thread_to_js_context_impl(JNIEnv *env, char **errp) { - return fProgramPath; -} + JSContext *cx = lm_crippled_context; + PRBool jvmMochaPrefsEnabled = PR_FALSE; -NS_METHOD_(const char*) -JVMMgr::GetTempDirPath(void) -{ - // XXX I don't need a static really, the browser holds the tempDir name - // as a static string -- it's just the XP_TempDirName that strdups it. - static const char* tempDirName = NULL; - if (tempDirName == NULL) - tempDirName = XP_TempDirName(); - return tempDirName; -} - -NS_METHOD -JVMMgr::GetFileName(const char* fn, FileNameType type, - char* resultBuf, PRUint32 bufLen) -{ - // XXX This should be rewritten so that we don't have to malloc the name. - XP_FileType filetype; - - if (type == SIGNED_APPLET_DBNAME) - filetype = xpSignedAppletDB; - else if (type == TEMP_FILENAME) - filetype = xpTemporary; - else - return NS_ERROR_ILLEGAL_VALUE; - - char* tempName = WH_FileName(fn, filetype); - if (tempName == NULL) - return NS_ERROR_OUT_OF_MEMORY; - XP_STRNCPY_SAFE(resultBuf, tempName, bufLen); - XP_FREE(tempName); - return NS_OK; -} - -NS_METHOD -JVMMgr::NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) -{ - // XXX This should be rewritten so that we don't have to malloc the name. - char* tempName = WH_TempName(xpTemporary, prefix); - if (tempName == NULL) - return NS_ERROR_OUT_OF_MEMORY; - XP_STRNCPY_SAFE(resultBuf, tempName, bufLen); - XP_FREE(tempName); - return NS_OK; -} - -NS_METHOD_(PRBool) -JVMMgr::HandOffJSLock(PRThread* oldOwner, PRThread* newOwner) -{ - return LM_HandOffJSLock(oldOwner, newOwner); -} - -//////////////////////////////////////////////////////////////////////////////// - -// Should be in a header; must solve build-order problem first -extern "C" void VR_Initialize(JRIEnv* env); -extern "C" void SU_Initialize(JRIEnv * env); - -JVMStatus -JVMMgr::StartupJVM(void) -{ - // Be sure to check the prefs first before asking java to startup. - if (GetJVMStatus() == JVMStatus_Disabled) { - return JVMStatus_Disabled; - } - JVMStatus status = fJVM->StartupJVM(); - if (status == JVMStatus_Running) { - JVMEnv* env = fJVM->EnsureExecEnv(); - - /* initialize VersionRegistry native routines */ - /* it is not an error that prevents java from starting if this stuff throws exceptions */ -#ifdef XP_MAC - if (env->ExceptionOccurred()) { -#ifdef DEBUG - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - return ShutdownJVM(); + *errp = NULL; + + nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); + if (pJVMMgr != NULL) { + nsIJVMPlugin* pJVMPI = pJVMMgr->GetJVMPlugin(); + jvmMochaPrefsEnabled = pJVMMgr->IsJVMAndMochaPrefsEnabled(); + if (pJVMPI != NULL) { + nsIPluginInstance* pPIT; + nsresult err = pJVMPI->GetPluginInstance(env, &pPIT); + if ( (err == NS_OK) && (pPIT != NULL) ) { + nsIJVMPluginInstance* pJVMPIT; + if (pPIT->QueryInterface(kIJVMPluginInstanceIID, + (void**)&pJVMPIT) == NS_OK) { + nsPluginInstancePeer* pPITP; + err = pJVMPIT->GetPeer((nsIPluginInstancePeer**)&pPITP); + if ( (err == NS_OK) &&(pPITP != NULL) ) { + cx = pPITP->GetJSContext(); + pPITP->Release(); + } + pJVMPIT->Release(); + } + pPIT->Release(); + } + pJVMPI->Release(); } -#else - - SU_Initialize(env); - if (JRI_ExceptionOccurred(env)) { -#ifdef DEBUG - fJVM->PrintToConsole("LJ: SU_Initialize failed. Bugs to atotic.\n"); - JRI_ExceptionDescribe(env); -#endif - JRI_ExceptionClear(env); - return ShutdownJVM(); - } -#endif /* !XP_MAC */ + pJVMMgr->Release(); } - return status; + if (jvmMochaPrefsEnabled == PR_FALSE) + { + *errp = strdup("Java preference is disabled"); + return NULL; + } + + if ( cx == NULL ) + { + *errp = strdup("Java thread could not be associated with a JSContext"); + return NULL; + } + + return cx; } -JVMStatus -JVMMgr::ShutdownJVM(PRBool fullShutdown) + static void PR_CALLBACK detach_jsjava_thread_state(void* env) + { + JSJavaThreadState *jsj_env = (JSJavaThreadState*)env; + JSJ_DetachCurrentThreadFromJava(jsj_env); + } + +/* +** This callback is called to map a JSContext to a JSJavaThreadState which +** is a wrapper around JNIEnv. Hence this callback essentially maps a JSContext +** to a java thread. JSJ_AttachCurrentThreadToJava just calls AttachCurrentThread +** on the java vm. +*/ +PR_IMPLEMENT(JSJavaThreadState *) +map_js_context_to_jsj_thread_impl(JSContext *cx, char **errp) { - if (fJVM) - return fJVM->ShutdownJVM(); - return JVMStatus_Enabled; // XXX what if there's no plugin available? + *errp = NULL; + + static ThreadLocalStorage localThreadState(&detach_jsjava_thread_state); + JSJavaThreadState* jsj_env = localThreadState.get(); + if (jsj_env != NULL) + return jsj_env; + + if (ET_InitMoja(0) != LM_MOJA_OK) { + *errp = strdup("LiveConnect initialization failed."); + return NULL; + } + + JSJavaVM* js_jvm = NULL; + nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); + if (pJVMMgr != NULL) { + js_jvm = pJVMMgr->GetJSJavaVM(); + pJVMMgr->Release(); + if (js_jvm == NULL) { + *errp = strdup("Failed to attach to a Java VM."); + return NULL; + } + } + + jsj_env = JSJ_AttachCurrentThreadToJava(js_jvm, NULL, NULL); + localThreadState.set(jsj_env); + + return jsj_env; } -//////////////////////////////////////////////////////////////////////////////// - -static int PR_CALLBACK -JavaPrefChanged(const char *prefStr, void* data) +/* +** This callback is called to map a applet,bean to its corresponding JSObject +** created on javascript side and then map that to a java wrapper JSObject class. +** This callback is called in JSObject.getWindow implementation to get +** a java wrapper JSObject class for a applet only once. +** Note that once a mapping between applet -> javascript JSObject -> Java wrapper JSObject +** is made, all subsequent method calls via JSObject use the internal field +** to get to the javascript JSObject. +*/ +PR_IMPLEMENT(JSObject *) +map_java_object_to_js_object_impl(JNIEnv *env, jobject applet, char **errp) { - JVMMgr* mgr = (JVMMgr*)data; - XP_Bool prefBool; - PREF_GetBoolPref(prefStr, &prefBool); - mgr->SetJVMEnabled((PRBool)prefBool); + MWContext *cx; + JSObject *window; + MochaDecoder *decoder; + PRBool mayscript = PR_FALSE; + PRBool jvmMochaPrefsEnabled = PR_FALSE; + + *errp = NULL; + /* XXX assert JS is locked */ + + if (!applet) { + env->ThrowNew(env->FindClass("java/lang/NullPointerException"),0); + return 0; + } + if (!env->IsInstanceOf(applet, + env->FindClass("java/applet/Applet"))) { + env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), + "JSObject.getWindow() requires a java.applet.Applet argument"); + return 0; + } + + nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); + if (pJVMMgr != NULL) { + nsIJVMPlugin* pJVMPI = pJVMMgr->GetJVMPlugin(); + jvmMochaPrefsEnabled = pJVMMgr->IsJVMAndMochaPrefsEnabled(); + if (pJVMPI != NULL) { + jobject javaObject = applet; + nsIPluginInstance* pPIT; + nsresult err = pJVMPI->GetPluginInstance(javaObject, &pPIT); + if ( (err == NS_OK) && (pPIT != NULL) ) { + nsIJVMPluginInstance* pJVMPIT; + if (pPIT->QueryInterface(kIJVMPluginInstanceIID, + (void**)&pJVMPIT) == NS_OK) { + nsPluginInstancePeer* pPITP; + err = pJVMPIT->GetPeer((nsIPluginInstancePeer**)&pPITP); + if ( (err == NS_OK) &&(pPITP != NULL) ) { + nsIJVMPluginTagInfo* pJVMTagInfo; + if (pPITP->QueryInterface(kIJVMPluginTagInfoIID, + (void**)&pJVMTagInfo) == NS_OK) { + err = pJVMTagInfo->GetMayScript(&mayscript); + PR_ASSERT(err != NS_OK ? mayscript == PR_FALSE : PR_TRUE); + pJVMTagInfo->Release(); + } + cx = pPITP->GetMWContext(); + pPITP->Release(); + } + pJVMPIT->Release(); + } + pPIT->Release(); + } + pJVMPI->Release(); + } + pJVMMgr->Release(); + } + + if ( (mayscript == PR_FALSE) + ||(jvmMochaPrefsEnabled == PR_FALSE) + ) + { + *errp = strdup("JSObject.getWindow() requires mayscript attribute on this Applet or java preference is disabled"); + goto except; + } + + + if (!cx || (cx->type != MWContextBrowser && cx->type != MWContextPane)) + { + *errp = strdup("JSObject.getWindow() can only be called in MWContextBrowser or MWContextPane"); + return 0; + } + + decoder = LM_GetMochaDecoder(cx); + + /* if there is a decoder now, reflect the window */ + if (decoder && (jvmMochaPrefsEnabled == PR_TRUE)) { + window = decoder->window_object; + } + + LM_PutMochaDecoder(decoder); + + return window; + except: return 0; -} - -void -JVMMgr::EnsurePrefCallbackRegistered(void) -{ - if (fRegisteredJavaPrefChanged != PR_TRUE) { - fRegisteredJavaPrefChanged = PR_TRUE; - PREF_RegisterCallback("security.enable_java", JavaPrefChanged, this); - JavaPrefChanged("security.enable_java", this); - } } +PR_IMPLEMENT(JavaVM *) +get_java_vm_impl(char **errp) +{ + *errp = NULL; + JavaVM *pJavaVM = NULL; + + nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); + if (pJVMMgr != NULL) { + nsIJVMPlugin* pJVMPI = pJVMMgr->GetJVMPlugin(); + if (pJVMPI != NULL) { + nsresult err = pJVMPI->GetJavaVM(&pJavaVM); + PR_ASSERT(err != NS_OK ? pJavaVM == NULL : PR_TRUE); + pJVMPI->Release(); + } + pJVMMgr->Release(); + } + if ( pJavaVM == NULL ) + { + *errp = strdup("Could not find a JavaVM to attach to."); + } + return pJavaVM; +} + +#endif /* MOCHA */ + +PR_END_EXTERN_C + + +/* + * Callbacks for client-specific jsjava glue + */ +static JSJCallbacks jsj_callbacks = { + map_jsj_thread_to_js_context_impl, + map_js_context_to_jsj_thread_impl, + map_java_object_to_js_object_impl, + NULL, +#ifdef OJI + LM_LockJS, LM_UnlockJS, +#else + NULL, NULL, +#endif + NULL, + get_java_vm_impl +}; + PRBool -JVMMgr::GetJVMEnabled(void) +nsJVMMgr::JSJInit() { - EnsurePrefCallbackRegistered(); - return fJVM->GetJVMEnabled(); + nsIJVMPlugin* pJVMPI = NULL; + PRBool bJSJInited = PR_FALSE; + + if(fJSJavaVM == NULL) + { + if( (pJVMPI = GetJVMPlugin()) != NULL) + { + JSJ_Init(&jsj_callbacks); + if (StartupJVM() == nsJVMStatus_Running) { + const char* classpath = NULL; + nsresult err = pJVMPI->GetClassPath(&classpath); + PR_ASSERT(err == NS_OK); + fJSJavaVM = JSJ_ConnectToJavaVM(JVM_GetJavaVM(), classpath); + } + pJVMPI->Release(); + bJSJInited = PR_TRUE; + } + } + else + { + bJSJInited = PR_TRUE; + } + + return bJSJInited; } -void -JVMMgr::SetJVMEnabled(PRBool enable) -{ - fJVM->SetJVMEnabled(enable); -} +//////////////////////////////////////////////////////////////////////////////// -JVMStatus -JVMMgr::GetJVMStatus(void) +#if 0 +NS_METHOD_(PRBool) +nsJVMMgr::HandOffJSLock(PRThread* oldOwner, PRThread* newOwner) { - EnsurePrefCallbackRegistered(); - return fJVM->GetJVMStatus(); + return LM_HandOffJSLock(oldOwner, newOwner); } //////////////////////////////////////////////////////////////////////////////// @@ -349,15 +499,15 @@ ConvertToPlatformPathList(const char* cp) #endif } -NS_METHOD_(void) -JVMMgr::ReportJVMError(JVMEnv* env, JVMError err) +NS_METHOD +nsJVMMgr::ReportJVMError(void* env, nsresult err) { MWContext* cx = XP_FindSomeContext(); char *s; switch (err) { - case JVMError_NoClasses: { + case NS_JVM_ERROR_NO_CLASSES: { const char* cp = fJVM->GetClassPath(); - const char* jarName = fJVM->GetSystemJARPath(); + const char* jarName = ""; // XXX fJVM->GetSystemJARPath(); cp = ConvertToPlatformPathList(cp); s = PR_smprintf(XP_GetString(XP_JAVA_NO_CLASSES), jarName, jarName, @@ -366,13 +516,13 @@ JVMMgr::ReportJVMError(JVMEnv* env, JVMError err) break; } - case JVMError_JavaError: { - const char* msg = GetJavaErrorString(env); + case NS_JVM_ERROR_JAVA_ERROR: { + const char* msg = GetJavaErrorString((JRIEnv*)env); #ifdef DEBUG # ifdef XP_MAC - env->ExceptionDescribe(); + ((JRIEnv*)env)->ExceptionDescribe(); # else - JRI_ExceptionDescribe(env); + JRI_ExceptionDescribe((JRIEnv*)env); # endif #endif s = PR_smprintf(XP_GetString(XP_JAVA_STARTUP_FAILED), @@ -380,7 +530,7 @@ JVMMgr::ReportJVMError(JVMEnv* env, JVMError err) if (msg) free((void*)msg); break; } - case JVMError_NoDebugger: { + case NS_JVM_ERROR_NO_DEBUGGER: { s = PR_smprintf(XP_GetString(XP_JAVA_DEBUGGER_FAILED)); break; } @@ -399,7 +549,7 @@ JVMMgr::ReportJVMError(JVMEnv* env, JVMError err) #define sig_java_lang_Object_toString "()Ljava/lang/String;" const char* -JVMMgr::GetJavaErrorString(JVMEnv* env) +nsJVMMgr::GetJavaErrorString(JRIEnv* env) { /* XXX javah is a pain wrt mixing JRI and JDK native methods. Since we need to call a method on Object, we'll do it the hard way @@ -462,29 +612,593 @@ JVMMgr::GetJavaErrorString(JVMEnv* env) return strdup(msg); #endif } +#endif // 0 -NS_METHOD_(PRBool) -JVMMgr::SupportsURLProtocol(const char* protocol) +//////////////////////////////////////////////////////////////////////////////// + +#ifdef MOZ_SMARTUPDATE + +static NS_DEFINE_IID(kIJRIPluginIID, NS_IJRIPLUGIN_IID); + +// Should be in a header; must solve build-order problem first +extern "C" void SU_Initialize(JRIEnv * env); + +#endif + +nsJVMStatus +nsJVMMgr::StartupJVM(void) { - int type = NET_URL_Type(protocol); - return (PRBool)(type != 0); + // Be sure to check the prefs first before asking java to startup. + switch (GetJVMStatus()) { + case nsJVMStatus_Disabled: + return nsJVMStatus_Disabled; + case nsJVMStatus_Running: + return nsJVMStatus_Running; + default: + break; + } + + nsIJVMPlugin* jvm = GetJVMPlugin(); + if (jvm == NULL) { + fStatus = nsJVMStatus_Failed; + return fStatus; + } + + nsJVMInitArgs initargs; + int count = fClassPathAdditions->GetSize(); + char* classpathAdditions = NULL; + for (int i = 0; i < count; i++) { + const char* path = (const char*)(*fClassPathAdditions)[i]; + char* oldPath = classpathAdditions; + if (oldPath) { + classpathAdditions = PR_smprintf("%s%c%s", oldPath, PR_PATH_SEPARATOR, path); + PR_Free(oldPath); + } + else + classpathAdditions = PL_strdup(path); + } + initargs.version = nsJVMInitArgs_Version; + initargs.classpathAdditions = classpathAdditions; + + nsresult err = fJVM->StartupJVM(&initargs); + if (err == NS_OK) { + /* assume the JVM is running. */ + fStatus = nsJVMStatus_Running; +#ifdef MOZ_SMARTUPDATE + nsIJRIPlugin* jriJVM; + if (fJVM->QueryInterface(kIJRIPluginIID, (void**)&jriJVM) == NS_OK) { + JRIEnv* env; + nsresult err = jriJVM->GetJRIEnv(&env); + if (err == NS_OK) { + SU_Initialize(env); + if (JRI_ExceptionOccurred(env)) { +#ifdef DEBUG + JVM_PrintToConsole("LJ: SU_Initialize failed. Bugs to atotic.\n"); +#endif + JRI_ExceptionDescribe(env); + JRI_ExceptionClear(env); + } + jriJVM->ReleaseJRIEnv(env); + } + jriJVM->Release(); + } +#endif + } + jvm->Release(); + return fStatus; +} + +nsJVMStatus +nsJVMMgr::ShutdownJVM(PRBool fullShutdown) +{ + if (fJVM) { + // XXX we should just make nsPluginError and nsJVMStatus be nsresult + nsresult err = fJVM->ShutdownJVM(fullShutdown); + if (err == NS_OK) + return nsJVMStatus_Enabled; + else { + // XXX report error? + return nsJVMStatus_Disabled; + } + } + return nsJVMStatus_Enabled; // XXX what if there's no plugin available? } //////////////////////////////////////////////////////////////////////////////// -extern "C" PR_IMPLEMENT(JVMMgr*) +static int PR_CALLBACK +JavaPrefChanged(const char *prefStr, void* data) +{ + nsJVMMgr* mgr = (nsJVMMgr*)data; + XP_Bool prefBool; +#if defined(XP_MAC) + // beard: under Mozilla, no way to enable this right now. + prefBool = TRUE; +#else + PREF_GetBoolPref(prefStr, &prefBool); +#endif + mgr->SetJVMEnabled(prefBool); + return 0; +} + +void +nsJVMMgr::SetJVMEnabled(PRBool enabled) +{ + if (enabled) { + if (fStatus != nsJVMStatus_Running) + fStatus = nsJVMStatus_Enabled; + // don't start the JVM here, do it lazily + } + else { + if (fStatus == nsJVMStatus_Running) + (void)ShutdownJVM(); + else + fStatus = nsJVMStatus_Disabled; + } +} + +void +nsJVMMgr::EnsurePrefCallbackRegistered(void) +{ + if (fRegisteredJavaPrefChanged != PR_TRUE) { + fRegisteredJavaPrefChanged = PR_TRUE; + PREF_RegisterCallback("security.enable_java", JavaPrefChanged, this); + JavaPrefChanged("security.enable_java", this); + } +} + +nsJVMStatus +nsJVMMgr::GetJVMStatus(void) +{ + EnsurePrefCallbackRegistered(); + return fStatus; +} + +PRBool +nsJVMMgr::IsJVMAndMochaPrefsEnabled(void) +{ + if (GetJVMStatus() == nsJVMStatus_Disabled) { + return PR_FALSE; + } + if (!LM_GetMochaEnabled()) { + return PR_FALSE; + } + return PR_TRUE; +} + + +//////////////////////////////////////////////////////////////////////////////// + +nsresult +nsJVMMgr::AddToClassPath(const char* dirPath) +{ + nsIJVMPlugin* jvm = GetJVMPlugin(); + + /* Add any zip or jar files in this directory to the classpath: */ + PRDir* dir = PR_OpenDir(dirPath); + if (dir != NULL) { + PRDirEntry* dirent; + while ((dirent = PR_ReadDir(dir, PR_SKIP_BOTH)) != NULL) { + PRFileInfo info; + char* path = PR_smprintf("%s%c%s", dirPath, PR_DIRECTORY_SEPARATOR, PR_DirName(dirent)); + if (path != NULL) { + PRBool freePath = PR_TRUE; + if ((PR_GetFileInfo(path, &info) == PR_SUCCESS) + && (info.type == PR_FILE_FILE)) { + int len = PL_strlen(path); + + /* Is it a zip or jar file? */ + if ((len > 4) && + ((PL_strcasecmp(path+len-4, ".zip") == 0) || + (PL_strcasecmp(path+len-4, ".jar") == 0))) { + fClassPathAdditions->Add((void*)path); + if (jvm) { + /* Add this path to the classpath: */ + jvm->AddToClassPath(path); + } + freePath = PR_FALSE; + } + } + + // Don't leak the path! + if (freePath) + PR_smprintf_free(path); + } + } + PR_CloseDir(dir); + } + + /* Also add the directory to the classpath: */ + fClassPathAdditions->Add((void*)dirPath); + if (jvm) { + jvm->AddToClassPath(dirPath); + jvm->Release(); + } + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsJVMPluginTagInfo +//////////////////////////////////////////////////////////////////////////////// + +nsJVMPluginTagInfo::nsJVMPluginTagInfo(nsISupports* outer, nsIPluginTagInfo2* info) + : fPluginTagInfo(info), fSimulatedCodebase(NULL), fSimulatedCode(NULL) +{ + NS_INIT_AGGREGATED(outer); +} + +nsJVMPluginTagInfo::~nsJVMPluginTagInfo(void) +{ + if (fSimulatedCodebase) + PL_strfree(fSimulatedCodebase); + + if (fSimulatedCode) + PL_strfree(fSimulatedCode); +} + +NS_IMPL_AGGREGATED(nsJVMPluginTagInfo); + +NS_METHOD +nsJVMPluginTagInfo::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + if (aIID.Equals(kIJVMPluginTagInfoIID) || + aIID.Equals(kISupportsIID)) { + *aInstancePtr = this; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + + +static void +oji_StandardizeCodeAttribute(char* buf) +{ + // strip off the ".class" suffix + char* cp; + + if ((cp = PL_strrstr(buf, ".class")) != NULL) + *cp = '\0'; + + // Convert '/' to '.' + cp = buf; + while ((*cp) != '\0') { + if ((*cp) == '/') + (*cp) = '.'; + + ++cp; + } +} + +NS_METHOD +nsJVMPluginTagInfo::GetCode(const char* *result) +{ + if (fSimulatedCode) { + *result = fSimulatedCode; + return NS_OK; + } + + const char* code; + nsresult err = fPluginTagInfo->GetAttribute("code", &code); + if (err == NS_OK && code) { + fSimulatedCode = PL_strdup(code); + oji_StandardizeCodeAttribute(fSimulatedCode); + *result = fSimulatedCode; + return NS_OK; + } + + const char* classid; + err = fPluginTagInfo->GetAttribute("classid", &classid); + if (err == NS_OK && classid && PL_strncasecmp(classid, "java:", 5) == 0) { + fSimulatedCode = PL_strdup(classid + 5); // skip "java:" + oji_StandardizeCodeAttribute(fSimulatedCode); + *result = fSimulatedCode; + return NS_OK; + } + + // XXX what about "javaprogram:" and "javabean:"? + return NS_ERROR_FAILURE; +} + +NS_METHOD +nsJVMPluginTagInfo::GetCodeBase(const char* *result) +{ + // If we've already cached and computed the value, use it... + if (fSimulatedCodebase) { + *result = fSimulatedCodebase; + return NS_OK; + } + + // See if it's supplied as an attribute... + const char* codebase; + nsresult err = fPluginTagInfo->GetAttribute("codebase", &codebase); + if (err == NS_OK && codebase != NULL) { + *result = fSimulatedCodebase; + return NS_OK; + } + + // Okay, we'll need to simulate it from the layout tag's base URL. + const char* docBase; + err = fPluginTagInfo->GetDocumentBase(&docBase); + if (err != NS_OK) return err; + PA_LOCK(codebase, const char*, docBase); + + if ((fSimulatedCodebase = PL_strdup(codebase)) != NULL) { + char* lastSlash = PL_strrchr(fSimulatedCodebase, '/'); + + // chop of the filename from the original document base URL to + // generate the codebase. + if (lastSlash != NULL) + *(lastSlash + 1) = '\0'; + } + + PA_UNLOCK(docBase); + *result = fSimulatedCodebase; + return NS_OK; +} + +NS_METHOD +nsJVMPluginTagInfo::GetArchive(const char* *result) +{ + return fPluginTagInfo->GetAttribute("archive", result); +} + +NS_METHOD +nsJVMPluginTagInfo::GetName(const char* *result) +{ + const char* attrName; + nsPluginTagType type; + nsresult err = fPluginTagInfo->GetTagType(&type); + if (err != NS_OK) return err; + switch (type) { + case nsPluginTagType_Applet: + attrName = "name"; + break; + default: + attrName = "id"; + break; + } + return fPluginTagInfo->GetAttribute(attrName, result); +} + +NS_METHOD +nsJVMPluginTagInfo::GetMayScript(PRBool *result) +{ + const char* attr; + *result = PR_FALSE; + + nsresult err = fPluginTagInfo->GetAttribute("mayscript", &attr); + if (err) return err; + + if (PL_strcasecmp(attr, "true") == 0) + { + *result = PR_TRUE; + } + return NS_OK; +} + +NS_METHOD +nsJVMPluginTagInfo::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr, + nsIPluginTagInfo2* info) +{ + if (outer && !aIID.Equals(kISupportsIID)) + return NS_NOINTERFACE; // XXX right error? + + nsJVMPluginTagInfo* jvmInstPeer = new nsJVMPluginTagInfo(outer, info); + if (jvmInstPeer == NULL) + return NS_ERROR_OUT_OF_MEMORY; + nsresult result = jvmInstPeer->QueryInterface(aIID, aInstancePtr); + if (result != NS_OK) goto error; + + result = outer->QueryInterface(kIPluginTagInfo2IID, + (void**)&jvmInstPeer->fPluginTagInfo); + if (result != NS_OK) goto error; + outer->Release(); // no need to AddRef outer + return result; + + error: + delete jvmInstPeer; + return result; +} + +//////////////////////////////////////////////////////////////////////////////// +// Convenience Routines + +PR_BEGIN_EXTERN_C + +extern nsPluginManager* thePluginManager; + +PR_IMPLEMENT(nsJVMMgr*) JVM_GetJVMMgr(void) { - extern nsISupports* thePluginManager; - if (thePluginManager == NULL) - return NULL; - JVMMgr* mgr; - nsresult res = - thePluginManager->QueryInterface(kIJVMPluginManagerIID, (void**)&mgr); - if (res != NS_OK) + nsresult result = NS_OK; + if (thePluginManager == NULL) { + result = nsPluginManager::Create(NULL, kIPluginManagerIID, (void**)&thePluginManager); + if (result != NS_OK) + return NULL; + } + nsJVMMgr* mgr = NULL; + result = thePluginManager->QueryInterface(kIJVMManagerIID, (void**)&mgr); + if (result != NS_OK) return NULL; return mgr; } +static nsIJVMPlugin* +GetRunningJVM(void) +{ + nsIJVMPlugin* jvm = NULL; + nsJVMMgr* jvmMgr = JVM_GetJVMMgr(); + if (jvmMgr) { + nsJVMStatus status = jvmMgr->GetJVMStatus(); + if (status == nsJVMStatus_Enabled) + status = jvmMgr->StartupJVM(); + if (status == nsJVMStatus_Running) { + jvm = jvmMgr->GetJVMPlugin(); + } + jvmMgr->Release(); + } + return jvm; +} + +PR_IMPLEMENT(PRBool) +JVM_IsJVMAvailable(void) +{ + PRBool result = PR_FALSE; + nsJVMMgr* mgr = JVM_GetJVMMgr(); + if (mgr) { + nsJVMStatus status = mgr->GetJVMStatus(); + result = status != nsJVMStatus_Failed + && status != nsJVMStatus_Disabled; + mgr->Release(); + } + return result; +} + +PR_IMPLEMENT(nsresult) +JVM_AddToClassPath(const char* dirPath) +{ + nsresult err = NS_ERROR_FAILURE; + nsJVMMgr* mgr = JVM_GetJVMMgr(); + if (mgr) { + err = mgr->AddToClassPath(dirPath); + mgr->Release(); + } + return err; +} + +// This will get the JVMConsole if one is available. You have to Release it +// when you're done with it. +static nsIJVMConsole* +GetConsole(void) +{ + nsIJVMConsole* console = NULL; + nsIJVMPlugin* jvm = GetRunningJVM(); + if (jvm) { + jvm->QueryInterface(kIJVMConsoleIID, (void**)&console); + jvm->Release(); + } + return console; +} + +PR_IMPLEMENT(void) +JVM_ShowConsole(void) +{ + nsIJVMConsole* console = GetConsole(); + if (console) { + console->ShowConsole(); + console->Release(); + } +} + +PR_IMPLEMENT(void) +JVM_HideConsole(void) +{ + nsIJVMConsole* console = GetConsole(); + if (console) { + console->HideConsole(); + console->Release(); + } +} + +PR_IMPLEMENT(PRBool) +JVM_IsConsoleVisible(void) +{ + PRBool result = PR_FALSE; + nsIJVMConsole* console = GetConsole(); + if (console) { + nsresult err = console->IsConsoleVisible(&result); + PR_ASSERT(err != NS_OK ? result == PR_FALSE : PR_TRUE); + console->Release(); + } + return result; +} + +PR_IMPLEMENT(void) +JVM_ToggleConsole(void) +{ + nsIJVMConsole* console = GetConsole(); + if (console) { + PRBool visible = PR_FALSE; + nsresult err = console->IsConsoleVisible(&visible); + PR_ASSERT(err != NS_OK ? visible == PR_FALSE : PR_TRUE); + if (visible) + console->HideConsole(); + else + console->ShowConsole(); + console->Release(); + } +} + +PR_IMPLEMENT(void) +JVM_PrintToConsole(const char* msg) +{ + nsIJVMConsole* console = GetConsole(); + if (console) { + console->Print(msg); + console->Release(); + } +} + +PR_IMPLEMENT(void) +JVM_StartDebugger(void) +{ + nsIJVMPlugin* jvm = GetRunningJVM(); + if (jvm) { + nsISymantecDebugger* debugger; + if (jvm->QueryInterface(kISymantecDebuggerIID, (void**)&debugger) == NS_OK) { + // XXX should we make sure the vm is started first? + debugger->StartDebugger(nsSymantecDebugPort_SharedMemory); + debugger->Release(); + } + jvm->Release(); + } +} + +PR_IMPLEMENT(JavaVM*) +JVM_GetJavaVM(void) +{ + JavaVM* javaVM = NULL; + nsIJVMPlugin* jvm = GetRunningJVM(); + if (jvm) { + nsresult err = jvm->GetJavaVM(&javaVM); + PR_ASSERT(err == NS_OK); + jvm->Release(); + } + return javaVM; +} + +static void PR_CALLBACK detach_JNIEnv(void* env) +{ + JNIEnv* jenv = (JNIEnv*)env; + JavaVM* vm = NULL; + jenv->GetJavaVM(&vm); + vm->DetachCurrentThread(); +} + +PR_IMPLEMENT(JNIEnv*) +JVM_GetJNIEnv(void) +{ + /* Use NSPR thread private data to manage the per-thread JNIEnv* association. */ + static ThreadLocalStorage localEnv(&detach_JNIEnv); + + JNIEnv* env = localEnv.get(); + if (env != NULL) + return env; + + nsIJVMPlugin* jvm = GetRunningJVM(); + if (jvm) { + (void)jvm->GetJNIEnv(&env); + jvm->Release(); + } + + /* Associate the JNIEnv with the current thread. */ + localEnv.set(env); + + return env; +} + +PR_END_EXTERN_C + //////////////////////////////////////////////////////////////////////////////// diff --git a/modules/oji/src/jvmmgr.h b/modules/oji/src/jvmmgr.h index af1d02f0f2df..a2db4e6931a5 100644 --- a/modules/oji/src/jvmmgr.h +++ b/modules/oji/src/jvmmgr.h @@ -19,54 +19,34 @@ #ifndef jvmmgr_h___ #define jvmmgr_h___ +#include "xp_core.h" // include first because of Bool problem #include "nsjvm.h" -#include "nsscd.h" #include "nsAgg.h" +#include "jsjava.h" +#include "nsVector.h" +class nsIPluginTagInfo2; class nsSymantecDebugManager; +enum nsJVMStatus { + nsJVMStatus_Enabled, // but not Running + nsJVMStatus_Disabled, // explicitly disabled + nsJVMStatus_Running, // enabled and started + nsJVMStatus_Failed // enabled but failed to start +}; + //////////////////////////////////////////////////////////////////////////////// // JVMMgr is the interface to the JVM manager that the browser sees. All // files that want to include java services should include this header file. -// NPIJVMPluginManager is the more limited interface what the JVM plugin sees. +// nsIJVMManager is the more limited interface what the JVM plugin sees. -class JVMMgr : public NPIJVMPluginManager { +class nsJVMMgr : public nsIJVMManager { public: NS_DECL_AGGREGATED //////////////////////////////////////////////////////////////////////////// - // from NPIJVMPluginManager: - - // ====> These are usually only called by the plugin, not the browser... - - NS_IMETHOD_(void) - BeginWaitCursor(void); - - NS_IMETHOD_(void) - EndWaitCursor(void); - - NS_IMETHOD_(const char*) - GetProgramPath(void); - - NS_IMETHOD_(const char*) - GetTempDirPath(void); - - NS_IMETHOD_(nsresult) - GetFileName(const char* fn, FileNameType type, - char* resultBuf, PRUint32 bufLen); - - NS_IMETHOD_(nsresult) - NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen); - - NS_IMETHOD_(PRBool) - HandOffJSLock(PRThread* oldOwner, PRThread* newOwner); - - NS_IMETHOD_(void) - ReportJVMError(JVMEnv* env, JVMError err); - - NS_IMETHOD_(PRBool) - SupportsURLProtocol(const char* protocol); + // from nsIJVMManager: //////////////////////////////////////////////////////////////////////////// // JVMMgr specific methods: @@ -76,277 +56,150 @@ public: static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); - NPIJVMPlugin* GetJVM(void); + nsIJVMPlugin* GetJVMPlugin(void); - // Unlike the NPIJVMPlugin::StartupJVM, this version handles putting + // Unlike the nsIJVMPlugin::StartupJVM, this version handles putting // up any error dialog: - JVMStatus StartupJVM(void); - JVMStatus ShutdownJVM(PRBool fullShutdown = PR_TRUE); + nsJVMStatus StartupJVM(void); + nsJVMStatus ShutdownJVM(PRBool fullShutdown = PR_FALSE); + nsJVMStatus GetJVMStatus(void); + void SetJVMEnabled(PRBool enabled); - PRBool GetJVMEnabled(void); - void SetJVMEnabled(PRBool enable); - JVMStatus GetJVMStatus(void); + nsresult AddToClassPath(const char* dirPath); + PRBool JSJInit(); + PRBool IsJVMAndMochaPrefsEnabled(void); + JSJavaVM* GetJSJavaVM() { return fJSJavaVM; } - void SetProgramPath(const char* path) { fProgramPath = path; } protected: - JVMMgr(nsISupports* outer); - virtual ~JVMMgr(void); + nsJVMMgr(nsISupports* outer); + virtual ~nsJVMMgr(void); void EnsurePrefCallbackRegistered(void); - const char* GetJavaErrorString(JVMEnv* env); + const char* GetJavaErrorString(JRIEnv* env); - NPIJVMPlugin* fJVM; - PRUint16 fWaiting; - void* fOldCursor; - const char* fProgramPath; + nsIJVMPlugin* fJVM; + nsJVMStatus fStatus; PRBool fRegisteredJavaPrefChanged; nsISupports* fDebugManager; - + JSJavaVM * fJSJavaVM; + nsVector* fClassPathAdditions; }; //////////////////////////////////////////////////////////////////////////////// // Symantec Debugger Stuff -class nsSymantecDebugManager : public NPISymantecDebugManager { +class nsSymantecDebugManager : public nsISymantecDebugManager { public: NS_DECL_AGGREGATED - NS_IMETHOD_(PRBool) + NS_IMETHOD SetDebugAgentPassword(PRInt32 pwd); static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr, - JVMMgr* jvmMgr); + nsJVMMgr* jvmMgr); protected: - nsSymantecDebugManager(nsISupports* outer, JVMMgr* jvmMgr); + nsSymantecDebugManager(nsISupports* outer, nsJVMMgr* jvmMgr); virtual ~nsSymantecDebugManager(void); - JVMMgr* fJVMMgr; + nsJVMMgr* fJVMMgr; }; //////////////////////////////////////////////////////////////////////////////// -// JVMInstancePeer: The browser makes one of these when it sees an APPLET or +// nsJVMPluginTagInfo: The browser makes one of these when it sees an APPLET or // appropriate OBJECT tag. -class JVMInstancePeer : public NPIJVMPluginInstancePeer { +class nsJVMPluginTagInfo : public nsIJVMPluginTagInfo { public: NS_DECL_AGGREGATED //////////////////////////////////////////////////////////////////////////// - // Methods specific to NPIPluginInstancePeer: + // from nsIJVMPluginTagInfo: // ====> These are usually only called by the plugin, not the browser... - NS_IMETHOD_(NPIPlugin*) - GetClass(void); + NS_IMETHOD + GetCode(const char* *result); - // (Corresponds to NPP_New's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetCodeBase(const char* *result); - // (Corresponds to NPP_New's mode argument.) - NS_IMETHOD_(NPPluginType) - GetMode(void); + NS_IMETHOD + GetArchive(const char* *result); - // Get a ptr to the paired list of attribute names and values, - // returns the length of the array. - // - // Each name or value is a null-terminated string. - NS_IMETHOD_(NPPluginError) - GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values); + NS_IMETHOD + GetName(const char* *result); - // Get the value for the named attribute. Returns null - // if the attribute was not set. - NS_IMETHOD_(const char*) - GetAttribute(const char* name); - - // Get a ptr to the paired list of parameter names and values, - // returns the length of the array. - // - // Each name or value is a null-terminated string. - NS_IMETHOD_(NPPluginError) - GetParameters(PRUint16& n, const char*const*& names, const char*const*& values); - - // Get the value for the named parameter. Returns null - // if the parameter was not set. - NS_IMETHOD_(const char*) - GetParameter(const char* name); - - // Get the complete text of the HTML tag that was - // used to instantiate this plugin - NS_IMETHOD_(const char*) - GetTagText(void); - - // Get the type of the HTML tag that was used ot instantiate this - // plugin. Currently supported tags are EMBED, OBJECT and APPLET. - // - NS_IMETHOD_(NPTagType) - GetTagType(void); - - NS_IMETHOD_(NPIPluginManager*) - GetPluginManager(void); - - // (Corresponds to NPN_GetURL and NPN_GetURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - NS_IMETHOD_(NPPluginError) - GetURL(const char* url, const char* target, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE); - - // (Corresponds to NPN_PostURL and NPN_PostURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - // postHeaders: A string containing post headers. - // postHeadersLength: The length of the post headers string. - NS_IMETHOD_(NPPluginError) - PostURL(const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE, - PRUint32 postHeadersLength = 0, const char* postHeaders = NULL); - - // (Corresponds to NPN_NewStream.) - NS_IMETHOD_(NPPluginError) - NewStream(nsMIMEType type, const char* target, - NPIPluginManagerStream* *result); - - // (Corresponds to NPN_Status.) - NS_IMETHOD_(void) - ShowStatus(const char* message); - - // (Corresponds to NPN_UserAgent.) - NS_IMETHOD_(const char*) - UserAgent(void); - - // (Corresponds to NPN_GetValue.) - NS_IMETHOD_(NPPluginError) - GetValue(NPPluginManagerVariable variable, void *value); - - // (Corresponds to NPN_SetValue.) - NS_IMETHOD_(NPPluginError) - SetValue(NPPluginVariable variable, void *value); - - // (Corresponds to NPN_InvalidateRect.) - NS_IMETHOD_(void) - InvalidateRect(nsRect *invalidRect); - - // (Corresponds to NPN_InvalidateRegion.) - NS_IMETHOD_(void) - InvalidateRegion(nsRegion invalidRegion); - - // (Corresponds to NPN_ForceRedraw.) - NS_IMETHOD_(void) - ForceRedraw(void); - - // New top-level window handling calls for Mac: - - NS_IMETHOD_(void) - RegisterWindow(void* window); - - NS_IMETHOD_(void) - UnregisterWindow(void* window); - - // Menu ID allocation calls for Mac: - NS_IMETHOD_(PRInt16) - AllocateMenuID(PRBool isSubmenu); + NS_IMETHOD + GetMayScript(PRBool *result); //////////////////////////////////////////////////////////////////////////// - // Methods specific to NPIJVMPluginInstancePeer: - - NS_IMETHOD_(const char *) - GetCode(void); - - NS_IMETHOD_(const char *) - GetCodeBase(void); - - NS_IMETHOD_(const char *) - GetArchive(void); - - NS_IMETHOD_(PRBool) - GetMayScript(void); - - NS_IMETHOD_(const char *) - GetID(void); - - // XXX reload method? - - // Returns a unique id for the current document on which the - // plugin is displayed. - NS_IMETHOD_(PRUint32) - GetDocumentID(void); - - NS_IMETHOD_(const char*) - GetDocumentBase(void); - - NS_IMETHOD_(INTL_CharSetInfo) - GetDocumentCharSetInfo(void); - - NS_IMETHOD_(const char*) - GetAlignment(void); - - NS_IMETHOD_(PRUint32) - GetWidth(void); - - NS_IMETHOD_(PRUint32) - GetHeight(void); - - NS_IMETHOD_(PRUint32) - GetBorderVertSpace(void); - - NS_IMETHOD_(PRUint32) - GetBorderHorizSpace(void); - - NS_IMETHOD_(PRBool) - Tickle(void); - - //////////////////////////////////////////////////////////////////////////// - // Methods specific to JVMPluginInstancePeer: + // Methods specific to nsJVMPluginInstancePeer: // ====> From here on are things only called by the browser, not the plugin... static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr, - MWContext* cx, LO_CommonPluginStruct* lo); + nsIPluginTagInfo2* info); protected: - JVMInstancePeer(nsISupports* outer, MWContext* cx, LO_CommonPluginStruct* lo); - virtual ~JVMInstancePeer(void); + nsJVMPluginTagInfo(nsISupports* outer, nsIPluginTagInfo2* info); + virtual ~nsJVMPluginTagInfo(void); // Instance Variables: - NPIPluginInstancePeer* fPluginInstancePeer; - MWContext* fContext; - LO_CommonPluginStruct* fLayoutElement; - PRUint32 fUniqueID; - char* fSimulatedCodebase; + nsIPluginTagInfo2* fPluginTagInfo; + char* fSimulatedCodebase; + char* fSimulatedCode; }; //////////////////////////////////////////////////////////////////////////////// +// Convenience Routines + +PR_BEGIN_EXTERN_C // Returns the JVM manager. You must do a Release on the // pointer returned when you're done with it. -extern "C" PR_EXTERN(JVMMgr*) +PR_EXTERN(nsJVMMgr*) JVM_GetJVMMgr(void); +// Returns true if java is enabled, and has not failed to load. +PR_EXTERN(PRBool) +JVM_IsJVMAvailable(void); + +PR_EXTERN(nsresult) +JVM_AddToClassPath(const char* dirPath); + +PR_EXTERN(void) +JVM_ShowConsole(void); + +PR_EXTERN(void) +JVM_HideConsole(void); + +PR_EXTERN(PRBool) +JVM_IsConsoleVisible(void); + +PR_EXTERN(void) +JVM_ToggleConsole(void); + +PR_EXTERN(void) +JVM_PrintToConsole(const char* msg); + +PR_EXTERN(void) +JVM_StartDebugger(void); + +PR_EXTERN(JavaVM*) +JVM_GetJavaVM(void); + +PR_EXTERN(JNIEnv*) +JVM_GetJNIEnv(void); + +PR_END_EXTERN_C + //////////////////////////////////////////////////////////////////////////////// #endif /* jvmmgr_h___ */ diff --git a/modules/oji/src/makefile.win b/modules/oji/src/makefile.win index 5e444750112d..57f688f3acfc 100644 --- a/modules/oji/src/makefile.win +++ b/modules/oji/src/makefile.win @@ -35,7 +35,6 @@ PDBFILE=$(LIBNAME).pdb #//------------------------------------------------------------------------ OBJS = .\$(OBJDIR)\jvmmgr.obj \ - .\$(OBJDIR)\jvmpeer.obj \ .\$(OBJDIR)\scd.obj #//------------------------------------------------------------------------ @@ -54,7 +53,7 @@ LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib #// #//------------------------------------------------------------------------ -LINCS= $(LINCS) -I_jri -I$(DEPTH)/lib/plugin \ +LINCS= $(LINCS) -I_jri \ # # For Win16 the following include directories are copied into # ns/dist/public/win16 @@ -68,22 +67,24 @@ LINCS= $(LINCS) -I_jri -I$(DEPTH)/lib/plugin \ -I$(PUBLIC)/security \ -I$(PUBLIC)/pref \ -I$(PUBLIC)/xpcom \ + -I$(PUBLIC)/raptor \ + -I$(PUBLIC)/plugin \ + -I$(PUBLIC)/oji \ + -I$(PUBLIC)/plugimpl \ !endif -I$(DEPTH)/lib/layout \ -I$(DEPTH)/lib/libstyle \ -I$(DEPTH)/lib/libjar \ - -I$(DEPTH)/lib/plugin \ $(NULL) CSRCS = jvmmgr.cpp \ - jvmpeer.cpp \ scd.cpp !endif # MOZ_OJI -MODULE = oji +MODULE = ojiimpl -EXPORTS = nsjvm.h jvmmgr.h nsscd.h +EXPORTS = jvmmgr.h #//------------------------------------------------------------------------ #// @@ -96,14 +97,12 @@ LCFLAGS=$(LCFLAGS) ^ $(JAVA_DEFINES) !if "$(MOZ_BITS)" == "32" -PUBLIC_HEADER_DIR=$(PUBLIC)\oji +PUBLIC_HEADER_DIR=$(PUBLIC)\ojiimpl !else PUBLIC_HEADER_DIR=$(PUBLIC)\win16 !endif export:: - $(MAKE_INSTALL) nsjvm.h $(PUBLIC_HEADER_DIR) - $(MAKE_INSTALL) nsscd.h $(PUBLIC_HEADER_DIR) $(MAKE_INSTALL) jvmmgr.h $(PUBLIC_HEADER_DIR) !ifdef MOZ_OJI diff --git a/modules/oji/src/nsjvm.h b/modules/oji/src/nsjvm.h deleted file mode 100644 index e7841f6c67d8..000000000000 --- a/modules/oji/src/nsjvm.h +++ /dev/null @@ -1,274 +0,0 @@ -/* -*- 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.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. 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 this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -//////////////////////////////////////////////////////////////////////////////// -// NETSCAPE JAVA VM PLUGIN EXTENSIONS -// -// This interface allows a Java virtual machine to be plugged into -// Communicator to implement the APPLET tag and host applets. -// -// Note that this is the C++ interface that the plugin sees. The browser -// uses a specific implementation of this, nsJVMPlugin, found in navjvm.h. -//////////////////////////////////////////////////////////////////////////////// - -#ifndef nsjvm_h___ -#define nsjvm_h___ - -#include "nsIPlug.h" -#include "jri.h" // XXX for now -#include "jni.h" -#include "prthread.h" - -#include "libi18n.h" // XXX way too much browser dependence -#include "intl_csi.h" - -//////////////////////////////////////////////////////////////////////////////// - -#define NPJVM_MIME_TYPE "application/x-java-vm" - -enum JVMError { - JVMError_Ok = NPPluginError_NoError, - JVMError_Base = 0x1000, - JVMError_InternalError = JVMError_Base, - JVMError_NoClasses, - JVMError_WrongClasses, - JVMError_JavaError, - JVMError_NoDebugger -}; - -#ifdef XP_MAC -typedef JNIEnv JVMEnv; -#else -typedef JRIEnv JVMEnv; -#endif - - -//////////////////////////////////////////////////////////////////////////////// -// Java VM Plugin Manager -// This interface defines additional entry points that are available -// to JVM plugins for browsers that support JVM plugins. - -class NPIJVMPlugin; - -class NPIJVMPluginManager : public nsISupports { -public: - - NS_IMETHOD_(void) - BeginWaitCursor(void) = 0; - - NS_IMETHOD_(void) - EndWaitCursor(void) = 0; - - NS_IMETHOD_(const char*) - GetProgramPath(void) = 0; - - NS_IMETHOD_(const char*) - GetTempDirPath(void) = 0; - - enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME }; - - NS_IMETHOD_(nsresult) - GetFileName(const char* fn, FileNameType type, - char* resultBuf, PRUint32 bufLen) = 0; - - NS_IMETHOD_(nsresult) - NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0; - - NS_IMETHOD_(PRBool) - HandOffJSLock(PRThread* oldOwner, PRThread* newOwner) = 0; - - NS_IMETHOD_(void) - ReportJVMError(JVMEnv* env, JVMError err) = 0; // XXX JNIEnv* - - NS_IMETHOD_(PRBool) - SupportsURLProtocol(const char* protocol) = 0; - -}; - -#define NP_IJVMPLUGINMANAGER_IID \ -{ /* a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe */ \ - 0xa1e5ed50, \ - 0xaa4a, \ - 0x11d1, \ - {0x85, 0xb2, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \ -} - -//////////////////////////////////////////////////////////////////////////////// - -enum JVMStatus { - JVMStatus_Enabled, // but not Running - JVMStatus_Disabled, // explicitly disabled - JVMStatus_Running, // enabled and started - JVMStatus_Failed // enabled but failed to start -}; - -//////////////////////////////////////////////////////////////////////////////// -// Java VM Plugin Interface -// This interface defines additional entry points that a plugin developer needs -// to implement in order to implement a Java virtual machine plugin. - -class NPIJVMPlugin : public NPIPlugin { -public: - - // QueryInterface may be used to obtain a JRIEnv or JNIEnv - // from an NPIPluginManager. - // (Corresponds to NPN_GetJavaEnv.) - - NS_IMETHOD_(JVMStatus) - StartupJVM(void) = 0; - - NS_IMETHOD_(JVMStatus) - ShutdownJVM(PRBool fullShutdown = PR_TRUE) = 0; - - NS_IMETHOD_(PRBool) - GetJVMEnabled(void) = 0; - - NS_IMETHOD_(void) - SetJVMEnabled(PRBool enable) = 0; - - NS_IMETHOD_(JVMStatus) - GetJVMStatus(void) = 0; - - // Find or create a JNIEnv for the specified thread. The thread - // parameter may be NULL indicating the current thread. - // XXX JNIEnv* - NS_IMETHOD_(JVMEnv*) - EnsureExecEnv(PRThread* thread = NULL) = 0; - - NS_IMETHOD_(void) - AddToClassPath(const char* dirPath) = 0; - - NS_IMETHOD_(void) - ShowConsole(void) = 0; - - NS_IMETHOD_(void) - HideConsole(void) = 0; - - NS_IMETHOD_(PRBool) - IsConsoleVisible(void) = 0; - - NS_IMETHOD_(void) - PrintToConsole(const char* msg) = 0; - - NS_IMETHOD_(const char*) - GetClassPath(void) = 0; - - NS_IMETHOD_(const char*) - GetSystemJARPath(void) = 0; - -}; - -#define NP_IJVMPLUGIN_IID \ -{ /* da6f3bc0-a1bc-11d1-85b1-00805f0e4dfe */ \ - 0xda6f3bc0, \ - 0xa1bc, \ - 0x11d1, \ - {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \ -} - -//////////////////////////////////////////////////////////////////////////////// -// Java VM Plugin Instance Interface - -class NPIJVMPluginInstance : public NPIPluginInstance { -public: - - // This method is called when LiveConnect wants to find the Java object - // associated with this plugin instance, e.g. the Applet or JavaBean object. - NS_IMETHOD_(jobject) - GetJavaObject(void) = 0; - -}; - -//////////////////////////////////////////////////////////////////////////////// -// Java VM Plugin Instance Peer Interface -// This interface provides additional hooks into the plugin manager that allow -// a plugin to implement the plugin manager's Java virtual machine. - -enum NPTagAttributeName { - NPTagAttributeName_Width, - NPTagAttributeName_Height, - NPTagAttributeName_Classid, - NPTagAttributeName_Code, - NPTagAttributeName_Codebase, - NPTagAttributeName_Docbase, - NPTagAttributeName_Archive, - NPTagAttributeName_Name, - NPTagAttributeName_MayScript -}; - -class NPIJVMPluginInstancePeer : public NPIPluginInstancePeer { -public: - - // XXX reload method? - - // Returns a unique id for the current document on which the - // plugin is displayed. - NS_IMETHOD_(PRUint32) - GetDocumentID(void) = 0; - - NS_IMETHOD_(const char *) - GetCode(void) = 0; - - NS_IMETHOD_(const char *) - GetCodeBase(void) = 0; - - NS_IMETHOD_(const char *) - GetArchive(void) = 0; - - NS_IMETHOD_(const char *) - GetID(void) = 0; - - NS_IMETHOD_(PRBool) - GetMayScript(void) = 0; - - NS_IMETHOD_(const char*) - GetDocumentBase(void) = 0; - - NS_IMETHOD_(INTL_CharSetInfo) - GetDocumentCharSetInfo(void) = 0; - - NS_IMETHOD_(const char*) - GetAlignment(void) = 0; - - NS_IMETHOD_(PRUint32) - GetWidth(void) = 0; - - NS_IMETHOD_(PRUint32) - GetHeight(void) = 0; - - NS_IMETHOD_(PRUint32) - GetBorderVertSpace(void) = 0; - - NS_IMETHOD_(PRUint32) - GetBorderHorizSpace(void) = 0; - - NS_IMETHOD_(PRBool) - Tickle(void) = 0; - -}; - -#define NP_IJVMPLUGININSTANCEPEER_IID \ -{ /* 27b42df0-a1bd-11d1-85b1-00805f0e4dfe */ \ - 0x27b42df0, \ - 0xa1bd, \ - 0x11d1, \ - {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \ -} - -//////////////////////////////////////////////////////////////////////////////// -#endif /* nsjvm_h___ */ diff --git a/modules/oji/src/scd.cpp b/modules/oji/src/scd.cpp index 2e659bd93e97..b88436511ecd 100644 --- a/modules/oji/src/scd.cpp +++ b/modules/oji/src/scd.cpp @@ -23,11 +23,11 @@ #include "jvmmgr.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kISymantecDebugManagerIID, NP_ISYMANTECDEBUGMANAGER_IID); +static NS_DEFINE_IID(kISymantecDebugManagerIID, NS_ISYMANTECDEBUGMANAGER_IID); NS_IMPL_AGGREGATED(nsSymantecDebugManager); -nsSymantecDebugManager::nsSymantecDebugManager(nsISupports* outer, JVMMgr* jvmMgr) +nsSymantecDebugManager::nsSymantecDebugManager(nsISupports* outer, nsJVMMgr* jvmMgr) : fJVMMgr(jvmMgr) { NS_INIT_AGGREGATED(outer); @@ -50,7 +50,7 @@ nsSymantecDebugManager::AggregatedQueryInterface(const nsIID& aIID, void** aInst NS_METHOD nsSymantecDebugManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr, - JVMMgr* jvmMgr) + nsJVMMgr* jvmMgr) { if (outer && !aIID.Equals(kISupportsIID)) return NS_NOINTERFACE; // XXX right error? @@ -66,7 +66,7 @@ nsSymantecDebugManager::Create(nsISupports* outer, const nsIID& aIID, void* *aIn extern "C" HWND FindNavigatorHiddenWindow(void); #endif -NS_METHOD_(PRBool) +NS_METHOD nsSymantecDebugManager::SetDebugAgentPassword(PRInt32 pwd) { #if defined(XP_PC) && defined(_WIN32) @@ -86,9 +86,9 @@ nsSymantecDebugManager::SetDebugAgentPassword(PRInt32 pwd) ReleaseSemaphore(sem, 1, NULL); CloseHandle(sem); } - return PR_TRUE; + return NS_OK; #else - return PR_FALSE; + return NS_ERROR_FAILURE; #endif } diff --git a/modules/plugin/Makefile b/modules/plugin/Makefile index 46dc9f6fe3a2..418229efe4c9 100644 --- a/modules/plugin/Makefile +++ b/modules/plugin/Makefile @@ -20,7 +20,11 @@ DEPTH=../.. #// DIRS - There are subdirectories to process #// #//------------------------------------------------------------------------ +ifndef NGLAYOUT_PLUGINS DIRS= public src +else +DIRS= public nglsrc +endif #//------------------------------------------------------------------------ #// diff --git a/modules/plugin/bad/badapter.cpp b/modules/plugin/bad/badapter.cpp index 9aad2c653909..5519be986ab5 100644 --- a/modules/plugin/bad/badapter.cpp +++ b/modules/plugin/bad/badapter.cpp @@ -42,75 +42,49 @@ extern "C" { // // This is the dummy plugin manager that interacts with the 5.0 plugin. // -class CPluginManager : public nsIPluginManager { +class CPluginManager : public nsIPluginManager, + public nsINetworkManager { public: CPluginManager(void); virtual ~CPluginManager(void); NS_DECL_ISUPPORTS - - NS_IMETHOD_(void) - ReloadPlugins(PRBool reloadPages); - - NS_IMETHOD_(void* ) - MemAlloc(PRUint32 size); - NS_IMETHOD_(void) - MemFree(void* ptr); - - NS_IMETHOD_(PRUint32) - MemFlush(PRUint32 size); + //////////////////////////////////////////////////////////////////////////// + // from nsIPluginManager: // (Corresponds to NPN_GetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value); // (Corresponds to NPN_SetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD SetValue(nsPluginManagerVariable variable, void *value); + + NS_IMETHOD + ReloadPlugins(PRBool reloadPages); // (Corresponds to NPN_UserAgent.) - NS_IMETHOD_(const char*) - UserAgent(void); + NS_IMETHOD + UserAgent(const char* *result); - // (Corresponds to NPN_GetURL and NPN_GetURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - NS_IMETHOD_(nsPluginError) - GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE); + //////////////////////////////////////////////////////////////////////////// + // from nsINetworkManager: - // (Corresponds to NPN_PostURL and NPN_PostURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - // postHeaders: A string containing post headers. - // postHeadersLength: The length of the post headers string. - NS_IMETHOD_(nsPluginError) - PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData = NULL, + NS_IMETHOD + GetURL(nsISupports* peer, const char* url, const char* target, + void* notifyData = NULL, const char* altHost = NULL, + const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE); + + NS_IMETHOD + PostURL(nsISupports* peer, const char* url, const char* target, + PRUint32 postDataLen, const char* postData, + PRBool isFile = PR_FALSE, void* notifyData = NULL, const char* altHost = NULL, const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE, PRUint32 postHeadersLength = 0, const char* postHeaders = NULL); + }; //////////////////////////////////////////////////////////////////////////////// @@ -133,12 +107,15 @@ public: // Taken from nsIStream // - // The Release function in nsISupport will take care of destroying the stream. - - NS_IMETHOD_(PRInt32) - Write (const char* buffer, PRInt32 offset, PRInt32 len, nsresult* error); - // XXX - Hmm? Why is there an extra parameter offset? - // (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer); + /** Write data into the stream. + * @param aBuf the buffer into which the data is read + * @param aOffset the start offset of the data + * @param aCount the maximum number of bytes to read + * @param errorResult the error code if an error occurs + * @return number of bytes read or -1 if error + */ + NS_IMETHOD + Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aWriteCount); ////////////////////////////////////////////////////////////////////////// // @@ -146,20 +123,20 @@ public: // // Corresponds to NPStream's url field. - NS_IMETHOD_(const char* ) - GetURL(void); + NS_IMETHOD + GetURL(const char* *result); // Corresponds to NPStream's end field. - NS_IMETHOD_(PRUint32) - GetEnd(void); + NS_IMETHOD + GetEnd(PRUint32 *result); // Corresponds to NPStream's lastmodfied field. - NS_IMETHOD_(PRUint32) - GetLastModified(void); + NS_IMETHOD + GetLastModified(PRUint32 *result); // Corresponds to NPStream's notifyData field. - NS_IMETHOD_(void* ) - GetNotifyData(void); + NS_IMETHOD + GetNotifyData(void* *result); // Corresponds to NPStream's url field. NS_IMETHOD Close(void); @@ -190,42 +167,50 @@ public: // XXX - I add parameters to the constructor because I wasn't sure if // XXX - the 4.0 browser had the npp_instance struct implemented. // XXX - If so, then I can access npp_instance through npp->ndata. - CPluginInstancePeer(NPP npp, nsMIMEType typeString, nsPluginType type, + CPluginInstancePeer(NPP npp, nsMIMEType typeString, nsPluginMode type, PRUint16 attribute_cnt, const char** attribute_list, const char** values_list); virtual ~CPluginInstancePeer(void); NS_DECL_ISUPPORTS + // (Corresponds to NPN_GetValue.) + NS_IMETHOD + GetValue(nsPluginInstancePeerVariable variable, void *value); + + // (Corresponds to NPN_SetValue.) + NS_IMETHOD + SetValue(nsPluginInstancePeerVariable variable, void *value); + // Corresponds to NPP_New's MIMEType argument. - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetMIMEType(nsMIMEType *result); // Corresponds to NPP_New's mode argument. - NS_IMETHOD_(nsPluginType) - GetMode(void); + NS_IMETHOD + GetMode(nsPluginMode *result); // Get a ptr to the paired list of attribute names and values, // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values); // Get the value for the named attribute. Returns null // if the attribute was not set. - NS_IMETHOD_(const char*) - GetAttribute(const char* name); + NS_IMETHOD + GetAttribute(const char* name, const char* *result); // Corresponds to NPN_NewStream. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result); // Corresponds to NPN_ShowStatus. - NS_IMETHOD_(void) + NS_IMETHOD ShowStatus(const char* message); // XXX - Where did this go? - NS_IMETHOD_(void) + NS_IMETHOD Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor); @@ -238,7 +223,7 @@ protected: // XXX - The next five variables may need to be here since I // XXX - don't think np_instance is available in 4.0X. nsMIMEType typeString; - nsPluginType type; + nsPluginMode type; PRUint16 attribute_cnt; char** attribute_list; char** values_list; @@ -261,20 +246,20 @@ public: NS_DECL_ISUPPORTS // (Corresponds to NPStream's url field.) - NS_IMETHOD_(const char*) - GetURL(void); + NS_IMETHOD + GetURL(const char* *result); // (Corresponds to NPStream's end field.) - NS_IMETHOD_(PRUint32) - GetEnd(void); + NS_IMETHOD + GetEnd(PRUint32 *result); // (Corresponds to NPStream's lastmodified field.) - NS_IMETHOD_(PRUint32) - GetLastModified(void); + NS_IMETHOD + GetLastModified(PRUint32 *result); // (Corresponds to NPStream's notifyData field.) - NS_IMETHOD_(void*) - GetNotifyData(void); + NS_IMETHOD + GetNotifyData(void* *result); ////////////////////////////////////////////////////////////////////////// // @@ -282,12 +267,12 @@ public: // // Corresponds to NPP_DestroyStream's reason argument. - NS_IMETHOD_(nsPluginReason) - GetReason(void); + NS_IMETHOD + GetReason(nsPluginReason *result); // Corresponds to NPP_NewStream's MIMEType argument. - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetMIMEType(nsMIMEType *result); ////////////////////////////////////////////////////////////////////////// // @@ -295,7 +280,7 @@ public: // // Corresponds to NPN_RequestRead. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD RequestRead(nsByteRange* rangeList); protected: @@ -348,15 +333,33 @@ nsIPlugin* thePlugin = NULL; // Interface IDs for nsISupports // NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -NS_DEFINE_IID(kPluginIID, NS_IPLUGIN_IID); -NS_DEFINE_IID(kPluginInstanceIID, NS_IPLUGININSTANCE_IID); -NS_DEFINE_IID(kPluginManagerIID, NS_IPLUGINMANAGER_IID); -NS_DEFINE_IID(kPluginTagInfoIID, NS_IPLUGINTAGINFO_IID); -NS_DEFINE_IID(kOutputStreamIID, NS_IOUTPUTSTREAM_IID); -NS_DEFINE_IID(kPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); -NS_DEFINE_IID(kPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); -NS_DEFINE_IID(kSeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); +NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID); +NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID); +NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); +NS_DEFINE_IID(kINetworkManagerIID, NS_INETWORKMANAGER_IID); +NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID); +NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID); +NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); +NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); +NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); +// mapping from NPError to nsresult +nsresult fromNPError[] = { + NS_OK, // NPERR_NO_ERROR, + NS_ERROR_FAILURE, // NPERR_GENERIC_ERROR, + NS_ERROR_FAILURE, // NPERR_INVALID_INSTANCE_ERROR, + NS_ERROR_NOT_INITIALIZED, // NPERR_INVALID_FUNCTABLE_ERROR, + NS_ERROR_FACTORY_NOT_LOADED, // NPERR_MODULE_LOAD_FAILED_ERROR, + NS_ERROR_OUT_OF_MEMORY, // NPERR_OUT_OF_MEMORY_ERROR, + NS_NOINTERFACE, // NPERR_INVALID_PLUGIN_ERROR, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PLUGIN_DIR_ERROR, + NS_NOINTERFACE, // NPERR_INCOMPATIBLE_VERSION_ERROR, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PARAM, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_URL, + NS_ERROR_ILLEGAL_VALUE, // NPERR_FILE_NOT_FOUND, + NS_ERROR_FAILURE, // NPERR_NO_DATA, + NS_ERROR_FAILURE // NPERR_STREAM_NOT_SEEKABLE, +}; //////////////////////////////////////////////////////////////////////////////// // SECTION 4 - API Shim Plugin Implementations @@ -378,25 +381,28 @@ NS_DEFINE_IID(kSeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); //////////////////////////////////////////////////////////////////////////////// // UNIX-only API calls //////////////////////////////////////////////////////////////////////////////// + #ifdef XP_UNIX char* NPP_GetMIMEDescription(void) { int freeFac = 0; - fprintf(stderr, "MIME description\n"); + //fprintf(stderr, "MIME description\n"); if (thePlugin == NULL) { - freeFac = 1; - NSGetFactory(kPluginIID, (nsIFactory** )(&thePlugin)); + freeFac = 1; + NSGetFactory(kIPluginIID, (nsIFactory** )(&thePlugin)); } - fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); - char * ret = (char *) thePlugin->GetMIMEDescription(); - fprintf(stderr, "Get response %s\n", ret); + //fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); + const char * ret; + nsresult err = thePlugin->GetMIMEDescription(&ret); + if (err) return NULL; + //fprintf(stderr, "Get response %s\n", ret); if (freeFac) { - fprintf(stderr, "Freeing plugin..."); - thePlugin->Release(); - thePlugin = NULL; + //fprintf(stderr, "Freeing plugin..."); + thePlugin->Release(); + thePlugin = NULL; } - fprintf(stderr, "Done\n"); - return ret; + //fprintf(stderr, "Done\n"); + return (char*)ret; } @@ -407,36 +413,40 @@ char* NPP_GetMIMEDescription(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_SetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { - return (NPError)nsPluginError_NoError; + return NPERR_GENERIC_ERROR; // nothing to set } //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_GetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { int freeFac = 0; - fprintf(stderr, "MIME description\n"); + //fprintf(stderr, "MIME description\n"); if (thePlugin == NULL) { - freeFac = 1; - if (NSGetFactory(kPluginIID, (nsIFactory** )(&thePlugin)) != NS_OK) - return NPERR_GENERIC_ERROR; + freeFac = 1; + if (NSGetFactory(kIPluginIID, (nsIFactory** )(&thePlugin)) != NS_OK) + return NPERR_GENERIC_ERROR; } - fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); - NPError ret = (NPError) thePlugin->GetValue((nsPluginVariable)variable, value); - fprintf(stderr, "Get response %08x\n", ret); + //fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); + nsresult err = thePlugin->GetValue((nsPluginVariable)variable, value); + if (err) return NPERR_GENERIC_ERROR; + //fprintf(stderr, "Get response %08x\n", ret); if (freeFac) { - fprintf(stderr, "Freeing plugin..."); - thePlugin->Release(); - thePlugin = NULL; + //fprintf(stderr, "Freeing plugin..."); + thePlugin->Release(); + thePlugin = NULL; } - fprintf(stderr, "Done\n"); - return ret; + //fprintf(stderr, "Done\n"); + return NPERR_NO_ERROR; } -#endif +#endif // XP_UNIX + //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_Initialize: // Provides global initialization for a plug-in, and returns an error value. @@ -444,6 +454,7 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { // This function is called once when a plug-in is loaded, before the first instance // is created. thePluginManager and thePlugin are both initialized. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_Initialize(void) { @@ -453,19 +464,19 @@ NPP_Initialize(void) // This could happen if GetJavaClass() is called before // NPP Initialize. if (thePluginManager == NULL) { - // Create the plugin manager and plugin classes. - thePluginManager = new CPluginManager(); - if ( thePluginManager == NULL ) - return NPERR_OUT_OF_MEMORY_ERROR; - thePluginManager->AddRef(); + // Create the plugin manager and plugin classes. + thePluginManager = new CPluginManager(); + if ( thePluginManager == NULL ) + return NPERR_OUT_OF_MEMORY_ERROR; + thePluginManager->AddRef(); } nsresult error = NS_OK; // On UNIX the plugin might have been created when calling NPP_GetMIMEType. if (thePlugin == NULL) - // create nsIPlugin factory - error = (NPError)NSGetFactory(kPluginIID, (nsIFactory**) &thePlugin); + // create nsIPlugin factory + error = (NPError)NSGetFactory(kIPluginIID, (nsIFactory**) &thePlugin); if (error == NS_OK) - thePlugin->Initialize(thePluginManager); + thePlugin->Initialize(thePluginManager); return (NPError) error; } @@ -481,11 +492,12 @@ NPP_Initialize(void) // error will be signalled by "use_" and will cause the Navigator to // complain to the user. //+++++++++++++++++++++++++++++++++++++++++++++++++ + jref NPP_GetJavaClass(void) { // Only call initialize the plugin if it hasn't been `d. - /* if (thePluginManager == NULL) { + /* if (thePluginManager == NULL) { // Create the plugin manager and plugin objects. NPError result = CPluginManager::Create(); if (result) return NULL; @@ -493,8 +505,8 @@ NPP_GetJavaClass(void) thePluginManager->AddRef(); NP_CreatePlugin(thePluginManager, (nsIPlugin** )(&thePlugin)); assert( thePlugin != NULL ); - } -*/ + } + */ // return thePlugin->GetJavaClass(); return NULL; } @@ -506,6 +518,7 @@ NPP_GetJavaClass(void) // This function is called once after the last instance of your plug-in // is destroyed. thePluginManager and thePlugin are delete at this time. //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_Shutdown(void) { @@ -534,6 +547,7 @@ NPP_Shutdown(void) // a successful instansiation, the peer is stored in the plugin // instance's pdata. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_New(NPMIMEType pluginType, NPP instance, @@ -546,13 +560,13 @@ NPP_New(NPMIMEType pluginType, // TRACE("NPP_New\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; // Create a new plugin instance and start it. nsIPluginInstance* pluginInstance = NULL; - thePlugin->CreateInstance(NULL, kPluginInstanceIID, (void**)&pluginInstance); + thePlugin->CreateInstance(NULL, kIPluginInstanceIID, (void**)&pluginInstance); if (pluginInstance == NULL) { - return NPERR_OUT_OF_MEMORY_ERROR; + return NPERR_OUT_OF_MEMORY_ERROR; } // Create a new plugin instance peer, @@ -560,9 +574,9 @@ NPP_New(NPMIMEType pluginType, // XXX - had to save the plugin parameter in the peer class. // XXX - Ask Warren about np_instance. CPluginInstancePeer* peer = - new CPluginInstancePeer(instance, (nsMIMEType)pluginType, - (nsPluginType)mode, (PRUint16)argc, - (const char** )argn, (const char** )argv); + new CPluginInstancePeer(instance, (nsMIMEType)pluginType, + (nsPluginMode)mode, (PRUint16)argc, + (const char** )argn, (const char** )argv); assert( peer != NULL ); if (!peer) return NPERR_OUT_OF_MEMORY_ERROR; peer->AddRef(); @@ -582,13 +596,14 @@ NPP_New(NPMIMEType pluginType, // The plugin instance peer and plugin instance are destroyed. // The instance's pdata is set to NULL. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_Destroy(NPP instance, NPSavedData** save) { // TRACE("NPP_Destroy\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; nsIPluginInstance* pluginInstance = (nsIPluginInstance* )instance->pdata; pluginInstance->Stop(); @@ -603,18 +618,19 @@ NPP_Destroy(NPP instance, NPSavedData** save) // NPP_SetWindow: // Sets the window in which a plug-in draws, and returns an error value. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_SetWindow(NPP instance, NPWindow* window) { // TRACE("NPP_SetWindow\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; nsIPluginInstance* pluginInstance = (nsIPluginInstance* )instance->pdata; if( pluginInstance == 0 ) - return NPERR_INVALID_PLUGIN_ERROR; + return NPERR_INVALID_PLUGIN_ERROR; return (NPError)pluginInstance->SetWindow((nsPluginWindow* ) window ); } @@ -626,6 +642,7 @@ NPP_SetWindow(NPP instance, NPWindow* window) // Create a stream peer and stream. If succesful, save // the stream peer in NPStream's pdata. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_NewStream(NPP instance, NPMIMEType type, @@ -640,23 +657,25 @@ NPP_NewStream(NPP instance, // TRACE("NPP_NewStream\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; // Create a new plugin stream peer and plugin stream. CPluginStreamPeer* speer = new CPluginStreamPeer((nsMIMEType)type, stream, - (PRBool)seekable, stype); + (PRBool)seekable, stype); if (speer == NULL) return NPERR_OUT_OF_MEMORY_ERROR; speer->AddRef(); nsIPluginStream* pluginStream = NULL; nsIPluginInstance* pluginInstance = (nsIPluginInstance*) instance->pdata; - NPError result = (NPError)pluginInstance->NewStream(speer, &pluginStream); + nsresult err = pluginInstance->NewStream(speer, &pluginStream); + if (err) return NPERR_OUT_OF_MEMORY_ERROR; speer->Release(); if (pluginStream == NULL) - return NPERR_OUT_OF_MEMORY_ERROR; + return NPERR_OUT_OF_MEMORY_ERROR; stream->pdata = (void*) pluginStream; - *stype = pluginStream->GetStreamType(); + err = pluginStream->GetStreamType((nsPluginStreamType*)stype); + assert(err == NS_OK); return NPERR_NO_ERROR; } @@ -666,17 +685,18 @@ NPP_NewStream(NPP instance, // Returns the maximum number of bytes that an instance is prepared to accept // from the stream. //+++++++++++++++++++++++++++++++++++++++++++++++++ + int32 NPP_WriteReady(NPP instance, NPStream *stream) { // TRACE("NPP_WriteReady\n"); if (instance == NULL) - return -1; + return -1; nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata; if( theStream == 0 ) - return -1; + return -1; return 8192; } @@ -686,20 +706,22 @@ NPP_WriteReady(NPP instance, NPStream *stream) // NPP_Write: // Delivers data from a stream and returns the number of bytes written. //+++++++++++++++++++++++++++++++++++++++++++++++++ + int32 NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) { // TRACE("NPP_Write\n"); if (instance == NULL) - return -1; + return -1; nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata; if( theStream == 0 ) - return -1; + return -1; - nsresult result; - return theStream->Write((const char* )buffer, offset, len, &result); + PRInt32 count; + nsresult err = theStream->Write((const char* )buffer, offset, len, &count); + return (err == NS_OK) ? count : -1; } //+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -709,17 +731,18 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) // The stream peer and stream are destroyed. NPStream's // pdata is set to NULL. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) { // TRACE("NPP_DestroyStream\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata; if( theStream == 0 ) - return NPERR_GENERIC_ERROR; + return NPERR_GENERIC_ERROR; theStream->Release(); stream->pdata = NULL; @@ -731,6 +754,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) // NPP_StreamAsFile: // Provides a local file name for the data from a stream. //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname) { @@ -749,6 +773,7 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname) //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_Print: //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_Print(NPP instance, NPPrint* printInfo) { @@ -768,6 +793,7 @@ NPP_Print(NPP instance, NPPrint* printInfo) // NPP_URLNotify: // Notifies the instance of the completion of a URL request. //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData) { @@ -786,6 +812,7 @@ NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData) // Mac-only, but stub must be present for Windows // Delivers a platform-specific event to the instance. //+++++++++++++++++++++++++++++++++++++++++++++++++ + #ifndef XP_UNIX int16 NPP_HandleEvent(NPP instance, void* event) @@ -797,13 +824,16 @@ NPP_HandleEvent(NPP instance, void* event) return eventHandled; nsIPluginInstance* pluginInstance = (nsIPluginInstance*) instance->pdata; - if( pluginInstance ) - eventHandled = (int16) pluginInstance->HandleEvent((nsPluginEvent*) event ); + if (pluginInstance) { + PRBool handled; + nsresult err = pluginInstance->HandleEvent((nsPluginEvent*)event, &handled); + if (err) return FALSE; + eventHandled = (handled == PR_TRUE); + } return eventHandled; } #endif // ndef XP_UNIX -////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // SECTION 5 - API Browser Implementations @@ -832,10 +862,12 @@ CPluginManager::~CPluginManager(void) { } +#if 0 //+++++++++++++++++++++++++++++++++++++++++++++++++ // MemAlloc: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void* NP_LOADDS + +NS_METHOD CPluginManager::MemAlloc(PRUint32 size) { return NPN_MemAlloc(size); @@ -844,7 +876,8 @@ CPluginManager::MemAlloc(PRUint32 size) //+++++++++++++++++++++++++++++++++++++++++++++++++ // MemFree: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginManager::MemFree(void* ptr) { assert( ptr != NULL ); @@ -855,7 +888,8 @@ CPluginManager::MemFree(void* ptr) //+++++++++++++++++++++++++++++++++++++++++++++++++ // MemFlush: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 NP_LOADDS + +NS_METHOD CPluginManager::MemFlush(PRUint32 size) { #ifdef XP_MAC @@ -864,14 +898,17 @@ CPluginManager::MemFlush(PRUint32 size) return 0; #endif } +#endif //+++++++++++++++++++++++++++++++++++++++++++++++++ // ReloadPlugins: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginManager::ReloadPlugins(PRBool reloadPages) { NPN_ReloadPlugins(reloadPages); + return NS_OK; } @@ -887,128 +924,138 @@ CPluginManager::ReloadPlugins(PRBool reloadPages) // referrer: // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, // even if the user currently has JavaScript disabled. -nsPluginError NP_LOADDS -CPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData, - const char* altHost, const char* referrer, PRBool forceJSEnabled) +NS_METHOD +CPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, + void* notifyData, const char* altHost, + const char* referrer, PRBool forceJSEnabled) { - // assert( npp != NULL ); - // assert( url != NULL ); + // assert( npp != NULL ); + // assert( url != NULL ); assert( peer != NULL); CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)(nsIPluginInstancePeer*) peer; NPP npp = instancePeer->GetNPPInstance(); - + NPError err; // Call the correct GetURL* function. // This is determinded by checking notifyData. if (notifyData == NULL) { - return (nsPluginError)NPN_GetURL(npp, url, target); + err = NPN_GetURL(npp, url, target); } else { - return (nsPluginError)NPN_GetURLNotify(npp, url, target, notifyData); + err = NPN_GetURLNotify(npp, url, target, notifyData); } + return fromNPError[err]; } -// (Corresponds to NPN_PostURL and NPN_PostURLNotify.) -// notifyData: When present, URLNotify is called passing the notifyData back -// to the client. When NULL, this call behaves like NPN_GetURL. -// New arguments: -// peer: A plugin instance peer. The peer's window will be used to display -// progress information. If NULL, the load happens in the background. -// altHost: An IP-address string that will be used instead of the host -// specified in the URL. This is used to prevent DNS-spoofing attacks. -// Can be defaulted to NULL meaning use the host in the URL. -// referrer: -// forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, -// even if the user currently has JavaScript disabled. -// postHeaders: A string containing post headers. -// postHeadersLength: The length of the post headers string. -nsPluginError NP_LOADDS -CPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData, const char* altHost, - const char* referrer, PRBool forceJSEnabled, PRUint32 postHeadersLength, - const char* postHeaders) -{ - assert( peer != NULL); - CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)(nsIPluginInstancePeer*)peer; +NS_METHOD +CPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, + PRUint32 postDataLen, const char* postData, + PRBool isFile, void* notifyData, + const char* altHost, const char* referrer, + PRBool forceJSEnabled, + PRUint32 postHeadersLength, const char* postHeaders) +{ + // assert( npp != NULL ); + // assert( url != NULL ); + assert( peer != NULL); + + CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)(nsIPluginInstancePeer*) peer; NPP npp = instancePeer->GetNPPInstance(); + NPError err; // Call the correct PostURL* function. // This is determinded by checking notifyData. if (notifyData == NULL) { - return (nsPluginError)NPN_PostURL(npp, url, target, bufLen, buf, file); + err = NPN_PostURL(npp, url, target, postDataLen, postData, isFile); } else { - return (nsPluginError)NPN_PostURLNotify(npp, url, target, bufLen, buf, file, notifyData); + err = NPN_PostURLNotify(npp, url, target, postDataLen, postData, isFile, notifyData); } + return fromNPError[err]; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // UserAgent: //+++++++++++++++++++++++++++++++++++++++++++++++++ -const char* NP_LOADDS -CPluginManager::UserAgent(void) + +NS_METHOD +CPluginManager::UserAgent(const char* *result) { - return NPN_UserAgent(NULL); + *result = NPN_UserAgent(NULL); + return NS_OK; } +int varMap[] = { + (int)NPNVxDisplay, // nsPluginManagerVariable_XDisplay = 1, + (int)NPNVxtAppContext, // nsPluginManagerVariable_XtAppContext, + (int)NPNVnetscapeWindow, // nsPluginManagerVariable_NetscapeWindow, + (int)NPPVpluginWindowBool, // nsPluginInstancePeerVariable_WindowBool, + (int)NPPVpluginTransparentBool, // nsPluginInstancePeerVariable_TransparentBool, + (int)NPPVjavaClass, // nsPluginInstancePeerVariable_JavaClass, + (int)NPPVpluginWindowSize, // nsPluginInstancePeerVariable_WindowSize, + (int)NPPVpluginTimerInterval, // nsPluginInstancePeerVariable_TimerInterval +}; + //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS + +NS_METHOD CPluginManager::GetValue(nsPluginManagerVariable variable, void *value) { - // XXX - This may need to be stubbed out for - // XXX - other platforms than Unix. - // XXX - Change this to return NPPPlugin_Error; #ifdef XP_UNIX - return (nsPluginError)NPN_GetValue(NULL, (NPNVariable)variable, value); + return fromNPError[NPN_GetValue(NULL, (NPNVariable)varMap[(int)variable], value)]; #else - // XXX - Need to check this on the new API. - return nsPluginError_NoData; + return fromNPError[NPERR_GENERIC_ERROR]; #endif // XP_UNIX } //+++++++++++++++++++++++++++++++++++++++++++++++++ // SetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS + +NS_METHOD CPluginManager::SetValue(nsPluginManagerVariable variable, void *value) { - // XXX - This should do something like this. - // XXX - return (nsPluginError)npn_setvalue(npp, (NPPVariable)variable, value); - // XXX - Is this XP in 4.0x? - // XXX - Need to check this on the new API. - return nsPluginError_NoData; +#ifdef XP_UNIX + return fromNPError[NPN_SetValue(NULL, (NPPVariable)varMap[(int)variable], value)]; +#else + return fromNPError[NPERR_GENERIC_ERROR]; +#endif // XP_UNIX } - - - //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginManager); NS_IMPL_RELEASE(CPluginManager); -//NS_IMPL_QUERY_INTERFACE(CPluginManager, kPluginManagerIID); -nsresult CPluginManager::QueryInterface(const nsIID& iid, void** ptr) + +NS_METHOD +CPluginManager::QueryInterface(const nsIID& iid, void** ptr) { - if (NULL == ptr) { - return NS_ERROR_NULL_POINTER; - } + if (NULL == ptr) { + return NS_ERROR_NULL_POINTER; + } - if (iid.Equals(kPluginManagerIID)) { - *ptr = (void*) this; - AddRef(); - return NS_OK; - } - if (iid.Equals(kISupportsIID)) { - *ptr = (void*) ((nsISupports*)this); - AddRef(); - return NS_OK; - } - return NS_NOINTERFACE; + if (iid.Equals(kIPluginManagerIID)) { + *ptr = (void*) (nsIPluginManager*)this; + AddRef(); + return NS_OK; + } + if (iid.Equals(kINetworkManagerIID)) { + *ptr = (void*) (nsINetworkManager*)this; + AddRef(); + return NS_OK; + } + if (iid.Equals(kISupportsIID)) { + *ptr = (void*) ((nsIPluginManager*)this); + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; } @@ -1019,7 +1066,7 @@ nsresult CPluginManager::QueryInterface(const nsIID& iid, void** ptr) CPluginInstancePeer::CPluginInstancePeer(NPP npp, nsMIMEType typeString, - nsPluginType type, + nsPluginMode type, PRUint16 attr_cnt, const char** attr_list, const char** val_list) @@ -1053,24 +1100,56 @@ CPluginInstancePeer::~CPluginInstancePeer(void) } +//+++++++++++++++++++++++++++++++++++++++++++++++++ +// GetValue: +//+++++++++++++++++++++++++++++++++++++++++++++++++ + +NS_METHOD +CPluginInstancePeer::GetValue(nsPluginInstancePeerVariable variable, void *value) +{ +#ifdef XP_UNIX + return fromNPError[NPN_GetValue(NULL, (NPNVariable)varMap[(int)variable], value)]; +#else + return fromNPError[NPERR_GENERIC_ERROR]; +#endif // XP_UNIX +} + +//+++++++++++++++++++++++++++++++++++++++++++++++++ +// SetValue: +//+++++++++++++++++++++++++++++++++++++++++++++++++ + +NS_METHOD +CPluginInstancePeer::SetValue(nsPluginInstancePeerVariable variable, void *value) +{ +#ifdef XP_UNIX + return fromNPError[NPN_SetValue(NULL, (NPPVariable)varMap[(int)variable], value)]; +#else + return fromNPError[NPERR_GENERIC_ERROR]; +#endif // XP_UNIX +} + //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetMIMEType: // Corresponds to NPP_New's MIMEType argument. //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsMIMEType NP_LOADDS -CPluginInstancePeer::GetMIMEType(void) + +NS_METHOD +CPluginInstancePeer::GetMIMEType(nsMIMEType *result) { - return typeString; + *result = typeString; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetMode: // Corresponds to NPP_New's mode argument. //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginType NP_LOADDS -CPluginInstancePeer::GetMode(void) + +NS_METHOD +CPluginInstancePeer::GetMode(nsPluginMode *result) { - return type; + *result = type; + return NS_OK; } @@ -1078,32 +1157,35 @@ CPluginInstancePeer::GetMode(void) // returns the length of the array. // // Each name or value is a null-terminated string. -nsPluginError NP_LOADDS +NS_METHOD CPluginInstancePeer::GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values) { n = attribute_cnt; names = attribute_list; values = values_list; - return nsPluginError_NoError; + return NS_OK; } // Get the value for the named attribute. Returns null // if the attribute was not set. -const char* NP_LOADDS -CPluginInstancePeer::GetAttribute(const char* name) +NS_METHOD +CPluginInstancePeer::GetAttribute(const char* name, const char* *result) { for (int i=0; i < attribute_cnt; i++) { #ifdef XP_UNIX if (strcasecmp(name, attribute_list[i]) == 0) #else - if (stricmp(name, attribute_list[i]) == 0) + if (stricmp(name, attribute_list[i]) == 0) #endif - return values_list[i]; + { + *result = values_list[i]; + return NS_OK; + } } - return NULL; + return NS_ERROR_FAILURE; } //+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1112,18 +1194,20 @@ CPluginInstancePeer::GetAttribute(const char* name) // XXX - Where did this go in the new API? // //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginInstancePeer::Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor) + int* netscape_major, int* netscape_minor) { NPN_Version(plugin_major, plugin_minor, netscape_major, netscape_minor); + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // NewStream: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS +NS_METHOD CPluginInstancePeer::NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) { @@ -1131,56 +1215,61 @@ CPluginInstancePeer::NewStream(nsMIMEType type, const char* target, // Create a new NPStream. NPStream* ptr = NULL; - nsPluginError error = (nsPluginError)NPN_NewStream(npp, (NPMIMEType)type, target, &ptr); - if (error) return error; + NPError error = NPN_NewStream(npp, (NPMIMEType)type, target, &ptr); + if (error) + return fromNPError[error]; // Create a new Plugin Manager Stream. // XXX - Do we have to Release() the manager stream before doing this? // XXX - See the BAM doc for more info. CPluginManagerStream* mstream = new CPluginManagerStream(npp, ptr); - if (mstream == NULL) return nsPluginError_OutOfMemoryError; + if (mstream == NULL) + return NS_ERROR_OUT_OF_MEMORY; mstream->AddRef(); *result = (nsIOutputStream* )mstream; - return nsPluginError_NoError; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // ShowStatus: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginInstancePeer::ShowStatus(const char* message) { assert( message != NULL ); NPN_Status(npp, message); + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginInstancePeer); NS_IMPL_RELEASE(CPluginInstancePeer); - -nsresult CPluginInstancePeer::QueryInterface(const nsIID& iid, void** ptr) +NS_METHOD +CPluginInstancePeer::QueryInterface(const nsIID& iid, void** ptr) { - if (NULL == ptr) { - return NS_ERROR_NULL_POINTER; - } + if (NULL == ptr) { + return NS_ERROR_NULL_POINTER; + } - if (iid.Equals(kPluginInstancePeerIID)) { - *ptr = (void*) this; - AddRef(); - return NS_OK; - } - if (iid.Equals(kPluginTagInfoIID) || iid.Equals(kISupportsIID)) { - *ptr = (void*) ((nsIPluginTagInfo*)this); - AddRef(); - return NS_OK; - } - return NS_NOINTERFACE; + if (iid.Equals(kIPluginInstancePeerIID)) { + *ptr = (void*) this; + AddRef(); + return NS_OK; + } + if (iid.Equals(kIPluginTagInfoIID) || iid.Equals(kISupportsIID)) { + *ptr = (void*) ((nsIPluginTagInfo*)this); + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; } ////////////////////////////////////////////////////////////////////////////// @@ -1205,63 +1294,76 @@ CPluginManagerStream::~CPluginManagerStream(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // Write: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRInt32 NP_LOADDS -CPluginManagerStream::Write(const char* buffer, PRInt32 offset, PRInt32 len, nsresult* error) + +NS_METHOD +CPluginManagerStream::Write(const char* buffer, PRInt32 offset, PRInt32 len, + PRInt32 *aWriteCount) { assert( npp != NULL ); assert( pstream != NULL ); - return NPN_Write(npp, pstream, len, (void* )buffer); + assert(offset == 0); // XXX need to handle the non-sequential write case + *aWriteCount = NPN_Write(npp, pstream, len, (void* )buffer); + return *aWriteCount >= 0 ? NS_OK : NS_ERROR_FAILURE; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetURL: //+++++++++++++++++++++++++++++++++++++++++++++++++ -const char* NP_LOADDS -CPluginManagerStream::GetURL(void) + +NS_METHOD +CPluginManagerStream::GetURL(const char* *result) { assert( pstream != NULL ); - return pstream->url; + *result = pstream->url; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetEnd: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 NP_LOADDS -CPluginManagerStream::GetEnd(void) + +NS_METHOD +CPluginManagerStream::GetEnd(PRUint32 *result) { assert( pstream != NULL ); - return pstream->end; + *result = pstream->end; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetLastModified: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 NP_LOADDS -CPluginManagerStream::GetLastModified(void) + +NS_METHOD +CPluginManagerStream::GetLastModified(PRUint32 *result) { assert( pstream != NULL ); - return pstream->lastmodified; + *result = pstream->lastmodified; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetNotifyData: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void* NP_LOADDS -CPluginManagerStream::GetNotifyData(void) + +NS_METHOD +CPluginManagerStream::GetNotifyData(void* *result) { assert( pstream != NULL ); - return pstream->notifyData; + *result = pstream->notifyData; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetNotifyData: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsresult NP_LOADDS + +NS_METHOD CPluginManagerStream::Close(void) { assert( pstream != NULL ); @@ -1273,17 +1375,11 @@ CPluginManagerStream::Close(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginManagerStream); -//NS_IMPL_RELEASE(CPluginManagerStream); -nsrefcnt CPluginManagerStream::Release(void) -{ - if (--mRefCnt == 0) { - delete this; - return 0; - } - return mRefCnt; -} -NS_IMPL_QUERY_INTERFACE(CPluginManagerStream, kOutputStreamIID); +NS_IMPL_RELEASE(CPluginManagerStream); + +NS_IMPL_QUERY_INTERFACE(CPluginManagerStream, kIOutputStreamIID); ////////////////////////////////////////////////////////////////////////////// @@ -1308,77 +1404,96 @@ CPluginStreamPeer::~CPluginStreamPeer(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetURL: //+++++++++++++++++++++++++++++++++++++++++++++++++ -const char* CPluginStreamPeer::GetURL(void) + +NS_METHOD +CPluginStreamPeer::GetURL(const char* *result) { - return npStream->url; + *result = npStream->url; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetEnd: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 CPluginStreamPeer::GetEnd(void) + +NS_METHOD +CPluginStreamPeer::GetEnd(PRUint32 *result) { - return npStream->end; + *result = npStream->end; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetLastModified: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 CPluginStreamPeer::GetLastModified(void) + +NS_METHOD +CPluginStreamPeer::GetLastModified(PRUint32 *result) { - return npStream->lastmodified; + *result = npStream->lastmodified; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetNotifyData: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void* CPluginStreamPeer::GetNotifyData(void) + +NS_METHOD +CPluginStreamPeer::GetNotifyData(void* *result) { - return npStream->notifyData; + *result = npStream->notifyData; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetReason: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginReason CPluginStreamPeer::GetReason(void) + +NS_METHOD +CPluginStreamPeer::GetReason(nsPluginReason *result) { - return reason; + *result = reason; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetMIMEType: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsMIMEType NP_LOADDS -CPluginStreamPeer::GetMIMEType(void) + +NS_METHOD +CPluginStreamPeer::GetMIMEType(nsMIMEType *result) { - return type; + *result = type; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // RequestRead: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS + +NS_METHOD CPluginStreamPeer::RequestRead(nsByteRange* rangeList) { - return (nsPluginError)NPN_RequestRead(npStream, (NPByteRange* )rangeList); + return fromNPError[NPN_RequestRead(npStream, (NPByteRange* )rangeList)]; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginStreamPeer); NS_IMPL_RELEASE(CPluginStreamPeer); -//NS_IMPL_QUERY_INTERFACE(CPluginStreamPeer, kSeekablePluginStreamPeerIID); + nsresult CPluginStreamPeer::QueryInterface(const nsIID& iid, void** ptr) { if (NULL == ptr) { return NS_ERROR_NULL_POINTER; } - if (iid.Equals(kSeekablePluginStreamPeerIID)) { + if (iid.Equals(kISeekablePluginStreamPeerIID)) { *ptr = (void*) ((nsISeekablePluginStreamPeer*)this); AddRef(); return NS_OK; - } else if (iid.Equals(kPluginStreamPeerIID) || + } else if (iid.Equals(kIPluginStreamPeerIID) || iid.Equals(kISupportsIID)) { *ptr = (void*) ((nsIPluginStreamPeer*)this); AddRef(); diff --git a/modules/plugin/base/public/MANIFEST b/modules/plugin/base/public/MANIFEST index 1a731f872da5..6088c3869c81 100644 --- a/modules/plugin/base/public/MANIFEST +++ b/modules/plugin/base/public/MANIFEST @@ -19,17 +19,15 @@ # This is a list of local files which get copied to the mozilla:dist directory # +nsIEventHandler.h nsIFileUtilities.h nsIJRILiveConnectPlugin.h -#//nsIJRILiveConnectPluginInstancePeer.h nsIJRILiveConnectPlugInstPeer.h nsILiveConnectPlugin.h -#//nsILiveConnectPluginInstancePeer.h nsILiveConnectPlugInstPeer.h nsIPlugin.h nsIPluginInstance.h nsIPluginInstancePeer.h -nsIPluginInstancePeer2.h nsIPluginManager.h nsIPluginManager2.h nsIPluginStream.h @@ -38,7 +36,7 @@ nsIPluginStreamPeer2.h nsIPluginTagInfo.h nsIPluginTagInfo2.h nsISeekablePluginStreamPeer.h -#//nsIWindowlessPluginInstancePeer.h nsIWindowlessPlugInstPeer.h nsplugin.h nsplugindefs.h +nsINetworkManager.h diff --git a/modules/plugin/base/public/Makefile b/modules/plugin/base/public/Makefile index f87022e6ebad..e3099394456c 100644 --- a/modules/plugin/base/public/Makefile +++ b/modules/plugin/base/public/Makefile @@ -19,26 +19,27 @@ DEPTH = ../../.. MODULE = plugin -EXPORTS = \ - nsIFileUtilities.h \ - nsIJRILiveConnectPlugin.h \ - nsIJRILiveConnectPluginInstancePeer.h \ - nsILiveConnectPlugin.h \ - nsILiveConnectPluginInstancePeer.h \ - nsIPlugin.h \ - nsIPluginInstance.h \ - nsIPluginInstancePeer.h \ - nsIPluginInstancePeer2.h \ - nsIPluginManager.h \ - nsIPluginManager2.h \ - nsIPluginStream.h \ - nsIPluginStreamPeer.h \ - nsIPluginStreamPeer2.h \ - nsIPluginTagInfo.h \ - nsIPluginTagInfo2.h \ - nsISeekablePluginStreamPeer.h \ - nsIWindowlessPluginInstancePeer.h \ - nsplugin.h \ +EXPORTS = \ + nsIEventHandler.h \ + nsIFileUtilities.h \ + nsIJRILiveConnectPlugin.h \ + nsIJRILiveConnectPlugInstPeer.h \ + nsILiveConnectPlugin.h \ + nsILiveConnectPlugInstPeer.h \ + nsINetworkManager.h \ + nsIPlugin.h \ + nsIPluginInstance.h \ + nsIPluginInstancePeer.h \ + nsIPluginManager.h \ + nsIPluginManager2.h \ + nsIPluginStream.h \ + nsIPluginStreamPeer.h \ + nsIPluginStreamPeer2.h \ + nsIPluginTagInfo.h \ + nsIPluginTagInfo2.h \ + nsISeekablePluginStreamPeer.h \ + nsIWindowlessPlugInstPeer.h \ + nsplugin.h \ nsplugindefs.h include $(DEPTH)/config/rules.mk diff --git a/modules/plugin/base/public/makefile.win b/modules/plugin/base/public/makefile.win index 4dae17aff4da..3bda15a285ed 100644 --- a/modules/plugin/base/public/makefile.win +++ b/modules/plugin/base/public/makefile.win @@ -22,15 +22,16 @@ DEPTH = ..\..\.. MODULE = plugin EXPORTS = \ + nsIEventHandler.h \ nsIFileUtilities.h \ nsIJRILiveConnectPlugin.h \ - nsIJRILiveConnectPluginInstancePeer.h \ + nsIJRILiveConnectPlugInstPeer.h \ nsILiveConnectPlugin.h \ - nsILiveConnectPluginInstancePeer.h \ + nsILiveConnectPlugInstPeer.h \ + nsINetworkManager.h \ nsIPlugin.h \ nsIPluginInstance.h \ nsIPluginInstancePeer.h \ - nsIPluginInstancePeer2.h \ nsIPluginManager.h \ nsIPluginManager2.h \ nsIPluginStream.h \ @@ -39,7 +40,7 @@ EXPORTS = \ nsIPluginTagInfo.h \ nsIPluginTagInfo2.h \ nsISeekablePluginStreamPeer.h \ - nsIWindowlessPluginInstancePeer.h \ + nsIWindowlessPlugInstPeer.h \ nsplugin.h \ nsplugindefs.h diff --git a/modules/plugin/base/public/npapi.h b/modules/plugin/base/public/npapi.h index 208b089cd7a5..98a741acb8b5 100644 --- a/modules/plugin/base/public/npapi.h +++ b/modules/plugin/base/public/npapi.h @@ -18,7 +18,7 @@ /* - * npapi.h $Revision: 3.2 $ + * npapi.h $Revision: 3.3 $ * Netscape client plug-in API spec */ @@ -133,22 +133,29 @@ RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" } #ifndef _UINT16 typedef unsigned short uint16; #endif + #ifndef _UINT32 -#if defined(__alpha) +# ifndef NSPR20 +# if defined(__alpha) typedef unsigned int uint32; -#else /* __alpha */ +# else /* __alpha */ typedef unsigned long uint32; -#endif /* __alpha */ +# endif /* __alpha */ +# endif /* NSPR20 */ #endif + #ifndef _INT16 typedef short int16; #endif + #ifndef _INT32 -#if defined(__alpha) +# ifndef NSPR20 +# if defined(__alpha) typedef int int32; -#else /* __alpha */ +# else /* __alpha */ typedef long int32; -#endif /* __alpha */ +# endif /* __alpha */ +# endif /* NSPR20 */ #endif #ifndef FALSE @@ -513,11 +520,11 @@ void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint); int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event); void NP_LOADDS NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData); -jref NP_LOADDS NPP_GetJavaClass(void); -NPError NP_LOADDS NPP_GetValue(void *instance, NPPVariable variable, - void *value); -NPError NP_LOADDS NPP_SetValue(void *instance, NPNVariable variable, - void *value); +jref NP_LOADDS NPP_GetJavaClass(void); +NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, + void *value); +NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, + void *value); /* * NPN_* functions are provided by the navigator and called by the plugin. diff --git a/modules/plugin/base/public/nsIFileUtilities.h b/modules/plugin/base/public/nsIFileUtilities.h index 880435d4d9f9..82eeb525b215 100644 --- a/modules/plugin/base/public/nsIFileUtilities.h +++ b/modules/plugin/base/public/nsIFileUtilities.h @@ -35,30 +35,47 @@ #define nsIFileUtilities_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // File Utilities Interface // This interface reflects operations only available in Communicator 5.0. +/** + * The nsIFileUtilities interface provides access to random file operations. + * To obtain: QueryInterface on nsIPluginManager. + */ class nsIFileUtilities : public nsISupports { public: - - // QueryInterface on nsIPluginManager to get this. - NS_IMETHOD_(const char*) - GetProgramPath(void) = 0; + /** + * Returns the name of the browser executable program. + * + * @param result - the returned path to the program + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetProgramPath(const char* *result) = 0; - NS_IMETHOD_(const char*) - GetTempDirPath(void) = 0; + /** + * Returns the name of the temporary directory. + * + * @param result - the returned path to the temp directory + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetTempDirPath(const char* *result) = 0; - enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME }; - - NS_IMETHOD_(nsresult) - GetFileName(const char* fn, FileNameType type, - char* resultBuf, PRUint32 bufLen) = 0; - - NS_IMETHOD_(nsresult) - NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0; + /** + * Returns a unique temporary file name. + * + * @param prefix - a string to prefix to the temporary file name + * @param bufLen - the length of the resultBuf to receive the data + * @param resultBuf - the returned temp file name + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + NewTempFileName(const char* prefix, PRUint32 bufLen, char* resultBuf) = 0; }; diff --git a/modules/plugin/base/public/nsIJRILiveConnectPlugin.h b/modules/plugin/base/public/nsIJRILiveConnectPlugin.h index bc2382ced4b1..14ca7dcf9d2c 100644 --- a/modules/plugin/base/public/nsIJRILiveConnectPlugin.h +++ b/modules/plugin/base/public/nsIJRILiveConnectPlugin.h @@ -34,7 +34,7 @@ #ifndef nsIJRILiveConnectPlugin_h__ #define nsIJRILiveConnectPlugin_h__ -#include "nsplugindefs.h" +#include "nsIPlugin.h" //////////////////////////////////////////////////////////////////////////////// // JRI-Based LiveConnect Classes @@ -47,20 +47,31 @@ // Warning: Don't use this anymore, unless you're sure that you have to! //////////////////////////////////////////////////////////////////////////////// -#include "jri.h" // ancient - -//////////////////////////////////////////////////////////////////////////////// -// JRILiveConnect Plugin Interface -// This interface defines additional entry points that a plugin developer needs -// to implement in order for the plugin to support JRI-based LiveConnect, -// i.e. be scriptable by Java or JavaScript. +#include "jri.h" +/** + * The nsIJRILiveConnectPlugin interface defines additional entry points that a + * plugin developer needs to implement in order for the plugin to support + * JRI-based LiveConnect, as opposed to the standard JNI-based LiveConnect + * (which new in 5.0). + * + * Plugin developers requiring this capability should implement this interface + * in addition to the basic nsIPlugin interface. + */ class nsIJRILiveConnectPlugin : public nsIPlugin { public: - // (Corresponds to NPP_GetJavaClass.) - NS_IMETHOD_(jref) - GetJavaClass(void) = 0; + /** + * Returns the class of the Java instance to be associated with the + * plugin. + * + * (Corresponds to NPP_GetJavaClass.) + * + * @param resultingClass - a resulting reference to the Java class + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetJavaClass(jref *resultingClass) = 0; }; diff --git a/modules/plugin/base/public/nsILiveConnectPlugin.h b/modules/plugin/base/public/nsILiveConnectPlugin.h index 31753271bcd3..e35ffafc42b0 100644 --- a/modules/plugin/base/public/nsILiveConnectPlugin.h +++ b/modules/plugin/base/public/nsILiveConnectPlugin.h @@ -34,21 +34,31 @@ #ifndef nsILiveConnectPlugin_h__ #define nsILiveConnectPlugin_h__ -#include "nsplugindefs.h" +#include "nsIPlugin.h" #include "jni.h" // standard JVM API -//////////////////////////////////////////////////////////////////////////////// -// LiveConnect Plugin Interface -// This interface defines additional entry points that a plugin developer needs -// to implement in order for the plugin to support JNI-based LiveConnect, -// i.e. be scriptable by Java or JavaScript. - +/** + * The nsILiveConnectPlugin interface defines additional entry points that a + * plugin developer needs to implement in order for the plugin to support + * JNI-based LiveConnect (new in 5.0). + * + * Plugin developers requiring this capability should implement this interface + * in addition to the basic nsIPlugin interface. + */ class nsILiveConnectPlugin : public nsIPlugin { public: - // (New JNI-based entry point, roughly corresponds to NPP_GetJavaClass.) - NS_IMETHOD_(jclass) - GetJavaClass(void) = 0; + /** + * Returns the class of the Java instance to be associated with the + * plugin. + * + * (New JNI-based entry point, roughly corresponds to NPP_GetJavaClass.) + * + * @param resultingClass - a resulting reference to the Java class + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetJavaClass(jclass *resultingClass) = 0; }; diff --git a/modules/plugin/base/public/nsIPlugin.h b/modules/plugin/base/public/nsIPlugin.h index 8512a5815346..53db089d7b7d 100644 --- a/modules/plugin/base/public/nsIPlugin.h +++ b/modules/plugin/base/public/nsIPlugin.h @@ -37,51 +37,88 @@ #include "nsplugindefs.h" #include "nsIFactory.h" -//////////////////////////////////////////////////////////////////////////////// -// Plugin Interface -// This is the minimum interface plugin developers need to support in order to -// implement a plugin. The plugin manager may QueryInterface for more specific -// plugin types, e.g. nsILiveConnectPlugin. - +/** + * The nsIPlugin interface is the minimum interface plugin developers need to + * support in order to implement a plugin. The plugin manager may QueryInterface + * for more specific plugin types, e.g. nsILiveConnectPlugin. + * + * The old NPP_New plugin operation is now subsumed by two operations: + * + * CreateInstance -- called once, after the plugin instance is created. This + * method is used to initialize the new plugin instance (although the actual + * plugin instance object will be created by the plugin manager). + * + * nsIPluginInstance::Start -- called when the plugin instance is to be + * started. This happens in two circumstances: (1) after the plugin instance + * is first initialized, and (2) after a plugin instance is returned to + * (e.g. by going back in the window history) after previously being stopped + * by the Stop method. + */ struct nsIPlugin : public nsIFactory { public: - // This call initializes the plugin and will be called before any new - // instances are created. It is passed browserInterfaces on which QueryInterface - // may be used to obtain an nsIPluginManager, and other interfaces. - NS_IMETHOD_(nsPluginError) + /** + * Initializes the plugin and will be called before any new instances are + * created. It is passed browserInterfaces on which QueryInterface + * may be used to obtain an nsIPluginManager, and other interfaces. + * + * @param browserInterfaces - an object that allows access to other browser + * interfaces via QueryInterface + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Initialize(nsISupports* browserInterfaces) = 0; - // (Corresponds to NPP_Shutdown.) - // Called when the browser is done with the plugin factory, or when - // the plugin is disabled by the user. - NS_IMETHOD_(nsPluginError) + /** + * Called when the browser is done with the plugin factory, or when + * the plugin is disabled by the user. + * + * (Corresponds to NPP_Shutdown.) + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Shutdown(void) = 0; - // (Corresponds to NPP_GetMIMEDescription.) - NS_IMETHOD_(const char*) - GetMIMEDescription(void) = 0; + /** + * Returns the MIME description for the plugin. The MIME description + * is a colon-separated string containg the plugin MIME type, plugin + * data file extension, and plugin name, e.g.: + * + * "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in" + * + * (Corresponds to NPP_GetMIMEDescription.) + * + * @param resultingDesc - the resulting MIME description + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetMIMEDescription(const char* *resultingDesc) = 0; - // (Corresponds to NPP_GetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Returns the value of a variable associated with the plugin. + * + * (Corresponds to NPP_GetValue.) + * + * @param variable - the plugin variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD GetValue(nsPluginVariable variable, void *value) = 0; - // (Corresponds to NPP_SetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Sets the value of a variable associated with the plugin. + * + * (Corresponds to NPP_SetValue.) + * + * @param variable - the plugin variable to get + * @param value - the address of the value to store + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD SetValue(nsPluginVariable variable, void *value) = 0; - // The old NPP_New call has been factored into two plugin instance methods: - // - // CreateInstance -- called once, after the plugin instance is created. This - // method is used to initialize the new plugin instance (although the actual - // plugin instance object will be created by the plugin manager). - // - // nsIPluginInstance::Start -- called when the plugin instance is to be - // started. This happens in two circumstances: (1) after the plugin instance - // is first initialized, and (2) after a plugin instance is returned to - // (e.g. by going back in the window history) after previously being stopped - // by the Stop method. - }; #define NS_IPLUGIN_IID \ diff --git a/modules/plugin/base/public/nsIPluginInstance.h b/modules/plugin/base/public/nsIPluginInstance.h index 29825c92f138..d277af536afb 100644 --- a/modules/plugin/base/public/nsIPluginInstance.h +++ b/modules/plugin/base/public/nsIPluginInstance.h @@ -35,64 +35,135 @@ #define nsIPluginInstance_h___ #include "nsplugindefs.h" +#include "nsIEventHandler.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Instance Interface -// (Corresponds to NPP object.) -class nsIPluginInstance : public nsISupports { +/** + * The nsIPluginInstance interface is the minimum interface plugin developers + * need to support in order to implement a plugin instance. The plugin manager + * may QueryInterface for more specific types, e.g. nsILiveConnectPluginInstance. + * + * (Corresponds to NPP object.) + * + * The old NPP_Destroy call has been factored into two plugin instance + * methods: + * + * Stop -- called when the plugin instance is to be stopped (e.g. by + * displaying another plugin manager window, causing the page containing + * the plugin to become removed from the display). + * + * Destroy -- called once, before the plugin instance peer is to be + * destroyed. This method is used to destroy the plugin instance. + */ +class nsIPluginInstance : public nsIEventHandler { public: - NS_IMETHOD_(nsPluginError) + /** + * Initializes a newly created plugin instance, passing to it the plugin + * instance peer which it should use for all communication back to the browser. + * + * @param peer - the corresponding plugin instance peer + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Initialize(nsIPluginInstancePeer* peer) = 0; - // Required backpointer to the peer. - NS_IMETHOD_(nsIPluginInstancePeer*) - GetPeer(void) = 0; + /** + * Returns a reference back to the plugin instance peer. This method is + * used whenever the browser needs to obtain the peer back from a plugin + * instance. The implementation of this method should be sure to increment + * the reference count on the peer by calling AddRef. + * + * @param resultingPeer - the resulting plugin instance peer + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetPeer(nsIPluginInstancePeer* *resultingPeer) = 0; - // See comment for nsIPlugin::CreateInstance, above. - NS_IMETHOD_(nsPluginError) + /** + * Called to instruct the plugin instance to start. This will be called after + * the plugin is first created and initialized, and may be called after the + * plugin is stopped (via the Stop method) if the plugin instance is returned + * to in the browser window's history. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Start(void) = 0; - // The old NPP_Destroy call has been factored into two plugin instance - // methods: - // - // Stop -- called when the plugin instance is to be stopped (e.g. by - // displaying another plugin manager window, causing the page containing - // the plugin to become removed from the display). - // - // Release -- called once, before the plugin instance peer is to be - // destroyed. This method is used to destroy the plugin instance. - - NS_IMETHOD_(nsPluginError) + /** + * Called to instruct the plugin instance to stop, thereby suspending its state. + * This method will be called whenever the browser window goes on to display + * another page and the page containing the plugin goes into the window's history + * list. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Stop(void) = 0; - NS_IMETHOD_(nsPluginError) + /** + * Called to instruct the plugin instance to destroy itself. This is called when + * it become no longer possible to return to the plugin instance, either because + * the browser window's history list of pages is being trimmed, or because the + * window containing this page in the history is being closed. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Destroy(void) = 0; - // (Corresponds to NPP_SetWindow.) - NS_IMETHOD_(nsPluginError) + /** + * Called when the window containing the plugin instance changes. + * + * (Corresponds to NPP_SetWindow.) + * + * @param window - the plugin window structure + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD SetWindow(nsPluginWindow* window) = 0; - // (Corresponds to NPP_NewStream.) - NS_IMETHOD_(nsPluginError) + /** + * Called when a new plugin stream must be constructed in order for the plugin + * instance to receive a stream of data from the browser. + * + * (Corresponds to NPP_NewStream.) + * + * @param peer - the plugin stream peer, representing information about the + * incoming stream, and stream-specific callbacks into the browser + * @param result - the resulting plugin stream + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0; - // (Corresponds to NPP_Print.) - NS_IMETHOD_(void) + /** + * Called to instruct the plugin instance to print itself to a printer. + * + * (Corresponds to NPP_Print.) + * + * @param platformPrint - platform-specific printing information + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Print(nsPluginPrint* platformPrint) = 0; - // (Corresponds to NPP_HandleEvent.) - // Note that for Unix and Mac the nsPluginEvent structure is different - // from the old NPEvent structure -- it's no longer the native event - // record, but is instead a struct. This was done for future extensibility, - // and so that the Mac could receive the window argument too. For Windows - // and OS2, it's always been a struct, so there's no change for them. - NS_IMETHOD_(PRInt16) - HandleEvent(nsPluginEvent* event) = 0; - - // (Corresponds to NPP_URLNotify.) - NS_IMETHOD_(void) + /** + * Called to notify the plugin instance that a URL request has been + * completed. (See nsIPluginManager::GetURL and nsIPluginManager::PostURL). + * + * (Corresponds to NPP_URLNotify.) + * + * @param url - the requested URL + * @param target - the target window name + * @param reason - the reason for completion + * @param notifyData - the notify data supplied to GetURL or PostURL + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData) = 0; diff --git a/modules/plugin/base/public/nsIPluginInstancePeer.h b/modules/plugin/base/public/nsIPluginInstancePeer.h index 98229dee428e..05d29933a8bf 100644 --- a/modules/plugin/base/public/nsIPluginInstancePeer.h +++ b/modules/plugin/base/public/nsIPluginInstancePeer.h @@ -35,34 +35,98 @@ #define nsIPluginInstancePeer_h___ #include "nsplugindefs.h" +#include "nsISupports.h" + +class nsIOutputStream; //////////////////////////////////////////////////////////////////////////////// // Plugin Instance Peer Interface -enum nsPluginTagType { - nsPluginTagType_Unknown, - nsPluginTagType_Embed, - nsPluginTagType_Object, - nsPluginTagType_Applet -}; - +/** + * The nsIPluginInstancePeer interface is the set of operations implemented + * by the browser to support a plugin instance. When a plugin instance is + * constructed, a nsIPluginInstancePeer is passed to its initializer + * representing the instantiation of the plugin on the page. + * + * Other interfaces may be obtained from nsIPluginInstancePeer by calling + * QueryInterface, e.g. nsIPluginTagInfo. + */ class nsIPluginInstancePeer : public nsISupports { public: - // (Corresponds to NPP_New's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void) = 0; + /** + * Returns the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_GetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - // (Corresponds to NPP_New's mode argument.) - NS_IMETHOD_(nsPluginType) - GetMode(void) = 0; + /** + * Sets the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_SetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of the value to store + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + SetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - // (Corresponds to NPN_NewStream.) - NS_IMETHOD_(nsPluginError) + /** + * Returns the MIME type of the plugin instance. + * + * (Corresponds to NPP_New's MIMEType argument.) + * + * @param result - resulting MIME type + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetMIMEType(nsMIMEType *result) = 0; + + /** + * Returns the mode of the plugin instance, i.e. whether the plugin is + * embedded in the html, or full page. + * + * (Corresponds to NPP_New's mode argument.) + * + * @param result - the resulting mode + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetMode(nsPluginMode *result) = 0; + + /** + * This operation is called by the plugin instance when it wishes to send + * a stream of data to the browser. It constructs a new output stream to which + * the plugin may send the data. When complete, the Close and Release methods + * should be called on the output stream. + * + * (Corresponds to NPN_NewStream.) + * + * @param type - type MIME type of the stream to create + * @param target - the target window name to receive the data + * @param result - the resulting output stream + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) = 0; - // (Corresponds to NPN_Status.) - NS_IMETHOD_(void) + /** + * This operation causes status information to be displayed on the window + * associated with the plugin instance. + * + * (Corresponds to NPN_Status.) + * + * @param message - the status message to display + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD ShowStatus(const char* message) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginManager.h b/modules/plugin/base/public/nsIPluginManager.h index dffd0376f75d..fe5df70e314d 100644 --- a/modules/plugin/base/public/nsIPluginManager.h +++ b/modules/plugin/base/public/nsIPluginManager.h @@ -35,83 +35,64 @@ #define nsIPluginManager_h___ #include "nsplugindefs.h" +#include "nsISupports.h" -//////////////////////////////////////////////////////////////////////////////// -// Plugin Manager Interface -// This interface defines the minimum set of functionality that a plugin -// manager will support if it implements plugins. Plugin implementations can -// QueryInterface to determine if a plugin manager implements more specific -// APIs for the plugin to use. - +/** + * The nsIPluginManager interface defines the minimum set of functionality that + * the browser will support if it allows plugins. Plugins can call QueryInterface + * to determine if a plugin manager implements more specific APIs or other + * browser interfaces for the plugin to use (e.g. nsINetworkManager). + */ class nsIPluginManager : public nsISupports { public: - // (Corresponds to NPN_ReloadPlugins.) - NS_IMETHOD_(void) - ReloadPlugins(PRBool reloadPages) = 0; - - // (Corresponds to NPN_MemAlloc.) - NS_IMETHOD_(void*) - MemAlloc(PRUint32 size) = 0; - - // (Corresponds to NPN_MemFree.) - NS_IMETHOD_(void) - MemFree(void* ptr) = 0; - - // (Corresponds to NPN_MemFlush.) - NS_IMETHOD_(PRUint32) - MemFlush(PRUint32 size) = 0; - - // (Corresponds to NPN_UserAgent.) - NS_IMETHOD_(const char*) - UserAgent(void) = 0; - - // (Corresponds to NPN_GetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Returns the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_GetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value) = 0; - // (Corresponds to NPN_SetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Sets the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_SetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of the value to store + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD SetValue(nsPluginManagerVariable variable, void *value) = 0; + /** + * Causes the plugins directory to be searched again for new plugin + * libraries. + * + * (Corresponds to NPN_ReloadPlugins.) + * + * @param reloadPages - indicates whether currently visible pages should + * also be reloaded + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + ReloadPlugins(PRBool reloadPages) = 0; - // (Corresponds to NPN_GetURL and NPN_GetURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - NS_IMETHOD_(nsPluginError) - GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE) = 0; - - // (Corresponds to NPN_PostURL and NPN_PostURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - // postHeaders: A string containing post headers. - // postHeadersLength: The length of the post headers string. - NS_IMETHOD_(nsPluginError) - PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE, - PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0; + /** + * Returns the user agent string for the browser. + * + * (Corresponds to NPN_UserAgent.) + * + * @param resultingAgentString - the resulting user agent string + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + UserAgent(const char* *resultingAgentString) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginManager2.h b/modules/plugin/base/public/nsIPluginManager2.h index 2ac771339e99..316a67ab2f29 100644 --- a/modules/plugin/base/public/nsIPluginManager2.h +++ b/modules/plugin/base/public/nsIPluginManager2.h @@ -34,7 +34,7 @@ #ifndef nsIPluginManager2_h___ #define nsIPluginManager2_h___ -#include "nsplugindefs.h" +#include "nsIPluginManager.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Manager 2 Interface @@ -43,14 +43,118 @@ class nsIPluginManager2 : public nsIPluginManager { public: - NS_IMETHOD_(void) + /** + * Puts up a wait cursor. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD BeginWaitCursor(void) = 0; - NS_IMETHOD_(void) + /** + * Restores the previous (non-wait) cursor. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD EndWaitCursor(void) = 0; - NS_IMETHOD_(PRBool) - SupportsURLProtocol(const char* protocol) = 0; + /** + * Returns true if a URL protocol (e.g. "http") is supported. + * + * @param protocol - the protocol name + * @param result - true if the protocol is supported + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + SupportsURLProtocol(const char* protocol, PRBool *result) = 0; + + /** + * This method may be called by the plugin to indicate that an error + * has occurred, e.g. that the plugin has failed or is shutting down + * spontaneously. This allows the browser to clean up any plugin-specific + * state. + * + * @param plugin - the plugin whose status is changing + * @param errorStatus - the the error status value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + NotifyStatusChange(nsIPlugin* plugin, nsresult errorStatus) = 0; + + //////////////////////////////////////////////////////////////////////////// + // New top-level window handling calls for Mac: + + /** + * Registers a top-level window with the browser. Events received by that + * window will be dispatched to the event handler specified. + * + * @param handler - the event handler for the window + * @param window - the platform window reference + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + RegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) = 0; + + /** + * Unregisters a top-level window with the browser. The handler and window pair + * should be the same as that specified to RegisterWindow. + * + * @param handler - the event handler for the window + * @param window - the platform window reference + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + UnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) = 0; + + /** + * Allocates a new menu ID (for the Mac). + * + * @param handler - the event handler for the window + * @param isSubmenu - whether this is a sub-menu ID or not + * @param result - the resulting menu ID + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + AllocateMenuID(nsIEventHandler* handler, PRBool isSubmenu, PRInt16 *result) = 0; + + /** + * Deallocates a menu ID (for the Mac). + * + * @param handler - the event handler for the window + * @param menuID - the menu ID + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + DeallocateMenuID(nsIEventHandler* handler, PRInt16 menuID) = 0; + + /** + * Indicates whether this event handler has allocated the given menu ID. + * + * @param handler - the event handler for the window + * @param menuID - the menu ID + * @param result - returns PR_TRUE if the menu ID is allocated + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result) = 0; + + /** + * This operation causes the next browser event to be processed. This is + * handy for implement nested event loops where some other activity must + * be performed each time around the loop. + * + * On the Mac (and most likely on Win16), network activity can only occur on + * the main thread. Therefore, we provide a hook here for the case that the + * main thread needs to process events while waiting for network activity to + * complete. + * + * @param bEventHandled - a boolean indicating whether an event was processed on the + * main thread. If not on the main browser thread, PR_FALSE is returned. + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + ProcessNextEvent(PRBool *bEventHandled) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginStream.h b/modules/plugin/base/public/nsIPluginStream.h index e3f9b2c7e13f..4389b6280daf 100644 --- a/modules/plugin/base/public/nsIPluginStream.h +++ b/modules/plugin/base/public/nsIPluginStream.h @@ -37,18 +37,37 @@ #include "nsplugindefs.h" #include "nsIOutputStream.h" -//////////////////////////////////////////////////////////////////////////////// -// Plugin Stream Interface - +/** + * The nsIPluginStream interface specifies the minimal set of operations that + * must be implemented by a plugin stream in order to receive data from the + * browser. When a nsIPluginManager::FetchURL request is made, a subsequent + * nsIPluginInstance::NewStream request will be made to instruct the plugin + * instance to construct a new stream to receive the data. + */ class nsIPluginStream : public nsIOutputStream { public: - // (Corresponds to NPP_NewStream's stype return parameter.) - NS_IMETHOD_(NPStreamType) - GetStreamType(void) = 0; + /** + * Returns the stream type of a stream. + * + * (Corresponds to NPP_NewStream's stype return parameter.) + * + * @param result - the resulting stream type + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetStreamType(nsPluginStreamType *result) = 0; - // (Corresponds to NPP_StreamAsFile.) - NS_IMETHOD_(void) + /** + * This operation passes to the plugin the name of the file which + * contains the stream data. + * + * (Corresponds to NPP_StreamAsFile.) + * + * @param fname - the file name + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD AsFile(const char* fname) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginStreamPeer.h b/modules/plugin/base/public/nsIPluginStreamPeer.h index da46281e8be8..3b9de94d8e06 100644 --- a/modules/plugin/base/public/nsIPluginStreamPeer.h +++ b/modules/plugin/base/public/nsIPluginStreamPeer.h @@ -35,6 +35,7 @@ #define nsIPluginStreamPeer_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Stream Peer Interface @@ -46,28 +47,28 @@ class nsIPluginStreamPeer : public nsISupports { public: // (Corresponds to NPStream's url field.) - NS_IMETHOD_(const char*) - GetURL(void) = 0; + NS_IMETHOD + GetURL(const char* *result) = 0; // (Corresponds to NPStream's end field.) - NS_IMETHOD_(PRUint32) - GetEnd(void) = 0; + NS_IMETHOD + GetEnd(PRUint32 *result) = 0; // (Corresponds to NPStream's lastmodified field.) - NS_IMETHOD_(PRUint32) - GetLastModified(void) = 0; + NS_IMETHOD + GetLastModified(PRUint32 *result) = 0; // (Corresponds to NPStream's notifyData field.) - NS_IMETHOD_(void*) - GetNotifyData(void) = 0; + NS_IMETHOD + GetNotifyData(void* *result) = 0; // (Corresponds to NPP_DestroyStream's reason argument.) - NS_IMETHOD_(nsPluginReason) - GetReason(void) = 0; + NS_IMETHOD + GetReason(nsPluginReason *result) = 0; // (Corresponds to NPP_NewStream's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void) = 0; + NS_IMETHOD + GetMIMEType(nsMIMEType *result) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginStreamPeer2.h b/modules/plugin/base/public/nsIPluginStreamPeer2.h index 30a69a336310..bc686306c3cb 100644 --- a/modules/plugin/base/public/nsIPluginStreamPeer2.h +++ b/modules/plugin/base/public/nsIPluginStreamPeer2.h @@ -34,7 +34,7 @@ #ifndef nsIPluginStreamPeer2_h___ #define nsIPluginStreamPeer2_h___ -#include "nsplugindefs.h" +#include "nsIPluginStreamPeer.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Stream Peer Interface @@ -43,17 +43,17 @@ class nsIPluginStreamPeer2 : public nsIPluginStreamPeer { public: - NS_IMETHOD_(PRUint32) - GetContentLength(void) = 0; + NS_IMETHOD + GetContentLength(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetHeaderFieldCount(void) = 0; + NS_IMETHOD + GetHeaderFieldCount(PRUint32 *result) = 0; - NS_IMETHOD_(const char*) - GetHeaderFieldKey(PRUint32 index) = 0; + NS_IMETHOD + GetHeaderFieldKey(PRUint32 index, const char* *result) = 0; - NS_IMETHOD_(const char*) - GetHeaderField(PRUint32 index) = 0; + NS_IMETHOD + GetHeaderField(PRUint32 index, const char* *result) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginTagInfo.h b/modules/plugin/base/public/nsIPluginTagInfo.h index 3171c135265c..0191481a45b9 100644 --- a/modules/plugin/base/public/nsIPluginTagInfo.h +++ b/modules/plugin/base/public/nsIPluginTagInfo.h @@ -35,6 +35,7 @@ #define nsIPluginTagInfo_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Tag Info Interface @@ -51,13 +52,20 @@ public: // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values) = 0; - // Get the value for the named attribute. Returns NULL - // if the attribute was not set. - NS_IMETHOD_(const char*) - GetAttribute(const char* name) = 0; + /** + * Gets the value for the named attribute. + * + * @param name - the name of the attribute to find + * @param result - the resulting attribute + * @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if + * this operation failed. result is set to NULL if the attribute is not found + * else to the found value. + */ + NS_IMETHOD + GetAttribute(const char* name, const char* *result) = 0; }; diff --git a/modules/plugin/base/public/nsIPluginTagInfo2.h b/modules/plugin/base/public/nsIPluginTagInfo2.h index f023e58b7c12..a3c8e80ecdca 100644 --- a/modules/plugin/base/public/nsIPluginTagInfo2.h +++ b/modules/plugin/base/public/nsIPluginTagInfo2.h @@ -34,12 +34,19 @@ #ifndef nsIPluginTagInfo2_h___ #define nsIPluginTagInfo2_h___ -#include "nsplugindefs.h" +#include "nsIPluginTagInfo.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Tag Info Interface // These extensions to nsIPluginTagInfo are only available in Communicator 5.0. +enum nsPluginTagType { + nsPluginTagType_Unknown, + nsPluginTagType_Embed, + nsPluginTagType_Object, + nsPluginTagType_Applet +}; + class nsIPluginTagInfo2 : public nsIPluginTagInfo { public: @@ -47,53 +54,56 @@ public: // Get the type of the HTML tag that was used ot instantiate this // plugin. Currently supported tags are EMBED, OBJECT and APPLET. - NS_IMETHOD_(nsPluginTagType) - GetTagType(void) = 0; + NS_IMETHOD + GetTagType(nsPluginTagType *result) = 0; // Get the complete text of the HTML tag that was // used to instantiate this plugin - NS_IMETHOD_(const char *) - GetTagText(void) = 0; + NS_IMETHOD + GetTagText(const char* *result) = 0; // Get a ptr to the paired list of parameter names and values, // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetParameters(PRUint16& n, const char*const*& names, const char*const*& values) = 0; // Get the value for the named parameter. Returns null // if the parameter was not set. - NS_IMETHOD_(const char*) - GetParameter(const char* name) = 0; + // @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if + // this operation failed. result is set to NULL if the attribute is not found + // else to the found value. + NS_IMETHOD + GetParameter(const char* name, const char* *result) = 0; - NS_IMETHOD_(const char*) - GetDocumentBase(void) = 0; + NS_IMETHOD + GetDocumentBase(const char* *result) = 0; // Return an encoding whose name is specified in: // http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303 - NS_IMETHOD_(const char*) - GetDocumentEncoding(void) = 0; + NS_IMETHOD + GetDocumentEncoding(const char* *result) = 0; - NS_IMETHOD_(const char*) - GetAlignment(void) = 0; + NS_IMETHOD + GetAlignment(const char* *result) = 0; - NS_IMETHOD_(PRUint32) - GetWidth(void) = 0; + NS_IMETHOD + GetWidth(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetHeight(void) = 0; + NS_IMETHOD + GetHeight(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetBorderVertSpace(void) = 0; + NS_IMETHOD + GetBorderVertSpace(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetBorderHorizSpace(void) = 0; + NS_IMETHOD + GetBorderHorizSpace(PRUint32 *result) = 0; // Returns a unique id for the current document on which the // plugin is displayed. - NS_IMETHOD_(PRUint32) - GetUniqueID(void) = 0; + NS_IMETHOD + GetUniqueID(PRUint32 *result) = 0; }; diff --git a/modules/plugin/base/public/nsISeekablePluginStreamPeer.h b/modules/plugin/base/public/nsISeekablePluginStreamPeer.h index dcfd07f7519e..85b2ced1bfb7 100644 --- a/modules/plugin/base/public/nsISeekablePluginStreamPeer.h +++ b/modules/plugin/base/public/nsISeekablePluginStreamPeer.h @@ -35,6 +35,7 @@ #define nsISeekablePluginStreamPeer_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // Seekable Plugin Stream Peer Interface @@ -49,7 +50,7 @@ public: // seekable argument. // (Corresponds to NPN_RequestRead.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD RequestRead(nsByteRange* rangeList) = 0; }; diff --git a/modules/plugin/base/public/nsplugin.h b/modules/plugin/base/public/nsplugin.h index 47417bec7c4b..b6bf84bee33f 100644 --- a/modules/plugin/base/public/nsplugin.h +++ b/modules/plugin/base/public/nsplugin.h @@ -70,6 +70,7 @@ * +---------------------+ * | nsIPluginManager | * | nsIPluginManager2 | + * | nsINetworkManager | * | nsIFileUtilities | * | nsIPref | * | nsICacheManager ... | @@ -139,6 +140,12 @@ */ #include "nsIPluginManager.h" +/** + * The network manager provides access to the network for URL get + * and post operations. + */ +#include "nsINetworkManager.h" + /** * A plugin instance peer gets created by the browser and associated with each * plugin instance to represent tag information and other callbacks needed by @@ -160,11 +167,7 @@ * * To obtain: QueryInterface on nsIPluginInstancePeer */ -#ifdef XP_MAC -/*#include "nsIWindowlessPlugInstPeer.h"*/ -#else -#include "nsIWindowlessPluginInstancePeer.h" -#endif +#include "nsIWindowlessPlugInstPeer.h" /** * A plugin stream peer gets create by the browser and associated with each @@ -203,14 +206,6 @@ */ #include "nsIFileUtilities.h" -/** - * The nsIPluginInstancePeer2 interface provides additional plugin instance - * peer features only available in Communicator 5.0. - * - * To obtain: QueryInterface on nsIPluginInstancePeer - */ -#include "nsIPluginInstancePeer2.h" - /** * The nsILiveConnectPluginInstancePeer allows plugins to be manipulated * by JavaScript, providing basic scriptability. @@ -220,11 +215,7 @@ * * To obtain: QueryInterface on nsIPluginInstancePeer */ -#ifdef XP_MAC -/*#include "nsILiveConnectPlugInstPeer.h"*/ -#else -#include "nsILiveConnectPluginInstancePeer.h" -#endif +#include "nsILiveConnectPlugInstPeer.h" /** * The nsIPluginStreamPeer2 interface provides additional plugin stream diff --git a/modules/plugin/base/public/nsplugindefs.h b/modules/plugin/base/public/nsplugindefs.h index 3d2e45d9b07d..c06bf04c35f7 100644 --- a/modules/plugin/base/public/nsplugindefs.h +++ b/modules/plugin/base/public/nsplugindefs.h @@ -34,22 +34,27 @@ #ifndef nsplugindefs_h___ #define nsplugindefs_h___ +#ifndef prtypes_h___ +#include "prtypes.h" +#endif + #ifdef __OS2__ #pragma pack(1) #endif #ifdef XP_MAC - #include - #include +# include +# include +# include #endif #ifdef XP_UNIX - #include - #include +# include +# include #endif #ifdef XP_PC - #include +# include #endif //////////////////////////////////////////////////////////////////////////////// @@ -116,7 +121,7 @@ struct nsByteRange { struct nsByteRange* next; }; -struct nsRect { +struct nsPluginRect { PRUint16 top; PRUint16 left; PRUint16 bottom; @@ -161,47 +166,44 @@ struct nsPluginPrintCallbackStruct { //////////////////////////////////////////////////////////////////////////////// -// List of variable names for which NPP_GetValue shall be implemented +// List of variables which should be implmented by the plugin enum nsPluginVariable { - nsPluginVariable_NameString = 1, - nsPluginVariable_DescriptionString, - nsPluginVariable_WindowBool, // XXX go away - nsPluginVariable_TransparentBool, // XXX go away? - nsPluginVariable_JavaClass, // XXX go away - nsPluginVariable_WindowSize, - nsPluginVariable_TimerInterval - // XXX add MIMEDescription (for unix) (but GetValue is on the instance, not the class) + nsPluginVariable_NameString = 1, + nsPluginVariable_DescriptionString = 2 }; -// List of variable names for which NPN_GetValue is implemented by Mozilla +// List of variables which are implemented by the browser enum nsPluginManagerVariable { - nsPluginManagerVariable_XDisplay = 1, - nsPluginManagerVariable_XtAppContext, - nsPluginManagerVariable_NetscapeWindow, - nsPluginManagerVariable_JavascriptEnabledBool, // XXX prefs accessor api - nsPluginManagerVariable_ASDEnabledBool, // XXX prefs accessor api - nsPluginManagerVariable_IsOfflineBool // XXX prefs accessor api + nsPluginManagerVariable_XDisplay = 1, + nsPluginManagerVariable_XtAppContext = 2, + nsPluginManagerVariable_NetscapeWindow = 3 +}; + +enum nsPluginInstancePeerVariable { + nsPluginInstancePeerVariable_WindowBool = 3, + nsPluginInstancePeerVariable_TransparentBool = 4, + nsPluginInstancePeerVariable_JavaClass = 5, + nsPluginInstancePeerVariable_WindowSize = 6, + nsPluginInstancePeerVariable_TimerInterval = 7 }; //////////////////////////////////////////////////////////////////////////////// -enum nsPluginType { - nsPluginType_Embedded = 1, - nsPluginType_Full +enum nsPluginMode { + nsPluginMode_Embedded = 1, + nsPluginMode_Full }; // XXX this can go away now -enum NPStreamType { - NPStreamType_Normal = 1, - NPStreamType_Seek, - NPStreamType_AsFile, - NPStreamType_AsFileOnly +enum nsPluginStreamType { + nsPluginStreamType_Normal = 1, + nsPluginStreamType_Seek, + nsPluginStreamType_AsFile, + nsPluginStreamType_AsFileOnly }; -#define NP_STREAM_MAXREADY (((unsigned)(~0)<<1)>>1) - /* - * The type of a NPWindow - it specifies the type of the data structure + * The type of a nsPluginWindow - it specifies the type of the data structure * returned in the window field. */ enum nsPluginWindowType { @@ -209,18 +211,48 @@ enum nsPluginWindowType { nsPluginWindowType_Drawable }; +#ifdef XP_MAC + +struct nsPluginPort { + CGrafPtr port; /* Grafport */ + PRInt32 portx; /* position inside the topmost window */ + PRInt32 porty; +}; +typedef RgnHandle nsPluginRegion; +typedef WindowRef nsPluginPlatformWindowRef; + +#elif defined(XP_PC) + +struct nsPluginPort; +typedef HRGN nsPluginRegion; +typedef HWND nsPluginPlatformWindowRef; + +#elif defined(XP_UNIX) + +struct nsPluginPort; +typedef Region nsPluginRegion; +typedef Drawable nsPluginPlatformWindowRef; + +#else + +struct nsPluginPort; +typedef void* nsPluginRegion; +typedef void* nsPluginPlatformWindowRef; + +#endif + struct nsPluginWindow { - void* window; /* Platform specific window handle */ + nsPluginPort* window; /* Platform specific window handle */ /* OS/2: x - Position of bottom left corner */ /* OS/2: y - relative to visible netscape window */ - PRUint32 x; /* Position of top left corner relative */ - PRUint32 y; /* to a netscape page. */ - PRUint32 width; /* Maximum window size */ - PRUint32 height; - nsRect clipRect; /* Clipping rectangle in port coordinates */ + PRUint32 x; /* Position of top left corner relative */ + PRUint32 y; /* to a netscape page. */ + PRUint32 width; /* Maximum window size */ + PRUint32 height; + nsPluginRect clipRect; /* Clipping rectangle in port coordinates */ /* Used by MAC only. */ #ifdef XP_UNIX - void* ws_info; /* Platform-dependent additonal data */ + void* ws_info; /* Platform-dependent additonal data */ #endif /* XP_UNIX */ nsPluginWindowType type; /* Is this a window or a drawable? */ }; @@ -235,23 +267,23 @@ struct nsPluginFullPrint { struct nsPluginEmbedPrint { nsPluginWindow window; - void* platformPrint; /* Platform-specific printing info */ + void* platformPrint; /* Platform-specific printing info */ }; struct nsPluginPrint { - nsPluginType mode; /* NP_FULL or nsPluginType_Embedded */ + nsPluginMode mode; /* nsPluginMode_Full or nsPluginMode_Embedded */ union { - nsPluginFullPrint fullPrint; /* if mode is NP_FULL */ - nsPluginEmbedPrint embedPrint; /* if mode is nsPluginType_Embedded */ + nsPluginFullPrint fullPrint; /* if mode is nsPluginMode_Full */ + nsPluginEmbedPrint embedPrint; /* if mode is nsPluginMode_Embedded */ } print; }; struct nsPluginEvent { #if defined(XP_MAC) - EventRecord* event; - void* window; + EventRecord* event; + nsPluginPlatformWindowRef window; #elif defined(XP_PC) uint16 event; @@ -269,59 +301,20 @@ struct nsPluginEvent { #endif }; -#ifdef XP_MAC -typedef RgnHandle nsRegion; -#elif defined(XP_PC) -typedef HRGN nsRegion; -#elif defined(XP_UNIX) -typedef Region nsRegion; -#else -typedef void *nsRegion; -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Mac-specific structures and definitions. - -#ifdef XP_MAC - -struct NPPort { - CGrafPtr port; /* Grafport */ - PRInt32 portx; /* position inside the topmost window */ - PRInt32 porty; -}; - /* * Non-standard event types that can be passed to HandleEvent */ -#define getFocusEvent (osEvt + 16) -#define loseFocusEvent (osEvt + 17) -#define adjustCursorEvent (osEvt + 18) -#define menuCommandEvent (osEvt + 19) - +enum nsPluginEventType { +#ifdef XP_MAC + nsPluginEventType_GetFocusEvent = (osEvt + 16), + nsPluginEventType_LoseFocusEvent = (osEvt + 17), + nsPluginEventType_AdjustCursorEvent = (osEvt + 18), + nsPluginEventType_MenuCommandEvent = (osEvt + 19), #endif /* XP_MAC */ - -//////////////////////////////////////////////////////////////////////////////// -// Error and Reason Code definitions - -enum nsPluginError { - nsPluginError_Base = 0, - nsPluginError_NoError = 0, - nsPluginError_GenericError, - nsPluginError_InvalidInstanceError, - nsPluginError_InvalidFunctableError, - nsPluginError_ModuleLoadFailedError, - nsPluginError_OutOfMemoryError, - nsPluginError_InvalidPluginError, - nsPluginError_InvalidPluginDirError, - nsPluginError_IncompatibleVersionError, - nsPluginError_InvalidParam, - nsPluginError_InvalidUrl, - nsPluginError_FileNotFound, - nsPluginError_NoData, - nsPluginError_StreamNotSeekable + nsPluginEventType_Idle = 0 }; -#define NPCallFailed( code ) ((code) != nsPluginError_NoError) +//////////////////////////////////////////////////////////////////////////////// enum nsPluginReason { nsPluginReason_Base = 0, @@ -331,6 +324,21 @@ enum nsPluginReason { nsPluginReason_NoReason }; +//////////////////////////////////////////////////////////////////////////////// +// Version Numbers for Structs + +// These version number are for structures whose fields may evolve over time. +// When fields are added to the end of the struct, the minor version will be +// incremented. When the struct changes in an incompatible way the major version +// will be incremented. + +#define nsMajorVersion(v) (((PRInt32)(v) >> 16) & 0xffff) +#define nsMinorVersion(v) ((PRInt32)(v) & 0xffff) + +#define nsVersionOK(suppliedV, requiredV) \ + (nsMajorVersion(suppliedV) == nsMajorVersion(requiredV) \ + && nsMinorVersion(suppliedV) >= nsMinorVersion(requiredV)) + //////////////////////////////////////////////////////////////////////////////// // Classes //////////////////////////////////////////////////////////////////////////////// @@ -338,6 +346,7 @@ enum nsPluginReason { // Classes that must be implemented by the plugin DLL: struct nsIPlugin; // plugin class (MIME-type handler) class nsILiveConnectPlugin; // subclass of nsIPlugin +class nsIEventHandler; // event handler interface class nsIPluginInstance; // plugin instance class nsIPluginStream; // stream to receive data from the browser diff --git a/modules/plugin/makefile.win b/modules/plugin/makefile.win index b4dccf752740..0ce7083249c2 100644 --- a/modules/plugin/makefile.win +++ b/modules/plugin/makefile.win @@ -20,8 +20,11 @@ DEPTH=..\.. #// DIRS - There are subdirectories to process #// #//------------------------------------------------------------------------ +!if !defined(NGLAYOUT_PLUGINS) DIRS= public src - +!else +DIRS= public nglsrc +!endif #//------------------------------------------------------------------------ #// #// Include the common makefile rules diff --git a/modules/plugin/public/MANIFEST b/modules/plugin/public/MANIFEST index 1a731f872da5..6088c3869c81 100644 --- a/modules/plugin/public/MANIFEST +++ b/modules/plugin/public/MANIFEST @@ -19,17 +19,15 @@ # This is a list of local files which get copied to the mozilla:dist directory # +nsIEventHandler.h nsIFileUtilities.h nsIJRILiveConnectPlugin.h -#//nsIJRILiveConnectPluginInstancePeer.h nsIJRILiveConnectPlugInstPeer.h nsILiveConnectPlugin.h -#//nsILiveConnectPluginInstancePeer.h nsILiveConnectPlugInstPeer.h nsIPlugin.h nsIPluginInstance.h nsIPluginInstancePeer.h -nsIPluginInstancePeer2.h nsIPluginManager.h nsIPluginManager2.h nsIPluginStream.h @@ -38,7 +36,7 @@ nsIPluginStreamPeer2.h nsIPluginTagInfo.h nsIPluginTagInfo2.h nsISeekablePluginStreamPeer.h -#//nsIWindowlessPluginInstancePeer.h nsIWindowlessPlugInstPeer.h nsplugin.h nsplugindefs.h +nsINetworkManager.h diff --git a/modules/plugin/public/Makefile b/modules/plugin/public/Makefile index f87022e6ebad..e3099394456c 100644 --- a/modules/plugin/public/Makefile +++ b/modules/plugin/public/Makefile @@ -19,26 +19,27 @@ DEPTH = ../../.. MODULE = plugin -EXPORTS = \ - nsIFileUtilities.h \ - nsIJRILiveConnectPlugin.h \ - nsIJRILiveConnectPluginInstancePeer.h \ - nsILiveConnectPlugin.h \ - nsILiveConnectPluginInstancePeer.h \ - nsIPlugin.h \ - nsIPluginInstance.h \ - nsIPluginInstancePeer.h \ - nsIPluginInstancePeer2.h \ - nsIPluginManager.h \ - nsIPluginManager2.h \ - nsIPluginStream.h \ - nsIPluginStreamPeer.h \ - nsIPluginStreamPeer2.h \ - nsIPluginTagInfo.h \ - nsIPluginTagInfo2.h \ - nsISeekablePluginStreamPeer.h \ - nsIWindowlessPluginInstancePeer.h \ - nsplugin.h \ +EXPORTS = \ + nsIEventHandler.h \ + nsIFileUtilities.h \ + nsIJRILiveConnectPlugin.h \ + nsIJRILiveConnectPlugInstPeer.h \ + nsILiveConnectPlugin.h \ + nsILiveConnectPlugInstPeer.h \ + nsINetworkManager.h \ + nsIPlugin.h \ + nsIPluginInstance.h \ + nsIPluginInstancePeer.h \ + nsIPluginManager.h \ + nsIPluginManager2.h \ + nsIPluginStream.h \ + nsIPluginStreamPeer.h \ + nsIPluginStreamPeer2.h \ + nsIPluginTagInfo.h \ + nsIPluginTagInfo2.h \ + nsISeekablePluginStreamPeer.h \ + nsIWindowlessPlugInstPeer.h \ + nsplugin.h \ nsplugindefs.h include $(DEPTH)/config/rules.mk diff --git a/modules/plugin/public/makefile.win b/modules/plugin/public/makefile.win index 4dae17aff4da..3bda15a285ed 100644 --- a/modules/plugin/public/makefile.win +++ b/modules/plugin/public/makefile.win @@ -22,15 +22,16 @@ DEPTH = ..\..\.. MODULE = plugin EXPORTS = \ + nsIEventHandler.h \ nsIFileUtilities.h \ nsIJRILiveConnectPlugin.h \ - nsIJRILiveConnectPluginInstancePeer.h \ + nsIJRILiveConnectPlugInstPeer.h \ nsILiveConnectPlugin.h \ - nsILiveConnectPluginInstancePeer.h \ + nsILiveConnectPlugInstPeer.h \ + nsINetworkManager.h \ nsIPlugin.h \ nsIPluginInstance.h \ nsIPluginInstancePeer.h \ - nsIPluginInstancePeer2.h \ nsIPluginManager.h \ nsIPluginManager2.h \ nsIPluginStream.h \ @@ -39,7 +40,7 @@ EXPORTS = \ nsIPluginTagInfo.h \ nsIPluginTagInfo2.h \ nsISeekablePluginStreamPeer.h \ - nsIWindowlessPluginInstancePeer.h \ + nsIWindowlessPlugInstPeer.h \ nsplugin.h \ nsplugindefs.h diff --git a/modules/plugin/public/nsIFileUtilities.h b/modules/plugin/public/nsIFileUtilities.h index 880435d4d9f9..82eeb525b215 100644 --- a/modules/plugin/public/nsIFileUtilities.h +++ b/modules/plugin/public/nsIFileUtilities.h @@ -35,30 +35,47 @@ #define nsIFileUtilities_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // File Utilities Interface // This interface reflects operations only available in Communicator 5.0. +/** + * The nsIFileUtilities interface provides access to random file operations. + * To obtain: QueryInterface on nsIPluginManager. + */ class nsIFileUtilities : public nsISupports { public: - - // QueryInterface on nsIPluginManager to get this. - NS_IMETHOD_(const char*) - GetProgramPath(void) = 0; + /** + * Returns the name of the browser executable program. + * + * @param result - the returned path to the program + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetProgramPath(const char* *result) = 0; - NS_IMETHOD_(const char*) - GetTempDirPath(void) = 0; + /** + * Returns the name of the temporary directory. + * + * @param result - the returned path to the temp directory + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetTempDirPath(const char* *result) = 0; - enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME }; - - NS_IMETHOD_(nsresult) - GetFileName(const char* fn, FileNameType type, - char* resultBuf, PRUint32 bufLen) = 0; - - NS_IMETHOD_(nsresult) - NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0; + /** + * Returns a unique temporary file name. + * + * @param prefix - a string to prefix to the temporary file name + * @param bufLen - the length of the resultBuf to receive the data + * @param resultBuf - the returned temp file name + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + NewTempFileName(const char* prefix, PRUint32 bufLen, char* resultBuf) = 0; }; diff --git a/modules/plugin/public/nsIJRILiveConnectPlugin.h b/modules/plugin/public/nsIJRILiveConnectPlugin.h index bc2382ced4b1..14ca7dcf9d2c 100644 --- a/modules/plugin/public/nsIJRILiveConnectPlugin.h +++ b/modules/plugin/public/nsIJRILiveConnectPlugin.h @@ -34,7 +34,7 @@ #ifndef nsIJRILiveConnectPlugin_h__ #define nsIJRILiveConnectPlugin_h__ -#include "nsplugindefs.h" +#include "nsIPlugin.h" //////////////////////////////////////////////////////////////////////////////// // JRI-Based LiveConnect Classes @@ -47,20 +47,31 @@ // Warning: Don't use this anymore, unless you're sure that you have to! //////////////////////////////////////////////////////////////////////////////// -#include "jri.h" // ancient - -//////////////////////////////////////////////////////////////////////////////// -// JRILiveConnect Plugin Interface -// This interface defines additional entry points that a plugin developer needs -// to implement in order for the plugin to support JRI-based LiveConnect, -// i.e. be scriptable by Java or JavaScript. +#include "jri.h" +/** + * The nsIJRILiveConnectPlugin interface defines additional entry points that a + * plugin developer needs to implement in order for the plugin to support + * JRI-based LiveConnect, as opposed to the standard JNI-based LiveConnect + * (which new in 5.0). + * + * Plugin developers requiring this capability should implement this interface + * in addition to the basic nsIPlugin interface. + */ class nsIJRILiveConnectPlugin : public nsIPlugin { public: - // (Corresponds to NPP_GetJavaClass.) - NS_IMETHOD_(jref) - GetJavaClass(void) = 0; + /** + * Returns the class of the Java instance to be associated with the + * plugin. + * + * (Corresponds to NPP_GetJavaClass.) + * + * @param resultingClass - a resulting reference to the Java class + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetJavaClass(jref *resultingClass) = 0; }; diff --git a/modules/plugin/public/nsILiveConnectPlugin.h b/modules/plugin/public/nsILiveConnectPlugin.h index 31753271bcd3..e35ffafc42b0 100644 --- a/modules/plugin/public/nsILiveConnectPlugin.h +++ b/modules/plugin/public/nsILiveConnectPlugin.h @@ -34,21 +34,31 @@ #ifndef nsILiveConnectPlugin_h__ #define nsILiveConnectPlugin_h__ -#include "nsplugindefs.h" +#include "nsIPlugin.h" #include "jni.h" // standard JVM API -//////////////////////////////////////////////////////////////////////////////// -// LiveConnect Plugin Interface -// This interface defines additional entry points that a plugin developer needs -// to implement in order for the plugin to support JNI-based LiveConnect, -// i.e. be scriptable by Java or JavaScript. - +/** + * The nsILiveConnectPlugin interface defines additional entry points that a + * plugin developer needs to implement in order for the plugin to support + * JNI-based LiveConnect (new in 5.0). + * + * Plugin developers requiring this capability should implement this interface + * in addition to the basic nsIPlugin interface. + */ class nsILiveConnectPlugin : public nsIPlugin { public: - // (New JNI-based entry point, roughly corresponds to NPP_GetJavaClass.) - NS_IMETHOD_(jclass) - GetJavaClass(void) = 0; + /** + * Returns the class of the Java instance to be associated with the + * plugin. + * + * (New JNI-based entry point, roughly corresponds to NPP_GetJavaClass.) + * + * @param resultingClass - a resulting reference to the Java class + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetJavaClass(jclass *resultingClass) = 0; }; diff --git a/modules/plugin/public/nsIPlugin.h b/modules/plugin/public/nsIPlugin.h index 8512a5815346..53db089d7b7d 100644 --- a/modules/plugin/public/nsIPlugin.h +++ b/modules/plugin/public/nsIPlugin.h @@ -37,51 +37,88 @@ #include "nsplugindefs.h" #include "nsIFactory.h" -//////////////////////////////////////////////////////////////////////////////// -// Plugin Interface -// This is the minimum interface plugin developers need to support in order to -// implement a plugin. The plugin manager may QueryInterface for more specific -// plugin types, e.g. nsILiveConnectPlugin. - +/** + * The nsIPlugin interface is the minimum interface plugin developers need to + * support in order to implement a plugin. The plugin manager may QueryInterface + * for more specific plugin types, e.g. nsILiveConnectPlugin. + * + * The old NPP_New plugin operation is now subsumed by two operations: + * + * CreateInstance -- called once, after the plugin instance is created. This + * method is used to initialize the new plugin instance (although the actual + * plugin instance object will be created by the plugin manager). + * + * nsIPluginInstance::Start -- called when the plugin instance is to be + * started. This happens in two circumstances: (1) after the plugin instance + * is first initialized, and (2) after a plugin instance is returned to + * (e.g. by going back in the window history) after previously being stopped + * by the Stop method. + */ struct nsIPlugin : public nsIFactory { public: - // This call initializes the plugin and will be called before any new - // instances are created. It is passed browserInterfaces on which QueryInterface - // may be used to obtain an nsIPluginManager, and other interfaces. - NS_IMETHOD_(nsPluginError) + /** + * Initializes the plugin and will be called before any new instances are + * created. It is passed browserInterfaces on which QueryInterface + * may be used to obtain an nsIPluginManager, and other interfaces. + * + * @param browserInterfaces - an object that allows access to other browser + * interfaces via QueryInterface + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Initialize(nsISupports* browserInterfaces) = 0; - // (Corresponds to NPP_Shutdown.) - // Called when the browser is done with the plugin factory, or when - // the plugin is disabled by the user. - NS_IMETHOD_(nsPluginError) + /** + * Called when the browser is done with the plugin factory, or when + * the plugin is disabled by the user. + * + * (Corresponds to NPP_Shutdown.) + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Shutdown(void) = 0; - // (Corresponds to NPP_GetMIMEDescription.) - NS_IMETHOD_(const char*) - GetMIMEDescription(void) = 0; + /** + * Returns the MIME description for the plugin. The MIME description + * is a colon-separated string containg the plugin MIME type, plugin + * data file extension, and plugin name, e.g.: + * + * "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in" + * + * (Corresponds to NPP_GetMIMEDescription.) + * + * @param resultingDesc - the resulting MIME description + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetMIMEDescription(const char* *resultingDesc) = 0; - // (Corresponds to NPP_GetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Returns the value of a variable associated with the plugin. + * + * (Corresponds to NPP_GetValue.) + * + * @param variable - the plugin variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD GetValue(nsPluginVariable variable, void *value) = 0; - // (Corresponds to NPP_SetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Sets the value of a variable associated with the plugin. + * + * (Corresponds to NPP_SetValue.) + * + * @param variable - the plugin variable to get + * @param value - the address of the value to store + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD SetValue(nsPluginVariable variable, void *value) = 0; - // The old NPP_New call has been factored into two plugin instance methods: - // - // CreateInstance -- called once, after the plugin instance is created. This - // method is used to initialize the new plugin instance (although the actual - // plugin instance object will be created by the plugin manager). - // - // nsIPluginInstance::Start -- called when the plugin instance is to be - // started. This happens in two circumstances: (1) after the plugin instance - // is first initialized, and (2) after a plugin instance is returned to - // (e.g. by going back in the window history) after previously being stopped - // by the Stop method. - }; #define NS_IPLUGIN_IID \ diff --git a/modules/plugin/public/nsIPluginInstance.h b/modules/plugin/public/nsIPluginInstance.h index 29825c92f138..d277af536afb 100644 --- a/modules/plugin/public/nsIPluginInstance.h +++ b/modules/plugin/public/nsIPluginInstance.h @@ -35,64 +35,135 @@ #define nsIPluginInstance_h___ #include "nsplugindefs.h" +#include "nsIEventHandler.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Instance Interface -// (Corresponds to NPP object.) -class nsIPluginInstance : public nsISupports { +/** + * The nsIPluginInstance interface is the minimum interface plugin developers + * need to support in order to implement a plugin instance. The plugin manager + * may QueryInterface for more specific types, e.g. nsILiveConnectPluginInstance. + * + * (Corresponds to NPP object.) + * + * The old NPP_Destroy call has been factored into two plugin instance + * methods: + * + * Stop -- called when the plugin instance is to be stopped (e.g. by + * displaying another plugin manager window, causing the page containing + * the plugin to become removed from the display). + * + * Destroy -- called once, before the plugin instance peer is to be + * destroyed. This method is used to destroy the plugin instance. + */ +class nsIPluginInstance : public nsIEventHandler { public: - NS_IMETHOD_(nsPluginError) + /** + * Initializes a newly created plugin instance, passing to it the plugin + * instance peer which it should use for all communication back to the browser. + * + * @param peer - the corresponding plugin instance peer + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Initialize(nsIPluginInstancePeer* peer) = 0; - // Required backpointer to the peer. - NS_IMETHOD_(nsIPluginInstancePeer*) - GetPeer(void) = 0; + /** + * Returns a reference back to the plugin instance peer. This method is + * used whenever the browser needs to obtain the peer back from a plugin + * instance. The implementation of this method should be sure to increment + * the reference count on the peer by calling AddRef. + * + * @param resultingPeer - the resulting plugin instance peer + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetPeer(nsIPluginInstancePeer* *resultingPeer) = 0; - // See comment for nsIPlugin::CreateInstance, above. - NS_IMETHOD_(nsPluginError) + /** + * Called to instruct the plugin instance to start. This will be called after + * the plugin is first created and initialized, and may be called after the + * plugin is stopped (via the Stop method) if the plugin instance is returned + * to in the browser window's history. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Start(void) = 0; - // The old NPP_Destroy call has been factored into two plugin instance - // methods: - // - // Stop -- called when the plugin instance is to be stopped (e.g. by - // displaying another plugin manager window, causing the page containing - // the plugin to become removed from the display). - // - // Release -- called once, before the plugin instance peer is to be - // destroyed. This method is used to destroy the plugin instance. - - NS_IMETHOD_(nsPluginError) + /** + * Called to instruct the plugin instance to stop, thereby suspending its state. + * This method will be called whenever the browser window goes on to display + * another page and the page containing the plugin goes into the window's history + * list. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Stop(void) = 0; - NS_IMETHOD_(nsPluginError) + /** + * Called to instruct the plugin instance to destroy itself. This is called when + * it become no longer possible to return to the plugin instance, either because + * the browser window's history list of pages is being trimmed, or because the + * window containing this page in the history is being closed. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Destroy(void) = 0; - // (Corresponds to NPP_SetWindow.) - NS_IMETHOD_(nsPluginError) + /** + * Called when the window containing the plugin instance changes. + * + * (Corresponds to NPP_SetWindow.) + * + * @param window - the plugin window structure + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD SetWindow(nsPluginWindow* window) = 0; - // (Corresponds to NPP_NewStream.) - NS_IMETHOD_(nsPluginError) + /** + * Called when a new plugin stream must be constructed in order for the plugin + * instance to receive a stream of data from the browser. + * + * (Corresponds to NPP_NewStream.) + * + * @param peer - the plugin stream peer, representing information about the + * incoming stream, and stream-specific callbacks into the browser + * @param result - the resulting plugin stream + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0; - // (Corresponds to NPP_Print.) - NS_IMETHOD_(void) + /** + * Called to instruct the plugin instance to print itself to a printer. + * + * (Corresponds to NPP_Print.) + * + * @param platformPrint - platform-specific printing information + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD Print(nsPluginPrint* platformPrint) = 0; - // (Corresponds to NPP_HandleEvent.) - // Note that for Unix and Mac the nsPluginEvent structure is different - // from the old NPEvent structure -- it's no longer the native event - // record, but is instead a struct. This was done for future extensibility, - // and so that the Mac could receive the window argument too. For Windows - // and OS2, it's always been a struct, so there's no change for them. - NS_IMETHOD_(PRInt16) - HandleEvent(nsPluginEvent* event) = 0; - - // (Corresponds to NPP_URLNotify.) - NS_IMETHOD_(void) + /** + * Called to notify the plugin instance that a URL request has been + * completed. (See nsIPluginManager::GetURL and nsIPluginManager::PostURL). + * + * (Corresponds to NPP_URLNotify.) + * + * @param url - the requested URL + * @param target - the target window name + * @param reason - the reason for completion + * @param notifyData - the notify data supplied to GetURL or PostURL + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData) = 0; diff --git a/modules/plugin/public/nsIPluginInstancePeer.h b/modules/plugin/public/nsIPluginInstancePeer.h index 98229dee428e..05d29933a8bf 100644 --- a/modules/plugin/public/nsIPluginInstancePeer.h +++ b/modules/plugin/public/nsIPluginInstancePeer.h @@ -35,34 +35,98 @@ #define nsIPluginInstancePeer_h___ #include "nsplugindefs.h" +#include "nsISupports.h" + +class nsIOutputStream; //////////////////////////////////////////////////////////////////////////////// // Plugin Instance Peer Interface -enum nsPluginTagType { - nsPluginTagType_Unknown, - nsPluginTagType_Embed, - nsPluginTagType_Object, - nsPluginTagType_Applet -}; - +/** + * The nsIPluginInstancePeer interface is the set of operations implemented + * by the browser to support a plugin instance. When a plugin instance is + * constructed, a nsIPluginInstancePeer is passed to its initializer + * representing the instantiation of the plugin on the page. + * + * Other interfaces may be obtained from nsIPluginInstancePeer by calling + * QueryInterface, e.g. nsIPluginTagInfo. + */ class nsIPluginInstancePeer : public nsISupports { public: - // (Corresponds to NPP_New's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void) = 0; + /** + * Returns the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_GetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - // (Corresponds to NPP_New's mode argument.) - NS_IMETHOD_(nsPluginType) - GetMode(void) = 0; + /** + * Sets the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_SetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of the value to store + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + SetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - // (Corresponds to NPN_NewStream.) - NS_IMETHOD_(nsPluginError) + /** + * Returns the MIME type of the plugin instance. + * + * (Corresponds to NPP_New's MIMEType argument.) + * + * @param result - resulting MIME type + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetMIMEType(nsMIMEType *result) = 0; + + /** + * Returns the mode of the plugin instance, i.e. whether the plugin is + * embedded in the html, or full page. + * + * (Corresponds to NPP_New's mode argument.) + * + * @param result - the resulting mode + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetMode(nsPluginMode *result) = 0; + + /** + * This operation is called by the plugin instance when it wishes to send + * a stream of data to the browser. It constructs a new output stream to which + * the plugin may send the data. When complete, the Close and Release methods + * should be called on the output stream. + * + * (Corresponds to NPN_NewStream.) + * + * @param type - type MIME type of the stream to create + * @param target - the target window name to receive the data + * @param result - the resulting output stream + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) = 0; - // (Corresponds to NPN_Status.) - NS_IMETHOD_(void) + /** + * This operation causes status information to be displayed on the window + * associated with the plugin instance. + * + * (Corresponds to NPN_Status.) + * + * @param message - the status message to display + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD ShowStatus(const char* message) = 0; }; diff --git a/modules/plugin/public/nsIPluginManager.h b/modules/plugin/public/nsIPluginManager.h index dffd0376f75d..fe5df70e314d 100644 --- a/modules/plugin/public/nsIPluginManager.h +++ b/modules/plugin/public/nsIPluginManager.h @@ -35,83 +35,64 @@ #define nsIPluginManager_h___ #include "nsplugindefs.h" +#include "nsISupports.h" -//////////////////////////////////////////////////////////////////////////////// -// Plugin Manager Interface -// This interface defines the minimum set of functionality that a plugin -// manager will support if it implements plugins. Plugin implementations can -// QueryInterface to determine if a plugin manager implements more specific -// APIs for the plugin to use. - +/** + * The nsIPluginManager interface defines the minimum set of functionality that + * the browser will support if it allows plugins. Plugins can call QueryInterface + * to determine if a plugin manager implements more specific APIs or other + * browser interfaces for the plugin to use (e.g. nsINetworkManager). + */ class nsIPluginManager : public nsISupports { public: - // (Corresponds to NPN_ReloadPlugins.) - NS_IMETHOD_(void) - ReloadPlugins(PRBool reloadPages) = 0; - - // (Corresponds to NPN_MemAlloc.) - NS_IMETHOD_(void*) - MemAlloc(PRUint32 size) = 0; - - // (Corresponds to NPN_MemFree.) - NS_IMETHOD_(void) - MemFree(void* ptr) = 0; - - // (Corresponds to NPN_MemFlush.) - NS_IMETHOD_(PRUint32) - MemFlush(PRUint32 size) = 0; - - // (Corresponds to NPN_UserAgent.) - NS_IMETHOD_(const char*) - UserAgent(void) = 0; - - // (Corresponds to NPN_GetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Returns the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_GetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value) = 0; - // (Corresponds to NPN_SetValue.) - NS_IMETHOD_(nsPluginError) + /** + * Sets the value of a variable associated with the plugin manager. + * + * (Corresponds to NPN_SetValue.) + * + * @param variable - the plugin manager variable to get + * @param value - the address of the value to store + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD SetValue(nsPluginManagerVariable variable, void *value) = 0; + /** + * Causes the plugins directory to be searched again for new plugin + * libraries. + * + * (Corresponds to NPN_ReloadPlugins.) + * + * @param reloadPages - indicates whether currently visible pages should + * also be reloaded + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + ReloadPlugins(PRBool reloadPages) = 0; - // (Corresponds to NPN_GetURL and NPN_GetURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - NS_IMETHOD_(nsPluginError) - GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE) = 0; - - // (Corresponds to NPN_PostURL and NPN_PostURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - // postHeaders: A string containing post headers. - // postHeadersLength: The length of the post headers string. - NS_IMETHOD_(nsPluginError) - PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE, - PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0; + /** + * Returns the user agent string for the browser. + * + * (Corresponds to NPN_UserAgent.) + * + * @param resultingAgentString - the resulting user agent string + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + UserAgent(const char* *resultingAgentString) = 0; }; diff --git a/modules/plugin/public/nsIPluginManager2.h b/modules/plugin/public/nsIPluginManager2.h index 2ac771339e99..316a67ab2f29 100644 --- a/modules/plugin/public/nsIPluginManager2.h +++ b/modules/plugin/public/nsIPluginManager2.h @@ -34,7 +34,7 @@ #ifndef nsIPluginManager2_h___ #define nsIPluginManager2_h___ -#include "nsplugindefs.h" +#include "nsIPluginManager.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Manager 2 Interface @@ -43,14 +43,118 @@ class nsIPluginManager2 : public nsIPluginManager { public: - NS_IMETHOD_(void) + /** + * Puts up a wait cursor. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD BeginWaitCursor(void) = 0; - NS_IMETHOD_(void) + /** + * Restores the previous (non-wait) cursor. + * + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD EndWaitCursor(void) = 0; - NS_IMETHOD_(PRBool) - SupportsURLProtocol(const char* protocol) = 0; + /** + * Returns true if a URL protocol (e.g. "http") is supported. + * + * @param protocol - the protocol name + * @param result - true if the protocol is supported + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + SupportsURLProtocol(const char* protocol, PRBool *result) = 0; + + /** + * This method may be called by the plugin to indicate that an error + * has occurred, e.g. that the plugin has failed or is shutting down + * spontaneously. This allows the browser to clean up any plugin-specific + * state. + * + * @param plugin - the plugin whose status is changing + * @param errorStatus - the the error status value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + NotifyStatusChange(nsIPlugin* plugin, nsresult errorStatus) = 0; + + //////////////////////////////////////////////////////////////////////////// + // New top-level window handling calls for Mac: + + /** + * Registers a top-level window with the browser. Events received by that + * window will be dispatched to the event handler specified. + * + * @param handler - the event handler for the window + * @param window - the platform window reference + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + RegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) = 0; + + /** + * Unregisters a top-level window with the browser. The handler and window pair + * should be the same as that specified to RegisterWindow. + * + * @param handler - the event handler for the window + * @param window - the platform window reference + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + UnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) = 0; + + /** + * Allocates a new menu ID (for the Mac). + * + * @param handler - the event handler for the window + * @param isSubmenu - whether this is a sub-menu ID or not + * @param result - the resulting menu ID + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + AllocateMenuID(nsIEventHandler* handler, PRBool isSubmenu, PRInt16 *result) = 0; + + /** + * Deallocates a menu ID (for the Mac). + * + * @param handler - the event handler for the window + * @param menuID - the menu ID + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + DeallocateMenuID(nsIEventHandler* handler, PRInt16 menuID) = 0; + + /** + * Indicates whether this event handler has allocated the given menu ID. + * + * @param handler - the event handler for the window + * @param menuID - the menu ID + * @param result - returns PR_TRUE if the menu ID is allocated + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result) = 0; + + /** + * This operation causes the next browser event to be processed. This is + * handy for implement nested event loops where some other activity must + * be performed each time around the loop. + * + * On the Mac (and most likely on Win16), network activity can only occur on + * the main thread. Therefore, we provide a hook here for the case that the + * main thread needs to process events while waiting for network activity to + * complete. + * + * @param bEventHandled - a boolean indicating whether an event was processed on the + * main thread. If not on the main browser thread, PR_FALSE is returned. + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + ProcessNextEvent(PRBool *bEventHandled) = 0; }; diff --git a/modules/plugin/public/nsIPluginStream.h b/modules/plugin/public/nsIPluginStream.h index e3f9b2c7e13f..4389b6280daf 100644 --- a/modules/plugin/public/nsIPluginStream.h +++ b/modules/plugin/public/nsIPluginStream.h @@ -37,18 +37,37 @@ #include "nsplugindefs.h" #include "nsIOutputStream.h" -//////////////////////////////////////////////////////////////////////////////// -// Plugin Stream Interface - +/** + * The nsIPluginStream interface specifies the minimal set of operations that + * must be implemented by a plugin stream in order to receive data from the + * browser. When a nsIPluginManager::FetchURL request is made, a subsequent + * nsIPluginInstance::NewStream request will be made to instruct the plugin + * instance to construct a new stream to receive the data. + */ class nsIPluginStream : public nsIOutputStream { public: - // (Corresponds to NPP_NewStream's stype return parameter.) - NS_IMETHOD_(NPStreamType) - GetStreamType(void) = 0; + /** + * Returns the stream type of a stream. + * + * (Corresponds to NPP_NewStream's stype return parameter.) + * + * @param result - the resulting stream type + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetStreamType(nsPluginStreamType *result) = 0; - // (Corresponds to NPP_StreamAsFile.) - NS_IMETHOD_(void) + /** + * This operation passes to the plugin the name of the file which + * contains the stream data. + * + * (Corresponds to NPP_StreamAsFile.) + * + * @param fname - the file name + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD AsFile(const char* fname) = 0; }; diff --git a/modules/plugin/public/nsIPluginStreamPeer.h b/modules/plugin/public/nsIPluginStreamPeer.h index da46281e8be8..3b9de94d8e06 100644 --- a/modules/plugin/public/nsIPluginStreamPeer.h +++ b/modules/plugin/public/nsIPluginStreamPeer.h @@ -35,6 +35,7 @@ #define nsIPluginStreamPeer_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Stream Peer Interface @@ -46,28 +47,28 @@ class nsIPluginStreamPeer : public nsISupports { public: // (Corresponds to NPStream's url field.) - NS_IMETHOD_(const char*) - GetURL(void) = 0; + NS_IMETHOD + GetURL(const char* *result) = 0; // (Corresponds to NPStream's end field.) - NS_IMETHOD_(PRUint32) - GetEnd(void) = 0; + NS_IMETHOD + GetEnd(PRUint32 *result) = 0; // (Corresponds to NPStream's lastmodified field.) - NS_IMETHOD_(PRUint32) - GetLastModified(void) = 0; + NS_IMETHOD + GetLastModified(PRUint32 *result) = 0; // (Corresponds to NPStream's notifyData field.) - NS_IMETHOD_(void*) - GetNotifyData(void) = 0; + NS_IMETHOD + GetNotifyData(void* *result) = 0; // (Corresponds to NPP_DestroyStream's reason argument.) - NS_IMETHOD_(nsPluginReason) - GetReason(void) = 0; + NS_IMETHOD + GetReason(nsPluginReason *result) = 0; // (Corresponds to NPP_NewStream's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void) = 0; + NS_IMETHOD + GetMIMEType(nsMIMEType *result) = 0; }; diff --git a/modules/plugin/public/nsIPluginStreamPeer2.h b/modules/plugin/public/nsIPluginStreamPeer2.h index 30a69a336310..bc686306c3cb 100644 --- a/modules/plugin/public/nsIPluginStreamPeer2.h +++ b/modules/plugin/public/nsIPluginStreamPeer2.h @@ -34,7 +34,7 @@ #ifndef nsIPluginStreamPeer2_h___ #define nsIPluginStreamPeer2_h___ -#include "nsplugindefs.h" +#include "nsIPluginStreamPeer.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Stream Peer Interface @@ -43,17 +43,17 @@ class nsIPluginStreamPeer2 : public nsIPluginStreamPeer { public: - NS_IMETHOD_(PRUint32) - GetContentLength(void) = 0; + NS_IMETHOD + GetContentLength(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetHeaderFieldCount(void) = 0; + NS_IMETHOD + GetHeaderFieldCount(PRUint32 *result) = 0; - NS_IMETHOD_(const char*) - GetHeaderFieldKey(PRUint32 index) = 0; + NS_IMETHOD + GetHeaderFieldKey(PRUint32 index, const char* *result) = 0; - NS_IMETHOD_(const char*) - GetHeaderField(PRUint32 index) = 0; + NS_IMETHOD + GetHeaderField(PRUint32 index, const char* *result) = 0; }; diff --git a/modules/plugin/public/nsIPluginTagInfo.h b/modules/plugin/public/nsIPluginTagInfo.h index 3171c135265c..0191481a45b9 100644 --- a/modules/plugin/public/nsIPluginTagInfo.h +++ b/modules/plugin/public/nsIPluginTagInfo.h @@ -35,6 +35,7 @@ #define nsIPluginTagInfo_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Tag Info Interface @@ -51,13 +52,20 @@ public: // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values) = 0; - // Get the value for the named attribute. Returns NULL - // if the attribute was not set. - NS_IMETHOD_(const char*) - GetAttribute(const char* name) = 0; + /** + * Gets the value for the named attribute. + * + * @param name - the name of the attribute to find + * @param result - the resulting attribute + * @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if + * this operation failed. result is set to NULL if the attribute is not found + * else to the found value. + */ + NS_IMETHOD + GetAttribute(const char* name, const char* *result) = 0; }; diff --git a/modules/plugin/public/nsIPluginTagInfo2.h b/modules/plugin/public/nsIPluginTagInfo2.h index f023e58b7c12..a3c8e80ecdca 100644 --- a/modules/plugin/public/nsIPluginTagInfo2.h +++ b/modules/plugin/public/nsIPluginTagInfo2.h @@ -34,12 +34,19 @@ #ifndef nsIPluginTagInfo2_h___ #define nsIPluginTagInfo2_h___ -#include "nsplugindefs.h" +#include "nsIPluginTagInfo.h" //////////////////////////////////////////////////////////////////////////////// // Plugin Tag Info Interface // These extensions to nsIPluginTagInfo are only available in Communicator 5.0. +enum nsPluginTagType { + nsPluginTagType_Unknown, + nsPluginTagType_Embed, + nsPluginTagType_Object, + nsPluginTagType_Applet +}; + class nsIPluginTagInfo2 : public nsIPluginTagInfo { public: @@ -47,53 +54,56 @@ public: // Get the type of the HTML tag that was used ot instantiate this // plugin. Currently supported tags are EMBED, OBJECT and APPLET. - NS_IMETHOD_(nsPluginTagType) - GetTagType(void) = 0; + NS_IMETHOD + GetTagType(nsPluginTagType *result) = 0; // Get the complete text of the HTML tag that was // used to instantiate this plugin - NS_IMETHOD_(const char *) - GetTagText(void) = 0; + NS_IMETHOD + GetTagText(const char* *result) = 0; // Get a ptr to the paired list of parameter names and values, // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetParameters(PRUint16& n, const char*const*& names, const char*const*& values) = 0; // Get the value for the named parameter. Returns null // if the parameter was not set. - NS_IMETHOD_(const char*) - GetParameter(const char* name) = 0; + // @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if + // this operation failed. result is set to NULL if the attribute is not found + // else to the found value. + NS_IMETHOD + GetParameter(const char* name, const char* *result) = 0; - NS_IMETHOD_(const char*) - GetDocumentBase(void) = 0; + NS_IMETHOD + GetDocumentBase(const char* *result) = 0; // Return an encoding whose name is specified in: // http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303 - NS_IMETHOD_(const char*) - GetDocumentEncoding(void) = 0; + NS_IMETHOD + GetDocumentEncoding(const char* *result) = 0; - NS_IMETHOD_(const char*) - GetAlignment(void) = 0; + NS_IMETHOD + GetAlignment(const char* *result) = 0; - NS_IMETHOD_(PRUint32) - GetWidth(void) = 0; + NS_IMETHOD + GetWidth(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetHeight(void) = 0; + NS_IMETHOD + GetHeight(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetBorderVertSpace(void) = 0; + NS_IMETHOD + GetBorderVertSpace(PRUint32 *result) = 0; - NS_IMETHOD_(PRUint32) - GetBorderHorizSpace(void) = 0; + NS_IMETHOD + GetBorderHorizSpace(PRUint32 *result) = 0; // Returns a unique id for the current document on which the // plugin is displayed. - NS_IMETHOD_(PRUint32) - GetUniqueID(void) = 0; + NS_IMETHOD + GetUniqueID(PRUint32 *result) = 0; }; diff --git a/modules/plugin/public/nsISeekablePluginStreamPeer.h b/modules/plugin/public/nsISeekablePluginStreamPeer.h index dcfd07f7519e..85b2ced1bfb7 100644 --- a/modules/plugin/public/nsISeekablePluginStreamPeer.h +++ b/modules/plugin/public/nsISeekablePluginStreamPeer.h @@ -35,6 +35,7 @@ #define nsISeekablePluginStreamPeer_h___ #include "nsplugindefs.h" +#include "nsISupports.h" //////////////////////////////////////////////////////////////////////////////// // Seekable Plugin Stream Peer Interface @@ -49,7 +50,7 @@ public: // seekable argument. // (Corresponds to NPN_RequestRead.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD RequestRead(nsByteRange* rangeList) = 0; }; diff --git a/modules/plugin/public/nsplugin.h b/modules/plugin/public/nsplugin.h index 47417bec7c4b..b6bf84bee33f 100644 --- a/modules/plugin/public/nsplugin.h +++ b/modules/plugin/public/nsplugin.h @@ -70,6 +70,7 @@ * +---------------------+ * | nsIPluginManager | * | nsIPluginManager2 | + * | nsINetworkManager | * | nsIFileUtilities | * | nsIPref | * | nsICacheManager ... | @@ -139,6 +140,12 @@ */ #include "nsIPluginManager.h" +/** + * The network manager provides access to the network for URL get + * and post operations. + */ +#include "nsINetworkManager.h" + /** * A plugin instance peer gets created by the browser and associated with each * plugin instance to represent tag information and other callbacks needed by @@ -160,11 +167,7 @@ * * To obtain: QueryInterface on nsIPluginInstancePeer */ -#ifdef XP_MAC -/*#include "nsIWindowlessPlugInstPeer.h"*/ -#else -#include "nsIWindowlessPluginInstancePeer.h" -#endif +#include "nsIWindowlessPlugInstPeer.h" /** * A plugin stream peer gets create by the browser and associated with each @@ -203,14 +206,6 @@ */ #include "nsIFileUtilities.h" -/** - * The nsIPluginInstancePeer2 interface provides additional plugin instance - * peer features only available in Communicator 5.0. - * - * To obtain: QueryInterface on nsIPluginInstancePeer - */ -#include "nsIPluginInstancePeer2.h" - /** * The nsILiveConnectPluginInstancePeer allows plugins to be manipulated * by JavaScript, providing basic scriptability. @@ -220,11 +215,7 @@ * * To obtain: QueryInterface on nsIPluginInstancePeer */ -#ifdef XP_MAC -/*#include "nsILiveConnectPlugInstPeer.h"*/ -#else -#include "nsILiveConnectPluginInstancePeer.h" -#endif +#include "nsILiveConnectPlugInstPeer.h" /** * The nsIPluginStreamPeer2 interface provides additional plugin stream diff --git a/modules/plugin/public/nsplugindefs.h b/modules/plugin/public/nsplugindefs.h index 3d2e45d9b07d..c06bf04c35f7 100644 --- a/modules/plugin/public/nsplugindefs.h +++ b/modules/plugin/public/nsplugindefs.h @@ -34,22 +34,27 @@ #ifndef nsplugindefs_h___ #define nsplugindefs_h___ +#ifndef prtypes_h___ +#include "prtypes.h" +#endif + #ifdef __OS2__ #pragma pack(1) #endif #ifdef XP_MAC - #include - #include +# include +# include +# include #endif #ifdef XP_UNIX - #include - #include +# include +# include #endif #ifdef XP_PC - #include +# include #endif //////////////////////////////////////////////////////////////////////////////// @@ -116,7 +121,7 @@ struct nsByteRange { struct nsByteRange* next; }; -struct nsRect { +struct nsPluginRect { PRUint16 top; PRUint16 left; PRUint16 bottom; @@ -161,47 +166,44 @@ struct nsPluginPrintCallbackStruct { //////////////////////////////////////////////////////////////////////////////// -// List of variable names for which NPP_GetValue shall be implemented +// List of variables which should be implmented by the plugin enum nsPluginVariable { - nsPluginVariable_NameString = 1, - nsPluginVariable_DescriptionString, - nsPluginVariable_WindowBool, // XXX go away - nsPluginVariable_TransparentBool, // XXX go away? - nsPluginVariable_JavaClass, // XXX go away - nsPluginVariable_WindowSize, - nsPluginVariable_TimerInterval - // XXX add MIMEDescription (for unix) (but GetValue is on the instance, not the class) + nsPluginVariable_NameString = 1, + nsPluginVariable_DescriptionString = 2 }; -// List of variable names for which NPN_GetValue is implemented by Mozilla +// List of variables which are implemented by the browser enum nsPluginManagerVariable { - nsPluginManagerVariable_XDisplay = 1, - nsPluginManagerVariable_XtAppContext, - nsPluginManagerVariable_NetscapeWindow, - nsPluginManagerVariable_JavascriptEnabledBool, // XXX prefs accessor api - nsPluginManagerVariable_ASDEnabledBool, // XXX prefs accessor api - nsPluginManagerVariable_IsOfflineBool // XXX prefs accessor api + nsPluginManagerVariable_XDisplay = 1, + nsPluginManagerVariable_XtAppContext = 2, + nsPluginManagerVariable_NetscapeWindow = 3 +}; + +enum nsPluginInstancePeerVariable { + nsPluginInstancePeerVariable_WindowBool = 3, + nsPluginInstancePeerVariable_TransparentBool = 4, + nsPluginInstancePeerVariable_JavaClass = 5, + nsPluginInstancePeerVariable_WindowSize = 6, + nsPluginInstancePeerVariable_TimerInterval = 7 }; //////////////////////////////////////////////////////////////////////////////// -enum nsPluginType { - nsPluginType_Embedded = 1, - nsPluginType_Full +enum nsPluginMode { + nsPluginMode_Embedded = 1, + nsPluginMode_Full }; // XXX this can go away now -enum NPStreamType { - NPStreamType_Normal = 1, - NPStreamType_Seek, - NPStreamType_AsFile, - NPStreamType_AsFileOnly +enum nsPluginStreamType { + nsPluginStreamType_Normal = 1, + nsPluginStreamType_Seek, + nsPluginStreamType_AsFile, + nsPluginStreamType_AsFileOnly }; -#define NP_STREAM_MAXREADY (((unsigned)(~0)<<1)>>1) - /* - * The type of a NPWindow - it specifies the type of the data structure + * The type of a nsPluginWindow - it specifies the type of the data structure * returned in the window field. */ enum nsPluginWindowType { @@ -209,18 +211,48 @@ enum nsPluginWindowType { nsPluginWindowType_Drawable }; +#ifdef XP_MAC + +struct nsPluginPort { + CGrafPtr port; /* Grafport */ + PRInt32 portx; /* position inside the topmost window */ + PRInt32 porty; +}; +typedef RgnHandle nsPluginRegion; +typedef WindowRef nsPluginPlatformWindowRef; + +#elif defined(XP_PC) + +struct nsPluginPort; +typedef HRGN nsPluginRegion; +typedef HWND nsPluginPlatformWindowRef; + +#elif defined(XP_UNIX) + +struct nsPluginPort; +typedef Region nsPluginRegion; +typedef Drawable nsPluginPlatformWindowRef; + +#else + +struct nsPluginPort; +typedef void* nsPluginRegion; +typedef void* nsPluginPlatformWindowRef; + +#endif + struct nsPluginWindow { - void* window; /* Platform specific window handle */ + nsPluginPort* window; /* Platform specific window handle */ /* OS/2: x - Position of bottom left corner */ /* OS/2: y - relative to visible netscape window */ - PRUint32 x; /* Position of top left corner relative */ - PRUint32 y; /* to a netscape page. */ - PRUint32 width; /* Maximum window size */ - PRUint32 height; - nsRect clipRect; /* Clipping rectangle in port coordinates */ + PRUint32 x; /* Position of top left corner relative */ + PRUint32 y; /* to a netscape page. */ + PRUint32 width; /* Maximum window size */ + PRUint32 height; + nsPluginRect clipRect; /* Clipping rectangle in port coordinates */ /* Used by MAC only. */ #ifdef XP_UNIX - void* ws_info; /* Platform-dependent additonal data */ + void* ws_info; /* Platform-dependent additonal data */ #endif /* XP_UNIX */ nsPluginWindowType type; /* Is this a window or a drawable? */ }; @@ -235,23 +267,23 @@ struct nsPluginFullPrint { struct nsPluginEmbedPrint { nsPluginWindow window; - void* platformPrint; /* Platform-specific printing info */ + void* platformPrint; /* Platform-specific printing info */ }; struct nsPluginPrint { - nsPluginType mode; /* NP_FULL or nsPluginType_Embedded */ + nsPluginMode mode; /* nsPluginMode_Full or nsPluginMode_Embedded */ union { - nsPluginFullPrint fullPrint; /* if mode is NP_FULL */ - nsPluginEmbedPrint embedPrint; /* if mode is nsPluginType_Embedded */ + nsPluginFullPrint fullPrint; /* if mode is nsPluginMode_Full */ + nsPluginEmbedPrint embedPrint; /* if mode is nsPluginMode_Embedded */ } print; }; struct nsPluginEvent { #if defined(XP_MAC) - EventRecord* event; - void* window; + EventRecord* event; + nsPluginPlatformWindowRef window; #elif defined(XP_PC) uint16 event; @@ -269,59 +301,20 @@ struct nsPluginEvent { #endif }; -#ifdef XP_MAC -typedef RgnHandle nsRegion; -#elif defined(XP_PC) -typedef HRGN nsRegion; -#elif defined(XP_UNIX) -typedef Region nsRegion; -#else -typedef void *nsRegion; -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Mac-specific structures and definitions. - -#ifdef XP_MAC - -struct NPPort { - CGrafPtr port; /* Grafport */ - PRInt32 portx; /* position inside the topmost window */ - PRInt32 porty; -}; - /* * Non-standard event types that can be passed to HandleEvent */ -#define getFocusEvent (osEvt + 16) -#define loseFocusEvent (osEvt + 17) -#define adjustCursorEvent (osEvt + 18) -#define menuCommandEvent (osEvt + 19) - +enum nsPluginEventType { +#ifdef XP_MAC + nsPluginEventType_GetFocusEvent = (osEvt + 16), + nsPluginEventType_LoseFocusEvent = (osEvt + 17), + nsPluginEventType_AdjustCursorEvent = (osEvt + 18), + nsPluginEventType_MenuCommandEvent = (osEvt + 19), #endif /* XP_MAC */ - -//////////////////////////////////////////////////////////////////////////////// -// Error and Reason Code definitions - -enum nsPluginError { - nsPluginError_Base = 0, - nsPluginError_NoError = 0, - nsPluginError_GenericError, - nsPluginError_InvalidInstanceError, - nsPluginError_InvalidFunctableError, - nsPluginError_ModuleLoadFailedError, - nsPluginError_OutOfMemoryError, - nsPluginError_InvalidPluginError, - nsPluginError_InvalidPluginDirError, - nsPluginError_IncompatibleVersionError, - nsPluginError_InvalidParam, - nsPluginError_InvalidUrl, - nsPluginError_FileNotFound, - nsPluginError_NoData, - nsPluginError_StreamNotSeekable + nsPluginEventType_Idle = 0 }; -#define NPCallFailed( code ) ((code) != nsPluginError_NoError) +//////////////////////////////////////////////////////////////////////////////// enum nsPluginReason { nsPluginReason_Base = 0, @@ -331,6 +324,21 @@ enum nsPluginReason { nsPluginReason_NoReason }; +//////////////////////////////////////////////////////////////////////////////// +// Version Numbers for Structs + +// These version number are for structures whose fields may evolve over time. +// When fields are added to the end of the struct, the minor version will be +// incremented. When the struct changes in an incompatible way the major version +// will be incremented. + +#define nsMajorVersion(v) (((PRInt32)(v) >> 16) & 0xffff) +#define nsMinorVersion(v) ((PRInt32)(v) & 0xffff) + +#define nsVersionOK(suppliedV, requiredV) \ + (nsMajorVersion(suppliedV) == nsMajorVersion(requiredV) \ + && nsMinorVersion(suppliedV) >= nsMinorVersion(requiredV)) + //////////////////////////////////////////////////////////////////////////////// // Classes //////////////////////////////////////////////////////////////////////////////// @@ -338,6 +346,7 @@ enum nsPluginReason { // Classes that must be implemented by the plugin DLL: struct nsIPlugin; // plugin class (MIME-type handler) class nsILiveConnectPlugin; // subclass of nsIPlugin +class nsIEventHandler; // event handler interface class nsIPluginInstance; // plugin instance class nsIPluginStream; // stream to receive data from the browser diff --git a/modules/plugin/samples/backward/badapter.cpp b/modules/plugin/samples/backward/badapter.cpp index 9aad2c653909..5519be986ab5 100644 --- a/modules/plugin/samples/backward/badapter.cpp +++ b/modules/plugin/samples/backward/badapter.cpp @@ -42,75 +42,49 @@ extern "C" { // // This is the dummy plugin manager that interacts with the 5.0 plugin. // -class CPluginManager : public nsIPluginManager { +class CPluginManager : public nsIPluginManager, + public nsINetworkManager { public: CPluginManager(void); virtual ~CPluginManager(void); NS_DECL_ISUPPORTS - - NS_IMETHOD_(void) - ReloadPlugins(PRBool reloadPages); - - NS_IMETHOD_(void* ) - MemAlloc(PRUint32 size); - NS_IMETHOD_(void) - MemFree(void* ptr); - - NS_IMETHOD_(PRUint32) - MemFlush(PRUint32 size); + //////////////////////////////////////////////////////////////////////////// + // from nsIPluginManager: // (Corresponds to NPN_GetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value); // (Corresponds to NPN_SetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD SetValue(nsPluginManagerVariable variable, void *value); + + NS_IMETHOD + ReloadPlugins(PRBool reloadPages); // (Corresponds to NPN_UserAgent.) - NS_IMETHOD_(const char*) - UserAgent(void); + NS_IMETHOD + UserAgent(const char* *result); - // (Corresponds to NPN_GetURL and NPN_GetURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - NS_IMETHOD_(nsPluginError) - GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData = NULL, - const char* altHost = NULL, const char* referrer = NULL, - PRBool forceJSEnabled = PR_FALSE); + //////////////////////////////////////////////////////////////////////////// + // from nsINetworkManager: - // (Corresponds to NPN_PostURL and NPN_PostURLNotify.) - // notifyData: When present, URLNotify is called passing the notifyData back - // to the client. When NULL, this call behaves like NPN_GetURL. - // New arguments: - // peer: A plugin instance peer. The peer's window will be used to display - // progress information. If NULL, the load happens in the background. - // altHost: An IP-address string that will be used instead of the host - // specified in the URL. This is used to prevent DNS-spoofing attacks. - // Can be defaulted to NULL meaning use the host in the URL. - // referrer: - // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, - // even if the user currently has JavaScript disabled. - // postHeaders: A string containing post headers. - // postHeadersLength: The length of the post headers string. - NS_IMETHOD_(nsPluginError) - PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData = NULL, + NS_IMETHOD + GetURL(nsISupports* peer, const char* url, const char* target, + void* notifyData = NULL, const char* altHost = NULL, + const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE); + + NS_IMETHOD + PostURL(nsISupports* peer, const char* url, const char* target, + PRUint32 postDataLen, const char* postData, + PRBool isFile = PR_FALSE, void* notifyData = NULL, const char* altHost = NULL, const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE, PRUint32 postHeadersLength = 0, const char* postHeaders = NULL); + }; //////////////////////////////////////////////////////////////////////////////// @@ -133,12 +107,15 @@ public: // Taken from nsIStream // - // The Release function in nsISupport will take care of destroying the stream. - - NS_IMETHOD_(PRInt32) - Write (const char* buffer, PRInt32 offset, PRInt32 len, nsresult* error); - // XXX - Hmm? Why is there an extra parameter offset? - // (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer); + /** Write data into the stream. + * @param aBuf the buffer into which the data is read + * @param aOffset the start offset of the data + * @param aCount the maximum number of bytes to read + * @param errorResult the error code if an error occurs + * @return number of bytes read or -1 if error + */ + NS_IMETHOD + Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aWriteCount); ////////////////////////////////////////////////////////////////////////// // @@ -146,20 +123,20 @@ public: // // Corresponds to NPStream's url field. - NS_IMETHOD_(const char* ) - GetURL(void); + NS_IMETHOD + GetURL(const char* *result); // Corresponds to NPStream's end field. - NS_IMETHOD_(PRUint32) - GetEnd(void); + NS_IMETHOD + GetEnd(PRUint32 *result); // Corresponds to NPStream's lastmodfied field. - NS_IMETHOD_(PRUint32) - GetLastModified(void); + NS_IMETHOD + GetLastModified(PRUint32 *result); // Corresponds to NPStream's notifyData field. - NS_IMETHOD_(void* ) - GetNotifyData(void); + NS_IMETHOD + GetNotifyData(void* *result); // Corresponds to NPStream's url field. NS_IMETHOD Close(void); @@ -190,42 +167,50 @@ public: // XXX - I add parameters to the constructor because I wasn't sure if // XXX - the 4.0 browser had the npp_instance struct implemented. // XXX - If so, then I can access npp_instance through npp->ndata. - CPluginInstancePeer(NPP npp, nsMIMEType typeString, nsPluginType type, + CPluginInstancePeer(NPP npp, nsMIMEType typeString, nsPluginMode type, PRUint16 attribute_cnt, const char** attribute_list, const char** values_list); virtual ~CPluginInstancePeer(void); NS_DECL_ISUPPORTS + // (Corresponds to NPN_GetValue.) + NS_IMETHOD + GetValue(nsPluginInstancePeerVariable variable, void *value); + + // (Corresponds to NPN_SetValue.) + NS_IMETHOD + SetValue(nsPluginInstancePeerVariable variable, void *value); + // Corresponds to NPP_New's MIMEType argument. - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetMIMEType(nsMIMEType *result); // Corresponds to NPP_New's mode argument. - NS_IMETHOD_(nsPluginType) - GetMode(void); + NS_IMETHOD + GetMode(nsPluginMode *result); // Get a ptr to the paired list of attribute names and values, // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values); // Get the value for the named attribute. Returns null // if the attribute was not set. - NS_IMETHOD_(const char*) - GetAttribute(const char* name); + NS_IMETHOD + GetAttribute(const char* name, const char* *result); // Corresponds to NPN_NewStream. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result); // Corresponds to NPN_ShowStatus. - NS_IMETHOD_(void) + NS_IMETHOD ShowStatus(const char* message); // XXX - Where did this go? - NS_IMETHOD_(void) + NS_IMETHOD Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor); @@ -238,7 +223,7 @@ protected: // XXX - The next five variables may need to be here since I // XXX - don't think np_instance is available in 4.0X. nsMIMEType typeString; - nsPluginType type; + nsPluginMode type; PRUint16 attribute_cnt; char** attribute_list; char** values_list; @@ -261,20 +246,20 @@ public: NS_DECL_ISUPPORTS // (Corresponds to NPStream's url field.) - NS_IMETHOD_(const char*) - GetURL(void); + NS_IMETHOD + GetURL(const char* *result); // (Corresponds to NPStream's end field.) - NS_IMETHOD_(PRUint32) - GetEnd(void); + NS_IMETHOD + GetEnd(PRUint32 *result); // (Corresponds to NPStream's lastmodified field.) - NS_IMETHOD_(PRUint32) - GetLastModified(void); + NS_IMETHOD + GetLastModified(PRUint32 *result); // (Corresponds to NPStream's notifyData field.) - NS_IMETHOD_(void*) - GetNotifyData(void); + NS_IMETHOD + GetNotifyData(void* *result); ////////////////////////////////////////////////////////////////////////// // @@ -282,12 +267,12 @@ public: // // Corresponds to NPP_DestroyStream's reason argument. - NS_IMETHOD_(nsPluginReason) - GetReason(void); + NS_IMETHOD + GetReason(nsPluginReason *result); // Corresponds to NPP_NewStream's MIMEType argument. - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetMIMEType(nsMIMEType *result); ////////////////////////////////////////////////////////////////////////// // @@ -295,7 +280,7 @@ public: // // Corresponds to NPN_RequestRead. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD RequestRead(nsByteRange* rangeList); protected: @@ -348,15 +333,33 @@ nsIPlugin* thePlugin = NULL; // Interface IDs for nsISupports // NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -NS_DEFINE_IID(kPluginIID, NS_IPLUGIN_IID); -NS_DEFINE_IID(kPluginInstanceIID, NS_IPLUGININSTANCE_IID); -NS_DEFINE_IID(kPluginManagerIID, NS_IPLUGINMANAGER_IID); -NS_DEFINE_IID(kPluginTagInfoIID, NS_IPLUGINTAGINFO_IID); -NS_DEFINE_IID(kOutputStreamIID, NS_IOUTPUTSTREAM_IID); -NS_DEFINE_IID(kPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); -NS_DEFINE_IID(kPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); -NS_DEFINE_IID(kSeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); +NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID); +NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID); +NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); +NS_DEFINE_IID(kINetworkManagerIID, NS_INETWORKMANAGER_IID); +NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID); +NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID); +NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); +NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); +NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); +// mapping from NPError to nsresult +nsresult fromNPError[] = { + NS_OK, // NPERR_NO_ERROR, + NS_ERROR_FAILURE, // NPERR_GENERIC_ERROR, + NS_ERROR_FAILURE, // NPERR_INVALID_INSTANCE_ERROR, + NS_ERROR_NOT_INITIALIZED, // NPERR_INVALID_FUNCTABLE_ERROR, + NS_ERROR_FACTORY_NOT_LOADED, // NPERR_MODULE_LOAD_FAILED_ERROR, + NS_ERROR_OUT_OF_MEMORY, // NPERR_OUT_OF_MEMORY_ERROR, + NS_NOINTERFACE, // NPERR_INVALID_PLUGIN_ERROR, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PLUGIN_DIR_ERROR, + NS_NOINTERFACE, // NPERR_INCOMPATIBLE_VERSION_ERROR, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PARAM, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_URL, + NS_ERROR_ILLEGAL_VALUE, // NPERR_FILE_NOT_FOUND, + NS_ERROR_FAILURE, // NPERR_NO_DATA, + NS_ERROR_FAILURE // NPERR_STREAM_NOT_SEEKABLE, +}; //////////////////////////////////////////////////////////////////////////////// // SECTION 4 - API Shim Plugin Implementations @@ -378,25 +381,28 @@ NS_DEFINE_IID(kSeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); //////////////////////////////////////////////////////////////////////////////// // UNIX-only API calls //////////////////////////////////////////////////////////////////////////////// + #ifdef XP_UNIX char* NPP_GetMIMEDescription(void) { int freeFac = 0; - fprintf(stderr, "MIME description\n"); + //fprintf(stderr, "MIME description\n"); if (thePlugin == NULL) { - freeFac = 1; - NSGetFactory(kPluginIID, (nsIFactory** )(&thePlugin)); + freeFac = 1; + NSGetFactory(kIPluginIID, (nsIFactory** )(&thePlugin)); } - fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); - char * ret = (char *) thePlugin->GetMIMEDescription(); - fprintf(stderr, "Get response %s\n", ret); + //fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); + const char * ret; + nsresult err = thePlugin->GetMIMEDescription(&ret); + if (err) return NULL; + //fprintf(stderr, "Get response %s\n", ret); if (freeFac) { - fprintf(stderr, "Freeing plugin..."); - thePlugin->Release(); - thePlugin = NULL; + //fprintf(stderr, "Freeing plugin..."); + thePlugin->Release(); + thePlugin = NULL; } - fprintf(stderr, "Done\n"); - return ret; + //fprintf(stderr, "Done\n"); + return (char*)ret; } @@ -407,36 +413,40 @@ char* NPP_GetMIMEDescription(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_SetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { - return (NPError)nsPluginError_NoError; + return NPERR_GENERIC_ERROR; // nothing to set } //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_GetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { int freeFac = 0; - fprintf(stderr, "MIME description\n"); + //fprintf(stderr, "MIME description\n"); if (thePlugin == NULL) { - freeFac = 1; - if (NSGetFactory(kPluginIID, (nsIFactory** )(&thePlugin)) != NS_OK) - return NPERR_GENERIC_ERROR; + freeFac = 1; + if (NSGetFactory(kIPluginIID, (nsIFactory** )(&thePlugin)) != NS_OK) + return NPERR_GENERIC_ERROR; } - fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); - NPError ret = (NPError) thePlugin->GetValue((nsPluginVariable)variable, value); - fprintf(stderr, "Get response %08x\n", ret); + //fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin); + nsresult err = thePlugin->GetValue((nsPluginVariable)variable, value); + if (err) return NPERR_GENERIC_ERROR; + //fprintf(stderr, "Get response %08x\n", ret); if (freeFac) { - fprintf(stderr, "Freeing plugin..."); - thePlugin->Release(); - thePlugin = NULL; + //fprintf(stderr, "Freeing plugin..."); + thePlugin->Release(); + thePlugin = NULL; } - fprintf(stderr, "Done\n"); - return ret; + //fprintf(stderr, "Done\n"); + return NPERR_NO_ERROR; } -#endif +#endif // XP_UNIX + //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_Initialize: // Provides global initialization for a plug-in, and returns an error value. @@ -444,6 +454,7 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { // This function is called once when a plug-in is loaded, before the first instance // is created. thePluginManager and thePlugin are both initialized. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_Initialize(void) { @@ -453,19 +464,19 @@ NPP_Initialize(void) // This could happen if GetJavaClass() is called before // NPP Initialize. if (thePluginManager == NULL) { - // Create the plugin manager and plugin classes. - thePluginManager = new CPluginManager(); - if ( thePluginManager == NULL ) - return NPERR_OUT_OF_MEMORY_ERROR; - thePluginManager->AddRef(); + // Create the plugin manager and plugin classes. + thePluginManager = new CPluginManager(); + if ( thePluginManager == NULL ) + return NPERR_OUT_OF_MEMORY_ERROR; + thePluginManager->AddRef(); } nsresult error = NS_OK; // On UNIX the plugin might have been created when calling NPP_GetMIMEType. if (thePlugin == NULL) - // create nsIPlugin factory - error = (NPError)NSGetFactory(kPluginIID, (nsIFactory**) &thePlugin); + // create nsIPlugin factory + error = (NPError)NSGetFactory(kIPluginIID, (nsIFactory**) &thePlugin); if (error == NS_OK) - thePlugin->Initialize(thePluginManager); + thePlugin->Initialize(thePluginManager); return (NPError) error; } @@ -481,11 +492,12 @@ NPP_Initialize(void) // error will be signalled by "use_" and will cause the Navigator to // complain to the user. //+++++++++++++++++++++++++++++++++++++++++++++++++ + jref NPP_GetJavaClass(void) { // Only call initialize the plugin if it hasn't been `d. - /* if (thePluginManager == NULL) { + /* if (thePluginManager == NULL) { // Create the plugin manager and plugin objects. NPError result = CPluginManager::Create(); if (result) return NULL; @@ -493,8 +505,8 @@ NPP_GetJavaClass(void) thePluginManager->AddRef(); NP_CreatePlugin(thePluginManager, (nsIPlugin** )(&thePlugin)); assert( thePlugin != NULL ); - } -*/ + } + */ // return thePlugin->GetJavaClass(); return NULL; } @@ -506,6 +518,7 @@ NPP_GetJavaClass(void) // This function is called once after the last instance of your plug-in // is destroyed. thePluginManager and thePlugin are delete at this time. //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_Shutdown(void) { @@ -534,6 +547,7 @@ NPP_Shutdown(void) // a successful instansiation, the peer is stored in the plugin // instance's pdata. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_New(NPMIMEType pluginType, NPP instance, @@ -546,13 +560,13 @@ NPP_New(NPMIMEType pluginType, // TRACE("NPP_New\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; // Create a new plugin instance and start it. nsIPluginInstance* pluginInstance = NULL; - thePlugin->CreateInstance(NULL, kPluginInstanceIID, (void**)&pluginInstance); + thePlugin->CreateInstance(NULL, kIPluginInstanceIID, (void**)&pluginInstance); if (pluginInstance == NULL) { - return NPERR_OUT_OF_MEMORY_ERROR; + return NPERR_OUT_OF_MEMORY_ERROR; } // Create a new plugin instance peer, @@ -560,9 +574,9 @@ NPP_New(NPMIMEType pluginType, // XXX - had to save the plugin parameter in the peer class. // XXX - Ask Warren about np_instance. CPluginInstancePeer* peer = - new CPluginInstancePeer(instance, (nsMIMEType)pluginType, - (nsPluginType)mode, (PRUint16)argc, - (const char** )argn, (const char** )argv); + new CPluginInstancePeer(instance, (nsMIMEType)pluginType, + (nsPluginMode)mode, (PRUint16)argc, + (const char** )argn, (const char** )argv); assert( peer != NULL ); if (!peer) return NPERR_OUT_OF_MEMORY_ERROR; peer->AddRef(); @@ -582,13 +596,14 @@ NPP_New(NPMIMEType pluginType, // The plugin instance peer and plugin instance are destroyed. // The instance's pdata is set to NULL. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_Destroy(NPP instance, NPSavedData** save) { // TRACE("NPP_Destroy\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; nsIPluginInstance* pluginInstance = (nsIPluginInstance* )instance->pdata; pluginInstance->Stop(); @@ -603,18 +618,19 @@ NPP_Destroy(NPP instance, NPSavedData** save) // NPP_SetWindow: // Sets the window in which a plug-in draws, and returns an error value. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_SetWindow(NPP instance, NPWindow* window) { // TRACE("NPP_SetWindow\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; nsIPluginInstance* pluginInstance = (nsIPluginInstance* )instance->pdata; if( pluginInstance == 0 ) - return NPERR_INVALID_PLUGIN_ERROR; + return NPERR_INVALID_PLUGIN_ERROR; return (NPError)pluginInstance->SetWindow((nsPluginWindow* ) window ); } @@ -626,6 +642,7 @@ NPP_SetWindow(NPP instance, NPWindow* window) // Create a stream peer and stream. If succesful, save // the stream peer in NPStream's pdata. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_NewStream(NPP instance, NPMIMEType type, @@ -640,23 +657,25 @@ NPP_NewStream(NPP instance, // TRACE("NPP_NewStream\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; // Create a new plugin stream peer and plugin stream. CPluginStreamPeer* speer = new CPluginStreamPeer((nsMIMEType)type, stream, - (PRBool)seekable, stype); + (PRBool)seekable, stype); if (speer == NULL) return NPERR_OUT_OF_MEMORY_ERROR; speer->AddRef(); nsIPluginStream* pluginStream = NULL; nsIPluginInstance* pluginInstance = (nsIPluginInstance*) instance->pdata; - NPError result = (NPError)pluginInstance->NewStream(speer, &pluginStream); + nsresult err = pluginInstance->NewStream(speer, &pluginStream); + if (err) return NPERR_OUT_OF_MEMORY_ERROR; speer->Release(); if (pluginStream == NULL) - return NPERR_OUT_OF_MEMORY_ERROR; + return NPERR_OUT_OF_MEMORY_ERROR; stream->pdata = (void*) pluginStream; - *stype = pluginStream->GetStreamType(); + err = pluginStream->GetStreamType((nsPluginStreamType*)stype); + assert(err == NS_OK); return NPERR_NO_ERROR; } @@ -666,17 +685,18 @@ NPP_NewStream(NPP instance, // Returns the maximum number of bytes that an instance is prepared to accept // from the stream. //+++++++++++++++++++++++++++++++++++++++++++++++++ + int32 NPP_WriteReady(NPP instance, NPStream *stream) { // TRACE("NPP_WriteReady\n"); if (instance == NULL) - return -1; + return -1; nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata; if( theStream == 0 ) - return -1; + return -1; return 8192; } @@ -686,20 +706,22 @@ NPP_WriteReady(NPP instance, NPStream *stream) // NPP_Write: // Delivers data from a stream and returns the number of bytes written. //+++++++++++++++++++++++++++++++++++++++++++++++++ + int32 NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) { // TRACE("NPP_Write\n"); if (instance == NULL) - return -1; + return -1; nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata; if( theStream == 0 ) - return -1; + return -1; - nsresult result; - return theStream->Write((const char* )buffer, offset, len, &result); + PRInt32 count; + nsresult err = theStream->Write((const char* )buffer, offset, len, &count); + return (err == NS_OK) ? count : -1; } //+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -709,17 +731,18 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) // The stream peer and stream are destroyed. NPStream's // pdata is set to NULL. //+++++++++++++++++++++++++++++++++++++++++++++++++ + NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) { // TRACE("NPP_DestroyStream\n"); if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; + return NPERR_INVALID_INSTANCE_ERROR; nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata; if( theStream == 0 ) - return NPERR_GENERIC_ERROR; + return NPERR_GENERIC_ERROR; theStream->Release(); stream->pdata = NULL; @@ -731,6 +754,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) // NPP_StreamAsFile: // Provides a local file name for the data from a stream. //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname) { @@ -749,6 +773,7 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname) //+++++++++++++++++++++++++++++++++++++++++++++++++ // NPP_Print: //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_Print(NPP instance, NPPrint* printInfo) { @@ -768,6 +793,7 @@ NPP_Print(NPP instance, NPPrint* printInfo) // NPP_URLNotify: // Notifies the instance of the completion of a URL request. //+++++++++++++++++++++++++++++++++++++++++++++++++ + void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData) { @@ -786,6 +812,7 @@ NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData) // Mac-only, but stub must be present for Windows // Delivers a platform-specific event to the instance. //+++++++++++++++++++++++++++++++++++++++++++++++++ + #ifndef XP_UNIX int16 NPP_HandleEvent(NPP instance, void* event) @@ -797,13 +824,16 @@ NPP_HandleEvent(NPP instance, void* event) return eventHandled; nsIPluginInstance* pluginInstance = (nsIPluginInstance*) instance->pdata; - if( pluginInstance ) - eventHandled = (int16) pluginInstance->HandleEvent((nsPluginEvent*) event ); + if (pluginInstance) { + PRBool handled; + nsresult err = pluginInstance->HandleEvent((nsPluginEvent*)event, &handled); + if (err) return FALSE; + eventHandled = (handled == PR_TRUE); + } return eventHandled; } #endif // ndef XP_UNIX -////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // SECTION 5 - API Browser Implementations @@ -832,10 +862,12 @@ CPluginManager::~CPluginManager(void) { } +#if 0 //+++++++++++++++++++++++++++++++++++++++++++++++++ // MemAlloc: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void* NP_LOADDS + +NS_METHOD CPluginManager::MemAlloc(PRUint32 size) { return NPN_MemAlloc(size); @@ -844,7 +876,8 @@ CPluginManager::MemAlloc(PRUint32 size) //+++++++++++++++++++++++++++++++++++++++++++++++++ // MemFree: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginManager::MemFree(void* ptr) { assert( ptr != NULL ); @@ -855,7 +888,8 @@ CPluginManager::MemFree(void* ptr) //+++++++++++++++++++++++++++++++++++++++++++++++++ // MemFlush: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 NP_LOADDS + +NS_METHOD CPluginManager::MemFlush(PRUint32 size) { #ifdef XP_MAC @@ -864,14 +898,17 @@ CPluginManager::MemFlush(PRUint32 size) return 0; #endif } +#endif //+++++++++++++++++++++++++++++++++++++++++++++++++ // ReloadPlugins: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginManager::ReloadPlugins(PRBool reloadPages) { NPN_ReloadPlugins(reloadPages); + return NS_OK; } @@ -887,128 +924,138 @@ CPluginManager::ReloadPlugins(PRBool reloadPages) // referrer: // forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, // even if the user currently has JavaScript disabled. -nsPluginError NP_LOADDS -CPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData, - const char* altHost, const char* referrer, PRBool forceJSEnabled) +NS_METHOD +CPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, + void* notifyData, const char* altHost, + const char* referrer, PRBool forceJSEnabled) { - // assert( npp != NULL ); - // assert( url != NULL ); + // assert( npp != NULL ); + // assert( url != NULL ); assert( peer != NULL); CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)(nsIPluginInstancePeer*) peer; NPP npp = instancePeer->GetNPPInstance(); - + NPError err; // Call the correct GetURL* function. // This is determinded by checking notifyData. if (notifyData == NULL) { - return (nsPluginError)NPN_GetURL(npp, url, target); + err = NPN_GetURL(npp, url, target); } else { - return (nsPluginError)NPN_GetURLNotify(npp, url, target, notifyData); + err = NPN_GetURLNotify(npp, url, target, notifyData); } + return fromNPError[err]; } -// (Corresponds to NPN_PostURL and NPN_PostURLNotify.) -// notifyData: When present, URLNotify is called passing the notifyData back -// to the client. When NULL, this call behaves like NPN_GetURL. -// New arguments: -// peer: A plugin instance peer. The peer's window will be used to display -// progress information. If NULL, the load happens in the background. -// altHost: An IP-address string that will be used instead of the host -// specified in the URL. This is used to prevent DNS-spoofing attacks. -// Can be defaulted to NULL meaning use the host in the URL. -// referrer: -// forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs, -// even if the user currently has JavaScript disabled. -// postHeaders: A string containing post headers. -// postHeadersLength: The length of the post headers string. -nsPluginError NP_LOADDS -CPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData, const char* altHost, - const char* referrer, PRBool forceJSEnabled, PRUint32 postHeadersLength, - const char* postHeaders) -{ - assert( peer != NULL); - CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)(nsIPluginInstancePeer*)peer; +NS_METHOD +CPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, + PRUint32 postDataLen, const char* postData, + PRBool isFile, void* notifyData, + const char* altHost, const char* referrer, + PRBool forceJSEnabled, + PRUint32 postHeadersLength, const char* postHeaders) +{ + // assert( npp != NULL ); + // assert( url != NULL ); + assert( peer != NULL); + + CPluginInstancePeer* instancePeer = (CPluginInstancePeer*)(nsIPluginInstancePeer*) peer; NPP npp = instancePeer->GetNPPInstance(); + NPError err; // Call the correct PostURL* function. // This is determinded by checking notifyData. if (notifyData == NULL) { - return (nsPluginError)NPN_PostURL(npp, url, target, bufLen, buf, file); + err = NPN_PostURL(npp, url, target, postDataLen, postData, isFile); } else { - return (nsPluginError)NPN_PostURLNotify(npp, url, target, bufLen, buf, file, notifyData); + err = NPN_PostURLNotify(npp, url, target, postDataLen, postData, isFile, notifyData); } + return fromNPError[err]; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // UserAgent: //+++++++++++++++++++++++++++++++++++++++++++++++++ -const char* NP_LOADDS -CPluginManager::UserAgent(void) + +NS_METHOD +CPluginManager::UserAgent(const char* *result) { - return NPN_UserAgent(NULL); + *result = NPN_UserAgent(NULL); + return NS_OK; } +int varMap[] = { + (int)NPNVxDisplay, // nsPluginManagerVariable_XDisplay = 1, + (int)NPNVxtAppContext, // nsPluginManagerVariable_XtAppContext, + (int)NPNVnetscapeWindow, // nsPluginManagerVariable_NetscapeWindow, + (int)NPPVpluginWindowBool, // nsPluginInstancePeerVariable_WindowBool, + (int)NPPVpluginTransparentBool, // nsPluginInstancePeerVariable_TransparentBool, + (int)NPPVjavaClass, // nsPluginInstancePeerVariable_JavaClass, + (int)NPPVpluginWindowSize, // nsPluginInstancePeerVariable_WindowSize, + (int)NPPVpluginTimerInterval, // nsPluginInstancePeerVariable_TimerInterval +}; + //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS + +NS_METHOD CPluginManager::GetValue(nsPluginManagerVariable variable, void *value) { - // XXX - This may need to be stubbed out for - // XXX - other platforms than Unix. - // XXX - Change this to return NPPPlugin_Error; #ifdef XP_UNIX - return (nsPluginError)NPN_GetValue(NULL, (NPNVariable)variable, value); + return fromNPError[NPN_GetValue(NULL, (NPNVariable)varMap[(int)variable], value)]; #else - // XXX - Need to check this on the new API. - return nsPluginError_NoData; + return fromNPError[NPERR_GENERIC_ERROR]; #endif // XP_UNIX } //+++++++++++++++++++++++++++++++++++++++++++++++++ // SetValue: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS + +NS_METHOD CPluginManager::SetValue(nsPluginManagerVariable variable, void *value) { - // XXX - This should do something like this. - // XXX - return (nsPluginError)npn_setvalue(npp, (NPPVariable)variable, value); - // XXX - Is this XP in 4.0x? - // XXX - Need to check this on the new API. - return nsPluginError_NoData; +#ifdef XP_UNIX + return fromNPError[NPN_SetValue(NULL, (NPPVariable)varMap[(int)variable], value)]; +#else + return fromNPError[NPERR_GENERIC_ERROR]; +#endif // XP_UNIX } - - - //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginManager); NS_IMPL_RELEASE(CPluginManager); -//NS_IMPL_QUERY_INTERFACE(CPluginManager, kPluginManagerIID); -nsresult CPluginManager::QueryInterface(const nsIID& iid, void** ptr) + +NS_METHOD +CPluginManager::QueryInterface(const nsIID& iid, void** ptr) { - if (NULL == ptr) { - return NS_ERROR_NULL_POINTER; - } + if (NULL == ptr) { + return NS_ERROR_NULL_POINTER; + } - if (iid.Equals(kPluginManagerIID)) { - *ptr = (void*) this; - AddRef(); - return NS_OK; - } - if (iid.Equals(kISupportsIID)) { - *ptr = (void*) ((nsISupports*)this); - AddRef(); - return NS_OK; - } - return NS_NOINTERFACE; + if (iid.Equals(kIPluginManagerIID)) { + *ptr = (void*) (nsIPluginManager*)this; + AddRef(); + return NS_OK; + } + if (iid.Equals(kINetworkManagerIID)) { + *ptr = (void*) (nsINetworkManager*)this; + AddRef(); + return NS_OK; + } + if (iid.Equals(kISupportsIID)) { + *ptr = (void*) ((nsIPluginManager*)this); + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; } @@ -1019,7 +1066,7 @@ nsresult CPluginManager::QueryInterface(const nsIID& iid, void** ptr) CPluginInstancePeer::CPluginInstancePeer(NPP npp, nsMIMEType typeString, - nsPluginType type, + nsPluginMode type, PRUint16 attr_cnt, const char** attr_list, const char** val_list) @@ -1053,24 +1100,56 @@ CPluginInstancePeer::~CPluginInstancePeer(void) } +//+++++++++++++++++++++++++++++++++++++++++++++++++ +// GetValue: +//+++++++++++++++++++++++++++++++++++++++++++++++++ + +NS_METHOD +CPluginInstancePeer::GetValue(nsPluginInstancePeerVariable variable, void *value) +{ +#ifdef XP_UNIX + return fromNPError[NPN_GetValue(NULL, (NPNVariable)varMap[(int)variable], value)]; +#else + return fromNPError[NPERR_GENERIC_ERROR]; +#endif // XP_UNIX +} + +//+++++++++++++++++++++++++++++++++++++++++++++++++ +// SetValue: +//+++++++++++++++++++++++++++++++++++++++++++++++++ + +NS_METHOD +CPluginInstancePeer::SetValue(nsPluginInstancePeerVariable variable, void *value) +{ +#ifdef XP_UNIX + return fromNPError[NPN_SetValue(NULL, (NPPVariable)varMap[(int)variable], value)]; +#else + return fromNPError[NPERR_GENERIC_ERROR]; +#endif // XP_UNIX +} + //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetMIMEType: // Corresponds to NPP_New's MIMEType argument. //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsMIMEType NP_LOADDS -CPluginInstancePeer::GetMIMEType(void) + +NS_METHOD +CPluginInstancePeer::GetMIMEType(nsMIMEType *result) { - return typeString; + *result = typeString; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetMode: // Corresponds to NPP_New's mode argument. //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginType NP_LOADDS -CPluginInstancePeer::GetMode(void) + +NS_METHOD +CPluginInstancePeer::GetMode(nsPluginMode *result) { - return type; + *result = type; + return NS_OK; } @@ -1078,32 +1157,35 @@ CPluginInstancePeer::GetMode(void) // returns the length of the array. // // Each name or value is a null-terminated string. -nsPluginError NP_LOADDS +NS_METHOD CPluginInstancePeer::GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values) { n = attribute_cnt; names = attribute_list; values = values_list; - return nsPluginError_NoError; + return NS_OK; } // Get the value for the named attribute. Returns null // if the attribute was not set. -const char* NP_LOADDS -CPluginInstancePeer::GetAttribute(const char* name) +NS_METHOD +CPluginInstancePeer::GetAttribute(const char* name, const char* *result) { for (int i=0; i < attribute_cnt; i++) { #ifdef XP_UNIX if (strcasecmp(name, attribute_list[i]) == 0) #else - if (stricmp(name, attribute_list[i]) == 0) + if (stricmp(name, attribute_list[i]) == 0) #endif - return values_list[i]; + { + *result = values_list[i]; + return NS_OK; + } } - return NULL; + return NS_ERROR_FAILURE; } //+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1112,18 +1194,20 @@ CPluginInstancePeer::GetAttribute(const char* name) // XXX - Where did this go in the new API? // //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginInstancePeer::Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor) + int* netscape_major, int* netscape_minor) { NPN_Version(plugin_major, plugin_minor, netscape_major, netscape_minor); + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // NewStream: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS +NS_METHOD CPluginInstancePeer::NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) { @@ -1131,56 +1215,61 @@ CPluginInstancePeer::NewStream(nsMIMEType type, const char* target, // Create a new NPStream. NPStream* ptr = NULL; - nsPluginError error = (nsPluginError)NPN_NewStream(npp, (NPMIMEType)type, target, &ptr); - if (error) return error; + NPError error = NPN_NewStream(npp, (NPMIMEType)type, target, &ptr); + if (error) + return fromNPError[error]; // Create a new Plugin Manager Stream. // XXX - Do we have to Release() the manager stream before doing this? // XXX - See the BAM doc for more info. CPluginManagerStream* mstream = new CPluginManagerStream(npp, ptr); - if (mstream == NULL) return nsPluginError_OutOfMemoryError; + if (mstream == NULL) + return NS_ERROR_OUT_OF_MEMORY; mstream->AddRef(); *result = (nsIOutputStream* )mstream; - return nsPluginError_NoError; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // ShowStatus: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void NP_LOADDS + +NS_METHOD CPluginInstancePeer::ShowStatus(const char* message) { assert( message != NULL ); NPN_Status(npp, message); + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginInstancePeer); NS_IMPL_RELEASE(CPluginInstancePeer); - -nsresult CPluginInstancePeer::QueryInterface(const nsIID& iid, void** ptr) +NS_METHOD +CPluginInstancePeer::QueryInterface(const nsIID& iid, void** ptr) { - if (NULL == ptr) { - return NS_ERROR_NULL_POINTER; - } + if (NULL == ptr) { + return NS_ERROR_NULL_POINTER; + } - if (iid.Equals(kPluginInstancePeerIID)) { - *ptr = (void*) this; - AddRef(); - return NS_OK; - } - if (iid.Equals(kPluginTagInfoIID) || iid.Equals(kISupportsIID)) { - *ptr = (void*) ((nsIPluginTagInfo*)this); - AddRef(); - return NS_OK; - } - return NS_NOINTERFACE; + if (iid.Equals(kIPluginInstancePeerIID)) { + *ptr = (void*) this; + AddRef(); + return NS_OK; + } + if (iid.Equals(kIPluginTagInfoIID) || iid.Equals(kISupportsIID)) { + *ptr = (void*) ((nsIPluginTagInfo*)this); + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; } ////////////////////////////////////////////////////////////////////////////// @@ -1205,63 +1294,76 @@ CPluginManagerStream::~CPluginManagerStream(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // Write: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRInt32 NP_LOADDS -CPluginManagerStream::Write(const char* buffer, PRInt32 offset, PRInt32 len, nsresult* error) + +NS_METHOD +CPluginManagerStream::Write(const char* buffer, PRInt32 offset, PRInt32 len, + PRInt32 *aWriteCount) { assert( npp != NULL ); assert( pstream != NULL ); - return NPN_Write(npp, pstream, len, (void* )buffer); + assert(offset == 0); // XXX need to handle the non-sequential write case + *aWriteCount = NPN_Write(npp, pstream, len, (void* )buffer); + return *aWriteCount >= 0 ? NS_OK : NS_ERROR_FAILURE; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetURL: //+++++++++++++++++++++++++++++++++++++++++++++++++ -const char* NP_LOADDS -CPluginManagerStream::GetURL(void) + +NS_METHOD +CPluginManagerStream::GetURL(const char* *result) { assert( pstream != NULL ); - return pstream->url; + *result = pstream->url; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetEnd: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 NP_LOADDS -CPluginManagerStream::GetEnd(void) + +NS_METHOD +CPluginManagerStream::GetEnd(PRUint32 *result) { assert( pstream != NULL ); - return pstream->end; + *result = pstream->end; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetLastModified: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 NP_LOADDS -CPluginManagerStream::GetLastModified(void) + +NS_METHOD +CPluginManagerStream::GetLastModified(PRUint32 *result) { assert( pstream != NULL ); - return pstream->lastmodified; + *result = pstream->lastmodified; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetNotifyData: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void* NP_LOADDS -CPluginManagerStream::GetNotifyData(void) + +NS_METHOD +CPluginManagerStream::GetNotifyData(void* *result) { assert( pstream != NULL ); - return pstream->notifyData; + *result = pstream->notifyData; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetNotifyData: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsresult NP_LOADDS + +NS_METHOD CPluginManagerStream::Close(void) { assert( pstream != NULL ); @@ -1273,17 +1375,11 @@ CPluginManagerStream::Close(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginManagerStream); -//NS_IMPL_RELEASE(CPluginManagerStream); -nsrefcnt CPluginManagerStream::Release(void) -{ - if (--mRefCnt == 0) { - delete this; - return 0; - } - return mRefCnt; -} -NS_IMPL_QUERY_INTERFACE(CPluginManagerStream, kOutputStreamIID); +NS_IMPL_RELEASE(CPluginManagerStream); + +NS_IMPL_QUERY_INTERFACE(CPluginManagerStream, kIOutputStreamIID); ////////////////////////////////////////////////////////////////////////////// @@ -1308,77 +1404,96 @@ CPluginStreamPeer::~CPluginStreamPeer(void) //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetURL: //+++++++++++++++++++++++++++++++++++++++++++++++++ -const char* CPluginStreamPeer::GetURL(void) + +NS_METHOD +CPluginStreamPeer::GetURL(const char* *result) { - return npStream->url; + *result = npStream->url; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetEnd: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 CPluginStreamPeer::GetEnd(void) + +NS_METHOD +CPluginStreamPeer::GetEnd(PRUint32 *result) { - return npStream->end; + *result = npStream->end; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetLastModified: //+++++++++++++++++++++++++++++++++++++++++++++++++ -PRUint32 CPluginStreamPeer::GetLastModified(void) + +NS_METHOD +CPluginStreamPeer::GetLastModified(PRUint32 *result) { - return npStream->lastmodified; + *result = npStream->lastmodified; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetNotifyData: //+++++++++++++++++++++++++++++++++++++++++++++++++ -void* CPluginStreamPeer::GetNotifyData(void) + +NS_METHOD +CPluginStreamPeer::GetNotifyData(void* *result) { - return npStream->notifyData; + *result = npStream->notifyData; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetReason: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginReason CPluginStreamPeer::GetReason(void) + +NS_METHOD +CPluginStreamPeer::GetReason(nsPluginReason *result) { - return reason; + *result = reason; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // GetMIMEType: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsMIMEType NP_LOADDS -CPluginStreamPeer::GetMIMEType(void) + +NS_METHOD +CPluginStreamPeer::GetMIMEType(nsMIMEType *result) { - return type; + *result = type; + return NS_OK; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // RequestRead: //+++++++++++++++++++++++++++++++++++++++++++++++++ -nsPluginError NP_LOADDS + +NS_METHOD CPluginStreamPeer::RequestRead(nsByteRange* rangeList) { - return (nsPluginError)NPN_RequestRead(npStream, (NPByteRange* )rangeList); + return fromNPError[NPN_RequestRead(npStream, (NPByteRange* )rangeList)]; } //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions //+++++++++++++++++++++++++++++++++++++++++++++++++ + NS_IMPL_ADDREF(CPluginStreamPeer); NS_IMPL_RELEASE(CPluginStreamPeer); -//NS_IMPL_QUERY_INTERFACE(CPluginStreamPeer, kSeekablePluginStreamPeerIID); + nsresult CPluginStreamPeer::QueryInterface(const nsIID& iid, void** ptr) { if (NULL == ptr) { return NS_ERROR_NULL_POINTER; } - if (iid.Equals(kSeekablePluginStreamPeerIID)) { + if (iid.Equals(kISeekablePluginStreamPeerIID)) { *ptr = (void*) ((nsISeekablePluginStreamPeer*)this); AddRef(); return NS_OK; - } else if (iid.Equals(kPluginStreamPeerIID) || + } else if (iid.Equals(kIPluginStreamPeerIID) || iid.Equals(kISupportsIID)) { *ptr = (void*) ((nsIPluginStreamPeer*)this); AddRef(); diff --git a/modules/plugin/samples/simple/Simple32.def b/modules/plugin/samples/simple/Simple32.def index 424678074a10..57c94ea4daed 100644 --- a/modules/plugin/samples/simple/Simple32.def +++ b/modules/plugin/samples/simple/Simple32.def @@ -1,19 +1,19 @@ -# -*- 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.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. 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 this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. +; -*- 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.0 (the "NPL"); you may not use this file except in +; compliance with the NPL. 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 this code under the NPL is Netscape +; Communications Corporation. Portions created by Netscape are +; Copyright (C) 1998 Netscape Communications Corporation. All Rights +; Reserved. LIBRARY NPSimp32 diff --git a/modules/plugin/samples/simple/makefile.win b/modules/plugin/samples/simple/makefile.win index 30dd2d65b161..bf38efdec9ba 100644 --- a/modules/plugin/samples/simple/makefile.win +++ b/modules/plugin/samples/simple/makefile.win @@ -79,8 +79,5 @@ include <$(DEPTH)/config/rules.mak> LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl install:: $(DLL) - -mkdir $(DEPTH)\cmd\winfe\mkfiles32\x86dbg - -mkdir $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins - -mkdir $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple $(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple $(MAKE_INSTALL) $(OBJDIR)\npsimple.dll $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple diff --git a/modules/plugin/samples/simple/npsimple.cpp b/modules/plugin/samples/simple/npsimple.cpp index 930ca8649613..87b4963677fb 100644 --- a/modules/plugin/samples/simple/npsimple.cpp +++ b/modules/plugin/samples/simple/npsimple.cpp @@ -39,7 +39,7 @@ #include #include "nsplugin.h" #include "nsIJRILiveConnectPlugin.h" -#include "nsIJRILiveConnectPluginInstancePeer.h" +#include "nsIJRILiveConnectPlugInstPeer.h" /*------------------------------------------------------------------------------ * Define IMPLEMENT_Simple before including Simple.h to state that we're * implementing the native methods of this plug-in here, and consequently @@ -146,25 +146,25 @@ public: // This call initializes the plugin and will be called before any new // instances are created. It is passed browserInterfaces on which QueryInterface // may be used to obtain an nsIPluginManager, and other interfaces. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Initialize(nsISupports* browserInterfaces); // (Corresponds to NPP_Shutdown.) // Called when the browser is done with the plugin factory, or when // the plugin is disabled by the user. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Shutdown(void); // (Corresponds to NPP_GetMIMEDescription.) - NS_IMETHOD_(const char*) - GetMIMEDescription(void); + NS_IMETHOD + GetMIMEDescription(const char* *result); // (Corresponds to NPP_GetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetValue(nsPluginVariable variable, void *value); // (Corresponds to NPP_SetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD SetValue(nsPluginVariable variable, void *value); // The old NPP_New call has been factored into two plugin instance methods: @@ -183,8 +183,8 @@ public: // from nsIJRILiveConnectPlugin: // (Corresponds to NPP_GetJavaClass.) - NS_IMETHOD_(jref) - GetJavaClass(void); + NS_IMETHOD + GetJavaClass(jref *result); //////////////////////////////////////////////////////////////////////////// // SimplePlugin specific methods: @@ -207,18 +207,30 @@ protected: class SimplePluginInstance : public nsIPluginInstance { public: + //////////////////////////////////////////////////////////////////////////// + // from nsIEventHandler: + + // (Corresponds to NPP_HandleEvent.) + // Note that for Unix and Mac the nsPluginEvent structure is different + // from the old NPEvent structure -- it's no longer the native event + // record, but is instead a struct. This was done for future extensibility, + // and so that the Mac could receive the window argument too. For Windows + // and OS2, it's always been a struct, so there's no change for them. + NS_IMETHOD + HandleEvent(nsPluginEvent* event, PRBool* handled); + //////////////////////////////////////////////////////////////////////////// // from nsIPluginInstance: - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Initialize(nsIPluginInstancePeer* peer); // Required backpointer to the peer. - NS_IMETHOD_(nsIPluginInstancePeer*) - GetPeer(void); + NS_IMETHOD + GetPeer(nsIPluginInstancePeer* *result); // See comment for nsIPlugin::CreateInstance, above. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Start(void); // The old NPP_Destroy call has been factored into two plugin instance @@ -231,35 +243,26 @@ public: // Destroy -- called once, before the plugin instance peer is to be // destroyed. This method is used to destroy the plugin instance. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Stop(void); - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Destroy(void); // (Corresponds to NPP_SetWindow.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD SetWindow(nsPluginWindow* window); // (Corresponds to NPP_NewStream.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result); // (Corresponds to NPP_Print.) - NS_IMETHOD_(void) + NS_IMETHOD Print(nsPluginPrint* platformPrint); - // (Corresponds to NPP_HandleEvent.) - // Note that for Unix and Mac the nsPluginEvent structure is different - // from the old NPEvent structure -- it's no longer the native event - // record, but is instead a struct. This was done for future extensibility, - // and so that the Mac could receive the window argument too. For Windows - // and OS2, it's always been a struct, so there's no change for them. - NS_IMETHOD_(PRInt16) - HandleEvent(nsPluginEvent* event); - // (Corresponds to NPP_URLNotify.) - NS_IMETHOD_(void) + NS_IMETHOD URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData); @@ -273,11 +276,11 @@ public: void DisplayJavaMessage(char* msg, int len); void PlatformNew(void); - nsPluginError PlatformDestroy(void); - nsPluginError PlatformSetWindow(nsPluginWindow* window); + nsresult PlatformDestroy(void); + nsresult PlatformSetWindow(nsPluginWindow* window); PRInt16 PlatformHandleEvent(nsPluginEvent* event); - void SetMode(PRUint16 mode) { fMode = mode; } + void SetMode(nsPluginMode mode) { fMode = mode; } #ifdef XP_PC static LRESULT CALLBACK @@ -291,7 +294,7 @@ public: protected: nsIPluginInstancePeer* fPeer; nsPluginWindow* fWindow; - PRUint16 fMode; + nsPluginMode fMode; PlatformInstance fPlatform; }; @@ -320,19 +323,18 @@ public: * @param errorResult the error code if an error occurs * @return number of bytes read or -1 if error */ - NS_IMETHOD_(PRInt32) - Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, - nsresult *errorResult); + NS_IMETHOD + Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount); //////////////////////////////////////////////////////////////////////////// // from nsIPluginStream: // (Corresponds to NPP_NewStream's stype return parameter.) - NS_IMETHOD_(NPStreamType) - GetStreamType(void); + NS_IMETHOD + GetStreamType(nsPluginStreamType *result); // (Corresponds to NPP_StreamAsFile.) - NS_IMETHOD_(void) + NS_IMETHOD AsFile(const char* fname); //////////////////////////////////////////////////////////////////////////// @@ -452,32 +454,33 @@ SimplePlugin::LockFactory(PRBool aLock) return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::Initialize(nsISupports* browserInterfaces) { if (browserInterfaces->QueryInterface(kIPluginManagerIID, (void**)mgr) != NS_OK) { - return nsPluginError_GenericError; + return NS_ERROR_FAILURE; } - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::Shutdown(void) { mgr->Release(); // QueryInterface in Initialize mgr = NULL; - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ * GetMIMEDescription: +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(const char*) -SimplePlugin::GetMIMEDescription(void) +NS_METHOD +SimplePlugin::GetMIMEDescription(const char* *result) { - return "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"; + *result = "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -487,24 +490,24 @@ SimplePlugin::GetMIMEDescription(void) #define PLUGIN_NAME "Simple LiveConnect Sample Plug-in" #define PLUGIN_DESCRIPTION "Demonstrates a simple LiveConnected plug-in." -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::GetValue(nsPluginVariable variable, void *value) { - nsPluginError err = nsPluginError_NoError; + nsresult err = NS_OK; if (variable == nsPluginVariable_NameString) *((char **)value) = PLUGIN_NAME; else if (variable == nsPluginVariable_DescriptionString) *((char **)value) = PLUGIN_DESCRIPTION; else - err = nsPluginError_GenericError; + err = NS_ERROR_FAILURE; return err; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::SetValue(nsPluginVariable variable, void *value) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -518,12 +521,12 @@ SimplePlugin::SetValue(nsPluginVariable variable, void *value) * complain to the user. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(jref) -SimplePlugin::GetJavaClass(void) +NS_METHOD +SimplePlugin::GetJavaClass(jref *result) { struct java_lang_Class* myClass; if (mgr->QueryInterface(kIJRIEnvIID, (void**)&env) == NS_NOINTERFACE) - return NULL; // Java disabled + return NS_ERROR_FAILURE; // Java disabled myClass = Simple::_use(env); @@ -534,7 +537,8 @@ SimplePlugin::GetJavaClass(void) */ env = NULL; } - return (jref)myClass; + *result = (jref)myClass; + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -542,7 +546,7 @@ SimplePlugin::GetJavaClass(void) //////////////////////////////////////////////////////////////////////////////// SimplePluginInstance::SimplePluginInstance(void) - : fPeer(NULL), fWindow(NULL), fMode(0) + : fPeer(NULL), fWindow(NULL), fMode(nsPluginMode_Embedded) { NS_INIT_REFCNT(); } @@ -571,22 +575,25 @@ NS_IMPL_RELEASE(SimplePluginInstance); * time. The NPP pointer is valid until the instance is destroyed. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Initialize(nsIPluginInstancePeer* peer) { fPeer = peer; - fMode = peer->GetMode(); + nsresult err = peer->GetMode(&fMode); + if (err) return err; PlatformNew(); /* Call Platform-specific initializations */ - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsIPluginInstancePeer*) -SimplePluginInstance::GetPeer(void) +NS_METHOD +SimplePluginInstance::GetPeer(nsIPluginInstancePeer* *result) { - return fPeer; + fPeer->AddRef(); + *result = fPeer; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Start(void) { /* Show off some of that Java functionality: */ @@ -609,19 +616,19 @@ SimplePluginInstance::Start(void) sprintf(factString, "my favorite function returned %d\n", v); DisplayJavaMessage(factString, -1); } - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Stop(void) { - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Destroy(void) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -638,10 +645,10 @@ SimplePluginInstance::Destroy(void) * with the window. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::SetWindow(nsPluginWindow* window) { - nsPluginError result; + nsresult result; DisplayJavaMessage("Calling SimplePluginInstance::SetWindow.", -1); /* @@ -666,30 +673,31 @@ SimplePluginInstance::SetWindow(nsPluginWindow* window) * parameter type. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) { DisplayJavaMessage("Calling SimplePluginInstance::NewStream.", -1); SimplePluginStream* strm = new SimplePluginStream(peer, this); - if (strm == NULL) return nsPluginError_OutOfMemoryError; + if (strm == NULL) + return NS_ERROR_OUT_OF_MEMORY; strm->AddRef(); *result = strm; - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ * NPP_Print: +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(void) +NS_METHOD SimplePluginInstance::Print(nsPluginPrint* printInfo) { DisplayJavaMessage("Calling SimplePluginInstance::Print.", -1); if (printInfo == NULL) - return; + return NS_ERROR_FAILURE; - if (printInfo->mode == nsPluginType_Full) { + if (printInfo->mode == nsPluginMode_Full) { /* * PLUGIN DEVELOPERS: * If your plugin would like to take over @@ -720,7 +728,7 @@ SimplePluginInstance::Print(nsPluginPrint* printInfo) * PLUGIN DEVELOPERS: * If your plugin is embedded, or is full-screen * but you returned false in pluginPrinted above, NPP_Print - * will be called with mode == nsPluginType_Embedded. The nsPluginWindow + * will be called with mode == nsPluginMode_Embedded. The nsPluginWindow * in the printInfo gives the location and dimensions of * the embedded plugin on the printed page. On the * Macintosh, platformPrint is the printer port; on @@ -733,6 +741,7 @@ SimplePluginInstance::Print(nsPluginPrint* printInfo) void* platformPrint = printInfo->print.embedPrint.platformPrint; } + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -745,11 +754,11 @@ SimplePluginInstance::Print(nsPluginPrint* printInfo) * return TRUE if you handle the event and FALSE if you ignore the event. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(PRInt16) -SimplePluginInstance::HandleEvent(nsPluginEvent* event) +NS_METHOD +SimplePluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) { - PRInt16 eventHandled = PlatformHandleEvent(event); - return eventHandled; + *handled = (PRBool)PlatformHandleEvent(event); + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -771,11 +780,12 @@ SimplePluginInstance::HandleEvent(nsPluginEvent* event) * call, and can be used by your plug-in to uniquely identify the request. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(void) +NS_METHOD SimplePluginInstance::URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData) { // Not used in the Simple plugin + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -801,22 +811,6 @@ NS_IMPL_QUERY_INTERFACE(SimplePluginStream, kIPluginStreamIID); NS_IMPL_ADDREF(SimplePluginStream); NS_IMPL_RELEASE(SimplePluginStream); -/* PLUGIN DEVELOPERS: - * These next 2 functions are directly relevant in a plug-in which - * handles the data in a streaming manner. If you want zero bytes - * because no buffer space is YET available, return 0. As long as - * the stream has not been written to the plugin, Navigator will - * continue trying to send bytes. If the plugin doesn't want them, - * just return some large number from NPP_WriteReady(), and - * ignore them in NPP_Write(). For a NP_ASFILE stream, they are - * still called but can safely be ignored using this strategy. - */ - -PRInt32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile - * mode so we can take any size stream in our - * write call (since we ignore it) */ - - NS_METHOD SimplePluginStream::Close(void) { @@ -845,22 +839,22 @@ SimplePluginStream::Close(void) * is not persistent. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(PRInt32) -SimplePluginStream::Write(const char* buffer, PRInt32 len, PRInt32 aCount, - nsresult *errorResult) +NS_METHOD +SimplePluginStream::Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount) { - fInst->DisplayJavaMessage((char*)buffer, len); - *errorResult = NS_OK; - return len; /* The number of bytes accepted */ + PR_ASSERT(aOffset == 0); // XXX need to handle the non-sequential write case + fInst->DisplayJavaMessage((char*)aBuf, aCount); + return aCount; /* The number of bytes accepted */ } /*******************************************************************************/ -NS_METHOD_(NPStreamType) -SimplePluginStream::GetStreamType(void) +NS_METHOD +SimplePluginStream::GetStreamType(nsPluginStreamType *result) { // XXX these should become subclasses - return NPStreamType_Normal; + *result = nsPluginStreamType_Normal; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -874,10 +868,11 @@ SimplePluginStream::GetStreamType(void) * retrieving the data or writing the file, fname may be NULL. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(void ) +NS_METHOD SimplePluginStream::AsFile(const char* fname) { fInst->DisplayJavaMessage("Calling SimplePluginStream::AsFile.", -1); + return NS_OK; } @@ -940,7 +935,8 @@ SimplePluginInstance::DisplayJavaMessage(char* msg, int len) ** Use the GetJavaPeer operation to get the Java instance that ** corresponds to our plug-in (an instance of the Simple class): */ - javaPeer = (Simple*)lcPeer->GetJavaPeer(); + nsresult err = lcPeer->GetJavaPeer((jobject*)&javaPeer); + if (err) return; /* ** Finally, call our plug-in's big "feature" -- the 'doit' method, @@ -978,10 +974,10 @@ SimplePluginInstance::PlatformNew(void) * Destroy any Platform-Specific instance data. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformDestroy(void) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -990,7 +986,7 @@ SimplePluginInstance::PlatformDestroy(void) * Perform platform-specific window operations +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { Widget netscape_widget; @@ -1005,7 +1001,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) netscape_widget = XtWindowToWidget(fPlatform.display, fPlatform.window); XtAddEventHandler(netscape_widget, ExposureMask, FALSE, (XtEventHandler)Redraw, this); Redraw(netscape_widget, (XtPointer)this, NULL); - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1071,7 +1067,7 @@ SimplePluginInstance::PlatformNew(void) * Destroy any Platform-Specific instance data. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformDestroy(void) { if( fWindow != NULL ) { /* If we have a window, clean @@ -1081,7 +1077,7 @@ SimplePluginInstance::PlatformDestroy(void) fPlatform.fhWnd = NULL; } - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1090,7 +1086,7 @@ SimplePluginInstance::PlatformDestroy(void) * Perform platform-specific window operations +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { if( fWindow != NULL ) /* If we already have a window, clean @@ -1103,12 +1099,12 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) SetWindowLong( fPlatform.fhWnd, GWL_WNDPROC, (LONG)fPlatform.fDefaultWindowProc); fPlatform.fDefaultWindowProc = NULL; fPlatform.fhWnd = NULL; - return nsPluginError_NoError; + return NS_OK; } else if ( fPlatform.fhWnd == (HWND) window->window ) { /* The new window is the same as the old one. Exit now. */ - return nsPluginError_NoError; + return NS_OK; } else { /* Clean up the old window, so that we can subclass the new @@ -1121,7 +1117,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) else if( (window == NULL) || ( window->window == NULL ) ) { /* We can just get out of here if there is no current * window and there is no new window to use. */ - return nsPluginError_NoError; + return NS_OK; } /* At this point, we will subclass @@ -1135,7 +1131,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) InvalidateRect( fPlatform.fhWnd, NULL, TRUE ); UpdateWindow( fPlatform.fhWnd ); - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1214,10 +1210,10 @@ SimplePluginInstance::PlatformNew(void) * Destroy any Platform-Specific instance data. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformDestroy(void) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1226,7 +1222,7 @@ SimplePluginInstance::PlatformDestroy(void) * Perform platform-specific window operations +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { fWindow = window; @@ -1234,7 +1230,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) DoDraw(This); EndDraw( window ); } - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/modules/plugin/src/Makefile b/modules/plugin/src/Makefile index 16adf498ec41..fbf067a25f20 100644 --- a/modules/plugin/src/Makefile +++ b/modules/plugin/src/Makefile @@ -17,24 +17,22 @@ DEPTH = ../../.. -MODULE = plug +MODULE = plugimpl LIBRARY_NAME = plug CSRCS = npassoc.c -CPPSRCS = nsplugin.cpp +CPPSRCS = nsplugin.cpp npglue.cpp EXPORTS = nppg.h npglue.h nppriv.h -REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom netcnvts oji ojiimpl +REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom raptor netcnvts plugin oji ojiimpl ifeq ($(subst /,_,$(shell uname -s)),OS2) CPPSRCS = npwplat.cpp REQUIRES += xp libfont os2font jtools endif -CPPSRCS += npglue.cpp - include $(DEPTH)/config/rules.mk ifeq ($(subst /,_,$(shell uname -s)),OS2) diff --git a/modules/plugin/src/makefile.win b/modules/plugin/src/makefile.win index 2ccdf86d8105..bc0992cd99cf 100644 --- a/modules/plugin/src/makefile.win +++ b/modules/plugin/src/makefile.win @@ -36,11 +36,16 @@ LINCS = -I$(DIST)\include \ -I$(PUBLIC)\lay \ -I$(PUBLIC)\style \ -I$(PUBLIC)\xpcom \ + -I$(PUBLIC)\raptor \ -I$(PUBLIC)\oji \ -I$(PUBLIC)\ojiimpl OBJS = .\$(OBJDIR)\npassoc.obj \ + .\$(OBJDIR)\nsplugin.obj \ .\$(OBJDIR)\npglue.obj include <$(DEPTH)/config/rules.mak> +install:: $(LIBRARY) + $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib + diff --git a/modules/plugin/src/npglue.cpp b/modules/plugin/src/npglue.cpp index 240abd592a8c..7fdc13b68836 100644 --- a/modules/plugin/src/npglue.cpp +++ b/modules/plugin/src/npglue.cpp @@ -57,6 +57,10 @@ static np_handle *np_alist = NULL; int np_debug = 0; +#ifdef XP_MAC +static XP_Bool gForcingRedraw = FALSE; +#endif /* XP_MAC */ + NPNetscapeFuncs npp_funcs; /* @@ -166,10 +170,13 @@ np_processURLNode(np_urlsnode* node, np_instance* instance, int status) TRACEMSG(("npglue.c: CallNPP_URLNotifyProc")); if (np_is50StylePlugin(instance->handle)) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); - userInst->URLNotify(node->urls->address, node->urls->window_target, - (nsPluginReason)np_statusToReason(status), - node->notifyData); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + if (pluginInst != NULL) { + pluginInst->URLNotify(node->urls->address, node->urls->window_target, + (nsPluginReason)np_statusToReason(status), + node->notifyData); + pluginInst->Release(); + } } else if (ISFUNCPTR(instance->handle->f->urlnotify)) { CallNPP_URLNotifyProc(instance->handle->f->urlnotify, @@ -537,9 +544,10 @@ NPL_Write(NET_StreamClass *stream, const unsigned char *str, int32 len) if (newstream->handle->userPlugin) { nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)newstream->pstream->pdata; nsIPluginStream* userStream = peerStream->GetUserStream(); - nsresult err; - ret = userStream->Write((const char*)str, 0, len, &err); - PR_ASSERT(err == NS_OK); // XXX this should go somewhere + PRInt32 written; + nsresult err = userStream->Write((const char*)str, 0, len, &written); + PR_ASSERT(err == NS_OK); // XXX this error should go somewhere + PR_ASSERT(written == len); } else if (ISFUNCPTR(newstream->handle->f->write)) { ret = CallNPP_WriteProc(newstream->handle->f->write, newstream->instance->npp, newstream->pstream, @@ -2117,6 +2125,16 @@ npn_invalidateregion(NPP npp, NPRegion invalidRegion) } } +#ifdef XP_MAC +/* + Used only in CHTMLView::GetCurrentPort(). +*/ +XP_Bool NPL_IsForcingRedraw() +{ + return gForcingRedraw; +} +#endif /* XP_MAC */ + void NP_EXPORT npn_forceredraw(NPP npp) { @@ -2127,7 +2145,13 @@ npn_forceredraw(NPP npp) } if (instance && !instance->windowed) { +#ifdef XP_MAC + gForcingRedraw = TRUE; +#endif /* XP_MAC */ CL_CompositeNow(CL_GetLayerCompositor(instance->layer)); +#ifdef XP_MAC + gForcingRedraw = FALSE; +#endif /* XP_MAC */ } } @@ -2147,20 +2171,20 @@ npn_forceredraw(NPP npp) #endif #if defined(OJI) JNIEnv* NP_EXPORT -npn_getJavaEnv(PRThread *pPRThread) +npn_getJavaEnv(void) { #ifdef XP_MAC short resNum1, resNum2; resNum1 = CurResFile(); #endif /* XP_MAC */ - JNIEnv *pJNIEnv = NULL; + JNIEnv *pJNIEnv = NULL; - /* =-= What do we do with the thread passed in? Looks like we cannot - * get a JNIEnv for any arbitrary thread. One can only attach to a - * current thread. - */ - pJNIEnv = JVM_GetJNIEnv(); /* This may startup the VM. */ + /* =-= What do we do with the thread passed in? Looks like we cannot + * get a JNIEnv for any arbitrary thread. One can only attach to a + * current thread. + */ + pJNIEnv = JVM_GetJNIEnv(); /* This may startup the VM. */ #ifdef XP_MAC /* if Java changed the res file, change it back to the plugin's res file */ @@ -2169,7 +2193,7 @@ npn_getJavaEnv(PRThread *pPRThread) UseResFile(resNum1); #endif /* XP_MAC */ - return pJNIEnv; + return pJNIEnv; } #else /* OJI */ JRIEnv* NP_EXPORT @@ -2211,7 +2235,7 @@ npn_getJavaEnv(void) jclass NP_EXPORT npn_getJavaClass(np_handle* handle); -void +static void np_recover_mochaWindow(JNIEnv * env, np_instance * instance) { if (env && instance && instance->mochaWindow && instance->javaInstance){ @@ -2227,7 +2251,7 @@ jobject classPlugin = NULL; #define NPN_NO_JAVA_INSTANCE ((jobject)-1) #elif defined(JAVA) -void +static void np_recover_mochaWindow(JRIEnv * env, np_instance * instance) { netscape_plugin_Plugin* javaInstance = NULL; @@ -2258,16 +2282,18 @@ NS_DEFINE_IID(kLiveConnectPluginIID, NS_ILIVECONNECTPLUGIN_IID); #pragma pointers_in_D0 #endif -#if defined(OJI) jclass NP_EXPORT npn_getJavaClass(np_handle* handle) { +#if defined(OJI) if (handle->userPlugin) { nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin; nsILiveConnectPlugin* lcPlugin; if (userPluginClass->QueryInterface(kLiveConnectPluginIID, (void**)&lcPlugin) != NS_NOINTERFACE) { - jclass clazz = lcPlugin->GetJavaClass(); + jclass clazz; + nsresult err = lcPlugin->GetJavaClass(&clazz); + PR_ASSERT(err == NS_OK); // Remember, QueryInterface increments the ref count; // since we're done with it in this scope, release it. @@ -2278,16 +2304,11 @@ npn_getJavaClass(np_handle* handle) return NULL; // not a LiveConnected plugin } else if (handle && handle->f) { - JNIEnv* env = npn_getJavaEnv(NULL); /* may start up the java runtime */ + JNIEnv* env = npn_getJavaEnv(); /* may start up the java runtime */ if (env == NULL) return NULL; return (jclass) env->NewGlobalRef((jobject)handle->f->javaClass); } - return NULL; -} #elif defined(JAVA) -java_lang_Class* NP_EXPORT -npn_getJavaClass(np_handle* handle) -{ if (handle->userPlugin) { nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin; nsILiveConnectPlugin* lcPlugin; @@ -2308,96 +2329,99 @@ npn_getJavaClass(np_handle* handle) if (env == NULL) return NULL; return (java_lang_Class*)JRI_GetGlobalRef(env, handle->f->javaClass); } +#endif /* JAVA */ return NULL; } -#endif /* JAVA */ #if defined(OJI) jobject NP_EXPORT npn_getJavaPeer(NPP npp) +#else +jref NP_EXPORT +npn_getJavaPeer(NPP npp) +#endif { +#if defined(OJI) jobject javaInstance = NULL; np_instance* instance; if (npp == NULL) - return NULL; + return NULL; instance = (np_instance*) npp->ndata; - if (instance == NULL) return NULL; + if (instance == NULL) return NULL; - if (instance->javaInstance == NPN_NO_JAVA_INSTANCE) { - /* Been there, done that. */ - return NULL; - } + if (instance->javaInstance == NPN_NO_JAVA_INSTANCE) { + /* Been there, done that. */ + return NULL; + } else if (instance->javaInstance != NULL) { - /* - ** It's ok to get the JNIEnv here -- it won't initialize the - ** runtime because it would have already been initialized to - ** create the instance that we're just about to return. - */ + /* + ** It's ok to get the JNIEnv here -- it won't initialize the + ** runtime because it would have already been initialized to + ** create the instance that we're just about to return. + */ /* But first, see if we need to recover the mochaWindow... */ - np_recover_mochaWindow(npn_getJavaEnv(NULL),instance); + np_recover_mochaWindow(npn_getJavaEnv(), instance); - return (jref)instance->javaInstance; - } + return (jref)instance->javaInstance; + } else { - jclass clazz = npn_getJavaClass(instance->handle); - if (clazz) { - JNIEnv* env = npn_getJavaEnv(NULL); /* may start up the java runtime */ - if (classPlugin == NULL) { - /* - ** Make sure we never unload the Plugin class. Why? Because - ** the method and field IDs we're using below have the same - ** lifetime as the class (theoretically): - */ - classPlugin = env->NewGlobalRef(clazz); - } + jclass clazz = npn_getJavaClass(instance->handle); + if (clazz) { + JNIEnv* env = npn_getJavaEnv(); /* may start up the java runtime */ + if (classPlugin == NULL) { + /* + ** Make sure we never unload the Plugin class. Why? Because + ** the method and field IDs we're using below have the same + ** lifetime as the class (theoretically): + */ + classPlugin = env->NewGlobalRef(clazz); + } /* instantiate the plugin's class: */ #define methodname_netscape_plugin_Plugin_new "" #define methodsig_netscape_plugin_Plugin_new "()V" - javaInstance = env->NewObject(clazz, env->GetMethodID(clazz, - methodname_netscape_plugin_Plugin_new, methodsig_netscape_plugin_Plugin_new)); - if (javaInstance) { - instance->javaInstance = env->NewGlobalRef(javaInstance); - np_recover_mochaWindow(env,instance); + javaInstance = env->NewObject(clazz, env->GetMethodID(clazz, + methodname_netscape_plugin_Plugin_new, methodsig_netscape_plugin_Plugin_new)); + if (javaInstance) { + instance->javaInstance = env->NewGlobalRef(javaInstance); + np_recover_mochaWindow(env,instance); /* Store the plugin as the peer: */ #define fieldname_netscape_plugin_Plugin_peer "peer" #define fieldsig_netscape_plugin_Plugin_peer "I" - env->SetIntField(javaInstance, - env->GetFieldID(clazz, - fieldname_netscape_plugin_Plugin_peer, fieldsig_netscape_plugin_Plugin_peer), - (jint)instance->npp); + env->SetIntField(javaInstance, + env->GetFieldID(clazz, + fieldname_netscape_plugin_Plugin_peer, fieldsig_netscape_plugin_Plugin_peer), + (jint)instance->npp); #define methodname_netscape_plugin_Plugin_init "init" #define methodsig_netscape_plugin_Plugin_init "()V" - env->CallVoidMethod(javaInstance, - env->GetMethodID(clazz, - methodname_netscape_plugin_Plugin_init, methodsig_netscape_plugin_Plugin_init)); + env->CallVoidMethod(javaInstance, + env->GetMethodID(clazz, + methodname_netscape_plugin_Plugin_init, methodsig_netscape_plugin_Plugin_init)); - } - if (env->ExceptionOccurred()) { - env->DeleteGlobalRef(instance->javaInstance); - instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */ - env->DeleteGlobalRef(classPlugin); - classPlugin = NULL; - env->ExceptionClear(); - return NULL; - } \ - } - else { - instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */ - return NULL; - } - } - return (jref)javaInstance; -} + } + if (env->ExceptionOccurred()) { + env->DeleteGlobalRef(instance->javaInstance); + instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */ + env->DeleteGlobalRef(classPlugin); + classPlugin = NULL; + env->ExceptionClear(); + return NULL; + } \ + } + else { + instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */ + return NULL; + } + } + return (jref)javaInstance; + #elif defined(JAVA) -jref NP_EXPORT -npn_getJavaPeer(NPP npp) -{ + netscape_plugin_Plugin* javaInstance = NULL; np_instance* instance; @@ -2418,12 +2442,12 @@ npn_getJavaPeer(NPP npp) */ /* But first, see if we need to recover the mochaWindow... */ - np_recover_mochaWindow(npn_getJavaEnv(),instance); + np_recover_mochaWindow(npn_getJavaEnv(), instance); return (jref)JRI_GetGlobalRef(npn_getJavaEnv(), instance->javaInstance); } else { - struct java_lang_Class* clazz = npn_getJavaClass(instance->handle); + jclass clazz = npn_getJavaClass(instance->handle); if (clazz) { JRIEnv* env = npn_getJavaEnv(); /* may start up the java runtime */ if (classPlugin == NULL) { @@ -2456,8 +2480,10 @@ npn_getJavaPeer(NPP npp) } } return (jref)javaInstance; +#else + return NULL; +#endif } -#endif /* JAVA */ #if defined(XP_MAC) && !defined(powerc) #pragma pointers_in_A0 @@ -2502,7 +2528,13 @@ XP_Bool NPL_IsLiveConnected(LO_EmbedStruct *embed) ndata = (np_data*) app->np_data; XP_ASSERT(ndata); - return np_IsLiveConnected(ndata->instance->handle); + if(ndata->instance != NULL) + { + return np_IsLiveConnected(ndata->instance->handle); + } + return FALSE; +#else + return FALSE; #endif } @@ -2543,16 +2575,21 @@ np_setwindow(np_instance *instance, NPWindow *appWin) TRACEMSG(("npglue.c: CallNPP_SetWindowProc")); if (instance->handle->userPlugin) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); - userInst->SetWindow((nsPluginWindow*)appWin); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + if (pluginInst != NULL) { + pluginInst->SetWindow((nsPluginWindow*)appWin); - // If this is the first time we're drawing this, then call - // the plugin's Start() method. - if (lo_struct && ! (lo_struct->objTag.ele_attrmask & LO_ELE_DRAWN)) { - nsPluginError err = userInst->Start(); - if (err != nsPluginError_NoError) { - np_delete_instance(instance); - return PR_FALSE; + // If this is the first time we're drawing this, then call + // the plugin's Start() method. + if (lo_struct && ! (lo_struct->objTag.ele_attrmask & LO_ELE_DRAWN)) { + nsresult err = pluginInst->Start(); + pluginInst->Release(); + if (err != NS_OK) { + np_delete_instance(instance); + return PR_FALSE; + } + } else { + pluginInst->Release(); } } } @@ -2577,7 +2614,7 @@ np_UnloadPluginClass(np_handle *handle) if (handle->userPlugin == NULL && handle->f && handle->f->javaClass != NULL) { /* Don't get the environment unless there is a Java class, because this would cause the java runtime to start up. */ - JNIEnv* env = npn_getJavaEnv(NULL); + JNIEnv* env = npn_getJavaEnv(); env->DeleteGlobalRef((jobject)handle->f->javaClass); handle->f->javaClass = NULL; } @@ -2716,26 +2753,29 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app, /* invite the plugin */ TRACEMSG(("npglue.c: CallNPP_NewProc")); if (handle->userPlugin) { - nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin; + nsIPlugin* pluginClass = (nsIPlugin*)handle->userPlugin; nsPluginInstancePeer* peerInst = new nsPluginInstancePeer(npp); if (peerInst == NULL) { err = NPERR_OUT_OF_MEMORY_ERROR; } else { peerInst->AddRef(); - nsIPluginInstance* userInst; - nsresult err2 = userPluginClass->CreateInstance(NULL, kPluginInstanceIID, - (void**)&userInst); - if (err2 == NS_OK && userInst != NULL) { - nsPluginError err3 = userInst->Initialize(peerInst); - if (err3 == nsPluginError_NoError) { + nsIPluginInstance* pluginInst; + nsresult err2 = pluginClass->CreateInstance(NULL, kPluginInstanceIID, + (void**)&pluginInst); + if (err2 == NS_OK && pluginInst != NULL) { + peerInst->SetPluginInstance(pluginInst); + nsresult err3 = pluginInst->Initialize(peerInst); + if (err3 == NS_OK) { npp->pdata = peerInst; - peerInst->SetUserInstance(userInst); - ndata->sdata = (NPSavedData*)userInst; + ndata->sdata = (NPSavedData*)pluginInst; err = NPERR_NO_ERROR; } - else + else { + // this will release the plugin instance. + peerInst->SetPluginInstance(NULL); err = NPERR_INVALID_INSTANCE_ERROR; + } } else err = NPERR_INVALID_INSTANCE_ERROR; @@ -2816,9 +2856,9 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app, // Finally, if it's a 5.0-style (C++) plugin, send it the Start message. // Do this before sending the mocha OnLoad message. if (handle->userPlugin && ndata->sdata) { - nsIPluginInstance* userInst = (nsIPluginInstance*)ndata->sdata; - nsPluginError err = userInst->Start(); - if (err != nsPluginError_NoError) goto error; + nsIPluginInstance* pluginInst = (nsIPluginInstance*)ndata->sdata; + nsresult err = pluginInst->Start(); + if (err != NS_OK) goto error; } */ @@ -2835,13 +2875,11 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app, /* tell the mocha thread to set us up with the window when it can */ if ( -#if 0 // XXX This is what we really want here, because it doesn't actually // start up the jvm, it just checks that the plugin is LiveConnected. // The problem is that by deferring the jvm startup, we cause it to // happen later on the wrong thread. - np_IsLiveConnected(handle) -#elif defined(JAVA) +#if defined(JAVA) || defined(OJI) npn_getJavaClass(handle) #else FALSE @@ -2922,7 +2960,7 @@ np_newstream(URL_Struct *urls, np_handle *handle, np_instance *instance) TRACEMSG(("npglue.c: CallNPP_NewStreamProc")); if (handle->userPlugin) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); nsPluginStreamPeer* peerStream = new nsPluginStreamPeer(urls, stream); if (peerStream == NULL) { /* XXX where's the error go? */ @@ -2930,17 +2968,19 @@ np_newstream(URL_Struct *urls, np_handle *handle, np_instance *instance) else { peerStream->AddRef(); nsIPluginStream* userStream; - nsPluginError err = userInst->NewStream(peerStream, &userStream); - if (err == nsPluginError_NoError && userStream != NULL) { + nsresult err = pluginInst->NewStream(peerStream, &userStream); + if (err == NS_OK && userStream != NULL) { peerStream->SetUserStream(userStream); pstream->pdata = peerStream; - stype = userStream->GetStreamType(); + nsresult err = userStream->GetStreamType((nsPluginStreamType*)&stype); + PR_ASSERT(err == NS_OK); } else { /* XXX where's the error go? */ } } + pluginInst->Release(); } else if (ISFUNCPTR(handle->f->newstream)) { @@ -3717,13 +3757,17 @@ np_delete_instance(np_instance *instance) TRACEMSG(("npglue.c: CallNPP_DestroyProc")); if (np_is50StylePlugin(instance->handle)) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); - - userInst->SetWindow(NULL); - - nsPluginError err = userInst->Destroy(); - XP_ASSERT(err == nsPluginError_NoError); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + pluginInst->SetWindow(NULL); + + // tell the plugin instance the browser is through with it. + nsresult err = pluginInst->Destroy(); + XP_ASSERT(err == NS_OK); + pluginInst->Release(); + + // break the reference cycle and release the instance peer. + peerInst->SetPluginInstance(NULL); nsrefcnt cnt = peerInst->Release(); XP_ASSERT(cnt == 0); @@ -4000,7 +4044,9 @@ NPL_HandleEvent(NPEmbeddedApp *app, void *event, void* window) TRACEMSG(("npglue.c: CallNPP_HandleEventProc")); if (handle->userPlugin) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)ndata->instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + if (pluginInst == NULL) + return 0; // Note that the new nsPluginEvent struct is different from the // old NPEvent (which is the argument passed in) so we have to @@ -4010,7 +4056,7 @@ NPL_HandleEvent(NPEmbeddedApp *app, void *event, void* window) nsPluginEvent newEvent; #if defined(XP_MAC) newEvent.event = oldEvent; - newEvent.window = window; + newEvent.window = (nsPluginPlatformWindowRef) window; #elif defined(XP_WIN) newEvent.event = oldEvent->event; newEvent.wParam = oldEvent->wParam; @@ -4023,7 +4069,10 @@ NPL_HandleEvent(NPEmbeddedApp *app, void *event, void* window) XP_MEMCPY(&newEvent.event, event, sizeof(XEvent)); // we don't need window for unix -- it's already in the event #endif - return userInst->HandleEvent(&newEvent); + PRBool eventHandled = PR_FALSE; + nsresult result = pluginInst->HandleEvent(&newEvent, &eventHandled); + pluginInst->Release(); + return eventHandled; } else if (handle->f && ISFUNCPTR(handle->f->event)) { // window is not passed through to old-style plugins @@ -4036,26 +4085,35 @@ NPL_HandleEvent(NPEmbeddedApp *app, void *event, void* window) return 0; } -void npn_registerwindow(NPP npp, void* window) +void npn_registerwindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) { #ifdef XP_MAC - if(npp) { +#if 1 + FE_RegisterWindow(handler, window); +#else + if (npp) { np_instance* instance = (np_instance*) npp->ndata; FE_RegisterWindow(instance->app->fe_data, window); } #endif +#endif } -void npn_unregisterwindow(NPP npp, void* window) +void npn_unregisterwindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) { #ifdef XP_MAC +#if 1 + FE_UnregisterWindow(handler, window); +#else if(npp) { np_instance* instance = (np_instance*) npp->ndata; FE_UnregisterWindow(instance->app->fe_data, window); } #endif +#endif } +#if 0 int16 npn_allocateMenuID(NPP npp, XP_Bool isSubmenu) { #ifdef XP_MAC @@ -4066,6 +4124,7 @@ int16 npn_allocateMenuID(NPP npp, XP_Bool isSubmenu) #endif return 0; } +#endif XP_Bool npn_IsWindowless(np_handle* handle) @@ -4113,10 +4172,9 @@ NPL_Print(NPEmbeddedApp *app, void *pdata) TRACEMSG(("npglue.c: CallNPP_PrintProc(1)")); if (handle->userPlugin) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)ndata->instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); - userInst->Print((nsPluginPrint*)pdata); - - + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + pluginInst->Print((nsPluginPrint*)pdata); + pluginInst->Release(); } else if (handle->f && ISFUNCPTR(handle->f->print)) { CallNPP_PrintProc(handle->f->print, ndata->instance->npp, (NPPrint*)pdata); @@ -4131,8 +4189,9 @@ NPL_Print(NPEmbeddedApp *app, void *pdata) TRACEMSG(("npglue.c: CallNPP_PrintProc(2)")); if (handle->userPlugin) { nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)ndata->instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); - userInst->Print((nsPluginPrint*)pdata); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); + pluginInst->Print((nsPluginPrint*)pdata); + pluginInst->Release(); } else if (handle->f && ISFUNCPTR(handle->f->print)) { CallNPP_PrintProc(handle->f->print, ndata->instance->npp, (NPPrint*)pdata); @@ -4224,10 +4283,11 @@ NPL_EmbedDelete(MWContext* cx, LO_EmbedStruct* embed_struct) traversing ndata->sdata, but that scares me for some reason. */ nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*) ndata->instance->npp->pdata; - nsIPluginInstance* userInst = peerInst->GetUserInstance(); + nsIPluginInstance* pluginInst = peerInst->GetPluginInstance(); - nsPluginError err = userInst->Stop(); - if (err == nsPluginError_NoError) { + nsresult err = pluginInst->Stop(); + pluginInst->Release(); + if (err == NS_OK) { /* XXX So I'm going out on a limb here and saying that by keeping the plugin in a "cached" state, we should pretty much not need to perturb much @@ -4429,63 +4489,60 @@ extern "C" PR_IMPLEMENT(struct nsIPluginInstance*) NPL_GetOJIPluginInstance(NPEmbeddedApp *embed) { - struct nsIPluginInstance *psNPIT = NULL; - np_data *ndata = (np_data*) embed->np_data; - np_instance *instance = ndata->instance; - if (instance) - { - nsIPluginInstancePeer *pNPIP = (nsIPluginInstancePeer *)instance->npp->pdata; - nsIPluginInstance *pNPI = ((nsPluginInstancePeer *)pNPIP)->GetUserInstance(); - psNPIT = (struct nsIPluginInstance*)pNPI; - } - return (psNPIT); + nsIPluginInstance* pluginInst = NULL; + np_data *ndata = (np_data*) embed->np_data; + np_instance *instance = ndata->instance; + if (instance != NULL) { + nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata; + pluginInst = peerInst->GetPluginInstance(); + } + return pluginInst; } +#ifdef OJI +static NS_DEFINE_IID(kJVMPluginInstanceIID, NS_IJVMPLUGININSTANCE_IID); +#endif // Used by layout code to get to a text representing a java bean. PR_IMPLEMENT(const char *) -NPL_GetText(struct nsIPluginInstance *psNPIT) +NPL_GetText(nsIPluginInstance* pluginInst) { - nsIPluginInstance *pNPIT = (nsIPluginInstance *)psNPIT; - const char *text = NULL; - - nsIJVMPluginInstance *pJVMPIT = NULL; - NS_DEFINE_IID(kJvmPluginInstanceIID, NS_IJVMPLUGININSTANCE_IID); - if (pNPIT->QueryInterface(kJvmPluginInstanceIID, - (void**)&pJVMPIT) == NS_OK) { - - text = pJVMPIT->GetText(); - pJVMPIT->Release(); - } - return text; + const char *text = NULL; +#ifdef OJI + nsIJVMPluginInstance *jvmInst = NULL; + if (pluginInst->QueryInterface(kJVMPluginInstanceIID, (void**)&jvmInst) == NS_OK) { + nsresult err = jvmInst->GetText(&text); + PR_ASSERT(err == NS_OK); + jvmInst->Release(); + } +#endif + return text; } PR_IMPLEMENT(jobject) -NPL_GetJavaObject(struct nsIPluginInstance *psNPIT) +NPL_GetJavaObject(nsIPluginInstance* pluginInst) { - nsIPluginInstance *pNPIT = (nsIPluginInstance *)psNPIT; - jobject javaobject = NULL; - - nsIJVMPluginInstance *pJVMPIT = NULL; - NS_DEFINE_IID(kJvmPluginInstanceIID, NS_IJVMPLUGININSTANCE_IID); - if (pNPIT->QueryInterface(kJvmPluginInstanceIID, - (void**)&pJVMPIT) == NS_OK) { - - javaobject = pJVMPIT->GetJavaObject(); - pJVMPIT->Release(); - } - return javaobject; + jobject javaobject = NULL; +#if OJI + nsIJVMPluginInstance *jvmInst = NULL; + if (pluginInst->QueryInterface(kJVMPluginInstanceIID, (void**)&jvmInst) == NS_OK) { + nsresult err = jvmInst->GetJavaObject(&javaobject); + PR_ASSERT(err == NS_OK); + jvmInst->Release(); + } +#endif + return javaobject; } -PR_IMPLEMENT(void) NPL_Release(struct nsISupports *psnsISup) +PR_IMPLEMENT(void) NPL_Release(struct nsISupports *supports) { - nsISupports *pnsISup = (nsISupports *)psnsISup; - pnsISup->Release(); + supports->Release(); } PR_IMPLEMENT(XP_Bool) NPL_IsJVMAndMochaPrefsEnabled(void) { XP_Bool bPrefs = PR_FALSE; +#if OJI nsJVMMgr *pJVMMgr = JVM_GetJVMMgr(); if (pJVMMgr != NULL) { @@ -4494,22 +4551,30 @@ PR_IMPLEMENT(XP_Bool) NPL_IsJVMAndMochaPrefsEnabled(void) } pJVMMgr->Release(); } - +#endif return bPrefs; } -PR_IMPLEMENT(void)NPL_JSJInit(void) +PR_IMPLEMENT(PRBool)NPL_JSJInit(void) { + PRBool bJSJInited = PR_FALSE; +#ifdef OJI nsJVMMgr* pJVMMgr = JVM_GetJVMMgr(); if (pJVMMgr != NULL) { - pJVMMgr->JSJInit(); - pJVMMgr->Release(); + bJSJInited = pJVMMgr->JSJInit(); + pJVMMgr->Release(); } +#endif + return bJSJInited; } PR_IMPLEMENT(JNIEnv *)NPL_EnsureJNIExecEnv(PRThread* thread) { - return npn_getJavaEnv(thread); +#ifdef OJI + return npn_getJavaEnv(); +#else + return NULL; +#endif } diff --git a/modules/plugin/src/npglue.h b/modules/plugin/src/npglue.h index b841d7fed632..987ce4af373d 100644 --- a/modules/plugin/src/npglue.h +++ b/modules/plugin/src/npglue.h @@ -62,6 +62,7 @@ extern "C" { plugin code, it is never actually dereferenced outside of an `#ifdef OJI'. */ struct nsIJVMManager; +class nsHashtable; #endif /* OJI */ extern int XP_PLUGIN_LOADING_PLUGIN; @@ -200,13 +201,15 @@ void NP_EXPORT npn_status(NPP npp, const char *message); void NP_EXPORT -npn_registerwindow(NPP npp, void* window); +npn_registerwindow(struct nsIEventHandler* handler, nsPluginPlatformWindowRef window); void NP_EXPORT -npn_unregisterwindow(NPP npp, void* window); +npn_unregisterwindow(struct nsIEventHandler* handler, nsPluginPlatformWindowRef window); +#if 0 int16 NP_EXPORT npn_allocateMenuID(NPP npp, XP_Bool isSubmenu); +#endif #if defined(XP_MAC) && !defined(powerc) #pragma pointers_in_D0 @@ -250,7 +253,7 @@ npn_forceredraw(NPP npp); #endif #if defined(OJI) JNIEnv* NP_EXPORT -npn_getJavaEnv(PRThread *pPRThread); +npn_getJavaEnv(void); #else JRIEnv* NP_EXPORT npn_getJavaEnv(void); @@ -272,61 +275,96 @@ npn_getJavaPeer(NPP npp); /* End of function prototypes */ - /* this is a hack for now */ #define NP_MAXBUF (0xE000) //////////////////////////////////////////////////////////////////////////////// -class nsPluginManager : public nsIPluginManager2 { +class nsPluginManager : public nsIPluginManager2, + public nsINetworkManager +{ public: //////////////////////////////////////////////////////////////////////////// // from nsIPluginManager: + NS_IMETHOD + GetValue(nsPluginManagerVariable variable, void *value); + + NS_IMETHOD + SetValue(nsPluginManagerVariable variable, void *value); + // (Corresponds to NPN_ReloadPlugins.) - NS_IMETHOD_(void) + NS_IMETHOD ReloadPlugins(PRBool reloadPages); - // (Corresponds to NPN_MemAlloc.) - NS_IMETHOD_(void*) - MemAlloc(PRUint32 size); - - // (Corresponds to NPN_MemFree.) - NS_IMETHOD_(void) - MemFree(void* ptr); - - // (Corresponds to NPN_MemFlush.) - NS_IMETHOD_(PRUint32) - MemFlush(PRUint32 size); - // (Corresponds to NPN_UserAgent.) - NS_IMETHOD_(const char*) - UserAgent(void); - - // (Corresponds to NPN_GetURL and NPN_GetURLNotify.) - NS_IMETHOD_(nsPluginError) - GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData, - const char* altHost, const char* referer, PRBool forceJSEnabled); - - // (Corresponds to NPN_PostURL and NPN_PostURLNotify.) - NS_IMETHOD_(nsPluginError) - PostURL(nsISupports* peer, const char* url, const char* target, - PRUint32 len, const char* buf, PRBool file, void* notifyData, - const char* altHost, const char* referer, PRBool forceJSEnabled, - PRUint32 postHeadersLength, const char* postHeaders); + NS_IMETHOD + UserAgent(const char* *result); //////////////////////////////////////////////////////////////////////////// // from nsIPluginManager2: - NS_IMETHOD_(void) + NS_IMETHOD BeginWaitCursor(void); - NS_IMETHOD_(void) + NS_IMETHOD EndWaitCursor(void); - NS_IMETHOD_(PRBool) - SupportsURLProtocol(const char* protocol); + NS_IMETHOD + SupportsURLProtocol(const char* protocol, PRBool *result); + + // This method may be called by the plugin to indicate that an error has + // occurred, e.g. that the plugin has failed or is shutting down spontaneously. + // This allows the browser to clean up any plugin-specific state. + NS_IMETHOD + NotifyStatusChange(nsIPlugin* plugin, nsresult errorStatus); + + //////////////////////////////////////////////////////////////////////////// + // New top-level window handling calls for Mac: + + NS_IMETHOD + RegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window); + + NS_IMETHOD + UnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window); + + // Menu ID allocation calls for Mac: + NS_IMETHOD + AllocateMenuID(nsIEventHandler* handler, PRBool isSubmenu, PRInt16 *result); + + NS_IMETHOD + DeallocateMenuID(nsIEventHandler* handler, PRInt16 menuID); + + /** + * Indicates whether this event handler has allocated the given menu ID. + */ + NS_IMETHOD + HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result); + + // On the mac (and most likely win16), network activity can + // only occur on the main thread. Therefore, we provide a hook + // here for the case that the main thread needs to tickle itself. + // In this case, we make sure that we give up the monitor so that + // the tickle code can notify it without freezing. + NS_IMETHOD + ProcessNextEvent(PRBool *bEventHandled); + + //////////////////////////////////////////////////////////////////////////// + // from nsINetworkManager: + + NS_IMETHOD + GetURL(nsISupports* peer, const char* url, const char* target, + void* notifyData = NULL, const char* altHost = NULL, + const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE); + + NS_IMETHOD + PostURL(nsISupports* peer, const char* url, const char* target, + PRUint32 postDataLen, const char* postData, + PRBool isFile = PR_FALSE, void* notifyData = NULL, + const char* altHost = NULL, const char* referrer = NULL, + PRBool forceJSEnabled = PR_FALSE, + PRUint32 postHeadersLength = 0, const char* postHeaders = NULL); //////////////////////////////////////////////////////////////////////////// // nsPluginManager specific methods: @@ -335,7 +373,7 @@ public: static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); - + protected: nsPluginManager(nsISupports* outer); virtual ~nsPluginManager(void); @@ -344,8 +382,11 @@ protected: nsIJVMManager* GetJVMMgr(const nsIID& aIID); nsISupports* fJVMMgr; + nsISupports* fMalloc; PRUint16 fWaiting; void* fOldCursor; + + nsHashtable* fAllocatedMenuIDs; }; extern nsPluginManager* thePluginManager; @@ -358,18 +399,14 @@ public: //////////////////////////////////////////////////////////////////////////// // from nsIFileUtilities: - NS_IMETHOD_(const char*) - GetProgramPath(void); + NS_IMETHOD + GetProgramPath(const char* *result); - NS_IMETHOD_(const char*) - GetTempDirPath(void); + NS_IMETHOD + GetTempDirPath(const char* *result); - NS_IMETHOD_(nsresult) - GetFileName(const char* fn, FileNameType type, - char* resultBuf, PRUint32 bufLen); - - NS_IMETHOD_(nsresult) - NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen); + NS_IMETHOD + NewTempFileName(const char* prefix, PRUint32 bufLen, char* resultBuf); //////////////////////////////////////////////////////////////////////////// // nsFileUtilities specific methods: @@ -391,7 +428,7 @@ typedef struct JSContext JSContext; class nsPluginTagInfo; -class nsPluginInstancePeer : public nsIPluginInstancePeer2, +class nsPluginInstancePeer : public nsIPluginInstancePeer, public nsILiveConnectPluginInstancePeer, public nsIWindowlessPluginInstancePeer { @@ -400,70 +437,48 @@ public: //////////////////////////////////////////////////////////////////////////// // from nsIPluginInstancePeer: + NS_IMETHOD + GetValue(nsPluginInstancePeerVariable variable, void *value); + + NS_IMETHOD + SetValue(nsPluginInstancePeerVariable variable, void *value); + // (Corresponds to NPP_New's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetMIMEType(nsMIMEType *result); // (Corresponds to NPP_New's mode argument.) - NS_IMETHOD_(nsPluginType) - GetMode(void); + NS_IMETHOD + GetMode(nsPluginMode *result); // (Corresponds to NPN_NewStream.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result); // (Corresponds to NPN_Status.) - NS_IMETHOD_(void) + NS_IMETHOD ShowStatus(const char* message); - // (Corresponds to NPN_GetValue.) - NS_IMETHOD_(nsPluginError) - GetValue(nsPluginManagerVariable variable, void *value); - - // (Corresponds to NPN_SetValue.) - NS_IMETHOD_(nsPluginError) - SetValue(nsPluginVariable variable, void *value); - - //////////////////////////////////////////////////////////////////////////// - // from nsIPluginInstancePeer2: - - NS_IMETHOD_(void) - RegisterWindow(void* window); - - NS_IMETHOD_(void) - UnregisterWindow(void* window); - - NS_IMETHOD_(PRInt16) - AllocateMenuID(PRBool isSubmenu); - - // On the mac (and most likely win16), network activity can - // only occur on the main thread. Therefore, we provide a hook - // here for the case that the main thread needs to tickle itself. - // In this case, we make sure that we give up the monitor so that - // the tickle code can notify it without freezing. - NS_IMETHOD_(PRBool) - Tickle(void); - //////////////////////////////////////////////////////////////////////////// // from nsIJRILiveConnectPluginInstancePeer: // (Corresponds to NPN_GetJavaPeer.) - NS_IMETHOD_(jobject) - GetJavaPeer(void); + NS_IMETHOD + GetJavaPeer(jobject *result); //////////////////////////////////////////////////////////////////////////// // from nsIWindowlessPluginInstancePeer: // (Corresponds to NPN_InvalidateRect.) - NS_IMETHOD_(void) - InvalidateRect(nsRect *invalidRect); + NS_IMETHOD + InvalidateRect(nsPluginRect *invalidRect); // (Corresponds to NPN_InvalidateRegion.) - NS_IMETHOD_(void) - InvalidateRegion(nsRegion invalidRegion); + NS_IMETHOD + InvalidateRegion(nsPluginRegion invalidRegion); // (Corresponds to NPN_ForceRedraw.) - NS_IMETHOD_(void) + NS_IMETHOD ForceRedraw(void); //////////////////////////////////////////////////////////////////////////// @@ -472,18 +487,12 @@ public: nsPluginInstancePeer(NPP npp); virtual ~nsPluginInstancePeer(void); - NS_DECL_AGGREGATED + NS_DECL_ISUPPORTS - nsIPluginInstance* GetUserInstance(void) { - userInst->AddRef(); - return userInst; - } - - void SetUserInstance(nsIPluginInstance* inst) { - userInst = inst; - } + void SetPluginInstance(nsIPluginInstance* inst); + nsIPluginInstance* GetPluginInstance(void); - NPP GetNPP(void) { return npp; } + NPP GetNPP(void); JSContext *GetJSContext(void); MWContext *GetMWContext(void); protected: @@ -491,11 +500,10 @@ protected: // NPP is the old plugin structure. If we were implementing this // from scratch we wouldn't use it, but for now we're calling the old // npglue.c routines wherever possible. - NPP npp; - - nsIPluginInstance* userInst; - nsPluginTagInfo* tagInfo; + NPP fNPP; + nsIPluginInstance* fPluginInst; + nsPluginTagInfo* fTagInfo; }; #define NS_PLUGININSTANCEPEER_CID \ @@ -519,66 +527,66 @@ public: // // Each name or value is a null-terminated string. // - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values); // Get the value for the named attribute. Returns null // if the attribute was not set. - NS_IMETHOD_(const char*) - GetAttribute(const char* name); + NS_IMETHOD + GetAttribute(const char* name, const char* *result); //////////////////////////////////////////////////////////////////////////// // from nsIPluginTagInfo2: // Get the type of the HTML tag that was used ot instantiate this // plugin. Currently supported tags are EMBED, OBJECT and APPLET. - NS_IMETHOD_(nsPluginTagType) - GetTagType(void); + NS_IMETHOD + GetTagType(nsPluginTagType *result); // Get the complete text of the HTML tag that was // used to instantiate this plugin - NS_IMETHOD_(const char *) - GetTagText(void); + NS_IMETHOD + GetTagText(const char * *result); // Get a ptr to the paired list of parameter names and values, // returns the length of the array. // // Each name or value is a null-terminated string. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetParameters(PRUint16& n, const char*const*& names, const char*const*& values); // Get the value for the named parameter. Returns null // if the parameter was not set. - NS_IMETHOD_(const char*) - GetParameter(const char* name); + NS_IMETHOD + GetParameter(const char* name, const char* *result); - NS_IMETHOD_(const char*) - GetDocumentBase(void); + NS_IMETHOD + GetDocumentBase(const char* *result); // Return an encoding whose name is specified in: // http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303 - NS_IMETHOD_(const char*) - GetDocumentEncoding(void); + NS_IMETHOD + GetDocumentEncoding(const char* *result); - NS_IMETHOD_(const char*) - GetAlignment(void); + NS_IMETHOD + GetAlignment(const char* *result); - NS_IMETHOD_(PRUint32) - GetWidth(void); + NS_IMETHOD + GetWidth(PRUint32 *result); - NS_IMETHOD_(PRUint32) - GetHeight(void); + NS_IMETHOD + GetHeight(PRUint32 *result); - NS_IMETHOD_(PRUint32) - GetBorderVertSpace(void); + NS_IMETHOD + GetBorderVertSpace(PRUint32 *result); - NS_IMETHOD_(PRUint32) - GetBorderHorizSpace(void); + NS_IMETHOD + GetBorderHorizSpace(PRUint32 *result); // Returns a unique id for the current document on which the // plugin is displayed. - NS_IMETHOD_(PRUint32) - GetUniqueID(void); + NS_IMETHOD + GetUniqueID(PRUint32 *result); //////////////////////////////////////////////////////////////////////////// // nsPluginTagInfo specific methods: @@ -618,9 +626,15 @@ public: //////////////////////////////////////////////////////////////////////////// // from nsIOutputStream: - NS_IMETHOD_(PRInt32) - Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, - nsresult *errorResult); + /** Write data into the stream. + * @param aBuf the buffer into which the data is read + * @param aOffset the start offset of the data + * @param aCount the maximum number of bytes to read + * @return number of bytes read or an error if < 0 + */ + NS_IMETHOD + Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, + PRInt32 *resultingCount); //////////////////////////////////////////////////////////////////////////// // nsPluginManagerStream specific methods: @@ -638,9 +652,8 @@ protected: //////////////////////////////////////////////////////////////////////////////// -class nsPluginStreamPeer : - virtual public nsIPluginStreamPeer2, - virtual public nsISeekablePluginStreamPeer +class nsPluginStreamPeer : public nsIPluginStreamPeer2, + public nsISeekablePluginStreamPeer { public: @@ -648,49 +661,49 @@ public: // from nsIPluginStreamPeer: // (Corresponds to NPStream's url field.) - NS_IMETHOD_(const char*) - GetURL(void); + NS_IMETHOD + GetURL(const char* *result); // (Corresponds to NPStream's end field.) - NS_IMETHOD_(PRUint32) - GetEnd(void); + NS_IMETHOD + GetEnd(PRUint32 *result); // (Corresponds to NPStream's lastmodified field.) - NS_IMETHOD_(PRUint32) - GetLastModified(void); + NS_IMETHOD + GetLastModified(PRUint32 *result); // (Corresponds to NPStream's notifyData field.) - NS_IMETHOD_(void*) - GetNotifyData(void); + NS_IMETHOD + GetNotifyData(void* *result); // (Corresponds to NPP_DestroyStream's reason argument.) - NS_IMETHOD_(nsPluginReason) - GetReason(void); + NS_IMETHOD + GetReason(nsPluginReason *result); // (Corresponds to NPP_NewStream's MIMEType argument.) - NS_IMETHOD_(nsMIMEType) - GetMIMEType(void); + NS_IMETHOD + GetMIMEType(nsMIMEType *result); //////////////////////////////////////////////////////////////////////////// // from nsIPluginStreamPeer2: - NS_IMETHOD_(PRUint32) - GetContentLength(void); + NS_IMETHOD + GetContentLength(PRUint32 *result); - NS_IMETHOD_(PRUint32) - GetHeaderFieldCount(void); + NS_IMETHOD + GetHeaderFieldCount(PRUint32 *result); - NS_IMETHOD_(const char*) - GetHeaderFieldKey(PRUint32 index); + NS_IMETHOD + GetHeaderFieldKey(PRUint32 index, const char* *result); - NS_IMETHOD_(const char*) - GetHeaderField(PRUint32 index); + NS_IMETHOD + GetHeaderField(PRUint32 index, const char* *result); //////////////////////////////////////////////////////////////////////////// // from nsISeekablePluginStreamPeer: // (Corresponds to NPN_RequestRead.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD RequestRead(nsByteRange* rangeList); //////////////////////////////////////////////////////////////////////////// diff --git a/modules/plugin/src/nppg.h b/modules/plugin/src/nppg.h index 5106de1bc44f..48b023015a6f 100644 --- a/modules/plugin/src/nppg.h +++ b/modules/plugin/src/nppg.h @@ -17,7 +17,7 @@ */ /* - * nppg.h $Revision: 1.1 $ + * nppg.h $Revision: 1.2 $ * Prototypes for functions exported by the FEs and called by libplugin. * Some (perhaps all) of these prototypes could be moved to fe_proto.h. * Protypes for functions exported by libplugin are in np.h. @@ -44,9 +44,9 @@ extern void FE_FreeEmbedSessionData(MWContext *context, NPEmbeddedApp* pApp); #ifdef XP_MAC extern void FE_PluginProgress(MWContext *context, const char *message); extern void FE_ResetRefreshURLTimer(MWContext *context); -extern void FE_RegisterWindow(void* plugin, void* window); -extern void FE_UnregisterWindow(void* plugin, void* window); -extern SInt16 FE_AllocateMenuID(void *plugin, XP_Bool isSubmenu); +extern void FE_RegisterWindow(struct nsIEventHandler* handler, void* window); +extern void FE_UnregisterWindow(struct nsIEventHandler*, void* window); +// extern SInt16 FE_AllocateMenuID(void *plugin, XP_Bool isSubmenu); #endif #ifdef XP_UNIX diff --git a/modules/plugin/src/nsplugin.cpp b/modules/plugin/src/nsplugin.cpp index 1c4fd22b9592..54f2a2c7e33a 100644 --- a/modules/plugin/src/nsplugin.cpp +++ b/modules/plugin/src/nsplugin.cpp @@ -25,9 +25,10 @@ //////////////////////////////////////////////////////////////////////////////// #include "npglue.h" +#include "np.h" #ifdef OJI -#include "nsIPlug.h" +#include "nsplugin.h" #include "jvmmgr.h" #endif #include "plstr.h" /* PL_strcasecmp */ @@ -38,19 +39,25 @@ #ifdef XP_MAC #include "MacMemAllocator.h" #include "asyncCursors.h" +#include "LMenuSharing.h" +#include #endif +#include "nsHashtable.h" +#include "nsMalloc.h" + #include "intl_csi.h" -static NS_DEFINE_IID(kIJRIEnvIID, NS_IJRIENV_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); static NS_DEFINE_IID(kIPluginManager2IID, NS_IPLUGINMANAGER2_IID); +static NS_DEFINE_IID(kINetworkManagerIID, NS_INETWORKMANAGER_IID); static NS_DEFINE_IID(kIJNIEnvIID, NS_IJNIENV_IID); -static NS_DEFINE_IID(kILiveConnectPluginInstancePeerIID, NS_ILIVECONNECTPLUGININSTANCEPEER_IID); +static NS_DEFINE_IID(kILiveConnectPluginInstancePeerIID, NS_ILIVECONNECTPLUGININSTANCEPEER_IID); +static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININSTANCEPEER_IID); +static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID); static NS_DEFINE_IID(kPluginInstancePeerCID, NS_PLUGININSTANCEPEER_CID); static NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); -static NS_DEFINE_IID(kIPluginInstancePeer2IID, NS_IPLUGININSTANCEPEER2_IID); static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID); static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID); static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID); @@ -59,6 +66,26 @@ static NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); static NS_DEFINE_IID(kIPluginStreamPeer2IID, NS_IPLUGINSTREAMPEER2_IID); static NS_DEFINE_IID(kIFileUtilitiesIID, NS_IFILEUTILITIES_IID); +#include "prerror.h" + +// mapping from NPError to nsresult +nsresult fromNPError[] = { + NS_OK, // NPERR_NO_ERROR, + NS_ERROR_FAILURE, // NPERR_GENERIC_ERROR, + NS_ERROR_FAILURE, // NPERR_INVALID_INSTANCE_ERROR, + NS_ERROR_NOT_INITIALIZED, // NPERR_INVALID_FUNCTABLE_ERROR, + NS_ERROR_FACTORY_NOT_LOADED, // NPERR_MODULE_LOAD_FAILED_ERROR, + NS_ERROR_OUT_OF_MEMORY, // NPERR_OUT_OF_MEMORY_ERROR, + NS_NOINTERFACE, // NPERR_INVALID_PLUGIN_ERROR, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PLUGIN_DIR_ERROR, + NS_NOINTERFACE, // NPERR_INCOMPATIBLE_VERSION_ERROR, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PARAM, + NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_URL, + NS_ERROR_ILLEGAL_VALUE, // NPERR_FILE_NOT_FOUND, + NS_ERROR_FAILURE, // NPERR_NO_DATA, + NS_ERROR_FAILURE // NPERR_STREAM_NOT_SEEKABLE, +}; + //////////////////////////////////////////////////////////////////////////////// // THINGS IMPLEMENTED BY THE BROWSER... //////////////////////////////////////////////////////////////////////////////// @@ -73,7 +100,7 @@ static NS_DEFINE_IID(kIFileUtilitiesIID, NS_IFILEUTILITIES_IID); nsPluginManager* thePluginManager = NULL; nsPluginManager::nsPluginManager(nsISupports* outer) - : fJVMMgr(NULL) + : fJVMMgr(NULL), fMalloc(NULL), fAllocatedMenuIDs(NULL) { NS_INIT_AGGREGATED(outer); } @@ -82,12 +109,19 @@ nsPluginManager::~nsPluginManager(void) { fJVMMgr->Release(); fJVMMgr = NULL; + fMalloc->Release(); + fMalloc = NULL; + +#ifdef XP_MAC + if (fAllocatedMenuIDs != NULL) { + // Fix me, delete all the elements before deleting the table. + delete fAllocatedMenuIDs; + } +#endif } NS_IMPL_AGGREGATED(nsPluginManager); -#include "nsRepository.h" - NS_METHOD nsPluginManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) { @@ -101,39 +135,32 @@ nsPluginManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInstanceP return result; } -NS_METHOD_(void) +NS_METHOD +nsPluginManager::GetValue(nsPluginManagerVariable variable, void *value) +{ + NPError err = npn_getvalue(NULL, (NPNVariable)variable, value); + return fromNPError[err]; +} + +NS_METHOD +nsPluginManager::SetValue(nsPluginManagerVariable variable, void *value) +{ + NPError err = npn_setvalue(NULL, (NPPVariable)variable, value); + return fromNPError[err]; +} + +NS_METHOD nsPluginManager::ReloadPlugins(PRBool reloadPages) { npn_reloadplugins(reloadPages); + return NS_OK; } -NS_METHOD_(void*) -nsPluginManager::MemAlloc(PRUint32 size) +NS_METHOD +nsPluginManager::UserAgent(const char* *resultingAgentString) { - return XP_ALLOC(size); -} - -NS_METHOD_(void) -nsPluginManager::MemFree(void* ptr) -{ - (void)XP_FREE(ptr); -} - -NS_METHOD_(PRUint32) -nsPluginManager::MemFlush(PRUint32 size) -{ -#ifdef XP_MAC - /* Try to free some memory and return the amount we freed. */ - if (CallCacheFlushers(size)) - return size; -#endif - return 0; -} - -NS_METHOD_(const char*) -nsPluginManager::UserAgent(void) -{ - return npn_useragent(NULL); // we don't really need an npp here + *resultingAgentString = npn_useragent(NULL); // we don't really need an npp here + return NS_OK; } NS_METHOD @@ -145,7 +172,12 @@ nsPluginManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr if (aIID.Equals(kIPluginManagerIID) || aIID.Equals(kIPluginManager2IID) || aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) this; + *aInstancePtr = (nsIPluginManager*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kINetworkManagerIID)) { + *aInstancePtr = (nsINetworkManager*) this; AddRef(); return NS_OK; } @@ -157,25 +189,27 @@ nsPluginManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr // AddRef(); // XXX should the plugin instance peer and the env be linked? return NS_OK; } -#endif +#endif +#ifdef OJI if (aIID.Equals(kIJNIEnvIID)) { // XXX Need to implement ISupports for JNIEnv - *aInstancePtr = (void*) ((nsISupports*)npn_getJavaEnv(NULL)); //=-= Fix this to return a Interface XXX need JNI version + *aInstancePtr = (void*) ((nsISupports*)npn_getJavaEnv()); //=-= Fix this to return a Interface XXX need JNI version // AddRef(); // XXX should the plugin instance peer and the env be linked? return NS_OK; } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) ((nsISupports*)this); - AddRef(); - return NS_OK; - } +#endif // Aggregates... nsIJVMManager* jvmMgr = GetJVMMgr(aIID); if (jvmMgr) { *aInstancePtr = (void*) ((nsISupports*)jvmMgr); return NS_OK; } - return NS_NOINTERFACE; + if (fMalloc == NULL) { + if (nsMalloc::Create((nsIPluginManager*)this, kISupportsIID, + (void**)&fMalloc) != NS_OK) + return NS_NOINTERFACE; + } + return fMalloc->QueryInterface(aIID, aInstancePtr); } nsIJVMManager* @@ -185,7 +219,8 @@ nsPluginManager::GetJVMMgr(const nsIID& aIID) #ifdef OJI if (fJVMMgr == NULL) { // The plugin manager is the outer of the JVM manager - if (nsJVMMgr::Create(this, kISupportsIID, (void**)&fJVMMgr) != NS_OK) + if (nsJVMMgr::Create((nsIPluginManager*)this, kISupportsIID, + (void**)&fJVMMgr) != NS_OK) return NULL; } if (fJVMMgr->QueryInterface(aIID, (void**)&result) != NS_OK) @@ -194,43 +229,7 @@ nsPluginManager::GetJVMMgr(const nsIID& aIID) return result; } -NS_METHOD_(nsPluginError) -nsPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, void* notifyData, - const char* altHost, const char* referrer, - PRBool forceJSEnabled) -{ - nsPluginError rslt; - nsPluginInstancePeer* instPeer; - NPP npp = NULL; - if (peer->QueryInterface(kPluginInstancePeerCID, (void**)&instPeer) == NS_OK) - npp = instPeer->GetNPP(); - rslt = (nsPluginError)np_geturlinternal(npp, url, target, altHost, referrer, - forceJSEnabled, notifyData != NULL, notifyData); - if (npp) - instPeer->Release(); - return rslt; -} - -NS_METHOD_(nsPluginError) -nsPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 bufLen, - const char* buf, PRBool file, void* notifyData, - const char* altHost, const char* referrer, - PRBool forceJSEnabled, - PRUint32 postHeadersLength, const char* postHeaders) -{ - nsPluginError rslt; - nsPluginInstancePeer* instPeer; - NPP npp = NULL; - if (peer->QueryInterface(kPluginInstancePeerCID, (void**)&instPeer) == NS_OK) - npp = instPeer->GetNPP(); - rslt = (nsPluginError)np_posturlinternal(npp, url, target, altHost, referrer, forceJSEnabled, - bufLen, buf, file, notifyData != NULL, notifyData); - if (npp) - instPeer->Release(); - return rslt; -} - -NS_METHOD_(void) +NS_METHOD nsPluginManager::BeginWaitCursor(void) { if (fWaiting == 0) { @@ -245,9 +244,10 @@ nsPluginManager::BeginWaitCursor(void) #endif } fWaiting++; + return NS_OK; } -NS_METHOD_(void) +NS_METHOD nsPluginManager::EndWaitCursor(void) { fWaiting--; @@ -261,13 +261,371 @@ nsPluginManager::EndWaitCursor(void) #endif fOldCursor = NULL; } + return NS_OK; } -NS_METHOD_(PRBool) -nsPluginManager::SupportsURLProtocol(const char* protocol) +NS_METHOD +nsPluginManager::SupportsURLProtocol(const char* protocol, PRBool *result) { int type = NET_URL_Type(protocol); - return (PRBool)(type != 0); + *result = (PRBool)(type != 0); + return NS_OK; +} + +NS_METHOD +nsPluginManager::NotifyStatusChange(nsIPlugin* plugin, nsresult errorStatus) +{ + // XXX need to shut down all instances of this plugin + return NS_OK; +} + +#if 0 +static NPP getNPPFromHandler(nsIEventHandler* handler) +{ + NPP npp = NULL; + nsIPluginInstance* pluginInst = NULL; + if (handler->QueryInterface(kIPluginInstanceIID, (void**)&pluginInst) == NS_OK) { + nsPluginInstancePeer* myPeer; + nsresult err = pluginInst->GetPeer((nsIPluginInstancePeer**)&myPeer); + PR_ASSERT(err == NS_OK); + npp = myPeer->GetNPP(); + myPeer->Release(); + pluginInst->Release(); + } + return npp; +} +#endif + +NS_METHOD +nsPluginManager::RegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) +{ +#if 1 + npn_registerwindow(handler, window); + return NS_OK; +#else + NPP npp = getNPPFromHandler(handler); + if (npp != NULL) { + npn_registerwindow(npp, window); + return NS_OK; + } + return NS_ERROR_FAILURE; +#endif +} + +NS_METHOD +nsPluginManager::UnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window) +{ +#if 1 + npn_unregisterwindow(handler, window); + return NS_OK; +#else + NPP npp = getNPPFromHandler(handler); + if (npp != NULL) { + npn_unregisterwindow(npp, window); + return NS_OK; + } + return NS_ERROR_FAILURE; +#endif +} + +class nsEventHandlerKey : public nsHashKey { +public: + nsEventHandlerKey(nsIEventHandler* handler) : mHandler(handler) {} + + virtual PRUint32 HashValue(void) const + { + return PRUint32(mHandler); + } + + virtual PRBool Equals(const nsHashKey *aKey) const + { + return ((nsEventHandlerKey*)aKey)->mHandler == mHandler; + } + + virtual nsHashKey *Clone(void) const + { + return new nsEventHandlerKey(mHandler); + } + +private: + nsIEventHandler* mHandler; +}; + +NS_METHOD +nsPluginManager::AllocateMenuID(nsIEventHandler* handler, PRBool isSubmenu, + PRInt16 *result) +{ +#ifdef XP_MAC + PRInt16 menuID = LMenuSharingAttachment::AllocatePluginMenuID(isSubmenu); + if (fAllocatedMenuIDs == NULL) + fAllocatedMenuIDs = new nsHashtable(16); + if (fAllocatedMenuIDs != NULL) { + nsEventHandlerKey key(handler); + TArray* menuIDs = (TArray*) fAllocatedMenuIDs->Get(&key); + if (menuIDs == NULL) { + menuIDs = new TArray; + fAllocatedMenuIDs->Put(&key, menuIDs); + } + if (menuIDs != NULL) + menuIDs->AddItem(menuID); + } + *result = menuID; + return NS_OK; +#else + return NS_ERROR_NOT_IMPLEMENTED; +#endif +} + +NS_METHOD +nsPluginManager::DeallocateMenuID(nsIEventHandler* handler, PRInt16 menuID) +{ +#ifdef XP_MAC + if (fAllocatedMenuIDs != NULL) { + nsEventHandlerKey key(handler); + TArray* menuIDs = (TArray*) fAllocatedMenuIDs->Get(&key); + if (menuIDs != NULL) { + menuIDs->Remove(menuID); + if (menuIDs->GetCount() == 0) { + // let go of the vector and the hash table entry. + fAllocatedMenuIDs->Remove(&key); + delete menuIDs; + } + return NS_OK; + } + } + return NS_ERROR_FAILURE; +#else + return NS_ERROR_NOT_IMPLEMENTED; +#endif +} + +NS_METHOD +nsPluginManager::HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result) +{ +#ifdef XP_MAC + if (fAllocatedMenuIDs != NULL) { + nsEventHandlerKey key(handler); + TArray* menuIDs = (TArray*) fAllocatedMenuIDs->Get(&key); + if (menuIDs != NULL) { + TArray& menus = *menuIDs; + UInt32 count = menus.GetCount(); + for (UInt32 i = count; i > 0; --i) { + if (menus[i] == menuID) { + *result = PR_TRUE; + return NS_OK; + } + } + } + } + return PR_FALSE; +#else + return NS_ERROR_NOT_IMPLEMENTED; +#endif +} + +static NPL_ProcessNextEventProc npl_ProcessNextEventProc = NULL; +static void* npl_ProcessNextEventData = NULL; + +PR_IMPLEMENT(void) +NPL_InstallProcessNextEventProc(NPL_ProcessNextEventProc proc, void* data) +{ + npl_ProcessNextEventProc = proc; + npl_ProcessNextEventData = data; +} + +NS_METHOD +nsPluginManager::ProcessNextEvent(PRBool *bEventHandled) +{ +#ifdef XP_MAC + if (npl_ProcessNextEventProc != NULL) + *bEventHandled = npl_ProcessNextEventProc(npl_ProcessNextEventData); + return NS_OK; +#else + *bEventHandled = PR_FALSE; + return NS_OK; +#endif +} + +//////////////////////////////////////////////////////////////////////////////// +// from nsINetworkManager: + +#include "plevent.h" + +extern "C" { +extern PREventQueue* mozilla_event_queue; +extern PRThread* mozilla_thread; +}; + +struct GetURLEvent { + PLEvent event; + nsPluginInstancePeer* peer; + const char* url; + const char* target; + void* notifyData; + const char* altHost; + const char* referrer; + PRBool forceJSEnabled; +}; + +static void* +HandleGetURLEvent(PLEvent* event) +{ + PR_ASSERT(PR_CurrentThread() == mozilla_thread); + GetURLEvent* e = (GetURLEvent*)event; + NPP npp = e->peer->GetNPP(); + NPError rslt = np_geturlinternal(npp, + e->url, + e->target, + e->altHost, + e->referrer, + e->forceJSEnabled, + e->notifyData != NULL, + e->notifyData); + return (void*)rslt; +} + +static void +DestroyGetURLEvent(PLEvent* event) +{ + GetURLEvent* e = (GetURLEvent*)event; + PR_Free(event); +} + +NS_METHOD +nsPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, + void* notifyData, const char* altHost, + const char* referrer, PRBool forceJSEnabled) +{ + NPError rslt = NPERR_INVALID_PARAM; + nsPluginInstancePeer* instPeer = NULL; + if (peer->QueryInterface(kPluginInstancePeerCID, (void**)&instPeer) == NS_OK) { + if (PR_CurrentThread() == mozilla_thread) { + NPP npp = instPeer->GetNPP(); + rslt = np_geturlinternal(npp, + url, + target, + altHost, + referrer, + forceJSEnabled, + notifyData != NULL, + notifyData); + } + else { + GetURLEvent* e = PR_NEW(GetURLEvent); + if (e == NULL) { + rslt = NPERR_OUT_OF_MEMORY_ERROR; + } + else { + PL_InitEvent(&e->event, NULL, HandleGetURLEvent, DestroyGetURLEvent); + e->peer = instPeer; + e->url = url; + e->target = target; + e->notifyData = notifyData; + e->altHost = altHost; + e->referrer = referrer; + e->forceJSEnabled = forceJSEnabled; + rslt = (NPError)PL_PostSynchronousEvent(mozilla_event_queue, &e->event); + } + } + instPeer->Release(); + } + return fromNPError[rslt]; +} + +struct PostURLEvent { + PLEvent event; + nsPluginInstancePeer* peer; + const char* url; + const char* target; + PRUint32 postDataLen; + const char* postData; + PRBool isFile; + void* notifyData; + const char* altHost; + const char* referrer; + PRBool forceJSEnabled; + PRUint32 postHeadersLen; + const char* postHeaders; +}; + +static void* +HandlePostURLEvent(PLEvent* event) +{ + PR_ASSERT(PR_CurrentThread() == mozilla_thread); + PostURLEvent* e = (PostURLEvent*)event; + NPP npp = e->peer->GetNPP(); + NPError rslt = np_posturlinternal(npp, + e->url, + e->target, + e->altHost, + e->referrer, + e->forceJSEnabled, + e->postDataLen, + e->postData, + e->isFile, + e->notifyData != NULL, + e->notifyData); + return (void*)rslt; +} + +static void +DestroyPostURLEvent(PLEvent* event) +{ + PostURLEvent* e = (PostURLEvent*)event; + PR_Free(event); +} + +NS_METHOD +nsPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, + PRUint32 postDataLen, const char* postData, + PRBool isFile, void* notifyData, + const char* altHost, const char* referrer, + PRBool forceJSEnabled, + PRUint32 postHeadersLen, const char* postHeaders) +{ + NPError rslt = NPERR_INVALID_PARAM; + nsPluginInstancePeer* instPeer = NULL; + if (peer->QueryInterface(kPluginInstancePeerCID, (void**)&instPeer) == NS_OK) { + if (PR_CurrentThread() == mozilla_thread) { + NPP npp = instPeer->GetNPP(); + PR_ASSERT(postHeaders == NULL); // XXX need to deal with postHeaders + rslt = np_posturlinternal(npp, + url, + target, + altHost, + referrer, + forceJSEnabled, + postDataLen, + postData, + isFile, + notifyData != NULL, + notifyData); + } + else { + PostURLEvent* e = PR_NEW(PostURLEvent); + if (e == NULL) { + rslt = NPERR_OUT_OF_MEMORY_ERROR; + } + else { + PL_InitEvent(&e->event, NULL, HandlePostURLEvent, DestroyPostURLEvent); + e->peer = instPeer; + e->url = url; + e->target = target; + e->notifyData = notifyData; + e->altHost = altHost; + e->referrer = referrer; + e->forceJSEnabled = forceJSEnabled; + e->postDataLen = postDataLen; + e->postData = postData; + e->isFile = isFile; + e->postHeadersLen = postHeadersLen; + e->postHeaders = postHeaders; + rslt = (NPError)PL_PostSynchronousEvent(mozilla_event_queue, &e->event); + } + } + instPeer->Release(); + } + return fromNPError[rslt]; } //////////////////////////////////////////////////////////////////////////////// @@ -301,23 +659,26 @@ nsFileUtilities::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr } -NS_METHOD_(const char*) -nsFileUtilities::GetProgramPath(void) +NS_METHOD +nsFileUtilities::GetProgramPath(const char* *result) { - return fProgramPath; + *result = fProgramPath; + return NS_OK; } -NS_METHOD_(const char*) -nsFileUtilities::GetTempDirPath(void) +NS_METHOD +nsFileUtilities::GetTempDirPath(const char* *result) { // XXX I don't need a static really, the browser holds the tempDir name // as a static string -- it's just the XP_TempDirName that strdups it. static const char* tempDirName = NULL; if (tempDirName == NULL) tempDirName = XP_TempDirName(); - return tempDirName; + *result = tempDirName; + return NS_OK; } +#if 0 NS_METHOD nsFileUtilities::GetFileName(const char* fn, FileNameType type, char* resultBuf, PRUint32 bufLen) @@ -339,9 +700,10 @@ nsFileUtilities::GetFileName(const char* fn, FileNameType type, XP_FREE(tempName); return NS_OK; } +#endif NS_METHOD -nsFileUtilities::NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) +nsFileUtilities::NewTempFileName(const char* prefix, PRUint32 bufLen, char* resultBuf) { // XXX This should be rewritten so that we don't have to malloc the name. char* tempName = WH_TempName(xpTemporary, prefix); @@ -356,136 +718,155 @@ nsFileUtilities::NewTempFileName(const char* prefix, char* resultBuf, PRUint32 b // Plugin Instance Peer Interface nsPluginInstancePeer::nsPluginInstancePeer(NPP npp) - : npp(npp), userInst(NULL) + : fNPP(npp), fPluginInst(NULL), fTagInfo(NULL) { - NS_INIT_AGGREGATED(NULL); - tagInfo = new nsPluginTagInfo(npp); - tagInfo->AddRef(); +// NS_INIT_AGGREGATED(NULL); + NS_INIT_REFCNT(); + fTagInfo = new nsPluginTagInfo(npp); + fTagInfo->AddRef(); } nsPluginInstancePeer::~nsPluginInstancePeer(void) { - tagInfo->Release(); - tagInfo = NULL; + if (fTagInfo != NULL) { + fTagInfo->Release(); + fTagInfo = NULL; + } } -NS_IMPL_AGGREGATED(nsPluginInstancePeer); +NS_IMPL_ADDREF(nsPluginInstancePeer); +NS_IMPL_RELEASE(nsPluginInstancePeer); NS_METHOD -nsPluginInstancePeer::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) +nsPluginInstancePeer::QueryInterface(const nsIID& aIID, void** aInstancePtr) { if (NULL == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - if (aIID.Equals(kILiveConnectPluginInstancePeerIID) || - aIID.Equals(kIPluginInstancePeer2IID) || - aIID.Equals(kIPluginInstancePeerIID) || + if (aIID.Equals(kIPluginInstancePeerIID) || aIID.Equals(kPluginInstancePeerCID) || aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIPluginInstancePeer*)this; - AddRef(); - return NS_OK; + // *aInstancePtr = (void*) (nsISupports*) (nsIPluginInstancePeer*)this; + *aInstancePtr = (nsIPluginInstancePeer*) this; + AddRef(); + return NS_OK; } - return tagInfo->QueryInterface(aIID, aInstancePtr); + // beard: check for interfaces that aren't on the left edge of the inheritance graph. + // this is required so that the proper offsets are applied to this, and so the proper + // vtable is used. + if (aIID.Equals(kILiveConnectPluginInstancePeerIID)) { + *aInstancePtr = (nsILiveConnectPluginInstancePeer*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIWindowlessPluginInstancePeerIID)) { + *aInstancePtr = (nsIWindowlessPluginInstancePeer*) this; + AddRef(); + return NS_OK; + } + return fTagInfo->QueryInterface(aIID, aInstancePtr); } -NS_METHOD_(nsMIMEType) -nsPluginInstancePeer::GetMIMEType(void) +NS_METHOD +nsPluginInstancePeer::GetValue(nsPluginInstancePeerVariable variable, void *value) { - np_instance* instance = (np_instance*)npp->ndata; - return instance->typeString; + NPError err = npn_getvalue(fNPP, (NPNVariable)variable, value); + return fromNPError[err]; } -NS_METHOD_(nsPluginType) -nsPluginInstancePeer::GetMode(void) +NS_METHOD +nsPluginInstancePeer::SetValue(nsPluginInstancePeerVariable variable, void *value) { - np_instance* instance = (np_instance*)npp->ndata; - return (nsPluginType)instance->type; + NPError err = npn_setvalue(fNPP, (NPPVariable)variable, value); + return fromNPError[err]; } -NS_METHOD_(nsPluginError) +NS_METHOD +nsPluginInstancePeer::GetMIMEType(nsMIMEType *result) +{ + np_instance* instance = (np_instance*)fNPP->ndata; + *result = instance->typeString; + return NS_OK; +} + +NS_METHOD +nsPluginInstancePeer::GetMode(nsPluginMode *result) +{ + np_instance* instance = (np_instance*)fNPP->ndata; + *result = (nsPluginMode)instance->type; + return NS_OK; +} + +NS_METHOD nsPluginInstancePeer::NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) { NPStream* pstream; - nsPluginError err = (nsPluginError) - npn_newstream(npp, (char*)type, (char*)target, &pstream); - if (err != nsPluginError_NoError) + NPError err = npn_newstream(fNPP, (char*)type, (char*)target, &pstream); + if (err != NPERR_NO_ERROR) return err; - *result = new nsPluginManagerStream(npp, pstream); - return nsPluginError_NoError; + *result = new nsPluginManagerStream(fNPP, pstream); + return NS_OK; } -NS_METHOD_(void) +NS_METHOD nsPluginInstancePeer::ShowStatus(const char* message) { - npn_status(npp, message); + npn_status(fNPP, message); + return NS_OK; } -NS_METHOD_(nsPluginError) -nsPluginInstancePeer::GetValue(nsPluginManagerVariable variable, void *value) +NS_METHOD +nsPluginInstancePeer::InvalidateRect(nsPluginRect *invalidRect) { - return (nsPluginError)npn_getvalue(npp, (NPNVariable)variable, value); + npn_invalidaterect(fNPP, (NPRect*)invalidRect); + return NS_OK; } -NS_METHOD_(nsPluginError) -nsPluginInstancePeer::SetValue(nsPluginVariable variable, void *value) +NS_METHOD +nsPluginInstancePeer::InvalidateRegion(nsPluginRegion invalidRegion) { - return (nsPluginError)npn_setvalue(npp, (NPPVariable)variable, value); + npn_invalidateregion(fNPP, invalidRegion); + return NS_OK; } -NS_METHOD_(void) -nsPluginInstancePeer::InvalidateRect(nsRect *invalidRect) -{ - npn_invalidaterect(npp, (NPRect*)invalidRect); -} - -NS_METHOD_(void) -nsPluginInstancePeer::InvalidateRegion(nsRegion invalidRegion) -{ - npn_invalidateregion(npp, invalidRegion); -} - -NS_METHOD_(void) +NS_METHOD nsPluginInstancePeer::ForceRedraw(void) { - npn_forceredraw(npp); + npn_forceredraw(fNPP); + return NS_OK; } -NS_METHOD_(void) -nsPluginInstancePeer::RegisterWindow(void* window) +NS_METHOD +nsPluginInstancePeer::GetJavaPeer(jref *peer) { - npn_registerwindow(npp, window); + *peer = npn_getJavaPeer(fNPP); + return NS_OK; } -NS_METHOD_(void) -nsPluginInstancePeer::UnregisterWindow(void* window) +void nsPluginInstancePeer::SetPluginInstance(nsIPluginInstance* inst) { - npn_unregisterwindow(npp, window); + if (fPluginInst != NULL) { + fPluginInst->Release(); + } + fPluginInst = inst; + if (fPluginInst != NULL) { + fPluginInst->AddRef(); + } } -NS_METHOD_(PRInt16) -nsPluginInstancePeer::AllocateMenuID(PRBool isSubmenu) +nsIPluginInstance* nsPluginInstancePeer::GetPluginInstance() { -#ifdef XP_MAC - return npn_allocateMenuID(npp, isSubmenu); -#else - return -1; -#endif + if (fPluginInst != NULL) { + fPluginInst->AddRef(); + return fPluginInst; + } + return NULL; } -NS_METHOD_(PRBool) -nsPluginInstancePeer::Tickle(void) +NPP +nsPluginInstancePeer::GetNPP() { -#ifdef XP_MAC - // XXX add something for the Mac... -#endif - return PR_TRUE; -} - -NS_METHOD_(jref) -nsPluginInstancePeer::GetJavaPeer(void) -{ - return npn_getJavaPeer(npp); + return fNPP; } extern "C" JSContext *lm_crippled_context; /* XXX kill me */ @@ -513,7 +894,7 @@ nsPluginInstancePeer::GetJSContext(void) MWContext * nsPluginInstancePeer::GetMWContext(void) { - np_instance* instance = (np_instance*) npp->ndata; + np_instance* instance = (np_instance*) fNPP->ndata; MWContext *pMWCX = instance->cx; return pMWCX; @@ -524,7 +905,7 @@ nsPluginInstancePeer::GetMWContext(void) // Plugin Tag Info Interface nsPluginTagInfo::nsPluginTagInfo(NPP npp) - : npp(npp), fUniqueID(0), fJVMPluginTagInfo(NULL) + : fJVMPluginTagInfo(NULL), npp(npp), fUniqueID(0) { NS_INIT_AGGREGATED(NULL); } @@ -551,8 +932,6 @@ nsPluginTagInfo::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr #ifdef OJI // Aggregates... if (fJVMPluginTagInfo == NULL) { - np_instance* instance = (np_instance*) npp->ndata; - MWContext* cx = instance->cx; nsresult result = nsJVMPluginTagInfo::Create((nsISupports*)this, kISupportsIID, (void**)&fJVMPluginTagInfo, this); @@ -564,7 +943,7 @@ nsPluginTagInfo::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr static char* empty_list[] = { "", NULL }; -NS_METHOD_(nsPluginError) +NS_METHOD nsPluginTagInfo::GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values) @@ -594,7 +973,7 @@ nsPluginTagInfo::GetAttributes(PRUint16& n, n = (PRUint16) ndata->lo_struct->attribute_cnt; #endif - return nsPluginError_NoError; + return NS_OK; } else { static char _name[] = "PALETTE"; static char* _names[1]; @@ -609,7 +988,7 @@ nsPluginTagInfo::GetAttributes(PRUint16& n, values = (const char*const*) _values; n = 1; - return nsPluginError_NoError; + return NS_OK; } // random, sun-spot induced error @@ -619,54 +998,57 @@ nsPluginTagInfo::GetAttributes(PRUint16& n, // const char* const* empty_list = { { '\0' } }; names = values = (const char*const*)empty_list; - return nsPluginError_GenericError; + return NS_ERROR_FAILURE; } -NS_METHOD_(const char*) -nsPluginTagInfo::GetAttribute(const char* name) +NS_METHOD +nsPluginTagInfo::GetAttribute(const char* name, const char* *result) { PRUint16 nAttrs, i; const char*const* names; const char*const* values; - if( NPCallFailed( GetAttributes( nAttrs, names, values )) ) - return 0; - + nsresult rslt = GetAttributes(nAttrs, names, values); + if (rslt != NS_OK) + return rslt; + + *result = NULL; for( i = 0; i < nAttrs; i++ ) { - if( PL_strcasecmp( name, names[i] ) == 0 ) - return values[i]; + if (PL_strcasecmp(name, names[i]) == 0) { + *result = values[i]; + return NS_OK; + } } - return 0; + return NS_OK; } -NS_METHOD_(nsPluginTagType) -nsPluginTagInfo::GetTagType(void) +NS_METHOD +nsPluginTagInfo::GetTagType(nsPluginTagType *result) { -#ifdef XXX - switch (GetLayoutElement()->lo_element.type) { + *result = nsPluginTagType_Unknown; + switch (GetLayoutElement()->type) { case LO_JAVA: - return nsPluginTagType_Applet; + *result = nsPluginTagType_Applet; + return NS_OK; case LO_EMBED: - return nsPluginTagType_Embed; + *result = nsPluginTagType_Embed; + return NS_OK; case LO_OBJECT: - return nsPluginTagType_Object; - + *result = nsPluginTagType_Object; + return NS_OK; default: - return nsPluginTagType_Unknown; + return NS_OK; } -#endif - return nsPluginTagType_Unknown; } -NS_METHOD_(const char *) -nsPluginTagInfo::GetTagText(void) +NS_METHOD +nsPluginTagInfo::GetTagText(const char* *result) { - // XXX - return NULL; + return NS_ERROR_NOT_IMPLEMENTED; // XXX } -NS_METHOD_(nsPluginError) +NS_METHOD nsPluginTagInfo::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values) @@ -688,7 +1070,7 @@ nsPluginTagInfo::GetParameters(PRUint16& n, n = (PRUint16)ndata->lo_struct->attribute_cnt; #endif - return nsPluginError_NoError; + return NS_OK; } else { static char _name[] = "PALETTE"; static char* _names[1]; @@ -703,7 +1085,7 @@ nsPluginTagInfo::GetParameters(PRUint16& n, values = (const char*const*) _values; n = 1; - return nsPluginError_NoError; + return NS_OK; } // random, sun-spot induced error @@ -713,45 +1095,51 @@ nsPluginTagInfo::GetParameters(PRUint16& n, // static const char* const* empty_list = { { '\0' } }; names = values = (const char*const*)empty_list; - return nsPluginError_GenericError; + return NS_ERROR_FAILURE; } -NS_METHOD_(const char*) -nsPluginTagInfo::GetParameter(const char* name) +NS_METHOD +nsPluginTagInfo::GetParameter(const char* name, const char* *result) { PRUint16 nParams, i; const char*const* names; const char*const* values; - if( NPCallFailed( GetParameters( nParams, names, values )) ) - return 0; + nsresult rslt = GetParameters(nParams, names, values); + if (rslt != NS_OK) + return rslt; + *result = NULL; for( i = 0; i < nParams; i++ ) { - if( PL_strcasecmp( name, names[i] ) == 0 ) - return values[i]; + if (PL_strcasecmp(name, names[i]) == 0) { + *result = values[i]; + return NS_OK; + } } - return 0; + return NS_OK; } -NS_METHOD_(const char*) -nsPluginTagInfo::GetDocumentBase(void) +NS_METHOD +nsPluginTagInfo::GetDocumentBase(const char* *result) { - return (const char*)GetLayoutElement()->base_url; + *result = (const char*)GetLayoutElement()->base_url; + return NS_OK; } -NS_METHOD_(const char*) -nsPluginTagInfo::GetDocumentEncoding(void) +NS_METHOD +nsPluginTagInfo::GetDocumentEncoding(const char* *result) { np_instance* instance = (np_instance*) npp->ndata; MWContext* cx = instance->cx; INTL_CharSetInfo info = LO_GetDocumentCharacterSetInfo(cx); int16 doc_csid = INTL_GetCSIWinCSID(info); - return INTL_CharSetIDToJavaCharSetName(doc_csid); + *result = INTL_CharSetIDToJavaCharSetName(doc_csid); + return NS_OK; } -NS_METHOD_(const char*) -nsPluginTagInfo::GetAlignment(void) +NS_METHOD +nsPluginTagInfo::GetAlignment(const char* *result) { int alignment = GetLayoutElement()->alignment; @@ -767,37 +1155,42 @@ nsPluginTagInfo::GetAlignment(void) case LO_ALIGN_NCSA_TOP: cp = "top"; break; default: cp = "baseline"; break; } - return cp; + *result = cp; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginTagInfo::GetWidth(void) +NS_METHOD +nsPluginTagInfo::GetWidth(PRUint32 *result) { LO_CommonPluginStruct* lo = GetLayoutElement(); - return lo->width ? lo->width : 50; + *result = lo->width ? lo->width : 50; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginTagInfo::GetHeight(void) +NS_METHOD +nsPluginTagInfo::GetHeight(PRUint32 *result) { LO_CommonPluginStruct* lo = GetLayoutElement(); - return lo->height ? lo->height : 50; + *result = lo->height ? lo->height : 50; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginTagInfo::GetBorderVertSpace(void) +NS_METHOD +nsPluginTagInfo::GetBorderVertSpace(PRUint32 *result) { - return GetLayoutElement()->border_vert_space; + *result = GetLayoutElement()->border_vert_space; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginTagInfo::GetBorderHorizSpace(void) +NS_METHOD +nsPluginTagInfo::GetBorderHorizSpace(PRUint32 *result) { - return GetLayoutElement()->border_horiz_space; + *result = GetLayoutElement()->border_horiz_space; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginTagInfo::GetUniqueID(void) +NS_METHOD +nsPluginTagInfo::GetUniqueID(PRUint32 *result) { if (fUniqueID == 0) { np_instance* instance = (np_instance*) npp->ndata; @@ -815,7 +1208,8 @@ nsPluginTagInfo::GetUniqueID(void) } PR_ASSERT(fUniqueID != 0); } - return fUniqueID; + *result = fUniqueID; + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -840,14 +1234,16 @@ nsPluginManagerStream::Close(void) return (nsresult)err; } -NS_METHOD_(PRInt32) +NS_METHOD nsPluginManagerStream::Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, - nsresult *errorResult) + PRInt32 *resultingCount) { - PRInt32 rslt = npn_write(npp, pstream, aCount, (void*)(aBuf + aOffset)); + PR_ASSERT(aOffset == 0); // XXX need to handle the non-sequential write case + PRInt32 rslt = npn_write(npp, pstream, aCount, (void*)aBuf); if (rslt == -1) - *errorResult = NS_ERROR_FAILURE; // XXX what should this be? - return rslt; + return NS_ERROR_FAILURE; // XXX what should this be? + *resultingCount = rslt; + return NS_OK; } NS_IMPL_QUERY_INTERFACE(nsPluginManagerStream, kIOutputStreamIID); @@ -872,46 +1268,53 @@ nsPluginStreamPeer::~nsPluginStreamPeer(void) #endif } -NS_METHOD_(const char*) -nsPluginStreamPeer::GetURL(void) +NS_METHOD +nsPluginStreamPeer::GetURL(const char* *result) { - return stream->pstream->url; + *result = stream->pstream->url; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginStreamPeer::GetEnd(void) +NS_METHOD +nsPluginStreamPeer::GetEnd(PRUint32 *result) { - return stream->pstream->end; + *result = stream->pstream->end; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginStreamPeer::GetLastModified(void) +NS_METHOD +nsPluginStreamPeer::GetLastModified(PRUint32 *result) { - return stream->pstream->lastmodified; + *result = stream->pstream->lastmodified; + return NS_OK; } -NS_METHOD_(void*) -nsPluginStreamPeer::GetNotifyData(void) +NS_METHOD +nsPluginStreamPeer::GetNotifyData(void* *result) { - return stream->pstream->notifyData; + *result = stream->pstream->notifyData; + return NS_OK; } -NS_METHOD_(nsPluginReason) -nsPluginStreamPeer::GetReason(void) +NS_METHOD +nsPluginStreamPeer::GetReason(nsPluginReason *result) { - return reason; + *result = reason; + return NS_OK; } -NS_METHOD_(nsMIMEType) -nsPluginStreamPeer::GetMIMEType(void) +NS_METHOD +nsPluginStreamPeer::GetMIMEType(nsMIMEType *result) { - return (nsMIMEType)urls->content_type; + *result = (nsMIMEType)urls->content_type; + return NS_OK; } -NS_METHOD_(PRUint32) -nsPluginStreamPeer::GetContentLength(void) +NS_METHOD +nsPluginStreamPeer::GetContentLength(PRUint32 *result) { - return urls->content_length; + *result = urls->content_length; + return NS_OK; } #if 0 NS_METHOD_(const char*) @@ -962,29 +1365,33 @@ nsPluginStreamPeer::GetServerStatus(void) return urls->server_status; } #endif -NS_METHOD_(PRUint32) -nsPluginStreamPeer::GetHeaderFieldCount(void) +NS_METHOD +nsPluginStreamPeer::GetHeaderFieldCount(PRUint32 *result) { - return urls->all_headers.empty_index; + *result = urls->all_headers.empty_index; + return NS_OK; } -NS_METHOD_(const char*) -nsPluginStreamPeer::GetHeaderFieldKey(PRUint32 index) +NS_METHOD +nsPluginStreamPeer::GetHeaderFieldKey(PRUint32 index, const char* *result) { - return urls->all_headers.key[index]; + *result = urls->all_headers.key[index]; + return NS_OK; } -NS_METHOD_(const char*) -nsPluginStreamPeer::GetHeaderField(PRUint32 index) +NS_METHOD +nsPluginStreamPeer::GetHeaderField(PRUint32 index, const char* *result) { - return urls->all_headers.value[index]; + *result = urls->all_headers.value[index]; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD nsPluginStreamPeer::RequestRead(nsByteRange* rangeList) { - return (nsPluginError)npn_requestread(stream->pstream, - (NPByteRange*)rangeList); + NPError err = npn_requestread(stream->pstream, + (NPByteRange*)rangeList); + return fromNPError[err]; } NS_IMPL_ADDREF(nsPluginStreamPeer); diff --git a/modules/plugin/test/Simple32.def b/modules/plugin/test/Simple32.def index 424678074a10..57c94ea4daed 100644 --- a/modules/plugin/test/Simple32.def +++ b/modules/plugin/test/Simple32.def @@ -1,19 +1,19 @@ -# -*- 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.0 (the "NPL"); you may not use this file except in -# compliance with the NPL. 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 this code under the NPL is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All Rights -# Reserved. +; -*- 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.0 (the "NPL"); you may not use this file except in +; compliance with the NPL. 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 this code under the NPL is Netscape +; Communications Corporation. Portions created by Netscape are +; Copyright (C) 1998 Netscape Communications Corporation. All Rights +; Reserved. LIBRARY NPSimp32 diff --git a/modules/plugin/test/makefile.win b/modules/plugin/test/makefile.win index 30dd2d65b161..bf38efdec9ba 100644 --- a/modules/plugin/test/makefile.win +++ b/modules/plugin/test/makefile.win @@ -79,8 +79,5 @@ include <$(DEPTH)/config/rules.mak> LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl install:: $(DLL) - -mkdir $(DEPTH)\cmd\winfe\mkfiles32\x86dbg - -mkdir $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins - -mkdir $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple $(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple $(MAKE_INSTALL) $(OBJDIR)\npsimple.dll $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple diff --git a/modules/plugin/test/npsimple.cpp b/modules/plugin/test/npsimple.cpp index 930ca8649613..87b4963677fb 100644 --- a/modules/plugin/test/npsimple.cpp +++ b/modules/plugin/test/npsimple.cpp @@ -39,7 +39,7 @@ #include #include "nsplugin.h" #include "nsIJRILiveConnectPlugin.h" -#include "nsIJRILiveConnectPluginInstancePeer.h" +#include "nsIJRILiveConnectPlugInstPeer.h" /*------------------------------------------------------------------------------ * Define IMPLEMENT_Simple before including Simple.h to state that we're * implementing the native methods of this plug-in here, and consequently @@ -146,25 +146,25 @@ public: // This call initializes the plugin and will be called before any new // instances are created. It is passed browserInterfaces on which QueryInterface // may be used to obtain an nsIPluginManager, and other interfaces. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Initialize(nsISupports* browserInterfaces); // (Corresponds to NPP_Shutdown.) // Called when the browser is done with the plugin factory, or when // the plugin is disabled by the user. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Shutdown(void); // (Corresponds to NPP_GetMIMEDescription.) - NS_IMETHOD_(const char*) - GetMIMEDescription(void); + NS_IMETHOD + GetMIMEDescription(const char* *result); // (Corresponds to NPP_GetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD GetValue(nsPluginVariable variable, void *value); // (Corresponds to NPP_SetValue.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD SetValue(nsPluginVariable variable, void *value); // The old NPP_New call has been factored into two plugin instance methods: @@ -183,8 +183,8 @@ public: // from nsIJRILiveConnectPlugin: // (Corresponds to NPP_GetJavaClass.) - NS_IMETHOD_(jref) - GetJavaClass(void); + NS_IMETHOD + GetJavaClass(jref *result); //////////////////////////////////////////////////////////////////////////// // SimplePlugin specific methods: @@ -207,18 +207,30 @@ protected: class SimplePluginInstance : public nsIPluginInstance { public: + //////////////////////////////////////////////////////////////////////////// + // from nsIEventHandler: + + // (Corresponds to NPP_HandleEvent.) + // Note that for Unix and Mac the nsPluginEvent structure is different + // from the old NPEvent structure -- it's no longer the native event + // record, but is instead a struct. This was done for future extensibility, + // and so that the Mac could receive the window argument too. For Windows + // and OS2, it's always been a struct, so there's no change for them. + NS_IMETHOD + HandleEvent(nsPluginEvent* event, PRBool* handled); + //////////////////////////////////////////////////////////////////////////// // from nsIPluginInstance: - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Initialize(nsIPluginInstancePeer* peer); // Required backpointer to the peer. - NS_IMETHOD_(nsIPluginInstancePeer*) - GetPeer(void); + NS_IMETHOD + GetPeer(nsIPluginInstancePeer* *result); // See comment for nsIPlugin::CreateInstance, above. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Start(void); // The old NPP_Destroy call has been factored into two plugin instance @@ -231,35 +243,26 @@ public: // Destroy -- called once, before the plugin instance peer is to be // destroyed. This method is used to destroy the plugin instance. - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Stop(void); - NS_IMETHOD_(nsPluginError) + NS_IMETHOD Destroy(void); // (Corresponds to NPP_SetWindow.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD SetWindow(nsPluginWindow* window); // (Corresponds to NPP_NewStream.) - NS_IMETHOD_(nsPluginError) + NS_IMETHOD NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result); // (Corresponds to NPP_Print.) - NS_IMETHOD_(void) + NS_IMETHOD Print(nsPluginPrint* platformPrint); - // (Corresponds to NPP_HandleEvent.) - // Note that for Unix and Mac the nsPluginEvent structure is different - // from the old NPEvent structure -- it's no longer the native event - // record, but is instead a struct. This was done for future extensibility, - // and so that the Mac could receive the window argument too. For Windows - // and OS2, it's always been a struct, so there's no change for them. - NS_IMETHOD_(PRInt16) - HandleEvent(nsPluginEvent* event); - // (Corresponds to NPP_URLNotify.) - NS_IMETHOD_(void) + NS_IMETHOD URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData); @@ -273,11 +276,11 @@ public: void DisplayJavaMessage(char* msg, int len); void PlatformNew(void); - nsPluginError PlatformDestroy(void); - nsPluginError PlatformSetWindow(nsPluginWindow* window); + nsresult PlatformDestroy(void); + nsresult PlatformSetWindow(nsPluginWindow* window); PRInt16 PlatformHandleEvent(nsPluginEvent* event); - void SetMode(PRUint16 mode) { fMode = mode; } + void SetMode(nsPluginMode mode) { fMode = mode; } #ifdef XP_PC static LRESULT CALLBACK @@ -291,7 +294,7 @@ public: protected: nsIPluginInstancePeer* fPeer; nsPluginWindow* fWindow; - PRUint16 fMode; + nsPluginMode fMode; PlatformInstance fPlatform; }; @@ -320,19 +323,18 @@ public: * @param errorResult the error code if an error occurs * @return number of bytes read or -1 if error */ - NS_IMETHOD_(PRInt32) - Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, - nsresult *errorResult); + NS_IMETHOD + Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount); //////////////////////////////////////////////////////////////////////////// // from nsIPluginStream: // (Corresponds to NPP_NewStream's stype return parameter.) - NS_IMETHOD_(NPStreamType) - GetStreamType(void); + NS_IMETHOD + GetStreamType(nsPluginStreamType *result); // (Corresponds to NPP_StreamAsFile.) - NS_IMETHOD_(void) + NS_IMETHOD AsFile(const char* fname); //////////////////////////////////////////////////////////////////////////// @@ -452,32 +454,33 @@ SimplePlugin::LockFactory(PRBool aLock) return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::Initialize(nsISupports* browserInterfaces) { if (browserInterfaces->QueryInterface(kIPluginManagerIID, (void**)mgr) != NS_OK) { - return nsPluginError_GenericError; + return NS_ERROR_FAILURE; } - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::Shutdown(void) { mgr->Release(); // QueryInterface in Initialize mgr = NULL; - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ * GetMIMEDescription: +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(const char*) -SimplePlugin::GetMIMEDescription(void) +NS_METHOD +SimplePlugin::GetMIMEDescription(const char* *result) { - return "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"; + *result = "application/x-simple-plugin:smp:Simple LiveConnect Sample Plug-in"; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -487,24 +490,24 @@ SimplePlugin::GetMIMEDescription(void) #define PLUGIN_NAME "Simple LiveConnect Sample Plug-in" #define PLUGIN_DESCRIPTION "Demonstrates a simple LiveConnected plug-in." -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::GetValue(nsPluginVariable variable, void *value) { - nsPluginError err = nsPluginError_NoError; + nsresult err = NS_OK; if (variable == nsPluginVariable_NameString) *((char **)value) = PLUGIN_NAME; else if (variable == nsPluginVariable_DescriptionString) *((char **)value) = PLUGIN_DESCRIPTION; else - err = nsPluginError_GenericError; + err = NS_ERROR_FAILURE; return err; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePlugin::SetValue(nsPluginVariable variable, void *value) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -518,12 +521,12 @@ SimplePlugin::SetValue(nsPluginVariable variable, void *value) * complain to the user. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(jref) -SimplePlugin::GetJavaClass(void) +NS_METHOD +SimplePlugin::GetJavaClass(jref *result) { struct java_lang_Class* myClass; if (mgr->QueryInterface(kIJRIEnvIID, (void**)&env) == NS_NOINTERFACE) - return NULL; // Java disabled + return NS_ERROR_FAILURE; // Java disabled myClass = Simple::_use(env); @@ -534,7 +537,8 @@ SimplePlugin::GetJavaClass(void) */ env = NULL; } - return (jref)myClass; + *result = (jref)myClass; + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -542,7 +546,7 @@ SimplePlugin::GetJavaClass(void) //////////////////////////////////////////////////////////////////////////////// SimplePluginInstance::SimplePluginInstance(void) - : fPeer(NULL), fWindow(NULL), fMode(0) + : fPeer(NULL), fWindow(NULL), fMode(nsPluginMode_Embedded) { NS_INIT_REFCNT(); } @@ -571,22 +575,25 @@ NS_IMPL_RELEASE(SimplePluginInstance); * time. The NPP pointer is valid until the instance is destroyed. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Initialize(nsIPluginInstancePeer* peer) { fPeer = peer; - fMode = peer->GetMode(); + nsresult err = peer->GetMode(&fMode); + if (err) return err; PlatformNew(); /* Call Platform-specific initializations */ - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsIPluginInstancePeer*) -SimplePluginInstance::GetPeer(void) +NS_METHOD +SimplePluginInstance::GetPeer(nsIPluginInstancePeer* *result) { - return fPeer; + fPeer->AddRef(); + *result = fPeer; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Start(void) { /* Show off some of that Java functionality: */ @@ -609,19 +616,19 @@ SimplePluginInstance::Start(void) sprintf(factString, "my favorite function returned %d\n", v); DisplayJavaMessage(factString, -1); } - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Stop(void) { - return nsPluginError_NoError; + return NS_OK; } -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::Destroy(void) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -638,10 +645,10 @@ SimplePluginInstance::Destroy(void) * with the window. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::SetWindow(nsPluginWindow* window) { - nsPluginError result; + nsresult result; DisplayJavaMessage("Calling SimplePluginInstance::SetWindow.", -1); /* @@ -666,30 +673,31 @@ SimplePluginInstance::SetWindow(nsPluginWindow* window) * parameter type. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(nsPluginError) +NS_METHOD SimplePluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) { DisplayJavaMessage("Calling SimplePluginInstance::NewStream.", -1); SimplePluginStream* strm = new SimplePluginStream(peer, this); - if (strm == NULL) return nsPluginError_OutOfMemoryError; + if (strm == NULL) + return NS_ERROR_OUT_OF_MEMORY; strm->AddRef(); *result = strm; - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ * NPP_Print: +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(void) +NS_METHOD SimplePluginInstance::Print(nsPluginPrint* printInfo) { DisplayJavaMessage("Calling SimplePluginInstance::Print.", -1); if (printInfo == NULL) - return; + return NS_ERROR_FAILURE; - if (printInfo->mode == nsPluginType_Full) { + if (printInfo->mode == nsPluginMode_Full) { /* * PLUGIN DEVELOPERS: * If your plugin would like to take over @@ -720,7 +728,7 @@ SimplePluginInstance::Print(nsPluginPrint* printInfo) * PLUGIN DEVELOPERS: * If your plugin is embedded, or is full-screen * but you returned false in pluginPrinted above, NPP_Print - * will be called with mode == nsPluginType_Embedded. The nsPluginWindow + * will be called with mode == nsPluginMode_Embedded. The nsPluginWindow * in the printInfo gives the location and dimensions of * the embedded plugin on the printed page. On the * Macintosh, platformPrint is the printer port; on @@ -733,6 +741,7 @@ SimplePluginInstance::Print(nsPluginPrint* printInfo) void* platformPrint = printInfo->print.embedPrint.platformPrint; } + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -745,11 +754,11 @@ SimplePluginInstance::Print(nsPluginPrint* printInfo) * return TRUE if you handle the event and FALSE if you ignore the event. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(PRInt16) -SimplePluginInstance::HandleEvent(nsPluginEvent* event) +NS_METHOD +SimplePluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) { - PRInt16 eventHandled = PlatformHandleEvent(event); - return eventHandled; + *handled = (PRBool)PlatformHandleEvent(event); + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -771,11 +780,12 @@ SimplePluginInstance::HandleEvent(nsPluginEvent* event) * call, and can be used by your plug-in to uniquely identify the request. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(void) +NS_METHOD SimplePluginInstance::URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData) { // Not used in the Simple plugin + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -801,22 +811,6 @@ NS_IMPL_QUERY_INTERFACE(SimplePluginStream, kIPluginStreamIID); NS_IMPL_ADDREF(SimplePluginStream); NS_IMPL_RELEASE(SimplePluginStream); -/* PLUGIN DEVELOPERS: - * These next 2 functions are directly relevant in a plug-in which - * handles the data in a streaming manner. If you want zero bytes - * because no buffer space is YET available, return 0. As long as - * the stream has not been written to the plugin, Navigator will - * continue trying to send bytes. If the plugin doesn't want them, - * just return some large number from NPP_WriteReady(), and - * ignore them in NPP_Write(). For a NP_ASFILE stream, they are - * still called but can safely be ignored using this strategy. - */ - -PRInt32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile - * mode so we can take any size stream in our - * write call (since we ignore it) */ - - NS_METHOD SimplePluginStream::Close(void) { @@ -845,22 +839,22 @@ SimplePluginStream::Close(void) * is not persistent. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(PRInt32) -SimplePluginStream::Write(const char* buffer, PRInt32 len, PRInt32 aCount, - nsresult *errorResult) +NS_METHOD +SimplePluginStream::Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount) { - fInst->DisplayJavaMessage((char*)buffer, len); - *errorResult = NS_OK; - return len; /* The number of bytes accepted */ + PR_ASSERT(aOffset == 0); // XXX need to handle the non-sequential write case + fInst->DisplayJavaMessage((char*)aBuf, aCount); + return aCount; /* The number of bytes accepted */ } /*******************************************************************************/ -NS_METHOD_(NPStreamType) -SimplePluginStream::GetStreamType(void) +NS_METHOD +SimplePluginStream::GetStreamType(nsPluginStreamType *result) { // XXX these should become subclasses - return NPStreamType_Normal; + *result = nsPluginStreamType_Normal; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -874,10 +868,11 @@ SimplePluginStream::GetStreamType(void) * retrieving the data or writing the file, fname may be NULL. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -NS_METHOD_(void ) +NS_METHOD SimplePluginStream::AsFile(const char* fname) { fInst->DisplayJavaMessage("Calling SimplePluginStream::AsFile.", -1); + return NS_OK; } @@ -940,7 +935,8 @@ SimplePluginInstance::DisplayJavaMessage(char* msg, int len) ** Use the GetJavaPeer operation to get the Java instance that ** corresponds to our plug-in (an instance of the Simple class): */ - javaPeer = (Simple*)lcPeer->GetJavaPeer(); + nsresult err = lcPeer->GetJavaPeer((jobject*)&javaPeer); + if (err) return; /* ** Finally, call our plug-in's big "feature" -- the 'doit' method, @@ -978,10 +974,10 @@ SimplePluginInstance::PlatformNew(void) * Destroy any Platform-Specific instance data. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformDestroy(void) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -990,7 +986,7 @@ SimplePluginInstance::PlatformDestroy(void) * Perform platform-specific window operations +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { Widget netscape_widget; @@ -1005,7 +1001,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) netscape_widget = XtWindowToWidget(fPlatform.display, fPlatform.window); XtAddEventHandler(netscape_widget, ExposureMask, FALSE, (XtEventHandler)Redraw, this); Redraw(netscape_widget, (XtPointer)this, NULL); - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1071,7 +1067,7 @@ SimplePluginInstance::PlatformNew(void) * Destroy any Platform-Specific instance data. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformDestroy(void) { if( fWindow != NULL ) { /* If we have a window, clean @@ -1081,7 +1077,7 @@ SimplePluginInstance::PlatformDestroy(void) fPlatform.fhWnd = NULL; } - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1090,7 +1086,7 @@ SimplePluginInstance::PlatformDestroy(void) * Perform platform-specific window operations +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { if( fWindow != NULL ) /* If we already have a window, clean @@ -1103,12 +1099,12 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) SetWindowLong( fPlatform.fhWnd, GWL_WNDPROC, (LONG)fPlatform.fDefaultWindowProc); fPlatform.fDefaultWindowProc = NULL; fPlatform.fhWnd = NULL; - return nsPluginError_NoError; + return NS_OK; } else if ( fPlatform.fhWnd == (HWND) window->window ) { /* The new window is the same as the old one. Exit now. */ - return nsPluginError_NoError; + return NS_OK; } else { /* Clean up the old window, so that we can subclass the new @@ -1121,7 +1117,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) else if( (window == NULL) || ( window->window == NULL ) ) { /* We can just get out of here if there is no current * window and there is no new window to use. */ - return nsPluginError_NoError; + return NS_OK; } /* At this point, we will subclass @@ -1135,7 +1131,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) InvalidateRect( fPlatform.fhWnd, NULL, TRUE ); UpdateWindow( fPlatform.fhWnd ); - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1214,10 +1210,10 @@ SimplePluginInstance::PlatformNew(void) * Destroy any Platform-Specific instance data. +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformDestroy(void) { - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1226,7 +1222,7 @@ SimplePluginInstance::PlatformDestroy(void) * Perform platform-specific window operations +++++++++++++++++++++++++++++++++++++++++++++++++*/ -nsPluginError +nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { fWindow = window; @@ -1234,7 +1230,7 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) DoDraw(This); EndDraw( window ); } - return nsPluginError_NoError; + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/modules/rdf/include/MANIFEST b/modules/rdf/include/MANIFEST index 30d8c3fa1b83..09dbb79365c5 100644 --- a/modules/rdf/include/MANIFEST +++ b/modules/rdf/include/MANIFEST @@ -5,3 +5,4 @@ rdf.h vocab.h htrdf.h +jsec2rdf.h diff --git a/modules/rdf/include/jsec2rdf.h b/modules/rdf/include/jsec2rdf.h index 214a72f47c04..04bae0ef1fdc 100644 --- a/modules/rdf/include/jsec2rdf.h +++ b/modules/rdf/include/jsec2rdf.h @@ -32,43 +32,43 @@ typedef RDF_Resource JSec_Target; NSPR_BEGIN_EXTERN_C -char * RDFJSec_GetPrincipalURLString(char *principalID); -const char * RDFJSec_PrincipalUseID(JSec_PrincipalUse prUse); +PR_EXTERN(char*) RDFJSec_GetPrincipalURLString(char *principalID); +PR_EXTERN(const char*) RDFJSec_PrincipalUseID(JSec_PrincipalUse prUse); -JSec_Error RDFJSec_InitPrivilegeDB(); /* just use gNCDB */ -JSec_Error RDFJSec_SavePrivilegeDB(); -JSec_Error RDFJSec_ClosePrivilegeDB(); +PR_EXTERN(JSec_Error) RDFJSec_InitPrivilegeDB(); /* just use gNCDB */ +PR_EXTERN(JSec_Error) RDFJSec_SavePrivilegeDB(); +PR_EXTERN(JSec_Error) RDFJSec_ClosePrivilegeDB(); -RDF_Cursor RDFJSec_ListAllPrincipals(); -JSec_Principal RDFJSec_NextPrincipal(RDF_Cursor c); -JSec_Error RDFJSec_ReleaseCursor(RDF_Cursor c); +PR_EXTERN(RDF_Cursor) RDFJSec_ListAllPrincipals(); +PR_EXTERN(JSec_Principal) RDFJSec_NextPrincipal(RDF_Cursor c); +PR_EXTERN(JSec_Error) RDFJSec_ReleaseCursor(RDF_Cursor c); -JSec_Principal RDFJSec_NewPrincipal(char* principalID); -JSec_Error RDFJSec_AddPrincipal(JSec_Principal pr); -JSec_Error RDFJSec_DeletePrincipal(JSec_Principal pr); -char* RDFJSec_PrincipalID(JSec_Principal pr); -void * RDFJSec_AttributeOfPrincipal(JSec_Principal pr, char* attributeType); -JSec_Error RDFJSec_SetPrincipalAttribute(JSec_Principal pr, char* attributeType, void* attValue); +PR_EXTERN(JSec_Principal) RDFJSec_NewPrincipal(char* principalID); +PR_EXTERN(JSec_Error) RDFJSec_AddPrincipal(JSec_Principal pr); +PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipal(JSec_Principal pr); +PR_EXTERN(char*) RDFJSec_PrincipalID(JSec_Principal pr); +PR_EXTERN(void*) RDFJSec_AttributeOfPrincipal(JSec_Principal pr, char* attributeType); +PR_EXTERN(JSec_Error) RDFJSec_SetPrincipalAttribute(JSec_Principal pr, char* attributeType, void* attValue); -RDF_Cursor RDFJSec_ListAllPrincipalUses(JSec_Principal pr); -JSec_PrincipalUse RDFJSec_NextPrincipalUse(RDF_Cursor c); +PR_EXTERN(RDF_Cursor) RDFJSec_ListAllPrincipalUses(JSec_Principal pr); +PR_EXTERN(JSec_PrincipalUse) RDFJSec_NextPrincipalUse(RDF_Cursor c); -JSec_PrincipalUse RDFJSec_NewPrincipalUse(JSec_Principal pr, JSec_Target tr, char* priv); -JSec_Error RDFJSec_AddPrincipalUse(JSec_Principal pr, JSec_PrincipalUse prUse); -JSec_Error RDFJSec_DeletePrincipalUse (JSec_Principal pr, JSec_PrincipalUse prUse); +PR_EXTERN(JSec_PrincipalUse) RDFJSec_NewPrincipalUse(JSec_Principal pr, JSec_Target tr, char* priv); +PR_EXTERN(JSec_Error) RDFJSec_AddPrincipalUse(JSec_Principal pr, JSec_PrincipalUse prUse); +PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipalUse (JSec_Principal pr, JSec_PrincipalUse prUse); -JSec_Error RDFJSec_AddPrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv); -JSec_Error RDFJSec_DeletePrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv); -char* RDFJSec_PrivilegeOfPrincipalUse (JSec_PrincipalUse p); +PR_EXTERN(JSec_Error) RDFJSec_AddPrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv); +PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv); +PR_EXTERN(char*) RDFJSec_PrivilegeOfPrincipalUse (JSec_PrincipalUse p); -JSec_Error RDFJSec_AddTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr); -JSec_Error RDFJSec_DeleteTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr); -JSec_Target RDFJSec_TargetOfPrincipalUse (JSec_PrincipalUse p); +PR_EXTERN(JSec_Error) RDFJSec_AddTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr); +PR_EXTERN(JSec_Error) RDFJSec_DeleteTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr); +PR_EXTERN(JSec_Target) RDFJSec_TargetOfPrincipalUse (JSec_PrincipalUse p); -JSec_Target RDFJSec_NewTarget(char* targetName, JSec_Principal pr); -char* RDFJSec_GetTargetName(JSec_Target tr); -char* RDFJSec_AttributeOfTarget(JSec_Target tr, char* attributeType); -JSec_Error RDFJSec_SetTargetAttribute(JSec_Target tr, char* attributeType, char* attValue); +PR_EXTERN(JSec_Target) RDFJSec_NewTarget(char* targetName, JSec_Principal pr); +PR_EXTERN(char*) RDFJSec_GetTargetName(JSec_Target tr); +PR_EXTERN(char*) RDFJSec_AttributeOfTarget(JSec_Target tr, char* attributeType); +PR_EXTERN(JSec_Error) RDFJSec_SetTargetAttribute(JSec_Target tr, char* attributeType, char* attValue); NSPR_END_EXTERN_C diff --git a/modules/security/freenav/secstubn.h b/modules/security/freenav/secstubn.h index 3598d9a17f6b..9246f8db261f 100644 --- a/modules/security/freenav/secstubn.h +++ b/modules/security/freenav/secstubn.h @@ -45,6 +45,16 @@ typedef struct FINGERZIG_ { #define ZIG_MF 2 #define ZIG_ERR_PNF 12 +/* certificate stuff */ + +#define ZIG_C_COMPANY 1 +#define ZIG_C_CA 2 +#define ZIG_C_SERIAL 3 +#define ZIG_C_EXPIRES 4 +#define ZIG_C_NICKNAME 5 +#define ZIG_C_FP 6 +#define ZIG_C_JAVA 100 + SEC_BEGIN_PROTOS void @@ -194,11 +204,11 @@ int SOB_parse_manifest(char XP_HUGE *raw_manifest, long length, void SECNAV_signedAppletPrivileges(void *proto_win, char *javaPrin, - char *javaTarget, char *risk, int isCert); + char *javaTarget, char *risk, PRBool isCert); void SECNAV_signedAppletPrivilegesOnMozillaThread(void *proto_win, char *javaPrin, - char *javaTarget, char *risk, int isCert); + char *javaTarget, char *risk, PRBool isCert); char * SOB_JAR_list_certs (void); diff --git a/nav-java/stubs/include/javasec.h b/nav-java/stubs/include/javasec.h index 009cca343ce3..f89a409e1815 100644 --- a/nav-java/stubs/include/javasec.h +++ b/nav-java/stubs/include/javasec.h @@ -18,28 +18,6 @@ #ifndef _JAVASEC_H_ #define _JAVASEC_H_ -#include "jritypes.h" - -JRI_PUBLIC_API(const char *) java_netscape_security_getPrincipals(const char *charSetName); - -JRI_PUBLIC_API(void) java_netscape_security_getPrivilegeDescs(const char *charSetName, - char *prinName, - char** forever, - char** session, - char **denied); - -JRI_PUBLIC_API(void) java_netscape_security_getTargetDetails(const char *charSetName, - char* targetName, - char** details, - char **risk); - -JRI_PUBLIC_API(jint) java_netscape_security_removePrincipal(const char *charSetName, - char *prinName); - -JRI_PUBLIC_API(jint) java_netscape_security_removePrivilege(const char *charSetName, - char *prinName, - char *targetName); - -JRI_PUBLIC_API(void) java_netscape_security_savePrivilege(int privilege); +/* bye */ #endif /* _JAVASEC_H_ */ diff --git a/nav-java/stubs/macjri/netscape_javascript_JSObject.h b/nav-java/stubs/macjri/netscape_javascript_JSObject.h index 7351f60436d5..12f599e84260 100644 --- a/nav-java/stubs/macjri/netscape_javascript_JSObject.h +++ b/nav-java/stubs/macjri/netscape_javascript_JSObject.h @@ -46,5 +46,4 @@ struct netscape_javascript_JSObject { } /* extern "C" */ #endif /* __cplusplus */ - #endif /* Class netscape/javascript/JSObject */ diff --git a/nav-java/stubs/src/stubnj.c b/nav-java/stubs/src/stubnj.c index b1d6bc84161f..7b25114fbdc3 100644 --- a/nav-java/stubs/src/stubnj.c +++ b/nav-java/stubs/src/stubnj.c @@ -550,6 +550,7 @@ java_netscape_security_getPrivilegeDescs(const char *charSetName, return; } +#if 0 /* now in caps */ /* java_netscape_security_getTargetDetails libsecnav.so */ /* ns/nav-java/netscape/security/javasec.h */ @@ -563,6 +564,8 @@ java_netscape_security_getTargetDetails(const char *charSetName, return; } +#endif /* now in caps */ + /* java_netscape_security_removePrincipal libsecnav.so */ /* ns/nav-java/netscape/security/javasec.h */ /* ns/nav-java/netscape/security/secStubs.c */ @@ -584,6 +587,7 @@ java_netscape_security_removePrivilege(const char *charSetName, return 0; } +#if 0 /* now in caps */ /* java_netscape_security_savePrivilege libsecnav.so */ /* ns/nav-java/netscape/security/javasec.h */ @@ -594,6 +598,8 @@ java_netscape_security_savePrivilege(int privilege) return; } +#endif /* now in caps */ + /* makeJavaString libmocha.so */ /* sun-java */ diff --git a/nsprpub/config/UNIX.mk b/nsprpub/config/UNIX.mk index ad45ddb144ac..6de1e5429734 100644 --- a/nsprpub/config/UNIX.mk +++ b/nsprpub/config/UNIX.mk @@ -32,7 +32,7 @@ OBJDIR_TAG = _DBG endif # Name of the binary code directories -OBJDIR_NAME = $(OS_CONFIG)$(CPU_ARCH_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ +OBJDIR_NAME = SunOS5.5_sparc_DBG.OBJ MKDEPEND_DIR = $(DEPTH)/config/mkdepend MKDEPEND = $(MKDEPEND_DIR)/$(OBJDIR_NAME)/mkdepend diff --git a/nsprpub/lib/ds/MANIFEST b/nsprpub/lib/ds/MANIFEST index ce8226bdd8b0..b4ce1eb05929 100644 --- a/nsprpub/lib/ds/MANIFEST +++ b/nsprpub/lib/ds/MANIFEST @@ -6,3 +6,4 @@ plarenas.h plarena.h plevent.h plhash.h +plvector.h diff --git a/nsprpub/lib/ds/Makefile b/nsprpub/lib/ds/Makefile index 8890afe1d942..e4071d954e57 100644 --- a/nsprpub/lib/ds/Makefile +++ b/nsprpub/lib/ds/Makefile @@ -34,6 +34,7 @@ CSRCS = \ plarena.c \ plevent.c \ plhash.c \ + plvector.c \ $(NULL) HEADERS = \ @@ -41,6 +42,7 @@ HEADERS = \ plarena.h \ plevent.h \ plhash.h \ + plvector.h \ $(NULL) ifeq ($(OS_ARCH), WINNT) diff --git a/nsprpub/macbuild/NSPR20PPC.mcp b/nsprpub/macbuild/NSPR20PPC.mcp index b5d2f01705f7..0f33391604fe 100644 Binary files a/nsprpub/macbuild/NSPR20PPC.mcp and b/nsprpub/macbuild/NSPR20PPC.mcp differ diff --git a/sun-java/stubs/include/jni.h b/sun-java/stubs/include/jni.h index c10bdef963ab..5b68c2c91f22 100644 --- a/sun-java/stubs/include/jni.h +++ b/sun-java/stubs/include/jni.h @@ -1,32 +1,56 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* + * @(#)jni.h 1.28 97/05/19 * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ + * Copyright (c) 1993-1996 Sun Microsystems, Inc. All Rights Reserved. * - * 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. + * Permission to use, copy, modify, and distribute this software + * and its documentation for NON-COMMERCIAL purposes and without + * fee is hereby granted provided that this copyright notice + * appears in all copies. * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * The Java source code is the confidential and proprietary information + * of Sun Microsystems, Inc. ("Confidential Information"). You shall + * not disclose such Confidential Information and shall use it only in + * accordance with the terms of the license agreement you entered into + * with Sun. + * + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ + +/* + * We used part of Netscape's Java Runtime Interface (JRI) as the starting + * point of our design and implementation. + */ + +/****************************************************************************** + * Java Runtime Interface + * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved. + *****************************************************************************/ + #ifndef JNI_H #define JNI_H #include #include +/* jni_md.h contains the machine-dependent typedefs for jbyte, jint + and jlong */ + #include "jni_md.h" #ifdef __cplusplus extern "C" { #endif +/* + * JNI Types + */ + typedef unsigned char jboolean; typedef unsigned short jchar; typedef short jshort; @@ -35,15 +59,1745 @@ typedef double jdouble; typedef jint jsize; -typedef void *jobject; -typedef jobject jref; +#ifdef __cplusplus + +class _jobject {}; +class _jclass : public _jobject {}; +class _jthrowable : public _jobject {}; +class _jstring : public _jobject {}; +class _jarray : public _jobject {}; +class _jbooleanArray : public _jarray {}; +class _jbyteArray : public _jarray {}; +class _jcharArray : public _jarray {}; +class _jshortArray : public _jarray {}; +class _jintArray : public _jarray {}; +class _jlongArray : public _jarray {}; +class _jfloatArray : public _jarray {}; +class _jdoubleArray : public _jarray {}; +class _jobjectArray : public _jarray {}; + +typedef _jobject *jobject; +typedef _jclass *jclass; +typedef _jthrowable *jthrowable; +typedef _jstring *jstring; +typedef _jarray *jarray; +typedef _jbooleanArray *jbooleanArray; +typedef _jbyteArray *jbyteArray; +typedef _jcharArray *jcharArray; +typedef _jshortArray *jshortArray; +typedef _jintArray *jintArray; +typedef _jlongArray *jlongArray; +typedef _jfloatArray *jfloatArray; +typedef _jdoubleArray *jdoubleArray; +typedef _jobjectArray *jobjectArray; + +#else + +struct _jobject; + +typedef struct _jobject *jobject; typedef jobject jclass; +typedef jobject jthrowable; +typedef jobject jstring; +typedef jobject jarray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jarray jobjectArray; -typedef void *jbyteArray; -typedef void *jobjectArray; +#endif -typedef void JNIEnvInterface; -typedef const JNIEnvInterface *JNIEnv; +#if 0 /* moved to jri_md.h */ +typedef jobject jref; /* For transition---not meant to be part of public + API anymore.*/ +#endif + +typedef union jvalue { + jboolean z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong j; + jfloat f; + jdouble d; + jobject l; +} jvalue; + +struct _jfieldID; +typedef struct _jfieldID *jfieldID; + +struct _jmethodID; +typedef struct _jmethodID *jmethodID; + +/* + * jboolean constants + */ + +#define JNI_FALSE 0 +#define JNI_TRUE 1 + +/* + * possible return values for JNI functions. + */ + +#define JNI_OK 0 +#define JNI_ERR (-1) + +/* + * used in ReleaseScalarArrayElements + */ + +#define JNI_COMMIT 1 +#define JNI_ABORT 2 + +/* + * used in RegisterNatives to describe native method name, signature, + * and function pointer. + */ + +typedef struct { + char *name; + char *signature; + void *fnPtr; +} JNINativeMethod; + +/* + * JNI Native Method Interface. + */ + +struct JNINativeInterface_; + +struct JNIEnv_; + +#ifdef __cplusplus +typedef JNIEnv_ JNIEnv; +#else +typedef const struct JNINativeInterface_ *JNIEnv; +#endif + +/* + * JNI Invocation Interface. + */ + +struct JNIInvokeInterface_; + +struct JavaVM_; + +#ifdef __cplusplus +typedef JavaVM_ JavaVM; +#else +typedef const struct JNIInvokeInterface_ *JavaVM; +#endif + +struct JNINativeInterface_ { + void *reserved0; + void *reserved1; + void *reserved2; + + void *reserved3; + jint (JNICALL *GetVersion)(JNIEnv *env); + + jclass (JNICALL *DefineClass) + (JNIEnv *env, const char *name, jobject loader, const jbyte *buf, + jsize len); + jclass (JNICALL *FindClass) + (JNIEnv *env, const char *name); + + void *reserved4; + void *reserved5; + void *reserved6; + + jclass (JNICALL *GetSuperclass) + (JNIEnv *env, jclass sub); + jboolean (JNICALL *IsAssignableFrom) + (JNIEnv *env, jclass sub, jclass sup); + void *reserved7; + + + jint (JNICALL *Throw) + (JNIEnv *env, jthrowable obj); + jint (JNICALL *ThrowNew) + (JNIEnv *env, jclass clazz, const char *msg); + jthrowable (JNICALL *ExceptionOccurred) + (JNIEnv *env); + void (JNICALL *ExceptionDescribe) + (JNIEnv *env); + void (JNICALL *ExceptionClear) + (JNIEnv *env); + void (JNICALL *FatalError) + (JNIEnv *env, const char *msg); + void *reserved8; + void *reserved9; + + jobject (JNICALL *NewGlobalRef) + (JNIEnv *env, jobject lobj); + void (JNICALL *DeleteGlobalRef) + (JNIEnv *env, jobject gref); + void (JNICALL *DeleteLocalRef) + (JNIEnv *env, jobject obj); + jboolean (JNICALL *IsSameObject) + (JNIEnv *env, jobject obj1, jobject obj2); + void *reserved10; + void *reserved11; + + jobject (JNICALL *AllocObject) + (JNIEnv *env, jclass clazz); + jobject (JNICALL *NewObject) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jobject (JNICALL *NewObjectV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jobject (JNICALL *NewObjectA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jclass (JNICALL *GetObjectClass) + (JNIEnv *env, jobject obj); + jboolean (JNICALL *IsInstanceOf) + (JNIEnv *env, jobject obj, jclass clazz); + + jmethodID (JNICALL *GetMethodID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (JNICALL *CallObjectMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jobject (JNICALL *CallObjectMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jobject (JNICALL *CallObjectMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args); + + jboolean (JNICALL *CallBooleanMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jboolean (JNICALL *CallBooleanMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jboolean (JNICALL *CallBooleanMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args); + + jbyte (JNICALL *CallByteMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jbyte (JNICALL *CallByteMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jbyte (JNICALL *CallByteMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + jchar (JNICALL *CallCharMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jchar (JNICALL *CallCharMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jchar (JNICALL *CallCharMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + jshort (JNICALL *CallShortMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jshort (JNICALL *CallShortMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jshort (JNICALL *CallShortMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + jint (JNICALL *CallIntMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jint (JNICALL *CallIntMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jint (JNICALL *CallIntMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + jlong (JNICALL *CallLongMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jlong (JNICALL *CallLongMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jlong (JNICALL *CallLongMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + jfloat (JNICALL *CallFloatMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jfloat (JNICALL *CallFloatMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jfloat (JNICALL *CallFloatMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + jdouble (JNICALL *CallDoubleMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jdouble (JNICALL *CallDoubleMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jdouble (JNICALL *CallDoubleMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args); + + void (JNICALL *CallVoidMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + void (JNICALL *CallVoidMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + void (JNICALL *CallVoidMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args); + + jobject (JNICALL *CallNonvirtualObjectMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jobject (JNICALL *CallNonvirtualObjectMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jobject (JNICALL *CallNonvirtualObjectMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue * args); + + jboolean (JNICALL *CallNonvirtualBooleanMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jboolean (JNICALL *CallNonvirtualBooleanMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jboolean (JNICALL *CallNonvirtualBooleanMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue * args); + + jbyte (JNICALL *CallNonvirtualByteMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jbyte (JNICALL *CallNonvirtualByteMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jbyte (JNICALL *CallNonvirtualByteMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + jchar (JNICALL *CallNonvirtualCharMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jchar (JNICALL *CallNonvirtualCharMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jchar (JNICALL *CallNonvirtualCharMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + jshort (JNICALL *CallNonvirtualShortMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jshort (JNICALL *CallNonvirtualShortMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jshort (JNICALL *CallNonvirtualShortMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + jint (JNICALL *CallNonvirtualIntMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jint (JNICALL *CallNonvirtualIntMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jint (JNICALL *CallNonvirtualIntMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + jlong (JNICALL *CallNonvirtualLongMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jlong (JNICALL *CallNonvirtualLongMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jlong (JNICALL *CallNonvirtualLongMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + jfloat (JNICALL *CallNonvirtualFloatMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jfloat (JNICALL *CallNonvirtualFloatMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jfloat (JNICALL *CallNonvirtualFloatMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + jdouble (JNICALL *CallNonvirtualDoubleMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jdouble (JNICALL *CallNonvirtualDoubleMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jdouble (JNICALL *CallNonvirtualDoubleMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue *args); + + void (JNICALL *CallNonvirtualVoidMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + void (JNICALL *CallNonvirtualVoidMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + void (JNICALL *CallNonvirtualVoidMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + jvalue * args); + + jfieldID (JNICALL *GetFieldID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (JNICALL *GetObjectField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jboolean (JNICALL *GetBooleanField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jbyte (JNICALL *GetByteField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jchar (JNICALL *GetCharField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jshort (JNICALL *GetShortField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jint (JNICALL *GetIntField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jlong (JNICALL *GetLongField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jfloat (JNICALL *GetFloatField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jdouble (JNICALL *GetDoubleField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + + void (JNICALL *SetObjectField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val); + void (JNICALL *SetBooleanField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val); + void (JNICALL *SetByteField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val); + void (JNICALL *SetCharField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val); + void (JNICALL *SetShortField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val); + void (JNICALL *SetIntField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jint val); + void (JNICALL *SetLongField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val); + void (JNICALL *SetFloatField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val); + void (JNICALL *SetDoubleField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val); + + jmethodID (JNICALL *GetStaticMethodID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (JNICALL *CallStaticObjectMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jobject (JNICALL *CallStaticObjectMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jobject (JNICALL *CallStaticObjectMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jboolean (JNICALL *CallStaticBooleanMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jboolean (JNICALL *CallStaticBooleanMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jboolean (JNICALL *CallStaticBooleanMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jbyte (JNICALL *CallStaticByteMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jbyte (JNICALL *CallStaticByteMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jbyte (JNICALL *CallStaticByteMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jchar (JNICALL *CallStaticCharMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jchar (JNICALL *CallStaticCharMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jchar (JNICALL *CallStaticCharMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jshort (JNICALL *CallStaticShortMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jshort (JNICALL *CallStaticShortMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jshort (JNICALL *CallStaticShortMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jint (JNICALL *CallStaticIntMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jint (JNICALL *CallStaticIntMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jint (JNICALL *CallStaticIntMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jlong (JNICALL *CallStaticLongMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jlong (JNICALL *CallStaticLongMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jlong (JNICALL *CallStaticLongMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jfloat (JNICALL *CallStaticFloatMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jfloat (JNICALL *CallStaticFloatMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jfloat (JNICALL *CallStaticFloatMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + jdouble (JNICALL *CallStaticDoubleMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jdouble (JNICALL *CallStaticDoubleMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jdouble (JNICALL *CallStaticDoubleMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args); + + void (JNICALL *CallStaticVoidMethod) + (JNIEnv *env, jclass cls, jmethodID methodID, ...); + void (JNICALL *CallStaticVoidMethodV) + (JNIEnv *env, jclass cls, jmethodID methodID, va_list args); + void (JNICALL *CallStaticVoidMethodA) + (JNIEnv *env, jclass cls, jmethodID methodID, jvalue * args); + + jfieldID (JNICALL *GetStaticFieldID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + jobject (JNICALL *GetStaticObjectField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jboolean (JNICALL *GetStaticBooleanField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jbyte (JNICALL *GetStaticByteField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jchar (JNICALL *GetStaticCharField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jshort (JNICALL *GetStaticShortField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jint (JNICALL *GetStaticIntField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jlong (JNICALL *GetStaticLongField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jfloat (JNICALL *GetStaticFloatField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jdouble (JNICALL *GetStaticDoubleField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + + void (JNICALL *SetStaticObjectField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value); + void (JNICALL *SetStaticBooleanField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value); + void (JNICALL *SetStaticByteField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value); + void (JNICALL *SetStaticCharField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value); + void (JNICALL *SetStaticShortField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value); + void (JNICALL *SetStaticIntField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value); + void (JNICALL *SetStaticLongField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value); + void (JNICALL *SetStaticFloatField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value); + void (JNICALL *SetStaticDoubleField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value); + + jstring (JNICALL *NewString) + (JNIEnv *env, const jchar *unicode, jsize len); + jsize (JNICALL *GetStringLength) + (JNIEnv *env, jstring str); + const jchar *(JNICALL *GetStringChars) + (JNIEnv *env, jstring str, jboolean *isCopy); + void (JNICALL *ReleaseStringChars) + (JNIEnv *env, jstring str, const jchar *chars); + + jstring (JNICALL *NewStringUTF) + (JNIEnv *env, const char *utf); + jsize (JNICALL *GetStringUTFLength) + (JNIEnv *env, jstring str); + const char* (JNICALL *GetStringUTFChars) + (JNIEnv *env, jstring str, jboolean *isCopy); + void (JNICALL *ReleaseStringUTFChars) + (JNIEnv *env, jstring str, const char* chars); + + + jsize (JNICALL *GetArrayLength) + (JNIEnv *env, jarray array); + + jobjectArray (JNICALL *NewObjectArray) + (JNIEnv *env, jsize len, jclass clazz, jobject init); + jobject (JNICALL *GetObjectArrayElement) + (JNIEnv *env, jobjectArray array, jsize index); + void (JNICALL *SetObjectArrayElement) + (JNIEnv *env, jobjectArray array, jsize index, jobject val); + + jbooleanArray (JNICALL *NewBooleanArray) + (JNIEnv *env, jsize len); + jbyteArray (JNICALL *NewByteArray) + (JNIEnv *env, jsize len); + jcharArray (JNICALL *NewCharArray) + (JNIEnv *env, jsize len); + jshortArray (JNICALL *NewShortArray) + (JNIEnv *env, jsize len); + jintArray (JNICALL *NewIntArray) + (JNIEnv *env, jsize len); + jlongArray (JNICALL *NewLongArray) + (JNIEnv *env, jsize len); + jfloatArray (JNICALL *NewFloatArray) + (JNIEnv *env, jsize len); + jdoubleArray (JNICALL *NewDoubleArray) + (JNIEnv *env, jsize len); + + jboolean * (JNICALL *GetBooleanArrayElements) + (JNIEnv *env, jbooleanArray array, jboolean *isCopy); + jbyte * (JNICALL *GetByteArrayElements) + (JNIEnv *env, jbyteArray array, jboolean *isCopy); + jchar * (JNICALL *GetCharArrayElements) + (JNIEnv *env, jcharArray array, jboolean *isCopy); + jshort * (JNICALL *GetShortArrayElements) + (JNIEnv *env, jshortArray array, jboolean *isCopy); + jint * (JNICALL *GetIntArrayElements) + (JNIEnv *env, jintArray array, jboolean *isCopy); + jlong * (JNICALL *GetLongArrayElements) + (JNIEnv *env, jlongArray array, jboolean *isCopy); + jfloat * (JNICALL *GetFloatArrayElements) + (JNIEnv *env, jfloatArray array, jboolean *isCopy); + jdouble * (JNICALL *GetDoubleArrayElements) + (JNIEnv *env, jdoubleArray array, jboolean *isCopy); + + void (JNICALL *ReleaseBooleanArrayElements) + (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode); + void (JNICALL *ReleaseByteArrayElements) + (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode); + void (JNICALL *ReleaseCharArrayElements) + (JNIEnv *env, jcharArray array, jchar *elems, jint mode); + void (JNICALL *ReleaseShortArrayElements) + (JNIEnv *env, jshortArray array, jshort *elems, jint mode); + void (JNICALL *ReleaseIntArrayElements) + (JNIEnv *env, jintArray array, jint *elems, jint mode); + void (JNICALL *ReleaseLongArrayElements) + (JNIEnv *env, jlongArray array, jlong *elems, jint mode); + void (JNICALL *ReleaseFloatArrayElements) + (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode); + void (JNICALL *ReleaseDoubleArrayElements) + (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode); + + void (JNICALL *GetBooleanArrayRegion) + (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf); + void (JNICALL *GetByteArrayRegion) + (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); + void (JNICALL *GetCharArrayRegion) + (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); + void (JNICALL *GetShortArrayRegion) + (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); + void (JNICALL *GetIntArrayRegion) + (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); + void (JNICALL *GetLongArrayRegion) + (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); + void (JNICALL *GetFloatArrayRegion) + (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); + void (JNICALL *GetDoubleArrayRegion) + (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf); + + void (JNICALL *SetBooleanArrayRegion) + (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf); + void (JNICALL *SetByteArrayRegion) + (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); + void (JNICALL *SetCharArrayRegion) + (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); + void (JNICALL *SetShortArrayRegion) + (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); + void (JNICALL *SetIntArrayRegion) + (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); + void (JNICALL *SetLongArrayRegion) + (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); + void (JNICALL *SetFloatArrayRegion) + (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); + void (JNICALL *SetDoubleArrayRegion) + (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf); + + jint (JNICALL *RegisterNatives) + (JNIEnv *env, jclass clazz, const JNINativeMethod *methods, + jint nMethods); + jint (JNICALL *UnregisterNatives) + (JNIEnv *env, jclass clazz); + + jint (JNICALL *MonitorEnter) + (JNIEnv *env, jobject obj); + jint (JNICALL *MonitorExit) + (JNIEnv *env, jobject obj); + + jint (JNICALL *GetJavaVM) + (JNIEnv *env, JavaVM **vm); +}; + +/* + * We use inlined functions for C++ so that programmers can write: + * + * env->FindClass("java/lang/String") + * + * in C++ rather than: + * + * (*env)->FindClass(env, "java/lang/String") + * + * in C. + */ + +struct JNIEnv_ { + const struct JNINativeInterface_ *functions; + void *reserved0; + void *reserved1[6]; +#ifdef __cplusplus + + jint GetVersion() { + return functions->GetVersion(this); + } + jclass DefineClass(const char *name, jobject loader, const jbyte *buf, + jsize len) { + return functions->DefineClass(this, name, loader, buf, len); + } + jclass FindClass(const char *name) { + return functions->FindClass(this, name); + } + jclass GetSuperclass(jclass sub) { + return functions->GetSuperclass(this, sub); + } + jboolean IsAssignableFrom(jclass sub, jclass sup) { + return functions->IsAssignableFrom(this, sub, sup); + } + + jint Throw(jthrowable obj) { + return functions->Throw(this, obj); + } + jint ThrowNew(jclass clazz, const char *msg) { + return functions->ThrowNew(this, clazz, msg); + } + jthrowable ExceptionOccurred() { + return functions->ExceptionOccurred(this); + } + void ExceptionDescribe() { + functions->ExceptionDescribe(this); + } + void ExceptionClear() { + functions->ExceptionClear(this); + } + void FatalError(const char *msg) { + functions->FatalError(this, msg); + } + + jobject NewGlobalRef(jobject lobj) { + return functions->NewGlobalRef(this,lobj); + } + void DeleteGlobalRef(jobject gref) { + functions->DeleteGlobalRef(this,gref); + } + void DeleteLocalRef(jobject obj) { + functions->DeleteLocalRef(this, obj); + } + + jboolean IsSameObject(jobject obj1, jobject obj2) { + return functions->IsSameObject(this,obj1,obj2); + } + + jobject AllocObject(jclass clazz) { + return functions->AllocObject(this,clazz); + } + jobject NewObject(jclass clazz, jmethodID methodID, ...) { + va_list args; + jobject result; + va_start(args, methodID); + result = functions->NewObjectV(this,clazz,methodID,args); + va_end(args); + return result; + } + jobject NewObjectV(jclass clazz, jmethodID methodID, + va_list args) { + return functions->NewObjectV(this,clazz,methodID,args); + } + jobject NewObjectA(jclass clazz, jmethodID methodID, + jvalue *args) { + return functions->NewObjectA(this,clazz,methodID,args); + } + + jclass GetObjectClass(jobject obj) { + return functions->GetObjectClass(this,obj); + } + jboolean IsInstanceOf(jobject obj, jclass clazz) { + return functions->IsInstanceOf(this,obj,clazz); + } + + jmethodID GetMethodID(jclass clazz, const char *name, + const char *sig) { + return functions->GetMethodID(this,clazz,name,sig); + } + + jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jobject result; + va_start(args,methodID); + result = functions->CallObjectMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jobject CallObjectMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallObjectMethodV(this,obj,methodID,args); + } + jobject CallObjectMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallObjectMethodA(this,obj,methodID,args); + } + + jboolean CallBooleanMethod(jobject obj, + jmethodID methodID, ...) { + va_list args; + jboolean result; + va_start(args,methodID); + result = functions->CallBooleanMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jboolean CallBooleanMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallBooleanMethodV(this,obj,methodID,args); + } + jboolean CallBooleanMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallBooleanMethodA(this,obj,methodID, args); + } + + jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jbyte result; + va_start(args,methodID); + result = functions->CallByteMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jbyte CallByteMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallByteMethodV(this,obj,methodID,args); + } + jbyte CallByteMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallByteMethodA(this,obj,methodID,args); + } + + jchar CallCharMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jchar result; + va_start(args,methodID); + result = functions->CallCharMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jchar CallCharMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallCharMethodV(this,obj,methodID,args); + } + jchar CallCharMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallCharMethodA(this,obj,methodID,args); + } + + jshort CallShortMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jshort result; + va_start(args,methodID); + result = functions->CallShortMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jshort CallShortMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallShortMethodV(this,obj,methodID,args); + } + jshort CallShortMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallShortMethodA(this,obj,methodID,args); + } + + jint CallIntMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jint result; + va_start(args,methodID); + result = functions->CallIntMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jint CallIntMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallIntMethodV(this,obj,methodID,args); + } + jint CallIntMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallIntMethodA(this,obj,methodID,args); + } + + jlong CallLongMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jlong result; + va_start(args,methodID); + result = functions->CallLongMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jlong CallLongMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallLongMethodV(this,obj,methodID,args); + } + jlong CallLongMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallLongMethodA(this,obj,methodID,args); + } + + jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jfloat result; + va_start(args,methodID); + result = functions->CallFloatMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jfloat CallFloatMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallFloatMethodV(this,obj,methodID,args); + } + jfloat CallFloatMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallFloatMethodA(this,obj,methodID,args); + } + + jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jdouble result; + va_start(args,methodID); + result = functions->CallDoubleMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jdouble CallDoubleMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallDoubleMethodV(this,obj,methodID,args); + } + jdouble CallDoubleMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + return functions->CallDoubleMethodA(this,obj,methodID,args); + } + + void CallVoidMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + va_start(args,methodID); + functions->CallVoidMethodV(this,obj,methodID,args); + va_end(args); + } + void CallVoidMethodV(jobject obj, jmethodID methodID, + va_list args) { + functions->CallVoidMethodV(this,obj,methodID,args); + } + void CallVoidMethodA(jobject obj, jmethodID methodID, + jvalue * args) { + functions->CallVoidMethodA(this,obj,methodID,args); + } + + jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jobject result; + va_start(args,methodID); + result = functions->CallNonvirtualObjectMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualObjectMethodV(this,obj,clazz, + methodID,args); + } + jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualObjectMethodA(this,obj,clazz, + methodID,args); + } + + jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jboolean result; + va_start(args,methodID); + result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualBooleanMethodV(this,obj,clazz, + methodID,args); + } + jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualBooleanMethodA(this,obj,clazz, + methodID, args); + } + + jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jbyte result; + va_start(args,methodID); + result = functions->CallNonvirtualByteMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualByteMethodV(this,obj,clazz, + methodID,args); + } + jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualByteMethodA(this,obj,clazz, + methodID,args); + } + + jchar CallNonvirtualCharMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jchar result; + va_start(args,methodID); + result = functions->CallNonvirtualCharMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualCharMethodV(this,obj,clazz, + methodID,args); + } + jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualCharMethodA(this,obj,clazz, + methodID,args); + } + + jshort CallNonvirtualShortMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jshort result; + va_start(args,methodID); + result = functions->CallNonvirtualShortMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualShortMethodV(this,obj,clazz, + methodID,args); + } + jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualShortMethodA(this,obj,clazz, + methodID,args); + } + + jint CallNonvirtualIntMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jint result; + va_start(args,methodID); + result = functions->CallNonvirtualIntMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jint CallNonvirtualIntMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualIntMethodV(this,obj,clazz, + methodID,args); + } + jint CallNonvirtualIntMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualIntMethodA(this,obj,clazz, + methodID,args); + } + + jlong CallNonvirtualLongMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jlong result; + va_start(args,methodID); + result = functions->CallNonvirtualLongMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualLongMethodV(this,obj,clazz, + methodID,args); + } + jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz, + jmethodID methodID, jvalue * args) { + return functions->CallNonvirtualLongMethodA(this,obj,clazz, + methodID,args); + } + + jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jfloat result; + va_start(args,methodID); + result = functions->CallNonvirtualFloatMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz, + jmethodID methodID, + va_list args) { + return functions->CallNonvirtualFloatMethodV(this,obj,clazz, + methodID,args); + } + jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz, + jmethodID methodID, + jvalue * args) { + return functions->CallNonvirtualFloatMethodA(this,obj,clazz, + methodID,args); + } + + jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jdouble result; + va_start(args,methodID); + result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz, + jmethodID methodID, + va_list args) { + return functions->CallNonvirtualDoubleMethodV(this,obj,clazz, + methodID,args); + } + jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz, + jmethodID methodID, + jvalue * args) { + return functions->CallNonvirtualDoubleMethodA(this,obj,clazz, + methodID,args); + } + + void CallNonvirtualVoidMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + va_start(args,methodID); + functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); + va_end(args); + } + void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, + jmethodID methodID, + va_list args) { + functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); + } + void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, + jmethodID methodID, + jvalue * args) { + functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args); + } + + jfieldID GetFieldID(jclass clazz, const char *name, + const char *sig) { + return functions->GetFieldID(this,clazz,name,sig); + } + + jobject GetObjectField(jobject obj, jfieldID fieldID) { + return functions->GetObjectField(this,obj,fieldID); + } + jboolean GetBooleanField(jobject obj, jfieldID fieldID) { + return functions->GetBooleanField(this,obj,fieldID); + } + jbyte GetByteField(jobject obj, jfieldID fieldID) { + return functions->GetByteField(this,obj,fieldID); + } + jchar GetCharField(jobject obj, jfieldID fieldID) { + return functions->GetCharField(this,obj,fieldID); + } + jshort GetShortField(jobject obj, jfieldID fieldID) { + return functions->GetShortField(this,obj,fieldID); + } + jint GetIntField(jobject obj, jfieldID fieldID) { + return functions->GetIntField(this,obj,fieldID); + } + jlong GetLongField(jobject obj, jfieldID fieldID) { + return functions->GetLongField(this,obj,fieldID); + } + jfloat GetFloatField(jobject obj, jfieldID fieldID) { + return functions->GetFloatField(this,obj,fieldID); + } + jdouble GetDoubleField(jobject obj, jfieldID fieldID) { + return functions->GetDoubleField(this,obj,fieldID); + } + + void SetObjectField(jobject obj, jfieldID fieldID, jobject val) { + functions->SetObjectField(this,obj,fieldID,val); + } + void SetBooleanField(jobject obj, jfieldID fieldID, + jboolean val) { + functions->SetBooleanField(this,obj,fieldID,val); + } + void SetByteField(jobject obj, jfieldID fieldID, + jbyte val) { + functions->SetByteField(this,obj,fieldID,val); + } + void SetCharField(jobject obj, jfieldID fieldID, + jchar val) { + functions->SetCharField(this,obj,fieldID,val); + } + void SetShortField(jobject obj, jfieldID fieldID, + jshort val) { + functions->SetShortField(this,obj,fieldID,val); + } + void SetIntField(jobject obj, jfieldID fieldID, + jint val) { + functions->SetIntField(this,obj,fieldID,val); + } + void SetLongField(jobject obj, jfieldID fieldID, + jlong val) { + functions->SetLongField(this,obj,fieldID,val); + } + void SetFloatField(jobject obj, jfieldID fieldID, + jfloat val) { + functions->SetFloatField(this,obj,fieldID,val); + } + void SetDoubleField(jobject obj, jfieldID fieldID, + jdouble val) { + functions->SetDoubleField(this,obj,fieldID,val); + } + + jmethodID GetStaticMethodID(jclass clazz, const char *name, + const char *sig) { + return functions->GetStaticMethodID(this,clazz,name,sig); + } + + jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID, + ...) { + va_list args; + jobject result; + va_start(args,methodID); + result = functions->CallStaticObjectMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID, + va_list args) { + return functions->CallStaticObjectMethodV(this,clazz,methodID,args); + } + jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID, + jvalue *args) { + return functions->CallStaticObjectMethodA(this,clazz,methodID,args); + } + + jboolean CallStaticBooleanMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jboolean result; + va_start(args,methodID); + result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jboolean CallStaticBooleanMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticBooleanMethodV(this,clazz,methodID,args); + } + jboolean CallStaticBooleanMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticBooleanMethodA(this,clazz,methodID,args); + } + + jbyte CallStaticByteMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jbyte result; + va_start(args,methodID); + result = functions->CallStaticByteMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jbyte CallStaticByteMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticByteMethodV(this,clazz,methodID,args); + } + jbyte CallStaticByteMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticByteMethodA(this,clazz,methodID,args); + } + + jchar CallStaticCharMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jchar result; + va_start(args,methodID); + result = functions->CallStaticCharMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jchar CallStaticCharMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticCharMethodV(this,clazz,methodID,args); + } + jchar CallStaticCharMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticCharMethodA(this,clazz,methodID,args); + } + + jshort CallStaticShortMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jshort result; + va_start(args,methodID); + result = functions->CallStaticShortMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jshort CallStaticShortMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticShortMethodV(this,clazz,methodID,args); + } + jshort CallStaticShortMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticShortMethodA(this,clazz,methodID,args); + } + + jint CallStaticIntMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jint result; + va_start(args,methodID); + result = functions->CallStaticIntMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jint CallStaticIntMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticIntMethodV(this,clazz,methodID,args); + } + jint CallStaticIntMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticIntMethodA(this,clazz,methodID,args); + } + + jlong CallStaticLongMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jlong result; + va_start(args,methodID); + result = functions->CallStaticLongMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jlong CallStaticLongMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticLongMethodV(this,clazz,methodID,args); + } + jlong CallStaticLongMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticLongMethodA(this,clazz,methodID,args); + } + + jfloat CallStaticFloatMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jfloat result; + va_start(args,methodID); + result = functions->CallStaticFloatMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jfloat CallStaticFloatMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticFloatMethodV(this,clazz,methodID,args); + } + jfloat CallStaticFloatMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticFloatMethodA(this,clazz,methodID,args); + } + + jdouble CallStaticDoubleMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jdouble result; + va_start(args,methodID); + result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jdouble CallStaticDoubleMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticDoubleMethodV(this,clazz,methodID,args); + } + jdouble CallStaticDoubleMethodA(jclass clazz, + jmethodID methodID, jvalue *args) { + return functions->CallStaticDoubleMethodA(this,clazz,methodID,args); + } + + void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) { + va_list args; + va_start(args,methodID); + functions->CallStaticVoidMethodV(this,cls,methodID,args); + va_end(args); + } + void CallStaticVoidMethodV(jclass cls, jmethodID methodID, + va_list args) { + functions->CallStaticVoidMethodV(this,cls,methodID,args); + } + void CallStaticVoidMethodA(jclass cls, jmethodID methodID, + jvalue * args) { + functions->CallStaticVoidMethodA(this,cls,methodID,args); + } + + jfieldID GetStaticFieldID(jclass clazz, const char *name, + const char *sig) { + return functions->GetStaticFieldID(this,clazz,name,sig); + } + jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticObjectField(this,clazz,fieldID); + } + jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticBooleanField(this,clazz,fieldID); + } + jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticByteField(this,clazz,fieldID); + } + jchar GetStaticCharField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticCharField(this,clazz,fieldID); + } + jshort GetStaticShortField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticShortField(this,clazz,fieldID); + } + jint GetStaticIntField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticIntField(this,clazz,fieldID); + } + jlong GetStaticLongField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticLongField(this,clazz,fieldID); + } + jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticFloatField(this,clazz,fieldID); + } + jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticDoubleField(this,clazz,fieldID); + } + + void SetStaticObjectField(jclass clazz, jfieldID fieldID, + jobject value) { + functions->SetStaticObjectField(this,clazz,fieldID,value); + } + void SetStaticBooleanField(jclass clazz, jfieldID fieldID, + jboolean value) { + functions->SetStaticBooleanField(this,clazz,fieldID,value); + } + void SetStaticByteField(jclass clazz, jfieldID fieldID, + jbyte value) { + functions->SetStaticByteField(this,clazz,fieldID,value); + } + void SetStaticCharField(jclass clazz, jfieldID fieldID, + jchar value) { + functions->SetStaticCharField(this,clazz,fieldID,value); + } + void SetStaticShortField(jclass clazz, jfieldID fieldID, + jshort value) { + functions->SetStaticShortField(this,clazz,fieldID,value); + } + void SetStaticIntField(jclass clazz, jfieldID fieldID, + jint value) { + functions->SetStaticIntField(this,clazz,fieldID,value); + } + void SetStaticLongField(jclass clazz, jfieldID fieldID, + jlong value) { + functions->SetStaticLongField(this,clazz,fieldID,value); + } + void SetStaticFloatField(jclass clazz, jfieldID fieldID, + jfloat value) { + functions->SetStaticFloatField(this,clazz,fieldID,value); + } + void SetStaticDoubleField(jclass clazz, jfieldID fieldID, + jdouble value) { + functions->SetStaticDoubleField(this,clazz,fieldID,value); + } + + jstring NewString(const jchar *unicode, jsize len) { + return functions->NewString(this,unicode,len); + } + jsize GetStringLength(jstring str) { + return functions->GetStringLength(this,str); + } + const jchar *GetStringChars(jstring str, jboolean *isCopy) { + return functions->GetStringChars(this,str,isCopy); + } + void ReleaseStringChars(jstring str, const jchar *chars) { + functions->ReleaseStringChars(this,str,chars); + } + + jstring NewStringUTF(const char *utf) { + return functions->NewStringUTF(this,utf); + } + jsize GetStringUTFLength(jstring str) { + return functions->GetStringUTFLength(this,str); + } + const char* GetStringUTFChars(jstring str, jboolean *isCopy) { + return functions->GetStringUTFChars(this,str,isCopy); + } + void ReleaseStringUTFChars(jstring str, const char* chars) { + functions->ReleaseStringUTFChars(this,str,chars); + } + + jsize GetArrayLength(jarray array) { + return functions->GetArrayLength(this,array); + } + + jobjectArray NewObjectArray(jsize len, jclass clazz, + jobject init) { + return functions->NewObjectArray(this,len,clazz,init); + } + jobject GetObjectArrayElement(jobjectArray array, jsize index) { + return functions->GetObjectArrayElement(this,array,index); + } + void SetObjectArrayElement(jobjectArray array, jsize index, + jobject val) { + functions->SetObjectArrayElement(this,array,index,val); + } + + jbooleanArray NewBooleanArray(jsize len) { + return functions->NewBooleanArray(this,len); + } + jbyteArray NewByteArray(jsize len) { + return functions->NewByteArray(this,len); + } + jcharArray NewCharArray(jsize len) { + return functions->NewCharArray(this,len); + } + jshortArray NewShortArray(jsize len) { + return functions->NewShortArray(this,len); + } + jintArray NewIntArray(jsize len) { + return functions->NewIntArray(this,len); + } + jlongArray NewLongArray(jsize len) { + return functions->NewLongArray(this,len); + } + jfloatArray NewFloatArray(jsize len) { + return functions->NewFloatArray(this,len); + } + jdoubleArray NewDoubleArray(jsize len) { + return functions->NewDoubleArray(this,len); + } + + jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) { + return functions->GetBooleanArrayElements(this,array,isCopy); + } + jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) { + return functions->GetByteArrayElements(this,array,isCopy); + } + jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) { + return functions->GetCharArrayElements(this,array,isCopy); + } + jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) { + return functions->GetShortArrayElements(this,array,isCopy); + } + jint * GetIntArrayElements(jintArray array, jboolean *isCopy) { + return functions->GetIntArrayElements(this,array,isCopy); + } + jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) { + return functions->GetLongArrayElements(this,array,isCopy); + } + jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) { + return functions->GetFloatArrayElements(this,array,isCopy); + } + jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) { + return functions->GetDoubleArrayElements(this,array,isCopy); + } + + void ReleaseBooleanArrayElements(jbooleanArray array, + jboolean *elems, + jint mode) { + functions->ReleaseBooleanArrayElements(this,array,elems,mode); + } + void ReleaseByteArrayElements(jbyteArray array, + jbyte *elems, + jint mode) { + functions->ReleaseByteArrayElements(this,array,elems,mode); + } + void ReleaseCharArrayElements(jcharArray array, + jchar *elems, + jint mode) { + functions->ReleaseCharArrayElements(this,array,elems,mode); + } + void ReleaseShortArrayElements(jshortArray array, + jshort *elems, + jint mode) { + functions->ReleaseShortArrayElements(this,array,elems,mode); + } + void ReleaseIntArrayElements(jintArray array, + jint *elems, + jint mode) { + functions->ReleaseIntArrayElements(this,array,elems,mode); + } + void ReleaseLongArrayElements(jlongArray array, + jlong *elems, + jint mode) { + functions->ReleaseLongArrayElements(this,array,elems,mode); + } + void ReleaseFloatArrayElements(jfloatArray array, + jfloat *elems, + jint mode) { + functions->ReleaseFloatArrayElements(this,array,elems,mode); + } + void ReleaseDoubleArrayElements(jdoubleArray array, + jdouble *elems, + jint mode) { + functions->ReleaseDoubleArrayElements(this,array,elems,mode); + } + + void GetBooleanArrayRegion(jbooleanArray array, + jsize start, jsize len, jboolean *buf) { + functions->GetBooleanArrayRegion(this,array,start,len,buf); + } + void GetByteArrayRegion(jbyteArray array, + jsize start, jsize len, jbyte *buf) { + functions->GetByteArrayRegion(this,array,start,len,buf); + } + void GetCharArrayRegion(jcharArray array, + jsize start, jsize len, jchar *buf) { + functions->GetCharArrayRegion(this,array,start,len,buf); + } + void GetShortArrayRegion(jshortArray array, + jsize start, jsize len, jshort *buf) { + functions->GetShortArrayRegion(this,array,start,len,buf); + } + void GetIntArrayRegion(jintArray array, + jsize start, jsize len, jint *buf) { + functions->GetIntArrayRegion(this,array,start,len,buf); + } + void GetLongArrayRegion(jlongArray array, + jsize start, jsize len, jlong *buf) { + functions->GetLongArrayRegion(this,array,start,len,buf); + } + void GetFloatArrayRegion(jfloatArray array, + jsize start, jsize len, jfloat *buf) { + functions->GetFloatArrayRegion(this,array,start,len,buf); + } + void GetDoubleArrayRegion(jdoubleArray array, + jsize start, jsize len, jdouble *buf) { + functions->GetDoubleArrayRegion(this,array,start,len,buf); + } + + void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, + jboolean *buf) { + functions->SetBooleanArrayRegion(this,array,start,len,buf); + } + void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, + jbyte *buf) { + functions->SetByteArrayRegion(this,array,start,len,buf); + } + void SetCharArrayRegion(jcharArray array, jsize start, jsize len, + jchar *buf) { + functions->SetCharArrayRegion(this,array,start,len,buf); + } + void SetShortArrayRegion(jshortArray array, jsize start, jsize len, + jshort *buf) { + functions->SetShortArrayRegion(this,array,start,len,buf); + } + void SetIntArrayRegion(jintArray array, jsize start, jsize len, + jint *buf) { + functions->SetIntArrayRegion(this,array,start,len,buf); + } + void SetLongArrayRegion(jlongArray array, jsize start, jsize len, + jlong *buf) { + functions->SetLongArrayRegion(this,array,start,len,buf); + } + void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + jfloat *buf) { + functions->SetFloatArrayRegion(this,array,start,len,buf); + } + void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + jdouble *buf) { + functions->SetDoubleArrayRegion(this,array,start,len,buf); + } + + jint RegisterNatives(jclass clazz, const JNINativeMethod *methods, + jint nMethods) { + return functions->RegisterNatives(this,clazz,methods,nMethods); + } + jint UnregisterNatives(jclass clazz) { + return functions->UnregisterNatives(this,clazz); + } + + jint MonitorEnter(jobject obj) { + return functions->MonitorEnter(this,obj); + } + jint MonitorExit(jobject obj) { + return functions->MonitorExit(this,obj); + } + + jint GetJavaVM(JavaVM **vm) { + return functions->GetJavaVM(this,vm); + } + +#endif /* __cplusplus */ +}; + +/* These structures will be VM-specific. */ + +typedef struct JDK1_1InitArgs { + jint version; + + char **properties; + jint checkSource; + jint nativeStackSize; + jint javaStackSize; + jint minHeapSize; + jint maxHeapSize; + jint verifyMode; + char *classpath; + + jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); + void (JNICALL *exit)(jint code); + void (JNICALL *abort)(); + + jint enableClassGC; + jint enableVerboseGC; + jint disableAsyncGC; + jint verbose; + jboolean debugging; + jint debugPort; +} JDK1_1InitArgs; + +typedef struct JDK1_1AttachArgs { + void * __padding; /* C compilers don't allow empty structures. */ +} JDK1_1AttachArgs; + +/* End VM-specific. */ + +struct JNIInvokeInterface_ { + void *reserved0; + void *reserved1; + void *reserved2; + + jint (JNICALL *DestroyJavaVM)(JavaVM *vm); + + jint (JNICALL *AttachCurrentThread) + (JavaVM *vm, JNIEnv **penv, void *args); + + jint (JNICALL *DetachCurrentThread)(JavaVM *vm); +}; + +struct JavaVM_ { + const struct JNIInvokeInterface_ *functions; + void *reserved0; + void *reserved1; + void *reserved2; +#ifdef __cplusplus + + jint DestroyJavaVM() { + return functions->DestroyJavaVM(this); + } + jint AttachCurrentThread(JNIEnv **penv, void *args) { + return functions->AttachCurrentThread(this, penv, args); + } + jint DetachCurrentThread() { + return functions->DetachCurrentThread(this); + } + +#endif +}; + +JNI_PUBLIC_API(void) JNI_GetDefaultJavaVMInitArgs(void *); + +JNI_PUBLIC_API(jint) JNI_CreateJavaVM(JavaVM **, JNIEnv **, void *); + +JNI_PUBLIC_API(jint) JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *); +JNI_PUBLIC_API(jref) JNI_MakeLocalRef(JNIEnv *pJNIEnv, void *pHObject); #ifdef __cplusplus } /* extern "C" */ diff --git a/sun-java/stubs/include/jni_md.h b/sun-java/stubs/include/jni_md.h index 3b45e8a68024..bd1619467383 100644 --- a/sun-java/stubs/include/jni_md.h +++ b/sun-java/stubs/include/jni_md.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- 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.0 (the "NPL"); you may not use this file except in @@ -15,14 +15,138 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +/******************************************************************************* + * Netscape version of jni_md.h -- depends on jri_md.h + ******************************************************************************/ + #ifndef JNI_MD_H #define JNI_MD_H -/* Get the rest of the stuff from jri_md.h */ -#include "jri_md.h" +/******************************************************************************* + * WHAT'S UP WITH THIS FILE? + * + * This is where we define the mystical JNI_PUBLIC_API macro that works on all + * platforms. If you're running with Visual C++, Symantec C, or Borland's + * development environment on the PC, you're all set. Or if you're on the Mac + * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't + * matter. + + * Changes by sailesh on 9/26 + + * There are two symbols used in the declaration of the JNI functions + * and native code that uses the JNI: + * JNICALL - specifies the calling convention + * JNIEXPORT - specifies export status of the function + * + * The syntax to specify calling conventions is different in Win16 and + * Win32 - the brains at Micro$oft at work here. JavaSoft in their + * infinite wisdom cares for no platform other than Win32, and so they + * just define these two symbols as: + + #define JNIEXPORT __declspec(dllexport) + #define JNICALL __stdcall + + * We deal with this, in the way JRI defines the JRI_PUBLIC_API, by + * defining a macro called JNI_PUBLIC_API. Any of our developers who + * wish to use code for Win16 and Win32, _must_ use JNI_PUBLIC_API to + * be able to export functions properly. + + * Since we must also maintain compatibility with JavaSoft, we + * continue to define the symbol JNIEXPORT. However, use of this + * internally is deprecated, since it will cause a mess on Win16. + + * We _do not_ need a new symbol called JNICALL. Instead we + * redefine JNICALL in the same way JRI_CALLBACK was defined. + + ******************************************************************************/ + +/* DLL Entry modifiers... */ + +/* PC */ +#if defined(XP_PC) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) +# include +# if defined(_MSC_VER) +# if defined(WIN32) || defined(_WIN32) +# define JNI_PUBLIC_API(ResultType) _declspec(dllexport) ResultType __stdcall +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) _declspec(dllexport) ResultType +# define JNICALL __stdcall +# else /* !_WIN32 */ +# if defined(_WINDLL) +# define JNI_PUBLIC_API(ResultType) ResultType __cdecl __export __loadds +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds +# define JNICALL __loadds +# else /* !WINDLL */ +# define JNI_PUBLIC_API(ResultType) ResultType __cdecl __export +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType __cdecl __export +# define JNICALL __export +# endif /* !WINDLL */ +# endif /* !_WIN32 */ +# elif defined(__BORLANDC__) +# if defined(WIN32) || defined(_WIN32) +# define JNI_PUBLIC_API(ResultType) __export ResultType +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) __export ResultType +# define JNICALL +# else /* !_WIN32 */ +# define JNI_PUBLIC_API(ResultType) ResultType _cdecl _export _loadds +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds +# define JNICALL _loadds +# endif +# else +# error Unsupported PC development environment. +# endif +# ifndef IS_LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN +# endif + /* This is the stuff inherited from JavaSoft .. */ +# define JNIEXPORT __declspec(dllexport) + + +/* Mac */ +#elif macintosh || Macintosh || THINK_C +# if defined(__MWERKS__) /* Metrowerks */ +# if !__option(enumsalwaysint) +# error You need to define 'Enums Always Int' for your project. +# endif +# if defined(GENERATING68K) && !GENERATINGCFM +# if !__option(fourbyteints) +# error You need to define 'Struct Alignment: 68k' for your project. +# endif +# endif /* !GENERATINGCFM */ +# define JNI_PUBLIC_API(ResultType) __declspec(export) ResultType +# define JNI_PUBLIC_VAR(VarType) JNI_PUBLIC_API(VarType) +# define JNI_NATIVE_STUB(ResultType) JNI_PUBLIC_API(ResultType) +# elif defined(__SC__) /* Symantec */ +# error What are the Symantec defines? (warren@netscape.com) +# elif macintosh && applec /* MPW */ +# error Please upgrade to the latest MPW compiler (SC). +# else +# error Unsupported Mac development environment. +# endif +# define JNICALL + /* This is the stuff inherited from JavaSoft .. */ +# define JNIEXPORT + +/* Unix or else */ +#else +# define JNI_PUBLIC_API(ResultType) ResultType +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType +# define JNICALL + /* This is the stuff inherited from JavaSoft .. */ +# define JNIEXPORT +#endif #ifndef FAR /* for non-Win16 */ #define FAR #endif +/* Get the rest of the stuff from jri_md.h */ +#include "jri_md.h" + #endif /* JNI_MD_H */ diff --git a/sun-java/stubs/include/jri.h b/sun-java/stubs/include/jri.h index 7cb939b7a8e0..ea77dd09d4ef 100644 --- a/sun-java/stubs/include/jri.h +++ b/sun-java/stubs/include/jri.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- 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.0 (the "NPL"); you may not use this file except in @@ -15,6 +15,11 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +/******************************************************************************* + * Java Runtime Interface + ******************************************************************************/ + #ifndef JRI_H #define JRI_H @@ -24,11 +29,642 @@ extern "C" { #endif /* __cplusplus */ -typedef void JRIEnvInterface; -typedef const JRIEnvInterface *JRIEnv; +/******************************************************************************* + * JRIEnv + ******************************************************************************/ + +/* The type of the JRIEnv interface. */ +typedef struct JRIEnvInterface JRIEnvInterface; + +/* The type of a JRIEnv instance. */ +typedef const JRIEnvInterface* JRIEnv; + +/******************************************************************************* + * JRIEnv Operations + ******************************************************************************/ + +#define JRI_DefineClass(env, classLoader, buf, bufLen) \ + (((*(env))->DefineClass)(env, JRI_DefineClass_op, classLoader, buf, bufLen)) + +#define JRI_FindClass(env, name) \ + (((*(env))->FindClass)(env, JRI_FindClass_op, name)) + +#define JRI_Throw(env, obj) \ + (((*(env))->Throw)(env, JRI_Throw_op, obj)) + +#define JRI_ThrowNew(env, clazz, message) \ + (((*(env))->ThrowNew)(env, JRI_ThrowNew_op, clazz, message)) + +#define JRI_ExceptionOccurred(env) \ + (((*(env))->ExceptionOccurred)(env, JRI_ExceptionOccurred_op)) + +#define JRI_ExceptionDescribe(env) \ + (((*(env))->ExceptionDescribe)(env, JRI_ExceptionDescribe_op)) + +#define JRI_ExceptionClear(env) \ + (((*(env))->ExceptionClear)(env, JRI_ExceptionClear_op)) + +#define JRI_NewGlobalRef(env, ref) \ + (((*(env))->NewGlobalRef)(env, JRI_NewGlobalRef_op, ref)) + +#define JRI_DisposeGlobalRef(env, gref) \ + (((*(env))->DisposeGlobalRef)(env, JRI_DisposeGlobalRef_op, gref)) + +#define JRI_GetGlobalRef(env, gref) \ + (((*(env))->GetGlobalRef)(env, JRI_GetGlobalRef_op, gref)) + +#define JRI_SetGlobalRef(env, gref, ref) \ + (((*(env))->SetGlobalRef)(env, JRI_SetGlobalRef_op, gref, ref)) + +#define JRI_IsSameObject(env, a, b) \ + (((*(env))->IsSameObject)(env, JRI_IsSameObject_op, a, b)) + +#define JRI_NewObject(env) ((*(env))->NewObject) +#define JRI_NewObjectV(env, clazz, methodID, args) \ + (((*(env))->NewObjectV)(env, JRI_NewObject_op_va_list, clazz, methodID, args)) +#define JRI_NewObjectA(env, clazz, method, args) \ + (((*(env))->NewObjectA)(env, JRI_NewObject_op_array, clazz, methodID, args)) + +#define JRI_GetObjectClass(env, obj) \ + (((*(env))->GetObjectClass)(env, JRI_GetObjectClass_op, obj)) + +#define JRI_IsInstanceOf(env, obj, clazz) \ + (((*(env))->IsInstanceOf)(env, JRI_IsInstanceOf_op, obj, clazz)) + +#define JRI_GetMethodID(env, clazz, name, sig) \ + (((*(env))->GetMethodID)(env, JRI_GetMethodID_op, clazz, name, sig)) + +#define JRI_CallMethod(env) ((*(env))->CallMethod) +#define JRI_CallMethodV(env, obj, methodID, args) \ + (((*(env))->CallMethodV)(env, JRI_CallMethod_op_va_list, obj, methodID, args)) +#define JRI_CallMethodA(env, obj, methodID, args) \ + (((*(env))->CallMethodA)(env, JRI_CallMethod_op_array, obj, methodID, args)) + +#define JRI_CallMethodBoolean(env) ((*(env))->CallMethodBoolean) +#define JRI_CallMethodBooleanV(env, obj, methodID, args) \ + (((*(env))->CallMethodBooleanV)(env, JRI_CallMethodBoolean_op_va_list, obj, methodID, args)) +#define JRI_CallMethodBooleanA(env, obj, methodID, args) \ + (((*(env))->CallMethodBooleanA)(env, JRI_CallMethodBoolean_op_array, obj, methodID, args)) + +#define JRI_CallMethodByte(env) ((*(env))->CallMethodByte) +#define JRI_CallMethodByteV(env, obj, methodID, args) \ + (((*(env))->CallMethodByteV)(env, JRI_CallMethodByte_op_va_list, obj, methodID, args)) +#define JRI_CallMethodByteA(env, obj, methodID, args) \ + (((*(env))->CallMethodByteA)(env, JRI_CallMethodByte_op_array, obj, methodID, args)) + +#define JRI_CallMethodChar(env) ((*(env))->CallMethodChar) +#define JRI_CallMethodCharV(env, obj, methodID, args) \ + (((*(env))->CallMethodCharV)(env, JRI_CallMethodChar_op_va_list, obj, methodID, args)) +#define JRI_CallMethodCharA(env, obj, methodID, args) \ + (((*(env))->CallMethodCharA)(env, JRI_CallMethodChar_op_array, obj, methodID, args)) + +#define JRI_CallMethodShort(env) ((*(env))->CallMethodShort) +#define JRI_CallMethodShortV(env, obj, methodID, args) \ + (((*(env))->CallMethodShortV)(env, JRI_CallMethodShort_op_va_list, obj, methodID, args)) +#define JRI_CallMethodShortA(env, obj, methodID, args) \ + (((*(env))->CallMethodShortA)(env, JRI_CallMethodShort_op_array, obj, methodID, args)) + +#define JRI_CallMethodInt(env) ((*(env))->CallMethodInt) +#define JRI_CallMethodIntV(env, obj, methodID, args) \ + (((*(env))->CallMethodIntV)(env, JRI_CallMethodInt_op_va_list, obj, methodID, args)) +#define JRI_CallMethodIntA(env, obj, methodID, args) \ + (((*(env))->CallMethodIntA)(env, JRI_CallMethodInt_op_array, obj, methodID, args)) + +#define JRI_CallMethodLong(env) ((*(env))->CallMethodLong) +#define JRI_CallMethodLongV(env, obj, methodID, args) \ + (((*(env))->CallMethodLongV)(env, JRI_CallMethodLong_op_va_list, obj, methodID, args)) +#define JRI_CallMethodLongA(env, obj, methodID, args) \ + (((*(env))->CallMethodLongA)(env, JRI_CallMethodLong_op_array, obj, methodID, args)) + +#define JRI_CallMethodFloat(env) ((*(env))->CallMethodFloat) +#define JRI_CallMethodFloatV(env, obj, methodID, args) \ + (((*(env))->CallMethodFloatV)(env, JRI_CallMethodFloat_op_va_list, obj, methodID, args)) +#define JRI_CallMethodFloatA(env, obj, methodID, args) \ + (((*(env))->CallMethodFloatA)(env, JRI_CallMethodFloat_op_array, obj, methodID, args)) + +#define JRI_CallMethodDouble(env) ((*(env))->CallMethodDouble) +#define JRI_CallMethodDoubleV(env, obj, methodID, args) \ + (((*(env))->CallMethodDoubleV)(env, JRI_CallMethodDouble_op_va_list, obj, methodID, args)) +#define JRI_CallMethodDoubleA(env, obj, methodID, args) \ + (((*(env))->CallMethodDoubleA)(env, JRI_CallMethodDouble_op_array, obj, methodID, args)) + +#define JRI_GetFieldID(env, clazz, name, sig) \ + (((*(env))->GetFieldID)(env, JRI_GetFieldID_op, clazz, name, sig)) + +#define JRI_GetField(env, obj, fieldID) \ + (((*(env))->GetField)(env, JRI_GetField_op, obj, fieldID)) + +#define JRI_GetFieldBoolean(env, obj, fieldID) \ + (((*(env))->GetFieldBoolean)(env, JRI_GetFieldBoolean_op, obj, fieldID)) + +#define JRI_GetFieldByte(env, obj, fieldID) \ + (((*(env))->GetFieldByte)(env, JRI_GetFieldByte_op, obj, fieldID)) + +#define JRI_GetFieldChar(env, obj, fieldID) \ + (((*(env))->GetFieldChar)(env, JRI_GetFieldChar_op, obj, fieldID)) + +#define JRI_GetFieldShort(env, obj, fieldID) \ + (((*(env))->GetFieldShort)(env, JRI_GetFieldShort_op, obj, fieldID)) + +#define JRI_GetFieldInt(env, obj, fieldID) \ + (((*(env))->GetFieldInt)(env, JRI_GetFieldInt_op, obj, fieldID)) + +#define JRI_GetFieldLong(env, obj, fieldID) \ + (((*(env))->GetFieldLong)(env, JRI_GetFieldLong_op, obj, fieldID)) + +#define JRI_GetFieldFloat(env, obj, fieldID) \ + (((*(env))->GetFieldFloat)(env, JRI_GetFieldFloat_op, obj, fieldID)) + +#define JRI_GetFieldDouble(env, obj, fieldID) \ + (((*(env))->GetFieldDouble)(env, JRI_GetFieldDouble_op, obj, fieldID)) + +#define JRI_SetField(env, obj, fieldID, value) \ + (((*(env))->SetField)(env, JRI_SetField_op, obj, fieldID, value)) + +#define JRI_SetFieldBoolean(env, obj, fieldID, value) \ + (((*(env))->SetFieldBoolean)(env, JRI_SetFieldBoolean_op, obj, fieldID, value)) + +#define JRI_SetFieldByte(env, obj, fieldID, value) \ + (((*(env))->SetFieldByte)(env, JRI_SetFieldByte_op, obj, fieldID, value)) + +#define JRI_SetFieldChar(env, obj, fieldID, value) \ + (((*(env))->SetFieldChar)(env, JRI_SetFieldChar_op, obj, fieldID, value)) + +#define JRI_SetFieldShort(env, obj, fieldID, value) \ + (((*(env))->SetFieldShort)(env, JRI_SetFieldShort_op, obj, fieldID, value)) + +#define JRI_SetFieldInt(env, obj, fieldID, value) \ + (((*(env))->SetFieldInt)(env, JRI_SetFieldInt_op, obj, fieldID, value)) + +#define JRI_SetFieldLong(env, obj, fieldID, value) \ + (((*(env))->SetFieldLong)(env, JRI_SetFieldLong_op, obj, fieldID, value)) + +#define JRI_SetFieldFloat(env, obj, fieldID, value) \ + (((*(env))->SetFieldFloat)(env, JRI_SetFieldFloat_op, obj, fieldID, value)) + +#define JRI_SetFieldDouble(env, obj, fieldID, value) \ + (((*(env))->SetFieldDouble)(env, JRI_SetFieldDouble_op, obj, fieldID, value)) + +#define JRI_IsSubclassOf(env, a, b) \ + (((*(env))->IsSubclassOf)(env, JRI_IsSubclassOf_op, a, b)) + +#define JRI_GetStaticMethodID(env, clazz, name, sig) \ + (((*(env))->GetStaticMethodID)(env, JRI_GetStaticMethodID_op, clazz, name, sig)) + +#define JRI_CallStaticMethod(env) ((*(env))->CallStaticMethod) +#define JRI_CallStaticMethodV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodV)(env, JRI_CallStaticMethod_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodA)(env, JRI_CallStaticMethod_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodBoolean(env) ((*(env))->CallStaticMethodBoolean) +#define JRI_CallStaticMethodBooleanV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodBooleanV)(env, JRI_CallStaticMethodBoolean_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodBooleanA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodBooleanA)(env, JRI_CallStaticMethodBoolean_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodByte(env) ((*(env))->CallStaticMethodByte) +#define JRI_CallStaticMethodByteV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodByteV)(env, JRI_CallStaticMethodByte_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodByteA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodByteA)(env, JRI_CallStaticMethodByte_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodChar(env) ((*(env))->CallStaticMethodChar) +#define JRI_CallStaticMethodCharV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodCharV)(env, JRI_CallStaticMethodChar_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodCharA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodCharA)(env, JRI_CallStaticMethodChar_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodShort(env) ((*(env))->CallStaticMethodShort) +#define JRI_CallStaticMethodShortV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodShortV)(env, JRI_CallStaticMethodShort_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodShortA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodShortA)(env, JRI_CallStaticMethodShort_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodInt(env) ((*(env))->CallStaticMethodInt) +#define JRI_CallStaticMethodIntV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodIntV)(env, JRI_CallStaticMethodInt_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodIntA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodIntA)(env, JRI_CallStaticMethodInt_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodLong(env) ((*(env))->CallStaticMethodLong) +#define JRI_CallStaticMethodLongV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodLongV)(env, JRI_CallStaticMethodLong_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodLongA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodLongA)(env, JRI_CallStaticMethodLong_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodFloat(env) ((*(env))->CallStaticMethodFloat) +#define JRI_CallStaticMethodFloatV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodFloatV)(env, JRI_CallStaticMethodFloat_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodFloatA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodFloatA)(env, JRI_CallStaticMethodFloat_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodDouble(env) ((*(env))->CallStaticMethodDouble) +#define JRI_CallStaticMethodDoubleV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodDoubleV)(env, JRI_CallStaticMethodDouble_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodDoubleA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodDoubleA)(env, JRI_CallStaticMethodDouble_op_array, clazz, methodID, args)) + +#define JRI_GetStaticFieldID(env, clazz, name, sig) \ + (((*(env))->GetStaticFieldID)(env, JRI_GetStaticFieldID_op, clazz, name, sig)) + +#define JRI_GetStaticField(env, clazz, fieldID) \ + (((*(env))->GetStaticField)(env, JRI_GetStaticField_op, clazz, fieldID)) + +#define JRI_GetStaticFieldBoolean(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldBoolean)(env, JRI_GetStaticFieldBoolean_op, clazz, fieldID)) + +#define JRI_GetStaticFieldByte(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldByte)(env, JRI_GetStaticFieldByte_op, clazz, fieldID)) + +#define JRI_GetStaticFieldChar(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldChar)(env, JRI_GetStaticFieldChar_op, clazz, fieldID)) + +#define JRI_GetStaticFieldShort(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldShort)(env, JRI_GetStaticFieldShort_op, clazz, fieldID)) + +#define JRI_GetStaticFieldInt(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldInt)(env, JRI_GetStaticFieldInt_op, clazz, fieldID)) + +#define JRI_GetStaticFieldLong(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldLong)(env, JRI_GetStaticFieldLong_op, clazz, fieldID)) + +#define JRI_GetStaticFieldFloat(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldFloat)(env, JRI_GetStaticFieldFloat_op, clazz, fieldID)) + +#define JRI_GetStaticFieldDouble(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldDouble)(env, JRI_GetStaticFieldDouble_op, clazz, fieldID)) + +#define JRI_SetStaticField(env, clazz, fieldID, value) \ + (((*(env))->SetStaticField)(env, JRI_SetStaticField_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldBoolean(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldBoolean)(env, JRI_SetStaticFieldBoolean_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldByte(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldByte)(env, JRI_SetStaticFieldByte_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldChar(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldChar)(env, JRI_SetStaticFieldChar_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldShort(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldShort)(env, JRI_SetStaticFieldShort_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldInt(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldInt)(env, JRI_SetStaticFieldInt_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldLong(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldLong)(env, JRI_SetStaticFieldLong_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldFloat(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldFloat)(env, JRI_SetStaticFieldFloat_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldDouble(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldDouble)(env, JRI_SetStaticFieldDouble_op, clazz, fieldID, value)) + +#define JRI_NewString(env, unicode, len) \ + (((*(env))->NewString)(env, JRI_NewString_op, unicode, len)) + +#define JRI_GetStringLength(env, string) \ + (((*(env))->GetStringLength)(env, JRI_GetStringLength_op, string)) + +#define JRI_GetStringChars(env, string) \ + (((*(env))->GetStringChars)(env, JRI_GetStringChars_op, string)) + +#define JRI_NewStringUTF(env, utf, len) \ + (((*(env))->NewStringUTF)(env, JRI_NewStringUTF_op, utf, len)) + +#define JRI_GetStringUTFLength(env, string) \ + (((*(env))->GetStringUTFLength)(env, JRI_GetStringUTFLength_op, string)) + +#define JRI_GetStringUTFChars(env, string) \ + (((*(env))->GetStringUTFChars)(env, JRI_GetStringUTFChars_op, string)) + +#define JRI_NewScalarArray(env, length, elementSig, initialElements) \ + (((*(env))->NewScalarArray)(env, JRI_NewScalarArray_op, length, elementSig, initialElements)) + +#define JRI_GetScalarArrayLength(env, array) \ + (((*(env))->GetScalarArrayLength)(env, JRI_GetScalarArrayLength_op, array)) + +#define JRI_GetScalarArrayElements(env, array) \ + (((*(env))->GetScalarArrayElements)(env, JRI_GetScalarArrayElements_op, array)) + +#define JRI_NewObjectArray(env, length, elementClass, initialElement) \ + (((*(env))->NewObjectArray)(env, JRI_NewObjectArray_op, length, elementClass, initialElement)) + +#define JRI_GetObjectArrayLength(env, array) \ + (((*(env))->GetObjectArrayLength)(env, JRI_GetObjectArrayLength_op, array)) + +#define JRI_GetObjectArrayElement(env, array, index) \ + (((*(env))->GetObjectArrayElement)(env, JRI_GetObjectArrayElement_op, array, index)) + +#define JRI_SetObjectArrayElement(env, array, index, value) \ + (((*(env))->SetObjectArrayElement)(env, JRI_SetObjectArrayElement_op, array, index, value)) + +#define JRI_RegisterNatives(env, clazz, nameAndSigArray, nativeProcArray) \ + (((*(env))->RegisterNatives)(env, JRI_RegisterNatives_op, clazz, nameAndSigArray, nativeProcArray)) + +#define JRI_UnregisterNatives(env, clazz) \ + (((*(env))->UnregisterNatives)(env, JRI_UnregisterNatives_op, clazz)) + +#define JRI_NewStringPlatform(env, string, len, encoding, encodingLength) \ + (((*(env))->NewStringPlatform)(env, JRI_NewStringPlatform_op, string, len, encoding, encodingLength)) + +#define JRI_GetStringPlatformChars(env, string, encoding, encodingLength) \ + (((*(env))->GetStringPlatformChars)(env, JRI_GetStringPlatformChars_op, string, encoding, encodingLength)) + + +/******************************************************************************* + * JRIEnv Interface + ******************************************************************************/ + +struct java_lang_ClassLoader; +struct java_lang_Class; +struct java_lang_Throwable; +struct java_lang_Object; +struct java_lang_String; + +struct JRIEnvInterface { + void* reserved0; + void* reserved1; + void* reserved2; + void* reserved3; + struct java_lang_Class* (*FindClass)(JRIEnv* env, jint op, const char* a); + void (*Throw)(JRIEnv* env, jint op, struct java_lang_Throwable* a); + void (*ThrowNew)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b); + struct java_lang_Throwable* (*ExceptionOccurred)(JRIEnv* env, jint op); + void (*ExceptionDescribe)(JRIEnv* env, jint op); + void (*ExceptionClear)(JRIEnv* env, jint op); + jglobal (*NewGlobalRef)(JRIEnv* env, jint op, void* a); + void (*DisposeGlobalRef)(JRIEnv* env, jint op, jglobal a); + void* (*GetGlobalRef)(JRIEnv* env, jint op, jglobal a); + void (*SetGlobalRef)(JRIEnv* env, jint op, jglobal a, void* b); + jbool (*IsSameObject)(JRIEnv* env, jint op, void* a, void* b); + void* (*NewObject)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + void* (*NewObjectV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + void* (*NewObjectA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + struct java_lang_Class* (*GetObjectClass)(JRIEnv* env, jint op, void* a); + jbool (*IsInstanceOf)(JRIEnv* env, jint op, void* a, struct java_lang_Class* b); + jint (*GetMethodID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*CallMethod)(JRIEnv* env, jint op, void* a, jint b, ...); + void* (*CallMethodV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + void* (*CallMethodA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jbool (*CallMethodBoolean)(JRIEnv* env, jint op, void* a, jint b, ...); + jbool (*CallMethodBooleanV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jbool (*CallMethodBooleanA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jbyte (*CallMethodByte)(JRIEnv* env, jint op, void* a, jint b, ...); + jbyte (*CallMethodByteV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jbyte (*CallMethodByteA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jchar (*CallMethodChar)(JRIEnv* env, jint op, void* a, jint b, ...); + jchar (*CallMethodCharV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jchar (*CallMethodCharA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jshort (*CallMethodShort)(JRIEnv* env, jint op, void* a, jint b, ...); + jshort (*CallMethodShortV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jshort (*CallMethodShortA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jint (*CallMethodInt)(JRIEnv* env, jint op, void* a, jint b, ...); + jint (*CallMethodIntV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jint (*CallMethodIntA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jlong (*CallMethodLong)(JRIEnv* env, jint op, void* a, jint b, ...); + jlong (*CallMethodLongV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jlong (*CallMethodLongA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jfloat (*CallMethodFloat)(JRIEnv* env, jint op, void* a, jint b, ...); + jfloat (*CallMethodFloatV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jfloat (*CallMethodFloatA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jdouble (*CallMethodDouble)(JRIEnv* env, jint op, void* a, jint b, ...); + jdouble (*CallMethodDoubleV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jdouble (*CallMethodDoubleA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jint (*GetFieldID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*GetField)(JRIEnv* env, jint op, void* a, jint b); + jbool (*GetFieldBoolean)(JRIEnv* env, jint op, void* a, jint b); + jbyte (*GetFieldByte)(JRIEnv* env, jint op, void* a, jint b); + jchar (*GetFieldChar)(JRIEnv* env, jint op, void* a, jint b); + jshort (*GetFieldShort)(JRIEnv* env, jint op, void* a, jint b); + jint (*GetFieldInt)(JRIEnv* env, jint op, void* a, jint b); + jlong (*GetFieldLong)(JRIEnv* env, jint op, void* a, jint b); + jfloat (*GetFieldFloat)(JRIEnv* env, jint op, void* a, jint b); + jdouble (*GetFieldDouble)(JRIEnv* env, jint op, void* a, jint b); + void (*SetField)(JRIEnv* env, jint op, void* a, jint b, void* c); + void (*SetFieldBoolean)(JRIEnv* env, jint op, void* a, jint b, jbool c); + void (*SetFieldByte)(JRIEnv* env, jint op, void* a, jint b, jbyte c); + void (*SetFieldChar)(JRIEnv* env, jint op, void* a, jint b, jchar c); + void (*SetFieldShort)(JRIEnv* env, jint op, void* a, jint b, jshort c); + void (*SetFieldInt)(JRIEnv* env, jint op, void* a, jint b, jint c); + void (*SetFieldLong)(JRIEnv* env, jint op, void* a, jint b, jlong c); + void (*SetFieldFloat)(JRIEnv* env, jint op, void* a, jint b, jfloat c); + void (*SetFieldDouble)(JRIEnv* env, jint op, void* a, jint b, jdouble c); + jbool (*IsSubclassOf)(JRIEnv* env, jint op, struct java_lang_Class* a, struct java_lang_Class* b); + jint (*GetStaticMethodID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*CallStaticMethod)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + void* (*CallStaticMethodV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + void* (*CallStaticMethodA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jbool (*CallStaticMethodBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jbool (*CallStaticMethodBooleanV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jbool (*CallStaticMethodBooleanA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jbyte (*CallStaticMethodByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jbyte (*CallStaticMethodByteV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jbyte (*CallStaticMethodByteA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jchar (*CallStaticMethodChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jchar (*CallStaticMethodCharV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jchar (*CallStaticMethodCharA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jshort (*CallStaticMethodShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jshort (*CallStaticMethodShortV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jshort (*CallStaticMethodShortA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jint (*CallStaticMethodInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jint (*CallStaticMethodIntV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jint (*CallStaticMethodIntA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jlong (*CallStaticMethodLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jlong (*CallStaticMethodLongV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jlong (*CallStaticMethodLongA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jfloat (*CallStaticMethodFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jfloat (*CallStaticMethodFloatV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jfloat (*CallStaticMethodFloatA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jdouble (*CallStaticMethodDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jdouble (*CallStaticMethodDoubleV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jdouble (*CallStaticMethodDoubleA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jint (*GetStaticFieldID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*GetStaticField)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jbool (*GetStaticFieldBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jbyte (*GetStaticFieldByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jchar (*GetStaticFieldChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jshort (*GetStaticFieldShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jint (*GetStaticFieldInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jlong (*GetStaticFieldLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jfloat (*GetStaticFieldFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jdouble (*GetStaticFieldDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + void (*SetStaticField)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, void* c); + void (*SetStaticFieldBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jbool c); + void (*SetStaticFieldByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jbyte c); + void (*SetStaticFieldChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jchar c); + void (*SetStaticFieldShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jshort c); + void (*SetStaticFieldInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jint c); + void (*SetStaticFieldLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jlong c); + void (*SetStaticFieldFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jfloat c); + void (*SetStaticFieldDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jdouble c); + struct java_lang_String* (*NewString)(JRIEnv* env, jint op, const jchar* a, jint b); + jint (*GetStringLength)(JRIEnv* env, jint op, struct java_lang_String* a); + const jchar* (*GetStringChars)(JRIEnv* env, jint op, struct java_lang_String* a); + struct java_lang_String* (*NewStringUTF)(JRIEnv* env, jint op, const jbyte* a, jint b); + jint (*GetStringUTFLength)(JRIEnv* env, jint op, struct java_lang_String* a); + const jbyte* (*GetStringUTFChars)(JRIEnv* env, jint op, struct java_lang_String* a); + void* (*NewScalarArray)(JRIEnv* env, jint op, jint a, const char* b, const jbyte* c); + jint (*GetScalarArrayLength)(JRIEnv* env, jint op, void* a); + jbyte* (*GetScalarArrayElements)(JRIEnv* env, jint op, void* a); + void* (*NewObjectArray)(JRIEnv* env, jint op, jint a, struct java_lang_Class* b, void* c); + jint (*GetObjectArrayLength)(JRIEnv* env, jint op, void* a); + void* (*GetObjectArrayElement)(JRIEnv* env, jint op, void* a, jint b); + void (*SetObjectArrayElement)(JRIEnv* env, jint op, void* a, jint b, void* c); + void (*RegisterNatives)(JRIEnv* env, jint op, struct java_lang_Class* a, char** b, void** c); + void (*UnregisterNatives)(JRIEnv* env, jint op, struct java_lang_Class* a); + struct java_lang_Class* (*DefineClass)(JRIEnv* env, jint op, struct java_lang_ClassLoader* a, jbyte* b, jsize bLen); + struct java_lang_String* (*NewStringPlatform)(JRIEnv* env, jint op, const jbyte* a, jint b, const jbyte* c, jint d); + const jbyte* (*GetStringPlatformChars)(JRIEnv* env, jint op, struct java_lang_String* a, const jbyte* b, jint c); +}; + +/* +** **************************************************************************** +** JRIEnv Operation IDs +** *************************************************************************** +*/ + +typedef enum JRIEnvOperations { + JRI_Reserved0_op, + JRI_Reserved1_op, + JRI_Reserved2_op, + JRI_Reserved3_op, + JRI_FindClass_op, + JRI_Throw_op, + JRI_ThrowNew_op, + JRI_ExceptionOccurred_op, + JRI_ExceptionDescribe_op, + JRI_ExceptionClear_op, + JRI_NewGlobalRef_op, + JRI_DisposeGlobalRef_op, + JRI_GetGlobalRef_op, + JRI_SetGlobalRef_op, + JRI_IsSameObject_op, + JRI_NewObject_op, + JRI_NewObject_op_va_list, + JRI_NewObject_op_array, + JRI_GetObjectClass_op, + JRI_IsInstanceOf_op, + JRI_GetMethodID_op, + JRI_CallMethod_op, + JRI_CallMethod_op_va_list, + JRI_CallMethod_op_array, + JRI_CallMethodBoolean_op, + JRI_CallMethodBoolean_op_va_list, + JRI_CallMethodBoolean_op_array, + JRI_CallMethodByte_op, + JRI_CallMethodByte_op_va_list, + JRI_CallMethodByte_op_array, + JRI_CallMethodChar_op, + JRI_CallMethodChar_op_va_list, + JRI_CallMethodChar_op_array, + JRI_CallMethodShort_op, + JRI_CallMethodShort_op_va_list, + JRI_CallMethodShort_op_array, + JRI_CallMethodInt_op, + JRI_CallMethodInt_op_va_list, + JRI_CallMethodInt_op_array, + JRI_CallMethodLong_op, + JRI_CallMethodLong_op_va_list, + JRI_CallMethodLong_op_array, + JRI_CallMethodFloat_op, + JRI_CallMethodFloat_op_va_list, + JRI_CallMethodFloat_op_array, + JRI_CallMethodDouble_op, + JRI_CallMethodDouble_op_va_list, + JRI_CallMethodDouble_op_array, + JRI_GetFieldID_op, + JRI_GetField_op, + JRI_GetFieldBoolean_op, + JRI_GetFieldByte_op, + JRI_GetFieldChar_op, + JRI_GetFieldShort_op, + JRI_GetFieldInt_op, + JRI_GetFieldLong_op, + JRI_GetFieldFloat_op, + JRI_GetFieldDouble_op, + JRI_SetField_op, + JRI_SetFieldBoolean_op, + JRI_SetFieldByte_op, + JRI_SetFieldChar_op, + JRI_SetFieldShort_op, + JRI_SetFieldInt_op, + JRI_SetFieldLong_op, + JRI_SetFieldFloat_op, + JRI_SetFieldDouble_op, + JRI_IsSubclassOf_op, + JRI_GetStaticMethodID_op, + JRI_CallStaticMethod_op, + JRI_CallStaticMethod_op_va_list, + JRI_CallStaticMethod_op_array, + JRI_CallStaticMethodBoolean_op, + JRI_CallStaticMethodBoolean_op_va_list, + JRI_CallStaticMethodBoolean_op_array, + JRI_CallStaticMethodByte_op, + JRI_CallStaticMethodByte_op_va_list, + JRI_CallStaticMethodByte_op_array, + JRI_CallStaticMethodChar_op, + JRI_CallStaticMethodChar_op_va_list, + JRI_CallStaticMethodChar_op_array, + JRI_CallStaticMethodShort_op, + JRI_CallStaticMethodShort_op_va_list, + JRI_CallStaticMethodShort_op_array, + JRI_CallStaticMethodInt_op, + JRI_CallStaticMethodInt_op_va_list, + JRI_CallStaticMethodInt_op_array, + JRI_CallStaticMethodLong_op, + JRI_CallStaticMethodLong_op_va_list, + JRI_CallStaticMethodLong_op_array, + JRI_CallStaticMethodFloat_op, + JRI_CallStaticMethodFloat_op_va_list, + JRI_CallStaticMethodFloat_op_array, + JRI_CallStaticMethodDouble_op, + JRI_CallStaticMethodDouble_op_va_list, + JRI_CallStaticMethodDouble_op_array, + JRI_GetStaticFieldID_op, + JRI_GetStaticField_op, + JRI_GetStaticFieldBoolean_op, + JRI_GetStaticFieldByte_op, + JRI_GetStaticFieldChar_op, + JRI_GetStaticFieldShort_op, + JRI_GetStaticFieldInt_op, + JRI_GetStaticFieldLong_op, + JRI_GetStaticFieldFloat_op, + JRI_GetStaticFieldDouble_op, + JRI_SetStaticField_op, + JRI_SetStaticFieldBoolean_op, + JRI_SetStaticFieldByte_op, + JRI_SetStaticFieldChar_op, + JRI_SetStaticFieldShort_op, + JRI_SetStaticFieldInt_op, + JRI_SetStaticFieldLong_op, + JRI_SetStaticFieldFloat_op, + JRI_SetStaticFieldDouble_op, + JRI_NewString_op, + JRI_GetStringLength_op, + JRI_GetStringChars_op, + JRI_NewStringUTF_op, + JRI_GetStringUTFLength_op, + JRI_GetStringUTFChars_op, + JRI_NewScalarArray_op, + JRI_GetScalarArrayLength_op, + JRI_GetScalarArrayElements_op, + JRI_NewObjectArray_op, + JRI_GetObjectArrayLength_op, + JRI_GetObjectArrayElement_op, + JRI_SetObjectArrayElement_op, + JRI_RegisterNatives_op, + JRI_UnregisterNatives_op, + JRI_DefineClass_op, + JRI_NewStringPlatform_op, + JRI_GetStringPlatformChars_op +} JRIEnvOperations; #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* JRI_H */ +/******************************************************************************/ diff --git a/sun-java/stubs/include/jri_md.h b/sun-java/stubs/include/jri_md.h index 2d1a5c110049..fb7358c2f41b 100644 --- a/sun-java/stubs/include/jri_md.h +++ b/sun-java/stubs/include/jri_md.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- 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.0 (the "NPL"); you may not use this file except in @@ -15,6 +15,11 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +/******************************************************************************* + * Java Runtime Interface - Machine Dependent Types + ******************************************************************************/ + #ifndef JRI_MD_H #define JRI_MD_H @@ -95,7 +100,7 @@ extern "C" { # endif /* Mac */ -#elif macintosh || Macintosh || THINK_C +#elif defined (macintosh) || Macintosh || THINK_C # if defined(__MWERKS__) /* Metrowerks */ # if !__option(enumsalwaysint) # error You need to define 'Enums Always Int' for your project. @@ -121,7 +126,7 @@ extern "C" { /* Unix or else */ #else -# define JRI_PUBLIC_API(ResultType) ResultType +# define JRI_PUBLIC_API(ResultType) ResultType # define JRI_PUBLIC_VAR(VarType) VarType # define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) # define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) @@ -145,6 +150,9 @@ typedef double jdouble; typedef juint jsize; #endif +/* moved from jni.h -- Sun's new jni.h doesn't have this anymore */ +typedef struct _jobject *jref; + typedef unsigned char jbool; typedef char jbyte; #ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */ @@ -167,21 +175,30 @@ typedef long jint; #ifdef HAVE_LONG_LONG -#if !(defined(WIN32) || defined(_WIN32)) -typedef long long jlong; -typedef unsigned long long julong; +#ifdef OSF1 -#define jlong_MAXINT 0x7fffffffffffffffLL -#define jlong_MININT 0x8000000000000000LL -#define jlong_ZERO 0x0LL +/* long is default 64-bit on OSF1, -std1 does not allow long long */ +typedef long jlong; +typedef unsigned long julong; +#define jlong_MAXINT 0x7fffffffffffffffL +#define jlong_MININT 0x8000000000000000L +#define jlong_ZERO 0x0L + +#elif (defined(WIN32) || defined(_WIN32)) + +typedef LONGLONG jlong; +typedef DWORDLONG julong; +#define jlong_MAXINT 0x7fffffffffffffffi64 +#define jlong_MININT 0x8000000000000000i64 +#define jlong_ZERO 0x0i64 #else -typedef LONGLONG jlong; -typedef DWORDLONG julong; -#define jlong_MAXINT 0x7fffffffffffffffi64 -#define jlong_MININT 0x8000000000000000i64 -#define jlong_ZERO 0x0i64 +typedef long long jlong; +typedef unsigned long long julong; +#define jlong_MAXINT 0x7fffffffffffffffLL +#define jlong_MININT 0x8000000000000000LL +#define jlong_ZERO 0x0LL #endif diff --git a/sun-java/stubs/include/jriext.h b/sun-java/stubs/include/jriext.h index f64455864d66..e52d6f29b56f 100644 --- a/sun-java/stubs/include/jriext.h +++ b/sun-java/stubs/include/jriext.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- 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.0 (the "NPL"); you may not use this file except in @@ -15,16 +15,613 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +/******************************************************************************* + * Java Runtime Interface -- Extension Interfaces + ******************************************************************************/ + #ifndef JRIEXT_H #define JRIEXT_H #include "jri.h" +#include "minicom.h" #ifdef __cplusplus extern "C" { #endif +extern const GUID JRINativePkgID; + +/******************************************************************************* + * Optional Embedding + ******************************************************************************/ + +/* Runtime */ +extern const GUID JRIRuntimePkgID; + +typedef struct JRIRuntimeInterface JRIRuntimeInterface; +typedef const JRIRuntimeInterface* JRIRuntimeInstance; + +typedef void +(JRI_CALLBACK* JRICollectionStartProc)(JRIRuntimeInstance* runtime); + +typedef void +(JRI_CALLBACK* JRICollectionEndProc)(JRIRuntimeInstance* runtime); + +/* Passed in JRIRuntimeInitargs: */ +typedef enum JRIVerifyMode { + JRIVerifyNone, + JRIVerifyRemote, + JRIVerifyAll +} JRIVerifyMode; + +typedef struct JRIRuntimeInitargsStruct { + /* Required arguments */ + short majorVersion; + short minorVersion; + jsize initialHeapSize; + jsize maxHeapSize; + JRICollectionStartProc collectionStartProc; + JRICollectionEndProc collectionEndProc; + JRIVerifyMode verifyMode; + int insideNavigator; +} JRIRuntimeInitargs; + +/* JRIIOMode control bits. These can be or'd together */ +typedef enum JRIIOModeFlags { + JRIIOMode_Unrestricted = ~0, + JRIIOMode_None = 0, + JRIIOMode_AllowStdin = 0x01, + JRIIOMode_AllowStdout = 0x02, + JRIIOMode_AllowSocket = 0x04, + JRIIOMode_AllowFileInput = 0x08, + JRIIOMode_AllowFileOutput = 0x10 +} JRIIOModeFlags; + +typedef enum JRIFSModeFlags { + JRIFSMode_Unrestricted, /* no C level filesystem checks */ + JRIFSMode_None /* no filesystem access allowed */ +} JRIFSModeFlags; + +typedef enum JRIRTModeFlags { + JRIRTMode_Unrestricted, /* no C level runtime checks */ + JRIRTMode_None /* no runtime access allowed */ +} JRIRTModeFlags; + +extern JRI_PUBLIC_API(JRIRuntimeInstance*) +JRI_NewRuntime(JRIRuntimeInitargs* initargs); + +typedef void +(*JRI_DisposeRuntime_t)(JRIRuntimeInstance* runtime); + +/* +** Change the JRI io mode. The JRI io mode is the lowest level security +** check done by the C implementation of the native i/o methods. +*/ +typedef void +(*JRI_SetIOMode_t)(JRIRuntimeInstance* runtime, JRIIOModeFlags mode); + +/* +** Change the JRI fs mode. The JRI fs mode is the lowest level security +** check done by the C implementation of the native filesystem methods. +*/ +typedef void +(*JRI_SetFSMode_t)(JRIRuntimeInstance* runtime, JRIFSModeFlags mode); + +/* +** Change the JRI runtime mode. The JRI runtime mode is the lowest +** level security check done by the C implementation of the native +** runtime methods. +*/ +typedef void +(*JRI_SetRTMode_t)(JRIRuntimeInstance* runtime, JRIRTModeFlags mode); + +/* Environments */ + +typedef JRIEnv* +(*JRI_NewEnv_t)(JRIRuntimeInstance* runtime, void* thread); + +typedef void +(*JRI_DisposeEnv_t)(JRIEnv* env); + +typedef JRIRuntimeInstance* +(*JRI_GetRuntime_t)(JRIEnv* env); + +typedef void* +(*JRI_GetThread_t)(JRIEnv* env); + +typedef void +(*JRI_SetClassLoader_t)(JRIEnv* env, jref classLoader); + +struct JRIRuntimeInterface { + MCOM_QueryInterface_t QueryInterface; + MCOM_AddRef_t AddRef; + MCOM_Release_t Release; + void* reserved3; + JRI_DisposeRuntime_t DisposeRuntime; + JRI_SetIOMode_t SetIOMode; + JRI_SetFSMode_t SetFSMode; + JRI_SetRTMode_t SetRTMode; + JRI_NewEnv_t NewEnv; + JRI_DisposeEnv_t DisposeEnv; + JRI_GetRuntime_t GetRuntime; + JRI_GetThread_t GetThread; + JRI_SetClassLoader_t SetClassLoader; +}; + +#define JRI_DisposeRuntime(runtime) \ + ((*(runtime))->DisposeRuntime(runtime)) + +/* +** Change the JRI io mode. The JRI io mode is the lowest level security +** check done by the C implementation of the native i/o methods. +*/ +#define JRI_SetIOMode(runtime, mode) \ + ((*(runtime))->SetIOMode(runtime, mode)) + +/* +** Change the JRI fs mode. The JRI fs mode is the lowest level security +** check done by the C implementation of the native filesystem methods. +*/ +#define JRI_SetFSMode(runtime, mode) \ + ((*(runtime))->SetFSMode(runtime, mode)) + +/* +** Change the JRI runtime mode. The JRI runtime mode is the lowest +** level security check done by the C implementation of the native +** runtime methods. +*/ +#define JRI_SetRTMode(runtime, mode) \ + ((*(runtime))->SetRTMode(runtime, mode)) + +/* Environments */ + +#define JRI_NewEnv(runtime, thread) \ + ((*(runtime))->NewEnv(runtime, thread)) + +#define JRI_DisposeEnv(env) \ + ((*(env))->DisposeEnv(env)) + +#define JRI_GetRuntime(env) \ + ((*(env))->GetRuntime(env)) + +#define JRI_GetThread(env) \ + ((*(env))->GetThread(env)) + +#define JRI_SetClassLoader(env, classLoader) \ + ((*(env))->SetClassLoader(env, classLoader)) + +/******************************************************************************* + * Optional Reflection + ******************************************************************************/ + +extern const GUID JRIReflectionPkgID; + +typedef struct JRIReflectionInterface JRIReflectionInterface; +typedef const JRIReflectionInterface* JRIReflectionEnv; + +typedef enum JRIAccessFlags { + /* Field and Method Access */ + JRIAccessPublic = 0x0001, + JRIAccessPrivate = 0x0002, + JRIAccessProtected = 0x0004, + JRIAccessStatic = 0x0008, + JRIAccessFinal = 0x0010, + JRIAccessSynchronized = 0x0020, + JRIAccessNative = 0x0100, + /* Class Access */ + JRIAccessInterface = 0x0200, + JRIAccessAbstract = 0x0400 +} JRIAccessFlags; + +typedef jsize +(*JRI_GetClassCount_t)(JRIReflectionEnv* env); + +typedef jref +(*JRI_GetClass_t)(JRIReflectionEnv* env, jsize index); + +typedef const char* +(*JRI_GetClassName_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +typedef jbool +(*JRI_VerifyClass_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +typedef jref +(*JRI_GetClassSuperclass_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +/* These next two routines can be used to iterate through all the + interfaces of a class: */ + +typedef jsize +(*JRI_GetClassInterfaceCount_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +typedef jref +(*JRI_GetClassInterface_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz, jsize index); + +/* These next two routines can be used to iterate through all the + fields of a class, getting info about them: */ + +typedef jsize +(*JRI_GetClassFieldCount_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +typedef void +(*JRI_GetClassFieldInfo_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz, + jsize fieldIndex, char* *fieldName, char* *fieldSig, + JRIAccessFlags *fieldAccess, jref *fieldClass); + +/* These next two routines can be used to iterate through all the + methods of a class, getting info about them: */ + +typedef jsize +(*JRI_GetClassMethodCount_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +typedef void +(*JRI_GetClassMethodInfo_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz, + jsize methodIndex, char* *methodName, char* *methodSig, + JRIAccessFlags *methodAccess, + jref *methodClass, void* *methodNativeProc); + +typedef JRIAccessFlags +(*JRI_GetClassAccessFlags_t)(JRIReflectionEnv* env, struct java_lang_Class* clazz); + +/******************************************************************************/ + +struct JRIReflectionInterface { + MCOM_QueryInterface_t QueryInterface; + MCOM_AddRef_t AddRef; + MCOM_Release_t Release; + void* reserved3; + JRI_GetClassCount_t GetClassCount; + JRI_GetClass_t GetClass; + JRI_GetClassName_t GetClassName; + JRI_VerifyClass_t VerifyClass; + JRI_GetClassSuperclass_t GetClassSuperclass; + JRI_GetClassInterfaceCount_t GetClassInterfaceCount; + JRI_GetClassInterface_t GetClassInterface; + JRI_GetClassFieldCount_t GetClassFieldCount; + JRI_GetClassFieldInfo_t GetClassFieldInfo; + JRI_GetClassMethodCount_t GetClassMethodCount; + JRI_GetClassMethodInfo_t GetClassMethodInfo; + JRI_GetClassAccessFlags_t GetClassAccessFlags; +}; + +#define JRI_GetClassCount(env) \ + ((*(env))->GetClassCount(env)) + +#define JRI_GetClass(env, index) \ + ((*(env))->GetClass(env, index)) + +#define JRI_GetClassName(env, clazz) \ + ((*(env))->GetClassName(env, clazz)) + +#define JRI_VerifyClass(env, clazz) \ + ((*(env))->VerifyClass(env, clazz)) + +#define JRI_GetClassSuperclass(env, clazz) \ + ((*(env))->GetClassSuperclass(env, clazz)) + +/* These next two routines can be used to iterate through all the + interfaces of a class: */ + +#define JRI_GetClassInterfaceCount(env, clazz) \ + ((*(env))->GetClassInterfaceCount(env, clazz)) + +#define JRI_GetClassInterface(env, clazz, index) \ + ((*(env))->GetClassInterface(env, clazz, index)) + +/* These next two routines can be used to iterate through all the + fields of a class, getting info about them: */ + +#define JRI_GetClassFieldCount(env, clazz) \ + ((*(env))->GetClassFieldCount(env, clazz)) + +#define JRI_GetClassFieldInfo(env, clazz, fieldIndex, fieldName, fieldSig, fieldAccess, fieldClass) \ + ((*(env))->GetClassFieldInfo(env, clazz, fieldIndex, fieldName, fieldSig, fieldAccess, fieldClass)) + +/* These next two routines can be used to iterate through all the + methods of a class, getting info about them: */ + +#define JRI_GetClassMethodCount(env, clazz) \ + ((*(env))->GetClassMethodCount(env, clazz)) + +#define JRI_GetClassMethodInfo(env, clazz, methodIndex, methodName, methodSig, methodAccess, methodClass, methodNativeProc) \ + ((*(env))->GetClassMethodInfo(env, clazz, methodIndex, methodName, methodSig, methodAccess, methodClass, methodNativeProc)) + +#define JRI_GetClassAccessFlags(env, clazz) \ + ((*(env))->GetClassAccessFlags(env, clazz)) + +/******************************************************************************* + * Optional Debugger + ******************************************************************************/ + +extern const GUID JRIDebuggerPkgID; + +typedef struct JRIDebuggerInterface JRIDebuggerInterface; +typedef const JRIDebuggerInterface* JRIDebuggerEnv; + +/* Manipulating Stacks */ + +typedef jsize +(*JRI_GetFrameCount_t)(JRIDebuggerEnv* env); + +typedef jbool +(*JRI_GetFrameInfo_t)(JRIDebuggerEnv* env, jsize frameIndex, + jref *methodClass, jsize *methodIndex, + jsize *pc, jsize *varsCount); + +typedef void +(*JRI_GetVarInfo_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, + char* *name, char* *signature, + jbool *isArgument, jsize *startScope, jsize *endScope); + +#define JRIVarNotInScope ((JRIFieldID)-1) + +typedef void +(*JRI_GetSourceInfo_t)(JRIDebuggerEnv* env, jsize frameIndex, + const char* *filename, jsize *lineNumber); + +/******************************************************************************/ + +typedef jref +(*JRI_GetVar_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jbool +(*JRI_GetVar_boolean_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jbyte +(*JRI_GetVar_byte_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jchar +(*JRI_GetVar_char_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jshort +(*JRI_GetVar_short_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jint +(*JRI_GetVar_int_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jlong +(*JRI_GetVar_long_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jfloat +(*JRI_GetVar_float_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +typedef jdouble +(*JRI_GetVar_double_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex); + +/******************************************************************************/ + +typedef void +(*JRI_SetVar_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jref value); + +typedef void +(*JRI_SetVar_boolean_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jbool value); + +typedef void +(*JRI_SetVar_byte_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jbyte value); + +typedef void +(*JRI_SetVar_char_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jchar value); + +typedef void +(*JRI_SetVar_short_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jshort value); + +typedef void +(*JRI_SetVar_int_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jint value); + +typedef void +(*JRI_SetVar_long_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jlong value); + +typedef void +(*JRI_SetVar_float_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jfloat value); + +typedef void +(*JRI_SetVar_double_t)(JRIDebuggerEnv* env, jsize frameIndex, jsize varIndex, jdouble value); + +/******************************************************************************/ + +/* Controlling Execution */ + +typedef void +(*JRI_StepOver_t)(JRIDebuggerEnv* env); + +typedef void +(*JRI_StepIn_t)(JRIDebuggerEnv* env); + +typedef void +(*JRI_StepOut_t)(JRIDebuggerEnv* env); + +typedef void +(*JRI_Continue_t)(JRIDebuggerEnv* env); + +typedef void +(*JRI_Return_t)(JRIDebuggerEnv* env, jsize frameIndex, JRIValue value); + +/******************************************************************************/ + +struct JRIDebuggerInterface { + MCOM_QueryInterface_t QueryInterface; + MCOM_AddRef_t AddRef; + MCOM_Release_t Release; + void* reserved3; + JRI_GetFrameCount_t GetFrameCount; + JRI_GetFrameInfo_t GetFrameInfo; + JRI_GetVarInfo_t GetVarInfo; + JRI_GetSourceInfo_t GetSourceInfo; + JRI_GetVar_t GetVar; + JRI_GetVar_boolean_t GetVar_boolean; + JRI_GetVar_byte_t GetVar_byte; + JRI_GetVar_char_t GetVar_char; + JRI_GetVar_short_t GetVar_short; + JRI_GetVar_int_t GetVar_int; + JRI_GetVar_long_t GetVar_long; + JRI_GetVar_float_t GetVar_float; + JRI_GetVar_double_t GetVar_double; + JRI_SetVar_t SetVar; + JRI_SetVar_boolean_t SetVar_boolean; + JRI_SetVar_byte_t SetVar_byte; + JRI_SetVar_char_t SetVar_char; + JRI_SetVar_short_t SetVar_short; + JRI_SetVar_int_t SetVar_int; + JRI_SetVar_long_t SetVar_long; + JRI_SetVar_float_t SetVar_float; + JRI_SetVar_double_t SetVar_double; + JRI_StepOver_t StepOver; + JRI_StepIn_t StepIn; + JRI_StepOut_t StepOut; + JRI_Continue_t Continue; + JRI_Return_t Return; +}; + + +#define JRI_GetFrameCount(env) \ + ((*(env))->GetFrameCount(env)) + +#define JRI_GetFrameInfo(env, frameIndex, methodClass, methodIndex, pc, varsCount) \ + ((*(env))->GetFrameInfo(env, frameIndex, methodClass, methodIndex, pc, varsCount)) + +#define JRI_GetVarInfo(env, frameIndex, varIndex, name, signature, pos, isArgument, startScope, endScope) \ + ((*(env))->GetVarInfo(env, frameIndex, varIndex, name, signature, pos, isArgument, startScope, endScope)) + +#define JRI_GetSourceInfo(env, frameIndex, filename, lineNumber) \ + ((*(env))->GetSourceInfo(env, frameIndex, filename, lineNumber)) + +/******************************************************************************/ + +#define JRI_GetVar(env, frameIndex, varIndex) \ + ((*(env))->GetVar(env, frameIndex, varIndex)) + +#define JRI_GetVar_boolean(env, frameIndex, varIndex) \ + ((*(env))->GetVar_boolean(env, frameIndex, varIndex)) + +#define JRI_GetVar_byte(env, frameIndex, varIndex) \ + ((*(env))->GetVar_byte(env, frameIndex, varIndex)) + +#define JRI_GetVar_char(env, frameIndex, varIndex) \ + ((*(env))->GetVar_char(env, frameIndex, varIndex)) + +#define JRI_GetVar_short(env, frameIndex, varIndex) \ + ((*(env))->GetVar_short(env, frameIndex, varIndex)) + +#define JRI_GetVar_int(env, frameIndex, varIndex) \ + ((*(env))->GetVar_int(env, frameIndex, varIndex)) + +#define JRI_GetVar_long(env, frameIndex, varIndex) \ + ((*(env))->GetVar_long(env, frameIndex, varIndex)) + +#define JRI_GetVar_float(env, frameIndex, varIndex) \ + ((*(env))->GetVar_float(env, frameIndex, varIndex)) + +#define JRI_GetVar_double(env, frameIndex, varIndex) \ + ((*(env))->GetVar_double(env, frameIndex, varIndex)) + +/******************************************************************************/ + +#define JRI_SetVar(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_boolean(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_boolean(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_byte(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_byte(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_char(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_char(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_short(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_short(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_int(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_int(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_long(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_long(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_float(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_float(env, frameIndex, varIndex, value)) + +#define JRI_SetVar_double(env, frameIndex, varIndex, value) \ + ((*(env))->SetVar_double(env, frameIndex, varIndex, value)) + +/******************************************************************************/ + +/* Controlling Execution */ + +#define JRI_StepOver(env) \ + ((*(env))->StepOver(env)) + +#define JRI_StepIn(env) \ + ((*(env))->StepIn(env)) + +#define JRI_StepOut(env) \ + ((*(env))->StepOut(env)) + +#define JRI_Continue(env) \ + ((*(env))->Continue(env)) + +#define JRI_Return(env, frameIndex, value) \ + ((*(env))->Return(env, frameIndex, value)) + +/******************************************************************************* + * Optional Compiling + ******************************************************************************/ + +extern const GUID JRICompilerPkgID; + +typedef struct JRICompilerInterface JRICompilerInterface; +typedef const JRICompilerInterface* JRICompilerEnv; + +typedef void +(*JRI_CompileClass_t)(JRICompilerEnv* env, + const char* classSrc, jsize classSrcLen, + jbyte* *resultingClassData, jsize *classDataLen); + +struct JRICompilerInterface { + MCOM_QueryInterface_t QueryInterface; + MCOM_AddRef_t AddRef; + MCOM_Release_t Release; + void* reserved3; + JRI_CompileClass_t CompileClass; +}; + +#define JRI_CompileClass(env, classSrc, classSrcLen, resultingClassData, classDataLen) \ + ((*(env))->CompileClass(env, classSrc, classSrcLen, resultingClassData, classDataLen)) + +/******************************************************************************* + * Optional Expression Evaluation + ******************************************************************************/ + +extern const GUID JRIExprPkgID; + +typedef struct JRIExprInterface JRIExprInterface; +typedef const JRIExprInterface* JRIExprEnv; + +typedef jref +(*JRI_CompileExpr_t)(JRIExprEnv* env, + const char* exprSrc, jsize exprSrcLen); + +typedef jref +(*JRI_EvalExpr_t)(JRIExprEnv* env, jref expr); + +struct JRIExprInterface { + MCOM_QueryInterface_t QueryInterface; + MCOM_AddRef_t AddRef; + MCOM_Release_t Release; + void* reserved3; + JRI_CompileExpr_t CompileExpr; + JRI_EvalExpr_t EvalExpr; +}; + +#define JRI_CompileExpr(env, exprSrc, exprSrcLen) \ + ((*(env))->CompileExpr(env, exprSrc, exprSrcLen)) + +#define JRI_EvalExpr(env, expr) \ + ((*(env))->EvalExpr(env, expr)) + +/******************************************************************************/ #ifdef __cplusplus } #endif #endif /* JRIEXT_H */ +/******************************************************************************/ diff --git a/sun-java/stubs/include/jritypes.h b/sun-java/stubs/include/jritypes.h index 61c386b736e3..b008a9ae6fa1 100644 --- a/sun-java/stubs/include/jritypes.h +++ b/sun-java/stubs/include/jritypes.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- 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.0 (the "NPL"); you may not use this file except in @@ -15,9 +15,15 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +/******************************************************************************* + * Java Runtime Interface + ******************************************************************************/ + #ifndef JRITYPES_H #define JRITYPES_H +#include "jri_md.h" #include "jni.h" #include #include @@ -27,20 +33,192 @@ extern "C" { #endif -typedef void *JRIGlobalRef; -typedef JRIGlobalRef jglobal; +/******************************************************************************* + * Types + ******************************************************************************/ + +struct JRIEnvInterface; + +typedef void* JRIRef; +typedef void* JRIGlobalRef; -typedef struct jarrayArrayStruct* jarrayArray; typedef jint JRIFieldID; typedef jint JRIMethodID; +/* synonyms: */ +typedef JRIGlobalRef jglobal; + +typedef union JRIValue { + jbool z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong l; + jfloat f; + jdouble d; + jref r; +} JRIValue; + +typedef enum JRIBoolean { + JRIFalse = 0, + JRITrue = 1 +} JRIBoolean; + typedef enum JRIConstant { JRIUninitialized = -1 } JRIConstant; +/* convenience types (these must be distinct struct types for c++ overloading): */ +#if 0 /* now in jni.h */ +typedef struct jbooleanArrayStruct* jbooleanArray; +typedef struct jbyteArrayStruct* jbyteArray; +typedef struct jcharArrayStruct* jcharArray; +typedef struct jshortArrayStruct* jshortArray; +typedef struct jintArrayStruct* jintArray; +typedef struct jlongArrayStruct* jlongArray; +typedef struct jfloatArrayStruct* jfloatArray; +typedef struct jdoubleArrayStruct* jdoubleArray; +typedef struct jobjectArrayStruct* jobjectArray; +#endif +typedef struct jstringArrayStruct* jstringArray; +typedef struct jarrayArrayStruct* jarrayArray; +#define JRIConstructorMethodName "" + +/******************************************************************************* + * Signature Construction Macros + ******************************************************************************/ + +/* +** These macros can be used to construct signature strings. Hopefully their names +** are a little easier to remember than the single character they correspond to. +** For example, to specify the signature of the method: +** +** public int read(byte b[], int off, int len); +** +** you could write something like this in C: +** +** char* readSig = JRISigMethod(JRISigArray(JRISigByte) +** JRISigInt +** JRISigInt) JRISigInt; +** +** Of course, don't put commas between the types. +*/ +#define JRISigArray(T) "[" T +#define JRISigByte "B" +#define JRISigChar "C" +#define JRISigClass(name) "L" name ";" +#define JRISigFloat "F" +#define JRISigDouble "D" +#define JRISigMethod(args) "(" args ")" +#define JRISigNoArgs "" +#define JRISigInt "I" +#define JRISigLong "J" +#define JRISigShort "S" +#define JRISigVoid "V" +#define JRISigBoolean "Z" + +/******************************************************************************* + * Environments + ******************************************************************************/ + +extern JRI_PUBLIC_API(const struct JRIEnvInterface**) +JRI_GetCurrentEnv(void); + +/******************************************************************************* + * Specific Scalar Array Types + ******************************************************************************/ + +/* +** The JRI Native Method Interface does not support boolean arrays. This +** is to allow Java runtime implementations to optimize boolean array +** storage. Using the ScalarArray operations on boolean arrays is bound +** to fail, so convert any boolean arrays to byte arrays in Java before +** passing them to a native method. +*/ + +#define JRI_NewByteArray(env, length, initialValues) \ + JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues)) +#define JRI_GetByteArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetByteArrayElements(env, array) \ + JRI_GetScalarArrayElements(env, array) + +#define JRI_NewCharArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues)) +#define JRI_GetCharArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetCharArrayElements(env, array) \ + ((jchar*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewShortArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues)) +#define JRI_GetShortArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetShortArrayElements(env, array) \ + ((jshort*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewIntArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues)) +#define JRI_GetIntArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetIntArrayElements(env, array) \ + ((jint*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewLongArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues)) +#define JRI_GetLongArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetLongArrayElements(env, array) \ + ((jlong*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewFloatArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues)) +#define JRI_GetFloatArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetFloatArrayElements(env, array) \ + ((jfloat*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewDoubleArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues)) +#define JRI_GetDoubleArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetDoubleArrayElements(env, array) \ + ((jdouble*)JRI_GetScalarArrayElements(env, array)) + +/******************************************************************************/ +/* +** JDK Stuff -- This stuff is still needed while we're using the JDK +** dynamic linking strategy to call native methods. +*/ + +typedef union JRI_JDK_stack_item { + /* Non pointer items */ + jint i; + jfloat f; + jint o; + /* Pointer items */ + void *h; + void *p; + unsigned char *addr; +#ifdef IS_64 + double d; + long l; /* == 64bits! */ +#endif +} JRI_JDK_stack_item; + +typedef union JRI_JDK_Java8Str { + jint x[2]; + jdouble d; + jlong l; + void *p; + float f; +} JRI_JDK_Java8; + +/******************************************************************************/ #ifdef __cplusplus } #endif - #endif /* JRITYPES_H */ +/******************************************************************************/ diff --git a/xpcom/components/nsRepository.cpp b/xpcom/components/nsRepository.cpp index 89445f74f637..44f85e61b2f4 100644 --- a/xpcom/components/nsRepository.cpp +++ b/xpcom/components/nsRepository.cpp @@ -55,7 +55,7 @@ public: } instance = NULL; } - ~FactoryEntry() { + ~FactoryEntry(void) { if (library != NULL) { free(library); } @@ -295,7 +295,7 @@ nsresult NSRepository::FindFactory(const nsCID &aClass, return res; } -nsresult NSRepository::checkInitialized() +nsresult NSRepository::checkInitialized(void) { nsresult res = NS_OK; if (factories == NULL) { @@ -304,7 +304,7 @@ nsresult NSRepository::checkInitialized() return res; } -nsresult NSRepository::Initialize() +nsresult NSRepository::Initialize(void) { if (factories == NULL) { factories = new nsHashtable(); @@ -586,7 +586,7 @@ static PRBool freeLibraryEnum(nsHashKey *aKey, void *aData) return PR_TRUE; } -nsresult NSRepository::FreeLibraries() +nsresult NSRepository::FreeLibraries(void) { PR_EnterMonitor(monitor); diff --git a/xpcom/macbuild/xpcom.exp b/xpcom/macbuild/xpcom.exp index 5573ba6aef72..0ba455d5d5d7 100644 --- a/xpcom/macbuild/xpcom.exp +++ b/xpcom/macbuild/xpcom.exp @@ -64,3 +64,4 @@ NS_NewISupportsArray__FPP16nsISupportsArray # NS_NewISupportsArray(nsISupportsA #AddRef__17SupportsArrayImplFv # SupportsArrayImpl::AddRef() #__dt__17SupportsArrayImplFv # SupportsArrayImpl::~SupportsArrayImpl() #__ct__17SupportsArrayImplFv # SupportsArrayImpl::SupportsArrayImpl() +Create__8nsMallocFP11nsISupportsRC4nsIDPPv # nsMalloc::Create(nsISupports*,const nsID&,void**) diff --git a/xpcom/macbuild/xpcomPPC.mcp b/xpcom/macbuild/xpcomPPC.mcp index 7b7fade825d9..8e87ea1bfa78 100644 Binary files a/xpcom/macbuild/xpcomPPC.mcp and b/xpcom/macbuild/xpcomPPC.mcp differ diff --git a/xpcom/src/MANIFEST b/xpcom/src/MANIFEST index 201d21abb17c..404f763422be 100644 --- a/xpcom/src/MANIFEST +++ b/xpcom/src/MANIFEST @@ -2,15 +2,18 @@ # This is a list of local files which get copied to the mozilla:dist directory # -nsAgg.h nsCom.h +nsAgg.h nsDebug.h nsError.h nsHashtable.h nsID.h nsIFactory.h -nsIPtr.h nsISupports.h +nsIPtr.h nsISupportsArray.h nsRepository.h nsIEnumerator.h +nsIMalloc.h +nsMalloc.h +nsVector.h diff --git a/xpcom/src/Makefile b/xpcom/src/Makefile index c3938d274139..1838e85eabab 100644 --- a/xpcom/src/Makefile +++ b/xpcom/src/Makefile @@ -24,6 +24,7 @@ CPPSRCS = nsDebug.cpp \ nsID.cpp \ nsSupportsArray.cpp \ nsRepository.cpp \ + nsMalloc.cpp \ $(NULL) EXPORTS = nsCom.h \ @@ -38,6 +39,9 @@ EXPORTS = nsCom.h \ nsISupportsArray.h \ nsRepository.h \ nsIEnumerator.h \ + nsIMalloc.h \ + nsMalloc.h \ + nsVector.h \ $(NULL) LCFLAGS = -D_IMPL_NS_COM -DUSE_NSREG diff --git a/xpcom/src/makefile.win b/xpcom/src/makefile.win index f09fd4040e2a..822e284f249a 100644 --- a/xpcom/src/makefile.win +++ b/xpcom/src/makefile.win @@ -45,6 +45,7 @@ CPPSRCS = \ nsID.cpp \ nsRepository.cpp \ nsSupportsArray.cpp \ + nsMalloc.cpp \ CPP_OBJS = \ .\$(OBJDIR)\nsDebug.obj \ @@ -52,6 +53,7 @@ CPP_OBJS = \ .\$(OBJDIR)\nsID.obj \ .\$(OBJDIR)\nsSupportsArray.obj \ .\$(OBJDIR)\nsRepository.obj \ + .\$(OBJDIR)\nsMalloc.obj \ EXPORTS = \ nsAgg.h \ @@ -66,6 +68,9 @@ EXPORTS = \ nsISupportsArray.h \ nsRepository.h \ nsIEnumerator.h \ + nsIMalloc.h \ + nsMalloc.h \ + nsVector.h \ $(NULL) MODULE = xpcom diff --git a/xpcom/src/nsMalloc.cpp b/xpcom/src/nsMalloc.cpp index de5827fe7ff2..00e33708350c 100644 --- a/xpcom/src/nsMalloc.cpp +++ b/xpcom/src/nsMalloc.cpp @@ -51,7 +51,7 @@ nsMalloc::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) return NS_NOINTERFACE; } -NS_METHOD +NS_COM NS_METHOD nsMalloc::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) { if (outer && !aIID.Equals(kISupportsIID)) diff --git a/xpcom/src/nsMalloc.h b/xpcom/src/nsMalloc.h index 2109ebc83697..99ecff8d3fbf 100644 --- a/xpcom/src/nsMalloc.h +++ b/xpcom/src/nsMalloc.h @@ -27,7 +27,7 @@ #include "prmem.h" #include "nsAgg.h" -class NS_COM nsMalloc : nsIMalloc { +class nsMalloc : nsIMalloc { public: /** @@ -92,7 +92,7 @@ public: NS_DECL_AGGREGATED - static NS_METHOD + static NS_COM NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); }; diff --git a/xpcom/src/nsRepository.cpp b/xpcom/src/nsRepository.cpp index 89445f74f637..44f85e61b2f4 100644 --- a/xpcom/src/nsRepository.cpp +++ b/xpcom/src/nsRepository.cpp @@ -55,7 +55,7 @@ public: } instance = NULL; } - ~FactoryEntry() { + ~FactoryEntry(void) { if (library != NULL) { free(library); } @@ -295,7 +295,7 @@ nsresult NSRepository::FindFactory(const nsCID &aClass, return res; } -nsresult NSRepository::checkInitialized() +nsresult NSRepository::checkInitialized(void) { nsresult res = NS_OK; if (factories == NULL) { @@ -304,7 +304,7 @@ nsresult NSRepository::checkInitialized() return res; } -nsresult NSRepository::Initialize() +nsresult NSRepository::Initialize(void) { if (factories == NULL) { factories = new nsHashtable(); @@ -586,7 +586,7 @@ static PRBool freeLibraryEnum(nsHashKey *aKey, void *aData) return PR_TRUE; } -nsresult NSRepository::FreeLibraries() +nsresult NSRepository::FreeLibraries(void) { PR_EnterMonitor(monitor); diff --git a/xpcom/src/nsRepository.h b/xpcom/src/nsRepository.h index 10aa2f8a8260..a5562c19d8f6 100644 --- a/xpcom/src/nsRepository.h +++ b/xpcom/src/nsRepository.h @@ -64,12 +64,11 @@ private: static nsHashtable *factories; static PRMonitor *monitor; - static nsresult checkInitialized(); + static nsresult checkInitialized(void); static nsresult loadFactory(FactoryEntry *aEntry, nsIFactory **aFactory); public: - static nsresult Initialize(); - + static nsresult Initialize(void); // Finds a factory for a specific class ID static nsresult FindFactory(const nsCID &aClass, nsIFactory **aFactory); @@ -107,7 +106,7 @@ public: const char *aLibrary); // Unload dynamically loaded factories that are not in use - static nsresult FreeLibraries(); + static nsresult FreeLibraries(void); }; #endif