mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
simplify file dragging - don't consider torrent creation even if verifying a .torrent file fails
This commit is contained in:
parent
7c68a0895c
commit
ff841806e0
1 changed files with 10 additions and 22 deletions
|
@ -2693,7 +2693,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
NSPasteboard * pasteboard = [info draggingPasteboard];
|
NSPasteboard * pasteboard = [info draggingPasteboard];
|
||||||
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
||||||
{
|
{
|
||||||
#warning simplify
|
|
||||||
//check if any torrent files can be added
|
//check if any torrent files can be added
|
||||||
BOOL torrent = NO;
|
BOOL torrent = NO;
|
||||||
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
||||||
|
@ -2701,19 +2700,16 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
{
|
{
|
||||||
if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
|
if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
|
||||||
{
|
{
|
||||||
|
torrent = YES;
|
||||||
tr_ctor * ctor = tr_ctorNew(fLib);
|
tr_ctor * ctor = tr_ctorNew(fLib);
|
||||||
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
||||||
switch (tr_torrentParse(ctor, NULL))
|
if (tr_torrentParse(ctor, NULL) == TR_OK)
|
||||||
{
|
{
|
||||||
case TR_OK:
|
if (!fOverlayWindow)
|
||||||
if (!fOverlayWindow)
|
fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
|
||||||
fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
|
[fOverlayWindow setTorrents: files];
|
||||||
[fOverlayWindow setTorrents: files];
|
|
||||||
|
|
||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
|
|
||||||
case TR_EDUPLICATE:
|
|
||||||
torrent = YES;
|
|
||||||
}
|
}
|
||||||
tr_ctorFree(ctor);
|
tr_ctorFree(ctor);
|
||||||
}
|
}
|
||||||
|
@ -2759,24 +2755,17 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
BOOL torrent = NO, accept = YES;
|
BOOL torrent = NO, accept = YES;
|
||||||
|
|
||||||
//create an array of files that can be opened
|
//create an array of files that can be opened
|
||||||
NSMutableArray * filesToOpen = [[NSMutableArray alloc] init];
|
|
||||||
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
|
||||||
|
NSMutableArray * filesToOpen = [NSMutableArray arrayWithCapacity: [files count]];
|
||||||
for (NSString * file in files)
|
for (NSString * file in files)
|
||||||
{
|
{
|
||||||
if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
|
if ([[[NSWorkspace sharedWorkspace] typeOfFile: file error: NULL] isEqualToString: @"org.bittorrent.torrent"])
|
||||||
{
|
{
|
||||||
|
torrent = YES;
|
||||||
tr_ctor * ctor = tr_ctorNew(fLib);
|
tr_ctor * ctor = tr_ctorNew(fLib);
|
||||||
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]);
|
||||||
switch (tr_torrentParse(ctor, NULL))
|
if (tr_torrentParse(ctor, NULL) == TR_OK)
|
||||||
{
|
[filesToOpen addObject: file];
|
||||||
case TR_OK:
|
|
||||||
[filesToOpen addObject: file];
|
|
||||||
torrent = YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TR_EDUPLICATE:
|
|
||||||
torrent = YES;
|
|
||||||
}
|
|
||||||
tr_ctorFree(ctor);
|
tr_ctorFree(ctor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2790,7 +2779,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
else
|
else
|
||||||
accept = NO;
|
accept = NO;
|
||||||
}
|
}
|
||||||
[filesToOpen release];
|
|
||||||
|
|
||||||
return accept;
|
return accept;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue