oledlg: Update the Polish translation.
[wine] / dlls / gameux / gamestatistics.c
1 /*
2  *    Gameux library coclass GameStatistics implementation
3  *
4  * Copyright (C) 2010 Mariusz PluciƄski
5  *
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.
10  *
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.
15  *
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
19  */
20 #define COBJMACROS
21
22 #include "config.h"
23
24 #include "ole2.h"
25
26 #include "gameux.h"
27 #include "gameux_private.h"
28
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(gameux);
32
33 /*
34  * IGameStatisticsMgr implementation
35  */
36
37 typedef struct _GameStatisticsMgrImpl
38 {
39     const struct IGameStatisticsMgrVtbl *lpVtbl;
40     LONG ref;
41 } GameStatisticsMgrImpl;
42
43 static inline GameStatisticsMgrImpl *impl_from_IGameStatisticsMgr( IGameStatisticsMgr *iface )
44 {
45     return (GameStatisticsMgrImpl *)((char*)iface - FIELD_OFFSET(GameStatisticsMgrImpl, lpVtbl));
46 }
47
48
49 static HRESULT WINAPI GameStatisticsMgrImpl_QueryInterface(
50         IGameStatisticsMgr *iface,
51         REFIID riid,
52         void **ppvObject)
53 {
54     GameStatisticsMgrImpl *This = impl_from_IGameStatisticsMgr( iface );
55
56     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
57
58     *ppvObject = NULL;
59
60     if(IsEqualGUID(riid, &IID_IUnknown) ||
61        IsEqualGUID(riid, &IID_IGameStatisticsMgr) )
62     {
63         *ppvObject = iface;
64     }
65     else
66     {
67         FIXME("interface %s not implemented\n", debugstr_guid(riid));
68         return E_NOINTERFACE;
69     }
70
71     IGameStatisticsMgr_AddRef( iface );
72     return S_OK;
73 }
74
75 static ULONG WINAPI GameStatisticsMgrImpl_AddRef(IGameStatisticsMgr *iface)
76 {
77     GameStatisticsMgrImpl *This = impl_from_IGameStatisticsMgr( iface );
78     LONG ref;
79
80     ref = InterlockedIncrement(&This->ref);
81
82     TRACE("(%p): ref=%d\n", This, ref);
83     return ref;
84 }
85
86 static ULONG WINAPI GameStatisticsMgrImpl_Release(IGameStatisticsMgr *iface)
87 {
88     GameStatisticsMgrImpl *This = impl_from_IGameStatisticsMgr( iface );
89     LONG ref;
90
91     ref = InterlockedDecrement(&This->ref);
92     TRACE("(%p): ref=%d\n", This, ref);
93
94     if ( ref == 0 )
95     {
96         TRACE("freeing GameStatistics object\n");
97         HeapFree( GetProcessHeap(), 0, This);
98     }
99
100     return ref;
101 }
102
103 static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_GetGameStatistics(
104         IGameStatisticsMgr* iface,
105         LPCWSTR GDFBinaryPath,
106         GAMESTATS_OPEN_TYPE openType,
107         GAMESTATS_OPEN_RESULT *pOpenResult,
108         IGameStatistics **ppiStats)
109 {
110     FIXME("stub (%p, %s, 0x%x, %p, %p)\n", iface, debugstr_w(GDFBinaryPath), openType, pOpenResult, ppiStats);
111     return E_NOTIMPL;
112 }
113
114 static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_RemoveGameStatistics(
115         IGameStatisticsMgr* iface,
116         LPCWSTR GDFBinaryPath)
117 {
118     FIXME("stub (%p, %s)\n", iface, debugstr_w(GDFBinaryPath));
119     return E_NOTIMPL;
120 }
121
122 static const struct IGameStatisticsMgrVtbl GameStatisticsMgrImplVtbl =
123 {
124     GameStatisticsMgrImpl_QueryInterface,
125     GameStatisticsMgrImpl_AddRef,
126     GameStatisticsMgrImpl_Release,
127     GameStatisticsMgrImpl_GetGameStatistics,
128     GameStatisticsMgrImpl_RemoveGameStatistics,
129 };
130
131 HRESULT GameStatistics_create(
132         IUnknown *pUnkOuter,
133         IUnknown **ppObj)
134 {
135     GameStatisticsMgrImpl *pGameStatistics;
136
137     TRACE("(%p, %p)\n", pUnkOuter, ppObj);
138
139     pGameStatistics = HeapAlloc( GetProcessHeap(), 0, sizeof (*pGameStatistics) );
140
141     if( !pGameStatistics )
142         return E_OUTOFMEMORY;
143
144     pGameStatistics->lpVtbl = &GameStatisticsMgrImplVtbl;
145     pGameStatistics->ref = 1;
146
147     *ppObj = (IUnknown*)(&pGameStatistics->lpVtbl);
148
149     TRACE("returning iface %p\n", *ppObj);
150     return S_OK;
151 }