From: Jacek S. <arn...@us...> - 2006-02-19 20:39:24
|
Update of /cvsroot/dcplusplus/dcplusplus/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv564/client Modified Files: NmdcHub.h AdcCommand.h AdcHub.h Client.h NmdcHub.cpp AdcCommand.cpp StringDefs.cpp Log Message: More janitory action Index: Client.h =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/Client.h,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** Client.h 19 Feb 2006 16:19:06 -0000 1.109 --- Client.h 19 Feb 2006 20:39:20 -0000 1.110 *************** *** 88,93 **** virtual void connect(); ! bool isConnected() const { return socket && socket->isConnected(); } ! void disconnect(bool graceless) { if(socket) socket->disconnect(graceless); } virtual void connect(const OnlineUser& user) = 0; --- 88,92 ---- virtual void connect(); ! virtual void disconnect(bool graceless) { if(socket) socket->disconnect(graceless); } virtual void connect(const OnlineUser& user) = 0; *************** *** 101,105 **** virtual size_t getUserCount() const = 0; virtual int64_t getAvailable() const = 0; ! bool isOp() const { return getMyIdentity().isOp(); } --- 100,109 ---- virtual size_t getUserCount() const = 0; virtual int64_t getAvailable() const = 0; ! ! virtual void send(const AdcCommand& command) = 0; ! ! virtual string escape(string const& str) const { return str; } ! ! bool isConnected() const { return socket && socket->isConnected(); } bool isOp() const { return getMyIdentity().isOp(); } *************** *** 111,117 **** string getLocalIp() const; ! void updated(const OnlineUser& aUser) { ! fire(ClientListener::UserUpdated(), this, aUser); ! } static string getCounts() { --- 115,119 ---- string getLocalIp() const; ! void updated(const OnlineUser& aUser) { fire(ClientListener::UserUpdated(), this, aUser); } static string getCounts() { *************** *** 120,124 **** } - virtual string escape(string const& str) const { return str; } StringMap& escapeParams(StringMap& sm) { for(StringMapIter i = sm.begin(); i != sm.end(); ++i) { --- 122,125 ---- *************** *** 136,140 **** socket->write(aMessage, aLen); } - virtual void send(const AdcCommand& command) = 0; const string& getMyNick() const { return getMyIdentity().getNick(); } --- 137,140 ---- Index: NmdcHub.h =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/NmdcHub.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** NmdcHub.h 19 Feb 2006 16:19:06 -0000 1.31 --- NmdcHub.h 19 Feb 2006 20:39:20 -0000 1.32 *************** *** 37,56 **** class NmdcHub : public Client, private TimerManagerListener, private Flags { - friend class ClientManager; public: ! typedef NmdcHub* Ptr; ! typedef list<Ptr> List; ! typedef List::iterator Iter; ! ! enum SupportFlags { ! SUPPORTS_USERCOMMAND = 0x01, ! SUPPORTS_NOGETINFO = 0x02, ! SUPPORTS_USERIP2 = 0x04 ! }; ! ! #define checkstate() if(state != STATE_CONNECTED) return virtual void connect(const OnlineUser& aUser); ! virtual void hubMessage(const string& aMessage) { checkstate(); send(toNmdc( "<" + getMyNick() + "> " + Util::validateMessage(aMessage, false) + "|" ) ); } virtual void privateMessage(const OnlineUser& aUser, const string& aMessage); virtual void sendUserCmd(const string& aUserCmd) throw() { send(toNmdc(aUserCmd)); } --- 37,47 ---- class NmdcHub : public Client, private TimerManagerListener, private Flags { public: ! using Client::send; 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); virtual void sendUserCmd(const string& aUserCmd) throw() { send(toNmdc(aUserCmd)); } *************** *** 64,97 **** virtual string escape(string const& str) const { return Util::validateMessage(str, false); } - virtual void disconnect(bool graceless) throw(); - using Client::send; virtual void send(const AdcCommand&) { dcassert(0); } - void myInfo(bool alwaysSend); - - void refreshUserList(bool unknownOnly = false); - - void validateNick(const string& aNick) { send("$ValidateNick " + toNmdc(aNick) + "|"); } - void key(const string& aKey) { send("$Key " + aKey + "|"); } - void version() { send("$Version 1,0091|"); } - void getNickList() { checkstate(); send("$GetNickList|"); } - void getInfo(const OnlineUser& aUser) { checkstate(); send("$GetINFO " + toNmdc(aUser.getIdentity().getNick()) + " " + toNmdc(getMyNick()) + "|"); } - - void connectToMe(const OnlineUser& aUser); - void revConnectToMe(const OnlineUser& aUser); - - /* void privateMessage(const string& aNick, const string& aMessage) { - } - */ - void supports(const StringList& feat) { - string x; - for(StringList::const_iterator i = feat.begin(); i != feat.end(); ++i) { - x+= *i + ' '; - } - send("$Supports " + x + '|'); - } - GETSET(int, supportFlags, SupportFlags); private: enum States { STATE_CONNECT, --- 55,69 ---- virtual string escape(string const& str) const { return Util::validateMessage(str, false); } virtual void send(const AdcCommand&) { dcassert(0); } GETSET(int, supportFlags, SupportFlags); private: + friend class ClientManager; + enum SupportFlags { + SUPPORTS_USERCOMMAND = 0x01, + SUPPORTS_NOGETINFO = 0x02, + SUPPORTS_USERIP2 = 0x04 + }; + enum States { STATE_CONNECT, *************** *** 136,139 **** --- 108,120 ---- string toNmdc(const string& str) const { return Text::utf8ToAcp(str); } + void validateNick(const string& aNick) { send("$ValidateNick " + toNmdc(aNick) + "|"); } + void key(const string& aKey) { send("$Key " + aKey + "|"); } + void version() { send("$Version 1,0091|"); } + void getNickList() { send("$GetNickList|"); } + void connectToMe(const OnlineUser& aUser); + void revConnectToMe(const OnlineUser& aUser); + void myInfo(bool alwaysSend); + void supports(const StringList& feat); + void updateFromTag(Identity& id, const string& tag); Index: AdcCommand.h =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/AdcCommand.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** AdcCommand.h 17 Feb 2006 19:23:51 -0000 1.28 --- AdcCommand.h 19 Feb 2006 20:39:20 -0000 1.29 *************** *** 138,158 **** bool operator==(u_int32_t aCmd) { return cmdInt == aCmd; } ! static string escape(const string& str, bool old) { ! string tmp = str; ! string::size_type i = 0; ! while( (i = tmp.find_first_of(" \n\\", i)) != string::npos) { ! if(old) { ! tmp.insert(i, "\\"); ! } else { ! switch(tmp[i]) { ! case ' ': tmp.replace(i, 1, "\\s"); break; ! case '\n': tmp.replace(i, 1, "\\n"); break; ! case '\\': tmp.replace(i, 1, "\\\\"); break; ! } ! } ! i+=2; ! } ! return tmp; ! } u_int32_t getTo() const { return to; } AdcCommand& setTo(const u_int32_t sid) { to = sid; return *this; } --- 138,142 ---- bool operator==(u_int32_t aCmd) { return cmdInt == aCmd; } ! static string escape(const string& str, bool old); u_int32_t getTo() const { return to; } AdcCommand& setTo(const u_int32_t sid) { to = sid; return *this; } Index: AdcHub.h =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/AdcHub.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** AdcHub.h 19 Feb 2006 16:19:06 -0000 1.41 --- AdcHub.h 19 Feb 2006 20:39:20 -0000 1.42 *************** *** 33,41 **** class AdcHub : public Client, public CommandHandler<AdcHub>, private TimerManagerListener { public: - using Client::send; virtual void connect(const OnlineUser& user); ! virtual void connect(const OnlineUser& user, string const& token, bool secure); virtual void disconnect(bool graceless); --- 33,40 ---- class AdcHub : public Client, public CommandHandler<AdcHub>, private TimerManagerListener { public: using Client::send; virtual void connect(const OnlineUser& user); ! void connect(const OnlineUser& user, string const& token, bool secure); virtual void disconnect(bool graceless); *************** *** 50,76 **** virtual int64_t getAvailable() const; - template<typename T> void handle(T, AdcCommand&) { - //Speaker<AdcHubListener>::fire(t, this, c); - } - - void send(const AdcCommand& cmd); - void sendUDP(const AdcCommand& cmd); - - void handle(AdcCommand::SUP, AdcCommand& c) throw(); - void handle(AdcCommand::SID, AdcCommand& c) throw(); - void handle(AdcCommand::MSG, AdcCommand& c) throw(); - void handle(AdcCommand::INF, AdcCommand& c) throw(); - void handle(AdcCommand::GPA, AdcCommand& c) throw(); - void handle(AdcCommand::QUI, AdcCommand& c) throw(); - void handle(AdcCommand::CTM, AdcCommand& c) throw(); - void handle(AdcCommand::RCM, AdcCommand& c) throw(); - void handle(AdcCommand::STA, AdcCommand& c) throw(); - void handle(AdcCommand::SCH, AdcCommand& c) throw(); - void handle(AdcCommand::CMD, AdcCommand& c) throw(); virtual string escape(string const& str) const { return AdcCommand::escape(str, false); } string getMySID() { return AdcCommand::fromSID(sid); } private: friend class ClientManager; enum States { --- 49,59 ---- virtual int64_t getAvailable() const; virtual string escape(string const& str) const { return AdcCommand::escape(str, false); } + virtual void send(const AdcCommand& cmd); string getMySID() { return AdcCommand::fromSID(sid); } private: friend class ClientManager; + friend class CommandHandler<AdcHub>; enum States { *************** *** 114,117 **** --- 97,118 ---- void clearUsers(); + void handle(AdcCommand::SUP, AdcCommand& c) throw(); + void handle(AdcCommand::SID, AdcCommand& c) throw(); + void handle(AdcCommand::MSG, AdcCommand& c) throw(); + void handle(AdcCommand::INF, AdcCommand& c) throw(); + void handle(AdcCommand::GPA, AdcCommand& c) throw(); + void handle(AdcCommand::QUI, AdcCommand& c) throw(); + void handle(AdcCommand::CTM, AdcCommand& c) throw(); + void handle(AdcCommand::RCM, AdcCommand& c) throw(); + void handle(AdcCommand::STA, AdcCommand& c) throw(); + void handle(AdcCommand::SCH, AdcCommand& c) throw(); + void handle(AdcCommand::CMD, AdcCommand& c) throw(); + + template<typename T> void handle(T, AdcCommand&) { + //Speaker<AdcHubListener>::fire(t, this, c); + } + + void sendUDP(const AdcCommand& cmd); + virtual void on(Connecting) throw() { fire(ClientListener::Connecting(), this); } virtual void on(Connected) throw(); Index: StringDefs.cpp =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/StringDefs.cpp,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** StringDefs.cpp 13 Feb 2006 21:13:27 -0000 1.162 --- StringDefs.cpp 19 Feb 2006 20:39:20 -0000 1.163 *************** *** 510,513 **** --- 510,514 ---- "Window options", "Write buffer size", + "Sort all downloads first", "Use SSL when remote client supports it", "CRC32 inconsistency (SFV-Check)", *************** *** 1106,1109 **** --- 1107,1111 ---- "SettingsWindowsOptions", "SettingsWriteBuffer", + "SettingsAltSortOrder", "SettingsUseSsl", "SfvInconsistency", Index: AdcCommand.cpp =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/AdcCommand.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AdcCommand.cpp 12 Feb 2006 18:16:12 -0000 1.17 --- AdcCommand.cpp 19 Feb 2006 20:39:20 -0000 1.18 *************** *** 132,135 **** --- 132,153 ---- } + string AdcCommand::escape(const string& str, bool old) { + string tmp = str; + string::size_type i = 0; + while( (i = tmp.find_first_of(" \n\\", i)) != string::npos) { + if(old) { + tmp.insert(i, "\\"); + } else { + switch(tmp[i]) { + case ' ': tmp.replace(i, 1, "\\s"); break; + case '\n': tmp.replace(i, 1, "\\n"); break; + case '\\': tmp.replace(i, 1, "\\\\"); break; + } + } + i+=2; + } + return tmp; + } + string AdcCommand::getHeaderString(u_int32_t sid, bool nmdc) const { string tmp; Index: NmdcHub.cpp =================================================================== RCS file: /cvsroot/dcplusplus/dcplusplus/client/NmdcHub.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** NmdcHub.cpp 10 Feb 2006 07:56:46 -0000 1.54 --- NmdcHub.cpp 19 Feb 2006 20:39:20 -0000 1.55 *************** *** 56,59 **** --- 56,61 ---- } + #define checkstate() if(state != STATE_CONNECTED) return + void NmdcHub::connect(const OnlineUser& aUser) { checkstate(); *************** *** 75,92 **** } - void NmdcHub::refreshUserList(bool unknownOnly /* = false */) { - if(unknownOnly) { - Lock l(cs); - for(NickIter i = users.begin(); i != users.end(); ++i) { - if(!i->second->getIdentity().isSet(Identity::GOT_INF)) { - getInfo(*i->second); - } - } - } else { - clearUsers(); - getNickList(); - } - } - OnlineUser& NmdcHub::getUser(const string& aNick) { OnlineUser* u = NULL; --- 77,80 ---- *************** *** 114,117 **** --- 102,113 ---- } + void NmdcHub::supports(const StringList& feat) { + string x; + for(StringList::const_iterator i = feat.begin(); i != feat.end(); ++i) { + x+= *i + ' '; + } + send("$Supports " + x + '|'); + } + OnlineUser* NmdcHub::findUser(const string& aNick) { Lock l(cs); *************** *** 678,681 **** --- 674,682 ---- } + void NmdcHub::hubMessage(const string& aMessage) { + checkstate(); + send(toNmdc( "<" + getMyNick() + "> " + Util::validateMessage(aMessage, false) + "|" ) ); + } + void NmdcHub::myInfo(bool alwaysSend) { checkstate(); |