http.sys: Keep connection sockets open after sending a 400 response.
[wine.git] / dlls / windows.networking.hostname / hostname.c
blob6f0d3fb90324866b9e70cb1434003287c44a85c6
1 /* WinRT Windows.Networking.Hostname Hostname Implementation
3 * Copyright (C) 2023 Mohamad Al-Jaf
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "private.h"
21 #include "wine/debug.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(hostname);
25 struct hostname_statics
27 IActivationFactory IActivationFactory_iface;
28 IHostNameFactory IHostNameFactory_iface;
29 LONG ref;
32 static inline struct hostname_statics *impl_from_IActivationFactory( IActivationFactory *iface )
34 return CONTAINING_RECORD( iface, struct hostname_statics, IActivationFactory_iface );
37 static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
39 struct hostname_statics *impl = impl_from_IActivationFactory( iface );
41 TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
43 if (IsEqualGUID( iid, &IID_IUnknown ) ||
44 IsEqualGUID( iid, &IID_IInspectable ) ||
45 IsEqualGUID( iid, &IID_IAgileObject ) ||
46 IsEqualGUID( iid, &IID_IActivationFactory ))
48 *out = &impl->IActivationFactory_iface;
49 IInspectable_AddRef( *out );
50 return S_OK;
53 if (IsEqualGUID( iid, &IID_IHostNameFactory ))
55 *out = &impl->IHostNameFactory_iface;
56 IInspectable_AddRef( *out );
57 return S_OK;
60 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) );
61 *out = NULL;
62 return E_NOINTERFACE;
65 static ULONG WINAPI factory_AddRef( IActivationFactory *iface )
67 struct hostname_statics *impl = impl_from_IActivationFactory( iface );
68 ULONG ref = InterlockedIncrement( &impl->ref );
69 TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
70 return ref;
73 static ULONG WINAPI factory_Release( IActivationFactory *iface )
75 struct hostname_statics *impl = impl_from_IActivationFactory( iface );
76 ULONG ref = InterlockedDecrement( &impl->ref );
77 TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
78 return ref;
81 static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids )
83 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids );
84 return E_NOTIMPL;
87 static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name )
89 FIXME( "iface %p, class_name %p stub!\n", iface, class_name );
90 return E_NOTIMPL;
93 static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level )
95 FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
96 return E_NOTIMPL;
99 static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance )
101 FIXME( "iface %p, instance %p stub!\n", iface, instance );
102 return E_NOTIMPL;
105 static const struct IActivationFactoryVtbl factory_vtbl =
107 factory_QueryInterface,
108 factory_AddRef,
109 factory_Release,
110 /* IInspectable methods */
111 factory_GetIids,
112 factory_GetRuntimeClassName,
113 factory_GetTrustLevel,
114 /* IActivationFactory methods */
115 factory_ActivateInstance,
118 struct hostname
120 IHostName IHostName_iface;
121 LONG ref;
123 HSTRING raw_name;
126 static inline struct hostname *impl_from_IHostName( IHostName *iface )
128 return CONTAINING_RECORD( iface, struct hostname, IHostName_iface );
131 static HRESULT WINAPI hostname_QueryInterface( IHostName *iface, REFIID iid, void **out )
133 struct hostname *impl = impl_from_IHostName( iface );
135 TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
137 if (IsEqualGUID( iid, &IID_IUnknown ) ||
138 IsEqualGUID( iid, &IID_IInspectable ) ||
139 IsEqualGUID( iid, &IID_IAgileObject ) ||
140 IsEqualGUID( iid, &IID_IHostName ))
142 *out = &impl->IHostName_iface;
143 IInspectable_AddRef( *out );
144 return S_OK;
147 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) );
148 *out = NULL;
149 return E_NOINTERFACE;
152 static ULONG WINAPI hostname_AddRef( IHostName *iface )
154 struct hostname *impl = impl_from_IHostName( iface );
155 ULONG ref = InterlockedIncrement( &impl->ref );
156 TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
157 return ref;
160 static ULONG WINAPI hostname_Release( IHostName *iface )
162 struct hostname *impl = impl_from_IHostName( iface );
163 ULONG ref = InterlockedDecrement( &impl->ref );
165 TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
167 if (!ref)
169 WindowsDeleteString( impl->raw_name );
170 free( impl );
173 return ref;
176 static HRESULT WINAPI hostname_GetIids( IHostName *iface, ULONG *iid_count, IID **iids )
178 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids );
179 return E_NOTIMPL;
182 static HRESULT WINAPI hostname_GetRuntimeClassName( IHostName *iface, HSTRING *class_name )
184 FIXME( "iface %p, class_name %p stub!\n", iface, class_name );
185 return E_NOTIMPL;
188 static HRESULT WINAPI hostname_GetTrustLevel( IHostName *iface, TrustLevel *trust_level )
190 FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
191 return E_NOTIMPL;
194 static HRESULT WINAPI hostname_get_IPInformation( IHostName *iface, IIPInformation **value )
196 FIXME( "iface %p, value %p stub!\n", iface, value );
197 return E_NOTIMPL;
200 static HRESULT WINAPI hostname_get_RawName( IHostName *iface, HSTRING *value )
202 struct hostname *impl = impl_from_IHostName( iface );
204 TRACE( "iface %p, value %p.\n", iface, value );
206 if (!value) return E_INVALIDARG;
207 return WindowsDuplicateString( impl->raw_name, value );
210 static HRESULT WINAPI hostname_get_DisplayName( IHostName *iface, HSTRING *value )
212 FIXME( "iface %p, value %p stub!\n", iface, value );
213 return E_NOTIMPL;
216 static HRESULT WINAPI hostname_get_CanonicalName( IHostName *iface, HSTRING *value )
218 FIXME( "iface %p, value %p stub!\n", iface, value );
219 return E_NOTIMPL;
222 static HRESULT WINAPI hostname_get_Type( IHostName *iface, HostNameType *value )
224 FIXME( "iface %p, value %p stub!\n", iface, value );
225 return E_NOTIMPL;
228 static HRESULT WINAPI hostname_IsEqual( IHostName *iface, IHostName *name, boolean *equal )
230 FIXME( "iface %p, name %p, equal %p stub!\n", iface, name, equal );
231 return E_NOTIMPL;
234 static const struct IHostNameVtbl hostname_vtbl =
236 hostname_QueryInterface,
237 hostname_AddRef,
238 hostname_Release,
239 /* IInspectable methods */
240 hostname_GetIids,
241 hostname_GetRuntimeClassName,
242 hostname_GetTrustLevel,
243 /* IHostName methods */
244 hostname_get_IPInformation,
245 hostname_get_RawName,
246 hostname_get_DisplayName,
247 hostname_get_CanonicalName,
248 hostname_get_Type,
249 hostname_IsEqual,
252 DEFINE_IINSPECTABLE( hostname_factory, IHostNameFactory, struct hostname_statics, IActivationFactory_iface )
254 static HRESULT WINAPI hostname_factory_CreateHostName( IHostNameFactory *iface, HSTRING name, IHostName **value )
256 struct hostname *impl;
258 TRACE( "iface %p, name %s, value %p\n", iface, debugstr_hstring(name), value );
260 if (!value) return E_POINTER;
261 if (!name) return E_INVALIDARG;
262 if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY;
264 impl->IHostName_iface.lpVtbl = &hostname_vtbl;
265 impl->ref = 1;
266 WindowsDuplicateString( name, &impl->raw_name );
268 *value = &impl->IHostName_iface;
269 TRACE( "created IHostName %p.\n", *value );
270 return S_OK;
273 static const struct IHostNameFactoryVtbl hostname_factory_vtbl =
275 hostname_factory_QueryInterface,
276 hostname_factory_AddRef,
277 hostname_factory_Release,
278 /* IInspectable methods */
279 hostname_factory_GetIids,
280 hostname_factory_GetRuntimeClassName,
281 hostname_factory_GetTrustLevel,
282 /* IHostNameFactory methods */
283 hostname_factory_CreateHostName,
286 static struct hostname_statics hostname_statics =
288 {&factory_vtbl},
289 {&hostname_factory_vtbl},
293 IActivationFactory *hostname_factory = &hostname_statics.IActivationFactory_iface;