diff options
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 68 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 23 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 16 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 18 |
7 files changed, 120 insertions, 13 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 4d3560d128..2fd7189502 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -925,7 +925,6 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments, BBCSupport iBBC) {
debugLogA("CVkProto::GetAttachmentDescr");
CMString res;
- res.AppendChar('\n');
res += SetBBCString(TranslateT("Attachments:"), iBBC, vkbbcB);
res.AppendChar('\n');
JSONNODE *pAttach;
@@ -1047,3 +1046,70 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments, BBCSupport iBBC) return res;
}
+
+CMString CVkProto::GetFwdMessages(JSONNODE *pMessages, BBCSupport iBBC)
+{
+ CMString res;
+ debugLogA("CVkProto::GetFwdMessages");
+ if (pMessages == NULL){
+ debugLogA("CVkProto::GetFwdMessages pMessages == NULL");
+ return res;
+ }
+
+ JSONNODE *pMsg;
+ for (int i = 0; (pMsg = json_at(pMessages, i)) != NULL; i++) {
+ if (pMsg == NULL) {
+ debugLogA("CVkProto::GetFwdMessages pMsg == NULL");
+ break;
+ }
+
+ int uid = json_as_int(json_get(pMsg, "user_id"));
+ MCONTACT hContact = FindUser(uid);
+ CMString tszNick;
+ if (hContact)
+ tszNick = ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"));
+ if (tszNick.IsEmpty())
+ tszNick = TranslateT("(Unknown contact)");
+
+ CMString tszUrl = _T("https://vk.com/id");
+ tszUrl.AppendFormat(_T("%d"), uid);
+
+ time_t datetime = (time_t)json_as_int(json_get(pMsg, "date"));
+ TCHAR ttime[64];
+ _locale_t locale = _create_locale(LC_ALL, "");
+ _tcsftime_l(ttime, SIZEOF(ttime), _T("%x %X"), localtime(&datetime), locale);
+ _free_locale(locale);
+
+ CMString tszBody = json_as_CMString(json_get(pMsg, "body"));
+
+ JSONNODE *pFwdMessages = json_get(pMsg, "fwd_messages");
+ if (pFwdMessages != NULL){
+ CMString tszFwdMessages = GetFwdMessages(pFwdMessages, m_iBBCForAttachments);
+ if (!tszBody.IsEmpty())
+ tszFwdMessages = _T("\n") + tszFwdMessages;
+ tszBody += tszFwdMessages;
+ }
+
+ JSONNODE *pAttachments = json_get(pMsg, "attachments");
+ if (pAttachments != NULL){
+ CMString tszAttachmentDescr = GetAttachmentDescr(pAttachments, m_iBBCForAttachments);
+ if (!tszBody.IsEmpty())
+ tszAttachmentDescr = _T("\n") + tszAttachmentDescr;
+ tszBody += tszAttachmentDescr;
+ }
+
+ tszBody.Replace(_T("\n"), _T("\n\t"));
+ CMString tszMes;
+ tszMes.AppendFormat(_T("%s %s %s %s:\n%s"),
+ SetBBCString(TranslateT("Message from"), iBBC, vkbbcB).GetBuffer(),
+ SetBBCString(tszNick.GetBuffer(), iBBC, vkbbcUrl, tszUrl.GetBuffer()).GetBuffer(),
+ SetBBCString(TranslateT("at"), iBBC, vkbbcB).GetBuffer(),
+ ttime,
+ tszBody.GetBuffer());
+
+ if (!res.IsEmpty())
+ res.AppendChar(_T('\n'));
+ res += tszMes;
+ }
+ return res;
+}
\ No newline at end of file diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index dd4a9a2ed0..45028dc385 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 44
+#define __BUILD_NUM 45
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 8a2ddb51ed..327f07df55 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -251,13 +251,26 @@ void CVkProto::AppendChatMessage(int id, JSONNODE *pMsg, bool bIsHistory) if (!msgTime || msgTime > now)
msgTime = now;
- ptrT tszBody(json_as_string(json_get(pMsg, "body")));
+ ptrT ptszBody(json_as_string(json_get(pMsg, "body")));
+
+ JSONNODE *pFwdMessages = json_get(pMsg, "fwd_messages");
+ if (pFwdMessages != NULL){
+ CMString tszFwdMessages = GetFwdMessages(pFwdMessages, m_iBBCForAttachments);
+ if (!IsEmpty(ptszBody))
+ tszFwdMessages = _T("\n") + tszFwdMessages;
+ ptszBody = mir_tstrdup(CMString(ptszBody) + tszFwdMessages);
+ }
+
JSONNODE *pAttachments = json_get(pMsg, "attachments");
- if (pAttachments != NULL)
- tszBody = mir_tstrdup(CMString(tszBody) + GetAttachmentDescr(pAttachments));
+ if (pAttachments != NULL){
+ CMString tszAttachmentDescr = GetAttachmentDescr(pAttachments, m_iBBCForAttachments);
+ if (!IsEmpty(ptszBody))
+ tszAttachmentDescr = _T("\n") + tszAttachmentDescr;
+ ptszBody = mir_tstrdup(CMString(ptszBody) + tszAttachmentDescr);
+ }
if (cc->m_bHistoryRead)
- AppendChatMessage(cc, uid, msgTime, tszBody, bIsHistory);
+ AppendChatMessage(cc, uid, msgTime, ptszBody, bIsHistory);
else {
CVkChatMessage *cm = cc->m_msgs.find((CVkChatMessage *)&mid);
if (cm == NULL)
@@ -265,7 +278,7 @@ void CVkProto::AppendChatMessage(int id, JSONNODE *pMsg, bool bIsHistory) cm->m_uid = uid;
cm->m_date = msgTime;
- cm->m_tszBody = tszBody.detouch();
+ cm->m_tszBody = ptszBody.detouch();
cm->m_bHistory = bIsHistory;
}
}
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 9240e56dd2..de43af6405 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -200,8 +200,11 @@ CVKNewsItem* CVkProto::GetVkNewsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> &vkUs }
JSONNODE *pAttachments = json_get(pItem, "attachments");
- if (pAttachments)
+ if (pAttachments){
+ if (!tszText.IsEmpty())
+ tszText.AppendChar(_T('\n'));
tszText += GetAttachmentDescr(pAttachments, m_bUseBBCOnAttacmentsAsNews ? m_iBBCForNews : m_iBBCForAttachments);
+ }
}
CMString tszResFormat;
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index f2a6d53f05..fdca4b00db 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -200,9 +200,21 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque int isRead = json_as_int(json_get(pMsg, "read_state"));
int uid = json_as_int(json_get(pMsg, "user_id"));
+ JSONNODE *pFwdMessages = json_get(pMsg, "fwd_messages");
+ if (pFwdMessages != NULL){
+ CMString tszFwdMessages = GetFwdMessages(pFwdMessages, m_iBBCForAttachments);
+ if (!IsEmpty(ptszBody))
+ tszFwdMessages = _T("\n") + tszFwdMessages;
+ ptszBody = mir_tstrdup(CMString(ptszBody) + tszFwdMessages);
+ }
+
JSONNODE *pAttachments = json_get(pMsg, "attachments");
- if (pAttachments != NULL)
- ptszBody = mir_tstrdup(CMString(ptszBody) + GetAttachmentDescr(pAttachments, m_iBBCForAttachments));
+ if (pAttachments != NULL){
+ CMString tszAttachmentDescr = GetAttachmentDescr(pAttachments, m_iBBCForAttachments);
+ if (!IsEmpty(ptszBody))
+ tszAttachmentDescr = _T("\n") + tszAttachmentDescr;
+ ptszBody = mir_tstrdup(CMString(ptszBody) + tszAttachmentDescr);
+ }
MCONTACT hContact = FindUser(uid, true);
PROTORECVEVENT recv = { 0 };
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 7f705edd56..bf5132c03b 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -420,6 +420,7 @@ struct CVkProto : public PROTO<CVkProto> CMString& ClearFormatNick(CMString& tszText);
CMString GetAttachmentDescr(JSONNODE*, BBCSupport iBBC = bbcNo);
+ CMString GetFwdMessages(JSONNODE *pMessages, BBCSupport iBBC = bbcNo);
//====================================================================================
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index a34e83d07e..3b931859d7 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -637,10 +637,22 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe int isOut = json_as_int(json_get(pMsg, "out"));
int isRead = json_as_int(json_get(pMsg, "read_state"));
int uid = json_as_int(json_get(pMsg, "user_id"));
- JSONNODE *pAttachments = json_get(pMsg, "attachments");
- if (pAttachments != NULL)
- ptszBody = mir_tstrdup(CMString(ptszBody) + GetAttachmentDescr(pAttachments, m_iBBCForAttachments));
+ JSONNODE *pFwdMessages = json_get(pMsg, "fwd_messages");
+ if (pFwdMessages != NULL){
+ CMString tszFwdMessages = GetFwdMessages(pFwdMessages, m_iBBCForAttachments);
+ if (!IsEmpty(ptszBody))
+ tszFwdMessages = _T("\n") + tszFwdMessages;
+ ptszBody = mir_tstrdup(CMString(ptszBody) + tszFwdMessages);
+ }
+
+ JSONNODE *pAttachments = json_get(pMsg, "attachments");
+ if (pAttachments != NULL){
+ CMString tszAttachmentDescr = GetAttachmentDescr(pAttachments, m_iBBCForAttachments);
+ if (!IsEmpty(ptszBody))
+ tszAttachmentDescr = _T("\n") + tszAttachmentDescr;
+ ptszBody = mir_tstrdup(CMString(ptszBody) + tszAttachmentDescr);
+ }
MCONTACT hContact = NULL;
int chat_id = json_as_int(json_get(pMsg, "chat_id"));
|