diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-06 12:58:08 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-06 12:58:08 +0000 |
commit | 91003eb7373b4cb9e340be5ecdbbb7884a5e973f (patch) | |
tree | c23c5bd46135e8ce4bff21251794936e17f1c5fa | |
parent | 39955d4f87fbf76691b4fd2cb7e46940608a2a90 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6372 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rwxr-xr-x | plugins/Watrack_MPD/src/main.cpp | 6 | ||||
-rwxr-xr-x | plugins/Watrack_MPD/src/utilities.cpp | 18 | ||||
-rwxr-xr-x | plugins/Watrack_MPD/src/utilities.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 13 | ||||
-rw-r--r-- | protocols/MRA/src/MraAvatars.cpp | 6 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen.h | 11 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_file.cpp | 26 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_p2p_old.cpp | 30 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_p2p_old.h | 10 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_picture.cpp | 4 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_voice.cpp | 30 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_ws.cpp | 6 |
12 files changed, 56 insertions, 105 deletions
diff --git a/plugins/Watrack_MPD/src/main.cpp b/plugins/Watrack_MPD/src/main.cpp index 55888e4caa..dd9a9feea0 100755 --- a/plugins/Watrack_MPD/src/main.cpp +++ b/plugins/Watrack_MPD/src/main.cpp @@ -24,14 +24,14 @@ SONGINFO SongInfo = {0}; void Start(void* param) { - NETLIBOPENCONNECTION nloc = {0}; + NETLIBOPENCONNECTION nloc = { sizeof(nloc) }; char *tmp = (char*)mir_u2a(gbHost); - nloc.cbSize = sizeof(nloc); nloc.szHost = tmp; nloc.timeout = 5; + nloc.flags = NLOCF_V2; nloc.wPort = gbPort; Connected = FALSE; - ghConnection = NetLib_CreateConnection(ghNetlibUser, &nloc); + ghConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ghNetlibUser, (LPARAM)&nloc); if(ghConnection) ghPacketReciever = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER,(WPARAM)ghConnection,2048); } diff --git a/plugins/Watrack_MPD/src/utilities.cpp b/plugins/Watrack_MPD/src/utilities.cpp index 05c5d2f1b4..55e100cea1 100755 --- a/plugins/Watrack_MPD/src/utilities.cpp +++ b/plugins/Watrack_MPD/src/utilities.cpp @@ -30,21 +30,3 @@ TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,c db_free(&dbv); return szRes; } - -HANDLE NetLib_CreateConnection(HANDLE hUser, NETLIBOPENCONNECTION* nloc) //from icq ) -{ - HANDLE hConnection; - - nloc->cbSize = sizeof(NETLIBOPENCONNECTION); - nloc->flags |= NLOCF_V2; - - hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hUser, (LPARAM)nloc); - if (!hConnection && (GetLastError() == 87)) - { // this ensures, an old Miranda will be able to connect also - nloc->cbSize = NETLIBOPENCONNECTION_V1_SIZE; - hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hConnection, (LPARAM)nloc); - } - return hConnection; -} - - diff --git a/plugins/Watrack_MPD/src/utilities.h b/plugins/Watrack_MPD/src/utilities.h index 7bd9dd0830..018f32a03c 100755 --- a/plugins/Watrack_MPD/src/utilities.h +++ b/plugins/Watrack_MPD/src/utilities.h @@ -1,7 +1,6 @@ #ifndef UTILITIES_H #define UTILITIES_H -HANDLE NetLib_CreateConnection(HANDLE hUser, NETLIBOPENCONNECTION* nloc); HANDLE CreateThreadEx(pThreadFuncEx AFunc, void* arg, DWORD* pThreadID); TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef); diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 7fcd1827bb..a2950c07f5 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -157,19 +157,6 @@ void FacebookProto::SetAllContactStatuses(int status, bool reset_client) ptrT mirver( getTStringA(hContact, "MirVer"));
if (!mirver || _tcscmp(mirver, _T(FACEBOOK_NAME)))
setTString(hContact, "MirVer", _T(FACEBOOK_NAME));
-
- /*std::tstring foldername = GetAvatarFolder() + L"\\smileys\\";
- TCHAR *path = _tcsdup(foldername.c_str());
-
- if (getByte(FACEBOOK_KEY_CUSTOM_SMILEYS, DEFAULT_CUSTOM_SMILEYS)) {
- SMADD_CONT cont;
- cont.cbSize = sizeof(SMADD_CONT);
- cont.hContact = hContact;
- cont.type = 0;
- cont.path = path;
- CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
- mir_free(path);
- }*/
}
if (getWord(hContact, "Status", 0) != status)
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index 6421be8ddf..d6ef6620b0 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -367,8 +367,8 @@ HANDLE MraAvatarsHttpConnect(HANDLE m_hNetlibUser, LPCSTR lpszHost, DWORD dwPort nloc.szHost = lpszHost;
nloc.wPort = ( IsHTTPSProxyUsed(m_hNetlibUser)) ? MRA_SERVER_PORT_HTTPS : dwPort;
nloc.timeout = db_get_dw(NULL, MRA_AVT_SECT_NAME, "TimeOutConnect", MRA_AVT_DEFAULT_TIMEOUT_CONN);
- if (nloc.timeout<MRA_TIMEOUT_CONN_MIN) nloc.timeout = MRA_TIMEOUT_CONN_MIN;
- if (nloc.timeout>MRA_TIMEOUT_CONN_ÌÀÕ) nloc.timeout = MRA_TIMEOUT_CONN_ÌÀÕ;
+ if (nloc.timeout < MRA_TIMEOUT_CONN_MIN) nloc.timeout = MRA_TIMEOUT_CONN_MIN;
+ if (nloc.timeout > MRA_TIMEOUT_CONN_ÌÀÕ) nloc.timeout = MRA_TIMEOUT_CONN_ÌÀÕ;
DWORD dwConnectReTryCount = db_get_dw(NULL, MRA_AVT_SECT_NAME, "ConnectReTryCount", MRA_AVT_DEFAULT_CONN_RETRY_COUNT);
DWORD dwCurConnectReTryCount = dwConnectReTryCount;
@@ -376,7 +376,7 @@ HANDLE MraAvatarsHttpConnect(HANDLE m_hNetlibUser, LPCSTR lpszHost, DWORD dwPort do {
m_hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
}
- while (--dwCurConnectReTryCount && m_hConnection == NULL);
+ while (--dwCurConnectReTryCount && m_hConnection == NULL);
return m_hConnection;
}
diff --git a/protocols/Tlen/src/tlen.h b/protocols/Tlen/src/tlen.h index 5fbedc645a..f794e8432e 100644 --- a/protocols/Tlen/src/tlen.h +++ b/protocols/Tlen/src/tlen.h @@ -132,7 +132,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /*******************************************************************
* Global data structures and data type definitions
*******************************************************************/
-typedef HANDLE TLEN_SOCKET;
typedef enum {
LIST_ROSTER, // Roster list
@@ -367,7 +366,7 @@ typedef struct ThreadDataStruct{ WORD port;
BOOL useEncryption;
- TLEN_SOCKET s; //HANDLE from CallService(MS_NETLIB_OPENCONNECTION (tlen_ws.c:68)
+ HANDLE s; //HANDLE from CallService(MS_NETLIB_OPENCONNECTION (tlen_ws.c:68)
aes_context aes_in_context;
aes_context aes_out_context;
unsigned char aes_in_iv[16];
@@ -383,7 +382,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{
HANDLE hContact;
- TLEN_SOCKET s;
+ HANDLE s;
NETLIBNEWCONNECTIONPROC_V2 pfnNewConnectionV2;
TLEN_FILE_STATE state;
char *jid;
@@ -457,9 +456,9 @@ void __cdecl TlenServerThread(ThreadData *info); // tlen_ws.cpp
BOOL TlenWsInit(TlenProtocol *proto);
void TlenWsUninit(TlenProtocol *proto);
-TLEN_SOCKET TlenWsConnect(TlenProtocol *proto, char *host, WORD port);
-int TlenWsSend(TlenProtocol *proto, TLEN_SOCKET s, char *data, int datalen);
-int TlenWsRecv(TlenProtocol *proto, TLEN_SOCKET s, char *data, long datalen);
+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);
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 fed69c8ae6..d2f44dddf1 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -152,9 +152,9 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) }
}
-static void TlenFileReceivingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra)
+static void TlenFileReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, void * pExtra)
{
- TLEN_SOCKET slisten;
+ HANDLE slisten;
TLEN_FILE_TRANSFER *ft;
TlenProtocol *proto = (TlenProtocol *)pExtra;
@@ -187,16 +187,14 @@ static void TlenFileReceivingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteI static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft)
{
- NETLIBOPENCONNECTION nloc;
- TLEN_SOCKET s;
TlenLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort);
ft->mode = FT_RECV;
- nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION);
+
+ NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- nloc.flags = 0;
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
- s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
if (s != NULL) {
ft->s = s;
TlenLog(ft->proto, "Entering file receive loop");
@@ -395,9 +393,9 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) }
}
-static void TlenFileSendingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra)
+static void TlenFileSendingConnection(HANDLE hConnection, DWORD dwRemoteIP, void * pExtra)
{
- TLEN_SOCKET slisten;
+ HANDLE slisten;
TLEN_FILE_TRANSFER *ft;
TlenProtocol *proto = (TlenProtocol *)pExtra;
@@ -462,7 +460,7 @@ int TlenFileCancelAll(TlenProtocol *proto) static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft)
{
- TLEN_SOCKET s = NULL;
+ HANDLE s = NULL;
HANDLE hEvent;
char *nick;
@@ -494,15 +492,13 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) TlenLog(ft->proto, "ft->s is NULL");
if (ft->state == FT_SWITCH) {
- NETLIBOPENCONNECTION nloc;
- TLEN_SOCKET s;
TlenLog(ft->proto, "Sending as client...");
ft->state = FT_CONNECTING;
- nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION);
+
+ NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- nloc.flags = 0;
- s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
if (s != NULL) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
ft->s = s;
diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index 92ee4b6681..0d6754599b 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(TLEN_SOCKET s, TLEN_FILE_PACKET *packet)
+int TlenP2PPacketSend(HANDLE s, TLEN_FILE_PACKET *packet)
{
DWORD sendResult;
if (packet != NULL && packet->packet != NULL) {
@@ -126,7 +126,7 @@ int TlenP2PPacketSend(TLEN_SOCKET s, TLEN_FILE_PACKET *packet) return 1;
}
-TLEN_FILE_PACKET* TlenP2PPacketReceive(TLEN_SOCKET s)
+TLEN_FILE_PACKET* TlenP2PPacketReceive(HANDLE s)
{
TLEN_FILE_PACKET *packet;
DWORD recvResult;
@@ -185,7 +185,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) }
}
-TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, TLEN_SOCKET s, TLEN_LIST list, BOOL sendAck)
+TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, HANDLE s, TLEN_LIST list, BOOL sendAck)
{
TLEN_LIST_ITEM *item = NULL;
TLEN_FILE_PACKET *packet;
@@ -296,20 +296,17 @@ static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft) }
-static TLEN_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
+static HANDLE TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
{ //rfc1928
int len;
BYTE buf[256];
int status;
struct in_addr in;
- NETLIBOPENCONNECTION nloc;
- TLEN_SOCKET s;
- nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION);
+ NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = sb->szHost;
nloc.wPort = sb->wPort;
- nloc.flags = 0;
- s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc);
if (s == NULL) {
// TlenLog("Connection failed (%d), thread ended", WSAGetLastError());
return NULL;
@@ -352,19 +349,16 @@ static TLEN_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) return s;
}
-static TLEN_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
+static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
{ //rfc1928
BYTE buf[512];
int len, status;
- NETLIBOPENCONNECTION nloc;
struct in_addr in;
- TLEN_SOCKET s;
- nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION);
+ NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = sb->szHost;
nloc.wPort = sb->wPort;
- nloc.flags = 0;
- s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc);
if (s == NULL) {
TlenLog(ft->proto, "Connection failed (%d), thread ended", WSAGetLastError());
return NULL;
@@ -453,10 +447,10 @@ static TLEN_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) }
-TLEN_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft)
+HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft)
{
NETLIBBIND nlb = {0};
- TLEN_SOCKET s = NULL;
+ HANDLE s = NULL;
int useProxy;
DBVARIANT dbv;
SOCKSBIND sb;
@@ -525,7 +519,7 @@ TLEN_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft) return s;
}
-void TlenP2PStopListening(TLEN_SOCKET s) {
+void TlenP2PStopListening(HANDLE s) {
if (s != NULL) {
// listenCount--;
// if (listenCount <= 0) {
diff --git a/protocols/Tlen/src/tlen_p2p_old.h b/protocols/Tlen/src/tlen_p2p_old.h index 4ce48e2b26..1e8bc111f9 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(TLEN_SOCKET s, TLEN_FILE_PACKET *packet);
-extern TLEN_FILE_PACKET* TlenP2PPacketReceive(TLEN_SOCKET s);
+extern int TlenP2PPacketSend(HANDLE s, TLEN_FILE_PACKET *packet);
+extern TLEN_FILE_PACKET* TlenP2PPacketReceive(HANDLE s);
extern void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck);
-extern TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, TLEN_SOCKET s, TLEN_LIST list, BOOL sendAck);
-extern TLEN_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft);
-extern void TlenP2PStopListening(TLEN_SOCKET s);
+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);
void __cdecl TlenProcessP2P(XmlNode *node, void *userdata);
diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index 25618f9bec..ee241ead74 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;
- TLEN_SOCKET socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
+ HANDLE socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
BOOL bSent = FALSE;
if (socket != NULL) {
char header[512];
@@ -108,7 +108,7 @@ static void TlenPsGetThread(void *ptr) { FILE *fp;
fp = fopen( item->ft->files[0], "wb" );
if (fp) {
- TLEN_SOCKET socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
+ HANDLE 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 cff67606c0..e1d7774295 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -312,17 +312,13 @@ static void TlenVoiceCrypt(char *buffer, int len) void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft)
{
- NETLIBOPENCONNECTION nloc;
- TLEN_SOCKET s;
-
TlenLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort);
- nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION);
+
+ NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- nloc.flags = 0;
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Connecting..."));
-// ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
- s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
if (s != NULL) {
ft->s = s;
TlenLog(ft->proto, "Entering file receive loop");
@@ -386,9 +382,9 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) TlenP2PFreeFileTransfer(ft);
}
-static void TlenVoiceReceivingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra)
+static void TlenVoiceReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, void * pExtra)
{
- TLEN_SOCKET slisten;
+ HANDLE slisten;
TLEN_FILE_TRANSFER *ft;
TlenProtocol *proto = (TlenProtocol *)pExtra;
@@ -533,7 +529,7 @@ static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft) void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft)
{
- TLEN_SOCKET s = NULL;
+ HANDLE s = NULL;
HANDLE hEvent;
char *nick;
@@ -565,15 +561,13 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) TlenLog(ft->proto, "ft->s is NULL");
if (ft->state == FT_SWITCH) {
- NETLIBOPENCONNECTION nloc;
- TLEN_SOCKET s;
TlenLog(ft->proto, "Sending as client...");
ft->state = FT_CONNECTING;
- nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION);
+
+ NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- nloc.flags = 0;
- s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc);
if (s != NULL) {
SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Connecting..."));
//ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
@@ -591,11 +585,11 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) }
TlenLog(ft->proto, "Closing connection for this file transfer... ");
Netlib_CloseHandle(s);
- } else {
- ft->state = FT_ERROR;
}
+ else ft->state = FT_ERROR;
}
- } else {
+ }
+ else {
TlenLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended.");
ft->state = FT_ERROR;
}
diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp index bbd1fb7898..7c8449e3e5 100644 --- a/protocols/Tlen/src/tlen_ws.cpp +++ b/protocols/Tlen/src/tlen_ws.cpp @@ -56,7 +56,7 @@ void TlenWsUninit(TlenProtocol *proto) proto->hFileNetlibUser = NULL;
}
-TLEN_SOCKET TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
+HANDLE TlenWsConnect(TlenProtocol *proto, char *host, WORD port)
{
NETLIBOPENCONNECTION nloc = {0};
@@ -69,7 +69,7 @@ TLEN_SOCKET TlenWsConnect(TlenProtocol *proto, char *host, WORD port) }
-int TlenWsSend(TlenProtocol *proto, TLEN_SOCKET s, char *data, int datalen)
+int TlenWsSend(TlenProtocol *proto, HANDLE s, char *data, int datalen)
{
int len;
if ((len=Netlib_Send(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT)) == SOCKET_ERROR || len != datalen) {
@@ -79,7 +79,7 @@ int TlenWsSend(TlenProtocol *proto, TLEN_SOCKET s, char *data, int datalen) return TRUE;
}
-int TlenWsRecv(TlenProtocol *proto, TLEN_SOCKET s, char *data, long datalen)
+int TlenWsRecv(TlenProtocol *proto, HANDLE s, char *data, long datalen)
{
int ret;
ret = Netlib_Recv(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT);
|