MCPcopy Create free account
hub / github.com/amule-project/amule / AddKnownClient

Method AddKnownClient

src/Statistics.cpp:987–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985}
986
987void CStatistics::AddKnownClient(CUpDownClient *pClient)
988{
989 ++(*s_clients);
990
991 uint32 clientSoft = pClient->GetClientSoft();
992 uint32 id = GetSoftID(clientSoft);
993
994 CStatTreeItemCounter *client;
995
996 if (s_clients->HasChildWithId(id)) {
997 client = static_cast<CStatTreeItemCounter*>(s_clients->GetChildById(id));
998 ++(*client);
999 } else {
1000 uint32 flags = stSortChildren | stShowPercent | stHideIfZero;
1001 if (!SupportsOSInfo(clientSoft)) {
1002 flags |= stCapChildren;
1003 }
1004 client = new CStatTreeItemCounter(GetSoftName(clientSoft) + ": %s", flags);
1005 ++(*client);
1006 s_clients->AddChild(client, id);
1007 if (SupportsOSInfo(clientSoft)) {
1008 client->AddChild(new CStatTreeItemBase(wxTRANSLATE("Version"), stSortChildren | stCapChildren), 2);
1009 client->AddChild(new CStatTreeItemBase(wxTRANSLATE("Operating System"), stSortChildren | stSortByValue), 1);
1010 }
1011 }
1012
1013 CStatTreeItemBase *versionRoot = SupportsOSInfo(clientSoft) ? client->GetChildById(2) : client;
1014 uint32 clientVersion = pClient->GetVersion();
1015
1016 if (versionRoot->HasChildWithId(clientVersion)) {
1017 CStatTreeItemCounter *version = static_cast<CStatTreeItemCounter*>(versionRoot->GetChildById(clientVersion));
1018 ++(*version);
1019 } else {
1020 const wxString& versionStr = pClient->GetVersionString();
1021 CStatTreeItemCounter *version = new CStatTreeItemCounter((versionStr.IsEmpty() ? wxString(wxTRANSLATE("Unknown")) : versionStr) + ": %s", stShowPercent | stHideIfZero);
1022 ++(*version);
1023 versionRoot->AddChild(version, clientVersion, SupportsOSInfo(clientSoft));
1024 }
1025
1026 if (SupportsOSInfo(clientSoft)) {
1027 const wxString& OSInfo = pClient->GetClientOSInfo();
1028 uint32 OS_ID = OSInfo.IsEmpty() ? 0 : GetIdFromString(OSInfo);
1029 CStatTreeItemBase* OSRoot = client->GetChildById(1);
1030 CStatTreeItemCounter* OSNode = static_cast<CStatTreeItemCounter*>(OSRoot->GetChildById(OS_ID));
1031 if (OSNode) {
1032 ++(*OSNode);
1033 } else {
1034 OSNode = new CStatTreeItemCounter((OS_ID ? OSInfo : wxString(wxTRANSLATE("Not Received"))) + ": %s", stShowPercent | stHideIfZero);
1035 ++(*OSNode);
1036 OSRoot->AddChild(OSNode, OS_ID, true);
1037 }
1038 }
1039}
1040
1041void CStatistics::RemoveKnownClient(uint32 clientSoft, uint32 clientVersion, const wxString& OSInfo)
1042{

Callers

nothing calls this directly

Calls 11

GetSoftIDFunction · 0.85
SupportsOSInfoFunction · 0.85
GetSoftNameFunction · 0.85
GetIdFromStringFunction · 0.85
HasChildWithIdMethod · 0.80
GetChildByIdMethod · 0.80
wxStringClass · 0.70
GetClientSoftMethod · 0.45
AddChildMethod · 0.45
GetVersionMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected