[39103] branches/gsoc08-framework/MacPorts_Framework
armahg at macports.org
armahg at macports.org
Fri Aug 8 02:07:56 PDT 2008
Revision: 39103
http://trac.macosforge.org/projects/macports/changeset/39103
Author: armahg at macports.org
Date: 2008-08-08 02:07:56 -0700 (Fri, 08 Aug 2008)
Log Message:
-----------
Sitll working on IPC between framework and helpertool. Completed code on MPHelperTool side to retrieve file descriptor and write to file. bind() call on Framework side fails
Modified Paths:
--------------
branches/gsoc08-framework/MacPorts_Framework/MPHelperCommon.h
branches/gsoc08-framework/MacPorts_Framework/MPHelperTool.m
branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h
branches/gsoc08-framework/MacPorts_Framework/interpInit.tcl
Modified: branches/gsoc08-framework/MacPorts_Framework/MPHelperCommon.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPHelperCommon.h 2008-08-08 08:54:38 UTC (rev 39102)
+++ branches/gsoc08-framework/MacPorts_Framework/MPHelperCommon.h 2008-08-08 09:07:56 UTC (rev 39103)
@@ -40,6 +40,14 @@
//Tcl interpInit.tcl Path
#define kInterpInitFilePath "InterpInitTclFilePath" //CFString
+ //File Descriptor for server file
+ #define kServerFileDescriptor "ServerFileDescriptor" //CFNumber
+
+
+
+
+
+
//response keys
#define kTclStringEvaluationResult "TclStringEvaluationResult" //CFString
Modified: branches/gsoc08-framework/MacPorts_Framework/MPHelperTool.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPHelperTool.m 2008-08-08 08:54:38 UTC (rev 39102)
+++ branches/gsoc08-framework/MacPorts_Framework/MPHelperTool.m 2008-08-08 09:07:56 UTC (rev 39103)
@@ -80,7 +80,7 @@
}
else {
asl_NSLog(logClient, logMsg, ASL_LEVEL_ERR, @"Attempted to initialize writeHandle");
- asl_NSLog(logClient, logMsg, ASL_LEVEL_ERR, @"without having set notificationsFileDescriptor value");
+ asl_NSLog(logClient, logMsg, ASL_LEVEL_ERR, @"without having set proper notificationsFileDescriptor value");
}
err = asl_NSLog(logClient , logMsg, ASL_LEVEL_DEBUG, @"Starting writing to notification socket");
@@ -146,13 +146,23 @@
err = asl_NSLog(logClient , logMsg, ASL_LEVEL_DEBUG, @"Starting simplelog Logging");
assert( err == 0);
+ if (hasSetFileDescriptor) {
+ err = asl_NSLog(logClient, logMsg, ASL_LEVEL_DEBUG, @"Setting file descriptor");
+ assert(err == 0);
+ asl_add_log_file(logClient, notificationsFileDescriptor);
+ }
+ else{
+ err = asl_NSLog(logClient, logMsg, ASL_LEVEL_ERR, @"Unable to log to file descriptor");
+ assert(err == 0);
+ }
+
++objv, --objc;
if (objc) {
data = [NSString stringWithUTF8String:Tcl_GetString(*objv)];
[dHandle writeData:[data dataUsingEncoding:NSUTF8StringEncoding]];
- err = asl_NSLog(logClient , logMsg, ASL_LEVEL_DEBUG, @" %@ " , data);
- assert(err == 0);
+ //err = asl_NSLog(logClient , logMsg, ASL_LEVEL_DEBUG, @" %@ " , data);
+ //assert(err == 0);
returnCode = TCL_OK;
}
@@ -169,7 +179,7 @@
(
AuthorizationRef auth,
const void * userData,
- CFDictionaryRef request,
+ CFDictionaryRef request,
CFMutableDictionaryRef response,
aslclient asl,
aslmsg aslMsg
@@ -187,6 +197,14 @@
//asl may be null
//aslMsg may be null
+ //Set the file Descriptor here
+ NSNumber * num = (NSNumber *) (CFNumberRef) CFDictionaryGetValue(request, CFSTR(kServerFileDescriptor));
+ notificationsFileDescriptor = [num intValue];
+ asl_NSLog(asl, aslMsg, ASL_LEVEL_DEBUG, @"Setting file descriptor with value %i", notificationsFileDescriptor);
+ if (notificationsFileDescriptor > 0) {
+ hasSetFileDescriptor = YES;
+ }
+
//Get the string that was passed in the request dictionary
NSString * tclCmd = (NSString *) (CFStringRef)CFDictionaryGetValue(request, CFSTR(kTclStringToBeEvaluated));
if (tclCmd == nil) {
@@ -201,6 +219,7 @@
else
CFDictionaryAddValue(response, CFSTR("TclCommandInput"), (CFStringRef)tclCmd);
+
//Initialize Tcl Interpreter
Tcl_Interp * interpreter = Tcl_CreateInterp();
if(interpreter == NULL) {
@@ -240,6 +259,7 @@
CFDictionaryAddValue(response, CFSTR("MPFastload"), CFSTR("YES"));
}
+
//Add simplelog tcl command
Tcl_CreateObjCommand(interpreter, "simplelog", SimpleLog_Command, NULL, NULL);
if (Tcl_PkgProvide(interpreter, "simplelog", "1.0") != TCL_OK) {
Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m 2008-08-08 08:54:38 UTC (rev 39102)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m 2008-08-08 09:07:56 UTC (rev 39103)
@@ -504,11 +504,18 @@
NSString * interpInitPath = [[NSBundle bundleForClass:[MPInterpreter class]]
pathForResource:@"interpInit" ofType:@"tcl"];
+ int serverFileDesc = [[MPNotifications sharedListener] getServerFileDescriptor];
+
+ if (serverFileDesc < 0)
+ NSLog(@"Uninitialized file descriptor for HelperTool IPC");
+
+
request = [NSDictionary dictionaryWithObjectsAndKeys:
@kMPHelperEvaluateTclCommand, @kBASCommandKey,
statement, @kTclStringToBeEvaluated,
tclInterpreterPkgPath, @kTclInterpreterInitPath ,
- interpInitPath, @kInterpInitFilePath, nil];
+ interpInitPath, @kInterpInitFilePath,
+ [NSNumber numberWithInt:serverFileDesc], @kServerFileDescriptor, nil];
assert(request != NULL);
@@ -540,12 +547,16 @@
//NSLog(@"mpBundle is %@", [mpBundle description]);
NSString * installToolPath = [mpBundle pathForResource:@"MPHelperInstallTool" ofType:nil];
+ assert(installToolPath != nil);
NSURL * installToolURL = [NSURL fileURLWithPath:installToolPath];
+ assert(installToolURL != nil);
NSString * helperToolPath = [mpBundle pathForResource:@"MPHelperTool" ofType:nil];
+ assert(helperToolPath != nil);
NSURL * helperToolURL = [NSURL fileURLWithPath:helperToolPath];
+ assert(helperToolURL != nil);
//NSLog(@"Helper and Install tool URL's are \n %@ and \n %@ respectively",
- // [helperToolURL description] , [installToolURL description]);
+ // [helperToolURL description] , [installToolURL description]);
err = BASFixFailure(internalMacPortsAuthRef,
Modified: branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h 2008-08-08 08:54:38 UTC (rev 39102)
+++ branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h 2008-08-08 09:07:56 UTC (rev 39103)
@@ -142,7 +142,7 @@
//These methods aren't for the public ... yet ...
-(void)setPerformingTclCommand:(NSString *)string;
-(NSString *)performingTclCommand;
+-(int) getServerFileDescriptor;
-
@end
Modified: branches/gsoc08-framework/MacPorts_Framework/interpInit.tcl
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/interpInit.tcl 2008-08-08 08:54:38 UTC (rev 39102)
+++ branches/gsoc08-framework/MacPorts_Framework/interpInit.tcl 2008-08-08 09:07:56 UTC (rev 39103)
@@ -9,9 +9,9 @@
package require macports
package require simplelog
-package require mphelpertool_notify1
+
#Set ui_options to log all messages to stdout and notify system
#filtering is done on the Obj-C side of things
set ui_options(ports_debug) "yes"
@@ -84,6 +84,7 @@
puts $logDest "SOMETHING DEY HERE"
simplelog "SOMETHING DEY HERE"
+
#Modifying UI initialization to enable notifications
#Redefine ui_$pritority to throw global notifications
#This is currently under works ... a reasonable solution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080808/a51556d4/attachment-0001.html
More information about the macports-changes
mailing list