summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-12 13:57:38 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-12 13:57:38 +0300
commitffbdd25f9aec76d7da5507810cd793193725ecfa (patch)
tree2b2da6ee7838a6ecf05074a62f8e5a4a40e5db9d /src
parentd958e3fb847813075cc059bd5a7aa28252982268 (diff)
- Netlib_GetConnNlu - returns a pointer to NetlibUser associated with a connection
- NetlibDoClose renamed to NetlibDoCloseSocket
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/netlib.cpp20
-rw-r--r--src/mir_app/src/netlib.h2
-rw-r--r--src/mir_app/src/netlibhttp.cpp4
-rw-r--r--src/mir_app/src/netlibhttpproxy.cpp2
-rw-r--r--src/mir_app/src/netlibopenconn.cpp4
7 files changed, 26 insertions, 8 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 3c24d69dc5..98b5cf622c 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -353,3 +353,4 @@ Netlib_Log @353
Netlib_LogW @354
Netlib_Logf @355
Netlib_LogfW @356
+Netlib_GetConnNlu @357
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index b7a8c032e1..b777b03b2e 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -353,3 +353,4 @@ Netlib_Log @353
Netlib_LogW @354
Netlib_Logf @355
Netlib_LogfW @356
+Netlib_GetConnNlu @357
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index 71f1d5ea85..69b4195b37 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -230,7 +230,9 @@ static INT_PTR NetlibSetUserSettings(WPARAM wParam, LPARAM lParam)
return 1;
}
-void NetlibDoClose(NetlibConnection *nlc, bool noShutdown)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void NetlibDoCloseSocket(NetlibConnection *nlc, bool noShutdown)
{
if (nlc->s == INVALID_SOCKET) return;
@@ -278,7 +280,7 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib)
HttpGatewayRemovePacket(nlc, -1);
else {
if (nlc->s != INVALID_SOCKET)
- NetlibDoClose(nlc, nlc->termRequested);
+ NetlibDoCloseSocket(nlc, nlc->termRequested);
if (nlc->s2 != INVALID_SOCKET)
closesocket(nlc->s2);
nlc->s2 = INVALID_SOCKET;
@@ -318,6 +320,8 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib)
return 1;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR NetlibGetSocket(WPARAM wParam, LPARAM)
{
SOCKET s;
@@ -344,6 +348,8 @@ static INT_PTR NetlibGetSocket(WPARAM wParam, LPARAM)
return s;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR NetlibStringToAddressSrv(WPARAM wParam, LPARAM lParam)
{
return (INT_PTR)!NetlibStringToAddress((char*)wParam, (SOCKADDR_INET_M*)lParam);
@@ -371,6 +377,16 @@ INT_PTR NetlibGetMyIp(WPARAM wParam, LPARAM)
return (INT_PTR)GetMyIp((unsigned)wParam);
}
+MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HANDLE hConn)
+{
+ if (GetNetlibHandleType(hConn) != NLH_CONNECTION)
+ return NULL;
+
+ return ((NetlibConnection*)hConn)->nlu;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR NetlibShutdown(WPARAM wParam, LPARAM)
{
if (wParam) {
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h
index 0e6281a935..738242b0ae 100644
--- a/src/mir_app/src/netlib.h
+++ b/src/mir_app/src/netlib.h
@@ -187,7 +187,7 @@ struct NetlibPacketRecver {
//netlib.c
void NetlibFreeUserSettingsStruct(NETLIBUSERSETTINGS *settings);
-void NetlibDoClose(NetlibConnection *nlc, bool noShutdown = false);
+void NetlibDoCloseSocket(NetlibConnection *nlc, bool noShutdown = false);
void NetlibInitializeNestedCS(NetlibNestedCriticalSection *nlncs);
void NetlibDeleteNestedCS(NetlibNestedCriticalSection *nlncs);
#define NLNCS_SEND 0
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp
index e04e8a21d0..b37a14e6dd 100644
--- a/src/mir_app/src/netlibhttp.cpp
+++ b/src/mir_app/src/netlibhttp.cpp
@@ -184,7 +184,7 @@ static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUse
bool sameHost = mir_strcmp(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;
if (!httpProxy && !sameHost) {
- NetlibDoClose(nlc);
+ NetlibDoCloseSocket(nlc);
mir_free((char*)nlc->nloc.szHost);
nlc->nloc = nloc;
@@ -1151,7 +1151,7 @@ next:
if (close &&
(nlc->proxyType != PROXYTYPE_HTTP || nlc->nloc.flags & NLOCF_SSL) &&
(!isConnect || nlhrReply->resultCode != 200))
- NetlibDoClose(nlc);
+ NetlibDoCloseSocket(nlc);
return nlhrReply;
}
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp
index 75c714a1c7..d34d67985e 100644
--- a/src/mir_app/src/netlibhttpproxy.cpp
+++ b/src/mir_app/src/netlibhttpproxy.cpp
@@ -113,7 +113,7 @@ static bool NetlibHttpGatewaySend(NetlibConnection *nlc, RequestType reqType, co
bool sameHost = mir_strcmp(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;
if (!sameHost) {
- NetlibDoClose(nlc);
+ NetlibDoCloseSocket(nlc);
mir_free((char*)nlc->nloc.szHost);
nlc->nloc = nloc;
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp
index cbbf885d28..18216f1c51 100644
--- a/src/mir_app/src/netlibopenconn.cpp
+++ b/src/mir_app/src/netlibopenconn.cpp
@@ -660,7 +660,7 @@ static bool my_connect(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc)
static int NetlibHttpFallbackToDirect(NetlibConnection *nlc, NetlibUser *nlu, NETLIBOPENCONNECTION *nloc)
{
- NetlibDoClose(nlc, true);
+ NetlibDoCloseSocket(nlc, true);
Netlib_Logf(nlu, "Fallback to direct connection");
@@ -800,7 +800,7 @@ bool NetlibReconnect(NetlibConnection *nlc)
}
if (!opened)
- NetlibDoClose(nlc, true);
+ NetlibDoCloseSocket(nlc, true);
}
if (!opened) {