source: trunk/macosx/Torrent.h @ 9045

Last change on this file since 9045 was 9045, checked in by livings124, 13 years ago

Simplify the progress bar drawing code using NSDivideRect(). This also allows the bars to have non-integer lengths

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