summaryrefslogtreecommitdiff
path: root/protocols/Tlen
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-18 11:49:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-18 11:49:54 +0000
commit878d72910cccf4f84c7cb45bb4c11134920f3166 (patch)
tree251fba89632c389309ff9b2451850aa949efb8d0 /protocols/Tlen
parent871410044ecbac0d2dd67a7c98f8bcd2df9410eb (diff)
- naming conflict;
- warning fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14988 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tlen')
-rw-r--r--protocols/Tlen/src/tlen_file.cpp209
1 files changed, 99 insertions, 110 deletions
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp
index 20de8dafee..887ef89994 100644
--- a/protocols/Tlen/src/tlen_file.cpp
+++ b/protocols/Tlen/src/tlen_file.cpp
@@ -38,13 +38,13 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
p = rpacket->packet;
if (rpacket->type == TLEN_FILE_PACKET_FILE_LIST) { // list of files (length & name)
ft->fileCount = (int)(*((DWORD*)p));
- ft->files = (char **) mir_alloc(sizeof(char *) * ft->fileCount);
- ft->filesSize = (long *) mir_alloc(sizeof(long) * ft->fileCount);
+ ft->files = (char **)mir_alloc(sizeof(char *) * ft->fileCount);
+ ft->filesSize = (long *)mir_alloc(sizeof(long) * ft->fileCount);
ft->currentFile = 0;
ft->allFileTotalSize = 0;
ft->allFileReceivedBytes = 0;
p += sizeof(DWORD);
- for (i=0;i<ft->fileCount;i++) {
+ for (i = 0; i < ft->fileCount; i++) {
ft->filesSize[i] = (long)(*((DWORD*)p));
ft->allFileTotalSize += ft->filesSize[i];
p += sizeof(DWORD);
@@ -52,9 +52,9 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
memcpy(ft->files[i], p, 256);
p += 256;
}
- if ((packet=TlenP2PPacketCreate(3*sizeof(DWORD))) == NULL) {
+
+ if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) == NULL)
ft->state = FT_ERROR;
- }
else {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_LIST_ACK);
TlenP2PPacketSend(ft->s, packet);
@@ -65,13 +65,11 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
}
TlenP2PPacketFree(rpacket);
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
else if (ft->state == FT_INITIALIZING) {
char *fullFileName;
- if ((packet=TlenP2PPacketCreate(3*sizeof(DWORD))) != NULL) {
+ if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) != NULL) {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_REQUEST); // file request
TlenP2PPacketPackDword(packet, ft->currentFile);
TlenP2PPacketPackDword(packet, 0);
@@ -79,12 +77,12 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
TlenP2PPacketSend(ft->s, packet);
TlenP2PPacketFree(packet);
- fullFileName = (char *) mir_alloc(mir_strlen(ft->szSavePath) + mir_strlen(ft->files[ft->currentFile]) + 2);
+ fullFileName = (char *)mir_alloc(mir_strlen(ft->szSavePath) + mir_strlen(ft->files[ft->currentFile]) + 2);
mir_strcpy(fullFileName, ft->szSavePath);
- if (fullFileName[mir_strlen(fullFileName)-1] != '\\')
+ if (fullFileName[mir_strlen(fullFileName) - 1] != '\\')
mir_strcat(fullFileName, "\\");
mir_strcat(fullFileName, ft->files[ft->currentFile]);
- ft->fileId = _open(fullFileName, _O_BINARY|_O_WRONLY|_O_CREAT|_O_TRUNC, _S_IREAD|_S_IWRITE);
+ 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];
ft->proto->debugLogA("Saving to [%s] [%d]", fullFileName, ft->filesSize[ft->currentFile]);
@@ -92,9 +90,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
ft->state = FT_RECEIVING;
ft->proto->debugLogA("Change to FT_RECEIVING");
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
else if (ft->state == FT_RECEIVING) {
PROTOFILETRANSFERSTATUS pfts;
@@ -116,7 +112,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
p = rpacket->packet;
if (rpacket->type == TLEN_FILE_PACKET_FILE_DATA) { // file data
int writeSize;
- writeSize = rpacket->len - 2 * sizeof(DWORD) ; // skip file offset
+ writeSize = rpacket->len - 2 * sizeof(DWORD); // skip file offset
if (_write(ft->fileId, p + 2 * sizeof(DWORD), writeSize) != writeSize) {
ft->state = FT_ERROR;
}
@@ -125,13 +121,13 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
ft->allFileReceivedBytes += writeSize;
pfts.totalProgress = ft->allFileReceivedBytes;
pfts.currentFileProgress = ft->fileReceivedBytes;
- ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM) &pfts);
+ ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&pfts);
}
}
else if (rpacket->type == TLEN_FILE_PACKET_END_OF_FILE) { // end of file
_close(ft->fileId);
ft->proto->debugLogA("Finishing this file...");
- if (ft->currentFile >= ft->fileCount-1) {
+ if (ft->currentFile >= ft->fileCount - 1) {
ft->state = FT_DONE;
}
else {
@@ -143,9 +139,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft)
}
TlenP2PPacketFree(rpacket);
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
}
}
@@ -159,9 +153,9 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD, void * pExtra
ft->s = hConnection;
ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
ft->proto->debugLogA("Entering send loop for this file connection... (ft->s is hConnection)");
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR)
TlenFileReceiveParse(ft);
- }
+
if (ft->state == FT_DONE)
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
else
@@ -169,17 +163,15 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD, void * pExtra
ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
ft->s = slisten;
ft->proto->debugLogA("ft->s is restored to %d", ft->s);
- if (ft->s != hConnection) {
+
+ if (ft->s != hConnection)
Netlib_CloseHandle(hConnection);
- }
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
- } else {
- Netlib_CloseHandle(hConnection);
}
+ else Netlib_CloseHandle(hConnection);
}
-
static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft)
{
ft->proto->debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort);
@@ -189,19 +181,20 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft)
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->m_hNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
if (s != NULL) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
TlenP2PEstablishOutgoingConnection(ft, TRUE);
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR)
TlenFileReceiveParse(ft);
- }
+
if (ft->s) {
Netlib_CloseHandle(s);
+ ft->s = NULL;
}
- ft->s = NULL;
- } else {
+ }
+ else {
ft->pfnNewConnectionV2 = TlenFileReceivingConnection;
ft->proto->debugLogA("Connection failed - receiving as server");
s = TlenP2PListen(ft);
@@ -220,7 +213,8 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft)
CloseHandle(hEvent);
ft->proto->debugLogA("Finish all files");
Netlib_CloseHandle(s);
- } else {
+ }
+ else {
ft->state = FT_ERROR;
}
}
@@ -248,23 +242,22 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
char *fileBuffer;
TLEN_FILE_PACKET *packet;
-
if (ft->state == FT_CONNECTING) {
char filename[256]; // Must be 256 (0x100)
- if ((packet=TlenP2PPacketCreate(sizeof(DWORD)+(ft->fileCount*(sizeof(filename)+sizeof(DWORD))))) != NULL) {
+ if ((packet = TlenP2PPacketCreate(sizeof(DWORD) + (ft->fileCount*(sizeof(filename) + sizeof(DWORD))))) != NULL) {
// Must pause a bit, sending these two packets back to back
// will break the session because the receiver cannot take it :)
SleepEx(1000, TRUE);
TlenP2PPacketSetLen(packet, 0); // Reuse packet
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_LIST);
- TlenP2PPacketPackDword(packet, (DWORD) ft->fileCount);
- for (i=0; i<ft->fileCount; i++) {
-// struct _stat statbuf;
-// _stat(ft->files[i], &statbuf);
-// TlenP2PPacketPackDword(packet, statbuf.st_size);
+ TlenP2PPacketPackDword(packet, (DWORD)ft->fileCount);
+ for (i = 0; i < ft->fileCount; i++) {
+ // struct _stat statbuf;
+ // _stat(ft->files[i], &statbuf);
+ // TlenP2PPacketPackDword(packet, statbuf.st_size);
TlenP2PPacketPackDword(packet, ft->filesSize[i]);
memset(filename, 0, sizeof(filename));
- if ((t=strrchr(ft->files[i], '\\')) != NULL)
+ if ((t = strrchr(ft->files[i], '\\')) != NULL)
t++;
else
t = ft->files[i];
@@ -278,9 +271,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
ft->state = FT_INITIALIZING;
ft->proto->debugLogA("Change to FT_INITIALIZING");
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
else if (ft->state == FT_INITIALIZING) { // FT_INITIALIZING
TLEN_FILE_PACKET *rpacket = TlenP2PPacketReceive(ft->s);
@@ -312,13 +303,13 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
ft->state = FT_ERROR;
}
else {
- // _stat(ft->files[currentFile], &statbuf); // file size in statbuf.st_size
+ // _stat(ft->files[currentFile], &statbuf); // file size in statbuf.st_size
ft->proto->debugLogA("Sending [%s] [%d]", ft->files[currentFile], ft->filesSize[currentFile]);
- if ((ft->fileId=_open(ft->files[currentFile], _O_BINARY|_O_RDONLY)) < 0) {
+ if ((ft->fileId = _open(ft->files[currentFile], _O_BINARY | _O_RDONLY)) < 0) {
ft->proto->debugLogA("File cannot be opened");
ft->state = FT_ERROR;
}
- else {
+ else {
memset(&pfts, 0, sizeof(PROTOFILETRANSFERSTATUS));
pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS);
pfts.hContact = ft->hContact;
@@ -332,16 +323,16 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
pfts.currentFileSize = ft->filesSize[ft->currentFile]; //statbuf.st_size;
pfts.currentFileTime = 0;
ft->fileReceivedBytes = 0;
- if ((packet = TlenP2PPacketCreate(2*sizeof(DWORD)+2048)) == NULL) {
+ if ((packet = TlenP2PPacketCreate(2 * sizeof(DWORD) + 2048)) == NULL) {
ft->state = FT_ERROR;
}
else {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_DATA);
- fileBuffer = (char *) mir_alloc(2048);
+ fileBuffer = (char *)mir_alloc(2048);
ft->proto->debugLogA("Sending file data...");
- while ((numRead=_read(ft->fileId, fileBuffer, 2048)) > 0) {
+ while ((numRead = _read(ft->fileId, fileBuffer, 2048)) > 0) {
TlenP2PPacketSetLen(packet, 0); // Reuse packet
- TlenP2PPacketPackDword(packet, (DWORD) ft->fileReceivedBytes);
+ TlenP2PPacketPackDword(packet, (DWORD)ft->fileReceivedBytes);
TlenP2PPacketPackDword(packet, 0);
TlenP2PPacketPackBuffer(packet, fileBuffer, numRead);
if (TlenP2PPacketSend(ft->s, packet)) {
@@ -349,7 +340,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
ft->allFileReceivedBytes += numRead;
pfts.totalProgress = ft->allFileReceivedBytes;
pfts.currentFileProgress = ft->fileReceivedBytes;
- ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM) &pfts);
+ ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&pfts);
}
else {
ft->state = FT_ERROR;
@@ -359,7 +350,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
mir_free(fileBuffer);
_close(ft->fileId);
if (ft->state != FT_ERROR) {
- if (ft->currentFile >= ft->fileCount-1)
+ if (ft->currentFile >= ft->fileCount - 1)
ft->state = FT_DONE;
else {
ft->currentFile++;
@@ -408,14 +399,13 @@ static void TlenFileSendingConnection(HANDLE hConnection, DWORD, void * pExtra)
ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
ft->s = slisten;
ft->proto->debugLogA("ft->s is restored to %d", ft->s);
- if (ft->s != hConnection) {
+
+ if (ft->s != hConnection)
Netlib_CloseHandle(hConnection);
- }
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
- } else {
- Netlib_CloseHandle(hConnection);
}
+ else Netlib_CloseHandle(hConnection);
}
int TlenFileCancelAll(TlenProtocol *proto)
@@ -423,7 +413,7 @@ int TlenFileCancelAll(TlenProtocol *proto)
HANDLE hEvent;
int i = 0;
- while ((i=TlenListFindNext(proto, LIST_FILE, 0)) >=0 ) {
+ while ((i = TlenListFindNext(proto, LIST_FILE, 0)) >= 0) {
TLEN_LIST_ITEM *item = TlenListGetItemPtrFromIndex(proto, i);
if (item != NULL) {
TLEN_FILE_TRANSFER *ft = item->ft;
@@ -440,7 +430,8 @@ int TlenFileCancelAll(TlenProtocol *proto)
ft->hFileEvent = NULL;
SetEvent(hEvent);
}
- } else {
+ }
+ else {
ft->proto->debugLogA("freeing ft struct");
TlenP2PFreeFileTransfer(ft);
}
@@ -488,30 +479,31 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft)
NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nloc);
- if (s != NULL) {
+ HANDLE hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
+ if (hConn != NULL) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
- ft->s = s;
+ ft->s = hConn;
TlenP2PEstablishOutgoingConnection(ft, TRUE);
ft->proto->debugLogA("Entering send loop for this file connection...");
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR)
TlenFileSendParse(ft);
- }
+
if (ft->state == FT_DONE)
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);
ft->proto->debugLogA("Closing connection for this file transfer... ");
- Netlib_CloseHandle(s);
- } else {
- ft->state = FT_ERROR;
+ Netlib_CloseHandle(hConn);
}
+ else ft->state = FT_ERROR;
}
- } else {
+ }
+ else {
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:
ft->proto->debugLogA("Finish successfully");
@@ -533,8 +525,9 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft)
}
-TLEN_FILE_TRANSFER *TlenFileCreateFT(TlenProtocol *proto, const char *jid) {
- TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) mir_alloc(sizeof(TLEN_FILE_TRANSFER));
+TLEN_FILE_TRANSFER *TlenFileCreateFT(TlenProtocol *proto, const char *jid)
+{
+ TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)mir_alloc(sizeof(TLEN_FILE_TRANSFER));
memset(ft, 0, sizeof(TLEN_FILE_TRANSFER));
ft->proto = proto;
ft->jid = mir_strdup(jid);
@@ -552,46 +545,44 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
int numFiles;
TLEN_LIST_ITEM *item;
-// if (!node->name || mir_strcmp(node->name, "f")) return;
+ // if (!node->name || mir_strcmp(node->name, "f")) return;
if (info == NULL) return;
- char *from=TlenXmlGetAttrValue(node, "f");
+ char *from = TlenXmlGetAttrValue(node, "f");
if (from != NULL) {
- if (strchr(from, '@') == NULL) {
+ if (strchr(from, '@') == NULL)
mir_snprintf(jid, _countof(jid), "%s@%s", from, info->server);
- } else {
+ else
strncpy_s(jid, from, _TRUNCATE);
- }
- char *e=TlenXmlGetAttrValue(node, "e");
+
+ char *e = TlenXmlGetAttrValue(node, "e");
if (e != NULL) {
if (!mir_strcmp(e, "1")) {
// FILE_RECV : e='1' : File transfer request
TLEN_FILE_TRANSFER *ft = TlenFileCreateFT(info->proto, jid);
ft->hContact = TlenHContactFromJID(info->proto, jid);
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL)
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL)
ft->iqId = mir_strdup(p);
szFilename[0] = '\0';
- if ((p=TlenXmlGetAttrValue(node, "c")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "c")) != NULL) {
numFiles = atoi(p);
if (numFiles == 1) {
- if ((p=TlenXmlGetAttrValue(node, "n")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "n")) != NULL) {
p = TlenTextDecode(p);
- strncpy(szFilename, p, sizeof(szFilename)-1);
+ strncpy(szFilename, p, sizeof(szFilename) - 1);
mir_free(p);
- } else {
- mir_strcpy(szFilename, Translate("1 File"));
}
+ else mir_strcpy(szFilename, Translate("1 File"));
}
- else if (numFiles > 1) {
+ else if (numFiles > 1)
mir_snprintf(szFilename, _countof(szFilename), Translate("%d Files"), numFiles);
- }
}
if (szFilename[0] != '\0' && ft->iqId != NULL) {
TCHAR* filenameT = mir_utf8decodeT((char*)szFilename);
- PROTORECVFILET pre = {0};
+ PROTORECVFILET pre = { 0 };
pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
@@ -601,7 +592,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
ft->proto->debugLogA("sending chainrecv");
ProtoChainRecvFile(ft->hContact, &pre);
mir_free(filenameT);
- } else {
+ }
+ else {
// malformed <f/> request, reject
if (ft->iqId)
TlenSend(ft->proto, "<f i='%s' e='4' t='%s'/>", ft->iqId, from);
@@ -612,8 +604,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "3")) {
// FILE_RECV : e='3' : invalid transfer error
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
if (item->ft != NULL) {
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0);
info->proto->FileCancel(NULL, item->ft);
@@ -624,8 +616,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "4")) {
// FILE_SEND : e='4' : File sending request was denied by the remote client
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
if (!mir_strcmp(item->ft->jid, jid)) {
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, item->ft, 0);
TlenListRemove(info->proto, LIST_FILE, p);
@@ -635,22 +627,20 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "5")) {
// FILE_SEND : e='5' : File sending request was accepted
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL)
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL)
if (!mir_strcmp(item->ft->jid, jid))
- forkthread((void (__cdecl *)(void*))TlenFileSendingThread, 0, item->ft);
- }
- }
+ forkthread((void(__cdecl *)(void*))TlenFileSendingThread, 0, item->ft);
}
else if (!mir_strcmp(e, "6")) {
// FILE_RECV : e='6' : IP and port information to connect to get file
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "a")) != NULL) {
item->ft->hostName = mir_strdup(p);
- if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "p")) != NULL) {
item->ft->wPort = atoi(p);
- forkthread((void (__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft);
+ forkthread((void(__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft);
}
}
}
@@ -659,12 +649,12 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
else if (!mir_strcmp(e, "7")) {
// FILE_RECV : e='7' : IP and port information to connect to send file
// in case the conection to the given server was not successful
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "a")) != NULL) {
if (item->ft->hostName != NULL) mir_free(item->ft->hostName);
item->ft->hostName = mir_strdup(p);
- if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "p")) != NULL) {
item->ft->wPort = atoi(p);
item->ft->state = FT_SWITCH;
SetEvent(item->ft->hFileEvent);
@@ -675,14 +665,13 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
}
else if (!mir_strcmp(e, "8")) {
// FILE_RECV : e='8' : transfer error
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
item->ft->state = FT_ERROR;
- if (item->ft->hFileEvent != NULL) {
+ if (item->ft->hFileEvent != NULL)
SetEvent(item->ft->hFileEvent);
- } else {
+ else
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0);
- }
}
}
}