diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-03-18 20:28:01 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-03-18 20:28:01 +0000 |
commit | 3364fd6b8bdc21692805302a4333e49b44590b2c (patch) | |
tree | 578dd1a7a5db05311add225a78c65cc2a7b03f6d /protocols/SkypeWeb/src/skype_request.cpp | |
parent | cd4a3aab6a6406bcaca07734848e57477db4485d (diff) |
SkypeWeb:
- contact list loading
- refactoring
git-svn-id: http://svn.miranda-ng.org/main/trunk@12431 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_request.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_request.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/skype_request.cpp b/protocols/SkypeWeb/src/skype_request.cpp new file mode 100644 index 0000000000..1cd5d654f0 --- /dev/null +++ b/protocols/SkypeWeb/src/skype_request.cpp @@ -0,0 +1,42 @@ +#include "common.h"
+
+class SkypeResponseDelegate
+{
+private:
+ CSkypeProto *proto;
+ SkypeResponseCallback responseCallback;
+
+public:
+ SkypeResponseDelegate(CSkypeProto *proto, SkypeResponseCallback responseCallback)
+ : proto(proto), responseCallback(responseCallback) { }
+
+ void Invoke(const NETLIBHTTPREQUEST *response)
+ {
+ (proto->*(responseCallback))(response);
+ }
+};
+
+static void SkypeHttpResponse(const NETLIBHTTPREQUEST *response, void *arg)
+{
+ ((SkypeResponseDelegate*)arg)->Invoke(response);
+}
+
+void CSkypeProto::PushRequest(HttpRequest *request, SkypeResponseCallback response)
+{
+ if (!cookies.empty())
+ {
+ CMStringA allCookies;
+ for (std::map<std::string, std::string>::iterator cookie = cookies.begin(); cookie != cookies.end(); ++cookie)
+ allCookies.AppendFormat("%s=%s; ", cookie->first.c_str(), cookie->second.c_str());
+ request->SetCookie(allCookies);
+ }
+
+ if (response == NULL)
+ {
+ requestQueue->Push(request);
+ return;
+ }
+
+ SkypeResponseDelegate *delegate = new SkypeResponseDelegate(this, response);
+ requestQueue->Push(request, SkypeHttpResponse, delegate);
+}
\ No newline at end of file |