2
* Copyright (C) 2004-2012 See the AUTHORS file for details.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 2 as published
6
* by the Free Software Foundation.
12
#include <znc/zncconfig.h>
13
#include <znc/Socket.h>
18
// Forward Declarations
23
// !Forward Declarations
25
class CIRCSock : public CZNCSock {
27
CIRCSock(CIRCNetwork* pNetwork);
31
// These values must line up with their position in the CHANMODE argument to raw 005
39
bool OnCTCPReply(CNick& Nick, CString& sMessage);
40
bool OnPrivCTCP(CNick& Nick, CString& sMessage);
41
bool OnChanCTCP(CNick& Nick, const CString& sChan, CString& sMessage);
42
bool OnGeneralCTCP(CNick& Nick, CString& sMessage);
43
bool OnPrivMsg(CNick& Nick, CString& sMessage);
44
bool OnChanMsg(CNick& Nick, const CString& sChan, CString& sMessage);
45
bool OnPrivNotice(CNick& Nick, CString& sMessage);
46
bool OnChanNotice(CNick& Nick, const CString& sChan, CString& sMessage);
47
bool OnServerCapAvailable(const CString& sCap);
50
virtual void ReadLine(const CString& sData);
51
virtual void Connected();
52
virtual void Disconnected();
53
virtual void ConnectionRefused();
54
virtual void SockError(int iErrno, const CString& sDescription);
55
virtual void Timeout();
56
virtual void ReachedMaxBuffer();
58
void PutIRC(const CString& sLine);
59
void PutIRCQuick(const CString& sLine); //!< Should be used for PONG only
61
void Quit(const CString& sQuitMsg = "");
63
/** You can call this from CModule::OnServerCapResult to suspend
64
* sending other CAP requests and CAP END for a while. Each
65
* call to PauseCap should be balanced with a call to ResumeCap.
68
/** If you used PauseCap, call this when CAP negotiation and logging in
69
* should be resumed again.
74
void SetPass(const CString& s) { m_sPass = s; }
78
unsigned int GetMaxNickLen() const { return m_uMaxNickLen; }
79
EChanModeArgs GetModeType(unsigned char uMode) const;
80
unsigned char GetPermFromMode(unsigned char uMode) const;
81
const std::map<unsigned char, EChanModeArgs>& GetChanModes() const { return m_mueChanModes; }
82
bool IsPermChar(const char c) const { return (c != '\0' && GetPerms().find(c) != CString::npos); }
83
bool IsPermMode(const char c) const { return (c != '\0' && GetPermModes().find(c) != CString::npos); }
84
const CString& GetPerms() const { return m_sPerms; }
85
const CString& GetPermModes() const { return m_sPermModes; }
86
CString GetNickMask() const { return m_Nick.GetNickMask(); }
87
const CString& GetNick() const { return m_Nick.GetNick(); }
88
const CString& GetPass() const { return m_sPass; }
89
CIRCNetwork* GetNetwork() const { return m_pNetwork; }
90
bool HasNamesx() const { return m_bNamesx; }
91
bool HasUHNames() const { return m_bUHNames; }
92
const std::set<unsigned char>& GetUserModes() const { return m_scUserModes; }
93
// This is true if we are past raw 001
94
bool IsAuthed() const { return m_bAuthed; }
95
bool IsCapAccepted(const CString& sCap) { return 1 == m_ssAcceptedCaps.count(sCap); }
96
const MCString& GetISupport() const { return m_mISupport; }
99
// This handles NAMESX and UHNAMES in a raw 353 reply
100
void ForwardRaw353(const CString& sLine) const;
101
void ForwardRaw353(const CString& sLine, CClient* pClient) const;
103
// TODO move this function to CIRCNetwork and make it non-static?
104
static bool IsFloodProtected(double fRate);
106
void SetNick(const CString& sNick);
107
void ParseISupport(const CString& sLine);
108
// This is called when we connect and the nick we want is already taken
109
void SendAltNick(const CString& sBadNick);
117
CString m_sPermModes;
118
std::set<unsigned char> m_scUserModes;
119
std::map<unsigned char, EChanModeArgs> m_mueChanModes;
120
CIRCNetwork* m_pNetwork;
123
std::map<CString, CChan*> m_msChans;
124
unsigned int m_uMaxNickLen;
125
unsigned int m_uCapPaused;
126
SCString m_ssAcceptedCaps;
127
SCString m_ssPendingCaps;
129
unsigned int m_uNumCTCP;
130
static const time_t m_uCTCPFloodTime;
131
static const unsigned int m_uCTCPFloodCount;
132
MCString m_mISupport;
133
std::deque<CString> m_vsSendQueue;
134
short int m_iSendsAllowed;
135
unsigned short int m_uFloodBurst;
137
bool m_bFloodProtection;
139
friend class CIRCFloodTimer;
142
#endif // !_IRCSOCK_H