summaryrefslogtreecommitdiff
path: root/protocols/Steam
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-12-09 17:08:24 +0000
committerRobert Pösel <robyer@seznam.cz>2014-12-09 17:08:24 +0000
commit8a78d1312d2a7d25aabc4b2fd082891e4714dbb7 (patch)
treed0eae08094d99b1830ba66d581540f5ea10598dc /protocols/Steam
parent89ce406fb710ff91a3f80d5f1ee674c09a1f7603 (diff)
Steam: Show xstatus as extra icon in clist (step 3)
git-svn-id: http://svn.miranda-ng.org/main/trunk@11303 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r--protocols/Steam/src/common.h3
-rw-r--r--protocols/Steam/src/stdafx.cpp9
-rw-r--r--protocols/Steam/src/steam_contacts.cpp22
-rw-r--r--protocols/Steam/src/steam_pooling.cpp2
-rw-r--r--protocols/Steam/src/steam_proto.cpp1
-rw-r--r--protocols/Steam/src/steam_proto.h1
-rw-r--r--protocols/Steam/src/steam_xstatus.cpp8
7 files changed, 41 insertions, 5 deletions
diff --git a/protocols/Steam/src/common.h b/protocols/Steam/src/common.h
index 37822139b9..d19f25ab3e 100644
--- a/protocols/Steam/src/common.h
+++ b/protocols/Steam/src/common.h
@@ -27,6 +27,7 @@
#include <m_protoint.h>
#include <m_idle.h>
#include <m_xstatus.h>
+#include <m_extraicons.h>
#include <win2k.h>
#include <map>
@@ -42,6 +43,8 @@
class CSteamProto;
extern HINSTANCE g_hInstance;
+extern HANDLE hExtraXStatus;
+
#include "Steam\steam.h"
#include "steam_proto.h"
diff --git a/protocols/Steam/src/stdafx.cpp b/protocols/Steam/src/stdafx.cpp
index d51a866ca3..7c6793d8cb 100644
--- a/protocols/Steam/src/stdafx.cpp
+++ b/protocols/Steam/src/stdafx.cpp
@@ -3,6 +3,8 @@
int hLangpack;
HINSTANCE g_hInstance;
+HANDLE hExtraXStatus;
+
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -43,6 +45,13 @@ extern "C" int __declspec(dllexport) Load(void)
pd.fnUninit = (pfnUninitProto)CSteamProto::UninitProtoInstance;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+ char iconName[100];
+ mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, "gaming");
+
+ // extra statuses
+ HookEvent(ME_SKIN2_ICONSCHANGED, OnReloadIcons);
+ hExtraXStatus = ExtraIcon_Register("steam_game", LPGEN("Steam game"), iconName);
+
CSteamProto::InitMenus();
return 0;
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index 25720b1d05..a950b8b436 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -4,7 +4,19 @@ void CSteamProto::SetContactStatus(MCONTACT hContact, WORD status)
{
WORD oldStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
if (oldStatus != status)
+ {
setWord(hContact, "Status", status);
+
+ // If contact is offline, clear also xstatus
+ if (status == ID_STATUS_OFFLINE)
+ {
+ delSetting(hContact, "XStatusId");
+ delSetting(hContact, "XStatusName");
+ delSetting(hContact, "XStatusMsg");
+
+ SetContactExtraIcon(hContact, NULL);
+ }
+ }
}
void CSteamProto::SetAllContactsStatus(WORD status)
@@ -13,8 +25,8 @@ void CSteamProto::SetAllContactsStatus(WORD status)
{
if (this->isChatRoom(hContact))
continue;
- //if (this->IsContactOnline(hContact))
- setWord(hContact, "Status", status);
+
+ SetContactStatus(hContact, status);
}
}
@@ -190,6 +202,8 @@ void CSteamProto::UpdateContact(MCONTACT hContact, JSONNODE *data)
setDword(hContact, "XStatusId", gameId);
setTString(hContact, "XStatusName", TranslateT("Playing"));
setTString(hContact, "XStatusMsg", message);
+
+ SetContactExtraIcon(hContact, gameId);
}
else
{
@@ -200,6 +214,8 @@ void CSteamProto::UpdateContact(MCONTACT hContact, JSONNODE *data)
delSetting(hContact, "XStatusId");
delSetting(hContact, "XStatusName");
delSetting(hContact, "XStatusMsg");
+
+ SetContactExtraIcon(hContact, NULL);
}
}
@@ -209,7 +225,7 @@ void CSteamProto::ContactIsRemoved(MCONTACT hContact)
{
setByte(hContact, "Auth", 1);
setDword(hContact, "DeletedTS", ::time(NULL));
- setWord(hContact, "Status", ID_STATUS_OFFLINE);
+ SetContactStatus(hContact, ID_STATUS_OFFLINE);
ptrT nick(getTStringA(hContact, "Nick"));
TCHAR message[MAX_PATH];
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp
index ff21a8e9c2..efdd6514f3 100644
--- a/protocols/Steam/src/steam_pooling.cpp
+++ b/protocols/Steam/src/steam_pooling.cpp
@@ -84,7 +84,7 @@ void CSteamProto::ParsePollData(JSONNODE *data)
if (hContact == NULL)
continue; // probably this is info about random player playing on same server, so we ignore it
- setWord(hContact, "Status", status);
+ SetContactStatus(hContact, status);
node = json_get(item, "persona_name");
setTString(hContact, "Nick", json_as_string(node));
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 2cb802c9fd..952e74b4e2 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -62,7 +62,6 @@ CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName) :
CreateProtoService(PS_GETCUSTOMSTATUSEX, &CSteamProto::OnGetXStatusEx);
CreateProtoService(PS_GETCUSTOMSTATUSICON, &CSteamProto::OnGetXStatusIcon);
CreateProtoService(PS_GETADVANCEDSTATUSICON, &CSteamProto::OnRequestAdvStatusIconIdx);
- HookEvent(ME_SKIN2_ICONSCHANGED, OnReloadIcons);
}
CSteamProto::~CSteamProto()
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index d3c5b65b0a..0b1b2c0d20 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -292,5 +292,6 @@ protected:
};
int OnReloadIcons(WPARAM wParam, LPARAM lParam);
+void SetContactExtraIcon(MCONTACT hContact, int status);
#endif //_STEAM_PROTO_H_ \ No newline at end of file
diff --git a/protocols/Steam/src/steam_xstatus.cpp b/protocols/Steam/src/steam_xstatus.cpp
index c67ddf5f6b..b157971331 100644
--- a/protocols/Steam/src/steam_xstatus.cpp
+++ b/protocols/Steam/src/steam_xstatus.cpp
@@ -17,6 +17,14 @@ int CSteamProto::GetContactXStatus(MCONTACT hContact)
return getDword(hContact, "XStatusId", 0) ? 1 : 0;
}
+void SetContactExtraIcon(MCONTACT hContact, int status)
+{
+ char iconName[100];
+ mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, "gaming");
+
+ ExtraIcon_SetIcon(hExtraXStatus, hContact, (status > 0) ? Skin_GetIconHandle(iconName) : NULL);
+}
+
INT_PTR CSteamProto::OnGetXStatusEx(WPARAM wParam, LPARAM lParam)
{
MCONTACT hContact = (MCONTACT)wParam;