1
1
/******************************************************************************
2
* $Id: Torrent.h 5678 2008-04-24 06:35:21Z livings124 $
2
* $Id: Torrent.h 8260 2009-04-20 02:45:27Z livings124 $
4
* Copyright (c) 2006-2008 Transmission authors and contributors
4
* Copyright (c) 2006-2009 Transmission authors and contributors
6
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
7
* copy of this software and associated documentation files (the "Software"),
34
34
TORRENT_FILE_DEFAULT
35
35
} torrentFileState;
37
#define STAT_TIME_NONE -1
38
#define STAT_TIME_NOW -2
37
40
@interface Torrent : NSObject
39
42
tr_torrent * fHandle;
40
43
const tr_info * fInfo;
41
44
const tr_stat * fStat;
45
46
BOOL fResumeOnWake;
46
NSDate * fDateAdded, * fDateCompleted, * fDateActivity;
48
48
BOOL fUseIncompleteFolder;
49
49
NSString * fDownloadFolder, * fIncompleteFolder;
58
58
NSString * fNameString, * fHashString;
60
60
tr_file_stat * fFileStat;
63
float * fPreviousFinishedPieces;
64
NSDate * fFinishedPiecesDate;
61
NSArray * fFileList, * fFlatFileList;
63
NSIndexSet * fPreviousFinishedIndexes;
64
NSDate * fPreviousFinishedIndexesDate;
68
66
BOOL fFinishedSeeding, fWaitToStart, fStalled;
70
int fOrderValue, fGroupValue;
68
NSInteger fGroupValue;
72
72
NSDictionary * fQuickPauseDict;
75
75
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
76
lib: (tr_handle *) lib;
77
- (id) initWithData: (NSData *) data location: (NSString *) location lib: (tr_handle *) lib;
78
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle *) lib;
76
lib: (tr_session *) lib;
77
- (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_session *) lib;
78
- (id) initWithHistory: (NSDictionary *) history lib: (tr_session *) lib;
80
80
- (NSDictionary *) history;
85
85
- (void) changeDownloadFolder: (NSString *) folder;
86
86
- (NSString *) downloadFolder;
88
- (void) getAvailability: (int8_t *) tab size: (int) size;
89
- (void) getAmountFinished: (float *) tab size: (int) size;
90
- (float *) getPreviousAmountFinished;
91
-(void) setPreviousAmountFinished: (float *) tab;
88
- (void) getAvailability: (int8_t *) tab size: (NSInteger) size;
89
- (void) getAmountFinished: (float *) tab size: (NSInteger) size;
90
- (NSIndexSet *) previousFinishedPieces;
91
-(void) setPreviousFinishedPieces: (NSIndexSet *) indexes;
103
103
- (void) resetCache;
106
- (int) ratioSetting;
107
- (void) setRatioSetting: (int) setting;
108
- (float) ratioLimit;
109
- (void) setRatioLimit: (float) limit;
110
- (float) actualStopRatio; //returns INVALID if will not stop
111
- (float) progressStopRatio;
106
- (tr_ratiolimit) ratioSetting;
107
- (void) setRatioSetting: (tr_ratiolimit) setting;
108
- (CGFloat) ratioLimit;
109
- (void) setRatioLimit: (CGFloat) limit;
110
- (BOOL) seedRatioSet;
111
- (CGFloat) progressStopRatio;
113
- (tr_speedlimit) speedMode: (BOOL) upload;
114
- (void) setSpeedMode: (tr_speedlimit) mode upload: (BOOL) upload;
115
- (int) speedLimit: (BOOL) upload;
116
- (void) setSpeedLimit: (int) limit upload: (BOOL) upload;
113
- (BOOL) usesSpeedLimit: (BOOL) upload;
114
- (void) setUseSpeedLimit: (BOOL) use upload: (BOOL) upload;
115
- (NSInteger) speedLimit: (BOOL) upload;
116
- (void) setSpeedLimit: (NSInteger) limit upload: (BOOL) upload;
117
- (BOOL) usesGlobalSpeedLimit;
118
- (void) setUseGlobalSpeedLimit: (BOOL) use;
118
120
- (void) setMaxPeerConnect: (uint16_t) count;
119
121
- (uint16_t) maxPeerConnect;
135
140
- (NSImage *) icon;
137
142
- (NSString *) name;
139
144
- (uint64_t) size;
140
145
- (uint64_t) sizeLeft;
142
147
- (NSString *) trackerAddressAnnounce;
143
148
- (NSDate *) lastAnnounceTime;
144
- (int) nextAnnounceTime;
149
- (NSInteger) nextAnnounceTime;
145
150
- (NSString *) announceResponse;
147
152
- (NSString *) trackerAddressScrape;
148
153
- (NSDate *) lastScrapeTime;
149
- (int) nextScrapeTime;
154
- (NSInteger) nextScrapeTime;
150
155
- (NSString *) scrapeResponse;
152
- (NSArray *) allTrackers: (BOOL) separators;
157
- (NSMutableArray *) allTrackers: (BOOL) separators;
158
- (NSArray *) allTrackersFlat;
159
- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
160
- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
161
- (BOOL) hasAddedTrackers;
154
163
- (NSString *) comment;
155
164
- (NSString *) creator;
156
165
- (NSDate *) dateCreated;
167
- (NSInteger) pieceSize;
168
- (NSInteger) pieceCount;
160
169
- (NSString *) hashString;
161
170
- (BOOL) privateTorrent;
167
176
- (BOOL) publicTorrent;
170
- (float) progressDone;
171
- (float) progressLeft;
172
- (float) checkingProgress;
177
- (float) notAvailableDesired;
178
- (CGFloat) progress;
179
- (CGFloat) progressDone;
180
- (CGFloat) progressLeft;
181
- (CGFloat) checkingProgress;
185
- (CGFloat) notAvailableDesired;
179
187
- (BOOL) isActive;
180
188
- (BOOL) isSeeding;
195
206
- (NSString *) stateString;
199
- (int) completedFromTracker;
201
- (int) totalPeersConnected;
202
- (int) totalPeersTracker;
203
- (int) totalPeersIncoming;
204
- (int) totalPeersCache;
205
- (int) totalPeersPex;
206
- (int) totalPeersKnown;
208
- (int) peersSendingToUs;
209
- (int) peersGettingFromUs;
211
- (float) downloadRate;
212
- (float) uploadRate;
208
- (NSInteger) seeders;
209
- (NSInteger) leechers;
210
- (NSInteger) completedFromTracker;
212
- (NSInteger) totalPeersConnected;
213
- (NSInteger) totalPeersTracker;
214
- (NSInteger) totalPeersIncoming;
215
- (NSInteger) totalPeersCache;
216
- (NSInteger) totalPeersPex;
217
- (NSInteger) totalPeersKnown;
219
- (NSInteger) peersSendingToUs;
220
- (NSInteger) peersGettingFromUs;
222
- (CGFloat) downloadRate;
223
- (CGFloat) uploadRate;
224
- (CGFloat) totalRate;
214
225
- (uint64_t) haveVerified;
215
226
- (uint64_t) haveTotal;
216
227
- (uint64_t) totalSizeSelected;
217
228
- (uint64_t) downloadedTotal;
218
229
- (uint64_t) uploadedTotal;
219
230
- (uint64_t) failedHash;
220
- (float) swarmSpeed;
223
- (void) setOrderValue: (int) orderValue;
226
- (void) setGroupValue: (int) groupValue;
227
- (int) groupOrderValue;
231
- (CGFloat) swarmSpeed;
233
- (NSInteger) groupValue;
234
- (void) setGroupValue: (NSInteger) groupValue;
235
- (NSInteger) groupOrderValue;
228
236
- (void) checkGroupValueForRemoval: (NSNotification *) notification;
230
238
- (NSArray *) fileList;
239
- (NSInteger) fileCount;
232
240
- (void) updateFileStat;
241
- (NSArray *) flatFileList;
234
243
//methods require fileStats to have been updated recently to be accurate
235
- (float) fileProgress: (int) index;
236
- (BOOL) canChangeDownloadCheckForFile: (int) index;
244
- (CGFloat) fileProgress: (FileListNode *) node;
245
- (BOOL) canChangeDownloadCheckForFile: (NSInteger) index;
237
246
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
238
- (int) checkForFiles: (NSIndexSet *) indexSet;
239
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
240
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
241
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
247
- (NSInteger) checkForFiles: (NSIndexSet *) indexSet;
248
- (void) setFileCheckState: (NSInteger) state forIndexes: (NSIndexSet *) indexSet;
249
- (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet;
250
- (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet;
242
251
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
244
253
- (NSDate *) dateAdded;
246
255
- (NSDate *) dateActivity;
247
256
- (NSDate *) dateActivityOrAdd;
249
- (int) stalledMinutes;
258
- (NSInteger) stalledMinutes;
250
259
- (BOOL) isStalled;
252
- (NSNumber *) stateSortKey;
261
- (NSInteger) stateSortKey;
255
263
- (tr_torrent *) torrentStruct;