summaryrefslogtreecommitdiff
path: root/protocols/MSN
diff options
context:
space:
mode:
authorPiotr Piastucki <leech.miranda@gmail.com>2015-09-26 12:42:01 +0000
committerPiotr Piastucki <leech.miranda@gmail.com>2015-09-26 12:42:01 +0000
commit6ea19ec892b3b1f89ff8fc23e002839cf3bc66d3 (patch)
tree27808e6f65c082dfb1c814eb87b93cfc0b13ee75 /protocols/MSN
parent526422ad0d6a038125013ae7e41c7baa8d6fbfd4 (diff)
MSN: Fixed ping so that registration hopefully doesn't timeout anymore
git-svn-id: http://svn.miranda-ng.org/main/trunk@15448 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN')
-rw-r--r--protocols/MSN/src/msn_commands.cpp1
-rw-r--r--protocols/MSN/src/msn_misc.cpp6
-rw-r--r--protocols/MSN/src/msn_proto.h1
-rw-r--r--protocols/MSN/src/msn_threads.cpp4
4 files changed, 9 insertions, 3 deletions
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index fbecb676ac..cf4a7054f0 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -163,6 +163,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
else mChatID = info->mChatID;
const char* tMsgId = tHeader["Message-ID"];
+ if (tMsgId) lastMsgId=_atoi64(tMsgId);
// Chunked message
char* newbody = NULL;
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index 7efabf73f9..a1cb7bfa0f 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -740,6 +740,7 @@ int ThreadData::sendPacket(const char* cmd, const char* fmt, ...)
int ThreadData::sendPacketPayload(const char* cmd, const char *param, const char* fmt, ...)
{
int thisTrid = 0;
+ bool bTopHdr;
if (this == NULL) return 0;
@@ -752,12 +753,13 @@ int ThreadData::sendPacketPayload(const char* cmd, const char *param, const char
thisTrid = InterlockedIncrement(&mTrid);
int regSz = proto->msnRegistration ? (int)mir_strlen(proto->msnRegistration)+16 : 0;
int paramStart = mir_snprintf(str, strsize, "%s %d %s ", cmd, thisTrid, param), strSz;
+ if (bTopHdr=*fmt=='\b') fmt++;
while ((strSz = mir_vsnprintf(str + paramStart, strsize - paramStart - regSz - 10, fmt, vararg)) == -1)
str = (char*)mir_realloc(str, strsize += 512);
- if (strSz) strSz+=2;
+ if (strSz && !bTopHdr) strSz+=2;
paramStart+=mir_snprintf(str+paramStart, strsize - paramStart , "%d\r\n", strSz+regSz);
if (proto->msnRegistration) paramStart+=mir_snprintf(str+paramStart, strsize - paramStart, "Registration: %s\r\n", proto->msnRegistration);
- if (strSz) paramStart+=mir_snprintf(str+paramStart, strsize - paramStart, "\r\n");
+ if (strSz && !bTopHdr) paramStart+=mir_snprintf(str+paramStart, strsize - paramStart, "\r\n");
mir_vsnprintf(str + paramStart, strsize - paramStart, fmt, vararg);
str[strsize - 3] = 0;
va_end(vararg);
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h
index f5a4fa8358..d5dc0d0152 100644
--- a/protocols/MSN/src/msn_proto.h
+++ b/protocols/MSN/src/msn_proto.h
@@ -151,6 +151,7 @@ struct CMsnProto : public PROTO<CMsnProto>
LONG m_chatID;
int msnPingTimeout;
+ unsigned __int64 lastMsgId;
HANDLE hKeepAliveThreadEvt;
char* msnModeMsgs[MSN_NUM_MODES];
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp
index 4cd7eb197a..e72575e1fb 100644
--- a/protocols/MSN/src/msn_threads.cpp
+++ b/protocols/MSN/src/msn_threads.cpp
@@ -42,7 +42,9 @@ void __cdecl CMsnProto::msn_keepAliveThread(void*)
msnPingTimeout = 45;
else {
msnPingTimeout = 20;
- keepFlag = keepFlag && msnNsThread->sendPacket("PNG", "CON 0");
+ keepFlag = keepFlag && (lastMsgId?msnNsThread->sendPacketPayload("PNG", "CON", "\bLast-Msg-Id: %I64u\r\n\r\n", lastMsgId):
+ (msnRegistration?msnNsThread->sendPacketPayload("PNG", "CON", "\b\r\n"):
+ msnNsThread->sendPacket("PNG", "CON 0")));
}
#ifdef OBSOLETE
p2p_clearDormantSessions();