1 /* WinRT Windows.Globalization implementation
3 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
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
22 WINE_DEFAULT_DEBUG_CHANNEL(locale
);
24 struct geographic_region
26 IGeographicRegion IGeographicRegion_iface
;
30 static inline struct geographic_region
*impl_from_IGeographicRegion( IGeographicRegion
*iface
)
32 return CONTAINING_RECORD( iface
, struct geographic_region
, IGeographicRegion_iface
);
35 static HRESULT WINAPI
geographic_region_QueryInterface( IGeographicRegion
*iface
, REFIID iid
, void **out
)
37 struct geographic_region
*impl
= impl_from_IGeographicRegion( iface
);
39 TRACE( "iface %p, iid %s, out %p.\n", iface
, debugstr_guid( iid
), out
);
41 if (IsEqualGUID( iid
, &IID_IUnknown
) ||
42 IsEqualGUID( iid
, &IID_IInspectable
) ||
43 IsEqualGUID( iid
, &IID_IAgileObject
) ||
44 IsEqualGUID( iid
, &IID_IGeographicRegion
))
46 IInspectable_AddRef( (*out
= &impl
->IGeographicRegion_iface
) );
50 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
55 static ULONG WINAPI
geographic_region_AddRef( IGeographicRegion
*iface
)
57 struct geographic_region
*impl
= impl_from_IGeographicRegion( iface
);
58 ULONG ref
= InterlockedIncrement( &impl
->ref
);
59 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
63 static ULONG WINAPI
geographic_region_Release( IGeographicRegion
*iface
)
65 struct geographic_region
*impl
= impl_from_IGeographicRegion( iface
);
66 ULONG ref
= InterlockedDecrement( &impl
->ref
);
67 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
68 if (!ref
) free( impl
);
72 static HRESULT WINAPI
geographic_region_GetIids( IGeographicRegion
*iface
, ULONG
*iid_count
, IID
**iids
)
74 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
78 static HRESULT WINAPI
geographic_region_GetRuntimeClassName( IGeographicRegion
*iface
, HSTRING
*class_name
)
80 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
84 static HRESULT WINAPI
geographic_region_GetTrustLevel( IGeographicRegion
*iface
, TrustLevel
*trust_level
)
86 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
90 static HRESULT WINAPI
geographic_region_get_Code( IGeographicRegion
*iface
, HSTRING
*value
)
92 FIXME( "iface %p stub!\n", iface
);
96 static HRESULT WINAPI
geographic_region_get_CodeTwoLetter( IGeographicRegion
*iface
, HSTRING
*value
)
98 WCHAR buffer
[LOCALE_NAME_MAX_LENGTH
];
100 FIXME( "iface %p semi-stub!\n", iface
);
102 if (!GetLocaleInfoEx( LOCALE_NAME_USER_DEFAULT
, LOCALE_SISO3166CTRYNAME
, buffer
, ARRAY_SIZE(buffer
) )) return E_INVALIDARG
;
103 return WindowsCreateString( buffer
, wcslen( buffer
), value
);
106 static HRESULT WINAPI
geographic_region_get_CodeThreeLetter( IGeographicRegion
*iface
, HSTRING
*value
)
108 FIXME( "iface %p stub!\n", iface
);
112 static HRESULT WINAPI
geographic_region_get_CodeThreeDigit( IGeographicRegion
*iface
, HSTRING
*value
)
114 FIXME( "iface %p stub!\n", iface
);
118 static HRESULT WINAPI
geographic_region_get_DisplayName( IGeographicRegion
*iface
, HSTRING
*value
)
120 FIXME( "iface %p stub!\n", iface
);
124 static HRESULT WINAPI
geographic_region_get_NativeName( IGeographicRegion
*iface
, HSTRING
*value
)
126 FIXME( "iface %p stub!\n", iface
);
130 static HRESULT WINAPI
geographic_region_get_CurrenciesInUse( IGeographicRegion
*iface
, IVectorView_HSTRING
**value
)
132 FIXME( "iface %p stub!\n", iface
);
136 static const struct IGeographicRegionVtbl geographic_region_vtbl
=
138 geographic_region_QueryInterface
,
139 geographic_region_AddRef
,
140 geographic_region_Release
,
141 /* IInspectable methods */
142 geographic_region_GetIids
,
143 geographic_region_GetRuntimeClassName
,
144 geographic_region_GetTrustLevel
,
145 /* IGeographicRegion methods */
146 geographic_region_get_Code
,
147 geographic_region_get_CodeTwoLetter
,
148 geographic_region_get_CodeThreeLetter
,
149 geographic_region_get_CodeThreeDigit
,
150 geographic_region_get_DisplayName
,
151 geographic_region_get_NativeName
,
152 geographic_region_get_CurrenciesInUse
,
155 struct geographic_region_factory
157 IActivationFactory IActivationFactory_iface
;
158 IGeographicRegionFactory IGeographicRegionFactory_iface
;
162 static inline struct geographic_region_factory
*impl_from_IActivationFactory( IActivationFactory
*iface
)
164 return CONTAINING_RECORD( iface
, struct geographic_region_factory
, IActivationFactory_iface
);
167 static HRESULT WINAPI
activation_factory_QueryInterface( IActivationFactory
*iface
, REFIID iid
, void **out
)
169 struct geographic_region_factory
*factory
= impl_from_IActivationFactory( iface
);
171 TRACE( "iface %p, iid %s, out %p.\n", iface
, debugstr_guid( iid
), out
);
173 if (IsEqualGUID( iid
, &IID_IUnknown
) ||
174 IsEqualGUID( iid
, &IID_IInspectable
) ||
175 IsEqualGUID( iid
, &IID_IAgileObject
) ||
176 IsEqualGUID( iid
, &IID_IActivationFactory
))
178 IActivationFactory_AddRef( (*out
= &factory
->IActivationFactory_iface
) );
182 if (IsEqualGUID( iid
, &IID_IGeographicRegionFactory
))
184 IGeographicRegionFactory_AddRef( (*out
= &factory
->IGeographicRegionFactory_iface
) );
188 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
190 return E_NOINTERFACE
;
193 static ULONG WINAPI
activation_factory_AddRef( IActivationFactory
*iface
)
195 struct geographic_region_factory
*impl
= impl_from_IActivationFactory( iface
);
196 ULONG ref
= InterlockedIncrement( &impl
->ref
);
197 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
201 static ULONG WINAPI
activation_factory_Release( IActivationFactory
*iface
)
203 struct geographic_region_factory
*impl
= impl_from_IActivationFactory( iface
);
204 ULONG ref
= InterlockedDecrement( &impl
->ref
);
205 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
209 static HRESULT WINAPI
activation_factory_GetIids( IActivationFactory
*iface
, ULONG
*iid_count
, IID
**iids
)
211 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
215 static HRESULT WINAPI
activation_factory_GetRuntimeClassName( IActivationFactory
*iface
, HSTRING
*class_name
)
217 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
221 static HRESULT WINAPI
activation_factory_GetTrustLevel( IActivationFactory
*iface
, TrustLevel
*trust_level
)
223 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
227 static HRESULT WINAPI
activation_factory_ActivateInstance( IActivationFactory
*iface
, IInspectable
**out
)
229 struct geographic_region
*region
;
231 TRACE( "iface %p, out %p.\n", iface
, out
);
233 if (!(region
= calloc( 1, sizeof(*region
) ))) return E_OUTOFMEMORY
;
234 region
->IGeographicRegion_iface
.lpVtbl
= &geographic_region_vtbl
;
237 *out
= (IInspectable
*)®ion
->IGeographicRegion_iface
;
241 static const struct IActivationFactoryVtbl activation_factory_vtbl
=
243 activation_factory_QueryInterface
,
244 activation_factory_AddRef
,
245 activation_factory_Release
,
246 /* IInspectable methods */
247 activation_factory_GetIids
,
248 activation_factory_GetRuntimeClassName
,
249 activation_factory_GetTrustLevel
,
250 /* IActivationFactory methods */
251 activation_factory_ActivateInstance
,
254 DEFINE_IINSPECTABLE( geographic_region_factory
, IGeographicRegionFactory
, struct geographic_region_factory
, IActivationFactory_iface
)
256 static HRESULT WINAPI
geographic_region_factory_CreateGeographicRegion( IGeographicRegionFactory
*iface
, HSTRING code
,
257 IGeographicRegion
**value
)
259 FIXME( "iface %p, code %p, value %p stub!\n", iface
, code
, value
);
263 static const struct IGeographicRegionFactoryVtbl geographic_region_factory_vtbl
=
265 geographic_region_factory_QueryInterface
,
266 geographic_region_factory_AddRef
,
267 geographic_region_factory_Release
,
268 /* IInspectable methods */
269 geographic_region_factory_GetIids
,
270 geographic_region_factory_GetRuntimeClassName
,
271 geographic_region_factory_GetTrustLevel
,
272 /* IGeographicRegionFactory methods */
273 geographic_region_factory_CreateGeographicRegion
,
276 static struct geographic_region_factory factory
=
278 {&activation_factory_vtbl
},
279 {&geographic_region_factory_vtbl
},
283 IActivationFactory
*geographic_region_factory
= &factory
.IActivationFactory_iface
;