This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
curl-bridge.h
98 lines (76 loc) · 2.18 KB
/
curl-bridge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* curl-bridge.h: curl bridge
*
* Contact:
* Moonlight List (moonlight-list@lists.ximian.com)
*
* Copyright 2010 Novell, Inc. (http://www.novell.com)
*
* See the LICENSE file included with the distribution for details.
*
*/
#ifndef __CURL_BRIDGE__
#define __CURL_BRIDGE__
class CallData;
class CurlBrowserBridge;
#include "moonbuild.h"
#include "browser-bridge.h"
#include "list.h"
#include "ptr.h"
#include "timemanager.h"
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <pthread.h>
typedef void ( * CallHandler ) ( CallData * object ) ;
class Closure : public EventObject {
public:
Closure (CurlBrowserBridge *value)
: bridge (value)
{
}
virtual ~Closure () {}
CurlBrowserBridge* bridge;
};
class CurlBrowserBridge : public BrowserBridge {
public:
CURL* sharecurl;
CURL* multicurl;
DOPtr<Closure> closure;
int running;
bool quit;
// available handles pool
Queue* pool;
Queue* handles;
GList *calls;
CurlBrowserBridge ();
~CurlBrowserBridge ();
virtual DownloaderRequest* CreateDownloaderRequest (const char *method, const char *uri, bool disable_cache);
virtual void Shutdown ();
CURL* RequestHandle ();
void ReleaseHandle (CURL* handle);
void OpenHandle (DownloaderRequest* res, CURL* handle);
void CloseHandle (DownloaderRequest* res, CURL* handle);
void GetData ();
void AddCallback (CallHandler func, DownloaderResponse *res, char *buffer, size_t size, const char* name, const char* val);
bool IsDataThread ();
};
class CallData {
public:
CallData (CurlBrowserBridge *bridge, CallHandler func, DownloaderResponse *res, char *buffer, size_t size, const char* name, const char* val)
: bridge(bridge), func(func), res (res), buffer(buffer), size(size), name(name), val(val)
{}
CallData (CurlBrowserBridge *bridge, CallHandler func, DownloaderRequest *req) :
bridge(bridge), func(func), req(req), buffer(NULL), size(0), name(NULL), val(NULL) {}
~CallData ();
CurlBrowserBridge *bridge;
CallHandler func;
DownloaderResponse *res;
DownloaderRequest *req;
char *buffer;
size_t size;
const char *name;
const char *val;
};
#endif // CURL_BRIDGE