summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-12-26 04:23:50 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-12-26 04:23:50 +0000
commitefee96cfd3e6318ed376363ab9781bd944940107 (patch)
tree65b7c778fb973910bd0dc8bc82b56e4e3c70b7e0 /protocols
parentf323ef4e6b1fe263e5564c66da33bdef7eb5fdde (diff)
VKontakte:
add news&notification autoclear option code cleanup version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@11641 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/res/resource.rc2
-rw-r--r--protocols/VKontakte/src/resource.h2
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp21
-rw-r--r--protocols/VKontakte/src/vk_history.cpp8
-rw-r--r--protocols/VKontakte/src/vk_options.cpp5
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.h8
8 files changed, 40 insertions, 10 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index d4faf88787..a35e284991 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -149,6 +149,8 @@ BEGIN
CONTROL "",IDC_SPIN_INT_NOTIF,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,230,67,14,14
CONTROL "Special contact always enabled",IDC_SPEC_CONT_ENBL,
"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
END
IDD_ACCMGRUI DIALOGEX 0, 0, 186, 68
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index 5313811205..d469f7b127 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -61,6 +61,7 @@
#define IDC_SYNC_LAST3DAY 1053
#define IDC_NEWS_ENBL 1054
#define IDC_NOTIF_ENBL 1055
+#define IDC_NEWSAUTOCLEAR 1056
#define IDC_ED_INT_NEWS 1057
#define IDC_SPIN_INT_NEWS 1058
#define IDC_ED_INT_NOTIF 1059
@@ -74,7 +75,6 @@
#define IDC_NEWSBBC_BASIC 1067
#define IDC_NEWSBBC_ADV 1068
#define IDC_IEVIEW 1069
-
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 142a18f885..214cf90db2 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 36
+#define __BUILD_NUM 37
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index e4152d5ae5..9f13a44dea 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -493,10 +493,12 @@ void CVkProto::RetrieveUnreadEvents()
if (time(NULL) - tLastNewsTime >= m_iNewsInterval * 60 && m_bNewsEnabled)
RetrieveUnreadNews(tLastNewsTime);
+ NewsClearHistory();
}
INT_PTR CVkProto::SvcLoadVKNews(WPARAM, LPARAM)
{
+ debugLogA("CVkProto::SvcLoadVKNews");
if (!IsOnline())
return 1;
@@ -509,4 +511,23 @@ INT_PTR CVkProto::SvcLoadVKNews(WPARAM, LPARAM)
RetrieveUnreadNews(tLastNewsTime);
return 0;
+}
+
+void CVkProto::NewsClearHistory()
+{
+ debugLogA("CVkProto::NewsClearHistory");
+ MCONTACT hContact = FindUser(VK_FEED_USER);
+ if (hContact == NULL || !m_bNewsAutoClearHistory)
+ return;
+
+ time_t tTime = time(NULL) - m_iNewsAutoClearHistoryInterval;
+ HANDLE hDBEvent = db_event_first(hContact);
+ while (hDBEvent) {
+ HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDBEvent, &dbei);
+ if (dbei.timestamp < tTime)
+ db_event_delete(hContact, hDBEvent);
+ hDBEvent = hDBEventNext;
+ }
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index 7474b512ea..5a7a1ece6b 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -99,23 +99,21 @@ INT_PTR __cdecl CVkProto::SvcGetServerHistoryLast90Day(WPARAM hContact, LPARAM)
void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay)
{
debugLogA("CVkProto::SvcGetServerHistoryLastNDay %d", NDay);
- if (!IsOnline())
- return;
- UINT iTime = time(NULL) - 60 * 60 * 24 * NDay;
+ time_t tTime = time(NULL) - 60 * 60 * 24 * NDay;
HANDLE hDBEvent = db_event_first(hContact);
while (hDBEvent) {
HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDBEvent, &dbei);
- if (dbei.timestamp > iTime)
+ if (dbei.timestamp > tTime)
db_event_delete(hContact, hDBEvent);
hDBEvent = hDBEventNext;
}
db_unset(hContact, m_szModuleName, "lastmsgid");
- GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, iTime, 0);
+ GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, tTime, 0);
}
void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int iTime, int iLastMsgId, bool once)
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index e601164676..c5728a7e20 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -348,6 +348,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_SPEC_CONT_ENBL, ppro->m_bSpecialContactAlwaysEnabled ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_NEWSAUTOCLEAR, ppro->m_bNewsAutoClearHistory ? 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);
@@ -368,6 +369,7 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
case IDC_NEWS_ENBL:
case IDC_NOTIF_ENBL:
case IDC_SPEC_CONT_ENBL:
+ case IDC_NEWSAUTOCLEAR:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -388,6 +390,9 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
ppro->m_bSpecialContactAlwaysEnabled = IsDlgButtonChecked(hwndDlg, IDC_SPEC_CONT_ENBL) == BST_CHECKED;
ppro->setByte("SpecialContactAlwaysEnabled", ppro->m_bSpecialContactAlwaysEnabled);
+ ppro->m_bNewsAutoClearHistory = IsDlgButtonChecked(hwndDlg, IDC_NEWSAUTOCLEAR) == BST_CHECKED;
+ ppro->setByte("NewsAutoClearHistory", ppro->m_bNewsAutoClearHistory);
+
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 ef47adc411..9ca06e231a 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -84,6 +84,8 @@ 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_iNewsAutoClearHistoryInterval = getDword("NewsAutoClearHistoryInterval", 60*60*24*3);
// 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 5592662f32..4c41ce0709 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -365,7 +365,8 @@ struct CVkProto : public PROTO<CVkProto>
void RetrieveUnreadNotifications(time_t tLastNotificationsTime);
void OnReceiveUnreadNotifications(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
- void CVkProto::RetrieveUnreadEvents();
+ void RetrieveUnreadEvents();
+ void NewsClearHistory();
INT_PTR __cdecl SvcLoadVKNews(WPARAM, LPARAM);
@@ -550,9 +551,10 @@ private:
m_bUserForceOnlineOnActivity,
m_bNewsEnabled,
m_bNotificationsEnabled,
- m_bSpecialContactAlwaysEnabled;
+ m_bSpecialContactAlwaysEnabled,
+ m_bNewsAutoClearHistory;
- int m_iNewsInterval, m_iNotificationsInterval;
+ int m_iNewsInterval, m_iNotificationsInterval, m_iNewsAutoClearHistoryInterval;
enum MarkMsgReadOn { markOnRead, markOnReceive, markOnReply, markOnTyping };
int m_iMarkMessageReadOn;