Client-server through DBus, cmake support
[qtrapids] / src / server / TorrentSession.hpp
diff --git a/src/server/TorrentSession.hpp b/src/server/TorrentSession.hpp
new file mode 100644 (file)
index 0000000..76b11f2
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _TEST_HPP_
+#define _TEST_HPP_
+
+#include "TorrentHandle.hpp"
+#include "server.h"
+
+#include <QObject>
+#include <QString>
+#include <QSharedPointer>
+#include <QWeakPointer>
+
+#include <qtrapids/dbus.hpp>
+
+#include <libtorrent/session.hpp>
+#include <libtorrent/torrent_info.hpp>
+#include <libtorrent/alert_types.hpp>
+#include <libtorrent/error_code.hpp>
+
+class QSettings;
+
+namespace qtrapids
+{
+
+    typedef QWeakPointer<QSettings> settings_weak_ptr;
+
+    class AlertWaiterThread;
+    typedef libtorrent::session session_t;
+    typedef libtorrent::session const* session_cptr;
+
+    typedef libtorrent::add_torrent_params add_torrent_params_t;
+    typedef libtorrent::alert alert_t;
+    //    typedef libtorrent::alert const* alert_cptr;
+    typedef    libtorrent::torrent_alert torrent_alert_t;
+    typedef libtorrent::libtorrent_exception torrent_exception_t;
+
+    typedef QSharedPointer<TorrentHandle> TorrentHandlePtr;
+    typedef QHash<QString, TorrentHandlePtr > torrents_t;
+
+    class ServerDb;
+    class ServerSettings;
+
+    class TorrentSession : public QObject
+    {
+
+        Q_OBJECT;
+        Q_CLASSINFO("D-Bus Interface", "com.ixonos.qtrapids");
+
+    public:
+
+        TorrentSession(QObject *parent, QSettings *);
+
+    public slots:
+
+        void getState();
+        void addTorrent(const QString &path, const QString &save_path
+                        , qtrapids::ParamsMap_t other_params);
+        void removeTorrent(const QString &hash);
+
+    signals:
+        void alert(qtrapids::TorrentState info, qtrapids::ParamsMap_t other_info);
+
+    private slots:
+               void on_alert();
+
+    private:
+        session_t btSession_;
+               AlertWaiterThread *alertWaiter_;
+               torrents_t torrents_;
+    };
+
+} // namespace qtrapids
+
+#endif // _TEST_HPP_