Show uploading clients for shared files
[amule.git] / src / KnownFile.cpp
blob5cda08edc67f85adc633cb126eb215df12642c15
1 //
2 // This file is part of the aMule Project.
3 //
4 // Parts of this file are based on work from pan One (http://home-3.tiscali.nl/~meost/pms/)
5 //
6 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
7 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
8 //
9 // Any parts of this program derived from the xMule, lMule or eMule project,
10 // or contributed by third-party developers are copyrighted by their
11 // respective authors.
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2 of the License, or
16 // (at your option) any later version.
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "KnownFile.h" // Do_not_auto_remove
32 #include <protocol/kad/Constants.h>
33 #include <protocol/ed2k/Client2Client/TCP.h>
34 #include <protocol/Protocols.h>
35 #include <tags/FileTags.h>
38 #include <wx/config.h>
41 #include "MemFile.h" // Needed for CMemFile
42 #include "updownclient.h" // Needed for CUpDownClient
43 #include "Packet.h" // Needed for CPacket
44 #include "Preferences.h" // Needed for CPreferences
45 #include "KnownFileList.h" // Needed for CKnownFileList
46 #include "amule.h" // Needed for theApp
47 #include "PartFile.h" // Needed for SavePartFile
48 #include "ClientList.h" // Needed for clientlist (buddy support)
49 #include "Logger.h"
50 #include "ScopedPtr.h" // Needed for CScopedArray and CScopedPtr
51 #include "GuiEvents.h" // Needed for Notify_*
52 #include "SearchFile.h" // Needed for CSearchFile
53 #include "FileArea.h" // Needed for CFileArea
54 #include "FileAutoClose.h" // Needed for CFileAutoClose
56 #include "CryptoPP_Inc.h" // Needed for MD4
58 #include <common/Format.h>
60 CFileStatistic::CFileStatistic() :
61 requested(0),
62 transferred(0),
63 accepted(0),
64 alltimerequested(0),
65 alltimetransferred(0),
66 alltimeaccepted(0)
70 #ifndef CLIENT_GUI
72 void CFileStatistic::AddRequest(){
73 requested++;
74 alltimerequested++;
75 theApp->knownfiles->requested++;
76 theApp->sharedfiles->UpdateItem(fileParent);
79 void CFileStatistic::AddAccepted(){
80 accepted++;
81 alltimeaccepted++;
82 theApp->knownfiles->accepted++;
83 theApp->sharedfiles->UpdateItem(fileParent);
86 void CFileStatistic::AddTransferred(uint64 bytes){
87 transferred += bytes;
88 alltimetransferred += bytes;
89 theApp->knownfiles->transferred += bytes;
90 theApp->sharedfiles->UpdateItem(fileParent);
93 #endif // CLIENT_GUI
96 /* Abstract File (base class)*/
98 CAbstractFile::CAbstractFile()
100 m_iRating(0),
101 m_hasComment(false),
102 m_iUserRating(0),
103 m_nFileSize(0)
108 CAbstractFile::CAbstractFile(const CAbstractFile& other)
110 m_abyFileHash(other.m_abyFileHash),
111 m_strComment(other.m_strComment),
112 m_iRating(other.m_iRating),
113 m_hasComment(other.m_hasComment),
114 m_iUserRating(other.m_iUserRating),
115 m_taglist(other.m_taglist),
116 m_nFileSize(other.m_nFileSize),
117 m_fileName(other.m_fileName)
119 /* // TODO: Currently it's not safe to duplicate the entries, but isn't needed either.
120 CKadEntryPtrList::const_iterator it = other.m_kadNotes.begin();
121 for (; it != other.m_kadNotes.end(); ++it) {
122 m_kadNotes.push_back(new Kademlia::CEntry(**it));
128 void CAbstractFile::SetFileName(const CPath& fileName)
130 m_fileName = fileName;
133 uint32 CAbstractFile::GetIntTagValue(uint8 tagname) const
135 ArrayOfCTag::const_iterator it = m_taglist.begin();
136 for (; it != m_taglist.end(); ++it){
137 if (((*it).GetNameID() == tagname) && (*it).IsInt()) {
138 return (*it).GetInt();
141 return 0;
144 bool CAbstractFile::GetIntTagValue(uint8 tagname, uint32& ruValue) const
146 ArrayOfCTag::const_iterator it = m_taglist.begin();
147 for (; it != m_taglist.end(); ++it){
148 if (((*it).GetNameID() == tagname) && (*it).IsInt()){
149 ruValue = (*it).GetInt();
150 return true;
153 return false;
156 uint32 CAbstractFile::GetIntTagValue(const wxString& tagname) const
158 ArrayOfCTag::const_iterator it = m_taglist.begin();
159 for (; it != m_taglist.end(); ++it){
160 if ((*it).IsInt() && ((*it).GetName() == tagname)) {
161 return (*it).GetInt();
164 return 0;
167 const wxString& CAbstractFile::GetStrTagValue(uint8 tagname) const
169 ArrayOfCTag::const_iterator it = m_taglist.begin();
170 for (; it != m_taglist.end(); ++it){
171 if ((*it).GetNameID() == tagname && (*it).IsStr()) {
172 return (*it).GetStr();
175 return EmptyString;
178 const wxString& CAbstractFile::GetStrTagValue(const wxString& tagname) const
180 ArrayOfCTag::const_iterator it = m_taglist.begin();
181 for (; it != m_taglist.end(); ++it){
182 if ((*it).IsStr() && ((*it).GetName() == tagname)) {
183 return (*it).GetStr();
186 return EmptyString;
189 const CTag *CAbstractFile::GetTag(uint8 tagname, uint8 tagtype) const
191 ArrayOfCTag::const_iterator it = m_taglist.begin();
192 for (; it != m_taglist.end(); ++it){
193 if ((*it).GetNameID() == tagname && (*it).GetType() == tagtype) {
194 return &(*it);
197 return NULL;
200 const CTag *CAbstractFile::GetTag(const wxString& tagname, uint8 tagtype) const
202 ArrayOfCTag::const_iterator it = m_taglist.begin();
203 for (; it != m_taglist.end(); ++it){
204 if ((*it).GetType() == tagtype && (*it).GetName() == tagname) {
205 return &(*it);
208 return NULL;
211 const CTag *CAbstractFile::GetTag(uint8 tagname) const
213 ArrayOfCTag::const_iterator it = m_taglist.begin();
214 for (; it != m_taglist.end(); ++it){
215 if ((*it).GetNameID() == tagname) {
216 return &(*it);
219 return NULL;
222 const CTag *CAbstractFile::GetTag(const wxString& tagname) const
224 ArrayOfCTag::const_iterator it = m_taglist.begin();
225 for (; it != m_taglist.end(); ++it){
226 if ((*it).GetName() == tagname) {
227 return &(*it);
230 return NULL;
233 void CAbstractFile::AddTagUnique(const CTag &rTag)
235 ArrayOfCTag::iterator it = m_taglist.begin();
236 for (; it != m_taglist.end(); ++it) {
237 if ( ( ((*it).GetNameID() != 0 &&
238 (*it).GetNameID() == rTag.GetNameID()) ||
239 (!(*it).GetName().IsEmpty() &&
240 !rTag.GetName().IsEmpty() &&
241 (*it).GetName() == rTag.GetName()) ) &&
242 (*it).GetType() == rTag.GetType()){
243 m_taglist.erase(it);
244 m_taglist.insert(it, rTag);
245 return;
248 m_taglist.push_back(rTag);
251 #ifndef CLIENT_GUI
252 void CAbstractFile::AddNote(Kademlia::CEntry *pEntry)
254 CKadEntryPtrList::iterator it = m_kadNotes.begin();
255 for (; it != m_kadNotes.end(); ++it) {
256 Kademlia::CEntry* entry = *it;
257 if(entry->m_uIP == pEntry->m_uIP || entry->m_uSourceID == pEntry->m_uSourceID) {
258 delete pEntry;
259 return;
262 m_kadNotes.push_front(pEntry);
264 #else
265 void CAbstractFile::AddNote(Kademlia::CEntry *)
268 #endif
271 /* Known File */
273 CKnownFile::CKnownFile()
275 Init();
278 CKnownFile::CKnownFile(uint32 ecid) : CECID(ecid)
280 Init();
284 //#warning Experimental: Construct a CKnownFile from a CSearchFile
285 CKnownFile::CKnownFile(const CSearchFile &searchFile)
287 // This will copy the file hash
288 CAbstractFile(static_cast<const CAbstractFile &>(searchFile))
290 Init();
292 // Use CKnownFile::SetFileName()
293 SetFileName(searchFile.GetFileName());
295 // Use CKnownFile::SetFileSize()
296 SetFileSize(searchFile.GetFileSize());
300 void CKnownFile::Init()
302 m_showSources = false;
303 m_nCompleteSourcesTime = time(NULL);
304 m_nCompleteSourcesCount = 0;
305 m_nCompleteSourcesCountLo = 0;
306 m_nCompleteSourcesCountHi = 0;
307 m_bCommentLoaded = false;
308 m_iPartCount = 0;
309 m_iED2KPartCount = 0;
310 m_iED2KPartHashCount = 0;
311 m_PublishedED2K = false;
312 kadFileSearchID = 0;
313 m_lastPublishTimeKadSrc = 0;
314 m_lastPublishTimeKadNotes = 0;
315 m_lastBuddyIP = 0;
316 m_lastDateChanged = 0;
317 m_bAutoUpPriority = thePrefs::GetNewAutoUp();
318 m_iUpPriority = ( m_bAutoUpPriority ) ? PR_HIGH : PR_NORMAL;
320 statistic.fileParent = this;
322 #ifndef CLIENT_GUI
323 m_pAICHHashSet = new CAICHHashSet(this);
324 #endif
328 void CKnownFile::SetFileSize(uint64 nFileSize)
330 CAbstractFile::SetFileSize(nFileSize);
331 #ifndef CLIENT_GUI
332 m_pAICHHashSet->SetFileSize(nFileSize);
333 #endif
335 // Examples of parthashs, hashsets and filehashs for different filesizes
336 // according the ed2k protocol
337 //----------------------------------------------------------------------
339 //File size: 3 bytes
340 //File hash: 2D55E87D0E21F49B9AD25F98531F3724
341 //Nr. hashs: 0
344 //File size: 1*PARTSIZE
345 //File hash: A72CA8DF7F07154E217C236C89C17619
346 //Nr. hashs: 2
347 //Hash[ 0]: 4891ED2E5C9C49F442145A3A5F608299
348 //Hash[ 1]: 31D6CFE0D16AE931B73C59D7E0C089C0 *special part hash*
351 //File size: 1*PARTSIZE + 1 byte
352 //File hash: 2F620AE9D462CBB6A59FE8401D2B3D23
353 //Nr. hashs: 2
354 //Hash[ 0]: 121795F0BEDE02DDC7C5426D0995F53F
355 //Hash[ 1]: C329E527945B8FE75B3C5E8826755747
358 //File size: 2*PARTSIZE
359 //File hash: A54C5E562D5E03CA7D77961EB9A745A4
360 //Nr. hashs: 3
361 //Hash[ 0]: B3F5CE2A06BF403BFB9BFFF68BDDC4D9
362 //Hash[ 1]: 509AA30C9EA8FC136B1159DF2F35B8A9
363 //Hash[ 2]: 31D6CFE0D16AE931B73C59D7E0C089C0 *special part hash*
366 //File size: 3*PARTSIZE
367 //File hash: 5E249B96F9A46A18FC2489B005BF2667
368 //Nr. hashs: 4
369 //Hash[ 0]: 5319896A2ECAD43BF17E2E3575278E72
370 //Hash[ 1]: D86EF157D5E49C5ED502EDC15BB5F82B
371 //Hash[ 2]: 10F2D5B1FCB95C0840519C58D708480F
372 //Hash[ 3]: 31D6CFE0D16AE931B73C59D7E0C089C0 *special part hash*
375 //File size: 3*PARTSIZE + 1 byte
376 //File hash: 797ED552F34380CAFF8C958207E40355
377 //Nr. hashs: 4
378 //Hash[ 0]: FC7FD02CCD6987DCF1421F4C0AF94FB8
379 //Hash[ 1]: 2FE466AF8A7C06DA3365317B75A5ACFE
380 //Hash[ 2]: 873D3BF52629F7C1527C6E8E473C1C30
381 //Hash[ 3]: BCE50BEE7877BB07BB6FDA56BFE142FB
384 // File size Data parts ED2K parts ED2K part hashs
385 // ---------------------------------------------------------------
386 // 1..PARTSIZE-1 1 1 0(!)
387 // PARTSIZE 1 2(!) 2(!)
388 // PARTSIZE+1 2 2 2
389 // PARTSIZE*2 2 3(!) 3(!)
390 // PARTSIZE*2+1 3 3 3
392 if (nFileSize == 0){
393 //wxFAIL; // Kry - Why commented out by lemonfan? it can never be 0
394 m_iPartCount = 0;
395 m_iED2KPartCount = 0;
396 m_iED2KPartHashCount = 0;
397 m_sizeLastPart = 0;
398 return;
401 // nr. of data parts
402 m_iPartCount = nFileSize / PARTSIZE + 1;
403 // size of last part
404 m_sizeLastPart = nFileSize % PARTSIZE;
405 // file with size of n * PARTSIZE
406 if (m_sizeLastPart == 0) {
407 m_sizeLastPart = PARTSIZE;
408 m_iPartCount--;
411 // nr. of parts to be used with OP_FILESTATUS
412 m_iED2KPartCount = nFileSize / PARTSIZE + 1;
414 // nr. of parts to be used with OP_HASHSETANSWER
415 m_iED2KPartHashCount = nFileSize / PARTSIZE;
416 if (m_iED2KPartHashCount != 0) {
417 m_iED2KPartHashCount += 1;
422 void CKnownFile::AddUploadingClient(CUpDownClient* client)
424 m_ClientUploadList.insert(client);
426 SourceItemType type = UNAVAILABLE_SOURCE;
427 switch (client->GetUploadState()) {
428 case US_UPLOADING:
429 case US_ONUPLOADQUEUE:
430 type = AVAILABLE_SOURCE;
431 break;
432 default: {
433 // Any other state is UNAVAILABLE_SOURCE by default.
437 Notify_SharedCtrlAddClient(this, client, type);
439 UpdateAutoUpPriority();
443 void CKnownFile::RemoveUploadingClient(CUpDownClient* client)
445 if (m_ClientUploadList.erase(client)) {
446 Notify_SharedCtrlRemoveClient(this, client);
447 UpdateAutoUpPriority();
452 #ifdef CLIENT_GUI
454 CKnownFile::CKnownFile(CEC_SharedFile_Tag *tag) : CECID(tag->ID())
456 Init();
458 m_abyFileHash = tag->FileHash();
459 SetFileSize(tag->SizeFull());
460 m_AvailPartFrequency.insert(m_AvailPartFrequency.end(), m_iPartCount, 0);
461 m_queuedCount = 0;
464 CKnownFile::~CKnownFile()
468 void CKnownFile::UpdateAutoUpPriority()
473 #else // ! CLIENT_GUI
475 CKnownFile::~CKnownFile()
477 SourceSet::iterator it = m_ClientUploadList.begin();
478 for ( ; it != m_ClientUploadList.end(); ++it ) {
479 (*it)->ClearUploadFileID();
482 delete m_pAICHHashSet;
486 void CKnownFile::SetFilePath(const CPath& filePath)
488 m_filePath = filePath;
492 // needed for memfiles. its probably better to switch everything to CFile...
493 bool CKnownFile::LoadHashsetFromFile(const CFileDataIO* file, bool checkhash)
495 CMD4Hash checkid = file->ReadHash();
497 uint16 parts = file->ReadUInt16();
498 for (uint16 i = 0; i < parts; ++i){
499 CMD4Hash cur_hash = file->ReadHash();
500 m_hashlist.push_back(cur_hash);
503 // SLUGFILLER: SafeHash - always check for valid m_hashlist
504 if (!checkhash){
505 m_abyFileHash = checkid;
506 if (parts <= 1) { // nothing to check
507 return true;
509 } else {
510 if ( m_abyFileHash != checkid ) {
511 return false; // wrong file?
512 } else {
513 if (parts != GetED2KPartHashCount()) {
514 return false;
518 // SLUGFILLER: SafeHash
520 // trust noone ;-)
521 // lol, useless comment but made me lmao
522 // wtf you guys are weird.
524 if (!m_hashlist.empty()) {
525 CreateHashFromHashlist(m_hashlist, &checkid);
528 if ( m_abyFileHash == checkid ) {
529 return true;
530 } else {
531 m_hashlist.clear();
532 return false;
537 bool CKnownFile::LoadTagsFromFile(const CFileDataIO* file)
539 uint32 tagcount = file->ReadUInt32();
540 for (uint32 j = 0; j != tagcount; ++j) {
541 CTag newtag(*file, true);
542 switch(newtag.GetNameID()){
543 case FT_FILENAME:
544 if (GetFileName().IsOk()) {
545 // Unlike eMule, we actually prefer the second
546 // filename tag, since we use it to specify the
547 // 'universial' filename (see CPath::ToUniv).
548 CPath path = CPath::FromUniv(newtag.GetStr());
550 // May be invalid, if from older versions where
551 // unicoded filenames be saved as empty-strings.
552 if (path.IsOk()) {
553 SetFileName(path);
555 } else {
556 SetFileName(CPath(newtag.GetStr()));
558 break;
560 case FT_FILESIZE:
561 SetFileSize(newtag.GetInt());
562 m_AvailPartFrequency.clear();
563 m_AvailPartFrequency.insert(
564 m_AvailPartFrequency.begin(),
565 GetPartCount(), 0);
566 break;
568 case FT_ATTRANSFERRED:
569 statistic.alltimetransferred += newtag.GetInt();
570 break;
572 case FT_ATTRANSFERREDHI:
573 statistic.alltimetransferred =
574 (((uint64)newtag.GetInt()) << 32) +
575 ((uint64)statistic.alltimetransferred);
576 break;
578 case FT_ATREQUESTED:
579 statistic.alltimerequested = newtag.GetInt();
580 break;
582 case FT_ATACCEPTED:
583 statistic.alltimeaccepted = newtag.GetInt();
584 break;
586 case FT_ULPRIORITY:
587 m_iUpPriority = newtag.GetInt();
588 if( m_iUpPriority == PR_AUTO ){
589 m_iUpPriority = PR_HIGH;
590 m_bAutoUpPriority = true;
591 } else {
592 if ( m_iUpPriority != PR_VERYLOW &&
593 m_iUpPriority != PR_LOW &&
594 m_iUpPriority != PR_NORMAL &&
595 m_iUpPriority != PR_HIGH &&
596 m_iUpPriority != PR_VERYHIGH &&
597 m_iUpPriority != PR_POWERSHARE) {
598 m_iUpPriority = PR_NORMAL;
601 m_bAutoUpPriority = false;
603 break;
605 case FT_PERMISSIONS:
606 // Ignore it, it's not used anymore.
607 break;
609 case FT_AICH_HASH: {
610 CAICHHash hash;
611 bool hashSizeOk =
612 hash.DecodeBase32(newtag.GetStr()) == CAICHHash::GetHashSize();
613 wxASSERT(hashSizeOk);
614 if (hashSizeOk) {
615 m_pAICHHashSet->SetMasterHash(hash, AICH_HASHSETCOMPLETE);
617 break;
620 case FT_KADLASTPUBLISHSRC:
621 SetLastPublishTimeKadSrc( newtag.GetInt(), 0 );
623 if(GetLastPublishTimeKadSrc() > (uint32)time(NULL)+KADEMLIAREPUBLISHTIMES) {
624 //There may be a posibility of an older client that saved a random number here.. This will check for that..
625 SetLastPublishTimeKadSrc(0, 0);
627 break;
629 case FT_KADLASTPUBLISHNOTES:
630 SetLastPublishTimeKadNotes( newtag.GetInt() );
631 break;
633 case FT_KADLASTPUBLISHKEY:
634 // Just purge it
635 wxASSERT( newtag.IsInt() );
636 break;
638 default:
639 // Store them here and write them back on saving.
640 m_taglist.push_back(newtag);
644 return true;
648 bool CKnownFile::LoadDateFromFile(const CFileDataIO* file)
650 m_lastDateChanged = file->ReadUInt32();
652 return true;
656 bool CKnownFile::LoadFromFile(const CFileDataIO* file)
658 // SLUGFILLER: SafeHash - load first, verify later
659 bool ret1 = LoadDateFromFile(file);
660 bool ret2 = LoadHashsetFromFile(file,false);
661 bool ret3 = LoadTagsFromFile(file);
662 UpdatePartsInfo();
663 // Final hash-count verification, needs to be done after the tags are loaded.
664 return ret1 && ret2 && ret3 && GetED2KPartHashCount()==GetHashCount();
665 // SLUGFILLER: SafeHash
669 bool CKnownFile::WriteToFile(CFileDataIO* file)
671 wxCHECK(!IsPartFile(), false);
673 // date
674 file->WriteUInt32(m_lastDateChanged);
675 // hashset
676 file->WriteHash(m_abyFileHash);
678 uint16 parts = m_hashlist.size();
679 file->WriteUInt16(parts);
681 for (int i = 0; i < parts; ++i)
682 file->WriteHash(m_hashlist[i]);
684 //tags
685 const int iFixedTags = 8;
686 uint32 tagcount = iFixedTags;
687 if (HasProperAICHHashSet()) {
688 tagcount++;
690 // Float meta tags are currently not written. All older eMule versions < 0.28a have
691 // a bug in the meta tag reading+writing code. To achive maximum backward
692 // compatibility for met files with older eMule versions we just don't write float
693 // tags. This is OK, because we (eMule) do not use float tags. The only float tags
694 // we may have to handle is the '# Sent' tag from the Hybrid, which is pretty
695 // useless but may be received from us via the servers.
697 // The code for writing the float tags SHOULD BE ENABLED in SOME MONTHS (after most
698 // people are using the newer eMule versions which do not write broken float tags).
699 for (size_t j = 0; j < m_taglist.size(); ++j){
700 if (m_taglist[j].IsInt() || m_taglist[j].IsStr()) {
701 ++tagcount;
705 if (m_lastPublishTimeKadSrc) {
706 ++tagcount;
709 if (m_lastPublishTimeKadNotes){
710 ++tagcount;
713 // standard tags
715 file->WriteUInt32(tagcount);
717 // We still save the unicoded filename, for backwards
718 // compatibility with pre-2.2 and other clients.
719 CTagString nametag_unicode(FT_FILENAME, GetFileName().GetRaw());
720 // We write it with BOM to kep eMule compatibility
721 nametag_unicode.WriteTagToFile(file,utf8strOptBOM);
723 // The non-unicoded filename is written in an 'universial'
724 // format, which allows us to identify files, even if the
725 // system locale changes.
726 CTagString nametag(FT_FILENAME, CPath::ToUniv(GetFileName()));
727 nametag.WriteTagToFile(file);
729 CTagIntSized sizetag(FT_FILESIZE, GetFileSize(), IsLargeFile() ? 64 : 32);
730 sizetag.WriteTagToFile(file);
732 // statistic
733 uint32 tran;
734 tran=statistic.alltimetransferred & 0xFFFFFFFF;
735 CTagInt32 attag1(FT_ATTRANSFERRED, tran);
736 attag1.WriteTagToFile(file);
738 tran=statistic.alltimetransferred>>32;
739 CTagInt32 attag4(FT_ATTRANSFERREDHI, tran);
740 attag4.WriteTagToFile(file);
742 CTagInt32 attag2(FT_ATREQUESTED, statistic.GetAllTimeRequests());
743 attag2.WriteTagToFile(file);
745 CTagInt32 attag3(FT_ATACCEPTED, statistic.GetAllTimeAccepts());
746 attag3.WriteTagToFile(file);
748 // priority N permission
749 CTagInt32 priotag(FT_ULPRIORITY, IsAutoUpPriority() ? PR_AUTO : m_iUpPriority);
750 priotag.WriteTagToFile(file);
752 //AICH Filehash
753 if (HasProperAICHHashSet()) {
754 CTagString aichtag(FT_AICH_HASH, m_pAICHHashSet->GetMasterHash().GetString());
755 aichtag.WriteTagToFile(file);
758 // Kad sources
759 if (m_lastPublishTimeKadSrc){
760 CTagInt32 kadLastPubSrc(FT_KADLASTPUBLISHSRC, m_lastPublishTimeKadSrc);
761 kadLastPubSrc.WriteTagToFile(file);
764 // Kad notes
765 if (m_lastPublishTimeKadNotes){
766 CTagInt32 kadLastPubNotes(FT_KADLASTPUBLISHNOTES, m_lastPublishTimeKadNotes);
767 kadLastPubNotes.WriteTagToFile(file);
770 //other tags
771 for (size_t j = 0; j < m_taglist.size(); ++j){
772 if (m_taglist[j].IsInt() || m_taglist[j].IsStr()) {
773 m_taglist[j].WriteTagToFile(file);
776 return true;
780 void CKnownFile::CreateHashFromHashlist(const ArrayOfCMD4Hash& hashes, CMD4Hash* Output)
782 wxCHECK_RET(hashes.size(), wxT("No input to hash from in CreateHashFromHashlist"));
784 std::vector<byte> buffer(hashes.size() * MD4HASH_LENGTH);
785 std::vector<byte>::iterator it = buffer.begin();
787 for (size_t i = 0; i < hashes.size(); ++i) {
788 it = STLCopy_n(hashes[i].GetHash(), MD4HASH_LENGTH, it);
791 CreateHashFromInput(&buffer[0], buffer.size(), Output, NULL);
795 void CKnownFile::CreateHashFromFile(CFileAutoClose& file, uint64 offset, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut)
797 wxCHECK_RET(Length, wxT("No input to hash from in CreateHashFromFile"));
799 CFileArea area;
800 area.ReadAt(file, offset, Length);
802 CreateHashFromInput(area.GetBuffer(), Length, Output, pShaHashOut);
803 area.CheckError();
807 void CKnownFile::CreateHashFromInput(const byte* input, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut )
809 wxASSERT_MSG(Output || pShaHashOut, wxT("Nothing to do in CreateHashFromInput"));
810 wxCHECK_RET(input, wxT("No input to hash from in CreateHashFromInput"));
811 wxASSERT(Length <= PARTSIZE); // We never hash more than one PARTSIZE
813 CMemFile data(input, Length);
815 uint32 Required = Length;
816 byte X[64*128];
818 uint32 posCurrentEMBlock = 0;
819 uint32 nIACHPos = 0;
820 CScopedPtr<CAICHHashAlgo> pHashAlg(CAICHHashSet::GetNewHashAlgo());
822 // This is all AICH.
823 while (Required >= 64) {
824 uint32 len = Required / 64;
825 if (len > sizeof(X)/(64 * sizeof(X[0]))) {
826 len = sizeof(X)/(64 * sizeof(X[0]));
829 data.Read(&X, len * 64);
831 // SHA hash needs 180KB blocks
832 if (pShaHashOut) {
833 if (nIACHPos + len*64 >= EMBLOCKSIZE) {
834 uint32 nToComplete = EMBLOCKSIZE - nIACHPos;
835 pHashAlg->Add(X, nToComplete);
836 wxASSERT( nIACHPos + nToComplete == EMBLOCKSIZE );
837 pShaHashOut->SetBlockHash(EMBLOCKSIZE, posCurrentEMBlock, pHashAlg.get());
838 posCurrentEMBlock += EMBLOCKSIZE;
839 pHashAlg->Reset();
840 pHashAlg->Add(X+nToComplete,(len*64) - nToComplete);
841 nIACHPos = (len*64) - nToComplete;
843 else{
844 pHashAlg->Add(X, len*64);
845 nIACHPos += len*64;
849 Required -= len*64;
851 // bytes to read
852 Required = Length % 64;
853 if (Required != 0){
854 data.Read(&X,Required);
856 if (pShaHashOut != NULL){
857 if (nIACHPos + Required >= EMBLOCKSIZE){
858 uint32 nToComplete = EMBLOCKSIZE - nIACHPos;
859 pHashAlg->Add(X, nToComplete);
860 wxASSERT( nIACHPos + nToComplete == EMBLOCKSIZE );
861 pShaHashOut->SetBlockHash(EMBLOCKSIZE, posCurrentEMBlock, pHashAlg.get());
862 posCurrentEMBlock += EMBLOCKSIZE;
863 pHashAlg->Reset();
864 pHashAlg->Add(X+nToComplete, Required - nToComplete);
865 nIACHPos = Required - nToComplete;
867 else{
868 pHashAlg->Add(X, Required);
869 nIACHPos += Required;
873 if (pShaHashOut != NULL){
874 if(nIACHPos > 0){
875 pShaHashOut->SetBlockHash(nIACHPos, posCurrentEMBlock, pHashAlg.get());
876 posCurrentEMBlock += nIACHPos;
878 wxASSERT( posCurrentEMBlock == Length );
879 wxCHECK2( pShaHashOut->ReCalculateHash(pHashAlg.get(), false), );
882 if (Output != NULL){
883 #ifdef __WEAK_CRYPTO__
884 CryptoPP::Weak::MD4 md4_hasher;
885 #else
886 CryptoPP::MD4 md4_hasher;
887 #endif
888 md4_hasher.CalculateDigest(Output->GetHash(), input, Length);
893 const CMD4Hash& CKnownFile::GetPartHash(uint16 part) const {
894 wxASSERT( part < m_hashlist.size() );
896 return m_hashlist[part];
899 CPacket* CKnownFile::CreateSrcInfoPacket(const CUpDownClient* forClient, uint8 byRequestedVersion, uint16 nRequestedOptions)
901 // Kad reviewed
903 if (m_ClientUploadList.empty()) {
904 return NULL;
907 if ((((CKnownFile*)forClient->GetRequestFile() != this)
908 && ((CKnownFile*)forClient->GetUploadFile() != this)) || forClient->GetUploadFileID() != GetFileHash()) {
909 wxString file1 = _("Unknown");
910 if (forClient->GetRequestFile() && forClient->GetRequestFile()->GetFileName().IsOk()) {
911 file1 = forClient->GetRequestFile()->GetFileName().GetPrintable();
912 } else if (forClient->GetUploadFile() && forClient->GetUploadFile()->GetFileName().IsOk()) {
913 file1 = forClient->GetUploadFile()->GetFileName().GetPrintable();
915 wxString file2 = _("Unknown");
916 if (GetFileName().IsOk()) {
917 file2 = GetFileName().GetPrintable();
919 AddDebugLogLineM(false, logKnownFiles, wxT("File missmatch on source packet (K) Sending: ") + file1 + wxT(" From: ") + file2);
920 return NULL;
923 const BitVector& rcvstatus = forClient->GetUpPartStatus();
924 bool SupportsUploadChunksState = !rcvstatus.empty();
925 //wxASSERT(rcvstatus.size() == GetPartCount()); // Obviously!
926 if (rcvstatus.size() != GetPartCount()) {
927 // Yuck. Same file but different part count? Seriously fucked up.
928 AddDebugLogLineM(false, logKnownFiles, CFormat(wxT("Impossible situation: different partcounts for the same known file: %i (client) and %i (file)")) % rcvstatus.size() % GetPartCount());
929 return NULL;
932 CMemFile data(1024);
934 uint8 byUsedVersion;
935 bool bIsSX2Packet;
936 if (forClient->SupportsSourceExchange2() && byRequestedVersion > 0){
937 // the client uses SourceExchange2 and requested the highest version he knows
938 // and we send the highest version we know, but of course not higher than his request
939 byUsedVersion = std::min(byRequestedVersion, (uint8)SOURCEEXCHANGE2_VERSION);
940 bIsSX2Packet = true;
941 data.WriteUInt8(byUsedVersion);
943 // we don't support any special SX2 options yet, reserved for later use
944 if (nRequestedOptions != 0) {
945 AddDebugLogLineM(false, logKnownFiles, CFormat(wxT("Client requested unknown options for SourceExchange2: %u")) % nRequestedOptions);
947 } else {
948 byUsedVersion = forClient->GetSourceExchange1Version();
949 bIsSX2Packet = false;
950 if (forClient->SupportsSourceExchange2()) {
951 AddDebugLogLineM(false, logKnownFiles, wxT("Client which announced to support SX2 sent SX1 packet instead"));
955 uint16 nCount = 0;
957 data.WriteHash(forClient->GetUploadFileID());
958 data.WriteUInt16(nCount);
959 uint32 cDbgNoSrc = 0;
961 SourceSet::iterator it = m_ClientUploadList.begin();
962 for ( ; it != m_ClientUploadList.end(); it++ ) {
963 const CUpDownClient *cur_src = *it;
965 if ( cur_src->HasLowID() ||
966 cur_src == forClient ||
967 !( cur_src->GetUploadState() == US_UPLOADING ||
968 cur_src->GetUploadState() == US_ONUPLOADQUEUE)) {
969 continue;
972 bool bNeeded = false;
974 if ( SupportsUploadChunksState ) {
975 const BitVector& srcstatus = cur_src->GetUpPartStatus();
976 if ( !srcstatus.empty() ) {
977 //wxASSERT(srcstatus.size() == GetPartCount()); // Obviously!
978 if (srcstatus.size() != GetPartCount()) {
979 continue;
981 if ( cur_src->GetUpPartCount() == forClient->GetUpPartCount() ) {
982 for (int x = 0; x < GetPartCount(); x++ ) {
983 if ( srcstatus.get(x) && !rcvstatus.get(x) ) {
984 // We know the receiving client needs
985 // a chunk from this client.
986 bNeeded = true;
987 break;
991 } else {
992 cDbgNoSrc++;
993 // This client doesn't support upload chunk status.
994 // So just send it and hope for the best.
995 bNeeded = true;
997 } else {
998 // remote client does not support upload chunk status,
999 // search sources which have at least one complete part
1000 // we could even sort the list of sources by available
1001 // chunks to return as much sources as possible which
1002 // have the most available chunks. but this could be
1003 // a noticeable performance problem.
1004 const BitVector& srcstatus = cur_src->GetUpPartStatus();
1005 if ( !srcstatus.empty() ) {
1006 //wxASSERT(srcstatus.size() == GetPartCount());
1007 if (srcstatus.size() != GetPartCount()) {
1008 continue;
1010 for (int x = 0; x < GetPartCount(); x++ ) {
1011 if ( srcstatus.get(x) ) {
1012 // this client has at least one chunk
1013 bNeeded = true;
1014 break;
1017 } else {
1018 // This client doesn't support upload chunk status.
1019 // So just send it and hope for the best.
1020 bNeeded = true;
1024 if ( bNeeded ) {
1025 nCount++;
1026 uint32 dwID;
1027 if(byUsedVersion >= 3) {
1028 dwID = cur_src->GetUserIDHybrid();
1029 } else {
1030 dwID = cur_src->GetIP();
1032 data.WriteUInt32(dwID);
1033 data.WriteUInt16(cur_src->GetUserPort());
1034 data.WriteUInt32(cur_src->GetServerIP());
1035 data.WriteUInt16(cur_src->GetServerPort());
1037 if (byUsedVersion >= 2) {
1038 data.WriteHash(cur_src->GetUserHash());
1041 if (byUsedVersion >= 4){
1042 // CryptSettings - SourceExchange V4
1043 // 5 Reserved (!)
1044 // 1 CryptLayer Required
1045 // 1 CryptLayer Requested
1046 // 1 CryptLayer Supported
1047 const uint8 uSupportsCryptLayer = cur_src->SupportsCryptLayer() ? 1 : 0;
1048 const uint8 uRequestsCryptLayer = cur_src->RequestsCryptLayer() ? 1 : 0;
1049 const uint8 uRequiresCryptLayer = cur_src->RequiresCryptLayer() ? 1 : 0;
1050 const uint8 byCryptOptions = (uRequiresCryptLayer << 2) | (uRequestsCryptLayer << 1) | (uSupportsCryptLayer << 0);
1051 data.WriteUInt8(byCryptOptions);
1054 if (nCount > 500) {
1055 break;
1060 if (!nCount) {
1061 return 0;
1064 data.Seek(bIsSX2Packet ? 17 : 16, wxFromStart);
1065 data.WriteUInt16(nCount);
1067 CPacket* result = new CPacket(data, OP_EMULEPROT, bIsSX2Packet ? OP_ANSWERSOURCES2 : OP_ANSWERSOURCES);
1069 if ( result->GetPacketSize() > 354 ) {
1070 result->PackPacket();
1073 return result;
1077 // Updates priority of file if autopriority is activated
1078 void CKnownFile::UpdateAutoUpPriority()
1080 if (IsAutoUpPriority()) {
1081 uint32 queued = GetQueuedCount();
1082 uint8 priority = PR_NORMAL;
1084 if (queued > 20) {
1085 priority = PR_LOW;
1086 } else if (queued > 1) {
1087 priority = PR_NORMAL;
1088 } else {
1089 priority = PR_HIGH;
1092 if (GetUpPriority() != priority) {
1093 SetUpPriority(priority, false);
1094 Notify_SharedFilesUpdateItem(this);
1099 void CKnownFile::SetFileComment(const wxString& strNewComment)
1101 if (m_strComment != strNewComment) {
1102 SetLastPublishTimeKadNotes(0);
1103 wxString strCfgPath = wxT("/") + m_abyFileHash.Encode() + wxT("/");
1105 wxConfigBase* cfg = wxConfigBase::Get();
1106 cfg->Write( strCfgPath + wxT("Comment"), strNewComment);
1108 m_strComment = strNewComment;
1110 SourceSet::iterator it = m_ClientUploadList.begin();
1111 for ( ; it != m_ClientUploadList.end(); it++ ) {
1112 (*it)->SetCommentDirty();
1118 // For File rate
1119 void CKnownFile::SetFileRating(int8 iNewRating)
1121 if (m_iRating != iNewRating) {
1122 SetLastPublishTimeKadNotes(0);
1123 wxString strCfgPath = wxT("/") + m_abyFileHash.Encode() + wxT("/");
1124 wxConfigBase* cfg = wxConfigBase::Get();
1125 cfg->Write( strCfgPath + wxT("Rate"), (int)iNewRating);
1126 m_iRating = iNewRating;
1128 SourceSet::iterator it = m_ClientUploadList.begin();
1129 for ( ; it != m_ClientUploadList.end(); it++ ) {
1130 (*it)->SetCommentDirty();
1136 void CKnownFile::SetUpPriority(uint8 iNewUpPriority, bool m_bsave){
1137 m_iUpPriority = iNewUpPriority;
1138 if( IsPartFile() && m_bsave ) {
1139 ((CPartFile*)this)->SavePartFile();
1143 void CKnownFile::SetPublishedED2K(bool val){
1144 m_PublishedED2K = val;
1145 Notify_SharedFilesUpdateItem(this);
1148 bool CKnownFile::PublishNotes()
1150 if(m_lastPublishTimeKadNotes > (uint32)time(NULL)) {
1151 return false;
1154 if(!GetFileComment().IsEmpty()) {
1155 m_lastPublishTimeKadNotes = (uint32)time(NULL)+KADEMLIAREPUBLISHTIMEN;
1156 return true;
1159 if(GetFileRating() != 0) {
1160 m_lastPublishTimeKadNotes = (uint32)time(NULL)+KADEMLIAREPUBLISHTIMEN;
1161 return true;
1164 return false;
1167 bool CKnownFile::PublishSrc()
1169 uint32 lastBuddyIP = 0;
1171 if( theApp->IsFirewalled() ) {
1172 CUpDownClient* buddy = theApp->clientlist->GetBuddy();
1173 if( buddy ) {
1174 lastBuddyIP = theApp->clientlist->GetBuddy()->GetIP();
1175 if( lastBuddyIP != m_lastBuddyIP ) {
1176 SetLastPublishTimeKadSrc( (uint32)time(NULL)+KADEMLIAREPUBLISHTIMES, lastBuddyIP );
1177 return true;
1179 } else {
1180 return false;
1184 if(m_lastPublishTimeKadSrc > (uint32)time(NULL)) {
1185 return false;
1188 SetLastPublishTimeKadSrc((uint32)time(NULL)+KADEMLIAREPUBLISHTIMES,lastBuddyIP);
1189 return true;
1193 void CKnownFile::UpdatePartsInfo()
1195 // Cache part count
1196 uint16 partcount = GetPartCount();
1197 bool flag = (time(NULL) - m_nCompleteSourcesTime > 0);
1199 // Ensure the frequency-list is ready
1200 if ( m_AvailPartFrequency.size() != GetPartCount() ) {
1201 m_AvailPartFrequency.clear();
1202 m_AvailPartFrequency.insert(m_AvailPartFrequency.begin(), GetPartCount(), 0);
1205 if (flag) {
1206 ArrayOfUInts16 count;
1207 count.reserve(m_ClientUploadList.size());
1209 SourceSet::iterator it = m_ClientUploadList.begin();
1210 for ( ; it != m_ClientUploadList.end(); it++ ) {
1211 if ( !(*it)->GetUpPartStatus().empty() && (*it)->GetUpPartCount() == partcount ) {
1212 count.push_back((*it)->GetUpCompleteSourcesCount());
1216 m_nCompleteSourcesCount = m_nCompleteSourcesCountLo = m_nCompleteSourcesCountHi = 0;
1218 if( partcount > 0) {
1219 m_nCompleteSourcesCount = m_AvailPartFrequency[0];
1221 for (uint16 i = 1; i < partcount; ++i) {
1222 if( m_nCompleteSourcesCount > m_AvailPartFrequency[i]) {
1223 m_nCompleteSourcesCount = m_AvailPartFrequency[i];
1226 count.push_back(m_nCompleteSourcesCount);
1228 int32 n = count.size();
1229 if (n > 0) {
1230 std::sort(count.begin(), count.end(), std::less<uint16>());
1232 // calculate range
1233 int i = n >> 1; // (n / 2)
1234 int j = (n * 3) >> 2; // (n * 3) / 4
1235 int k = (n * 7) >> 3; // (n * 7) / 8
1237 // For complete files, trust the people your uploading to more...
1239 // For low guess and normal guess count
1240 // - If we see more sources then the guessed low and
1241 // normal, use what we see.
1242 // - If we see less sources then the guessed low,
1243 // adjust network accounts for 100%, we account for
1244 // 0% with what we see and make sure we are still
1245 // above the normal.
1246 // For high guess
1247 // Adjust 100% network and 0% what we see.
1248 if (n < 20) {
1249 if ( count[i] < m_nCompleteSourcesCount ) {
1250 m_nCompleteSourcesCountLo = m_nCompleteSourcesCount;
1251 } else {
1252 m_nCompleteSourcesCountLo = count[i];
1254 m_nCompleteSourcesCount= m_nCompleteSourcesCountLo;
1255 m_nCompleteSourcesCountHi = count[j];
1256 if( m_nCompleteSourcesCountHi < m_nCompleteSourcesCount ) {
1257 m_nCompleteSourcesCountHi = m_nCompleteSourcesCount;
1259 } else {
1260 // Many sources..
1261 // For low guess
1262 // Use what we see.
1263 // For normal guess
1264 // Adjust network accounts for 100%, we account for
1265 // 0% with what we see and make sure we are still above the low.
1266 // For high guess
1267 // Adjust network accounts for 100%, we account for 0%
1268 // with what we see and make sure we are still above the normal.
1270 m_nCompleteSourcesCountLo = m_nCompleteSourcesCount;
1271 m_nCompleteSourcesCount = count[j];
1272 if( m_nCompleteSourcesCount < m_nCompleteSourcesCountLo ) {
1273 m_nCompleteSourcesCount = m_nCompleteSourcesCountLo;
1275 m_nCompleteSourcesCountHi= count[k];
1276 if( m_nCompleteSourcesCountHi < m_nCompleteSourcesCount ) {
1277 m_nCompleteSourcesCountHi = m_nCompleteSourcesCount;
1281 m_nCompleteSourcesTime = time(NULL) + (60);
1284 Notify_SharedFilesUpdateItem(this);
1288 void CKnownFile::UpdateUpPartsFrequency( CUpDownClient* client, bool increment )
1290 if ( m_AvailPartFrequency.size() != GetPartCount() ) {
1291 m_AvailPartFrequency.clear();
1292 m_AvailPartFrequency.insert(m_AvailPartFrequency.begin(), GetPartCount(), 0);
1293 if ( !increment ) {
1294 return;
1298 const BitVector& freq = client->GetUpPartStatus();
1299 unsigned int size = freq.size();
1300 if ( size != m_AvailPartFrequency.size() ) {
1301 return;
1304 if ( increment ) {
1305 for ( unsigned int i = 0; i < size; ++i ) {
1306 if ( freq.get(i) ) {
1307 m_AvailPartFrequency[i]++;
1310 } else {
1311 for ( unsigned int i = 0; i < size; ++i ) {
1312 if ( freq.get(i) ) {
1313 m_AvailPartFrequency[i]--;
1319 void CKnownFile::ClearPriority() {
1320 if ( !m_bAutoUpPriority ) return;
1321 m_iUpPriority = ( m_bAutoUpPriority ) ? PR_HIGH : PR_NORMAL;
1322 UpdateAutoUpPriority();
1325 void GuessAndRemoveExt(CPath& name)
1327 wxString ext = name.GetExt();
1329 // Remove common two-part extensions, such as "tar.gz"
1330 if (ext == wxT("gz") || ext == wxT("bz2")) {
1331 name = name.RemoveExt();
1332 if (name.GetExt() == wxT("tar")) {
1333 name = name.RemoveExt();
1335 // might be an extension if length == 3
1336 // and also remove some common non-three-character extensions
1337 } else if (ext.Length() == 3 ||
1338 ext == wxT("7z") ||
1339 ext == wxT("rm") ||
1340 ext == wxT("jpeg") ||
1341 ext == wxT("mpeg")
1343 name = name.RemoveExt();
1347 void CKnownFile::SetFileName(const CPath& filename)
1349 CAbstractFile::SetFileName(filename);
1350 wordlist.clear();
1351 // Don't publish extension. That'd kill the node indexing e.g. "avi".
1352 CPath tmpName = GetFileName();
1353 GuessAndRemoveExt(tmpName);
1354 Kademlia::CSearchManager::GetWords(tmpName.GetPrintable(), &wordlist);
1357 #endif // CLIENT_GUI
1359 //For File Comment //
1360 void CKnownFile::LoadComment()
1362 #ifndef CLIENT_GUI
1363 wxString strCfgPath = wxT("/") + m_abyFileHash.Encode() + wxT("/");
1365 wxConfigBase* cfg = wxConfigBase::Get();
1367 m_strComment = cfg->Read( strCfgPath + wxT("Comment"), wxEmptyString);
1368 m_iRating = cfg->Read( strCfgPath + wxT("Rate"), 0l);
1369 m_bCommentLoaded = true;
1371 #else
1372 m_strComment.Clear();
1373 m_bCommentLoaded = true;
1374 m_iRating =0;
1375 #endif
1380 wxString CKnownFile::GetAICHMasterHash() const
1382 #ifdef CLIENT_GUI
1383 return m_AICHMasterHash;
1384 #else
1385 if (HasProperAICHHashSet()) {
1386 return m_pAICHHashSet->GetMasterHash().GetString();
1389 return wxEmptyString;
1390 #endif
1394 bool CKnownFile::HasProperAICHHashSet() const
1396 #ifdef CLIENT_GUI
1397 return m_AICHMasterHash.Length() != 0;
1398 #else
1399 return m_pAICHHashSet->HasValidMasterHash() &&
1400 (m_pAICHHashSet->GetStatus() == AICH_HASHSETCOMPLETE ||
1401 m_pAICHHashSet->GetStatus() == AICH_VERIFIED);
1402 #endif
1405 wxString CKnownFile::GetFeedback() const
1407 return wxString(_("File name")) + wxT(": ") + GetFileName().GetPrintable() + wxT("\n")
1408 + _("File size") + wxT(": ") + CastItoXBytes(GetFileSize()) + wxT("\n")
1409 + _("Share ratio") + wxString::Format(wxT(": %.2f%%\n"), (((double)statistic.GetAllTimeTransferred() / (double)GetFileSize()) * 100.0))
1410 + _("Uploaded") + wxT(": ") + CastItoXBytes(statistic.GetTransferred()) + wxT(" (") + CastItoXBytes(statistic.GetAllTimeTransferred()) + wxT(")\n")
1411 + _("Requested") + CFormat(wxT(": %u (%u)\n")) % statistic.GetRequests() % statistic.GetAllTimeRequests()
1412 + _("Accepted") + CFormat(wxT(": %u (%u)\n")) % statistic.GetAccepts() % statistic.GetAllTimeAccepts()
1413 + _("On Queue") + CFormat(wxT(": %u\n")) % GetQueuedCount()
1414 + _("Complete sources") + CFormat(wxT(": %u\n")) % m_nCompleteSourcesCount;
1417 // File_checked_for_headers