- License texts modified to GPLv2
[qtrapids] / src / engine / QBittorrentSession.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Ixonos Plc   *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; version 2 of the License.               *
7  *                                                                         *
8  *   This program is distributed in the hope that it will be useful,       *
9  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
10  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
11  *   GNU General Public License for more details.                          *
12  *                                                                         *
13  *   You should have received a copy of the GNU General Public License     *
14  *   along with this program; if not, write to the                         *
15  *   Free Software Foundation, Inc.,                                       *
16  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
17  ***************************************************************************/
18 #ifndef QBITTORRENTSESSION_H
19 #define QBITTORRENTSESSION_H
20
21 #include <memory>
22
23 #include <QObject>
24
25 #include <libtorrent/session.hpp>
26 #include <libtorrent/torrent_info.hpp>
27 #include <libtorrent/alert_types.hpp>
28
29 #include "QTorrentHandle.h"
30
31
32 // Forward declarations and typedefs
33 class AlertWaiterThread;
34 typedef libtorrent::session TorrentSession;
35 typedef libtorrent::session_settings SessionSettings;
36 typedef libtorrent::add_torrent_params AddTorrentParams;
37 typedef libtorrent::alert Alert;
38 typedef libtorrent::torrent_alert TorrentAlert;
39 typedef libtorrent::sha1_hash Sha1Hash;
40
41
42 namespace qtrapids
43 {
44
45 /**
46         @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
47 */
48 class QBittorrentSession : public QObject
49 {
50         Q_OBJECT
51 //              class   BitTorrentSession;
52
53 public:
54         QBittorrentSession(QObject *parent = 0);
55         ~QBittorrentSession();
56
57         /// @brief Add torrent to session.
58         qtrapids::QTorrentHandle addTorrent(AddTorrentParams const& params);
59         void removeTorrent(qtrapids::QTorrentHandle const& handle);
60
61         void setUploadRateLimit(int rate);
62         void setDownloadRateLimit(int rate);
63         int getUploadRateLimt() const;
64         int getDownloadRateLimit() const;
65         
66 signals:
67         void alert(std::auto_ptr<Alert> al);
68
69 private slots:
70         void on_alert(Alert const *al);
71
72 private:
73         TorrentSession btSession_;
74         AlertWaiterThread *alertWaiter_;
75
76 };
77
78 } //namespace qtrapids
79 #endif