is_new attribute added to the torrent state information
authordeztructor <denis.zalewsky@gmail.com>
Tue, 17 Nov 2009 13:13:13 +0000 (13:13 +0000)
committerdeztructor <denis.zalewsky@gmail.com>
Tue, 17 Nov 2009 13:13:13 +0000 (13:13 +0000)
This attribute is the boolean value, server to inform client it has not
notified client about this torrent yet to avoid information flow
synchronization issues

git-svn-id: file:///svnroot/qtrapids/trunk@27 42ac0dd5-4c8c-4c71-bb3e-ecdfe252ffda

dbus/com.ixonos.qtrapids.xml
src/client/DownloadView.cpp
src/include/qtrapids/dbus.hpp
src/server/TorrentSession.cpp

index 92f5702..c4fdd90 100644 (file)
@@ -20,7 +20,7 @@
     </method>
 
     <signal name="alert">
-      <arg type="(ssuuuuuuut)" name="info" direction="out"/>
+      <arg type="(ssbuuuuuuut)" name="info" direction="out"/>
       <annotation name="com.trolltech.QtDBus.QtTypeName.In0" 
                   value="qtrapids::TorrentState"/>
       <arg type="a{ss}" name="other_info" direction="out"/>
index d2201db..5aecc86 100644 (file)
@@ -49,8 +49,15 @@ namespace qtrapids
     {
         DownloadItems_t::iterator p = items_.find(info.hash);
         if (p != items_.end()) {
+            if (info.is_new) {
+                qWarning() << "item with similar info hash marked as new";
+            }
             updateItem_(p.value(), info, other_info);
         } else {
+            if (!info.is_new) {
+                qDebug() << "torrent info arrived but there is no torrent for it";
+                return;
+            }
             addItem_(info, other_info);
         }
     }
index 52681d4..433aa16 100644 (file)
@@ -28,6 +28,7 @@ namespace qtrapids
 
         QString hash;
         QString name;
+        bool is_new;
         uint state;
         uint progress;
         uint down_rate;
@@ -48,7 +49,7 @@ namespace qtrapids
     {
         std::cout << "serialize" << std::endl;
         argument.beginStructure();
-        argument << state.hash << state.name << state.state << state.progress 
+        argument << state.hash << state.name << state.is_new << state.state << state.progress 
                  << state.down_rate << state.up_rate << state.seeds
                  << state.leeches << state.ratio << state.total_size;
         argument.endStructure();
@@ -60,7 +61,7 @@ namespace qtrapids
     {
         std::cout << "deserialize" << std::endl;
         argument.beginStructure();
-        argument >> state.hash >> state.name >> state.state >> state.progress 
+        argument >> state.hash >> state.name >> state.is_new >> state.state >> state.progress 
                  >> state.down_rate >> state.up_rate >> state.seeds
                  >> state.leeches >> state.ratio >> state.total_size;
         argument.endStructure();
index aa1f105..6158452 100644 (file)
@@ -58,6 +58,7 @@ namespace qtrapids
                 TorrentState state;
 
                 state.hash = Hash2QStr(handle.hash());
+                state.is_new = false;
                 state.state = handle.state();
                 state.progress = handle.progress() * torrent_progress_max;
                 state.down_rate = handle.downloadRate();
@@ -82,6 +83,7 @@ namespace qtrapids
             
             state.hash = hash;
             state.name = handle->name();
+            state.is_new = true;
             state.state = handle->state();
             state.progress = handle->progress() * torrent_progress_max;
             state.down_rate = handle->downloadRate();
@@ -121,6 +123,7 @@ namespace qtrapids
 
         state.hash = hash;
         state.name = handle->name();
+        state.is_new = true;
         state.state = handle->state();
         state.progress = handle->progress() * torrent_progress_max;
         state.down_rate = handle->downloadRate();