From 496290d263b5fd99eee3e30d67ede0c71074e189 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 18 Mar 2012 14:33:50 +0000 Subject: [PATCH] #4839 Use configuration directory retrieved from libtransmission --- macosx/Controller.h | 2 ++ macosx/Controller.m | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/macosx/Controller.h b/macosx/Controller.h index 910985094..48f4c8671 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -61,6 +61,8 @@ typedef enum NSUserDefaults * fDefaults; + NSString * fConfigDirectory; + IBOutlet NSWindow * fWindow; DragOverlayWindow * fOverlayWindow; IBOutlet TorrentTableView * fTableView; diff --git a/macosx/Controller.m b/macosx/Controller.m index 7c79c38a6..2e1b310af 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -324,6 +324,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy fLib = tr_sessionInit("macosx", configDir, YES, &settings); tr_bencFree(&settings); + fConfigDirectory = [[NSString alloc] initWithUTF8String: configDir]; + [NSApp setDelegate: self]; //register for magnet URLs (has to be in init) @@ -444,8 +446,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy NSLog(@"Could not IORegisterForSystemPower"); //load previous transfers - NSURL * historyURL = [[[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationSupportDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission"] URLByAppendingPathComponent: TRANSFER_PLIST]; - NSArray * history = [NSArray arrayWithContentsOfURL: historyURL]; + NSString * historyFile = [fConfigDirectory stringByAppendingPathComponent: TRANSFER_PLIST]; + NSArray * history = [NSArray arrayWithContentsOfFile: historyFile]; if (!history) { //old version saved transfer info in prefs file @@ -724,6 +726,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy [fPreviewPanel release]; + [fConfigDirectory release]; + //complete cleanup tr_sessionClose(fLib); } @@ -1903,8 +1907,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy for (Torrent * torrent in fTorrents) [history addObject: [torrent history]]; - NSURL * historyURL = [[[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationSupportDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission"] URLByAppendingPathComponent: TRANSFER_PLIST]; - [history writeToURL: historyURL atomically: YES]; + NSString * historyFile = [fConfigDirectory stringByAppendingPathComponent: TRANSFER_PLIST]; + [history writeToFile: historyFile atomically: YES]; } - (void) setSort: (id) sender -- 2.40.0