From f08c773ae32838a6669664349d85580c910abf60 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Wed, 15 Jul 2015 15:49:49 +0000 Subject: VKontakte: fix audiostatus processing git-svn-id: http://svn.miranda-ng.org/main/trunk@14569 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_thread.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 0261f4ad6a..0be2273a07 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -337,23 +337,29 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) tszValue = jnItem["status"].as_mstring(); CMString tszOldStatus(ptrT(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg"))); - if (tszValue != tszOldStatus) { + if (tszValue != tszOldStatus) db_set_ts(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", tszValue); - db_unset(hContact, m_szModuleName, "AudioUrl"); - const JSONNode &jnAudio = jnItem["status_audio"]; - if (!jnAudio.isnull()) { - db_set_ts(hContact, m_szModuleName, "ListeningTo", tszValue); - tszValue = jnAudio["url"].as_mstring(); - db_set_ts(hContact, m_szModuleName, "AudioUrl", tszValue); + + CMString tszOldListeningTo(ptrT(db_get_tsa(hContact, m_szModuleName, "ListeningTo"))); + const JSONNode &jnAudio = jnItem["status_audio"]; + if (!jnAudio.isnull()) { + CMString tszListeningTo(FORMAT, _T("%s - %s"), jnAudio["artist"].as_mstring(), jnAudio["title"].as_mstring()); + if (tszListeningTo != tszOldListeningTo) { + setTString(hContact, "ListeningTo", tszListeningTo); + setTString(hContact, "AudioUrl", jnAudio["url"].as_mstring()); } - else if (tszValue[0] == TCHAR(9835) && tszValue.GetLength() > 2) - db_set_ts(hContact, m_szModuleName, "ListeningTo", &(tszValue.GetBuffer())[2]); - else - db_unset(hContact, m_szModuleName, "ListeningTo"); + } + else if (tszValue[0] == TCHAR(9835) && tszValue.GetLength() > 2) { + setTString(hContact, "ListeningTo", &(tszValue.GetBuffer())[2]); + db_unset(hContact, m_szModuleName, "AudioUrl"); + } + else { + db_unset(hContact, m_szModuleName, "ListeningTo"); + db_unset(hContact, m_szModuleName, "AudioUrl"); } - tszValue = jnItem["about"].as_mstring(); + tszValue = jnItem["about"].as_mstring(); if (!tszValue.IsEmpty()) setTString(hContact, "About", tszValue); -- cgit v1.2.3