2006-07-16 19:39:23 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2007-04-03 02:22:25 +00:00
|
|
|
* Copyright (c) 2006-2007 Transmission authors and contributors
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import <transmission.h>
|
|
|
|
|
2007-03-22 04:30:08 +00:00
|
|
|
#define INVALID -99
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
@interface Torrent : NSObject
|
|
|
|
{
|
2007-06-30 21:53:45 +00:00
|
|
|
tr_handle_t * fLib;
|
2006-07-16 19:39:23 +00:00
|
|
|
tr_torrent_t * fHandle;
|
2007-06-30 21:53:45 +00:00
|
|
|
const tr_info_t * fInfo;
|
2007-07-15 22:20:02 +00:00
|
|
|
const tr_stat_t * fStat;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-05-28 02:27:13 +00:00
|
|
|
int fID;
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
BOOL fResumeOnWake;
|
2007-07-30 22:19:52 +00:00
|
|
|
NSDate * fDateAdded, * fDateCompleted, * fDateActivity;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-11-03 16:01:45 +00:00
|
|
|
BOOL fUseIncompleteFolder;
|
|
|
|
NSString * fDownloadFolder, * fIncompleteFolder;
|
|
|
|
|
2006-11-05 19:08:38 +00:00
|
|
|
BOOL fPublicTorrent;
|
2006-07-16 19:39:23 +00:00
|
|
|
NSString * fPublicTorrentLocation;
|
2007-03-31 20:08:10 +00:00
|
|
|
|
|
|
|
BOOL fPex;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-01-17 20:50:42 +00:00
|
|
|
NSUserDefaults * fDefaults;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-01-17 20:50:42 +00:00
|
|
|
NSImage * fIcon, * fIconFlipped, * fIconSmall;
|
2006-07-25 00:59:14 +00:00
|
|
|
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-07-15 21:57:42 +00:00
|
|
|
tr_file_stat_t * fileStat;
|
2007-06-18 03:40:41 +00:00
|
|
|
NSArray * fFileList, * fFlatFileList;
|
2006-12-27 02:57:55 +00:00
|
|
|
|
2007-08-08 01:03:34 +00:00
|
|
|
NSMenu * fTorrentMenu;
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
float fRatioLimit;
|
2007-07-20 04:26:50 +00:00
|
|
|
int fRatioSetting;
|
2007-05-26 06:16:43 +00:00
|
|
|
BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
int fOrderValue;
|
2006-10-05 21:21:30 +00:00
|
|
|
|
|
|
|
NSBitmapImageRep * fBitmap;
|
|
|
|
int8_t * fPieces;
|
2007-07-20 20:54:55 +00:00
|
|
|
|
|
|
|
NSDictionary * fQuickPauseDict;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-06-27 22:12:10 +00:00
|
|
|
- (id) initWithPath: (NSString *) path location: (NSString *) location forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib;
|
2007-05-10 18:29:36 +00:00
|
|
|
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle_t *) lib;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
- (NSDictionary *) history;
|
2007-05-10 18:29:36 +00:00
|
|
|
|
2007-07-01 05:23:07 +00:00
|
|
|
- (void) closeTorrent;
|
|
|
|
- (void) closeRemoveTorrent;
|
2007-06-29 21:25:32 +00:00
|
|
|
|
2007-06-27 22:12:10 +00:00
|
|
|
- (void) changeIncompleteDownloadFolder: (NSString *) folder;
|
|
|
|
- (void) changeDownloadFolder: (NSString *) folder;
|
2006-07-16 19:39:23 +00:00
|
|
|
- (NSString *) downloadFolder;
|
2006-10-12 23:34:20 +00:00
|
|
|
|
|
|
|
- (void) getAvailability: (int8_t *) tab size: (int) size;
|
2006-10-13 01:34:15 +00:00
|
|
|
- (void) getAmountFinished: (float *) tab size: (int) size;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-05-10 18:29:36 +00:00
|
|
|
- (void) update;
|
|
|
|
- (NSDictionary *) infoForCurrentView;
|
2006-09-11 23:52:03 +00:00
|
|
|
|
2007-06-27 22:12:10 +00:00
|
|
|
- (void) startTransfer;
|
|
|
|
- (void) stopTransfer;
|
|
|
|
- (void) sleep;
|
|
|
|
- (void) wakeUp;
|
|
|
|
|
2007-07-31 00:10:55 +00:00
|
|
|
- (void) manualAnnounce;
|
|
|
|
- (BOOL) canManualAnnounce;
|
2007-06-27 22:12:10 +00:00
|
|
|
|
|
|
|
- (void) resetCache;
|
|
|
|
|
|
|
|
- (float) ratio;
|
|
|
|
- (int) ratioSetting;
|
|
|
|
- (void) setRatioSetting: (int) setting;
|
|
|
|
- (float) ratioLimit;
|
|
|
|
- (void) setRatioLimit: (float) limit;
|
|
|
|
- (float) actualStopRatio; //returns INVALID if will not stop
|
|
|
|
- (float) progressStopRatio;
|
|
|
|
|
2007-07-21 03:13:11 +00:00
|
|
|
- (int) speedMode: (BOOL) upload;
|
|
|
|
- (void) setSpeedMode: (int) mode upload: (BOOL) upload;
|
|
|
|
- (int) speedLimit: (BOOL) upload;
|
|
|
|
- (void) setSpeedLimit: (int) limit upload: (BOOL) upload;
|
2006-12-27 02:57:55 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
- (void) setWaitToStart: (BOOL) wait;
|
|
|
|
- (BOOL) waitingToStart;
|
|
|
|
|
2007-05-09 05:07:44 +00:00
|
|
|
- (void) revealData;
|
|
|
|
- (void) revealPublicTorrent;
|
|
|
|
- (void) trashData;
|
|
|
|
- (void) trashTorrent;
|
2007-05-09 14:52:52 +00:00
|
|
|
- (void) moveTorrentDataFileTo: (NSString *) folder;
|
|
|
|
- (void) copyTorrentFileTo: (NSString *) path;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-11-16 19:32:01 +00:00
|
|
|
- (BOOL) alertForRemainingDiskSpace;
|
2007-01-14 20:22:51 +00:00
|
|
|
- (BOOL) alertForFolderAvailable;
|
|
|
|
- (BOOL) alertForMoveFolderAvailable;
|
2006-09-28 00:32:26 +00:00
|
|
|
|
2007-06-27 22:12:10 +00:00
|
|
|
- (NSImage *) icon;
|
|
|
|
- (NSImage *) iconFlipped;
|
|
|
|
- (NSImage *) iconSmall;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
- (NSString *) name;
|
2007-06-27 22:12:10 +00:00
|
|
|
- (uint64_t) size;
|
2006-12-26 21:02:00 +00:00
|
|
|
- (NSString *) trackerAddress;
|
|
|
|
- (NSString *) trackerAddressAnnounce;
|
2006-11-23 01:38:18 +00:00
|
|
|
|
|
|
|
- (NSString *) comment;
|
|
|
|
- (NSString *) creator;
|
2007-06-27 22:12:10 +00:00
|
|
|
- (NSDate *) dateCreated;
|
2006-11-23 01:38:18 +00:00
|
|
|
|
2007-06-27 22:12:10 +00:00
|
|
|
- (int) pieceSize;
|
|
|
|
- (int) pieceCount;
|
2006-07-16 19:39:23 +00:00
|
|
|
- (NSString *) hashString;
|
2007-06-27 22:12:10 +00:00
|
|
|
- (BOOL) privateTorrent;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
- (NSString *) torrentLocation;
|
|
|
|
- (NSString *) publicTorrentLocation;
|
|
|
|
- (NSString *) dataLocation;
|
|
|
|
|
|
|
|
- (BOOL) publicTorrent;
|
|
|
|
|
|
|
|
- (NSString *) stateString;
|
|
|
|
|
2007-05-07 04:28:17 +00:00
|
|
|
- (float) progress;
|
2007-06-20 23:53:09 +00:00
|
|
|
- (float) progressDone;
|
2007-05-07 04:28:17 +00:00
|
|
|
- (int) eta;
|
|
|
|
|
|
|
|
- (BOOL) isActive;
|
|
|
|
- (BOOL) isSeeding;
|
|
|
|
- (BOOL) isPaused;
|
|
|
|
- (BOOL) isChecking;
|
2007-06-18 03:40:41 +00:00
|
|
|
- (BOOL) allDownloaded;
|
2007-07-15 04:06:04 +00:00
|
|
|
- (BOOL) isComplete;
|
2007-05-07 04:28:17 +00:00
|
|
|
- (BOOL) isError;
|
|
|
|
- (NSString *) errorMessage;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-08-13 15:46:02 +00:00
|
|
|
- (NSArray *) peers;
|
|
|
|
|
2006-07-25 00:59:14 +00:00
|
|
|
- (NSString *) progressString;
|
|
|
|
- (NSString *) statusString;
|
|
|
|
- (NSString *) shortStatusString;
|
|
|
|
- (NSString *) remainingTimeString;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
- (int) seeders;
|
|
|
|
- (int) leechers;
|
2006-12-02 01:46:54 +00:00
|
|
|
- (int) completedFromTracker;
|
2007-03-23 08:28:01 +00:00
|
|
|
|
2007-07-15 17:25:06 +00:00
|
|
|
- (int) totalPeersConnected;
|
2007-03-23 08:28:01 +00:00
|
|
|
- (int) totalPeersTracker;
|
2006-10-13 18:58:12 +00:00
|
|
|
- (int) totalPeersIncoming;
|
2007-03-23 08:28:01 +00:00
|
|
|
- (int) totalPeersCache;
|
|
|
|
- (int) totalPeersPex;
|
|
|
|
|
2007-07-16 01:05:03 +00:00
|
|
|
- (int) peersSendingToUs;
|
|
|
|
- (int) peersGettingFromUs;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
- (float) downloadRate;
|
|
|
|
- (float) uploadRate;
|
|
|
|
- (uint64_t) downloadedValid;
|
|
|
|
- (uint64_t) downloadedTotal;
|
|
|
|
- (uint64_t) uploadedTotal;
|
|
|
|
- (float) swarmSpeed;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-03-31 20:08:10 +00:00
|
|
|
- (BOOL) pex;
|
2007-03-31 20:19:19 +00:00
|
|
|
- (void) setPex: (BOOL) setting;
|
2007-03-31 20:08:10 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
- (NSNumber *) orderValue;
|
|
|
|
- (void) setOrderValue: (int) orderValue;
|
|
|
|
|
|
|
|
- (NSArray *) fileList;
|
2007-01-17 06:43:07 +00:00
|
|
|
- (int) fileCount;
|
2007-07-15 21:57:42 +00:00
|
|
|
- (void) updateFileStat;
|
|
|
|
|
|
|
|
//methods require fileStats to have been updated recently to be accurate
|
2007-06-18 03:40:41 +00:00
|
|
|
- (float) fileProgress: (int) index;
|
2007-07-15 22:14:03 +00:00
|
|
|
- (BOOL) canChangeDownloadCheckForFile: (int) index;
|
2007-06-18 03:40:41 +00:00
|
|
|
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
|
2007-07-15 22:14:03 +00:00
|
|
|
- (int) checkForFiles: (NSIndexSet *) indexSet;
|
2007-06-18 03:40:41 +00:00
|
|
|
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
|
|
|
|
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
|
|
|
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
2007-07-13 04:52:40 +00:00
|
|
|
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-08 01:03:34 +00:00
|
|
|
- (NSMenu *) torrentMenu;
|
|
|
|
|
2007-03-30 18:58:18 +00:00
|
|
|
- (NSDate *) dateAdded;
|
2007-03-31 01:00:51 +00:00
|
|
|
- (NSDate *) dateCompleted;
|
2007-05-25 19:45:14 +00:00
|
|
|
- (NSDate *) dateActivity;
|
2007-03-31 01:00:51 +00:00
|
|
|
|
2007-05-28 16:40:56 +00:00
|
|
|
- (int) stalledMinutes;
|
2007-05-26 06:16:43 +00:00
|
|
|
- (BOOL) isStalled;
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
- (NSNumber *) stateSortKey;
|
|
|
|
- (NSNumber *) progressSortKey;
|
2007-01-15 04:41:01 +00:00
|
|
|
- (NSNumber *) ratioSortKey;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-05-28 02:53:30 +00:00
|
|
|
- (int) torrentID;
|
2007-06-30 21:53:45 +00:00
|
|
|
- (const tr_info_t *) torrentInfo;
|
2007-07-15 22:20:02 +00:00
|
|
|
- (const tr_stat_t *) torrentStat;
|
2007-05-28 02:27:13 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
@end
|