From a8411c1263db4f5411b1b51358d4bf4b3faf6e29 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Mon, 15 Feb 2010 21:39:22 +0000 Subject: [PATCH] Upstream tarball 10018 --- .svn-revision | 2 +- MSVC Solution/aMule/aMule.vcproj | 4 +++ MSVC Solution/aMuleGUI/aMuleGUI.vcproj | 4 +++ MSVC Solution/libs/libmuleec/libmuleec.vcproj | 4 +++ src/ECSpecialCoreTags.cpp | 5 ++-- src/ExternalConn.cpp | 13 ++------ src/amule-remote-gui.cpp | 9 +++--- 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/ECID.h | 43 +++++++++++++++++++++++++++ src/libs/ec/cpp/ECSpecialTags.h | 5 ++-- src/libs/ec/cpp/ECTag.cpp | 4 +++ src/libs/ec/cpp/Makefile.am | 1 + src/libs/ec/cpp/Makefile.in | 1 + src/libs/ec/java/ECCodes.java | 1 + src/remote-gui.net/ECCodes.cs | 1 + src/updownclient.h | 3 +- 18 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 src/libs/ec/cpp/ECID.h diff --git a/.svn-revision b/.svn-revision index 896da6e1..7c83b39f 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10017 +10018 diff --git a/MSVC Solution/aMule/aMule.vcproj b/MSVC Solution/aMule/aMule.vcproj index 5ab8b159..9bed4470 100644 --- a/MSVC Solution/aMule/aMule.vcproj +++ b/MSVC Solution/aMule/aMule.vcproj @@ -1052,6 +1052,10 @@ > + + diff --git a/MSVC Solution/aMuleGUI/aMuleGUI.vcproj b/MSVC Solution/aMuleGUI/aMuleGUI.vcproj index c9904ae9..439f2688 100644 --- a/MSVC Solution/aMuleGUI/aMuleGUI.vcproj +++ b/MSVC Solution/aMuleGUI/aMuleGUI.vcproj @@ -772,6 +772,10 @@ > + + diff --git a/MSVC Solution/libs/libmuleec/libmuleec.vcproj b/MSVC Solution/libs/libmuleec/libmuleec.vcproj index b00a24c2..c9109b6d 100644 --- a/MSVC Solution/libs/libmuleec/libmuleec.vcproj +++ b/MSVC Solution/libs/libmuleec/libmuleec.vcproj @@ -314,6 +314,10 @@ > + + diff --git a/src/ECSpecialCoreTags.cpp b/src/ECSpecialCoreTags.cpp index 80df68db..fe588b17 100644 --- a/src/ECSpecialCoreTags.cpp +++ b/src/ECSpecialCoreTags.cpp @@ -212,12 +212,13 @@ CEC_SharedFile_Tag::CEC_SharedFile_Tag(const CKnownFile *file, EC_DETAIL_LEVEL d theApp->CreateED2kLink(file, (theApp->IsConnectedED2K() && !theApp->serverconnect->IsLowID())), valuemap); } -CEC_UpDownClient_Tag::CEC_UpDownClient_Tag(const CUpDownClient* client, EC_DETAIL_LEVEL detail_level, uint32 userID, CValueMap *valuemap) : - CECTag(EC_TAG_CLIENT, userID) +CEC_UpDownClient_Tag::CEC_UpDownClient_Tag(const CUpDownClient* client, EC_DETAIL_LEVEL detail_level, CValueMap *valuemap) : + CECTag(EC_TAG_CLIENT, client->ECID()) { // General AddTag(CECTag(EC_TAG_CLIENT_NAME, client->GetUserName()), valuemap); AddTag(CECTag(EC_TAG_CLIENT_HASH, client->GetUserHash()), valuemap); + AddTag(CECTag(EC_TAG_CLIENT_USER_ID, client->GetUserIDHybrid()), valuemap); AddTag(CECTag(EC_TAG_CLIENT_SCORE, client->GetScore(false, client->IsDownloading(), false)), valuemap); AddTag(CECTag(EC_TAG_CLIENT_RATING, client->GetRating()), valuemap); AddTag(CECTag(EC_TAG_CLIENT_SOFTWARE, client->GetClientSoft()), valuemap); diff --git a/src/ExternalConn.cpp b/src/ExternalConn.cpp index 828cd4a6..839a945b 100644 --- a/src/ExternalConn.cpp +++ b/src/ExternalConn.cpp @@ -513,8 +513,6 @@ static CECPacket *Get_EC_Response_GetClientQueue(const CECPacket *request, CObjT // (not for incremental update of course) CTagSet queryitems(request); - std::set idSet; - const CClientPtrList& clients = (op == EC_OP_WAIT_QUEUE) ? theApp->uploadqueue->GetWaitingList() : theApp->uploadqueue->GetUploadingList(); CClientPtrList::const_iterator it = clients.begin(); @@ -524,21 +522,14 @@ static CECPacket *Get_EC_Response_GetClientQueue(const CECPacket *request, CObjT if (!cur_client) { // shouldn't happen continue; } - // Sometimes clients can have the same ID. Make sure we transmit something unique. - uint32 id = cur_client->GetUserIDHybrid(); - while (idSet.count(id)) { - id++; - } - idSet.insert(id); - - if (!queryitems.empty() && !queryitems.count(id)) { + if (!queryitems.empty() && !queryitems.count(cur_client->ECID())) { continue; } CValueMap *valuemap = NULL; if (detail_level == EC_DETAIL_INC_UPDATE) { valuemap = &tagmap.GetValueMap(cur_client); } - CEC_UpDownClient_Tag cli_tag(cur_client, detail_level, id, valuemap); + CEC_UpDownClient_Tag cli_tag(cur_client, detail_level, valuemap); response->AddTag(cli_tag); } diff --git a/src/amule-remote-gui.cpp b/src/amule-remote-gui.cpp index ba72ec09..f2244e59 100644 --- a/src/amule-remote-gui.cpp +++ b/src/amule-remote-gui.cpp @@ -1061,10 +1061,10 @@ CRemoteContainer(conn, true) } -CUpDownClient::CUpDownClient(CEC_UpDownClient_Tag *tag) +CUpDownClient::CUpDownClient(CEC_UpDownClient_Tag *tag) : CECID(tag->ID()) { m_bRemoteQueueFull = false; - m_nUserIDHybrid = tag->ID(); + m_nUserIDHybrid = tag->UserID(); m_Username = tag->ClientName(); m_clientSoft = tag->ClientSoftware(); m_clientVersionString = GetSoftName(m_clientSoft); @@ -1083,7 +1083,7 @@ CUpDownClient::CUpDownClient(CEC_UpDownClient_Tag *tag) m_fullClientVerString = m_clientSoftString + wxT(" ") + m_clientVerString; // User hash - m_UserHash = tag->UserID(); + m_UserHash = tag->UserHash(); // User IP:Port m_nConnectIP = m_dwUserIP = tag->UserIP(); @@ -1196,7 +1196,7 @@ void CUpDownClientListRem::DeleteItem(CUpDownClient *client) uint32 CUpDownClientListRem::GetItemID(CUpDownClient *client) { - return client->GetUserIDHybrid(); + return client->ECID(); } @@ -1204,6 +1204,7 @@ void CUpDownClientListRem::ProcessItemUpdate( CEC_UpDownClient_Tag *tag, CUpDownClient *client) { + tag->UserID(&client->m_nUserIDHybrid); tag->GetCurrentIdentState(&client->m_identState); tag->HasObfuscatedConnection(&client->m_hasbeenobfuscatinglately); tag->HasExtendedProtocol(&client->m_bEmuleProtocol); diff --git a/src/libs/ec/abstracts/ECCodes.abstract b/src/libs/ec/abstracts/ECCodes.abstract index adb99d5b..4cbd0477 100644 --- a/src/libs/ec/abstracts/ECCodes.abstract +++ b/src/libs/ec/abstracts/ECCodes.abstract @@ -274,6 +274,7 @@ EC_TAG_CLIENT 0x0600 EC_TAG_CLIENT_ASKED_COUNT 0x061B EC_TAG_CLIENT_UPLOAD_STATE 0x061C EC_TAG_CLIENT_EXT_PROTOCOL 0x061D + EC_TAG_CLIENT_USER_ID 0x061E EC_TAG_SEARCHFILE 0x0700 EC_TAG_SEARCH_TYPE 0x0701 diff --git a/src/libs/ec/c#/ECCodes.cs b/src/libs/ec/c#/ECCodes.cs index 5d32f9bc..480c5d03 100644 --- a/src/libs/ec/c#/ECCodes.cs +++ b/src/libs/ec/c#/ECCodes.cs @@ -239,6 +239,7 @@ public enum ECTagNames { EC_TAG_CLIENT_ASKED_COUNT = 0x061B, EC_TAG_CLIENT_UPLOAD_STATE = 0x061C, EC_TAG_CLIENT_EXT_PROTOCOL = 0x061D, + EC_TAG_CLIENT_USER_ID = 0x061E, EC_TAG_SEARCHFILE = 0x0700, EC_TAG_SEARCH_TYPE = 0x0701, EC_TAG_SEARCH_NAME = 0x0702, diff --git a/src/libs/ec/cpp/ECCodes.h b/src/libs/ec/cpp/ECCodes.h index a135c9b7..73a8cc26 100644 --- a/src/libs/ec/cpp/ECCodes.h +++ b/src/libs/ec/cpp/ECCodes.h @@ -248,6 +248,7 @@ enum ECTagNames { EC_TAG_CLIENT_ASKED_COUNT = 0x061B, EC_TAG_CLIENT_UPLOAD_STATE = 0x061C, EC_TAG_CLIENT_EXT_PROTOCOL = 0x061D, + EC_TAG_CLIENT_USER_ID = 0x061E, EC_TAG_SEARCHFILE = 0x0700, EC_TAG_SEARCH_TYPE = 0x0701, EC_TAG_SEARCH_NAME = 0x0702, @@ -647,6 +648,7 @@ wxString GetDebugNameECTagNames(uint16 arg) case 0x061B: return wxT("EC_TAG_CLIENT_ASKED_COUNT"); case 0x061C: return wxT("EC_TAG_CLIENT_UPLOAD_STATE"); case 0x061D: return wxT("EC_TAG_CLIENT_EXT_PROTOCOL"); + case 0x061E: return wxT("EC_TAG_CLIENT_USER_ID"); case 0x0700: return wxT("EC_TAG_SEARCHFILE"); case 0x0701: return wxT("EC_TAG_SEARCH_TYPE"); case 0x0702: return wxT("EC_TAG_SEARCH_NAME"); diff --git a/src/libs/ec/cpp/ECID.h b/src/libs/ec/cpp/ECID.h new file mode 100644 index 00000000..9489f25f --- /dev/null +++ b/src/libs/ec/cpp/ECID.h @@ -0,0 +1,43 @@ +// +// This file is part of the aMule Project. +// +// Copyright (c) 2003-2010 aMule Team ( admin@amule.org / http://www.amule.org ) +// +// Any parts of this program derived from the xMule, lMule or eMule project, +// or contributed by third-party developers are copyrighted by their +// respective authors. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +// + +#ifndef ECID_H +#define ECID_H + +/* + * Class to create unique IDs for Objects transmitted through EC + * (Partfiles, Knownfiles, clients...) + */ +class CECID { + // the id + uint32 m_ID; + // counter to calculate unique ids (defined in ECTag.cpp) + static uint32 s_IDCounter; +public: + CECID() { m_ID = ++s_IDCounter; } + CECID(uint32 id) { m_ID = id; } + uint32 ECID() const { return m_ID; } +}; + +#endif diff --git a/src/libs/ec/cpp/ECSpecialTags.h b/src/libs/ec/cpp/ECSpecialTags.h index a4311c3f..f3b57ba2 100644 --- a/src/libs/ec/cpp/ECSpecialTags.h +++ b/src/libs/ec/cpp/ECSpecialTags.h @@ -275,12 +275,13 @@ class CEC_SharedFile_Tag : public CECTag { class CEC_UpDownClient_Tag : public CECTag { public: - CEC_UpDownClient_Tag(const CUpDownClient* client, EC_DETAIL_LEVEL detail_level, uint32 userID, CValueMap* valuemap); + CEC_UpDownClient_Tag(const CUpDownClient* client, EC_DETAIL_LEVEL detail_level, CValueMap* valuemap); uint32 ID() const { return GetInt(); } CMD4Hash FileID() const { return GetTagByNameSafe(EC_TAG_KNOWNFILE)->GetMD4Data(); } - CMD4Hash UserID() const { return GetTagByNameSafe(EC_TAG_CLIENT_HASH)->GetMD4Data(); } + CMD4Hash UserHash() const { return GetTagByNameSafe(EC_TAG_CLIENT_HASH)->GetMD4Data(); } + uint32 UserID(uint32 *target = 0) const { return AssignIfExist(EC_TAG_CLIENT_USER_ID, target); } bool HaveFile() const { return GetTagByName(EC_TAG_KNOWNFILE) != NULL; } diff --git a/src/libs/ec/cpp/ECTag.cpp b/src/libs/ec/cpp/ECTag.cpp index 36271fe9..f701ba5b 100644 --- a/src/libs/ec/cpp/ECTag.cpp +++ b/src/libs/ec/cpp/ECTag.cpp @@ -31,6 +31,7 @@ #include "ECTag.h" // Needed for ECTag #include "ECSocket.h" // Needed for CECSocket #include "ECSpecialTags.h" // Needed for CValueMap +#include "ECID.h" // Needed for CECID /********************************************************** * * @@ -864,4 +865,7 @@ void CECTag::DebugPrint(int level, bool print_empty) const * * \sa CECTag(ec_tagname_t, uint64) */ + +uint32 CECID::s_IDCounter = 0; + // File_checked_for_headers diff --git a/src/libs/ec/cpp/Makefile.am b/src/libs/ec/cpp/Makefile.am index b2fd2c6f..9021b13c 100644 --- a/src/libs/ec/cpp/Makefile.am +++ b/src/libs/ec/cpp/Makefile.am @@ -25,6 +25,7 @@ noinst_HEADERS = \ ECSpecialTags.h \ ECCodes.h \ ECTagTypes.h \ + ECID.h \ RemoteConnect.h MAINTAINERCLEANFILES = Makefile.in diff --git a/src/libs/ec/cpp/Makefile.in b/src/libs/ec/cpp/Makefile.in index 9222e92c..73e6e1ff 100644 --- a/src/libs/ec/cpp/Makefile.in +++ b/src/libs/ec/cpp/Makefile.in @@ -358,6 +358,7 @@ noinst_HEADERS = \ ECSpecialTags.h \ ECCodes.h \ ECTagTypes.h \ + ECID.h \ RemoteConnect.h MAINTAINERCLEANFILES = Makefile.in diff --git a/src/libs/ec/java/ECCodes.java b/src/libs/ec/java/ECCodes.java index 2b9726f7..3512ec1e 100644 --- a/src/libs/ec/java/ECCodes.java +++ b/src/libs/ec/java/ECCodes.java @@ -236,6 +236,7 @@ public final static short EC_TAG_CLIENT_REMOTE_QUEUE_RANK = 0x061A; public final static short EC_TAG_CLIENT_ASKED_COUNT = 0x061B; public final static short EC_TAG_CLIENT_UPLOAD_STATE = 0x061C; public final static short EC_TAG_CLIENT_EXT_PROTOCOL = 0x061D; +public final static short EC_TAG_CLIENT_USER_ID = 0x061E; public final static short EC_TAG_SEARCHFILE = 0x0700; public final static short EC_TAG_SEARCH_TYPE = 0x0701; public final static short EC_TAG_SEARCH_NAME = 0x0702; diff --git a/src/remote-gui.net/ECCodes.cs b/src/remote-gui.net/ECCodes.cs index 5d32f9bc..480c5d03 100644 --- a/src/remote-gui.net/ECCodes.cs +++ b/src/remote-gui.net/ECCodes.cs @@ -239,6 +239,7 @@ public enum ECTagNames { EC_TAG_CLIENT_ASKED_COUNT = 0x061B, EC_TAG_CLIENT_UPLOAD_STATE = 0x061C, EC_TAG_CLIENT_EXT_PROTOCOL = 0x061D, + EC_TAG_CLIENT_USER_ID = 0x061E, EC_TAG_SEARCHFILE = 0x0700, EC_TAG_SEARCH_TYPE = 0x0701, EC_TAG_SEARCH_NAME = 0x0702, diff --git a/src/updownclient.h b/src/updownclient.h index 85df1f9e..2274e74b 100644 --- a/src/updownclient.h +++ b/src/updownclient.h @@ -32,6 +32,7 @@ #include "NetworkFunctions.h" #include "OtherStructs.h" #include "ClientCredits.h" // Needed for EIdentState +#include // Needed for CECID #include @@ -148,7 +149,7 @@ enum ClientState // This is fixed on ed2k v1, but can be any number on ED2Kv2 #define STANDARD_BLOCKS_REQUEST 3 -class CUpDownClient +class CUpDownClient : public CECID { friend class CClientList; friend class CUpDownClientListRem; -- 2.11.4.GIT