From 15c49e3fc4cf033fffbf79e9f68a0405d5a95d14 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 26 Sep 2019 22:15:57 +0300 Subject: Clist_IsHidden / Clist_HideContact - two helpers to hide CList/Hidden variable and unify access to it --- protocols/IRCG/src/clist.cpp | 6 +++--- protocols/IRCG/src/commandmonitor.cpp | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'protocols/IRCG/src') diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp index 02739d42e0..43011ce264 100644 --- a/protocols/IRCG/src/clist.cpp +++ b/protocols/IRCG/src/clist.cpp @@ -31,7 +31,7 @@ BOOL CIrcProto::CList_AddDCCChat(const CMStringW& name, const CMStringW& hostmas CONTACT usertemp = { name, nullptr, nullptr, false, false, true }; MCONTACT hc = CList_FindContact(&usertemp); - if (hc && db_get_b(hc, "CList", "NotOnList", 0) == 0 && db_get_b(hc, "CList", "Hidden", 0) == 0) + if (hc && db_get_b(hc, "CList", "NotOnList", 0) == 0 && Clist_IsHidden(hc) == 0) bFlag = true; CMStringW contactname = name; contactname += DCCSTRING; @@ -90,7 +90,7 @@ MCONTACT CIrcProto::CList_AddContact(CONTACT *user, bool InList, bool SetOnline) if (InList) db_unset(hContact, "CList", "NotOnList"); setWString(hContact, "Nick", user->name); - db_unset(hContact, "CList", "Hidden"); + Clist_HideContact(hContact, false); if (SetOnline && getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) setWord(hContact, "Status", ID_STATUS_ONLINE); return hContact; @@ -105,7 +105,7 @@ MCONTACT CIrcProto::CList_AddContact(CONTACT *user, bool InList, bool SetOnline) db_unset(hContact, "CList", "NotOnList"); else db_set_b(hContact, "CList", "NotOnList", 1); - db_unset(hContact, "CList", "Hidden"); + Clist_HideContact(hContact, false); setWString(hContact, "Nick", user->name); setWString(hContact, "Default", user->name); setWord(hContact, "Status", SetOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE); diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 36ae19a469..d982705974 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -146,7 +146,7 @@ VOID CALLBACK OnlineNotifTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD) continue; BYTE bDCC = ppro->getByte(hContact, "DCC", 0); - BYTE bHidden = db_get_b(hContact, "CList", "Hidden", 0); + bool bHidden = Clist_IsHidden(hContact); if (bDCC || bHidden) continue; if (ppro->getWString(hContact, "Default", &dbv)) @@ -691,7 +691,7 @@ bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage *pmsg) if ((m_ignore && IsIgnored(pmsg->prefix.sNick, pmsg->prefix.sUser, pmsg->prefix.sHost, 'q'))) { MCONTACT hContact = CList_FindContact(&user); - if (!hContact || (hContact && db_get_b(hContact, "CList", "Hidden", 0) == 1)) + if (!hContact || (hContact && Clist_IsHidden(hContact))) return true; } @@ -1063,10 +1063,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage *pmsg) MCONTACT hContact = CList_FindContact(&user); // check if it should be ignored - if (m_DCCChatIgnore == 1 || - m_DCCChatIgnore == 2 && hContact && - db_get_b(hContact, "CList", "NotOnList", 0) == 0 && - db_get_b(hContact, "CList", "Hidden", 0) == 0) { + if (m_DCCChatIgnore == 1 || m_DCCChatIgnore == 2 && hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 0 && !Clist_IsHidden(hContact)) { CMStringW host = pmsg->prefix.sUser + L"@" + pmsg->prefix.sHost; CList_AddDCCChat(pmsg->prefix.sNick, host, dwAdr, iPort); // add a CHAT event to the clist } -- cgit v1.2.3