Branching for 0.3.15 release after two days of no response from a certain sphere...
[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 #define WIN32_NO_STATUS
23 #define _INC_WINDOWS
24
25 #define COBJMACROS
26
27 #include <config.h>
28 #include <stdarg.h>
29
30 #include <windef.h>
31 #include <winbase.h>
32 //#include "winuser.h"
33 #include <ole2.h>
34 #include <wuapi.h>
35
36 #include <wine/debug.h>
37
38 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
39
40 typedef struct _systeminfo
41 {
42 ISystemInformation ISystemInformation_iface;
43 LONG refs;
44 } systeminfo;
45
46 static inline systeminfo *impl_from_ISystemInformation(ISystemInformation *iface)
47 {
48 return CONTAINING_RECORD(iface, systeminfo, ISystemInformation_iface);
49 }
50
51 static ULONG WINAPI systeminfo_AddRef(ISystemInformation *iface)
52 {
53 systeminfo *This = impl_from_ISystemInformation(iface);
54 return InterlockedIncrement(&This->refs);
55 }
56
57 static ULONG WINAPI systeminfo_Release(ISystemInformation *iface)
58 {
59 systeminfo *This = impl_from_ISystemInformation(iface);
60 LONG refs = InterlockedDecrement(&This->refs);
61 if (!refs)
62 {
63 TRACE("destroying %p\n", This);
64 HeapFree(GetProcessHeap(), 0, This);
65 }
66 return refs;
67 }
68
69 static HRESULT WINAPI systeminfo_QueryInterface(ISystemInformation *iface,
70 REFIID riid, void **ppvObject)
71 {
72 systeminfo *This = impl_from_ISystemInformation(iface);
73
74 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
75
76 if (IsEqualGUID(riid, &IID_ISystemInformation) ||
77 IsEqualGUID(riid, &IID_IDispatch) ||
78 IsEqualGUID(riid, &IID_IUnknown))
79 {
80 *ppvObject = iface;
81 }
82 else
83 {
84 FIXME("interface %s not implemented\n", debugstr_guid(riid));
85 return E_NOINTERFACE;
86 }
87 ISystemInformation_AddRef(iface);
88 return S_OK;
89 }
90
91 static HRESULT WINAPI systeminfo_GetTypeInfoCount(ISystemInformation *iface,
92 UINT *pctinfo )
93 {
94 FIXME("\n");
95 return E_NOTIMPL;
96 }
97
98 static HRESULT WINAPI systeminfo_GetTypeInfo(ISystemInformation *iface,
99 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
100 {
101 FIXME("\n");
102 return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI systeminfo_GetIDsOfNames(ISystemInformation *iface,
106 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
107 DISPID *rgDispId)
108 {
109 FIXME("\n");
110 return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI systeminfo_Invoke(ISystemInformation *iface,
114 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
115 DISPPARAMS *pDispParams, VARIANT *pVarResult,
116 EXCEPINFO *pExcepInfo, UINT *puArgErr )
117 {
118 FIXME("\n");
119 return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI systeminfo_get_OemHardwareSupportLink(ISystemInformation *iface,
123 BSTR *retval)
124 {
125 FIXME("\n");
126 return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI systeminfo_get_RebootRequired(ISystemInformation *iface,
130 VARIANT_BOOL *retval)
131 {
132 *retval = VARIANT_FALSE;
133 return S_OK;
134 }
135
136 static const struct ISystemInformationVtbl systeminfo_vtbl =
137 {
138 systeminfo_QueryInterface,
139 systeminfo_AddRef,
140 systeminfo_Release,
141 systeminfo_GetTypeInfoCount,
142 systeminfo_GetTypeInfo,
143 systeminfo_GetIDsOfNames,
144 systeminfo_Invoke,
145 systeminfo_get_OemHardwareSupportLink,
146 systeminfo_get_RebootRequired
147 };
148
149 HRESULT SystemInformation_create(IUnknown *pUnkOuter, LPVOID *ppObj)
150 {
151 systeminfo *info;
152
153 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
154
155 info = HeapAlloc(GetProcessHeap(), 0, sizeof(*info));
156 if (!info)
157 return E_OUTOFMEMORY;
158
159 info->ISystemInformation_iface.lpVtbl = &systeminfo_vtbl;
160 info->refs = 1;
161
162 *ppObj = &info->ISystemInformation_iface;
163
164 TRACE("returning iface %p\n", *ppObj);
165 return S_OK;
166 }