summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_netlib.h43
-rw-r--r--protocols/Facebook/src/avatars.cpp4
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp5
-rw-r--r--protocols/WhatsApp/src/avatars.cpp3
-rw-r--r--src/mir_app/src/chat_svc.cpp2
-rw-r--r--src/mir_app/src/mir_app.def5
-rw-r--r--src/mir_app/src/mir_app64.def5
-rw-r--r--src/mir_app/src/netlib.cpp10
-rw-r--r--src/mir_app/src/netlib.h6
-rw-r--r--src/mir_app/src/netlib_http.cpp38
-rw-r--r--src/mir_app/src/netlib_httpproxy.cpp12
11 files changed, 41 insertions, 92 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h
index c667d760fb..149b025f8e 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -357,11 +357,6 @@ EXTERN_C MIR_APP_DLL(UINT_PTR) Netlib_GetSocket(HNETLIBCONN hConnection);
#define Netlib_GetBase64EncodedBufferSize(cbDecoded) (((cbDecoded)*4+11)/12*4+1)
/////////////////////////////////////////////////////////////////////////////////////////
-// Gets HNETLIBUSER owner of a connection
-
-EXTERN_C MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HNETLIBCONN hConn);
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Gets the fake User-Agent header field to make some sites happy
EXTERN_C MIR_APP_DLL(char*) Netlib_GetUserAgent();
@@ -406,15 +401,6 @@ struct NETLIBIPLIST
EXTERN_C MIR_APP_DLL(NETLIBIPLIST*) Netlib_GetMyIp(bool bGlobalOnly);
/////////////////////////////////////////////////////////////////////////////////////////
-// Send an HTTP request over a connection
-//
-// Returns number of bytes sent on success, SOCKET_ERROR on failure
-// hConnection must have been returned by MS_NETLIB_OPENCONNECTION
-// Note that if you use NLHRF_SMARTAUTHHEADER and NTLM authentication is in use
-// then the full NTLM authentication transaction occurs, comprising sending the
-// domain, receiving the challenge, then sending the response.
-// nlhr.resultCode and nlhr.szResultDescr are ignored by this function.
-// Errors: ERROR_INVALID_PARAMETER, anything returned by MS_NETLIB_SEND
struct NETLIBHTTPHEADER
{
@@ -467,27 +453,6 @@ struct NETLIBHTTPREQUEST
}
};
-EXTERN_C MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN hConnection, NETLIBHTTPREQUEST *pRec);
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Receives HTTP headers
-//
-// Returns a pointer to a NETLIBHTTPREQUEST structure on success, NULL on failure.
-// Call Netlib_FreeHttpRequest() to free this.
-// hConnection must have been returned by MS_NETLIB_OPENCONNECTION
-// nlhr->pData = NULL and nlhr->dataLength = 0 always. The requested data should
-// be retrieved using MS_NETLIB_RECV once the header has been parsed.
-// If the headers haven't finished within 60 seconds the function returns NULL
-// and ERROR_TIMEOUT.
-// Errors: ERROR_INVALID_PARAMETER, any from MS_NETLIB_RECV or select()
-// ERROR_HANDLE_EOF (connection closed before headers complete)
-// ERROR_TIMEOUT (headers still not complete after 60 seconds)
-// ERROR_BAD_FORMAT (invalid character or line ending in headers, or first line is blank)
-// ERROR_BUFFER_OVERFLOW (each header line must be less than 4096 chars long)
-// ERROR_INVALID_DATA (first header line is malformed ("http/[01].[0-9] [0-9]+ .*", or no colon in subsequent line)
-
-EXTERN_C MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, int flags = 0);
-
/////////////////////////////////////////////////////////////////////////////////////////
// Free the memory used by a NETLIBHTTPREQUEST structure
//
@@ -716,14 +681,6 @@ struct NETLIBPACKETRECVER
EXTERN_C MIR_APP_DLL(int) Netlib_GetMorePackets(HANDLE hReceiver, NETLIBPACKETRECVER *nlprParam);
/////////////////////////////////////////////////////////////////////////////////////////
-// Sets a gateway polling timeout interval
-//
-// Returns previous timeout value
-// Errors: -1
-
-EXTERN_C MIR_APP_DLL(int) Netlib_SetPollingTimeout(HNETLIBCONN hConnection, int iTimeout);
-
-/////////////////////////////////////////////////////////////////////////////////////////
// netlib log funcitons
EXTERN_C MIR_APP_DLL(int) Netlib_Log(HNETLIBUSER hUser, const char *pszStr);
diff --git a/protocols/Facebook/src/avatars.cpp b/protocols/Facebook/src/avatars.cpp
index 3f514fca9a..6759d20468 100644
--- a/protocols/Facebook/src/avatars.cpp
+++ b/protocols/Facebook/src/avatars.cpp
@@ -52,7 +52,7 @@ void __cdecl FacebookProto::AvatarsUpdate(void *)
CMStringA szUrl(FORMAT, "https://graph.facebook.com/%s/picture?%s", getMStringA(cc, DBKEY_ID).c_str(), szParams.c_str());
req.szUrl = szUrl.GetBuffer();
- NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ NLHR_PTR pReply(Netlib_HttpTransaction(m_hNetlibUser, &req));
if (pReply == nullptr) {
debugLogA("Failed to retrieve avatar from url: %s", szUrl.c_str());
continue;
@@ -82,8 +82,6 @@ void __cdecl FacebookProto::AvatarsUpdate(void *)
else debugLogA("Error %d reading avatar from url: %s", pReply->resultCode, szUrl.c_str());
ProtoBroadcastAck(cc, ACKTYPE_AVATAR, bSuccess ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, &ai);
-
- Netlib_FreeHttpRequest(pReply);
}
}
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index e0ede298da..9ca292ca71 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -756,7 +756,7 @@ LBL_Fail:
}
_close(fileId);
- NETLIBHTTPREQUEST *res = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
+ NLHR_PTR res(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (res == nullptr) {
debugLogA("error uploading file %S", pwszFileName);
goto LBL_Fail;
@@ -769,12 +769,9 @@ LBL_Fail:
default:
debugLogA("error uploading file %S: error %d", pwszFileName, res->resultCode);
- Netlib_FreeHttpRequest(res);
goto LBL_Fail;
}
- Netlib_FreeHttpRequest(res);
-
// this parameter is optional, if not specified we simply use upload URL
CMStringA szMessage;
if (auto *szGetUrl = version ? XmlGetChildText(slotNode, "get") : XmlGetAttr(XmlFirstChild(slotNode, "get"), "url"))
diff --git a/protocols/WhatsApp/src/avatars.cpp b/protocols/WhatsApp/src/avatars.cpp
index 39e521eff3..9bb7e926aa 100644
--- a/protocols/WhatsApp/src/avatars.cpp
+++ b/protocols/WhatsApp/src/avatars.cpp
@@ -136,7 +136,7 @@ bool CMPlugin::SaveFile(const char *pszUrl, PROTO_AVATAR_INFORMATION &ai)
req.szUrl = (char*)pszUrl;
req.nlc = hAvatarConn;
- NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(hAvatarUser, &req);
+ NLHR_PTR pReply(Netlib_HttpTransaction(hAvatarUser, &req));
if (pReply == nullptr) {
hAvatarConn = nullptr;
debugLogA("Failed to retrieve avatar from url: %s", pszUrl);
@@ -163,6 +163,5 @@ bool CMPlugin::SaveFile(const char *pszUrl, PROTO_AVATAR_INFORMATION &ai)
}
else debugLogA("Error %d reading avatar from url: %s", pReply->resultCode, pszUrl);
- Netlib_FreeHttpRequest(pReply);
return bSuccess;
}
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index aacc6d7eb3..c5ec1731c2 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -874,7 +874,7 @@ static int OnEventDeleted(WPARAM hContact, LPARAM hDbEvent)
if (Contact::IsGroupChat(hContact))
if (auto *si = SM_FindSessionByContact(hContact))
for (auto &it : si->arEvents.rev_iter())
- if (it->hEvent == hDbEvent) {
+ if (it->hEvent == MEVENT(hDbEvent)) {
si->arEvents.removeItem(&it);
break;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 4152581314..68914f96b2 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -260,10 +260,7 @@ Netlib_Log @353
Netlib_LogW @354
Netlib_Logf @355
Netlib_LogfW @356
-Netlib_GetConnNlu @357
-Netlib_RecvHttpHeaders @358
Netlib_HttpTransaction @359
-Netlib_SendHttpRequest @360
Netlib_GetUserSettings @361
Netlib_SetUserSettings @362
Netlib_OpenConnection @363
@@ -276,9 +273,7 @@ Netlib_AddressToString @369
Netlib_StringToAddress @370
Netlib_Select @371
Netlib_SelectEx @372
-Netlib_SendHttpRequest @373
Netlib_SetStickyHeaders @374
-Netlib_SetPollingTimeout @375
Netlib_GetSocket @376
Netlib_StartSsl @377
Netlib_GetConnectionInfo @378
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 1adcdd89e3..b3aa1095b9 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -260,10 +260,7 @@ Netlib_Log @353
Netlib_LogW @354
Netlib_Logf @355
Netlib_LogfW @356
-Netlib_GetConnNlu @357
-Netlib_RecvHttpHeaders @358
Netlib_HttpTransaction @359
-Netlib_SendHttpRequest @360
Netlib_GetUserSettings @361
Netlib_SetUserSettings @362
Netlib_OpenConnection @363
@@ -276,9 +273,7 @@ Netlib_AddressToString @369
Netlib_StringToAddress @370
Netlib_Select @371
Netlib_SelectEx @372
-Netlib_SendHttpRequest @373
Netlib_SetStickyHeaders @374
-Netlib_SetPollingTimeout @375
Netlib_GetSocket @376
Netlib_StartSsl @377
Netlib_GetConnectionInfo @378
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index 89da9164bf..e12184255c 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -378,16 +378,6 @@ MIR_APP_DLL(UINT_PTR) Netlib_GetSocket(HNETLIBCONN hConnection)
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HANDLE hConn)
-{
- if (GetNetlibHandleType(hConn) != NLH_CONNECTION)
- return nullptr;
-
- return ((NetlibConnection*)hConn)->nlu;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
MIR_APP_DLL(char*) Netlib_GetUserAgent()
{
return szUserAgent;
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h
index 09480637bf..d5ddb6687b 100644
--- a/src/mir_app/src/netlib.h
+++ b/src/mir_app/src/netlib.h
@@ -105,7 +105,6 @@ struct NetlibConnection : public MZeroedObject
uint16_t wProxyPort;
CMStringA szProxyBuf;
- int pollingTimeout;
unsigned lastPost;
};
@@ -165,7 +164,10 @@ bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn);
// netlibhttp.cpp
void NetlibHttpSetLastErrorUsingHttpResult(int result);
-NETLIBHTTPREQUEST* NetlibHttpRecv(NetlibConnection* nlc, uint32_t hflags, uint32_t dflags, bool isConnect = false);
+int Netlib_SendHttpRequest(HNETLIBCONN hConnection, NETLIBHTTPREQUEST *pRec);
+
+NETLIBHTTPREQUEST* Netlib_RecvHttpHeaders(NetlibConnection *hConnection, int flags = 0);
+NETLIBHTTPREQUEST* NetlibHttpRecv(NetlibConnection *nlc, uint32_t hflags, uint32_t dflags, bool isConnect = false);
// netliblog.cpp
void NetlibLogShowOptions(void);
diff --git a/src/mir_app/src/netlib_http.cpp b/src/mir_app/src/netlib_http.cpp
index 2317329e04..6845435d34 100644
--- a/src/mir_app/src/netlib_http.cpp
+++ b/src/mir_app/src/netlib_http.cpp
@@ -368,7 +368,18 @@ static int SendHttpRequestAndData(NetlibConnection *nlc, CMStringA &httpRequest,
return bytesSent;
}
-MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Sends a HTTP request over a connection
+//
+// Returns number of bytes sent on success, SOCKET_ERROR on failure
+// hConnection must have been returned by MS_NETLIB_OPENCONNECTION
+// Note that if you use NLHRF_SMARTAUTHHEADER and NTLM authentication is in use
+// then the full NTLM authentication transaction occurs, comprising sending the
+// domain, receiving the challenge, then sending the response.
+// nlhr.resultCode and nlhr.szResultDescr are ignored by this function.
+// Errors: ERROR_INVALID_PARAMETER, anything returned by MS_NETLIB_SEND
+
+int Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr)
{
NETLIBHTTPREQUEST *nlhrReply = nullptr;
HttpSecurityContext httpSecurity;
@@ -544,13 +555,13 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr
(nlhr->flags & NLHRF_NOPROXY ? MSG_RAW : 0) | MSG_NODUMP;
if (resultCode == 100)
- nlhrReply = (NETLIBHTTPREQUEST*)Netlib_RecvHttpHeaders(nlc, hflags);
+ nlhrReply = Netlib_RecvHttpHeaders(nlc, hflags);
else if (resultCode == 307 || ((resultCode == 301 || resultCode == 302) && (nlhr->flags & NLHRF_REDIRECT))) { // redirect
pszUrl = nullptr;
if (nlhr->requestType == REQUEST_HEAD)
- nlhrReply = (NETLIBHTTPREQUEST*)Netlib_RecvHttpHeaders(nlc, hflags);
+ nlhrReply = Netlib_RecvHttpHeaders(nlc, hflags);
else
nlhrReply = NetlibHttpRecv(nlc, hflags, dflags);
@@ -592,7 +603,7 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr
}
else if (resultCode == 401 && !doneAuthHeader) { //auth required
if (nlhr->requestType == REQUEST_HEAD)
- nlhrReply = (NETLIBHTTPREQUEST*)Netlib_RecvHttpHeaders(nlc, hflags);
+ nlhrReply = Netlib_RecvHttpHeaders(nlc, hflags);
else
nlhrReply = NetlibHttpRecv(nlc, hflags, dflags);
@@ -710,9 +721,26 @@ MIR_APP_DLL(bool) Netlib_FreeHttpRequest(NETLIBHTTPREQUEST *nlhr)
return true;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Receives HTTP headers
+//
+// Returns a pointer to a NETLIBHTTPREQUEST structure on success, NULL on failure.
+// Call Netlib_FreeHttpRequest() to free this.
+// hConnection must have been returned by MS_NETLIB_OPENCONNECTION
+// nlhr->pData = NULL and nlhr->dataLength = 0 always. The requested data should
+// be retrieved using MS_NETLIB_RECV once the header has been parsed.
+// If the headers haven't finished within 60 seconds the function returns NULL
+// and ERROR_TIMEOUT.
+// Errors: ERROR_INVALID_PARAMETER, any from MS_NETLIB_RECV or select()
+// ERROR_HANDLE_EOF (connection closed before headers complete)
+// ERROR_TIMEOUT (headers still not complete after 60 seconds)
+// ERROR_BAD_FORMAT (invalid character or line ending in headers, or first line is blank)
+// ERROR_BUFFER_OVERFLOW (each header line must be less than 4096 chars long)
+// ERROR_INVALID_DATA (first header line is malformed ("http/[01].[0-9] [0-9]+ .*", or no colon in subsequent line)
+
#define NHRV_BUF_SIZE 8192
-MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, int flags)
+NETLIBHTTPREQUEST* Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, int flags)
{
NetlibConnection *nlc = (NetlibConnection*)hConnection;
if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
diff --git a/src/mir_app/src/netlib_httpproxy.cpp b/src/mir_app/src/netlib_httpproxy.cpp
index 66adc7fe9a..4c51f2b417 100644
--- a/src/mir_app/src/netlib_httpproxy.cpp
+++ b/src/mir_app/src/netlib_httpproxy.cpp
@@ -71,15 +71,3 @@ MIR_APP_DLL(int) Netlib_SetStickyHeaders(HNETLIBUSER nlu, const char *szHeaders)
replaceStr(nlu->szStickyHeaders, szHeaders); // pointer is ours
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-MIR_APP_DLL(int) Netlib_SetPollingTimeout(HNETLIBCONN nlc, int iTimeout)
-{
- if (GetNetlibHandleType(nlc) != NLH_CONNECTION)
- return -1;
-
- int oldTimeout = nlc->pollingTimeout;
- nlc->pollingTimeout = iTimeout;
- return oldTimeout;
-}