From 60794bc7fa63989340bbc0c351b50d6091f07a4b Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sun, 24 Jan 2010 19:53:05 +0000 Subject: [PATCH] Upstream tarball 9974 --- .svn-revision | 2 +- src/ECSpecialCoreTags.cpp | 12 ++++++++--- src/PartFile.h | 2 +- src/amule-remote-gui.cpp | 37 +++++++++++++++++++++++++++------- src/libs/ec/abstracts/ECCodes.abstract | 1 + src/libs/ec/c#/ECCodes.cs | 1 + src/libs/ec/cpp/ECCodes.h | 2 ++ src/libs/ec/cpp/ECSpecialTags.h | 10 +++++++-- src/libs/ec/java/ECCodes.java | 1 + src/remote-gui.net/ECCodes.cs | 1 + 10 files changed, 55 insertions(+), 14 deletions(-) diff --git a/.svn-revision b/.svn-revision index 49df05f6..dd54067a 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -9973 +9974 diff --git a/src/ECSpecialCoreTags.cpp b/src/ECSpecialCoreTags.cpp index 3581861f..83fd9bd3 100644 --- a/src/ECSpecialCoreTags.cpp +++ b/src/ECSpecialCoreTags.cpp @@ -125,7 +125,8 @@ CEC_ConnState_Tag::CEC_ConnState_Tag(EC_DETAIL_LEVEL detail_level) : CECTag(EC_T void CEC_PartFile_Tag::Detail_Tag(CPartFile *file, CValueMap *valuemap) { // Tag for source names - CECTag sn(EC_TAG_PARTFILE_SOURCE_NAMES, (uint64) 0); + CECEmptyTag sn(EC_TAG_PARTFILE_SOURCE_NAMES); + CECEmptyTag snc(EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS); SourcenameItemList sil; const CPartFile::SourceSet &sources = file->GetSourceList(); for (CPartFile::SourceSet::const_iterator it = sources.begin(); it != sources.end(); ++it) { @@ -149,9 +150,14 @@ void CEC_PartFile_Tag::Detail_Tag(CPartFile *file, CValueMap *valuemap) for (SourcenameItemList::const_iterator its = sil.begin() ; its != sil.end(); ++its ) { // Tag children are evaluated by index, not by name sn.AddTag(CECTag(EC_TAG_PARTFILE_SOURCE_NAMES, its->name)); - sn.AddTag(CECTag(EC_TAG_PARTFILE_SOURCE_NAMES, (uint64) its->count)); + snc.AddTag(CECTag(EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS, (uint64) its->count)); } - AddTag(sn, valuemap); + if (AddTag(sn, valuemap) && valuemap) { + // If there was a change in the list of names, + // make sure that the counts are updated too. + valuemap->ForgetTag(EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS); + } + AddTag(snc, valuemap); } CEC_PartFile_Tag::CEC_PartFile_Tag(CPartFile *file, EC_DETAIL_LEVEL detail_level, bool detail, CValueMap *valuemap) diff --git a/src/PartFile.h b/src/PartFile.h index 1ce629c4..1886517a 100644 --- a/src/PartFile.h +++ b/src/PartFile.h @@ -404,7 +404,7 @@ private: uint8 m_iDownPriorityEC; SourcenameItemList m_SourcenameItem_list; public: - const SourcenameItemList &GetSourcenameItemList() { return m_SourcenameItem_list; } + SourcenameItemList &GetSourcenameItemList() { return m_SourcenameItem_list; } void ClearSourcenameItemList() { m_SourcenameItem_list.clear(); } void AddSourcenameItemList(const wxString &name, long count) { m_SourcenameItem_list.push_back(SourcenameItem(name, count)); } #endif diff --git a/src/amule-remote-gui.cpp b/src/amule-remote-gui.cpp index c8585f9a..ae0ce05f 100644 --- a/src/amule-remote-gui.cpp +++ b/src/amule-remote-gui.cpp @@ -1431,15 +1431,38 @@ void CDownQueueRem::ProcessItemUpdate(CEC_PartFile_Tag *tag, CPartFile *file) AddLogLineNS(CFormat(wxT("ERROR: %X %X %X")) % (size_t)gaptag % (size_t)parttag % (size_t)reqtag); } - // Get source names + // Get source names and counts CECTag *srcnametag = tag->GetTagByName(EC_TAG_PARTFILE_SOURCE_NAMES); + CECTag *srccounttag = tag->GetTagByName(EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS); + // Full update (names and counts) if (srcnametag) { - file->ClearSourcenameItemList(); - int max = srcnametag->GetTagCount(); - for (int i = 0; i < max - 1; ) { - wxString name = srcnametag->GetTagByIndex(i++)->GetStringData(); - long count = srcnametag->GetTagByIndex(i++)->GetInt(); - file->AddSourcenameItemList(name, count); + size_t max = srcnametag->GetTagCount(); + // Some sanity checks (this shouldn't go wrong) + if (!srccounttag) { + AddLogLineN(wxT("Source names missing counts - too old core ?")); + } else if (srccounttag->GetTagCount() != max) { + AddLogLineN(CFormat(wxT("%d source names and %d source counts - should not happen.")) + % max % srccounttag->GetTagCount()); + } else { + file->ClearSourcenameItemList(); + for (size_t i = 0; i < max; i++) { + wxString name = srcnametag->GetTagByIndex(i)->GetStringData(); + long count = srccounttag->GetTagByIndex(i)->GetInt(); + file->AddSourcenameItemList(name, count); + } + } + // Only counts updated + } else if (srccounttag) { + size_t max = srccounttag->GetTagCount(); + SourcenameItemList &list = file->GetSourcenameItemList(); + if (list.size() != max) { + AddLogLineN(CFormat(wxT("%d source items and %d source counts - should not happen.")) + % list.size() % max); + } else { + SourcenameItemList::iterator it = list.begin(); + for (size_t i = 0; i < max; i++, it++) { + it->count = srccounttag->GetTagByIndex(i)->GetInt(); + } } } diff --git a/src/libs/ec/abstracts/ECCodes.abstract b/src/libs/ec/abstracts/ECCodes.abstract index fe8db625..5e4e5615 100644 --- a/src/libs/ec/abstracts/ECCodes.abstract +++ b/src/libs/ec/abstracts/ECCodes.abstract @@ -219,6 +219,7 @@ EC_TAG_PARTFILE 0x0300 EC_TAG_PARTFILE_LOST_CORRUPTION 0x0319 EC_TAG_PARTFILE_GAINED_COMPRESSION 0x031A EC_TAG_PARTFILE_SAVED_ICH 0x031B + EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS 0x031C EC_TAG_KNOWNFILE 0x0400 EC_TAG_KNOWNFILE_XFERRED 0x0401 diff --git a/src/libs/ec/c#/ECCodes.cs b/src/libs/ec/c#/ECCodes.cs index 1c70d935..e8e66202 100644 --- a/src/libs/ec/c#/ECCodes.cs +++ b/src/libs/ec/c#/ECCodes.cs @@ -187,6 +187,7 @@ public enum ECTagNames { EC_TAG_PARTFILE_LOST_CORRUPTION = 0x0319, EC_TAG_PARTFILE_GAINED_COMPRESSION = 0x031A, EC_TAG_PARTFILE_SAVED_ICH = 0x031B, + EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS = 0x031C, EC_TAG_KNOWNFILE = 0x0400, EC_TAG_KNOWNFILE_XFERRED = 0x0401, EC_TAG_KNOWNFILE_XFERRED_ALL = 0x0402, diff --git a/src/libs/ec/cpp/ECCodes.h b/src/libs/ec/cpp/ECCodes.h index 45aebbbd..a6765119 100644 --- a/src/libs/ec/cpp/ECCodes.h +++ b/src/libs/ec/cpp/ECCodes.h @@ -196,6 +196,7 @@ enum ECTagNames { EC_TAG_PARTFILE_LOST_CORRUPTION = 0x0319, EC_TAG_PARTFILE_GAINED_COMPRESSION = 0x031A, EC_TAG_PARTFILE_SAVED_ICH = 0x031B, + EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS = 0x031C, EC_TAG_KNOWNFILE = 0x0400, EC_TAG_KNOWNFILE_XFERRED = 0x0401, EC_TAG_KNOWNFILE_XFERRED_ALL = 0x0402, @@ -594,6 +595,7 @@ wxString GetDebugNameECTagNames(uint16 arg) case 0x0319: return wxT("EC_TAG_PARTFILE_LOST_CORRUPTION"); case 0x031A: return wxT("EC_TAG_PARTFILE_GAINED_COMPRESSION"); case 0x031B: return wxT("EC_TAG_PARTFILE_SAVED_ICH"); + case 0x031C: return wxT("EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS"); case 0x0400: return wxT("EC_TAG_KNOWNFILE"); case 0x0401: return wxT("EC_TAG_KNOWNFILE_XFERRED"); case 0x0402: return wxT("EC_TAG_KNOWNFILE_XFERRED_ALL"); diff --git a/src/libs/ec/cpp/ECSpecialTags.h b/src/libs/ec/cpp/ECSpecialTags.h index 1c33c222..965243de 100644 --- a/src/libs/ec/cpp/ECSpecialTags.h +++ b/src/libs/ec/cpp/ECSpecialTags.h @@ -123,14 +123,20 @@ class CValueMap { bool AddTag(const CECTag &tag, CECTag *parent) { - bool ret = true; + bool ret = false; ec_tagname_t tagname = tag.GetTagName(); if (m_map_tag.count(tagname) == 0 || m_map_tag[tagname] != tag) { - ret = parent->AddTag(tag); + parent->AddTag(tag); m_map_tag[tagname] = tag; + ret = true; } return ret; } + + void ForgetTag(ec_tagname_t tagname) + { + m_map_tag.erase(tagname); + } }; class CEC_Category_Tag : public CECTag { diff --git a/src/libs/ec/java/ECCodes.java b/src/libs/ec/java/ECCodes.java index c0242b7f..bd018d96 100644 --- a/src/libs/ec/java/ECCodes.java +++ b/src/libs/ec/java/ECCodes.java @@ -184,6 +184,7 @@ public final static short EC_TAG_PARTFILE_DOWNLOAD_ACTIVE = 0x0318; public final static short EC_TAG_PARTFILE_LOST_CORRUPTION = 0x0319; public final static short EC_TAG_PARTFILE_GAINED_COMPRESSION = 0x031A; public final static short EC_TAG_PARTFILE_SAVED_ICH = 0x031B; +public final static short EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS = 0x031C; public final static short EC_TAG_KNOWNFILE = 0x0400; public final static short EC_TAG_KNOWNFILE_XFERRED = 0x0401; public final static short EC_TAG_KNOWNFILE_XFERRED_ALL = 0x0402; diff --git a/src/remote-gui.net/ECCodes.cs b/src/remote-gui.net/ECCodes.cs index 1c70d935..e8e66202 100644 --- a/src/remote-gui.net/ECCodes.cs +++ b/src/remote-gui.net/ECCodes.cs @@ -187,6 +187,7 @@ public enum ECTagNames { EC_TAG_PARTFILE_LOST_CORRUPTION = 0x0319, EC_TAG_PARTFILE_GAINED_COMPRESSION = 0x031A, EC_TAG_PARTFILE_SAVED_ICH = 0x031B, + EC_TAG_PARTFILE_SOURCE_NAMES_COUNTS = 0x031C, EC_TAG_KNOWNFILE = 0x0400, EC_TAG_KNOWNFILE_XFERRED = 0x0401, EC_TAG_KNOWNFILE_XFERRED_ALL = 0x0402, -- 2.11.4.GIT