summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp47
1 files changed, 31 insertions, 16 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 78b5e6b9e5..ebd26e4996 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -338,7 +338,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
CMString tszOldStatus(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg"));
if (tszValue != tszOldStatus){
db_set_ts(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", tszValue.GetBuffer());
- if (json_get(pItem, "status_audio"))
+ if ((json_get(pItem, "status_audio") != NULL) || (tszValue.GetBuffer()[0] == TCHAR(9835)))
db_set_ts(hContact, m_szModuleName, "ListeningTo", tszValue.GetBuffer());
else
db_unset(hContact, m_szModuleName, "ListeningTo");
@@ -859,13 +859,13 @@ void CVkProto::RetrieveStatusMsg(const CMString &StatusMsg)
void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg)
{
debugLogA("CVkProto::RetrieveStatusMusic");
- if (!IsOnline() || (m_iStatus == ID_STATUS_INVISIBLE))
+ if (!IsOnline() || (m_iStatus == ID_STATUS_INVISIBLE) || (m_iMusicSendMetod == sendNone))
return;
-
+
CMString code;
CMString oldStatusMsg = db_get_tsa(0, m_szModuleName, "OldStatusMsg");
if (StatusMsg.IsEmpty()){
- if (oldStatusMsg.IsEmpty() || m_bAudioStatusOnly)
+ if (m_iMusicSendMetod == sendBroadcastOnly)
code = "API.audio.setBroadcast();return null;";
else{
CMString codeformat("API.status.set({text:\"%s\"});return null;");
@@ -873,22 +873,35 @@ void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg)
}
}
else {
- if (m_bAudioStatusOnly){
- CMString codeformat("var StatusMsg=\"%s\";"
- "var Track=API.audio.search({\"q\":StatusMsg,\"count\":1});"
- "if(Track.count==0){API.audio.setBroadcast();}"
- "else{var owner=Track.items[0].owner_id;var trackID=Track.items[0].id;var audioTxt=owner+\"_\"+trackID;"
- "var ids=API.audio.setBroadcast({\"audio\":audioTxt});};return null;");
+ if (m_iMusicSendMetod == sendBroadcastOnly){
+ CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;"
+ "var Tracks = API.audio.search({\"q\":StatusMsg,\"count\":CntLmt});"
+ "var Cnt=Tracks.count;if (Cnt>CntLmt){Cnt=CntLmt;}"
+ "if (Cnt == 0){API.audio.setBroadcast();}"
+ "else{var i = 0;var j = 0;var Track=\" \";"
+ "while (i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track == StatusMsg){j = i;}i=i+1;}"
+ "Track=Tracks.items[j].owner_id + \"_\" + Tracks.items[j].id;API.audio.setBroadcast({\"audio\":Track});"
+ "};return null;");
code.AppendFormat(codeformat, StatusMsg);
}
- else{
- CMString codeformat("var StatusMsg=\"%s\";"
- "var Track=API.audio.search({\"q\":StatusMsg,\"count\":1});"
- "if(Track.count==0){API.status.set({\"text\":StatusMsg});return null;}"
- "else{var owner=Track.items[0].owner_id;var trackID=Track.items[0].id;var audioTxt=owner+\"_\"+trackID;"
- "var ids=API.audio.setBroadcast({\"audio\":audioTxt});return null;};");
+ else if (m_iMusicSendMetod == sendStatusOnly){
+ CMString codeformat("var StatusMsg=\"&#9835; %s\";"
+ "API.status.set({\"text\":StatusMsg});"
+ "return null;");
code.AppendFormat(codeformat, StatusMsg);
}
+ else if (m_iMusicSendMetod == sendBroadcastAndStatus){
+ CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;var Track=\" \";"
+ "var Tracks = API.audio.search({\"q\":StatusMsg,\"count\":CntLmt});"
+ "var Cnt=Tracks.count;if (Cnt>CntLmt){Cnt=CntLmt;}"
+ "if (Cnt == 0){Track = \"&#9835; \"+StatusMsg; API.status.set({\"text\":Track});}"
+ "else{var i = 0;var j = -1;"
+ "while (i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track == StatusMsg){j = i;}i=i+1;}"
+ "if(j==-1) {Track = \"&#9835; \"+StatusMsg; API.status.set({\"text\":Track});} else {"
+ "Track=Tracks.items[j].owner_id + \"_\" + Tracks.items[j].id;};API.audio.setBroadcast({\"audio\":Track});"
+ "}; return null;");
+ code.AppendFormat(codeformat, StatusMsg);
+ }
}
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
<< TCHAR_PARAM("code", code)
@@ -898,6 +911,8 @@ void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg)
INT_PTR __cdecl CVkProto::SvcSetListeningTo(WPARAM wParam, LPARAM lParam)
{
debugLogA("CVkProto::SvcSetListeningTo");
+ if (m_iMusicSendMetod == sendNone)
+ return 1;
LISTENINGTOINFO *pliInfo = (LISTENINGTOINFO*)lParam;
CMStringW wszListeningTo;
if (pliInfo == NULL || pliInfo->cbSize != sizeof(LISTENINGTOINFO))