summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_request.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/SkypeWeb/src/skype_request.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_request.cpp42
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