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