mpr: Implement WNetGetResourceInformation functions.

This commit is contained in:
Konstantin Kondratyuk 2007-10-01 11:58:59 +04:00 committed by Alexandre Julliard
parent 6706a1b3fd
commit 7fb98bfba5
2 changed files with 141 additions and 7 deletions

View File

@ -52,6 +52,7 @@ typedef struct _WNetProvider
PF_NPOpenEnum openEnum;
PF_NPEnumResource enumResource;
PF_NPCloseEnum closeEnum;
PF_NPGetResourceInformation getResourceInformation;
} WNetProvider, *PWNetProvider;
typedef struct _WNetProviderTable
@ -182,6 +183,10 @@ static void _tryLoadProvider(PCWSTR provider)
provider->closeEnum = (PF_NPCloseEnum)
GetProcAddress(hLib, "NPCloseEnum");
TRACE("closeEnum is %p\n", provider->closeEnum);
provider->getResourceInformation = (PF_NPGetResourceInformation)
GetProcAddress(hLib, "NPGetResourceInformation");
TRACE("getResourceInformation is %p\n",
provider->getResourceInformation);
if (!provider->openEnum || !provider->enumResource
|| !provider->closeEnum)
{
@ -1281,30 +1286,157 @@ DWORD WINAPI WNetCloseEnum( HANDLE hEnum )
/*********************************************************************
* WNetGetResourceInformationA [MPR.@]
*
* See WNetGetResourceInformationW
*/
DWORD WINAPI WNetGetResourceInformationA( LPNETRESOURCEA lpNetResource,
LPVOID lpBuffer, LPDWORD cbBuffer,
LPSTR *lplpSystem )
{
FIXME( "(%p, %p, %p, %p): stub\n",
DWORD ret;
TRACE( "(%p, %p, %p, %p)\n",
lpNetResource, lpBuffer, cbBuffer, lplpSystem );
SetLastError(WN_NO_NETWORK);
return WN_NO_NETWORK;
if (!providerTable || providerTable->numProviders == 0)
ret = WN_NO_NETWORK;
else if (lpNetResource)
{
LPNETRESOURCEW lpNetResourceW = NULL;
DWORD size = 1024, count = 1;
DWORD len;
lpNetResourceW = HeapAlloc(GetProcessHeap(), 0, size);
ret = _thunkNetResourceArrayAToW(lpNetResource, &count, lpNetResourceW, &size);
if (ret == WN_MORE_DATA)
{
lpNetResourceW = HeapAlloc(GetProcessHeap(), 0, size);
if (lpNetResourceW)
ret = _thunkNetResourceArrayAToW(lpNetResource,
&count, lpNetResourceW, &size);
else
ret = WN_OUT_OF_MEMORY;
}
if (ret == WN_SUCCESS)
{
LPWSTR lpSystemW;
LPVOID lpBufferW;
size = 1024;
lpBufferW = HeapAlloc(GetProcessHeap(), 0, size);
if (lpBufferW)
{
ret = WNetGetResourceInformationW(lpNetResourceW,
lpBufferW, &size, &lpSystemW);
if (ret == WN_MORE_DATA)
{
HeapFree(GetProcessHeap(), 0, lpBufferW);
lpBufferW = HeapAlloc(GetProcessHeap(), 0, size);
if (lpBufferW)
ret = WNetGetResourceInformationW(lpNetResourceW,
lpBufferW, &size, &lpSystemW);
else
ret = WN_OUT_OF_MEMORY;
}
if (ret == WN_SUCCESS)
{
ret = _thunkNetResourceArrayWToA(lpBufferW,
&count, lpBuffer, cbBuffer);
lpNetResourceW = lpBufferW;
size = sizeof(NETRESOURCEA);
size += WideCharToMultiByte(CP_ACP, 0, lpNetResourceW->lpRemoteName,
-1, NULL, 0, NULL, NULL);
size += WideCharToMultiByte(CP_ACP, 0, lpNetResourceW->lpProvider,
-1, NULL, 0, NULL, NULL);
len = WideCharToMultiByte(CP_ACP, 0, lpSystemW,
-1, NULL, 0, NULL, NULL);
if ((len) && ( size + len < *cbBuffer))
{
*lplpSystem = (char*)lpBuffer + *cbBuffer - len;
WideCharToMultiByte(CP_ACP, 0, lpSystemW, -1,
*lplpSystem, len, NULL, NULL);
ret = WN_SUCCESS;
}
else
ret = WN_MORE_DATA;
}
else
ret = WN_OUT_OF_MEMORY;
HeapFree(GetProcessHeap(), 0, lpBufferW);
}
else
ret = WN_OUT_OF_MEMORY;
HeapFree(GetProcessHeap(), 0, lpSystemW);
}
HeapFree(GetProcessHeap(), 0, lpNetResourceW);
}
else
ret = WN_NO_NETWORK;
if (ret)
SetLastError(ret);
TRACE("Returning %d\n", ret);
return ret;
}
/*********************************************************************
* WNetGetResourceInformationW [MPR.@]
*
* WNetGetResourceInformationW function identifies the network provider
* that owns the resource and gets information about the type of the resource.
*
* PARAMS:
* lpNetResource [ I] the pointer to NETRESOURCEW structure, that
* defines a network resource.
* lpBuffer [ O] the pointer to buffer, containing result. It
* contains NETRESOURCEW structure and strings to
* which the members of the NETRESOURCEW structure
* point.
* cbBuffer [I/O] the pointer to DWORD number - size of buffer
* in bytes.
* lplpSystem [ O] the pointer to string in the output buffer,
* containing the part of the resource name without
* names of the server and share.
*
* RETURNS:
* NO_ERROR if the function succeeds. System error code if the function fails.
*/
DWORD WINAPI WNetGetResourceInformationW( LPNETRESOURCEW lpNetResource,
LPVOID lpBuffer, LPDWORD cbBuffer,
LPWSTR *lplpSystem )
{
FIXME( "(%p, %p, %p, %p): stub\n",
lpNetResource, lpBuffer, cbBuffer, lplpSystem );
DWORD ret = WN_NO_NETWORK;
DWORD index;
SetLastError(WN_NO_NETWORK);
return WN_NO_NETWORK;
TRACE( "(%p, %p, %p, %p): stub\n",
lpNetResource, lpBuffer, cbBuffer, lplpSystem);
if (!(lpBuffer))
ret = WN_OUT_OF_MEMORY;
else
{
/* FIXME: For function value of a variable is indifferent, it does
* search of all providers in a network.
*/
for (index = 0; index < providerTable->numProviders; index++)
{
if(providerTable->table[index].getCaps(WNNC_DIALOG) &
WNNC_DLG_GETRESOURCEINFORMATION)
{
if (providerTable->table[index].getResourceInformation)
ret = providerTable->table[index].getResourceInformation(
lpNetResource, lpBuffer, cbBuffer, lplpSystem);
else
ret = WN_NO_NETWORK;
if (ret == WN_SUCCESS)
break;
}
}
}
if (ret)
SetLastError(ret);
return ret;
}
/*********************************************************************

View File

@ -70,6 +70,8 @@ typedef DWORD (APIENTRY *PF_NPOpenEnum)(DWORD dwScope, DWORD dwType, DWORD dwUsa
typedef DWORD (APIENTRY *PF_NPEnumResource)(HANDLE hEnum, LPDWORD lpcCount,
LPVOID lpBuffer, LPDWORD lpBufferSize);
typedef DWORD (APIENTRY *PF_NPCloseEnum)(HANDLE hEnum);
typedef DWORD (APIENTRY *PF_NPGetResourceInformation)(LPNETRESOURCEW lpNetResource,
LPVOID lpBuffer, LPDWORD lpcbBuffer, LPWSTR* lplpSystem);
/* connection-related */
typedef DWORD (APIENTRY *PF_NPAddConnection)(LPNETRESOURCEW lpNetResource,