summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-24 16:08:11 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-24 16:08:11 +0300
commitcf30319150edb0d5b49b05078817725c629320ba (patch)
tree8d3fe712d532a4f2b3513fc316fd25fe0ba74806
parent660b4e02d4bef4f7ac953689ce00d727bf9bacbd (diff)
PS_EMPTY_SRV_HISTORY implementation for Telegram
-rw-r--r--include/m_history.h8
-rw-r--r--protocols/Telegram/src/proto.cpp16
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/server.cpp9
-rw-r--r--src/mir_app/src/clui.cpp4
-rw-r--r--src/mir_app/src/netlib_websocket.cpp2
-rw-r--r--src/mir_app/src/srmm_main.cpp7
7 files changed, 18 insertions, 30 deletions
diff --git a/include/m_history.h b/include/m_history.h
index a64a975119..c63b63d621 100644
--- a/include/m_history.h
+++ b/include/m_history.h
@@ -41,12 +41,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_HISTORY_EMPTY "History/EmptyHistory"
-/////////////////////////////////////////////////////////////////////////////////////////
-// Event called when someone gonna wipe contact's history
-// wParam = (MCONTACT)hContact
-// hContact can be NULL to wipe system history
-// returns 0 if the core should wipe local history or any other value to cancel wiping
-
-#define ME_HISTORY_EMPTY "History/OnEmptyHistory"
-
#endif // M_HISTORY_H__
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 48bb212951..9b9b9bb4f5 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -64,9 +64,10 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
CreateProtoService(PS_GETAVATARINFO, &CTelegramProto::SvcGetAvatarInfo);
CreateProtoService(PS_GETMYAVATAR, &CTelegramProto::SvcGetMyAvatar);
CreateProtoService(PS_SETMYAVATAR, &CTelegramProto::SvcSetMyAvatar);
+
CreateProtoService(PS_MENU_LOADHISTORY, &CTelegramProto::SvcLoadServerHistory);
+ CreateProtoService(PS_EMPTY_SRV_HISTORY, &CTelegramProto::SvcEmptyServerHistory);
- HookProtoEvent(ME_HISTORY_EMPTY, &CTelegramProto::OnEmptyHistory);
HookProtoEvent(ME_OPT_INITIALISE, &CTelegramProto::OnOptionsInit);
HookProtoEvent(ME_MSG_WINDOWEVENT, &CTelegramProto::OnWindowEvent);
@@ -140,16 +141,6 @@ bool CTelegramProto::OnContactDeleted(MCONTACT hContact, uint32_t)
return true;
}
-int CTelegramProto::OnEmptyHistory(WPARAM hContact, LPARAM)
-{
- if (Proto_IsProtoOnContact(hContact, m_szModuleName)) {
- if (auto *pUser = FindUser(GetId(hContact)))
- SendQuery(new TD::deleteChatHistory(pUser->chatId, true, true));
- }
-
- return 0;
-}
-
void CTelegramProto::OnModulesLoaded()
{
int iCompatLevel = getByte(DBKEY_COMPAT);
@@ -340,7 +331,8 @@ INT_PTR CTelegramProto::GetCaps(int type, MCONTACT)
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY;
case PFLAGNUM_4:
- return PF4_NOCUSTOMAUTH | PF4_FORCEAUTH | PF4_OFFLINEFILES | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_SERVERMSGID | PF4_REPLY;
+ return PF4_NOCUSTOMAUTH | PF4_FORCEAUTH | PF4_OFFLINEFILES | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS
+ | PF4_SERVERMSGID | PF4_DELETEFORALL | PF4_REPLY;
case PFLAGNUM_5:
return PF2_SHORTAWAY | PF2_LONGAWAY;
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 62b23d2f8e..800a718740 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -380,7 +380,6 @@ public:
// Events ////////////////////////////////////////////////////////////////////////////
- int __cdecl OnEmptyHistory(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnWindowEvent(WPARAM, LPARAM);
@@ -393,6 +392,7 @@ public:
INT_PTR __cdecl SvcAddByPhone(WPARAM, LPARAM);
INT_PTR __cdecl SvcOfflineFile(WPARAM, LPARAM);
INT_PTR __cdecl SvcLoadServerHistory(WPARAM, LPARAM);
+ INT_PTR __cdecl SvcEmptyServerHistory(WPARAM, LPARAM);
// Options ///////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 7a59341212..8fd72e3e59 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -438,6 +438,15 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM)
///////////////////////////////////////////////////////////////////////////////
+INT_PTR CTelegramProto::SvcEmptyServerHistory(WPARAM hContact, LPARAM lParam)
+{
+ if (auto *pUser = FindUser(GetId(hContact)))
+ SendQuery(new TD::deleteChatHistory(pUser->chatId, false, (lParam & CDF_FOR_EVERYONE) != 0));
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
{
int64_t userId;
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index f01ed76b7c..7af3cbcdf3 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -218,7 +218,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM hContact, LPARAM lParam)
options |= CDF_FOR_EVERYONE;
if (dlg.bDelHistory)
- CallContactService(hContact, PS_EMPTY_SRV_HISTORY, CDF_DEL_HISTORY | (dlg.bForEveryone ? CDF_FOR_EVERYONE : 0));
+ CallContactService(hContact, PS_EMPTY_SRV_HISTORY, hContact, options);
int status = Proto_GetStatus(dlg.szProto);
if (status == ID_STATUS_OFFLINE || IsStatusConnecting(status)) {
@@ -228,7 +228,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM hContact, LPARAM lParam)
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);
+ else db_delete_contact(hContact);
return 0;
}
diff --git a/src/mir_app/src/netlib_websocket.cpp b/src/mir_app/src/netlib_websocket.cpp
index 9117980074..9ce6f72be9 100644
--- a/src/mir_app/src/netlib_websocket.cpp
+++ b/src/mir_app/src/netlib_websocket.cpp
@@ -150,7 +150,7 @@ static void WebSocket_Send(HNETLIBCONN nlc, const void *pData, int64_t dataLen,
memcpy(sendBuf, header, cbLen);
if (dataLen) {
memcpy(sendBuf.get() + cbLen, pData, dataLen);
- for (size_t i = 0; i < dataLen; i++)
+ for (int i = 0; i < dataLen; i++)
sendBuf[i + cbLen] ^= arMask[i & 3];
}
Netlib_Send(nlc, sendBuf, int(dataLen + cbLen), MSG_NODUMP);
diff --git a/src/mir_app/src/srmm_main.cpp b/src/mir_app/src/srmm_main.cpp
index 5050ebec5d..b2ebc81c7a 100644
--- a/src/mir_app/src/srmm_main.cpp
+++ b/src/mir_app/src/srmm_main.cpp
@@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
HCURSOR g_hCurHyperlinkHand;
HANDLE hHookIconsChanged, hHookIconPressedEvt, hHookSrmmEvent;
-static HANDLE hHookEmptyHistory;
static HGENMENU hmiEmpty;
void LoadSrmmToolbarModule();
@@ -89,9 +88,6 @@ public:
static INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM lParam)
{
- if (NotifyEventHooks(hHookEmptyHistory))
- return 2;
-
CEmptyHistoryDlg dlg(hContact);
if (lParam == 0)
if (dlg.DoModal() != IDOK)
@@ -106,7 +102,7 @@ static INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM lParam)
Chat_EmptyHistory(si);
if (dlg.bDelHistory)
- CallContactService(hContact, PS_EMPTY_SRV_HISTORY, CDF_DEL_HISTORY | (dlg.bForEveryone ? CDF_FOR_EVERYONE : 0));
+ CallContactService(hContact, PS_EMPTY_SRV_HISTORY, hContact, CDF_DEL_HISTORY | (dlg.bForEveryone ? CDF_FOR_EVERYONE : 0));
return 0;
}
@@ -149,7 +145,6 @@ int LoadSrmmModule()
LoadSrmmToolbarModule();
CreateServiceFunction(MS_HISTORY_EMPTY, svcEmptyHistory);
- hHookEmptyHistory = CreateHookableEvent(ME_HISTORY_EMPTY);
hHookSrmmEvent = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);