|
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("$... [truncated message content] |
|
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); + ... [truncated message content] |
|
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 - namespa... [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 =) (se... [truncated message content] |
|
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: dcplusp... [truncated message content] |
|
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 ClientMa...
[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...
[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.
|