2007-09-16 01:02:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-01-02 16:55:05 +00:00
|
|
|
* Copyright (c) 2006-2008 Transmission authors and contributors
|
2007-09-16 01:02:06 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import <transmission.h>
|
|
|
|
|
|
|
|
#define INVALID -99
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TORRENT_FILE_DELETE,
|
|
|
|
TORRENT_FILE_SAVE,
|
|
|
|
TORRENT_FILE_DEFAULT
|
|
|
|
} torrentFileState;
|
|
|
|
|
|
|
|
@interface Torrent : NSObject
|
|
|
|
{
|
2007-09-20 20:24:33 +00:00
|
|
|
tr_handle * fLib;
|
|
|
|
tr_torrent * fHandle;
|
|
|
|
const tr_info * fInfo;
|
|
|
|
const tr_stat * fStat;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
int fID;
|
|
|
|
|
|
|
|
BOOL fResumeOnWake;
|
|
|
|
NSDate * fDateAdded, * fDateCompleted, * fDateActivity;
|
|
|
|
|
|
|
|
BOOL fUseIncompleteFolder;
|
|
|
|
NSString * fDownloadFolder, * fIncompleteFolder;
|
|
|
|
|
|
|
|
BOOL fPublicTorrent;
|
|
|
|
NSString * fPublicTorrentLocation;
|
|
|
|
|
|
|
|
NSUserDefaults * fDefaults;
|
|
|
|
|
|
|
|
NSImage * fIcon;
|
|
|
|
|
2007-09-20 20:24:33 +00:00
|
|
|
tr_file_stat * fileStat;
|
2007-09-28 14:31:20 +00:00
|
|
|
NSArray * fFileList;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
NSMenu * fFileMenu;
|
|
|
|
|
2007-12-28 21:37:06 +00:00
|
|
|
float * fPreviousFinishedPieces;
|
|
|
|
NSDate * fFinishedPiecesDate;
|
|
|
|
|
2007-11-23 15:45:58 +00:00
|
|
|
float fRatioLimit;
|
|
|
|
int fRatioSetting;
|
|
|
|
BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2007-12-17 16:06:20 +00:00
|
|
|
int fOrderValue, fGroupValue;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
NSDictionary * fQuickPauseDict;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
|
2007-09-20 20:24:33 +00:00
|
|
|
lib: (tr_handle *) lib;
|
|
|
|
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle *) lib;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
- (NSDictionary *) history;
|
|
|
|
|
|
|
|
- (void) closeRemoveTorrent;
|
|
|
|
|
|
|
|
- (void) changeIncompleteDownloadFolder: (NSString *) folder;
|
|
|
|
- (void) changeDownloadFolder: (NSString *) folder;
|
|
|
|
- (NSString *) downloadFolder;
|
|
|
|
|
|
|
|
- (void) getAvailability: (int8_t *) tab size: (int) size;
|
|
|
|
- (void) getAmountFinished: (float *) tab size: (int) size;
|
2007-12-28 21:37:06 +00:00
|
|
|
- (float *) getPreviousAmountFinished;
|
|
|
|
-(void) setPreviousAmountFinished: (float *) tab;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
- (void) update;
|
|
|
|
|
|
|
|
- (void) startTransfer;
|
|
|
|
- (void) stopTransfer;
|
|
|
|
- (void) sleep;
|
|
|
|
- (void) wakeUp;
|
|
|
|
|
|
|
|
- (void) manualAnnounce;
|
|
|
|
- (BOOL) canManualAnnounce;
|
|
|
|
|
|
|
|
- (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-09-22 04:45:15 +00:00
|
|
|
- (tr_speedlimit) speedMode: (BOOL) upload;
|
|
|
|
- (void) setSpeedMode: (tr_speedlimit) mode upload: (BOOL) upload;
|
2007-09-16 01:02:06 +00:00
|
|
|
- (int) speedLimit: (BOOL) upload;
|
|
|
|
- (void) setSpeedLimit: (int) limit upload: (BOOL) upload;
|
|
|
|
|
2007-12-22 05:21:25 +00:00
|
|
|
- (void) setMaxPeerConnect: (uint16_t) count;
|
|
|
|
- (uint16_t) maxPeerConnect;
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
- (void) setWaitToStart: (BOOL) wait;
|
|
|
|
- (BOOL) waitingToStart;
|
|
|
|
|
|
|
|
- (void) revealData;
|
|
|
|
- (void) revealPublicTorrent;
|
|
|
|
- (void) trashData;
|
|
|
|
- (void) trashTorrent;
|
|
|
|
- (void) moveTorrentDataFileTo: (NSString *) folder;
|
|
|
|
- (void) copyTorrentFileTo: (NSString *) path;
|
|
|
|
|
|
|
|
- (BOOL) alertForRemainingDiskSpace;
|
|
|
|
- (BOOL) alertForFolderAvailable;
|
|
|
|
- (BOOL) alertForMoveFolderAvailable;
|
|
|
|
|
|
|
|
- (NSImage *) icon;
|
|
|
|
|
|
|
|
- (NSString *) name;
|
2007-11-25 04:06:26 +00:00
|
|
|
- (BOOL) folder;
|
2007-09-16 01:02:06 +00:00
|
|
|
- (uint64_t) size;
|
2007-10-07 03:28:06 +00:00
|
|
|
- (uint64_t) sizeLeft;
|
2007-09-16 01:02:06 +00:00
|
|
|
- (NSString *) trackerAddress;
|
|
|
|
- (NSString *) trackerAddressAnnounce;
|
2007-10-24 18:49:59 +00:00
|
|
|
- (NSArray *) allTrackers;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
- (NSString *) comment;
|
|
|
|
- (NSString *) creator;
|
|
|
|
- (NSDate *) dateCreated;
|
|
|
|
|
|
|
|
- (int) pieceSize;
|
|
|
|
- (int) pieceCount;
|
|
|
|
- (NSString *) hashString;
|
|
|
|
- (BOOL) privateTorrent;
|
|
|
|
|
|
|
|
- (NSString *) torrentLocation;
|
|
|
|
- (NSString *) publicTorrentLocation;
|
|
|
|
- (NSString *) dataLocation;
|
|
|
|
|
|
|
|
- (BOOL) publicTorrent;
|
|
|
|
|
|
|
|
- (float) progress;
|
|
|
|
- (float) progressDone;
|
|
|
|
- (float) progressLeft;
|
2008-01-10 20:59:56 +00:00
|
|
|
- (float) checkingProgress;
|
2007-11-23 17:42:49 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
- (int) eta;
|
2007-11-23 17:42:49 +00:00
|
|
|
- (int) etaRatio;
|
2007-11-24 16:46:11 +00:00
|
|
|
- (NSString *) etaString: (int) eta;
|
2007-09-27 21:02:25 +00:00
|
|
|
|
2007-09-27 20:42:20 +00:00
|
|
|
- (float) notAvailableDesired;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
- (BOOL) isActive;
|
|
|
|
- (BOOL) isSeeding;
|
|
|
|
- (BOOL) isChecking;
|
|
|
|
- (BOOL) allDownloaded;
|
|
|
|
- (BOOL) isComplete;
|
|
|
|
- (BOOL) isError;
|
|
|
|
- (NSString *) errorMessage;
|
|
|
|
|
|
|
|
- (NSArray *) peers;
|
|
|
|
|
|
|
|
- (NSString *) progressString;
|
|
|
|
- (NSString *) statusString;
|
|
|
|
- (NSString *) shortStatusString;
|
|
|
|
- (NSString *) remainingTimeString;
|
|
|
|
|
2007-09-28 02:58:25 +00:00
|
|
|
- (NSString *) stateString;
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
- (int) seeders;
|
|
|
|
- (int) leechers;
|
|
|
|
- (int) completedFromTracker;
|
|
|
|
|
|
|
|
- (int) totalPeersConnected;
|
|
|
|
- (int) totalPeersTracker;
|
|
|
|
- (int) totalPeersIncoming;
|
|
|
|
- (int) totalPeersCache;
|
|
|
|
- (int) totalPeersPex;
|
2007-10-01 16:23:00 +00:00
|
|
|
- (int) totalPeersKnown;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
- (int) peersSendingToUs;
|
|
|
|
- (int) peersGettingFromUs;
|
|
|
|
|
|
|
|
- (float) downloadRate;
|
|
|
|
- (float) uploadRate;
|
2007-11-23 16:03:49 +00:00
|
|
|
- (float) totalRate;
|
2007-09-26 03:27:00 +00:00
|
|
|
- (uint64_t) haveVerified;
|
|
|
|
- (uint64_t) haveTotal;
|
2007-09-26 18:32:32 +00:00
|
|
|
- (uint64_t) downloadedTotal;
|
2007-09-26 18:43:32 +00:00
|
|
|
- (uint64_t) uploadedTotal;
|
2007-09-26 18:32:32 +00:00
|
|
|
- (uint64_t) failedHash;
|
2007-09-16 01:02:06 +00:00
|
|
|
- (float) swarmSpeed;
|
|
|
|
|
2007-11-23 15:45:58 +00:00
|
|
|
- (int) orderValue;
|
2007-09-16 01:02:06 +00:00
|
|
|
- (void) setOrderValue: (int) orderValue;
|
|
|
|
|
2007-12-17 16:06:20 +00:00
|
|
|
- (int) groupValue;
|
|
|
|
- (void) setGroupValue: (int) groupValue;
|
2007-12-17 20:10:51 +00:00
|
|
|
- (int) groupOrderValue;
|
2007-12-19 21:11:49 +00:00
|
|
|
- (void) checkGroupValueForRemoval: (NSNotification *) notification;
|
2007-12-17 16:06:20 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
- (NSArray *) fileList;
|
|
|
|
- (int) fileCount;
|
|
|
|
- (void) updateFileStat;
|
|
|
|
|
|
|
|
//methods require fileStats to have been updated recently to be accurate
|
|
|
|
- (float) fileProgress: (int) index;
|
|
|
|
- (BOOL) canChangeDownloadCheckForFile: (int) index;
|
|
|
|
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
|
|
|
|
- (int) checkForFiles: (NSIndexSet *) indexSet;
|
|
|
|
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
|
|
|
|
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
|
|
|
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
|
|
|
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
|
|
|
|
|
|
|
|
- (NSMenu *) fileMenu;
|
|
|
|
|
|
|
|
- (NSDate *) dateAdded;
|
|
|
|
- (NSDate *) dateCompleted;
|
|
|
|
- (NSDate *) dateActivity;
|
2007-11-23 02:46:29 +00:00
|
|
|
- (NSDate *) dateActivityOrAdd;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
- (int) stalledMinutes;
|
|
|
|
- (BOOL) isStalled;
|
|
|
|
|
|
|
|
- (NSNumber *) stateSortKey;
|
|
|
|
|
|
|
|
- (int) torrentID;
|
2007-09-20 20:24:33 +00:00
|
|
|
- (const tr_info *) torrentInfo;
|
|
|
|
- (const tr_stat *) torrentStat;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
@end
|