[Adium-devl] Distant objects
Joe Ranieri
jranieri at realsoftware.com
Mon Apr 23 12:50:42 UTC 2007
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
More information about the devel
mailing list