xref: /reactos/dll/win32/wmvcore/wmvcore_main.c (revision 40462c92)
1 /*
2  * Copyright 2012 Austin English
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "wmvcore.h"
20 
21 #include "initguid.h"
22 #include "wmsdk.h"
23 #include "wine/debug.h"
24 #include "wine/heap.h"
25 
26 WINE_DEFAULT_DEBUG_CHANNEL(wmvcore);
27 
28 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
29 {
30     TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
31 
32     switch (fdwReason)
33     {
34         case DLL_WINE_PREATTACH:
35             return FALSE;    /* prefer native version */
36         case DLL_PROCESS_ATTACH:
37             DisableThreadLibraryCalls(hinstDLL);
38             break;
39     }
40 
41     return TRUE;
42 }
43 
44 HRESULT WINAPI DllRegisterServer(void)
45 {
46     FIXME("(): stub\n");
47 
48     return S_OK;
49 }
50 
51 HRESULT WINAPI WMCheckURLExtension(const WCHAR *url)
52 {
53     FIXME("(%s): stub\n", wine_dbgstr_w(url));
54 
55     if (!url)
56         return E_INVALIDARG;
57 
58     return NS_E_INVALID_NAME;
59 }
60 
61 HRESULT WINAPI WMCheckURLScheme(const WCHAR *scheme)
62 {
63     FIXME("(%s): stub\n", wine_dbgstr_w(scheme));
64 
65     return NS_E_INVALID_NAME;
66 }
67 
68 HRESULT WINAPI WMCreateEditor(IWMMetadataEditor **editor)
69 {
70     FIXME("(%p): stub\n", editor);
71 
72     *editor = NULL;
73 
74     return E_NOTIMPL;
75 }
76 
77 HRESULT WINAPI WMCreateBackupRestorer(IUnknown *callback, IWMLicenseBackup **licBackup)
78 {
79     FIXME("(%p %p): stub\n", callback, licBackup);
80 
81     if (!callback)
82         return E_INVALIDARG;
83 
84     *licBackup = NULL;
85 
86     return E_NOTIMPL;
87 }
88 
89 typedef struct {
90     IWMProfileManager2 IWMProfileManager2_iface;
91     LONG ref;
92 } WMProfileManager;
93 
94 static inline WMProfileManager *impl_from_IWMProfileManager2(IWMProfileManager2 *iface)
95 {
96     return CONTAINING_RECORD(iface, WMProfileManager, IWMProfileManager2_iface);
97 }
98 
99 static HRESULT WINAPI WMProfileManager_QueryInterface(IWMProfileManager2 *iface, REFIID riid, void **ppv)
100 {
101     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
102 
103     if(IsEqualGUID(&IID_IUnknown, riid)) {
104         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
105         *ppv = &This->IWMProfileManager2_iface;
106     }else if(IsEqualGUID(&IID_IWMProfileManager, riid)) {
107         TRACE("(%p)->(IID_IWMProfileManager %p)\n", This, ppv);
108         *ppv = &This->IWMProfileManager2_iface;
109     }else if(IsEqualGUID(&IID_IWMProfileManager2, riid)) {
110         TRACE("(%p)->(IID_IWMProfileManager2 %p)\n", This, ppv);
111         *ppv = &This->IWMProfileManager2_iface;
112     }else {
113         FIXME("Unsupported iface %s\n", debugstr_guid(riid));
114         *ppv = NULL;
115         return E_NOINTERFACE;
116     }
117 
118     IUnknown_AddRef((IUnknown*)*ppv);
119     return S_OK;
120 }
121 
122 static ULONG WINAPI WMProfileManager_AddRef(IWMProfileManager2 *iface)
123 {
124     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
125     LONG ref = InterlockedIncrement(&This->ref);
126 
127     TRACE("(%p) ref=%d\n", This, ref);
128 
129     return ref;
130 }
131 
132 static ULONG WINAPI WMProfileManager_Release(IWMProfileManager2 *iface)
133 {
134     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
135     LONG ref = InterlockedDecrement(&This->ref);
136 
137     TRACE("(%p) ref=%d\n", This, ref);
138 
139     if(!ref)
140         heap_free(This);
141 
142     return ref;
143 }
144 
145 static HRESULT WINAPI WMProfileManager_CreateEmptyProfile(IWMProfileManager2 *iface, WMT_VERSION version, IWMProfile **ret)
146 {
147     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
148     FIXME("(%p)->(%x %p)\n", This, version, ret);
149     return E_NOTIMPL;
150 }
151 
152 static HRESULT WINAPI WMProfileManager_LoadProfileByID(IWMProfileManager2 *iface, REFGUID guid, IWMProfile **ret)
153 {
154     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
155     FIXME("(%p)->(%s %p)\n", This, debugstr_guid(guid), ret);
156     return E_NOTIMPL;
157 }
158 
159 static HRESULT WINAPI WMProfileManager_LoadProfileByData(IWMProfileManager2 *iface, const WCHAR *profile, IWMProfile **ret)
160 {
161     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
162     FIXME("(%p)->(%s %p)\n", This, debugstr_w(profile), ret);
163     return E_NOTIMPL;
164 }
165 
166 static HRESULT WINAPI WMProfileManager_SaveProfile(IWMProfileManager2 *iface, IWMProfile *profile, WCHAR *profile_str, DWORD *len)
167 {
168     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
169     FIXME("(%p)->(%p %p %p)\n", This, profile, profile_str, len);
170     return E_NOTIMPL;
171 }
172 
173 static HRESULT WINAPI WMProfileManager_GetSystemProfileCount(IWMProfileManager2 *iface, DWORD *ret)
174 {
175     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
176     FIXME("(%p)->(%p)\n", This, ret);
177     return E_NOTIMPL;
178 }
179 
180 static HRESULT WINAPI WMProfileManager_LoadSystemProfile(IWMProfileManager2 *iface, DWORD index, IWMProfile **ret)
181 {
182     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
183     FIXME("(%p)->(%d %p)\n", This, index, ret);
184     return E_NOTIMPL;
185 }
186 
187 static HRESULT WINAPI WMProfileManager2_GetSystemProfileVersion(IWMProfileManager2 *iface, WMT_VERSION *version)
188 {
189     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
190     FIXME("(%p)->(%p)\n", This, version);
191     return E_NOTIMPL;
192 }
193 
194 static HRESULT WINAPI WMProfileManager2_SetSystemProfileVersion(IWMProfileManager2 *iface, WMT_VERSION version)
195 {
196     WMProfileManager *This = impl_from_IWMProfileManager2(iface);
197     FIXME("(%p)->(%x)\n", This, version);
198     return E_NOTIMPL;
199 }
200 
201 static const IWMProfileManager2Vtbl WMProfileManager2Vtbl = {
202     WMProfileManager_QueryInterface,
203     WMProfileManager_AddRef,
204     WMProfileManager_Release,
205     WMProfileManager_CreateEmptyProfile,
206     WMProfileManager_LoadProfileByID,
207     WMProfileManager_LoadProfileByData,
208     WMProfileManager_SaveProfile,
209     WMProfileManager_GetSystemProfileCount,
210     WMProfileManager_LoadSystemProfile,
211     WMProfileManager2_GetSystemProfileVersion,
212     WMProfileManager2_SetSystemProfileVersion
213 };
214 
215 HRESULT WINAPI WMCreateProfileManager(IWMProfileManager **ret)
216 {
217     WMProfileManager *profile_mgr;
218 
219     TRACE("(%p)\n", ret);
220 
221     profile_mgr = heap_alloc(sizeof(*profile_mgr));
222     if(!profile_mgr)
223         return E_OUTOFMEMORY;
224 
225     profile_mgr->IWMProfileManager2_iface.lpVtbl = &WMProfileManager2Vtbl;
226     profile_mgr->ref = 1;
227 
228     *ret = (IWMProfileManager *)&profile_mgr->IWMProfileManager2_iface;
229     return S_OK;
230 }
231