diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-14 19:40:31 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-14 19:40:31 +0000 |
commit | dab02845fea8031dd3d7864dc1efc211a434f969 (patch) | |
tree | 5106120c4f64fbf518f57a963f5c7aec6eb19363 /protocols/MSN | |
parent | 60df08c2f6194702ec180c2d2adf20d3675edae1 (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')
-rw-r--r-- | protocols/MSN/msn_chat.cpp | 2 | ||||
-rw-r--r-- | protocols/MSN/msn_commands.cpp | 32 | ||||
-rw-r--r-- | protocols/MSN/msn_p2p.cpp | 52 | ||||
-rw-r--r-- | protocols/MSN/msn_p2ps.cpp | 20 | ||||
-rw-r--r-- | protocols/MSN/msn_proto.h | 1 |
5 files changed, 75 insertions, 32 deletions
diff --git a/protocols/MSN/msn_chat.cpp b/protocols/MSN/msn_chat.cpp index eb3411d4ce..58bfcbf866 100644 --- a/protocols/MSN/msn_chat.cpp +++ b/protocols/MSN/msn_chat.cpp @@ -128,7 +128,7 @@ void CMsnProto::MSN_KillChatSession(TCHAR* id) gcd.ptszID = id;
GCEVENT gce = {0};
gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
+ gce.dwFlags = GC_TCHAR | GCEF_REMOVECONTACT;
gce.pDest = &gcd;
CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
diff --git a/protocols/MSN/msn_commands.cpp b/protocols/MSN/msn_commands.cpp index 3902f29a25..b83def22d2 100644 --- a/protocols/MSN/msn_commands.cpp +++ b/protocols/MSN/msn_commands.cpp @@ -67,7 +67,9 @@ void CMsnProto::sttSetMirVer(HANDLE hContact, DWORD dwValue, bool always) "WLM Unknown",
};
- if (dwValue & 0x1)
+ if (dwValue == 0)
+ setString(hContact, "MirVer", "Windows Phone");
+ else if (dwValue & 0x1)
setString(hContact, "MirVer", "MSN Mobile");
else if (dwValue & 0x200)
setString(hContact, "MirVer", "Webmessenger");
@@ -827,18 +829,18 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli }
// Process status message info
- char* szStatMsg = ezxml_txt(ezxml_child(xmli, "PSM"));
- if (*szStatMsg) {
- stripBBCode(szStatMsg);
- stripColorCode(szStatMsg);
- mir_ptr<TCHAR> tszStatMsg( mir_utf8decodeT(szStatMsg));
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", tszStatMsg);
- SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)tszStatMsg);
+ const char* szStatMsg = ezxml_txt(ezxml_child(xmli, "PSM"));
+ if (*szStatMsg)
+ {
+ stripBBCode((char*)szStatMsg);
+ stripColorCode((char*)szStatMsg);
+ DBWriteContactSettingStringUtf(hContact, "CList", "StatusMsg", szStatMsg);
}
- else {
+ else
DBDeleteContactSetting(hContact, "CList", "StatusMsg");
- SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, NULL);
- }
+
+ mir_utf8decode((char*)szStatMsg, NULL);
+ SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)szStatMsg);
// Process current media info
const char* szCrntMda = ezxml_txt(ezxml_child(xmli, "CurrentMedia"));
@@ -1190,6 +1192,8 @@ LBL_InvalidCommand: if (strchr(data.userEmail, ';'))
{
+ if (info->mJoinedContactsWLID.getCount() == 1)
+ p2p_clearThreadSessions(info->mJoinedContactsWLID[0], info->mType);
info->contactLeft(data.userEmail);
break;
}
@@ -1401,7 +1405,7 @@ LBL_InvalidCommand: sttSetMirVer(hContact, cont->cap1, always);
}
- if ((cont->cap1 & 0xf0000000) && data.cmdstring[0] && strcmp(data.cmdstring, "0"))
+ if (/*(cont->cap1 & 0xf0000000) &&*/ data.cmdstring[0] && strcmp(data.cmdstring, "0"))
{
char* szAvatarHash = MSN_GetAvatarHash(data.cmdstring);
if (szAvatarHash == NULL) goto remove;
@@ -1468,7 +1472,8 @@ remove: {
UrlDecode(data.userNick);
HANDLE hContact = MSN_HContactFromEmail(data.userEmail, data.userNick, true, true);
- if (tNumTokens == 5)
+
+ if (tNumTokens == 5 && strcmp(data.flags, "0:0"))
{
MsnContact *cont = Lists_Get(data.userEmail);
if (cont)
@@ -1780,6 +1785,7 @@ remove: case 10:
// TURN setup
+ p2p_processSIP(info, msgBody, NULL, szEmail);
break;
}
break;
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
{
diff --git a/protocols/MSN/msn_p2ps.cpp b/protocols/MSN/msn_p2ps.cpp index a274997524..a3b5965ac8 100644 --- a/protocols/MSN/msn_p2ps.cpp +++ b/protocols/MSN/msn_p2ps.cpp @@ -127,6 +127,24 @@ filetransfer* CMsnProto::p2p_getThreadSession(HANDLE hContact, TInfoType mType) return result;
}
+void CMsnProto::p2p_clearThreadSessions(HANDLE hContact, TInfoType mType)
+{
+ EnterCriticalSection(&sessionLock);
+
+ for (int i=0; i < sessionList.getCount(); i++)
+ {
+ filetransfer* ft = &sessionList[i];
+ if (ft->std.hContact == hContact && ft->tType == mType)
+ {
+ ft->bCanceled = true;
+ ft->tType = SERVER_NOTIFICATION;
+ p2p_sendCancel(ft);
+ }
+ }
+
+ LeaveCriticalSection(&sessionLock);
+}
+
filetransfer* CMsnProto::p2p_getAvatarSession(HANDLE hContact)
{
EnterCriticalSection(&sessionLock);
@@ -172,7 +190,7 @@ void CMsnProto::p2p_clearDormantSessions(void) filetransfer* FT = &sessionList[i];
if (!FT->p2p_sessionid && !MSN_GetUnconnectedThread(FT->p2p_dest, SERVER_P2P_DIRECT))
p2p_invite(FT->p2p_type, FT, NULL);
- else if (FT->p2p_waitack && (ts - FT->ts) > 60)
+ else if (FT->p2p_waitack && (ts - FT->ts) > 120)
{
FT->bCanceled = true;
p2p_sendCancel(FT);
diff --git a/protocols/MSN/msn_proto.h b/protocols/MSN/msn_proto.h index 8f6ddfbfd4..d038850ba4 100644 --- a/protocols/MSN/msn_proto.h +++ b/protocols/MSN/msn_proto.h @@ -354,6 +354,7 @@ struct CMsnProto : public PROTO_INTERFACE void p2p_cancelAllSessions(void);
void p2p_redirectSessions(const char* wlid);
void p2p_startSessions(const char* wlid);
+ void p2p_clearThreadSessions(HANDLE hContact, TInfoType mType);
void p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid);
void p2p_inviteDc(filetransfer* ft, const char *wlid);
|