[CLT2012]
[reactos.git] / dll / win32 / pstorec / pstorec.c
1 /*
2 * Protected Storage (pstores)
3 *
4 * Copyright 2004 Mike McCormack for CodeWeavers
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
21 #include <stdarg.h>
22
23 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "pstore.h"
29
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(pstores);
33
34 typedef struct
35 {
36 const IPStoreVtbl *lpVtbl;
37 LONG ref;
38 } PStore_impl;
39
40 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
41 {
42 TRACE("%p %x %p\n", hinst, fdwReason, fImpLoad);
43
44 switch (fdwReason)
45 {
46 case DLL_WINE_PREATTACH:
47 return FALSE; /* prefer native version */
48 case DLL_PROCESS_ATTACH:
49 DisableThreadLibraryCalls(hinst);
50 break;
51 case DLL_PROCESS_DETACH:
52 break;
53 }
54 return TRUE;
55 }
56
57 /**************************************************************************
58 * IPStore->QueryInterface
59 */
60 static HRESULT WINAPI PStore_fnQueryInterface(
61 IPStore* iface,
62 REFIID riid,
63 LPVOID *ppvObj)
64 {
65 PStore_impl *This = (PStore_impl *)iface;
66
67 TRACE("%p %s\n",This,debugstr_guid(riid));
68
69 *ppvObj = NULL;
70
71 if (IsEqualIID(riid, &IID_IUnknown))
72 {
73 *ppvObj = This;
74 }
75
76 if (*ppvObj)
77 {
78 IUnknown_AddRef((IUnknown*)(*ppvObj));
79 return S_OK;
80 }
81 TRACE("-- Interface: E_NOINTERFACE\n");
82 return E_NOINTERFACE;
83 }
84
85 /******************************************************************************
86 * IPStore->AddRef
87 */
88 static ULONG WINAPI PStore_fnAddRef(IPStore* iface)
89 {
90 PStore_impl *This = (PStore_impl *)iface;
91
92 TRACE("%p %u\n", This, This->ref);
93
94 return InterlockedIncrement( &This->ref );
95 }
96
97 /******************************************************************************
98 * IPStore->Release
99 */
100 static ULONG WINAPI PStore_fnRelease(IPStore* iface)
101 {
102 PStore_impl *This = (PStore_impl *)iface;
103 LONG ref;
104
105 TRACE("%p %u\n", This, This->ref);
106
107 ref = InterlockedDecrement( &This->ref );
108 if( !ref )
109 HeapFree( GetProcessHeap(), 0, This );
110
111 return ref;
112 }
113
114 /******************************************************************************
115 * IPStore->GetInfo
116 */
117 static HRESULT WINAPI PStore_fnGetInfo( IPStore* iface, PPST_PROVIDERINFO* ppProperties)
118 {
119 FIXME("\n");
120 return E_NOTIMPL;
121 }
122
123 /******************************************************************************
124 * IPStore->GetProvParam
125 */
126 static HRESULT WINAPI PStore_fnGetProvParam( IPStore* iface,
127 DWORD dwParam, DWORD* pcbData, BYTE** ppbData, DWORD dwFlags)
128 {
129 FIXME("\n");
130 return E_NOTIMPL;
131 }
132
133 /******************************************************************************
134 * IPStore->SetProvParam
135 */
136 static HRESULT WINAPI PStore_fnSetProvParam( IPStore* This,
137 DWORD dwParam, DWORD cbData, BYTE* pbData, DWORD* dwFlags)
138 {
139 FIXME("\n");
140 return E_NOTIMPL;
141 }
142
143 /******************************************************************************
144 * IPStore->CreateType
145 */
146 static HRESULT WINAPI PStore_fnCreateType( IPStore* This,
147 PST_KEY Key, const GUID* pType, PPST_TYPEINFO pInfo, DWORD dwFlags)
148 {
149 FIXME("%p %08x %s %p(%d,%s) %08x\n", This, Key, debugstr_guid(pType),
150 pInfo, pInfo->cbSize, debugstr_w(pInfo->szDisplayName), dwFlags);
151
152 return E_NOTIMPL;
153 }
154
155 /******************************************************************************
156 * IPStore->GetTypeInfo
157 */
158 static HRESULT WINAPI PStore_fnGetTypeInfo( IPStore* This,
159 PST_KEY Key, const GUID* pType, PPST_TYPEINFO** ppInfo, DWORD dwFlags)
160 {
161 FIXME("\n");
162 return E_NOTIMPL;
163 }
164
165 /******************************************************************************
166 * IPStore->DeleteType
167 */
168 static HRESULT WINAPI PStore_fnDeleteType( IPStore* This,
169 PST_KEY Key, const GUID* pType, DWORD dwFlags)
170 {
171 FIXME("%p %d %s %08x\n", This, Key, debugstr_guid(pType), dwFlags);
172 return E_NOTIMPL;
173 }
174
175 /******************************************************************************
176 * IPStore->CreateSubtype
177 */
178 static HRESULT WINAPI PStore_fnCreateSubtype( IPStore* This,
179 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
180 PPST_TYPEINFO pInfo, PPST_ACCESSRULESET pRules, DWORD dwFlags)
181 {
182 FIXME("%p %08x %s %s %p %p %08x\n", This, Key, debugstr_guid(pType),
183 debugstr_guid(pSubtype), pInfo, pRules, dwFlags);
184 return E_NOTIMPL;
185 }
186
187 /******************************************************************************
188 * IPStore->GetSubtypeInfo
189 */
190 static HRESULT WINAPI PStore_fnGetSubtypeInfo( IPStore* This,
191 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
192 PPST_TYPEINFO** ppInfo, DWORD dwFlags)
193 {
194 FIXME("\n");
195 return E_NOTIMPL;
196 }
197
198 /******************************************************************************
199 * IPStore->DeleteSubtype
200 */
201 static HRESULT WINAPI PStore_fnDeleteSubtype( IPStore* This,
202 PST_KEY Key, const GUID* pType, const GUID* pSubtype, DWORD dwFlags)
203 {
204 FIXME("%p %u %s %s %08x\n", This, Key,
205 debugstr_guid(pType), debugstr_guid(pSubtype), dwFlags);
206 return E_NOTIMPL;
207 }
208
209 /******************************************************************************
210 * IPStore->ReadAccessRuleset
211 */
212 static HRESULT WINAPI PStore_fnReadAccessRuleset( IPStore* This,
213 PST_KEY Key, const GUID* pType, const GUID* pSubtype, PPST_TYPEINFO pInfo,
214 PPST_ACCESSRULESET** ppRules, DWORD dwFlags)
215 {
216 FIXME("\n");
217 return E_NOTIMPL;
218 }
219
220 /******************************************************************************
221 * IPStore->WriteAccessRuleSet
222 */
223 static HRESULT WINAPI PStore_fnWriteAccessRuleset( IPStore* This,
224 PST_KEY Key, const GUID* pType, const GUID* pSubtype,
225 PPST_TYPEINFO pInfo, PPST_ACCESSRULESET pRules, DWORD dwFlags)
226 {
227 FIXME("\n");
228 return E_NOTIMPL;
229 }
230
231 /******************************************************************************
232 * IPStore->EnumTypes
233 */
234 static HRESULT WINAPI PStore_fnEnumTypes( IPStore* This, PST_KEY Key,
235 DWORD dwFlags, IEnumPStoreTypes** ppenum)
236 {
237 FIXME("\n");
238 return E_NOTIMPL;
239 }
240
241 /******************************************************************************
242 * IPStore->EnumSubtypes
243 */
244 static HRESULT WINAPI PStore_fnEnumSubtypes( IPStore* This, PST_KEY Key,
245 const GUID* pType, DWORD dwFlags, IEnumPStoreTypes** ppenum)
246 {
247 FIXME("\n");
248 return E_NOTIMPL;
249 }
250
251 /******************************************************************************
252 * IPStore->DeleteItem
253 */
254 static HRESULT WINAPI PStore_fnDeleteItem( IPStore* This, PST_KEY Key,
255 const GUID* pItemType, const GUID* pItemSubType, LPCWSTR szItemName,
256 PPST_PROMPTINFO pPromptInfo, DWORD dwFlags)
257 {
258 FIXME("\n");
259 return E_NOTIMPL;
260 }
261
262 /******************************************************************************
263 * IPStore->ReadItem
264 */
265 static HRESULT WINAPI PStore_fnReadItem( IPStore* This, PST_KEY Key,
266 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
267 DWORD *cbData, BYTE** pbData, PPST_PROMPTINFO pPromptInfo, DWORD dwFlags)
268 {
269 FIXME("%p %08x %s %s %s %p %p %p %08x\n", This, Key,
270 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
271 debugstr_w(szItemName), cbData, pbData, pPromptInfo, dwFlags);
272 return E_NOTIMPL;
273 }
274
275 /******************************************************************************
276 * IPStore->WriteItem
277 */
278 static HRESULT WINAPI PStore_fnWriteItem( IPStore* This, PST_KEY Key,
279 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
280 DWORD cbData, BYTE* ppbData, PPST_PROMPTINFO pPromptInfo,
281 DWORD dwDefaultConfirmationStyle, DWORD dwFlags)
282 {
283 FIXME("%p %08x %s %s %s %d %p %p %08x\n", This, Key,
284 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
285 debugstr_w(szItemName), cbData, ppbData, pPromptInfo, dwFlags);
286 return E_NOTIMPL;
287 }
288
289 /******************************************************************************
290 * IPStore->OpenItem
291 */
292 static HRESULT WINAPI PStore_fnOpenItem( IPStore* This, PST_KEY Key,
293 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR szItemName,
294 PST_ACCESSMODE ModeFlags, PPST_PROMPTINFO pProomptInfo, DWORD dwFlags )
295 {
296 FIXME("%p %08x %s %s %p %08x %p %08x\n", This, Key,
297 debugstr_guid(pItemType), debugstr_guid(pItemSubtype),
298 debugstr_w(szItemName), ModeFlags, pProomptInfo, dwFlags);
299 return E_NOTIMPL;
300 }
301
302 /******************************************************************************
303 * IPStore->CloseItem
304 */
305 static HRESULT WINAPI PStore_fnCloseItem( IPStore* This, PST_KEY Key,
306 const GUID* pItemType, const GUID* pItemSubtype, LPCWSTR* szItemName,
307 DWORD dwFlags)
308 {
309 FIXME("\n");
310 return E_NOTIMPL;
311 }
312
313 /******************************************************************************
314 * IPStore->EnumItems
315 */
316 static HRESULT WINAPI PStore_fnEnumItems( IPStore* This, PST_KEY Key,
317 const GUID* pItemType, const GUID* pItemSubtype, DWORD dwFlags,
318 IEnumPStoreItems** ppenum)
319 {
320 FIXME("\n");
321 return E_NOTIMPL;
322 }
323
324
325 static const IPStoreVtbl pstores_vtbl =
326 {
327 PStore_fnQueryInterface,
328 PStore_fnAddRef,
329 PStore_fnRelease,
330 PStore_fnGetInfo,
331 PStore_fnGetProvParam,
332 PStore_fnSetProvParam,
333 PStore_fnCreateType,
334 PStore_fnGetTypeInfo,
335 PStore_fnDeleteType,
336 PStore_fnCreateSubtype,
337 PStore_fnGetSubtypeInfo,
338 PStore_fnDeleteSubtype,
339 PStore_fnReadAccessRuleset,
340 PStore_fnWriteAccessRuleset,
341 PStore_fnEnumTypes,
342 PStore_fnEnumSubtypes,
343 PStore_fnDeleteItem,
344 PStore_fnReadItem,
345 PStore_fnWriteItem,
346 PStore_fnOpenItem,
347 PStore_fnCloseItem,
348 PStore_fnEnumItems
349 };
350
351 HRESULT WINAPI PStoreCreateInstance( IPStore** ppProvider,
352 PST_PROVIDERID* pProviderID, void* pReserved, DWORD dwFlags)
353 {
354 PStore_impl *ips;
355
356 TRACE("%p %s %p %08x\n", ppProvider, debugstr_guid(pProviderID), pReserved, dwFlags);
357
358 ips = HeapAlloc( GetProcessHeap(), 0, sizeof (PStore_impl) );
359 if( !ips )
360 return E_OUTOFMEMORY;
361
362 ips->lpVtbl = &pstores_vtbl;
363 ips->ref = 1;
364
365 *ppProvider = (IPStore*) ips;
366
367 return S_OK;
368 }
369
370 HRESULT WINAPI DllRegisterServer(void)
371 {
372 FIXME("\n");
373 return S_OK;
374 }
375
376 HRESULT WINAPI DllUnregisterServer(void)
377 {
378 FIXME("\n");
379 return S_OK;
380 }
381
382 /***********************************************************************
383 * DllGetClassObject (PSTOREC.@)
384 */
385 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
386 {
387 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
388 return CLASS_E_CLASSNOTAVAILABLE;
389 }
390
391 HRESULT WINAPI DllCanUnloadNow(void)
392 {
393 return S_OK;
394 }