Improve speed of category tab title updates
[amule.git] / src / SharedFileList.h
blobac41f7e1c1774baf0f096136817895a962518051
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef SHAREDFILELIST_H
27 #define SHAREDFILELIST_H
29 #include <map>
30 #include <wx/thread.h> // Needed for wxMutex
32 #include "Types.h" // Needed for uint16 and uint64
34 struct UnknownFile_Struct;
36 class CKnownFileList;
37 class CKnownFile;
38 class CMemFile;
39 class CMD4Hash;
40 class CServer;
41 class CPublishKeywordList;
42 class CPath;
43 class CAICHHash;
46 typedef std::map<CMD4Hash,CKnownFile*> CKnownFileMap;
48 class CSharedFileList {
49 public:
50 CSharedFileList(CKnownFileList* in_filelist);
51 ~CSharedFileList();
52 void Reload();
53 void SafeAddKFile(CKnownFile* toadd, bool bOnlyAdd = false);
54 void RemoveFile(CKnownFile* toremove);
55 CKnownFile* GetFileByID(const CMD4Hash& filehash);
56 short GetFilePriorityByID(const CMD4Hash& filehash);
57 const CKnownFile* GetFileByIndex(unsigned int index) const;
58 size_t GetCount() { wxMutexLocker lock(list_mut); return m_Files_map.size(); }
59 size_t GetFileCount() { wxMutexLocker lock(list_mut); return m_Files_map.size(); }
60 void CopyFileList(std::vector<CKnownFile*>& out_list) const;
61 void UpdateItem(CKnownFile* toupdate);
62 unsigned AddFilesFromDirectory(const CPath& directory);
63 void GetSharedFilesByDirectory(const wxString& directory, CKnownFilePtrList& list);
64 void ClearED2KPublishInfo();
65 void RepublishFile(CKnownFile* pFile);
66 void Process();
67 void PublishNextTurn() { m_lastPublishED2KFlag = true; }
68 bool RenameFile(CKnownFile* pFile, const CPath& newName);
70 /* Kad Stuff */
71 void Publish();
72 void AddKeywords(CKnownFile* pFile);
73 void RemoveKeywords(CKnownFile* pFile);
74 // This is actually unused, but keep it here - will be needed later.
75 void ClearKadSourcePublishInfo();
77 /**
78 * Checks for files which missing or wrong AICH hashes.
79 * Those that are found are scheduled for ACIH hashing.
81 void CheckAICHHashes(const std::list<CAICHHash>& hashes);
83 private:
84 bool AddFile(CKnownFile* pFile);
85 void FindSharedFiles();
86 bool reloading;
88 void SendListToServer();
89 uint32 m_lastPublishED2K;
90 bool m_lastPublishED2KFlag;
92 CKnownFileList* filelist;
94 CKnownFileMap m_Files_map;
95 mutable wxMutex list_mut;
98 /* Kad Stuff */
99 CPublishKeywordList* m_keywords;
100 unsigned int m_currFileSrc;
101 unsigned int m_currFileNotes;
102 unsigned int m_currFileKey;
103 uint32 m_lastPublishKadSrc;
104 uint32 m_lastPublishKadNotes;
107 #endif // SHAREDFILELIST_H
108 // File_checked_for_headers