From: <arn...@us...> - 2007-12-13 20:15:34
|
Revision: 937 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=937&view=rev Author: arnetheduck Date: 2007-12-13 12:15:27 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Fix some connectivity issues, fix download moving Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/dcpp/AdcHub.cpp dcplusplus/trunk/dcpp/ConnectionManager.cpp dcplusplus/trunk/dcpp/Download.cpp dcplusplus/trunk/dcpp/DownloadManager.cpp dcplusplus/trunk/dcpp/QueueManager.cpp dcplusplus/trunk/dcpp/UserConnection.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/changelog.txt 2007-12-13 20:15:27 UTC (rev 937) @@ -7,7 +7,7 @@ * Fixed version info (poy) * Keep selection visible on move up/down in some list views (poy) * Fixed clicking in the header of the favorite hubs list view (poy) -* Update to ADC 1.0 +* Update most things to ADC 1.0 * Fixed pressing enter in the notepad (poy) * Fixed user commands params (poy) * Readded list view double buffering (thanks poy) Modified: dcplusplus/trunk/dcpp/AdcHub.cpp =================================================================== --- dcplusplus/trunk/dcpp/AdcHub.cpp 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/dcpp/AdcHub.cpp 2007-12-13 20:15:27 UTC (rev 937) @@ -275,20 +275,26 @@ OnlineUser* u = findUser(c.getFrom()); if(!u || u->getUser() == ClientManager::getInstance()->getMe()) return; - if(c.getParameters().size() < 3) + if(c.getParameters().size() < 2) return; const string& protocol = c.getParam(0); const string& port = c.getParam(1); - + string token; - bool hasToken = c.getParam("TO", 2, token); - - if(!hasToken) { - // @todo remove this bugfix for <=0.698 some time - token = c.getParam(2); + if(c.getParameters().size() == 3) { + const string& tok = c.getParam(2); + + // 0.699 put TO before the token, keep this bug fix for a while + if(tok.compare(0, 2, "TO") == 0) { + token = tok.substr(2); + } else { + token = tok; + } + } else { + // <= 0.703 would send an empty token for passive connections... } - + bool secure = false; if(protocol == CLIENT_PROTOCOL || protocol == CLIENT_PROTOCOL_TEST) { // Nothing special @@ -298,10 +304,8 @@ AdcCommand cmd(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown", AdcCommand::TYPE_DIRECT); cmd.setTo(c.getFrom()); cmd.addParam("PR", protocol); + cmd.addParam("TO", token); - if(hasToken) - cmd.addParam("TO", token); - send(cmd); return; } @@ -315,7 +319,7 @@ } void AdcHub::handle(AdcCommand::RCM, AdcCommand& c) throw() { - if(c.getParameters().empty()) { + if(c.getParameters().size() < 2) { return; } if(!ClientManager::getInstance()->isActive()) @@ -325,8 +329,14 @@ return; const string& protocol = c.getParam(0); + const string& tok = c.getParam(1); string token; - bool hasToken = c.getParam("TO", 1, token); + // 0.699 sent a token with "TO" prefix + if(tok.compare(0, 2, "TO") == 0) { + token = tok.substr(2); + } else { + token = tok; + } bool secure; if(protocol == CLIENT_PROTOCOL || protocol == CLIENT_PROTOCOL_TEST) { @@ -337,10 +347,8 @@ AdcCommand cmd(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown", AdcCommand::TYPE_DIRECT); cmd.setTo(c.getFrom()); cmd.addParam("PR", protocol); + cmd.addParam("TO", token); - if(hasToken) - cmd.addParam("TO", token); - send(cmd); return; } Modified: dcplusplus/trunk/dcpp/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/ConnectionManager.cpp 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/dcpp/ConnectionManager.cpp 2007-12-13 20:15:27 UTC (rev 937) @@ -634,9 +634,10 @@ ConnectionQueueItem::Iter i = find(downloads.begin(), downloads.end(), aSource->getUser()); if(i != downloads.end()) { - // Last compare for compatibility with pre-0.700 const string& to = (*i)->getToken(); - if(to == token || (to.size() > 2 && to.compare(0, 2, "TO") == 0 && to.compare(2, to.size() - 2, token) == 0)) { + + // 0.698 would send an empty token in some cases...remove this bugfix at some point + if(to == token || token.empty()) { down = true; } } Modified: dcplusplus/trunk/dcpp/Download.cpp =================================================================== --- dcplusplus/trunk/dcpp/Download.cpp 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/dcpp/Download.cpp 2007-12-13 20:15:27 UTC (rev 937) @@ -85,7 +85,6 @@ Download::~Download() { getUserConnection().setDownload(0); - delete file; } AdcCommand Download::getCommand(bool zlib) { Modified: dcplusplus/trunk/dcpp/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/DownloadManager.cpp 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/dcpp/DownloadManager.cpp 2007-12-13 20:15:27 UTC (rev 937) @@ -489,10 +489,6 @@ } catch(const Exception&) { } } - - if(d->isSet(Download::FLAG_ANTI_FRAG)) { - d->unsetFlag(Download::FLAG_ANTI_FRAG); - } } { Modified: dcplusplus/trunk/dcpp/QueueManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/QueueManager.cpp 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/dcpp/QueueManager.cpp 2007-12-13 20:15:27 UTC (rev 937) @@ -797,6 +797,9 @@ { Lock l(cs); + delete aDownload->getFile(); + aDownload->setFile(0); + if(aDownload->getType() == Transfer::TYPE_PARTIAL_LIST) { pair<PfsIter, PfsIter> range = pfsQueue.equal_range(aDownload->getUser()->getCID()); PfsIter i = find_if(range.first, range.second, CompareSecond<CID, string>(aDownload->getPath())); @@ -849,9 +852,6 @@ } if(aDownload->getType() != Transfer::TYPE_FILE || q->isFinished()) { - // Delete file here to ensure that move works - delete aDownload->getFile(); - aDownload->setFile(0); // Check if we're anti-fragging... if(aDownload->isSet(Download::FLAG_ANTI_FRAG)) { Modified: dcplusplus/trunk/dcpp/UserConnection.cpp =================================================================== --- dcplusplus/trunk/dcpp/UserConnection.cpp 2007-12-12 19:28:12 UTC (rev 936) +++ dcplusplus/trunk/dcpp/UserConnection.cpp 2007-12-13 20:15:27 UTC (rev 937) @@ -150,12 +150,7 @@ AdcCommand c(AdcCommand::CMD_INF); c.addParam("ID", ClientManager::getInstance()->getMyCID().toBase32()); if(withToken) { - if(getToken().compare(0, 2, "TO") == 0) { - // Compatibility with pre-0.700 - c.addParam(getToken()); - } else { - c.addParam("TO", getToken()); - } + c.addParam("TO", getToken()); } send(c); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |