| 1171 | |
| 1172 | |
| 1173 | void 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 | |
| 1206 | void CUpDownClient::ClearDownloadBlockRequests() |
no test coverage detected