A29DF8BE0DB2545F00D04E5A /* verify.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D22A110D65EED100007D5F /* verify.h */; };
A29E653613F1603100048D71 /* evutil_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = A29E653513F1603100048D71 /* evutil_rand.c */; };
A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */; };
- A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
- A2A3065E0AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
- A2A306600AAD24A80049E2AC /* UKKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306580AAD24A80049E2AC /* UKKQueue.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
- A2A306620AAD24A80049E2AC /* UKMainThreadProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; };
+ A2A3065E0AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */; };
+ A2A306600AAD24A80049E2AC /* UKKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306580AAD24A80049E2AC /* UKKQueue.m */; };
+ A2A306620AAD24A80049E2AC /* UKMainThreadProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */; };
A2A4E9210DE0F7E9000CE197 /* web.h in Headers */ = {isa = PBXBuildFile; fileRef = A29EBE530DC01FC9006CEE80 /* web.h */; };
A2A4E9220DE0F7EB000CE197 /* web.c in Sources */ = {isa = PBXBuildFile; fileRef = A29EBE520DC01FC9006CEE80 /* web.c */; };
A2A4E9870DE10399000CE197 /* json.h in Headers */ = {isa = PBXBuildFile; fileRef = A2A4E9840DE1038C000CE197 /* json.h */; };
A2661D3B12D0E51B004F69D5 /* FilterBarView.m */,
A2ED7D8D0CEF431B00970975 /* FilterButton.h */,
A2ED7D8E0CEF431B00970975 /* FilterButton.m */,
- A28E1DDF0CFFD8EC00E16385 /* ButtonToolbarItem.h */,
A2C89D5F0CFCBF57004CC2BC /* ButtonToolbarItem.m */,
+ A28E1DDF0CFFD8EC00E16385 /* ButtonToolbarItem.h */,
A21979890D07B78400438EA7 /* GroupToolbarItem.h */,
A219798A0D07B78400438EA7 /* GroupToolbarItem.m */,
A20BFFB50D091CC700CE5D2B /* ToolbarSegmentedCell.h */,
0053D3D50C86774200545606 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_ARC = YES;
FRAMEWORK_SEARCH_PATHS = macosx;
GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
INFOPLIST_FILE = macosx/Info.plist;
4DF0C599089918A300DD8943 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_ARC = YES;
FRAMEWORK_SEARCH_PATHS = macosx;
GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
INFOPLIST_FILE = macosx/Info.plist;
A250CFEC0CDA19680068B4B6 /* Release - Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_ARC = YES;
FRAMEWORK_SEARCH_PATHS = macosx;
GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
INFOPLIST_FILE = macosx/Info.plist;
[fCopyrightField setStringValue: [[NSBundle mainBundle] localizedStringForKey: @"NSHumanReadableCopyright"
value: nil table: @"InfoPlist"]];
- [[fTextView textStorage] setAttributedString: [[NSAttributedString alloc] initWithPath:
- [[NSBundle mainBundle] pathForResource: @"Credits" ofType: @"rtf"] documentAttributes: nil]];
+ [[fTextView textStorage] setAttributedString: [[[NSAttributedString alloc] initWithPath:
+ [[NSBundle mainBundle] pathForResource: @"Credits" ofType: @"rtf"] documentAttributes: nil] autorelease]];
//size license button
const CGFloat oldButtonWidth = NSWidth([fLicenseButton frame]);
- (void) windowWillClose: (id) sender
{
+ [fAboutBoxInstance autorelease];
fAboutBoxInstance = nil;
}
IBOutlet NSButton * fStartCheck;
IBOutlet NSPopUpButton * fGroupPopUp, * fPriorityPopUp;
- __unsafe_unretained Controller * fController;
+ Controller * fController;
Torrent * fTorrent;
NSString * fDestination;
if ((self = [super initWithWindowNibName: @"AddMagnetWindow"]))
{
fTorrent = torrent;
- fDestination = [path stringByExpandingTildeInPath];
+ fDestination = [[path stringByExpandingTildeInPath] retain];
fController = controller;
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+
+ [fDestination release];
+
+ [super dealloc];
}
- (Torrent *) torrent
destination = [destination stringByExpandingTildeInPath];
if (!fDestination || ![fDestination isEqualToString: destination])
{
- fDestination = destination;
+ [fDestination release];
+ fDestination = [destination retain];
[fTorrent changeDownloadFolderBeforeUsing: fDestination];
}
ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
[fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
+ [iconTransformer release];
}
- (void) setGroupsMenu
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
+ [alert release];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
IBOutlet FileOutlineController * fFileController;
- __unsafe_unretained Controller * fController;
+ Controller * fController;
Torrent * fTorrent;
NSString * fDestination, * fTorrentFile;
if ((self = [super initWithWindowNibName: @"AddWindow"]))
{
fTorrent = torrent;
- fDestination = [path stringByExpandingTildeInPath];
+ fDestination = [[path stringByExpandingTildeInPath] retain];
fLockDestination = lockDestination;
fController = controller;
- fTorrentFile = [torrentFile stringByExpandingTildeInPath];
+ fTorrentFile = [[torrentFile stringByExpandingTildeInPath] retain];
fDeleteTorrentInitial = deleteTorrent;
fDeleteEnableInitial = canToggleDelete;
[[NSNotificationCenter defaultCenter] removeObserver: self];
[fTimer invalidate];
+
+ [fDestination release];
+ [fTorrentFile release];
+
+ [super dealloc];
}
- (Torrent *) torrent
destination = [destination stringByExpandingTildeInPath];
if (!fDestination || ![fDestination isEqualToString: destination])
{
- fDestination = destination;
+ [fDestination release];
+ fDestination = [destination retain];
[fTorrent changeDownloadFolderBeforeUsing: fDestination];
}
ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
[fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
+ [iconTransformer release];
}
- (void) setGroupsMenu
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
+ [alert release];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
return self;
}
+- (void) dealloc
+{
+ [fAttributes release];
+ [super dealloc];
+}
- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
{
[fAttributes setObject: [NSColor whiteColor] forKey: NSForegroundColorAttributeName];
[fAttributes setObject: stringShadow forKey: NSShadowAttributeName];
+ [stringShadow release];
}
NSRect badgeRect;
BadgeView * view = [[BadgeView alloc] initWithLib: lib];
[[NSApp dockTile] setContentView: view];
+ [view release];
fHashes = [[NSMutableSet alloc] init];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+
+ [fHashes release];
+
+ [super dealloc];
}
- (void) updateBadgeWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
{
NSURLDownload * fDownload;
- __unsafe_unretained BlocklistDownloaderViewController * fViewController;
+ BlocklistDownloaderViewController * fViewController;
NSString * fDestination;
NSUInteger fCurrentSize;
- (void) startDownload;
- (void) decompressBlocklist;
+- (void) finishDownloadSuccess;
@end
@implementation BlocklistDownloader
-BlocklistDownloader * fBLDownloader = nil;
+BlocklistDownloader * fDownloader = nil;
+ (BlocklistDownloader *) downloader
{
- if (!fBLDownloader)
+ if (!fDownloader)
{
- fBLDownloader = [[BlocklistDownloader alloc] init];
- [fBLDownloader startDownload];
+ fDownloader = [[BlocklistDownloader alloc] init];
+ [fDownloader startDownload];
}
- return fBLDownloader;
+ return fDownloader;
}
+ (BOOL) isRunning
{
- return fBLDownloader != nil;
+ return fDownloader != nil;
}
- (void) setViewController: (BlocklistDownloaderViewController *) viewController
}
}
+- (void) dealloc
+{
+ [fDownload release];
+ [fDestination release];
+ [super dealloc];
+}
- (void) cancelDownload
{
[[BlocklistScheduler scheduler] updateSchedule];
- fBLDownloader = nil;
+ fDownloader = nil;
+ [self release];
}
//using the actual filename is the best bet
- (void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
{
- fDestination = path;
+ [fDestination release];
+ fDestination = [path retain];
}
- (void) download: (NSURLDownload *) download didReceiveResponse: (NSURLResponse *) response
[[NSUserDefaults standardUserDefaults] setObject: [NSDate date] forKey: @"BlocklistNewLastUpdate"];
[[BlocklistScheduler scheduler] updateSchedule];
- fBLDownloader = nil;
+ fDownloader = nil;
+ [self release];
}
- (void) downloadDidFinish: (NSURLDownload *) download
{
fState = BLOCKLIST_DL_PROCESSING;
-
- [fViewController setStatusProcessing];
-
- //process data
- NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [self decompressBlocklist];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
-
- //delete downloaded file
- [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
-
- if (count > 0)
- [fViewController setFinished];
- else
- [fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
- "blocklist fail message")];
-
- //update last updated date for schedule
- NSDate * date = [NSDate date];
- [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
- [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
- [[BlocklistScheduler scheduler] updateSchedule];
-
- [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
-
- fBLDownloader = nil;
- });
- });
+ [self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
}
- (BOOL) download: (NSURLDownload *) download shouldDecodeSourceDataOfMIMEType: (NSString *) encodingType
{
success = NO;
}
+ [unzip release];
if (success) {
//Now find out what file we actually extracted; don't just assume it matches the zipfile's name
[zipinfo launch];
[zipinfo waitUntilExit];
- NSString * actualFilename = [[NSString alloc] initWithData: [zipinfoOutput readDataToEndOfFile]
- encoding: NSUTF8StringEncoding];
+ NSString * actualFilename = [[[NSString alloc] initWithData: [zipinfoOutput readDataToEndOfFile]
+ encoding: NSUTF8StringEncoding] autorelease];
actualFilename = [actualFilename stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString * newBlocklistPath = [workingDirectory stringByAppendingPathComponent: actualFilename];
//Finally, delete the ZIP file; we're done with it, and we'll return the unzipped blocklist
[[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
- fDestination = newBlocklistPath;
+ [fDestination release];
+ fDestination = [newBlocklistPath retain];
}
@catch(id exc) {}
+ [zipinfo release];
}
}
}
+
+- (void) finishDownloadSuccess
+{
+ @autoreleasepool
+ {
+ [fViewController setStatusProcessing];
+
+ //process data
+ NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
+
+ [self decompressBlocklist];
+
+ const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
+
+ //delete downloaded file
+ [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
+
+ if (count > 0)
+ [fViewController setFinished];
+ else
+ [fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
+ "blocklist fail message")];
+
+ //update last updated date for schedule
+ NSDate * date = [NSDate date];
+ [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
+ [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
+ [[BlocklistScheduler scheduler] updateSchedule];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
+ }
+
+ fDownloader = nil;
+ [self release];
+}
+
@end
@interface BlocklistDownloaderViewController : NSObject
{
- __unsafe_unretained PrefsController * fPrefsController;
+ PrefsController * fPrefsController;
IBOutlet NSWindow * fStatusWindow;
IBOutlet NSProgressIndicator * fProgressBar;
@implementation BlocklistDownloaderViewController
-BlocklistDownloaderViewController * fBLViewController = nil;
+ (void) downloadWithPrefsController: (PrefsController *) prefsController
{
- if (!fBLViewController)
- {
- fBLViewController = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
- [fBLViewController startDownload];
- }
+ BlocklistDownloaderViewController * downloader = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
+ [downloader startDownload];
}
- (void) awakeFromNib
[NSApp endSheet: fStatusWindow];
[fStatusWindow orderOut: self];
- fBLViewController = nil;
+ [self release];
}
- (void) setFailed: (NSString *) error
[NSApp endSheet: fStatusWindow];
[fStatusWindow orderOut: self];
- NSAlert * alert = [[NSAlert alloc] init];
+ NSAlert * alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Blocklist -> button")];
[alert setMessageText: NSLocalizedString(@"Download of the blocklist failed.", "Blocklist -> message")];
[alert setAlertStyle: NSWarningAlertStyle];
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
{
[[alert window] orderOut: self];
-
- fBLViewController = nil;
+ [self release];
}
@end
BonjourController * fDefaultController = nil;
+ (BonjourController *) defaultController
{
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
+ if (!fDefaultController)
fDefaultController = [[BonjourController alloc] init];
- });
-
return fDefaultController;
}
+- (void) dealloc
+{
+ [fService release];
+ [super dealloc];
+}
- (void) startWithPort: (NSInteger) port
{
- (void) stop
{
[fService stop];
+ [fService release];
fService = nil;
}
#import <Cocoa/Cocoa.h>
@interface ButtonToolbarItem : NSToolbarItem
+{
+}
@end
[menuItem setTarget: [self target]];
[menuItem setEnabled: [[self target] validateToolbarItem: self]];
- return menuItem;
+ return [menuItem autorelease];
}
@end
NSMutableSet * fAddingTransfers;
- NSMutableSet * fAddWindows;
- URLSheetWindowController * fUrlSheetController;
-
BOOL fGlobalPopoverShown;
BOOL fSoundPlaying;
}
- (void) openURL: (NSString *) urlString;
- (void) openURLShowSheet: (id) sender;
+- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode;
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
{
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [[NSNumber alloc] initWithBool: active], @"Active",
[[NSNumber alloc] initWithBool: byUser], @"ByUser", nil];
- [(__bridge Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
+ [(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
withObject: dict waitUntilDone: NO];
}
static tr_rpc_callback_status rpcCallback(tr_session * handle UNUSED, tr_rpc_callback_type type, struct tr_torrent * torrentStruct,
void * controller)
{
- [(__bridge Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
+ [(Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
return TR_RPC_NOREMOVE; //we'll do the remove manually
}
static void sleepCallback(void * controller, io_service_t y, natural_t messageType, void * messageArgument)
{
- [(__bridge Controller *)controller sleepCallback: messageType argument: messageArgument];
+ [(Controller *)controller sleepCallback: messageType argument: messageArgument];
}
@implementation Controller
[alert setAlertStyle: NSCriticalAlertStyle];
[alert runModal];
+ [alert release];
//kill ourselves right away
exit(0);
[[NSBundle mainBundle] pathForResource: @"Defaults" ofType: @"plist"]]];
//set custom value transformers
- ExpandedPathToPathTransformer * pathTransformer = [[ExpandedPathToPathTransformer alloc] init];
+ ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer: pathTransformer forName: @"ExpandedPathToPathTransformer"];
- ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
+ ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer: iconTransformer forName: @"ExpandedPathToIconTransformer"];
//cover our asses
if ([alert runModal] == NSAlertSecondButtonReturn)
exit(0);
+ [alert release];
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningLegal"];
}
fGlobalPopoverShown = NO;
fSoundPlaying = NO;
- tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, (__bridge void *)(self));
+ tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, self);
if (usesSpeedLimitSched)
[fDefaults setBool: tr_sessionUsesAltSpeed(fLib) forKey: @"SpeedLimit"];
- tr_sessionSetRPCCallback(fLib, rpcCallback, (__bridge void *)(self));
+ tr_sessionSetRPCCallback(fLib, rpcCallback, self);
[GrowlApplicationBridge setGrowlDelegate: self];
[toolbar setAutosavesConfiguration: YES];
[toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
[fWindow setToolbar: toolbar];
+ [toolbar release];
[fWindow setDelegate: self]; //do manually to avoid placement issue
//register for sleep notifications
IONotificationPortRef notify;
io_object_t iterator;
- if ((fRootPort = IORegisterForSystemPower((__bridge void *)(self), & notify, sleepCallback, &iterator)))
+ if ((fRootPort = IORegisterForSystemPower(self, & notify, sleepCallback, &iterator)))
CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notify), kCFRunLoopCommonModes);
else
NSLog(@"Could not IORegisterForSystemPower");
if (!fPauseOnLaunch && (waitToStart = [historyItem objectForKey: @"WaitToStart"]) && [waitToStart boolValue])
[waitToStartTorrents addObject: torrent];
+ [torrent release];
}
}
if (allowNeverAgain)
[fDefaults setBool: ([[alert suppressionButton] state] != NSOnState) forKey: @"WarningDonate"];
+ [alert release];
}
}
}
{
if ([fAutoImportTimer isValid])
[fAutoImportTimer invalidate];
+ [fAutoImportTimer release];
}
[fBadger setQuitting];
{
NSURLDownload * download = [downloadDict objectForKey: @"Download"];
[download cancel];
+ [download release];
}
+ [fPendingTorrentDownloads release];
}
//remember window states and close all windows
[self updateTorrentHistory];
[fTableView saveCollapsedGroups];
+ //remaining calls the same as dealloc
+ [fInfoController release];
+ [fMessageController release];
+ [fPrefsController release];
+
+ [fStatusBar release];
+ [fFilterBar release];
+
+ [fTorrents release];
+ [fDisplayedTorrents release];
+
+ [fAddingTransfers release];
+
+ [fOverlayWindow release];
+ [fBadger release];
+
+ [fAutoImportedNames release];
+
+ [fPreviewPanel release];
+
//complete cleanup
tr_sessionClose(fLib);
}
{
[download cancel];
- [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
- if ([fPendingTorrentDownloads count] == 0)
- fPendingTorrentDownloads = nil;
-
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
[NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
"Download not a torrent -> message"), suggestedName,
[[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]],
NSLocalizedString(@"OK", "Download not a torrent -> button"), nil, nil);
+
+ [download release];
}
else
[download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]]
-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
{
- [(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
+ if (!fPendingTorrentDownloads)
+ fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
+
+ [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
+ path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
}
- (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
if ([fPendingTorrentDownloads count] == 0)
+ {
+ [fPendingTorrentDownloads release];
fPendingTorrentDownloads = nil;
+ }
+
+ [download release];
}
- (void) downloadDidFinish: (NSURLDownload *) download
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
if ([fPendingTorrentDownloads count] == 0)
+ {
+ [fPendingTorrentDownloads release];
fPendingTorrentDownloads = nil;
+ }
+
+ [download release];
}
- (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
lockDestination: lockDestination controller: self torrentFile: torrentPath
deleteTorrent: deleteTorrentFile canToggleDelete: canToggleDelete];
[addController showWindow: self];
-
- if (!fAddWindows)
- fAddWindows = [NSMutableSet set];
- [fAddWindows addObject: addController];
}
else
{
[torrent update];
[fTorrents addObject: torrent];
+ [torrent release];
if (!fAddingTransfers)
fAddingTransfers = [[NSMutableSet alloc] init];
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
{
Torrent * torrent = [addController torrent];
+ [addController autorelease];
if (add)
{
[torrent update];
[fTorrents addObject: torrent];
+ [torrent release];
if (!fAddingTransfers)
fAddingTransfers = [[NSMutableSet alloc] init];
else
{
[torrent closeRemoveTorrent: NO];
+ [torrent release];
}
-
- [fAddWindows removeObject: addController];
- if ([fAddWindows count] == 0)
- fAddWindows = nil;
}
- (void) openMagnet: (NSString *) address
AddMagnetWindowController * addController = [[AddMagnetWindowController alloc] initWithTorrent: torrent destination: location
controller: self];
[addController showWindow: self];
-
- if (!fAddWindows)
- fAddWindows = [NSMutableSet set];
- [fAddWindows addObject: addController];
}
else
{
[torrent update];
[fTorrents addObject: torrent];
+ [torrent release];
if (!fAddingTransfers)
fAddingTransfers = [[NSMutableSet alloc] init];
- (void) askOpenMagnetConfirmed: (AddMagnetWindowController *) addController add: (BOOL) add
{
Torrent * torrent = [addController torrent];
+ [addController autorelease];
if (add)
{
[torrent update];
[fTorrents addObject: torrent];
+ [torrent release];
if (!fAddingTransfers)
fAddingTransfers = [[NSMutableSet alloc] init];
else
{
[torrent closeRemoveTorrent: NO];
+ [torrent release];
}
-
- [fAddWindows removeObject: addController];
- if ([fAddWindows count] == 0)
- fAddWindows = nil;
}
- (void) openCreatedFile: (NSNotification *) notification
{
NSDictionary * dict = [notification userInfo];
- [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] addType: ADD_CREATED forcePath: [dict objectForKey: @"Path"]];
+ [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] addType: ADD_CREATED
+ forcePath: [dict objectForKey: @"Path"]];
+ [dict release];
}
- (void) openFilesWithDict: (NSDictionary *) dictionary
{
[self openFiles: [dictionary objectForKey: @"Filenames"] addType: [[dictionary objectForKey: @"AddType"] intValue] forcePath: nil];
+
+ [dictionary release];
}
//called on by applescript
[alert runModal];
if ([[alert suppressionButton] state] == NSOnState)
[fDefaults setBool: NO forKey: @"WarningInvalidOpen"];
+ [alert release];
}
- (void) invalidOpenMagnetAlert: (NSString *) address
[alert runModal];
if ([[alert suppressionButton] state] == NSOnState)
[fDefaults setBool: NO forKey: @"WarningInvalidOpen"];
+ [alert release];
}
- (void) duplicateOpenAlert: (NSString *) name
[alert runModal];
if ([[alert suppressionButton] state])
[fDefaults setBool: NO forKey: @"WarningDuplicate"];
+ [alert release];
}
- (void) duplicateOpenMagnetAlert: (NSString *) address transferName: (NSString *) name
[alert runModal];
if ([[alert suppressionButton] state])
[fDefaults setBool: NO forKey: @"WarningDuplicate"];
+ [alert release];
}
- (void) openURL: (NSString *) urlString
NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
-
- if ([fPendingTorrentDownloads objectForKey: [request URL]])
- {
- NSLog(@"Already downloading %@", [request URL]);
- return;
- }
-
- NSURLDownload * download = [[NSURLDownload alloc] initWithRequest: request delegate: self];
-
- if (!fPendingTorrentDownloads)
- fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
-
- [fPendingTorrentDownloads setObject: [NSMutableDictionary dictionaryWithObject: download forKey: @"Download"] forKey: [request URL]];
+ [[NSURLDownload alloc] initWithRequest: request delegate: self];
}
}
- (void) openURLShowSheet: (id) sender
{
- if (!fUrlSheetController)
- {
- fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self];
-
- [NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
- }
+ [[[URLSheetWindowController alloc] initWithController: self] beginSheetForWindow: fWindow];
}
-- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
+- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
{
if (returnCode == 1)
- {
- NSString * urlString = [fUrlSheetController urlString];
[self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
- }
- fUrlSheetController = nil;
+ [controller release];
}
- (void) createFile: (id) sender
- (void) removeTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
{
+ [torrents retain];
if ([fDefaults boolForKey: @"CheckRemove"])
{
NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"),
NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self,
- nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge void *)dict, message);
+ nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), dict, message);
return;
}
}
NSArray * torrents = [dict objectForKey: @"Torrents"];
if (returnCode == NSAlertDefaultReturn)
[self confirmRemoveTorrents: torrents deleteData: [[dict objectForKey: @"DeleteData"] boolValue]];
+ else
+ [torrents release];
+
+ [dict release];
}
- (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
[fTableView selectValues: selectedValues];
[self fullUpdateUI];
+
+ #warning why do we need them retained?
+ [torrents autorelease];
}
- (void) removeNoDelete: (id) sender
"Remove completed confirm panel -> message");
}
- NSAlert * alert = [[NSAlert alloc] init];
+ NSAlert * alert = [[[NSAlert alloc] init] autorelease];
[alert setMessageText: message];
[alert setInformativeText: info];
[alert setAlertStyle: NSWarningAlertStyle];
if (returnCode != NSAlertFirstButtonReturn)
{
+ [torrents release];
return;
}
}
{
if ([torrents count] == 0)
{
+ [torrents release];
return;
}
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];
+ [alert release];
}
[torrents removeObjectAtIndex: 0];
TorrentGroup * newGroup = [groupsByIndex objectForKey: [NSNumber numberWithInteger: groupValue]];
if (!newGroup)
{
- newGroup = [[TorrentGroup alloc] initWithGroup: groupValue];
+ newGroup = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
[groupsByIndex setObject: newGroup forKey: [NSNumber numberWithInteger: groupValue]];
[fDisplayedTorrents addObject: newGroup];
TorrentGroup * group = [groupsByIndex objectForKey: [NSNumber numberWithInteger: groupValue]];
if (!group)
{
- group = [[TorrentGroup alloc] initWithGroup: groupValue];
+ group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
[groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
[fDisplayedTorrents addObject: group];
TorrentGroup * group = [groupsByIndex objectForKey: [NSNumber numberWithInteger: groupValue]];
if (!group)
{
- group = [[TorrentGroup alloc] initWithGroup: groupValue];
+ group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
[groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
}
if (fAddingTransfers)
{
+ [fAddingTransfers release];
fAddingTransfers = nil;
}
}
[popover showRelativeToRect: [sender frame] ofView: sender preferredEdge: NSMaxYEdge];
+ [viewController release];
+ [popover release];
}
else
{
const NSInteger groupMenuCount = [groupMenu numberOfItems];
for (NSInteger i = 0; i < groupMenuCount; i++)
{
- NSMenuItem * item = [groupMenu itemAtIndex: 0];
+ NSMenuItem * item = [[groupMenu itemAtIndex: 0] retain];
[groupMenu removeItemAtIndex: 0];
[menu addItem: item];
+ [item release];
}
}
else if (menu == fUploadMenu || menu == fDownloadMenu)
[item setTarget: self];
[item setRepresentedObject: [NSNumber numberWithInt: speedLimitActionValue[i]]];
[menu addItem: item];
+ [item release];
}
}
else if (menu == fRatioStopMenu)
[item setTarget: self];
[item setRepresentedObject: [NSNumber numberWithFloat: ratioLimitActionValue[i]]];
[menu addItem: item];
+ [item release];
}
}
else;
description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description")
notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil];
+ [dict release];
}
- (void) setLimitGlobalEnabled: (id) sender
{
if ([fAutoImportTimer isValid])
[fAutoImportTimer invalidate];
+ [fAutoImportTimer release];
fAutoImportTimer = nil;
}
//check again in 10 seconds in case torrent file wasn't complete
- fAutoImportTimer = [NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
- selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO];
+ fAutoImportTimer = [[NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
+ selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO] retain];
[self checkAutoImportDirectory];
}
{
if ([fAutoImportTimer isValid])
[fAutoImportTimer invalidate];
+ [fAutoImportTimer release];
fAutoImportTimer = nil;
}
- fAutoImportedNames = nil;
+ if (fAutoImportedNames)
+ {
+ [fAutoImportedNames release];
+ fAutoImportedNames = nil;
+ }
[self checkAutoImportDirectory];
}
tr_ctorFree(ctor);
}
+ [newNames release];
}
- (void) beginCreateFile: (NSNotification *) notification
if (!show)
{
[[fStatusBar view] removeFromSuperviewWithoutNeedingDisplay];
+ [fStatusBar release];
fStatusBar = nil;
}
if (!show)
{
[[fFilterBar view] removeFromSuperviewWithoutNeedingDisplay];
+ [fFilterBar release];
fFilterBar = nil;
}
- (void) beginPreviewPanelControl: (QLPreviewPanel *) panel
{
- fPreviewPanel = panel;
+ fPreviewPanel = [panel retain];
[fPreviewPanel setDelegate: self];
[fPreviewPanel setDataSource: self];
}
- (void) endPreviewPanelControl: (QLPreviewPanel *) panel
{
+ [fPreviewPanel release];
fPreviewPanel = nil;
}
[button setStringValue: @""];
[item setView: button];
+ [button release];
const NSSize buttonSize = NSMakeSize(36.0, 25.0);
[item setMinSize: buttonSize];
[item setMaxSize: buttonSize];
- return item;
+ return [item autorelease];
}
- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
GroupToolbarItem * groupItem = [[GroupToolbarItem alloc] initWithItemIdentifier: ident];
NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
- [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]];
+ [segmentedControl setCell: [[[ToolbarSegmentedCell alloc] init] autorelease]];
[groupItem setView: segmentedControl];
NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell];
[groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
+ [segmentedControl release];
[groupItem setVisibilityPriority: NSToolbarItemVisibilityPriorityHigh];
- return groupItem;
+ return [groupItem autorelease];
}
else if ([ident isEqualToString: TOOLBAR_PAUSE_RESUME_SELECTED])
{
GroupToolbarItem * groupItem = [[GroupToolbarItem alloc] initWithItemIdentifier: ident];
NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
- [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]];
+ [segmentedControl setCell: [[[ToolbarSegmentedCell alloc] init] autorelease]];
[groupItem setView: segmentedControl];
NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell];
[groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause Selected", "Selected toolbar item -> label"),
NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
+ [segmentedControl release];
[groupItem setVisibilityPriority: NSToolbarItemVisibilityPriorityHigh];
- return groupItem;
+ return [groupItem autorelease];
}
else if ([ident isEqualToString: TOOLBAR_FILTER])
{
[menu addItem: [NSMenuItem separatorItem]];
[menu addItemWithTitle: NSLocalizedString(@"Speed Limit", "Dock item") action: @selector(toggleSpeedLimit:) keyEquivalent: @""];
- return menu;
+ return [menu autorelease];
}
- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
for (torrent in fTorrents)
if (torrentStruct == [torrent torrentStruct])
{
+ [torrent retain];
break;
}
{
case TR_RPC_TORRENT_ADDED:
[self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
- [NSValue valueWithPointer: torrentStruct] waitUntilDone: NO];
+ [[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
break;
case TR_RPC_TORRENT_STARTED:
default:
NSAssert1(NO, @"Unknown RPC command received: %d", type);
+ [torrent release];
}
}
}
- (void) rpcAddTorrentStruct: (NSValue *) torrentStructPtr
{
tr_torrent * torrentStruct = (tr_torrent *)[torrentStructPtr pointerValue];
+ [torrentStructPtr release];
NSString * location = nil;
if (tr_torrentGetDownloadDir(torrentStruct) != NULL)
[torrent update];
[fTorrents addObject: torrent];
+ [torrent release];
if (!fAddingTransfers)
fAddingTransfers = [[NSMutableSet alloc] init];
- (void) rpcRemoveTorrent: (Torrent *) torrent
{
- [self confirmRemoveTorrents: [NSArray arrayWithObject: torrent] deleteData: NO];
+ [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: NO];
+ [torrent release];
}
- (void) rpcRemoveTorrentDeleteData: (Torrent *) torrent
{
- [self confirmRemoveTorrents: [NSArray arrayWithObject: torrent] deleteData: YES];
+ [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: YES];
+ [torrent release];
}
- (void) rpcStartedStoppedTorrent: (Torrent *) torrent
{
[torrent update];
+ [torrent release];
[self updateUI];
[self applyFilter];
[fInfoController updateOptions];
}
+ [torrent release];
}
- (void) rpcMovedTorrent: (Torrent *) torrent
if ([[fTableView selectedTorrents] containsObject: torrent])
[fInfoController updateInfoStats];
+ [torrent release];
}
- (void) rpcUpdateQueue
{
fStarted = NO;
- fPath = path;
+ fPath = [path retain];
fInfo = tr_metaInfoBuilderCreate([fPath UTF8String]);
if (fInfo->fileCount == 0)
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];
+ [alert release];
+ [self release];
return nil;
}
if (fInfo->totalSize == 0)
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];
+ [alert release];
+ [self release];
return nil;
}
[fPiecesField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d pieces, %@ each", "Create torrent -> info"),
fInfo->pieceCount, [NSString stringForFileSize: fInfo->pieceSize]]];
- fLocation = [[[fDefaults stringForKey: @"CreatorLocation"] stringByExpandingTildeInPath] stringByAppendingPathComponent:
- [name stringByAppendingPathExtension: @"torrent"]];
+ fLocation = [[[[fDefaults stringForKey: @"CreatorLocation"] stringByExpandingTildeInPath] stringByAppendingPathComponent:
+ [name stringByAppendingPathExtension: @"torrent"]] retain];
[fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
[fLocationField setToolTip: fLocation];
- (void) dealloc
{
+ [fPath release];
+ [fLocation release];
+ [fTrackers release];
if (fInfo)
tr_metaInfoBuilderFree(fInfo);
[fTimer invalidate];
+ [super dealloc];
}
- (void) setLocation: (id) sender
[panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
{
- fLocation = [[panel URL] path];
+ [fLocation release];
+ fLocation = [[[panel URL] path] retain];
[fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
[fLocationField setToolTip: fLocation];
[[self window] close];
}
+- (void) windowWillClose: (NSNotification *) notification
+{
+ [self autorelease];
+}
+
- (void) cancelCreateProgress: (id) sender
{
fInfo->abortFlag = 1;
BOOL added = NO;
- for (__strong NSString * tracker in tempTrackers)
+ for (NSString * tracker in tempTrackers)
{
tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorPrivateBlankAddress"];
}
+ [alert release];
if (returnCode == NSAlertFirstButtonReturn)
[self performSelectorOnMainThread: @selector(createReal) withObject: nil waitUntilDone: NO];
//check if the location currently exists
if (![[NSFileManager defaultManager] fileExistsAtPath: [fLocation stringByDeletingLastPathComponent]])
{
- NSAlert * alert = [[NSAlert alloc] init];
+ NSAlert * alert = [[[NSAlert alloc] init] autorelease];
[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")];
NSArray * pathComponents = [fLocation pathComponents];
NSInteger count = [pathComponents count];
- NSAlert * alert = [[NSAlert alloc] init];
+ NSAlert * alert = [[[NSAlert alloc] init] autorelease];
[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")];
break;
default:
- alert = [[NSAlert alloc] init];
+ alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> failed -> button")];
[alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Creation of \"%@\" failed.",
"Create torrent -> failed -> title"), [fLocation lastPathComponent]]];
smallFont, NSFontAttributeName, stringShadow, NSShadowAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
+ [stringShadow release];
+ [paragraphStyle release];
}
return self;
}
+- (void) dealloc
+{
+ [fBadge release];
+
+ [fMainLineAttributes release];
+ [fSubLineAttributes release];
+
+ [super dealloc];
+}
- (void) setOverlay: (NSImage *) icon mainLine: (NSString *) mainLine subLine: (NSString *) subLine
{
+ [fBadge release];
//create badge
const NSRect badgeRect = NSMakeRect(0.0, 0.0, 325.0, 84.0);
DragOverlayView * view = [[DragOverlayView alloc] initWithFrame: [self frame]];
[self setContentView: view];
+ [view release];
[self setReleasedWhenClosed: NO];
[self setIgnoresMouseEvents: YES];
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [fFadeInAnimation release];
+ [fFadeOutAnimation release];
+ [super dealloc];
}
- (void) setTorrents: (NSArray *) files
#import <Foundation/Foundation.h>
@interface ExpandedPathToIconTransformer : NSValueTransformer
+{
+}
@end
\ No newline at end of file
#import <Foundation/Foundation.h>
@interface ExpandedPathToPathTransformer : NSValueTransformer
+{
+}
@end
\ No newline at end of file
NSString * fName;
NSString * fPath;
- Torrent * __unsafe_unretained fTorrent;
+ Torrent * fTorrent;
uint64_t fSize;
NSImage * fIcon;
BOOL fIsFolder;
@property (nonatomic, readonly) NSString * name;
@property (nonatomic, readonly) NSString * path;
-@property (nonatomic, readonly, unsafe_unretained) Torrent * torrent;
+@property (nonatomic, readonly) Torrent * torrent;
@property (nonatomic, readonly) uint64_t size;
@property (nonatomic, readonly) NSImage * icon;
- (id) copyWithZone: (NSZone *) zone
{
//this object is essentially immutable after initial setup
- return self;
+ return [self retain];
}
+- (void) dealloc
+{
+ [fName release];
+ [fPath release];
+ [fIndexes release];
+
+ [fIcon release];
+
+ [fChildren release];
+
+ [super dealloc];
+}
- (NSString *) description
{
- (NSImage *) icon
{
if (!fIcon)
- fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fIsFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
- : [fName pathExtension]];
+ fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: fIsFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
+ : [fName pathExtension]] retain];
return fIcon;
}
if ((self = [super init]))
{
fIsFolder = isFolder;
- fName = name;
- fPath = path;
+ fName = [name retain];
+ fPath = [path retain];
fIndexes = [[NSMutableIndexSet alloc] init];
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
statusParagraphStyle, NSParagraphStyleAttributeName, nil];
+ [paragraphStyle release];
+ [statusParagraphStyle release];
}
return self;
}
+- (void) dealloc
+{
+ [fTitleAttributes release];
+ [fStatusAttributes release];
+
+ [super dealloc];
+}
+
+- (id) copyWithZone: (NSZone *) zone
+{
+ FileNameCell * copy = [super copyWithZone: zone];
+
+ copy->fTitleAttributes = [fTitleAttributes retain];
+ copy->fStatusAttributes = [fStatusAttributes retain];
+
+ return copy;
+}
+
- (NSImage *) image
{
FileListNode * node = (FileListNode *)[self objectValue];
- (NSAttributedString *) attributedTitle
{
NSString * title = [(FileListNode *)[self objectValue] name];
- return [[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes];
+ return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease];
}
- (NSAttributedString *) attributedStatus
NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@",
"Inspector -> Files tab -> file status string"), percentString, [NSString stringForFileSize: [node size]]];
- return [[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes];
+ return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease];
}
@end
@interface FileOutlineController : NSObject
{
- __unsafe_unretained Torrent * fTorrent;
+ Torrent * fTorrent;
NSMutableArray * fFileList;
IBOutlet FileOutlineView * fOutline;
[self setTorrent: nil];
}
+- (void) dealloc
+{
+ [fFileList release];
+ [fFilterText release];
+
+ [super dealloc];
+}
+
- (FileOutlineView *) outlineView
{
return fOutline;
[fFileList setArray: [fTorrent fileList]];
+ [fFilterText release];
fFilterText = nil;
[fOutline reloadData];
else
[fOutline reloadData];
- fFilterText = text;
+ [fFilterText release];
+ fFilterText = [text retain];
}
- (void) refresh
[item setTarget: self];
[item setTag: FILE_CHECK_TAG];
[menu addItem: item];
+ [item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Uncheck Selected", "File Outline -> Menu")
action: @selector(setCheck:) keyEquivalent: @""];
[item setTarget: self];
[item setTag: FILE_UNCHECK_TAG];
[menu addItem: item];
+ [item release];
//only check selected
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Only Check Selected", "File Outline -> Menu")
action: @selector(setOnlySelectedCheck:) keyEquivalent: @""];
[item setTarget: self];
[menu addItem: item];
+ [item release];
[menu addItem: [NSMenuItem separatorItem]];
NSMenu * priorityMenu = [[NSMenu alloc] initWithTitle: @"File Priority Menu"];
[item setSubmenu: priorityMenu];
[menu addItem: item];
+ [item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"High", "File Outline -> Priority Menu")
action: @selector(setPriority:) keyEquivalent: @""];
[item setTag: FILE_PRIORITY_HIGH_TAG];
[item setImage: [NSImage imageNamed: @"PriorityHighTemplate.png"]];
[priorityMenu addItem: item];
+ [item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Normal", "File Outline -> Priority Menu")
action: @selector(setPriority:) keyEquivalent: @""];
[item setTag: FILE_PRIORITY_NORMAL_TAG];
[item setImage: [NSImage imageNamed: @"PriorityNormalTemplate.png"]];
[priorityMenu addItem: item];
+ [item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Low", "File Outline -> Priority Menu")
action: @selector(setPriority:) keyEquivalent: @""];
[item setTag: FILE_PRIORITY_LOW_TAG];
[item setImage: [NSImage imageNamed: @"PriorityLowTemplate.png"]];
[priorityMenu addItem: item];
+ [item release];
+ [priorityMenu release];
[menu addItem: [NSMenuItem separatorItem]];
action: @selector(revealFile:) keyEquivalent: @""];
[item setTarget: self];
[menu addItem: item];
+ [item release];
- return menu;
+ return [menu autorelease];
}
- (NSUInteger) findFileNode: (FileListNode *) node inList: (NSArray *) list atIndexes: (NSIndexSet *) indexes currentParent: (FileListNode *) currentParent finalParent: (FileListNode **) parent
{
FileNameCell * nameCell = [[FileNameCell alloc] init];
[[self tableColumnWithIdentifier: @"Name"] setDataCell: nameCell];
+ [nameCell release];
FilePriorityCell * priorityCell = [[FilePriorityCell alloc] init];
[[self tableColumnWithIdentifier: @"Priority"] setDataCell: priorityCell];
+ [priorityCell release];
[self setAutoresizesOutlineColumn: NO];
[self setIndentationPerLevel: 14.0];
fMouseRow = -1;
}
+- (void) dealloc
+{
+ [super dealloc];
+}
- (void) mouseDown: (NSEvent *) event
{
NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: cellFrame options: options owner: controlView userInfo: userInfo];
[controlView addTrackingArea: area];
+ [area release];
}
- (void) setHovered: (BOOL) hovered
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
}
- (void) setFilter: (id) sender
const NSInteger groupMenuCount = [groupMenu numberOfItems];
for (NSInteger i = 0; i < groupMenuCount; i++)
{
- NSMenuItem * item = [groupMenu itemAtIndex: 0];
+ NSMenuItem * item = [[groupMenu itemAtIndex: 0] retain];
[groupMenu removeItemAtIndex: 0];
[menu addItem: item];
+ [item release];
}
}
}
return self;
}
+- (void) dealloc
+{
+ [fGradient release];
+ [super dealloc];
+}
- (BOOL) mouseDownCanMoveWindow
{
- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
{
- fInitialString = [control stringValue];
+ [fInitialString release];
+ fInitialString = [[control stringValue] retain];
return YES;
}
if (fInitialString)
{
[control setStringValue: fInitialString];
+ [fInitialString release];
fInitialString = nil;
}
return NO;
@implementation GroupToolbarItem
+- (void) dealloc
+{
+ [fIdentifiers release];
+ [super dealloc];
+}
- (void) setIdentifiers: (NSArray *) identifiers
{
- fIdentifiers = identifiers;
+ [fIdentifiers release];
+ fIdentifiers = [identifiers retain];
}
- (void) validate
for (NSInteger i = 0; i < [control segmentCount]; i++)
[control setEnabled: [[self target] validateToolbarItem:
- [[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]]] forSegment: i];
+ [[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]] forSegment: i];
}
- (void) createMenu: (NSArray *) labels
[addItem setTag: i];
[menu addItem: addItem];
+ [addItem release];
}
+ [menu release];
[self setMenuFormRepresentation: menuItem];
+ [menuItem release];
}
- (NSMenuItem *) menuFormRepresentation
const NSInteger count = [(NSSegmentedControl *)[self view] segmentCount];
for (NSInteger i = 0; i < count; i++)
[[[menuItem submenu] itemAtIndex: i] setEnabled: [[self target] validateToolbarItem:
- [[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]]]];
+ [[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]]];
return menuItem;
}
{
NSData * data;
if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"GroupDicts"]))
- fGroups = [NSKeyedUnarchiver unarchiveObjectWithData: data];
+ fGroups = [[NSKeyedUnarchiver unarchiveObjectWithData: data] retain];
else if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"Groups"])) //handle old groups
{
- fGroups = [NSUnarchiver unarchiveObjectWithData: data];
+ fGroups = [[NSUnarchiver unarchiveObjectWithData: data] retain];
[[NSUserDefaults standardUserDefaults] removeObjectForKey: @"Groups"];
[self saveGroups];
}
return self;
}
+- (void) dealloc
+{
+ [fGroups release];
+ [super dealloc];
+}
- (NSInteger) numberOfGroups
{
[icon setSize: NSMakeSize(ICON_WIDTH_SMALL, ICON_WIDTH_SMALL)];
[item setImage: icon];
+ [icon release];
}
else
[item setImage: icon];
[menu addItem: item];
+ [item release];
for (NSMutableDictionary * dict in fGroups)
{
[icon setSize: NSMakeSize(ICON_WIDTH_SMALL, ICON_WIDTH_SMALL)];
[item setImage: icon];
+ [icon release];
}
else
[item setImage: icon];
[menu addItem: item];
+ [item release];
}
- return menu;
+ return [menu autorelease];
}
- (NSInteger) groupIndexForTorrent: (Torrent *) torrent;
NSMutableDictionary * tempDict = [dict mutableCopy];
[tempDict removeObjectForKey: @"Icon"];
[groups addObject: tempDict];
+ [tempDict release];
}
[[NSUserDefaults standardUserDefaults] setObject: [NSKeyedArchiver archivedDataWithRootObject: groups] forKey: @"GroupDicts"];
NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [color blendedColorWithFraction: 0.45 ofColor:
[NSColor whiteColor]] endingColor: color];
[gradient drawInBezierPath: bp angle: 270.0];
+ [gradient release];
//inside
bp = [NSBezierPath bezierPathWithRoundedRect: NSInsetRect(rect, 1.0, 1.0) xRadius: 3.0 yRadius: 3.0];
gradient = [[NSGradient alloc] initWithStartingColor: [color blendedColorWithFraction: 0.75 ofColor: [NSColor whiteColor]]
endingColor: [color blendedColorWithFraction: 0.2 ofColor: [NSColor whiteColor]]];
[gradient drawInBezierPath: bp angle: 270.0];
+ [gradient release];
[icon unlockFocus];
[dict setObject: icon forKey: @"Icon"];
+ [icon release];
return icon;
}
NSString * location = [[GroupsController groups] customDownloadLocationForIndex: index];
if (location)
{
- ExpandedPathToPathTransformer * pathTransformer = [[ExpandedPathToPathTransformer alloc] init];
+ ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
[[fCustomLocationPopUp itemAtIndex: 0] setTitle: [pathTransformer transformedValue: location]];
- ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
+ ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
[[fCustomLocationPopUp itemAtIndex: 0] setImage: [iconTransformer transformedValue: location]];
}
else
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [fTorrents release];
+ [super dealloc];
}
- (void) setInfoForTorrents: (NSArray *) torrents
{
//don't check if it's the same in case the metadata changed
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
fSet = NO;
}
[[fFileFilterField cell] setPlaceholderString: NSLocalizedString(@"Filter", "inspector -> file filter")];
}
+- (void) dealloc
+{
+ [fTorrents release];
+
+ [super dealloc];
+}
- (void) setInfoForTorrents: (NSArray *) torrents
{
//don't check if it's the same in case the metadata changed
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
fSet = NO;
}
return self;
}
+- (void) dealloc
+{
+ [fTorrents release];
+
+ [super dealloc];
+}
- (void) setInfoForTorrents: (NSArray *) torrents
{
//don't check if it's the same in case the metadata changed
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
fSet = NO;
}
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [fTorrents release];
+ [super dealloc];
}
- (void) setInfoForTorrents: (NSArray *) torrents
{
//don't check if it's the same in case the metadata changed
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
fSet = NO;
}
- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
{
- fInitialString = [control stringValue];
+ [fInitialString release];
+ fInitialString = [[control stringValue] retain];
return YES;
}
if (fInitialString)
{
[control setStringValue: fInitialString];
+ [fInitialString release];
fInitialString = nil;
}
return NO;
[self setWebSeedTableHidden: YES animate: NO];
}
+- (void) dealloc
+{
+ [fTorrents release];
+
+ [fPeers release];
+ [fWebSeeds release];
+
+ [fWebSeedTableAnimation release];
+
+ [super dealloc];
+}
#warning subclass?
- (void) setInfoForTorrents: (NSArray *) torrents
{
//don't check if it's the same in case the metadata changed
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
fSet = NO;
}
if (fWebSeedTableAnimation)
[self setWebSeedTableHidden: !fWebSeeds animate: NO];
+ [fPeers release];
fPeers = nil;
+ [fWebSeeds release];
fWebSeeds = nil;
}
{
if (animation == fWebSeedTableAnimation)
{
+ [fWebSeedTableAnimation release];
fWebSeedTableAnimation = nil;
}
}
if (fWebSeedTableAnimation)
{
[fWebSeedTableAnimation stopAnimation]; // jumps to end frame
+ [fWebSeedTableAnimation release];
fWebSeedTableAnimation = nil;
}
}
if ([fTorrents count] == 0)
{
+ [fPeers release];
fPeers = nil;
[fPeerTable reloadData];
if (!hasWebSeeds)
{
+ [fWebSeeds release];
fWebSeeds = nil;
[fWebSeedTable reloadData];
}
if (fWebSeedTableAnimation)
{
[fWebSeedTableAnimation stopAnimation];
+ [fWebSeedTableAnimation release];
fWebSeedTableAnimation = nil;
}
return self;
}
+- (void) dealloc
+{
+ [fGradient release];
+ [super dealloc];
+}
- (void) drawRect: (NSRect) rect
{
fSelected = NO;
//expects the icon to currently be set as the image
- fIcon = [self image];
+ fIcon = [[self image] retain];
[self setSelectedTab: fSelected];
}
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [fIcon release];
+ [super dealloc];
}
- (void) setSelectedTab: (BOOL) selected
tabRect = NSMakeRect(0.0, 1.0, NSWidth(tabRect) - 1.0, NSHeight(tabRect) - 2.0);
[gradient drawInRect: tabRect angle: 270.0];
+ [gradient release];
if (fIcon)
{
[tabImage unlockFocus];
[self setImage: tabImage];
+ [tabImage release];
}
- (void) updateControlTint: (NSNotification *) notification
}
}
+- (void) dealloc
+{
+ [fTorrents release];
+ [fTrackers release];
+ [fTrackerCell release];
+
+ [super dealloc];
+}
- (void) setInfoForTorrents: (NSArray *) torrents
{
//don't check if it's the same in case the metadata changed
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
fSet = NO;
}
NSArray * oldTrackers = fTrackers;
if ([fTorrents count] == 1)
- fTrackers = [[fTorrents objectAtIndex: 0] allTrackerStats];
+ fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
else
{
fTrackers = [[NSMutableArray alloc] init];
else
[fTrackerTable reloadData];
+ [oldTrackers release];
}
else
{
NSIndexSet * addedIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fTrackers count]-2, 2)];
NSArray * tierAndTrackerBeingAdded = [fTrackers objectsAtIndexes: addedIndexes];
- fTrackers = [[fTorrents objectAtIndex: 0] allTrackerStats];
+ [fTrackers release];
+ fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
[fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
[fTrackerTable setTrackers: fTrackers];
- (void) clearView
{
+ [fTrackers release];
fTrackers = nil;
}
NSBeep();
//reset table with either new or old value
- fTrackers = [torrent allTrackerStats];
+ [fTrackers release];
+ fTrackers = [[torrent allTrackerStats] retain];
[fTrackerTable setTrackers: fTrackers];
[fTrackerTable reloadData];
{
if (numberSelected == 0)
{
+ [fTrackers release];
fTrackers = nil;
[fTrackerTable setTrackers: nil];
NSInteger result = [alert runModal];
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningRemoveTrackers"];
+ [alert release];
if (result != NSAlertFirstButtonReturn)
return;
[torrent removeTrackers: [removeIdentifiers objectForKey: torrent]];
//reset table with either new or old value
+ [fTrackers release];
fTrackers = [[NSMutableArray alloc] init];
for (Torrent * torrent in fTorrents)
[fTrackers addObjectsFromArray: [torrent allTrackerStats]];
if ([fViewController respondsToSelector: @selector(saveViewSize)])
[fViewController saveViewSize];
+ [fGeneralViewController dealloc];
+ [fActivityViewController dealloc];
+ [fTrackersViewController dealloc];
+ [fPeersViewController dealloc];
+ [fFileViewController dealloc];
+ [fOptionsViewController dealloc];
+ [fTorrents release];
+ [super dealloc];
}
- (void) setInfoForTorrents: (NSArray *) torrents
if (fTorrents && [fTorrents isEqualToArray: torrents])
return;
- fTorrents = torrents;
+ [fTorrents release];
+ fTorrents = [torrents retain];
[self resetInfo];
}
filterButtonFrame.origin.x -= NSWidth(clearButtonFrame) - oldClearButtonWidth;
[fFilterField setFrame: filterButtonFrame];
- fAttributes = [[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
- attributesAtIndex: 0 effectiveRange: NULL];
+ fAttributes = [[[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
+ attributesAtIndex: 0 effectiveRange: NULL] retain];
//select proper level in popup button
switch ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"])
[[NSNotificationCenter defaultCenter] removeObserver: self];
[fTimer invalidate];
+ [fLock release];
+ [fMessages release];
+ [fDisplayedMessages release];
+ [fAttributes release];
+ [super dealloc];
}
- (void) windowDidBecomeKey: (NSNotification *) notification
NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"Index" ascending: YES];
NSArray * descriptors = [[NSArray alloc] initWithObjects: descriptor, nil];
NSArray * sortedMessages = [fDisplayedMessages sortedArrayUsingDescriptors: descriptors];
+ [descriptors release];
//create the text to output
NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [sortedMessages count]];
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];
+ [alert release];
}
}
}];
[coloredImage unlockFocus];
- return coloredImage;
+ return [coloredImage autorelease];
}
@end
if (fromIndex == toIndex)
return;
- id object = [self objectAtIndex: fromIndex];
+ id object = [[self objectAtIndex: fromIndex] retain];
//shift objects - more efficient than simply removing the object and re-inserting the object
if (fromIndex < toIndex)
}
[self replaceObjectAtIndex: toIndex withObject: object];
+ [object release];
}
@end
+ (NSString *) formattedUInteger: (NSUInteger) value
{
- NSNumberFormatter * numberFormatter = [[NSNumberFormatter alloc] init];
+ NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits: 0];
[numberFormatter setMaximumFractionDigits: decimals];
NSString * fileSizeString = [numberFormatter stringFromNumber: [NSNumber numberWithFloat: convertedSize]];
+ [numberFormatter release];
if (!notAllowedUnit || ![unit isEqualToString: notAllowedUnit])
fileSizeString = [fileSizeString stringByAppendingFormat: @" %@", unit];
#import "PeerProgressIndicatorCell.h"
#import "NSStringAdditions.h"
+#import "transmission.h" // required by utils.h
+#import "utils.h"
+
@implementation PeerProgressIndicatorCell
+- (id) copyWithZone: (NSZone *) zone
+{
+ PeerProgressIndicatorCell * copy = [super copyWithZone: zone];
+ copy->fAttributes = [fAttributes retain];
+
+ return copy;
+}
+
+- (void) dealloc
+{
+ [fAttributes release];
+ [super dealloc];
+}
+
- (void) setSeed: (BOOL) seed
{
fSeed = seed;
fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: [NSFont systemFontOfSize: 11.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
+ [paragraphStyle release];
}
[[NSString percentString: [self floatValue] longDecimals: NO] drawInRect: cellFrame withAttributes: fAttributes];
else
{
//attributes not needed anymore
- fAttributes = nil;
+ if (fAttributes)
+ {
+ [fAttributes release];
+ fAttributes = nil;
+ }
[super drawWithFrame: cellFrame inView: controlView];
if (fSeed)
NSColor * fGreenAvailabilityColor, * fBluePieceColor;
- __unsafe_unretained Torrent * fTorrent;
+ Torrent * fTorrent;
NSInteger fNumPieces, fAcross, fWidth, fExtraBorder;
}
- (void) awakeFromNib
{
//store box colors
- fGreenAvailabilityColor = [NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.4 alpha: 1.0];
- fBluePieceColor = [NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0];
+ fGreenAvailabilityColor = [[NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.4 alpha: 1.0] retain];
+ fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
//actually draw the box
[self setTorrent: nil];
{
tr_free(fPieces);
+ [fGreenAvailabilityColor release];
+ [fBluePieceColor release];
+ [super dealloc];
}
- (void) setTorrent: (Torrent *) torrent
NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.4]
endingColor: [NSColor colorWithCalibratedWhite: 0.2 alpha: 0.4]];
[gradient drawInRect: [self bounds] angle: 90.0];
+ [gradient release];
[back unlockFocus];
[self setImage: back];
+ [back release];
[self setNeedsDisplay];
}
@interface PortChecker : NSObject
{
- __unsafe_unretained id fDelegate;
+ id fDelegate;
port_status_t fStatus;
NSURLConnection * fConnection;
{
[fTimer invalidate];
+ [fConnection release];
+ [fPortProbeData release];
+ [super dealloc];
}
- (port_status_t) status
- (void) connectionDidFinishLoading: (NSURLConnection *) connection
{
NSString * probeString = [[NSString alloc] initWithData: fPortProbeData encoding: NSUTF8StringEncoding];
+ [fPortProbeData release];
fPortProbeData = nil;
if (probeString)
NSLog(@"Unable to get port status: invalid response (%@)", probeString);
[self callBackWithStatus: PORT_STATUS_ERROR];
}
+ [probeString release];
}
else
{
#import <Cocoa/Cocoa.h>
@interface PredicateEditorRowTemplateAny : NSPredicateEditorRowTemplate
+{
+}
@end
fRPCWhitelistArray = [[fDefaults arrayForKey: @"RPCWhitelist"] mutableCopy];
if (!fRPCWhitelistArray)
- fRPCWhitelistArray = [NSMutableArray arrayWithObject: @"127.0.0.1"];
+ fRPCWhitelistArray = [[NSMutableArray arrayWithObject: @"127.0.0.1"] retain];
[self updateRPCWhitelist];
//reset old Sparkle settings from previous versions
if (fPortChecker)
{
[fPortChecker cancelProbe];
+ [fPortChecker release];
}
+ [fRPCWhitelistArray release];
+ [fRPCPassword release];
+ [super dealloc];
}
- (void) awakeFromNib
[toolbar setSizeMode: NSToolbarSizeModeRegular];
[toolbar setSelectedItemIdentifier: TOOLBAR_GENERAL];
[[self window] setToolbar: toolbar];
+ [toolbar release];
[self setPrefView: nil];
}
else
{
+ [item release];
return nil;
}
- return item;
+ return [item autorelease];
}
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
if (fPortChecker)
{
[fPortChecker cancelProbe];
+ [fPortChecker release];
}
BOOL delay = natStatusChanged || tr_sessionIsPortForwardingEnabled(fHandle);
fPortChecker = [[PortChecker alloc] initForPort: fPeerPort delay: delay withDelegate: self];
NSAssert1(NO, @"Port checker returned invalid status: %d", [fPortChecker status]);
break;
}
+ [fPortChecker release];
fPortChecker = nil;
}
NSArray * directories = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
NSUserDomainMask | NSLocalDomainMask | NSSystemDomainMask, YES);
- for (__strong NSString * directory in directories)
+ for (NSString * directory in directories)
{
directory = [directory stringByAppendingPathComponent: @"Sounds"];
if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
{
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: directory error: NULL];
- for (__strong NSString * sound in directoryContents)
+ for (NSString * sound in directoryContents)
{
sound = [sound stringByDeletingPathExtension];
if ([NSSound soundNamed: sound])
+ (NSDate *) timeSumToDate: (NSInteger) sum
{
- NSDateComponents * comps = [[NSDateComponents alloc] init];
+ NSDateComponents * comps = [[[NSDateComponents alloc] init] autorelease];
[comps setHour: sum / 60];
[comps setMinute: sum % 60];
- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
{
- fInitialString = [control stringValue];
+ [fInitialString release];
+ fInitialString = [[control stringValue] retain];
return YES;
}
if (fInitialString)
{
[control setStringValue: fInitialString];
+ [fInitialString release];
fInitialString = nil;
}
return NO;
- (void) setDefaultForMagnets: (id) sender
{
NSString * bundleID = [[NSBundle mainBundle] bundleIdentifier];
- const OSStatus result = LSSetDefaultHandlerForURLScheme((CFStringRef)@"magnet", (__bridge CFStringRef)bundleID);
+ const OSStatus result = LSSetDefaultHandlerForURLScheme((CFStringRef)@"magnet", (CFStringRef)bundleID);
if (result != noErr)
NSLog(@"Failed setting default magnet link handler");
}
- (void) setRPCPassword: (id) sender
{
+ [fRPCPassword release];
fRPCPassword = [[sender stringValue] copy];
const char * password = [[sender stringValue] UTF8String];
SecKeychainFindGenericPassword(NULL, strlen(RPC_KEYCHAIN_SERVICE), RPC_KEYCHAIN_SERVICE,
strlen(RPC_KEYCHAIN_NAME), RPC_KEYCHAIN_NAME, &passwordLength, (void **)&password, NULL);
+ [fRPCPassword release];
if (password != NULL)
{
char fullPassword[passwordLength+1];
#import <Cocoa/Cocoa.h>
@interface PrefsWindow : NSWindow
+{
+}
@end
NSColor * color3 = [NSColor colorWithCalibratedRed: redComponent * 0.85 green: greenComponent * 0.85 blue: blueComponent * 0.85
alpha: alpha];
- return [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5, baseColor, 1.0, nil];
+ NSGradient * progressGradient = [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5,
+ baseColor, 1.0, nil];
+ return [progressGradient autorelease];
}
@end
{
[fTimer invalidate];
+ [fStatsWindowInstance autorelease];
fStatsWindowInstance = nil;
}
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
}
- (void) updateWithDownload: (CGFloat) dlRate upload: (CGFloat) ulRate
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+ [fGradient release];
+ [super dealloc];
}
- (BOOL) mouseDownCanMoveWindow
void startQueueCallback(tr_torrent * torrent, void * torrentData)
{
- [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(startQueue) withObject: nil waitUntilDone: NO];
+ [(Torrent *)torrentData performSelectorOnMainThread: @selector(startQueue) withObject: nil waitUntilDone: NO];
}
void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, bool wasRunning, void * torrentData)
{
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: status], @"Status",
[NSNumber numberWithBool: wasRunning], @"WasRunning", nil];
- [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
+ [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
}
}
void ratioLimitHitCallback(tr_torrent * torrent, void * torrentData)
{
- [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(ratioLimitHit) withObject: nil waitUntilDone: NO];
+ [(Torrent *)torrentData performSelectorOnMainThread: @selector(ratioLimitHit) withObject: nil waitUntilDone: NO];
}
void idleLimitHitCallback(tr_torrent * torrent, void * torrentData)
{
- [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(idleLimitHit) withObject: nil waitUntilDone: NO];
+ [(Torrent *)torrentData performSelectorOnMainThread: @selector(idleLimitHit) withObject: nil waitUntilDone: NO];
}
void metadataCallback(tr_torrent * torrent, void * torrentData)
{
- [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(metadataRetrieved) withObject: nil waitUntilDone: NO];
+ [(Torrent *)torrentData performSelectorOnMainThread: @selector(metadataRetrieved) withObject: nil waitUntilDone: NO];
}
int trashDataFile(const char * filename)
if (fFileStat)
tr_torrentFilesFree(fFileStat, [self fileCount]);
+
+ [fPreviousFinishedIndexes release];
+ [fPreviousFinishedIndexesDate release];
+
+ [fHashString release];
+
+ [fIcon release];
+
+ [fFileList release];
+ [fFlatFileList release];
+
+ [fTimeMachineExclude release];
+
+ [super dealloc];
}
- (NSString *) description
- (id) copyWithZone: (NSZone *) zone
{
- return self;
+ return [self retain];
}
- (void) closeRemoveTorrent: (BOOL) trashFiles
if (fTimeMachineExclude)
{
[self setTimeMachineExclude: NO forPath: fTimeMachineExclude];
+ [fTimeMachineExclude release];
fTimeMachineExclude = nil;
}
- (void) setPreviousFinishedPieces: (NSIndexSet *) indexes
{
- fPreviousFinishedIndexes = indexes;
+ [fPreviousFinishedIndexes release];
+ fPreviousFinishedIndexes = [indexes retain];
+ [fPreviousFinishedIndexesDate release];
fPreviousFinishedIndexesDate = indexes != nil ? [[NSDate alloc] init] : nil;
}
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Move inside itself alert -> button")];
[alert runModal];
+ [alert release];
return;
}
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Move error alert -> button")];
[alert runModal];
+ [alert release];
}
[self updateTimeMachineExclude];
const NSInteger result = [alert runModal];
if ([[alert suppressionButton] state] == NSOnState)
[fDefaults setBool: NO forKey: @"WarningRemainingSpace"];
+ [alert release];
return result != NSAlertFirstButtonReturn;
}
#warning replace kGenericFolderIcon stuff with NSImageNameFolder on 10.6
if (!fIcon)
- fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: [self isFolder] ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
- : [[self name] pathExtension]];
+ fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: [self isFolder] ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
+ : [[self name] pathExtension]] retain];
return fIcon;
}
TrackerNode * tracker = [[TrackerNode alloc] initWithTrackerStat: &stats[i] torrent: self];
[trackers addObject: tracker];
+ [tracker release];
}
tr_torrentTrackersFree(stats, count);
if (fTimeMachineExclude)
{
[self setTimeMachineExclude: NO forPath: fTimeMachineExclude];
+ [fTimeMachineExclude release];
fTimeMachineExclude = nil;
}
if (currentLocation)
{
[self setTimeMachineExclude: YES forPath: currentLocation];
- fTimeMachineExclude = currentLocation;
+ fTimeMachineExclude = [currentLocation retain];
}
}
if (!fHandle)
{
+ [self release];
return nil;
}
}
fInfo = tr_torrentInfo(fHandle);
- tr_torrentSetQueueStartCallback(fHandle, startQueueCallback, (__bridge void *)(self));
- tr_torrentSetCompletenessCallback(fHandle, completenessChangeCallback, (__bridge void *)(self));
- tr_torrentSetRatioLimitHitCallback(fHandle, ratioLimitHitCallback, (__bridge void *)(self));
- tr_torrentSetIdleLimitHitCallback(fHandle, idleLimitHitCallback, (__bridge void *)(self));
- tr_torrentSetMetadataCallback(fHandle, metadataCallback, (__bridge void *)(self));
+ tr_torrentSetQueueStartCallback(fHandle, startQueueCallback, self);
+ tr_torrentSetCompletenessCallback(fHandle, completenessChangeCallback, self);
+ tr_torrentSetRatioLimitHitCallback(fHandle, ratioLimitHitCallback, self);
+ tr_torrentSetIdleLimitHitCallback(fHandle, idleLimitHitCallback, self);
+ tr_torrentSetMetadataCallback(fHandle, metadataCallback, self);
fHashString = [[NSString alloc] initWithUTF8String: fInfo->hashString];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
name: @"GroupValueRemoved" object: nil];
- fTimeMachineExclude = timeMachineExclude;
+ fTimeMachineExclude = [timeMachineExclude retain];
[self update];
return self;
{
node = [[FileListNode alloc] initWithFolderName: name path: path torrent: self];
[fileList addObject: node];
+ [node release];
}
NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange: NSMakeRange(2, [pathComponents count]-2)]];
FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i torrent: self];
[fileList addObject: node];
[flatFileList addObject: node];
+ [node release];
}
}
else
{
FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0 torrent: self];
- fFileList = [NSArray arrayWithObject: node];
- fFlatFileList = fFileList;
+ fFileList = [[NSArray arrayWithObject: node] retain];
+ fFlatFileList = [fFileList retain];
+ [node release];
}
}
}
[parent insertChild: node];
+ [node release];
}
if (isFolder)
{
case TR_SEED:
case TR_PARTIAL_SEED:
- {
//simpler to create a new dictionary than to use statusInfo - avoids retention chicanery
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self
userInfo: [NSDictionary dictionaryWithObject: [statusInfo objectForKey: @"WasRunning"] forKey: @"WasRunning"]];
if (FSPathMakeRef((const UInt8 *)[dataLocation UTF8String], &ref, NULL) == noErr)
{
NSDictionary * quarantineProperties = [NSDictionary dictionaryWithObject: (NSString *)kLSQuarantineTypeOtherDownload forKey: (NSString *)kLSQuarantineTypeKey];
- if (LSSetItemAttribute(&ref, kLSRolesAll, kLSItemQuarantineProperties, (__bridge void *)quarantineProperties) != noErr)
+ if (LSSetItemAttribute(&ref, kLSRolesAll, kLSItemQuarantineProperties, quarantineProperties) != noErr)
NSLog(@"Failed to quarantine: %@", dataLocation);
}
else
NSLog(@"Could not find file to quarantine: %@", dataLocation);
break;
- }
case TR_LEECH:
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRestartedDownloading" object: self];
break;
}
+ [statusInfo release];
[self update];
[self updateTimeMachineExclude];
- (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path
{
- CSBackupSetItemExcluded((__bridge CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
+ CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
}
@end
[fStatusAttributes setObject: [NSFont messageFontOfSize: 9.0] forKey: NSFontAttributeName];
[fStatusAttributes setObject: paragraphStyle forKey: NSParagraphStyleAttributeName];
+ [paragraphStyle release];
- fBluePieceColor = [NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0];
- fBarBorderColor = [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.2];
- fBarMinimalBorderColor = [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.015];
+ fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
+ fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.2] retain];
+ fBarMinimalBorderColor = [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.015] retain];
}
return self;
}
[rowInfo setObject: @"Row" forKey: @"Type"];
NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: cellFrame options: rowOptions owner: controlView userInfo: rowInfo];
[controlView addTrackingArea: area];
+ [rowInfo release];
+ [area release];
}
//control button
NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: controlButtonRect options: controlOptions owner: controlView
userInfo: controlInfo];
[controlView addTrackingArea: area];
+ [controlInfo release];
+ [area release];
//reveal button
NSRect revealButtonRect = [self revealButtonRectForBounds: cellFrame];
area = [[NSTrackingArea alloc] initWithRect: revealButtonRect options: revealOptions owner: controlView
userInfo: revealInfo];
[controlView addTrackingArea: area];
+ [revealInfo release];
+ [area release];
//action button
NSRect actionButtonRect = [self iconRectForBounds: cellFrame]; //use the whole icon
[actionInfo setObject: @"Action" forKey: @"Type"];
area = [[NSTrackingArea alloc] initWithRect: actionButtonRect options: actionOptions owner: controlView userInfo: actionInfo];
[controlView addTrackingArea: area];
+ [actionInfo release];
+ [area release];
}
- (void) setHover: (BOOL) hover
NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [groupColor blendedColorWithFraction: 0.7
ofColor: [NSColor whiteColor]] endingColor: darkGroupColor];
[gradient drawInBezierPath: bp angle: 90.0];
+ [gradient release];
}
const BOOL error = [torrent isAnyErrorOrWarning];
[bitmap drawInRect: barRect fromRect: NSZeroRect operation: NSCompositeSourceOver
fraction: ([fDefaults boolForKey: @"SmallView"] ? 0.25 : 1.0) respectFlipped: YES hints: nil];
+ [bitmap release];
}
- (NSRect) rectForMinimalStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
- (NSAttributedString *) attributedTitle
{
NSString * title = [(Torrent *)[self representedObject] name];
- return [[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes];
+ return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease];
}
- (NSAttributedString *) attributedStatusString: (NSString *) string
{
- return [[NSAttributedString alloc] initWithString: string attributes: fStatusAttributes];
+ return [[[NSAttributedString alloc] initWithString: string attributes: fStatusAttributes] autorelease];
}
- (NSString *) buttonString
return self;
}
+- (void) dealloc
+{
+ [fTorrents release];
+ [super dealloc];
+}
- (NSString *) description
{
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
+
+ [fCollapsedGroups release];
+
+ [fPiecesBarAnimation release];
+ [fMenuTorrent release];
+
+ [fSelectedValues release];
+
+ [fTorrentCell release];
+
+ [super dealloc];
}
- (void) awakeFromNib
//if pushing a button, don't change the selected rows
if (pushed)
- fSelectedValues = [self selectedValues];
+ fSelectedValues = [[self selectedValues] retain];
[super mouseDown: event];
+ [fSelectedValues release];
fSelectedValues = nil;
//avoid weird behavior when showing menu by doing this after mouse down
[infoViewController setInfoForTorrents: [NSArray arrayWithObject: torrent]];
[infoViewController updateInfo];
+ [infoViewController release];
+ [popover release];
}
else
{
//update file action menu
- fMenuTorrent = [self itemAtRow: row];
+ fMenuTorrent = [[self itemAtRow: row] retain];
//update global limit check
[fGlobalLimitItem setState: [fMenuTorrent usesGlobalSpeedLimit] ? NSOnState : NSOffState];
location = [self convertPoint: location toView: self];
[fActionMenu popUpMenuPositioningItem: nil atLocation: location inView: self];
+ [fMenuTorrent release];
fMenuTorrent = nil;
}
}
[item setTarget: self];
[item setRepresentedObject: [NSNumber numberWithInt: speedLimitActionValue[i]]];
[menu addItem: item];
+ [item release];
}
}
[item setTarget: self];
[item setRepresentedObject: [NSNumber numberWithFloat: ratioLimitActionValue[i]]];
[menu addItem: item];
+ [item release];
}
}
- (void) togglePiecesBar
{
+ //stop previous animation
+ if (fPiecesBarAnimation)
+ [fPiecesBarAnimation release];
+
NSMutableArray * progressMarks = [NSMutableArray arrayWithCapacity: 16];
- for (NSAnimationProgress i = 1.0/16; i <= 1.0; i += 1.0/16)
+ for (NSAnimationProgress i = 0.0625; i <= 1.0; i += 0.0625)
[progressMarks addObject: [NSNumber numberWithFloat: i]];
fPiecesBarAnimation = [[NSAnimation alloc] initWithDuration: TOGGLE_PROGRESS_SECONDS animationCurve: NSAnimationEaseIn];
{
if (animation == fPiecesBarAnimation)
{
+ [fPiecesBarAnimation release];
fPiecesBarAnimation = nil;
}
}
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
+ [paragraphStyle release];
}
return self;
}
+- (void) dealloc
+{
+ [fNameAttributes release];
+ [fStatusAttributes release];
+
+ [super dealloc];
+}
+
+- (id) copyWithZone: (NSZone *) zone
+{
+ TrackerCell * copy = [super copyWithZone: zone];
+
+ copy->fNameAttributes = [fNameAttributes retain];
+ copy->fStatusAttributes = [fStatusAttributes retain];
+
+ return copy;
+}
+
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
{
//icon
if (icon)
{
[fTrackerIconCache setObject: icon forKey: baseAddress];
+ [icon release];
[[self controlView] setNeedsDisplay: YES];
}
- (NSAttributedString *) attributedName
{
NSString * name = [(TrackerNode *)[self objectValue] host];
- return [[NSAttributedString alloc] initWithString: name attributes: fNameAttributes];
+ return [[[NSAttributedString alloc] initWithString: name attributes: fNameAttributes] autorelease];
}
- (NSAttributedString *) attributedStatusWithString: (NSString *) statusString
{
- return [[NSAttributedString alloc] initWithString: statusString attributes: fStatusAttributes];
+ return [[[NSAttributedString alloc] initWithString: statusString attributes: fStatusAttributes] autorelease];
}
- (NSAttributedString *) attributedCount: (NSInteger) count
{
NSString * countString = count != -1 ? [NSString stringWithFormat: @"%d", count] : NSLocalizedString(@"N/A", "tracker peer stat");
- return [[NSAttributedString alloc] initWithString: countString attributes: fStatusAttributes];
+ return [[[NSAttributedString alloc] initWithString: countString attributes: fStatusAttributes] autorelease];
}
@end
{
tr_tracker_stat fStat;
- __unsafe_unretained Torrent * fTorrent;
+ Torrent * fTorrent;
}
-@property (nonatomic, readonly, assign) Torrent * torrent;
+@property (nonatomic, readonly) Torrent * torrent;
- (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent;
@implementation TrackerNode
#warning remove ivars in header when 64-bit only (or it compiles in 32-bit mode)
-#warning make weak when 10.7-only (not assign)
@synthesize torrent = fTorrent;
- (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent
if ((self = [super init]))
{
fStat = *stat;
- #warning make __weak when 10.7-only
- fTorrent = torrent;
+ fTorrent = torrent; //weak reference
}
return self;
- (id) copyWithZone: (NSZone *) zone
{
//this object is essentially immutable after initial setup
- return self;
+ return [self retain];
}
- (BOOL) isEqual: (id) object
[dateFormatter setDoesRelativeDateFormatting: YES];
dateString = [dateFormatter stringFromDate: [NSDate dateWithTimeIntervalSince1970: fStat.lastAnnounceTime]];
+ [dateFormatter release];
}
else
dateString = NSLocalizedString(@"N/A", "Tracker last announce");
[dateFormatter setDoesRelativeDateFormatting: YES];
dateString = [dateFormatter stringFromDate: [NSDate dateWithTimeIntervalSince1970: fStat.lastScrapeTime]];
+ [dateFormatter release];
}
else
dateString = NSLocalizedString(@"N/A", "Tracker last scrape");
@interface TrackerTableView : NSTableView
{
- __unsafe_unretained Torrent * fTorrent;
- __unsafe_unretained NSArray * fTrackers;
+ //weak references
+ Torrent * fTorrent;
+ NSArray * fTrackers;
}
- (void) setTorrent: (Torrent *) torrent;
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
- <string key="IBDocument.SystemVersion">11D50</string>
- <string key="IBDocument.InterfaceBuilderVersion">2182</string>
- <string key="IBDocument.AppKitVersion">1138.32</string>
- <string key="IBDocument.HIToolboxVersion">568.00</string>
+ <string key="IBDocument.SystemVersion">11B26</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1617</string>
+ <string key="IBDocument.AppKitVersion">1138</string>
+ <string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">2182</string>
+ <string key="NS.object.0">1617</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSTextField</string>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
- <object class="NSMutableDictionary" key="IBDocument.Metadata">
- <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
- <integer value="1" key="NS.object.0"/>
- </object>
+ <dictionary class="NSMutableDictionary" key="IBDocument.Metadata"/>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">URLSheetWindowController</string>
<nil key="NSUserInterfaceItemIdentifier"/>
<string key="NSWindowContentMinSize">{400, 177}</string>
<object class="NSView" key="NSWindowView" id="892541411">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSTextField" id="1066788818">
<int key="NSvFlags">274</int>
<string key="NSFrame">{{20, 50}, {360, 80}}</string>
<reference key="NSSuperview" ref="892541411"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="9691643"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="139057847">
<int key="NSCellFlags">-1805517311</int>
<int key="NSvFlags">289</int>
<string key="NSFrame">{{304, 12}, {82, 32}}</string>
<reference key="NSSuperview" ref="892541411"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="62424678">
<int key="NSCellFlags">604110336</int>
<int key="NSvFlags">289</int>
<string key="NSFrame">{{222, 12}, {82, 32}}</string>
<reference key="NSSuperview" ref="892541411"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="794131740"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="341887532">
<int key="NSCellFlags">67239424</int>
<int key="NSvFlags">266</int>
<string key="NSFrame">{{17, 140}, {366, 17}}</string>
<reference key="NSSuperview" ref="892541411"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="1066788818"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="830118733">
<int key="NSCellFlags">67239488</int>
</object>
</array>
<string key="NSFrameSize">{400, 177}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="459786882"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMinSize">{400, 199}</string>
</object>
<int key="connectionID">17</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">fCancelButton</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="9691643"/>
- </object>
- <int key="connectionID">22</int>
- </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">openURLEndSheet:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="794131740"/>
</object>
- <int key="connectionID">23</int>
+ <int key="connectionID">18</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<reference key="source" ref="1001"/>
<reference key="destination" ref="9691643"/>
</object>
- <int key="connectionID">24</int>
+ <int key="connectionID">19</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
</object>
<int key="connectionID">21</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">fCancelButton</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="9691643"/>
+ </object>
+ <int key="connectionID">22</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">24</int>
+ <int key="maxID">22</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">URLSheetWindowController</string>
<string key="superclassName">NSWindowController</string>
- <dictionary class="NSMutableDictionary" key="actions">
- <string key="openURLCancelEndSheet:">id</string>
- <string key="openURLEndSheet:">id</string>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="actionInfosByName">
- <object class="IBActionInfo" key="openURLCancelEndSheet:">
- <string key="name">openURLCancelEndSheet:</string>
- <string key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo" key="openURLEndSheet:">
- <string key="name">openURLEndSheet:</string>
- <string key="candidateClassName">id</string>
- </object>
- </dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="fCancelButton">NSButton</string>
<string key="fLabelField">NSTextField</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <real value="1070" key="NS.object.0"/>
+ <integer value="1060" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
IBOutlet NSTextField * fTextField;
IBOutlet NSButton * fOpenButton, * fCancelButton;
- __unsafe_unretained Controller * fController;
+ Controller * fController;
}
- (id) initWithController: (Controller *) controller;
+- (void) beginSheetForWindow: (NSWindow *) window;
-- (IBAction) openURLEndSheet: (id) sender;
-- (IBAction) openURLCancelEndSheet: (id) sender;
-
-- (NSString *) urlString;
+- (void) openURLEndSheet: (id) sender;
+- (void) openURLCancelEndSheet: (id) sender;
@end
[fCancelButton setFrame: cancelFrame];
}
-- (IBAction) openURLEndSheet: (id) sender
+- (IBAction) beginSheetForWindow: (NSWindow *) window
+{
+ [NSApp beginSheet: [self window] modalForWindow: window modalDelegate: self
+ didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
+}
+
+- (void) openURLEndSheet: (id) sender
{
[[self window] orderOut: sender];
[NSApp endSheet: [self window] returnCode: 1];
}
-- (IBAction) openURLCancelEndSheet: (id) sender
+- (void) openURLCancelEndSheet: (id) sender
{
[[self window] orderOut: sender];
[NSApp endSheet: [self window] returnCode: 0];
}
-- (NSString *) urlString
+- (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
- return [fTextField stringValue];
+ [urlString release];
+ urlString = [[fTextField stringValue] retain];
+ [fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
}
- (void) controlTextDidChange: (NSNotification *) notification