diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-12-19 21:24:11 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-12-19 21:24:11 +0000 |
commit | 925c04de5ee370511fe1c09d42ba8c4589c7d2ee (patch) | |
tree | b48de2c2498b01f5195d5016f6e47f91141d71ab | |
parent | a313a57561b0a4ab336f031f4ccd433d659bb7fb (diff) |
Steam: Support for receiving "user left conversation" events (like jabber has)
Miranda is NOT sending this event, maybe in future if there is exists such request from mobile/web steam.
git-svn-id: http://svn.miranda-ng.org/main/trunk@15903 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Steam/src/stdafx.h | 5 | ||||
-rw-r--r-- | protocols/Steam/src/steam_events.cpp | 8 | ||||
-rw-r--r-- | protocols/Steam/src/steam_polling.cpp | 18 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_utils.cpp | 19 |
6 files changed, 52 insertions, 3 deletions
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index 71db9d6561..992b168ccb 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -53,6 +53,11 @@ extern HANDLE hExtraXStatus; #define STEAM_API_URL "https://api.steampowered.com"
#define STEAM_WEB_URL "https://steamcommunity.com"
+// registered db event types
+#define EVENTTYPE_STEAM_CHATSTATES 2000
+#define STEAM_DB_GETEVENTTEXT_CHATSTATES "/GetEventText2000"
+#define STEAM_DB_EVENT_CHATSTATES_GONE 1
+
#include "steam_dialogs.h"
#include "steam_options.h"
#include "http_request.h"
diff --git a/protocols/Steam/src/steam_events.cpp b/protocols/Steam/src/steam_events.cpp index 69dc630b86..1a7bdbc9a4 100644 --- a/protocols/Steam/src/steam_events.cpp +++ b/protocols/Steam/src/steam_events.cpp @@ -6,6 +6,14 @@ int CSteamProto::OnModulesLoaded(WPARAM, LPARAM) HookProtoEvent(ME_IDLE_CHANGED, &CSteamProto::OnIdleChanged); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSteamProto::PrebuildContactMenu); + + // Register custom db event + DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) }; + dbEventType.module = m_szModuleName; + dbEventType.eventType = EVENTTYPE_STEAM_CHATSTATES; + dbEventType.descr = "Chat state notifications"; + CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + return 0; } diff --git a/protocols/Steam/src/steam_polling.cpp b/protocols/Steam/src/steam_polling.cpp index 43ceece247..8086db033e 100644 --- a/protocols/Steam/src/steam_polling.cpp +++ b/protocols/Steam/src/steam_polling.cpp @@ -143,9 +143,23 @@ void CSteamProto::ParsePollData(JSONNode *data) default: continue; } } - /*else if (!lstrcmpi(type, _T("leftconversation"))) + else if (!lstrcmpi(type, _T("leftconversation"))) { - }*/ + // chatstates gone event + MCONTACT hContact = FindContact(steamId); + if (hContact) + { + BYTE bEventType = STEAM_DB_EVENT_CHATSTATES_GONE; + DBEVENTINFO dbei = { sizeof(dbei) }; + dbei.pBlob = &bEventType; + dbei.cbBlob = 1; + dbei.eventType = EVENTTYPE_STEAM_CHATSTATES; + dbei.flags = DBEF_READ; + dbei.timestamp = time(NULL); + dbei.szModule = m_szModuleName; + db_event_add(hContact, &dbei); + } + } else { continue; diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index c8cdb86ed3..0fdbd61995 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -60,6 +60,9 @@ CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName) CreateProtoService(PS_GETCUSTOMSTATUSICON, &CSteamProto::OnGetXStatusIcon); CreateProtoService(PS_GETADVANCEDSTATUSICON, &CSteamProto::OnRequestAdvStatusIconIdx); + // custom db events API + CreateProtoService(STEAM_DB_GETEVENTTEXT_CHATSTATES, &CSteamProto::OnGetEventTextChatStates); + // netlib support TCHAR name[128]; mir_sntprintf(name, TranslateT("%s connection"), m_tszUserName); diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 613a50c6b4..89805d86af 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -211,6 +211,8 @@ protected: static void CSteamProto::ShowNotification(const TCHAR *message, int flags = 0, MCONTACT hContact = NULL);
static void CSteamProto::ShowNotification(const TCHAR *caption, const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
+ INT_PTR __cdecl OnGetEventTextChatStates(WPARAM wParam, LPARAM lParam);
+
// helpers
inline int IdleSeconds() {
// Based on idle time we report Steam server will mark us as online/away/snooze
diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp index 33ac3f8bde..c45440cb10 100644 --- a/protocols/Steam/src/steam_utils.cpp +++ b/protocols/Steam/src/steam_utils.cpp @@ -182,4 +182,21 @@ void CSteamProto::ShowNotification(const TCHAR *caption, const wchar_t *message, void CSteamProto::ShowNotification(const TCHAR *message, int flags, MCONTACT hContact)
{
ShowNotification(TranslateT(MODULE), message, flags, hContact);
-}
\ No newline at end of file +}
+
+INT_PTR __cdecl CSteamProto::OnGetEventTextChatStates(WPARAM, LPARAM lParam)
+{
+ // Retrieves a chat state description from an event
+
+ DBEVENTGETTEXT *pdbEvent = (DBEVENTGETTEXT *)lParam;
+ if (pdbEvent->dbei->cbBlob > 0) {
+ if (pdbEvent->dbei->pBlob[0] == STEAM_DB_EVENT_CHATSTATES_GONE) {
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ return (INT_PTR)mir_tstrdup(TranslateT("closed chat session"));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ return (INT_PTR)mir_strdup(Translate("closed chat session"));
+ }
+ }
+
+ return NULL;
+}
|