[38103] branches/gsoc08-framework/MacPorts.Framework
armahg at macports.org
armahg at macports.org
Sun Jul 6 10:44:41 PDT 2008
Revision: 38103
http://trac.macosforge.org/projects/macports/changeset/38103
Author: armahg at macports.org
Date: 2008-07-06 10:44:41 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
Added -selfupdate to MPMacPorts class. Updated notifications code
Modified Paths:
--------------
branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h
branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.m
branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m
branches/gsoc08-framework/MacPorts.Framework/init.tcl
branches/gsoc08-framework/MacPorts.Framework/notifications.m
Modified: branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h
===================================================================
--- branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h 2008-07-06 16:43:33 UTC (rev 38102)
+++ branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h 2008-07-06 17:44:41 UTC (rev 38103)
@@ -73,6 +73,11 @@
@brief Synchronizes the ports tree without checking for upgrades to the MacPorts base.
*/
- (void)sync;
+/*!
+ @brief Synchronizes the ports tree and checks for upgrades to MacPorts base.
+ @discussion The selfupdate port command is available only on Mac OS X systems.s
+ */
+- (void)selfUpdate;
Modified: branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.m
===================================================================
--- branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.m 2008-07-06 16:43:33 UTC (rev 38102)
+++ branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.m 2008-07-06 17:44:41 UTC (rev 38103)
@@ -93,6 +93,14 @@
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSyncFinished" object:nil];
}
+- (void)selfUpdate {
+ //Also needs to throw an exception if things don't go well
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSelfupdateStarted" object:nil];
+ [interpreter evaluateStringAsString:@"macports::selfupdate"];
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSelfupdateFinished" object:nil];
+}
+
+
- (NSDictionary *)search:(NSString *)query {
return [self search:query caseSensitive:YES];
}
Modified: branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m
===================================================================
--- branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m 2008-07-06 16:43:33 UTC (rev 38102)
+++ branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m 2008-07-06 17:44:41 UTC (rev 38103)
@@ -87,7 +87,12 @@
}
-
+-(void) testSelfupdate {
+ //The only way to test this that I know of is to listen for the posted notifications
+ //and take actions as appropriate
+ [testPort selfUpdate];
+
+}
-(void) listenForPortSync {
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(actOnPortSync:)
Modified: branches/gsoc08-framework/MacPorts.Framework/init.tcl
===================================================================
--- branches/gsoc08-framework/MacPorts.Framework/init.tcl 2008-07-06 16:43:33 UTC (rev 38102)
+++ branches/gsoc08-framework/MacPorts.Framework/init.tcl 2008-07-06 17:44:41 UTC (rev 38103)
@@ -74,9 +74,11 @@
#Modifying UI initialization to enable notifications
proc ui_init {priority prefix channels message} {
-
+
+ set t "duna"
#notifications send global "MP $message Notification" "INSIDE UI_INIT"
- notifications send MPpriorityNotification "INSIDE UI_INIT"
+ notifications send global "MP $priority Notification" "Channel none \
+ Prefix $prefix" $message
# Get the list of channels.
try {
@@ -90,7 +92,8 @@
if {$nbchans == 0} {
proc ::ui_$priority {str}
[
- notifications send global "MP $priority Notification" $message ]
+ notifications send global "MP $priority Notification1" "Channel none \
+ Prefix $prefix" $str ]
} else {
try {
set prefix [ui_prefix $priority]
@@ -108,7 +111,8 @@
#Send notifications using NSDistributedNotificationCenter for now
#We need a way to name notifications based on given input, using
#testMacPortsNotification for now
- notifications send global "MP $priority Notification" $message
+ notifications send global "MP $priority Notification2" "Channel $chan \
+ Prefix $prefix" "$str"
]
@@ -120,7 +124,8 @@
}
}
#Should we discriminate based on channel?
- notifications send global "MP $priority Notification" $message
+ notifications send global "MP $priority Notification3" "Channel $chan \
+ Prefix $prefix" $str
]
}
Modified: branches/gsoc08-framework/MacPorts.Framework/notifications.m
===================================================================
--- branches/gsoc08-framework/MacPorts.Framework/notifications.m 2008-07-06 16:43:33 UTC (rev 38102)
+++ branches/gsoc08-framework/MacPorts.Framework/notifications.m 2008-07-06 17:44:41 UTC (rev 38103)
@@ -53,31 +53,37 @@
tclResult = Tcl_SplitList(interpreter, Tcl_GetString(*objv), &tclCount, &tclElements);
if (tclResult == TCL_OK) {
- //For now we return a single element dictionary containing the ui_* log message
+ /*/For now we return a single element dictionary containing the ui_* log message
info = [NSMutableDictionary dictionaryWithCapacity:1];
- [info setObject:[NSString stringWithUTF8String:Tcl_GetString(*objv)] forKey:[NSString stringWithString:@"ui_msg"]];
+ [info setObject:[NSString stringWithUTF8String:Tcl_GetString(*objv)] forKey:[NSString stringWithString:@"ui_notification"]];
//Afaik local notifications don't work. I'm keeping code for it in case we find a work around
if (global != 0) {
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:info];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:info];
- }
+ }*/
- /*
- I don't understand what Randall's original intent was for parsing the ui_msg as an NSDictionary.
- I'll keep this code here till further notice.
+
+ //I don't understand what Randall's original intent was for parsing the ui_msg as an NSDictionary.
+ //I'll keep this code here till further notice.
info = [NSMutableDictionary dictionaryWithCapacity:(tclCount / 2)];
for (i = 0; i < tclCount; i +=2) {
- [info setObject:[NSString stringWithUTF8String:tclElements[i + 1]] forKey:[NSString stringWithUTF8String:tclElements[i]]];
+ [info setObject:[NSString stringWithUTF8String:tclElements[i + 1]] forKey:[NSString stringWithUTF8String:tclElements[i]]];
}
+
+ //Get ui_* message separately
+ ++objv; --objc;
+ if(objv != NULL)
+ [info setObject:[NSString stringWithUTF8String:Tcl_GetString(*objv)] forKey:[NSString stringWithString:@"Message"]];
+
if (global != 0) {
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:info];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:info];
- }*/
+ }
} else {
return TCL_ERROR;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080706/cb87ed77/attachment.html
More information about the macports-changes
mailing list