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 /protocols/Tlen | |
parent | 39955d4f87fbf76691b4fd2cb7e46940608a2a90 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6372 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tlen')
-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 |
7 files changed, 50 insertions, 67 deletions
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);
|