summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/common.h1
-rw-r--r--protocols/Steam/src/resource.h5
-rw-r--r--protocols/Steam/src/steam_contacts.cpp37
-rw-r--r--protocols/Steam/src/steam_proto.cpp19
-rw-r--r--protocols/Steam/src/steam_proto.h8
-rw-r--r--protocols/Steam/src/steam_xstatus.cpp98
6 files changed, 144 insertions, 24 deletions
diff --git a/protocols/Steam/src/common.h b/protocols/Steam/src/common.h
index 36427d7a1c..3e654c1d8a 100644
--- a/protocols/Steam/src/common.h
+++ b/protocols/Steam/src/common.h
@@ -26,6 +26,7 @@
#include <m_protosvc.h>
#include <m_protoint.h>
#include <m_idle.h>
+#include <m_xstatus.h>
#include <win2k.h>
#include <map>
diff --git a/protocols/Steam/src/resource.h b/protocols/Steam/src/resource.h
index eb70eecf40..ec80b9a7ce 100644
--- a/protocols/Steam/src/resource.h
+++ b/protocols/Steam/src/resource.h
@@ -7,10 +7,9 @@
#define IDD_OPT_BLOCKED 20
#define IDD_OPT_BLOCK_LIST 20
#define IDD_IGNORE_LIST 21
+#define IDI_STEAM 100
+#define IDI_GAMING 101
#define IDD_CAPTCHA 118
-#define IDI_ICON1 119
-#define IDI_STEAM 119
-#define IDD_STEAMGUARD 119
#define IDD_GUARD 119
#define IDC_SN 1001
#define IDC_PW 1002
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index 5724d2a411..25720b1d05 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -139,7 +139,7 @@ void CSteamProto::UpdateContact(MCONTACT hContact, JSONNODE *data)
WORD steamStatus = json_as_int(node);
WORD status = SteamToMirandaStatus(steamStatus);
if (hContact != NULL)
- setWord(hContact, "Status", status);
+ SetContactStatus(hContact, status);
// client
node = json_get(data, "personastateflags");
@@ -170,31 +170,36 @@ void CSteamProto::UpdateContact(MCONTACT hContact, JSONNODE *data)
DWORD gameId = node ? atol(_T2A(json_as_string(node))) : 0;
if (gameId > 0)
{
- setDword(hContact, "GameID", gameId);
-
node = json_get(data, "gameextrainfo");
const TCHAR *gameInfo = json_as_string(node);
- if (hContact != NULL)
- db_set_ts(hContact, "CList", "StatusMsg", gameInfo);
- setTString(hContact, "GameInfo", gameInfo);
-
node = json_get(data, "gameserverip");
- setString(hContact, "GameServerIP", _T2A(json_as_string(node)));
+ const TCHAR *serverIP = json_as_string(node);
node = json_get(data, "gameserversteamid");
- setString(hContact, "GameServerID", _T2A(json_as_string(node)));
+ const TCHAR *serverID = json_as_string(node);
+
+ setDword(hContact, "GameID", gameId);
+ setString(hContact, "ServerIP", _T2A(serverIP));
+ setString(hContact, "ServerID", _T2A(serverID));
+
+ CMString message(gameInfo);
+ if (serverIP[0] != '\0')
+ message.AppendFormat(TranslateT(" on server %s"), serverIP);
+
+ setDword(hContact, "XStatusId", gameId);
+ setTString(hContact, "XStatusName", TranslateT("Playing"));
+ setTString(hContact, "XStatusMsg", message);
}
else
{
- if (hContact != NULL)
- db_unset(hContact, "CList", "StatusMsg");
-
delSetting(hContact, "GameID");
- delSetting(hContact, "GameInfo");
- delSetting(hContact, "GameServerIP");
- delSetting(hContact, "GameServerID");
- delSetting(hContact, "GameInfo");
+ delSetting(hContact, "ServerIP");
+ delSetting(hContact, "ServerID");
+
+ delSetting(hContact, "XStatusId");
+ delSetting(hContact, "XStatusName");
+ delSetting(hContact, "XStatusMsg");
}
}
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index f9ef530e79..bd255c5e10 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -34,13 +34,20 @@ CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName) :
sid.iDefaultIndex = -IDI_STEAM;
Skin_AddIcon(&sid);
+ mir_snprintf(settingName, SIZEOF(settingName), "%s_%s", MODULE, "gaming");
+ sid.ptszDescription = LPGENT("Gaming icon");
+ sid.iDefaultIndex = -IDI_GAMING;
+ Skin_AddIcon(&sid);
+
// temporary DB settings
- db_set_resident(m_szModuleName, "Status"); // NOTE: XStatus cannot be temporary
+ db_set_resident(m_szModuleName, "Status");
+ db_set_resident(m_szModuleName, "XStatusId");
+ db_set_resident(m_szModuleName, "XStatusName");
+ db_set_resident(m_szModuleName, "XStatusMsg");
db_set_resident(m_szModuleName, "IdleTS");
db_set_resident(m_szModuleName, "GameID");
- db_set_resident(m_szModuleName, "GameInfo");
- db_set_resident(m_szModuleName, "GameServerIP");
- db_set_resident(m_szModuleName, "GameServerID");
+ db_set_resident(m_szModuleName, "ServerIP");
+ db_set_resident(m_szModuleName, "ServerID");
SetAllContactsStatus(ID_STATUS_OFFLINE);
@@ -50,6 +57,10 @@ CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName) :
CreateProtoService(PS_GETAVATARINFOT, &CSteamProto::GetAvatarInfo);
CreateProtoService(PS_GETAVATARCAPS, &CSteamProto::GetAvatarCaps);
CreateProtoService(PS_GETMYAVATART, &CSteamProto::GetMyAvatar);
+ // custom status API
+ CreateProtoService(PS_GETCUSTOMSTATUSEX, &CSteamProto::GetXStatusEx);
+ CreateProtoService(PS_GETCUSTOMSTATUSICON, &CSteamProto::GetXStatusIcon);
+ CreateProtoService(PS_GETADVANCEDSTATUSICON, &CSteamProto::RequestAdvStatusIconIdx);
}
CSteamProto::~CSteamProto()
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 82dd4f925b..850f97b581 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -254,7 +254,13 @@ protected:
INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM);
INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM);
- //events
+ // xstatuses
+ INT_PTR __cdecl GetXStatusEx(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl GetXStatusIcon(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl RequestAdvStatusIconIdx(WPARAM wParam, LPARAM lParam);
+ int GetContactXStatus(MCONTACT hContact);
+
+ // events
int OnModulesLoaded(WPARAM, LPARAM);
int OnPreShutdown(WPARAM, LPARAM);
int __cdecl OnIdleChanged(WPARAM, LPARAM);
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