Sync with trunk r62754.
[reactos.git] / dll / win32 / wuapi / systeminfo.c
1 /*
2 * IAutomaticUpdates implementation
3 *
4 * Copyright 2008 Hans Leidekker
5 * Copyright 2011 Bernhard Loos
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include "wuapi_private.h"
23
24 typedef struct _systeminfo
25 {
26 ISystemInformation ISystemInformation_iface;
27 LONG refs;
28 } systeminfo;
29
30 static inline systeminfo *impl_from_ISystemInformation(ISystemInformation *iface)
31 {
32 return CONTAINING_RECORD(iface, systeminfo, ISystemInformation_iface);
33 }
34
35 static ULONG WINAPI systeminfo_AddRef(ISystemInformation *iface)
36 {
37 systeminfo *This = impl_from_ISystemInformation(iface);
38 return InterlockedIncrement(&This->refs);
39 }
40
41 static ULONG WINAPI systeminfo_Release(ISystemInformation *iface)
42 {
43 systeminfo *This = impl_from_ISystemInformation(iface);
44 LONG refs = InterlockedDecrement(&This->refs);
45 if (!refs)
46 {
47 TRACE("destroying %p\n", This);
48 HeapFree(GetProcessHeap(), 0, This);
49 }
50 return refs;
51 }
52
53 static HRESULT WINAPI systeminfo_QueryInterface(ISystemInformation *iface,
54 REFIID riid, void **ppvObject)
55 {
56 systeminfo *This = impl_from_ISystemInformation(iface);
57
58 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
59
60 if (IsEqualGUID(riid, &IID_ISystemInformation) ||
61 IsEqualGUID(riid, &IID_IDispatch) ||
62 IsEqualGUID(riid, &IID_IUnknown))
63 {
64 *ppvObject = iface;
65 }
66 else
67 {
68 FIXME("interface %s not implemented\n", debugstr_guid(riid));
69 return E_NOINTERFACE;
70 }
71 ISystemInformation_AddRef(iface);
72 return S_OK;
73 }
74
75 static HRESULT WINAPI systeminfo_GetTypeInfoCount(ISystemInformation *iface,
76 UINT *pctinfo )
77 {
78 FIXME("\n");
79 return E_NOTIMPL;
80 }
81
82 static HRESULT WINAPI systeminfo_GetTypeInfo(ISystemInformation *iface,
83 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
84 {
85 FIXME("\n");
86 return E_NOTIMPL;
87 }
88
89 static HRESULT WINAPI systeminfo_GetIDsOfNames(ISystemInformation *iface,
90 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
91 DISPID *rgDispId)
92 {
93 FIXME("\n");
94 return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI systeminfo_Invoke(ISystemInformation *iface,
98 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
99 DISPPARAMS *pDispParams, VARIANT *pVarResult,
100 EXCEPINFO *pExcepInfo, UINT *puArgErr )
101 {
102 FIXME("\n");
103 return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI systeminfo_get_OemHardwareSupportLink(ISystemInformation *iface,
107 BSTR *retval)
108 {
109 FIXME("\n");
110 return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI systeminfo_get_RebootRequired(ISystemInformation *iface,
114 VARIANT_BOOL *retval)
115 {
116 *retval = VARIANT_FALSE;
117 return S_OK;
118 }
119
120 static const struct ISystemInformationVtbl systeminfo_vtbl =
121 {
122 systeminfo_QueryInterface,
123 systeminfo_AddRef,
124 systeminfo_Release,
125 systeminfo_GetTypeInfoCount,
126 systeminfo_GetTypeInfo,
127 systeminfo_GetIDsOfNames,
128 systeminfo_Invoke,
129 systeminfo_get_OemHardwareSupportLink,
130 systeminfo_get_RebootRequired
131 };
132
133 HRESULT SystemInformation_create(IUnknown *pUnkOuter, LPVOID *ppObj)
134 {
135 systeminfo *info;
136
137 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
138
139 info = HeapAlloc(GetProcessHeap(), 0, sizeof(*info));
140 if (!info)
141 return E_OUTOFMEMORY;
142
143 info->ISystemInformation_iface.lpVtbl = &systeminfo_vtbl;
144 info->refs = 1;
145
146 *ppObj = &info->ISystemInformation_iface;
147
148 TRACE("returning iface %p\n", *ppObj);
149 return S_OK;
150 }