From 8bcefd591d0a8e3232b790e4ce17f6f32e543867 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Mon, 15 Sep 2014 10:41:25 +0000 Subject: VKontakte: ListeningTo support version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10452 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_thread.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'protocols/VKontakte/src/vk_thread.cpp') diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 6b049b078c..842ad34ce9 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -106,6 +106,7 @@ void CVkProto::SetServerStatus(int iNewStatus) m_iStatus = ID_STATUS_ONLINE; Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/account.setOnline.json", true, &CVkProto::OnReceiveSmth) << VER_API); + RetrieveStatusMusic(); } else m_iStatus = ID_STATUS_INVISIBLE; @@ -750,6 +751,40 @@ void CVkProto::OnReceivePollingInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * m_hPollingThread = ForkThreadEx(&CVkProto::PollingThread, NULL, NULL); } +void CVkProto::RetrieveStatusMusic() +{ + CMString wszListeningTo = db_get_tsa(NULL, m_szModuleName, "ListeningTo"); + RetrieveStatusMsg(wszListeningTo); +} + +void CVkProto::RetrieveStatusMsg(const CMString &StatusMsg) +{ + debugLogA("CVkProto::RetrieveStatusMsg"); + + Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/status.set.json", true, &CVkProto::OnReceiveSmth) + << TCHAR_PARAM("text", StatusMsg) + << VER_API); +} + +INT_PTR __cdecl CVkProto::SetListeningTo(WPARAM wParam, LPARAM lParam) +{ + LISTENINGTOINFO *pliInfo = (LISTENINGTOINFO*)lParam; + + if (pliInfo == NULL || pliInfo->cbSize != sizeof(LISTENINGTOINFO)) + db_unset(NULL, m_szModuleName, "ListeningTo"); + else if (pliInfo->dwFlags & LTI_UNICODE) { + CMStringW wszListeningTo; + if (ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT)) + wszListeningTo = ptrT((LPWSTR)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)L"%track%. %title% - %artist% - %player%", (LPARAM)pliInfo)); + else + wszListeningTo.Format(L"%s. %s - %s - %s", pliInfo->ptszTrack ? pliInfo->ptszTrack : _T(""), pliInfo->ptszTitle ? pliInfo->ptszTitle : _T(""), pliInfo->ptszArtist ? pliInfo->ptszArtist : _T(""), pliInfo->ptszPlayer ? pliInfo->ptszPlayer : _T("")); + + setTString("ListeningTo", wszListeningTo); + } + return 0; +} + + INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM hContact, LPARAM) { LPCTSTR str = TranslateT("Are you sure to reload all messages from vk.com?\nLocal contact history will be deleted and reloaded from the server.\nIt may take a long time.\nDo you want to continue?"); -- cgit v1.2.3