diff options
author | Graham Madarasz (Graham Linden) <graham@lindenlab.com> | 2013-09-26 18:53:12 -0700 |
---|---|---|
committer | Graham Madarasz (Graham Linden) <graham@lindenlab.com> | 2013-09-26 18:53:12 -0700 |
commit | 4bc93932401353efda75f51694edd65f4b187fe0 (patch) | |
tree | 2f86a6d8571eded97bb40bd6ef8e8c66ab47cc1c | |
parent | badb8a945d31aed6f396e7efb521e76083870069 (diff) |
MAINT-3155 add cocoa equiv for former AppleEventManager shenanigans for SLURL handling
-rwxr-xr-x | indra/llwindow/llwindowmacosx-objc.h | 1 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmacosx-objc.mm | 2 | ||||
-rw-r--r-- | indra/newview/llappdelegate-objc.mm | 13 | ||||
-rwxr-xr-x | indra/newview/llappviewermacosx.cpp | 53 |
4 files changed, 33 insertions, 36 deletions
diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index 32b3bfb078..2cae6f3f72 100755 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -49,6 +49,7 @@ void handleQuit(); bool runMainLoop(); void initMainLoop(); void cleanupViewer(); +void handleUrl(const char* url); /* Defined in llwindowmacosx-objc.mm: */ int createNSApp(int argc, const char **argv); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 0354c2b717..0768d0352e 100755 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -57,7 +57,7 @@ void setupCocoa() [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; [pool release]; - + inited = true; } } diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 30476b3d22..91251ed7c0 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -54,6 +54,19 @@ } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil]; + + [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; +} + +- (void) handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { + NSString *url= nil; + url = [[[[NSAppleEventManager sharedAppleEventManager]// 1 + currentAppleEvent]// 2 + paramDescriptorForKeyword:keyDirectObject]// 3 + stringValue];// 4 + + const char* url_utf8 = [url UTF8String]; + handleUrl(url_utf8); } - (void) applicationDidBecomeActive:(NSNotification *)notification diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index 316c90d9d2..2723f0b90d 100755 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -483,41 +483,24 @@ bool LLAppViewerMacOSX::getMasterSystemAudioMute() return (mute != 0); } -OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) +void handleUrl(const char* url_utf8) { - OSErr result = noErr; - DescType actualType; - char buffer[1024]; // Flawfinder: ignore - Size size; - - result = AEGetParamPtr ( - messagein, - keyDirectObject, - typeCString, - &actualType, - (Ptr)buffer, - sizeof(buffer), - &size); - - if(result == noErr) - { - std::string url = buffer; + if (url_utf8) + { + std::string url = url_utf8; + // Safari 3.2 silently mangles secondlife:///app/ URLs into + // secondlife:/app/ (only one leading slash). + // Fix them up to meet the URL specification. JC + const std::string prefix = "secondlife:/app/"; + std::string test_prefix = url.substr(0, prefix.length()); + LLStringUtil::toLower(test_prefix); + if (test_prefix == prefix) + { + url.replace(0, prefix.length(), "secondlife:///app/"); + } - // Safari 3.2 silently mangles secondlife:///app/ URLs into - // secondlife:/app/ (only one leading slash). - // Fix them up to meet the URL specification. JC - const std::string prefix = "secondlife:/app/"; - std::string test_prefix = url.substr(0, prefix.length()); - LLStringUtil::toLower(test_prefix); - if (test_prefix == prefix) - { - url.replace(0, prefix.length(), "secondlife:///app/"); - } - - LLMediaCtrl* web = NULL; - const bool trusted_browser = false; - LLURLDispatcher::dispatch(url, "", web, trusted_browser); - } - - return(result); + LLMediaCtrl* web = NULL; + const bool trusted_browser = false; + LLURLDispatcher::dispatch(url, "", web, trusted_browser); + } } |