From 481af24ca7b41d80d7e3a76ec0fefa7b9ab339cf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 16 Dec 2024 18:48:19 +0300 Subject: added notification service --- protocols/Steam/src/main.cpp | 5 +++ .../steammessages_notifications.steamclient.pb-c.h | 8 ----- protocols/Steam/src/stdafx.h | 1 + protocols/Steam/src/steam_proto.h | 39 ++++++++++++---------- protocols/Steam/src/steam_server.cpp | 15 +++++++++ 5 files changed, 43 insertions(+), 25 deletions(-) (limited to 'protocols/Steam/src') diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp index 9181cc600d..9724c602be 100644 --- a/protocols/Steam/src/main.cpp +++ b/protocols/Steam/src/main.cpp @@ -152,6 +152,9 @@ void CMPlugin::InitSteamServices() services["FriendMessages"] = &friend_messages__descriptor; services["FriendMessagesClient"] = &friend_messages_client__descriptor; + // services from steammessages_notifications.steamclient.proto + services["SteamNotificationClient"] = &steam_notification_client__descriptor; + // static service handlers serviceHandlers[PollAuthSessionStatus] = ServiceResponseHandler(&CSteamProto::OnPollSession); serviceHandlers[GetPasswordRSAPublicKey] = ServiceResponseHandler(&CSteamProto::OnGotRsaKey); @@ -160,6 +163,8 @@ void CMPlugin::InitSteamServices() serviceHandlers[FriendSendMessage] = ServiceResponseHandler(&CSteamProto::OnMessageSent); serviceHandlers[FriendGetActiveSessions] = ServiceResponseHandler(&CSteamProto::OnGotConversations); + + serviceHandlers[NotificationReceived] = ServiceResponseHandler(&CSteamProto::OnGotNotification); } int CMPlugin::Load() diff --git a/protocols/Steam/src/protobuf-c/steammessages_notifications.steamclient.pb-c.h b/protocols/Steam/src/protobuf-c/steammessages_notifications.steamclient.pb-c.h index e6838858ec..583e617686 100644 --- a/protocols/Steam/src/protobuf-c/steammessages_notifications.steamclient.pb-c.h +++ b/protocols/Steam/src/protobuf-c/steammessages_notifications.steamclient.pb-c.h @@ -70,14 +70,6 @@ extern const ProtobufCServiceDescriptor steam_notification_client__descriptor; extern "C" void message_init_generic(const ProtobufCMessageDescriptor * desc, ProtobufCMessage * message); -struct ProtobufCppMessage : public ProtobufCMessage -{ - ProtobufCppMessage(const ProtobufCMessageDescriptor &descr) - { - message_init_generic(&descr, this); - } -}; - struct SteamNotificationData : public ProtobufCppMessage { SteamNotificationData() : diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index 5cd6bd1fcf..87d0bbeace 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -44,6 +44,7 @@ #include "protobuf-c/steammessages_clientserver.pb-c.h" #include "protobuf-c/steammessages_clientserver_login.pb-c.h" #include "protobuf-c/steammessages_friendmessages.steamclient.pb-c.h" +#include "protobuf-c/steammessages_notifications.steamclient.pb-c.h" #include "proto.h" #define MODULE "Steam" diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 9bf4a573b8..2d7f1c4b5b 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -25,6 +25,8 @@ #define FriendSendMessage "FriendMessages.SendMessage#1" #define FriendGetActiveSessions "FriendMessages.GetActiveMessageSessions#1" +#define NotificationReceived "SteamNotificationClient.NotificationsReceived#1" + struct SendAuthParam { MCONTACT hContact; @@ -175,6 +177,15 @@ class CSteamProto : public PROTO void DeleteAuthSettings(); void SendConfirmationCode(bool, const char *pszCode); + // avatars + wchar_t *GetAvatarFilePath(MCONTACT hContact); + bool GetDbAvatarInfo(PROTO_AVATAR_INFORMATION &pai); + void CheckAvatarChange(MCONTACT hContact, std::string avatarUrl); + + INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); + INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); + INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM); + // contacts void SetAllContactStatuses(int status); void SetContactStatus(MCONTACT hContact, uint16_t status); @@ -216,16 +227,6 @@ class CSteamProto : public PROTO void OnSearchResults(const MHttpResponse &response, void *arg); void OnSearchByNameStarted(const MHttpResponse &response, void *arg); - // messages - mir_cs m_csOwnMessages; - OBJLIST m_arOwnMessages; - - void SendFriendMessage(uint32_t msgId, int64_t steamId, const char *pszMessage); - void OnMessageSent(const CFriendMessagesSendMessageResponse &reply, const CMsgProtoBufHeader &hdr); - int __cdecl OnPreCreateMessage(WPARAM, LPARAM lParam); - - void SendFriendActiveSessions(); - // history void OnGotConversations(const CFriendsMessagesGetActiveMessageSessionsResponse &reply, const CMsgProtoBufHeader &hdr); void OnGotHistoryMessages(const JSONNode &root, void *); @@ -248,14 +249,18 @@ class CSteamProto : public PROTO void OnInitStatusMenu(); - // avatars - wchar_t *GetAvatarFilePath(MCONTACT hContact); - bool GetDbAvatarInfo(PROTO_AVATAR_INFORMATION &pai); - void CheckAvatarChange(MCONTACT hContact, std::string avatarUrl); + // notifications + void OnGotNotification(const CSteamNotificationNotificationsReceivedNotification &reply, const CMsgProtoBufHeader &hdr); - INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); - INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); - INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM); + // messages + mir_cs m_csOwnMessages; + OBJLIST m_arOwnMessages; + + void SendFriendMessage(uint32_t msgId, int64_t steamId, const char *pszMessage); + void OnMessageSent(const CFriendMessagesSendMessageResponse &reply, const CMsgProtoBufHeader &hdr); + int __cdecl OnPreCreateMessage(WPARAM, LPARAM lParam); + + void SendFriendActiveSessions(); // xstatuses INT_PTR __cdecl OnGetXStatusEx(WPARAM wParam, LPARAM lParam); diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp index 4528ccecfe..f7330dbc49 100644 --- a/protocols/Steam/src/steam_server.cpp +++ b/protocols/Steam/src/steam_server.cpp @@ -66,6 +66,21 @@ void CSteamProto::OnMessageSent(const CFriendMessagesSendMessageResponse &reply, ///////////////////////////////////////////////////////////////////////////////////////// +void CSteamProto::OnGotNotification(const CSteamNotificationNotificationsReceivedNotification &reply, const CMsgProtoBufHeader &hdr) +{ + if (hdr.eresult != 1) + return; + + debugLogA("got %d notifications", reply.n_notifications); + + for (int i = 0; i < reply.n_notifications; i++) { + auto *N = reply.notifications[i]; + debugLogA("notification type %d: %s", N->notification_type, N->body_data); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + void CSteamProto::SendFriendActiveSessions() { CFriendsMessagesGetActiveMessageSessionsRequest request; -- cgit v1.2.3