From c6804efd7ba31e209cf8a6bb76dea84f7f1d8eee Mon Sep 17 00:00:00 2001 From: Piotr Piastucki Date: Mon, 28 Dec 2015 13:51:32 +0000 Subject: MSN should now parse Skype client version of other contacts correctly. git-svn-id: http://svn.miranda-ng.org/main/trunk@15951 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn_commands.cpp | 67 +++++++++++++++++++++++++++++++------- protocols/MSN/src/msn_libstr.cpp | 5 ++- protocols/MSN/src/msn_lists.cpp | 11 +++++-- protocols/MSN/src/msn_proto.h | 4 +++ protocols/MSN/src/stdafx.h | 2 ++ 5 files changed, 74 insertions(+), 15 deletions(-) (limited to 'protocols/MSN/src') diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index f6e7e74084..05eff0aec3 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include "stdafx.h" #include "msn_proto.h" +#ifdef OBSOLETE void CMsnProto::MSN_SetMirVer(MCONTACT hContact, DWORD dwValue, bool always) { static const char* MirVerStr[] = @@ -69,6 +70,40 @@ void CMsnProto::MSN_SetMirVer(MCONTACT hContact, DWORD dwValue, bool always) setString(hContact, "MirVer", szVersion); setByte(hContact, "StdMirVer", 1); } +#endif + +void CMsnProto::MSN_SetMirVer(MCONTACT hContact, MsnPlace *place) +{ + static const char* MirVerStr[] = + { + "Windows Messenger", + "Web", + "Windows Phone", + "Xbox", + "Zune", + "iPhone Messenger", + "Mac Messenger", + "SMS Messenger", + "Modern Messenger", + "Skype", + "Windows Skype", + "Windows 8 Skype", + "Mac Skype", + "Linux Skype", + "Windows Phone Skype", + "iOS Skype", + "Android Skype", + "Skype" + }; + + char szVersion[64]; + + if (!place) return; + mir_snprintf(szVersion, sizeof(szVersion), "%s (%s)", + MirVerStr[place->client>=sizeof(MirVerStr)/sizeof(MirVerStr[0])?9:place->client-1], place->szClientVer); + setString(hContact, "MirVer", szVersion); + setByte(hContact, "StdMirVer", 1); +} ///////////////////////////////////////////////////////////////////////////////////////// @@ -205,8 +240,8 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para else if (!ubmMsg && !sdgMsg && !nfyMsg && !info->firstMsgRecv) { info->firstMsgRecv = true; MsnContact *cont = Lists_Get(email); - if (cont && cont->hContact != NULL) - MSN_SetMirVer(cont->hContact, cont->cap1, true); + if (cont && cont->hContact != NULL && cont->places.getCount() > 0) + MSN_SetMirVer(cont->hContact, &cont->places[0]); } if (!_strnicmp(tContentType, "text/plain", 10) || @@ -580,8 +615,8 @@ void CMsnProto::MSN_ProcessNLN(const char *userStatus, const char *wlid, char *u } bool isMe = false; - char* szEmail, *szNet; - parseWLID(NEWSTR_ALLOCA(wlid), &szNet, &szEmail, NULL); + char* szEmail, *szNet, *szInst; + parseWLID(NEWSTR_ALLOCA(wlid), &szNet, &szEmail, &szInst); if (!mir_strcmpi(szEmail, GetMyUsername(atoi(szNet)))) { if (!*userStatus) return; isMe = true; @@ -622,12 +657,8 @@ void CMsnProto::MSN_ProcessNLN(const char *userStatus, const char *wlid, char *u cont->cap2 = end && *end == ':' ? strtoul(end + 1, NULL, 10) : 0; } - if (lastStatus == ID_STATUS_OFFLINE) { - DBVARIANT dbv; - bool always = getString(hContact, "MirVer", &dbv) != 0; - if (!always) db_free(&dbv); - MSN_SetMirVer(hContact, cont->cap1, always); - } + if (lastStatus == ID_STATUS_OFFLINE) + MSN_SetMirVer(hContact, cont->places.find((MsnPlace*)&szInst)); char *pszUrl, *pszAvatarHash; if (cmdstring && *cmdstring && mir_strcmp(cmdstring, "0") && @@ -675,8 +706,8 @@ void CMsnProto::MSN_ProcessStatusMessage(ezxml_t xmli, const char* wlid) MCONTACT hContact = MSN_HContactFromEmail(wlid); if (hContact == NULL) return; - char* szEmail, *szNetId; - parseWLID(NEWSTR_ALLOCA(wlid), &szNetId, &szEmail, NULL); + char* szEmail, *szNetId, *szInst; + parseWLID(NEWSTR_ALLOCA(wlid), &szNetId, &szEmail, &szInst); bool bHasPSM=false; char* szStatMsg = NULL; @@ -710,11 +741,23 @@ void CMsnProto::MSN_ProcessStatusMessage(ezxml_t xmli, const char* wlid) unsigned cap2 = end && *end == ':' ? strtoul(end + 1, NULL, 10) : 0; Lists_AddPlace(szEmail, id, cap1, cap2); + } else if (!mir_strcmp(n, "PE")) { + MsnPlace *place = Lists_GetPlace(szEmail, ezxml_attr(endp, "epid")); + if (place) + { + place->client = atoi(ezxml_txt(ezxml_child(endp, "TYP"))); + mir_strncpy(place->szClientVer, ezxml_txt(ezxml_child(endp, "VER")), sizeof(place->szClientVer)); + } } } { ptrT tszStatus(mir_utf8decodeT(szStatMsg)); + if (szInst) MSN_SetMirVer(hContact, Lists_GetPlace(szEmail, szInst)); + else { + MsnContact *cont = Lists_Get(hContact); + if (cont->places.getCount() > 0) MSN_SetMirVer(hContact, &cont->places[0]); + } ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, tszStatus); } diff --git a/protocols/MSN/src/msn_libstr.cpp b/protocols/MSN/src/msn_libstr.cpp index 741ccb41b6..2e1c52ca98 100644 --- a/protocols/MSN/src/msn_libstr.cpp +++ b/protocols/MSN/src/msn_libstr.cpp @@ -98,7 +98,10 @@ void parseWLID(char* wlid, char** net, char** email, char** inst) col = strchr(wlid, ';'); if (col) { *col = 0; - if (inst) *inst = col + 1; + if (inst) { + *inst = col + 1; + if (strncmp(*inst, "epid=", 5)==0) *inst+=5; + } } else if (inst) *inst = NULL; diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index 8e747106ca..6f752dcc90 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -66,11 +66,16 @@ MsnContact* CMsnProto::Lists_Get(MCONTACT hContact) MsnPlace* CMsnProto::Lists_GetPlace(const char* wlid) { - mir_cslock lck(m_csLists); - char *szEmail, *szInst; parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, &szInst); + return Lists_GetPlace(szEmail, szInst); +} + +MsnPlace* CMsnProto::Lists_GetPlace(const char* szEmail, const char *szInst) +{ + mir_cslock lck(m_csLists); + if (szInst == NULL) szInst = (char*)sttVoidUid; @@ -95,6 +100,8 @@ MsnPlace* CMsnProto::Lists_AddPlace(const char* email, const char* id, unsigned pl->id = mir_strdup(id); pl->cap1 = cap1; pl->cap2 = cap2; + pl->client = 11; + *pl->szClientVer = 0; pl->p2pMsgId = 0; pl->p2pPktNum = 0; p->places.insert(pl); diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index 48d793a770..336aca1bc2 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -225,7 +225,10 @@ struct CMsnProto : public PROTO void MSN_ProcessURIObject(MCONTACT hContact, ezxml_t xmli); void MSN_CustomSmiley(const char* msgBody, char* email, char* nick, int iSmileyType); void MSN_InviteMessage(ThreadData* info, char* msgBody, char* email, char* nick); +#ifdef OBSOLETE void MSN_SetMirVer(MCONTACT hContact, DWORD dwValue, bool always); +#endif + void MSN_SetMirVer(MCONTACT hContact, MsnPlace *place); void LoadOptions(void); @@ -449,6 +452,7 @@ struct CMsnProto : public PROTO MsnContact* Lists_GetNext(int& i); MsnPlace* Lists_GetPlace(const char* wlid); + MsnPlace* Lists_GetPlace(const char* szEmail, const char *szInst); MsnPlace* Lists_AddPlace(const char* email, const char* id, unsigned cap1, unsigned cap2); void Lists_Uninit(void); diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index 0bece806b7..1875c9886a 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -759,6 +759,8 @@ struct MsnPlace char *id; unsigned cap1; unsigned cap2; + unsigned client; + char szClientVer[32]; unsigned p2pMsgId; unsigned short p2pPktNum; -- cgit v1.2.3