| 38 | #include "KnownFileList.h" // Needed for CKnownFileList |
| 39 | |
| 40 | CSearchFile::CSearchFile(const CMemFile& data, bool optUTF8, wxUIntPtr searchID, uint32_t serverIP, uint16_t serverPort, const wxString& directory, bool kademlia) |
| 41 | : m_parent(NULL), |
| 42 | m_showChildren(false), |
| 43 | m_searchID(searchID), |
| 44 | m_sourceCount(0), |
| 45 | m_completeSourceCount(0), |
| 46 | m_kademlia(kademlia), |
| 47 | m_downloadStatus(NEW), |
| 48 | m_directory(directory), |
| 49 | m_clientServerIP(serverIP), |
| 50 | m_clientServerPort(serverPort), |
| 51 | m_kadPublishInfo(0) |
| 52 | { |
| 53 | m_abyFileHash = data.ReadHash(); |
| 54 | SetDownloadStatus(); |
| 55 | m_clientID = data.ReadUInt32(); |
| 56 | m_clientPort = data.ReadUInt16(); |
| 57 | |
| 58 | if (!m_clientID || !m_clientPort || !IsGoodIP(m_clientID, thePrefs::FilterLanIPs())) { |
| 59 | m_clientID = 0; |
| 60 | m_clientPort = 0; |
| 61 | } |
| 62 | |
| 63 | uint32 tagcount = data.ReadUInt32(); |
| 64 | for (unsigned int i = 0; i < tagcount; ++i) { |
| 65 | CTag tag(data, optUTF8); |
| 66 | switch (tag.GetNameID()) { |
| 67 | case FT_FILENAME: |
| 68 | SetFileName(CPath(tag.GetStr())); |
| 69 | break; |
| 70 | case FT_FILESIZE: |
| 71 | SetFileSize(tag.GetInt()); |
| 72 | break; |
| 73 | case FT_FILESIZE_HI: |
| 74 | SetFileSize((((uint64)tag.GetInt()) << 32) + GetFileSize()); |
| 75 | break; |
| 76 | case FT_FILERATING: |
| 77 | m_iUserRating = (tag.GetInt() & 0xF) / 3; |
| 78 | break; |
| 79 | case FT_SOURCES: |
| 80 | m_sourceCount = tag.GetInt(); |
| 81 | break; |
| 82 | case FT_COMPLETE_SOURCES: |
| 83 | m_completeSourceCount = tag.GetInt(); |
| 84 | break; |
| 85 | case FT_PERMISSIONS: |
| 86 | case FT_KADLASTPUBLISHKEY: |
| 87 | case FT_PARTFILENAME: |
| 88 | // Just ignore |
| 89 | break; |
| 90 | default: |
| 91 | AddTagUnique(tag); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | if (!GetFileName().IsOk()) { |
| 96 | throw CInvalidPacket("No filename in search result"); |
| 97 | } |
nothing calls this directly
no test coverage detected