summaryrefslogtreecommitdiff
path: root/protocols/MSN/src/msn_p2p.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-01-30 14:25:01 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-01-30 14:25:01 +0000
commiteb8ce4835cfe80601daaf64b6f842e63b85e62af (patch)
tree0a6efec04fb4330daea0a48ed2456048bacbe53e /protocols/MSN/src/msn_p2p.cpp
parent8e1b69f9327909134a9646d3f182155125623b70 (diff)
copyright update
fixes #204 git-svn-id: http://svn.miranda-ng.org/main/trunk@3367 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN/src/msn_p2p.cpp')
-rw-r--r--protocols/MSN/src/msn_p2p.cpp272
1 files changed, 137 insertions, 135 deletions
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp
index 3a7a6c4429..46a24488a7 100644
--- a/protocols/MSN/src/msn_p2p.cpp
+++ b/protocols/MSN/src/msn_p2p.cpp
@@ -1,5 +1,7 @@
/*
Plugin of Miranda IM for communicating with users of the MSN Messenger protocol.
+
+Copyright (c) 2012-2013 Miranda NG Team
Copyright (c) 2006-2012 Boris Krasnovskiy.
Copyright (c) 2003-2005 George Hazan.
Copyright (c) 2002-2003 Richard Hughes (original version).
@@ -34,7 +36,7 @@ static const char sttP2PheaderV2[] =
const char sttVoidUid[] = "{00000000-0000-0000-0000-000000000000}";
static const char szUbnCall[] = "{F13B5C79-0126-458F-A29D-747C79C56530}";
-static const char p2pV2Caps[] = { 0x01, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0F, 0x01, 0x00, 0x00 };
+static const char p2pV2Caps[] = { 0x01, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0F, 0x01, 0x00, 0x00 };
void P2P_Header::logHeader(CMsnProto *ppro)
{
@@ -87,7 +89,7 @@ bool CMsnProto::p2p_createListener(filetransfer* ft, directconnection *dc, MimeH
nlb.pfnNewConnectionV2 = MSN_ConnectionProc;
nlb.pExtra = this;
HANDLE sb = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) hNetlibUser, (LPARAM)&nlb);
- if (sb == NULL)
+ if (sb == NULL)
{
MSN_DebugLog("Unable to bind the port for incoming transfers");
return false;
@@ -105,7 +107,7 @@ bool CMsnProto::p2p_createListener(filetransfer* ft, directconnection *dc, MimeH
char szIpv4[256] = "";
char szIpv6[256] = "";
- const char *szExtIp = MyConnection.GetMyExtIPStr();
+ const char *szExtIp = MyConnection.GetMyExtIPStr();
bool ipInt = false;
int i4 = 0, i6 = 0;
@@ -165,7 +167,7 @@ bool p2p_IsDlFileOk(filetransfer* ft)
bool res = false;
int fileId = _topen(ft->std.tszCurrentFile, O_RDONLY | _O_BINARY, _S_IREAD);
- if (fileId != -1)
+ if (fileId != -1)
{
BYTE buf[4096];
int bytes;
@@ -217,7 +219,7 @@ void CMsnProto::p2p_savePicture2disk(filetransfer* ft)
if (p2p_IsDlFileOk(ft))
{
int fileId = _topen(ft->std.tszCurrentFile, O_RDONLY | _O_BINARY, _S_IREAD);
- if (fileId == -1)
+ if (fileId == -1)
{
p2p_pictureTransferFailed(ft);
return;
@@ -313,11 +315,11 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
unsigned fportion = msgType == 1 ? 1352 : 1202;
if (hdrdata.isV2Hdr()) fportion += 4;
- char* buf = (char*) alloca(sizeof(sttP2PheaderV2)+ MSN_MAX_EMAIL_LEN +
+ char* buf = (char*) alloca(sizeof(sttP2PheaderV2)+ MSN_MAX_EMAIL_LEN +
120 + fportion);
size_t offset = 0;
- do
+ do
{
size_t portion = msgsz - offset;
if (portion > fportion) portion = fportion;
@@ -325,13 +327,13 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
char* p = buf;
// add message header
- p += msgType == 1 ? sizeof(unsigned) :
+ p += msgType == 1 ? sizeof(unsigned) :
sprintf(p, hdrdata.isV2Hdr() ? sttP2PheaderV2 : sttP2Pheader, wlid, MyOptions.szEmail, MyOptions.szMachineGuidP2P);
if (hdrdata.isV2Hdr())
{
- P2PV2_Header *ph = (P2PV2_Header*)&hdrdata;
- if (offset == 0)
+ P2PV2_Header *ph = (P2PV2_Header*)&hdrdata;
+ if (offset == 0)
{
if (!info || !info->mBridgeInit)
{
@@ -349,7 +351,7 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
}
}
}
- else
+ else
{
ph->mOpCode = 0;
ph->mCap = NULL;
@@ -360,7 +362,7 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
{
if (hdrdata.isV2Hdr())
{
- P2PV2_Header *ph = (P2PV2_Header*)&hdrdata;
+ P2PV2_Header *ph = (P2PV2_Header*)&hdrdata;
ph->mPacketLen = (unsigned)portion;
ph->mRemSize = msgsz - offset - portion;
ph->mTFCode = offset ? ph->mTFCode & 0xfe : ph->mTFCode | 0x01;
@@ -370,7 +372,7 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
}
else
{
- P2P_Header *ph = (P2P_Header*)&hdrdata;
+ P2P_Header *ph = (P2P_Header*)&hdrdata;
ph->mPacketLen = (unsigned)portion;
ph->mOffset = offset;
ph->mTotalSize = msgsz;
@@ -386,20 +388,20 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
// add message footer
if (msgType != 1)
- {
+ {
*(unsigned*)p = _htonl(appId);
p += 4;
}
char* szEmail;
- switch (msgType)
+ switch (msgType)
{
case 0:
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, NULL);
MsgQueue_Add(szEmail, 'D', buf, p - buf);
break;
- case 1:
+ case 1:
*(unsigned*)buf = (unsigned)(p - buf - sizeof(unsigned));
info->send(buf, p - buf);
break;
@@ -409,13 +411,13 @@ void CMsnProto::p2p_sendMsg(ThreadData* info, const char *wlid, unsigned appId,
break;
}
offset += portion;
- }
+ }
while (offset < msgsz);
}
void CMsnProto::p2p_sendAck(const char *wlid, P2PB_Header* hdr)
-{
+{
if (hdr == NULL) return;
if (!hdr->isV2Hdr())
@@ -448,7 +450,7 @@ void CMsnProto::p2p_sendAck(const char *wlid, P2PB_Header* hdr)
void CMsnProto::p2p_sendAbortSession(filetransfer* ft)
{
- if (ft == NULL)
+ if (ft == NULL)
{
MSN_DebugLog(sttVoidSession);
return;
@@ -462,12 +464,12 @@ void CMsnProto::p2p_sendAbortSession(filetransfer* ft)
tHdr.mAckSessionID = ft->p2p_sendmsgid;
tHdr.mID = p2p_getMsgId(ft->p2p_dest, 1);
- if (ft->std.flags & PFTS_SENDING)
+ if (ft->std.flags & PFTS_SENDING)
{
tHdr.mFlags = 0x40;
tHdr.mAckSessionID = tHdr.mID - 2;
}
- else
+ else
{
tHdr.mAckUniqueID = 0x8200000f;
tHdr.mFlags = 0x80;
@@ -480,7 +482,7 @@ void CMsnProto::p2p_sendAbortSession(filetransfer* ft)
void CMsnProto::p2p_sendRedirect(filetransfer* ft)
{
- if (ft == NULL)
+ if (ft == NULL)
{
MSN_DebugLog(sttVoidSession);
return;
@@ -508,7 +510,7 @@ void CMsnProto::p2p_sendRedirect(filetransfer* ft)
void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
MimeHeaders &pContent, const char *wlid)
{
- if (ft == NULL)
+ if (ft == NULL)
{
MSN_DebugLog(sttVoidSession);
return;
@@ -522,7 +524,7 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
char* buf = (char*)alloca(pHeaders.getLength() + cbContLen + 512);
char* p = buf;
- switch (iKind)
+ switch (iKind)
{
case -3: p += sprintf(p, "ACK MSNMSGR:%s MSNSLP/1.0", wlid); break;
case -2: p += sprintf(p, "INVITE MSNMSGR:%s MSNSLP/1.0", wlid); break;
@@ -535,7 +537,7 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
default: return;
}
- if (iKind < 0)
+ if (iKind < 0)
{
mir_free(ft->p2p_branch);
ft->p2p_branch = getNewUuid();
@@ -546,7 +548,7 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
p += sprintf(p,
"\r\nTo: <msnmsgr:%s>\r\n"
"From: <msnmsgr:%s;%s>\r\n"
- "Via: MSNSLP/1.0/TLP ;branch=%s\r\n",
+ "Via: MSNSLP/1.0/TLP ;branch=%s\r\n",
wlid, MyOptions.szEmail, MyOptions.szMachineGuidP2P, ft->p2p_branch);
}
else
@@ -554,7 +556,7 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
p += sprintf(p,
"\r\nTo: <msnmsgr:%s>\r\n"
"From: <msnmsgr:%s>\r\n"
- "Via: MSNSLP/1.0/TLP ;branch=%s\r\n",
+ "Via: MSNSLP/1.0/TLP ;branch=%s\r\n",
wlid, MyOptions.szEmail, ft->p2p_branch);
}
@@ -562,9 +564,9 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
p = pContent.writeToBuffer(p);
unsigned short status = getWord(ft->std.hContact, "Status", ID_STATUS_OFFLINE);
- if (!(myFlags & cap_SupportsP2PBootstrap) || ft->p2p_sessionid ||
+ if (!(myFlags & cap_SupportsP2PBootstrap) || ft->p2p_sessionid ||
MSN_GetThreadByContact(wlid, SERVER_P2P_DIRECT) ||
- status == ID_STATUS_OFFLINE || status == ID_STATUS_INVISIBLE ||
+ status == ID_STATUS_OFFLINE || status == ID_STATUS_INVISIBLE ||
m_iStatus == ID_STATUS_INVISIBLE)
{
if (!ft->p2p_isV2)
@@ -575,10 +577,10 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
p2p_sendMsg(wlid, 0, tHdr, buf, p - buf + 1);
ft->p2p_waitack = true;
- switch (iKind)
+ switch (iKind)
{
- case -1: case 500: case 603:
- ft->p2p_byemsgid = tHdr.mID;
+ case -1: case 500: case 603:
+ ft->p2p_byemsgid = tHdr.mID;
break;
}
@@ -602,7 +604,7 @@ void CMsnProto::p2p_sendSlp(int iKind, filetransfer *ft, MimeHeaders &pHeaders,
void CMsnProto::p2p_sendBye(filetransfer* ft)
{
- if (ft == NULL)
+ if (ft == NULL)
{
MSN_DebugLog(sttVoidSession);
return;
@@ -629,7 +631,7 @@ void CMsnProto::p2p_sendCancel(filetransfer* ft)
void CMsnProto::p2p_sendNoCall(filetransfer* ft)
{
- if (ft == NULL)
+ if (ft == NULL)
{
MSN_DebugLog(sttVoidSession);
return;
@@ -653,7 +655,7 @@ void CMsnProto::p2p_sendNoCall(filetransfer* ft)
void CMsnProto::p2p_sendStatus(filetransfer* ft, long lStatus)
{
- if (ft == NULL)
+ if (ft == NULL)
{
MSN_DebugLog(sttVoidSession);
return;
@@ -723,7 +725,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc)
tConn.timeout = 5;
char* tPortDelim = strrchr(info->mServer, ':');
- if (tPortDelim != NULL)
+ if (tPortDelim != NULL)
{
*tPortDelim = '\0';
tConn.wPort = (WORD)atol(tPortDelim + 1);
@@ -762,7 +764,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc)
long cbPacketLen;
HReadBuffer buf(info, 0);
BYTE* p;
- if ((p = buf.surelyRead(4)) == NULL)
+ if ((p = buf.surelyRead(4)) == NULL)
{
MSN_DebugLog("Error reading data, closing filetransfer");
return false;
@@ -778,7 +780,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc)
{
P2P_Header cookie((char*)p);
- if (dc->useHashedNonce)
+ if (dc->useHashedNonce)
{
char* hnonce = dc->calcHashedNonce((UUID*)&cookie.mAckSessionID);
cookieMatch = strcmp(hnonce, dc->xNonce) == 0;
@@ -794,7 +796,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc)
mir_free(hnonce);
}
- if (!cookieMatch)
+ if (!cookieMatch)
{
MSN_DebugLog("Invalid cookie received, exiting");
return false;
@@ -808,7 +810,7 @@ bool CMsnProto::p2p_connectTo(ThreadData* info, directconnection *dc)
bool CMsnProto::p2p_listen(ThreadData* info, directconnection *dc)
{
- switch(WaitForSingleObject(info->hWaitEvent, 10000))
+ switch(WaitForSingleObject(info->hWaitEvent, 10000))
{
case WAIT_TIMEOUT:
case WAIT_FAILED:
@@ -825,13 +827,13 @@ LBL_Error:
if ((p = buf.surelyRead(8)) == NULL)
goto LBL_Error;
- if (memcmp(p, p2p_greeting, 8) != 0)
+ if (memcmp(p, p2p_greeting, 8) != 0)
{
MSN_DebugLog("Invalid input data, exiting");
return false;
}
- if ((p = buf.surelyRead(4)) == NULL)
+ if ((p = buf.surelyRead(4)) == NULL)
{
MSN_DebugLog("Error reading data, closing filetransfer");
return false;
@@ -848,7 +850,7 @@ LBL_Error:
{
P2P_Header cookie((char*)p);
- if (dc->useHashedNonce)
+ if (dc->useHashedNonce)
{
char* hnonce = dc->calcHashedNonce((UUID*)&cookie.mAckSessionID);
cookieMatch = strcmp(hnonce, dc->xNonce) == 0;
@@ -858,7 +860,7 @@ LBL_Error:
else
cookieMatch = memcmp(&cookie.mAckSessionID, dc->mNonce, sizeof(UUID)) == 0;
- if (!cookieMatch)
+ if (!cookieMatch)
{
MSN_DebugLog("Invalid cookie received, exiting");
return false;
@@ -874,7 +876,7 @@ LBL_Error:
cookieMatch = strcmp(hnonce, dc->xNonce) == 0;
mir_free(hnonce);
- if (!cookieMatch)
+ if (!cookieMatch)
{
MSN_DebugLog("Invalid cookie received, exiting");
goto LBL_Error;
@@ -953,7 +955,7 @@ LONG CMsnProto::p2p_sendPortion(filetransfer* ft, ThreadData* T, bool isV2)
trid = T->sendRawMessage('D', (char *)databuf, p - databuf);
}
- if (trid != 0)
+ if (trid != 0)
{
ft->std.totalProgress += portion;
ft->std.currentFileProgress += portion;
@@ -985,7 +987,7 @@ void __cdecl CMsnProto::p2p_sendFeedThread(void* arg)
MSN_DebugLog("File send thread started");
- switch(WaitForSingleObject(info->hWaitEvent, 6000))
+ switch(WaitForSingleObject(info->hWaitEvent, 6000))
{
case WAIT_FAILED:
MSN_DebugLog("File send wait failed");
@@ -996,7 +998,7 @@ void __cdecl CMsnProto::p2p_sendFeedThread(void* arg)
ThreadData* T = NULL;
TInfoType lastType = SERVER_NOTIFICATION;
- filetransfer *ft = p2p_getSessionByCallID(info->mCookie,
+ filetransfer *ft = p2p_getSessionByCallID(info->mCookie,
info->mJoinedIdentContactsWLID.getCount() ? info->mJoinedIdentContactsWLID[0] : info->mJoinedContactsWLID[0]);
if (ft != NULL && WaitForSingleObject(ft->hLockHandle, 2000) == WAIT_OBJECT_0)
@@ -1030,9 +1032,9 @@ void __cdecl CMsnProto::p2p_sendFeedThread(void* arg)
if (ft->bCanceled) break;
bool cfault = (T == NULL || p2p_sendPortion(ft, T, isV2) == 0);
- if (cfault)
+ if (cfault)
{
- if (fault)
+ if (fault)
{
MSN_DebugLog("File send failed");
break;
@@ -1075,7 +1077,7 @@ void CMsnProto::p2p_sendFeedStart(filetransfer* ft)
strcpy(newThread->mCookie, ft->p2p_callID);
newThread->mInitialContactWLID = mir_strdup(ft->p2p_dest);
newThread->startThread(&CMsnProto::p2p_sendFeedThread, this);
- }
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1098,7 +1100,7 @@ void CMsnProto::p2p_sendRecvFileDirectly(ThreadData* info)
bool isV2 = strchr(wlid, ';') != NULL;
- for (;;)
+ for (;;)
{
long len = state ? cbPacketLen : 4;
@@ -1176,7 +1178,7 @@ void __cdecl CMsnProto::p2p_filePassiveThread(void* arg)
void CMsnProto::p2p_InitFileTransfer(
ThreadData* info,
MimeHeaders& tFileInfo,
- MimeHeaders& tFileInfo2,
+ MimeHeaders& tFileInfo2,
const char* wlid)
{
if (info->mJoinedContactsWLID.getCount() == 0 && info->mJoinedIdentContactsWLID.getCount() == 0)
@@ -1200,7 +1202,7 @@ void CMsnProto::p2p_InitFileTransfer(
*szContext = tFileInfo2["Context"],
*szAppId = tFileInfo2["AppID"];
- if (szSessionID == NULL || szAppId == NULL || szEufGuid == NULL)
+ if (szSessionID == NULL || szAppId == NULL || szEufGuid == NULL)
{
MSN_DebugLog("Ignoring invalid invitation: SessionID='%s', AppID=%s, Branch='%s',Context='%s'",
szSessionID, szAppId, szEufGuid, szContext);
@@ -1236,7 +1238,7 @@ void CMsnProto::p2p_InitFileTransfer(
if (!_stricmp(szEufGuid, "{A4268EEC-FEC5-49E5-95C3-F126696BDBF6}")) {
DBVARIANT dbv;
bool pictmatch = !getString("PictObject", &dbv);
- if (pictmatch)
+ if (pictmatch)
{
UrlDecode(dbv.pszVal);
@@ -1260,12 +1262,12 @@ void CMsnProto::p2p_InitFileTransfer(
ezxml_free(xmldb);
MSN_FreeVariant(&dbv);
}
- if (pictmatch)
+ if (pictmatch)
{
TCHAR szFileName[MAX_PATH];
MSN_GetAvatarFileName(NULL, szFileName, SIZEOF(szFileName), NULL);
ft->fileId = _topen(szFileName, O_RDONLY | _O_BINARY, _S_IREAD);
- if (ft->fileId == -1)
+ if (ft->fileId == -1)
{
p2p_sendStatus(ft, 603);
MSN_ShowError("Your avatar not set correctly. Avatar should be set in View/Change My Details | Avatar");
@@ -1301,17 +1303,17 @@ void CMsnProto::p2p_InitFileTransfer(
break;
case MSN_APPID_FILE:
- if (!_stricmp(szEufGuid, "{5D3E02AB-6190-11D3-BBBB-00C04F795683}"))
+ if (!_stricmp(szEufGuid, "{5D3E02AB-6190-11D3-BBBB-00C04F795683}"))
{
wchar_t* wszFileName = ((HFileContext*)szContext)->wszFileName;
for (wchar_t* p = wszFileName; *p != 0; p++)
- {
- switch(*p)
+ {
+ switch(*p)
{
case ':': case '?': case '/': case '\\': case '*':
*p = '_';
- }
- }
+ }
+ }
mir_free(ft->std.tszCurrentFile);
ft->std.tszCurrentFile = mir_u2t(wszFileName);
@@ -1336,12 +1338,12 @@ void CMsnProto::p2p_InitFileTransfer(
case MSN_APPID_WEBCAM:
if (!_stricmp(szEufGuid, "{4BD96FC0-AB17-4425-A14A-439185962DC8}")) {
MSN_ShowPopup(ft->std.hContact,
- TranslateT("Contact tried to send its webcam data (currently not supported)"),
+ TranslateT("Contact tried to send its webcam data (currently not supported)"),
MSN_ALLOW_MSGBOX | MSN_SHOW_ERROR);
}
if (!_stricmp(szEufGuid, "{1C9AA97E-9C05-4583-A3BD-908A196F1E92}")) {
MSN_ShowPopup(ft->std.hContact,
- TranslateT("Contact tried to view our webcam data (currently not supported)"),
+ TranslateT("Contact tried to view our webcam data (currently not supported)"),
MSN_ALLOW_MSGBOX | MSN_SHOW_ERROR);
}
p2p_sendStatus(ft, 603);
@@ -1350,7 +1352,7 @@ void CMsnProto::p2p_InitFileTransfer(
case MSN_APPID_MEDIA_SHARING:
// MSN_ShowPopup(ft->std.hContact,
-// TranslateT("Contact tried to share media with us (currently not supported)"),
+// TranslateT("Contact tried to share media with us (currently not supported)"),
// MSN_ALLOW_MSGBOX | MSN_SHOW_ERROR);
p2p_sendStatus(ft, 603);
p2p_unregisterSession(ft);
@@ -1376,19 +1378,19 @@ void CMsnProto::p2p_InitDirectTransfer(MimeHeaders& tFileInfo, MimeHeaders& tFil
*szICF = tFileInfo2["ICF"],
*szHashedNonce = tFileInfo2["Hashed-Nonce"];
- if (szBranch != NULL)
+ if (szBranch != NULL)
{
szBranch = strstr(szBranch, "branch=");
if (szBranch != NULL)
szBranch += 7;
}
- if (szCallID == NULL || szBranch == NULL)
+ if (szCallID == NULL || szBranch == NULL)
{
MSN_DebugLog("Ignoring invalid invitation: CallID='%s', Branch='%s'", szCallID, szBranch);
return;
}
- if (szConnType == NULL || szUPnPNat == NULL || szICF == NULL || szNetID == NULL)
+ if (szConnType == NULL || szUPnPNat == NULL || szICF == NULL || szNetID == NULL)
{
MSN_DebugLog("Ignoring invalid invitation: ConnType='%s', UPnPNat='%s', ICF='%s', NetID='%s'",
szConnType, szUPnPNat, szICF, szNetID);
@@ -1411,7 +1413,7 @@ void CMsnProto::p2p_InitDirectTransfer(MimeHeaders& tFileInfo, MimeHeaders& tFil
replaceStr(ft->p2p_branch, szBranch);
ft->p2p_acksessid = MSN_GenRandom();
/*
- if (p2p_isAvatarOnly(ft->std.hContact))
+ if (p2p_isAvatarOnly(ft->std.hContact))
{
p2p_sendStatus(ft, 1603);
return;
@@ -1459,7 +1461,7 @@ void CMsnProto::p2p_InitDirectTransfer(MimeHeaders& tFileInfo, MimeHeaders& tFil
if (conType.weight <= MyConnection.weight)
listen = p2p_createListener(ft, dc, chdrs);
- if (!listen)
+ if (!listen)
{
chdrs.addString("Bridge", "TCPv1");
chdrs.addBool("Listening", false);
@@ -1486,13 +1488,13 @@ void CMsnProto::p2p_startConnect(const char* wlid, const char* szCallID, const c
if (port == NULL) return;
char *pPortTokBeg = (char*)port;
- for (;;)
+ for (;;)
{
char *pPortTokEnd = strchr(pPortTokBeg, ' ');
if (pPortTokEnd != NULL) *pPortTokEnd = 0;
char *pAddrTokBeg = (char*)addr;
- for (;;)
+ for (;;)
{
char *pAddrTokEnd = strchr(pAddrTokBeg, ' ');
if (pAddrTokEnd != NULL) *pAddrTokEnd = 0;
@@ -1533,14 +1535,14 @@ void CMsnProto::p2p_InitDirectTransfer2(MimeHeaders& tFileInfo, MimeHeaders& tFi
*szV6Address = tFileInfo2["IPv6-Addrs"],
*szV6Port = tFileInfo2["IPv6-Port" ];
- if ((szNonce == NULL && szHashedNonce == NULL) || szListening == NULL)
+ if ((szNonce == NULL && szHashedNonce == NULL) || szListening == NULL)
{
MSN_DebugLog("Ignoring invalid invitation: Listening='%s', Nonce=%s", szListening, szNonce);
return;
}
directconnection* dc = p2p_getDCByCallID(szCallID, wlid);
- if (dc == NULL)
+ if (dc == NULL)
{
dc = new directconnection(szCallID, wlid);
p2p_registerDC(dc);
@@ -1549,7 +1551,7 @@ void CMsnProto::p2p_InitDirectTransfer2(MimeHeaders& tFileInfo, MimeHeaders& tFi
dc->useHashedNonce = szHashedNonce != NULL;
replaceStr(dc->xNonce, szHashedNonce ? szHashedNonce : szNonce);
- if (!strcmp(szListening, "true") && strcmp(dc->xNonce, sttVoidUid))
+ if (!strcmp(szListening, "true") && strcmp(dc->xNonce, sttVoidUid))
{
p2p_startConnect(wlid, szCallID, szV6Address, szV6Port, true);
p2p_startConnect(wlid, szCallID, szInternalAddress, szInternalPort, false);
@@ -1582,14 +1584,14 @@ void CMsnProto::p2p_AcceptTransfer(MimeHeaders& tFileInfo, MimeHeaders& tFileInf
}
else
{
- if (!(ft->std.flags & PFTS_SENDING))
+ if (!(ft->std.flags & PFTS_SENDING))
{
replaceStr(ft->p2p_branch, szBranch);
replaceStr(ft->p2p_callID, szCallID);
}
}
- if (szCallID == NULL || szBranch == NULL || szOldContentType == NULL)
+ if (szCallID == NULL || szBranch == NULL || szOldContentType == NULL)
{
MSN_DebugLog("Ignoring invalid invitation: CallID='%s', szBranch='%s'", szCallID, szBranch);
LBL_Close:
@@ -1604,7 +1606,7 @@ LBL_Close:
MimeHeaders chdrs(12);
- if (!strcmp(szOldContentType, "application/x-msnmsgr-sessionreqbody"))
+ if (!strcmp(szOldContentType, "application/x-msnmsgr-sessionreqbody"))
{
if (ft == &ftl)
{
@@ -1622,7 +1624,7 @@ LBL_Close:
if (ft->p2p_type != MSN_APPID_FILE)
{
- if (ft->fileId == -1) ft->create();
+ if (ft->fileId == -1) ft->create();
return;
}
@@ -1651,7 +1653,7 @@ LBL_Close:
chdrs.addString("IPv6-global", GetGlobalIp(), 2);
chdrs.addString("Hashed-Nonce", dc->mNonceToHash(), 2);
}
- else if (!strcmp(szOldContentType, "application/x-msnmsgr-transrespbody"))
+ else if (!strcmp(szOldContentType, "application/x-msnmsgr-transrespbody"))
{
const char *szListening = tFileInfo2["Listening"],
*szNonce = tFileInfo2["Nonce"],
@@ -1663,7 +1665,7 @@ LBL_Close:
*szV6Address = tFileInfo2["IPv6-Addrs"],
*szV6Port = tFileInfo2["IPv6-Port" ];
- if ((szNonce == NULL && szHashedNonce == NULL) || szListening == NULL)
+ if ((szNonce == NULL && szHashedNonce == NULL) || szListening == NULL)
{
MSN_DebugLog("Invalid data packet, exiting...");
goto LBL_Close;
@@ -1681,7 +1683,7 @@ LBL_Close:
replaceStr(dc->xNonce, szHashedNonce ? szHashedNonce : szNonce);
// another side reported that it will be a server.
- if (!strcmp(szListening, "true") && (szNonce == NULL || strcmp(szNonce, sttVoidUid)))
+ if (!strcmp(szListening, "true") && (szNonce == NULL || strcmp(szNonce, sttVoidUid)))
{
p2p_startConnect(ft->p2p_dest, szCallID, szV6Address, szV6Port, true);
p2p_startConnect(ft->p2p_dest, szCallID, szInternalAddress, szInternalPort, false);
@@ -1690,7 +1692,7 @@ LBL_Close:
}
// no, send a file via server
- if (!p2p_createListener(ft, dc, chdrs))
+ if (!p2p_createListener(ft, dc, chdrs))
{
p2p_unregisterDC(dc);
if (ft != &ftl)
@@ -1702,13 +1704,13 @@ LBL_Close:
tResult.addString("Content-Type", "application/x-msnmsgr-transrespbody");
}
- else if (!strcmp(szOldContentType, "application/x-msnmsgr-transreqbody"))
+ else if (!strcmp(szOldContentType, "application/x-msnmsgr-transreqbody"))
{
const char *szHashedNonce = tFileInfo2["Hashed-Nonce"];
const char *szNonce = tFileInfo2["Nonce"];
directconnection* dc = p2p_getDCByCallID(szCallID, wlid);
- if (dc == NULL)
+ if (dc == NULL)
{
dc = new directconnection(szCallID, wlid);
p2p_registerDC(dc);
@@ -1718,7 +1720,7 @@ LBL_Close:
replaceStr(dc->xNonce, szHashedNonce ? szHashedNonce : szNonce);
// no, send a file via server
- if (!p2p_createListener(ft, dc, chdrs))
+ if (!p2p_createListener(ft, dc, chdrs))
{
p2p_unregisterDC(dc);
MSN_StartP2PTransferByContact(ft->p2p_dest);
@@ -1727,7 +1729,7 @@ LBL_Close:
tResult.addString("Content-Type", "application/x-msnmsgr-transrespbody");
}
- else
+ else
return;
if (!ft->p2p_isV2) p2p_getMsgId(ft->p2p_dest, -1);
@@ -1765,7 +1767,7 @@ void CMsnProto::p2p_processSIP(ThreadData* info, char* msgbody, P2PB_Header* hdr
msgbody = tFileInfo2.readFromBuffer(msgbody);
const char* szContentType = tFileInfo["Content-Type"];
- if (szContentType == NULL)
+ if (szContentType == NULL)
{
MSN_DebugLog("Invalid or missing Content-Type field, exiting");
return;
@@ -1777,7 +1779,7 @@ void CMsnProto::p2p_processSIP(ThreadData* info, char* msgbody, P2PB_Header* hdr
p2p_getMsgId(wlid, 1);
}
- switch(iMsgType)
+ switch(iMsgType)
{
case 1:
if (!strcmp(szContentType, "application/x-msnmsgr-sessionreqbody"))
@@ -1805,7 +1807,7 @@ void CMsnProto::p2p_processSIP(ThreadData* info, char* msgbody, P2PB_Header* hdr
}
else
{
- if (!(ft->std.flags & PFTS_SENDING))
+ if (!(ft->std.flags & PFTS_SENDING))
ft->bCompleted = true;
}
@@ -1932,7 +1934,7 @@ void CMsnProto::p2p_processMsgV2(ThreadData* info, char* msgbody, const char*
ft->ts = time(NULL);
- if (hdrdata.mTFCode >= 4 && hdrdata.mTFCode <= 7)
+ if (hdrdata.mTFCode >= 4 && hdrdata.mTFCode <= 7)
{
_write(ft->fileId, msg, hdrdata.mPacketLen);
@@ -1948,25 +1950,25 @@ void CMsnProto::p2p_processMsgV2(ThreadData* info, char* msgbody, const char*
MSN_DebugLog("Transferred %I64u bytes remaining %I64u", ft->std.currentFileProgress, hdrdata.mRemSize);
}
- if (hdrdata.mRemSize == 0)
+ if (hdrdata.mRemSize == 0)
{
if (ft->p2p_appID == MSN_APPID_FILE)
{
SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
ft->complete();
}
- else
+ else
{
p2p_savePicture2disk(ft);
if (!ft->p2p_isV2) p2p_sendBye(ft);
}
- }
+ }
}
}
void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wlid)
{
- P2P_Header hdrdata;
+ P2P_Header hdrdata;
msgbody = hdrdata.parseMsg(msgbody);
hdrdata.logHeader(this);
@@ -1981,7 +1983,7 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
{
char msgid[128];
mir_snprintf(msgid, sizeof(msgid), "%s_%08x", wlid, hdrdata.mID);
- int idx = addCachedMsg(msgid, msgbody, (size_t)hdrdata.mOffset, hdrdata.mPacketLen,
+ int idx = addCachedMsg(msgid, msgbody, (size_t)hdrdata.mOffset, hdrdata.mPacketLen,
(size_t)hdrdata.mTotalSize, false);
char* newbody;
@@ -2016,9 +2018,9 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
ft->ts = time(NULL);
//---- receiving redirect -----------
- if (hdrdata.mFlags == 0x01)
+ if (hdrdata.mFlags == 0x01)
{
- if (WaitForSingleObject(ft->hLockHandle, INFINITE) == WAIT_OBJECT_0)
+ if (WaitForSingleObject(ft->hLockHandle, INFINITE) == WAIT_OBJECT_0)
{
__int64 dp = (__int64)(ft->std.currentFileProgress - hdrdata.mAckDataSize);
ft->std.totalProgress -= dp ;
@@ -2026,17 +2028,17 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
_lseeki64(ft->fileId, ft->std.currentFileProgress, SEEK_SET);
ft->tType = info->mType;
ReleaseMutex(ft->hLockHandle);
- }
+ }
}
//---- receiving ack -----------
- if (hdrdata.mFlags == 0x02)
+ if (hdrdata.mFlags == 0x02)
{
ft->p2p_waitack = false;
- if (hdrdata.mAckSessionID == ft->p2p_sendmsgid)
+ if (hdrdata.mAckSessionID == ft->p2p_sendmsgid)
{
- if (ft->p2p_appID == MSN_APPID_FILE)
+ if (ft->p2p_appID == MSN_APPID_FILE)
{
ft->bCompleted = true;
p2p_sendBye(ft);
@@ -2050,7 +2052,7 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
return;
}
- switch(ft->p2p_ackID)
+ switch(ft->p2p_ackID)
{
case 1000:
//---- send Data Preparation Message
@@ -2067,11 +2069,11 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
return;
}
- if (LOWORD(hdrdata.mFlags) == 0)
+ if (LOWORD(hdrdata.mFlags) == 0)
{
//---- accept the data preparation message ------
// const unsigned* pLongs = (unsigned*)msgbody;
- if (hdrdata.mPacketLen == 4 && hdrdata.mTotalSize == 4)
+ if (hdrdata.mPacketLen == 4 && hdrdata.mTotalSize == 4)
{
p2p_sendAck(ft->p2p_dest, &hdrdata);
return;
@@ -2081,12 +2083,12 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
}
//---- receiving data -----------
- if (LOWORD(hdrdata.mFlags) == 0x20 || LOWORD(hdrdata.mFlags) == 0x30)
+ if (LOWORD(hdrdata.mFlags) == 0x20 || LOWORD(hdrdata.mFlags) == 0x30)
{
if (hdrdata.mOffset + hdrdata.mPacketLen > hdrdata.mTotalSize)
hdrdata.mPacketLen = DWORD(hdrdata.mTotalSize - hdrdata.mOffset);
- if (ft->tTypeReq == 0 || ft->tTypeReq == info->mType)
+ if (ft->tTypeReq == 0 || ft->tTypeReq == info->mType)
{
ft->tType = info->mType;
ft->p2p_sendmsgid = hdrdata.mID;
@@ -2095,9 +2097,9 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
__int64 dsz = ft->std.currentFileSize - hdrdata.mOffset;
if (dsz > hdrdata.mPacketLen) dsz = hdrdata.mPacketLen;
- if (ft->tType == info->mType)
+ if (ft->tType == info->mType)
{
- if (dsz > 0 && ft->fileId >= 0)
+ if (dsz > 0 && ft->fileId >= 0)
{
if (ft->lstFilePtr != hdrdata.mOffset)
_lseeki64(ft->fileId, hdrdata.mOffset, SEEK_SET);
@@ -2106,7 +2108,7 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
ft->lstFilePtr = hdrdata.mOffset + dsz;
__int64 dp = ft->lstFilePtr - ft->std.currentFileProgress;
- if (dp > 0)
+ if (dp > 0)
{
ft->std.totalProgress += dp;
ft->std.currentFileProgress += dp;
@@ -2122,7 +2124,7 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
MSN_DebugLog("Transferred %I64u bytes out of %I64u", ft->std.currentFileProgress, hdrdata.mTotalSize);
}
- if (ft->std.currentFileProgress >= hdrdata.mTotalSize)
+ if (ft->std.currentFileProgress >= hdrdata.mTotalSize)
{
SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
p2p_sendAck(ft->p2p_dest, &hdrdata);
@@ -2132,16 +2134,16 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
ft->p2p_waitack = true;
ft->complete();
}
- else
+ else
{
p2p_savePicture2disk(ft);
p2p_sendBye(ft);
}
- }
- }
+ }
+ }
}
- if (hdrdata.mFlags == 0x40 || hdrdata.mFlags == 0x80)
+ if (hdrdata.mFlags == 0x40 || hdrdata.mFlags == 0x80)
{
p2p_sendAbortSession(ft);
p2p_unregisterSession(ft);
@@ -2154,7 +2156,7 @@ void CMsnProto::p2p_processMsg(ThreadData* info, char* msgbody, const char* wl
void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
{
const char* szAppID;
- switch(iAppID)
+ switch(iAppID)
{
case MSN_APPID_FILE: szAppID = "{5D3E02AB-6190-11D3-BBBB-00C04F795683}"; break;
case MSN_APPID_AVATAR: szAppID = "{A4268EEC-FEC5-49E5-95C3-F126696BDBF6}"; break;
@@ -2180,7 +2182,7 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
char* pContext = NULL;
size_t cbContext = 0;
- switch (iAppID)
+ switch (iAppID)
{
case MSN_APPID_FILE:
{
@@ -2191,11 +2193,11 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
if (ft->p2p_isV2)
{
cbContext -= 64;
- ctx->ver = 2;
+ ctx->ver = 2;
}
else
{
- ctx->ver = 3;
+ ctx->ver = 3;
ctx->id = 0xffffffff;
}
ctx->len = (unsigned)cbContext;
@@ -2263,12 +2265,12 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
}
bool sessionExist = p2p_sessionRegistered(ft);
- if (!sessionExist)
+ if (!sessionExist)
{
p2p_registerSession(ft);
unsigned short status = getWord(ft->std.hContact, "Status", ID_STATUS_OFFLINE);
- if ((myFlags & 0x4000000) && cont->places.getCount() <= 1 &&
+ if ((myFlags & 0x4000000) && cont->places.getCount() <= 1 &&
status != ID_STATUS_OFFLINE && status != ID_STATUS_INVISIBLE && m_iStatus != ID_STATUS_INVISIBLE)
{
if (ft->p2p_isV2)
@@ -2276,8 +2278,8 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
if (cont->places.getCount() && cont->places[0].cap1 & cap_SupportsP2PBootstrap)
{
char wlid[128];
- mir_snprintf(wlid, SIZEOF(wlid),
- strcmp(cont->places[0].id, sttVoidUid) ? "%s;%s" : "%s",
+ mir_snprintf(wlid, SIZEOF(wlid),
+ strcmp(cont->places[0].id, sttVoidUid) ? "%s;%s" : "%s",
cont->email, cont->places[0].id);
if (!MSN_GetThreadByContact(wlid, SERVER_P2P_DIRECT))
@@ -2326,7 +2328,7 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
tResult.addLong("Max-Forwards", 0);
tResult.addString("Content-Type", "application/x-msnmsgr-sessionreqbody");
- if (iAppID != MSN_APPID_FILE)
+ if (iAppID != MSN_APPID_FILE)
ft->p2p_waitack = true;
if (ft->p2p_isV2 && ft->std.currentFileNumber == 0)
@@ -2334,8 +2336,8 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
for (int i = 0; i < cont->places.getCount(); ++i)
{
char wlid[128];
- mir_snprintf(wlid, SIZEOF(wlid),
- strcmp(cont->places[i].id, sttVoidUid) ? "%s;%s" : "%s",
+ mir_snprintf(wlid, SIZEOF(wlid),
+ strcmp(cont->places[i].id, sttVoidUid) ? "%s;%s" : "%s",
cont->email, cont->places[i].id);
p2p_sendSlp(-2, ft, tResult, chdrs, wlid);
@@ -2398,20 +2400,20 @@ void CMsnProto::p2p_sessionComplete(filetransfer* ft)
{
if (ft->p2p_appID != MSN_APPID_FILE)
p2p_unregisterSession(ft);
- else if (ft->std.flags & PFTS_SENDING)
+ else if (ft->std.flags & PFTS_SENDING)
{
- if (ft->openNext() == -1)
+ 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);
}
- else
+ else
{
SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0);
p2p_invite(ft->p2p_appID, ft, NULL);
}
}
- else
+ else
{
SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ft->bCompleted ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, ft, 0);
p2p_unregisterSession(ft);
@@ -2469,7 +2471,7 @@ char* P2PV2_Header::createMsg(char *buf, const char* wlid, CMsnProto *ppro)
{
unsigned char hdrLen1 = 8 + (mAckUniqueID ? 6 : 0) + (mCap ? 2 + mCap[1] : 0);
unsigned char comp = hdrLen1 & 3;
- hdrLen1 += comp ? 4 - comp : 0;
+ hdrLen1 += comp ? 4 - comp : 0;
unsigned char hdrLen2 = mPacketLen ? (8 + (mRemSize ? 10 : 0)) : 0;
comp = hdrLen2 & 3;
@@ -2520,8 +2522,8 @@ char* P2PV2_Header::createMsg(char *buf, const char* wlid, CMsnProto *ppro)
}
char* P2P_Header::createMsg(char *buf, const char* wlid, CMsnProto *ppro)
-{
- if (!mID) mID = ppro->p2p_getMsgId(wlid, 1);
- memcpy(buf, &mSessionID, 48);
- return buf + 48;
+{
+ if (!mID) mID = ppro->p2p_getMsgId(wlid, 1);
+ memcpy(buf, &mSessionID, 48);
+ return buf + 48;
}