alerting race condition fix
[qtrapids] / src / server / TorrentSession.hpp
1 #ifndef _TEST_HPP_
2 #define _TEST_HPP_
3
4 #include "TorrentHandle.hpp"
5 #include "server.h"
6
7 #include <QObject>
8 #include <QString>
9 #include <QSharedPointer>
10 #include <QWeakPointer>
11
12 #include <qtrapids/dbus.hpp>
13
14 #include <libtorrent/session.hpp>
15 #include <libtorrent/torrent_info.hpp>
16 #include <libtorrent/alert_types.hpp>
17 #include <libtorrent/error_code.hpp>
18
19 class QSettings;
20
21 namespace qtrapids
22 {
23
24     typedef QWeakPointer<QSettings> settings_weak_ptr;
25
26     class AlertWaiterThread;
27     typedef libtorrent::session session_t;
28     typedef libtorrent::session const* session_cptr;
29
30     typedef libtorrent::add_torrent_params add_torrent_params_t;
31     typedef libtorrent::alert alert_t;
32     //    typedef libtorrent::alert const* alert_cptr;
33     typedef     libtorrent::torrent_alert torrent_alert_t;
34     typedef libtorrent::libtorrent_exception torrent_exception_t;
35
36     typedef QSharedPointer<TorrentHandle> TorrentHandlePtr;
37     typedef QHash<QString, TorrentHandlePtr > torrents_t;
38
39     class ServerDb;
40     class ServerSettings;
41
42     class TorrentSession : public QObject
43     {
44
45         Q_OBJECT;
46         Q_CLASSINFO("D-Bus Interface", "com.ixonos.qtrapids");
47
48     public:
49
50         TorrentSession(QObject *parent, QSettings *);
51
52     public slots:
53
54         void getState();
55         void addTorrent(const QString &path, const QString &save_path
56                         , qtrapids::ParamsMap_t other_params);
57         void removeTorrent(const QString &hash);
58
59     signals:
60         void alert(qtrapids::TorrentState info, qtrapids::ParamsMap_t other_info);
61
62     private slots:
63                 void on_alert();
64
65     private:
66         session_t btSession_;
67                 AlertWaiterThread *alertWaiter_;
68                 torrents_t torrents_;
69     };
70
71 } // namespace qtrapids
72
73 #endif // _TEST_HPP_