summaryrefslogtreecommitdiff
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
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
-rw-r--r--protocols/Steam/src/steam_messages.cpp14
-rw-r--r--protocols/Steam/src/steam_proto.cpp26
-rw-r--r--protocols/Steam/src/steam_proto.h3
-rw-r--r--protocols/Steam/src/version.h6
4 files changed, 32 insertions, 17 deletions
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp
index 418d57d814..f2f2c51c8a 100644
--- a/protocols/Steam/src/steam_messages.cpp
+++ b/protocols/Steam/src/steam_messages.cpp
@@ -17,30 +17,26 @@ void CSteamProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
{
SendMessageParam *param = (SendMessageParam*)arg;
- int status = ACKRESULT_FAILED;
- ptrT error;
-
+ ptrT error(mir_tstrdup(TranslateT("Unknown error")));
ptrT steamId(getTStringA(param->hContact, "SteamID"));
if (response != NULL && response->resultCode == HTTP_STATUS_OK)
{
JSONROOT root(response->pData);
JSONNODE *node = json_get(root, "error");
- error = json_as_string(node);
+ if (node)
+ error = json_as_string(node);
}
+ int status = ACKRESULT_FAILED;
+
if (!mir_tstrcmpi(error, _T("OK")))
{
status = ACKRESULT_SUCCESS;
error = NULL;
}
else
- {
- if (!error)
- error = mir_tstrdup(IsOnline() ? TranslateT("Unknown error") : TranslateT("You cannot send messages when you are offline."));
-
debugLog(_T("CSteamProto::OnMessageSent: failed to send message for %s (%s)"), steamId, error);
- }
ProtoBroadcastAck(
param->hContact,
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; }
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 1ed62dff5c..e2a76fa44b 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -28,6 +28,8 @@ struct SendMessageParam
{
MCONTACT hContact;
HANDLE hMessage;
+ const char *msg;
+ int flags;
};
struct STEAM_SEARCH_RESULT
@@ -198,6 +200,7 @@ protected:
void ExecuteRequest(QueueItem *requestItem);
+ void __cdecl SendMsgThread(void*);
void __cdecl QueueThread(void*);
// pooling thread
diff --git a/protocols/Steam/src/version.h b/protocols/Steam/src/version.h
index 802fa4e515..027d483369 100644
--- a/protocols/Steam/src/version.h
+++ b/protocols/Steam/src/version.h
@@ -1,14 +1,14 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 2
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
#define __PLUGIN_NAME "Steam protocol"
#define __FILENAME "Steam.dll"
#define __DESCRIPTION "Steam protocol support for Miranda NG."
-#define __AUTHOR "unsane"
+#define __AUTHOR "unsane, Robert P\xf6" "sel"
#define __AUTHOREMAIL ""
#define __AUTHORWEB "http://miranda-ng.org/p/Steam/"
-#define __COPYRIGHT "© 2014 Miranda NG team"
+#define __COPYRIGHT "© 2014-15 Miranda NG team"