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
24 WINE_DEFAULT_DEBUG_CHANNEL(twinapi
);
26 struct analytics_version_info
28 IAnalyticsVersionInfo IAnalyticsVersionInfo_iface
;
32 static inline struct analytics_version_info
*impl_from_IAnalyticsVersionInfo( IAnalyticsVersionInfo
*iface
)
34 return CONTAINING_RECORD( iface
, struct analytics_version_info
, IAnalyticsVersionInfo_iface
);
37 static HRESULT WINAPI
analytics_version_info_QueryInterface( IAnalyticsVersionInfo
*iface
, REFIID iid
, void **out
)
39 struct analytics_version_info
*impl
= impl_from_IAnalyticsVersionInfo( 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_IAnalyticsVersionInfo
))
48 IAnalyticsVersionInfo_AddRef( (*out
= &impl
->IAnalyticsVersionInfo_iface
) );
52 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
57 static ULONG WINAPI
analytics_version_info_AddRef( IAnalyticsVersionInfo
*iface
)
59 struct analytics_version_info
*impl
= impl_from_IAnalyticsVersionInfo( iface
);
60 ULONG ref
= InterlockedIncrement( &impl
->ref
);
61 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
65 static ULONG WINAPI
analytics_version_info_Release( IAnalyticsVersionInfo
*iface
)
67 struct analytics_version_info
*impl
= impl_from_IAnalyticsVersionInfo( iface
);
68 ULONG ref
= InterlockedDecrement( &impl
->ref
);
69 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
70 if (!ref
) free( impl
);
74 static HRESULT WINAPI
analytics_version_info_GetIids( IAnalyticsVersionInfo
*iface
, ULONG
*iid_count
, IID
**iids
)
76 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
80 static HRESULT WINAPI
analytics_version_info_GetRuntimeClassName( IAnalyticsVersionInfo
*iface
, HSTRING
*class_name
)
82 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
86 static HRESULT WINAPI
analytics_version_info_GetTrustLevel( IAnalyticsVersionInfo
*iface
, TrustLevel
*trust_level
)
88 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
92 static HRESULT WINAPI
analytics_version_info_get_DeviceFamily( IAnalyticsVersionInfo
*iface
, HSTRING
*value
)
94 TRACE( "iface %p, value %p\n", iface
, value
);
95 return WindowsCreateString( L
"Windows.Desktop", wcslen( L
"Windows.Desktop" ), value
);
98 static HRESULT WINAPI
analytics_version_info_get_DeviceFamilyVersion( IAnalyticsVersionInfo
*iface
, HSTRING
*value
)
100 DWORD revision
, size
;
105 TRACE( "iface %p, value %p\n", iface
, value
);
107 if (RegGetValueW( HKEY_LOCAL_MACHINE
, L
"Software\\Microsoft\\Windows NT\\CurrentVersion", L
"UBR",
108 RRF_RT_REG_DWORD
, NULL
, &revision
, &size
))
110 version
= NtCurrentTeb()->Peb
->OSMajorVersion
& 0xffff;
111 version
= (version
<< 16) | (NtCurrentTeb()->Peb
->OSMinorVersion
& 0xffff);
112 version
= (version
<< 16) | (NtCurrentTeb()->Peb
->OSBuildNumber
& 0xffff);
113 version
= (version
<< 16) | revision
;
115 len
= swprintf( buffer
, ARRAY_SIZE(buffer
), L
"%I64u", version
);
116 return WindowsCreateString( buffer
, len
, value
);
119 static IAnalyticsVersionInfoVtbl analytics_version_info_vtbl
=
121 analytics_version_info_QueryInterface
,
122 analytics_version_info_AddRef
,
123 analytics_version_info_Release
,
124 /* IInspectable methods */
125 analytics_version_info_GetIids
,
126 analytics_version_info_GetRuntimeClassName
,
127 analytics_version_info_GetTrustLevel
,
128 /* IAnalyticsVersionInfo methods */
129 analytics_version_info_get_DeviceFamily
,
130 analytics_version_info_get_DeviceFamilyVersion
,
133 struct analytics_info_factory
135 IActivationFactory IActivationFactory_iface
;
136 IAnalyticsInfoStatics IAnalyticsInfoStatics_iface
;
140 static inline struct analytics_info_factory
*impl_from_IActivationFactory( IActivationFactory
*iface
)
142 return CONTAINING_RECORD( iface
, struct analytics_info_factory
, IActivationFactory_iface
);
145 static HRESULT WINAPI
activation_factory_QueryInterface( IActivationFactory
*iface
, REFIID iid
, void **out
)
147 struct analytics_info_factory
*impl
= impl_from_IActivationFactory( iface
);
149 TRACE( "iface %p, iid %s, out %p.\n", iface
, debugstr_guid( iid
), out
);
151 if (IsEqualGUID( iid
, &IID_IUnknown
) ||
152 IsEqualGUID( iid
, &IID_IInspectable
) ||
153 IsEqualGUID( iid
, &IID_IAgileObject
) ||
154 IsEqualGUID( iid
, &IID_IActivationFactory
))
156 IActivationFactory_AddRef( (*out
= &impl
->IActivationFactory_iface
) );
160 if (IsEqualGUID( iid
, &IID_IAnalyticsInfoStatics
))
162 IAnalyticsInfoStatics_AddRef( (*out
= &impl
->IAnalyticsInfoStatics_iface
) );
166 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
168 return E_NOINTERFACE
;
171 static ULONG WINAPI
activation_factory_AddRef( IActivationFactory
*iface
)
173 struct analytics_info_factory
*impl
= impl_from_IActivationFactory( iface
);
174 ULONG ref
= InterlockedIncrement( &impl
->ref
);
175 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
179 static ULONG WINAPI
activation_factory_Release( IActivationFactory
*iface
)
181 struct analytics_info_factory
*impl
= impl_from_IActivationFactory( iface
);
182 ULONG ref
= InterlockedDecrement( &impl
->ref
);
183 TRACE( "iface %p, ref %lu.\n", iface
, ref
);
187 static HRESULT WINAPI
activation_factory_GetIids( IActivationFactory
*iface
, ULONG
*iid_count
, IID
**iids
)
189 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
193 static HRESULT WINAPI
activation_factory_GetRuntimeClassName( IActivationFactory
*iface
, HSTRING
*class_name
)
195 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
199 static HRESULT WINAPI
activation_factory_GetTrustLevel( IActivationFactory
*iface
, TrustLevel
*trust_level
)
201 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
205 static HRESULT WINAPI
activation_factory_ActivateInstance( IActivationFactory
*iface
, IInspectable
**out
)
207 FIXME( "iface %p, out %p stub!\n", iface
, out
);
211 static const struct IActivationFactoryVtbl activation_factory_vtbl
=
213 activation_factory_QueryInterface
,
214 activation_factory_AddRef
,
215 activation_factory_Release
,
216 /* IInspectable methods */
217 activation_factory_GetIids
,
218 activation_factory_GetRuntimeClassName
,
219 activation_factory_GetTrustLevel
,
220 /* IActivationFactory methods */
221 activation_factory_ActivateInstance
,
224 DEFINE_IINSPECTABLE( statics
, IAnalyticsInfoStatics
, struct analytics_info_factory
, IActivationFactory_iface
);
226 static HRESULT WINAPI
statics_get_VersionInfo( IAnalyticsInfoStatics
*iface
, IAnalyticsVersionInfo
**value
)
228 struct analytics_version_info
*info
;
230 TRACE( "iface %p, out %p.\n", iface
, value
);
232 if (!(info
= calloc( 1, sizeof(*info
) ))) return E_OUTOFMEMORY
;
233 info
->IAnalyticsVersionInfo_iface
.lpVtbl
= &analytics_version_info_vtbl
;
236 *value
= &info
->IAnalyticsVersionInfo_iface
;
240 static HRESULT WINAPI
statics_get_DeviceForm( IAnalyticsInfoStatics
*iface
, HSTRING
*value
)
242 FIXME( "iface %p, value %p stub!\n", iface
, value
);
246 static const struct IAnalyticsInfoStaticsVtbl statics_vtbl
=
248 statics_QueryInterface
,
251 /* IInspectable methods */
253 statics_GetRuntimeClassName
,
254 statics_GetTrustLevel
,
255 /* IAnalyticsInfoStatics methods */
256 statics_get_VersionInfo
,
257 statics_get_DeviceForm
,
260 static struct analytics_info_factory factory
=
262 {&activation_factory_vtbl
},
267 IActivationFactory
*analytics_info_factory
= &factory
.IActivationFactory_iface
;