[39690] branches/gsoc08-framework/MacPorts_Framework_Release

armahg at macports.org armahg at macports.org
Sat Aug 30 19:16:26 PDT 2008


Revision: 39690
          http://trac.macosforge.org/projects/macports/changeset/39690
Author:   armahg at macports.org
Date:     2008-08-30 19:16:26 -0700 (Sat, 30 Aug 2008)
Log Message:
-----------
Added code to create BSD socket file for IPC on the fly. This means the socket file changes for every call to MPHelperTool.

Modified Paths:
--------------
    branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperCommon.h
    branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperTool.m
    branches/gsoc08-framework/MacPorts_Framework_Release/MPInterpreter.m
    branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.h
    branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.m
    branches/gsoc08-framework/MacPorts_Framework_Release/MacPorts.Framework.xcodeproj/project.pbxproj

Modified: branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperCommon.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperCommon.h	2008-08-30 21:52:05 UTC (rev 39689)
+++ branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperCommon.h	2008-08-31 02:16:26 UTC (rev 39690)
@@ -43,11 +43,14 @@
 	//File Descriptor for server file
 	#define kServerFileDescriptor		"ServerFileDescriptor"		//CFNumber
 
+	//File path for IPC socket
+	#define kServerFileSocketPath		"ServerFileSocketPath"		//CFString
 
 
 
 
 
+
 	//response keys
 	#define kTclStringEvaluationResult	"TclStringEvaluationResult"		//CFString
 

Modified: branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperTool.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperTool.m	2008-08-30 21:52:05 UTC (rev 39689)
+++ branches/gsoc08-framework/MacPorts_Framework_Release/MPHelperTool.m	2008-08-31 02:16:26 UTC (rev 39690)
@@ -60,6 +60,7 @@
 //fromt he request dictionary
 int notificationsFileDescriptor;
 BOOL hasSetFileDescriptor = NO;
+NSString * ipcFilePath;
 
 #pragma mark -
 #pragma mark ASL Logging 
@@ -894,7 +895,15 @@
 	//asl may be null
 	//aslMsg may be null
 	
+	//Get the ipc file path
+	ipcFilePath = (NSString *) (CFStringRef)CFDictionaryGetValue(request, CFSTR(kServerFileSocketPath));
+	if (ipcFilePath == nil) {
+		retval = coreFoundationUnknownErr;
+	}
+	else
+		CFDictionaryAddValue(response, CFSTR("SocketServerFilePath"), (CFStringRef)ipcFilePath);
 	
+	
 	//Get the string that was passed in the request dictionary
 	NSString *  tclCmd = (NSString *) (CFStringRef)CFDictionaryGetValue(request, CFSTR(kTclStringToBeEvaluated));
 	if (tclCmd == nil) {

Modified: branches/gsoc08-framework/MacPorts_Framework_Release/MPInterpreter.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework_Release/MPInterpreter.m	2008-08-30 21:52:05 UTC (rev 39689)
+++ branches/gsoc08-framework/MacPorts_Framework_Release/MPInterpreter.m	2008-08-31 02:16:26 UTC (rev 39690)
@@ -36,6 +36,7 @@
 #import "MPInterpreter.h"
 #include "BetterAuthorizationSampleLib.h"
 #include "MPHelperCommon.h"
+#include "MPHelperNotificationsProtocol.h"
 static AuthorizationRef internalMacPortsAuthRef;
 
 
@@ -381,28 +382,8 @@
 	
 	if ( *mportError != nil) {
 		*mportError = nil; 
-		
-		//We need to use the notificationsObject to set up IPC with the helper tool
-		//I hope BAS's main method is blocking ... it should be since we obtain
-		//a return value
-		MPNotifications * notificationObject = [MPNotifications sharedListener];
-		//if ([notificationObject respondsToSelector:@selector(prepareIPCServerThread)]) {
-			NSLog(@"PREPARING SERVER THREAD");
-			[notificationObject prepareIPCServerThread];
-		//}
-		
-		//if ([notificationObject respondsToSelector:@selector(startServerThread)]) {
-			NSThread * cThread = [NSThread currentThread];
-			NSLog(@"STARTING SERVER THREAD with previous thread %@", [cThread threadDictionary]);
-		[NSThread detachNewThreadSelector:@selector(startIPCServerThread) 
-								 toTarget:notificationObject 
-							   withObject:nil];
-		//[notificationObject startIPCServerThread];
-		
-		//}
 		secondResult = [self evaluateStringWithMPHelperTool:statement error:mportError];
 		
-		
 		return secondResult;
 	}
 	
@@ -422,17 +403,47 @@
 	
 	response = NULL;
 	
+	//Creating file path for IPC with helper tool
+	NSString * ipcFilePath = [NSString stringWithFormat:@"%@_%@", @kServerSocketPath, [NSDate date]];
+	NSString * ipcFilePathCopy = [NSString stringWithString:ipcFilePath];
+	
+	
+	//We need to use the notificationsObject to set up IPC with the helper tool
+	//I hope BAS's main method is blocking ... it should be since we obtain
+	//a return value
+	MPNotifications * notificationObject = [MPNotifications sharedListener];
+	//if ([notificationObject respondsToSelector:@selector(prepareIPCServerThread)]) {
+	NSLog(@"PREPARING SERVER THREAD");
+	[notificationObject prepareIPCServerThread];
+	//}
+	
+	//if ([notificationObject respondsToSelector:@selector(startServerThread)]) {
+	NSThread * cThread = [NSThread currentThread];
+	NSLog(@"STARTING SERVER THREAD with previous thread %@", [cThread threadDictionary]);
+	[NSThread detachNewThreadSelector:@selector(startIPCServerThread:) 
+							 toTarget:notificationObject 
+						   withObject:ipcFilePathCopy];
+	//[notificationObject startIPCServerThread];
+	//}
+	
+	
+	
+	
+	
 	//Retrieving the path for interpInit.tcl for our helper tool
 	NSString * interpInitPath = [[NSBundle bundleForClass:[MPInterpreter class]] 
 								 pathForResource:@"interpInit" ofType:@"tcl"];
 	
+		
 	
 	
+	
 	request = [NSDictionary dictionaryWithObjectsAndKeys:
 			   @kMPHelperEvaluateTclCommand, @kBASCommandKey,
 			   statement, @kTclStringToBeEvaluated, 
 			   tclInterpreterPkgPath, @kTclInterpreterInitPath ,
-			   interpInitPath, @kInterpInitFilePath, nil];
+			   interpInitPath, @kInterpInitFilePath, 
+			   ipcFilePath, @kServerFileSocketPath , nil];
 	
 	assert(request != NULL);
 	
@@ -546,7 +557,7 @@
 		}
 	}
 	
-	//NSLog(@"AFTER Tool Execution request is %@ , response is %@ \n\n", request, response);
+	NSLog(@"AFTER Tool Execution request is %@ , response is %@ \n\n", request, response);
 	
 	return result;
 }

Modified: branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.h	2008-08-30 21:52:05 UTC (rev 39689)
+++ branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.h	2008-08-31 02:16:26 UTC (rev 39690)
@@ -14,7 +14,7 @@
 @interface MPNotifications (IPCAdditions) 
 -(BOOL) terminateBackgroundThread;
 -(void) setTerminateBackgroundThread:(BOOL)newStatus;
--(void) startIPCServerThread;
+-(void) startIPCServerThread:(NSString *) socketFilePath;
 -(void) prepareIPCServerThread;
 -(void) stopIPCServerThread;
 

Modified: branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.m	2008-08-30 21:52:05 UTC (rev 39689)
+++ branches/gsoc08-framework/MacPorts_Framework_Release/MPNotifications+IPCAdditions.m	2008-08-31 02:16:26 UTC (rev 39690)
@@ -1344,7 +1344,7 @@
 	terminateBackgroundThread = newStatus;
 }
 
--(void) startIPCServerThread {
+-(void) startIPCServerThread:(NSString *)socketFilePath {
 	NSAutoreleasePool * sPool = [[NSAutoreleasePool alloc] init];
 	
 	NSLog(@"INSIDE SERVER THREAD");

Modified: branches/gsoc08-framework/MacPorts_Framework_Release/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework_Release/MacPorts.Framework.xcodeproj/project.pbxproj	2008-08-30 21:52:05 UTC (rev 39689)
+++ branches/gsoc08-framework/MacPorts_Framework_Release/MacPorts.Framework.xcodeproj/project.pbxproj	2008-08-31 02:16:26 UTC (rev 39690)
@@ -107,7 +107,7 @@
 			isa = PBXContainerItemProxy;
 			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
 			proxyType = 1;
-			remoteGlobalIDString = 8DC2EF4F0486A6940098B216 /* MacPorts */;
+			remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
 			remoteInfo = MacPorts;
 		};
 /* End PBXContainerItemProxy section */
@@ -169,7 +169,7 @@
 		6ED12A540E3E55DF0026773D /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
 		6ED12AA60E3E7E900026773D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
 		6ED1AC740E4BA162000353B6 /* HelperToolServerFile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HelperToolServerFile.txt; sourceTree = "<group>"; };
-		6EE6DD9E0E626D2800FB2115 /* MPHelperToolIPCTester */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MPHelperToolIPCTester; path = build/Debug/MPHelperToolIPCTester; sourceTree = "<group>"; };
+		6EE6DD9E0E626D2800FB2115 /* MPHelperToolIPCTester */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPHelperToolIPCTester; sourceTree = BUILT_PRODUCTS_DIR; };
 		6EE6DDAA0E626DC900FB2115 /* MPHelperToolIPCTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPHelperToolIPCTester.m; sourceTree = "<group>"; };
 		6EE6DDCC0E6276AA00FB2115 /* MPNotifications+IPCAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPNotifications+IPCAdditions.h"; sourceTree = "<group>"; };
 		6EE6DDCD0E6276AA00FB2115 /* MPNotifications+IPCAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPNotifications+IPCAdditions.m"; sourceTree = "<group>"; };
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080830/d74a2429/attachment-0001.html 


More information about the macports-changes mailing list