From bb03623fd3ba7b9cc456da2c9504bad87b80ace0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Jan 2017 19:51:30 +0300 Subject: - Netlib_Send & Netlib_Recv helpers became real functions, MS_NETLIB_SEND & MS_NETLIB_RECV died; - fix for dumping chunked http replies into a network log --- protocols/IcqOscarJ/src/icq_http.cpp | 5 ++--- protocols/IcqOscarJ/src/icq_http.h | 2 +- protocols/MSN/src/msn_http.cpp | 5 ++--- protocols/MSN/src/msn_proto.cpp | 2 +- protocols/MSN/src/msn_ws.cpp | 8 ++------ protocols/WhatsApp/src/WASocketConnection.cpp | 14 ++------------ 6 files changed, 10 insertions(+), 26 deletions(-) (limited to 'protocols') diff --git a/protocols/IcqOscarJ/src/icq_http.cpp b/protocols/IcqOscarJ/src/icq_http.cpp index 5c5492cbc3..d9a8e5378a 100644 --- a/protocols/IcqOscarJ/src/icq_http.cpp +++ b/protocols/IcqOscarJ/src/icq_http.cpp @@ -101,7 +101,7 @@ int icq_httpGatewayBegin(HANDLE hConn, NETLIBOPENCONNECTION* nloc) -int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend) +int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags) { PBYTE sendBuf = buf; int sendLen = len; @@ -119,8 +119,7 @@ int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDA write_httphdr(&packet, HTTP_PACKETTYPE_FLAP, GetGatewayIndex(hConn)); packBuffer(&packet, sendBuf, curLen); - NETLIBBUFFER nlb={ (char*)packet.pData, packet.wLen, flags }; - curResult = pfnNetlibSend((WPARAM)hConn, (LPARAM)&nlb); + curResult = Netlib_Send(hConn, (char*)packet.pData, packet.wLen, flags); SAFE_FREE((void**)&packet.pData); diff --git a/protocols/IcqOscarJ/src/icq_http.h b/protocols/IcqOscarJ/src/icq_http.h index fb4b948770..0f2eb6a394 100644 --- a/protocols/IcqOscarJ/src/icq_http.h +++ b/protocols/IcqOscarJ/src/icq_http.h @@ -37,7 +37,7 @@ int icq_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr); int icq_httpGatewayBegin(HANDLE hConn, NETLIBOPENCONNECTION *nloc); -int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend); +int icq_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags); PBYTE icq_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr, PBYTE buf, int bufLen, int *outBufLen, void *(*NetlibRealloc)(void *, size_t)); int icq_httpGatewayWalkTo(HANDLE hConn, NETLIBOPENCONNECTION* nloc); diff --git a/protocols/MSN/src/msn_http.cpp b/protocols/MSN/src/msn_http.cpp index 7ea45b5a8a..74a0f66fb7 100644 --- a/protocols/MSN/src/msn_http.cpp +++ b/protocols/MSN/src/msn_http.cpp @@ -52,7 +52,7 @@ int msn_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION*, NETLIBHTTPREQUEST*) // function generates the initial URL depending on a thread type //======================================================================================= -int msn_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend) +int msn_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags) { ThreadData *T = FindThreadConn(hConn); if (T != NULL) { @@ -62,8 +62,7 @@ int msn_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDA T->applyGatewayData(hConn, len == 0); } - NETLIBBUFFER tBuf = { (char*)buf, len, flags }; - return pfnNetlibSend((LPARAM)hConn, WPARAM(&tBuf)); + return Netlib_Send(hConn, (char*)buf, len, flags); } //======================================================================================= diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index ce4d563de3..1efe0b33d9 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -25,7 +25,7 @@ static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int msn_httpGatewayInit(HANDLE hConn,NETLIBOPENCONNECTION *nloc,NETLIBHTTPREQUEST *nlhr); int msn_httpGatewayBegin(HANDLE hConn,NETLIBOPENCONNECTION *nloc); -int msn_httpGatewayWrapSend(HANDLE hConn,PBYTE buf,int len,int flags,MIRANDASERVICE pfnNetlibSend); +int msn_httpGatewayWrapSend(HANDLE hConn,PBYTE buf,int len,int flags); PBYTE msn_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr,PBYTE buf,int len,int *outBufLen,void *(*NetlibRealloc)(void*,size_t)); static int CompareLists(const MsnContact *p1, const MsnContact *p2) diff --git a/protocols/MSN/src/msn_ws.cpp b/protocols/MSN/src/msn_ws.cpp index d087f579c0..1c7dcd07e9 100644 --- a/protocols/MSN/src/msn_ws.cpp +++ b/protocols/MSN/src/msn_ws.cpp @@ -27,8 +27,6 @@ along with this program. If not, see . int ThreadData::send(const char data[], size_t datalen) { - NETLIBBUFFER nlb = { (char*)data, (int)datalen, 0 }; - resetTimeout(); if (proto->usingGateway && !(mType == SERVER_FILETRANS || mType == SERVER_P2P_DIRECT)) { @@ -36,7 +34,7 @@ int ThreadData::send(const char data[], size_t datalen) CallService(MS_NETLIB_SETPOLLINGTIMEOUT, WPARAM(s), mGatewayTimeout); } - int rlen = CallService(MS_NETLIB_SEND, (WPARAM)s, (LPARAM)&nlb); + int rlen = Netlib_Send(s, data, (int)datalen); if (rlen == SOCKET_ERROR) { // should really also check if sendlen is the same as datalen proto->debugLogA("Send failed: %d", WSAGetLastError()); @@ -113,8 +111,6 @@ bool ThreadData::isTimeout(void) int ThreadData::recv(char* data, size_t datalen) { - NETLIBBUFFER nlb = { data, (int)datalen, 0 }; - if (!proto->usingGateway) { resetTimeout(); NETLIBSELECT nls = { 0 }; @@ -137,7 +133,7 @@ int ThreadData::recv(char* data, size_t datalen) } LBL_RecvAgain: - int ret = CallService(MS_NETLIB_RECV, (WPARAM)s, (LPARAM)&nlb); + int ret = Netlib_Recv(s, data, (int)datalen); if (ret == 0) { proto->debugLogA("Connection closed gracefully"); return 0; diff --git a/protocols/WhatsApp/src/WASocketConnection.cpp b/protocols/WhatsApp/src/WASocketConnection.cpp index b6ec0c0998..03ebf84ea7 100644 --- a/protocols/WhatsApp/src/WASocketConnection.cpp +++ b/protocols/WhatsApp/src/WASocketConnection.cpp @@ -30,12 +30,7 @@ void WASocketConnection::write(int i) char buffer; buffer = (char)i; - NETLIBBUFFER nlb; - nlb.buf = &buffer; - nlb.len = 1; - nlb.flags = MSG_NOHTTPGATEWAYWRAP | MSG_NODUMP; - - int result = CallService(MS_NETLIB_SEND, WPARAM(this->hConn), LPARAM(&nlb)); + int result = Netlib_Send(this->hConn, &buffer, 1, MSG_NOHTTPGATEWAYWRAP | MSG_NODUMP); if (result < 1) throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_SEND); } @@ -49,13 +44,8 @@ void WASocketConnection::flush() {} void WASocketConnection::write(const std::vector &bytes, int length) { - NETLIBBUFFER nlb; std::string tmpBuf = std::string(bytes.begin(), bytes.end()); - nlb.buf = (char*)&(tmpBuf.c_str()[0]); - nlb.len = length; - nlb.flags = MSG_NODUMP; - - int result = CallService(MS_NETLIB_SEND, WPARAM(hConn), LPARAM(&nlb)); + int result = Netlib_Send(hConn, tmpBuf.c_str(), length, MSG_NODUMP); if (result < length) throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_SEND); } -- cgit v1.2.3