From c89e8a054ac888b27065916ffde96af73404228c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 4 Apr 2015 20:10:50 +0000 Subject: SkypeWeb: - history sync (patch from MikalaiR) - refactored message sending git-svn-id: http://svn.miranda-ng.org/main/trunk@12599 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_request.cpp | 40 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_request.cpp') diff --git a/protocols/SkypeWeb/src/skype_request.cpp b/protocols/SkypeWeb/src/skype_request.cpp index 61d9754ec0..b0026de980 100644 --- a/protocols/SkypeWeb/src/skype_request.cpp +++ b/protocols/SkypeWeb/src/skype_request.cpp @@ -5,14 +5,24 @@ class SkypeResponseDelegate private: CSkypeProto *proto; SkypeResponseCallback responseCallback; + SkypeResponseWithArgCallback responseWithArgCallback; + + void *arg; + bool hasArg; public: SkypeResponseDelegate(CSkypeProto *proto, SkypeResponseCallback responseCallback) - : proto(proto), responseCallback(responseCallback) { } + : proto(proto), responseCallback(responseCallback), arg(NULL), hasArg(false) {} + + SkypeResponseDelegate(CSkypeProto *proto, SkypeResponseWithArgCallback responseCallback, void *arg) + : proto(proto), responseWithArgCallback(responseCallback), arg(arg), hasArg(true) { } void Invoke(const NETLIBHTTPREQUEST *response) { - (proto->*(responseCallback))(response); + if (hasArg) + (proto->*(responseWithArgCallback))(response, arg); + else + (proto->*(responseCallback))(response); } }; @@ -21,22 +31,20 @@ static void SkypeHttpResponse(const NETLIBHTTPREQUEST *response, void *arg) ((SkypeResponseDelegate*)arg)->Invoke(response); } -void CSkypeProto::PushRequest(HttpRequest *request, SkypeResponseCallback response) +void CSkypeProto::PushRequest(HttpRequest *request) { - if (!cookies.empty()) - { - CMStringA allCookies; - for (std::map::iterator cookie = cookies.begin(); cookie != cookies.end(); ++cookie) - allCookies.AppendFormat("%s=%s; ", cookie->first.c_str(), cookie->second.c_str()); - request->Headers << CHAR_VALUE("Set-Cookie", allCookies); - } - - if (response == NULL) - { - requestQueue->Push(request); - return; - } + requestQueue->Push(request); + return; +} +void CSkypeProto::PushRequest(HttpRequest *request, SkypeResponseCallback response) +{ SkypeResponseDelegate *delegate = new SkypeResponseDelegate(this, response); requestQueue->Push(request, SkypeHttpResponse, delegate); +} + +void CSkypeProto::PushRequest(HttpRequest *request, SkypeResponseWithArgCallback response, void *arg) +{ + SkypeResponseDelegate *delegate = new SkypeResponseDelegate(this, response, arg); + requestQueue->Push(request, SkypeHttpResponse, delegate); } \ No newline at end of file -- cgit v1.2.3