From 5fff20c40f52af8641f4139e48de74db40d43ca8 Mon Sep 17 00:00:00 2001 From: deztructor Date: Tue, 17 Nov 2009 13:13:13 +0000 Subject: [PATCH] is_new attribute added to the torrent state information 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 | 2 +- src/client/DownloadView.cpp | 7 +++++++ src/include/qtrapids/dbus.hpp | 5 +++-- src/server/TorrentSession.cpp | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dbus/com.ixonos.qtrapids.xml b/dbus/com.ixonos.qtrapids.xml index 92f5702..c4fdd90 100644 --- a/dbus/com.ixonos.qtrapids.xml +++ b/dbus/com.ixonos.qtrapids.xml @@ -20,7 +20,7 @@ - + diff --git a/src/client/DownloadView.cpp b/src/client/DownloadView.cpp index d2201db..5aecc86 100644 --- a/src/client/DownloadView.cpp +++ b/src/client/DownloadView.cpp @@ -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); } } diff --git a/src/include/qtrapids/dbus.hpp b/src/include/qtrapids/dbus.hpp index 52681d4..433aa16 100644 --- a/src/include/qtrapids/dbus.hpp +++ b/src/include/qtrapids/dbus.hpp @@ -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(); diff --git a/src/server/TorrentSession.cpp b/src/server/TorrentSession.cpp index aa1f105..6158452 100644 --- a/src/server/TorrentSession.cpp +++ b/src/server/TorrentSession.cpp @@ -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(); -- 1.7.9.5