1/****************************************************************************** 2 * $Id: Torrent.h 13419 2012-08-06 03:59:07Z livings124 $ 3 * 4 * Copyright (c) 2006-2012 Transmission authors and contributors 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 *****************************************************************************/ 24 25#import <Cocoa/Cocoa.h> 26#import <transmission.h> 27#import <Quartz/Quartz.h> 28 29@class FileListNode; 30 31@interface Torrent : NSObject <NSCopying, QLPreviewItem> 32{ 33 tr_torrent * fHandle; 34 const tr_info * fInfo; 35 const tr_stat * fStat; 36 37 NSUserDefaults * fDefaults; 38 39 NSImage * fIcon; 40 41 NSString * fHashString; 42 43 tr_file_stat * fFileStat; 44 NSArray * fFileList, * fFlatFileList; 45 46 NSIndexSet * fPreviousFinishedIndexes; 47 NSDate * fPreviousFinishedIndexesDate; 48 49 BOOL fRemoveWhenFinishSeeding; 50 51 NSInteger fGroupValue; 52 53 BOOL fResumeOnWake; 54 55 BOOL fTimeMachineExcludeInitialized; 56} 57 58- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (BOOL) torrentDelete 59 lib: (tr_session *) lib; 60- (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_session *) lib; 61- (id) initWithMagnetAddress: (NSString *) address location: (NSString *) location lib: (tr_session *) lib; 62- (id) initWithHistory: (NSDictionary *) history lib: (tr_session *) lib forcePause: (BOOL) pause; 63 64- (NSDictionary *) history; 65 66- (void) closeRemoveTorrent: (BOOL) trashFiles; 67 68- (void) changeDownloadFolderBeforeUsing: (NSString *) folder; 69 70- (NSString *) currentDirectory; 71 72- (void) getAvailability: (int8_t *) tab size: (NSInteger) size; 73- (void) getAmountFinished: (float *) tab size: (NSInteger) size; 74- (NSIndexSet *) previousFinishedPieces; 75- (void) setPreviousFinishedPieces: (NSIndexSet *) indexes; 76 77- (void) update; 78 79- (void) startTransferIgnoringQueue: (BOOL) ignoreQueue; 80- (void) startTransferNoQueue; 81- (void) startTransfer; 82- (void) stopTransfer; 83- (void) sleep; 84- (void) wakeUp; 85 86- (NSInteger) queuePosition; 87- (void) setQueuePosition: (NSUInteger) index; 88 89- (void) manualAnnounce; 90- (BOOL) canManualAnnounce; 91 92- (void) resetCache; 93 94- (BOOL) isMagnet; 95- (NSString *) magnetLink; 96 97- (CGFloat) ratio; 98- (tr_ratiolimit) ratioSetting; 99- (void) setRatioSetting: (tr_ratiolimit) setting; 100- (CGFloat) ratioLimit; 101- (void) setRatioLimit: (CGFloat) limit; 102- (CGFloat) progressStopRatio; 103 104- (tr_idlelimit) idleSetting; 105- (void) setIdleSetting: (tr_idlelimit) setting; 106- (NSUInteger) idleLimitMinutes; 107- (void) setIdleLimitMinutes: (NSUInteger) limit; 108 109- (BOOL) usesSpeedLimit: (BOOL) upload; 110- (void) setUseSpeedLimit: (BOOL) use upload: (BOOL) upload; 111- (NSInteger) speedLimit: (BOOL) upload; 112- (void) setSpeedLimit: (NSInteger) limit upload: (BOOL) upload; 113- (BOOL) usesGlobalSpeedLimit; 114- (void) setUseGlobalSpeedLimit: (BOOL) use; 115 116- (void) setMaxPeerConnect: (uint16_t) count; 117- (uint16_t) maxPeerConnect; 118 119@property (nonatomic) BOOL removeWhenFinishSeeding; 120 121- (BOOL) waitingToStart; 122 123- (tr_priority_t) priority; 124- (void) setPriority: (tr_priority_t) priority; 125 126+ (void) trashFile: (NSString *) path; 127- (void) moveTorrentDataFileTo: (NSString *) folder; 128- (void) copyTorrentFileTo: (NSString *) path; 129 130- (BOOL) alertForRemainingDiskSpace; 131 132- (NSImage *) icon; 133 134- (NSString *) name; 135- (BOOL) isFolder; 136- (uint64_t) size; 137- (uint64_t) sizeLeft; 138 139- (NSMutableArray *) allTrackerStats; 140- (NSArray *) allTrackersFlat; //used by GroupRules 141- (BOOL) addTrackerToNewTier: (NSString *) tracker; 142- (void) removeTrackers: (NSSet *) trackers; 143 144- (NSString *) comment; 145- (NSString *) creator; 146- (NSDate *) dateCreated; 147 148- (NSInteger) pieceSize; 149- (NSInteger) pieceCount; 150- (NSString *) hashString; 151- (BOOL) privateTorrent; 152 153- (NSString *) torrentLocation; 154- (NSString *) dataLocation; 155- (NSString *) fileLocation: (FileListNode *) node; 156 157- (CGFloat) progress; 158- (CGFloat) progressDone; 159- (CGFloat) progressLeft; 160- (CGFloat) checkingProgress; 161 162- (CGFloat) availableDesired; 163 164- (BOOL) isActive; 165- (BOOL) isSeeding; 166- (BOOL) isChecking; 167- (BOOL) isCheckingWaiting; 168- (BOOL) allDownloaded; 169- (BOOL) isComplete; 170- (BOOL) isFinishedSeeding; 171- (BOOL) isError; 172- (BOOL) isAnyErrorOrWarning; 173- (NSString *) errorMessage; 174 175- (NSArray *) peers; 176 177- (NSUInteger) webSeedCount; 178- (NSArray *) webSeeds; 179 180- (NSString *) progressString; 181- (NSString *) statusString; 182- (NSString *) shortStatusString; 183- (NSString *) remainingTimeString; 184 185- (NSString *) stateString; 186- (NSInteger) totalPeersConnected; 187- (NSInteger) totalPeersTracker; 188- (NSInteger) totalPeersIncoming; 189- (NSInteger) totalPeersCache; 190- (NSInteger) totalPeersPex; 191- (NSInteger) totalPeersDHT; 192- (NSInteger) totalPeersLocal; 193- (NSInteger) totalPeersLTEP; 194 195- (NSInteger) peersSendingToUs; 196- (NSInteger) peersGettingFromUs; 197 198- (CGFloat) downloadRate; 199- (CGFloat) uploadRate; 200- (CGFloat) totalRate; 201- (uint64_t) haveVerified; 202- (uint64_t) haveTotal; 203- (uint64_t) totalSizeSelected; 204- (uint64_t) downloadedTotal; 205- (uint64_t) uploadedTotal; 206- (uint64_t) failedHash; 207 208- (NSInteger) groupValue; 209- (void) setGroupValue: (NSInteger) groupValue; 210- (NSInteger) groupOrderValue; 211- (void) checkGroupValueForRemoval: (NSNotification *) notification; 212 213- (NSArray *) fileList; 214- (NSArray *) flatFileList; 215- (NSInteger) fileCount; 216- (void) updateFileStat; 217 218//methods require fileStats to have been updated recently to be accurate 219- (CGFloat) fileProgress: (FileListNode *) node; 220- (BOOL) canChangeDownloadCheckForFile: (NSUInteger) index; 221- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet; 222- (NSInteger) checkForFiles: (NSIndexSet *) indexSet; 223- (void) setFileCheckState: (NSInteger) state forIndexes: (NSIndexSet *) indexSet; 224- (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet; 225- (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet; 226- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet; 227 228- (NSDate *) dateAdded; 229- (NSDate *) dateCompleted; 230- (NSDate *) dateActivity; 231- (NSDate *) dateActivityOrAdd; 232 233- (NSInteger) secondsDownloading; 234- (NSInteger) secondsSeeding; 235 236- (NSInteger) stalledMinutes; 237- (BOOL) isStalled; 238 239- (void) updateTimeMachineExclude; 240 241- (NSInteger) stateSortKey; 242- (NSString *) trackerSortKey; 243 244- (tr_torrent *) torrentStruct; 245 246@end 247