1 /******************************************************************************
2 * $Id: Controller.h 13256 2012-03-18 14:33:50Z livings124 $
4 * Copyright (c) 2005-2012 Transmission authors and contributors
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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 *****************************************************************************/
25 #import <Cocoa/Cocoa.h>
26 #import <transmission.h>
27 #import <Quartz/Quartz.h>
28 #import <Growl/Growl.h>
30 @
class AddMagnetWindowController
;
31 @
class AddWindowController
;
33 @
class DragOverlayWindow
;
34 @
class FilterBarController
;
35 @
class InfoWindowController
;
36 @
class MessageWindowController
;
37 @
class PrefsController
;
38 @
class StatusBarController
;
40 @
class TorrentTableView
;
41 @
class URLSheetWindowController
;
52 @interface Controller
: NSObject
<GrowlApplicationBridgeDelegate
, NSURLDownloadDelegate
, NSPopoverDelegate
, NSSoundDelegate
, NSToolbarDelegate
, NSWindowDelegate
, QLPreviewPanelDataSource
, QLPreviewPanelDelegate
>
56 NSMutableArray
* fTorrents
, * fDisplayedTorrents
;
58 PrefsController
* fPrefsController
;
59 InfoWindowController
* fInfoController
;
60 MessageWindowController
* fMessageController
;
62 NSUserDefaults
* fDefaults
;
64 NSString
* fConfigDirectory
;
66 IBOutlet NSWindow
* fWindow
;
67 DragOverlayWindow
* fOverlayWindow
;
68 IBOutlet TorrentTableView
* fTableView
;
70 io_connect_t fRootPort
;
73 IBOutlet NSMenuItem
* fOpenIgnoreDownloadFolder
;
74 IBOutlet NSButton
* fActionButton
, * fSpeedLimitButton
, * fClearCompletedButton
;
75 IBOutlet NSTextField
* fTotalTorrentsField
;
77 StatusBarController
* fStatusBar
;
79 FilterBarController
* fFilterBar
;
80 IBOutlet NSMenuItem
* fNextFilterItem
;
82 IBOutlet NSMenuItem
* fNextInfoTabItem
, * fPrevInfoTabItem
;
84 IBOutlet NSMenu
* fSortMenu
;
86 IBOutlet NSMenu
* fActionMenu
;
88 IBOutlet NSMenu
* fUploadMenu
, * fDownloadMenu
;
89 IBOutlet NSMenuItem
* fUploadLimitItem
, * fUploadNoLimitItem
,
90 * fDownloadLimitItem
, * fDownloadNoLimitItem
;
92 IBOutlet NSMenu
* fRatioStopMenu
;
93 IBOutlet NSMenuItem
* fCheckRatioItem
, * fNoCheckRatioItem
;
95 IBOutlet NSMenu
* fGroupsSetMenu
, * fGroupsSetContextMenu
;
97 QLPreviewPanel
* fPreviewPanel
;
104 NSMutableArray
* fAutoImportedNames
;
105 NSTimer
* fAutoImportTimer
;
107 NSMutableDictionary
* fPendingTorrentDownloads
;
109 NSMutableSet
* fAddingTransfers
;
111 NSMutableSet
* fAddWindows
;
112 URLSheetWindowController
* fUrlSheetController
;
114 BOOL fGlobalPopoverShown
;
118 - (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
;
125 - (void) openMagnet
: (NSString
*) address
;
126 - (void) askOpenMagnetConfirmed
: (AddMagnetWindowController
*) addController add
: (BOOL
) add
;
128 - (void) invalidOpenAlert
: (NSString
*) filename
;
129 - (void) invalidOpenMagnetAlert
: (NSString
*) address
;
130 - (void) duplicateOpenAlert
: (NSString
*) name
;
131 - (void) duplicateOpenMagnetAlert
: (NSString
*) address transferName
: (NSString
*) name
;
133 - (void) openURL
: (NSString
*) urlString
;
134 - (void) openURLShowSheet
: (id
) sender
;
136 - (void) quitSheetDidEnd
: (NSWindow
*) sheet returnCode
: (NSInteger
) returnCode contextInfo
: (void *) contextInfo
;
138 - (void) createFile
: (id
) sender
;
140 - (void) resumeSelectedTorrents
: (id
) sender
;
141 - (void) resumeAllTorrents
: (id
) sender
;
142 - (void) resumeTorrents
: (NSArray
*) torrents
;
144 - (void) resumeSelectedTorrentsNoWait
: (id
) sender
;
145 - (void) resumeWaitingTorrents
: (id
) sender
;
146 - (void) resumeTorrentsNoWait
: (NSArray
*) torrents
;
148 - (void) stopSelectedTorrents
: (id
) sender
;
149 - (void) stopAllTorrents
: (id
) sender
;
150 - (void) stopTorrents
: (NSArray
*) torrents
;
152 - (void) removeTorrents
: (NSArray
*) torrents deleteData
: (BOOL
) deleteData
;
153 - (void) removeSheetDidEnd
: (NSWindow
*) sheet returnCode
: (NSInteger
) returnCode
154 contextInfo
: (NSDictionary
*) dict
;
155 - (void) confirmRemoveTorrents
: (NSArray
*) torrents deleteData
: (BOOL
) deleteData
;
156 - (void) removeNoDelete
: (id
) sender
;
157 - (void) removeDeleteData
: (id
) sender
;
159 - (void) clearCompleted
: (id
) sender
;
161 - (void) moveDataFilesSelected
: (id
) sender
;
162 - (void) moveDataFiles
: (NSArray
*) torrents
;
164 - (void) copyTorrentFiles
: (id
) sender
;
165 - (void) copyTorrentFileForTorrents
: (NSMutableArray
*) torrents
;
167 - (void) copyMagnetLinks
: (id
) sender
;
169 - (void) revealFile
: (id
) sender
;
171 - (void) announceSelectedTorrents
: (id
) sender
;
173 - (void) verifySelectedTorrents
: (id
) sender
;
174 - (void) verifyTorrents
: (NSArray
*) torrents
;
176 - (void) showPreferenceWindow
: (id
) sender
;
178 - (void) showAboutWindow
: (id
) sender
;
180 - (void) showInfo
: (id
) sender
;
182 - (void) setInfoTab
: (id
) sender
;
184 - (void) showMessageWindow
: (id
) sender
;
185 - (void) showStatsWindow
: (id
) sender
;
188 - (void) fullUpdateUI
;
190 - (void) setBottomCountText
: (BOOL
) filtering
;
192 - (void) torrentFinishedDownloading
: (NSNotification
*) notification
;
193 - (void) torrentRestartedDownloading
: (NSNotification
*) notification
;
194 - (void) torrentFinishedSeeding
: (NSNotification
*) notification
;
196 - (void) updateTorrentHistory
;
198 - (void) applyFilter
;
200 - (void) sortTorrents
: (BOOL
) includeQueueOrder
;
201 - (void) sortTorrentsCallUpdates
: (BOOL
) callUpdates includeQueueOrder
: (BOOL
) includeQueueOrder
;
202 - (void) rearrangeTorrentTableArray
: (NSMutableArray
*) rearrangeArray forParent
: (id
) parent withSortDescriptors
: (NSArray
*) descriptors beganTableUpdate
: (BOOL
*) beganTableUpdate
;
203 - (void) setSort
: (id
) sender
;
204 - (void) setSortByGroup
: (id
) sender
;
205 - (void) setSortReverse
: (id
) sender
;
207 - (void) switchFilter
: (id
) sender
;
209 - (IBAction
) showGlobalPopover
: (id
) sender
;
211 - (void) setGroup
: (id
) sender
; //used by delegate-generated menu items
213 - (void) toggleSpeedLimit
: (id
) sender
;
214 - (void) speedLimitChanged
: (id
) sender
;
215 - (void) altSpeedToggledCallbackIsLimited
: (NSDictionary
*) dict
;
217 - (void) setLimitGlobalEnabled
: (id
) sender
;
218 - (void) setQuickLimitGlobal
: (id
) sender
;
220 - (void) setRatioGlobalEnabled
: (id
) sender
;
221 - (void) setQuickRatioGlobal
: (id
) sender
;
223 - (void) changeAutoImport
;
224 - (void) checkAutoImportDirectory
;
226 - (void) beginCreateFile
: (NSNotification
*) notification
;
228 - (void) sleepCallback
: (natural_t
) messageType argument
: (void *) messageArgument
;
230 - (void) torrentTableViewSelectionDidChange
: (NSNotification
*) notification
;
232 - (void) toggleSmallView
: (id
) sender
;
233 - (void) togglePiecesBar
: (id
) sender
;
234 - (void) toggleAvailabilityBar
: (id
) sender
;
235 - (void) toggleStatusString
: (id
) sender
;
237 - (void) toggleStatusBar
: (id
) sender
;
238 - (void) showStatusBar
: (BOOL
) show animate
: (BOOL
) animate
;
239 - (void) toggleFilterBar
: (id
) sender
;
240 - (void) showFilterBar
: (BOOL
) show animate
: (BOOL
) animate
;
241 - (void) focusFilterField
;
243 - (void) allToolbarClicked
: (id
) sender
;
244 - (void) selectedToolbarClicked
: (id
) sender
;
246 - (void) setWindowSizeToFit
;
247 - (NSRect
) sizedWindowFrame
;
248 - (void) updateForAutoSize
;
249 - (void) setWindowMinMaxToCurrent
;
250 - (CGFloat
) minWindowContentSizeAllowed
;
252 - (void) updateForExpandCollape
;
254 - (void) showMainWindow
: (id
) sender
;
256 - (void) toggleQuickLook
: (id
) sender
;
258 - (void) linkHomepage
: (id
) sender
;
259 - (void) linkForums
: (id
) sender
;
260 - (void) linkTrac
: (id
) sender
;
261 - (void) linkDonate
: (id
) sender
;
263 - (void) rpcCallback
: (tr_rpc_callback_type
) type forTorrentStruct
: (struct tr_torrent
*) torrentStruct
;
264 - (void) rpcAddTorrentStruct
: (NSValue
*) torrentStructPtr
;
265 - (void) rpcRemoveTorrent
: (Torrent
*) torrent
;
266 - (void) rpcRemoveTorrentDeleteData
: (Torrent
*) torrent
;
267 - (void) rpcStartedStoppedTorrent
: (Torrent
*) torrent
;
268 - (void) rpcChangedTorrent
: (Torrent
*) torrent
;
269 - (void) rpcMovedTorrent
: (Torrent
*) torrent
;
270 - (void) rpcUpdateQueue
;