2007-09-16 01:02:06 +00:00
|
|
|
/******************************************************************************
|
2012-01-14 17:12:04 +00:00
|
|
|
* Copyright (c) 2007-2012 Transmission authors and contributors
|
2007-09-16 01:02:06 +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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#import "CreatorWindowController.h"
|
2012-05-28 14:28:50 +00:00
|
|
|
#import "Controller.h"
|
2012-06-18 01:33:27 +00:00
|
|
|
#import "NSApplicationAdditions.h"
|
2007-09-16 01:02:06 +00:00
|
|
|
#import "NSStringAdditions.h"
|
2010-04-23 16:59:14 +00:00
|
|
|
|
|
|
|
#import "transmission.h" // required by utils.h
|
|
|
|
#import "utils.h" // tr_urlIsValidTracker()
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
#define TRACKER_ADD_TAG 0
|
|
|
|
#define TRACKER_REMOVE_TAG 1
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@interface CreatorWindowController (Private)
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
+ (NSURL *) chooseFile;
|
2008-05-28 23:57:25 +00:00
|
|
|
|
2012-05-28 19:43:53 +00:00
|
|
|
- (void) updateLocationField;
|
2008-11-04 01:31:24 +00:00
|
|
|
- (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
|
2008-05-28 23:57:25 +00:00
|
|
|
- (void) createReal;
|
2007-09-16 01:02:06 +00:00
|
|
|
- (void) checkProgress;
|
2008-11-04 01:31:24 +00:00
|
|
|
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
NSMutableSet *creatorWindowControllerSet = nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
@implementation CreatorWindowController
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
+ (CreatorWindowController *) createTorrentFile: (tr_session *) handle
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
//get file/folder for torrent
|
2012-05-28 14:28:50 +00:00
|
|
|
NSURL * path;
|
2007-09-16 01:02:06 +00:00
|
|
|
if (!(path = [CreatorWindowController chooseFile]))
|
2012-05-28 14:28:50 +00:00
|
|
|
return nil;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-01-04 04:45:31 +00:00
|
|
|
CreatorWindowController * creator = [[self alloc] initWithHandle: handle path: path];
|
2007-09-16 01:02:06 +00:00
|
|
|
[creator showWindow: nil];
|
2012-05-28 14:28:50 +00:00
|
|
|
return creator;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
+ (CreatorWindowController *) createTorrentFile: (tr_session *) handle forFile: (NSURL *) file
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-01-04 04:45:31 +00:00
|
|
|
CreatorWindowController * creator = [[self alloc] initWithHandle: handle path: file];
|
2007-09-16 01:02:06 +00:00
|
|
|
[creator showWindow: nil];
|
2012-05-28 14:28:50 +00:00
|
|
|
return creator;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
- (id) initWithHandle: (tr_session *) handle path: (NSURL *) path
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-01-04 04:45:31 +00:00
|
|
|
if ((self = [super initWithWindowNibName: @"Creator"]))
|
2009-09-12 01:07:21 +00:00
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
if (!creatorWindowControllerSet) {
|
|
|
|
creatorWindowControllerSet = [NSMutableSet set];
|
|
|
|
}
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
fStarted = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
fPath = path;
|
2012-05-28 14:28:50 +00:00
|
|
|
fInfo = tr_metaInfoBuilderCreate([[fPath path] UTF8String]);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
if (fInfo->fileCount == 0)
|
|
|
|
{
|
|
|
|
NSAlert * alert = [[NSAlert alloc] init];
|
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> no files -> button")];
|
|
|
|
[alert setMessageText: NSLocalizedString(@"This folder contains no files.",
|
|
|
|
"Create torrent -> no files -> title")];
|
|
|
|
[alert setInformativeText: NSLocalizedString(@"There must be at least one file in a folder to create a torrent file.",
|
|
|
|
"Create torrent -> no files -> warning")];
|
|
|
|
[alert setAlertStyle: NSWarningAlertStyle];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[alert runModal];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
if (fInfo->totalSize == 0)
|
|
|
|
{
|
|
|
|
NSAlert * alert = [[NSAlert alloc] init];
|
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> zero size -> button")];
|
|
|
|
[alert setMessageText: NSLocalizedString(@"The total file size is zero bytes.",
|
|
|
|
"Create torrent -> zero size -> title")];
|
|
|
|
[alert setInformativeText: NSLocalizedString(@"A torrent file cannot be created for files with no size.",
|
|
|
|
"Create torrent -> zero size -> warning")];
|
|
|
|
[alert setAlertStyle: NSWarningAlertStyle];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[alert runModal];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
return nil;
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
fDefaults = [NSUserDefaults standardUserDefaults];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
//get list of trackers
|
|
|
|
if (!(fTrackers = [[fDefaults arrayForKey: @"CreatorTrackers"] mutableCopy]))
|
|
|
|
{
|
2012-05-28 14:28:50 +00:00
|
|
|
fTrackers = [[NSMutableArray alloc] init];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-08-14 21:47:23 +00:00
|
|
|
//check for single tracker from versions before 1.3
|
2008-06-04 20:55:38 +00:00
|
|
|
NSString * tracker;
|
|
|
|
if ((tracker = [fDefaults stringForKey: @"CreatorTracker"]))
|
|
|
|
{
|
|
|
|
[fDefaults removeObjectForKey: @"CreatorTracker"];
|
2008-08-17 22:50:02 +00:00
|
|
|
if (![tracker isEqualToString: @""])
|
|
|
|
{
|
|
|
|
[fTrackers addObject: tracker];
|
|
|
|
[fDefaults setObject: fTrackers forKey: @"CreatorTrackers"];
|
|
|
|
}
|
2008-06-04 20:55:38 +00:00
|
|
|
}
|
2008-06-24 03:59:34 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-08-14 21:47:23 +00:00
|
|
|
//remove potentially invalid addresses
|
2008-10-12 22:17:27 +00:00
|
|
|
for (NSInteger i = [fTrackers count]-1; i >= 0; i--)
|
2008-08-14 21:47:23 +00:00
|
|
|
{
|
2017-07-08 09:16:01 +00:00
|
|
|
if (!tr_urlIsValidTracker([fTrackers[i] UTF8String]))
|
2008-08-14 21:47:23 +00:00
|
|
|
[fTrackers removeObjectAtIndex: i];
|
|
|
|
}
|
2017-07-29 16:14:22 +00:00
|
|
|
|
|
|
|
[creatorWindowControllerSet addObject:self];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) awakeFromNib
|
|
|
|
{
|
2016-01-06 11:05:37 +00:00
|
|
|
[[self window] setRestorationClass: [self class]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
NSString * name = [fPath lastPathComponent];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[[self window] setTitle: name];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[fNameField setStringValue: name];
|
2012-05-28 14:28:50 +00:00
|
|
|
[fNameField setToolTip: [fPath path]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2014-06-08 22:16:01 +00:00
|
|
|
const BOOL multifile = fInfo->isFolder;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: multifile
|
2011-10-06 03:16:06 +00:00
|
|
|
? NSFileTypeForHFSTypeCode(kGenericFolderIcon) : [fPath pathExtension]];
|
2007-09-16 01:02:06 +00:00
|
|
|
[icon setSize: [fIconView frame].size];
|
|
|
|
[fIconView setImage: icon];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
NSString * statusString = [NSString stringForFileSize: fInfo->totalSize];
|
|
|
|
if (multifile)
|
|
|
|
{
|
|
|
|
NSString * fileString;
|
2008-09-07 17:57:58 +00:00
|
|
|
NSInteger count = fInfo->fileCount;
|
2007-09-16 01:02:06 +00:00
|
|
|
if (count != 1)
|
2010-11-14 21:04:25 +00:00
|
|
|
fileString = [NSString stringWithFormat: NSLocalizedString(@"%@ files", "Create torrent -> info"),
|
|
|
|
[NSString formattedUInteger: count]];
|
2007-09-16 01:02:06 +00:00
|
|
|
else
|
2008-04-07 13:29:46 +00:00
|
|
|
fileString = NSLocalizedString(@"1 file", "Create torrent -> info");
|
2008-03-18 22:11:43 +00:00
|
|
|
statusString = [NSString stringWithFormat: @"%@, %@", fileString, statusString];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
[fStatusField setStringValue: statusString];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-20 20:58:13 +00:00
|
|
|
if (fInfo->pieceCount == 1)
|
2009-09-18 03:57:18 +00:00
|
|
|
[fPiecesField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"1 piece, %@", "Create torrent -> info"),
|
|
|
|
[NSString stringForFileSize: fInfo->pieceSize]]];
|
2007-09-16 01:02:06 +00:00
|
|
|
else
|
2009-09-18 03:57:18 +00:00
|
|
|
[fPiecesField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d pieces, %@ each", "Create torrent -> info"),
|
2009-09-20 20:58:13 +00:00
|
|
|
fInfo->pieceCount, [NSString stringForFileSize: fInfo->pieceSize]]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
fLocation = [[fDefaults URLForKey: @"CreatorLocationURL"] URLByAppendingPathComponent: [name stringByAppendingPathExtension: @"torrent"]];
|
2012-05-28 14:28:50 +00:00
|
|
|
if (!fLocation)
|
|
|
|
{
|
|
|
|
//for 2.5 and earlier
|
|
|
|
#warning we still store "CreatorLocation" in Defaults.plist, and not "CreatorLocationURL"
|
|
|
|
NSString * location = [fDefaults stringForKey: @"CreatorLocation"];
|
|
|
|
fLocation = [[NSURL alloc] initFileURLWithPath: [[location stringByExpandingTildeInPath] stringByAppendingPathComponent: [name stringByAppendingPathExtension: @"torrent"]]];
|
|
|
|
}
|
2012-05-28 19:43:53 +00:00
|
|
|
[self updateLocationField];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
//set previously saved values
|
|
|
|
if ([fDefaults objectForKey: @"CreatorPrivate"])
|
|
|
|
[fPrivateCheck setState: [fDefaults boolForKey: @"CreatorPrivate"] ? NSOnState : NSOffState];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-26 00:44:21 +00:00
|
|
|
[fOpenCheck setState: [fDefaults boolForKey: @"CreatorOpen"] ? NSOnState : NSOffState];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
if (fInfo)
|
|
|
|
tr_metaInfoBuilderFree(fInfo);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-18 16:25:30 +00:00
|
|
|
[fTimer invalidate];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
+ (void) restoreWindowWithIdentifier: (NSString *) identifier state: (NSCoder *) state completionHandler: (void (^)(NSWindow *, NSError *)) completionHandler
|
|
|
|
{
|
|
|
|
NSURL * path = [state decodeObjectForKey: @"TRCreatorPath"];
|
|
|
|
if (!path || ![path checkResourceIsReachableAndReturnError: nil])
|
|
|
|
{
|
|
|
|
completionHandler(nil, [NSError errorWithDomain: NSURLErrorDomain code: NSURLErrorCannotOpenFile userInfo: nil]);
|
|
|
|
return;
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
NSWindow * window = [[self createTorrentFile: [(Controller *)[NSApp delegate] sessionHandle] forFile: path] window];
|
|
|
|
completionHandler(window, nil);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) window: (NSWindow *) window willEncodeRestorableState: (NSCoder *) state
|
|
|
|
{
|
|
|
|
[state encodeObject: fPath forKey: @"TRCreatorPath"];
|
|
|
|
[state encodeObject: fLocation forKey: @"TRCreatorLocation"];
|
|
|
|
[state encodeObject: fTrackers forKey: @"TRCreatorTrackers"];
|
|
|
|
[state encodeInteger: [fOpenCheck state] forKey: @"TRCreatorOpenCheck"];
|
|
|
|
[state encodeInteger: [fPrivateCheck state] forKey: @"TRCreatorPrivateCheck"];
|
|
|
|
[state encodeObject: [fCommentView string] forKey: @"TRCreatorPrivateComment"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) window: (NSWindow *) window didDecodeRestorableState: (NSCoder *) coder
|
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
fLocation = [coder decodeObjectForKey: @"TRCreatorLocation"];
|
2012-05-28 19:43:53 +00:00
|
|
|
[self updateLocationField];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
fTrackers = [coder decodeObjectForKey: @"TRCreatorTrackers"];
|
2012-05-28 14:28:50 +00:00
|
|
|
[fTrackerTable reloadData];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
[fOpenCheck setState: [coder decodeIntegerForKey: @"TRCreatorOpenCheck"]];
|
|
|
|
[fPrivateCheck setState: [coder decodeIntegerForKey: @"TRCreatorPrivateCheck"]];
|
|
|
|
[fCommentView setString: [coder decodeObjectForKey: @"TRCreatorPrivateComment"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction) setLocation: (id) sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
NSSavePanel * panel = [NSSavePanel savePanel];
|
|
|
|
|
2007-11-17 18:54:07 +00:00
|
|
|
[panel setPrompt: NSLocalizedString(@"Select", "Create torrent -> location sheet -> button")];
|
|
|
|
[panel setMessage: NSLocalizedString(@"Select the name and location for the torrent file.",
|
2017-01-24 17:53:16 +00:00
|
|
|
"Create torrent -> location sheet -> message")];
|
|
|
|
|
2017-07-08 08:23:05 +00:00
|
|
|
[panel setAllowedFileTypes: @[@"org.bittorrent.torrent", @"torrent"]];
|
2007-09-16 01:02:06 +00:00
|
|
|
[panel setCanSelectHiddenExtension: YES];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
[panel setDirectoryURL: [fLocation URLByDeletingLastPathComponent]];
|
2011-12-11 22:31:01 +00:00
|
|
|
[panel setNameFieldStringValue: [fLocation lastPathComponent]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-12-11 22:31:01 +00:00
|
|
|
[panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
|
|
|
|
if (result == NSFileHandlingPanelOKButton)
|
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
fLocation = [panel URL];
|
2012-05-28 19:43:53 +00:00
|
|
|
[self updateLocationField];
|
2011-12-11 22:31:01 +00:00
|
|
|
}
|
|
|
|
}];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
- (IBAction) create: (id) sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2009-09-12 00:23:13 +00:00
|
|
|
//make sure the trackers are no longer being verified
|
|
|
|
if ([fTrackerTable editedRow] != -1)
|
|
|
|
[[self window] endEditingFor: fTrackerTable];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-26 00:44:21 +00:00
|
|
|
const BOOL isPrivate = [fPrivateCheck state] == NSOnState;
|
|
|
|
if ([fTrackers count] == 0
|
|
|
|
&& [fDefaults boolForKey: isPrivate ? @"WarningCreatorPrivateBlankAddress" : @"WarningCreatorBlankAddress"])
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-05-29 00:18:10 +00:00
|
|
|
NSAlert * alert = [[NSAlert alloc] init];
|
2009-11-26 00:44:21 +00:00
|
|
|
[alert setMessageText: NSLocalizedString(@"There are no tracker addresses.", "Create torrent -> blank address -> title")];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-26 00:44:21 +00:00
|
|
|
NSString * infoString = isPrivate
|
|
|
|
? NSLocalizedString(@"A transfer marked as private with no tracker addresses will be unable to connect to peers."
|
|
|
|
" The torrent file will only be useful if you plan to upload the file to a tracker website"
|
|
|
|
" that will add the addresses for you.", "Create torrent -> blank address -> message")
|
2010-05-20 00:16:49 +00:00
|
|
|
: NSLocalizedString(@"The transfer will not contact trackers for peers, and will have to rely solely on"
|
2010-05-01 16:19:40 +00:00
|
|
|
" non-tracker peer discovery methods such as PEX and DHT to download and seed.",
|
2009-11-26 00:44:21 +00:00
|
|
|
"Create torrent -> blank address -> message");
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-26 00:44:21 +00:00
|
|
|
[alert setInformativeText: infoString];
|
2008-05-29 00:18:10 +00:00
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"Create", "Create torrent -> blank address -> button")];
|
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Create torrent -> blank address -> button")];
|
2008-12-26 05:57:51 +00:00
|
|
|
[alert setShowsSuppressionButton: YES];
|
2008-05-29 00:18:10 +00:00
|
|
|
|
|
|
|
[alert beginSheetModalForWindow: [self window] modalDelegate: self
|
|
|
|
didEndSelector: @selector(createBlankAddressAlertDidEnd:returnCode:contextInfo:) contextInfo: nil];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
2008-05-29 00:18:10 +00:00
|
|
|
else
|
2008-05-28 23:57:25 +00:00
|
|
|
[self createReal];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
- (IBAction) cancelCreateWindow: (id) sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
[[self window] close];
|
|
|
|
}
|
|
|
|
|
2012-03-13 02:52:11 +00:00
|
|
|
- (void) windowWillClose: (NSNotification *) notification
|
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
[creatorWindowControllerSet removeObject:self];
|
2012-03-13 02:52:11 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
- (IBAction) cancelCreateProgress: (id) sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
fInfo->abortFlag = 1;
|
|
|
|
[fTimer fire];
|
|
|
|
}
|
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableView
|
|
|
|
{
|
|
|
|
return [fTrackers count];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
|
|
|
|
{
|
2017-07-08 09:16:01 +00:00
|
|
|
return fTrackers[row];
|
2008-06-04 20:55:38 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
- (IBAction) addRemoveTracker: (id) sender
|
2008-06-04 20:55:38 +00:00
|
|
|
{
|
|
|
|
//don't allow add/remove when currently adding - it leads to weird results
|
|
|
|
if ([fTrackerTable editedRow] != -1)
|
|
|
|
return;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
if ([[sender cell] tagForSegment: [sender selectedSegment]] == TRACKER_REMOVE_TAG)
|
|
|
|
{
|
|
|
|
[fTrackers removeObjectsAtIndexes: [fTrackerTable selectedRowIndexes]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
[fTrackerTable deselectAll: self];
|
|
|
|
[fTrackerTable reloadData];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[fTrackers addObject: @""];
|
|
|
|
[fTrackerTable reloadData];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-08-28 23:40:11 +00:00
|
|
|
const NSInteger row = [fTrackers count] - 1;
|
|
|
|
[fTrackerTable selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
|
2008-06-04 20:55:38 +00:00
|
|
|
[fTrackerTable editColumn: 0 row: row withEvent: nil select: YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
|
|
|
|
row: (NSInteger) row
|
|
|
|
{
|
|
|
|
NSString * tracker = (NSString *)object;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-09-06 13:49:20 +00:00
|
|
|
tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
if ([tracker rangeOfString: @"://"].location == NSNotFound)
|
|
|
|
tracker = [@"http://" stringByAppendingString: tracker];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-02-20 15:57:34 +00:00
|
|
|
if (!tr_urlIsValidTracker([tracker UTF8String]))
|
2008-06-04 20:55:38 +00:00
|
|
|
{
|
|
|
|
NSBeep();
|
|
|
|
[fTrackers removeObjectAtIndex: row];
|
|
|
|
}
|
|
|
|
else
|
2017-07-08 09:16:01 +00:00
|
|
|
fTrackers[row] = tracker;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-04 20:55:38 +00:00
|
|
|
[fTrackerTable deselectAll: self];
|
|
|
|
[fTrackerTable reloadData];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) tableViewSelectionDidChange: (NSNotification *) notification
|
|
|
|
{
|
|
|
|
[fTrackerAddRemoveControl setEnabled: [fTrackerTable numberOfSelectedRows] > 0 forSegment: TRACKER_REMOVE_TAG];
|
|
|
|
}
|
|
|
|
|
2010-04-23 02:13:54 +00:00
|
|
|
- (void) copy: (id) sender
|
|
|
|
{
|
|
|
|
NSArray * addresses = [fTrackers objectsAtIndexes: [fTrackerTable selectedRowIndexes]];
|
|
|
|
NSString * text = [addresses componentsJoinedByString: @"\n"];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:13:54 +00:00
|
|
|
NSPasteboard * pb = [NSPasteboard generalPasteboard];
|
2011-10-06 00:30:40 +00:00
|
|
|
[pb clearContents];
|
2017-07-08 08:23:05 +00:00
|
|
|
[pb writeObjects: @[text]];
|
2010-04-23 02:13:54 +00:00
|
|
|
}
|
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
|
|
|
|
{
|
|
|
|
const SEL action = [menuItem action];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:13:54 +00:00
|
|
|
if (action == @selector(copy:))
|
|
|
|
return [[self window] firstResponder] == fTrackerTable && [fTrackerTable numberOfSelectedRows] > 0;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
if (action == @selector(paste:))
|
|
|
|
return [[self window] firstResponder] == fTrackerTable
|
2017-07-08 08:23:05 +00:00
|
|
|
&& [[NSPasteboard generalPasteboard] canReadObjectForClasses: @[[NSString class]] options: nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) paste: (id) sender
|
|
|
|
{
|
|
|
|
NSMutableArray * tempTrackers = [NSMutableArray array];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-08 08:23:05 +00:00
|
|
|
NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: @[[NSString class]] options: nil];
|
2011-10-06 00:30:40 +00:00
|
|
|
NSAssert(items != nil, @"no string items to paste; should not be able to call this method");
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-10-06 00:30:40 +00:00
|
|
|
for (NSString * pbItem in items)
|
2010-04-23 02:05:34 +00:00
|
|
|
{
|
|
|
|
for (NSString * tracker in [pbItem componentsSeparatedByString: @"\n"])
|
|
|
|
[tempTrackers addObject: tracker];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
BOOL added = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
for (__strong NSString * tracker in tempTrackers)
|
2010-04-23 02:05:34 +00:00
|
|
|
{
|
|
|
|
tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
if ([tracker rangeOfString: @"://"].location == NSNotFound)
|
|
|
|
tracker = [@"http://" stringByAppendingString: tracker];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
if (tr_urlIsValidTracker([tracker UTF8String]))
|
|
|
|
{
|
|
|
|
[fTrackers addObject: tracker];
|
|
|
|
added = YES;
|
|
|
|
}
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-23 02:05:34 +00:00
|
|
|
if (added)
|
|
|
|
{
|
|
|
|
[fTrackerTable deselectAll: self];
|
|
|
|
[fTrackerTable reloadData];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
NSBeep();
|
|
|
|
}
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation CreatorWindowController (Private)
|
|
|
|
|
2012-05-28 19:43:53 +00:00
|
|
|
- (void) updateLocationField
|
|
|
|
{
|
|
|
|
NSString * pathString = [fLocation path];
|
|
|
|
[fLocationField setStringValue: [pathString stringByAbbreviatingWithTildeInPath]];
|
|
|
|
[fLocationField setToolTip: pathString];
|
|
|
|
}
|
|
|
|
|
2012-05-28 14:28:50 +00:00
|
|
|
+ (NSURL *) chooseFile
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[panel setTitle: NSLocalizedString(@"Create Torrent File", "Create torrent -> select file")];
|
|
|
|
[panel setPrompt: NSLocalizedString(@"Select", "Create torrent -> select file")];
|
|
|
|
[panel setAllowsMultipleSelection: NO];
|
|
|
|
[panel setCanChooseFiles: YES];
|
|
|
|
[panel setCanChooseDirectories: YES];
|
|
|
|
[panel setCanCreateDirectories: NO];
|
|
|
|
|
|
|
|
[panel setMessage: NSLocalizedString(@"Select a file or folder for the torrent file.", "Create torrent -> select file")];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
BOOL success = [panel runModal] == NSOKButton;
|
2017-07-08 09:16:01 +00:00
|
|
|
return success ? [panel URLs][0] : nil;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-04 01:31:24 +00:00
|
|
|
- (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
2008-05-29 00:18:10 +00:00
|
|
|
{
|
2008-12-26 05:57:51 +00:00
|
|
|
if ([[alert suppressionButton] state] == NSOnState)
|
2009-11-26 00:44:21 +00:00
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorBlankAddress"]; //set regardless of private/public
|
|
|
|
if ([fPrivateCheck state] == NSOnState)
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorPrivateBlankAddress"];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
|
|
|
|
2008-05-29 00:18:10 +00:00
|
|
|
if (returnCode == NSAlertFirstButtonReturn)
|
|
|
|
[self performSelectorOnMainThread: @selector(createReal) withObject: nil waitUntilDone: NO];
|
|
|
|
}
|
|
|
|
|
2008-05-28 23:57:25 +00:00
|
|
|
- (void) createReal
|
|
|
|
{
|
2009-09-26 20:13:15 +00:00
|
|
|
//check if the location currently exists
|
2012-05-28 14:28:50 +00:00
|
|
|
if (![[fLocation URLByDeletingLastPathComponent] checkResourceIsReachableAndReturnError: NULL])
|
2009-09-26 20:13:15 +00:00
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
NSAlert * alert = [[NSAlert alloc] init];
|
2009-09-26 20:13:15 +00:00
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> directory doesn't exist warning -> button")];
|
|
|
|
[alert setMessageText: NSLocalizedString(@"The chosen torrent file location does not exist.",
|
|
|
|
"Create torrent -> directory doesn't exist warning -> title")];
|
|
|
|
[alert setInformativeText: [NSString stringWithFormat:
|
|
|
|
NSLocalizedString(@"The directory \"%@\" does not currently exist. "
|
|
|
|
"Create this directory or choose a different one to create the torrent file.",
|
|
|
|
"Create torrent -> directory doesn't exist warning -> warning"),
|
2012-05-28 14:28:50 +00:00
|
|
|
[[fLocation URLByDeletingLastPathComponent] path]]];
|
2009-09-26 20:13:15 +00:00
|
|
|
[alert setAlertStyle: NSWarningAlertStyle];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-26 20:13:15 +00:00
|
|
|
[alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
|
|
|
|
return;
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-02 01:55:15 +00:00
|
|
|
//check if a file with the same name and location already exists
|
2012-05-28 14:28:50 +00:00
|
|
|
if ([fLocation checkResourceIsReachableAndReturnError: NULL])
|
2008-06-02 01:55:15 +00:00
|
|
|
{
|
|
|
|
NSArray * pathComponents = [fLocation pathComponents];
|
2008-11-04 01:31:24 +00:00
|
|
|
NSInteger count = [pathComponents count];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
NSAlert * alert = [[NSAlert alloc] init];
|
2008-06-02 01:55:15 +00:00
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> file already exists warning -> button")];
|
|
|
|
[alert setMessageText: NSLocalizedString(@"A torrent file with this name and directory cannot be created.",
|
|
|
|
"Create torrent -> file already exists warning -> title")];
|
|
|
|
[alert setInformativeText: [NSString stringWithFormat:
|
|
|
|
NSLocalizedString(@"A file with the name \"%@\" already exists in the directory \"%@\". "
|
|
|
|
"Choose a new name or directory to create the torrent file.",
|
|
|
|
"Create torrent -> file already exists warning -> warning"),
|
2017-07-08 09:16:01 +00:00
|
|
|
pathComponents[count-1], pathComponents[count-2]]];
|
2008-06-02 01:55:15 +00:00
|
|
|
[alert setAlertStyle: NSWarningAlertStyle];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-06-02 01:55:15 +00:00
|
|
|
[alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
|
|
|
|
return;
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-05-28 23:57:25 +00:00
|
|
|
//parse non-empty tracker strings
|
2008-06-04 20:55:38 +00:00
|
|
|
tr_tracker_info * trackerInfo = tr_new0(tr_tracker_info, [fTrackers count]);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-10-12 22:17:27 +00:00
|
|
|
for (NSUInteger i = 0; i < [fTrackers count]; i++)
|
2009-10-10 12:58:40 +00:00
|
|
|
{
|
2017-07-08 09:16:01 +00:00
|
|
|
trackerInfo[i].announce = (char *)[fTrackers[i] UTF8String];
|
2009-10-10 12:58:40 +00:00
|
|
|
trackerInfo[i].tier = i;
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-05-28 23:57:25 +00:00
|
|
|
//store values
|
2008-06-04 20:55:38 +00:00
|
|
|
[fDefaults setObject: fTrackers forKey: @"CreatorTrackers"];
|
2008-05-28 23:57:25 +00:00
|
|
|
[fDefaults setBool: [fPrivateCheck state] == NSOnState forKey: @"CreatorPrivate"];
|
2009-11-26 00:44:21 +00:00
|
|
|
[fDefaults setBool: [fOpenCheck state] == NSOnState forKey: @"CreatorOpen"];
|
2012-05-28 19:43:53 +00:00
|
|
|
fOpenWhenCreated = [fOpenCheck state] == NSOnState; //need this since the check box might not exist, and value in prefs might have changed from another creator window
|
2012-05-28 14:28:50 +00:00
|
|
|
[fDefaults setURL: [fLocation URLByDeletingLastPathComponent] forKey: @"CreatorLocationURL"];
|
2016-01-06 11:05:37 +00:00
|
|
|
|
|
|
|
[[self window] setRestorable: NO];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-05-28 23:57:25 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil];
|
2012-05-28 19:43:53 +00:00
|
|
|
tr_makeMetaInfo(fInfo, [[fLocation path] UTF8String], trackerInfo, [fTrackers count], [[fCommentView string] UTF8String], [fPrivateCheck state] == NSOnState);
|
2008-06-04 20:55:38 +00:00
|
|
|
tr_free(trackerInfo);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(checkProgress) userInfo: nil repeats: YES];
|
2008-05-28 23:57:25 +00:00
|
|
|
}
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
- (void) checkProgress
|
|
|
|
{
|
|
|
|
if (fInfo->isDone)
|
|
|
|
{
|
|
|
|
[fTimer invalidate];
|
|
|
|
fTimer = nil;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-03-24 19:38:29 +00:00
|
|
|
NSAlert * alert;
|
|
|
|
switch (fInfo->result)
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-03-24 19:38:29 +00:00
|
|
|
case TR_MAKEMETA_OK:
|
2012-05-28 19:43:53 +00:00
|
|
|
if (fOpenWhenCreated)
|
2008-03-24 19:38:29 +00:00
|
|
|
{
|
2017-07-17 17:34:52 +00:00
|
|
|
NSDictionary * dict = [[NSDictionary alloc] initWithObjects: @[
|
|
|
|
[fLocation path],
|
|
|
|
[[fPath URLByDeletingLastPathComponent] path]]
|
|
|
|
forKeys: @[@"File", @"Path"]];
|
2008-03-24 19:38:29 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"OpenCreatedTorrentFile" object: self userInfo: dict];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-03-24 19:38:29 +00:00
|
|
|
[[self window] close];
|
|
|
|
break;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-03-24 19:38:29 +00:00
|
|
|
case TR_MAKEMETA_CANCELLED:
|
|
|
|
[[self window] close];
|
|
|
|
break;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-03-24 19:38:29 +00:00
|
|
|
default:
|
2017-07-29 16:14:22 +00:00
|
|
|
alert = [[NSAlert alloc] init];
|
2007-09-16 01:02:06 +00:00
|
|
|
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> failed -> button")];
|
|
|
|
[alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Creation of \"%@\" failed.",
|
|
|
|
"Create torrent -> failed -> title"), [fLocation lastPathComponent]]];
|
|
|
|
[alert setAlertStyle: NSWarningAlertStyle];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-03-24 19:38:29 +00:00
|
|
|
if (fInfo->result == TR_MAKEMETA_IO_READ)
|
2008-03-28 15:30:26 +00:00
|
|
|
[alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"Could not read \"%s\": %s.",
|
|
|
|
"Create torrent -> failed -> warning"), fInfo->errfile, strerror(fInfo->my_errno)]];
|
2008-03-24 19:38:29 +00:00
|
|
|
else if (fInfo->result == TR_MAKEMETA_IO_WRITE)
|
2008-03-28 15:30:26 +00:00
|
|
|
[alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"Could not write \"%s\": %s.",
|
|
|
|
"Create torrent -> failed -> warning"), fInfo->errfile, strerror(fInfo->my_errno)]];
|
2009-01-23 02:39:34 +00:00
|
|
|
else //invalid url should have been caught before creating
|
|
|
|
[alert setInformativeText: [NSString stringWithFormat: @"%@ (%d)",
|
|
|
|
NSLocalizedString(@"An unknown error has occurred.", "Create torrent -> failed -> warning"), fInfo->result]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[alert beginSheetModalForWindow: [self window] modalDelegate: self
|
2009-01-23 02:39:34 +00:00
|
|
|
didEndSelector: @selector(failureSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[fProgressIndicator setDoubleValue: (double)fInfo->pieceIndex / fInfo->pieceCount];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
if (!fStarted)
|
|
|
|
{
|
2008-03-24 19:38:29 +00:00
|
|
|
fStarted = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-11-01 15:58:21 +00:00
|
|
|
[fProgressView setHidden: YES];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
NSWindow * window = [self window];
|
2009-09-12 01:00:54 +00:00
|
|
|
[window setFrameAutosaveName: @""];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
NSRect windowRect = [window frame];
|
2008-09-07 17:57:58 +00:00
|
|
|
CGFloat difference = [fProgressView frame].size.height - [[window contentView] frame].size.height;
|
2007-09-16 01:02:06 +00:00
|
|
|
windowRect.origin.y -= difference;
|
|
|
|
windowRect.size.height += difference;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
//don't allow vertical resizing
|
2008-09-07 17:57:58 +00:00
|
|
|
CGFloat height = windowRect.size.height;
|
2007-09-16 01:02:06 +00:00
|
|
|
[window setMinSize: NSMakeSize([window minSize].width, height)];
|
|
|
|
[window setMaxSize: NSMakeSize([window maxSize].width, height)];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[window setContentView: fProgressView];
|
|
|
|
[window setFrame: windowRect display: YES animate: YES];
|
|
|
|
[fProgressView setHidden: NO];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-04-07 02:48:51 +00:00
|
|
|
[[window standardWindowButton: NSWindowCloseButton] setEnabled: NO];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-04 01:31:24 +00:00
|
|
|
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
[[alert window] orderOut: nil];
|
|
|
|
[[self window] close];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|