diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-26 07:48:02 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-26 07:48:02 +0000 |
commit | 53e54f19ecbcd12202473505dd12cea27b453f2c (patch) | |
tree | adce7986ea2f73d3b84c8a30939c5c71f8148431 | |
parent | efee96cfd3e6318ed376363ab9781bd944940107 (diff) |
VKontakte: add filtering by type and source content for news
git-svn-id: http://svn.miranda-ng.org/main/trunk@11642 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 18 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 13 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 42 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 52 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 13 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 14 |
6 files changed, 142 insertions, 10 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index a35e284991..9784b53811 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -57,7 +57,7 @@ BEGIN LEFTMARGIN, 4
RIGHTMARGIN, 297
TOPMARGIN, 7
- BOTTOMMARGIN, 113
+ BOTTOMMARGIN, 193
END
IDD_ACCMGRUI, DIALOG
@@ -132,12 +132,12 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,278,10
END
-IDD_OPT_FEEDS DIALOGEX 0, 0, 304, 122
+IDD_OPT_FEEDS DIALOGEX 0, 0, 304, 202
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "News and event notifications",IDC_STATIC,4,8,293,102
+ GROUPBOX "News and event notifications",IDC_STATIC,4,8,293,97
CTEXT "WARNING: Causes excessive network traffic!!!",IDC_STATIC,12,19,278,8
CONTROL "Enable news feeds",IDC_NEWS_ENBL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,278,10
LTEXT "Interval for news updates (min):",IDC_STATIC,16,44,169,8
@@ -151,6 +151,18 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,81,278,10
CONTROL "Autoclear news and notification history",IDC_NEWSAUTOCLEAR,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,92,278,10
+ GROUPBOX "News types",IDC_STATIC,4,107,293,35
+ CONTROL "Wall posts",IDC_F_POSTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,118,129,10
+ CONTROL "Photos",IDC_F_PHOTOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,129,129,10
+ CONTROL "Photos tags",IDC_F_TAGS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,118,129,10
+ CONTROL "Wall photos",IDC_F_WALLPHOTOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,129,129,10
+ GROUPBOX "News sources",IDC_STATIC,4,144,293,46
+ CONTROL "Friends",IDC_S_FRIENDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,155,129,10
+ CONTROL "Groups",IDC_S_GROUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,166,129,10
+ CONTROL "Include banned sources",IDC_S_BANNED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,177,129,10
+ CONTROL "Pages",IDC_S_PAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,155,129,10
+ CONTROL "Subscriptions to users",IDC_S_FOLLOWING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,166,129,10
+ CONTROL "No reposts",IDC_S_NOREPOSTES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,177,129,10
END
IDD_ACCMGRUI DIALOGEX 0, 0, 186, 68
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index d469f7b127..252877ef6d 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -75,6 +75,17 @@ #define IDC_NEWSBBC_BASIC 1067
#define IDC_NEWSBBC_ADV 1068
#define IDC_IEVIEW 1069
+#define IDC_F_POSTS 1070
+#define IDC_F_PHOTOS 1071
+#define IDC_F_TAGS 1072
+#define IDC_F_WALLPHOTOS 1073
+#define IDC_S_FRIENDS 1074
+#define IDC_S_GROUPS 1075
+#define IDC_S_PAGES 1076
+#define IDC_S_FOLLOWING 1077
+#define IDC_S_BANNED 1078
+#define IDC_S_NOREPOSTES 1079
+
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
@@ -82,7 +93,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1070
+#define _APS_NEXT_CONTROL_VALUE 1071
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 9f13a44dea..d392063d06 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -385,13 +385,48 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime) debugLogA("CVkProto::RetrieveUnreadNews");
if (!IsOnline())
return;
+
+ CMStringA szFilter;
+ szFilter = m_bNewsFilterPosts ? "post" : "";
+
+ szFilter += szFilter.IsEmpty() ? "" : ",";
+ szFilter += m_bNewsFilterPhotos ? "photo" : "";
+
+ szFilter += szFilter.IsEmpty() ? "" : ",";
+ szFilter += m_bNewsFilterTags ? "photo_tag" : "";
+
+ szFilter += szFilter.IsEmpty() ? "" : ",";
+ szFilter += m_bNewsFilterWallPhotos ? "wall_photo" : "";
+
+ if (szFilter.IsEmpty()){
+ debugLogA("CVkProto::RetrieveUnreadNews szFilter empty");
+ return;
+ }
+ CMStringA szSource;
+ szSource = m_bNewsSourceFriends ? "friends" : "";
+
+ szSource += szSource.IsEmpty() ? "" : ",";
+ szSource += m_bNewsSourceGroups ? "groups" : "";
+
+ szSource += szSource.IsEmpty() ? "" : ",";
+ szSource += m_bNewsSourcePages ? "pages" : "";
+
+ szSource += szSource.IsEmpty() ? "" : ",";
+ szSource += m_bNewsSourceFollowing ? "following" : "";
+
+ if (szSource.IsEmpty()){
+ debugLogA("CVkProto::RetrieveUnreadNews szSource empty");
+ return;
+ }
+
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/newsfeed.get.json", true, &CVkProto::OnReceiveUnreadNews)
<< INT_PARAM("count", 100)
- << INT_PARAM("return_banned", 0)
+ << INT_PARAM("return_banned", m_bNewsSourceIncludeBanned ? 1 : 0)
<< INT_PARAM("max_photos", 5)
<< INT_PARAM("start_time", tLastNewsTime + 1)
- << CHAR_PARAM("filters", "post,photo,photo_tag,wall_photo")
+ << CHAR_PARAM("filters", szFilter.GetBuffer())
+ << CHAR_PARAM("source_ids", szSource.GetBuffer())
<< VER_API);
}
@@ -428,7 +463,8 @@ void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *p }
for (int i = 0; i < vkNews.getCount(); i++)
- AddFeedEvent(vkNews[i].tszText, vkNews[i].tDate);
+ if (!(m_bNewsSourceNoReposts && vkNews[i].bIsRepost))
+ AddFeedEvent(vkNews[i].tszText, vkNews[i].tDate);
setDword("LastNewsTime", time(NULL));
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index c5728a7e20..4cff0b64a6 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -349,7 +349,19 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar CheckDlgButton(hwndDlg, IDC_NOTIF_ENBL, ppro->m_bNotificationsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SPEC_CONT_ENBL, ppro->m_bSpecialContactAlwaysEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NEWSAUTOCLEAR, ppro->m_bNewsAutoClearHistory ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_F_POSTS, ppro->m_bNewsFilterPosts ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_F_PHOTOS, ppro->m_bNewsFilterPhotos ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_F_TAGS, ppro->m_bNewsFilterTags ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_F_WALLPHOTOS, ppro->m_bNewsFilterWallPhotos ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_S_FRIENDS, ppro->m_bNewsSourceFriends ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_S_GROUPS, ppro->m_bNewsSourceGroups ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_S_PAGES, ppro->m_bNewsSourcePages ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_S_FOLLOWING, ppro->m_bNewsSourceFollowing ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_S_BANNED, ppro->m_bNewsSourceIncludeBanned ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_S_NOREPOSTES, ppro->m_bNewsSourceNoReposts ? BST_CHECKED : BST_UNCHECKED);
+
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETRANGE, 0, MAKELONG(60*24, 1));
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETPOS, 0, ppro->m_iNewsInterval);
@@ -370,6 +382,16 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar case IDC_NOTIF_ENBL:
case IDC_SPEC_CONT_ENBL:
case IDC_NEWSAUTOCLEAR:
+ case IDC_F_POSTS:
+ case IDC_F_PHOTOS:
+ case IDC_F_TAGS:
+ case IDC_F_WALLPHOTOS:
+ case IDC_S_FRIENDS:
+ case IDC_S_GROUPS:
+ case IDC_S_PAGES:
+ case IDC_S_FOLLOWING:
+ case IDC_S_BANNED:
+ case IDC_S_NOREPOSTES:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -393,6 +415,36 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar ppro->m_bNewsAutoClearHistory = IsDlgButtonChecked(hwndDlg, IDC_NEWSAUTOCLEAR) == BST_CHECKED;
ppro->setByte("NewsAutoClearHistory", ppro->m_bNewsAutoClearHistory);
+ ppro->m_bNewsFilterPosts = IsDlgButtonChecked(hwndDlg, IDC_F_POSTS) == BST_CHECKED;
+ ppro->setByte("NewsFilterPosts", ppro->m_bNewsFilterPosts);
+
+ ppro->m_bNewsFilterPhotos = IsDlgButtonChecked(hwndDlg, IDC_F_PHOTOS) == BST_CHECKED;
+ ppro->setByte("NewsFilterPhotos", ppro->m_bNewsFilterPhotos);
+
+ ppro->m_bNewsFilterTags = IsDlgButtonChecked(hwndDlg, IDC_F_TAGS) == BST_CHECKED;
+ ppro->setByte("NewsFilterTags", ppro->m_bNewsFilterTags);
+
+ ppro->m_bNewsFilterWallPhotos = IsDlgButtonChecked(hwndDlg, IDC_F_WALLPHOTOS) == BST_CHECKED;
+ ppro->setByte("NewsFilterWallPhotos", ppro->m_bNewsFilterWallPhotos);
+
+ ppro->m_bNewsSourceFriends = IsDlgButtonChecked(hwndDlg, IDC_S_FRIENDS) == BST_CHECKED;
+ ppro->setByte("NewsSourceFriends", ppro->m_bNewsSourceFriends);
+
+ ppro->m_bNewsSourceGroups = IsDlgButtonChecked(hwndDlg, IDC_S_GROUPS) == BST_CHECKED;
+ ppro->setByte("NewsSourceGroups", ppro->m_bNewsSourceGroups);
+
+ ppro->m_bNewsSourcePages = IsDlgButtonChecked(hwndDlg, IDC_S_PAGES) == BST_CHECKED;
+ ppro->setByte("NewsSourcePages", ppro->m_bNewsSourcePages);
+
+ ppro->m_bNewsSourceFollowing = IsDlgButtonChecked(hwndDlg, IDC_S_FOLLOWING) == BST_CHECKED;
+ ppro->setByte("NewsSourceFollowing", ppro->m_bNewsSourceFollowing);
+
+ ppro->m_bNewsSourceIncludeBanned = IsDlgButtonChecked(hwndDlg, IDC_S_BANNED) == BST_CHECKED;
+ ppro->setByte("NewsSourceIncludeBanned", ppro->m_bNewsSourceIncludeBanned);
+
+ ppro->m_bNewsSourceNoReposts = IsDlgButtonChecked(hwndDlg, IDC_S_NOREPOSTES) == BST_CHECKED;
+ ppro->setByte("NewsSourceNoReposts", ppro->m_bNewsSourceNoReposts);
+
TCHAR buffer[5] = { 0 };
GetDlgItemText(hwndDlg, IDC_ED_INT_NEWS, buffer, SIZEOF(buffer));
ppro->setDword("NewsInterval", ppro->m_iNewsInterval = _ttoi(buffer));
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 9ca06e231a..61c11dde35 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -84,9 +84,20 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_iNotificationsInterval = getDword("NotificationsInterval", 1);
m_iIMGBBCSupport = getByte("IMGBBCSupport", 0);
m_iBBCForNews = getByte("BBCForNews", 0);
- m_bNewsAutoClearHistory = getBool("NewsAutoClearHistory", 0);
+ m_bNewsAutoClearHistory = getBool("NewsAutoClearHistory", false);
m_iNewsAutoClearHistoryInterval = getDword("NewsAutoClearHistoryInterval", 60*60*24*3);
+ m_bNewsFilterPosts = getBool("NewsFilterPosts", true);
+ m_bNewsFilterPhotos = getBool("NewsFilterPhotos", true);
+ m_bNewsFilterTags = getBool("NewsFilterTags", true);
+ m_bNewsFilterWallPhotos = getBool("NewsFilterWallPhotos", true);
+ m_bNewsSourceFriends = getBool("NewsSourceFriends", true);
+ m_bNewsSourceGroups = getBool("NewsSourceGroups", true);
+ m_bNewsSourcePages = getBool("NewsSourcePages", true);
+ m_bNewsSourceFollowing = getBool("NewsSourceFollowing", true);
+ m_bNewsSourceIncludeBanned = getBool("NewsSourceIncludeBanned", false);
+ m_bNewsSourceNoReposts = getBool("NewsSourceNoReposts", false);
+
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
vk_Instances.insert(this);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 4c41ce0709..7355130c1c 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -193,7 +193,7 @@ struct CVKNewsItem : public MZeroedObject { {
tDate = NULL;
vkUser = NULL;
- bIsGroup = bIsRepost = true;
+ bIsGroup = bIsRepost = false;
};
CMString tszId;
@@ -552,7 +552,17 @@ private: m_bNewsEnabled,
m_bNotificationsEnabled,
m_bSpecialContactAlwaysEnabled,
- m_bNewsAutoClearHistory;
+ m_bNewsAutoClearHistory,
+ m_bNewsFilterPosts,
+ m_bNewsFilterPhotos,
+ m_bNewsFilterTags,
+ m_bNewsFilterWallPhotos,
+ m_bNewsSourceFriends,
+ m_bNewsSourceGroups,
+ m_bNewsSourcePages,
+ m_bNewsSourceFollowing,
+ m_bNewsSourceIncludeBanned,
+ m_bNewsSourceNoReposts;
int m_iNewsInterval, m_iNotificationsInterval, m_iNewsAutoClearHistoryInterval;
|