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
24 #define NONAMELESSUNION
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
;
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
);
64 IInternetZoneManager_Release(sd
->zone_mgr
);
68 IInternetSecurityManager_Release(sd
->sec_mgr
);
72 /*********************************************************************
73 * security_enum_zones [internal]
76 static HRESULT
security_enum_zones(secdlg_data
* sd
)
80 hr
= CoInternetCreateSecurityManager(NULL
, &sd
->sec_mgr
, 0);
82 hr
= CoInternetCreateZoneManager(NULL
, &sd
->zone_mgr
, 0);
84 hr
= IInternetZoneManager_CreateZoneEnumerator(sd
->zone_mgr
, &sd
->zone_enumerator
, &sd
->num_zones
, 0);
90 /*********************************************************************
91 * security_on_destroy [internal]
96 static INT_PTR
security_on_destroy(secdlg_data
* sd
)
100 security_cleanup_zones(sd
);
101 SetWindowLongPtrW(sd
->hsec
, DWLP_USER
, 0);
106 /*********************************************************************
107 * security_on_initdialog [internal]
109 * handle WM_INITDIALOG
112 static INT_PTR
security_on_initdialog(HWND hsec
)
117 sd
= heap_alloc_zero(sizeof(secdlg_data
));
118 SetWindowLongPtrW(hsec
, DWLP_USER
, (LONG_PTR
) sd
);
124 sd
->hlv
= GetDlgItem(hsec
, IDC_SEC_LISTVIEW
);
126 hr
= security_enum_zones(sd
);
128 ERR("got 0x%x\n", hr
);
129 security_on_destroy(sd
);
133 TRACE("found %d zones\n", sd
->num_zones
);
137 /*********************************************************************
138 * security_on_notify [internal]
143 static INT_PTR
security_on_notify(WPARAM wparam
, LPARAM lparam
)
147 nm
= (NMLISTVIEW
*) lparam
;
148 switch (nm
->hdr
.code
)
151 TRACE("PSN_APPLY (0x%lx, 0x%lx) from %p with code: %d\n", wparam
, lparam
,
152 nm
->hdr
.hwndFrom
, nm
->hdr
.code
);
156 TRACE("WM_NOTIFY (0x%lx, 0x%lx) from %p with code: %d\n", wparam
, lparam
,
157 nm
->hdr
.hwndFrom
, nm
->hdr
.code
);
163 /*********************************************************************
164 * security_dlgproc [internal]
167 INT_PTR CALLBACK
security_dlgproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
171 if (msg
== WM_INITDIALOG
) {
172 return security_on_initdialog(hwnd
);
175 sd
= (secdlg_data
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
180 return security_on_notify(wparam
, lparam
);
183 return security_on_destroy(sd
);
186 /* do not flood the log */
187 if ((msg
== WM_SETCURSOR
) || (msg
== WM_NCHITTEST
) ||
188 (msg
== WM_MOUSEMOVE
) || (msg
== WM_MOUSEACTIVATE
) || (msg
== WM_PARENTNOTIFY
))
191 TRACE("(%p, 0x%08x/%03d, 0x%08lx, 0x%08lx)\n", hwnd
, msg
, msg
, wparam
, lparam
);