summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_proto.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-03-06 10:23:12 +0000
committerRobert Pösel <robyer@seznam.cz>2015-03-06 10:23:12 +0000
commit80697b0e53191d73dfb440b334a928cbf0bc9c2c (patch)
treec797b07c48aadbd30e6ab95b7285fb010474719c /protocols/Steam/src/steam_proto.cpp
parent224d0671bfbfccb2883313183a51f86fdf967745 (diff)
Steam: Rework SendMsg() method; Version bump
Now it raise error immediately when user tries to send message when protocol is offline git-svn-id: http://svn.miranda-ng.org/main/trunk@12350 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_proto.cpp')
-rw-r--r--protocols/Steam/src/steam_proto.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 1867187985..e7efc9f510 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -334,23 +334,39 @@ int __cdecl CSteamProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
{
UINT hMessage = InterlockedIncrement(&hMessageProcess);
- CMStringA message = (flags & PREF_UNICODE) ? ptrA(mir_utf8encode(msg)) : msg; // TODO: mir_utf8encode check taken from FacebookRM, is it needed? Usually we get PREF_UTF8 flag instead.
-
SendMessageParam *param = (SendMessageParam*)mir_calloc(sizeof(SendMessageParam));
param->hContact = hContact;
param->hMessage = (HANDLE)hMessage;
+ param->msg = msg;
+ param->flags = flags;
+
+ ForkThread(&CSteamProto::SendMsgThread, (void*)param);
+
+ return hMessage;
+}
+
+void __cdecl CSteamProto::SendMsgThread(void *arg)
+{
+ SendMessageParam *param = (SendMessageParam*)arg;
+
+ if (!IsOnline())
+ {
+ ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hMessage, (LPARAM)Translate("You cannot send messages when you are offline."));
+ mir_free(param);
+ return;
+ }
+
+ CMStringA message = (param->flags & PREF_UNICODE) ? ptrA(mir_utf8encode(param->msg)) : param->msg; // TODO: mir_utf8encode check taken from FacebookRM, is it needed? Usually we get PREF_UTF8 flag instead.
ptrA token(getStringA("TokenSecret"));
ptrA umqid(getStringA("UMQID"));
- ptrA steamId(getStringA(hContact, "SteamID"));
+ ptrA steamId(getStringA(param->hContact, "SteamID"));
PushRequest(
new SteamWebApi::SendMessageRequest(token, umqid, steamId, message),
&CSteamProto::OnMessageSent,
param,
ARG_MIR_FREE);
-
- return hMessage;
}
int __cdecl CSteamProto::SendUrl(MCONTACT hContact, int flags, const char *url) { return 0; }