1 | /****************************************************************************** |
---|
2 | * $Id: Torrent.h 9182 2009-09-26 13:58:40Z livings124 $ |
---|
3 | * |
---|
4 | * Copyright (c) 2006-2009 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 | #warning remove!? |
---|
32 | #define STAT_TIME_NONE -1 |
---|
33 | #define STAT_TIME_NOW -2 |
---|
34 | |
---|
35 | @interface Torrent : NSObject <QLPreviewItem> |
---|
36 | { |
---|
37 | tr_torrent * fHandle; |
---|
38 | const tr_info * fInfo; |
---|
39 | const tr_stat * fStat; |
---|
40 | |
---|
41 | BOOL fResumeOnWake; |
---|
42 | |
---|
43 | BOOL fUseIncompleteFolder; |
---|
44 | NSString * fDownloadFolder, * fIncompleteFolder; |
---|
45 | |
---|
46 | NSUserDefaults * fDefaults; |
---|
47 | |
---|
48 | NSImage * fIcon; |
---|
49 | |
---|
50 | NSString * fNameString, * fHashString; |
---|
51 | |
---|
52 | tr_file_stat * fFileStat; |
---|
53 | NSArray * fFileList, * fFlatFileList; |
---|
54 | |
---|
55 | NSIndexSet * fPreviousFinishedIndexes; |
---|
56 | NSDate * fPreviousFinishedIndexesDate; |
---|
57 | |
---|
58 | BOOL fFinishedSeeding, fWaitToStart, fStalled; |
---|
59 | |
---|
60 | NSInteger fGroupValue; |
---|
61 | |
---|
62 | NSDictionary * fQuickPauseDict; |
---|
63 | } |
---|
64 | |
---|
65 | - (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (BOOL) torrentDelete |
---|
66 | lib: (tr_session *) lib; |
---|
67 | - (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_session *) lib; |
---|
68 | - (id) initWithHistory: (NSDictionary *) history lib: (tr_session *) lib forcePause: (BOOL) pause; |
---|
69 | |
---|
70 | - (NSDictionary *) history; |
---|
71 | |
---|
72 | - (void) closeRemoveTorrent; |
---|
73 | |
---|
74 | - (void) changeIncompleteDownloadFolder: (NSString *) folder; |
---|
75 | - (void) changeDownloadFolder: (NSString *) folder; |
---|
76 | - (NSString *) downloadFolder; |
---|
77 | |
---|
78 | - (void) getAvailability: (int8_t *) tab size: (NSInteger) size; |
---|
79 | - (void) getAmountFinished: (float *) tab size: (NSInteger) size; |
---|
80 | - (NSIndexSet *) previousFinishedPieces; |
---|
81 | -(void) setPreviousFinishedPieces: (NSIndexSet *) indexes; |
---|
82 | |
---|
83 | - (void) update; |
---|
84 | |
---|
85 | - (void) startTransfer; |
---|
86 | - (void) stopTransfer; |
---|
87 | - (void) sleep; |
---|
88 | - (void) wakeUp; |
---|
89 | |
---|
90 | - (void) manualAnnounce; |
---|
91 | - (BOOL) canManualAnnounce; |
---|
92 | |
---|
93 | - (void) resetCache; |
---|
94 | |
---|
95 | - (CGFloat) ratio; |
---|
96 | - (tr_ratiolimit) ratioSetting; |
---|
97 | - (void) setRatioSetting: (tr_ratiolimit) setting; |
---|
98 | - (CGFloat) ratioLimit; |
---|
99 | - (void) setRatioLimit: (CGFloat) limit; |
---|
100 | - (BOOL) seedRatioSet; |
---|
101 | - (CGFloat) progressStopRatio; |
---|
102 | |
---|
103 | - (BOOL) usesSpeedLimit: (BOOL) upload; |
---|
104 | - (void) setUseSpeedLimit: (BOOL) use upload: (BOOL) upload; |
---|
105 | - (NSInteger) speedLimit: (BOOL) upload; |
---|
106 | - (void) setSpeedLimit: (NSInteger) limit upload: (BOOL) upload; |
---|
107 | - (BOOL) usesGlobalSpeedLimit; |
---|
108 | - (void) setUseGlobalSpeedLimit: (BOOL) use; |
---|
109 | |
---|
110 | - (void) setMaxPeerConnect: (uint16_t) count; |
---|
111 | - (uint16_t) maxPeerConnect; |
---|
112 | |
---|
113 | - (void) setWaitToStart: (BOOL) wait; |
---|
114 | - (BOOL) waitingToStart; |
---|
115 | |
---|
116 | - (tr_priority_t) priority; |
---|
117 | - (void) setPriority: (tr_priority_t) priority; |
---|
118 | |
---|
119 | + (void) trashFile: (NSString *) path; |
---|
120 | - (void) trashData; |
---|
121 | - (void) moveTorrentDataFileTo: (NSString *) folder; |
---|
122 | - (void) copyTorrentFileTo: (NSString *) path; |
---|
123 | |
---|
124 | - (BOOL) alertForRemainingDiskSpace; |
---|
125 | - (BOOL) alertForFolderAvailable; |
---|
126 | - (BOOL) alertForMoveFolderAvailable; |
---|
127 | |
---|
128 | - (NSImage *) icon; |
---|
129 | |
---|
130 | - (NSString *) name; |
---|
131 | - (BOOL) isFolder; |
---|
132 | - (uint64_t) size; |
---|
133 | - (uint64_t) sizeLeft; |
---|
134 | |
---|
135 | /*- (NSString *) trackerAddressAnnounce; |
---|
136 | - (NSDate *) lastAnnounceTime; |
---|
137 | - (NSInteger) nextAnnounceTime; |
---|
138 | - (NSString *) announceResponse; |
---|
139 | |
---|
140 | - (NSString *) trackerAddressScrape; |
---|
141 | - (NSDate *) lastScrapeTime; |
---|
142 | - (NSInteger) nextScrapeTime; |
---|
143 | - (NSString *) scrapeResponse;*/ |
---|
144 | |
---|
145 | - (NSArray *) allTrackerStats; |
---|
146 | - (NSArray *) allTrackersFlat; //used by GroupRules |
---|
147 | /*- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers; |
---|
148 | - (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;*/ |
---|
149 | |
---|
150 | - (NSString *) comment; |
---|
151 | - (NSString *) creator; |
---|
152 | - (NSDate *) dateCreated; |
---|
153 | |
---|
154 | - (NSInteger) pieceSize; |
---|
155 | - (NSInteger) pieceCount; |
---|
156 | - (NSString *) hashString; |
---|
157 | - (BOOL) privateTorrent; |
---|
158 | |
---|
159 | - (NSString *) torrentLocation; |
---|
160 | - (NSString *) dataLocation; |
---|
161 | |
---|
162 | - (CGFloat) progress; |
---|
163 | - (CGFloat) progressDone; |
---|
164 | - (CGFloat) checkingProgress; |
---|
165 | |
---|
166 | - (NSInteger) eta; |
---|
167 | |
---|
168 | - (CGFloat) availableDesired; |
---|
169 | |
---|
170 | - (BOOL) isActive; |
---|
171 | - (BOOL) isSeeding; |
---|
172 | - (BOOL) isChecking; |
---|
173 | - (BOOL) isCheckingWaiting; |
---|
174 | - (BOOL) allDownloaded; |
---|
175 | - (BOOL) isComplete; |
---|
176 | - (BOOL) isError; |
---|
177 | - (BOOL) isErrorOrWarning; |
---|
178 | - (NSString *) errorMessage; |
---|
179 | |
---|
180 | - (NSArray *) peers; |
---|
181 | |
---|
182 | - (NSUInteger) webSeedCount; |
---|
183 | - (NSArray *) webSeeds; |
---|
184 | |
---|
185 | - (NSString *) progressString; |
---|
186 | - (NSString *) statusString; |
---|
187 | - (NSString *) shortStatusString; |
---|
188 | - (NSString *) remainingTimeString; |
---|
189 | |
---|
190 | - (NSString *) stateString; |
---|
191 | - (NSInteger) totalPeersConnected; |
---|
192 | - (NSInteger) totalPeersTracker; |
---|
193 | - (NSInteger) totalPeersIncoming; |
---|
194 | - (NSInteger) totalPeersCache; |
---|
195 | - (NSInteger) totalPeersPex; |
---|
196 | - (NSInteger) totalPeersDHT; |
---|
197 | - (NSInteger) totalPeersKnown; |
---|
198 | |
---|
199 | - (NSInteger) peersSendingToUs; |
---|
200 | - (NSInteger) peersGettingFromUs; |
---|
201 | |
---|
202 | - (CGFloat) downloadRate; |
---|
203 | - (CGFloat) uploadRate; |
---|
204 | - (CGFloat) totalRate; |
---|
205 | - (uint64_t) haveVerified; |
---|
206 | - (uint64_t) haveTotal; |
---|
207 | - (uint64_t) totalSizeSelected; |
---|
208 | - (uint64_t) downloadedTotal; |
---|
209 | - (uint64_t) uploadedTotal; |
---|
210 | - (uint64_t) failedHash; |
---|
211 | - (CGFloat) swarmSpeed; |
---|
212 | |
---|
213 | - (NSInteger) groupValue; |
---|
214 | - (void) setGroupValue: (NSInteger) groupValue; |
---|
215 | - (NSInteger) groupOrderValue; |
---|
216 | - (void) checkGroupValueForRemoval: (NSNotification *) notification; |
---|
217 | |
---|
218 | - (NSArray *) fileList; |
---|
219 | - (NSInteger) fileCount; |
---|
220 | - (void) updateFileStat; |
---|
221 | - (NSArray *) flatFileList; |
---|
222 | |
---|
223 | //methods require fileStats to have been updated recently to be accurate |
---|
224 | - (CGFloat) fileProgress: (FileListNode *) node; |
---|
225 | - (BOOL) canChangeDownloadCheckForFile: (NSInteger) index; |
---|
226 | - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet; |
---|
227 | - (NSInteger) checkForFiles: (NSIndexSet *) indexSet; |
---|
228 | - (void) setFileCheckState: (NSInteger) state forIndexes: (NSIndexSet *) indexSet; |
---|
229 | - (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet; |
---|
230 | - (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet; |
---|
231 | - (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet; |
---|
232 | |
---|
233 | - (NSDate *) dateAdded; |
---|
234 | - (NSDate *) dateCompleted; |
---|
235 | - (NSDate *) dateActivity; |
---|
236 | - (NSDate *) dateActivityOrAdd; |
---|
237 | |
---|
238 | - (NSInteger) stalledMinutes; |
---|
239 | - (BOOL) isStalled; |
---|
240 | |
---|
241 | - (NSInteger) stateSortKey; |
---|
242 | |
---|
243 | - (tr_torrent *) torrentStruct; |
---|
244 | |
---|
245 | @end |
---|