summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_protosvc.h25
-rw-r--r--src/mir_app/res/resource.rc14
-rw-r--r--src/mir_app/src/clui.cpp13
-rw-r--r--src/mir_app/src/resource.h1
-rw-r--r--src/mir_app/src/srmm_main.cpp61
5 files changed, 99 insertions, 15 deletions
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index 5291a94759..a1f1a6a193 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -202,6 +202,15 @@ static __inline unsigned long Proto_Status2Flag(int status)
#define PS_LOADICON "/LoadIcon"
///////////////////////////////////////////////////////////////////////////////
+// Get the status mode that a protocol is currently in
+// wParam = lParam = 0
+// Returns the status mode
+// Non-network-level protocol modules do not have the concept of a status and
+// should leave this service unimplemented
+
+#define PS_GETSTATUS "/GetStatus"
+
+///////////////////////////////////////////////////////////////////////////////
// Change the protocol's status mode
// wParam = newMode, from ui/contactlist/statusmodes.h
// lParam = 0
@@ -259,15 +268,6 @@ static __inline unsigned long Proto_Status2Flag(int status)
#define PS_SETAWAYMSG "/SetAwayMsg"
///////////////////////////////////////////////////////////////////////////////
-// Get the status mode that a protocol is currently in
-// wParam = lParam = 0
-// Returns the status mode
-// Non-network-level protocol modules do not have the concept of a status and
-// should leave this service unimplemented
-
-#define PS_GETSTATUS "/GetStatus"
-
-///////////////////////////////////////////////////////////////////////////////
// Updates a contact's details from the server
// wParam = flags
// lParam = 0
@@ -581,6 +581,13 @@ struct PROTOFILERESUME
#define PS_MENU_LOADHISTORY "/LoadServerHistory"
///////////////////////////////////////////////////////////////////////////////
+// Empties the server history for a contact
+// wParam = hContact
+// lParam = 0
+
+#define PS_EMPTY_SRV_HISTORY "/EmptyServerHistory"
+
+///////////////////////////////////////////////////////////////////////////////
// SENDING SERVICES
// these should be called with ProtoChainSend()
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;
}