summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-12-29 13:30:44 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-12-29 13:30:44 +0300
commit8f347ca6c98948cab9d79475fe9d070fa3155828 (patch)
tree1ff3abd64983238c3f34b78b28e43c2aabf0448c /protocols/Steam/src
parentf98fe1465694e5899d00bfb8814a5578b144d7c1 (diff)
code cleaning
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/main.cpp2
-rw-r--r--protocols/Steam/src/stdafx.h2
-rw-r--r--protocols/Steam/src/steam_contacts.cpp2
-rw-r--r--protocols/Steam/src/steam_dialogs.cpp2
-rw-r--r--protocols/Steam/src/steam_login.cpp8
-rw-r--r--protocols/Steam/src/steam_menus.cpp6
-rw-r--r--protocols/Steam/src/steam_proto.h1
-rw-r--r--protocols/Steam/src/steam_server.cpp4
-rw-r--r--protocols/Steam/src/steam_utils.cpp4
-rw-r--r--protocols/Steam/src/steam_ws.cpp8
-rw-r--r--protocols/Steam/src/steam_xstatus.cpp5
11 files changed, 20 insertions, 24 deletions
diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp
index b72fc2a36f..bc43925734 100644
--- a/protocols/Steam/src/main.cpp
+++ b/protocols/Steam/src/main.cpp
@@ -183,7 +183,7 @@ int CMPlugin::Load()
InitSteamServices();
// icons
- g_plugin.registerIcon("Protocols/" MODULE, iconList, MODULE);
+ g_plugin.registerIcon("Protocols/" MODULENAME, iconList, MODULENAME);
// extra statuses
hExtraXStatus = ExtraIcon_RegisterIcolib("steam_game", LPGEN("Steam game"), g_plugin.getIconHandle(IDI_GAMING));
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h
index a966f38da0..ed82f77a07 100644
--- a/protocols/Steam/src/stdafx.h
+++ b/protocols/Steam/src/stdafx.h
@@ -50,7 +50,7 @@
#include "protobuf-c/steammessages_notifications.steamclient.pb-c.h"
#include "proto.h"
-#define MODULE "Steam"
+#define MODULENAME "Steam"
#define STEAM_API_TIMEOUT 20
#define STEAM_API_IDLEOUT_AWAY 600
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index 61f8feeff4..9bc052a324 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -175,7 +175,7 @@ void CSteamProto::OnGotFriendInfo(const CMsgClientPersonaState &reply, const CMs
CMStringW message(gameInfo);
if (gameId && message.IsEmpty()) {
CMStringA szSetting(FORMAT, "AppInfo_%d", gameId);
- ptrW szName(getWStringA(szSetting));
+ ptrW szName(g_plugin.getWStringA(szSetting));
if (szName)
message = szName;
else
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp
index 95cc2df8df..6baf791e55 100644
--- a/protocols/Steam/src/steam_dialogs.cpp
+++ b/protocols/Steam/src/steam_dialogs.cpp
@@ -10,7 +10,7 @@ CSteamPasswordEditor::CSteamPasswordEditor(CSteamProto *proto) :
bool CSteamPasswordEditor::OnInitDialog()
{
char iconName[100];
- mir_snprintf(iconName, "%s_%s", MODULE, "main");
+ mir_snprintf(iconName, "%s_%s", MODULENAME, "main");
Window_SetIcon_IcoLib(m_hwnd, IcoLib_GetIconHandle(iconName));
SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 64, 0);
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp
index 24c247ce76..acdc25f889 100644
--- a/protocols/Steam/src/steam_login.cpp
+++ b/protocols/Steam/src/steam_login.cpp
@@ -25,17 +25,17 @@ void CSteamProto::Logout()
void CSteamProto::OnGotHosts(const JSONNode &root, void*)
{
- db_delete_module(0, STEAM_MODULE);
+ db_delete_module(0, MODULENAME);
int i = 0;
CMStringA szSetting;
for (auto &it : root["response"]["serverlist_websockets"]) {
szSetting.Format("Host%d", i++);
- db_set_ws(0, STEAM_MODULE, szSetting, it.as_mstring());
+ db_set_ws(0, MODULENAME, szSetting, it.as_mstring());
}
- db_set_dw(0, STEAM_MODULE, DBKEY_HOSTS_COUNT, i);
- db_set_dw(0, STEAM_MODULE, DBKEY_HOSTS_DATE, time(0));
+ db_set_dw(0, MODULENAME, DBKEY_HOSTS_COUNT, i);
+ db_set_dw(0, MODULENAME, DBKEY_HOSTS_DATE, time(0));
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp
index 3795b9066e..9260528aa9 100644
--- a/protocols/Steam/src/steam_menus.cpp
+++ b/protocols/Steam/src/steam_menus.cpp
@@ -106,7 +106,7 @@ void CSteamProto::InitMenus()
// "Block"
SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32);
- mi.pszService = MODULE "/Block";
+ mi.pszService = MODULENAME "/Block";
mi.name.w = LPGENW("Block");
mi.position = -201001001 + CMI_BLOCK;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_OFF);
@@ -115,7 +115,7 @@ void CSteamProto::InitMenus()
// "Unblock"
SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32);
- mi.pszService = MODULE "/Unblock";
+ mi.pszService = MODULENAME "/Unblock";
mi.name.w = LPGENW("Unblock");
mi.position = -201001001 + CMI_UNBLOCK;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_ON);
@@ -126,7 +126,7 @@ void CSteamProto::InitMenus()
// "Join to game"
SET_UID(mi, 0x1a6aaab7, 0xba31, 0x4b47, 0x8e, 0xce, 0xf8, 0x8e, 0xf4, 0x62, 0x4f, 0xd7);
- mi.pszService = MODULE "/JoinToGame";
+ mi.pszService = MODULENAME "/JoinToGame";
mi.name.w = LPGENW("Join to game");
mi.position = -200001000 + CMI_JOIN_GAME;
mi.hIcolibItem = nullptr;
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index de2670a376..57531bacec 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -8,7 +8,6 @@
#define STEAM_PROTOCOL_MASK 0x80000000
// Global settings for all accounts: hosts' list
-#define STEAM_MODULE "Steam"
#define DBKEY_HOSTS_COUNT "HostsCount"
#define DBKEY_HOSTS_DATE "HostsDate"
#define DBKEY_LASTMSG "LastMessageTS"
diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp
index e3150a4499..c96e821e19 100644
--- a/protocols/Steam/src/steam_server.cpp
+++ b/protocols/Steam/src/steam_server.cpp
@@ -50,13 +50,13 @@ void CSteamProto::OnGotAppInfo(const CMsgClientPICSProductInfoResponse &reply, c
auto *pApp = reply.apps[i];
if (pApp->buffer.len) {
- std::regex regex("\"name\"[\\s*]\"(.+?)\"");
+ std::regex regex("\"name\"\\s*\"(.+?)\"");
std::smatch match;
std::string content((char *)pApp->buffer.data, pApp->buffer.len);
if (std::regex_search(content, match, regex)) {
std::string szName = match[1];
CMStringA szSetting(FORMAT, "AppInfo_%d", pApp->appid);
- setString(szSetting, szName.c_str());
+ g_plugin.setUString(szSetting, szName.c_str());
for (auto &cc : AccContacts()) {
if (getDword(cc, "XStatusId") == pApp->appid) {
diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp
index b8b15f5db8..04610d7cc9 100644
--- a/protocols/Steam/src/steam_utils.cpp
+++ b/protocols/Steam/src/steam_utils.cpp
@@ -146,7 +146,7 @@ void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags,
ppd.lchContact = hContact;
wcsncpy(ppd.lpwzContactName, caption, MAX_CONTACTNAME);
wcsncpy(ppd.lpwzText, message, MAX_SECONDLINE);
- ppd.lchIcon = IcoLib_GetIcon(MODULE"_main");
+ ppd.lchIcon = g_plugin.getIcon(IDI_STEAM);
if (!PUAddPopupW(&ppd))
return;
@@ -157,7 +157,7 @@ void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags,
void ShowNotification(const wchar_t *message, int flags, MCONTACT hContact)
{
- ShowNotification(_A2W(MODULE), message, flags, hContact);
+ ShowNotification(_A2W(MODULENAME), message, flags, hContact);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Steam/src/steam_ws.cpp b/protocols/Steam/src/steam_ws.cpp
index c4994c0041..b6700f754a 100644
--- a/protocols/Steam/src/steam_ws.cpp
+++ b/protocols/Steam/src/steam_ws.cpp
@@ -20,14 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void __cdecl CSteamProto::ServerThread(void *)
{
// load web socket servers first if needed
- int iTimeDiff = db_get_dw(0, STEAM_MODULE, DBKEY_HOSTS_DATE);
- int iHostCount = db_get_dw(0, STEAM_MODULE, DBKEY_HOSTS_COUNT);
+ int iTimeDiff = db_get_dw(0, MODULENAME, DBKEY_HOSTS_DATE);
+ int iHostCount = db_get_dw(0, MODULENAME, DBKEY_HOSTS_COUNT);
if (!iHostCount || time(0) - iTimeDiff > 3600 * 24 * 7) { // once a week
if (!SendRequest(new GetHostsRequest(), &CSteamProto::OnGotHosts)) {
Logout();
return;
}
- iHostCount = db_get_dw(0, STEAM_MODULE, DBKEY_HOSTS_COUNT);
+ iHostCount = db_get_dw(0, MODULENAME, DBKEY_HOSTS_COUNT);
}
srand(time(0));
@@ -36,7 +36,7 @@ void __cdecl CSteamProto::ServerThread(void *)
CMStringA szHost;
do {
szHost.Format("Host%d", rand() % iHostCount);
- szHost = db_get_sm(0, STEAM_MODULE, szHost);
+ szHost = db_get_sm(0, MODULENAME, szHost);
szHost.Insert(0, "wss://");
szHost += "/cmsocket/";
}
diff --git a/protocols/Steam/src/steam_xstatus.cpp b/protocols/Steam/src/steam_xstatus.cpp
index 0594be7665..5ebef439e2 100644
--- a/protocols/Steam/src/steam_xstatus.cpp
+++ b/protocols/Steam/src/steam_xstatus.cpp
@@ -93,10 +93,7 @@ HICON CSteamProto::GetXStatusIcon(int status, UINT flags)
if (status < 1)
return nullptr;
- char iconName[100];
- mir_snprintf(iconName, "%s_%s", MODULE, "gaming");
-
- HICON icon = IcoLib_GetIcon(iconName, (flags & LR_BIGICON) != 0);
+ HICON icon = g_plugin.getIcon(IDI_GAMING, (flags & LR_BIGICON) != 0);
return (flags & LR_SHARED) ? icon : CopyIcon(icon);
}