Skip to content
Snippets Groups Projects
Commit c775ae7c authored by Graham Madarasz (Graham Linden)'s avatar Graham Madarasz (Graham Linden)
Browse files

MAINT-3155 add cocoa equiv for former AppleEventManager shenanigans for SLURL handling

parent b8a1fd33
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,7 @@ void handleQuit(); ...@@ -49,6 +49,7 @@ void handleQuit();
bool runMainLoop(); bool runMainLoop();
void initMainLoop(); void initMainLoop();
void cleanupViewer(); void cleanupViewer();
void handleUrl(const char* url);
/* Defined in llwindowmacosx-objc.mm: */ /* Defined in llwindowmacosx-objc.mm: */
int createNSApp(int argc, const char **argv); int createNSApp(int argc, const char **argv);
......
...@@ -57,7 +57,7 @@ void setupCocoa() ...@@ -57,7 +57,7 @@ void setupCocoa()
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
[pool release]; [pool release];
inited = true; inited = true;
} }
} }
......
...@@ -54,6 +54,19 @@ ...@@ -54,6 +54,19 @@
} }
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil]; [[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 - (void) applicationDidBecomeActive:(NSNotification *)notification
......
...@@ -483,41 +483,24 @@ bool LLAppViewerMacOSX::getMasterSystemAudioMute() ...@@ -483,41 +483,24 @@ bool LLAppViewerMacOSX::getMasterSystemAudioMute()
return (mute != 0); return (mute != 0);
} }
OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) void handleUrl(const char* url_utf8)
{ {
OSErr result = noErr; if (url_utf8)
DescType actualType; {
char buffer[1024]; // Flawfinder: ignore std::string url = url_utf8;
Size size; // Safari 3.2 silently mangles secondlife:///app/ URLs into
// secondlife:/app/ (only one leading slash).
result = AEGetParamPtr ( // Fix them up to meet the URL specification. JC
messagein, const std::string prefix = "secondlife:/app/";
keyDirectObject, std::string test_prefix = url.substr(0, prefix.length());
typeCString, LLStringUtil::toLower(test_prefix);
&actualType, if (test_prefix == prefix)
(Ptr)buffer, {
sizeof(buffer), url.replace(0, prefix.length(), "secondlife:///app/");
&size); }
if(result == noErr)
{
std::string url = buffer;
// Safari 3.2 silently mangles secondlife:///app/ URLs into LLMediaCtrl* web = NULL;
// secondlife:/app/ (only one leading slash). const bool trusted_browser = false;
// Fix them up to meet the URL specification. JC LLURLDispatcher::dispatch(url, "", web, trusted_browser);
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);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment