[53688] branches/gsoc09-gui/MacPorts_Framework
juanger at macports.org
juanger at macports.org
Sat Jul 11 15:20:45 PDT 2009
Revision: 53688
http://trac.macports.org/changeset/53688
Author: juanger at macports.org
Date: 2009-07-11 15:20:44 -0700 (Sat, 11 Jul 2009)
Log Message:
-----------
Adding portProcessInit.tcl
Modified Paths:
--------------
branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
Added Paths:
-----------
branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl
Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m 2009-07-11 22:13:39 UTC (rev 53687)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m 2009-07-11 22:20:44 UTC (rev 53688)
@@ -56,6 +56,8 @@
@end
int main(int argc, char const * argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
NSConnection *portProcessConnection;
portProcessConnection = [NSConnection defaultConnection];
NSString *PKGPath = [[NSString alloc] initWithCString:argv[1] encoding:NSUTF8StringEncoding];
@@ -77,5 +79,6 @@
// Wait for any message
[[NSRunLoop currentRunLoop] run];
+ [pool release];
return 0;
}
\ No newline at end of file
Modified: branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2009-07-11 22:13:39 UTC (rev 53687)
+++ branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2009-07-11 22:20:44 UTC (rev 53688)
@@ -24,6 +24,7 @@
21D95442100940FF00DEF58A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EB6FC900E45DEA80057962C /* Foundation.framework */; };
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 */; };
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, ); }; };
@@ -129,6 +130,7 @@
21D9543E100940EE00DEF58A /* MPPortProcess */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MPPortProcess; path = build/Release/MPPortProcess; sourceTree = "<group>"; };
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>"; };
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>"; };
@@ -305,6 +307,7 @@
489DD8F50C94365F00595506 /* Test-Info.plist */,
6E44A00C0E2DAD66007DE8EC /* ToDo.txt */,
6EE93E660E493AC600AECE9E /* interpInit.tcl */,
+ 21D954711009475200DEF58A /* portProcessInit.tcl */,
);
name = Resources;
sourceTree = "<group>";
@@ -625,6 +628,7 @@
48E9939F0C82CEB000219DDF /* init.tcl in Resources */,
6E44A00D0E2DAD66007DE8EC /* ToDo.txt in Resources */,
6EE93E670E493AC600AECE9E /* interpInit.tcl in Resources */,
+ 21D954721009475200DEF58A /* portProcessInit.tcl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl (rev 0)
+++ branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl 2009-07-11 22:20:44 UTC (rev 53688)
@@ -0,0 +1,212 @@
+package require macports
+#package require notifications Require My new notifications extension
+
+
+#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"
+set ui_options(ports_verbose) "yes"
+
+# ui_options accessor
+proc ui_isset {val} {
+ global ui_options
+ if {[info exists ui_options($val)]} {
+ if {$ui_options($val) == "yes"} {
+ return 1
+ }
+ }
+ 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.
+proc mportuninstall {portname {v ""} {optionslist ""}} {
+ if {[catch {portuninstall::uninstall $portname $v $optionslist} result]} {
+
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Uninstall $portname $v failed: $result"
+ return 1
+ }
+}
+
+proc mportactivate {portname v optionslist} {
+ if {[catch {portimage::activate $portname $v $optionslist} result]} {
+
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Activate $portname $v failed: $result"
+ return 1
+ }
+}
+
+proc mportdeactivate {portname v optionslist} {
+ if {[catch {portimage::deactivate $portname $v $optionslist} result]} {
+
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Deactivate $portname $v failed: $result"
+ return 1
+ }
+}
+
+proc mportupgrade {portname} {
+ array set depscache {}
+ if {[catch {macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options] depscache} result]} {
+
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Upgrade $portname failed: $result"
+ return 1
+ }
+}
+
+
+# Initialize dport
+# This must be done following parse of global options, as some options are
+# evaluated by dportinit.
+if {[catch {mportinit ui_options global_options global_variations} result]} {
+ global errorInfo
+ puts "$errorInfo"
+ fatal "Failed to initialize ports system, $result"
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090711/53bb0333/attachment.html>
More information about the macports-changes
mailing list