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