Author: pschweitzer
Date: Tue Aug 2 09:49:20 2016
New Revision: 72082
URL:
http://svn.reactos.org/svn/reactos?rev=72082&view=rev
Log:
[MPR]
Time to react (again!).
Implement automatic local name redirection for new connection. This implements the
behavior of the CONNECT_REDIRECT flag of WNetUseConnection.
Already sent upstream.
Patch 1/6
CORE-11757
ROSAPPS-303
Modified:
trunk/reactos/dll/win32/mpr/wnet.c
Modified: trunk/reactos/dll/win32/mpr/wnet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mpr/wnet.c?rev=7…
==============================================================================
--- trunk/reactos/dll/win32/mpr/wnet.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/mpr/wnet.c [iso-8859-1] Tue Aug 2 09:49:20 2016
@@ -1617,6 +1617,8 @@
{
WNetProvider *provider;
DWORD index, ret, caps;
+ BOOLEAN redirect = FALSE;
+ WCHAR letter[3] = {'z', ':', 0};
if (!providerTable || providerTable->numProviders == 0)
return WN_NO_NETWORK;
@@ -1624,41 +1626,74 @@
if (!ctxt->resource)
return ERROR_INVALID_PARAMETER;
+ if (!ctxt->resource->lpLocalName && (ctxt->flags &
CONNECT_REDIRECT))
+ {
+ if (ctxt->resource->dwType != RESOURCETYPE_DISK &&
ctxt->resource->dwType != RESOURCETYPE_PRINT)
+ {
+ return ERROR_BAD_DEV_TYPE;
+ }
+
+ if (ctxt->resource->dwType == RESOURCETYPE_PRINT)
+ {
+ FIXME("Locale device selection is not implemented for
printers.\n");
+ return WN_NO_NETWORK;
+ }
+
+ redirect = TRUE;
+ ctxt->resource->lpLocalName = letter;
+ }
+
if (!ctxt->resource->lpProvider)
{
FIXME("Networking provider selection is not implemented.\n");
- return WN_NO_NETWORK;
- }
-
- if (!ctxt->resource->lpLocalName && (ctxt->flags &
CONNECT_REDIRECT))
- {
- FIXME("Locale device selection is not implemented.\n");
- return WN_NO_NETWORK;
+ ret = WN_NO_NETWORK;
+ goto done;
}
if (ctxt->flags & CONNECT_INTERACTIVE)
- return ERROR_BAD_NET_NAME;
+ {
+ ret = ERROR_BAD_NET_NAME;
+ goto done;
+ }
index = _findProviderIndexW(ctxt->resource->lpProvider);
if (index == BAD_PROVIDER_INDEX)
- return ERROR_BAD_PROVIDER;
+ {
+ ret = ERROR_BAD_PROVIDER;
+ goto done;
+ }
provider = &providerTable->table[index];
caps = provider->getCaps(WNNC_CONNECTION);
if (!(caps & (WNNC_CON_ADDCONNECTION | WNNC_CON_ADDCONNECTION3)))
- return ERROR_BAD_PROVIDER;
+ {
+ ret = ERROR_BAD_PROVIDER;
+ goto done;
+ }
if ((ret = ctxt->pre_set_accessname(ctxt)))
- return ret;
+ {
+ goto done;
+ }
ret = WN_ACCESS_DENIED;
- if ((caps & WNNC_CON_ADDCONNECTION3) && provider->addConnection3)
- ret = provider->addConnection3(ctxt->hwndOwner, ctxt->resource,
ctxt->password, ctxt->userid, ctxt->flags);
- else if ((caps & WNNC_CON_ADDCONNECTION) && provider->addConnection)
- ret = provider->addConnection(ctxt->resource, ctxt->password,
ctxt->userid);
+ do
+ {
+ if ((caps & WNNC_CON_ADDCONNECTION3) && provider->addConnection3)
+ ret = provider->addConnection3(ctxt->hwndOwner, ctxt->resource,
ctxt->password, ctxt->userid, ctxt->flags);
+ else if ((caps & WNNC_CON_ADDCONNECTION) &&
provider->addConnection)
+ ret = provider->addConnection(ctxt->resource, ctxt->password,
ctxt->userid);
+
+ if (redirect)
+ letter[0] -= 1;
+ } while (redirect && ret == WN_ALREADY_CONNECTED && letter[0] >=
'c');
if (ret == WN_SUCCESS && ctxt->accessname)
ctxt->set_accessname(ctxt);
+
+done:
+ if (redirect)
+ ctxt->resource->lpLocalName = NULL;
return ret;
}