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

Method ProcessMuleCommentPacket

src/BaseClient.cpp:1173–1203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1171
1172
1173void CUpDownClient::ProcessMuleCommentPacket(const uint8_t* pachPacket, uint32 nSize)
1174{
1175 if (!m_reqfile) {
1176 throw CInvalidPacket("Comment packet for unknown file");
1177 }
1178
1179 if (!m_reqfile->IsPartFile()) {
1180 throw CInvalidPacket("Comment packet for completed file");
1181 }
1182
1183 const CMemFile data(pachPacket, nSize);
1184
1185 uint8 rating = data.ReadUInt8();
1186 if (rating > 5) {
1187 AddDebugLogLineN( logClient, wxString("Invalid Rating for file '") << m_clientFilename << "' received: " << rating);
1188 m_iRating = 0;
1189 } else {
1190 m_iRating = rating;
1191 AddDebugLogLineN( logClient, wxString("Rating for file '") << m_clientFilename << "' received: " << m_iRating);
1192 }
1193
1194 // The comment is unicoded, with a uin32 len and safe read
1195 // (won't break if string size is < than advertised len)
1196 // Truncated to MAXFILECOMMENTLEN size
1197 m_strComment = data.ReadString((GetUnicodeSupport() != utf8strNone), 4 /* bytes (it's a uint32)*/, true).Left(MAXFILECOMMENTLEN);
1198
1199 AddDebugLogLineN( logClient, wxString("Description for file '") << m_clientFilename << "' received: " << m_strComment);
1200
1201 // Update file rating
1202 m_reqfile->UpdateFileRatingCommentAvail();
1203}
1204
1205
1206void CUpDownClient::ClearDownloadBlockRequests()

Callers 1

ProcessExtPacketMethod · 0.80

Calls 6

CInvalidPacketClass · 0.85
ReadUInt8Method · 0.80
wxStringClass · 0.70
IsPartFileMethod · 0.45
ReadStringMethod · 0.45

Tested by

no test coverage detected