summaryrefslogtreecommitdiff
path: root/protocols/MSN/msn_p2p.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-14 19:40:31 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-14 19:40:31 +0000
commitdab02845fea8031dd3d7864dc1efc211a434f969 (patch)
tree5106120c4f64fbf518f57a963f5c7aec6eb19363 /protocols/MSN/msn_p2p.cpp
parent60df08c2f6194702ec180c2d2adf20d3675edae1 (diff)
- code cleaning
- sync git-svn-id: http://svn.miranda-ng.org/main/trunk@975 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN/msn_p2p.cpp')
-rw-r--r--protocols/MSN/msn_p2p.cpp52
1 files changed, 35 insertions, 17 deletions
diff --git a/protocols/MSN/msn_p2p.cpp b/protocols/MSN/msn_p2p.cpp
index 9c805eb530..84d1ee8d2c 100644
--- a/protocols/MSN/msn_p2p.cpp
+++ b/protocols/MSN/msn_p2p.cpp
@@ -808,7 +808,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc)
bool CMsnProto::p2p_listen(ThreadData* info, directconnection *dc)
{
- switch(WaitForSingleObject(info->hWaitEvent, 6000))
+ switch(WaitForSingleObject(info->hWaitEvent, 10000))
{
case WAIT_TIMEOUT:
case WAIT_FAILED:
@@ -1433,6 +1433,7 @@ void CMsnProto::p2p_InitDirectTransfer(MimeHeaders& tFileInfo, MimeHeaders& tFil
if (MSN_GetThreadByContact(wlid, SERVER_P2P_DIRECT))
{
p2p_sendStatus(ft, 1603);
+ p2p_unregisterDC(dc);
return;
}
p2p_unregisterDC(dc);
@@ -1490,22 +1491,38 @@ void CMsnProto::p2p_startConnect(const char* wlid, const char* szCallID, const c
{
if (port == NULL) return;
- while (addr != NULL)
+ char *pPortTokBeg = (char*)port;
+ for (;;)
{
- char* pSpace = (char*)strchr(addr, ' ');
- if (pSpace != NULL) *(pSpace++) = 0;
+ char *pPortTokEnd = strchr(pPortTokBeg, ' ');
+ if (pPortTokEnd != NULL) *pPortTokEnd = 0;
- ThreadData* newThread = new ThreadData;
+ char *pAddrTokBeg = (char*)addr;
+ for (;;)
+ {
+ char *pAddrTokEnd = strchr(pAddrTokBeg, ' ');
+ if (pAddrTokEnd != NULL) *pAddrTokEnd = 0;
+
+ ThreadData* newThread = new ThreadData;
+
+ newThread->mType = SERVER_P2P_DIRECT;
+ newThread->mInitialContactWLID = mir_strdup(wlid);
+ mir_snprintf(newThread->mCookie, sizeof(newThread->mCookie), "%s", szCallID);
+ mir_snprintf(newThread->mServer, sizeof(newThread->mServer),
+ ipv6 ? "[%s]:%s" : "%s:%s", pAddrTokBeg, pPortTokBeg);
- newThread->mType = SERVER_P2P_DIRECT;
- newThread->mInitialContactWLID = mir_strdup(wlid);
- mir_snprintf(newThread->mCookie, sizeof(newThread->mCookie), "%s", szCallID);
- mir_snprintf(newThread->mServer, sizeof(newThread->mServer),
- ipv6 ? "[%s]:%s" : "%s:%s", addr, port);
+ newThread->startThread(&CMsnProto::p2p_fileActiveThread, this);
- newThread->startThread(&CMsnProto::p2p_fileActiveThread, this);
+ if (pAddrTokEnd == NULL) break;
- addr = pSpace;
+ *pAddrTokEnd = ' ';
+ pAddrTokBeg = pAddrTokEnd + 1;
+ }
+
+ if (pPortTokEnd == NULL) break;
+
+ *pPortTokEnd = ' ';
+ pPortTokBeg = pPortTokEnd + 1;
}
}
@@ -1805,18 +1822,18 @@ void CMsnProto::p2p_processSIP(ThreadData* info, char* msgbody, P2PB_Header* hdr
case 4:
{
- const char* callID = tFileInfo["Call-ID"];
+ const char* szCallID = tFileInfo["Call-ID"];
// application/x-msnmsgr-session-failure-respbody
- directconnection *dc = p2p_getDCByCallID(callID, wlid);
+ directconnection *dc = p2p_getDCByCallID(szCallID, wlid);
if (dc != NULL)
{
p2p_unregisterDC(dc);
break;
}
- filetransfer* ft = p2p_getSessionByCallID(callID, wlid);
+ filetransfer* ft = p2p_getSessionByCallID(szCallID, wlid);
if (ft == NULL)
break;
@@ -2385,13 +2402,14 @@ void CMsnProto::p2p_sendSessionAck(filetransfer* ft)
*/
void CMsnProto::p2p_sessionComplete(filetransfer* ft)
{
- if (ft->std.flags & PFTS_SENDING)
+ if (ft->p2p_appID != MSN_APPID_FILE)
+ p2p_unregisterSession(ft);
+ else if (ft->std.flags & PFTS_SENDING)
{
if (ft->openNext() == -1)
{
bool success = ft->std.currentFileNumber >= ft->std.totalFiles && ft->bCompleted;
SendBroadcast(ft->std.hContact, ACKTYPE_FILE, success ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, ft, 0);
- p2p_unregisterSession(ft);
}
else
{