[39001] branches/gsoc08-framework/MacPorts_Framework
armahg at macports.org
armahg at macports.org
Tue Aug 5 16:40:20 PDT 2008
Revision: 39001
http://trac.macosforge.org/projects/macports/changeset/39001
Author: armahg at macports.org
Date: 2008-08-05 16:40:20 -0700 (Tue, 05 Aug 2008)
Log Message:
-----------
Completed implementation of Authorization for Framework. Framework Clients will now have to provide an initialized AuthorizationRef. Added SimplDOMHelperTool code: a helper tool that uses distributed objects. Remember to add checking for AuthorizationRef initialization before performing privileged operations
Modified Paths:
--------------
branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h
branches/gsoc08-framework/MacPorts_Framework/MPNotifications.m
branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
branches/gsoc08-framework/MacPorts_Framework/init.tcl
Added Paths:
-----------
branches/gsoc08-framework/MacPorts_Framework/MPInterpreterProtocol.h
branches/gsoc08-framework/MacPorts_Framework/SimpleDOMPHelperTool.m
Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h 2008-08-05 23:40:20 UTC (rev 39001)
@@ -40,6 +40,7 @@
*/
#import <Cocoa/Cocoa.h>
+#import <Security/Security.h>
#include <tcl.h>
#import "MPNotifications.h"
#import "MPInterpreterProtocol.h"
@@ -58,7 +59,19 @@
#define MPFrameworkErrorDomain @"MacPortsFrameworkErrorDomain"
+#define MPNOTIFICATION_NAME @"Notification"
+#define MPCHANNEL @"Channel"
+#define MPPREFIX @"Prefix"
+#define MPMETHOD @"Method"
+#define MPMESSAGE @"Message"
+
+
+/////////////////////////////////////////////////////////////////
+#pragma mark ***** Globals
+
+
+
/*!
@class MPInterpreter
@abstract Tcl interpreter object
@@ -176,6 +189,9 @@
*/
- (NSString *)getVariableAsString:(NSString *)variable;
+// METHODS FOR INTERNAL USE ONLY
+-(void)setAuthorizationRef:(AuthorizationRef)authRef;
+-(BOOL)checkIfAuthorized;
//For testing helper tools
-(NSString *)evaluateStringWithMPHelperTool:(NSString *)statement;
Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m 2008-08-05 23:40:20 UTC (rev 39001)
@@ -36,13 +36,10 @@
#import "MPInterpreter.h"
#include "BetterAuthorizationSampleLib.h"
#include "MPHelperCommon.h"
+static AuthorizationRef internalMacPortsAuthRef;
-/////////////////////////////////////////////////////////////////
-#pragma mark ***** Globals
-static AuthorizationRef mpAuth;
-
#pragma mark -
@implementation MPInterpreter
@@ -52,12 +49,13 @@
NSString *name;
NSMutableString *msg;
- //Our info dictionary is of size 4 and contains the following keys
- //Channel - eg. stdout, stderr
- //Prefix - prefix string for this message e.g. DEBUG:
- //Function - the function whose operation led to this notification eg. sync, selfupdate
- //Message - the message logged to channel
- NSMutableDictionary *info = [NSMutableDictionary dictionaryWithCapacity:4];
+ //Our info dictionary is of size 5 and contains the following keys
+ //NOTIFICATION_NAME - e.g. MPWARN, MPDEBUG etc.
+ //CHANNEL - eg. stdout, stderr
+ //PREFIX - prefix string for this message e.g. DEBUG:
+ //METHOD - the function whose operation led to this notification eg. sync, selfupdate
+ //MESSAGE - the message logged to channel
+ NSMutableDictionary *info = [NSMutableDictionary dictionaryWithCapacity:5];
MPNotifications *mln = [MPNotifications sharedListener];
int tclCount;
@@ -65,7 +63,8 @@
const char **tclElements;
name = [NSString stringWithUTF8String:Tcl_GetString(*objv)];
- NSLog(@"name is %@", name);
+ //NSLog(@"name is %@", name);
+ [info setObject:name forKey:MPNOTIFICATION_NAME];
//Name and Notification constants should match. Convention
//used is MPPriorityNotification. Is it ok to just return TCL_OK ?
@@ -81,16 +80,16 @@
//I have sacrificed generality for simplicity in the code below
if (tclElements > 0) {
- [info setObject:[NSString stringWithUTF8String:tclElements[0]] forKey:@"Channel"];
+ [info setObject:[NSString stringWithUTF8String:tclElements[0]] forKey:MPCHANNEL];
if(tclElements[1])
- [info setObject:[NSString stringWithUTF8String:tclElements[1]] forKey:@"Prefix"];
+ [info setObject:[NSString stringWithUTF8String:tclElements[1]] forKey:MPPREFIX];
else
- [info setObject:@"None" forKey:@"Prefix"];
+ [info setObject:@"None" forKey:MPPREFIX];
}
else {
- [info setObject:@"None" forKey:@"Channel"];
- [info setObject:@"None" forKey:@"Prefix"];
+ [info setObject:@"None" forKey:MPCHANNEL];
+ [info setObject:@"None" forKey:MPPREFIX];
}
@@ -103,7 +102,7 @@
//strip off "--->" over here
NSArray * temp = [msg componentsSeparatedByString:@"--->"];
[msg setString:[temp componentsJoinedByString:@""]];
- [info setObject:msg forKey:@"Message"];
+ [info setObject:msg forKey:MPMESSAGE];
}
//Get the Tcl function that called this method
@@ -166,57 +165,23 @@
#pragma mark -
#pragma mark Authorization Code
-//Internal method for setting up Authorizatin Reference
-//Called during initialization of interpreter object
-//This is a bit weird: Since MPInterpreter is compiled twice First for the helper
-//tool and then for the Framework, we want to call this method only when it is
-//being compiled for the Framework ... hence we check that the main bundle name is
-//MacPorts.Framework before initializing authorization
--(void) initializeAuthorization {
- //I'll probably regret doing this later on
- //but whatever ....
- char * username = "armahg";
- char * password = "200485";
-
- OSStatus junk;
-
- //Create Environment specific to this machine for tesitng purposes
- AuthorizationItem envItems[2];
- envItems[0].name = kAuthorizationEnvironmentPassword;
- envItems[0].value = password;
- envItems[0].valueLength = strlen(password);
- envItems[0].flags = 0;
-
- envItems[1].name = kAuthorizationEnvironmentUsername;
- envItems[1].value = username;
- envItems[1].valueLength = strlen(username);
- envItems[1].flags = 0;
-
- AuthorizationItemSet env = { 2 , envItems };
-
- AuthorizationFlags envFlags;
- envFlags = kAuthorizationFlagDefaults |
- kAuthorizationFlagExtendRights |
- kAuthorizationFlagPreAuthorize;
-
-
- junk = AuthorizationCreate(NULL, &env, envFlags, &mpAuth);
- assert(junk == noErr);
- //assert (junk == noErr) == (mpAuth != NULL);
-
- NSString * bundleID = [[NSBundle bundleForClass:[self class]] bundleIdentifier];
-
- //Set _userDataInterp over here
- //kMPHelperCommandSet[0].userData = _interpreter;
-
- BASSetDefaultRules(mpAuth,
- kMPHelperCommandSet,
- (CFStringRef) bundleID,
- NULL);
-
+
+- (BOOL)checkIfAuthorized {
+ if (internalMacPortsAuthRef == NULL ) {
+ return NO;
+ }
+ return YES;
}
+-(void)setAuthorizationRef:(AuthorizationRef)authRef {
+ //I can do this since Framework client responsible
+ //for managing memory for Authorization
+ internalMacPortsAuthRef = authRef;
+}
+
+
+
#pragma mark -
#pragma mark MPInterpreterProtocol
@@ -224,11 +189,11 @@
- (BOOL) vendSelfForServer {
NSConnection * defaultConn;
defaultConn = [NSConnection defaultConnection];
- NSLog(@"Creating connection ...");
+ //NSLog(@"Creating connection ...");
[defaultConn setRootObject:self];
- NSLog(@"Connection Created ... "); //%@, %@", defaultConn, [defaultConn statistics]);
+ //NSLog(@"Connection Created ... "); //%@, %@", defaultConn, [defaultConn statistics]);
return [defaultConn registerName:MP_DOSERVER];
}
@@ -331,12 +296,12 @@
//worry (I hope) about running loops for different threads
//[[NSRunLoop currentRunLoop] run];
- if (![self vendSelfForServer]) {
- NSLog(@"Failed To initialize NSConnection server ");
- //Should probably do some more error handling over here
- }
- else
- NSLog(@"MPInterpreter Initialized ...");
+ //if (![self vendSelfForServer]) {
+// NSLog(@"Failed To initialize NSConnection server ");
+// //Should probably do some more error handling over here
+// }
+// else
+// NSLog(@"MPInterpreter Initialized ...");
}
@@ -510,6 +475,10 @@
#pragma mark -
#pragma mark Helper Tool(s) Code
+//NOTE: We expect the Framework client to initialize the AuthorizationRef
+//Completely before calling any privileged operation. Perhaps we
+//should check for this and send an NSError ... rather than go
+//through the trouble of initializing the call and erroring out?
- (NSString *) evaluateStringWithMPHelperTool:(NSString *) statement {
OSStatus err;
BASFailCode failCode;
@@ -528,13 +497,13 @@
assert(bundleID != NULL);
+ BASSetDefaultRules(internalMacPortsAuthRef,
+ kMPHelperCommandSet,
+ (CFStringRef) bundleID,
+ NULL);
- //_userDataInterp points to _interpreter after the
- //method below
- [self initializeAuthorization];
-
NSLog(@"BEFORE Tool Execution request is %@ , resonse is %@ \n\n", request, response);
- err = BASExecuteRequestInHelperTool(mpAuth,
+ err = BASExecuteRequestInHelperTool(internalMacPortsAuthRef,
kMPHelperCommandSet,
(CFStringRef) bundleID,
(CFDictionaryRef) request,
@@ -543,16 +512,16 @@
//Try to recover
if ( (err != noErr) && (err != userCanceledErr) ) {
- failCode = BASDiagnoseFailure(mpAuth, (CFStringRef) bundleID);
+ failCode = BASDiagnoseFailure(internalMacPortsAuthRef, (CFStringRef) bundleID);
- err = BASFixFailure(mpAuth,
+ err = BASFixFailure(internalMacPortsAuthRef,
(CFStringRef) bundleID,
CFSTR("MPHelperInstallTool"),
CFSTR("MPHelperTool"),
failCode);
if (err == noErr) {
- err = BASExecuteRequestInHelperTool(mpAuth,
+ err = BASExecuteRequestInHelperTool(internalMacPortsAuthRef,
kMPHelperCommandSet,
(CFStringRef) bundleID,
(CFDictionaryRef) request,
Added: branches/gsoc08-framework/MacPorts_Framework/MPInterpreterProtocol.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreterProtocol.h (rev 0)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreterProtocol.h 2008-08-05 23:40:20 UTC (rev 39001)
@@ -0,0 +1,84 @@
+/*
+ * $Id$
+ * MacPorts.Framework
+ *
+ * Authors:
+ * George Armah <armahg at macports.org>
+ *
+ * Copyright (c) 2008 George Armah <armahg at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright owner nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//MPInterpreter needs to be exposed (in a controlled manner)
+//to MPHelperTool. There are various reasons for doing this.
+
+//- The first is that, there is no way (that I know so far) to access
+// the created Tcl interpreter from the Helper Tool. Even if we could
+// access it, I doubt that the Notifications mechanism will still be
+// able to work on a local level since MPHelperTool is a completely
+// different process. For this reason I am adopting the following
+// strategy
+
+// I'll illustrate with a port sync example. Note that all the necessary
+// Distributed Objects stuff is assumed to have already been set up.
+// 1) There is a [[MPMacPorts sharedInstance] sync] call
+// 2) This calls an internal [interp evaluateStringWithMPHelperTool@"mportsync"]
+// which then invokes MPHelperTool using BAS protocol. Passing the argument
+// @"mportsync" within the request dictionary.
+// 3) So now we are within MPHelperTool. We first obtain the vended of instance
+// MPInterpreter (which invoked this all in the first place ... ha) and then
+// call an this protocol's method [interp evaluateTclStringFromMPHelperTool: ]
+// This takes us back to
+// MacPorts.Framework space where everything happens as expected and then
+// (hopefully without any hiccups) returns the string result and error object.
+// 4) Now we can put the string returned into the response dictionary and pass
+// it back as the return value for the message passed in 2)
+//
+// You can probably tell that the above solution is kind of clunky. But its a
+// start. I'm not too worried about security being compromised since I am sure
+// of what happens in MPInterpreter space. In any event, using this method is
+// no more dangerous than running "sudo port -dv sync" from Terminal.
+//
+// I am still thinking of a way to implement error handling within the new set up.
+// One possiblity would be to have MPInterpreter's evaluateStringWithMPHelperTool:
+// message do an internal NSError creation depending on whether or not the
+// response dictionary contians a value for kNSError. This is going to be a
+// CFDictionaryRef object from which I'll have enough information to create
+// a reasonably informative NSError object. Thats for later though .... for
+// now lets get basic functionally going first.
+
+#define MP_DOSERVER @"MacPortsDistributedObjectServer"
+
+ at protocol MPInterpreterProtocol
+
+- (bycopy NSString *)evaluateStringFromMPHelperTool:(in bycopy NSString *)statement;
+- (void) setTclCommand:(in bycopy NSString *)tclCmd;
+- (bycopy NSString *) getTclCommand;
+- (void) setTclCommandResult:(in bycopy NSString *)tclCmdResult;
+- (bycopy NSString *) getTclCommandResult;
+- (void) log:(in bycopy id)logOutput;
+ at end
Property changes on: branches/gsoc08-framework/MacPorts_Framework/MPInterpreterProtocol.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h 2008-08-05 23:40:20 UTC (rev 39001)
@@ -54,6 +54,14 @@
@discussion This class represents a single instance of the MacPorts installation system on a user's machine.
There is usually only one instance of this per machine, even though there might be more than one in some
cases.
+
+ Available Delegate methods:
+ Delegates of this class may choose to implement one of the following method
+ - (AuthorizationRef) getAuthorizationRef;
+ getAuthorizationRef should return an AuthorizationRef structure which will be used for
+ performing privileged MacPorts operations. Framework clients should do all necessary preauthorization
+ before returning the AuthorizationRef structure, in addition, Framework clients are
+ responsible for freeing the memory associated with the passed AuthorizationRef structure.
*/
@interface MPMacPorts : NSObject {
@@ -63,6 +71,8 @@
NSArray *sources;
NSString *version;
+ id macportsDelegate;
+
}
/*!
@@ -173,6 +183,22 @@
- (NSString *)version;
+/*!
+ @brief Returns the delegate for this MPMacPorts object
+ @Discussion Delegates of MPMacPorts may opt to implement -setAuthoriztionRef: .
+ See (add link here to class discussion section) for more details.
+ */
+- (id)delegate;
+
+/*!
+ @brief Sets the delegate for this MPMacPorts object
+ @param mpDelegate The object to be set as the delegate
+ @Discussion Delegates of MPMacPorts may opt to implement -setAuthoriztionRef: .
+ See (add link here to class discussion section) for more details.
+ */
+- (void)setDelegate:(id)delegate;
+
+
//Notifications stuff for private use and testing purposes
-(void)registerForLocalNotifications;
-(void)respondToLocalNotification:(NSNotification *) notification;
Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m 2008-08-05 23:40:20 UTC (rev 39001)
@@ -110,11 +110,11 @@
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSyncStarted" object:nil];
[[MPNotifications sharedListener] setPerformingTclCommand:@"YES_sync"];
- //result = [interpreter evaluateStringAsString:@"mportsync" error:sError];
+ result = [interpreter evaluateStringAsString:@"mportsync" error:sError];
//Testing DO implementation
//result = [interpreter evaluateStringWithMPHelperTool:@"mportsync"];
- [interpreter evaluateStringWithSimpleMPDOPHelperTool:@"mportsync"];
+ //[interpreter evaluateStringWithSimpleMPDOPHelperTool:@"mportsync"];
result = [interpreter getTclCommandResult];
@@ -248,12 +248,38 @@
return version;
}
+#pragma mark -
+#pragma mark Delegate Methods
+
+-(id) delegate {
+ return macportsDelegate;
+}
+
+-(void) setDelegate:(id)delegate {
+ [delegate retain];
+ [macportsDelegate release];
+ macportsDelegate = delegate;
+}
+
+//Internal Method for setting our Authorization Reference
+- (void) setAuthorizationRef {
+ if ([[self delegate] respondsToSelector:@selector(getAuthorizationRef)]) {
+ [interpreter setAuthorizationRef:
+ [[self delegate] performSelector:@selector(getAuthorizationRef)]];
+ }
+ //else { //I think i'll iniitalizeAuthorization lazily .. i.e. right
+ //before using helper tool
+// [interpreter initializeAuthorization];
+// }
+}
+
+#pragma mark -
#pragma mark Testing MacPorts Notifications
-(void) registerForLocalNotifications {
- //[[NSNotificationCenter defaultCenter] addObserver:self
-// selector:@selector(respondToLocalNotification:)
-// name:MPINFO
-// object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(respondToLocalNotification:)
+ name:MPINFO
+ object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(respondToLocalNotification:)
Modified: branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MPNotifications.h 2008-08-05 23:40:20 UTC (rev 39001)
@@ -39,6 +39,14 @@
sent to Framework clients. The following constants MPMSG, MPINFO, MPWARN, MPERROR, MPDEBUG
define the names of notifications that Framework clients can register for.
+ The posted notificaion's userInfo dictionary contains the following keys and values
+ MPNOTIFICATION_NAME - The name of the notification e.g. MPWARN, MPDEBUG etc.
+ MPCHANNEL - The channel to which the message was logged eg. stdout, stderr
+ MPPREFIX - The prefix string for this message e.g. DEBUG:
+ MPMETHOD - The method whose execution led to this notification eg. sync, selfupdate
+ MPMESSAGE - The output message logged to channel
+
+
THERE IS A REASON I'M NOT INCLUDING MPALL AS ONE OF THE POSSIBLE NOTIFICATIONS TO REGISTER FOR.
HOW IS THE FRAMEWORK SUPPOSE TO KNOW THAT SOMEONE HAS REGISTERED FOR ALL NOTIFICATIONS? THE ONLY
WAY TO DO THAT THAT I CAN SEE IS FORCING CLIENTS TO USE A CUSTOM METHOD (THAT UPDATES SOME
Modified: branches/gsoc08-framework/MacPorts_Framework/MPNotifications.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPNotifications.m 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MPNotifications.m 2008-08-05 23:40:20 UTC (rev 39001)
@@ -84,7 +84,7 @@
blockOptions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:0], MPMSG, [NSNumber numberWithInt:0], MPINFO,
[NSNumber numberWithInt:0], MPWARN, [NSNumber numberWithInt:0], MPERROR,
- [NSNumber numberWithInt:1], MPDEBUG, [NSNumber numberWithInt:0], MPALL, nil];
+ [NSNumber numberWithInt:0], MPDEBUG, [NSNumber numberWithInt:0], MPALL, nil];
//NSLog(@"Dictionary is %@ ", [blockOptions description]);
}
return self;
Modified: branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2008-08-05 23:40:20 UTC (rev 39001)
@@ -68,6 +68,7 @@
6ECD97180E465CB300488335 /* MPInterpreterProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EB6FC690E45AC610057962C /* MPInterpreterProtocol.h */; };
6ECD973F0E465F6A00488335 /* SimpleDOMPHelperTool in Resources */ = {isa = PBXBuildFile; fileRef = 6ECD97050E465C0F00488335 /* SimpleDOMPHelperTool */; };
6ECD98110E484E8400488335 /* MPHelperTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ECD98100E484E8400488335 /* MPHelperTool.m */; };
+ 6ECD99C60E48B91B00488335 /* MPHelperToolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ECD99C50E48B91B00488335 /* MPHelperToolTest.m */; };
6ED12A550E3E55DF0026773D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ED12A540E3E55DF0026773D /* Security.framework */; };
6ED12A560E3E55DF0026773D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ED12A540E3E55DF0026773D /* Security.framework */; };
6ED12AF10E3E9E210026773D /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
@@ -157,6 +158,8 @@
6ECD97050E465C0F00488335 /* SimpleDOMPHelperTool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SimpleDOMPHelperTool; sourceTree = BUILT_PRODUCTS_DIR; };
6ECD970D0E465C7800488335 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
6ECD98100E484E8400488335 /* MPHelperTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPHelperTool.m; sourceTree = "<group>"; };
+ 6ECD99C40E48B91B00488335 /* MPHelperToolTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPHelperToolTest.h; sourceTree = "<group>"; };
+ 6ECD99C50E48B91B00488335 /* MPHelperToolTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPHelperToolTest.m; sourceTree = "<group>"; };
6ED12A4A0E3E552F0026773D /* MPHelperTool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPHelperTool; sourceTree = BUILT_PRODUCTS_DIR; };
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; };
@@ -336,6 +339,8 @@
489DD92E0C94674B00595506 /* MPInterpreterTest.m */,
6E88D1CA0DF4B90B00684E9F /* MPMacPortsTest.h */,
6E88D1CB0DF4B90B00684E9F /* MPMacPortsTest.m */,
+ 6ECD99C40E48B91B00488335 /* MPHelperToolTest.h */,
+ 6ECD99C50E48B91B00488335 /* MPHelperToolTest.m */,
);
name = Tests;
sourceTree = "<group>";
@@ -606,6 +611,7 @@
files = (
6EA294590E080DEB00902D12 /* MPMacPortsTest.m in Sources */,
6E49F37B0DFFAB0B0030C3AF /* MPInterpreterTest.m in Sources */,
+ 6ECD99C60E48B91B00488335 /* MPHelperToolTest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: branches/gsoc08-framework/MacPorts_Framework/SimpleDOMPHelperTool.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/SimpleDOMPHelperTool.m (rev 0)
+++ branches/gsoc08-framework/MacPorts_Framework/SimpleDOMPHelperTool.m 2008-08-05 23:40:20 UTC (rev 39001)
@@ -0,0 +1,39 @@
+//
+// SimpleDOMPHelperTool.m
+// MacPorts.Framework
+//
+// Created by George Armah on 8/3/08.
+// Copyright 2008 Lafayette College. All rights reserved.
+//
+
+
+
+#import <Foundation/Foundation.h>
+#import "MPInterpreterProtocol.h"
+
+int main(int argc, char const * argv[]) {
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ NSString * tclCmd;
+
+ id distObj = [NSConnection
+ rootProxyForConnectionWithRegisteredName:MP_DOSERVER
+ host:nil];
+ [distObj setProtocolForProxy:@protocol(MPInterpreterProtocol)];
+
+ //[distObj log:[NSString stringWithFormat:
+// @"Number of arguments are %u", argc]];
+// [distObj log:[NSString stringWithFormat:
+// @"Arguments are %s and %s", argv[0], argv[1]]];
+//
+// [distObj log:@"Getting tclCmd"];
+ tclCmd = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding];
+ //[distObj log:[NSString stringWithFormat:
+// @"tclCmd is %@", tclCmd]];
+ NSString * result = [distObj evaluateStringFromMPHelperTool:tclCmd];
+
+ [distObj setTclCommandResult:result];
+
+ [pool release];
+
+ return 0;
+}
\ No newline at end of file
Property changes on: branches/gsoc08-framework/MacPorts_Framework/SimpleDOMPHelperTool.m
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: branches/gsoc08-framework/MacPorts_Framework/init.tcl
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/init.tcl 2008-08-05 20:25:51 UTC (rev 39000)
+++ branches/gsoc08-framework/MacPorts_Framework/init.tcl 2008-08-05 23:40:20 UTC (rev 39001)
@@ -85,7 +85,7 @@
#This is currently under works ... a reasonable solution
#should be coming up soon
proc ui_init {priority prefix channels message} {
- puts "INSIDE ui_init priority with prefix $prefix and message $message"
+ #puts "INSIDE ui_init priority with prefix $prefix and message $message"
switch $priority {
msg {
@@ -93,18 +93,18 @@
}
debug {
set "MPDebugNotification"
- #puts "Recieved Debug"
+ puts "Recieved Debug"
}
warn {
set nottype "MPWarnNotification"
}
error {
set nottype "MPErrorNotification"
- #puts "Recieved Error"
+ puts "Recieved Error"
}
info {
set nottype "MPInfoNotification"
- #puts "Recieved Info"
+ puts "Recieved Info"
}
default {
set nottype "MPDefaultNotification"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080805/28277266/attachment-0001.html
More information about the macports-changes
mailing list