Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // PortsController.m
- // Porton
- //
- // Created by Juan Germán Castañeda Echevarría on 3/28/09.
- // Copyright 2009 UNAM. All rights reserved.
- //
- #import "PortsController.h"
- @implementation PortsController
- - (void)awakeFromNib
- {
- [self setLoaded:NO];
- [self setBusy:YES];
- }
- - (void)loadIndex
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [self setBusy:YES];
- portsIndex = [MPIndex new];
- NSArray *ports = [portsIndex ports];
- [portsList addObjects: ports];
- [self setLoaded:YES];
- [self setBusy:NO];
- [pool release];
- }
- - (void)install
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [self setBusy:YES];
- NSArray *ports = [portsList selectedObjects];
- for (int i = 0; i < [ports count]; i++) {
- NSError * error;
- MPPort * port = [ports objectAtIndex:i];
- [port installWithOptions:nil variants:nil error:&error];
- if (error != nil) {
- NSLog(@"\n\nInstallation of %@ failed with error %@", [port name], error);
- [[NSAlert alertWithMessageText:@"Port Installation Failed"
- defaultButton:@"OK"
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"Installation of %@ failed with error %@", [port name], error] runModal];
- } else {
- [port setState:MPPortStateInstalled];
- [[NSAlert alertWithMessageText:@"Port Installed"
- defaultButton:@"OK"
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"You have succesfully installed %@", [port name]] runModal];
- }
- }
- [self setMessage:@""];
- [self setBusy:NO];
- [pool release];
- }
- - (void)uninstall
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [self setBusy:YES];
- NSArray *ports = [portsList selectedObjects];
- for (int i = 0; i < [ports count]; i++) {
- NSError * error;
- MPPort * port = [ports objectAtIndex:i];
- [port uninstallWithVersion:nil error:&error];
- if (error != nil) {
- NSLog(@"\n\nUninstallation of %@ failed with error %@", [port name], error);
- } else {
- [port setState:MPPortStateNotInstalled];
- [[NSAlert alertWithMessageText:@"Port Uninstalled"
- defaultButton:@"OK"
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:@"You have succesfully uninstalled %@", [port name]] runModal];
- }
- }
- [self setMessage:@""];
- [self setBusy:NO];
- [pool release];
- }
- #pragma mark Bindings
- - (void)setLoaded:(BOOL)newLoaded
- {
- loaded = newLoaded;
- }
- - (BOOL)loaded
- {
- return loaded;
- }
- - (void)setBusy:(BOOL)newBusy
- {
- busy = newBusy;
- }
- - (BOOL)busy
- {
- return busy;
- }
- - (void)setMessage:(NSString*)newMsg
- {
- message = newMsg;
- }
- - (NSString*)message
- {
- return message;
- }
- @end
Add Comment
Please, Sign In to add comment