summaryrefslogtreecommitdiff
path: root/protocols
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
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')
-rw-r--r--protocols/Steam/Steam_10.vcxproj2
-rw-r--r--protocols/Steam/Steam_10.vcxproj.filters6
-rw-r--r--protocols/Steam/Steam_12.vcxproj2
-rw-r--r--protocols/Steam/Steam_12.vcxproj.filters6
-rw-r--r--protocols/Steam/res/Resource.rc1
-rw-r--r--protocols/Steam/res/gaming.icobin0 -> 5430 bytes
-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
12 files changed, 161 insertions, 24 deletions
diff --git a/protocols/Steam/Steam_10.vcxproj b/protocols/Steam/Steam_10.vcxproj
index 7adb920113..f52cbf1189 100644
--- a/protocols/Steam/Steam_10.vcxproj
+++ b/protocols/Steam/Steam_10.vcxproj
@@ -222,6 +222,7 @@
</ClCompile>
<ClCompile Include="src\steam_queue.cpp" />
<ClCompile Include="src\steam_utils.cpp" />
+ <ClCompile Include="src\steam_xstatus.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\Version.rc" />
@@ -238,6 +239,7 @@
<Image Include="res\skype.ico" />
</ItemGroup>
<ItemGroup>
+ <None Include="res\gaming.ico" />
<None Include="res\steam.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/protocols/Steam/Steam_10.vcxproj.filters b/protocols/Steam/Steam_10.vcxproj.filters
index f652465c1e..4b9cbf0d34 100644
--- a/protocols/Steam/Steam_10.vcxproj.filters
+++ b/protocols/Steam/Steam_10.vcxproj.filters
@@ -57,6 +57,9 @@
<ClCompile Include="src\steam_queue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\steam_xstatus.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
@@ -123,5 +126,8 @@
<None Include="res\steam.ico">
<Filter>Resource Files\Icon</Filter>
</None>
+ <None Include="res\gaming.ico">
+ <Filter>Resource Files\Icon</Filter>
+ </None>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/Steam/Steam_12.vcxproj b/protocols/Steam/Steam_12.vcxproj
index 192936124f..325b031a0f 100644
--- a/protocols/Steam/Steam_12.vcxproj
+++ b/protocols/Steam/Steam_12.vcxproj
@@ -225,6 +225,7 @@
<ClCompile Include="src\steam_queue.cpp" />
<ClCompile Include="src\steam_pooling.cpp" />
<ClCompile Include="src\steam_utils.cpp" />
+ <ClCompile Include="src\steam_xstatus.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\Version.rc" />
@@ -232,6 +233,7 @@
</ItemGroup>
<ItemGroup>
<None Include="res\steam.ico" />
+ <None Include="res\gaming.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/protocols/Steam/Steam_12.vcxproj.filters b/protocols/Steam/Steam_12.vcxproj.filters
index 0a9df2ae03..d1cfed825f 100644
--- a/protocols/Steam/Steam_12.vcxproj.filters
+++ b/protocols/Steam/Steam_12.vcxproj.filters
@@ -57,6 +57,9 @@
<ClCompile Include="src\steam_pooling.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\steam_xstatus.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
@@ -120,5 +123,8 @@
<None Include="res\steam.ico">
<Filter>Resource Files\Icon</Filter>
</None>
+ <None Include="res\gaming.ico">
+ <Filter>Resource Files\Icon</Filter>
+ </None>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/Steam/res/Resource.rc b/protocols/Steam/res/Resource.rc
index 93b2abc639..66d4075412 100644
--- a/protocols/Steam/res/Resource.rc
+++ b/protocols/Steam/res/Resource.rc
@@ -63,6 +63,7 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_STEAM ICON "steam.ico"
+IDI_GAMING ICON "gaming.ico"
#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Steam/res/gaming.ico b/protocols/Steam/res/gaming.ico
new file mode 100644
index 0000000000..a100a1f371
--- /dev/null
+++ b/protocols/Steam/res/gaming.ico
Binary files differ
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