summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/api/history.h4
-rw-r--r--protocols/Steam/src/steam_contacts.cpp48
-rw-r--r--protocols/Steam/src/steam_history.cpp10
-rw-r--r--protocols/Steam/src/steam_login.cpp5
-rw-r--r--protocols/Steam/src/steam_proto.cpp2
-rw-r--r--protocols/Steam/src/steam_proto.h4
-rw-r--r--protocols/Steam/src/steam_utils.h6
7 files changed, 10 insertions, 69 deletions
diff --git a/protocols/Steam/src/api/history.h b/protocols/Steam/src/api/history.h
index de3e7367f9..d3e4a49988 100644
--- a/protocols/Steam/src/api/history.h
+++ b/protocols/Steam/src/api/history.h
@@ -3,13 +3,13 @@
struct GetHistoryMessagesRequest : public HttpRequest
{
- GetHistoryMessagesRequest(const char *token, int64_t steamId, const char *who, time_t since) :
+ GetHistoryMessagesRequest(const char *token, int64_t steamId, int64_t who, time_t since) :
HttpRequest(REQUEST_GET, "/IFriendMessagesService/GetRecentMessages/v0001")
{
this
<< CHAR_PARAM("access_token", token)
<< INT64_PARAM("steamid1", steamId)
- << CHAR_PARAM("steamid2", who)
+ << INT64_PARAM("steamid2", who)
// Steam somehow doesn't respect too precise start time parameter, so we better request older time and then do own filtering again
<< INT64_PARAM("rtime32_start_time", since - 1500);
}
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index fbd824187e..ce62518054 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -62,16 +62,6 @@ MCONTACT CSteamProto::GetContactFromAuthEvent(MEVENT hEvent)
return DbGetAuthEventContact(&dbei);
}
-MCONTACT CSteamProto::GetContact(const char *steamId)
-{
- for (auto &hContact : AccContacts()) {
- ptrA cSteamId(getStringA(hContact, DBKEY_STEAM_ID));
- if (!mir_strcmp(cSteamId, steamId))
- return hContact;
- }
- return NULL;
-}
-
MCONTACT CSteamProto::GetContact(int64_t steamId)
{
for (auto &hContact : AccContacts())
@@ -293,44 +283,6 @@ void CSteamProto::ContactIsAskingAuth(MCONTACT hContact)
ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei);
}
-MCONTACT CSteamProto::AddContact(const char *steamId, const wchar_t *nick, bool isTemporary)
-{
- mir_cslock lock(m_addContactLock);
-
- if (!steamId || !mir_strlen(steamId)) {
- debugLogA(__FUNCTION__ ": empty steam id");
- return NULL;
- }
-
- MCONTACT hContact = GetContact(steamId);
- if (hContact)
- return hContact;
-
- // create contact
- hContact = db_add_contact();
- Proto_AddToContact(hContact, m_szModuleName);
-
- setString(hContact, DBKEY_STEAM_ID, steamId);
- if (mir_wstrlen(nick)) {
- setWString(hContact, "Nick", nick);
- db_set_ws(hContact, "CList", "MyHandle", nick);
- }
-
- if (isTemporary) {
- debugLogA("Contact %d added as a temporary one");
- Contact::RemoveFromList(hContact);
- }
-
- setByte(hContact, "Auth", 1);
-
- // move to default group
- if (!Clist_GroupExists(m_wszGroupName))
- Clist_GroupCreate(0, m_wszGroupName);
- Clist_SetGroup(hContact, m_wszGroupName);
-
- return hContact;
-}
-
MCONTACT CSteamProto::AddContact(int64_t steamId, const wchar_t *nick, bool isTemporary)
{
mir_cslock lock(m_addContactLock);
diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp
index 3b4b3a85b2..bbb1239aa1 100644
--- a/protocols/Steam/src/steam_history.cpp
+++ b/protocols/Steam/src/steam_history.cpp
@@ -8,8 +8,8 @@ void CSteamProto::OnGotConversations(const CFriendsMessagesGetActiveMessageSessi
for (int i=0; i < reply.n_message_sessions; i++) {
auto *session = reply.message_sessions[i];
- const char *who = AccountIdToSteamId(session->accountid_friend);
- MCONTACT hContact = GetContact(who);
+ uint64_t steamId = AccountIdToSteamId(session->accountid_friend);
+ MCONTACT hContact = GetContact(steamId);
if (!hContact)
continue;
@@ -20,7 +20,7 @@ void CSteamProto::OnGotConversations(const CFriendsMessagesGetActiveMessageSessi
time_t lastMessageTS = session->last_message;
if (lastMessageTS > storedMessageTS)
- SendRequest(new GetHistoryMessagesRequest(m_szAccessToken, m_iSteamId, who, storedMessageTS), &CSteamProto::OnGotHistoryMessages, (void*)hContact);
+ SendRequest(new GetHistoryMessagesRequest(m_szAccessToken, m_iSteamId, steamId, storedMessageTS), &CSteamProto::OnGotHistoryMessages, (void*)hContact);
}
}
@@ -39,7 +39,7 @@ void CSteamProto::OnGotHistoryMessages(const JSONNode &root, void *arg)
const JSONNode &message = messages[i - 1];
long long accountId = _wtoi64(message["accountid"].as_mstring());
- const char *steamId = AccountIdToSteamId(accountId);
+ uint64_t steamId = AccountIdToSteamId(accountId);
json_string text = message["message"].as_string();
@@ -53,7 +53,7 @@ void CSteamProto::OnGotHistoryMessages(const JSONNode &root, void *arg)
dbei.timestamp = timestamp;
dbei.pBlob = (char *)text.c_str();
- if (IsMe(steamId))
+ if (steamId == m_iSteamId)
dbei.flags = DBEF_SENT;
RecvMsg(hContact, dbei);
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp
index dda672c0af..8749e6ca09 100644
--- a/protocols/Steam/src/steam_login.cpp
+++ b/protocols/Steam/src/steam_login.cpp
@@ -15,11 +15,6 @@ bool CSteamProto::IsOnline()
return m_iStatus > ID_STATUS_OFFLINE && m_ws != nullptr;
}
-bool CSteamProto::IsMe(const char *steamId)
-{
- return m_iSteamId == (uint64_t)_atoi64(steamId);
-}
-
void CSteamProto::Logout()
{
m_bTerminated = true;
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 655343095d..4c9ce15628 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -105,7 +105,7 @@ MCONTACT CSteamProto::AddToListByEvent(int, int, MEVENT hDbEvent)
return 0;
DB::AUTH_BLOB blob(dbei.pBlob);
- return AddContact(blob.get_email(), Utf2T(blob.get_nick()));
+ return AddContact(_atoi64(blob.get_email()), Utf2T(blob.get_nick()));
}
int CSteamProto::Authorize(MEVENT hDbEvent)
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index c358906253..45f829197b 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -159,7 +159,6 @@ class CSteamProto : public PROTO<CSteamProto>
// login
bool IsOnline();
- bool IsMe(const char *steamId);
void Login();
void Logout();
@@ -213,9 +212,6 @@ class CSteamProto : public PROTO<CSteamProto>
void OnGotFriendList(const CMsgClientFriendsList &reply, const CMsgProtoBufHeader &hdr);
void OnGotFriendInfo(const CMsgClientPersonaState &reply, const CMsgProtoBufHeader &hdr);
- MCONTACT GetContact(const char *steamId);
- MCONTACT AddContact(const char *steamId, const wchar_t *nick = nullptr, bool isTemporary = false);
-
MCONTACT GetContact(int64_t steamId);
MCONTACT AddContact(int64_t steamId, const wchar_t *nick = nullptr, bool isTemporary = false);
diff --git a/protocols/Steam/src/steam_utils.h b/protocols/Steam/src/steam_utils.h
index aaae1c1fb5..29ac97b1e2 100644
--- a/protocols/Steam/src/steam_utils.h
+++ b/protocols/Steam/src/steam_utils.h
@@ -15,11 +15,9 @@ MBinBuffer createMachineID(const char *accName);
uint64_t getRandomInt();
CMStringA protobuf_c_text_to_string(const ProtobufCMessage &msg);
-inline const char *AccountIdToSteamId(long long accountId)
+inline uint64_t AccountIdToSteamId(uint64_t accountId)
{
- static char steamId[20];
- mir_snprintf(steamId, "%llu", accountId + 76561197960265728ll);
- return steamId;
+ return accountId | 0x110000100000000ll;
}
inline uint64_t SteamIdToAccountId(uint64_t steamId)