summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_database.h2
-rw-r--r--include/m_protoint.h3
-rw-r--r--libs/win32/mir_app.libbin291208 -> 291214 bytes
-rw-r--r--libs/win64/mir_app.libbin290956 -> 290960 bytes
-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
-rw-r--r--protocols/Discord/src/dispatch.cpp2
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp5
-rw-r--r--protocols/ICQ-WIM/src/proto.h2
-rw-r--r--protocols/ICQ-WIM/src/server.cpp2
-rw-r--r--protocols/Telegram/src/proto.cpp26
-rw-r--r--protocols/Telegram/src/proto.h3
-rw-r--r--protocols/Telegram/src/server.cpp4
-rw-r--r--protocols/VKontakte/src/vk_history.cpp2
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/proto_interface.cpp2
-rw-r--r--src/mir_core/src/db.cpp6
20 files changed, 126 insertions, 31 deletions
diff --git a/include/m_database.h b/include/m_database.h
index 3533980641..7f9d1600b1 100644
--- a/include/m_database.h
+++ b/include/m_database.h
@@ -296,7 +296,7 @@ EXTERN_C MIR_CORE_DLL(int) db_event_count(MCONTACT hContact);
// Returns 0 on success, or nonzero if hDbEvent was invalid
// Triggers a db/event/deleted event just *before* the event is deleted
-EXTERN_C MIR_CORE_DLL(int) db_event_delete(MEVENT hDbEvent, bool bFromServer = false);
+EXTERN_C MIR_CORE_DLL(int) db_event_delete(MEVENT hDbEvent, int flags = 0);
// Edits an event in the database
// Returns 0 on success, or nonzero on error
diff --git a/include/m_protoint.h b/include/m_protoint.h
index 0bf9f73a62..4f34c94be8 100644
--- a/include/m_protoint.h
+++ b/include/m_protoint.h
@@ -267,7 +267,8 @@ public:
virtual MWindow OnCreateAccMgrUI(MWindow hwndParent);
// called when an event is removed from the database
- virtual void OnEventDeleted(MCONTACT, MEVENT);
+ // flags is a collection of CDF_* constants
+ virtual void OnEventDeleted(MCONTACT, MEVENT, int flags);
// called when an event is altered in database
virtual void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index eca65d4159..d1e8f8ec70 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index ce38cff252..80461ade47 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
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
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index 0c6062f1d5..642694e3cb 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -456,7 +456,7 @@ void CDiscordProto::OnCommandMessageDelete(const JSONNode &pRoot)
if (!msgid.IsEmpty()) {
MEVENT hEvent = db_event_getById(m_szModuleName, msgid);
if (hEvent)
- db_event_delete(hEvent, true);
+ db_event_delete(hEvent, CDF_FROM_SERVER);
}
}
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index 48f94f5714..ac144f2cdf 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -226,8 +226,11 @@ void CIcqProto::BatchDeleteMsg()
m_hDeleteContact = INVALID_CONTACT_ID;
}
-void CIcqProto::OnEventDeleted(MCONTACT hContact, MEVENT hEvent)
+void CIcqProto::OnEventDeleted(MCONTACT hContact, MEVENT hEvent, int flags)
{
+ if (!(flags & CDF_FROM_SERVER))
+ return;
+
if (m_hDeleteContact != INVALID_CONTACT_ID)
if (m_hDeleteContact != hContact)
BatchDeleteMsg();
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index 7fe31a13e0..b7f05974ae 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -444,7 +444,7 @@ class CIcqProto : public PROTO<CIcqProto>
void OnContactAdded(MCONTACT) override;
bool OnContactDeleted(MCONTACT, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow) override;
- void OnEventDeleted(MCONTACT, MEVENT) override;
+ void OnEventDeleted(MCONTACT, MEVENT, int) override;
void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index cd024c1a08..10a7905f27 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -824,7 +824,7 @@ void CIcqProto::OnGetPatches(MHttpResponse *pReply, AsyncHttpRequest *pReq)
char msgId[100];
_i64toa(it.first, msgId, 10);
if (MEVENT hEvent = db_event_getById(m_szModuleName, msgId))
- db_event_delete(hEvent, true);
+ db_event_delete(hEvent, CDF_FROM_SERVER);
}
}
}
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 3b79b01e66..f1315dc56d 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -214,9 +214,9 @@ void CTelegramProto::OnErase()
DeleteDirectoryTreeW(GetProtoFolder(), false);
}
-void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent)
+void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags)
{
- if (!hContact)
+ if (!hContact || !(flags & CDF_FROM_SERVER))
return;
auto *pUser = FindUser(GetId(hContact));
@@ -224,19 +224,21 @@ void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent)
return;
DB::EventInfo dbei(hDbEvent, false);
- if (dbei.szId) {
- mir_cslock lck(m_csDeleteMsg);
- if (m_deleteChatId) {
- if (m_deleteChatId != pUser->chatId)
- SendDeleteMsg();
+ if (!dbei.szId)
+ return;
- m_impl.m_deleteMsg.Stop();
- }
+ mir_cslock lck(m_csDeleteMsg);
+ if (m_deleteChatId) {
+ if (m_deleteChatId != pUser->chatId)
+ SendDeleteMsg();
- m_deleteChatId = pUser->chatId;
- m_deleteIds.push_back(dbei2id(dbei));
- m_impl.m_deleteMsg.Start(500);
+ m_impl.m_deleteMsg.Stop();
}
+
+ m_bDeleteForAll = (flags & CDF_FOR_EVERYONE) != 0;
+ m_deleteChatId = pUser->chatId;
+ m_deleteIds.push_back(dbei2id(dbei));
+ m_impl.m_deleteMsg.Start(500);
}
void CTelegramProto::OnEventEdited(MCONTACT hContact, MEVENT, const DBEVENTINFO &dbei)
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 800a718740..830b937e05 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -198,6 +198,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
TD::array<TD::int53> m_markIds;
mir_cs m_csDeleteMsg;
+ bool m_bDeleteForAll;
TD::int53 m_deleteChatId = 0;
TD::array<TD::int53> m_deleteIds;
@@ -370,7 +371,7 @@ public:
bool OnContactDeleted(MCONTACT hContact, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow hwndParent) override;
void OnErase() override;
- void OnEventDeleted(MCONTACT, MEVENT) override;
+ void OnEventDeleted(MCONTACT, MEVENT, int) override;
void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 78f4f43134..2082a73e13 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -152,7 +152,7 @@ void CTelegramProto::SendDeleteMsg()
m_impl.m_deleteMsg.Stop();
mir_cslock lck(m_csDeleteMsg);
- SendQuery(new TD::deleteMessages(m_deleteChatId, std::move(m_deleteIds), true));
+ SendQuery(new TD::deleteMessages(m_deleteChatId, std::move(m_deleteIds), m_bDeleteForAll));
m_deleteChatId = 0;
}
@@ -694,7 +694,7 @@ void CTelegramProto::ProcessDeleteMessage(TD::updateDeleteMessages *pObj)
for (auto &it : pObj->message_ids_)
if (MEVENT hEvent = db_event_getById(m_szModuleName, msg2id(pObj->chat_id_, it)))
- db_event_delete(hEvent, true);
+ db_event_delete(hEvent, CDF_FROM_SERVER);
}
void CTelegramProto::ProcessGroups(TD::updateChatFolders *pObj)
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index bb386c812d..2c228a27e0 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -309,7 +309,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest *
MEVENT hDbEvent = db_event_getById(m_szModuleName, strcat(szMid, "_"));
if (hDbEvent)
- db_event_delete(hDbEvent, true);
+ db_event_delete(hDbEvent, CDF_FROM_SERVER);
if (bIsRead && bIsOut && tDateTime > tLastReadMessageTime)
tLastReadMessageTime = tDateTime;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 42d8f60e6c..db4932e80a 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -806,7 +806,7 @@ Srmm_CreateHotkey @886 NONAME
?OnCreateAccMgrUI@PROTO_INTERFACE@@UAEPAUHWND__@@PAU2@@Z @937 NONAME
?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD0@Z @938 NONAME
?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PBD0@Z @939 NONAME
-?OnEventDeleted@PROTO_INTERFACE@@UAEXII@Z @940 NONAME
+?OnEventDeleted@PROTO_INTERFACE@@UAEXIIH@Z @940 NONAME
Chat_IsMuted @941 NONAME
?Srmm_AddEvent@@YGXII@Z @942 NONAME
?iDiskLogFlags@Chat@@3V?$CMOption@I@@A @943 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 7274527130..e3de66bb95 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -806,7 +806,7 @@ Srmm_CreateHotkey @886 NONAME
?OnCreateAccMgrUI@PROTO_INTERFACE@@UEAAPEAUHWND__@@PEAU2@@Z @937 NONAME
?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD0@Z @938 NONAME
?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PEBD0@Z @939 NONAME
-?OnEventDeleted@PROTO_INTERFACE@@UEAAXII@Z @940 NONAME
+?OnEventDeleted@PROTO_INTERFACE@@UEAAXIIH@Z @940 NONAME
Chat_IsMuted @941 NONAME
?Srmm_AddEvent@@YAXII@Z @942 NONAME
?iDiskLogFlags@Chat@@3V?$CMOption@I@@A @943 NONAME
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp
index 83c4f994f1..edb4c85e76 100644
--- a/src/mir_app/src/proto_interface.cpp
+++ b/src/mir_app/src/proto_interface.cpp
@@ -82,7 +82,7 @@ MWindow PROTO_INTERFACE::OnCreateAccMgrUI(MWindow)
return nullptr; // error
}
-void PROTO_INTERFACE::OnEventDeleted(MCONTACT, MEVENT)
+void PROTO_INTERFACE::OnEventDeleted(MCONTACT, MEVENT, int)
{}
void PROTO_INTERFACE::OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &)
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index 57b22754c3..8fd08f873d 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -413,15 +413,15 @@ MIR_CORE_DLL(int) db_event_count(MCONTACT hContact)
return (g_pCurrDb == nullptr) ? 0 : g_pCurrDb->GetEventCount(hContact);
}
-MIR_CORE_DLL(int) db_event_delete(MEVENT hDbEvent, bool bFromServer)
+MIR_CORE_DLL(int) db_event_delete(MEVENT hDbEvent, int flags)
{
if (g_pCurrDb == nullptr)
return 0;
- if (!bFromServer) {
+ if (!(flags & CDF_FROM_SERVER)) {
MCONTACT hContact = g_pCurrDb->GetEventContact(hDbEvent);
if (auto *ppro = Proto_GetInstance(hContact))
- ppro->OnEventDeleted(hContact, hDbEvent);
+ ppro->OnEventDeleted(hContact, hDbEvent, flags);
}
return g_pCurrDb->DeleteEvent(hDbEvent);