summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/http_request.h
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-02-19 13:33:46 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-02-19 13:33:46 +0000
commit36df84a13018c6c26e7cd1bb8e093dc54393aed7 (patch)
treebe220c6dd21741370af430e066486143a4cc747f /plugins/Dropbox/src/http_request.h
parenta8934644810474ad6f367759ee0ea14da12909de (diff)
folder rename
git-svn-id: http://svn.miranda-ng.org/main/trunk@8179 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/http_request.h')
-rw-r--r--plugins/Dropbox/src/http_request.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/Dropbox/src/http_request.h b/plugins/Dropbox/src/http_request.h
new file mode 100644
index 0000000000..b17ef16b58
--- /dev/null
+++ b/plugins/Dropbox/src/http_request.h
@@ -0,0 +1,92 @@
+#ifndef _HTTP_REQUEST_H_
+#define _HTTP_REQUEST_H_
+
+#include "common.h"
+
+enum HttpStatus
+{
+ OK = 200
+};
+
+class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
+{
+public:
+ HttpRequest(HANDLE hNetlibUser, int requestType, LPCSTR url)
+ {
+ cbSize = sizeof(NETLIBHTTPREQUEST);
+ flags = NLHRF_HTTP11;
+ this->requestType = requestType;
+
+ m_hNetlibUser = hNetlibUser;
+ m_szUrl = mir_strdup(url);
+ }
+
+ ~HttpRequest()
+ {
+ for (int i=0; i < headersCount; i++)
+ {
+ mir_free(headers[i].szName);
+ mir_free(headers[i].szValue);
+ }
+ mir_free(headers);
+ mir_free(pData);
+ }
+
+
+ void AddHeader(LPCSTR szName, LPCSTR szValue)
+ {
+ headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount+1));
+ headers[headersCount].szName = mir_strdup(szName);
+ headers[headersCount].szValue = mir_strdup(szValue);
+ headersCount++;
+ }
+
+ void AddParameter(LPCSTR szName, LPCSTR szValue)
+ {
+ if(m_szUrl.Find('?') == -1)
+ m_szUrl.AppendFormat("?%s=%s", szName, szValue);
+ else
+ m_szUrl.AppendFormat("&%s=%s", szName, szValue);
+ }
+
+ void AddParameter(LPCSTR szName, int value)
+ {
+ if(m_szUrl.Find('?') == -1)
+ m_szUrl.AppendFormat("?%s=%i", szName, value);
+ else
+ m_szUrl.AppendFormat("&%s=%i", szName, value);
+ }
+
+ NETLIBHTTPREQUEST *Send()
+ {
+ szUrl = m_szUrl.GetBuffer();
+ return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)this);
+ }
+
+ //void SendAsync(typename CBaseProto<T>::AsyncHttpRequest callback)
+ //{
+ // szUrl = m_szUrl.GetBuffer();
+ // AsyncParam param = { this, proto, callback };
+ // /*HANDLE hThread = */mir_forkthread(SendAsync, &param);
+ // //WaitForSingleObject(hThread, INFINITE);
+ //}
+
+private:
+
+ CMStringA m_szUrl;
+ HANDLE m_hNetlibUser;
+
+ /*static void SendAsync(void *arg)
+ {
+ AsyncParam *param = (AsyncParam*)arg;
+ NETLIBHTTPREQUEST* response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)param->m_proto->m_hNetlibUser, (LPARAM)param->m_request);
+
+ CBaseProto<T> *proto = param->m_proto;
+ AsyncRequestCallback callback = param->m_callback;
+ proto->*callback(response);
+
+ delete response;
+ }*/
+};
+
+#endif //_HTTP_REQUEST_H_ \ No newline at end of file