From d3cb19278d60ac6f7963379254546cdca36a90e2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 14 Jan 2017 01:22:55 +0300 Subject: separate handle types for HNETLIBCONN & HNETLIBBIND --- protocols/JabberG/src/jabber_byte.cpp | 15 ++++++--------- protocols/JabberG/src/jabber_byte.h | 4 ++-- protocols/JabberG/src/jabber_file.cpp | 9 ++++----- protocols/JabberG/src/jabber_ft.cpp | 4 ++-- protocols/JabberG/src/jabber_ibb.h | 2 +- protocols/JabberG/src/jabber_proto.h | 18 +++++++++--------- protocols/JabberG/src/jabber_util.cpp | 2 +- protocols/JabberG/src/jabber_ws.cpp | 6 +++--- protocols/JabberG/src/stdafx.h | 5 ++--- 9 files changed, 30 insertions(+), 35 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index 95a9976176..512c67197c 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -80,7 +80,7 @@ void CJabberProto::IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo *pInfo) SetEvent(jbt->hProxyEvent); } -void JabberByteSendConnection(HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra) +void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* extra) { CJabberProto *ppro = (CJabberProto*)extra; wchar_t szPort[8]; @@ -193,7 +193,6 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) localAddr = getStringA("BsDirectAddr"); NETLIBBIND nlb = {}; - nlb.cbSize = sizeof(NETLIBBIND); nlb.pfnNewConnectionV2 = JabberByteSendConnection; nlb.pExtra = this; nlb.wPort = 0; // Use user-specified incoming port ranges, if available @@ -315,7 +314,7 @@ void CJabberProto::ByteInitiateResult(HXML iqNode, CJabberIqInfo *pInfo) SetEvent(jbt->hProxyEvent); } -int CJabberProto::ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen) +int CJabberProto::ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen) { int nMethods; BYTE data[10]; @@ -428,7 +427,6 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) { wchar_t *szHost, *szPort; WORD port; - HANDLE hConn; char data[3]; char* buffer; int datalen, bytesParsed, recvResult; @@ -454,7 +452,7 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) nloc.cbSize = sizeof(nloc); nloc.szHost = mir_u2a(szHost); nloc.wPort = port; - hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc); + HNETLIBCONN hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc); mir_free((void*)nloc.szHost); if (hConn != NULL) { @@ -490,7 +488,7 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas")); } -int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen) +int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen) { int num = datalen; @@ -593,7 +591,6 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) const wchar_t *sid = NULL, *from = NULL, *to = NULL, *szId = NULL, *szHost, *szPort, *str; int i; WORD port; - HANDLE hConn; char data[3]; char* buffer; int datalen, bytesParsed, recvResult; @@ -634,7 +631,7 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) nloc.cbSize = sizeof(nloc); nloc.szHost = mir_u2a(szHost); nloc.wPort = port; - hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc); + HNETLIBCONN hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc); mir_free((void*)nloc.szHost); if (hConn == NULL) { @@ -686,7 +683,7 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) debugLogA("Thread ended: type=bytestream_recv"); } -int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen) +int CJabberProto::ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen) { int bytesReceived, num = datalen; diff --git a/protocols/JabberG/src/jabber_byte.h b/protocols/JabberG/src/jabber_byte.h index 3b6b8423b3..b89c12a711 100644 --- a/protocols/JabberG/src/jabber_byte.h +++ b/protocols/JabberG/src/jabber_byte.h @@ -44,8 +44,8 @@ struct JABBER_BYTE_TRANSFER HANDLE hConn; HANDLE hEvent; HXML iqNode; - BOOL (CJabberProto::*pfnSend)(HANDLE hConn, filetransfer *ft); - int (CJabberProto::*pfnRecv)(HANDLE hConn, filetransfer *ft, char* buffer, int datalen); + BOOL (CJabberProto::*pfnSend)(HNETLIBCONN hConn, filetransfer *ft); + int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft); filetransfer *ft; diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 2ac8d9b0c3..0d9904899f 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -171,7 +171,7 @@ int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen) return num; } -void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, void* extra) +void JabberFileServerConnection(HNETLIBCONN hConnection, DWORD /*dwRemoteIP*/, void* extra) { CJabberProto *ppro = (CJabberProto*)extra; @@ -190,7 +190,7 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, } filetransfer *ft = item->ft; - JABBER_SOCKET slisten = ft->s; + HNETLIBCONN slisten = ft->s; ft->s = hConnection; ppro->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten); @@ -241,12 +241,11 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) ft->type = FT_OOB; NETLIBBIND nlb = {}; - nlb.cbSize = sizeof(NETLIBBIND); nlb.pfnNewConnectionV2 = JabberFileServerConnection; nlb.pExtra = this; nlb.wPort = 0; // Use user-specified incoming port ranges, if available - info.s = Netlib_BindPort(m_hNetlibUser, &nlb); + info.s = (HNETLIBCONN)Netlib_BindPort(m_hNetlibUser, &nlb); if (info.s == NULL) { debugLogA("Cannot allocate port to bind for file server thread, thread ended."); ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); @@ -341,7 +340,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) delete ft; } -int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer, int datalen) +int CJabberProto::FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, int datalen) { char* p, *q, *eob; char* str; diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 76f3c99cac..eb34f5afe4 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -180,7 +180,7 @@ void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo) } } -BOOL CJabberProto::FtSend(HANDLE hConn, filetransfer *ft) +BOOL CJabberProto::FtSend(HNETLIBCONN hConn, filetransfer *ft) { struct _stati64 statbuf; int fd; @@ -532,7 +532,7 @@ BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen) return FALSE; } -int CJabberProto::FtReceive(HANDLE, filetransfer *ft, char* buffer, int datalen) +int CJabberProto::FtReceive(HNETLIBCONN, filetransfer *ft, char* buffer, int datalen) { if (ft->create() == -1) return -1; diff --git a/protocols/JabberG/src/jabber_ibb.h b/protocols/JabberG/src/jabber_ibb.h index 6680829881..a835ecaa94 100644 --- a/protocols/JabberG/src/jabber_ibb.h +++ b/protocols/JabberG/src/jabber_ibb.h @@ -39,7 +39,7 @@ typedef struct { BOOL bStreamClosed; WORD wPacketId; BOOL (CJabberProto::*pfnSend)(int blocksize, filetransfer *ft); - int (CJabberProto::*pfnRecv)(HANDLE hConn, filetransfer *ft, char* buffer, int datalen); + int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft); filetransfer *ft; } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 9eb9640ea6..f62d73c528 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -303,10 +303,10 @@ struct CJabberProto : public PROTO, public IJabberInterface void IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo *pInfo); void ByteInitiateResult(HXML iqNode, CJabberIqInfo *pInfo); void ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt); - int ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); + int ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); void IqResultStreamActivate(HXML iqNode, CJabberIqInfo *pInfo); - int ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); - int ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); + int ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); + int ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); //---- jabber_caps.cpp --------------------------------------------------------------- @@ -378,7 +378,7 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_file.cpp --------------------------------------------------------------- int FileReceiveParse(filetransfer *ft, char* buffer, int datalen); - int FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer, int datalen); + int FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, int datalen); void UpdateChatUserStatus(wchar_t* chat_jid, wchar_t* jid, wchar_t* nick, int role, int affil, int status, BOOL update_nick); @@ -498,9 +498,9 @@ struct CJabberProto : public PROTO, public IJabberInterface void OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo); BOOL FtIbbSend(int blocksize, filetransfer *ft); - BOOL FtSend(HANDLE hConn, filetransfer *ft); + BOOL FtSend(HNETLIBCONN hConn, filetransfer *ft); void FtSendFinal(BOOL success, filetransfer *ft); - int FtReceive(HANDLE hConn, filetransfer *ft, char* buffer, int datalen); + int FtReceive(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); void FtReceiveFinal(BOOL success, filetransfer *ft); //---- jabber_iqid.cpp --------------------------------------------------------------- @@ -765,12 +765,12 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_ws.c ------------------------------------------------- - JABBER_SOCKET WsConnect(char* host, WORD port); + HNETLIBCONN WsConnect(char* host, WORD port); BOOL WsInit(void); void WsUninit(void); - int WsSend(JABBER_SOCKET s, char* data, int datalen, int flags); - int WsRecv(JABBER_SOCKET s, char* data, long datalen, int flags); + int WsSend(HNETLIBCONN s, char* data, int datalen, int flags); + int WsRecv(HNETLIBCONN s, char* data, long datalen, int flags); //---- jabber_xml.c ------------------------------------------------------------------ diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 86850775aa..11185bd6b4 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -889,7 +889,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) Thread_SetName("Jabber: LoadHttpAvatars"); OBJLIST &avs = *(OBJLIST*)param; - HANDLE hHttpCon = NULL; + HNETLIBCONN hHttpCon = NULL; for (int i = 0; i < avs.getCount(); i++) { NETLIBHTTPREQUEST nlhr = { 0 }; nlhr.cbSize = sizeof(nlhr); diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp index 92dab17061..db491e365b 100644 --- a/protocols/JabberG/src/jabber_ws.cpp +++ b/protocols/JabberG/src/jabber_ws.cpp @@ -45,7 +45,7 @@ void CJabberProto::WsUninit(void) m_hNetlibUser = NULL; } -JABBER_SOCKET CJabberProto::WsConnect(char* host, WORD port) +HNETLIBCONN CJabberProto::WsConnect(char* host, WORD port) { NETLIBOPENCONNECTION nloc = {}; nloc.cbSize = sizeof(nloc); @@ -55,7 +55,7 @@ JABBER_SOCKET CJabberProto::WsConnect(char* host, WORD port) return Netlib_OpenConnection(m_hNetlibUser, &nloc); } -int CJabberProto::WsSend(JABBER_SOCKET hConn, char* data, int datalen, int flags) +int CJabberProto::WsSend(HNETLIBCONN hConn, char* data, int datalen, int flags) { m_lastTicks = ::GetTickCount(); int len; @@ -67,7 +67,7 @@ int CJabberProto::WsSend(JABBER_SOCKET hConn, char* data, int datalen, int flags return len; } -int CJabberProto::WsRecv(JABBER_SOCKET hConn, char* data, long datalen, int flags) +int CJabberProto::WsRecv(HNETLIBCONN hConn, char* data, long datalen, int flags) { int ret; diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 1d09f4d866..df2533fbfc 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -336,7 +336,6 @@ struct CJabberHttpAuthParams /******************************************************************* * Global data structures and data type definitions *******************************************************************/ -typedef HANDLE JABBER_SOCKET; #define CAPS_BOOKMARK 0x0001 #define CAPS_BOOKMARKS_LOADED 0x8000 @@ -371,7 +370,7 @@ struct ThreadData char* buffer; // network support - JABBER_SOCKET s; + HNETLIBCONN s; HANDLE iomutex; // protects i/o operations CJabberProto *proto; @@ -442,7 +441,7 @@ struct filetransfer PROTOFILETRANSFERSTATUS std; JABBER_FT_TYPE type; - JABBER_SOCKET s; + HNETLIBCONN s; JABBER_FILE_STATE state; wchar_t *jid; int fileId; -- cgit v1.2.3