diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-03-16 10:52:18 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-03-16 10:52:18 +0000 |
commit | 927f7544d4639e95929da0827d73a830caf40667 (patch) | |
tree | 4114b60330f28ac1c0618a4d1131ed6b04c712a8 /protocols/VKontakte/src | |
parent | e157b8ecc9d3c75d7b7aef9f59ce69975d702d1d (diff) |
VKontakte:
add ‘Mark notification as viewed on receive’ option
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@12414 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 28 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 4 |
6 files changed, 37 insertions, 6 deletions
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index da2e728ec0..8f71ff1966 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -103,6 +103,7 @@ #define IDC_ED_URL 1092
#define IDC_ONLY_FRIENDS 1093
#define IDC_ST_WARNING 1095
+#define IDC_NOTIF_MARK_VIEWED 1096
// Next default values for new objects
//
@@ -111,7 +112,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 122
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1096
+#define _APS_NEXT_CONTROL_VALUE 1097
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index d44c6569b9..3f543d71c8 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 50
+#define __BUILD_NUM 51
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index de43af6405..abe233451a 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -543,22 +543,38 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime) << VER_API);
}
-bool CVkProto::FilterNotification(CVKNewsItem* vkNotificationItem)
+bool CVkProto::FilterNotification(CVKNewsItem* vkNotificationItem, bool& isCommented)
{
+ isCommented = false;
if (vkNotificationItem->vkParentType == vkNull)
return false;
if (vkNotificationItem->tszType == _T("mention_comments")
|| vkNotificationItem->tszType == _T("mention_comment_photo")
- || vkNotificationItem->tszType == _T("mention_comment_video"))
+ || vkNotificationItem->tszType == _T("mention_comment_video")){
+ isCommented = true;
return m_bNotificationFilterMentions;
+ }
bool result = (vkNotificationItem->vkFeedbackType == vkUsers && m_bNotificationFilterLikes);
result = (vkNotificationItem->vkFeedbackType == vkCopy && m_bNotificationFilterReposts) || result;
result = (vkNotificationItem->vkFeedbackType == vkComment && m_bNotificationFilterComments) || result;
+
+ isCommented = (vkNotificationItem->vkFeedbackType == vkComment);
+
return result;
}
+void CVkProto::NotificationMarkAsViewed()
+{
+ debugLogA("CVkProto::NotificationMarkAsViewed");
+ if (!IsOnline())
+ return;
+
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/notifications.markAsViewed.json", true, &CVkProto::OnReceiveSmth)
+ << VER_API);
+}
+
void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveUnreadNotifications %d", reply->resultCode);
@@ -588,11 +604,17 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR delete vkNotificationItem;
}
+ bool bNotificationCommentAdded = false;
+ bool bNotificationComment = false;
for (int i = 0; i < vkNotification.getCount(); i++)
- if (FilterNotification(&vkNotification[i]))
+ if (FilterNotification(&vkNotification[i], bNotificationComment)) {
AddFeedEvent(vkNotification[i].tszText, vkNotification[i].tDate);
+ bNotificationCommentAdded = bNotificationComment || bNotificationCommentAdded;
+ }
setDword("LastNotificationsTime", time(NULL));
+ if (m_bNotificationsMarkAsViewed && bNotificationCommentAdded)
+ NotificationMarkAsViewed();
vkNotification.destroy();
vkUsers.destroy();
}
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 7c82a41464..f2da107e70 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -364,6 +364,7 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar 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_NOTIF_MARK_VIEWED, ppro->m_bNotificationsMarkAsViewed ? 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);
@@ -402,6 +403,7 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar case IDC_NEWS_ENBL:
case IDC_NOTIF_ENBL:
+ case IDC_NOTIF_MARK_VIEWED:
case IDC_SPEC_CONT_ENBL:
case IDC_NEWSAUTOCLEAR:
case IDC_F_POSTS:
@@ -435,6 +437,9 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar ppro->m_bNotificationsEnabled = IsDlgButtonChecked(hwndDlg, IDC_NOTIF_ENBL) == BST_CHECKED;
ppro->setByte("NotificationsEnabled", ppro->m_bNotificationsEnabled);
+ ppro->m_bNotificationsMarkAsViewed = IsDlgButtonChecked(hwndDlg, IDC_NOTIF_MARK_VIEWED) == BST_CHECKED;
+ ppro->setByte("NotificationsMarkAsViewed", ppro->m_bNotificationsMarkAsViewed);
+
ppro->m_bSpecialContactAlwaysEnabled = IsDlgButtonChecked(hwndDlg, IDC_SPEC_CONT_ENBL) == BST_CHECKED;
ppro->setByte("SpecialContactAlwaysEnabled", ppro->m_bSpecialContactAlwaysEnabled);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 00d793c473..16a3fc1c64 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -81,6 +81,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_bNewsEnabled = getBool("NewsEnabled", false);
m_iMaxLoadNewsPhoto = getByte("MaxLoadNewsPhoto", 5);
m_bNotificationsEnabled = getBool("NotificationsEnabled", false);
+ m_bNotificationsMarkAsViewed = getBool("NotificationsMarkAsViewed", true);
m_bSpecialContactAlwaysEnabled = getBool("SpecialContactAlwaysEnabled", false);
m_iNewsInterval = getDword("NewsInterval", 15);
m_iNotificationsInterval = getDword("NotificationsInterval", 1);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 3296e5d0a6..63647070a7 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -378,7 +378,8 @@ struct CVkProto : public PROTO<CVkProto> void OnReceiveUnreadNews(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void RetrieveUnreadNotifications(time_t tLastNotificationsTime);
- bool FilterNotification(CVKNewsItem* vkNotificationItem);
+ bool FilterNotification(CVKNewsItem* vkNotificationItem, bool& isCommented);
+ void NotificationMarkAsViewed();
void OnReceiveUnreadNotifications(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void RetrieveUnreadEvents();
void NewsClearHistory();
@@ -578,6 +579,7 @@ private: m_bUserForceOnlineOnActivity,
m_bNewsEnabled,
m_bNotificationsEnabled,
+ m_bNotificationsMarkAsViewed,
m_bSpecialContactAlwaysEnabled,
m_bNewsAutoClearHistory,
m_bNewsFilterPosts,
|