From efc8291dafe68435480bb5dd378cf26ee62d042f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 14 Nov 2024 17:24:43 +0300 Subject: =?UTF-8?q?fixes=20#4641=20(Telegram:=20=D1=83=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=20=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=20=D1=87=D1=83=D0=B6=D0=B8=D1=85=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B3=D1=80?= =?UTF-8?q?=D1=83=D0=BF=D1=87=D0=B0=D1=82=D0=B0,=20=D0=B5=D1=81=D0=BB?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=20=D0=9C=D0=B8=D1=80=D0=B0=D0=BD=D0=B4=D1=8B?= =?UTF-8?q?=20=D0=BD=D0=B5=20=D0=BC=D0=BE=D0=B4=D0=B5=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80/=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB=D0=B5=D1=86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/m_core.h | 2 +- libs/win32/mir_app.lib | Bin 301544 -> 301554 bytes libs/win64/mir_app.lib | Bin 301602 -> 301602 bytes plugins/NewStory/src/history_control.cpp | 17 ++++++++++++----- protocols/Telegram/src/proto.cpp | 21 ++++++++++----------- protocols/Telegram/src/proto.h | 2 +- protocols/Telegram/src/server.cpp | 10 ++++++++-- src/mir_app/src/menu_clist.cpp | 4 ++-- src/mir_app/src/mir_app.def | 2 +- src/mir_app/src/proto_utils.cpp | 4 ++-- 10 files changed, 37 insertions(+), 25 deletions(-) diff --git a/include/m_core.h b/include/m_core.h index 71fad47b41..3d78994229 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -319,7 +319,7 @@ MIR_CORE_DLL(int) mir_vsnwprintf(_Pre_notnull_ _Always_(_Post_z_) wchar_t *bu struct PROTO_INTERFACE; -MIR_APP_DLL(bool) Proto_CanDeleteHistory(const char *szModule, MCONTACT hContact); +MIR_APP_DLL(bool) Proto_CanDeleteHistory(const char *szModule, MCONTACT hContact, bool bIncoming = false); MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam = 0); MIR_APP_DLL(void) ProtoBroadcastAsync(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam = 0); diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 0004dc6cf7..65c5a6875f 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 873568ded1..859fd2a292 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index b10e7a98a3..d3ee3d07b1 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -347,7 +347,7 @@ class CDeleteEventsDlg : public CDlgBase public: bool bDelHistory = false, bForEveryone = false; - CDeleteEventsDlg(MCONTACT hContact, int nEvents) : + CDeleteEventsDlg(MCONTACT hContact, int nEvents, bool bIncoming) : CDlgBase(g_plugin, IDD_EMPTYHISTORY), m_hContact(hContact), m_iNumEvents(nEvents), @@ -355,7 +355,7 @@ public: chkForEveryone(this, IDC_BOTH) { if (char *szProto = Proto_GetBaseAccountName(hContact)) { - bDelHistory = Proto_CanDeleteHistory(szProto, hContact); + bDelHistory = Proto_CanDeleteHistory(szProto, hContact, bIncoming); bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, hContact) & PF4_DELETEFORALL) != 0; } } @@ -406,11 +406,18 @@ public: void NewstoryListData::DeleteItems(void) { int nSelected = 0; - for (int i = totalCount - 1; i >= 0; i--) - if (GetItem(i)->m_bSelected) + bool bIncoming = false; + + for (int i = totalCount - 1; i >= 0; i--) { + auto *pItem = GetItem(i); + if (pItem->m_bSelected) { + if ((pItem->dbe.flags & DBEF_SENT) == 0) + bIncoming = true; nSelected++; + } + } - CDeleteEventsDlg dlg(m_hContact, nSelected); + CDeleteEventsDlg dlg(m_hContact, nSelected, bIncoming); if (IDOK == dlg.DoModal()) { g_plugin.bDisableDelete = true; diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 73834415b8..a61d72b6ba 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -349,21 +349,12 @@ int CTelegramProto::AuthRequest(MCONTACT hContact, const wchar_t *) INT_PTR CTelegramProto::GetCaps(int type, MCONTACT hContact) { - uint32_t ret; - switch (type) { case PFLAGNUM_1: return PF1_IM | PF1_FILE | PF1_CHAT | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES | PF1_MODEMSGRECV | PF1_SERVERCLIST; case PFLAGNUM_2: return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY; - - case PFLAGNUM_4: - ret = PF4_NOCUSTOMAUTH | PF4_FORCEAUTH | PF4_OFFLINEFILES | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS - | PF4_SERVERMSGID | PF4_REPLY | PF4_GROUPCHATFILES | PF4_IMSENDOFFLINE | PF4_SERVERFORMATTING; - if (GetId(hContact) != m_iOwnId) - ret |= PF4_DELETEFORALL; - return ret; case PFLAGNUM_5: return PF2_SHORTAWAY | PF2_LONGAWAY; @@ -371,9 +362,17 @@ INT_PTR CTelegramProto::GetCaps(int type, MCONTACT hContact) case PFLAG_UNIQUEIDTEXT: return (INT_PTR)L"ID"; - default: - return 0; + case PFLAGNUM_4: + uint32_t ret = PF4_NOCUSTOMAUTH | PF4_FORCEAUTH | PF4_OFFLINEFILES | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS + | PF4_SERVERMSGID | PF4_REPLY | PF4_GROUPCHATFILES | PF4_IMSENDOFFLINE | PF4_SERVERFORMATTING; + + if (GetId(hContact) != m_iOwnId) + ret |= PF4_DELETEFORALL; + + return ret; } + + return 0; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index dec95199dc..69737ba35c 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -102,7 +102,7 @@ struct TG_USER : public MZeroedObject int64_t id, chatId = -1; MCONTACT hContact; int folderId = -1, nHistoryChunks; - bool isGroupChat, isChannel, isBot, isForum, bLoadMembers, bStartChat, bInited; + bool isGroupChat, isChannel, isBot, isForum, bLoadMembers, bStartChat, bInited, bDelOwn = true, bDelAll = true; CMStringA szAvatarHash; CMStringW wszNick, wszFirstName, wszLastName; time_t m_timer1 = 0, m_timer2 = 0; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 9303509442..0f97275314 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -520,12 +520,16 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM) /////////////////////////////////////////////////////////////////////////////// -INT_PTR CTelegramProto::SvcCanEmptyHistory(WPARAM hContact, LPARAM) +INT_PTR CTelegramProto::SvcCanEmptyHistory(WPARAM hContact, LPARAM bIncoming) { if (auto *pUser = FindUser(GetId(hContact))) { TG_SUPER_GROUP tmp(pUser->id, 0); if (auto *pGroup = m_arSuperGroups.find(&tmp)) - return !pGroup->group->is_channel_; + if (pGroup->group->is_channel_) + return 0; + + if (!pUser->bDelOwn || (bIncoming && !pUser->bDelAll)) + return 0; return 1; } @@ -586,6 +590,8 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj) pUser->chatId = pChat->id_; pUser->isChannel = isChannel; + pUser->bDelAll = pChat->can_be_deleted_for_all_users_; + pUser->bDelOwn = pChat->can_be_deleted_only_for_self_; MCONTACT hContact = (pUser->id == m_iOwnId) ? 0 : pUser->hContact; diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index edffe8e774..2bdcc8df49 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -699,7 +699,7 @@ void RebuildMenuOrder(void) if (!pa->IsVisible()) continue; - uint32_t flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0); + uint32_t flags = pa->ppro->GetCaps(PFLAGNUM_2) & ~pa->ppro->GetCaps(PFLAGNUM_5); HICON ic; wchar_t tbuf[256]; int pos = 0; @@ -797,7 +797,7 @@ void RebuildMenuOrder(void) if (!pa->IsVisible()) continue; - uint32_t flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0); + uint32_t flags = pa->ppro->GetCaps(PFLAGNUM_2) & ~pa->ppro->GetCaps(PFLAGNUM_5); if (!(flags & it.Pf2flag)) continue; diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index cb3f7515ec..2bf1f10949 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -984,7 +984,7 @@ g_hevEventSetJson @1103 NONAME ??1MJsonWebSocket@@QAE@XZ @1115 NONAME ??_7MJsonWebSocket@@6B@ @1116 NONAME ?process@MJsonWebSocket@@EAEXPBEI@Z @1117 NONAME -_Proto_CanDeleteHistory@8 @1118 NONAME +Proto_CanDeleteHistory @1118 NONAME ?OnCacheInit@PROTO_INTERFACE@@UAEXXZ @1119 NONAME ?DoRtfToTags@CSrmmBaseDialog@@IBE_NAAV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@@Z @1120 NONAME ?bUseGroup@Chat@@3V?$CMOption@_N@@A @1121 NONAME diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 10702e1473..903355a6c2 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -105,13 +105,13 @@ MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, ///////////////////////////////////////////////////////////////////////////////////////// -MIR_APP_DLL(bool) Proto_CanDeleteHistory(const char *szModule, MCONTACT hContact) +MIR_APP_DLL(bool) Proto_CanDeleteHistory(const char *szModule, MCONTACT hContact, bool bIncoming) { if (!ProtoServiceExists(szModule, PS_EMPTY_SRV_HISTORY)) return false; // CallProtoService can return CALLSERVICE_NOTFOUND, we don't care - return CallProtoService(szModule, PS_CAN_EMPTY_HISTORY, hContact) != 0; + return CallProtoService(szModule, PS_CAN_EMPTY_HISTORY, hContact, bIncoming) != 0; } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3