1 | /** |
---|
2 | * Copyright (C) 2007 Bryan Varner |
---|
3 | * |
---|
4 | * Permission is hereby granted, free of charge, to any person obtaining |
---|
5 | * a copy of this software and associated documentation files (the |
---|
6 | * "Software"), to deal in the Software without restriction, including |
---|
7 | * without limitation the rights to use, copy, modify, merge, publish, |
---|
8 | * distribute, sublicense, and/or sell copies of the Software, and to |
---|
9 | * permit persons to whom the Software is furnished to do so, subject to |
---|
10 | * the following conditions: |
---|
11 | * |
---|
12 | * The above copyright notice and this permission notice shall be included |
---|
13 | * in all copies or substantial portions of the Software. |
---|
14 | * |
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
---|
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
---|
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
---|
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
---|
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
---|
21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
---|
22 | * |
---|
23 | * $Id:$ |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef TR_WIND |
---|
27 | #define TR_WIND |
---|
28 | |
---|
29 | #include <Entry.h> |
---|
30 | #include <FilePanel.h> |
---|
31 | #include <ListView.h> |
---|
32 | #include <ListItem.h> |
---|
33 | #include <Window.h> |
---|
34 | |
---|
35 | #include <libtransmission/transmission.h> |
---|
36 | |
---|
37 | #include "TRPrefsWindow.h" |
---|
38 | |
---|
39 | #define TR_INFO 'tNfo' |
---|
40 | |
---|
41 | #define TR_RESUME 'tRes' |
---|
42 | #define TR_PAUSE 'tPse' |
---|
43 | #define TR_REMOVE 'tRmv' |
---|
44 | #define TR_SELECT 'tSel' |
---|
45 | #define TR_SETTINGS 'tSet' |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | /** |
---|
50 | * Transmission Window. |
---|
51 | */ |
---|
52 | class TRWindow : public BWindow { |
---|
53 | public: // BWindow |
---|
54 | TRWindow(); |
---|
55 | ~TRWindow(); |
---|
56 | |
---|
57 | virtual void MessageReceived(BMessage *msg); |
---|
58 | virtual bool QuitRequested(); |
---|
59 | virtual void FrameResized(float width, float height); |
---|
60 | |
---|
61 | public: // TRWindow |
---|
62 | void AddEntry(BEntry *torrent); |
---|
63 | |
---|
64 | void UpdateList(int32 selection, bool menus); |
---|
65 | |
---|
66 | void LoadSettings(); |
---|
67 | BString GetFolder(void); |
---|
68 | void StopTorrent(tr_torrent_t *torrent); |
---|
69 | void StartTorrent(tr_torrent_t *torrent); |
---|
70 | |
---|
71 | static int32 AsynchStopTorrent(void *data); |
---|
72 | static int32 AsynchStartTorrent(void *data); |
---|
73 | |
---|
74 | void RescanTorrents(); |
---|
75 | |
---|
76 | private: |
---|
77 | static BListView *transfers; |
---|
78 | BFilePanel *openPanel; |
---|
79 | |
---|
80 | tr_handle_t *engine; |
---|
81 | |
---|
82 | TRPrefsWindow *fSettings; |
---|
83 | |
---|
84 | static bool RemovePath(BListItem *item, void *data); |
---|
85 | static bool CheckQuitStatus(BListItem *item, void *data); |
---|
86 | static bool UpdateStats(BListItem *item, void *data); |
---|
87 | |
---|
88 | bool stopping; |
---|
89 | BInvoker *quitter; |
---|
90 | }; |
---|
91 | |
---|
92 | /** |
---|
93 | * Used to pass info off to the worker thread that runs AsynchStopTorrent |
---|
94 | */ |
---|
95 | struct worker_info { |
---|
96 | TRWindow *window; |
---|
97 | tr_torrent_t *torrent; |
---|
98 | }; |
---|
99 | |
---|
100 | struct remove_info { |
---|
101 | TRWindow *window; |
---|
102 | char path[B_FILE_NAME_LENGTH]; |
---|
103 | }; |
---|
104 | |
---|
105 | struct quit_info { |
---|
106 | TRWindow *window; |
---|
107 | int running; |
---|
108 | }; |
---|
109 | |
---|
110 | struct update_info { |
---|
111 | TRWindow *window; |
---|
112 | bool running; |
---|
113 | int selected; |
---|
114 | int invalid; |
---|
115 | }; |
---|
116 | |
---|
117 | #endif /* TR_WIND */ |
---|