1 | /****************************************************************************** |
---|
2 | * $Id: Controller.h 6736 2008-09-07 14:51:50Z livings124 $ |
---|
3 | * |
---|
4 | * Copyright (c) 2005-2008 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 "PrefsController.h" |
---|
28 | #import "InfoWindowController.h" |
---|
29 | #import "MessageWindowController.h" |
---|
30 | #import "AddWindowController.h" |
---|
31 | #import "DragOverlayWindow.h" |
---|
32 | #import "Badger.h" |
---|
33 | #import "StatusBarView.h" |
---|
34 | #import "FilterButton.h" |
---|
35 | #import "MenuLabel.h" |
---|
36 | |
---|
37 | #import <Growl/Growl.h> |
---|
38 | |
---|
39 | @class TorrentTableView; |
---|
40 | |
---|
41 | typedef enum |
---|
42 | { |
---|
43 | ADD_MANUAL, |
---|
44 | ADD_AUTO, |
---|
45 | ADD_SHOW_OPTIONS, |
---|
46 | ADD_URL, |
---|
47 | ADD_CREATED |
---|
48 | } addType; |
---|
49 | |
---|
50 | @interface Controller : NSObject <GrowlApplicationBridgeDelegate> |
---|
51 | { |
---|
52 | tr_handle * fLib; |
---|
53 | |
---|
54 | NSMutableArray * fTorrents, * fDisplayedTorrents; |
---|
55 | |
---|
56 | PrefsController * fPrefsController; |
---|
57 | InfoWindowController * fInfoController; |
---|
58 | MessageWindowController * fMessageController; |
---|
59 | |
---|
60 | NSUserDefaults * fDefaults; |
---|
61 | |
---|
62 | IBOutlet NSWindow * fWindow; |
---|
63 | DragOverlayWindow * fOverlayWindow; |
---|
64 | IBOutlet TorrentTableView * fTableView; |
---|
65 | |
---|
66 | io_connect_t fRootPort; |
---|
67 | NSTimer * fTimer; |
---|
68 | |
---|
69 | IBOutlet NSMenuItem * fOpenIgnoreDownloadFolder; |
---|
70 | |
---|
71 | IBOutlet NSBox * fBottomTigerLine; |
---|
72 | IBOutlet NSButton * fActionButton, * fSpeedLimitButton; |
---|
73 | IBOutlet NSTextField * fTotalTorrentsField; |
---|
74 | |
---|
75 | IBOutlet StatusBarView * fStatusBar; |
---|
76 | IBOutlet NSButton * fStatusButton; |
---|
77 | IBOutlet MenuLabel * fStatusTigerField; |
---|
78 | IBOutlet NSImageView * fStatusTigerImageView; |
---|
79 | IBOutlet NSTextField * fTotalDLField, * fTotalULField; |
---|
80 | IBOutlet NSImageView * fTotalDLImageView; |
---|
81 | |
---|
82 | IBOutlet StatusBarView * fFilterBar; |
---|
83 | IBOutlet FilterButton * fNoFilterButton, * fActiveFilterButton, * fDownloadFilterButton, |
---|
84 | * fSeedFilterButton, * fPauseFilterButton; |
---|
85 | IBOutlet NSSearchField * fSearchFilterField; |
---|
86 | IBOutlet NSMenuItem * fNextFilterItem, * fPrevFilterItem; |
---|
87 | |
---|
88 | IBOutlet NSMenuItem * fNextInfoTabItem, * fPrevInfoTabItem; |
---|
89 | |
---|
90 | IBOutlet NSMenu * fUploadMenu, * fDownloadMenu; |
---|
91 | IBOutlet NSMenuItem * fUploadLimitItem, * fUploadNoLimitItem, |
---|
92 | * fDownloadLimitItem, * fDownloadNoLimitItem; |
---|
93 | |
---|
94 | IBOutlet NSMenu * fRatioStopMenu; |
---|
95 | IBOutlet NSMenuItem * fCheckRatioItem, * fNoCheckRatioItem; |
---|
96 | |
---|
97 | IBOutlet NSMenu * fGroupsSetMenu, * fGroupsSetContextMenu, * fGroupFilterMenu; |
---|
98 | IBOutlet NSPopUpButton * fGroupsButton; |
---|
99 | |
---|
100 | IBOutlet NSWindow * fURLSheetWindow; |
---|
101 | IBOutlet NSTextField * fURLSheetTextField; |
---|
102 | IBOutlet NSButton * fURLSheetOpenButton; |
---|
103 | |
---|
104 | BOOL fUpdateInProgress; |
---|
105 | |
---|
106 | Badger * fBadger; |
---|
107 | IBOutlet NSMenu * fDockMenu; |
---|
108 | |
---|
109 | NSTimer * fSpeedLimitTimer; |
---|
110 | |
---|
111 | NSMutableArray * fAutoImportedNames; |
---|
112 | NSTimer * fAutoImportTimer; |
---|
113 | |
---|
114 | NSMutableDictionary * fPendingTorrentDownloads; |
---|
115 | |
---|
116 | BOOL fSoundPlaying; |
---|
117 | } |
---|
118 | |
---|
119 | - (void) openFiles: (NSArray *) filenames addType: (addType) type forcePath: (NSString *) path; |
---|
120 | - (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add; |
---|
121 | - (void) openCreatedFile: (NSNotification *) notification; |
---|
122 | - (void) openFilesWithDict: (NSDictionary *) dictionary; |
---|
123 | - (void) openShowSheet: (id) sender; |
---|
124 | |
---|
125 | - (void) invalidOpenAlert: (NSString *) filename; |
---|
126 | - (void) duplicateOpenAlert: (NSString *) name; |
---|
127 | |
---|
128 | - (void) openURL: (NSURL *) torrentURL; |
---|
129 | - (void) openURLEndSheet: (id) sender; |
---|
130 | - (void) openURLCancelEndSheet: (id) sender; |
---|
131 | - (void) openURLShowSheet: (id) sender; |
---|
132 | |
---|
133 | - (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo; |
---|
134 | |
---|
135 | - (void) createFile: (id) sender; |
---|
136 | |
---|
137 | - (void) resumeSelectedTorrents: (id) sender; |
---|
138 | - (void) resumeAllTorrents: (id) sender; |
---|
139 | - (void) resumeTorrents: (NSArray *) torrents; |
---|
140 | |
---|
141 | - (void) resumeSelectedTorrentsNoWait: (id) sender; |
---|
142 | - (void) resumeWaitingTorrents: (id) sender; |
---|
143 | - (void) resumeTorrentsNoWait: (NSArray *) torrents; |
---|
144 | |
---|
145 | - (void) stopSelectedTorrents: (id) sender; |
---|
146 | - (void) stopAllTorrents: (id) sender; |
---|
147 | - (void) stopTorrents: (NSArray *) torrents; |
---|
148 | |
---|
149 | - (void) removeTorrents: (NSArray *) torrents |
---|
150 | deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteData; |
---|
151 | - (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode |
---|
152 | contextInfo: (NSDictionary *) dict; |
---|
153 | - (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent; |
---|
154 | - (void) removeNoDelete: (id) sender; |
---|
155 | - (void) removeDeleteData: (id) sender; |
---|
156 | - (void) removeDeleteTorrent: (id) sender; |
---|
157 | - (void) removeDeleteDataAndTorrent: (id) sender; |
---|
158 | |
---|
159 | - (void) moveDataFilesSelected: (id) sender; |
---|
160 | - (void) moveDataFiles: (NSArray *) torrents; |
---|
161 | - (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSArray *) torrents; |
---|
162 | |
---|
163 | - (void) copyTorrentFiles: (id) sender; |
---|
164 | - (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents; |
---|
165 | |
---|
166 | - (void) revealFile: (id) sender; |
---|
167 | |
---|
168 | - (void) announceSelectedTorrents: (id) sender; |
---|
169 | |
---|
170 | - (void) verifySelectedTorrents: (id) sender; |
---|
171 | - (void) verifyTorrents: (NSArray *) torrents; |
---|
172 | |
---|
173 | - (void) showPreferenceWindow: (id) sender; |
---|
174 | |
---|
175 | - (void) showAboutWindow: (id) sender; |
---|
176 | |
---|
177 | - (void) showInfo: (id) sender; |
---|
178 | - (void) resetInfo; |
---|
179 | - (void) setInfoTab: (id) sender; |
---|
180 | |
---|
181 | - (void) showMessageWindow: (id) sender; |
---|
182 | - (void) showStatsWindow: (id) sender; |
---|
183 | |
---|
184 | - (void) updateUI; |
---|
185 | |
---|
186 | - (void) resizeStatusButton; |
---|
187 | - (void) setBottomCountText: (BOOL) filtering; |
---|
188 | |
---|
189 | - (void) updateTorrentsInQueue; |
---|
190 | - (int) numToStartFromQueue: (BOOL) downloadQueue; |
---|
191 | |
---|
192 | - (void) torrentFinishedDownloading: (NSNotification *) notification; |
---|
193 | - (void) torrentRestartedDownloading: (NSNotification *) notification; |
---|
194 | - (void) torrentStoppedForRatio: (NSNotification *) notification; |
---|
195 | |
---|
196 | - (void) updateTorrentHistory; |
---|
197 | |
---|
198 | - (void) applyFilter: (id) sender; |
---|
199 | |
---|
200 | - (void) sortTorrents; |
---|
201 | - (void) sortTorrentsIgnoreSelected; |
---|
202 | - (void) setSort: (id) sender; |
---|
203 | - (void) setSortByGroup: (id) sender; |
---|
204 | - (void) setSortReverse: (id) sender; |
---|
205 | |
---|
206 | - (void) setFilter: (id) sender; |
---|
207 | - (void) setFilterSearchType: (id) sender; |
---|
208 | - (void) switchFilter: (id) sender; |
---|
209 | |
---|
210 | - (void) setStatusLabel: (id) sender; |
---|
211 | |
---|
212 | - (void) showGroups: (id) sender; |
---|
213 | - (void) setGroup: (id) sender; //used by delegate-generated menu items |
---|
214 | - (void) setGroupFilter: (id) sender; |
---|
215 | - (void) updateGroupsFilterButton; |
---|
216 | - (void) updateGroupsFilters: (NSNotification *) notification; |
---|
217 | |
---|
218 | - (void) toggleSpeedLimit: (id) sender; |
---|
219 | - (void) autoSpeedLimitChange: (NSNotification *) notification; |
---|
220 | - (void) autoSpeedLimit: (NSTimer *) timer; |
---|
221 | - (void) setAutoSpeedLimitTimer: (BOOL) nextIsLimit; |
---|
222 | |
---|
223 | - (void) setLimitGlobalEnabled: (id) sender; |
---|
224 | - (void) setQuickLimitGlobal: (id) sender; |
---|
225 | |
---|
226 | - (void) setRatioGlobalEnabled: (id) sender; |
---|
227 | - (void) setQuickRatioGlobal: (id) sender; |
---|
228 | |
---|
229 | - (void) changeAutoImport; |
---|
230 | - (void) checkAutoImportDirectory; |
---|
231 | |
---|
232 | - (void) beginCreateFile: (NSNotification *) notification; |
---|
233 | |
---|
234 | - (void) sleepCallback: (natural_t) messageType argument: (void *) messageArgument; |
---|
235 | |
---|
236 | - (void) torrentTableViewSelectionDidChange: (NSNotification *) notification; |
---|
237 | |
---|
238 | - (void) toggleSmallView: (id) sender; |
---|
239 | - (void) togglePiecesBar: (id) sender; |
---|
240 | - (void) toggleAvailabilityBar: (id) sender; |
---|
241 | - (void) toggleStatusString: (id) sender; |
---|
242 | |
---|
243 | - (void) toggleStatusBar: (id) sender; |
---|
244 | - (void) showStatusBar: (BOOL) show animate: (BOOL) animate; |
---|
245 | - (void) toggleFilterBar: (id) sender; |
---|
246 | - (void) showFilterBar: (BOOL) show animate: (BOOL) animate; |
---|
247 | - (void) focusFilterField; |
---|
248 | |
---|
249 | - (void) allToolbarClicked: (id) sender; |
---|
250 | - (void) selectedToolbarClicked: (id) sender; |
---|
251 | |
---|
252 | - (void) setWindowSizeToFit; |
---|
253 | - (NSRect) sizedWindowFrame; |
---|
254 | |
---|
255 | - (void) updateForExpandCollape; |
---|
256 | |
---|
257 | - (void) showMainWindow: (id) sender; |
---|
258 | |
---|
259 | - (NSArray *) quickLookURLs; |
---|
260 | - (BOOL) canQuickLook; |
---|
261 | - (BOOL) canQuickLookTorrent: (Torrent *) torrent; |
---|
262 | - (NSRect) quickLookFrameWithURL: (NSURL*) url; |
---|
263 | - (void) toggleQuickLook: (id) sender; |
---|
264 | |
---|
265 | - (void) linkHomepage: (id) sender; |
---|
266 | - (void) linkForums: (id) sender; |
---|
267 | - (void) linkTrac: (id) sender; |
---|
268 | - (void) linkDonate: (id) sender; |
---|
269 | |
---|
270 | - (void) rpcCallback: (tr_rpc_callback_type) type forTorrentStruct: (struct tr_torrent *) torrentStruct; |
---|
271 | - (void) rpcAddTorrentStruct: (NSValue *) torrentStructPtr; |
---|
272 | - (void) rpcRemoveTorrent: (Torrent *) torrent; |
---|
273 | - (void) rpcStartedStoppedTorrent: (Torrent *) torrent; |
---|
274 | - (void) rpcChangedTorrent: (Torrent *) torrent; |
---|
275 | |
---|
276 | @end |
---|