[54592] branches/gsoc09-gui
juanger at macports.org
juanger at macports.org
Wed Jul 29 15:58:34 PDT 2009
Revision: 54592
http://trac.macports.org/changeset/54592
Author: juanger at macports.org
Date: 2009-07-29 15:58:34 -0700 (Wed, 29 Jul 2009)
Log Message:
-----------
Removing the delegate in favour of NSNotification
Modified Paths:
--------------
branches/gsoc09-gui/MPGUI/MPActionLauncher.m
branches/gsoc09-gui/MPGUI/MPActionsController.m
branches/gsoc09-gui/MacPorts_Framework/MPHelperTool.m
branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h
branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m
branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h
branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
Modified: branches/gsoc09-gui/MPGUI/MPActionLauncher.m
===================================================================
--- branches/gsoc09-gui/MPGUI/MPActionLauncher.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MPGUI/MPActionLauncher.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -32,6 +32,7 @@
}
- (id)init {
+ [self subscribeToNotifications];
if (sharedActionLauncher == nil) {
ports = [NSMutableArray arrayWithCapacity:1];
sharedActionLauncher = self;
@@ -87,7 +88,7 @@
- (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 @@
#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];
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(gotMPMSG:)
+ name:MPMSG object:nil];
[[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()
+ selector:@selector(gotMPMSG:)
name:MPMSG object:nil];
- */
}
+- (void)gotMPMSG:(NSNotification *)notification {
+ NSLog(@"GOT MPMSG NOTIFICATION");
+}
+
@end
Modified: branches/gsoc09-gui/MPGUI/MPActionsController.m
===================================================================
--- branches/gsoc09-gui/MPGUI/MPActionsController.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MPGUI/MPActionsController.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -64,7 +64,6 @@
[tableController hidePredicateEditor:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *pkgPath = [defaults objectForKey:@"PKGPath"];
-
if (pkgPath == nil) {
[self openPreferences:self];
} else {
Modified: branches/gsoc09-gui/MacPorts_Framework/MPHelperTool.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPHelperTool.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/MPHelperTool.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -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
Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h 2009-07-29 22:58:34 UTC (rev 54592)
@@ -104,12 +104,8 @@
+(void) setPKGPath:(NSString*)newPath;
-+(id) delegate;
++(NSTask*) task;
-+(void) setDelegate:(id)newDelegate;
-
--(NSTask*) task;
-
//Internal methods
-(BOOL) setOptionsForNewTclPort:(NSArray *)options;
Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -165,15 +165,6 @@
//tool
static NSString * tclInterpreterPkgPath = nil;
-+(id) delegate {
- return delegate;
-}
-
-+(void) setDelegate:(id)newDelegate {
- delegate = newDelegate;
-}
-
-
+(NSString*) PKGPath {
return PKGPath;
}
@@ -470,7 +461,7 @@
*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 @@
}
while (theProxy == nil);
- [theProxy evaluateString:statement delegate:delegate];
+ [theProxy evaluateString:statement];
+ [aTask waitUntilExit];
return nil;
}
-- (NSTask*) task {
++ (NSTask*) task {
return aTask;
}
Modified: branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -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];
}
Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -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);
}
Modified: branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h 2009-07-29 22:58:34 UTC (rev 54592)
@@ -9,6 +9,4 @@
#include <tcl.h>
-id delegate;
-
int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
\ No newline at end of file
Modified: branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m 2009-07-29 22:53:27 UTC (rev 54591)
+++ branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m 2009-07-29 22:58:34 UTC (rev 54592)
@@ -11,18 +11,14 @@
#define MPSEPARATOR @"_&MP&_"
- at interface NSObject (SimpleLogDelegate)
--(void)processDidBeginRunning;
--(void)processDidEndRunning;
- at 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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090729/481e21a2/attachment.html>
More information about the macports-changes
mailing list