summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_file.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-11 14:01:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-11 14:01:25 +0000
commit773421e8ba17637d994088c393d406226b516a30 (patch)
tree130c0bf529e30f493ae4f2abbe1230d31fecdeed /protocols/JabberG/src/jabber_file.cpp
parent3fc8b6f686262e8a595fc10b2bd947526ca77bdc (diff)
- 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
Diffstat (limited to 'protocols/JabberG/src/jabber_file.cpp')
-rw-r--r--protocols/JabberG/src/jabber_file.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index 7af86a90a7..b7556ca9af 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -30,7 +30,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft)
{
ThreadData info(this, JABBER_SESSION_NORMAL);
- Log("Thread started: type=file_receive server='%s' port='%d'", ft->httpHostName, ft->httpPort);
+ debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->httpHostName, ft->httpPort);
ft->type = FT_OOB;
@@ -41,7 +41,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft)
nloc.wPort = ft->httpPort;
info.s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
if (info.s == NULL) {
- Log("Connection failed (%d), thread ended", WSAGetLastError());
+ debugLogA("Connection failed (%d), thread ended", WSAGetLastError());
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
}
else {
@@ -52,13 +52,13 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft)
info.send(buffer, datalen);
ft->state = FT_CONNECTING;
- Log("Entering file_receive recv loop");
+ debugLogA("Entering file_receive recv loop");
datalen = 0;
while (ft->state != FT_DONE && ft->state != FT_ERROR) {
int recvResult, bytesParsed;
- Log("Waiting for data...");
+ debugLogA("Waiting for data...");
recvResult = info.recv(buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen);
if (recvResult <= 0)
break;
@@ -75,7 +75,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft)
if (ft->state==FT_DONE || (ft->state==FT_RECEIVING && ft->std.currentFileSize < 0))
ft->complete();
- Log("Thread ended: type=file_receive server='%s'", ft->httpHostName);
+ debugLogA("Thread ended: type=file_receive server='%s'", ft->httpHostName);
}
delete ft;
}
@@ -96,13 +96,13 @@ int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen)
if ((str=(char*)mir_alloc(q-p+1)) != NULL) {
strncpy(str, p, q-p);
str[q-p] = '\0';
- Log("FT Got: %s", str);
+ debugLogA("FT Got: %s", str);
if (ft->state == FT_CONNECTING) {
// looking for "HTTP/1.1 200 OK"
if (sscanf(str, "HTTP/%*d.%*d %d %*s", &code)==1 && code==200) {
ft->state = FT_INITIALIZING;
ft->std.currentFileSize = -1;
- Log("Change to FT_INITIALIZING");
+ debugLogA("Change to FT_INITIALIZING");
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0);
}
}
@@ -121,7 +121,7 @@ int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen)
}
ft->state = FT_RECEIVING;
ft->std.currentFileProgress = 0;
- Log("Change to FT_RECEIVING");
+ debugLogA("Change to FT_RECEIVING");
}
else if ((s=strchr(str, ':')) != NULL) {
*s = '\0';
@@ -155,7 +155,7 @@ int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen)
else
writeSize = bufferSize;
if (_write(ft->fileId, p, writeSize) != writeSize) {
- Log("_write() error");
+ debugLogA("_write() error");
ft->state = FT_ERROR;
}
else {
@@ -184,11 +184,11 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/,
TCHAR szPort[10];
mir_sntprintf(szPort, SIZEOF(szPort), _T("%d"), connInfo.wPort);
- ppro->Log("File server incoming connection accepted: %s", connInfo.szIpPort);
+ ppro->debugLogA("File server incoming connection accepted: %s", connInfo.szIpPort);
JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_FILE, szPort);
if (item == NULL) {
- ppro->Log("No file is currently served, file server connection closed.");
+ ppro->debugLogA("No file is currently served, file server connection closed.");
Netlib_CloseHandle(hConnection);
return;
}
@@ -196,11 +196,11 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/,
filetransfer *ft = item->ft;
JABBER_SOCKET slisten = ft->s;
ft->s = hConnection;
- ppro->Log("Set ft->s to %d (saving %d)", hConnection, slisten);
+ ppro->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
char* buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE+1);
if (buffer == NULL) {
- ppro->Log("Cannot allocate network buffer, file server connection closed.");
+ ppro->debugLogA("Cannot allocate network buffer, file server connection closed.");
Netlib_CloseHandle(hConnection);
ft->state = FT_ERROR;
if (ft->hFileEvent != NULL)
@@ -208,7 +208,7 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/,
return;
}
- ppro->Log("Entering recv loop for this file connection... (ft->s is hConnection)");
+ ppro->debugLogA("Entering recv loop for this file connection... (ft->s is hConnection)");
int datalen = 0;
while (ft->state!=FT_DONE && ft->state!=FT_ERROR) {
int recvResult, bytesParsed;
@@ -219,7 +219,7 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/,
datalen += recvResult;
buffer[datalen] = '\0';
- ppro->Log("RECV:%s", buffer);
+ ppro->debugLogA("RECV:%s", buffer);
bytesParsed = ppro->FileSendParse(hConnection, ft, buffer, datalen);
if (bytesParsed < datalen)
@@ -227,10 +227,10 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/,
datalen -= bytesParsed;
}
- ppro->Log("Closing connection for this file transfer... (ft->s is now hBind)");
+ ppro->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
Netlib_CloseHandle(hConnection);
ft->s = slisten;
- ppro->Log("ft->s is restored to %d", ft->s);
+ ppro->debugLogA("ft->s is restored to %d", ft->s);
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
mir_free(buffer);
@@ -238,7 +238,7 @@ void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/,
void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
{
- Log("Thread started: type=file_send");
+ debugLogA("Thread started: type=file_send");
ThreadData info(this, JABBER_SESSION_NORMAL);
ft->type = FT_OOB;
@@ -250,14 +250,14 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
nlb.wPort = 0; // Use user-specified incoming port ranges, if available
info.s = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlb);
if (info.s == NULL) {
- Log("Cannot allocate port to bind for file server thread, thread ended.");
+ debugLogA("Cannot allocate port to bind for file server thread, thread ended.");
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
delete ft;
return;
}
ft->s = info.s;
- Log("ft->s = %d", info.s);
+ debugLogA("ft->s = %d", info.s);
HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
ft->hFileEvent = hEvent;
@@ -307,37 +307,37 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
query << XCHILD(_T("desc"), ft->szDescription);
m_ThreadInfo->send(iq);
- Log("Waiting for the file to be sent...");
+ debugLogA("Waiting for the file to be sent...");
WaitForSingleObject(hEvent, INFINITE);
}
- Log("File sent, advancing to the next file...");
+ debugLogA("File sent, advancing to the next file...");
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0);
}
CloseHandle(hEvent);
ft->hFileEvent = NULL;
- Log("Finish all files");
+ debugLogA("Finish all files");
}
ft->s = NULL;
- Log("ft->s is NULL");
+ debugLogA("ft->s is NULL");
ListRemove(LIST_FILE, szPort);
switch (ft->state) {
case FT_DONE:
- Log("Finish successfully");
+ debugLogA("Finish successfully");
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
break;
case FT_DENIED:
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ft, 0);
break;
default: // FT_ERROR:
- Log("Finish with errors");
+ debugLogA("Finish with errors");
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
break;
}
- Log("Thread ended: type=file_send");
+ debugLogA("Thread ended: type=file_send");
delete ft;
}
@@ -363,7 +363,7 @@ int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer,
}
strncpy(str, p, q-p);
str[q-p] = '\0';
- Log("FT Got: %s", str);
+ debugLogA("FT Got: %s", str);
if (ft->state == FT_CONNECTING) {
// looking for "GET filename.ext HTTP/1.1"
if ( !strncmp(str, "GET ", 4)) {
@@ -373,7 +373,7 @@ int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer,
ft->httpPath = mir_a2t(t);
JabberHttpUrlDecode(ft->httpPath);
ft->state = FT_INITIALIZING;
- Log("Change to FT_INITIALIZING");
+ debugLogA("Change to FT_INITIALIZING");
}
}
else { // FT_INITIALIZING
@@ -392,16 +392,16 @@ int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer,
if (ft->httpPath == NULL || lstrcmp(ft->httpPath, t)) {
if (ft->httpPath == NULL)
- Log("Requested file name does not matched (httpPath == NULL)");
+ debugLogA("Requested file name does not matched (httpPath == NULL)");
else
- Log("Requested file name does not matched ('%s' vs. '%s')", ft->httpPath, t);
+ debugLogA("Requested file name does not matched ('%s' vs. '%s')", ft->httpPath, t);
ft->state = FT_ERROR;
break;
}
- Log("Sending [%s]", ft->std.ptszFiles[ currentFile ]);
+ debugLogA("Sending [%s]", ft->std.ptszFiles[ currentFile ]);
_tstati64(ft->std.ptszFiles[ currentFile ], &statbuf); // file size in statbuf.st_size
if ((fileId = _topen(ft->std.ptszFiles[currentFile], _O_BINARY|_O_RDONLY)) < 0) {
- Log("File cannot be opened");
+ debugLogA("File cannot be opened");
ft->state = FT_ERROR;
mir_free(ft->httpPath);
ft->httpPath = NULL;
@@ -414,7 +414,7 @@ int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer,
ft->std.flags |= PFTS_SENDING;
ft->std.currentFileProgress = 0;
- Log("Sending file data...");
+ debugLogA("Sending file data...");
while ((numRead = _read(fileId, fileBuffer, 2048)) > 0) {
if (Netlib_Send(s, fileBuffer, numRead, 0) != numRead) {
@@ -428,7 +428,7 @@ int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer,
_close(fileId);
if (ft->state != FT_ERROR)
ft->state = FT_DONE;
- Log("Finishing this file...");
+ debugLogA("Finishing this file...");
mir_free(ft->httpPath);
ft->httpPath = NULL;
break;
@@ -457,7 +457,7 @@ filetransfer::filetransfer(CJabberProto* proto)
filetransfer::~filetransfer()
{
- ppro->Log("Destroying file transfer session %08p", this);
+ ppro->debugLogA("Destroying file transfer session %08p", this);
if ( !bCompleted)
ppro->ProtoBroadcastAck(std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, this, 0);
@@ -515,12 +515,12 @@ int filetransfer::create()
WaitForSingleObject(hWaitEvent, INFINITE);
if (fileId == -1) {
- ppro->Log("Saving to [%S]", std.tszCurrentFile);
+ ppro->debugLogA("Saving to [%S]", std.tszCurrentFile);
fileId = _topen(std.tszCurrentFile, _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IREAD | _S_IWRITE);
}
if (fileId == -1)
- ppro->Log("Cannot create file '%S' during a file transfer", filefull);
+ ppro->debugLogA("Cannot create file '%S' during a file transfer", filefull);
else if (std.currentFileSize != 0)
_chsize(fileId, std.currentFileSize);