From: <arn...@us...> - 2006-06-18 15:13:39
|
Revision: 619 Author: arnetheduck Date: 2006-06-18 08:13:10 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=619&view=rev Log Message: ----------- More cleanup Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/DCPlusPlus.cpp dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/File.h dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/StringDefs.cpp dcplusplus/trunk/client/StringDefs.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/windows/CommandDlg.cpp dcplusplus/trunk/windows/CommandDlg.h dcplusplus/trunk/windows/FlatTabCtrl.h dcplusplus/trunk/windows/GeneralPage.cpp dcplusplus/trunk/windows/GeneralPage.h dcplusplus/trunk/windows/HubFrame.cpp Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/Example.xml 2006-06-18 15:13:10 UTC (rev 619) @@ -112,6 +112,7 @@ <String Name="ErrorCreatingRegistryKeyDchub">Error creating dchub registry key</String> <String Name="ErrorCreatingRegistryKeyMagnet">Error creating magnet registry key</String> <String Name="ErrorHashing">Error hashing </String> + <String Name="ErrorSavingHash">Error saving hash data: </String> <String Name="ExactSize">Exact size</String> <String Name="Executable">Executable</String> <String Name="FavJoinShowingOff">Join/part of favorite users showing off</String> Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/changelog.txt 2006-06-18 15:13:10 UTC (rev 619) @@ -17,7 +17,11 @@ * Fixed auto-reconnect * [bug 936] Fixed duplicate entries in search hubs * Fixed some hub title display issues -* Some code spring cleanup +* Some spring cleanup +* [bug 970] Unix file permissions correctly set (thanks steven sheehy) +* [ADC] Allowed $ and | in nick/description +* Fixed targetdrive bug for temp target location +* Fixed a crash bug when hash data cannot be saved -- 0.691 2006-06-03 -- * Links to bugzilla in html changelog Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -133,7 +133,7 @@ u->getUser()->setFlag(User::SSL); } - if(u->getUser() == ClientManager::getInstance()->getMe()) { + if(u->getUser() == getMyIdentity().getUser()) { state = STATE_NORMAL; setMyIdentity(u->getIdentity()); updateCounts(false); @@ -519,9 +519,10 @@ string AdcHub::checkNick(const string& aNick) { string tmp = aNick; - string::size_type i = 0; - while( (i = tmp.find_first_of(" ", i)) != string::npos) { - tmp[i++]='_'; + for(size_t i = 0; i < aNick.size(); ++i) { + if(tmp[i] <= 32) { + tmp[i] = '_'; + } } return tmp; } Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/Client.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -74,7 +74,9 @@ } setPassword(hub->getPassword()); } else { - setCurrentNick(checkNick(SETTING(NICK))); + if(updateNick) { + setCurrentNick(checkNick(SETTING(NICK))); + } setCurrentDescription(SETTING(DESCRIPTION)); } } @@ -87,7 +89,7 @@ setReconnDelay(120 + Util::rand(0, 60)); reloadSettings(true); setRegistered(false); - setMyIdentity(Identity()); + setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0)); setHubIdentity(Identity()); try { Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -61,18 +61,7 @@ { Lock l(cs); - - // Either I'm stupid or the msvc7 optimizer is doing something _very_ strange here... - // STL-port -D_STL_DEBUG complains that .begin() and .end() don't have the same owner (!) - // dcassert(find(clients.begin(), clients.end(), aClient) != clients.end()); - // clients.erase(find(clients.begin(), clients.end(), aClient)); - - for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { - if(*i == aClient) { - clients.erase(i); - break; - } - } + clients.erase(remove(clients.begin(), clients.end(), aClient), clients.end()); } delete aClient; } Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -122,10 +122,10 @@ fire(ConnectionManagerListener::Removed(), cqi); if(cqi->getDownload()) { dcassert(find(downloads.begin(), downloads.end(), cqi) != downloads.end()); - downloads.erase(find(downloads.begin(), downloads.end(), cqi)); + downloads.erase(remove(downloads.begin(), downloads.end(), cqi), downloads.end()); } else { dcassert(find(uploads.begin(), uploads.end(), cqi) != uploads.end()); - uploads.erase(find(uploads.begin(), uploads.end(), cqi)); + uploads.erase(remove(uploads.begin(), uploads.end(), cqi), uploads.end()); } delete cqi; } Modified: dcplusplus/trunk/client/DCPlusPlus.cpp =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/DCPlusPlus.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -36,6 +36,13 @@ #include "StringTokenizer.h" +#ifdef _STLP_DEBUG +void __stl_debug_terminate() { + int* x = 0; + *x = 0; +} +#endif + void startup(void (*f)(void*, const string&), void* p) { // "Dedicated to the near-memory of Nev. Let's start remembering people while they're still alive." // Nev's great contribution to dc++ Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -86,46 +86,53 @@ return cmd; } -void DownloadManager::on(TimerManagerListener::Second, u_int32_t /*aTick*/) throw() { - Lock l(cs); +void DownloadManager::on(TimerManagerListener::Second, u_int32_t aTick) throw() { + typedef vector<pair<string, User::Ptr> > TargetList; + TargetList dropTargets; - Download::List tickList; - // Tick each ongoing download - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - if((*i)->getTotal() > 0) { - tickList.push_back(*i); + { + Lock l(cs); + + Download::List tickList; + // Tick each ongoing download + for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { + if((*i)->getTotal() > 0) { + tickList.push_back(*i); + } } - } - if(tickList.size() > 0) - fire(DownloadManagerListener::Tick(), tickList); + if(tickList.size() > 0) + fire(DownloadManagerListener::Tick(), tickList); + - // Automatically remove or disconnect slow sources - if((u_int32_t)(GET_TICK() / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - u_int32_t timeElapsed = GET_TICK() - (*i)->getStart(); - u_int32_t timeInactive = GET_TICK() - (*i)->getUserConnection()->getLastActivity(); - u_int64_t bytesDownloaded = (*i)->getTotal(); - bool timeElapsedOk = timeElapsed >= (u_int32_t)SETTING(AUTODROP_ELAPSED) * 1000; - bool timeInactiveOk = timeInactive <= (u_int32_t)SETTING(AUTODROP_INACTIVITY) * 1000; - bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ? - bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; - bool onlineSourcesOk = (*i)->isSet(Download::FLAG_USER_LIST) ? - true : QueueManager::getInstance()->countOnlineSources((*i)->getTarget()) >= SETTING(AUTODROP_MINSOURCES); - bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((size_t)SETTING(AUTODROP_FILESIZE)) * 1024; - bool dropIt = ((*i)->isSet(Download::FLAG_USER_LIST) && BOOLSETTING(AUTODROP_FILELISTS)) || - (filesizeOk && BOOLSETTING(AUTODROP_ALL)); - if(speedTooLow && onlineSourcesOk && dropIt) { - if(BOOLSETTING(AUTODROP_DISCONNECT) && !((*i)->isSet(Download::FLAG_USER_LIST))) { - (*i)->getUserConnection()->disconnect(); - } else { - QueueManager::getInstance()->removeSource((*i)->getTarget(), - (*i)->getUserConnection()->getUser(), QueueItem::Source::FLAG_SLOW_SOURCE); + // Automatically remove or disconnect slow sources + if((u_int32_t)(aTick / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { + for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { + u_int32_t timeElapsed = GET_TICK() - (*i)->getStart(); + u_int32_t timeInactive = GET_TICK() - (*i)->getUserConnection()->getLastActivity(); + u_int64_t bytesDownloaded = (*i)->getTotal(); + bool timeElapsedOk = timeElapsed >= (u_int32_t)SETTING(AUTODROP_ELAPSED) * 1000; + bool timeInactiveOk = timeInactive <= (u_int32_t)SETTING(AUTODROP_INACTIVITY) * 1000; + bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ? + bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; + bool onlineSourcesOk = (*i)->isSet(Download::FLAG_USER_LIST) ? + true : QueueManager::getInstance()->countOnlineSources((*i)->getTarget()) >= SETTING(AUTODROP_MINSOURCES); + bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((size_t)SETTING(AUTODROP_FILESIZE)) * 1024; + bool dropIt = ((*i)->isSet(Download::FLAG_USER_LIST) && BOOLSETTING(AUTODROP_FILELISTS)) || + (filesizeOk && BOOLSETTING(AUTODROP_ALL)); + if(speedTooLow && onlineSourcesOk && dropIt) { + if(BOOLSETTING(AUTODROP_DISCONNECT) && !((*i)->isSet(Download::FLAG_USER_LIST))) { + (*i)->getUserConnection()->disconnect(); + } else { + dropTargets.push_back(make_pair((*i)->getTarget(), (*i)->getUserConnection()->getUser())); + } } - continue; } } } + for(TargetList::iterator i = dropTargets.begin(); i != dropTargets.end(); ++i) { + QueueManager::getInstance()->removeSource(i->first, i->second, QueueItem::Source::FLAG_SLOW_SOURCE); + } } void DownloadManager::FileMover::moveFile(const string& source, const string& target) { @@ -237,7 +244,7 @@ Download* d = QueueManager::getInstance()->getDownload(aConn->getUser(), aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL)); - if(d == NULL) { + if(!d) { Lock l(cs); idlers.push_back(aConn); return; @@ -499,19 +506,11 @@ file->setPos(d->getPos()); } catch(const FileException& e) { delete file; - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, STRING(COULD_NOT_OPEN_TARGET_FILE) + e.getError()); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, STRING(COULD_NOT_OPEN_TARGET_FILE) + e.getError()); return false; } catch(const Exception& e) { delete file; - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, e.getError()); return false; } @@ -572,34 +571,16 @@ aSource->setLineMode(0); } } catch(const RollbackException& e) { - string target = d->getTarget(); - QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_ROLLBACK_INCONSISTENCY); - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - + QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_ROLLBACK_INCONSISTENCY); d->resetPos(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); - return; + failDownload(aSource, e.getError()); } catch(const FileException& e) { - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - d->resetPos(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); - return; + failDownload(aSource, e.getError()); } catch(const Exception& e) { - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); // Nuke the bytes we have written, this is probably a compression error d->resetPos(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); - return; + failDownload(aSource, e.getError()); } } @@ -626,12 +607,11 @@ removeDownload(d); fire(DownloadManagerListener::Failed(), d, STRING(INVALID_TREE)); - string target = d->getTarget(); + QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_BAD_TREE, false); aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, false); - QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_BAD_TREE, false); checkDownloads(aSource); return; } @@ -663,12 +643,7 @@ } } } catch(const FileException& e) { - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, e.getError()); - - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, e.getError()); return; } @@ -733,12 +708,10 @@ removeDownload(d); fire(DownloadManagerListener::Failed(), d, STRING(SFV_INCONSISTENCY)); - string target = d->getTarget(); - + QueueManager::getInstance()->removeSource(d->getTarget(), aSource->getUser(), QueueItem::Source::FLAG_CRC_WARN, false); aSource->setDownload(NULL); QueueManager::getInstance()->putDownload(d, false); - QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_CRC_WARN, false); checkDownloads(aSource); return false; } @@ -814,31 +787,23 @@ return; } - Download* d = aSource->getDownload(); - dcassert(d != NULL); - - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, STRING(NO_SLOTS_AVAILABLE)); - - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); - removeConnection(aSource); + failDownload(aSource, STRING(NO_SLOTS_AVAILABLE)); } void DownloadManager::on(UserConnectionListener::Failed, UserConnection* aSource, const string& aError) throw() { + failDownload(aSource, aError); +} + +void DownloadManager::failDownload(UserConnection* aSource, const string& reason) { Download* d = aSource->getDownload(); - if(d == NULL) { - removeConnection(aSource); - return; - } - - removeDownload(d); - fire(DownloadManagerListener::Failed(), d, aError); + if(d) { + removeDownload(d); + fire(DownloadManagerListener::Failed(), d, reason); - string target = d->getTarget(); - aSource->setDownload(NULL); - QueueManager::getInstance()->putDownload(d, false); + aSource->setDownload(0); + QueueManager::getInstance()->putDownload(d, false); + } removeConnection(aSource); } @@ -855,7 +820,6 @@ d->setCrcCalc(NULL); if(d->isSet(Download::FLAG_ANTI_FRAG)) { - // Ok, set the pos to whereever it was last writing and hope for the best... d->unsetFlag(Download::FLAG_ANTI_FRAG); } } @@ -868,29 +832,17 @@ dcassert(find(downloads.begin(), downloads.end(), d) != downloads.end()); - // downloads.erase(find(downloads.begin(), downloads.end(), d)); + downloads.erase(remove(downloads.begin(), downloads.end(), d), downloads.end()); - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { +/* for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { if(*i == d) { downloads.erase(i); break; } - } + }*/ } } -void DownloadManager::abortDownload(const string& aTarget) { - Lock l(cs); - for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - Download* d = *i; - if(d->getTarget() == aTarget) { - dcassert(d->getUserConnection() != NULL); - d->getUserConnection()->disconnect(); - break; - } - } -} - void DownloadManager::on(UserConnectionListener::FileNotAvailable, UserConnection* aSource) throw() { fileNotAvailable(aSource); } @@ -930,12 +882,6 @@ dcassert(d != NULL); dcdebug("File Not Available: %s\n", d->getTarget().c_str()); - if(d->getFile()) { - delete d->getFile(); - d->setFile(NULL); - d->setCrcCalc(NULL); - } - removeDownload(d); fire(DownloadManagerListener::Failed(), d, d->getTargetFileName() + ": " + STRING(FILE_NOT_AVAILABLE)); Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/DownloadManager.h 2006-06-18 15:13:10 UTC (rev 619) @@ -181,9 +181,6 @@ void checkIdle(const User::Ptr& user); - /** @internal */ - void abortDownload(const string& aTarget); - /** * @remarks This is only used in the tray icons. In MainFrame this is * calculated instead so there seems to be a little duplication of code. @@ -242,6 +239,8 @@ bool checkSfv(UserConnection* aSource, Download* d, u_int32_t crc); int64_t getResumePos(const string& file, const TigerTree& tt, int64_t startPos); + void failDownload(UserConnection* aSource, const string& reason); + friend class Singleton<DownloadManager>; DownloadManager() { TimerManager::getInstance()->addListener(this); Modified: dcplusplus/trunk/client/File.h =================================================================== --- dcplusplus/trunk/client/File.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/File.h 2006-06-18 15:13:10 UTC (rev 619) @@ -246,7 +246,7 @@ if(mode & TRUNCATE) { m |= O_TRUNC; } - h = open(aFileName.c_str(), m, S_IRUSR | S_IWUSR); + h = open(aFileName.c_str(), m, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if(h == -1) throw FileException("Could not open file"); } @@ -390,7 +390,7 @@ string acp = Text::utf8ToAcp(aFile); string::size_type start = 0; while( (start = aFile.find_first_of(L'/', start)) != string::npos) { - mkdir(aFile.substr(0, start+1).c_str(), 0755); + mkdir(aFile.substr(0, start+1).c_str(), S_IRWXU | S_IRWXG | S_IRWXO); start++; } } Modified: dcplusplus/trunk/client/HashManager.cpp =================================================================== --- dcplusplus/trunk/client/HashManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/HashManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -97,16 +97,20 @@ dirty = true; } -void HashManager::HashStore::addTree(const TigerTree& tt) { +void HashManager::HashStore::addTree(const TigerTree& tt) throw() { if(treeIndex.find(tt.getRoot()) == treeIndex.end()) { - File f(getDataFile(), File::READ|File::WRITE, File::OPEN); - int64_t index = saveTree(f, tt); - treeIndex.insert(make_pair(tt.getRoot(), TreeInfo(tt.getFileSize(), index, tt.getBlockSize()))); - dirty = true; + try { + File f(getDataFile(), File::READ|File::WRITE, File::OPEN); + int64_t index = saveTree(f, tt); + treeIndex.insert(make_pair(tt.getRoot(), TreeInfo(tt.getFileSize(), index, tt.getBlockSize()))); + dirty = true; + } catch(const FileException& e) { + LogManager::getInstance()->message(STRING(ERROR_SAVING_HASH) + e.getError()); + } } } -int64_t HashManager::HashStore::saveTree(File& f, const TigerTree& tt) { +int64_t HashManager::HashStore::saveTree(File& f, const TigerTree& tt) throw(FileException) { if(tt.getLeaves().size() == 1) return SMALL_TREE; @@ -310,8 +314,8 @@ File::renameFile(getIndexFile() + ".tmp", getIndexFile()); dirty = false; - } catch(const FileException&) { - // Too bad... + } catch(const FileException& e) { + LogManager::getInstance()->message(STRING(ERROR_SAVING_HASH) + e.getError()); } } } Modified: dcplusplus/trunk/client/HashManager.h =================================================================== --- dcplusplus/trunk/client/HashManager.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/HashManager.h 2006-06-18 15:13:10 UTC (rev 619) @@ -48,6 +48,7 @@ }; class HashLoader; +class FileException; class HashManager : public Singleton<HashManager>, public Speaker<HashManagerListener>, private TimerManagerListener @@ -194,7 +195,7 @@ bool checkTTH(const string& aFileName, int64_t aSize, u_int32_t aTimeStamp); - void addTree(const TigerTree& tt); + void addTree(const TigerTree& tt) throw(); const TTHValue* getTTH(const string& aFileName); bool getTree(const TTHValue& root, TigerTree& tth); bool isDirty() { return dirty; } @@ -244,7 +245,7 @@ void createDataFile(const string& name); bool loadTree(File& dataFile, const TreeInfo& ti, const TTHValue& root, TigerTree& tt); - int64_t saveTree(File& dataFile, const TigerTree& tt); + int64_t saveTree(File& dataFile, const TigerTree& tt) throw(FileException); string getIndexFile() { return Util::getConfigPath() + "HashIndex.xml"; } string getDataFile() { return Util::getConfigPath() + "HashData.dat"; } Modified: dcplusplus/trunk/client/NmdcHub.cpp =================================================================== --- dcplusplus/trunk/client/NmdcHub.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/NmdcHub.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -84,7 +84,7 @@ } User::Ptr p; - if(aNick == getMyNick()) { + if(aNick == getCurrentNick()) { p = ClientManager::getInstance()->getMe(); } else { p = ClientManager::getInstance()->getUser(aNick, getHubUrl()); @@ -524,13 +524,14 @@ } key(CryptoManager::getInstance()->makeKey(lock)); - validateNick(getMyNick()); + OnlineUser& ou = getUser(getCurrentNick()); + validateNick(ou.getIdentity().getNick()); } } else if(cmd == "$Hello") { if(!param.empty()) { OnlineUser& u = getUser(param); - if(getMyNick() == param) { + if(u.getUser() == getMyIdentity().getUser()) { u.getUser()->setFlag(User::DCPLUSPLUS); if(ClientManager::getInstance()->isActive()) u.getUser()->unsetFlag(User::PASSIVE); @@ -538,7 +539,7 @@ u.getUser()->setFlag(User::PASSIVE); } - if(state == STATE_HELLO) { + if(state == STATE_HELLO && u.getUser() == getMyIdentity().getUser()) { state = STATE_CONNECTED; updateCounts(false); @@ -689,9 +690,10 @@ string NmdcHub::checkNick(const string& aNick) { string tmp = aNick; - string::size_type i = 0; - while( (i = tmp.find_first_of("|$ ", i)) != string::npos) { - tmp[i++]='_'; + for(size_t i = 0; i < aNick.size(); ++i) { + if(tmp[i] <= 32 || tmp[i] == '|' || tmp[i] == '$' || tmp[i] == '<' || tmp[i] == '>') { + tmp[i] = '_'; + } } return tmp; } @@ -745,7 +747,7 @@ string uMin = (SETTING(MIN_UPLOAD_SPEED) == 0) ? Util::emptyString : tmp5 + Util::toString(SETTING(MIN_UPLOAD_SPEED)); string myInfoA = - "$MyINFO $ALL " + toAcp(getCurrentNick()) + " " + toAcp(escape(getCurrentDescription())) + + "$MyINFO $ALL " + toAcp(getMyNick()) + " " + toAcp(escape(getCurrentDescription())) + tmp1 + VERSIONSTRING + tmp2 + modeChar + tmp3 + getCounts() + tmp4 + Util::toString(SETTING(SLOTS)) + uMin + ">$ $" + SETTING(UPLOAD_SPEED) + "\x01$" + toAcp(escape(SETTING(EMAIL))) + '$'; string myInfoB = ShareManager::getInstance()->getShareSizeString() + "$|"; Modified: dcplusplus/trunk/client/QueueItem.h =================================================================== --- dcplusplus/trunk/client/QueueItem.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/QueueItem.h 2006-06-18 15:13:10 UTC (rev 619) @@ -204,8 +204,6 @@ } } - string getSearchString() const; - const string& getTempTarget(); void setTempTarget(const string& aTempTarget) { tempTarget = aTempTarget; Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -62,9 +62,6 @@ return tmp; } } -string QueueItem::getSearchString() const { - return SearchManager::clean(getTargetFileName()); -} const string& QueueItem::getTempTarget() { if(!isSet(QueueItem::FLAG_USER_LIST) && tempTarget.empty()) { @@ -75,7 +72,7 @@ sm["targetdrive"] = target.substr(0, 3); else sm["targetdrive"] = Util::getConfigPath().substr(0, 3); - setTempTarget(Util::formatParams(SETTING(TEMP_DOWNLOAD_DIRECTORY), sm, true) + getTempName(getTargetFileName(), getTTH())); + setTempTarget(Util::formatParams(SETTING(TEMP_DOWNLOAD_DIRECTORY), sm, false) + getTempName(getTargetFileName(), getTTH())); #else //_WIN32 setTempTarget(SETTING(TEMP_DOWNLOAD_DIRECTORY) + getTempName(getTargetFileName(), getTTH())); #endif //_WIN32 @@ -219,9 +216,9 @@ } void QueueManager::UserQueue::add(QueueItem* qi, const User::Ptr& aUser) { - dcassert(qi->getStatus() == QueueItem::STATUS_WAITING); - dcassert(qi->isSource(aUser)); - dcassert(qi->getCurrent() == NULL); + if(qi->getStatus() == QueueItem::STATUS_RUNNING) { + return; + } QueueItem::List& l = userQueue[qi->getPriority()][aUser]; if(qi->isSet(QueueItem::FLAG_EXISTS)) { @@ -247,7 +244,8 @@ } void QueueManager::UserQueue::setRunning(QueueItem* qi, const User::Ptr& aUser) { - dcassert(qi->getCurrent() == NULL); + dcassert(qi->getCurrent() == 0); + dcassert(qi->getCurrentDownload() == 0); dcassert(qi->getStatus() == QueueItem::STATUS_WAITING); // Remove the download from the userQueue... @@ -260,13 +258,12 @@ // Move the download to the running list... dcassert(running.find(aUser) == running.end()); running[aUser] = qi; - } void QueueManager::UserQueue::setWaiting(QueueItem* qi) { - dcassert(qi->getCurrentDownload() != NULL); - dcassert(qi->getCurrent() != NULL); dcassert(qi->getStatus() == QueueItem::STATUS_RUNNING); + dcassert(qi->getCurrentDownload() != 0); + dcassert(qi->getCurrent() != 0); dcassert(running.find(qi->getCurrent()->getUser()) != running.end()); // Remove the download from running @@ -274,8 +271,8 @@ // Set flag to waiting qi->setStatus(QueueItem::STATUS_WAITING); - qi->setCurrent(NULL); - qi->setCurrentDownload(NULL); + qi->setCurrent(0); + qi->setCurrentDownload(0); // Add to the userQueue add(qi); @@ -283,26 +280,23 @@ QueueItem* QueueManager::UserQueue::getRunning(const User::Ptr& aUser) { QueueItem::UserIter i = running.find(aUser); - return (i == running.end()) ? NULL : i->second; + return (i == running.end()) ? 0 : i->second; } void QueueManager::UserQueue::remove(QueueItem* qi) { - if(qi->getStatus() == QueueItem::STATUS_RUNNING) { - dcassert(qi->getCurrent() != NULL); - remove(qi, qi->getCurrent()->getUser()); - } else { - for(QueueItem::Source::Iter i = qi->getSources().begin(); i != qi->getSources().end(); ++i) { - remove(qi, (*i)->getUser()); - } + for(QueueItem::Source::Iter i = qi->getSources().begin(); i != qi->getSources().end(); ++i) { + remove(qi, (*i)->getUser()); } } void QueueManager::UserQueue::remove(QueueItem* qi, const User::Ptr& aUser) { if(qi->getStatus() == QueueItem::STATUS_RUNNING) { - // Remove from running... - dcassert(qi->getCurrent() != NULL); - dcassert(running.find(aUser) != running.end()); - running.erase(aUser); + dcassert(qi->getCurrent() != 0); + if(qi->getCurrent()->getUser() == aUser) { + // Remove from running... + dcassert(running.find(aUser) != running.end()); + running.erase(aUser); + } } else { dcassert(qi->isSource(aUser)); dcassert(qi->getCurrent() == NULL); @@ -311,7 +305,7 @@ dcassert(j != ulm.end()); QueueItem::List& l = j->second; dcassert(find(l.begin(), l.end(), qi) != l.end()); - l.erase(find(l.begin(), l.end(), qi)); + l.erase(std::remove(l.begin(), l.end(), qi), l.end()); if(l.empty()) { ulm.erase(j); @@ -578,12 +572,11 @@ if(aUser->isSet(User::PASSIVE) && !ClientManager::getInstance()->isActive() ) { qi->removeSource(aUser, QueueItem::Source::FLAG_PASSIVE); wantConnection = false; - } else if(qi->getStatus() != QueueItem::STATUS_RUNNING) { + } else { userQueue.add(qi, aUser); + aUser->setFlag(User::SAVE_NICK); } - aUser->setFlag(User::SAVE_NICK); - fire(QueueManagerListener::SourcesUpdated(), qi); setDirty(); @@ -809,7 +802,6 @@ d->setStartPos(q->getDownloadedBytes()); } - fire(QueueManagerListener::StatusUpdated(), q); return d; } @@ -834,7 +826,7 @@ } else { QueueItem* q = fileQueue.find(aDownload->getTarget()); - if(q != NULL) { + if(q) { if(aDownload->isSet(Download::FLAG_USER_LIST)) { if(aDownload->getSource() == "files.xml.bz2") { q->setFlag(QueueItem::FLAG_XML_BZLIST); @@ -844,18 +836,16 @@ } if(finished) { - dcassert(q->getStatus() == QueueItem::STATUS_RUNNING); if(aDownload->isSet(Download::FLAG_TREE_DOWNLOAD)) { // Got a full tree, now add it to the HashManager dcassert(aDownload->getTreeValid()); HashManager::getInstance()->addTree(aDownload->getTigerTree()); - userQueue.setWaiting(q); - - fire(QueueManagerListener::StatusUpdated(), q); + if(q->getStatus() == QueueItem::STATUS_RUNNING) { + userQueue.setWaiting(q); + fire(QueueManagerListener::StatusUpdated(), q); + } } else { - fire(QueueManagerListener::Finished(), q, aDownload->getAverageSpeed()); - fire(QueueManagerListener::Removed(), q); // Now, let's see if this was a directory download filelist... if( (q->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD) && directories.find(q->getCurrent()->getUser()) != directories.end()) || (q->isSet(QueueItem::FLAG_MATCH_QUEUE)) ) @@ -864,7 +854,11 @@ up = q->getCurrent()->getUser(); flag = (q->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD) ? QueueItem::FLAG_DIRECTORY_DOWNLOAD : 0) | (q->isSet(QueueItem::FLAG_MATCH_QUEUE) ? QueueItem::FLAG_MATCH_QUEUE : 0); - } + } + + fire(QueueManagerListener::Finished(), q, aDownload->getAverageSpeed()); + fire(QueueManagerListener::Removed(), q); + userQueue.remove(q); fileQueue.remove(q); setDirty(); @@ -888,7 +882,7 @@ q->getOnlineUsers(getConn); } - // This might have been set to wait by removesource already... + // This might have been set to wait elsewhere already... if(q->getStatus() == QueueItem::STATUS_RUNNING) { userQueue.setWaiting(q); fire(QueueManagerListener::StatusUpdated(), q); @@ -901,7 +895,7 @@ } } } - aDownload->setUserConnection(NULL); + aDownload->setUserConnection(0); delete aDownload; } @@ -948,13 +942,13 @@ } void QueueManager::remove(const string& aTarget) throw() { - string x; + User::Ptr x; { Lock l(cs); QueueItem* q = fileQueue.find(aTarget); - if(q == NULL) + if(!q) return; if(q->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD)) { @@ -967,7 +961,7 @@ } if(q->getStatus() == QueueItem::STATUS_RUNNING) { - x = q->getTarget(); + x = q->getCurrent()->getUser(); } else if(!q->getTempTarget().empty() && q->getTempTarget() != q->getTarget()) { File::deleteFile(q->getTempTarget() + Download::ANTI_FRAG_EXT); File::deleteFile(q->getTempTarget()); @@ -981,18 +975,18 @@ setDirty(); } - if(!x.empty()) { - DownloadManager::getInstance()->abortDownload(x); + if(x) { + ConnectionManager::getInstance()->disconnect(x, true); } } void QueueManager::removeSource(const string& aTarget, User::Ptr& aUser, int reason, bool removeConn /* = true */) throw() { - string x; + bool isRunning = false; bool removeCompletely = false; { Lock l(cs); QueueItem* q = fileQueue.find(aTarget); - if(q == NULL) + if(!q) return; if(!q->isSource(aUser)) @@ -1019,23 +1013,22 @@ return; } } + if((q->getStatus() == QueueItem::STATUS_RUNNING) && q->getCurrent()->getUser() == aUser) { - if(removeConn) - x = q->getTarget(); + isRunning = true; userQueue.setWaiting(q); - userQueue.remove(q, aUser); - } else if(q->getStatus() == QueueItem::STATUS_WAITING) { - userQueue.remove(q, aUser); + fire(QueueManagerListener::StatusUpdated(), q); } + userQueue.remove(q, aUser); q->removeSource(aUser, reason); fire(QueueManagerListener::SourcesUpdated(), q); setDirty(); } endCheck: - if(!x.empty()) { - DownloadManager::getInstance()->abortDownload(x); + if(isRunning && removeConn) { + ConnectionManager::getInstance()->disconnect(aUser, true); } if(removeCompletely) { remove(aTarget); @@ -1043,7 +1036,7 @@ } void QueueManager::removeSource(User::Ptr& aUser, int reason) throw() { - string x; + bool isRunning = false; string removeRunning; { Lock l(cs); @@ -1060,22 +1053,23 @@ } qi = userQueue.getRunning(aUser); - if(qi != NULL) { + if(qi) { if(qi->isSet(QueueItem::FLAG_USER_LIST)) { removeRunning = qi->getTarget(); } else { userQueue.setWaiting(qi); userQueue.remove(qi, aUser); - x = qi->getTarget(); + isRunning = true; qi->removeSource(aUser, reason); + fire(QueueManagerListener::StatusUpdated(), qi); fire(QueueManagerListener::SourcesUpdated(), qi); setDirty(); } } } - if(!x.empty()) { - DownloadManager::getInstance()->abortDownload(x); + if(isRunning) { + ConnectionManager::getInstance()->disconnect(aUser, true); } if(!removeRunning.empty()) { remove(removeRunning); Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -1181,7 +1181,7 @@ newStr = auto_ptr<StringSearch::List>(new StringSearch::List(aStrings)); } dcassert(find(newStr->begin(), newStr->end(), *k) != newStr->end()); - newStr->erase(find(newStr->begin(), newStr->end(), *k)); + newStr->erase(remove(newStr->begin(), newStr->end(), *k), newStr->end()); } } @@ -1313,7 +1313,7 @@ newStr = auto_ptr<StringSearch::List>(new StringSearch::List(*cur)); } dcassert(find(newStr->begin(), newStr->end(), *k) != newStr->end()); - newStr->erase(find(newStr->begin(), newStr->end(), *k)); + newStr->erase(remove(newStr->begin(), newStr->end(), *k), newStr->end()); } } Modified: dcplusplus/trunk/client/StringDefs.cpp =================================================================== --- dcplusplus/trunk/client/StringDefs.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/StringDefs.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -113,6 +113,7 @@ "Error creating dchub registry key", "Error creating magnet registry key", "Error hashing ", +"Error saving hash data: ", "Exact size", "Executable", "Join/part of favorite users showing off", @@ -724,6 +725,7 @@ "ErrorCreatingRegistryKeyDchub", "ErrorCreatingRegistryKeyMagnet", "ErrorHashing", +"ErrorSavingHash", "ExactSize", "Executable", "FavJoinShowingOff", Modified: dcplusplus/trunk/client/StringDefs.h =================================================================== --- dcplusplus/trunk/client/StringDefs.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/StringDefs.h 2006-06-18 15:13:10 UTC (rev 619) @@ -116,6 +116,7 @@ ERROR_CREATING_REGISTRY_KEY_DCHUB, // "Error creating dchub registry key" ERROR_CREATING_REGISTRY_KEY_MAGNET, // "Error creating magnet registry key" ERROR_HASHING, // "Error hashing " + ERROR_SAVING_HASH, // "Error saving hash data: " EXACT_SIZE, // "Exact size" EXECUTABLE, // "Executable" FAV_JOIN_SHOWING_OFF, // "Join/part of favorite users showing off" Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -224,7 +224,7 @@ void UploadManager::removeUpload(Upload* aUpload) { Lock l(cs); dcassert(find(uploads.begin(), uploads.end(), aUpload) != uploads.end()); - uploads.erase(find(uploads.begin(), uploads.end(), aUpload)); + uploads.erase(remove(uploads.begin(), uploads.end(), aUpload), uploads.end()); aUpload->setUserConnection(NULL); delete aUpload; } Modified: dcplusplus/trunk/windows/CommandDlg.cpp =================================================================== --- dcplusplus/trunk/windows/CommandDlg.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/CommandDlg.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -19,10 +19,12 @@ #include "stdafx.h" #include "../client/DCPlusPlus.h" #include "Resource.h" + #include "../client/ResourceManager.h" - #include "../client/UserCommand.h" +#include "../client/NmdcHub.h" +#include "WinUtil.h" #include "CommandDlg.h" LRESULT CommandDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) @@ -194,3 +196,55 @@ HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_UCPAGE); return 0; } + +void CommandDlg::updateType() { + if(ctrlSeparator.GetCheck() == BST_CHECKED) { + type = 0; + } else if(ctrlRaw.GetCheck() == BST_CHECKED) { + type = 1; + } else if(ctrlChat.GetCheck() == BST_CHECKED) { + type = 2; + } else if(ctrlPM.GetCheck() == BST_CHECKED) { + type = 3; + } +} + +void CommandDlg::updateCommand() { + static const size_t BUF_LEN = 1024; + TCHAR buf[BUF_LEN]; + if(type == 0) { + command.clear(); + } else if(type == 1) { + ctrlCommand.GetWindowText(buf, BUF_LEN-1); + command = buf; + } else if(type == 2) { + ctrlCommand.GetWindowText(buf, BUF_LEN - 1); + command = Text::toT("<%[myNI]> " + NmdcHub::validateMessage(Text::fromT(buf), false) + "|"); + } else if(type == 3) { + ctrlNick.GetWindowText(buf, BUF_LEN - 1); + tstring to(buf); + ctrlCommand.GetWindowText(buf, BUF_LEN - 1); + command = _T("$To: ") + to + _T(" From: %[myNI] $<%[myNI]> ") + Text::toT(NmdcHub::validateMessage(Text::fromT(buf), false)) + _T("|"); + } +} + +void CommandDlg::updateControls() { + switch(type) { + case 0: + ctrlName.EnableWindow(FALSE); + ctrlCommand.EnableWindow(FALSE); + ctrlNick.EnableWindow(FALSE); + break; + case 1: + case 2: + ctrlName.EnableWindow(TRUE); + ctrlCommand.EnableWindow(TRUE); + ctrlNick.EnableWindow(FALSE); + break; + case 3: + ctrlName.EnableWindow(TRUE); + ctrlCommand.EnableWindow(TRUE); + ctrlNick.EnableWindow(TRUE); + break; + } +} Modified: dcplusplus/trunk/windows/CommandDlg.h =================================================================== --- dcplusplus/trunk/windows/CommandDlg.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/CommandDlg.h 2006-06-18 15:13:10 UTC (rev 619) @@ -23,9 +23,6 @@ #pragma once #endif // _MSC_VER > 1000 -#include "../client/Util.h" -#include "WinUtil.h" - class CommandDlg : public CDialogImpl<CommandDlg> { CEdit ctrlName; @@ -82,55 +79,9 @@ LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); private: - void updateType() { - if(ctrlSeparator.GetCheck() == BST_CHECKED) { - type = 0; - } else if(ctrlRaw.GetCheck() == BST_CHECKED) { - type = 1; - } else if(ctrlChat.GetCheck() == BST_CHECKED) { - type = 2; - } else if(ctrlPM.GetCheck() == BST_CHECKED) { - type = 3; - } - } - enum { BUF_LEN = 1024 }; - void updateCommand() { - TCHAR buf[BUF_LEN]; - if(type == 0) { - command.clear(); - } else if(type == 1) { - ctrlCommand.GetWindowText(buf, BUF_LEN-1); - command = buf; - } else if(type == 2) { - ctrlCommand.GetWindowText(buf, BUF_LEN - 1); - command = Text::toT("<%[myNI]> " + NmdcHub::validateMessage(Text::fromT(buf), false) + "|"); - } else if(type == 3) { - ctrlNick.GetWindowText(buf, BUF_LEN - 1); - tstring to(buf); - ctrlCommand.GetWindowText(buf, BUF_LEN - 1); - command = _T("$To: ") + to + _T(" From: %[myNI] $<%[myNI]> ") + Text::toT(NmdcHub::validateMessage(Text::fromT(buf), false)) + _T("|"); - } - } - void updateControls() { - switch(type) { - case 0: - ctrlName.EnableWindow(FALSE); - ctrlCommand.EnableWindow(FALSE); - ctrlNick.EnableWindow(FALSE); - break; - case 1: - case 2: - ctrlName.EnableWindow(TRUE); - ctrlCommand.EnableWindow(TRUE); - ctrlNick.EnableWindow(FALSE); - break; - case 3: - ctrlName.EnableWindow(TRUE); - ctrlCommand.EnableWindow(TRUE); - ctrlNick.EnableWindow(TRUE); - break; - } - } + void updateType(); + void updateCommand(); + void updateControls(); void updateContext(); }; Modified: dcplusplus/trunk/windows/FlatTabCtrl.h =================================================================== --- dcplusplus/trunk/windows/FlatTabCtrl.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/FlatTabCtrl.h 2006-06-18 15:13:10 UTC (rev 619) @@ -83,7 +83,7 @@ delete ti; tabs.erase(i); dcassert(find(viewOrder.begin(), viewOrder.end(), aWnd) != viewOrder.end()); - viewOrder.erase(find(viewOrder.begin(), viewOrder.end(), aWnd)); + viewOrder.erase(remove(viewOrder.begin(), viewOrder.end(), aWnd), viewOrder.end()); nextTab = viewOrder.end(); if(!viewOrder.empty()) --nextTab; @@ -137,7 +137,7 @@ void setTop(HWND aWnd) { dcassert(find(viewOrder.begin(), viewOrder.end(), aWnd) != viewOrder.end()); - viewOrder.erase(find(viewOrder.begin(), viewOrder.end(), aWnd)); + viewOrder.erase(remove(viewOrder.begin(), viewOrder.end(), aWnd), viewOrder.end()); viewOrder.push_back(aWnd); nextTab = --viewOrder.end(); } Modified: dcplusplus/trunk/windows/GeneralPage.cpp =================================================================== --- dcplusplus/trunk/windows/GeneralPage.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/GeneralPage.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -75,11 +75,11 @@ GetDlgItemText(wID, buf, SETTINGS_BUF_LEN); tstring old = buf; - // Strip '$', '|', '<', '>' and ' ' from text + // Strip ' ' from nick TCHAR *b = buf, *f = buf, c; while( (c = *b++) != 0 ) { - if(c != '$' && c != '|' && (wID == IDC_DESCRIPTION || c != ' ') && ( (wID != IDC_NICK) || (c != '<' && c != '>')) ) + if(c != ' ') *f++ = c; } Modified: dcplusplus/trunk/windows/GeneralPage.h =================================================================== --- dcplusplus/trunk/windows/GeneralPage.h 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/GeneralPage.h 2006-06-18 15:13:10 UTC (rev 619) @@ -39,8 +39,6 @@ MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) MESSAGE_HANDLER(WM_HELP, onHelp) COMMAND_HANDLER(IDC_NICK, EN_CHANGE, onTextChanged) - COMMAND_HANDLER(IDC_EMAIL, EN_CHANGE, onTextChanged) - COMMAND_HANDLER(IDC_DESCRIPTION, EN_CHANGE, onTextChanged) NOTIFY_CODE_HANDLER_EX(PSN_HELP, onHelpInfo) END_MSG_MAP() Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-06-17 23:26:36 UTC (rev 618) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-06-18 15:13:10 UTC (rev 619) @@ -1313,6 +1313,9 @@ tstring::size_type end = static_cast<tstring::size_type>(tstring::npos); int64_t multiplier = 1; + if(filter.empty()) { + return false; + } if(filter.compare(0, 2, _T(">=")) == 0) { mode = FilterModes::GREATER_EQUAL; start = 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |