Server methods to store/get options
[qtrapids] / src / server / TorrentSession.hpp
index 85a8c3f..4f56050 100644 (file)
@@ -16,6 +16,8 @@
 #include <libtorrent/alert_types.hpp>
 #include <libtorrent/error_code.hpp>
 
+#include <utility>
+
 class QSettings;
 
 namespace qtrapids
@@ -35,6 +37,7 @@ typedef libtorrent::libtorrent_exception torrent_exception_t;
 
 typedef QSharedPointer<TorrentHandle> TorrentHandlePtr;
 typedef QHash<QString, TorrentHandlePtr > torrents_t;
+typedef std::pair<int, int> ports_range_t;
 
 class ServerDb;
 class ServerSettings;
@@ -42,30 +45,38 @@ class ServerSettings;
 class TorrentSession : public QObject
 {
 
-    Q_OBJECT;
-    Q_CLASSINFO("D-Bus Interface", "com.ixonos.qtrapids");
+       Q_OBJECT;
+       Q_CLASSINFO("D-Bus Interface", "com.ixonos.qtrapids");
 
 public:
 
-    TorrentSession(QObject *parent, QSettings *);
+       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);
+       void getState();
+       void addTorrent(const QString &path, const QString &save_path
+                       , qtrapids::ParamsMap_t other_params);
+       void removeTorrent(const QString &hash);
+       void setOptions(qtrapids::ParamsMap_t options);
+       qtrapids::ParamsMap_t getOptions();
 
 signals:
-    void alert(qtrapids::TorrentState info, qtrapids::ParamsMap_t other_info);
+       void alert(qtrapids::TorrentState info, qtrapids::ParamsMap_t other_info);
 
 private slots:
-    void on_alert();
+       void on_alert();
 
 private:
-    session_t btSession_;
-    AlertWaiterThread *alertWaiter_;
-    torrents_t torrents_;
+
+       void loadState();
+       void addTorrent_(const QString &, const QString &, const qtrapids::ParamsMap_t &, bool);
+
+       session_t btSession_;
+       AlertWaiterThread *alertWaiter_;
+       torrents_t torrents_;
+       std::auto_ptr<ServerSettings> settings_;
+       std::auto_ptr<ServerDb> db_;
 };
 
 } // namespace qtrapids