diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-24 14:30:28 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-24 14:30:28 +0300 |
commit | 660b4e02d4bef4f7ac953689ce00d727bf9bacbd (patch) | |
tree | bbf88aac1bfe8c47608a0d3c99971f7fae9218e0 /src/mir_app | |
parent | 1de0331abb7082ebda12896cd52a509047ae5799 (diff) |
PS_EMPTY_SRV_HISTORY introduced for removing server history for a contact
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/res/resource.rc | 14 | ||||
-rw-r--r-- | src/mir_app/src/clui.cpp | 13 | ||||
-rw-r--r-- | src/mir_app/src/resource.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_main.cpp | 61 |
4 files changed, 83 insertions, 6 deletions
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index 2df21d5287..69f5a92395 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -73,6 +73,20 @@ BEGIN DEFPUSHBUTTON "&No",IDCANCEL,221,78,65,14
END
+IDD_EMPTYHISTORY DIALOGEX 0, 0, 294, 86
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Empty history"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "Are you sure to wipe the history for %s?",IDC_TOPLINE,"Static",SS_SIMPLE | SS_NOPREFIX | WS_GROUP,7,7,270,8
+ LTEXT "This will erase all history for this contact!",IDC_STATIC,7,18,239,16
+ CONTROL "Remove server history", IDC_DELSERVERHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,37,280,8
+ CONTROL "Remove history for everyone",IDC_BOTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,50,260,8
+ PUSHBUTTON "&Yes",IDOK,149,65,65,14
+ DEFPUSHBUTTON "&No",IDCANCEL,221,65,65,14
+END
+
IDD_OPT_CONTACT DIALOGEX 0, 0, 313, 242
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index b942e43469..f01ed76b7c 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -141,25 +141,25 @@ public: CDlgBase(g_plugin, IDD_DELETECONTACT),
m_hContact(hContact),
chkDelContact(this, IDC_DELSERVERCONTACT),
- chkDelHistory(this, IDC_DELETEHISTORY),
+ chkDelHistory(this, IDC_DELSERVERHISTORY),
chkForEveryone(this, IDC_BOTH)
{
szProto = Proto_GetBaseAccountName(hContact);
bDelContact = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_SERVERCLIST) != 0;
- bDelHistory = ProtoServiceExists(szProto, PS_GETCAPS);
+ bDelHistory = ProtoServiceExists(szProto, PS_EMPTY_SRV_HISTORY);
bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_DELETEFORALL) != 0;
}
bool OnInitDialog() override
{
chkDelContact.SetState(bDelContact);
- chkDelHistory.Enable(bDelHistory);
chkDelHistory.SetState(bDelHistory);
- chkForEveryone.Enable(bDelHistory && bForEveryone);
+ chkDelHistory.Enable(bDelHistory);
chkForEveryone.SetState(bForEveryone);
+ chkForEveryone.Enable(bDelHistory && bForEveryone);
LOGFONT lf;
- HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDYES, WM_GETFONT, 0, 0);
+ HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDOK, WM_GETFONT, 0, 0);
GetObject(hFont, sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
SendDlgItemMessage(m_hwnd, IDC_TOPLINE, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
@@ -217,6 +217,9 @@ static INT_PTR MenuItem_DeleteContact(WPARAM hContact, LPARAM lParam) if (dlg.bForEveryone)
options |= CDF_FOR_EVERYONE;
+ if (dlg.bDelHistory)
+ CallContactService(hContact, PS_EMPTY_SRV_HISTORY, CDF_DEL_HISTORY | (dlg.bForEveryone ? CDF_FOR_EVERYONE : 0));
+
int status = Proto_GetStatus(dlg.szProto);
if (status == ID_STATUS_OFFLINE || IsStatusConnecting(status)) {
// Set a flag so we remember to delete the contact when the protocol goes online the next time
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h index d526e2c4f2..9787221267 100644 --- a/src/mir_app/src/resource.h +++ b/src/mir_app/src/resource.h @@ -130,6 +130,7 @@ #define IDD_FILETRANSFERINFO 249
#define IDD_OPT_FILEGENERAL 250
#define IDD_OPT_FILESECURITY 251
+#define IDD_EMPTYHISTORY 252
#define IDD_FILEEXISTS 253
#define IDD_DELETECONTACT 254
#define IDD_ADDCONTACT 257
diff --git a/src/mir_app/src/srmm_main.cpp b/src/mir_app/src/srmm_main.cpp index 4c6786aa8a..5050ebec5d 100644 --- a/src/mir_app/src/srmm_main.cpp +++ b/src/mir_app/src/srmm_main.cpp @@ -31,13 +31,70 @@ void UnloadSrmmToolbarModule(); ///////////////////////////////////////////////////////////////////////////////////////// // Empty history service for main menu +class CEmptyHistoryDlg : public CDlgBase +{ + MCONTACT m_hContact; + CCtrlCheck chkDelHistory, chkForEveryone; + +public: + char *szProto; + bool bDelHistory, bForEveryone; + + CEmptyHistoryDlg(MCONTACT hContact) : + CDlgBase(g_plugin, IDD_EMPTYHISTORY), + m_hContact(hContact), + chkDelHistory(this, IDC_DELSERVERHISTORY), + chkForEveryone(this, IDC_BOTH) + { + szProto = Proto_GetBaseAccountName(hContact); + bDelHistory = ProtoServiceExists(szProto, PS_EMPTY_SRV_HISTORY); + bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_DELETEFORALL) != 0; + } + + bool OnInitDialog() override + { + chkDelHistory.SetState(bDelHistory); + chkDelHistory.Enable(bDelHistory); + chkForEveryone.SetState(bForEveryone); + chkForEveryone.Enable(bDelHistory && bForEveryone); + + LOGFONT lf; + HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDOK, WM_GETFONT, 0, 0); + GetObject(hFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + SendDlgItemMessage(m_hwnd, IDC_TOPLINE, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0); + + wchar_t szFormat[256], szFinal[256]; + GetDlgItemText(m_hwnd, IDC_TOPLINE, szFormat, _countof(szFormat)); + mir_snwprintf(szFinal, szFormat, Clist_GetContactDisplayName(m_hContact)); + SetDlgItemText(m_hwnd, IDC_TOPLINE, szFinal); + + SetFocus(GetDlgItem(m_hwnd, IDNO)); + SetWindowPos(m_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + return true; + } + + bool OnApply() override + { + bDelHistory = chkDelHistory.IsChecked(); + bForEveryone = chkForEveryone.IsChecked(); + return true; + } + + void OnDestroy() override + { + DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TOPLINE, WM_GETFONT, 0, 0)); + } +}; + static INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM lParam) { if (NotifyEventHooks(hHookEmptyHistory)) return 2; + CEmptyHistoryDlg dlg(hContact); if (lParam == 0) - if (IDYES != MessageBoxW(nullptr, TranslateT("Are you sure to remove all events from history?"), L"Miranda", MB_YESNO | MB_ICONQUESTION)) + if (dlg.DoModal() != IDOK) return 1; DB::ECPTR pCursor(DB::Events(hContact)); @@ -48,6 +105,8 @@ static INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM lParam) if (auto *si = SM_FindSessionByContact(hContact)) Chat_EmptyHistory(si); + if (dlg.bDelHistory) + CallContactService(hContact, PS_EMPTY_SRV_HISTORY, CDF_DEL_HISTORY | (dlg.bForEveryone ? CDF_FOR_EVERYONE : 0)); return 0; } |