summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_xstatus.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-12-09 17:08:19 +0000
committerRobert Pösel <robyer@seznam.cz>2014-12-09 17:08:19 +0000
commit061cf8a12c07aecc4526840a59ba0135f43b2fca (patch)
tree8b8ea9640e1aabb69ef3978b4c09f415e13cad36 /protocols/Steam/src/steam_xstatus.cpp
parent278ba931862278aa0b2ea9fae11fd4198cdb1442 (diff)
Steam: Use XStatus for info about playing game (part 1)
git-svn-id: http://svn.miranda-ng.org/main/trunk@11300 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_xstatus.cpp')
-rw-r--r--protocols/Steam/src/steam_xstatus.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/protocols/Steam/src/steam_xstatus.cpp b/protocols/Steam/src/steam_xstatus.cpp
new file mode 100644
index 0000000000..f7e5ac59a7
--- /dev/null
+++ b/protocols/Steam/src/steam_xstatus.cpp
@@ -0,0 +1,98 @@
+#include "common.h"
+
+#define STATUS_TITLE_MAX 64
+#define STATUS_DESC_MAX 255
+
+int CSteamProto::GetContactXStatus(MCONTACT hContact)
+{
+ return getDword(hContact, "XStatusId", 0) ? 1 : 0;
+}
+
+INT_PTR CSteamProto::GetXStatusEx(WPARAM wParam, LPARAM lParam)
+{
+ MCONTACT hContact = (MCONTACT)wParam;
+
+ CUSTOM_STATUS *pData = (CUSTOM_STATUS*)lParam;
+ if (pData->cbSize < sizeof(CUSTOM_STATUS))
+ return 1;
+
+ // fill status member
+ if (pData->flags & CSSF_MASK_STATUS)
+ *pData->status = GetContactXStatus(hContact);
+
+ // fill status name member
+ if (pData->flags & CSSF_MASK_NAME)
+ {
+ int status = (pData->wParam == NULL) ? GetContactXStatus(hContact) : *pData->wParam;
+ if (status < 1)
+ return 1;
+
+ ptrT title;
+ if (pData->flags & CSSF_DEFAULT_NAME)
+ title = mir_tstrdup(TranslateT("Playing"));
+ else
+ title = getTStringA(hContact, "XStatusName");
+
+ if (pData->flags & CSSF_UNICODE)
+ mir_tstrncpy(pData->ptszName, title, STATUS_TITLE_MAX);
+ else
+ mir_strncpy(pData->pszName, _T2A(title), STATUS_TITLE_MAX);
+ }
+
+ // fill status message member
+ if (pData->flags & CSSF_MASK_MESSAGE) {
+ ptrT message(getTStringA(hContact, "XStatusMsg"));
+
+ if (pData->flags & CSSF_UNICODE)
+ mir_tstrncpy(pData->ptszMessage, message, STATUS_DESC_MAX);
+ else
+ mir_strncpy(pData->pszMessage, _T2A(message), STATUS_DESC_MAX);
+ }
+
+ // disable menu
+ if (pData->flags & CSSF_DISABLE_MENU)
+ if (pData->wParam)
+ *pData->wParam = true;
+
+ // disable ui
+ if (pData->flags & CSSF_DISABLE_UI)
+ if (pData->wParam)
+ *pData->wParam = true;
+
+ // number of xstatuses
+ if (pData->flags & CSSF_STATUSES_COUNT)
+ if (pData->wParam)
+ *pData->wParam = 1; // TODO: how to solve unknown count of games?
+
+ // data sizes
+ if (pData->flags & CSSF_STR_SIZES) {
+ if (pData->wParam) *pData->wParam = STATUS_TITLE_MAX;
+ if (pData->lParam) *pData->lParam = STATUS_DESC_MAX;
+ }
+
+ return 0;
+}
+
+INT_PTR CSteamProto::GetXStatusIcon(WPARAM wParam, LPARAM lParam)
+{
+ if (!wParam)
+ wParam = GetContactXStatus(NULL);
+
+ if (wParam < 1)
+ return 0;
+
+ char iconName[100];
+ mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, "gaming");
+
+ HICON icon = Skin_GetIcon(iconName, (lParam & LR_BIGICON) ? 32 : 16);
+ return (lParam & LR_SHARED) ? (INT_PTR)icon : (INT_PTR)CopyIcon(icon);
+}
+
+INT_PTR CSteamProto::RequestAdvStatusIconIdx(WPARAM wParam, LPARAM lParam)
+{
+ int status = GetContactXStatus(wParam);
+ if (status < 1)
+ return -1;
+
+ return ((status & 0xFFFF) << 16);
+} \ No newline at end of file