- Fixes: Restoring download rate setting on startup. Rate setting spinbox initial...
[qtrapids] / src / engine / QBittorrentSession.cpp
index 2ab40ed..0f0e67e 100644 (file)
@@ -23,8 +23,9 @@
 #include "AlertWaiterThread.h"
 #include "QBittorrentSession.h"
 
-namespace qtrapids {
-       
+namespace qtrapids
+{
+
 QBittorrentSession::QBittorrentSession(QObject *parent):
                QObject(parent),
                btSession_(),
@@ -34,6 +35,11 @@ QBittorrentSession::QBittorrentSession(QObject *parent):
        alertWaiter_->allAlerts();
        connect(alertWaiter_, SIGNAL(alert(Alert const*)), this, SLOT(on_alert(Alert const*)));
        alertWaiter_->start();
+       
+       SessionSettings settings;
+       settings.ignore_limits_on_local_network = false;
+       btSession_.set_settings(settings);
+       
 }
 
 
@@ -52,22 +58,49 @@ QBittorrentSession::addTorrent(AddTorrentParams const& params)
 }
 
 
-void QBittorrentSession::removeTorrent(qtrapids::QTorrentHandle const& handle) 
+void QBittorrentSession::removeTorrent(qtrapids::QTorrentHandle const& handle)
 {
        btSession_.remove_torrent(handle.getHandle());
 }
 
 
+void QBittorrentSession::setUploadRateLimit(int rate)
+{
+       btSession_.set_upload_rate_limit(rate);
+}
+
+
+void QBittorrentSession::setDownloadRateLimit(int rate)
+{
+       btSession_.set_download_rate_limit(rate);
+}
+
+
+int QBittorrentSession::getUploadRateLimt() const
+{
+       return btSession_.upload_rate_limit();
+}
+
+
+int QBittorrentSession::getDownloadRateLimit() const
+{
+       return btSession_.download_rate_limit();
+}
+
+
+
+
+
 // ========================== SLOTS ==============================
 /// @TODO This function is called when AlertWaiterThread emits alert()
 /// If connection is direct, as it is now, we need to use QMutex here (if necessary?)
-void QBittorrentSession::on_alert(Alert const *al) 
-               //NOTE: al parameter not necessarily needed here, as we pop_alert() now!
+void QBittorrentSession::on_alert(Alert const *al)
+//NOTE: al parameter not necessarily needed here, as we pop_alert() now!
 {
-       
+
 #ifdef QTRAPIDS_DEBUG
-       if (al)
-               qDebug() << "on_alert():" << QString::fromStdString(al->message());
+       //if (al)
+       //      qDebug() << "on_alert():" << QString::fromStdString(al->message());
 #endif
 
        std::auto_ptr<Alert> alertPtr = btSession_.pop_alert();