From: <arn...@us...> - 2006-06-18 16:50:28
|
Revision: 620 Author: arnetheduck Date: 2006-06-18 09:50:11 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=620&view=rev Log Message: ----------- Reconnect fixes Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/windows/HubFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/changelog.txt 2006-06-18 16:50:11 UTC (rev 620) @@ -22,6 +22,7 @@ * [ADC] Allowed $ and | in nick/description * Fixed targetdrive bug for temp target location * Fixed a crash bug when hash data cannot be saved +* Possibly fixed issues with queue items not being updated -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -354,12 +354,6 @@ } } -void AdcHub::disconnect(bool graceless) { - Client::disconnect(graceless); - state = STATE_PROTOCOL; - clearUsers(); -} - void AdcHub::hubMessage(const string& aMessage) { if(state != STATE_NORMAL) return; @@ -545,6 +539,8 @@ void AdcHub::on(Failed, const string& aLine) throw() { clearUsers(); + socket->removeListener(this); + state = STATE_PROTOCOL; fire(ClientListener::Failed(), this, aLine); } @@ -557,3 +553,10 @@ sendUDP(cmd); send(cmd.toString(sid)); } + +void AdcHub::on(Second, u_int32_t aTick) throw() { + if(getAutoReconnect() && state == STATE_PROTOCOL && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + // Try to reconnect... + connect(); + } +} Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/AdcHub.h 2006-06-18 16:50:11 UTC (rev 620) @@ -33,10 +33,10 @@ class AdcHub : public Client, public CommandHandler<AdcHub> { public: using Client::send; + using Client::connect; virtual void connect(const OnlineUser& user); void connect(const OnlineUser& user, string const& token, bool secure); - virtual void disconnect(bool graceless); virtual void hubMessage(const string& aMessage); virtual void privateMessage(const OnlineUser& user, const string& aMessage); @@ -119,6 +119,8 @@ virtual void on(Connected) throw(); virtual void on(Line, const string& aLine) throw(); virtual void on(Failed, const string& aLine) throw(); + + virtual void on(Second, u_int32_t aTick) throw(); }; #endif // !defined(ADC_HUB_H) Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -459,6 +459,16 @@ return 0; } +void BufferedSocket::fail(const string& aError) { + if(sock) { + sock->disconnect(); + } + if(!failed) { + failed = true; + fire(BufferedSocketListener::Failed(), aError); + } +} + void BufferedSocket::shutdown() { if(sock) { Lock l(cs); Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-06-18 16:50:11 UTC (rev 620) @@ -170,13 +170,7 @@ void threadSendData(); void threadDisconnect(); - void fail(const string& aError) { - if(sock) - sock->disconnect(); - fire(BufferedSocketListener::Failed(), aError); - failed = true; - } - + void fail(const string& aError); static size_t sockets; bool checkEvents(); Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/Client.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -109,7 +109,6 @@ void Client::disconnect(bool graceLess) { if(!socket) return; - socket->removeListener(this); socket->disconnect(graceLess); } @@ -158,9 +157,5 @@ return lip; } -void Client::on(Second, u_int32_t aTick) throw() { - if(getAutoReconnect() && !isConnected() && (getLastActivity() + getReconnDelay() * 1000) < aTick) { - // Try to reconnect... - connect(); - } +void Client::on(Second, u_int32_t) throw() { } Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -296,9 +296,9 @@ return; int type = Util::toInt(param.substr(i, j-i)) - 1; i = j + 1; - string terms = param.substr(i); + string terms = unescape(param.substr(i)); - if(param.size() > 0) { + if(terms.size() > 0) { if(seeker.compare(0, 4, "Hub:") == 0) { OnlineUser* u = findUser(seeker.substr(4)); @@ -312,7 +312,7 @@ } } - fire(ClientListener::NmdcSearch(), this, seeker, a, Util::toInt64(size), type, param); + fire(ClientListener::NmdcSearch(), this, seeker, a, Util::toInt64(size), type, terms); } } else if(cmd == "$MyINFO") { string::size_type i, j; @@ -760,18 +760,12 @@ } } -void NmdcHub::disconnect(bool graceless) throw() { - Client::disconnect(graceless); - state = STATE_CONNECT; - clearUsers(); -} - void NmdcHub::search(int aSizeType, int64_t aSize, int aFileType, const string& aString, const string&) { checkstate(); AutoArray<char> buf((char*)NULL); char c1 = (aSizeType == SearchManager::SIZE_DONTCARE) ? 'F' : 'T'; char c2 = (aSizeType == SearchManager::SIZE_ATLEAST) ? 'F' : 'T'; - string tmp = toAcp(escape((aFileType == SearchManager::TYPE_TTH) ? "TTH:" + aString : aString)); + string tmp = ((aFileType == SearchManager::TYPE_TTH) ? "TTH:" + aString : toAcp(escape(aString))); string::size_type i; while((i = tmp.find(' ')) != string::npos) { tmp[i] = '$'; @@ -866,12 +860,15 @@ // TimerManagerListener void NmdcHub::on(Second, u_int32_t aTick) throw() { - - if(isConnected() && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + if(state == STATE_CONNECTED && (getLastActivity() + getReconnDelay() * 1000) < aTick) { // Try to send something for the fun of it... dcdebug("Testing writing...\n"); send("|", 1); + } else if(getAutoReconnect() && state == STATE_CONNECT && (getLastActivity() + getReconnDelay() * 1000) < aTick) { + // Try to reconnect... + connect(); } + { Lock l(cs); @@ -891,6 +888,8 @@ void NmdcHub::on(BufferedSocketListener::Failed, const string& aLine) throw() { clearUsers(); + socket->removeListener(this); + if(state == STATE_CONNECTED) state = STATE_CONNECT; Modified: dcplusplus/trunk/client/NmdcHub.h =================================================================== --- dcplusplus/trunk/client/NmdcHub.h 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/client/NmdcHub.h 2006-06-18 16:50:11 UTC (rev 620) @@ -40,7 +40,6 @@ virtual void connect(); virtual void connect(const OnlineUser& aUser); - virtual void disconnect(bool graceless) throw(); virtual void hubMessage(const string& aMessage); virtual void privateMessage(const OnlineUser& aUser, const string& aMessage); Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 15:13:10 UTC (rev 619) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 16:50:11 UTC (rev 620) @@ -1415,9 +1415,10 @@ ctrlUsers.insertItem(i->second, getImage(i->second->getIdentity())); } } else { - for(UserMapIter i = userMap.begin(); i != userMap.end(); ++i){ - if(!ui->isHidden() && matchFilter(*i->second, sel, doSizeCompare, mode, size)) { - ctrlUsers.insertItem(i->second, getImage(i->second->getIdentity())); + for(UserMapIter i = userMap.begin(); i != userMap.end(); ++i) { + UserInfo* ui = i->second; + if(!ui->isHidden() && matchFilter(*ui, sel, doSizeCompare, mode, size)) { + ctrlUsers.insertItem(ui, getImage(ui->getIdentity())); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |