~vcs-imports/lince/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/***************************************************************************
 *            NoteBook.h
 *
 *  Sat Feb 17 22:11:07 2007
 *  Copyright  2007  Fernando TarĂ­n Morales
 *  icemanf@gmail.com
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

#ifndef _NOTEBOOK_H
#define _NOTEBOOK_H

#include <gtkmm.h>

#include "libtorrent/session.hpp"

#include "Notifications.h"
#include "TorrentsTab.h"
#include "OptionsTab.h"
#include "StatisticsTab.h"
#include "TorrentInfoTab.h"
#include "LogTab.h"
#include "SearchTab.h"
#include "Utils.h"

#include "Lince/Torrent.h"
#include "Lince/TorrentsManager.h"

class MainWindow;
class MenuBar;

#if HAVE_LIBNOTIFY
class Notifications;
#endif

typedef std::list<TorrentInfoTab> TorrentsInfoTab;

class NoteBookManager: public Gtk::Notebook{
	private:
		class TorrentsTab TT;
		class OptionsTab OT;
		class StatisticsTab ST;
		class LogTab LT;
		class SearchTab SChT;
		TorrentsInfoTab TIT;

		class MenuBar *menuBar;
#if HAVE_LIBNOTIFY
		class Notifications *notifications;
#endif

		int last_page;
		std::vector<int> page_positions;

		void updatePagePositions(int value);
		void on_my_switch_page(Gtk::Widget*, guint);
		bool isInfoTabListed(const libtorrent::sha1_hash &, TorrentsInfoTab::iterator &);

	public:
#if HAVE_LIBNOTIFY
		NoteBookManager(MainWindow *, MenuBar *, Notifications *);
#else
		NoteBookManager(MainWindow *, MenuBar *);
#endif

		~NoteBookManager();

		enum TabsPositions { FIRST_TAB, TORRENTS_TAB=FIRST_TAB, OPTIONS_TAB, STATISTICS_TAB, LOG_TAB, SEARCH_TAB, LAST_TAB };

		void setActivePage(int page) { set_current_page(page_positions[page]); };
		void getSelectedTabName(Glib::ustring &);
		void removeCurrentTab();
		int getActivePage();
		bool isTorrentsTabSelected();
		bool isTorrentsInfoTabSelected();

		// TorrentsTab
		void addTorrentsTab(void);
		void removeTorrentsTab(void);
		void clearTorrentsList() { TT.clearTorrentsList(); };
		void updateDownloadingTorrents() { TT.updateDownloadingTorrents(); };
		void updateDownloadedTorrents() { TT.updateDownloadedTorrents(); };
		void addTorrent(Lince::Torrent *t) { TT.addTorrent(t); TT.autoSizeDownloadingTorrentsColumns(); };
		void addFinshedTorrent(Lince::Torrent *t) { TT.addFinishedTorrent(t); TT.autoSizeDownloadedTorrentsColumns();};
		void removeDownloadingRowGivenTID(int tId) { TT.removeDownloadingRowGivenTID(tId); TT.autoSizeDownloadingTorrentsColumns(); };
		void removeDownloadedRowGivenTID(int tId) { TT.removeDownloadedRowGivenTID(tId); TT.autoSizeDownloadedTorrentsColumns(); };
		void setSelectedDownloadingRow(int tId) { TT.setSelectedDownloadingRow(tId); };
		void setSelectedDownloadedRow(int tId) { TT.setSelectedDownloadedRow(tId); };
		void setTorrentsTabPaneSeparatorPosition(int position) { TT.setPaneSeparatorPosition(position); };

		int getTorrentsTabPaneSeparatorPosition() { return TT.getPaneSeparatorPosition(); };
		int getDownloadingSelectedRow() { return TT.getDownloadingSelectedRow(); };
		int getDownloadedSelectedRow() { return TT.getDownloadedSelectedRow(); };
		int getDownloadingSelectedTorrents(void) { return TT.getDownloadingSelectedTorrents(); };
		Lince::torrentPosition getSelectedTorrentPosition(void) { return TT.getSelectedTorrentPosition(); };
		std::vector<Lince::torrentPosition> getSelectedTorrentsPositions(void) { return TT.getSelectedTorrentsPositions(); };

		bool isDownloadingSorted() { return TT.isDownloadingSorted(); };
		bool isDownloadedSorted() { return TT.isDownloadedSorted(); };
		bool isTorrentsTabShown(void) { return TT.isTabShown(); };

		// OptionsTab
		void addOptionsTab(void);
		void removeOptionsTab(void);
		void setOptionsGuiSetupManager(GuiSetupManager * gsm ) { OT.setGuiSetupManager(gsm); };
		void setOptionsFirstWindow(void) { OT.setConnectionWindow(); };
		void updateIpFilterData() { OT.updateIpFilterData(); };
		void setMaxConfigUploadSpeed(int value) { OT.setMaxConfigUploadSpeed(value); };
		void setMaxConfigDownloadSpeed(int value) { OT.setMaxConfigDownloadSpeed(value); };
		void setMaxConfigConnects(int value) { OT.setMaxConfigConnects(value); };
		void setMaxConfigUploadSlots(int value) { OT.setMaxConfigUploadSlots(value); };
		bool isOptionsTabShown(void) { return OT.isTabShown(); };

		// StatisticsTab
		void addStatisticsTab(void);
		void removeStatisticsTab(void);
		void showGraphStats(bool value) { ST.showGraphStats(value); };
		void updateGraphics(void) { ST.updateGraphics(); };
		void setMaxUploadSpeed(float speed) { ST.setMaxUploadSpeed(speed); };
		void setMaxDownloadSpeed(float speed) { ST.setMaxDownloadSpeed(speed); };
		void addCurrentUploadSpeed(float value) { ST.addCurrentUploadSpeed(value); };
		void addCurrentDownloadSpeed(float value) { ST.addCurrentDownloadSpeed(value); };
		void updateDownloadSpeed(float value) { ST.updateDownloadSpeed(value); };
		void updateDownloadSession(float value) { ST.updateDownloadSession(value); };
		void updateDownloadTotal(int64_t value) { ST.updateDownloadTotal(value); };
		void updateUploadSpeed(float value) { ST.updateUploadSpeed(value); };
		void updateUploadSession(float value) { ST.updateUploadSession(value); };
		void updateUploadTotal(int64_t value) { ST.updateUploadTotal(value); };
		void updateShareSession() { ST.updateShareSession(); };
		void updateShareTotal() { ST.updateShareTotal(); };
		void updateTimeSession(double value) { ST.updateTimeSession(value); };
		void updateTimeTotal(double value) { ST.updateTimeTotal(value); };
		void updateCurrentDownloadingSize(int64_t value) { ST.updateCurrentDownloadingSize(value); };
		void updateTotalDownloadingSize(int64_t value) { ST.updateTotalDownloadingSize(value); };
		void updateDownloadingRatio() { ST.updateDownloadingRatio(); };
		void updateTotalSharedSize(int64_t value) { ST.updateTotalSharedSize(value); };
		bool isStatisticsTabShown(void) { return ST.isTabShown(); };

		// LogTab
		void addLogTab(void);
		void removeLogTab(void);
		void setLogTabActive(bool value) { LT.setLogTabActive(value); };
		void setLogLevel(int value) { LT.setLogLevel(value); };
		void setMaxLogSize(int64_t value) { LT.setMaxLogSize(value); };
		void setLogSaveToFile(bool value) { LT.setSaveToFile(value); };
		void setLogColoredOutput(bool value) { LT.setColoredOutput(value); };
		void setLogAutoScroll(bool value) { LT.setAutoScroll(value); };
		void setFileName(const Glib::ustring & fname) { LT.setFileName(fname); };
		void flushLogMessages(void) { LT.flushMessages(); }
		bool isLogTabShown(void) { return LT.isTabShown(); };

		// Notifications
#if HAVE_LIBNOTIFY
		void setShowNotifications(bool value) { notifications->showNotifications(value); };
		void setNotifyMessage(int type, bool value) { notifications->setNotifyMessage(type, value); };
		void setNotifyFromSystray(bool value) { notifications->showNotificationsFromSystray(value); };
		void flushNotification(void) { notifications->flushNotification(); };
#endif

		// Search Tab
		void addSearchTab(void);
		void removeSearchTab(void);
		void setSearchSetupManager(GuiSetupManager * gsm ) { SChT.setGuiSetupManager(gsm); };
		bool isSearchTabShown(void) { return SChT.isTabShown(); };

		// TorrentsInfoTab
		void addTorrentInfoTab(Lince::Torrent *);
		void updateTorrentsInfoTab();
		void removeInfoTab(const libtorrent::sha1_hash &);
		bool isTorrentInfoTabShown(const libtorrent::sha1_hash &);

		// Bans management
		void banClient(Glib::ustring&, int);
		bool unbanClient(Glib::ustring &);

		Lince::torrentPosition getSelectedTorrentInfoTabPosition(void);

		//Gtk::Notebook * getNoteBook(void) { return &notebook; };
};

#endif /* _NOTEBOOK_H */