summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-08-27 18:45:45 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-08-27 18:45:45 +0000
commitee46b2da0a78717c9ac1ca0739fe7f1f666377ce (patch)
tree894530e91c09ce757e3870e6ad41b5f01e542554 /protocols
parentd7d76938e05d7170668f4f950c40d65c47d1bb64 (diff)
VKontakte:
- fix for long chat messages; - fix for retrieveing user info on adding git-svn-id: http://svn.miranda-ng.org/main/trunk@10332 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/misc.cpp11
-rw-r--r--protocols/VKontakte/src/vk.h3
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp12
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp7
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp9
5 files changed, 34 insertions, 8 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 58d3b356ba..a2fae6f2d1 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -51,6 +51,7 @@ MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate)
CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hNewContact, (LPARAM)m_szModuleName);
setDword(hNewContact, "ID", dwUserid);
db_set_ts(hNewContact, "CList", "Group", m_defaultGroup);
+ RetrieveUserInfo(dwUserid);
return hNewContact;
}
@@ -109,6 +110,16 @@ void CVkProto::OnReceiveSmth(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
CheckJsonResponse(pReq, reply, pRoot);
}
+void MyHtmlDecode(CMStringW &str)
+{
+ str.Replace(_T("<br>"), _T("\n"));
+ str.Replace(_T("&amp;"), _T("&"));
+ str.Replace(_T("&pos;"), _T("\'"));
+ str.Replace(_T("&gt;"), _T(">"));
+ str.Replace(_T("&lt;"), _T("<"));
+ str.Replace(_T("&quot;"), _T("\""));
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
static IconItem iconList[] =
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h
index 0a2058b874..a61ba05cb1 100644
--- a/protocols/VKontakte/src/vk.h
+++ b/protocols/VKontakte/src/vk.h
@@ -52,3 +52,6 @@ LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField);
void InitIcons(void);
HANDLE GetIconHandle(int iCommand);
+
+void MyHtmlDecode(CMStringW &str);
+
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 0bb9873dea..7a83bd2853 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -335,9 +335,15 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
TCHAR *buf = NEWTSTR_ALLOCA(gch->ptszText);
rtrimt(buf);
UnEscapeChatTags(buf);
-
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg)
- << INT_PARAM("type", 1) << INT_PARAM("chat_id", cc->m_chatid) << TCHAR_PARAM("message", buf));
+
+ AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg)
+ << INT_PARAM("type", 1) << INT_PARAM("chat_id", cc->m_chatid);
+ pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ CMStringA szBody(FORMAT, "message=%s", ptrA(mir_urlEncode(mir_utf8encodeT(buf))));
+ pReq->pData = mir_strdup(szBody);
+ pReq->dataLength = szBody.GetLength();
+ Push(pReq);
}
case GC_USER_LOGMENU:
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 033eb42dbb..6d36ad8d0b 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -335,8 +335,11 @@ int CVkProto::FileResume(HANDLE hTransfer,int *action,const PROTOCHAR **filename
int CVkProto::GetInfo(MCONTACT hContact, int infoType)
{
- // TODO: Most probably some ProtoAck should be here instead
- return 1;
+ LONG userID = getDword(hContact, "ID", -1);
+ if (userID == -1)
+ return 1;
+ RetrieveUserInfo(userID);
+ return 0;
}
HWND CVkProto::SearchAdvanced(HWND owner)
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index ebf5929b7a..681b8ef763 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -436,8 +436,11 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (pMsg == NULL)
continue;
- char szMid[40];
int mid = json_as_int(json_get(pMsg, "mid"));
+ if (!CheckMid(mid))
+ continue;
+
+ char szMid[40];
_itoa(mid, szMid, 10);
if (!mids.IsEmpty())
mids.AppendChar(',');
@@ -479,8 +482,8 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
recv.timestamp = datetime;
CMStringW szBody = ptszBody;
- szBody.Replace(_T("<br>"),_T("\n"));
- recv.tszMessage = (TCHAR *) szBody.c_str();
+ MyHtmlDecode(szBody);
+ recv.tszMessage = szBody.GetBuffer();
recv.lParam = isOut;
recv.pCustomData = szMid;