Commit f9862efa authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

netcfgx: Add INetCfg interface support.

parent 66c1a099
......@@ -17024,6 +17024,7 @@ wine_fn_config_dll nddeapi enable_nddeapi implib
wine_fn_config_dll netapi32 enable_netapi32 implib
wine_fn_config_test dlls/netapi32/tests netapi32_test
wine_fn_config_dll netcfgx enable_netcfgx clean
wine_fn_config_test dlls/netcfgx/tests netcfgx_test
wine_fn_config_dll newdev enable_newdev implib
wine_fn_config_dll normaliz enable_normaliz implib
wine_fn_config_dll npmshtml enable_npmshtml
......
......@@ -3028,6 +3028,7 @@ WINE_CONFIG_DLL(nddeapi,,[implib])
WINE_CONFIG_DLL(netapi32,,[implib])
WINE_CONFIG_TEST(dlls/netapi32/tests)
WINE_CONFIG_DLL(netcfgx,,[clean])
WINE_CONFIG_TEST(dlls/netcfgx/tests)
WINE_CONFIG_DLL(newdev,,[implib])
WINE_CONFIG_DLL(normaliz,,[implib])
WINE_CONFIG_DLL(npmshtml)
......
MODULE = netcfgx.dll
IMPORTS = uuid
C_SRCS = \
main.c
main.c \
netcfg.c
IDL_SRCS = netcfgx_classes.idl
......@@ -19,16 +19,107 @@
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "rpcproxy.h"
#include "wine/debug.h"
#include "netcfgx.h"
#include "netcfg_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(netcfgx);
static HINSTANCE NETCFGX_hInstance;
typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown **);
typedef struct netcfgcf
{
IClassFactory IClassFactory_iface;
ClassFactoryCreateInstanceFunc fnCreateInstance;
} netcfgcf;
static inline netcfgcf *impl_from_IClassFactory( IClassFactory *iface )
{
return CONTAINING_RECORD(iface, netcfgcf, IClassFactory_iface);
}
static HRESULT WINAPI netcfgcf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj )
{
TRACE("%s %p\n", debugstr_guid(riid), ppobj);
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IClassFactory))
{
IClassFactory_AddRef( iface );
*ppobj = iface;
return S_OK;
}
ERR("interface %s not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI netcfgcf_AddRef(IClassFactory *iface )
{
TRACE("%p\n", iface);
return 2;
}
static ULONG WINAPI netcfgcf_Release(IClassFactory *iface )
{
TRACE("%p\n", iface);
return 1;
}
static HRESULT WINAPI netcfgcf_CreateInstance(IClassFactory *iface,LPUNKNOWN pOuter,
REFIID riid, LPVOID *ppobj )
{
netcfgcf *This = impl_from_IClassFactory( iface );
HRESULT hr;
IUnknown *punk;
TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
*ppobj = NULL;
if (pOuter)
return CLASS_E_NOAGGREGATION;
hr = This->fnCreateInstance( &punk );
if (SUCCEEDED(hr))
{
hr = IUnknown_QueryInterface( punk, riid, ppobj );
IUnknown_Release( punk );
}
else
{
WARN("Cannot create an instance object. 0x%08x\n", hr);
}
return hr;
}
static HRESULT WINAPI netcfgcf_LockServer(IClassFactory *iface, BOOL dolock)
{
FIXME("(%p)->(%d),stub!\n",iface,dolock);
return S_OK;
}
static const struct IClassFactoryVtbl netcfgcf_vtbl =
{
netcfgcf_QueryInterface,
netcfgcf_AddRef,
netcfgcf_Release,
netcfgcf_CreateInstance,
netcfgcf_LockServer
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
......@@ -49,11 +140,23 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
return TRUE;
}
static netcfgcf netconfigcf = { {&netcfgcf_vtbl}, INetCfg_CreateInstance };
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
IClassFactory *cf = NULL;
TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
if(IsEqualCLSID(rclsid, &CLSID_CNetCfg))
{
cf = &netconfigcf.IClassFactory_iface;
}
if(!cf)
return CLASS_E_CLASSNOTAVAILABLE;
return CLASS_E_CLASSNOTAVAILABLE;
return IClassFactory_QueryInterface(cf, riid, ppv);
}
HRESULT WINAPI DllRegisterServer(void)
......
/*
* Copyright 2014 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
#include "netcfgx.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL( netcfgx );
typedef struct NetConfiguration
{
INetCfg INetCfg_iface;
LONG ref;
} NetConfiguration;
static inline NetConfiguration *impl_from_INetCfg(INetCfg *iface)
{
return CONTAINING_RECORD(iface, NetConfiguration, INetCfg_iface);
}
static HRESULT WINAPI netcfg_QueryInterface(INetCfg *iface, REFIID riid, void **ppvObject)
{
TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
if (IsEqualGUID(riid, &IID_INetCfg) ||
IsEqualGUID(riid, &IID_IUnknown))
{
*ppvObject = iface;
}
else
{
FIXME("Unsupported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
INetCfg_AddRef( iface );
return S_OK;
}
static ULONG WINAPI netcfg_AddRef(INetCfg *iface)
{
NetConfiguration *This = impl_from_INetCfg(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p ref=%u\n", This, ref);
return ref;
}
static ULONG WINAPI netcfg_Release(INetCfg *iface)
{
NetConfiguration *This = impl_from_INetCfg(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p ref=%u\n", This, ref);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI netcfg_Initialize(INetCfg *iface, PVOID pvReserved)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p %p\n", This, pvReserved);
return S_OK;
}
static HRESULT WINAPI netcfg_Uninitialize(INetCfg *iface)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p\n", This);
return S_OK;
}
static HRESULT WINAPI netcfg_Apply(INetCfg *iface)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI netcfg_Cancel(INetCfg *iface)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI netcfg_EnumComponents(INetCfg *iface, const GUID *pguidClass, IEnumNetCfgComponent **ppenumComponent)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p %s %p\n", This, debugstr_guid(pguidClass), ppenumComponent);
return E_NOTIMPL;
}
static HRESULT WINAPI netcfg_FindComponent(INetCfg *iface, LPCWSTR pszwInfId, INetCfgComponent **pComponent)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p %s %p\n", This, debugstr_w(pszwInfId), pComponent);
return E_NOTIMPL;
}
static HRESULT WINAPI netcfg_QueryNetCfgClass(INetCfg *iface, const GUID *pguidClass, REFIID riid, void **ppvObject)
{
NetConfiguration *This = impl_from_INetCfg(iface);
FIXME("%p %s %p\n", This, debugstr_guid(pguidClass), ppvObject);
return E_NOTIMPL;
}
static const struct INetCfgVtbl NetCfgVtbl =
{
netcfg_QueryInterface,
netcfg_AddRef,
netcfg_Release,
netcfg_Initialize,
netcfg_Uninitialize,
netcfg_Apply,
netcfg_Cancel,
netcfg_EnumComponents,
netcfg_FindComponent,
netcfg_QueryNetCfgClass
};
HRESULT INetCfg_CreateInstance(IUnknown **ppUnk)
{
NetConfiguration *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(NetConfiguration));
if (!This)
return E_OUTOFMEMORY;
This->INetCfg_iface.lpVtbl = &NetCfgVtbl;
This->ref = 1;
*ppUnk = (IUnknown*)This;
return S_OK;
}
/*
* Copyright 2014 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __NETCFG_PRIVATE_H__
#define __NETCFG_PRIVATE_H__
extern HRESULT INetCfg_CreateInstance(IUnknown **ppUnk) DECLSPEC_HIDDEN;
#endif
TESTDLL = netcfgx.dll
IMPORTS = uuid ole32
C_SRCS = \
netcfgx.c
/*
* Copyright 2014 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#define COBJMACROS
#include "netcfgx.h"
#include "wine/test.h"
void create_configuration(void)
{
static const WCHAR tcpipW[] = {'M','S','_','T','C','P','I','P',0};
HRESULT hr;
INetCfg *config = NULL;
INetCfgComponent *component = NULL;
hr = CoCreateInstance( &CLSID_CNetCfg, NULL, CLSCTX_ALL, &IID_INetCfg, (LPVOID*)&config);
ok(hr == S_OK, "Failed to create object\n");
if(SUCCEEDED(hr))
{
hr = INetCfg_Initialize(config, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = INetCfg_FindComponent(config, tcpipW, &component);
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
if(hr == S_OK)
{
INetCfgComponent_Release(component);
}
hr = INetCfg_Uninitialize(config);
ok(hr == S_OK, "got 0x%08x\n", hr);
INetCfg_Release(config);
}
}
START_TEST(netcfgx)
{
HRESULT hr;
hr = CoInitialize(0);
ok( hr == S_OK, "failed to init com\n");
if (hr != S_OK)
return;
create_configuration();
CoUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment