diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-13 00:01:59 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-13 00:01:59 +0300 |
commit | e145db68fb5b7d0682a4b2be0174cebfe47dd74e (patch) | |
tree | c8f9edc907876d236eb16bc8ca8b592accb9846f /protocols | |
parent | 3cb3883908e3168e5f955be3143771721614307a (diff) |
a bit less netlib services
Diffstat (limited to 'protocols')
39 files changed, 151 insertions, 155 deletions
diff --git a/protocols/AimOscar/src/connection.cpp b/protocols/AimOscar/src/connection.cpp index 15e88e87af..a3635cdcfc 100755 --- a/protocols/AimOscar/src/connection.cpp +++ b/protocols/AimOscar/src/connection.cpp @@ -28,7 +28,7 @@ HANDLE CAimProto::aim_connect(const char* server, unsigned short port, bool use_ ncon.timeout = 6;
ncon.flags = NLOCF_V2;
debugLogA("%s:%u", server, port);
- HANDLE con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&ncon);
+ HANDLE con = Netlib_OpenConnection(m_hNetlibUser, &ncon);
if (con && use_ssl) {
NETLIBSSL ssl = { 0 };
ssl.cbSize = sizeof(ssl);
@@ -49,7 +49,7 @@ HANDLE CAimProto::aim_peer_connect(const char* ip, unsigned short port) ncon.szHost = ip;
ncon.wPort = port;
ncon.timeout = 3;
- return (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibPeer, (LPARAM)&ncon);
+ return Netlib_OpenConnection(m_hNetlibPeer, &ncon);
}
HANDLE CAimProto::aim_peer_connect(unsigned long ip, unsigned short port)
@@ -68,12 +68,12 @@ void CAimProto::aim_connection_authorization(void) mir_free(m_username);
m_username = getStringA(AIM_KEY_SN);
if (m_username != NULL) {
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hServerConn, 2048 * 4);
- NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(m_hServerConn, 2048 * 4);
+
+ NETLIBPACKETRECVER packetRecv = {};
packetRecv.dwTimeout = 5000;
for (;;) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)& packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0) {
debugLogA("Connection Closed: No Error? during Connection Authorization");
break;
@@ -347,15 +347,12 @@ void CAimProto::aim_connection_clientlogin(void) void __cdecl CAimProto::aim_protocol_negotiation(void*)
{
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hServerConn, 2048 * 8);
-
-
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(m_hServerConn, 2048 * 8);
- NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
+ NETLIBPACKETRECVER packetRecv = {};
packetRecv.dwTimeout = DEFAULT_KEEPALIVE_TIMER * 1000;
for (;;) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0) {
debugLogA("Connection Closed: No Error during Connection Negotiation?");
break;
@@ -477,13 +474,13 @@ exit: void __cdecl CAimProto::aim_mail_negotiation(void*)
{
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hMailConn, 2048 * 8);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(m_hMailConn, 2048 * 8);
NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
packetRecv.dwTimeout = DEFAULT_KEEPALIVE_TIMER * 1000;
+
while (m_iStatus != ID_STATUS_OFFLINE) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0)
break;
@@ -539,13 +536,13 @@ exit: void __cdecl CAimProto::aim_avatar_negotiation(void*)
{
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hAvatarConn, 2048 * 8);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(m_hAvatarConn, 2048 * 8);
NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
packetRecv.dwTimeout = 300000;//5 minutes connected
+
for (;;) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)& packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0)
break;
@@ -599,13 +596,13 @@ exit: void __cdecl CAimProto::aim_chatnav_negotiation(void*)
{
unsigned idle_chat = 0;
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hChatNavConn, 2048 * 8);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(m_hChatNavConn, 2048 * 8);
NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
packetRecv.dwTimeout = DEFAULT_KEEPALIVE_TIMER * 1000;
+
for (;;) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0)
break;
@@ -668,13 +665,13 @@ exit: void __cdecl CAimProto::aim_chat_negotiation(void* param)
{
chat_list_item *item = (chat_list_item*)param;
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)item->hconn, 2048 * 8);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(item->hconn, 2048 * 8);
NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
packetRecv.dwTimeout = DEFAULT_KEEPALIVE_TIMER * 1000;
+
for (;;) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0)
break;
@@ -733,13 +730,13 @@ exit: void __cdecl CAimProto::aim_admin_negotiation(void*)
{
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hAdminConn, 2048 * 8);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(m_hAdminConn, 2048 * 8);
+
+ NETLIBPACKETRECVER packetRecv = {};
+ packetRecv.dwTimeout = 300000; // 5 minutes connected
- NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
- packetRecv.dwTimeout = 300000;//5 minutes connected
for (;;) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)& packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0)
break;
diff --git a/protocols/AimOscar/src/defines.h b/protocols/AimOscar/src/defines.h index 2caf13aa05..11126ac2fb 100644 --- a/protocols/AimOscar/src/defines.h +++ b/protocols/AimOscar/src/defines.h @@ -305,7 +305,7 @@ public: unsigned short LocalPort;// our port
//Peer connection stuff
- HANDLE m_hNetlibPeer;//handle to the peer netlib
+ HNETLIBUSER m_hNetlibPeer;//handle to the peer netlib
HANDLE hDirectBoundPort;//direct connection listening port
HANDLE current_rendezvous_accept_user;//hack
diff --git a/protocols/AimOscar/src/direct_connect.cpp b/protocols/AimOscar/src/direct_connect.cpp index fa1f8ea22c..2b4bcb9366 100644 --- a/protocols/AimOscar/src/direct_connect.cpp +++ b/protocols/AimOscar/src/direct_connect.cpp @@ -25,11 +25,10 @@ void __cdecl CAimProto::aim_dc_helper(void* param) //only called when we are ini ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, ft, 0);
- NETLIBPACKETRECVER packetRecv = { 0 };
- packetRecv.cbSize = sizeof(packetRecv);
+ NETLIBPACKETRECVER packetRecv = {};
packetRecv.dwTimeout = 350000;
- HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)ft->hConn, 2048 * 4);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(ft->hConn, 2048 * 4);
int result;
if (ft->sending)//we are sending
diff --git a/protocols/AimOscar/src/file.cpp b/protocols/AimOscar/src/file.cpp index 007359eb8f..cdb81e03b6 100644 --- a/protocols/AimOscar/src/file.cpp +++ b/protocols/AimOscar/src/file.cpp @@ -154,7 +154,7 @@ int CAimProto::sending_file(file_transfer *ft, HANDLE hServerPacketRecver, NETLI for (;;) {
int recvResult = packetRecv.bytesAvailable - packetRecv.bytesUsed;
if (recvResult <= 0)
- recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0) {
debugLogA("P2P: File transfer connection Error: 0");
break;
@@ -272,7 +272,7 @@ int CAimProto::receiving_file(file_transfer *ft, HANDLE hServerPacketRecver, NET for (;;) {
int recvResult = packetRecv.bytesAvailable - packetRecv.bytesUsed;
if (recvResult <= 0)
- recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0) {
debugLogA("P2P: File transfer connection Error: 0");
break;
@@ -529,11 +529,11 @@ void file_transfer::listen(CAimProto* ppro) {
if (hDirectBoundPort) return;
- NETLIBBIND nlb = { 0 };
+ NETLIBBIND nlb = {};
nlb.cbSize = sizeof(nlb);
nlb.pfnNewConnectionV2 = aim_direct_connection_initiated;
nlb.pExtra = ppro;
- hDirectBoundPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)ppro->m_hNetlibPeer, (LPARAM)&nlb);
+ hDirectBoundPort = Netlib_BindPort(ppro->m_hNetlibPeer, &nlb);
local_port = hDirectBoundPort ? nlb.wPort : 0;
}
diff --git a/protocols/AimOscar/src/proto.h b/protocols/AimOscar/src/proto.h index 79980483eb..f2a31d60d6 100755 --- a/protocols/AimOscar/src/proto.h +++ b/protocols/AimOscar/src/proto.h @@ -129,7 +129,7 @@ struct CAimProto : public PROTO<CAimProto> unsigned short m_local_port; // our port
//Peer connection stuff
- HANDLE m_hNetlibPeer;//handle to the peer netlib
+ HNETLIBUSER m_hNetlibPeer;//handle to the peer netlib
HANDLE m_hDirectBoundPort;//direct connection listening port
//Handles for the context menu items
diff --git a/protocols/AimOscar/src/proxy.cpp b/protocols/AimOscar/src/proxy.cpp index 10e04df718..d3ac4deebe 100644 --- a/protocols/AimOscar/src/proxy.cpp +++ b/protocols/AimOscar/src/proxy.cpp @@ -34,14 +34,13 @@ void __cdecl CAimProto::aim_proxy_helper(void* param) }
//start listen for packets stuff
- NETLIBPACKETRECVER packetRecv = {0};
- packetRecv.cbSize = sizeof(packetRecv);
+ NETLIBPACKETRECVER packetRecv = {};
packetRecv.dwTimeout = INFINITE;
- HANDLE hServerPacketRecver = (HANDLE) CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)ft->hConn, 2048 * 4);
+ HANDLE hServerPacketRecver = Netlib_CreatePacketReceiver(ft->hConn, 2048 * 4);
for (;;)
{
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hServerPacketRecver, &packetRecv);
if (recvResult == 0)
{
ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp index 7454383878..d17ccf4952 100644 --- a/protocols/Discord/src/gateway.cpp +++ b/protocols/Discord/src/gateway.cpp @@ -102,7 +102,7 @@ void CDiscordProto::GatewayThreadWorker() } else conn.wPort = 443; - m_hGatewayConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hGatewayNetlibUser, (LPARAM)&conn); + m_hGatewayConnection = Netlib_OpenConnection(m_hGatewayNetlibUser, &conn); if (m_hGatewayConnection == NULL) { debugLogA("Gateway connection failed to connect to %s:%d, exiting", m_szGateway.c_str(), conn.wPort); return; diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 15a6a9eeeb..22fe036f5b 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -145,9 +145,8 @@ class CDiscordProto : public PROTO<CDiscordProto> m_szGateway, // gateway url m_szGatewaySessionId; // current session id - HANDLE - m_hGatewayNetlibUser, // the separate netlib user handle for gateways - m_hGatewayConnection; // gateway connection + HNETLIBUSER m_hGatewayNetlibUser; // the separate netlib user handle for gateways + HANDLE m_hGatewayConnection; // gateway connection void __cdecl GatewayThread(void*); void CDiscordProto::GatewayThreadWorker(void); diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 000edf3ed9..f619bab6ea 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -284,7 +284,7 @@ void __cdecl GGPROTO::mainthread(void *) // Setup proxy
nlus.cbSize = sizeof(nlus);
- if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus)) {
+ if (Netlib_GetUserSettings(m_hNetlibUser, &nlus)) {
if (nlus.useProxy)
debugLogA("mainthread() (%x): Using proxy %s:%d.", this, nlus.szProxyServer, nlus.wProxyPort);
gg_proxy_enabled = nlus.useProxy;
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 84b5d6476e..3235e06a76 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -198,11 +198,10 @@ bool CIrcProto::Connect(const CIrcSessionInfo& info) ncon.cbSize = sizeof(ncon); ncon.szHost = info.sServer.c_str(); ncon.wPort = info.iPort; - con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&ncon); + con = Netlib_OpenConnection(m_hNetlibUser, &ncon); if (con == NULL) { wchar_t szTemp[300]; - mir_snwprintf(szTemp, L"\0035%s \002%s\002 (%S: %u).", - TranslateT("Failed to connect to"), si.sNetwork.c_str(), si.sServer.c_str(), si.iPort); + mir_snwprintf(szTemp, L"\0035%s \002%s\002 (%S: %u).", TranslateT("Failed to connect to"), si.sNetwork.c_str(), si.sServer.c_str(), si.iPort); DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false); return false; } @@ -358,12 +357,13 @@ void CIrcProto::DoReceive() int cbInBuf = 0; if (m_info.bIdentServer && m_info.iIdentServerPort != NULL) { - NETLIBBIND nb = { 0 }; + NETLIBBIND nb = {}; nb.cbSize = sizeof(NETLIBBIND); nb.pfnNewConnectionV2 = DoIdent; nb.pExtra = this; nb.wPort = m_info.iIdentServerPort; - hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nb); + + hBindPort = Netlib_BindPort(m_hNetlibUser, &nb); if (!hBindPort || nb.wPort != m_info.iIdentServerPort) { debugLogA("Error: unable to bind local port %u", m_info.iIdentServerPort); KillIdent(); @@ -874,13 +874,13 @@ int CDccSession::SetupConnection() // create a listening socket for outgoing chat/send requests. The remote computer connects to this computer. Used for both chat and filetransfer. if (di->bSender && !di->bReverse) { - NETLIBBIND nb = { 0 }; + NETLIBBIND nb = {}; nb.cbSize = sizeof(NETLIBBIND); nb.pfnNewConnectionV2 = DoIncomingDcc; // this is the (helper) function to be called once an incoming connection is made. The 'real' function that is called is IncomingConnection() nb.pExtra = (void *)this; nb.wPort = 0; - hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&nb); - + + hBindPort = Netlib_BindPort(m_proto->hNetlibDCC, &nb); if (hBindPort == NULL) { delete this; // dcc objects destroy themselves when the connection has been closed or failed for some reasson. return 0; @@ -897,7 +897,7 @@ int CDccSession::SetupConnection() ncon.cbSize = sizeof(ncon); ncon.szHost = ConvertIntegerToIP(di->dwAdr); ncon.wPort = (WORD)di->iPort; - con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&ncon); + con = Netlib_OpenConnection(m_proto->hNetlibDCC, &ncon); } // If a remote computer initiates a filetransfer this is used to connect to that computer (the user has chosen to accept but it is possible the file exists/needs to be resumed etc still) @@ -953,13 +953,13 @@ int CDccSession::SetupConnection() // hack for passive filetransfers if (di->iType == DCC_SEND && !di->bSender && di->bReverse) { - NETLIBBIND nb = { 0 }; + NETLIBBIND nb = {}; nb.cbSize = sizeof(NETLIBBIND); nb.pfnNewConnectionV2 = DoIncomingDcc; // this is the (helper) function to be called once an incoming connection is made. The 'real' function that is called is IncomingConnection() nb.pExtra = (void *)this; nb.wPort = 0; - hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&nb); + hBindPort = Netlib_BindPort(m_proto->hNetlibDCC, &nb); if (hBindPort == NULL) { m_proto->DoEvent(GC_EVENT_INFORMATION, 0, m_proto->m_info.sNick.c_str(), LPGENW("DCC ERROR: Unable to bind local port for passive file transfer"), NULL, NULL, NULL, true, false); delete this; // dcc objects destroy themselves when the connection has been closed or failed for some reasson. @@ -995,7 +995,7 @@ int CDccSession::SetupConnection() ncon.szHost = ConvertIntegerToIP(di->dwAdr); ncon.wPort = (WORD)di->iPort; - con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_proto->hNetlibDCC, (LPARAM)&ncon); + con = Netlib_OpenConnection(m_proto->hNetlibDCC, &ncon); } // if for some reason the plugin has failed to connect to the remote computer the object is destroyed. @@ -1097,12 +1097,11 @@ void CDccSession::DoSendFile() tLastActivity = time(0); // create a packet receiver to handle receiving ack's from the remote computer. - HANDLE hPackrcver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)con, sizeof(DWORD)); - NETLIBPACKETRECVER npr; - npr.cbSize = sizeof(NETLIBPACKETRECVER); + HANDLE hPackrcver = Netlib_CreatePacketReceiver(con, sizeof(DWORD)); + + NETLIBPACKETRECVER npr = {}; npr.dwTimeout = 60 * 1000; npr.bufferSize = sizeof(DWORD); - npr.bytesUsed = 0; // until the connection is dropped it will spin around in this while() loop while (con) { @@ -1127,7 +1126,7 @@ void CDccSession::DoSendFile() DWORD dwPacket = NULL; do { - dwRead = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPackrcver, (LPARAM)&npr); + dwRead = Netlib_GetMorePackets(hPackrcver, &npr); npr.bytesUsed = sizeof(DWORD); if (dwRead <= 0) @@ -1148,7 +1147,7 @@ void CDccSession::DoSendFile() DWORD dwPacket = 0; do { - dwRead = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPackrcver, (LPARAM)&npr); + dwRead = Netlib_GetMorePackets(hPackrcver, &npr); npr.bytesUsed = sizeof(DWORD); if (dwRead <= 0) break; // connection closed, or a timeout occurred. diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index 7010ac4931..ca32a61167 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -343,8 +343,8 @@ struct CIrcProto : public PROTO<CIrcProto> DWORD m_bConnectRequested;
DWORD m_bConnectThreadRunning;
- HGENMENU hMenuQuick, hMenuServer, hMenuJoin, hMenuNick, hMenuList;
- HANDLE hNetlibDCC;
+ HGENMENU hMenuQuick, hMenuServer, hMenuJoin, hMenuNick, hMenuList;
+ HNETLIBUSER hNetlibDCC;
bool bTempDisableCheck, bTempForceCheck, bEcho;
bool nickflag;
diff --git a/protocols/IcqOscarJ/src/chan_04close.cpp b/protocols/IcqOscarJ/src/chan_04close.cpp index c9d4157f8e..315b22c888 100644 --- a/protocols/IcqOscarJ/src/chan_04close.cpp +++ b/protocols/IcqOscarJ/src/chan_04close.cpp @@ -142,7 +142,7 @@ int CIcqProto::connectNewServer(serverthread_info *info) if (hServerConn) {
/* Time to recreate the packet receiver */
- info->hPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)hServerConn, 0x2400);
+ info->hPacketRecver = Netlib_CreatePacketReceiver(hServerConn, 0x2400);
if (!info->hPacketRecver)
debugLogA("Error: Failed to create packet receiver.");
else { // we need to reset receiving structs
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 6fd71d67e0..ad93fb8065 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -879,14 +879,14 @@ void avatars_server_connection::checkRequestQueue() void avatars_server_connection::connectionThread()
{
// This is the "infinite" loop that receives the packets from the ICQ avatar server
- NETLIBPACKETRECVER packetRecv = { 0 };
DWORD dwLastKeepAlive = time(0) + KEEPALIVE_INTERVAL;
- hPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)hConnection, 65536);
- packetRecv.cbSize = sizeof(packetRecv);
+ hPacketRecver = Netlib_CreatePacketReceiver(hConnection, 65536);
+
+ NETLIBPACKETRECVER packetRecv = {};
packetRecv.dwTimeout = 1000; // timeout - for stopThread to work
while (!stopThread) {
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hPacketRecver, &packetRecv);
if (recvResult == 0) {
ppro->debugLogA("Clean closure of avatar socket");
break;
diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp index 59cc9bc35b..d87b215704 100644 --- a/protocols/IcqOscarJ/src/icq_direct.cpp +++ b/protocols/IcqOscarJ/src/icq_direct.cpp @@ -194,9 +194,8 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi) {
Thread_SetName("ICQ: directThread");
+ NETLIBPACKETRECVER packetRecv = {};
directconnect dc = { 0 };
- NETLIBPACKETRECVER packetRecv = { 0 };
- HANDLE hPacketRecver;
BOOL bFirstPacket = TRUE;
size_t nSkipPacketBytes = 0;
DWORD dwReqMsgID1 = 0, dwReqMsgID2 = 0;
@@ -333,16 +332,14 @@ void __cdecl CIcqProto::icq_directThread(directthreadstartinfo *dtsi) }
}
- hPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)dc.hConnection, 8192);
- packetRecv.cbSize = sizeof(packetRecv);
- packetRecv.bytesUsed = 0;
+ HANDLE hPacketRecver = Netlib_CreatePacketReceiver(dc.hConnection, 8192);
// Packet receiving loop
while (dc.hConnection) {
packetRecv.dwTimeout = dc.wantIdleTime ? 0 : 600000;
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hPacketRecver, &packetRecv);
if (recvResult == 0) {
NetLog_Direct("Clean closure of direct socket (%p)", dc.hConnection);
break;
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp index 87e1007267..1de0a261e5 100644 --- a/protocols/IcqOscarJ/src/icq_server.cpp +++ b/protocols/IcqOscarJ/src/icq_server.cpp @@ -107,17 +107,16 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam) // This is the "infinite" loop that receives the packets from the ICQ server
NETLIBPACKETRECVER packetRecv;
- info.hPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)hServerConn, 0x2400);
+ info.hPacketRecver = Netlib_CreatePacketReceiver(hServerConn, 0x2400);
while (serverThreadHandle) {
if (info.bReinitRecver) { // we reconnected, reinit struct
info.bReinitRecver = false;
memset(&packetRecv, 0, sizeof(packetRecv));
- packetRecv.cbSize = sizeof(packetRecv);
packetRecv.dwTimeout = 1000;
}
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)info.hPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(info.hPacketRecver, &packetRecv);
if (recvResult == 0) {
debugLogA("Clean closure of server socket");
break;
diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index 57277b4a51..20d7165643 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -157,7 +157,7 @@ void CIcqProto::UpdateGlobalSettings() if (m_hNetlibUser) {
NETLIBUSERSETTINGS nlus = { sizeof(NETLIBUSERSETTINGS) };
- if ( !m_bSecureConnection && CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus)) {
+ if (!m_bSecureConnection && Netlib_GetUserSettings(m_hNetlibUser, &nlus)) {
if (nlus.useProxy && nlus.proxyType == PROXYTYPE_HTTP)
m_bGatewayMode = 1;
else
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index 5d5d480194..69ca05538a 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -1101,8 +1101,6 @@ void __cdecl CIcqProto::oft_connectionThread(oscarthreadstartinfo *otsi) {
oscar_connection oc = { 0 };
oscar_listener *source;
- NETLIBPACKETRECVER packetRecv = { 0 };
- HANDLE hPacketRecver;
Thread_SetName("ICQ: oft_connectionThread");
@@ -1299,15 +1297,16 @@ void __cdecl CIcqProto::oft_connectionThread(oscarthreadstartinfo *otsi) oft_sendPeerInit(&oc);
}
}
- hPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)oc.hConnection, 8192);
- packetRecv.cbSize = sizeof(packetRecv);
+
+ HANDLE hPacketRecver = Netlib_CreatePacketReceiver(oc.hConnection, 8192);
+ NETLIBPACKETRECVER packetRecv = {};
// Packet receiving loop
while (oc.hConnection) {
packetRecv.dwTimeout = oc.wantIdleTime ? 0 : 120000;
- int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hPacketRecver, (LPARAM)&packetRecv);
+ int recvResult = Netlib_GetMorePackets(hPacketRecver, &packetRecv);
if (!recvResult) {
NetLog_Direct("Clean closure of oscar socket (%p)", oc.hConnection);
break;
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 7ad7f12dbf..85a34e4238 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -1367,20 +1367,19 @@ HANDLE NetLib_OpenConnection(HNETLIBUSER hUser, const char* szIdent, NETLIBOPENC nloc->cbSize = sizeof(NETLIBOPENCONNECTION);
nloc->flags |= NLOCF_V2;
-
- return (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hUser, (LPARAM)nloc);
+ return Netlib_OpenConnection(hUser, nloc);
}
HANDLE CIcqProto::NetLib_BindPort(NETLIBNEWCONNECTIONPROC_V2 pFunc, void* lParam, WORD* pwPort, DWORD* pdwIntIP)
{
- NETLIBBIND nlb = { 0 };
+ NETLIBBIND nlb = {};
nlb.cbSize = sizeof(NETLIBBIND);
nlb.pfnNewConnectionV2 = pFunc;
nlb.pExtra = lParam;
SetLastError(ERROR_INVALID_PARAMETER); // this must be here - NetLib does not set any error :((
-
- HANDLE hBoundPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hDirectNetlibUser, (LPARAM)&nlb);
+
+ HANDLE hBoundPort = Netlib_BindPort(m_hDirectNetlibUser, &nlb);
if (pwPort) *pwPort = nlb.wPort;
if (pdwIntIP) *pdwIntIP = nlb.dwInternalIP;
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index 90cf6c6894..deefa4ebe7 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -192,20 +192,25 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) if (m_options.BsDirectManual)
localAddr = getStringA("BsDirectAddr");
- NETLIBBIND nlb = {0};
+ NETLIBBIND nlb = {};
nlb.cbSize = sizeof(NETLIBBIND);
nlb.pfnNewConnectionV2 = JabberByteSendConnection;
nlb.pExtra = this;
nlb.wPort = 0; // Use user-specified incoming port ranges, if available
- jbt->hConn = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlb);
+
+ jbt->hConn = Netlib_BindPort(m_hNetlibUser, &nlb);
if (jbt->hConn == NULL) {
debugLogA("Cannot allocate port for bytestream_send thread, thread ended.");
delete jbt;
return;
}
- if (localAddr == NULL)
- localAddr = (char*)CallService(MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP);
+ if (localAddr == NULL) {
+ sockaddr_in sin = {};
+ sin.sin_family = AF_INET;
+ sin.sin_addr.S_un.S_addr = nlb.dwExternalIP;
+ localAddr = Netlib_AddressToString(&sin);
+ }
mir_snwprintf(szPort, L"%d", nlb.wPort);
JABBER_LIST_ITEM *item = ListAdd(LIST_BYTE, szPort);
@@ -449,7 +454,7 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) nloc.cbSize = sizeof(nloc);
nloc.szHost = mir_u2a(szHost);
nloc.wPort = port;
- hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc);
mir_free((void*)nloc.szHost);
if (hConn != NULL) {
@@ -629,7 +634,7 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) nloc.cbSize = sizeof(nloc);
nloc.szHost = mir_u2a(szHost);
nloc.wPort = port;
- hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc);
mir_free((void*)nloc.szHost);
if (hConn == NULL) {
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index bfd730a73c..ff95251f6f 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -40,7 +40,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) nloc.cbSize = sizeof(nloc);
nloc.szHost = ft->httpHostName;
nloc.wPort = ft->httpPort;
- info.s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ info.s = Netlib_OpenConnection(m_hNetlibUser, &nloc);
if (info.s == NULL) {
debugLogA("Connection failed (%d), thread ended", WSAGetLastError());
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
@@ -240,12 +240,13 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) ThreadData info(this, NULL);
ft->type = FT_OOB;
- NETLIBBIND nlb = { 0 };
+ 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 = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlb);
+
+ info.s = 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);
@@ -286,8 +287,12 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) ptrA myAddr;
if (m_options.BsDirect && m_options.BsDirectManual)
myAddr = getStringA("BsDirectAddr");
- if (myAddr == NULL)
- myAddr = (char*)CallService(MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP);
+ if (myAddr == NULL) {
+ sockaddr_in sin = {};
+ sin.sin_family = AF_INET;
+ sin.sin_addr.S_un.S_addr = nlb.dwExternalIP;
+ myAddr = Netlib_AddressToString(&sin);
+ }
char szAddr[256];
mir_snprintf(szAddr, "http://%s:%d/%s", myAddr, nlb.wPort, pFileName);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 4820aafc0d..86850775aa 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 = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NETLIBHTTPREQUEST *res = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
if (res) {
hHttpCon = res->nlc;
if (res->resultCode == 200 && res->dataLength) {
diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp index 986d1620c1..92dab17061 100644 --- a/protocols/JabberG/src/jabber_ws.cpp +++ b/protocols/JabberG/src/jabber_ws.cpp @@ -47,12 +47,12 @@ void CJabberProto::WsUninit(void) JABBER_SOCKET CJabberProto::WsConnect(char* host, WORD port)
{
- NETLIBOPENCONNECTION nloc = { 0 };
+ NETLIBOPENCONNECTION nloc = {};
nloc.cbSize = sizeof(nloc);
nloc.szHost = host;
nloc.wPort = port;
nloc.timeout = 6;
- return (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ return Netlib_OpenConnection(m_hNetlibUser, &nloc);
}
int CJabberProto::WsSend(JABBER_SOCKET hConn, char* data, int datalen, int flags)
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index a14c976c64..2979323977 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -18,7 +18,7 @@ const LPSTR lpcszContentType[9] = struct MRA_AVATARS_QUEUE : public FIFO_MT
{
- HANDLE hNetlibUser;
+ HNETLIBUSER hNetlibUser;
HANDLE hThreadEvents[64];
int iThreadsCount, iThreadsRunning;
};
@@ -37,7 +37,7 @@ struct MRA_AVATARS_QUEUE_ITEM : public FIFO_MT_ITEM char szAvtSectName[MAX_PATH];
#define MRA_AVT_SECT_NAME szAvtSectName
-HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPCSTR lpszHost, DWORD dwPort);
+HANDLE MraAvatarsHttpConnect(HNETLIBUSER hNetlibUser, LPCSTR lpszHost, DWORD dwPort);
#define MAHTRO_AVT 0
#define MAHTRO_AVTMRIM 1
@@ -333,7 +333,7 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter) CloseHandle(hThreadEvent);
}
-HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPCSTR lpszHost, DWORD dwPort)
+HANDLE MraAvatarsHttpConnect(HNETLIBUSER hNetlibUser, LPCSTR lpszHost, DWORD dwPort)
{
NETLIBOPENCONNECTION nloc = { 0 };
nloc.cbSize = sizeof(nloc);
@@ -348,7 +348,7 @@ HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPCSTR lpszHost, DWORD dwPort) DWORD dwCurConnectReTryCount = dwConnectReTryCount;
HANDLE hConnection;
do {
- hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
+ hConnection = Netlib_OpenConnection(hNetlibUser, &nloc);
}
while (--dwCurConnectReTryCount && hConnection == NULL);
@@ -393,7 +393,7 @@ DWORD MraAvatarsHttpTransaction(HANDLE hConnection, DWORD dwRequestType, LPCSTR nlhr.headers = (NETLIBHTTPHEADER*)&nlbhHeaders;
nlhr.headersCount = 4;
- DWORD dwSent = CallService(MS_NETLIB_SENDHTTPREQUEST, (WPARAM)hConnection, (LPARAM)&nlhr);
+ DWORD dwSent = Netlib_SendHttpRequest(hConnection, &nlhr);
if (dwSent == SOCKET_ERROR || !dwSent)
return GetLastError();
diff --git a/protocols/MRA/src/MraFilesQueue.cpp b/protocols/MRA/src/MraFilesQueue.cpp index 83234d5adf..bad116e95e 100644 --- a/protocols/MRA/src/MraFilesQueue.cpp +++ b/protocols/MRA/src/MraFilesQueue.cpp @@ -471,7 +471,7 @@ HANDLE CMraProto::MraFilesQueueConnectOut(MRA_FILES_QUEUE_ITEM *dat) dwCurConnectReTryCount = dwConnectReTryCount;
do {
- dat->hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ dat->hConnection = Netlib_OpenConnection(m_hNetlibUser, &nloc);
}
while (--dwCurConnectReTryCount && dat->hConnection == NULL);
@@ -521,14 +521,13 @@ HANDLE CMraProto::MraFilesQueueConnectIn(MRA_FILES_QUEUE_ITEM *dat) // копируем адреса в соответствии с правилами и начинаем слушать порт
if (getByte("FileSendEnableDirectConn", MRA_DEF_FS_ENABLE_DIRECT_CONN)) {
- NETLIBBIND nlbBind = { 0 };
-
+ NETLIBBIND nlbBind = {};
nlbBind.cbSize = sizeof(nlbBind);
nlbBind.pfnNewConnectionV2 = MraFilesQueueConnectionReceived;
nlbBind.wPort = 0;
nlbBind.pExtra = (LPVOID)dat;
- dat->hListen = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlbBind);
+ dat->hListen = Netlib_BindPort(m_hNetlibUser, &nlbBind);
if (dat->hListen) {
ProtoBroadcastAck(dat->hContact, ACKTYPE_FILE, ACKRESULT_LISTENING, (HANDLE)dat->dwIDRequest, 0);
dwAddrListSize = MraFilesQueueGetLocalAddressesList(szAddrList, sizeof(szAddrList), nlbBind.wPort);
diff --git a/protocols/MRA/src/MraMRIMProxy.cpp b/protocols/MRA/src/MraMRIMProxy.cpp index e3789af1e2..2953356770 100644 --- a/protocols/MRA/src/MraMRIMProxy.cpp +++ b/protocols/MRA/src/MraMRIMProxy.cpp @@ -121,7 +121,7 @@ DWORD CMraProto::MraMrimProxyConnect(HANDLE hMraMrimProxyData, HANDLE *phConnect dwCurConnectReTryCount = dwConnectReTryCount;
do {
- pmmpd->hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ pmmpd->hConnection = Netlib_OpenConnection(m_hNetlibUser, &nloc);
}
while (--dwCurConnectReTryCount && pmmpd->hConnection == NULL);
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index a63493bfc3..da0f03fd69 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -693,10 +693,10 @@ void CMraProto::MraUpdateEmailStatus(const CMStringA &pszFrom, const CMStringA & }
}
-bool IsHTTPSProxyUsed(HANDLE hNetlibUser)
+bool IsHTTPSProxyUsed(HNETLIBUSER hNetlibUser)
{
NETLIBUSERSETTINGS nlus = { sizeof(nlus) };
- if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)hNetlibUser, (LPARAM)&nlus))
+ Netlib_GetUserSettings(hNetlibUser, &nlus);
if (nlus.useProxy && nlus.proxyType == PROXYTYPE_HTTPS)
return true;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 2245fd2604..acd9977a65 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -59,7 +59,7 @@ void CMraProto::MraThreadProc(LPVOID) dwCurConnectReTryCount = dwConnectReTryCount;
do {
InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
- m_hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ m_hConnection = Netlib_OpenConnection(m_hNetlibUser, &nloc);
}
while (--dwCurConnectReTryCount && m_hConnection == NULL);
@@ -82,7 +82,7 @@ void CMraProto::MraThreadProc(LPVOID) dwCurConnectReTryCount = dwConnectReTryCount;
do {
InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
- m_hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ m_hConnection = Netlib_OpenConnection(m_hNetlibUser, &nloc);
}
while (--dwCurConnectReTryCount && m_hConnection == NULL);
@@ -143,7 +143,7 @@ DWORD CMraProto::MraGetNLBData(CMStringA &szHost, WORD *pwPort) dwCurConnectReTryCount = dwConnectReTryCount;
do {
InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
- nls.hReadConns[0] = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ nls.hReadConns[0] = Netlib_OpenConnection(m_hNetlibUser, &nloc);
}
while (--dwCurConnectReTryCount && nls.hReadConns[0] == NULL);
diff --git a/protocols/MRA/src/stdafx.h b/protocols/MRA/src/stdafx.h index 6fd37937ae..29dfaa5fe9 100644 --- a/protocols/MRA/src/stdafx.h +++ b/protocols/MRA/src/stdafx.h @@ -199,7 +199,7 @@ CMStringA CopyNumber(const CMStringA&); CMStringW DecodeXML(const CMStringW &lptszMessage);
CMStringW EncodeXML(const CMStringW &lptszMessage);
-bool IsHTTPSProxyUsed(HANDLE hConnection);
+bool IsHTTPSProxyUsed(HNETLIBUSER hConnection);
bool IsContactMraProto(MCONTACT hContact);
bool IsEMailMR(const CMStringA& szEmail);
bool GetEMailFromString(const CMStringA& szBuff, CMStringA& szEmail);
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp index 9785717103..2c81a6ecc0 100644 --- a/protocols/MSN/src/msn_p2p.cpp +++ b/protocols/MSN/src/msn_p2p.cpp @@ -682,7 +682,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc) debugLogA("Connecting to %s:%d", tConn.szHost, tConn.wPort);
- info->s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&tConn);
+ info->s = (HANDLE)Netlib_OpenConnection(m_hNetlibUser, (LPARAM)&tConn);
if (info->s == NULL) {
TWinErrorCode err;
debugLogA("Connection Failed (%d): %s", err.mErrorCode, err.getText());
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 0f1a20f5fd..a938b42be9 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -538,10 +538,11 @@ void __cdecl CMsnProto::MsnFileAckThread(void* arg) NETLIBOPENCONNECTION nloc = { 0 };
MyNetlibConnFromUrl(nlhr.szUrl, nloc);
nloc.flags |= NLOCF_HTTP;
- 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 = Netlib_RecvHttpHeaders(nlc))) {
+ if (nloc.flags & NLOCF_SSL)
+ nlhr.flags |= NLHRF_SSL;
+
+ HANDLE nlc = Netlib_OpenConnection(m_hNetlibUser, &nloc);
+ if (nlc && Netlib_SendHttpRequest(nlc, &nlhr) != SOCKET_ERROR && (nlhrReply = Netlib_RecvHttpHeaders(nlc))) {
if (nlhrReply->resultCode == 200 || nlhrReply->resultCode == 206) {
INT_PTR dw;
char buf[1024];
@@ -562,7 +563,8 @@ void __cdecl CMsnProto::MsnFileAckThread(void* arg) }
Netlib_CloseHandle(nlc);
mir_free((char*)nloc.szHost);
- if (ft->std.currentFileNumber >= ft->std.totalFiles) ft->complete();
+ if (ft->std.currentFileNumber >= ft->std.totalFiles)
+ ft->complete();
}
delete ft;
}
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index 2bddaea516..de17faa243 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -160,7 +160,7 @@ void __cdecl CMsnProto::MSNServerThread(void* arg) debugLogA("Thread started: server='%s:%d', type=%d", tConn.szHost, tConn.wPort, info->mType);
- info->s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&tConn);
+ info->s = Netlib_OpenConnection(m_hNetlibUser, &tConn);
if (info->s == NULL) {
debugLogA("Connection Failed (%d) server='%s:%d'", WSAGetLastError(), tConn.szHost, tConn.wPort);
@@ -336,7 +336,7 @@ void CMsnProto::MSN_CloseConnections(void) break;
case SERVER_P2P_DIRECT:
- CallService(MS_NETLIB_SHUTDOWN, (WPARAM)T.s, 0);
+ Netlib_Shutdown(T.s);
break;
}
}
@@ -344,7 +344,7 @@ void CMsnProto::MSN_CloseConnections(void) lck.unlock();
if (hHttpsConnection)
- CallService(MS_NETLIB_SHUTDOWN, (WPARAM)hHttpsConnection, 0);
+ Netlib_Shutdown(hHttpsConnection);
}
void CMsnProto::Threads_Uninit(void)
diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp index e492bdaa94..154a165f83 100644 --- a/protocols/Sametime/src/sametime_session.cpp +++ b/protocols/Sametime/src/sametime_session.cpp @@ -379,12 +379,13 @@ int waitcallback(unsigned int* timeout) void __cdecl SessionThread(LPVOID param)
{
CSametimeProto* proto = (CSametimeProto*)param;
- HANDLE hNetlibUser = proto->m_hNetlibUser;
proto->debugLogW(L"SessionThread() start");
continue_connect = true;
- //setup
+ proto->BroadcastNewStatus(ID_STATUS_CONNECTING);
+
+ // setup
NETLIBOPENCONNECTION conn_data = { 0 };
conn_data.cbSize = sizeof(NETLIBOPENCONNECTION);
conn_data.flags = NLOCF_V2;
@@ -392,10 +393,7 @@ void __cdecl SessionThread(LPVOID param) conn_data.wPort = proto->options.port;
conn_data.timeout = 20;
conn_data.waitcallback = waitcallback;
-
- proto->BroadcastNewStatus(ID_STATUS_CONNECTING);
-
- proto->server_connection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&conn_data);
+ proto->server_connection = Netlib_OpenConnection(proto->m_hNetlibUser, &conn_data);
if (!proto->server_connection) {
diff --git a/protocols/Tlen/src/stdafx.h b/protocols/Tlen/src/stdafx.h index d0b6031d7a..67f085a708 100644 --- a/protocols/Tlen/src/stdafx.h +++ b/protocols/Tlen/src/stdafx.h @@ -281,7 +281,7 @@ struct TlenProtocol : public PROTO<TlenProtocol> int __cdecl MUCHandleEvent(WPARAM wParam, LPARAM lParam);
//====================================================================================
- HANDLE hFileNetlibUser;
+ HNETLIBUSER hFileNetlibUser;
TLEN_MODEMSGS modeMsgs;
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index 11a269f377..dcbc77d8c0 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -182,7 +182,7 @@ static void __cdecl TlenFileReceiveThread(void *arg) nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
- HANDLE s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
+ HANDLE s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
if (s != NULL) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
@@ -481,7 +481,7 @@ static void __cdecl TlenFileSendingThread(void *arg) NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
+ HANDLE hConn = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
if (hConn != NULL) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = hConn;
diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index a2265f6e8a..71eee92fc8 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -300,7 +300,7 @@ static HANDLE TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = sb->szHost;
nloc.wPort = sb->wPort;
- HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc);
+ HANDLE s = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
if (s == NULL) {
// TlenLog("Connection failed (%d), thread ended", WSAGetLastError());
return NULL;
@@ -352,7 +352,7 @@ static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = sb->szHost;
nloc.wPort = sb->wPort;
- HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc);
+ HANDLE s = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
if (s == NULL) {
ft->proto->debugLogA("Connection failed (%d), thread ended", WSAGetLastError());
return NULL;
@@ -443,7 +443,6 @@ static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft)
{
- NETLIBBIND nlb = {0};
HANDLE s = NULL;
int useProxy;
DBVARIANT dbv;
@@ -491,13 +490,15 @@ HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft) ft->wLocalPort = sb.wPort;
}
}
+
+ NETLIBBIND nlb = {};
if (useProxy<2) {
nlb.cbSize = sizeof(NETLIBBIND);
nlb.pfnNewConnectionV2 = ft->pfnNewConnectionV2;
nlb.wPort = 0; // Use user-specified incoming port ranges, if available
nlb.pExtra = proto;
ft->proto->debugLogA("Calling MS_NETLIB_BINDPORT");
- s = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nlb);
+ s = Netlib_BindPort(ft->proto->m_hNetlibUser, &nlb);
ft->proto->debugLogA("listening on %d",s);
}
if (useProxy == 0) {
diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp index 6dfb47e3f8..eb52fb034b 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -292,11 +292,12 @@ static void __cdecl TlenVoiceReceiveThread(void *arg) TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)arg;
ft->proto->debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort);
+ SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Connecting..."));
+
NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Connecting..."));
- HANDLE s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
+ HANDLE s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
if (s != NULL) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
@@ -548,7 +549,7 @@ static void __cdecl TlenVoiceSendingThread(void *arg) NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE sock = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
+ HANDLE sock = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
if (sock != NULL) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Connecting..."));
//ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp index 1bed6c9865..eaa952d33b 100644 --- a/protocols/Tlen/src/tlen_ws.cpp +++ b/protocols/Tlen/src/tlen_ws.cpp @@ -42,7 +42,7 @@ BOOL TlenWsInit(TlenProtocol *proto) NETLIBUSERSETTINGS nlus = {0};
nlus.cbSize = sizeof(nlus);
nlus.useProxy = 0;
- CallService(MS_NETLIB_SETUSERSETTINGS, (WPARAM) proto->hFileNetlibUser, (LPARAM) &nlus);
+ Netlib_SetUserSettings(proto->hFileNetlibUser, &nlus);
return (proto->m_hNetlibUser != NULL)?TRUE:FALSE;
}
@@ -57,17 +57,15 @@ void TlenWsUninit(TlenProtocol *proto) HANDLE TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
{
- NETLIBOPENCONNECTION nloc = {0};
-
+ NETLIBOPENCONNECTION nloc = {};
nloc.cbSize = sizeof(NETLIBOPENCONNECTION); //NETLIBOPENCONNECTION_V1_SIZE;
nloc.szHost = host;
nloc.wPort = port;
nloc.flags = 0;
nloc.timeout = 6;
- return (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) proto->m_hNetlibUser, (LPARAM) &nloc);
+ return Netlib_OpenConnection(proto->m_hNetlibUser, &nloc);
}
-
int TlenWsSend(TlenProtocol *proto, HANDLE s, char *data, int datalen)
{
int len;
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 89687f69d4..7ac8d3a55b 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -15,8 +15,8 @@ Tox_Options* CToxProto::GetToxOptions() if (m_hNetlibUser != NULL)
{
- NETLIBUSERSETTINGS nlus = { sizeof(NETLIBUSERSETTINGS) };
- CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus);
+ NETLIBUSERSETTINGS nlus = { sizeof(nlus) };
+ Netlib_GetUserSettings(m_hNetlibUser, &nlus);
if (nlus.useProxy)
{
diff --git a/protocols/WhatsApp/src/WASocketConnection.cpp b/protocols/WhatsApp/src/WASocketConnection.cpp index 78957b21c6..5ba6c781eb 100644 --- a/protocols/WhatsApp/src/WASocketConnection.cpp +++ b/protocols/WhatsApp/src/WASocketConnection.cpp @@ -18,7 +18,7 @@ WASocketConnection::WASocketConnection(const std::string &dir, int port) throw ( noc.szHost = dir.c_str();
noc.wPort = port;
noc.flags = NLOCF_V2; // | NLOCF_SSL;
- this->hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, WPARAM(g_hNetlibUser), LPARAM(&noc));
+ this->hConn = Netlib_OpenConnection(g_hNetlibUser, &noc);
if (this->hConn == NULL)
throw WAException(getLastErrorMsg(), WAException::SOCKET_EX, WAException::SOCKET_EX_OPEN);
|