d3drm: Implement IDirect3DRMTextureX_GetClassName.
[wine] / dlls / wbemprox / wbemlocator.c
1 /*
2  * Copyright 2009 Hans Leidekker for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #define COBJMACROS
20
21 #include "config.h"
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "wbemcli.h"
28
29 #include "wine/debug.h"
30 #include "wine/unicode.h"
31 #include "wbemprox_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
34
35 typedef struct
36 {
37     IWbemLocator IWbemLocator_iface;
38     LONG refs;
39 } wbem_locator;
40
41 static inline wbem_locator *impl_from_IWbemLocator( IWbemLocator *iface )
42 {
43     return CONTAINING_RECORD(iface, wbem_locator, IWbemLocator_iface);
44 }
45
46 static ULONG WINAPI wbem_locator_AddRef(
47     IWbemLocator *iface )
48 {
49     wbem_locator *wl = impl_from_IWbemLocator( iface );
50     return InterlockedIncrement( &wl->refs );
51 }
52
53 static ULONG WINAPI wbem_locator_Release(
54     IWbemLocator *iface )
55 {
56     wbem_locator *wl = impl_from_IWbemLocator( iface );
57     LONG refs = InterlockedDecrement( &wl->refs );
58     if (!refs)
59     {
60         TRACE("destroying %p\n", wl);
61         heap_free( wl );
62     }
63     return refs;
64 }
65
66 static HRESULT WINAPI wbem_locator_QueryInterface(
67     IWbemLocator *iface,
68     REFIID riid,
69     void **ppvObject )
70 {
71     wbem_locator *This = impl_from_IWbemLocator( iface );
72
73     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
74
75     if ( IsEqualGUID( riid, &IID_IWbemLocator ) ||
76          IsEqualGUID( riid, &IID_IUnknown ) )
77     {
78         *ppvObject = iface;
79     }
80     else
81     {
82         FIXME("interface %s not implemented\n", debugstr_guid(riid));
83         return E_NOINTERFACE;
84     }
85     IWbemLocator_AddRef( iface );
86     return S_OK;
87 }
88
89 static HRESULT WINAPI wbem_locator_ConnectServer(
90     IWbemLocator *iface,
91     const BSTR NetworkResource,
92     const BSTR User,
93     const BSTR Password,
94     const BSTR Locale,
95     LONG SecurityFlags,
96     const BSTR Authority,
97     IWbemContext *pCtx,
98     IWbemServices **ppNamespace)
99 {
100     HRESULT hr;
101
102     FIXME("%p, %s, %s, %s, %s, 0x%08x, %s, %p, %p)\n", iface, debugstr_w(NetworkResource), debugstr_w(User),
103           debugstr_w(Password), debugstr_w(Locale), SecurityFlags, debugstr_w(Authority), pCtx, ppNamespace);
104
105     if (((NetworkResource[0] == '\\' && NetworkResource[1] == '\\') ||
106          (NetworkResource[0] == '/' && NetworkResource[1] == '/')) && NetworkResource[2] != '.')
107     {
108         FIXME("remote computer not supported\n");
109         return WBEM_E_TRANSPORT_FAILURE;
110     }
111     hr = WbemServices_create( NULL, (void **)ppNamespace );
112     if (SUCCEEDED( hr ))
113         return WBEM_NO_ERROR;
114
115     return WBEM_E_FAILED;
116 }
117
118 static const IWbemLocatorVtbl wbem_locator_vtbl =
119 {
120     wbem_locator_QueryInterface,
121     wbem_locator_AddRef,
122     wbem_locator_Release,
123     wbem_locator_ConnectServer
124 };
125
126 HRESULT WbemLocator_create( IUnknown *pUnkOuter, LPVOID *ppObj )
127 {
128     wbem_locator *wl;
129
130     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
131
132     wl = heap_alloc( sizeof(*wl) );
133     if (!wl) return E_OUTOFMEMORY;
134
135     wl->IWbemLocator_iface.lpVtbl = &wbem_locator_vtbl;
136     wl->refs = 1;
137
138     *ppObj = &wl->IWbemLocator_iface;
139
140     TRACE("returning iface %p\n", *ppObj);
141     return S_OK;
142 }