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