commit e13727e3c4921bde411c275aef71999324cd3faf from: Rob Kroeger via: Russ Cox date: Sun Oct 21 16:53:33 2012 UTC plumb.app: accept plumb:foo as alias for foo R=rsc CC=plan9port.codebot http://codereview.appspot.com/5495046 commit - e4122a42b922fd1047a4b5beee6fdc0ce623f873 commit + e13727e3c4921bde411c275aef71999324cd3faf blob - cf3e2282caf5c2b247b00132de09d5e5f3ea3662 blob + ec5bf49fdf65ee73c3fc4be2c398495faa33809e --- src/cmd/devdraw/macargv.m +++ src/cmd/devdraw/macargv.m @@ -1,8 +1,10 @@ #import +#import #include #include +AUTOFRAMEWORK(Foundation) AUTOFRAMEWORK(Cocoa) @interface appdelegate : NSObject @end @@ -14,7 +16,13 @@ main(void) [NSAutoreleasePool new]; [NSApplication sharedApplication]; - [NSApp setDelegate:[appdelegate new]]; + NSObject *delegate = [appdelegate new]; + [NSApp setDelegate:delegate]; + + NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; /* Register a call-back for URL Events */ + [appleEventManager setEventHandler:delegate andSelector:@selector(handleGetURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass andEventID:kAEGetURL]; + [NSApp run]; } @@ -31,4 +39,11 @@ main(void) } [NSApp terminate:self]; } + +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + NSString* url = [[event descriptorForKeyword:keyDirectObject] stringValue]; + print("%s\n", [url UTF8String] + (sizeof("plumb:") - 1)); + [NSApp terminate:self]; +} @end