Add away-notify support - close #315

This commit is contained in:
J-P Nurmi
2015-06-28 17:46:09 +02:00
parent 089a0fd925
commit 1fb321703d
3 changed files with 18 additions and 1 deletions
+4
View File
@@ -96,6 +96,7 @@ public:
m_bGotUser(false),
m_bInCap(false),
m_bCapNotify(false),
m_bAwayNotify(false),
m_bNamesx(false),
m_bUHNames(false),
m_bAway(false),
@@ -119,6 +120,7 @@ public:
{"server-time", {false, [this](bool bVal) { m_bServerTime = bVal; }}},
{"batch", {false, [this](bool bVal) { m_bBatch = bVal; }}},
{"cap-notify", {false, [this](bool bVal) { m_bCapNotify = bVal; }}},
{"away-notify", {true, [this](bool bVal) { m_bAwayNotify = bVal; }}},
})
{
EnableReadLine();
@@ -145,6 +147,7 @@ public:
CString GetNickMask() const;
CString GetIdentifier() const { return m_sIdentifier; }
bool HasCapNotify() const { return m_bCapNotify; }
bool HasAwayNotify() const { return m_bAwayNotify; }
bool HasNamesx() const { return m_bNamesx; }
bool HasUHNames() const { return m_bUHNames; }
bool IsAway() const { return m_bAway; }
@@ -209,6 +212,7 @@ protected:
bool m_bGotUser;
bool m_bInCap;
bool m_bCapNotify;
bool m_bAwayNotify;
bool m_bNamesx;
bool m_bUHNames;
bool m_bAway;
+2
View File
@@ -101,6 +101,7 @@ public:
CIRCNetwork* GetNetwork() const { return m_pNetwork; }
bool HasNamesx() const { return m_bNamesx; }
bool HasUHNames() const { return m_bUHNames; }
bool HasAwayNotify() const { return m_bAwayNotify; }
const std::set<unsigned char>& GetUserModes() const { return m_scUserModes; }
// This is true if we are past raw 001
bool IsAuthed() const { return m_bAuthed; }
@@ -127,6 +128,7 @@ protected:
bool m_bAuthed;
bool m_bNamesx;
bool m_bUHNames;
bool m_bAwayNotify;
CString m_sPerms;
CString m_sPermModes;
std::set<unsigned char> m_scUserModes;
+12 -1
View File
@@ -60,6 +60,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork)
m_bAuthed(false),
m_bNamesx(false),
m_bUHNames(false),
m_bAwayNotify(false),
m_sPerms("*!@%+"),
m_sPermModes("qaohv"),
m_scUserModes(),
@@ -809,7 +810,7 @@ void CIRCSock::ReadLine(const CString& sData) {
sArgs.Split(" ", vsTokens, false);
for (const CString& sCap : vsTokens) {
if (OnServerCapAvailable(sCap) || sCap == "multi-prefix" || sCap == "userhost-in-names") {
if (OnServerCapAvailable(sCap) || sCap == "multi-prefix" || sCap == "userhost-in-names" || sCap == "away-notify") {
m_ssPendingCaps.insert(sCap);
}
}
@@ -820,6 +821,8 @@ void CIRCSock::ReadLine(const CString& sData) {
m_bNamesx = true;
} else if ("userhost-in-names" == sArgs) {
m_bUHNames = true;
} else if ("away-notify" == sArgs) {
m_bAwayNotify = true;
}
m_ssAcceptedCaps.insert(sArgs);
} else if (sSubCmd == "NAK") {
@@ -836,6 +839,14 @@ void CIRCSock::ReadLine(const CString& sData) {
} else if (sCmd.Equals("INVITE")) {
IRCSOCKMODULECALL(OnInvite(Nick, sLine.Token(3).TrimPrefix_n(":")), &bReturn);
if (bReturn) return;
} else if (sCmd.Equals("AWAY")) {
const vector<CClient*>& vClients = m_pNetwork->GetClients();
for (CClient* pClient : vClients) {
if (pClient->HasAwayNotify()) {
m_pNetwork->PutUser(sLine, pClient);
}
}
return;
}
}