Changeset 54152


Ignore:
Timestamp:
Jul 22, 2009, 1:06:12 AM (10 years ago)
Author:
juanger@…
Message:

New Notifications for MPPortProcess

Location:
branches/gsoc09-gui/MacPorts_Framework
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc09-gui/MacPorts_Framework/MPInterpreter.m

    r53735 r54152  
    459459        NSString * secondResult;
    460460       
    461         *mportError = nil;
    462     //  firstResult = [self evaluateStringAsString:statement error:mportError];
    463         firstResult = [self evaluateStringWithMPPortProcess:statement error:mportError];
     461        //*mportError = nil;
     462        //firstResult = [self evaluateStringWithMPPortProcess:statement error:mportError];
    464463       
    465464        //Because of string results of methods like mportsync (which returns the empty string)
     
    468467        //the helper tool
    469468       
    470         if ( *mportError != nil) {
     469        //if ( *mportError != nil) {
    471470                *mportError = nil;
    472471                secondResult = [self evaluateStringWithMPHelperTool:statement error:mportError];
    473472               
    474473                return secondResult;
    475         }
    476        
    477         return firstResult;
     474        //}
     475       
     476        //return firstResult;
    478477}
    479478
  • branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m

    r53735 r54152  
    88
    99#import "MPPortProcess.h"
     10#import "SimpleLog.h"
    1011
    1112@interface MPPortProcess (PrivateMethods)
     
    2223    [self initializeInterpreter];
    2324    return self;
     25}
     26
     27- (oneway void)setDelegate:(byref id)newDelegate {
     28    delegate = newDelegate;
    2429}
    2530
     
    5055                Tcl_DeleteInterp(interpreter);
    5156        }
    52     // TODO Load notifications methods
    53    
     57    // Load notifications methods
     58    Tcl_CreateObjCommand(interpreter, "simplelog", Notify_Command, NULL, NULL);
     59        if (Tcl_PkgProvide(interpreter, "simplelog", "1.0") != TCL_OK) {
     60                NSLog(@"Error in Tcl_PkgProvide: %s", Tcl_GetStringResult(interpreter));
     61        }
    5462    // Load portProcessInit.tcl
    5563    NSString *portProcessInitPath = @"portProcessInit.tcl";
  • branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj

    r53717 r54152  
    2222
    2323/* Begin PBXBuildFile section */
     24                218DEE2610162091003B5A3B /* SimpleLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 218DED83101612F1003B5A3B /* SimpleLog.m */; };
     25                218DEE3E10162157003B5A3B /* SimpleLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 218DED82101612F1003B5A3B /* SimpleLog.h */; };
    2426                21D95442100940FF00DEF58A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EB6FC900E45DEA80057962C /* Foundation.framework */; };
    2527                21D954431009411400DEF58A /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
     
    129131                1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
    130132                21067BB50FE5B25800CAD732 /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
     133                218DED82101612F1003B5A3B /* SimpleLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLog.h; sourceTree = "<group>"; };
     134                218DED83101612F1003B5A3B /* SimpleLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleLog.m; sourceTree = "<group>"; };
    131135                21D9543E100940EE00DEF58A /* MPPortProcess */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MPPortProcess; sourceTree = BUILT_PRODUCTS_DIR; };
    132136                21D954461009412F00DEF58A /* MPPortProcess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPortProcess.m; sourceTree = "<group>"; };
     
    188192                6EE6DDCC0E6276AA00FB2115 /* MPNotifications+IPCAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MPNotifications+IPCAdditions.h"; sourceTree = "<group>"; };
    189193                6EE6DDCD0E6276AA00FB2115 /* MPNotifications+IPCAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPNotifications+IPCAdditions.m"; sourceTree = "<group>"; };
    190                 6EE93E660E493AC600AECE9E /* interpInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = interpInit.tcl; sourceTree = "<group>"; };
     194                6EE93E660E493AC600AECE9E /* interpInit.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = interpInit.tcl; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.simpleColoring; };
    191195                6EE93E780E495B3100AECE9E /* Tcl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tcl.framework; path = Library/Frameworks/Tcl.framework; sourceTree = SDKROOT; };
    192196                8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
     
    358362                                21D954491009413800DEF58A /* MPPortProcess.h */,
    359363                                21D954461009412F00DEF58A /* MPPortProcess.m */,
     364                                218DED82101612F1003B5A3B /* SimpleLog.h */,
     365                                218DED83101612F1003B5A3B /* SimpleLog.m */,
    360366                        );
    361367                        name = MPPortProcess;
     
    434440
    435441/* Begin PBXHeadersBuildPhase section */
     442                218DEE4010162175003B5A3B /* Headers */ = {
     443                        isa = PBXHeadersBuildPhase;
     444                        buildActionMask = 2147483647;
     445                        files = (
     446                                218DEE3E10162157003B5A3B /* SimpleLog.h in Headers */,
     447                        );
     448                        runOnlyForDeploymentPostprocessing = 0;
     449                };
    436450                6ED12AD30E3E9AE10026773D /* Headers */ = {
    437451                        isa = PBXHeadersBuildPhase;
     
    473487                        buildConfigurationList = 21D954481009413000DEF58A /* Build configuration list for PBXNativeTarget "MPPortProcess" */;
    474488                        buildPhases = (
     489                                218DEE4010162175003B5A3B /* Headers */,
    475490                                21D9543B100940EE00DEF58A /* Sources */,
    476491                                21D9543C100940EE00DEF58A /* Frameworks */,
     
    686701                        files = (
    687702                                21D954471009412F00DEF58A /* MPPortProcess.m in Sources */,
     703                                218DEE2610162091003B5A3B /* SimpleLog.m in Sources */,
    688704                        );
    689705                        runOnlyForDeploymentPostprocessing = 0;
  • branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl

    r53692 r54152  
    11package require macports
    2 #package require notifications Require My new notifications extension
    3 
     2package require simplelog #Require My new notifications extension
    43
    54#Set ui_options to log all messages to stdout and notify system
     
    1716        }
    1817        return 0
     18}
     19
     20# UI Callback
     21proc ui_prefix {priority} {
     22    switch $priority {
     23        debug {
     24                return "DEBUG: "
     25        }
     26        error {
     27                return "Error: "
     28        }
     29        warn {
     30                return "Warning: "
     31        }
     32        default {
     33                return ""
     34        }
     35    }
     36}
     37
     38proc ui_channels {priority} {
     39    global logfd
     40    switch $priority {
     41        debug {
     42            if {[ui_isset ports_debug]} {
     43                return {stderr}
     44            } else {
     45                return {}
     46            }
     47        }
     48        info {
     49            if {[ui_isset ports_verbose]} {
     50                return {stdout}
     51            } else {
     52                return {}
     53                        }
     54                }
     55        msg {
     56            if {[ui_isset ports_quiet]} {
     57                return {}
     58                        } else {
     59                                return {stdout}
     60                        }
     61                }
     62        error {
     63                return {stderr}
     64        }
     65        default {
     66                return {stdout}
     67        }
     68    }
     69}
     70
     71
     72
     73#Modifying UI initialization to enable notifications
     74#Redefine ui_$pritority to throw global notifications
     75#This is currently under works ... a reasonable solution
     76#should be coming up soon
     77proc ui_init {priority prefix channels message} {
     78        #puts "INSIDE ui_init priority with prefix $prefix and message $message"
     79       
     80    # Get the list of channels.
     81    try {
     82        set channels [ui_channels $priority]
     83    } catch * {
     84        set channels [ui_channels_default $priority]
     85    }
     86   
     87    #set channels [ui_channels $priority]
     88   
     89    # Simplify ui_$priority.
     90    set nbchans [llength $channels]
     91    if {$nbchans == 0} {
     92        proc ::ui_$priority {str} [subst {
     93                simplelog "$nottype $chan $prefix" "\$str"
     94        }]
     95    } else {
     96        try {
     97            set prefix [ui_prefix $priority]
     98        } catch * {
     99            set prefix [ui_prefix_default $priority]
     100        }
     101       
     102        #set prefix [ui_prefix $priority]
     103       
     104        if {$nbchans == 1} {
     105          set chan [lindex $channels 0]
     106
     107          proc ::ui_$priority {args} [subst {
     108            if {\[lindex \$args 0\] == "-nonewline"} {
     109              puts $chan "$prefix\[lindex \$args 1\]"
     110              simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
     111            } else {
     112              puts -nonewline $chan "$prefix\[lindex \$args 1\]"
     113              simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
     114            }
     115          }]
     116        } else {
     117          proc ::ui_$priority {args} [subst {
     118            foreach chan \$channels {
     119              if {\[lindex \$args 0\] == "-nonewline"} {
     120                puts $chan "$prefix\[lindex \$args 1\]"
     121                simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
     122              } else {
     123                puts -nonewline $chan "$prefix\[lindex \$args 1\]"
     124                simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
     125              }
     126            }
     127          }]
     128        }
     129
     130    # Call ui_$priority - Is this step necessary? Consult with Randall
     131    #::ui_$priority $message
     132    }
    19133}
    20134
Note: See TracChangeset for help on using the changeset viewer.