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 * IGameExplorer implementation
37 typedef struct _GameExplorerImpl
39 const struct IGameExplorerVtbl
*lpGameExplorerVtbl
;
43 static inline GameExplorerImpl
*impl_from_IGameExplorer(IGameExplorer
*iface
)
45 return (GameExplorerImpl
*)((char*)iface
- FIELD_OFFSET(GameExplorerImpl
, lpGameExplorerVtbl
));
48 static HRESULT WINAPI
GameExplorerImpl_QueryInterface(
53 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
55 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppvObject
);
59 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
60 IsEqualGUID(riid
, &IID_IGameExplorer
))
66 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
70 IGameExplorer_AddRef(iface
);
74 static ULONG WINAPI
GameExplorerImpl_AddRef(IGameExplorer
*iface
)
76 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
79 ref
= InterlockedIncrement(&This
->ref
);
81 TRACE("(%p): ref=%d\n", This
, ref
);
85 static ULONG WINAPI
GameExplorerImpl_Release(IGameExplorer
*iface
)
87 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
90 ref
= InterlockedDecrement(&This
->ref
);
91 TRACE("(%p): ref=%d\n", This
, ref
);
95 TRACE("freeing GameExplorer object\n");
96 HeapFree(GetProcessHeap(), 0, This
);
102 static HRESULT WINAPI
GameExplorerImpl_AddGame(
103 IGameExplorer
*iface
,
104 BSTR bstrGDFBinaryPath
,
105 BSTR sGameInstallDirectory
,
106 GAME_INSTALL_SCOPE installScope
,
109 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
111 TRACE("(%p, %s, %s, %d, %s)\n", This
, debugstr_w(bstrGDFBinaryPath
), debugstr_w(sGameInstallDirectory
), installScope
, debugstr_guid(pInstanceID
));
116 static HRESULT WINAPI
GameExplorerImpl_RemoveGame(
117 IGameExplorer
*iface
,
120 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
122 TRACE("(%p, %s)\n", This
, debugstr_guid(&instanceID
));
127 static HRESULT WINAPI
GameExplorerImpl_UpdateGame(
128 IGameExplorer
*iface
,
131 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
133 TRACE("(%p, %s)\n", This
, debugstr_guid(&instanceID
));
138 static HRESULT WINAPI
GameExplorerImpl_VerifyAccess(
139 IGameExplorer
*iface
,
143 GameExplorerImpl
*This
= impl_from_IGameExplorer(iface
);
145 TRACE("(%p, %s, %p)\n", This
, debugstr_w(sGDFBinaryPath
), pHasAccess
);
150 static const struct IGameExplorerVtbl GameExplorerImplVtbl
=
152 GameExplorerImpl_QueryInterface
,
153 GameExplorerImpl_AddRef
,
154 GameExplorerImpl_Release
,
155 GameExplorerImpl_AddGame
,
156 GameExplorerImpl_RemoveGame
,
157 GameExplorerImpl_UpdateGame
,
158 GameExplorerImpl_VerifyAccess
162 * Construction routine
164 HRESULT
GameExplorer_create(
168 GameExplorerImpl
*pGameExplorer
;
170 TRACE("(%p, %p)\n", pUnkOuter
, ppObj
);
172 pGameExplorer
= HeapAlloc(GetProcessHeap(), 0, sizeof(*pGameExplorer
));
175 return E_OUTOFMEMORY
;
177 pGameExplorer
->lpGameExplorerVtbl
= &GameExplorerImplVtbl
;
178 pGameExplorer
->ref
= 1;
180 *ppObj
= (IUnknown
*)(&pGameExplorer
->lpGameExplorerVtbl
);
182 TRACE("returning iface: %p\n", *ppObj
);