From e528a508b7e307bd35b142b269a0bbd1b6813e89 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 12 Jan 2014 11:59:23 +0000 Subject: VKontakte: - completely rewritten schema of pushing requests; - typed http parameters insted of old strings git-svn-id: http://svn.miranda-ng.org/main/trunk@7613 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'protocols/VKontakte/src/misc.cpp') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index b687f7fd16..1a3195812b 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -55,10 +55,10 @@ HANDLE CVkProto::FindUser(LONG dwUserid, bool bCreate) return hNewContact; } -bool CVkProto::CheckMid(int msgid) +bool CVkProto::CheckMid(int guid) { for (int i=m_sendIds.getCount()-1; i >= 0; i--) - if (m_sendIds[i] == (HANDLE)msgid) { + if ((int)m_sendIds[i] == guid) { m_sendIds.remove(i); return true; } @@ -216,6 +216,31 @@ AsyncHttpRequest::AsyncHttpRequest() AddHeader("Accept-Encoding", "booo"); } +AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc) +{ + cbSize = sizeof(NETLIBHTTPREQUEST); + + AddHeader("Connection", "keep-alive"); + AddHeader("Accept-Encoding", "booo"); + + flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT; + if (bSecure) + flags |= NLHRF_SSL; + + if (*_url == '/') { // relative url leads to a site + m_szUrl = ((bSecure) ? "https://" : "http://") + CMStringA("api.vk.com"); + m_szUrl += _url; + bIsMainConn = true; + } + else m_szUrl = _url; + + if (bSecure) + this << CHAR_PARAM("access_token", ppro->m_szAccessToken); + + requestType = iRequestType; + m_pFunc = pFunc; +} + AsyncHttpRequest::~AsyncHttpRequest() { for (int i=0; i < headersCount; i++) { @@ -223,7 +248,6 @@ AsyncHttpRequest::~AsyncHttpRequest() mir_free(headers[i].szValue); } mir_free(headers); - mir_free(szUrl); mir_free(pData); } @@ -240,7 +264,7 @@ void AsyncHttpRequest::Redirect(NETLIBHTTPREQUEST *nhr) for (int i=0; i < nhr->headersCount; i++) { LPCSTR szValue = nhr->headers[i].szValue; if (!_stricmp(nhr->headers[i].szName, "Location")) - replaceStr(szUrl, szValue); + m_szUrl = szValue; } } @@ -286,7 +310,7 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq) CMStringA szCookie; for (int i=0; i < m_cookies.getCount(); i++) { - if ( !strstr(pReq->szUrl, m_cookies[i].m_domain)) + if (!strstr(pReq->m_szUrl, m_cookies[i].m_domain)) continue; if (!szCookie.IsEmpty()) -- cgit v1.2.3