37 #include "inspsocket.h"
39 #include "membership.h"
55 enum RegistrationState {
57 #ifndef _WIN32 // Burlex: This is already defined in win32, luckily it is still 0.
168 const std::string& GetName() {
return name; }
169 const std::string& GetHost() {
return host; }
175 return (registration_timeout ? registration_timeout : 90);
182 return (pingtime ? pingtime : 120);
190 return (softsendqmax ? softsendqmax : 4096);
197 return (hardsendqmax ? hardsendqmax : 0x100000);
204 return (recvqmax ? recvqmax : 4096);
211 return penaltythreshold ? penaltythreshold : (fakelag ? 10 : 20);
214 unsigned int GetCommandRate()
216 return commandrate ? commandrate : 1000;
244 std::string cached_fullhost;
248 std::string cached_hostip;
252 std::string cached_makehost;
256 std::string cached_fullrealhost;
260 std::string cachedip;
263 std::string displayhost;
266 std::string realhost;
269 std::string realname;
277 std::bitset<ModeParser::MODEID_MAX> modes;
290 virtual void Execute(
LocalUser* user) = 0;
375 const std::string& GetIPString();
380 const std::string& GetHost(
bool uncloak)
const;
383 const std::string& GetDisplayedHost()
const;
386 const std::string& GetRealHost()
const;
389 const std::string& GetRealName()
const;
398 virtual bool SetClientIP(
const std::string& address);
405 User(
const std::string& uid,
Server* srv, UserType objtype);
412 virtual const std::string& GetFullHost();
420 virtual const std::string& GetFullRealHost();
425 void InvalidateCache();
431 bool IsAway()
const {
return (!awaymsg.empty()); }
443 bool IsNoticeMaskSet(
unsigned char sm);
450 std::string GetModeLetters(
bool includeparams =
false)
const;
456 bool IsModeSet(
unsigned char m)
const;
458 bool IsModeSet(
const ModeHandler& mh)
const {
return IsModeSet(&mh); }
466 void SetMode(
ModeHandler& mh,
bool value) { SetMode(&mh, value); }
474 virtual bool HasCommandPermission(
const std::string& command);
483 virtual bool HasPrivPermission(
const std::string& privstr);
491 virtual bool HasModePermission(
const ModeHandler* mh)
const;
497 virtual bool HasSnomaskPermission(
char chr)
const;
503 const std::string& MakeHost();
509 const std::string& MakeHostIP();
524 void WriteNotice(
const std::string& text);
529 virtual void WriteRemoteNotice(
const std::string& text);
533 template <
typename T1>
534 void WriteRemoteNumeric(
unsigned int numeric, T1 p1)
538 WriteRemoteNumeric(n);
541 template <
typename T1,
typename T2>
542 void WriteRemoteNumeric(
unsigned int numeric, T1 p1, T2 p2)
547 WriteRemoteNumeric(n);
550 template <
typename T1,
typename T2,
typename T3>
551 void WriteRemoteNumeric(
unsigned int numeric, T1 p1, T2 p2, T3 p3)
557 WriteRemoteNumeric(n);
560 template <
typename T1,
typename T2,
typename T3,
typename T4>
561 void WriteRemoteNumeric(
unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
568 WriteRemoteNumeric(n);
571 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
572 void WriteRemoteNumeric(
unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
580 WriteRemoteNumeric(n);
585 template <
typename T1>
586 void WriteNumeric(
unsigned int numeric, T1 p1)
593 template <
typename T1,
typename T2>
594 void WriteNumeric(
unsigned int numeric, T1 p1, T2 p2)
602 template <
typename T1,
typename T2,
typename T3>
603 void WriteNumeric(
unsigned int numeric, T1 p1, T2 p2, T3 p3)
612 template <
typename T1,
typename T2,
typename T3,
typename T4>
613 void WriteNumeric(
unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
623 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
624 void WriteNumeric(
unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
649 void ForEachNeighbor(ForEachNeighborHandler& handler,
bool include_self =
true);
655 bool SharesChannelWith(
User *other);
661 bool ChangeDisplayedHost(
const std::string& host);
667 void ChangeRealHost(
const std::string& host,
bool resetdisplay);
676 bool ChangeIdent(
const std::string& newident);
682 bool ChangeRealName(
const std::string& real);
689 bool ChangeNick(
const std::string& newnick, time_t newts = 0);
694 void PurgeEmptyChannels();
702 bool Deserialize(Data& data) CXX11_OVERRIDE;
705 bool Serialize(
Serializable::Data& data) CXX11_OVERRIDE;
711 size_t checked_until;
720 void OnDataReady() CXX11_OVERRIDE;
722 void OnError(BufferedSocketError error) CXX11_OVERRIDE;
729 void AddWriteBuf(
const std::string &data);
737 typedef unsigned int already_sent_t;
744 void Write(
const ClientProtocol::SerializedMessage& serialized);
755 static ClientProtocol::MessageList sendmsglist;
802 void CheckClass(
bool clone_count =
true);
834 already_sent_t already_sent;
840 bool CheckLines(
bool doZline =
false);
851 void SetClass(
const std::string &explicit_name =
"");
853 bool SetClientIP(
const std::string& address) CXX11_OVERRIDE;
927 :
User(uid, srv, USERTYPE_SERVER)
932 FakeUser(
const std::string& uid,
const std::string& sname,
const std::string& sdesc)
933 :
User(uid,
new Server(uid, sname, sdesc), USERTYPE_SERVER)
947 return (u != NULL && u->
usertype == USERTYPE_LOCAL) ?
static_cast<LocalUser*
>(u) : NULL;
952 return (u != NULL && u->
usertype == USERTYPE_REMOTE) ?
static_cast<RemoteUser*
>(u) : NULL;
957 return (u != NULL && u->
usertype == USERTYPE_SERVER) ?
static_cast<FakeUser*
>(u) : NULL;
975 modes[mh->
GetId()] = value;