Modifications for building under mach-o with project builder.

This commit is contained in:
beard%netscape.com 2002-05-23 22:33:04 +00:00
parent 11b68134ae
commit 888d4d444e
10 changed files with 112 additions and 61 deletions

View File

@ -401,10 +401,10 @@ public:
protected:
MRJPlugin* mPlugin;
JNIEnv* mProxyEnv;
JNIEnv* mJavaEnv;
MRJSession* mSession;
nsIThreadManager* mThreadManager;
JNIEnv* mJavaEnv;
jboolean* mIsRunning;
JavaMessageQueue* mJavaQueue;
JavaMessageQueue* mNativeQueue;

View File

@ -47,7 +47,6 @@
#include "SupportsMixin.h"
#include "jni.h"
#include <JManager.h>
class MRJPlugin;
class MRJSession;
@ -115,7 +114,10 @@ private:
jbooleanArray mResults;
#if !TARGET_CARBON
JMAWTContextRef mContext;
#endif
TopLevelFrame* mFrame;
// support for SupportsMixin.

View File

@ -64,7 +64,7 @@ public:
operator int() { return (mRef != NULL); }
private:
cfref(const cfref& other) {}
// cfref(const cfref<RefType>& other) {}
};
#endif
@ -75,11 +75,13 @@ private:
#include "MRJPage.h"
#include "MRJMonitor.h"
#include "AsyncMessage.h"
#include "TopLevelFrame.h"
#include "EmbeddedFrame.h"
#include "LocalPort.h"
#include "StringUtils.h"
#include "TimedMessage.h"
#if !TARGET_CARBON
#include "TopLevelFrame.h"
#include "EmbeddedFrame.h"
#endif
#include "nsIPluginManager2.h"
#include "nsIPluginInstancePeer.h"
@ -93,9 +95,6 @@ using namespace std;
extern nsIPluginManager* thePluginManager;
extern nsIPluginManager2* thePluginManager2;
static OSStatus JMTextToStr255(JMTextRef textRef, Str255 str);
static char* JMTextToEncoding(JMTextRef textRef, JMTextEncoding encoding);
static void blinkRgn(RgnHandle rgn);
void LocalPort::Enter()
@ -105,7 +104,7 @@ void LocalPort::Enter()
::SetPort(fPort);
Rect portRect;
GetPortBounds(fPort, &portRect);
fOldOrigin = topLeft(portRect);
fOldOrigin.h = portRect.left, fOldOrigin.v = portRect.top;
if (fOldOrigin.h != fOrigin.h || fOldOrigin.v != fOrigin.v)
::SetOrigin(fOrigin.h, fOrigin.v);
}
@ -127,9 +126,11 @@ static RgnHandle NewEmptyRgn()
MRJContext::MRJContext(MRJSession* session, MRJPluginInstance* instance)
: mPluginInstance(instance), mSession(session), mPeer(NULL),
#if !TARGET_CARBON
mLocator(NULL), mContext(NULL), mViewer(NULL), mViewerFrame(NULL),
#endif
mIsActive(false), mIsFocused(false), mIsVisible(false),
mPluginWindow(NULL), mPluginClipping(NULL), mPluginPort(NULL),
mPluginClipping(NULL), mPluginWindow(NULL), mPluginPort(NULL),
mDocumentBase(NULL), mAppletHTML(NULL), mPage(NULL), mSecurityContext(NULL)
#if TARGET_CARBON
, mAppletFrame(NULL), mAppletObject(NULL), mAppletControl(NULL), mScrollCounter(0)
@ -211,6 +212,10 @@ MRJContext::~MRJContext()
env->DeleteGlobalRef(mAppletObject);
mAppletObject = NULL;
}
if (mAppletControl != NULL) {
::DisposeControl(mAppletControl);
mAppletControl = NULL;
}
if (mAppletFrame != NULL) {
OSStatus status;
@ -228,6 +233,8 @@ MRJContext::~MRJContext()
#endif
}
#if !TARGET_CARBON
JMAWTContextRef MRJContext::getContextRef()
{
return mContext;
@ -238,6 +245,8 @@ JMAppletViewerRef MRJContext::getViewerRef()
return mViewer;
}
#endif
Boolean MRJContext::appletLoaded()
{
#if TARGET_CARBON
@ -413,7 +422,9 @@ static char* synthesizeAppletElement(nsIPluginTagInfo* tagInfo)
return ::strdup(element.c_str());
}
#if !TARGET_CARBON
static void fetchCompleted(JMAppletLocatorRef ref, JMLocatorErrors status) {}
#endif
#if TARGET_CARBON
@ -564,17 +575,17 @@ void MRJContext::processAppletTag()
}
}
#if !TARGET_CARBON
static MRJFrame* getFrame(JMFrameRef ref)
{
MRJFrame* frame = NULL;
#if !TARGET_CARBON
if (ref != NULL)
::JMGetFrameData(ref, (JMClientData*)&frame);
#endif
return frame;
}
#endif
Boolean MRJContext::createContext()
{
@ -652,6 +663,7 @@ void MRJContext::showURL(const char* url, const char* target)
}
}
#if !TARGET_CARBON
static SInt16 nextMenuId = 20000;
static SInt16 nextMenuPopupId = 200;
@ -667,8 +679,6 @@ SInt16 MRJContext::allocateMenuID(Boolean isSubmenu)
return (isSubmenu ? nextMenuPopupId++ : nextMenuId++);
}
#if !TARGET_CARBON
OSStatus MRJContext::createFrame(JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable)
{
OSStatus status = memFullErr;
@ -696,11 +706,8 @@ OSStatus MRJContext::createFrame(JMFrameRef frameRef, JMFrameKind kind, const Re
return status;
}
#endif
void MRJContext::setProxyInfoForURL(char * url, JMProxyType proxyType)
{
#if !TARGET_CARBON
/*
* We then call 'nsIPluginManager2::FindProxyForURL' which will return
* proxy information which we can parse and set via JMSetProxyInfo.
@ -727,9 +734,10 @@ void MRJContext::setProxyInfoForURL(char * url, JMProxyType proxyType)
delete[] proxy;
}
#endif
}
#endif /* !TARGET_CARBON */
#if TARGET_CARBON
void* TimedMessage::operator new(size_t n)

View File

@ -45,7 +45,6 @@
#pragma once
#include "jni.h"
#include "JManager.h"
#include "nsIPluginTagInfo2.h"
@ -78,9 +77,12 @@ public:
void processAppletTag();
Boolean createContext();
#if !TARGET_CARBON
JMAWTContextRef getContextRef();
JMAppletViewerRef getViewerRef();
#endif
Boolean appletLoaded();
Boolean loadApplet();
Boolean isActive();
@ -135,23 +137,27 @@ private:
void synchronizeClipping();
void synchronizeVisibility();
static OSStatus requestFrame(JMAWTContextRef context, JMFrameRef newFrame, JMFrameKind kind,
#if !TARGET_CARBON
static OSStatus requestFrame(JMAWTContextRef context, JMFrameRef newFrame, JMFrameKind kind,
const Rect *initialBounds, Boolean resizeable, JMFrameCallbacks *callbacks);
static OSStatus releaseFrame(JMAWTContextRef context, JMFrameRef oldFrame);
static SInt16 getUniqueMenuID(JMAWTContextRef context, Boolean isSubmenu);
static void exceptionOccurred(JMAWTContextRef context, JMTextRef exceptionName, JMTextRef exceptionMsg, JMTextRef stackTrace);
SInt16 allocateMenuID(Boolean isSubmenu);
OSStatus createFrame(JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable);
#endif
// Finds a suitable MRJPage object for this document URL, or creates one.
MRJPage* findPage(const MRJPageAttributes& attributes);
static CGrafPtr getEmptyPort();
#if !TARGET_CARBON
void setProxyInfoForURL(char * url, JMProxyType proxyType);
#endif
OSStatus installEventHandlers(WindowRef window);
OSStatus removeEventHandlers(WindowRef window);
@ -159,11 +165,13 @@ private:
MRJPluginInstance* mPluginInstance;
MRJSession* mSession;
nsIPluginInstancePeer* mPeer;
JMAppletLocatorRef mLocator;
#if !TARGET_CARBON
JMAppletLocatorRef mLocator;
JMAWTContextRef mContext;
JMAppletViewerRef mViewer;
JMFrameRef mViewerFrame;
Boolean mIsActive;
#endif
Boolean mIsActive;
Boolean mIsFocused;
Boolean mIsVisible;
nsPluginPoint mCachedOrigin;
@ -175,7 +183,7 @@ private:
char* mAppletHTML;
MRJPage* mPage;
MRJSecurityContext* mSecurityContext;
#ifdef TARGET_CARBON
#if TARGET_CARBON
jobject mAppletFrame;
jobject mAppletObject;
ControlRef mAppletControl;

View File

@ -48,7 +48,7 @@
#include "StringUtils.h"
MRJPage::MRJPage(MRJSession* session, UInt32 documentID, const char* codeBase, const char* archive, Boolean mayScript)
: mRefCount(0), mNextPage(NULL), mSession(session), mPageRef(NULL),
: mRefCount(0), mNextPage(NULL), mSession(session),
mDocumentID(documentID), mCodeBase(strdup(codeBase)), mArchive(strdup(archive)), mMayScript(mayScript)
{
pushPage();
@ -62,7 +62,7 @@ MRJPage::MRJPage(MRJSession* session, UInt32 documentID, const char* codeBase, c
}
MRJPage::MRJPage(MRJSession* session, const MRJPageAttributes& attributes)
: mRefCount(0), mNextPage(NULL), mSession(session), mPageRef(NULL),
: mRefCount(0), mNextPage(NULL), mSession(session),
mDocumentID(attributes.documentID), mCodeBase(strdup(attributes.codeBase)),
mArchive(strdup(attributes.archive)), mMayScript(attributes.mayScript)
{
@ -112,9 +112,9 @@ UInt16 MRJPage::Release()
return result;
}
#if !TARGET_CARBON
Boolean MRJPage::createContext(JMAWTContextRef* outContext, const JMAWTContextCallbacks * callbacks, JMClientData data)
{
#if !TARGET_CARBON
OSStatus status = noErr;
if (&::JMNewAWTContextInPage != NULL && mPageRef != NULL) {
status = ::JMNewAWTContextInPage(outContext, mSession->getSessionRef(), mPageRef, callbacks, data);
@ -122,10 +122,8 @@ Boolean MRJPage::createContext(JMAWTContextRef* outContext, const JMAWTContextCa
status = ::JMNewAWTContext(outContext, mSession->getSessionRef(), callbacks, data);
}
return (status == noErr);
#else
return false;
#endif
}
#endif
static MRJPage* thePageList = NULL;

View File

@ -42,18 +42,7 @@
by Patrick C. Beard.
*/
#ifndef __TYPES__
#include <Types.h>
#endif
#ifndef CALL_NOT_IN_CARBON
#define CALL_NOT_IN_CARBON 1
#endif
#include "JManager.h"
// For now.
typedef struct OpaqueJMAppletPageRef* JMAppletPageRef;
#include <MacTypes.h>
class MRJSession;
@ -74,18 +63,11 @@ public:
UInt16 AddRef(void);
UInt16 Release(void);
JMAppletPageRef getPageRef() { return mPageRef; }
UInt32 getDocumentID() { return mDocumentID; }
const char* getCodeBase() { return mCodeBase; }
const char* getArchive() { return mArchive; }
Boolean getMayScript() { return mMayScript; }
// Creating AWTContexts.
Boolean createContext(JMAWTContextRef* outContext,
const JMAWTContextCallbacks * callbacks,
JMClientData data);
// Accessing the list of instances.
static MRJPage* getFirstPage(void);
MRJPage* getNextPage(void);
@ -98,7 +80,6 @@ private:
UInt16 mRefCount;
MRJPage* mNextPage;
MRJSession* mSession;
JMAppletPageRef mPageRef;
UInt32 mDocumentID;
char* mCodeBase;
char* mArchive;

View File

@ -45,10 +45,13 @@
#include "MRJPlugin.h"
#include "MRJSession.h"
#include "MRJContext.h"
#include "MRJFrame.h"
#include "MRJConsole.h"
#include "EmbeddedFramePluginInstance.h"
#if !TARGET_CARBON
#include "MRJFrame.h"
#endif
#include "nsIServiceManager.h"
#include "nsIServiceManagerObsolete.h"
#include "nsObsoleteModuleLoading.h"
@ -65,6 +68,7 @@
#include <Resources.h>
#include <LaunchServices.h>
#include <string>
#include <CFBundle.h>
nsIPluginManager* thePluginManager = NULL;
nsIPluginManager2* thePluginManager2 = NULL;
@ -146,6 +150,8 @@ nsresult NSGetFactory(nsISupports* serviceManager, const nsCID &aClass, const ch
#pragma export off
#if TARGET_RT_MAC_CFM
extern "C" {
pascal OSErr __initialize(const CFragInitBlock *initBlock);
@ -198,6 +204,41 @@ pascal void MRJPlugin__terminate()
__terminate();
}
#endif /* TARGET_RT_MAC_CFM */
#if TARGET_RT_MAC_MACHO
extern "C" {
CF_EXPORT Boolean CFURLGetFSRef(CFURLRef url, FSRef *fsRef);
}
static CFBundleRef getPluginBundle()
{
printf("### MRJPlugin: getPluginBundle() here. ###\n");
CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.netscape.MRJPlugin"));
if (bundle) {
printf("### MRJPlugin: CFBundleGetBundleWithIdentifier() succeeded. ###\n");
// initialize thePluginSpec for later use. open our resource fork as well?
CFURLRef url = CFBundleCopyExecutableURL(bundle);
if (url) {
FSRef ref;
if (CFURLGetFSRef(url, &ref)) {
printf("### MRJPlugin: CFURLGetFSRef() succeeded. ###\n");
FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &thePluginSpec, NULL);
// Open plugin's resource fork for read-only access. is this really necessary?
thePluginRefnum = ::CFBundleOpenBundleResourceMap(bundle);
}
CFRelease(url);
}
}
return bundle;
}
CFBundleRef thePluginBundle = getPluginBundle();
#endif /* TARGET_RT_MAC_MACHO */
//
// The MEAT of the plugin.
//
@ -216,7 +257,7 @@ const UInt32 MRJPlugin::kInterfaceCount = sizeof(sInterfaces) / sizeof(Interface
MRJPlugin::MRJPlugin()
: SupportsMixin(this, sInterfaces, kInterfaceCount),
mManager(NULL), mThreadManager(NULL), mSession(NULL), mConsole(NULL), mIsEnabled(false), mPluginThreadID(NULL)
mManager(NULL), mThreadManager(NULL), mSession(NULL), mConsole(NULL), mPluginThreadID(NULL), mIsEnabled(false)
{
}
@ -797,8 +838,8 @@ NS_METHOD MRJPluginInstance::HandleEvent(nsPluginEvent* pluginEvent, PRBool* eve
inspectInstance(isUpdate);
if (event->what == nullEvent) {
// Give MRJ another quantum of time.
mSession->idle(kDefaultJMTime); // now SpendTime does this.
// Give Java another quantum of time. We don't need this on Mac OS X.
mSession->idle(0x00000400); // now SpendTime does this.
} else {
#if TARGET_CARBON
*eventHandled = mContext->handleEvent(event);
@ -859,6 +900,8 @@ NS_METHOD MRJPluginInstance::GetValue(nsPluginInstanceVariable variable, void *v
case nsPluginInstanceVariable_DoCacheBool:
*(PRBool*)value = PR_FALSE;
break;
default:
break;
}
return NS_OK;
}

View File

@ -244,10 +244,13 @@ OSStatus MRJSession::open(const char* consolePath)
// create a monitor for the message queue to unblock Java threads.
mMessageMonitor = new MRJMonitor(this);
}
printf("### MRJPlugin: MRJSession::open() here. ###\n");
JNIEnv* env = mMainEnv;
jclass session = env->FindClass("netscape/oji/MRJSession");
if (session) {
printf("### MRJPlugin: MRJSession::open() loaded the session class. ###\n");
mSession = (jclass) env->NewGlobalRef(session);
jmethodID openMethod = env->GetStaticMethodID(session, "open", "(Ljava/lang/String;)V");
if (openMethod) {
@ -258,6 +261,8 @@ OSStatus MRJSession::open(const char* consolePath)
}
}
env->DeleteLocalRef(session);
} else {
printf("### MRJPlugin: MRJSession::open() couldn't load the session class. ###\n");
}
if (mStatus == noErr)
@ -285,7 +290,7 @@ OSStatus MRJSession::close()
if (mMessageMonitor != NULL) {
mMessageMonitor->notifyAll();
delete mMessageMonitor;
mMessageMonitor;
mMessageMonitor = NULL;
}
if (mSession) {
@ -512,7 +517,9 @@ string MRJSession::getClassPath()
++i;
}
}
printf("### MRJPlugin: classPath = %s ###\n", classPath.c_str());
return classPath;
}
@ -528,6 +535,8 @@ string MRJSession::getPluginHome()
pluginHome += path;
}
}
printf("### MRJPlugin: pluginHome = %s ###\n", pluginHome.c_str());
return pluginHome;
}

View File

@ -44,10 +44,12 @@
#pragma once
#include <MacTypes.h>
#include <jni.h>
#include <vector>
#include <stringfwd>
#include <string>
using std::vector;
using std::string;

View File

@ -49,7 +49,7 @@ class nsIThreadManager;
class NativeMonitor : public Monitor {
public:
NativeMonitor(MRJSession* session, nsIThreadManager* manager, void* address = NULL);
NativeMonitor(MRJSession* session, nsIThreadManager* manager, void* address = 0);
virtual ~NativeMonitor();
virtual void enter();