[Adium-devl] Out of process plugins (was: Distant objects)
Colin Barrett
timber at lava.net
Wed Apr 25 09:24:37 UTC 2007
Very interesting! This could allow us to, in theory, run 3rd party
plugins out of process, thus protecting our internal APIs that
shouldn't be exposed, and preventing Adium from crashing when a 3rd
party plugin does something dumb.
Other than the typo in the comment (s/how/Now/) and a small style nit
(|*connection| instead of |* connection|), it looks excellent to me.
-Colin
On Apr 23, 2007, at 5:50 AM, Joe Ranieri wrote:
> Here's a small patch for distant object support:
>
> ===================================================================
> --- /Users/joe/adium/Source/AIAdium.m (revision 19524)
> +++ /Users/joe/adium/Source/AIAdium.m (working copy)
> @@ -435,6 +435,15 @@
> pool = [[NSAutoreleasePool alloc] init];
> [applescriptabilityController controllerDidLoad];
> [statusController controllerDidLoad];
> +
> + // how that we have everything inited, let's broadcast our
> presence
> + NSConnection * connection = [NSConnection defaultConnection];
> + [connection setRootObject:self];
> + [connection registerName:@"com.adiumx.adiumx"];
> +
> + [[NSDistributedNotificationCenter defaultCenter]
> postNotificationName:@"AdiumLaunchedDistNotification"
> +
> object:nil];
> +
> //Open the preferences if we were unable to because
> application:openFile: was called before we got here
> [self openAppropriatePreferencesIfNeeded];
> @@ -648,6 +657,11 @@
> //Other
> ------------------------------------------------------------------------
> -------------------------------
> #pragma mark Other
> +// while code running in this process can access NSApplication,
> distant objects can't
> +- (NSApplication *)application {
> + return [NSApplication sharedApplication];
> +}
> +
> //If Adium was launched by double-clicking an associated file, we get
> this call after willFinishLaunching but before
> //didFinishLaunching
> - (BOOL)application:(NSApplication *)theApplication openFile:
> (NSString *)filename
>
>
>
>
> and an example project:
> #import <Foundation/Foundation.h>
>
> int main (int argc, const char * argv[]) {
> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
> NSDistantObject * adium = [[NSConnection
> rootProxyForConnectionWithRegisteredName:@"com.adiumx.adiumx"
> host:nil] retain];
>
> [adium showAboutBox:nil];
> [[adium application] activateIgnoringOtherApps:YES];
>
> [pool release];
> return 0;
> }
>
>
>
> -- Joe Ranieri
>
> _______________________________________________
> Adium-devl mailing list
> Adium-devl at adiumx.com
> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com
More information about the devel
mailing list