summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-06-22 14:15:36 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-06-22 14:15:36 +0000
commit0514092bbe0dfcfa7a091a7a66b4df83be3a7eb9 (patch)
tree674ab9d3fccf2e62b4d6861c97bf048ad38f65d2 /protocols
parentca410fe247243f87ac3234f526f708111f227c74 (diff)
VKontakte:
fix logline for quite from muc fix invite after kick situation fix muc title on return to muc change type for IsEmpty() parameter version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/misc.cpp4
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk.h4
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp53
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp6
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
6 files changed, 44 insertions, 26 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 39bc02044a..9646b486d2 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -23,7 +23,7 @@ static const char* szGiftTypes[] = { "thumb_256", "thumb_96", "thumb_48" };
JSONNode nullNode(JSON_NULL);
-bool IsEmpty(TCHAR *str)
+bool IsEmpty(LPCTSTR str)
{
if (str == NULL)
return true;
@@ -32,7 +32,7 @@ bool IsEmpty(TCHAR *str)
return false;
}
-bool IsEmpty(char *str)
+bool IsEmpty(LPCSTR str)
{
if (str == NULL)
return true;
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 087bea8737..102e1daee0 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 7
+#define __BUILD_NUM 8
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h
index 3ffe6bc7fb..4ee5ce3eac 100644
--- a/protocols/VKontakte/src/vk.h
+++ b/protocols/VKontakte/src/vk.h
@@ -90,5 +90,5 @@ HANDLE GetIconHandle(int iCommand);
char* ExpUrlEncode(const char *szUrl, bool strict = false);
-bool IsEmpty(TCHAR *str);
-bool IsEmpty(char *str); \ No newline at end of file
+bool IsEmpty(LPCTSTR str);
+bool IsEmpty(LPCSTR str); \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index ee65cb5714..c9f63cf48c 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -142,16 +142,9 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
const JSONNode &jnInfo = jnResponse["info"];
if (!jnInfo.isnull()) {
- CMString tszTitle(jnInfo["title"].as_mstring());
- if (tszTitle == (cc->m_tszTopic ? cc->m_tszTopic : _T(""))) {
- cc->m_tszTopic = mir_tstrdup(tszTitle);
- setTString(cc->m_hContact, "Nick", tszTitle);
+ if (!jnInfo["title"].isnull())
+ SetChatTitle(cc, jnInfo["title"].as_mstring());
- GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_CHANGESESSIONAME };
- GCEVENT gce = { sizeof(GCEVENT), &gcd };
- gce.ptszText = tszTitle;
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
- }
if (jnInfo["left"].as_int() == 1 || jnInfo["kicked"].as_int() == 1) {
setByte(cc->m_hContact, "kicked", (int)true);
LeaveChat(cc->m_chatid);
@@ -213,6 +206,9 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_PART };
GCEVENT gce = { sizeof(GCEVENT), &gcd };
gce.ptszUID = tszId;
+ gce.dwFlags = GCEF_REMOVECONTACT | GCEF_NOTNOTIFY;
+ gce.time = time(NULL);
+ gce.ptszNick = mir_tstrdup(CMString(FORMAT, _T("%s (https://vk.com/id%s)"), cu.m_tszNick, tszId));
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
cc->m_users.remove(i);
@@ -260,6 +256,24 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
cc->m_msgs.destroy();
}
+void CVkProto::SetChatTitle(CVkChatInfo *cc, LPCTSTR tszTopic)
+{
+ debugLog(_T("CVkProto::SetChatTitle"));
+ if (!cc)
+ return;
+\
+ if (mir_tstrcmp(cc->m_tszTopic, tszTopic) == 0)
+ return;
+
+ cc->m_tszTopic = mir_tstrdup(tszTopic);
+ setTString(cc->m_hContact, "Nick", tszTopic);
+
+ GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_CHANGESESSIONAME };
+ GCEVENT gce = { sizeof(GCEVENT), &gcd };
+ gce.ptszText = tszTopic;
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory)
@@ -313,8 +327,11 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory)
else {
CMString tszUid;
tszUid.AppendFormat(_T("%d"), uid);
- if (tszUid == tszActionMid)
+ if (tszUid == tszActionMid) {
+ if (cc->m_bHistoryRead)
+ return;
tszBody.AppendFormat(_T(" (https://vk.com/id%s) %s"), tszUid, TranslateT("left chat"));
+ }
else {
int a_uid = 0;
int iReadCount = _stscanf(tszActionMid, _T("%d"), &a_uid);
@@ -358,22 +375,18 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory)
CMString tszTitle = jnMsg["action_text"].as_mstring();
tszBody.AppendFormat(_T("%s \"%s\""), TranslateT("change chat title to"), tszTitle.IsEmpty() ? _T(" ") : tszTitle);
- if (!bIsHistory && tszTitle != (cc->m_tszTopic ? cc->m_tszTopic : _T(""))) {
- cc->m_tszTopic = mir_tstrdup(tszTitle);
- setTString(cc->m_hContact, "Nick", tszTitle);
-
- GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_CHANGESESSIONAME };
- GCEVENT gce = { sizeof(GCEVENT), &gcd };
- gce.ptszText = tszTitle;
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
- }
+ if (!bIsHistory)
+ SetChatTitle(cc, tszTitle);
}
else
tszBody.AppendFormat(_T(": %s (%s)"), TranslateT("chat action not supported"), tszAction);
}
- if (cc->m_bHistoryRead)
+ if (cc->m_bHistoryRead) {
+ if (!jnMsg["title"].isnull())
+ SetChatTitle(cc, jnMsg["title"].as_mstring());
AppendChatMessage(cc, uid, msgTime, tszBody, bIsHistory, bIsAction);
+ }
else {
CVkChatMessage *cm = cc->m_msgs.find((CVkChatMessage *)&mid);
if (cm == NULL)
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index cbf42c6c2f..fc07790b82 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -246,8 +246,12 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
int action_mid = _ttoi(jnMsg["action_mid"].as_mstring());
if ((action_chat == "chat_kick_user") && (action_mid == m_myUserId))
KickFromChat(chat_id, uid, jnMsg);
- else
+ else {
+ MCONTACT chatContact = FindChat(chat_id);
+ if (chatContact && getBool(chatContact, "kicked", true))
+ db_unset(chatContact, m_szModuleName, "kicked");
AppendChatMessage(chat_id, jnMsg, false);
+ }
continue;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index db970b9998..4273d2b606 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -640,6 +640,7 @@ private:
OBJLIST<CVkChatInfo> m_chats;
CVkChatInfo* AppendChat(int id, const JSONNode &jnNode);
+ void SetChatTitle(CVkChatInfo *cc, LPCTSTR tszTopic);
void AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory);
void AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCTSTR ptszBody, bool bIsHistory, bool bIsAction = false);
void RetrieveChatInfo(CVkChatInfo*);