From f5718dda9247abb9e735fbf60e975d6d0662363a Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Tue, 16 Dec 2014 05:12:06 +0000 Subject: =?UTF-8?q?VKontakte:=20vk=20feeds=20support=20(wall)=20=E2=80=93?= =?UTF-8?q?=20part=202=20version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@11443 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/resource.h | 8 +++- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_feed.cpp | 7 +-- protocols/VKontakte/src/vk_options.cpp | 79 ++++++++++++++++++++++++++++++++++ protocols/VKontakte/src/vk_proto.cpp | 5 ++- protocols/VKontakte/src/vk_proto.h | 2 + 6 files changed, 97 insertions(+), 6 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index f4532a417e..9ce31f0f30 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -8,6 +8,7 @@ #define IDD_INVITE 104 #define IDD_GC_CREATE 105 #define IDD_OPT_ADV 106 +#define IDD_OPT_FEEDS 107 #define IDI_NOTIFICATION 109 #define IDI_FRIENDADD 110 #define IDI_BAN 111 @@ -58,6 +59,11 @@ #define IDC_SYNC_AUTO 1051 #define IDC_SYNC_LAST1DAY 1052 #define IDC_SYNC_LAST3DAY 1053 +#define IDC_NEWS_ENBL 1054 +#define IDC_NOTIF_ENBL 1055 +#define IDC_BBC_NEWS 1056 +#define IDC_ED_INT 1057 +#define IDC_SPIN_INT 1058 // Next default values for new objects // @@ -66,7 +72,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 118 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1054 +#define _APS_NEXT_CONTROL_VALUE 1059 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index d2776a5e3a..e765d64d4f 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 30 +#define __BUILD_NUM 31 #include diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index d2d22e21bd..791c423d6b 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -22,8 +22,9 @@ static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_ void CVkProto::AddFeedSpecialUser() { - MCONTACT hContact = FindUser(VK_FEED_USER, m_bNewsEnabled); - if (!m_bNewsEnabled) { + bool bSpecialContact = m_bNewsEnabled || m_bNotificationsEnabled; + MCONTACT hContact = FindUser(VK_FEED_USER, bSpecialContact); + if (!bSpecialContact) { if (hContact) CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); return; @@ -64,7 +65,7 @@ void CVkProto::AddFeedEvent(CMString& tszBody, time_t tTime) void CVkProto::RetrieveUnreadNews() { debugLogA("CVkProto::RetrieveUnreadNews"); - if (!IsOnline() || !m_bNewsEnabled) + if (!IsOnline() || !(m_bNewsEnabled || m_bNotificationsEnabled)) return; time_t tLastNewsTime = getDword("LastNewsTime", time(NULL) - 24 * 60 * 60); diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 380e3a5d3e..19037329f3 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -338,6 +338,79 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam return FALSE; } +INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (uMsg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + ppro = (CVkProto*)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon, 1)); + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon)); + + CheckDlgButton(hwndDlg, IDC_NEWS_ENBL, ppro->m_bNewsEnabled ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_NOTIF_ENBL, ppro->m_bNotificationsEnabled ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_BBC_NEWS, ppro->m_bBBCOnNews ? BST_CHECKED : BST_UNCHECKED); + + SendDlgItemMessage(hwndDlg, IDC_SPIN_INT, UDM_SETRANGE, 0, MAKELONG(60*24, 1)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_INT, UDM_SETPOS, 0, ppro->m_iNewsInterval); + + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_ED_INT: + if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE)) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case IDC_NEWS_ENBL: + case IDC_NOTIF_ENBL: + case IDC_BBC_NEWS: + if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == UDN_DELTAPOS) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + if (((LPNMHDR)lParam)->code == PSN_APPLY) { + ppro->m_bNewsEnabled = IsDlgButtonChecked(hwndDlg, IDC_NEWS_ENBL) == BST_CHECKED; + ppro->setByte("NewsEnabled", ppro->m_bNewsEnabled); + + ppro->m_bNotificationsEnabled = IsDlgButtonChecked(hwndDlg, IDC_NOT_ENBL) == BST_CHECKED; + ppro->setByte("NotificationsEnabled", ppro->m_bNotificationsEnabled); + + ppro->m_bBBCOnNews = IsDlgButtonChecked(hwndDlg, IDC_BBC_NEWS) == BST_CHECKED; + ppro->setByte("BBCOnNews", ppro->m_bBBCOnNews); + + TCHAR buffer[5] = { 0 }; + GetDlgItemText(hwndDlg, IDC_ED_INT, buffer, SIZEOF(buffer)); + ppro->setDword("NewsInterval", ppro->m_iNewsInterval = _ttoi(buffer)); + + } + break; + + case WM_CLOSE: + EndDialog(hwndDlg, 0); + break; + + case WM_DESTROY: + Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0)); + Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0)); + break; + } + + return FALSE; +} + int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { sizeof(odp) }; @@ -358,5 +431,11 @@ int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ADV); odp.pfnDlgProc = &CVkProto::OptionsAdvProc; Options_AddPage(wParam, &odp); + + odp.ptszTab = LPGENT("News and notifications"); + odp.position = 3; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FEEDS); + odp.pfnDlgProc = &CVkProto::OptionsFeedsProc; + Options_AddPage(wParam, &odp); return 0; } diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 6238e399a5..5786d5aa0e 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -79,6 +79,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : szListeningTo += "Enabled"; db_set_b(NULL, "ListeningTo", szListeningTo.GetBuffer(), m_iMusicSendMetod == 0 ? 0 : 1); m_bNewsEnabled = getBool("NewsEnabled", false); + m_bNotificationsEnabled = getBool("NotificationsEnabled", false); m_bBBCOnNews = getBool("BBCOnNews", false); m_iNewsInterval = getDword("NewsInterval", 15); @@ -424,8 +425,10 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) if (!IsOnline()) return 0; LONG userID = getDword(hContact, "ID", -1); - if (userID == -1 || userID == VK_FEED_USER) + if (userID == -1 || userID == VK_FEED_USER){ + ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, 0)); return 0; + } ptrA szMsg; if (flags & PREF_UTF) diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 2e906bb011..8167a0b47d 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -476,6 +476,7 @@ private: m_bStikersAsSmyles, m_bUserForceOnlineOnActivity, m_bNewsEnabled, + m_bNotificationsEnabled, m_bBBCOnNews; int m_iNewsInterval; @@ -511,6 +512,7 @@ private: static INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + static INT_PTR CALLBACK OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); OBJLIST m_chats; CVkChatInfo* AppendChat(int id, JSONNODE *pNode); -- cgit v1.2.3