| 234 | |
| 235 | |
| 236 | void CSearchFile::UpdateParent() |
| 237 | { |
| 238 | wxCHECK_RET(!m_parent, "UpdateParent called on child item"); |
| 239 | |
| 240 | uint32_t sourceCount = 0; // ed2k: sum of all sources, kad: the max sources found |
| 241 | uint32_t completeSourceCount = 0; // ed2k: sum of all sources, kad: the max sources found |
| 242 | uint32_t differentNames = 0; // max known different names |
| 243 | uint32_t publishersKnown = 0; // max publishers known |
| 244 | uint32_t trustValue = 0; // average trust value |
| 245 | unsigned publishInfoTags = 0; |
| 246 | unsigned ratingCount = 0; |
| 247 | unsigned ratingTotal = 0; |
| 248 | CSearchResultList::const_iterator best = m_children.begin(); |
| 249 | for (CSearchResultList::const_iterator it = m_children.begin(); it != m_children.end(); ++it) { |
| 250 | const CSearchFile* child = *it; |
| 251 | |
| 252 | // Locate the most common name |
| 253 | if (child->GetSourceCount() > (*best)->GetSourceCount()) { |
| 254 | best = it; |
| 255 | } |
| 256 | |
| 257 | // Sources |
| 258 | if (m_kademlia) { |
| 259 | sourceCount = std::max(sourceCount, child->m_sourceCount); |
| 260 | completeSourceCount = std::max(completeSourceCount, child->m_completeSourceCount); |
| 261 | } else { |
| 262 | sourceCount += child->m_sourceCount; |
| 263 | completeSourceCount += child->m_completeSourceCount; |
| 264 | } |
| 265 | |
| 266 | // Publish info |
| 267 | if (child->GetKadPublishInfo() != 0) { |
| 268 | differentNames = std::max(differentNames, (child->GetKadPublishInfo() & 0xFF000000) >> 24); |
| 269 | publishersKnown = std::max(publishersKnown, (child->GetKadPublishInfo() & 0x00FF0000) >> 16); |
| 270 | trustValue += child->GetKadPublishInfo() & 0x0000FFFF; |
| 271 | publishInfoTags++; |
| 272 | } |
| 273 | |
| 274 | // Rating |
| 275 | if (child->HasRating()) { |
| 276 | ratingCount++; |
| 277 | ratingTotal += child->UserRating(); |
| 278 | } |
| 279 | |
| 280 | // Available sources |
| 281 | if (child->GetClientID() && child->GetClientPort()) { |
| 282 | CSearchFile::ClientStruct client(child->GetClientID(), child->GetClientPort(), child->GetClientServerIP(), child->GetClientServerPort()); |
| 283 | AddClient(client); |
| 284 | } |
| 285 | for (std::list<ClientStruct>::const_iterator cit = child->m_clients.begin(); cit != child->m_clients.end(); ++cit) { |
| 286 | AddClient(*cit); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | m_sourceCount = sourceCount; |
| 291 | m_completeSourceCount = completeSourceCount; |
| 292 | |
| 293 | if (publishInfoTags > 0) { |
nothing calls this directly
no test coverage detected