summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Steam/src/main.cpp1
-rw-r--r--protocols/Steam/src/steam_messages.cpp19
-rw-r--r--protocols/Steam/src/steam_proto.cpp21
-rw-r--r--protocols/Steam/src/steam_proto.h5
4 files changed, 46 insertions, 0 deletions
diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp
index 828311e40f..29cb4017a9 100644
--- a/protocols/Steam/src/main.cpp
+++ b/protocols/Steam/src/main.cpp
@@ -170,6 +170,7 @@ void CMPlugin::InitSteamServices()
serviceHandlers[FriendGetActiveSessions] = ServiceResponseHandler(&CSteamProto::OnGotConversations);
serviceHandlers[FriendGetRecentMessages] = ServiceResponseHandler(&CSteamProto::OnGotRecentMessages);
serviceHandlers[FriendGetIncomingMessage] = ServiceResponseHandler(&CSteamProto::OnGotIncomingMessage);
+ serviceHandlers[FriendNotifyAckMessage] = ServiceResponseHandler(&CSteamProto::OnGotMarkRead);
serviceHandlers[GetMyChatRoomGroups] = ServiceResponseHandler(&CSteamProto::OnGetMyChats);
serviceHandlers[GetChatHistory] = ServiceResponseHandler(&CSteamProto::OnGetChatHistory);
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp
index 956b1a07db..28ea4c4b9f 100644
--- a/protocols/Steam/src/steam_messages.cpp
+++ b/protocols/Steam/src/steam_messages.cpp
@@ -60,6 +60,25 @@ void CSteamProto::OnGotIncomingMessage(const CFriendMessagesIncomingMessageNotif
}
}
+void CSteamProto::OnGotMarkRead(const CFriendMessagesAckMessageNotification &reply, const CMsgProtoBufHeader &)
+{
+ MCONTACT hContact = GetContact(reply.steamid_partner);
+ if (!hContact) {
+ debugLogA("notification from unknown account %lld ignored", reply.steamid_partner);
+ return;
+ }
+
+ DB::ECPTR pCursor(DB::Events(hContact, db_event_firstUnread(hContact)));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
+ DB::EventInfo dbei(hDbEvent, false);
+ if (reply.timestamp > dbei.iTimestamp)
+ break;
+
+ if (!dbei.markedRead())
+ db_event_markRead(hContact, hDbEvent, true);
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
int CSteamProto::UserIsTyping(MCONTACT hContact, int type)
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index dcea10e561..1946440bad 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -298,6 +298,27 @@ bool CSteamProto::OnContactDeleted(MCONTACT hContact, uint32_t)
return true;
}
+void CSteamProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
+{
+ if (IsOnline()) {
+ DB::EventInfo dbei(hDbEvent, false);
+
+ if (Contact::IsGroupChat(hContact)) {
+ CChatRoomAckChatMessageNotification 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.timestamp = dbei.iTimestamp; request.has_timestamp = true;
+ WSSendService(AckChatMessage, request);
+ }
+ else {
+ CFriendMessagesAckMessageNotification request;
+ request.steamid_partner = GetId(hContact, DBKEY_STEAM_ID); request.has_steamid_partner = true;
+ request.timestamp = dbei.iTimestamp; request.has_timestamp = true;
+ WSSendService(FriendAckMessage, request);
+ }
+ }
+}
+
int CSteamProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
{
MessageWindowEvent *evt = (MessageWindowEvent *)lParam;
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 924563dabb..9d4c822cd6 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -24,15 +24,18 @@
#define GetOwnAuthorizedDevices "DeviceAuth.GetOwnAuthorizedDevices#1"
+#define FriendAckMessage "FriendMessages.AckMessage#1"
#define FriendSendMessage "FriendMessages.SendMessage#1"
#define FriendGetActiveSessions "FriendMessages.GetActiveMessageSessions#1"
#define FriendGetRecentMessages "FriendMessages.GetRecentMessages#1"
#define FriendGetIncomingMessage "FriendMessagesClient.IncomingMessage#1"
+#define FriendNotifyAckMessage "FriendMessagesClient.NotifyAckMessageEcho#1"
#define GetMyChatRoomGroups "ChatRoom.GetMyChatRoomGroups#1"
#define GetChatHistory "ChatRoom.GetMessageHistory#1"
#define SendChatMessage "ChatRoom.SendChatMessage#1"
#define LeaveChatGroup "ChatRoom.LeaveChatRoomGroup#1"
+#define AckChatMessage "ChatRoom.AckChatMessage#1"
#define NotifyIncomingChatMessage "ChatRoomClient.NotifyIncomingChatMessage#1"
@@ -298,6 +301,7 @@ class CSteamProto : public PROTO<CSteamProto>
void SendFriendMessage(EChatEntryType, int64_t steamId, const char *pszMessage, void *pInfo = nullptr);
void OnGotIncomingMessage(const CFriendMessagesIncomingMessageNotification &reply, const CMsgProtoBufHeader &hdr);
+ void OnGotMarkRead(const CFriendMessagesAckMessageNotification &reply, const CMsgProtoBufHeader &hdr);
void OnMessageSent(const CFriendMessagesSendMessageResponse &reply, const CMsgProtoBufHeader &hdr);
int __cdecl OnPreCreateMessage(WPARAM, LPARAM lParam);
@@ -367,6 +371,7 @@ public:
bool OnContactDeleted(MCONTACT, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow) override;
+ void OnMarkRead(MCONTACT hContact, MEVENT hDbEvent) override;
void OnModulesLoaded() override;
// menus