Correct support for multiply clients
[qtrapids] / src / server / TorrentSession.cpp
index 6158452..531cd83 100644 (file)
@@ -58,7 +58,7 @@ namespace qtrapids
                 TorrentState state;
 
                 state.hash = Hash2QStr(handle.hash());
-                state.is_new = false;
+                state.action = TorrentState::action_update;
                 state.state = handle.state();
                 state.progress = handle.progress() * torrent_progress_max;
                 state.down_rate = handle.downloadRate();
@@ -83,7 +83,7 @@ namespace qtrapids
             
             state.hash = hash;
             state.name = handle->name();
-            state.is_new = true;
+            state.action = TorrentState::action_add;
             state.state = handle->state();
             state.progress = handle->progress() * torrent_progress_max;
             state.down_rate = handle->downloadRate();
@@ -123,7 +123,7 @@ namespace qtrapids
 
         state.hash = hash;
         state.name = handle->name();
-        state.is_new = true;
+        state.action = TorrentState::action_add;
         state.state = handle->state();
         state.progress = handle->progress() * torrent_progress_max;
         state.down_rate = handle->downloadRate();
@@ -140,6 +140,7 @@ namespace qtrapids
     void TorrentSession::removeTorrent(const QString &hash)
     {
         torrents_t::iterator p = torrents_.find(hash);
+           
         if (p == torrents_.end()) {
             qDebug() << "Invalid request to remove torrent with hash " << hash;
             return;
@@ -151,6 +152,12 @@ namespace qtrapids
                 "exception catched"
                 ;
         }
+
+        TorrentState state;
+        state.hash = hash;
+        state.action = TorrentState::action_remove;
+        emit alert(state, ParamsMap_t());
+        torrents_.erase(p);
     }