Skip to content

Commit

Permalink
Fixed NC bug, added cancel download
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Oelgart committed Nov 7, 2013
1 parent b09f8b5 commit ac9f5d1
Show file tree
Hide file tree
Showing 10 changed files with 382 additions and 259 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@
[submodule "PutioKit"]
path = PutioKit
url = git@github.com:PutioKit/PutioKit.git
[submodule "UIView-Badge"]
path = UIView-Badge
url = git@github.com:robrasmussen/UIView-Badge.git
Binary file not shown.
10 changes: 7 additions & 3 deletions put.io adder/PutioHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ - (void)updateUserInfo
newTransfer = (PKTransfer*)[putioTransfers objectAtIndex:j];

if ((currentTransfer.id == newTransfer.id) &&
(![currentTransfer.status isEqualToString:@"COMPLETED"] &&
((![currentTransfer.status isEqualToString:@"COMPLETED"] &&
![currentTransfer.status isEqualToString:@"SEEDING"])
&&
([newTransfer.status isEqualToString:@"COMPLETED"]
|| [newTransfer.status isEqualToString:@"SEEDING"])))
{
Expand All @@ -110,10 +112,12 @@ - (void)updateUserInfo
notification.soundName = NSUserNotificationDefaultSoundName;

[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];

// [NSImageView alloc] ini
/*
NSImage *badge = [[NSImage alloc] initWithSize:NSSizeFromCGSize(CGSizeMake(20, 20))];
badge.backgroundColor = [NSColor redColor];
[NSApp setApplicationIconImage: badge];
//[NSApp setApplicationIconImage: badge];
*/
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions put.io adder/PutioMainController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
IBOutlet NSPanel *prefSheet;
IBOutlet NSTableView *tableView;
IBOutlet NSButton *toggleShowTransfers;
IBOutlet NSButton *cancelTransfer;

PutioBrowser *authWindow;
NSMutableArray *transfers;
Expand All @@ -31,6 +32,7 @@
- (IBAction)closePreferences:(id)sender;
- (IBAction)checkForUpdates:(id)sender;
- (IBAction)toggleShowTransfers:(id)sender;
- (IBAction)cancelTransfer:(id)sender;
- (void)openFileOnPutIO;

@property (nonatomic, retain) NSTextField *message;
Expand All @@ -41,6 +43,7 @@
@property (assign) IBOutlet NSWindow *putiowindow;
@property (nonatomic, retain) IBOutlet NSTableView *tableView;
@property (nonatomic, retain) IBOutlet NSButton *toggleShowTransfers;
@property (nonatomic, retain) IBOutlet NSButton *cancelTransfer;

@property (strong) PutioBrowser *authWindow;
@property (strong) NSMutableArray *transfers;
Expand Down
72 changes: 62 additions & 10 deletions put.io adder/PutioMainController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
@implementation PutioMainController

@synthesize
message,
activityIndicator,
authWindow,
userInfo,
versionInfo,
transferInfo,
putiowindow,
transfers,
tableView,
toggleShowTransfers;
message,
activityIndicator,
authWindow,
userInfo,
versionInfo,
transferInfo,
putiowindow,
transfers,
tableView,
toggleShowTransfers,
cancelTransfer;

static BOOL transfersAreHidden = YES;

Expand All @@ -40,6 +41,7 @@ - (void)awakeFromNib
self.toggleShowTransfers.title = NSLocalizedString(@"HELPER_TRANSFERS_SHOW", nil);
self.userInfo.stringValue = NSLocalizedString(@"HELPER_FETCHING_USERINFO", nil);
self.message.stringValue = NSLocalizedString(@"HELPER_MSG_READY", nil);
self.cancelTransfer.stringValue = NSLocalizedString(@"HELPER_CANCEL", nil);

PutioHelper *helper = [PutioHelper sharedHelper];
[helper authenticateUser];
Expand Down Expand Up @@ -183,6 +185,56 @@ - (void)tableView:(NSTableView *)_tableView sortDescriptorsDidChange: (NSArray *
}


- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
[self.cancelTransfer setHidden: (self.tableView.selectedRow > -1 ? NO : YES)];
}


- (IBAction)cancelTransfer:(id)sender
{
if (self.tableView.selectedRow == -1)
{
return;
}

PKTransfer *transfer;

@try
{
transfer = [self.transfers objectAtIndex: [self.tableView selectedRow]];
}
@catch (NSException *exception)
{
return;
}
@finally {}

self.message.stringValue = NSLocalizedString(@"HELPER_CANCELING_DOWNLOAD", nil);
[self.activityIndicator startAnimation:nil];
[self.cancelTransfer setEnabled:NO];

PutioHelper *helper = [PutioHelper sharedHelper];

[[helper putioAPI] cancelTransfer:transfer:^
{
self.message.stringValue = NSLocalizedString(@"HELPER_DOWNLOAD_CANCELED", nil);
[self.activityIndicator stopAnimation:nil];
[self.cancelTransfer setEnabled:YES];
[self.cancelTransfer setHidden:YES];

[helper updateUserInfo];
}
failure:^(NSError *error)
{
self.message.stringValue = NSLocalizedString(@"HELPER_CANCEL_FAILED", nil);
[self.activityIndicator stopAnimation:nil];
[self.cancelTransfer setEnabled:YES];
[self.cancelTransfer setHidden:YES];
}];
}


- (void)openFileOnPutIO
{
// Table header was clicked
Expand Down
9 changes: 8 additions & 1 deletion put.io adder/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ HELPER_STATE_SEEDING="Fertig/Seeding...";
HELPER_STATE_QUEDED="In Warteschlange";

HELPER_TRANSFERS_SHOW="Transfers Anzeigen";
HELPER_TRANSFERS_HIDE="Transfers Verbergen";
HELPER_TRANSFERS_HIDE="Transfers Verbergen";

HELPER_CANCELING_DOWNLOAD="Download wird Abgebrochen...";
HELPER_DOWNLOAD_CANCELED="Download Abgebrochen";
HELPER_CANCEL_FAILED="Download konnte nicht abgrbrochen werden";

NOTIFICATION_TITLE="Erfolgreicher Download";
NOTIFICATION_MSG="\"%@\" Wurde Erfolgreich Heruntergeladen";
4 changes: 4 additions & 0 deletions put.io adder/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ HELPER_STATE_QUEDED="In Queue";
HELPER_TRANSFERS_SHOW="Show Transfers";
HELPER_TRANSFERS_HIDE="Hide Transfers";

HELPER_CANCELING_DOWNLOAD="Canceling Download...";
HELPER_DOWNLOAD_CANCELED="Download Canceled";
HELPER_CANCEL_FAILED="Error Canceling Download";

NOTIFICATION_TITLE="Finished Download";
NOTIFICATION_MSG="\"%@\" finished downloading";
Loading

0 comments on commit ac9f5d1

Please sign in to comment.