Correct support for multiply clients
[qtrapids] / src / include / qtrapids / dbus.hpp
index 433aa16..103c950 100644 (file)
@@ -13,6 +13,14 @@ namespace qtrapids
 
     struct TorrentState
     {
+
+        enum torrent_action
+        {
+            action_add,
+            action_remove,
+            action_update
+        };
+        
         TorrentState() 
             : hash("")
             , name("")
@@ -24,11 +32,11 @@ namespace qtrapids
             , leeches(0)
             , ratio(0)
             , total_size(0)
-        { }
+            { }
 
         QString hash;
         QString name;
-        bool is_new;
+        torrent_action action;
         uint state;
         uint progress;
         uint down_rate;
@@ -49,7 +57,7 @@ namespace qtrapids
     {
         std::cout << "serialize" << std::endl;
         argument.beginStructure();
-        argument << state.hash << state.name << state.is_new << state.state << state.progress 
+        argument << state.hash << state.name << (uint)(state.action) << state.state << state.progress 
                  << state.down_rate << state.up_rate << state.seeds
                  << state.leeches << state.ratio << state.total_size;
         argument.endStructure();
@@ -61,9 +69,11 @@ namespace qtrapids
     {
         std::cout << "deserialize" << std::endl;
         argument.beginStructure();
-        argument >> state.hash >> state.name >> state.is_new >> state.state >> state.progress 
+        uint action;
+        argument >> state.hash >> state.name >> action >> state.state >> state.progress 
                  >> state.down_rate >> state.up_rate >> state.seeds
                  >> state.leeches >> state.ratio >> state.total_size;
+        state.action = (TorrentState::torrent_action)action;
         argument.endStructure();
         return argument;
     }