summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_thread.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-10-11 11:52:12 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-10-11 11:52:12 +0000
commit16836ea77582da49b82c9b95332762f7135c76ea (patch)
tree84b799b2d266d21606e28f59a174b3cdc2b06d03 /protocols/VKontakte/src/vk_thread.cpp
parent5a7f3b64a5f911cbdea5fdd3af571c03b423ec2f (diff)
VKontakte:
add processing for net error on PollServer fix for close chat tab when it destroy fix for rare crash on load chat history version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10763 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index d68c299bf4..e9e8bb035a 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -124,6 +124,7 @@ static char VK_TOKEN_BEG[] = "access_token=";
void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
+ debugLogA("CVkProto::OnOAuthAuthorize %d", reply->resultCode);
GrabCookies(reply);
if (reply->resultCode == 302) { // manual redirect
@@ -1149,6 +1150,8 @@ int CVkProto::PollServer()
NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
if (reply == NULL) {
debugLogA("CVkProto::PollServer is dead");
+ m_pollingConn = NULL;
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
ShutdownSession();
return 0;
}
@@ -1169,6 +1172,14 @@ int CVkProto::PollServer()
PollUpdates(pUpdates);
retVal = 1;
}
+ }
+ else if (((reply->resultCode >= 400) && (reply->resultCode <= 417))
+ || ((reply->resultCode >= 500) && (reply->resultCode <= 509))) {
+ debugLogA("CVkProto::PollServer is dead. Error code - %d", reply->resultCode);
+ m_pollingConn = NULL;
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
+ ShutdownSession();
+ return 0;
}
m_pollingConn = reply->nlc;
@@ -1192,6 +1203,7 @@ void CVkProto::PollingThread(void*)
CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
{
+ debugLogA("CVkProto::GetAttachmentDescr");
CMString res;
res.AppendChar('\n');
res += TranslateT("Attachments:");
@@ -1218,7 +1230,7 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
ptrT ptszTypeTranslate((lstrcmp(ptszType, _T("photo")) == 0) ? TranslateT("Photo") : TranslateT("Sticker"));
res.AppendFormat(_T("%s: %s (%dx%d)"), ptszTypeTranslate, ptszLink, iWidth, iHeight);
if (m_bAddImgBbc)
- res.AppendFormat(L"\n\t[img]%s[/img]", ptszLink);
+ res.AppendFormat(L"\n\t[img]%s[/img]", ptszLink);
}
else if (!lstrcmp(ptszType, _T("audio"))) {
JSONNODE *pAudio = json_get(pAttach, "audio");
@@ -1257,7 +1269,7 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
ptrT ptszText(json_as_string(json_get(pWall, "text")));
int id = json_as_int(json_get(pWall, "id"));
int fromID = json_as_int(json_get(pWall, "from_id"));
- res.AppendFormat(_T("%s: %s - http://vk.com/wall%d_%d"), TranslateT("Wall post"), ptszText, fromID, id);
+ res.AppendFormat(_T("%s: %s - http://vk.com/wall%d_%d"), TranslateT("Wall post"), ptszText ? ptszText : L" ", fromID, id);
}
else res.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType);