mirror of
https://github.com/macports/pallet.git
synced 2026-07-12 18:18:47 -07:00
Removing the delegate in favour of NSNotification
git-svn-id: https://svn.macports.org/repository/macports/branches/gsoc09-gui@54592 d073be05-634f-4543-b044-5fe20cf6d1d6
This commit is contained in:
+26
-20
@@ -32,6 +32,7 @@ static MPActionLauncher *sharedActionLauncher = nil;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
[self subscribeToNotifications];
|
||||
if (sharedActionLauncher == nil) {
|
||||
ports = [NSMutableArray arrayWithCapacity:1];
|
||||
sharedActionLauncher = self;
|
||||
@@ -87,7 +88,7 @@ static MPActionLauncher *sharedActionLauncher = nil;
|
||||
|
||||
- (void)cancelPortProcess {
|
||||
// TODO: display confirmation dialog
|
||||
NSTask *task = [[MPInterpreter sharedInterpreter] task];
|
||||
NSTask *task = [MPInterpreter task];
|
||||
if(task != nil && [task isRunning]) {
|
||||
[task terminate];
|
||||
}
|
||||
@@ -96,26 +97,31 @@ static MPActionLauncher *sharedActionLauncher = nil;
|
||||
#pragma mark Private Methods implementation
|
||||
|
||||
- (void)subscribeToNotifications {
|
||||
/*
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector()
|
||||
name:MPINFO object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector()
|
||||
name:MPERROR object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector()
|
||||
name:MPWARN object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector()
|
||||
name:MPDEBUG object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector()
|
||||
name:MPDEFAULT object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector()
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self
|
||||
// selector:@selector()
|
||||
// name:MPINFO object:nil];
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self
|
||||
// selector:@selector()
|
||||
// name:MPERROR object:nil];
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self
|
||||
// selector:@selector()
|
||||
// name:MPWARN object:nil];
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self
|
||||
// selector:@selector()
|
||||
// name:MPDEBUG object:nil];
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self
|
||||
// selector:@selector()
|
||||
// name:MPDEFAULT object:nil];
|
||||
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(gotMPMSG:)
|
||||
name:MPMSG object:nil];
|
||||
*/
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(gotMPMSG:)
|
||||
name:MPMSG object:nil];
|
||||
}
|
||||
|
||||
- (void)gotMPMSG:(NSNotification *)notification {
|
||||
NSLog(@"GOT MPMSG NOTIFICATION");
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
[tableController hidePredicateEditor:self];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString *pkgPath = [defaults objectForKey:@"PKGPath"];
|
||||
|
||||
if (pkgPath == nil) {
|
||||
[self openPreferences:self];
|
||||
} else {
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
|
||||
//According to the docs all I need is
|
||||
//the file descriptor that MPNotifications
|
||||
//obtained when creating the server socket
|
||||
|
||||
@@ -104,11 +104,7 @@
|
||||
|
||||
+(void) setPKGPath:(NSString*)newPath;
|
||||
|
||||
+(id) delegate;
|
||||
|
||||
+(void) setDelegate:(id)newDelegate;
|
||||
|
||||
-(NSTask*) task;
|
||||
+(NSTask*) task;
|
||||
|
||||
//Internal methods
|
||||
-(BOOL) setOptionsForNewTclPort:(NSArray *)options;
|
||||
|
||||
@@ -165,15 +165,6 @@ int Notifications_Command(ClientData clientData, Tcl_Interp *interpreter, int ob
|
||||
//tool
|
||||
static NSString * tclInterpreterPkgPath = nil;
|
||||
|
||||
+(id) delegate {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
+(void) setDelegate:(id)newDelegate {
|
||||
delegate = newDelegate;
|
||||
}
|
||||
|
||||
|
||||
+(NSString*) PKGPath {
|
||||
return PKGPath;
|
||||
}
|
||||
@@ -470,7 +461,7 @@ static NSString * tclInterpreterPkgPath = nil;
|
||||
|
||||
*mportError = nil;
|
||||
firstResult = [self evaluateStringWithMPPortProcess:statement error:mportError];
|
||||
|
||||
|
||||
//Because of string results of methods like mportsync (which returns the empty string)
|
||||
//the only way to truly check for an error is to check the mportError parameter.
|
||||
//If it is nil then there was no error, if not we re-evaluate with privileges using
|
||||
@@ -684,11 +675,12 @@ static NSString * tclInterpreterPkgPath = nil;
|
||||
}
|
||||
while (theProxy == nil);
|
||||
|
||||
[theProxy evaluateString:statement delegate:delegate];
|
||||
[theProxy evaluateString:statement];
|
||||
[aTask waitUntilExit];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSTask*) task {
|
||||
+ (NSTask*) task {
|
||||
return aTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,15 +59,6 @@
|
||||
[MPInterpreter setPKGPath:newPath];
|
||||
}
|
||||
|
||||
+(id) notificationsDelegate {
|
||||
return [MPInterpreter delegate];
|
||||
}
|
||||
|
||||
+(void) setNotificationsDelegate:(id)newDelegate {
|
||||
[MPInterpreter setDelegate:newDelegate];
|
||||
}
|
||||
|
||||
|
||||
+ (MPMacPorts *)sharedInstance {
|
||||
return [self sharedInstanceWithPkgPath:[MPInterpreter PKGPath] portOptions:nil];
|
||||
}
|
||||
|
||||
@@ -23,13 +23,8 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (oneway void)setDelegate:(byref id)newDelegate {
|
||||
delegate = newDelegate;
|
||||
}
|
||||
|
||||
- (oneway void)evaluateString:(bycopy id)statement delegate:(byref id)newDelegate {
|
||||
- (oneway void)evaluateString:(bycopy id)statement {
|
||||
// TODO Handle the posible errors and notifications
|
||||
delegate = newDelegate;
|
||||
Tcl_Eval(interpreter, [statement UTF8String]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,4 @@
|
||||
|
||||
#include <tcl.h>
|
||||
|
||||
id delegate;
|
||||
|
||||
int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
|
||||
@@ -11,18 +11,14 @@
|
||||
|
||||
#define MPSEPARATOR @"_&MP&_"
|
||||
|
||||
@interface NSObject (SimpleLogDelegate)
|
||||
-(void)processDidBeginRunning;
|
||||
-(void)processDidEndRunning;
|
||||
@end
|
||||
|
||||
int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]){
|
||||
int returnCode = TCL_OK;
|
||||
|
||||
NSArray *msgType = [[NSString stringWithUTF8String:Tcl_GetString(*(++objv))] componentsSeparatedByString:@" "];
|
||||
NSString *msg = [NSString stringWithUTF8String:Tcl_GetString(*(++objv))];
|
||||
|
||||
[delegate doSomething];
|
||||
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MPMsgNotification" object:msg];
|
||||
//[[NSDistributedNotificationCenter defaultCenter] postNotificationName: object:msg];
|
||||
|
||||
NSLog(@"%@ : %@",[msgType objectAtIndex:0], msg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user