summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-27 20:23:20 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-27 20:23:20 +0300
commitd18fdf58c517c957809e9ec0b8044a05984de7c6 (patch)
tree795967aee27142f012f47e739b1bbb31c53b7450 /plugins
parentabc610a264a0a9c03effe579283c7d4c4fdf08b5 (diff)
fixes #4140 (NewStory: удаление отдельных сообщений)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewStory/res/resource.rc12
-rw-r--r--plugins/NewStory/src/history_control.cpp77
-rw-r--r--plugins/NewStory/src/history_control.h1
-rw-r--r--plugins/NewStory/src/resource.h4
4 files changed, 91 insertions, 3 deletions
diff --git a/plugins/NewStory/res/resource.rc b/plugins/NewStory/res/resource.rc
index 2764a4c02f..69b81bcd7f 100644
--- a/plugins/NewStory/res/resource.rc
+++ b/plugins/NewStory/res/resource.rc
@@ -174,6 +174,18 @@ BEGIN
CONTROL "",IDC_VARHELP,"MButtonClass",WS_DISABLED | WS_TABSTOP,284,202,16,16
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 remove selected event(s)?",IDC_TOPLINE,"Static",SS_SIMPLE | SS_NOPREFIX | WS_GROUP,7,7,270,8
+ 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
/////////////////////////////////////////////////////////////////////////////
//
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index 2e7f799833..bf9188e5e0 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -303,21 +303,87 @@ void NewstoryListData::CopyUrl()
Srmm_DownloadOfflineFile(pItem->hContact, pItem->hEvent, OFD_COPYURL);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Delete events dialog
+
+class CDeleteEventsDlg : public CDlgBase
+{
+ MCONTACT m_hContact;
+ CCtrlCheck chkDelHistory, chkForEveryone;
+
+public:
+ bool bDelHistory = false, bForEveryone = false;
+
+ CDeleteEventsDlg(MCONTACT hContact) :
+ CDlgBase(g_plugin, IDD_EMPTYHISTORY),
+ chkDelHistory(this, IDC_DELSERVERHISTORY),
+ chkForEveryone(this, IDC_BOTH)
+ {
+ if (char *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);
+
+ bool bEnabled = bDelHistory && bForEveryone;
+ chkForEveryone.SetState(!bEnabled);
+ chkForEveryone.Enable(bEnabled);
+
+ 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));
+ }
+};
+
void NewstoryListData::DeleteItems(void)
{
- if (IDYES != MessageBoxW(m_hwnd, TranslateT("Are you sure to remove selected event(s)?"), _T(MODULETITLE), MB_YESNOCANCEL | MB_ICONQUESTION))
+ CDeleteEventsDlg dlg(m_hContact);
+ if (IDOK != dlg.DoModal())
return;
g_plugin.bDisableDelete = true;
- int firstSel = -1;
+ int firstSel = -1, flags = 0;
+ if (dlg.bDelHistory)
+ flags |= CDF_FROM_SERVER;
+ if (dlg.bForEveryone)
+ flags |= CDF_FOR_EVERYONE;
+
for (int i = totalCount - 1; i >= 0; i--) {
auto *p = GetItem(i);
if (!p->m_bSelected)
continue;
if (p->hEvent)
- db_event_delete(p->hEvent);
+ db_event_delete(p->hEvent, flags);
items.remove(i);
totalCount--;
firstSel = i;
@@ -332,6 +398,8 @@ void NewstoryListData::DeleteItems(void)
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void NewstoryListData::Download(int options)
{
if (auto *p = LoadItem(caret))
@@ -766,8 +834,11 @@ void NewstoryListData::SetCaret(int idx, bool bEnsureVisible)
EnsureVisible(idx);
}
}
+
void NewstoryListData::SetContact(MCONTACT hContact)
{
+ m_hContact = hContact;
+
WindowList_Add(g_hNewstoryLogs, m_hwnd, hContact);
}
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h
index 206f9514ac..eb14bf6cc9 100644
--- a/plugins/NewStory/src/history_control.h
+++ b/plugins/NewStory/src/history_control.h
@@ -22,6 +22,7 @@ struct NewstoryListData : public MZeroedObject
int totalCount;
RECT rcLastPaint;
+ MCONTACT m_hContact = INVALID_CONTACT_ID;
bool bWasShift, bSortAscending, bWasAtBottom;
diff --git a/plugins/NewStory/src/resource.h b/plugins/NewStory/src/resource.h
index 4281744430..8862d46dd3 100644
--- a/plugins/NewStory/src/resource.h
+++ b/plugins/NewStory/src/resource.h
@@ -31,6 +31,7 @@
#define IDI_VARHELP 128
#define IDI_TIMETREE 129
#define IDI_REPLY 130
+#define IDD_EMPTYHISTORY 131
#define IDC_USERINFO 1000
#define IDC_USERMENU 1001
#define IDC_MESSAGE 1002
@@ -95,6 +96,9 @@
#define IDC_BOOKMARKSLIST 1060
#define IDC_SHOW_TYPE 1060
#define IDC_SHOW_DIRECTION 1061
+#define IDC_TOPLINE 1062
+#define IDC_DELSERVERHISTORY 1063
+#define IDC_BOTH 1064
#define ID_FILTER_SHOWALLEVENTS 40001
#define ID_FILTER_SHOWINCOMINGEVENTSONLY 40002
#define ID_FILTER_SHOWOUTGOINGEVENTSONLY 40003