2006-01-12 17:43:21 +00:00
|
|
|
/******************************************************************************
|
2006-05-29 21:21:23 +00:00
|
|
|
* $Id$
|
|
|
|
*
|
2006-03-23 12:39:39 +00:00
|
|
|
* Copyright (c) 2005-2006 Transmission authors and contributors
|
2006-01-12 17:43:21 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2006-01-20 01:13:21 +00:00
|
|
|
#import <IOKit/IOMessage.h>
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
#import "Controller.h"
|
|
|
|
#import "Torrent.h"
|
|
|
|
#import "TorrentCell.h"
|
2006-06-06 18:05:57 +00:00
|
|
|
#import "TorrentTableView.h"
|
2006-01-20 01:13:21 +00:00
|
|
|
#import "StringAdditions.h"
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
#import <Sparkle/Sparkle.h>
|
2006-01-12 18:57:23 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
#define TOOLBAR_OPEN @"Toolbar Open"
|
|
|
|
#define TOOLBAR_REMOVE @"Toolbar Remove"
|
|
|
|
#define TOOLBAR_INFO @"Toolbar Info"
|
|
|
|
#define TOOLBAR_PAUSE_ALL @"Toolbar Pause All"
|
|
|
|
#define TOOLBAR_RESUME_ALL @"Toolbar Resume All"
|
|
|
|
#define TOOLBAR_PAUSE_SELECTED @"Toolbar Pause Selected"
|
|
|
|
#define TOOLBAR_RESUME_SELECTED @"Toolbar Resume Selected"
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-07-02 21:57:51 +00:00
|
|
|
#define TORRENT_TABLE_VIEW_DATA_TYPE @"TorrentTableViewDataType"
|
2006-07-02 21:05:51 +00:00
|
|
|
|
2006-06-18 03:40:11 +00:00
|
|
|
#define WEBSITE_URL @"http://transmission.m0k.org/"
|
|
|
|
#define FORUM_URL @"http://transmission.m0k.org/forum/"
|
2006-01-12 18:57:23 +00:00
|
|
|
|
|
|
|
#define GROWL_PATH @"/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app"
|
2006-01-12 18:29:20 +00:00
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
static void sleepCallBack(void * controller, io_service_t y,
|
|
|
|
natural_t messageType, void * messageArgument)
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
|
|
|
Controller * c = controller;
|
|
|
|
[c sleepCallBack: messageType argument: messageArgument];
|
|
|
|
}
|
|
|
|
|
2006-01-12 21:45:45 +00:00
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
@implementation Controller
|
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
- (id) init
|
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
fLib = tr_init();
|
|
|
|
fTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
|
2006-06-06 18:05:57 +00:00
|
|
|
fDefaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
fInfoController = [[InfoWindowController alloc] initWithWindowNibName: @"InfoWindow"];
|
|
|
|
fPrefsController = [[PrefsController alloc] initWithWindowNibName: @"PrefsWindow"];
|
2006-06-19 23:07:28 +00:00
|
|
|
fBadger = [[Badger alloc] init];
|
|
|
|
|
|
|
|
//check and register Growl if it is installed for this user or all users
|
|
|
|
NSFileManager * manager = [NSFileManager defaultManager];
|
|
|
|
fHasGrowl = [manager fileExistsAtPath: GROWL_PATH]
|
|
|
|
|| [manager fileExistsAtPath: [NSHomeDirectory() stringByAppendingPathComponent: GROWL_PATH]];
|
|
|
|
[self growlRegister];
|
2006-05-25 12:22:19 +00:00
|
|
|
}
|
2006-03-23 12:39:39 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
[fTorrents release];
|
2006-06-06 18:05:57 +00:00
|
|
|
[fToolbar release];
|
2006-05-25 12:22:19 +00:00
|
|
|
[fInfoController release];
|
2006-06-06 18:05:57 +00:00
|
|
|
[fBadger release];
|
|
|
|
[fSortType release];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
tr_close( fLib );
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
- (void) awakeFromNib
|
|
|
|
{
|
2006-06-16 03:45:12 +00:00
|
|
|
[fPrefsController setPrefs: fLib];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-20 19:20:36 +00:00
|
|
|
[fAdvancedBarItem setState: [fDefaults boolForKey: @"UseAdvancedBar"]];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
fToolbar = [[NSToolbar alloc] initWithIdentifier: @"Transmission Toolbar"];
|
|
|
|
[fToolbar setDelegate: self];
|
|
|
|
[fToolbar setAllowsUserCustomization: YES];
|
|
|
|
[fToolbar setAutosavesConfiguration: YES];
|
2006-01-12 18:57:23 +00:00
|
|
|
[fWindow setToolbar: fToolbar];
|
|
|
|
[fWindow setDelegate: self];
|
2006-05-01 00:15:18 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
//window min height
|
|
|
|
NSSize contentMinSize = [fWindow contentMinSize];
|
|
|
|
contentMinSize.height = [[fWindow contentView] frame].size.height - [fScrollView frame].size.height
|
|
|
|
+ [fTableView rowHeight] + [fTableView intercellSpacing].height;
|
|
|
|
[fWindow setContentMinSize: contentMinSize];
|
|
|
|
|
|
|
|
//set info keyboard shortcuts
|
|
|
|
unichar ch = NSRightArrowFunctionKey;
|
|
|
|
[fNextInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & ch length: 1]];
|
|
|
|
ch = NSLeftArrowFunctionKey;
|
|
|
|
[fPrevInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & ch length: 1]];
|
|
|
|
|
|
|
|
//set up status bar
|
|
|
|
NSRect statusBarFrame = [fStatusBar frame];
|
|
|
|
statusBarFrame.size.width = [fWindow frame].size.width;
|
|
|
|
[fStatusBar setFrame: statusBarFrame];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
NSView * contentView = [fWindow contentView];
|
|
|
|
[contentView addSubview: fStatusBar];
|
2006-07-01 21:34:53 +00:00
|
|
|
[fStatusBar setFrameOrigin: NSMakePoint(0, [fScrollView frame].origin.y + [fScrollView frame].size.height)];
|
2006-06-06 18:05:57 +00:00
|
|
|
[self showStatusBar: [fDefaults boolForKey: @"StatusBar"] animate: NO];
|
|
|
|
|
2006-06-30 23:43:43 +00:00
|
|
|
//set speed limit
|
2006-07-01 21:34:53 +00:00
|
|
|
if ([fDefaults boolForKey: @"SpeedLimit"])
|
2006-07-01 18:02:36 +00:00
|
|
|
{
|
2006-07-01 21:34:53 +00:00
|
|
|
[fSpeedLimitItem setState: NSOnState];
|
|
|
|
[fSpeedLimitDockItem setState: NSOnState];
|
2006-07-01 00:29:26 +00:00
|
|
|
[fSpeedLimitButton setState: NSOnState];
|
2006-07-01 18:02:36 +00:00
|
|
|
}
|
2006-07-01 21:34:53 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
[fActionButton setToolTip: @"Shortcuts for changing global settings."];
|
2006-07-01 00:29:26 +00:00
|
|
|
[fSpeedLimitButton setToolTip: @"Speed Limit overrides the total bandwidth limits with its own limits."];
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
[fTableView setTorrents: fTorrents];
|
2006-07-01 00:29:26 +00:00
|
|
|
[[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell: [[TorrentCell alloc] init]];
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-07-02 21:05:51 +00:00
|
|
|
[fTableView registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType,
|
2006-07-02 21:57:51 +00:00
|
|
|
TORRENT_TABLE_VIEW_DATA_TYPE, nil]];
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
//register for sleep notifications
|
2006-05-25 12:22:19 +00:00
|
|
|
IONotificationPortRef notify;
|
2006-06-21 14:07:56 +00:00
|
|
|
io_object_t iterator;
|
|
|
|
if (fRootPort = IORegisterForSystemPower(self, & notify, sleepCallBack, & iterator))
|
|
|
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notify),
|
|
|
|
kCFRunLoopCommonModes);
|
2006-01-12 18:57:23 +00:00
|
|
|
else
|
2006-06-19 23:07:28 +00:00
|
|
|
NSLog(@"Could not IORegisterForSystemPower");
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
//load torrents from history
|
2006-03-23 12:39:39 +00:00
|
|
|
Torrent * torrent;
|
2006-05-25 12:22:19 +00:00
|
|
|
NSDictionary * historyItem;
|
2006-01-12 18:57:23 +00:00
|
|
|
NSEnumerator * enumerator = [[fDefaults arrayForKey: @"History"] objectEnumerator];
|
2006-05-25 12:22:19 +00:00
|
|
|
while ((historyItem = [enumerator nextObject]))
|
|
|
|
if ((torrent = [[Torrent alloc] initWithHistory: historyItem lib: fLib]))
|
|
|
|
{
|
|
|
|
[fTorrents addObject: torrent];
|
|
|
|
[torrent release];
|
|
|
|
}
|
|
|
|
|
|
|
|
[self torrentNumberChanged];
|
|
|
|
|
|
|
|
//set sort
|
2006-06-06 18:05:57 +00:00
|
|
|
fSortType = [[fDefaults stringForKey: @"Sort"] retain];
|
|
|
|
|
|
|
|
NSMenuItem * currentSortItem;
|
2006-05-25 12:22:19 +00:00
|
|
|
if ([fSortType isEqualToString: @"Name"])
|
2006-06-06 18:05:57 +00:00
|
|
|
currentSortItem = fNameSortItem;
|
2006-05-25 12:22:19 +00:00
|
|
|
else if ([fSortType isEqualToString: @"State"])
|
2006-06-06 18:05:57 +00:00
|
|
|
currentSortItem = fStateSortItem;
|
|
|
|
else if ([fSortType isEqualToString: @"Progress"])
|
|
|
|
currentSortItem = fProgressSortItem;
|
2006-06-25 18:33:52 +00:00
|
|
|
else if ([fSortType isEqualToString: @"Date"])
|
2006-06-06 18:05:57 +00:00
|
|
|
currentSortItem = fDateSortItem;
|
2006-06-25 18:33:52 +00:00
|
|
|
else
|
|
|
|
currentSortItem = fOrderSortItem;
|
2006-06-06 18:05:57 +00:00
|
|
|
[currentSortItem setState: NSOnState];
|
|
|
|
|
|
|
|
//set upload limit action button
|
|
|
|
[fUploadLimitItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)",
|
|
|
|
[fDefaults integerForKey: @"UploadLimit"]]];
|
|
|
|
if ([fDefaults boolForKey: @"CheckUpload"])
|
|
|
|
[fUploadLimitItem setState: NSOnState];
|
|
|
|
else
|
|
|
|
[fUploadNoLimitItem setState: NSOnState];
|
|
|
|
|
|
|
|
//set download limit action menu
|
|
|
|
[fDownloadLimitItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)",
|
|
|
|
[fDefaults integerForKey: @"DownloadLimit"]]];
|
|
|
|
if ([fDefaults boolForKey: @"CheckDownload"])
|
|
|
|
[fDownloadLimitItem setState: NSOnState];
|
|
|
|
else
|
|
|
|
[fDownloadNoLimitItem setState: NSOnState];
|
|
|
|
|
|
|
|
//set ratio action menu
|
|
|
|
[fRatioSetItem setTitle: [NSString stringWithFormat: @"Stop at Ratio (%.2f)",
|
|
|
|
[fDefaults floatForKey: @"RatioLimit"]]];
|
|
|
|
if ([fDefaults boolForKey: @"RatioCheck"])
|
|
|
|
[fRatioSetItem setState: NSOnState];
|
|
|
|
else
|
|
|
|
[fRatioNotSetItem setState: NSOnState];
|
|
|
|
|
|
|
|
//observe notifications
|
|
|
|
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
[nc addObserver: self selector: @selector(prepareForUpdate:)
|
|
|
|
name: SUUpdaterWillRestartNotification object: nil];
|
|
|
|
fUpdateInProgress = NO;
|
|
|
|
|
|
|
|
[nc addObserver: self selector: @selector(limitGlobalChange:)
|
|
|
|
name: @"LimitGlobalChange" object: nil];
|
|
|
|
|
|
|
|
[nc addObserver: self selector: @selector(ratioGlobalChange:)
|
|
|
|
name: @"RatioGlobalChange" object: nil];
|
2006-06-23 15:06:27 +00:00
|
|
|
|
2006-06-23 22:32:01 +00:00
|
|
|
//check to start another because of stopped torrent
|
|
|
|
[nc addObserver: self selector: @selector(checkWaitingForStopped:)
|
|
|
|
name: @"StoppedDownloading" object: nil];
|
2006-06-23 17:40:56 +00:00
|
|
|
|
2006-06-23 22:32:01 +00:00
|
|
|
//check all torrents for starting
|
|
|
|
[nc addObserver: self selector: @selector(globalStartSettingChange:)
|
|
|
|
name: @"GlobalStartSettingChange" object: nil];
|
|
|
|
|
|
|
|
//check if torrent should now start
|
|
|
|
[nc addObserver: self selector: @selector(torrentStartSettingChange:)
|
|
|
|
name: @"TorrentStartSettingChange" object: nil];
|
2006-06-23 18:08:55 +00:00
|
|
|
|
2006-06-23 22:32:01 +00:00
|
|
|
//change that just impacts the inspector
|
2006-07-04 18:42:12 +00:00
|
|
|
[nc addObserver: self selector: @selector(reloadInspectorSettings:)
|
2006-06-23 18:08:55 +00:00
|
|
|
name: @"TorrentSettingChange" object: nil];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
//timer to update the interface
|
2006-01-29 01:20:22 +00:00
|
|
|
fCompleted = 0;
|
2006-02-11 06:46:40 +00:00
|
|
|
[self updateUI: nil];
|
2006-02-07 02:32:50 +00:00
|
|
|
fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self
|
2006-02-11 06:46:40 +00:00
|
|
|
selector: @selector( updateUI: ) userInfo: nil repeats: YES];
|
2006-07-01 21:34:53 +00:00
|
|
|
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode];
|
|
|
|
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
|
|
|
[self sortTorrents];
|
|
|
|
|
|
|
|
[fWindow makeKeyAndOrderFront: nil];
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-07-04 18:42:12 +00:00
|
|
|
//load info for no torrents
|
|
|
|
[fInfoController updateInfoForTorrents: [NSArray array]];
|
2006-05-25 12:22:19 +00:00
|
|
|
if ([fDefaults boolForKey: @"InfoVisible"])
|
|
|
|
[self showInfo: nil];
|
2006-01-12 18:20:48 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 14:23:14 +00:00
|
|
|
- (BOOL) applicationShouldHandleReopen: (NSApplication *) app hasVisibleWindows: (BOOL) visibleWindows
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-06-22 06:32:27 +00:00
|
|
|
if (![fWindow isVisible] && ![[fPrefsController window] isVisible])
|
2006-06-20 14:16:32 +00:00
|
|
|
[fWindow makeKeyAndOrderFront: nil];
|
2006-01-12 17:43:21 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) sender
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
if (!fUpdateInProgress && [fDefaults boolForKey: @"CheckQuit"])
|
2006-01-29 01:20:22 +00:00
|
|
|
{
|
2006-06-26 05:52:51 +00:00
|
|
|
int active = 0, downloading = 0;
|
2006-06-06 18:05:57 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isActive])
|
2006-06-26 05:52:51 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
active++;
|
2006-06-26 05:52:51 +00:00
|
|
|
if (![torrent isSeeding])
|
|
|
|
downloading++;
|
|
|
|
}
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-07-04 19:28:35 +00:00
|
|
|
if ([fDefaults boolForKey: @"CheckQuitDownloading"] ? downloading > 0 : active > 0)
|
2006-06-06 18:05:57 +00:00
|
|
|
{
|
|
|
|
NSString * message = active == 1
|
2006-06-11 21:37:21 +00:00
|
|
|
? @"There is an active transfer. Do you really want to quit?"
|
2006-06-06 18:05:57 +00:00
|
|
|
: [NSString stringWithFormat:
|
2006-06-18 03:40:11 +00:00
|
|
|
@"There are %d active transfers. Do you really want to quit?", active];
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
NSBeginAlertSheet(@"Confirm Quit", @"Quit", @"Cancel", nil, fWindow, self,
|
2006-06-06 18:05:57 +00:00
|
|
|
@selector(quitSheetDidEnd:returnCode:contextInfo:),
|
|
|
|
nil, nil, message);
|
|
|
|
return NSTerminateLater;
|
|
|
|
}
|
2006-03-23 12:39:39 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
return NSTerminateNow;
|
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode
|
2006-06-19 23:07:28 +00:00
|
|
|
contextInfo: (void *) contextInfo
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-01-12 18:57:23 +00:00
|
|
|
[NSApp stopModal];
|
2006-06-20 14:23:14 +00:00
|
|
|
[NSApp replyToApplicationShouldTerminate: returnCode == NSAlertDefaultReturn];
|
2006-01-12 18:57:23 +00:00
|
|
|
}
|
|
|
|
|
2006-01-29 22:16:16 +00:00
|
|
|
- (void) applicationWillTerminate: (NSNotification *) notification
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
2006-07-02 22:59:23 +00:00
|
|
|
//stop updating the interface
|
2006-01-12 17:43:21 +00:00
|
|
|
[fTimer invalidate];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-07-03 11:20:07 +00:00
|
|
|
//save history and stop running torrents
|
2006-02-08 19:05:42 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-07-03 11:20:07 +00:00
|
|
|
[fTorrents makeObjectsPerformSelector: @selector(stopTransferForQuit)];
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-07-04 19:49:43 +00:00
|
|
|
//remember window states and close all windows
|
2006-06-06 18:05:57 +00:00
|
|
|
[fDefaults setBool: [[fInfoController window] isVisible] forKey: @"InfoVisible"];
|
2006-07-04 19:49:43 +00:00
|
|
|
[[NSApp windows] makeObjectsPerformSelector: @selector(close)];
|
2006-06-06 18:05:57 +00:00
|
|
|
[self showStatusBar: NO animate: NO];
|
|
|
|
|
|
|
|
//clear badge
|
|
|
|
[fBadger clearBadge];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-07-04 19:49:43 +00:00
|
|
|
//end quickly if the app is updating
|
2006-06-06 18:05:57 +00:00
|
|
|
if (fUpdateInProgress)
|
|
|
|
return;
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-07-04 19:49:43 +00:00
|
|
|
//wait for running transfers to stop (5 second timeout)
|
2006-01-12 17:43:21 +00:00
|
|
|
NSDate * start = [NSDate date];
|
2006-07-03 02:30:20 +00:00
|
|
|
BOOL timeUp = NO;
|
|
|
|
|
2006-07-03 11:12:14 +00:00
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
|
|
|
Torrent * torrent;
|
2006-07-03 11:15:53 +00:00
|
|
|
while (!timeUp && (torrent = [enumerator nextObject]))
|
2006-07-03 11:12:14 +00:00
|
|
|
while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] < -5.0))
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-07-03 02:30:20 +00:00
|
|
|
usleep(100000);
|
2006-03-23 12:39:39 +00:00
|
|
|
[torrent update];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
2006-07-03 11:15:53 +00:00
|
|
|
|
2006-07-03 02:30:20 +00:00
|
|
|
[fTorrents release];
|
2006-01-12 18:57:23 +00:00
|
|
|
}
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
|
2006-04-04 09:45:36 +00:00
|
|
|
contextInfo: (Torrent *) torrent
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-01-12 18:57:23 +00:00
|
|
|
if (code == NSOKButton)
|
|
|
|
{
|
2006-06-21 14:07:56 +00:00
|
|
|
[torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
|
2006-06-30 02:57:50 +00:00
|
|
|
[torrent update];
|
2006-06-23 22:32:01 +00:00
|
|
|
[self attemptToStartAuto: torrent];
|
2006-05-25 12:22:19 +00:00
|
|
|
[fTorrents addObject: torrent];
|
|
|
|
|
|
|
|
[self torrentNumberChanged];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
[NSApp stopModal];
|
|
|
|
}
|
|
|
|
|
2006-06-23 15:06:27 +00:00
|
|
|
- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-06-18 03:40:11 +00:00
|
|
|
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath;
|
2006-03-23 12:39:39 +00:00
|
|
|
Torrent * torrent;
|
2006-01-12 18:57:23 +00:00
|
|
|
NSEnumerator * enumerator = [filenames objectEnumerator];
|
|
|
|
while ((torrentPath = [enumerator nextObject]))
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib]))
|
2006-01-12 17:43:21 +00:00
|
|
|
continue;
|
|
|
|
|
2006-06-23 15:06:27 +00:00
|
|
|
//add it to the "File > Open Recent" menu
|
2006-01-12 18:58:57 +00:00
|
|
|
[[NSDocumentController sharedDocumentController]
|
|
|
|
noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
if ([downloadChoice isEqualToString: @"Ask"])
|
2006-01-12 18:58:57 +00:00
|
|
|
{
|
|
|
|
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-01-12 18:58:57 +00:00
|
|
|
[panel setPrompt: @"Select Download Folder"];
|
|
|
|
[panel setAllowsMultipleSelection: NO];
|
|
|
|
[panel setCanChooseFiles: NO];
|
|
|
|
[panel setCanChooseDirectories: YES];
|
|
|
|
|
2006-07-04 19:09:41 +00:00
|
|
|
[panel setMessage: [NSString stringWithFormat: @"Select the download folder for \"%@\"", [torrent name]]];
|
2006-04-03 19:29:09 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
[panel beginSheetForDirectory: nil file: nil types: nil
|
2006-01-12 18:58:57 +00:00
|
|
|
modalForWindow: fWindow modalDelegate: self didEndSelector:
|
|
|
|
@selector( folderChoiceClosed:returnCode:contextInfo: )
|
2006-04-04 09:45:36 +00:00
|
|
|
contextInfo: torrent];
|
2006-01-12 18:58:57 +00:00
|
|
|
[NSApp runModalForWindow: panel];
|
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
NSString * folder = [downloadChoice isEqualToString: @"Constant"]
|
2006-06-18 03:40:11 +00:00
|
|
|
? [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath]
|
|
|
|
: [torrentPath stringByDeletingLastPathComponent];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
[torrent setDownloadFolder: folder];
|
2006-06-30 02:57:50 +00:00
|
|
|
[torrent update];
|
2006-06-23 22:32:01 +00:00
|
|
|
[self attemptToStartAuto: torrent];
|
2006-05-25 12:22:19 +00:00
|
|
|
[fTorrents addObject: torrent];
|
|
|
|
}
|
|
|
|
|
|
|
|
[torrent release];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
[self torrentNumberChanged];
|
|
|
|
|
2006-04-04 09:45:36 +00:00
|
|
|
[self updateUI: nil];
|
2006-05-25 12:22:19 +00:00
|
|
|
[self sortTorrents];
|
2006-02-08 19:05:42 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet
|
|
|
|
{
|
2006-06-07 01:39:57 +00:00
|
|
|
if ([fTorrents respondsToSelector: @selector(objectsAtIndexes:)])
|
|
|
|
return [fTorrents objectsAtIndexes: indexSet];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [indexSet count]];
|
|
|
|
unsigned int i;
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
|
|
|
[torrents addObject: [fTorrents objectAtIndex: i]];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-07 01:39:57 +00:00
|
|
|
return torrents;
|
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) torrentNumberChanged
|
|
|
|
{
|
2006-06-16 03:45:12 +00:00
|
|
|
int count = [fTorrents count];
|
|
|
|
[fTotalTorrentsField setStringValue: [NSString stringWithFormat:
|
2006-06-19 23:07:28 +00:00
|
|
|
@"%d Transfer%s", count, count == 1 ? "" : "s"]];
|
2006-05-25 12:22:19 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
//called on by applescript
|
2006-01-12 18:33:20 +00:00
|
|
|
- (void) open: (NSArray *) files
|
|
|
|
{
|
2006-06-21 14:07:56 +00:00
|
|
|
[self performSelectorOnMainThread: @selector(openFromSheet:) withObject: files waitUntilDone: NO];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) openShowSheet: (id) sender
|
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
|
|
|
NSArray * fileTypes = [NSArray arrayWithObject: @"torrent"];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
[panel setAllowsMultipleSelection: YES];
|
2006-05-25 12:22:19 +00:00
|
|
|
[panel setCanChooseFiles: YES];
|
|
|
|
[panel setCanChooseDirectories: NO];
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
[panel beginSheetForDirectory: nil file: nil types: fileTypes
|
2006-01-12 17:43:21 +00:00
|
|
|
modalForWindow: fWindow modalDelegate: self didEndSelector:
|
2006-06-20 14:23:14 +00:00
|
|
|
@selector(openSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 14:23:14 +00:00
|
|
|
- (void) openFromSheet: (NSArray *) filenames
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-04-05 13:39:30 +00:00
|
|
|
[self application: NSApp openFiles: filenames];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (void) openSheetClosed: (NSOpenPanel *) panel returnCode: (int) code
|
2006-01-12 17:43:21 +00:00
|
|
|
contextInfo: (void *) info
|
|
|
|
{
|
2006-06-20 14:23:14 +00:00
|
|
|
if (code == NSOKButton)
|
|
|
|
[self performSelectorOnMainThread: @selector(openFromSheet:)
|
2006-05-25 12:22:19 +00:00
|
|
|
withObject: [panel filenames] waitUntilDone: NO];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) resumeTorrent: (id) sender
|
|
|
|
{
|
2006-04-07 13:09:19 +00:00
|
|
|
[self resumeTorrentWithIndex: [fTableView selectedRowIndexes]];
|
2006-01-12 18:20:48 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:33:20 +00:00
|
|
|
- (void) resumeAllTorrents: (id) sender
|
|
|
|
{
|
2006-07-04 19:01:23 +00:00
|
|
|
[self resumeTorrentWithIndex: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTorrents count])]];
|
2006-01-12 18:33:20 +00:00
|
|
|
}
|
|
|
|
|
2006-04-07 13:09:19 +00:00
|
|
|
- (void) resumeTorrentWithIndex: (NSIndexSet *) indexSet
|
2006-01-12 18:20:48 +00:00
|
|
|
{
|
2006-04-07 13:09:19 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
2006-06-21 23:46:41 +00:00
|
|
|
[[fTorrents objectAtIndex: i] startTransfer];
|
2006-04-25 16:31:19 +00:00
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
[self updateUI: nil];
|
2006-07-04 17:26:18 +00:00
|
|
|
[fInfoController updateInfoSettings];
|
2006-02-08 19:05:42 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) stopTorrent: (id) sender
|
|
|
|
{
|
2006-04-07 13:09:19 +00:00
|
|
|
[self stopTorrentWithIndex: [fTableView selectedRowIndexes]];
|
2006-01-12 18:20:48 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:33:20 +00:00
|
|
|
- (void) stopAllTorrents: (id) sender
|
|
|
|
{
|
2006-07-04 19:01:23 +00:00
|
|
|
[self stopTorrentWithIndex: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTorrents count])]];
|
2006-01-12 18:33:20 +00:00
|
|
|
}
|
|
|
|
|
2006-04-07 13:09:19 +00:00
|
|
|
- (void) stopTorrentWithIndex: (NSIndexSet *) indexSet
|
2006-01-12 18:20:48 +00:00
|
|
|
{
|
2006-06-23 23:00:58 +00:00
|
|
|
//don't want any of these starting then stopping
|
2006-04-07 13:09:19 +00:00
|
|
|
unsigned int i;
|
2006-06-23 23:00:58 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
|
|
|
{
|
|
|
|
torrent = [fTorrents objectAtIndex: i];
|
|
|
|
[torrent setWaitToStart: NO];
|
|
|
|
}
|
|
|
|
|
2006-04-07 13:09:19 +00:00
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
2006-06-21 23:46:41 +00:00
|
|
|
[[fTorrents objectAtIndex: i] stopTransfer];
|
2006-04-25 16:31:19 +00:00
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
[self updateUI: nil];
|
2006-07-04 17:26:18 +00:00
|
|
|
[fInfoController updateInfoSettings];
|
2006-02-08 19:05:42 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-15 02:07:50 +00:00
|
|
|
- (void) removeWithIndex: (NSIndexSet *) indexSet
|
|
|
|
deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
NSArray * torrents = [[self torrentsAtIndexes: indexSet] retain];
|
2006-06-26 05:52:51 +00:00
|
|
|
int active = 0, downloading = 0;
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-26 05:52:51 +00:00
|
|
|
if ([fDefaults boolForKey: @"CheckRemove"])
|
|
|
|
{
|
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [torrents objectEnumerator];
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isActive])
|
|
|
|
{
|
|
|
|
active++;
|
|
|
|
if (![torrent isSeeding])
|
|
|
|
downloading++;
|
|
|
|
}
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-07-04 19:37:12 +00:00
|
|
|
if ([fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0)
|
2006-04-25 16:31:19 +00:00
|
|
|
{
|
2006-07-04 19:37:12 +00:00
|
|
|
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
|
|
torrents, @"Torrents",
|
|
|
|
[NSNumber numberWithBool: deleteData], @"DeleteData",
|
|
|
|
[NSNumber numberWithBool: deleteTorrent], @"DeleteTorrent", nil];
|
|
|
|
|
|
|
|
NSString * title, * message;
|
|
|
|
|
|
|
|
int selected = [fTableView numberOfSelectedRows];
|
|
|
|
if (selected == 1)
|
|
|
|
{
|
|
|
|
title = [NSString stringWithFormat: @"Comfirm Removal of \"%@\"",
|
|
|
|
[[fTorrents objectAtIndex: [fTableView selectedRow]] name]];
|
|
|
|
message = @"This transfer is active."
|
|
|
|
" Once removed, continuing the transfer will require the torrent file."
|
|
|
|
" Do you really want to remove it?";
|
|
|
|
}
|
2006-04-25 16:31:19 +00:00
|
|
|
else
|
2006-07-04 19:37:12 +00:00
|
|
|
{
|
|
|
|
title = [NSString stringWithFormat: @"Comfirm Removal of %d Transfers", selected];
|
|
|
|
if (selected == active)
|
|
|
|
message = [NSString stringWithFormat:
|
|
|
|
@"There are %d active transfers.", active];
|
|
|
|
else
|
|
|
|
message = [NSString stringWithFormat:
|
|
|
|
@"There are %d transfers (%d active).", selected, active];
|
|
|
|
message = [message stringByAppendingString:
|
|
|
|
@" Once removed, continuing the transfers will require the torrent files."
|
|
|
|
" Do you really want to remove them?"];
|
|
|
|
}
|
2006-04-07 13:09:19 +00:00
|
|
|
|
2006-07-04 19:37:12 +00:00
|
|
|
NSBeginAlertSheet(title, @"Remove", @"Cancel", nil, fWindow, self,
|
|
|
|
@selector(removeSheetDidEnd:returnCode:contextInfo:), nil, dict, message);
|
|
|
|
return;
|
|
|
|
}
|
2006-03-23 12:39:39 +00:00
|
|
|
}
|
2006-07-04 19:37:12 +00:00
|
|
|
|
|
|
|
[self confirmRemove: torrents deleteData: deleteData deleteTorrent: deleteTorrent];
|
2006-01-12 18:57:23 +00:00
|
|
|
}
|
|
|
|
|
2006-07-04 19:37:12 +00:00
|
|
|
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (NSDictionary *) dict
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
|
|
|
[NSApp stopModal];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
NSArray * torrents = [dict objectForKey: @"Torrents"];
|
2006-06-15 02:07:50 +00:00
|
|
|
BOOL deleteData = [[dict objectForKey: @"DeleteData"] boolValue],
|
|
|
|
deleteTorrent = [[dict objectForKey: @"DeleteTorrent"] boolValue];
|
2006-05-25 12:22:19 +00:00
|
|
|
[dict release];
|
|
|
|
|
|
|
|
if (returnCode == NSAlertDefaultReturn)
|
2006-06-18 03:40:11 +00:00
|
|
|
[self confirmRemove: torrents deleteData: deleteData deleteTorrent: deleteTorrent];
|
2006-05-25 12:22:19 +00:00
|
|
|
else
|
|
|
|
[torrents release];
|
2006-01-12 18:57:23 +00:00
|
|
|
}
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-07-04 19:37:12 +00:00
|
|
|
- (void) confirmRemove: (NSArray *) torrents deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-06-24 18:28:50 +00:00
|
|
|
//don't want any of these starting then stopping
|
2006-05-25 12:22:19 +00:00
|
|
|
NSEnumerator * enumerator = [torrents objectEnumerator];
|
2006-06-24 18:28:50 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
[torrent setWaitToStart: NO];
|
|
|
|
|
|
|
|
NSNumber * lowestOrderValue = [NSNumber numberWithInt: [torrents count]], * currentOrederValue;
|
|
|
|
|
|
|
|
enumerator = [torrents objectEnumerator];
|
2006-05-25 12:22:19 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
2006-04-25 16:31:19 +00:00
|
|
|
{
|
2006-06-21 23:46:41 +00:00
|
|
|
[torrent stopTransfer];
|
2006-04-25 16:31:19 +00:00
|
|
|
|
2006-06-15 02:07:50 +00:00
|
|
|
if (deleteData)
|
2006-04-25 16:31:19 +00:00
|
|
|
[torrent trashData];
|
2006-06-15 02:07:50 +00:00
|
|
|
if (deleteTorrent)
|
|
|
|
[torrent trashTorrent];
|
2006-06-24 18:28:50 +00:00
|
|
|
|
|
|
|
//determine lowest order value
|
|
|
|
currentOrederValue = [torrent orderValue];
|
|
|
|
if ([lowestOrderValue compare: currentOrederValue] == NSOrderedDescending)
|
|
|
|
lowestOrderValue = currentOrederValue;
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-09 19:53:35 +00:00
|
|
|
[torrent removeForever];
|
2006-04-25 16:31:19 +00:00
|
|
|
[fTorrents removeObject: torrent];
|
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
[torrents release];
|
2006-06-24 18:28:50 +00:00
|
|
|
|
|
|
|
//reset the order values if necessary
|
|
|
|
if ([lowestOrderValue intValue] < [fTorrents count])
|
|
|
|
{
|
|
|
|
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"orderValue" ascending: YES] autorelease];
|
|
|
|
NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
|
|
|
|
|
|
|
NSArray * tempTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
|
|
|
[descriptors release];
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = [lowestOrderValue intValue]; i < [tempTorrents count]; i++)
|
|
|
|
[[tempTorrents objectAtIndex: i] setOrderValue: i];
|
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
|
|
|
|
[self torrentNumberChanged];
|
|
|
|
[fTableView deselectAll: nil];
|
2006-03-23 12:39:39 +00:00
|
|
|
[self updateUI: nil];
|
2006-02-08 19:05:42 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-15 02:07:50 +00:00
|
|
|
- (void) removeNoDelete: (id) sender
|
2006-01-12 18:29:20 +00:00
|
|
|
{
|
2006-06-15 02:07:50 +00:00
|
|
|
[self removeWithIndex: [fTableView selectedRowIndexes] deleteData: NO deleteTorrent: NO];
|
2006-01-12 18:29:20 +00:00
|
|
|
}
|
|
|
|
|
2006-06-15 02:07:50 +00:00
|
|
|
- (void) removeDeleteData: (id) sender
|
2006-01-12 18:29:20 +00:00
|
|
|
{
|
2006-06-15 02:07:50 +00:00
|
|
|
[self removeWithIndex: [fTableView selectedRowIndexes] deleteData: YES deleteTorrent: NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) removeDeleteTorrent: (id) sender
|
|
|
|
{
|
|
|
|
[self removeWithIndex: [fTableView selectedRowIndexes] deleteData: NO deleteTorrent: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) removeDeleteBoth: (id) sender
|
|
|
|
{
|
|
|
|
[self removeWithIndex: [fTableView selectedRowIndexes] deleteData: YES deleteTorrent: YES];
|
2006-01-12 18:29:20 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 23:06:30 +00:00
|
|
|
- (void) copyTorrentFile: (id) sender
|
|
|
|
{
|
2006-06-11 00:16:31 +00:00
|
|
|
[self copyTorrentFileForTorrents: [[NSMutableArray alloc] initWithArray:
|
|
|
|
[self torrentsAtIndexes: [fTableView selectedRowIndexes]]]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents
|
|
|
|
{
|
|
|
|
if ([torrents count] == 0)
|
2006-06-10 23:06:30 +00:00
|
|
|
{
|
2006-06-11 00:16:31 +00:00
|
|
|
[torrents release];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Torrent * torrent = [torrents objectAtIndex: 0];
|
|
|
|
|
|
|
|
//warn user if torrent file can't be found
|
|
|
|
if (![[NSFileManager defaultManager] fileExistsAtPath: [torrent torrentLocation]])
|
|
|
|
{
|
|
|
|
NSAlert * alert = [[NSAlert alloc] init];
|
|
|
|
[alert addButtonWithTitle: @"OK"];
|
|
|
|
[alert setMessageText: [NSString stringWithFormat:
|
|
|
|
@"Copy of \"%@\" Cannot Be Created", [torrent name]]];
|
|
|
|
[alert setInformativeText: [NSString stringWithFormat:
|
|
|
|
@"The torrent file (%@) cannot be found.", [torrent torrentLocation]]];
|
|
|
|
[alert setAlertStyle: NSWarningAlertStyle];
|
2006-06-10 23:06:30 +00:00
|
|
|
|
2006-06-11 00:16:31 +00:00
|
|
|
[alert runModal];
|
|
|
|
|
|
|
|
[torrents removeObjectAtIndex: 0];
|
|
|
|
[self copyTorrentFileForTorrents: torrents];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSSavePanel * panel = [NSSavePanel savePanel];
|
|
|
|
[panel setRequiredFileType: @"torrent"];
|
|
|
|
[panel setCanSelectHiddenExtension: NO];
|
2006-06-19 23:07:28 +00:00
|
|
|
[panel setExtensionHidden: NO];
|
2006-06-10 23:06:30 +00:00
|
|
|
|
2006-06-11 00:16:31 +00:00
|
|
|
[panel beginSheetForDirectory: nil file: [torrent name]
|
|
|
|
modalForWindow: fWindow modalDelegate: self didEndSelector:
|
|
|
|
@selector( saveTorrentCopySheetClosed:returnCode:contextInfo: )
|
|
|
|
contextInfo: torrents];
|
2006-06-10 23:06:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-11 00:16:31 +00:00
|
|
|
- (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (int) code
|
|
|
|
contextInfo: (NSMutableArray *) torrents
|
|
|
|
{
|
|
|
|
//if save successful, copy torrent to new location with name of data file
|
|
|
|
if (code == NSOKButton)
|
|
|
|
[[NSFileManager defaultManager] copyPath: [[torrents objectAtIndex: 0] torrentLocation]
|
|
|
|
toPath: [panel filename] handler: nil];
|
|
|
|
|
|
|
|
[torrents removeObjectAtIndex: 0];
|
|
|
|
[self performSelectorOnMainThread: @selector(copyTorrentFileForTorrents:)
|
|
|
|
withObject: torrents waitUntilDone: NO];
|
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) revealFile: (id) sender
|
2006-03-27 15:09:29 +00:00
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
2006-06-21 23:46:41 +00:00
|
|
|
[[fTorrents objectAtIndex: i] revealData];
|
2006-03-27 15:09:29 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) showPreferenceWindow: (id) sender
|
|
|
|
{
|
|
|
|
NSWindow * window = [fPrefsController window];
|
|
|
|
if (![window isVisible])
|
|
|
|
[window center];
|
|
|
|
|
|
|
|
[window makeKeyAndOrderFront: nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) showInfo: (id) sender
|
|
|
|
{
|
|
|
|
if ([[fInfoController window] isVisible])
|
2006-07-03 02:10:59 +00:00
|
|
|
[fInfoController close];
|
2006-06-06 18:05:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[fInfoController updateInfoStats];
|
|
|
|
[[fInfoController window] orderFront: nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setInfoTab: (id) sender
|
|
|
|
{
|
|
|
|
if (sender == fNextInfoTabItem)
|
|
|
|
[fInfoController setNextTab];
|
|
|
|
else
|
|
|
|
[fInfoController setPreviousTab];
|
|
|
|
}
|
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
- (void) updateUI: (NSTimer *) t
|
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
2006-03-23 12:39:39 +00:00
|
|
|
Torrent * torrent;
|
2006-06-21 14:07:56 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
|
|
|
[torrent update];
|
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
if ([torrent justFinished])
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
2006-06-23 22:32:01 +00:00
|
|
|
[self checkWaitingForFinished: torrent];
|
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
//notifications
|
2006-03-23 12:39:39 +00:00
|
|
|
[self notifyGrowl: [torrent name]];
|
2006-06-21 14:07:56 +00:00
|
|
|
if (![fWindow isKeyWindow])
|
2006-03-23 12:39:39 +00:00
|
|
|
fCompleted++;
|
|
|
|
}
|
|
|
|
}
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-06-20 19:20:36 +00:00
|
|
|
if ([fSortType isEqualToString: @"Progress"] || [fSortType isEqualToString: @"State"])
|
2006-06-06 18:05:57 +00:00
|
|
|
[self sortTorrents];
|
|
|
|
else
|
|
|
|
[fTableView reloadData];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-06-21 14:07:56 +00:00
|
|
|
//update the global DL/UL rates
|
2006-06-06 18:05:57 +00:00
|
|
|
float downloadRate, uploadRate;
|
|
|
|
tr_torrentRates(fLib, & downloadRate, & uploadRate);
|
|
|
|
if (fStatusBarVisible)
|
|
|
|
{
|
|
|
|
[fTotalDLField setStringValue: [NSString stringForSpeed: downloadRate]];
|
|
|
|
[fTotalULField setStringValue: [NSString stringForSpeed: uploadRate]];
|
|
|
|
}
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
if ([[fInfoController window] isVisible])
|
|
|
|
[fInfoController updateInfoStats];
|
2006-01-20 01:51:07 +00:00
|
|
|
|
|
|
|
//badge dock
|
2006-02-08 18:10:42 +00:00
|
|
|
[fBadger updateBadgeWithCompleted: fCompleted
|
2006-06-06 18:05:57 +00:00
|
|
|
uploadRate: uploadRate downloadRate: downloadRate];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-02-08 19:05:42 +00:00
|
|
|
- (void) updateTorrentHistory
|
|
|
|
{
|
2006-03-23 12:39:39 +00:00
|
|
|
NSMutableArray * history = [NSMutableArray
|
|
|
|
arrayWithCapacity: [fTorrents count]];
|
2006-02-08 19:05:42 +00:00
|
|
|
|
2006-03-23 12:39:39 +00:00
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
|
|
|
Torrent * torrent;
|
|
|
|
while( ( torrent = [enumerator nextObject] ) )
|
2006-05-25 12:22:19 +00:00
|
|
|
[history addObject: [torrent history]];
|
|
|
|
|
|
|
|
[fDefaults setObject: history forKey: @"History"];
|
2006-06-20 14:00:53 +00:00
|
|
|
[fDefaults synchronize];
|
2006-05-25 12:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) sortTorrents
|
|
|
|
{
|
|
|
|
//remember selected rows if needed
|
|
|
|
NSArray * selectedTorrents = nil;
|
|
|
|
int numSelected = [fTableView numberOfSelectedRows];
|
|
|
|
if (numSelected > 0 && numSelected < [fTorrents count])
|
|
|
|
selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
|
|
|
|
|
|
|
|
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"name" ascending: YES] autorelease],
|
2006-06-25 18:33:52 +00:00
|
|
|
* orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"orderValue" ascending: YES] autorelease];
|
2006-06-20 14:46:15 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
NSArray * descriptors;
|
|
|
|
if ([fSortType isEqualToString: @"Name"])
|
2006-06-25 18:33:52 +00:00
|
|
|
descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, orderDescriptor, nil];
|
2006-05-25 12:22:19 +00:00
|
|
|
else if ([fSortType isEqualToString: @"State"])
|
|
|
|
{
|
|
|
|
NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
2006-06-20 14:54:03 +00:00
|
|
|
@"stateSortKey" ascending: NO] autorelease],
|
|
|
|
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"progressSortKey" ascending: NO] autorelease];
|
|
|
|
|
2006-06-20 14:46:15 +00:00
|
|
|
descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor,
|
2006-06-25 18:33:52 +00:00
|
|
|
nameDescriptor, orderDescriptor, nil];
|
2006-05-25 12:22:19 +00:00
|
|
|
}
|
2006-06-06 18:05:57 +00:00
|
|
|
else if ([fSortType isEqualToString: @"Progress"])
|
2006-06-20 14:54:03 +00:00
|
|
|
{
|
|
|
|
NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"progressSortKey" ascending: YES] autorelease];
|
|
|
|
|
2006-06-25 18:33:52 +00:00
|
|
|
descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, nameDescriptor, orderDescriptor, nil];
|
|
|
|
}
|
|
|
|
else if ([fSortType isEqualToString: @"Date"])
|
|
|
|
{
|
|
|
|
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"date" ascending: YES] autorelease];
|
|
|
|
|
|
|
|
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
|
2006-06-20 14:54:03 +00:00
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
else
|
2006-06-25 18:33:52 +00:00
|
|
|
descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
2006-05-25 12:22:19 +00:00
|
|
|
|
|
|
|
[fTorrents sortUsingDescriptors: descriptors];
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
[descriptors release];
|
|
|
|
|
|
|
|
[fTableView reloadData];
|
|
|
|
|
|
|
|
//set selected rows if needed
|
|
|
|
if (selectedTorrents)
|
|
|
|
{
|
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
|
2006-06-06 18:05:57 +00:00
|
|
|
NSMutableIndexSet * indexSet = [[NSMutableIndexSet alloc] init];
|
2006-05-25 12:22:19 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
2006-06-06 18:05:57 +00:00
|
|
|
[indexSet addIndex: [fTorrents indexOfObject: torrent]];
|
|
|
|
|
|
|
|
[fTableView selectRowIndexes: indexSet byExtendingSelection: NO];
|
|
|
|
[indexSet release];
|
2006-05-25 12:22:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSort: (id) sender
|
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
NSMenuItem * prevSortItem;
|
|
|
|
if ([fSortType isEqualToString: @"Name"])
|
|
|
|
prevSortItem = fNameSortItem;
|
|
|
|
else if ([fSortType isEqualToString: @"State"])
|
|
|
|
prevSortItem = fStateSortItem;
|
|
|
|
else if ([fSortType isEqualToString: @"Progress"])
|
|
|
|
prevSortItem = fProgressSortItem;
|
2006-06-25 18:33:52 +00:00
|
|
|
else if ([fSortType isEqualToString: @"Date"])
|
2006-06-06 18:05:57 +00:00
|
|
|
prevSortItem = fDateSortItem;
|
2006-06-25 18:33:52 +00:00
|
|
|
else
|
|
|
|
prevSortItem = fOrderSortItem;
|
2006-06-06 18:05:57 +00:00
|
|
|
|
2006-06-19 04:30:36 +00:00
|
|
|
if (sender != prevSortItem)
|
|
|
|
{
|
|
|
|
[prevSortItem setState: NSOffState];
|
|
|
|
[sender setState: NSOnState];
|
|
|
|
|
|
|
|
[fSortType release];
|
|
|
|
if (sender == fNameSortItem)
|
|
|
|
fSortType = [[NSString alloc] initWithString: @"Name"];
|
|
|
|
else if (sender == fStateSortItem)
|
|
|
|
fSortType = [[NSString alloc] initWithString: @"State"];
|
|
|
|
else if (sender == fProgressSortItem)
|
|
|
|
fSortType = [[NSString alloc] initWithString: @"Progress"];
|
2006-06-25 18:33:52 +00:00
|
|
|
else if (sender == fDateSortItem)
|
2006-06-19 04:30:36 +00:00
|
|
|
fSortType = [[NSString alloc] initWithString: @"Date"];
|
2006-06-25 18:33:52 +00:00
|
|
|
else
|
|
|
|
fSortType = [[NSString alloc] initWithString: @"Order"];
|
2006-06-19 04:30:36 +00:00
|
|
|
|
|
|
|
[fDefaults setObject: fSortType forKey: @"Sort"];
|
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
|
|
|
|
[self sortTorrents];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 23:43:43 +00:00
|
|
|
- (void) toggleSpeedLimit: (id) sender
|
|
|
|
{
|
2006-07-01 00:29:26 +00:00
|
|
|
int state = [fSpeedLimitItem state] ? NSOffState : NSOnState;
|
2006-06-30 23:43:43 +00:00
|
|
|
|
2006-07-01 00:29:26 +00:00
|
|
|
[fSpeedLimitItem setState: state];
|
2006-07-01 18:02:36 +00:00
|
|
|
[fSpeedLimitDockItem setState: state];
|
2006-07-01 00:29:26 +00:00
|
|
|
[fSpeedLimitButton setState: state];
|
|
|
|
|
|
|
|
[fPrefsController enableSpeedLimit: state];
|
2006-06-30 23:43:43 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) setLimitGlobalEnabled: (id) sender
|
|
|
|
{
|
|
|
|
[fPrefsController setLimitEnabled: (sender == fUploadLimitItem || sender == fDownloadLimitItem)
|
2006-06-19 23:07:28 +00:00
|
|
|
type: (sender == fUploadLimitItem || sender == fUploadNoLimitItem) ? @"Upload" : @"Download"];
|
2006-06-06 18:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setQuickLimitGlobal: (id) sender
|
|
|
|
{
|
2006-06-17 23:00:12 +00:00
|
|
|
[fPrefsController setQuickLimit: [[sender title] intValue]
|
|
|
|
type: [sender menu] == fUploadMenu ? @"Upload" : @"Download"];
|
2006-06-06 18:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) limitGlobalChange: (NSNotification *) notification
|
|
|
|
{
|
|
|
|
NSDictionary * dict = [notification object];
|
|
|
|
|
|
|
|
NSMenuItem * limitItem, * noLimitItem;
|
|
|
|
if ([[dict objectForKey: @"Type"] isEqualToString: @"Upload"])
|
|
|
|
{
|
|
|
|
limitItem = fUploadLimitItem;
|
|
|
|
noLimitItem = fUploadNoLimitItem;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
limitItem = fDownloadLimitItem;
|
|
|
|
noLimitItem = fDownloadNoLimitItem;
|
|
|
|
}
|
2006-06-17 23:00:12 +00:00
|
|
|
|
|
|
|
BOOL enable = [[dict objectForKey: @"Enable"] boolValue];
|
2006-06-06 18:05:57 +00:00
|
|
|
[limitItem setState: enable ? NSOnState : NSOffState];
|
|
|
|
[noLimitItem setState: !enable ? NSOnState : NSOffState];
|
|
|
|
|
|
|
|
[limitItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)",
|
|
|
|
[[dict objectForKey: @"Limit"] intValue]]];
|
|
|
|
|
|
|
|
[dict release];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setRatioGlobalEnabled: (id) sender
|
|
|
|
{
|
|
|
|
[fPrefsController setRatioEnabled: sender == fRatioSetItem];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setQuickRatioGlobal: (id) sender
|
|
|
|
{
|
|
|
|
[fPrefsController setQuickRatio: [[sender title] floatValue]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) ratioGlobalChange: (NSNotification *) notification
|
|
|
|
{
|
|
|
|
NSDictionary * dict = [notification object];
|
|
|
|
|
|
|
|
BOOL enable = [[dict objectForKey: @"Enable"] boolValue];
|
|
|
|
[fRatioSetItem setState: enable ? NSOnState : NSOffState];
|
|
|
|
[fRatioNotSetItem setState: !enable ? NSOnState : NSOffState];
|
|
|
|
|
|
|
|
[fRatioSetItem setTitle: [NSString stringWithFormat: @"Stop at Ratio (%.2f)",
|
|
|
|
[[dict objectForKey: @"Ratio"] floatValue]]];
|
|
|
|
|
|
|
|
[dict release];
|
|
|
|
}
|
|
|
|
|
2006-06-23 22:32:01 +00:00
|
|
|
- (void) checkWaitingForStopped: (NSNotification *) notification
|
|
|
|
{
|
|
|
|
[self checkWaitingForFinished: [notification object]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) checkWaitingForFinished: (Torrent *) finishedTorrent
|
2006-06-23 15:06:27 +00:00
|
|
|
{
|
|
|
|
//don't try to start a transfer if there should be none waiting
|
|
|
|
if (![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"])
|
|
|
|
return;
|
|
|
|
|
2006-07-02 13:41:22 +00:00
|
|
|
int desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"];
|
2006-06-23 15:06:27 +00:00
|
|
|
|
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
|
|
|
Torrent * torrent, * torrentToStart = nil;
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
{
|
2006-07-02 13:41:22 +00:00
|
|
|
//ignore the torrent just stopped
|
2006-06-23 22:32:01 +00:00
|
|
|
if (torrent == finishedTorrent)
|
2006-06-23 15:06:27 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if ([torrent isActive])
|
|
|
|
{
|
|
|
|
if (![torrent isSeeding])
|
|
|
|
{
|
2006-07-02 13:41:22 +00:00
|
|
|
desiredActive--;
|
|
|
|
if (desiredActive <= 0)
|
2006-06-23 15:06:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-24 04:42:55 +00:00
|
|
|
//use as next if it is waiting to start and either no previous or order value is lower
|
2006-06-23 15:44:18 +00:00
|
|
|
if ([torrent waitingToStart] && (!torrentToStart
|
2006-06-24 04:42:55 +00:00
|
|
|
|| [[torrentToStart orderValue] compare: [torrent orderValue]] == NSOrderedDescending))
|
2006-06-23 15:06:27 +00:00
|
|
|
torrentToStart = torrent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//since it hasn't returned, the queue amount has not been met
|
|
|
|
if (torrentToStart)
|
|
|
|
{
|
|
|
|
[torrentToStart startTransfer];
|
2006-07-02 13:41:22 +00:00
|
|
|
|
2006-06-23 15:06:27 +00:00
|
|
|
[self updateUI: nil];
|
2006-07-04 17:26:18 +00:00
|
|
|
[fInfoController updateInfoSettings];
|
2006-07-02 13:41:22 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-06-23 15:06:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-23 22:32:01 +00:00
|
|
|
- (void) globalStartSettingChange: (NSNotification *) notification
|
2006-06-23 17:40:56 +00:00
|
|
|
{
|
2006-07-01 22:06:31 +00:00
|
|
|
[self attemptToStartMultipleAuto: fTorrents];
|
2006-06-23 17:40:56 +00:00
|
|
|
|
|
|
|
[self updateUI: nil];
|
2006-07-04 17:26:18 +00:00
|
|
|
[fInfoController updateInfoSettings];
|
2006-07-02 13:41:22 +00:00
|
|
|
[self updateTorrentHistory];
|
2006-06-23 18:08:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-23 22:32:01 +00:00
|
|
|
- (void) torrentStartSettingChange: (NSNotification *) notification
|
|
|
|
{
|
2006-07-01 22:06:31 +00:00
|
|
|
[self attemptToStartMultipleAuto: [notification object]];
|
2006-06-23 22:32:01 +00:00
|
|
|
|
|
|
|
[self updateUI: nil];
|
2006-07-04 17:26:18 +00:00
|
|
|
[fInfoController updateInfoSettings];
|
2006-06-23 22:32:01 +00:00
|
|
|
[self updateTorrentHistory];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) attemptToStartAuto: (Torrent *) torrent
|
|
|
|
{
|
2006-07-01 22:06:31 +00:00
|
|
|
[self attemptToStartMultipleAuto: [NSArray arrayWithObject: torrent]];
|
|
|
|
}
|
|
|
|
|
2006-07-02 13:41:22 +00:00
|
|
|
//will try to start, taking into consideration the start preference
|
2006-07-01 22:06:31 +00:00
|
|
|
- (void) attemptToStartMultipleAuto: (NSArray *) torrents
|
|
|
|
{
|
|
|
|
NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
|
|
|
|
if ([startSetting isEqualToString: @"Start"])
|
2006-06-23 22:32:01 +00:00
|
|
|
{
|
2006-07-01 22:06:31 +00:00
|
|
|
NSEnumerator * enumerator = [torrents objectEnumerator];
|
|
|
|
Torrent * torrent;
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent waitingToStart])
|
|
|
|
[torrent startTransfer];
|
2006-06-23 22:32:01 +00:00
|
|
|
|
2006-07-01 22:06:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (![startSetting isEqualToString: @"Wait"])
|
|
|
|
return;
|
|
|
|
else;
|
2006-07-01 22:13:29 +00:00
|
|
|
|
|
|
|
//determine the number of downloads needed to start
|
|
|
|
int desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"];
|
|
|
|
|
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
|
|
|
Torrent * torrent;
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isActive] && ![torrent isSeeding])
|
|
|
|
{
|
|
|
|
desiredActive--;
|
|
|
|
if (desiredActive <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-07-01 22:06:31 +00:00
|
|
|
//sort torrents by order value
|
|
|
|
NSArray * sortedTorrents;
|
2006-07-01 22:13:29 +00:00
|
|
|
if ([torrents count] > 1 && desiredActive > 0)
|
2006-07-01 22:06:31 +00:00
|
|
|
{
|
|
|
|
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
|
|
@"orderValue" ascending: YES] autorelease];
|
|
|
|
NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
2006-07-02 13:41:22 +00:00
|
|
|
|
2006-07-01 22:06:31 +00:00
|
|
|
sortedTorrents = [torrents sortedArrayUsingDescriptors: descriptors];
|
|
|
|
[descriptors release];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sortedTorrents = torrents;
|
|
|
|
|
|
|
|
enumerator = [sortedTorrents objectEnumerator];
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
{
|
|
|
|
if ([torrent progress] >= 1.0)
|
2006-07-01 00:55:41 +00:00
|
|
|
[torrent startTransfer];
|
2006-07-01 22:06:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([torrent waitingToStart] && desiredActive > 0)
|
|
|
|
{
|
|
|
|
[torrent startTransfer];
|
|
|
|
desiredActive--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[torrent update];
|
2006-06-23 22:32:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-04 18:42:12 +00:00
|
|
|
- (void) reloadInspectorSettings: (NSNotification *) notification
|
2006-06-23 18:08:55 +00:00
|
|
|
{
|
2006-07-04 18:42:12 +00:00
|
|
|
[fInfoController updateInfoSettings];
|
2006-06-23 17:40:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (int) numberOfRowsInTableView: (NSTableView *) t
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-05-25 12:22:19 +00:00
|
|
|
return [fTorrents count];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) tableView: (NSTableView *) t willDisplayCell: (id) cell
|
2006-06-06 18:05:57 +00:00
|
|
|
forTableColumn: (NSTableColumn *) tableColumn row: (int) row
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
[cell setTorrent: [fTorrents objectAtIndex: row]];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-07-02 21:05:51 +00:00
|
|
|
- (BOOL) tableView: (NSTableView *) tableView writeRowsWithIndexes: (NSIndexSet *) indexes
|
|
|
|
toPasteboard: (NSPasteboard *) pasteboard
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-07-02 21:05:51 +00:00
|
|
|
if ([fSortType isEqualToString: @"Order"])
|
|
|
|
{
|
2006-07-02 21:57:51 +00:00
|
|
|
[pasteboard declareTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE] owner: self];
|
|
|
|
[pasteboard setData: [NSKeyedArchiver archivedDataWithRootObject: indexes]
|
|
|
|
forType: TORRENT_TABLE_VIEW_DATA_TYPE];
|
2006-07-02 21:05:51 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
return NO;
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-07-02 21:05:51 +00:00
|
|
|
- (NSDragOperation) tableView: (NSTableView *) t validateDrop: (id <NSDraggingInfo>) info
|
|
|
|
proposedRow: (int) row proposedDropOperation: (NSTableViewDropOperation) operation
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-02-10 20:46:44 +00:00
|
|
|
NSPasteboard * pasteboard = [info draggingPasteboard];
|
2006-07-02 21:05:51 +00:00
|
|
|
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
|
|
|
{
|
|
|
|
if ([[[pasteboard propertyListForType: NSFilenamesPboardType]
|
|
|
|
pathsMatchingExtensions: [NSArray arrayWithObject: @"torrent"]] count] > 0)
|
|
|
|
{
|
|
|
|
[fTableView setDropRow: -1 dropOperation: NSTableViewDropOn];
|
|
|
|
return NSDragOperationGeneric;
|
|
|
|
}
|
|
|
|
}
|
2006-07-02 21:57:51 +00:00
|
|
|
else if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
|
2006-07-02 21:05:51 +00:00
|
|
|
{
|
|
|
|
[fTableView setDropRow: row dropOperation: NSTableViewDropAbove];
|
|
|
|
return NSDragOperationGeneric;
|
|
|
|
}
|
|
|
|
else;
|
|
|
|
|
|
|
|
return NSDragOperationNone;
|
|
|
|
}
|
2006-02-10 20:46:44 +00:00
|
|
|
|
2006-07-02 21:05:51 +00:00
|
|
|
- (BOOL) tableView: (NSTableView *) t acceptDrop: (id <NSDraggingInfo>) info
|
|
|
|
row: (int) newRow dropOperation: (NSTableViewDropOperation) operation
|
|
|
|
{
|
|
|
|
NSPasteboard * pasteboard = [info draggingPasteboard];
|
|
|
|
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
|
|
|
[self application: NSApp openFiles: [[[info draggingPasteboard] propertyListForType: NSFilenamesPboardType]
|
|
|
|
pathsMatchingExtensions: [NSArray arrayWithObject: @"torrent"]]];
|
|
|
|
else
|
|
|
|
{
|
2006-07-02 21:53:36 +00:00
|
|
|
//remember selected rows if needed
|
|
|
|
NSArray * selectedTorrents = nil;
|
|
|
|
int numSelected = [fTableView numberOfSelectedRows];
|
|
|
|
if (numSelected > 0 && numSelected < [fTorrents count])
|
|
|
|
selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
|
2006-07-02 21:46:18 +00:00
|
|
|
|
2006-07-02 21:05:51 +00:00
|
|
|
NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData:
|
2006-07-02 21:57:51 +00:00
|
|
|
[pasteboard dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]];
|
2006-07-02 21:05:51 +00:00
|
|
|
|
2006-07-02 21:46:18 +00:00
|
|
|
//move torrent in array
|
|
|
|
NSArray * movingTorrents = [[self torrentsAtIndexes: indexes] retain];
|
|
|
|
[fTorrents removeObjectsInArray: movingTorrents];
|
2006-07-02 21:05:51 +00:00
|
|
|
|
2006-07-02 21:46:18 +00:00
|
|
|
//determine the insertion index now that transfers to move have been removed
|
|
|
|
int i, decrease = 0;
|
|
|
|
for (i = [indexes firstIndex]; i < newRow && i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
|
|
|
decrease++;
|
2006-07-02 21:05:51 +00:00
|
|
|
|
2006-07-02 21:46:18 +00:00
|
|
|
//insert objects at new location
|
|
|
|
for (i = 0; i < [movingTorrents count]; i++)
|
|
|
|
[fTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: newRow - decrease + i];
|
2006-07-02 21:05:51 +00:00
|
|
|
|
2006-07-02 21:46:18 +00:00
|
|
|
[movingTorrents release];
|
2006-07-02 21:05:51 +00:00
|
|
|
|
|
|
|
//redo order values
|
2006-07-02 21:46:18 +00:00
|
|
|
int low = [indexes firstIndex], high = [indexes lastIndex];
|
|
|
|
if (newRow < low)
|
|
|
|
low = newRow;
|
|
|
|
else if (newRow > high + 1)
|
|
|
|
high = newRow - 1;
|
|
|
|
else;
|
|
|
|
|
2006-07-02 21:05:51 +00:00
|
|
|
for (i = low; i <= high; i++)
|
|
|
|
[[fTorrents objectAtIndex: i] setOrderValue: i];
|
|
|
|
|
|
|
|
[fTableView reloadData];
|
2006-07-02 21:53:36 +00:00
|
|
|
|
|
|
|
//set selected rows if needed
|
|
|
|
if (selectedTorrents)
|
|
|
|
{
|
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
|
|
|
|
NSMutableIndexSet * indexSet = [[NSMutableIndexSet alloc] init];
|
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
[indexSet addIndex: [fTorrents indexOfObject: torrent]];
|
|
|
|
|
|
|
|
[fTableView selectRowIndexes: indexSet byExtendingSelection: NO];
|
|
|
|
[indexSet release];
|
|
|
|
}
|
2006-07-02 21:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return YES;
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) tableViewSelectionDidChange: (NSNotification *) notification
|
|
|
|
{
|
2006-07-04 18:42:12 +00:00
|
|
|
[fInfoController updateInfoForTorrents: [self torrentsAtIndexes: [fTableView selectedRowIndexes]]];
|
2006-06-06 18:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) toggleStatusBar: (id) sender
|
|
|
|
{
|
|
|
|
[self showStatusBar: !fStatusBarVisible animate: YES];
|
|
|
|
[fDefaults setBool: fStatusBarVisible forKey: @"StatusBar"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) showStatusBar: (BOOL) show animate: (BOOL) animate
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
if (show == fStatusBarVisible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NSRect frame = [fWindow frame];
|
|
|
|
float heightChange = [fStatusBar frame].size.height;
|
|
|
|
if (!show)
|
|
|
|
heightChange *= -1;
|
|
|
|
|
|
|
|
frame.size.height += heightChange;
|
|
|
|
frame.origin.y -= heightChange;
|
|
|
|
|
|
|
|
fStatusBarVisible = !fStatusBarVisible;
|
|
|
|
|
|
|
|
[self updateUI: nil];
|
|
|
|
|
|
|
|
//set views to not autoresize
|
|
|
|
unsigned int statsMask = [fStatusBar autoresizingMask];
|
|
|
|
unsigned int scrollMask = [fScrollView autoresizingMask];
|
|
|
|
[fStatusBar setAutoresizingMask: 0];
|
|
|
|
[fScrollView setAutoresizingMask: 0];
|
|
|
|
|
|
|
|
[fWindow setFrame: frame display: YES animate: animate];
|
|
|
|
|
|
|
|
//re-enable autoresize
|
|
|
|
[fStatusBar setAutoresizingMask: statsMask];
|
|
|
|
[fScrollView setAutoresizingMask: scrollMask];
|
|
|
|
|
|
|
|
//change min size
|
|
|
|
NSSize minSize = [fWindow contentMinSize];
|
|
|
|
minSize.height += heightChange;
|
|
|
|
[fWindow setContentMinSize: minSize];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-07-01 18:02:36 +00:00
|
|
|
- (void) toggleAdvancedBar: (id) sender
|
|
|
|
{
|
|
|
|
[fAdvancedBarItem setState: ![fAdvancedBarItem state]];
|
|
|
|
[fDefaults setBool: [fAdvancedBarItem state] forKey: @"UseAdvancedBar"];
|
|
|
|
|
|
|
|
[fTableView display];
|
|
|
|
}
|
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
- (NSToolbarItem *) toolbar: (NSToolbar *) t itemForItemIdentifier:
|
|
|
|
(NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
|
|
|
|
{
|
2006-01-12 18:57:23 +00:00
|
|
|
NSToolbarItem * item = [[NSToolbarItem alloc] initWithItemIdentifier: ident];
|
2006-01-12 17:43:21 +00:00
|
|
|
|
|
|
|
if( [ident isEqualToString: TOOLBAR_OPEN] )
|
|
|
|
{
|
|
|
|
[item setLabel: @"Open"];
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setPaletteLabel: @"Open Torrent Files"];
|
2006-05-25 12:22:19 +00:00
|
|
|
[item setToolTip: @"Open torrent files"];
|
2006-01-12 18:20:48 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"Open.png"]];
|
|
|
|
[item setTarget: self];
|
|
|
|
[item setAction: @selector( openShowSheet: )];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
else if( [ident isEqualToString: TOOLBAR_REMOVE] )
|
|
|
|
{
|
|
|
|
[item setLabel: @"Remove"];
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setPaletteLabel: @"Remove Selected"];
|
2006-06-16 14:30:59 +00:00
|
|
|
[item setToolTip: @"Remove selected transfers"];
|
2006-01-12 18:20:48 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"Remove.png"]];
|
|
|
|
[item setTarget: self];
|
2006-06-16 14:19:04 +00:00
|
|
|
[item setAction: @selector( removeNoDelete: )];
|
2006-01-12 18:20:48 +00:00
|
|
|
}
|
2006-01-12 17:43:21 +00:00
|
|
|
else if( [ident isEqualToString: TOOLBAR_INFO] )
|
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setLabel: @"Inspector"];
|
|
|
|
[item setPaletteLabel: @"Show/Hide Inspector"];
|
2006-06-07 22:02:28 +00:00
|
|
|
[item setToolTip: @"Display torrent inspector"];
|
2006-01-12 18:20:48 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"Info.png"]];
|
|
|
|
[item setTarget: self];
|
|
|
|
[item setAction: @selector( showInfo: )];
|
2006-06-06 18:05:57 +00:00
|
|
|
}
|
|
|
|
else if( [ident isEqualToString: TOOLBAR_PAUSE_ALL] )
|
|
|
|
{
|
|
|
|
[item setLabel: @"Pause All"];
|
|
|
|
[item setPaletteLabel: [item label]];
|
2006-06-16 14:30:59 +00:00
|
|
|
[item setToolTip: @"Pause all transfers"];
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"PauseAll.png"]];
|
|
|
|
[item setTarget: self];
|
|
|
|
[item setAction: @selector( stopAllTorrents: )];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
2006-01-12 18:54:46 +00:00
|
|
|
else if( [ident isEqualToString: TOOLBAR_RESUME_ALL] )
|
|
|
|
{
|
|
|
|
[item setLabel: @"Resume All"];
|
|
|
|
[item setPaletteLabel: [item label]];
|
2006-06-16 14:30:59 +00:00
|
|
|
[item setToolTip: @"Resume all transfers"];
|
2006-01-21 02:34:14 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"ResumeAll.png"]];
|
2006-01-12 18:54:46 +00:00
|
|
|
[item setTarget: self];
|
|
|
|
[item setAction: @selector( resumeAllTorrents: )];
|
|
|
|
}
|
2006-06-06 18:05:57 +00:00
|
|
|
else if( [ident isEqualToString: TOOLBAR_PAUSE_SELECTED] )
|
2006-01-12 18:54:46 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setLabel: @"Pause"];
|
|
|
|
[item setPaletteLabel: @"Pause Selected"];
|
2006-06-16 14:30:59 +00:00
|
|
|
[item setToolTip: @"Pause selected transfers"];
|
2006-06-07 20:10:15 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"PauseSelected.png"]];
|
2006-01-12 18:54:46 +00:00
|
|
|
[item setTarget: self];
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setAction: @selector( stopTorrent: )];
|
|
|
|
}
|
|
|
|
else if( [ident isEqualToString: TOOLBAR_RESUME_SELECTED] )
|
|
|
|
{
|
|
|
|
[item setLabel: @"Resume"];
|
|
|
|
[item setPaletteLabel: @"Resume Selected"];
|
2006-06-16 14:30:59 +00:00
|
|
|
[item setToolTip: @"Resume selected transfers"];
|
2006-06-07 20:10:15 +00:00
|
|
|
[item setImage: [NSImage imageNamed: @"ResumeSelected.png"]];
|
2006-06-06 18:05:57 +00:00
|
|
|
[item setTarget: self];
|
|
|
|
[item setAction: @selector( resumeTorrent: )];
|
2006-01-12 18:54:46 +00:00
|
|
|
}
|
2006-01-12 17:43:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[item release];
|
2006-04-07 13:09:19 +00:00
|
|
|
return nil;
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) t
|
|
|
|
{
|
2006-01-12 18:54:46 +00:00
|
|
|
return [NSArray arrayWithObjects:
|
|
|
|
TOOLBAR_OPEN, TOOLBAR_REMOVE,
|
2006-06-06 18:05:57 +00:00
|
|
|
TOOLBAR_PAUSE_SELECTED, TOOLBAR_RESUME_SELECTED,
|
2006-07-01 18:02:36 +00:00
|
|
|
TOOLBAR_PAUSE_ALL, TOOLBAR_RESUME_ALL, TOOLBAR_INFO,
|
2006-01-12 18:54:46 +00:00
|
|
|
NSToolbarSeparatorItemIdentifier,
|
|
|
|
NSToolbarSpaceItemIdentifier,
|
|
|
|
NSToolbarFlexibleSpaceItemIdentifier,
|
2006-05-25 12:22:19 +00:00
|
|
|
NSToolbarCustomizeToolbarItemIdentifier, nil];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) t
|
|
|
|
{
|
2006-01-12 18:54:46 +00:00
|
|
|
return [NSArray arrayWithObjects:
|
|
|
|
TOOLBAR_OPEN, TOOLBAR_REMOVE,
|
2006-01-12 18:57:23 +00:00
|
|
|
NSToolbarSeparatorItemIdentifier,
|
2006-05-25 12:22:19 +00:00
|
|
|
TOOLBAR_PAUSE_ALL, TOOLBAR_RESUME_ALL,
|
2006-01-12 18:54:46 +00:00
|
|
|
NSToolbarFlexibleSpaceItemIdentifier,
|
2006-05-25 12:22:19 +00:00
|
|
|
TOOLBAR_INFO, nil];
|
2006-01-12 18:54:46 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
2006-06-16 14:30:59 +00:00
|
|
|
NSString * ident = [toolbarItem itemIdentifier];
|
2006-01-29 01:20:22 +00:00
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
//enable remove item
|
2006-06-16 14:30:59 +00:00
|
|
|
if ([ident isEqualToString: TOOLBAR_REMOVE])
|
2006-04-07 13:09:19 +00:00
|
|
|
return [fTableView numberOfSelectedRows] > 0;
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
//enable pause all item
|
2006-06-16 14:30:59 +00:00
|
|
|
if ([ident isEqualToString: TOOLBAR_PAUSE_ALL])
|
2006-06-06 18:05:57 +00:00
|
|
|
{
|
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
2006-06-21 14:07:56 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isActive])
|
2006-06-06 18:05:57 +00:00
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
2006-01-29 01:20:22 +00:00
|
|
|
|
|
|
|
//enable resume all item
|
2006-06-16 14:30:59 +00:00
|
|
|
if ([ident isEqualToString: TOOLBAR_RESUME_ALL])
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
2006-06-21 14:07:56 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isPaused])
|
2006-03-23 12:39:39 +00:00
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
2006-01-29 01:20:22 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
//enable pause item
|
2006-06-16 14:30:59 +00:00
|
|
|
if ([ident isEqualToString: TOOLBAR_PAUSE_SELECTED])
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
2006-06-21 14:07:56 +00:00
|
|
|
if ([[fTorrents objectAtIndex: i] isActive])
|
2006-06-06 18:05:57 +00:00
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//enable resume item
|
2006-06-16 14:30:59 +00:00
|
|
|
if ([ident isEqualToString: TOOLBAR_RESUME_SELECTED])
|
2006-06-06 18:05:57 +00:00
|
|
|
{
|
|
|
|
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
2006-06-21 14:07:56 +00:00
|
|
|
if ([[fTorrents objectAtIndex: i] isPaused])
|
2006-03-23 12:39:39 +00:00
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
|
2006-01-12 18:54:46 +00:00
|
|
|
{
|
2006-01-29 01:20:22 +00:00
|
|
|
SEL action = [menuItem action];
|
|
|
|
|
2006-06-10 04:12:40 +00:00
|
|
|
//only enable some items if it is in a context menu or the window is useable
|
2006-07-01 18:02:36 +00:00
|
|
|
BOOL canUseMenu = [fWindow isKeyWindow] || [[[menuItem menu] title] isEqualToString: @"Context"];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-01-12 18:54:46 +00:00
|
|
|
//enable show info
|
2006-01-29 01:20:22 +00:00
|
|
|
if (action == @selector(showInfo:))
|
2006-01-12 18:54:46 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
NSString * title = [[fInfoController window] isVisible] ? @"Hide Inspector" : @"Show Inspector";
|
|
|
|
if (![[menuItem title] isEqualToString: title])
|
|
|
|
[menuItem setTitle: title];
|
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
return YES;
|
2006-01-12 18:54:46 +00:00
|
|
|
}
|
2006-05-01 00:15:18 +00:00
|
|
|
|
2006-07-01 18:02:36 +00:00
|
|
|
//enable prev/next inspector tab
|
2006-06-06 18:05:57 +00:00
|
|
|
if (action == @selector(setInfoTab:))
|
|
|
|
return [[fInfoController window] isVisible];
|
|
|
|
|
|
|
|
//enable toggle status bar
|
2006-05-01 00:15:18 +00:00
|
|
|
if (action == @selector(toggleStatusBar:))
|
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
NSString * title = fStatusBarVisible ? @"Hide Status Bar" : @"Show Status Bar";
|
|
|
|
if (![[menuItem title] isEqualToString: title])
|
|
|
|
[menuItem setTitle: title];
|
|
|
|
|
2006-06-10 04:12:40 +00:00
|
|
|
return canUseMenu;
|
2006-05-01 00:15:18 +00:00
|
|
|
}
|
2006-01-29 01:20:22 +00:00
|
|
|
|
|
|
|
//enable resume all item
|
|
|
|
if (action == @selector(resumeAllTorrents:))
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
2006-04-25 16:31:19 +00:00
|
|
|
Torrent * torrent;
|
2006-04-07 13:09:19 +00:00
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
2006-06-21 14:07:56 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isPaused])
|
2006-03-23 12:39:39 +00:00
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
2006-01-29 01:20:22 +00:00
|
|
|
|
|
|
|
//enable pause all item
|
|
|
|
if (action == @selector(stopAllTorrents:))
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
2006-04-07 13:09:19 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
2006-06-21 14:07:56 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isActive])
|
2006-03-23 12:39:39 +00:00
|
|
|
return YES;
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2006-07-01 18:02:36 +00:00
|
|
|
//enable reveal in finder
|
2006-06-06 18:05:57 +00:00
|
|
|
if (action == @selector(revealFile:))
|
2006-06-10 04:12:40 +00:00
|
|
|
return canUseMenu && [fTableView numberOfSelectedRows] > 0;
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-01-12 18:54:46 +00:00
|
|
|
//enable remove items
|
2006-06-15 02:07:50 +00:00
|
|
|
if (action == @selector(removeNoDelete:) || action == @selector(removeDeleteData:)
|
|
|
|
|| action == @selector(removeDeleteTorrent:) || action == @selector(removeDeleteBoth:))
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
2006-06-30 02:57:50 +00:00
|
|
|
BOOL warning = NO,
|
|
|
|
onlyDownloading = [fDefaults boolForKey: @"CheckRemoveDownloading"],
|
2006-06-21 14:07:56 +00:00
|
|
|
canDelete = action != @selector(removeDeleteTorrent:) && action != @selector(removeDeleteBoth:);
|
2006-04-25 16:31:19 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
|
|
|
{
|
|
|
|
torrent = [fTorrents objectAtIndex: i];
|
2006-06-30 01:14:52 +00:00
|
|
|
if (!warning && [torrent isActive])
|
2006-06-17 23:29:27 +00:00
|
|
|
{
|
2006-06-30 01:14:52 +00:00
|
|
|
warning = onlyDownloading ? ![torrent isSeeding] : YES;
|
|
|
|
if (warning && canDelete)
|
2006-06-17 23:29:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!canDelete && [torrent publicTorrent])
|
|
|
|
{
|
2006-06-15 02:07:50 +00:00
|
|
|
canDelete = YES;
|
2006-06-30 01:14:52 +00:00
|
|
|
if (warning)
|
2006-06-17 23:29:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-25 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
//append or remove ellipsis when needed
|
2006-06-14 20:08:51 +00:00
|
|
|
NSString * title = [menuItem title], * ellipsis = [NSString ellipsis];
|
2006-06-30 01:14:52 +00:00
|
|
|
if (warning && [fDefaults boolForKey: @"CheckRemove"])
|
2006-01-12 18:57:23 +00:00
|
|
|
{
|
2006-06-14 20:08:51 +00:00
|
|
|
if (![title hasSuffix: ellipsis])
|
|
|
|
[menuItem setTitle: [title stringByAppendingEllipsis]];
|
2006-01-12 18:57:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-14 20:08:51 +00:00
|
|
|
if ([title hasSuffix: ellipsis])
|
2006-06-21 14:07:56 +00:00
|
|
|
[menuItem setTitle: [title substringToIndex: [title rangeOfString: ellipsis].location]];
|
2006-01-12 18:57:23 +00:00
|
|
|
}
|
2006-06-15 02:07:50 +00:00
|
|
|
|
|
|
|
return canUseMenu && canDelete && [fTableView numberOfSelectedRows] > 0;
|
2006-04-07 13:09:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//enable pause item
|
|
|
|
if( action == @selector(stopTorrent:) )
|
|
|
|
{
|
2006-06-10 04:12:40 +00:00
|
|
|
if (!canUseMenu)
|
2006-05-25 12:22:19 +00:00
|
|
|
return NO;
|
|
|
|
|
2006-04-25 16:31:19 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
|
|
|
{
|
|
|
|
torrent = [fTorrents objectAtIndex: i];
|
|
|
|
if ([torrent isActive])
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//enable resume item
|
2006-04-07 13:09:19 +00:00
|
|
|
if( action == @selector(resumeTorrent:) )
|
|
|
|
{
|
2006-06-10 04:12:40 +00:00
|
|
|
if (!canUseMenu)
|
2006-05-25 12:22:19 +00:00
|
|
|
return NO;
|
|
|
|
|
2006-04-25 16:31:19 +00:00
|
|
|
Torrent * torrent;
|
|
|
|
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
|
|
|
{
|
|
|
|
torrent = [fTorrents objectAtIndex: i];
|
|
|
|
if ([torrent isPaused])
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
return NO;
|
2006-01-12 18:54:46 +00:00
|
|
|
}
|
2006-05-25 12:22:19 +00:00
|
|
|
|
2006-07-01 18:02:36 +00:00
|
|
|
//enable sort and advanced bar items
|
|
|
|
if (action == @selector(setSort:) || (action == @selector(toggleAdvancedBar:)))
|
2006-06-10 04:12:40 +00:00
|
|
|
return canUseMenu;
|
2006-06-10 23:29:47 +00:00
|
|
|
|
|
|
|
//enable copy torrent file item
|
|
|
|
if( action == @selector(copyTorrentFile:) )
|
|
|
|
{
|
|
|
|
return canUseMenu && [fTableView numberOfSelectedRows] > 0;
|
|
|
|
}
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-01-12 18:57:23 +00:00
|
|
|
return YES;
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 23:07:28 +00:00
|
|
|
- (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-04-05 12:21:16 +00:00
|
|
|
NSEnumerator * enumerator;
|
2006-03-23 12:39:39 +00:00
|
|
|
Torrent * torrent;
|
2006-04-05 12:21:16 +00:00
|
|
|
BOOL active;
|
2006-01-12 17:43:21 +00:00
|
|
|
|
|
|
|
switch( messageType )
|
|
|
|
{
|
|
|
|
case kIOMessageSystemWillSleep:
|
|
|
|
/* Close all connections before going to sleep and remember
|
|
|
|
we should resume when we wake up */
|
2006-05-25 12:22:19 +00:00
|
|
|
[fTorrents makeObjectsPerformSelector: @selector(sleep)];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
|
|
|
/* Wait for torrents to stop (5 seconds timeout) */
|
|
|
|
NSDate * start = [NSDate date];
|
|
|
|
enumerator = [fTorrents objectEnumerator];
|
|
|
|
while( ( torrent = [enumerator nextObject] ) )
|
|
|
|
{
|
|
|
|
while( [[NSDate date] timeIntervalSinceDate: start] < 5 &&
|
|
|
|
![torrent isPaused] )
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-03-23 12:39:39 +00:00
|
|
|
usleep( 100000 );
|
|
|
|
[torrent update];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IOAllowPowerChange( fRootPort, (long) messageArgument );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kIOMessageCanSystemSleep:
|
2006-01-29 01:20:22 +00:00
|
|
|
/* Prevent idle sleep unless all paused */
|
2006-04-05 12:21:16 +00:00
|
|
|
active = NO;
|
|
|
|
enumerator = [fTorrents objectEnumerator];
|
2006-06-06 18:05:57 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
if ([torrent isActive])
|
|
|
|
{
|
2006-04-05 12:21:16 +00:00
|
|
|
active = YES;
|
2006-06-06 18:05:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-05 12:21:16 +00:00
|
|
|
|
|
|
|
if (active)
|
2006-01-29 01:20:22 +00:00
|
|
|
IOCancelPowerChange( fRootPort, (long) messageArgument );
|
|
|
|
else
|
|
|
|
IOAllowPowerChange( fRootPort, (long) messageArgument );
|
2006-01-12 17:43:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kIOMessageSystemHasPoweredOn:
|
|
|
|
/* Resume download after we wake up */
|
2006-05-25 12:22:19 +00:00
|
|
|
[fTorrents makeObjectsPerformSelector: @selector(wakeUp)];
|
2006-01-12 17:43:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-19 23:07:28 +00:00
|
|
|
- (NSRect) windowWillUseStandardFrame: (NSWindow *) w defaultFrame: (NSRect) defaultFrame
|
2006-01-12 17:43:21 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
NSRect windowRect = [fWindow frame];
|
|
|
|
float newHeight = windowRect.size.height - [fScrollView frame].size.height
|
2006-06-18 03:40:11 +00:00
|
|
|
+ [fTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height) + 30.0;
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-05-25 12:22:19 +00:00
|
|
|
float minHeight = [fWindow minSize].height;
|
|
|
|
if (newHeight < minHeight)
|
|
|
|
newHeight = minHeight;
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
windowRect.origin.y -= (newHeight - windowRect.size.height);
|
|
|
|
windowRect.size.height = newHeight;
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
return windowRect;
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) showMainWindow: (id) sender
|
|
|
|
{
|
2006-01-12 18:57:23 +00:00
|
|
|
[fWindow makeKeyAndOrderFront: nil];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) windowDidBecomeKey: (NSNotification *) notification
|
|
|
|
{
|
|
|
|
fCompleted = 0;
|
|
|
|
}
|
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
- (void) linkHomepage: (id) sender
|
|
|
|
{
|
2006-06-17 23:00:12 +00:00
|
|
|
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: WEBSITE_URL]];
|
2006-01-12 17:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) linkForums: (id) sender
|
|
|
|
{
|
2006-06-17 23:00:12 +00:00
|
|
|
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: FORUM_URL]];
|
2006-01-12 18:47:30 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:40:47 +00:00
|
|
|
- (void) notifyGrowl: (NSString * ) file
|
2006-01-12 18:33:20 +00:00
|
|
|
{
|
2006-06-19 23:07:28 +00:00
|
|
|
if (!fHasGrowl)
|
2006-01-12 18:47:30 +00:00
|
|
|
return;
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-06-19 23:07:28 +00:00
|
|
|
NSString * growlScript = [NSString stringWithFormat:
|
2006-01-12 18:40:47 +00:00
|
|
|
@"tell application \"System Events\"\n"
|
|
|
|
" if exists application process \"GrowlHelperApp\" then\n"
|
|
|
|
" tell application \"GrowlHelperApp\"\n "
|
|
|
|
" notify with name \"Download Complete\""
|
|
|
|
" title \"Download Complete\""
|
|
|
|
" description \"%@\""
|
|
|
|
" application name \"Transmission\"\n"
|
|
|
|
" end tell\n"
|
|
|
|
" end if\n"
|
|
|
|
"end tell", file];
|
2006-06-19 23:07:28 +00:00
|
|
|
|
|
|
|
NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
|
|
|
|
NSDictionary * error;
|
2006-06-21 14:07:56 +00:00
|
|
|
if (![appleScript executeAndReturnError: & error])
|
2006-06-19 23:07:28 +00:00
|
|
|
NSLog(@"Growl notify failed");
|
2006-01-12 18:40:47 +00:00
|
|
|
[appleScript release];
|
2006-01-12 18:33:20 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 23:07:28 +00:00
|
|
|
- (void) growlRegister
|
2006-03-23 12:39:39 +00:00
|
|
|
{
|
2006-06-19 23:07:28 +00:00
|
|
|
if (!fHasGrowl)
|
2006-01-12 18:47:30 +00:00
|
|
|
return;
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-06-19 23:07:28 +00:00
|
|
|
NSString * growlScript = [NSString stringWithFormat:
|
2006-01-12 18:40:47 +00:00
|
|
|
@"tell application \"System Events\"\n"
|
|
|
|
" if exists application process \"GrowlHelperApp\" then\n"
|
|
|
|
" tell application \"GrowlHelperApp\"\n"
|
|
|
|
" register as application \"Transmission\" "
|
|
|
|
" all notifications {\"Download Complete\"}"
|
|
|
|
" default notifications {\"Download Complete\"}"
|
|
|
|
" icon of application \"Transmission\"\n"
|
|
|
|
" end tell\n"
|
|
|
|
" end if\n"
|
|
|
|
"end tell"];
|
2006-03-23 12:39:39 +00:00
|
|
|
|
2006-06-19 23:07:28 +00:00
|
|
|
NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
|
|
|
|
NSDictionary * error;
|
2006-06-21 14:07:56 +00:00
|
|
|
if (![appleScript executeAndReturnError: & error])
|
2006-06-19 23:07:28 +00:00
|
|
|
NSLog(@"Growl registration failed");
|
2006-01-12 18:40:47 +00:00
|
|
|
[appleScript release];
|
2006-01-12 18:33:20 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) checkUpdate: (id) sender
|
2006-01-29 22:01:08 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
[fPrefsController checkUpdate];
|
2006-01-29 22:01:08 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 18:05:57 +00:00
|
|
|
- (void) prepareForUpdate: (NSNotification *) notification
|
2006-01-29 22:01:08 +00:00
|
|
|
{
|
2006-06-06 18:05:57 +00:00
|
|
|
fUpdateInProgress = YES;
|
2006-01-29 22:01:08 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
@end
|