diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-06-24 08:49:49 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-06-24 08:49:49 +0000 |
commit | fe4cec89d652ba57f7a47d98fb320f710b33ae98 (patch) | |
tree | ec60d2e26ad90cd8de31a029d6bb9aeb9fa20b89 /protocols | |
parent | 3d01a16121bbdaf4b324f375e28d6e6b0feb4fed (diff) |
VKontakte:
added friend_accepted notification type
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@17026 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 13 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 23 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 3 |
11 files changed, 57 insertions, 12 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 3001e246fa..7d5d902c4b 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -231,6 +231,7 @@ BEGIN CONTROL "Invites",IDC_N_INVITES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,217,129,10
CONTROL "Reposts",IDC_N_REPOSTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,195,129,10
CONTROL "Mentions in comments",IDC_N_MENTIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,206,129,10
+ CONTROL "Accepted friend requests",IDC_N_FRIENDACCEPTED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,217,129,10
END
IDD_ACCMGRUI DIALOGEX 0, 0, 186, 68
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index a075efef8f..b2d05a04e1 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -496,21 +496,22 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq) void __cdecl CVkProto::DBAddAuthRequestThread(void *p)
{
- MCONTACT hContact = (UINT_PTR)p;
- if (hContact == NULL || hContact == INVALID_CONTACT_ID || !IsOnline())
+ CVkDBAddAuthRequestThreadParam *param = (CVkDBAddAuthRequestThreadParam *)p;
+ if (param->hContact == NULL || param->hContact == INVALID_CONTACT_ID || !IsOnline())
return;
- for (int i = 0; i < MAX_RETRIES && IsEmpty(ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"))); i++) {
+ for (int i = 0; i < MAX_RETRIES && IsEmpty(ptrT(db_get_tsa(param->hContact, m_szModuleName, "Nick"))); i++) {
Sleep(1500);
if (!IsOnline())
return;
}
- DBAddAuthRequest(hContact);
+ DBAddAuthRequest(param->hContact, param->bAdded);
+ delete param;
}
-void CVkProto::DBAddAuthRequest(const MCONTACT hContact)
+void CVkProto::DBAddAuthRequest(const MCONTACT hContact, bool added)
{
debugLogA("CVkProto::DBAddAuthRequest");
@@ -524,7 +525,7 @@ void CVkProto::DBAddAuthRequest(const MCONTACT hContact) dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_UTF;
- dbei.eventType = EVENTTYPE_AUTHREQUEST;
+ dbei.eventType = added ? EVENTTYPE_ADDED: EVENTTYPE_AUTHREQUEST;
dbei.cbBlob = (DWORD)(sizeof(DWORD) * 2 + mir_strlen(szNick) + mir_strlen(szFirstName) + mir_strlen(szLastName) + 5);
PBYTE pCurBlob = dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index b5c9ec2042..e5db19f100 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Включаемый файл, созданный в Microsoft Visual C++.
-// Используется D:\svn\protocols\VKontakte\res\resource.rc
+// Используется d:\svn\protocols\VKontakte\res\resource.rc
//
#define IDOPENBROWSER 3
#define IDD_ACCMGRUI 101
@@ -123,6 +123,7 @@ #define IDC_SHOW_MENU6 1107
#define IDC_COMBO_MARKASREAD 1108
#define IDC_COMBO_SYNCHISTORY 1109
+#define IDC_N_FRIENDACCEPTED 1110
// Next default values for new objects
//
@@ -131,7 +132,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 123
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1110
+#define _APS_NEXT_CONTROL_VALUE 1111
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 4709f99e49..e5c54ccf68 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 2
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 4aac6e56ac..c889c12705 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -466,6 +466,11 @@ CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CV const JSONNode &jnFeedback = jnItem["feedback"];
const JSONNode &jnParent = jnItem["parent"];
+ if (m_vkOptions.bNotificationFilterAcceptedFriends && tszType == _T("friend_accepted") && jnFeedback && vkFeedbackType == VKObjType::vkUsers) {
+ OnFriendAccepted(jnFeedback);
+ return NULL;
+ }
+
if (!jnFeedback || !jnParent)
return NULL;
@@ -503,6 +508,24 @@ CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CV return NULL;
}
+void CVkProto::OnFriendAccepted(const JSONNode & jnFeedback)
+{
+ const JSONNode &jnUsers = jnFeedback["items"];
+
+ for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
+ const JSONNode &jnUserItem = (*it);
+ if (!jnUserItem["from_id"])
+ continue;
+
+ LONG iUserId = jnUserItem["from_id"].as_int();
+ MCONTACT hContact = FindUser(iUserId, true);
+
+ RetrieveUserInfo(iUserId);
+ CVkDBAddAuthRequestThreadParam *param = new CVkDBAddAuthRequestThreadParam(hContact, true);
+ ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)param);
+ }
+}
+
CVKNewsItem* CVkProto::GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers)
{
debugLogA("CVkProto::GetVkGroupInvates");
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index f0ea304234..096599c20a 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -314,7 +314,8 @@ CVkOptionFeedsForm::CVkOptionFeedsForm(CVkProto *proto): m_cbNotificationFilterLikes(this, IDC_N_LIKES),
m_cbNotificationFilterReposts(this, IDC_N_REPOSTS),
m_cbNotificationFilterMentions(this, IDC_N_MENTIONS),
- m_cbNotificationFilterInvites(this, IDC_N_INVITES)
+ m_cbNotificationFilterInvites(this, IDC_N_INVITES),
+ m_cbNotificationFilterAcceptedFriends(this, IDC_N_FRIENDACCEPTED)
{
CreateLink(m_cbNewsEnabled, m_proto->m_vkOptions.bNewsEnabled);
CreateLink(m_edtNewsInterval, m_proto->m_vkOptions.iNewsInterval);
@@ -338,6 +339,7 @@ CVkOptionFeedsForm::CVkOptionFeedsForm(CVkProto *proto): CreateLink(m_cbNotificationFilterReposts, m_proto->m_vkOptions.bNotificationFilterReposts);
CreateLink(m_cbNotificationFilterMentions, m_proto->m_vkOptions.bNotificationFilterMentions);
CreateLink(m_cbNotificationFilterInvites, m_proto->m_vkOptions.bNotificationFilterInvites);
+ CreateLink(m_cbNotificationFilterAcceptedFriends, m_proto->m_vkOptions.bNotificationFilterAcceptedFriends);
m_cbNewsEnabled.OnChange = Callback(this, &CVkOptionFeedsForm::On_cbNewsEnabledChange);
m_cbNotificationsEnabled.OnChange = Callback(this, &CVkOptionFeedsForm::On_cbNotificationsEnabledChange);
diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h index 3bb05c6efd..52bb746b0c 100644 --- a/protocols/VKontakte/src/vk_options.h +++ b/protocols/VKontakte/src/vk_options.h @@ -133,6 +133,7 @@ class CVkOptionFeedsForm : public CVkDlgBase CCtrlCheck m_cbNotificationFilterReposts;
CCtrlCheck m_cbNotificationFilterMentions;
CCtrlCheck m_cbNotificationFilterInvites;
+ CCtrlCheck m_cbNotificationFilterAcceptedFriends;
public:
CVkOptionFeedsForm(CVkProto *proto);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 0ad602b9c5..f9af337d48 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -267,6 +267,7 @@ private: CVKNewsItem* GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers, bool isRepost = false);
CVKNewsItem* GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers);
CVKNewsItem* GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers);
+ void OnFriendAccepted(const JSONNode &jnFeedback);
CMString GetVkFeedback(const JSONNode &jnFeedback, VKObjType vkFeedbackType, OBJLIST<CVkUserInfo> &vkUsers, CVkUserInfo *vkUser);
CVKNewsItem* GetVkParent(const JSONNode &jnParent, VKObjType vkParentType, LPCTSTR ptszReplyText = NULL, LPCTSTR ptszReplyLink = NULL);
void RetrieveUnreadNews(time_t tLastNewsTime);
@@ -329,7 +330,7 @@ private: void GrabCookies(NETLIBHTTPREQUEST *nhr);
void ApplyCookies(AsyncHttpRequest*);
void __cdecl DBAddAuthRequestThread(void *p);
- void DBAddAuthRequest(const MCONTACT hContact);
+ void DBAddAuthRequest(const MCONTACT hContact, bool bAdded = false);
MCONTACT MContactFromDbEvent(MEVENT hDbEvent);
void SetMirVer(MCONTACT hContact, int platform);
void __cdecl ContactTypingThread(void *p);
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index 8abcc68bb9..f5f4493a48 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -202,6 +202,8 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : bNotificationFilterReposts(proto, "NotificationFilterReposts", true),
bNotificationFilterMentions(proto, "NotificationFilterMentions", true),
bNotificationFilterInvites(proto, "NotificationFilterInvites", true),
+ bNotificationFilterAcceptedFriends(proto, "NotificationFilterAcceptedFriends", true),
+
bUseNonStandardNotifications(proto, "UseNonStandardNotifications", false),
bUseNonStandardUrlEncode(proto, "UseNonStandardUrlEncode", true),
bShortenLinksForAudio(proto, "ShortenLinksForAudio", true),
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 2f2116da87..d8ef6f4104 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -118,6 +118,17 @@ struct CVkSendMsgParam : public MZeroedObject CVkFileUploadParam *pFUP;
};
+struct CVkDBAddAuthRequestThreadParam : public MZeroedObject
+{
+ CVkDBAddAuthRequestThreadParam(MCONTACT _hContact, bool _bAdded) :
+ hContact(_hContact),
+ bAdded(_bAdded)
+ {}
+
+ MCONTACT hContact;
+ bool bAdded;
+};
+
struct CVkChatMessage : public MZeroedObject
{
CVkChatMessage(int _id) :
@@ -316,6 +327,7 @@ struct CVKOptions { CMOption<BYTE> bNotificationFilterReposts;
CMOption<BYTE> bNotificationFilterMentions;
CMOption<BYTE> bNotificationFilterInvites;
+ CMOption<BYTE> bNotificationFilterAcceptedFriends;
CMOption<BYTE> bUseNonStandardNotifications;
CMOption<BYTE> bUseNonStandardUrlEncode;
CMOption<BYTE> bShortenLinksForAudio;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 2430e21a15..14a21a619e 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -581,7 +581,8 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (!getBool(hContact, "ReqAuth")) {
RetrieveUserInfo(userid);
setByte(hContact, "ReqAuth", 1);
- ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)hContact);
+ CVkDBAddAuthRequestThreadParam *param = new CVkDBAddAuthRequestThreadParam(hContact, false);
+ ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)param);
}
}
}
|