Stub implementation of IInternetSecurityManager.
[wine] / dlls / urlmon / sec_mgr.c
1 /*
2  * Internet Security Manager
3  *
4  * Copyright (c) 2004 Huw D M Davies
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wine/debug.h"
28 #include "ole2.h"
29 #include "wine/unicode.h"
30 #include "urlmon.h"
31 #include "urlmon_main.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
34
35 typedef struct SecManagerImpl{
36
37     IInternetSecurityManagerVtbl*  lpvtbl1;  /* VTable relative to the IInternetSecurityManager interface.*/
38
39     ULONG ref; /* reference counter for this object */
40
41 } SecManagerImpl;
42
43 /* IUnknown prototype functions */
44 static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject);
45 static ULONG   WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface);
46 static ULONG   WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface);
47
48 static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
49                                                      IInternetSecurityMgrSite *pSite);
50 static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
51                                                      IInternetSecurityMgrSite **ppSite);
52 static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *iface,
53                                                   LPCWSTR pwszUrl, DWORD *pdwZone,
54                                                   DWORD dwFlags);
55 static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface, 
56                                                    LPCWSTR pwszUrl,
57                                                    BYTE *pbSecurityId, DWORD *pcbSecurityId,
58                                                    DWORD dwReserved);
59 static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *iface,
60                                                       LPCWSTR pwszUrl, DWORD dwAction,
61                                                       BYTE *pPolicy, DWORD cbPolicy,
62                                                       BYTE *pContext, DWORD cbContext,
63                                                       DWORD dwFlags, DWORD dwReserved);
64 static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager *iface,
65                                                        LPCWSTR pwszUrl, REFGUID guidKey,
66                                                        BYTE **ppPolicy, DWORD *pcbPolicy,
67                                                        BYTE *pContext, DWORD cbContext,
68                                                        DWORD dwReserved);
69 static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
70                                                     DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags);
71 static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
72                                                      DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags);
73
74 static HRESULT SecManagerImpl_Destroy(SecManagerImpl* This);
75 HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
76
77 static IInternetSecurityManagerVtbl VT_SecManagerImpl =
78 {
79     SecManagerImpl_QueryInterface,
80     SecManagerImpl_AddRef,
81     SecManagerImpl_Release,
82     SecManagerImpl_SetSecuritySite,
83     SecManagerImpl_GetSecuritySite,
84     SecManagerImpl_MapUrlToZone,
85     SecManagerImpl_GetSecurityId,
86     SecManagerImpl_ProcessUrlAction,
87     SecManagerImpl_QueryCustomPolicy,
88     SecManagerImpl_SetZoneMapping,
89     SecManagerImpl_GetZoneMappings
90 };
91
92 static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
93 {
94     SecManagerImpl *This = (SecManagerImpl *)iface;
95
96     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
97
98     /* Perform a sanity check on the parameters.*/
99     if ( (This==0) || (ppvObject==0) )
100         return E_INVALIDARG;
101
102     /* Initialize the return parameter */
103     *ppvObject = 0;
104
105     /* Compare the riid with the interface IDs implemented by this object.*/
106     if (IsEqualIID(&IID_IUnknown, riid) ||
107         IsEqualIID(&IID_IInternetSecurityManager, riid))
108         *ppvObject = iface;
109
110     /* Check that we obtained an interface.*/
111     if ((*ppvObject)==0)
112         return E_NOINTERFACE;
113
114     /* Query Interface always increases the reference count by one when it is successful */
115     SecManagerImpl_AddRef(iface);
116
117     return S_OK;
118 }
119
120 static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
121 {
122     SecManagerImpl *This = (SecManagerImpl *)iface;
123
124     TRACE("(%p)\n",This);
125
126     return InterlockedIncrement(&This->ref);
127 }
128
129 static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
130 {
131     SecManagerImpl *This = (SecManagerImpl *)iface;
132     ULONG ref;
133     TRACE("(%p)\n",This);
134
135     ref = InterlockedDecrement(&This->ref);
136
137     /* destroy the object if there's no more reference on it */
138     if (ref==0){
139
140         SecManagerImpl_Destroy(This);
141
142         return 0;
143     }
144     return ref;
145 }
146
147 static HRESULT SecManagerImpl_Destroy(SecManagerImpl* This)
148 {
149     TRACE("(%p)\n",This);
150
151     HeapFree(GetProcessHeap(),0,This);
152
153     return S_OK;
154 }
155
156 HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
157 {
158     SecManagerImpl *This;
159
160     TRACE("(%p,%p)\n",pUnkOuter,ppobj);
161     This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
162
163     /* Initialize the virtual function table. */
164     This->lpvtbl1      = &VT_SecManagerImpl;
165     This->ref          = 1;
166
167     *ppobj = This;
168     return S_OK;
169 }
170
171 static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
172                                                      IInternetSecurityMgrSite *pSite)
173 {
174     FIXME("(%p)->(%p)\n", iface, pSite);
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
179                                                      IInternetSecurityMgrSite **ppSite)
180 {
181     FIXME("(%p)->( %p)\n", iface, ppSite);
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *iface,
186                                                   LPCWSTR pwszUrl, DWORD *pdwZone,
187                                                   DWORD dwFlags)
188 {
189     FIXME("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface, 
194                                                    LPCWSTR pwszUrl,
195                                                    BYTE *pbSecurityId, DWORD *pcbSecurityId,
196                                                    DWORD dwReserved)
197 {
198     FIXME("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId, pcbSecurityId,
199           dwReserved);
200     return E_NOTIMPL;
201 }
202
203
204 static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *iface,
205                                                       LPCWSTR pwszUrl, DWORD dwAction,
206                                                       BYTE *pPolicy, DWORD cbPolicy,
207                                                       BYTE *pContext, DWORD cbContext,
208                                                       DWORD dwFlags, DWORD dwReserved)
209 {
210     FIXME("(%p)->(%s %08lx %p %08lx %p %08lx %08lx %08lx)\n", iface, debugstr_w(pwszUrl), dwAction,
211           pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
212     return E_NOTIMPL;
213 }
214                                                
215
216 static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager *iface,
217                                                        LPCWSTR pwszUrl, REFGUID guidKey,
218                                                        BYTE **ppPolicy, DWORD *pcbPolicy,
219                                                        BYTE *pContext, DWORD cbContext,
220                                                        DWORD dwReserved)
221 {
222     FIXME("(%p)->(%s %s %p %p %p %08lx %08lx )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
223           ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
224     return E_NOTIMPL;
225 }
226
227 static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
228                                                     DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
229 {
230     FIXME("(%p)->(%08lx %s %08lx)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
231     return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
235                                                      DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
236 {
237     FIXME("(%p)->(%08lx %p %08lx)\n", iface, dwZone, ppenumString,dwFlags);
238     return E_NOTIMPL;
239 }
240
241 /***********************************************************************
242  *           CoInternetCreateSecurityManager (URLMON.@)
243  *
244  */
245 HRESULT WINAPI CoInternetCreateSecurityManager( IServiceProvider *pSP,
246     IInternetSecurityManager **ppSM, DWORD dwReserved )
247 {
248     TRACE("%p %p %ld\n", pSP, ppSM, dwReserved );
249     return SecManagerImpl_Construct(NULL, (void**) ppSM);
250 }