Files
pallet/Pallet/MPActionLauncher.m
T
Juan Germán Castañeda Echevarría fcff5ee4e9 Copying Pallet from gsoc09-gui branch to contrib
git-svn-id: https://svn.macports.org/repository/macports/contrib/Pallet@65496 d073be05-634f-4543-b044-5fe20cf6d1d6
2010-03-26 21:20:39 +00:00

82 lines
1.9 KiB
Objective-C

//
// MPActionLauncher.m
// MPGUI
//
// Created by Juan Germán Castañeda Echevarría on 6/15/09.
// Copyright 2009 UNAM. All rights reserved.
//
#import "MPActionLauncher.h"
static MPActionLauncher *sharedActionLauncher = nil;
#pragma mark Implementation
@implementation MPActionLauncher
@synthesize ports, isLoading, actionTool;
+ (MPActionLauncher*) sharedInstance {
if (sharedActionLauncher == nil) {
[[self alloc] init]; // assignment not done here
}
return sharedActionLauncher;
}
- (id)init {
if (sharedActionLauncher == nil) {
ports = [NSMutableArray arrayWithCapacity:1];
sharedActionLauncher = self;
}
return sharedActionLauncher;
}
- (void)loadPorts {
[self setIsLoading:YES];
NSDictionary *allPorts = [[MPMacPorts sharedInstance] search:MPPortsAll];
NSDictionary *installedPorts = [[MPRegistry sharedRegistry] installed];
[self willChangeValueForKey:@"ports"];
for (id port in installedPorts) {
[[allPorts objectForKey:port] setStateFromReceipts:[installedPorts objectForKey:port]];
}
ports = [allPorts allValues];
[self didChangeValueForKey:@"ports"];
[self setIsLoading:NO];
}
- (void)installPort:(MPPort *)port {
NSError * error;
NSArray *empty = [NSArray arrayWithObject: @""];
[port installWithOptions:empty variants:empty error:&error];
}
- (void)uninstallPort:(MPPort *)port {
NSError * error;
[port uninstallWithVersion:@"" error:&error];
}
- (void)upgradePort:(MPPort *)port {
NSError * error;
[port upgradeWithError:&error];
}
- (void)sync {
NSError * error;
[[MPMacPorts sharedInstance] sync:&error];
}
- (void)selfupdate {
NSError * error;
[[MPMacPorts sharedInstance] selfUpdate:&error];
}
- (void)cancelPortProcess {
// TODO: display confirmation dialog
[[MPMacPorts sharedInstance] cancelCurrentCommand];
}
@end