summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Steam/src/main.cpp4
-rw-r--r--protocols/Steam/src/steam_history.cpp12
-rw-r--r--protocols/Steam/src/steam_proto.cpp24
-rw-r--r--protocols/Steam/src/steam_proto.h25
-rw-r--r--protocols/Steam/src/steam_server.cpp30
5 files changed, 90 insertions, 5 deletions
diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp
index 29cb4017a9..13a688ac4e 100644
--- a/protocols/Steam/src/main.cpp
+++ b/protocols/Steam/src/main.cpp
@@ -174,8 +174,10 @@ void CMPlugin::InitSteamServices()
serviceHandlers[GetMyChatRoomGroups] = ServiceResponseHandler(&CSteamProto::OnGetMyChats);
serviceHandlers[GetChatHistory] = ServiceResponseHandler(&CSteamProto::OnGetChatHistory);
- serviceHandlers[NotifyIncomingChatMessage] = ServiceResponseHandler(&CSteamProto::OnGetChatMessage);
serviceHandlers[LeaveChatGroup] = ServiceResponseHandler(&CSteamProto::OnLeftChat);
+ serviceHandlers[DeleteChatMessage] = ServiceResponseHandler(&CSteamProto::OnDoNothing);
+ serviceHandlers[NotifyIncomingChatMessage] = ServiceResponseHandler(&CSteamProto::OnGetChatMessage);
+ serviceHandlers[NotifyModifiedChatMessage] = ServiceResponseHandler(&CSteamProto::OnDoNothing);
serviceHandlers[GetOwnAuthorizedDevices] = ServiceResponseHandler(&CSteamProto::OnGotDeviceList);
diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp
index c94a0d6b0f..839bd66ed0 100644
--- a/protocols/Steam/src/steam_history.cpp
+++ b/protocols/Steam/src/steam_history.cpp
@@ -1,5 +1,17 @@
#include "stdafx.h"
+INT_PTR CSteamProto::SvcCanEmptyHistory(WPARAM hContact, LPARAM)
+{
+ return (hContact && Contact::IsGroupChat(hContact));
+}
+
+INT_PTR CSteamProto::SvcEmptyHistory(WPARAM, LPARAM)
+{
+ return 1;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CSteamProto::SendHistoryRequest(uint64_t accountId, uint32_t startTime)
{
CFriendMessagesGetRecentMessagesRequest request;
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 1946440bad..172da982e4 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -24,6 +24,10 @@ CSteamProto::CSteamProto(const char *protoName, const wchar_t *userName) :
CreateProtoService(PS_GETAVATARCAPS, &CSteamProto::GetAvatarCaps);
CreateProtoService(PS_GETMYAVATAR, &CSteamProto::GetMyAvatar);
+ // history
+ CreateProtoService(PS_CAN_EMPTY_HISTORY, &CSteamProto::SvcCanEmptyHistory);
+ CreateProtoService(PS_EMPTY_SRV_HISTORY, &CSteamProto::SvcEmptyHistory);
+
// custom status API
CreateProtoService(PS_GETCUSTOMSTATUSEX, &CSteamProto::OnGetXStatusEx);
CreateProtoService(PS_GETCUSTOMSTATUSICON, &CSteamProto::OnGetXStatusIcon);
@@ -138,7 +142,7 @@ int CSteamProto::AuthRequest(MCONTACT hContact, const wchar_t*)
return 1;
}
-INT_PTR CSteamProto::GetCaps(int type, MCONTACT)
+INT_PTR CSteamProto::GetCaps(int type, MCONTACT hContact)
{
switch (type) {
case PFLAGNUM_1:
@@ -146,7 +150,7 @@ INT_PTR CSteamProto::GetCaps(int type, MCONTACT)
case PFLAGNUM_2:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_FREECHAT | PF2_INVISIBLE;
case PFLAGNUM_4:
- return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_SUPPORTIDLE | PF4_SUPPORTTYPING;// | PF4_IMSENDOFFLINE;
+ return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_SUPPORTIDLE | PF4_SUPPORTTYPING | PF4_SERVERMSGID;
case PFLAGNUM_5:
return PF2_HEAVYDND | PF2_FREECHAT;
case PFLAG_UNIQUEIDTEXT:
@@ -298,6 +302,22 @@ bool CSteamProto::OnContactDeleted(MCONTACT hContact, uint32_t)
return true;
}
+void CSteamProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags)
+{
+ if (!hContact || !Contact::IsGroupChat(hContact) || !(flags & CDF_DEL_HISTORY))
+ return;
+
+ DB::EventInfo dbei(hDbEvent, false);
+
+ mir_cslock lck(m_csChats);
+ if (hContact != m_deletedContact && m_deletedContact != INVALID_CONTACT_ID)
+ SendDeleteMessageRequest();
+
+ m_deletedContact = hContact;
+ m_deletedMessages.push_back(dbei.iTimestamp);
+ m_impl.m_deleteMsg.Start(500);
+}
+
void CSteamProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
{
if (IsOnline()) {
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 9d4c822cd6..d416e76650 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -36,8 +36,11 @@
#define SendChatMessage "ChatRoom.SendChatMessage#1"
#define LeaveChatGroup "ChatRoom.LeaveChatRoomGroup#1"
#define AckChatMessage "ChatRoom.AckChatMessage#1"
+#define DeleteChatMessage "ChatRoom.DeleteChatMessages#1"
+
#define NotifyIncomingChatMessage "ChatRoomClient.NotifyIncomingChatMessage#1"
+#define NotifyModifiedChatMessage "ChatRoomClient.NotifyChatMessageModified#1"
#define NotificationReceived "SteamNotificationClient.NotificationsReceived#1"
@@ -109,18 +112,25 @@ class CSteamProto : public PROTO<CSteamProto>
friend class CSteamProto;
CSteamProto &m_proto;
- CTimer m_heartBeat;
+ CTimer m_heartBeat, m_deleteMsg;
void OnHeartBeat(CTimer *)
{
m_proto.SendHeartBeat();
}
+ void OnDeleteMsg(CTimer *)
+ {
+ m_proto.SendDeleteMessageRequest();
+ }
+
CProtoImpl(CSteamProto &pro) :
m_proto(pro),
- m_heartBeat(Miranda_GetSystemWindow(), UINT_PTR(this)+1)
+ m_heartBeat(Miranda_GetSystemWindow(), UINT_PTR(this) + 1),
+ m_deleteMsg(Miranda_GetSystemWindow(), UINT_PTR(this) + 2)
{
m_heartBeat.OnEvent = Callback(this, &CProtoImpl::OnHeartBeat);
+ m_deleteMsg.OnEvent = Callback(this, &CProtoImpl::OnDeleteMsg);
}
}
m_impl;
@@ -213,6 +223,11 @@ class CSteamProto : public PROTO<CSteamProto>
// chats
mir_cs m_csChats;
std::map<uint64_t, SESSION_INFO*> m_chatContactInfo;
+
+ MCONTACT m_deletedContact = INVALID_CONTACT_ID;
+ std::vector<uint64_t> m_deletedMessages;
+
+ void SendDeleteMessageRequest();
void SendGetChatsRequest();
void OnGetMyChats(const CChatRoomGetMyChatRoomGroupsResponse &pResponse, const CMsgProtoBufHeader &hdr);
@@ -268,6 +283,9 @@ class CSteamProto : public PROTO<CSteamProto>
void OnSearchByNameStarted(const MHttpResponse &response, void *arg);
// history
+ INT_PTR __cdecl SvcCanEmptyHistory(WPARAM, LPARAM);
+ INT_PTR __cdecl SvcEmptyHistory(WPARAM, LPARAM);
+
void SendHistoryRequest(uint64_t accountId, uint32_t startTime);
void OnGotRecentMessages(const CFriendMessagesGetRecentMessagesResponse &reply, const CMsgProtoBufHeader &hdr);
@@ -323,6 +341,8 @@ class CSteamProto : public PROTO<CSteamProto>
INT_PTR __cdecl OnGetEventTextChatStates(WPARAM wParam, LPARAM lParam);
// helpers
+ void OnDoNothing(const CMsgProtoBufHeader &, const CMsgProtoBufHeader &) {}
+
inline int IdleSeconds()
{
// Based on idle time we report Steam server will mark us as online/away/snooze
@@ -371,6 +391,7 @@ public:
bool OnContactDeleted(MCONTACT, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow) override;
+ void OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags) override;
void OnMarkRead(MCONTACT hContact, MEVENT hDbEvent) override;
void OnModulesLoaded() override;
diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp
index 0714e10e78..1d2b397f47 100644
--- a/protocols/Steam/src/steam_server.cpp
+++ b/protocols/Steam/src/steam_server.cpp
@@ -64,6 +64,36 @@ void CSteamProto::OnGotAppInfo(const CMsgClientPICSProductInfoResponse &reply, c
setUString(cc, "XStatusMsg", szName.c_str());
} } } } } }
+void CSteamProto::SendDeleteMessageRequest()
+{
+ if (m_deletedContact == INVALID_CONTACT_ID)
+ return;
+
+ m_impl.m_deleteMsg.Stop();
+
+ MCONTACT hContact;
+ OBJLIST<CChatRoomDeleteChatMessagesRequest__Message> msgs((int)m_deletedMessages.size());
+ {
+ mir_cslock lck(m_csChats);
+ for (auto &it : m_deletedMessages) {
+ CChatRoomDeleteChatMessagesRequest__Message msg;
+ msg.has_server_timestamp = true; msg.server_timestamp = it;
+ msgs.insert(new CChatRoomDeleteChatMessagesRequest__Message(msg));
+ }
+
+ hContact = m_deletedContact;
+ m_deletedContact = INVALID_CONTACT_ID;
+ m_deletedMessages.clear();
+ }
+
+ CChatRoomDeleteChatMessagesRequest request;
+ request.chat_group_id = GetId(hContact, DBKEY_STEAM_ID); request.has_chat_group_id = true;
+ request.chat_id = getDword(hContact, "ChatId"); request.has_chat_id = true;
+ request.messages = msgs.getArray();
+ request.n_messages = msgs.getCount();
+ WSSendService(DeleteChatMessage, request);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void CSteamProto::SendDeviceListRequest()