mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
Patch by Brian Webster to automatically download and open torrents by dragging url's onto the window/dock icon.
This commit is contained in:
parent
8ebdd6070a
commit
ed82ce2223
4 changed files with 362 additions and 265 deletions
|
@ -1,202 +1,204 @@
|
|||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2005-2006 Transmission authors and contributors
|
||||
*
|
||||
* 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <transmission.h>
|
||||
#import "PrefsController.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "MessageWindowController.h"
|
||||
#import "Badger.h"
|
||||
#import "ImageBackgroundView.h"
|
||||
#import "BarButton.h"
|
||||
|
||||
#import <Growl/Growl.h>
|
||||
|
||||
@class TorrentTableView;
|
||||
|
||||
@interface Controller : NSObject <GrowlApplicationBridgeDelegate>
|
||||
{
|
||||
tr_handle_t * fLib;
|
||||
int fCompleted;
|
||||
|
||||
NSMutableArray * fTorrents, * fDisplayedTorrents;
|
||||
|
||||
PrefsController * fPrefsController;
|
||||
NSUserDefaults * fDefaults;
|
||||
InfoWindowController * fInfoController;
|
||||
MessageWindowController * fMessageController;
|
||||
|
||||
IBOutlet NSWindow * fWindow;
|
||||
IBOutlet NSScrollView * fScrollView;
|
||||
IBOutlet TorrentTableView * fTableView;
|
||||
NSToolbar * fToolbar;
|
||||
|
||||
IBOutlet NSMenuItem * fOpenIgnoreDownloadFolder;
|
||||
|
||||
IBOutlet NSButton * fActionButton, * fSpeedLimitButton;
|
||||
NSTimer * fSpeedLimitTimer;
|
||||
|
||||
IBOutlet ImageBackgroundView * fStatusBar;
|
||||
IBOutlet NSTextField * fTotalDLField, * fTotalULField, * fTotalTorrentsField;
|
||||
|
||||
NSString * fSortType;
|
||||
IBOutlet NSMenuItem * fNameSortItem, * fStateSortItem, * fProgressSortItem,
|
||||
* fDateSortItem, * fOrderSortItem,
|
||||
* fNameSortActionItem, * fStateSortActionItem, * fProgressSortActionItem,
|
||||
* fDateSortActionItem, * fOrderSortActionItem;
|
||||
|
||||
IBOutlet ImageBackgroundView * fFilterBar;
|
||||
NSString * fFilterType;
|
||||
IBOutlet BarButton * fNoFilterButton, * fPauseFilterButton,
|
||||
* fSeedFilterButton, * fDownloadFilterButton;
|
||||
IBOutlet NSSearchField * fSearchFilterField;
|
||||
IBOutlet NSMenuItem * fNextFilterItem, * fPrevFilterItem;
|
||||
|
||||
IBOutlet NSMenuItem * fNextInfoTabItem, * fPrevInfoTabItem;
|
||||
|
||||
IBOutlet NSMenu * fUploadMenu, * fDownloadMenu;
|
||||
IBOutlet NSMenuItem * fUploadLimitItem, * fUploadNoLimitItem,
|
||||
* fDownloadLimitItem, * fDownloadNoLimitItem;
|
||||
|
||||
io_connect_t fRootPort;
|
||||
NSTimer * fTimer;
|
||||
|
||||
IBOutlet SUUpdater * fUpdater;
|
||||
BOOL fUpdateInProgress;
|
||||
|
||||
Badger * fBadger;
|
||||
|
||||
NSMutableArray * fAutoImportedNames;
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames;
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files;
|
||||
- (void) openShowSheet: (id) sender;
|
||||
|
||||
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
|
||||
|
||||
- (void) resumeSelectedTorrents: (id) sender;
|
||||
- (void) resumeAllTorrents: (id) sender;
|
||||
- (void) resumeTorrents: (NSArray *) torrents;
|
||||
|
||||
- (void) resumeSelectedTorrentsNoWait: (id) sender;
|
||||
- (void) resumeWaitingTorrents: (id) sender;
|
||||
- (void) resumeTorrentsNoWait: (NSArray *) torrents;
|
||||
|
||||
- (void) stopSelectedTorrents: (id) sender;
|
||||
- (void) stopAllTorrents: (id) sender;
|
||||
- (void) stopTorrents: (NSArray *) torrents;
|
||||
|
||||
- (void) removeTorrents: (NSArray *) torrents
|
||||
deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteData;
|
||||
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode
|
||||
contextInfo: (NSDictionary *) dict;
|
||||
- (void) confirmRemoveTorrents: (NSArray *) torrents
|
||||
deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent;
|
||||
- (void) removeNoDelete: (id) sender;
|
||||
- (void) removeDeleteData: (id) sender;
|
||||
- (void) removeDeleteTorrent: (id) sender;
|
||||
- (void) removeDeleteDataAndTorrent: (id) sender;
|
||||
|
||||
- (void) copyTorrentFile: (id) sender;
|
||||
- (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents;
|
||||
- (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (int) code
|
||||
contextInfo: (NSMutableArray *) torrents;
|
||||
|
||||
- (void) revealFile: (id) sender;
|
||||
|
||||
- (void) showPreferenceWindow: (id) sender;
|
||||
|
||||
- (void) showInfo: (id) sender;
|
||||
- (void) setInfoTab: (id) sender;
|
||||
|
||||
- (void) showMessageWindow: (id) sender;
|
||||
|
||||
- (void) updateControlTint: (NSNotification *) notification;
|
||||
|
||||
- (void) updateUI: (NSTimer *) timer;
|
||||
- (void) torrentFinishedDownloading: (NSNotification *) notification;
|
||||
- (void) updateTorrentHistory;
|
||||
|
||||
- (void) sortTorrents;
|
||||
- (void) sortTorrentsIgnoreSelected;
|
||||
- (void) setSort: (id) sender;
|
||||
- (void) applyFilter: (id) sender;
|
||||
- (void) setFilter: (id) sender;
|
||||
- (void) switchFilter: (id) sender;
|
||||
|
||||
- (void) applySpeedLimit: (id) sender;
|
||||
- (void) toggleSpeedLimit: (id) sender;
|
||||
- (void) autoSpeedLimitChange: (NSNotification *) notification;
|
||||
- (void) autoSpeedLimit: (NSTimer *) timer;
|
||||
|
||||
- (void) setLimitGlobalEnabled: (id) sender;
|
||||
- (void) setQuickLimitGlobal: (id) sender;
|
||||
|
||||
- (void) setQuickRatioGlobal: (id) sender;
|
||||
|
||||
- (void) checkWaitingForStopped: (NSNotification *) notification;
|
||||
- (void) checkToStartWaiting: (Torrent *) finishedTorrent;
|
||||
- (void) torrentStartSettingChange: (NSNotification *) notification;
|
||||
- (void) globalStartSettingChange: (NSNotification *) notification;
|
||||
|
||||
- (void) torrentStoppedForRatio: (NSNotification *) notification;
|
||||
|
||||
- (void) attemptToStartAuto: (Torrent *) torrent;
|
||||
- (void) attemptToStartMultipleAuto: (NSArray *) torrents;
|
||||
|
||||
- (void) changeAutoImport;
|
||||
- (void) checkAutoImportDirectory;
|
||||
|
||||
- (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument;
|
||||
|
||||
- (void) toggleSmallView: (id) sender;
|
||||
|
||||
- (void) toggleStatusBar: (id) sender;
|
||||
- (void) showStatusBar: (BOOL) show animate: (BOOL) animate;
|
||||
- (void) toggleFilterBar: (id) sender;
|
||||
- (void) showFilterBar: (BOOL) show animate: (BOOL) animate;
|
||||
|
||||
- (void) toggleAdvancedBar: (id) sender;
|
||||
|
||||
- (void) doNothing: (id) sender; //needed for menu items that use bindings with no associated action
|
||||
|
||||
- (void) resetDockBadge: (NSNotification *) notification;
|
||||
|
||||
- (void) setWindowSizeToFit;
|
||||
- (NSRect) sizedWindowFrame;
|
||||
|
||||
- (void) showMainWindow: (id) sender;
|
||||
- (void) linkHomepage: (id) sender;
|
||||
- (void) linkForums: (id) sender;
|
||||
|
||||
- (void) prepareForUpdate: (NSNotification *) notification;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2005-2006 Transmission authors and contributors
|
||||
*
|
||||
* 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <transmission.h>
|
||||
#import "PrefsController.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "MessageWindowController.h"
|
||||
#import "Badger.h"
|
||||
#import "ImageBackgroundView.h"
|
||||
#import "BarButton.h"
|
||||
|
||||
#import <Growl/Growl.h>
|
||||
|
||||
@class TorrentTableView;
|
||||
|
||||
@interface Controller : NSObject <GrowlApplicationBridgeDelegate>
|
||||
{
|
||||
tr_handle_t * fLib;
|
||||
int fCompleted;
|
||||
|
||||
NSMutableArray * fTorrents, * fDisplayedTorrents;
|
||||
|
||||
PrefsController * fPrefsController;
|
||||
NSUserDefaults * fDefaults;
|
||||
InfoWindowController * fInfoController;
|
||||
MessageWindowController * fMessageController;
|
||||
|
||||
IBOutlet NSWindow * fWindow;
|
||||
IBOutlet NSScrollView * fScrollView;
|
||||
IBOutlet TorrentTableView * fTableView;
|
||||
NSToolbar * fToolbar;
|
||||
|
||||
IBOutlet NSMenuItem * fOpenIgnoreDownloadFolder;
|
||||
|
||||
IBOutlet NSButton * fActionButton, * fSpeedLimitButton;
|
||||
NSTimer * fSpeedLimitTimer;
|
||||
|
||||
IBOutlet ImageBackgroundView * fStatusBar;
|
||||
IBOutlet NSTextField * fTotalDLField, * fTotalULField, * fTotalTorrentsField;
|
||||
|
||||
NSString * fSortType;
|
||||
IBOutlet NSMenuItem * fNameSortItem, * fStateSortItem, * fProgressSortItem,
|
||||
* fDateSortItem, * fOrderSortItem,
|
||||
* fNameSortActionItem, * fStateSortActionItem, * fProgressSortActionItem,
|
||||
* fDateSortActionItem, * fOrderSortActionItem;
|
||||
|
||||
IBOutlet ImageBackgroundView * fFilterBar;
|
||||
NSString * fFilterType;
|
||||
IBOutlet BarButton * fNoFilterButton, * fPauseFilterButton,
|
||||
* fSeedFilterButton, * fDownloadFilterButton;
|
||||
IBOutlet NSSearchField * fSearchFilterField;
|
||||
IBOutlet NSMenuItem * fNextFilterItem, * fPrevFilterItem;
|
||||
|
||||
IBOutlet NSMenuItem * fNextInfoTabItem, * fPrevInfoTabItem;
|
||||
|
||||
IBOutlet NSMenu * fUploadMenu, * fDownloadMenu;
|
||||
IBOutlet NSMenuItem * fUploadLimitItem, * fUploadNoLimitItem,
|
||||
* fDownloadLimitItem, * fDownloadNoLimitItem;
|
||||
|
||||
io_connect_t fRootPort;
|
||||
NSTimer * fTimer;
|
||||
|
||||
IBOutlet SUUpdater * fUpdater;
|
||||
BOOL fUpdateInProgress;
|
||||
|
||||
Badger * fBadger;
|
||||
|
||||
NSMutableArray * fAutoImportedNames;
|
||||
NSMutableDictionary * fPendingTorrentDownloads;
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames;
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files;
|
||||
- (void) openShowSheet: (id) sender;
|
||||
- (void) openURL: (NSURL *) torrentURL;
|
||||
|
||||
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
|
||||
|
||||
- (void) resumeSelectedTorrents: (id) sender;
|
||||
- (void) resumeAllTorrents: (id) sender;
|
||||
- (void) resumeTorrents: (NSArray *) torrents;
|
||||
|
||||
- (void) resumeSelectedTorrentsNoWait: (id) sender;
|
||||
- (void) resumeWaitingTorrents: (id) sender;
|
||||
- (void) resumeTorrentsNoWait: (NSArray *) torrents;
|
||||
|
||||
- (void) stopSelectedTorrents: (id) sender;
|
||||
- (void) stopAllTorrents: (id) sender;
|
||||
- (void) stopTorrents: (NSArray *) torrents;
|
||||
|
||||
- (void) removeTorrents: (NSArray *) torrents
|
||||
deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteData;
|
||||
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode
|
||||
contextInfo: (NSDictionary *) dict;
|
||||
- (void) confirmRemoveTorrents: (NSArray *) torrents
|
||||
deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent;
|
||||
- (void) removeNoDelete: (id) sender;
|
||||
- (void) removeDeleteData: (id) sender;
|
||||
- (void) removeDeleteTorrent: (id) sender;
|
||||
- (void) removeDeleteDataAndTorrent: (id) sender;
|
||||
|
||||
- (void) copyTorrentFile: (id) sender;
|
||||
- (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents;
|
||||
- (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (int) code
|
||||
contextInfo: (NSMutableArray *) torrents;
|
||||
|
||||
- (void) revealFile: (id) sender;
|
||||
|
||||
- (void) showPreferenceWindow: (id) sender;
|
||||
|
||||
- (void) showInfo: (id) sender;
|
||||
- (void) setInfoTab: (id) sender;
|
||||
|
||||
- (void) showMessageWindow: (id) sender;
|
||||
|
||||
- (void) updateControlTint: (NSNotification *) notification;
|
||||
|
||||
- (void) updateUI: (NSTimer *) timer;
|
||||
- (void) torrentFinishedDownloading: (NSNotification *) notification;
|
||||
- (void) updateTorrentHistory;
|
||||
|
||||
- (void) sortTorrents;
|
||||
- (void) sortTorrentsIgnoreSelected;
|
||||
- (void) setSort: (id) sender;
|
||||
- (void) applyFilter: (id) sender;
|
||||
- (void) setFilter: (id) sender;
|
||||
- (void) switchFilter: (id) sender;
|
||||
|
||||
- (void) applySpeedLimit: (id) sender;
|
||||
- (void) toggleSpeedLimit: (id) sender;
|
||||
- (void) autoSpeedLimitChange: (NSNotification *) notification;
|
||||
- (void) autoSpeedLimit: (NSTimer *) timer;
|
||||
|
||||
- (void) setLimitGlobalEnabled: (id) sender;
|
||||
- (void) setQuickLimitGlobal: (id) sender;
|
||||
|
||||
- (void) setQuickRatioGlobal: (id) sender;
|
||||
|
||||
- (void) checkWaitingForStopped: (NSNotification *) notification;
|
||||
- (void) checkToStartWaiting: (Torrent *) finishedTorrent;
|
||||
- (void) torrentStartSettingChange: (NSNotification *) notification;
|
||||
- (void) globalStartSettingChange: (NSNotification *) notification;
|
||||
|
||||
- (void) torrentStoppedForRatio: (NSNotification *) notification;
|
||||
|
||||
- (void) attemptToStartAuto: (Torrent *) torrent;
|
||||
- (void) attemptToStartMultipleAuto: (NSArray *) torrents;
|
||||
|
||||
- (void) changeAutoImport;
|
||||
- (void) checkAutoImportDirectory;
|
||||
|
||||
- (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument;
|
||||
|
||||
- (void) toggleSmallView: (id) sender;
|
||||
|
||||
- (void) toggleStatusBar: (id) sender;
|
||||
- (void) showStatusBar: (BOOL) show animate: (BOOL) animate;
|
||||
- (void) toggleFilterBar: (id) sender;
|
||||
- (void) showFilterBar: (BOOL) show animate: (BOOL) animate;
|
||||
|
||||
- (void) toggleAdvancedBar: (id) sender;
|
||||
|
||||
- (void) doNothing: (id) sender; //needed for menu items that use bindings with no associated action
|
||||
|
||||
- (void) resetDockBadge: (NSNotification *) notification;
|
||||
|
||||
- (void) setWindowSizeToFit;
|
||||
- (NSRect) sizedWindowFrame;
|
||||
|
||||
- (void) showMainWindow: (id) sender;
|
||||
- (void) linkHomepage: (id) sender;
|
||||
- (void) linkForums: (id) sender;
|
||||
|
||||
- (void) prepareForUpdate: (NSNotification *) notification;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -107,6 +107,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
fTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
fDisplayedTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
|
||||
|
||||
fDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
|
@ -140,6 +141,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[fFilterType release];
|
||||
|
||||
[fAutoImportedNames release];
|
||||
[fPendingTorrentDownloads release];
|
||||
|
||||
tr_close(fLib);
|
||||
[super dealloc];
|
||||
|
@ -216,7 +218,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[fTableView setTorrents: fDisplayedTorrents];
|
||||
[[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell: [[TorrentCell alloc] init]];
|
||||
|
||||
[fTableView registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType,
|
||||
[fTableView registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType,
|
||||
NSURLPboardType,
|
||||
TORRENT_TABLE_VIEW_DATA_TYPE, nil]];
|
||||
|
||||
//register for sleep notifications
|
||||
|
@ -348,6 +351,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[self checkAutoImportDirectory];
|
||||
}
|
||||
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) notification
|
||||
{
|
||||
[NSApp setServicesProvider:self];
|
||||
|
||||
//register for dock icon drags
|
||||
[[NSAppleEventManager sharedAppleEventManager] setEventHandler: self
|
||||
andSelector: @selector(handleOpenContentsEvent:replyEvent:)
|
||||
forEventClass: kCoreEventClass andEventID: kAEOpenContents];
|
||||
}
|
||||
|
||||
- (BOOL) applicationShouldHandleReopen: (NSApplication *) app hasVisibleWindows: (BOOL) visibleWindows
|
||||
{
|
||||
if (![fWindow isVisible] && ![[fPrefsController window] isVisible])
|
||||
|
@ -439,10 +452,67 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[self openFiles: filenames ignoreDownloadFolder: NO];
|
||||
}
|
||||
|
||||
- (void) handleOpenContentsEvent: (NSAppleEventDescriptor *) event replyEvent: (NSAppleEventDescriptor *) replyEvent
|
||||
{
|
||||
NSURL * url;
|
||||
NSString * urlString;
|
||||
|
||||
NSAppleEventDescriptor * directObject = [event paramDescriptorForKeyword: keyDirectObject];
|
||||
if ([directObject descriptorType] == typeAEList)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 1; i <= [directObject numberOfItems]; i++)
|
||||
if ((urlString = [[directObject descriptorAtIndex: i] stringValue]))
|
||||
{
|
||||
url = [[NSURL alloc] initWithString: urlString];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((urlString = [directObject stringValue]))
|
||||
url = [[NSURL alloc] initWithString: urlString];
|
||||
else;
|
||||
|
||||
if (url)
|
||||
{
|
||||
[self openURL: url];
|
||||
[url release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) openURL: (NSURL *) url
|
||||
{
|
||||
#warning check for .torrent
|
||||
NSURLDownload * torrentDownload = [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url]
|
||||
delegate: self];
|
||||
|
||||
NSString * tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent: [[url path] lastPathComponent]];
|
||||
NSLog(tempPath);[torrentDownload setDestination: tempPath allowOverwrite: NO];
|
||||
[fPendingTorrentDownloads setObject: tempPath forKey: url];
|
||||
[torrentDownload release];
|
||||
}
|
||||
|
||||
- (void) download: (NSURLDownload *)download didFailWithError: (NSError *) error
|
||||
{
|
||||
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
||||
|
||||
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
|
||||
@"Torrent download error -> title"), [NSString stringWithFormat:
|
||||
NSLocalizedString(@"The torrent could not be downloaded from %@ because an error occurred (%@)",
|
||||
@"Torrent download failed -> message"), [[[download request] URL] absoluteString],
|
||||
[error localizedDescription]], NSLocalizedString(@"OK", @"Torrent download failed -> button"), nil, nil);
|
||||
}
|
||||
|
||||
- (void) downloadDidFinish: (NSURLDownload *) download
|
||||
{
|
||||
#warning try to open, if not delete
|
||||
|
||||
[self openFiles: [NSArray arrayWithObject: [fPendingTorrentDownloads objectForKey: [[download request] URL]]]
|
||||
ignoreDownloadFolder: NO];
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
|
||||
{
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath;
|
||||
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
|
||||
if (ignore || [downloadChoice isEqualToString: @"Ask"])
|
||||
{
|
||||
[self openFilesAsk: [filenames mutableCopy]];
|
||||
|
@ -450,6 +520,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
|
||||
Torrent * torrent;
|
||||
NSString * torrentPath;
|
||||
NSEnumerator * enumerator = [filenames objectEnumerator];
|
||||
while ((torrentPath = [enumerator nextObject]))
|
||||
{
|
||||
|
@ -1538,7 +1609,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
if (![fDefaults boolForKey: @"AutoImport"])
|
||||
return;
|
||||
|
||||
|
||||
NSString * path = [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath];
|
||||
|
||||
NSArray * importedNames;
|
||||
|
@ -1639,6 +1710,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
return NSDragOperationGeneric;
|
||||
}
|
||||
}
|
||||
else if ([[pasteboard types] containsObject: NSURLPboardType])
|
||||
{
|
||||
[fTableView setDropRow: row dropOperation: NSTableViewDropAbove];
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
else if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
|
||||
{
|
||||
[fTableView setDropRow: row dropOperation: NSTableViewDropAbove];
|
||||
|
@ -1665,7 +1741,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[self application: NSApp openFiles: filesToOpen];
|
||||
[filesToOpen release];
|
||||
}
|
||||
else
|
||||
else if ([[pasteboard types] containsObject: NSURLPboardType])
|
||||
{
|
||||
NSURL * url;
|
||||
if ((url = [NSURL URLFromPasteboard:pasteboard]))
|
||||
[self openURL: url];
|
||||
}
|
||||
else if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
|
||||
{
|
||||
//remember selected rows if needed
|
||||
NSArray * selectedTorrents = nil;
|
||||
|
@ -1717,6 +1799,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[indexSet release];
|
||||
}
|
||||
}
|
||||
else;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -1,57 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>torrent</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>TransmissionDocument</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>BitTorrent Document</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<false/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Transmission</string>
|
||||
<key>CFBundleHelpBookFolder</key>
|
||||
<string>Transmission Help</string>
|
||||
<key>CFBundleHelpBookName</key>
|
||||
<string>Transmission Help</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Transmission</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.m0k.transmission</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>%%SHORT_VERSION_STRING%%</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>TR##</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>%%BUNDLE_VERSION%%</string>
|
||||
<key>NSAppleScriptEnabled</key>
|
||||
<string>YES</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>SUCheckAtStartup</key>
|
||||
<false/>
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://transmission.m0k.org/appcast.xml</string>
|
||||
</dict>
|
||||
</plist>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>torrent</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>TransmissionDocument</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>BitTorrent Document</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<false/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Transmission</string>
|
||||
<key>CFBundleHelpBookFolder</key>
|
||||
<string>Transmission Help</string>
|
||||
<key>CFBundleHelpBookName</key>
|
||||
<string>Transmission Help</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Transmission</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.m0k.transmission</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>%%SHORT_VERSION_STRING%%</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>TR##</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>%%BUNDLE_VERSION%%</string>
|
||||
<key>NSAppleScriptEnabled</key>
|
||||
<string>YES</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSServices</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPortName</key>
|
||||
<string>Transmission</string>
|
||||
<key>NSSendTypes</key>
|
||||
<array>
|
||||
<string>NSStringPboardType</string>
|
||||
<string>NSURLPboardType</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>SUCheckAtStartup</key>
|
||||
<false/>
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://transmission.m0k.org/appcast.xml</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
+ (NSString *) stringForRatioWithDownload: (uint64_t) down upload: (uint64_t) up
|
||||
{
|
||||
if (down == 0)
|
||||
return up == 0 ? @"N/A" : [NSString stringWithUTF8String: "\xE2\x88\x9E"];
|
||||
return up == 0 ? NSLocalizedString(@"N/A", "No Ratio") : [NSString stringWithUTF8String: "\xE2\x88\x9E"];
|
||||
|
||||
float ratio = (float) up / (float) down;
|
||||
if (ratio < 10.0)
|
||||
|
|
Loading…
Reference in a new issue