diff options
author | aunsane <aunsane@gmail.com> | 2018-02-07 21:24:20 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-02-07 21:24:20 +0300 |
commit | a0905e751e2524f63d2468c2063191143b51785e (patch) | |
tree | a34ba66541b47c511d0e5fcb1d6088d9310b7f95 /protocols/Steam/src | |
parent | 18d9a96928b22e847967b41a89eec6f636a260b2 (diff) |
Steam:
- set default timeout for request in 3 sec
- clean geme info when contact goes offline
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r-- | protocols/Steam/src/http_request.h | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 70 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 1 |
4 files changed, 44 insertions, 33 deletions
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 321bad5e7e..f6fe0d10ab 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -353,6 +353,7 @@ public: cbSize = sizeof(NETLIBHTTPREQUEST); requestType = method; flags = NLHRF_HTTP11 | NLHRF_SSL; + timeout = 3000; Content = new HttpContent(this); } @@ -363,6 +364,7 @@ public: cbSize = sizeof(NETLIBHTTPREQUEST); requestType = method; flags = NLHRF_HTTP11 | NLHRF_SSL; + timeout = 5; va_list formatArgs; va_start(formatArgs, urlFormat); diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 75f17f80e4..e163597127 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -1,44 +1,52 @@ #include "stdafx.h" +void CSteamProto::SetAllContactStatuses(int status) +{ + for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) + SetContactStatus(hContact, status); +} + void CSteamProto::SetContactStatus(MCONTACT hContact, WORD status) { if (!hContact) return; WORD oldStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE); - if (oldStatus != status) - { - setWord(hContact, "Status", status); + if (oldStatus == status) + return; + + setWord(hContact, "Status", status); - // Special handling of some statuses - switch (status) - { - case ID_STATUS_FREECHAT: - // Contact is looking to play, save it to as status message - db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Looking to play")); - break; - - case ID_STATUS_OUTTOLUNCH: - // Contact is looking to trade, save it to as status message - db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Looking to trade")); - break; - - case ID_STATUS_OFFLINE: - { - // If contact is offline, clear also xstatus - delSetting(hContact, "XStatusId"); - delSetting(hContact, "XStatusName"); - delSetting(hContact, "XStatusMsg"); - - SetContactExtraIcon(hContact, NULL); - } - // no break intentionally - [[fallthrough]]; + // Special handling of some statuses + switch (status) + { + case ID_STATUS_FREECHAT: + // Contact is looking to play, save it to as status message + db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Looking to play")); + break; + + case ID_STATUS_OUTTOLUNCH: + // Contact is looking to trade, save it to as status message + db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Looking to trade")); + break; + + case ID_STATUS_OFFLINE: + // if contact is offline, remove played game info + delSetting(hContact, "GameID"); + delSetting(hContact, "ServerIP"); + delSetting(hContact, "ServerID"); + // clear also xstatus + delSetting(hContact, "XStatusId"); + delSetting(hContact, "XStatusName"); + delSetting(hContact, "XStatusMsg"); + // and extra icon + SetContactExtraIcon(hContact, NULL); + // no break intentionally + [[fallthrough]]; - default: - db_unset(hContact, "CList", "StatusMsg"); - break; - } + default: + db_unset(hContact, "CList", "StatusMsg"); + break; } } diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index b3ba3024bc..586565c8cb 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -51,7 +51,7 @@ CSteamProto::CSteamProto(const char* protoName, const wchar_t* userName) db_set_resident(m_szModuleName, "ServerIP"); db_set_resident(m_szModuleName, "ServerID"); - setAllContactStatuses(ID_STATUS_OFFLINE); + SetAllContactStatuses(ID_STATUS_OFFLINE); // avatar API CreateProtoService(PS_GETAVATARINFO, &CSteamProto::GetAvatarInfo); @@ -288,7 +288,7 @@ int CSteamProto::SetStatus(int new_status) m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; if (!Miranda_IsTerminated()) - setAllContactStatuses(ID_STATUS_OFFLINE); + SetAllContactStatuses(ID_STATUS_OFFLINE); Logout(); } diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index d1e5513baa..2478eb3223 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -158,6 +158,7 @@ protected: void DeleteAuthSettings();
// contacts
+ void SetAllContactStatuses(int status);
void SetContactStatus(MCONTACT hContact, WORD status);
MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
|