1 /***************************************************************************
2 * Copyright (C) 2010 by Ixonos Plc *
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. *
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. *
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 ***************************************************************************/
21 #include "TorrentHandle.hpp"
26 #include <QSharedPointer>
27 #include <QWeakPointer>
29 #include <qtrapids/dbus.hpp>
31 #include <libtorrent/session.hpp>
32 #include <libtorrent/torrent_info.hpp>
33 #include <libtorrent/alert_types.hpp>
34 #include <libtorrent/error_code.hpp>
43 typedef QWeakPointer<QSettings> settings_weak_ptr;
45 class AlertWaiterThread;
46 typedef libtorrent::session session_t;
47 typedef libtorrent::session const* session_cptr;
48 typedef libtorrent::session_settings session_settings_t;
50 typedef libtorrent::add_torrent_params add_torrent_params_t;
51 typedef libtorrent::alert alert_t;
52 // typedef libtorrent::alert const* alert_cptr;
53 typedef libtorrent::torrent_alert torrent_alert_t;
54 typedef libtorrent::libtorrent_exception torrent_exception_t;
56 typedef QSharedPointer<TorrentHandle> TorrentHandlePtr;
57 typedef QHash<QString, TorrentHandlePtr > torrents_t;
58 typedef std::pair<int, int> ports_range_t;
63 class TorrentSession : public QObject
67 Q_CLASSINFO("D-Bus Interface", "com.ixonos.qtrapids");
70 TorrentSession(QObject *parent, QSettings *);
71 virtual ~TorrentSession();
75 void addTorrent(const QString &path, const QString &save_path
76 , qtrapids::ParamsMap_t other_params);
77 void removeTorrent(const QString &hash);
78 void setOptions(qtrapids::ParamsMap_t options);
79 qtrapids::ParamsMap_t getOptions();
80 void terminateSession();
83 void alert(qtrapids::TorrentState info, qtrapids::ParamsMap_t other_info);
85 void sessionTerminated();
93 void addTorrent_(const QString &, const QString &, const qtrapids::ParamsMap_t &, bool);
96 AlertWaiterThread *alertWaiter_;
98 std::auto_ptr<ServerSettings> settings_;
99 std::auto_ptr<ServerDb> db_;
102 } // namespace qtrapids