summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/src/misc.cpp31
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp6
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp2
-rw-r--r--protocols/VKontakte/src/vk_history.cpp6
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp6
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp29
-rw-r--r--protocols/VKontakte/src/vk_proto.h9
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp2
8 files changed, 61 insertions, 30 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 5839d90226..018c0da7fe 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -800,9 +800,10 @@ char* CVkProto::GetStickerId(const char *Msg, int &stickerid)
char *retMsg = nullptr;
int iRes = 0;
- const char *tmpMsg = strstr(Msg, "[sticker:");
+ const char *tmpMsg = strstr(Msg, "[sticker");
if (tmpMsg)
- iRes = sscanf(tmpMsg, "[sticker:%d]", &stickerid);
+ iRes = sscanf(tmpMsg, "[sticker:%d]", &stickerid) == 1 ? 1 : sscanf(tmpMsg, "[sticker-%d]", &stickerid);
+
if (iRes == 1) {
char HeadMsg[32] = { 0 };
mir_snprintf(HeadMsg, "[sticker:%d]", stickerid);
@@ -1086,7 +1087,7 @@ CMStringW& CVkProto::ClearFormatNick(CMStringW& wszText)
/////////////////////////////////////////////////////////////////////////////////////////
-CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT hContact, BBCSupport iBBC)
+CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC)
{
debugLogA("CVkProto::GetAttachmentDescr");
CMStringW res;
@@ -1209,7 +1210,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT h
const JSONNode& jnSubAttachments = jnCopyHystoryItem["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, hContact, iBBC);
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
wszAttachmentDescr.Replace(L"\n", L"\n\t\t");
wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t\t" + wszAttachmentDescr;
@@ -1220,7 +1221,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT h
const JSONNode& jnSubAttachments = jnWall["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, hContact, iBBC);
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
wszAttachmentDescr.Replace(L"\n", L"\n\t");
wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t" + wszAttachmentDescr;
@@ -1274,7 +1275,6 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT h
const JSONNode& jnImages = jnSticker[m_vkOptions.bStickerBackground ? "images_with_background" : "images"];
int iStickerId = jnSticker["sticker_id"].as_int();
- int iProductId = jnSticker["product_id"].as_int();
for (auto& jnImage : jnImages) {
if (jnImage["width"].as_int() == (int)m_vkOptions.iStickerSize) {
@@ -1300,7 +1300,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT h
CreateDirectoryTreeW(wszPath);
bool bSuccess = false;
- CMStringW wszFileName(FORMAT, L"%s\\{sticker-%d-%d}.png", wszPath.c_str(), iProductId, iStickerId);
+ CMStringW wszFileName(FORMAT, L"%s\\[sticker-%d].png", wszPath.c_str(), iStickerId);
if (GetFileAttributesW(wszFileName) == INVALID_FILE_ATTRIBUTES) {
T2Utf szUrl(wszUrl);
@@ -1321,13 +1321,12 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT h
else
bSuccess = true;
-
if (bSuccess) {
- res.AppendFormat(L"{sticker-%d-%d}", iProductId, iStickerId);
+ res.AppendFormat(L"[sticker-%d]", iStickerId);
SMADD_CONT cont;
cont.cbSize = sizeof(SMADD_CONT);
- cont.hContact = hContact;
+ cont.hContact = 0;
cont.type = 1;
cont.path = wszFileName.GetBuffer();
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
@@ -1421,7 +1420,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT h
return res;
}
-CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, MCONTACT hConContact, BBCSupport iBBC)
+CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, BBCSupport iBBC)
{
UINT uid = jnMsg["from_id"].as_int();
CMStringW wszBody(jnMsg["text"].as_mstring());
@@ -1450,7 +1449,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser
const JSONNode& jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, hConContact, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -1458,7 +1457,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser
const JSONNode& jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, hConContact, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
if (wszAttachmentDescr != L"== FilterAudioMessages ==") {
if (!wszBody.IsEmpty())
wszAttachmentDescr = L"\n" + wszAttachmentDescr;
@@ -1481,7 +1480,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser
}
-CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, MCONTACT hConContact, BBCSupport iBBC)
+CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC)
{
CMStringW res;
debugLogA("CVkProto::GetFwdMessages");
@@ -1509,10 +1508,10 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
for (auto& jnMsg : jnMessages.as_array()) {
if (!res.IsEmpty())
res.AppendChar('\n');
- res += GetFwdMessage(jnMsg, jnFUsers, vkUsers, hConContact, iBBC);
+ res += GetFwdMessage(jnMsg, jnFUsers, vkUsers, iBBC);
}
else
- res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, hConContact, iBBC);
+ res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, iBBC);
res.AppendChar('\n');
vkUsers.destroy();
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index becd62f285..f6dd409c78 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -294,7 +294,7 @@ void CVkProto::AppendChatConversationMessage(int id, const JSONNode& jnMsg, cons
const JSONNode& jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, cc->m_hContact, bbcNo);
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, bbcNo);
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -302,7 +302,7 @@ void CVkProto::AppendChatConversationMessage(int id, const JSONNode& jnMsg, cons
const JSONNode& jnReplyMessages = jnMsg["reply_message"];
if (jnReplyMessages && !jnReplyMessages.empty()) {
- CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, cc->m_hContact, bbcNo);
+ CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo);
if (!wszBody.IsEmpty())
wszReplyMessages = L"\n" + wszReplyMessages;
wszBody += wszReplyMessages;
@@ -310,7 +310,7 @@ void CVkProto::AppendChatConversationMessage(int id, const JSONNode& jnMsg, cons
const JSONNode& jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, cc->m_hContact, bbcNo);
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo);
if (wszAttachmentDescr == L"== FilterAudioMessages ==")
return;
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 5f87ba23ff..d2e92ec6f6 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -237,7 +237,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo
if (!wszPopupText.IsEmpty())
wszPopupText.AppendChar('\n');
wszPopupText += TranslateT("(attachments)");
- wszText += GetAttachmentDescr(jnAttachments, FindUser(VK_FEED_USER), m_vkOptions.bUseBBCOnAttacmentsAsNews ? m_vkOptions.BBCForNews() : m_vkOptions.BBCForAttachments());
+ wszText += GetAttachmentDescr(jnAttachments, m_vkOptions.bUseBBCOnAttacmentsAsNews ? m_vkOptions.BBCForNews() : m_vkOptions.BBCForAttachments());
}
}
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index d63cd3761f..417f3521a3 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -239,7 +239,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, hContact, m_vkOptions.BBCForAttachments());
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -247,7 +247,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
const JSONNode& jnReplyMessages = jnMsg["reply_message"];
if (jnReplyMessages && !jnReplyMessages.empty()) {
- CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, hContact, m_vkOptions.BBCForAttachments());
+ CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszReplyMessages = L"\n" + wszReplyMessages;
wszBody += wszReplyMessages;
@@ -255,7 +255,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
const JSONNode &jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, hContact, m_vkOptions.BBCForAttachments());
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
if (wszAttachmentDescr == L"== FilterAudioMessages ==") {
count++;
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index fb644400f0..13484b3b8c 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -276,7 +276,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
const JSONNode& jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, hContact, m_vkOptions.BBCForAttachments());
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -284,7 +284,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
const JSONNode& jnReplyMessages = jnMsg["reply_message"];
if (jnReplyMessages && !jnReplyMessages.empty()) {
- CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, hContact, m_vkOptions.BBCForAttachments());
+ CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszReplyMessages = L"\n" + wszReplyMessages;
wszBody += wszReplyMessages;
@@ -295,7 +295,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
CMStringW wszAttachmentDescr;
const JSONNode& jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- wszAttachmentDescr = GetAttachmentDescr(jnAttachments, hContact, m_vkOptions.BBCForAttachments());
+ wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
if (wszAttachmentDescr == L"== FilterAudioMessages ==") {
if (hContact && (mid > getDword(hContact, "lastmsgid", -1)))
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 2ba0ebfc25..9fb235deeb 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -112,9 +112,38 @@ void CVkProto::OnModulesLoaded()
InitPopups();
InitMenus();
InitDBCustomEvents();
+ InitSmileys();
}
/////////////////////////////////////////////////////////////////////////////////////////
+
+void CVkProto::InitSmileys()
+{
+ if (!m_vkOptions.bStikersAsSmyles)
+ return;
+
+ if (m_vkOptions.bUseStikersAsStaticSmyles)
+ return;
+
+ CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName);
+
+ WIN32_FIND_DATAW findData;
+ HANDLE hFind = FindFirstFileW(wszPath, &findData);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ wszPath.Truncate(wszPath.GetLength() - 5);
+ do {
+ CMStringW wszFileName = wszPath + findData.cFileName;
+
+ SMADD_CONT cont;
+ cont.cbSize = sizeof(SMADD_CONT);
+ cont.hContact = 0;
+ cont.type = 1;
+ cont.path = wszFileName.GetBuffer();
+ CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
+ } while (FindNextFileW(hFind, &findData));
+ }
+}
+
// Menu support
void CVkProto::OnBuildProtoMenu()
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index c2d49e0e3b..dcc60f9c7f 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -230,6 +230,9 @@ private:
m_hContactHistoryMenuItems[CHMI_COUNT],
m_hProtoMenuItems[PMI_COUNT];
+
+ void InitSmileys();
+
//==== Menus =========================================================================
void InitMenus();
@@ -358,9 +361,9 @@ private:
CMStringW GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC);
CMStringW SetBBCString(LPCWSTR wszString, BBCSupport iBBC, VKBBCType bbcType, LPCWSTR wszAddString = nullptr);
CMStringW& ClearFormatNick(CMStringW& wszText);
- CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, MCONTACT hContact, BBCSupport iBBC);
- CMStringW GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, MCONTACT hConContact, BBCSupport iBBC);
- CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, MCONTACT hConContact, BBCSupport iBBC);
+ CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC);
+ CMStringW GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, BBCSupport iBBC);
+ CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC);
void SetInvisible(MCONTACT hContact);
CMStringW RemoveBBC(CMStringW& wszSrc);
void AddVkDeactivateEvent(MCONTACT hContact, CMStringW & wszType);
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index e493bcbe90..7afe14c6e7 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -160,7 +160,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE* proto) :
bPopUpSyncHistory(proto, "PopUpSyncHistory", false),
iMarkMessageReadOn(proto, "MarkMessageReadOn", MarkMsgReadOn::markOnRead),
bStikersAsSmyles(proto, "StikersAsSmyles", false),
- bUseStikersAsStaticSmyles(proto, "UseStikersAsStaticSmyles", true), //true - while issue #2527 not fixed
+ bUseStikersAsStaticSmyles(proto, "UseStikersAsStaticSmyles", false),
bUserForceInvisibleOnActivity(proto, "UserForceOnlineOnActivity", false),
bNewsEnabled(proto, "NewsEnabled", false),
iMaxLoadNewsPhoto(proto, "MaxLoadNewsPhoto", 5),