summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-12 21:27:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-12 21:27:03 +0300
commit3cb3883908e3168e5f955be3143771721614307a (patch)
treee160797994b28577e5fa71a4c790e1670e6f4035
parent6461f17159c83bfaeba1ecbd124ab53551f3e22d (diff)
Netlib_FreeHttpRequest() instead of MS_NETLIB_FREEHTTPREQUESTSTRUCT
-rw-r--r--bin10/lib/mir_app.libbin91876 -> 92634 bytes
-rw-r--r--bin10/lib/mir_app64.libbin87588 -> 88296 bytes
-rw-r--r--bin12/lib/mir_app.libbin91876 -> 92634 bytes
-rw-r--r--bin12/lib/mir_app64.libbin87588 -> 88296 bytes
-rw-r--r--bin14/lib/mir_app.libbin91876 -> 92634 bytes
-rw-r--r--bin14/lib/mir_app64.libbin87588 -> 88296 bytes
-rw-r--r--include/delphi/m_netlib.inc58
-rw-r--r--include/m_jabber.h2
-rw-r--r--include/m_netlib.h35
-rw-r--r--plugins/CrashDumper/src/upload.cpp6
-rw-r--r--plugins/Dropbox/src/http_request.h4
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp4
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp8
-rw-r--r--plugins/Non-IM Contact/src/http.cpp4
-rw-r--r--plugins/PackUpdater/Src/Utils.cpp7
-rw-r--r--plugins/PasteIt/src/PasteToWeb.cpp4
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp10
-rw-r--r--plugins/Quotes/src/HTTPSession.cpp11
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp6
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp6
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp6
-rw-r--r--plugins/SmileyAdd/src/download.cpp4
-rw-r--r--plugins/Utils.pas/mirutils.pas26
-rw-r--r--plugins/Watrack/myshows/i_cookies.inc4
-rw-r--r--plugins/Weather/src/weather_http.cpp4
-rw-r--r--plugins/WebView/src/webview_getdata.cpp4
-rwxr-xr-xprotocols/AimOscar/src/connection.cpp4
-rw-r--r--protocols/Discord/src/connection.cpp4
-rw-r--r--protocols/FacebookRM/src/captcha.cpp2
-rw-r--r--protocols/FacebookRM/src/communication.cpp7
-rw-r--r--protocols/FacebookRM/src/http_request.h2
-rw-r--r--protocols/GTalkExt/src/inbox.cpp12
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp31
-rw-r--r--protocols/Gadu-Gadu/src/oauth.cpp16
-rw-r--r--protocols/JabberG/src/jabber_api.cpp2
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp8
-rw-r--r--protocols/JabberG/src/jabber_proto.h3
-rw-r--r--protocols/JabberG/src/jabber_util.cpp4
-rw-r--r--protocols/MRA/src/MraAvatars.cpp4
-rw-r--r--protocols/MSN/src/msn_auth.cpp27
-rw-r--r--protocols/MSN/src/msn_avatar.cpp6
-rw-r--r--protocols/MSN/src/msn_commands.cpp4
-rw-r--r--protocols/MSN/src/msn_proto.cpp36
-rw-r--r--protocols/MSN/src/msn_skypeab.cpp32
-rw-r--r--protocols/MSN/src/msn_soapab.cpp7
-rw-r--r--protocols/MSN/src/msn_ssl.cpp9
-rw-r--r--protocols/MinecraftDynmap/src/communication.cpp4
-rw-r--r--protocols/Omegle/src/client.h4
-rw-r--r--protocols/Omegle/src/communication.cpp4
-rw-r--r--protocols/SkypeWeb/src/http_request.h2
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp2
-rw-r--r--protocols/Steam/src/http_request.h4
-rw-r--r--protocols/Tlen/src/tlen.cpp4
-rw-r--r--protocols/Tlen/src/tlen_avatar.cpp12
-rw-r--r--protocols/Tox/src/http_request.h4
-rw-r--r--protocols/Tox/src/tox_search.cpp4
-rw-r--r--protocols/Twitter/src/proto.h2
-rw-r--r--protocols/Twitter/src/utility.cpp13
-rw-r--r--protocols/Twitter/src/utility.h6
-rw-r--r--protocols/VKontakte/src/vk_captcha.cpp2
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp6
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp4
-rw-r--r--protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp2
-rw-r--r--protocols/WhatsApp/src/proto.cpp2
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/netlib.cpp3
-rw-r--r--src/mir_app/src/netlib.h25
-rw-r--r--src/mir_app/src/netlibautoproxy.cpp11
-rw-r--r--src/mir_app/src/netlibhttp.cpp71
-rw-r--r--src/mir_app/src/netlibhttpproxy.cpp18
-rw-r--r--src/mir_app/src/netlibopenconn.cpp6
72 files changed, 287 insertions, 365 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib
index 34646c634b..83b463beba 100644
--- a/bin10/lib/mir_app.lib
+++ b/bin10/lib/mir_app.lib
Binary files differ
diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib
index 294adeb216..9adefe94ee 100644
--- a/bin10/lib/mir_app64.lib
+++ b/bin10/lib/mir_app64.lib
Binary files differ
diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib
index 34646c634b..83b463beba 100644
--- a/bin12/lib/mir_app.lib
+++ b/bin12/lib/mir_app.lib
Binary files differ
diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib
index 294adeb216..9adefe94ee 100644
--- a/bin12/lib/mir_app64.lib
+++ b/bin12/lib/mir_app64.lib
Binary files differ
diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib
index 34646c634b..83b463beba 100644
--- a/bin14/lib/mir_app.lib
+++ b/bin14/lib/mir_app.lib
Binary files differ
diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib
index 294adeb216..9adefe94ee 100644
--- a/bin14/lib/mir_app64.lib
+++ b/bin14/lib/mir_app64.lib
Binary files differ
diff --git a/include/delphi/m_netlib.inc b/include/delphi/m_netlib.inc
index 7772113a94..3bfe107306 100644
--- a/include/delphi/m_netlib.inc
+++ b/include/delphi/m_netlib.inc
@@ -466,59 +466,7 @@ type
szIp :array[0..0,0..63] of AnsiChar;
end;
-const
-{
- Get connection Information
- wParam=(WPARAM)IP filter 1 - return global only IPv6 address, 0 all IPs
- Returns (INT_PTR)(NETLIBIPLIST*) numeric IP address address array
- the last element of the array is all 0s, 0 if not successful
-}
- MS_NETLIB_GETMYIP:PAnsiChar = 'Netlib/GetMyIP';
-
{
- wParam : HANDLE
- lParam : Pointer to a initialised TNETLIBHTTPREQUEST structure
- Affect : Send an HTTP request over a connection, see notes
- Returns: The number of bytes on success, SOCKET_ERROR on failure
- Notes : HANDLE must of been returned by MS_NETLIB_OPENCONNECTION,,
- If you use NLHRF_SMARTAUTHHEADER and NTLM auth is in use then
- full NTLM auth transcation occurs, comprising sending the
- domain, getting the challenge, sending the response.
- NETLIBHTTPREQUEST.resultCode and NETLIBHTTPREQUEST.szResultDescr are
- ignored by this service.
- Errors : ERROR_INVALID_PARAMETER, MS_NETLIB_SEND (return codes)
- }
- MS_NETLIB_SENDHTTPREQUEST:PAnsiChar = 'Netlib/SendHttpRequest';
-
- {
- wParam : HANDLE
- lParam : 0
- Affect : Receive HTTP headers, see notes
- Returns: A pointer to a TNETLIBHTTPREQUEST structure on success, NULL(0) on failure
- Notes : The returned pointer must be freed after it's done with
- use MS_NETLIB_FREEHTTPREQUESTSTRUCT.
- -
- HANDLE must be returned by MS_NETLIB_OPENCONNECTION
- -
- Return^.pData=NIL and Return^.dataLength=0 always
- -
- The returned data should be retrieved using MS_NETLIB_RECV once
- the headers have been parsed.
- If headers haven't finished within 60 seconds the function returns
- NULL(0) and ERROR_TIMEOUT
- Errors : ERROR_INVALID_PARAMETER, any MS_NETLIB_RECV or select()
- ERROR_HANDLE_EOF (connection closed bfore headers complete)
- ERROR_TIMEOUT (headers still not complete after 60 seconds)
- ERROR_BAD_FORMAT (invalid character or line ending in headers, or first line is blank)
- ERROR_BUFFER_OVERFLOW (each header line must be less than 4096 chars long)
- ERROR_INVALID_DATA (first header line is malformed ("http/[01].[0-9] [0-9]+ .*", or no colon in subsequent line)
-
- }
- MS_NETLIB_RECVHTTPHEADERS:PAnsiChar = 'Netlib/RecvHttpHeaders';
-
- {
- wParam : 0
- lParam : Pointer returned by MS_NETLIB_RECVHTTPHEADERS to free
Affect : Free the memory used by a TNETLIBHTTPREQUEST structure, see notes
Returns: [non zero] on success, NULL(0) on failure
Notes : This service should only be used with memory pointers returned
@@ -526,7 +474,8 @@ const
Errors : ERROR_INVALID_PARAMETER
}
- MS_NETLIB_FREEHTTPREQUESTSTRUCT:PAnsiChar = 'Netlib/FreeHttpRequestStruct';
+
+function Netlib_FreeHttpRequest(param:PNETLIBHTTPREQUEST) : bytebool; stdcall; external AppDll;
{
wParam : HANDLE
@@ -564,7 +513,8 @@ const
Errors : ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY
Errors returned by the aforementioned internally used functions
}
- MS_NETLIB_HTTPTRANSACTION:PAnsiChar = 'Netlib/HttpTransaction';
+
+function Netlib_HttpTransaction(nlu:THANDLE; param:PNETLIBHTTPREQUEST) : PNETLIBHTTPREQUEST; stdcall; external AppDll;
{
Affect : Send data over an open connection see notes
diff --git a/include/m_jabber.h b/include/m_jabber.h
index 01d0c71d5e..f6b0b8878d 100644
--- a/include/m_jabber.h
+++ b/include/m_jabber.h
@@ -157,7 +157,7 @@ struct IJabberInterface
virtual LPTSTR STDMETHODCALLTYPE GetResourceFeatures(LPCTSTR jid) = 0;
// Returns the connection handle
- virtual HANDLE STDMETHODCALLTYPE GetHandle(void) = 0;
+ virtual HNETLIBUSER STDMETHODCALLTYPE GetHandle(void) = 0;
};
/*
diff --git a/include/m_netlib.h b/include/m_netlib.h
index a5df2a3f91..1ab848528c 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -498,12 +498,10 @@ struct NETLIBHTTPREQUEST
#define MS_NETLIB_SENDHTTPREQUEST "Netlib/SendHttpRequest"
/////////////////////////////////////////////////////////////////////////////////////////
-// Receive HTTP headers
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = 0
-// Returns a pointer to a NETLIBHTTPREQUEST structure on success, NULL on
-// failure.
-// Call MS_NETLIB_FREEHTTPREQUESTSTRUCT to free this.
+// Receives HTTP headers
+//
+// Returns a pointer to a NETLIBHTTPREQUEST structure on success, NULL on failure.
+// Call Netlib_FreeHttpRequest() to free this.
// hConnection must have been returned by MS_NETLIB_OPENCONNECTION
// nlhr->pData = NULL and nlhr->dataLength = 0 always. The requested data should
// be retrieved using MS_NETLIB_RECV once the header has been parsed.
@@ -516,22 +514,21 @@ struct NETLIBHTTPREQUEST
// ERROR_BUFFER_OVERFLOW (each header line must be less than 4096 chars long)
// ERROR_INVALID_DATA (first header line is malformed ("http/[01].[0-9] [0-9]+ .*", or no colon in subsequent line)
-#define MS_NETLIB_RECVHTTPHEADERS "Netlib/RecvHttpHeaders"
+EXTERN_C MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HANDLE hConnection, int flags = 0);
/////////////////////////////////////////////////////////////////////////////////////////
// Free the memory used by a NETLIBHTTPREQUEST structure
-// wParam = 0
-// lParam = (LPARAM)(NETLIBHTTPREQUEST*)pnlhr
-// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
+//
+// Returns true on success, false on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
// This should only be called on structures returned by
// MS_NETLIB_RECVHTTPHEADERS or MS_NETLIB_HTTPTRANSACTION. Calling it on an
// arbitrary structure will have disastrous results.
// Errors: ERROR_INVALID_PARAMETER
-#define MS_NETLIB_FREEHTTPREQUESTSTRUCT "Netlib/FreeHttpRequestStruct"
+EXTERN_C MIR_APP_DLL(bool) Netlib_FreeHttpRequest(NETLIBHTTPREQUEST*);
/////////////////////////////////////////////////////////////////////////////////////////
-// smart pointer for NETLIBHTTPREQUEST via a call of MS_NETLIB_FREEHTTPREQUESTSTRUCT
+// smart pointer for NETLIBHTTPREQUEST via a call of Netlib_FreeHttpRequest()
#ifdef __cplusplus
class NLHR_PTR
@@ -550,7 +547,7 @@ public:
__inline NETLIBHTTPREQUEST* operator=(NETLIBHTTPREQUEST *p)
{
if (_p)
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)(NETLIBHTTPREQUEST*)_p);
+ Netlib_FreeHttpRequest(_p);
_p = p;
return _p;
}
@@ -558,18 +555,16 @@ public:
__inline NETLIBHTTPREQUEST* operator->() const { return _p; }
__inline ~NLHR_PTR()
{
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)(NETLIBHTTPREQUEST*)_p);
+ Netlib_FreeHttpRequest(_p);
}
};
#endif
/////////////////////////////////////////////////////////////////////////////////////////
// Do an entire HTTP transaction
-// wParam = (WPARAM)(HANDLE)hUser
-// lParam = (LPARAM)(NETLIBHTTPREQUEST*)&nlhr
-// Returns a pointer to another NETLIBHTTPREQUEST structure on success, NULL on
-// failure.
-// Call MS_NETLIB_FREEHTTPREQUESTSTRUCT to free this.
+//
+// Returns a pointer to another NETLIBHTTPREQUEST structure on success, NULL on failure.
+// Call Netlib_FreeHttpRequest() to free this.
// hUser must have been returned by MS_NETLIB_REGISTERUSER
// nlhr.szUrl should be a full HTTP URL. If it does not start with http:// , that
// will be assumed (but it's best not to use this fact, for reasons of
@@ -593,7 +588,7 @@ public:
// Errors: ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY, anything from the above
// list of functions
-#define MS_NETLIB_HTTPTRANSACTION "Netlib/HttpTransaction"
+EXTERN_C MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_HttpTransaction(HNETLIBUSER hNlu, NETLIBHTTPREQUEST *pRequest);
/////////////////////////////////////////////////////////////////////////////////////////
// Send data over a connection
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp
index dc95363449..26359b0b74 100644
--- a/plugins/CrashDumper/src/upload.cpp
+++ b/plugins/CrashDumper/src/upload.cpp
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-HANDLE hNetlibUser;
+HNETLIBUSER hNetlibUser;
static void arrayToHex(BYTE* data, size_t datasz, char* res)
{
@@ -122,7 +122,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq)
while (result == 0xBADBAD) {
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlhrReply) {
int i;
@@ -189,7 +189,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq)
ShowMessage(0, TranslateT("Cannot upload Version Info. Host unreachable."));
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
mir_free(szRedirUrl);
diff --git a/plugins/Dropbox/src/http_request.h b/plugins/Dropbox/src/http_request.h
index 3c11f99b17..9d11ee4742 100644
--- a/plugins/Dropbox/src/http_request.h
+++ b/plugins/Dropbox/src/http_request.h
@@ -155,11 +155,11 @@ public:
mir_free(pData);
}
- NETLIBHTTPREQUEST* Send(HANDLE hNetlibConnection)
+ NETLIBHTTPREQUEST* Send(HNETLIBUSER hNetlibConnection)
{
m_szUrl.Replace('\\', '/');
szUrl = m_szUrl.GetBuffer();
- return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibConnection, (LPARAM)this);
+ return Netlib_HttpTransaction(hNetlibConnection, this);
}
};
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index f9d8c2c126..3335b489a2 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -158,7 +158,7 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern)
IN_ADDR externIP;
externIP.s_addr = 0;
- NETLIBHTTPREQUEST *nlreply = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)& nlhr);
+ NETLIBHTTPREQUEST *nlreply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlreply) {
if (nlreply->resultCode >= 200 && nlreply->resultCode < 300) {
nlreply->pData[nlreply->dataLength] = 0;// make sure its null terminated
@@ -178,7 +178,7 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern)
if ((externIP.s_addr = inet_addr(pszIp)) == INADDR_NONE)
externIP.s_addr = 0;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlreply);
+ Netlib_FreeHttpRequest(nlreply);
}
::SetCursor(hPrevCursor);
return ntohl(externIP.s_addr);
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index 0f16b5664e..d2d02635dc 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -81,7 +81,7 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, HWND hwndDlg
}
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlhrReply) {
// if the recieved code is 200 OK
if (nlhrReply->resultCode == 200 && nlhrReply->dataLength > 0) {
@@ -101,7 +101,7 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, HWND hwndDlg
}
else Netlib_LogfW(hNetlibUser, L"Code %d: Failed getting feed data %s.", nlhrReply->resultCode, tszUrl);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else Netlib_LogfW(hNetlibUser, L"Failed getting feed data %s, no response.", tszUrl);
@@ -305,7 +305,7 @@ bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
nlhr.headers[3].szValue = "no-cache";
bool ret = false;
- NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (pReply) {
if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
char *date = NULL, *size = NULL;
@@ -359,7 +359,7 @@ bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
CloseHandle(hFile);
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
+ Netlib_FreeHttpRequest(pReply);
}
mir_free(szUrl);
diff --git a/plugins/Non-IM Contact/src/http.cpp b/plugins/Non-IM Contact/src/http.cpp
index e63521df09..38eb3c510d 100644
--- a/plugins/Non-IM Contact/src/http.cpp
+++ b/plugins/Non-IM Contact/src/http.cpp
@@ -48,7 +48,7 @@ int InternetDownloadFile(char *szUrl)
nlhr.headers[nlhr.headersCount - 1].szValue = NETLIB_USER_AGENT;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlhrReply) {
// return error code if the recieved code is neither 200 OK or 302 Moved
if (nlhrReply->resultCode != 200 && nlhrReply->resultCode != 302)
@@ -81,7 +81,7 @@ int InternetDownloadFile(char *szUrl)
// make a copy of the retrieved data, then free the memory of the http reply
szInfo = szData;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
// the recieved data is empty, data was not recieved, so return an error code of 1
if (!mir_strcmp(szInfo, "")) return 1;
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp
index 84827faa0b..9396d59be2 100644
--- a/plugins/PackUpdater/Src/Utils.cpp
+++ b/plugins/PackUpdater/Src/Utils.cpp
@@ -28,7 +28,8 @@ INT Period;
wchar_t tszDialogMsg[2048] = { 0 };
FILEINFO* pFileInfo = NULL;
FILEURL* pFileUrl = NULL;
-HANDLE hCheckThread = NULL, hNetlibUser = NULL;
+HANDLE hCheckThread = NULL;
+HNETLIBUSER hNetlibUser = NULL;
MYOPTIONS MyOptions = { 0 };
aPopups PopupsList[POPUPS];
LPCTSTR Title = { 0 }, Text = { 0 };
@@ -125,7 +126,7 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
nlhr.headers[3].szValue = "no-cache";
bool ret = false;
- NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (pReply) {
if (200 == pReply->resultCode && pReply->dataLength > 0) {
@@ -136,7 +137,7 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
if (hFile)
CloseHandle(hFile);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
+ Netlib_FreeHttpRequest(pReply);
}
mir_free(szUrl);
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp
index ec6cdd9878..1307a2fabd 100644
--- a/plugins/PasteIt/src/PasteToWeb.cpp
+++ b/plugins/PasteIt/src/PasteToWeb.cpp
@@ -542,7 +542,7 @@ wchar_t* PasteToWeb::SendToWeb(char* url, std::map<std::string, std::string>& he
}
nlhr.headersCount = nHeaders;
- NETLIBHTTPREQUEST* nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST* nlhrReply = Netlib_HttpTransaction(g_hNetlibUser, &nlhr);
if (nlhrReply != NULL)
{
if (nlhrReply->resultCode == 200)
@@ -557,7 +557,7 @@ wchar_t* PasteToWeb::SendToWeb(char* url, std::map<std::string, std::string>& he
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
delete[] httpHeaders;
for (std::list<char*>::iterator it = mallBuf.begin(); it != mallBuf.end(); ++it)
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index 7e2555d86e..186cf9dc34 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -259,7 +259,7 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
bool ret = false;
for (int i = 0; !ret && i < MAX_RETRIES; i++) {
Netlib_LogfW(hNetlibUser,L"Downloading file %s to %s (attempt %d)",pFileURL->tszDownloadURL,pFileURL->tszDiskPath, i+1);
- NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (pReply) {
nlc = pReply->nlc;
if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
@@ -270,7 +270,7 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
if (crc != pFileURL->CRCsum) {
// crc check failed, try again
Netlib_LogfW(hNetlibUser,L"crc check failed for file %s",pFileURL->tszDiskPath);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
+ Netlib_FreeHttpRequest(pReply);
continue;
}
}
@@ -296,9 +296,9 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
}
ret = true;
}
- else
- Netlib_LogfW(hNetlibUser,L"Downloading file %s failed with error %d",pFileURL->tszDownloadURL,pReply->resultCode);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
+ else Netlib_LogfW(hNetlibUser,L"Downloading file %s failed with error %d",pFileURL->tszDownloadURL,pReply->resultCode);
+
+ Netlib_FreeHttpRequest(pReply);
}
else {
Netlib_LogfW(hNetlibUser,L"Downloading file %s failed, host is propably temporary down.",pFileURL->tszDownloadURL);
diff --git a/plugins/Quotes/src/HTTPSession.cpp b/plugins/Quotes/src/HTTPSession.cpp
index ae0679b758..345b3d0cec 100644
--- a/plugins/Quotes/src/HTTPSession.cpp
+++ b/plugins/Quotes/src/HTTPSession.cpp
@@ -36,7 +36,7 @@ public:
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
nlu.szSettingsModule = QUOTES_PROTOCOL_NAME;
nlu.ptszDescriptiveName = TranslateT("Quotes HTTP connections");
- g_hNetLib = reinterpret_cast<HANDLE>(Netlib_RegisterUser(&nlu));
+ g_hNetLib = Netlib_RegisterUser(&nlu);
return (NULL != g_hNetLib);
}
@@ -83,8 +83,7 @@ public:
NETLIBHTTPREQUEST* pReply = NULL;
{
mir_cslock lck(m_mx);
- pReply = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
- reinterpret_cast<WPARAM>(g_hNetLib), reinterpret_cast<LPARAM>(&nlhr)));
+ pReply = Netlib_HttpTransaction(g_hNetLib, &nlhr);
}
if (pReply) {
@@ -109,7 +108,7 @@ public:
bResult = true;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, reinterpret_cast<LPARAM>(pReply));
+ Netlib_FreeHttpRequest(pReply);
}
mir_free(nlhr.headers);
@@ -118,13 +117,13 @@ public:
}
private:
- static HANDLE g_hNetLib;
+ static HNETLIBUSER g_hNetLib;
typedef std::vector<char> TBuffer;
mutable TBuffer m_aURL;
mutable mir_cs m_mx;
};
-HANDLE CImplMI::g_hNetLib = NULL;
+HNETLIBUSER CImplMI::g_hNetLib = NULL;
CHTTPSession::CHTTPSession()
: m_pImpl(new CImplMI)
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
index bc52a13db7..143606a096 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
@@ -74,7 +74,7 @@ int CSendHost_ImageShack::Send()
void CSendHost_ImageShack::SendThread()
{
/// send DATA and wait for m_nlreply
- NETLIBHTTPREQUEST* reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&m_nlhr);
+ NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &m_nlhr);
HTTPFormDestroy(&m_nlhr);
if (reply) {
if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->dataLength) {
@@ -95,7 +95,7 @@ void CSendHost_ImageShack::SendThread()
}
else mir_freeAndNil(m_URLthumb);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
svcSendMsgExit(url); return;
}
else {/// check error mess from server
@@ -112,7 +112,7 @@ void CSendHost_ImageShack::SendThread()
}
else Error(SS_ERR_RESPONSE, m_pszSendTyp, reply->resultCode);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
}
else Error(SS_ERR_NORESPONSE, m_pszSendTyp, m_nlhr.resultCode);
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
index e87cc78e3f..b9738687e3 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
@@ -60,7 +60,7 @@ void CSendHost_Imgur::SendThread(void* obj)
{
CSendHost_Imgur* self = (CSendHost_Imgur*)obj;
/// send DATA and wait for m_nlreply
- NETLIBHTTPREQUEST* reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&self->m_nlhr);
+ NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr);
self->HTTPFormDestroy(&self->m_nlhr);
if (reply) {
if (reply->dataLength) {
@@ -79,14 +79,14 @@ void CSendHost_Imgur::SendThread(void* obj)
self->m_URLthumb[thumblen] = 'm'; // 320x320, see http://api.imgur.com/models/image
mir_strcpy(self->m_URLthumb + thumblen + 1, self->m_URL + thumblen);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
self->svcSendMsgExit(self->m_URL); return;
}
else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, GetJSONInteger(reply->pData, reply->dataLength, "status", 0));
}
else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, reply->resultCode);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
}
else self->Error(SS_ERR_NORESPONSE, self->m_pszSendTyp, self->m_nlhr.resultCode);
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
index d354b0aaa1..eeaf4a9b89 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
@@ -66,7 +66,7 @@ void CSendHost_UploadPie::SendThread(void* obj)
{
CSendHost_UploadPie* self = (CSendHost_UploadPie*)obj;
/// send DATA and wait for m_nlreply
- NETLIBHTTPREQUEST* reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&self->m_nlhr);
+ NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr);
self->HTTPFormDestroy(&self->m_nlhr);
if (reply) {
if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->dataLength) {
@@ -88,7 +88,7 @@ void CSendHost_UploadPie::SendThread(void* obj)
if (url) {
mir_free(self->m_URL), self->m_URL = mir_strdup(url);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
self->svcSendMsgExit(url); return;
}
else {/// check error mess from server
@@ -102,7 +102,7 @@ void CSendHost_UploadPie::SendThread(void* obj)
}
else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, reply->resultCode);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
}
else self->Error(SS_ERR_NORESPONSE, self->m_pszSendTyp, self->m_nlhr.resultCode);
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp
index dd5e1e05a2..66d938a506 100644
--- a/plugins/SmileyAdd/src/download.cpp
+++ b/plugins/SmileyAdd/src/download.cpp
@@ -62,7 +62,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HANDLE &hHttpDwnl)
while (result == 0xBADBAD) {
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlhrReply) {
hHttpDwnl = nlhrReply->nlc;
// if the recieved code is 200 OK
@@ -114,7 +114,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HANDLE &hHttpDwnl)
result = 1;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
mir_free(szRedirUrl);
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas
index 5b3e87a33b..46cc56aa94 100644
--- a/plugins/Utils.pas/mirutils.pas
+++ b/plugins/Utils.pas/mirutils.pas
@@ -441,8 +441,7 @@ begin
else
hTmpNetLib:=hNetLib;
- resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hTmpNetLib,lparam(@req)));
-
+ resp:=Netlib_HttpTransaction(hTmpNetLib,@req);
if resp<>nil then
begin
if resp^.resultCode=200 then
@@ -453,7 +452,7 @@ begin
begin
result:=PAnsiChar(int_ptr(resp^.resultCode and $0FFF));
end;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
+ Netlib_FreeHttpRequest(resp);
end;
if (hNetLib=0) and (nlu.flags<>0) then
@@ -494,8 +493,7 @@ begin
hNetLib:=Netlib_RegisterUser(@nlu);
end;
- resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hNetLib,lparam(@req)));
-
+ resp:=Netlib_HttpTransaction(hNetLib,@req);
if resp<>nil then
begin
if resp^.resultCode=200 then
@@ -513,25 +511,14 @@ begin
// get new location
for i:=0 to resp^.headersCount-1 do
begin
- //MessageBox(0,resp^.headers[i].szValue, resp^.headers[i].szName,MB_OK);
if StrCmp(resp^.headers^[i].szName,'Location')=0 then
begin
result:=GetFile(resp^.headers^[i].szValue,save_file,hNetLib,recurse_count+1);
break;
end
end;
- end
- else
- begin
-{
- _stprintf(buff, TranslateT("Failed to download \"%s\" - Invalid response, code %d"), plugin_name, resp->resultCode);
-
- ShowError(buff);
- AnsiChar *ts = GetAString(buff);
- NLog(ts);
-}
end;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
+ Netlib_FreeHttpRequest(resp);
if nlu.flags<>0 then
Netlib_CloseHandle(hNetLib);
@@ -620,8 +607,7 @@ begin
nlu.szSettingsModule:='dummy';
hNetLib:=Netlib_RegisterUser(@nlu);
- resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hNetLib,lparam(@req)));
-
+ resp:=Netlib_HttpTransaction(hNetLib,@req);
if resp<>nil then
begin
if resp^.resultCode=200 then
@@ -634,7 +620,7 @@ begin
// if result<>0 then
// DeleteObject(SendMessage(wnd,STM_SETIMAGE,IMAGE_BITMAP,result)); //!!
end;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
+ Netlib_FreeHttpRequest(resp);
end;
Netlib_CloseHandle(hNetLib);
end;
diff --git a/plugins/Watrack/myshows/i_cookies.inc b/plugins/Watrack/myshows/i_cookies.inc
index 62563e7afc..24c90216b9 100644
--- a/plugins/Watrack/myshows/i_cookies.inc
+++ b/plugins/Watrack/myshows/i_cookies.inc
@@ -66,7 +66,7 @@ begin
nlu.szSettingsModule:='dummy';
hTmpNetLib:=Netlib_RegisterUser(@nlu);
- resp:=pointer(CallService(MS_NETLIB_HTTPTRANSACTION,hTmpNetLib,lparam(@req)));
+ resp:=Netlib_HttpTransaction(hTmpNetLib,@req);
if resp<>nil then
begin
if resp^.resultCode=200 then
@@ -82,7 +82,7 @@ begin
begin
result:=pAnsiChar(int_ptr(resp^.resultCode and $0FFF));
end;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,lparam(resp));
+ Netlib_FreeHttpRequest(resp);
end;
Netlib_CloseHandle(hTmpNetLib);
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp
index 5fdf2cb22f..cdc9656082 100644
--- a/plugins/Weather/src/weather_http.cpp
+++ b/plugins/Weather/src/weather_http.cpp
@@ -75,7 +75,7 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
--nlhr.headersCount;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlhrReply == 0) {
// if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
*szData = (wchar_t*)mir_alloc(512);
@@ -144,7 +144,7 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
hNetlibHttp = nlhrReply->nlc;
// make a copy of the retrieved data, then free the memory of the http reply
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return result;
}
diff --git a/plugins/WebView/src/webview_getdata.cpp b/plugins/WebView/src/webview_getdata.cpp
index 75fca2a20f..3e0c656a0a 100644
--- a/plugins/WebView/src/webview_getdata.cpp
+++ b/plugins/WebView/src/webview_getdata.cpp
@@ -134,7 +134,7 @@ void GetData(void *param)
db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Updating..."));
db_set_w(hContact, MODULENAME, "Status", ID_STATUS_DND); // download
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
if (nlhrReply) {
if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) {
db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY);
@@ -169,7 +169,7 @@ void GetData(void *param)
else if (nlhrReply)
DownloadSuccess = 1;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
if (DownloadSuccess)
SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));
diff --git a/protocols/AimOscar/src/connection.cpp b/protocols/AimOscar/src/connection.cpp
index cb4fbf092f..15e88e87af 100755
--- a/protocols/AimOscar/src/connection.cpp
+++ b/protocols/AimOscar/src/connection.cpp
@@ -280,7 +280,7 @@ void CAimProto::aim_connection_clientlogin(void)
req.pData = buf.GetBuffer();
req.dataLength = buf.GetLength();
- NLHR_PTR resp(CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req));
+ NLHR_PTR resp(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (!resp || !resp->dataLength) {
broadcast_status(ID_STATUS_OFFLINE);
return;
@@ -312,7 +312,7 @@ void CAimProto::aim_connection_clientlogin(void)
};
req.headers = headers2;
- resp = CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
}
if (!resp || !resp->dataLength) {
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp
index 969e85fb05..287beca884 100644
--- a/protocols/Discord/src/connection.cpp
+++ b/protocols/Discord/src/connection.cpp
@@ -39,14 +39,14 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
debugLogA("Executing request #%d:\n%s", pReq->m_iReqNum, pReq->szUrl);
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq);
+ NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq);
if (reply != NULL) {
if (pReq->m_pCallback != NULL)
(this->*(pReq->m_pCallback))(reply, pReq);
m_hAPIConnection = reply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
}
else {
debugLogA("Request %d failed", pReq->m_iReqNum);
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp
index 5060d2c913..8e65cf6374 100644
--- a/protocols/FacebookRM/src/captcha.cpp
+++ b/protocols/FacebookRM/src/captcha.cpp
@@ -110,7 +110,7 @@ bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result)
req.szUrl = (char*)captchaUrl.c_str();
req.flags = NLHRF_NODUMPHEADERS;
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)facy.handle_, (LPARAM)&req);
+ NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(facy.handle_, &req);
if (reply == NULL)
return false;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 2e228719f3..c36c064994 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -108,7 +108,7 @@ http::response facebook_client::sendRequest(HttpRequest *request)
resp.code = pnlhr->resultCode;
resp.data = pnlhr->pData ? pnlhr->pData : "";
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pnlhr);
+ Netlib_FreeHttpRequest(pnlhr);
}
else {
parent->debugLogA("!!! No response from server (time-out)");
@@ -1192,8 +1192,7 @@ bool facebook_client::save_url(const std::string &url, const std::wstring &filen
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT | NLHRF_NODUMP;
req.nlc = nlc;
- resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
- reinterpret_cast<WPARAM>(handle_), reinterpret_cast<LPARAM>(&req)));
+ resp = Netlib_HttpTransaction(handle_, &req);
bool ret = false;
@@ -1215,7 +1214,7 @@ bool facebook_client::save_url(const std::string &url, const std::wstring &filen
ret = _waccess(filename.c_str(), 0) == 0;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
else {
nlc = NULL;
diff --git a/protocols/FacebookRM/src/http_request.h b/protocols/FacebookRM/src/http_request.h
index 64750eef39..9e3a578f56 100644
--- a/protocols/FacebookRM/src/http_request.h
+++ b/protocols/FacebookRM/src/http_request.h
@@ -289,7 +289,7 @@ public:
Netlib_Logf(nlu, "Send request to %s", szUrl);
- return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)nlu, (LPARAM)(NETLIBHTTPREQUEST*)this);
+ return Netlib_HttpTransaction(nlu, this);
}
};
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index fb317bd2f8..b49d0e3854 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -51,7 +51,7 @@ const NETLIBHTTPHEADER HEADER_URL_ENCODED = { "Content-Type", "application/x-www
#define NLH_INVALID 0
#define NLH_USER 'USER'
-LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams)
+LPSTR HttpPost(HNETLIBUSER hUser, LPSTR reqUrl, LPSTR reqParams)
{
NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) };
nlhr.requestType = REQUEST_POST;
@@ -62,11 +62,11 @@ LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams)
nlhr.pData = reqParams;
nlhr.dataLength = (int)mir_strlen(reqParams);
- NLHR_PTR pResp((NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hUser, (LPARAM)&nlhr));
+ NLHR_PTR pResp(Netlib_HttpTransaction(hUser, &nlhr));
return ((pResp && pResp->resultCode == HTTP_OK) ? mir_strdup(pResp->pData) : nullptr);
}
-LPSTR MakeRequest(HANDLE hUser, LPSTR reqUrl, LPSTR reqParamsFormat, LPSTR p1, LPSTR p2)
+LPSTR MakeRequest(HNETLIBUSER hUser, LPSTR reqUrl, LPSTR reqParamsFormat, LPSTR p1, LPSTR p2)
{
ptrA encodedP1(mir_urlEncode(p1)), encodedP2(mir_urlEncode(p2));
size_t size = mir_strlen(reqParamsFormat) + 1 + mir_strlen(encodedP1) + mir_strlen(encodedP2);
@@ -104,7 +104,7 @@ void DoOpenUrl(LPSTR tokenResp, LPSTR url)
Utils_OpenUrl(composedUrl);
}
-BOOL AuthAndOpen(HANDLE hUser, LPSTR url, LPSTR mailbox, LPSTR pwd)
+BOOL AuthAndOpen(HNETLIBUSER hUser, LPSTR url, LPSTR mailbox, LPSTR pwd)
{
ptrA authResp(MakeRequest(hUser, AUTH_REQUEST_URL, AUTH_REQUEST_PARAMS, mailbox, pwd));
if (!authResp)
@@ -127,7 +127,7 @@ struct OPEN_URL_HEADER {
LPCSTR acc;
};
-HANDLE FindNetUserHandle(LPCSTR acc)
+HNETLIBUSER FindNetUserHandle(LPCSTR acc)
{
IJabberInterface *ji = getJabberApi(acc);
if (!ji)
@@ -140,7 +140,7 @@ void OpenUrlThread(void *param)
{
OPEN_URL_HEADER* data = (OPEN_URL_HEADER*)param;
- HANDLE hUser = FindNetUserHandle(data->acc);
+ HNETLIBUSER hUser = FindNetUserHandle(data->acc);
if (!hUser || !AuthAndOpen(hUser, data->url, data->mailbox, data->pwd))
Utils_OpenUrl(data->url);
free(data);
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index 9587cd11b0..24ac5b6e68 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -68,7 +68,7 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
req.szUrl = szUrl;
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_REDIRECT;
- NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp == NULL) {
debugLogA("getAvatarFileInfo(): No response from HTTP request");
return false;
@@ -76,7 +76,7 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
if (resp->resultCode != 200 || !resp->dataLength || !resp->pData) {
debugLogA("getAvatarFileInfo(): Invalid response code from HTTP request");
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
return false;
}
@@ -118,14 +118,14 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
}
}
}
-
- } else {
+ }
+ else {
debugLogA("getAvatarFileInfo(): Invalid response code from HTTP request, unknown format");
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
return false;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
return true;
}
@@ -250,7 +250,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*)
req.szUrl = data->szAvatarURL;
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_REDIRECT;
- NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
int file_fd;
@@ -276,7 +276,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*)
}
}
else debugLogA("avatarrequestthread(): Invalid response code from HTTP request");
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
else debugLogA("avatarrequestthread(): No response from HTTP request");
@@ -436,7 +436,7 @@ void __cdecl GGPROTO::setavatarthread(void *param)
//send request
int resultSuccess = 0;
int needRepeat = 0;
- NETLIBHTTPREQUEST* resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ NETLIBHTTPREQUEST* resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
debugLogA("setavatarthread(): 1 resp.data= %s", resp->pData);
@@ -447,7 +447,7 @@ void __cdecl GGPROTO::setavatarthread(void *param)
needRepeat = 1;
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
} else {
debugLogA("setavatarthread(): No response from HTTP request");
}
@@ -471,18 +471,17 @@ void __cdecl GGPROTO::setavatarthread(void *param)
req.pData = data;
req.dataLength = int(dataLen);
- resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
debugLogA("setavatarthread(): 2 resp.data= %s", resp->pData);
resultSuccess = 1;
- } else {
- debugLogA("setavatarthread(): Invalid response code from HTTP request [%d]", resp->resultCode);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
- } else {
- debugLogA("setavatarthread(): No response from HTTP request");
+ else debugLogA("setavatarthread(): Invalid response code from HTTP request [%d]", resp->resultCode);
+
+ Netlib_FreeHttpRequest(resp);
}
+ else debugLogA("setavatarthread(): No response from HTTP request");
}
//clean and end thread
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp
index 2a24e7e5c5..bf1bb81504 100644
--- a/protocols/Gadu-Gadu/src/oauth.cpp
+++ b/protocols/Gadu-Gadu/src/oauth.cpp
@@ -311,7 +311,7 @@ int GGPROTO::oauth_receivetoken()
req.headersCount = 3;
req.headers = httpHeaders;
- NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp) {
nlc = resp->nlc;
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
@@ -329,7 +329,7 @@ int GGPROTO::oauth_receivetoken()
mir_free(xmlAction);
}
else debugLogA("oauth_receivetoken(): Invalid response code from HTTP request");
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
else debugLogA("oauth_receivetoken(): No response from HTTP request");
@@ -356,9 +356,11 @@ int GGPROTO::oauth_receivetoken()
req.pData = str;
req.dataLength = (int)mir_strlen(str);
- resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
- if (resp) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
- else debugLogA("oauth_receivetoken(): No response from HTTP request");
+ resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ if (resp)
+ Netlib_FreeHttpRequest(resp);
+ else
+ debugLogA("oauth_receivetoken(): No response from HTTP request");
// 3. Obtaining an Access Token
debugLogA("oauth_receivetoken(): Obtaining an Access Token...");
@@ -381,7 +383,7 @@ int GGPROTO::oauth_receivetoken()
httpHeaders[1].szName = "Authorization";
httpHeaders[1].szValue = str;
- resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
wchar_t *xmlAction = mir_a2u(resp->pData);
@@ -399,7 +401,7 @@ int GGPROTO::oauth_receivetoken()
}
else debugLogA("oauth_receivetoken(): Invalid response code from HTTP request");
Netlib_CloseHandle(resp->nlc);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
else debugLogA("oauth_receivetoken(): No response from HTTP request");
diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp
index 8d9e0a5a03..49b36cbb2a 100644
--- a/protocols/JabberG/src/jabber_api.cpp
+++ b/protocols/JabberG/src/jabber_api.cpp
@@ -353,7 +353,7 @@ LPTSTR CJabberProto::GetResourceFeatures(LPCTSTR jid)
return str;
}
-HANDLE CJabberProto::GetHandle()
+HNETLIBUSER CJabberProto::GetHandle()
{
return m_hNetlibUser;
}
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 844436fc45..a604cd30fa 100755
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -726,7 +726,7 @@ private:
request.flags = NLHRF_REDIRECT | NLHRF_HTTP11;
request.szUrl = JABBER_SERVER_URL;
- NETLIBHTTPREQUEST *result = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)wnd->GetProto()->m_hNetlibUser, (LPARAM)&request);
+ NETLIBHTTPREQUEST *result = Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request);
if (result) {
if (result->resultCode == 200 && result->dataLength && result->pData) {
wchar_t *buf = mir_a2u(result->pData);
@@ -738,7 +738,7 @@ private:
}
mir_free(buf);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)result);
+ Netlib_FreeHttpRequest(result);
}
if (bIsError)
@@ -2188,7 +2188,7 @@ void CJabberDlgAccMgrUI::QueryServerListThread(void *arg)
request.flags = NLHRF_HTTP11;
request.szUrl = JABBER_SERVER_URL;
- NETLIBHTTPREQUEST *result = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)wnd->GetProto()->m_hNetlibUser, (LPARAM)&request);
+ NETLIBHTTPREQUEST *result = Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request);
if (result && IsWindow(hwnd)) {
if ((result->resultCode == 200) && result->dataLength && result->pData) {
wchar_t *ptszText = mir_a2u(result->pData);
@@ -2205,7 +2205,7 @@ void CJabberDlgAccMgrUI::QueryServerListThread(void *arg)
}
if (result)
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)result);
+ Netlib_FreeHttpRequest(result);
if (bIsError)
SendMessage(hwnd, WM_JABBER_REFRESH, 0, 0);
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index e9f721af67..9eb9640ea6 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -849,7 +849,8 @@ public:
int STDMETHODCALLTYPE AddFeatures(LPCTSTR szFeatures); // Adds features to the list of features returned by the client.
int STDMETHODCALLTYPE RemoveFeatures(LPCTSTR szFeatures); // Removes features from the list of features returned by the client.
LPTSTR STDMETHODCALLTYPE GetResourceFeatures(LPCTSTR jid); // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free().
- HANDLE STDMETHODCALLTYPE GetHandle(); // Returns connection handle
+
+ HNETLIBUSER STDMETHODCALLTYPE GetHandle(); // Returns connection handle
private:
JabberFeatCapPairDynamic *FindFeature(LPCTSTR szFeature);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 54dc784587..4820aafc0d 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -898,7 +898,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
nlhr.szUrl = avs[i].Url;
nlhr.nlc = hHttpCon;
- NETLIBHTTPREQUEST * res = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST * res = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
if (res) {
hHttpCon = res->nlc;
if (res->resultCode == 200 && res->dataLength) {
@@ -941,7 +941,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
}
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)res);
+ Netlib_FreeHttpRequest(res);
}
else hHttpCon = NULL;
}
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp
index 6fb91f4131..a14c976c64 100644
--- a/protocols/MRA/src/MraAvatars.cpp
+++ b/protocols/MRA/src/MraAvatars.cpp
@@ -397,7 +397,7 @@ DWORD MraAvatarsHttpTransaction(HANDLE hConnection, DWORD dwRequestType, LPCSTR
if (dwSent == SOCKET_ERROR || !dwSent)
return GetLastError();
- NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_RECVHTTPHEADERS, (WPARAM)hConnection, 0);
+ NETLIBHTTPREQUEST *pnlhr = Netlib_RecvHttpHeaders(hConnection);
if (!pnlhr)
return GetLastError();
@@ -428,7 +428,7 @@ DWORD MraAvatarsHttpTransaction(HANDLE hConnection, DWORD dwRequestType, LPCSTR
if (pdwResultCode)
*pdwResultCode = pnlhr->resultCode;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pnlhr);
+ Netlib_FreeHttpRequest(pnlhr);
return 0;
}
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp
index 5e6631e242..5501cc4b51 100644
--- a/protocols/MSN/src/msn_auth.cpp
+++ b/protocols/MSN/src/msn_auth.cpp
@@ -286,7 +286,7 @@ bool SkypeToken::Refresh(bool bForce)
}
m_proto->mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_proto->hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_proto->hNetlibUserHttps, &nlhr);
m_proto->mHttpsTS = clock();
if (nlhrReply) {
@@ -312,7 +312,7 @@ bool SkypeToken::Refresh(bool bForce)
bRet=true;
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
} else m_proto->hHttpsConnection = NULL;
return bRet;
}
@@ -795,7 +795,7 @@ bool CMsnProto::RefreshOAuth(const char *pszRefreshToken, const char *pszService
// Query
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -816,7 +816,7 @@ bool CMsnProto::RefreshOAuth(const char *pszRefreshToken, const char *pszService
}
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
} else hHttpsConnection = NULL;
return bRet;
}
@@ -1117,7 +1117,7 @@ int CMsnProto::MSN_AuthOAuth(void)
// Get oauth20 login data
nlhr.szUrl = AUTH_URL;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
@@ -1142,7 +1142,7 @@ int CMsnProto::MSN_AuthOAuth(void)
nlhr.flags &= (~NLHRF_REDIRECT);
mHttpsTS = clock();
nlhr.nlc = hHttpsConnection;
- NETLIBHTTPREQUEST *nlhrReply2 = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply2 = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply2) {
char *pszURL=NULL, *pAccessToken, *pEnd;
@@ -1171,14 +1171,14 @@ int CMsnProto::MSN_AuthOAuth(void)
pszURL = param.pszURL;
mir_free(authCookies);
authCookies = nlhr.headers[1].szValue = param.pszCookies;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply2);
+ Netlib_FreeHttpRequest(nlhrReply2);
nlhrReply2 = NULL;
bAskingForAuth = false;
bPassportAuth = false;
}
}
setByte("PassportAuth", bPassportAuth);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
nlhrReply = nlhrReply2;
if (pszURL &&
@@ -1245,8 +1245,9 @@ int CMsnProto::MSN_AuthOAuth(void)
/* Request MappingContainer */
mHttpsTS = clock();
- if (nlhrReply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
- nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ if (nlhrReply)
+ Netlib_FreeHttpRequest(nlhrReply);
+ nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -1275,8 +1276,10 @@ int CMsnProto::MSN_AuthOAuth(void)
else hHttpsConnection = NULL;
}
}
- if (nlhrReply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
- } else hHttpsConnection = NULL;
+ if (nlhrReply)
+ Netlib_FreeHttpRequest(nlhrReply);
+ }
+ else hHttpsConnection = NULL;
if (retVal<=0) authSkypeComToken.Clear(); else {
if (bPassportAuth) {
diff --git a/protocols/MSN/src/msn_avatar.cpp b/protocols/MSN/src/msn_avatar.cpp
index 8b1e6e0d46..88491305fd 100644
--- a/protocols/MSN/src/msn_avatar.cpp
+++ b/protocols/MSN/src/msn_avatar.cpp
@@ -61,13 +61,13 @@ bool CMsnProto::loadHttpAvatar(AvatarQueueEntry *p)
nlhr.headers = (NETLIBHTTPHEADER*)&nlbhHeaders;
nlhr.headersCount = 1;
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
if (nlhrReply == NULL)
return false;
if (nlhrReply->resultCode != 200 || nlhrReply->dataLength == 0) {
LBL_Error:
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return false;
}
@@ -90,7 +90,7 @@ LBL_Error:
_close(fileId);
ProtoBroadcastAck(p->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai, 0);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return true;
}
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index 9e148547fb..cdea188a44 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -476,7 +476,7 @@ void CMsnProto::MSN_ProcessURIObject(MCONTACT hContact, ezxml_t xmli)
nlhr.nlc = hHttpsConnection;
mHttpsTS = clock();
- nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -491,7 +491,7 @@ void CMsnProto::MSN_ProcessURIObject(MCONTACT hContact, ezxml_t xmli)
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
} else hHttpsConnection = NULL;
if (fileSize) {
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 61eab09889..0f1a20f5fd 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -541,26 +541,24 @@ void __cdecl CMsnProto::MsnFileAckThread(void* arg)
if (nloc.flags & NLOCF_SSL) nlhr.flags |= NLHRF_SSL;
HANDLE nlc = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
- if (nlc && CallService(MS_NETLIB_SENDHTTPREQUEST, (WPARAM)nlc, (LPARAM)&nlhr) != SOCKET_ERROR &&
- (nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_RECVHTTPHEADERS, (WPARAM)nlc, 0)))
- {
- if (nlhrReply->resultCode == 200 || nlhrReply->resultCode == 206) {
- INT_PTR dw;
- char buf[1024];
-
- ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, ft, 0);
- while (!ft->bCanceled && ft->std.currentFileProgress < ft->std.currentFileSize &&
- (dw = Netlib_Recv(nlc, buf, sizeof(buf), MSG_NODUMP))>0 && dw!=SOCKET_ERROR)
- {
- _write(ft->fileId, buf, dw);
- ft->std.totalProgress += dw;
- ft->std.currentFileProgress += dw;
- ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
- }
- if (ft->std.currentFileProgress == ft->std.currentFileSize) ft->std.currentFileNumber++;
-
+ if (nlc && CallService(MS_NETLIB_SENDHTTPREQUEST, (WPARAM)nlc, (LPARAM)&nlhr) != SOCKET_ERROR && (nlhrReply = Netlib_RecvHttpHeaders(nlc))) {
+ if (nlhrReply->resultCode == 200 || nlhrReply->resultCode == 206) {
+ INT_PTR dw;
+ char buf[1024];
+
+ ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, ft, 0);
+ while (!ft->bCanceled && ft->std.currentFileProgress < ft->std.currentFileSize &&
+ (dw = Netlib_Recv(nlc, buf, sizeof(buf), MSG_NODUMP))>0 && dw!=SOCKET_ERROR)
+ {
+ _write(ft->fileId, buf, dw);
+ ft->std.totalProgress += dw;
+ ft->std.currentFileProgress += dw;
+ ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ if (ft->std.currentFileProgress == ft->std.currentFileSize) ft->std.currentFileNumber++;
+
+ }
+ Netlib_FreeHttpRequest(nlhrReply);
}
Netlib_CloseHandle(nlc);
mir_free((char*)nloc.szHost);
diff --git a/protocols/MSN/src/msn_skypeab.cpp b/protocols/MSN/src/msn_skypeab.cpp
index 604219b292..1a34f71ec0 100644
--- a/protocols/MSN/src/msn_skypeab.cpp
+++ b/protocols/MSN/src/msn_skypeab.cpp
@@ -68,7 +68,7 @@ bool CMsnProto::MSN_SKYABRefreshClist(void)
// Query addressbook
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -101,7 +101,7 @@ bool CMsnProto::MSN_SKYABRefreshClist(void)
json_delete(items);
MSN_SKYABGetProfiles((const char*)post);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = NULL;
return bRet;
@@ -122,7 +122,7 @@ bool CMsnProto::MSN_SKYABGetProfiles(const char *pszPOST)
nlhr.pData = (char*)pszPOST;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -155,7 +155,7 @@ bool CMsnProto::MSN_SKYABGetProfiles(const char *pszPOST)
json_delete(items);
bRet = true;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = NULL;
return bRet;
@@ -175,7 +175,7 @@ bool CMsnProto::MSN_SKYABGetProfile(const char *wlid)
nlhr.szUrl = szURL;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -227,7 +227,7 @@ bool CMsnProto::MSN_SKYABGetProfile(const char *wlid)
}
bRet = true;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = NULL;
return bRet;
@@ -253,11 +253,11 @@ bool CMsnProto::MSN_SKYABBlockContact(const char *wlid, const char *pszAction)
nlhr.pData = szPOST;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
bRet = true;
}
else hHttpsConnection = NULL;
@@ -281,11 +281,11 @@ bool CMsnProto::MSN_SKYABDeleteContact(const char *wlid)
nlhr.headersCount++;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
bRet = true;
}
else hHttpsConnection = NULL;
@@ -307,11 +307,11 @@ bool CMsnProto::MSN_SKYABAuthRsp(const char *wlid, const char *pszAction)
nlhr.szUrl = szURL;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
bRet = true;
}
else hHttpsConnection = NULL;
@@ -339,11 +339,11 @@ bool CMsnProto::MSN_SKYABAuthRq(const char *wlid, const char *pszGreeting)
nlhr.pData = (char*)(const char*)post;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
bRet = true;
}
else hHttpsConnection = NULL;
@@ -370,7 +370,7 @@ bool CMsnProto::MSN_SKYABSearch(const char *keyWord, HANDLE hSearch)
nlhr.headersCount++;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -400,7 +400,7 @@ bool CMsnProto::MSN_SKYABSearch(const char *keyWord, HANDLE hSearch)
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, hSearch, 0);
bRet = true;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = NULL;
return bRet;
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp
index e8c28d2cb6..084f63bcea 100644
--- a/protocols/MSN/src/msn_soapab.cpp
+++ b/protocols/MSN/src/msn_soapab.cpp
@@ -862,7 +862,7 @@ bool CMsnProto::MSN_ABRefreshClist(unsigned int nTry)
// Query addressbook
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -946,8 +946,9 @@ bool CMsnProto::MSN_ABRefreshClist(unsigned int nTry)
authSkypeComToken.Clear();
if (MSN_AuthOAuth() > 0) return MSN_ABRefreshClist(1);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
- } else hHttpsConnection = NULL;
+ Netlib_FreeHttpRequest(nlhrReply);
+ }
+ else hHttpsConnection = NULL;
return bRet;
}
diff --git a/protocols/MSN/src/msn_ssl.cpp b/protocols/MSN/src/msn_ssl.cpp
index 6bcfcffeb8..7e8541ab7c 100644
--- a/protocols/MSN/src/msn_ssl.cpp
+++ b/protocols/MSN/src/msn_ssl.cpp
@@ -76,7 +76,7 @@ char* CMsnProto::getSslResult(char** parUrl, const char* parAuthInfo, const char
}
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -93,7 +93,7 @@ char* CMsnProto::getSslResult(char** parUrl, const char* parAuthInfo, const char
nlhrReply->dataLength = 0;
nlhrReply->pData = NULL;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else
hHttpsConnection = NULL;
@@ -120,15 +120,14 @@ bool CMsnProto::getMyAvatarFile(char *url, wchar_t *fname)
nlhr.headers[0].szValue = (char*)MSN_USER_AGENT;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps, (LPARAM)&nlhr);
-
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUserHttps, &nlhr);
if (nlhrReply) {
if (nlhrReply->resultCode == 200 && nlhrReply->dataLength)
MSN_SetMyAvatar(fname, nlhrReply->pData, nlhrReply->dataLength);
else
result = false;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
return result;
}
diff --git a/protocols/MinecraftDynmap/src/communication.cpp b/protocols/MinecraftDynmap/src/communication.cpp
index f61bc9d5af..9962317773 100644
--- a/protocols/MinecraftDynmap/src/communication.cpp
+++ b/protocols/MinecraftDynmap/src/communication.cpp
@@ -81,7 +81,7 @@ http::response MinecraftDynmapProto::sendRequest(const int request_type, std::st
debugLogA("@@@@@ Sending request to '%s'", nlhr.szUrl);
// Send the request
- NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *pnlhr = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
mir_free(nlhr.headers);
@@ -111,7 +111,7 @@ http::response MinecraftDynmapProto::sendRequest(const int request_type, std::st
// debugLogA("&&&&& Got response: %s", resp.data.c_str());
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pnlhr);
+ Netlib_FreeHttpRequest(pnlhr);
} else {
debugLogA("!!!!! No response from server (time-out)");
resp.code = HTTP_CODE_FAKE_DISCONNECTED;
diff --git a/protocols/Omegle/src/client.h b/protocols/Omegle/src/client.h
index d992333330..1f95e0c335 100644
--- a/protocols/Omegle/src/client.h
+++ b/protocols/Omegle/src/client.h
@@ -117,9 +117,9 @@ public:
// Netlib handle
- HANDLE handle_;
+ HNETLIBUSER handle_;
- void set_handle(HANDLE h)
+ void set_handle(HNETLIBUSER h)
{
handle_ = h;
}
diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp
index 81d43c3242..827560e378 100644
--- a/protocols/Omegle/src/communication.cpp
+++ b/protocols/Omegle/src/communication.cpp
@@ -79,7 +79,7 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
parent->debugLogA("@@@@@ Sending request to '%s'", nlhr.szUrl);
// Send the request
- NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *pnlhr = Netlib_HttpTransaction(handle_, &nlhr);
mir_free(nlhr.headers);
@@ -109,7 +109,7 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
parent->debugLogA("&&&&& Got response: %s", resp.data.c_str());
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pnlhr);
+ Netlib_FreeHttpRequest(pnlhr);
}
else {
parent->debugLogA("!!!!! No response from server (time-out)");
diff --git a/protocols/SkypeWeb/src/http_request.h b/protocols/SkypeWeb/src/http_request.h
index b7c8ef73be..bfc872ba68 100644
--- a/protocols/SkypeWeb/src/http_request.h
+++ b/protocols/SkypeWeb/src/http_request.h
@@ -276,7 +276,7 @@ public:
Netlib_Logf(nlu, "Send request to %s", szUrl);
- return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)nlu, (LPARAM)(NETLIBHTTPREQUEST*)this);
+ return Netlib_HttpTransaction(nlu, this);
}
};
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index 57c7cf40a4..db030aa10f 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -73,7 +73,7 @@ void RequestQueue::Execute(RequestQueueItem *item)
NETLIBHTTPREQUEST *response = item->request->Send(nlu);
if (item->responseCallback != NULL)
item->responseCallback(response, item->arg);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
+ Netlib_FreeHttpRequest(response);
requests.remove(item);
delete item;
}
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h
index 60d3c1b403..8016f2cf1d 100644
--- a/protocols/Steam/src/http_request.h
+++ b/protocols/Steam/src/http_request.h
@@ -146,9 +146,9 @@ public:
Netlib_Logf(nlu, "Send request to %s", szUrl);
- NETLIBHTTPREQUEST* response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)nlu, (LPARAM)this);
+ NETLIBHTTPREQUEST* response = Netlib_HttpTransaction(nlu, this);
HttpResponse* result = new HttpResponse(response, this);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
+ Netlib_FreeHttpRequest(response);
return result;
}
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp
index 1affd2da6e..34f6828abf 100644
--- a/protocols/Tlen/src/tlen.cpp
+++ b/protocols/Tlen/src/tlen.cpp
@@ -198,7 +198,7 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM, LPARAM)
req.pData = form;
req.dataLength = (int)mir_strlen(form);
req.szUrl = "http://poczta.o2.pl/login.html";
- resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (resp != NULL) {
if (resp->resultCode / 100 == 2 || resp->resultCode == 302) {
int i;
@@ -217,7 +217,7 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM, LPARAM)
}
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
}
mir_free(login);
diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp
index f82d450634..bd9c031b3a 100644
--- a/protocols/Tlen/src/tlen_avatar.cpp
+++ b/protocols/Tlen/src/tlen_avatar.cpp
@@ -267,7 +267,7 @@ static void TlenGetAvatarThread(void *ptr)
req.headers = NULL;
req.dataLength = 0;
req.szUrl = request;
- NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->m_hNetlibUser, (LPARAM)&req);
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(data->proto->m_hNetlibUser, &req);
if (item != NULL)
item->newAvatarDownloading = FALSE;
@@ -297,7 +297,7 @@ static void TlenGetAvatarThread(void *ptr)
}
else RemoveAvatar(data->proto, hContact);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
mir_free(request);
mir_free(login);
@@ -334,13 +334,13 @@ struct TLENREMOVEAVATARTHREADDATA
static void TlenRemoveAvatarRequestThread(void *ptr) {
TLENREMOVEAVATARTHREADDATA *data = (TLENREMOVEAVATARTHREADDATA*)ptr;
NETLIBHTTPREQUEST *req = (NETLIBHTTPREQUEST *)data->req;
- NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->m_hNetlibUser, (LPARAM)req);
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(data->proto->m_hNetlibUser, req);
mir_free(req->szUrl);
mir_free(req->headers);
mir_free(req->pData);
mir_free(req);
if (resp != NULL) {
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
RemoveAvatar(data->proto, NULL);
}
mir_free(data);
@@ -379,9 +379,9 @@ static void TlenUploadAvatarRequestThread(void *ptr)
{
TLENUPLOADAVATARTHREADDATA *data = (TLENUPLOADAVATARTHREADDATA *) ptr;
NETLIBHTTPREQUEST *req = data->req;
- NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->m_hNetlibUser, (LPARAM)req);
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(data->proto->m_hNetlibUser, req);
if (checkUploadAvatarResponse(data->proto, resp)) {
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
SetAvatar(data->proto, NULL, NULL, data->data, data->length, PA_FORMAT_PNG);
}
mir_free(req->szUrl);
diff --git a/protocols/Tox/src/http_request.h b/protocols/Tox/src/http_request.h
index 1ffa523775..18b8228f63 100644
--- a/protocols/Tox/src/http_request.h
+++ b/protocols/Tox/src/http_request.h
@@ -98,11 +98,11 @@ public:
memcpy(pData, data, size);
}
- NETLIBHTTPREQUEST* Send(HANDLE hNetlibConnection)
+ NETLIBHTTPREQUEST* Send(HNETLIBUSER hNetlibConnection)
{
m_szUrl.Replace('\\', '/');
szUrl = m_szUrl.GetBuffer();
- return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibConnection, (LPARAM)this);
+ return Netlib_HttpTransaction(hNetlibConnection, this);
}
};
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp
index 952515d60d..d2afffc717 100644
--- a/protocols/Tox/src/tox_search.cpp
+++ b/protocols/Tox/src/tox_search.cpp
@@ -57,7 +57,7 @@ ToxHexAddress ResolveToxAddressFromDns(const char *dnsQuery)
return address;
}
-ToxHexAddress ResolveToxAddressFromToxme(HANDLE hNetlib, const char *query)
+ToxHexAddress ResolveToxAddressFromToxme(HNETLIBUSER hNetlib, const char *query)
{
ToxHexAddress address = ToxHexAddress::Empty();
@@ -87,7 +87,7 @@ void CToxProto::SearchByNameAsync(void *arg)
char *query = (char*)arg;
char *name = strtok(query, "@");
- char *domain = strtok(NULL, "");
+ // char *domain = strtok(NULL, "");
/*int resolved = 0;
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index a62c462045..d344bc1a9e 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -113,7 +113,7 @@ private:
mir_cs avatar_lock_;
mir_cs twitter_lock_;
- HANDLE hAvatarNetlib_;
+ HNETLIBUSER hAvatarNetlib_;
HANDLE hMsgLoop_;
mir_twitter twit_;
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp
index f22e71de5b..6ac208279d 100644
--- a/protocols/Twitter/src/utility.cpp
+++ b/protocols/Twitter/src/utility.cpp
@@ -111,8 +111,7 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu
req.nlc = httpPOST_;
http::response resp_data;
ppro_->debugLogA("**SLURP - just before calling HTTPTRANSACTION");
- NETLIBHTTPREQUEST *resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
- reinterpret_cast<WPARAM>(handle_), reinterpret_cast<LPARAM>(&req)));
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(handle_, &req);
ppro_->debugLogA("**SLURP - HTTPTRANSACTION complete.");
if (resp) {
ppro_->debugLogA("**SLURP - the server has responded!");
@@ -120,7 +119,7 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu
resp_data.code = resp->resultCode;
resp_data.data = resp->pData ? resp->pData : "";
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
}
else {
httpPOST_ = NULL;
@@ -130,16 +129,14 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu
return resp_data;
}
-bool save_url(HANDLE hNetlib, const std::string &url, const std::wstring &filename)
+bool save_url(HNETLIBUSER hNetlib, const std::string &url, const std::wstring &filename)
{
NETLIBHTTPREQUEST req = { sizeof(req) };
req.requestType = REQUEST_GET;
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
req.szUrl = const_cast<char*>(url.c_str());
- NETLIBHTTPREQUEST *resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
- reinterpret_cast<WPARAM>(hNetlib), reinterpret_cast<LPARAM>(&req)));
-
+ NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(hNetlib, &req);
if (resp) {
bool success = (resp->resultCode == 200);
if (success) {
@@ -154,7 +151,7 @@ bool save_url(HANDLE hNetlib, const std::string &url, const std::wstring &filena
fclose(f);
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
+ Netlib_FreeHttpRequest(resp);
return success;
}
diff --git a/protocols/Twitter/src/utility.h b/protocols/Twitter/src/utility.h
index ab778900f4..e7e14e084c 100644
--- a/protocols/Twitter/src/utility.h
+++ b/protocols/Twitter/src/utility.h
@@ -31,7 +31,7 @@ class mir_twitter : public twitter
{
public:
mir_twitter() : twitter(), handle_(NULL), httpPOST_(NULL) {}
- void set_handle(PROTO_INTERFACE *ppro, HANDLE h)
+ void set_handle(PROTO_INTERFACE *ppro, HNETLIBUSER h)
{
ppro_ = ppro;
handle_ = h;
@@ -86,7 +86,7 @@ protected:
http::response slurp(const std::string &,http::method, OAuthParameters );
HANDLE httpPOST_;
- HANDLE handle_;
+ HNETLIBUSER handle_;
PROTO_INTERFACE *ppro_;
};
@@ -95,4 +95,4 @@ inline void mbcs_to_tcs(UINT code_page, const char *mbstr, wchar_t *tstr, int tl
MultiByteToWideChar(code_page, 0, mbstr, -1, tstr, tlen);
}
-bool save_url(HANDLE hNetlib,const std::string &url,const std::wstring &filename);
+bool save_url(HNETLIBUSER hNetlib,const std::string &url,const std::wstring &filename);
diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp
index 807e367453..98fa443e86 100644
--- a/protocols/VKontakte/src/vk_captcha.cpp
+++ b/protocols/VKontakte/src/vk_captcha.cpp
@@ -38,7 +38,7 @@ bool CVkProto::RunCaptchaForm(LPCSTR szUrl, CMStringA &result)
req.szUrl = (LPSTR)szUrl;
req.flags = VK_NODUMPHEADERS;
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, &req);
if (reply == NULL)
return false;
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index 9e108cdc66..e2931e62b4 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -201,7 +201,7 @@ int CVkProto::PollServer()
req.timeout = 30000;
req.nlc = m_pollingConn;
- while ((reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req)) == NULL) {
+ while ((reply = Netlib_HttpTransaction(m_hNetlibUser, &req)) == NULL) {
debugLogA("CVkProto::PollServer is dead");
m_pollingConn = NULL;
if (iPollConnRetry && !m_bTerminated) {
@@ -239,14 +239,14 @@ int CVkProto::PollServer()
|| (reply->resultCode >= 500 && reply->resultCode <= 509)) {
debugLogA("CVkProto::PollServer is dead. Error code - %d", reply->resultCode);
m_pollingConn = NULL;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
ShutdownSession();
return 0;
}
m_pollingConn = reply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
debugLogA("CVkProto::PollServer return %d", retVal);
return retVal;
}
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 6bd1a3d583..870575837b 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -55,7 +55,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
debugLogA("CVkProto::ExecuteRequest \n====\n%s\n====\n", pReq->szUrl);
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq);
+ NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq);
if (reply != NULL) {
if (pReq->m_pFunc != NULL)
(this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart
@@ -63,7 +63,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
if (pReq->m_bApiReq)
m_hAPIConnection = reply->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ Netlib_FreeHttpRequest(reply);
}
else if (pReq->bIsMainConn) {
if (IsStatusConnecting(m_iStatus))
diff --git a/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp b/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp
index b2fa8ff091..34a99a9de4 100644
--- a/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp
+++ b/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp
@@ -55,7 +55,7 @@ namespace MediaUploader
nlhr.pData = (char*)allVector.data();
nlhr.dataLength = (int)allVector.size();
- NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *pnlhr = Netlib_HttpTransaction(g_hNetlibUser, &nlhr);
string data = pnlhr->pData;
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp
index 69b91de842..23246c783f 100644
--- a/protocols/WhatsApp/src/proto.cpp
+++ b/protocols/WhatsApp/src/proto.cpp
@@ -261,7 +261,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number,
nlhr.headersCount = _countof(s_registerHeaders);
nlhr.flags = NLHRF_HTTP11 | NLHRF_SSL;
- NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr);
+ NETLIBHTTPREQUEST* pnlhr = Netlib_HttpTransaction(g_hNetlibUser, &nlhr);
const wchar_t *ptszTitle = TranslateT("Registration");
if (pnlhr == NULL) {
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 98b5cf622c..430ecaa097 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -354,3 +354,5 @@ Netlib_LogW @354
Netlib_Logf @355
Netlib_LogfW @356
Netlib_GetConnNlu @357
+Netlib_RecvHttpHeaders @358
+Netlib_HttpTransaction @359
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index b777b03b2e..d3bff9758a 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -354,3 +354,5 @@ Netlib_LogW @354
Netlib_Logf @355
Netlib_LogfW @356
Netlib_GetConnNlu @357
+Netlib_RecvHttpHeaders @358
+Netlib_HttpTransaction @359
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index 69b4195b37..0ae2a3a7d4 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -503,9 +503,6 @@ int LoadNetlibModule(void)
CreateServiceFunction(MS_NETLIB_SETSTICKYHEADERS, NetlibHttpSetSticky);
CreateServiceFunction(MS_NETLIB_GETSOCKET, NetlibGetSocket);
CreateServiceFunction(MS_NETLIB_SENDHTTPREQUEST, NetlibHttpSendRequest);
- CreateServiceFunction(MS_NETLIB_RECVHTTPHEADERS, NetlibHttpRecvHeaders);
- CreateServiceFunction(MS_NETLIB_FREEHTTPREQUESTSTRUCT, NetlibHttpFreeRequestStruct);
- CreateServiceFunction(MS_NETLIB_HTTPTRANSACTION, NetlibHttpTransaction);
CreateServiceFunction(MS_NETLIB_SELECT, NetlibSelect);
CreateServiceFunction(MS_NETLIB_SELECTEX, NetlibSelectEx);
CreateServiceFunction(MS_NETLIB_SHUTDOWN, NetlibShutdown);
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h
index 738242b0ae..c327339945 100644
--- a/src/mir_app/src/netlib.h
+++ b/src/mir_app/src/netlib.h
@@ -201,27 +201,24 @@ INT_PTR NetlibHttpUrlEncode(WPARAM wParam, LPARAM lParam);
extern mir_cs csNetlibUser;
extern LIST<NetlibUser> netlibUser;
-//netlibautoproxy.c
+// netlibautoproxy.c
void NetlibLoadIeProxy(void);
void NetlibUnloadIeProxy(void);
char* NetlibGetIeProxy(char *szUrl);
bool NetlibGetIeProxyConn(NetlibConnection *nlc, bool forceHttps);
-//netlibbind.c
+// netlibbind.c
int NetlibFreeBoundPort(NetlibBoundPort *nlbp);
INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam);
bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn);
-//netlibhttp.c
+// netlibhttp.c
INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibHttpFreeRequestStruct(WPARAM wParam, LPARAM lParam);
-INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam);
void NetlibHttpSetLastErrorUsingHttpResult(int result);
NETLIBHTTPREQUEST* NetlibHttpRecv(NetlibConnection* nlc, DWORD hflags, DWORD dflags, bool isConnect = false);
void NetlibConnFromUrl(const char* szUrl, bool secur, NETLIBOPENCONNECTION &nloc);
-//netlibhttpproxy.c
+// netlibhttpproxy.c
int NetlibInitHttpConnection(NetlibConnection *nlc, NetlibUser *nlu, NETLIBOPENCONNECTION *nloc);
int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags);
int NetlibHttpGatewayPost(NetlibConnection *nlc, const char *buf, int len, int flags);
@@ -231,13 +228,13 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibHttpSetPollingTimeout(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam);
-//netliblog.c
+// netliblog.c
void NetlibLogShowOptions(void);
void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags);
void NetlibLogInit(void);
void NetlibLogShutdown(void);
-//netlibopenconn.c
+// netlibopenconn.c
DWORD DnsLookup(NetlibUser *nlu, const char *szHost);
int WaitUntilReadable(SOCKET s, DWORD dwTimeout, bool check = false);
int WaitUntilWritable(SOCKET s, DWORD dwTimeout);
@@ -246,15 +243,15 @@ bool NetlibReconnect(NetlibConnection *nlc);
INT_PTR NetlibOpenConnection(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibStartSsl(WPARAM wParam, LPARAM lParam);
-//netlibopts.c
+// netlibopts.c
int NetlibOptInitialise(WPARAM wParam, LPARAM lParam);
void NetlibSaveUserSettingsStruct(const char *szSettingsModule, NETLIBUSERSETTINGS *settings);
-//netlibpktrecver.c
+// netlibpktrecver.c
INT_PTR NetlibPacketRecverCreate(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam);
-//netlibsock.c
+// netlibsock.c
#define NL_SELECT_READ 0x0001
#define NL_SELECT_WRITE 0x0002
#define NL_SELECT_ALL (NL_SELECT_READ+NL_SELECT_WRITE)
@@ -268,7 +265,7 @@ char* NetlibAddressToString(SOCKADDR_INET_M* addr);
void NetlibGetConnectionInfo(NetlibConnection* nlc, NETLIBCONNINFO *connInfo);
NETLIBIPLIST* GetMyIp(unsigned flags);
-//netlibupnp.c
+// netlibupnp.c
bool NetlibUPnPAddPortMapping(WORD intport, char *proto,
WORD *extport, DWORD *extip, bool search);
void NetlibUPnPDeletePortMapping(WORD extport, char* proto);
@@ -276,7 +273,7 @@ void NetlibUPnPCleanup(void*);
void NetlibUPnPInit(void);
void NetlibUPnPDestroy(void);
-//netlibsecurity.c
+// netlibsecurity.c
void NetlibSecurityInit(void);
void NetlibDestroySecurityProvider(HANDLE hSecurity);
HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPrincipal);
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp
index 3e2e070df9..15fb93b3a2 100644
--- a/src/mir_app/src/netlibautoproxy.cpp
+++ b/src/mir_app/src/netlibautoproxy.cpp
@@ -144,19 +144,16 @@ static void GetFile(char* szUrl, AUTO_PROXY_SCRIPT_BUFFER &buf)
nlhr.szUrl = szUrl;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpTransaction((WPARAM)&nlu, (LPARAM)&nlhr);
-
- if (nlhrReply)
- {
- if (nlhrReply->resultCode == 200)
- {
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(&nlu, &nlhr);
+ if (nlhrReply) {
+ if (nlhrReply->resultCode == 200) {
buf.lpszScriptBuffer = nlhrReply->pData;
buf.dwScriptBufferSize = nlhrReply->dataLength + 1;
nlhrReply->dataLength = 0;
nlhrReply->pData = NULL;
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
}
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp
index b37a14e6dd..3ff0e83ba4 100644
--- a/src/mir_app/src/netlibhttp.cpp
+++ b/src/mir_app/src/netlibhttp.cpp
@@ -550,13 +550,13 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
(nlhr->flags & NLHRF_NOPROXY ? MSG_RAW : 0) | MSG_NODUMP;
if (resultCode == 100)
- nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpRecvHeaders((WPARAM)nlc, hflags);
+ nlhrReply = (NETLIBHTTPREQUEST*)Netlib_RecvHttpHeaders(nlc, hflags);
else if (resultCode == 307 || ((resultCode == 301 || resultCode == 302) && (nlhr->flags & NLHRF_REDIRECT))) { // redirect
pszUrl = NULL;
if (nlhr->requestType == REQUEST_HEAD)
- nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpRecvHeaders((WPARAM)nlc, hflags);
+ nlhrReply = (NETLIBHTTPREQUEST*)Netlib_RecvHttpHeaders(nlc, hflags);
else
nlhrReply = NetlibHttpRecv(nlc, hflags, dflags);
@@ -598,7 +598,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
}
else if (resultCode == 401 && !doneAuthHeader) { //auth required
if (nlhr->requestType == REQUEST_HEAD)
- nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpRecvHeaders((WPARAM)nlc, hflags);
+ nlhrReply = (NETLIBHTTPREQUEST*)Netlib_RecvHttpHeaders(nlc, hflags);
else
nlhrReply = NetlibHttpRecv(nlc, hflags, dflags);
@@ -632,7 +632,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
}
else if (resultCode == 407 && !doneProxyAuthHeader) { //proxy auth required
if (nlhr->requestType == REQUEST_HEAD)
- nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpRecvHeaders((WPARAM)nlc, hflags);
+ nlhrReply = Netlib_RecvHttpHeaders(nlc, hflags);
else
nlhrReply = NetlibHttpRecv(nlc, hflags, dflags);
@@ -673,14 +673,14 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
replaceStr(pszAuthHdr, NULL);
if (nlhrReply) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
nlhrReply = NULL;
}
}
if (count == 0) bytesSent = SOCKET_ERROR;
if (nlhrReply)
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
//clean up
mir_free(pszProxyAuthHdr);
@@ -694,14 +694,13 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam)
return bytesSent;
}
-INT_PTR NetlibHttpFreeRequestStruct(WPARAM, LPARAM lParam)
+MIR_APP_DLL(bool) Netlib_FreeHttpRequest(NETLIBHTTPREQUEST *nlhr)
{
- NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam;
-
if (nlhr == NULL || nlhr->cbSize != sizeof(NETLIBHTTPREQUEST) || nlhr->requestType != REQUEST_RESPONSE) {
SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
+ return false;
}
+
if (nlhr->headers) {
for (int i = 0; i < nlhr->headersCount; i++) {
NETLIBHTTPHEADER &p = nlhr->headers[i];
@@ -714,16 +713,16 @@ INT_PTR NetlibHttpFreeRequestStruct(WPARAM, LPARAM lParam)
mir_free(nlhr->szResultDescr);
mir_free(nlhr->szUrl);
mir_free(nlhr);
- return 1;
+ return true;
}
#define NHRV_BUF_SIZE 8192
-INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HANDLE hConnection, int flags)
{
- NetlibConnection *nlc = (NetlibConnection*)wParam;
+ NetlibConnection *nlc = (NetlibConnection*)hConnection;
if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
- return 0;
+ return NULL;
DWORD dwRequestTimeoutTime = GetTickCount() + HTTPRECVDATATIMEOUT;
NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)mir_calloc(sizeof(NETLIBHTTPREQUEST));
@@ -732,20 +731,20 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
nlhr->requestType = REQUEST_RESPONSE;
int firstLineLength = 0;
- if (!HttpPeekFirstResponseLine(nlc, dwRequestTimeoutTime, lParam | MSG_PEEK, &nlhr->resultCode, &nlhr->szResultDescr, &firstLineLength)) {
+ if (!HttpPeekFirstResponseLine(nlc, dwRequestTimeoutTime, flags | MSG_PEEK, &nlhr->resultCode, &nlhr->szResultDescr, &firstLineLength)) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhr);
- return 0;
+ Netlib_FreeHttpRequest(nlhr);
+ return NULL;
}
char *buffer = (char*)_alloca(NHRV_BUF_SIZE + 1);
- int bytesPeeked = Netlib_Recv(nlc, buffer, min(firstLineLength, NHRV_BUF_SIZE), lParam | MSG_DUMPASTEXT);
+ int bytesPeeked = Netlib_Recv(nlc, buffer, min(firstLineLength, NHRV_BUF_SIZE), flags | MSG_DUMPASTEXT);
if (bytesPeeked != firstLineLength) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhr);
+ Netlib_FreeHttpRequest(nlhr);
if (bytesPeeked != SOCKET_ERROR)
SetLastError(ERROR_HANDLE_EOF);
- return 0;
+ return NULL;
}
// Make sure all headers arrived
@@ -753,7 +752,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
int headersCount = 0;
bytesPeeked = 0;
for (bool headersCompleted = false; !headersCompleted;) {
- bytesPeeked = RecvWithTimeoutTime(nlc, dwRequestTimeoutTime, buffer, NHRV_BUF_SIZE, lParam | MSG_DUMPASTEXT | MSG_NOTITLE);
+ bytesPeeked = RecvWithTimeoutTime(nlc, dwRequestTimeoutTime, buffer, NHRV_BUF_SIZE, flags | MSG_DUMPASTEXT | MSG_NOTITLE);
if (bytesPeeked == 0)
break;
@@ -780,8 +779,8 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
// Receive headers
if (bytesPeeked <= 0) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhr);
- return 0;
+ Netlib_FreeHttpRequest(nlhr);
+ return NULL;
}
nlhr->headersCount = headersCount;
@@ -796,7 +795,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
char *pColon = strchr(pbuffer, ':');
if (pColon == NULL) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhr); nlhr = NULL;
+ Netlib_FreeHttpRequest(nlhr); nlhr = NULL;
SetLastError(ERROR_INVALID_DATA);
break;
}
@@ -814,14 +813,11 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
}
NetlibLeaveNestedCS(&nlc->ncsRecv);
- return (INT_PTR)nlhr;
+ return nlhr;
}
-INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_HttpTransaction(HNETLIBUSER nlu, NETLIBHTTPREQUEST *nlhr)
{
- NetlibUser *nlu = (NetlibUser*)wParam;
- NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam, *nlhrReply;
-
if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_OUTGOING) ||
nlhr == NULL || nlhr->cbSize != sizeof(NETLIBHTTPREQUEST) ||
nlhr->szUrl == NULL || nlhr->szUrl[0] == 0)
@@ -888,8 +884,9 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
(nlhr->flags & NLHRF_NODUMP ? MSG_NODUMP : (nlhr->flags & NLHRF_DUMPPROXY ? MSG_DUMPPROXY : 0)) |
(nlhr->flags & NLHRF_NOPROXY ? MSG_RAW : 0);
+ NETLIBHTTPREQUEST *nlhrReply;
if (nlhr->requestType == REQUEST_HEAD)
- nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpRecvHeaders((WPARAM)nlc, 0);
+ nlhrReply = Netlib_RecvHttpHeaders(nlc);
else
nlhrReply = NetlibHttpRecv(nlc, hflags, dflags);
@@ -905,7 +902,7 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam)
}
else nlhrReply->nlc = nlc;
- return (INT_PTR)nlhrReply;
+ return nlhrReply;
}
void NetlibHttpSetLastErrorUsingHttpResult(int result)
@@ -1011,12 +1008,12 @@ NETLIBHTTPREQUEST* NetlibHttpRecv(NetlibConnection *nlc, DWORD hflags, DWORD dfl
int cenc = 0, cenctype = 0, close = 0;
next:
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)NetlibHttpRecvHeaders((WPARAM)nlc, hflags);
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_RecvHttpHeaders(nlc, hflags);
if (nlhrReply == NULL)
return NULL;
if (nlhrReply->resultCode == 100) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
goto next;
}
@@ -1050,7 +1047,7 @@ next:
if (chunked) {
chunksz = NetlibHttpRecvChunkHeader(nlc, true, dflags | (cenctype ? MSG_NODUMP : 0));
if (chunksz == SOCKET_ERROR) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return NULL;
}
dataLen = chunksz;
@@ -1067,7 +1064,7 @@ next:
if (recvResult == 0) break;
if (recvResult == SOCKET_ERROR) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return NULL;
}
nlhrReply->dataLength += recvResult;
@@ -1081,7 +1078,7 @@ next:
nlhrReply->pData = (char*)mir_realloc(nlhrReply->pData, dataBufferAlloced);
if (nlhrReply->pData == NULL) {
SetLastError(ERROR_OUTOFMEMORY);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return NULL;
}
}
@@ -1093,7 +1090,7 @@ next:
chunksz = NetlibHttpRecvChunkHeader(nlc, false, dflags | MSG_NODUMP);
if (chunksz == SOCKET_ERROR) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return NULL;
}
dataLen += chunksz;
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp
index d34d67985e..db4cdcb70e 100644
--- a/src/mir_app/src/netlibhttpproxy.cpp
+++ b/src/mir_app/src/netlibhttpproxy.cpp
@@ -185,7 +185,7 @@ static bool NetlibHttpGatewayOscarPost(NetlibConnection *nlc, const char *buf, i
NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode);
res = false;
}
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
else res = false;
}
@@ -304,7 +304,7 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags)
if (nlhrReply->resultCode >= 300) {
int resultCode = nlhrReply->resultCode;
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
if (nlc->nlhpi.szHttpGetUrl && resultCode != 404) {
Netlib_Logf(nlu, "Error received from proxy, retrying");
@@ -324,7 +324,7 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags)
if (nlhrReply->dataLength) {
if (peek) {
nlc->szProxyBuf.Append(nlhrReply->pData, nlhrReply->dataLength);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return HttpGatewayReadSetResult(nlc, buf, len, peek);
}
@@ -337,16 +337,16 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags)
else
nlc->szProxyBuf.Empty();
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return bytes;
}
else {
if ((peek && nlc->szProxyBuf.GetLength() != 0) || nlhrReply->pData) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return HttpGatewayReadSetResult(nlc, buf, len, peek);
}
}
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
}
SetLastError(ERROR_GEN_FAILURE);
@@ -371,15 +371,15 @@ int NetlibInitHttpConnection(NetlibConnection *nlc, NetlibUser *nlu, NETLIBOPENC
if (nlhrReply->resultCode != 200) {
NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return 0;
}
}
if (!nlu->user.pfnHttpGatewayInit(nlc, nloc, nlhrReply)) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return 0;
}
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
/*
* Gena01 - Ok, we should be able to use just POST. Needed for Yahoo, NO GET requests
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp
index 18216f1c51..de29ab3b44 100644
--- a/src/mir_app/src/netlibopenconn.cpp
+++ b/src/mir_app/src/netlibopenconn.cpp
@@ -324,17 +324,17 @@ static bool NetlibInitHttpsConnection(NetlibConnection *nlc, NetlibUser *nlu, NE
if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) {
if (nlhrReply->resultCode == 403 && nlc->dnsThroughProxy) {
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
nlc->dnsThroughProxy = 0;
return NetlibInitHttpsConnection(nlc, nlu, nloc);
}
NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode);
Netlib_Logf(nlu, "%s %d: %s request failed (%u %s)", __FILE__, __LINE__, nlu->settings.proxyType == PROXYTYPE_HTTP ? "HTTP" : "HTTPS", nlhrReply->resultCode, nlhrReply->szResultDescr);
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return 0;
}
- NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply);
+ Netlib_FreeHttpRequest(nlhrReply);
return true; // connected
}