From: <arn...@us...> - 2006-06-17 22:24:50
|
Revision: 617 Author: arnetheduck Date: 2006-06-17 15:24:01 -0700 (Sat, 17 Jun 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=617&view=rev Log Message: ----------- Partial commit, more to come in a few minutes Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/CryptoManager.h dcplusplus/trunk/client/DCPlusPlus.cpp dcplusplus/trunk/client/FavoriteUser.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SSLSocket.h dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/User.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/windows/CommandDlg.cpp dcplusplus/trunk/windows/CommandDlg.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/windows/QueuePage.cpp dcplusplus/trunk/windows/UPnP.cpp dcplusplus/trunk/windows/UPnP.h Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/Example.xml 2006-06-17 22:24:01 UTC (rev 617) @@ -130,6 +130,7 @@ <String Name="File">File</String> <String Name="Files">Files</String> <String Name="FileHasNoTth">This file has no TTH</String> + <String Name="FileIsAlreadyQueued">This file is already queued</String> <String Name="FileListDiff">Subtract list</String> <String Name="FileListRefreshFailed">File list refresh failed: </String> <String Name="FileListRefreshFinished">File list refresh finished</String> @@ -406,6 +407,7 @@ <String Name="SettingsDefaultAwayMsg">Default away message</String> <String Name="SettingsDirect">Direct connection</String> <String Name="SettingsDirectories">Directories</String> + <String Name="SettingsDontDlAlreadyQueued">Don't download files already in the queue</String> <String Name="SettingsDontDlAlreadyShared">Don't download files already in share</String> <String Name="SettingsDownloadDirectory">Default download directory</String> <String Name="SettingsDownloadLimits">Limits</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/changelog.txt 2006-06-17 22:24:01 UTC (rev 617) @@ -14,8 +14,11 @@ * [bug 959] Code cleanup (thanks pothead) * [bug 966] Max hash speed fixed when fast hashing method is not used (thanks steven sheehy) * [bug 967] Fixed path case-sensitivity issue (thanks steven sheehy) +* Fixed auto-reconnect +* [bug 936] Fixed duplicate entries in search hubs +* Fixed some hub title display issues +* Some code spring cleanup - -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog * [bug 122] Added userlist filter (thanks trem) Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -29,7 +29,7 @@ #include "Util.h" #include "UserCommand.h" #include "FavoriteManager.h" -#include "SSLSocket.h" +#include "CryptoManager.h" const string AdcHub::CLIENT_PROTOCOL("ADC/0.10"); const string AdcHub::SECURE_CLIENT_PROTOCOL("ADCS/0.10"); @@ -453,8 +453,8 @@ ADDPARAM("ID", ClientManager::getInstance()->getMyCID().toBase32()); ADDPARAM("PD", ClientManager::getInstance()->getMyPID().toBase32()); - ADDPARAM("NI", getMyIdentity().getNick()); - ADDPARAM("DE", getMyIdentity().getDescription()); + ADDPARAM("NI", getCurrentNick()); + ADDPARAM("DE", getCurrentDescription()); ADDPARAM("SL", Util::toString(SETTING(SLOTS))); ADDPARAM("SS", ShareManager::getInstance()->getShareSizeString()); ADDPARAM("SF", Util::toString(ShareManager::getInstance()->getSharedFiles())); @@ -478,7 +478,7 @@ } string su; - if(SSLSocketFactory::getInstance()->hasCerts()) { + if(CryptoManager::getInstance()->hasCerts()) { su += ADCS_FEATURE + ","; } @@ -548,17 +548,6 @@ fire(ClientListener::Failed(), this, aLine); } -void AdcHub::on(TimerManagerListener::Second, u_int32_t aTick) throw() { - if(socket && (getLastActivity() + getReconnDelay() * 1000) < aTick) { - // Nothing's happened for ~120 seconds, check if we're connected, if not, try to connect... - if(!isConnected()) { - // Try to reconnect... - if(reconnect && !getAddress().empty()) - Client::connect(); - } - } -} - void AdcHub::send(const AdcCommand& cmd) { dcassert(socket); if(!socket) Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/AdcHub.h 2006-06-17 22:24:01 UTC (rev 617) @@ -30,7 +30,7 @@ class ClientManager; -class AdcHub : public Client, public CommandHandler<AdcHub>, private TimerManagerListener { +class AdcHub : public Client, public CommandHandler<AdcHub> { public: using Client::send; @@ -119,7 +119,6 @@ virtual void on(Connected) throw(); virtual void on(Line, const string& aLine) throw(); virtual void on(Failed, const string& aLine) throw(); - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); }; #endif // !defined(ADC_HUB_H) Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -27,6 +27,7 @@ #include "Streams.h" #include "SSLSocket.h" +#include "CryptoManager.h" // Polling is used for tasks...should be fixed... #define POLL_TIMEOUT 250 @@ -75,7 +76,7 @@ dcassert(!sock); dcdebug("BufferedSocket::accept() %p\n", (void*)this); - sock = secure ? SSLSocketFactory::getInstance()->getClientSocket() : new Socket; + sock = secure ? CryptoManager::getInstance()->getClientSocket() : new Socket; sock->accept(srv); if(SETTING(SOCKET_IN_BUFFER) > 0) @@ -103,7 +104,7 @@ dcassert(!sock); dcdebug("BufferedSocket::connect() %p\n", (void*)this); - sock = secure ? SSLSocketFactory::getInstance()->getClientSocket() : new Socket; + sock = secure ? CryptoManager::getInstance()->getClientSocket() : new Socket; sock->create(); if(SETTING(SOCKET_IN_BUFFER) >= 1024) Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/Client.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -29,20 +29,31 @@ Client::Counts Client::counts; Client::Client(const string& hubURL, char separator_, bool secure_) : - reconnDelay(120), lastActivity(0), registered(false), socket(NULL), + myIdentity(ClientManager::getInstance()->getMe(), 0), + reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(true), socket(0), hubUrl(hubURL), port(0), separator(separator_), secure(secure_), countType(COUNT_UNCOUNTED) { string file; Util::decodeUrl(hubURL, address, port, file); + + TimerManager::getInstance()->addListener(this); } Client::~Client() throw() { dcassert(!socket); + TimerManager::getInstance()->removeListener(this); updateCounts(true); } +void Client::reconnect() { + disconnect(true); + setAutoReconnect(true); + resetActivtiy(); +} + void Client::shutdown() { + if(socket) { BufferedSocket::putSocket(socket); socket = 0; @@ -52,29 +63,32 @@ void Client::reloadSettings(bool updateNick) { FavoriteHubEntry* hub = FavoriteManager::getInstance()->getFavoriteHubEntry(getHubUrl()); if(hub) { - if(updateNick) - getMyIdentity().setNick(checkNick(hub->getNick(true))); + if(updateNick) { + setCurrentNick(checkNick(hub->getNick(true))); + } + if(!hub->getUserDescription().empty()) { - getMyIdentity().setDescription(hub->getUserDescription()); + setCurrentDescription(hub->getUserDescription()); } else { - getMyIdentity().setDescription(SETTING(DESCRIPTION)); + setCurrentDescription(SETTING(DESCRIPTION)); } setPassword(hub->getPassword()); } else { - getMyIdentity().setNick(checkNick(SETTING(NICK))); - getMyIdentity().setDescription(SETTING(DESCRIPTION)); + setCurrentNick(checkNick(SETTING(NICK))); + setCurrentDescription(SETTING(DESCRIPTION)); } - getMyIdentity().setUser(ClientManager::getInstance()->getMe()); - getMyIdentity().setHubUrl(getHubUrl()); } void Client::connect() { if(socket) BufferedSocket::putSocket(socket); + setAutoReconnect(true); setReconnDelay(120 + Util::rand(0, 60)); reloadSettings(true); setRegistered(false); + setMyIdentity(Identity()); + setHubIdentity(Identity()); try { socket = BufferedSocket::getSocket(separator); @@ -97,10 +111,6 @@ socket->disconnect(graceLess); } -void Client::updateActivity() { - lastActivity = GET_TICK(); -} - void Client::updateCounts(bool aRemove) { // We always remove the count and then add the correct one if requested... if(countType == COUNT_NORMAL) { @@ -117,7 +127,7 @@ if(getMyIdentity().isOp()) { Thread::safeInc(counts.op); countType = COUNT_OP; - } else if(registered) { + } else if(getMyIdentity().isRegistered()) { Thread::safeInc(counts.registered); countType = COUNT_REGISTERED; } else { @@ -145,3 +155,10 @@ return Util::getLocalIp(); return lip; } + +void Client::on(Second, u_int32_t aTick) throw() { + if(getAutoReconnect() && !isConnected() && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + // Try to reconnect... + connect(); + } +} Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/Client.h 2006-06-17 22:24:01 UTC (rev 617) @@ -26,6 +26,7 @@ #include "User.h" #include "BufferedSocket.h" #include "SettingsManager.h" +#include "TimerManager.h" class Client; class AdcCommand; @@ -77,7 +78,7 @@ }; /** Yes, this should probably be called a Hub */ -class Client : public Speaker<ClientListener>, public BufferedSocketListener { +class Client : public Speaker<ClientListener>, public BufferedSocketListener, protected TimerManagerListener { public: typedef Client* Ptr; typedef list<Ptr> List; @@ -125,6 +126,8 @@ return sm; } + void reconnect(); + void shutdown(); void send(const string& aMessage) { send(aMessage.c_str(), aMessage.length()); } @@ -140,7 +143,6 @@ const string& getHubName() const { return getHubIdentity().getNick().empty() ? getHubUrl() : getHubIdentity().getNick(); } const string& getHubDescription() const { return getHubIdentity().getDescription(); } - Identity& getMyIdentity() { return myIdentity; } Identity& getHubIdentity() { return hubIdentity; } const string& getHubUrl() const { return hubUrl; } @@ -152,7 +154,10 @@ GETSET(u_int32_t, reconnDelay, ReconnDelay); GETSET(u_int32_t, lastActivity, LastActivity); GETSET(bool, registered, Registered); + GETSET(bool, autoReconnect, AutoReconnect); + GETSET(string, currentNick, CurrentNick); + GETSET(string, currentDescription, CurrentDescription); protected: friend class ClientManager; Client(const string& hubURL, char separator, bool secure_); @@ -171,13 +176,17 @@ Counts lastCounts; void updateCounts(bool aRemove); - void updateActivity(); + void updateActivity() { lastActivity = GET_TICK(); } + void resetActivtiy() { lastActivity = 0; } /** Reload details from favmanager or settings */ void reloadSettings(bool updateNick); virtual string checkNick(const string& nick) = 0; + // TimerManagerListener + virtual void on(Second, u_int32_t aTick) throw(); + private: enum CountType { @@ -196,12 +205,13 @@ u_int16_t port; char separator; bool secure; - CountType countType; // BufferedSocketListener virtual void on(Connecting) throw() { fire(ClientListener::Connecting(), this); } virtual void on(Connected) throw() { updateActivity(); ip = socket->getIp(); fire(ClientListener::Connected(), this); } + + }; #endif // !defined(CLIENT_H) Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -405,14 +405,6 @@ SearchManager::getInstance()->respond(adc, from); } -Identity ClientManager::getIdentity(const User::Ptr& aUser) { - OnlineIter i = onlineUsers.find(aUser->getCID()); - if(i != onlineUsers.end()) { - return i->second->getIdentity(); - } - return Identity(aUser, Util::emptyString, 0); -} - void ClientManager::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) { Lock l(cs); Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/ClientManager.h 2006-06-17 22:24:01 UTC (rev 617) @@ -89,8 +89,6 @@ void lock() throw() { cs.enter(); } void unlock() throw() { cs.leave(); } - Identity getIdentity(const User::Ptr& aUser); - Client::List& getClients() { return clients; } string getCachedIp() const { Lock l(cs); return cachedIp; } Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -24,13 +24,118 @@ #include "BitInputStream.h" #include "BitOutputStream.h" #include "ResourceManager.h" +#include "LogManager.h" +#include <openssl/ssl.h> + #ifdef _WIN32 #include "../bzip2/bzlib.h" #else #include <bzlib.h> #endif +CryptoManager::CryptoManager() +: + clientContext(SSL_CTX_new(TLSv1_client_method())), + serverContext(SSL_CTX_new(TLSv1_server_method())), + dh(DH_new()), + certsLoaded(false), + lock("EXTENDEDPROTOCOLABCABCABCABCABCABC"), + pk("DCPLUSPLUS" VERSIONSTRING "ABCABC") +{ + static unsigned char dh512_p[] = + { + 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75, + 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F, + 0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3, + 0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12, + 0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C, + 0x47,0x74,0xE8,0x33, + }; + + static unsigned char dh512_g[] = + { + 0x02, + }; + + if(dh) { + dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), 0); + dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), 0); + + if (!dh->p || !dh->g) { + DH_free(dh); + dh = 0; + } else { + SSL_CTX_set_tmp_dh(serverContext, dh); + } + } +} + +CryptoManager::~CryptoManager() { + if(serverContext) + SSL_CTX_free(serverContext); + if(clientContext) + SSL_CTX_free(clientContext); + if(dh) + DH_free(dh); +} + + +void CryptoManager::loadCertificates() throw() { + SSL_CTX_set_verify(serverContext, SSL_VERIFY_NONE, 0); + SSL_CTX_set_verify(clientContext, SSL_VERIFY_NONE, 0); + + if(!SETTING(SSL_CERTIFICATE_FILE).empty()) { + if(SSL_CTX_use_certificate_file(serverContext, SETTING(SSL_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load certificate file"); + return; + } + if(SSL_CTX_use_certificate_file(clientContext, SETTING(SSL_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load certificate file"); + return; + } + } + + if(!SETTING(SSL_PRIVATE_KEY_FILE).empty()) { + if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(SSL_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load private key"); + return; + } + if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(SSL_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load private key"); + return; + } + } + +#ifdef _WIN32 + WIN32_FIND_DATA data; + HANDLE hFind; + + hFind = FindFirstFile(Text::toT(SETTING(SSL_TRUSTED_CERTIFICATES_PATH) + "*.pem").c_str(), &data); + if(hFind != INVALID_HANDLE_VALUE) { + do { + if(SSL_CTX_load_verify_locations(clientContext, (SETTING(SSL_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); + } + } while(FindNextFile(hFind, &data)); + + FindClose(hFind); + } +#else +#error todo +#endif + certsLoaded = true; +} + + +SSLSocket* CryptoManager::getClientSocket() throw(SocketException) { + return new SSLSocket(clientContext); +} +SSLSocket* CryptoManager::getServerSocket() throw(SocketException) { + return new SSLSocket(serverContext); +} + + void CryptoManager::decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw (CryptoException) { bz_stream bs = { 0 }; Modified: dcplusplus/trunk/client/CryptoManager.h =================================================================== --- dcplusplus/trunk/client/CryptoManager.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/CryptoManager.h 2006-06-17 22:24:01 UTC (rev 617) @@ -29,6 +29,7 @@ #include "Singleton.h" #include "FastAlloc.h" #include "version.h" +#include "SSLSocket.h" STANDARD_EXCEPTION(CryptoException); @@ -79,12 +80,18 @@ 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() throw(SocketException); + SSLSocket* getServerSocket() throw(SocketException); + + void loadCertificates() throw(); + bool hasCerts() const { return certsLoaded; } private: friend class Singleton<CryptoManager>; - CryptoManager() : lock("EXTENDEDPROTOCOLABCABCABCABCABCABC"), pk("DCPLUSPLUS" VERSIONSTRING "ABCABC") { } - virtual ~CryptoManager() { } + CryptoManager(); + virtual ~CryptoManager(); class Leaf : public FastAlloc<Leaf> { public: @@ -108,6 +115,11 @@ } }; + SSL_CTX* clientContext; + SSL_CTX* serverContext; + DH* dh; + bool certsLoaded; + const string lock; const string pk; Modified: dcplusplus/trunk/client/DCPlusPlus.cpp =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/DCPlusPlus.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -33,7 +33,6 @@ #include "SettingsManager.h" #include "FinishedManager.h" #include "ADLSearch.h" -#include "SSLSocket.h" #include "StringTokenizer.h" @@ -61,7 +60,6 @@ QueueManager::newInstance(); FinishedManager::newInstance(); ADLSearchManager::newInstance(); - SSLSocketFactory::newInstance(); SettingsManager::getInstance()->load(); @@ -70,7 +68,7 @@ } FavoriteManager::getInstance()->load(); - SSLSocketFactory::getInstance()->loadCertificates(); + CryptoManager::getInstance()->loadCertificates(); if(f != NULL) (*f)(p, STRING(HASH_DATABASE)); @@ -93,7 +91,6 @@ SettingsManager::getInstance()->save(); - SSLSocketFactory::deleteInstance(); ADLSearchManager::deleteInstance(); FinishedManager::deleteInstance(); ShareManager::deleteInstance(); Modified: dcplusplus/trunk/client/FavoriteUser.h =================================================================== --- dcplusplus/trunk/client/FavoriteUser.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/FavoriteUser.h 2006-06-17 22:24:01 UTC (rev 617) @@ -37,7 +37,7 @@ User::Ptr& getUser() { return user; } - void update(const OnlineUser& info) { setNick(info.getIdentity().getNick()); setUrl(info.getIdentity().getHubUrl()); } + void update(const OnlineUser& info); GETSET(User::Ptr, user, User); GETSET(string, nick, Nick); Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -33,18 +33,15 @@ #include "StringTokenizer.h" NmdcHub::NmdcHub(const string& aHubURL) : Client(aHubURL, '|', false), supportFlags(0), state(STATE_CONNECT), - reconnect(true), lastUpdate(0) + lastUpdate(0) { - TimerManager::getInstance()->addListener(this); } NmdcHub::~NmdcHub() throw() { - TimerManager::getInstance()->removeListener(this); clearUsers(); } void NmdcHub::connect() { - reconnect = true; supportFlags = 0; lastMyInfoA.clear(); lastMyInfoB.clear(); @@ -89,8 +86,6 @@ User::Ptr p; if(aNick == getMyNick()) { p = ClientManager::getInstance()->getMe(); - getMyIdentity().setUser(p); - getMyIdentity().setHubUrl(getHubUrl()); } else { p = ClientManager::getInstance()->getUser(aNick, getHubUrl()); } @@ -99,6 +94,9 @@ Lock l(cs); u = users.insert(make_pair(aNick, new OnlineUser(p, *this, 0))).first->second; u->getIdentity().setNick(aNick); + if(u->getUser() == getMyIdentity().getUser()) { + setMyIdentity(u->getIdentity()); + } } ClientManager::getInstance()->putOnline(*u); @@ -190,12 +188,12 @@ // Check if we're being banned... if(state != STATE_CONNECTED) { if(Util::findSubString(aLine, "banned") != string::npos) { - reconnect = false; + setAutoReconnect(false); } } - string line = fromNmdc(aLine); + string line = fromAcp(aLine); // @todo Decrypt who the message is from... - fire(ClientListener::StatusMessage(), this, Util::validateMessage(fromNmdc(aLine), true)); + fire(ClientListener::StatusMessage(), this, unescape(fromAcp(aLine))); return; } @@ -207,7 +205,7 @@ cmd = aLine; } else { cmd = aLine.substr(0, x); - param = fromNmdc(aLine.substr(x+1)); + param = fromAcp(aLine.substr(x+1)); } if(cmd == "$Search") { @@ -321,7 +319,7 @@ if(j == string::npos) return; - string tmpDesc = Util::validateMessage(param.substr(i, j-i), true); + string tmpDesc = unescape(param.substr(i, j-i)); // Look for a tag... if(tmpDesc.size() > 0 && tmpDesc[tmpDesc.size()-1] == '>') { x = tmpDesc.rfind('<'); @@ -353,7 +351,7 @@ if(j == string::npos) return; - u.getIdentity().setEmail(Util::validateMessage(param.substr(i, j-i), true)); + u.getIdentity().setEmail(unescape(param.substr(i, j-i)); i = j + 1; j = param.find('$', i); @@ -361,8 +359,9 @@ return; u.getIdentity().setBytesShared(param.substr(i, j-i)); - if(u.getUser() == getMyIdentity().getUser()) + if(u.getUser() == getMyIdentity().getUser()) { setMyIdentity(u.getIdentity()); + } fire(ClientListener::UserUpdated(), this, u); } else if(cmd == "$Quit") { @@ -428,11 +427,11 @@ // Hack - first word goes to hub name, rest to description string::size_type i = param.find(' '); if(i == string::npos) { - getHubIdentity().setNick(param); + getHubIdentity().setNick(unescape(param)); getHubIdentity().setDescription(Util::emptyString); } else { - getHubIdentity().setNick(param.substr(0, i)); - getHubIdentity().setDescription(param.substr(i+1)); + getHubIdentity().setNick(unescape(param.substr(0, i))); + getHubIdentity().setDescription(unescape(param.substr(i+1))); } fire(ClientListener::HubUpdated(), this); } else if(cmd == "$Supports") { @@ -470,7 +469,7 @@ string name = param.substr(i, j-i); i = j+1; string command = param.substr(i, param.length() - i); - fire(ClientListener::UserCommand(), this, type, ctx, Util::validateMessage(name, true, false), Util::validateMessage(command, true, false)); + fire(ClientListener::UserCommand(), this, type, ctx, unescape(name), unescape(command)); } } else if(cmd == "$Lock") { if(state != STATE_LOCK) { @@ -478,7 +477,7 @@ } state = STATE_HELLO; - // Param must not be fromNmdc'd... + // Param must not be fromAcp'd... param = aLine.substr(6); if(!param.empty()) { @@ -562,6 +561,9 @@ continue; u->getIdentity().setIp(it->substr(j+1)); + if(u->getUser() == getMyIdentity().getUser()) { + setMyIdentity(u->getIdentity()); + } v.push_back(u); } @@ -584,10 +586,10 @@ string tmp; // Let's assume 10 characters per nick... tmp.reserve(v.size() * (11 + 10 + getMyNick().length())); - string n = ' ' + toNmdc(getMyNick()) + '|'; + string n = ' ' + toAcp(getMyNick()) + '|'; for(OnlineUser::List::const_iterator i = v.begin(); i != v.end(); ++i) { tmp += "$GetINFO "; - tmp += toNmdc((*i)->getIdentity().getNick()); + tmp += toAcp((*i)->getIdentity().getNick()); tmp += n; } if(!tmp.empty()) { @@ -607,8 +609,9 @@ continue; OnlineUser& ou = getUser(*it); ou.getIdentity().setOp(true); - if(*it == getMyNick()) - getMyIdentity().setOp(true); + if(ou.getUser() == getMyIdentity().getUser()) { + setMyIdentity(ou.getIdentity()); + } v.push_back(&ou); } @@ -650,13 +653,15 @@ OnlineUser* to = findUser(getMyNick()); if(replyTo == NULL || from == NULL || to == NULL) { - fire(ClientListener::StatusMessage(), this, Util::validateMessage(param.substr(i), true)); + fire(ClientListener::StatusMessage(), this, unescape(param.substr(i))); } else { string msg = param.substr(j + 2); - fire(ClientListener::PrivateMessage(), this, *from, *to, *replyTo, Util::validateMessage(param.substr(j + 2), true)); + fire(ClientListener::PrivateMessage(), this, *from, *to, *replyTo, unescape(param.substr(j + 2))); } } else if(cmd == "$GetPass") { - setRegistered(true); + OnlineUser& ou = getUser(getMyNick()); + ou.getIdentity().set("RG", "1"); + setMyIdentity(ou.getIdentity()); fire(ClientListener::GetPassword(), this); } else if(cmd == "$BadPass") { fire(ClientListener::BadPassword(), this); @@ -681,18 +686,18 @@ checkstate(); dcdebug("NmdcHub::connectToMe %s\n", aUser.getIdentity().getNick().c_str()); ConnectionManager::getInstance()->nmdcExpect(aUser.getIdentity().getNick(), getMyNick(), getHubUrl()); - send("$ConnectToMe " + toNmdc(aUser.getIdentity().getNick()) + " " + getLocalIp() + ":" + Util::toString(ConnectionManager::getInstance()->getPort()) + "|"); + send("$ConnectToMe " + toAcp(aUser.getIdentity().getNick()) + " " + getLocalIp() + ":" + Util::toString(ConnectionManager::getInstance()->getPort()) + "|"); } void NmdcHub::revConnectToMe(const OnlineUser& aUser) { checkstate(); dcdebug("NmdcHub::revConnectToMe %s\n", aUser.getIdentity().getNick().c_str()); - send("$RevConnectToMe " + toNmdc(getMyNick()) + " " + toNmdc(aUser.getIdentity().getNick()) + "|"); + send("$RevConnectToMe " + toAcp(getMyNick()) + " " + toAcp(aUser.getIdentity().getNick()) + "|"); } void NmdcHub::hubMessage(const string& aMessage) { checkstate(); - send(toNmdc( "<" + getMyNick() + "> " + Util::validateMessage(aMessage, false) + "|" ) ); + send(toAcp( "<" + getMyNick() + "> " + escape(aMessage) + "|" ) ); } void NmdcHub::myInfo(bool alwaysSend) { @@ -726,9 +731,9 @@ string uMin = (SETTING(MIN_UPLOAD_SPEED) == 0) ? Util::emptyString : tmp5 + Util::toString(SETTING(MIN_UPLOAD_SPEED)); string myInfoA = - "$MyINFO $ALL " + toNmdc(checkNick(getMyNick())) + " " + toNmdc(Util::validateMessage(getMyIdentity().getDescription(), false)) + + "$MyINFO $ALL " + toAcp(getCurrentNick()) + " " + toAcp(NmdcHub::validateMessage(getCurrentDescription(), false)) + tmp1 + VERSIONSTRING + tmp2 + modeChar + tmp3 + getCounts() + tmp4 + Util::toString(SETTING(SLOTS)) + uMin + - ">$ $" + SETTING(UPLOAD_SPEED) + "\x01$" + toNmdc(Util::validateMessage(SETTING(EMAIL), false)) + '$'; + ">$ $" + SETTING(UPLOAD_SPEED) + "\x01$" + toAcp(NmdcHub::validateMessage(SETTING(EMAIL), false)) + '$'; string myInfoB = ShareManager::getInstance()->getShareSizeString() + "$|"; if(lastMyInfoA != myInfoA || alwaysSend || (lastMyInfoB != myInfoB && lastUpdate + 15*60*1000 < GET_TICK()) ){ @@ -750,7 +755,7 @@ AutoArray<char> buf((char*)NULL); char c1 = (aSizeType == SearchManager::SIZE_DONTCARE) ? 'F' : 'T'; char c2 = (aSizeType == SearchManager::SIZE_ATLEAST) ? 'F' : 'T'; - string tmp = Util::validateMessage(toNmdc((aFileType == SearchManager::TYPE_TTH) ? "TTH:" + aString : aString), false); + string tmp = NmdcHub::validateMessage(toAcp((aFileType == SearchManager::TYPE_TTH) ? "TTH:" + aString : aString), false); string::size_type i; while((i = tmp.find(' ')) != string::npos) { tmp[i] = '$'; @@ -762,15 +767,76 @@ chars = sprintf(buf, "$Search %s:%d %c?%c?%s?%d?%s|", x.c_str(), (int)SearchManager::getInstance()->getPort(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); } else { buf = new char[getMyNick().length() + aString.length() + 64]; - chars = sprintf(buf, "$Search Hub:%s %c?%c?%s?%d?%s|", toNmdc(getMyNick()).c_str(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); + chars = sprintf(buf, "$Search Hub:%s %c?%c?%s?%d?%s|", toAcp(getMyNick()).c_str(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); } send(buf, chars); } +string NmdcHub::validateMessage(string tmp, bool reverse, bool checkNewLines) { + string::size_type i = 0; + + if(reverse) { + while( (i = tmp.find("$", i)) != string::npos) { + tmp.replace(i, 5, "$"); + i++; + } + i = 0; + while( (i = tmp.find("|", i)) != string::npos) { + tmp.replace(i, 6, "|"); + i++; + } + i = 0; + while( (i = tmp.find("&", i)) != string::npos) { + tmp.replace(i, 5, "&"); + i++; + } + if(checkNewLines) { + // Check all '<' and '[' after newlines... + i = 0; + while( (i = tmp.find('\n', i)) != string::npos) { + if(i + 1 < tmp.length()) { + if(tmp[i+1] == '[' || tmp[i+1] == '<') { + tmp.insert(i+1, "- "); + i += 2; + } + } + i++; + } + } + } else { + i = 0; + while( (i = tmp.find("&", i)) != string::npos) { + tmp.replace(i, 1, "&"); + i += 4; + } + i = 0; + while( (i = tmp.find("$", i)) != string::npos) { + tmp.replace(i, 1, "&"); + i += 4; + } + i = 0; + while( (i = tmp.find("|", i)) != string::npos) { + tmp.replace(i, 1, "&"); + i += 4; + } + i = 0; + while( (i = tmp.find('$', i)) != string::npos) { + tmp.replace(i, 1, "$"); + i += 4; + } + i = 0; + while( (i = tmp.find('|', i)) != string::npos) { + tmp.replace(i, 1, "|"); + i += 5; + } + } + return tmp; +} + void NmdcHub::privateMessage(const OnlineUser& aUser, const string& aMessage) { checkstate(); - send("$To: " + toNmdc(aUser.getIdentity().getNick()) + " From: " + toNmdc(getMyNick()) + " $" + toNmdc(Util::validateMessage("<" + getMyNick() + "> " + aMessage, false)) + "|"); + send("$To: " + toAcp(aUser.getIdentity().getNick()) + " From: " + toAcp(getMyNick()) + " $" + toAcp(NmdcHub::validateMessage("<" + getMyNick() + "> " + aMessage, false)) + "|"); // Emulate a returning message... Lock l(cs); NickIter i = users.find(getMyNick()); @@ -779,18 +845,12 @@ } // TimerManagerListener -void NmdcHub::on(TimerManagerListener::Second, u_int32_t aTick) throw() { - if(socket && (getLastActivity() + getReconnDelay() * 1000) < aTick) { - // Nothing's happened for ~120 seconds, check if we're connected, if not, try to connect... - if(isConnected()) { - // Try to send something for the fun of it... - dcdebug("Testing writing...\n"); - send("|", 1); - } else { - // Try to reconnect... - if(reconnect && !getAddress().empty()) - connect(); - } +void NmdcHub::on(Second, u_int32_t aTick) throw() { + + if(isConnected() && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + // Try to send something for the fun of it... + dcdebug("Testing writing...\n"); + send("|", 1); } { Lock l(cs); @@ -803,6 +863,8 @@ flooders.pop_front(); } } + + Client::on(Second(), aTick); } // BufferedSocketListener Modified: dcplusplus/trunk/client/NmdcHub.h =================================================================== --- dcplusplus/trunk/client/NmdcHub.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/NmdcHub.h 2006-06-17 22:24:01 UTC (rev 617) @@ -33,7 +33,7 @@ class ClientManager; -class NmdcHub : public Client, private TimerManagerListener, private Flags +class NmdcHub : public Client, private Flags { public: using Client::send; @@ -44,18 +44,21 @@ virtual void hubMessage(const string& aMessage); virtual void privateMessage(const OnlineUser& aUser, const string& aMessage); - virtual void sendUserCmd(const string& aUserCmd) throw() { send(toNmdc(aUserCmd)); } + virtual void sendUserCmd(const string& aUserCmd) throw() { send(toAcp(aUserCmd)); } virtual void search(int aSizeType, int64_t aSize, int aFileType, const string& aString, const string& aToken); - virtual void password(const string& aPass) { send("$MyPass " + toNmdc(aPass) + "|"); } + virtual void password(const string& aPass) { send("$MyPass " + toAcp(aPass) + "|"); } virtual void info(bool force) { myInfo(force); } virtual size_t getUserCount() const { Lock l(cs); return users.size(); } virtual int64_t getAvailable() const; - virtual string escape(string const& str) const { return Util::validateMessage(str, false); } + virtual string escape(string const& str) const; + virtual string unescape(const string& str) const; virtual void send(const AdcCommand&) { dcassert(0); } + static string validateMessage(string tmp, bool reverse, bool checkNewLines); + GETSET(int, supportFlags, SupportFlags); private: friend class ClientManager; @@ -79,7 +82,6 @@ NickMap users; - bool reconnect; u_int32_t lastUpdate; string lastMyInfoA, lastMyInfoB; @@ -102,10 +104,10 @@ OnlineUser* findUser(const string& aNick); void putUser(const string& aNick); - string fromNmdc(const string& str) const { return Text::acpToUtf8(str); } - string toNmdc(const string& str) const { return Text::utf8ToAcp(str); } + string fromAcp(const string& str) const { return Text::acpToUtf8(str); } + string toAcp(const string& str) const { return Text::utf8ToAcp(str); } - void validateNick(const string& aNick) { send("$ValidateNick " + toNmdc(aNick) + "|"); } + void validateNick(const string& aNick) { send("$ValidateNick " + toAcp(aNick) + "|"); } void key(const string& aKey) { send("$Key " + aKey + "|"); } void version() { send("$Version 1,0091|"); } void getNickList() { send("$GetNickList|"); } @@ -119,7 +121,7 @@ virtual string checkNick(const string& aNick); // TimerManagerListener - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); + virtual void on(Second, u_int32_t aTick) throw(); virtual void on(Line, const string& l) throw() { onLine(l); } virtual void on(Failed, const string&) throw(); Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -489,7 +489,9 @@ q->setTTH(new TTHValue(*root)); } else if(!(*root == *q->getTTH())) { throw QueueException(STRING(FILE_WITH_DIFFERENT_TTH)); - } + } else if(BOOLSETTING(DONT_DL_ALREADY_QUEUED)) { + throw QueueException(STRING(FILE_IS_ALREADY_QUEUED)); + } } q->setFlag(aFlags); Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -25,102 +25,7 @@ #include <openssl/ssl.h> -SSLSocketFactory::SSLSocketFactory() -: clientContext(SSL_CTX_new(TLSv1_client_method())), - serverContext(SSL_CTX_new(TLSv1_server_method())), - dh(DH_new()), - certsLoaded(false) -{ - static unsigned char dh512_p[] = - { - 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75, - 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F, - 0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3, - 0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12, - 0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C, - 0x47,0x74,0xE8,0x33, - }; - static unsigned char dh512_g[] = - { - 0x02, - }; - - if(dh) { - dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), 0); - dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), 0); - - if (!dh->p || !dh->g) { - DH_free(dh); - dh = 0; - } else { - SSL_CTX_set_tmp_dh(serverContext, dh); - } - } -} - -void SSLSocketFactory::loadCertificates() throw() { - SSL_CTX_set_verify(serverContext, SSL_VERIFY_NONE, 0); - SSL_CTX_set_verify(clientContext, SSL_VERIFY_NONE, 0); - - if(!SETTING(SSL_CERTIFICATE_FILE).empty()) { - if(SSL_CTX_use_certificate_file(serverContext, SETTING(SSL_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load certificate file"); - return; - } - if(SSL_CTX_use_certificate_file(clientContext, SETTING(SSL_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load certificate file"); - return; - } - } - - if(!SETTING(SSL_PRIVATE_KEY_FILE).empty()) { - if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(SSL_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load private key"); - return; - } - if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(SSL_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load private key"); - return; - } - } - -#ifdef _WIN32 - WIN32_FIND_DATA data; - HANDLE hFind; - - hFind = FindFirstFile(Text::toT(SETTING(SSL_TRUSTED_CERTIFICATES_PATH) + "*.pem").c_str(), &data); - if(hFind != INVALID_HANDLE_VALUE) { - do { - if(SSL_CTX_load_verify_locations(clientContext, (SETTING(SSL_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); - } - } while(FindNextFile(hFind, &data)); - - FindClose(hFind); - } -#else -#error todo -#endif - certsLoaded = true; -} - -SSLSocketFactory::~SSLSocketFactory() { - if(serverContext) - SSL_CTX_free(serverContext); - if(clientContext) - SSL_CTX_free(clientContext); - if(dh) - DH_free(dh); -} - -SSLSocket* SSLSocketFactory::getClientSocket() throw(SocketException) { - return new SSLSocket(clientContext); -} -SSLSocket* SSLSocketFactory::getServerSocket() throw(SocketException) { - return new SSLSocket(serverContext); -} - SSLSocket::SSLSocket(SSL_CTX* context) throw(SocketException) : ctx(context), ssl(0) { } Modified: dcplusplus/trunk/client/SSLSocket.h =================================================================== --- dcplusplus/trunk/client/SSLSocket.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/SSLSocket.h 2006-06-17 22:24:01 UTC (rev 617) @@ -32,23 +32,8 @@ using namespace yaSSL; -class SSLSocketFactory : public Singleton<SSLSocketFactory> { -public: - SSLSocketFactory(); - virtual ~SSLSocketFactory(); +class CryptoManager; - SSLSocket* getClientSocket() throw(SocketException); - SSLSocket* getServerSocket() throw(SocketException); - - void loadCertificates() throw(); - bool hasCerts() const { return certsLoaded; } -private: - SSL_CTX* clientContext; - SSL_CTX* serverContext; - DH* dh; - bool certsLoaded; -}; - class SSLSocket : public Socket { public: virtual ~SSLSocket() throw() {} @@ -61,7 +46,7 @@ virtual void shutdown() throw(); virtual void close() throw(); private: - friend class SSLSocketFactory; + friend class CryptoManager; SSLSocket(SSL_CTX* context) throw(SocketException); SSLSocket(const SSLSocket&); Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -74,6 +74,7 @@ "BoldHub", "BoldPm", "BoldSearch", "SocketInBuffer", "SocketOutBuffer", "OnlyDlTthFiles", "OpenWaitingUsers", "BoldWaitingUsers", "OpenSystemLog", "BoldSystemLog", "AutoRefreshTime", "UseSsl", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", + "DontDlAlreadyQueued", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -258,6 +259,7 @@ setDefault(AUTO_KICK_NO_FAVS, false); setDefault(PROMPT_PASSWORD, false); setDefault(SPY_FRAME_IGNORE_TTH_SEARCHES, false); + setDefault(DONT_DL_ALREADY_QUEUED, false); #ifdef _WIN32 setDefault(MAIN_WINDOW_STATE, SW_SHOWNORMAL); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/SettingsManager.h 2006-06-17 22:24:01 UTC (rev 617) @@ -89,7 +89,8 @@ NO_IP_OVERRIDE, SEARCH_ONLY_FREE_SLOTS, LAST_SEARCH_TYPE, BOLD_FINISHED_DOWNLOADS, BOLD_FINISHED_UPLOADS, BOLD_QUEUE, BOLD_HUB, BOLD_PM, BOLD_SEARCH, SOCKET_IN_BUFFER, SOCKET_OUT_BUFFER, ONLY_DL_TTH_FILES, OPEN_WAITING_USERS, BOLD_WAITING_USERS, OPEN_SYSTEM_LOG, BOLD_SYSTEM_LOG, AUTO_REFRESH_TIME, - USE_SSL, AUTO_SEARCH_LIMIT, ALT_SORT_ORDER, AUTO_KICK_NO_FAVS, PROMPT_PASSWORD, SPY_FRAME_IGNORE_TTH_SEARCHES, + USE_SSL, AUTO_SEARCH_LIMIT, ALT_SORT_ORDER, AUTO_KICK_NO_FAVS, PROMPT_PASSWORD, SPY_FRAME_IGNORE_TTH_SEARCHES, + DONT_DL_ALREADY_QUEUED, INT_LAST }; enum Int64Setting { INT64_FIRST = INT_LAST + 1, Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -131,6 +131,7 @@ "File", "Files", "This file has no TTH", +"This file is already queued", "Subtract list", "File list refresh failed: ", "File list refresh finished", @@ -407,6 +408,7 @@ "Default away message", "Direct connection", "Directories", +"Don't download files already in the queue", "Don't download files already in share", "Default download directory", "Limits", @@ -740,6 +742,7 @@ "File", "Files", "FileHasNoTth", +"FileIsAlreadyQueued", "FileListDiff", "FileListRefreshFailed", "FileListRefreshFinished", @@ -1016,6 +1019,7 @@ "SettingsDefaultAwayMsg", "SettingsDirect", "SettingsDirectories", +"SettingsDontDlAlreadyQueued", "SettingsDontDlAlreadyShared", "SettingsDownloadDirectory", "SettingsDownloadLimits", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/StringDefs.h 2006-06-17 22:24:01 UTC (rev 617) @@ -134,6 +134,7 @@ FILE, // "File" FILES, // "Files" FILE_HAS_NO_TTH, // "This file has no TTH" + FILE_IS_ALREADY_QUEUED, // "This file is already queued" FILE_LIST_DIFF, // "Subtract list" FILE_LIST_REFRESH_FAILED, // "File list refresh failed: " FILE_LIST_REFRESH_FINISHED, // "File list refresh finished" @@ -410,6 +411,7 @@ SETTINGS_DEFAULT_AWAY_MSG, // "Default away message" SETTINGS_DIRECT, // "Direct connection" SETTINGS_DIRECTORIES, // "Directories" + SETTINGS_DONT_DL_ALREADY_QUEUED, // "Don't download files already in the queue" SETTINGS_DONT_DL_ALREADY_SHARED, // "Don't download files already in share" SETTINGS_DOWNLOAD_DIRECTORY, // "Default download directory" SETTINGS_DOWNLOAD_LIMITS, // "Limits" Modified: dcplusplus/trunk/client/User.cpp =================================================================== --- dcplusplus/trunk/client/User.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/User.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -22,8 +22,9 @@ #include "User.h" #include "Client.h" #include "StringTokenizer.h" +#include "FavoriteUser.h" -OnlineUser::OnlineUser(const User::Ptr& ptr, Client& client_, u_int32_t sid_) : user(ptr), identity(ptr, client_.getHubUrl(), sid_), client(&client_) { +OnlineUser::OnlineUser(const User::Ptr& ptr, Client& client_, u_int32_t sid_) : identity(ptr, sid_), client(&client_) { } @@ -64,3 +65,8 @@ } return false; } + +void FavoriteUser::update(const OnlineUser& info) { + setNick(info.getIdentity().getNick()); + setUrl(info.getClient().getHubUrl()); +} Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/User.h 2006-06-17 22:24:01 UTC (rev 617) @@ -98,9 +98,9 @@ }; Identity() : sid(0) { } - Identity(const User::Ptr& ptr, const string& aHubUrl, u_int32_t aSID) : user(ptr), hubUrl(aHubUrl), sid(aSID) { } - Identity(const Identity& rhs) : ::Flags(rhs), user(rhs.user), hubUrl(rhs.hubUrl), sid(rhs.sid), info(rhs.info) { } - Identity& operator=(const Identity& rhs) { user = rhs.user; hubUrl = rhs.hubUrl; sid = rhs.sid; info = rhs.info; return *this; } + Identity(const User::Ptr& ptr, u_int32_t aSID) : user(ptr), sid(aSID) { } + Identity(const Identity& rhs) : ::Flags(rhs), user(rhs.user), sid(rhs.sid), info(rhs.info) { } + Identity& operator=(const Identity& rhs) { user = rhs.user; sid = rhs.sid; info = rhs.info; return *this; } #define GS(n, x) const string& get##n() const { return get(x); } void set##n(const string& v) { set(x, v); } GS(Nick, "NI") @@ -127,8 +127,10 @@ bool supports(const string& name) const; bool isHub() const { return !get("HU").empty(); } bool isOp() const { return !get("OP").empty(); } + bool isRegistered() const { return !get("RG").empty(); } bool isHidden() const { return !get("HI").empty(); } bool isBot() const { return !get("BO").empty(); } + bool isAway() const { return !get("AW").empty(); } bool isTcpActive() const { return !getIp().empty() || (user->isSet(User::NMDC) && !user->isSet(User::PASSIVE)); } bool isUdpActive() const { return !getIp().empty() && !getUdpPort().empty(); } @@ -151,12 +153,10 @@ void getParams(StringMap& map, const string& prefix, bool compatibility) const; User::Ptr& getUser() { return user; } GETSET(User::Ptr, user, User); - GETSET(string, hubUrl, HubUrl); GETSET(u_int32_t, sid, SID); private: typedef map<short, string> InfMap; typedef InfMap::iterator InfIter; - InfMap info; }; @@ -170,15 +170,15 @@ OnlineUser(const User::Ptr& ptr, Client& client_, u_int32_t sid_); - operator User::Ptr&() { return user; } - operator const User::Ptr&() const { return user; } + operator User::Ptr&() { return getUser(); } + operator const User::Ptr&() const { return getUser(); } - User::Ptr& getUser() { return user; } + User::Ptr& getUser() { return getIdentity().getUser(); } + const User::Ptr& getUser() const { return getIdentity().getUser(); } Identity& getIdentity() { return identity; } Client& getClient() { return *client; } const Client& getClient() const { return *client; } - GETSET(User::Ptr, user, User); GETSET(Identity, identity, Identity); private: friend class NmdcHub; Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/Util.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -173,67 +173,6 @@ #endif // _WIN32 } -string Util::validateMessage(string tmp, bool reverse, bool checkNewLines) { - string::size_type i = 0; - - if(reverse) { - while( (i = tmp.find("$", i)) != string::npos) { - tmp.replace(i, 5, "$"); - i++; - } - i = 0; - while( (i = tmp.find("|", i)) != string::npos) { - tmp.replace(i, 6, "|"); - i++; - } - i = 0; - while( (i = tmp.find("&", i)) != string::npos) { - tmp.replace(i, 5, "&"); - i++; - } - if(checkNewLines) { - // Check all '<' and '[' after newlines... - i = 0; - while( (i = tmp.find('\n', i)) != string::npos) { - if(i + 1 < tmp.length()) { - if(tmp[i+1] == '[' || tmp[i+1] == '<') { - tmp.insert(i+1, "- "); - i += 2; - } - } - i++; - } - } - } else { - i = 0; - while( (i = tmp.find("&", i)) != string::npos) { - tmp.replace(i, 1, "&"); - i += 4; - } - i = 0; - while( (i = tmp.find("$", i)) != string::npos) { - tmp.replace(i, 1, "&"); - i += 4; - } - i = 0; - while( (i = tmp.find("|", i)) != string::npos) { - tmp.replace(i, 1, "&"); - i += 4; - } - i = 0; - while( (i = tmp.find('$', i)) != string::npos) { - tmp.replace(i, 1, "$"); - i += 4; - } - i = 0; - while( (i = tmp.find('|', i)) != string::npos) { - tmp.replace(i, 1, "|"); - i += 5; - } - } - return tmp; -} - #ifdef _WIN32 static const char badChars[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, Modified: dcplusplus/trunk/client/Util.h =================================================================== --- dcplusplus/trunk/client/Util.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/client/Util.h 2006-06-17 22:24:01 UTC (rev 617) @@ -489,8 +489,6 @@ static int stricmp(const wstring& a, const wstring& b) { return stricmp(a.c_str(), b.c_str()); } static int strnicmp(const wstring& a, const wstring& b, size_t n) { return strnicmp(a.c_str(), b.c_str(), n); } - static string validateMessage(string tmp, bool reverse, bool checkNewLines = true); - static string getOsVersion(); static string getIpCountry (string IP); Modified: dcplusplus/trunk/windows/CommandDlg.cpp =================================================================== --- dcplusplus/trunk/windows/CommandDlg.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/CommandDlg.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -84,7 +84,7 @@ dcassert(i != string::npos); tstring to = command.substr(5, i-5); string::size_type cmd_pos = command.find(_T('>'), 5) + 2; - tstring cmd = Text::toT(Util::validateMessage(Text::fromT(command.substr(cmd_pos, command.length()-cmd_pos-1)), true, false)); + tstring cmd = Text::toT(NmdcHub::validateMessage(Text::fromT(command.substr(cmd_pos, command.length()-cmd_pos-1)), true, false)); ctrlPM.SetCheck(BST_CHECKED); ctrlNick.SetWindowText(to.c_str()); ctrlCommand.SetWindowText(cmd.c_str()); @@ -94,7 +94,7 @@ { // Looks like a chat thing... string::size_type cmd_pos = command.find(_T('>')) + 2; - tstring cmd = Text::toT(Util::validateMessage(Text::fromT(command.substr(cmd_pos, command.length()-cmd_pos-1)), true, false)); + tstring cmd = Text::toT(NmdcHub::validateMessage(Text::fromT(command.substr(cmd_pos, command.length()-cmd_pos-1)), true, false)); ctrlChat.SetCheck(BST_CHECKED); ctrlCommand.SetWindowText(cmd.c_str()); } else { Modified: dcplusplus/trunk/windows/CommandDlg.h =================================================================== --- dcplusplus/trunk/windows/CommandDlg.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/CommandDlg.h 2006-06-17 22:24:01 UTC (rev 617) @@ -103,12 +103,12 @@ command = buf; } else if(type == 2) { ctrlCommand.GetWindowText(buf, BUF_LEN - 1); - command = Text::toT("<%[myNI]> " + Util::validateMessage(Text::fromT(buf), false) + "|"); + command = Text::toT("<%[myNI]> " + NmdcHub::validateMessage(Text::fromT(buf), false) + "|"); } else if(type == 3) { ctrlNick.GetWindowText(buf, BUF_LEN - 1); tstring to(buf); ctrlCommand.GetWindowText(buf, BUF_LEN - 1); - command = _T("$To: ") + to + _T(" From: %[myNI] $<%[myNI]> ") + Text::toT(Util::validateMessage(Text::fromT(buf), false)) + _T("|"); + command = _T("$To: ") + to + _T(" From: %[myNI] $<%[myNI]> ") + Text::toT(NmdcHub::validateMessage(Text::fromT(buf), false)) + _T("|"); } } void updateControls() { Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -960,10 +960,7 @@ } LRESULT HubFrame::onFileReconnect(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - client->disconnect(false); - clearUserList(); - clearTaskList(); - client->connect(); + client->reconnect(); return 0; } @@ -1190,7 +1187,7 @@ } } -void HubFrame::on(TimerManagerListener::Second, DWORD /*aTick*/) throw() { +void HubFrame::on(Second, DWORD /*aTick*/) throw() { updateStatusBar(); if(updateUsers) { updateUsers = false; @@ -1245,7 +1242,12 @@ speak(GET_PASSWORD); } void HubFrame::on(HubUpdated, Client*) throw() { - speak(SET_WINDOW_TITLE, Util::validateMessage(client->getHubName() + " " + client->getHubDescription(), true, false) + " (" + client->getHubUrl() + ")"); + string hubName = client->getHubName(); + if(!client->getHubDescription().empty()) { + hubName += " - " + client->getHubDescription(); + } + hubName += " (" + client->getHubUrl() + ")"; + speak(SET_WINDOW_TITLE, hubName); } void HubFrame::on(Message, Client*, const OnlineUser& from, const string& msg) throw() { speak(ADD_CHAT_LINE, Util::toDOS("<" + from.getIdentity().getNick() + "> " + msg)); Modified: dcplusplus/trunk/windows/MainFrm.cpp =================================================================== --- dcplusplus/trunk/windows/MainFrm.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/MainFrm.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -554,8 +554,8 @@ { PropertiesDlg dlg(m_hWnd, SettingsManager::getInstance()); - short lastPort = (short)SETTING(TCP_PORT); - short lastUDP = (short)SETTING(UDP_PORT); + unsigned short lastPort = (unsigned short)SETTING(TCP_PORT); + unsigned short lastUDP = (unsigned short)SETTING(UDP_PORT); int lastConn = SETTING(INCOMING_CONNECTIONS); if(dlg.DoModal(m_hWnd) == IDOK) Modified: dcplusplus/trunk/windows/QueuePage.cpp =================================================================== --- dcplusplus/trunk/windows/QueuePage.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/QueuePage.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -78,6 +78,7 @@ { SettingsManager::ANTI_FRAG, ResourceManager::SETTINGS_ANTI_FRAG }, { SettingsManager::ADVANCED_RESUME, ResourceManager::SETTINGS_ADVANCED_RESUME }, { SettingsManager::ONLY_DL_TTH_FILES, ResourceManager::SETTINGS_ONLY_DL_TTH_FILES }, + { SettingsManager::DONT_DL_ALREADY_QUEUED, ResourceManager::SETTINGS_DONT_DL_ALREADY_QUEUED }, { 0, ResourceManager::SETTINGS_AUTO_AWAY } }; Modified: dcplusplus/trunk/windows/UPnP.cpp =================================================================== --- dcplusplus/trunk/windows/UPnP.cpp 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/UPnP.cpp 2006-06-17 22:24:01 UTC (rev 617) @@ -24,7 +24,7 @@ #include <atlconv.h> #include "../client/Util.h" -UPnP::UPnP(const string theIPAddress, const string theProtocol, const string theDescription, const short thePort) { +UPnP::UPnP(const string theIPAddress, const string theProtocol, const string theDescription, const unsigned short thePort) { // need some messy string conversions in here // to convert STL::string to BSTR type strings // required for the UPnP code. Modified: dcplusplus/trunk/windows/UPnP.h =================================================================== --- dcplusplus/trunk/windows/UPnP.h 2006-06-17 15:40:35 UTC (rev 616) +++ dcplusplus/trunk/windows/UPnP.h 2006-06-17 22:24:01 UTC (rev 617) @@ -28,7 +28,7 @@ class UPnP { public: - UPnP( const string, const string, const string, const short ); + UPnP( const string, const string, const string, const unsigned short ); ~UPnP(); HRESULT OpenPorts(); HRESULT ClosePorts(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-06-18 15:13:39
|
Revision: 619 Author: arnetheduck Date: 2006-06-18 08:13:10 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=619&view=rev Log Message: ----------- More cleanup Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/DCPlusPlus.cpp dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/File.h dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/windows/CommandDlg.cpp dcplusplus/trunk/windows/CommandDlg.h dcplusplus/trunk/windows/FlatTabCtrl.h dcplusplus/trunk/windows/GeneralPage.cpp dcplusplus/trunk/windows/GeneralPage.h dcplusplus/trunk/windows/HubFrame.cpp Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/Example.xml 2006-06-18 15:13:10 UTC (rev 619) @@ -112,6 +112,7 @@ <String Name="ErrorCreatingRegistryKeyDchub">Error creating dchub registry key</String> <String Name="ErrorCreatingRegistryKeyMagnet">Error creating magnet registry key</String> <String Name="ErrorHashing">Error hashing </String> + <String Name="ErrorSavingHash">Error saving hash data: </String> <String Name="ExactSize">Exact size</String> <String Name="Executable">Executable</String> <String Name="FavJoinShowingOff">Join/part of favorite users showing off</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/changelog.txt 2006-06-18 15:13:10 UTC (rev 619) @@ -17,7 +17,11 @@ * Fixed auto-reconnect * [bug 936] Fixed duplicate entries in search hubs * Fixed some hub title display issues -* Some code spring cleanup +* Some spring cleanup +* [bug 970] Unix file permissions correctly set (thanks steven sheehy) +* [ADC] Allowed $ and | in nick/description +* Fixed targetdrive bug for temp target location +* Fixed a crash bug when hash data cannot be saved -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -133,7 +133,7 @@ u->getUser()->setFlag(User::SSL); } - if(u->getUser() == ClientManager::getInstance()->getMe()) { + if(u->getUser() == getMyIdentity().getUser()) { state = STATE_NORMAL; setMyIdentity(u->getIdentity()); updateCounts(false); @@ -519,9 +519,10 @@ string AdcHub::checkNick(const string& aNick) { string tmp = aNick; - string::size_type i = 0; - while( (i = tmp.find_first_of(" ", i)) != string::npos) { - tmp[i++]='_'; + for(size_t i = 0; i < aNick.size(); ++i) { + if(tmp[i] <= 32) { + tmp[i] = '_'; + } } return tmp; } Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/Client.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -74,7 +74,9 @@ } setPassword(hub->getPassword()); } else { - setCurrentNick(checkNick(SETTING(NICK))); + if(updateNick) { + setCurrentNick(checkNick(SETTING(NICK))); + } setCurrentDescription(SETTING(DESCRIPTION)); } } @@ -87,7 +89,7 @@ setReconnDelay(120 + Util::rand(0, 60)); reloadSettings(true); setRegistered(false); - setMyIdentity(Identity()); + setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0)); setHubIdentity(Identity()); try { Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -61,18 +61,7 @@ { Lock l(cs); - - // Either I'm stupid or the msvc7 optimizer is doing something _very_ strange here... - // STL-port -D_STL_DEBUG complains that .begin() and .end() don't have the same owner (!) - // dcassert(find(clients.begin(), clients.end(), aClient) != clients.end()); - // clients.erase(find(clients.begin(), clients.end(), aClient)); - - for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { - if(*i == aClient) { - clients.erase(i); - break; - } - } + clients.erase(remove(clients.begin(), clients.end(), aClient), clients.end()); } delete aClient; } Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -122,10 +122,10 @@ fire(ConnectionManagerListener::Removed(), cqi); if(cqi->getDownload()) { dcassert(find(downloads.begin(), downloads.end(), cqi) != downloads.end()); - downloads.erase(find(downloads.begin(), downloads.end(), cqi)); + downloads.erase(remove(downloads.begin(), downloads.end(), cqi), downloads.end()); } else { dcassert(find(uploads.begin(), uploads.end(), cqi) != uploads.end()); - uploads.erase(find(uploads.begin(), uploads.end(), cqi)); + uploads.erase(remove(uploads.begin(), uploads.end(), cqi), uploads.end()); } delete cqi; } Modified: dcplusplus/trunk/client/DCPlusPlus.cpp =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/DCPlusPlus.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -36,6 +36,13 @@ #include "StringTokenizer.h" +#ifdef _STLP_DEBUG +void __stl_debug_terminate() { + int* x = 0; + *x = 0; +} +#endif + void startup(void (*f)(void*, const string&), void* p) { // "Dedicated to the near-memory of Nev. Let's start remembering people while they're still alive." // Nev's great contribution to dc++ Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -86,46 +86,53 @@ return cmd; } -void DownloadManager::on(TimerManagerListener::Second, u_int32_t /*aTick*/) throw() { - Lock l(cs); +void DownloadManager::on(TimerManagerListener::Second, u_int32_t aTick) throw() { + typedef vector<pair<string, User::Ptr> > TargetList; + TargetList dropTargets; - Download::List tickList; - // Tick each ongoing download - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - if((*i)->getTotal() > 0) { - tickList.push_back(*i); + { + Lock l(cs); + + Download::List tickList; + // Tick each ongoing download + for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { + if((*i)->getTotal() > 0) { + tickList.push_back(*i); + } } - } - if(tickList.size() > 0) - fire(DownloadManagerListener::Tick(), tickList); + if(tickList.size() > 0) + fire(DownloadManagerListener::Tick(), tickList); + - // Automatically remove or disconnect slow sources - if((u_int32_t)(GET_TICK() / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - u_int32_t timeElapsed = GET_TICK() - (*i)->getStart(); - u_int32_t timeInactive = GET_TICK() - (*i)->getUserConnection()->getLastActivity(); - u_int64_t bytesDownloaded = (*i)->getTotal(); - bool timeElapsedOk = timeElapsed >= (u_int32_t)SETTING(AUTODROP_ELAPSED) * 1000; - bool timeInactiveOk = timeInactive <= (u_int32_t)SETTING(AUTODROP_INACTIVITY) * 1000; - bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ? - bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; - bool onlineSourcesOk = (*i)->isSet(Download::FLAG_USER_LIST) ? - true : QueueManager::getInstance()->countOnlineSources((*i)->getTarget()) >= SETTING(AUTODROP_MINSOURCES); - bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((size_t)SETTING(AUTODROP_FILESIZE)) * 1024; - bool dropIt = ((*i)->isSet(Download::FLAG_USER_LIST) && BOOLSETTING(AUTODROP_FILELISTS)) || - (filesizeOk && BOOLSETTING(AUTODROP_ALL)); - if(speedTooLow && onlineSourcesOk && dropIt) { - if(BOOLSETTING(AUTODROP_DISCONNECT) && !((*i)->isSet(Download::FLAG_USER_LIST))) { - (*i)->getUserConnection()->disconnect(); - } else { - QueueManager::getInstance()->removeSource((*i)->getTarget(), - (*i)->getUserConnection()->getUser(), QueueItem::Source::FLAG_SLOW_SOURCE); + // Automatically remove or disconnect slow sources + if((u_int32_t)(aTick / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { + for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { + u_int32_t timeElapsed = GET_TICK() - (*i)->getStart(); + u_int32_t timeInactive = GET_TICK() - (*i)->getUserConnection()->getLastActivity(); + u_int64_t bytesDownloaded = (*i)->getTotal(); + bool timeElapsedOk = timeElapsed >= (u_int32_t)SETTING(AUTODROP_ELAPSED) * 1000; + bool timeInactiveOk = timeInactive <= (u_int32_t)SETTING(AUTODROP_INACTIVITY) * 1000; + bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ? + bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; + bool onlineSourcesOk = (*i)->isSet(Download::FLAG_USER_LIST) ? + true : QueueManager::getInstance()->countOnlineSources((*i)->getTarget()) >= SETTING(AUTODROP_MINSOURCES); + bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((size_t)SETTING(AUTODROP_FILESIZE)) * 1024; + bool dropIt = ((*i)->isSet(Download::FLAG_USER_LIST) && BOOLSETTING(AUTODROP_FILELISTS)) || + (filesizeOk && BOOLSETTING(AUTODROP_ALL)); + if(speedTooLow && onlineSourcesOk && dropIt) { + if(BOOLSETTING(AUTODROP_DISCONNECT) && !((*i)->isSet(Download::FLAG_USER_LIST))) { + (*i)->getUserConnection()->disconnect(); + } else { + dropTargets.push_back(make_pair((*i)->getTarget(), (*i)->getUserConnection()->getUser())); + } } - continue; } } } + for(TargetList::iterator i = dropTargets.begin(); i != dropTargets.end(); ++i) { + QueueManager::getInstance()->removeSource(i->first, i->second, QueueItem::Source::FLAG_SLOW_SOURCE); + } } void DownloadManager::FileMover::moveFile(const string& source, const string& target) { @@ -237,7 +244,7 @@ Download* d = QueueManager::getInstance()->getDownload(aConn->getUser(), aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL)); - if(d == NULL) { + if(!d) { Lock l(cs); idlers.push_back(aConn); return; @@ -499,19 +506,11 @@ file->setPos(d->getPos()); } catch(const FileException& e) { delete file; - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, STRING(COULD_NOT_OPEN_TARGET_FILE) + e.getError()); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, STRING(COULD_NOT_OPEN_TARGET_FILE) + e.getError()); return false; } catch(const Exception& e) { delete file; - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, e.getError()); return false; } @@ -572,34 +571,16 @@ aSource->setLineMode(0); } } catch(const RollbackException& e) { - string target = d->getTarget(); - QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_ROLLBACK_INCONSISTENCY); - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - + QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_ROLLBACK_INCONSISTENCY); d->resetPos(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); - return; + failDownload(aSource, e.getError()); } catch(const FileException& e) { - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - d->resetPos(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); - return; + failDownload(aSource, e.getError()); } catch(const Exception& e) { - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); // Nuke the bytes we have written, this is probably a compression error d->resetPos(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); - return; + failDownload(aSource, e.getError()); } } @@ -626,12 +607,11 @@ removeDownload(d); fire(DownloadManagerListener::Failed(), d, STRING(INVALID_TREE)); - string target = d->getTarget(); + QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_BAD_TREE, false); aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, false); - QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_BAD_TREE, false); checkDownloads(aSource); return; } @@ -663,12 +643,7 @@ } } } catch(const FileException& e) { - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, e.getError()); return; } @@ -733,12 +708,10 @@ removeDownload(d); fire(DownloadManagerListener::Failed(), d, STRING(SFV_INCONSISTENCY)); - string target = d->getTarget(); - + QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_CRC_WARN, false); aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, false); - QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_CRC_WARN, false); checkDownloads(aSource); return false; } @@ -814,31 +787,23 @@ return; } - Download* d = aSource->getDownload(); - dcassert(d != NULL); - - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, STRING(NO_SLOTS_AVAILABLE)); - - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, STRING(NO_SLOTS_AVAILABLE)); } void DownloadManager::on(UserConnectionListener::Failed, UserConnection* aSource, const string& aError) throw() { + failDownload(aSource, aError); +} + +void DownloadManager::failDownload(UserConnection* aSource, const string& reason) { Download* d = aSource->getDownload(); - if(d == NULL) { - removeConnection(aSource); - return; - } - - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, aError); + if(d) { + removeDownload(d); + fire(DownloadManagerListener::Failed(), d, reason); - string target = d->getTarget(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); + aSource->setDownload(0); + QueueManager::getInstance()->putDownload(d, false); + } removeConnection(aSource); } @@ -855,7 +820,6 @@ d->setCrcCalc(NULL); if(d->isSet(Download::FLAG_ANTI_FRAG)) { - // Ok, set the pos to whereever it was last writing and hope for the best... d->unsetFlag(Download::FLAG_ANTI_FRAG); } } @@ -868,29 +832,17 @@ dcassert(find(downloads.begin(), downloads.end(), d) != downloads.end()); - // downloads.erase(find(downloads.begin(), downloads.end(), d)); + downloads.erase(remove(downloads.begin(), downloads.end(), d), downloads.end()); - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { +/* for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { if(*i == d) { downloads.erase(i); break; } - } + }*/ } } -void DownloadManager::abortDownload(const string& aTarget) { - Lock l(cs); - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - Download* d = *i; - if(d->getTarget() == aTarget) { - dcassert(d->getUserConnection() != NULL); - d->getUserConnection()->disconnect(); - break; - } - } -} - void DownloadManager::on(UserConnectionListener::FileNotAvailable, UserConnection* aSource) throw() { fileNotAvailable(aSource); } @@ -930,12 +882,6 @@ dcassert(d != NULL); dcdebug("File Not Available: %s\n", d->getTarget().c_str()); - if(d->getFile()) { - delete d->getFile(); - d->setFile(NULL); - d->setCrcCalc(NULL); - } - removeDownload(d); fire(DownloadManagerListener::Failed(), d, d->getTargetFileName() + ": " + STRING(FILE_NOT_AVAILABLE)); Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/DownloadManager.h 2006-06-18 15:13:10 UTC (rev 619) @@ -181,9 +181,6 @@ void checkIdle(const User::Ptr& user); - /** @internal */ - void abortDownload(const string& aTarget); - /** * @remarks This is only used in the tray icons. In MainFrame this is * calculated instead so there seems to be a little duplication of code. @@ -242,6 +239,8 @@ bool checkSfv(UserConnection* aSource, Download* d, u_int32_t crc); int64_t getResumePos(const string& file, const TigerTree& tt, int64_t startPos); + void failDownload(UserConnection* aSource, const string& reason); + friend class Singleton<DownloadManager>; DownloadManager() { TimerManager::getInstance()->addListener(this); Modified: dcplusplus/trunk/client/File.h =================================================================== --- dcplusplus/trunk/client/File.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/File.h 2006-06-18 15:13:10 UTC (rev 619) @@ -246,7 +246,7 @@ if(mode & TRUNCATE) { m |= O_TRUNC; } - h = open(aFileName.c_str(), m, S_IRUSR | S_IWUSR); + h = open(aFileName.c_str(), m, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if(h == -1) throw FileException("Could not open file"); } @@ -390,7 +390,7 @@ string acp = Text::utf8ToAcp(aFile); string::size_type start = 0; while( (start = aFile.find_first_of(L'/', start)) != string::npos) { - mkdir(aFile.substr(0, start+1).c_str(), 0755); + mkdir(aFile.substr(0, start+1).c_str(), S_IRWXU | S_IRWXG | S_IRWXO); start++; } } Modified: dcplusplus/trunk/client/HashManager.cpp =================================================================== --- dcplusplus/trunk/client/HashManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/HashManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -97,16 +97,20 @@ dirty = true; } -void HashManager::HashStore::addTree(const TigerTree& tt) { +void HashManager::HashStore::addTree(const TigerTree& tt) throw() { if(treeIndex.find(tt.getRoot()) == treeIndex.end()) { - File f(getDataFile(), File::READ|File::WRITE, File::OPEN); - int64_t index = saveTree(f, tt); - treeIndex.insert(make_pair(tt.getRoot(), TreeInfo(tt.getFileSize(), index, tt.getBlockSize()))); - dirty = true; + try { + File f(getDataFile(), File::READ|File::WRITE, File::OPEN); + int64_t index = saveTree(f, tt); + treeIndex.insert(make_pair(tt.getRoot(), TreeInfo(tt.getFileSize(), index, tt.getBlockSize()))); + dirty = true; + } catch(const FileException& e) { + LogManager::getInstance()->message(STRING(ERROR_SAVING_HASH) + e.getError()); + } } } -int64_t HashManager::HashStore::saveTree(File& f, const TigerTree& tt) { +int64_t HashManager::HashStore::saveTree(File& f, const TigerTree& tt) throw(FileException) { if(tt.getLeaves().size() == 1) return SMALL_TREE; @@ -310,8 +314,8 @@ File::renameFile(getIndexFile() + ".tmp", getIndexFile()); dirty = false; - } catch(const FileException&) { - // Too bad... + } catch(const FileException& e) { + LogManager::getInstance()->message(STRING(ERROR_SAVING_HASH) + e.getError()); } } } Modified: dcplusplus/trunk/client/HashManager.h =================================================================== --- dcplusplus/trunk/client/HashManager.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/HashManager.h 2006-06-18 15:13:10 UTC (rev 619) @@ -48,6 +48,7 @@ }; class HashLoader; +class FileException; class HashManager : public Singleton<HashManager>, public Speaker<HashManagerListener>, private TimerManagerListener @@ -194,7 +195,7 @@ bool checkTTH(const string& aFileName, int64_t aSize, u_int32_t aTimeStamp); - void addTree(const TigerTree& tt); + void addTree(const TigerTree& tt) throw(); const TTHValue* getTTH(const string& aFileName); bool getTree(const TTHValue& root, TigerTree& tth); bool isDirty() { return dirty; } @@ -244,7 +245,7 @@ void createDataFile(const string& name); bool loadTree(File& dataFile, const TreeInfo& ti, const TTHValue& root, TigerTree& tt); - int64_t saveTree(File& dataFile, const TigerTree& tt); + int64_t saveTree(File& dataFile, const TigerTree& tt) throw(FileException); string getIndexFile() { return Util::getConfigPath() + "HashIndex.xml"; } string getDataFile() { return Util::getConfigPath() + "HashData.dat"; } Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -84,7 +84,7 @@ } User::Ptr p; - if(aNick == getMyNick()) { + if(aNick == getCurrentNick()) { p = ClientManager::getInstance()->getMe(); } else { p = ClientManager::getInstance()->getUser(aNick, getHubUrl()); @@ -524,13 +524,14 @@ } key(CryptoManager::getInstance()->makeKey(lock)); - validateNick(getMyNick()); + OnlineUser& ou = getUser(getCurrentNick()); + validateNick(ou.getIdentity().getNick()); } } else if(cmd == "$Hello") { if(!param.empty()) { OnlineUser& u = getUser(param); - if(getMyNick() == param) { + if(u.getUser() == getMyIdentity().getUser()) { u.getUser()->setFlag(User::DCPLUSPLUS); if(ClientManager::getInstance()->isActive()) u.getUser()->unsetFlag(User::PASSIVE); @@ -538,7 +539,7 @@ u.getUser()->setFlag(User::PASSIVE); } - if(state == STATE_HELLO) { + if(state == STATE_HELLO && u.getUser() == getMyIdentity().getUser()) { state = STATE_CONNECTED; updateCounts(false); @@ -689,9 +690,10 @@ string NmdcHub::checkNick(const string& aNick) { string tmp = aNick; - string::size_type i = 0; - while( (i = tmp.find_first_of("|$ ", i)) != string::npos) { - tmp[i++]='_'; + for(size_t i = 0; i < aNick.size(); ++i) { + if(tmp[i] <= 32 || tmp[i] == '|' || tmp[i] == '$' || tmp[i] == '<' || tmp[i] == '>') { + tmp[i] = '_'; + } } return tmp; } @@ -745,7 +747,7 @@ string uMin = (SETTING(MIN_UPLOAD_SPEED) == 0) ? Util::emptyString : tmp5 + Util::toString(SETTING(MIN_UPLOAD_SPEED)); string myInfoA = - "$MyINFO $ALL " + toAcp(getCurrentNick()) + " " + toAcp(escape(getCurrentDescription())) + + "$MyINFO $ALL " + toAcp(getMyNick()) + " " + toAcp(escape(getCurrentDescription())) + tmp1 + VERSIONSTRING + tmp2 + modeChar + tmp3 + getCounts() + tmp4 + Util::toString(SETTING(SLOTS)) + uMin + ">$ $" + SETTING(UPLOAD_SPEED) + "\x01$" + toAcp(escape(SETTING(EMAIL))) + '$'; string myInfoB = ShareManager::getInstance()->getShareSizeString() + "$|"; Modified: dcplusplus/trunk/client/QueueItem.h =================================================================== --- dcplusplus/trunk/client/QueueItem.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/QueueItem.h 2006-06-18 15:13:10 UTC (rev 619) @@ -204,8 +204,6 @@ } } - string getSearchString() const; - const string& getTempTarget(); void setTempTarget(const string& aTempTarget) { tempTarget = aTempTarget; Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -62,9 +62,6 @@ return tmp; } } -string QueueItem::getSearchString() const { - return SearchManager::clean(getTargetFileName()); -} const string& QueueItem::getTempTarget() { if(!isSet(QueueItem::FLAG_USER_LIST) && tempTarget.empty()) { @@ -75,7 +72,7 @@ sm["targetdrive"] = target.substr(0, 3); else sm["targetdrive"] = Util::getConfigPath().substr(0, 3); - setTempTarget(Util::formatParams(SETTING(TEMP_DOWNLOAD_DIRECTORY), sm, true) + getTempName(getTargetFileName(), getTTH())); + setTempTarget(Util::formatParams(SETTING(TEMP_DOWNLOAD_DIRECTORY), sm, false) + getTempName(getTargetFileName(), getTTH())); #else //_WIN32 setTempTarget(SETTING(TEMP_DOWNLOAD_DIRECTORY) + getTempName(getTargetFileName(), getTTH())); #endif //_WIN32 @@ -219,9 +216,9 @@ } void QueueManager::UserQueue::add(QueueItem* qi, const User::Ptr& aUser) { - dcassert(qi->getStatus() == QueueItem::STATUS_WAITING); - dcassert(qi->isSource(aUser)); - dcassert(qi->getCurrent() == NULL); + if(qi->getStatus() == QueueItem::STATUS_RUNNING) { + return; + } QueueItem::List& l = userQueue[qi->getPriority()][aUser]; if(qi->isSet(QueueItem::FLAG_EXISTS)) { @@ -247,7 +244,8 @@ } void QueueManager::UserQueue::setRunning(QueueItem* qi, const User::Ptr& aUser) { - dcassert(qi->getCurrent() == NULL); + dcassert(qi->getCurrent() == 0); + dcassert(qi->getCurrentDownload() == 0); dcassert(qi->getStatus() == QueueItem::STATUS_WAITING); // Remove the download from the userQueue... @@ -260,13 +258,12 @@ // Move the download to the running list... dcassert(running.find(aUser) == running.end()); running[aUser] = qi; - } void QueueManager::UserQueue::setWaiting(QueueItem* qi) { - dcassert(qi->getCurrentDownload() != NULL); - dcassert(qi->getCurrent() != NULL); dcassert(qi->getStatus() == QueueItem::STATUS_RUNNING); + dcassert(qi->getCurrentDownload() != 0); + dcassert(qi->getCurrent() != 0); dcassert(running.find(qi->getCurrent()->getUser()) != running.end()); // Remove the download from running @@ -274,8 +271,8 @@ // Set flag to waiting qi->setStatus(QueueItem::STATUS_WAITING); - qi->setCurrent(NULL); - qi->setCurrentDownload(NULL); + qi->setCurrent(0); + qi->setCurrentDownload(0); // Add to the userQueue add(qi); @@ -283,26 +280,23 @@ QueueItem* QueueManager::UserQueue::getRunning(const User::Ptr& aUser) { QueueItem::UserIter i = running.find(aUser); - return (i == running.end()) ? NULL : i->second; + return (i == running.end()) ? 0 : i->second; } void QueueManager::UserQueue::remove(QueueItem* qi) { - if(qi->getStatus() == QueueItem::STATUS_RUNNING) { - dcassert(qi->getCurrent() != NULL); - remove(qi, qi->getCurrent()->getUser()); - } else { - for(QueueItem::Source::Iter i = qi->getSources().begin(); i != qi->getSources().end(); ++i) { - remove(qi, (*i)->getUser()); - } + for(QueueItem::Source::Iter i = qi->getSources().begin(); i != qi->getSources().end(); ++i) { + remove(qi, (*i)->getUser()); } } void QueueManager::UserQueue::remove(QueueItem* qi, const User::Ptr& aUser) { if(qi->getStatus() == QueueItem::STATUS_RUNNING) { - // Remove from running... - dcassert(qi->getCurrent() != NULL); - dcassert(running.find(aUser) != running.end()); - running.erase(aUser); + dcassert(qi->getCurrent() != 0); + if(qi->getCurrent()->getUser() == aUser) { + // Remove from running... + dcassert(running.find(aUser) != running.end()); + running.erase(aUser); + } } else { dcassert(qi->isSource(aUser)); dcassert(qi->getCurrent() == NULL); @@ -311,7 +305,7 @@ dcassert(j != ulm.end()); QueueItem::List& l = j->second; dcassert(find(l.begin(), l.end(), qi) != l.end()); - l.erase(find(l.begin(), l.end(), qi)); + l.erase(std::remove(l.begin(), l.end(), qi), l.end()); if(l.empty()) { ulm.erase(j); @@ -578,12 +572,11 @@ if(aUser->isSet(User::PASSIVE) && !ClientManager::getInstance()->isActive() ) { qi->removeSource(aUser, QueueItem::Source::FLAG_PASSIVE); wantConnection = false; - } else if(qi->getStatus() != QueueItem::STATUS_RUNNING) { + } else { userQueue.add(qi, aUser); + aUser->setFlag(User::SAVE_NICK); } - aUser->setFlag(User::SAVE_NICK); - fire(QueueManagerListener::SourcesUpdated(), qi); setDirty(); @@ -809,7 +802,6 @@ d->setStartPos(q->getDownloadedBytes()); } - fire(QueueManagerListener::StatusUpdated(), q); return d; } @@ -834,7 +826,7 @@ } else { QueueItem* q = fileQueue.find(aDownload->getTarget()); - if(q != NULL) { + if(q) { if(aDownload->isSet(Download::FLAG_USER_LIST)) { if(aDownload->getSource() == "files.xml.bz2") { q->setFlag(QueueItem::FLAG_XML_BZLIST); @@ -844,18 +836,16 @@ } if(finished) { - dcassert(q->getStatus() == QueueItem::STATUS_RUNNING); if(aDownload->isSet(Download::FLAG_TREE_DOWNLOAD)) { // Got a full tree, now add it to the HashManager dcassert(aDownload->getTreeValid()); HashManager::getInstance()->addTree(aDownload->getTigerTree()); - userQueue.setWaiting(q); - - fire(QueueManagerListener::StatusUpdated(), q); + if(q->getStatus() == QueueItem::STATUS_RUNNING) { + userQueue.setWaiting(q); + fire(QueueManagerListener::StatusUpdated(), q); + } } else { - fire(QueueManagerListener::Finished(), q, aDownload->getAverageSpeed()); - fire(QueueManagerListener::Removed(), q); // Now, let's see if this was a directory download filelist... if( (q->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD) && directories.find(q->getCurrent()->getUser()) != directories.end()) || (q->isSet(QueueItem::FLAG_MATCH_QUEUE)) ) @@ -864,7 +854,11 @@ up = q->getCurrent()->getUser(); flag = (q->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD) ? QueueItem::FLAG_DIRECTORY_DOWNLOAD : 0) | (q->isSet(QueueItem::FLAG_MATCH_QUEUE) ? QueueItem::FLAG_MATCH_QUEUE : 0); - } + } + + fire(QueueManagerListener::Finished(), q, aDownload->getAverageSpeed()); + fire(QueueManagerListener::Removed(), q); + userQueue.remove(q); fileQueue.remove(q); setDirty(); @@ -888,7 +882,7 @@ q->getOnlineUsers(getConn); } - // This might have been set to wait by removesource already... + // This might have been set to wait elsewhere already... if(q->getStatus() == QueueItem::STATUS_RUNNING) { userQueue.setWaiting(q); fire(QueueManagerListener::StatusUpdated(), q); @@ -901,7 +895,7 @@ } } } - aDownload->setUserConnection(NULL); + aDownload->setUserConnection(0); delete aDownload; } @@ -948,13 +942,13 @@ } void QueueManager::remove(const string& aTarget) throw() { - string x; + User::Ptr x; { Lock l(cs); QueueItem* q = fileQueue.find(aTarget); - if(q == NULL) + if(!q) return; if(q->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD)) { @@ -967,7 +961,7 @@ } if(q->getStatus() == QueueItem::STATUS_RUNNING) { - x = q->getTarget(); + x = q->getCurrent()->getUser(); } else if(!q->getTempTarget().empty() && q->getTempTarget() != q->getTarget()) { File::deleteFile(q->getTempTarget() + Download::ANTI_FRAG_EXT); File::deleteFile(q->getTempTarget()); @@ -981,18 +975,18 @@ setDirty(); } - if(!x.empty()) { - DownloadManager::getInstance()->abortDownload(x); + if(x) { + ConnectionManager::getInstance()->disconnect(x, true); } } void QueueManager::removeSource(const string& aTarget, User::Ptr& aUser, int reason, bool removeConn /* = true */) throw() { - string x; + bool isRunning = false; bool removeCompletely = false; { Lock l(cs); QueueItem* q = fileQueue.find(aTarget); - if(q == NULL) + if(!q) return; if(!q->isSource(aUser)) @@ -1019,23 +1013,22 @@ return; } } + if((q->getStatus() == QueueItem::STATUS_RUNNING) && q->getCurrent()->getUser() == aUser) { - if(removeConn) - x = q->getTarget(); + isRunning = true; userQueue.setWaiting(q); - userQueue.remove(q, aUser); - } else if(q->getStatus() == QueueItem::STATUS_WAITING) { - userQueue.remove(q, aUser); + fire(QueueManagerListener::StatusUpdated(), q); } + userQueue.remove(q, aUser); q->removeSource(aUser, reason); fire(QueueManagerListener::SourcesUpdated(), q); setDirty(); } endCheck: - if(!x.empty()) { - DownloadManager::getInstance()->abortDownload(x); + if(isRunning && removeConn) { + ConnectionManager::getInstance()->disconnect(aUser, true); } if(removeCompletely) { remove(aTarget); @@ -1043,7 +1036,7 @@ } void QueueManager::removeSource(User::Ptr& aUser, int reason) throw() { - string x; + bool isRunning = false; string removeRunning; { Lock l(cs); @@ -1060,22 +1053,23 @@ } qi = userQueue.getRunning(aUser); - if(qi != NULL) { + if(qi) { if(qi->isSet(QueueItem::FLAG_USER_LIST)) { removeRunning = qi->getTarget(); } else { userQueue.setWaiting(qi); userQueue.remove(qi, aUser); - x = qi->getTarget(); + isRunning = true; qi->removeSource(aUser, reason); + fire(QueueManagerListener::StatusUpdated(), qi); fire(QueueManagerListener::SourcesUpdated(), qi); setDirty(); } } } - if(!x.empty()) { - DownloadManager::getInstance()->abortDownload(x); + if(isRunning) { + ConnectionManager::getInstance()->disconnect(aUser, true); } if(!removeRunning.empty()) { remove(removeRunning); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -1181,7 +1181,7 @@ newStr = auto_ptr<StringSearch::List>(new StringSearch::List(aStrings)); } dcassert(find(newStr->begin(), newStr->end(), *k) != newStr->end()); - newStr->erase(find(newStr->begin(), newStr->end(), *k)); + newStr->erase(remove(newStr->begin(), newStr->end(), *k), newStr->end()); } } @@ -1313,7 +1313,7 @@ newStr = auto_ptr<StringSearch::List>(new StringSearch::List(*cur)); } dcassert(find(newStr->begin(), newStr->end(), *k) != newStr->end()); - newStr->erase(find(newStr->begin(), newStr->end(), *k)); + newStr->erase(remove(newStr->begin(), newStr->end(), *k), newStr->end()); } } Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -113,6 +113,7 @@ "Error creating dchub registry key", "Error creating magnet registry key", "Error hashing ", +"Error saving hash data: ", "Exact size", "Executable", "Join/part of favorite users showing off", @@ -724,6 +725,7 @@ "ErrorCreatingRegistryKeyDchub", "ErrorCreatingRegistryKeyMagnet", "ErrorHashing", +"ErrorSavingHash", "ExactSize", "Executable", "FavJoinShowingOff", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/StringDefs.h 2006-06-18 15:13:10 UTC (rev 619) @@ -116,6 +116,7 @@ ERROR_CREATING_REGISTRY_KEY_DCHUB, // "Error creating dchub registry key" ERROR_CREATING_REGISTRY_KEY_MAGNET, // "Error creating magnet registry key" ERROR_HASHING, // "Error hashing " + ERROR_SAVING_HASH, // "Error saving hash data: " EXACT_SIZE, // "Exact size" EXECUTABLE, // "Executable" FAV_JOIN_SHOWING_OFF, // "Join/part of favorite users showing off" Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -224,7 +224,7 @@ void UploadManager::removeUpload(Upload* aUpload) { Lock l(cs); dcassert(find(uploads.begin(), uploads.end(), aUpload) != uploads.end()); - uploads.erase(find(uploads.begin(), uploads.end(), aUpload)); + uploads.erase(remove(uploads.begin(), uploads.end(), aUpload), uploads.end()); aUpload->setUserConnection(NULL); delete aUpload; } Modified: dcplusplus/trunk/windows/CommandDlg.cpp =================================================================== --- dcplusplus/trunk/windows/CommandDlg.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/CommandDlg.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -19,10 +19,12 @@ #include "stdafx.h" #include "../client/DCPlusPlus.h" #include "Resource.h" + #include "../client/ResourceManager.h" - #include "../client/UserCommand.h" +#include "../client/NmdcHub.h" +#include "WinUtil.h" #include "CommandDlg.h" LRESULT CommandDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) @@ -194,3 +196,55 @@ HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_UCPAGE); return 0; } + +void CommandDlg::updateType() { + if(ctrlSeparator.GetCheck() == BST_CHECKED) { + type = 0; + } else if(ctrlRaw.GetCheck() == BST_CHECKED) { + type = 1; + } else if(ctrlChat.GetCheck() == BST_CHECKED) { + type = 2; + } else if(ctrlPM.GetCheck() == BST_CHECKED) { + type = 3; + } +} + +void CommandDlg::updateCommand() { + static const size_t BUF_LEN = 1024; + TCHAR buf[BUF_LEN]; + if(type == 0) { + command.clear(); + } else if(type == 1) { + ctrlCommand.GetWindowText(buf, BUF_LEN-1); + command = buf; + } else if(type == 2) { + ctrlCommand.GetWindowText(buf, BUF_LEN - 1); + command = Text::toT("<%[myNI]> " + NmdcHub::validateMessage(Text::fromT(buf), false) + "|"); + } else if(type == 3) { + ctrlNick.GetWindowText(buf, BUF_LEN - 1); + tstring to(buf); + ctrlCommand.GetWindowText(buf, BUF_LEN - 1); + command = _T("$To: ") + to + _T(" From: %[myNI] $<%[myNI]> ") + Text::toT(NmdcHub::validateMessage(Text::fromT(buf), false)) + _T("|"); + } +} + +void CommandDlg::updateControls() { + switch(type) { + case 0: + ctrlName.EnableWindow(FALSE); + ctrlCommand.EnableWindow(FALSE); + ctrlNick.EnableWindow(FALSE); + break; + case 1: + case 2: + ctrlName.EnableWindow(TRUE); + ctrlCommand.EnableWindow(TRUE); + ctrlNick.EnableWindow(FALSE); + break; + case 3: + ctrlName.EnableWindow(TRUE); + ctrlCommand.EnableWindow(TRUE); + ctrlNick.EnableWindow(TRUE); + break; + } +} Modified: dcplusplus/trunk/windows/CommandDlg.h =================================================================== --- dcplusplus/trunk/windows/CommandDlg.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/CommandDlg.h 2006-06-18 15:13:10 UTC (rev 619) @@ -23,9 +23,6 @@ #pragma once #endif // _MSC_VER > 1000 -#include "../client/Util.h" -#include "WinUtil.h" - class CommandDlg : public CDialogImpl<CommandDlg> { CEdit ctrlName; @@ -82,55 +79,9 @@ LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); private: - void updateType() { - if(ctrlSeparator.GetCheck() == BST_CHECKED) { - type = 0; - } else if(ctrlRaw.GetCheck() == BST_CHECKED) { - type = 1; - } else if(ctrlChat.GetCheck() == BST_CHECKED) { - type = 2; - } else if(ctrlPM.GetCheck() == BST_CHECKED) { - type = 3; - } - } - enum { BUF_LEN = 1024 }; - void updateCommand() { - TCHAR buf[BUF_LEN]; - if(type == 0) { - command.clear(); - } else if(type == 1) { - ctrlCommand.GetWindowText(buf, BUF_LEN-1); - command = buf; - } else if(type == 2) { - ctrlCommand.GetWindowText(buf, BUF_LEN - 1); - command = Text::toT("<%[myNI]> " + NmdcHub::validateMessage(Text::fromT(buf), false) + "|"); - } else if(type == 3) { - ctrlNick.GetWindowText(buf, BUF_LEN - 1); - tstring to(buf); - ctrlCommand.GetWindowText(buf, BUF_LEN - 1); - command = _T("$To: ") + to + _T(" From: %[myNI] $<%[myNI]> ") + Text::toT(NmdcHub::validateMessage(Text::fromT(buf), false)) + _T("|"); - } - } - void updateControls() { - switch(type) { - case 0: - ctrlName.EnableWindow(FALSE); - ctrlCommand.EnableWindow(FALSE); - ctrlNick.EnableWindow(FALSE); - break; - case 1: - case 2: - ctrlName.EnableWindow(TRUE); - ctrlCommand.EnableWindow(TRUE); - ctrlNick.EnableWindow(FALSE); - break; - case 3: - ctrlName.EnableWindow(TRUE); - ctrlCommand.EnableWindow(TRUE); - ctrlNick.EnableWindow(TRUE); - break; - } - } + void updateType(); + void updateCommand(); + void updateControls(); void updateContext(); }; Modified: dcplusplus/trunk/windows/FlatTabCtrl.h =================================================================== --- dcplusplus/trunk/windows/FlatTabCtrl.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/FlatTabCtrl.h 2006-06-18 15:13:10 UTC (rev 619) @@ -83,7 +83,7 @@ delete ti; tabs.erase(i); dcassert(find(viewOrder.begin(), viewOrder.end(), aWnd) != viewOrder.end()); - viewOrder.erase(find(viewOrder.begin(), viewOrder.end(), aWnd)); + viewOrder.erase(remove(viewOrder.begin(), viewOrder.end(), aWnd), viewOrder.end()); nextTab = viewOrder.end(); if(!viewOrder.empty()) --nextTab; @@ -137,7 +137,7 @@ void setTop(HWND aWnd) { dcassert(find(viewOrder.begin(), viewOrder.end(), aWnd) != viewOrder.end()); - viewOrder.erase(find(viewOrder.begin(), viewOrder.end(), aWnd)); + viewOrder.erase(remove(viewOrder.begin(), viewOrder.end(), aWnd), viewOrder.end()); viewOrder.push_back(aWnd); nextTab = --viewOrder.end(); } Modified: dcplusplus/trunk/windows/GeneralPage.cpp =================================================================== --- dcplusplus/trunk/windows/GeneralPage.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/GeneralPage.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -75,11 +75,11 @@ GetDlgItemText(wID, buf, SETTINGS_BUF_LEN); tstring old = buf; - // Strip '$', '|', '<', '>' and ' ' from text + // Strip ' ' from nick TCHAR *b = buf, *f = buf, c; while( (c = *b++) != 0 ) { - if(c != '$' && c != '|' && (wID == IDC_DESCRIPTION || c != ' ') && ( (wID != IDC_NICK) || (c != '<' && c != '>')) ) + if(c != ' ') *f++ = c; } Modified: dcplusplus/trunk/windows/GeneralPage.h =================================================================== --- dcplusplus/trunk/windows/GeneralPage.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/GeneralPage.h 2006-06-18 15:13:10 UTC (rev 619) @@ -39,8 +39,6 @@ MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) MESSAGE_HANDLER(WM_HELP, onHelp) COMMAND_HANDLER(IDC_NICK, EN_CHANGE, onTextChanged) - COMMAND_HANDLER(IDC_EMAIL, EN_CHANGE, onTextChanged) - COMMAND_HANDLER(IDC_DESCRIPTION, EN_CHANGE, onTextChanged) NOTIFY_CODE_HANDLER_EX(PSN_HELP, onHelpInfo) END_MSG_MAP() Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -1313,6 +1313,9 @@ tstring::size_type end = static_cast<tstring::size_type>(tstring::npos); int64_t multiplier = 1; + if(filter.empty()) { + return false; + } if(filter.compare(0, 2, _T(">=")) == 0) { mode = FilterModes::GREATER_EQUAL; start = 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-06-18 16:50:28
|
Revision: 620 Author: arnetheduck Date: 2006-06-18 09:50:11 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=620&view=rev Log Message: ----------- Reconnect fixes Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/windows/HubFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/changelog.txt 2006-06-18 16:50:11 UTC (rev 620) @@ -22,6 +22,7 @@ * [ADC] Allowed $ and | in nick/description * Fixed targetdrive bug for temp target location * Fixed a crash bug when hash data cannot be saved +* Possibly fixed issues with queue items not being updated -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -354,12 +354,6 @@ } } -void AdcHub::disconnect(bool graceless) { - Client::disconnect(graceless); - state = STATE_PROTOCOL; - clearUsers(); -} - void AdcHub::hubMessage(const string& aMessage) { if(state != STATE_NORMAL) return; @@ -545,6 +539,8 @@ void AdcHub::on(Failed, const string& aLine) throw() { clearUsers(); + socket->removeListener(this); + state = STATE_PROTOCOL; fire(ClientListener::Failed(), this, aLine); } @@ -557,3 +553,10 @@ sendUDP(cmd); send(cmd.toString(sid)); } + +void AdcHub::on(Second, u_int32_t aTick) throw() { + if(getAutoReconnect() && state == STATE_PROTOCOL && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + // Try to reconnect... + connect(); + } +} Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/AdcHub.h 2006-06-18 16:50:11 UTC (rev 620) @@ -33,10 +33,10 @@ class AdcHub : public Client, public CommandHandler<AdcHub> { public: using Client::send; + using Client::connect; virtual void connect(const OnlineUser& user); void connect(const OnlineUser& user, string const& token, bool secure); - virtual void disconnect(bool graceless); virtual void hubMessage(const string& aMessage); virtual void privateMessage(const OnlineUser& user, const string& aMessage); @@ -119,6 +119,8 @@ virtual void on(Connected) throw(); virtual void on(Line, const string& aLine) throw(); virtual void on(Failed, const string& aLine) throw(); + + virtual void on(Second, u_int32_t aTick) throw(); }; #endif // !defined(ADC_HUB_H) Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -459,6 +459,16 @@ return 0; } +void BufferedSocket::fail(const string& aError) { + if(sock) { + sock->disconnect(); + } + if(!failed) { + failed = true; + fire(BufferedSocketListener::Failed(), aError); + } +} + void BufferedSocket::shutdown() { if(sock) { Lock l(cs); Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-06-18 16:50:11 UTC (rev 620) @@ -170,13 +170,7 @@ void threadSendData(); void threadDisconnect(); - void fail(const string& aError) { - if(sock) - sock->disconnect(); - fire(BufferedSocketListener::Failed(), aError); - failed = true; - } - + void fail(const string& aError); static size_t sockets; bool checkEvents(); Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/Client.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -109,7 +109,6 @@ void Client::disconnect(bool graceLess) { if(!socket) return; - socket->removeListener(this); socket->disconnect(graceLess); } @@ -158,9 +157,5 @@ return lip; } -void Client::on(Second, u_int32_t aTick) throw() { - if(getAutoReconnect() && !isConnected() && (getLastActivity() + getReconnDelay() * 1000) < aTick) { - // Try to reconnect... - connect(); - } +void Client::on(Second, u_int32_t) throw() { } Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -296,9 +296,9 @@ return; int type = Util::toInt(param.substr(i, j-i)) - 1; i = j + 1; - string terms = param.substr(i); + string terms = unescape(param.substr(i)); - if(param.size() > 0) { + if(terms.size() > 0) { if(seeker.compare(0, 4, "Hub:") == 0) { OnlineUser* u = findUser(seeker.substr(4)); @@ -312,7 +312,7 @@ } } - fire(ClientListener::NmdcSearch(), this, seeker, a, Util::toInt64(size), type, param); + fire(ClientListener::NmdcSearch(), this, seeker, a, Util::toInt64(size), type, terms); } } else if(cmd == "$MyINFO") { string::size_type i, j; @@ -760,18 +760,12 @@ } } -void NmdcHub::disconnect(bool graceless) throw() { - Client::disconnect(graceless); - state = STATE_CONNECT; - clearUsers(); -} - void NmdcHub::search(int aSizeType, int64_t aSize, int aFileType, const string& aString, const string&) { checkstate(); AutoArray<char> buf((char*)NULL); char c1 = (aSizeType == SearchManager::SIZE_DONTCARE) ? 'F' : 'T'; char c2 = (aSizeType == SearchManager::SIZE_ATLEAST) ? 'F' : 'T'; - string tmp = toAcp(escape((aFileType == SearchManager::TYPE_TTH) ? "TTH:" + aString : aString)); + string tmp = ((aFileType == SearchManager::TYPE_TTH) ? "TTH:" + aString : toAcp(escape(aString))); string::size_type i; while((i = tmp.find(' ')) != string::npos) { tmp[i] = '$'; @@ -866,12 +860,15 @@ // TimerManagerListener void NmdcHub::on(Second, u_int32_t aTick) throw() { - - if(isConnected() && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + if(state == STATE_CONNECTED && (getLastActivity() + getReconnDelay() * 1000) < aTick) { // Try to send something for the fun of it... dcdebug("Testing writing...\n"); send("|", 1); + } else if(getAutoReconnect() && state == STATE_CONNECT && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + // Try to reconnect... + connect(); } + { Lock l(cs); @@ -891,6 +888,8 @@ void NmdcHub::on(BufferedSocketListener::Failed, const string& aLine) throw() { clearUsers(); + socket->removeListener(this); + if(state == STATE_CONNECTED) state = STATE_CONNECT; Modified: dcplusplus/trunk/client/NmdcHub.h =================================================================== --- dcplusplus/trunk/client/NmdcHub.h 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/NmdcHub.h 2006-06-18 16:50:11 UTC (rev 620) @@ -40,7 +40,6 @@ virtual void connect(); virtual void connect(const OnlineUser& aUser); - virtual void disconnect(bool graceless) throw(); virtual void hubMessage(const string& aMessage); virtual void privateMessage(const OnlineUser& aUser, const string& aMessage); Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -1415,9 +1415,10 @@ ctrlUsers.insertItem(i->second, getImage(i->second->getIdentity())); } } else { - for(UserMapIter i = userMap.begin(); i != userMap.end(); ++i){ - if(!ui->isHidden() && matchFilter(*i->second, sel, doSizeCompare, mode, size)) { - ctrlUsers.insertItem(i->second, getImage(i->second->getIdentity())); + for(UserMapIter i = userMap.begin(); i != userMap.end(); ++i) { + UserInfo* ui = i->second; + if(!ui->isHidden() && matchFilter(*ui, sel, doSizeCompare, mode, size)) { + ctrlUsers.insertItem(ui, getImage(ui->getIdentity())); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-06-19 19:17:14
|
Revision: 622 Author: arnetheduck Date: 2006-06-19 12:16:49 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=622&view=rev Log Message: ----------- Fixes / patches Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/client/version.h dcplusplus/trunk/windows/ExListViewCtrl.cpp dcplusplus/trunk/windows/ExListViewCtrl.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/WinUtil.cpp dcplusplus/trunk/windows/WinUtil.h Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-06-19 19:16:49 UTC (rev 622) @@ -933,8 +933,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,9,1 - PRODUCTVERSION 0,6,9,1 + FILEVERSION 0,6,9,2 + PRODUCTVERSION 0,6,9,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -951,12 +951,12 @@ BEGIN VALUE "Comments", "http://dcplusplus.sourceforge.net" VALUE "FileDescription", "DC++" - VALUE "FileVersion", "0, 6, 9, 1" + VALUE "FileVersion", "0, 6, 9, 2" VALUE "InternalName", "DC++" VALUE "LegalCopyright", "Copyright 2001-2006 Jacek Sieka" VALUE "OriginalFilename", "DCPlusPlus.exe" VALUE "ProductName", "DC++" - VALUE "ProductVersion", "0, 6, 9, 1" + VALUE "ProductVersion", "0, 6, 9, 2" END END BLOCK "VarFileInfo" Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/Example.xml 2006-06-19 19:16:49 UTC (rev 622) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version="0.691" Revision="1" RightToLeft="0"> +<Language Name="Example Language" Author="arnetheduck" Version="0.692" Revision="1" RightToLeft="0"> <Strings> <String Name="Active">Active</String> <String Name="ActiveSearchString">Enabled / Search String</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/changelog.txt 2006-06-19 19:16:49 UTC (rev 622) @@ -23,7 +23,11 @@ * Fixed targetdrive bug for temp target location * Fixed a crash bug when hash data cannot be saved * Possibly fixed issues with queue items not being updated +* Added warning when someone tries to spam hublist.org or dcpp.net with your client +* [bug 968] Fixed unix compile issue (thanks pothead) +* [bug 975] Fixed silly warning (thanks pothead) + -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog * [bug 122] Added userlist filter (thanks trem) Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-06-19 19:16:49 UTC (rev 622) @@ -29,6 +29,7 @@ #include "SimpleXML.h" #include "UserCommand.h" #include "ResourceManager.h" +#include "LogManager.h" #include "AdcHub.h" #include "NmdcHub.h" @@ -364,7 +365,15 @@ u_int16_t port = 0; Util::decodeUrl(aSeeker, ip, port, file); ip = Socket::resolve(ip); - if(port == 0) port = 412; + + // 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) + port = 412; for(SearchResult::Iter i = l.begin(); i != l.end(); ++i) { SearchResult* sr = *i; s.writeTo(ip, port, sr->toSR(*aClient)); Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-06-19 19:16:49 UTC (rev 622) @@ -800,22 +800,6 @@ tmp.replace(i, 5, "&"); i++; } -#if 0 -/// @todo move this to a better place - if(checkNewLines) { - // Check all '<' and '[' after newlines... - i = 0; - while( (i = tmp.find('\n', i)) != string::npos) { - if(i + 1 < tmp.length()) { - if(tmp[i+1] == '[' || tmp[i+1] == '<') { - tmp.insert(i+1, "- "); - i += 2; - } - } - i++; - } - } -#endif } else { i = 0; while( (i = tmp.find("&", i)) != string::npos) { Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/client/Util.cpp 2006-06-19 19:16:49 UTC (rev 622) @@ -341,24 +341,6 @@ return buf; } -double Util::toBytes(TCHAR* aSize) { - double bytes = _tstof(aSize); - - if (_tcsstr(aSize, CTSTRING(PIB))) { - return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(TiB))) { - return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(GiB))) { - return bytes * 1024.0 * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(MiB))) { - return bytes * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(KiB))) { - return bytes * 1024.0; - } else { - return bytes; - } -} - string Util::formatExactSize(int64_t aBytes) { #ifdef _WIN32 TCHAR buf[64]; @@ -916,3 +898,19 @@ } return tmp2; } + +string Util::formatMessage(const string& nick, const string& message) { + string tmp = '<' + nick + "> " + message; + // Check all '<' and '[' after newlines as they're probably pasts... + size_t i = 0; + while( (i = tmp.find('\n', i)) != string::npos) { + if(i + 1 < tmp.length()) { + if(tmp[i+1] == '[' || tmp[i+1] == '<') { + tmp.insert(i+1, "- "); + i += 2; + } + } + i++; + } + return toDOS(tmp); +} \ No newline at end of file Modified: dcplusplus/trunk/client/Util.h =================================================================== --- dcplusplus/trunk/client/Util.h 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/client/Util.h 2006-06-19 19:16:49 UTC (rev 622) @@ -274,8 +274,7 @@ return formatBytes(toInt64(aString)); } - static double toBytes(TCHAR* aSize); - + static string formatMessage(const string& nick, const string& message); static string toDOS(const string& tmp); static string getShortTimeString(time_t t = time(NULL) ); Modified: dcplusplus/trunk/client/version.h =================================================================== --- dcplusplus/trunk/client/version.h 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/client/version.h 2006-06-19 19:16:49 UTC (rev 622) @@ -17,8 +17,8 @@ */ #define APPNAME "DC++" -#define VERSIONSTRING "0.691" -#define VERSIONFLOAT 0.691 +#define VERSIONSTRING "0.692" +#define VERSIONFLOAT 0.692 /* Update the .rc file as well... */ Modified: dcplusplus/trunk/windows/ExListViewCtrl.cpp =================================================================== --- dcplusplus/trunk/windows/ExListViewCtrl.cpp 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/windows/ExListViewCtrl.cpp 2006-06-19 19:16:49 UTC (rev 622) @@ -45,9 +45,9 @@ lvi.iItem = newPos; } int i = InsertItem(&lvi); - int j = 0; - for(TStringIter k = l.begin(); k != l.end(); ++k, j++) { - SetItemText(i, j, k->c_str()); + int m = 0; + for(TStringIter k = l.begin(); k != l.end(); ++k, m++) { + SetItemText(i, m, k->c_str()); } EnsureVisible(i, FALSE); Modified: dcplusplus/trunk/windows/ExListViewCtrl.h =================================================================== --- dcplusplus/trunk/windows/ExListViewCtrl.h 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/windows/ExListViewCtrl.h 2006-06-19 19:16:49 UTC (rev 622) @@ -23,8 +23,8 @@ #pragma once #endif // _MSC_VER > 1000 -#include "../client/Util.h" #include "ListViewArrows.h" +#include "WinUtil.h" class ExListViewCtrl : public CWindowImpl<ExListViewCtrl, CListViewCtrl, CControlWinTraits>, public ListViewArrows<ExListViewCtrl> @@ -147,7 +147,7 @@ } else if(result == SORT_BYTES) { p->GetItemText(na, p->sortColumn, buf, 128); p->GetItemText(nb, p->sortColumn, buf2, 128); - result = compare(Util::toBytes(buf), Util::toBytes(buf2)); + result = compare(WinUtil::toBytes(buf), WinUtil::toBytes(buf2)); } if(!p->ascending) result = -result; Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-06-19 19:16:49 UTC (rev 622) @@ -1250,7 +1250,7 @@ speak(SET_WINDOW_TITLE, hubName); } void HubFrame::on(Message, Client*, const OnlineUser& from, const string& msg) throw() { - speak(ADD_CHAT_LINE, Util::toDOS("<" + from.getIdentity().getNick() + "> " + msg)); + speak(ADD_CHAT_LINE, Util::formatMessage(from.getIdentity().getNick(), msg)); } void HubFrame::on(StatusMessage, Client*, const string& line) { @@ -1268,7 +1268,7 @@ } void HubFrame::on(PrivateMessage, Client*, const OnlineUser& from, const OnlineUser& to, const OnlineUser& replyTo, const string& line) throw() { - speak(from, to, replyTo, Util::toDOS("<" + from.getIdentity().getNick() + "> " + line)); + speak(from, to, replyTo, Util::formatMessage(from.getIdentity().getNick(), line)); } void HubFrame::on(NickTaken, Client*) throw() { speak(ADD_STATUS_LINE, STRING(NICK_TAKEN)); Modified: dcplusplus/trunk/windows/WinUtil.cpp =================================================================== --- dcplusplus/trunk/windows/WinUtil.cpp 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/windows/WinUtil.cpp 2006-06-19 19:16:49 UTC (rev 622) @@ -1113,6 +1113,24 @@ } } +double WinUtil::toBytes(TCHAR* aSize) { + double bytes = _tstof(aSize); + + if (_tcsstr(aSize, CTSTRING(PIB))) { + return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(TiB))) { + return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(GiB))) { + return bytes * 1024.0 * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(MiB))) { + return bytes * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(KiB))) { + return bytes * 1024.0; + } else { + return bytes; + } +} + int WinUtil::getOsMajor() { OSVERSIONINFOEX ver; memset(&ver, 0, sizeof(OSVERSIONINFOEX)); Modified: dcplusplus/trunk/windows/WinUtil.h =================================================================== --- dcplusplus/trunk/windows/WinUtil.h 2006-06-18 21:46:33 UTC (rev 621) +++ dcplusplus/trunk/windows/WinUtil.h 2006-06-19 19:16:49 UTC (rev 622) @@ -312,6 +312,8 @@ static int getDirIconIndex() { return dirIconIndex; } static int getDirMaskedIndex() { return dirMaskedIndex; } + + static double toBytes(TCHAR* aSize); static int getOsMajor(); static int getOsMinor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-02 16:56:33
|
Revision: 623 Author: arnetheduck Date: 2006-07-02 09:52:24 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=623&view=rev Log Message: ----------- Patches, new yassl, some small fixes Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/DCPlusPlus.h dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/yassl/README dcplusplus/trunk/yassl/include/handshake.hpp dcplusplus/trunk/yassl/include/openssl/crypto.h dcplusplus/trunk/yassl/include/openssl/err.h dcplusplus/trunk/yassl/include/openssl/md5.h dcplusplus/trunk/yassl/include/openssl/rsa.h dcplusplus/trunk/yassl/include/openssl/ssl.h dcplusplus/trunk/yassl/include/socket_wrapper.hpp dcplusplus/trunk/yassl/include/yassl_error.hpp dcplusplus/trunk/yassl/include/yassl_int.hpp dcplusplus/trunk/yassl/include/yassl_types.hpp dcplusplus/trunk/yassl/mySTL/helpers.hpp dcplusplus/trunk/yassl/mySTL/list.hpp dcplusplus/trunk/yassl/mySTL/vector.hpp dcplusplus/trunk/yassl/src/cert_wrapper.cpp dcplusplus/trunk/yassl/src/handshake.cpp dcplusplus/trunk/yassl/src/socket_wrapper.cpp dcplusplus/trunk/yassl/src/ssl.cpp dcplusplus/trunk/yassl/src/template_instnt.cpp dcplusplus/trunk/yassl/src/timer.cpp dcplusplus/trunk/yassl/src/yassl.cpp dcplusplus/trunk/yassl/src/yassl_error.cpp dcplusplus/trunk/yassl/src/yassl_imp.cpp dcplusplus/trunk/yassl/src/yassl_int.cpp dcplusplus/trunk/yassl/taocrypt/include/asn.hpp dcplusplus/trunk/yassl/taocrypt/include/block.hpp dcplusplus/trunk/yassl/taocrypt/include/integer.hpp dcplusplus/trunk/yassl/taocrypt/include/misc.hpp dcplusplus/trunk/yassl/taocrypt/include/runtime.hpp dcplusplus/trunk/yassl/taocrypt/include/types.hpp dcplusplus/trunk/yassl/taocrypt/src/algebra.cpp dcplusplus/trunk/yassl/taocrypt/src/asn.cpp dcplusplus/trunk/yassl/taocrypt/src/integer.cpp dcplusplus/trunk/yassl/taocrypt/src/misc.cpp dcplusplus/trunk/yassl/taocrypt/src/random.cpp dcplusplus/trunk/yassl/taocrypt/src/template_instnt.cpp Added Paths: ----------- dcplusplus/trunk/yassl/include/openssl/engine.h dcplusplus/trunk/yassl/include/openssl/md4.h dcplusplus/trunk/yassl/include/openssl/pem.h dcplusplus/trunk/yassl/include/openssl/pkcs12.h dcplusplus/trunk/yassl/include/openssl/x509.h dcplusplus/trunk/yassl/include/openssl/x509v3.h dcplusplus/trunk/yassl/taocrypt/include/md4.hpp dcplusplus/trunk/yassl/taocrypt/src/md4.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/changelog.txt 2006-07-02 16:52:24 UTC (rev 623) @@ -26,8 +26,11 @@ * Added warning when someone tries to spam hublist.org or dcpp.net with your client * [bug 968] Fixed unix compile issue (thanks pothead) * [bug 975] Fixed silly warning (thanks pothead) +* [bug 978] Fixed 64-bit compiler issue (thanks steven sheehy) +* [bug 988] Only unique nicks diplayed in title bar +* Added protection from hubs/clients sending junk data resulting in high memory usage / crash +* Updated to yaSSL 1.3.7 - -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog * [bug 122] Added userlist filter (thanks trem) Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -540,7 +540,6 @@ void AdcHub::on(Failed, const string& aLine) throw() { clearUsers(); socket->removeListener(this); - state = STATE_PROTOCOL; fire(ClientListener::Failed(), this, aLine); } @@ -555,7 +554,7 @@ } void AdcHub::on(Second, u_int32_t aTick) throw() { - if(getAutoReconnect() && state == STATE_PROTOCOL && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + if(getAutoReconnect() && state == STATE_PROTOCOL && (getReconnecting() || ((getLastActivity() + getReconnDelay() * 1000) < aTick)) ) { // Try to reconnect... connect(); } Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -254,6 +254,10 @@ break; } } + + if(mode == MODE_LINE && line.size() > SETTING(MAX_COMMAND_LENGTH)) { + throw SocketException(STRING(COMMAND_TOO_LONG)); + } } void BufferedSocket::threadSendFile(InputStream* file) throw(Exception) { Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/Client.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -30,7 +30,7 @@ Client::Client(const string& hubURL, char separator_, bool secure_) : myIdentity(ClientManager::getInstance()->getMe(), 0), - reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(true), 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) { @@ -49,7 +49,7 @@ void Client::reconnect() { disconnect(true); setAutoReconnect(true); - resetActivtiy(); + setReconnecting(true); } void Client::shutdown() { @@ -86,6 +86,7 @@ BufferedSocket::putSocket(socket); setAutoReconnect(true); + setReconnecting(false); setReconnDelay(120 + Util::rand(0, 60)); reloadSettings(true); setRegistered(false); Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/Client.h 2006-07-02 16:52:24 UTC (rev 623) @@ -127,7 +127,6 @@ } void reconnect(); - void shutdown(); void send(const string& aMessage) { send(aMessage.c_str(), aMessage.length()); } @@ -155,6 +154,7 @@ GETSET(u_int32_t, lastActivity, LastActivity); GETSET(bool, registered, Registered); GETSET(bool, autoReconnect, AutoReconnect); + GETSET(bool, reconnecting, Reconnecting); GETSET(string, currentNick, CurrentNick); GETSET(string, currentDescription, CurrentDescription); @@ -177,7 +177,6 @@ void updateCounts(bool aRemove); void updateActivity() { lastActivity = GET_TICK(); } - void resetActivtiy() { lastActivity = 0; } /** Reload details from favmanager or settings */ void reloadSettings(bool updateNick); Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -94,21 +94,21 @@ StringList ClientManager::getNicks(const CID& cid) { Lock l(cs); - StringList lst; + StringSet nicks; OnlinePair op = onlineUsers.equal_range(cid); for(OnlineIter i = op.first; i != op.second; ++i) { - lst.push_back(i->second->getIdentity().getNick()); + nicks.insert(i->second->getIdentity().getNick()); } - if(lst.empty()) { + if(nicks.empty()) { // Offline perhaps? UserIter i = users.find(cid); if(i != users.end() && !i->second->getFirstNick().empty()) { - lst.push_back(i->second->getFirstNick()); + nicks.insert(i->second->getFirstNick()); } else { - lst.push_back('{' + cid.toBase32() + '}'); + nicks.insert('{' + cid.toBase32() + '}'); } } - return lst; + return StringList(nicks.begin(), nicks.end()); } string ClientManager::getConnection(const CID& cid) { Modified: dcplusplus/trunk/client/DCPlusPlus.h =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/DCPlusPlus.h 2006-07-02 16:52:24 UTC (rev 623) @@ -85,6 +85,9 @@ typedef HASH_MAP<string, string> StringMap; typedef StringMap::iterator StringMapIter; +typedef HASH_SET<string> StringSet; +typedef StringSet::iterator StringSetIter; + typedef vector<wstring> WStringList; typedef WStringList::iterator WStringIter; typedef WStringList::const_iterator WStringIterC; Modified: dcplusplus/trunk/client/HashManager.cpp =================================================================== --- dcplusplus/trunk/client/HashManager.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/HashManager.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -409,7 +409,7 @@ HashManager::HashStore::HashStore() : dirty(false) { - if(File::getSize(getDataFile()) <= sizeof(int64_t)) { + if(File::getSize(getDataFile()) <= static_cast<int64_t>(sizeof(int64_t))) { try { createDataFile(getDataFile()); } catch(const FileException&) { Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -848,7 +848,7 @@ // Try to send something for the fun of it... dcdebug("Testing writing...\n"); send("|", 1); - } else if(getAutoReconnect() && state == STATE_CONNECT && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + } else if(getAutoReconnect() && state == STATE_CONNECT && (getReconnecting() || ((getLastActivity() + getReconnDelay() * 1000) < aTick))) { // Try to reconnect... connect(); } @@ -871,11 +871,7 @@ // BufferedSocketListener void NmdcHub::on(BufferedSocketListener::Failed, const string& aLine) throw() { clearUsers(); - socket->removeListener(this); - - if(state == STATE_CONNECTED) - state = STATE_CONNECT; - - fire(ClientListener::Failed(), this, aLine); + state = STATE_CONNECT; + fire(ClientListener::Failed(), this, aLine); } Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -74,7 +74,7 @@ "BoldHub", "BoldPm", "BoldSearch", "SocketInBuffer", "SocketOutBuffer", "OnlyDlTthFiles", "OpenWaitingUsers", "BoldWaitingUsers", "OpenSystemLog", "BoldSystemLog", "AutoRefreshTime", "UseSsl", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", - "DontDlAlreadyQueued", + "DontDlAlreadyQueued", "MaxCommandLength", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -260,6 +260,7 @@ setDefault(PROMPT_PASSWORD, false); setDefault(SPY_FRAME_IGNORE_TTH_SEARCHES, false); setDefault(DONT_DL_ALREADY_QUEUED, false); + setDefault(MAX_COMMAND_LENGTH, 16*1024*1024); #ifdef _WIN32 setDefault(MAIN_WINDOW_STATE, SW_SHOWNORMAL); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/SettingsManager.h 2006-07-02 16:52:24 UTC (rev 623) @@ -90,7 +90,7 @@ BOLD_HUB, BOLD_PM, BOLD_SEARCH, SOCKET_IN_BUFFER, SOCKET_OUT_BUFFER, ONLY_DL_TTH_FILES, OPEN_WAITING_USERS, BOLD_WAITING_USERS, OPEN_SYSTEM_LOG, BOLD_SYSTEM_LOG, AUTO_REFRESH_TIME, USE_SSL, AUTO_SEARCH_LIMIT, ALT_SORT_ORDER, AUTO_KICK_NO_FAVS, PROMPT_PASSWORD, SPY_FRAME_IGNORE_TTH_SEARCHES, - DONT_DL_ALREADY_QUEUED, + DONT_DL_ALREADY_QUEUED, MAX_COMMAND_LENGTH, INT_LAST }; enum Int64Setting { INT64_FIRST = INT_LAST + 1, Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/client/StringDefs.h 2006-07-02 16:52:24 UTC (rev 623) @@ -51,6 +51,7 @@ CLOSING_CONNECTION, // "Closing connection..." COMPRESSED, // "Compressed" COMPRESSION_ERROR, // "Error during compression" + COMMAND_TOO_LONG, // "Maximum command length exceeded" CONFIGURE, // "&Configure" CONNECT, // "&Connect" CONNECT_FAVUSER_HUB, // "Connect to hub" Modified: dcplusplus/trunk/yassl/README =================================================================== --- dcplusplus/trunk/yassl/README 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/README 2006-07-02 16:52:24 UTC (rev 623) @@ -1,13 +1,66 @@ -yaSSL Release notes, version 1.2.2 (03/27/06) +yaSSL Release notes, version 1.3.7 (06/26/06) + This release of yaSSL contains bug fixes, portability enhancements, + and libcurl 7.15.4 support (any newer versions may not build). + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + +********************yaSSL Release notes, version 1.3.5 (06/01/06) + + + This release of yaSSL contains bug fixes, portability enhancements, + better libcurl support, and improved non-blocking I/O. + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + +********************yaSSL Release notes, version 1.3.0 (04/26/06) + + + This release of yaSSL contains minor bug fixes, portability enhancements, + and libcurl support. + +See normal build instructions below under 1.0.6. + + +--To build for libcurl on Linux, Solaris, *BSD, Mac OS X, or Cygwin: + + To build for libcurl the library needs to be built without C++ globals since + the linker will be called in a C context, also libcurl configure will expect + OpenSSL library names so some symbolic links are created. + + ./configure --enable-pure-c + make + make openssl-links + + (then go to your libcurl home and tell libcurl about yaSSL build dir) + ./configure --with-ssl=/yaSSL-BuildDir LDFLAGS=-lm + make + + +--To build for libcurl on Win32: + + Simply add the yaSSL project as a dependency to libcurl, add + yaSSL-Home\include and yaSSL-Home\include\openssl to the include list, and + define USE_SSLEAY and USE_OPENSSL + + please email to...@ya... if you have any questions. + + +*******************yaSSL Release notes, version 1.2.2 (03/27/06) + + This release of yaSSL contains minor bug fixes and portability enhancements. See build instructions below under 1.0.6: -*****************yaSSL Release notes, version 1.2.0 +*******************yaSSL Release notes, version 1.2.0 This release of yaSSL contains minor bug fixes, portability enhancements, Modified: dcplusplus/trunk/yassl/include/handshake.hpp =================================================================== --- dcplusplus/trunk/yassl/include/handshake.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/handshake.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -55,7 +55,7 @@ int sendData(SSL&, const void*, int); int sendAlert(SSL& ssl, const Alert& alert); -int receiveData(SSL&, Data&); +int receiveData(SSL&, Data&, bool peek = false); void processReply(SSL&); void buildFinished(SSL&, Finished&, const opaque*); Modified: dcplusplus/trunk/yassl/include/openssl/crypto.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/crypto.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/openssl/crypto.h 2006-07-02 16:52:24 UTC (rev 623) @@ -3,6 +3,10 @@ #ifndef ysSSL_crypto_h__ #define yaSSL_crypto_h__ +#ifdef YASSL_PREFIX +#include "prefix_crypto.h" +#endif + const char* SSLeay_version(int type); #define SSLEAY_VERSION 0x0900L Added: dcplusplus/trunk/yassl/include/openssl/engine.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/engine.h (rev 0) +++ dcplusplus/trunk/yassl/include/openssl/engine.h 2006-07-02 16:52:24 UTC (rev 623) @@ -0,0 +1,5 @@ +/* engine.h for libcurl */ + +#undef HAVE_OPENSSL_ENGINE_H + + Modified: dcplusplus/trunk/yassl/include/openssl/err.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/err.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/openssl/err.h 2006-07-02 16:52:24 UTC (rev 623) @@ -1,6 +1,6 @@ /* err.h for openssl */ -#ifndef ysSSL_err_h__ +#ifndef yaSSL_err_h__ #define yaSSL_err_h__ Added: dcplusplus/trunk/yassl/include/openssl/md4.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/md4.h (rev 0) +++ dcplusplus/trunk/yassl/include/openssl/md4.h 2006-07-02 16:52:24 UTC (rev 623) @@ -0,0 +1 @@ +/* md4.h for libcurl */ Modified: dcplusplus/trunk/yassl/include/openssl/md5.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/md5.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/openssl/md5.h 2006-07-02 16:52:24 UTC (rev 623) @@ -1 +1,4 @@ /* md5.h for openssl */ + +#include "ssl.h" /* in there for now */ + Added: dcplusplus/trunk/yassl/include/openssl/pem.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/pem.h (rev 0) +++ dcplusplus/trunk/yassl/include/openssl/pem.h 2006-07-02 16:52:24 UTC (rev 623) @@ -0,0 +1 @@ +/* pem.h for libcurl */ Added: dcplusplus/trunk/yassl/include/openssl/pkcs12.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/pkcs12.h (rev 0) +++ dcplusplus/trunk/yassl/include/openssl/pkcs12.h 2006-07-02 16:52:24 UTC (rev 623) @@ -0,0 +1,5 @@ +/* pkcs12.h for libcurl */ + + +#undef HAVE_OPENSSL_PKCS12_H + Modified: dcplusplus/trunk/yassl/include/openssl/rsa.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/rsa.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/openssl/rsa.h 2006-07-02 16:52:24 UTC (rev 623) @@ -1,7 +1,7 @@ /* rsa.h for openSSL */ -#ifndef ysSSL_rsa_h__ +#ifndef yaSSL_rsa_h__ #define yaSSL_rsa_h__ enum { RSA_F4 = 1 }; Modified: dcplusplus/trunk/yassl/include/openssl/ssl.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/ssl.h 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/openssl/ssl.h 2006-07-02 16:52:24 UTC (rev 623) @@ -25,12 +25,30 @@ -#ifndef ysSSL_openssl_h__ +#ifndef yaSSL_openssl_h__ #define yaSSL_openssl_h__ -#include <stdio.h> /* ERR_print fp */ +#ifdef YASSL_PREFIX +#include "prefix_ssl.h" +#endif + +#include <stdio.h> /* ERR_print fp */ +#include "opensslv.h" /* for version number */ #include "rsa.h" +#if defined(__cplusplus) +extern "C" { +#endif + + void yaSSL_CleanUp(); /* call once at end of application use to + free static singleton memory holders, + not a leak per se, but helpful when + looking for them */ + +#if defined(__cplusplus) +} // extern +#endif + #if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE) namespace yaSSL { extern "C" { @@ -102,7 +120,6 @@ typedef struct BIO BIO; /* ASN stuff */ -typedef struct ASN1_TIME ASN1_TIME; @@ -260,6 +277,7 @@ enum { /* ssl Constants */ + SSL_WOULD_BLOCK = -8, SSL_BAD_STAT = -7, SSL_BAD_PATH = -6, SSL_BAD_FILETYPE = -5, @@ -345,7 +363,8 @@ long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*); void OpenSSL_add_all_algorithms(void); -void SSLeay_add_ssl_algorithms(void); +int SSL_library_init(); +int SSLeay_add_ssl_algorithms(void); SSL_CIPHER* SSL_get_current_cipher(SSL*); @@ -358,11 +377,9 @@ /* EVP stuff, des and md5, different file? */ -typedef struct Digest Digest; -typedef Digest EVP_MD; +typedef char EVP_MD; -typedef struct BulkCipher BulkCipher; -typedef BulkCipher EVP_CIPHER; +typedef char EVP_CIPHER; typedef struct EVP_PKEY EVP_PKEY; @@ -370,6 +387,10 @@ typedef const DES_cblock const_DES_cblock; typedef DES_cblock DES_key_schedule; +enum { + DES_ENCRYPT = 1, + DES_DECRYPT = 0 +}; const EVP_MD* EVP_md5(void); const EVP_CIPHER* EVP_des_ede3_cbc(void); @@ -391,6 +412,112 @@ int RAND_load_file(const char*, long); +/* for libcurl */ +int RAND_status(void); +int RAND_bytes(unsigned char* buf, int num); + +int DES_set_key(const_DES_cblock*, DES_key_schedule*); +void DES_set_odd_parity(DES_cblock*); +void DES_ecb_encrypt(DES_cblock*, DES_cblock*, DES_key_schedule*, int); + +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata); +void SSL_SESSION_free(SSL_SESSION* session); +int SSL_peek(SSL* ssl, void* buf, int num); + +X509* SSL_get_certificate(SSL* ssl); +EVP_PKEY* SSL_get_privatekey(SSL* ssl); +EVP_PKEY* X509_get_pubkey(X509* x); + +int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from); +void EVP_PKEY_free(EVP_PKEY* pkey); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +void ERR_free_strings(void); +void EVP_cleanup(void); + +void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx); + +#define GEN_IPADD 7 +#define NID_subject_alt_name 85 +#define STACK_OF(x) x + + +/* defined here because libcurl dereferences */ +typedef struct ASN1_STRING { + int type; + int length; + unsigned char* data; +} ASN1_STRING; + + +typedef struct GENERAL_NAME { + int type; + union { + ASN1_STRING* ia5; + } d; +} GENERAL_NAME; + +void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x); + +int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x); +GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i); + + +unsigned char* ASN1_STRING_data(ASN1_STRING* x); +int ASN1_STRING_length(ASN1_STRING* x); +int ASN1_STRING_type(ASN1_STRING *x); + +typedef ASN1_STRING X509_NAME_ENTRY; + +int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos); + +ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne); +X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc); + +#define OPENSSL_malloc(x) malloc(x) +#define OPENSSL_free(x) free(x) + +int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in); + +SSL_METHOD* SSLv23_client_method(void); /* doesn't actually roll back */ +SSL_METHOD* SSLv2_client_method(void); /* will never work, no v 2 */ + + +SSL_SESSION* SSL_get1_session(SSL* ssl); /* what's ref count */ + + +#define CRYPTO_free(x) free(x) +#define ASN1_TIME ASN1_STRING + +ASN1_TIME* X509_get_notBefore(X509* x); +ASN1_TIME* X509_get_notAfter(X509* x); + + +#define ASN1_UTCTIME ASN1_STRING +#define NID_commonName 13 +#define V_ASN1_UTF8STRING 12 +#define GEN_DNS 2 + + +typedef struct MD4_CTX { + int buffer[32]; /* big enough to hold, check size in Init */ +} MD4_CTX; + +void MD4_Init(MD4_CTX*); +void MD4_Update(MD4_CTX*, const void*, unsigned long); +void MD4_Final(unsigned char*, MD4_CTX*); + + +typedef struct MD5_CTX { + int buffer[32]; /* big enough to hold, check size in Init */ +} MD5_CTX; + +void MD5_Init(MD5_CTX*); +void MD5_Update(MD5_CTX*, const void*, unsigned long); +void MD5_Final(unsigned char*, MD5_CTX*); + +#define MD5_DIGEST_LENGTH 16 + + #define SSL_DEFAULT_CIPHER_LIST "" /* default all */ Added: dcplusplus/trunk/yassl/include/openssl/x509.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/x509.h (rev 0) +++ dcplusplus/trunk/yassl/include/openssl/x509.h 2006-07-02 16:52:24 UTC (rev 623) @@ -0,0 +1 @@ +/* x509.h for libcurl */ Added: dcplusplus/trunk/yassl/include/openssl/x509v3.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/x509v3.h (rev 0) +++ dcplusplus/trunk/yassl/include/openssl/x509v3.h 2006-07-02 16:52:24 UTC (rev 623) @@ -0,0 +1 @@ +/* x509v3.h for libcurl */ Modified: dcplusplus/trunk/yassl/include/socket_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/socket_wrapper.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/socket_wrapper.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -66,6 +66,7 @@ // Wraps Windows Sockets and BSD Sockets class Socket { socket_t socket_; // underlying socket descriptor + bool wouldBlock_; // for non-blocking data public: explicit Socket(socket_t s = INVALID_SOCKET); ~Socket(); @@ -75,9 +76,10 @@ socket_t get_fd() const; uint send(const byte* buf, unsigned int len, int flags = 0) const; - uint receive(byte* buf, unsigned int len, int flags = 0) const; + uint receive(byte* buf, unsigned int len, int flags = 0); - bool wait() const; + bool wait(); + bool WouldBlock() const; void closeSocket(); void shutDown(int how = SD_SEND); Modified: dcplusplus/trunk/yassl/include/yassl_error.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_error.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/yassl_error.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -26,7 +26,6 @@ #ifndef yaSSL_ERROR_HPP #define yaSSL_ERROR_HPP -#include "stdexcept.hpp" namespace yaSSL { @@ -63,7 +62,7 @@ void SetErrorString(YasslError, char*); - +/* remove for now, if go back to exceptions use this wrapper // Base class for all yaSSL exceptions class Error : public mySTL::runtime_error { YasslError error_; @@ -75,6 +74,7 @@ YasslError get_number() const; Library get_lib() const; }; +*/ } // naemspace Modified: dcplusplus/trunk/yassl/include/yassl_int.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -34,6 +34,7 @@ #include "cert_wrapper.hpp" #include "log.hpp" #include "lock.hpp" +#include "openssl/ssl.h" // ASN1_STRING and DH namespace yaSSL { @@ -121,8 +122,6 @@ friend sslFactory& GetSSL_Factory(); // singleton creator private: - static sslFactory instance_; - sslFactory(const sslFactory&); // hide copy sslFactory& operator=(const sslFactory&); // and assign }; @@ -132,28 +131,47 @@ // openSSL X509 names class X509_NAME { - char* name_; + char* name_; + size_t sz_; + ASN1_STRING entry_; public: X509_NAME(const char*, size_t sz); ~X509_NAME(); - char* GetName(); + char* GetName(); + ASN1_STRING* GetEntry(int i); private: X509_NAME(const X509_NAME&); // hide copy X509_NAME& operator=(const X509_NAME&); // and assign }; +class StringHolder { + ASN1_STRING asnString_; +public: + StringHolder(const char* str, int sz); + ~StringHolder(); + + ASN1_STRING* GetString(); +}; + + // openSSL X509 class X509 { X509_NAME issuer_; X509_NAME subject_; + StringHolder beforeDate_; // not valid before + StringHolder afterDate_; // not valid after public: - X509(const char* i, size_t, const char* s, size_t); + X509(const char* i, size_t, const char* s, size_t, + const char* b, int, const char* a, int); ~X509() {} X509_NAME* GetIssuer(); X509_NAME* GetSubject(); + + ASN1_STRING* GetBefore(); + ASN1_STRING* GetAfter(); private: X509(const X509&); // hide copy X509& operator=(const X509&); // and assign @@ -214,8 +232,6 @@ friend Sessions& GetSessions(); // singleton creator private: - static Sessions instance_; - Sessions(const Sessions&); // hide copy Sessions& operator=(const Sessions&); // and assign }; @@ -505,6 +521,7 @@ void makeTLSMasterSecret(); void addData(input_buffer* data); void fillData(Data&); + void PeekData(Data&); void addBuffer(output_buffer* b); void flushBuffer(); void verifyState(const RecordLayerHeader&); Modified: dcplusplus/trunk/yassl/include/yassl_types.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_types.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/include/yassl_types.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -34,6 +34,7 @@ namespace yaSSL { + #ifdef YASSL_PURE_C // library allocation Modified: dcplusplus/trunk/yassl/mySTL/helpers.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/helpers.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/mySTL/helpers.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -28,14 +28,14 @@ #define mySTL_HELPERS_HPP #include <stdlib.h> -#include <new> // placement new +#ifdef _MSC_VER + #include <new> +#endif - - -#ifdef __IBMCPP__ /* Workaround for the lack of operator new(size_t, void*) in IBM VA C++ 6.0 + Also used as a workaround to avoid including <new> */ struct Dummy {}; @@ -44,12 +44,13 @@ return static_cast<void*>(d); } + // for compilers that want matching delete + inline void operator delete(void* ptr, Dummy* d) + { + } + typedef Dummy* yassl_pointer; -#else - typedef void* yassl_pointer; -#endif - namespace mySTL { Modified: dcplusplus/trunk/yassl/mySTL/list.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/list.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/mySTL/list.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -164,7 +164,7 @@ { void* mem = malloc(sizeof(node)); if (!mem) abort(); - node* add = new (mem) node(t); + node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t); if (head_) { add->next_ = head_; @@ -210,7 +210,7 @@ { void* mem = malloc(sizeof(node)); if (!mem) abort(); - node* add = new (mem) node(t); + node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t); if (tail_) { tail_->next_ = add; Modified: dcplusplus/trunk/yassl/mySTL/vector.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/vector.hpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/mySTL/vector.hpp 2006-07-02 16:52:24 UTC (rev 623) @@ -45,7 +45,8 @@ vector_base() : start_(0), finish_(0), end_of_storage_(0) {} vector_base(size_t n) { - start_ = static_cast<T*>(malloc(n * sizeof(T))); + // Don't allow malloc(0), if n is 0 use 1 + start_ = static_cast<T*>(malloc((n ? n : 1) * sizeof(T))); if (!start_) abort(); finish_ = start_; end_of_storage_ = start_ + n; Modified: dcplusplus/trunk/yassl/src/cert_wrapper.cpp =================================================================== --- dcplusplus/trunk/yassl/src/cert_wrapper.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/cert_wrapper.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -271,10 +271,13 @@ else peerKeyType_ = dsa_sa_algo; - int iSz = cert.GetIssuer() ? strlen(cert.GetIssuer()) + 1 : 0; - int sSz = cert.GetCommonName() ? strlen(cert.GetCommonName()) + 1 : 0; + int iSz = strlen(cert.GetIssuer()) + 1; + int sSz = strlen(cert.GetCommonName()) + 1; + int bSz = strlen(cert.GetBeforeDate()) + 1; + int aSz = strlen(cert.GetAfterDate()) + 1; peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(), - sSz); + sSz, cert.GetBeforeDate(), bSz, + cert.GetAfterDate(), aSz); } return 0; } Modified: dcplusplus/trunk/yassl/src/handshake.cpp =================================================================== --- dcplusplus/trunk/yassl/src/handshake.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/handshake.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -458,6 +458,11 @@ uint16 sz = ((b0 & 0x7f) << 8) | b1; + if (sz > input.get_remaining()) { + ssl.SetError(bad_input); + return; + } + // hashHandShake manually const opaque* buffer = input.get_buffer() + input.get_current(); ssl.useHashes().use_MD5().update(buffer, sz); @@ -650,16 +655,16 @@ } -mySTL::auto_ptr<input_buffer> null_buffer(ysDelete); // do process input requests mySTL::auto_ptr<input_buffer> DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered) { // wait for input if blocking - if (!ssl.getSocket().wait()) { + if (!ssl.useSocket().wait()) { ssl.SetError(receive_error); - return buffered = null_buffer; + buffered.reset(0); + return buffered; } uint ready = ssl.getSocket().get_ready(); if (!ready) return buffered; @@ -669,11 +674,11 @@ input_buffer buffer(buffSz + ready); if (buffSz) { buffer.assign(buffered.get()->get_buffer(), buffSz); - buffered = null_buffer; + buffered.reset(0); } - // add NEW_YS data - uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready); + // add new data + uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready); buffer.add_size(read); uint offset = 0; const MessageFactory& mf = ssl.getFactory().getMessage(); @@ -681,39 +686,56 @@ // old style sslv2 client hello? if (ssl.getSecurity().get_parms().entity_ == server_end && ssl.getStates().getServer() == clientNull) - if (buffer.peek() != handshake) + if (buffer.peek() != handshake) { ProcessOldClientHello(buffer, ssl); + if (ssl.GetError()) { + buffered.reset(0); + return buffered; + } + } while(!buffer.eof()) { // each record RecordLayerHeader hdr; - buffer >> hdr; - ssl.verifyState(hdr); + bool needHdr = false; + if (static_cast<uint>(RECORD_HEADER) > buffer.get_remaining()) + needHdr = true; + else { + buffer >> hdr; + ssl.verifyState(hdr); + } + // make sure we have enough input in buffer to process this record - if (hdr.length_ > buffer.get_remaining()) { - uint sz = buffer.get_remaining() + RECORD_HEADER; + if (needHdr || hdr.length_ > buffer.get_remaining()) { + // put header in front for next time processing + uint extra = needHdr ? 0 : RECORD_HEADER; + uint sz = buffer.get_remaining() + extra; buffered.reset(NEW_YS input_buffer(sz, buffer.get_buffer() + - buffer.get_current() - RECORD_HEADER, sz)); + buffer.get_current() - extra, sz)); break; } while (buffer.get_current() < hdr.length_ + RECORD_HEADER + offset) { - // each message in record + // each message in record, can be more than 1 if not encrypted if (ssl.getSecurity().get_parms().pending_ == false) // cipher on decrypt_message(ssl, buffer, hdr.length_); mySTL::auto_ptr<Message> msg(mf.CreateObject(hdr.type_), ysDelete); if (!msg.get()) { ssl.SetError(factory_error); - return buffered = null_buffer; + buffered.reset(0); + return buffered; } buffer >> *msg; msg->Process(buffer, ssl); - if (ssl.GetError()) return buffered = null_buffer; + if (ssl.GetError()) { + buffered.reset(0); + return buffered; + } } offset += hdr.length_ + RECORD_HEADER; } - return buffered; // done, don't call again + return buffered; } @@ -854,8 +876,11 @@ // send data int sendData(SSL& ssl, const void* buffer, int sz) { + if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ)) + ssl.SetError(no_error); + ssl.verfiyHandShakeComplete(); - if (ssl.GetError()) return 0; + if (ssl.GetError()) return -1; int sent = 0; for (;;) { @@ -866,7 +891,7 @@ buildMessage(ssl, out, data); ssl.Send(out.get_buffer(), out.get_size()); - if (ssl.GetError()) return 0; + if (ssl.GetError()) return -1; sent += len; if (sent == sz) break; } @@ -887,17 +912,29 @@ // process input data -int receiveData(SSL& ssl, Data& data) +int receiveData(SSL& ssl, Data& data, bool peek) { + if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ)) + ssl.SetError(no_error); + ssl.verfiyHandShakeComplete(); - if (ssl.GetError()) return 0; + if (ssl.GetError()) return -1; if (!ssl.bufferedData()) processReply(ssl); - ssl.fillData(data); + + if (peek) + ssl.PeekData(data); + else + ssl.fillData(data); + ssl.useLog().ShowData(data.get_length()); + if (ssl.GetError()) return -1; - if (ssl.GetError()) return 0; + if (data.get_length() == 0 && ssl.getSocket().WouldBlock()) { + ssl.SetError(YasslError(SSL_ERROR_WANT_READ)); + return SSL_WOULD_BLOCK; + } return data.get_length(); } Modified: dcplusplus/trunk/yassl/src/socket_wrapper.cpp =================================================================== --- dcplusplus/trunk/yassl/src/socket_wrapper.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/socket_wrapper.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -39,7 +39,7 @@ #include <string.h> #endif // _WIN32 -#ifdef __sun +#if defined(__sun) || defined(__SCO_VERSION__) #include <sys/filio.h> #endif @@ -58,7 +58,7 @@ Socket::Socket(socket_t s) - : socket_(s) + : socket_(s), wouldBlock_(false) {} @@ -95,11 +95,15 @@ uint Socket::get_ready() const { +#ifdef _WIN32 unsigned long ready = 0; - -#ifdef _WIN32 ioctlsocket(socket_, FIONREAD, &ready); #else + /* + 64-bit Solaris requires the variable passed to + FIONREAD be a 32-bit value. + */ + unsigned int ready = 0; ioctl(socket_, FIONREAD, &ready); #endif @@ -109,26 +113,39 @@ uint Socket::send(const byte* buf, unsigned int sz, int flags) const { + const byte* pos = buf; + const byte* end = pos + sz; + assert(socket_ != INVALID_SOCKET); - int sent = ::send(socket_, reinterpret_cast<const char *>(buf), sz, flags); - if (sent == -1) - return 0; + while (pos != end) { + int sent = ::send(socket_, reinterpret_cast<const char *>(pos), + static_cast<int>(end - pos), flags); - return sent; + if (sent == -1) + return 0; + + pos += sent; + } + + return sz; } -uint Socket::receive(byte* buf, unsigned int sz, int flags) const +uint Socket::receive(byte* buf, unsigned int sz, int flags) { assert(socket_ != INVALID_SOCKET); + wouldBlock_ = false; + int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags); // idea to seperate error from would block by arn...@gm... if (recvd == -1) { if (get_lastError() == SOCKET_EWOULDBLOCK || - get_lastError() == SOCKET_EAGAIN) + get_lastError() == SOCKET_EAGAIN) { + wouldBlock_ = true; return 0; + } } else if (recvd == 0) return static_cast<uint>(-1); @@ -138,7 +155,7 @@ // wait if blocking for input, return false for error -bool Socket::wait() const +bool Socket::wait() { byte b; return receive(&b, 1, MSG_PEEK) != static_cast<uint>(-1); @@ -162,6 +179,12 @@ } +bool Socket::WouldBlock() const +{ + return wouldBlock_; +} + + void Socket::set_lastError(int errorCode) { #ifdef _WIN32 Modified: dcplusplus/trunk/yassl/src/ssl.cpp =================================================================== --- dcplusplus/trunk/yassl/src/ssl.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/ssl.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -1,4 +1,4 @@ -/* ssl.cpp + /* ssl.cpp * * Copyright (C) 2003 Sawtooth Consulting Ltd. * @@ -35,6 +35,8 @@ #include "openssl/ssl.h" #include "handshake.hpp" #include "yassl_int.hpp" +#include "md5.hpp" // for TaoCrypt MD5 size assert +#include "md4.hpp" // for TaoCrypt MD4 size assert #include <stdio.h> #ifdef _WIN32 @@ -51,6 +53,53 @@ using mySTL::min; +int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) +{ + if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM) + return SSL_BAD_FILETYPE; + + FILE* input = fopen(file, "rb"); + if (!input) + return SSL_BAD_FILE; + + if (type == CA) { + x509* ptr = PemToDer(file, Cert); + if (!ptr) { + fclose(input); + return SSL_BAD_FILE; + } + ctx->AddCA(ptr); // takes ownership + } + else { + x509*& x = (type == Cert) ? ctx->certificate_ : ctx->privateKey_; + + if (format == SSL_FILETYPE_ASN1) { + fseek(input, 0, SEEK_END); + long sz = ftell(input); + rewind(input); + x = NEW_YS x509(sz); // takes ownership + size_t bytes = fread(x->use_buffer(), sz, 1, input); + if (bytes != 1) { + fclose(input); + return SSL_BAD_FILE; + } + } + else { + x = PemToDer(file, type); + if (!x) { + fclose(input); + return SSL_BAD_FILE; + } + } + } + fclose(input); + return SSL_SUCCESS; +} + + +extern "C" { + + SSL_METHOD* SSLv3_method() { return SSLv3_client_method(); @@ -447,50 +496,6 @@ } -int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) -{ - if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM) - return SSL_BAD_FILETYPE; - - FILE* input = fopen(file, "rb"); - if (!input) - return SSL_BAD_FILE; - - if (type == CA) { - x509* ptr = PemToDer(file, Cert); - if (!ptr) { - fclose(input); - return SSL_BAD_FILE; - } - ctx->AddCA(ptr); // takes ownership - } - else { - x509*& x = (type == Cert) ? ctx->certificate_ : ctx->privateKey_; - - if (format == SSL_FILETYPE_ASN1) { - fseek(input, 0, SEEK_END); - long sz = ftell(input); - rewind(input); - x = NEW_YS x509(sz); // takes ownership - size_t bytes = fread(x->use_buffer(), sz, 1, input); - if (bytes != 1) { - fclose(input); - return SSL_BAD_FILE; - } - } - else { - x = PemToDer(file, type); - if (!x) { - fclose(input); - return SSL_BAD_FILE; - } - } - } - fclose(input); - return SSL_SUCCESS; -} - - int SSL_CTX_use_certificate_file(SSL_CTX* ctx, const char* file, int format) { return read_file(ctx, file, format, Cert); @@ -722,6 +727,12 @@ {} +int SSL_library_init() // compatiblity only +{ + return 1; +} + + DH* DH_new(void) { DH* dh = NEW_YS DH; @@ -799,27 +810,34 @@ const EVP_MD* EVP_md5(void) { - // TODO: FIX add to some list for destruction - return NEW_YS MD5; + static const char* type = "MD5"; + return type; } const EVP_CIPHER* EVP_des_ede3_cbc(void) { - // TODO: FIX add to some list for destruction - return NEW_YS DES_EDE; + static const char* type = "DES_EDE3_CBC"; + return type; } int EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt, const byte* data, int sz, int count, byte* key, byte* iv) { - EVP_MD* myMD = const_cast<EVP_MD*>(md); - uint digestSz = myMD->get_digestSize(); + // only support MD5 for now + if (strncmp(md, "MD5", 3)) return 0; + + // only support DES_EDE3_CBC for now + if (strncmp(type, "DES_EDE3_CBC", 12)) return 0; + + yaSSL::MD5 myMD; + uint digestSz = myMD.get_digestSize(); byte digest[SHA_LEN]; // max size - int keyLen = type->get_keySize(); - int ivLen = type->get_ivSize(); + yaSSL::DES_EDE cipher; + int keyLen = cipher.get_keySize(); + int ivLen = cipher.get_ivSize(); int keyLeft = keyLen; int ivLeft = ivLen; int keyOutput = 0; @@ -828,17 +846,17 @@ int digestLeft = digestSz; // D_(i - 1) if (keyOutput) // first time D_0 is empty - myMD->update(digest, digestSz); + myMD.update(digest, digestSz); // data - myMD->update(data, sz); + myMD.update(data, sz); // salt if (salt) - myMD->update(salt, EVP_SALT_SZ); - myMD->get_digest(digest); + myMD.update(salt, EVP_SALT_SZ); + myMD.get_digest(digest); // count for (int j = 1; j < count; j++) { - myMD->update(digest, digestSz); - myMD->get_digest(digest); + myMD.update(digest, digestSz); + myMD.get_digest(digest); } if (keyLeft) { @@ -892,6 +910,303 @@ } +// functions for libcurl +int RAND_status() +{ + return 1; /* TaoCrypt provides enough seed */ +} + + +int DES_set_key(const_DES_cblock* key, DES_key_schedule* schedule) +{ + memcpy(schedule, key, sizeof(const_DES_cblock)); + return 1; +} + + +void DES_set_odd_parity(DES_cblock* key) +{ + // not needed now for TaoCrypt +} + + +void DES_ecb_encrypt(DES_cblock* input, DES_cblock* output, + DES_key_schedule* key, int enc) +{ + DES des; + + if (enc) { + des.set_encryptKey(*key, 0); + des.encrypt(*output, *input, DES_BLOCK); + } + else { + des.set_decryptKey(*key, 0); + des.decrypt(*output, *input, DES_BLOCK); + } +} + + +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata) +{ + // yaSSL doesn't support yet, unencrypt your PEM file with userdata + // before handing off to yaSSL +} + + +X509* SSL_get_certificate(SSL* ssl) +{ + // only used to pass to get_privatekey which isn't used + return 0; +} + + +EVP_PKEY* SSL_get_privatekey(SSL* ssl) +{ + // only called, not used + return 0; +} + + +void SSL_SESSION_free(SSL_SESSION* session) +{ + // managed by singleton +} + + + +EVP_PKEY* X509_get_pubkey(X509* x) +{ + // called, not used though + return 0; +} + + +int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from) +{ + // called, not used though + return 0; +} + + +void EVP_PKEY_free(EVP_PKEY* pkey) +{ + // never allocated from above +} + + +void ERR_error_string_n(unsigned long e, char *buf, size_t len) +{ + if (len) ERR_error_string(e, buf); +} + + +void ERR_free_strings(void) +{ + // handled internally +} + + +void EVP_cleanup(void) +{ + // nothing to do yet +} + + +ASN1_TIME* X509_get_notBefore(X509* x) +{ + if (x) return x->GetBefore(); + return 0; +} + + +ASN1_TIME* X509_get_notAfter(X509* x) +{ + if (x) return x->GetAfter(); + return 0; +} + + +SSL_METHOD* SSLv23_client_method(void) /* doesn't actually roll back */ +{ + return SSLv3_client_method(); +} + + +SSL_METHOD* SSLv2_client_method(void) /* will never work, no v 2 */ +{ + return 0; +} + + +SSL_SESSION* SSL_get1_session(SSL* ssl) /* what's ref count */ +{ + return SSL_get_session(ssl); +} + + +void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x) +{ + // no extension names supported yet +} + + +int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x) +{ + // no extension names supported yet + return 0; +} + + +GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i) +{ + // no extension names supported yet + return 0; +} + + +unsigned char* ASN1_STRING_data(ASN1_STRING* x) +{ + if (x) return x->data; + return 0; +} + + +int ASN1_STRING_length(ASN1_STRING* x) +{ + if (x) return x->length; + return 0; +} + + +int ASN1_STRING_type(ASN1_STRING *x) +{ + if (x) return x->type; + return 0; +} + + +int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos) +{ + int idx = -1; // not found + const char* start = &name->GetName()[lastpos + 1]; + + switch (nid) { + case NID_commonName: + const char* found = strstr(start, "/CN="); + if (found) { + found += 4; // advance to str + idx = found - start + lastpos + 1; + } + break; + } + + return idx; +} + + +ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne) +{ + // the same in yaSSL + return ne; +} + + +X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc) +{ + return name->GetEntry(loc); +} + + +// already formatted, caller responsible for freeing *out +int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in) +{ + if (!in) return 0; + + *out = (unsigned char*)malloc(in->length + 1); + if (*out) { + memcpy(*out, in->data, in->length); + (*out)[in->length] = 0; + } + return in->length; +} + + +void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx) +{ + // no extensions supported yet + return 0; +} + + +void MD4_Init(MD4_CTX* md4) +{ + // make sure we have a big enough buffer + typedef char ok[sizeof(md4->buffer) >= sizeof(TaoCrypt::MD4) ? 1 : -1]; + (void) sizeof(ok); + + // using TaoCrypt since no dynamic memory allocated + // and no destructor will be called + new (reinterpret_cast<yassl_pointer>(md4->buffer)) TaoCrypt::MD4(); +} + + +void MD4_Update(MD4_CTX* md4, const void* data, unsigned long sz) +{ + reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Update( + static_cast<const byte*>(data), static_cast<unsigned int>(sz)); +} + + +void MD4_Final(unsigned char* hash, MD4_CTX* md4) +{ + reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Final(hash); +} + + +void MD5_Init(MD5_CTX* md5) +{ + // make sure we have a big enough buffer + typedef char ok[sizeof(md5->buffer) >= sizeof(TaoCrypt::MD5) ? 1 : -1]; + (void) sizeof(ok); + + // using TaoCrypt since no dynamic memory allocated + // and no destructor will be called + new (reinterpret_cast<yassl_pointer>(md5->buffer)) TaoCrypt::MD5(); +} + + +void MD5_Update(MD5_CTX* md5, const void* data, unsigned long sz) +{ + reinterpret_cast<TaoCrypt::MD5*>(md5->buffer)->Update( + static_cast<const byte*>(data), static_cast<unsigned int>(sz)); +} + + +void MD5_Final(unsigned char* hash, MD5_CTX* md5) +{ + reinterpret_cast<TaoCrypt::MD5*>(md5->buffer)->Final(hash); +} + + +int RAND_bytes(unsigned char* buf, int num) +{ + RandomPool ran; + + if (ran.GetError()) return 0; + + ran.Fill(buf, num); + return 1; +} + + +int SSL_peek(SSL* ssl, void* buffer, int sz) +{ + Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer)); + return receiveData(*ssl, data, true); +} + + + // functions for stunnel void RAND_screen() @@ -1093,8 +1408,10 @@ } - void SSLeay_add_ssl_algorithms() // compatibility only - {} + int SSLeay_add_ssl_algorithms() // compatibility only + { + return 1; + } void ERR_remove_state(unsigned long) @@ -1124,4 +1441,5 @@ // end stunnel needs +} // extern "C" } // namespace Modified: dcplusplus/trunk/yassl/src/template_instnt.cpp =================================================================== --- dcplusplus/trunk/yassl/src/template_instnt.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/template_instnt.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -35,13 +35,6 @@ #include "openssl/ssl.h" #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION -#if !defined(USE_CRYPTOPP_LIB) -namespace TaoCrypt { -template class HMAC<MD5>; -template class HMAC<SHA>; -template class HMAC<RIPEMD160>; -} -#endif // USE_CRYPTOPP_LIB namespace mySTL { template class list<unsigned char*>; @@ -58,12 +51,16 @@ template class list<yaSSL::input_buffer*>; template class list<yaSSL::output_buffer*>; template class list<yaSSL::x509*>; +template class list<yaSSL::Digest*>; +template class list<yaSSL::BulkCipher*>; template void destroy<mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*); template yaSSL::del_ptr_zero for_each<mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<TaoCrypt::Signer*>::iterator, mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::x509*>::iterator, mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::Digest*>::iterator, mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::BulkCipher*>::iterator, mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero); } namespace yaSSL { @@ -87,6 +84,8 @@ template void ysDelete<Digest>(Digest*); template void ysDelete<X509>(X509*); template void ysDelete<Message>(Message*); +template void ysDelete<sslFactory>(sslFactory*); +template void ysDelete<Sessions>(Sessions*); template void ysArrayDelete<unsigned char>(unsigned char*); template void ysArrayDelete<char>(char*); } Modified: dcplusplus/trunk/yassl/src/timer.cpp =================================================================== --- dcplusplus/trunk/yassl/src/timer.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/timer.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -26,13 +26,17 @@ #include "runtime.hpp" #include "timer.hpp" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else +#include <sys/time.h> +#endif + namespace yaSSL { #ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - timer_d timer() { static bool init(false); @@ -57,8 +61,6 @@ #else // _WIN32 - #include <sys/time.h> - timer_d timer() { struct timeval tv; Modified: dcplusplus/trunk/yassl/src/yassl.cpp =================================================================== --- dcplusplus/trunk/yassl/src/yassl.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/yassl.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -31,7 +31,7 @@ #include "openssl/ssl.h" // get rid of this -/* + // yaSSL overloads hide these void* operator new[](size_t sz) { @@ -43,7 +43,7 @@ ::operator delete(ptr); } -*/ + namespace yaSSL { using mySTL::min; Modified: dcplusplus/trunk/yassl/src/yassl_error.cpp =================================================================== --- dcplusplus/trunk/yassl/src/yassl_error.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/yassl_error.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -26,10 +26,13 @@ #include "runtime.hpp" #include "yassl_error.hpp" #include "error.hpp" // TaoCrypt error numbers +#include "openssl/ssl.h" // SSL_ERROR_WANT_READ +#include <string.h> // strncpy namespace yaSSL { +/* may bring back in future Error::Error(const char* s, YasslError e, Library l) : mySTL::runtime_error(s), error_(e), lib_(l) { @@ -47,6 +50,7 @@ return lib_; } +*/ void SetErrorString(YasslError error, char* buffer) @@ -115,7 +119,12 @@ case certificate_error : strncpy(buffer, "unable to proccess cerificate", max); - break; + break; + + // openssl errors + case SSL_ERROR_WANT_READ : + strncpy(buffer, "the read operation would block", max); + break; // TaoCrypt errors case NO_ERROR : Modified: dcplusplus/trunk/yassl/src/yassl_imp.cpp =================================================================== --- dcplusplus/trunk/yassl/src/yassl_imp.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/yassl_imp.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -1329,7 +1329,8 @@ // Compression hello.comp_len_ = input[AUTO]; - hello.compression_methods_ = CompressionMethod(input[AUTO]); + while (hello.comp_len_--) // ignore for now + hello.compression_methods_ = CompressionMethod(input[AUTO]); return input; } @@ -1974,7 +1975,9 @@ : pre_master_secret_(0), sequence_number_(0), peer_sequence_number_(0), pre_secret_len_(0), send_server_key_(false), master_clean_(false), TLS_(v.major_ >= 3 && v.minor_ >= 1), version_(v), random_(ran) -{} +{ + memset(sessionID_, 0, sizeof(sessionID_)); +} Connection::~Connection() Modified: dcplusplus/trunk/yassl/src/yassl_int.cpp =================================================================== --- dcplusplus/trunk/yassl/src/yassl_int.cpp 2006-06-19 19:16:49 UTC (rev 622) +++ dcplusplus/trunk/yassl/src/yassl_int.cpp 2006-07-02 16:52:24 UTC (rev 623) @@ -28,7 +28,6 @@ #include "yassl_int.hpp" #include "handshake.hpp" #include "timer.hpp" -#include "openssl/ssl.h" // for DH #ifdef YASSL_PURE_C @@ -987,6 +986,36 @@ } +// like Fill but keep data in buffer +void SSL::PeekData(Data& data) +{ + if (GetError()) return; + uint dataSz = data.get_length(); // input, data size to fill + uint elements = buffers_.getData().size(); + + data.set_length(0); // output, actual data filled + dataSz = min(dataSz, bufferedData()); + + Buffers::inputList::iterator front = buffers_.getData().begin(); + + while (elements) { + uint frontSz = (*front)->get_remaining(); + uint readSz = min(dataSz - data.get_length(), frontSz); + uint before = (*front)->get_current(); + + (*front)->read(data.set_buffer() + data.get_length(), readSz); + data.set_length(data.get_length() + readSz); + (*front)->set_current(before); + + if (data.get_length() == dataSz) + break; + + elements--; + front++; + } +} + + // flush output buffer void SSL::flushBuffer() { @@ -1363,22 +1392,27 @@ } -Sessions Sessions::instance_; // simple singleton +static Sessions* sessionsInstance = 0; Sessions& GetSessions() { - return Sessions::instance_; + if (!sessionsInstance) + sessionsInstance = NEW_YS Sessions; + return *sessionsInstance; } -sslFactory sslFactory::instance_; // simple singleton +static sslFactory* sslFactoryInstance = 0; sslFactory& GetSSL_Factory() -{ - return sslFactory::instance_; +{ + if (!sslFactoryInstance) + sslFactoryInstance = NEW_YS sslFactory; + retur... [truncated message content] |
From: <arn...@us...> - 2006-07-02 21:00:38
|
Revision: 624 Author: arnetheduck Date: 2006-07-02 13:59:53 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=624&view=rev Log Message: ----------- Playing with ssl options Modified Paths: -------------- dcplusplus/trunk/Compile.txt dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/CryptoManager.h dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SSLSocket.h dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/User.h dcplusplus/trunk/client/UserConnection.h dcplusplus/trunk/windows/AdvancedPage.cpp dcplusplus/trunk/windows/CertificatesPage.cpp dcplusplus/trunk/windows/CertificatesPage.h dcplusplus/trunk/windows/TransferView.cpp dcplusplus/trunk/windows/resource.h dcplusplus/trunk/yassl/include/yassl_int.hpp dcplusplus/trunk/yassl/src/yassl.cpp dcplusplus/trunk/yassl/taocrypt/taocrypt.vcproj dcplusplus/trunk/yassl/yassl.vcproj Modified: dcplusplus/trunk/Compile.txt =================================================================== --- dcplusplus/trunk/Compile.txt 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/Compile.txt 2006-07-02 20:59:53 UTC (rev 624) @@ -4,7 +4,6 @@ 1) Download the source and STLPort from the DC++ download site. Unpack the DC++ source. Unpack the STLport source into the stlport directory. Download WTL from http://sf.net/projects/wtl. Unpack it to the wtl folder. - Download YaSSL from http://yassl.com/. Unpack it to the yassl folder. 2) You most probably have to update your Platform SDK, http://msdn.microsoft.com will tell you how. You have to do this if you get an error that "natupnp.h" is missing. Since all you need is this Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-07-02 20:59:53 UTC (rev 624) @@ -681,17 +681,20 @@ CAPTION "Security Certificates" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_SSL_PRIVATE_KEY_FILE,102,7,166,14,ES_AUTOHSCROLL - EDITTEXT IDC_SSL_CERTIFICATE_FILE,102,24,166,14,ES_AUTOHSCROLL - EDITTEXT IDC_SSL_TRUSTED_CERTIFICATES_PATH,102,42,166,14, + EDITTEXT IDC_TLS_PRIVATE_KEY_FILE,102,7,166,14,ES_AUTOHSCROLL + EDITTEXT IDC_TLS_CERTIFICATE_FILE,102,24,166,14,ES_AUTOHSCROLL + EDITTEXT IDC_TLS_TRUSTED_CERTIFICATES_PATH,102,42,166,14, ES_AUTOHSCROLL LTEXT "Private key file",IDC_STATIC,50,10,48,8 LTEXT "Own certificate file",IDC_STATIC,37,27,61,8 LTEXT "Trusted certificates path",IDC_STATIC,18,45,80,8 LTEXT "Under construction, restart dc++ to see effects...", - IDC_STATIC,7,90,163,8 + IDC_STATIC,7,186,163,8 LTEXT "Experimental feature, don't consider DC++ secure in any way", - IDC_STATIC,7,106,200,8 + IDC_STATIC,7,201,200,8 + CONTROL "",IDC_TLS_OPTIONS,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,15,72,243,90 END Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/Example.xml 2006-07-02 20:59:53 UTC (rev 624) @@ -40,6 +40,7 @@ <String Name="Browse">Browse...</String> <String Name="BrowseAccel">&Browse...</String> <String Name="BrowseFileList">Browse file list</String> + <String Name="CertificateNotTrusted">Certificate not trusted, unable to connect</String> <String Name="ChooseFolder">Choose folder</String> <String Name="Cid">CID</String> <String Name="Close">Close</String> @@ -47,6 +48,7 @@ <String Name="ClosingConnection">Closing connection...</String> <String Name="Compressed">Compressed</String> <String Name="CompressionError">Error during compression</String> + <String Name="CommandTooLong">Maximum command length exceeded</String> <String Name="Configure">&Configure</String> <String Name="Connect">&Connect</String> <String Name="ConnectFavuserHub">Connect to hub</String> @@ -301,6 +303,7 @@ <String Name="Offline">Offline</String> <String Name="Online">Online</String> <String Name="OnlyFreeSlots">Only users with free slots</String> + <String Name="OnlyTlsAllowed">Only TLS connections allowed</String> <String Name="OnlyTth">Only results with TTH root</String> <String Name="OnlyWhereOp">Only where I'm op</String> <String Name="Open">Open</String> @@ -369,6 +372,8 @@ <String Name="SettingsAdvanced3">Advanced\Experts only</String> <String Name="SettingsAdvancedResume">Advanced resume using TTH</String> <String Name="SettingsAdvancedSettings">Advanced settings</String> + <String Name="SettingsAllowUntrustedClients">Allow TLS connections to hubs without trusted certificate</String> + <String Name="SettingsAllowUntrustedHubs">Allow TLS connections to hubs without trusted certificate</String> <String Name="SettingsAntiFrag">Use antifragmentation method for downloads</String> <String Name="SettingsAppearance">Appearance</String> <String Name="SettingsAppearance2">Appearance\Colors and sounds</String> @@ -415,7 +420,7 @@ <String Name="SettingsDownloads">Downloads</String> <String Name="SettingsDownloadsMax">Maximum simultaneous downloads (0 = infinite)</String> <String Name="SettingsDownloadsSpeedPause">No new downloads if speed exceeds (KiB/s, 0 = disable)</String> - <String Name="SettingsExampleText">Donate €€€:s! (ok, dirty dollars are fine as well =) (see help menu)</String> + <String Name="SettingsExampleText">Donate €€€:s! (ok, dirty dollars are fine as well =) (see help menu)</String> <String Name="SettingsExternalIp">External / WAN IP</String> <String Name="SettingsFavShowJoins">Only show joins / parts for favorite users</String> <String Name="SettingsFavoriteDirsPage">Downloads\Favorites</String> @@ -524,7 +529,7 @@ <String Name="SettingsWindowsOptions">Window options</String> <String Name="SettingsWriteBuffer">Write buffer size</String> <String Name="SettingsAltSortOrder">Sort all downloads first</String> - <String Name="SettingsUseSsl">Use SSL when remote client supports it</String> + <String Name="SettingsUseTls">Use TLS when remote client supports it</String> <String Name="SfvInconsistency">CRC32 inconsistency (SFV-Check)</String> <String Name="Shared">Shared</String> <String Name="SharedFiles">Shared Files</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/changelog.txt 2006-07-02 20:59:53 UTC (rev 624) @@ -30,6 +30,7 @@ * [bug 988] Only unique nicks diplayed in title bar * Added protection from hubs/clients sending junk data resulting in high memory usage / crash * Updated to yaSSL 1.3.7 +* Added a few TLS options; [U] in transfer status means untrusted TLS (encrypted but certificate not validated) -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -130,7 +130,7 @@ } if(u->getIdentity().supports(ADCS_FEATURE)) { - u->getUser()->setFlag(User::SSL); + u->getUser()->setFlag(User::TLS); } if(u->getUser() == getMyIdentity().getUser()) { @@ -218,13 +218,26 @@ if(c.getParameters().size() < 3) return; + const string& protocol = c.getParam(0); + const string& port = c.getParam(1); + + string token; + bool hasToken = c.getParam("TO", 2, token); + bool secure; - if(c.getParam(0) == CLIENT_PROTOCOL) { + if(protocol == CLIENT_PROTOCOL) { secure = false; - } else if(c.getParam(0) == SECURE_CLIENT_PROTOCOL) { + } else if(protocol == SECURE_CLIENT_PROTOCOL && CryptoManager::getInstance()->TLSOk()) { secure = true; } else { - send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown", AdcCommand::TYPE_DIRECT).setTo(c.getFrom())); + 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); + + send(cmd); return; } @@ -233,22 +246,40 @@ return; } - string token; - c.getParam("TO", 2, token); - ConnectionManager::getInstance()->adcConnect(*u, (short)Util::toInt(c.getParameters()[1]), token, secure); + ConnectionManager::getInstance()->adcConnect(*u, (short)Util::toInt(port), token, secure); } void AdcHub::handle(AdcCommand::RCM, AdcCommand& c) throw() { + if(c.getParameters().empty()) { + return; + } if(!ClientManager::getInstance()->isActive()) return; OnlineUser* u = findUser(c.getFrom()); if(!u || u->getUser() == ClientManager::getInstance()->getMe()) return; - if(c.getParameters().empty() || (c.getParameters()[0] != CLIENT_PROTOCOL && c.getParameters()[0] != SECURE_CLIENT_PROTOCOL)) + + const string& protocol = c.getParam(0); + string token; + bool hasToken = c.getParam("TO", 1, token); + + bool secure; + if(protocol == CLIENT_PROTOCOL) { + secure = false; + } else if(protocol == SECURE_CLIENT_PROTOCOL && CryptoManager::getInstance()->TLSOk()) { + secure = true; + } else { + 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); + + send(cmd); return; - string token; - c.getParam("TO", 1, token); - connect(*u, token, c.getParameters()[0] == SECURE_CLIENT_PROTOCOL); + } + connect(*u, token, secure); } void AdcHub::handle(AdcCommand::CMD, AdcCommand& c) throw() { @@ -312,7 +343,7 @@ if(!u) return; - // @todo Check for invalid protocol and unset SSL if necessary + // @todo Check for invalid protocol and unset TLS if necessary fire(ClientListener::Message(), this, *u, c.getParam(1)); } @@ -337,7 +368,7 @@ void AdcHub::connect(const OnlineUser& user) { u_int32_t r = Util::rand(); - connect(user, Util::toString(r), BOOLSETTING(USE_SSL) && user.getUser()->isSet(User::SSL)); + connect(user, Util::toString(r), CryptoManager::getInstance()->TLSOk() && user.getUser()->isSet(User::TLS)); } void AdcHub::connect(const OnlineUser& user, string const& token, bool secure) { @@ -472,7 +503,7 @@ } string su; - if(CryptoManager::getInstance()->hasCerts()) { + if(CryptoManager::getInstance()->TLSOk()) { su += ADCS_FEATURE + ","; } Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -255,7 +255,7 @@ } } - if(mode == MODE_LINE && line.size() > SETTING(MAX_COMMAND_LENGTH)) { + if(mode == MODE_LINE && line.size() > static_cast<size_t>(SETTING(MAX_COMMAND_LENGTH))) { throw SocketException(STRING(COMMAND_TOO_LONG)); } } Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-07-02 20:59:53 UTC (rev 624) @@ -99,8 +99,11 @@ void setLineMode(size_t aRollback) { setMode (MODE_LINE, aRollback);} void setMode(Modes mode, size_t aRollback = 0); Modes getMode() const { return mode; } - const string& getIp() { return sock ? sock->getIp() : Util::emptyString; } - bool isConnected() { return sock && sock->isConnected(); } + const string& getIp() const { return sock ? sock->getIp() : Util::emptyString; } + bool isConnected() const { return sock && sock->isConnected(); } + + 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(); Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/Client.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -25,6 +25,7 @@ #include "FavoriteManager.h" #include "TimerManager.h" +#include "ResourceManager.h" Client::Counts Client::counts; @@ -100,13 +101,25 @@ } catch(const Exception& e) { if(socket) { BufferedSocket::putSocket(socket); - socket = NULL; + socket = 0; } fire(ClientListener::Failed(), this, e.getError()); } updateActivity(); } +void Client::on(Connected) throw() { + if(socket->isSecure() && !socket->isTrusted() && !BOOLSETTING(ALLOW_UNTRUSTED_HUBS)) { + fire(ClientListener::StatusMessage(), this, STRING(CERTIFICATE_NOT_TRUSTED)); + disconnect(true); + return; + } + + updateActivity(); + ip = socket->getIp(); + fire(ClientListener::Connected(), this); +} + void Client::disconnect(bool graceLess) { if(!socket) return; Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/Client.h 2006-07-02 20:59:53 UTC (rev 624) @@ -208,7 +208,7 @@ // BufferedSocketListener virtual void on(Connecting) throw() { fire(ClientListener::Connecting(), this); } - virtual void on(Connected) throw() { updateActivity(); ip = socket->getIp(); fire(ClientListener::Connected(), this); } + virtual void on(Connected) throw(); }; Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -27,6 +27,7 @@ #include "CryptoManager.h" #include "ClientManager.h" #include "QueueManager.h" +#include "LogManager.h" #include "UserConnection.h" @@ -295,6 +296,10 @@ uc->setLastActivity(GET_TICK()); try { uc->accept(sock); + if(uc->isSecure() && !uc->isTrusted() && !BOOLSETTING(ALLOW_UNTRUSTED_CLIENTS)) { + putConnection(uc); + LogManager::getInstance()->message(STRING(CERTIFICATE_NOT_TRUSTED)); + } } catch(const Exception&) { putConnection(uc); delete uc; @@ -379,6 +384,12 @@ } void ConnectionManager::on(UserConnectionListener::Connected, UserConnection* aSource) throw() { + if(aSource->isSecure() && !aSource->isTrusted() && !BOOLSETTING(ALLOW_UNTRUSTED_CLIENTS)) { + putConnection(aSource); + LogManager::getInstance()->message(STRING(CERTIFICATE_NOT_TRUSTED)); + return; + } + dcassert(aSource->getState() == UserConnection::STATE_CONNECT); if(aSource->isSet(UserConnection::FLAG_NMDC)) { aSource->myNick(aSource->getToken()); Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -80,28 +80,63 @@ DH_free(dh); } +bool CryptoManager::TLSOk() const throw() { + return BOOLSETTING(USE_TLS) && certsLoaded; +} +bool CryptoManager::generateCertificate() throw() { +#ifdef _WIN32 + // Generate certificate using OpenSSL + if(SETTING(TLS_PRIVATE_KEY_FILE).empty()) { + return false; + } + wstring cmd = L"openssl.exe -out \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + L"\" 2048"; + PROCESS_INFORMATION pi = { 0 }; + STARTUPINFO si = { 0 }; + si.cb = sizeof(si); + + if(!CreateProcess(L"openssl.exe", const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, 0, &pi)) { + return false; + } + WaitForSingleObject(pi.hProcess, INFINITE); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + + cmd = L"openssl.exe x509 -x509 -new -batch -key \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + + L"\" -out \"" + Text::utf8ToWide(SETTING(TLS_CERTIFICATE_FILE)) + L"\""; + + if(!CreateProcess(L"openssl.exe", const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, 0, &pi)) { + return false; + } + + WaitForSingleObject(pi.hProcess, INFINITE); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); +#endif + return true; +} + void CryptoManager::loadCertificates() throw() { SSL_CTX_set_verify(serverContext, SSL_VERIFY_NONE, 0); SSL_CTX_set_verify(clientContext, SSL_VERIFY_NONE, 0); - if(!SETTING(SSL_CERTIFICATE_FILE).empty()) { - if(SSL_CTX_use_certificate_file(serverContext, SETTING(SSL_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + if(!SETTING(TLS_CERTIFICATE_FILE).empty()) { + if(SSL_CTX_use_certificate_file(serverContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { LogManager::getInstance()->message("Failed to load certificate file"); return; } - if(SSL_CTX_use_certificate_file(clientContext, SETTING(SSL_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + if(SSL_CTX_use_certificate_file(clientContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { LogManager::getInstance()->message("Failed to load certificate file"); return; } } - if(!SETTING(SSL_PRIVATE_KEY_FILE).empty()) { - if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(SSL_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + if(!SETTING(TLS_PRIVATE_KEY_FILE).empty()) { + if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { LogManager::getInstance()->message("Failed to load private key"); return; } - if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(SSL_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { LogManager::getInstance()->message("Failed to load private key"); return; } @@ -111,10 +146,10 @@ WIN32_FIND_DATA data; HANDLE hFind; - hFind = FindFirstFile(Text::toT(SETTING(SSL_TRUSTED_CERTIFICATES_PATH) + "*.pem").c_str(), &data); + hFind = FindFirstFile(Text::toT(SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + "*.pem").c_str(), &data); if(hFind != INVALID_HANDLE_VALUE) { do { - if(SSL_CTX_load_verify_locations(clientContext, (SETTING(SSL_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + if(SSL_CTX_load_verify_locations(clientContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); } } while(FindNextFile(hFind, &data)); Modified: dcplusplus/trunk/client/CryptoManager.h =================================================================== --- dcplusplus/trunk/client/CryptoManager.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/CryptoManager.h 2006-07-02 20:59:53 UTC (rev 624) @@ -85,7 +85,9 @@ SSLSocket* getServerSocket() throw(SocketException); void loadCertificates() throw(); - bool hasCerts() const { return certsLoaded; } + bool generateCertificate() throw(); + + bool TLSOk() const throw(); private: friend class Singleton<CryptoManager>; Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -27,6 +27,7 @@ SSLSocket::SSLSocket(SSL_CTX* context) throw(SocketException) : ctx(context), ssl(0) { + } void SSLSocket::connect(const string& aIp, short aPort) throw(SocketException) { @@ -120,6 +121,22 @@ return Socket::wait(millis, waitFor); } +bool SSLSocket::isTrusted() const throw() { + if(!ssl) { + return false; + } + + if(SSL_get_verify_result(ssl) != SSL_ERROR_NONE) { + return false; + } + + if(!SSL_get_peer_certificate(ssl)) { + return false; + } + + return true; +} + void SSLSocket::shutdown() throw() { if(ssl) SSL_shutdown(ssl); Modified: dcplusplus/trunk/client/SSLSocket.h =================================================================== --- dcplusplus/trunk/client/SSLSocket.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/SSLSocket.h 2006-07-02 20:59:53 UTC (rev 624) @@ -45,6 +45,10 @@ virtual int wait(u_int32_t millis, int waitFor) throw(SocketException); virtual void shutdown() throw(); virtual void close() throw(); + + virtual bool isSecure() const throw() { return true; } + virtual bool isTrusted() const throw(); + private: friend class CryptoManager; Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -74,7 +74,7 @@ "BoldHub", "BoldPm", "BoldSearch", "SocketInBuffer", "SocketOutBuffer", "OnlyDlTthFiles", "OpenWaitingUsers", "BoldWaitingUsers", "OpenSystemLog", "BoldSystemLog", "AutoRefreshTime", "UseSsl", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", - "DontDlAlreadyQueued", "MaxCommandLength", + "DontDlAlreadyQueued", "MaxCommandLength", "AllowUntrustedHubs", "AllowUntrustedClients", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -243,7 +243,7 @@ setDefault(ONLY_DL_TTH_FILES, false); setDefault(OPEN_WAITING_USERS, false); setDefault(OPEN_SYSTEM_LOG, true); - setDefault(SSL_TRUSTED_CERTIFICATES_PATH, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR); + setDefault(TLS_TRUSTED_CERTIFICATES_PATH, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR); setDefault(BOLD_FINISHED_DOWNLOADS, true); setDefault(BOLD_FINISHED_UPLOADS, true); setDefault(BOLD_QUEUE, true); @@ -253,7 +253,7 @@ setDefault(BOLD_WAITING_USERS, true); setDefault(BOLD_SYSTEM_LOG, true); setDefault(AUTO_REFRESH_TIME, 60); - setDefault(USE_SSL, false); + setDefault(USE_TLS, true); setDefault(AUTO_SEARCH_LIMIT, 5); setDefault(ALT_SORT_ORDER, false); setDefault(AUTO_KICK_NO_FAVS, false); @@ -261,6 +261,8 @@ setDefault(SPY_FRAME_IGNORE_TTH_SEARCHES, false); setDefault(DONT_DL_ALREADY_QUEUED, false); setDefault(MAX_COMMAND_LENGTH, 16*1024*1024); + setDefault(ALLOW_UNTRUSTED_HUBS, true); + setDefault(ALLOW_UNTRUSTED_CLIENTS, true); #ifdef _WIN32 setDefault(MAIN_WINDOW_STATE, SW_SHOWNORMAL); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/SettingsManager.h 2006-07-02 20:59:53 UTC (rev 624) @@ -59,7 +59,7 @@ FINISHED_UL_WIDTHS, FINISHED_UL_ORDER, PRIVATE_ID, SPYFRAME_WIDTHS, SPYFRAME_ORDER, LOG_FILE_MAIN_CHAT, LOG_FILE_PRIVATE_CHAT, LOG_FILE_STATUS, LOG_FILE_UPLOAD, LOG_FILE_DOWNLOAD, LOG_FILE_SYSTEM, LOG_FORMAT_SYSTEM, LOG_FORMAT_STATUS, DIRECTORLISTINGFRAME_ORDER, DIRECTORLISTINGFRAME_WIDTHS, - SSL_PRIVATE_KEY_FILE, SSL_CERTIFICATE_FILE, SSL_TRUSTED_CERTIFICATES_PATH, + TLS_PRIVATE_KEY_FILE, TLS_CERTIFICATE_FILE, TLS_TRUSTED_CERTIFICATES_PATH, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, @@ -89,8 +89,9 @@ NO_IP_OVERRIDE, SEARCH_ONLY_FREE_SLOTS, LAST_SEARCH_TYPE, BOLD_FINISHED_DOWNLOADS, BOLD_FINISHED_UPLOADS, BOLD_QUEUE, BOLD_HUB, BOLD_PM, BOLD_SEARCH, SOCKET_IN_BUFFER, SOCKET_OUT_BUFFER, ONLY_DL_TTH_FILES, OPEN_WAITING_USERS, BOLD_WAITING_USERS, OPEN_SYSTEM_LOG, BOLD_SYSTEM_LOG, AUTO_REFRESH_TIME, - USE_SSL, AUTO_SEARCH_LIMIT, ALT_SORT_ORDER, AUTO_KICK_NO_FAVS, PROMPT_PASSWORD, SPY_FRAME_IGNORE_TTH_SEARCHES, - DONT_DL_ALREADY_QUEUED, MAX_COMMAND_LENGTH, + USE_TLS, AUTO_SEARCH_LIMIT, ALT_SORT_ORDER, AUTO_KICK_NO_FAVS, PROMPT_PASSWORD, SPY_FRAME_IGNORE_TTH_SEARCHES, + DONT_DL_ALREADY_QUEUED, MAX_COMMAND_LENGTH, ALLOW_UNTRUSTED_HUBS, ALLOW_UNTRUSTED_CLIENTS, + TLS_PORT, INT_LAST }; enum Int64Setting { INT64_FIRST = INT_LAST + 1, Modified: dcplusplus/trunk/client/Socket.h =================================================================== --- dcplusplus/trunk/client/Socket.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/Socket.h 2006-07-02 20:59:53 UTC (rev 624) @@ -176,6 +176,9 @@ int getSocketOptInt(int option) throw(SocketException); void setSocketOpt(int option, int value) throw(SocketException); + virtual bool isSecure() const throw() { return false; } + virtual bool isTrusted() const throw() { return false; } + /** When socks settings are updated, this has to be called... */ static void socksUpdated(); Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -41,6 +41,7 @@ "Browse...", "&Browse...", "Browse file list", +"Certificate not trusted, unable to connect", "Choose folder", "CID", "Close", @@ -48,6 +49,7 @@ "Closing connection...", "Compressed", "Error during compression", +"Maximum command length exceeded", "&Configure", "&Connect", "Connect to hub", @@ -302,6 +304,7 @@ "Offline", "Online", "Only users with free slots", +"Only TLS connections allowed", "Only results with TTH root", "Only where I'm op", "Open", @@ -370,6 +373,8 @@ "Advanced\\Experts only", "Advanced resume using TTH", "Advanced settings", +"Allow TLS connections to hubs without trusted certificate", +"Allow TLS connections to hubs without trusted certificate", "Use antifragmentation method for downloads", "Appearance", "Appearance\\Colors and sounds", @@ -416,7 +421,7 @@ "Downloads", "Maximum simultaneous downloads (0 = infinite)", "No new downloads if speed exceeds (KiB/s, 0 = disable)", -"Donate €€€:s! (ok, dirty dollars are fine as well =) (see help menu)", +"Donate :s! (ok, dirty dollars are fine as well =) (see help menu)", "External / WAN IP", "Only show joins / parts for favorite users", "Downloads\\Favorites", @@ -525,7 +530,7 @@ "Window options", "Write buffer size", "Sort all downloads first", -"Use SSL when remote client supports it", +"Use TLS when remote client supports it", "CRC32 inconsistency (SFV-Check)", "Shared", "Shared Files", @@ -653,6 +658,7 @@ "Browse", "BrowseAccel", "BrowseFileList", +"CertificateNotTrusted", "ChooseFolder", "Cid", "Close", @@ -660,6 +666,7 @@ "ClosingConnection", "Compressed", "CompressionError", +"CommandTooLong", "Configure", "Connect", "ConnectFavuserHub", @@ -914,6 +921,7 @@ "Offline", "Online", "OnlyFreeSlots", +"OnlyTlsAllowed", "OnlyTth", "OnlyWhereOp", "Open", @@ -982,6 +990,8 @@ "SettingsAdvanced3", "SettingsAdvancedResume", "SettingsAdvancedSettings", +"SettingsAllowUntrustedClients", +"SettingsAllowUntrustedHubs", "SettingsAntiFrag", "SettingsAppearance", "SettingsAppearance2", @@ -1137,7 +1147,7 @@ "SettingsWindowsOptions", "SettingsWriteBuffer", "SettingsAltSortOrder", -"SettingsUseSsl", +"SettingsUseTls", "SfvInconsistency", "Shared", "SharedFiles", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/StringDefs.h 2006-07-02 20:59:53 UTC (rev 624) @@ -44,6 +44,7 @@ BROWSE, // "Browse..." BROWSE_ACCEL, // "&Browse..." BROWSE_FILE_LIST, // "Browse file list" + CERTIFICATE_NOT_TRUSTED, // "Certificate not trusted, unable to connect" CHOOSE_FOLDER, // "Choose folder" CID, // "CID" CLOSE, // "Close" @@ -306,6 +307,7 @@ OFFLINE, // "Offline" ONLINE, // "Online" ONLY_FREE_SLOTS, // "Only users with free slots" + ONLY_TLS_ALLOWED, // "Only TLS connections allowed" ONLY_TTH, // "Only results with TTH root" ONLY_WHERE_OP, // "Only where I'm op" OPEN, // "Open" @@ -374,6 +376,8 @@ SETTINGS_ADVANCED3, // "Advanced\\Experts only" SETTINGS_ADVANCED_RESUME, // "Advanced resume using TTH" SETTINGS_ADVANCED_SETTINGS, // "Advanced settings" + SETTINGS_ALLOW_UNTRUSTED_CLIENTS, // "Allow TLS connections to hubs without trusted certificate" + SETTINGS_ALLOW_UNTRUSTED_HUBS, // "Allow TLS connections to hubs without trusted certificate" SETTINGS_ANTI_FRAG, // "Use antifragmentation method for downloads" SETTINGS_APPEARANCE, // "Appearance" SETTINGS_APPEARANCE2, // "Appearance\\Colors and sounds" @@ -420,7 +424,7 @@ SETTINGS_DOWNLOADS, // "Downloads" SETTINGS_DOWNLOADS_MAX, // "Maximum simultaneous downloads (0 = infinite)" SETTINGS_DOWNLOADS_SPEED_PAUSE, // "No new downloads if speed exceeds (KiB/s, 0 = disable)" - SETTINGS_EXAMPLE_TEXT, // "Donate €€€:s! (ok, dirty dollars are fine as well =) (see help menu)" + SETTINGS_EXAMPLE_TEXT, // "Donate :s! (ok, dirty dollars are fine as well =) (see help menu)" SETTINGS_EXTERNAL_IP, // "External / WAN IP" SETTINGS_FAV_SHOW_JOINS, // "Only show joins / parts for favorite users" SETTINGS_FAVORITE_DIRS_PAGE, // "Downloads\\Favorites" @@ -529,7 +533,7 @@ SETTINGS_WINDOWS_OPTIONS, // "Window options" SETTINGS_WRITE_BUFFER, // "Write buffer size" SETTINGS_ALT_SORT_ORDER, // "Sort all downloads first" - SETTINGS_USE_SSL, // "Use SSL when remote client supports it" + SETTINGS_USE_TLS, // "Use TLS when remote client supports it" SFV_INCONSISTENCY, // "CRC32 inconsistency (SFV-Check)" SHARED, // "Shared" SHARED_FILES, // "Shared Files" Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/User.h 2006-07-02 20:59:53 UTC (rev 624) @@ -41,7 +41,7 @@ HUB_BIT, TTH_GET_BIT, SAVE_NICK_BIT, - SSL_BIT + TLS_BIT }; /** Each flag is set if it's true in at least one hub */ @@ -54,7 +54,7 @@ HUB = 1<<HUB_BIT, TTH_GET = 1<<TTH_GET_BIT, //< User supports getting files by tth -> don't have path in queue... SAVE_NICK = 1<<SAVE_NICK_BIT, //< Save cid->nick association - SSL = 1<<SSL_BIT //< Client supports SSL + TLS = 1<<TLS_BIT //< Client supports SSL }; typedef Pointer<User> Ptr; Modified: dcplusplus/trunk/client/UserConnection.h =================================================================== --- dcplusplus/trunk/client/UserConnection.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/client/UserConnection.h 2006-07-02 20:59:53 UTC (rev 624) @@ -279,7 +279,8 @@ } User::Ptr& getUser() { return user; } - bool isSecure() const { return secure; } + bool isSecure() const { return socket && socket->isSecure(); } + bool isTrusted() const { return socket && socket->isTrusted(); } string getRemoteIp() const { return socket->getIp(); } Download* getDownload() { dcassert(isSet(FLAG_DOWNLOAD)); return download; } @@ -305,8 +306,8 @@ GETSET(u_int32_t, lastActivity, LastActivity); private: BufferedSocket* socket; + bool secure; User::Ptr user; - bool secure; static const string UPLOAD, DOWNLOAD; @@ -316,7 +317,7 @@ }; // We only want ConnectionManager to create this... - UserConnection(bool secure_) throw() : /*cqi(NULL),*/ state(STATE_UNCONNECTED), lastActivity(0), + UserConnection(bool secure_) throw() : state(STATE_UNCONNECTED), lastActivity(0), socket(0), secure(secure_), download(NULL) { } Modified: dcplusplus/trunk/windows/AdvancedPage.cpp =================================================================== --- dcplusplus/trunk/windows/AdvancedPage.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/windows/AdvancedPage.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -47,7 +47,6 @@ { SettingsManager::SEND_UNKNOWN_COMMANDS, ResourceManager::SETTINGS_SEND_UNKNOWN_COMMANDS }, { SettingsManager::ADD_FINISHED_INSTANTLY, ResourceManager::SETTINGS_ADD_FINISHED_INSTANTLY }, { SettingsManager::USE_CTRL_FOR_LINE_HISTORY, ResourceManager::SETTINGS_USE_CTRL_FOR_LINE_HISTORY }, - { SettingsManager::USE_SSL, ResourceManager::SETTINGS_USE_SSL }, { SettingsManager::AUTO_KICK_NO_FAVS, ResourceManager::SETTINGS_AUTO_KICK_NO_FAVS }, { 0, ResourceManager::SETTINGS_AUTO_AWAY } }; Modified: dcplusplus/trunk/windows/CertificatesPage.cpp =================================================================== --- dcplusplus/trunk/windows/CertificatesPage.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/windows/CertificatesPage.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -33,23 +33,29 @@ }; PropPage::Item CertificatesPage::items[] = { - { IDC_SSL_CERTIFICATE_FILE, SettingsManager::SSL_CERTIFICATE_FILE, PropPage::T_STR }, - { IDC_SSL_PRIVATE_KEY_FILE, SettingsManager::SSL_PRIVATE_KEY_FILE, PropPage::T_STR }, - { IDC_SSL_TRUSTED_CERTIFICATES_PATH, SettingsManager::SSL_TRUSTED_CERTIFICATES_PATH, PropPage::T_STR }, + { IDC_TLS_CERTIFICATE_FILE, SettingsManager::TLS_CERTIFICATE_FILE, PropPage::T_STR }, + { IDC_TLS_PRIVATE_KEY_FILE, SettingsManager::TLS_PRIVATE_KEY_FILE, PropPage::T_STR }, + { IDC_TLS_TRUSTED_CERTIFICATES_PATH, SettingsManager::TLS_TRUSTED_CERTIFICATES_PATH, PropPage::T_STR }, { 0, 0, PropPage::T_END } }; +PropPage::ListItem CertificatesPage::listItems[] = { + { SettingsManager::USE_TLS, ResourceManager::SETTINGS_USE_TLS }, + { SettingsManager::ALLOW_UNTRUSTED_HUBS, ResourceManager::SETTINGS_ALLOW_UNTRUSTED_HUBS }, + { SettingsManager::ALLOW_UNTRUSTED_CLIENTS, ResourceManager::SETTINGS_ALLOW_UNTRUSTED_CLIENTS, } +}; + LRESULT CertificatesPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { PropPage::translate((HWND)(*this), texts); - PropPage::read((HWND)*this, items, 0, 0); + PropPage::read((HWND)*this, items, listItems, GetDlgItem(IDC_TLS_OPTIONS)); // Do specialized reading here return TRUE; } void CertificatesPage::write() { - PropPage::write((HWND)*this, items, 0, 0); + PropPage::write((HWND)*this, items, listItems, GetDlgItem(IDC_TLS_OPTIONS)); } LRESULT CertificatesPage::onHelpInfo(LPNMHDR /*pnmh*/) { Modified: dcplusplus/trunk/windows/CertificatesPage.h =================================================================== --- dcplusplus/trunk/windows/CertificatesPage.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/windows/CertificatesPage.h 2006-07-02 20:59:53 UTC (rev 624) @@ -55,6 +55,7 @@ static Item items[]; static TextItem texts[]; + static ListItem listItems[]; }; #endif // !defined(CERTIFICATES_PAGE_H) Modified: dcplusplus/trunk/windows/TransferView.cpp =================================================================== --- dcplusplus/trunk/windows/TransferView.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/windows/TransferView.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -499,7 +499,11 @@ tstring statusString; if(d->getUserConnection()->isSecure()) { - statusString += _T("[S]"); + if(d->getUserConnection()->isTrusted()) { + statusString += _T("[S]"); + } else { + statusString += _T("[U]"); + } } if(d->isSet(Download::FLAG_TTH_CHECK)) { statusString += _T("[T]"); Modified: dcplusplus/trunk/windows/resource.h =================================================================== --- dcplusplus/trunk/windows/resource.h 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/windows/resource.h 2006-07-02 20:59:53 UTC (rev 624) @@ -372,6 +372,7 @@ #define IDC_EDIT2 1318 #define IDC_SOCKET_OUT_BUFFER 1318 #define IDC_SSL_CERTIFICATE_FILE 1318 +#define IDC_TLS_CERTIFICATE_FILE 1318 #define IDC_SETTINGS_SOCKET_OUT_BUFFER 1319 #define IDC_SETTINGS_SOCKET_IN_BUFFER 1320 #define IDC_CHECK1 1321 @@ -408,12 +409,16 @@ #define IDC_SETTINGS_MB 1411 #define IDC_SYSTEM_LOG 1412 #define IDC_SSL_PRIVATE_KEY_FILE 1414 +#define IDC_TLS_PRIVATE_KEY_FILE 1414 #define IDC_SSL_TRUSTED_CERTIFICATES_PATH 1415 +#define IDC_TLS_TRUSTED_CERTIFICATES_PATH 1415 #define IDC_CLIENT_ID 1416 #define IDC_PRIVATE_ID 1416 #define IDC_AUTO_REFRESH_TIME 1419 #define IDC_SETTINGS_AUTO_REFRESH_TIME 1420 #define IDC_AUTO_SEARCH_LIMIT 1421 +#define IDC_SSL_OPTIONS 1421 +#define IDC_TLS_OPTIONS 1421 #define IDC_SETTINGS_AUTO_SEARCH_LIMIT 1422 #define IDC_CLOSE_ALL_PM 1423 #define IDC_CLOSE_ALL_OFFLINE_PM 1424 @@ -460,7 +465,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 246 #define _APS_NEXT_COMMAND_VALUE 32789 -#define _APS_NEXT_CONTROL_VALUE 1421 +#define _APS_NEXT_CONTROL_VALUE 1422 #define _APS_NEXT_SYMED_VALUE 105 #endif #endif Modified: dcplusplus/trunk/yassl/include/yassl_int.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-07-02 20:59:53 UTC (rev 624) @@ -429,16 +429,14 @@ // holds input and output buffers class Buffers { - typedef mySTL::list<input_buffer*> inputList; - typedef mySTL::list<output_buffer*> outputList; - - inputList dataList_; // list of users app data / handshake - outputList handShakeList_; // buffered handshake msgs public: Buffers() {} ~Buffers(); - const inputList& getData() const; + typedef mySTL::list<input_buffer*> inputList; + typedef mySTL::list<output_buffer*> outputList; + + const inputList& getData() const; const outputList& getHandShake() const; inputList& useData(); @@ -446,6 +444,9 @@ private: Buffers(const Buffers&); // hide copy Buffers& operator=(const Buffers&); // and assign + + inputList dataList_; // list of users app data / handshake + outputList handShakeList_; // buffered handshake msgs }; Modified: dcplusplus/trunk/yassl/src/yassl.cpp =================================================================== --- dcplusplus/trunk/yassl/src/yassl.cpp 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/yassl/src/yassl.cpp 2006-07-02 20:59:53 UTC (rev 624) @@ -31,7 +31,7 @@ #include "openssl/ssl.h" // get rid of this - +/* // yaSSL overloads hide these void* operator new[](size_t sz) { @@ -43,7 +43,7 @@ ::operator delete(ptr); } - +*/ namespace yaSSL { using mySTL::min; Modified: dcplusplus/trunk/yassl/taocrypt/taocrypt.vcproj =================================================================== --- dcplusplus/trunk/yassl/taocrypt/taocrypt.vcproj 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/yassl/taocrypt/taocrypt.vcproj 2006-07-02 20:59:53 UTC (rev 624) @@ -438,6 +438,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\md4.cpp"> + </File> + <File RelativePath="src\md5.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -564,6 +567,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\template_instnt.cpp"> + </File> + <File RelativePath="src\tftables.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -655,9 +661,15 @@ RelativePath="include\integer.hpp"> </File> <File + RelativePath=".\include\kernelc.hpp"> + </File> + <File RelativePath="include\md2.hpp"> </File> <File + RelativePath=".\include\md4.hpp"> + </File> + <File RelativePath="include\md5.hpp"> </File> <File @@ -682,6 +694,9 @@ RelativePath="include\rsa.hpp"> </File> <File + RelativePath=".\include\runtime.hpp"> + </File> + <File RelativePath="include\sha.hpp"> </File> <File Modified: dcplusplus/trunk/yassl/yassl.vcproj =================================================================== --- dcplusplus/trunk/yassl/yassl.vcproj 2006-07-02 16:52:24 UTC (rev 623) +++ dcplusplus/trunk/yassl/yassl.vcproj 2006-07-02 20:59:53 UTC (rev 624) @@ -291,6 +291,9 @@ </FileConfiguration> </File> <File + RelativePath=".\src\template_instnt.cpp"> + </File> + <File RelativePath="src\timer.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -388,21 +391,57 @@ RelativePath="include\cert_wrapper.hpp"> </File> <File + RelativePath=".\include\openssl\crypto.h"> + </File> + <File RelativePath="include\crypto_wrapper.hpp"> </File> <File + RelativePath=".\include\openssl\des.h"> + </File> + <File + RelativePath=".\include\openssl\engine.h"> + </File> + <File + RelativePath=".\include\openssl\err.h"> + </File> + <File RelativePath="include\factory.hpp"> </File> <File RelativePath="include\handshake.hpp"> </File> <File + RelativePath=".\include\openssl\lhash.h"> + </File> + <File RelativePath="include\lock.hpp"> </File> <File RelativePath="include\log.hpp"> </File> <File + RelativePath=".\include\openssl\md4.h"> + </File> + <File + RelativePath=".\include\openssl\md5.h"> + </File> + <File + RelativePath=".\include\openssl\opensslv.h"> + </File> + <File + RelativePath=".\include\openssl\pem.h"> + </File> + <File + RelativePath=".\include\openssl\pkcs12.h"> + </File> + <File + RelativePath=".\include\openssl\rand.h"> + </File> + <File + RelativePath=".\include\openssl\rsa.h"> + </File> + <File RelativePath="include\socket_wrapper.hpp"> </File> <File @@ -412,6 +451,12 @@ RelativePath="include\timer.hpp"> </File> <File + RelativePath=".\include\openssl\x509.h"> + </File> + <File + RelativePath=".\include\openssl\x509v3.h"> + </File> + <File RelativePath=".\include\yassl.hpp"> </File> <File This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-08 17:02:20
|
Revision: 625 Author: arnetheduck Date: 2006-07-08 10:01:15 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=625&view=rev Log Message: ----------- SSL fixes Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/CryptoManager.h dcplusplus/trunk/client/HttpConnection.cpp dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UserConnection.cpp dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/windows/CertificatesPage.cpp dcplusplus/trunk/windows/CertificatesPage.h dcplusplus/trunk/windows/resource.h dcplusplus/trunk/yassl/src/ssl.cpp Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-07-08 17:01:15 UTC (rev 625) @@ -681,9 +681,9 @@ CAPTION "Security Certificates" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_TLS_PRIVATE_KEY_FILE,102,7,166,14,ES_AUTOHSCROLL - EDITTEXT IDC_TLS_CERTIFICATE_FILE,102,24,166,14,ES_AUTOHSCROLL - EDITTEXT IDC_TLS_TRUSTED_CERTIFICATES_PATH,102,42,166,14, + EDITTEXT IDC_TLS_PRIVATE_KEY_FILE,102,7,141,14,ES_AUTOHSCROLL + EDITTEXT IDC_TLS_CERTIFICATE_FILE,102,24,141,14,ES_AUTOHSCROLL + EDITTEXT IDC_TLS_TRUSTED_CERTIFICATES_PATH,102,42,141,14, ES_AUTOHSCROLL LTEXT "Private key file",IDC_STATIC,50,10,48,8 LTEXT "Own certificate file",IDC_STATIC,37,27,61,8 @@ -694,7 +694,11 @@ IDC_STATIC,7,201,200,8 CONTROL "",IDC_TLS_OPTIONS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | - LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,15,72,243,90 + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,89,261,90 + PUSHBUTTON "Generate certificates",IDC_GENERATE_CERTS,184,62,84,14 + PUSHBUTTON "...",IDC_BROWSE_PRIVATE_KEY,247,7,21,14 + PUSHBUTTON "...",IDC_BROWSE_CERTIFICATE,247,24,21,14 + PUSHBUTTON "...",IDC_BROWSE_TRUSTED_PATH,248,42,20,14 END Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/Example.xml 2006-07-08 17:01:15 UTC (rev 625) @@ -41,6 +41,7 @@ <String Name="BrowseAccel">&Browse...</String> <String Name="BrowseFileList">Browse file list</String> <String Name="CertificateNotTrusted">Certificate not trusted, unable to connect</String> + <String Name="CertificateGenerationFailed">TLS disabled, failed to generate certificate: </String> <String Name="ChooseFolder">Choose folder</String> <String Name="Cid">CID</String> <String Name="Close">Close</String> @@ -117,6 +118,8 @@ <String Name="ErrorSavingHash">Error saving hash data: </String> <String Name="ExactSize">Exact size</String> <String Name="Executable">Executable</String> + <String Name="FailedToLoadCertificate">Failed to load certificate file</String> + <String Name="FailedToLoadPrivateKey">Failed to load private key</String> <String Name="FavJoinShowingOff">Join/part of favorite users showing off</String> <String Name="FavJoinShowingOn">Join/part of favorite users showing on</String> <String Name="FavoriteDirName">Favorite name</String> @@ -288,14 +291,15 @@ <String Name="Nick">Nick</String> <String Name="NickTaken">Your nick was already taken, please change to something else!</String> <String Name="NickUnknown"> (Nick unknown)</String> + <String Name="NoCertificateFileSet">TLS disabled, no certificate file set</String> <String Name="NoCrc32Match"> not shared; calculated CRC32 does not match the one found in SFV file.</String> - <String Name="NoStr">No</String> <String Name="NoDirectorySpecified">No directory specified</String> <String Name="NoDownloadsFromSelf">You're trying to download from yourself!</String> <String Name="NoDownloadsFromPassive">Can't download from passive users when you're passive</String> <String Name="NoErrors">No errors</String> <String Name="NoMatches">No matches</String> <String Name="NoSlotsAvailable">No slots available</String> + <String Name="NoStr">No</String> <String Name="NoUsers">No users</String> <String Name="NoUsersToDownloadFrom">No users to download from</String> <String Name="Normal">Normal</String> @@ -372,7 +376,7 @@ <String Name="SettingsAdvanced3">Advanced\Experts only</String> <String Name="SettingsAdvancedResume">Advanced resume using TTH</String> <String Name="SettingsAdvancedSettings">Advanced settings</String> - <String Name="SettingsAllowUntrustedClients">Allow TLS connections to hubs without trusted certificate</String> + <String Name="SettingsAllowUntrustedClients">Allow TLS connections to clients without trusted certificate</String> <String Name="SettingsAllowUntrustedHubs">Allow TLS connections to hubs without trusted certificate</String> <String Name="SettingsAntiFrag">Use antifragmentation method for downloads</String> <String Name="SettingsAppearance">Appearance</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/changelog.txt 2006-07-08 17:01:15 UTC (rev 625) @@ -31,6 +31,8 @@ * Added protection from hubs/clients sending junk data resulting in high memory usage / crash * Updated to yaSSL 1.3.7 * Added a few TLS options; [U] in transfer status means untrusted TLS (encrypted but certificate not validated) +* Added certificate generation, OpenSSL must be installed and in PATH for this to work +* [bug 996] Fixed an issue where directories that are hard to delete were created -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -72,11 +72,11 @@ } } -void BufferedSocket::accept(const Socket& srv, bool secure) throw(SocketException, ThreadException) { +void BufferedSocket::accept(const Socket& srv, bool secure, bool allowUntrusted) throw(SocketException, ThreadException) { dcassert(!sock); dcdebug("BufferedSocket::accept() %p\n", (void*)this); - sock = secure ? CryptoManager::getInstance()->getClientSocket() : new Socket; + sock = secure ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : new Socket; sock->accept(srv); if(SETTING(SOCKET_IN_BUFFER) > 0) @@ -100,11 +100,11 @@ addTask(ACCEPTED, 0); } -void BufferedSocket::connect(const string& aAddress, short aPort, bool secure, bool proxy) throw(SocketException, ThreadException) { +void BufferedSocket::connect(const string& aAddress, short aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException) { dcassert(!sock); dcdebug("BufferedSocket::connect() %p\n", (void*)this); - sock = secure ? CryptoManager::getInstance()->getClientSocket() : new Socket; + sock = secure ? CryptoManager::getInstance()->getClientSocket(allowUntrusted) : new Socket; sock->create(); if(SETTING(SOCKET_IN_BUFFER) >= 1024) Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-07-08 17:01:15 UTC (rev 625) @@ -86,8 +86,8 @@ Thread::sleep(100); } - void accept(const Socket& srv, bool secure) throw(SocketException, ThreadException); - void connect(const string& aAddress, short aPort, bool secure, bool proxy) throw(SocketException, ThreadException); + void accept(const Socket& srv, bool secure, bool allowUntrusted) throw(SocketException, ThreadException); + void connect(const string& aAddress, short aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException); /** Sets data mode for aBytes bytes. Must be called within onLine. */ void setDataMode(int64_t aBytes = -1) { mode = MODE_DATA; dataBytes = aBytes; } Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/Client.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -97,7 +97,7 @@ try { socket = BufferedSocket::getSocket(separator); socket->addListener(this); - socket->connect(address, port, secure, true); + socket->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true); } catch(const Exception& e) { if(socket) { BufferedSocket::putSocket(socket); @@ -109,12 +109,6 @@ } void Client::on(Connected) throw() { - if(socket->isSecure() && !socket->isTrusted() && !BOOLSETTING(ALLOW_UNTRUSTED_HUBS)) { - fire(ClientListener::StatusMessage(), this, STRING(CERTIFICATE_NOT_TRUSTED)); - disconnect(true); - return; - } - updateActivity(); ip = socket->getIp(); fire(ClientListener::Connected(), this); Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -25,6 +25,7 @@ #include "BitOutputStream.h" #include "ResourceManager.h" #include "LogManager.h" +#include "ClientManager.h" #include <openssl/ssl.h> @@ -38,6 +39,8 @@ : 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"), @@ -84,64 +87,103 @@ return BOOLSETTING(USE_TLS) && certsLoaded; } -bool CryptoManager::generateCertificate() throw() { +void CryptoManager::generateCertificate() throw(CryptoException) { #ifdef _WIN32 // Generate certificate using OpenSSL if(SETTING(TLS_PRIVATE_KEY_FILE).empty()) { - return false; + throw CryptoException("No private key file chosen"); } - wstring cmd = L"openssl.exe -out \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + L"\" 2048"; + if(SETTING(TLS_CERTIFICATE_FILE).empty()) { + throw CryptoException("No certificate file chosen"); + } + wstring cmd = L"openssl.exe genrsa -out \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + L"\" 2048"; PROCESS_INFORMATION pi = { 0 }; STARTUPINFO si = { 0 }; si.cb = sizeof(si); - if(!CreateProcess(L"openssl.exe", const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, 0, &pi)) { - return false; + if(!CreateProcess(0, const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, &si, &pi)) { + throw CryptoException(Util::translateError(::GetLastError())); } WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); - cmd = L"openssl.exe x509 -x509 -new -batch -key \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + - L"\" -out \"" + Text::utf8ToWide(SETTING(TLS_CERTIFICATE_FILE)) + L"\""; + 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"\""; - if(!CreateProcess(L"openssl.exe", const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, 0, &pi)) { - return false; + if(!CreateProcess(0, const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, &si, &pi)) { + throw CryptoException(Util::translateError(::GetLastError())); } WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); #endif - return true; } void CryptoManager::loadCertificates() throw() { + if(!BOOLSETTING(USE_TLS)) + return; + SSL_CTX_set_verify(serverContext, SSL_VERIFY_NONE, 0); SSL_CTX_set_verify(clientContext, SSL_VERIFY_NONE, 0); + SSL_CTX_set_verify(clientVerContext, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0); + SSL_CTX_set_verify(serverVerContext, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0); - if(!SETTING(TLS_CERTIFICATE_FILE).empty()) { - if(SSL_CTX_use_certificate_file(serverContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load certificate file"); - return; - } - if(SSL_CTX_use_certificate_file(clientContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load certificate file"); - return; - } + const string& cert = SETTING(TLS_CERTIFICATE_FILE); + const string& key = SETTING(TLS_PRIVATE_KEY_FILE); + + if(cert.empty() || key.empty()) { + LogManager::getInstance()->message(STRING(NO_CERTIFICATE_FILE_SET)); + return; } - if(!SETTING(TLS_PRIVATE_KEY_FILE).empty()) { - if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load private key"); - return; + if(File::getSize(cert) == -1 || File::getSize(key) == -1) { + // Try to generate them... + try { + generateCertificate(); + } catch(const CryptoException& e) { + LogManager::getInstance()->message(STRING(CERTIFICATE_GENERATION_FAILED) + e.getError()); } - if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load private key"); - return; - } } + if(SSL_CTX_use_certificate_file(serverContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE)); + return; + } + if(SSL_CTX_use_certificate_file(clientContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE)); + return; + } + + if(SSL_CTX_use_certificate_file(serverVerContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE)); + return; + } + if(SSL_CTX_use_certificate_file(clientVerContext, SETTING(TLS_CERTIFICATE_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_CERTIFICATE)); + return; + } + + if(SSL_CTX_use_PrivateKey_file(serverContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY)); + return; + } + if(SSL_CTX_use_PrivateKey_file(clientContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY)); + return; + } + + if(SSL_CTX_use_PrivateKey_file(serverVerContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY)); + return; + } + if(SSL_CTX_use_PrivateKey_file(clientVerContext, SETTING(TLS_PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) != SSL_SUCCESS) { + LogManager::getInstance()->message(STRING(FAILED_TO_LOAD_PRIVATE_KEY)); + return; + } + #ifdef _WIN32 WIN32_FIND_DATA data; HANDLE hFind; @@ -163,11 +205,11 @@ } -SSLSocket* CryptoManager::getClientSocket() throw(SocketException) { - return new SSLSocket(clientContext); +SSLSocket* CryptoManager::getClientSocket(bool allowUntrusted) throw(SocketException) { + return new SSLSocket(allowUntrusted ? clientContext : clientVerContext); } -SSLSocket* CryptoManager::getServerSocket() throw(SocketException) { - return new SSLSocket(serverContext); +SSLSocket* CryptoManager::getServerSocket(bool allowUntrusted) throw(SocketException) { + return new SSLSocket(allowUntrusted ? serverContext : serverVerContext); } Modified: dcplusplus/trunk/client/CryptoManager.h =================================================================== --- dcplusplus/trunk/client/CryptoManager.h 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/CryptoManager.h 2006-07-08 17:01:15 UTC (rev 625) @@ -81,11 +81,11 @@ 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() throw(SocketException); - SSLSocket* getServerSocket() throw(SocketException); + SSLSocket* getClientSocket(bool allowUntrusted) throw(SocketException); + SSLSocket* getServerSocket(bool allowUntrusted) throw(SocketException); void loadCertificates() throw(); - bool generateCertificate() throw(); + void generateCertificate() throw(CryptoException); bool TLSOk() const throw(); private: @@ -118,7 +118,10 @@ }; SSL_CTX* clientContext; + SSL_CTX* clientVerContext; SSL_CTX* serverContext; + SSL_CTX* serverVerContext; + DH* dh; bool certsLoaded; Modified: dcplusplus/trunk/client/HttpConnection.cpp =================================================================== --- dcplusplus/trunk/client/HttpConnection.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/HttpConnection.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -68,7 +68,7 @@ } socket->addListener(this); try { - socket->connect(server, port, false, false); + socket->connect(server, port, false, false, false); } catch(const Exception& e) { fire(HttpConnectionListener::Failed(), this, e.getError() + " (" + currentUrl + ")"); } Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -114,9 +114,9 @@ int SSLSocket::wait(u_int32_t millis, int waitFor) throw(SocketException) { if(ssl && (waitFor & Socket::WAIT_READ)) { /** @todo Take writing into account as well if reading is possible? */ -// if(SSL_pending(ssl) > 0) -// return WAIT_READ; - // doesn't work in yassl...sigh... + char c; + if(SSL_peek(ssl, &c, 1) > 0) + return WAIT_READ; } return Socket::wait(millis, waitFor); } Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -44,7 +44,7 @@ "FinishedULWidths", "FinishedULOrder", "CID", "SpyFrameWidths", "SpyFrameOrder", "LogFileMainChat", "LogFilePrivateChat", "LogFileStatus", "LogFileUpload", "LogFileDownload", "LogFileSystem", "LogFormatSystem", "LogFormatStatus", "DirectoryListingFrameOrder", "DirectoryListingFrameWidths", - "SslPrivateKeyFile", "SslCertificateFile", "SslTrustedCertificatesPath", + "TLSPrivateKeyFile", "TLSCertificateFile", "TLSTrustedCertificatesPath", "SENTRY", // Ints "IncomingConnections", "InPort", "Slots", "Rollback", "AutoFollow", "ClearSearch", @@ -73,8 +73,9 @@ "NoIpOverride", "SearchOnlyFreeSlots", "LastSearchType", "BoldFinishedDownloads", "BoldFinishedUploads", "BoldQueue", "BoldHub", "BoldPm", "BoldSearch", "SocketInBuffer", "SocketOutBuffer", "OnlyDlTthFiles", "OpenWaitingUsers", "BoldWaitingUsers", "OpenSystemLog", "BoldSystemLog", "AutoRefreshTime", - "UseSsl", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", + "UseTLS", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", "DontDlAlreadyQueued", "MaxCommandLength", "AllowUntrustedHubs", "AllowUntrustedClients", + "TLSPort", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -244,6 +245,8 @@ setDefault(OPEN_WAITING_USERS, false); setDefault(OPEN_SYSTEM_LOG, true); setDefault(TLS_TRUSTED_CERTIFICATES_PATH, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR); + setDefault(TLS_PRIVATE_KEY_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.key"); + setDefault(TLS_CERTIFICATE_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.crt"); setDefault(BOLD_FINISHED_DOWNLOADS, true); setDefault(BOLD_FINISHED_UPLOADS, true); setDefault(BOLD_QUEUE, true); @@ -361,6 +364,8 @@ set(PRIVATE_ID, CID::generate().toBase32()); #endif setDefault(UDP_PORT, SETTING(TCP_PORT)); + + File::ensureDirectory(SETTING(TLS_TRUSTED_CERTIFICATES_PATH)); fire(SettingsManagerListener::Load(), &xml); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -695,6 +695,9 @@ int64_t size = i->getSize(); string fileName = aName + name; + if(Util::stricmp(fileName, SETTING(TLS_PRIVATE_KEY_FILE)) == 0) { + continue; + } try { if(HashManager::getInstance()->checkTTH(fileName, size, i->getLastWriteTime())) lastFileIter = dir->files.insert(lastFileIter, Directory::File(name, size, dir, HashManager::getInstance()->getTTH(fileName, size))); Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -42,6 +42,7 @@ "&Browse...", "Browse file list", "Certificate not trusted, unable to connect", +"TLS disabled, failed to generate certificate: ", "Choose folder", "CID", "Close", @@ -118,6 +119,8 @@ "Error saving hash data: ", "Exact size", "Executable", +"Failed to load certificate file", +"Failed to load private key", "Join/part of favorite users showing off", "Join/part of favorite users showing on", "Favorite name", @@ -289,14 +292,15 @@ "Nick", "Your nick was already taken, please change to something else!", " (Nick unknown)", +"TLS disabled, no certificate file set", " not shared; calculated CRC32 does not match the one found in SFV file.", -"No", "No directory specified", "You're trying to download from yourself!", "Can't download from passive users when you're passive", "No errors", "No matches", "No slots available", +"No", "No users", "No users to download from", "Normal", @@ -373,8 +377,8 @@ "Advanced\\Experts only", "Advanced resume using TTH", "Advanced settings", +"Allow TLS connections to clients without trusted certificate", "Allow TLS connections to hubs without trusted certificate", -"Allow TLS connections to hubs without trusted certificate", "Use antifragmentation method for downloads", "Appearance", "Appearance\\Colors and sounds", @@ -659,6 +663,7 @@ "BrowseAccel", "BrowseFileList", "CertificateNotTrusted", +"CertificateGenerationFailed", "ChooseFolder", "Cid", "Close", @@ -735,6 +740,8 @@ "ErrorSavingHash", "ExactSize", "Executable", +"FailedToLoadCertificate", +"FailedToLoadPrivateKey", "FavJoinShowingOff", "FavJoinShowingOn", "FavoriteDirName", @@ -906,14 +913,15 @@ "Nick", "NickTaken", "NickUnknown", +"NoCertificateFileSet", "NoCrc32Match", -"NoStr", "NoDirectorySpecified", "NoDownloadsFromSelf", "NoDownloadsFromPassive", "NoErrors", "NoMatches", "NoSlotsAvailable", +"NoStr", "NoUsers", "NoUsersToDownloadFrom", "Normal", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/StringDefs.h 2006-07-08 17:01:15 UTC (rev 625) @@ -45,6 +45,7 @@ BROWSE_ACCEL, // "&Browse..." BROWSE_FILE_LIST, // "Browse file list" CERTIFICATE_NOT_TRUSTED, // "Certificate not trusted, unable to connect" + CERTIFICATE_GENERATION_FAILED, // "TLS disabled, failed to generate certificate: " CHOOSE_FOLDER, // "Choose folder" CID, // "CID" CLOSE, // "Close" @@ -121,6 +122,8 @@ ERROR_SAVING_HASH, // "Error saving hash data: " EXACT_SIZE, // "Exact size" EXECUTABLE, // "Executable" + FAILED_TO_LOAD_CERTIFICATE, // "Failed to load certificate file" + FAILED_TO_LOAD_PRIVATE_KEY, // "Failed to load private key" FAV_JOIN_SHOWING_OFF, // "Join/part of favorite users showing off" FAV_JOIN_SHOWING_ON, // "Join/part of favorite users showing on" FAVORITE_DIR_NAME, // "Favorite name" @@ -292,14 +295,15 @@ NICK, // "Nick" NICK_TAKEN, // "Your nick was already taken, please change to something else!" NICK_UNKNOWN, // " (Nick unknown)" + NO_CERTIFICATE_FILE_SET, // "TLS disabled, no certificate file set" NO_CRC32_MATCH, // " not shared; calculated CRC32 does not match the one found in SFV file." - NO_STR, // "No" NO_DIRECTORY_SPECIFIED, // "No directory specified" NO_DOWNLOADS_FROM_SELF, // "You're trying to download from yourself!" NO_DOWNLOADS_FROM_PASSIVE, // "Can't download from passive users when you're passive" NO_ERRORS, // "No errors" NO_MATCHES, // "No matches" NO_SLOTS_AVAILABLE, // "No slots available" + NO_STR, // "No" NO_USERS, // "No users" NO_USERS_TO_DOWNLOAD_FROM, // "No users to download from" NORMAL, // "Normal" @@ -376,7 +380,7 @@ SETTINGS_ADVANCED3, // "Advanced\\Experts only" SETTINGS_ADVANCED_RESUME, // "Advanced resume using TTH" SETTINGS_ADVANCED_SETTINGS, // "Advanced settings" - SETTINGS_ALLOW_UNTRUSTED_CLIENTS, // "Allow TLS connections to hubs without trusted certificate" + SETTINGS_ALLOW_UNTRUSTED_CLIENTS, // "Allow TLS connections to clients without trusted certificate" SETTINGS_ALLOW_UNTRUSTED_HUBS, // "Allow TLS connections to hubs without trusted certificate" SETTINGS_ANTI_FRAG, // "Use antifragmentation method for downloads" SETTINGS_APPEARANCE, // "Appearance" Modified: dcplusplus/trunk/client/UserConnection.cpp =================================================================== --- dcplusplus/trunk/client/UserConnection.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/UserConnection.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -181,14 +181,14 @@ socket = BufferedSocket::getSocket(0); socket->addListener(this); - socket->connect(aServer, aPort, secure, true); + socket->connect(aServer, aPort, secure, BOOLSETTING(ALLOW_UNTRUSTED_CLIENTS), true); } void UserConnection::accept(const Socket& aServer) throw(SocketException, ThreadException) { dcassert(!socket); socket = BufferedSocket::getSocket(0); socket->addListener(this); - socket->accept(aServer, secure); + socket->accept(aServer, secure, BOOLSETTING(ALLOW_UNTRUSTED_CLIENTS)); } void UserConnection::inf(bool withToken) { Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/client/Util.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -248,6 +248,19 @@ i += 2; } + // Dots at the end of path names aren't popular + i = 0; + while( ((i = tmp.find(".\\", i)) != string::npos) ) { + tmp[i] = '_'; + i += 1; + } + i = 0; + while( ((i = tmp.find("./", i)) != string::npos) ) { + tmp[i] = '_'; + i += 1; + } + + return tmp; } Modified: dcplusplus/trunk/windows/CertificatesPage.cpp =================================================================== --- dcplusplus/trunk/windows/CertificatesPage.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/windows/CertificatesPage.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -25,6 +25,7 @@ #include "../client/SettingsManager.h" #include "../client/FavoriteManager.h" +#include "../client/CryptoManager.h" #include "WinUtil.h" @@ -67,3 +68,42 @@ HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_CERTIFICATESPAGE); return 0; } + +LRESULT CertificatesPage::onBrowsePrivateKey(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + tstring target = Text::toT(SETTING(TLS_PRIVATE_KEY_FILE)); + CEdit edt(GetDlgItem(IDC_TLS_PRIVATE_KEY_FILE)); + + if(WinUtil::browseFile(target, m_hWnd, false, target)) { + edt.SetWindowText(&target[0]); + } + return 0; +} + +LRESULT CertificatesPage::onBrowseCertificate(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + tstring target = Text::toT(SETTING(TLS_CERTIFICATE_FILE)); + CEdit edt(GetDlgItem(IDC_TLS_CERTIFICATE_FILE)); + + if(WinUtil::browseFile(target, m_hWnd, false, target)) { + edt.SetWindowText(&target[0]); + } + return 0; +} + +LRESULT CertificatesPage::onBrowseTrustedPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + tstring target = Text::toT(SETTING(TLS_TRUSTED_CERTIFICATES_PATH)); + CEdit edt(GetDlgItem(IDC_TLS_TRUSTED_CERTIFICATES_PATH)); + + if(WinUtil::browseDirectory(target, m_hWnd)) { + edt.SetWindowText(&target[0]); + } + return 0; +} + +LRESULT CertificatesPage::onGenerateCerts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + try { + CryptoManager::getInstance()->generateCertificate(); + } catch(const CryptoException& e) { + MessageBox(Text::toT(e.getError()).c_str(), L"Error generating certificate"); + } + return 0; +} Modified: dcplusplus/trunk/windows/CertificatesPage.h =================================================================== --- dcplusplus/trunk/windows/CertificatesPage.h 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/windows/CertificatesPage.h 2006-07-08 17:01:15 UTC (rev 625) @@ -39,10 +39,18 @@ BEGIN_MSG_MAP(CertificatesPage) MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) + COMMAND_ID_HANDLER(IDC_BROWSE_PRIVATE_KEY, onBrowsePrivateKey) + COMMAND_ID_HANDLER(IDC_BROWSE_CERTIFICATE, onBrowseCertificate) + COMMAND_ID_HANDLER(IDC_BROWSE_TRUSTED_PATH, onBrowseTrustedPath) + COMMAND_ID_HANDLER(IDC_GENERATE_CERTS, onGenerateCerts) NOTIFY_CODE_HANDLER_EX(PSN_HELP, onHelpInfo) MESSAGE_HANDLER(WM_HELP, onHelp) END_MSG_MAP() + LRESULT onBrowsePrivateKey(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT onBrowseCertificate(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT onBrowseTrustedPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT onGenerateCerts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT onHelp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT onHelpInfo(LPNMHDR /*pnmh*/); Modified: dcplusplus/trunk/windows/resource.h =================================================================== --- dcplusplus/trunk/windows/resource.h 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/windows/resource.h 2006-07-08 17:01:15 UTC (rev 625) @@ -417,12 +417,16 @@ #define IDC_AUTO_REFRESH_TIME 1419 #define IDC_SETTINGS_AUTO_REFRESH_TIME 1420 #define IDC_AUTO_SEARCH_LIMIT 1421 -#define IDC_SSL_OPTIONS 1421 #define IDC_TLS_OPTIONS 1421 #define IDC_SETTINGS_AUTO_SEARCH_LIMIT 1422 +#define IDC_GENERATE_CERTS 1422 #define IDC_CLOSE_ALL_PM 1423 +#define IDC_BROWSE_PRIVATE_KEY 1423 #define IDC_CLOSE_ALL_OFFLINE_PM 1424 +#define IDC_BROWSE_OWN_CERTIFICATE 1424 +#define IDC_BROWSE_CERTIFICATE 1424 #define IDC_CLOSE_ALL_DIR_LIST 1425 +#define IDC_BROWSE_TRUSTED_PATH 1425 #define IDC_CLOSE_ALL_SEARCH_FRAME 1426 #define IDC_BROWSELIST 3000 #define IDC_REMOVE_SOURCE 3500 @@ -465,7 +469,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 246 #define _APS_NEXT_COMMAND_VALUE 32789 -#define _APS_NEXT_CONTROL_VALUE 1422 +#define _APS_NEXT_CONTROL_VALUE 1426 #define _APS_NEXT_SYMED_VALUE 105 #endif #endif Modified: dcplusplus/trunk/yassl/src/ssl.cpp =================================================================== --- dcplusplus/trunk/yassl/src/ssl.cpp 2006-07-02 20:59:53 UTC (rev 624) +++ dcplusplus/trunk/yassl/src/ssl.cpp 2006-07-08 17:01:15 UTC (rev 625) @@ -1370,9 +1370,12 @@ } - int SSL_pending(SSL*) + int SSL_pending(SSL* ssl) { - return SSL_SUCCESS; // TODO: + // Just in case there's pending data that hasn't been processed yet... + char c; + SSL_peek(ssl, &c, 1); + return ssl->bufferedData(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-08 17:22:19
|
Revision: 626 Author: arnetheduck Date: 2006-07-08 10:21:56 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=626&view=rev Log Message: ----------- More minor fixes Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/config.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-08 17:01:15 UTC (rev 625) +++ dcplusplus/trunk/changelog.txt 2006-07-08 17:21:56 UTC (rev 626) @@ -33,6 +33,7 @@ * Added a few TLS options; [U] in transfer status means untrusted TLS (encrypted but certificate not validated) * Added certificate generation, OpenSSL must be installed and in PATH for this to work * [bug 996] Fixed an issue where directories that are hard to delete were created +* [bug 1000] Fixed linux compile issue (thanks steven sheehy) -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-08 17:01:15 UTC (rev 625) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-08 17:21:56 UTC (rev 626) @@ -36,15 +36,15 @@ separator(aSeparator), mode(MODE_LINE), dataBytes(0), rollback(0), failed(false), sock(0), disconnecting(false), filterIn(NULL) { - sockets++; + Thread::safeInc(sockets); } -size_t BufferedSocket::sockets = 0; +volatile long BufferedSocket::sockets = 0; BufferedSocket::~BufferedSocket() throw() { delete sock; delete filterIn; - sockets--; + Thread::safeDec(sockets); } void BufferedSocket::setMode (Modes aMode, size_t aRollback) { @@ -74,22 +74,21 @@ void BufferedSocket::accept(const Socket& srv, bool secure, bool allowUntrusted) throw(SocketException, ThreadException) { dcassert(!sock); - - dcdebug("BufferedSocket::accept() %p\n", (void*)this); - sock = secure ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : new Socket; + try { + dcdebug("BufferedSocket::accept() %p\n", (void*)this); + sock = secure ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : new Socket; - sock->accept(srv); - if(SETTING(SOCKET_IN_BUFFER) > 0) - sock->setSocketOpt(SO_RCVBUF, SETTING(SOCKET_IN_BUFFER)); - if(SETTING(SOCKET_OUT_BUFFER) > 0) - sock->setSocketOpt(SO_SNDBUF, SETTING(SOCKET_OUT_BUFFER)); - sock->setBlocking(false); + sock->accept(srv); + if(SETTING(SOCKET_IN_BUFFER) > 0) + sock->setSocketOpt(SO_RCVBUF, SETTING(SOCKET_IN_BUFFER)); + if(SETTING(SOCKET_OUT_BUFFER) > 0) + sock->setSocketOpt(SO_SNDBUF, SETTING(SOCKET_OUT_BUFFER)); + sock->setBlocking(false); - inbuf.resize(sock->getSocketOptInt(SO_RCVBUF)); + inbuf.resize(sock->getSocketOptInt(SO_RCVBUF)); - // This lock prevents the shutdown task from being added and executed before we're done initializing the socket - Lock l(cs); - try { + // This lock prevents the shutdown task from being added and executed before we're done initializing the socket + Lock l(cs); start(); } catch(...) { delete sock; @@ -103,20 +102,20 @@ void BufferedSocket::connect(const string& aAddress, short aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException) { dcassert(!sock); - dcdebug("BufferedSocket::connect() %p\n", (void*)this); - sock = secure ? CryptoManager::getInstance()->getClientSocket(allowUntrusted) : new Socket; + try { + dcdebug("BufferedSocket::connect() %p\n", (void*)this); + sock = secure ? CryptoManager::getInstance()->getClientSocket(allowUntrusted) : new Socket; - sock->create(); - if(SETTING(SOCKET_IN_BUFFER) >= 1024) - sock->setSocketOpt(SO_RCVBUF, SETTING(SOCKET_IN_BUFFER)); - if(SETTING(SOCKET_OUT_BUFFER) >= 1024) - sock->setSocketOpt(SO_SNDBUF, SETTING(SOCKET_OUT_BUFFER)); - sock->setBlocking(false); + sock->create(); + if(SETTING(SOCKET_IN_BUFFER) >= 1024) + sock->setSocketOpt(SO_RCVBUF, SETTING(SOCKET_IN_BUFFER)); + if(SETTING(SOCKET_OUT_BUFFER) >= 1024) + sock->setSocketOpt(SO_SNDBUF, SETTING(SOCKET_OUT_BUFFER)); + sock->setBlocking(false); - inbuf.resize(sock->getSocketOptInt(SO_RCVBUF)); + inbuf.resize(sock->getSocketOptInt(SO_RCVBUF)); - Lock l(cs); - try { + Lock l(cs); start(); } catch(...) { delete sock; Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-07-08 17:01:15 UTC (rev 625) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-07-08 17:21:56 UTC (rev 626) @@ -174,7 +174,7 @@ void threadDisconnect(); void fail(const string& aError); - static size_t sockets; + static volatile long sockets; bool checkEvents(); void checkSocket(); Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-07-08 17:01:15 UTC (rev 625) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-07-08 17:21:56 UTC (rev 626) @@ -70,6 +70,7 @@ dh = 0; } else { SSL_CTX_set_tmp_dh(serverContext, dh); + SSL_CTX_set_tmp_dh(serverVerContext, dh); } } } @@ -79,6 +80,10 @@ SSL_CTX_free(serverContext); if(clientContext) SSL_CTX_free(clientContext); + if(serverVerContext) + SSL_CTX_free(serverVerContext); + if(clientVerContext) + SSL_CTX_free(clientVerContext); if(dh) DH_free(dh); } @@ -194,6 +199,15 @@ if(SSL_CTX_load_verify_locations(clientContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); } + if(SSL_CTX_load_verify_locations(clientVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); + } + if(SSL_CTX_load_verify_locations(serverContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); + } + if(SSL_CTX_load_verify_locations(serverVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); + } } while(FindNextFile(hFind, &data)); FindClose(hFind); Modified: dcplusplus/trunk/client/config.h =================================================================== --- dcplusplus/trunk/client/config.h 2006-07-08 17:01:15 UTC (rev 625) +++ dcplusplus/trunk/client/config.h 2006-07-08 17:21:56 UTC (rev 626) @@ -27,10 +27,6 @@ #include "autoconf.h" #endif -// Changing this number will change the maximum number of simultaneous users -// we can handle (when using select)... -#define FD_SETSIZE 4096 - // Remove this line if hashes are not available in your stl #define HAVE_HASH 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-08 18:47:02
|
Revision: 627 Author: arnetheduck Date: 2006-07-08 11:46:12 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=627&view=rev Log Message: ----------- TLS port settings Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/SimpleXML.cpp dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/NetworkPage.cpp dcplusplus/trunk/windows/resource.h Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-07-08 18:46:12 UTC (rev 627) @@ -573,9 +573,9 @@ WS_TABSTOP,12,103,249,10 LTEXT "Ports",IDC_SETTINGS_PORTS,230,17,18,8 LTEXT "TCP",IDC_SETTINGS_PORT_TCP,209,31,15,8,NOT WS_GROUP - EDITTEXT IDC_PORT_TCP,230,28,29,14,ES_AUTOHSCROLL + EDITTEXT IDC_PORT_TCP,230,28,29,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "UDP",IDC_SETTINGS_PORT_UDP,209,48,16,8 - EDITTEXT IDC_PORT_UDP,230,45,30,14,ES_AUTOHSCROLL + EDITTEXT IDC_PORT_UDP,230,45,30,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "External / WAN IP",IDC_SETTINGS_IP,59,59,68,8,NOT WS_GROUP EDITTEXT IDC_EXTERNAL_IP,59,69,99,14,ES_AUTOHSCROLL @@ -598,6 +598,8 @@ CONTROL "Use SOCKS5 server to resolve hostnames", IDC_SOCKS_RESOLVE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,59,207,165,10 + LTEXT "TLS",IDC_SETTINGS_PORT_TLS,209,64,21,8 + EDITTEXT IDC_PORT_TLS,230,61,30,14,ES_AUTOHSCROLL | ES_NUMBER END IDD_WINDOWSPAGE DIALOGEX 0, 0, 275, 225 Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/Example.xml 2006-07-08 18:46:12 UTC (rev 627) @@ -506,7 +506,8 @@ <String Name="SettingsSounds">Sounds</String> <String Name="SettingsSpeedsNotAccurate">Note; because of changing download speeds, this is not 100% accurate...</String> <String Name="SettingsStatusInChat">View status messages in main chat</String> - <String Name="SettingsTcpPort">TCP Port</String> + <String Name="SettingsTcpPort">TCP</String> + <String Name="SettingsTlsPort">TLS</String> <String Name="SettingsTextMinislot">Mini slot size</String> <String Name="SettingsPrioAutoprio">Autoprio settings</String> <String Name="SettingsPrioHighest">Highest prio max size</String> @@ -517,7 +518,7 @@ <String Name="SettingsTimeStamps">Show timestamps in chat by default</String> <String Name="SettingsTimeStampsFormat">Set timestamps</String> <String Name="SettingsToggleActiveWindow">Toggle window when selecting an active tab</String> - <String Name="SettingsUdpPort">UDP Port</String> + <String Name="SettingsUdpPort">UDP</String> <String Name="SettingsUnfinishedDownloadDirectory">Unfinished downloads directory</String> <String Name="SettingsUploadLineSpeed">Line speed (upload)</String> <String Name="SettingsUploads">Sharing</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/changelog.txt 2006-07-08 18:46:12 UTC (rev 627) @@ -34,6 +34,9 @@ * Added certificate generation, OpenSSL must be installed and in PATH for this to work * [bug 996] Fixed an issue where directories that are hard to delete were created * [bug 1000] Fixed linux compile issue (thanks steven sheehy) +* [bug 949] Fixed a crash when reading invalid XML files +* TLS port may now be specified in settings and is only opened if TLS is enabled +* Added TLS port to /connection -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -67,7 +67,10 @@ } } - lastPort++; + if(!CryptoManager::getInstance()->TLSOk()) { + return; + } + lastPort = (unsigned short)SETTING(TLS_PORT); firstPort = lastPort; while(true) { Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -116,6 +116,7 @@ setDefault(SLOTS, 1); setDefault(TCP_PORT, 0); setDefault(UDP_PORT, 0); + setDefault(TLS_PORT, 0); setDefault(INCOMING_CONNECTIONS, INCOMING_DIRECT); setDefault(OUTGOING_CONNECTIONS, OUTGOING_DIRECT); setDefault(ROLLBACK, 4096); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -294,13 +294,13 @@ break; } } - } else if(cur != NULL) { + } else if(cur != 0) { cur = new ShareManager::Directory(getAttrib(attribs, "Name", 0), cur); cur->addType(SearchManager::TYPE_DIRECTORY); // needed since we match our own name in directory searches cur->getParent()->directories[cur->getName()] = cur; } - if(simple) + if(simple && cur) cur = cur->getParent(); else depth++; Modified: dcplusplus/trunk/client/SimpleXML.cpp =================================================================== --- dcplusplus/trunk/client/SimpleXML.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/client/SimpleXML.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -164,9 +164,12 @@ string::size_type j; for(;;) { - if((j = tmp.find('=', i)) == string::npos) { + if((j = tmp.find_first_of("= \"'/>", i)) == string::npos) { throw SimpleXMLException("Missing '=' in " + name); } + if(tmp[j] != '=') { + throw SimpleXMLException("Missing '=' in " + name); + } if(tmp[j+1] != '"' && tmp[j+1] != '\'') { throw SimpleXMLException("Invalid character after '=' in " + name); Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -507,7 +507,8 @@ "Sounds", "Note; because of changing download speeds, this is not 100% accurate...", "View status messages in main chat", -"TCP Port", +"TCP", +"TLS", "Mini slot size", "Autoprio settings", "Highest prio max size", @@ -518,7 +519,7 @@ "Show timestamps in chat by default", "Set timestamps", "Toggle window when selecting an active tab", -"UDP Port", +"UDP", "Unfinished downloads directory", "Line speed (upload)", "Sharing", @@ -1129,6 +1130,7 @@ "SettingsSpeedsNotAccurate", "SettingsStatusInChat", "SettingsTcpPort", +"SettingsTlsPort", "SettingsTextMinislot", "SettingsPrioAutoprio", "SettingsPrioHighest", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/client/StringDefs.h 2006-07-08 18:46:12 UTC (rev 627) @@ -510,7 +510,8 @@ SETTINGS_SOUNDS, // "Sounds" SETTINGS_SPEEDS_NOT_ACCURATE, // "Note; because of changing download speeds, this is not 100% accurate..." SETTINGS_STATUS_IN_CHAT, // "View status messages in main chat" - SETTINGS_TCP_PORT, // "TCP Port" + SETTINGS_TCP_PORT, // "TCP" + SETTINGS_TLS_PORT, // "TLS" SETTINGS_TEXT_MINISLOT, // "Mini slot size" SETTINGS_PRIO_AUTOPRIO, // "Autoprio settings" SETTINGS_PRIO_HIGHEST, // "Highest prio max size" @@ -521,7 +522,7 @@ SETTINGS_TIME_STAMPS, // "Show timestamps in chat by default" SETTINGS_TIME_STAMPS_FORMAT, // "Set timestamps" SETTINGS_TOGGLE_ACTIVE_WINDOW, // "Toggle window when selecting an active tab" - SETTINGS_UDP_PORT, // "UDP Port" + SETTINGS_UDP_PORT, // "UDP" SETTINGS_UNFINISHED_DOWNLOAD_DIRECTORY, // "Unfinished downloads directory" SETTINGS_UPLOAD_LINE_SPEED, // "Line speed (upload)" SETTINGS_UPLOADS, // "Sharing" Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -231,7 +231,12 @@ } else if(Util::stricmp(cmd.c_str(), _T("userlist")) == 0) { ctrlShowUsers.SetCheck(showUsers ? BST_UNCHECKED : BST_CHECKED); } else if(Util::stricmp(cmd.c_str(), _T("connection")) == 0) { - addClientLine(Text::toT((STRING(IP) + client->getLocalIp() + ", " + STRING(PORT) + Util::toString(ConnectionManager::getInstance()->getPort()) + "/" + Util::toString(SearchManager::getInstance()->getPort())))); + addClientLine(Text::toT((STRING(IP) + client->getLocalIp() + ", " + + STRING(PORT) + + Util::toString(ConnectionManager::getInstance()->getPort()) + "/" + + Util::toString(SearchManager::getInstance()->getPort()) + "/" + + Util::toString(ConnectionManager::getInstance()->getSecurePort()) + ))); } else if((Util::stricmp(cmd.c_str(), _T("favorite")) == 0) || (Util::stricmp(cmd.c_str(), _T("fav")) == 0)) { addAsFavorite(); } else if((Util::stricmp(cmd.c_str(), _T("removefavorite")) == 0) || (Util::stricmp(cmd.c_str(), _T("removefav")) == 0)) { Modified: dcplusplus/trunk/windows/NetworkPage.cpp =================================================================== --- dcplusplus/trunk/windows/NetworkPage.cpp 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/windows/NetworkPage.cpp 2006-07-08 18:46:12 UTC (rev 627) @@ -37,6 +37,7 @@ { IDC_SETTINGS_IP, ResourceManager::SETTINGS_EXTERNAL_IP }, { IDC_SETTINGS_PORT_TCP, ResourceManager::SETTINGS_TCP_PORT }, { IDC_SETTINGS_PORT_UDP, ResourceManager::SETTINGS_UDP_PORT }, + { IDC_SETTINGS_PORT_TLS, ResourceManager::SETTINGS_TLS_PORT }, { IDC_SETTINGS_SOCKS5_IP, ResourceManager::SETTINGS_SOCKS5_IP }, { IDC_SETTINGS_SOCKS5_PORT, ResourceManager::SETTINGS_SOCKS5_PORT }, { IDC_SETTINGS_SOCKS5_USERNAME, ResourceManager::SETTINGS_SOCKS5_USERNAME }, @@ -51,6 +52,7 @@ { IDC_EXTERNAL_IP, SettingsManager::EXTERNAL_IP, PropPage::T_STR }, { IDC_PORT_TCP, SettingsManager::TCP_PORT, PropPage::T_INT }, { IDC_PORT_UDP, SettingsManager::UDP_PORT, PropPage::T_INT }, + { IDC_PORT_TLS, SettingsManager::TLS_PORT, PropPage::T_INT }, { IDC_OVERRIDE, SettingsManager::NO_IP_OVERRIDE, PropPage::T_BOOL }, { IDC_SOCKS_SERVER, SettingsManager::SOCKS_SERVER, PropPage::T_STR }, { IDC_SOCKS_PORT, SettingsManager::SOCKS_PORT, PropPage::T_INT }, Modified: dcplusplus/trunk/windows/resource.h =================================================================== --- dcplusplus/trunk/windows/resource.h 2006-07-08 17:21:56 UTC (rev 626) +++ dcplusplus/trunk/windows/resource.h 2006-07-08 18:46:12 UTC (rev 627) @@ -373,6 +373,8 @@ #define IDC_SOCKET_OUT_BUFFER 1318 #define IDC_SSL_CERTIFICATE_FILE 1318 #define IDC_TLS_CERTIFICATE_FILE 1318 +#define IDC_TLS_PORT 1318 +#define IDC_PORT_TLS 1318 #define IDC_SETTINGS_SOCKET_OUT_BUFFER 1319 #define IDC_SETTINGS_SOCKET_IN_BUFFER 1320 #define IDC_CHECK1 1321 @@ -423,11 +425,11 @@ #define IDC_CLOSE_ALL_PM 1423 #define IDC_BROWSE_PRIVATE_KEY 1423 #define IDC_CLOSE_ALL_OFFLINE_PM 1424 -#define IDC_BROWSE_OWN_CERTIFICATE 1424 #define IDC_BROWSE_CERTIFICATE 1424 #define IDC_CLOSE_ALL_DIR_LIST 1425 #define IDC_BROWSE_TRUSTED_PATH 1425 #define IDC_CLOSE_ALL_SEARCH_FRAME 1426 +#define IDC_SETTINGS_PORT_TLS 1427 #define IDC_BROWSELIST 3000 #define IDC_REMOVE_SOURCE 3500 #define IDC_PM 4000 @@ -469,7 +471,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 246 #define _APS_NEXT_COMMAND_VALUE 32789 -#define _APS_NEXT_CONTROL_VALUE 1426 +#define _APS_NEXT_CONTROL_VALUE 1428 #define _APS_NEXT_SYMED_VALUE 105 #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-09 09:15:40
|
Revision: 628 Author: arnetheduck Date: 2006-07-09 02:15:27 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=628&view=rev Log Message: ----------- Patches Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/DirectoryListing.cpp dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-08 18:46:12 UTC (rev 627) +++ dcplusplus/trunk/changelog.txt 2006-07-09 09:15:27 UTC (rev 628) @@ -1,4 +1,4 @@ --- 0.692 -- +-- 0.692 2006-07-09 -- * [bug 927] Fixed OP detection bug really (thanks pothead) * [bug 938] Added a few more ADC info fields (thanks ullner) * [bug 939] Fixed hub info update (thanks ullner) @@ -37,6 +37,8 @@ * [bug 949] Fixed a crash when reading invalid XML files * TLS port may now be specified in settings and is only opened if TLS is enabled * Added TLS port to /connection +* [bug 977] Added copy hub address to hub right-click menu (thanks pothead) +* [bug 1001] Fixed assertion on unix (thanks steven sheehy) -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/DirectoryListing.cpp =================================================================== --- dcplusplus/trunk/client/DirectoryListing.cpp 2006-07-08 18:46:12 UTC (rev 627) +++ dcplusplus/trunk/client/DirectoryListing.cpp 2006-07-09 09:15:27 UTC (rev 628) @@ -338,7 +338,7 @@ void DirectoryListing::download(const string& aDir, const string& aTarget, bool highPrio) { dcassert(aDir.size() > 2); - dcassert(aDir[aDir.size() - 1] == PATH_SEPARATOR); + dcassert(aDir[aDir.size() - 1] == '\\'); // This should not be PATH_SEPARATOR Directory* d = find(aDir, getRoot()); if(d != NULL) download(d, aTarget, highPrio); Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-07-08 18:46:12 UTC (rev 627) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-07-09 09:15:27 UTC (rev 628) @@ -119,6 +119,7 @@ tabMenu = CreatePopupMenu(); tabMenu.AppendMenu(MF_STRING, IDC_ADD_AS_FAVORITE, CTSTRING(ADD_TO_FAVORITES)); tabMenu.AppendMenu(MF_STRING, ID_FILE_RECONNECT, CTSTRING(MENU_RECONNECT)); + tabMenu.AppendMenu(MF_STRING, IDC_COPY_HUB, CTSTRING(COPY_HUB)); showJoins = BOOLSETTING(SHOW_JOINS); favShowJoins = BOOLSETTING(FAV_SHOW_JOINS); @@ -373,6 +374,11 @@ return 0; } +LRESULT HubFrame::onCopyHub(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + WinUtil::setClipboard(Text::toT(client->getHubUrl())); + return 0; +} + LRESULT HubFrame::onDoubleClickUsers(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) { NMITEMACTIVATE* item = (NMITEMACTIVATE*)pnmh; if(item->iItem != -1) { Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-07-08 18:46:12 UTC (rev 627) +++ dcplusplus/trunk/windows/HubFrame.h 2006-07-09 09:15:27 UTC (rev 628) @@ -72,6 +72,7 @@ COMMAND_ID_HANDLER(IDC_SEND_MESSAGE, onSendMessage) COMMAND_ID_HANDLER(IDC_ADD_AS_FAVORITE, onAddAsFavorite) COMMAND_ID_HANDLER(IDC_COPY_NICK, onCopyNick) + COMMAND_ID_HANDLER(IDC_COPY_HUB, onCopyHub) COMMAND_ID_HANDLER(IDC_CLOSE_WINDOW, onCloseWindow) CHAIN_COMMANDS(ucBase) CHAIN_COMMANDS(uibBase) @@ -92,6 +93,7 @@ LRESULT onSpeaker(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/); LRESULT onCopyNick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT onCopyHub(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); LRESULT onDoubleClickUsers(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-09 11:07:30
|
Revision: 630 Author: arnetheduck Date: 2006-07-09 04:07:09 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=630&view=rev Log Message: ----------- Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/help/changelog.html dcplusplus/trunk/makedefs.py Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-09 09:31:00 UTC (rev 629) +++ dcplusplus/trunk/Example.xml 2006-07-09 11:07:09 UTC (rev 630) @@ -1,5 +1,5 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version="0.692" Revision="1" RightToLeft="0"> +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<Language Name="Example Language" Author="arnetheduck" Version="0.691" Revision="1" RightToLeft="0"> <Strings> <String Name="Active">Active</String> <String Name="ActiveSearchString">Enabled / Search String</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-09 09:31:00 UTC (rev 629) +++ dcplusplus/trunk/changelog.txt 2006-07-09 11:07:09 UTC (rev 630) @@ -1,4 +1,8 @@ --- 0.692 2006-07-09 -- +-- 0.693 2006-07-09 -- +* Fixed crash bug +* Added language code to example language xml + +-- 0.692 2006-07-09 -- * [bug 927] Fixed OP detection bug really (thanks pothead) * [bug 938] Added a few more ADC info fields (thanks ullner) * [bug 939] Fixed hub info update (thanks ullner) Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-09 09:31:00 UTC (rev 629) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-09 11:07:09 UTC (rev 630) @@ -90,13 +90,13 @@ // This lock prevents the shutdown task from being added and executed before we're done initializing the socket Lock l(cs); start(); + addTask(ACCEPTED, 0); } catch(...) { delete sock; sock = 0; throw; } - addTask(ACCEPTED, 0); } void BufferedSocket::connect(const string& aAddress, short aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException) { @@ -117,13 +117,13 @@ Lock l(cs); start(); + addTask(CONNECT, new ConnectInfo(aAddress, aPort, proxy && (SETTING(OUTGOING_CONNECTIONS) == SettingsManager::OUTGOING_SOCKS5))); } catch(...) { delete sock; sock = 0; throw; } - addTask(CONNECT, new ConnectInfo(aAddress, aPort, proxy && (SETTING(OUTGOING_CONNECTIONS) == SettingsManager::OUTGOING_SOCKS5))); } #define CONNECT_TIMEOUT 30000 Modified: dcplusplus/trunk/help/changelog.html =================================================================== --- dcplusplus/trunk/help/changelog.html 2006-07-09 09:31:00 UTC (rev 629) +++ dcplusplus/trunk/help/changelog.html 2006-07-09 11:07:09 UTC (rev 630) @@ -13,6 +13,50 @@ <h1>DC++ Changelog</h1> See the version history of DC++ below. +<h2>0.692 <span style="color: gray;">(2006-07-09)</span></h2> +<ul> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=927">[bug 927]</a> Fixed OP detection bug really (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=938">[bug 938]</a> Added a few more ADC info fields (thanks ullner)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=939">[bug 939]</a> Fixed hub info update (thanks ullner)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=940">[bug 940]</a> Fixed a 64-bit compile error (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=942">[bug 942]</a> Fixed atomic operations on unices (thanks tobias nygren)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=943">[bug 943]</a> Fixed unix utsname compile issue (thanks tobias nygren)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=944">[bug 944]</a> Fixed unix string conversion bug (thanks tobias nygren)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=945">[bug 945]</a> Fixed unix mutex initialiser (thanks tobias nygren)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=946">[bug 946]</a> Tiger hash supports big endian and 64-bit architectures (thanks tobias nygren)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=941">[bug 941]</a> Updated usercount display (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=951">[bug 951]</a> Fixed issue with high port numbers (thanks tpo)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=958">[bug 958]</a> Search spy tth option automagically saved (thanks ullner)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=959">[bug 959]</a> Code cleanup (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=966">[bug 966]</a> Max hash speed fixed when fast hashing method is not used (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=967">[bug 967]</a> Fixed path case-sensitivity issue (thanks steven sheehy)</li> + <li>Fixed auto-reconnect</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=936">[bug 936]</a> Fixed duplicate entries in search hubs</li> + <li>Fixed some hub title display issues</li> + <li>Some spring cleanup</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=970">[bug 970]</a> Unix file permissions correctly set (thanks steven sheehy)</li> + <li>[ADC] Allowed $ and | in nick/description</li> + <li>Fixed targetdrive bug for temp target location</li> + <li>Fixed a crash bug when hash data cannot be saved</li> + <li>Possibly fixed issues with queue items not being updated</li> + <li>Added warning when someone tries to spam hublist.org or dcpp.net with your client</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=968">[bug 968]</a> Fixed unix compile issue (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=975">[bug 975]</a> Fixed silly warning (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=978">[bug 978]</a> Fixed 64-bit compiler issue (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=988">[bug 988]</a> Only unique nicks diplayed in title bar</li> + <li>Added protection from hubs/clients sending junk data resulting in high memory usage / crash</li> + <li>Updated to yaSSL 1.3.7</li> + <li>Added a few TLS options; [U] in transfer status means untrusted TLS (encrypted but certificate not validated)</li> + <li>Added certificate generation, OpenSSL must be installed and in PATH for this to work</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=996">[bug 996]</a> Fixed an issue where directories that are hard to delete were created</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1000">[bug 1000]</a> Fixed linux compile issue (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=949">[bug 949]</a> Fixed a crash when reading invalid XML files</li> + <li>TLS port may now be specified in settings and is only opened if TLS is enabled</li> + <li>Added TLS port to /connection</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=977">[bug 977]</a> Added copy hub address to hub right-click menu (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1001">[bug 1001]</a> Fixed assertion on unix (thanks steven sheehy)</li> +</ul> + <h2>0.691 <span style="color: gray;">(2006-06-03)</span></h2> <ul> <li>Links to bugzilla in html changelog</li> Modified: dcplusplus/trunk/makedefs.py =================================================================== --- dcplusplus/trunk/makedefs.py 2006-07-09 09:31:00 UTC (rev 629) +++ dcplusplus/trunk/makedefs.py 2006-07-09 11:07:09 UTC (rev 630) @@ -29,7 +29,7 @@ prolog = ""; example = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n'; -example += '<Language Name="Example Language" Author="arnetheduck" Version=' + version + ' Revision="1" RightToLeft="0">\n' +example += '<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version=' + version + ' Revision="1" RightToLeft="0">\n' example += '\t<Strings>\n'; lre = re.compile('\s*(\w+),\s*//\s*\"(.+)\"\s*') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-09 11:39:22
|
Revision: 632 Author: arnetheduck Date: 2006-07-09 04:39:04 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=632&view=rev Log Message: ----------- Version update Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/client/version.h Removed Paths: ------------- dcplusplus/trunk/yassl/.cvsignore Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-07-09 11:21:30 UTC (rev 631) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-07-09 11:39:04 UTC (rev 632) @@ -942,8 +942,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,9,2 - PRODUCTVERSION 0,6,9,2 + FILEVERSION 0,6,9,3 + PRODUCTVERSION 0,6,9,3 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -960,12 +960,12 @@ BEGIN VALUE "Comments", "http://dcplusplus.sourceforge.net" VALUE "FileDescription", "DC++" - VALUE "FileVersion", "0, 6, 9, 2" + VALUE "FileVersion", "0, 6, 9, 3" VALUE "InternalName", "DC++" VALUE "LegalCopyright", "Copyright 2001-2006 Jacek Sieka" VALUE "OriginalFilename", "DCPlusPlus.exe" VALUE "ProductName", "DC++" - VALUE "ProductVersion", "0, 6, 9, 2" + VALUE "ProductVersion", "0, 6, 9, 3" END END BLOCK "VarFileInfo" Modified: dcplusplus/trunk/client/version.h =================================================================== --- dcplusplus/trunk/client/version.h 2006-07-09 11:21:30 UTC (rev 631) +++ dcplusplus/trunk/client/version.h 2006-07-09 11:39:04 UTC (rev 632) @@ -17,8 +17,8 @@ */ #define APPNAME "DC++" -#define VERSIONSTRING "0.692" -#define VERSIONFLOAT 0.692 +#define VERSIONSTRING "0.693" +#define VERSIONFLOAT 0.693 /* Update the .rc file as well... */ Deleted: dcplusplus/trunk/yassl/.cvsignore =================================================================== --- dcplusplus/trunk/yassl/.cvsignore 2006-07-09 11:21:30 UTC (rev 631) +++ dcplusplus/trunk/yassl/.cvsignore 2006-07-09 11:39:04 UTC (rev 632) @@ -1 +0,0 @@ -doc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-10 20:34:56
|
Revision: 636 Author: arnetheduck Date: 2006-07-10 13:34:17 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=636&view=rev Log Message: ----------- 0.694 fixes Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/Streams.h dcplusplus/trunk/client/version.h dcplusplus/trunk/windows/DirectoryListingFrm.cpp Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-07-10 20:34:17 UTC (rev 636) @@ -942,8 +942,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,9,3 - PRODUCTVERSION 0,6,9,3 + FILEVERSION 0,6,9,4 + PRODUCTVERSION 0,6,9,4 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -960,12 +960,12 @@ BEGIN VALUE "Comments", "http://dcplusplus.sourceforge.net" VALUE "FileDescription", "DC++" - VALUE "FileVersion", "0, 6, 9, 3" + VALUE "FileVersion", "0, 6, 9, 4" VALUE "InternalName", "DC++" VALUE "LegalCopyright", "Copyright 2001-2006 Jacek Sieka" VALUE "OriginalFilename", "DCPlusPlus.exe" VALUE "ProductName", "DC++" - VALUE "ProductVersion", "0, 6, 9, 3" + VALUE "ProductVersion", "0, 6, 9, 4" END END BLOCK "VarFileInfo" Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/Example.xml 2006-07-10 20:34:17 UTC (rev 636) @@ -1,5 +1,5 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version="0.691" Revision="1" RightToLeft="0"> +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version="0.694" Revision="1" RightToLeft="0"> <Strings> <String Name="Active">Active</String> <String Name="ActiveSearchString">Enabled / Search String</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/changelog.txt 2006-07-10 20:34:17 UTC (rev 636) @@ -1,4 +1,10 @@ --- 0.693 2006-07-09 -- +-- 0.694 2006-07-10 -- +* Fixed crash in certificates page +* [bug 1005] Fixed linux compile issue (thanks tpo) +* [bug 1004] Fixed browse file list on self +* Both .crt and .pem files are read as trusted certificates + +-- 0.693 2006-07-09 -- * Fixed crash bug * Added language code to example language xml Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-07-10 20:34:17 UTC (rev 636) @@ -196,18 +196,29 @@ hFind = FindFirstFile(Text::toT(SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + "*.pem").c_str(), &data); if(hFind != INVALID_HANDLE_VALUE) { do { - if(SSL_CTX_load_verify_locations(clientContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + if( + SSL_CTX_load_verify_locations(clientContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS || + SSL_CTX_load_verify_locations(clientVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS || + SSL_CTX_load_verify_locations(serverContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS || + SSL_CTX_load_verify_locations(serverVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS + ) { LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); } - if(SSL_CTX_load_verify_locations(clientVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { + } while(FindNextFile(hFind, &data)); + + FindClose(hFind); + } + hFind = FindFirstFile(Text::toT(SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + "*.crt").c_str(), &data); + if(hFind != INVALID_HANDLE_VALUE) { + do { + if( + SSL_CTX_load_verify_locations(clientContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS || + SSL_CTX_load_verify_locations(clientVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS || + SSL_CTX_load_verify_locations(serverContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS || + SSL_CTX_load_verify_locations(serverVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS + ) { LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); } - if(SSL_CTX_load_verify_locations(serverContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); - } - if(SSL_CTX_load_verify_locations(serverVerContext, (SETTING(TLS_TRUSTED_CERTIFICATES_PATH) + Text::fromT(data.cFileName)).c_str(), NULL) != SSL_SUCCESS) { - LogManager::getInstance()->message("Failed to load trusted certificate from " + Text::fromT(data.cFileName)); - } } while(FindNextFile(hFind, &data)); FindClose(hFind); Modified: dcplusplus/trunk/client/HashManager.h =================================================================== --- dcplusplus/trunk/client/HashManager.h 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/client/HashManager.h 2006-07-10 20:34:17 UTC (rev 636) @@ -32,6 +32,7 @@ #include "Util.h" #include "FastAlloc.h" #include "Text.h" +#include "Streams.h" STANDARD_EXCEPTION(HashException); class File; Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-07-10 20:34:17 UTC (rev 636) @@ -413,7 +413,11 @@ add(target, -1, NULL, aUser, USER_LIST_NAME, true, QueueItem::FLAG_USER_LIST | aFlags); } -void QueueManager::addPfs(const User::Ptr& aUser, const string& aDir) throw() { +void QueueManager::addPfs(const User::Ptr& aUser, const string& aDir) throw(QueueException) { + if(aUser == ClientManager::getInstance()->getMe()) { + throw QueueException(STRING(NO_DOWNLOADS_FROM_SELF)); + } + if(!aUser->isOnline() || aUser->getCID().isZero()) return; Modified: dcplusplus/trunk/client/QueueManager.h =================================================================== --- dcplusplus/trunk/client/QueueManager.h 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/client/QueueManager.h 2006-07-10 20:34:17 UTC (rev 636) @@ -80,7 +80,7 @@ /** Add a user's filelist to the queue. */ void addList(const User::Ptr& aUser, int aFlags) throw(QueueException, FileException); /** Queue a partial file list download */ - void addPfs(const User::Ptr& aUser, const string& aDir) throw(); + void addPfs(const User::Ptr& aUser, const string& aDir) throw(QueueException); /** Readd a source that was removed */ void readd(const string& target, User::Ptr& aUser) throw(QueueException); /** Add a directory to the queue (downloads filelist and matches the directory). */ Modified: dcplusplus/trunk/client/Streams.h =================================================================== --- dcplusplus/trunk/client/Streams.h 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/client/Streams.h 2006-07-10 20:34:17 UTC (rev 636) @@ -23,6 +23,7 @@ #pragma once #endif // _MSC_VER > 1000 +#include "SettingsManager.h" #include "Exception.h" STANDARD_EXCEPTION(FileException); Modified: dcplusplus/trunk/client/version.h =================================================================== --- dcplusplus/trunk/client/version.h 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/client/version.h 2006-07-10 20:34:17 UTC (rev 636) @@ -17,8 +17,8 @@ */ #define APPNAME "DC++" -#define VERSIONSTRING "0.693" -#define VERSIONFLOAT 0.693 +#define VERSIONSTRING "0.694" +#define VERSIONFLOAT 0.694 /* Update the .rc file as well... */ Modified: dcplusplus/trunk/windows/DirectoryListingFrm.cpp =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-07-10 08:40:05 UTC (rev 635) +++ dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-07-10 20:34:17 UTC (rev 636) @@ -334,8 +334,12 @@ if(!d->getComplete()) { if(dl->getUser()->isOnline()) { - QueueManager::getInstance()->addPfs(dl->getUser(), dl->getPath(d)); - ctrlStatus.SetText(STATUS_TEXT, CTSTRING(DOWNLOADING_LIST)); + try { + QueueManager::getInstance()->addPfs(dl->getUser(), dl->getPath(d)); + ctrlStatus.SetText(STATUS_TEXT, CTSTRING(DOWNLOADING_LIST)); + } catch(const QueueException& e) { + ctrlStatus.SetText(STATUS_TEXT, Text::toT(e.getError()).c_str()); + } } else { ctrlStatus.SetText(STATUS_TEXT, CTSTRING(USER_OFFLINE)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-12 10:19:44
|
Revision: 638 Author: arnetheduck Date: 2006-07-12 03:19:01 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=638&view=rev Log Message: ----------- PM fixes, autodisconnect fixes Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/UploadManager.h dcplusplus/trunk/client/User.h dcplusplus/trunk/help/changelog.html dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h dcplusplus/trunk/windows/WindowsPage.cpp Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/Example.xml 2006-07-12 10:19:01 UTC (rev 638) @@ -438,7 +438,8 @@ <String Name="SettingsGeneral">Personal information</String> <String Name="SettingsGetUserCountry">Guess user country from IP</String> <String Name="SettingsHubUserCommands">Accept custom user commands from hub</String> - <String Name="SettingsIgnoreOffline">Ignore private messages from offline users</String> + <String Name="SettingsIgnoreHubPms">Ignore private messages from the hub</String> + <String Name="SettingsIgnoreBotPms">Ignore private messages from bots</String> <String Name="SettingsIncoming">Incoming connection settings (see Help/FAQ if unsure)</String> <String Name="SettingsKeepLists">Don't delete file lists when exiting</String> <String Name="SettingsLanguageFile">Language file</String> @@ -475,7 +476,8 @@ <String Name="SettingsPmHistory">PM history</String> <String Name="SettingsPopunderFilelist">Open new file list windows in the background</String> <String Name="SettingsPopunderPm">Open new private message windows in the background</String> - <String Name="SettingsPopupOffline">Open private messages from offline users in their own window</String> + <String Name="SettingsPopupBotPms">Open private messages from the hub in their own window</String> + <String Name="SettingsPopupHubPms">Open private messages from bots in their own window</String> <String Name="SettingsPopupPms">Open private messages in their own window</String> <String Name="SettingsPorts">Ports</String> <String Name="SettingsPromptPassword">Popup box to input password for hubs</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/changelog.txt 2006-07-12 10:19:01 UTC (rev 638) @@ -1,4 +1,10 @@ --- 0.694 2006-07-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 +* [bug 224] Slots are no longer granted to disconnected users, instead disconnection is delayed a minute + +-- 0.694 2006-07-10 -- * Fixed crash in certificates page * [bug 1005] Fixed linux compile issue (thanks tpo) * [bug 1004] Fixed browse file list on self Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-07-12 10:19:01 UTC (rev 638) @@ -206,7 +206,13 @@ if(ou) { fire(ClientListener::Message(), this, *ou, unescape(line.substr(i+1))); } else { - fire(ClientListener::StatusMessage(), this, unescape(line)); + OnlineUser& o = getUser(nick); + // Assume that messages from unknown users come from the hub + o.getIdentity().setHub(true); + o.getIdentity().setHidden(true); + fire(ClientListener::UserUpdated(), this, o); + + fire(ClientListener::Message(), this, o, unescape(line.substr(i+1))); } return; } @@ -354,10 +360,14 @@ if(connection.empty()) { // No connection = bot... u.getUser()->setFlag(User::BOT); + u.getIdentity().setHub(false); } else { u.getUser()->unsetFlag(User::BOT); + u.getIdentity().setBot(false); } + u.getIdentity().setHub(false); + u.getIdentity().setConnection(connection); i = j + 1; j = param.find('$', i); @@ -663,16 +673,33 @@ if(fromNick.empty()) return; - OnlineUser* replyTo = findUser(rtNick); + OnlineUser* replyTo = findUser(rtNick); OnlineUser* from = findUser(fromNick); - OnlineUser* to = findUser(getMyNick()); + OnlineUser& to = getUser(getMyNick()); - if(replyTo == NULL || from == NULL || to == NULL) { - fire(ClientListener::StatusMessage(), this, unescape(param.substr(i))); - } else { - string msg = param.substr(j + 2); - fire(ClientListener::PrivateMessage(), this, *from, *to, *replyTo, unescape(param.substr(j + 2))); - } + string msg = param.substr(j + 2); + if(replyTo == NULL || from == NULL) { + if(replyTo == 0) { + // Assume it's from the hub + replyTo = &getUser(rtNick); + replyTo->getIdentity().setHub(true); + replyTo->getIdentity().setHidden(true); + fire(ClientListener::UserUpdated(), this, *replyTo); + } + if(from == 0) { + // Assume it's from the hub + from = &getUser(rtNick); + from->getIdentity().setHub(true); + from->getIdentity().setHidden(true); + fire(ClientListener::UserUpdated(), this, *from); + } + + // Update pointers just in case they've been invalidated + replyTo = findUser(rtNick); + from = findUser(fromNick); + + } + fire(ClientListener::PrivateMessage(), this, *from, to, *replyTo, unescape(msg)); } else if(cmd == "$GetPass") { OnlineUser& ou = getUser(getMyNick()); ou.getIdentity().set("RG", "1"); Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-07-12 10:19:01 UTC (rev 638) @@ -49,7 +49,7 @@ // Ints "IncomingConnections", "InPort", "Slots", "Rollback", "AutoFollow", "ClearSearch", "BackgroundColor", "TextColor", "UseOemMonoFont", "ShareHidden", "FilterMessages", "MinimizeToTray", - "AutoSearch", "TimeStamps", "ConfirmExit", "IgnoreOffline", "PopupOffline", + "AutoSearch", "TimeStamps", "ConfirmExit", "PopupHubPms", "PopupBotPms", "IgnoreHubPms", "IgnoreBotPms", "ListDuplicates", "BufferSize", "DownloadSlots", "MaxDownloadSpeed", "LogMainChat", "LogPrivateChat", "LogDownloads", "LogUploads", "StatusInChat", "ShowJoins", "PrivateMessageBeep", "PrivateMessageBeepOpen", "UseSystemIcons", "PopupPMs", "MinUploadSpeed", "GetUserInfo", "UrlHandler", "MainWindowState", @@ -128,8 +128,10 @@ setDefault(AUTO_SEARCH, false); setDefault(TIME_STAMPS, false); setDefault(CONFIRM_EXIT, true); - setDefault(IGNORE_OFFLINE, false); - setDefault(POPUP_OFFLINE, false); + setDefault(POPUP_HUB_PMS, true); + setDefault(POPUP_BOT_PMS, true); + setDefault(IGNORE_HUB_PMS, false); + setDefault(IGNORE_BOT_PMS, false); setDefault(LIST_DUPES, true); setDefault(BUFFER_SIZE, 64); setDefault(HUBLIST_SERVERS, "http://www.hublist.org/PublicHubList.xml.bz2;http://dc.selwerd.nl/hublist.xml.bz2"); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/SettingsManager.h 2006-07-12 10:19:01 UTC (rev 638) @@ -65,7 +65,7 @@ enum IntSetting { INT_FIRST = STR_LAST + 1, INCOMING_CONNECTIONS = INT_FIRST, TCP_PORT, SLOTS, ROLLBACK, AUTO_FOLLOW, CLEAR_SEARCH, BACKGROUND_COLOR, TEXT_COLOR, USE_OEM_MONOFONT, SHARE_HIDDEN, FILTER_MESSAGES, MINIMIZE_TRAY, - AUTO_SEARCH, TIME_STAMPS, CONFIRM_EXIT, IGNORE_OFFLINE, POPUP_OFFLINE, + AUTO_SEARCH, TIME_STAMPS, CONFIRM_EXIT, POPUP_HUB_PMS, POPUP_BOT_PMS, IGNORE_HUB_PMS, IGNORE_BOT_PMS, LIST_DUPES, BUFFER_SIZE, DOWNLOAD_SLOTS, MAX_DOWNLOAD_SPEED, LOG_MAIN_CHAT, LOG_PRIVATE_CHAT, LOG_DOWNLOADS, LOG_UPLOADS, STATUS_IN_CHAT, SHOW_JOINS, PRIVATE_MESSAGE_BEEP, PRIVATE_MESSAGE_BEEP_OPEN, USE_SYSTEM_ICONS, POPUP_PMS, MIN_UPLOAD_SPEED, GET_USER_INFO, URL_HANDLER, MAIN_WINDOW_STATE, Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-07-12 10:19:01 UTC (rev 638) @@ -439,7 +439,8 @@ "Personal information", "Guess user country from IP", "Accept custom user commands from hub", -"Ignore private messages from offline users", +"Ignore private messages from the hub", +"Ignore private messages from bots", "Incoming connection settings (see Help/FAQ if unsure)", "Don't delete file lists when exiting", "Language file", @@ -476,7 +477,8 @@ "PM history", "Open new file list windows in the background", "Open new private message windows in the background", -"Open private messages from offline users in their own window", +"Open private messages from the hub in their own window", +"Open private messages from bots in their own window", "Open private messages in their own window", "Ports", "Popup box to input password for hubs", @@ -1061,7 +1063,8 @@ "SettingsGeneral", "SettingsGetUserCountry", "SettingsHubUserCommands", -"SettingsIgnoreOffline", +"SettingsIgnoreHubPms", +"SettingsIgnoreBotPms", "SettingsIncoming", "SettingsKeepLists", "SettingsLanguageFile", @@ -1098,7 +1101,8 @@ "SettingsPmHistory", "SettingsPopunderFilelist", "SettingsPopunderPm", -"SettingsPopupOffline", +"SettingsPopupBotPms", +"SettingsPopupHubPms", "SettingsPopupPms", "SettingsPorts", "SettingsPromptPassword", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/StringDefs.h 2006-07-12 10:19:01 UTC (rev 638) @@ -442,7 +442,8 @@ SETTINGS_GENERAL, // "Personal information" SETTINGS_GET_USER_COUNTRY, // "Guess user country from IP" SETTINGS_HUB_USER_COMMANDS, // "Accept custom user commands from hub" - SETTINGS_IGNORE_OFFLINE, // "Ignore private messages from offline users" + SETTINGS_IGNORE_HUB_PMS, // "Ignore private messages from the hub" + SETTINGS_IGNORE_BOT_PMS, // "Ignore private messages from bots" SETTINGS_INCOMING, // "Incoming connection settings (see Help/FAQ if unsure)" SETTINGS_KEEP_LISTS, // "Don't delete file lists when exiting" SETTINGS_LANGUAGE_FILE, // "Language file" @@ -479,7 +480,8 @@ SETTINGS_PM_HISTORY, // "PM history" SETTINGS_POPUNDER_FILELIST, // "Open new file list windows in the background" SETTINGS_POPUNDER_PM, // "Open new private message windows in the background" - SETTINGS_POPUP_OFFLINE, // "Open private messages from offline users in their own window" + SETTINGS_POPUP_BOT_PMS, // "Open private messages from the hub in their own window" + SETTINGS_POPUP_HUB_PMS, // "Open private messages from bots in their own window" SETTINGS_POPUP_PMS, // "Open private messages in their own window" SETTINGS_PORTS, // "Ports" SETTINGS_PROMPT_PASSWORD, // "Popup box to input password for hubs" Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-07-12 10:19:01 UTC (rev 638) @@ -406,6 +406,28 @@ } waitingUsers.erase(i, waitingUsers.end()); + + if( BOOLSETTING(AUTO_KICK) ) { + for(Upload::Iter i = uploads.begin(); i != uploads.end(); ++i) { + Upload* u = *i; + if(u->getUser()->isOnline()) { + u->unsetFlag(Upload::FLAG_PENDING_KICK); + continue; + } + + if(u->isSet(Upload::FLAG_PENDING_KICK)) { + u->getUserConnection()->disconnect(true); + LogManager::getInstance()->message(STRING(DISCONNECTED_USER) + Util::toString(ClientManager::getInstance()->getNicks(u->getUser()->getCID()))); + } + + if(BOOLSETTING(AUTO_KICK_NO_FAVS) && FavoriteManager::getInstance()->isFavoriteUser(u->getUser())) { + continue; + } + + u->setFlag(Upload::FLAG_PENDING_KICK); + } + } + } void UploadManager::on(GetListLength, UserConnection* conn) throw() { @@ -490,25 +512,6 @@ } void UploadManager::on(ClientManagerListener::UserDisconnected, const User::Ptr& aUser) throw() { - - /// @todo Don't kick when /me disconnects - if( BOOLSETTING(AUTO_KICK) && !(BOOLSETTING(AUTO_KICK_NO_FAVS) && FavoriteManager::getInstance()->isFavoriteUser(aUser)) ) { - - Lock l(cs); - for(Upload::Iter i = uploads.begin(); i != uploads.end(); ++i) { - Upload* u = *i; - if(u->getUser() == aUser) { - // Oops...adios... - u->getUserConnection()->disconnect(true); - // But let's grant him/her a free slot just in case... - if (!u->getUserConnection()->isSet(UserConnection::FLAG_HASEXTRASLOT)) - reserveSlot(aUser); - LogManager::getInstance()->message(STRING(DISCONNECTED_USER) + Util::toString(ClientManager::getInstance()->getNicks(aUser->getCID()))); - } - } - } - - //Remove references to them. if(!aUser->isOnline()) { clearUserFiles(aUser); } Modified: dcplusplus/trunk/client/UploadManager.h =================================================================== --- dcplusplus/trunk/client/UploadManager.h 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/UploadManager.h 2006-07-12 10:19:01 UTC (rev 638) @@ -37,7 +37,8 @@ FLAG_USER_LIST = 0x01, FLAG_TTH_LEAVES = 0x02, FLAG_ZUPLOAD = 0x04, - FLAG_PARTIAL_LIST = 0x08 + FLAG_PARTIAL_LIST = 0x08, + FLAG_PENDING_KICK = 0x10 }; typedef Upload* Ptr; @@ -175,8 +176,8 @@ virtual void on(ClientManagerListener::UserDisconnected, const User::Ptr& aUser) 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(Second, u_int32_t aTick) throw(); + virtual void on(Minute, u_int32_t aTick) throw(); // UserConnectionListener virtual void on(BytesSent, UserConnection*, size_t, size_t) throw(); Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/client/User.h 2006-07-12 10:19:01 UTC (rev 638) @@ -38,7 +38,6 @@ PASSIVE_BIT, NMDC_BIT, BOT_BIT, - HUB_BIT, TTH_GET_BIT, SAVE_NICK_BIT, TLS_BIT @@ -51,7 +50,6 @@ PASSIVE = 1<<PASSIVE_BIT, NMDC = 1<<NMDC_BIT, BOT = 1<<BOT_BIT, - HUB = 1<<HUB_BIT, TTH_GET = 1<<TTH_GET_BIT, //< User supports getting files by tth -> don't have path in queue... SAVE_NICK = 1<<SAVE_NICK_BIT, //< Save cid->nick association TLS = 1<<TLS_BIT //< Client supports SSL @@ -114,6 +112,9 @@ int64_t getBytesShared() const { return Util::toInt64(get("SS")); } void setOp(bool op) { set("OP", op ? "1" : Util::emptyString); } + void setHub(bool hub) { set("HU", hub ? "1" : Util::emptyString); } + void setBot(bool bot) { set("BO", bot ? "1" : Util::emptyString); } + void setHidden(bool hidden) { set("HI", hidden ? "1" : Util::emptyString); } string getTag() const { if(!get("TA").empty()) Modified: dcplusplus/trunk/help/changelog.html =================================================================== --- dcplusplus/trunk/help/changelog.html 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/help/changelog.html 2006-07-12 10:19:01 UTC (rev 638) @@ -13,6 +13,14 @@ <h1>DC++ Changelog</h1> See the version history of DC++ below. +<h2>0.694 <span style="color: gray;">(2006-07-10)</span></h2> +<ul> + <li>Fixed crash in certificates page</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1005">[bug 1005]</a> Fixed linux compile issue (thanks tpo)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1004">[bug 1004]</a> Fixed browse file list on self</li> + <li>Both .crt and .pem files are read as trusted certificates</li> +</ul> + <h2>0.693 <span style="color: gray;">(2006-07-09)</span></h2> <ul> <li>Fixed crash bug</li> Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-07-12 10:19:01 UTC (rev 638) @@ -539,20 +539,28 @@ } } else if(task->speaker == PRIVATE_MESSAGE) { PMTask& pm = *static_cast<PMTask*>(task); - if(pm.replyTo->isOnline()) { - if(BOOLSETTING(POPUP_PMS) || PrivateFrame::isOpen(pm.replyTo)) { + if(pm.hub) { + if(BOOLSETTING(IGNORE_HUB_PMS)) { + addClientLine(TSTRING(IGNORED_MESSAGE) + pm.msg, false); + } else if(BOOLSETTING(POPUP_HUB_PMS) || PrivateFrame::isOpen(pm.replyTo)) { PrivateFrame::gotMessage(pm.from, pm.to, pm.replyTo, pm.msg); } else { addLine(TSTRING(PRIVATE_MESSAGE_FROM) + getNick(pm.from) + _T(": ") + pm.msg); } - } else { - if(BOOLSETTING(IGNORE_OFFLINE)) { + } else if(pm.bot) { + if(BOOLSETTING(IGNORE_BOT_PMS)) { addClientLine(TSTRING(IGNORED_MESSAGE) + pm.msg, false); - } else if(BOOLSETTING(POPUP_OFFLINE)) { + } else if(BOOLSETTING(POPUP_BOT_PMS) || PrivateFrame::isOpen(pm.replyTo)) { PrivateFrame::gotMessage(pm.from, pm.to, pm.replyTo, pm.msg); } else { addLine(TSTRING(PRIVATE_MESSAGE_FROM) + getNick(pm.from) + _T(": ") + pm.msg); } + } else { + if(BOOLSETTING(POPUP_PMS) || PrivateFrame::isOpen(pm.replyTo)) { + PrivateFrame::gotMessage(pm.from, pm.to, pm.replyTo, pm.msg); + } else { + addLine(TSTRING(PRIVATE_MESSAGE_FROM) + getNick(pm.from) + _T(": ") + pm.msg); + } } } Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/windows/HubFrame.h 2006-07-12 10:19:01 UTC (rev 638) @@ -209,10 +209,15 @@ }; struct PMTask : public StringTask { - PMTask(const User::Ptr& from_, const User::Ptr& to_, const User::Ptr& replyTo_, const tstring& m) : StringTask(PRIVATE_MESSAGE, m), from(from_), to(to_), replyTo(replyTo_) { } + PMTask(const OnlineUser& from_, const OnlineUser& to_, const OnlineUser& replyTo_, const tstring& m) : StringTask(PRIVATE_MESSAGE, m), + from(from_.getUser()), to(to_.getUser()), replyTo(replyTo_.getUser()), hub(replyTo_.getIdentity().isHub()), bot(replyTo_.getIdentity().isBot()) { } + User::Ptr from; User::Ptr to; User::Ptr replyTo; + + bool hub; + bool bot; }; friend struct CompareItems; Modified: dcplusplus/trunk/windows/WindowsPage.cpp =================================================================== --- dcplusplus/trunk/windows/WindowsPage.cpp 2006-07-10 20:44:32 UTC (rev 637) +++ dcplusplus/trunk/windows/WindowsPage.cpp 2006-07-12 10:19:01 UTC (rev 638) @@ -52,11 +52,13 @@ WindowsPage::ListItem WindowsPage::optionItems[] = { { SettingsManager::POPUP_PMS, ResourceManager::SETTINGS_POPUP_PMS }, - { SettingsManager::POPUP_OFFLINE, ResourceManager::SETTINGS_POPUP_OFFLINE }, + { SettingsManager::POPUP_HUB_PMS, ResourceManager::SETTINGS_POPUP_HUB_PMS }, + { SettingsManager::POPUP_BOT_PMS, ResourceManager::SETTINGS_POPUP_BOT_PMS }, { SettingsManager::POPUNDER_FILELIST, ResourceManager::SETTINGS_POPUNDER_FILELIST }, { SettingsManager::POPUNDER_PM, ResourceManager::SETTINGS_POPUNDER_PM }, { SettingsManager::JOIN_OPEN_NEW_WINDOW, ResourceManager::SETTINGS_OPEN_NEW_WINDOW }, - { SettingsManager::IGNORE_OFFLINE, ResourceManager::SETTINGS_IGNORE_OFFLINE }, + { SettingsManager::IGNORE_HUB_PMS, ResourceManager::SETTINGS_IGNORE_HUB_PMS }, + { SettingsManager::IGNORE_BOT_PMS, ResourceManager::SETTINGS_IGNORE_BOT_PMS }, { SettingsManager::TOGGLE_ACTIVE_WINDOW, ResourceManager::SETTINGS_TOGGLE_ACTIVE_WINDOW }, { SettingsManager::PROMPT_PASSWORD, ResourceManager::SETTINGS_PROMPT_PASSWORD }, { 0, ResourceManager::SETTINGS_AUTO_AWAY } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-12 11:34:41
|
Revision: 639 Author: arnetheduck Date: 2006-07-12 04:34:22 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=639&view=rev Log Message: ----------- space fix Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/NmdcHub.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-12 10:19:01 UTC (rev 638) +++ dcplusplus/trunk/changelog.txt 2006-07-12 11:34:22 UTC (rev 639) @@ -3,6 +3,7 @@ without connection type * [bug 125] Fixed out-of-order PM/quit * [bug 224] Slots are no longer granted to disconnected users, instead disconnection is delayed a minute +* [NMDC] Fixed extra space in chat -- 0.694 2006-07-10 -- * Fixed crash in certificates page Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-07-12 10:19:01 UTC (rev 638) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-07-12 11:34:22 UTC (rev 639) @@ -202,9 +202,11 @@ return; } string nick = line.substr(1, i-1); + string message = line.substr(i+2); + OnlineUser* ou = findUser(nick); if(ou) { - fire(ClientListener::Message(), this, *ou, unescape(line.substr(i+1))); + fire(ClientListener::Message(), this, *ou, unescape(message)); } else { OnlineUser& o = getUser(nick); // Assume that messages from unknown users come from the hub @@ -212,7 +214,7 @@ o.getIdentity().setHidden(true); fire(ClientListener::UserUpdated(), this, o); - fire(ClientListener::Message(), this, o, unescape(line.substr(i+1))); + fire(ClientListener::Message(), this, o, unescape(message)); } return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-12 20:13:19
|
Revision: 640 Author: arnetheduck Date: 2006-07-12 13:12:22 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=640&view=rev Log Message: ----------- badpassword, move file Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/changelog.txt 2006-07-12 20:12:22 UTC (rev 640) @@ -4,6 +4,8 @@ * [bug 125] Fixed out-of-order PM/quit * [bug 224] Slots are no longer granted to disconnected users, instead disconnection is delayed a minute * [NMDC] Fixed extra space in chat +* [bug 395] Fixed password being blanked +* [bug 419] Allowed changing case only when moving file in queue -- 0.694 2006-07-10 -- * Fixed crash in certificates page Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-07-12 20:12:22 UTC (rev 640) @@ -343,6 +343,12 @@ if(!u) return; + int severity = Util::toInt(c.getParam(0).substr(0, 1)); + int code = Util::toInt(c.getParam(0).substr(1)); + + if(code == AdcCommand::ERROR_BAD_PASSWORD) { + setPassword(Util::emptyString); + } // @todo Check for invalid protocol and unset TLS if necessary fire(ClientListener::Message(), this, *u, c.getParam(1)); } Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/client/Client.cpp 2006-07-12 20:12:22 UTC (rev 640) @@ -73,7 +73,8 @@ } else { setCurrentDescription(SETTING(DESCRIPTION)); } - setPassword(hub->getPassword()); + if(!hub->getPassword().empty()) + setPassword(hub->getPassword()); } else { if(updateNick) { setCurrentNick(checkNick(SETTING(NICK))); Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/client/Client.h 2006-07-12 20:12:22 UTC (rev 640) @@ -38,7 +38,6 @@ typedef X<0> Connecting; typedef X<1> Connected; - typedef X<2> BadPassword; typedef X<3> UserUpdated; typedef X<4> UsersUpdated; typedef X<5> UserRemoved; @@ -58,7 +57,6 @@ virtual void on(Connecting, Client*) throw() { } virtual void on(Connected, Client*) throw() { } - virtual void on(BadPassword, Client*) throw() { } virtual void on(UserUpdated, Client*, const OnlineUser&) throw() { } virtual void on(UsersUpdated, Client*, const OnlineUser::List&) throw() { } virtual void on(UserRemoved, Client*, const OnlineUser&) throw() { } Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-07-12 20:12:22 UTC (rev 640) @@ -708,7 +708,7 @@ setMyIdentity(ou.getIdentity()); fire(ClientListener::GetPassword(), this); } else if(cmd == "$BadPass") { - fire(ClientListener::BadPassword(), this); + setPassword(Util::emptyString); } else if(cmd == "$ZOn") { socket->setMode(BufferedSocket::MODE_ZPIPE); } else { Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-07-12 20:12:22 UTC (rev 640) @@ -699,7 +699,7 @@ void QueueManager::move(const string& aSource, const string& aTarget) throw() { string target = Util::validateFileName(aTarget); - if(Util::stricmp(aSource, target) == 0) + if(aSource == target) return; bool delSource = false; @@ -717,7 +717,7 @@ // Let's see if the target exists...then things get complicated... QueueItem* qt = fileQueue.find(target); - if(qt == NULL) { + if(qt == NULL || Util::stricmp(aSource, target) == 0) { // Good, update the target and move in the queue... fileQueue.move(qs, target); fire(QueueManagerListener::Moved(), qs); Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-07-12 20:12:22 UTC (rev 640) @@ -1221,9 +1221,6 @@ void HubFrame::on(Connected, Client*) throw() { speak(CONNECTED); } -void HubFrame::on(BadPassword, Client*) throw() { - client->setPassword(Util::emptyString); -} void HubFrame::on(UserUpdated, Client*, const OnlineUser& user) throw() { speak(UPDATE_USER_JOIN, user); } Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-07-12 11:34:22 UTC (rev 639) +++ dcplusplus/trunk/windows/HubFrame.h 2006-07-12 20:12:22 UTC (rev 640) @@ -391,7 +391,6 @@ // ClientListener virtual void on(Connecting, Client*) throw(); virtual void on(Connected, Client*) throw(); - virtual void on(BadPassword, Client*) throw(); virtual void on(UserUpdated, Client*, const OnlineUser&) throw(); virtual void on(UsersUpdated, Client*, const OnlineUser::List&) throw(); virtual void on(UserRemoved, Client*, const OnlineUser&) throw(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-07-23 09:31:48
|
Revision: 641 Author: arnetheduck Date: 2006-07-23 02:31:25 -0700 (Sun, 23 Jul 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=641&view=rev Log Message: ----------- Bug fixes Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/windows/QueueFrame.cpp dcplusplus/trunk/windows/WinUtil.h Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/Example.xml 2006-07-23 09:31:25 UTC (rev 641) @@ -203,6 +203,7 @@ <String Name="LastHub">Hub (last seen on if offline)</String> <String Name="LastSeen">Time last seen</String> <String Name="Left">left</String> + <String Name="ListenerFailed">Listening socket failed (you need to restart DC++): </String> <String Name="Loading">Loading DC++, please wait...</String> <String Name="LookupAtBitzi">Lookup TTH at Bitzi.com</String> <String Name="Low">Low</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/changelog.txt 2006-07-23 09:31:25 UTC (rev 641) @@ -6,6 +6,7 @@ * [NMDC] Fixed extra space in chat * [bug 395] Fixed password being blanked * [bug 419] Allowed changing case only when moving file in queue +* [bug 736] Fixed escaping of menu items -- 0.694 2006-07-10 -- * Fixed crash in certificates page Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -262,10 +262,14 @@ static const u_int32_t POLL_TIMEOUT = 250; int ConnectionManager::Server::run() throw() { - while(!die) { - if(sock.wait(POLL_TIMEOUT, Socket::WAIT_READ) == Socket::WAIT_READ) { - ConnectionManager::getInstance()->accept(sock, secure); + try { + while(!die) { + if(sock.wait(POLL_TIMEOUT, Socket::WAIT_CONNECT) == Socket::WAIT_CONNECT) { + ConnectionManager::getInstance()->accept(sock, secure); + } } + } catch(const Exception& e) { + LogManager::getInstance()->message(STRING(LISTENER_FAILED) + e.getError()); } return 0; } @@ -299,10 +303,6 @@ uc->setLastActivity(GET_TICK()); try { uc->accept(sock); - if(uc->isSecure() && !uc->isTrusted() && !BOOLSETTING(ALLOW_UNTRUSTED_CLIENTS)) { - putConnection(uc); - LogManager::getInstance()->message(STRING(CERTIFICATE_NOT_TRUSTED)); - } } catch(const Exception&) { putConnection(uc); delete uc; Modified: dcplusplus/trunk/client/HashManager.cpp =================================================================== --- dcplusplus/trunk/client/HashManager.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/HashManager.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -614,7 +614,7 @@ #ifdef _WIN32 TigerTree fastTTH(bs); tth = &fastTTH; - if(!virtualBuf || !fastHash(fname, buf, fastTTH, size, xcrc32)) { + if(!virtualBuf || !BOOLSETTING(FAST_HASH) || !fastHash(fname, buf, fastTTH, size, xcrc32)) { tth = &slowTTH; crc32 = CRC32Filter(); #endif Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -677,7 +677,6 @@ OnlineUser* replyTo = findUser(rtNick); OnlineUser* from = findUser(fromNick); - OnlineUser& to = getUser(getMyNick()); string msg = param.substr(j + 2); if(replyTo == NULL || from == NULL) { @@ -701,6 +700,7 @@ from = findUser(fromNick); } + OnlineUser& to = getUser(getMyNick()); fire(ClientListener::PrivateMessage(), this, *from, to, *replyTo, unescape(msg)); } else if(cmd == "$GetPass") { OnlineUser& ou = getUser(getMyNick()); Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -25,7 +25,6 @@ #include <openssl/ssl.h> - SSLSocket::SSLSocket(SSL_CTX* context) throw(SocketException) : ctx(context), ssl(0) { } Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -75,7 +75,7 @@ "OpenWaitingUsers", "BoldWaitingUsers", "OpenSystemLog", "BoldSystemLog", "AutoRefreshTime", "UseTLS", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", "DontDlAlreadyQueued", "MaxCommandLength", "AllowUntrustedHubs", "AllowUntrustedClients", - "TLSPort", + "TLSPort", "FastHash", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -269,6 +269,7 @@ setDefault(MAX_COMMAND_LENGTH, 16*1024*1024); setDefault(ALLOW_UNTRUSTED_HUBS, true); setDefault(ALLOW_UNTRUSTED_CLIENTS, true); + setDefault(FAST_HASH, true); #ifdef _WIN32 setDefault(MAIN_WINDOW_STATE, SW_SHOWNORMAL); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/SettingsManager.h 2006-07-23 09:31:25 UTC (rev 641) @@ -91,7 +91,7 @@ OPEN_WAITING_USERS, BOLD_WAITING_USERS, OPEN_SYSTEM_LOG, BOLD_SYSTEM_LOG, AUTO_REFRESH_TIME, USE_TLS, AUTO_SEARCH_LIMIT, ALT_SORT_ORDER, AUTO_KICK_NO_FAVS, PROMPT_PASSWORD, SPY_FRAME_IGNORE_TTH_SEARCHES, DONT_DL_ALREADY_QUEUED, MAX_COMMAND_LENGTH, ALLOW_UNTRUSTED_HUBS, ALLOW_UNTRUSTED_CLIENTS, - TLS_PORT, + TLS_PORT, FAST_HASH, INT_LAST }; enum Int64Setting { INT64_FIRST = INT_LAST + 1, Modified: dcplusplus/trunk/client/Socket.cpp =================================================================== --- dcplusplus/trunk/client/Socket.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/Socket.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -437,14 +437,18 @@ if(waitFor & WAIT_CONNECT) { dcassert(!(waitFor & WAIT_READ) && !(waitFor & WAIT_WRITE)); - FD_ZERO(&wfd); + FD_ZERO(&rfd); FD_ZERO(&efd); - FD_SET(sock, &wfd); + FD_SET(sock, &rfd); FD_SET(sock, &efd); - check(select((int)(sock+1), NULL, &wfd, &efd, &tv)); + check(select((int)(sock+1), &rfd, 0, &efd, &tv)); - if(FD_ISSET(sock, &wfd) || FD_ISSET(sock, &efd)) { + if(FD_ISSET(sock, &rfd)) { + return WAIT_CONNECT; + } + + if(FD_ISSET(sock, &efd)) { int y = 0; socklen_t z = sizeof(y); check(getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*)&y, &z)); Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -204,6 +204,7 @@ "Hub (last seen on if offline)", "Time last seen", "left", +"Listening socket failed (you need to restart DC++): ", "Loading DC++, please wait...", "Lookup TTH at Bitzi.com", "Low", @@ -828,6 +829,7 @@ "LastHub", "LastSeen", "Left", +"ListenerFailed", "Loading", "LookupAtBitzi", "Low", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/client/StringDefs.h 2006-07-23 09:31:25 UTC (rev 641) @@ -207,6 +207,7 @@ LAST_HUB, // "Hub (last seen on if offline)" LAST_SEEN, // "Time last seen" LEFT, // "left" + LISTENER_FAILED, // "Listening socket failed (you need to restart DC++): " LOADING, // "Loading DC++, please wait..." LOOKUP_AT_BITZI, // "Lookup TTH at Bitzi.com" LOW, // "Low" Modified: dcplusplus/trunk/windows/QueueFrame.cpp =================================================================== --- dcplusplus/trunk/windows/QueueFrame.cpp 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/windows/QueueFrame.cpp 2006-07-23 09:31:25 UTC (rev 641) @@ -775,7 +775,7 @@ int pmItems = 0; QueueItemInfo::SourceIter i; for(i = ii->getSources().begin(); i != ii->getSources().end(); ++i) { - tstring nick = WinUtil::getNicks(i->getUser()); + tstring nick = WinUtil::escapeMenu(WinUtil::getNicks(i->getUser())); mi.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; mi.fType = MFT_STRING; mi.dwTypeData = (LPTSTR)nick.c_str(); Modified: dcplusplus/trunk/windows/WinUtil.h =================================================================== --- dcplusplus/trunk/windows/WinUtil.h 2006-07-12 20:12:22 UTC (rev 640) +++ dcplusplus/trunk/windows/WinUtil.h 2006-07-23 09:31:25 UTC (rev 641) @@ -341,6 +341,14 @@ static bool isAlt() { return (GetKeyState(VK_MENU) & 0x8000) > 0; } static bool isCtrl() { return (GetKeyState(VK_CONTROL) & 0x8000) > 0; } + static tstring escapeMenu(tstring str) { + string::size_type i = 0; + while( (i = str.find(_T('&'), i)) != string::npos) { + str.insert(str.begin()+i, 1, _T('&')); + i += 2; + } + return str; + } template<class T> static HWND hiddenCreateEx(T& p) throw() { HWND active = (HWND)::SendMessage(mdiClient, WM_MDIGETACTIVE, 0, 0); ::LockWindowUpdate(mdiClient); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-08-31 07:46:44
|
Revision: 643 http://svn.sourceforge.net/dcplusplus/?rev=643&view=rev Author: arnetheduck Date: 2006-08-31 00:46:12 -0700 (Thu, 31 Aug 2006) Log Message: ----------- Patches Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcCommand.h dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/DCPlusPlus.h dcplusplus/trunk/client/DirectoryListing.cpp dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/FilteredFile.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/windows/AboutDlg.h dcplusplus/trunk/windows/FlatTabCtrl.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/changelog.txt 2006-08-31 07:46:12 UTC (rev 643) @@ -7,6 +7,14 @@ * [bug 395] Fixed password being blanked * [bug 419] Allowed changing case only when moving file in queue * [bug 736] Fixed escaping of menu items +* [bug 1013] Fixed gcc warnings (thanks steven sheehy) +* [bug 1023] Fixed some large stack allocations (thanks steven sheehy) +* [bug 1026] Fixed some potential buffer overflows (thanks steven sheehy) +* [bug 1027] Improved unix socket support (thanks steven sheehy) +* [bug 1028] Improved big endian support (thanks steven sheehy) +* [bug 1029] Fixed BSD compile issue (thanks steven sheehy) +* [bug 1031] Fixed a crash after closing hub window (thanks bigmuscle/pothead) +* [bug 1032] Fixed certificates help (thanks pothead) -- 0.694 2006-07-10 -- * Fixed crash in certificates page Modified: dcplusplus/trunk/client/AdcCommand.h =================================================================== --- dcplusplus/trunk/client/AdcCommand.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/AdcCommand.h 2006-08-31 07:46:12 UTC (rev 643) @@ -79,7 +79,11 @@ static const char TYPE_HUB = 'H'; static const char TYPE_UDP = 'U'; +#if defined(_WIN32) || defined(__i386__) || defined(__x86_64__) || defined(__alpha) #define C(n, a, b, c) static const u_int32_t CMD_##n = (((u_int32_t)a) | (((u_int32_t)b)<<8) | (((u_int32_t)c)<<16)); typedef Type<CMD_##n> n +#else +#define C(n, a, b, c) static const u_int32_t CMD_##n = ((((u_int32_t)a)<<24) | (((u_int32_t)b)<<16) | (((u_int32_t)c)<<8)); typedef Type<CMD_##n> n +#endif // Base commands C(SUP, 'S','U','P'); C(STA, 'S','T','A'); Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -33,8 +33,8 @@ #define POLL_TIMEOUT 250 BufferedSocket::BufferedSocket(char aSeparator) throw() : -separator(aSeparator), mode(MODE_LINE), -dataBytes(0), rollback(0), failed(false), sock(0), disconnecting(false), filterIn(NULL) +separator(aSeparator), mode(MODE_LINE), filterIn(NULL), +dataBytes(0), rollback(0), failed(false), sock(0), disconnecting(false) { Thread::safeInc(sockets); } @@ -69,6 +69,8 @@ case MODE_ZPIPE: filterIn = new UnZFilter; break; + case MODE_DATA: + break; } } @@ -423,6 +425,8 @@ break; case SHUTDOWN: return false; + case ACCEPTED: + break; } delete p.second; Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/Client.h 2006-08-31 07:46:12 UTC (rev 643) @@ -34,6 +34,7 @@ class ClientListener { public: + virtual ~ClientListener() { } template<int I> struct X { enum { TYPE = I }; }; typedef X<0> Connecting; @@ -114,7 +115,7 @@ static string getCounts() { char buf[128]; - return string(buf, sprintf(buf, "%ld/%ld/%ld", counts.normal, counts.registered, counts.op)); + return string(buf, snprintf(buf, sizeof(buf), "%ld/%ld/%ld", counts.normal, counts.registered, counts.op)); } StringMap& escapeParams(StringMap& sm) { Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -62,7 +62,7 @@ { Lock l(cs); - clients.erase(remove(clients.begin(), clients.end(), aClient), clients.end()); + clients.remove(aClient); } delete aClient; } Modified: dcplusplus/trunk/client/DCPlusPlus.h =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/DCPlusPlus.h 2006-08-31 07:46:12 UTC (rev 643) @@ -41,6 +41,10 @@ va_end(args); } +#ifdef _WIN32 +#define snprintf _snprintf +#endif + #define dcdebug debugTrace #ifdef _WIN32 #define dcassert(exp) \ Modified: dcplusplus/trunk/client/DirectoryListing.cpp =================================================================== --- dcplusplus/trunk/client/DirectoryListing.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/DirectoryListing.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -95,7 +95,7 @@ ::File ff(name, ::File::READ, ::File::OPEN); FilteredInputStream<UnBZFilter, false> f(&ff); const size_t BUF_SIZE = 64*1024; - char buf[BUF_SIZE]; + AutoArray<char> buf(BUF_SIZE); size_t len; size_t bytesRead = 0; for(;;) { @@ -110,7 +110,7 @@ } } else if(Util::stricmp(ext, ".xml") == 0) { int64_t sz = ::File::getSize(name); - if(sz == -1 || sz >= txt.max_size()) + if(sz == -1 || sz >= static_cast<int64_t>(txt.max_size())) throw(FileException(CSTRING(FILE_NOT_AVAILABLE))); txt.resize((size_t) sz); size_t n = txt.length(); Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -117,7 +117,7 @@ bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; bool onlineSourcesOk = (*i)->isSet(Download::FLAG_USER_LIST) ? true : QueueManager::getInstance()->countOnlineSources((*i)->getTarget()) >= SETTING(AUTODROP_MINSOURCES); - bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((size_t)SETTING(AUTODROP_FILESIZE)) * 1024; + bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((int64_t)SETTING(AUTODROP_FILESIZE)) * 1024; bool dropIt = ((*i)->isSet(Download::FLAG_USER_LIST) && BOOLSETTING(AUTODROP_FILELISTS)) || (filesizeOk && BOOLSETTING(AUTODROP_ALL)); if(speedTooLow && onlineSourcesOk && dropIt) { Modified: dcplusplus/trunk/client/FilteredFile.h =================================================================== --- dcplusplus/trunk/client/FilteredFile.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/FilteredFile.h 2006-08-31 07:46:12 UTC (rev 643) @@ -24,6 +24,7 @@ #endif // _MSC_VER > 1000 #include "Streams.h" +#include "Util.h" template<class Filter, bool managed> class CalcOutputStream : public OutputStream { @@ -72,7 +73,7 @@ public: using OutputStream::write; - FilteredOutputStream(OutputStream* aFile) : f(aFile), flushed(false) { } + FilteredOutputStream(OutputStream* aFile) : f(aFile), buf(BUF_SIZE), flushed(false) { } ~FilteredOutputStream() throw() { if(manage) delete f; } size_t flush() throw(Exception) { @@ -123,19 +124,19 @@ } private: - enum { BUF_SIZE = 64*1024 }; + static const size_t BUF_SIZE = 64*1024; OutputStream* f; Filter filter; - u_int8_t buf[BUF_SIZE]; + AutoArray<u_int8_t> buf; bool flushed; }; template<class Filter, bool managed> class FilteredInputStream : public InputStream { public: - FilteredInputStream(InputStream* aFile) : f(aFile), pos(0), valid(0), more(true) { } + FilteredInputStream(InputStream* aFile) : f(aFile), buf(BUF_SIZE), pos(0), valid(0), more(true) { } virtual ~FilteredInputStream() throw() { if(managed) delete f; } /** @@ -173,11 +174,11 @@ } private: - enum { BUF_SIZE = 64*1024 }; + static const size_t BUF_SIZE = 64*1024; InputStream* f; Filter filter; - u_int8_t buf[BUF_SIZE]; + AutoArray<u_int8_t> buf; size_t pos; size_t valid; bool more; Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -800,13 +800,16 @@ tmp[i] = '$'; } int chars = 0; + size_t BUF_SIZE; if(ClientManager::getInstance()->isActive()) { string x = ClientManager::getInstance()->getCachedIp(); - buf = new char[x.length() + aString.length() + 64]; - chars = sprintf(buf, "$Search %s:%d %c?%c?%s?%d?%s|", x.c_str(), (int)SearchManager::getInstance()->getPort(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); + BUF_SIZE = x.length() + aString.length() + 64; + buf = new char[BUF_SIZE]; + chars = snprintf(buf, BUF_SIZE, "$Search %s:%d %c?%c?%s?%d?%s|", x.c_str(), (int)SearchManager::getInstance()->getPort(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); } else { - buf = new char[getMyNick().length() + aString.length() + 64]; - chars = sprintf(buf, "$Search Hub:%s %c?%c?%s?%d?%s|", toAcp(getMyNick()).c_str(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); + BUF_SIZE = getMyNick().length() + aString.length() + 64; + buf = new char[BUF_SIZE]; + chars = snprintf(buf, BUF_SIZE, "$Search Hub:%s %c?%c?%s?%d?%s|", toAcp(getMyNick()).c_str(), c1, c2, Util::toString(aSize).c_str(), aFileType+1, tmp.c_str()); } send(buf, chars); } Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -939,8 +939,9 @@ } } if(flags & QueueItem::FLAG_MATCH_QUEUE) { - AutoArray<char> tmp(STRING(MATCHED_FILES).size() + 16); - sprintf(tmp, CSTRING(MATCHED_FILES), matchListing(dirList)); + const size_t BUF_SIZE = STRING(MATCHED_FILES).size() + 16; + AutoArray<char> tmp(BUF_SIZE); + snprintf(tmp, BUF_SIZE, CSTRING(MATCHED_FILES), matchListing(dirList)); LogManager::getInstance()->message(Util::toString(ClientManager::getInstance()->getNicks(user->getCID())) + ": " + string(tmp)); } } Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -339,7 +339,7 @@ ::File ff(Util::getConfigPath() + "files.xml.bz2", ::File::READ, ::File::OPEN); FilteredInputStream<UnBZFilter, false> f(&ff); const size_t BUF_SIZE = 64*1024; - char buf[BUF_SIZE]; + AutoArray<char> buf(BUF_SIZE); size_t len; for(;;) { size_t n = BUF_SIZE; Modified: dcplusplus/trunk/client/Socket.cpp =================================================================== --- dcplusplus/trunk/client/Socket.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/Socket.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -52,7 +52,7 @@ if(msg.empty()) { char tmp[64]; - sprintf(tmp, CSTRING(UNKNOWN_ERROR), aError); + snprintf(tmp, sizeof(tmp), CSTRING(UNKNOWN_ERROR), aError); msg = tmp; } return msg; Modified: dcplusplus/trunk/client/Socket.h =================================================================== --- dcplusplus/trunk/client/Socket.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/Socket.h 2006-08-31 07:46:12 UTC (rev 643) @@ -236,7 +236,7 @@ static int check(int ret, bool blockOk = false) { if(ret == -1) { int error = getLastError(); - if(blockOk && (error == EWOULDBLOCK || error == ENOBUFS || error == EINPROGRESS) ) { + if(blockOk && (error == EWOULDBLOCK || error == ENOBUFS || error == EINPROGRESS || error == EAGAIN) ) { return -1; } else { throw SocketException(error); Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/Util.cpp 2006-08-31 07:46:12 UTC (rev 643) @@ -338,17 +338,17 @@ string Util::formatBytes(int64_t aBytes) { char buf[64]; if(aBytes < 1024) { - sprintf(buf, "%d %s", (int)(aBytes&0xffffffff), CSTRING(B)); + snprintf(buf, sizeof(buf), "%d %s", (int)(aBytes&0xffffffff), CSTRING(B)); } else if(aBytes < 1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0), CSTRING(KiB)); + snprintf(buf, sizeof(buf), "%.02f %s", (double)aBytes/(1024.0), CSTRING(KiB)); } else if(aBytes < 1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0), CSTRING(MiB)); + snprintf(buf, sizeof(buf), "%.02f %s", (double)aBytes/(1024.0*1024.0), CSTRING(MiB)); } else if(aBytes < (int64_t)1024*1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0), CSTRING(GiB)); + snprintf(buf, sizeof(buf), "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0), CSTRING(GiB)); } else if(aBytes < (int64_t)1024*1024*1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0*1024.0), CSTRING(TiB)); + snprintf(buf, sizeof(buf), "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0*1024.0), CSTRING(TiB)); } else { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0*1024.0*1024.0), CSTRING(PIB)); + snprintf(buf, sizeof(buf), "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0*1024.0*1024.0), CSTRING(PIB)); } return buf; @@ -380,9 +380,8 @@ return Text::fromT(buf); #else char buf[64]; - sprintf(buf, "%'lld", aBytes); - sprintf(buf, "%s %s", buf, CSTRING(B)); - return buf; + snprintf(buf, sizeof(buf), "%'lld", aBytes); + return string(buf) + STRING(B); #endif } Modified: dcplusplus/trunk/client/Util.h =================================================================== --- dcplusplus/trunk/client/Util.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/Util.h 2006-08-31 07:46:12 UTC (rev 643) @@ -326,7 +326,7 @@ static string formatSeconds(int64_t aSec) { char buf[64]; - sprintf(buf, "%01lu:%02d:%02d", (unsigned long)(aSec / (60*60)), (int)((aSec / 60) % 60), (int)(aSec % 60)); + snprintf(buf, sizeof(buf), "%01lu:%02d:%02d", (unsigned long)(aSec / (60*60)), (int)((aSec / 60) % 60), (int)(aSec % 60)); return buf; } @@ -369,55 +369,55 @@ static string toString(short val) { char buf[8]; - sprintf(buf, "%d", (int)val); + snprintf(buf, sizeof(buf), "%d", (int)val); return buf; } static string toString(unsigned short val) { char buf[8]; - sprintf(buf, "%u", (unsigned int)val); + snprintf(buf, sizeof(buf), "%u", (unsigned int)val); return buf; } static string toString(int val) { char buf[16]; - sprintf(buf, "%d", val); + snprintf(buf, sizeof(buf), "%d", val); return buf; } static string toString(unsigned int val) { char buf[16]; - sprintf(buf, "%u", val); + snprintf(buf, sizeof(buf), "%u", val); return buf; } static string toString(long val) { char buf[32]; - sprintf(buf, "%ld", val); + snprintf(buf, sizeof(buf), "%ld", val); return buf; } static string toString(unsigned long val) { char buf[32]; - sprintf(buf, "%lu", val); + snprintf(buf, sizeof(buf), "%lu", val); return buf; } static string toString(long long val) { char buf[32]; #ifdef _MSC_VER - sprintf(buf, "%I64d", val); + snprintf(buf, sizeof(buf), "%I64d", val); #else - sprintf(buf, "%lld", val); + snprintf(buf, sizeof(buf), "%lld", val); #endif return buf; } static string toString(unsigned long long val) { char buf[32]; #ifdef _MSC_VER - sprintf(buf, "%I64u", val); + snprintf(buf, sizeof(buf), "%I64u", val); #else - sprintf(buf, "%llu", val); + snprintf(buf, sizeof(buf), "%llu", val); #endif return buf; } static string toString(double val) { char buf[16]; - sprintf(buf, "%0.2f", val); + snprintf(buf, sizeof(buf), "%0.2f", val); return buf; } @@ -437,7 +437,7 @@ static string toHexEscape(char val) { char buf[sizeof(int)*2+1+1]; - sprintf(buf, "%%%X", val&0x0FF); + snprintf(buf, sizeof(buf), "%%%X", val&0x0FF); return buf; } static char fromHexEscape(const string aString) { Modified: dcplusplus/trunk/client/stdinc.h =================================================================== --- dcplusplus/trunk/client/stdinc.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/client/stdinc.h 2006-08-31 07:46:12 UTC (rev 643) @@ -47,6 +47,7 @@ #else #include <unistd.h> +#include <stdint.h> #endif #include <stdio.h> Modified: dcplusplus/trunk/windows/AboutDlg.h =================================================================== --- dcplusplus/trunk/windows/AboutDlg.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/windows/AboutDlg.h 2006-08-31 07:46:12 UTC (rev 643) @@ -41,7 +41,7 @@ _T("theparanoidone, gadget, naga, tremor, joakim tosteberg, pofis, psf8500, lauris ievins, ") _T("defr, ullner, fleetcommand, liny, xan, olle svensson, mark gillespie, jeremy huddleston, ") _T("bsod, sulan, jonathan stone, tim burton, izzzo, guitarm, paka, nils maier, jens oknelid, yoji, ") -_T("krzysztof tyszecki, poison, pothead, pur, bigmuscle, martin, jove, bart vullings, steven, ") +_T("krzysztof tyszecki, poison, pothead, pur, bigmuscle, martin, jove, bart vullings, ") _T("steven sheehy, tobias nygren. ") _T("Keep it coming!"); Modified: dcplusplus/trunk/windows/FlatTabCtrl.h =================================================================== --- dcplusplus/trunk/windows/FlatTabCtrl.h 2006-07-23 12:21:17 UTC (rev 642) +++ dcplusplus/trunk/windows/FlatTabCtrl.h 2006-08-31 07:46:12 UTC (rev 643) @@ -82,8 +82,7 @@ active = NULL; delete ti; tabs.erase(i); - dcassert(find(viewOrder.begin(), viewOrder.end(), aWnd) != viewOrder.end()); - viewOrder.erase(remove(viewOrder.begin(), viewOrder.end(), aWnd), viewOrder.end()); + viewOrder.remove(aWnd); nextTab = viewOrder.end(); if(!viewOrder.empty()) --nextTab; @@ -136,8 +135,7 @@ } void setTop(HWND aWnd) { - dcassert(find(viewOrder.begin(), viewOrder.end(), aWnd) != viewOrder.end()); - viewOrder.erase(remove(viewOrder.begin(), viewOrder.end(), aWnd), viewOrder.end()); + viewOrder.remove(aWnd); viewOrder.push_back(aWnd); nextTab = --viewOrder.end(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-04 14:04:11
|
Revision: 644 http://svn.sourceforge.net/dcplusplus/?rev=644&view=rev Author: arnetheduck Date: 2006-09-04 07:02:22 -0700 (Mon, 04 Sep 2006) Log Message: ----------- Configuration fixes, back to unicows Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.nsi dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/File.h dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/client/config.h dcplusplus/trunk/windows/AppearancePage.cpp dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/windows/WinUtil.cpp dcplusplus/trunk/windows/WinUtil.h dcplusplus/trunk/windows/main.cpp Added Paths: ----------- dcplusplus/trunk/dcppboot.xml dcplusplus/trunk/release.cmd dcplusplus/trunk/unicows.dll dcplusplus/trunk/unicows.pdb Removed Paths: ------------- dcplusplus/trunk/opencow.dll Modified: dcplusplus/trunk/DCPlusPlus.nsi =================================================================== --- dcplusplus/trunk/DCPlusPlus.nsi 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/DCPlusPlus.nsi 2006-09-04 14:02:22 UTC (rev 644) @@ -56,15 +56,15 @@ ; Put file there File "/oname=DCPlusPlus.exe" "App\DCPlusPlus.exe" File "/oname=DCPlusPlus.chm" "App\DCPlusPlus.chm" - File "/oname=opencow.dll" "app\opencow.dll" + File "unicows.dll" File "ChangeLog.txt" File "Example.xml" File "License.txt" File "License-GeoIP.txt" File "Magnet.exe" - ; Remove unicows so that opencow will be used instead - Delete "$INSTDIR\unicows.dll" - Delete "$INSTDIR\unicows.pdb" + File "dcppboot.xml" + ; Remove opencow just in case we're upgrading + Delete "$INSTDIR\opencow.dll" ; Get DCPlusplus version we just installed and store in $1 Push "DCPlusPlus.exe" @@ -97,6 +97,7 @@ Section "Debug Information (recommended, helps finding bugs)" SetOutPath $INSTDIR File "/oname=DCPlusPlus.pdb" "App\DCPlusPlus.pdb" + File "unicows.pdb" File "dbghelp.dll" SectionEnd @@ -127,7 +128,8 @@ Delete "$INSTDIR\License-GeoIP.txt" Delete "$INSTDIR\License.txt" Delete "$INSTDIR\ChangeLog.txt" - Delete "$INSTDIR\opencow.dll" + Delete "$INSTDIR\unicows.dll" + Delete "$INSTDIR\unicows.pdb" Delete "$INSTDIR\Example.xml" Delete "$INSTDIR\Magnet.exe" Delete "$INSTDIR\GeoIPCountryWhois.csv" Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/changelog.txt 2006-09-04 14:02:22 UTC (rev 644) @@ -15,6 +15,8 @@ * [bug 1029] Fixed BSD compile issue (thanks steven sheehy) * [bug 1031] Fixed a crash after closing hub window (thanks bigmuscle/pothead) * [bug 1032] Fixed certificates help (thanks pothead) +* Added possibility to store configuration files in separate directory +* Switched back to unicows for w9x users, opencow was missing too many functions -- 0.694 2006-07-10 -- * Fixed crash in certificates page Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -343,7 +343,7 @@ if(!u) return; - int severity = Util::toInt(c.getParam(0).substr(0, 1)); + //int severity = Util::toInt(c.getParam(0).substr(0, 1)); int code = Util::toInt(c.getParam(0).substr(1)); if(code == AdcCommand::ERROR_BAD_PASSWORD) { Modified: dcplusplus/trunk/client/File.h =================================================================== --- dcplusplus/trunk/client/File.h 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/File.h 2006-09-04 14:02:22 UTC (rev 644) @@ -222,6 +222,10 @@ } } + static bool isAbsolute(const string& path) { + return path.size() > 2 && (path[1] == ':' || path[0] == '/' || path[0] == '\\'); + } + #else // _WIN32 enum { @@ -395,6 +399,9 @@ } } + static bool isAbsolute(const string& path) { + return path.size() > 1 && path[0] = '/'; + } #endif // _WIN32 Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -84,6 +84,7 @@ SettingsManager::SettingsManager() { + connectionSpeeds.push_back("0.005"); connectionSpeeds.push_back("0.01"); connectionSpeeds.push_back("0.02"); @@ -111,8 +112,8 @@ int64Settings[k] = 0; } - setDefault(DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Downloads" PATH_SEPARATOR_STR); - setDefault(TEMP_DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Incomplete" PATH_SEPARATOR_STR); + setDefault(DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Downloads" PATH_SEPARATOR_STR); + setDefault(TEMP_DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Incomplete" PATH_SEPARATOR_STR); setDefault(SLOTS, 1); setDefault(TCP_PORT, 0); setDefault(UDP_PORT, 0); @@ -137,7 +138,7 @@ setDefault(HUBLIST_SERVERS, "http://www.hublist.org/PublicHubList.xml.bz2;http://dc.selwerd.nl/hublist.xml.bz2"); setDefault(DOWNLOAD_SLOTS, 3); setDefault(MAX_DOWNLOAD_SPEED, 0); - setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR); + setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR); setDefault(LOG_UPLOADS, false); setDefault(LOG_DOWNLOADS, false); setDefault(LOG_PRIVATE_CHAT, false); @@ -248,8 +249,8 @@ setDefault(OPEN_WAITING_USERS, false); setDefault(OPEN_SYSTEM_LOG, true); setDefault(TLS_TRUSTED_CERTIFICATES_PATH, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR); - setDefault(TLS_PRIVATE_KEY_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.key"); - setDefault(TLS_CERTIFICATE_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.crt"); + setDefault(TLS_PRIVATE_KEY_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.key"); + setDefault(TLS_CERTIFICATE_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.crt"); setDefault(BOLD_FINISHED_DOWNLOADS, true); setDefault(BOLD_FINISHED_UPLOADS, true); setDefault(BOLD_QUEUE, true); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -74,14 +74,14 @@ if(hFind != INVALID_HANDLE_VALUE) { do { if(_tcslen(data.cFileName) > 13) // length of "files.xml.bz2" - File::deleteFile(Util::getAppPath() + Text::fromT(data.cFileName)); + File::deleteFile(Util::getConfigPath() + Text::fromT(data.cFileName)); } while(FindNextFile(hFind, &data)); FindClose(hFind); } #else - DIR* dir = opendir(Util::getAppName().c_str()); + DIR* dir = opendir(Util::getConfigPath().c_str()); if (dir) { while (struct dirent* ent = readdir(dir)) { if (fnmatch("files*.xml.bz2", ent->d_name, 0) == 0) { Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/Util.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -27,8 +27,12 @@ #include "StringTokenizer.h" #include "SettingsManager.h" #include "version.h" +#include "File.h" +#include "SimpleXML.h" -#ifndef _WIN32 +#ifdef _WIN32 +#include <ShlObj.h> +#else #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -56,7 +60,9 @@ time_t Util::awayTime; Util::CountryList Util::countries; -string Util::appPath; +string Util::configPath; +string Util::systemPath; +string Util::dataPath; static void sgenrand(unsigned long seed); @@ -79,22 +85,49 @@ #ifdef _WIN32 TCHAR buf[MAX_PATH+1]; - GetModuleFileName(NULL, buf, MAX_PATH); - appPath = Text::fromT(buf); - appPath.erase(appPath.rfind('\\') + 1); + ::GetModuleFileName(NULL, buf, MAX_PATH); + // System config path is DC++ executable path... + systemPath = Util::getFilePath(Text::fromT(buf)); + configPath = systemPath; + dataPath = systemPath; +#else + systemPath = "/etc/"; + char* home = getenv("HOME"); + configPath = home ? home + string("/.dc++/") : "/tmp/"; +#error dataPath = wherever linux should fetch data +#endif + + // Load boot settings + try { + SimpleXML boot; + boot.fromXML(File(systemPath + "dcppboot.xml", File::READ, File::OPEN).read()); + boot.stepIn(); + + if(boot.findChild("ConfigPath")) { + StringMap params; +#ifdef _WIN32 + TCHAR path[MAX_PATH]; + + params["APPDATA"] = Text::fromT((::SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path), path)); + params["PERSONAL"] = Text::fromT((::SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path), path)); + configPath = Util::formatParams(boot.getChildData(), params, false); +#else +#error TODO - make env vars available perhaps? +#endif + } + } catch(const Exception& ) { + // Unable to load boot settings... + } + + if(!File::isAbsolute(configPath)) { + configPath = systemPath + configPath; + } + #if _MSC_VER == 1400 _set_invalid_parameter_handler(reinterpret_cast<_invalid_parameter_handler>(invalidParameterHandler)); #endif -#else // _WIN32 - char* home = getenv("HOME"); - if (home) { - appPath = Text::fromT(home); - appPath += "/.dc++/"; - } -#endif // _WIN32 - try { // This product includes GeoIP data created by MaxMind, available from http://maxmind.com/ // Updates at http://www.maxmind.com/app/geoip_country @@ -138,42 +171,7 @@ } } -string Util::getConfigPath() { #ifdef _WIN32 - return getAppPath(); -#else - char* home = getenv("HOME"); - if (home) { -#ifdef __APPLE__ -/// @todo Verify this for apple? - return string(home) + "/Library/Application Support/Mac DC++/"; -#else - return string(home) + "/.dc++/"; -#endif // __APPLE__ - } - return emptyString; -#endif // _WIN32 -} - -string Util::getDataPath() { -#ifdef _WIN32 - return getAppPath(); -#else - // This probably ought to be /usr/share/*... - char* home = getenv("HOME"); - if (home) { -#ifdef __APPLE__ - /// @todo Verify this for apple? - return string(home) + "/Library/Application Support/Mac DC++/"; -#else - return string(home) + "/.dc++/"; -#endif // __APPLE__ - } - return emptyString; -#endif // _WIN32 -} - -#ifdef _WIN32 static const char badChars[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, @@ -925,4 +923,45 @@ i++; } return toDOS(tmp); -} \ No newline at end of file +} + +string Util::getTimeString() { + char buf[64]; + time_t _tt; + time(&_tt); + tm* _tm = localtime(&_tt); + if(_tm == NULL) { + strcpy(buf, "xx:xx:xx"); + } else { + strftime(buf, 64, "%X", _tm); + } + return buf; +} + +string Util::toAdcFile(const string& file) { + if(file == "files.xml.bz2" || file == "MyList.DcLst") + return file; + + string ret; + ret.reserve(file.length() + 1); + ret += '/'; + ret += file; + for(string::size_type i = 0; i < ret.length(); ++i) { + if(ret[i] == '\\') { + ret[i] = '/'; + } + } + return ret; +} +string Util::toNmdcFile(const string& file) { + if(file.empty()) + return Util::emptyString; + + string ret(file.substr(1)); + for(string::size_type i = 0; i < ret.length(); ++i) { + if(ret[i] == '/') { + ret[i] = '\\'; + } + } + return ret; +} Modified: dcplusplus/trunk/client/Util.h =================================================================== --- dcplusplus/trunk/client/Util.h 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/Util.h 2006-09-04 14:02:22 UTC (rev 644) @@ -144,56 +144,26 @@ static void initialize(); - /** - * Get the path to the application executable. - * This is mainly intended for use on Windows. - * - * @return Path to executable file. - */ - static string getAppPath() { return appPath; } - - static string getAppName() { -#ifdef _WIN32 - TCHAR buf[MAX_PATH+1]; - DWORD x = GetModuleFileName(NULL, buf, MAX_PATH); - return Text::wideToUtf8(wstring(buf, x)); -#else // _WIN32 - char buf[PATH_MAX + 1]; - int n; - n = readlink("/proc/self/exe", buf, PATH_MAX); - if (n == -1) { - return emptyString; - } - buf[n] = '\0'; - return string(buf); -#endif // _WIN32 - } - /** Path of temporary storage */ static string getTempPath() { #ifdef _WIN32 TCHAR buf[MAX_PATH + 1]; DWORD x = GetTempPath(MAX_PATH, buf); - return Text::wideToUtf8(wstring(buf, x)); + return Text::fromT(tstring(buf, x)); #else return "/tmp/"; #endif } - /** Path of resource directory */ - static string getDataPath(); - /** Path of configuration files */ - static string getConfigPath(); + static const string& getConfigPath() { return configPath; } + static const string& getDataPath() { return dataPath; } + static const string& getSystemPath() { return systemPath; } /** Path of file lists */ - static string getListPath() { - return getConfigPath() + "FileLists" PATH_SEPARATOR_STR; - } + static string getListPath() { return getConfigPath() + "FileLists" PATH_SEPARATOR_STR; } /** Notepad filename */ - static string getNotepadFile() { - return getConfigPath() + "Notepad.txt"; - } + static string getNotepadFile() { return getConfigPath() + "Notepad.txt"; } static string translateError(int aError) { #ifdef _WIN32 @@ -270,55 +240,15 @@ static string validateFileName(string aFile); static string cleanPathChars(string aNick); - static string formatBytes(const string& aString) { - return formatBytes(toInt64(aString)); - } - + static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); } static string formatMessage(const string& nick, const string& message); static string toDOS(const string& tmp); static string getShortTimeString(time_t t = time(NULL) ); - static string getTimeString() { - char buf[64]; - time_t _tt; - time(&_tt); - tm* _tm = localtime(&_tt); - if(_tm == NULL) { - strcpy(buf, "xx:xx:xx"); - } else { - strftime(buf, 64, "%X", _tm); - } - return buf; - } - - static string toAdcFile(const string& file) { - if(file == "files.xml.bz2" || file == "MyList.DcLst") - return file; - - string ret; - ret.reserve(file.length() + 1); - ret += '/'; - ret += file; - for(string::size_type i = 0; i < ret.length(); ++i) { - if(ret[i] == '\\') { - ret[i] = '/'; - } - } - return ret; - } - static string toNmdcFile(const string& file) { - if(file.empty()) - return Util::emptyString; - - string ret(file.substr(1)); - for(string::size_type i = 0; i < ret.length(); ++i) { - if(ret[i] == '/') { - ret[i] = '\\'; - } - } - return ret; - } + static string getTimeString(); + static string toAdcFile(const string& file); + static string toNmdcFile(const string& file); static string formatBytes(int64_t aBytes); @@ -399,20 +329,12 @@ } static string toString(long long val) { char buf[32]; -#ifdef _MSC_VER - snprintf(buf, sizeof(buf), "%I64d", val); -#else - snprintf(buf, sizeof(buf), "%lld", val); -#endif + snprintf(buf, sizeof(buf), I64_FMT, val); return buf; } static string toString(unsigned long long val) { char buf[32]; -#ifdef _MSC_VER - snprintf(buf, sizeof(buf), "%I64u", val); -#else - snprintf(buf, sizeof(buf), "%llu", val); -#endif + snprintf(buf, sizeof(buf), U64_FMT, val); return buf; } static string toString(double val) { @@ -511,8 +433,13 @@ static double randd() { return ((double)rand()) / ((double)0xffffffff); } private: - static string appPath; + /** Per-user configuration */ + static string configPath; + /** Global configuration */ + static string systemPath; + /** Various resources (help files etc) */ static string dataPath; + static bool away; static bool manualAway; static string awayMsg; Modified: dcplusplus/trunk/client/config.h =================================================================== --- dcplusplus/trunk/client/config.h 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/client/config.h 2006-09-04 14:02:22 UTC (rev 644) @@ -80,14 +80,18 @@ #define _LL(x) x##ll #define _ULL(x) x##ull #define I64_FMT "%I64d" +#define U64_FMT "%I64d" + #elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8 #define _LL(x) x##l #define _ULL(x) x##ul #define I64_FMT "%ld" +#define U64_FMT "%ld" #else #define _LL(x) x##ll #define _ULL(x) x##ull #define I64_FMT "%lld" +#define U64_FMT "%lld" #endif #ifdef _WIN32 Added: dcplusplus/trunk/dcppboot.xml =================================================================== --- dcplusplus/trunk/dcppboot.xml (rev 0) +++ dcplusplus/trunk/dcppboot.xml 2006-09-04 14:02:22 UTC (rev 644) @@ -0,0 +1,16 @@ +<Boot> + <!-- + ConfigPath specifies where settings, queue and other runtime data should be saved. + Relative paths are relative to the DC++ executable. + You may use the following variables, which are interpreted on a per-user basis: + + %[APPDATA] - Application data, typically c:\documents and settings\<username>\Application Data\ + %[PERSONAL] - My documents + + All % variables from strftime with the current time: + http://msdn.microsoft.com/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp + + --> + + <ConfigPath>.\</ConfigPath> +</Boot> Deleted: dcplusplus/trunk/opencow.dll =================================================================== (Binary files differ) Added: dcplusplus/trunk/release.cmd =================================================================== --- dcplusplus/trunk/release.cmd (rev 0) +++ dcplusplus/trunk/release.cmd 2006-09-04 14:02:22 UTC (rev 644) @@ -0,0 +1,14 @@ +copy /b app\dcplusplus.exe . +copy /b app\dcplusplus.chm . +copy /b app\dcplusplus.pdb . +"c:\program files\WinRAR\WinRAR" a -ep -m5 DCPlusPlus-%1.zip dcppboot.xml unicows.dll unicows.pdb dcplusplus.chm dcplusplus.exe dcplusplus.pdb dbghelp.dll changelog.txt Example.xml License.txt GeoIPCountryWhois.csv +"c:\program files\WinRAR\WinRAR" a -m5 DCPlusPlus-%1-src.zip dcppboot.xml bootstrap makedefs.py Makefile.am configure.ac libunicows.lib unicows.dll unicows.pdb yassl\* yassl\certs\* yassl\include\openssl\* yassl\mySTL\* yassl\src\* yassl\include\* yassl\taocrypt\* yassl\taocrypt\src\* yassl\taocrypt\include\* stlport\.keep wtl\.keep help\* zlib\* bzip2\* client\* MakeDefs\* res\* windows\* changelog.txt Example.xml License.txt compile.txt GeoIPCountryWhois.csv *.dsp *.vcproj *.dsw *.sln *.rc extensions.txt doxyfile dcplusplus.nsi +del dcplusplus.exe +del dcplusplus.pdb +del dcplusplus.chm +makensis dcplusplus.nsi +move dcplusplus.exe DCPlusPlus-%1.exe + +svn status +pause +svn copy . https://svn.sourceforge.net/svnroot/dcplusplus/dcplusplus/tags/dcplusplus-%1 -m "%1" Added: dcplusplus/trunk/unicows.dll =================================================================== (Binary files differ) Property changes on: dcplusplus/trunk/unicows.dll ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: dcplusplus/trunk/unicows.pdb =================================================================== (Binary files differ) Property changes on: dcplusplus/trunk/unicows.pdb ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: dcplusplus/trunk/windows/AppearancePage.cpp =================================================================== --- dcplusplus/trunk/windows/AppearancePage.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/windows/AppearancePage.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -82,7 +82,7 @@ GetDlgItemText(IDC_LANGUAGE, buf, MAX_PATH); tstring x = buf; - if(WinUtil::browseFile(x, m_hWnd, false, Text::toT(Util::getAppPath()), types) == IDOK) { + if(WinUtil::browseFile(x, m_hWnd, false, Text::toT(Util::getDataPath()), types) == IDOK) { SetDlgItemText(IDC_LANGUAGE, x.c_str()); } return 0; Modified: dcplusplus/trunk/windows/MainFrm.cpp =================================================================== --- dcplusplus/trunk/windows/MainFrm.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/windows/MainFrm.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -515,7 +515,7 @@ LRESULT MainFrame::onCopyData(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { tstring cmdLine = (LPCTSTR) (((COPYDATASTRUCT *)lParam)->lpData); - parseCommandLine(Text::toT(Util::getAppName() + " ") + cmdLine); + parseCommandLine(Text::toT(WinUtil::getAppName() + " ") + cmdLine); return true; } Modified: dcplusplus/trunk/windows/WinUtil.cpp =================================================================== --- dcplusplus/trunk/windows/WinUtil.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/windows/WinUtil.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -693,7 +693,7 @@ void WinUtil::registerDchubHandler() { HKEY hk; TCHAR Buf[512]; - tstring app = _T("\"") + Text::toT(Util::getAppName()) + _T("\" %1"); + tstring app = _T("\"") + Text::toT(getAppName()) + _T("\" %1"); Buf[0] = 0; if(::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("dchub\\Shell\\Open\\Command"), 0, KEY_WRITE | KEY_READ, &hk) == ERROR_SUCCESS) { @@ -719,7 +719,7 @@ ::RegCloseKey(hk); ::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("dchub\\DefaultIcon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL); - app = Text::toT(Util::getAppName()); + app = Text::toT(getAppName()); ::RegSetValueEx(hk, _T(""), 0, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length() + 1)); ::RegCloseKey(hk); } @@ -732,7 +732,7 @@ void WinUtil::registerADChubHandler() { HKEY hk; TCHAR Buf[512]; - tstring app = _T("\"") + Text::toT(Util::getAppName()) + _T("\" %1"); + tstring app = _T("\"") + Text::toT(getAppName()) + _T("\" %1"); Buf[0] = 0; if(::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("adc\\Shell\\Open\\Command"), 0, KEY_WRITE | KEY_READ, &hk) == ERROR_SUCCESS) { @@ -758,7 +758,7 @@ ::RegCloseKey(hk); ::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("adc\\DefaultIcon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL); - app = Text::toT(Util::getAppName()); + app = Text::toT(getAppName()); ::RegSetValueEx(hk, _T(""), 0, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length() + 1)); ::RegCloseKey(hk); } @@ -796,10 +796,10 @@ } // check for the existence of magnet.exe if(File::getSize(Text::fromT(magnetExe)) == -1) { - magnetExe = Text::toT(Util::getAppPath() + "magnet.exe"); + magnetExe = Text::toT(Util::getDataPath() + "magnet.exe"); if(File::getSize(Text::fromT(magnetExe)) == -1) { // gracefully fall back to registering DC++ to handle magnets - magnetExe = Text::toT(Util::getAppName()); + magnetExe = Text::toT(getAppName()); haveMagnet = false; } else { // set Magnet\Location @@ -839,10 +839,10 @@ ::RegSetValueEx(hk, NULL, NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_HANDLER_ROOT), sizeof(TCHAR) * (TSTRING(MAGNET_HANDLER_ROOT).size()+1)); ::RegSetValueEx(hk, _T("Description"), NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_HANDLER_DESC), sizeof(TCHAR) * (STRING(MAGNET_HANDLER_DESC).size()+1)); // set ShellExecute - tstring app = Text::toT("\"" + Util::getAppName() + "\" %URL"); + tstring app = Text::toT("\"" + getAppName() + "\" %URL"); ::RegSetValueEx(hk, _T("ShellExecute"), NULL, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length()+1)); // set DefaultIcon - app = Text::toT('"' + Util::getAppName() + '"'); + app = Text::toT('"' + getAppName() + '"'); ::RegSetValueEx(hk, _T("DefaultIcon"), NULL, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR)*(app.length()+1)); ::RegCloseKey(hk); Modified: dcplusplus/trunk/windows/WinUtil.h =================================================================== --- dcplusplus/trunk/windows/WinUtil.h 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/windows/WinUtil.h 2006-09-04 14:02:22 UTC (rev 644) @@ -195,6 +195,12 @@ static void init(HWND hWnd); static void uninit(); + static string getAppName() { + TCHAR buf[MAX_PATH+1]; + DWORD x = GetModuleFileName(NULL, buf, MAX_PATH); + return Text::fromT(tstring(buf, x)); + } + static void decodeFont(const tstring& setting, LOGFONT &dest); static void addInitalDir(const User::Ptr& user, string dir) { @@ -277,7 +283,7 @@ static tstring encodeFont(LOGFONT const& font); static tstring getHelpFile() { - return Text::toT(Util::getAppPath() + "DCPlusPlus.chm"); + return Text::toT(Util::getDataPath() + "DCPlusPlus.chm"); } static bool browseFile(tstring& target, HWND owner = NULL, bool save = true, const tstring& initialDir = Util::emptyStringW, const TCHAR* types = NULL, const TCHAR* defExt = NULL); Modified: dcplusplus/trunk/windows/main.cpp =================================================================== --- dcplusplus/trunk/windows/main.cpp 2006-08-31 07:46:12 UTC (rev 643) +++ dcplusplus/trunk/windows/main.cpp 2006-09-04 14:02:22 UTC (rev 644) @@ -67,7 +67,7 @@ #endif // The release version loads the dll and pdb:s here... - EXTENDEDTRACEINITIALIZE( Util::getAppPath().c_str() ); + EXTENDEDTRACEINITIALIZE( Util::getDataPath().c_str() ); #endif @@ -76,7 +76,7 @@ firstException = false; } - if(File::getSize(Util::getAppPath() + "DCPlusPlus.pdb") == -1) { + if(File::getSize(Util::getDataPath() + "DCPlusPlus.pdb") == -1) { // No debug symbols, we're not interested... ::MessageBox(WinUtil::mainWnd, _T("DC++ has crashed and you don't have debug symbols installed. Hence, I can't find out why it crashed, so don't report this as a bug unless you find a solution..."), _T("DC++ has crashed"), MB_OK); #ifndef _DEBUG @@ -315,8 +315,8 @@ // For SHBrowseForFolder, UPnP HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); #ifdef _DEBUG - EXTENDEDTRACEINITIALIZE( Util::getAppPath().c_str() ); - //File::deleteFile(Util::getAppPath() + "exceptioninfo.txt"); + EXTENDEDTRACEINITIALIZE( Util::getDataPath().c_str() ); + //File::deleteFile(Util::getDataPath() + "exceptioninfo.txt"); #endif SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter); @@ -330,7 +330,7 @@ ATLASSERT(SUCCEEDED(hRes)); try { - File f(Util::getAppName(), File::READ, File::OPEN); + File f(WinUtil::getAppName(), File::READ, File::OPEN); TigerTree tth(TigerTree::calcBlockSize(f.getSize(), 1)); size_t n = 0; size_t n2 = DEBUG_BUFSIZE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-10 19:04:52
|
Revision: 646 http://svn.sourceforge.net/dcplusplus/?rev=646&view=rev Author: arnetheduck Date: 2006-09-10 12:03:10 -0700 (Sun, 10 Sep 2006) Log Message: ----------- Patches and small fixes Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/DCPlusPlus.vcproj dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/DCPlusPlus.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/User.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/version.h dcplusplus/trunk/help/changelog.html dcplusplus/trunk/windows/AboutDlg.h dcplusplus/trunk/windows/DirectoryListingFrm.cpp dcplusplus/trunk/windows/FlatTabCtrl.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h dcplusplus/trunk/windows/MainFrm.h dcplusplus/trunk/windows/NetworkPage.cpp Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-09-10 19:03:10 UTC (rev 646) @@ -97,6 +97,9 @@ DEFPUSHBUTTON "OK",IDOK,96,266,50,14 ICON IDR_MAINFRAME,IDC_STATIC,110,15,21,20 GROUPBOX "",IDC_STATIC,7,7,229,102 + EDITTEXT IDC_TTH,35,93,196,12,ES_AUTOHSCROLL | ES_READONLY | NOT + WS_BORDER + LTEXT "TTH:",IDC_STATIC,13,93,18,12 GROUPBOX "Greetz && Contributors",IDC_STATIC,7,112,229,82, BS_CENTER GROUPBOX "Latest version",IDC_STATIC,7,239,229,24,BS_CENTER @@ -108,9 +111,6 @@ EDITTEXT IDC_THANKS,13,122,218,66,ES_MULTILINE | ES_READONLY | WS_VSCROLL CTEXT "Static",IDC_VERSION,13,37,218,54 - EDITTEXT IDC_TTH,35,93,196,12,ES_AUTOHSCROLL | ES_READONLY | NOT - WS_BORDER - LTEXT "TTH:",IDC_STATIC,13,93,18,12 END IDD_LINE DIALOGEX 0, 0, 239, 46 @@ -526,6 +526,9 @@ LTEXT "MiB",IDC_SETTINGS_MB,117,78,14,8 LTEXT "PID",IDC_STATIC,52,95,12,8 EDITTEXT IDC_PRIVATE_ID,69,92,45,14,ES_AUTOHSCROLL + LTEXT "Auto refresh time",IDC_SETTINGS_AUTO_REFRESH_TIME,7,113, + 57,8 + EDITTEXT IDC_AUTO_REFRESH_TIME,69,110,45,14,ES_AUTOHSCROLL RTEXT "File write buffer",IDC_SETTINGS_WRITE_BUFFER,139,10,65, 8 EDITTEXT IDC_BUFFERSIZE,208,7,41,14,ES_AUTOHSCROLL @@ -547,9 +550,6 @@ 96,76,8 EDITTEXT IDC_SOCKET_OUT_BUFFER,208,93,41,14,ES_AUTOHSCROLL LTEXT "B",IDC_STATIC,252,96,8,8 - LTEXT "Auto refresh time",IDC_SETTINGS_AUTO_REFRESH_TIME,7,113, - 57,8 - EDITTEXT IDC_AUTO_REFRESH_TIME,69,110,45,14,ES_AUTOHSCROLL EDITTEXT IDC_AUTO_SEARCH_LIMIT,208,111,41,14,ES_AUTOHSCROLL LTEXT "Auto-search limit",IDC_SETTINGS_AUTO_SEARCH_LIMIT,148, 113,56,13 Modified: dcplusplus/trunk/DCPlusPlus.vcproj =================================================================== --- dcplusplus/trunk/DCPlusPlus.vcproj 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/DCPlusPlus.vcproj 2006-09-10 19:03:10 UTC (rev 646) @@ -48,7 +48,7 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/FIXED:NO /SAFESEH:NO" - AdditionalDependencies="libunicows.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib htmlhelp.lib ws2_32.lib" + AdditionalDependencies="libunicows.lib SHFolder.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib htmlhelp.lib ws2_32.lib" OutputFile="$(SolutionDir)App/$(ProjectName).exe" LinkIncremental="2" SuppressStartupBanner="TRUE" @@ -127,7 +127,7 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/FIXED:NO /SAFESEH:NO" - AdditionalDependencies="libunicows.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib htmlhelp.lib ws2_32.lib" + AdditionalDependencies="libunicows.lib SHFolder.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib htmlhelp.lib ws2_32.lib" OutputFile="$(SolutionDir)App/$(ProjectName).exe" Version="" LinkIncremental="1" Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/changelog.txt 2006-09-10 19:03:10 UTC (rev 646) @@ -1,4 +1,4 @@ --- -- +-- 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 @@ -17,6 +17,15 @@ * [bug 1032] Fixed certificates help (thanks pothead) * Added possibility to store configuration files in separate directory * Switched back to unicows for w9x users, opencow was missing too many functions +* [bug 876] Fixed lost tooltips (thanks poy and bigmuscle) +* [bug 1041] Fixed about tab order (thanks pothead) +* [bug 1042] Fixed experts tab order (thanks pothead) +* [bug 1047] Fixed possible nmdc crash (thanks guitarm) +* [bug 1049] Added tooltip to tab bar (thanks poy) +* [bug 1053] Fixed vista detection (thanks ullner) +* [bug 988] Fixed duplicate nicks +* [bug 1015] Fixed chevron text +* Default hub lists updated -- 0.694 2006-07-10 -- * Fixed crash in certificates page Modified: dcplusplus/trunk/client/DCPlusPlus.h =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/DCPlusPlus.h 2006-09-10 19:03:10 UTC (rev 646) @@ -23,6 +23,10 @@ #pragma once #endif // _MSC_VER > 1000 +#ifdef _WIN32 +#define snprintf _snprintf +#endif + #ifdef _DEBUG inline void CDECL debugTrace(const char* format, ...) @@ -41,10 +45,6 @@ va_end(args); } -#ifdef _WIN32 -#define snprintf _snprintf -#endif - #define dcdebug debugTrace #ifdef _WIN32 #define dcassert(exp) \ Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -202,7 +202,13 @@ return; } string nick = line.substr(1, i-1); - string message = line.substr(i+2); + string message; + if((line.length()-1) > i) { + message = line.substr(i+2); + } else { + fire(ClientListener::StatusMessage(), this, unescape(line)); + return; + } OnlineUser* ou = findUser(nick); if(ou) { @@ -689,7 +695,7 @@ } if(from == 0) { // Assume it's from the hub - from = &getUser(rtNick); + from = &getUser(fromNick); from->getIdentity().setHub(true); from->getIdentity().setHidden(true); fire(ClientListener::UserUpdated(), this, *from); @@ -698,8 +704,8 @@ // Update pointers just in case they've been invalidated replyTo = findUser(rtNick); from = findUser(fromNick); - - } + } + OnlineUser& to = getUser(getMyNick()); fire(ClientListener::PrivateMessage(), this, *from, to, *replyTo, unescape(msg)); } else if(cmd == "$GetPass") { Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -135,7 +135,7 @@ setDefault(IGNORE_BOT_PMS, false); setDefault(LIST_DUPES, true); setDefault(BUFFER_SIZE, 64); - setDefault(HUBLIST_SERVERS, "http://www.hublist.org/PublicHubList.xml.bz2;http://dc.selwerd.nl/hublist.xml.bz2"); + setDefault(HUBLIST_SERVERS, "http://hubs.bandicoot.nl/;http://www.hublist.org/PublicHubList.xml.bz2"); setDefault(DOWNLOAD_SLOTS, 3); setDefault(MAX_DOWNLOAD_SPEED, 0); setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR); Modified: dcplusplus/trunk/client/User.cpp =================================================================== --- dcplusplus/trunk/client/User.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/User.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -28,7 +28,10 @@ } +RWLock<> Identity::rw; + void Identity::getParams(StringMap& sm, const string& prefix, bool compatibility) const { + RLock<> l(rw); for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) { sm[prefix + string((char*)(&i->first), 2)] = i->second; } Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/User.h 2006-09-10 19:03:10 UTC (rev 646) @@ -27,6 +27,7 @@ #include "Pointer.h" #include "CID.h" #include "FastAlloc.h" +#include "CriticalSection.h" /** A user connected to one or more hubs. */ class User : public FastAlloc<User>, public PointerBase, public Flags @@ -136,11 +137,13 @@ bool isUdpActive() const { return !getIp().empty() && !getUdpPort().empty(); } const string& get(const char* name) const { + RLock<> l(rw); InfMap::const_iterator i = info.find(*(short*)name); return i == info.end() ? Util::emptyString : i->second; } void set(const char* name, const string& val) { + WLock<> l(rw); if(val.empty()) info.erase(*(short*)name); else @@ -159,6 +162,8 @@ typedef map<short, string> InfMap; typedef InfMap::iterator InfIter; InfMap info; + /** @todo there are probably more threading issues here ...*/ + static RWLock<> rw; }; class Client; Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/Util.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -831,6 +831,8 @@ os += " Server"; else if(ver.wProductType & VER_NT_DOMAIN_CONTROLLER) os += " DC"; + } else if(ver.dwMajorVersion == 6) { + os = "WinVista"; } if(ver.wServicePackMajor != 0) { Modified: dcplusplus/trunk/client/version.h =================================================================== --- dcplusplus/trunk/client/version.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/client/version.h 2006-09-10 19:03:10 UTC (rev 646) @@ -17,8 +17,8 @@ */ #define APPNAME "DC++" -#define VERSIONSTRING "0.694" -#define VERSIONFLOAT 0.694 +#define VERSIONSTRING "0.695" +#define VERSIONFLOAT 0.695 /* Update the .rc file as well... */ Modified: dcplusplus/trunk/help/changelog.html =================================================================== --- dcplusplus/trunk/help/changelog.html 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/help/changelog.html 2006-09-10 19:03:10 UTC (rev 646) @@ -13,6 +13,36 @@ <h1>DC++ Changelog</h1> See the version history of DC++ below. +<h2>0.695 <span style="color: gray;">(2006-09-10)</span></h2> +<ul> + <li>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</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=125">[bug 125]</a> Fixed out-of-order PM/quit</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=224">[bug 224]</a> Slots are no longer granted to disconnected users, instead disconnection is delayed a minute</li> + <li>[NMDC] Fixed extra space in chat</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=395">[bug 395]</a> Fixed password being blanked</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=419">[bug 419]</a> Allowed changing case only when moving file in queue</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=736">[bug 736]</a> Fixed escaping of menu items</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1013">[bug 1013]</a> Fixed gcc warnings (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1023">[bug 1023]</a> Fixed some large stack allocations (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1026">[bug 1026]</a> Fixed some potential buffer overflows (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1027">[bug 1027]</a> Improved unix socket support (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1028">[bug 1028]</a> Improved big endian support (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1029">[bug 1029]</a> Fixed BSD compile issue (thanks steven sheehy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1031">[bug 1031]</a> Fixed a crash after closing hub window (thanks bigmuscle/pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1032">[bug 1032]</a> Fixed certificates help (thanks pothead)</li> + <li>Added possibility to store configuration files in separate directory</li> + <li>Switched back to unicows for w9x users, opencow was missing too many functions</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=876">[bug 876]</a> Fixed lost tooltips (thanks poy and bigmuscle)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1041">[bug 1041]</a> Fixed about tab order (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1042">[bug 1042]</a> Fixed experts tab order (thanks pothead)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1047">[bug 1047]</a> Fixed possible nmdc crash (thanks guitarm)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1049">[bug 1049]</a> Added tooltip to tab bar (thanks poy)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1053">[bug 1053]</a> Fixed vista detection (thanks ullner)</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=988">[bug 988]</a> Fixed duplicate nicks</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1015">[bug 1015]</a> Fixed chevron text</li> + <li>Default hub lists updated</li> +</ul> + <h2>0.694 <span style="color: gray;">(2006-07-10)</span></h2> <ul> <li>Fixed crash in certificates page</li> Modified: dcplusplus/trunk/windows/AboutDlg.h =================================================================== --- dcplusplus/trunk/windows/AboutDlg.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/AboutDlg.h 2006-09-10 19:03:10 UTC (rev 646) @@ -42,7 +42,7 @@ _T("defr, ullner, fleetcommand, liny, xan, olle svensson, mark gillespie, jeremy huddleston, ") _T("bsod, sulan, jonathan stone, tim burton, izzzo, guitarm, paka, nils maier, jens oknelid, yoji, ") _T("krzysztof tyszecki, poison, pothead, pur, bigmuscle, martin, jove, bart vullings, ") -_T("steven sheehy, tobias nygren. ") +_T("steven sheehy, tobias nygren, poy. ") _T("Keep it coming!"); class AboutDlg : public CDialogImpl<AboutDlg>, private HttpConnectionListener Modified: dcplusplus/trunk/windows/DirectoryListingFrm.cpp =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -212,6 +212,7 @@ updateTree(*i, ht); } } + void DirectoryListingFrame::refreshTree(const tstring& root) { ctrlTree.SetRedraw(FALSE); @@ -365,6 +366,7 @@ history = tmp; } } + void DirectoryListingFrame::forward() { if(history.size() > 1 && historyIndex < history.size()) { size_t n = min(historyIndex, history.size() - 1); Modified: dcplusplus/trunk/windows/FlatTabCtrl.h =================================================================== --- dcplusplus/trunk/windows/FlatTabCtrl.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/FlatTabCtrl.h 2006-09-10 19:03:10 UTC (rev 646) @@ -183,6 +183,7 @@ MESSAGE_HANDLER(WM_LBUTTONDOWN, onLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, onLButtonUp) MESSAGE_HANDLER(WM_CONTEXTMENU, onContextMenu) + MESSAGE_HANDLER(WM_MOUSEMOVE, onMouseMove) COMMAND_ID_HANDLER(IDC_CLOSE_WINDOW, onCloseWindow) COMMAND_ID_HANDLER(IDC_CHEVRON, onChevron) COMMAND_RANGE_HANDLER(IDC_SELECT_WINDOW, IDC_SELECT_WINDOW+tabs.size(), onSelectWindow) @@ -268,6 +269,37 @@ return 0; } + LRESULT onMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; // location of mouse click + + int xPos = pt.x; + int row = rows - ((pt.y / height) + 1); + + for(TabInfo::ListIter i = tabs.begin(); i != tabs.end(); ++i) { + TabInfo* t = *i; + if((row == t->row) && (xPos >= t->xpos) && (xPos < (t->xpos + t->getWidth()))) { + // Bingo, the mouse was over this one + int len = ::GetWindowTextLength(t->hWnd) + 1; + if(len >= TabInfo::MAX_LENGTH) { + TCHAR* buf = new TCHAR[len]; + ::GetWindowText(t->hWnd, buf, len); + if(buf != current_tip) { + tab_tip.DelTool(m_hWnd); + CToolInfo ti(TTF_SUBCLASS, m_hWnd, 0, NULL, buf); + tab_tip.AddTool(&ti); + tab_tip.Activate(TRUE); + current_tip = buf; + } + delete[] buf; + return 1; + } + } + } + tab_tip.Activate(FALSE); + current_tip = _T(""); + return 1; + } + LRESULT onCloseWindow(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if(::IsWindow(closing)) ::SendMessage(closing, WM_CLOSE, 0, 0); @@ -323,10 +355,12 @@ LRESULT onCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { chevron.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_PUSHBUTTON , 0, IDC_CHEVRON); - chevron.SetWindowText(_T("�")); + chevron.SetWindowText(_T("\u00bb")); mnu.CreatePopupMenu(); + tab_tip.Create(m_hWnd, rcDefault, NULL, TTS_ALWAYSTIP | TTS_NOPREFIX); + CDC dc(::GetDC(m_hWnd)); HFONT oldfont = dc.SelectFont(WinUtil::font); height = WinUtil::getTextHeight(dc) + 2; @@ -542,10 +576,13 @@ HWND closing; CButton chevron; CMenu mnu; + CToolTipCtrl tab_tip; int rows; int height; + tstring current_tip; + TabInfo* active; TabInfo* moving; typename TabInfo::List tabs; Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -161,6 +161,13 @@ } } +LRESULT HubFrame::OnForwardMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { + LPMSG pMsg = (LPMSG)lParam; + if((pMsg->message >= WM_MOUSEFIRST) && (pMsg->message <= WM_MOUSELAST)) + ctrlLastLines.RelayEvent(pMsg); + return 0; +} + void HubFrame::onEnter() { if(ctrlMessage.GetWindowTextLength() > 0) { AutoArray<TCHAR> msg(ctrlMessage.GetWindowTextLength()+1); Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/HubFrame.h 2006-09-10 19:03:10 UTC (rev 646) @@ -62,6 +62,7 @@ MESSAGE_HANDLER(WM_CLOSE, onClose) MESSAGE_HANDLER(WM_SETFOCUS, onSetFocus) MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_FORWARDMSG, OnForwardMsg) MESSAGE_HANDLER(WM_SPEAKER, onSpeaker) MESSAGE_HANDLER(WM_CONTEXTMENU, onContextMenu) MESSAGE_HANDLER(WM_CTLCOLORSTATIC, onCtlColor) @@ -91,6 +92,7 @@ COMMAND_CODE_HANDLER(CBN_SELCHANGE, onSelChange) END_MSG_MAP() + LRESULT OnForwardMsg(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/); LRESULT onSpeaker(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/); LRESULT onCopyNick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onCopyHub(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); Modified: dcplusplus/trunk/windows/MainFrm.h =================================================================== --- dcplusplus/trunk/windows/MainFrm.h 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/MainFrm.h 2006-09-10 19:03:10 UTC (rev 646) @@ -61,6 +61,9 @@ virtual BOOL PreTranslateMessage(MSG* pMsg) { + if((pMsg->message >= WM_MOUSEFIRST) && (pMsg->message <= WM_MOUSELAST)) + ctrlLastLines.RelayEvent(pMsg); + if(CMDIFrameWindowImpl<MainFrame>::PreTranslateMessage(pMsg)) return TRUE; Modified: dcplusplus/trunk/windows/NetworkPage.cpp =================================================================== --- dcplusplus/trunk/windows/NetworkPage.cpp 2006-09-04 15:16:01 UTC (rev 645) +++ dcplusplus/trunk/windows/NetworkPage.cpp 2006-09-10 19:03:10 UTC (rev 646) @@ -113,8 +113,8 @@ { PropPage::translate((HWND)(*this), texts); - if(!(WinUtil::getOsMajor() >= 5 && WinUtil::getOsMinor() >= 1 ) //WinXP & WinSvr2003 - || WinUtil::getOsMajor() >= 6 ) //Longhorn + if(!(WinUtil::getOsMajor() >= 5 && WinUtil::getOsMinor() >= 1 //WinXP & WinSvr2003 + || WinUtil::getOsMajor() >= 6 )) //Vista { ::EnableWindow(GetDlgItem(IDC_FIREWALL_UPNP), FALSE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-11 13:41:53
|
Revision: 647 http://svn.sourceforge.net/dcplusplus/?rev=647&view=rev Author: arnetheduck Date: 2006-09-11 06:41:15 -0700 (Mon, 11 Sep 2006) Log Message: ----------- Last fixes before release Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/client/SettingsManager.cpp Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-09-10 19:03:10 UTC (rev 646) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-09-11 13:41:15 UTC (rev 647) @@ -942,8 +942,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,9,4 - PRODUCTVERSION 0,6,9,4 + FILEVERSION 0,6,9,5 + PRODUCTVERSION 0,6,9,5 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -960,12 +960,12 @@ BEGIN VALUE "Comments", "http://dcplusplus.sourceforge.net" VALUE "FileDescription", "DC++" - VALUE "FileVersion", "0, 6, 9, 4" + VALUE "FileVersion", "0, 6, 9, 5" VALUE "InternalName", "DC++" VALUE "LegalCopyright", "Copyright 2001-2006 Jacek Sieka" VALUE "OriginalFilename", "DCPlusPlus.exe" VALUE "ProductName", "DC++" - VALUE "ProductVersion", "0, 6, 9, 4" + VALUE "ProductVersion", "0, 6, 9, 5" END END BLOCK "VarFileInfo" Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-10 19:03:10 UTC (rev 646) +++ dcplusplus/trunk/Example.xml 2006-09-11 13:41:15 UTC (rev 647) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version="0.694" Revision="1" RightToLeft="0"> +<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version="0.695" Revision="1" RightToLeft="0"> <Strings> <String Name="Active">Active</String> <String Name="ActiveSearchString">Enabled / Search String</String> Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-09-10 19:03:10 UTC (rev 646) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-09-11 13:41:15 UTC (rev 647) @@ -135,7 +135,7 @@ setDefault(IGNORE_BOT_PMS, false); setDefault(LIST_DUPES, true); setDefault(BUFFER_SIZE, 64); - setDefault(HUBLIST_SERVERS, "http://hubs.bandicoot.nl/;http://www.hublist.org/PublicHubList.xml.bz2"); + setDefault(HUBLIST_SERVERS, "http://home.bandicoot.nl/adchublist.xml.bz2;http://www.hublist.org/PublicHubList.xml.bz2"); setDefault(DOWNLOAD_SLOTS, 3); setDefault(MAX_DOWNLOAD_SPEED, 0); setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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] |
From: <arn...@us...> - 2006-09-18 21:43:01
|
Revision: 650 http://svn.sourceforge.net/dcplusplus/?rev=650&view=rev Author: arnetheduck Date: 2006-09-18 14:40:58 -0700 (Mon, 18 Sep 2006) Log Message: ----------- Connection fixes, other small stuff Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/ConnectionManager.h dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/FavoriteManager.cpp dcplusplus/trunk/client/FavoriteManager.h dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/Speaker.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/yassl/README dcplusplus/trunk/yassl/include/buffer.hpp dcplusplus/trunk/yassl/include/cert_wrapper.hpp dcplusplus/trunk/yassl/include/crypto_wrapper.hpp dcplusplus/trunk/yassl/include/factory.hpp dcplusplus/trunk/yassl/include/handshake.hpp dcplusplus/trunk/yassl/include/lock.hpp dcplusplus/trunk/yassl/include/log.hpp dcplusplus/trunk/yassl/include/openssl/ssl.h dcplusplus/trunk/yassl/include/socket_wrapper.hpp dcplusplus/trunk/yassl/include/timer.hpp dcplusplus/trunk/yassl/include/yassl_error.hpp dcplusplus/trunk/yassl/include/yassl_imp.hpp dcplusplus/trunk/yassl/include/yassl_int.hpp dcplusplus/trunk/yassl/include/yassl_types.hpp dcplusplus/trunk/yassl/mySTL/algorithm.hpp dcplusplus/trunk/yassl/mySTL/helpers.hpp dcplusplus/trunk/yassl/mySTL/list.hpp dcplusplus/trunk/yassl/mySTL/memory.hpp dcplusplus/trunk/yassl/mySTL/pair.hpp dcplusplus/trunk/yassl/mySTL/stdexcept.hpp dcplusplus/trunk/yassl/mySTL/vector.hpp dcplusplus/trunk/yassl/src/buffer.cpp dcplusplus/trunk/yassl/src/cert_wrapper.cpp dcplusplus/trunk/yassl/src/crypto_wrapper.cpp dcplusplus/trunk/yassl/src/handshake.cpp dcplusplus/trunk/yassl/src/lock.cpp dcplusplus/trunk/yassl/src/log.cpp dcplusplus/trunk/yassl/src/socket_wrapper.cpp dcplusplus/trunk/yassl/src/ssl.cpp dcplusplus/trunk/yassl/src/template_instnt.cpp dcplusplus/trunk/yassl/src/timer.cpp dcplusplus/trunk/yassl/src/yassl.cpp dcplusplus/trunk/yassl/src/yassl_error.cpp dcplusplus/trunk/yassl/src/yassl_imp.cpp dcplusplus/trunk/yassl/src/yassl_int.cpp dcplusplus/trunk/yassl/taocrypt/include/aes.hpp dcplusplus/trunk/yassl/taocrypt/include/algebra.hpp dcplusplus/trunk/yassl/taocrypt/include/arc4.hpp dcplusplus/trunk/yassl/taocrypt/include/asn.hpp dcplusplus/trunk/yassl/taocrypt/include/block.hpp dcplusplus/trunk/yassl/taocrypt/include/blowfish.hpp dcplusplus/trunk/yassl/taocrypt/include/coding.hpp dcplusplus/trunk/yassl/taocrypt/include/des.hpp dcplusplus/trunk/yassl/taocrypt/include/dh.hpp dcplusplus/trunk/yassl/taocrypt/include/dsa.hpp dcplusplus/trunk/yassl/taocrypt/include/error.hpp dcplusplus/trunk/yassl/taocrypt/include/file.hpp dcplusplus/trunk/yassl/taocrypt/include/hash.hpp dcplusplus/trunk/yassl/taocrypt/include/hmac.hpp dcplusplus/trunk/yassl/taocrypt/include/integer.hpp dcplusplus/trunk/yassl/taocrypt/include/kernelc.hpp dcplusplus/trunk/yassl/taocrypt/include/md2.hpp dcplusplus/trunk/yassl/taocrypt/include/md4.hpp dcplusplus/trunk/yassl/taocrypt/include/md5.hpp dcplusplus/trunk/yassl/taocrypt/include/misc.hpp dcplusplus/trunk/yassl/taocrypt/include/modarith.hpp dcplusplus/trunk/yassl/taocrypt/include/modes.hpp dcplusplus/trunk/yassl/taocrypt/include/pwdbased.hpp dcplusplus/trunk/yassl/taocrypt/include/random.hpp dcplusplus/trunk/yassl/taocrypt/include/ripemd.hpp dcplusplus/trunk/yassl/taocrypt/include/rsa.hpp dcplusplus/trunk/yassl/taocrypt/include/runtime.hpp dcplusplus/trunk/yassl/taocrypt/include/sha.hpp dcplusplus/trunk/yassl/taocrypt/include/twofish.hpp dcplusplus/trunk/yassl/taocrypt/include/type_traits.hpp dcplusplus/trunk/yassl/taocrypt/include/types.hpp dcplusplus/trunk/yassl/taocrypt/src/aes.cpp dcplusplus/trunk/yassl/taocrypt/src/aestables.cpp dcplusplus/trunk/yassl/taocrypt/src/algebra.cpp dcplusplus/trunk/yassl/taocrypt/src/arc4.cpp dcplusplus/trunk/yassl/taocrypt/src/asn.cpp dcplusplus/trunk/yassl/taocrypt/src/bftables.cpp dcplusplus/trunk/yassl/taocrypt/src/blowfish.cpp dcplusplus/trunk/yassl/taocrypt/src/coding.cpp dcplusplus/trunk/yassl/taocrypt/src/des.cpp dcplusplus/trunk/yassl/taocrypt/src/dh.cpp dcplusplus/trunk/yassl/taocrypt/src/dsa.cpp dcplusplus/trunk/yassl/taocrypt/src/file.cpp dcplusplus/trunk/yassl/taocrypt/src/hash.cpp dcplusplus/trunk/yassl/taocrypt/src/integer.cpp dcplusplus/trunk/yassl/taocrypt/src/md2.cpp dcplusplus/trunk/yassl/taocrypt/src/md4.cpp dcplusplus/trunk/yassl/taocrypt/src/md5.cpp dcplusplus/trunk/yassl/taocrypt/src/misc.cpp dcplusplus/trunk/yassl/taocrypt/src/random.cpp dcplusplus/trunk/yassl/taocrypt/src/ripemd.cpp dcplusplus/trunk/yassl/taocrypt/src/rsa.cpp dcplusplus/trunk/yassl/taocrypt/src/sha.cpp dcplusplus/trunk/yassl/taocrypt/src/template_instnt.cpp dcplusplus/trunk/yassl/taocrypt/src/tftables.cpp dcplusplus/trunk/yassl/taocrypt/src/twofish.cpp Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/Example.xml 2006-09-18 21:40:58 UTC (rev 650) @@ -563,7 +563,7 @@ <String Name="SystemLog">System Log</String> <String Name="Tag">Tag</String> <String Name="TargetFilenameTooLong">Target filename too long</String> - <String Name="TcpPortBusy">Unable to open TCP port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP port</String> + <String Name="TcpPortBusy">Unable to open TCP/TLS port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP/TLS port</String> <String Name="Tib">TiB</String> <String Name="Time">Time</String> <String Name="TimeLeft">Time left</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/changelog.txt 2006-09-18 21:40:58 UTC (rev 650) @@ -4,7 +4,11 @@ * 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 +* Sources in the queue with no TTH support will no longer appear +* Files without TTH in the queue will be removed (finish downloads with an older version) +* [ADC] Fixed support for uncompressed files.xml as well as proper files.xml.bz2 support +* Some socket code cleanup +* Removed broken nick save code -- 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 Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -431,6 +431,10 @@ } } +void ClientManager::on(Load, SimpleXML&) throw() { + users.insert(make_pair(getMe()->getCID(), getMe())); +} + void ClientManager::on(TimerManagerListener::Minute, u_int32_t /* aTick */) throw() { Lock l(cs); @@ -449,43 +453,6 @@ } } -void ClientManager::save() { - Lock l(cs); - - try { - string tmp; - - File ff(getUsersFile() + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE); - BufferedOutputStream<false> f(&ff); - - f.write(SimpleXML::utf8Header); - f.write(LIT("<Users Version=\"1\">\r\n")); - for(UserIter i = users.begin(); i != users.end(); ++i) { - User::Ptr& p = i->second; - if(p->isSet(User::SAVE_NICK) && !p->getCID().isZero() && !p->getFirstNick().empty()) { - f.write(LIT("\t<User CID=\"")); - f.write(p->getCID().toBase32()); - f.write(LIT("\" Nick=\"")); - f.write(SimpleXML::escape(p->getFirstNick(), tmp, true)); - f.write(LIT("\"/>\r\n")); - } - } - - f.write("</Users>\r\n"); - f.flush(); - ff.close(); - File::deleteFile(getUsersFile()); - File::renameFile(getUsersFile() + ".tmp", getUsersFile()); - - } catch(const FileException&) { - // ... - } -} - -void ClientManager::on(Save, SimpleXML*) throw() { - save(); -} - User::Ptr& ClientManager::getMe() { if(!me) { Lock l(cs); @@ -509,29 +476,6 @@ return CID(tiger.finalize()); } -void ClientManager::on(Load, SimpleXML*) throw() { - users.insert(make_pair(getMe()->getCID(), getMe())); - - try { - SimpleXML xml; - xml.fromXML(File(getUsersFile(), File::READ, File::OPEN).read()); - if(xml.findChild("Users") && xml.getChildAttrib("Version") == "1") { - xml.stepIn(); - while(xml.findChild("User")) { - const string& cid = xml.getChildAttrib("CID"); - const string& nick = xml.getChildAttrib("Nick"); - if(cid.length() != 39 || nick.empty()) - continue; - User::Ptr p(new User(CID(cid))); - p->setFirstNick(xml.getChildData()); - users.insert(make_pair(p->getCID(), p)); - } - } - } catch(const Exception& e) { - dcdebug("Error loading Users.xml: %s\n", e.getError().c_str()); - } -} - void ClientManager::on(Failed, Client* client, const string&) throw() { FavoriteManager::getInstance()->removeUserCommand(client->getHubUrl()); fire(ClientManagerListener::ClientDisconnected(), client); Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ClientManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -96,7 +96,6 @@ CID getMyCID(); const CID& getMyPID(); - void save(); private: typedef HASH_MAP<string, User::Ptr> LegacyMap; typedef LegacyMap::iterator LegacyIter; @@ -133,13 +132,10 @@ TimerManager::getInstance()->removeListener(this); } - string getUsersFile() { return Util::getConfigPath() + "Users.xml"; } - void updateCachedIp(); // SettingsManagerListener - virtual void on(Load, SimpleXML*) throw(); - virtual void on(Save, SimpleXML*) throw(); + virtual void on(Load, SimpleXML&); // ClientListener virtual void on(Connected, Client* c) throw() { fire(ClientManagerListener::ClientConnected(), c); } Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -31,7 +31,7 @@ #include "UserConnection.h" -ConnectionManager::ConnectionManager() : port(0), securePort(0), floodCounter(0), server(0), secureServer(0), shuttingDown(false) { +ConnectionManager::ConnectionManager() : floodCounter(0), server(0), secureServer(0), shuttingDown(false) { TimerManager::getInstance()->addListener(this); features.push_back(UserConnection::FEATURE_MINISLOTS); @@ -44,50 +44,19 @@ 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); - - unsigned short firstPort = lastPort; - +void ConnectionManager::listen() throw(SocketException){ disconnect(); + unsigned short port = static_cast<unsigned short>(SETTING(TCP_PORT)); - while(true) { - try { - server = new Server(false, lastPort, SETTING(BIND_ADDRESS)); - port = lastPort; - break; - } catch(const Exception&) { - short newPort = (short)((lastPort == 32000) ? 1025 : lastPort + 1); - if(!SettingsManager::getInstance()->isDefault(SettingsManager::TCP_PORT) || (firstPort == newPort)) { - throw Exception("Could not find a suitable free port"); - } - lastPort = newPort; - } - } + server = new Server(false, port, SETTING(BIND_ADDRESS)); if(!CryptoManager::getInstance()->TLSOk()) { return; } - lastPort = (unsigned short)SETTING(TLS_PORT); - firstPort = lastPort; - while(true) { - try { - secureServer = new Server(true, lastPort, SETTING(BIND_ADDRESS)); - securePort = lastPort; - break; - } catch(const Exception&) { - short newPort = (short)((lastPort == 32000) ? 1025 : lastPort + 1); - if(!SettingsManager::getInstance()->isDefault(SettingsManager::TCP_PORT) || (firstPort == newPort)) { - throw Exception("Could not find a suitable free port"); - } - lastPort = newPort; - } - } + port = static_cast<unsigned short>(SETTING(TLS_PORT)); + + secureServer = new Server(true, port, SETTING(BIND_ADDRESS)); } /** @@ -252,9 +221,9 @@ static const u_int32_t FLOOD_TRIGGER = 20000; static const u_int32_t FLOOD_ADD = 2000; -ConnectionManager::Server::Server(bool secure_, short port, const string& ip /* = "0.0.0.0" */) : secure(secure_), die(false) { +ConnectionManager::Server::Server(bool secure_, short aPort, const string& ip /* = "0.0.0.0" */) : port(0), secure(secure_), die(false) { sock.create(); - sock.bind(port, ip); + port = sock.bind(aPort, ip); sock.listen(); start(); @@ -345,6 +314,14 @@ } } +void ConnectionManager::disconnect() throw() { + delete server; + delete secureServer; + + server = secureServer = 0; +} + + void ConnectionManager::on(AdcCommand::SUP, UserConnection* aSource, const AdcCommand& cmd) throw() { if(aSource->getState() != UserConnection::STATE_SUPNICK) { // Already got this once, ignore...@todo fix support updates @@ -359,6 +336,11 @@ string feat = i->substr(2); if(feat == UserConnection::FEATURE_ADC_BASE) { baseOk = true; + // ADC clients must support all these... + aSource->setFlag(UserConnection::FLAG_SUPPORTS_ADCGET); + aSource->setFlag(UserConnection::FLAG_SUPPORTS_MINISLOTS); + aSource->setFlag(UserConnection::FLAG_SUPPORTS_TTHF); + aSource->setFlag(UserConnection::FLAG_SUPPORTS_TTHL); // For compatibility with older clients... aSource->setFlag(UserConnection::FLAG_SUPPORTS_XML_BZLIST); } else if(feat == UserConnection::FEATURE_ZLIB_GET) { Modified: dcplusplus/trunk/client/ConnectionManager.h =================================================================== --- dcplusplus/trunk/client/ConnectionManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ConnectionManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -33,6 +33,8 @@ #include "ConnectionManagerListener.h" +class SocketException; + class ConnectionQueueItem { public: typedef ConnectionQueueItem* Ptr; @@ -110,27 +112,23 @@ void shutdown(); /** Find a suitable port to listen on, and start doing it */ - void listen() throw(Exception); - void disconnect() throw() { - delete server; - delete secureServer; + void listen() throw(SocketException); + void disconnect() throw(); - server = secureServer = 0; - port = securePort = 0; - } - - unsigned short getPort() { return port; } - unsigned short getSecurePort() { return securePort; } + unsigned short getPort() { return static_cast<unsigned short>(server->getPort()); } + unsigned short getSecurePort() { return static_cast<unsigned short>(secureServer->getPort()); } private: class Server : public Thread { public: Server(bool secure_, short port, const string& ip = "0.0.0.0"); + short getPort() { return port; } virtual ~Server() { die = true; join(); } private: virtual int run() throw(); Socket sock; + short port; bool secure; bool die; }; @@ -138,8 +136,6 @@ friend class Server; CriticalSection cs; - unsigned short port; - unsigned short securePort; /** All ConnectionQueueItems */ ConnectionQueueItem::List downloads; Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -49,7 +49,7 @@ const string DownloadManager::USER_LIST_NAME_BZ = "files.xml.bz2"; Download::Download() throw() : file(NULL), -crcCalc(NULL), tth(NULL), treeValid(false) { +crcCalc(NULL), treeValid(false) { } Download::Download(QueueItem* qi) throw() : @@ -63,7 +63,7 @@ setFlag(Download::FLAG_RESUME); } -AdcCommand Download::getCommand(bool zlib, bool tthf) { +AdcCommand Download::getCommand(bool zlib) { AdcCommand cmd(AdcCommand::CMD_GET); if(isSet(FLAG_TREE_DOWNLOAD)) { cmd.addParam("tthl"); @@ -72,15 +72,15 @@ } else { cmd.addParam("file"); } - if(tthf) { + if(isSet(FLAG_PARTIAL_LIST) || isSet(FLAG_USER_LIST)) { + cmd.addParam(Util::toAdcFile(getSource())); + } else { cmd.addParam("TTH/" + getTTH().toBase32()); - } else { - cmd.addParam(Util::toAdcFile(getSource())); } cmd.addParam(Util::toString(getPos())); cmd.addParam(Util::toString(getSize() - getPos())); - if(zlib && getSize() != -1 && BOOLSETTING(COMPRESS_TRANSFERS)) { + if(zlib && BOOLSETTING(COMPRESS_TRANSFERS)) { cmd.addParam("ZL1"); } @@ -91,7 +91,7 @@ TimerManager::getInstance()->addListener(this); } -~DownloadManager::DownloadManager() throw() { +DownloadManager::~DownloadManager() throw() { TimerManager::getInstance()->removeListener(this); while(true) { { @@ -246,7 +246,7 @@ } void DownloadManager::addConnection(UserConnection::Ptr conn) { - if(!conn->isSet(UserConnection::FLAG_SUPPORTS_TTHF)) { + if(!conn->isSet(UserConnection::FLAG_SUPPORTS_TTHF) || !conn->isSet(UserConnection::FLAG_SUPPORTS_ADCGET)) { // Can't download from these... QueueManager::getInstance()->removeSource(conn->getUser(), QueueItem::Source::FLAG_NO_TTHF); removeConnection(conn); @@ -333,7 +333,7 @@ downloads.push_back(d); } - aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET), !d->isSet(Download::FLAG_USER_LIST))); + aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET))); } class DummyOutputStream : public OutputStream { @@ -498,10 +498,10 @@ string target = d->getDownloadTarget(); File::ensureDirectory(target); if(d->isSet(Download::FLAG_USER_LIST)) { - if(!aSource->isSet(UserConnection::FLAG_NMDC) || aSource->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST)) { + if(aSource->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST)) { target += ".xml.bz2"; } else { - target += ".DcLst"; + target += ".xml"; } } Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/DownloadManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -90,7 +90,7 @@ TigerTree& getTigerTree() { return tt; } string& getPFS() { return pfs; } /** @internal */ - AdcCommand getCommand(bool zlib, bool tthf); + AdcCommand getCommand(bool zlib); typedef CalcOutputStream<CRC32Filter, true> CrcOS; GETSET(string, source, Source); Modified: dcplusplus/trunk/client/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/client/FavoriteManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/FavoriteManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -125,7 +125,6 @@ void FavoriteManager::addFavoriteUser(User::Ptr& aUser) { Lock l(cs); if(users.find(aUser->getCID()) == users.end()) { - aUser->setFlag(User::SAVE_NICK); StringList urls = ClientManager::getInstance()->getHubs(aUser->getCID()); StringList nicks = ClientManager::getInstance()->getNicks(aUser->getCID()); @@ -345,7 +344,6 @@ xml.addTag("Users"); xml.stepIn(); for(FavoriteMap::iterator j = users.begin(); j != users.end(); ++j) { - j->second.getUser()->setFlag(User::SAVE_NICK); xml.addTag("User"); xml.addChildAttrib("LastSeen", j->second.getLastSeen()); xml.addChildAttrib("GrantSlot", j->second.isSet(FavoriteUser::FLAG_GRANTSLOT)); @@ -418,7 +416,7 @@ if(xml.findChild("Favorites")) { xml.stepIn(); - load(&xml); + load(xml); xml.stepOut(); } } catch(const Exception& e) { @@ -426,37 +424,37 @@ } } -void FavoriteManager::load(SimpleXML* aXml) { +void FavoriteManager::load(SimpleXML& aXml) { dontSave = true; - aXml->resetCurrentChild(); - if(aXml->findChild("Hubs")) { - aXml->stepIn(); - while(aXml->findChild("Hub")) { + aXml.resetCurrentChild(); + if(aXml.findChild("Hubs")) { + aXml.stepIn(); + while(aXml.findChild("Hub")) { FavoriteHubEntry* e = new FavoriteHubEntry(); - e->setName(aXml->getChildAttrib("Name")); - e->setConnect(aXml->getBoolChildAttrib("Connect")); - e->setDescription(aXml->getChildAttrib("Description")); - e->setNick(aXml->getChildAttrib("Nick")); - e->setPassword(aXml->getChildAttrib("Password")); - e->setServer(aXml->getChildAttrib("Server")); - e->setUserDescription(aXml->getChildAttrib("UserDescription")); - e->setBottom((u_int16_t)aXml->getIntChildAttrib("Bottom") ); - e->setTop((u_int16_t)aXml->getIntChildAttrib("Top")); - e->setRight((u_int16_t)aXml->getIntChildAttrib("Right")); - e->setLeft((u_int16_t)aXml->getIntChildAttrib("Left")); + e->setName(aXml.getChildAttrib("Name")); + e->setConnect(aXml.getBoolChildAttrib("Connect")); + e->setDescription(aXml.getChildAttrib("Description")); + e->setNick(aXml.getChildAttrib("Nick")); + e->setPassword(aXml.getChildAttrib("Password")); + e->setServer(aXml.getChildAttrib("Server")); + e->setUserDescription(aXml.getChildAttrib("UserDescription")); + e->setBottom((u_int16_t)aXml.getIntChildAttrib("Bottom") ); + e->setTop((u_int16_t)aXml.getIntChildAttrib("Top")); + e->setRight((u_int16_t)aXml.getIntChildAttrib("Right")); + e->setLeft((u_int16_t)aXml.getIntChildAttrib("Left")); favoriteHubs.push_back(e); } - aXml->stepOut(); + aXml.stepOut(); } - aXml->resetCurrentChild(); - if(aXml->findChild("Users")) { - aXml->stepIn(); - while(aXml->findChild("User")) { + aXml.resetCurrentChild(); + if(aXml.findChild("Users")) { + aXml.stepIn(); + while(aXml.findChild("User")) { User::Ptr u; - const string& cid = aXml->getChildAttrib("CID"); - const string& nick = aXml->getChildAttrib("Nick"); - const string& hubUrl = aXml->getChildAttrib("URL"); + const string& cid = aXml.getChildAttrib("CID"); + const string& nick = aXml.getChildAttrib("Nick"); + const string& hubUrl = aXml.getChildAttrib("URL"); if(cid.length() != 39) { if(nick.empty() || hubUrl.empty()) @@ -469,35 +467,34 @@ } FavoriteMap::iterator i = users.insert(make_pair(u->getCID(), FavoriteUser(u, nick, hubUrl))).first; - if(aXml->getBoolChildAttrib("GrantSlot")) + if(aXml.getBoolChildAttrib("GrantSlot")) i->second.setFlag(FavoriteUser::FLAG_GRANTSLOT); - i->second.setLastSeen((u_int32_t)aXml->getIntChildAttrib("LastSeen")); - i->second.setDescription(aXml->getChildAttrib("UserDescription")); + i->second.setLastSeen((u_int32_t)aXml.getIntChildAttrib("LastSeen")); + i->second.setDescription(aXml.getChildAttrib("UserDescription")); - i->second.getUser()->setFlag(User::SAVE_NICK); } - aXml->stepOut(); + aXml.stepOut(); } - aXml->resetCurrentChild(); - if(aXml->findChild("UserCommands")) { - aXml->stepIn(); - while(aXml->findChild("UserCommand")) { - addUserCommand(aXml->getIntChildAttrib("Type"), aXml->getIntChildAttrib("Context"), - 0, aXml->getChildAttrib("Name"), aXml->getChildAttrib("Command"), aXml->getChildAttrib("Hub")); + aXml.resetCurrentChild(); + if(aXml.findChild("UserCommands")) { + aXml.stepIn(); + while(aXml.findChild("UserCommand")) { + addUserCommand(aXml.getIntChildAttrib("Type"), aXml.getIntChildAttrib("Context"), + 0, aXml.getChildAttrib("Name"), aXml.getChildAttrib("Command"), aXml.getChildAttrib("Hub")); } - aXml->stepOut(); + aXml.stepOut(); } //Favorite download to dirs - aXml->resetCurrentChild(); - if(aXml->findChild("FavoriteDirs")) { - aXml->stepIn(); - while(aXml->findChild("Directory")) { - string virt = aXml->getChildAttrib("Name"); - string d(aXml->getChildData()); + aXml.resetCurrentChild(); + if(aXml.findChild("FavoriteDirs")) { + aXml.stepIn(); + while(aXml.findChild("Directory")) { + string virt = aXml.getChildAttrib("Name"); + string d(aXml.getChildData()); FavoriteManager::getInstance()->addFavoriteDir(d, virt); } - aXml->stepOut(); + aXml.stepOut(); } dontSave = false; Modified: dcplusplus/trunk/client/FavoriteManager.h =================================================================== --- dcplusplus/trunk/client/FavoriteManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/FavoriteManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -269,11 +269,11 @@ void onHttpFinished() throw(); // SettingsManagerListener - virtual void on(SettingsManagerListener::Load, SimpleXML* xml) throw() { + virtual void on(SettingsManagerListener::Load, SimpleXML& xml) throw() { load(xml); } - void load(SimpleXML* aXml); + void load(SimpleXML& aXml); string getConfigFile() { return Util::getConfigPath() + "Favorites.xml"; } }; Modified: dcplusplus/trunk/client/QueueItem.h =================================================================== --- dcplusplus/trunk/client/QueueItem.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/QueueItem.h 2006-09-18 21:40:58 UTC (rev 650) @@ -188,7 +188,7 @@ if(isSet(QueueItem::FLAG_XML_BZLIST)) { return getTarget() + ".xml.bz2"; } else { - return getTarget() + ".DcLst"; + return getTarget() + ".xml"; } } Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -561,7 +561,6 @@ wantConnection = false; } else { userQueue.add(qi, aUser); - aUser->setFlag(User::SAVE_NICK); } fire(QueueManagerListener::SourcesUpdated(), qi); @@ -1143,8 +1142,6 @@ File::deleteFile(getQueueFile()); File::renameFile(getQueueFile() + ".tmp", getQueueFile()); - ClientManager::getInstance()->save(); - dirty = false; } catch(const FileException&) { // ... Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -30,9 +30,9 @@ } void SSLSocket::connect(const string& aIp, short aPort) throw(SocketException) { + Socket::setBlocking(true); Socket::connect(aIp, aPort); - setBlocking(true); if(ssl) SSL_free(ssl); @@ -43,12 +43,12 @@ checkSSL(SSL_set_fd(ssl, sock)); checkSSL(SSL_connect(ssl)); dcdebug("Connected to SSL server using %s\n", SSL_get_cipher(ssl)); + Socket::setBlocking(false); } void SSLSocket::accept(const Socket& listeningSocket) throw(SocketException) { Socket::accept(listeningSocket); - setBlocking(true); if(ssl) SSL_free(ssl); Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -371,7 +371,7 @@ File::ensureDirectory(SETTING(TLS_TRUSTED_CERTIFICATES_PATH)); - fire(SettingsManagerListener::Load(), &xml); + fire(SettingsManagerListener::Load(), xml); xml.stepOut(); @@ -422,7 +422,7 @@ } xml.stepOut(); - fire(SettingsManagerListener::Save(), &xml); + fire(SettingsManagerListener::Save(), xml); try { File out(aFileName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/SettingsManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -37,8 +37,8 @@ typedef X<0> Load; typedef X<1> Save; - virtual void on(Load, SimpleXML*) throw() { } - virtual void on(Save, SimpleXML*) throw() { } + virtual void on(Load, SimpleXML&) throw() { } + virtual void on(Save, SimpleXML&) throw() { } }; class SettingsManager : public Singleton<SettingsManager>, public Speaker<SettingsManagerListener> Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -248,14 +248,14 @@ return tmp; } -void ShareManager::load(SimpleXML* aXml) { +void ShareManager::load(SimpleXML& aXml) { WLock<> l(cs); - if(aXml->findChild("Share")) { - aXml->stepIn(); - while(aXml->findChild("Directory")) { - const string& virt = aXml->getChildAttrib("Virtual"); - string d(aXml->getChildData()), newVirt; + if(aXml.findChild("Share")) { + aXml.stepIn(); + while(aXml.findChild("Directory")) { + const string& virt = aXml.getChildAttrib("Virtual"); + string d(aXml.getChildData()), newVirt; if(d[d.length() - 1] != PATH_SEPARATOR) d += PATH_SEPARATOR; @@ -278,7 +278,7 @@ virtualMap.push_back(make_pair(newVirt, d)); } } - aXml->stepOut(); + aXml.stepOut(); } } @@ -362,16 +362,16 @@ return false; } -void ShareManager::save(SimpleXML* aXml) { +void ShareManager::save(SimpleXML& aXml) { RLock<> l(cs); - aXml->addTag("Share"); - aXml->stepIn(); + aXml.addTag("Share"); + aXml.stepIn(); for(StringPairIter i = virtualMap.begin(); i != virtualMap.end(); ++i) { - aXml->addTag("Directory", i->second); - aXml->addChildAttrib("Virtual", i->first); + aXml.addTag("Directory", i->second); + aXml.addChildAttrib("Virtual", i->first); } - aXml->stepOut(); + aXml.stepOut(); } void ShareManager::addDirectory(const string& aDirectory, const string& aName) throw(ShareException) { Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/ShareManager.h 2006-09-18 21:40:58 UTC (rev 650) @@ -308,17 +308,17 @@ virtual void on(HashManagerListener::TTHDone, const string& fname, const TTHValue& root) throw(); // SettingsManagerListener - virtual void on(SettingsManagerListener::Save, SimpleXML* xml) throw() { + virtual void on(SettingsManagerListener::Save, SimpleXML& xml) throw() { save(xml); } - virtual void on(SettingsManagerListener::Load, SimpleXML* xml) throw() { + virtual void on(SettingsManagerListener::Load, SimpleXML& xml) throw() { load(xml); } // TimerManagerListener virtual void on(TimerManagerListener::Minute, u_int32_t tick) throw(); - void load(SimpleXML* aXml); - void save(SimpleXML* aXml); + void load(SimpleXML& aXml); + void save(SimpleXML& aXml); }; Modified: dcplusplus/trunk/client/Socket.cpp =================================================================== --- dcplusplus/trunk/client/Socket.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Socket.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -97,7 +97,7 @@ } -void Socket::bind(short aPort, const string& aIp /* = 0.0.0.0 */) throw (SocketException){ +short Socket::bind(short aPort, const string& aIp /* = 0.0.0.0 */) throw (SocketException){ sockaddr_in sock_addr; sock_addr.sin_family = AF_INET; @@ -108,6 +108,9 @@ sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); check(::bind(sock, (sockaddr *)&sock_addr, sizeof(sock_addr))); } + int size = sizeof(sock_addr); + getsockname(sock, (sockaddr*)&sock_addr, &size); + return ntohs(sock_addr.sin_port); } void Socket::listen() throw(SocketException) { Modified: dcplusplus/trunk/client/Socket.h =================================================================== --- dcplusplus/trunk/client/Socket.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Socket.h 2006-09-18 21:40:58 UTC (rev 650) @@ -169,7 +169,7 @@ virtual void create(int aType = TYPE_TCP) throw(SocketException); /** Binds a socket to a certain local port and possibly IP. */ - virtual void bind(short aPort = 0, const string& aIp = "0.0.0.0") throw(SocketException); + virtual short bind(short aPort = 0, const string& aIp = "0.0.0.0") throw(SocketException); virtual void listen() throw(SocketException); virtual void accept(const Socket& listeningSocket) throw(SocketException); Modified: dcplusplus/trunk/client/Speaker.h =================================================================== --- dcplusplus/trunk/client/Speaker.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Speaker.h 2006-09-18 21:40:58 UTC (rev 650) @@ -51,6 +51,14 @@ (*i)->on(type, p1); } } + template<typename T0, class T1> + void fire(T0 type, T1& p1) throw() { + Lock l(listenerCS); + tmp = listeners; + for(ListenerIter i=tmp.begin(); i != tmp.end(); ++i ) { + (*i)->on(type, p1); + } + } template<typename T0, class T1, class T2> void fire(T0 type, const T1& p1, const T2& p2) throw() { Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -564,7 +564,7 @@ "System Log", "Tag", "Target filename too long", -"Unable to open TCP port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP port", +"Unable to open TCP/TLS port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP/TLS port", "TiB", "Time", "Time left", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/StringDefs.h 2006-09-18 21:40:58 UTC (rev 650) @@ -567,7 +567,7 @@ SYSTEM_LOG, // "System Log" TAG, // "Tag" TARGET_FILENAME_TOO_LONG, // "Target filename too long" - TCP_PORT_BUSY, // "Unable to open TCP port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP port" + TCP_PORT_BUSY, // "Unable to open TCP/TLS port. File transfers will not work correctly until you change settings or turn off any application that might be using the TCP/TLS port" TiB, // "TiB" TIME, // "Time" TIME_LEFT, // "Time left" Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -166,7 +166,7 @@ bool isFavorite = FavoriteManager::getInstance()->hasSlot(aSource->getUser()); if(!(hasReserved || isFavorite || getFreeSlots() > 0 || getAutoSlot())) { - bool supportsFree = aSource->isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS) || !aSource->isSet(UserConnection::FLAG_NMDC); + bool supportsFree = aSource->isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS); bool allowedFree = aSource->isSet(UserConnection::FLAG_HASEXTRASLOT) || aSource->isSet(UserConnection::FLAG_OP) || getFreeExtraSlots() > 0; if(free && supportsFree && allowedFree) { extraSlot = true; Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/User.h 2006-09-18 21:40:58 UTC (rev 650) @@ -40,7 +40,6 @@ NMDC_BIT, BOT_BIT, TTH_GET_BIT, - SAVE_NICK_BIT, TLS_BIT }; @@ -52,7 +51,6 @@ NMDC = 1<<NMDC_BIT, BOT = 1<<BOT_BIT, TTH_GET = 1<<TTH_GET_BIT, //< User supports getting files by tth -> don't have path in queue... - SAVE_NICK = 1<<SAVE_NICK_BIT, //< Save cid->nick association TLS = 1<<TLS_BIT //< Client supports SSL }; Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/client/Util.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -941,7 +941,7 @@ } string Util::toAdcFile(const string& file) { - if(file == "files.xml.bz2" || file == "MyList.DcLst") + if(file == "files.xml.bz2" || file == "files.xml") return file; string ret; Modified: dcplusplus/trunk/windows/MainFrm.cpp =================================================================== --- dcplusplus/trunk/windows/MainFrm.cpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/windows/MainFrm.cpp 2006-09-18 21:40:58 UTC (rev 650) @@ -1083,7 +1083,6 @@ if(qi->isSet(QueueItem::FLAG_CLIENT_VIEW)) { if(qi->isSet(QueueItem::FLAG_USER_LIST)) { // This is a file listing, show it... - DirectoryListInfo* i = new DirectoryListInfo(qi->getCurrent()->getUser(), Text::toT(qi->getListName()), speed); PostMessage(WM_SPEAKER, DOWNLOAD_LISTING, (LPARAM)i); Modified: dcplusplus/trunk/yassl/README =================================================================== --- dcplusplus/trunk/yassl/README 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/README 2006-09-18 21:40:58 UTC (rev 650) @@ -1,7 +1,18 @@ -yaSSL Release notes, version 1.3.7 (06/26/06) +yaSSL Release notes, version 1.4.0 (08/13/06) This release of yaSSL contains bug fixes, portability enhancements, + nonblocking connect and accept, better OpenSSL error mapping, and + certificate caching for session resumption. + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + +********************yaSSL Release notes, version 1.3.7 (06/26/06) + + + This release of yaSSL contains bug fixes, portability enhancements, and libcurl 7.15.4 support (any newer versions may not build). See normal build instructions below under 1.0.6. Modified: dcplusplus/trunk/yassl/include/buffer.hpp =================================================================== --- dcplusplus/trunk/yassl/include/buffer.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/buffer.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/cert_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/cert_wrapper.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/cert_wrapper.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -116,6 +120,7 @@ void setVerifyNone(); void setFailNoCert(); void setSendVerify(); + void setPeerX509(X509*); private: CertManager(const CertManager&); // hide copy CertManager& operator=(const CertManager&); // and assign Modified: dcplusplus/trunk/yassl/include/crypto_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/crypto_wrapper.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/crypto_wrapper.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -36,6 +40,7 @@ #define yaSSL_CRYPTO_WRAPPER_HPP #include "yassl_types.hpp" +#include <stdio.h> // FILE namespace yaSSL { @@ -410,9 +415,10 @@ class x509; -x509* PemToDer(const char*, CertType); +x509* PemToDer(FILE*, CertType); + } // naemspace #endif // yaSSL_CRYPTO_WRAPPER_HPP Modified: dcplusplus/trunk/yassl/include/factory.hpp =================================================================== --- dcplusplus/trunk/yassl/include/factory.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/factory.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/handshake.hpp =================================================================== --- dcplusplus/trunk/yassl/include/handshake.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/handshake.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/lock.hpp =================================================================== --- dcplusplus/trunk/yassl/include/lock.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/lock.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/log.hpp =================================================================== --- dcplusplus/trunk/yassl/include/log.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/log.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/openssl/ssl.h =================================================================== --- dcplusplus/trunk/yassl/include/openssl/ssl.h 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/openssl/ssl.h 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -36,6 +40,10 @@ #include "opensslv.h" /* for version number */ #include "rsa.h" + +#define YASSL_VERSION "1.4.0" + + #if defined(__cplusplus) extern "C" { #endif @@ -497,7 +505,9 @@ #define V_ASN1_UTF8STRING 12 #define GEN_DNS 2 +#define CERTFICATE_ERROR 0x14090086 /* SSLv3 error */ + typedef struct MD4_CTX { int buffer[32]; /* big enough to hold, check size in Init */ } MD4_CTX; Modified: dcplusplus/trunk/yassl/include/socket_wrapper.hpp =================================================================== --- dcplusplus/trunk/yassl/include/socket_wrapper.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/socket_wrapper.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -67,6 +71,7 @@ class Socket { socket_t socket_; // underlying socket descriptor bool wouldBlock_; // for non-blocking data + bool blocking_; // is option set public: explicit Socket(socket_t s = INVALID_SOCKET); ~Socket(); @@ -80,6 +85,7 @@ bool wait(); bool WouldBlock() const; + bool IsBlocking() const; void closeSocket(); void shutDown(int how = SD_SEND); Modified: dcplusplus/trunk/yassl/include/timer.hpp =================================================================== --- dcplusplus/trunk/yassl/include/timer.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/timer.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/yassl_error.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_error.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_error.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/include/yassl_imp.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_imp.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_imp.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -622,6 +626,7 @@ bool send_server_key_; // server key exchange? bool master_clean_; // master secret clean? bool TLS_; // TLSv1 or greater + bool sessionID_Set_; // do we have a session ProtocolVersion version_; RandomPool& random_; @@ -664,9 +669,9 @@ char cipher_name_[MAX_SUITE_NAME]; char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME]; - Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion); + Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH); - void SetSuites(ProtocolVersion pv); + void SetSuites(ProtocolVersion pv, bool removeDH = false); void SetCipherNames(); private: Parameters(const Parameters&); // hide copy Modified: dcplusplus/trunk/yassl/include/yassl_int.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_int.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -36,7 +40,11 @@ #include "lock.hpp" #include "openssl/ssl.h" // ASN1_STRING and DH +#ifdef _POSIX_THREADS + #include <pthread.h> +#endif + namespace yaSSL { @@ -76,12 +84,35 @@ }; +// client connect state for nonblocking restart +enum ConnectState { + CONNECT_BEGIN = 0, + CLIENT_HELLO_SENT, + FIRST_REPLY_DONE, + FINISHED_DONE, + SECOND_REPLY_DONE +}; + + +// server accpet state for nonblocking restart +enum AcceptState { + ACCEPT_BEGIN = 0, + ACCEPT_FIRST_REPLY_DONE, + SERVER_HELLO_DONE, + ACCEPT_SECOND_REPLY_DONE, + ACCEPT_FINISHED_DONE, + ACCEPT_THIRD_REPLY_DONE +}; + + // combines all states class States { RecordLayerState recordLayer_; HandShakeState handshakeLayer_; ClientState clientState_; ServerState serverState_; + ConnectState connectState_; + AcceptState acceptState_; char errorString_[MAX_ERROR_SZ]; YasslError what_; public: @@ -91,6 +122,8 @@ const HandShakeState& getHandShake() const; const ClientState& getClient() const; const ServerState& getServer() const; + const ConnectState& GetConnect() const; + const AcceptState& GetAccept() const; const char* getString() const; YasslError What() const; @@ -98,6 +131,8 @@ HandShakeState& useHandShake(); ClientState& useClient(); ServerState& useServer(); + ConnectState& UseConnect(); + AcceptState& UseAccept(); char* useString(); void SetError(YasslError); private: @@ -138,8 +173,9 @@ X509_NAME(const char*, size_t sz); ~X509_NAME(); - char* GetName(); + const char* GetName() const; ASN1_STRING* GetEntry(int i); + size_t GetLength() const; private: X509_NAME(const X509_NAME&); // hide copy X509_NAME& operator=(const X509_NAME&); // and assign @@ -153,6 +189,9 @@ ~StringHolder(); ASN1_STRING* GetString(); +private: + StringHolder(const StringHolder&); // hide copy + StringHolder& operator=(const StringHolder&); // and assign }; @@ -172,6 +211,7 @@ ASN1_STRING* GetBefore(); ASN1_STRING* GetAfter(); + private: X509(const X509&); // hide copy X509& operator=(const X509&); // and assign @@ -198,21 +238,25 @@ uint bornOn_; // create time in seconds uint timeout_; // timeout in seconds RandomPool& random_; // will clean master secret + X509* peerX509_; public: explicit SSL_SESSION(RandomPool&); SSL_SESSION(const SSL&, RandomPool&); ~SSL_SESSION(); - const opaque* GetID() const; - const opaque* GetSecret() const; - const Cipher* GetSuite() const; - uint GetBornOn() const; - uint GetTimeOut() const; + const opaque* GetID() const; + const opaque* GetSecret() const; + const Cipher* GetSuite() const; + uint GetBornOn() const; + uint GetTimeOut() const; + X509* GetPeerX509() const; void SetTimeOut(uint); SSL_SESSION& operator=(const SSL_SESSION&); // allow assign for resumption private: SSL_SESSION(const SSL_SESSION&); // hide copy + + void CopyX509(X509*); }; @@ -237,8 +281,42 @@ }; +#ifdef _POSIX_THREADS + typedef pthread_t THREAD_ID_T; +#else + typedef DWORD THREAD_ID_T; +#endif + +// thread error data +struct ThreadError { + THREAD_ID_T threadID_; + int errorID_; +}; + + +// holds all errors +class Errors { + mySTL::list<ThreadError> list_; + Mutex mutex_; + + Errors() {} // only GetErrors can create +public: + int Lookup(bool peek); // self lookup + void Add(int); + void Remove(); // remove self + + ~Errors() {} + + friend Errors& GetErrors(); // singleton creator +private: + Errors(const Errors&); // hide copy + Errors& operator=(const Errors); // and assign +}; + + Sessions& GetSessions(); // forward singletons sslFactory& GetSSL_Factory(); +Errors& GetErrors(); // openSSL method and context types @@ -429,24 +507,28 @@ // holds input and output buffers class Buffers { +public: + typedef mySTL::list<input_buffer*> inputList; + typedef mySTL::list<output_buffer*> outputList; +private: + inputList dataList_; // list of users app data / handshake + outputList handShakeList_; // buffered handshake msgs + input_buffer* rawInput_; // buffered raw input yet to process public: - Buffers() {} + Buffers(); ~Buffers(); - typedef mySTL::list<input_buffer*> inputList; - typedef mySTL::list<output_buffer*> outputList; - - const inputList& getData() const; + const inputList& getData() const; const outputList& getHandShake() const; inputList& useData(); outputList& useHandShake(); + + void SetRawInput(input_buffer*); // takes ownership + input_buffer* TakeRawInput(); // takes ownership private: Buffers(const Buffers&); // hide copy - Buffers& operator=(const Buffers&); // and assign - - inputList dataList_; // list of users app data / handshake - outputList handShakeList_; // buffered handshake msgs + Buffers& operator=(const Buffers&); // and assign }; @@ -459,7 +541,7 @@ bool resuming_; // trying to resume public: Security(ProtocolVersion, RandomPool&, ConnectionEnd, const Ciphers&, - SSL_CTX*); + SSL_CTX*, bool); const SSL_CTX* GetContext() const; const Connection& get_connection() const; @@ -505,6 +587,7 @@ sslHashes& useHashes(); Socket& useSocket(); Log& useLog(); + Buffers& useBuffers(); // sets void set_pending(Cipher suite); Modified: dcplusplus/trunk/yassl/include/yassl_types.hpp =================================================================== --- dcplusplus/trunk/yassl/include/yassl_types.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/include/yassl_types.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -9,6 +9,10 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. + * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: dcplusplus/trunk/yassl/mySTL/algorithm.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/algorithm.hpp 2006-09-18 18:13:50 UTC (rev 649) +++ dcplusplus/trunk/yassl/mySTL/algorithm.hpp 2006-09-18 21:40:58 UTC (rev 650) @@ -8,6 +8,10 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. + * + * There are special exceptions to the terms and conditions of the GPL as it + * is applied to yaSSL. View the full text of the exception in the file + * FLOSS-EXCEPTIONS in the directory of this software distribution. * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of Modified: dcplusplus/trunk/yassl/mySTL/helpers.hpp =================================================================== --- dcplusplus/trunk/yassl/mySTL/helpers.hpp 2006-09-18 18:13:... [truncated message content] |
From: <arn...@us...> - 2006-09-19 09:42:45
|
Revision: 651 http://svn.sourceforge.net/dcplusplus/?rev=651&view=rev Author: arnetheduck Date: 2006-09-19 02:42:13 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Removed some more code, fixed some utf8 issues Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/Extensions.txt dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/SearchManager.cpp dcplusplus/trunk/client/SearchManager.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/UploadManager.h dcplusplus/trunk/client/User.h dcplusplus/trunk/client/UserConnection.cpp dcplusplus/trunk/client/UserConnection.h dcplusplus/trunk/windows/SearchFrm.cpp dcplusplus/trunk/windows/TransferView.cpp Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/Example.xml 2006-09-19 09:42:13 UTC (rev 651) @@ -551,7 +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="SourceTooOld">Remote client does not fully support TTH - cannot download</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/Extensions.txt =================================================================== --- dcplusplus/trunk/Extensions.txt 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/Extensions.txt 2006-09-19 09:42:13 UTC (rev 651) @@ -74,6 +74,7 @@ Feature: GetZBlock Since: 0.307 +Deprecated - replaced by ADCGet Usage: Instead of $Get and $Send, use "$GetZBlock <start> <numbytes> <filename>|" where <start> is the 0-based Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/changelog.txt 2006-09-19 09:42:13 UTC (rev 651) @@ -9,6 +9,9 @@ * [ADC] Fixed support for uncompressed files.xml as well as proper files.xml.bz2 support * Some socket code cleanup * Removed broken nick save code +* Upgraded yaSSL to 1.4.0 +* Fixed some SSL connection issues +* Fixed on-the-fly compression of file lists -- 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 Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -248,6 +248,7 @@ void DownloadManager::addConnection(UserConnection::Ptr conn) { if(!conn->isSet(UserConnection::FLAG_SUPPORTS_TTHF) || !conn->isSet(UserConnection::FLAG_SUPPORTS_ADCGET)) { // Can't download from these... + conn->getUser()->setFlag(User::OLD_CLIENT); QueueManager::getInstance()->removeSource(conn->getUser(), QueueItem::Source::FLAG_NO_TTHF); removeConnection(conn); } Modified: dcplusplus/trunk/client/SearchManager.cpp =================================================================== --- dcplusplus/trunk/client/SearchManager.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/SearchManager.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -29,7 +29,7 @@ SearchResult::SearchResult(Types aType, int64_t aSize, const string& aFile, const TTHValue& aTTH) : file(aFile), user(ClientManager::getInstance()->getMe()), size(aSize), type(aType), slots(SETTING(SLOTS)), freeSlots(UploadManager::getInstance()->getFreeSlots()), - tth(aTTH), utf8(true), ref(1) { } + tth(aTTH), ref(1) { } string SearchResult::toSR(const Client& c) const { // File: "$SR %s %s%c%s %d/%d%c%s (%s)|" @@ -39,7 +39,7 @@ tmp.append("$SR ", 4); tmp.append(Text::utf8ToAcp(c.getMyNick())); tmp.append(1, ' '); - string acpFile = utf8 ? Text::utf8ToAcp(file) : file; + string acpFile = Text::utf8ToAcp(file); if(type == TYPE_FILE) { tmp.append(acpFile); tmp.append(1, '\x05'); @@ -63,7 +63,7 @@ AdcCommand cmd(AdcCommand::CMD_RES, type); cmd.addParam("SI", Util::toString(size)); cmd.addParam("SL", Util::toString(freeSlots)); - cmd.addParam("FN", Util::toAdcFile(utf8 ? file : Text::acpToUtf8(file))); + cmd.addParam("FN", Util::toAdcFile(file)); cmd.addParam("TR", getTTH().toBase32()); return cmd; } @@ -211,12 +211,12 @@ if(j < i + 1) { return; } - file = x.substr(i, j-i) + '\\'; + file = Text::acpToUtf8(x.substr(i, j-i)) + '\\'; } else if(cnt == 2) { if( (j = x.find((char)5, i)) == string::npos) { return; } - file = x.substr(i, j-i); + file = Text::acpToUtf8(x.substr(i, j-i)); i = j + 1; if( (j = x.find(' ', i)) == string::npos) { return; @@ -264,7 +264,7 @@ return; SearchResult* sr = new SearchResult(user, type, slots, freeSlots, size, - file, hubName, url, remoteIp, TTHValue(tth), false, Util::emptyString); + file, hubName, url, remoteIp, TTHValue(tth), Util::emptyString); fire(SearchManagerListener::SR(), sr); sr->decRef(); } else if(x.compare(1, 4, "RES ") == 0 && x[x.length() - 1] == 0x0a) { @@ -326,7 +326,7 @@ return; /// @todo Something about the slots SearchResult* sr = new SearchResult(from, type, 0, freeSlots, size, - file, hubName, hub, remoteIp, TTHValue(tth), true, token); + file, hubName, hub, remoteIp, TTHValue(tth), token); fire(SearchManagerListener::SR(), sr); sr->decRef(); } Modified: dcplusplus/trunk/client/SearchManager.h =================================================================== --- dcplusplus/trunk/client/SearchManager.h 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/SearchManager.h 2006-09-19 09:42:13 UTC (rev 651) @@ -55,10 +55,10 @@ SearchResult(const User::Ptr& aUser, Types aType, int aSlots, int aFreeSlots, int64_t aSize, const string& aFile, const string& aHubName, - const string& aHubURL, const string& ip, TTHValue aTTH, bool aUtf8, const string& aToken) : + const string& aHubURL, const string& ip, TTHValue aTTH, const string& aToken) : file(aFile), hubName(aHubName), hubURL(aHubURL), user(aUser), size(aSize), type(aType), slots(aSlots), freeSlots(aFreeSlots), IP(ip), - tth(aTTH), token(aToken), utf8(aUtf8), ref(1) { } + tth(aTTH), token(aToken), ref(1) { } string getFileName() const; string toSR(const Client& client) const; @@ -75,7 +75,6 @@ int getSlots() const { return slots; } int getFreeSlots() const { return freeSlots; } TTHValue getTTH() const { return tth; } - bool getUtf8() const { return utf8; } const string& getIP() const { return IP; } const string& getToken() const { return token; } @@ -105,7 +104,6 @@ TTHValue tth; string token; - bool utf8; volatile long ref; }; Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -552,7 +552,7 @@ "The socks server failed establish a connection", "The socks server requires authentication", "Failed to set up the socks server for UDP relay (check socks address and port)", -"Source client does not support TTH", +"Remote client does not fully support TTH - cannot download", "Source too slow", "Source Type", "Specify a search string", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/StringDefs.h 2006-09-19 09:42:13 UTC (rev 651) @@ -555,7 +555,7 @@ SOCKS_FAILED, // "The socks server failed establish a connection" SOCKS_NEEDS_AUTH, // "The socks server requires authentication" SOCKS_SETUP_ERROR, // "Failed to set up the socks server for UDP relay (check socks address and port)" - SOURCE_TOO_OLD, // "Source client does not support TTH" + SOURCE_TOO_OLD, // "Remote client does not fully support TTH - cannot download" SOURCE_TOO_SLOW, // "Source too slow" SOURCE_TYPE, // "Source Type" SPECIFY_SEARCH_STRING, // "Specify a search string" Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -259,31 +259,6 @@ } } -void UploadManager::onGetBlock(UserConnection* aSource, const string& aFile, int64_t aStartPos, int64_t aBytes, bool z) { - if(!z || BOOLSETTING(COMPRESS_TRANSFERS)) { - if(prepareFile(aSource, "file", Util::toAdcFile(aFile), aStartPos, aBytes)) { - Upload* u = aSource->getUpload(); - dcassert(u != NULL); - if(aBytes == -1) - aBytes = u->getSize() - aStartPos; - - dcassert(aBytes >= 0); - - u->setStart(GET_TICK()); - - if(z) { - u->setFile(new FilteredInputStream<ZFilter, true>(u->getFile())); - u->setFlag(Upload::FLAG_ZUPLOAD); - } - - aSource->sending(aBytes); - aSource->setState(UserConnection::STATE_DONE); - aSource->transmitFile(u->getFile()); - fire(UploadManagerListener::Starting(), u); - } - } -} - void UploadManager::on(UserConnectionListener::Send, UserConnection* aSource) throw() { if(aSource->getState() != UserConnection::STATE_SEND) { dcdebug("UM::onSend Bad state, ignoring\n"); Modified: dcplusplus/trunk/client/UploadManager.h =================================================================== --- dcplusplus/trunk/client/UploadManager.h 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/UploadManager.h 2006-09-19 09:42:13 UTC (rev 651) @@ -182,8 +182,6 @@ virtual void on(BytesSent, UserConnection*, size_t, size_t) throw(); virtual void on(Failed, UserConnection*, const string&) throw(); virtual void on(Get, UserConnection*, const string&, int64_t) throw(); - virtual void on(GetBlock, UserConnection* conn, const string& line, int64_t resume, int64_t bytes) throw() { onGetBlock(conn, line, resume, bytes, false); } - virtual void on(GetZBlock, UserConnection* conn, const string& line, int64_t resume, int64_t bytes) throw() { onGetBlock(conn, line, resume, bytes, true); } virtual void on(Send, UserConnection*) throw(); virtual void on(GetListLength, UserConnection* conn) throw(); virtual void on(TransmitDone, UserConnection*) throw(); @@ -191,7 +189,6 @@ virtual void on(AdcCommand::GET, UserConnection*, const AdcCommand&) throw(); virtual void on(AdcCommand::GFI, UserConnection*, const AdcCommand&) throw(); - void onGetBlock(UserConnection* aSource, const string& aFile, int64_t aResume, int64_t aBytes, bool z); bool prepareFile(UserConnection* aSource, const string& aType, const string& aFile, int64_t aResume, int64_t aBytes, bool listRecursive = false); }; Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/User.h 2006-09-19 09:42:13 UTC (rev 651) @@ -40,7 +40,8 @@ NMDC_BIT, BOT_BIT, TTH_GET_BIT, - TLS_BIT + TLS_BIT, + OLD_CLIENT_BIT }; /** Each flag is set if it's true in at least one hub */ @@ -51,7 +52,8 @@ NMDC = 1<<NMDC_BIT, BOT = 1<<BOT_BIT, TTH_GET = 1<<TTH_GET_BIT, //< User supports getting files by tth -> don't have path in queue... - TLS = 1<<TLS_BIT //< Client supports SSL + TLS = 1<<TLS_BIT, //< Client supports SSL + OLD_CLIENT = 1<<OLD_CLIENT_BIT //< Can't download - old client }; typedef Pointer<User> Ptr; Modified: dcplusplus/trunk/client/UserConnection.cpp =================================================================== --- dcplusplus/trunk/client/UserConnection.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/UserConnection.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -116,28 +116,6 @@ if(x != string::npos) { fire(UserConnectionListener::Get(), this, Text::acpToUtf8(param.substr(0, x)), Util::toInt64(param.substr(x+1)) - (int64_t)1); } - } else if(cmd == "$GetZBlock" || cmd == "$UGetZBlock" || cmd == "$UGetBlock") { - string::size_type i = param.find(' '); - if(i == string::npos) - return; - int64_t start = Util::toInt64(param.substr(0, i)); - if(start < 0) { - disconnect(); - return; - } - i++; - string::size_type j = param.find(' ', i); - if(j == string::npos) - return; - int64_t bytes = Util::toInt64(param.substr(i, j-i)); - string name = param.substr(j+1); - if(cmd == "$GetZBlock") - name = Text::acpToUtf8(name); - if(cmd == "$UGetBlock") { - fire(UserConnectionListener::GetBlock(), this, name, start, bytes); - } else { - fire(UserConnectionListener::GetZBlock(), this, name, start, bytes); - } } else if(cmd == "$Key") { if(!param.empty()) fire(UserConnectionListener::Key(), this, param); Modified: dcplusplus/trunk/client/UserConnection.h =================================================================== --- dcplusplus/trunk/client/UserConnection.h 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/client/UserConnection.h 2006-09-19 09:42:13 UTC (rev 651) @@ -46,8 +46,6 @@ typedef X<5> Key; typedef X<6> Direction; typedef X<7> Get; - typedef X<8> GetBlock; - typedef X<9> GetZBlock; typedef X<10> Sending; typedef X<11> FileLength; typedef X<12> Send; @@ -70,8 +68,6 @@ virtual void on(Key, UserConnection*, const string&) throw() { } virtual void on(Direction, UserConnection*, const string&, const string&) throw() { } virtual void on(Get, UserConnection*, const string&, int64_t) throw() { } - virtual void on(GetBlock, UserConnection*, const string&, int64_t, int64_t) throw() { } - virtual void on(GetZBlock, UserConnection*, const string&, int64_t, int64_t) throw() { } virtual void on(Sending, UserConnection*, int64_t) throw() { } virtual void on(FileLength, UserConnection*, int64_t) throw() { } virtual void on(Send, UserConnection*) throw() { } @@ -235,8 +231,6 @@ void key(const string& aKey) { send("$Key " + aKey + '|'); } void direction(const string& aDirection, int aNumber) { send("$Direction " + aDirection + " " + Util::toString(aNumber) + '|'); } void get(const string& aFile, int64_t aResume) { send("$Get " + aFile + "$" + Util::toString(aResume + 1) + '|'); } // No acp - utf conversion here... - void getZBlock(const string& aFile, int64_t aResume, int64_t aBytes, bool utf8) { send((utf8 ? "$UGetZBlock " : "$GetZBlock ") + Util::toString(aResume) + ' ' + Util::toString(aBytes) + ' ' + aFile + '|'); } - void uGetBlock(const string& aFile, int64_t aResume, int64_t aBytes) { send("$UGetBlock " + Util::toString(aResume) + ' ' + Util::toString(aBytes) + ' ' + aFile + '|'); } void fileLength(const string& aLength) { send("$FileLength " + aLength + '|'); } void startSend() { send("$Send|"); } void sending(int64_t bytes) { send(bytes == -1 ? string("$Sending|") : "$Sending " + Util::toString(bytes) + "|"); } Modified: dcplusplus/trunk/windows/SearchFrm.cpp =================================================================== --- dcplusplus/trunk/windows/SearchFrm.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/windows/SearchFrm.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -352,8 +352,8 @@ } else { // match all here for(TStringIter j = search.begin(); j != search.end(); ++j) { - if((*j->begin() != _T('-') && Util::findSubString(aResult->getUtf8() ? aResult->getFile() : Text::acpToUtf8(aResult->getFile()), Text::fromT(*j)) == -1) || - (*j->begin() == _T('-') && j->size() != 1 && Util::findSubString(aResult->getUtf8() ? aResult->getFile() : Text::acpToUtf8(aResult->getFile()), Text::fromT(j->substr(1))) != -1) + if((*j->begin() != _T('-') && Util::findSubString(aResult->getFile(), Text::fromT(*j)) == -1) || + (*j->begin() == _T('-') && j->size() != 1 && Util::findSubString(aResult->getFile(), Text::fromT(j->substr(1))) != -1) ) { droppedResults++; @@ -1109,10 +1109,10 @@ void SearchFrame::SearchInfo::update() { if(sr->getType() == SearchResult::TYPE_FILE) { if(sr->getFile().rfind(_T('\\')) == tstring::npos) { - columns[COLUMN_FILENAME] = Text::toT(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile())); + columns[COLUMN_FILENAME] = Text::toT(sr->getFile()); } else { - columns[COLUMN_FILENAME] = Text::toT(Util::getFileName(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile()))); - columns[COLUMN_PATH] = Text::toT(Util::getFilePath(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile()))); + columns[COLUMN_FILENAME] = Text::toT(Util::getFileName(sr->getFile())); + columns[COLUMN_PATH] = Text::toT(Util::getFilePath(sr->getFile())); } columns[COLUMN_TYPE] = Text::toT(Util::getFileExt(Text::fromT(columns[COLUMN_FILENAME]))); @@ -1121,8 +1121,8 @@ columns[COLUMN_SIZE] = Text::toT(Util::formatBytes(sr->getSize())); columns[COLUMN_EXACT_SIZE] = Text::toT(Util::formatExactSize(sr->getSize())); } else { - columns[COLUMN_FILENAME] = Text::toT(sr->getUtf8() ? sr->getFileName() : Text::acpToUtf8(sr->getFileName())); - columns[COLUMN_PATH] = Text::toT(sr->getUtf8() ? sr->getFile() : Text::acpToUtf8(sr->getFile())); + columns[COLUMN_FILENAME] = Text::toT(sr->getFileName()); + columns[COLUMN_PATH] = Text::toT(sr->getFile()); columns[COLUMN_TYPE] = TSTRING(DIRECTORY); if(sr->getSize() > 0) { columns[COLUMN_SIZE] = Text::toT(Util::formatBytes(sr->getSize())); Modified: dcplusplus/trunk/windows/TransferView.cpp =================================================================== --- dcplusplus/trunk/windows/TransferView.cpp 2006-09-18 21:40:58 UTC (rev 650) +++ dcplusplus/trunk/windows/TransferView.cpp 2006-09-19 09:42:13 UTC (rev 651) @@ -439,7 +439,11 @@ void TransferView::on(ConnectionManagerListener::Failed, ConnectionQueueItem* aCqi, const string& aReason) { UpdateInfo* ui = new UpdateInfo(aCqi->getUser(), aCqi->getDownload()); - ui->setStatusString(Text::toT(aReason)); + if(aCqi->getUser()->isSet(User::OLD_CLIENT)) { + ui->setStatusString(TSTRING(SOURCE_TOO_OLD)); + } else { + ui->setStatusString(Text::toT(aReason)); + } speak(UPDATE_ITEM, ui); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-19 13:00:56
|
Revision: 652 http://svn.sourceforge.net/dcplusplus/?rev=652&view=rev Author: arnetheduck Date: 2006-09-19 06:00:44 -0700 (Tue, 19 Sep 2006) Log Message: ----------- patch Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/windows/AboutDlg.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-19 09:42:13 UTC (rev 651) +++ dcplusplus/trunk/changelog.txt 2006-09-19 13:00:44 UTC (rev 652) @@ -12,6 +12,7 @@ * Upgraded yaSSL to 1.4.0 * Fixed some SSL connection issues * Fixed on-the-fly compression of file lists +* [bug 1055] Stopped files.xml.bz2 from being deleted on linux (thanks dorian) -- 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 Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-09-19 09:42:13 UTC (rev 651) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-09-19 13:00:44 UTC (rev 652) @@ -70,7 +70,7 @@ WIN32_FIND_DATA data; HANDLE hFind; - hFind = FindFirstFile(Text::toT(Util::getConfigPath() + "files*.xml.bz2").c_str(), &data); + hFind = FindFirstFile(Text::toT(Util::getConfigPath() + "files?*.xml.bz2").c_str(), &data); if(hFind != INVALID_HANDLE_VALUE) { do { if(_tcslen(data.cFileName) > 13) // length of "files.xml.bz2" @@ -84,7 +84,7 @@ DIR* dir = opendir(Util::getConfigPath().c_str()); if (dir) { while (struct dirent* ent = readdir(dir)) { - if (fnmatch("files*.xml.bz2", ent->d_name, 0) == 0) { + if (fnmatch("files?*.xml.bz2", ent->d_name, 0) == 0) { File::deleteFile(Util::getConfigPath() + ent->d_name); } } Modified: dcplusplus/trunk/windows/AboutDlg.h =================================================================== --- dcplusplus/trunk/windows/AboutDlg.h 2006-09-19 09:42:13 UTC (rev 651) +++ dcplusplus/trunk/windows/AboutDlg.h 2006-09-19 13:00:44 UTC (rev 652) @@ -42,7 +42,7 @@ _T("defr, ullner, fleetcommand, liny, xan, olle svensson, mark gillespie, jeremy huddleston, ") _T("bsod, sulan, jonathan stone, tim burton, izzzo, guitarm, paka, nils maier, jens oknelid, yoji, ") _T("krzysztof tyszecki, poison, pothead, pur, bigmuscle, martin, jove, bart vullings, ") -_T("steven sheehy, tobias nygren, poy. ") +_T("steven sheehy, tobias nygren, poy, dorian. ") _T("Keep it coming!"); class AboutDlg : public CDialogImpl<AboutDlg>, private HttpConnectionListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |