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
21 #include "wine/debug.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(hostname
);
25 struct hostname_statics
27 IActivationFactory IActivationFactory_iface
;
28 IHostNameFactory IHostNameFactory_iface
;
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
);
53 if (IsEqualGUID( iid
, &IID_IHostNameFactory
))
55 *out
= &impl
->IHostNameFactory_iface
;
56 IInspectable_AddRef( *out
);
60 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
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
);
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
);
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
);
87 static HRESULT WINAPI
factory_GetRuntimeClassName( IActivationFactory
*iface
, HSTRING
*class_name
)
89 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
93 static HRESULT WINAPI
factory_GetTrustLevel( IActivationFactory
*iface
, TrustLevel
*trust_level
)
95 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
99 static HRESULT WINAPI
factory_ActivateInstance( IActivationFactory
*iface
, IInspectable
**instance
)
101 FIXME( "iface %p, instance %p stub!\n", iface
, instance
);
105 static const struct IActivationFactoryVtbl factory_vtbl
=
107 factory_QueryInterface
,
110 /* IInspectable methods */
112 factory_GetRuntimeClassName
,
113 factory_GetTrustLevel
,
114 /* IActivationFactory methods */
115 factory_ActivateInstance
,
120 IHostName IHostName_iface
;
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
);
147 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
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
);
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
);
169 WindowsDeleteString( impl
->raw_name
);
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
);
182 static HRESULT WINAPI
hostname_GetRuntimeClassName( IHostName
*iface
, HSTRING
*class_name
)
184 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
188 static HRESULT WINAPI
hostname_GetTrustLevel( IHostName
*iface
, TrustLevel
*trust_level
)
190 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
194 static HRESULT WINAPI
hostname_get_IPInformation( IHostName
*iface
, IIPInformation
**value
)
196 FIXME( "iface %p, value %p stub!\n", iface
, value
);
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
);
216 static HRESULT WINAPI
hostname_get_CanonicalName( IHostName
*iface
, HSTRING
*value
)
218 FIXME( "iface %p, value %p stub!\n", iface
, value
);
222 static HRESULT WINAPI
hostname_get_Type( IHostName
*iface
, HostNameType
*value
)
224 FIXME( "iface %p, value %p stub!\n", iface
, value
);
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
);
234 static const struct IHostNameVtbl hostname_vtbl
=
236 hostname_QueryInterface
,
239 /* IInspectable methods */
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
,
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
;
266 WindowsDuplicateString( name
, &impl
->raw_name
);
268 *value
= &impl
->IHostName_iface
;
269 TRACE( "created IHostName %p.\n", *value
);
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
=
289 {&hostname_factory_vtbl
},
293 IActivationFactory
*hostname_factory
= &hostname_statics
.IActivationFactory_iface
;