diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-19 04:56:17 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-19 04:56:17 +0000 |
commit | ac22f33faa8c715e6723319c925de0639e10497d (patch) | |
tree | d5701b24d93cf02ba0103ea2ea0e747e5444aa62 /protocols/VKontakte | |
parent | 8ddc6112404431487d4e710405cb726a51243005 (diff) |
VKontakte:
rework notifications for true translate
fix processing for vkComment parent
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11522 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 58 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 55 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 5 |
4 files changed, 75 insertions, 45 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 05d0b6483b..1b8ba128c3 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -634,41 +634,45 @@ int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) //////////////////////////////////////////////////////////////////////////////////////////////////////////
-void CVkProto::SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent)
+CMString CVkProto::SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent)
{
CVkNotification vkNotification[] = {
- { _T("follow"), vkNull, vkUsers },
- { _T("friend_accepted"), vkNull, vkUsers },
- { _T("mention"), vkNull, vkPost },
- { _T("mention_comments"), vkPost, vkComment },
- { _T("wall"), vkNull, vkPost },
- { _T("wall_publish"), vkNull, vkPost },
- { _T("comment_post"), vkPost, vkComment },
- { _T("comment_photo"), vkPhoto, vkComment },
- { _T("comment_video"), vkVideo, vkComment },
- { _T("reply_comment"), vkComment, vkComment },
- { _T("reply_comment_photo"), vkComment, vkComment },
- { _T("reply_comment_video"), vkComment, vkComment },
- { _T("reply_topic"), vkTopic, vkComment },
- { _T("like_post"), vkPost, vkUsers },
- { _T("like_comment"), vkComment, vkUsers },
- { _T("like_photo"), vkPhoto, vkUsers },
- { _T("like_video"), vkVideo, vkUsers },
- { _T("like_comment_photo"), vkComment, vkUsers },
- { _T("like_comment_video"), vkComment, vkUsers },
- { _T("like_comment_topic"), vkComment, vkUsers },
- { _T("copy_post"), vkPost, vkCopy },
- { _T("copy_photo"), vkPhoto, vkCopy },
- { _T("copy_video"), vkVideo, vkCopy },
- { _T("mention_comment_photo"), vkPhoto, vkComment },
- { _T("mention_comment_video"), vkVideo, vkComment }
+ // type, parent, feedback, string for translate
+ { _T("follow"), vkNull, vkUsers, _T("") },
+ { _T("friend_accepted"), vkNull, vkUsers, _T("") },
+ { _T("mention"), vkNull, vkPost, _T("") },
+ { _T("mention_comments"), vkPost, vkComment, _T("") },
+ { _T("wall"), vkNull, vkPost, _T("") },
+ { _T("wall_publish"), vkNull, vkPost, _T("") },
+ { _T("comment_post"), vkPost, vkComment, TranslateT("commented your post") },
+ { _T("comment_photo"), vkPhoto, vkComment, TranslateT("commented your photo") },
+ { _T("comment_video"), vkVideo, vkComment, TranslateT("commented your video") },
+ { _T("reply_comment"), vkComment, vkComment, TranslateT("replied to your comment") },
+ { _T("reply_comment_photo"), vkComment, vkComment, TranslateT("replied to your comment to photo") },
+ { _T("reply_comment_video"), vkComment, vkComment, TranslateT("replied to your comment to video") },
+ { _T("reply_topic"), vkTopic, vkComment, TranslateT("replied to your topic") },
+ { _T("like_post"), vkPost, vkUsers, TranslateT("liked you post") },
+ { _T("like_comment"), vkComment, vkUsers, TranslateT("liked you comment") },
+ { _T("like_photo"), vkPhoto, vkUsers, TranslateT("liked you photo") },
+ { _T("like_video"), vkVideo, vkUsers, TranslateT("liked you video") },
+ { _T("like_comment_photo"), vkComment, vkUsers, TranslateT("liked you comment to photo") },
+ { _T("like_comment_video"), vkComment, vkUsers, TranslateT("liked you comment to video" ) },
+ { _T("like_comment_topic"), vkComment, vkUsers, TranslateT("liked you comment to topic") },
+ { _T("copy_post"), vkPost, vkCopy, TranslateT("shared you post") },
+ { _T("copy_photo"), vkPhoto, vkCopy, TranslateT("shared you photo") },
+ { _T("copy_video"), vkVideo, vkCopy, TranslateT("shared you video") },
+ { _T("mention_comment_photo"), vkPhoto, vkComment, _T("") },
+ { _T("mention_comment_video"), vkVideo, vkComment, _T("") }
};
+ CMString tszRes;
vkFeedback = vkParent = vkNull;
for (int i = 0; i < SIZEOF(vkNotification); i++)
- if (tszType == vkNotification[i].tszType) {
+ if (tszType == vkNotification[i].ptszType) {
vkFeedback = vkNotification[i].vkFeedback;
vkParent = vkNotification[i].vkParent;
+ tszRes = vkNotification[i].ptszTranslate;
break;
}
+ return tszRes;
}
\ No newline at end of file diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index ccfd097a0f..c66a5036da 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 32
+#define __BUILD_NUM 33
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 631372cc12..8d71615558 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -258,11 +258,11 @@ CMString CVkProto::GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType, if (vkFeedbackType == vkComment) {
iUserId = json_as_int(json_get(pFeedback, "from_id"));
- tszFormat = TranslateT("%s%s%s (%s) commented %%s\n%s");
+ tszFormat = TranslateT("%s%s%s (%s) %%s %%s\n%s");
}
else if (vkFeedbackType == vkPost) {
iUserId = json_as_int(json_get(pFeedback, "owner_id "));
- tszFormat = TranslateT("%s%s%s (%s) posted %%s\n%s");
+ tszFormat = TranslateT("%s%s%s (%s) %%s %%s\n%s");
}
else if (vkFeedbackType == VKObjType::vkUsers || vkFeedbackType == vkCopy){
JSONNODE *pUsers = json_get(pFeedback, "items"), *pUserItem;
@@ -277,7 +277,7 @@ CMString CVkProto::GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType, tszUsers += _T(", ");
tszUsers.AppendFormat(_T("%s%s%s (%s)"), tszBBCIn.GetBuffer(), vkUser->m_tszUserNick.GetBuffer(), tszBBCOut.GetBuffer(), vkUser->m_tszLink.GetBuffer());
}
- tszRes.AppendFormat(_T("%s %s %%s"), tszUsers.GetBuffer(), (vkFeedbackType == VKObjType::vkUsers) ? TranslateT("liked your") : TranslateT("shared your"));
+ tszRes.AppendFormat(_T("%s %%s %%s"), tszUsers.GetBuffer());
vkUser = NULL;
iUserId = 0;
}
@@ -305,30 +305,55 @@ CMString CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType) CMString tszPhoto = GetVkPhotoItem(pParent);
LONG iOwnerId = json_as_int(json_get(pParent, "owner_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
- CMString tszFormat = _T("%s\n%s\n%s: https://vk.com/photo%d_%d");
- tszRes.AppendFormat(tszFormat, TranslateT("photo"), tszPhoto.GetBuffer(), TranslateT("Link"), iOwnerId, iId);
+ CMString tszFormat = _T("\n%s\n%s: https://vk.com/photo%d_%d");
+ tszRes.AppendFormat(tszFormat, tszPhoto.GetBuffer(), TranslateT("Link"), iOwnerId, iId);
}
else if (vkParentType == vkVideo) {
LONG iOwnerId = json_as_int(json_get(pParent, "owner_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
CMString tszTitle = json_as_string(json_get(pParent, "title"));
- CMString tszFormat = _T("%s %s%s%s\n%s: https://vk.com/video%d_%d");
- tszRes.AppendFormat(tszFormat, TranslateT("video"), tszBBCIn.GetBuffer(), tszTitle.GetBuffer(), tszBBCOut.GetBuffer(), TranslateT("Link"), iOwnerId, iId);
+ CMString tszFormat = _T("\n%s%s%s\n%s: https://vk.com/video%d_%d");
+ tszRes.AppendFormat(tszFormat, tszBBCIn.GetBuffer(), tszTitle.GetBuffer(), tszBBCOut.GetBuffer(), TranslateT("Link"), iOwnerId, iId);
}
else if (vkParentType == vkPost) {
LONG iOwnerId = json_as_int(json_get(pParent, "from_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
- CMString tszFormat = _T("%s\n%s: https://vk.com/wall%d_%d");
- tszRes.AppendFormat(tszFormat, TranslateT("post"), TranslateT("Link"), iOwnerId, iId);
+ CMString tszFormat = _T("\n%s: https://vk.com/wall%d_%d");
+ tszRes.AppendFormat(tszFormat, TranslateT("Link"), iOwnerId, iId);
}
- else if (vkParentType == vkTopic || vkParentType == vkComment) {
+ else if (vkParentType == vkTopic) {
LONG iOwnerId = json_as_int(json_get(pParent, "owner_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
CMString tszTitle = json_as_string(json_get(pParent, "title"));
- CMString tszFormat = _T("%s %s%s%s\n%s: https://vk.com/topic%d_%d");
- tszRes.AppendFormat(tszFormat, TranslateT("topic"), tszBBCIn.GetBuffer(), tszTitle.GetBuffer(), tszBBCOut.GetBuffer(), TranslateT("Link"), iOwnerId, iId);
+ CMString tszFormat = _T("%s%s%s\n%s: https://vk.com/topic%d_%d");
+ tszRes.AppendFormat(tszFormat, tszBBCIn.GetBuffer(), tszTitle.GetBuffer(), tszBBCOut.GetBuffer(), TranslateT("Link"), iOwnerId, iId);
+ }
+ else if (vkParentType == vkComment) {
+ JSONNODE *pNode = json_get(pParent, "photo");
+ if (pNode)
+ return GetVkParent(pNode, vkPhoto);
+
+ pNode = json_get(pParent, "video");
+ if (pNode)
+ return GetVkParent(pNode, vkVideo);
+
+ LONG iId = json_as_int(json_get(pParent, "id"));
+
+ pNode = json_get(pParent, "post");
+ if (pNode){
+ tszRes = GetVkParent(pNode, vkPost);
+ tszRes.AppendFormat(_T("?reply=%d"), iId);
+ return tszRes;
+ }
+
+ pNode = json_get(pParent, "topic");
+ if (pNode){
+ tszRes = GetVkParent(pNode, vkTopic);
+ tszRes.AppendFormat(_T("?reply=%d"), iId);
+ return tszRes;
+ }
}
return tszRes;
@@ -345,7 +370,7 @@ CMString CVkProto::GetVkNotificationsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> tDate = json_as_int(json_get(pItem, "date"));
VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
- SpanVKNotificationType(tszType, vkFeedbackType, vkParentType);
+ CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType);
JSONNODE *pFeedback = json_get(pItem, "feedback");
if (!pFeedback)
@@ -358,7 +383,7 @@ CMString CVkProto::GetVkNotificationsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> return tszRes;
CMString tszParent = GetVkParent(pParent, vkParentType);
if (!tszParent.IsEmpty() && !tszFeedback.IsEmpty())
- tszRes.AppendFormat(tszFeedback, tszParent.GetBuffer());
+ tszRes.AppendFormat(tszFeedback, tszNotificationTranslate.GetBuffer(), tszParent.GetBuffer());
return tszRes;
}
@@ -427,7 +452,7 @@ void CVkProto::RetrieveUnreadNotifications() Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/notifications.get.json", true, &CVkProto::OnReceiveUnreadNotifications)
<< INT_PARAM("count", 100)
<< INT_PARAM("start_time", tLastNotificationsTime + 1)
- << CHAR_PARAM("filters", "wall,comments,mentions,likes,reposts")
+ << CHAR_PARAM("filters", "comments,likes,reposts")
<< VER_API);
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 6ee5a25b7b..632ea47f60 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -191,8 +191,9 @@ struct TFakeAckParams enum VKObjType { vkNull, vkPost, vkPhoto, vkVideo, vkComment, vkTopic, vkUsers, vkCopy };
struct CVkNotification {
- TCHAR *tszType;
+ TCHAR *ptszType;
VKObjType vkParent, vkFeedback;
+ TCHAR *ptszTranslate;
};
struct CVkProto : public PROTO<CVkProto>
@@ -335,7 +336,7 @@ struct CVkProto : public PROTO<CVkProto> void RetrieveUnreadNotifications();
void OnReceiveUnreadNotifications(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
- void SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent);
+ CMString SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent);
//==== Misc ==========================================================================
|