summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-07-24 14:30:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-07-24 14:30:13 +0300
commit103de9c164934b2393dfcba7011625f90c8a2097 (patch)
treef7a4a09afe29398f3b7605d7d0db264638a18150 /protocols
parent541eab20530165d10592a9fda590f435c6a8b4be (diff)
NLHR_PTR - smart pointers make better code
Diffstat (limited to 'protocols')
-rw-r--r--protocols/CurrencyRates/src/HTTPSession.cpp6
-rw-r--r--protocols/Discord/src/connection.cpp4
-rw-r--r--protocols/FacebookRM/src/communication.cpp8
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp19
-rw-r--r--protocols/Gadu-Gadu/src/oauth.cpp9
-rw-r--r--protocols/GmailNotifier/src/check.cpp9
-rw-r--r--protocols/ICQ-WIM/src/http.cpp3
-rw-r--r--protocols/ICQ-WIM/src/server.cpp4
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp7
-rwxr-xr-xprotocols/JabberG/src/jabber_util.cpp3
-rw-r--r--protocols/MSN/src/msn_auth.cpp11
-rw-r--r--protocols/MSN/src/msn_avatar.cpp12
-rw-r--r--protocols/MSN/src/msn_commands.cpp6
-rw-r--r--protocols/MSN/src/msn_proto.cpp24
-rw-r--r--protocols/MSN/src/msn_skypeab.cpp86
-rw-r--r--protocols/MSN/src/msn_soapab.cpp3
-rw-r--r--protocols/MSN/src/msn_ssl.cpp25
-rw-r--r--protocols/MinecraftDynmap/src/communication.cpp7
-rw-r--r--protocols/NewsAggregator/Src/Utils.cpp7
-rw-r--r--protocols/Non-IM Contact/src/http.cpp3
-rw-r--r--protocols/Omegle/src/communication.cpp4
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp3
-rw-r--r--protocols/Twitter/src/utility.cpp10
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp5
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp5
-rw-r--r--protocols/Weather/src/weather_http.cpp3
-rw-r--r--protocols/WebView/src/webview_getdata.cpp4
27 files changed, 101 insertions, 189 deletions
diff --git a/protocols/CurrencyRates/src/HTTPSession.cpp b/protocols/CurrencyRates/src/HTTPSession.cpp
index 22c34867c5..004450736f 100644
--- a/protocols/CurrencyRates/src/HTTPSession.cpp
+++ b/protocols/CurrencyRates/src/HTTPSession.cpp
@@ -26,7 +26,7 @@ bool CHTTPSession::OpenURL(const tstring &rsURL)
return true;
}
-bool CHTTPSession::ReadResponce(tstring& rsResponce)
+bool CHTTPSession::ReadResponce(tstring &rsResponce)
{
if (m_szUrl.IsEmpty())
return false;
@@ -48,7 +48,7 @@ bool CHTTPSession::ReadResponce(tstring& rsResponce)
nlhr.headers = headers;
bool bResult = false;
- NETLIBHTTPREQUEST *pReply = nullptr;
+ NLHR_PTR pReply(0);
{
mir_cslock lck(m_mx);
pReply = Netlib_HttpTransaction(g_hNetLib, &nlhr);
@@ -65,8 +65,6 @@ bool CHTTPSession::ReadResponce(tstring& rsResponce)
bResult = true;
}
-
- Netlib_FreeHttpRequest(pReply);
}
return bResult;
}
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp
index da7f777d59..1842fe1331 100644
--- a/protocols/Discord/src/connection.cpp
+++ b/protocols/Discord/src/connection.cpp
@@ -41,15 +41,13 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
debugLogA("Executing request #%d:\n%s", pReq->m_iReqNum, pReq->szUrl);
- NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq);
+ NLHR_PTR reply(Netlib_HttpTransaction(m_hNetlibUser, pReq));
if (reply != nullptr) {
if (pReq->m_pFunc != nullptr)
(this->*(pReq->m_pFunc))(reply, pReq);
if (pReq->m_bMainSite)
m_hAPIConnection = reply->nlc;
-
- Netlib_FreeHttpRequest(reply);
}
else {
debugLogA("Request %d failed", pReq->m_iReqNum);
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index a7e59ef64b..7d0dfaa86f 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -79,7 +79,7 @@ http::response facebook_client::sendRequest(HttpRequest *request)
parent->debugLogA("@@@ Sending request to '%s'", request->m_szUrl.c_str());
// Send the request
- NETLIBHTTPREQUEST *pnlhr = request->Send(handle_);
+ NLHR_PTR pnlhr(request->Send(handle_));
// Remember the persistent connection handle (or not)
switch (request->Persistent) {
@@ -103,8 +103,6 @@ http::response facebook_client::sendRequest(HttpRequest *request)
store_headers(&resp, pnlhr->headers, pnlhr->headersCount);
resp.code = pnlhr->resultCode;
resp.data = pnlhr->pData ? pnlhr->pData : "";
-
- Netlib_FreeHttpRequest(pnlhr);
}
else {
parent->debugLogA("!!! No response from server (time-out)");
@@ -1114,7 +1112,7 @@ bool facebook_client::save_url(const std::string &url, const std::wstring &filen
req.nlc = nlc;
bool ret = false;
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(handle_, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(handle_, &req));
if (resp) {
nlc = resp->nlc;
parent->debugLogA("@@@ Saving URL %s to file %s", url.c_str(), _T2A(filename.c_str()));
@@ -1132,8 +1130,6 @@ bool facebook_client::save_url(const std::string &url, const std::wstring &filen
ret = _waccess(filename.c_str(), 0) == 0;
}
-
- Netlib_FreeHttpRequest(resp);
}
else nlc = nullptr;
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index 55dce87b48..2a2c40f71d 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -68,7 +68,7 @@ bool GaduProto::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
req.szUrl = szUrl;
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_REDIRECT;
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (resp == nullptr) {
debugLogA("getAvatarFileInfo(): No response from HTTP request");
return false;
@@ -76,7 +76,6 @@ bool GaduProto::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
if (resp->resultCode != 200 || !resp->dataLength || !resp->pData) {
debugLogA("getAvatarFileInfo(): Invalid response code from HTTP request");
- Netlib_FreeHttpRequest(resp);
return false;
}
@@ -116,11 +115,9 @@ bool GaduProto::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
}
else {
debugLogA("getAvatarFileInfo(): Invalid response code from HTTP request, unknown format");
- Netlib_FreeHttpRequest(resp);
return false;
}
- Netlib_FreeHttpRequest(resp);
return true;
}
@@ -245,7 +242,7 @@ void __cdecl GaduProto::avatarrequestthread(void*)
req.szUrl = data->szAvatarURL;
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_REDIRECT;
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
int file_fd;
@@ -272,7 +269,6 @@ void __cdecl GaduProto::avatarrequestthread(void*)
}
}
else debugLogA("avatarrequestthread(): Invalid response code from HTTP request");
- Netlib_FreeHttpRequest(resp);
}
else debugLogA("avatarrequestthread(): No response from HTTP request");
@@ -428,10 +424,10 @@ void __cdecl GaduProto::setavatarthread(void *param)
req.pData = data;
req.dataLength = int(dataLen);
- //send request
+ // send request
int resultSuccess = 0;
int needRepeat = 0;
- NETLIBHTTPREQUEST* resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
debugLogA("setavatarthread(): 1 resp.data= %s", resp->pData);
@@ -443,13 +439,12 @@ void __cdecl GaduProto::setavatarthread(void *param)
needRepeat = 1;
}
}
- Netlib_FreeHttpRequest(resp);
}
else {
debugLogA("setavatarthread(): No response from HTTP request");
}
- //check if we should repeat request
+ // check if we should repeat request
if (needRepeat) {
// Access Token expired - force obtain new
oauth_checktoken(1);
@@ -468,15 +463,13 @@ void __cdecl GaduProto::setavatarthread(void *param)
req.pData = data;
req.dataLength = int(dataLen);
- resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
debugLogA("setavatarthread(): 2 resp.data= %s", resp->pData);
resultSuccess = 1;
}
else debugLogA("setavatarthread(): Invalid response code from HTTP request [%d]", resp->resultCode);
-
- Netlib_FreeHttpRequest(resp);
}
else debugLogA("setavatarthread(): No response from HTTP request");
}
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp
index 805f92bed0..94d51e83f8 100644
--- a/protocols/Gadu-Gadu/src/oauth.cpp
+++ b/protocols/Gadu-Gadu/src/oauth.cpp
@@ -298,7 +298,7 @@ int GaduProto::oauth_receivetoken()
req.headersCount = 3;
req.headers = httpHeaders;
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (resp) {
nlc = resp->nlc;
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
@@ -313,8 +313,6 @@ int GaduProto::oauth_receivetoken()
}
}
else debugLogA("oauth_receivetoken(): Invalid response code from HTTP request");
-
- Netlib_FreeHttpRequest(resp);
}
else debugLogA("oauth_receivetoken(): No response from HTTP request");
@@ -342,9 +340,7 @@ int GaduProto::oauth_receivetoken()
req.dataLength = (int)mir_strlen(str);
resp = Netlib_HttpTransaction(m_hNetlibUser, &req);
- if (resp)
- Netlib_FreeHttpRequest(resp);
- else
+ if (!resp)
debugLogA("oauth_receivetoken(): No response from HTTP request");
// 3. Obtaining an Access Token
@@ -384,7 +380,6 @@ int GaduProto::oauth_receivetoken()
else debugLogA("oauth_receivetoken(): Invalid response code from HTTP request");
Netlib_CloseHandle(resp->nlc);
- Netlib_FreeHttpRequest(resp);
}
else debugLogA("oauth_receivetoken(): No response from HTTP request");
diff --git a/protocols/GmailNotifier/src/check.cpp b/protocols/GmailNotifier/src/check.cpp
index 06a1926ef1..d9386b191b 100644
--- a/protocols/GmailNotifier/src/check.cpp
+++ b/protocols/GmailNotifier/src/check.cpp
@@ -80,18 +80,14 @@ void CheckMailInbox(Account *curAcc)
nlr.dataLength = szBody.GetLength();
nlr.pData = szBody.GetBuffer();
- NETLIBHTTPREQUEST *nlu = Netlib_HttpTransaction(hNetlibUser, &nlr);
+ NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlr));
if (nlu == nullptr || nlu->resultCode != 200) {
mir_strcpy(curAcc->results.content, Translate("Can't send account data!"));
- Netlib_FreeHttpRequest(nlu);
curAcc->results_num = -1;
mir_strcat(curAcc->results.content, "]");
curAcc->IsChecking = false;
- return;
}
-
- Netlib_FreeHttpRequest(nlu);
}
// go!
@@ -115,11 +111,10 @@ void CheckMailInbox(Account *curAcc)
nlr.headers = headers;
nlr.headersCount = _countof(headers);
- NETLIBHTTPREQUEST *nlu = Netlib_HttpTransaction(hNetlibUser, &nlr);
+ NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlr));
if (nlu == nullptr) {
mir_snprintf(curAcc->results.content, "%s [%s]", szNick.get(),
(nlr.resultCode == 401) ? Translate("Wrong name or password!") : Translate("Can't get RSS feed!"));
- Netlib_FreeHttpRequest(nlu);
curAcc->results_num = -1;
curAcc->IsChecking = false;
diff --git a/protocols/ICQ-WIM/src/http.cpp b/protocols/ICQ-WIM/src/http.cpp
index 87819b1849..419342460d 100644
--- a/protocols/ICQ-WIM/src/http.cpp
+++ b/protocols/ICQ-WIM/src/http.cpp
@@ -172,7 +172,7 @@ bool CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
bool bRet;
- NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq);
+ NLHR_PTR reply(Netlib_HttpTransaction(m_hNetlibUser, pReq));
if (reply != nullptr) {
if (pReq->m_conn != CONN_NONE) {
auto &conn = m_ConnPool[pReq->m_conn];
@@ -207,7 +207,6 @@ bool CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq)
if (pReq->m_pFunc != nullptr)
(this->*(pReq->m_pFunc))(reply, pReq);
- Netlib_FreeHttpRequest(reply);
bRet = true;
}
else {
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index d1600d79d2..2bc5723a80 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -417,7 +417,7 @@ bool CIcqProto::RefreshRobustToken()
CMStringA szAgent(FORMAT, "%S Mail.ru Windows ICQ (version 10.0.1999)", (wchar_t*)m_szOwnId);
tmp->AddHeader("User-Agent", szAgent);
- NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, tmp);
+ NLHR_PTR reply(Netlib_HttpTransaction(m_hNetlibUser, tmp));
if (reply != nullptr) {
m_ConnPool[CONN_RAPI].s = reply->nlc;
@@ -434,8 +434,6 @@ bool CIcqProto::RefreshRobustToken()
add->pUserInfo = &bRet;
ExecuteRequest(add);
}
-
- Netlib_FreeHttpRequest(reply);
}
else m_ConnPool[CONN_RAPI].s = nullptr;
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 3ade180008..c8eb921250 100755
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -715,7 +715,7 @@ private:
request.flags = NLHRF_REDIRECT | NLHRF_HTTP11;
request.szUrl = JABBER_SERVER_URL;
- NETLIBHTTPREQUEST *result = Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request);
+ NLHR_PTR result(Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request));
if (result) {
if (result->resultCode == 200 && result->dataLength && result->pData) {
TiXmlDocument doc;
@@ -725,7 +725,6 @@ private:
bIsError = false;
}
}
- Netlib_FreeHttpRequest(result);
}
if (bIsError)
@@ -1600,7 +1599,7 @@ private:
request.flags = NLHRF_HTTP11;
request.szUrl = JABBER_SERVER_URL;
- NETLIBHTTPREQUEST *result = Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request);
+ NLHR_PTR result(Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request));
if (result && IsWindow(hwnd)) {
if ((result->resultCode == 200) && result->dataLength && result->pData) {
TiXmlDocument doc;
@@ -1614,8 +1613,6 @@ private:
}
}
- if (result)
- Netlib_FreeHttpRequest(result);
if (bIsError)
SendMessage(hwnd, WM_JABBER_REFRESH, 0, 0);
}
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 87b69204e7..2631783213 100755
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -893,7 +893,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
nlhr.szUrl = it->Url;
nlhr.nlc = hHttpCon;
- NETLIBHTTPREQUEST *res = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR res(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (res) {
hHttpCon = res->nlc;
if (res->resultCode == 200 && res->dataLength) {
@@ -936,7 +936,6 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
}
}
}
- Netlib_FreeHttpRequest(res);
}
else hHttpCon = nullptr;
}
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp
index 176c42f1f9..c2956d09af 100644
--- a/protocols/MSN/src/msn_auth.cpp
+++ b/protocols/MSN/src/msn_auth.cpp
@@ -287,10 +287,9 @@ bool SkypeToken::Refresh(bool bForce)
nlhr.pData = szPOST.GetBuffer();
m_proto->mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_proto->m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_proto->m_hNetlibUser, &nlhr));
m_proto->mHttpsTS = clock();
- bool bRet = false;
if (nlhrReply) {
m_proto->hHttpsConnection = nlhrReply->nlc;
@@ -303,14 +302,13 @@ bool SkypeToken::Refresh(bool bForce)
if (tExpires == 0)
tExpires = 86400;
SetToken("skype_token " + szToken, time(0) + tExpires);
- bRet = true;
+ return true;
}
}
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else m_proto->hHttpsConnection = nullptr;
- return bRet;
+ return false;
}
const char* SkypeToken::XSkypetoken()
@@ -698,7 +696,7 @@ bool CMsnProto::RefreshOAuth(const char *pszRefreshToken, const char *pszService
// Query
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -728,7 +726,6 @@ bool CMsnProto::RefreshOAuth(const char *pszRefreshToken, const char *pszService
}
}
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
return bRet;
diff --git a/protocols/MSN/src/msn_avatar.cpp b/protocols/MSN/src/msn_avatar.cpp
index 7d148dd5ca..91122e32c5 100644
--- a/protocols/MSN/src/msn_avatar.cpp
+++ b/protocols/MSN/src/msn_avatar.cpp
@@ -61,20 +61,17 @@ bool CMsnProto::loadHttpAvatar(AvatarQueueEntry *p)
nlhr.headers = (NETLIBHTTPHEADER*)&nlbhHeaders;
nlhr.headersCount = 1;
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (nlhrReply == nullptr)
return false;
- if (nlhrReply->resultCode != 200 || nlhrReply->dataLength == 0) {
-LBL_Error:
- Netlib_FreeHttpRequest(nlhrReply);
+ if (nlhrReply->resultCode != 200 || nlhrReply->dataLength == 0)
return false;
- }
const wchar_t *szExt;
int fmt = ProtoGetBufferFormat(nlhrReply->pData, &szExt);
if (fmt == PA_FORMAT_UNKNOWN)
- goto LBL_Error;
+ return false;
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.format = fmt;
@@ -84,13 +81,12 @@ LBL_Error:
int fileId = _wopen(ai.filename, _O_CREAT | _O_TRUNC | _O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE);
if (fileId == -1)
- goto LBL_Error;
+ return false;
_write(fileId, nlhrReply->pData, (unsigned)nlhrReply->dataLength);
_close(fileId);
ProtoBroadcastAck(p->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai);
- Netlib_FreeHttpRequest(nlhrReply);
return true;
}
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index 0a4fa74562..e4e3beca97 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -392,7 +392,7 @@ void CMsnProto::MSN_ProcessURIObject(MCONTACT hContact, ezxml_t xmli)
nlbhHeaders[0].szName = "User-Agent"; nlbhHeaders[0].szValue = (LPSTR)MSN_USER_AGENT;
nlbhHeaders[1].szName = "Authorization"; nlbhHeaders[1].szValue = (char*)pszSkypeToken;
- NETLIBHTTPREQUEST nlhr = { 0 }, *nlhrReply;
+ NETLIBHTTPREQUEST nlhr = {};
nlhr.cbSize = sizeof(nlhr);
nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_PERSISTENT;
@@ -402,7 +402,7 @@ void CMsnProto::MSN_ProcessURIObject(MCONTACT hContact, ezxml_t xmli)
nlhr.nlc = hHttpsConnection;
mHttpsTS = clock();
- nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -416,8 +416,6 @@ void CMsnProto::MSN_ProcessURIObject(MCONTACT hContact, ezxml_t xmli)
fileSize = _atoi64(pLength);
}
}
-
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index e26d2828f0..24bd25f121 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -796,22 +796,14 @@ int CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
}
else {
- // MSNP24 doesn't have a switchboard anymore
- bool isOffline = true;
- ThreadData *thread = nullptr;
-
- if (thread == nullptr) {
- if (isOffline) {
- if (netId != NETID_LCS) {
- seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag | MSG_OFFLINE);
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, nullptr, this));
- }
- else {
- seq = 999993;
- errMsg = Translate("Offline messaging is not allowed for LCS contacts");
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
- }
- }
+ if (netId != NETID_LCS) {
+ seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag | MSG_OFFLINE);
+ ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, nullptr, this));
+ }
+ else {
+ seq = 999993;
+ errMsg = Translate("Offline messaging is not allowed for LCS contacts");
+ ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
}
}
break;
diff --git a/protocols/MSN/src/msn_skypeab.cpp b/protocols/MSN/src/msn_skypeab.cpp
index c759604fba..eb5fa20886 100644
--- a/protocols/MSN/src/msn_skypeab.cpp
+++ b/protocols/MSN/src/msn_skypeab.cpp
@@ -68,7 +68,7 @@ bool CMsnProto::MSN_SKYABRefreshClist(void)
// Query addressbook
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -107,9 +107,7 @@ bool CMsnProto::MSN_SKYABRefreshClist(void)
}
}
bRet = true;
- //MSN_SKYABGetProfiles((const char*)post);
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
return bRet;
@@ -130,7 +128,7 @@ bool CMsnProto::MSN_SKYABGetProfiles(const char *pszPOST)
nlhr.pData = (char*)pszPOST;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -163,7 +161,6 @@ bool CMsnProto::MSN_SKYABGetProfiles(const char *pszPOST)
json_delete(items);
bRet = true;
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
return bRet;
@@ -183,7 +180,7 @@ bool CMsnProto::MSN_SKYABGetProfile(const char *wlid)
nlhr.szUrl = szURL;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -235,7 +232,6 @@ bool CMsnProto::MSN_SKYABGetProfile(const char *wlid)
}
bRet = true;
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
return bRet;
@@ -246,13 +242,14 @@ bool CMsnProto::MSN_SKYABBlockContact(const char *wlid, const char *pszAction)
{
NETLIBHTTPREQUEST nlhr = { 0 };
NETLIBHTTPHEADER headers[4];
- bool bRet = false;
+ // initialize the netlib request
+ if (!APISkypeComRequest(&nlhr, headers))
+ return false;
+
char szURL[256], szPOST[128];
+ mir_snprintf(szURL, sizeof(szURL), "https://api.skype.com/users/self/contacts/%s/%s", wlid, pszAction);
- // initialize the netlib request
- if (!APISkypeComRequest(&nlhr, headers)) return false;
nlhr.requestType = REQUEST_PUT;
- mir_snprintf(szURL, sizeof(szURL), "https://api.skype.com/users/self/contacts/%s/%s", wlid, pszAction);
nlhr.szUrl = szURL;
nlhr.headers[3].szName = "Content-type";
nlhr.headers[3].szValue = "application/x-www-form-urlencoded";
@@ -261,69 +258,68 @@ bool CMsnProto::MSN_SKYABBlockContact(const char *wlid, const char *pszAction)
nlhr.pData = szPOST;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
- if (nlhrReply) {
- hHttpsConnection = nlhrReply->nlc;
- Netlib_FreeHttpRequest(nlhrReply);
- bRet = true;
+ if (!nlhrReply) {
+ hHttpsConnection = nullptr;
+ return false;
}
- else hHttpsConnection = nullptr;
- return bRet;
+
+ hHttpsConnection = nlhrReply->nlc;
+ return true;
}
bool CMsnProto::MSN_SKYABDeleteContact(const char *wlid)
{
+ // initialize the netlib request
NETLIBHTTPREQUEST nlhr = { 0 };
NETLIBHTTPHEADER headers[4];
- bool bRet = false;
- char szURL[256];
+ if (!APISkypeComRequest(&nlhr, headers))
+ return false;
- // initialize the netlib request
- if (!APISkypeComRequest(&nlhr, headers)) return false;
- nlhr.requestType = REQUEST_DELETE;
+ char szURL[256];
mir_snprintf(szURL, sizeof(szURL), "https://contacts.skype.com/contacts/v2/users/SELF/contacts/%s", wlid);
+ nlhr.requestType = REQUEST_DELETE;
nlhr.szUrl = szURL;
nlhr.headers[3].szName = "Content-type";
nlhr.headers[3].szValue = "application/x-www-form-urlencoded";
nlhr.headersCount++;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
- if (nlhrReply) {
- hHttpsConnection = nlhrReply->nlc;
- Netlib_FreeHttpRequest(nlhrReply);
- bRet = true;
+ if (!nlhrReply) {
+ hHttpsConnection = nullptr;
+ return false;
}
- else hHttpsConnection = nullptr;
- return bRet;
+
+ hHttpsConnection = nlhrReply->nlc;
+ return true;
}
// pszAction: "accept" or "decline"
bool CMsnProto::MSN_SKYABAuthRsp(const char *wlid, const char *pszAction)
{
+ // initialize the netlib request
NETLIBHTTPREQUEST nlhr = { 0 };
NETLIBHTTPHEADER headers[3];
- bool bRet = false;
- char szURL[256];
+ if (!APISkypeComRequest(&nlhr, headers))
+ return false;
- // initialize the netlib request
- if (!APISkypeComRequest(&nlhr, headers)) return false;
+ char szURL[256];
+ mir_snprintf(szURL, sizeof(szURL), "https://contacts.skype.com/contacts/v2/users/SELF/invites/%s/%s", wlid, pszAction);
nlhr.requestType = REQUEST_PUT;
- mir_snprintf(szURL, sizeof(szURL), "https://contacts.skype.com/contacts/v2/users/SELF/invites/%s/%s", wlid, pszAction);
nlhr.szUrl = szURL;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
- if (nlhrReply) {
- hHttpsConnection = nlhrReply->nlc;
- Netlib_FreeHttpRequest(nlhrReply);
- bRet = true;
+ if (!nlhrReply) {
+ hHttpsConnection = nullptr;
+ return false;
}
- else hHttpsConnection = nullptr;
- return bRet;
+ hHttpsConnection = nlhrReply->nlc;
+ return true;
}
bool CMsnProto::MSN_SKYABAuthRq(const char *wlid, const char *pszGreeting)
@@ -349,11 +345,10 @@ bool CMsnProto::MSN_SKYABAuthRq(const char *wlid, const char *pszGreeting)
nlhr.pData = (char*)(const char*)post;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
- Netlib_FreeHttpRequest(nlhrReply);
return true;
}
@@ -383,7 +378,7 @@ bool CMsnProto::MSN_SKYABSearch(const char *keyWord, HANDLE hSearch)
nlhr.headersCount++;
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -413,7 +408,6 @@ bool CMsnProto::MSN_SKYABSearch(const char *keyWord, HANDLE hSearch)
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, hSearch);
bRet = true;
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
return bRet;
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp
index d9f4194f81..6a98c797de 100644
--- a/protocols/MSN/src/msn_soapab.cpp
+++ b/protocols/MSN/src/msn_soapab.cpp
@@ -862,7 +862,7 @@ bool CMsnProto::MSN_ABRefreshClist(unsigned int nTry)
// Query addressbook
mHttpsTS = clock();
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mHttpsTS = clock();
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
@@ -947,7 +947,6 @@ bool CMsnProto::MSN_ABRefreshClist(unsigned int nTry)
authSkypeComToken.Clear();
if (MSN_AuthOAuth() > 0) return MSN_ABRefreshClist(1);
}
- Netlib_FreeHttpRequest(nlhrReply);
}
else hHttpsConnection = nullptr;
return bRet;
diff --git a/protocols/MSN/src/msn_ssl.cpp b/protocols/MSN/src/msn_ssl.cpp
index dbd9d2f7db..bdf32d5647 100644
--- a/protocols/MSN/src/msn_ssl.cpp
+++ b/protocols/MSN/src/msn_ssl.cpp
@@ -76,8 +76,7 @@ char* CMsnProto::getSslResult(char** parUrl, const char* parAuthInfo, const char
}
// download the page
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
-
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (nlhrReply) {
hHttpsConnection = nlhrReply->nlc;
status = nlhrReply->resultCode;
@@ -92,11 +91,8 @@ char* CMsnProto::getSslResult(char** parUrl, const char* parAuthInfo, const char
nlhrReply->dataLength = 0;
nlhrReply->pData = nullptr;
-
- Netlib_FreeHttpRequest(nlhrReply);
}
- else
- hHttpsConnection = nullptr;
+ else hHttpsConnection = nullptr;
mHttpsTS = clock();
@@ -105,29 +101,24 @@ char* CMsnProto::getSslResult(char** parUrl, const char* parAuthInfo, const char
bool CMsnProto::getMyAvatarFile(char *url, wchar_t *fname)
{
- NETLIBHTTPREQUEST nlhr = { 0 };
- bool result = true;
-
// initialize the netlib request
+ NETLIBHTTPREQUEST nlhr = {};
nlhr.cbSize = sizeof(nlhr);
nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
nlhr.szUrl = url;
-
nlhr.headersCount = 1;
nlhr.headers = (NETLIBHTTPHEADER*)alloca(sizeof(NETLIBHTTPHEADER) * nlhr.headersCount);
nlhr.headers[0].szName = "User-Agent";
nlhr.headers[0].szValue = (char*)MSN_USER_AGENT;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (nlhrReply) {
- if (nlhrReply->resultCode == 200 && nlhrReply->dataLength)
+ if (nlhrReply->resultCode == 200 && nlhrReply->dataLength) {
MSN_SetMyAvatar(fname, nlhrReply->pData, nlhrReply->dataLength);
- else
- result = false;
-
- Netlib_FreeHttpRequest(nlhrReply);
+ return true;
+ }
}
- return result;
+ return false;
}
diff --git a/protocols/MinecraftDynmap/src/communication.cpp b/protocols/MinecraftDynmap/src/communication.cpp
index b8131f51bf..0366b5e9cb 100644
--- a/protocols/MinecraftDynmap/src/communication.cpp
+++ b/protocols/MinecraftDynmap/src/communication.cpp
@@ -81,13 +81,12 @@ http::response MinecraftDynmapProto::sendRequest(const int request_type, std::st
debugLogA("@@@@@ Sending request to '%s'", nlhr.szUrl);
// Send the request
- NETLIBHTTPREQUEST *pnlhr = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR pnlhr(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
mir_free(nlhr.headers);
// Remember the persistent connection handle (or not)
- switch (request_type)
- {
+ switch (request_type) {
case MINECRAFTDYNMAP_REQUEST_HOME:
break;
@@ -110,8 +109,6 @@ http::response MinecraftDynmapProto::sendRequest(const int request_type, std::st
resp.data = pnlhr->pData ? pnlhr->pData : "";
// debugLogA("&&&&& Got response: %s", resp.data.c_str());
-
- Netlib_FreeHttpRequest(pnlhr);
} else {
debugLogA("!!!!! No response from server (time-out)");
resp.code = HTTP_CODE_FAKE_DISCONNECTED;
diff --git a/protocols/NewsAggregator/Src/Utils.cpp b/protocols/NewsAggregator/Src/Utils.cpp
index 80248ba48f..29c2017b66 100644
--- a/protocols/NewsAggregator/Src/Utils.cpp
+++ b/protocols/NewsAggregator/Src/Utils.cpp
@@ -81,7 +81,7 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, CFeedEditor
}
// download the page
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
if (nlhrReply) {
// if the recieved code is 200 OK
if (nlhrReply->resultCode == 200 && nlhrReply->dataLength > 0) {
@@ -98,8 +98,6 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, CFeedEditor
GetNewsData(tszUrl, szData, hContact, pEditDlg);
}
else Netlib_LogfW(hNetlibUser, L"Code %d: Failed getting feed data %s.", nlhrReply->resultCode, tszUrl);
-
- Netlib_FreeHttpRequest(nlhrReply);
}
else Netlib_LogfW(hNetlibUser, L"Failed getting feed data %s, no response.", tszUrl);
@@ -242,7 +240,7 @@ bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
nlhr.headers[3].szValue = "no-cache";
bool ret = false;
- NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
+ NLHR_PTR pReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
if (pReply) {
if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
char *date = nullptr, *size = nullptr;
@@ -294,7 +292,6 @@ bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
CloseHandle(hFile);
}
}
- Netlib_FreeHttpRequest(pReply);
}
mir_free(szUrl);
diff --git a/protocols/Non-IM Contact/src/http.cpp b/protocols/Non-IM Contact/src/http.cpp
index a7eaca69cb..55e648c248 100644
--- a/protocols/Non-IM Contact/src/http.cpp
+++ b/protocols/Non-IM Contact/src/http.cpp
@@ -48,7 +48,7 @@ int InternetDownloadFile(char *szUrl)
nlhr.headers[nlhr.headersCount - 1].szValue = NETLIB_USER_AGENT;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
if (nlhrReply) {
// return error code if the recieved code is neither 200 OK or 302 Moved
if (nlhrReply->resultCode != 200 && nlhrReply->resultCode != 302)
@@ -81,7 +81,6 @@ int InternetDownloadFile(char *szUrl)
// make a copy of the retrieved data, then free the memory of the http reply
szInfo = szData;
- Netlib_FreeHttpRequest(nlhrReply);
// the recieved data is empty, data was not recieved, so return an error code of 1
if (!mir_strcmp(szInfo, "")) return 1;
diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp
index a7b6c7960b..66f1205f12 100644
--- a/protocols/Omegle/src/communication.cpp
+++ b/protocols/Omegle/src/communication.cpp
@@ -79,7 +79,7 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
parent->debugLogA("@@@@@ Sending request to '%s'", nlhr.szUrl);
// Send the request
- NETLIBHTTPREQUEST *pnlhr = Netlib_HttpTransaction(handle_, &nlhr);
+ NLHR_PTR pnlhr(Netlib_HttpTransaction(handle_, &nlhr));
mir_free(nlhr.headers);
@@ -113,8 +113,6 @@ http::response Omegle_client::flap(const int request_type, std::string *post_dat
}
parent->debugLogA("&&&&& Got response: %s", resp.data.c_str());
-
- Netlib_FreeHttpRequest(pnlhr);
}
else {
parent->debugLogA("!!!!! No response from server (time-out)");
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index 83945ae5fa..e17b2ba9a6 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -75,10 +75,9 @@ void RequestQueue::Send(HttpRequest *request, HttpResponseCallback response, voi
void RequestQueue::Execute(RequestQueueItem *item)
{
- NETLIBHTTPREQUEST *response = item->request->Send(nlu);
+ NLHR_PTR response(item->request->Send(nlu));
if (item->responseCallback != nullptr)
item->responseCallback(response, item->arg);
- Netlib_FreeHttpRequest(response);
requests.remove(item);
delete item;
}
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp
index 134ef2b1f9..3001173ee1 100644
--- a/protocols/Twitter/src/utility.cpp
+++ b/protocols/Twitter/src/utility.cpp
@@ -110,16 +110,12 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu
req.flags = NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
req.nlc = httpPOST_;
http::response resp_data;
- ppro_->debugLogA("**SLURP - just before calling HTTPTRANSACTION");
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(handle_, &req);
- ppro_->debugLogA("**SLURP - HTTPTRANSACTION complete.");
+ NLHR_PTR resp(Netlib_HttpTransaction(handle_, &req));
if (resp) {
ppro_->debugLogA("**SLURP - the server has responded!");
httpPOST_ = resp->nlc;
resp_data.code = resp->resultCode;
resp_data.data = resp->pData ? resp->pData : "";
-
- Netlib_FreeHttpRequest(resp);
}
else {
httpPOST_ = nullptr;
@@ -136,7 +132,7 @@ bool save_url(HNETLIBUSER hNetlib, const std::string &url, const std::wstring &f
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
req.szUrl = const_cast<char*>(url.c_str());
- NETLIBHTTPREQUEST *resp = Netlib_HttpTransaction(hNetlib, &req);
+ NLHR_PTR resp(Netlib_HttpTransaction(hNetlib, &req));
if (resp) {
bool success = (resp->resultCode == 200);
if (success) {
@@ -150,8 +146,6 @@ bool save_url(HNETLIBUSER hNetlib, const std::string &url, const std::wstring &f
fwrite(resp->pData, 1, resp->dataLength, f);
fclose(f);
}
-
- Netlib_FreeHttpRequest(resp);
return success;
}
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index 80a6b91f8b..09c5a59878 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -249,7 +249,7 @@ int CVkProto::PollServer()
debugLogA("CVkProto::PollServer (online)");
int iPollConnRetry = MAX_RETRIES;
- NETLIBHTTPREQUEST *reply;
+
CMStringA szReqUrl(FORMAT, "https://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d&version=%d", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken, 106, 2);
// see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
NETLIBHTTPREQUEST req = {};
@@ -265,6 +265,7 @@ int CVkProto::PollServer()
tLocalPoolThreadTimer = m_tPoolThreadTimer = time(0);
}
+ NLHR_PTR reply(0);
while ((reply = Netlib_HttpTransaction(m_hNetlibUser, &req)) == nullptr) {
{
mir_cslock lck(m_csPoolThreadTimer);
@@ -310,14 +311,12 @@ int CVkProto::PollServer()
|| (reply->resultCode >= 500 && reply->resultCode <= 509)) {
debugLogA("CVkProto::PollServer is dead. Error code - %d", reply->resultCode);
ClosePollingConnection();
- Netlib_FreeHttpRequest(reply);
ShutdownSession();
return 0;
}
m_pollingConn = reply->nlc;
- Netlib_FreeHttpRequest(reply);
debugLogA("CVkProto::PollServer return %d", retVal);
return retVal;
}
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 5cbf3a5d08..8a874fb469 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -64,8 +64,7 @@ bool CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
debugLogA("CVkProto::ExecuteRequest \n====\n%s\n====\n", pReq->szUrl);
- NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq);
-
+ NLHR_PTR reply(Netlib_HttpTransaction(m_hNetlibUser, pReq));
{
mir_cslock lck(m_csWorkThreadTimer);
if (tLocalWorkThreadTimer != m_tWorkThreadTimer) {
@@ -81,8 +80,6 @@ bool CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
if (pReq->m_bApiReq)
m_hAPIConnection = reply->nlc;
-
- Netlib_FreeHttpRequest(reply);
}
else if (pReq->bIsMainConn) {
if (IsStatusConnecting(m_iStatus))
diff --git a/protocols/Weather/src/weather_http.cpp b/protocols/Weather/src/weather_http.cpp
index 319663bfe7..b0672282c1 100644
--- a/protocols/Weather/src/weather_http.cpp
+++ b/protocols/Weather/src/weather_http.cpp
@@ -73,7 +73,7 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
--nlhr.headersCount;
// download the page
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
if (nlhrReply == nullptr) {
// if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
*szData = (wchar_t*)mir_alloc(512);
@@ -140,7 +140,6 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
}
// make a copy of the retrieved data, then free the memory of the http reply
- Netlib_FreeHttpRequest(nlhrReply);
return result;
}
diff --git a/protocols/WebView/src/webview_getdata.cpp b/protocols/WebView/src/webview_getdata.cpp
index 155f1be6c9..ab21c3f3ce 100644
--- a/protocols/WebView/src/webview_getdata.cpp
+++ b/protocols/WebView/src/webview_getdata.cpp
@@ -134,7 +134,7 @@ void GetData(void *param)
db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Updating..."));
g_plugin.setWord(hContact, "Status", ID_STATUS_DND); // download
- NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
+ NLHR_PTR nlhrReply(Netlib_HttpTransaction(hNetlibUser, &nlhr));
if (nlhrReply) {
if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) {
g_plugin.setWord(hContact, "Status", ID_STATUS_AWAY);
@@ -169,8 +169,6 @@ void GetData(void *param)
else if (nlhrReply)
DownloadSuccess = 1;
- Netlib_FreeHttpRequest(nlhrReply);
-
if (DownloadSuccess)
SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));