|
From: <arn...@us...> - 2006-12-13 17:10:10
|
Revision: 687
http://svn.sourceforge.net/dcplusplus/?rev=687&view=rev
Author: arnetheduck
Date: 2006-12-13 09:10:06 -0800 (Wed, 13 Dec 2006)
Log Message:
-----------
Patches & ADC connect fix
Modified Paths:
--------------
dcplusplus/trunk/DCPlusPlus.rc
dcplusplus/trunk/DCPlusPlus.vcproj
dcplusplus/trunk/changelog.txt
dcplusplus/trunk/client/AdcHub.cpp
dcplusplus/trunk/client/AdcHub.h
dcplusplus/trunk/client/BufferedSocket.cpp
dcplusplus/trunk/client/BufferedSocket.h
dcplusplus/trunk/client/Client.h
dcplusplus/trunk/client/ClientManager.cpp
dcplusplus/trunk/client/ClientManager.h
dcplusplus/trunk/client/ConnectionManager.cpp
dcplusplus/trunk/client/ConnectionManager.h
dcplusplus/trunk/client/NmdcHub.cpp
dcplusplus/trunk/client/NmdcHub.h
dcplusplus/trunk/client/SSLSocket.cpp
dcplusplus/trunk/client/SSLSocket.h
dcplusplus/trunk/client/SearchManager.cpp
dcplusplus/trunk/client/SearchManager.h
dcplusplus/trunk/client/ServerSocket.cpp
dcplusplus/trunk/client/ServerSocket.h
dcplusplus/trunk/client/Socket.cpp
dcplusplus/trunk/client/Socket.h
dcplusplus/trunk/client/UploadManager.cpp
dcplusplus/trunk/client/UserConnection.cpp
dcplusplus/trunk/client/UserConnection.h
dcplusplus/trunk/client/Util.cpp
dcplusplus/trunk/client.vcproj
dcplusplus/trunk/help/help.vcproj
dcplusplus/trunk/windows/SearchFrm.cpp
dcplusplus/trunk/windows/TransferView.cpp
Modified: dcplusplus/trunk/DCPlusPlus.rc
===================================================================
--- dcplusplus/trunk/DCPlusPlus.rc 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/DCPlusPlus.rc 2006-12-13 17:10:06 UTC (rev 687)
@@ -235,8 +235,8 @@
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
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
+ LTEXT "Notification sound",IDC_BEEP_NOTIFICATION,10,110,66,8
+ EDITTEXT IDC_BEEPFILE,85,108,119,12,ES_AUTOHSCROLL
PUSHBUTTON "&Browse...",IDC_BROWSE,210,109,50,12
END
Modified: dcplusplus/trunk/DCPlusPlus.vcproj
===================================================================
--- dcplusplus/trunk/DCPlusPlus.vcproj 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/DCPlusPlus.vcproj 2006-12-13 17:10:06 UTC (rev 687)
@@ -168,6 +168,7 @@
PrecompiledHeaderThrough="stdafx.h"
AssemblerOutput="4"
WarningLevel="4"
+ Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
Modified: dcplusplus/trunk/changelog.txt
===================================================================
--- dcplusplus/trunk/changelog.txt 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/changelog.txt 2006-12-13 17:10:06 UTC (rev 687)
@@ -19,6 +19,8 @@
* [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)
+* [bug 1112] Port sign cleanup (thanks steven sheehy)
+* Fixed ADC client-to-client connection sequence
-- 0.698 2006-10-10 --
* [bug 1065] Code cleanup (thanks steven sheehy)
Modified: dcplusplus/trunk/client/AdcHub.cpp
===================================================================
--- dcplusplus/trunk/client/AdcHub.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/AdcHub.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -268,6 +268,11 @@
string token;
bool hasToken = c.getParam("TO", 2, token);
+ if(!hasToken) {
+ // @todo remove this bugfix for <=0.698 some time
+ token = c.getParam(2);
+ }
+
bool secure;
if(protocol == CLIENT_PROTOCOL) {
secure = false;
@@ -290,7 +295,7 @@
return;
}
- ConnectionManager::getInstance()->adcConnect(*u, (short)Util::toInt(port), token, secure);
+ ConnectionManager::getInstance()->adcConnect(*u, static_cast<uint16_t>(Util::toInt(port)), token, secure);
}
void AdcHub::handle(AdcCommand::RCM, AdcCommand& c) throw() {
@@ -357,7 +362,7 @@
void AdcHub::sendUDP(const AdcCommand& cmd) throw() {
string command;
string ip;
- short port;
+ uint16_t port;
{
Lock l(cs);
SIDMap::const_iterator i = users.find(cmd.getTo());
@@ -370,7 +375,7 @@
return;
}
ip = ou.getIdentity().getIp();
- port = static_cast<short>(Util::toInt(ou.getIdentity().getUdpPort()));
+ port = static_cast<uint16_t>(Util::toInt(ou.getIdentity().getUdpPort()));
command = cmd.toString(ou.getUser()->getCID());
}
try {
@@ -417,9 +422,8 @@
SearchManager::getInstance()->onRES(c, ou->getUser());
}
-void AdcHub::connect(const OnlineUser& user) {
- uint32_t r = Util::rand();
- connect(user, Util::toString(r), CryptoManager::getInstance()->TLSOk() && user.getUser()->isSet(User::TLS));
+void AdcHub::connect(const OnlineUser& user, const string& token) {
+ connect(user, token, CryptoManager::getInstance()->TLSOk() && user.getUser()->isSet(User::TLS));
}
void AdcHub::connect(const OnlineUser& user, string const& token, bool secure) {
@@ -428,15 +432,15 @@
const string& proto = secure ? SECURE_CLIENT_PROTOCOL : CLIENT_PROTOCOL;
if(ClientManager::getInstance()->isActive()) {
- short port = secure ? ConnectionManager::getInstance()->getSecurePort() : ConnectionManager::getInstance()->getPort();
+ uint16_t 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(), AdcCommand::TYPE_DIRECT).addParam(proto).addParam(Util::toString(port)).addParam(token));
+ send(AdcCommand(AdcCommand::CMD_CTM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(proto).addParam(Util::toString(port)).addParam("TO", token));
} else {
- send(AdcCommand(AdcCommand::CMD_RCM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(proto));
+ send(AdcCommand(AdcCommand::CMD_RCM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(proto).addParam("TO", token));
}
}
Modified: dcplusplus/trunk/client/AdcHub.h
===================================================================
--- dcplusplus/trunk/client/AdcHub.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/AdcHub.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -35,7 +35,7 @@
using Client::send;
using Client::connect;
- virtual void connect(const OnlineUser& user);
+ virtual void connect(const OnlineUser& user, const string& token);
void connect(const OnlineUser& user, string const& token, bool secure);
virtual void hubMessage(const string& aMessage);
Modified: dcplusplus/trunk/client/BufferedSocket.cpp
===================================================================
--- dcplusplus/trunk/client/BufferedSocket.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -101,7 +101,7 @@
}
-void BufferedSocket::connect(const string& aAddress, short aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException) {
+void BufferedSocket::connect(const string& aAddress, uint16_t aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException) {
dcassert(!sock);
try {
@@ -129,7 +129,7 @@
}
#define CONNECT_TIMEOUT 30000
-void BufferedSocket::threadConnect(const string& aAddr, short aPort, bool proxy) throw(SocketException) {
+void BufferedSocket::threadConnect(const string& aAddr, uint16_t aPort, bool proxy) throw(SocketException) {
dcdebug("threadConnect %s:%d\n", aAddr.c_str(), (int)aPort);
dcassert(sock);
if(!sock)
Modified: dcplusplus/trunk/client/BufferedSocket.h
===================================================================
--- dcplusplus/trunk/client/BufferedSocket.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/BufferedSocket.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -87,7 +87,7 @@
}
void accept(const Socket& srv, bool secure, bool allowUntrusted) throw(SocketException, ThreadException);
- void connect(const string& aAddress, short aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException);
+ void connect(const string& aAddress, uint16_t aPort, bool secure, bool allowUntrusted, bool proxy) throw(SocketException, ThreadException);
/** Sets data mode for aBytes bytes. Must be called within onLine. */
void setDataMode(int64_t aBytes = -1) { mode = MODE_DATA; dataBytes = aBytes; }
@@ -129,9 +129,9 @@
virtual ~TaskData() { }
};
struct ConnectInfo : public TaskData {
- ConnectInfo(string addr_, short port_, bool proxy_) : addr(addr_), port(port_), proxy(proxy_) { }
+ ConnectInfo(string addr_, uint16_t port_, bool proxy_) : addr(addr_), port(port_), proxy(proxy_) { }
string addr;
- short port;
+ uint16_t port;
bool proxy;
};
struct SendFileInfo : public TaskData {
@@ -167,7 +167,7 @@
virtual int run();
- void threadConnect(const string& aAddr, short aPort, bool proxy) throw(SocketException);
+ void threadConnect(const string& aAddr, uint16_t aPort, bool proxy) throw(SocketException);
void threadRead() throw(SocketException);
void threadSendFile(InputStream* is) throw(Exception);
void threadSendData();
Modified: dcplusplus/trunk/client/Client.h
===================================================================
--- dcplusplus/trunk/client/Client.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/Client.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -86,7 +86,7 @@
virtual void connect();
virtual void disconnect(bool graceless);
- virtual void connect(const OnlineUser& user) = 0;
+ virtual void connect(const OnlineUser& user, const string& token) = 0;
virtual void hubMessage(const string& aMessage) = 0;
virtual void privateMessage(const OnlineUser& user, const string& aMessage) = 0;
virtual void sendUserCmd(const string& aUserCmd) = 0;
@@ -104,7 +104,7 @@
bool isConnected() const { return socket && socket->isConnected(); }
bool isOp() const { return getMyIdentity().isOp(); }
- short getPort() const { return port; }
+ uint16_t getPort() const { return port; }
const string& getAddress() const { return address; }
const string& getIp() const { return ip; }
Modified: dcplusplus/trunk/client/ClientManager.cpp
===================================================================
--- dcplusplus/trunk/client/ClientManager.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/ClientManager.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -144,13 +144,13 @@
Lock l(cs);
string ip;
- short port = 411;
+ uint16_t port = 411;
string::size_type i = ipPort.find(':');
if(i == string::npos) {
ip = ipPort;
} else {
ip = ipPort.substr(0, i);
- port = (short)Util::toInt(ipPort.substr(i+1));
+ port = static_cast<uint16_t>(Util::toInt(ipPort.substr(i+1)));
}
string url;
@@ -277,12 +277,12 @@
}
}
-void ClientManager::connect(const User::Ptr& p) {
+void ClientManager::connect(const User::Ptr& p, const string& token) {
Lock l(cs);
OnlineIter i = onlineUsers.find(p->getCID());
if(i != onlineUsers.end()) {
OnlineUser* u = i->second;
- u->getClient().connect(*u);
+ u->getClient().connect(*u, token);
}
}
@@ -306,7 +306,7 @@
u.getClient().send(cmd);
} else {
try {
- udp.writeTo(u.getIdentity().getIp(), static_cast<short>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID()));
+ udp.writeTo(u.getIdentity().getIp(), static_cast<uint16_t>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID()));
} catch(const SocketException&) {
dcdebug("Socket exception sending ADC UDP command\n");
}
Modified: dcplusplus/trunk/client/ClientManager.h
===================================================================
--- dcplusplus/trunk/client/ClientManager.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/ClientManager.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -78,7 +78,7 @@
User::Ptr& getMe();
- void connect(const User::Ptr& p);
+ void connect(const User::Ptr& p, const string& token);
void send(AdcCommand& c, const CID& to);
void privateMessage(const User::Ptr& p, const string& msg);
Modified: dcplusplus/trunk/client/ConnectionManager.cpp
===================================================================
--- dcplusplus/trunk/client/ConnectionManager.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -46,7 +46,7 @@
void ConnectionManager::listen() throw(SocketException){
disconnect();
- unsigned short port = static_cast<unsigned short>(SETTING(TCP_PORT));
+ uint16_t port = static_cast<uint16_t>(SETTING(TCP_PORT));
server = new Server(false, port, SETTING(BIND_ADDRESS));
@@ -55,7 +55,7 @@
return;
}
- port = static_cast<unsigned short>(SETTING(TLS_PORT));
+ port = static_cast<uint16_t>(SETTING(TLS_PORT));
secureServer = new Server(true, port, SETTING(BIND_ADDRESS));
}
@@ -170,7 +170,7 @@
if(cqi->getState() == ConnectionQueueItem::WAITING) {
if(startDown) {
cqi->setState(ConnectionQueueItem::CONNECTING);
- ClientManager::getInstance()->connect(cqi->getUser());
+ ClientManager::getInstance()->connect(cqi->getUser(), cqi->getToken());
fire(ConnectionManagerListener::StatusChanged(), cqi);
attemptDone = true;
} else {
@@ -215,7 +215,7 @@
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) {
+ConnectionManager::Server::Server(bool secure_, uint16_t aPort, const string& ip /* = "0.0.0.0" */) : port(0), secure(secure_), die(false) {
sock.create();
port = sock.bind(aPort, ip);
sock.listen();
@@ -273,7 +273,7 @@
}
}
-void ConnectionManager::nmdcConnect(const string& aServer, short aPort, const string& aNick, const string& hubUrl) {
+void ConnectionManager::nmdcConnect(const string& aServer, uint16_t aPort, const string& aNick, const string& hubUrl) {
if(shuttingDown)
return;
@@ -290,7 +290,7 @@
}
}
-void ConnectionManager::adcConnect(const OnlineUser& aUser, short aPort, const string& aToken, bool secure) {
+void ConnectionManager::adcConnect(const OnlineUser& aUser, uint16_t aPort, const string& aToken, bool secure) {
if(shuttingDown)
return;
@@ -315,7 +315,6 @@
server = secureServer = 0;
}
-
void ConnectionManager::on(AdcCommand::SUP, UserConnection* aSource, const AdcCommand& cmd) throw() {
if(aSource->getState() != UserConnection::STATE_SUPNICK) {
// Already got this once, ignore...@todo fix support updates
@@ -608,7 +607,28 @@
return;
}
+ string token;
if(aSource->isSet(UserConnection::FLAG_INCOMING)) {
+ if(!cmd.getParam("TO", 0, token)) {
+ aSource->send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_GENERIC, "TO missing"));
+ putConnection(aSource);
+ return;
+ }
+ } else {
+ token = aSource->getToken();
+ }
+
+ bool down = true;
+ {
+ Lock l(cs);
+ ConnectionQueueItem::Iter i = find(downloads.begin(), downloads.end(), aSource->getUser());
+ if(i == downloads.end() || (*i)->getToken() != token) {
+ down = false;
+ }
+ /** @todo check tokens for upload connections */
+ }
+
+ if(down) {
aSource->setFlag(UserConnection::FLAG_DOWNLOAD);
addDownloadConnection(aSource);
} else {
@@ -617,6 +637,17 @@
}
}
+void ConnectionManager::force(const User::Ptr& aUser) {
+ Lock l(cs);
+
+ ConnectionQueueItem::Iter i = find(downloads.begin(), downloads.end(), aUser);
+ if(i == downloads.end()) {
+ return;
+ }
+
+ (*i)->setLastAttempt(0);
+}
+
void ConnectionManager::on(UserConnectionListener::Failed, UserConnection* aSource, const string& aError) throw() {
Lock l(cs);
Modified: dcplusplus/trunk/client/ConnectionManager.h
===================================================================
--- dcplusplus/trunk/client/ConnectionManager.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/ConnectionManager.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -48,7 +48,7 @@
ACTIVE // In one up/downmanager
};
- ConnectionQueueItem(const User::Ptr& aUser, bool aDownload) : state(WAITING), lastAttempt(0), download(aDownload), user(aUser) { }
+ ConnectionQueueItem(const User::Ptr& aUser, bool aDownload) : state(WAITING), lastAttempt(0), download(aDownload), token(Util::toString(Util::rand())), user(aUser) { }
User::Ptr& getUser() { return user; }
const User::Ptr& getUser() const { return user; }
@@ -56,6 +56,7 @@
GETSET(State, state, State);
GETSET(uint32_t, lastAttempt, LastAttempt);
GETSET(bool, download, Download);
+ GETSET(string, token, Token);
private:
ConnectionQueueItem(const ConnectionQueueItem&);
ConnectionQueueItem& operator=(const ConnectionQueueItem&);
@@ -103,10 +104,11 @@
expectedConnections.add(aNick, aMyNick, aHubUrl);
}
- void nmdcConnect(const string& aServer, short aPort, const string& aMyNick, const string& hubUrl);
- void adcConnect(const OnlineUser& aUser, short aPort, const string& aToken, bool secure);
+ void nmdcConnect(const string& aServer, uint16_t aPort, const string& aMyNick, const string& hubUrl);
+ void adcConnect(const OnlineUser& aUser, uint16_t aPort, const string& aToken, bool secure);
void getDownloadConnection(const User::Ptr& aUser);
+ void force(const User::Ptr& aUser);
void disconnect(const User::Ptr& aUser, int isDownload);
@@ -116,20 +118,20 @@
void listen() throw(SocketException);
void disconnect() throw();
- unsigned short getPort() { return server ? static_cast<unsigned short>(server->getPort()) : 0; }
- unsigned short getSecurePort() { return secureServer ? static_cast<unsigned short>(secureServer->getPort()) : 0; }
+ uint16_t getPort() { return server ? static_cast<uint16_t>(server->getPort()) : 0; }
+ uint16_t getSecurePort() { return secureServer ? static_cast<uint16_t>(secureServer->getPort()) : 0; }
private:
class Server : public Thread {
public:
- Server(bool secure_, short port, const string& ip = "0.0.0.0");
- short getPort() { return port; }
+ Server(bool secure_, uint16_t port, const string& ip = "0.0.0.0");
+ uint16_t getPort() { return port; }
virtual ~Server() { die = true; join(); }
private:
virtual int run() throw();
Socket sock;
- short port;
+ uint16_t port;
bool secure;
bool die;
};
Modified: dcplusplus/trunk/client/NmdcHub.cpp
===================================================================
--- dcplusplus/trunk/client/NmdcHub.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/NmdcHub.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -44,7 +44,7 @@
#define checkstate() if(state != STATE_NORMAL) return
-void NmdcHub::connect(const OnlineUser& aUser) {
+void NmdcHub::connect(const OnlineUser& aUser, const string&) {
checkstate();
dcdebug("NmdcHub::connect %s\n", aUser.getIdentity().getNick().c_str());
if(ClientManager::getInstance()->isActive()) {
@@ -417,7 +417,7 @@
return;
}
string port = param.substr(j+1);
- ConnectionManager::getInstance()->nmdcConnect(server, (unsigned short)Util::toInt(port), getMyNick(), getHubUrl());
+ ConnectionManager::getInstance()->nmdcConnect(server, static_cast<uint16_t>(Util::toInt(port)), getMyNick(), getHubUrl());
} else if(cmd == "$RevConnectToMe") {
if(state != STATE_NORMAL) {
return;
Modified: dcplusplus/trunk/client/NmdcHub.h
===================================================================
--- dcplusplus/trunk/client/NmdcHub.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/NmdcHub.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -39,7 +39,7 @@
using Client::send;
using Client::connect;
- virtual void connect(const OnlineUser& aUser);
+ virtual void connect(const OnlineUser& aUser, const string&);
virtual void hubMessage(const string& aMessage);
virtual void privateMessage(const OnlineUser& aUser, const string& aMessage);
Modified: dcplusplus/trunk/client/SSLSocket.cpp
===================================================================
--- dcplusplus/trunk/client/SSLSocket.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/SSLSocket.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -29,7 +29,7 @@
}
-void SSLSocket::connect(const string& aIp, short aPort) throw(SocketException) {
+void SSLSocket::connect(const string& aIp, uint16_t aPort) throw(SocketException) {
Socket::setBlocking(true);
Socket::connect(aIp, aPort);
Modified: dcplusplus/trunk/client/SSLSocket.h
===================================================================
--- dcplusplus/trunk/client/SSLSocket.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/SSLSocket.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -39,7 +39,7 @@
virtual ~SSLSocket() throw() {}
virtual void accept(const Socket& listeningSocket) throw(SocketException);
- virtual void connect(const string& aIp, short aPort) throw(SocketException);
+ virtual void connect(const string& aIp, uint16_t aPort) throw(SocketException);
virtual int read(void* aBuffer, int aBufLen) throw(SocketException);
virtual int write(const void* aBuffer, int aLen) throw(SocketException);
virtual int wait(uint32_t millis, int waitFor) throw(SocketException);
Modified: dcplusplus/trunk/client/SearchManager.cpp
===================================================================
--- dcplusplus/trunk/client/SearchManager.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/SearchManager.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -102,7 +102,7 @@
socket = new Socket();
socket->create(Socket::TYPE_UDP);
- port = socket->bind(static_cast<short>(SETTING(UDP_PORT)));
+ port = socket->bind(static_cast<uint16_t>(SETTING(UDP_PORT)));
start();
}
Modified: dcplusplus/trunk/client/SearchManager.h
===================================================================
--- dcplusplus/trunk/client/SearchManager.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/SearchManager.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -142,7 +142,7 @@
void respond(const AdcCommand& cmd, const CID& cid);
- unsigned short getPort()
+ uint16_t getPort()
{
return port;
}
@@ -166,7 +166,7 @@
private:
Socket* socket;
- unsigned short port;
+ uint16_t port;
bool stop;
uint32_t lastSearch;
friend class Singleton<SearchManager>;
Modified: dcplusplus/trunk/client/ServerSocket.cpp
===================================================================
--- dcplusplus/trunk/client/ServerSocket.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/ServerSocket.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -22,7 +22,7 @@
#include "ServerSocket.h"
#include "SettingsManager.h"
-void ServerSocket::listen(short aPort) throw(SocketException) {
+void ServerSocket::listen(uint16_t aPort) throw(SocketException) {
socket.disconnect();
socket.create(Socket::TYPE_TCP);
// Set reuse address option...
Modified: dcplusplus/trunk/client/ServerSocket.h
===================================================================
--- dcplusplus/trunk/client/ServerSocket.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/ServerSocket.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -39,7 +39,7 @@
public:
ServerSocket() throw() { }
- void listen(short port) throw(SocketException);
+ void listen(uint16_t port) throw(SocketException);
void disconnect() throw() { socket.disconnect(); }
/** This is called by windows whenever an "FD_ACCEPT" is sent...doesn't work with unix... */
Modified: dcplusplus/trunk/client/Socket.cpp
===================================================================
--- dcplusplus/trunk/client/Socket.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/Socket.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -26,7 +26,7 @@
#include "TimerManager.h"
string Socket::udpServer;
-short Socket::udpPort;
+uint16_t Socket::udpPort;
#define checkconnected() if(!isConnected()) throw SocketException(ENOTCONN))
@@ -97,7 +97,7 @@
}
-short Socket::bind(short aPort, const string& aIp /* = 0.0.0.0 */) throw (SocketException){
+uint16_t Socket::bind(uint16_t aPort, const string& aIp /* = 0.0.0.0 */) throw (SocketException){
sockaddr_in sock_addr;
sock_addr.sin_family = AF_INET;
@@ -118,7 +118,7 @@
connected = true;
}
-void Socket::connect(const string& aAddr, short aPort) throw(SocketException) {
+void Socket::connect(const string& aAddr, uint16_t aPort) throw(SocketException) {
sockaddr_in serv_addr;
if(sock == INVALID_SOCKET) {
@@ -149,7 +149,7 @@
}
}
-void Socket::socksConnect(const string& aAddr, short aPort, uint32_t timeout) throw(SocketException) {
+void Socket::socksConnect(const string& aAddr, uint16_t aPort, uint32_t timeout) throw(SocketException) {
if(SETTING(SOCKS_SERVER).empty() || SETTING(SOCKS_PORT) == 0) {
throw SocketException(STRING(SOCKS_FAILED));
@@ -160,7 +160,7 @@
uint32_t start = GET_TICK();
- connect(SETTING(SOCKS_SERVER), (short)SETTING(SOCKS_PORT));
+ connect(SETTING(SOCKS_SERVER), static_cast<uint16_t>(SETTING(SOCKS_PORT)));
if(wait(timeLeft(start, timeout), WAIT_CONNECT) != WAIT_CONNECT) {
throw SocketException(STRING(SOCKS_FAILED));
@@ -363,7 +363,7 @@
* @param aLen Data length
* @throw SocketExcpetion Send failed.
*/
-void Socket::writeTo(const string& aAddr, short aPort, const void* aBuffer, int aLen, bool proxy) throw(SocketException) {
+void Socket::writeTo(const string& aAddr, uint16_t aPort, const void* aBuffer, int aLen, bool proxy) throw(SocketException) {
if(aLen <= 0)
return;
@@ -530,7 +530,7 @@
try {
Socket s;
s.setBlocking(false);
- s.connect(SETTING(SOCKS_SERVER), (short)SETTING(SOCKS_PORT));
+ s.connect(SETTING(SOCKS_SERVER), static_cast<uint16_t>(SETTING(SOCKS_PORT)));
s.socksAuth(SOCKS_TIMEOUT);
char connStr[10];
@@ -553,7 +553,7 @@
return;
}
- udpPort = (short)ntohs(*((uint16_t*)(&connStr[8])));
+ udpPort = static_cast<uint16_t>(ntohs(*((uint16_t*)(&connStr[8]))));
in_addr serv_addr;
Modified: dcplusplus/trunk/client/Socket.h
===================================================================
--- dcplusplus/trunk/client/Socket.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/Socket.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -80,7 +80,7 @@
};
Socket() throw(SocketException) : sock(INVALID_SOCKET), connected(false), blocking(true) { }
- Socket(const string& aIp, short aPort) throw(SocketException) : sock(INVALID_SOCKET), connected(false), blocking(true) { connect(aIp, aPort); }
+ Socket(const string& aIp, uint16_t aPort) throw(SocketException) : sock(INVALID_SOCKET), connected(false), blocking(true) { connect(aIp, aPort); }
virtual ~Socket() throw() { Socket::disconnect(); }
/**
@@ -90,12 +90,12 @@
* @param aPort Server port.
* @throw SocketException If any connection error occurs.
*/
- virtual void connect(const string& aIp, short aPort) throw(SocketException);
- void connect(const string& aIp, const string& aPort) throw(SocketException) { connect(aIp, (short)Util::toInt(aPort)); }
+ virtual void connect(const string& aIp, uint16_t aPort) throw(SocketException);
+ void connect(const string& aIp, const string& aPort) throw(SocketException) { connect(aIp, static_cast<uint16_t>(Util::toInt(aPort))); }
/**
* Same as connect(), but through the SOCKS5 server
*/
- void socksConnect(const string& aIp, short aPort, uint32_t timeout = 0) throw(SocketException);
+ void socksConnect(const string& aIp, uint16_t aPort, uint32_t timeout = 0) throw(SocketException);
/**
* Sends data, will block until all data has been sent or an exception occurs
@@ -106,8 +106,8 @@
void writeAll(const void* aBuffer, int aLen, uint32_t timeout = 0) throw(SocketException);
virtual int write(const void* aBuffer, int aLen) throw(SocketException);
int write(const string& aData) throw(SocketException) { return write(aData.data(), (int)aData.length()); }
- virtual void writeTo(const string& aIp, short aPort, const void* aBuffer, int aLen, bool proxy = true) throw(SocketException);
- void writeTo(const string& aIp, short aPort, const string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), (int)aData.length()); }
+ virtual void writeTo(const string& aIp, uint16_t aPort, const void* aBuffer, int aLen, bool proxy = true) throw(SocketException);
+ void writeTo(const string& aIp, uint16_t aPort, const string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), (int)aData.length()); }
virtual void shutdown() throw();
virtual void close() throw();
void disconnect() throw();
@@ -169,7 +169,7 @@
virtual void create(int aType = TYPE_TCP) throw(SocketException);
/** Binds a socket to a certain local port and possibly IP. */
- virtual short bind(short aPort = 0, const string& aIp = "0.0.0.0") throw(SocketException);
+ virtual uint16_t bind(uint16_t aPort = 0, const string& aIp = "0.0.0.0") throw(SocketException);
virtual void listen() throw(SocketException);
virtual void accept(const Socket& listeningSocket) throw(SocketException);
@@ -197,7 +197,7 @@
static Stats stats;
static string udpServer;
- static short udpPort;
+ static uint16_t udpPort;
private:
Socket(const Socket&);
@@ -208,8 +208,8 @@
#ifdef _WIN32
static int getLastError() { return ::WSAGetLastError(); }
- static int checksocket(socket_t ret) {
- if(ret == (socket_t) SOCKET_ERROR) {
+ static int checksocket(int ret) {
+ if(ret == SOCKET_ERROR) {
throw SocketException(getLastError());
}
return ret;
Modified: dcplusplus/trunk/client/UploadManager.cpp
===================================================================
--- dcplusplus/trunk/client/UploadManager.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/UploadManager.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -271,7 +271,7 @@
reservedSlots.insert(aUser);
}
if(aUser->isOnline())
- ClientManager::getInstance()->connect(aUser);
+ ClientManager::getInstance()->connect(aUser, Util::toString(Util::rand()));
}
void UploadManager::on(UserConnectionListener::Get, UserConnection* aSource, const string& aFile, int64_t aResume) throw() {
Modified: dcplusplus/trunk/client/UserConnection.cpp
===================================================================
--- dcplusplus/trunk/client/UserConnection.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/UserConnection.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -191,7 +191,7 @@
}
}
-void UserConnection::connect(const string& aServer, short aPort) throw(SocketException, ThreadException) {
+void UserConnection::connect(const string& aServer, uint16_t aPort) throw(SocketException, ThreadException) {
dcassert(!socket);
socket = BufferedSocket::getSocket(0);
Modified: dcplusplus/trunk/client/UserConnection.h
===================================================================
--- dcplusplus/trunk/client/UserConnection.h 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/UserConnection.h 2006-12-13 17:10:06 UTC (rev 687)
@@ -279,7 +279,7 @@
void setDataMode(int64_t aBytes = -1) { dcassert(socket); socket->setDataMode(aBytes); }
void setLineMode(size_t rollback) { dcassert(socket); socket->setLineMode(rollback); }
- void connect(const string& aServer, short aPort) throw(SocketException, ThreadException);
+ void connect(const string& aServer, uint16_t aPort) throw(SocketException, ThreadException);
void accept(const Socket& aServer) throw(SocketException, ThreadException);
void disconnect(bool graceless = false) { if(socket) socket->disconnect(graceless); }
Modified: dcplusplus/trunk/client/Util.cpp
===================================================================
--- dcplusplus/trunk/client/Util.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client/Util.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -313,9 +313,9 @@
if( (k=url.find(':', i)) != string::npos) {
// Port
if(j == string::npos) {
- aPort = (short)Util::toInt(url.substr(k+1));
+ aPort = static_cast<uint16_t>(Util::toInt(url.substr(k+1)));
} else if(k < j) {
- aPort = (short)Util::toInt(url.substr(k+1, j-k-1));
+ aPort = static_cast<uint16_t>(Util::toInt(url.substr(k+1, j-k-1)));
}
} else {
k = j;
Modified: dcplusplus/trunk/client.vcproj
===================================================================
--- dcplusplus/trunk/client.vcproj 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/client.vcproj 2006-12-13 17:10:06 UTC (rev 687)
@@ -143,6 +143,7 @@
AssemblerOutput="4"
WarningLevel="4"
SuppressStartupBanner="true"
+ Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="1"
DisableSpecificWarnings="4996"
Modified: dcplusplus/trunk/help/help.vcproj
===================================================================
--- dcplusplus/trunk/help/help.vcproj 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/help/help.vcproj 2006-12-13 17:10:06 UTC (rev 687)
@@ -253,6 +253,10 @@
>
</File>
<File
+ RelativePath=".\settings_tabs.html"
+ >
+ </File>
+ <File
RelativePath=".\template.html"
>
</File>
Modified: dcplusplus/trunk/windows/SearchFrm.cpp
===================================================================
--- dcplusplus/trunk/windows/SearchFrm.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/windows/SearchFrm.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -287,6 +287,7 @@
}
if ((*si)[0] != _T('-'))
s += *si + _T(' ');
+ ++si;
}
s = s.substr(0, max(s.size(), static_cast<tstring::size_type>(1)) - 1);
Modified: dcplusplus/trunk/windows/TransferView.cpp
===================================================================
--- dcplusplus/trunk/windows/TransferView.cpp 2006-12-07 22:44:50 UTC (rev 686)
+++ dcplusplus/trunk/windows/TransferView.cpp 2006-12-13 17:10:06 UTC (rev 687)
@@ -156,7 +156,7 @@
int i = -1;
while( (i = ctrlTransfers.GetNextItem(i, LVNI_SELECTED)) != -1) {
ctrlTransfers.SetItemText(i, COLUMN_STATUS, CTSTRING(CONNECTING_FORCED));
- ClientManager::getInstance()->connect(((ItemInfo*)ctrlTransfers.getItemData(i))->user);
+ ConnectionManager::getInstance()->force(ctrlTransfers.getItemData(i)->user);
}
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|