You can subscribe to this list here.
2006 |
Jan
|
Feb
(24) |
Mar
(9) |
Apr
(4) |
May
(7) |
Jun
(13) |
Jul
(19) |
Aug
(1) |
Sep
(12) |
Oct
(20) |
Nov
(1) |
Dec
(15) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(6) |
Mar
(24) |
Apr
(1) |
May
(10) |
Jun
(30) |
Jul
(46) |
Aug
(20) |
Sep
(12) |
Oct
(27) |
Nov
(51) |
Dec
(58) |
2008 |
Jan
(40) |
Feb
(40) |
Mar
(78) |
Apr
(138) |
May
(4) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(2) |
Jul
(10) |
Aug
(1) |
Sep
(11) |
Oct
(31) |
Nov
(7) |
Dec
(1) |
2011 |
Jan
(1) |
Feb
|
Mar
(3) |
Apr
|
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
2013 |
Jan
(3) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2014 |
Jan
(2) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <arn...@us...> - 2006-12-07 22:43:19
|
Revision: 685 http://svn.sourceforge.net/dcplusplus/?rev=685&view=rev Author: arnetheduck Date: 2006-12-07 14:43:16 -0800 (Thu, 07 Dec 2006) Log Message: ----------- Cleanup and patches Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.vcproj dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/DirectoryListing.h dcplusplus/trunk/client/File.cpp dcplusplus/trunk/client/File.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/Socket.cpp dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/Thread.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/help/help.vcproj dcplusplus/trunk/windows/AboutDlg.h dcplusplus/trunk/windows/AdvancedPage.cpp dcplusplus/trunk/windows/AppearancePage.cpp dcplusplus/trunk/windows/FinishedFrameBase.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/windows/SearchFrm.cpp dcplusplus/trunk/windows/resource.h Added Paths: ----------- dcplusplus/trunk/help/public_hubs.html Modified: dcplusplus/trunk/DCPlusPlus.vcproj =================================================================== --- dcplusplus/trunk/DCPlusPlus.vcproj 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/DCPlusPlus.vcproj 2006-12-07 22:43:16 UTC (rev 685) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" - Version="8.00" + Version="8,00" Name="DCPlusPlus" ProjectGUID="{E82610AA-B6FD-4813-B5B9-E717CBD0F23B}" RootNamespace="DCPlusPlus" @@ -477,6 +477,10 @@ > </File> <File + RelativePath=".\windows\ShellContextMenu.cpp" + > + </File> + <File RelativePath=".\windows\SpyFrame.cpp" > </File> @@ -718,6 +722,10 @@ > </File> <File + RelativePath=".\windows\ShellContextMenu.h" + > + </File> + <File RelativePath="windows\SingleInstance.h" > </File> Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/Example.xml 2006-12-07 22:43:16 UTC (rev 685) @@ -501,6 +501,7 @@ <String Name="SettingsSharedDirectories">Shared directories</String> <String Name="SettingsShowJoins">Show joins / parts in chat by default</String> <String Name="SettingsShowProgressBars">Show progress bars for transfers</String> + <String Name="SettingsShowShellMenu">Show shell menu in finished transfers</String> <String Name="SettingsSkipZeroByte">Skip zero-byte files</String> <String Name="SettingsSmallSendBuffer">Use small send buffer (enable if uploads slow downloads a lot)</String> <String Name="SettingsSocks5">SOCKS5</String> @@ -508,6 +509,7 @@ <String Name="SettingsSocks5Port">Port</String> <String Name="SettingsSocks5Resolve">Use SOCKS5 server to resolve host names</String> <String Name="SettingsSocks5Username">Login</String> + <String Name="SettingsSortFavusersFirst">Sort favorite users first</String> <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> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/changelog.txt 2006-12-07 22:43:16 UTC (rev 685) @@ -12,6 +12,13 @@ * Linux checks for invalid file types (thanks steven sheehy) * Fixed potential crash when search began with space * [bug 1085] Better sound playing settings (thanks cologic / ullner) +* [bug 1111] OpenSSL compatibility and some unix fixes (thanks steven sheehy) +* [bug 1056] Added option to sort fav users above other users in hub frame (thanks poy) +* [bug 1063] Added option to show shell context menu in finished frame (thanks poy) +* [bug 1092] Fixed TTH tree being redownloaded (thanks stephan hohe) +* [bug 1097] Fixed waiting users being removed (thanks stephan hohe) +* [bug 1110] Added new adc hub list (thanks mafa_45) +* [bug 1091] Added new nmdc hub lists (thanks poy) -- 0.698 2006-10-10 -- * [bug 1065] Code cleanup (thanks steven sheehy) Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/ClientManager.h 2006-12-07 22:43:16 UTC (rev 685) @@ -137,7 +137,7 @@ void updateCachedIp(); // SettingsManagerListener - virtual void on(Load, SimpleXML&); + virtual void on(Load, SimpleXML&) throw(); // ClientListener virtual void on(Connected, Client* c) throw() { fire(ClientManagerListener::ClientConnected(), c); } Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -27,8 +27,6 @@ #include "LogManager.h" #include "ClientManager.h" -#include <openssl/ssl.h> - #ifdef _WIN32 #include "../bzip2/bzlib.h" #else @@ -37,15 +35,19 @@ CryptoManager::CryptoManager() : - clientContext(SSL_CTX_new(TLSv1_client_method())), - serverContext(SSL_CTX_new(TLSv1_server_method())), - clientVerContext(SSL_CTX_new(TLSv1_client_method())), - serverVerContext(SSL_CTX_new(TLSv1_server_method())), dh(DH_new()), certsLoaded(false), lock("EXTENDEDPROTOCOLABCABCABCABCABCABC"), pk("DCPLUSPLUS" VERSIONSTRING "ABCABC") { + SSL_library_init(); + + // Probably should check the return value of these. + clientContext = SSL_CTX_new(TLSv1_client_method()); + clientVerContext = SSL_CTX_new(TLSv1_client_method()); + serverContext = SSL_CTX_new(TLSv1_server_method()); + serverVerContext = SSL_CTX_new(TLSv1_server_method()); + static unsigned char dh512_p[] = { 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75, @@ -93,7 +95,6 @@ } void CryptoManager::generateCertificate() throw(CryptoException) { -#ifdef _WIN32 // Generate certificate using OpenSSL if(SETTING(TLS_PRIVATE_KEY_FILE).empty()) { throw CryptoException("No private key file chosen"); @@ -101,6 +102,8 @@ if(SETTING(TLS_CERTIFICATE_FILE).empty()) { throw CryptoException("No certificate file chosen"); } + +#ifdef _WIN32 wstring cmd = L"openssl.exe genrsa -out \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + L"\" 2048"; PROCESS_INFORMATION pi = { 0 }; STARTUPINFO si = { 0 }; @@ -124,6 +127,18 @@ WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); +#else + string cmd = "openssl genrsa -out \"" + Text::utf8ToAcp(SETTING(TLS_PRIVATE_KEY_FILE)) + "\" 2048"; + if (system(cmd.c_str()) == -1) { + throw CryptoException("Failed to spawn process: openssl"); + } + + cmd = "openssl req -x509 -new -batch -days 3650 -key \"" + Text::utf8ToAcp(SETTING(TLS_PRIVATE_KEY_FILE)) + + "\" -out \"" + Text::utf8ToAcp(SETTING(TLS_CERTIFICATE_FILE)) + "\" -subj \"/CN=" + + Text::utf8ToAcp(ClientManager::getInstance()->getMyCID().toBase32()) + "\""; + if (system(cmd.c_str()) == -1) { + throw CryptoException("Failed to spawn process: openssl"); + } #endif } Modified: dcplusplus/trunk/client/DirectoryListing.h =================================================================== --- dcplusplus/trunk/client/DirectoryListing.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/DirectoryListing.h 2006-12-07 22:43:16 UTC (rev 685) @@ -27,11 +27,10 @@ #include "FastAlloc.h" #include "MerkleTree.h" +#include "SimpleXML.h" +#include "Streams.h" class ListLoader; -class SimpleXML; -class SimpleXMLException; -class FileException; class DirectoryListing { Modified: dcplusplus/trunk/client/File.cpp =================================================================== --- dcplusplus/trunk/client/File.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/File.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -383,7 +383,7 @@ } bool File::isAbsolute(const string& path) throw() { - return path.size() > 1 && path[0] = '/'; + return path.size() > 1 && path[0] == '/'; } #endif // !_WIN32 Modified: dcplusplus/trunk/client/File.h =================================================================== --- dcplusplus/trunk/client/File.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/File.h 2006-12-07 22:43:16 UTC (rev 685) @@ -33,6 +33,8 @@ #include <sys/stat.h> #include <fcntl.h> #include <errno.h> +#include <dirent.h> +#include <fnmatch.h> #endif #ifdef _WIN32 Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -729,7 +729,7 @@ if(d->getSize() != -1) { if(HashManager::getInstance()->getTree(d->getTTH(), d->getTigerTree())) { d->setTreeValid(true); - } else if(supportsTrees && !q->getCurrent()->isSet(QueueItem::Source::FLAG_NO_TREE) && d->getSize() > HashManager::MIN_BLOCK_SIZE) { + } else if(supportsTrees && !q->getSource(aUser)->isSet(QueueItem::Source::FLAG_NO_TREE) && d->getSize() > HashManager::MIN_BLOCK_SIZE) { // Get the tree unless the file is small (for small files, we'd probably only get the root anyway) d->setFlag(Download::FLAG_TREE_DOWNLOAD); d->getTigerTree().setFileSize(d->getSize()); Modified: dcplusplus/trunk/client/SSLSocket.cpp =================================================================== --- dcplusplus/trunk/client/SSLSocket.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/SSLSocket.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -23,7 +23,7 @@ #include "LogManager.h" #include "SettingsManager.h" -#include <openssl/ssl.h> +#include <openssl/err.h> SSLSocket::SSLSocket(SSL_CTX* context) throw(SocketException) : ctx(context), ssl(0) { Modified: dcplusplus/trunk/client/SSLSocket.h =================================================================== --- dcplusplus/trunk/client/SSLSocket.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/SSLSocket.h 2006-12-07 22:43:16 UTC (rev 685) @@ -22,15 +22,15 @@ #include "Socket.h" #include "Singleton.h" -class SSLSocket; +#include <openssl/ssl.h> -namespace yaSSL { - class SSL; - class SSL_CTX; - struct DH; -} +#ifndef SSL_SUCCESS +#define SSL_SUCCESS 1 +#endif +#ifdef YASSL_VERSION using namespace yaSSL; +#endif class CryptoManager; Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -75,7 +75,7 @@ "OpenWaitingUsers", "BoldWaitingUsers", "OpenSystemLog", "BoldSystemLog", "AutoRefreshTime", "UseTLS", "AutoSearchLimit", "AltSortOrder", "AutoKickNoFavs", "PromptPassword", "SpyFrameIgnoreTthSearches", "DontDlAlreadyQueued", "MaxCommandLength", "AllowUntrustedHubs", "AllowUntrustedClients", - "TLSPort", "FastHash", + "TLSPort", "FastHash", "SortFavUsersFirst", "ShowShellMenu", "SENTRY", // Int64 "TotalUpload", "TotalDownload", @@ -135,7 +135,7 @@ setDefault(IGNORE_BOT_PMS, false); setDefault(LIST_DUPES, true); setDefault(BUFFER_SIZE, 64); - setDefault(HUBLIST_SERVERS, "http://home.bandicoot.nl/adchublist.xml.bz2;http://www.hublist.org/PublicHubList.xml.bz2"); + setDefault(HUBLIST_SERVERS, "http://home.bandicoot.nl/adchublist.xml.bz2;http://adchublist.com/hublist.xml.bz2;http://www.hublist.org/PublicHubList.xml.bz2;http://dchublist.com/hublist.xml.bz2"); setDefault(DOWNLOAD_SLOTS, 3); setDefault(MAX_DOWNLOAD_SPEED, 0); setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR); @@ -269,6 +269,8 @@ setDefault(ALLOW_UNTRUSTED_HUBS, true); setDefault(ALLOW_UNTRUSTED_CLIENTS, true); setDefault(FAST_HASH, true); + setDefault(SORT_FAVUSERS_FIRST, false); + setDefault(SHOW_SHELL_MENU, false); #ifdef _WIN32 setDefault(MAIN_WINDOW_STATE, SW_SHOWNORMAL); Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/SettingsManager.h 2006-12-07 22:43:16 UTC (rev 685) @@ -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, FAST_HASH, + TLS_PORT, FAST_HASH, SORT_FAVUSERS_FIRST, SHOW_SHELL_MENU, INT_LAST }; enum Int64Setting { INT64_FIRST = INT_LAST + 1, Modified: dcplusplus/trunk/client/Socket.cpp =================================================================== --- dcplusplus/trunk/client/Socket.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/Socket.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -109,7 +109,7 @@ check(::bind(sock, (sockaddr *)&sock_addr, sizeof(sock_addr))); } int size = sizeof(sock_addr); - getsockname(sock, (sockaddr*)&sock_addr, &size); + getsockname(sock, (sockaddr*)&sock_addr, (socklen_t*)&size); return ntohs(sock_addr.sin_port); } Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -502,6 +502,7 @@ "Shared directories", "Show joins / parts in chat by default", "Show progress bars for transfers", +"Show shell menu in finished transfers", "Skip zero-byte files", "Use small send buffer (enable if uploads slow downloads a lot)", "SOCKS5", @@ -509,6 +510,7 @@ "Port", "Use SOCKS5 server to resolve host names", "Login", +"Sort favorite users first", "Sounds", "Note; because of changing download speeds, this is not 100% accurate...", "View status messages in main chat", @@ -1132,6 +1134,7 @@ "SettingsSharedDirectories", "SettingsShowJoins", "SettingsShowProgressBars", +"SettingsShowShellMenu", "SettingsSkipZeroByte", "SettingsSmallSendBuffer", "SettingsSocks5", @@ -1139,6 +1142,7 @@ "SettingsSocks5Port", "SettingsSocks5Resolve", "SettingsSocks5Username", +"SettingsSortFavusersFirst", "SettingsSounds", "SettingsSpeedsNotAccurate", "SettingsStatusInChat", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/StringDefs.h 2006-12-07 22:43:16 UTC (rev 685) @@ -505,6 +505,7 @@ SETTINGS_SHARED_DIRECTORIES, // "Shared directories" SETTINGS_SHOW_JOINS, // "Show joins / parts in chat by default" SETTINGS_SHOW_PROGRESS_BARS, // "Show progress bars for transfers" + SETTINGS_SHOW_SHELL_MENU, // "Show shell menu in finished transfers" SETTINGS_SKIP_ZERO_BYTE, // "Skip zero-byte files" SETTINGS_SMALL_SEND_BUFFER, // "Use small send buffer (enable if uploads slow downloads a lot)" SETTINGS_SOCKS5, // "SOCKS5" @@ -512,6 +513,7 @@ SETTINGS_SOCKS5_PORT, // "Port" SETTINGS_SOCKS5_RESOLVE, // "Use SOCKS5 server to resolve host names" SETTINGS_SOCKS5_USERNAME, // "Login" + SETTINGS_SORT_FAVUSERS_FIRST, // "Sort favorite users first" 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" Modified: dcplusplus/trunk/client/Thread.h =================================================================== --- dcplusplus/trunk/client/Thread.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/Thread.h 2006-12-07 22:43:16 UTC (rev 685) @@ -105,6 +105,13 @@ pthread_mutex_unlock(&mtx); return ret; } + static long safeExchange(volatile long& target, long value) { + pthread_mutex_lock(&mtx); + long ret = target; + target = value; + pthread_mutex_unlock(&mtx); + return ret; + } #endif protected: Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -371,8 +371,12 @@ void UploadManager::addFailedUpload(const UserConnection& source, string filename) { { Lock l(cs); - if (!count_if(waitingUsers.begin(), waitingUsers.end(), CompareFirst<User::Ptr, uint32_t>(source.getUser()))) + UserList::iterator it = find_if(waitingUsers.begin(), waitingUsers.end(), CompareFirst<User::Ptr, uint32_t>(source.getUser())); + if (it==waitingUsers.end()) { waitingUsers.push_back(WaitingUser(source.getUser(), GET_TICK())); + } else { + it->second = GET_TICK(); + } waitingFiles[source.getUser()].insert(filename); //files for which user's asked } Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/client/Util.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -95,7 +95,7 @@ systemPath = "/etc/"; char* home = getenv("HOME"); configPath = home ? home + string("/.dc++/") : "/tmp/"; -#error dataPath = wherever linux should fetch data + dataPath = configPath; // dataPath in linux is usually prefix + /share/app_name, so we can't represent it here #endif // Load boot settings @@ -112,8 +112,6 @@ 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& ) { @@ -378,7 +376,7 @@ return Text::fromT(buf); #else char buf[64]; - snprintf(buf, sizeof(buf), "%'lld", aBytes); + snprintf(buf, sizeof(buf), "%'lld", (long long int)aBytes); return string(buf) + STRING(B); #endif } Modified: dcplusplus/trunk/help/help.vcproj =================================================================== --- dcplusplus/trunk/help/help.vcproj 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/help/help.vcproj 2006-12-07 22:43:16 UTC (rev 685) @@ -153,10 +153,6 @@ > </File> <File - RelativePath=".\public_hubs.html" - > - </File> - <File RelativePath=".\favorite_hubs.html" > </File> @@ -197,6 +193,10 @@ > </File> <File + RelativePath=".\public_hubs.html" + > + </File> + <File RelativePath=".\settings_advanced.html" > </File> @@ -251,9 +251,6 @@ <File RelativePath=".\settings_windows.html" > - <File - RelativePath=".\settings_tabs.html" - > </File> <File RelativePath=".\template.html" Added: dcplusplus/trunk/help/public_hubs.html =================================================================== --- dcplusplus/trunk/help/public_hubs.html (rev 0) +++ dcplusplus/trunk/help/public_hubs.html 2006-12-07 22:43:16 UTC (rev 685) @@ -0,0 +1,46 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <title>Public hubs</title> + <meta content="text/html; charset=us-ascii" http-equiv="content-type"> + <link type="text/css" rel="stylesheet" href="office11.css"> +</head> +<body> +<h1>Public hubs</h1> +<h2>Columns</h2> +<dl style="margin-left: 40px;"> + <dt>Name</dt> + <dd>The name of the hub</dd> + <dt>Description</dt> + <dd>The hub's description</dd> + <dt>Users</dt> + <dd>Amount of users in the hub when the hub was checked by a hublist bot</dd> + <dt>Address</dt> + <dd>The hub's address</dd> + <dt>Country</dt> + <dd>Which country the hub resides in</dd> + <dt>Shared</dt> + <dd>Amount of bytes shared in the hub when the hub was checked by a hublist bot</dd> + <dt>Min share</dt> + <dd>A restriction in the hub, where Min Share in the minimum amount of bytes you have to share to be let in</dd> + <dt>Min Slots</dt> + <dd>A restriction in the hub, where Min Slots in the minimum amount of slots you have to have open to be let in</dd> + <dt>Max hubs</dt> + <dd>A restriction in the hub, where Max Hubs in the maximum amount of hubs you are allowed to be in to be let in</dd> + <dt>Max Users</dt> + <dd>A restriction in the hub, where Max Users in the maximum amount of users the hub will let in</dd> + <dt>Reliability</dt> + <dd>How often the hub has been online, in per centage</dd> + <dt>Rating</dt> + <dd>If the hublist allowed users to vote on a hub, this will appear as the hub's rating. The more stars, the better.</dd> +</dl> +<h2>Filter</h2> +Here, you can filter the hublist so you will only see specific hubs in the hublist. Eg, selecting 'address' in the drop down, and writing "foo" in the filter, will only display hubs that have "foo" in their address. +<h2>Configured Public Hub lists</h2> +In the dropdown, you may select different hublists you want to see. Press the 'Refresh' button to download a fresh version of the hublist. +<br> +If you click on 'Configure', you will be able to change, add and remove hublists. The order in 'Configured Public Hub lists' determine the order hublists are displayed in the dropdown mentioned above. +<a href="http://dcpp.net/hublist" target="_blank" class="external">List of alternative hublists.</a> +<img title="External Link" src="external.png" border="0" height="10" width="10" alt="External Link"> +</body> +</html> Modified: dcplusplus/trunk/windows/AboutDlg.h =================================================================== --- dcplusplus/trunk/windows/AboutDlg.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/AboutDlg.h 2006-12-07 22:43:16 UTC (rev 685) @@ -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, dorian. ") +_T("steven sheehy, tobias nygren, poy, dorian, stephan hohe, mafa_45. ") _T("Keep it coming!"); class AboutDlg : public CDialogImpl<AboutDlg>, private HttpConnectionListener Modified: dcplusplus/trunk/windows/AdvancedPage.cpp =================================================================== --- dcplusplus/trunk/windows/AdvancedPage.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/AdvancedPage.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -48,6 +48,7 @@ { SettingsManager::ADD_FINISHED_INSTANTLY, ResourceManager::SETTINGS_ADD_FINISHED_INSTANTLY }, { SettingsManager::USE_CTRL_FOR_LINE_HISTORY, ResourceManager::SETTINGS_USE_CTRL_FOR_LINE_HISTORY }, { SettingsManager::AUTO_KICK_NO_FAVS, ResourceManager::SETTINGS_AUTO_KICK_NO_FAVS }, + { SettingsManager::SHOW_SHELL_MENU, ResourceManager::SETTINGS_SHOW_SHELL_MENU }, { 0, ResourceManager::SETTINGS_AUTO_AWAY } }; Modified: dcplusplus/trunk/windows/AppearancePage.cpp =================================================================== --- dcplusplus/trunk/windows/AppearancePage.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/AppearancePage.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -52,6 +52,7 @@ { SettingsManager::STATUS_IN_CHAT, ResourceManager::SETTINGS_STATUS_IN_CHAT }, { SettingsManager::SHOW_JOINS, ResourceManager::SETTINGS_SHOW_JOINS }, { SettingsManager::FAV_SHOW_JOINS, ResourceManager::SETTINGS_FAV_SHOW_JOINS }, + { SettingsManager::SORT_FAVUSERS_FIRST, ResourceManager::SETTINGS_SORT_FAVUSERS_FIRST }, { SettingsManager::USE_SYSTEM_ICONS, ResourceManager::SETTINGS_USE_SYSTEM_ICONS }, { SettingsManager::USE_OEM_MONOFONT, ResourceManager::SETTINGS_USE_OEM_MONOFONT }, { SettingsManager::GET_USER_COUNTRY, ResourceManager::SETTINGS_GET_USER_COUNTRY }, Modified: dcplusplus/trunk/windows/FinishedFrameBase.h =================================================================== --- dcplusplus/trunk/windows/FinishedFrameBase.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/FinishedFrameBase.h 2006-12-07 22:43:16 UTC (rev 685) @@ -28,6 +28,7 @@ #include "FlatTabCtrl.h" #include "ExListViewCtrl.h" +#include "ShellContextMenu.h" #include "WinUtil.h" #include "TextFrame.h" @@ -200,7 +201,32 @@ WinUtil::getContextMenuPos(ctrlList, pt); } - ctxMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd); + bool bShellMenuShown = false; + if(BOOLSETTING(SHOW_SHELL_MENU) && (ctrlList.GetSelectedCount() == 1)) { + tstring path = Text::toT(((FinishedItem*)ctrlList.GetItemData(ctrlList.GetSelectedIndex()))->getTarget()); + if(GetFileAttributes(path.c_str()) != 0xFFFFFFFF) { // Check that the file still exists + CShellContextMenu shellMenu; + shellMenu.SetPath(path); + + CMenu* pShellMenu = shellMenu.GetMenu(); + pShellMenu->AppendMenu(MF_STRING, IDC_VIEW_AS_TEXT, CTSTRING(VIEW_AS_TEXT)); + pShellMenu->AppendMenu(MF_STRING, IDC_OPEN_FOLDER, CTSTRING(OPEN_FOLDER)); + pShellMenu->AppendMenu(MF_SEPARATOR); + pShellMenu->AppendMenu(MF_STRING, IDC_REMOVE, CTSTRING(REMOVE)); + pShellMenu->AppendMenu(MF_STRING, IDC_TOTAL, CTSTRING(REMOVE_ALL)); + pShellMenu->AppendMenu(MF_SEPARATOR); + + UINT idCommand = shellMenu.ShowContextMenu(m_hWnd, pt); + if(idCommand != 0) + PostMessage(WM_COMMAND, idCommand); + + bShellMenuShown = true; + } + } + + if(!bShellMenuShown) + ctxMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd); + return TRUE; } bHandled = FALSE; Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -143,6 +143,7 @@ MoveWindow(rc, TRUE); } + FavoriteManager::getInstance()->addListener(this); TimerManager::getInstance()->addListener(this); return 1; @@ -653,6 +654,7 @@ LRESULT HubFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { if(!closed) { TimerManager::getInstance()->removeListener(this); + FavoriteManager::getInstance()->removeListener(this); client->removeListener(this); client->disconnect(true); @@ -1232,6 +1234,11 @@ } } +void HubFrame::resortUsers() { + for(FrameIter i = frames.begin(); i != frames.end(); ++i) + i->second->resortForFavsFirst(true); +} + void HubFrame::closeDisconnected() { for(FrameIter i=frames.begin(); i!= frames.end(); ++i) { if (!(i->second->client->isConnected())) { @@ -1240,6 +1247,20 @@ } } +void HubFrame::on(FavoriteManagerListener::UserAdded, const FavoriteUser& /*aUser*/) throw() { + resortForFavsFirst(); +} +void HubFrame::on(FavoriteManagerListener::UserRemoved, const FavoriteUser& /*aUser*/) throw() { + resortForFavsFirst(); +} + +void HubFrame::resortForFavsFirst(bool justDoIt /* = false */) { + if(justDoIt || BOOLSETTING(SORT_FAVUSERS_FIRST)) { + resort = true; + PostMessage(WM_SPEAKER); + } +} + void HubFrame::on(Second, uint32_t /*aTick*/) throw() { updateStatusBar(); if(updateUsers) { @@ -1265,7 +1286,7 @@ updateUsers = true; } -void HubFrame::on(UserRemoved, Client*, const OnlineUser& user) throw() { +void HubFrame::on(ClientListener::UserRemoved, Client*, const OnlineUser& user) throw() { speak(REMOVE_USER, user); } Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/HubFrame.h 2006-12-07 22:43:16 UTC (rev 685) @@ -41,8 +41,8 @@ struct CompareItems; class HubFrame : public MDITabChildWindowImpl<HubFrame>, private ClientListener, - public CSplitterImpl<HubFrame>, private TimerManagerListener, public UCHandler<HubFrame>, - public UserInfoBaseHandler<HubFrame> + public CSplitterImpl<HubFrame>, private FavoriteManagerListener, private TimerManagerListener, + public UCHandler<HubFrame>, public UserInfoBaseHandler<HubFrame> { public: DECLARE_FRAME_WND_CLASS_EX(_T("HubFrame"), IDR_HUB, 0, COLOR_3DFACE); @@ -122,6 +122,7 @@ void runUserCommand(::UserCommand& uc); static void openWindow(const tstring& server); + static void resortUsers(); static void closeDisconnected(); LRESULT onSetFocus(UINT /* uMsg */, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { @@ -226,10 +227,19 @@ static int compareItems(const UserInfo* a, const UserInfo* b, int col) { if(col == COLUMN_NICK) { - if(a->getIdentity().isOp() && !b->getIdentity().isOp()) { + bool a_isOp = a->getIdentity().isOp(), + b_isOp = b->getIdentity().isOp(); + if(a_isOp && !b_isOp) return -1; - } else if(!a->getIdentity().isOp() && b->getIdentity().isOp()) { + if(!a_isOp && b_isOp) return 1; + if(BOOLSETTING(SORT_FAVUSERS_FIRST)) { + bool a_isFav = FavoriteManager::getInstance()->isFavoriteUser(a->getIdentity().getUser()), + b_isFav = FavoriteManager::getInstance()->isFavoriteUser(b->getIdentity().getUser()); + if(a_isFav && !b_isFav) + return -1; + if(!a_isFav && b_isFav) + return 1; } } if(col == COLUMN_SHARED) { @@ -384,6 +394,11 @@ void updateStatusBar() { if(m_hWnd) speak(STATS); } + // FavoriteManagerListener + virtual void on(FavoriteManagerListener::UserAdded, const FavoriteUser& /*aUser*/) throw(); + virtual void on(FavoriteManagerListener::UserRemoved, const FavoriteUser& /*aUser*/) throw(); + void resortForFavsFirst(bool justDoIt = false); + // TimerManagerListener virtual void on(TimerManagerListener::Second, uint32_t /*aTick*/) throw(); @@ -392,7 +407,7 @@ virtual void on(Connected, 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(); + virtual void on(ClientListener::UserRemoved, Client*, const OnlineUser&) throw(); virtual void on(Redirect, Client*, const string&) throw(); virtual void on(Failed, Client*, const string&) throw(); virtual void on(GetPassword, Client*) throw(); Modified: dcplusplus/trunk/windows/MainFrm.cpp =================================================================== --- dcplusplus/trunk/windows/MainFrm.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/MainFrm.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -597,6 +597,8 @@ int lastConn = SETTING(INCOMING_CONNECTIONS); + bool lastSortFavUsersFirst = BOOLSETTING(SORT_FAVUSERS_FIRST); + if(dlg.DoModal(m_hWnd) == IDOK) { SettingsManager::getInstance()->save(); @@ -608,6 +610,9 @@ } ClientManager::getInstance()->infoUpdated(); + if(BOOLSETTING(SORT_FAVUSERS_FIRST) != lastSortFavUsersFirst) + HubFrame::resortUsers(); + if(BOOLSETTING(URL_HANDLER)) { WinUtil::registerDchubHandler(); WinUtil::registerADChubHandler(); Modified: dcplusplus/trunk/windows/SearchFrm.cpp =================================================================== --- dcplusplus/trunk/windows/SearchFrm.cpp 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/SearchFrm.cpp 2006-12-07 22:43:16 UTC (rev 685) @@ -278,13 +278,20 @@ { Lock l(cs); search = StringTokenizer<tstring>(s, ' ').getTokens(); + s.clear(); + //strip out terms beginning with - + for(TStringList::iterator si = search.begin(); si != search.end(); ) { + if(si->empty()) { + si = search.erase(si); + continue; + } + if ((*si)[0] != _T('-')) + s += *si + _T(' '); + } + + s = s.substr(0, max(s.size(), static_cast<tstring::size_type>(1)) - 1); } - //strip out terms beginning with - - s.clear(); - for (TStringList::const_iterator si = search.begin(); si != search.end(); ++si) - if ((*si)[0] != _T('-')) s += *si + _T(' '); //Shouldn't get 0-length tokens, so safely assume at least a first char. - s = s.substr(0, max(s.size(), static_cast<tstring::size_type>(1)) - 1); SearchManager::SizeModes mode((SearchManager::SizeModes)ctrlMode.GetCurSel()); if(llsize == 0) Modified: dcplusplus/trunk/windows/resource.h =================================================================== --- dcplusplus/trunk/windows/resource.h 2006-11-02 21:44:12 UTC (rev 684) +++ dcplusplus/trunk/windows/resource.h 2006-12-07 22:43:16 UTC (rev 685) @@ -454,6 +454,8 @@ #define IDC_REMOVE_SOURCES 8000 #define IDC_DOWNLOAD_FAVORITE_DIRS 8500 #define IDC_DOWNLOAD_WHOLE_FAVORITE_DIRS 9000 +#define ID_SHELLCONTEXTMENU_MIN 10000 +#define ID_SHELLCONTEXTMENU_MAX 12000 #define ID_FILE_CONNECT 32772 #define ID_FILE_SETTINGS 32774 #define ID_FILE_RECONNECT 32775 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-11-02 21:44:56
|
Revision: 684 http://svn.sourceforge.net/dcplusplus/?rev=684&view=rev Author: arnetheduck Date: 2006-11-02 13:44:12 -0800 (Thu, 02 Nov 2006) Log Message: ----------- Patches & fixes Modified Paths: -------------- dcplusplus/trunk/Compile.txt dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/DCPlusPlus.vcproj dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/File.cpp dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/SettingsManager.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/help/DCPlusPlus.hhp dcplusplus/trunk/help/faq_secret.html dcplusplus/trunk/help/help.vcproj dcplusplus/trunk/help/index.html dcplusplus/trunk/help/settings_advanced.html dcplusplus/trunk/help/settings_appearance.html dcplusplus/trunk/help/settings_certs.html dcplusplus/trunk/help/settings_colors_and_sounds.html dcplusplus/trunk/help/settings_expert.html dcplusplus/trunk/help/settings_queue.html dcplusplus/trunk/help/settings_windows.html dcplusplus/trunk/help/toc.hhc dcplusplus/trunk/windows/Appearance2Page.cpp dcplusplus/trunk/windows/Appearance2Page.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/PrivateFrame.cpp dcplusplus/trunk/windows/PropertiesDlg.cpp dcplusplus/trunk/windows/PropertiesDlg.h dcplusplus/trunk/windows/resource.h Modified: dcplusplus/trunk/Compile.txt =================================================================== --- dcplusplus/trunk/Compile.txt 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/Compile.txt 2006-11-02 21:44:12 UTC (rev 684) @@ -3,9 +3,6 @@ How to compile in 3 easy steps: 1) Download the source DC++ download site. Unpack the DC++ source. - Download STLPort 5.0.2 from http://sf.net/stlport and unpack it to a temporary folder. Inside you'll - find a folder named stlport which contains files such as "algorithm". Copy the contents of this folder - to the stlport folder where you unpacked DC++. Download WTL from http://sf.net/projects/wtl. Unpack it to the wtl folder. 2) You most probably have to update your Platform SDK, http://msdn.microsoft.com will tell you how. @@ -13,10 +10,9 @@ one file, you can ask someone at the dev hub to supply it for you (or look for it in the DC++ bugzilla, it's attached to one of the bugs). -3) Open the solution in vc7.1 (2004) and press your build button. If you find your executable unreasonably large, +3) Open the solution in vc8.0 (2005) and press your build button. If you find your executable unreasonably large, you probably compiled in debug mode - switch to release once you're done testing the code. - Note; You'll need DBGHELP.dll from the binary distribution unless you're using WinXP, otherwise you'll get errors saying symbols are missing when running your compiled executable. My copy says version 5.1.2600.1106 right now. @@ -61,4 +57,3 @@ to make it easier for us to defend the gpl against violators. If you don't like this policy, start your own distribution, if you're lucky it might become more popular than the original =). Please state explicitly in the bugzilla that you give me copyright over the code if the submission is larger than trivial. - Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-11-02 21:44:12 UTC (rev 684) @@ -7,7 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "wtl\\atlres.h" +#include "atlres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -234,9 +234,10 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,74,246,10 CONTROL "Make an annoying sound when a private message window is opened",IDC_PRIVATE_MESSAGE_BEEP_OPEN, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,87,246,10 - GROUPBOX "Bold options",IDC_SETTINGS_BOLD_CONTENTS,5,106,263,98 - CONTROL "",IDC_BOLD_BOOLEANS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,10,117,254,81 LTEXT "Note; most of these options require that you restart DC++",IDC_SETTINGS_REQUIRES_RESTART,7,209,253,8 + LTEXT "Notification sound",IDC_BEEP_NOTIFICATION,10,110,53,8 + EDITTEXT IDC_BEEPFILE,71,108,133,12,ES_AUTOHSCROLL + PUSHBUTTON "&Browse...",IDC_BROWSE,210,109,50,12 END IDD_LOGPAGE DIALOGEX 0, 0, 275, 225 @@ -440,8 +441,6 @@ RTEXT "File write buffer",IDC_SETTINGS_WRITE_BUFFER,139,10,65,8 EDITTEXT IDC_BUFFERSIZE,208,7,41,14,ES_AUTOHSCROLL LTEXT "KiB",IDC_SETTINGS_KB,252,10,10,8 - RTEXT "Max tab rows",IDC_SETTINGS_MAX_TAB_ROWS,139,27,65,8 - EDITTEXT IDC_MAX_TAB_ROWS,208,24,41,14,ES_AUTOHSCROLL RTEXT "Search history",IDC_SETTINGS_SEARCH_HISTORY,139,44,65,8 EDITTEXT IDC_SEARCH_HISTORY,208,41,41,14,ES_AUTOHSCROLL CONTROL "",IDC_SEARCH_HISTORY_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,246,41,11,14 @@ -453,8 +452,8 @@ RTEXT "Socket write buffer",IDC_SETTINGS_SOCKET_OUT_BUFFER,128,96,76,8 EDITTEXT IDC_SOCKET_OUT_BUFFER,208,93,41,14,ES_AUTOHSCROLL LTEXT "B",IDC_STATIC,252,96,8,8 - EDITTEXT IDC_AUTO_SEARCH_LIMIT,208,111,41,14,ES_AUTOHSCROLL - LTEXT "Auto-search limit",IDC_SETTINGS_AUTO_SEARCH_LIMIT,148,113,56,13 + EDITTEXT IDC_AUTO_SEARCH_LIMIT,208,24,41,14,ES_AUTOHSCROLL + LTEXT "Auto-search limit",IDC_SETTINGS_AUTO_SEARCH_LIMIT,148,26,56,13 END IDD_NETWORKPAGE DIALOGEX 0, 0, 275, 225 @@ -571,7 +570,19 @@ PUSHBUTTON "...",IDC_BROWSE_TRUSTED_PATH,248,42,20,14 END +IDD_TABSPAGE DIALOGEX 0, 0, 275, 225 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION +EXSTYLE WS_EX_STATICEDGE +CAPTION "Tabs" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + RTEXT "Max tab rows",IDC_SETTINGS_MAX_TAB_ROWS,8,117,44,8 + EDITTEXT IDC_MAX_TAB_ROWS,56,115,41,14,ES_AUTOHSCROLL + GROUPBOX "Bold options",IDC_SETTINGS_BOLD_CONTENTS,5,8,263,98 + CONTROL "",IDC_BOLD_BOOLEANS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,10,19,254,81 +END + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -800,6 +811,16 @@ TOPMARGIN, 7 BOTTOMMARGIN, 218 END + + IDD_TABSPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 268 + VERTGUIDE, 13 + VERTGUIDE, 261 + TOPMARGIN, 7 + BOTTOMMARGIN, 218 + END END #endif // APSTUDIO_INVOKED Modified: dcplusplus/trunk/DCPlusPlus.vcproj =================================================================== --- dcplusplus/trunk/DCPlusPlus.vcproj 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/DCPlusPlus.vcproj 2006-11-02 21:44:12 UTC (rev 684) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" - Version="8,00" + Version="8.00" Name="DCPlusPlus" ProjectGUID="{E82610AA-B6FD-4813-B5B9-E717CBD0F23B}" RootNamespace="DCPlusPlus" @@ -80,7 +80,7 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/FIXED:NO /SAFESEH:NO" - 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" + 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 winmm.lib" OutputFile="$(SolutionDir)App/$(ProjectName).exe" LinkIncremental="2" SuppressStartupBanner="true" @@ -187,7 +187,7 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/FIXED:NO /SAFESEH:NO" - 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" + 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 winmm.lib" OutputFile="$(SolutionDir)App/$(ProjectName).exe" Version="" LinkIncremental="1" @@ -509,6 +509,10 @@ > </File> <File + RelativePath=".\windows\TabsPage.cpp" + > + </File> + <File RelativePath="windows\TextFrame.cpp" > </File> @@ -734,6 +738,10 @@ > </File> <File + RelativePath=".\windows\TabsPage.h" + > + </File> + <File RelativePath="windows\TextFrame.h" > </File> Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/Example.xml 2006-11-02 21:44:12 UTC (rev 684) @@ -463,6 +463,7 @@ <String Name="SettingsMinimizeTray">Minimize to tray</String> <String Name="SettingsName">Name</String> <String Name="SettingsNetwork">Connection settings</String> + <String Name="SettingsNotificationSound">Notification sound</String> <String Name="SettingsNoAwaymsgToBots">Don't send the away message to bots</String> <String Name="SettingsOnlyHashed">Note; Files appear in the share only after they've been hashed!</String> <String Name="SettingsOnlyTth">Search for files with TTH root only as standard</String> @@ -519,6 +520,7 @@ <String Name="SettingsPrioNormal">Normal prio max size</String> <String Name="SettingsPrioLow">Low prio max size</String> <String Name="SettingsPrioLowest">Set lowest prio for newly added files larger than Low prio size</String> + <String Name="SettingsTabs">Appearance\Tabs</String> <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> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/changelog.txt 2006-11-02 21:44:12 UTC (rev 684) @@ -9,6 +9,9 @@ * [bug 1080] Better nick tab completion (thanks cologic) * [bug 1081] Added user IP in hub frame (thanks cologic) * No more STLport for the time being +* Linux checks for invalid file types (thanks steven sheehy) +* Fixed potential crash when search began with space +* [bug 1085] Better sound playing settings (thanks cologic / ullner) -- 0.698 2006-10-10 -- * [bug 1065] Code cleanup (thanks steven sheehy) Modified: dcplusplus/trunk/client/File.cpp =================================================================== --- dcplusplus/trunk/client/File.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/client/File.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -214,6 +214,12 @@ m |= O_TRUNC; } + struct stat s; + if(lstat(aFileName.c_str(), &s) != -1) { + if(!S_ISREG(s.st_mode) && !S_ISLNK(s.st_mode)) + throw FileException("Invalid file type"); + } + 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"); @@ -417,7 +423,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(pattern.c_str(), ent->d_name, 0) == 0) { ret.push_back(path + ent->d_name); } } Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -44,7 +44,7 @@ "FinishedULWidths", "FinishedULOrder", "CID", "SpyFrameWidths", "SpyFrameOrder", "LogFileMainChat", "LogFilePrivateChat", "LogFileStatus", "LogFileUpload", "LogFileDownload", "LogFileSystem", "LogFormatSystem", "LogFormatStatus", "DirectoryListingFrameOrder", "DirectoryListingFrameWidths", - "TLSPrivateKeyFile", "TLSCertificateFile", "TLSTrustedCertificatesPath", + "TLSPrivateKeyFile", "TLSCertificateFile", "TLSTrustedCertificatesPath", "BeepFile", "SENTRY", // Ints "IncomingConnections", "InPort", "Slots", "Rollback", "AutoFollow", "ClearSearch", Modified: dcplusplus/trunk/client/SettingsManager.h =================================================================== --- dcplusplus/trunk/client/SettingsManager.h 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/client/SettingsManager.h 2006-11-02 21:44:12 UTC (rev 684) @@ -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, - TLS_PRIVATE_KEY_FILE, TLS_CERTIFICATE_FILE, TLS_TRUSTED_CERTIFICATES_PATH, + TLS_PRIVATE_KEY_FILE, TLS_CERTIFICATE_FILE, TLS_TRUSTED_CERTIFICATES_PATH, BEEPFILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -464,6 +464,7 @@ "Minimize to tray", "Name", "Connection settings", +"Notification sound", "Don't send the away message to bots", "Note; Files appear in the share only after they've been hashed!", "Search for files with TTH root only as standard", @@ -520,6 +521,7 @@ "Normal prio max size", "Low prio max size", "Set lowest prio for newly added files larger than Low prio size", +"Appearance\\Tabs", "Show timestamps in chat by default", "Set timestamps", "Toggle window when selecting an active tab", @@ -1092,6 +1094,7 @@ "SettingsMinimizeTray", "SettingsName", "SettingsNetwork", +"SettingsNotificationSound", "SettingsNoAwaymsgToBots", "SettingsOnlyHashed", "SettingsOnlyTth", @@ -1148,6 +1151,7 @@ "SettingsPrioNormal", "SettingsPrioLow", "SettingsPrioLowest", +"SettingsTabs", "SettingsTimeStamps", "SettingsTimeStampsFormat", "SettingsToggleActiveWindow", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/client/StringDefs.h 2006-11-02 21:44:12 UTC (rev 684) @@ -467,6 +467,7 @@ SETTINGS_MINIMIZE_TRAY, // "Minimize to tray" SETTINGS_NAME, // "Name" SETTINGS_NETWORK, // "Connection settings" + SETTINGS_NOTIFICATION_SOUND, // "Notification sound" SETTINGS_NO_AWAYMSG_TO_BOTS, // "Don't send the away message to bots" SETTINGS_ONLY_HASHED, // "Note; Files appear in the share only after they've been hashed!" SETTINGS_ONLY_TTH, // "Search for files with TTH root only as standard" @@ -523,6 +524,7 @@ SETTINGS_PRIO_NORMAL, // "Normal prio max size" SETTINGS_PRIO_LOW, // "Low prio max size" SETTINGS_PRIO_LOWEST, // "Set lowest prio for newly added files larger than Low prio size" + SETTINGS_TABS, // "Appearance\\Tabs" 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" Modified: dcplusplus/trunk/client/stdinc.h =================================================================== --- dcplusplus/trunk/client/stdinc.h 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/client/stdinc.h 2006-11-02 21:44:12 UTC (rev 684) @@ -122,7 +122,6 @@ #include <utility> #include <functional> -// Use maps if hash_maps aren't available #ifdef _STLPORT_VERSION # define HASH_SET hash_set # define HASH_MAP hash_map Modified: dcplusplus/trunk/help/DCPlusPlus.hhp =================================================================== --- dcplusplus/trunk/help/DCPlusPlus.hhp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/DCPlusPlus.hhp 2006-11-02 21:44:12 UTC (rev 684) @@ -29,12 +29,14 @@ settings_windows.html settings_queue.html settings_certs.html +settings_tabs.html chat_commands.html non-routable.html plusplus_tag.html netiquette.html credits.html adlsearch.html +public_hubs.html favorite_hubs.html favorite_users.html fdl.html @@ -73,6 +75,7 @@ IDD_WINDOWSPAGE=settings_windows.html IDR_ADLSEARCH=adlsearch.html IDD_CERTSPAGE=settings_certs.html +IDD_TABSPAGE=settings_tabs.html [MAP] #include ..\windows\resource.h Modified: dcplusplus/trunk/help/faq_secret.html =================================================================== --- dcplusplus/trunk/help/faq_secret.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/faq_secret.html 2006-11-02 21:44:12 UTC (rev 684) @@ -15,7 +15,7 @@ <li>If DC++ receives "banned" during the login phase, it'll stop automatically reconnecting</li> <li>Your file list will be created on disk the first time someone requests it</li> <li>Pressing shift on startup will prevent DC++ from autoconnecting to favorite hubs.</li> - <li>You can tab complete nicks in mainchat (if the option is on), including ignoring prefixes.</li> + <li>You can tab complete nicks in mainchat, including ignoring prefixes.</li> <li>You can drag and drop all tabs to the position of your choice.</li> <li>You can see who wants to download from you and what they want to download by opening the <a href="waiting_users.html">Waiting users frame</a>.</li> <li>You can drag folders from Windows Explorer and drop them in the <a href="settings_sharing.html">Sharing </a>page in Settings.</li> Modified: dcplusplus/trunk/help/help.vcproj =================================================================== --- dcplusplus/trunk/help/help.vcproj 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/help.vcproj 2006-11-02 21:44:12 UTC (rev 684) @@ -153,6 +153,10 @@ > </File> <File + RelativePath=".\public_hubs.html" + > + </File> + <File RelativePath=".\favorite_hubs.html" > </File> @@ -247,6 +251,9 @@ <File RelativePath=".\settings_windows.html" > + <File + RelativePath=".\settings_tabs.html" + > </File> <File RelativePath=".\template.html" Modified: dcplusplus/trunk/help/index.html =================================================================== --- dcplusplus/trunk/help/index.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/index.html 2006-11-02 21:44:12 UTC (rev 684) @@ -35,6 +35,7 @@ <br> <h2>Windows</h2> <div style="margin-left: 40px;"><a href="adlsearch.html">ADLSearch</a><br> +<a href="public_hubs.html">Public hubs</a><br> <a href="favorite_hubs.html">Favorite Hubs</a><br> <a href="favorite_users.html">Favorite Users</a></div> <h2>Frequently Asked Questions</h2> @@ -61,6 +62,7 @@ <a href="settings_sharing.html">Sharing</a><br> <a href="settings_appearance.html">Appearance</a><br> <div style="margin-left: 40px;"><a href="settings_colors_and_sounds.html">Colors and sounds</a><br> +<a href="settings_tabs.html">Tabs</a><br> <a href="settings_windows.html">Windows</a><br> </div> <a href="settings_advanced.html">Advanced</a> Modified: dcplusplus/trunk/help/settings_advanced.html =================================================================== --- dcplusplus/trunk/help/settings_advanced.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_advanced.html 2006-11-02 21:44:12 UTC (rev 684) @@ -90,12 +90,6 @@ the first search it matches. If disabled, it may appear multiple times, if it matches more than one search. <span style="font-style: italic;">Disable if unsure.</span></dd> - <dt><a name="tab_completion"></a>Tab Completion of Nicks in Chat</dt> - <dd>You can use the tab key to complete partial (beginnings) of -nicknames from the main chat text input field (press tab multiple times -to switch between multiple nicks). A partial nick will also match if -comes after something between brackets (e.g. "arne<tab>" would -match "[BBB]arnetheduck").</dd> <dt>Enable Safe and Compressed Transfers</dt> <dd>When transfering data with a compatible client, DC++ will try to use ZLIB compression with integrity checks. This uses some CPU cycles, @@ -119,12 +113,8 @@ <dt>Use CTRL for line history</dt> <dd>Press up arrow while holding down CTRL to scroll through line history. If not enabled, up arrow will be enough.</dd> - <dt>Use SSL when remote client supports it</dt> - <dd>When this option is enabled, DC++ will connect to remote -clients on an ADC hub that support SSL using SSL. This option is -an experimental one, and shouldn't imply that DC++ is secure in any way.</dd> - <span style="font-weight: bold;">Use SSL when remote client supports it<br> - </span> + <dt>Don't automatically disconnect favorite users who leave the hub</dt> + <dd>With this option enabled, and <a href="settings_advanced.html#disconnect">Automatically disconnect users who leave the hub</a>, users who are in your <a href="favorite_users.html">Favorite users</a> page are not disconnected.</dd> </dl> </body> </html> Modified: dcplusplus/trunk/help/settings_appearance.html =================================================================== --- dcplusplus/trunk/help/settings_appearance.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_appearance.html 2006-11-02 21:44:12 UTC (rev 684) @@ -9,6 +9,8 @@ <h1>Appearance</h1> <h2>Options</h2> <dl style="margin-left: 40px;"> + <dt>Sort all downloads first</a> + <dd>With this option enabled, DC++ will sort the downloads and uploads; Current download(s), waiting download(s), current upload(s) and waiting upload(s). <br>With this option disabled, DC++ will sort downloads and uploads; Current download(s), current uploads(s), waiting download(s) and waiting upload(s)</dd> <dt>Filter kick and NMDC Debug Messages</dt> <dd>When enabled, kick and debug chat messages (sent by other clients) are hidden from main chat. These messages are generally not Modified: dcplusplus/trunk/help/settings_certs.html =================================================================== --- dcplusplus/trunk/help/settings_certs.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_certs.html 2006-11-02 21:44:12 UTC (rev 684) @@ -10,13 +10,23 @@ <dl style="margin-left: 40px;"> <dt>Private key file</dt> - <dd></dd> + <dd>This file is your personal and private certificate file. <span style="font-weight: bold;">Do not share this with other users or hubs.</span> If you do, you risk allowing others to use your certificate and in essence pose as you.</dd> <dt>Own certificate file</dt> - <dd></dd> + <dd>This file is the certificate file you should give to other users and hubs that you want to consider "trusted". </dd> <dt>Trusted certificates path</dt> - <dd>Where trusted certificates will be stored. (default: the Certs\ subdirectory of where you've installed the application.) </dd> + <dd>Where trusted certificates from users or hubs will be stored. (default: the Certs\ subdirectory of where you've installed the application.) </dd> </dl> - +<h2>Options</h2> +<dl style="margin-left: 40px;"> + <dt>Use SSL when remote client supports it</dt> + <dd>When this option is enabled, DC++ will connect to remote +clients on an ADC hub that support SSL using SSL. This option is +an experimental one, and shouldn't imply that DC++ is secure in any way.</dd> + <dt>Allow TLS connections to hubs without trusted certificate</dt> + <dd>With this option disabled, all hubs you connect to must have a certificate in your Trusted certificate folder.</dd> + <dt>Allow TLS connections to clients without trusted certificate</dt> + <dd>With this option disabled, all client you connect to must have a certificate in your Trusted certificate folder.</dd> +</dl> To see effects, please restart DC++.<br> <br> SSL support is an experimental feature and doesn't imply that DC++ is secure in any way. Modified: dcplusplus/trunk/help/settings_colors_and_sounds.html =================================================================== --- dcplusplus/trunk/help/settings_colors_and_sounds.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_colors_and_sounds.html 2006-11-02 21:44:12 UTC (rev 684) @@ -35,32 +35,8 @@ <dt>Make an annoying sound when a private message window is opened</dt> <dd>When set, the system's "Default Beep" sound will play when a private message window is opened. </dd> + <dt>Notification sound</dt> + <dd>Instead of the system's computer beep, you can select a different beep or tune for above options.</a> </dl> -<h2>Tab bolding on contents change</h2> -<dl style="margin-left: 40px;"> - <dt>Finished Downloads</dt> - <dd>When a download completes, the Finished -Downloads tab will turn bold if this option is selected.</dd> - <dt>Finished Uploads</dt> - <dd>When a upload completes, the Finished -Uploads tab will turn bold if this option is selected.</dd> - <dt>Download Queue</dt> - <dd>This option controls whether or not the Download Queue's tab will -highlight itself when a queue item changes state or finishes.</dd> - <dt>Hub</dt> - <dd>When a chat message appears in a hub that's -not focused the tab will become bold if you have this option selected.</dd> -<dt>Private message</dt> - <dd>When a private message appears that's -not focused the tab will become bold if you have this option selected.</dd> -<dt>Search</dt> - <dd>If more search result appear in an open search window that's -not focused the tab will become bold if you have this option selected.</dd> -<dt>Waiting users</dt> - <dd>If a user or an item is added or removed while the tab is not -focused, the tab will become bold if you have this option selected.</dd> -<dt>System log</dt> - <dd>If an system log entry is added while the tab is not focused, the tab will become bold if you have this option selected.</dd> -</dl> </body> </html> \ No newline at end of file Modified: dcplusplus/trunk/help/settings_expert.html =================================================================== --- dcplusplus/trunk/help/settings_expert.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_expert.html 2006-11-02 21:44:12 UTC (rev 684) @@ -39,21 +39,15 @@ malformed file lists that require large amounts of memory to decode. You may need to reduce or increase the value of this setting based on personal experience. (default: 512 MiB)</dd> - <dt>CID</dt> - <dd>This is your unique client ID (CID) used to identify you on -ADC hubs.</dd> + <dt>PID</dt> + <dd>This is your unique private ID (PID). This will later with an algorithm be used to identify you on ADC hubs. <span style="font-weight: bold;">Do not share this with other users.</span></dd> <dt>Auto refresh time</dt> <dd>This controls the interval at which your shared directories are rescanned for new and changed content. This is measured in minutes (default: 60 minutes)</dd> - <dt>Write Buffer Size</dt> <dd>This controls the size of the chunks that DC++ writes to disk for downloads. Measured in kibibytes. (default: 16 KiB)</dd> - <dt>Max Tab Rows</dt> - <dd>The maximum number of rows of tabs that DC++ will make. Any -tabs that do not fit will be accessible through the chevron at the -right of the tab control. (default: 2)</dd> <dt><a name="searchhistory"></a>Search history</dt> <dd>Number of old search lines that will be shown in the Search @@ -76,6 +70,8 @@ <dt>Socket write buffer</dt> <dd>The size of the buffer DC++ use to write to sockets. Measured in bytes. (default: 8192 bytes)</dd> + <dt>Auto-search limit</dt> + <dd>This will limit the amount of sources a file can have before it will no longer be auto searched for. For example, if this option is set to 2, if a file has more than or exactly 2 sources, the file will be excluded from the auto-search list.</dd> </dl> </body> </html> Modified: dcplusplus/trunk/help/settings_queue.html =================================================================== --- dcplusplus/trunk/help/settings_queue.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_queue.html 2006-11-02 21:44:12 UTC (rev 684) @@ -103,8 +103,10 @@ one, will consume some drive space.</dd> <dt>Don't download files already in share</dt> <dd>This option will stop you from downloading files which already -exist in one of your shared directories. Note that this only works with -those files which have a TTH.</dd> +exist in one of your shared directories.</dd> + <dt>Don't download files already in queue</dt> + <dd>This option will stop you from downloading files which already +exist in your queue.</dd> <dt><a name="antifrag"></a>Use AntiFragmentation Method for Downloads</dt> <dd>This option will try to reserve the full space needed for a file @@ -124,8 +126,6 @@ block fails verification, the previous block in the file will be tried, and so on, until a good block is found, or there is no more data in the file.</dd> - <dt>Only download files that have a TTH</dt> - <dd>With this option enabled, DC++ will <span style="font-weight: bold;">only</span> download files that have a TTH.</dd> </dl> </div> </body> Modified: dcplusplus/trunk/help/settings_windows.html =================================================================== --- dcplusplus/trunk/help/settings_windows.html 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/settings_windows.html 2006-11-02 21:44:12 UTC (rev 684) @@ -45,11 +45,16 @@ lessens the (user-friendly) Direct Connect experience, but is not always wise because failing to reply to a message from an Operator can get you kicked or, in the worst case, permanently banned from that hub.</span></dd> - <dt>Open Private Messages From Offline Users in Their Own Window</dt> + <dt>Open Private Messages from bots in their Own Window</dt> <dd>Enable this if you want messages from hub bots in their own window. When disabled they get sent as a status message in main chat instead which is less annoying yet still informative. <span style="font-style: italic;">This option only matters if you're not -ignoring private messages from offline users (previous option).</span></dd> +ignoring private messages from bots.</span></dd> + <dt>Open Private Messages from the hub in their Own Window</dt> + <dd>Enable this if you want messages from the hub in their own +window. When disabled they get sent as a status message in main chat +instead which is less annoying yet still informative. <span style="font-style: italic;">This option only matters if you're not +ignoring private messages from hubs.</span></dd> <dt>Open New File List Windows in the Background</dt> <dd>Keep this disabled if you want newly downloaded file lists to pop up in front of other windows. <span style="font-style: italic;">It can @@ -60,16 +65,17 @@ pop up in front of other windows.</dd> <dt><a name="new_window"></a>Open new window when using /join</dt> <dd>When using /join <ip>, a new window with the hub will open.</dd> - <dt>Ignore Private Messages From Offline Users</dt> - <dd>Enable this if you wish to ignore private messages from users -that are not online on the hub. These messages originate from hub bots -and generally contain useful information, like hub specific rules or -warnings.</dd> + <dt>Ignore Private Messages From the hub</dt> + <dd>Enable this if you wish to ignore private messages from the hub. However, these messages originate are generally contain useful information, like hub specific rules or warnings.</dd> + <dt>Ignore Private Messages From bots</dt> + <dd>Enable this if you wish to ignore private messages from bots. However, these messages originate are generally contain useful information, like hub specific rules or warnings.</dd> <dt>Toggle window when selecting an active tab</dt> <dd>With this option enabled, clicking on an active tab will mimic the behavior of Windows 98+ and send the currently active window to the background. The most recently accessed window will become the new active window.</dd> + <dt>Popup box to input password for hubs</dt> + <dd>When being prompted for a password in a hub, you will with this option enabled have a box popup and will allow you to enter your password. With this option disabled, you will be prompted with a "/password" instead. </dl> <h2>Confirm dialog options</h2> <dl style="margin-left: 40px;"> Modified: dcplusplus/trunk/help/toc.hhc =================================================================== --- dcplusplus/trunk/help/toc.hhc 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/help/toc.hhc 2006-11-02 21:44:12 UTC (rev 684) @@ -29,6 +29,10 @@ <param name="Local" value="adlsearch.html"> </OBJECT> <LI> <OBJECT type="text/sitemap"> + <param name="Name" value="Public Hubs"> + <param name="Local" value="public_hubs.html"> + </OBJECT> + <LI> <OBJECT type="text/sitemap"> <param name="Name" value="Favorite Hubs"> <param name="Local" value="favorite_hubs.html"> </OBJECT> @@ -122,6 +126,10 @@ <param name="Local" value="settings_colors_and_sounds.html"> </OBJECT> <LI> <OBJECT type="text/sitemap"> + <param name="Name" value="Tabs"> + <param name="Local" value="settings_tabs.html"> + </OBJECT> + <LI> <OBJECT type="text/sitemap"> <param name="Name" value="Windows"> <param name="Local" value="settings_windows.html"> </OBJECT> Modified: dcplusplus/trunk/windows/Appearance2Page.cpp =================================================================== --- dcplusplus/trunk/windows/Appearance2Page.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/Appearance2Page.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -26,7 +26,8 @@ #include "WinUtil.h" PropPage::TextItem Appearance2Page::texts[] = { - { IDC_SETTINGS_BOLD_CONTENTS, ResourceManager::SETTINGS_BOLD_OPTIONS }, + { IDC_BEEP_NOTIFICATION, ResourceManager::SETTINGS_NOTIFICATION_SOUND }, + { IDC_BROWSE, ResourceManager::BROWSE_ACCEL }, { IDC_SETTINGS_COLORS, ResourceManager::SETTINGS_COLORS }, { IDC_SELWINCOLOR, ResourceManager::SETTINGS_SELECT_WINDOW_COLOR }, { IDC_SELTEXT, ResourceManager::SETTINGS_SELECT_TEXT_FACE }, @@ -43,21 +44,10 @@ PropPage::Item Appearance2Page::items[] = { { IDC_PRIVATE_MESSAGE_BEEP, SettingsManager::PRIVATE_MESSAGE_BEEP, PropPage::T_BOOL }, { IDC_PRIVATE_MESSAGE_BEEP_OPEN, SettingsManager::PRIVATE_MESSAGE_BEEP_OPEN, PropPage::T_BOOL }, + { IDC_BEEPFILE, SettingsManager::BEEPFILE, PropPage::T_STR }, { 0, 0, PropPage::T_END } }; -PropPage::ListItem Appearance2Page::listItems[] = { - { SettingsManager::BOLD_FINISHED_DOWNLOADS, ResourceManager::FINISHED_DOWNLOADS }, - { SettingsManager::BOLD_FINISHED_UPLOADS, ResourceManager::FINISHED_UPLOADS }, - { SettingsManager::BOLD_QUEUE, ResourceManager::DOWNLOAD_QUEUE }, - { SettingsManager::BOLD_HUB, ResourceManager::HUB }, - { SettingsManager::BOLD_PM, ResourceManager::PRIVATE_MESSAGE }, - { SettingsManager::BOLD_SEARCH, ResourceManager::SEARCH }, - { SettingsManager::BOLD_WAITING_USERS, ResourceManager::WAITING_USERS }, - { SettingsManager::BOLD_SYSTEM_LOG, ResourceManager::SYSTEM_LOG }, - { 0, ResourceManager::SETTINGS_AUTO_AWAY } -}; - Appearance2Page::~Appearance2Page() { ::DeleteObject(bgbrush); @@ -69,7 +59,7 @@ PropPage::translate((HWND)(*this), texts); ctrlExample.Attach(GetDlgItem(IDC_COLOREXAMPLE)); - PropPage::read((HWND)*this, items, listItems,GetDlgItem(IDC_BOLD_BOOLEANS)); + PropPage::read((HWND)*this, items, 0, 0); WinUtil::decodeFont(Text::toT(SETTING(TEXT_FONT)), font); // Do specialized reading here @@ -84,7 +74,7 @@ void Appearance2Page::write() { - PropPage::write((HWND)*this, items, listItems,GetDlgItem(IDC_BOLD_BOOLEANS)); + PropPage::write((HWND)*this, items, 0,0); settings->set(SettingsManager::TEXT_COLOR, (int)fg); settings->set(SettingsManager::BACKGROUND_COLOR, (int)bg); @@ -95,6 +85,18 @@ settings->set(SettingsManager::TEXT_FONT, Text::fromT(f)); } +LRESULT Appearance2Page::onBrowse(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + TCHAR buf[MAX_PATH]; + + GetDlgItemText(IDC_BEEPFILE, buf, MAX_PATH); + tstring x = buf; + + if(WinUtil::browseFile(x, m_hWnd, false) == IDOK) { + SetDlgItemText(IDC_BEEPFILE, x.c_str()); + } + return 0; +} + LRESULT Appearance2Page::onClickedBackground(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CColorDialog d(SETTING(BACKGROUND_COLOR), 0, *this); Modified: dcplusplus/trunk/windows/Appearance2Page.h =================================================================== --- dcplusplus/trunk/windows/Appearance2Page.h 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/Appearance2Page.h 2006-11-02 21:44:12 UTC (rev 684) @@ -41,6 +41,7 @@ MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) MESSAGE_HANDLER(WM_CTLCOLORSTATIC, onCtlColor) MESSAGE_HANDLER(WM_HELP, onHelp) + COMMAND_HANDLER(IDC_BROWSE, BN_CLICKED, onBrowse) COMMAND_ID_HANDLER(IDC_SELTEXT, onClickedText) COMMAND_ID_HANDLER(IDC_SELWINCOLOR, onClickedBackground) COMMAND_ID_HANDLER(IDC_SETTINGS_UPLOAD_BAR_COLOR, onPickColor) @@ -49,6 +50,7 @@ END_MSG_MAP() LRESULT onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT onBrowse(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onHelp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT onClickedText(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT onClickedBackground(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); @@ -66,7 +68,6 @@ static Item items[]; static TextItem texts[]; - static ListItem listItems[]; CStatic ctrlExample; COLORREF fg, bg, upBar, downBar; Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -1295,6 +1295,12 @@ hubName += " - " + client->getHubDescription(); } hubName += " (" + client->getHubUrl() + ")"; +#ifdef _DEBUG + string version = client->getHubIdentity().get("VE"); + if(!version.empty()) { + hubName += " - " + version; + } +#endif speak(SET_WINDOW_TITLE, hubName); } void HubFrame::on(Message, Client*, const OnlineUser& from, const string& msg) throw() { Modified: dcplusplus/trunk/windows/PrivateFrame.cpp =================================================================== --- dcplusplus/trunk/windows/PrivateFrame.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/PrivateFrame.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -17,6 +17,7 @@ */ #include "stdafx.h" +#include <mmsystem.h> #include "../client/DCPlusPlus.h" #include "Resource.h" @@ -86,11 +87,17 @@ } if(BOOLSETTING(PRIVATE_MESSAGE_BEEP) || BOOLSETTING(PRIVATE_MESSAGE_BEEP_OPEN)) { - MessageBeep(MB_OK); + if (SETTING(BEEPFILE).empty()) + MessageBeep(MB_OK); + else + ::PlaySound(Text::toT(SETTING(BEEPFILE)).c_str(), NULL, SND_FILENAME | SND_ASYNC); } } else { if(BOOLSETTING(PRIVATE_MESSAGE_BEEP)) { - MessageBeep(MB_OK); + if (SETTING(BEEPFILE).empty()) + MessageBeep(MB_OK); + else + ::PlaySound(Text::toT(SETTING(BEEPFILE)).c_str(), NULL, SND_FILENAME | SND_ASYNC); } i->second->addLine(aMessage); } Modified: dcplusplus/trunk/windows/PropertiesDlg.cpp =================================================================== --- dcplusplus/trunk/windows/PropertiesDlg.cpp 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/PropertiesDlg.cpp 2006-11-02 21:44:12 UTC (rev 684) @@ -36,6 +36,7 @@ #include "WindowsPage.h" #include "QueuePage.h" #include "CertificatesPage.h" +#include "TabsPage.h" PropertiesDlg::PropertiesDlg(HWND parent, SettingsManager *s) : TreePropertySheet(CTSTRING(SETTINGS), 0, parent) { @@ -48,6 +49,7 @@ pages[n++] = new UploadPage(s); pages[n++] = new AppearancePage(s); pages[n++] = new Appearance2Page(s); + pages[n++] = new TabsPage(s); pages[n++] = new WindowsPage(s); pages[n++] = new AdvancedPage(s); pages[n++] = new LogPage(s); Modified: dcplusplus/trunk/windows/PropertiesDlg.h =================================================================== --- dcplusplus/trunk/windows/PropertiesDlg.h 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/PropertiesDlg.h 2006-11-02 21:44:12 UTC (rev 684) @@ -29,7 +29,7 @@ class PropertiesDlg : public TreePropertySheet { public: - enum { numPages = 14 }; + enum { numPages = 15 }; BEGIN_MSG_MAP(PropertiesDlg) COMMAND_ID_HANDLER(IDOK, onOK) Modified: dcplusplus/trunk/windows/resource.h =================================================================== --- dcplusplus/trunk/windows/resource.h 2006-10-20 12:35:20 UTC (rev 683) +++ dcplusplus/trunk/windows/resource.h 2006-11-02 21:44:12 UTC (rev 684) @@ -54,6 +54,7 @@ #define IDD_WINDOWSPAGE 244 #define IDD_QUEUEPAGE 245 #define IDD_CERTIFICATESPAGE 246 +#define IDD_TABSPAGE 247 #define IDC_REFRESH 1000 #define IDC_NICK 1001 #define IDC_EMAIL 1002 @@ -431,6 +432,8 @@ #define IDC_CLOSE_ALL_SEARCH_FRAME 1426 #define IDC_SETTINGS_PORT_TLS 1427 #define IDC_MATCH_ALL 1428 +#define IDC_BEEPFILE 1429 +#define IDC_BEEP_NOTIFICATION 1430 #define IDC_BROWSELIST 3000 #define IDC_REMOVE_SOURCE 3500 #define IDC_PM 4000 @@ -472,7 +475,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 247 #define _APS_NEXT_COMMAND_VALUE 32789 -#define _APS_NEXT_CONTROL_VALUE 1429 +#define _APS_NEXT_CONTROL_VALUE 1431 #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-10-20 12:35:41
|
Revision: 683 http://svn.sourceforge.net/dcplusplus/?rev=683&view=rev Author: arnetheduck Date: 2006-10-20 05:35:20 -0700 (Fri, 20 Oct 2006) Log Message: ----------- dupe cid detection Modified Paths: -------------- dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/release.cmd Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-10-18 21:36:08 UTC (rev 682) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-10-20 12:35:20 UTC (rev 683) @@ -73,6 +73,16 @@ return i == users.end() ? NULL : i->second; } +OnlineUser* AdcHub::findUser(const CID& aCID) const { + Lock l(cs); + for(SIDMap::const_iterator i = users.begin(); i != users.end(); ++i) { + if(i->second->getUser()->getCID() == aCID) { + return i->second; + } + } + return 0; +} + void AdcHub::putUser(const uint32_t aSID) { OnlineUser* ou = 0; { @@ -112,12 +122,27 @@ string cid; OnlineUser* u = 0; - if(c.getParam("ID", 0, cid)) - u = &getUser(c.getFrom(), CID(cid)); - else if(c.getFrom() == AdcCommand::HUB_SID) + if(c.getParam("ID", 0, cid)) { + u = findUser(CID(cid)); + if(u) { + if(u->getIdentity().getSID() != c.getFrom()) { + // Same CID but different SID not allowed - buggy hub? + string nick; + if(!c.getParam("NI", 0, nick)) { + nick = "[nick unknown]"; + } + fire(ClientListener::StatusMessage(), this, u->getIdentity().getNick() + " (" + u->getIdentity().getSIDString() + + ") has same CID {" + cid + "} as " + nick + " (" + AdcCommand::fromSID(c.getFrom()) + "), ignoring."); + return; + } + } else { + u = &getUser(c.getFrom(), CID(cid)); + } + } else if(c.getFrom() == AdcCommand::HUB_SID) { u = &getUser(c.getFrom(), CID()); - else + } else { u = findUser(c.getFrom()); + } if(!u) { dcdebug("AdcHub::INF Unknown user / no ID\n"); Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-10-18 21:36:08 UTC (rev 682) +++ dcplusplus/trunk/client/AdcHub.h 2006-10-20 12:35:20 UTC (rev 683) @@ -84,6 +84,7 @@ OnlineUser& getUser(const uint32_t aSID, const CID& aCID); OnlineUser* findUser(const uint32_t sid) const; + OnlineUser* findUser(const CID& cid) const; void putUser(const uint32_t sid); void clearUsers(); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-10-18 21:36:08 UTC (rev 682) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-20 12:35:20 UTC (rev 683) @@ -223,10 +223,9 @@ throw ShareException(UserConnection::FILE_NOT_AVAILABLE); } - string::size_type i = virtualFile.find('/', 1); if(i == string::npos || i == 1) { - return false; + throw ShareException(UserConnection::FILE_NOT_AVAILABLE); } string virtualName = virtualFile.substr(1, i-1); Modified: dcplusplus/trunk/release.cmd =================================================================== --- dcplusplus/trunk/release.cmd 2006-10-18 21:36:08 UTC (rev 682) +++ dcplusplus/trunk/release.cmd 2006-10-20 12:35:20 UTC (rev 683) @@ -2,7 +2,7 @@ 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 +"c:\program files\WinRAR\WinRAR" a -m5 DCPlusPlus-%1-src.zip dcppboot.xml makedefs.py 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\* res\* windows\* changelog.txt Example.xml License.txt compile.txt GeoIPCountryWhois.csv *.vcproj *.sln *.rc extensions.txt doxyfile dcplusplus.nsi del dcplusplus.exe del dcplusplus.pdb del dcplusplus.chm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-18 21:36:20
|
Revision: 682 http://svn.sourceforge.net/dcplusplus/?rev=682&view=rev Author: arnetheduck Date: 2006-10-18 14:36:08 -0700 (Wed, 18 Oct 2006) Log Message: ----------- stlport removal Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.vcproj dcplusplus/trunk/changelog.txt dcplusplus/trunk/client.vcproj Removed Paths: ------------- dcplusplus/trunk/bootstrap dcplusplus/trunk/stlport/ Modified: dcplusplus/trunk/DCPlusPlus.vcproj =================================================================== --- dcplusplus/trunk/DCPlusPlus.vcproj 2006-10-18 19:43:41 UTC (rev 681) +++ dcplusplus/trunk/DCPlusPlus.vcproj 2006-10-18 21:36:08 UTC (rev 682) @@ -46,7 +46,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" + AdditionalIncludeDirectories=""$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" @@ -155,7 +155,7 @@ FavorSizeOrSpeed="2" OmitFramePointers="true" EnableFiberSafeOptimizations="true" - AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" + AdditionalIncludeDirectories=""$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" Deleted: dcplusplus/trunk/bootstrap =================================================================== --- dcplusplus/trunk/bootstrap 2006-10-18 19:43:41 UTC (rev 681) +++ dcplusplus/trunk/bootstrap 2006-10-18 21:36:08 UTC (rev 682) @@ -1,9 +0,0 @@ -#!/bin/sh -echo "bootstrapping (this may take a while)" -rm -rf build -mkdir build -aclocal && -libtoolize && -autoconf && -autoheader && -automake --add-missing --force-missing || exit Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-18 19:43:41 UTC (rev 681) +++ dcplusplus/trunk/changelog.txt 2006-10-18 21:36:08 UTC (rev 682) @@ -8,6 +8,7 @@ * Automatic hub reconnection is only done if at least one successful connection has been made * [bug 1080] Better nick tab completion (thanks cologic) * [bug 1081] Added user IP in hub frame (thanks cologic) +* No more STLport for the time being -- 0.698 2006-10-10 -- * [bug 1065] Code cleanup (thanks steven sheehy) Modified: dcplusplus/trunk/client.vcproj =================================================================== --- dcplusplus/trunk/client.vcproj 2006-10-18 19:43:41 UTC (rev 681) +++ dcplusplus/trunk/client.vcproj 2006-10-18 21:36:08 UTC (rev 682) @@ -42,7 +42,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" + AdditionalIncludeDirectories=""$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" @@ -128,7 +128,7 @@ FavorSizeOrSpeed="2" OmitFramePointers="true" EnableFiberSafeOptimizations="true" - AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" + AdditionalIncludeDirectories=""$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-18 19:44:19
|
Revision: 681 http://svn.sourceforge.net/dcplusplus/?rev=681&view=rev Author: arnetheduck Date: 2006-10-18 12:43:41 -0700 (Wed, 18 Oct 2006) Log Message: ----------- cleanup, patches Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.vcproj dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/DCPlusPlus.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/client.vcproj dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h Removed Paths: ------------- dcplusplus/trunk/client/config.h Modified: dcplusplus/trunk/DCPlusPlus.vcproj =================================================================== --- dcplusplus/trunk/DCPlusPlus.vcproj 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/DCPlusPlus.vcproj 2006-10-18 19:43:41 UTC (rev 681) @@ -47,7 +47,6 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" - PreprocessorDefinitions="HAVE_STLPORT" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" @@ -157,7 +156,6 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" - PreprocessorDefinitions="HAVE_STLPORT" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/changelog.txt 2006-10-18 19:43:41 UTC (rev 681) @@ -5,6 +5,9 @@ * Confirm hub removal is now default * SFV checking is now default * Fixed TLS port not being greyed out +* Automatic hub reconnection is only done if at least one successful connection has been made +* [bug 1080] Better nick tab completion (thanks cologic) +* [bug 1081] Added user IP in hub frame (thanks cologic) -- 0.698 2006-10-10 -- * [bug 1065] Code cleanup (thanks steven sheehy) Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-10-18 19:43:41 UTC (rev 681) @@ -39,7 +39,7 @@ const string AdcHub::TCP4_FEATURE("TCP4"); const string AdcHub::UDP4_FEATURE("UDP4"); -AdcHub::AdcHub(const string& aHubURL, bool secure) : Client(aHubURL, '\n', secure), state(STATE_PROTOCOL), sid(0), reconnect(true) { +AdcHub::AdcHub(const string& aHubURL, bool secure) : Client(aHubURL, '\n', secure), sid(0) { TimerManager::getInstance()->addListener(this); } @@ -48,6 +48,7 @@ clearUsers(); } + OnlineUser& AdcHub::getUser(const uint32_t aSID, const CID& aCID) { OnlineUser* ou = findUser(aSID); if(ou) { @@ -146,6 +147,7 @@ if(u->getUser() == getMyIdentity().getUser()) { state = STATE_NORMAL; + setAutoReconnect(true); setMyIdentity(u->getIdentity()); updateCounts(false); } @@ -219,7 +221,13 @@ } void AdcHub::handle(AdcCommand::QUI, AdcCommand& c) throw() { - putUser(AdcCommand::toSID(c.getParam(0))); + uint32_t s = AdcCommand::toSID(c.getParam(0)); + putUser(s); + + // No use to hammer if we're banned + if(s == sid && c.hasFlag("TL", 1)) { + setAutoReconnect(false); + } } void AdcHub::handle(AdcCommand::CTM, AdcCommand& c) throw() { @@ -574,16 +582,24 @@ return tmp; } +void AdcHub::send(const AdcCommand& cmd) { + if(cmd.getType() == AdcCommand::TYPE_UDP) + sendUDP(cmd); + send(cmd.toString(sid)); +} + void AdcHub::on(Connected) throw() { - dcassert(state == STATE_PROTOCOL); + Client::on(Connected()); + lastInfoMap.clear(); - reconnect = true; + sid = 0; + send(AdcCommand(AdcCommand::CMD_SUP, AdcCommand::TYPE_HUB).addParam("ADBAS0")); - - fire(ClientListener::Connected(), this); } void AdcHub::on(Line, const string& aLine) throw() { + Client::on(Line(), aLine); + if(BOOLSETTING(ADC_DEBUG)) { fire(ClientListener::StatusMessage(), this, "<ADC>" + aLine + "</ADC>"); } @@ -592,23 +608,12 @@ void AdcHub::on(Failed, const string& aLine) throw() { clearUsers(); - socket->removeListener(this); - state = STATE_PROTOCOL; - fire(ClientListener::Failed(), this, aLine); + Client::on(Failed(), aLine); } -void AdcHub::send(const AdcCommand& cmd) { - dcassert(socket); - if(!socket) - return; - if(cmd.getType() == AdcCommand::TYPE_UDP) - sendUDP(cmd); - send(cmd.toString(sid)); -} - void AdcHub::on(Second, uint32_t aTick) throw() { - if(getAutoReconnect() && state == STATE_PROTOCOL && (getReconnecting() || ((getLastActivity() + getReconnDelay() * 1000) < aTick)) ) { - // Try to reconnect... - connect(); + Client::on(Second(), aTick); + if(state == STATE_NORMAL && (aTick > (getLastActivity() + 120*1000)) ) { + send("\n", 1); } } Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/AdcHub.h 2006-10-18 19:43:41 UTC (rev 681) @@ -56,13 +56,6 @@ friend class ClientManager; friend class CommandHandler<AdcHub>; - enum States { - STATE_PROTOCOL, - STATE_IDENTIFY, - STATE_VERIFY, - STATE_NORMAL - } state; - AdcHub(const string& aHubURL, bool secure); AdcHub(const AdcHub&); @@ -79,9 +72,7 @@ mutable CriticalSection cs; string salt; - uint32_t sid; - bool reconnect; static const string CLIENT_PROTOCOL; static const string SECURE_CLIENT_PROTOCOL; @@ -110,9 +101,7 @@ void handle(AdcCommand::CMD, AdcCommand& c) throw(); void handle(AdcCommand::RES, AdcCommand& c) throw(); - template<typename T> void handle(T, AdcCommand&) { - //Speaker<AdcHubListener>::fire(t, this, c); - } + template<typename T> void handle(T, AdcCommand&) { } void sendUDP(const AdcCommand& cmd) throw(); @@ -122,6 +111,7 @@ virtual void on(Failed, const string& aLine) throw(); virtual void on(Second, uint32_t aTick) throw(); + }; #endif // !defined(ADC_HUB_H) Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/Client.cpp 2006-10-18 19:43:41 UTC (rev 681) @@ -31,7 +31,7 @@ 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(false), state(STATE_DISCONNECTED), socket(0), hubUrl(hubURL), port(0), separator(separator_), secure(secure_), countType(COUNT_UNCOUNTED) { @@ -50,7 +50,7 @@ void Client::reconnect() { disconnect(true); setAutoReconnect(true); - setReconnecting(true); + setReconnDelay(0); } void Client::shutdown() { @@ -88,7 +88,6 @@ BufferedSocket::putSocket(socket); setAutoReconnect(true); - setReconnecting(false); setReconnDelay(120 + Util::rand(0, 60)); reloadSettings(true); setRegistered(false); @@ -107,18 +106,25 @@ fire(ClientListener::Failed(), this, e.getError()); } updateActivity(); + state = STATE_CONNECTING; } void Client::on(Connected) throw() { updateActivity(); ip = socket->getIp(); fire(ClientListener::Connected(), this); + state = STATE_PROTOCOL; } +void Client::on(Failed, const string& aLine) throw() { + state = STATE_DISCONNECTED; + socket->removeListener(this); + fire(ClientListener::Failed(), this, aLine); +} + void Client::disconnect(bool graceLess) { - if(!socket) - return; - socket->disconnect(graceLess); + if(socket) + socket->disconnect(graceLess); } void Client::updateCounts(bool aRemove) { @@ -166,5 +172,13 @@ return lip; } -void Client::on(Second, uint32_t) throw() { +void Client::on(Line, const string& /*aLine*/) throw() { + updateActivity(); } + +void Client::on(Second, uint32_t aTick) throw() { + if(state == STATE_DISCONNECTED && getAutoReconnect() && (aTick > (getLastActivity() + getReconnDelay() * 1000)) ) { + // Try to reconnect... + connect(); + } +} Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/Client.h 2006-10-18 19:43:41 UTC (rev 681) @@ -153,7 +153,6 @@ GETSET(uint32_t, lastActivity, LastActivity); GETSET(bool, registered, Registered); GETSET(bool, autoReconnect, AutoReconnect); - GETSET(bool, reconnecting, Reconnecting); GETSET(string, currentNick, CurrentNick); GETSET(string, currentDescription, CurrentDescription); @@ -169,6 +168,15 @@ bool operator !=(const Counts& rhs) { return normal != rhs.normal || registered != rhs.registered || op != rhs.op; } }; + enum States { + STATE_CONNECTING, ///< Waiting for socket to connect + STATE_PROTOCOL, ///< Protocol setup + STATE_IDENTIFY, ///< Nick setup + STATE_VERIFY, ///< Checking password + STATE_NORMAL, ///< Running + STATE_DISCONNECTED, ///< Nothing in particular + } state; + BufferedSocket* socket; static Counts counts; @@ -184,6 +192,11 @@ // TimerManagerListener virtual void on(Second, uint32_t aTick) throw(); + // BufferedSocketListener + virtual void on(Connecting) throw() { fire(ClientListener::Connecting(), this); } + virtual void on(Connected) throw(); + virtual void on(Line, const string& aLine) throw(); + virtual void on(Failed, const string&) throw(); private: @@ -204,12 +217,6 @@ char separator; bool secure; CountType countType; - - // BufferedSocketListener - virtual void on(Connecting) throw() { fire(ClientListener::Connecting(), this); } - virtual void on(Connected) throw(); - - }; #endif // !defined(CLIENT_H) Modified: dcplusplus/trunk/client/DCPlusPlus.h =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/DCPlusPlus.h 2006-10-18 19:43:41 UTC (rev 681) @@ -100,6 +100,37 @@ typedef vector<WStringPair> WStringPairList; typedef WStringPairList::iterator WStringPairIter; +#if defined(_MSC_VER) +#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 + +# define PATH_SEPARATOR '\\' +# define PATH_SEPARATOR_STR "\\" + +#else + +# define PATH_SEPARATOR '/' +# define PATH_SEPARATOR_STR "/" + +#endif + + typedef HASH_MAP<wstring, wstring> WStringMap; typedef WStringMap::iterator WStringMapIter; Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-10-18 19:43:41 UTC (rev 681) @@ -32,7 +32,7 @@ #include "UserCommand.h" #include "StringTokenizer.h" -NmdcHub::NmdcHub(const string& aHubURL) : Client(aHubURL, '|', false), supportFlags(0), state(STATE_CONNECT), +NmdcHub::NmdcHub(const string& aHubURL) : Client(aHubURL, '|', false), supportFlags(0), lastUpdate(0) { } @@ -41,19 +41,9 @@ clearUsers(); } -void NmdcHub::connect() { - supportFlags = 0; - lastMyInfoA.clear(); - lastMyInfoB.clear(); - lastUpdate = 0; - state = STATE_LOCK; +#define checkstate() if(state != STATE_NORMAL) return - Client::connect(); -} - -#define checkstate() if(state != STATE_CONNECTED) return - void NmdcHub::connect(const OnlineUser& aUser) { checkstate(); dcdebug("NmdcHub::connect %s\n", aUser.getIdentity().getNick().c_str()); @@ -178,14 +168,12 @@ } void NmdcHub::onLine(const string& aLine) throw() { - updateActivity(); - if(aLine.length() == 0) return; if(aLine[0] != '$') { // Check if we're being banned... - if(state != STATE_CONNECTED) { + if(state != STATE_NORMAL) { if(Util::findSubString(aLine, "banned") != string::npos) { setAutoReconnect(false); } @@ -236,7 +224,7 @@ } if(cmd == "$Search") { - if(state != STATE_CONNECTED) { + if(state != STATE_NORMAL) { return; } string::size_type i = 0; @@ -411,7 +399,7 @@ putUser(nick); } } else if(cmd == "$ConnectToMe") { - if(state != STATE_CONNECTED) { + if(state != STATE_NORMAL) { return; } string::size_type i = param.find(' '); @@ -431,7 +419,7 @@ string port = param.substr(j+1); ConnectionManager::getInstance()->nmdcConnect(server, (unsigned short)Util::toInt(port), getMyNick(), getHubUrl()); } else if(cmd == "$RevConnectToMe") { - if(state != STATE_CONNECTED) { + if(state != STATE_NORMAL) { return; } @@ -515,10 +503,10 @@ fire(ClientListener::UserCommand(), this, type, ctx, name, command); } } else if(cmd == "$Lock") { - if(state != STATE_LOCK) { + if(state != STATE_PROTOCOL) { return; } - state = STATE_HELLO; + state = STATE_IDENTIFY; // Param must not be fromAcp'd... param = aLine.substr(6); @@ -568,8 +556,8 @@ u.getUser()->setFlag(User::PASSIVE); } - if(state == STATE_HELLO && u.getUser() == getMyIdentity().getUser()) { - state = STATE_CONNECTED; + if(state == STATE_IDENTIFY && u.getUser() == getMyIdentity().getUser()) { + state = STATE_NORMAL; updateCounts(false); version(); @@ -626,7 +614,7 @@ v.push_back(&getUser(*it)); } - if(!(getSupportFlags() & SUPPORTS_NOGETINFO)) { + if(!(supportFlags & SUPPORTS_NOGETINFO)) { string tmp; // Let's assume 10 characters per nick... tmp.reserve(v.size() * (11 + 10 + getMyNick().length())); @@ -901,24 +889,29 @@ } } -// TimerManagerListener -void NmdcHub::on(Second, uint32_t aTick) throw() { - 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 && (getReconnecting() || ((getLastActivity() + getReconnDelay() * 1000) < aTick))) { - // Try to reconnect... - connect(); - } +void NmdcHub::on(Connected) throw() { + Client::on(Connected()); - Client::on(Second(), aTick); + supportFlags = 0; + lastMyInfoA.clear(); + lastMyInfoB.clear(); + lastUpdate = 0; } -// BufferedSocketListener -void NmdcHub::on(BufferedSocketListener::Failed, const string& aLine) throw() { +void NmdcHub::on(Line, const string& aLine) throw() { + Client::on(Line(), aLine); + onLine(aLine); +} + +void NmdcHub::on(Failed, const string& aLine) throw() { clearUsers(); - socket->removeListener(this); - state = STATE_CONNECT; - fire(ClientListener::Failed(), this, aLine); + Client::on(Failed(), aLine); } + +void NmdcHub::on(Second, uint32_t aTick) throw() { + Client::on(Second(), aTick); + + if(state == STATE_NORMAL && (aTick > (getLastActivity() + 120*1000)) ) { + send("|", 1); + } +} Modified: dcplusplus/trunk/client/NmdcHub.h =================================================================== --- dcplusplus/trunk/client/NmdcHub.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/NmdcHub.h 2006-10-18 19:43:41 UTC (rev 681) @@ -37,8 +37,8 @@ { public: using Client::send; + using Client::connect; - virtual void connect(); virtual void connect(const OnlineUser& aUser); virtual void hubMessage(const string& aMessage); @@ -57,8 +57,6 @@ virtual void send(const AdcCommand&) { dcassert(0); } static string validateMessage(string tmp, bool reverse); - - GETSET(int, supportFlags, SupportFlags); private: friend class ClientManager; enum SupportFlags { @@ -67,13 +65,6 @@ SUPPORTS_USERIP2 = 0x04 }; - enum States { - STATE_CONNECT, - STATE_LOCK, - STATE_HELLO, - STATE_CONNECTED - } state; - mutable CriticalSection cs; typedef HASH_MAP_X(string, OnlineUser*, noCaseStringHash, noCaseStringEq, noCaseStringLess) NickMap; @@ -81,6 +72,7 @@ NickMap users; + int supportFlags; uint32_t lastUpdate; string lastMyInfoA, lastMyInfoB; @@ -123,7 +115,8 @@ // TimerManagerListener virtual void on(Second, uint32_t aTick) throw(); - virtual void on(Line, const string& l) throw() { onLine(l); } + virtual void on(Connected) throw(); + virtual void on(Line, const string& l) throw(); virtual void on(Failed, const string&) throw(); }; Deleted: dcplusplus/trunk/client/config.h =================================================================== --- dcplusplus/trunk/client/config.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/config.h 2006-10-18 19:43:41 UTC (rev 681) @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#if !defined(CONFIG_H) -#define CONFIG_H - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifdef HAVE_CONFIG_H -#include "autoconf.h" -#endif - -// Remove this line if hashes are not available in your stl -#define HAVE_HASH 1 - -// This enables stlport's debug mode (and slows it down to a crawl...) -//#define _STLP_DEBUG 1 -//#define _STLP_USE_NEWALLOC 1 - -// --- Shouldn't have to change anything under here... - -#ifndef _REENTRANT -# define _REENTRANT 1 -#endif - -#ifdef HAVE_STLPORT -# define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 // Lots of memory issues with this undefined...wonder what's up with that.. -# define _STLP_USE_PTR_SPECIALIZATIONS 1 -# define _STLP_NO_ANACHRONISMS 1 -# define _STLP_NO_CUSTOM_IO 1 -# define _STLP_NO_IOSTREAMS 1 -# ifndef _DEBUG -# define _STLP_DONT_USE_EXCEPTIONS 1 -# endif -#endif - -#ifdef _MSC_VER -# pragma warning(disable: 4711) // function 'xxx' selected for automatic inline expansion -# pragma warning(disable: 4786) // identifier was truncated to '255' characters in the debug information -# pragma warning(disable: 4290) // C++ Exception Specification ignored -# pragma warning(disable: 4127) // constant expression -# pragma warning(disable: 4710) // function not inlined -# pragma warning(disable: 4503) // decorated name length exceeded, name was truncated -# pragma warning(disable: 4428) // universal-character-name encountered in source - -# if _MSC_VER == 1200 || _MSC_VER == 1300 || _MSC_VER == 1310 || _MSC_VER == 1400 - -typedef signed __int8 int8_t; -typedef signed __int16 int16_t; -typedef signed __int32 int32_t; -typedef signed __int64 int64_t; - -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; - -# endif - -#endif - -#if defined(_MSC_VER) -#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 - -# define PATH_SEPARATOR '\\' -# define PATH_SEPARATOR_STR "\\" - -#else - -# define PATH_SEPARATOR '/' -# define PATH_SEPARATOR_STR "/" - -#endif - -#ifdef _MSC_VER - -# ifndef CDECL -# define CDECL _cdecl -# endif - -#else // _MSC_VER - -# ifndef CDECL -# define CDECL -# endif - -#endif // _MSC_VER - -#define BZ_NO_STDIO - -#ifdef _WIN32 -# define _WIN32_WINNT 0x0501 -# define _WIN32_IE 0x0500 -#endif - -#endif // !defined(CONFIG_H) Modified: dcplusplus/trunk/client/stdinc.h =================================================================== --- dcplusplus/trunk/client/stdinc.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client/stdinc.h 2006-10-18 19:43:41 UTC (rev 681) @@ -19,9 +19,71 @@ #if !defined(STDINC_H) #define STDINC_H -#include "config.h" +// This enables stlport's debug mode (and slows it down to a crawl...) +//#define _STLP_DEBUG 1 +//#define _STLP_USE_NEWALLOC 1 +// --- Shouldn't have to change anything under here... + +#ifndef _REENTRANT +# define _REENTRANT 1 +#endif + +#ifndef BZ_NO_STDIO +#define BZ_NO_STDIO 1 +#endif + +#ifdef HAVE_STLPORT +# define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 // Lots of memory issues with this undefined...wonder what's up with that.. +# define _STLP_USE_PTR_SPECIALIZATIONS 1 +# define _STLP_NO_ANACHRONISMS 1 +# define _STLP_NO_CUSTOM_IO 1 +# define _STLP_NO_IOSTREAMS 1 +# ifndef _DEBUG +# define _STLP_DONT_USE_EXCEPTIONS 1 +# endif +#endif + +#ifdef _MSC_VER + +//disable the deprecated warnings for the CRT functions. +#define _CRT_SECURE_NO_DEPRECATE 1 +#define _ATL_SECURE_NO_DEPRECATE 1 +#define _CRT_NON_CONFORMING_SWPRINTFS 1 + +# pragma warning(disable: 4711) // function 'xxx' selected for automatic inline expansion +# pragma warning(disable: 4786) // identifier was truncated to '255' characters in the debug information +# pragma warning(disable: 4290) // C++ Exception Specification ignored +# pragma warning(disable: 4127) // constant expression +# pragma warning(disable: 4710) // function not inlined +# pragma warning(disable: 4503) // decorated name length exceeded, name was truncated +# pragma warning(disable: 4428) // universal-character-name encountered in source + +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef signed __int64 int64_t; + +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +# ifndef CDECL +# define CDECL _cdecl +# endif + +#else // _MSC_VER + +# ifndef CDECL +# define CDECL +# endif + +#endif // _MSC_VER + #ifdef _WIN32 +# define _WIN32_WINNT 0x0501 +# define _WIN32_IE 0x0500 #define STRICT #define WIN32_LEAN_AND_MEAN @@ -32,13 +94,6 @@ #define _ATL_NO_HOSTING #define _ATL_NO_OLD_NAMES -#if _MSC_VER == 1400 -//disable the deperecated warnings for the crt functions. -#define _CRT_SECURE_NO_DEPRECATE 1 -#define _ATL_SECURE_NO_DEPRECATE 1 -#define _CRT_NON_CONFORMING_SWPRINTFS 1 -#endif - #include <Winsock2.h> #include <windows.h> @@ -68,45 +123,27 @@ #include <functional> // Use maps if hash_maps aren't available -#ifdef HAVE_HASH -# ifdef _STLPORT_VERSION -# define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc, eq > -# define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc, eq > -// STLPort 5.0.2 hash_multimap buggy -# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) multimap<key, type, order > -# elif defined(__GLIBCPP__) || defined(__GLIBCXX__) // Using GNU C++ library? -# define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc, eq > -# define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc, eq > -# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) hash_multimap<key, type, hfunc, eq > -# elif defined(_MSC_VER) // Assume the msvc 7.x stl -# define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc > -# define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc > -# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) hash_multimap<key, type, hfunc > -# else -# error Unknown STL, hashes need to be configured -# endif - +#ifdef _STLPORT_VERSION # define HASH_SET hash_set # define HASH_MAP hash_map +// STLPort 5.0.2 hash_multimap buggy # define HASH_MULTIMAP multimap +# define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc, eq > +# define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc, eq > +# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) multimap<key, type, order > -#else // HAVE_HASH - -# define HASH_SET_X(key, hfunc, eq, order) -# define HASH_SET set -# define HASH_MAP map -# define HASH_MAP_X(key, type, hfunc, eq, order) map<key, type, order > -# define HASH_MULTIMAP multimap -# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) multimap<key, type, order > - -#endif // HAVE_HASH - -#ifdef _STLPORT_VERSION -using namespace std; #include <hash_map> #include <hash_set> +using namespace std; #elif defined(__GLIBCPP__) || defined(__GLIBCXX__) // Using GNU C++ library? +# define HASH_SET hash_set +# define HASH_MAP hash_map +# define HASH_MULTIMAP hash_multimap +# define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc, eq > +# define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc, eq > +# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) hash_multimap<key, type, hfunc, eq > + #include <ext/hash_map> #include <ext/hash_set> #include <ext/functional> @@ -117,20 +154,33 @@ namespace __gnu_cxx { template<> struct hash<std::string> { size_t operator()(const std::string& x) const - { return hash<const char*>()(x.c_str()); } + { return hash<const char*>()(x.c_str()); } }; template<> struct hash<long long int> { size_t operator()(long long int x) const { return x; } }; } -#else // __GLIBCPP__ +#elif defined(_MSC_VER) // Assume the msvc stl +# define HASH_SET hash_set +# define HASH_MAP hash_map +# define HASH_MULTIMAP hash_multimap +# define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc > +# define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc > +# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) hash_multimap<key, type, hfunc > + #include <hash_map> #include <hash_set> - using namespace std; using namespace stdext; -#endif // __GLIBCPP__ +#else +# define HASH_SET set +# define HASH_MAP map +# define HASH_SET_X(key, hfunc, eq, order) +# define HASH_MAP_X(key, type, hfunc, eq, order) map<key, type, order > +# define HASH_MULTIMAP multimap +# define HASH_MULTIMAP_X(key, type, hfunc, eq, order) multimap<key, type, order > +#endif #endif // !defined(STDINC_H) Modified: dcplusplus/trunk/client.vcproj =================================================================== --- dcplusplus/trunk/client.vcproj 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/client.vcproj 2006-10-18 19:43:41 UTC (rev 681) @@ -43,7 +43,6 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" - PreprocessorDefinitions="HAVE_STLPORT" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" @@ -130,7 +129,6 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)stlport";"$(SolutionDir)wtl";"$(SolutionDir)yassl\include"" - PreprocessorDefinitions="HAVE_STLPORT" StringPooling="true" MinimalRebuild="true" ExceptionHandling="1" Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-10-18 19:43:41 UTC (rev 681) @@ -37,10 +37,10 @@ HubFrame::FrameMap HubFrame::frames; -int HubFrame::columnSizes[] = { 100, 75, 75, 100, 75, 100, 125 }; -int HubFrame::columnIndexes[] = { COLUMN_NICK, COLUMN_SHARED, COLUMN_DESCRIPTION, COLUMN_TAG, COLUMN_CONNECTION, COLUMN_EMAIL, COLUMN_CID }; +int HubFrame::columnSizes[] = { 100, 75, 75, 100, 75, 100, 100, 125 }; +int HubFrame::columnIndexes[] = { COLUMN_NICK, COLUMN_SHARED, COLUMN_DESCRIPTION, COLUMN_TAG, COLUMN_CONNECTION, COLUMN_IP, COLUMN_EMAIL, COLUMN_CID }; static ResourceManager::Strings columnNames[] = { ResourceManager::NICK, ResourceManager::SHARED, -ResourceManager::DESCRIPTION, ResourceManager::TAG, ResourceManager::CONNECTION, ResourceManager::EMAIL, ResourceManager::CID }; +ResourceManager::DESCRIPTION, ResourceManager::TAG, ResourceManager::CONNECTION, ResourceManager::IP_BARE, ResourceManager::EMAIL, ResourceManager::CID }; LRESULT HubFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { @@ -463,6 +463,11 @@ columns[COLUMN_DESCRIPTION] = Text::toT(identity.getDescription()); columns[COLUMN_TAG] = Text::toT(identity.getTag()); columns[COLUMN_CONNECTION] = Text::toT(identity.getConnection()); + string ip = identity.getIp(); + string country = ip.empty()?Util::emptyString:Util::getIpCountry(ip); + if (!country.empty()) + ip = country + " (" + ip + ")"; + columns[COLUMN_IP] = Text::toT(ip); columns[COLUMN_EMAIL] = Text::toT(identity.getEmail()); columns[COLUMN_CID] = Text::toT(identity.getUser()->getCID().toBase32()); @@ -899,6 +904,45 @@ } } +string HubFrame::stripNick(const string& nick) const { + if (nick.substr(0, 1) != "[") return nick; + string::size_type x = nick.find(']'); + string ret; + // Avoid full deleting of [IMCOOL][CUSIHAVENOTHINGELSETHANBRACKETS]-type nicks + if ((x != string::npos) && (nick.substr(x+1).length() > 0)) { + ret = nick.substr(x+1); + } else { + ret = nick; + } + return ret; +} + +//Has fun side-effects. Otherwise needs reference arguments or multiple-return-values. +tstring HubFrame::scanNickPrefix(const tstring& prefixT) { + string prefix = Text::fromT(prefixT), maxPrefix; + tabCompleteNicks.clear(); + for (UserMap::const_iterator i = userMap.begin(); i != userMap.end(); ++i) { + string prevNick, nick = i->second->getIdentity().getNick(), wholeNick = nick; + + do { + string::size_type lp = prefix.size(), ln = nick.size(); + if ((ln >= lp) && (!Util::strnicmp(nick, prefix, lp))) { + if (maxPrefix == Util::emptyString) maxPrefix = nick; //ugly hack + tabCompleteNicks.push_back(nick); + tabCompleteNicks.push_back(wholeNick); + maxPrefix = maxPrefix.substr(0, mismatch(maxPrefix.begin(), + maxPrefix.begin()+min(maxPrefix.size(), nick.size()), + nick.begin(), compareCharsNoCase).first - maxPrefix.begin()); + } + + prevNick = nick; + nick = stripNick(nick); + } while (prevNick != nick); + } + + return Text::toT(maxPrefix); +} + void HubFrame::onTab() { if(ctrlMessage.GetWindowTextLength() == 0) { handleTab(WinUtil::isShift()); @@ -936,49 +980,34 @@ else textStart++; - int start = ctrlUsers.GetNextItem(-1, LVNI_FOCUSED) + 1; - int i = start; - int j = ctrlUsers.GetItemCount(); + if (inTabComplete) { + // Already pressed tab once. Output nick candidate list. + tstring nicks; + for (StringList::const_iterator i = tabCompleteNicks.begin(); i < tabCompleteNicks.end(); i+=2) + nicks.append(Text::toT(*i + " ")); + addClientLine(nicks); + inTabComplete = false; + } else { + // First tab. Maximally extend proposed nick. + tstring nick = scanNickPrefix(complete); + if (tabCompleteNicks.empty()) return; - bool firstPass = i < j; - if(!firstPass) - i = 0; - while(firstPass || (!firstPass && i < start)) { - UserInfo* ui = ctrlUsers.getItemData(i); - const tstring& nick = ui->columns[COLUMN_NICK]; - bool found = (Util::strnicmp(nick, complete, complete.length()) == 0); - tstring::size_type x = 0; - if(!found) { - // Check if there's one or more [ISP] tags to ignore... - tstring::size_type y = 0; - while(nick[y] == _T('[')) { - x = nick.find(_T(']'), y); - if(x != string::npos) { - if(Util::strnicmp(nick.c_str() + x + 1, complete.c_str(), complete.length()) == 0) { - found = true; - break; - } - } else { - break; - } - y = x + 1; // assuming that nick[y] == '\0' is legal - } - } - if(found) { - if((start - 1) != -1) { - ctrlUsers.SetItemState(start - 1, 0, LVNI_SELECTED | LVNI_FOCUSED); - } + // Maybe it found a unique match. If userlist showing, highlight. + if (showUsers && tabCompleteNicks.size() == 2) { + int i = ctrlUsers.findItem(Text::toT(tabCompleteNicks[1])); ctrlUsers.SetItemState(i, LVNI_FOCUSED | LVNI_SELECTED, LVNI_FOCUSED | LVNI_SELECTED); ctrlUsers.EnsureVisible(i, FALSE); - ctrlMessage.SetSel(textStart, ctrlMessage.GetWindowTextLength(), TRUE); + } + + ctrlMessage.SetSel(textStart, ctrlMessage.GetWindowTextLength(), TRUE); + // no shift, use partial nick when appropriate + if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { ctrlMessage.ReplaceSel(nick.c_str()); - return; + } else { + ctrlMessage.ReplaceSel(Text::toT(stripNick(Text::fromT(nick))).c_str()); } - i++; - if(i == j) { - firstPass = false; - i = 0; - } + + inTabComplete = true; } } } @@ -990,7 +1019,7 @@ LRESULT HubFrame::onChar(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(!complete.empty() && wParam != VK_TAB && uMsg == WM_KEYDOWN) - complete.clear(); + complete.clear(), inTabComplete = false; if (uMsg != WM_KEYDOWN) { switch(wParam) { Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-10-18 06:53:29 UTC (rev 680) +++ dcplusplus/trunk/windows/HubFrame.h 2006-10-18 19:43:41 UTC (rev 681) @@ -178,6 +178,7 @@ COLUMN_DESCRIPTION, COLUMN_TAG, COLUMN_CONNECTION, + COLUMN_IP, COLUMN_EMAIL, COLUMN_CID, COLUMN_LAST @@ -250,7 +251,7 @@ HubFrame(const tstring& aServer) : waitingForPW(false), extraSort(false), server(aServer), closed(false), showUsers(BOOLSETTING(GET_USER_INFO)), updateUsers(false), resort(false), - curCommandPosition(0), timeStamps(BOOLSETTING(TIME_STAMPS)), + curCommandPosition(0), timeStamps(BOOLSETTING(TIME_STAMPS)), inTabComplete(false), ctrlMessageContainer(WC_EDIT, this, EDIT_MESSAGE_MAP), showUsersContainer(WC_BUTTON, this, EDIT_MESSAGE_MAP), clientContainer(WC_EDIT, this, EDIT_MESSAGE_MAP), @@ -283,6 +284,8 @@ bool showJoins; bool favShowJoins; tstring complete; + StringList tabCompleteNicks; + bool inTabComplete; bool waitingForPW; bool extraSort; @@ -356,6 +359,13 @@ static int columnIndexes[COLUMN_LAST]; static int columnSizes[COLUMN_LAST]; + static bool compareCharsNoCase(string::value_type a, string::value_type b) { + return Text::toLower(a) == Text::toLower(b); + } + + string stripNick(const string& nick) const; + tstring scanNickPrefix(const tstring& prefix); + bool updateUser(const UserTask& u); void removeUser(const User::Ptr& aUser); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-18 06:53:37
|
Revision: 680 http://svn.sourceforge.net/dcplusplus/?rev=680&view=rev Author: arnetheduck Date: 2006-10-17 23:53:29 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Path fix Modified Paths: -------------- dcplusplus/trunk/client/ShareManager.cpp Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-10-15 19:06:14 UTC (rev 679) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-18 06:53:29 UTC (rev 680) @@ -96,7 +96,7 @@ string ShareManager::Directory::getRealPath() const throw() { if(getParent()) { - return getParent()->getRealPath() + PATH_SEPARATOR_STR + getName(); + return getParent()->getRealPath() + getName() + PATH_SEPARATOR_STR; } else { dcassert(ShareManager::getInstance()->getByVirtual(getName()) != ShareManager::getInstance()->directories.end()); return ShareManager::getInstance()->getByVirtual(getName())->first; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-15 19:06:30
|
Revision: 679 http://svn.sourceforge.net/dcplusplus/?rev=679&view=rev Author: arnetheduck Date: 2006-10-15 12:06:14 -0700 (Sun, 15 Oct 2006) Log Message: ----------- cleanup Modified Paths: -------------- dcplusplus/trunk/client/BloomFilter.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h Property Changed: ---------------- dcplusplus/trunk/ dcplusplus/trunk/help/ dcplusplus/trunk/yassl/ dcplusplus/trunk/yassl/taocrypt/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: svn:ignore - vc7 ADC* App* DCPlusPlus.aps DCPlusPlus.ncb DCPlusPlus.suo + vc7 ADC* App* DCPlusPlus.aps DCPlusPlus.ncb DCPlusPlus.suo .* *.vcproj.* Modified: dcplusplus/trunk/client/BloomFilter.h =================================================================== --- dcplusplus/trunk/client/BloomFilter.h 2006-10-14 15:52:30 UTC (rev 678) +++ dcplusplus/trunk/client/BloomFilter.h 2006-10-15 19:06:14 UTC (rev 679) @@ -38,14 +38,14 @@ ~BloomFilter() { } void add(const string& s) { xadd(s, N); } - bool match(const StringList& s) { + bool match(const StringList& s) const { 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) const { if(s.length() >= N) { string::size_type l = s.length() - N; for(string::size_type i = 0; i <= l; ++i) { @@ -82,7 +82,7 @@ } /* Same functionality, but the old one did not want to compile for some reason. */ - size_t getPos(const string& s, size_t i, size_t l) { + size_t getPos(const string& s, size_t i, size_t l) const { HashFunc hf; return (hf(&s[i], l) % table.size()); } Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-10-14 15:52:30 UTC (rev 678) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-15 19:06:14 UTC (rev 679) @@ -74,9 +74,58 @@ delete i->second; } -string ShareManager::toVirtual(const TTHValue& tth) throw(ShareException) { +string ShareManager::Directory::getADCPath() const throw() { + if(!getParent()) + return '/' + name + '/'; + return getParent()->getADCPath() + name + '/'; +} + +string ShareManager::Directory::getFullName() const throw() { + if(!getParent()) + return getName() + '\\'; + return getParent()->getFullName() + getName() + '\\'; +} + +void ShareManager::Directory::addType(uint32_t type) throw() { + if(!hasType(type)) { + fileTypes |= (1 << type); + if(getParent()) + getParent()->addType(type); + } +} + +string ShareManager::Directory::getRealPath() const throw() { + if(getParent()) { + return getParent()->getRealPath() + PATH_SEPARATOR_STR + getName(); + } else { + dcassert(ShareManager::getInstance()->getByVirtual(getName()) != ShareManager::getInstance()->directories.end()); + return ShareManager::getInstance()->getByVirtual(getName())->first; + } +} + +int64_t ShareManager::Directory::getSize() const throw() { + int64_t tmp = size; + for(Map::const_iterator i = directories.begin(); i != directories.end(); ++i) + tmp+=i->second->getSize(); + return tmp; +} + +size_t ShareManager::Directory::countFiles() const throw() { + size_t tmp = files.size(); + for(Map::const_iterator i = directories.begin(); i != directories.end(); ++i) + tmp+=i->second->countFiles(); + return tmp; +} + +string ShareManager::toVirtual(const TTHValue& tth) const throw(ShareException) { Lock l(cs); - HashFileIter i = tthIndex.find(tth); + if(tth == bzXmlRoot) { + return Transfer::USER_LIST_NAME_BZ; + } else if(tth == xmlRoot) { + return Transfer::USER_LIST_NAME; + } + + HashFileMap::const_iterator i = tthIndex.find(tth); if(i != tthIndex.end()) { return i->second->getADCPath(); } else { @@ -94,24 +143,22 @@ string realFile; Lock l(cs); - Directory::File::Iter it; - if(!checkFile(virtualFile, realFile, it)) { - throw ShareException(UserConnection::FILE_NOT_AVAILABLE); - } - return realFile; + return findFile(virtualFile)->getRealPath(); } } -TTHValue ShareManager::getTTH(const string& virtualFile) throw(ShareException) { +TTHValue ShareManager::getTTH(const string& virtualFile) const throw(ShareException) { Lock l(cs); - string realFile; - Directory::File::Iter it; - if(!checkFile(virtualFile, realFile, it)) - throw ShareException(); - return it->getTTH(); + if(virtualFile == Transfer::USER_LIST_NAME_BZ) { + return bzXmlRoot; + } else if(virtualFile == Transfer::USER_LIST_NAME) { + return xmlRoot; + } + + return findFile(virtualFile)->getTTH(); } -MemoryInputStream* ShareManager::getTree(const string& virtualFile) { +MemoryInputStream* ShareManager::getTree(const string& virtualFile) const { TigerTree tree; if(virtualFile.compare(0, 4, "TTH/") == 0) { if(!HashManager::getInstance()->getTree(TTHValue(virtualFile.substr(4)), tree)) @@ -165,52 +212,48 @@ return cmd; } -bool ShareManager::checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it) throw(ShareException) { - string file; +ShareManager::Directory::File::Set::const_iterator ShareManager::findFile(const string& virtualFile) const throw(ShareException) { if(virtualFile.compare(0, 4, "TTH/") == 0) { - file = toVirtual(TTHValue(virtualFile.substr(4))); + HashFileMap::const_iterator i = tthIndex.find(TTHValue(virtualFile.substr(4))); + if(i == tthIndex.end()) { + throw ShareException(UserConnection::FILE_NOT_AVAILABLE); + } + return i->second; } else if(virtualFile.empty() || virtualFile[0] != '/') { - return false; - } else { - file = virtualFile; + throw ShareException(UserConnection::FILE_NOT_AVAILABLE); } - string::size_type i = file.find('/', 1); + + string::size_type i = virtualFile.find('/', 1); if(i == string::npos || i == 1) { return false; } - string virtualName = file.substr(1, i-1); - Directory::MapIter dmi = getByVirtual(virtualName); + string virtualName = virtualFile.substr(1, i-1); + Directory::Map::const_iterator dmi = getByVirtual(virtualName); if(dmi == directories.end()) { - return false; + throw ShareException(UserConnection::FILE_NOT_AVAILABLE); } Directory* d = dmi->second; - file = file.substr(i + 1); + string file = virtualFile.substr(i + 1); string::size_type j = 0; while( (i = file.find('/', j)) != string::npos) { Directory::MapIter mi = d->directories.find(file.substr(j, i-j)); j = i + 1; if(mi == d->directories.end()) - return false; + throw ShareException(UserConnection::FILE_NOT_AVAILABLE); d = mi->second; } - it = find_if(d->files.begin(), d->files.end(), Directory::File::StringComp(file.substr(j))); + Directory::File::Set::const_iterator it = find_if(d->files.begin(), d->files.end(), Directory::File::StringComp(file.substr(j))); if(it == d->files.end()) - return false; - -#ifdef _WIN32 - replace_if(file.begin(), file.end(), bind2nd(equal_to<char>(), '/'), '\\'); -#endif - - realFile = dmi->first + file; - return true; + throw ShareException(UserConnection::FILE_NOT_AVAILABLE); + return it; } -string ShareManager::validateVirtual(const string& aVirt) { +string ShareManager::validateVirtual(const string& aVirt) const throw() { string tmp = aVirt; string::size_type idx = 0; @@ -220,7 +263,7 @@ return tmp; } -bool ShareManager::hasVirtual(const string& virtualName) { +bool ShareManager::hasVirtual(const string& virtualName) const throw() { return getByVirtual(virtualName) != directories.end(); } @@ -247,11 +290,18 @@ } } + +static const string SDIRECTORY = "Directory"; +static const string SFILE = "File"; +static const string SNAME = "Name"; +static const string SSIZE = "Size"; +static const string STTH = "TTH"; + struct ShareLoader : public SimpleXMLReader::CallBack { ShareLoader(ShareManager::Directory::Map& aDirs) : dirs(aDirs), cur(0), depth(0) { } virtual void startTag(const string& name, StringPairList& attribs, bool simple) { - if(name == "Directory") { - const string& name = getAttrib(attribs, "Name", 0); + if(name == SDIRECTORY) { + const string& name = getAttrib(attribs, SNAME, 0); if(!name.empty()) { if(depth == 0) { for(ShareManager::Directory::MapIter i = dirs.begin(); i != dirs.end(); ++i) { @@ -274,10 +324,10 @@ } else { depth++; } - } else if(cur && name == "File") { - const string& fname = getAttrib(attribs, "Name", 0); - const string& size = getAttrib(attribs, "Size", 1); - const string& root = getAttrib(attribs, "TTH", 2); + } else if(cur && name == SFILE) { + const string& fname = getAttrib(attribs, SNAME, 0); + const string& size = getAttrib(attribs, SSIZE, 1); + const string& root = getAttrib(attribs, STTH, 2); if(fname.empty() || size.empty() || (root.size() != 39)) { dcdebug("Invalid file found: %s\n", fname.c_str()); return; @@ -286,7 +336,7 @@ } } virtual void endTag(const string& name, const string&) { - if(name == "Directory") { + if(name == SDIRECTORY) { depth--; if(cur) { cur = cur->getParent(); @@ -301,7 +351,7 @@ size_t depth; }; -bool ShareManager::loadCache() { +bool ShareManager::loadCache() throw() { try { ShareLoader loader(directories); string txt; @@ -420,8 +470,8 @@ j->second->setName(vName); } -ShareManager::Directory::MapIter ShareManager::getByVirtual(const string& virtualName) { - for(Directory::MapIter i = directories.begin(); i != directories.end(); ++i) { +ShareManager::Directory::Map::const_iterator ShareManager::getByVirtual(const string& virtualName) const throw() { + for(Directory::Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { if(Util::stricmp(i->second->getName(), virtualName) == 0) { return i; } @@ -429,10 +479,10 @@ return directories.end(); } -int64_t ShareManager::getShareSize(const string& aDir) throw() { +int64_t ShareManager::getShareSize(const string& realPath) const throw() { Lock l(cs); - dcassert(aDir.size()>0); - Directory::MapIter i = directories.find(aDir); + dcassert(realPath.size()>0); + Directory::Map::const_iterator i = directories.find(realPath); if(i != directories.end()) { return i->second->getSize(); @@ -441,44 +491,24 @@ return -1; } -int64_t ShareManager::getShareSize() throw() { +int64_t ShareManager::getShareSize() const throw() { Lock l(cs); int64_t tmp = 0; - for(Directory::MapIter i = directories.begin(); i != directories.end(); ++i) { + for(Directory::Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { tmp += i->second->getSize(); } return tmp; } -size_t ShareManager::getSharedFiles() throw() { +size_t ShareManager::getSharedFiles() const throw() { Lock l(cs); size_t tmp = 0; - for(Directory::MapIter i = directories.begin(); i != directories.end(); ++i) { + for(Directory::Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { tmp += i->second->countFiles(); } return tmp; } - -string ShareManager::Directory::getADCPath() const throw() { - if(parent == NULL) - return '/' + name + '/'; - return parent->getADCPath() + name + '/'; -} -string ShareManager::Directory::getFullName() const throw() { - if(parent == NULL) - return getName() + '\\'; - return parent->getFullName() + getName() + '\\'; -} - -void ShareManager::Directory::addType(uint32_t type) throw() { - if(!hasType(type)) { - fileTypes |= (1 << type); - if(getParent() != NULL) - getParent()->addType(type); - } -} - class FileFindIter { #ifdef _WIN32 public: @@ -622,7 +652,7 @@ FileFindIter end; #ifdef _WIN32 - for(FileFindIter i(aName + "*"); i != end; ++i) { + for(FileFindIter i(aName + "*"); i != end; ++i) { #else //the fileiter just searches directorys for now, not sure if more //will be needed later @@ -708,7 +738,7 @@ bloom.add(Text::toLower(f.getName())); } -void ShareManager::refresh(bool dirs /* = false */, bool aUpdate /* = true */, bool block /* = false */) throw(ThreadException, ShareException) { +void ShareManager::refresh(bool dirs /* = false */, bool aUpdate /* = true */, bool block /* = false */) throw() { if(Thread::safeExchange(refreshing, 1) == 1) { LogManager::getInstance()->message(STRING(FILE_LIST_REFRRESH_IN_PROGRESS)); return; @@ -734,7 +764,7 @@ } } -StringPairList ShareManager::getDirectories() const { +StringPairList ShareManager::getDirectories() const throw() { Lock l(cs); StringPairList ret; for(Directory::Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { @@ -837,9 +867,9 @@ } } -MemoryInputStream* ShareManager::generatePartialList(const string& dir, bool recurse) { +MemoryInputStream* ShareManager::generatePartialList(const string& dir, bool recurse) const { if(dir[0] != '/' || dir[dir.size()-1] != '/') - return NULL; + return 0; string xml = SimpleXML::utf8Header; string tmp; @@ -849,13 +879,13 @@ Lock l(cs); if(dir == "/") { - for(ShareManager::Directory::MapIter i = directories.begin(); i != directories.end(); ++i) { + for(Directory::Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { tmp.clear(); i->second->toXml(sos, indent, tmp, recurse); } } else { string::size_type i = 1, j = 1; - ShareManager::Directory::MapIter it = directories.end(); + Directory::Map::const_iterator it = directories.end(); bool first = true; while( (i = dir.find('/', j)) != string::npos) { if(i == j) { @@ -870,7 +900,7 @@ if(it == directories.end()) return 0; } else { - ShareManager::Directory::MapIter it2 = it->second->directories.find(dir.substr(j, i-j)); + Directory::Map::const_iterator it2 = it->second->directories.find(dir.substr(j, i-j)); if(it2 == it->second->directories.end()) { return 0; } @@ -878,7 +908,7 @@ } j = i + 1; } - for(ShareManager::Directory::MapIter it2 = it->second->directories.begin(); it2 != it->second->directories.end(); ++it2) { + for(Directory::Map::const_iterator it2 = it->second->directories.begin(); it2 != it->second->directories.end(); ++it2) { it2->second->toXml(sos, indent, tmp, recurse); } it->second->filesToXml(sos, indent, tmp); @@ -888,26 +918,17 @@ return new MemoryInputStream(xml); } -static const string& escaper(const string& n, string& tmp) { - if(SimpleXML::needsEscape(n, true, false)) { - tmp.clear(); - tmp.append(n); - return SimpleXML::escape(tmp, true, false); - } - return n; -} - #define LITERAL(n) n, sizeof(n)-1 -void ShareManager::Directory::toXml(OutputStream& xmlFile, string& indent, string& tmp2, bool fullList) { +void ShareManager::Directory::toXml(OutputStream& xmlFile, string& indent, string& tmp2, bool fullList) const { xmlFile.write(indent); xmlFile.write(LITERAL("<Directory Name=\"")); - xmlFile.write(escaper(name, tmp2)); + xmlFile.write(SimpleXML::escape(name, tmp2, true)); if(fullList) { xmlFile.write(LITERAL("\">\r\n")); indent += '\t'; - for(MapIter i = directories.begin(); i != directories.end(); ++i) { + for(Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { i->second->toXml(xmlFile, indent, tmp2, fullList); } @@ -925,13 +946,13 @@ } } -void ShareManager::Directory::filesToXml(OutputStream& xmlFile, string& indent, string& tmp2) { - for(Directory::File::Iter i = files.begin(); i != files.end(); ++i) { +void ShareManager::Directory::filesToXml(OutputStream& xmlFile, string& indent, string& tmp2) const { + for(Directory::File::Set::const_iterator i = files.begin(); i != files.end(); ++i) { const Directory::File& f = *i; xmlFile.write(indent); xmlFile.write(LITERAL("<File Name=\"")); - xmlFile.write(escaper(f.getName(), tmp2)); + xmlFile.write(SimpleXML::escape(f.getName(), tmp2, true)); xmlFile.write(LITERAL("\" Size=\"")); xmlFile.write(Util::toString(f.getSize())); xmlFile.write(LITERAL("\" TTH=\"")); @@ -1030,7 +1051,7 @@ return false; } -SearchManager::TypeModes ShareManager::getType(const string& aFileName) { +SearchManager::TypeModes ShareManager::getType(const string& aFileName) const throw() { if(aFileName[aFileName.length() - 1] == PATH_SEPARATOR) { return SearchManager::TYPE_DIRECTORY; } @@ -1058,7 +1079,7 @@ * has been matched in the directory name. This new stringlist should also be used in all descendants, * but not the parents... */ -void ShareManager::Directory::search(SearchResult::List& aResults, StringSearch::List& aStrings, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) throw() { +void ShareManager::Directory::search(SearchResult::List& aResults, StringSearch::List& aStrings, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) const throw() { // Skip everything if there's nothing to find here (doh! =) if(!hasType(aFileType)) return; @@ -1090,7 +1111,7 @@ } if(aFileType != SearchManager::TYPE_DIRECTORY) { - for(File::Iter i = files.begin(); i != files.end(); ++i) { + for(File::Set::const_iterator i = files.begin(); i != files.end(); ++i) { if(aSearchType == SearchManager::SIZE_ATLEAST && aSize > i->getSize()) { continue; @@ -1116,17 +1137,17 @@ } } - for(Directory::MapIter l = directories.begin(); (l != directories.end()) && (aResults.size() < maxResults); ++l) { + for(Directory::Map::const_iterator l = directories.begin(); (l != directories.end()) && (aResults.size() < maxResults); ++l) { l->second->search(aResults, *cur, aSearchType, aSize, aFileType, aClient, maxResults); } } -void ShareManager::search(SearchResult::List& results, const string& aString, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) { +void ShareManager::search(SearchResult::List& results, const string& aString, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) throw() { Lock l(cs); if(aFileType == SearchManager::TYPE_TTH) { if(aString.compare(0, 4, "TTH:") == 0) { TTHValue tth(aString.substr(4)); - HashFileIter i = tthIndex.find(tth); + HashFileMap::const_iterator i = tthIndex.find(tth); if(i != tthIndex.end()) { SearchResult* sr = new SearchResult(SearchResult::TYPE_FILE, i->second->getSize(), i->second->getParent()->getFullName() + i->second->getName(), i->second->getTTH()); @@ -1151,7 +1172,7 @@ if(ssl.empty()) return; - for(Directory::MapIter j = directories.begin(); (j != directories.end()) && (results.size() < maxResults); ++j) { + for(Directory::Map::const_iterator j = directories.begin(); (j != directories.end()) && (results.size() < maxResults); ++j) { j->second->search(results, ssl, aSearchType, aSize, aFileType, aClient, maxResults); } } @@ -1191,7 +1212,7 @@ } } -void ShareManager::Directory::search(SearchResult::List& aResults, AdcSearch& aStrings, StringList::size_type maxResults) throw() { +void ShareManager::Directory::search(SearchResult::List& aResults, AdcSearch& aStrings, StringList::size_type maxResults) const throw() { StringSearch::List* cur = aStrings.include; StringSearch::List* old = aStrings.include; @@ -1220,7 +1241,7 @@ } if(!aStrings.isDirectory) { - for(File::Iter i = files.begin(); i != files.end(); ++i) { + for(File::Set::const_iterator i = files.begin(); i != files.end(); ++i) { if(!(i->getSize() >= aStrings.gt)) { continue; @@ -1252,19 +1273,19 @@ } } - for(Directory::MapIter l = directories.begin(); (l != directories.end()) && (aResults.size() < maxResults); ++l) { + for(Directory::Map::const_iterator l = directories.begin(); (l != directories.end()) && (aResults.size() < maxResults); ++l) { l->second->search(aResults, aStrings, maxResults); } aStrings.include = old; } -void ShareManager::search(SearchResult::List& results, const StringList& params, StringList::size_type maxResults) { +void ShareManager::search(SearchResult::List& results, const StringList& params, StringList::size_type maxResults) throw() { AdcSearch srch(params); Lock l(cs); if(srch.hasRoot) { - HashFileIter i = tthIndex.find(srch.root); + HashFileMap::const_iterator i = tthIndex.find(srch.root); if(i != tthIndex.end()) { SearchResult* sr = new SearchResult(SearchResult::TYPE_FILE, i->second->getSize(), i->second->getParent()->getFullName() + i->second->getName(), @@ -1280,25 +1301,11 @@ return; } - for(Directory::MapIter j = directories.begin(); (j != directories.end()) && (results.size() < maxResults); ++j) { + for(Directory::Map::const_iterator j = directories.begin(); (j != directories.end()) && (results.size() < maxResults); ++j) { j->second->search(results, srch, maxResults); } } -int64_t ShareManager::Directory::getSize() { - int64_t tmp = size; - for(MapIter i = directories.begin(); i != directories.end(); ++i) - tmp+=i->second->getSize(); - return tmp; -} - -size_t ShareManager::Directory::countFiles() { - size_t tmp = files.size(); - for(MapIter i = directories.begin(); i != directories.end(); ++i) - tmp+=i->second->countFiles(); - return tmp; -} - ShareManager::Directory* ShareManager::getDirectory(const string& fname) { for(Directory::MapIter mi = directories.begin(); mi != directories.end(); ++mi) { if(Util::strnicmp(fname, mi->first, mi->first.length()) == 0) { @@ -1342,8 +1349,8 @@ void ShareManager::on(HashManagerListener::TTHDone, const string& fname, const TTHValue& root) throw() { Lock l(cs); Directory* d = getDirectory(fname); - if(d != NULL) { - Directory::File::Iter i = d->findFile(Util::getFileName(fname)); + if(d) { + Directory::File::Set::const_iterator i = d->findFile(Util::getFileName(fname)); if(i != d->files.end()) { if(root != i->getTTH()) tthIndex.erase(i->getTTH()); @@ -1364,10 +1371,7 @@ void ShareManager::on(TimerManagerListener::Minute, uint32_t tick) throw() { if(SETTING(AUTO_REFRESH_TIME) > 0) { if(lastFullUpdate + SETTING(AUTO_REFRESH_TIME) * 60 * 1000 < tick) { - try { - refresh(true, true); - } catch(const ShareException&) { - } + refresh(true, true); } } } Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-10-14 15:52:30 UTC (rev 678) +++ dcplusplus/trunk/client/ShareManager.h 2006-10-15 19:06:14 UTC (rev 679) @@ -58,33 +58,34 @@ void removeDirectory(const string& realPath); void renameDirectory(const string& realPath, const string& virtualName) throw(ShareException); - string toVirtual(const TTHValue& tth) throw(ShareException); + string toVirtual(const TTHValue& tth) const throw(ShareException); string toReal(const string& virtualFile) throw(ShareException); - TTHValue getTTH(const string& virtualFile) throw(ShareException); - void refresh(bool dirs = false, bool aUpdate = true, bool block = false) throw(ThreadException, ShareException); + TTHValue getTTH(const string& virtualFile) const throw(ShareException); + + void refresh(bool dirs = false, bool aUpdate = true, bool block = false) throw(); void setDirty() { xmlDirty = true; } - void search(SearchResult::List& l, const string& aString, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults); - void search(SearchResult::List& l, const StringList& params, StringList::size_type maxResults); + void search(SearchResult::List& l, const string& aString, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) throw(); + void search(SearchResult::List& l, const StringList& params, StringList::size_type maxResults) throw(); - StringPairList getDirectories() const; + StringPairList getDirectories() const throw(); - MemoryInputStream* generatePartialList(const string& dir, bool recurse); - MemoryInputStream* getTree(const string& virtualFile); + MemoryInputStream* generatePartialList(const string& dir, bool recurse) const; + MemoryInputStream* getTree(const string& virtualFile) const; AdcCommand getFileInfo(const string& aFile) throw(ShareException); - int64_t getShareSize() throw(); - int64_t getShareSize(const string& aDir) throw(); + int64_t getShareSize() const throw(); + int64_t getShareSize(const string& realPath) const throw(); - size_t getSharedFiles() throw(); + size_t getSharedFiles() const throw(); - string getShareSizeString() { return Util::toString(getShareSize()); } - string getShareSizeString(const string& aDir) { return Util::toString(getShareSize(aDir)); } + string getShareSizeString() const { return Util::toString(getShareSize()); } + string getShareSizeString(const string& aDir) const { return Util::toString(getShareSize(aDir)); } - SearchManager::TypeModes getType(const string& fileName); + SearchManager::TypeModes getType(const string& fileName) const throw(); - string validateVirtual(const string& /*aVirt*/); + string validateVirtual(const string& /*aVirt*/) const throw(); void addHits(uint32_t aHits) { hits += aHits; @@ -138,7 +139,8 @@ } string getADCPath() const { return parent->getADCPath() + name; } - string getFullName() const { return parent->getFullName() + getName(); } + string getFullName() const { return parent->getFullName() + name; } + string getRealPath() const { return parent->getRealPath() + name; } GETSET(string, name, Name); GETSET(TTHValue, tth, TTH); @@ -167,17 +169,18 @@ string getADCPath() const throw(); string getFullName() const throw(); + string getRealPath() const throw(); - int64_t getSize(); - size_t countFiles(); + int64_t getSize() const throw(); + size_t countFiles() const throw(); - void search(SearchResult::List& aResults, StringSearch::List& aStrings, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) throw(); - void search(SearchResult::List& aResults, AdcSearch& aStrings, StringList::size_type maxResults) throw(); + void search(SearchResult::List& aResults, StringSearch::List& aStrings, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) const throw(); + void search(SearchResult::List& aResults, AdcSearch& aStrings, StringList::size_type maxResults) const throw(); - void toXml(OutputStream& xmlFile, string& indent, string& tmp2, bool fullList); - void filesToXml(OutputStream& xmlFile, string& indent, string& tmp2); + void toXml(OutputStream& xmlFile, string& indent, string& tmp2, bool fullList) const; + void filesToXml(OutputStream& xmlFile, string& indent, string& tmp2) const; - File::Iter findFile(const string& aFile) { return find_if(files.begin(), files.end(), Directory::File::StringComp(aFile)); } + File::Set::const_iterator findFile(const string& aFile) const { return find_if(files.begin(), files.end(), Directory::File::StringComp(aFile)); } GETSET(string, name, Name); GETSET(Directory*, parent, Parent); @@ -263,7 +266,7 @@ BloomFilter<5> bloom; - bool checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it) throw(ShareException); + Directory::File::Set::const_iterator findFile(const string& virtualFile) const throw(ShareException); Directory* buildTree(const string& aName, Directory* aParent); @@ -272,9 +275,9 @@ void addTree(Directory& aDirectory); void addFile(Directory& dir, Directory::File::Iter i); void generateXmlList(); - bool loadCache(); - bool hasVirtual(const string& name); - Directory::MapIter getByVirtual(const string& virtualName); + bool loadCache() throw(); + bool hasVirtual(const string& name) const throw(); + Directory::Map::const_iterator getByVirtual(const string& virtualName) const throw(); Directory* getDirectory(const string& fname); Property changes on: dcplusplus/trunk/help ___________________________________________________________________ Name: svn:ignore + *.vcproj.* Property changes on: dcplusplus/trunk/yassl ___________________________________________________________________ Name: svn:ignore - doc + doc *.vcproj.* Property changes on: dcplusplus/trunk/yassl/taocrypt ___________________________________________________________________ Name: svn:ignore + *.vcproj.* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-14 15:52:40
|
Revision: 678 http://svn.sourceforge.net/dcplusplus/?rev=678&view=rev Author: arnetheduck Date: 2006-10-14 08:52:30 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Network page fix Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/windows/NetworkPage.cpp dcplusplus/trunk/windows/UploadPage.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-14 14:57:33 UTC (rev 677) +++ dcplusplus/trunk/changelog.txt 2006-10-14 15:52:30 UTC (rev 678) @@ -4,6 +4,7 @@ * Antifrag is now default * Confirm hub removal is now default * SFV checking is now default +* Fixed TLS port not being greyed out -- 0.698 2006-10-10 -- * [bug 1065] Code cleanup (thanks steven sheehy) Modified: dcplusplus/trunk/windows/NetworkPage.cpp =================================================================== --- dcplusplus/trunk/windows/NetworkPage.cpp 2006-10-14 14:57:33 UTC (rev 677) +++ dcplusplus/trunk/windows/NetworkPage.cpp 2006-10-14 15:52:30 UTC (rev 678) @@ -161,6 +161,7 @@ ::EnableWindow(GetDlgItem(IDC_PORT_TCP), direct || upnp || nat); ::EnableWindow(GetDlgItem(IDC_PORT_UDP), direct || upnp || nat); + ::EnableWindow(GetDlgItem(IDC_PORT_TLS), direct || upnp || nat); BOOL socks = IsDlgButtonChecked(IDC_SOCKS5); ::EnableWindow(GetDlgItem(IDC_SOCKS_SERVER), socks); Modified: dcplusplus/trunk/windows/UploadPage.cpp =================================================================== --- dcplusplus/trunk/windows/UploadPage.cpp 2006-10-14 14:57:33 UTC (rev 677) +++ dcplusplus/trunk/windows/UploadPage.cpp 2006-10-14 15:52:30 UTC (rev 678) @@ -206,7 +206,7 @@ LineDlg virt; virt.title = TSTRING(VIRTUAL_NAME); virt.description = TSTRING(VIRTUAL_NAME_LONG); - virt.line = tstring(buf); + virt.line = vName; if(virt.DoModal(m_hWnd) == IDOK) { if (Util::stricmp(buf, virt.line) != 0) { ShareManager::getInstance()->renameDirectory(Text::fromT(rPath), Text::fromT(virt.line)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-10 14:45:33
|
Revision: 674 http://svn.sourceforge.net/dcplusplus/?rev=674&view=rev Author: arnetheduck Date: 2006-10-10 07:45:20 -0700 (Tue, 10 Oct 2006) Log Message: ----------- changlog fix Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/help/changelog.html Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-10 14:44:41 UTC (rev 673) +++ dcplusplus/trunk/changelog.txt 2006-10-10 14:45:20 UTC (rev 674) @@ -1,4 +1,4 @@ --- 0.698 -- +-- 0.698 2006-10-10 -- * [bug 1065] Code cleanup (thanks steven sheehy) * Fixed readme.txt (thanks ullner) * More code cleanup Modified: dcplusplus/trunk/help/changelog.html =================================================================== --- dcplusplus/trunk/help/changelog.html 2006-10-10 14:44:41 UTC (rev 673) +++ dcplusplus/trunk/help/changelog.html 2006-10-10 14:45:20 UTC (rev 674) @@ -13,6 +13,26 @@ <h1>DC++ Changelog</h1> See the version history of DC++ below. +<h2>0.698 <span style="color: gray;">(2006-10-10)</span></h2> +<ul> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1065">[bug 1065]</a> Code cleanup (thanks steven sheehy)</li> + <li>Fixed readme.txt (thanks ullner)</li> + <li>More code cleanup</li> + <li>Fixed trusted/untrusted upload view</li> + <li>Fixed crash on invalid remote command during upload</li> + <li>[ADC] Improved GFI command support</li> + <li>Lowest priority downloads are no longer started if there are other downloads running</li> + <li>Upgraded to STLport 5.0.2</li> + <li>Updated compile instructions</li> + <li>Updated unsigned types to C99</li> + <li>Removed unmaintained autoconf files</li> + <li>Reworked match listing to make it slightly faster</li> + <li>Fixed a few random crashes</li> + <li>[ADC] Removed obsolete DSC command</li> + <li>Fixed user list not being updated in some cases</li> + <li><a href="http://dcpp.net/bugzilla/show_bug.cgi?id=1071">[bug 1071]</a> Added fasthash for unix (thanks steven sheehy)</li> +</ul> + <h2>0.697 <span style="color: gray;">(2006-09-29)</span></h2> <ul> <li>[ADC] Fixed a few protocol issues</li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-10 14:44:52
|
Revision: 673 http://svn.sourceforge.net/dcplusplus/?rev=673&view=rev Author: arnetheduck Date: 2006-10-10 07:44:41 -0700 (Tue, 10 Oct 2006) Log Message: ----------- version update Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/version.h Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-10-10 10:16:29 UTC (rev 672) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-10-10 14:44:41 UTC (rev 673) @@ -942,8 +942,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,9,7 - PRODUCTVERSION 0,6,9,7 + FILEVERSION 0,6,9,8 + PRODUCTVERSION 0,6,9,8 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, 7" + VALUE "FileVersion", "0, 6, 9, 8" VALUE "InternalName", "DC++" VALUE "LegalCopyright", "Copyright 2001-2006 Jacek Sieka" VALUE "OriginalFilename", "DCPlusPlus.exe" VALUE "ProductName", "DC++" - VALUE "ProductVersion", "0, 6, 9, 7" + VALUE "ProductVersion", "0, 6, 9, 8" END END BLOCK "VarFileInfo" Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-10-10 10:16:29 UTC (rev 672) +++ dcplusplus/trunk/Example.xml 2006-10-10 14:44:41 UTC (rev 673) @@ -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.697" Revision="1" RightToLeft="0"> +<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version="0.698" 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-10-10 10:16:29 UTC (rev 672) +++ dcplusplus/trunk/changelog.txt 2006-10-10 14:44:41 UTC (rev 673) @@ -1,4 +1,4 @@ --- -- +-- 0.698 -- * [bug 1065] Code cleanup (thanks steven sheehy) * Fixed readme.txt (thanks ullner) * More code cleanup Modified: dcplusplus/trunk/client/version.h =================================================================== --- dcplusplus/trunk/client/version.h 2006-10-10 10:16:29 UTC (rev 672) +++ dcplusplus/trunk/client/version.h 2006-10-10 14:44:41 UTC (rev 673) @@ -17,7 +17,7 @@ */ #define APPNAME "DC++" -#define VERSIONSTRING "0.697" -#define VERSIONFLOAT 0.697 +#define VERSIONSTRING "0.698" +#define VERSIONFLOAT 0.698 /* Update the .rc file as well... */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-10 10:16:41
|
Revision: 672 http://svn.sourceforge.net/dcplusplus/?rev=672&view=rev Author: arnetheduck Date: 2006-10-10 03:16:29 -0700 (Tue, 10 Oct 2006) Log Message: ----------- patches Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/windows/HubFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-10 08:45:25 UTC (rev 671) +++ dcplusplus/trunk/changelog.txt 2006-10-10 10:16:29 UTC (rev 672) @@ -14,6 +14,7 @@ * Fixed a few random crashes * [ADC] Removed obsolete DSC command * Fixed user list not being updated in some cases +* [bug 1071] Added fasthash for unix (thanks steven sheehy) -- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-10-10 08:45:25 UTC (rev 671) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-10-10 10:16:29 UTC (rev 672) @@ -67,11 +67,11 @@ AdcCommand Download::getCommand(bool zlib) { AdcCommand cmd(AdcCommand::CMD_GET); if(isSet(FLAG_TREE_DOWNLOAD)) { - cmd.addParam("tthl"); + cmd.addParam(Transfer::TYPE_TTHL); } else if(isSet(FLAG_PARTIAL_LIST)) { - cmd.addParam("list"); + cmd.addParam(Transfer::TYPE_LIST); } else { - cmd.addParam("file"); + cmd.addParam(Transfer::TYPE_FILE); } if(isSet(FLAG_PARTIAL_LIST) || isSet(FLAG_USER_LIST)) { cmd.addParam(Util::toAdcFile(getSource())); @@ -436,8 +436,8 @@ const string& type = cmd.getParam(0); int64_t bytes = Util::toInt64(cmd.getParam(3)); - if(!(type == "file" || (type == "tthl" && aSource->getDownload()->isSet(Download::FLAG_TREE_DOWNLOAD)) || - (type == "list" && aSource->getDownload()->isSet(Download::FLAG_PARTIAL_LIST))) ) + if(!(type == Transfer::TYPE_FILE || (type == Transfer::TYPE_TTHL && aSource->getDownload()->isSet(Download::FLAG_TREE_DOWNLOAD)) || + (type == Transfer::TYPE_LIST && aSource->getDownload()->isSet(Download::FLAG_PARTIAL_LIST))) ) { // Uhh??? We didn't ask for this? aSource->disconnect(); Modified: dcplusplus/trunk/client/HashManager.cpp =================================================================== --- dcplusplus/trunk/client/HashManager.cpp 2006-10-10 08:45:25 UTC (rev 671) +++ dcplusplus/trunk/client/HashManager.cpp 2006-10-10 10:16:29 UTC (rev 672) @@ -27,6 +27,10 @@ #include "ZUtils.h" #include "SFVReader.h" +#ifndef _WIN32 +#include <sys/mman.h> // mmap, munmap, madvise +#endif + #define HASH_FILE_VERSION_STRING "2" static const uint32_t HASH_FILE_VERSION=2; const int64_t HashManager::MIN_BLOCK_SIZE = 64*1024; @@ -442,8 +446,6 @@ } } -#define BUF_SIZE (256*1024) - void HashManager::Hasher::hashFile(const string& fileName, int64_t size) { Lock l(cs); if(w.insert(make_pair(fileName, size)).second) { @@ -476,6 +478,8 @@ } #ifdef _WIN32 +#define BUF_SIZE (256*1024) + bool HashManager::Hasher::fastHash(const string& fname, uint8_t* buf, TigerTree& tth, int64_t size, CRC32Filter* xcrc32) { HANDLE h = INVALID_HANDLE_VALUE; DWORD x, y; @@ -580,8 +584,70 @@ ::CloseHandle(h); return ok; } -#endif +#else // !_WIN32 + +static const int64_t BUF_SIZE = 0x1000000 - (0x1000000 % getpagesize()); + +bool HashManager::Hasher::fastHash(const string& filename, u_int8_t* , TigerTree& tth, int64_t size, CRC32Filter* xcrc32) { + int fd = open(filename.c_str(), O_RDONLY); + if(fd == -1) + return false; + + int64_t size_left = size; + int64_t pos = 0; + int64_t size_read = 0; + void *buf = 0; + + u_int32_t lastRead = GET_TICK(); + while(pos <= size) { + if(size_left > 0) { + size_read = std::min(size_left, BUF_SIZE); + buf = mmap(0, size_read, PROT_READ, MAP_SHARED, fd, pos); + if(buf == MAP_FAILED) { + close(fd); + return false; + } + + madvise(buf, size_read, MADV_SEQUENTIAL | MADV_WILLNEED); + + if(SETTING(MAX_HASH_SPEED) > 0) { + u_int32_t now = GET_TICK(); + u_int32_t minTime = size_read * 1000LL / (SETTING(MAX_HASH_SPEED) * 1024LL * 1024LL); + if(lastRead + minTime > now) { + u_int32_t diff = now - lastRead; + Thread::sleep(minTime - diff); + } + lastRead = lastRead + minTime; + } else { + lastRead = GET_TICK(); + } + } else { + size_read = 0; + } + + tth.update(buf, size_read); + if(xcrc32) + (*xcrc32)(buf, size_read); + { + Lock l(cs); + currentSize = max(static_cast<u_int64_t>(currentSize - size_read), static_cast<u_int64_t>(0)); + } + + if(size_left <= 0) { + break; + } + + munmap(buf, size_read); + pos += size_read; + size_left -= size_read; + } + close(fd); + return true; +} + +#endif // !_WIN32 + int HashManager::Hasher::run() { setThreadPriority(Thread::IDLE); @@ -642,13 +708,15 @@ xcrc32 = &crc32; size_t n = 0; -#ifdef _WIN32 TigerTree fastTTH(bs); tth = &fastTTH; +#ifdef _WIN32 if(!virtualBuf || !BOOLSETTING(FAST_HASH) || !fastHash(fname, buf, fastTTH, size, xcrc32)) { +#else + if(!BOOLSETTING(FAST_HASH) || !fastHash(fname, 0, fastTTH, size, xcrc32)) { +#endif tth = &slowTTH; crc32 = CRC32Filter(); -#endif uint32_t lastRead = GET_TICK(); do { @@ -673,11 +741,10 @@ } sizeLeft -= n; } while (n > 0 && !stop); -#ifdef _WIN32 } else { sizeLeft = 0; } -#endif + f.close(); tth->finalize(); uint32_t end = GET_TICK(); @@ -706,7 +773,7 @@ VirtualFree(buf, 0, MEM_RELEASE); #endif } else { - delete buf; + delete [] buf; } buf = NULL; } Modified: dcplusplus/trunk/client/HashManager.h =================================================================== --- dcplusplus/trunk/client/HashManager.h 2006-10-10 08:45:25 UTC (rev 671) +++ dcplusplus/trunk/client/HashManager.h 2006-10-10 10:16:29 UTC (rev 672) @@ -113,9 +113,7 @@ void stopHashing(const string& baseDir); virtual int run(); -#ifdef _WIN32 bool fastHash(const string& fname, uint8_t* buf, TigerTree& tth, int64_t size, CRC32Filter* xcrc32); -#endif void getStats(string& curFile, int64_t& bytesLeft, size_t& filesLeft); void shutdown() { stop = true; s.signal(); } void scheduleRebuild() { rebuild = true; s.signal(); } Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-10-10 08:45:25 UTC (rev 671) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-10-10 10:16:29 UTC (rev 672) @@ -481,7 +481,9 @@ TaskQueue::List t; tasks.get(t); - ctrlUsers.SetRedraw(FALSE); + if(t.size() > 2) { + ctrlUsers.SetRedraw(FALSE); + } for(TaskQueue::Iter i = t.begin(); i != t.end(); ++i) { if(i->first == UPDATE_USER) { @@ -575,7 +577,9 @@ resort = false; } - ctrlUsers.SetRedraw(TRUE); + if(t.size() > 2) { + ctrlUsers.SetRedraw(TRUE); + } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-10 08:45:32
|
Revision: 671 http://svn.sourceforge.net/dcplusplus/?rev=671&view=rev Author: arnetheduck Date: 2006-10-10 01:45:25 -0700 (Tue, 10 Oct 2006) Log Message: ----------- Filelist slot fix Modified Paths: -------------- dcplusplus/trunk/client/UploadManager.cpp Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-10-10 07:22:32 UTC (rev 670) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-10-10 08:45:25 UTC (rev 671) @@ -113,7 +113,7 @@ return false; } - free = (size <= (int64_t)(SETTING(SET_MINISLOT_SIZE) * 1024) ); + free = free || (size <= (int64_t)(SETTING(SET_MINISLOT_SIZE) * 1024) ); f->setPos(start); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-10 07:22:38
|
Revision: 670 http://svn.sourceforge.net/dcplusplus/?rev=670&view=rev Author: arnetheduck Date: 2006-10-10 00:22:32 -0700 (Tue, 10 Oct 2006) Log Message: ----------- match fix Modified Paths: -------------- dcplusplus/trunk/client/QueueManager.cpp Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-10-10 06:36:40 UTC (rev 669) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-10-10 07:22:32 UTC (rev 670) @@ -625,6 +625,7 @@ int matches = 0; { Lock l(cs); + tthMap.clear(); buildMap(dl.getRoot()); for(QueueItem::StringMap::const_iterator i = fileQueue.getQueue().begin(); i != fileQueue.getQueue().end(); ++i) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-10 06:36:56
|
Revision: 669 http://svn.sourceforge.net/dcplusplus/?rev=669&view=rev Author: arnetheduck Date: 2006-10-09 23:36:40 -0700 (Mon, 09 Oct 2006) Log Message: ----------- lockup fix Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcCommand.h dcplusplus/trunk/client/ConnectionManager.h dcplusplus/trunk/client/FavoriteManager.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-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/changelog.txt 2006-10-10 06:36:40 UTC (rev 669) @@ -12,6 +12,8 @@ * Removed unmaintained autoconf files * Reworked match listing to make it slightly faster * Fixed a few random crashes +* [ADC] Removed obsolete DSC command +* Fixed user list not being updated in some cases -- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues Modified: dcplusplus/trunk/client/AdcCommand.h =================================================================== --- dcplusplus/trunk/client/AdcCommand.h 2006-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/client/AdcCommand.h 2006-10-10 06:36:40 UTC (rev 669) @@ -98,7 +98,6 @@ C(GPA, 'G','P','A'); C(PAS, 'P','A','S'); C(QUI, 'Q','U','I'); - C(DSC, 'D','S','C'); C(GET, 'G','E','T'); C(GFI, 'G','F','I'); C(SND, 'S','N','D'); @@ -190,7 +189,6 @@ C(GPA); C(PAS); C(QUI); - C(DSC); C(GET); C(GFI); C(SND); Modified: dcplusplus/trunk/client/ConnectionManager.h =================================================================== --- dcplusplus/trunk/client/ConnectionManager.h 2006-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/client/ConnectionManager.h 2006-10-10 06:36:40 UTC (rev 669) @@ -70,7 +70,7 @@ expectedConnections.insert(make_pair(aNick, make_pair(aMyNick, aHubUrl))); } - pair<string, string> remove(const string& aNick) { + StringPair remove(const string& aNick) { Lock l(cs); ExpectMap::iterator i = expectedConnections.find(aNick); Modified: dcplusplus/trunk/client/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/client/FavoriteManager.cpp 2006-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/client/FavoriteManager.cpp 2006-10-10 06:36:40 UTC (rev 669) @@ -404,12 +404,6 @@ addUserCommand(UserCommand::TYPE_RAW_ONCE, UserCommand::CONTEXT_CHAT | UserCommand::CONTEXT_SEARCH, UserCommand::FLAG_NOSAVE, STRING(REDIRECT_USER), redirstr, "op"); - // Add ADC standard op commands - static const char adc_disconnectstr[] = - "HDSC %[userSID]\n"; - addUserCommand(UserCommand::TYPE_RAW_ONCE, UserCommand::CONTEXT_CHAT | UserCommand::CONTEXT_SEARCH, UserCommand::FLAG_NOSAVE, - STRING(DISCONNECT_USER), adc_disconnectstr, "adc://op"); - try { SimpleXML xml; xml.fromXML(File(getConfigFile(), File::READ, File::OPEN).read()); Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-10-10 06:36:40 UTC (rev 669) @@ -633,7 +633,11 @@ continue; TTHMap::iterator j = tthMap.find(qi->getTTH()); if(j != tthMap.end() && i->second->getSize() == qi->getSize()) { - addSource(qi, dl.getUser(), QueueItem::Source::FLAG_FILE_NOT_AVAILABLE); + try { + addSource(qi, dl.getUser(), QueueItem::Source::FLAG_FILE_NOT_AVAILABLE); + } catch(...) { + // Ignore... + } matches++; } } Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-10-10 06:36:40 UTC (rev 669) @@ -1207,7 +1207,7 @@ } } -void HubFrame::on(Second, DWORD /*aTick*/) throw() { +void HubFrame::on(Second, uint32_t /*aTick*/) throw() { updateStatusBar(); if(updateUsers) { updateUsers = false; Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-10-08 22:22:19 UTC (rev 668) +++ dcplusplus/trunk/windows/HubFrame.h 2006-10-10 06:36:40 UTC (rev 669) @@ -375,7 +375,7 @@ void updateStatusBar() { if(m_hWnd) speak(STATS); } // TimerManagerListener - virtual void on(TimerManagerListener::Second, DWORD /*aTick*/) throw(); + virtual void on(TimerManagerListener::Second, uint32_t /*aTick*/) throw(); // ClientListener virtual void on(Connecting, Client*) throw(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-08 22:22:26
|
Revision: 668 http://svn.sourceforge.net/dcplusplus/?rev=668&view=rev Author: arnetheduck Date: 2006-10-08 15:22:19 -0700 (Sun, 08 Oct 2006) Log Message: ----------- comment fix Modified Paths: -------------- dcplusplus/trunk/client/stdinc.h Modified: dcplusplus/trunk/client/stdinc.h =================================================================== --- dcplusplus/trunk/client/stdinc.h 2006-10-08 20:45:44 UTC (rev 667) +++ dcplusplus/trunk/client/stdinc.h 2006-10-08 22:22:19 UTC (rev 668) @@ -72,7 +72,7 @@ # ifdef _STLPORT_VERSION # define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc, eq > # define HASH_MAP_X(key, type, hfunc, eq, order) hash_map<key, type, hfunc, eq > -// STLPort 4.6.2 hash_multimap buggy +// STLPort 5.0.2 hash_multimap buggy # define HASH_MULTIMAP_X(key, type, hfunc, eq, order) multimap<key, type, order > # elif defined(__GLIBCPP__) || defined(__GLIBCXX__) // Using GNU C++ library? # define HASH_SET_X(key, hfunc, eq, order) hash_set<key, hfunc, eq > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-08 20:45:52
|
Revision: 667 http://svn.sourceforge.net/dcplusplus/?rev=667&view=rev Author: arnetheduck Date: 2006-10-08 13:45:44 -0700 (Sun, 08 Oct 2006) Log Message: ----------- sharemanager fix Modified Paths: -------------- dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-10-08 19:59:43 UTC (rev 666) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-08 20:45:44 UTC (rev 667) @@ -43,7 +43,7 @@ #include <limits> -ShareManager::ShareManager() : hits(0), xmlListLen(0), bzXmlListLen(0), bzXmlFile(0), +ShareManager::ShareManager() : hits(0), xmlListLen(0), bzXmlListLen(0), xmlDirty(true), refreshDirs(false), update(false), initial(true), listN(0), refreshing(0), lastXmlUpdate(0), lastFullUpdate(GET_TICK()), bloom(1<<20) { @@ -344,7 +344,7 @@ SimpleXMLReader(&loader).fromXML(txt); for(Directory::MapIter i = directories.begin(); i != directories.end(); ++i) { - addTree(i->second); + addTree(*i->second); } return true; @@ -406,7 +406,7 @@ { Lock l(cs); - addTree(dp); + addTree(*dp); directories[d] = dp; virtualMap.push_back(make_pair(vName, d)); @@ -414,33 +414,33 @@ } } -void ShareManager::removeDirectory(const string& aDirectory, bool duringRefresh) { - Lock l(cs); - +void ShareManager::removeDirectory(const string& aDirectory) { string d(aDirectory); if(d[d.length() - 1] != PATH_SEPARATOR) d += PATH_SEPARATOR; - Directory::MapIter i = directories.find(d); - if(i != directories.end()) { - delete i->second; - directories.erase(i); - } + { + Lock l(cs); - for(StringPairIter j = virtualMap.begin(); j != virtualMap.end(); ++j) { - if(Util::stricmp(j->second.c_str(), d.c_str()) == 0) { - virtualMap.erase(j); - break; + Directory::MapIter i = directories.find(d); + if(i != directories.end()) { + delete i->second; + directories.erase(i); } - } - if(!duringRefresh) - HashManager::getInstance()->stopHashing(d); + for(StringPairIter j = virtualMap.begin(); j != virtualMap.end(); ++j) { + if(Util::stricmp(j->second.c_str(), d.c_str()) == 0) { + virtualMap.erase(j); + break; + } + } - buildIndex(); + rebuildIndices(); + setDirty(); + } - setDirty(); + HashManager::getInstance()->stopHashing(d); } void ShareManager::renameDirectory(const string& oName, const string& nName) throw(ShareException) { @@ -692,6 +692,7 @@ continue; } try { + //@todo race condition - if hashmanager finishes hashing before buildtree is done... if(HashManager::getInstance()->checkTTH(fileName, size, i->getLastWriteTime())) lastFileIter = dir->files.insert(lastFileIter, Directory::File(name, size, dir, HashManager::getInstance()->getTTH(fileName, size))); } catch(const HashException&) { @@ -703,58 +704,49 @@ return dir; } -void ShareManager::addTree(Directory* dir) { - bloom.add(Text::toLower(dir->getName())); +void ShareManager::addTree(Directory& dir) { + bloom.add(Text::toLower(dir.getName())); - for(Directory::MapIter i = dir->directories.begin(); i != dir->directories.end(); ++i) { - Directory* d = i->second; - addTree(d); + for(Directory::MapIter i = dir.directories.begin(); i != dir.directories.end(); ++i) { + addTree(*i->second); } - for(Directory::File::Iter i = dir->files.begin(); i != dir->files.end(); ) { + for(Directory::File::Iter i = dir.files.begin(); i != dir.files.end(); ) { addFile(dir, i++); } } -void ShareManager::buildIndex(const Directory& dir) { - for(Directory::Map::const_iterator i = dir.directories.begin(); i != dir.directories.end(); ++i) { - buildIndex(*i->second); - } - for(Directory::File::Set::const_iterator i = dir.files.begin(); i != dir.files.end(); ++i) { - tthIndex.insert(make_pair(i->getTTH(), i)); - } -} - -void ShareManager::buildIndex() { +void ShareManager::rebuildIndices() { tthIndex.clear(); + bloom.clear(); + for(Directory::Map::const_iterator i = directories.begin(); i != directories.end(); ++i) { - buildIndex(*i->second); + addTree(*i->second); } } -void ShareManager::addFile(Directory* dir, Directory::File::Iter i) { +void ShareManager::addFile(Directory& dir, Directory::File::Iter i) { const Directory::File& f = *i; HashFileIter j = tthIndex.find(f.getTTH()); if(j == tthIndex.end()) { - dir->size+=f.getSize(); + dir.size+=f.getSize(); } else { if(!SETTING(LIST_DUPES)) { - LogManager::getInstance()->message(STRING(DUPLICATE_FILE_NOT_SHARED) + dir->getFullName() + f.getName() + " (" + STRING(SIZE) + ": " + Util::toString(f.getSize()) + " " + STRING(B) + ") " + STRING(DUPLICATE_MATCH) + j->second->getParent()->getFullName() + j->second->getName() ); - dir->files.erase(i); + LogManager::getInstance()->message(STRING(DUPLICATE_FILE_NOT_SHARED) + dir.getFullName() + f.getName() + " (" + STRING(SIZE) + ": " + Util::toString(f.getSize()) + " " + STRING(B) + ") " + STRING(DUPLICATE_MATCH) + j->second->getParent()->getFullName() + j->second->getName() ); + dir.files.erase(i); return; } } - dir->addType(getType(f.getName())); + dir.addType(getType(f.getName())); tthIndex.insert(make_pair(f.getTTH(), i)); bloom.add(Text::toLower(f.getName())); } void ShareManager::refresh(bool dirs /* = false */, bool aUpdate /* = true */, bool block /* = false */) throw(ThreadException, ShareException) { - if(Thread::safeInc(refreshing) > 1) { - Thread::safeDec(refreshing); + if(Thread::safeExchange(refreshing, 1) == 1) { LogManager::getInstance()->message(STRING(FILE_LIST_REFRRESH_IN_PROGRESS)); return; } @@ -792,36 +784,30 @@ } for(StringPairIter i = dirs.begin(); i != dirs.end(); ++i) { - Directory* dp = buildTree(i->second, NULL); + Directory* dp = buildTree(i->second, 0); dp->setName(i->first); newDirs.insert(make_pair(i->second, dp)); } { Lock l(cs); - StringPairList dirs = virtualMap; - for(StringPairIter i = dirs.begin(); i != dirs.end(); ++i) { - removeDirectory(i->second, true); + for(Directory::MapIter i = directories.begin(); i != directories.end(); ++i) { + delete i->second; } - bloom.clear(); + directories = newDirs; - virtualMap = dirs; - - for(Directory::MapIter i = newDirs.begin(); i != newDirs.end(); ++i) { - addTree(i->second); - directories.insert(*i); - } + rebuildIndices(); } refreshDirs = false; } } - Thread::safeDec(refreshing); LogManager::getInstance()->message(STRING(FILE_LIST_REFRESH_FINISHED)); if(update) { ClientManager::getInstance()->infoUpdated(); } + refreshing = 0; return 0; } @@ -946,30 +932,6 @@ } #define LITERAL(n) n, sizeof(n)-1 -void ShareManager::Directory::toNmdc(string& nmdc, string& indent, string& tmp2) { - tmp2.clear(); - nmdc.append(indent); - nmdc.append(Text::utf8ToAcp(name, tmp2)); - nmdc.append(LITERAL("\r\n")); - - indent += '\t'; - for(MapIter i = directories.begin(); i != directories.end(); ++i) { - i->second->toNmdc(nmdc, indent, tmp2); - } - - Directory::File::Iter j = files.begin(); - for(Directory::File::Iter i = files.begin(); i != files.end(); ++i) { - const Directory::File& f = *i; - nmdc.append(indent); - tmp2.clear(); - nmdc.append(Text::utf8ToAcp(f.getName(), tmp2)); - nmdc.append(LITERAL("|")); - nmdc.append(Util::toString(f.getSize())); - nmdc.append(LITERAL("\r\n")); - } - indent.erase(indent.length()-1); -} - void ShareManager::Directory::toXml(OutputStream& xmlFile, string& indent, string& tmp2, bool fullList) { xmlFile.write(indent); xmlFile.write(LITERAL("<Directory Name=\"")); @@ -1357,6 +1319,20 @@ } } +int64_t ShareManager::Directory::getSize() { + int64_t tmp = size; + for(MapIter i = directories.begin(); i != directories.end(); ++i) + tmp+=i->second->getSize(); + return tmp; +} + +size_t ShareManager::Directory::countFiles() { + size_t tmp = files.size(); + for(MapIter i = directories.begin(); i != directories.end(); ++i) + tmp+=i->second->countFiles(); + return tmp; +} + ShareManager::Directory* ShareManager::getDirectory(const string& fname) { for(Directory::MapIter mi = directories.begin(); mi != directories.end(); ++mi) { if(Util::strnicmp(fname, mi->first, mi->first.length()) == 0) { @@ -1413,7 +1389,7 @@ string name = Util::getFileName(fname); int64_t size = File::getSize(fname); Directory::File::Iter it = d->files.insert(Directory::File(name, size, d, root)).first; - addFile(d, it); + addFile(*d, it); } setDirty(); } Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-10-08 19:59:43 UTC (rev 666) +++ dcplusplus/trunk/client/ShareManager.h 2006-10-08 20:45:44 UTC (rev 667) @@ -55,7 +55,7 @@ * @param aName Virtual name */ void addDirectory(const string& aDirectory, const string & aName) throw(ShareException); - void removeDirectory(const string& aName, bool duringRefresh = false); + void removeDirectory(const string& aName); void renameDirectory(const string& oName, const string& nName) throw(ShareException); string toVirtual(const TTHValue& tth) throw(ShareException); string toReal(const string& virtualFile) throw(ShareException); @@ -168,24 +168,12 @@ string getADCPath() const throw(); string getFullName() const throw(); - int64_t getSize() { - int64_t tmp = size; - for(MapIter i = directories.begin(); i != directories.end(); ++i) - tmp+=i->second->getSize(); - return tmp; - } + int64_t getSize(); + size_t countFiles(); - size_t countFiles() { - size_t tmp = files.size(); - for(MapIter i = directories.begin(); i != directories.end(); ++i) - tmp+=i->second->countFiles(); - return tmp; - } - void search(SearchResult::List& aResults, StringSearch::List& aStrings, int aSearchType, int64_t aSize, int aFileType, Client* aClient, StringList::size_type maxResults) throw(); void search(SearchResult::List& aResults, AdcSearch& aStrings, StringList::size_type maxResults) throw(); - void toNmdc(string& nmdc, string& indent, string& tmp2); void toXml(OutputStream& xmlFile, string& indent, string& tmp2, bool fullList); void filesToXml(OutputStream& xmlFile, string& indent, string& tmp2); @@ -286,12 +274,11 @@ bool checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it); Directory* buildTree(const string& aName, Directory* aParent); - - void buildIndex(); - void buildIndex(const Directory& dir); - void addTree(Directory* aDirectory); - void addFile(Directory* dir, Directory::File::Iter i); + void rebuildIndices(); + + void addTree(Directory& aDirectory); + void addFile(Directory& dir, Directory::File::Iter i); void generateXmlList(); bool loadCache(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-08 20:01:23
|
Revision: 666 http://svn.sourceforge.net/dcplusplus/?rev=666&view=rev Author: arnetheduck Date: 2006-10-08 12:59:43 -0700 (Sun, 08 Oct 2006) Log Message: ----------- cleanup, bugfixes Modified Paths: -------------- dcplusplus/trunk/Compile.txt dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcCommand.cpp dcplusplus/trunk/client/AdcCommand.h dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/BitInputStream.h dcplusplus/trunk/client/BitOutputStream.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/ConnectionManager.cpp dcplusplus/trunk/client/ConnectionManager.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/CryptoManager.h dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/Encoder.cpp dcplusplus/trunk/client/Encoder.h dcplusplus/trunk/client/FastAlloc.h dcplusplus/trunk/client/FavoriteManager.cpp dcplusplus/trunk/client/FavoriteManager.h dcplusplus/trunk/client/FavoriteUser.h dcplusplus/trunk/client/File.cpp dcplusplus/trunk/client/File.h dcplusplus/trunk/client/FilteredFile.h dcplusplus/trunk/client/FinishedManager.h dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/client/HashValue.h dcplusplus/trunk/client/HttpConnection.cpp dcplusplus/trunk/client/HttpConnection.h dcplusplus/trunk/client/MerkleCheckOutputStream.h dcplusplus/trunk/client/MerkleTree.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/SFVReader.h dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SSLSocket.h dcplusplus/trunk/client/SearchManager.cpp dcplusplus/trunk/client/SearchManager.h dcplusplus/trunk/client/Semaphore.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/Streams.h dcplusplus/trunk/client/StringSearch.h dcplusplus/trunk/client/Text.cpp dcplusplus/trunk/client/Text.h dcplusplus/trunk/client/Thread.h dcplusplus/trunk/client/TigerHash.cpp dcplusplus/trunk/client/TigerHash.h dcplusplus/trunk/client/TimerManager.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/UserConnection.cpp dcplusplus/trunk/client/UserConnection.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/client/ZUtils.h dcplusplus/trunk/client/config.h dcplusplus/trunk/client/stdinc.cpp dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/windows/AboutDlg.h dcplusplus/trunk/windows/HashProgressDlg.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/windows/MainFrm.h dcplusplus/trunk/windows/QueueFrame.h dcplusplus/trunk/windows/SpyFrame.cpp dcplusplus/trunk/windows/SpyFrame.h dcplusplus/trunk/windows/StatsFrame.cpp dcplusplus/trunk/windows/StatsFrame.h dcplusplus/trunk/windows/TransferView.h dcplusplus/trunk/windows/WinUtil.cpp Removed Paths: ------------- dcplusplus/trunk/Makefile.am dcplusplus/trunk/acinclude.m4 dcplusplus/trunk/client/Makefile.am dcplusplus/trunk/configure.ac Modified: dcplusplus/trunk/Compile.txt =================================================================== --- dcplusplus/trunk/Compile.txt 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/Compile.txt 2006-10-08 19:59:43 UTC (rev 666) @@ -2,7 +2,10 @@ How to compile in 3 easy steps: -1) Download the source and STLPort from the DC++ download site. Unpack the DC++ source. Unpack the STLport source into the stlport directory. +1) Download the source DC++ download site. Unpack the DC++ source. + Download STLPort 5.0.2 from http://sf.net/stlport and unpack it to a temporary folder. Inside you'll + find a folder named stlport which contains files such as "algorithm". Copy the contents of this folder + to the stlport folder where you unpacked DC++. Download WTL from http://sf.net/projects/wtl. Unpack it to the wtl folder. 2) You most probably have to update your Platform SDK, http://msdn.microsoft.com will tell you how. @@ -10,29 +13,24 @@ one file, you can ask someone at the dev hub to supply it for you (or look for it in the DC++ bugzilla, it's attached to one of the bugs). -3) Open the solution and press your build button. If you find your executable unreasonably large, you - probably compiled in debug mode - switch to release once you're done testing the code. +3) Open the solution in vc7.1 (2004) and press your build button. If you find your executable unreasonably large, + you probably compiled in debug mode - switch to release once you're done testing the code. -Note 1; I now use vc7.1 (2003). I don't care particularly if you use an older MS compiler (6.0, 7.0), - because these don't even come close to supporting the c++ standard. If you want to try anyway, - you're on your own. You will need a new Platform SDK if you're using VS 6.0. - The client part usually compiles fine with g++ 3.4+, There's a bug in 3.3 - (and probably older versions) that prevents a few files from being compiled. -Note 2; You'll need DBGHELP.dll from the binary distribution unless you're using WinXP, otherwise +Note; You'll need DBGHELP.dll from the binary distribution unless you're using WinXP, otherwise you'll get errors saying symbols are missing when running your compiled executable. My copy says version 5.1.2600.1106 right now. -Note 3; If you have problems, read the forum posts before posting. Somebody else has probably made your +Note; If you have problems, read the forum posts before posting. Somebody else has probably made your mistake already. The word to note in the last sentence is 'your', so let me articulate a bit more, it works on my computer, so it's yours that is not correctly set up. -Note 4; To build the HTML Help file, you will need to download and install the HTML Help Workshop +Note; To build the HTML Help file, you will need to download and install the HTML Help Workshop application. The custom build setup relies on it being installed to the default path, which is: "C:\Program Files\HTML Help Workshop\" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp -Note 5; You need to have python installed if you change StringDefs.h, as a small python script is automatically +Note; You need to have python installed if you change StringDefs.h, as a small python script is automatically run to generate StringDefs.cpp and Example.xml. To turn it off or change python path, go to client->Header Files->StringDefs.h->Properties->Custom build step and change the appropriate values. The help file's changelog.html is also updated via a python script (courtesy of fusbar). @@ -41,12 +39,7 @@ to generate some nice docs...just check that the paths in doxyfile are correct (graphviz)... Linux / Unix: -I've made some rudimentary autoconf/automake scripts now, so you can compile the client part into a library -without too much hassle (I don't check if it compiles very often though...). You'll need the latest versions -of automake and autoconf, and after getting the source (from SVN is easiest), do -"aclocal && automake && autoconf && configure && make" and you'll have the client part nicely compiled. -When / if I test it I do it on a Gentoo AMD64 box with the latest gcc in 64-bit mode, so I don't have a clue -if the 32-bit compile works... +Look at linuxdcpp.berlios.de for the *nix port of DC++ - they'll gladly accept any help. Submitting patches @@ -55,12 +48,17 @@ completely random, which just might be the case. Popular reasons for rejecting a patch include, but are not limited to, ugly code, abusable features, feature that I don't like that bloat the application and incompatibility with other modifications I've already done. -To increase the chances of your patch being accepted, post them in the DC++ bugzilla as diffs against the latest -code you can find (in the SVN repository on sourceforge most probably). You can find a lot of -information about diff and patch by googling for it. I like unified format (diff -u). When diffing, apply diff to -the folders of the two versions, so that the paths will be included in the diff. + +To increase the chances of your patch being accepted, do like this: +1) Check out the latest code from SVN (see http://sf.net/projects/dcplusplus for instructions) +2) Make your modification. If you make other modifications apart from the one you want to submit, do them + on a separate copy of the DC++ source code and then copy them to this folder. +3) In the source root folder (the one with this file in it) do "svn diff > my-patch.diff". +4) Post the file in the DC++ bugzilla (don't forget to hand over copyright, see below). + By submitting a patch, you agree to that I get copyright of it. This to avoid stupid situations later on where the copyright is split out over a million people, each of which could stop further distribution of DC++, and also to make it easier for us to defend the gpl against violators. If you don't like this policy, start your own distribution, if you're lucky it might become more popular than the original =). Please -state explicitly in the email that you give me copyright over the code if the submission is larger than trivial. +state explicitly in the bugzilla that you give me copyright over the code if the submission is larger than trivial. + Deleted: dcplusplus/trunk/Makefile.am =================================================================== --- dcplusplus/trunk/Makefile.am 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/Makefile.am 2006-10-08 19:59:43 UTC (rev 666) @@ -1 +0,0 @@ -SUBDIRS=client Deleted: dcplusplus/trunk/acinclude.m4 =================================================================== --- dcplusplus/trunk/acinclude.m4 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/acinclude.m4 2006-10-08 19:59:43 UTC (rev 666) @@ -1,21 +0,0 @@ - -# Check for STLPort -AC_DEFUN([AX_LIB_STLPORT], -[ - AC_MSG_CHECKING([for STLPort]) - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE( - [ - AC_LANG_PROGRAM - ([[ -#include <string> -#ifndef _STLPORT_VERSION -#error No STLPort -#endif - ]]) - ], - [AC_DEFINE([HAVE_STLPORT], 1, [If you have STLPort installed]) AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - AC_LANG_POP -]) \ No newline at end of file Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/changelog.txt 2006-10-08 19:59:43 UTC (rev 666) @@ -6,6 +6,12 @@ * Fixed crash on invalid remote command during upload * [ADC] Improved GFI command support * Lowest priority downloads are no longer started if there are other downloads running +* Upgraded to STLport 5.0.2 +* Updated compile instructions +* Updated unsigned types to C99 +* Removed unmaintained autoconf files +* Reworked match listing to make it slightly faster +* Fixed a few random crashes -- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues Modified: dcplusplus/trunk/client/AdcCommand.cpp =================================================================== --- dcplusplus/trunk/client/AdcCommand.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcCommand.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -22,8 +22,8 @@ #include "AdcCommand.h" #include "ClientManager.h" -AdcCommand::AdcCommand(u_int32_t aCmd, char aType /* = TYPE_CLIENT */) : cmdInt(aCmd), from(0), type(aType) { } -AdcCommand::AdcCommand(u_int32_t aCmd, const u_int32_t aTarget, char aType) : cmdInt(aCmd), from(0), to(aTarget), type(aType) { } +AdcCommand::AdcCommand(uint32_t aCmd, char aType /* = TYPE_CLIENT */) : cmdInt(aCmd), from(0), type(aType) { } +AdcCommand::AdcCommand(uint32_t aCmd, const uint32_t aTarget, char aType) : cmdInt(aCmd), from(0), to(aTarget), type(aType) { } AdcCommand::AdcCommand(Severity sev, Error err, const string& desc, char aType /* = TYPE_CLIENT */) : cmdInt(CMD_STA), from(0), type(aType) { addParam(Util::toString(sev * 100 + err)); addParam(desc); @@ -161,7 +161,7 @@ return getHeaderString(aCID) + getParamString(false); } -string AdcCommand::toString(u_int32_t sid /* = 0 */, bool nmdc /* = false */) const { +string AdcCommand::toString(uint32_t sid /* = 0 */, bool nmdc /* = false */) const { return getHeaderString(sid, nmdc) + getParamString(nmdc); } @@ -183,7 +183,7 @@ return tmp; } -string AdcCommand::getHeaderString(u_int32_t sid, bool nmdc) const { +string AdcCommand::getHeaderString(uint32_t sid, bool nmdc) const { string tmp; if(nmdc) { tmp += "$ADC"; Modified: dcplusplus/trunk/client/AdcCommand.h =================================================================== --- dcplusplus/trunk/client/AdcCommand.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcCommand.h 2006-10-08 19:59:43 UTC (rev 666) @@ -32,7 +32,7 @@ class AdcCommand { public: - template<u_int32_t T> + template<uint32_t T> struct Type { enum { CMD = T }; }; @@ -82,9 +82,9 @@ 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 +#define C(n, a, b, c) static const uint32_t CMD_##n = (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_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 +#define C(n, a, b, c) static const uint32_t CMD_##n = ((((uint32_t)a)<<24) | (((uint32_t)b)<<16) | (((uint32_t)c)<<8)); typedef Type<CMD_##n> n #endif // Base commands C(SUP, 'S','U','P'); @@ -107,15 +107,15 @@ C(CMD, 'C','M','D'); #undef C - static const u_int32_t HUB_SID = 0x41414141; // AAAA in base32 + static const uint32_t HUB_SID = 0x41414141; // AAAA in base32 - explicit AdcCommand(u_int32_t aCmd, char aType = TYPE_CLIENT); - explicit AdcCommand(u_int32_t aCmd, const u_int32_t aTarget, char aType); + explicit AdcCommand(uint32_t aCmd, char aType = TYPE_CLIENT); + explicit AdcCommand(uint32_t aCmd, const uint32_t aTarget, char aType); explicit AdcCommand(Severity sev, Error err, const string& desc, char aType = TYPE_CLIENT); explicit AdcCommand(const string& aLine, bool nmdc = false) throw(ParseException); void parse(const string& aLine, bool nmdc = false) throw(ParseException); - u_int32_t getCommand() const { return cmdInt; } + uint32_t getCommand() const { return cmdInt; } char getType() const { return type; } void setType(char t) { type = t; } @@ -125,7 +125,7 @@ const StringList& getParameters() const { return parameters; } string toString(const CID& aCID) const; - string toString(u_int32_t sid, bool nmdc = false) const; + string toString(uint32_t sid, bool nmdc = false) const; AdcCommand& addParam(const string& name, const string& value) { parameters.push_back(name); @@ -142,30 +142,30 @@ /** Return a named parameter where the name is a two-letter code */ bool getParam(const char* name, size_t start, string& ret) const; bool hasFlag(const char* name, size_t start) const; - static u_int16_t toCode(const char* x) { return *((u_int16_t*)x); } + static uint16_t toCode(const char* x) { return *((uint16_t*)x); } - bool operator==(u_int32_t aCmd) { return cmdInt == aCmd; } + bool operator==(uint32_t aCmd) { return cmdInt == aCmd; } static string escape(const string& str, bool old); - u_int32_t getTo() const { return to; } - AdcCommand& setTo(const u_int32_t sid) { to = sid; return *this; } - u_int32_t getFrom() const { return from; } + uint32_t getTo() const { return to; } + AdcCommand& setTo(const uint32_t sid) { to = sid; return *this; } + uint32_t getFrom() const { return from; } - static u_int32_t toSID(const string& aSID) { return *reinterpret_cast<const u_int32_t*>(aSID.data()); } - static string fromSID(const u_int32_t aSID) { return string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } + static uint32_t toSID(const string& aSID) { return *reinterpret_cast<const uint32_t*>(aSID.data()); } + static string fromSID(const uint32_t aSID) { return string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } private: string getHeaderString(const CID& cid) const; - string getHeaderString(u_int32_t sid, bool nmdc) const; + string getHeaderString(uint32_t sid, bool nmdc) const; string getParamString(bool nmdc) const; StringList parameters; string features; union { char cmdChar[4]; - u_int8_t cmd[4]; - u_int32_t cmdInt; + uint8_t cmd[4]; + uint32_t cmdInt; }; - u_int32_t from; - u_int32_t to; + uint32_t from; + uint32_t to; char type; }; Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -48,7 +48,7 @@ clearUsers(); } -OnlineUser& AdcHub::getUser(const u_int32_t aSID, const CID& aCID) { +OnlineUser& AdcHub::getUser(const uint32_t aSID, const CID& aCID) { OnlineUser* ou = findUser(aSID); if(ou) { return *ou; @@ -62,17 +62,17 @@ } if(aSID != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOnline(*ou); + ClientManager::getInstance()->putOnline(ou); return *ou; } -OnlineUser* AdcHub::findUser(const u_int32_t aSID) const { +OnlineUser* AdcHub::findUser(const uint32_t aSID) const { Lock l(cs); SIDMap::const_iterator i = users.find(aSID); return i == users.end() ? NULL : i->second; } -void AdcHub::putUser(const u_int32_t aSID) { +void AdcHub::putUser(const uint32_t aSID) { OnlineUser* ou = 0; { Lock l(cs); @@ -84,7 +84,7 @@ } if(aSID != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOffline(*ou); + ClientManager::getInstance()->putOffline(ou); fire(ClientListener::UserRemoved(), this, *ou); delete ou; @@ -99,12 +99,11 @@ for(SIDIter i = tmp.begin(); i != tmp.end(); ++i) { if(i->first != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOffline(*i->second); + ClientManager::getInstance()->putOffline(i->second); delete i->second; } } - void AdcHub::handle(AdcCommand::INF, AdcCommand& c) throw() { if(c.getParameters().empty()) return; @@ -386,7 +385,7 @@ } void AdcHub::connect(const OnlineUser& user) { - u_int32_t r = Util::rand(); + uint32_t r = Util::rand(); connect(user, Util::toString(r), CryptoManager::getInstance()->TLSOk() && user.getUser()->isSet(User::TLS)); } @@ -460,7 +459,7 @@ return; if(!salt.empty()) { size_t saltBytes = salt.size() * 5 / 8; - AutoArray<u_int8_t> buf(saltBytes); + AutoArray<uint8_t> buf(saltBytes); Encoder::fromBase32(salt.c_str(), buf, saltBytes); TigerHash th; CID cid = getMyIdentity().getUser()->getCID(); @@ -568,7 +567,7 @@ string AdcHub::checkNick(const string& aNick) { string tmp = aNick; for(size_t i = 0; i < aNick.size(); ++i) { - if(static_cast<u_int8_t>(tmp[i]) <= 32) { + if(static_cast<uint8_t>(tmp[i]) <= 32) { tmp[i] = '_'; } } @@ -607,7 +606,7 @@ send(cmd.toString(sid)); } -void AdcHub::on(Second, u_int32_t aTick) throw() { +void AdcHub::on(Second, uint32_t aTick) throw() { if(getAutoReconnect() && state == STATE_PROTOCOL && (getReconnecting() || ((getLastActivity() + getReconnDelay() * 1000) < aTick)) ) { // Try to reconnect... connect(); Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcHub.h 2006-10-08 19:59:43 UTC (rev 666) @@ -70,7 +70,7 @@ virtual ~AdcHub() throw(); /** Map session id to OnlineUser */ - typedef HASH_MAP<u_int32_t, OnlineUser*> SIDMap; + typedef HASH_MAP<uint32_t, OnlineUser*> SIDMap; typedef SIDMap::iterator SIDIter; Socket udp; @@ -80,7 +80,7 @@ string salt; - u_int32_t sid; + uint32_t sid; bool reconnect; static const string CLIENT_PROTOCOL; @@ -91,9 +91,9 @@ 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); + OnlineUser& getUser(const uint32_t aSID, const CID& aCID); + OnlineUser* findUser(const uint32_t sid) const; + void putUser(const uint32_t sid); void clearUsers(); @@ -121,7 +121,7 @@ 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(); + virtual void on(Second, uint32_t aTick) throw(); }; #endif // !defined(ADC_HUB_H) Modified: dcplusplus/trunk/client/BitInputStream.h =================================================================== --- dcplusplus/trunk/client/BitInputStream.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BitInputStream.h 2006-10-08 19:59:43 UTC (rev 666) @@ -35,14 +35,14 @@ class BitInputStream { public: - BitInputStream(const u_int8_t* aStream, size_t aStart, size_t aEnd) : bitPos(aStart*8), endPos(aEnd*8), is(aStream) { } + BitInputStream(const uint8_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)); } - bool ret = (((u_int8_t)is[bitPos>>3]) >> (bitPos&0x07)) & 0x01; + bool ret = (((uint8_t)is[bitPos>>3]) >> (bitPos&0x07)) & 0x01; bitPos++; return ret; } @@ -62,7 +62,7 @@ size_t bitPos; size_t endPos; - const u_int8_t* is; + const uint8_t* is; }; #endif // !defined(BIT_INPUT_STREAM_H) Modified: dcplusplus/trunk/client/BitOutputStream.h =================================================================== --- dcplusplus/trunk/client/BitOutputStream.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BitOutputStream.h 2006-10-08 19:59:43 UTC (rev 666) @@ -29,8 +29,8 @@ 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) { + void put(vector<uint8_t>& b) { + for(vector<uint8_t>::iterator i = b.begin(); i != b.end(); ++i) { next |= (*i) << bitPos++; if(bitPos > 7) { @@ -54,7 +54,7 @@ BitOutputStream& operator=(const BitOutputStream&); string& is; int bitPos; - u_int8_t next; + uint8_t next; }; #endif // !defined(BIT_OUTPUT_STREAM_H) Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -136,7 +136,7 @@ return; fire(BufferedSocketListener::Connecting()); - u_int32_t startTime = GET_TICK(); + uint32_t startTime = GET_TICK(); if(proxy) { sock->socksConnect(aAddr, aPort, CONNECT_TIMEOUT); } else { @@ -180,7 +180,7 @@ const int BufSize = 1024; // Special to autodetect nmdc connections... string::size_type pos = 0; - AutoArray<u_int8_t> buffer (BufSize); + AutoArray<uint8_t> buffer (BufSize); size_t in; l = line; // decompress all input data and store in l. @@ -269,8 +269,8 @@ 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); + vector<uint8_t> readBuf(bufSize); + vector<uint8_t> writeBuf(bufSize); size_t readPos = 0; Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-10-08 19:59:43 UTC (rev 666) @@ -51,7 +51,7 @@ virtual void on(Connecting) throw() { } virtual void on(Connected) throw() { } virtual void on(Line, const string&) throw() { } - virtual void on(Data, u_int8_t*, size_t) throw() { } + virtual void on(Data, uint8_t*, size_t) throw() { } virtual void on(BytesSent, size_t, size_t) throw() { } virtual void on(ModeChange) throw() { } virtual void on(TransmitDone) throw() { } @@ -158,9 +158,9 @@ size_t rollback; bool failed; string line; - vector<u_int8_t> inbuf; - vector<u_int8_t> writeBuf; - vector<u_int8_t> sendBuf; + vector<uint8_t> inbuf; + vector<uint8_t> writeBuf; + vector<uint8_t> sendBuf; Socket* sock; bool disconnecting; Modified: dcplusplus/trunk/client/CID.h =================================================================== --- dcplusplus/trunk/client/CID.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/CID.h 2006-10-08 19:59:43 UTC (rev 666) @@ -34,7 +34,7 @@ size_t operator()(const CID& c) const { return c.toHash(); } }; CID() { memset(cid, 0, sizeof(cid)); } - explicit CID(const u_int8_t* data) { memcpy(cid, data, sizeof(cid)); } + explicit CID(const uint8_t* data) { memcpy(cid, data, sizeof(cid)); } explicit CID(const string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } bool operator==(const CID& rhs) const { return memcmp(cid, rhs.cid, sizeof(cid)) == 0; } @@ -44,20 +44,20 @@ 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; } + const uint8_t* data() const { return cid; } - bool isZero() const { return find_if(cid, cid+SIZE, bind2nd(not_equal_to<u_int8_t>(), 0)) == (cid+SIZE); } + bool isZero() const { return find_if(cid, cid+SIZE, bind2nd(not_equal_to<uint8_t>(), 0)) == (cid+SIZE); } static CID generate() { - u_int8_t data[CID::SIZE]; + uint8_t data[CID::SIZE]; for(size_t i = 0; i < sizeof(data); ++i) { - data[i] = (u_int8_t)Util::rand(); + data[i] = (uint8_t)Util::rand(); } return CID(data); } private: - u_int8_t cid[SIZE]; + uint8_t cid[SIZE]; }; #endif // !defined(CID_H) Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Client.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -166,5 +166,5 @@ return lip; } -void Client::on(Second, u_int32_t) throw() { +void Client::on(Second, uint32_t) throw() { } Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Client.h 2006-10-08 19:59:43 UTC (rev 666) @@ -149,8 +149,8 @@ GETSET(Identity, hubIdentity, HubIdentity); GETSET(string, defpassword, Password); - GETSET(u_int32_t, reconnDelay, ReconnDelay); - GETSET(u_int32_t, lastActivity, LastActivity); + GETSET(uint32_t, reconnDelay, ReconnDelay); + GETSET(uint32_t, lastActivity, LastActivity); GETSET(bool, registered, Registered); GETSET(bool, autoReconnect, AutoReconnect); GETSET(bool, reconnecting, Reconnecting); @@ -183,7 +183,7 @@ virtual string checkNick(const string& nick) = 0; // TimerManagerListener - virtual void on(Second, u_int32_t aTick) throw(); + virtual void on(Second, uint32_t aTick) throw(); private: @@ -200,7 +200,7 @@ string hubUrl; string address; string ip; - u_int16_t port; + uint16_t port; char separator; bool secure; CountType countType; Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -33,7 +33,6 @@ #include "AdcHub.h" #include "NmdcHub.h" - Client* ClientManager::getClient(const string& aHubURL) { Client* c; if(Util::strnicmp("adc://", aHubURL.c_str(), 6) == 0) { @@ -67,41 +66,41 @@ delete aClient; } -size_t ClientManager::getUserCount() { +size_t ClientManager::getUserCount() const { Lock l(cs); return onlineUsers.size(); } -StringList ClientManager::getHubs(const CID& cid) { +StringList ClientManager::getHubs(const CID& cid) const { Lock l(cs); StringList lst; - OnlinePair op = onlineUsers.equal_range(cid); - for(OnlineIter i = op.first; i != op.second; ++i) { + OnlinePairC op = onlineUsers.equal_range(cid); + for(OnlineIterC i = op.first; i != op.second; ++i) { lst.push_back(i->second->getClient().getHubUrl()); } return lst; } -StringList ClientManager::getHubNames(const CID& cid) { +StringList ClientManager::getHubNames(const CID& cid) const { Lock l(cs); StringList lst; - OnlinePair op = onlineUsers.equal_range(cid); - for(OnlineIter i = op.first; i != op.second; ++i) { + OnlinePairC op = onlineUsers.equal_range(cid); + for(OnlineIterC i = op.first; i != op.second; ++i) { lst.push_back(i->second->getClient().getHubName()); } return lst; } -StringList ClientManager::getNicks(const CID& cid) { +StringList ClientManager::getNicks(const CID& cid) const { Lock l(cs); StringSet nicks; - OnlinePair op = onlineUsers.equal_range(cid); - for(OnlineIter i = op.first; i != op.second; ++i) { + OnlinePairC op = onlineUsers.equal_range(cid); + for(OnlineIterC i = op.first; i != op.second; ++i) { nicks.insert(i->second->getIdentity().getNick()); } if(nicks.empty()) { // Offline perhaps? - UserIter i = users.find(cid); + UserMap::const_iterator i = users.find(cid); if(i != users.end() && !i->second->getFirstNick().empty()) { nicks.insert(i->second->getFirstNick()); } else { @@ -111,29 +110,29 @@ return StringList(nicks.begin(), nicks.end()); } -string ClientManager::getConnection(const CID& cid) { +string ClientManager::getConnection(const CID& cid) const { Lock l(cs); - OnlineIter i = onlineUsers.find(cid); + OnlineIterC i = onlineUsers.find(cid); if(i != onlineUsers.end()) { return i->second->getIdentity().getConnection(); } return STRING(OFFLINE); } -int64_t ClientManager::getAvailable() { +int64_t ClientManager::getAvailable() const { Lock l(cs); int64_t bytes = 0; - for(OnlineIter i = onlineUsers.begin(); i != onlineUsers.end(); ++i) { + for(OnlineIterC i = onlineUsers.begin(); i != onlineUsers.end(); ++i) { bytes += i->second->getIdentity().getBytesShared(); } return bytes; } -bool ClientManager::isConnected(const string& aUrl) { +bool ClientManager::isConnected(const string& aUrl) const { Lock l(cs); - for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { + for(Client::List::const_iterator i = clients.begin(); i != clients.end(); ++i) { if((*i)->getHubUrl() == aUrl) { return true; } @@ -141,7 +140,7 @@ return false; } -string ClientManager::findHub(const string& ipPort) { +string ClientManager::findHub(const string& ipPort) const { Lock l(cs); string ip; @@ -155,8 +154,8 @@ } string url; - for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { - Client* c = *i; + for(Client::List::const_iterator i = clients.begin(); i != clients.end(); ++i) { + const Client* c = *i; if(c->getIp() == ip) { // If exact match is found, return it if(c->getPort() == port) @@ -188,15 +187,15 @@ UserIter ui = users.find(cid); if(ui != users.end()) { - if(ui->second->getFirstNick().empty()) // Could happen on bad queue loads etc... + if(ui->second->getFirstNick().empty()) ui->second->setFirstNick(aNick); ui->second->setFlag(User::NMDC); return ui->second; } - User::Ptr p(new User(aNick)); - - p->setCID(cid); + User::Ptr p(new User(cid)); + p->setFirstNick(aNick); + p->setFlag(User::NMDC); users.insert(make_pair(cid, p)); return p; @@ -214,19 +213,19 @@ return p; } -User::Ptr ClientManager::findUser(const CID& cid) throw() { +User::Ptr ClientManager::findUser(const CID& cid) const throw() { Lock l(cs); - UserIter ui = users.find(cid); + UserMap::const_iterator ui = users.find(cid); if(ui != users.end()) { return ui->second; } - return NULL; + return 0; } -bool ClientManager::isOp(const User::Ptr& user, const string& aHubUrl) { +bool ClientManager::isOp(const User::Ptr& user, const string& aHubUrl) const { Lock l(cs); - pair<OnlineIter, OnlineIter> p = onlineUsers.equal_range(user->getCID()); - for(OnlineIter i = p.first; i != p.second; ++i) { + OnlinePairC p = onlineUsers.equal_range(user->getCID()); + for(OnlineIterC i = p.first; i != p.second; ++i) { if(i->second->getClient().getHubUrl() == aHubUrl) { return i->second->getIdentity().isOp(); } @@ -234,39 +233,37 @@ return false; } -CID ClientManager::makeCid(const string& aNick, const string& aHubUrl) throw() { +CID ClientManager::makeCid(const string& aNick, const string& aHubUrl) const throw() { string n = Text::toLower(aNick); TigerHash th; th.update(n.c_str(), n.length()); th.update(Text::toLower(aHubUrl).c_str(), aHubUrl.length()); - // Construct hybrid CID from the first 64 bits of the tiger hash - should be + // Construct hybrid CID from the bits of the tiger hash - should be // fairly random, and hopefully low-collision return CID(th.finalize()); } -void ClientManager::putOnline(OnlineUser& ou) throw() { +void ClientManager::putOnline(OnlineUser* ou) throw() { { Lock l(cs); - dcassert(!ou.getUser()->getCID().isZero()); - onlineUsers.insert(make_pair(ou.getUser()->getCID(), &ou)); + onlineUsers.insert(make_pair(ou->getUser()->getCID(), ou)); } - if(!ou.getUser()->isOnline()) { - ou.getUser()->setFlag(User::ONLINE); - fire(ClientManagerListener::UserConnected(), ou.getUser()); + if(!ou->getUser()->isOnline()) { + ou->getUser()->setFlag(User::ONLINE); + fire(ClientManagerListener::UserConnected(), ou->getUser()); } } -void ClientManager::putOffline(OnlineUser& ou) throw() { +void ClientManager::putOffline(OnlineUser* ou) throw() { bool lastUser = false; { Lock l(cs); - OnlinePair op = onlineUsers.equal_range(ou.getUser()->getCID()); + OnlinePair op = onlineUsers.equal_range(ou->getUser()->getCID()); dcassert(op.first != op.second); for(OnlineIter i = op.first; i != op.second; ++i) { OnlineUser* ou2 = i->second; - /// @todo something nicer to compare with... - if(&ou.getClient() == &ou2->getClient()) { + if(ou == ou2) { lastUser = (distance(op.first, op.second) == 1); onlineUsers.erase(i); break; @@ -275,8 +272,8 @@ } if(lastUser) { - ou.getUser()->unsetFlag(User::ONLINE); - fire(ClientManagerListener::UserDisconnected(), ou.getUser()); + ou->getUser()->unsetFlag(User::ONLINE); + fire(ClientManagerListener::UserDisconnected(), ou->getUser()); } } @@ -362,7 +359,7 @@ } else { try { string ip, file; - u_int16_t port = 0; + uint16_t port = 0; Util::decodeUrl(aSeeker, ip, port, file); ip = Socket::resolve(ip); @@ -387,6 +384,7 @@ } void ClientManager::userCommand(const User::Ptr& p, const ::UserCommand& uc, StringMap& params, bool compatibility) { + Lock l(cs); OnlineIter i = onlineUsers.find(p->getCID()); if(i == onlineUsers.end()) return; @@ -435,7 +433,7 @@ users.insert(make_pair(getMe()->getCID(), getMe())); } -void ClientManager::on(TimerManagerListener::Minute, u_int32_t /* aTick */) throw() { +void ClientManager::on(TimerManagerListener::Minute, uint32_t /* aTick */) throw() { Lock l(cs); // Collect some garbage... Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ClientManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -41,14 +41,14 @@ Client* getClient(const string& aHubURL); void putClient(Client* aClient); - size_t getUserCount(); - int64_t getAvailable(); - StringList getHubs(const CID& cid); - StringList getHubNames(const CID& cid); - StringList getNicks(const CID& cid); - string getConnection(const CID& cid); + size_t getUserCount() const; + int64_t getAvailable() const; + StringList getHubs(const CID& cid) const; + StringList getHubNames(const CID& cid) const; + StringList getNicks(const CID& cid) const; + string getConnection(const CID& cid) const; - bool isConnected(const string& aUrl); + bool isConnected(const string& aUrl) const; void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken); void search(StringList& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken); @@ -57,24 +57,24 @@ User::Ptr getUser(const string& aNick, const string& aHubUrl) throw(); User::Ptr getUser(const CID& cid) throw(); - string findHub(const string& ipPort); + string findHub(const string& ipPort) const; - User::Ptr findUser(const string& aNick, const string& aHubUrl) throw() { return findUser(makeCid(aNick, aHubUrl)); } - User::Ptr findUser(const CID& cid) throw(); + User::Ptr findUser(const string& aNick, const string& aHubUrl) const throw() { return findUser(makeCid(aNick, aHubUrl)); } + User::Ptr findUser(const CID& cid) const throw(); User::Ptr findLegacyUser(const string& aNick) const throw(); - bool isOnline(const User::Ptr& aUser) { + bool isOnline(const User::Ptr& aUser) const { Lock l(cs); return onlineUsers.find(aUser->getCID()) != onlineUsers.end(); } - bool isOp(const User::Ptr& aUser, const string& aHubUrl); + bool isOp(const User::Ptr& aUser, const string& aHubUrl) const; /** Constructs a synthetic, hopefully unique CID */ - CID makeCid(const string& nick, const string& hubUrl) throw(); + CID makeCid(const string& nick, const string& hubUrl) const throw(); - void putOnline(OnlineUser& ou) throw(); - void putOffline(OnlineUser& ou) throw(); + void putOnline(OnlineUser* ou) throw(); + void putOffline(OnlineUser* ou) throw(); User::Ptr& getMe(); @@ -105,7 +105,9 @@ typedef HASH_MULTIMAP_X(CID, OnlineUser*, CID::Hash, equal_to<CID>, less<CID>) OnlineMap; typedef OnlineMap::iterator OnlineIter; + typedef OnlineMap::const_iterator OnlineIterC; typedef pair<OnlineIter, OnlineIter> OnlinePair; + typedef pair<OnlineIterC, OnlineIterC> OnlinePairC; Client::List clients; mutable CriticalSection cs; @@ -148,7 +150,7 @@ int aFileType, const string& aString) throw(); virtual void on(AdcSearch, Client* c, const AdcCommand& adc, const CID& from) throw(); // TimerManagerListener - virtual void on(TimerManagerListener::Minute, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Minute, uint32_t aTick) throw(); }; #endif // !defined(CLIENT_MANAGER_H) Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -126,7 +126,7 @@ userConnections.erase(remove(userConnections.begin(), userConnections.end(), aConn), userConnections.end()); } -void ConnectionManager::on(TimerManagerListener::Second, u_int32_t aTick) throw() { +void ConnectionManager::on(TimerManagerListener::Second, uint32_t aTick) throw() { User::List passiveUsers; ConnectionQueueItem::List removed; User::List idlers; @@ -202,7 +202,7 @@ } } -void ConnectionManager::on(TimerManagerListener::Minute, u_int32_t aTick) throw() { +void ConnectionManager::on(TimerManagerListener::Minute, uint32_t aTick) throw() { Lock l(cs); for(UserConnection::Iter j = userConnections.begin(); j != userConnections.end(); ++j) { @@ -212,8 +212,8 @@ } } -static const u_int32_t FLOOD_TRIGGER = 20000; -static const u_int32_t FLOOD_ADD = 2000; +static const uint32_t FLOOD_TRIGGER = 20000; +static const uint32_t FLOOD_ADD = 2000; ConnectionManager::Server::Server(bool secure_, short aPort, const string& ip /* = "0.0.0.0" */) : port(0), secure(secure_), die(false) { sock.create(); @@ -223,7 +223,7 @@ start(); } -static const u_int32_t POLL_TIMEOUT = 250; +static const uint32_t POLL_TIMEOUT = 250; int ConnectionManager::Server::run() throw() { try { @@ -243,7 +243,7 @@ * It's always the other fellow that starts sending if he made the connection. */ void ConnectionManager::accept(const Socket& sock, bool secure) throw() { - u_int32_t now = GET_TICK(); + uint32_t now = GET_TICK(); if(now > floodCounter) { floodCounter = now + FLOOD_ADD; Modified: dcplusplus/trunk/client/ConnectionManager.h =================================================================== --- dcplusplus/trunk/client/ConnectionManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ConnectionManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -54,7 +54,7 @@ const User::Ptr& getUser() const { return user; } GETSET(State, state, State); - GETSET(u_int32_t, lastAttempt, LastAttempt); + GETSET(uint32_t, lastAttempt, LastAttempt); GETSET(bool, download, Download); private: ConnectionQueueItem(const ConnectionQueueItem&); @@ -152,7 +152,7 @@ ExpectedMap expectedConnections; - u_int32_t floodCounter; + uint32_t floodCounter; Server* server; Server* secureServer; @@ -189,8 +189,8 @@ virtual void on(AdcCommand::STA, UserConnection*, const AdcCommand&) throw(); // TimerManagerListener - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); - virtual void on(TimerManagerListener::Minute, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Second, uint32_t aTick) throw(); + virtual void on(TimerManagerListener::Minute, uint32_t aTick) throw(); }; Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -216,7 +216,7 @@ } -void CryptoManager::decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw (CryptoException) { +void CryptoManager::decodeBZ2(const uint8_t* is, size_t sz, string& os) throw (CryptoException) { bz_stream bs = { 0 }; if(BZ2_bzDecompressInit(&bs, 0, 0) != BZ_OK) @@ -229,7 +229,7 @@ bs.avail_in = sz; bs.avail_out = bufsize; - bs.next_in = (char*)(const_cast<u_int8_t*>(is)); + bs.next_in = (char*)(const_cast<uint8_t*>(is)); bs.next_out = buf; int err; @@ -257,8 +257,8 @@ } } -string CryptoManager::keySubst(const u_int8_t* aKey, size_t len, size_t n) { - AutoArray<u_int8_t> temp(len + n * 10); +string CryptoManager::keySubst(const uint8_t* aKey, size_t len, size_t n) { + AutoArray<uint8_t> temp(len + n * 10); size_t j=0; @@ -279,32 +279,32 @@ temp[j++] = aKey[i]; } } - return string((char*)(u_int8_t*)temp, j); + return string((char*)(uint8_t*)temp, j); } string CryptoManager::makeKey(const string& aLock) { if(aLock.size() < 3) return Util::emptyString; - AutoArray<u_int8_t> temp(aLock.length()); - u_int8_t v1; + AutoArray<uint8_t> temp(aLock.length()); + uint8_t v1; size_t extra=0; - v1 = (u_int8_t)(aLock[0]^5); - v1 = (u_int8_t)(((v1 >> 4) | (v1 << 4)) & 0xff); + v1 = (uint8_t)(aLock[0]^5); + v1 = (uint8_t)(((v1 >> 4) | (v1 << 4)) & 0xff); temp[0] = v1; string::size_type i; for(i = 1; i<aLock.length(); i++) { - v1 = (u_int8_t)(aLock[i]^aLock[i-1]); - v1 = (u_int8_t)(((v1 >> 4) | (v1 << 4))&0xff); + v1 = (uint8_t)(aLock[i]^aLock[i-1]); + v1 = (uint8_t)(((v1 >> 4) | (v1 << 4))&0xff); temp[i] = v1; if(isExtra(temp[i])) extra++; } - temp[0] = (u_int8_t)(temp[0] ^ temp[aLock.length()-1]); + temp[0] = (uint8_t)(temp[0] ^ temp[aLock.length()-1]); if(isExtra(temp[0])) { extra++; Modified: dcplusplus/trunk/client/CryptoManager.h =================================================================== --- dcplusplus/trunk/client/CryptoManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/CryptoManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -44,7 +44,7 @@ const string& getPk() { return pk; } bool isExtended(const string& aLock) { return strncmp(aLock.c_str(), "EXTENDEDPROTOCOL", 16) == 0; } - void decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw(CryptoException); + void decodeBZ2(const uint8_t* is, size_t sz, string& os) throw(CryptoException); SSLSocket* getClientSocket(bool allowUntrusted) throw(SocketException); SSLSocket* getServerSocket(bool allowUntrusted) throw(SocketException); @@ -71,8 +71,8 @@ const string lock; const string pk; - string keySubst(const u_int8_t* aKey, size_t len, size_t n); - bool isExtra(u_int8_t b) { + string keySubst(const uint8_t* aKey, size_t len, size_t n); + bool isExtra(uint8_t b) { return (b == 0 || b==5 || b==124 || b==96 || b==126 || b==36); } }; Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -110,7 +110,7 @@ } } -void DownloadManager::on(TimerManagerListener::Second, u_int32_t aTick) throw() { +void DownloadManager::on(TimerManagerListener::Second, uint32_t aTick) throw() { typedef vector<pair<string, User::Ptr> > TargetList; TargetList dropTargets; @@ -130,15 +130,15 @@ // Automatically remove or disconnect slow sources - if((u_int32_t)(aTick / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { + if((uint32_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; + uint32_t timeElapsed = GET_TICK() - (*i)->getStart(); + uint32_t timeInactive = GET_TICK() - (*i)->getUserConnection().getLastActivity(); + uint64_t bytesDownloaded = (*i)->getTotal(); + bool timeElapsedOk = timeElapsed >= (uint32_t)SETTING(AUTODROP_ELAPSED) * 1000; + bool timeInactiveOk = timeInactive <= (uint32_t)SETTING(AUTODROP_INACTIVITY) * 1000; bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ? - bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; + bytesDownloaded / timeElapsed * 1000 < (uint32_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() >= ((int64_t)SETTING(AUTODROP_FILESIZE)) * 1024; @@ -211,7 +211,7 @@ virtual size_t write(const void* xbuf, size_t len) throw(Exception) { size_t pos = 0; - u_int8_t* b = (u_int8_t*)xbuf; + uint8_t* b = (uint8_t*)xbuf; while(pos < len) { size_t left = len - pos; if(bufPos == 0 && left >= TigerTree::HASH_SIZE) { @@ -236,7 +236,7 @@ } private: TigerTree& tree; - u_int8_t buf[TigerTree::HASH_SIZE]; + uint8_t buf[TigerTree::HASH_SIZE]; size_t bufPos; }; @@ -372,7 +372,7 @@ DummyOutputStream dummy; - vector<u_int8_t> buf((size_t)min((int64_t)1024*1024, tt.getBlockSize())); + vector<uint8_t> buf((size_t)min((int64_t)1024*1024, tt.getBlockSize())); do { int64_t blockPos = startPos - tt.getBlockSize(); @@ -457,7 +457,7 @@ template<bool managed> class RollbackOutputStream : public OutputStream { public: - RollbackOutputStream(File* f, OutputStream* aStream, size_t bytes) : s(aStream), pos(0), bufSize(bytes), buf(new u_int8_t[bytes]) { + RollbackOutputStream(File* f, OutputStream* aStream, size_t bytes) : s(aStream), pos(0), bufSize(bytes), buf(new uint8_t[bytes]) { size_t n = bytes; f->read(buf, n); f->movePos(-((int64_t)bytes)); @@ -472,7 +472,7 @@ if(buf != NULL) { size_t n = min(len, bufSize - pos); - u_int8_t* wb = (u_int8_t*)b; + uint8_t* wb = (uint8_t*)b; if(memcmp(buf + pos, wb, n) != 0) { throw RollbackException(STRING(ROLLBACK_INCONSISTENCY)); } @@ -489,7 +489,7 @@ OutputStream* s; size_t pos; size_t bufSize; - u_int8_t* buf; + uint8_t* buf; }; @@ -587,7 +587,7 @@ return true; } -void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const u_int8_t* aData, size_t aLen) throw() { +void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const uint8_t* aData, size_t aLen) throw() { Download* d = aSource->getDownload(); dcassert(d != NULL); @@ -648,7 +648,7 @@ } else { // Hm, if the real crc == 0, we'll get a file reread extra, but what the heck... - u_int32_t crc = 0; + uint32_t crc = 0; // First, finish writing the file (flushing the buffers and closing the file...) try { @@ -702,20 +702,20 @@ checkDownloads(aSource); } -u_int32_t DownloadManager::calcCrc32(const string& file) throw(FileException) { +uint32_t DownloadManager::calcCrc32(const string& file) throw(FileException) { File ff(file, File::READ, File::OPEN); CalcInputStream<CRC32Filter, false> f(&ff); const size_t BUF_SIZE = 1024*1024; - AutoArray<u_int8_t> b(BUF_SIZE); + AutoArray<uint8_t> b(BUF_SIZE); size_t n = BUF_SIZE; - while(f.read((u_int8_t*)b, n) > 0) + while(f.read((uint8_t*)b, n) > 0) ; // Keep on looping... return f.getFilter().getValue(); } -bool DownloadManager::checkSfv(UserConnection* aSource, Download* d, u_int32_t crc) { +bool DownloadManager::checkSfv(UserConnection* aSource, Download* d, uint32_t crc) { SFVReader sfv(d->getTarget()); if(sfv.hasCRC()) { bool crcMatch = (crc == sfv.getCRC()); Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/DownloadManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -199,7 +199,7 @@ Download::List downloads; UserConnection::List idlers; - bool checkRollback(Download* aDownload, const u_int8_t* aBuf, int aLen) throw(FileException); + bool checkRollback(Download* aDownload, const uint8_t* aBuf, int aLen) throw(FileException); void removeConnection(UserConnection::Ptr aConn); void removeDownload(Download* aDown); void fileNotAvailable(UserConnection* aSource); @@ -207,8 +207,8 @@ void moveFile(const string& source, const string&target); void logDownload(UserConnection* aSource, Download* d); - u_int32_t calcCrc32(const string& file) throw(FileException); - bool checkSfv(UserConnection* aSource, Download* d, u_int32_t crc); + uint32_t calcCrc32(const string& file) throw(FileException); + bool checkSfv(UserConnection* aSource, Download* d, uint32_t crc); int64_t getResumePos(const string& file, const TigerTree& tt, int64_t startPos); void failDownload(UserConnection* aSource, const string& reason); @@ -222,7 +222,7 @@ void handleEndData(UserConnection* aSource); // UserConnectionListener - virtual void on(Data, UserConnection*, const u_int8_t*, size_t) throw(); + virtual void on(Data, UserConnection*, const uint8_t*, size_t) throw(); virtual void on(Error, UserConnection*, const string&) throw(); virtual void on(Failed, UserConnection*, const string&) throw(); virtual void on(Sending, UserConnection*, int64_t) throw(); @@ -235,7 +235,7 @@ bool prepareFile(UserConnection* aSource, int64_t newSize, bool z); // TimerManagerListener - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Second, uint32_t aTick) throw(); }; #endif // !defined(DOWNLOAD_MANAGER_H) Modified: dcplusplus/trunk/client/Encoder.cpp =================================================================== --- dcplusplus/trunk/client/Encoder.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Encoder.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -42,16 +42,16 @@ const char Encoder::base32Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; -string& Encoder::toBase32(const u_int8_t* src, size_t len, string& dst) { +string& Encoder::toBase32(const uint8_t* src, size_t len, string& dst) { // Code snagged from the bitzi bitcollider size_t i, index; - u_int8_t word; + uint8_t word; dst.reserve(((len * 8) / 5) + 1); for(i = 0, index = 0; i < len;) { /* Is the current word going to span a byte boundary? */ if (index > 3) { - word = (u_int8_t)(src[i] & (0xFF >> index)); + word = (uint8_t)(src[i] & (0xFF >> index)); index = (index + 5) % 8; word <<= index; if ((i + 1) < len) @@ -59,7 +59,7 @@ i++; } else { - word = (u_int8_t)(src[i] >> (8 - (index + 5))) & 0x1F; + word = (uint8_t)(src[i] >> (8 - (index + 5))) & 0x1F; index = (index + 5) % 8; if (index == 0) i++; @@ -71,7 +71,7 @@ return dst; } -void Encoder::fromBase32(const char* src, u_int8_t* dst, size_t len) { +void Encoder::fromBase32(const char* src, uint8_t* dst, size_t len) { size_t i, index, offset; memset(dst, 0, len); Modified: dcplusplus/trunk/client/Encoder.h =================================================================== --- dcplusplus/trunk/client/Encoder.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Encoder.h 2006-10-08 19:59:43 UTC (rev 666) @@ -26,12 +26,12 @@ class Encoder { public: - static string& toBase32(const u_int8_t* src, size_t len, string& tgt); - static string toBase32(const u_int8_t* src, size_t len) { + static string& toBase32(const uint8_t* src, size_t len, string& tgt); + static string toBase32(const uint8_t* src, size_t len) { string tmp; return toBase32(src, len, tmp); } - static void fromBase32(const char* src, u_int8_t* dst, size_t len); + static void fromBase32(const char* src, uint8_t* dst, size_t len); private: static const int8_t base32Table[]; static const char base32Alphabet[]; Modified: dcplusplus/trunk/client/FastAlloc.h =================================================================== --- dcplusplus/trunk/client/FastAlloc.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FastAlloc.h 2006-10-08 19:59:43 UTC (rev 666) @@ -56,7 +56,7 @@ if (s != sizeof(T)) { ::operator delete(m); } else if(m != NULL) { - deallocate((u_int8_t*)m); + deallocate((uint8_t*)m); } } private: @@ -83,8 +83,8 @@ dcassert(sizeof(T) >= sizeof(void*)); // We want to grow by approximately 128kb at a time... size_t items = ((128*1024 + sizeof(T) - 1)/sizeof(T)); - freeList = new u_int8_t[sizeof(T)*items]; - u_int8_t* tmp = (u_int8_t*)freeList; + freeList = new uint8_t[sizeof(T)*items]; + uint8_t* tmp = (uint8_t*)freeList; for(size_t i = 0; i < items - 1; i++) { *(void**)tmp = tmp + sizeof(T); tmp += sizeof(T); Modified: dcplusplus/trunk/client/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/client/FavoriteManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FavoriteManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -237,7 +237,7 @@ if(listType == TYPE_BZIP2) { try { - CryptoManager::getInstance()->decodeBZ2((u_int8_t*)downloadBuf.data(), downloadBuf.size(), bzlist); + CryptoManager::getInstance()->decodeBZ2((uint8_t*)downloadBuf.data(), downloadBuf.size(), bzlist); } catch(const CryptoException&) { bzlist.clear(); } @@ -439,10 +439,10 @@ 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->setBottom((uint16_t)aXml.getIntChildAttrib("Bottom") ); + e->setTop((uint16_t)aXml.getIntChildAttrib("Top")); + e->setRight((uint16_t)aXml.getIntChildAttrib("Right")); + e->setLeft((uint16_t)aXml.getIntChildAttrib("Left")); favoriteHubs.push_back(e); } aXml.stepOut(); @@ -470,7 +470,7 @@ if(aXml.getBoolChildAttrib("GrantSlot")) i->second.setFlag(FavoriteUser::FLAG_GRANTSLOT); - i->second.setLastSeen((u_int32_t)aXml.getIntChildAttrib("LastSeen")); + i->second.setLastSeen((uint32_t)aXml.getIntChildAttrib("LastSeen")); i->second.setDescription(aXml.getChildAttrib("UserDescription")); } @@ -639,7 +639,7 @@ } // HttpConnectionListener -void FavoriteManager::on(Data, HttpConnection*, const u_int8_t* buf, size_t len) throw() { +void FavoriteManager::on(Data, HttpConnection*, const uint8_t* buf, size_t len) throw() { downloadBuf.append((const char*)buf, len); } Modified: dcplusplus/trunk/client/FavoriteManager.h =================================================================== --- dcplusplus/trunk/client/FavoriteManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FavoriteManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -98,10 +98,10 @@ GETSET(string, password, Password); GETSET(bool, connect, Connect); - GETSET(u_int16_t, bottom, Bottom); - GETSET(u_int16_t, top, Top); - GETSET(u_int16_t, left, Left); - GETSET(u_int16_t, right, Right); + GETSET(uint16_t, bottom, Bottom); + GETSET(uint16_t, top, Top); + GETSET(uint16_t, left, Left); + GETSET(uint16_t, right, Right); private: @@ -259,7 +259,7 @@ virtual void on(UserDisconnected, const User::Ptr& user) throw(); // HttpConnectionListener - virtual void on(Data, HttpConnection*, const u_int8_t*, size_t) throw(); + virtual void on(Data, HttpConnection*, const uint8_t*, size_t) throw(); virtual void on(Failed, HttpConnection*, const string&) throw(); virtual void on(Complete, HttpConnection*, const string&) throw(); virtual void on(Redirected, HttpConnection*, const string&) throw(); Modified: dcplusplus/trunk/client/FavoriteUser.h =================================================================== --- dcplusplus/trunk/client/FavoriteUser.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FavoriteUser.h 2006-10-08 19:59:43 UTC (rev 666) @@ -42,7 +42,7 @@ GETSET(User::Ptr, user, User); GETSET(string, nick, Nick); GETSET(string, url, Url); - GETSET(u_int32_t, lastSeen, LastSeen); + GETSET(uint32_t, lastSeen, LastSeen); GETSET(string, description, Description); }; Modified: dcplusplus/trunk/client/File.cpp =================================================================== --- dcplusplus/trunk/client/File.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/File.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -47,21 +47,21 @@ } } -u_int32_t File::getLastModified() throw() { +uint32_t File::getLastModified() throw() { FILETIME f = {0}; ::GetFileTime(h, NULL, NULL, &f); return convertTime(&f); } -u_int32_t File::convertTime(FILETIME* f) { +uint32_t File::convertTime(FILETIME* f) { SYSTEMTIME s = { 1970, 1, 0, 1, 0, 0, 0, 0 }; FILETIME f2 = {0}; if(::SystemTimeToFileTime(&s, &f2)) { - u_int64_t* a = (u_int64_t*)f; - u_int64_t* b = (u_int64_t*)&f2; + uint... [truncated message content] |
From: <arn...@us...> - 2006-10-07 21:51:35
|
Revision: 665 http://svn.sourceforge.net/dcplusplus/?rev=665&view=rev Author: arnetheduck Date: 2006-10-07 14:51:27 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Some more cleanup Modified Paths: -------------- dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/UploadManager.cpp Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-10-07 15:02:06 UTC (rev 664) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-07 21:51:27 UTC (rev 665) @@ -82,7 +82,7 @@ } } -string ShareManager::translateTTH(const TTHValue& tth) throw(ShareException) { +string ShareManager::toVirtual(const TTHValue& tth) throw(ShareException) { HashFileIter i = tthIndex.find(tth); if(i != tthIndex.end()) { return i->second->getADCPath(); @@ -91,7 +91,7 @@ } } -string ShareManager::translateFileName(const string& virtualFile) throw(ShareException) { +string ShareManager::toReal(const string& virtualFile) throw(ShareException) { if(virtualFile == "MyList.DcLst") { throw ShareException("NMDC-style lists no longer supported, please upgrade your client"); } else if(virtualFile == Transfer::USER_LIST_NAME_BZ || virtualFile == Transfer::USER_LIST_NAME) { @@ -109,23 +109,23 @@ } } -TTHValue ShareManager::getTTH(const string& virtualName) throw(ShareException) { +TTHValue ShareManager::getTTH(const string& virtualFile) throw(ShareException) { Lock l(cs); - string realName; + string realFile; Directory::File::Iter it; - if(!checkFile(virtualName, realName, it)) + if(!checkFile(virtualFile, realFile, it)) throw ShareException(); return it->getTTH(); } -MemoryInputStream* ShareManager::getTree(const string& aFile) { +MemoryInputStream* ShareManager::getTree(const string& virtualFile) { TigerTree tree; - if(aFile.compare(0, 4, "TTH/") == 0) { - if(!HashManager::getInstance()->getTree(TTHValue(aFile.substr(4)), tree)) + if(virtualFile.compare(0, 4, "TTH/") == 0) { + if(!HashManager::getInstance()->getTree(TTHValue(virtualFile.substr(4)), tree)) return 0; } else { try { - TTHValue tth = getTTH(aFile); + TTHValue tth = getTTH(virtualFile); HashManager::getInstance()->getTree(tth, tree); } catch(const Exception&) { return 0; @@ -191,7 +191,7 @@ bool ShareManager::checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it) { string file; if(virtualFile.compare(0, 4, "TTH/") == 0) { - file = translateTTH(TTHValue(virtualFile.substr(4))); + file = toVirtual(TTHValue(virtualFile.substr(4))); } else if(virtualFile.empty() || virtualFile[0] != '/') { return false; } else { Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-10-07 15:02:06 UTC (rev 664) +++ dcplusplus/trunk/client/ShareManager.h 2006-10-07 21:51:27 UTC (rev 665) @@ -57,9 +57,9 @@ void addDirectory(const string& aDirectory, const string & aName) throw(ShareException); void removeDirectory(const string& aName, bool duringRefresh = false); void renameDirectory(const string& oName, const string& nName) throw(ShareException); - string translateTTH(const TTHValue& tth) throw(ShareException); - string translateFileName(const string& aFile) throw(ShareException); - TTHValue getTTH(const string& aFile) throw(ShareException); + string toVirtual(const TTHValue& tth) throw(ShareException); + string toReal(const string& virtualFile) throw(ShareException); + TTHValue getTTH(const string& virtualFile) throw(ShareException); void refresh(bool dirs = false, bool aUpdate = true, bool block = false) throw(ThreadException, ShareException); void setDirty() { xmlDirty = true; } @@ -70,7 +70,7 @@ StringPairList getDirectories() const { Lock l(cs); return virtualMap; } MemoryInputStream* generatePartialList(const string& dir, bool recurse); - MemoryInputStream* getTree(const string& aFile); + MemoryInputStream* getTree(const string& virtualFile); AdcCommand getFileInfo(const string& aFile) throw(ShareException); Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-10-07 15:02:06 UTC (rev 664) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-10-07 21:51:27 UTC (rev 665) @@ -88,7 +88,7 @@ string sourceFile; try { if(aType == Transfer::TYPE_FILE) { - sourceFile = ShareManager::getInstance()->translateFileName(aFile); + sourceFile = ShareManager::getInstance()->toReal(aFile); if(aFile == Transfer::USER_LIST_NAME) { // Unpack before sending... @@ -123,7 +123,7 @@ } } } else if(aType == Transfer::TYPE_TTHL) { - sourceFile = ShareManager::getInstance()->translateFileName(aFile); + sourceFile = ShareManager::getInstance()->toReal(aFile); MemoryInputStream* mis = ShareManager::getInstance()->getTree(aFile); if(!mis) { aSource.fileNotAvail(); @@ -183,7 +183,7 @@ // Check for tth root identifier string tFile = aFile; if (tFile.compare(0, 4, "TTH/") == 0) - tFile = ShareManager::getInstance()->translateTTH(TTHValue(aFile.substr(4))); + tFile = ShareManager::getInstance()->toVirtual(TTHValue(aFile.substr(4))); addFailedUpload(aSource, tFile + " (" + Util::toString((aStartPos*1000/(size+10))/10.0)+"% of " + Util::formatBytes(size) + " done)"); @@ -474,9 +474,9 @@ if(type == Transfer::TYPE_FILE) { try { - string realFile = ShareManager::getInstance()->translateFileName(ident); + string realFile = ShareManager::getInstance()->toReal(ident); TTHValue tth = ShareManager::getInstance()->getTTH(ident); - string virtualFile = ShareManager::getInstance()->translateTTH(tth); + string virtualFile = ShareManager::getInstance()->toVirtual(tth); int64_t size = File::getSize(realFile); SearchResult* sr = new SearchResult(SearchResult::TYPE_FILE, size, virtualFile, tth); aSource->send(sr->toRES(AdcCommand::TYPE_CLIENT)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-07 15:02:29
|
Revision: 664 http://svn.sourceforge.net/dcplusplus/?rev=664&view=rev Author: arnetheduck Date: 2006-10-07 08:02:06 -0700 (Sat, 07 Oct 2006) Log Message: ----------- more cleanup Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/UploadManager.h dcplusplus/trunk/client/UserConnection.cpp dcplusplus/trunk/windows/MainFrm.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/changelog.txt 2006-10-07 15:02:06 UTC (rev 664) @@ -4,6 +4,8 @@ * More code cleanup * Fixed trusted/untrusted upload view * Fixed crash on invalid remote command during upload +* [ADC] Improved GFI command support +* Lowest priority downloads are no longer started if there are other downloads running -- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -24,7 +24,6 @@ #include "ShareManager.h" #include "SearchManager.h" #include "CryptoManager.h" -#include "ConnectionManager.h" #include "FavoriteManager.h" #include "SimpleXML.h" #include "UserCommand.h" Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -131,9 +131,6 @@ ConnectionQueueItem::List removed; User::List idlers; - bool tooMany = ((SETTING(DOWNLOAD_SLOTS) != 0) && DownloadManager::getInstance()->getDownloadCount() >= (size_t)SETTING(DOWNLOAD_SLOTS)); - bool tooFast = ((SETTING(MAX_DOWNLOAD_SPEED) != 0 && DownloadManager::getInstance()->getAverageSpeed() >= (SETTING(MAX_DOWNLOAD_SPEED)*1024))); - { Lock l(cs); @@ -161,19 +158,15 @@ if( ((cqi->getLastAttempt() + 60*1000) < aTick) && !attemptDone ) { cqi->setLastAttempt(aTick); - if(!QueueManager::getInstance()->hasDownload(cqi->getUser())) { + QueueItem::Priority prio = QueueManager::getInstance()->hasDownload(cqi->getUser()); + + if(prio == QueueItem::PAUSED) { removed.push_back(cqi); continue; } - // Always start high-priority downloads unless we have 3 more than maxdownslots already... - bool startDown = !tooMany && !tooFast; - - if(!startDown) { - bool extraFull = (SETTING(DOWNLOAD_SLOTS) != 0) && (DownloadManager::getInstance()->getDownloadCount() >= (size_t)(SETTING(DOWNLOAD_SLOTS)+3)); - startDown = !extraFull && QueueManager::getInstance()->hasDownload(cqi->getUser(), QueueItem::HIGHEST); - } - + bool startDown = DownloadManager::getInstance()->startDownload(prio); + if(cqi->getState() == ConnectionQueueItem::WAITING) { if(startDown) { cqi->setState(ConnectionQueueItem::CONNECTING); Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -22,9 +22,7 @@ #include "DownloadManager.h" #include "ResourceManager.h" -#include "ConnectionManager.h" #include "QueueManager.h" -#include "CryptoManager.h" #include "HashManager.h" #include "LogManager.h" @@ -33,7 +31,6 @@ #include "File.h" #include "FilteredFile.h" #include "MerkleCheckOutputStream.h" -#include "ClientManager.h" #include <limits> @@ -91,6 +88,12 @@ return cmd; } +void Download::getParams(const UserConnection& aSource, StringMap& params) { + Transfer::getParams(aSource, params); + params["target"] = getTarget(); + params["sfv"] = Util::toString(isSet(Download::FLAG_CRC32_OK) ? 1 : 0); +} + DownloadManager::DownloadManager() { TimerManager::getInstance()->addListener(this); } @@ -261,20 +264,36 @@ checkDownloads(conn); } -void DownloadManager::checkDownloads(UserConnection* aConn) { - dcassert(aConn->getDownload() == NULL); +bool DownloadManager::startDownload(QueueItem::Priority prio) { + size_t downloadCount = getDownloadCount(); - bool slotsFull = (SETTING(DOWNLOAD_SLOTS) != 0) && (getDownloadCount() >= (size_t)SETTING(DOWNLOAD_SLOTS)); - bool speedFull = (SETTING(MAX_DOWNLOAD_SPEED) != 0) && (getAverageSpeed() >= (SETTING(MAX_DOWNLOAD_SPEED)*1024)); + bool full = (SETTING(DOWNLOAD_SLOTS) != 0) && (downloadCount >= (size_t)SETTING(DOWNLOAD_SLOTS)); + full = full || (SETTING(MAX_DOWNLOAD_SPEED) != 0) && (getRunningAverage() >= (SETTING(MAX_DOWNLOAD_SPEED)*1024)); - if( slotsFull || speedFull ) { + if(full) { bool extraFull = (SETTING(DOWNLOAD_SLOTS) != 0) && (getDownloadCount() >= (size_t)(SETTING(DOWNLOAD_SLOTS)+3)); - if(extraFull || !QueueManager::getInstance()->hasDownload(aConn->getUser(), QueueItem::HIGHEST)) { - removeConnection(aConn); - return; + if(extraFull) { + return false; } + return prio == QueueItem::HIGHEST; } + if(downloadCount > 0) { + return prio != QueueItem::LOWEST; + } + + return true; +} + +void DownloadManager::checkDownloads(UserConnection* aConn) { + dcassert(aConn->getDownload() == NULL); + + QueueItem::Priority prio = QueueManager::getInstance()->hasDownload(aConn->getUser()); + if(!startDownload(prio)) { + removeConnection(aConn); + return; + } + Download* d = QueueManager::getInstance()->getDownload(*aConn, aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL)); if(!d) { @@ -731,10 +750,14 @@ return true; } -void Download::getParams(const UserConnection& aSource, StringMap& params) { - Transfer::getParams(aSource, params); - params["target"] = getTarget(); - params["sfv"] = Util::toString(isSet(Download::FLAG_CRC32_OK) ? 1 : 0); +int64_t DownloadManager::getRunningAverage() { + Lock l(cs); + int64_t avg = 0; + for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { + Download* d = *i; + avg += d->getRunningAverage(); + } + return avg; } void DownloadManager::logDownload(UserConnection* aSource, Download* d) { Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/DownloadManager.h 2006-10-07 15:02:06 UTC (rev 664) @@ -30,8 +30,8 @@ #include "FilteredFile.h" #include "ZUtils.h" #include "MerkleTree.h" +#include "QueueItem.h" -class QueueItem; class ConnectionQueueItem; /** @@ -67,12 +67,7 @@ virtual ~Download(); - /** - * @remarks This function is only used from DownloadManager but its - * functionality could be useful in TransferView. - * - * @return Target filename without path. - */ + /** @return Target filename without path. */ string getTargetFileName() { return Util::getFileName(getTarget()); } @@ -99,14 +94,12 @@ private: Download(const Download&); - Download& operator=(const Download&); TigerTree tt; string pfs; }; - /** * Use this listener interface to get progress information for downloads. * @@ -172,21 +165,8 @@ void addConnection(UserConnection::Ptr conn); void checkIdle(const User::Ptr& user); - /** - * @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. - * - * @return Average download speed in Bytes/s - */ - int getAverageSpeed() { - Lock l(cs); - int avg = 0; - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - Download* d = *i; - avg += (int)d->getRunningAverage(); - } - return avg; - } + /** @return Running average download speed in Bytes/s */ + int64_t getRunningAverage(); /** @return Number of downloads. */ size_t getDownloadCount() { @@ -194,6 +174,7 @@ return downloads.size(); } + bool startDownload(QueueItem::Priority prio); private: enum { MOVER_LIMIT = 10*1024*1024 }; class FileMover : public Thread { Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -613,6 +613,18 @@ return sz; } +QueueItem::Priority QueueManager::hasDownload(const User::Ptr& aUser) throw() { + Lock l(cs); + if(pfsQueue.find(aUser->getCID()) != pfsQueue.end()) { + return QueueItem::HIGHEST; + } + QueueItem* qi = userQueue.getNext(aUser, QueueItem::LOWEST); + if(!qi) { + return QueueItem::PAUSED; + } + return qi->getPriority(); +} + typedef HASH_MULTIMAP<u_int32_t, QueueItem*> SizeMap; typedef SizeMap::iterator SizeIter; typedef pair<SizeIter, SizeIter> SizePair; Modified: dcplusplus/trunk/client/QueueManager.h =================================================================== --- dcplusplus/trunk/client/QueueManager.h 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/QueueManager.h 2006-10-07 15:02:06 UTC (rev 664) @@ -106,10 +106,8 @@ Download* getDownload(UserConnection& aSource, bool supportsTrees) throw(); void putDownload(Download* aDownload, bool finished) throw(); - bool hasDownload(const User::Ptr& aUser, QueueItem::Priority minPrio = QueueItem::LOWEST) throw() { - Lock l(cs); - return (pfsQueue.find(aUser->getCID()) != pfsQueue.end()) || (userQueue.getNext(aUser, minPrio) != NULL); - } + /** @return The highest priority download the user has, PAUSED may also mean no downloads */ + QueueItem::Priority hasDownload(const User::Ptr& aUser) throw(); int countOnlineSources(const string& aTarget); Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -214,7 +214,6 @@ if(partList) u->setFlag(Upload::FLAG_PARTIAL_LIST); - dcassert(aSource.getUpload() == NULL); uploads.push_back(u); if(!aSource.isSet(UserConnection::FLAG_HASSLOT)) { @@ -238,6 +237,16 @@ return true; } +int64_t UploadManager::getRunningAverage() { + Lock l(cs); + int64_t avg = 0; + for(Upload::Iter i = uploads.begin(); i != uploads.end(); ++i) { + Upload* u = *i; + avg += (int)u->getRunningAverage(); + } + return avg; +} + bool UploadManager::getAutoSlot() { /** A 0 in settings means disable */ if(SETTING(MIN_UPLOAD_SPEED) == 0) @@ -246,7 +255,7 @@ if(GET_TICK() < getLastGrant() + 30*1000) return false; /** Grant if upload speed is less than the threshold speed */ - return getAverageSpeed() < (SETTING(MIN_UPLOAD_SPEED)*1024); + return getRunningAverage() < (SETTING(MIN_UPLOAD_SPEED)*1024); } void UploadManager::removeUpload(Upload* aUpload) { @@ -362,7 +371,7 @@ void UploadManager::addFailedUpload(const UserConnection& source, string filename) { { Lock l(cs); - if (!count_if(waitingUsers.begin(), waitingUsers.end(), UserMatch(source.getUser()))) + if (!count_if(waitingUsers.begin(), waitingUsers.end(), CompareFirst<User::Ptr, u_int32_t>(source.getUser()))) waitingUsers.push_back(WaitingUser(source.getUser(), GET_TICK())); waitingFiles[source.getUser()].insert(filename); //files for which user's asked } @@ -373,7 +382,7 @@ void UploadManager::clearUserFiles(const User::Ptr& source) { Lock l(cs); //run this when a user's got a slot or goes offline. - UserList::iterator sit = find_if(waitingUsers.begin(), waitingUsers.end(), UserMatch(source)); + UserList::iterator sit = find_if(waitingUsers.begin(), waitingUsers.end(), CompareFirst<User::Ptr, u_int32_t>(source)); if (sit == waitingUsers.end()) return; FilesMap::iterator fit = waitingFiles.find(sit->first); Modified: dcplusplus/trunk/client/UploadManager.h =================================================================== --- dcplusplus/trunk/client/UploadManager.h 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/UploadManager.h 2006-10-07 15:02:06 UTC (rev 664) @@ -86,17 +86,9 @@ * @remarks This is only used in the tray icons. Could be used in * MainFrame too. * - * @return Average download speed in Bytes/s + * @return Running average download speed in Bytes/s */ - int getAverageSpeed() { - Lock l(cs); - int avg = 0; - for(Upload::Iter i = uploads.begin(); i != uploads.end(); ++i) { - Upload* u = *i; - avg += (int)u->getRunningAverage(); - } - return avg; - } + int64_t getRunningAverage(); /** @return Number of free slots. */ int getFreeSlots() { return max((SETTING(SLOTS) - running), 0); } @@ -133,14 +125,6 @@ typedef pair<User::Ptr, u_int32_t> WaitingUser; typedef list<WaitingUser> UserList; - struct UserMatch { - UserMatch(const User::Ptr& u) : u(u) { } - const User::Ptr& u; - bool operator()(const WaitingUser& wu) { return wu.first == u; } - private: - UserMatch& operator=(const UserMatch&); - }; - struct WaitingUserFresh { bool operator()(const WaitingUser& wu) { return wu.second > GET_TICK() - 5*60*1000; } }; Modified: dcplusplus/trunk/client/UserConnection.cpp =================================================================== --- dcplusplus/trunk/client/UserConnection.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/client/UserConnection.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -53,12 +53,11 @@ void Transfer::updateRunningAverage() { u_int32_t tick = GET_TICK(); - if(tick > lastTick) { + // Update 4 times/sec at most + if(tick > (lastTick + 250)) { u_int32_t diff = tick - lastTick; int64_t tot = getTotal(); - if(diff == 0) { - // No time passed, don't update runningAverage; - } else if( ((tick - getStart()) < AVG_PERIOD) ) { + if( ((tick - getStart()) < AVG_PERIOD) ) { runningAverage = getAverageSpeed(); } else { int64_t bdiff = tot - last; Modified: dcplusplus/trunk/windows/MainFrm.cpp =================================================================== --- dcplusplus/trunk/windows/MainFrm.cpp 2006-10-06 21:18:32 UTC (rev 663) +++ dcplusplus/trunk/windows/MainFrm.cpp 2006-10-07 15:02:06 UTC (rev 664) @@ -1011,9 +1011,9 @@ nid.hWnd = m_hWnd; nid.uID = 0; nid.uFlags = NIF_TIP; - _tcsncpy(nid.szTip, Text::toT("D: " + Util::formatBytes(DownloadManager::getInstance()->getAverageSpeed()) + "/s (" + + _tcsncpy(nid.szTip, Text::toT("D: " + Util::formatBytes(DownloadManager::getInstance()->getRunningAverage()) + "/s (" + Util::toString(DownloadManager::getInstance()->getDownloadCount()) + ")\r\nU: " + - Util::formatBytes(UploadManager::getInstance()->getAverageSpeed()) + "/s (" + + Util::formatBytes(UploadManager::getInstance()->getRunningAverage()) + "/s (" + Util::toString(UploadManager::getInstance()->getUploadCount()) + ")").c_str(), 64); ::Shell_NotifyIcon(NIM_MODIFY, &nid); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-06 21:19:07
|
Revision: 663 http://svn.sourceforge.net/dcplusplus/?rev=663&view=rev Author: arnetheduck Date: 2006-10-06 14:18:32 -0700 (Fri, 06 Oct 2006) Log Message: ----------- Janitory Modified Paths: -------------- dcplusplus/trunk/Compile.txt dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/FinishedManager.cpp dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/SettingsManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/UploadManager.h dcplusplus/trunk/client/UserConnection.cpp dcplusplus/trunk/client/UserConnection.h dcplusplus/trunk/help/changelog.html dcplusplus/trunk/windows/TransferView.cpp Modified: dcplusplus/trunk/Compile.txt =================================================================== --- dcplusplus/trunk/Compile.txt 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/Compile.txt 2006-10-06 21:18:32 UTC (rev 663) @@ -43,7 +43,7 @@ Linux / Unix: I've made some rudimentary autoconf/automake scripts now, so you can compile the client part into a library without too much hassle (I don't check if it compiles very often though...). You'll need the latest versions -of automake and autoconf, and after getting the source (from CVS is easiest), do +of automake and autoconf, and after getting the source (from SVN is easiest), do "aclocal && automake && autoconf && configure && make" and you'll have the client part nicely compiled. When / if I test it I do it on a Gentoo AMD64 box with the latest gcc in 64-bit mode, so I don't have a clue if the 32-bit compile works... @@ -56,7 +56,7 @@ ugly code, abusable features, feature that I don't like that bloat the application and incompatibility with other modifications I've already done. To increase the chances of your patch being accepted, post them in the DC++ bugzilla as diffs against the latest -code you can find (in the cvs repository on sourceforge most probably). You can find a lot of +code you can find (in the SVN repository on sourceforge most probably). You can find a lot of information about diff and patch by googling for it. I like unified format (diff -u). When diffing, apply diff to the folders of the two versions, so that the paths will be included in the diff. By submitting a patch, you agree to that I get copyright of it. This to avoid stupid situations later on where Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/Example.xml 2006-10-06 21:18:32 UTC (rev 663) @@ -581,6 +581,7 @@ <String Name="UnableToCreateThread">Unable to create thread</String> <String Name="UnableToOpenFilelist">Unable to open filelist: </String> <String Name="UnableToRename">Unable to rename </String> + <String Name="UnableToSendFile">Unable to send file </String> <String Name="Unknown">Unknown</String> <String Name="UnknownAddress">Unknown address</String> <String Name="UnknownCommand">Unknown command: </String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/changelog.txt 2006-10-06 21:18:32 UTC (rev 663) @@ -1,7 +1,10 @@ -- -- * [bug 1065] Code cleanup (thanks steven sheehy) +* Fixed readme.txt (thanks ullner) +* More code cleanup +* Fixed trusted/untrusted upload view +* Fixed crash on invalid remote command during upload - -- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues * Some code cleanup Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -45,23 +45,27 @@ static const string DOWNLOAD_AREA = "Downloads"; const string Download::ANTI_FRAG_EXT = ".antifrag"; -const string DownloadManager::USER_LIST_NAME = "files.xml"; -const string DownloadManager::USER_LIST_NAME_BZ = "files.xml.bz2"; - -Download::Download() throw() : file(NULL), +Download::Download(UserConnection& conn) throw() : Transfer(conn), file(0), crcCalc(NULL), treeValid(false) { + conn.setDownload(this); } -Download::Download(QueueItem* qi) throw() : - target(qi->getTarget()), tempTarget(qi->getTempTarget()), file(NULL), - crcCalc(NULL), tth(qi->getTTH()), treeValid(false) { - - setSize(qi->getSize()); - if(qi->isSet(QueueItem::FLAG_USER_LIST)) +Download::Download(UserConnection& conn, QueueItem& qi) throw() : Transfer(conn), + target(qi.getTarget()), tempTarget(qi.getTempTarget()), file(0), + crcCalc(NULL), treeValid(false) +{ + conn.setDownload(this); + + setTTH(qi.getTTH()); + setSize(qi.getSize()); + if(qi.isSet(QueueItem::FLAG_USER_LIST)) setFlag(Download::FLAG_USER_LIST); - if(qi->isSet(QueueItem::FLAG_RESUME)) + if(qi.isSet(QueueItem::FLAG_RESUME)) setFlag(Download::FLAG_RESUME); } +Download::~Download() { + getUserConnection().setDownload(0); +} AdcCommand Download::getCommand(bool zlib) { AdcCommand cmd(AdcCommand::CMD_GET); @@ -126,7 +130,7 @@ 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_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; @@ -139,9 +143,9 @@ (filesizeOk && BOOLSETTING(AUTODROP_ALL)); if(speedTooLow && onlineSourcesOk && dropIt) { if(BOOLSETTING(AUTODROP_DISCONNECT) && !((*i)->isSet(Download::FLAG_USER_LIST))) { - (*i)->getUserConnection()->disconnect(); + (*i)->getUserConnection().disconnect(); } else { - dropTargets.push_back(make_pair((*i)->getTarget(), (*i)->getUserConnection()->getUser())); + dropTargets.push_back(make_pair((*i)->getTarget(), (*i)->getUser())); } } } @@ -271,7 +275,7 @@ } } - Download* d = QueueManager::getInstance()->getDownload(aConn->getUser(), aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL)); + Download* d = QueueManager::getInstance()->getDownload(*aConn, aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL)); if(!d) { Lock l(cs); @@ -279,9 +283,6 @@ return; } - d->setUserConnection(aConn); - aConn->setDownload(d); - aConn->setState(UserConnection::STATE_FILELENGTH); if(d->isSet(Download::FLAG_RESUME)) { @@ -323,9 +324,9 @@ if(d->isSet(Download::FLAG_USER_LIST)) { if(aConn->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST)) { - d->setSource(USER_LIST_NAME_BZ); + d->setSource(Transfer::USER_LIST_NAME_BZ); } else { - d->setSource(USER_LIST_NAME); + d->setSource(Transfer::USER_LIST_NAME); } } @@ -482,7 +483,6 @@ } if(d->getPos() >= d->getSize()) { // Already finished? - aSource->setDownload(NULL); removeDownload(d); QueueManager::getInstance()->putDownload(d, true); removeConnection(aSource); @@ -561,7 +561,7 @@ dcassert(d->getPos() != -1); d->setStart(GET_TICK()); - aSource->setState(UserConnection::STATE_DONE); + aSource->setState(UserConnection::STATE_RUNNING); fire(DownloadManagerListener::Starting(), d); @@ -598,7 +598,7 @@ /** Download finished! */ void DownloadManager::handleEndData(UserConnection* aSource) { - dcassert(aSource->getState() == UserConnection::STATE_DONE); + dcassert(aSource->getState() == UserConnection::STATE_RUNNING); Download* d = aSource->getDownload(); dcassert(d != NULL); @@ -620,7 +620,6 @@ QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_BAD_TREE, false); - aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, false); checkDownloads(aSource); @@ -680,7 +679,6 @@ removeDownload(d); fire(DownloadManagerListener::Complete(), d); - aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, true); checkDownloads(aSource); } @@ -720,7 +718,6 @@ fire(DownloadManagerListener::Failed(), d, STRING(SFV_INCONSISTENCY)); QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_CRC_WARN, false); - aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, false); checkDownloads(aSource); @@ -734,29 +731,15 @@ return true; } +void Download::getParams(const UserConnection& aSource, StringMap& params) { + Transfer::getParams(aSource, params); + params["target"] = getTarget(); + params["sfv"] = Util::toString(isSet(Download::FLAG_CRC32_OK) ? 1 : 0); +} + void DownloadManager::logDownload(UserConnection* aSource, Download* d) { StringMap params; - params["target"] = d->getTarget(); - params["userNI"] = Util::toString(ClientManager::getInstance()->getNicks(aSource->getUser()->getCID())); - params["userI4"] = aSource->getRemoteIp(); - StringList hubNames = ClientManager::getInstance()->getHubNames(aSource->getUser()->getCID()); - if(hubNames.empty()) - hubNames.push_back(STRING(OFFLINE)); - params["hub"] = Util::toString(hubNames); - StringList hubs = ClientManager::getInstance()->getHubs(aSource->getUser()->getCID()); - if(hubs.empty()) - hubs.push_back(STRING(OFFLINE)); - params["hubURL"] = Util::toString(hubs); - params["fileSI"] = Util::toString(d->getSize()); - params["fileSIshort"] = Util::formatBytes(d->getSize()); - params["fileSIchunk"] = Util::toString(d->getTotal()); - params["fileSIchunkshort"] = Util::formatBytes(d->getTotal()); - params["fileSIactual"] = Util::toString(d->getActual()); - params["fileSIactualshort"] = Util::formatBytes(d->getActual()); - params["speed"] = Util::formatBytes(d->getAverageSpeed()) + "/s"; - params["time"] = Util::formatSeconds((GET_TICK() - d->getStart()) / 1000); - params["sfv"] = Util::toString(d->isSet(Download::FLAG_CRC32_OK) ? 1 : 0); - params["fileTR"] = d->getTTH().toBase32(); + d->getParams(*aSource, params); LOG(LogManager::DOWNLOAD, params); } @@ -798,6 +781,10 @@ failDownload(aSource, STRING(NO_SLOTS_AVAILABLE)); } +void DownloadManager::on(UserConnectionListener::Error, UserConnection* aSource, const string& aError) throw() { + failDownload(aSource, aError); +} + void DownloadManager::on(UserConnectionListener::Failed, UserConnection* aSource, const string& aError) throw() { failDownload(aSource, aError); } @@ -809,7 +796,6 @@ removeDownload(d); fire(DownloadManagerListener::Failed(), d, reason); - aSource->setDownload(0); QueueManager::getInstance()->putDownload(d, false); } removeConnection(aSource); @@ -893,8 +879,6 @@ removeDownload(d); fire(DownloadManagerListener::Failed(), d, d->getTargetFileName() + ": " + STRING(FILE_NOT_AVAILABLE)); - aSource->setDownload(NULL); - QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), d->isSet(Download::FLAG_TREE_DOWNLOAD) ? QueueItem::Source::FLAG_NO_TREE : QueueItem::Source::FLAG_FILE_NOT_AVAILABLE, false); QueueManager::getInstance()->putDownload(d, false); Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/DownloadManager.h 2006-10-06 21:18:32 UTC (rev 663) @@ -60,11 +60,13 @@ FLAG_TTH_CHECK = 0x800 }; - Download() throw(); - Download(QueueItem* qi) throw(); + Download(UserConnection& conn) throw(); + Download(UserConnection& conn, QueueItem& qi) throw(); - virtual ~Download() { } + virtual void getParams(const UserConnection& aSource, StringMap& params); + virtual ~Download(); + /** * @remarks This function is only used from DownloadManager but its * functionality could be useful in TransferView. @@ -72,12 +74,7 @@ * @return Target filename without path. */ string getTargetFileName() { - string::size_type i = getTarget().rfind('\\'); - if(i != string::npos) { - return getTarget().substr(i + 1); - } else { - return getTarget(); - } + return Util::getFileName(getTarget()); } /** @internal */ @@ -98,7 +95,6 @@ GETSET(string, tempTarget, TempTarget); GETSET(OutputStream*, file, File); GETSET(CrcOS*, crcCalc, CrcCalc); - GETSET(TTHValue, tth, TTH); GETSET(bool, treeValid, TreeValid); private: @@ -198,8 +194,6 @@ return downloads.size(); } - static const string USER_LIST_NAME; - static const string USER_LIST_NAME_BZ; private: enum { MOVER_LIMIT = 10*1024*1024 }; class FileMover : public Thread { @@ -248,6 +242,7 @@ // UserConnectionListener virtual void on(Data, UserConnection*, const u_int8_t*, size_t) throw(); + virtual void on(Error, UserConnection*, const string&) throw(); virtual void on(Failed, UserConnection*, const string&) throw(); virtual void on(Sending, UserConnection*, int64_t) throw(); virtual void on(FileLength, UserConnection*, int64_t) throw(); Modified: dcplusplus/trunk/client/FinishedManager.cpp =================================================================== --- dcplusplus/trunk/client/FinishedManager.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/FinishedManager.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -66,8 +66,8 @@ { if(!d->isSet(Download::FLAG_TREE_DOWNLOAD) && (!d->isSet(Download::FLAG_USER_LIST) || BOOLSETTING(LOG_FILELIST_TRANSFERS))) { FinishedItem *item = new FinishedItem( - d->getTarget(), Util::toString(ClientManager::getInstance()->getNicks(d->getUserConnection()->getUser()->getCID())), - Util::toString(ClientManager::getInstance()->getHubNames(d->getUserConnection()->getUser()->getCID())), + d->getTarget(), Util::toString(ClientManager::getInstance()->getNicks(d->getUser()->getCID())), + Util::toString(ClientManager::getInstance()->getHubNames(d->getUser()->getCID())), d->getSize(), d->getTotal(), (GET_TICK() - d->getStart()), GET_TIME(), d->isSet(Download::FLAG_CRC32_OK)); { Lock l(cs); @@ -82,8 +82,8 @@ { if(!u->isSet(Upload::FLAG_TTH_LEAVES) && (!u->isSet(Upload::FLAG_USER_LIST) || BOOLSETTING(LOG_FILELIST_TRANSFERS))) { FinishedItem *item = new FinishedItem( - u->getLocalFileName(), Util::toString(ClientManager::getInstance()->getNicks(u->getUserConnection()->getUser()->getCID())), - Util::toString(ClientManager::getInstance()->getHubNames(u->getUserConnection()->getUser()->getCID())), + u->getSourceFile(), Util::toString(ClientManager::getInstance()->getNicks(u->getUser()->getCID())), + Util::toString(ClientManager::getInstance()->getHubNames(u->getUser()->getCID())), u->getSize(), u->getTotal(), (GET_TICK() - u->getStart()), GET_TIME()); { Lock l(cs); Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -724,13 +724,14 @@ } } -Download* QueueManager::getDownload(User::Ptr& aUser, bool supportsTrees) throw() { +Download* QueueManager::getDownload(UserConnection& aSource, bool supportsTrees) throw() { Lock l(cs); + User::Ptr& aUser = aSource.getUser(); // First check PFS's... PfsIter pi = pfsQueue.find(aUser->getCID()); if(pi != pfsQueue.end()) { - Download* d = new Download(); + Download* d = new Download(aSource); d->setFlag(Download::FLAG_PARTIAL_LIST); d->setSource(pi->second); return d; @@ -743,7 +744,7 @@ userQueue.setRunning(q, aUser); - Download* d = new Download(q); + Download* d = new Download(aSource, *q); q->setCurrentDownload(d); @@ -783,18 +784,18 @@ Lock l(cs); if(aDownload->isSet(Download::FLAG_PARTIAL_LIST)) { - pair<PfsIter, PfsIter> range = pfsQueue.equal_range(aDownload->getUserConnection()->getUser()->getCID()); + pair<PfsIter, PfsIter> range = pfsQueue.equal_range(aDownload->getUser()->getCID()); PfsIter i = find_if(range.first, range.second, CompareSecond<CID, string>(aDownload->getSource())); if(i != range.second) { pfsQueue.erase(i); - fire(QueueManagerListener::PartialList(), aDownload->getUserConnection()->getUser(), aDownload->getPFS()); + fire(QueueManagerListener::PartialList(), aDownload->getUser(), aDownload->getPFS()); } } else { QueueItem* q = fileQueue.find(aDownload->getTarget()); if(q) { if(aDownload->isSet(Download::FLAG_USER_LIST)) { - if(aDownload->getSource() == DownloadManager::USER_LIST_NAME_BZ) { + if(aDownload->getSource() == Transfer::USER_LIST_NAME_BZ) { q->setFlag(QueueItem::FLAG_XML_BZLIST); } else { q->unsetFlag(QueueItem::FLAG_XML_BZLIST); @@ -861,7 +862,6 @@ } } } - aDownload->setUserConnection(0); delete aDownload; } Modified: dcplusplus/trunk/client/QueueManager.h =================================================================== --- dcplusplus/trunk/client/QueueManager.h 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/QueueManager.h 2006-10-06 21:18:32 UTC (rev 663) @@ -103,7 +103,7 @@ QueueItem::StringMap& lockQueue() throw() { cs.enter(); return fileQueue.getQueue(); } ; void unlockQueue() throw() { cs.leave(); } - Download* getDownload(User::Ptr& aUser, bool supportsTrees) throw(); + Download* getDownload(UserConnection& aSource, bool supportsTrees) throw(); void putDownload(Download* aDownload, bool finished) throw(); bool hasDownload(const User::Ptr& aUser, QueueItem::Priority minPrio = QueueItem::LOWEST) throw() { Modified: dcplusplus/trunk/client/SettingsManager.cpp =================================================================== --- dcplusplus/trunk/client/SettingsManager.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/SettingsManager.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -152,8 +152,8 @@ setDefault(USE_OEM_MONOFONT, false); setDefault(POPUP_PMS, true); setDefault(MIN_UPLOAD_SPEED, 0); - setDefault(LOG_FORMAT_POST_DOWNLOAD, "%Y-%m-%d %H:%M: %[target]" + STRING(DOWNLOADED_FROM) + "%[userNI] (%[userCID]), %[fileSI] (%[fileSIchunk]), %[speed], %[time]"); - setDefault(LOG_FORMAT_POST_UPLOAD, "%Y-%m-%d %H:%M: %[source]" + STRING(UPLOADED_TO) + "%[userNI] (%[userCID]), %[fileSI] (%[fileSIchunk]), %[speed], %[time]"); + setDefault(LOG_FORMAT_POST_DOWNLOAD, "%Y-%m-%d %H:%M: %[target]" + STRING(DOWNLOADED_FROM) + "%[userNI] (%[userCID]), %[fileSI] (%[fileSIchunk]), %[speed], %[time], %[fileTR]"); + setDefault(LOG_FORMAT_POST_UPLOAD, "%Y-%m-%d %H:%M: %[source]" + STRING(UPLOADED_TO) + "%[userNI] (%[userCID]), %[fileSI] (%[fileSIchunk]), %[speed], %[time], %[fileTR]"); setDefault(LOG_FORMAT_MAIN_CHAT, "[%Y-%m-%d %H:%M] %[message]"); setDefault(LOG_FORMAT_PRIVATE_CHAT, "[%Y-%m-%d %H:%M] %[message]"); setDefault(LOG_FORMAT_STATUS, "[%Y-%m-%d %H:%M] %[message]"); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -82,9 +82,8 @@ } } -string ShareManager::translateTTH(const string& TTH) throw(ShareException) { - TTHValue v(TTH); - HashFileIter i = tthIndex.find(v); +string ShareManager::translateTTH(const TTHValue& tth) throw(ShareException) { + HashFileIter i = tthIndex.find(tth); if(i != tthIndex.end()) { return i->second->getADCPath(); } else { @@ -92,67 +91,64 @@ } } -string ShareManager::translateFileName(const string& aFile) throw(ShareException) { - if(aFile == "MyList.DcLst") { +string ShareManager::translateFileName(const string& virtualFile) throw(ShareException) { + if(virtualFile == "MyList.DcLst") { throw ShareException("NMDC-style lists no longer supported, please upgrade your client"); - } else if(aFile == DownloadManager::USER_LIST_NAME || aFile == DownloadManager::USER_LIST_NAME_BZ) { + } else if(virtualFile == Transfer::USER_LIST_NAME_BZ || virtualFile == Transfer::USER_LIST_NAME) { generateXmlList(); return getBZXmlFile(); } else { - if(aFile.length() < 3) - throw ShareException(UserConnection::FILE_NOT_AVAILABLE); - - string file; - + string realFile; Lock l(cs); - // Check for tth root identifier - if(aFile.compare(0, 4, "TTH/") == 0) { - file = translateTTH(aFile.substr(4)); - } else if(aFile[0] != '/') { + Directory::File::Iter it; + if(!checkFile(virtualFile, realFile, it)) { throw ShareException(UserConnection::FILE_NOT_AVAILABLE); - } else { - file = aFile; } + return realFile; + } +} - string::size_type i = file.find('/', 1); - if(i == string::npos) - throw ShareException(UserConnection::FILE_NOT_AVAILABLE); +TTHValue ShareManager::getTTH(const string& virtualName) throw(ShareException) { + Lock l(cs); + string realName; + Directory::File::Iter it; + if(!checkFile(virtualName, realName, it)) + throw ShareException(); + return it->getTTH(); +} - StringPairIter j = lookupVirtual(file.substr(1, i-1)); - if(j == virtualMap.end()) { - throw ShareException(UserConnection::FILE_NOT_AVAILABLE); +MemoryInputStream* ShareManager::getTree(const string& aFile) { + TigerTree tree; + if(aFile.compare(0, 4, "TTH/") == 0) { + if(!HashManager::getInstance()->getTree(TTHValue(aFile.substr(4)), tree)) + return 0; + } else { + try { + TTHValue tth = getTTH(aFile); + HashManager::getInstance()->getTree(tth, tree); + } catch(const Exception&) { + return 0; } - - file = file.substr(i + 1); - Directory::File::Iter it; - if(!checkFile(j->second, file, it)) { - throw ShareException(UserConnection::FILE_NOT_AVAILABLE); - } - -#ifdef _WIN32 - for(i = 0; i < file.length(); ++i) { - if(file[i] == '/') - file[i] = '\\'; - } -#endif - return j->second + file; } + + vector<u_int8_t> buf = tree.getLeafData(); + return new MemoryInputStream(&buf[0], buf.size()); } AdcCommand ShareManager::getFileInfo(const string& aFile) throw(ShareException) { - if(aFile == DownloadManager::USER_LIST_NAME) { + if(aFile == Transfer::USER_LIST_NAME) { generateXmlList(); /** todo fix size... */ AdcCommand cmd(AdcCommand::CMD_RES); - cmd.addParam("FN", DownloadManager::USER_LIST_NAME); + cmd.addParam("FN", aFile); cmd.addParam("TR", xmlRoot.toBase32()); return cmd; - } else if(aFile == DownloadManager::USER_LIST_NAME_BZ) { + } else if(aFile == Transfer::USER_LIST_NAME_BZ) { generateXmlList(); AdcCommand cmd(AdcCommand::CMD_RES); - cmd.addParam("FN", DownloadManager::USER_LIST_NAME_BZ); + cmd.addParam("FN", aFile); cmd.addParam("SI", Util::toString(File::getSize(getBZXmlFile()))); cmd.addParam("TR", xmlbzRoot.toBase32()); return cmd; @@ -176,42 +172,68 @@ return cmd; } -StringPairIter ShareManager::findVirtual(const string& name) { +StringPairIter ShareManager::findVirtual(const string& realName) { for(StringPairIter i = virtualMap.begin(); i != virtualMap. end(); ++i) { - if(Util::stricmp(name, i->second) == 0) + if(Util::stricmp(realName, i->second) == 0) return i; } return virtualMap.end(); } -StringPairIter ShareManager::lookupVirtual(const string& name) { +StringPairIter ShareManager::findReal(const string& virtualName) { for(StringPairIter i = virtualMap.begin(); i != virtualMap. end(); ++i) { - if(Util::stricmp(name, i->first) == 0) + if(Util::stricmp(virtualName, i->first) == 0) return i; } return virtualMap.end(); } -bool ShareManager::checkFile(const string& dir, const string& aFile, Directory::File::Iter& it) { - Directory::MapIter mi = directories.find(dir); +bool ShareManager::checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it) { + string file; + if(virtualFile.compare(0, 4, "TTH/") == 0) { + file = translateTTH(TTHValue(virtualFile.substr(4))); + } else if(virtualFile.empty() || virtualFile[0] != '/') { + return false; + } else { + file = virtualFile; + } + + string::size_type i = file.find('/', 1); + if(i == string::npos || i == 1) { + return false; + } + + StringPairIter k = findReal(file.substr(1, i-1)); + if(k == virtualMap.end()) { + return false; + } + + file = file.substr(i + 1); + + Directory::MapIter mi = directories.find(k->second); if(mi == directories.end()) return false; Directory* d = mi->second; - string::size_type i; string::size_type j = 0; - while( (i = aFile.find('/', j)) != string::npos) { - mi = d->directories.find(aFile.substr(j, i-j)); + while( (i = file.find('/', j)) != string::npos) { + mi = d->directories.find(file.substr(j, i-j)); j = i + 1; if(mi == d->directories.end()) return false; d = mi->second; } - it = find_if(d->files.begin(), d->files.end(), Directory::File::StringComp(aFile.substr(j))); + it = find_if(d->files.begin(), d->files.end(), Directory::File::StringComp(file.substr(j))); if(it == d->files.end()) return false; + +#ifdef _WIN32 + replace_if(file.begin(), file.end(), bind2nd(equal_to<char>(), '/'), '\\'); +#endif + + realFile = k->second + file; return true; } @@ -249,7 +271,7 @@ newVirt = validateVirtual(newVirt); // add only unique directories - if(lookupVirtual(newVirt) == virtualMap.end()) { + if(findReal(newVirt) == virtualMap.end()) { Directory* dp = new Directory(newVirt); directories[d] = dp; virtualMap.push_back(make_pair(newVirt, d)); @@ -381,7 +403,7 @@ } } - if(lookupVirtual(vName) != virtualMap.end()) { + if(findReal(vName) != virtualMap.end()) { throw ShareException(STRING(VIRTUAL_NAME_EXISTS)); } } @@ -427,13 +449,12 @@ } void ShareManager::renameDirectory(const string& oName, const string& nName) throw(ShareException) { - StringPairIter i; Lock l(cs); //Find the virtual name - i = lookupVirtual(oName); - if (lookupVirtual(nName) != virtualMap.end()) { + if (findReal(nName) != virtualMap.end()) { throw ShareException(STRING(VIRTUAL_NAME_EXISTS)); } else { + StringPairIter i = findReal(oName); // Valid newName, lets rename i->first = nName; @@ -886,7 +907,7 @@ if(first) { first = false; - StringPairIter k = lookupVirtual(dir.substr(j, i-j)); + StringPairIter k = findReal(dir.substr(j, i-j)); if(k == virtualMap.end()) return NULL; it = directories.find(k->second); @@ -911,47 +932,6 @@ return new MemoryInputStream(xml); } -bool ShareManager::getTTH(const string& aFile, TTHValue& tth) throw() { - if(aFile.length() < 3 || aFile[0] != '/') - return false; - - string::size_type i = aFile.find('/', 1); - if(i == string::npos) - return false; - - Lock l(cs); - StringPairIter j = lookupVirtual(aFile.substr(1, i-1)); - if(j == virtualMap.end()) { - return false; - } - - Directory::File::Iter it; - if(!checkFile(j->second, aFile.substr(i + 1), it)) - return false; - - tth = it->getTTH(); - return true; -} - -MemoryInputStream* ShareManager::getTree(const string& aFile) { - TigerTree tree; - if(aFile.compare(0, 4, "TTH/") == 0) { - if(!HashManager::getInstance()->getTree(TTHValue(aFile.substr(4)), tree)) - return NULL; - } else { - try { - TTHValue tth; - if(getTTH(aFile, tth)) - HashManager::getInstance()->getTree(tth, tree); - } catch(const Exception&) { - return NULL; - } - } - - vector<u_int8_t> buf = tree.getLeafData(); - return new MemoryInputStream(&buf[0], buf.size()); -} - static const string& escaper(const string& n, string& tmp) { if(SimpleXML::needsEscape(n, true, false)) { tmp.clear(); Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/ShareManager.h 2006-10-06 21:18:32 UTC (rev 663) @@ -57,9 +57,10 @@ void addDirectory(const string& aDirectory, const string & aName) throw(ShareException); void removeDirectory(const string& aName, bool duringRefresh = false); void renameDirectory(const string& oName, const string& nName) throw(ShareException); - string translateTTH(const string& TTH) throw(ShareException); + string translateTTH(const TTHValue& tth) throw(ShareException); string translateFileName(const string& aFile) throw(ShareException); - bool getTTH(const string& aFile, TTHValue& tth) throw(); + TTHValue getTTH(const string& aFile) throw(ShareException); + void refresh(bool dirs = false, bool aUpdate = true, bool block = false) throw(ThreadException, ShareException); void setDirty() { xmlDirty = true; } @@ -283,11 +284,11 @@ BloomFilter<5> bloom; /** Find virtual name from real name */ - StringPairIter findVirtual(const string& name); + StringPairIter findVirtual(const string& realName); /** Find real name from virtual name */ - StringPairIter lookupVirtual(const string& name); + StringPairIter findReal(const string& virtualName); - bool checkFile(const string& aDir, const string& aFile, Directory::File::Iter& it); + bool checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it); Directory* buildTree(const string& aName, Directory* aParent); void addTree(Directory* aDirectory); Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -582,6 +582,7 @@ "Unable to create thread", "Unable to open filelist: ", "Unable to rename ", +"Unable to send file ", "Unknown", "Unknown address", "Unknown command: ", @@ -1210,6 +1211,7 @@ "UnableToCreateThread", "UnableToOpenFilelist", "UnableToRename", +"UnableToSendFile", "Unknown", "UnknownAddress", "UnknownCommand", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/StringDefs.h 2006-10-06 21:18:32 UTC (rev 663) @@ -585,6 +585,7 @@ UNABLE_TO_CREATE_THREAD, // "Unable to create thread" UNABLE_TO_OPEN_FILELIST, // "Unable to open filelist: " UNABLE_TO_RENAME, // "Unable to rename " + UNABLE_TO_SEND_FILE, // "Unable to send file " UNKNOWN, // "Unknown" UNKNOWN_ADDRESS, // "Unknown address" UNKNOWN_COMMAND, // "Unknown command: " Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -37,6 +37,20 @@ static const string UPLOAD_AREA = "Uploads"; +Upload::Upload(UserConnection& conn) : Transfer(conn), stream(0) { + conn.setUpload(this); +} + +Upload::~Upload() { + getUserConnection().setUpload(0); + delete stream; +} + +void Upload::getParams(const UserConnection& aSource, StringMap& params) { + Transfer::getParams(aSource, params); + params["source"] = getSourceFile(); +} + UploadManager::UploadManager() throw() : running(0), extra(0), lastGrant(0) { ClientManager::getInstance()->addListener(this); TimerManager::getInstance()->addListener(this); @@ -55,153 +69,143 @@ } } -bool UploadManager::prepareFile(UserConnection* aSource, const string& aType, const string& aFile, int64_t aStartPos, int64_t aBytes, bool listRecursive) { - if(aSource->getState() != UserConnection::STATE_GET) { - dcdebug("UM:prepFile Wrong state, ignoring\n"); +bool UploadManager::prepareFile(UserConnection& aSource, const string& aType, const string& aFile, int64_t aStartPos, int64_t aBytes, bool listRecursive) { + if(aFile.empty() || aStartPos < 0 || aBytes < -1 || aBytes == 0) { + aSource.fileNotAvail("Invalid request"); return false; } - dcassert(aFile.size() > 0); - - InputStream* is = NULL; + InputStream* is = 0; + int64_t start = 0; + int64_t bytesLeft = 0; int64_t size = 0; - bool userlist = false; - bool free = false; + bool userlist = (aFile == Transfer::USER_LIST_NAME_BZ || aFile == Transfer::USER_LIST_NAME); + bool free = userlist; bool leaves = false; bool partList = false; - string file; + string sourceFile; try { - if(aType == "file") { - file = ShareManager::getInstance()->translateFileName(aFile); - userlist = (aFile == DownloadManager::USER_LIST_NAME_BZ || aFile == DownloadManager::USER_LIST_NAME); + if(aType == Transfer::TYPE_FILE) { + sourceFile = ShareManager::getInstance()->translateFileName(aFile); - try { - if(aFile == DownloadManager::USER_LIST_NAME) { - // Unpack before sending... - string bz2 = File(file, File::READ, File::OPEN).read(); - string xml; - CryptoManager::getInstance()->decodeBZ2(reinterpret_cast<const u_int8_t*>(bz2.data()), bz2.size(), xml); - // Clear to save some memory... - bz2 = string(); - is = new MemoryInputStream(xml); - aBytes = size = xml.size(); - aStartPos = 0; - free = true; - - } else { - File* f = new File(file, File::READ, File::OPEN); + if(aFile == Transfer::USER_LIST_NAME) { + // Unpack before sending... + string bz2 = File(sourceFile, File::READ, File::OPEN).read(); + string xml; + CryptoManager::getInstance()->decodeBZ2(reinterpret_cast<const u_int8_t*>(bz2.data()), bz2.size(), xml); + // Clear to save some memory... + string().swap(bz2); + is = new MemoryInputStream(xml); + start = 0; + bytesLeft = size = xml.size(); + } else { + File* f = new File(sourceFile, File::READ, File::OPEN); - size = f->getSize(); + start = aStartPos; + size = f->getSize(); + bytesLeft = (aBytes == -1) ? size : aBytes; - free = userlist || (size <= (int64_t)(SETTING(SET_MINISLOT_SIZE) * 1024) ); + if(size < (start + bytesLeft)) { + aSource.fileNotAvail(); + delete f; + return false; + } - if(aBytes == -1) { - aBytes = size - aStartPos; - } + free = (size <= (int64_t)(SETTING(SET_MINISLOT_SIZE) * 1024) ); - if((aBytes < 0) || ((aStartPos + aBytes) > size)) { - aSource->fileNotAvail(); - delete f; - return false; - } + f->setPos(start); - f->setPos(aStartPos); - - is = f; - - if((aStartPos + aBytes) < size) { - is = new LimitedInputStream<true>(is, aBytes); - } + is = f; + if((start + bytesLeft) < size) { + is = new LimitedInputStream<true>(is, aBytes); } - } catch(const Exception&) { - aSource->fileNotAvail(); - return false; } - - } else if(aType == "tthl") { - // TTH Leaves... + } else if(aType == Transfer::TYPE_TTHL) { + sourceFile = ShareManager::getInstance()->translateFileName(aFile); MemoryInputStream* mis = ShareManager::getInstance()->getTree(aFile); - file = ShareManager::getInstance()->translateFileName(aFile); - if(mis == NULL) { - aSource->fileNotAvail(); + if(!mis) { + aSource.fileNotAvail(); return false; } - size = mis->getSize(); - aStartPos = 0; + start = 0; + bytesLeft = size = mis->getSize(); is = mis; leaves = true; free = true; - } else if(aType == "list") { + } else if(aType == Transfer::TYPE_LIST) { // Partial file list MemoryInputStream* mis = ShareManager::getInstance()->generatePartialList(aFile, listRecursive); if(mis == NULL) { - aSource->fileNotAvail(); + aSource.fileNotAvail(); return false; } // Some old dc++ clients err here... aBytes = -1; - size = mis->getSize(); - aStartPos = 0; + start = 0; + bytesLeft = size = mis->getSize(); + is = mis; free = true; partList = true; } else { - aSource->fileNotAvail(); + aSource.fileNotAvail("Unknown file type"); return false; } } catch(const ShareException& e) { - aSource->fileNotAvail(e.getError()); + aSource.fileNotAvail(e.getError()); return false; + } catch(const Exception& e) { + LogManager::getInstance()->message(STRING(UNABLE_TO_SEND_FILE) + sourceFile + ": " + e.getError()); + aSource.fileNotAvail(); + return false; } Lock l(cs); bool extraSlot = false; - if(!aSource->isSet(UserConnection::FLAG_HASSLOT)) { - bool hasReserved = (reservedSlots.find(aSource->getUser()) != reservedSlots.end()); - bool isFavorite = FavoriteManager::getInstance()->hasSlot(aSource->getUser()); + if(!aSource.isSet(UserConnection::FLAG_HASSLOT)) { + bool hasReserved = (reservedSlots.find(aSource.getUser()) != reservedSlots.end()); + bool isFavorite = FavoriteManager::getInstance()->hasSlot(aSource.getUser()); if(!(hasReserved || isFavorite || getFreeSlots() > 0 || getAutoSlot())) { - bool supportsFree = aSource->isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS); - bool allowedFree = aSource->isSet(UserConnection::FLAG_HASEXTRASLOT) || aSource->isSet(UserConnection::FLAG_OP) || getFreeExtraSlots() > 0; + bool supportsFree = aSource.isSet(UserConnection::FLAG_SUPPORTS_MINISLOTS); + bool allowedFree = aSource.isSet(UserConnection::FLAG_HASEXTRASLOT) || aSource.isSet(UserConnection::FLAG_OP) || getFreeExtraSlots() > 0; if(free && supportsFree && allowedFree) { extraSlot = true; } else { delete is; - aSource->maxedOut(); + aSource.maxedOut(); // Check for tth root identifier string tFile = aFile; if (tFile.compare(0, 4, "TTH/") == 0) - tFile = ShareManager::getInstance()->translateTTH(aFile.substr(4)); + tFile = ShareManager::getInstance()->translateTTH(TTHValue(aFile.substr(4))); addFailedUpload(aSource, tFile + - " (" + Util::toString((aStartPos*1000/(File::getSize(file)+10))/10.0)+"% of " + Util::formatBytes(File::getSize(file)) + " done)"); - aSource->disconnect(); + " (" + Util::toString((aStartPos*1000/(size+10))/10.0)+"% of " + Util::formatBytes(size) + " done)"); + aSource.disconnect(); return false; } } else { - clearUserFiles(aSource->getUser()); // this user is using a full slot, nix them. + clearUserFiles(aSource.getUser()); // this user is using a full slot, nix them. } setLastGrant(GET_TICK()); } - Upload* u = new Upload(); - u->setUserConnection(aSource); - u->setFile(is); + Upload* u = new Upload(aSource); + u->setStream(is); if(aBytes == -1) u->setSize(size); else - u->setSize(aStartPos + aBytes); + u->setSize(start + bytesLeft); - u->setStartPos(aStartPos); - u->setFileName(file); - u->setLocalFileName(file); + u->setStartPos(start); + u->setSourceFile(sourceFile); if(userlist) u->setFlag(Upload::FLAG_USER_LIST); @@ -210,36 +214,45 @@ if(partList) u->setFlag(Upload::FLAG_PARTIAL_LIST); - dcassert(aSource->getUpload() == NULL); - aSource->setUpload(u); + dcassert(aSource.getUpload() == NULL); uploads.push_back(u); - if(!aSource->isSet(UserConnection::FLAG_HASSLOT)) { + if(!aSource.isSet(UserConnection::FLAG_HASSLOT)) { if(extraSlot) { - if(!aSource->isSet(UserConnection::FLAG_HASEXTRASLOT)) { - aSource->setFlag(UserConnection::FLAG_HASEXTRASLOT); + if(!aSource.isSet(UserConnection::FLAG_HASEXTRASLOT)) { + aSource.setFlag(UserConnection::FLAG_HASEXTRASLOT); extra++; } } else { - if(aSource->isSet(UserConnection::FLAG_HASEXTRASLOT)) { - aSource->unsetFlag(UserConnection::FLAG_HASEXTRASLOT); + if(aSource.isSet(UserConnection::FLAG_HASEXTRASLOT)) { + aSource.unsetFlag(UserConnection::FLAG_HASEXTRASLOT); extra--; } - aSource->setFlag(UserConnection::FLAG_HASSLOT); + aSource.setFlag(UserConnection::FLAG_HASSLOT); running++; } - reservedSlots.erase(aSource->getUser()); + reservedSlots.erase(aSource.getUser()); } return true; } +bool UploadManager::getAutoSlot() { + /** A 0 in settings means disable */ + if(SETTING(MIN_UPLOAD_SPEED) == 0) + return false; + /** Only grant one slot per 30 sec */ + if(GET_TICK() < getLastGrant() + 30*1000) + return false; + /** Grant if upload speed is less than the threshold speed */ + return getAverageSpeed() < (SETTING(MIN_UPLOAD_SPEED)*1024); +} + void UploadManager::removeUpload(Upload* aUpload) { Lock l(cs); dcassert(find(uploads.begin(), uploads.end(), aUpload) != uploads.end()); uploads.erase(remove(uploads.begin(), uploads.end(), aUpload), uploads.end()); - aUpload->setUserConnection(NULL); delete aUpload; } @@ -253,7 +266,12 @@ } void UploadManager::on(UserConnectionListener::Get, UserConnection* aSource, const string& aFile, int64_t aResume) throw() { - if(prepareFile(aSource, "file", Util::toAdcFile(aFile), aResume, -1)) { + if(aSource->getState() != UserConnection::STATE_GET) { + dcdebug("UM::onGet Bad state, ignoring\n"); + return; + } + + if(prepareFile(*aSource, Transfer::TYPE_FILE, Util::toAdcFile(aFile), aResume, -1)) { aSource->setState(UserConnection::STATE_SEND); aSource->fileLength(Util::toString(aSource->getUpload()->getSize())); } @@ -269,13 +287,43 @@ dcassert(u != NULL); u->setStart(GET_TICK()); - aSource->setState(UserConnection::STATE_DONE); - aSource->transmitFile(u->getFile()); + aSource->setState(UserConnection::STATE_RUNNING); + aSource->transmitFile(u->getStream()); fire(UploadManagerListener::Starting(), u); } +void UploadManager::on(AdcCommand::GET, UserConnection* aSource, const AdcCommand& c) throw() { + int64_t aBytes = Util::toInt64(c.getParam(3)); + int64_t aStartPos = Util::toInt64(c.getParam(2)); + const string& fname = c.getParam(1); + const string& type = c.getParam(0); + + if(prepareFile(*aSource, type, fname, aStartPos, aBytes, c.hasFlag("RE", 4))) { + Upload* u = aSource->getUpload(); + dcassert(u != NULL); + + AdcCommand cmd(AdcCommand::CMD_SND); + cmd.addParam(type).addParam(fname) + .addParam(Util::toString(u->getPos())) + .addParam(Util::toString(u->getSize() - u->getPos())); + + if(c.hasFlag("ZL", 4)) { + u->setStream(new FilteredInputStream<ZFilter, true>(u->getStream())); + u->setFlag(Upload::FLAG_ZUPLOAD); + cmd.addParam("ZL1"); + } + + aSource->send(cmd); + + u->setStart(GET_TICK()); + aSource->setState(UserConnection::STATE_RUNNING); + aSource->transmitFile(u->getStream()); + fire(UploadManagerListener::Starting(), u); + } +} + void UploadManager::on(UserConnectionListener::BytesSent, UserConnection* aSource, size_t aBytes, size_t aActual) throw() { - dcassert(aSource->getState() == UserConnection::STATE_DONE); + dcassert(aSource->getState() == UserConnection::STATE_RUNNING); Upload* u = aSource->getUpload(); dcassert(u != NULL); u->addPos(aBytes, aActual); @@ -285,7 +333,6 @@ Upload* u = aSource->getUpload(); if(u) { - aSource->setUpload(NULL); fire(UploadManagerListener::Failed(), u, aError); dcdebug("UM::onFailed: Removing upload\n"); @@ -296,35 +343,15 @@ } void UploadManager::on(UserConnectionListener::TransmitDone, UserConnection* aSource) throw() { - dcassert(aSource->getState() == UserConnection::STATE_DONE); + dcassert(aSource->getState() == UserConnection::STATE_RUNNING); Upload* u = aSource->getUpload(); dcassert(u != NULL); - aSource->setUpload(NULL); aSource->setState(UserConnection::STATE_GET); if(BOOLSETTING(LOG_UPLOADS) && !u->isSet(Upload::FLAG_TTH_LEAVES) && (BOOLSETTING(LOG_FILELIST_TRANSFERS) || !u->isSet(Upload::FLAG_USER_LIST))) { StringMap params; - params["source"] = u->getFileName(); - params["userNI"] = Util::toString(ClientManager::getInstance()->getNicks(aSource->getUser()->getCID())); - params["userI4"] = aSource->getRemoteIp(); - StringList hubNames = ClientManager::getInstance()->getHubNames(aSource->getUser()->getCID()); - if(hubNames.empty()) - hubNames.push_back(STRING(OFFLINE)); - params["hub"] = Util::toString(hubNames); - StringList hubs = ClientManager::getInstance()->getHubs(aSource->getUser()->getCID()); - if(hubs.empty()) - hubs.push_back(STRING(OFFLINE)); - params["hubURL"] = Util::toString(hubs); - params["fileSI"] = Util::toString(u->getSize()); - params["fileSIshort"] = Util::formatBytes(u->getSize()); - params["fileSIchunk"] = Util::toString(u->getTotal()); - params["fileSIchunkshort"] = Util::formatBytes(u->getTotal()); - params["fileSIactual"] = Util::toString(u->getActual()); - params["fileSIactualshort"] = Util::formatBytes(u->getActual()); - params["speed"] = Util::formatBytes(u->getAverageSpeed()) + "/s"; - params["time"] = Util::formatSeconds((GET_TICK() - u->getStart()) / 1000); - params["tth"] = u->getTTH().toBase32(); + u->getParams(*aSource, params); LOG(LogManager::UPLOAD, params); } @@ -332,15 +359,15 @@ removeUpload(u); } -void UploadManager::addFailedUpload(UserConnection::Ptr source, string filename) { +void UploadManager::addFailedUpload(const UserConnection& source, string filename) { { Lock l(cs); - if (!count_if(waitingUsers.begin(), waitingUsers.end(), UserMatch(source->getUser()))) - waitingUsers.push_back(WaitingUser(source->getUser(), GET_TICK())); - waitingFiles[source->getUser()].insert(filename); //files for which user's asked + if (!count_if(waitingUsers.begin(), waitingUsers.end(), UserMatch(source.getUser()))) + waitingUsers.push_back(WaitingUser(source.getUser(), GET_TICK())); + waitingFiles[source.getUser()].insert(filename); //files for which user's asked } - fire(UploadManagerListener::WaitingAddFile(), source->getUser(), filename); + fire(UploadManagerListener::WaitingAddFile(), source.getUser(), filename); } void UploadManager::clearUserFiles(const User::Ptr& source) { @@ -368,94 +395,65 @@ return waitingFiles.find(u)->second; } -void UploadManager::removeConnection(UserConnection::Ptr aConn) { - dcassert(aConn->getUpload() == NULL); - aConn->removeListener(this); - if(aConn->isSet(UserConnection::FLAG_HASSLOT)) { +void UploadManager::removeConnection(UserConnection* aSource) { + dcassert(aSource->getUpload() == NULL); + aSource->removeListener(this); + if(aSource->isSet(UserConnection::FLAG_HASSLOT)) { running--; - aConn->unsetFlag(UserConnection::FLAG_HASSLOT); + aSource->unsetFlag(UserConnection::FLAG_HASSLOT); } - if(aConn->isSet(UserConnection::FLAG_HASEXTRASLOT)) { + if(aSource->isSet(UserConnection::FLAG_HASEXTRASLOT)) { extra--; - aConn->unsetFlag(UserConnection::FLAG_HASEXTRASLOT); + aSource->unsetFlag(UserConnection::FLAG_HASEXTRASLOT); } } void UploadManager::on(TimerManagerListener::Minute, u_int32_t /* aTick */) throw() { - Lock l(cs); + User::List disconnects; + { + Lock l(cs); - UserList::iterator i = stable_partition(waitingUsers.begin(), waitingUsers.end(), WaitingUserFresh()); - for (UserList::iterator j = i; j != waitingUsers.end(); ++j) { - FilesMap::iterator fit = waitingFiles.find(j->first); - if (fit != waitingFiles.end()) waitingFiles.erase(fit); - fire(UploadManagerListener::WaitingRemoveUser(), j->first); - } + UserList::iterator i = stable_partition(waitingUsers.begin(), waitingUsers.end(), WaitingUserFresh()); + for (UserList::iterator j = i; j != waitingUsers.end(); ++j) { + FilesMap::iterator fit = waitingFiles.find(j->first); + if (fit != waitingFiles.end()) waitingFiles.erase(fit); + fire(UploadManagerListener::WaitingRemoveUser(), j->first); + } - waitingUsers.erase(i, waitingUsers.end()); + 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( 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(u->isSet(Upload::FLAG_PENDING_KICK)) { + disconnects.push_back(u->getUser()); + continue; + } - if(BOOLSETTING(AUTO_KICK_NO_FAVS) && FavoriteManager::getInstance()->isFavoriteUser(u->getUser())) { - continue; - } + if(BOOLSETTING(AUTO_KICK_NO_FAVS) && FavoriteManager::getInstance()->isFavoriteUser(u->getUser())) { + continue; + } - u->setFlag(Upload::FLAG_PENDING_KICK); + u->setFlag(Upload::FLAG_PENDING_KICK); + } } } + for(User::Iter i = disconnects.begin(); i != disconnects.end(); ++i) { + LogManager::getInstance()->message(STRING(DISCONNECTED_USER) + Util::toString(ClientManager::getInstance()->getNicks((*i)->getCID()))); + ConnectionManager::getInstance()->disconnect(*i, false); + } } void UploadManager::on(GetListLength, UserConnection* conn) throw() { conn->listLen("42"); } -void UploadManager::on(AdcCommand::GET, UserConnection* aSource, const AdcCommand& c) throw() { - int64_t aBytes = Util::toInt64(c.getParam(3)); - int64_t aStartPos = Util::toInt64(c.getParam(2)); - const string& fname = c.getParam(1); - const string& type = c.getParam(0); - string tmp; - - if(prepareFile(aSource, type, fname, aStartPos, aBytes, c.hasFlag("RE", 4))) { - Upload* u = aSource->getUpload(); - dcassert(u != NULL); - if(aBytes == -1) - aBytes = u->getSize() - aStartPos; - - dcassert(aBytes >= 0); - - u->setStart(GET_TICK()); - - AdcCommand cmd(AdcCommand::CMD_SND); - cmd.addParam(c.getParam(0)); - cmd.addParam(c.getParam(1)); - cmd.addParam(Util::toString(u->getPos())); - cmd.addParam(Util::toString(u->getSize() - u->getPos())); - - if(c.hasFlag("ZL", 4)) { - u->setFile(new FilteredInputStream<ZFilter, true>(u->getFile())); - u->setFlag(Upload::FLAG_ZUPLOAD); - cmd.addParam("ZL1"); - } - - aSource->send(cmd); - aSource->setState(UserConnection::STATE_DONE); - aSource->transmitFile(u->getFile()); - fire(UploadManagerListener::Starting(), u); - } -} - void UploadManager::on(AdcCommand::GFI, UserConnection* aSource, const AdcCommand& c) throw() { if(c.getParameters().size() < 2) { aSource->send(AdcCommand(AdcCommand::SEV_RECOVERABLE, AdcCommand::ERROR_PROTOCOL_GENERIC, "Missing parameters")); @@ -465,22 +463,20 @@ const string& type = c.getParam(0); const string& ident = c.getParam(1); - if(type == "file") { - SearchResult::List l; - StringList sl; - - if(ident.compare(0, 4, "TTH/") != 0) { - aSource->send(AdcCommand(AdcCommand::SEV_RECOVERABLE, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid identifier")); - return; + if(type == Transfer::TYPE_FILE) { + try { + string realFile = ShareManager::getInstance()->translateFileName(ident); + TTHValue tth = ShareManager::getInstance()->getTTH(ident); + string virtualFile = ShareManager::getInstance()->translateTTH(tth); + int64_t size = File::getSize(realFile); + SearchResult* sr = new SearchResult(SearchResult::TYPE_FILE, size, virtualFile, tth); + aSource->send(sr->toRES(AdcCommand::TYPE_CLIENT)); + sr->decRef(); + } catch(const ShareException&) { + aSource->fileNotAvail(); } - sl.push_back("TH" + ident.substr(4)); - ShareManager::getInstance()->search(l, sl, 1); - if(l.empty()) { - aSource->send(AdcCommand(AdcCommand::SEV_RECOVERABLE, AdcCommand::ERROR_FILE_NOT_AVAILABLE, "Not found")); - } else { - aSource->send(l[0]->toRES(AdcCommand::TYPE_CLIENT)); - l[0]->decRef(); - } + } else { + aSource->fileNotAvail(); } } Modified: dcplusplus/trunk/client/UploadManager.h =================================================================== --- dcplusplus/trunk/client/UploadManager.h 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/UploadManager.h 2006-10-06 21:18:32 UTC (rev 663) @@ -27,9 +27,10 @@ #include "Singleton.h" #include "ClientManagerListener.h" -#include "File.h" #include "MerkleTree.h" +class InputStream; + class Upload : public Transfer, public Flags { public: enum Flags { @@ -44,17 +45,13 @@ typedef vector<Ptr> List; typedef List::iterator Iter; - Upload() : file(0) { } - virtual ~Upload() { - delete file; - } + Upload(UserConnection& conn); + virtual ~Upload(); - User::Ptr& getUser() { dcassert(getUserConnection() != NULL); return getUserConnection()->getUser(); } + virtual void getParams(const UserConnection& aSource, StringMap& params); - GETSET(string, fileName, FileName); - GETSET(string, localFileName, LocalFileName); - GETSET(TTHValue, tth, TTH); - GETSET(InputStream*, file, File); + GETSET(string, sourceFile, SourceFile); + GETSET(InputStream*, stream, Stream); }; class UploadManagerListener { @@ -105,18 +102,6 @@ int getFreeSlots() { return max((SETTING(SLOTS) - running), 0); } /** @internal */ - bool getAutoSlot() { - /** A 0 in settings means disable */ - if(SETTING(MIN_UPLOAD_SPEED) == 0) - return false; - /** Only grant one slot per 30 sec */ - if(GET_TICK() < getLastGrant() + 30*1000) - return false; - /** Grant if upload speed is less than the threshold speed */ - return getAverageSpeed() < (SETTING(MIN_UPLOAD_SPEED)*1024); - } - - /** @internal */ int getFreeExtraSlots() { return max(3 - getExtra(), 0); } /** @param aUser Reserve an upload slot for this user and connect. */ @@ -163,13 +148,14 @@ //functions for manipulating waitingFiles and waitingUsers UserList waitingUsers; //this one merely lists the users waiting for slots FilesMap waitingFiles; //set of files which this user has asked for - void addFailedUpload(UserConnection::Ptr source, string filename); + void addFailedUpload(const UserConnection& source, string filename); friend class Singleton<UploadManager>; UploadManager() throw(); virtual ~UploadManager() throw(); - void removeConnection(UserConnection::Ptr aConn); + bool getAutoSlot(); + void removeConnection(UserConnection* aConn); void removeUpload(Upload* aUpload); // ClientManagerListener @@ -190,7 +176,7 @@ virtual void on(AdcCommand::GET, UserConnection*, const AdcCommand&) throw(); virtual void on(AdcCommand::GFI, UserConnection*, const AdcCommand&) throw(); - bool prepareFile(UserConnection* aSource, const string& aType, const string& aFile, int64_t aResume, int64_t aBytes, bool listRecursive = false); + bool prepareFile(UserConnection& aSource, const string& aType, const string& aFile, int64_t aResume, int64_t aBytes, bool listRecursive = false); }; #endif // !defined(UPLOAD_MANAGER_H) Modified: dcplusplus/trunk/client/UserConnection.cpp =================================================================== --- dcplusplus/trunk/client/UserConnection.cpp 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/UserConnection.cpp 2006-10-06 21:18:32 UTC (rev 663) @@ -21,6 +21,7 @@ #include "UserConnection.h" #include "ClientManager.h" +#include "ResourceManager.h" #include "StringTokenizer.h" #include "AdcCommand.h" @@ -37,9 +38,19 @@ const string UserConnection::FILE_NOT_AVAILABLE = "File Not Available"; +const string Transfer::TYPE_FILE = "file"; +const string Transfer::TYPE_LIST = "list"; +const string Transfer::TYPE_TTHL = "tthl"; + +const string Transfer::USER_LIST_NAME = "files.xml"; +const string Transfer::USER_LIST_NAME_BZ = "files.xml.bz2"; + const string UserConnection::UPLOAD = "Upload"; const string UserConnection::DOWNLOAD = "Download"; +Transfer::Transfer(UserConnection& conn) : start(0), lastTick(GET_TICK()), runningAverage(0), +last(0), actual(0), pos(0), startPos(0), size(-1), userConnection(conn) { } + void Transfer::updateRunningAverage() { u_int32_t tick = GET_TICK(); if(tick > lastTick) { @@ -64,6 +75,32 @@ lastTick = tick; } +void Transfer::getParams(const UserConnection& aSource, StringMap& params) { + params["userNI"] = Util::toString(ClientManager::getInstance()->getNicks(aSource.getUser()->getCID())); + params["userI4"] = aSource.getRemoteIp(); + StringList hubNames = ClientManager::getInstance()->getHubNames(aSource.getUser()->getCID()); + if(hubNames.empty()) + hubNames.push_back(STRING(OFFLINE)); + params["hub"] = Util::toString(hubNames); + StringList hubs = ClientManager::getInstance()->getHubs(aSource.getUser()->getCID()); + if(hubs.empty()) + hubs.push_back(STRING(OFFLINE)); + params["hubURL"] = Util::toString(hubs); + params["fileSI"] = Util::toString(getSize()); + params["fileSIshort"] = Util::formatBytes(getSize()); + params["fileSIchunk"] = Util::toString(getTotal()); + params["fileSIchunkshort"] = Util::formatBytes(getTotal()); + params["fileSIactual"] = Util::toString(getActual()); + params["fileSIactualshort"] = Util::formatBytes(getActual()); + params["speed"] = Util::formatBytes(getAverageSpeed()) + "/s"; + params["time"] = Util::formatSeconds((GET_TICK() - getStart()) / 1000); + params["fileTR"] = getTTH().toBase32(); +} + +User::Ptr Transfer::getUser() { + return getUserConnection().getUser(); +} + void UserConnection::on(BufferedSocketListener::Line, const string& aLine) throw () { if(aLine.length() < 2) Modified: dcplusplus/trunk/client/UserConnection.h =================================================================== --- dcplusplus/trunk/client/UserConnection.h 2006-09-29 16:24:13 UTC (rev 662) +++ dcplusplus/trunk/client/UserConnection.h 2006-10-06 21:18:32 UTC (rev 663) @@ -30,6 +30,7 @@ #include "File.h" #include "User.h" #include "AdcCommand.h" +#include "MerkleTree.h" class UserConnection; @@ -46,6 +47,7 @@ typedef X<5> Key; typedef X<6> Direction; typedef X<7> Get; + typedef X<8> Error; typedef X<10> Sending; typedef X<11> FileLength; typedef X<12> Send; @@ -63,6 +65,7 @@ virtual void on(BytesSent, UserConnection*, size_t, size_t) throw() { } virtual void on(Connected, UserConnection*) throw() { } virtual void on(Data, UserConnection*, const u_int8_t*, size_t) throw() { } + virtual void on(Error, UserConnection*, const string&) throw() { } virtual void on(Failed, UserConnection*, const string&) throw() { } virtual void on(CLock, UserConnection*, const string&, const string&) throw() { } virtual void on(Key, UserConnection*, const string&) throw() { } @@ -92,10 +95,16 @@ class Transfer { public: - Transfer() : userConnection(NULL), start(0), lastTick(GET_TICK()), runningAverage(0), - last(0), actual(0), pos(0), startPos(0), size(-1) { } - virtual ~Transfer() { } + static const string TYPE_FILE; ///< File transfer + static const string TYPE_LIST; ///< Partial file list + static const string TYPE_TTHL; ///< TTH Leaves + static const string USER_LIST_NAME; + static const string USER_LIST_NAME_BZ; + + Transfer(UserConnection& conn); + virtual ~Transfer() { }; + int64_t getPos() const { return pos; } void setPos(int64_t aPos) { pos = aPos; } @@ -113,7 +122,6 @@ int64_t getSize() const { return size; } void setSize(int64_t aSize) { size = aSize; } - void setSize(const string& aSize) { setSize(Util::toInt64(aSize)); } int64_t getAverageSpeed() const { int64_t diff = (int64_t)(GET_TICK() - getStart()); @@ -130,10 +138,17 @@ return getSize() - getPos(); } - GETSET(UserConnection*, userConnection, UserConnection); + virtual void getParams(const UserConnection& aSource, StringMap& params); + + User::Ptr getUser(); + + UserConnection& getUserConnection() { return userConnection; } + const UserConnection& getUserConnection() const { return userConnection; } + GETSET(u_int32_t, start, Start); GETSET(u_int32_t, lastTick, LastTick); GETSET(int64_t, runningAverage, RunningAverage); + GETSET(TTHValue, tth, TTH); private: Transfer(const Transfer&); Transfer& operator=(const Transfer&); @@ -149,6 +164,7 @@ /** Target size of this transfer */ int64_t size; + UserConnection& userConnection; }; class ServerSocket; @@ -214,9 +230,10 @@ STATE_KEY, // UploadManager - STATE_GET, - STATE_SEND, - STATE_DONE, + STATE_GET, // Waiting for GET + STATE_SEND, // Waiting for $Send + STATE_RUNNING, // Transmitting data + // DownloadManager STATE_FILELENGTH, STATE_TREE @@ -273,6 +290,7 @@ return isSet(FLAG_UPLOAD) ? UPLOAD : DOWNLOAD; } + const User::Ptr& getUser() const { return user... [truncated message content] |
From: <arn...@us...> - 2006-10-04 01:47:41
|
Revision: 662 http://svn.sourceforge.net/dcplusplus/?rev=662&view=rev Author: arnetheduck Date: 2006-09-29 09:24:13 -0700 (Fri, 29 Sep 2006) Log Message: ----------- file patch Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/File.cpp dcplusplus/trunk/client/File.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-29 16:05:42 UTC (rev 661) +++ dcplusplus/trunk/changelog.txt 2006-09-29 16:24:13 UTC (rev 662) @@ -1,4 +1,8 @@ -- -- +* [bug 1065] Code cleanup (thanks steven sheehy) + + +-- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues * Some code cleanup * Queue frame fixes and memory saves Modified: dcplusplus/trunk/client/File.cpp =================================================================== --- dcplusplus/trunk/client/File.cpp 2006-09-29 16:05:42 UTC (rev 661) +++ dcplusplus/trunk/client/File.cpp 2006-09-29 16:24:13 UTC (rev 662) @@ -66,6 +66,10 @@ return 0; } +bool File::isOpen() throw() { + return h != INVALID_HANDLE_VALUE; +} + void File::close() throw() { if(isOpen()) { CloseHandle(h); @@ -133,7 +137,7 @@ } } -size_t File::flush() throw(Exception) { +size_t File::flush() throw(FileException) { if(isOpen() && !FlushFileBuffers(h)) throw FileException(Util::translateError(GetLastError())); return 0; @@ -153,6 +157,11 @@ } } +void File::deleteFile(const string& aFileName) throw() +{ + ::DeleteFile(Text::toT(aFileName).c_str()); +} + int64_t File::getSize(const string& aFileName) throw() { WIN32_FIND_DATA fd; HANDLE hFind; @@ -185,7 +194,7 @@ return path.size() > 2 && (path[1] == ':' || path[0] == '/' || path[0] == '\\'); } -#else // _WIN32 +#else // !_WIN32 File::File(const string& aFileName, int access, int mode) throw(FileException) { dcassert(access == WRITE || access == READ || access == (READ | WRITE)); @@ -218,6 +227,10 @@ return (u_int32_t)s.st_mtime; } +bool File::isOpen() throw() { + return h != -1; +} + void File::close() throw() { if(h != -1) { ::close(h); @@ -302,7 +315,7 @@ } size_t File::flush() throw(FileException) { - if(h != -1 && fsync(h) == -1) + if(isOpen() && fsync(h) == -1) throw FileException(Util::translateError(errno)); return 0; } @@ -342,6 +355,10 @@ } } +void File::deleteFile(const string& aFileName) throw() { + ::unlink(aFileName.c_str()); +} + int64_t File::getSize(const string& aFileName) throw() { struct stat s; if(stat(aFileName.c_str(), &s) == -1) @@ -363,7 +380,7 @@ return path.size() > 1 && path[0] = '/'; } -#endif // _WIN32 +#endif // !_WIN32 string File::read(size_t len) throw(FileException) { string s(len, 0); Modified: dcplusplus/trunk/client/File.h =================================================================== --- dcplusplus/trunk/client/File.h 2006-09-29 16:05:42 UTC (rev 661) +++ dcplusplus/trunk/client/File.h 2006-09-29 16:24:13 UTC (rev 662) @@ -48,8 +48,33 @@ CREATE = 0x02, TRUNCATE = 0x04 }; + +#ifdef _WIN32 + enum { + READ = GENERIC_READ, + WRITE = GENERIC_WRITE, + RW = READ | WRITE + }; + + static u_int32_t convertTime(FILETIME* f); + +#else // !_WIN32 + + enum { + READ = 0x01, + WRITE = 0x02, + RW = READ | WRITE + }; + + // some ftruncate implementations can't extend files like SetEndOfFile, + // not sure if the client code needs this... + int extendFile(int64_t len) throw(); + +#endif // !_WIN32 + File(const string& aFileName, int access, int mode) throw(FileException); + bool isOpen() throw(); virtual void close() throw(); virtual int64_t getSize() throw(); virtual void setSize(int64_t newSize) throw(FileException); @@ -68,41 +93,13 @@ static void copyFile(const string& src, const string& target) throw(FileException); static void renameFile(const string& source, const string& target) throw(FileException); + static void deleteFile(const string& aFileName) throw(); static int64_t getSize(const string& aFileName) throw(); - static void ensureDirectory(const string& aFile); - static bool isAbsolute(const string& path); + static void ensureDirectory(const string& aFile) throw(); + static bool isAbsolute(const string& path) throw(); -#ifdef _WIN32 - enum { - READ = GENERIC_READ, - WRITE = GENERIC_WRITE, - RW = READ | WRITE - }; - - static u_int32_t convertTime(FILETIME* f); - bool isOpen() { return h != INVALID_HANDLE_VALUE; } - - static void deleteFile(const string& aFileName) throw() { ::DeleteFile(Text::toT(aFileName).c_str()); } - -#else // _WIN32 - - enum { - READ = 0x01, - WRITE = 0x02, - RW = READ | WRITE - }; - - bool isOpen() { return h != -1; } - static void deleteFile(const string& aFileName) throw() { ::unlink(aFileName.c_str()); } - - // some ftruncate implementations can't extend files like SetEndOfFile, - // not sure if the client code needs this... - int extendFile(int64_t len); - -#endif // _WIN32 - virtual ~File() throw() { File::close(); } string read(size_t len) throw(FileException); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-10-04 01:47:39
|
Revision: 660 http://svn.sourceforge.net/dcplusplus/?rev=660&view=rev Author: arnetheduck Date: 2006-09-29 08:41:55 -0700 (Fri, 29 Sep 2006) Log Message: ----------- New version Modified Paths: -------------- dcplusplus/trunk/DCPlusPlus.rc dcplusplus/trunk/Example.xml dcplusplus/trunk/client/version.h Modified: dcplusplus/trunk/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/DCPlusPlus.rc 2006-09-29 13:34:42 UTC (rev 659) +++ dcplusplus/trunk/DCPlusPlus.rc 2006-09-29 15:41:55 UTC (rev 660) @@ -942,8 +942,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,9,6 - PRODUCTVERSION 0,6,9,6 + FILEVERSION 0,6,9,7 + PRODUCTVERSION 0,6,9,7 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, 6" + VALUE "FileVersion", "0, 6, 9, 7" VALUE "InternalName", "DC++" VALUE "LegalCopyright", "Copyright 2001-2006 Jacek Sieka" VALUE "OriginalFilename", "DCPlusPlus.exe" VALUE "ProductName", "DC++" - VALUE "ProductVersion", "0, 6, 9, 6" + VALUE "ProductVersion", "0, 6, 9, 7" END END BLOCK "VarFileInfo" Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-09-29 13:34:42 UTC (rev 659) +++ dcplusplus/trunk/Example.xml 2006-09-29 15:41:55 UTC (rev 660) @@ -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.696" Revision="1" RightToLeft="0"> +<Language Name="Example Language" Native="English" Code="en" Author="arnetheduck" Version="0.697" Revision="1" RightToLeft="0"> <Strings> <String Name="Active">Active</String> <String Name="ActiveSearchString">Enabled / Search String</String> Modified: dcplusplus/trunk/client/version.h =================================================================== --- dcplusplus/trunk/client/version.h 2006-09-29 13:34:42 UTC (rev 659) +++ dcplusplus/trunk/client/version.h 2006-09-29 15:41:55 UTC (rev 660) @@ -17,7 +17,7 @@ */ #define APPNAME "DC++" -#define VERSIONSTRING "0.696" -#define VERSIONFLOAT 0.696 +#define VERSIONSTRING "0.697" +#define VERSIONFLOAT 0.697 /* Update the .rc file as well... */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-22 21:29:16
|
Revision: 656 http://svn.sourceforge.net/dcplusplus/?rev=656&view=rev Author: arnetheduck Date: 2006-09-22 14:29:07 -0700 (Fri, 22 Sep 2006) Log Message: ----------- changelog Modified Paths: -------------- dcplusplus/trunk/changelog.txt Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-22 21:23:35 UTC (rev 655) +++ dcplusplus/trunk/changelog.txt 2006-09-22 21:29:07 UTC (rev 656) @@ -1,4 +1,4 @@ --- 0.696 -- +-- 0.696 2006-09-22 -- * Fixed a possible deadlock * [bug 1058] Removed some whitespace (big thanks to pothead) * Removed the possibility to download files without TTH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-22 21:23:51
|
Revision: 655 http://svn.sourceforge.net/dcplusplus/?rev=655&view=rev Author: arnetheduck Date: 2006-09-22 14:23:35 -0700 (Fri, 22 Sep 2006) Log Message: ----------- patches Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/windows/LogPage.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-09-20 09:53:26 UTC (rev 654) +++ dcplusplus/trunk/changelog.txt 2006-09-22 21:23:35 UTC (rev 655) @@ -13,6 +13,9 @@ * 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) +* [bug 1061] Log page fix (thanks fleetcommand) +* [bug 1033] Altered NMDC hubname/description detection slightly (thanks fleetcommand) +* [bug 1059] Fixed the possibility for users to become hidden in some cases (thanks fleetcommand) -- 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/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-09-20 09:53:26 UTC (rev 654) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-09-22 21:23:35 UTC (rev 655) @@ -395,13 +395,13 @@ return; const string& proto = secure ? SECURE_CLIENT_PROTOCOL : CLIENT_PROTOCOL; - short port = secure ? ConnectionManager::getInstance()->getSecurePort() : ConnectionManager::getInstance()->getPort(); - if(port == 0) { - // Oops? - LogManager::getInstance()->message(STRING(NOT_LISTENING)); - return; - } if(ClientManager::getInstance()->isActive()) { + short port = secure ? ConnectionManager::getInstance()->getSecurePort() : ConnectionManager::getInstance()->getPort(); + if(port == 0) { + // Oops? + LogManager::getInstance()->message(STRING(NOT_LISTENING)); + return; + } send(AdcCommand(AdcCommand::CMD_CTM, user.getIdentity().getSID()).addParam(proto).addParam(Util::toString(port)).addParam(token)); } else { send(AdcCommand(AdcCommand::CMD_RCM, user.getIdentity().getSID()).addParam(proto)); Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-09-20 09:53:26 UTC (rev 654) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-09-22 21:23:35 UTC (rev 655) @@ -340,6 +340,12 @@ OnlineUser& u = getUser(nick); + // If he is already considered to be the hub (thus hidden), probably should appear in the UserList + if(u.getIdentity().isHidden()) { + u.getIdentity().setHidden(false); + u.getIdentity().setHub(false); + } + j = param.find('$', i); if(j == string::npos) return; @@ -453,14 +459,22 @@ } else if(cmd == "$SR") { SearchManager::getInstance()->onSearchResult(aLine); } else if(cmd == "$HubName") { - // Hack - first word goes to hub name, rest to description - string::size_type i = param.find(' '); + // If " - " found, the first part goes to hub name, rest to description + // If no " - " found, first word goes to hub name, rest to description + + string::size_type i = param.find(" - "); if(i == string::npos) { - getHubIdentity().setNick(unescape(param)); - getHubIdentity().setDescription(Util::emptyString); + i = param.find(' '); + if(i == string::npos) { + getHubIdentity().setNick(unescape(param)); + getHubIdentity().setDescription(Util::emptyString); + } else { + getHubIdentity().setNick(unescape(param.substr(0, i))); + getHubIdentity().setDescription(unescape(param.substr(i+1))); + } } else { getHubIdentity().setNick(unescape(param.substr(0, i))); - getHubIdentity().setDescription(unescape(param.substr(i+1))); + getHubIdentity().setDescription(unescape(param.substr(i+3))); } fire(ClientListener::HubUpdated(), this); } else if(cmd == "$Supports") { Modified: dcplusplus/trunk/windows/LogPage.cpp =================================================================== --- dcplusplus/trunk/windows/LogPage.cpp 2006-09-20 09:53:26 UTC (rev 654) +++ dcplusplus/trunk/windows/LogPage.cpp 2006-09-22 21:23:35 UTC (rev 655) @@ -65,6 +65,9 @@ options.push_back(pair); } + ::EnableWindow(GetDlgItem(IDC_LOG_FORMAT), false); + ::EnableWindow(GetDlgItem(IDC_LOG_FILE), false); + oldSelection = -1; // Do specialized reading here This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2006-09-20 09:53:47
|
Revision: 654 http://svn.sourceforge.net/dcplusplus/?rev=654&view=rev Author: arnetheduck Date: 2006-09-20 02:53:26 -0700 (Wed, 20 Sep 2006) Log Message: ----------- Some minor fixes here and there Modified Paths: -------------- dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/FinishedManager.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/SearchManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/windows/DirectoryListingFrm.cpp dcplusplus/trunk/windows/SearchFrm.cpp dcplusplus/trunk/windows/SearchFrm.h Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -49,21 +49,21 @@ } OnlineUser& AdcHub::getUser(const u_int32_t aSID, const CID& aCID) { - OnlineUser* u = findUser(aSID); - if(u) { - return *u; + OnlineUser* ou = findUser(aSID); + if(ou) { + return *ou; } User::Ptr p = ClientManager::getInstance()->getUser(aCID); { Lock l(cs); - u = users.insert(make_pair(aSID, new OnlineUser(p, *this, aSID))).first->second; + ou = users.insert(make_pair(aSID, new OnlineUser(p, *this, aSID))).first->second; } - if(!aCID.isZero()) - ClientManager::getInstance()->putOnline(*u); - return *u; + if(aSID != AdcCommand::HUB_SID) + ClientManager::getInstance()->putOnline(*ou); + return *ou; } OnlineUser* AdcHub::findUser(const u_int32_t aSID) const { @@ -73,25 +73,35 @@ } void AdcHub::putUser(const u_int32_t aSID) { - Lock l(cs); - SIDIter i = users.find(aSID); - if(i == users.end()) - return; + OnlineUser* ou = 0; + { + Lock l(cs); + SIDIter i = users.find(aSID); + if(i == users.end()) + return; + ou = i->second; + users.erase(i); + } + if(aSID != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOffline(*i->second); - fire(ClientListener::UserRemoved(), this, *i->second); - delete i->second; - users.erase(i); + ClientManager::getInstance()->putOffline(*ou); + + fire(ClientListener::UserRemoved(), this, *ou); + delete ou; } void AdcHub::clearUsers() { - Lock l(cs); - for(SIDIter i = users.begin(); i != users.end(); ++i) { + SIDMap tmp; + { + Lock l(cs); + users.swap(tmp); + } + + for(SIDIter i = tmp.begin(); i != tmp.end(); ++i) { if(i->first != AdcCommand::HUB_SID) ClientManager::getInstance()->putOffline(*i->second); delete i->second; } - users.clear(); } @@ -312,29 +322,30 @@ FavoriteManager::getInstance()->addUserCommand(once ? UserCommand::TYPE_RAW_ONCE : UserCommand::TYPE_RAW, ctx, UserCommand::FLAG_NOSAVE, name, txt, getHubUrl()); } -void AdcHub::sendUDP(const AdcCommand& cmd) { - try { - Socket s; - s.create(Socket::TYPE_UDP); - +void AdcHub::sendUDP(const AdcCommand& cmd) throw() { + string command; + string ip; + short port; + { Lock l(cs); SIDMap::const_iterator i = users.find(cmd.getTo()); if(i == users.end()) { dcdebug("AdcHub::sendUDP: invalid user\n"); return; } - OnlineUser& u = *i->second; - string tmp = cmd.toString(u.getUser()->getCID()); - if(u.getIdentity().isUdpActive()) { - try { - s.writeTo(u.getIdentity().getIp(), (short)Util::toInt(u.getIdentity().getUdpPort()), tmp); - } catch(const SocketException& e) { - dcdebug("AdcHub::sendUDP: write failed: %s\n", e.getError().c_str()); - } + OnlineUser& ou = *i->second; + if(!ou.getIdentity().isUdpActive()) { + return; } - } catch(SocketException&) { - dcdebug("Can't create UDP socket\n"); + ip = ou.getIdentity().getIp(); + port = static_cast<short>(Util::toInt(ou.getIdentity().getUdpPort())); + command = cmd.toString(ou.getUser()->getCID()); } + try { + udp.writeTo(ip, port, command); + } catch(const SocketException& e) { + dcdebug("AdcHub::sendUDP: write failed: %s\n", e.getError().c_str()); + } } void AdcHub::handle(AdcCommand::STA, AdcCommand& c) throw() { Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/AdcHub.h 2006-09-20 09:53:26 UTC (rev 654) @@ -73,6 +73,7 @@ typedef HASH_MAP<u_int32_t, OnlineUser*> SIDMap; typedef SIDMap::iterator SIDIter; + Socket udp; SIDMap users; StringMap lastInfoMap; mutable CriticalSection cs; @@ -113,7 +114,7 @@ //Speaker<AdcHubListener>::fire(t, this, c); } - void sendUDP(const AdcCommand& cmd); + void sendUDP(const AdcCommand& cmd) throw(); virtual void on(Connecting) throw() { fire(ClientListener::Connecting(), this); } virtual void on(Connected) throw(); Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -51,6 +51,7 @@ } c->addListener(this); + return c; } @@ -309,7 +310,7 @@ u.getClient().send(cmd); } else { try { - s.writeTo(u.getIdentity().getIp(), static_cast<short>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID())); + udp.writeTo(u.getIdentity().getIp(), static_cast<short>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID())); } catch(const SocketException&) { dcdebug("Socket exception sending ADC UDP command\n"); } @@ -376,7 +377,7 @@ port = 412; for(SearchResult::Iter i = l.begin(); i != l.end(); ++i) { SearchResult* sr = *i; - s.writeTo(ip, port, sr->toSR(*aClient)); + udp.writeTo(ip, port, sr->toSR(*aClient)); sr->decRef(); } } catch(const SocketException& /* e */) { Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/ClientManager.h 2006-09-20 09:53:26 UTC (rev 654) @@ -115,7 +115,7 @@ User::Ptr me; - Socket s; + Socket udp; string cachedIp; CID pid; Modified: dcplusplus/trunk/client/FinishedManager.cpp =================================================================== --- dcplusplus/trunk/client/FinishedManager.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/FinishedManager.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -23,12 +23,12 @@ #include "ClientManager.h" FinishedManager::~FinishedManager() throw() { + DownloadManager::getInstance()->removeListener(this); + UploadManager::getInstance()->removeListener(this); + Lock l(cs); for_each(downloads.begin(), downloads.end(), DeleteFunction()); for_each(uploads.begin(), uploads.end(), DeleteFunction()); - DownloadManager::getInstance()->removeListener(this); - UploadManager::getInstance()->removeListener(this); - } void FinishedManager::remove(FinishedItem *item, bool upload /* = false */) { Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -118,17 +118,17 @@ } void NmdcHub::putUser(const string& aNick) { - OnlineUser* u = NULL; + OnlineUser* ou = NULL; { Lock l(cs); NickIter i = users.find(aNick); if(i == users.end()) return; - u = i->second; + ou = i->second; users.erase(i); } - ClientManager::getInstance()->putOffline(*u); - delete u; + ClientManager::getInstance()->putOffline(*ou); + delete ou; } void NmdcHub::clearUsers() { @@ -136,8 +136,7 @@ { Lock l(cs); - u2 = users; - users.clear(); + u2.swap(users); } for(NickIter i = u2.begin(); i != u2.end(); ++i) { @@ -261,33 +260,31 @@ i = j + 1; - { - Lock l(cs); - u_int32_t tick = GET_TICK(); + u_int32_t tick = GET_TICK(); + clearFlooders(tick); - seekers.push_back(make_pair(seeker, tick)); + seekers.push_back(make_pair(seeker, tick)); - // First, check if it's a flooder - for(FloodIter fi = flooders.begin(); fi != flooders.end(); ++fi) { - if(fi->first == seeker) { - return; - } + // First, check if it's a flooder + for(FloodIter fi = flooders.begin(); fi != flooders.end(); ++fi) { + if(fi->first == seeker) { + return; } + } - int count = 0; - for(FloodIter fi = seekers.begin(); fi != seekers.end(); ++fi) { - if(fi->first == seeker) - count++; + int count = 0; + for(FloodIter fi = seekers.begin(); fi != seekers.end(); ++fi) { + if(fi->first == seeker) + count++; - if(count > 7) { - if(seeker.compare(0, 4, "Hub:") == 0) - fire(ClientListener::SearchFlood(), this, seeker.substr(4)); - else - fire(ClientListener::SearchFlood(), this, seeker + STRING(NICK_UNKNOWN)); + if(count > 7) { + if(seeker.compare(0, 4, "Hub:") == 0) + fire(ClientListener::SearchFlood(), this, seeker.substr(4)); + else + fire(ClientListener::SearchFlood(), this, seeker + STRING(NICK_UNKNOWN)); - flooders.push_back(make_pair(seeker, tick)); - return; - } + flooders.push_back(make_pair(seeker, tick)); + return; } } @@ -880,6 +877,16 @@ } } +void NmdcHub::clearFlooders(u_int32_t aTick) { + while(!seekers.empty() && seekers.front().second + (5 * 1000) < aTick) { + seekers.pop_front(); + } + + while(!flooders.empty() && flooders.front().second + (120 * 1000) < aTick) { + flooders.pop_front(); + } +} + // TimerManagerListener void NmdcHub::on(Second, u_int32_t aTick) throw() { if(state == STATE_CONNECTED && (getLastActivity() + getReconnDelay() * 1000) < aTick) { @@ -891,18 +898,6 @@ connect(); } - { - Lock l(cs); - - while(!seekers.empty() && seekers.front().second + (5 * 1000) < aTick) { - seekers.pop_front(); - } - - while(!flooders.empty() && flooders.front().second + (120 * 1000) < aTick) { - flooders.pop_front(); - } - } - Client::on(Second(), aTick); } Modified: dcplusplus/trunk/client/NmdcHub.h =================================================================== --- dcplusplus/trunk/client/NmdcHub.h 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/NmdcHub.h 2006-09-20 09:53:26 UTC (rev 654) @@ -114,6 +114,7 @@ void revConnectToMe(const OnlineUser& aUser); void myInfo(bool alwaysSend); void supports(const StringList& feat); + void clearFlooders(u_int32_t tick); void updateFromTag(Identity& id, const string& tag); Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -721,18 +721,9 @@ } } -void QueueManager::getTargetsBySize(StringList& sl, int64_t aSize, const string& suffix) throw() { +void QueueManager::getTargets(const TTHValue& tth, StringList& sl) { Lock l(cs); QueueItem::List ql; - fileQueue.find(ql, aSize, suffix); - for(QueueItem::Iter i = ql.begin(); i != ql.end(); ++i) { - sl.push_back((*i)->getTarget()); - } -} - -void QueueManager::getTargetsByRoot(StringList& sl, const TTHValue& tth) { - Lock l(cs); - QueueItem::List ql; fileQueue.find(ql, tth); for(QueueItem::Iter i = ql.begin(); i != ql.end(); ++i) { sl.push_back((*i)->getTarget()); @@ -753,8 +744,8 @@ QueueItem* q = userQueue.getNext(aUser); - if(q == NULL) - return NULL; + if(!q) + return 0; userQueue.setRunning(q, aUser); Modified: dcplusplus/trunk/client/QueueManager.h =================================================================== --- dcplusplus/trunk/client/QueueManager.h 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/QueueManager.h 2006-09-20 09:53:26 UTC (rev 654) @@ -99,8 +99,7 @@ void setPriority(const string& aTarget, QueueItem::Priority p) throw(); - void getTargetsBySize(StringList& sl, int64_t aSize, const string& suffix) throw(); - void getTargetsByRoot(StringList& sl, const TTHValue& tth); + void getTargets(const TTHValue& tth, StringList& sl); QueueItem::StringMap& lockQueue() throw() { cs.enter(); return fileQueue.getQueue(); } ; void unlockQueue() throw() { cs.leave(); } Modified: dcplusplus/trunk/client/SearchManager.cpp =================================================================== --- dcplusplus/trunk/client/SearchManager.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/SearchManager.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -220,6 +220,7 @@ if( (j = x.rfind(')')) == string::npos) { return; } + string hubIpPort = x.substr(i, j-i); string url = ClientManager::getInstance()->findHub(hubIpPort); @@ -237,9 +238,12 @@ StringList names = ClientManager::getInstance()->getHubNames(user->getCID()); hubName = names.empty() ? STRING(OFFLINE) : Util::toString(names); } - if(tth.empty()) + + if(tth.empty() && type == SearchResult::TYPE_FILE) { return; + } + SearchResult* sr = new SearchResult(user, type, slots, freeSlots, size, file, hubName, url, remoteIp, TTHValue(tth), Util::emptyString); fire(SearchManagerListener::SR(), sr); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -116,7 +116,6 @@ } string ShareManager::translateFileName(const string& aFile) throw(ShareException) { - RLock<> l(cs); if(aFile == "MyList.DcLst") { throw ShareException("NMDC-style lists no longer supported, please upgrade your client"); } else if(aFile == DownloadManager::USER_LIST_NAME || aFile == DownloadManager::USER_LIST_NAME_BZ) { @@ -128,6 +127,8 @@ string file; + RLock<> l(cs); + // Check for tth root identifier if(aFile.compare(0, 4, "TTH/") == 0) { file = translateTTH(aFile.substr(4)); @@ -141,7 +142,6 @@ if(i == string::npos) throw ShareException(UserConnection::FILE_NOT_AVAILABLE); - RLock<> l(cs); StringPairIter j = lookupVirtual(file.substr(1, i-1)); if(j == virtualMap.end()) { throw ShareException(UserConnection::FILE_NOT_AVAILABLE); @@ -1243,7 +1243,7 @@ i->second->getParent()->getFullName() + i->second->getName(), i->second->getTTH()); results.push_back(sr); - ShareManager::getInstance()->setHits(ShareManager::getInstance()->getHits()+1); + ShareManager::getInstance()->addHits(1); } } return; Modified: dcplusplus/trunk/windows/DirectoryListingFrm.cpp =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -632,7 +632,7 @@ n = 0; targetMenu.AppendMenu(MF_STRING, IDC_DOWNLOADTO, CTSTRING(BROWSE)); targets.clear(); - QueueManager::getInstance()->getTargetsByRoot(targets, ii->file->getTTH()); + QueueManager::getInstance()->getTargets(ii->file->getTTH(), targets); if(targets.size() > 0) { targetMenu.AppendMenu(MF_SEPARATOR); Modified: dcplusplus/trunk/windows/SearchFrm.cpp =================================================================== --- dcplusplus/trunk/windows/SearchFrm.cpp 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/windows/SearchFrm.cpp 2006-09-20 09:53:26 UTC (rev 654) @@ -347,8 +347,11 @@ } if(isHash) { - if(Util::stricmp(Text::toT(aResult->getTTH().toBase32()), search[0]) != 0) + if(aResult->getType() != SearchResult::TYPE_FILE || TTHValue(Text::fromT(search[0])) != aResult->getTTH()) { + droppedResults++; + PostMessage(WM_SPEAKER, FILTER_RESULT); return; + } } else { // match all here for(TStringIter j = search.begin(); j != search.end(); ++j) { @@ -357,23 +360,21 @@ ) { droppedResults++; - PostMessage(WM_SPEAKER, FILTER_RESULT, NULL); + PostMessage(WM_SPEAKER, FILTER_RESULT); return; } } } } - // Reject results without free slots or tth if selected - // but always show directories + // Reject results without free slots if((onlyFree && aResult->getFreeSlots() < 1)) { droppedResults++; - ctrlStatus.SetText(3, Text::toT(Util::toString(droppedResults) + ' ' + STRING(FILTERED)).c_str()); + PostMessage(WM_SPEAKER, FILTER_RESULT); return; } - SearchInfo* i = new SearchInfo(aResult); PostMessage(WM_SPEAKER, ADD_RESULT, (LPARAM)i); } @@ -400,10 +401,11 @@ ctrlStatus.SetText(3, _T("")); return 0; } + void SearchFrame::SearchInfo::view() { try { if(sr->getType() == SearchResult::TYPE_FILE) { - QueueManager::getInstance()->add(Util::getTempPath() + Text::fromT(columns[COLUMN_FILENAME]), + QueueManager::getInstance()->add(Util::getTempPath() + sr->getFileName(), sr->getSize(), sr->getTTH(), sr->getUser(), QueueItem::FLAG_CLIENT_VIEW | QueueItem::FLAG_TEXT); } @@ -430,12 +432,13 @@ void SearchFrame::SearchInfo::DownloadWhole::operator()(SearchInfo* si) { try { + QueueItem::Priority prio = WinUtil::isShift() ? QueueItem::HIGHEST : QueueItem::DEFAULT; if(si->sr->getType() == SearchResult::TYPE_FILE) { - QueueManager::getInstance()->addDirectory(Text::fromT(si->columns[COLUMN_PATH]), si->sr->getUser(), Text::fromT(tgt), - WinUtil::isShift() ? QueueItem::HIGHEST : QueueItem::DEFAULT); + QueueManager::getInstance()->addDirectory(Text::fromT(si->columns[COLUMN_PATH]), + si->sr->getUser(), Text::fromT(tgt), prio); } else { - QueueManager::getInstance()->addDirectory(si->sr->getFile(), si->sr->getUser(), Text::fromT(tgt), - WinUtil::isShift() ? QueueItem::HIGHEST : QueueItem::DEFAULT); + QueueManager::getInstance()->addDirectory(si->sr->getFile(), si->sr->getUser(), + Text::fromT(tgt), prio); } } catch(const Exception&) { } @@ -475,7 +478,7 @@ } } -void SearchFrame::SearchInfo::CheckSize::operator()(SearchInfo* si) { +void SearchFrame::SearchInfo::CheckTTH::operator()(SearchInfo* si) { if(firstTTH) { tth = si->columns[COLUMN_TTH]; hasTTH = true; @@ -486,19 +489,6 @@ } } - if(si->sr->getType() == SearchResult::TYPE_FILE) { - if(ext.empty()) { - ext = Util::getFileExt(si->columns[COLUMN_FILENAME]); - size = si->sr->getSize(); - } else if(size != -1) { - if((si->sr->getSize() != size) || (Util::stricmp(ext, Util::getFileExt(si->columns[COLUMN_FILENAME])) != 0)) { - size = -1; - } - } - } else { - size = -1; - } - if(firstHubs && hubs.empty()) { hubs = ClientManager::getInstance()->getHubs(si->sr->getUser()->getCID()); firstHubs = false; @@ -965,15 +955,11 @@ } } - SearchInfo::CheckSize cs = ctrlResults.forEachSelectedT(SearchInfo::CheckSize()); + SearchInfo::CheckTTH cs = ctrlResults.forEachSelectedT(SearchInfo::CheckTTH()); - if(cs.size != -1 || cs.hasTTH) { + if(cs.hasTTH) { targets.clear(); - if(cs.hasTTH) { - QueueManager::getInstance()->getTargetsByRoot(targets, TTHValue(Text::fromT(cs.tth))); - } else { - QueueManager::getInstance()->getTargetsBySize(targets, cs.size, Text::fromT(cs.ext)); - } + QueueManager::getInstance()->getTargets(TTHValue(Text::fromT(cs.tth)), targets); if(targets.size() > 0) { targetMenu.AppendMenu(MF_SEPARATOR); Modified: dcplusplus/trunk/windows/SearchFrm.h =================================================================== --- dcplusplus/trunk/windows/SearchFrm.h 2006-09-19 19:20:45 UTC (rev 653) +++ dcplusplus/trunk/windows/SearchFrm.h 2006-09-20 09:53:26 UTC (rev 654) @@ -258,11 +258,9 @@ void operator()(SearchInfo* si); const tstring& tgt; }; - struct CheckSize { - CheckSize() : size(-1), op(true), firstHubs(true), hasTTH(false), firstTTH(true) { } + struct CheckTTH { + CheckTTH() : op(true), firstHubs(true), hasTTH(false), firstTTH(true) { } void operator()(SearchInfo* si); - tstring ext; - int64_t size; bool firstHubs; StringList hubs; bool op; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |