From 773421e8ba17637d994088c393d406226b516a30 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 11 Oct 2013 14:01:25 +0000 Subject: - m_hNetlibUser moved to PROTO_INTERFACE; - unified protocol loggers git-svn-id: http://svn.miranda-ng.org/main/trunk@6435 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tlen/src/tlen.cpp | 4 +- protocols/Tlen/src/tlen.h | 2 - protocols/Tlen/src/tlen_avatar.cpp | 6 +-- protocols/Tlen/src/tlen_file.cpp | 90 ++++++++++++++++++------------------ protocols/Tlen/src/tlen_iqid.cpp | 6 +-- protocols/Tlen/src/tlen_misc.cpp | 2 +- protocols/Tlen/src/tlen_p2p_new.cpp | 24 +++++----- protocols/Tlen/src/tlen_p2p_old.cpp | 20 ++++---- protocols/Tlen/src/tlen_picture.cpp | 6 +-- protocols/Tlen/src/tlen_presence.cpp | 10 ++-- protocols/Tlen/src/tlen_svc.cpp | 18 ++++---- protocols/Tlen/src/tlen_thread.cpp | 60 ++++++++++++------------ protocols/Tlen/src/tlen_util.cpp | 51 +------------------- protocols/Tlen/src/tlen_voice.cpp | 74 ++++++++++++++--------------- protocols/Tlen/src/tlen_ws.cpp | 24 +++++----- 15 files changed, 173 insertions(+), 224 deletions(-) (limited to 'protocols/Tlen') diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index 92bd5d28d8..dbb36e1108 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -211,7 +211,7 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM wParam, LPARAM lParam) req.pData = form; req.dataLength = (int)strlen(form); req.szUrl = "http://poczta.o2.pl/login.html"; - resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&req); + resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req); if (resp != NULL) { if (resp->resultCode/100 == 2 || resp->resultCode == 302) { int i; @@ -264,7 +264,7 @@ int TlenProtocol::OnModulesLoaded(WPARAM wParam, LPARAM lParam) int TlenProtocol::PreShutdown(WPARAM wParam, LPARAM lParam) { - TlenLog(this, "TLEN TlenPreShutdown"); + debugLogA("TLEN TlenPreShutdown"); return 0; } diff --git a/protocols/Tlen/src/tlen.h b/protocols/Tlen/src/tlen.h index ddcf6ba3c5..9748f47742 100644 --- a/protocols/Tlen/src/tlen.h +++ b/protocols/Tlen/src/tlen.h @@ -299,7 +299,6 @@ struct TlenProtocol : public PROTO int __cdecl MUCHandleEvent(WPARAM wParam, LPARAM lParam); //==================================================================================== - HANDLE hNetlibUser; HANDLE hFileNetlibUser; TLEN_MODEMSGS modeMsgs; @@ -452,7 +451,6 @@ void uninitMenuItems(TlenProtocol *proto); HICON GetIcolibIcon(int iconId); void ReleaseIcolibIcon(HICON hIcon); -void TlenLog(TlenProtocol *proto, const char *fmt, ...); void __cdecl TlenServerThread(ThreadData *info); // tlen_ws.cpp BOOL TlenWsInit(TlenProtocol *proto); diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp index 478ae81e92..f995f7ec2e 100644 --- a/protocols/Tlen/src/tlen_avatar.cpp +++ b/protocols/Tlen/src/tlen_avatar.cpp @@ -243,7 +243,7 @@ static void TlenGetAvatarThread(void *ptr) { req.headers = NULL; req.dataLength = 0; req.szUrl = request; - resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->hNetlibUser, (LPARAM)&req); + resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->m_hNetlibUser, (LPARAM)&req); if (item != NULL) { item->newAvatarDownloading = FALSE; } @@ -309,7 +309,7 @@ static void TlenRemoveAvatarRequestThread(void *ptr) { NETLIBHTTPREQUEST *resp; TLENREMOVEAVATARTHREADDATA *data = (TLENREMOVEAVATARTHREADDATA*)ptr; NETLIBHTTPREQUEST *req = (NETLIBHTTPREQUEST *)data->req; - resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->hNetlibUser, (LPARAM)req); + resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->m_hNetlibUser, (LPARAM)req); mir_free(req->szUrl); mir_free(req->headers); mir_free(req->pData); @@ -333,7 +333,7 @@ static void TlenUploadAvatarRequestThread(void *ptr) { NETLIBHTTPREQUEST *resp; TLENUPLOADAVATARTHREADDATA * data = (TLENUPLOADAVATARTHREADDATA *) ptr; NETLIBHTTPREQUEST *req = data->req; - resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->hNetlibUser, (LPARAM)req); + resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)data->proto->m_hNetlibUser, (LPARAM)req); if (resp != NULL) { CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); SetAvatar(data->proto, NULL, NULL, data->data, data->length, PA_FORMAT_PNG); diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index d2f44dddf1..9aa2095994 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -62,7 +62,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) TlenP2PPacketSend(ft->s, packet); TlenP2PPacketFree(packet); ft->state = FT_INITIALIZING; - TlenLog(ft->proto, "Change to FT_INITIALIZING"); + ft->proto->debugLogA("Change to FT_INITIALIZING"); } } TlenP2PPacketFree(rpacket); @@ -89,10 +89,10 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) ft->fileId = _open(fullFileName, _O_BINARY|_O_WRONLY|_O_CREAT|_O_TRUNC, _S_IREAD|_S_IWRITE); ft->fileReceivedBytes = 0; ft->fileTotalSize = ft->filesSize[ft->currentFile]; - TlenLog(ft->proto, "Saving to [%s] [%d]", fullFileName, ft->filesSize[ft->currentFile]); + ft->proto->debugLogA("Saving to [%s] [%d]", fullFileName, ft->filesSize[ft->currentFile]); mir_free(fullFileName); ft->state = FT_RECEIVING; - TlenLog(ft->proto, "Change to FT_RECEIVING"); + ft->proto->debugLogA("Change to FT_RECEIVING"); } else { ft->state = FT_ERROR; @@ -111,7 +111,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) pfts.szCurrentFile = ft->files[ft->currentFile]; pfts.currentFileSize = ft->filesSize[ft->currentFile]; pfts.currentFileTime = 0; - TlenLog(ft->proto, "Receiving data..."); + ft->proto->debugLogA("Receiving data..."); while (ft->state == FT_RECEIVING) { rpacket = TlenP2PPacketReceive(ft->s); if (rpacket != NULL) { @@ -132,14 +132,14 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) } else if (rpacket->type == TLEN_FILE_PACKET_END_OF_FILE) { // end of file _close(ft->fileId); - TlenLog(ft->proto, "Finishing this file..."); + ft->proto->debugLogA("Finishing this file..."); if (ft->currentFile >= ft->fileCount-1) { ft->state = FT_DONE; } else { ft->currentFile++; ft->state = FT_INITIALIZING; - TlenLog(ft->proto, "File received, advancing to the next file..."); + ft->proto->debugLogA("File received, advancing to the next file..."); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); } } @@ -162,8 +162,8 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, vo if (ft != NULL) { slisten = ft->s; ft->s = hConnection; - TlenLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); - TlenLog(ft->proto, "Entering send loop for this file connection... (ft->s is 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)"); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileReceiveParse(ft); } @@ -171,9 +171,9 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, vo ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - TlenLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); + ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)"); ft->s = slisten; - TlenLog(ft->proto, "ft->s is restored to %d", ft->s); + ft->proto->debugLogA("ft->s is restored to %d", ft->s); if (ft->s != hConnection) { Netlib_CloseHandle(hConnection); } @@ -187,17 +187,17 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, vo static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) { - TlenLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); + ft->proto->debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); ft->mode = FT_RECV; NETLIBOPENCONNECTION nloc = { sizeof(nloc) }; 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->hNetlibUser, (LPARAM) &nloc); + HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nloc); if (s != NULL) { ft->s = s; - TlenLog(ft->proto, "Entering file receive loop"); + ft->proto->debugLogA("Entering file receive loop"); TlenP2PEstablishOutgoingConnection(ft, TRUE); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileReceiveParse(ft); @@ -208,7 +208,7 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) ft->s = NULL; } else { ft->pfnNewConnectionV2 = TlenFileReceivingConnection; - TlenLog(ft->proto, "Connection failed - receiving as server"); + ft->proto->debugLogA("Connection failed - receiving as server"); s = TlenP2PListen(ft); if (s != NULL) { HANDLE hEvent; @@ -221,11 +221,11 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) nick = TlenNickFromJID(ft->jid); TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - TlenLog(ft->proto, "Waiting for the file to be received..."); + ft->proto->debugLogA("Waiting for the file to be received..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - TlenLog(ft->proto, "Finish all files"); + ft->proto->debugLogA("Finish all files"); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; @@ -242,7 +242,7 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } - TlenLog(ft->proto, "Thread ended: type=file_receive server='%s'", ft->hostName); + ft->proto->debugLogA("Thread ended: type=file_receive server='%s'", ft->hostName); TlenP2PFreeFileTransfer(ft); } @@ -284,7 +284,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) ft->allFileReceivedBytes = 0; ft->state = FT_INITIALIZING; - TlenLog(ft->proto, "Change to FT_INITIALIZING"); + ft->proto->debugLogA("Change to FT_INITIALIZING"); } else { ft->state = FT_ERROR; @@ -292,12 +292,12 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) } else if (ft->state == FT_INITIALIZING) { // FT_INITIALIZING rpacket = TlenP2PPacketReceive(ft->s); - TlenLog(ft->proto, "FT_INITIALIZING: recv %d", rpacket); + ft->proto->debugLogA("FT_INITIALIZING: recv %d", rpacket); if (rpacket == NULL) { ft->state = FT_ERROR; return; } - TlenLog(ft->proto, "FT_INITIALIZING: recv type %d", rpacket->type); + ft->proto->debugLogA("FT_INITIALIZING: recv type %d", rpacket->type); p = rpacket->packet; // TYPE: TLEN_FILE_PACKET_FILE_LIST_ACK will be ignored // LEN: 0 @@ -316,14 +316,14 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) currentFile = *((DWORD*)p); if (currentFile != ft->currentFile) { - TlenLog(ft->proto, "Requested file (#%d) is invalid (must be %d)", currentFile, ft->currentFile); + ft->proto->debugLogA("Requested file (#%d) is invalid (must be %d)", currentFile, ft->currentFile); ft->state = FT_ERROR; } else { // _stat(ft->files[currentFile], &statbuf); // file size in statbuf.st_size - TlenLog(ft->proto, "Sending [%s] [%d]", ft->files[currentFile], ft->filesSize[currentFile]); + ft->proto->debugLogA("Sending [%s] [%d]", ft->files[currentFile], ft->filesSize[currentFile]); if ((ft->fileId=_open(ft->files[currentFile], _O_BINARY|_O_RDONLY)) < 0) { - TlenLog(ft->proto, "File cannot be opened"); + ft->proto->debugLogA("File cannot be opened"); ft->state = FT_ERROR; } else { @@ -346,7 +346,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) else { TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_DATA); fileBuffer = (char *) mir_alloc(2048); - TlenLog(ft->proto, "Sending file data..."); + ft->proto->debugLogA("Sending file data..."); while ((numRead=_read(ft->fileId, fileBuffer, 2048)) > 0) { TlenP2PPacketSetLen(packet, 0); // Reuse packet TlenP2PPacketPackDword(packet, (DWORD) ft->fileReceivedBytes); @@ -372,11 +372,11 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) else { ft->currentFile++; ft->state = FT_INITIALIZING; - TlenLog(ft->proto, "File sent, advancing to the next file..."); + ft->proto->debugLogA("File sent, advancing to the next file..."); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); } } - TlenLog(ft->proto, "Finishing this file..."); + ft->proto->debugLogA("Finishing this file..."); TlenP2PPacketSetLen(packet, 0); // Reuse packet TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_END_OF_FILE); TlenP2PPacketPackDword(packet, currentFile); @@ -403,9 +403,9 @@ static void TlenFileSendingConnection(HANDLE hConnection, DWORD dwRemoteIP, void if (ft != NULL) { slisten = ft->s; ft->s = hConnection; - TlenLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); + ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten); - TlenLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); + ft->proto->debugLogA("Entering send loop for this file connection... (ft->s is hConnection)"); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileSendParse(ft); } @@ -413,9 +413,9 @@ static void TlenFileSendingConnection(HANDLE hConnection, DWORD dwRemoteIP, void ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - TlenLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); + ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)"); ft->s = slisten; - TlenLog(ft->proto, "ft->s is restored to %d", ft->s); + ft->proto->debugLogA("ft->s is restored to %d", ft->s); if (ft->s != hConnection) { Netlib_CloseHandle(hConnection); } @@ -439,7 +439,7 @@ int TlenFileCancelAll(TlenProtocol *proto) if (ft != NULL) { if (ft->s) { //ProtoBroadcastAck(m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - TlenLog(ft->proto, "Closing ft->s = %d", ft->s); + ft->proto->debugLogA("Closing ft->s = %d", ft->s); ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); ft->s = NULL; @@ -449,7 +449,7 @@ int TlenFileCancelAll(TlenProtocol *proto) SetEvent(hEvent); } } else { - TlenLog(ft->proto, "freeing ft struct"); + ft->proto->debugLogA("freeing ft struct"); TlenP2PFreeFileTransfer(ft); } } @@ -464,7 +464,7 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) HANDLE hEvent; char *nick; - TlenLog(ft->proto, "Thread started: type=tlen_file_send"); + ft->proto->debugLogA("Thread started: type=tlen_file_send"); ft->mode = FT_SEND; ft->pfnNewConnectionV2 = TlenFileSendingConnection; s = TlenP2PListen(ft); @@ -482,28 +482,28 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) nick = TlenNickFromJID(ft->jid); TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - TlenLog(ft->proto, "Waiting for the file to be sent..."); + ft->proto->debugLogA("Waiting for the file to be sent..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - TlenLog(ft->proto, "Finish all files"); + ft->proto->debugLogA("Finish all files"); Netlib_CloseHandle(s); ft->s = NULL; - TlenLog(ft->proto, "ft->s is NULL"); + ft->proto->debugLogA("ft->s is NULL"); if (ft->state == FT_SWITCH) { - TlenLog(ft->proto, "Sending as client..."); + ft->proto->debugLogA("Sending as client..."); ft->state = FT_CONNECTING; NETLIBOPENCONNECTION nloc = { sizeof(nloc) }; nloc.szHost = ft->hostName; nloc.wPort = ft->wPort; - HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc); + HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nloc); if (s != NULL) { ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); ft->s = s; TlenP2PEstablishOutgoingConnection(ft, TRUE); - TlenLog(ft->proto, "Entering send loop for this file connection..."); + ft->proto->debugLogA("Entering send loop for this file connection..."); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileSendParse(ft); } @@ -511,20 +511,20 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - TlenLog(ft->proto, "Closing connection for this file transfer... "); + ft->proto->debugLogA("Closing connection for this file transfer... "); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; } } } else { - TlenLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended."); + ft->proto->debugLogA("Cannot allocate port to bind for file server thread, thread ended."); ft->state = FT_ERROR; } TlenListRemove(ft->proto, LIST_FILE, ft->iqId); switch (ft->state) { case FT_DONE: - TlenLog(ft->proto, "Finish successfully"); + ft->proto->debugLogA("Finish successfully"); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); break; case FT_DENIED: @@ -534,11 +534,11 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) nick = TlenNickFromJID(ft->jid); TlenSend(ft->proto, "", nick, ft->iqId); mir_free(nick); - TlenLog(ft->proto, "Finish with errors"); + ft->proto->debugLogA("Finish with errors"); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); break; } - TlenLog(ft->proto, "Thread ended: type=file_send"); + ft->proto->debugLogA("Thread ended: type=file_send"); TlenP2PFreeFileTransfer(ft); } @@ -610,7 +610,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info) pre.tszDescription = filenameT; pre.ptszFiles = &filenameT; pre.lParam = (LPARAM)ft; - TlenLog(ft->proto, "sending chainrecv"); + ft->proto->debugLogA("sending chainrecv"); ProtoChainRecvFile(ft->hContact, &pre); mir_free(filenameT); } else { diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index a7638ad549..368eb49481 100644 --- a/protocols/Tlen/src/tlen_iqid.cpp +++ b/protocols/Tlen/src/tlen_iqid.cpp @@ -195,7 +195,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) if (!db_get(hContact, proto->m_szModuleName, "AvatarHash", &dbv)) { if (item->avatarHash) mir_free(item->avatarHash); item->avatarHash = mir_strdup(dbv.pszVal); - TlenLog(proto, "Setting hash [%s] = %s", nick, item->avatarHash); + proto->debugLogA("Setting hash [%s] = %s", nick, item->avatarHash); db_free(&dbv); } item->avatarFormat = db_get_dw(hContact, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN); @@ -211,7 +211,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) ptrA jid( db_get_sa(hContact, proto->m_szModuleName, "jid")); if (jid != NULL) { if (!TlenListExist(proto, LIST_ROSTER, jid)) { - TlenLog(proto, "Syncing roster: deleting 0x%x", hContact); + proto->debugLogA("Syncing roster: deleting 0x%x", hContact); CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); } } @@ -226,7 +226,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) Menu_ModifyItem(proto->hMenuChats, &mi); proto->isOnline = TRUE; - TlenLog(proto, "Status changed via THREADSTART"); + proto->debugLogA("Status changed via THREADSTART"); oldStatus = proto->m_iStatus; TlenSendPresence(proto, proto->m_iDesiredStatus); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus); diff --git a/protocols/Tlen/src/tlen_misc.cpp b/protocols/Tlen/src/tlen_misc.cpp index 7876d2348e..ad62fbf4c3 100644 --- a/protocols/Tlen/src/tlen_misc.cpp +++ b/protocols/Tlen/src/tlen_misc.cpp @@ -57,7 +57,7 @@ void TlenDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) db_unset(hContact, proto->m_szModuleName, "Hidden"); } db_set_s(hContact, proto->m_szModuleName, "Nick", nick); - TlenLog(proto, "auth request: %s, %s", jid, nick); + proto->debugLogA("auth request: %s, %s", jid, nick); //blob is: uin(DWORD), hContact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) //blob is: 0(DWORD), hContact(HANDLE), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ) cbBlob = sizeof(DWORD) + sizeof(HANDLE) + (int)strlen(nick) + (int)strlen(jid) + 5; diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp index 80021fb004..128bde099d 100644 --- a/protocols/Tlen/src/tlen_p2p_new.cpp +++ b/protocols/Tlen/src/tlen_p2p_new.cpp @@ -48,7 +48,7 @@ static void logInfo(const char *filename, const char *fmt, ...) { void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft) { - TlenLog(ft->proto, "P2P receive thread started"); + ft->proto->debugLogA("P2P receive thread started"); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); // ft->mode = FT_RECV; // ft->currentFile = 0; @@ -109,13 +109,13 @@ void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft) else { ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } - TlenLog(ft->proto, "P2P receive thread ended"); + ft->proto->debugLogA("P2P receive thread ended"); TlenP2PFreeFileTransfer(ft); } void __cdecl TlenNewFileSendThread(TLEN_FILE_TRANSFER *ft) { - TlenLog(ft->proto, "P2P send thread started"); + ft->proto->debugLogA("P2P send thread started"); // ft->mode = FT_RECV; // ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); // ft->currentFile = 0; @@ -165,12 +165,12 @@ void __cdecl TlenNewFileSendThread(TLEN_FILE_TRANSFER *ft) SleepEx(1000, TRUE); } } - TlenLog(ft->proto, "P2P send thread ended"); + ft->proto->debugLogA("P2P send thread ended"); } void TlenBindUDPSocket(TLEN_FILE_TRANSFER *ft) { - TlenLog(ft->proto, "Binding UDP socket"); + ft->proto->debugLogA("Binding UDP socket"); ft->udps = socket(PF_INET, SOCK_DGRAM, 0); if (ft->udps != INVALID_SOCKET) { SOCKADDR_IN sin; @@ -192,7 +192,7 @@ void TlenBindUDPSocket(TLEN_FILE_TRANSFER *ft) ft->wLocalPort = ntohs(sin.sin_port); ft->localName= mir_strdup(host_name); - TlenLog(ft->proto, "UDP socket bound to %s:%d", ft->localName, ft->wLocalPort); + ft->proto->debugLogA("UDP socket bound to %s:%d", ft->localName, ft->wLocalPort); } } } @@ -269,7 +269,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { pre.tszDescription = filenameT; pre.ptszFiles = &filenameT; pre.lParam = (LPARAM)ft; - TlenLog(ft->proto, "sending chainrecv"); + ft->proto->debugLogA("sending chainrecv"); ProtoChainRecvFile(ft->hContact, &pre); mir_free(filenameT); } @@ -290,7 +290,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { } else if (dcng != NULL) { char *s, *id, *id2; - TlenLog(info->proto, "DCNG"); + info->proto->debugLogA("DCNG"); s = TlenXmlGetAttrValue(dcng, "s"); id2 = TlenXmlGetAttrValue(dcng, "i"); id = TlenXmlGetAttrValue(dcng, "mi"); @@ -321,9 +321,9 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { } } } else if (!strcmp(s, "2")) { - TlenLog(info->proto, "step = 2"); - TlenLog(info->proto, "%s",from); - TlenLog(info->proto, "%s",id2); + info->proto->debugLogA("step = 2"); + info->proto->debugLogA("%s",from); + info->proto->debugLogA("%s",id2); /* IP and port */ if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) { item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa")); @@ -337,7 +337,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { } else if (!strcmp(s, "4")) { /* IP and port */ if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) { - TlenLog(info->proto, "step = 4"); + info->proto->debugLogA("step = 4"); item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa")); item->ft->wPort = atoi(TlenXmlGetAttrValue(dcng, "pp")); forkthread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft); diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index 0d6754599b..88e561803b 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -158,7 +158,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) TLEN_FILE_PACKET *packet; TlenProtocol *proto = ft->proto; - TlenLog(proto, "Establishing outgoing connection."); + proto->debugLogA("Establishing outgoing connection."); ft->state = FT_ERROR; if ((packet = TlenP2PPacketCreate(2*sizeof(DWORD) + 20)) != NULL) { TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_CONNECTION_REQUEST); @@ -263,7 +263,7 @@ static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft) ft->state = FT_ERROR; } } - TlenLog(ft->proto, "Closing connection for this file transfer..."); + ft->proto->debugLogA("Closing connection for this file transfer..."); // Netlib_CloseHandle(ft->s); if (ft->hFileEvent != NULL) SetEvent(ft->hFileEvent); @@ -360,7 +360,7 @@ static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) nloc.wPort = sb->wPort; 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()); + ft->proto->debugLogA("Connection failed (%d), thread ended", WSAGetLastError()); return NULL; } buf[0] = 5; //yep, socks5 @@ -368,13 +368,13 @@ static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) buf[2] = sb->useAuth?2:0; // authorization status = Netlib_Send(s, (char*)buf, 3, MSG_NODUMP); if (status == SOCKET_ERROR || status < 3) { - TlenLog(ft->proto, "Send failed (%d), thread ended", WSAGetLastError()); + ft->proto->debugLogA("Send failed (%d), thread ended", WSAGetLastError()); Netlib_CloseHandle(s); return NULL; } status = Netlib_Recv(s, (char*)buf, 2, MSG_NODUMP); if (status == SOCKET_ERROR || status < 2 || (buf[1] != 0 && buf[1] != 2)) { - TlenLog(ft->proto, "SOCKS5 negotiation failed"); + ft->proto->debugLogA("SOCKS5 negotiation failed"); Netlib_CloseHandle(s); return NULL; } @@ -393,13 +393,13 @@ static HANDLE TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) status = Netlib_Send(s, (char*)pAuthBuf, 3+nUserLen+nPassLen, MSG_NODUMP); mir_free(pAuthBuf); if (status == SOCKET_ERROR || status < 3 + nUserLen+nPassLen) { - TlenLog(ft->proto, "Send failed (%d), thread ended", WSAGetLastError()); + ft->proto->debugLogA("Send failed (%d), thread ended", WSAGetLastError()); Netlib_CloseHandle(s); return NULL; } status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP); if (status == SOCKET_ERROR || status < 2 || buf[1] != 0) { - TlenLog(ft->proto, "SOCKS5 sub-negotiation failed"); + ft->proto->debugLogA("SOCKS5 sub-negotiation failed"); Netlib_CloseHandle(s); return NULL; } @@ -503,9 +503,9 @@ HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft) nlb.pfnNewConnectionV2 = ft->pfnNewConnectionV2; nlb.wPort = 0; // Use user-specified incoming port ranges, if available nlb.pExtra = proto; - TlenLog(ft->proto, "Calling MS_NETLIB_BINDPORT"); - s = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nlb); - TlenLog(ft->proto, "listening on %d",s); + ft->proto->debugLogA("Calling MS_NETLIB_BINDPORT"); + s = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nlb); + ft->proto->debugLogA("listening on %d",s); } if (useProxy == 0) { in.S_un.S_addr = htonl(nlb.dwExternalIP); diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index ee241ead74..3f0156f3f8 100644 --- a/protocols/Tlen/src/tlen_picture.cpp +++ b/protocols/Tlen/src/tlen_picture.cpp @@ -60,7 +60,7 @@ static void TlenPsPostThread(void *ptr) { char fileBuffer[2048]; mir_snprintf(header, sizeof(header), "", item->ft->iqId, item->jid); TlenWsSend(proto, socket, header, (int)strlen(header)); - TlenLog(proto, "Sending picture data..."); + proto->debugLogA("Sending picture data..."); for (i = item->ft->filesSize[0]; i > 0; ) { int toread = min(2048, i); int readcount = (int)fread(fileBuffer, (size_t)1, (size_t)toread, fp); @@ -116,7 +116,7 @@ static void TlenPsGetThread(void *ptr) { TlenXmlInitState(&xmlState); mir_snprintf(header, sizeof(header), "", proto->threadData->username, item->ft->jid, item->jid, item->ft->id2); TlenWsSend(proto, socket, header, (int)strlen(header)); - TlenLog(proto, "Reveiving picture data..."); + proto->debugLogA("Reveiving picture data..."); { int totalcount = 0; int size = item->ft->filesSize[0]; @@ -153,7 +153,7 @@ static void TlenPsGetThread(void *ptr) { } } Netlib_CloseHandle(socket); - TlenLog(proto, "Picture received..."); + proto->debugLogA("Picture received..."); LogPictureMessage(proto, item->ft->jid, item->ft->files[0], FALSE); } else { /* cannot connect to ps server */ diff --git a/protocols/Tlen/src/tlen_presence.cpp b/protocols/Tlen/src/tlen_presence.cpp index 52a8ca12c7..4d20d08f6a 100644 --- a/protocols/Tlen/src/tlen_presence.cpp +++ b/protocols/Tlen/src/tlen_presence.cpp @@ -49,7 +49,7 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) if ((hContact=TlenHContactFromJID(proto, from)) == NULL) hContact = TlenDBCreateContact(proto, from, nick, FALSE); if (!TlenListExist(proto, LIST_ROSTER, from)) { - TlenLog(proto, "Receive presence online from %s (who is not in my roster)", from); + proto->debugLogA("Receive presence online from %s (who is not in my roster)", from); TlenListAdd(proto, LIST_ROSTER, from); } status = ID_STATUS_ONLINE; @@ -100,13 +100,13 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) } } } - TlenLog(proto, "%s (%s) online, set contact status to %d", nick, from, status); + proto->debugLogA("%s (%s) online, set contact status to %d", nick, from, status); mir_free(nick); } } else if (!strcmp(type, "unavailable")) { if (!TlenListExist(proto, LIST_ROSTER, from)) { - TlenLog(proto, "Receive presence offline from %s (who is not in my roster)", from); + proto->debugLogA("Receive presence offline from %s (who is not in my roster)", from); TlenListAdd(proto, LIST_ROSTER, from); } else { @@ -144,7 +144,7 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) item->isTyping = FALSE; CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, PROTOTYPE_CONTACTTYPING_OFF); } - TlenLog(proto, "%s offline, set contact status to %d", from, status); + proto->debugLogA("%s offline, set contact status to %d", from, status); } } else if (!strcmp(type, "subscribe")) { @@ -153,7 +153,7 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) TlenSend(proto, "", from); } else if ((nick=TlenNickFromJID(from)) != NULL) { - TlenLog(proto, "%s (%s) requests authorization", nick, from); + proto->debugLogA("%s (%s) requests authorization", nick, from); TlenDBAddAuthRequest(proto, from, nick); mir_free(nick); } diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp index acfa66bc9b..7ee18ce37c 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -298,7 +298,7 @@ int TlenProtocol::Authorize(HANDLE hDbEvent) TLEN_LIST_ITEM *item; if ((item=TlenListGetItemPtr(this, LIST_ROSTER, jid)) == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { - TlenLog(this, "Try adding contact automatically jid=%s", jid); + debugLogA("Try adding contact automatically jid=%s", jid); if ((hContact=AddToListByJID(this, jid, 0)) != NULL) { // Trigger actual add by removing the "NotOnList" added by AddToListByJID() // See AddToListByJID() and TlenDbSettingChanged(). @@ -421,7 +421,7 @@ int TlenProtocol::SetAwayMsg(int iStatus, const PROTOCHAR* msg) char **szMsg; char *newModeMsg; - TlenLog(this, "SetAwayMsg called, wParam=%d lParam=%s", iStatus, msg); + debugLogA("SetAwayMsg called, wParam=%d lParam=%s", iStatus, msg); newModeMsg = TlenTextEncode(mir_t2a(msg)); //TODO TCHAR @@ -763,7 +763,7 @@ int TlenProtocol::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** sz int TlenProtocol::FileCancel(HANDLE hContact, HANDLE hTransfer) { TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) hTransfer; - TlenLog(this, "Invoking FileCancel()"); + debugLogA("Invoking FileCancel()"); if (ft->s != NULL) { ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); @@ -800,7 +800,7 @@ HANDLE TlenProtocol::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, P for (i=j=0; ifileCount; i++) { char* ppszFiles_i_A = mir_t2a(ppszFiles[i]); if (_stat(ppszFiles_i_A, &statbuf)) - TlenLog(this, "'%s' is an invalid filename", ppszFiles[i]); + debugLogA("'%s' is an invalid filename", ppszFiles[i]); else { ft->filesSize[j] = statbuf.st_size; ft->files[j++] = mir_strdup(ppszFiles_i_A); @@ -915,13 +915,13 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) if (nick != NULL) { // Note: we need to compare with item->group to prevent infinite loop if (cws->value.type == DBVT_DELETED && item->group != NULL) { - TlenLog(this, "Group set to nothing"); + debugLogA("Group set to nothing"); TlenSend(this, "", nick, item->jid); } else if (cws->value.pszVal != NULL) { char *newGroup = settingToChar(cws); if (item->group == NULL || strcmp(newGroup, item->group)) { - TlenLog(this, "Group set to %s", newGroup); + debugLogA("Group set to %s", newGroup); if ((group=TlenGroupEncode(newGroup)) != NULL) { TlenSend(this, "%s", nick, item->jid, group); mir_free(group); @@ -958,7 +958,7 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) // Note: we need to compare with item->nick to prevent infinite loop if (newNick != NULL && (item->nick == NULL || (item->nick != NULL && strcmp(item->nick, newNick)))) { if ((nick=TlenTextEncode(newNick)) != NULL) { - TlenLog(this, "Nick set to %s", newNick); + debugLogA("Nick set to %s", newNick); if (item->group != NULL && (group=TlenGroupEncode(item->group)) != NULL) { TlenSend(this, "%s", nick, jid, group); mir_free(group); @@ -981,7 +981,7 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { jid = mir_strdup(dbv.pszVal); db_free(&dbv); - TlenLog(this, "Add %s permanently to list", jid); + debugLogA("Add %s permanently to list", jid); if (!db_get(hContact, "CList", "MyHandle", &dbv)) { nick = TlenTextEncode(dbv.pszVal); //Utf8Encode db_free(&dbv); @@ -990,7 +990,7 @@ int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) nick = TlenNickFromJID(jid); } if (nick != NULL) { - TlenLog(this, "jid=%s nick=%s", jid, nick); + debugLogA("jid=%s nick=%s", jid, nick); if (!db_get(hContact, "CList", "Group", &dbv)) { if ((pGroup=TlenGroupEncode(dbv.pszVal)) != NULL) { TlenSend(this, "%s", nick, jid, pGroup); diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index a08f3763a8..42a34bfa5f 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -113,7 +113,7 @@ void __cdecl TlenServerThread(ThreadData *info) int numRetry; int reconnectTime; int loginErr = 0; - TlenLog(info->proto, "Thread started"); + info->proto->debugLogA("Thread started"); // Normal server connection, we will fetch all connection parameters // e.g. username, password, etc. from the database. @@ -124,7 +124,7 @@ void __cdecl TlenServerThread(ThreadData *info) // in case it is asleep in the reconnect loop so that it will immediately // reconnect. QueueUserAPC(TlenDummyApcFunc, info->proto->threadData->hThread, 0); - TlenLog(info->proto, "Thread ended, another normal thread is running"); + info->proto->debugLogA("Thread ended, another normal thread is running"); mir_free(info); return; } @@ -139,7 +139,7 @@ void __cdecl TlenServerThread(ThreadData *info) db_free(&dbv); } else { - TlenLog(info->proto, "Thread ended, login name is not configured"); + info->proto->debugLogA("Thread ended, login name is not configured"); loginErr = LOGINERR_BADUSERID; } @@ -151,7 +151,7 @@ void __cdecl TlenServerThread(ThreadData *info) db_set_s(NULL, info->proto->m_szModuleName, "LoginServer", info->server); db_free(&dbv); } else { - TlenLog(info->proto, "Thread ended, login server is not configured"); + info->proto->debugLogA("Thread ended, login server is not configured"); loginErr = LOGINERR_NONETWORK; } } @@ -172,7 +172,7 @@ void __cdecl TlenServerThread(ThreadData *info) strncpy(info->password, onlinePassword, sizeof(info->password)); info->password[sizeof(info->password)-1] = '\0'; } else { - TlenLog(info->proto, "Thread ended, password request dialog was canceled"); + info->proto->debugLogA("Thread ended, password request dialog was canceled"); loginErr = LOGINERR_BADUSERID; } } else { @@ -182,7 +182,7 @@ void __cdecl TlenServerThread(ThreadData *info) info->password[sizeof(info->password)-1] = '\0'; db_free(&dbv); } else { - TlenLog(info->proto, "Thread ended, password is not configured"); + info->proto->debugLogA("Thread ended, password is not configured"); loginErr = LOGINERR_BADUSERID; } } @@ -190,7 +190,7 @@ void __cdecl TlenServerThread(ThreadData *info) tlenNetworkBufferSize = 2048; if ((buffer=(char *) mir_alloc(tlenNetworkBufferSize+1)) == NULL) { // +1 is for '\0' when debug logging this buffer - TlenLog(info->proto, "Thread ended, network buffer cannot be allocated"); + info->proto->debugLogA("Thread ended, network buffer cannot be allocated"); loginErr = LOGINERR_NONETWORK; } @@ -220,7 +220,7 @@ void __cdecl TlenServerThread(ThreadData *info) else connectHost = info->server; - TlenLog(info->proto, "Thread server='%s' port='%d'", connectHost, info->port); + info->proto->debugLogA("Thread server='%s' port='%d'", connectHost, info->port); if (!db_get(NULL, info->proto->m_szModuleName, "AvatarHash", &dbv)) { @@ -237,7 +237,7 @@ void __cdecl TlenServerThread(ThreadData *info) info->s = TlenWsConnect(info->proto, connectHost, info->port); if (info->s == NULL) { - TlenLog(info->proto, "Connection failed (%d)", WSAGetLastError()); + info->proto->debugLogA("Connection failed (%d)", WSAGetLastError()); if (info->proto->threadData == info) { oldStatus = info->proto->m_iStatus; info->proto->m_iStatus = ID_STATUS_OFFLINE; @@ -245,12 +245,12 @@ void __cdecl TlenServerThread(ThreadData *info) ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus); if (info->proto->tlenOptions.reconnect == TRUE) { reconnectTime = rand() % reconnectMaxTime; - TlenLog(info->proto, "Sleeping %d seconds before automatic reconnecting...", reconnectTime); + info->proto->debugLogA("Sleeping %d seconds before automatic reconnecting...", reconnectTime); SleepEx(reconnectTime * 1000, TRUE); if (reconnectMaxTime < 10*60) // Maximum is 10 minutes reconnectMaxTime *= 2; if (info->proto->threadData == info) { // Make sure this is still the active thread for the main Tlen connection - TlenLog(info->proto, "Reconnecting to the network..."); + info->proto->debugLogA("Reconnecting to the network..."); if (numRetry < MAX_CONNECT_RETRIES) numRetry++; oldStatus = info->proto->m_iStatus; @@ -259,7 +259,7 @@ void __cdecl TlenServerThread(ThreadData *info) continue; } else { - TlenLog(info->proto, "Thread ended, connection failed"); + info->proto->debugLogA("Thread ended, connection failed"); mir_free(buffer); mir_free(info); return; @@ -267,7 +267,7 @@ void __cdecl TlenServerThread(ThreadData *info) } info->proto->threadData = NULL; } - TlenLog(info->proto, "Thread ended, connection failed"); + info->proto->debugLogA("Thread ended, connection failed"); mir_free(buffer); mir_free(info); return; @@ -293,7 +293,7 @@ void __cdecl TlenServerThread(ThreadData *info) TlenSend(info->proto, ""); } - TlenLog(info->proto, "Entering main recv loop"); + info->proto->debugLogA("Entering main recv loop"); datalen = 0; for (;;) { @@ -310,10 +310,10 @@ void __cdecl TlenServerThread(ThreadData *info) datalen += recvResult; buffer[datalen] = '\0'; - TlenLog(info->proto, "RECV:%s", buffer); + info->proto->debugLogA("RECV:%s", buffer); bytesParsed = TlenXmlParse(&xmlState, buffer, datalen); - TlenLog(info->proto, "bytesParsed = %d", bytesParsed); + info->proto->debugLogA("bytesParsed = %d", bytesParsed); if (bytesParsed > 0) { if (bytesParsed < datalen) memmove(buffer, buffer+bytesParsed, datalen-bytesParsed); @@ -321,14 +321,14 @@ void __cdecl TlenServerThread(ThreadData *info) } else if (datalen == tlenNetworkBufferSize) { tlenNetworkBufferSize += 2048; - TlenLog(info->proto, "Increasing network buffer size to %d", tlenNetworkBufferSize); + info->proto->debugLogA("Increasing network buffer size to %d", tlenNetworkBufferSize); if ((buffer=(char *) mir_realloc(buffer, tlenNetworkBufferSize+1)) == NULL) { - TlenLog(info->proto, "Cannot reallocate more network buffer, go offline now"); + info->proto->debugLogA("Cannot reallocate more network buffer, go offline now"); break; } } else { - TlenLog(info->proto, "Unknown state: bytesParsed=%d, datalen=%d, tlenNetworkBufferSize=%d", bytesParsed, datalen, tlenNetworkBufferSize); + info->proto->debugLogA("Unknown state: bytesParsed=%d, datalen=%d, tlenNetworkBufferSize=%d", bytesParsed, datalen, tlenNetworkBufferSize); } } @@ -370,12 +370,12 @@ void __cdecl TlenServerThread(ThreadData *info) if (info->proto->threadData != info) // Make sure this is still the main Tlen connection thread break; reconnectTime = rand() % 10; - TlenLog(info->proto, "Sleeping %d seconds before automatic reconnecting...", reconnectTime); + info->proto->debugLogA("Sleeping %d seconds before automatic reconnecting...", reconnectTime); SleepEx(reconnectTime * 1000, TRUE); reconnectMaxTime = 20; if (info->proto->threadData != info) // Make sure this is still the main Tlen connection thread break; - TlenLog(info->proto, "Reconnecting to the network..."); + info->proto->debugLogA("Reconnecting to the network..."); info->proto->m_iDesiredStatus = oldStatus; // Reconnect to my last status oldStatus = info->proto->m_iStatus; info->proto->m_iStatus = ID_STATUS_CONNECTING; @@ -383,7 +383,7 @@ void __cdecl TlenServerThread(ThreadData *info) ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus); } - TlenLog(info->proto, "Thread ended: server='%s'", info->server); + info->proto->debugLogA("Thread ended: server='%s'", info->server); if (info->proto->threadData == info) { info->proto->threadData = NULL; @@ -391,7 +391,7 @@ void __cdecl TlenServerThread(ThreadData *info) mir_free(buffer); if (info->streamId) mir_free(info->streamId); - TlenLog(info->proto, "Exiting ServerThread"); + info->proto->debugLogA("Exiting ServerThread"); mir_free(info); } @@ -500,7 +500,7 @@ static void TlenProcessProtocol(XmlNode *node, ThreadData *info) else if (!strcmp(node->name, "cipher")) TlenProcessCipher(node, info); else - TlenLog(info->proto, "Invalid top-level tag (only

and allowed)"); + info->proto->debugLogA("Invalid top-level tag (only

and allowed)"); } @@ -747,7 +747,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info) // MATCH BY ID ///////////////////////////////////////////////////////////////////////// if ((pfunc=TlenIqFetchFunc(info->proto, id)) != NULL) { - TlenLog(info->proto, "Handling iq request for id=%d", id); + info->proto->debugLogA("Handling iq request for id=%d", id); pfunc(info->proto, node); ///////////////////////////////////////////////////////////////////////// // MORE GENERAL ROUTINES, WHEN ID DOES NOT MATCH @@ -768,7 +768,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info) TLEN_LIST_ITEM *item; char *name; - TlenLog(info->proto, " Got roster push, query has %d children", queryNode->numChild); + info->proto->debugLogA(" Got roster push, query has %d children", queryNode->numChild); for (i=0; inumChild; i++) { itemNode = queryNode->child[i]; if (!strcmp(itemNode->name, "item")) { @@ -816,7 +816,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info) else if (!strcmp(str, "to")) item->subscription = SUB_TO; else if (!strcmp(str, "from")) item->subscription = SUB_FROM; else item->subscription = SUB_NONE; - TlenLog(info->proto, "Roster push for jid=%s, set subscription to %s", jid, str); + info->proto->debugLogA("Roster push for jid=%s, set subscription to %s", jid, str); // subscription = remove is to remove from roster list // but we will just set the contact to offline and not actually // remove, so that history will be retained. @@ -1333,9 +1333,9 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) // FILE_SEND : e='5' : Voice request was accepted if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { - TlenLog(info->proto, "should start voice 1 ? %s ?? %s", jid, item->ft->jid); + info->proto->debugLogA("should start voice 1 ? %s ?? %s", jid, item->ft->jid); if (!strcmp(item->ft->jid, jid)) { - TlenLog(info->proto, "starting voice 1"); + info->proto->debugLogA("starting voice 1"); TlenVoiceStart(item->ft, 1); } } @@ -1400,6 +1400,6 @@ static void __cdecl TlenKeepAliveThread(void *ptr) if (proto->tlenOptions.sendKeepAlive) TlenSend(proto, " \t "); } - TlenLog(proto, "Exiting KeepAliveThread"); + proto->debugLogA("Exiting KeepAliveThread"); } diff --git a/protocols/Tlen/src/tlen_util.cpp b/protocols/Tlen/src/tlen_util.cpp index 6f13a7dd99..5ac920336e 100644 --- a/protocols/Tlen/src/tlen_util.cpp +++ b/protocols/Tlen/src/tlen_util.cpp @@ -49,55 +49,6 @@ unsigned int TlenSerialNext(TlenProtocol *proto) return ret; } - -void TlenLog(TlenProtocol *proto, const char *fmt, ...) -{ -#ifdef ENABLE_LOGGING - char *str; - va_list vararg; - int strsize; - char *text; - char *p, *q; - int extra; - - va_start(vararg, fmt); - str = (char *) mir_alloc(strsize=2048); - while (mir_vsnprintf(str, strsize, fmt, vararg) == -1) - str = (char *) mir_realloc(str, strsize+=2048); - va_end(vararg); - - extra = 0; - for (p=str; *p != '\0'; p++) - if (*p == '\n' || *p == '\r') - extra++; - size_t size = strlen("TLEN") + 2 + strlen(str) + 2 + extra; - text = (char *) mir_alloc(size); - mir_snprintf(text, size, "[%s]", "TLEN"); - for (p=str,q=text+strlen(text); *p != '\0'; p++,q++) { - if (*p == '\r') { - *q = '\\'; - *(q+1) = 'r'; - q++; - } - else if (*p == '\n') { - *q = '\\'; - *(q+1) = 'n'; - q++; - } - else - *q = *p; - } - *q = '\n'; - *(q+1) = '\0'; - if (proto->hNetlibUser != NULL) { - CallService(MS_NETLIB_LOG, (WPARAM) proto->hNetlibUser, (LPARAM) text); - } - //OutputDebugString(text); - mir_free(text); - mir_free(str); -#endif -} - // Caution: DO NOT use TlenSend() to send binary (non-string) data int TlenSend(TlenProtocol *proto, const char *fmt, ...) @@ -118,7 +69,7 @@ int TlenSend(TlenProtocol *proto, const char *fmt, ...) } va_end(vararg); - TlenLog(proto, "SEND:%s", str); + proto->debugLogA("SEND:%s", str); size = (int)strlen(str); if (proto->threadData != NULL) { if (proto->threadData->useAES) { diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp index e1d7774295..9739aa53a7 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -91,7 +91,7 @@ static DWORD WINAPI TlenVoiceRecordingThreadProc(TLEN_VOICE_CONTROL *control) } } control->isRunning = 0; - TlenLog(control->proto, "recording thread ended..."); + control->proto->debugLogA("recording thread ended..."); return 0; } @@ -148,18 +148,18 @@ static int TlenVoicePlaybackStart(TLEN_VOICE_CONTROL *control) } } if (!waveOutGetDevCaps(iSelDev, &wic, sizeof(WAVEOUTCAPS))) { - TlenLog(control->proto, "Playback device ID #%u: %s\r\n", iSelDev, wic.szPname); + control->proto->debugLogA("Playback device ID #%u: %s\r\n", iSelDev, wic.szPname); } mmres = waveOutOpen(&control->hWaveOut, iSelDev, &wfm, (DWORD) &TlenVoicePlaybackCallback, (DWORD) control, CALLBACK_FUNCTION); if (mmres != MMSYSERR_NOERROR) { - TlenLog(control->proto, "TlenVoiceStart FAILED!"); + control->proto->debugLogA("TlenVoiceStart FAILED!"); return 1; } control->waveData = (short *)mir_alloc(control->waveHeadersNum * control->waveFrameSize * 2); memset(control->waveData, 0, control->waveHeadersNum * control->waveFrameSize * 2); control->waveHeaders = (WAVEHDR *)mir_alloc(control->waveHeadersNum * sizeof(WAVEHDR)); - TlenLog(control->proto, "TlenVoiceStart OK!"); + control->proto->debugLogA("TlenVoiceStart OK!"); return 0; } @@ -215,14 +215,14 @@ static int TlenVoiceRecordingStart(TLEN_VOICE_CONTROL *control) } } if (!waveInGetDevCaps(iSelDev, &wic, sizeof(WAVEINCAPS))) { - TlenLog(control->proto, "Recording device ID #%u: %s\r\n", iSelDev, wic.szPname); + control->proto->debugLogA("Recording device ID #%u: %s\r\n", iSelDev, wic.szPname); } mmres = waveInOpen(&control->hWaveIn, iSelDev, &wfm, (DWORD) control->threadID, 0, CALLBACK_THREAD); // mmres = waveInOpen(&control->hWaveIn, 3, &wfm, (DWORD) &TlenVoiceRecordingCallback, (DWORD) control, CALLBACK_FUNCTION); if (mmres != MMSYSERR_NOERROR) { PostThreadMessage(control->threadID, WIM_CLOSE, 0, 0); - TlenLog(control->proto, "TlenVoiceStart FAILED %d!", mmres); + control->proto->debugLogA("TlenVoiceStart FAILED %d!", mmres); return 1; } control->waveData = (short *)mir_alloc(control->waveHeadersNum * control->waveFrameSize * 2); @@ -236,7 +236,7 @@ static int TlenVoiceRecordingStart(TLEN_VOICE_CONTROL *control) if (mmres != MMSYSERR_NOERROR) { waveInClose(control->hWaveIn); // PostThreadMessage(control->threadID, WIM_CLOSE, 0, 0); - TlenLog(control->proto, "TlenVoiceStart FAILED #2!"); + control->proto->debugLogA("TlenVoiceStart FAILED #2!"); return 1; } } @@ -244,7 +244,7 @@ static int TlenVoiceRecordingStart(TLEN_VOICE_CONTROL *control) waveInAddBuffer(control->hWaveIn, &control->waveHeaders[i], sizeof(WAVEHDR)); } waveInStart(control->hWaveIn); - TlenLog(control->proto, "TlenVoiceRStart OK!"); + control->proto->debugLogA("TlenVoiceRStart OK!"); return 0; } @@ -262,7 +262,7 @@ static TLEN_VOICE_CONTROL *TlenVoiceCreateVC(TlenProtocol *proto, int codec) static void TlenVoiceFreeVc(TLEN_VOICE_CONTROL *vc) { int i; - TlenLog(vc->proto, "-> TlenVoiceFreeVc"); + vc->proto->debugLogA("-> TlenVoiceFreeVc"); vc->stopThread = 1; PostThreadMessage(vc->threadID, MM_WIM_CLOSE, 0, 0); while (vc->isRunning) { @@ -292,7 +292,7 @@ static void TlenVoiceFreeVc(TLEN_VOICE_CONTROL *vc) if (vc->waveData) mir_free(vc->waveData); if (vc->waveHeaders) mir_free(vc->waveHeaders); if (vc->gsmstate) gsm_release(vc->gsmstate); - TlenLog(vc->proto, "<- TlenVoiceFreeVc"); + vc->proto->debugLogA("<- TlenVoiceFreeVc"); mir_free(vc); } @@ -312,16 +312,16 @@ static void TlenVoiceCrypt(char *buffer, int len) void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) { - TlenLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); + ft->proto->debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); 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->hNetlibUser, (LPARAM) &nloc); + HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nloc); if (s != NULL) { ft->s = s; - TlenLog(ft->proto, "Entering file receive loop"); + ft->proto->debugLogA("Entering file receive loop"); TlenP2PEstablishOutgoingConnection(ft, FALSE); if (ft->state != FT_ERROR) { ft->proto->playbackControl = NULL; @@ -340,7 +340,7 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) } ft->s = NULL; } else { - TlenLog(ft->proto, "Connection failed - receiving as server"); + ft->proto->debugLogA("Connection failed - receiving as server"); ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection; s = TlenP2PListen(ft); if (s != NULL) { @@ -355,11 +355,11 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) nick = TlenNickFromJID(ft->jid); TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - TlenLog(ft->proto, "Waiting for the file to be received..."); + ft->proto->debugLogA("Waiting for the file to be received..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - TlenLog(ft->proto, "Finish all files"); + ft->proto->debugLogA("Finish all files"); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; @@ -377,7 +377,7 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Error...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } - TlenLog(ft->proto, "Thread ended: type=file_receive server='%s'", ft->hostName); + ft->proto->debugLogA("Thread ended: type=file_receive server='%s'", ft->hostName); TlenP2PFreeFileTransfer(ft); } @@ -392,8 +392,8 @@ static void TlenVoiceReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, v if (ft != NULL) { slisten = ft->s; ft->s = hConnection; - TlenLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); - TlenLog(ft->proto, "Entering send loop for this file connection... (ft->s is 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)"); proto->playbackControl = NULL; proto->recordingControl = TlenVoiceCreateVC(proto, 3); proto->recordingControl->ft = ft; @@ -411,9 +411,9 @@ static void TlenVoiceReceivingConnection(HANDLE hConnection, DWORD dwRemoteIP, v // ProtoBroadcastAck(proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Error...")); } - TlenLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); + ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)"); ft->s = slisten; - TlenLog(ft->proto, "ft->s is restored to %d", ft->s); + ft->proto->debugLogA("ft->s is restored to %d", ft->s); } Netlib_CloseHandle(hConnection); if (ft != NULL && ft->hFileEvent != NULL) @@ -533,7 +533,7 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) HANDLE hEvent; char *nick; - TlenLog(ft->proto, "Thread started: type=voice_send"); + ft->proto->debugLogA("Thread started: type=voice_send"); ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection; s = TlenP2PListen(ft); if (s != NULL) { @@ -551,30 +551,30 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) nick = TlenNickFromJID(ft->jid); TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - TlenLog(ft->proto, "Waiting for the voice data to be sent..."); + ft->proto->debugLogA("Waiting for the voice data to be sent..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - TlenLog(ft->proto, "Finish voice"); + ft->proto->debugLogA("Finish voice"); Netlib_CloseHandle(s); ft->s = NULL; - TlenLog(ft->proto, "ft->s is NULL"); + ft->proto->debugLogA("ft->s is NULL"); if (ft->state == FT_SWITCH) { - TlenLog(ft->proto, "Sending as client..."); + ft->proto->debugLogA("Sending as client..."); ft->state = FT_CONNECTING; NETLIBOPENCONNECTION nloc = { sizeof(nloc) }; nloc.szHost = ft->hostName; nloc.wPort = ft->wPort; - HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc); + HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_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); ft->s = s; TlenP2PEstablishOutgoingConnection(ft, FALSE); if (ft->state != FT_ERROR) { - TlenLog(ft->proto, "Entering send loop for this file connection..."); + ft->proto->debugLogA("Entering send loop for this file connection..."); ft->proto->playbackControl = NULL; ft->proto->recordingControl = TlenVoiceCreateVC(ft->proto, 3); ft->proto->recordingControl->ft = ft; @@ -583,20 +583,20 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) TlenVoiceReceiveParse(ft); } } - TlenLog(ft->proto, "Closing connection for this file transfer... "); + ft->proto->debugLogA("Closing connection for this file transfer... "); Netlib_CloseHandle(s); } else ft->state = FT_ERROR; } } else { - TlenLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended."); + ft->proto->debugLogA("Cannot allocate port to bind for file server thread, thread ended."); ft->state = FT_ERROR; } TlenListRemove(ft->proto, LIST_VOICE, ft->iqId); switch (ft->state) { case FT_DONE: - TlenLog(ft->proto, "Finish successfully"); + ft->proto->debugLogA("Finish successfully"); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Finished...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); break; @@ -608,12 +608,12 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) nick = TlenNickFromJID(ft->jid); TlenSend(ft->proto, "", nick, ft->iqId); mir_free(nick); - TlenLog(ft->proto, "Finish with errors"); + ft->proto->debugLogA("Finish with errors"); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Error...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); break; } - TlenLog(ft->proto, "Thread ended: type=voice_send"); + ft->proto->debugLogA("Thread ended: type=voice_send"); TlenP2PFreeFileTransfer(ft); } @@ -669,7 +669,7 @@ int TlenVoiceCancelAll(TlenProtocol *proto) if (ft != NULL) { if (ft->s) { //ProtoBroadcastAck(proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - TlenLog(proto, "Closing ft->s = %d", ft->s); + proto->debugLogA("Closing ft->s = %d", ft->s); ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); ft->s = NULL; @@ -679,7 +679,7 @@ int TlenVoiceCancelAll(TlenProtocol *proto) SetEvent(hEvent); } } else { - TlenLog(proto, "freeing (V) ft struct"); + proto->debugLogA("freeing (V) ft struct"); TlenP2PFreeFileTransfer(ft); } } @@ -719,7 +719,7 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM lParam) int TlenVoiceIsInUse(TlenProtocol *proto) { if (TlenListFindNext(proto, LIST_VOICE, 0) >= 0 || proto->voiceDlgHWND != NULL) { - TlenLog(proto, "voice in use ? %d", proto->voiceDlgHWND); + proto->debugLogA("voice in use ? %d", proto->voiceDlgHWND); return 1; } return 0; @@ -928,7 +928,7 @@ static void __cdecl TlenVoiceDlgThread(void *ptr) int TlenVoiceStart(TLEN_FILE_TRANSFER *ft, int mode) { - TlenLog(ft->proto, "starting voice %d", mode); + ft->proto->debugLogA("starting voice %d", mode); if (mode == 0) { forkthread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, ft); } else if (mode == 1) { diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp index 7c8449e3e5..7e31aedd37 100644 --- a/protocols/Tlen/src/tlen_ws.cpp +++ b/protocols/Tlen/src/tlen_ws.cpp @@ -35,7 +35,7 @@ BOOL TlenWsInit(TlenProtocol *proto) mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), proto->m_tszUserName); nlu.ptszDescriptiveName = name; nlu.szSettingsModule = proto->m_szModuleName; - proto->hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) &nlu); + proto->m_hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) &nlu); nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_NOOPTIONS | NUF_TCHAR; mir_sntprintf(name, SIZEOF(name), TranslateT("%s SOCKS connection"), proto->m_tszUserName); @@ -45,14 +45,14 @@ BOOL TlenWsInit(TlenProtocol *proto) nlus.useProxy = 0; CallService(MS_NETLIB_SETUSERSETTINGS, (WPARAM) proto->hFileNetlibUser, (LPARAM) &nlus); - return (proto->hNetlibUser != NULL)?TRUE:FALSE; + return (proto->m_hNetlibUser != NULL)?TRUE:FALSE; } void TlenWsUninit(TlenProtocol *proto) { - if (proto->hNetlibUser != NULL) Netlib_CloseHandle(proto->hNetlibUser); + if (proto->m_hNetlibUser != NULL) Netlib_CloseHandle(proto->m_hNetlibUser); if (proto->hFileNetlibUser != NULL) Netlib_CloseHandle(proto->hFileNetlibUser); - proto->hNetlibUser = NULL; + proto->m_hNetlibUser = NULL; proto->hFileNetlibUser = NULL; } @@ -65,7 +65,7 @@ HANDLE TlenWsConnect(TlenProtocol *proto, char *host, WORD port) nloc.wPort = port; nloc.flags = 0; nloc.timeout = 6; - return (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) proto->hNetlibUser, (LPARAM) &nloc); + return (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) proto->m_hNetlibUser, (LPARAM) &nloc); } @@ -73,7 +73,7 @@ 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) { - TlenLog(proto, "Netlib_Send() failed, error=%d", WSAGetLastError()); + proto->debugLogA("Netlib_Send() failed, error=%d", WSAGetLastError()); return FALSE; } return TRUE; @@ -84,11 +84,11 @@ int TlenWsRecv(TlenProtocol *proto, HANDLE s, char *data, long datalen) int ret; ret = Netlib_Recv(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT); if (ret == SOCKET_ERROR) { - TlenLog(proto, "Netlib_Recv() failed, error=%d", WSAGetLastError()); + proto->debugLogA("Netlib_Recv() failed, error=%d", WSAGetLastError()); return 0; } if (ret == 0) { - TlenLog(proto, "Connection closed gracefully"); + proto->debugLogA("Connection closed gracefully"); return 0; } return ret; @@ -115,9 +115,9 @@ int TlenWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes len += 16; } if (len > 0) { - TlenLog(proto, "Sending %d bytes", len); + proto->debugLogA("Sending %d bytes", len); if ((sendlen=Netlib_Send(proto->threadData->s, (char *)aes_output, len, MSG_NODUMP)) == SOCKET_ERROR || len != sendlen) { - TlenLog(proto, "Netlib_Send() failed, error=%d", WSAGetLastError()); + proto->debugLogA("Netlib_Send() failed, error=%d", WSAGetLastError()); return FALSE; } } @@ -136,11 +136,11 @@ int TlenWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *ae for (maxlen = maxlen & ~0xF; maxlen != 0; maxlen = maxlen & 0xF) { ret = Netlib_Recv(proto->threadData->s, data, maxlen, MSG_NODUMP); if (ret == SOCKET_ERROR) { - TlenLog(proto, "Netlib_Recv() failed, error=%d", WSAGetLastError()); + proto->debugLogA("Netlib_Recv() failed, error=%d", WSAGetLastError()); return 0; } if (ret == 0) { - TlenLog(proto, "Connection closed gracefully"); + proto->debugLogA("Connection closed gracefully"); return 0; } data += ret; -- cgit v1.2.3