transmission/macosx/Torrent.h

269 lines
7.4 KiB
C
Raw Normal View History

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>
@class FileListNode;
2007-09-16 01:02:06 +00:00
#define INVALID -99
typedef enum
{
TORRENT_FILE_DELETE,
TORRENT_FILE_SAVE,
TORRENT_FILE_DEFAULT
} torrentFileState;
#define STAT_TIME_NONE -1
#define STAT_TIME_NOW -2
2007-09-16 01:02:06 +00:00
@interface Torrent : NSObject
{
2007-09-20 20:24:33 +00:00
tr_torrent * fHandle;
const tr_info * fInfo;
const tr_stat * fStat;
2007-09-16 01:02:06 +00:00
BOOL fResumeOnWake;
2007-09-16 01:02:06 +00:00
BOOL fUseIncompleteFolder;
NSString * fDownloadFolder, * fIncompleteFolder;
2007-09-16 01:02:06 +00:00
BOOL fPublicTorrent;
NSString * fPublicTorrentLocation;
2007-09-16 01:02:06 +00:00
NSUserDefaults * fDefaults;
NSImage * fIcon;
2008-02-16 19:32:22 +00:00
NSString * fNameString, * fHashString;
tr_file_stat * fFileStat;
NSArray * fFileList, * fFlatFileList;
2007-09-16 01:02:06 +00:00
NSIndexSet * fPreviousFinishedIndexes;
NSDate * fPreviousFinishedIndexesDate;
2008-11-02 01:07:01 +00:00
CGFloat fRatioLimit;
NSInteger fRatioSetting;
2008-01-14 04:50:19 +00:00
BOOL fFinishedSeeding, fWaitToStart, fStalled;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
NSInteger fOrderValue, fGroupValue;
2007-09-16 01:02:06 +00:00
BOOL fAddedTrackers;
2007-09-16 01:02:06 +00:00
NSDictionary * fQuickPauseDict;
}
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
lib: (tr_session *) lib;
- (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_session *) lib;
- (id) initWithHistory: (NSDictionary *) history lib: (tr_session *) lib;
2007-09-16 01:02:06 +00:00
- (NSDictionary *) history;
- (void) closeRemoveTorrent;
- (void) changeIncompleteDownloadFolder: (NSString *) folder;
- (void) changeDownloadFolder: (NSString *) folder;
- (NSString *) downloadFolder;
2008-11-02 01:07:01 +00:00
- (void) getAvailability: (int8_t *) tab size: (NSInteger) size;
- (void) getAmountFinished: (float *) tab size: (NSInteger) size;
- (NSIndexSet *) previousFinishedPieces;
-(void) setPreviousFinishedPieces: (NSIndexSet *) indexes;
2007-09-16 01:02:06 +00:00
- (void) update;
- (void) startTransfer;
- (void) stopTransfer;
- (void) sleep;
- (void) wakeUp;
- (void) manualAnnounce;
- (BOOL) canManualAnnounce;
- (void) resetCache;
2008-11-02 01:07:01 +00:00
- (CGFloat) ratio;
- (NSInteger) ratioSetting;
- (void) setRatioSetting: (NSInteger) setting;
- (CGFloat) ratioLimit;
- (void) setRatioLimit: (CGFloat) limit;
- (CGFloat) actualStopRatio; //returns INVALID if will not stop
- (CGFloat) progressStopRatio;
2007-09-16 01:02:06 +00:00
2007-09-22 04:45:15 +00:00
- (tr_speedlimit) speedMode: (BOOL) upload;
- (void) setSpeedMode: (tr_speedlimit) mode upload: (BOOL) upload;
2008-11-02 01:07:01 +00:00
- (NSInteger) speedLimit: (BOOL) upload;
- (void) setSpeedLimit: (NSInteger) limit upload: (BOOL) upload;
2007-09-16 01:02:06 +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;
- (BOOL) isFolder;
2007-09-16 01:02:06 +00:00
- (uint64_t) size;
- (uint64_t) sizeLeft;
2008-02-22 01:36:30 +00:00
2007-09-16 01:02:06 +00:00
- (NSString *) trackerAddressAnnounce;
2008-02-22 01:36:30 +00:00
- (NSDate *) lastAnnounceTime;
2008-11-02 01:07:01 +00:00
- (NSInteger) nextAnnounceTime;
2008-02-22 01:36:30 +00:00
- (NSString *) announceResponse;
- (NSString *) trackerAddressScrape;
- (NSDate *) lastScrapeTime;
2008-11-02 01:07:01 +00:00
- (NSInteger) nextScrapeTime;
2008-02-22 01:36:30 +00:00
- (NSString *) scrapeResponse;
- (NSMutableArray *) allTrackers: (BOOL) separators;
2008-12-24 17:41:45 +00:00
- (NSString *) trackerList;
- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
- (BOOL) hasAddedTrackers;
2007-09-16 01:02:06 +00:00
- (NSString *) comment;
- (NSString *) creator;
- (NSDate *) dateCreated;
2008-11-02 01:07:01 +00:00
- (NSInteger) pieceSize;
- (NSInteger) pieceCount;
2007-09-16 01:02:06 +00:00
- (NSString *) hashString;
- (BOOL) privateTorrent;
- (NSString *) torrentLocation;
- (NSString *) publicTorrentLocation;
- (NSString *) dataLocation;
- (BOOL) publicTorrent;
2008-11-02 01:07:01 +00:00
- (CGFloat) progress;
- (CGFloat) progressDone;
- (CGFloat) progressLeft;
- (CGFloat) checkingProgress;
2008-11-02 01:07:01 +00:00
- (NSInteger) eta;
- (NSInteger) etaRatio;
2008-11-02 01:07:01 +00:00
- (CGFloat) notAvailableDesired;
2007-09-16 01:02:06 +00:00
- (BOOL) isActive;
- (BOOL) isSeeding;
- (BOOL) isChecking;
- (BOOL) isCheckingWaiting;
2007-09-16 01:02:06 +00:00
- (BOOL) allDownloaded;
- (BOOL) isComplete;
- (BOOL) isError;
- (NSString *) errorMessage;
- (NSArray *) peers;
- (NSUInteger) webSeedCount;
2008-06-08 18:02:16 +00:00
- (NSArray *) webSeeds;
2007-09-16 01:02:06 +00:00
- (NSString *) progressString;
- (NSString *) statusString;
- (NSString *) shortStatusString;
- (NSString *) remainingTimeString;
- (NSString *) stateString;
2008-11-02 01:07:01 +00:00
- (NSInteger) seeders;
- (NSInteger) leechers;
- (NSInteger) completedFromTracker;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
- (NSInteger) totalPeersConnected;
- (NSInteger) totalPeersTracker;
- (NSInteger) totalPeersIncoming;
- (NSInteger) totalPeersCache;
- (NSInteger) totalPeersPex;
- (NSInteger) totalPeersKnown;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
- (NSInteger) peersSendingToUs;
- (NSInteger) peersGettingFromUs;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
- (CGFloat) downloadRate;
- (CGFloat) uploadRate;
- (CGFloat) totalRate;
- (uint64_t) haveVerified;
- (uint64_t) haveTotal;
2008-02-27 19:34:55 +00:00
- (uint64_t) totalSizeSelected;
- (uint64_t) downloadedTotal;
- (uint64_t) uploadedTotal;
- (uint64_t) failedHash;
2008-11-02 01:07:01 +00:00
- (CGFloat) swarmSpeed;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
- (NSInteger) orderValue;
- (void) setOrderValue: (NSInteger) orderValue;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
- (NSInteger) groupValue;
- (void) setGroupValue: (NSInteger) groupValue;
- (NSInteger) groupOrderValue;
- (void) checkGroupValueForRemoval: (NSNotification *) notification;
2007-12-17 16:06:20 +00:00
2007-09-16 01:02:06 +00:00
- (NSArray *) fileList;
2008-11-02 01:07:01 +00:00
- (NSInteger) fileCount;
2007-09-16 01:02:06 +00:00
- (void) updateFileStat;
- (NSArray *) flatFileList;
2007-09-16 01:02:06 +00:00
//methods require fileStats to have been updated recently to be accurate
2008-11-02 01:07:01 +00:00
- (CGFloat) fileProgress: (FileListNode *) node;
- (BOOL) canChangeDownloadCheckForFile: (NSInteger) index;
2007-09-16 01:02:06 +00:00
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
2008-11-02 01:07:01 +00:00
- (NSInteger) checkForFiles: (NSIndexSet *) indexSet;
- (void) setFileCheckState: (NSInteger) state forIndexes: (NSIndexSet *) indexSet;
- (void) setFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
- (BOOL) hasFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
2007-09-16 01:02:06 +00:00
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
- (NSDate *) dateAdded;
- (NSDate *) dateCompleted;
- (NSDate *) dateActivity;
- (NSDate *) dateActivityOrAdd;
2007-09-16 01:02:06 +00:00
2008-11-02 01:07:01 +00:00
- (NSInteger) stalledMinutes;
2007-09-16 01:02:06 +00:00
- (BOOL) isStalled;
- (NSInteger) stateSortKey;
2007-09-16 01:02:06 +00:00
- (tr_torrent *) torrentStruct;
2007-09-16 01:02:06 +00:00
@end