-Added QTorrentHandle and started torrent adding implementation
[qtrapids] / src / engine / QBittorrentSession.cpp
index 34198c8..4cefcec 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
+#include <QDebug>
+
+#include "AlertWaiterThread.h"
 #include "QBittorrentSession.h"
 
-QBittorrentSession::QBittorrentSession()
+
+QBittorrentSession::QBittorrentSession(QObject *parent):
+               QObject(parent),
+               btSession_(),
+               alertWaiter_(NULL)
 {
+       alertWaiter_ = new AlertWaiterThread(&btSession_, this);
+       connect(alertWaiter_, SIGNAL(alert(TorrentAlert const*)), this, SLOT(on_alert(TorrentAlert const*)));
+       alertWaiter_->start();
 }
 
 
@@ -29,3 +40,19 @@ QBittorrentSession::~QBittorrentSession()
 }
 
 
+QTorrentHandle QBittorrentSession::addTorrent(AddTorrentParams const& params)
+{
+       // Delegate to Libtorrent and return QTorrentHandle.
+       QTorrentHandle handle(btSession_.add_torrent(params));
+       return handle;
+}
+
+
+// ========================== SLOTS ==============================
+void QBittorrentSession::on_alert(TorrentAlert const *al)
+{
+       qDebug() << "QBittorrentSession:on_alert(" << al << ")";
+       emit alert(al);
+}
+
+