diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-23 19:05:51 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-23 19:05:51 +0300 |
commit | 60fec7a89a7870d52ebd76315193b105973b1219 (patch) | |
tree | 8df3b928516934d478367791bf5b8d2f4b92a930 /src/mir_app | |
parent | 14b6b214743b1913258fc03c21f5e0841a66c2fd (diff) |
fixes #4104 (Удаление серверной истории)
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/res/resource.rc | 87 | ||||
-rw-r--r-- | src/mir_app/src/clc.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clui.cpp | 163 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/proto_interface.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/resource.h | 5 |
7 files changed, 104 insertions, 161 deletions
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index b683748fde..2df21d5287 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -58,19 +58,19 @@ BEGIN EDITTEXT IDC_AUTHREQ,13,95,204,29,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
END
-IDD_DELETECONTACT DIALOGEX 0, 0, 294, 101
+IDD_DELETECONTACT DIALOGEX 0, 0, 294, 99
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_CONTROLPARENT
CAPTION "Delete contact"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- PUSHBUTTON "&Yes",IDYES,58,38,65,14
- DEFPUSHBUTTON "&No",IDNO,172,38,65,14
- CONTROL "Hide from list only, in order to keep their history and ignore/visibility settings",IDC_HIDE,
- "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,65,280,9
- LTEXT "Use Options -> Contacts -> Ignore to unhide contacts.",IDC_STATIC,20,78,257,16
CONTROL "Are you sure you want to delete %s?",IDC_TOPLINE,"Static",SS_SIMPLE | SS_NOPREFIX | WS_GROUP,7,7,270,8
LTEXT "This will erase all history and settings for this contact!",IDC_STATIC,7,18,239,16
+ CONTROL "Remove contact from server too",IDC_DELSERVERCONTACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,37,280,8
+ CONTROL "Remove server history", IDC_DELSERVERHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,50,280,8
+ CONTROL "Remove history for everyone",IDC_BOTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,63,260,8
+ PUSHBUTTON "&Yes",IDOK,149,78,65,14
+ DEFPUSHBUTTON "&No",IDCANCEL,221,78,65,14
END
IDD_OPT_CONTACT DIALOGEX 0, 0, 313, 242
@@ -1185,7 +1185,7 @@ BEGIN LEFTMARGIN, 7
RIGHTMARGIN, 286
TOPMARGIN, 7
- BOTTOMMARGIN, 88
+ BOTTOMMARGIN, 79
END
IDD_OPT_CONTACT, DIALOG
@@ -1270,12 +1270,6 @@ BEGIN VERTGUIDE, 305
END
- IDD_OPT_VISIBILITY, DIALOG
- BEGIN
- VERTGUIDE, 8
- VERTGUIDE, 305
- END
-
IDD_ICONINDEX, DIALOG
BEGIN
LEFTMARGIN, 4
@@ -1757,77 +1751,10 @@ BEGIN END
END
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// AFX_DIALOG_LAYOUT
-//
-
-IDD_OPT_SRMMLOG AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_CLIST AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_CHAT_EVENTS AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_SOUND AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_NETLIBLOGOPTS AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_GENMENU AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_POPUPOPTION AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_FILESECURITY AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_OPT_FILEGENERAL AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_NEWPASS AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_CHANGEPASS AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
-IDD_PROFILE_NEW AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
-
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index ff352246f2..9f4d32e9a6 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -134,8 +134,8 @@ static int ClcProtoAck(WPARAM, LPARAM lParam) if (caps & PF1_SERVERCLIST) {
for (MCONTACT hContact = db_find_first(ack->szModule); hContact; ) {
MCONTACT hNext = db_find_next(hContact, ack->szModule);
- if (db_get_b(hContact, "CList", "Delete", 0))
- db_delete_contact(hContact);
+ if (int options = db_get_b(hContact, "CList", "Delete"))
+ db_delete_contact(hContact, options);
hContact = hNext;
}
}
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index e46368d640..7efc4404be 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -126,93 +126,106 @@ static INT_PTR MenuItem_RenameContact(WPARAM, LPARAM) return 0;
}
-static INT_PTR CALLBACK AskForConfirmationDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hWnd);
- {
- LOGFONT lf;
- HFONT hFont = (HFONT)SendDlgItemMessage(hWnd, IDYES, WM_GETFONT, 0, 0);
- GetObject(hFont, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- SendDlgItemMessage(hWnd, IDC_TOPLINE, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
-
- wchar_t szFormat[256], szFinal[256];
- GetDlgItemText(hWnd, IDC_TOPLINE, szFormat, _countof(szFormat));
- mir_snwprintf(szFinal, szFormat, Clist_GetContactDisplayName(lParam));
- SetDlgItemText(hWnd, IDC_TOPLINE, szFinal);
- }
- SetFocus(GetDlgItem(hWnd, IDNO));
- SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDYES:
- if (IsDlgButtonChecked(hWnd, IDC_HIDE)) {
- EndDialog(hWnd, IDC_HIDE);
- break;
- }
- __fallthrough;
+/////////////////////////////////////////////////////////////////////////////////////////
- case IDCANCEL:
- case IDNO:
- EndDialog(hWnd, LOWORD(wParam));
- break;
- }
- break;
+class CDeleteDlg : public CDlgBase
+{
+ MCONTACT m_hContact;
+ CCtrlCheck chkDelContact, chkDelHistory, chkForEveryone;
+
+public:
+ char *szProto;
+ bool bDelContact, bDelHistory, bForEveryone;
+
+ CDeleteDlg(MCONTACT hContact) :
+ CDlgBase(g_plugin, IDD_DELETECONTACT),
+ m_hContact(hContact),
+ chkDelContact(this, IDC_DELSERVERCONTACT),
+ chkDelHistory(this, IDC_DELETEHISTORY),
+ chkForEveryone(this, IDC_BOTH)
+ {
+ szProto = Proto_GetBaseAccountName(hContact);
+ bDelContact = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_SERVERCLIST) != 0;
+ bDelHistory = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_SERVERMSGID) != 0;
+ bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_DELETEFORALL) != 0;
+ }
- case WM_CLOSE:
- SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDNO, BN_CLICKED), 0);
- break;
+ bool OnInitDialog() override
+ {
+ chkDelContact.SetState(bDelContact);
+ chkDelHistory.Enable(bDelHistory);
+ chkDelHistory.SetState(bDelHistory);
+ chkForEveryone.Enable(bDelHistory && bForEveryone);
+ chkForEveryone.SetState(bForEveryone);
+
+ LOGFONT lf;
+ HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDYES, 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;
+ }
- case WM_DESTROY:
- DeleteObject((HFONT)SendDlgItemMessage(hWnd, IDC_TOPLINE, WM_GETFONT, 0, 0));
- break;
+ bool OnApply() override
+ {
+ bDelContact = chkDelContact.IsChecked();
+ bDelHistory = chkDelHistory.IsChecked();
+ bForEveryone = chkForEveryone.IsChecked();
+ return true;
}
- return FALSE;
-}
+ void OnDestroy() override
+ {
+ DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TOPLINE, WM_GETFONT, 0, 0));
+ }
+};
-static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam)
+static INT_PTR MenuItem_DeleteContact(WPARAM hContact, LPARAM lParam)
{
- //see notes about deleting contacts on PF1_SERVERCLIST servers in m_protosvc.h
- UINT_PTR action;
+ CDeleteDlg dlg(hContact);
+ if (dlg.szProto == nullptr)
+ return 0;
- if (Clist::ConfirmDelete && !(GetKeyState(VK_SHIFT) & 0x8000))
+ int action;
+ if (Clist::ConfirmDelete && !(GetKeyState(VK_SHIFT) & 0x8000)) {
// Ask user for confirmation, and if the contact should be archived (hidden, not deleted)
- action = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DELETECONTACT), (HWND)lParam, AskForConfirmationDlgProc, wParam);
- else
- action = IDYES;
-
- switch (action) {
- case IDC_HIDE: // Archive contact
- Contact::Hide(wParam);
- break;
+ dlg.SetParent((HWND)lParam);
+ action = dlg.DoModal();
+ }
+ else action = IDOK;
- case IDYES: // Delete contact
- char *szProto = Proto_GetBaseAccountName(wParam);
- if (szProto != nullptr) {
- // Check if protocol uses server side lists
- uint32_t caps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- if (caps & PF1_SERVERCLIST) {
- int status = Proto_GetStatus(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
- db_set_b(wParam, "CList", "Delete", 1);
- MessageBoxW(nullptr,
- TranslateT("This contact is on an instant messaging system which stores its contact list on a central server. The contact will be removed from the server and from your contact list when you next connect to that network."),
- TranslateT("Delete contact"), MB_ICONINFORMATION | MB_OK);
- return 0;
- }
- }
- }
+ if (action != IDOK)
+ return 0;
- db_delete_contact(wParam);
- break;
+ int options = 0;
+ if (!dlg.bDelContact)
+ Contact::Hide(hContact);
+ else
+ options |= CDF_DEL_CONTACT;
+
+ // Check if protocol uses server side lists
+ if (dlg.bDelHistory)
+ options |= CDF_DEL_HISTORY;
+ if (dlg.bForEveryone)
+ options |= CDF_FOR_EVERYONE;
+
+ 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
+ db_set_b(hContact, "CList", "Delete", options);
+ MessageBoxW(nullptr,
+ TranslateT("This contact is on an instant messaging system which stores its contact list on a central server. The contact will be removed from the server and from your contact list when you next connect to that network."),
+ TranslateT("Delete contact"), MB_ICONINFORMATION | MB_OK);
}
-
+ else db_delete_contact(hContact, options);
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 1fa9ad6573..7ebde24f72 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -486,7 +486,7 @@ Proto_GetStatus @601 ?OnModulesLoaded@PROTO_INTERFACE@@UAEXXZ @607 NONAME
?OnShutdown@PROTO_INTERFACE@@UAEXXZ @608 NONAME
?GetStatus@Contact@@YGHI@Z @609 NONAME
-?OnContactDeleted@PROTO_INTERFACE@@UAE_NI@Z @610 NONAME
+?OnContactDeleted@PROTO_INTERFACE@@UAE_NII@Z @610 NONAME
?OnBuildProtoMenu@PROTO_INTERFACE@@UAEXXZ @611 NONAME
?OnErase@PROTO_INTERFACE@@UAEXXZ @612 NONAME
?getMStringA@CMPluginBase@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD0@Z @613 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6b2391f2cb..6de004a53d 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -486,7 +486,7 @@ Proto_GetStatus @601 ?OnModulesLoaded@PROTO_INTERFACE@@UEAAXXZ @607 NONAME
?OnShutdown@PROTO_INTERFACE@@UEAAXXZ @608 NONAME
?GetStatus@Contact@@YAHI@Z @609 NONAME
-?OnContactDeleted@PROTO_INTERFACE@@UEAA_NI@Z @610 NONAME
+?OnContactDeleted@PROTO_INTERFACE@@UEAA_NII@Z @610 NONAME
?OnBuildProtoMenu@PROTO_INTERFACE@@UEAAXXZ @611 NONAME
?OnErase@PROTO_INTERFACE@@UEAAXXZ @612 NONAME
?getMStringA@CMPluginBase@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD0@Z @613 NONAME
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp index 31f04aaf0d..76b7b17778 100644 --- a/src/mir_app/src/proto_interface.cpp +++ b/src/mir_app/src/proto_interface.cpp @@ -72,7 +72,7 @@ void PROTO_INTERFACE::OnBuildProtoMenu() void PROTO_INTERFACE::OnContactAdded(MCONTACT)
{}
-bool PROTO_INTERFACE::OnContactDeleted(MCONTACT)
+bool PROTO_INTERFACE::OnContactDeleted(MCONTACT, uint32_t)
{
return true;
}
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h index 5d7c3e08d0..d526e2c4f2 100644 --- a/src/mir_app/src/resource.h +++ b/src/mir_app/src/resource.h @@ -496,6 +496,9 @@ #define IDC_ASK 1516
#define IDC_HIDE 1534
#define IDC_TOPLINE 1535
+#define IDC_BOTH 1536
+#define IDC_DELSERVERCONTACT 1537
+#define IDC_DELSERVERHISTORY 1538
#define IDC_MYHANDLE 1540
#define IDC_GROUP 1541
#define IDC_AUTH 1543
@@ -687,7 +690,7 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 338
+#define _APS_NEXT_RESOURCE_VALUE 339
#define _APS_NEXT_COMMAND_VALUE 40018
#define _APS_NEXT_CONTROL_VALUE 1761
#define _APS_NEXT_SYMED_VALUE 101
|