mpr: Implement WNetClearConnections().
[wine.git] / dlls / msident / msident.c
blob8b9842f9603dcc34dabb6216a2d45b033657e33f
1 /*
2 * Copyright 2012 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include "windows.h"
22 #include "initguid.h"
23 #include "msident.h"
24 #include "rpcproxy.h"
26 #include "wine/debug.h"
27 #include "wine/heap.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msident);
31 static HINSTANCE msident_instance;
33 typedef struct {
34 IEnumUserIdentity IEnumUserIdentity_iface;
35 LONG ref;
36 } EnumUserIdentity;
38 static inline EnumUserIdentity *impl_from_IEnumUserIdentity(IEnumUserIdentity *iface)
40 return CONTAINING_RECORD(iface, EnumUserIdentity, IEnumUserIdentity_iface);
43 static HRESULT WINAPI EnumUserIdentity_QueryInterface(IEnumUserIdentity *iface, REFIID riid, void **ppv)
45 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
47 if(IsEqualGUID(&IID_IUnknown, riid)) {
48 TRACE("(IID_IUnknown %p)\n", ppv);
49 *ppv = &This->IEnumUserIdentity_iface;
50 }else if(IsEqualGUID(&IID_IEnumUserIdentity, riid)) {
51 TRACE("(IID_IEnumUserIdentity %p)\n", ppv);
52 *ppv = &This->IEnumUserIdentity_iface;
53 }else {
54 WARN("(%s %p)\n", debugstr_guid(riid), ppv);
55 *ppv = NULL;
56 return E_NOINTERFACE;
59 IUnknown_AddRef((IUnknown*)*ppv);
60 return S_OK;
63 static ULONG WINAPI EnumUserIdentity_AddRef(IEnumUserIdentity *iface)
65 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
66 LONG ref = InterlockedIncrement(&This->ref);
68 TRACE("(%p) ref=%d\n", This, ref);
70 return ref;
73 static ULONG WINAPI EnumUserIdentity_Release(IEnumUserIdentity *iface)
75 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
76 LONG ref = InterlockedDecrement(&This->ref);
78 TRACE("(%p) ref=%d\n", This, ref);
80 if(!ref)
81 heap_free(This);
83 return ref;
86 static HRESULT WINAPI EnumUserIdentity_Next(IEnumUserIdentity *iface, ULONG celt, IUnknown **rgelt, ULONG *pceltFetched)
88 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
89 FIXME("(%p)->(%u %p %p)\n", This, celt, rgelt, pceltFetched);
90 return E_NOTIMPL;
93 static HRESULT WINAPI EnumUserIdentity_Skip(IEnumUserIdentity *iface, ULONG celt)
95 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
96 FIXME("(%p)->(%u)\n", This, celt);
97 return E_NOTIMPL;
100 static HRESULT WINAPI EnumUserIdentity_Reset(IEnumUserIdentity *iface)
102 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
103 FIXME("(%p)->()\n", This);
104 return E_NOTIMPL;
107 static HRESULT WINAPI EnumUserIdentity_Clone(IEnumUserIdentity *iface, IEnumUserIdentity **ppenum)
109 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
110 FIXME("(%p)->(%p)\n", This, ppenum);
111 return E_NOTIMPL;
114 static HRESULT WINAPI EnumUserIdentity_GetCount(IEnumUserIdentity *iface, ULONG *pnCount)
116 EnumUserIdentity *This = impl_from_IEnumUserIdentity(iface);
118 FIXME("(%p)->(%p)\n", This, pnCount);
120 *pnCount = 0;
121 return S_OK;
124 static const IEnumUserIdentityVtbl EnumUserIdentityVtbl = {
125 EnumUserIdentity_QueryInterface,
126 EnumUserIdentity_AddRef,
127 EnumUserIdentity_Release,
128 EnumUserIdentity_Next,
129 EnumUserIdentity_Skip,
130 EnumUserIdentity_Reset,
131 EnumUserIdentity_Clone,
132 EnumUserIdentity_GetCount
135 static HRESULT WINAPI UserIdentityManager_QueryInterface(IUserIdentityManager *iface, REFIID riid, void **ppv)
137 if(IsEqualGUID(&IID_IUnknown, riid)) {
138 TRACE("(IID_IUnknown %p)\n", ppv);
139 *ppv = iface;
140 }else if(IsEqualGUID(&IID_IUserIdentityManager, riid)) {
141 TRACE("(IID_IUserIdentityManager %p)\n", ppv);
142 *ppv = iface;
143 }else {
144 WARN("(%s %p)\n", debugstr_guid(riid), ppv);
145 *ppv = NULL;
146 return E_NOINTERFACE;
149 IUnknown_AddRef((IUnknown*)*ppv);
150 return S_OK;
153 static ULONG WINAPI UserIdentityManager_AddRef(IUserIdentityManager *iface)
155 TRACE("\n");
156 return 2;
159 static ULONG WINAPI UserIdentityManager_Release(IUserIdentityManager *iface)
161 TRACE("\n");
162 return 1;
165 static HRESULT WINAPI UserIdentityManager_EnumIdentities(IUserIdentityManager *iface, IEnumUserIdentity **ppEnumUser)
167 EnumUserIdentity *ret;
169 TRACE("(%p)\n", ppEnumUser);
171 ret = heap_alloc(sizeof(*ret));
172 if(!ret)
173 return E_OUTOFMEMORY;
175 ret->IEnumUserIdentity_iface.lpVtbl = &EnumUserIdentityVtbl;
176 ret->ref = 1;
178 *ppEnumUser = &ret->IEnumUserIdentity_iface;
179 return S_OK;
182 static HRESULT WINAPI UserIdentityManager_ManageIdentities(IUserIdentityManager *iface, HWND hwndParent, DWORD dwFlags)
184 FIXME("(%p %x)\n", hwndParent, dwFlags);
185 return E_NOTIMPL;
188 static HRESULT WINAPI UserIdentityManager_Logon(IUserIdentityManager *iface, HWND hwndParent,
189 DWORD dwFlags, IUserIdentity **ppIdentity)
191 FIXME("(%p %x %p)\n", hwndParent, dwFlags, ppIdentity);
192 return E_USER_CANCELLED;
195 static HRESULT WINAPI UserIdentityManager_Logoff(IUserIdentityManager *iface, HWND hwndParent)
197 FIXME("(%p)\n", hwndParent);
198 return E_NOTIMPL;
201 static HRESULT WINAPI UserIdentityManager_GetIdentityByCookie(IUserIdentityManager *iface, GUID *uidCookie,
202 IUserIdentity **ppIdentity)
204 FIXME("(%p %p)\n", uidCookie, ppIdentity);
205 return E_NOTIMPL;
208 static const IUserIdentityManagerVtbl UserIdentityManagerVtbl = {
209 UserIdentityManager_QueryInterface,
210 UserIdentityManager_AddRef,
211 UserIdentityManager_Release,
212 UserIdentityManager_EnumIdentities,
213 UserIdentityManager_ManageIdentities,
214 UserIdentityManager_Logon,
215 UserIdentityManager_Logoff,
216 UserIdentityManager_GetIdentityByCookie
219 static IUserIdentityManager UserIdentityManager = { &UserIdentityManagerVtbl };
221 static HRESULT WINAPI UserIdentityManager_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
223 TRACE("\n");
225 return IUserIdentityManager_QueryInterface(&UserIdentityManager, riid, ppv);
228 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
230 *ppv = NULL;
232 if(IsEqualGUID(&IID_IUnknown, riid)) {
233 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
234 *ppv = iface;
235 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
236 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
237 *ppv = iface;
240 if(*ppv) {
241 IUnknown_AddRef((IUnknown*)*ppv);
242 return S_OK;
245 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
246 return E_NOINTERFACE;
249 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
251 TRACE("(%p)\n", iface);
252 return 2;
255 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
257 TRACE("(%p)\n", iface);
258 return 1;
261 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
263 TRACE("(%p)->(%x)\n", iface, fLock);
264 return S_OK;
267 static const IClassFactoryVtbl UserIdentityManagerCFVtbl = {
268 ClassFactory_QueryInterface,
269 ClassFactory_AddRef,
270 ClassFactory_Release,
271 UserIdentityManager_CreateInstance,
272 ClassFactory_LockServer
275 static IClassFactory UserIdentityManagerCF = { &UserIdentityManagerCFVtbl };
277 /******************************************************************
278 * DllMain (msident.@)
280 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
282 TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
284 switch(fdwReason)
286 case DLL_WINE_PREATTACH:
287 return FALSE; /* prefer native version */
288 case DLL_PROCESS_ATTACH:
289 msident_instance = hInstDLL;
290 DisableThreadLibraryCalls(hInstDLL);
291 break;
294 return TRUE;
297 /***********************************************************************
298 * DllGetClassObject (msident.@)
300 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
302 if(IsEqualGUID(&CLSID_UserIdentityManager, rclsid)) {
303 TRACE("CLSID_UserIdentityManager\n");
304 return IClassFactory_QueryInterface(&UserIdentityManagerCF, riid, ppv);
307 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
308 return CLASS_E_CLASSNOTAVAILABLE;
311 /***********************************************************************
312 * DllCanUnloadNow (msident.@)
314 HRESULT WINAPI DllCanUnloadNow(void)
316 return S_FALSE;
319 /***********************************************************************
320 * DllRegisterServer (msident.@)
322 HRESULT WINAPI DllRegisterServer(void)
324 TRACE("()\n");
325 return __wine_register_resources(msident_instance);
328 /***********************************************************************
329 * DllUnregisterServer (msident.@)
331 HRESULT WINAPI DllUnregisterServer(void)
333 TRACE("()\n");
334 return __wine_unregister_resources(msident_instance);