[53692] branches/gsoc09-gui

juanger at macports.org juanger at macports.org
Sat Jul 11 19:24:50 PDT 2009


Revision: 53692
          http://trac.macports.org/changeset/53692
Author:   juanger at macports.org
Date:     2009-07-11 19:24:49 -0700 (Sat, 11 Jul 2009)
Log Message:
-----------
Integrating the MPPortProcess to the framework

Modified Paths:
--------------
    branches/gsoc09-gui/MPGUI/MPActionLauncher.m
    branches/gsoc09-gui/MPGUI/MPGUI.xcodeproj/project.pbxproj
    branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h
    branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
    branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h
    branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
    branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
    branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl

Modified: branches/gsoc09-gui/MPGUI/MPActionLauncher.m
===================================================================
--- branches/gsoc09-gui/MPGUI/MPActionLauncher.m	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MPGUI/MPActionLauncher.m	2009-07-12 02:24:49 UTC (rev 53692)
@@ -51,11 +51,14 @@
 }
 
 - (void)installPortInBackground:(MPPort *)port {
-    id theProxy;
-    theProxy = [NSConnection
-                    rootProxyForConnectionWithRegisteredName:@"actionTool"
-                    host:nil];
-    [theProxy installPort:port];
+//    id theProxy;
+//    theProxy = [NSConnection
+//                    rootProxyForConnectionWithRegisteredName:@"actionTool"
+//                    host:nil];
+//    [theProxy installPort:port];
+    NSError * error;
+    NSArray *empty = [NSArray arrayWithObject: @""];
+    [port installWithOptions:empty variants:empty error:&error];
 }
 
 - (void)uninstallPortInBackground:(MPPort *)port {

Modified: branches/gsoc09-gui/MPGUI/MPGUI.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc09-gui/MPGUI/MPGUI.xcodeproj/project.pbxproj	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MPGUI/MPGUI.xcodeproj/project.pbxproj	2009-07-12 02:24:49 UTC (rev 53692)
@@ -61,6 +61,13 @@
 			remoteGlobalIDString = 21A588130FF5D508003CF725;
 			remoteInfo = MPActionTool;
 		};
+		21D954D81009731100DEF58A /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 21F165400FE2C04300542AEE /* MacPorts.Framework.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 21D9543E100940EE00DEF58A /* MPPortProcess */;
+			remoteInfo = MPPortProcess;
+		};
 		21F1654C0FE2C04300542AEE /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = 21F165400FE2C04300542AEE /* MacPorts.Framework.xcodeproj */;
@@ -230,6 +237,7 @@
 				21F165510FE2C04300542AEE /* MacPorts.framework */,
 				21F165530FE2C04300542AEE /* Test.octest */,
 				21F165550FE2C04300542AEE /* MPHelperToolIPCTester */,
+				21D954D91009731100DEF58A /* MPPortProcess */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -387,6 +395,13 @@
 /* End PBXProject section */
 
 /* Begin PBXReferenceProxy section */
+		21D954D91009731100DEF58A /* MPPortProcess */ = {
+			isa = PBXReferenceProxy;
+			fileType = "compiled.mach-o.executable";
+			path = MPPortProcess;
+			remoteRef = 21D954D81009731100DEF58A /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
 		21F1654D0FE2C04300542AEE /* MPHelperInstallTool */ = {
 			isa = PBXReferenceProxy;
 			fileType = "compiled.mach-o.executable";

Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.h	2009-07-12 02:24:49 UTC (rev 53692)
@@ -201,5 +201,6 @@
 - (void)setAuthorizationRef:(AuthorizationRef)authRef;
 - (BOOL)checkIfAuthorized;
 -(NSString *)evaluateStringWithMPHelperTool:(NSString *)statement error:(NSError **)mportError;
+-(NSString *)evaluateStringWithMPPortProcess:(NSString *)statement error:(NSError **)mportError;
 
 @end

Modified: branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m	2009-07-12 02:24:49 UTC (rev 53692)
@@ -453,16 +453,14 @@
 }
 
 - (NSString *)evaluateStringWithPossiblePrivileges:(NSString *)statement error:(NSError **)mportError {
-	
-	
-	
 	//N.B. I am going to insist that funciton users not pass in nil for the
 	//mportError parameter
 	NSString * firstResult;
 	NSString * secondResult;
 	
 	*mportError = nil;
-	firstResult = [self evaluateStringAsString:statement error:mportError];
+    //  firstResult = [self evaluateStringAsString:statement error:mportError];
+   	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.
@@ -658,7 +656,18 @@
 	return result;
 }
 
+- (NSString *) evaluateStringWithMPPortProcess:(NSString *) statement error:(NSError **)mportError {
+    NSLog(@"Path: %@", [[NSBundle bundleForClass:[self class]] resourcePath]);
+    NSString *portProcessPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"MPPortProcess" ofType:@""];
+    NSTask *portProcess = [NSTask launchedTaskWithLaunchPath:portProcessPath arguments:[NSArray arrayWithObject:PKGPath]];
+    id theProxy = [NSConnection
+                rootProxyForConnectionWithRegisteredName:@"MPPortProcess"
+                host:nil];
+    [theProxy evaluateString:statement];
+    return nil;
+}
 
+
 #pragma mark -
 #pragma mark Authorization Code
 

Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h	2009-07-12 02:24:49 UTC (rev 53692)
@@ -13,4 +13,6 @@
     NSString *PKGPath;
 }
 
+- (oneway void)evaluateString:(bycopy id)statement;
+
 @end

Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m	2009-07-12 02:24:49 UTC (rev 53692)
@@ -23,7 +23,7 @@
     return self;
 }
 
-- (oneway void)evaluateString:(byref id)statement {
+- (oneway void)evaluateString:(bycopy id)statement {
     // TODO Handle the posible errors and notifications
     Tcl_Eval(interpreter, [statement UTF8String]);
 }
@@ -48,9 +48,14 @@
 		NSLog(@"Error in Tcl_EvalFile macports_fastload.tcl: %s", Tcl_GetStringResult(interpreter));
 		Tcl_DeleteInterp(interpreter);
 	}
-    // TODO Load distributed object messaging methods
+    // TODO Load notifications methods
     
-    // TODO load portProcessInit.tcl
+    // Load portProcessInit.tcl
+    NSString *portProcessInitPath = @"portProcessInit.tcl";
+    if( Tcl_EvalFile(interpreter, [portProcessInitPath UTF8String]) == TCL_ERROR) {
+		NSLog(@"Error in Tcl_EvalFile portProcessInit.tcl: %s", Tcl_GetStringResult(interpreter));
+		Tcl_DeleteInterp(interpreter);
+	}
 }
 
 @end
@@ -75,8 +80,6 @@
               [[[NSPortNameServer systemDefaultPortNameServer] portForName:@"MPPortProcess"] description] );
     }
     
-    // TODO Send a ready signal to "delegate"
-    
     // Wait for any message
     [[NSRunLoop currentRunLoop] run];
   	[pool release];

Modified: branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2009-07-12 02:24:49 UTC (rev 53692)
@@ -25,6 +25,7 @@
 		21D954431009411400DEF58A /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
 		21D954471009412F00DEF58A /* MPPortProcess.m in Sources */ = {isa = PBXBuildFile; fileRef = 21D954461009412F00DEF58A /* MPPortProcess.m */; };
 		21D954721009475200DEF58A /* portProcessInit.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 21D954711009475200DEF58A /* portProcessInit.tcl */; };
+		21D9548C1009522100DEF58A /* MPPortProcess in Resources */ = {isa = PBXBuildFile; fileRef = 21D9543E100940EE00DEF58A /* MPPortProcess */; };
 		481D04A20CDAAAFD00D4A550 /* MPMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		481D04A30CDAAAFD00D4A550 /* MPMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */; };
 		4825ECC30CE6145B006B0385 /* MPRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 48F811BE0CE4636A009630DE /* MPRegistry.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -127,10 +128,10 @@
 		089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
 		21067BB50FE5B25800CAD732 /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
-		21D9543E100940EE00DEF58A /* MPPortProcess */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MPPortProcess; path = build/Release/MPPortProcess; sourceTree = "<group>"; };
+		21D9543E100940EE00DEF58A /* MPPortProcess */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPPortProcess; sourceTree = BUILT_PRODUCTS_DIR; };
 		21D954461009412F00DEF58A /* MPPortProcess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPortProcess.m; sourceTree = "<group>"; };
 		21D954491009413800DEF58A /* MPPortProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPortProcess.h; sourceTree = "<group>"; };
-		21D954711009475200DEF58A /* portProcessInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = portProcessInit.tcl; sourceTree = "<group>"; };
+		21D954711009475200DEF58A /* portProcessInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = portProcessInit.tcl; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.simpleColoring; };
 		32DBCF5E0370ADEE00C91783 /* MacPorts.Framework_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacPorts.Framework_Prefix.pch; sourceTree = "<group>"; };
 		481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MPMutableDictionary.h; sourceTree = "<group>"; };
 		481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MPMutableDictionary.m; sourceTree = "<group>"; };
@@ -623,6 +624,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				6EB6FA460E43ECD60057962C /* MPHelperInstallTool in Resources */,
+				21D9548C1009522100DEF58A /* MPPortProcess in Resources */,
 				6EB6FA420E43ECCE0057962C /* MPHelperTool in Resources */,
 				8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
 				48E9939F0C82CEB000219DDF /* init.tcl in Resources */,

Modified: branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl	2009-07-12 01:53:13 UTC (rev 53691)
+++ branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl	2009-07-12 02:24:49 UTC (rev 53692)
@@ -18,145 +18,6 @@
 	return 0
 }
 
-# UI Callback
-proc ui_prefix {priority} {
-    switch $priority {
-        debug {
-        	return "DEBUG: "
-        }
-        error {
-        	return "Error: "
-        }
-        warn {
-        	return "Warning: "
-        }
-        default {
-        	return ""
-        }
-    }
-}
-
-proc ui_channels {priority} {
-    global logfd
-    switch $priority {
-        debug {
-            if {[ui_isset ports_debug]} {
-            	return {stderr}
-            } else {
-            	return {}
-            }
-        }
-        info {
-            if {[ui_isset ports_verbose]} {
-                return {stdout}
-            } else {
-                return {}
-			}
-		}
-        msg {
-            if {[ui_isset ports_quiet]} {
-                return {}
-			} else {
-				return {stdout}
-			}
-		}
-        error {
-        	return {stderr}
-        }
-        default {
-        	return {stdout}
-        }
-    }
-}
-
-
-
-
-#Modifying UI initialization to enable notifications
-#Redefine ui_$pritority to throw global notifications
-#This is currently under works ... a reasonable solution
-#should be coming up soon
-proc ui_init {priority prefix channels message} {
-	switch $priority {
-		msg {
-			set nottype "MPMsgNotification" 
-		}
-		debug {
-			set "MPDebugNotification"
-			puts "Recieved Debug"
-		}
-		warn {
-			set nottype "MPWarnNotification"
-		}
-		error {
-			set nottype "MPErrorNotification"
-			puts "Recieved Error"
-		}
-		info {
-			set nottype "MPInfoNotification"
-			puts "Recieved Info"
-		}
-		default {
-			set nottype "MPDefaultNotification"
-		}	
-	}
-	
-    # Get the list of channels.
-    try {
-        set channels [ui_channels $priority]
-    } catch * {
-        set channels [ui_channels_default $priority]
-    }
-    
-    #set channels [ui_channels $priority]
-    
-    # Simplify ui_$priority.
-    set nbchans [llength $channels]
-    if {$nbchans == 0} {
-        proc ::ui_$priority {str} [subst {
-        	# Here I should use my tcl extension
-        }]
-    } else {
-        try {
-            set prefix [ui_prefix $priority]
-        } catch * {
-            set prefix [ui_prefix_default $priority]
-        }
-        
-        #set prefix [ui_prefix $priority]
-        
-        if {$nbchans == 1} {
-          set chan [lindex $channels 0]
-
-          proc ::ui_$priority {args} [subst {
-            if {\[lindex \$args 0\] == "-nonewline"} {
-              puts $chan "$prefix\[lindex \$args 1\]"
-              notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
-            } else {
-              puts -nonewline $chan "$prefix\[lindex \$args 1\]"
-              notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
-            }
-          }]
-        } else {
-          proc ::ui_$priority {args} [subst {
-            foreach chan \$channels {
-              if {\[lindex \$args 0\] == "-nonewline"} {
-                puts $chan "$prefix\[lindex \$args 1\]"
-                notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
-              } else {
-                puts -nonewline $chan "$prefix\[lindex \$args 1\]"
-                notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
-              }
-            }
-          }]
-        }
-
-    # Call ui_$priority - Is this step necessary? Consult with Randall
-    #::ui_$priority $message
-    }
-}
-
-
 #Wrapping the following API routines to catch errors
 #and log error Information in a similar fashion to code
 #in macports.tcl.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090711/979b8bc7/attachment.html>


More information about the macports-changes mailing list