From 3b1846ee1e29db1cde81f95fd9446b3a3cd7065e Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Thu, 23 Oct 2014 07:48:18 +0000 Subject: VKontakte: improved search track for broadcast music (path by alitor) reworked code for broadcast music add recognition TCHAR(9835) as broadcasting sign version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10846 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/res/resource.rc | 34 +++++++++++++----------- protocols/VKontakte/src/resource.h | 9 +++++-- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_options.cpp | 26 +++++++++++++++---- protocols/VKontakte/src/vk_proto.cpp | 6 ++++- protocols/VKontakte/src/vk_proto.h | 6 +++-- protocols/VKontakte/src/vk_thread.cpp | 47 ++++++++++++++++++++++------------ 7 files changed, 88 insertions(+), 42 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index d9b251687d..9f4a317356 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -12,7 +12,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Russian (Russia) resources +// Русский (Россия) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT @@ -34,12 +34,12 @@ IDI_ABUSE ICON "report.ico" IDI_VISITPROFILE ICON "home.ico" IDI_HISTORY ICON "history.ico" IDI_KEYS ICON "key.ico" -#endif // Russian (Russia) resources +#endif // Русский (Россия) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources +// Английский (США) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -64,7 +64,7 @@ BEGIN LEFTMARGIN, 4 RIGHTMARGIN, 297 TOPMARGIN, 7 - BOTTOMMARGIN, 132 + BOTTOMMARGIN, 181 END IDD_OPT_MAIN, DIALOG @@ -117,12 +117,12 @@ BEGIN CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,0,49,174,12 END -IDD_OPT_ADV DIALOGEX 0, 0, 304, 143 +IDD_OPT_ADV DIALOGEX 0, 0, 304, 191 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Advanced",IDC_STATIC,4,8,293,77 + GROUPBOX "Advanced",IDC_STATIC,4,8,293,69 CONTROL "Hide chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,19,278,10 CONTROL "Always notify as unread for all incoming message",IDC_MESASUREAD, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,278,10 @@ -131,15 +131,19 @@ BEGIN CONTROL "Process stickers as smileys",IDC_STICKERS_AS_SMYLES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,278,10 CONTROL "Force online status upon user activity",IDC_FORCE_ONLINE_ON_ACT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,63,278,10 - CONTROL "Broadcast music with VK audio status only", IDC_AUDIO_STATUS_ONLY, - "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 74, 278, 10 - GROUPBOX "When I ban user...",IDC_STATIC,4,91,293,33 - CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,129,10 - CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,112,129,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,63,278,10 + GROUPBOX "When I ban user...",IDC_STATIC,4,80,293,33 + CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,90,129,10 + CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,129,10 CONTROL "Remove from friend list",IDC_REMOVE_FROM_FRENDLIST, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,101,129,10 - CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,112,129,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,90,141,10 + CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,101,141,10 + GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,116,293,58,WS_GROUP + CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,127,278,10 + CONTROL "as regular status for unknow music and audio status otherwise",IDC_SEND_MUSIC_BROADCAST_AND_STATUS, + "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,138,278,11 + CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,149,278,10 + CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,160,278,10 END IDD_OPT_MAIN DIALOGEX 0, 0, 304, 188 @@ -236,7 +240,7 @@ END #endif // APSTUDIO_INVOKED -#endif // English (United States) resources +#endif // Английский (США) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index c0418f3012..6d5f834f72 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -50,7 +50,12 @@ #define IDC_ONREPLY 1041 #define IDC_ONTYPING 1042 #define IDC_STATIC_MARK_AS_READ 1043 -#define IDC_AUDIO_STATUS_ONLY 1044 +#define IDC_STATIC_SEND_MUSIC_METOD 1044 +#define IDC_SEND_MUSIC_NONE 1045 +#define IDC_SEND_MUSIC_STATUS 1046 +#define IDC_SEND_MUSIC_BROADCAST 1047 +#define IDC_SEND_MUSIC_BROADCAST_AND_STATUS 1048 + // Next default values for new objects // @@ -59,7 +64,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 117 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1044 +#define _APS_NEXT_CONTROL_VALUE 1049 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 2b0ab6011b..0c6d463a8e 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 24 +#define __BUILD_NUM 25 #include diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 082078188e..bf1236564e 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -229,13 +229,17 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam CheckDlgButton(hwndDlg, IDC_ADD_IMG_BBC, ppro->m_bAddImgBbc); CheckDlgButton(hwndDlg, IDC_STICKERS_AS_SMYLES, ppro->m_bStikersAsSmyles); CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity); - CheckDlgButton(hwndDlg, IDC_AUDIO_STATUS_ONLY, ppro->m_bAudioStatusOnly); CheckDlgButton(hwndDlg, IDC_REPORT_ABUSE, ppro->m_bReportAbuse); CheckDlgButton(hwndDlg, IDC_CLEAR_SERVER_HISTORY, ppro->m_bClearServerHistory); CheckDlgButton(hwndDlg, IDC_REMOVE_FROM_FRENDLIST, ppro->m_bRemoveFromFrendlist); CheckDlgButton(hwndDlg, IDC_REMOVE_FROM_CLIST, ppro->m_bRemoveFromClist); + CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_NONE, (ppro->m_iMusicSendMetod == sendNone)); + CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_BROADCAST, (ppro->m_iMusicSendMetod == sendBroadcastOnly)); + CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_STATUS, (ppro->m_iMusicSendMetod == sendStatusOnly)); + CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_BROADCAST_AND_STATUS, (ppro->m_iMusicSendMetod == sendBroadcastAndStatus)); + return TRUE; case WM_COMMAND: @@ -245,11 +249,14 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam case IDC_ADD_IMG_BBC: case IDC_FORCE_ONLINE_ON_ACT: case IDC_STICKERS_AS_SMYLES: - case IDC_AUDIO_STATUS_ONLY: case IDC_REPORT_ABUSE: case IDC_CLEAR_SERVER_HISTORY: case IDC_REMOVE_FROM_FRENDLIST: case IDC_REMOVE_FROM_CLIST: + case IDC_SEND_MUSIC_NONE: + case IDC_SEND_MUSIC_BROADCAST: + case IDC_SEND_MUSIC_STATUS: + case IDC_SEND_MUSIC_BROADCAST_AND_STATUS: if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus()) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; @@ -273,9 +280,6 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED; ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity); - ppro->m_bAudioStatusOnly = IsDlgButtonChecked(hwndDlg, IDC_AUDIO_STATUS_ONLY) == BST_CHECKED; - ppro->setByte("AudioStatusOnly", ppro->m_bAudioStatusOnly); - ppro->m_bReportAbuse = IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) == BST_CHECKED; ppro->setByte("ReportAbuseOnBanUser", ppro->m_bReportAbuse); @@ -288,6 +292,18 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam ppro->m_bRemoveFromClist = IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_CLIST) == BST_CHECKED; ppro->setByte("RemoveFromClistOnBanUser", ppro->m_bRemoveFromClist); + if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_NONE) == BST_CHECKED) + ppro->m_iMusicSendMetod = sendNone; + if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_BROADCAST) == BST_CHECKED) + ppro->m_iMusicSendMetod = sendBroadcastOnly; + if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_STATUS) == BST_CHECKED) + ppro->m_iMusicSendMetod = sendStatusOnly; + if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_BROADCAST_AND_STATUS) == BST_CHECKED) + ppro->m_iMusicSendMetod = sendBroadcastAndStatus; + ppro->setByte("MusicSendMetod", ppro->m_iMusicSendMetod); + CMStringA szListeningTo(ppro->m_szModuleName); + szListeningTo += "Enabled"; + db_set_b(NULL, "ListeningTo", szListeningTo.GetBuffer(), ppro->m_iMusicSendMetod == 0 ? 0 : 1); } break; diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 53be268746..e02942e11f 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -76,7 +76,11 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_bAddImgBbc = getBool("AddImgBbc", false); m_bStikersAsSmyles = getBool("StikersAsSmyles", false); m_bUserForceOnlineOnActivity = getBool("UserForceOnlineOnActivity", false); - m_bAudioStatusOnly = getBool("AudioStatusOnly", false); + + m_iMusicSendMetod = getByte("MusicSendMetod", 0); + CMStringA szListeningTo(m_szModuleName); + szListeningTo += "Enabled"; + db_set_b(NULL, "ListeningTo", szListeningTo.GetBuffer(), m_iMusicSendMetod == 0 ? 0 : 1); // Set all contacts offline -- in case we crashed SetAllContactStatuses(ID_STATUS_OFFLINE); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index e05ba0bb2b..2260ccf459 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -414,12 +414,14 @@ private: m_bPopUpSyncHistory, m_bAddImgBbc, m_bStikersAsSmyles, - m_bUserForceOnlineOnActivity, - m_bAudioStatusOnly; + m_bUserForceOnlineOnActivity; enum MarkMsgReadOn{ markOnRead, markOnReceive, markOnReply, markOnTyping }; int m_iMarkMessageReadOn; + enum MusicSendMetod{ sendNone, sendStatusOnly, sendBroadcastOnly, sendBroadcastAndStatus }; + int m_iMusicSendMetod; + LONG m_myUserId; ptrT m_defaultGroup; 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 (iCntLmt){Cnt=CntLmt;}" + "if (Cnt == 0){Track = \"♫ \"+StatusMsg; API.status.set({\"text\":Track});}" + "else{var i = 0;var j = -1;" + "while (icbSize != sizeof(LISTENINGTOINFO)) -- cgit v1.2.3