From e441a31e9f912fc8e9244d16560565559b1924d2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 27 Sep 2019 23:43:06 +0300 Subject: end of manual experiments with CList/NotOnList --- src/core/stdfile/src/file.cpp | 2 +- src/core/stdfile/src/filerecvdlg.cpp | 6 +++--- src/core/stdfile/src/filexferdlg.cpp | 6 ++++-- src/core/stdmsg/src/msgdialog.cpp | 8 ++++---- src/mir_app/src/addcontact.cpp | 2 +- src/mir_app/src/auth.cpp | 8 ++++---- src/mir_app/src/clcitems.cpp | 2 +- src/mir_app/src/clistmod.cpp | 4 ++-- src/mir_app/src/contacts.cpp | 17 +++++++++++++++++ src/mir_app/src/ignore.cpp | 2 +- src/mir_app/src/menu_clist.cpp | 2 +- src/mir_app/src/meta_utils.cpp | 2 +- src/mir_app/src/mir_app.def | 3 +++ src/mir_app/src/mir_app64.def | 3 +++ 14 files changed, 46 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index cd106fedba..df862eb0ca 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -101,7 +101,7 @@ void PushFileEvent(MCONTACT hContact, MEVENT hdbe, LPARAM lParam) cle.hContact = hContact; cle.hDbEvent = hdbe; cle.lParam = lParam; - if (g_plugin.getByte("AutoAccept", 0) && !db_get_b(hContact, "CList", "NotOnList", 0)) { + if (g_plugin.getByte("AutoAccept", 0) && Contact_OnList(hContact)) { CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, (LPARAM)&cle); } else { diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 2fe57e4935..6c14b8d406 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -250,7 +250,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ptrW info(Contact_GetInfo(CNF_UNIQUEID, dat->hContact)); SetDlgItemText(hwndDlg, IDC_NAME, (info) ? info : contactName); - if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) { + if (!Contact_OnList(dat->hContact)) { RECT rcBtn1, rcBtn2, rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2); @@ -261,7 +261,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } - if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) + if (Contact_OnList(dat->hContact)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } return TRUE; @@ -348,7 +348,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_ADD: Contact_Add(dat->hContact, hwndDlg); - if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) + if (Contact_OnList(dat->hContact)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); break; diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index 9f8bc128f8..adaa06e9cf 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -245,8 +245,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR CreateDirectoryTreeW(dat->szSavePath); dat->fs = (HANDLE)ProtoChainSend(dat->hContact, PSS_FILEALLOW, (WPARAM)dat->fs, (LPARAM)dat->szSavePath); dat->transferStatus.szWorkingDir.w = mir_wstrdup(dat->szSavePath); - if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) dat->resumeBehaviour = FILERESUME_ASK; - else dat->resumeBehaviour = g_plugin.getByte("IfExists", FILERESUME_ASK); + if (!Contact_OnList(dat->hContact)) + dat->resumeBehaviour = FILERESUME_ASK; + else + dat->resumeBehaviour = g_plugin.getByte("IfExists", FILERESUME_ASK); SetFtStatus(hwndDlg, LPGENW("Waiting for connection..."), FTS_TEXT); } diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index f5e3c146c3..d1e6bfdb9c 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -336,7 +336,7 @@ void CMsgDialog::OnDestroy() // a temporary contact should be destroyed after removing window from the window list to prevent recursion if (m_hContact && g_dat.bDeleteTempCont) - if (db_get_b(m_hContact, "CList", "NotOnList", 0)) + if (!Contact_OnList(m_hContact)) db_delete_contact(m_hContact); } @@ -878,7 +878,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case IDC_ADD: Contact_Add(m_hContact, m_hwnd); - if (!db_get_b(m_hContact, "CList", "NotOnList", 0)) + if (Contact_OnList(m_hContact)) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE); break; } @@ -1472,7 +1472,7 @@ void CMsgDialog::OnOptionsApplied(bool bUpdateAvatar) bool bShow = false; if (m_hContact && g_dat.bShowButtons) { if (cbd->m_dwButtonCID == IDC_ADD) { - bShow = 0 != db_get_b(m_hContact, "CList", "NotOnList", 0); + bShow = !Contact_OnList(m_hContact); cbd->m_bHidden = !bShow; } else bShow = true; @@ -1611,7 +1611,7 @@ void CMsgDialog::NotifyTyping(int mode) if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(m_hContact, m_szProto, "ApparentMode", 0) != ID_STATUS_ONLINE) return; - if (!g_dat.bTypingUnknown && db_get_b(m_hContact, "CList", "NotOnList", 0)) + if (!g_dat.bTypingUnknown && !Contact_OnList(m_hContact)) return; // End user check diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp index 4d89422941..634ef8a50e 100644 --- a/src/mir_app/src/addcontact.cpp +++ b/src/mir_app/src/addcontact.cpp @@ -146,7 +146,7 @@ public: if (item > 0) Clist_ContactChangeGroup(hContact, m_group.GetItemData(item)); - db_unset(hContact, "CList", "NotOnList"); + Contact_PutOnList(hContact); if (m_chkAuth.GetState()) { DWORD flags = CallProtoServiceInt(0, m_szProto, PS_GETCAPS, PFLAGNUM_4, 0); diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp index 11b834b36c..c17866e93a 100644 --- a/src/mir_app/src/auth.cpp +++ b/src/mir_app/src/auth.cpp @@ -117,7 +117,7 @@ public: SetDlgItemText(m_hwnd, IDC_HEADERBAR, hdr); SetDlgItemText(m_hwnd, IDC_REASON, reasonT); - if (m_hContact == INVALID_CONTACT_ID || !db_get_b(m_hContact, "CList", "NotOnList", 0)) + if (m_hContact == INVALID_CONTACT_ID || Contact_OnList(m_hContact)) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE); SendDlgItemMessage(m_hwnd, IDC_DENYREASON, EM_LIMITTEXT, 255, 0); @@ -126,7 +126,7 @@ public: SetDlgItemText(m_hwnd, IDC_DENYREASON, TranslateT("Feature is not supported by protocol")); } - if (!db_get_b(m_hContact, "CList", "NotOnList", 0)) { + if (Contact_OnList(m_hContact)) { chkAdd.Disable(); chkAdd.SetState(false); } @@ -254,7 +254,7 @@ public: mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT.get() : TranslateT("(Unknown)"), acc->tszAccountName); SetDlgItemText(m_hwnd, IDC_HEADERBAR, hdr); - if (m_hContact == INVALID_CONTACT_ID || !db_get_b(m_hContact, "CList", "NotOnList", 0)) + if (m_hContact == INVALID_CONTACT_ID || Contact_OnList(m_hContact)) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE); return true; } @@ -276,7 +276,7 @@ public: { Contact_AddByEvent(m_hDbEvent, m_hwnd); - if (m_hContact == INVALID_CONTACT_ID || !db_get_b(m_hContact, "CList", "NotOnList", 0)) + if (m_hContact == INVALID_CONTACT_ID || Contact_OnList(m_hContact)) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE); } diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index ac6e365177..17da6a7888 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -201,7 +201,7 @@ ClcContact* fnAddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact cc->flags |= CONTACTF_VISTO; else if (apparentMode) cc->flags |= CONTACTF_VISTO | CONTACTF_INVISTO; - if (db_get_b(hContact, "CList", "NotOnList", 0)) + if (!Contact_OnList(hContact)) cc->flags |= CONTACTF_NOTONLIST; DWORD idleMode = szProto != nullptr ? db_get_dw(hContact, szProto, "IdleTS", 0) : 0; if (idleMode) diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index ed2f250eb5..7769183396 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -239,7 +239,7 @@ int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) { RECT rc, rcWin, rcWorkArea; POINT pt; - register int i, j, width, height, iCountedDots = 0, iNotCoveredDots = 0; + int i, j, width, height, iCountedDots = 0, iNotCoveredDots = 0; BOOL bPartiallyCovered = FALSE; HWND hAux = nullptr; @@ -405,7 +405,7 @@ void UnloadContactListModule() // remove transitory contacts for (MCONTACT hContact = db_find_first(); hContact != 0; ) { MCONTACT hNext = db_find_next(hContact); - if (db_get_b(hContact, "CList", "NotOnList", 0)) + if (!Contact_OnList(hContact)) db_delete_contact(hContact); hContact = hNext; } diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index daf95dbf86..afd191c9b0 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -294,6 +294,23 @@ MIR_APP_DLL(void) Contact_Hide(MCONTACT hContact, bool bHidden) db_unset(hContact, "CList", "Hidden"); } +/////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(bool) Contact_OnList(MCONTACT hContact) +{ + return db_get_b(hContact, "CList", "NotOnList", 0) == 0; +} + +MIR_APP_DLL(void) Contact_PutOnList(MCONTACT hContact) +{ + db_unset(hContact, "CList", "NotOnList"); +} + +MIR_APP_DLL(void) Contact_RemoveFromList(MCONTACT hContact) +{ + db_set_b(hContact, "CList", "NotOnList", 1); +} + ///////////////////////////////////////////////////////////////////////////////////////// // Options dialog diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 56c38e303f..9832bf56e1 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -38,7 +38,7 @@ static DWORD GetMask(MCONTACT hContact) if (hContact == 0) mask = 0; else { - if (Contact_IsHidden(hContact) || db_get_b(hContact, "CList", "NotOnList", 0)) + if (Contact_IsHidden(hContact) || !Contact_OnList(hContact)) mask = db_get_dw(0, "Ignore", "Mask1", 0); else mask = db_get_dw(0, "Ignore", "Default1", 0); diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index 181df23c64..2f16fe578f 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -229,7 +229,7 @@ EXTERN_C MIR_APP_DLL(HMENU) Menu_BuildContactMenu(MCONTACT hContact) BuildContactParam bcp; bcp.szProto = szProto; - bcp.isOnList = (db_get_b(hContact, "CList", "NotOnList", 0) == 0); + bcp.isOnList = Contact_OnList(hContact); bcp.isOnline = (szProto != nullptr && ID_STATUS_OFFLINE != db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)); HMENU hMenu = CreatePopupMenu(); diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp index e16a24d00b..9bae3558e5 100644 --- a/src/mir_app/src/meta_utils.cpp +++ b/src/mir_app/src/meta_utils.cpp @@ -79,7 +79,7 @@ BOOL Meta_Assign(MCONTACT hSub, MCONTACT hMeta, BOOL set_as_default) } // Check that is is 'on the list' - if (db_get_b(hSub, "CList", "NotOnList", 0) == 1) { + if (!Contact_OnList(hSub)) { MessageBox(nullptr, TranslateT("Contact is 'not on list' - please add the contact to your contact list before assigning."), TranslateT("Assignment error"), MB_OK | MB_ICONWARNING); db_free(&dbv); return FALSE; diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index a31384307a..5bfcbfed5a 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -693,3 +693,6 @@ Miranda_GetIdle @778 NONAME Ignore_Allow @779 Ignore_Ignore @780 Ignore_IsIgnored @781 +Contact_OnList @782 +Contact_PutOnList @783 +Contact_RemoveFromList @784 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index c92292f409..3a5645f024 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -693,3 +693,6 @@ Miranda_GetIdle @778 NONAME Ignore_Allow @779 Ignore_Ignore @780 Ignore_IsIgnored @781 +Contact_OnList @782 +Contact_PutOnList @783 +Contact_RemoveFromList @784 -- cgit v1.2.3