[55628] branches/gsoc09-gui/MacPorts_Framework
juanger at macports.org
juanger at macports.org
Fri Aug 14 18:17:39 PDT 2009
Revision: 55628
http://trac.macports.org/changeset/55628
Author: juanger at macports.org
Date: 2009-08-14 18:17:39 -0700 (Fri, 14 Aug 2009)
Log Message:
-----------
SimpleLog for MPPortProcess now uses MPNotifications. cancelCurrentCommand terminates MPPortProcess or MPHelperTool depending of needed write permissions for each tool. MPInterpreter sends notifications when a task is starting or stopping.
Modified Paths:
--------------
branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m
branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m 2009-08-15 00:53:36 UTC (rev 55627)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m 2009-08-15 01:17:39 UTC (rev 55628)
@@ -458,15 +458,19 @@
//mportError parameter
NSString * result;
+ [[MPNotifications sharedListener]
+ sendIPCNotification:@"MPInfoNotification_&MP&_stdout_&MP&_None_&MP&_Starting up"];
+
// Is this the best way to know if the running user can use macports without privileges?
if ([[NSFileManager defaultManager] isWritableFileAtPath:PKGPath]) {
- [[MPMacPorts sharedInstance] setAuthorizationMode:NO];
result = [self evaluateStringWithMPPortProcess:statement error:mportError];
} else {
- [[MPMacPorts sharedInstance] setAuthorizationMode:YES];
result = [self evaluateStringWithMPHelperTool:statement error:mportError];
}
-
+
+ [[MPNotifications sharedListener]
+ sendIPCNotification:@"MPInfoNotification_&MP&_stdout_&MP&_None_&MP&_Shutting down"];
+
return result;
}
@@ -632,6 +636,20 @@
[aTask setArguments:args];
[aTask launch];
+ NSConnection *notificationsConnection = [NSConnection defaultConnection];
+ // Vending MPNotifications sharedListener
+ [notificationsConnection setRootObject:[MPNotifications sharedListener]];
+
+ // Register the named connection
+ if ( [notificationsConnection registerName:@"MPNotifications"] ) {
+ NSLog( @"Successfully registered connection with port %@",
+ [[notificationsConnection receivePort] description] );
+ } else {
+ NSLog( @"Name used by %@",
+ [[[NSPortNameServer systemDefaultPortNameServer] portForName:@"MPNotifications"] description] );
+ }
+
+
id theProxy;
do {
theProxy = [NSConnection
@@ -645,11 +663,10 @@
int status = [aTask terminationStatus];
- if (status == TCL_OK) {
- NSLog(@"Task succeeded.");
- } else {
- NSLog(@"Task failed.%i", status);
+ if (status != TCL_OK) {
+ NSLog(@"Task failed. Code: %i", status);
}
+ [[notificationsConnection receivePort] invalidate];
return nil;
}
Modified: branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m 2009-08-15 00:53:36 UTC (rev 55627)
+++ branches/gsoc09-gui/MacPorts_Framework/MPMacPorts.m 2009-08-15 01:17:39 UTC (rev 55628)
@@ -60,13 +60,15 @@
}
- (void) cancelCurrentCommand {
- if (authorizationMode) {
- [MPInterpreter terminateMPHelperTool];
- } else {
+ if ([[NSFileManager defaultManager] isWritableFileAtPath:[MPInterpreter PKGPath]]) {
+ NSLog(@"Terminating MPPortProcess");
NSTask *task = [MPInterpreter task];
if(task != nil && [task isRunning]) {
[task terminate];
}
+ } else {
+ NSLog(@"Terminating MPHelperTool");
+ [MPInterpreter terminateMPHelperTool];
}
}
Modified: branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m 2009-08-15 00:53:36 UTC (rev 55627)
+++ branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m 2009-08-15 01:17:39 UTC (rev 55628)
@@ -11,16 +11,77 @@
#define MPSEPARATOR @"_&MP&_"
-int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]){
- int returnCode = TCL_OK;
+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))];
+// NSArray *msgType = [[NSString stringWithUTF8String:Tcl_GetString(*(++objv))] componentsSeparatedByString:@" "];
+// NSString *msg = [NSString stringWithUTF8String:Tcl_GetString(*(++objv))];
+//
+// NSLog(@"%@ : %@",[msgType objectAtIndex:0], msg);
- [[NSDistributedNotificationCenter defaultCenter] postNotificationName:[msgType objectAtIndex:0] object:msg];
+ //[[NSDistributedNotificationCenter defaultCenter] postNotificationName:[msgType objectAtIndex:0] object:msg];
//[[NSDistributedNotificationCenter defaultCenter] postNotificationName: object:msg];
- //NSLog(@"%@ : %@",[msgType objectAtIndex:0], msg);
+// NSLog(@"SIIIIIIIIIIIIIIIIIIIIIIIIII");
+//
+ int returnCode = TCL_ERROR;
+ NSMutableString * data;
+
+ ++objv, --objc;
+
+ if (objc) {
+ int tclCount;
+ int tclResult;
+ const char **tclElements;
+
+
+ tclResult = Tcl_SplitList(interpreter, Tcl_GetString(*objv), &tclCount, &tclElements);
+
+
+ if (tclResult == TCL_OK) {
+ if (tclCount > 0) {
+ data = [NSMutableString stringWithUTF8String:tclElements[0]];
+ [data appendString:MPSEPARATOR];
+
+ if(tclCount > 1 && tclElements[1]) {
+ [data appendString:[NSString stringWithUTF8String:tclElements[1]]];
+ [data appendString:MPSEPARATOR];
+ }
+ else {
+ [data appendString:@"None"];
+ [data appendString:MPSEPARATOR];
+ }
+
+ if(tclCount > 2 && tclElements[2]) {
+ [data appendString:[NSString stringWithUTF8String:tclElements[2]]];
+ [data appendString:MPSEPARATOR];
+ }
+ else {
+ [data appendString:@"None"];
+ [data appendString:MPSEPARATOR];
+ }
+ }
+ else {
+ data = [NSMutableString stringWithFormat:@"None%@None%@None%@", MPSEPARATOR, MPSEPARATOR, MPSEPARATOR ];
+ }
+ }
+ }
+ //Now get the actual message
+ ++objv; --objc;
+ if (objc) {
+ [data appendString:[NSString stringWithUTF8String:Tcl_GetString(*objv)]];
+ }
+ else {
+ [data appendString:@"None"];
+ }
+
+ id theProxy = [NSConnection
+ rootProxyForConnectionWithRegisteredName:@"MPNotifications"
+ host:nil];
+ [theProxy sendIPCNotification:data];
+
+ NSLog(@"-----%@", data);
+
return returnCode;
}
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090814/3fa7d32a/attachment.html>
More information about the macports-changes
mailing list