inetcpl: Add a security propsheet.
[wine/multimedia.git] / dlls / inetcpl.cpl / security.c
blobe853dd0e30cd488f2445987af7879972a96cc2aa
1 /*
2 * Internet control panel applet: security propsheet
4 * Copyright 2011 Detlef Riekenberg
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.
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.
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
22 #define COBJMACROS
23 #define CONST_VTABLE
24 #define NONAMELESSUNION
26 #include <stdarg.h>
27 #include <windef.h>
28 #include <winbase.h>
29 #include <winuser.h>
30 #include <prsht.h>
31 #include "commctrl.h"
33 #include "ole2.h"
34 #include "urlmon.h"
35 #include "initguid.h"
36 #include "winreg.h"
37 #include "shlwapi.h"
39 #include "inetcpl.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
44 typedef struct secdlg_data_s {
45 HWND hsec; /* security propsheet */
46 HWND hlv; /* listview */
47 IInternetSecurityManager *sec_mgr;
48 IInternetZoneManager *zone_mgr;
49 DWORD zone_enumerator;
50 DWORD num_zones;
51 } secdlg_data;
53 /*********************************************************************
54 * security_cleanup_zones [internal]
57 static void security_cleanup_zones(secdlg_data *sd)
59 if (sd->zone_enumerator) {
60 IInternetZoneManager_DestroyZoneEnumerator(sd->zone_mgr, sd->zone_enumerator);
63 if (sd->zone_mgr) {
64 IInternetZoneManager_Release(sd->zone_mgr);
67 if (sd->sec_mgr) {
68 IInternetSecurityManager_Release(sd->sec_mgr);
72 /*********************************************************************
73 * security_enum_zones [internal]
76 static HRESULT security_enum_zones(secdlg_data * sd)
78 HRESULT hr;
80 hr = CoInternetCreateSecurityManager(NULL, &sd->sec_mgr, 0);
81 if (SUCCEEDED(hr)) {
82 hr = CoInternetCreateZoneManager(NULL, &sd->zone_mgr, 0);
83 if (SUCCEEDED(hr)) {
84 hr = IInternetZoneManager_CreateZoneEnumerator(sd->zone_mgr, &sd->zone_enumerator, &sd->num_zones, 0);
87 return hr;
90 /*********************************************************************
91 * security_on_destroy [internal]
93 * handle WM_NCDESTROY
96 static INT_PTR security_on_destroy(secdlg_data * sd)
98 TRACE("(%p)\n", sd);
100 security_cleanup_zones(sd);
101 SetWindowLongPtrW(sd->hsec, DWLP_USER, 0);
102 heap_free(sd);
103 return TRUE;
106 /*********************************************************************
107 * security_on_initdialog [internal]
109 * handle WM_INITDIALOG
112 static INT_PTR security_on_initdialog(HWND hsec)
114 secdlg_data *sd;
115 HRESULT hr;
117 sd = heap_alloc_zero(sizeof(secdlg_data));
118 SetWindowLongPtrW(hsec, DWLP_USER, (LONG_PTR) sd);
119 if (!sd) {
120 return FALSE;
123 sd->hsec = hsec;
124 sd->hlv = GetDlgItem(hsec, IDC_SEC_LISTVIEW);
126 hr = security_enum_zones(sd);
127 if (FAILED(hr)) {
128 ERR("got 0x%x\n", hr);
129 security_on_destroy(sd);
130 return FALSE;
133 TRACE("found %d zones\n", sd->num_zones);
134 return TRUE;
137 /*********************************************************************
138 * security_on_notify [internal]
140 * handle WM_NOTIFY
143 static INT_PTR security_on_notify(WPARAM wparam, LPARAM lparam)
145 NMLISTVIEW *nm;
147 nm = (NMLISTVIEW *) lparam;
148 switch (nm->hdr.code)
150 case PSN_APPLY:
151 TRACE("PSN_APPLY (0x%lx, 0x%lx) from %p with code: %d\n", wparam, lparam,
152 nm->hdr.hwndFrom, nm->hdr.code);
153 break;
155 default:
156 TRACE("WM_NOTIFY (0x%lx, 0x%lx) from %p with code: %d\n", wparam, lparam,
157 nm->hdr.hwndFrom, nm->hdr.code);
160 return FALSE;
163 /*********************************************************************
164 * security_dlgproc [internal]
167 INT_PTR CALLBACK security_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
169 secdlg_data *sd;
171 if (msg == WM_INITDIALOG) {
172 return security_on_initdialog(hwnd);
175 sd = (secdlg_data *)GetWindowLongPtrW(hwnd, DWLP_USER);
176 if (sd) {
177 switch (msg)
179 case WM_NOTIFY:
180 return security_on_notify(wparam, lparam);
182 case WM_NCDESTROY:
183 return security_on_destroy(sd);
185 default:
186 /* do not flood the log */
187 if ((msg == WM_SETCURSOR) || (msg == WM_NCHITTEST) ||
188 (msg == WM_MOUSEMOVE) || (msg == WM_MOUSEACTIVATE) || (msg == WM_PARENTNOTIFY))
189 return FALSE;
191 TRACE("(%p, 0x%08x/%03d, 0x%08lx, 0x%08lx)\n", hwnd, msg, msg, wparam, lparam);
194 return FALSE;