2 * Gameux library coclass GameExplorer implementation
4 * Copyright (C) 2010 Mariusz PluciĆski
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "gameux_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(gameux
);
34 * GameExplorer implementation
37 typedef struct _GameExplorerImpl
39 const struct IGameExplorerVtbl
*lpGameExplorerVtbl
;
40 const struct IGameExplorer2Vtbl
*lpGameExplorer2Vtbl
;
44 static inline GameExplorerImpl
*impl_from_IGameExplorer(IGameExplorer
*iface
)
46 return (GameExplorerImpl
*)((char*)iface
- FIELD_OFFSET(GameExplorerImpl
, lpGameExplorerVtbl
));
49 static inline IGameExplorer
* IGameExplorer_from_impl(GameExplorerImpl
* This
)
51 return (struct IGameExplorer
*)&This
->lpGameExplorerVtbl
;
54 static inline GameExplorerImpl
*impl_from_IGameExplorer2(IGameExplorer2
*iface
)
56 return (GameExplorerImpl
*)((char*)iface
- FIELD_OFFSET(GameExplorerImpl
, lpGameExplorer2Vtbl
));
59 static inline IGameExplorer2
* IGameExplorer2_from_impl(GameExplorerImpl
* This
)
61 return (struct IGameExplorer2
*)&This
->lpGameExplorer2Vtbl
;
64 static HRESULT WINAPI
GameExplorerImpl_QueryInterface(
69 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
71 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppvObject
);
75 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
76 IsEqualGUID(riid
, &IID_IGameExplorer
))
78 *ppvObject
= IGameExplorer_from_impl(This
);
80 else if(IsEqualGUID(riid
, &IID_IGameExplorer2
))
82 *ppvObject
= IGameExplorer2_from_impl(This
);
86 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
90 IGameExplorer_AddRef(iface
);
94 static ULONG WINAPI
GameExplorerImpl_AddRef(IGameExplorer
*iface
)
96 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
99 ref
= InterlockedIncrement(&This
->ref
);
101 TRACE("(%p): ref=%d\n", This
, ref
);
105 static ULONG WINAPI
GameExplorerImpl_Release(IGameExplorer
*iface
)
107 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
110 ref
= InterlockedDecrement(&This
->ref
);
111 TRACE("(%p): ref=%d\n", This
, ref
);
115 TRACE("freeing GameExplorer object\n");
116 HeapFree(GetProcessHeap(), 0, This
);
122 static HRESULT WINAPI
GameExplorerImpl_AddGame(
123 IGameExplorer
*iface
,
124 BSTR bstrGDFBinaryPath
,
125 BSTR sGameInstallDirectory
,
126 GAME_INSTALL_SCOPE installScope
,
129 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
131 TRACE("(%p, %s, %s, %d, %s)\n", This
, debugstr_w(bstrGDFBinaryPath
), debugstr_w(sGameInstallDirectory
), installScope
, debugstr_guid(pInstanceID
));
136 static HRESULT WINAPI
GameExplorerImpl_RemoveGame(
137 IGameExplorer
*iface
,
140 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
142 TRACE("(%p, %s)\n", This
, debugstr_guid(&instanceID
));
147 static HRESULT WINAPI
GameExplorerImpl_UpdateGame(
148 IGameExplorer
*iface
,
151 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
153 TRACE("(%p, %s)\n", This
, debugstr_guid(&instanceID
));
158 static HRESULT WINAPI
GameExplorerImpl_VerifyAccess(
159 IGameExplorer
*iface
,
163 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
165 TRACE("(%p, %s, %p)\n", This
, debugstr_w(sGDFBinaryPath
), pHasAccess
);
170 static const struct IGameExplorerVtbl GameExplorerImplVtbl
=
172 GameExplorerImpl_QueryInterface
,
173 GameExplorerImpl_AddRef
,
174 GameExplorerImpl_Release
,
175 GameExplorerImpl_AddGame
,
176 GameExplorerImpl_RemoveGame
,
177 GameExplorerImpl_UpdateGame
,
178 GameExplorerImpl_VerifyAccess
182 static HRESULT WINAPI
GameExplorer2Impl_QueryInterface(
183 IGameExplorer2
*iface
,
187 GameExplorerImpl
*This
= impl_from_IGameExplorer2(iface
);
188 return GameExplorerImpl_QueryInterface(IGameExplorer_from_impl(This
), riid
, ppvObject
);
191 static ULONG WINAPI
GameExplorer2Impl_AddRef(IGameExplorer2
*iface
)
193 GameExplorerImpl
*This
= impl_from_IGameExplorer2(iface
);
194 return GameExplorerImpl_AddRef(IGameExplorer_from_impl(This
));
197 static ULONG WINAPI
GameExplorer2Impl_Release(IGameExplorer2
*iface
)
199 GameExplorerImpl
*This
= impl_from_IGameExplorer2(iface
);
200 return GameExplorerImpl_Release(IGameExplorer_from_impl(This
));
203 static HRESULT WINAPI
GameExplorer2Impl_CheckAccess(
204 IGameExplorer2
*iface
,
205 LPCWSTR binaryGDFPath
,
208 GameExplorerImpl
*This
= impl_from_IGameExplorer2(iface
);
209 FIXME("stub (%p, %s, %p)\n", This
, debugstr_w(binaryGDFPath
), pHasAccess
);
213 static HRESULT WINAPI
GameExplorer2Impl_InstallGame(
214 IGameExplorer2
*iface
,
215 LPCWSTR binaryGDFPath
,
216 LPCWSTR installDirectory
,
217 GAME_INSTALL_SCOPE installScope
)
219 GameExplorerImpl
*This
= impl_from_IGameExplorer2(iface
);
220 FIXME("stub (%p, %s, %s, 0x%x)\n", This
, debugstr_w(binaryGDFPath
), debugstr_w(installDirectory
), installScope
);
224 static HRESULT WINAPI
GameExplorer2Impl_UninstallGame(
225 IGameExplorer2
*iface
,
226 LPCWSTR binaryGDFPath
)
228 GameExplorerImpl
*This
= impl_from_IGameExplorer2(iface
);
229 FIXME("stub (%p, %s)\n", This
, debugstr_w(binaryGDFPath
));
233 static const struct IGameExplorer2Vtbl GameExplorer2ImplVtbl
=
235 GameExplorer2Impl_QueryInterface
,
236 GameExplorer2Impl_AddRef
,
237 GameExplorer2Impl_Release
,
238 GameExplorer2Impl_InstallGame
,
239 GameExplorer2Impl_UninstallGame
,
240 GameExplorer2Impl_CheckAccess
244 * Construction routine
246 HRESULT
GameExplorer_create(
250 GameExplorerImpl
*pGameExplorer
;
252 TRACE("(%p, %p)\n", pUnkOuter
, ppObj
);
254 pGameExplorer
= HeapAlloc(GetProcessHeap(), 0, sizeof(*pGameExplorer
));
257 return E_OUTOFMEMORY
;
259 pGameExplorer
->lpGameExplorerVtbl
= &GameExplorerImplVtbl
;
260 pGameExplorer
->lpGameExplorer2Vtbl
= &GameExplorer2ImplVtbl
;
261 pGameExplorer
->ref
= 1;
263 *ppObj
= (IUnknown
*)(&pGameExplorer
->lpGameExplorerVtbl
);
265 TRACE("returning iface: %p\n", *ppObj
);