diff options
Diffstat (limited to 'protocols/Steam/src/steam_messages.cpp')
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index f2111e03aa..d06eb54de2 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -10,52 +10,44 @@ int CSteamProto::OnSendMessage(MCONTACT hContact, const char *message) {
UINT hMessage = InterlockedIncrement(&hMessageProcess);
- SendMessageParam *param = (SendMessageParam*)mir_calloc(sizeof(SendMessageParam));
+ SendMessageParam *param = (SendMessageParam *)mir_calloc(sizeof(SendMessageParam));
param->hContact = hContact;
param->hMessage = (HANDLE)hMessage;
ptrA token(getStringA("TokenSecret"));
ptrA umqid(getStringA("UMQID"));
ptrA steamId(getStringA(hContact, "SteamID"));
- PushRequest(
- new SendMessageRequest(token, umqid, steamId, message),
- &CSteamProto::OnMessageSent,
- param);
-
+ PushRequest(new SendMessageRequest(token, umqid, steamId, message), &CSteamProto::OnMessageSent, param);
return hMessage;
}
void CSteamProto::OnMessageSent(const HttpResponse &response, void *arg)
{
- SendMessageParam *param = (SendMessageParam*)arg;
+ SendMessageParam *param = (SendMessageParam *)arg;
std::string error = Translate("Unknown error");
ptrW steamId(getWStringA(param->hContact, "SteamID"));
time_t timestamp = NULL;
- if (response)
- {
+ if (response) {
JSONNode root = JSONNode::parse(response.Content);
- JSONNode node = root["error"];
- if (!node.isnull())
+ const JSONNode &node = root["error"];
+ if (node)
error = node.as_string();
- node = root["utc_timestamp"];
- if (!node.isnull())
- {
+ const JSONNode &time = root["utc_timestamp"];
+ if (time) {
timestamp = atol(node.as_string().c_str());
if (timestamp > getDword("LastMessageTS", 0))
setDword("LastMessageTS", timestamp);
}
}
- if (mir_strcmpi(error.c_str(), "OK") != 0)
- {
+ if (mir_strcmpi(error.c_str(), "OK") != 0) {
debugLogA(__FUNCTION__ ": failed to send message for %s (%s)", steamId, error.c_str());
ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hMessage, _A2T(error.c_str()));
}
- else
- {
+ else {
// remember server time of this message
auto it = m_mpOutMessages.find(param->hMessage);
if (it == m_mpOutMessages.end() && timestamp != NULL)
@@ -69,13 +61,12 @@ void CSteamProto::OnMessageSent(const HttpResponse &response, void *arg) int CSteamProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
{
- MessageWindowEvent *evt = (MessageWindowEvent*)lParam;
+ MessageWindowEvent *evt = (MessageWindowEvent *)lParam;
if (mir_strcmp(GetContactProto(evt->hContact), m_szModuleName))
return 0;
auto it = m_mpOutMessages.find((HANDLE)evt->seq);
- if (it != m_mpOutMessages.end())
- {
+ if (it != m_mpOutMessages.end()) {
evt->dbei->timestamp = it->second;
m_mpOutMessages.erase(it);
}
@@ -88,11 +79,10 @@ int CSteamProto::UserIsTyping(MCONTACT hContact, int type) // NOTE: Steam doesn't support sending "user stopped typing" so we're sending only positive info
if (type == PROTOTYPE_SELFTYPING_OFF)
return 0;
-
+
ptrA token(getStringA("TokenSecret"));
ptrA umqid(getStringA("UMQID"));
ptrA steamId(getStringA(hContact, "SteamID"));
PushRequest(new SendTypingRequest(token, umqid, steamId));
-
return 0;
}
|