From: <arn...@us...> - 2006-05-15 21:53:37
|
Revision: 603 Author: arnetheduck Date: 2006-05-15 14:53:14 -0700 (Mon, 15 May 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=603&view=rev Log Message: ----------- User command fixes Modified Paths: -------------- dcplusplus/trunk/Example.xml dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/FavoriteManager.cpp dcplusplus/trunk/client/User.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/windows/DirectoryListingFrm.cpp dcplusplus/trunk/windows/DirectoryListingFrm.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/HubFrame.h dcplusplus/trunk/windows/PrivateFrame.cpp dcplusplus/trunk/windows/PrivateFrame.h dcplusplus/trunk/windows/SearchFrm.cpp dcplusplus/trunk/windows/SearchFrm.h dcplusplus/trunk/windows/SingleInstance.h dcplusplus/trunk/windows/TransferView.cpp dcplusplus/trunk/windows/TransferView.h Modified: dcplusplus/trunk/Example.xml =================================================================== --- dcplusplus/trunk/Example.xml 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/Example.xml 2006-05-15 21:53:14 UTC (rev 603) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version="0.689" Revision="1" RightToLeft="0"> +<Language Name="Example Language" Author="arnetheduck" Version="0.69" 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-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/changelog.txt 2006-05-15 21:53:14 UTC (rev 603) @@ -11,6 +11,9 @@ * Advanced TTH rollback no longer performed if tree is invalid (thanks garg) * Option not to auto-disconnect favorite users (thanks ullner) * Fixed auto-disconnect delay (thanks uller) +* Another fix for opencow +* Fixed user command parameters not being remembered +* Fixed ADC op commands -- 0.689 2006-04-01 -- * Fixed displaying of available bytes when user list is off Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -336,9 +336,9 @@ short port = secure ? ConnectionManager::getInstance()->getSecurePort() : ConnectionManager::getInstance()->getPort(); if(ClientManager::getInstance()->isActive()) { - send(AdcCommand(AdcCommand::CMD_CTM, user.getSID()).addParam(proto).addParam(Util::toString(port)).addParam(token)); + send(AdcCommand(AdcCommand::CMD_CTM, user.getIdentity().getSID()).addParam(proto).addParam(Util::toString(port)).addParam(token)); } else { - send(AdcCommand(AdcCommand::CMD_RCM, user.getSID()).addParam(proto)); + send(AdcCommand(AdcCommand::CMD_RCM, user.getIdentity().getSID()).addParam(proto)); } } @@ -357,7 +357,7 @@ void AdcHub::privateMessage(const OnlineUser& user, const string& aMessage) { if(state != STATE_NORMAL) return; - send(AdcCommand(AdcCommand::CMD_MSG, user.getSID()).addParam(aMessage).addParam("PM", getMySID())); + send(AdcCommand(AdcCommand::CMD_MSG, user.getIdentity().getSID()).addParam(aMessage).addParam("PM", getMySID())); } void AdcHub::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) { Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -316,7 +316,7 @@ if(cmd.getType() == AdcCommand::TYPE_UDP && !u->getIdentity().isUdpActive()) { cmd.setType(AdcCommand::TYPE_DIRECT); } - cmd.setTo(u->getSID()); + cmd.setTo(u->getIdentity().getSID()); u->getClient().send(cmd); } } @@ -404,7 +404,7 @@ if(i != onlineUsers.end()) { return i->second->getIdentity(); } - return Identity(aUser, Util::emptyString); + return Identity(aUser, Util::emptyString, 0); } void ClientManager::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken) { Modified: dcplusplus/trunk/client/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/client/FavoriteManager.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/client/FavoriteManager.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -408,11 +408,10 @@ // Add ADC standard op commands static const char adc_disconnectstr[] = - "HDSC %[mycid] %[cid] DI ND Friendly\\ disconnect\n"; + "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()); @@ -600,11 +599,11 @@ } UserCommand::List FavoriteManager::getUserCommands(int ctx, const StringList& hubs) { - bool isOp = false; - for(StringIterC i = hubs.begin(); i != hubs.end(); ++i) { - if(ClientManager::getInstance()->isOp(ClientManager::getInstance()->getMe(), *i)) { - isOp = true; - break; + vector<bool> isOp(hubs.size()); + + for(size_t i = 0; i < hubs.size(); ++i) { + if(ClientManager::getInstance()->isOp(ClientManager::getInstance()->getMe(), hubs[i])) { + isOp[i] = true; } } @@ -612,14 +611,32 @@ UserCommand::List lst; for(UserCommand::Iter i = userCommands.begin(); i != userCommands.end(); ++i) { UserCommand& uc = *i; - if( (uc.getCtx() & ctx) && - ( uc.getHub().empty() || - (uc.getHub() == "op" && isOp) || - (find_if(hubs.begin(), hubs.end(), bind1st(equal_to<string>(), uc.getHub())) != hubs.end()) - ) ) - { - lst.push_back(*i); + if(!(uc.getCtx() & ctx)) { + continue; } + + for(size_t j = 0; j < hubs.size(); ++j) { + const string& hub = hubs[j]; + bool hubAdc = hub.compare(0, 6, "adc://") == 0; + bool commandAdc = uc.getHub().compare(0, 6, "adc://") == 0; + if(hubAdc && commandAdc) { + if((uc.getHub().length() == 6) || + (uc.getHub() == "adc://op" && isOp[j]) || + (uc.getHub() == hub) ) + { + lst.push_back(*i); + break; + } + } else if(!hubAdc && !commandAdc) { + if((uc.getHub().length() == 0) || + (uc.getHub() == "op" && isOp[j]) || + (uc.getHub() == hub) ) + { + lst.push_back(*i); + break; + } + } + } } return lst; } Modified: dcplusplus/trunk/client/User.cpp =================================================================== --- dcplusplus/trunk/client/User.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/client/User.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -23,7 +23,7 @@ #include "Client.h" #include "StringTokenizer.h" -OnlineUser::OnlineUser(const User::Ptr& ptr, Client& client_, u_int32_t sid_) : user(ptr), identity(ptr, client_.getHubUrl()), sid(sid_), client(&client_) { +OnlineUser::OnlineUser(const User::Ptr& ptr, Client& client_, u_int32_t sid_) : user(ptr), identity(ptr, client_.getHubUrl(), sid_), client(&client_) { } @@ -32,6 +32,7 @@ sm[prefix + string((char*)(&i->first), 2)] = i->second; } if(user) { + sm[prefix + "SID"] = getSIDString(); sm[prefix + "CID"] = user->getCID().toBase32(); sm[prefix + "TAG"] = getTag(); sm[prefix + "SSshort"] = Util::formatBytes(get("SS")); Modified: dcplusplus/trunk/client/User.h =================================================================== --- dcplusplus/trunk/client/User.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/client/User.h 2006-05-15 21:53:14 UTC (rev 603) @@ -97,10 +97,10 @@ NMDC_PASSIVE = 1 << NMDC_PASSIVE_BIT }; - Identity() { } - Identity(const User::Ptr& ptr, const string& aHubUrl) : user(ptr), hubUrl(aHubUrl) { } - Identity(const Identity& rhs) : ::Flags(rhs), user(rhs.user), hubUrl(rhs.hubUrl), info(rhs.info) { } - Identity& operator=(const Identity& rhs) { user = rhs.user; hubUrl = rhs.hubUrl; info = rhs.info; return *this; } + Identity() : sid(0) { } + Identity(const User::Ptr& ptr, const string& aHubUrl, u_int32_t aSID) : user(ptr), hubUrl(aHubUrl), sid(aSID) { } + Identity(const Identity& rhs) : ::Flags(rhs), user(rhs.user), hubUrl(rhs.hubUrl), sid(rhs.sid), info(rhs.info) { } + Identity& operator=(const Identity& rhs) { user = rhs.user; hubUrl = rhs.hubUrl; sid = rhs.sid; info = rhs.info; return *this; } #define GS(n, x) const string& get##n() const { return get(x); } void set##n(const string& v) { set(x, v); } GS(Nick, "NI") @@ -143,10 +143,15 @@ info[*(short*)name] = val; } + string getSIDString() const { + return string((const char*)&sid, 4); + } + void getParams(StringMap& map, const string& prefix, bool compatibility) const; User::Ptr& getUser() { return user; } GETSET(User::Ptr, user, User); GETSET(string, hubUrl, HubUrl); + GETSET(u_int32_t, sid, SID); private: typedef map<short, string> InfMap; typedef InfMap::iterator InfIter; @@ -174,7 +179,6 @@ GETSET(User::Ptr, user, User); GETSET(Identity, identity, Identity); - GETSET(u_int32_t, sid, SID); private: friend class NmdcHub; Modified: dcplusplus/trunk/windows/DirectoryListingFrm.cpp =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/DirectoryListingFrm.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -1035,9 +1035,11 @@ } void DirectoryListingFrame::runUserCommand(UserCommand& uc) { - StringMap ucParams; - if(!WinUtil::getUCParams(m_hWnd, uc, ucParams)) + if(!WinUtil::getUCParams(m_hWnd, uc, ucLineParams)) return; + + StringMap ucParams = ucLineParams; + set<User::Ptr> nicks; int sel = -1; Modified: dcplusplus/trunk/windows/DirectoryListingFrm.h =================================================================== --- dcplusplus/trunk/windows/DirectoryListingFrm.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/DirectoryListingFrm.h 2006-05-15 21:53:14 UTC (rev 603) @@ -345,6 +345,8 @@ auto_ptr<DirectoryListing> dl; + StringMap ucLineParams; + typedef HASH_MAP_X(User::Ptr, DirectoryListingFrame*, User::HashFunction, equal_to<User::Ptr>, less<User::Ptr>) UserMap; typedef UserMap::iterator UserIter; Modified: dcplusplus/trunk/windows/HubFrame.cpp =================================================================== --- dcplusplus/trunk/windows/HubFrame.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/HubFrame.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -799,10 +799,11 @@ } void HubFrame::runUserCommand(::UserCommand& uc) { - StringMap ucParams; - if(!WinUtil::getUCParams(m_hWnd, uc, ucParams)) + if(!WinUtil::getUCParams(m_hWnd, uc, ucLineParams)) return; + StringMap ucParams = ucLineParams; + client->getMyIdentity().getParams(ucParams, "my", true); client->getHubIdentity().getParams(ucParams, "hub", false); Modified: dcplusplus/trunk/windows/HubFrame.h =================================================================== --- dcplusplus/trunk/windows/HubFrame.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/HubFrame.h 2006-05-15 21:53:14 UTC (rev 603) @@ -324,6 +324,8 @@ bool updateUsers; bool resort; + StringMap ucLineParams; + enum { MAX_CLIENT_LINES = 5 }; TStringList lastLinesList; tstring lastLines; Modified: dcplusplus/trunk/windows/PrivateFrame.cpp =================================================================== --- dcplusplus/trunk/windows/PrivateFrame.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/PrivateFrame.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -32,6 +32,7 @@ #include "../client/ShareManager.h" #include "../client/FavoriteManager.h" #include "../client/QueueManager.h" +#include "../client/StringTokenizer.h" PrivateFrame::FrameMap PrivateFrame::frames; @@ -284,10 +285,12 @@ } void PrivateFrame::runUserCommand(UserCommand& uc) { - StringMap ucParams; - if(!WinUtil::getUCParams(m_hWnd, uc, ucParams)) + + if(!WinUtil::getUCParams(m_hWnd, uc, ucLineParams)) return; + StringMap ucParams = ucLineParams; + ClientManager::getInstance()->userCommand(replyTo, uc, ucParams, true); } Modified: dcplusplus/trunk/windows/PrivateFrame.h =================================================================== --- dcplusplus/trunk/windows/PrivateFrame.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/PrivateFrame.h 2006-05-15 21:53:14 UTC (rev 603) @@ -161,6 +161,8 @@ bool closed; + StringMap ucLineParams; + void updateTitle(); // ClientManagerListener Modified: dcplusplus/trunk/windows/SearchFrm.cpp =================================================================== --- dcplusplus/trunk/windows/SearchFrm.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/SearchFrm.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -768,9 +768,11 @@ } void SearchFrame::runUserCommand(UserCommand& uc) { - StringMap ucParams; - if(!WinUtil::getUCParams(m_hWnd, uc, ucParams)) + if(!WinUtil::getUCParams(m_hWnd, uc, ucLineParams)) return; + + StringMap ucParams = ucLineParams; + set<CID> users; int sel = -1; Modified: dcplusplus/trunk/windows/SearchFrm.h =================================================================== --- dcplusplus/trunk/windows/SearchFrm.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/SearchFrm.h 2006-05-15 21:53:14 UTC (rev 603) @@ -383,6 +383,8 @@ bool closed; + StringMap ucLineParams; + static int columnIndexes[]; static int columnSizes[]; Modified: dcplusplus/trunk/windows/SingleInstance.h =================================================================== --- dcplusplus/trunk/windows/SingleInstance.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/SingleInstance.h 2006-05-15 21:53:14 UTC (rev 603) @@ -24,7 +24,7 @@ #endif // _MSC_VER > 1000 #define WMU_WHERE_ARE_YOU_MSG _T("WMU_WHERE_ARE_YOU-{885D4B75-6606-4add-A8DE-EEEDC04181F1}") -const UINT WMU_WHERE_ARE_YOU = ::RegisterWindowMessage(_T("WMU_WHERE_ARE_YOU_MSG")); +const UINT WMU_WHERE_ARE_YOU = ::RegisterWindowMessageA("WMU_WHERE_ARE_YOU_MSG"); class SingleInstance { Modified: dcplusplus/trunk/windows/TransferView.cpp =================================================================== --- dcplusplus/trunk/windows/TransferView.cpp 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/TransferView.cpp 2006-05-15 21:53:14 UTC (rev 603) @@ -128,10 +128,11 @@ } void TransferView::runUserCommand(UserCommand& uc) { - StringMap ucParams; - if(!WinUtil::getUCParams(m_hWnd, uc, ucParams)) + if(!WinUtil::getUCParams(m_hWnd, uc, ucLineParams)) return; + StringMap ucParams = ucLineParams; + int i = -1; while((i = ctrlTransfers.GetNextItem(i, LVNI_SELECTED)) != -1) { ItemInfo* itemI = ctrlTransfers.getItemData(i); Modified: dcplusplus/trunk/windows/TransferView.h =================================================================== --- dcplusplus/trunk/windows/TransferView.h 2006-05-13 15:00:16 UTC (rev 602) +++ dcplusplus/trunk/windows/TransferView.h 2006-05-15 21:53:14 UTC (rev 603) @@ -263,6 +263,8 @@ CMenu transferMenu; CImageList arrows; + StringMap ucLineParams; + virtual void on(ConnectionManagerListener::Added, ConnectionQueueItem* aCqi) throw(); virtual void on(ConnectionManagerListener::Failed, ConnectionQueueItem* aCqi, const string& aReason) throw(); virtual void on(ConnectionManagerListener::Removed, ConnectionQueueItem* aCqi) throw(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |