diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-09-22 09:30:48 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-09-22 09:30:48 +0000 |
commit | 5a5a0265a25e063ae560adbf83042e01d0ce1941 (patch) | |
tree | f6c3782d2b911a36f0b8abe71d19a68b38e99edb /protocols/VKontakte/src | |
parent | 3bbcdbe69ab3e2c084eb1e863315718c9c7b2aa1 (diff) |
VKontakte:
hidden option for full load clist
support for sync message read status from server
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@15421 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 26 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/stdafx.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_messages.cpp | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 16 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_pollserver.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 4 |
10 files changed, 63 insertions, 6 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index b83bb0d396..06e0bccac2 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -655,6 +655,32 @@ void CVkProto::SetSrmmReadStatus(MCONTACT hContact) CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
}
+void CVkProto::MarkDialogAsRead(MCONTACT hContact)
+{
+ debugLogA("CVkProto::MarkDialogAsRead");
+ if (!IsOnline())
+ return;
+
+ LONG userID = getDword(hContact, "ID", -1);
+ if (userID == -1 || userID == VK_FEED_USER)
+ return;
+
+ MEVENT hDBEvent;
+ while ((hDBEvent = db_event_firstUnread(hContact)) != NULL) {
+ db_event_markRead(hContact, hDBEvent);
+ int res = CallService(MS_CLIST_REMOVEEVENT, hContact, hDBEvent);
+ debugLogA("CVkProto::MarkDialogAsRead [1] result = %d, hDbEvent = %d", res, (int)hDBEvent);
+ }
+
+ hContact = db_mc_tryMeta(hContact);
+ CLISTEVENT *cle = NULL;
+ while ((cle = (CLISTEVENT*)CallService(MS_CLIST_GETEVENT, hContact, 0)) != NULL) {
+ db_event_markRead(hContact, cle->hDbEvent);
+ int res = CallService(MS_CLIST_REMOVEEVENT, hContact, cle->hDbEvent);
+ debugLogA("CVkProto::MarkDialogAsRead [2] result = %d, hDbEvent = %d", res, (int)(cle->hDbEvent));
+ }
+}
+
char* CVkProto::GetStickerId(const char* Msg, int &stickerid)
{
stickerid = 0;
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index cf4bbc365a..b02e3d1e88 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -40,6 +40,7 @@ #define IDC_CONTACT 1015
#define IDC_AUTOCLEAN 1020
#define IDC_MESASUREAD 1025
+#define IDC_SYNC_MSG_STATUS 1026
#define IDC_USE_LOCAL_TIME 1029
#define IDC_REPORT_ABUSE 1030
#define IDC_CLEAR_SERVER_HISTORY 1031
diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index b70f946812..2387f51043 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -61,6 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_messagestate.h>
#include <m_popup.h>
#include <m_folders.h>
+#include <m_metacontacts.h>
#include "win2k.h"
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index e9fb9515a4..74a6f915af 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 1
-#define __BUILD_NUM 15
+#define __BUILD_NUM 16
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 3e22601291..ae096560d0 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -278,7 +278,8 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe }
PROTORECVEVENT recv = { 0 };
- if (isRead && !m_bMesAsUnread)
+ bool bUseServerReadFlag = m_bSyncReadMessageStatusFromServer ? true : !m_bMesAsUnread;
+ if (isRead && bUseServerReadFlag)
recv.flags |= PREF_CREATEREAD;
if (isOut)
recv.flags |= PREF_SENT;
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index fbeb36b70e..bcb35b11cf 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -243,7 +243,11 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_SYNC_MSG_STATUS, ppro->m_bSyncReadMessageStatusFromServer ? BST_CHECKED : BST_UNCHECKED);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MESASUREAD), IsDlgButtonChecked(hwndDlg, IDC_SYNC_MSG_STATUS) == BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread ? BST_CHECKED : BST_UNCHECKED);
+
CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USENOSTDURLENCODE, ppro->m_bUseNonStandardUrlEncode ? BST_CHECKED : BST_UNCHECKED);
@@ -268,6 +272,13 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+
+ case IDC_SYNC_MSG_STATUS:
+ if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus()) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MESASUREAD), IsDlgButtonChecked(hwndDlg, IDC_SYNC_MSG_STATUS) == BST_UNCHECKED);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
case IDC_HIDECHATS:
case IDC_MESASUREAD:
@@ -295,9 +306,12 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam ppro->m_bHideChats = IsDlgButtonChecked(hwndDlg, IDC_HIDECHATS) == BST_CHECKED;
ppro->setByte("HideChats", ppro->m_bHideChats);
+ ppro->m_bSyncReadMessageStatusFromServer = IsDlgButtonChecked(hwndDlg, IDC_SYNC_MSG_STATUS) == BST_CHECKED;
+ ppro->setByte("SyncReadMessageStatusFromServer", ppro->m_bSyncReadMessageStatusFromServer);
+
ppro->m_bMesAsUnread = IsDlgButtonChecked(hwndDlg, IDC_MESASUREAD) == BST_CHECKED;
ppro->setByte("MesAsUnread", ppro->m_bMesAsUnread);
-
+
ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED;
ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity);
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index fa0617f874..84058a9dcf 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -95,6 +95,8 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) SetSrmmReadStatus(hContact);
if (m_bUserForceOnlineOnActivity)
SetInvisible(hContact);
+ if (m_bSyncReadMessageStatusFromServer)
+ MarkDialogAsRead(hContact);
}
break;
@@ -126,6 +128,12 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) SetInvisible(hContact);
}
break;
+ case VKPOLL_READ_ALL_IN:
+ uid = jnChild[1].as_int();
+ hContact = FindUser(uid);
+ if (hContact != NULL && m_bSyncReadMessageStatusFromServer)
+ MarkDialogAsRead(hContact);
+ break;
case VKPOLL_USR_ONLINE:
uid = -jnChild[1].as_int();
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index c0ea47c99c..f0f2de1357 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -121,6 +121,9 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_bShortenLinksForAudio = getBool("ShortenLinksForAudio", true);
m_bSplitFormatFwdMsg = getBool("SplitFormatFwdMsg", true);
+
+ m_bSyncReadMessageStatusFromServer = getBool("SyncReadMessageStatusFromServer", false);
+ m_bLoadFullCList = getBool("LoadFullCList", false);
m_bSetBroadcast = false;
m_bNeedSendOnline = false;
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 8d3750dddd..58d509bc4d 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -198,6 +198,7 @@ struct CVkProto : public PROTO<CVkProto> void __cdecl ContactTypingThread(void *p);
void SetSrmmReadStatus(MCONTACT hContact);
+ void MarkDialogAsRead(MCONTACT hContact);
char* GetStickerId(const char* Msg, int& stickerid);
@@ -387,7 +388,9 @@ private: m_bUseNonStandardUrlEncode,
m_bSetBroadcast,
m_bShortenLinksForAudio,
- m_bSplitFormatFwdMsg;
+ m_bSplitFormatFwdMsg,
+ m_bSyncReadMessageStatusFromServer,
+ m_bLoadFullCList;
int m_iNewsInterval,
m_iNotificationsInterval,
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 1817ddc68a..c48a330ef6 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -408,13 +408,13 @@ void CVkProto::RetrieveUsersInfo(bool flag) if (m_bNeedSendOnline)
codeformat += _T("API.account.setOnline();");
- if (flag)
+ if (flag && !m_bLoadFullCList)
codeformat += CMString("var US=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});"
"var res=[];var index=US.length;while(index>0){index=index-1;if(US[index].online!=0){res.unshift(US[index]);};};"
"return{\"freeoffline\":1,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
else
codeformat += CMString("var res=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});"
- "return{\"freeoffline\":0,\"users\":res};");
+ "return{\"freeoffline\":0,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
code.AppendFormat(codeformat, userIDs, CMString(flag ? "online,status" : fieldsName));
Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
|