From: <arn...@us...> - 2006-09-18 18:16:57
|
Revision: 649 http://svn.sourceforge.net/dcplusplus/?rev=649&view=rev Author: arnetheduck Date: 2006-09-18 11:13:50 -0700 (Mon, 18 Sep 2006) Log Message: ----------- Removed non-hashing support Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ADLSearch.cpp dcplusplus/trunk/client/ADLSearch.h dcplusplus/trunk/client/AdcCommand.cpp dcplusplus/trunk/client/AdcCommand.h dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/BZUtils.cpp dcplusplus/trunk/client/BitInputStream.h dcplusplus/trunk/client/BitOutputStream.h dcplusplus/trunk/client/BloomFilter.h dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/CID.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/ClientManagerListener.h dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/ConnectionManager.h dcplusplus/trunk/client/ConnectionManagerListener.h dcplusplus/trunk/client/CriticalSection.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/CryptoManager.h dcplusplus/trunk/client/DCPlusPlus.cpp dcplusplus/trunk/client/DCPlusPlus.h dcplusplus/trunk/client/DirectoryListing.cpp dcplusplus/trunk/client/DirectoryListing.h dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/Exception.h dcplusplus/trunk/client/FastAlloc.h dcplusplus/trunk/client/FavoriteManager.cpp dcplusplus/trunk/client/FavoriteManager.h dcplusplus/trunk/client/File.h dcplusplus/trunk/client/FinishedManager.cpp dcplusplus/trunk/client/FinishedManager.h dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/client/HttpConnection.cpp dcplusplus/trunk/client/HttpConnection.h dcplusplus/trunk/client/LogManager.h dcplusplus/trunk/client/MerkleCheckOutputStream.h dcplusplus/trunk/client/MerkleTree.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/client/Pointer.h dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/QueueManagerListener.h dcplusplus/trunk/client/ResourceManager.cpp dcplusplus/trunk/client/ResourceManager.h dcplusplus/trunk/client/SFVReader.cpp dcplusplus/trunk/client/SFVReader.h dcplusplus/trunk/client/SearchManager.cpp dcplusplus/trunk/client/SearchManager.h dcplusplus/trunk/client/SearchManagerListener.h dcplusplus/trunk/client/Semaphore.h dcplusplus/trunk/client/ServerSocket.h dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/SimpleXML.cpp dcplusplus/trunk/client/SimpleXML.h dcplusplus/trunk/client/Singleton.h dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/Speaker.h dcplusplus/trunk/client/Streams.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/StringSearch.h dcplusplus/trunk/client/Text.cpp dcplusplus/trunk/client/Thread.h dcplusplus/trunk/client/TigerHash.cpp dcplusplus/trunk/client/TimerManager.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/UploadManager.h dcplusplus/trunk/client/User.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/client/UserCommand.h dcplusplus/trunk/client/UserConnection.cpp dcplusplus/trunk/client/UserConnection.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/client/ZUtils.cpp dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/windows/ADLSProperties.h dcplusplus/trunk/windows/ADLSearchFrame.cpp dcplusplus/trunk/windows/ADLSearchFrame.h dcplusplus/trunk/windows/AboutDlg.h dcplusplus/trunk/windows/Advanced3Page.cpp dcplusplus/trunk/windows/Advanced3Page.h dcplusplus/trunk/windows/AdvancedPage.h dcplusplus/trunk/windows/Appearance2Page.cpp dcplusplus/trunk/windows/Appearance2Page.h dcplusplus/trunk/windows/AppearancePage.cpp dcplusplus/trunk/windows/AppearancePage.h dcplusplus/trunk/windows/CertificatesPage.h dcplusplus/trunk/windows/CommandDlg.cpp dcplusplus/trunk/windows/DirectoryListingFrm.cpp dcplusplus/trunk/windows/DirectoryListingFrm.h dcplusplus/trunk/windows/DownloadPage.cpp dcplusplus/trunk/windows/DownloadPage.h dcplusplus/trunk/windows/ExListViewCtrl.cpp dcplusplus/trunk/windows/ExListViewCtrl.h dcplusplus/trunk/windows/ExtendedTrace.cpp dcplusplus/trunk/windows/FavHubProperties.h dcplusplus/trunk/windows/FavoriteDirsPage.cpp dcplusplus/trunk/windows/FavoriteDirsPage.h dcplusplus/trunk/windows/FavoritesFrm.cpp dcplusplus/trunk/windows/FavoritesFrm.h dcplusplus/trunk/windows/FinishedFrame.h dcplusplus/trunk/windows/FinishedFrameBase.h dcplusplus/trunk/windows/FinishedULFrame.h dcplusplus/trunk/windows/FlatTabCtrl.h dcplusplus/trunk/windows/GeneralPage.cpp dcplusplus/trunk/windows/GeneralPage.h dcplusplus/trunk/windows/HashProgressDlg.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h dcplusplus/trunk/windows/LineDlg.h dcplusplus/trunk/windows/LogPage.cpp dcplusplus/trunk/windows/LogPage.h dcplusplus/trunk/windows/MagnetDlg.h dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/windows/MainFrm.h dcplusplus/trunk/windows/MemDC.h dcplusplus/trunk/windows/NetworkPage.cpp dcplusplus/trunk/windows/NetworkPage.h dcplusplus/trunk/windows/NotepadFrame.cpp dcplusplus/trunk/windows/NotepadFrame.h dcplusplus/trunk/windows/PrivateFrame.cpp dcplusplus/trunk/windows/PrivateFrame.h dcplusplus/trunk/windows/PublicHubsFrm.cpp dcplusplus/trunk/windows/PublicHubsFrm.h dcplusplus/trunk/windows/QueueFrame.cpp dcplusplus/trunk/windows/QueueFrame.h dcplusplus/trunk/windows/QueuePage.h dcplusplus/trunk/windows/SearchFrm.cpp dcplusplus/trunk/windows/SearchFrm.h dcplusplus/trunk/windows/SpyFrame.cpp dcplusplus/trunk/windows/SpyFrame.h dcplusplus/trunk/windows/StatsFrame.cpp dcplusplus/trunk/windows/StatsFrame.h dcplusplus/trunk/windows/SystemFrame.cpp dcplusplus/trunk/windows/SystemFrame.h dcplusplus/trunk/windows/TextFrame.cpp dcplusplus/trunk/windows/TextFrame.h dcplusplus/trunk/windows/TransferView.cpp dcplusplus/trunk/windows/TransferView.h dcplusplus/trunk/windows/TreePropertySheet.cpp dcplusplus/trunk/windows/TreePropertySheet.h dcplusplus/trunk/windows/TypedListViewCtrl.h dcplusplus/trunk/windows/UCPage.cpp dcplusplus/trunk/windows/UCPage.h dcplusplus/trunk/windows/UPnP.cpp dcplusplus/trunk/windows/UploadPage.cpp dcplusplus/trunk/windows/UploadPage.h dcplusplus/trunk/windows/UsersFrame.cpp dcplusplus/trunk/windows/UsersFrame.h dcplusplus/trunk/windows/WaitingUsersFrame.cpp dcplusplus/trunk/windows/WaitingUsersFrame.h dcplusplus/trunk/windows/WinUtil.cpp dcplusplus/trunk/windows/WinUtil.h dcplusplus/trunk/windows/WindowsPage.h dcplusplus/trunk/windows/main.cpp dcplusplus/trunk/windows/stdafx.h Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/Example.xml 2006-09-18 18:13:50 UTC (rev 649) @@ -551,6 +551,7 @@ <String Name="SocksFailed">The socks server failed establish a connection</String> <String Name="SocksNeedsAuth">The socks server requires authentication</String> <String Name="SocksSetupError">Failed to set up the socks server for UDP relay (check socks address and port)</String> + <String Name="SourceTooOld">Source client does not support TTH</String> <String Name="SourceTooSlow">Source too slow</String> <String Name="SourceType">Source Type</String> <String Name="SpecifySearchString">Specify a search string</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/changelog.txt 2006-09-18 18:13:50 UTC (rev 649) @@ -1,4 +1,12 @@ --- 0.695 2006-09-10 -- +-- -- +* Fixed a possible deadlock +* [bug 1058] Removed some whitespace (big thanks to pothead) +* Removed the possibility to download files without TTH +* Removed the possibility to read *.DcLst files (no TTH, no i18n support) +* Files with no TTH no longer show up in search and directory listings +* Fixed support for uncompressed files.xml + +-- 0.695 2006-09-10 -- * PM popup/ignore options updated, in nmdc a hub is any nick which hasn't sent a hello or myinfo, and a bot is a nick with myinfo without connection type * [bug 125] Fixed out-of-order PM/quit Modified: dcplusplus/trunk/client/ADLSearch.cpp =================================================================== --- dcplusplus/trunk/client/ADLSearch.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ADLSearch.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -72,7 +72,7 @@ } if(xml.findChild("IsActive")) { search.isActive = (Util::toInt(xml.getChildData()) != 0); - } + } if(xml.findChild("MaxSize")) { search.maxFileSize = Util::toInt64(xml.getChildData()); } @@ -163,7 +163,7 @@ xml.stepOut(); - // Save string to file + // Save string to file try { File fout(getConfigFile(), File::WRITE, File::CREATE | File::TRUNCATE); fout.write(SimpleXML::utf8Header); @@ -183,7 +183,7 @@ if(id->subdir != NULL) { DirectoryListing::File *copyFile = new DirectoryListing::File(*currentFile, true); dcassert(id->subdir->getAdls()); - + id->subdir->files.push_back(copyFile); } id->fileAdded = false; // Prepare for next stage @@ -207,7 +207,7 @@ if(is->isAutoQueue){ QueueManager::getInstance()->add(SETTING(DOWNLOAD_DIRECTORY) + currentFile->getName(), - currentFile->getSize(), currentFile->getTTH(), getUser(), currentFile->getName()); + currentFile->getSize(), currentFile->getTTH(), getUser()); } if(breakOnFirst) { @@ -222,7 +222,7 @@ // Add to any substructure being stored for(DestDirList::iterator id = destDirVector.begin(); id != destDirVector.end(); ++id) { if(id->subdir != NULL) { - DirectoryListing::Directory* newDir = + DirectoryListing::Directory* newDir = new DirectoryListing::AdlDirectory(fullPath, id->subdir, currentDir->getName()); id->subdir->directories.push_back(newDir); id->subdir = newDir; @@ -240,7 +240,7 @@ continue; } if(is->MatchesDirectory(currentDir->getName())) { - destDirVector[is->ddIndex].subdir = + destDirVector[is->ddIndex].subdir = new DirectoryListing::AdlDirectory(fullPath, destDirVector[is->ddIndex].dir, currentDir->getName()); destDirVector[is->ddIndex].dir->directories.push_back(destDirVector[is->ddIndex].subdir); if(breakOnFirst) { Modified: dcplusplus/trunk/client/ADLSearch.h =================================================================== --- dcplusplus/trunk/client/ADLSearch.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ADLSearch.h 2006-09-18 18:13:50 UTC (rev 649) @@ -47,7 +47,7 @@ public: // Constructor - ADLSearch() : searchString("<Enter string>"), isActive(true), isAutoQueue(false), sourceType(OnlyFile), + ADLSearch() : searchString("<Enter string>"), isActive(true), isAutoQueue(false), sourceType(OnlyFile), minFileSize(-1), maxFileSize(-1), typeFileSize(SizeBytes), destDir("ADLSearch"), ddIndex(0) {} // Prepare search @@ -69,7 +69,7 @@ } // The search string - string searchString; + string searchString; // Active search bool isActive; @@ -116,12 +116,12 @@ } } - // Maximum & minimum file sizes (in bytes). + // Maximum & minimum file sizes (in bytes). // Negative values means do not check. int64_t minFileSize; int64_t maxFileSize; enum SizeType { - SizeBytes = TypeFirst, + SizeBytes = TypeFirst, SizeKibiBytes, SizeMebiBytes, SizeGibiBytes @@ -172,7 +172,7 @@ string destDir; unsigned long ddIndex; - // Search for file match + // Search for file match bool MatchesFile(const string& f, const string& fp, int64_t size) { // Check status if(!isActive) { @@ -200,7 +200,7 @@ } } - // Search for directory match + // Search for directory match bool MatchesDirectory(const string& d) { // Check status if(!isActive) { Modified: dcplusplus/trunk/client/AdcCommand.cpp =================================================================== --- dcplusplus/trunk/client/AdcCommand.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/AdcCommand.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -84,7 +84,7 @@ else throw ParseException("Unknown escape"); break; - case ' ': + case ' ': // New parameter... { if((type == TYPE_BROADCAST || type == TYPE_DIRECT || type == TYPE_FEATURE) && !fromSet) { @@ -179,7 +179,7 @@ string AdcCommand::getHeaderString(const CID& cid) const { dcassert(type == TYPE_UDP); string tmp; - + tmp += getType(); tmp += cmdChar; tmp += ' '; @@ -213,7 +213,7 @@ bool AdcCommand::hasFlag(const char* name, size_t start) const { for(string::size_type i = start; i < getParameters().size(); ++i) { - if(toCode(name) == toCode(getParameters()[i].c_str()) && + if(toCode(name) == toCode(getParameters()[i].c_str()) && getParameters()[i][2] == '1' && getParameters()[i].size() == 3) { Modified: dcplusplus/trunk/client/AdcCommand.h =================================================================== --- dcplusplus/trunk/client/AdcCommand.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/AdcCommand.h 2006-09-18 18:13:50 UTC (rev 649) @@ -116,7 +116,7 @@ u_int32_t getCommand() const { return cmdInt; } char getType() const { return type; } void setType(char t) { type = t; } - + AdcCommand& setFeatures(const string& feat) { features = feat; return *this; } StringList& getParameters() { return parameters; } @@ -194,7 +194,7 @@ C(SND); C(SID); C(CMD); - default: + default: dcdebug("Unknown ADC command: %.50s\n", aLine.c_str()); break; #undef C Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -98,7 +98,7 @@ return; string cid; - + OnlineUser* u = 0; if(c.getParam("ID", 0, cid)) u = &getUser(c.getFrom(), CID(cid)); @@ -115,7 +115,7 @@ for(StringIterC i = c.getParameters().begin(); i != c.getParameters().end(); ++i) { if(i->length() < 2) continue; - + u->getIdentity().set(i->c_str(), i->substr(2)); } @@ -195,7 +195,7 @@ fire(ClientListener::PrivateMessage(), this, *from, *to, *replyTo, c.getParam(0)); } else { fire(ClientListener::Message(), this, *from, c.getParam(0)); - } + } } void AdcHub::handle(AdcCommand::GPA, AdcCommand& c) throw() { @@ -272,7 +272,7 @@ AdcCommand cmd(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown"); cmd.setTo(c.getFrom()); cmd.addParam("PR", protocol); - + if(hasToken) cmd.addParam("TO", token); @@ -394,16 +394,16 @@ void AdcHub::hubMessage(const string& aMessage) { if(state != STATE_NORMAL) return; - send(AdcCommand(AdcCommand::CMD_MSG, AdcCommand::TYPE_BROADCAST).addParam(aMessage)); + send(AdcCommand(AdcCommand::CMD_MSG, AdcCommand::TYPE_BROADCAST).addParam(aMessage)); } -void AdcHub::privateMessage(const OnlineUser& user, const string& aMessage) { +void AdcHub::privateMessage(const OnlineUser& user, const string& aMessage) { if(state != STATE_NORMAL) return; - send(AdcCommand(AdcCommand::CMD_MSG, user.getIdentity().getSID()).addParam(aMessage).addParam("PM", getMySID())); + send(AdcCommand(AdcCommand::CMD_MSG, user.getIdentity().getSID()).addParam(aMessage).addParam("PM", getMySID())); } -void AdcHub::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) { +void AdcHub::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) { if(state != STATE_NORMAL) return; @@ -438,7 +438,7 @@ } } -void AdcHub::password(const string& pwd) { +void AdcHub::password(const string& pwd) { if(state != STATE_VERIFY) return; if(!salt.empty()) { @@ -511,8 +511,8 @@ string su; if(CryptoManager::getInstance()->TLSOk()) { su += ADCS_FEATURE + ","; - } - + } + if(ClientManager::getInstance()->isActive()) { if(BOOLSETTING(NO_IP_OVERRIDE) && !SETTING(EXTERNAL_IP).empty()) { ADDPARAM("I4", Socket::resolve(SETTING(EXTERNAL_IP))); @@ -558,23 +558,23 @@ return tmp; } -void AdcHub::on(Connected) throw() { +void AdcHub::on(Connected) throw() { dcassert(state == STATE_PROTOCOL); lastInfoMap.clear(); reconnect = true; send(AdcCommand(AdcCommand::CMD_SUP, AdcCommand::TYPE_HUB).addParam("ADBAS0")); - + fire(ClientListener::Connected(), this); } -void AdcHub::on(Line, const string& aLine) throw() { +void AdcHub::on(Line, const string& aLine) throw() { if(BOOLSETTING(ADC_DEBUG)) { fire(ClientListener::StatusMessage(), this, "<ADC>" + aLine + "</ADC>"); } - dispatch(aLine); + dispatch(aLine); } -void AdcHub::on(Failed, const string& aLine) throw() { +void AdcHub::on(Failed, const string& aLine) throw() { clearUsers(); socket->removeListener(this); state = STATE_PROTOCOL; Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/AdcHub.h 2006-09-18 18:13:50 UTC (rev 649) @@ -37,7 +37,7 @@ virtual void connect(const OnlineUser& user); void connect(const OnlineUser& user, string const& token, bool secure); - + virtual void hubMessage(const string& aMessage); virtual void privateMessage(const OnlineUser& user, const string& aMessage); virtual void sendUserCmd(const string& aUserCmd) { send(aUserCmd); } @@ -87,9 +87,9 @@ static const string ADCS_FEATURE; static const string TCP4_FEATURE; static const string UDP4_FEATURE; - + virtual string checkNick(const string& nick); - + OnlineUser& getUser(const u_int32_t aSID, const CID& aCID); OnlineUser* findUser(const u_int32_t sid) const; void putUser(const u_int32_t sid); @@ -109,7 +109,7 @@ void handle(AdcCommand::CMD, AdcCommand& c) throw(); void handle(AdcCommand::RES, AdcCommand& c) throw(); - template<typename T> void handle(T, AdcCommand&) { + template<typename T> void handle(T, AdcCommand&) { //Speaker<AdcHubListener>::fire(t, this, c); } Modified: dcplusplus/trunk/client/BZUtils.cpp =================================================================== --- dcplusplus/trunk/client/BZUtils.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/BZUtils.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -32,7 +32,7 @@ } BZFilter::~BZFilter() { - dcdebug("BZFilter end, %u/%u = %.04f\n", zs.total_out_lo32, zs.total_in_lo32, (float)zs.total_out_lo32 / max((float)zs.total_in_lo32, (float)1)); + dcdebug("BZFilter end, %u/%u = %.04f\n", zs.total_out_lo32, zs.total_in_lo32, (float)zs.total_out_lo32 / max((float)zs.total_in_lo32, (float)1)); BZ2_bzCompressEnd(&zs); } @@ -67,13 +67,13 @@ UnBZFilter::UnBZFilter() { memset(&zs, 0, sizeof(zs)); - if(BZ2_bzDecompressInit(&zs, 0, 0) != BZ_OK) + if(BZ2_bzDecompressInit(&zs, 0, 0) != BZ_OK) throw Exception(STRING(DECOMPRESSION_ERROR)); } UnBZFilter::~UnBZFilter() { - dcdebug("UnBZFilter end, %u/%u = %.04f\n", zs.total_out_lo32, zs.total_in_lo32, (float)zs.total_out_lo32 / max((float)zs.total_in_lo32, (float)1)); + dcdebug("UnBZFilter end, %u/%u = %.04f\n", zs.total_out_lo32, zs.total_in_lo32, (float)zs.total_out_lo32 / max((float)zs.total_in_lo32, (float)1)); BZ2_bzDecompressEnd(&zs); } Modified: dcplusplus/trunk/client/BitInputStream.h =================================================================== --- dcplusplus/trunk/client/BitInputStream.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/BitInputStream.h 2006-09-18 18:13:50 UTC (rev 649) @@ -37,7 +37,7 @@ public: BitInputStream(const u_int8_t* aStream, size_t aStart, size_t aEnd) : bitPos(aStart*8), endPos(aEnd*8), is(aStream) { } ~BitInputStream() { } - + bool get() throw(BitStreamException) { if(bitPos > endPos) { throw BitStreamException(STRING(SEEK_BEYOND_END)); @@ -46,12 +46,12 @@ bitPos++; return ret; } - + void skipToByte() { if(bitPos%8 != 0) bitPos = (bitPos & (~7)) + 8; } - + void skip(int n) { bitPos += n * 8; return ; @@ -59,7 +59,7 @@ private: BitInputStream(const BitInputStream&); BitInputStream& operator=(const BitInputStream&); - + size_t bitPos; size_t endPos; const u_int8_t* is; Modified: dcplusplus/trunk/client/BitOutputStream.h =================================================================== --- dcplusplus/trunk/client/BitOutputStream.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/BitOutputStream.h 2006-09-18 18:13:50 UTC (rev 649) @@ -28,20 +28,20 @@ public: BitOutputStream(string& aStream) : is(aStream), bitPos(0), next(0) { } ~BitOutputStream() { } - + void put(vector<u_int8_t>& b) { for(vector<u_int8_t>::iterator i = b.begin(); i != b.end(); ++i) { - next |= (*i) << bitPos++; - + next |= (*i) << bitPos++; + if(bitPos > 7) { bitPos-=8; is += next; next = 0; } - + } } - + void skipToByte() { if(bitPos > 0) { bitPos = 0; @@ -49,7 +49,7 @@ next = 0; } } - + private: BitOutputStream& operator=(const BitOutputStream&); string& is; Modified: dcplusplus/trunk/client/BloomFilter.h =================================================================== --- dcplusplus/trunk/client/BloomFilter.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/BloomFilter.h 2006-09-18 18:13:50 UTC (rev 649) @@ -38,14 +38,14 @@ ~BloomFilter() { } void add(const string& s) { xadd(s, N); } - bool match(const StringList& s) { + bool match(const StringList& s) { for(StringList::const_iterator i = s.begin(); i != s.end(); ++i) { if(!match(*i)) return false; } return true; } - bool match(const string& s) { + bool match(const string& s) { if(s.length() >= N) { string::size_type l = s.length() - N; for(string::size_type i = 0; i <= l; ++i) { @@ -78,7 +78,7 @@ for(string::size_type i = 0; i <= l; ++i) { table[getPos(s, i, n)] = true; } - } + } } /* Same functionality, but the old one did not want to compile for some reason. */ @@ -86,7 +86,7 @@ HashFunc hf; return (hf(&s[i], l) % table.size()); } - + vector<bool> table; }; Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -32,7 +32,7 @@ // Polling is used for tasks...should be fixed... #define POLL_TIMEOUT 250 -BufferedSocket::BufferedSocket(char aSeparator) throw() : +BufferedSocket::BufferedSocket(char aSeparator) throw() : separator(aSeparator), mode(MODE_LINE), filterIn(NULL), dataBytes(0), rollback(0), failed(false), sock(0), disconnecting(false) { @@ -167,9 +167,9 @@ // This socket has been closed... throw SocketException(STRING(CONNECTION_CLOSED)); } - size_t used; + size_t used; string::size_type pos = 0; - // always uncompressed data + // always uncompressed data string l; int bufpos = 0, total = left; @@ -177,7 +177,7 @@ switch (mode) { case MODE_ZPIPE: if (filterIn != NULL){ - const int BufSize = 1024; + const int BufSize = 1024; // Special to autodetect nmdc connections... string::size_type pos = 0; AutoArray<u_int8_t> buffer (BufSize); @@ -228,7 +228,7 @@ break; } } - if (pos == string::npos) + if (pos == string::npos) left = 0; line = l; break; @@ -268,7 +268,7 @@ dcassert(file != NULL); size_t sockSize = (size_t)sock->getSocketOptInt(SO_SNDBUF); size_t bufSize = max(sockSize, (size_t)64*1024); - + vector<u_int8_t> readBuf(bufSize); vector<u_int8_t> writeBuf(bufSize); @@ -411,19 +411,19 @@ switch(p.first) { case SEND_DATA: threadSendData(); break; - case SEND_FILE: + case SEND_FILE: threadSendFile(((SendFileInfo*)p.second)->stream); break; - case CONNECT: + case CONNECT: { ConnectInfo* ci = (ConnectInfo*)p.second; - threadConnect(ci->addr, ci->port, ci->proxy); + threadConnect(ci->addr, ci->port, ci->proxy); break; } - case DISCONNECT: - if(isConnected()) - fail(STRING(DISCONNECTED)); + case DISCONNECT: + if(isConnected()) + fail(STRING(DISCONNECTED)); break; - case SHUTDOWN: + case SHUTDOWN: return false; case ACCEPTED: break; @@ -476,11 +476,11 @@ } } -void BufferedSocket::shutdown() { +void BufferedSocket::shutdown() { if(sock) { - Lock l(cs); - disconnecting = true; - addTask(SHUTDOWN, 0); + Lock l(cs); + disconnecting = true; + addTask(SHUTDOWN, 0); } else { // Socket thread not running yet, disconnect... delete this; Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-09-18 18:13:50 UTC (rev 649) @@ -37,7 +37,7 @@ class BufferedSocketListener { public: virtual ~BufferedSocketListener() { } - template<int I> struct X { enum { TYPE = I }; }; + template<int I> struct X { enum { TYPE = I }; }; typedef X<0> Connecting; typedef X<1> Connected; @@ -72,12 +72,12 @@ * @param sep Line separator * @return An unconnected socket */ - static BufferedSocket* getSocket(char sep) throw() { - return new BufferedSocket(sep); + static BufferedSocket* getSocket(char sep) throw() { + return new BufferedSocket(sep); } - static void putSocket(BufferedSocket* aSock) { - aSock->removeListeners(); + static void putSocket(BufferedSocket* aSock) { + aSock->removeListeners(); aSock->shutdown(); } @@ -91,10 +91,10 @@ /** Sets data mode for aBytes bytes. Must be called within onLine. */ void setDataMode(int64_t aBytes = -1) { mode = MODE_DATA; dataBytes = aBytes; } - /** + /** * Rollback is an ugly hack to solve problems with compressed transfers where not all data received * should be treated as data. - * Must be called from within onData. + * Must be called from within onData. */ void setLineMode(size_t aRollback) { setMode (MODE_LINE, aRollback);} void setMode(Modes mode, size_t aRollback = 0); @@ -104,7 +104,7 @@ bool isSecure() const { return sock && sock->isSecure(); } bool isTrusted() const { return sock && sock->isTrusted(); } - + void write(const string& aData) throw() { write(aData.data(), aData.length()); } void write(const char* aBuf, size_t aLen) throw(); /** Send the file f over this socket. */ @@ -125,7 +125,7 @@ ACCEPTED }; - struct TaskData { + struct TaskData { virtual ~TaskData() { } }; struct ConnectInfo : public TaskData { @@ -172,8 +172,8 @@ void threadSendFile(InputStream* is) throw(Exception); void threadSendData(); void threadDisconnect(); - - void fail(const string& aError); + + void fail(const string& aError); static volatile long sockets; bool checkEvents(); Modified: dcplusplus/trunk/client/CID.h =================================================================== --- dcplusplus/trunk/client/CID.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/CID.h 2006-09-18 18:13:50 UTC (rev 649) @@ -42,7 +42,7 @@ string toBase32() const { return Encoder::toBase32(cid, sizeof(cid)); } string& toBase32(string& tmp) const { return Encoder::toBase32(cid, sizeof(cid), tmp); } - + size_t toHash() const { return *reinterpret_cast<const size_t*>(cid); } const u_int8_t* data() const { return cid; } Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/Client.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -29,9 +29,9 @@ Client::Counts Client::counts; -Client::Client(const string& hubURL, char separator_, bool secure_) : +Client::Client(const string& hubURL, char separator_, bool secure_) : myIdentity(ClientManager::getInstance()->getMe(), 0), - reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(true), reconnecting(false), socket(0), + reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(true), reconnecting(false), socket(0), hubUrl(hubURL), port(0), separator(separator_), secure(secure_), countType(COUNT_UNCOUNTED) { @@ -110,8 +110,8 @@ } void Client::on(Connected) throw() { - updateActivity(); - ip = socket->getIp(); + updateActivity(); + ip = socket->getIp(); fire(ClientListener::Connected(), this); } Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/Client.h 2006-09-18 18:13:50 UTC (rev 649) @@ -31,11 +31,11 @@ class Client; class AdcCommand; class ClientManager; -class ClientListener +class ClientListener { public: virtual ~ClientListener() { } - template<int I> struct X { enum { TYPE = I }; }; + template<int I> struct X { enum { TYPE = I }; }; typedef X<0> Connecting; typedef X<1> Connected; @@ -93,7 +93,7 @@ virtual void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) = 0; virtual void password(const string& pwd) = 0; virtual void info(bool force) = 0; - + virtual size_t getUserCount() const = 0; virtual int64_t getAvailable() const = 0; Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -59,7 +59,7 @@ fire(ClientManagerListener::ClientDisconnected(), aClient); aClient->removeListeners(); - + { Lock l(cs); clients.remove(aClient); @@ -166,7 +166,7 @@ url = c->getHubUrl(); } } - + return url; } @@ -189,7 +189,7 @@ UserIter ui = users.find(cid); if(ui != users.end()) { if(ui->second->getFirstNick().empty()) // Could happen on bad queue loads etc... - ui->second->setFirstNick(aNick); + ui->second->setFirstNick(aNick); ui->second->setFlag(User::NMDC); return ui->second; } @@ -326,8 +326,8 @@ } } -void ClientManager::on(NmdcSearch, Client* aClient, const string& aSeeker, int aSearchType, int64_t aSize, - int aFileType, const string& aString) throw() +void ClientManager::on(NmdcSearch, Client* aClient, const string& aSeeker, int aSearchType, int64_t aSize, + int aFileType, const string& aString) throw() { Speaker<ClientManagerListener>::fire(ClientManagerListener::IncomingSearch(), aString); @@ -337,7 +337,7 @@ if(isPassive && !ClientManager::getInstance()->isActive()) { return; } - + SearchResult::List l; ShareManager::getInstance()->search(l, aString, aSearchType, aSize, aFileType, aClient, isPassive ? 5 : 10); // dcdebug("Found %d items (%s)\n", l.size(), aString.c_str()); @@ -355,24 +355,24 @@ sr->decRef(); } - + if(str.size() > 0) aClient->send(str); - + } else { try { string ip, file; u_int16_t port = 0; Util::decodeUrl(aSeeker, ip, port, file); ip = Socket::resolve(ip); - + // Temporary fix to avoid spamming hublist.org and dcpp.net if(ip == "70.85.55.252" || ip == "207.44.220.108") { LogManager::getInstance()->message("Someone is trying to use your client to spam " + ip + ", please urge hub owner to fix this"); return; } - - if(port == 0) + + if(port == 0) port = 412; for(SearchResult::Iter i = l.begin(); i != l.end(); ++i) { SearchResult* sr = *i; @@ -405,7 +405,7 @@ void ClientManager::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) { Lock l(cs); - + updateCachedIp(); // no point in doing a resolve for every single hub we're searching on for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { @@ -520,7 +520,7 @@ while(xml.findChild("User")) { const string& cid = xml.getChildAttrib("CID"); const string& nick = xml.getChildAttrib("Nick"); - if(cid.length() != 39 || nick.empty()) + if(cid.length() != 39 || nick.empty()) continue; User::Ptr p(new User(CID(cid))); p->setFirstNick(xml.getChildData()); @@ -532,12 +532,12 @@ } } -void ClientManager::on(Failed, Client* client, const string&) throw() { +void ClientManager::on(Failed, Client* client, const string&) throw() { FavoriteManager::getInstance()->removeUserCommand(client->getHubUrl()); fire(ClientManagerListener::ClientDisconnected(), client); } -void ClientManager::on(UserCommand, Client* client, int aType, int ctx, const string& name, const string& command) throw() { +void ClientManager::on(UserCommand, Client* client, int aType, int ctx, const string& name, const string& command) throw() { if(BOOLSETTING(HUB_USER_COMMANDS)) { if(aType == ::UserCommand::TYPE_CLEAR) { FavoriteManager::getInstance()->removeHubUserCommands(ctx, client->getHubUrl()); Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ClientManager.h 2006-09-18 18:13:50 UTC (rev 649) @@ -33,8 +33,8 @@ class UserCommand; -class ClientManager : public Speaker<ClientManagerListener>, - private ClientListener, public Singleton<ClientManager>, +class ClientManager : public Speaker<ClientManagerListener>, + private ClientListener, public Singleton<ClientManager>, private TimerManagerListener, private SettingsManagerListener { public: @@ -49,7 +49,7 @@ string getConnection(const CID& cid); bool isConnected(const string& aUrl); - + void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken); void search(StringList& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken); void infoUpdated(); @@ -77,7 +77,7 @@ void putOffline(OnlineUser& ou) throw(); User::Ptr& getMe(); - + void connect(const User::Ptr& p); void send(AdcCommand& c, const CID& to); void privateMessage(const User::Ptr& p, const string& msg); @@ -85,7 +85,7 @@ void userCommand(const User::Ptr& p, const ::UserCommand& uc, StringMap& params, bool compatibility); bool isActive() { return SETTING(INCOMING_CONNECTIONS) != SettingsManager::INCOMING_FIREWALL_PASSIVE; } - + void lock() throw() { cs.enter(); } void unlock() throw() { cs.leave(); } @@ -110,12 +110,12 @@ Client::List clients; mutable CriticalSection cs; - + UserMap users; OnlineMap onlineUsers; User::Ptr me; - + Socket s; string cachedIp; @@ -123,14 +123,14 @@ friend class Singleton<ClientManager>; - ClientManager() { - TimerManager::getInstance()->addListener(this); + ClientManager() { + TimerManager::getInstance()->addListener(this); SettingsManager::getInstance()->addListener(this); } - virtual ~ClientManager() throw() { + virtual ~ClientManager() throw() { SettingsManager::getInstance()->removeListener(this); - TimerManager::getInstance()->removeListener(this); + TimerManager::getInstance()->removeListener(this); } string getUsersFile() { return Util::getConfigPath() + "Users.xml"; } @@ -148,7 +148,7 @@ virtual void on(Failed, Client*, const string&) throw(); virtual void on(HubUpdated, Client* c) throw() { fire(ClientManagerListener::ClientUpdated(), c); } virtual void on(UserCommand, Client*, int, int, const string&, const string&) throw(); - virtual void on(NmdcSearch, Client* aClient, const string& aSeeker, int aSearchType, int64_t aSize, + virtual void on(NmdcSearch, Client* aClient, const string& aSeeker, int aSearchType, int64_t aSize, int aFileType, const string& aString) throw(); virtual void on(AdcSearch, Client* c, const AdcCommand& adc, const CID& from) throw(); // TimerManagerListener Modified: dcplusplus/trunk/client/ClientManagerListener.h =================================================================== --- dcplusplus/trunk/client/ClientManagerListener.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ClientManagerListener.h 2006-09-18 18:13:50 UTC (rev 649) @@ -26,7 +26,7 @@ class ClientManagerListener { public: virtual ~ClientManagerListener() { } - template<int I> struct X { enum { TYPE = I }; }; + template<int I> struct X { enum { TYPE = I }; }; typedef X<0> UserConnected; typedef X<1> UserUpdated; Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -41,11 +41,13 @@ features.push_back(UserConnection::FEATURE_TTHF); adcFeatures.push_back("AD" + UserConnection::FEATURE_ADC_BASE); + adcFeatures.push_back("AD" + UserConnection::FEATURE_ADC_BZIP); } + // @todo clean this up void ConnectionManager::listen() throw(Exception){ unsigned short lastPort = (unsigned short)SETTING(TCP_PORT); - + if(lastPort == 0) lastPort = (unsigned short)Util::rand(1025, 32000); @@ -178,8 +180,8 @@ // Not online anymore...remove it from the pending... removed.push_back(cqi); continue; - } - + } + if(cqi->getUser()->isSet(User::PASSIVE) && !ClientManager::getInstance()->isActive()) { passiveUsers.push_back(cqi->getUser()); removed.push_back(cqi); @@ -237,7 +239,7 @@ } } -void ConnectionManager::on(TimerManagerListener::Minute, u_int32_t aTick) throw() { +void ConnectionManager::on(TimerManagerListener::Minute, u_int32_t aTick) throw() { Lock l(cs); for(UserConnection::Iter j = userConnections.begin(); j != userConnections.end(); ++j) { @@ -258,7 +260,6 @@ start(); } - static const u_int32_t POLL_TIMEOUT = 250; int ConnectionManager::Server::run() throw() { @@ -301,7 +302,7 @@ uc->setFlag(UserConnection::FLAG_INCOMING); uc->setState(UserConnection::STATE_SUPNICK); uc->setLastActivity(GET_TICK()); - try { + try { uc->accept(sock); } catch(const Exception&) { putConnection(uc); @@ -356,10 +357,15 @@ for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { if(i->compare(0, 2, "AD") == 0) { string feat = i->substr(2); - if(feat == UserConnection::FEATURE_ADC_BASE) + if(feat == UserConnection::FEATURE_ADC_BASE) { baseOk = true; - else if(feat == UserConnection::FEATURE_ZLIB_GET) + // For compatibility with older clients... + aSource->setFlag(UserConnection::FLAG_SUPPORTS_XML_BZLIST); + } else if(feat == UserConnection::FEATURE_ZLIB_GET) { aSource->setFlag(UserConnection::FLAG_SUPPORTS_ZLIB_GET); + } else if(feat == UserConnection::FEATURE_ADC_BZIP) { + aSource->setFlag(UserConnection::FLAG_SUPPORTS_XML_BZLIST); + } } } @@ -427,7 +433,7 @@ putConnection(aSource); return; } - aSource->setToken(i.first); + aSource->setToken(i.first); aSource->setHubUrl(i.second); } CID cid = ClientManager::getInstance()->makeCid(aNick, aSource->getHubUrl()); @@ -463,7 +469,7 @@ aSource->setFlag(UserConnection::FLAG_OP); if( aSource->isSet(UserConnection::FLAG_INCOMING) ) { - aSource->myNick(aSource->getToken()); + aSource->myNick(aSource->getToken()); aSource->lock(CryptoManager::getInstance()->getLock(), CryptoManager::getInstance()->getPk()); } @@ -475,7 +481,7 @@ dcdebug("CM::onLock %p received lock twice, ignoring\n", (void*)aSource); return; } - + if( CryptoManager::getInstance()->isExtended(aLock) ) { // Alright, we have an extended protocol, set a user flag for this user and refresh his info... if( (aPk.find("DCPLUSPLUS") != string::npos) && aSource->getUser() && !aSource->getUser()->isSet(User::DCPLUSPLUS)) { @@ -543,7 +549,7 @@ uc->setFlag(UserConnection::FLAG_ASSOCIATED); fire(ConnectionManagerListener::Connected(), cqi); - + dcdebug("ConnectionManager::addDownloadConnection, leaving to downloadmanager\n"); addConn = true; } @@ -693,7 +699,7 @@ void ConnectionManager::on(UserConnectionListener::Supports, UserConnection* conn, const StringList& feat) throw() { for(StringList::const_iterator i = feat.begin(); i != feat.end(); ++i) { if(*i == UserConnection::FEATURE_GET_ZBLOCK) { - conn->setFlag(UserConnection::FLAG_SUPPORTS_GETZBLOCK); + conn->setFlag(UserConnection::FLAG_SUPPORTS_GETZBLOCK); } else if(*i == UserConnection::FEATURE_MINISLOTS) { conn->setFlag(UserConnection::FLAG_SUPPORTS_MINISLOTS); } else if(*i == UserConnection::FEATURE_XML_BZLIST) { Modified: dcplusplus/trunk/client/ConnectionManager.h =================================================================== --- dcplusplus/trunk/client/ConnectionManager.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ConnectionManager.h 2006-09-18 18:13:50 UTC (rev 649) @@ -38,7 +38,7 @@ typedef ConnectionQueueItem* Ptr; typedef vector<Ptr> List; typedef List::iterator Iter; - + enum State { CONNECTING, // Recently sent request to connect WAITING, // Waiting to send request to connect @@ -47,17 +47,17 @@ }; ConnectionQueueItem(const User::Ptr& aUser, bool aDownload) : state(WAITING), lastAttempt(0), download(aDownload), user(aUser) { } - + User::Ptr& getUser() { return user; } const User::Ptr& getUser() const { return user; } - + GETSET(State, state, State); GETSET(u_int32_t, lastAttempt, LastAttempt); GETSET(bool, download, Download); private: ConnectionQueueItem(const ConnectionQueueItem&); ConnectionQueueItem& operator=(const ConnectionQueueItem&); - + User::Ptr user; }; @@ -71,12 +71,12 @@ pair<string, string> remove(const string& aNick) { Lock l(cs); ExpectMap::iterator i = expectedConnections.find(aNick); - + if(i == expectedConnections.end()) return make_pair(Util::emptyString, Util::emptyString); pair<string, string> tmp = make_pair(i->second.first, i->second.second); expectedConnections.erase(i); - + return tmp; } @@ -91,8 +91,8 @@ // Comparing with a user... inline bool operator==(ConnectionQueueItem::Ptr ptr, const User::Ptr& aUser) { return ptr->getUser() == aUser; } -class ConnectionManager : public Speaker<ConnectionManagerListener>, - public UserConnectionListener, TimerManagerListener, +class ConnectionManager : public Speaker<ConnectionManagerListener>, + public UserConnectionListener, TimerManagerListener, public Singleton<ConnectionManager> { public: @@ -102,7 +102,7 @@ void nmdcConnect(const string& aServer, short aPort, const string& aMyNick, const string& hubUrl); void adcConnect(const OnlineUser& aUser, short aPort, const string& aToken, bool secure); - + void getDownloadConnection(const User::Ptr& aUser); void disconnect(const User::Ptr& aUser, int isDownload); @@ -166,7 +166,7 @@ ConnectionManager(); virtual ~ConnectionManager() throw() { shutdown(); } - + UserConnection* getConnection(bool aNmdc, bool secure) throw(); void putConnection(UserConnection* aConn); @@ -192,8 +192,8 @@ virtual void on(AdcCommand::STA, UserConnection*, const AdcCommand&) throw(); // TimerManagerListener - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); - virtual void on(TimerManagerListener::Minute, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Minute, u_int32_t aTick) throw(); }; Modified: dcplusplus/trunk/client/ConnectionManagerListener.h =================================================================== --- dcplusplus/trunk/client/ConnectionManagerListener.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/ConnectionManagerListener.h 2006-09-18 18:13:50 UTC (rev 649) @@ -28,7 +28,7 @@ class ConnectionManagerListener { public: virtual ~ConnectionManagerListener() { } - template<int I> struct X { enum { TYPE = I }; }; + template<int I> struct X { enum { TYPE = I }; }; typedef X<0> Added; typedef X<1> Connected; Modified: dcplusplus/trunk/client/CriticalSection.h =================================================================== --- dcplusplus/trunk/client/CriticalSection.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/CriticalSection.h 2006-09-18 18:13:50 UTC (rev 649) @@ -25,13 +25,13 @@ #include "Thread.h" -class CriticalSection +class CriticalSection { #ifdef _WIN32 public: void enter() throw() { EnterCriticalSection(&cs); - dcdrun(counter++); + dcdrun(counter++); } void leave() throw() { dcassert(--counter >= 0); @@ -72,8 +72,8 @@ /** * A fast, non-recursive and unfair implementation of the Critical Section. - * It is meant to be used in situations where the risk for lock conflict is very low, - * i e locks that are held for a very short time. The lock is _not_ recursive, i e if + * It is meant to be used in situations where the risk for lock conflict is very low, + * i e locks that are held for a very short time. The lock is _not_ recursive, i e if * the same thread will try to grab the lock it'll hang in a never-ending loop. The lock * is not fair, i e the first to try to enter a locked lock is not guaranteed to be the * first to get it when it's freed... @@ -96,7 +96,7 @@ #else // We have to use a pthread (nonrecursive) mutex, didn't find any test_and_set on linux... - FastCriticalSection() { + FastCriticalSection() { static pthread_mutex_t fastmtx = PTHREAD_MUTEX_INITIALIZER; mtx = fastmtx; } @@ -104,14 +104,14 @@ void enter() { pthread_mutex_lock(&mtx); } void leave() { pthread_mutex_unlock(&mtx); } private: - pthread_mutex_t mtx; + pthread_mutex_t mtx; #endif }; template<class T> class LockBase { public: - LockBase(T& aCs) throw() : cs(aCs) { cs.enter(); } + LockBase(T& aCs) throw() : cs(aCs) { cs.enter(); } ~LockBase() throw() { cs.leave(); } private: LockBase& operator=(const LockBase&); @@ -154,7 +154,7 @@ template<class T = CriticalSection> class RLock { public: - RLock(RWLock<T>& aRwl) throw() : rwl(aRwl) { rwl.enterRead(); } + RLock(RWLock<T>& aRwl) throw() : rwl(aRwl) { rwl.enterRead(); } ~RLock() throw() { rwl.leaveRead(); } private: RLock& operator=(const RLock&); @@ -164,7 +164,7 @@ template<class T = CriticalSection> class WLock { public: - WLock(RWLock<T>& aRwl) throw() : rwl(aRwl) { rwl.enterWrite(); } + WLock(RWLock<T>& aRwl) throw() : rwl(aRwl) { rwl.enterWrite(); } ~WLock() throw() { rwl.leaveWrite(); } private: WLock& operator=(const WLock&); Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -35,15 +35,15 @@ #include <bzlib.h> #endif -CryptoManager::CryptoManager() -: - clientContext(SSL_CTX_new(TLSv1_client_method())), - serverContext(SSL_CTX_new(TLSv1_server_method())), - clientVerContext(SSL_CTX_new(TLSv1_client_method())), - serverVerContext(SSL_CTX_new(TLSv1_server_method())), - dh(DH_new()), - certsLoaded(false), - lock("EXTENDEDPROTOCOLABCABCABCABCABCABC"), +CryptoManager::CryptoManager() +: + clientContext(SSL_CTX_new(TLSv1_client_method())), + serverContext(SSL_CTX_new(TLSv1_server_method())), + clientVerContext(SSL_CTX_new(TLSv1_client_method())), + serverVerContext(SSL_CTX_new(TLSv1_server_method())), + dh(DH_new()), + certsLoaded(false), + lock("EXTENDEDPROTOCOLABCABCABCABCABCABC"), pk("DCPLUSPLUS" VERSIONSTRING "ABCABC") { static unsigned char dh512_p[] = @@ -88,8 +88,8 @@ DH_free(dh); } -bool CryptoManager::TLSOk() const throw() { - return BOOLSETTING(USE_TLS) && certsLoaded; +bool CryptoManager::TLSOk() const throw() { + return BOOLSETTING(USE_TLS) && certsLoaded; } void CryptoManager::generateCertificate() throw(CryptoException) { @@ -113,7 +113,7 @@ CloseHandle(pi.hThread); CloseHandle(pi.hProcess); - cmd = L"openssl.exe req -x509 -new -batch -days 3650 -key \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + + cmd = L"openssl.exe req -x509 -new -batch -days 3650 -key \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + L"\" -out \"" + Text::utf8ToWide(SETTING(TLS_CERTIFICATE_FILE)) + L"\" -subj \"/CN=" + Text::utf8ToWide(ClientManager::getInstance()->getMyCID().toBase32()) + L"\""; @@ -248,7 +248,7 @@ // but we'll have to do multiple passes... size_t bufsize = 2*sz; AutoArray<char> buf(bufsize); - + bs.avail_in = sz; bs.avail_out = bufsize; bs.next_in = (char*)(const_cast<u_int8_t*>(is)); @@ -257,33 +257,33 @@ int err; os.clear(); - - while((err = BZ2_bzDecompress(&bs)) == BZ_OK) { - if (bs.avail_in == 0 && bs.avail_out > 0) { // error: BZ_UNEXPECTED_EOF - BZ2_bzDecompressEnd(&bs); - throw CryptoException(STRING(DECOMPRESSION_ERROR)); - } - os.append(buf, bufsize-bs.avail_out); - bs.avail_out = bufsize; - bs.next_out = buf; - } + while((err = BZ2_bzDecompress(&bs)) == BZ_OK) { + if (bs.avail_in == 0 && bs.avail_out > 0) { // error: BZ_UNEXPECTED_EOF + BZ2_bzDecompressEnd(&bs); + throw CryptoException(STRING(DECOMPRESSION_ERROR)); + } + os.append(buf, bufsize-bs.avail_out); + bs.avail_out = bufsize; + bs.next_out = buf; + } + if(err == BZ_STREAM_END) os.append(buf, bufsize-bs.avail_out); - + BZ2_bzDecompressEnd(&bs); if(err < 0) { // This was a real error - throw CryptoException(STRING(DECOMPRESSION_ERROR)); + throw CryptoException(STRING(DECOMPRESSION_ERROR)); } } string CryptoManager::keySubst(const u_int8_t* aKey, size_t len, size_t n) { AutoArray<u_int8_t> temp(len + n * 10); - + size_t j=0; - + for(size_t i = 0; i<len; i++) { if(isExtra(aKey[i])) { temp[j++] = '/'; temp[j++] = '%'; temp[j++] = 'D'; @@ -308,14 +308,14 @@ if(aLock.size() < 3) return Util::emptyString; - AutoArray<u_int8_t> temp(aLock.length()); + AutoArray<u_int8_t> temp(aLock.length()); u_int8_t v1; size_t extra=0; - + v1 = (u_int8_t)(aLock[0]^5); v1 = (u_int8_t)(((v1 >> 4) | (v1 << 4)) & 0xff); temp[0] = v1; - + string::size_type i; for(i = 1; i<aLock.length(); i++) { @@ -325,114 +325,13 @@ if(isExtra(temp[i])) extra++; } - + temp[0] = (u_int8_t)(temp[0] ^ temp[aLock.length()-1]); - + if(isExtra(temp[0])) { extra++; } - + return keySubst(temp, aLock.length(), extra); } -void CryptoManager::decodeHuffman(const u_int8_t* is, string& os, const size_t len) throw(CryptoException) { -// BitInputStream bis; - int pos = 0; - - if(len < 11 || is[pos] != 'H' || is[pos+1] != 'E' || !((is[pos+2] == '3') || (is[pos+2] == '0'))) { - throw CryptoException(STRING(DECOMPRESSION_ERROR)); - } - pos+=5; - - int size; - size = *(int*)&is[pos]; - - pos+=4; - - dcdebug("Size: %d\n", size); - - unsigned short treeSize; - treeSize = *(unsigned short*)&is[pos]; - - pos+=2; - - if(len < (size_t)(11 + treeSize * 2)) - throw CryptoException(STRING(DECOMPRESSION_ERROR)); - Leaf** leaves = new Leaf*[treeSize]; - - int i; - for(i=0; i<treeSize; i++) { - int chr = is[pos++]; - int bits = is[pos++]; - leaves[i] = new Leaf(chr, bits); - } - - BitInputStream bis(is, pos, len); - - DecNode* root = new DecNode(); - - for(i=0; i<treeSize; i++) { - DecNode* node = root; - for(int j=0; j<leaves[i]->len; j++) { - try { - if(bis.get()) { - if(node->right == NULL) - node->right = new DecNode(); - - node = node->right; - } else { - if(node->left == NULL) - node->left = new DecNode(); - - node = node->left; - } - } catch(const BitStreamException&) { - throw CryptoException(STRING(DECOMPRESSION_ERROR)); - } - } - node->chr = leaves[i]->chr; - } - - bis.skipToByte(); - - // We know the size, so no need to use strange STL stuff... - AutoArray<char> buf(size+1); - - pos = 0; - for(i=0; i<size; i++) { - DecNode* node = root; - while(node->chr == -1) { - try { - if(bis.get()) { - node = node->right; - } else { - node = node->left; - } - } catch(const BitStreamException&) { - throw CryptoException(STRING(DECOMPRESSION_ERROR)); - } - - if(node == NULL) { - for(i=0; i<treeSize; i++) { - delete leaves[i]; - } - - delete[] leaves; - delete root; - - dcdebug("Bad node found!!!\n"); - throw CryptoException(STRING(DECOMPRESSION_ERROR)); - } - } - buf[pos++] = (u_int8_t)node->chr; - } - buf[pos] = 0; - os.assign(buf, size); - - for(i=0; i<treeSize; i++) { - delete leaves[i]; - } - - delete[] leaves; - delete root; -} Modified: dcplusplus/trunk/client/CryptoManager.h =================================================================== --- dcplusplus/trunk/client/CryptoManager.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/CryptoManager.h 2006-09-18 18:13:50 UTC (rev 649) @@ -43,12 +43,12 @@ // typedef List::iterator Iter; int chr; int weight; - + Node* left; Node* right; - + Node(int aChr, int aWeight) : chr(aChr), weight(aWeight), left(NULL), right(NULL) { } - Node(Node* aLeft, Node* aRight) : chr(-1), weight(aLeft->weight + aRight->weight), left(aLeft), right(aRight) { } + Node(Node* aLeft, Node* aRight) : chr(-1), weight(aLeft->weight + aRight->weight), left(aLeft), right(aRight) { } ~Node() { delete left; delete right; @@ -78,7 +78,6 @@ const string& getPk() { return pk; } bool isExtended(const string& aLock) { return strncmp(aLock.c_str(), "EXTENDEDPROTOCOL", 16) == 0; } - void decodeHuffman(const u_int8_t* /*is*/, string& /*os*/, const size_t /*len*/) throw(CryptoException); void decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw(CryptoException); SSLSocket* getClientSocket(bool allowUntrusted) throw(SocketException); @@ -91,32 +90,10 @@ private: friend class Singleton<CryptoManager>; - + CryptoManager(); virtual ~CryptoManager(); - class Leaf : public FastAlloc<Leaf> { - public: - int chr; - int len; - Leaf(int aChr, int aLen) : chr(aChr), len(aLen) { } - Leaf() : chr(-1), len(-1) { } - }; - - class DecNode : public FastAlloc<DecNode> { - public: - int chr; - DecNode* left; - DecNode* right; - DecNode(int aChr) : chr(aChr), left(NULL), right(NULL) { } - DecNode(DecNode* aLeft, DecNode* aRight) : chr(-1), left(aLeft), right(aRight) { } - DecNode() : chr(-1), left(NULL), right(NULL) { } - ~DecNode() { - delete left; - delete right; - } - }; - SSL_CTX* clientContext; SSL_CTX* clientVerContext; SSL_CTX* serverContext; @@ -132,7 +109,7 @@ void walkTree(list<Node*>& aTree); void recurseLookup(vector<u_int8_t>* b, Node* node, vector<u_int8_t>& bytes); void buildLookup(vector<u_int8_t>* b, Node* root); - + string keySubst(const u_int8_t* aKey, size_t len, size_t n); bool isExtra(u_int8_t b) { return (b == 0 || b==5 || b==124 || b==96 || b==126 || b==36); Modified: dcplusplus/trunk/client/DCPlusPlus.cpp =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/DCPlusPlus.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -97,7 +97,7 @@ BufferedSocket::waitShutdown(); SettingsManager::getInstance()->save(); - + ADLSearchManager::deleteInstance(); FinishedManager::deleteInstance(); ShareManager::deleteInstance(); Modified: dcplusplus/trunk/client/DCPlusPlus.h =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.h 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/DCPlusPlus.h 2006-09-18 18:13:50 UTC (rev 649) @@ -33,10 +33,10 @@ { va_list args; va_start(args, format); - + #ifdef _WIN32 char buf[512]; - + _vsnprintf(buf, sizeof(buf), format, args); OutputDebugStringA(buf); #else // _WIN32 Modified: dcplusplus/trunk/client/DirectoryListing.cpp =================================================================== --- dcplusplus/trunk/client/DirectoryListing.cpp 2006-09-11 13:46:56 UTC (rev 648) +++ dcplusplus/trunk/client/DirectoryListing.cpp 2006-09-18 18:13:50 UTC (rev 649) @@ -80,17 +80,7 @@ // For now, we detect type by ending... string ext = Util::getFileExt(name); - if(Util::stricmp(ext, ".DcLst") == 0) { - size_t len = (size_t)::File::getSize(name); - if(len == (size_t)-1) - return; - AutoArray<u_int8_t> buf(len); - ::File(name, ::File::READ, ::File::OPEN).read(buf, len); - CryptoManager::getInstance()->decodeHuffman(buf, txt, len); - load(txt); - return; - } - + if(Util::stricmp(ext, ".bz2") == 0) { ::File ff(name, ::File::READ, ::File::OPEN); FilteredInputStream<UnBZFilter, false> f(&ff); @@ -120,62 +110,9 @@ loadXML(txt, false); } -void DirectoryListing::load(const string& in) { - StringTokenizer<string> t(in, '\n'); - - StringList& tokens = t.getTokens(); - string::size_type indent = 0; - - root->setComplete(true); - - Directory* cur = root; - string fullPath; - - for(StringIter i = tokens.begin(); i != tokens.end(); ++i) - { - string& tok = *i; - string::size_type j = tok.find_first_not_of('\t'); - if(j == string::npos) { - break; - } - - while(j < indent) { - // Wind up directory structure - cur = cur->getParent(); - dcassert(cur != NULL); - indent--; - string::size_type l = fullPath.find_last_of('\\'); - if(l != string::npos) { - fullPath.erase(fullPath.begin() + l, fullPath.end()); - } - } - - string::size_type k = tok.find('|', j); - if(k != string::npos) { - // this must be a file... - cur->files.push_back(new File(cur, tok.substr(j, k-j), Util::toInt64(tok.substr(k+1)))); - } else { - // A directory - string name = tok.substr(j, tok.length()-j-1); - fullPath += '\\'; - fullPath += name; - - Directory::Iter di = ::find(cur->directories.begin(), cur->directories.end(), name); - if(di != cur->directories.end()) { - cur = *di; - } else { - Directory* d = new Directory(cur, name, false, true); - cur->directories.push_back(d); - cur = d; - } - indent++; - } - } -} - class ListLoader : public SimpleXMLReader::CallBack { public: - ListLoader(DirectoryListing::Directory* root, bool aUpdating) : cur(root), base("/"), inListing(false), updating(aUpdating) { + ListLoader(DirectoryListing::Directory* root, bool aUpdating) : cur(root), base("/"), inListing(false), updating(aUpdating) { } virtual ~ListLoader() { } @@ -220,7 +157,10 @@ if(s.empty()) return; const string& h = getAttrib(attribs, sTTH, 2); - DirectoryListing::File* f = h.empty() ? new DirectoryListing::File(cur, n, Util::toInt64(s)) : new DirectoryListing::File(cur, n, Util::toInt64(s), h); + if(h.empty()) { + return; + } + DirectoryListing::File* f = new DirectoryListing::File(cur, n, Util::toInt64(s), h); cur->files.push_back(f); } else if(name == sDirectory) { const string& n = getAttrib(attribs, sName, 0); @@ -230,7 +1... [truncated message content] |