summaryrefslogtreecommitdiff
path: root/protocols/Tlen/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-14 01:22:55 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-14 01:22:55 +0300
commitd3cb19278d60ac6f7963379254546cdca36a90e2 (patch)
treef2fa018b343d5460419c1b323f5f3ce04a393d00 /protocols/Tlen/src
parentd5a6c0666a8d8d2055a3f4402f67f91e8548ec3a (diff)
separate handle types for HNETLIBCONN & HNETLIBBIND
Diffstat (limited to 'protocols/Tlen/src')
-rw-r--r--protocols/Tlen/src/stdafx.h10
-rw-r--r--protocols/Tlen/src/tlen_file.cpp14
-rw-r--r--protocols/Tlen/src/tlen_p2p_old.cpp21
-rw-r--r--protocols/Tlen/src/tlen_p2p_old.h10
-rw-r--r--protocols/Tlen/src/tlen_picture.cpp4
-rw-r--r--protocols/Tlen/src/tlen_voice.cpp14
-rw-r--r--protocols/Tlen/src/tlen_ws.cpp6
7 files changed, 39 insertions, 40 deletions
diff --git a/protocols/Tlen/src/stdafx.h b/protocols/Tlen/src/stdafx.h
index 67f085a708..d5783e17ee 100644
--- a/protocols/Tlen/src/stdafx.h
+++ b/protocols/Tlen/src/stdafx.h
@@ -348,7 +348,7 @@ typedef struct ThreadDataStruct{
WORD port;
BOOL useEncryption;
- HANDLE s; //HANDLE from CallService(MS_NETLIB_OPENCONNECTION (tlen_ws.c:68)
+ HNETLIBCONN s;
aes_context aes_in_context;
aes_context aes_out_context;
unsigned char aes_in_iv[16];
@@ -364,7 +364,7 @@ typedef enum { FT_CONNECTING, FT_INITIALIZING, FT_RECEIVING, FT_DONE, FT_ERROR,
typedef enum { FT_RECV, FT_SEND} TLEN_FILE_MODE;
typedef struct TLEN_FILE_TRANSFER_STRUCT{
MCONTACT hContact;
- HANDLE s;
+ HNETLIBCONN s;
NETLIBNEWCONNECTIONPROC_V2 pfnNewConnectionV2;
TLEN_FILE_STATE state;
char *jid;
@@ -437,9 +437,9 @@ void __cdecl TlenServerThread(ThreadData *info);
// tlen_ws.cpp
BOOL TlenWsInit(TlenProtocol *proto);
void TlenWsUninit(TlenProtocol *proto);
-HANDLE TlenWsConnect(TlenProtocol *proto, char *host, WORD port);
-int TlenWsSend(TlenProtocol *proto, HANDLE s, char *data, int datalen);
-int TlenWsRecv(TlenProtocol *proto, HANDLE s, char *data, long datalen);
+HNETLIBCONN TlenWsConnect(TlenProtocol *proto, char *host, WORD port);
+int TlenWsSend(TlenProtocol *proto, HNETLIBCONN s, char *data, int datalen);
+int TlenWsRecv(TlenProtocol *proto, HNETLIBCONN s, char *data, long datalen);
int TlenWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes_ctx, unsigned char *aes_iv);
int TlenWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *aes_ctx, unsigned char *aes_iv);
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp
index dcbc77d8c0..f97e6f1b19 100644
--- a/protocols/Tlen/src/tlen_file.cpp
+++ b/protocols/Tlen/src/tlen_file.cpp
@@ -144,12 +144,12 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
}
}
-static void TlenFileReceivingConnection(HANDLE hConnection, DWORD, void * pExtra)
+static void TlenFileReceivingConnection(HNETLIBCONN hConnection, DWORD, void * pExtra)
{
TlenProtocol *proto = (TlenProtocol *)pExtra;
TLEN_FILE_TRANSFER *ft = TlenP2PEstablishIncomingConnection(proto, hConnection, LIST_FILE, TRUE);
if (ft != NULL) {
- HANDLE slisten = ft->s;
+ HNETLIBCONN slisten = ft->s;
ft->s = hConnection;
ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
ft->proto->debugLogA("Entering send loop for this file connection... (ft->s is hConnection)");
@@ -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 = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
+ HNETLIBCONN s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
if (s != NULL) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
@@ -378,9 +378,9 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
}
}
-static void TlenFileSendingConnection(HANDLE hConnection, DWORD, void * pExtra)
+static void TlenFileSendingConnection(HNETLIBCONN hConnection, DWORD, void * pExtra)
{
- HANDLE slisten;
+ HNETLIBCONN slisten;
TlenProtocol *proto = (TlenProtocol *)pExtra;
TLEN_FILE_TRANSFER *ft = TlenP2PEstablishIncomingConnection(proto, hConnection, LIST_FILE, TRUE);
@@ -450,7 +450,7 @@ static void __cdecl TlenFileSendingThread(void *arg)
ft->proto->debugLogA("Thread started: type=tlen_file_send");
ft->mode = FT_SEND;
ft->pfnNewConnectionV2 = TlenFileSendingConnection;
- HANDLE s = TlenP2PListen(ft);
+ HNETLIBCONN s = TlenP2PListen(ft);
if (s != NULL) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = s;
@@ -481,7 +481,7 @@ static void __cdecl TlenFileSendingThread(void *arg)
NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE hConn = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
+ HNETLIBCONN 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 71eee92fc8..2180bde7a7 100644
--- a/protocols/Tlen/src/tlen_p2p_old.cpp
+++ b/protocols/Tlen/src/tlen_p2p_old.cpp
@@ -114,7 +114,7 @@ void TlenP2PInit() {
void TlenP2PUninit() {
}
-int TlenP2PPacketSend(HANDLE s, TLEN_FILE_PACKET *packet)
+int TlenP2PPacketSend(HNETLIBCONN s, TLEN_FILE_PACKET *packet)
{
DWORD sendResult;
if (packet != NULL && packet->packet != NULL) {
@@ -126,7 +126,7 @@ int TlenP2PPacketSend(HANDLE s, TLEN_FILE_PACKET *packet)
return 1;
}
-TLEN_FILE_PACKET* TlenP2PPacketReceive(HANDLE s)
+TLEN_FILE_PACKET* TlenP2PPacketReceive(HNETLIBCONN s)
{
DWORD type, len, pos;
DWORD recvResult = Netlib_Recv(s, (char *)&type, 4, MSG_NODUMP);
@@ -182,7 +182,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck)
}
}
-TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HANDLE s, TLEN_LIST list, BOOL sendAck)
+TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HNETLIBCONN s, TLEN_LIST list, BOOL sendAck)
{
char str[300];
DWORD iqId;
@@ -290,7 +290,7 @@ static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft)
}
-static HANDLE TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
+static HNETLIBCONN TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
{ //rfc1928
int len;
BYTE buf[256];
@@ -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 = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
+ HNETLIBCONN s = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
if (s == NULL) {
// TlenLog("Connection failed (%d), thread ended", WSAGetLastError());
return NULL;
@@ -343,7 +343,7 @@ static HANDLE TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
return s;
}
-static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
+static HNETLIBCONN TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
{ //rfc1928
BYTE buf[512];
int len, status;
@@ -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 = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
+ HNETLIBCONN s = Netlib_OpenConnection(ft->proto->hFileNetlibUser, &nloc);
if (s == NULL) {
ft->proto->debugLogA("Connection failed (%d), thread ended", WSAGetLastError());
return NULL;
@@ -441,9 +441,9 @@ static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
}
-HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft)
+HNETLIBCONN TlenP2PListen(TLEN_FILE_TRANSFER *ft)
{
- HANDLE s = NULL;
+ HNETLIBCONN s = NULL;
int useProxy;
DBVARIANT dbv;
SOCKSBIND sb;
@@ -493,12 +493,11 @@ HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft)
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 = Netlib_BindPort(ft->proto->m_hNetlibUser, &nlb);
+ s = (HNETLIBCONN)Netlib_BindPort(ft->proto->m_hNetlibUser, &nlb);
ft->proto->debugLogA("listening on %d",s);
}
if (useProxy == 0) {
diff --git a/protocols/Tlen/src/tlen_p2p_old.h b/protocols/Tlen/src/tlen_p2p_old.h
index 563054a83e..8b5a6ffde4 100644
--- a/protocols/Tlen/src/tlen_p2p_old.h
+++ b/protocols/Tlen/src/tlen_p2p_old.h
@@ -57,12 +57,12 @@ extern void TlenP2PPacketSetType(TLEN_FILE_PACKET *packet, DWORD type);
extern void TlenP2PPacketSetLen(TLEN_FILE_PACKET *packet, DWORD len);
extern void TlenP2PPacketPackDword(TLEN_FILE_PACKET *packet, DWORD data);
extern void TlenP2PPacketPackBuffer(TLEN_FILE_PACKET *packet, char *buffer, int len);
-extern int TlenP2PPacketSend(HANDLE s, TLEN_FILE_PACKET *packet);
-extern TLEN_FILE_PACKET* TlenP2PPacketReceive(HANDLE s);
+extern int TlenP2PPacketSend(HNETLIBCONN s, TLEN_FILE_PACKET *packet);
+extern TLEN_FILE_PACKET* TlenP2PPacketReceive(HNETLIBCONN s);
extern void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck);
-extern TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HANDLE s, TLEN_LIST list, BOOL sendAck);
-extern HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft);
-extern void TlenP2PStopListening(HANDLE s);
+extern TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HNETLIBCONN s, TLEN_LIST list, BOOL sendAck);
+extern HNETLIBCONN TlenP2PListen(TLEN_FILE_TRANSFER *ft);
+extern void TlenP2PStopListening(HNETLIBCONN s);
void __cdecl TlenProcessP2P(XmlNode *node, void *userdata);
diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp
index 14b15ad15c..79e9b7b545 100644
--- a/protocols/Tlen/src/tlen_picture.cpp
+++ b/protocols/Tlen/src/tlen_picture.cpp
@@ -42,7 +42,7 @@ static void TlenPsPostThread(void *ptr) {
TLENPSREQUESTTHREADDATA *data = (TLENPSREQUESTTHREADDATA *)ptr;
TlenProtocol *proto = data->proto;
TLEN_LIST_ITEM *item = data->item;
- HANDLE socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
+ HNETLIBCONN socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
BOOL bSent = FALSE;
if (socket != NULL) {
char header[512];
@@ -99,7 +99,7 @@ static void TlenPsGetThread(void *ptr) {
FILE *fp;
fp = fopen( item->ft->files[0], "wb" );
if (fp) {
- HANDLE socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
+ HNETLIBCONN socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
if (socket != NULL) {
XmlState xmlState;
char header[512];
diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp
index eb52fb034b..3255cd53f1 100644
--- a/protocols/Tlen/src/tlen_voice.cpp
+++ b/protocols/Tlen/src/tlen_voice.cpp
@@ -43,7 +43,7 @@ static HBITMAP vuMeterBitmaps[100];
static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft);
static void TlenVoiceSendParse(TLEN_FILE_TRANSFER *ft);
-static void TlenVoiceReceivingConnection(HANDLE hNewConnection, DWORD dwRemoteIP, void * pExtra);
+static void TlenVoiceReceivingConnection(HNETLIBCONN hNewConnection, DWORD dwRemoteIP, void * pExtra);
static void CALLBACK TlenVoicePlaybackCallback(HWAVEOUT hwo, UINT uMsg, DWORD* dwInstance, DWORD dwParam1, DWORD)
{
@@ -297,7 +297,7 @@ static void __cdecl TlenVoiceReceiveThread(void *arg)
NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
+ HNETLIBCONN s = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
if (s != NULL) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
@@ -322,7 +322,7 @@ static void __cdecl TlenVoiceReceiveThread(void *arg)
else {
ft->proto->debugLogA("Connection failed - receiving as server");
ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection;
- s = TlenP2PListen(ft);
+ s = (HNETLIBCONN)TlenP2PListen(ft);
if (s != NULL) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Waiting for connection..."));
ft->s = s;
@@ -362,9 +362,9 @@ static void __cdecl TlenVoiceReceiveThread(void *arg)
TlenP2PFreeFileTransfer(ft);
}
-static void TlenVoiceReceivingConnection(HANDLE hConnection, DWORD, void * pExtra)
+static void TlenVoiceReceivingConnection(HNETLIBCONN hConnection, DWORD, void * pExtra)
{
- HANDLE slisten;
+ HNETLIBCONN slisten;
TlenProtocol *proto = (TlenProtocol *)pExtra;
TLEN_FILE_TRANSFER *ft = TlenP2PEstablishIncomingConnection(proto, hConnection, LIST_VOICE, FALSE);
@@ -517,7 +517,7 @@ static void __cdecl TlenVoiceSendingThread(void *arg)
ft->proto->debugLogA("Thread started: type=voice_send");
ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection;
- HANDLE s = TlenP2PListen(ft);
+ HNETLIBCONN s = (HNETLIBCONN)TlenP2PListen(ft);
if (s != NULL) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Waiting for connection..."));
//ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
@@ -549,7 +549,7 @@ static void __cdecl TlenVoiceSendingThread(void *arg)
NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE sock = Netlib_OpenConnection(ft->proto->m_hNetlibUser, &nloc);
+ HNETLIBCONN 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 eaa952d33b..98b21892d4 100644
--- a/protocols/Tlen/src/tlen_ws.cpp
+++ b/protocols/Tlen/src/tlen_ws.cpp
@@ -55,7 +55,7 @@ void TlenWsUninit(TlenProtocol *proto)
proto->hFileNetlibUser = NULL;
}
-HANDLE TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
+HNETLIBCONN TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
{
NETLIBOPENCONNECTION nloc = {};
nloc.cbSize = sizeof(NETLIBOPENCONNECTION); //NETLIBOPENCONNECTION_V1_SIZE;
@@ -66,7 +66,7 @@ HANDLE TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
return Netlib_OpenConnection(proto->m_hNetlibUser, &nloc);
}
-int TlenWsSend(TlenProtocol *proto, HANDLE s, char *data, int datalen)
+int TlenWsSend(TlenProtocol *proto, HNETLIBCONN s, char *data, int datalen)
{
int len;
if ((len=Netlib_Send(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT)) == SOCKET_ERROR || len != datalen) {
@@ -76,7 +76,7 @@ int TlenWsSend(TlenProtocol *proto, HANDLE s, char *data, int datalen)
return TRUE;
}
-int TlenWsRecv(TlenProtocol *proto, HANDLE s, char *data, long datalen)
+int TlenWsRecv(TlenProtocol *proto, HNETLIBCONN s, char *data, long datalen)
{
int ret;
ret = Netlib_Recv(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT);