MAINT-3155 add cocoa equiv for former AppleEventManager shenanigans for SLURL handling
parent
b8a1fd33f5
commit
c775ae7cbd
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ void setupCocoa()
|
|||
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
|
||||
|
||||
[pool release];
|
||||
|
||||
|
||||
inited = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue