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