Fix for 36840 -- implement the Spyglass URL echo Apple Event. Code mostly from Steve Cox: scox@artlogic.com. r=sfraser, a=beppe.

This commit is contained in:
sfraser%netscape.com 2000-06-09 00:13:55 +00:00
Родитель ee35ab2390
Коммит ed81316922
7 изменённых файлов: 136 добавлений и 26 удалений

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

@ -30,10 +30,6 @@
#include "nsAEDocumentClass.h" #include "nsAEDocumentClass.h"
#include "nsAEWindowClass.h" #include "nsAEWindowClass.h"
#include "nsAEMozillaSuiteHandler.h"
#include "nsAEGetURLSuiteHandler.h"
#include "nsAESpyglassSuiteHandler.h"
/* /*
#include "nsAETextClass.h" #include "nsAETextClass.h"
#include "nsAEWordClass.h" #include "nsAEWordClass.h"
@ -711,8 +707,7 @@ pascal OSErr AECoreClass::SpyglassSuiteHandler(AppleEvent *appleEvent, AppleEven
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
void AECoreClass::HandleMozillaSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply) void AECoreClass::HandleMozillaSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply)
{ {
AEMozillaSuiteHandler mozEventHandler; mMozillaSuiteHandler.HandleMozillaSuiteEvent(appleEvent, reply);
mozEventHandler.HandleMozillaSuiteEvent(appleEvent, reply);
} }
@ -723,8 +718,7 @@ void AECoreClass::HandleMozillaSuiteEvent(AppleEvent *appleEvent, AppleEvent *re
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
void AECoreClass::HandleGetURLSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply) void AECoreClass::HandleGetURLSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply)
{ {
AEGetURLSuiteHandler getURLHandler; mGetURLSuiteHandler.HandleGetURLSuiteEvent(appleEvent, reply);
getURLHandler.HandleGetURLSuiteEvent(appleEvent, reply);
} }
@ -735,8 +729,7 @@ void AECoreClass::HandleGetURLSuiteEvent(AppleEvent *appleEvent, AppleEvent *rep
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
void AECoreClass::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply) void AECoreClass::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply)
{ {
AESpyglassSuiteHandler spyglassHandler; mSpyglassSuiteHandler.HandleSpyglassSuiteEvent(appleEvent, reply);
spyglassHandler.HandleSpyglassSuiteEvent(appleEvent, reply);
} }
@ -1054,21 +1047,21 @@ void AECoreClass::InstallSuiteHandlers(Boolean suspendEvents)
ThrowIfOSErr(err); ThrowIfOSErr(err);
// install the mozilla suite handler // install the mozilla suite handler
err = ::AEInstallEventHandler(kAEMozillaSuite, typeWildCard, err = ::AEInstallEventHandler(AEMozillaSuiteHandler::kSuiteSignature, typeWildCard,
suspendEvents ? mSuspendEventHandlerUPP : mMozillaSuiteHandlerUPP, suspendEvents ? mSuspendEventHandlerUPP : mMozillaSuiteHandlerUPP,
(long)this, (long)this,
false); false);
ThrowIfOSErr(err); ThrowIfOSErr(err);
// install the GetURL suite handler // install the GetURL suite handler
err = ::AEInstallEventHandler(kAEUrlSuite, typeWildCard, err = ::AEInstallEventHandler(AEGetURLSuiteHandler::kSuiteSignature, typeWildCard,
suspendEvents ? mSuspendEventHandlerUPP : mGetURLSuiteHandlerUPP, suspendEvents ? mSuspendEventHandlerUPP : mGetURLSuiteHandlerUPP,
(long)this, (long)this,
false); false);
ThrowIfOSErr(err); ThrowIfOSErr(err);
// install the SpyGlass suite handler // install the SpyGlass suite handler
err = ::AEInstallEventHandler(kAESpyglassSuite, typeWildCard, err = ::AEInstallEventHandler(AESpyglassSuiteHandler::kSuiteSignature, typeWildCard,
suspendEvents ? mSuspendEventHandlerUPP : mSpyGlassSuiteHandlerUPP, suspendEvents ? mSuspendEventHandlerUPP : mSpyGlassSuiteHandlerUPP,
(long)this, (long)this,
false); false);

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

@ -35,6 +35,10 @@
#include "nsAEClassDispatcher.h" #include "nsAEClassDispatcher.h"
#include "nsAEMozillaSuiteHandler.h"
#include "nsAEGetURLSuiteHandler.h"
#include "nsAESpyglassSuiteHandler.h"
class AEApplicationClass; class AEApplicationClass;
class AEDocumentClass; class AEDocumentClass;
class AEWindowClass; class AEWindowClass;
@ -43,13 +47,6 @@ class AECoreClass
{ {
public: public:
enum {
kAEMozillaSuite = 'MOZZ',
kAEUrlSuite = 'GURL',
kAESpyglassSuite = 'WWW!'
};
AECoreClass(Boolean suspendEvents = false); // throws OSErrs AECoreClass(Boolean suspendEvents = false); // throws OSErrs
~AECoreClass(); ~AECoreClass();
@ -167,6 +164,10 @@ protected:
AEEventHandlerUPP mGetURLSuiteHandlerUPP; AEEventHandlerUPP mGetURLSuiteHandlerUPP;
AEEventHandlerUPP mSpyGlassSuiteHandlerUPP; AEEventHandlerUPP mSpyGlassSuiteHandlerUPP;
AEMozillaSuiteHandler mMozillaSuiteHandler;
AEGetURLSuiteHandler mGetURLSuiteHandler;
AESpyglassSuiteHandler mSpyglassSuiteHandler;
OSLAccessorUPP mPropertyFromListAccessor; OSLAccessorUPP mPropertyFromListAccessor;
OSLAccessorUPP mAnythingFromAppAccessor; OSLAccessorUPP mAnythingFromAppAccessor;

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

@ -33,6 +33,7 @@ class AEGetURLSuiteHandler
{ {
public: public:
enum { enum {
kSuiteSignature = 'GURL',
kGetURLEvent = 'GURL' kGetURLEvent = 'GURL'
}; };

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

@ -33,6 +33,7 @@ class AEMozillaSuiteHandler
{ {
public: public:
enum { enum {
kSuiteSignature = 'MOZZ',
kDoJavaScriptEvent = 'jscr' kDoJavaScriptEvent = 'jscr'
}; };

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

@ -21,17 +21,18 @@
* Simon Fraser <sfraser@netscape.com> * Simon Fraser <sfraser@netscape.com>
*/ */
#include "nsMemory.h" #include "nsMemory.h"
#include "nsAESpyglassSuiteHandler.h" #include "nsAESpyglassSuiteHandler.h"
#include "nsCommandLineServiceMac.h" #include "nsCommandLineServiceMac.h"
#include "nsDocLoadObserver.h"
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
AESpyglassSuiteHandler AESpyglassSuiteHandler
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
AESpyglassSuiteHandler::AESpyglassSuiteHandler() AESpyglassSuiteHandler::AESpyglassSuiteHandler()
: mDocObserver(nsnull)
{ {
} }
@ -41,6 +42,7 @@ AESpyglassSuiteHandler::AESpyglassSuiteHandler()
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
AESpyglassSuiteHandler::~AESpyglassSuiteHandler() AESpyglassSuiteHandler::~AESpyglassSuiteHandler()
{ {
NS_IF_RELEASE(mDocObserver);
} }
@ -72,7 +74,15 @@ void AESpyglassSuiteHandler::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, Ap
case kOpenURLEvent: case kOpenURLEvent:
HandleOpenURLEvent(appleEvent, reply); HandleOpenURLEvent(appleEvent, reply);
break; break;
case kRegisterURLEchoEvent:
HandleRegisterURLEchoEvent(appleEvent, reply);
break;
case kUnregisterURLEchoEvent:
HandleUnregisterURLEchoEvent(appleEvent, reply);
break;
default: default:
ThrowOSErr(errAEEventNotHandled); ThrowOSErr(errAEEventNotHandled);
break; break;
@ -98,14 +108,40 @@ void AESpyglassSuiteHandler::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, Ap
void AESpyglassSuiteHandler::HandleOpenURLEvent(AppleEvent *appleEvent, AppleEvent *reply) void AESpyglassSuiteHandler::HandleOpenURLEvent(AppleEvent *appleEvent, AppleEvent *reply)
{ {
StAEDesc directParameter; StAEDesc directParameter;
FSSpec saveToFile;
Boolean gotSaveToFile = false;
SInt32 targetWindowID = -1;
SInt32 openFlags = 0;
OSErr err; OSErr err;
// extract the direct parameter (an object specifier) // extract the direct parameter (an object specifier)
err = ::AEGetKeyDesc(appleEvent, keyDirectObject, typeWildCard, &directParameter); err = ::AEGetKeyDesc(appleEvent, keyDirectObject, typeWildCard, &directParameter);
ThrowIfOSErr(err); ThrowIfOSErr(err);
// we need to look for other parameters, to do with destination etc. // look for the save to file param
StAEDesc targetFileDesc;
err = ::AEGetKeyDesc(appleEvent, kParamSaveToFileDest, typeFSS, &targetFileDesc);
if (err != errAEDescNotFound)
{
targetFileDesc.GetFileSpec(saveToFile);
gotSaveToFile = true;
}
#if 0
// look for the target window param
StAEDesc openInWindowDesc;
err = ::AEGetKeyDesc(appleEvent, kParamOpenInWindow, typeLongInteger, &openInWindowDesc);
if (err != errAEDescNotFound)
targetWindowID = openInWindowDesc.GetLong();
// look for the open flags
StAEDesc openFlagsDesc;
err = ::AEGetKeyDesc(appleEvent, kParamOpenFlags, typeLongInteger, &openFlagsDesc);
if (err != errAEDescNotFound)
openFlags = openFlagsDesc.GetLong();
// do something with targetWindowID and openFlags...
#endif
long dataSize = directParameter.GetDataSize(); long dataSize = directParameter.GetDataSize();
char* urlString = (char *)nsMemory::Alloc(dataSize + 1); char* urlString = (char *)nsMemory::Alloc(dataSize + 1);
@ -121,3 +157,40 @@ void AESpyglassSuiteHandler::HandleOpenURLEvent(AppleEvent *appleEvent, AppleEve
/*----------------------------------------------------------------------------
HandleRegisterURLEchoEvent
----------------------------------------------------------------------------*/
void AESpyglassSuiteHandler::HandleRegisterURLEchoEvent(AppleEvent *appleEvent, AppleEvent *reply)
{
// extract the direct parameter (the requester's signature)
StAEDesc directParameter;
OSErr err = ::AEGetKeyDesc(appleEvent, keyDirectObject, typeType, &directParameter);
ThrowIfOSErr(err);
if (typeType == directParameter.descriptorType)
{
mDocObserver = new nsDocLoadObserver;
ThrowIfNil(mDocObserver);
NS_ADDREF(mDocObserver); // our owning ref
mDocObserver->AddEchoRequester(**(OSType**)directParameter.dataHandle);
}
}
/*----------------------------------------------------------------------------
HandleUnregisterURLEchoEvent
----------------------------------------------------------------------------*/
void AESpyglassSuiteHandler::HandleUnregisterURLEchoEvent(AppleEvent *appleEvent, AppleEvent *reply)
{
// extract the direct parameter (the requester's signature)
StAEDesc directParameter;
OSErr err = ::AEGetKeyDesc(appleEvent, keyDirectObject, typeType, &directParameter);
ThrowIfOSErr(err);
if (typeType == directParameter.descriptorType)
{
if (mDocObserver)
mDocObserver->RemoveEchoRequester(**(OSType**)directParameter.dataHandle);
}
}

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

@ -27,12 +27,48 @@
#include "nsAEUtils.h" #include "nsAEUtils.h"
class nsDocLoadObserver;
class AESpyglassSuiteHandler class AESpyglassSuiteHandler
{ {
public: public:
enum { enum {
kOpenURLEvent = 'OURL' kSuiteSignature = 'WWW!',
kOpenURLEvent = 'OURL', // OpenURL
kRegisterURLEchoEvent = 'RGUE', // Register URL echo handler
kUnregisterURLEchoEvent = 'UNRU', // Unregister URL echo handler
// the following are unhandled in Mozilla
kRegisterViewerEvent = 'RGVW', // RegisterViewer
kUnregisterViewerEvent = 'UNRV', // UnregisterViewer
kShowFileEvent = 'SHWF', // ShowFile
kParseAnchorEvent = 'PRSA', // ParseAnchor
kSpyActivateEvent = 'ACTV', // Activate
kSpyListWindowsEvent = 'LSTW', // ListWindows
kGetWindowInfoEvent = 'WNFO', // GetWindowInfo
kRegisterWinCloseEvent = 'RGWC', // RegisterWindowClose
kUnregisterWinCloseEvent = 'UNRC', // UnregisterWindowClose
kRegisterProtocolEvent = 'RGPR', // RegisterProtocol
kUnregisterProtocolEvent = 'UNRP', // UnregisterProtocol
kCancelProgressEvent = 'CNCL', // Cancel download
kFindURLEvent = 'FURL', // Find the URL for the file
// Spyglass send events
kSpyglassSendSignature = 'WWW?',
kSendURLEchoEvent = 'URLE'
};
// event params
enum {
kParamSaveToFileDest = 'INTO', // FSSpec save to file
kParamOpenInWindow = 'WIND', // long, target window (window ID)
kParamOpenFlags = 'FLGS', // long, Binary: any combination of 1, 2 and 4 is allowed: 1 and 2 mean force reload the document. 4 is ignored
kParamPostData = 'POST', // text, Form posting data
kParamPostType = 'MIME', // text, MIME type of the posting data. Defaults to application/x-www-form-urlencoded
kParamProgressApp = 'PROG' // 'psn ', Application that will display progress
}; };
AESpyglassSuiteHandler(); AESpyglassSuiteHandler();
@ -43,11 +79,16 @@ public:
protected: protected:
void HandleOpenURLEvent(AppleEvent *appleEvent, AppleEvent *reply); void HandleOpenURLEvent(AppleEvent *appleEvent, AppleEvent *reply);
void HandleRegisterURLEchoEvent(AppleEvent *appleEvent, AppleEvent *reply);
void HandleUnregisterURLEchoEvent(AppleEvent *appleEvent, AppleEvent *reply);
protected:
nsDocLoadObserver* mDocObserver;
}; };
#endif // nsAESpyglassSuiteHandler_h_ #endif // nsAESpyglassSuiteHandler_h_

Двоичные данные
xpfe/bootstrap/appleevents/nsAppleEvents.rsrc

Двоичный файл не отображается.