diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-08-02 20:42:43 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-08-02 20:42:43 +0000 |
commit | 419e301b09de1935ab61f9a28363bb375fc7e208 (patch) | |
tree | 1f94bd57ff7482b4b11c5a206bbad6bbd52531f0 /protocols/Steam | |
parent | 32a70bf6533a4207324e0443463a3c12ece03672 (diff) |
Steam:
- fixed bug with default group creation
- added HttpResponse
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@14824 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r-- | protocols/Steam/src/http_request.h | 55 | ||||
-rw-r--r-- | protocols/Steam/src/request_queue.cpp | 3 | ||||
-rw-r--r-- | protocols/Steam/src/request_queue.h | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 3 | ||||
-rw-r--r-- | protocols/Steam/src/steam_login.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_options.cpp | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_pooling.cpp | 6 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_request.cpp | 2 | ||||
-rw-r--r-- | protocols/Steam/src/version.h | 6 |
10 files changed, 68 insertions, 19 deletions
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 73fce0eb1b..35a6352d42 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -1,6 +1,51 @@ #ifndef _HTTP_REQUEST_H_
#define _HTTP_REQUEST_H_
+class HttpResponse : public NETLIBHTTPREQUEST, public MZeroedObject
+{
+public:
+ const NETLIBHTTPREQUEST* request;
+
+ HttpResponse(const NETLIBHTTPREQUEST* response, const NETLIBHTTPREQUEST* request = NULL)
+ {
+ request = request;
+ if (response)
+ {
+ cbSize = response->cbSize;
+ requestType = response->requestType;
+ flags = response->flags;
+ szUrl = mir_strdup(response->szUrl);
+ headers = (NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER) * response->headersCount);
+ headersCount = response->headersCount;
+ for (int i = 0; i < headersCount; i++)
+ {
+ headers[i].szName = mir_strdup(response->headers[i].szName);
+ headers[i].szValue = mir_strdup(response->headers[i].szValue);
+ }
+ pData = (char*)mir_alloc(response->dataLength);
+ dataLength = response->dataLength;
+ memcpy(pData, response->pData, dataLength);
+ resultCode = response->resultCode;
+ szResultDescr = mir_strdup(response->szResultDescr);
+ nlc = response->nlc;
+ timeout = response->timeout;
+ }
+ }
+
+ ~HttpResponse()
+ {
+ for (int i = 0; i < headersCount; i++)
+ {
+ mir_free(headers[i].szName);
+ mir_free(headers[i].szValue);
+ }
+ mir_free(szUrl);
+ mir_free(headers);
+ mir_free(pData);
+ mir_free(szResultDescr);
+ }
+};
+
class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
{
private:
@@ -81,7 +126,7 @@ public: mir_free(pData);
}
- NETLIBHTTPREQUEST* Send(HANDLE hConnection)
+ HttpResponse* Send(HANDLE hConnection)
{
szUrl = m_url.GetBuffer();
@@ -89,8 +134,14 @@ public: mir_snprintf(message, _countof(message), "Send request to %s", szUrl);
CallService(MS_NETLIB_LOG, (WPARAM)hConnection, (LPARAM)&message);
- return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)this);
+ NETLIBHTTPREQUEST* response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)this);
+ HttpResponse* result = new HttpResponse(response, this);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
+
+ return result;
}
};
+
+
#endif //_HTTP_REQUEST_H_
\ No newline at end of file diff --git a/protocols/Steam/src/request_queue.cpp b/protocols/Steam/src/request_queue.cpp index c419ffbd26..12f9beb61c 100644 --- a/protocols/Steam/src/request_queue.cpp +++ b/protocols/Steam/src/request_queue.cpp @@ -72,10 +72,9 @@ void RequestQueue::Send(HttpRequest *request, HttpResponseCallback response, voi void RequestQueue::Execute(RequestQueueItem *item)
{
- NETLIBHTTPREQUEST *response = item->request->Send(hConnection);
+ HttpResponse *response = item->request->Send(hConnection);
if (item->responseCallback != NULL)
item->responseCallback(response, item->arg);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
if (item->finallyCallback != NULL)
item->finallyCallback(item->arg);
delete item;
diff --git a/protocols/Steam/src/request_queue.h b/protocols/Steam/src/request_queue.h index 3a213be0bf..0cd8811536 100644 --- a/protocols/Steam/src/request_queue.h +++ b/protocols/Steam/src/request_queue.h @@ -1,7 +1,7 @@ #ifndef _REQUEST_QUEUE_H_
#define _REQUEST_QUEUE_H_
-typedef void(*HttpResponseCallback)(const NETLIBHTTPREQUEST *response, void *arg);
+typedef void(*HttpResponseCallback)(const HttpResponse *response, void *arg);
typedef void(*HttpFinallyCallback)(void *arg);
struct RequestQueueItem
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 117ae8bbe4..c8e17b7aec 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -314,7 +314,8 @@ MCONTACT CSteamProto::AddContact(const char *steamId, bool isTemporary) DBVARIANT dbv; if (!getWString("DefaultGroup", &dbv)) { - db_set_ts(hContact, "CList", "Group", dbv.ptszVal); + if(Clist_GroupExists(dbv.ptszVal)) + db_set_ts(hContact, "CList", "Group", dbv.ptszVal); db_free(&dbv); } } diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp index e52455a4d5..52345fef00 100644 --- a/protocols/Steam/src/steam_login.cpp +++ b/protocols/Steam/src/steam_login.cpp @@ -160,11 +160,11 @@ void CSteamProto::OnAuthorizationError(const JSONNode &node) std::string captchaId = node["captcha_gid"].as_string();
GetCaptchaRequest *request = new GetCaptchaRequest(captchaId.c_str());
- NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser);
+ HttpResponse *response = request->Send(m_hNetlibUser);
delete request;
CSteamCaptchaDialog captchaDialog(this, (BYTE*)response->pData, response->dataLength);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
+ delete response;
if (!captchaDialog.DoModal())
{
delSetting("CaptchaId");
diff --git a/protocols/Steam/src/steam_options.cpp b/protocols/Steam/src/steam_options.cpp index 4f5a2a8dcd..391f534b24 100644 --- a/protocols/Steam/src/steam_options.cpp +++ b/protocols/Steam/src/steam_options.cpp @@ -25,7 +25,7 @@ void CSteamOptionsMain::OnInitDialog() void CSteamOptionsMain::OnApply()
{
TCHAR *group = m_group.GetText();
- if (mir_tstrlen(group) > 0 && Clist_GroupExists(group))
+ if (mir_tstrlen(group) > 0 && !Clist_GroupExists(group))
Clist_CreateGroup(0, group);
if (m_proto->IsOnline())
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index 1233c9a7a0..0c1f50e9fd 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -177,13 +177,13 @@ void CSteamProto::PollingThread(void*) { PollRequest *request = new PollRequest(token, umqId, messageId, IdleSeconds()); //request->nlc = m_pollingConnection; - NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser); + HttpResponse *response = request->Send(m_hNetlibUser); delete request; if (response == NULL || response->resultCode != HTTP_CODE_OK) { if (response != NULL) - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); + delete response; errors++; continue; @@ -245,7 +245,7 @@ void CSteamProto::PollingThread(void*) breaked = true; } - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); + delete response; } setDword("MessageID", messageId); diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 807d2a091d..69f498561b 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -209,13 +209,11 @@ DWORD_PTR CSteamProto:: GetCaps(int type, MCONTACT) case PFLAGNUM_4: return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTIDLE | PF4_SUPPORTTYPING;// | PF4_IMSENDOFFLINE; case PFLAGNUM_5: - return PF2_HEAVYDND | PF2_OUTTOLUNCH | PF2_FREECHAT; + return PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_OUTTOLUNCH | PF2_FREECHAT; case PFLAG_UNIQUEIDTEXT: return (DWORD_PTR)Translate("SteamID"); case PFLAG_UNIQUEIDSETTING: return (DWORD_PTR)"SteamID"; - case PFLAG_MAXLENOFMESSAGE: - return 200000; // this is guessed limit, in reality it is probably bigger default: return 0; } diff --git a/protocols/Steam/src/steam_request.cpp b/protocols/Steam/src/steam_request.cpp index c480628151..968c09da37 100644 --- a/protocols/Steam/src/steam_request.cpp +++ b/protocols/Steam/src/steam_request.cpp @@ -31,7 +31,7 @@ public: }
};
-static void SteamHttpResponse(const NETLIBHTTPREQUEST *response, void *arg)
+static void SteamHttpResponse(const HttpResponse *response, void *arg)
{
SteamResponseDelegate *delegate = (SteamResponseDelegate*)arg;
delegate->Invoke(response);
diff --git a/protocols/Steam/src/version.h b/protocols/Steam/src/version.h index f89c59fa87..c901a0c34f 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 4
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
#define __PLUGIN_NAME "Steam protocol"
#define __FILENAME "Steam.dll"
#define __DESCRIPTION "Steam protocol support for Miranda NG."
-#define __AUTHOR "unsane, Robert P\xf6" "sel"
+#define __AUTHOR "Miranda NG Team, Robert P\xf6" "sel"
#define __AUTHOREMAIL ""
#define __AUTHORWEB "http://miranda-ng.org/p/Steam/"
-#define __COPYRIGHT "� 2014-15 Miranda NG team"
+#define __COPYRIGHT "© 2014-15 Miranda NG team"
|