зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
ee35ab2390
Коммит
ed81316922
|
@ -30,10 +30,6 @@
|
|||
#include "nsAEDocumentClass.h"
|
||||
#include "nsAEWindowClass.h"
|
||||
|
||||
#include "nsAEMozillaSuiteHandler.h"
|
||||
#include "nsAEGetURLSuiteHandler.h"
|
||||
#include "nsAESpyglassSuiteHandler.h"
|
||||
|
||||
/*
|
||||
#include "nsAETextClass.h"
|
||||
#include "nsAEWordClass.h"
|
||||
|
@ -711,8 +707,7 @@ pascal OSErr AECoreClass::SpyglassSuiteHandler(AppleEvent *appleEvent, AppleEven
|
|||
----------------------------------------------------------------------------*/
|
||||
void AECoreClass::HandleMozillaSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply)
|
||||
{
|
||||
AEMozillaSuiteHandler mozEventHandler;
|
||||
mozEventHandler.HandleMozillaSuiteEvent(appleEvent, reply);
|
||||
mMozillaSuiteHandler.HandleMozillaSuiteEvent(appleEvent, reply);
|
||||
}
|
||||
|
||||
|
||||
|
@ -723,8 +718,7 @@ void AECoreClass::HandleMozillaSuiteEvent(AppleEvent *appleEvent, AppleEvent *re
|
|||
----------------------------------------------------------------------------*/
|
||||
void AECoreClass::HandleGetURLSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply)
|
||||
{
|
||||
AEGetURLSuiteHandler getURLHandler;
|
||||
getURLHandler.HandleGetURLSuiteEvent(appleEvent, reply);
|
||||
mGetURLSuiteHandler.HandleGetURLSuiteEvent(appleEvent, reply);
|
||||
}
|
||||
|
||||
|
||||
|
@ -735,8 +729,7 @@ void AECoreClass::HandleGetURLSuiteEvent(AppleEvent *appleEvent, AppleEvent *rep
|
|||
----------------------------------------------------------------------------*/
|
||||
void AECoreClass::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, AppleEvent *reply)
|
||||
{
|
||||
AESpyglassSuiteHandler spyglassHandler;
|
||||
spyglassHandler.HandleSpyglassSuiteEvent(appleEvent, reply);
|
||||
mSpyglassSuiteHandler.HandleSpyglassSuiteEvent(appleEvent, reply);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1054,21 +1047,21 @@ void AECoreClass::InstallSuiteHandlers(Boolean suspendEvents)
|
|||
ThrowIfOSErr(err);
|
||||
|
||||
// install the mozilla suite handler
|
||||
err = ::AEInstallEventHandler(kAEMozillaSuite, typeWildCard,
|
||||
err = ::AEInstallEventHandler(AEMozillaSuiteHandler::kSuiteSignature, typeWildCard,
|
||||
suspendEvents ? mSuspendEventHandlerUPP : mMozillaSuiteHandlerUPP,
|
||||
(long)this,
|
||||
false);
|
||||
ThrowIfOSErr(err);
|
||||
|
||||
// install the GetURL suite handler
|
||||
err = ::AEInstallEventHandler(kAEUrlSuite, typeWildCard,
|
||||
err = ::AEInstallEventHandler(AEGetURLSuiteHandler::kSuiteSignature, typeWildCard,
|
||||
suspendEvents ? mSuspendEventHandlerUPP : mGetURLSuiteHandlerUPP,
|
||||
(long)this,
|
||||
false);
|
||||
ThrowIfOSErr(err);
|
||||
|
||||
// install the SpyGlass suite handler
|
||||
err = ::AEInstallEventHandler(kAESpyglassSuite, typeWildCard,
|
||||
err = ::AEInstallEventHandler(AESpyglassSuiteHandler::kSuiteSignature, typeWildCard,
|
||||
suspendEvents ? mSuspendEventHandlerUPP : mSpyGlassSuiteHandlerUPP,
|
||||
(long)this,
|
||||
false);
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
|
||||
#include "nsAEClassDispatcher.h"
|
||||
|
||||
#include "nsAEMozillaSuiteHandler.h"
|
||||
#include "nsAEGetURLSuiteHandler.h"
|
||||
#include "nsAESpyglassSuiteHandler.h"
|
||||
|
||||
class AEApplicationClass;
|
||||
class AEDocumentClass;
|
||||
class AEWindowClass;
|
||||
|
@ -43,13 +47,6 @@ class AECoreClass
|
|||
{
|
||||
public:
|
||||
|
||||
enum {
|
||||
kAEMozillaSuite = 'MOZZ',
|
||||
kAEUrlSuite = 'GURL',
|
||||
kAESpyglassSuite = 'WWW!'
|
||||
};
|
||||
|
||||
|
||||
AECoreClass(Boolean suspendEvents = false); // throws OSErrs
|
||||
~AECoreClass();
|
||||
|
||||
|
@ -167,6 +164,10 @@ protected:
|
|||
AEEventHandlerUPP mGetURLSuiteHandlerUPP;
|
||||
AEEventHandlerUPP mSpyGlassSuiteHandlerUPP;
|
||||
|
||||
AEMozillaSuiteHandler mMozillaSuiteHandler;
|
||||
AEGetURLSuiteHandler mGetURLSuiteHandler;
|
||||
AESpyglassSuiteHandler mSpyglassSuiteHandler;
|
||||
|
||||
OSLAccessorUPP mPropertyFromListAccessor;
|
||||
OSLAccessorUPP mAnythingFromAppAccessor;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class AEGetURLSuiteHandler
|
|||
{
|
||||
public:
|
||||
enum {
|
||||
kSuiteSignature = 'GURL',
|
||||
kGetURLEvent = 'GURL'
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class AEMozillaSuiteHandler
|
|||
{
|
||||
public:
|
||||
enum {
|
||||
kSuiteSignature = 'MOZZ',
|
||||
kDoJavaScriptEvent = 'jscr'
|
||||
};
|
||||
|
||||
|
|
|
@ -21,17 +21,18 @@
|
|||
* Simon Fraser <sfraser@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsMemory.h"
|
||||
|
||||
#include "nsAESpyglassSuiteHandler.h"
|
||||
#include "nsCommandLineServiceMac.h"
|
||||
#include "nsDocLoadObserver.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
AESpyglassSuiteHandler
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
AESpyglassSuiteHandler::AESpyglassSuiteHandler()
|
||||
: mDocObserver(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,7 @@ AESpyglassSuiteHandler::AESpyglassSuiteHandler()
|
|||
----------------------------------------------------------------------------*/
|
||||
AESpyglassSuiteHandler::~AESpyglassSuiteHandler()
|
||||
{
|
||||
NS_IF_RELEASE(mDocObserver);
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,6 +75,14 @@ void AESpyglassSuiteHandler::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, Ap
|
|||
HandleOpenURLEvent(appleEvent, reply);
|
||||
break;
|
||||
|
||||
case kRegisterURLEchoEvent:
|
||||
HandleRegisterURLEchoEvent(appleEvent, reply);
|
||||
break;
|
||||
|
||||
case kUnregisterURLEchoEvent:
|
||||
HandleUnregisterURLEchoEvent(appleEvent, reply);
|
||||
break;
|
||||
|
||||
default:
|
||||
ThrowOSErr(errAEEventNotHandled);
|
||||
break;
|
||||
|
@ -98,14 +108,40 @@ void AESpyglassSuiteHandler::HandleSpyglassSuiteEvent(AppleEvent *appleEvent, Ap
|
|||
void AESpyglassSuiteHandler::HandleOpenURLEvent(AppleEvent *appleEvent, AppleEvent *reply)
|
||||
{
|
||||
StAEDesc directParameter;
|
||||
FSSpec saveToFile;
|
||||
Boolean gotSaveToFile = false;
|
||||
SInt32 targetWindowID = -1;
|
||||
SInt32 openFlags = 0;
|
||||
OSErr err;
|
||||
|
||||
// extract the direct parameter (an object specifier)
|
||||
err = ::AEGetKeyDesc(appleEvent, keyDirectObject, typeWildCard, &directParameter);
|
||||
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();
|
||||
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"
|
||||
|
||||
class nsDocLoadObserver;
|
||||
|
||||
class AESpyglassSuiteHandler
|
||||
{
|
||||
public:
|
||||
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();
|
||||
|
@ -43,11 +79,16 @@ public:
|
|||
protected:
|
||||
|
||||
void HandleOpenURLEvent(AppleEvent *appleEvent, AppleEvent *reply);
|
||||
|
||||
void HandleRegisterURLEchoEvent(AppleEvent *appleEvent, AppleEvent *reply);
|
||||
void HandleUnregisterURLEchoEvent(AppleEvent *appleEvent, AppleEvent *reply);
|
||||
|
||||
protected:
|
||||
|
||||
nsDocLoadObserver* mDocObserver;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // nsAESpyglassSuiteHandler_h_
|
||||
|
|
Двоичные данные
xpfe/bootstrap/appleevents/nsAppleEvents.rsrc
Двоичные данные
xpfe/bootstrap/appleevents/nsAppleEvents.rsrc
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче