[PATCH 3/4] inetcpl: Display description and security level for a zone
Detlef Riekenberg
wine.dev at web.de
Tue Apr 12 22:33:49 CDT 2011
Changing and saving the security level is not enabled yet.
I want to do more testing for that code, before i send the
related patch.
--
By by ... Detlef
---
dlls/inetcpl.cpl/cpl_En.rc | 6 ++
dlls/inetcpl.cpl/inetcpl.h | 18 ++++++
dlls/inetcpl.cpl/inetcpl.rc | 9 +++-
dlls/inetcpl.cpl/security.c | 126 +++++++++++++++++++++++++++++++++++++++++--
4 files changed, 154 insertions(+), 5 deletions(-)
diff --git a/dlls/inetcpl.cpl/cpl_En.rc b/dlls/inetcpl.cpl/cpl_En.rc
index cd7f5f5..296864f 100644
--- a/dlls/inetcpl.cpl/cpl_En.rc
+++ b/dlls/inetcpl.cpl/cpl_En.rc
@@ -77,6 +77,12 @@ BEGIN
CONTROL "Listview", IDC_SEC_LISTVIEW, "SysListView32",
LVS_ICON | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_VSCROLL,
4, 4, 312, 58
+ LTEXT "", IDC_SEC_ZONE_INFO, 4, 68, 312, 20
+ GROUPBOX "", IDC_SEC_GROUP, 4, 88, 312, 126
+ CONTROL "trackbar", IDC_SEC_TRACKBAR, "msctls_trackbar32",
+ TBS_VERT | TBS_AUTOTICKS | TBS_BOTH | TBS_REVERSED, 8, 98, 32, 100
+ LTEXT "", IDC_SEC_LEVEL, 48, 102, 180, 12
+ LTEXT "", IDC_SEC_LEVEL_INFO, 48, 114, 260, 80
END
/* "Content" propsheet */
diff --git a/dlls/inetcpl.cpl/inetcpl.h b/dlls/inetcpl.cpl/inetcpl.h
index 1797b49..bd1e55a 100644
--- a/dlls/inetcpl.cpl/inetcpl.h
+++ b/dlls/inetcpl.cpl/inetcpl.h
@@ -58,6 +58,19 @@ static inline BOOL heap_free( void *mem )
/* strings */
#define IDS_CPL_NAME 1
#define IDS_CPL_INFO 2
+#define IDS_SEC_SETTINGS 0x10
+#define IDS_SEC_LEVEL0 0x100
+#define IDS_SEC_LEVEL1 0x101
+#define IDS_SEC_LEVEL2 0x102
+#define IDS_SEC_LEVEL3 0x103
+#define IDS_SEC_LEVEL4 0x104
+#define IDS_SEC_LEVEL5 0x105
+#define IDS_SEC_LEVEL0_INFO 0x200
+#define IDS_SEC_LEVEL1_INFO 0x210
+#define IDS_SEC_LEVEL2_INFO 0x220
+#define IDS_SEC_LEVEL3_INFO 0x230
+#define IDS_SEC_LEVEL4_INFO 0x240
+#define IDS_SEC_LEVEL5_INFO 0x250
/* dialogs */
#define IDC_STATIC -1
@@ -79,6 +92,11 @@ static inline BOOL heap_free( void *mem )
#define IDD_SECURITY 2000
#define IDC_SEC_LISTVIEW 2001
+#define IDC_SEC_ZONE_INFO 2002
+#define IDC_SEC_GROUP 2003
+#define IDC_SEC_TRACKBAR 2004
+#define IDC_SEC_LEVEL 2005
+#define IDC_SEC_LEVEL_INFO 2006
#define IDD_CONTENT 4000
#define IDC_CERT 4100
diff --git a/dlls/inetcpl.cpl/inetcpl.rc b/dlls/inetcpl.cpl/inetcpl.rc
index 53d84c0..0c42d9f 100644
--- a/dlls/inetcpl.cpl/inetcpl.rc
+++ b/dlls/inetcpl.cpl/inetcpl.rc
@@ -26,7 +26,14 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE
BEGIN
IDS_CPL_NAME "Internet Settings"
- IDS_CPL_INFO "Configure Wine Internet Browser and related settings"
+ IDS_CPL_INFO "Configure Wine Internet Browser and related settings"
+ IDS_SEC_SETTINGS "Security settings for zone: "
+ IDS_SEC_LEVEL0 "Custom"
+ IDS_SEC_LEVEL1 "Very Low"
+ IDS_SEC_LEVEL2 "Low"
+ IDS_SEC_LEVEL3 "Medium"
+ IDS_SEC_LEVEL4 "Increased"
+ IDS_SEC_LEVEL5 "High"
END
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
diff --git a/dlls/inetcpl.cpl/security.c b/dlls/inetcpl.cpl/security.c
index 1aa29a5..1187185 100644
--- a/dlls/inetcpl.cpl/security.c
+++ b/dlls/inetcpl.cpl/security.c
@@ -44,15 +44,112 @@ WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
typedef struct secdlg_data_s {
HWND hsec; /* security propsheet */
HWND hlv; /* listview */
+ HWND htb; /* trackbar */
IInternetSecurityManager *sec_mgr;
IInternetZoneManager *zone_mgr;
DWORD zone_enumerator;
DWORD num_zones;
ZONEATTRIBUTES *zone_attr;
DWORD *zones;
+ DWORD *levels;
HIMAGELIST himages;
+ DWORD last_lv_index;
+ DWORD last_level;
} secdlg_data;
+#define NUM_TRACKBAR_POS 5
+
+static WCHAR spaceW[] = {' ',0};
+static DWORD url_templates[] = {URLTEMPLATE_CUSTOM,
+ URLTEMPLATE_LOW,
+ URLTEMPLATE_MEDLOW,
+ URLTEMPLATE_MEDIUM,
+ URLTEMPLATE_MEDHIGH,
+ URLTEMPLATE_HIGH};
+
+/*********************************************************************
+ * index_from_urltemplate [internal]
+ *
+ */
+static DWORD index_from_urltemplate(URLTEMPLATE value)
+{
+
+ DWORD index = sizeof(url_templates) / sizeof(url_templates[0]);
+
+ while((index > 0) && (url_templates[index-1] != value))
+ index--;
+
+ index--; /* table entries are 0 based */
+ if (!index && value)
+ FIXME("URLTEMPLATE 0x%x not supported\n", value);
+
+ TRACE("URLTEMPLATE 0x%08x=> Level %d\n", value, index);
+ return index;
+}
+
+/*********************************************************************
+ * update_security_level [internal]
+ *
+ */
+static void update_security_level(secdlg_data *sd, DWORD lv_index, DWORD tb_index)
+{
+ WCHAR name[512];
+ DWORD current_index;
+
+ TRACE("(%p, lv_index: %u, tb_index: %u)\n", sd, lv_index, tb_index);
+
+ if ((sd->levels[lv_index] != sd->last_level) || (tb_index > 0)) {
+ /* show or hide the trackbar */
+ if (!sd->levels[lv_index] || !sd->last_level)
+ ShowWindow(sd->htb, sd->levels[lv_index] ? SW_NORMAL : SW_HIDE);
+
+ current_index = (tb_index > 0) ? tb_index : index_from_urltemplate(sd->levels[lv_index]);
+
+ name[0] = 0;
+ LoadStringW(hcpl, IDS_SEC_LEVEL0 + current_index, name, sizeof(name)/sizeof(name[0]));
+ TRACE("new level #%d: %s\n", current_index, debugstr_w(name));
+ SetWindowTextW(GetDlgItem(sd->hsec, IDC_SEC_LEVEL), name);
+
+ name[0] = 0;
+ LoadStringW(hcpl, IDS_SEC_LEVEL0_INFO + (current_index * 0x10), name, sizeof(name)/sizeof(name[0]));
+ TRACE("new level info: %s\n", debugstr_w(name));
+ SetWindowTextW(GetDlgItem(sd->hsec, IDC_SEC_LEVEL_INFO), name);
+
+ if (current_index)
+ SendMessageW(sd->htb, TBM_SETPOS, TRUE, NUM_TRACKBAR_POS - current_index);
+
+ sd->last_level = sd->levels[lv_index];
+
+ }
+}
+
+/*********************************************************************
+ * update_zone_info [internal]
+ *
+ */
+static void update_zone_info(secdlg_data *sd, DWORD lv_index)
+{
+ ZONEATTRIBUTES *za = &sd->zone_attr[lv_index];
+ WCHAR name[MAX_PATH];
+ DWORD len;
+
+ SetWindowTextW(GetDlgItem(sd->hsec, IDC_SEC_ZONE_INFO), za->szDescription);
+
+ name[0] = ' ';
+ name[1] = 0;
+
+ LoadStringW(hcpl, IDS_SEC_SETTINGS, &name[1], sizeof(name)/sizeof(name[0]) - 3);
+ len = lstrlenW(name);
+ lstrcpynW(&name[len], za->szDisplayName, sizeof(name)/sizeof(name[0]) - len - 3);
+ lstrcatW(name, spaceW);
+
+ TRACE("new title: %s\n", debugstr_w(name));
+ SetWindowTextW(GetDlgItem(sd->hsec, IDC_SEC_GROUP), name);
+
+ update_security_level(sd, lv_index, 0);
+ sd->last_lv_index = lv_index;
+}
+
/*********************************************************************
* add_zone_to_listview [internal]
*
@@ -87,6 +184,8 @@ static void add_zone_to_listview(secdlg_data *sd, DWORD *pindex, DWORD zone)
return;
}
+ sd->levels[lv_index] = za->dwTemplateCurrentLevel;
+
lvitem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
lvitem.iItem = lv_index;
lvitem.iSubItem = 0;
@@ -122,6 +221,8 @@ static void add_zone_to_listview(secdlg_data *sd, DWORD *pindex, DWORD zone)
lvitem.state = LVIS_FOCUSED | LVIS_SELECTED;
lvitem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
SendMessageW(sd->hlv, LVM_SETITEMSTATE, 0, (LPARAM) &lvitem);
+ sd->last_level = ~0;
+ update_zone_info(sd, lv_index);
}
(*pindex)++;
}
@@ -213,6 +314,14 @@ static INT_PTR security_on_initdialog(HWND hsec)
sd->hsec = hsec;
sd->hlv = GetDlgItem(hsec, IDC_SEC_LISTVIEW);
+ sd->htb = GetDlgItem(hsec, IDC_SEC_TRACKBAR);
+
+ EnableWindow(sd->htb, FALSE); /* not changeable yet */
+
+ TRACE("(%p) (data: %p, listview: %p, trackbar: %p)\n", hsec, sd, sd->hlv, sd->htb);
+
+ SendMessageW(sd->htb, TBM_SETRANGE, FALSE, MAKELONG(0, NUM_TRACKBAR_POS - 1));
+ SendMessageW(sd->htb, TBM_SETTICFREQ, 1, 0 );
/* Create the image lists for the listview */
sd->himages = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), ILC_COLOR32 | ILC_MASK, 1, 1);
@@ -240,12 +349,13 @@ static INT_PTR security_on_initdialog(HWND hsec)
return FALSE;
}
- /* remember zone number for a listview entry */
- sd->zones = heap_alloc(sizeof(DWORD) * sd->num_zones);
+ /* remember zone number and current security level for a listview entry */
+ sd->zones = heap_alloc((sizeof(DWORD) + sizeof(DWORD)) * sd->num_zones);
if (!sd->zones) {
security_on_destroy(sd);
return FALSE;
}
+ sd->levels = &sd->zones[sd->num_zones];
/* use the same order as visible with native inetcpl.cpl */
add_zone_to_listview(sd, &lv_index, URLZONE_INTERNET);
@@ -271,13 +381,21 @@ static INT_PTR security_on_initdialog(HWND hsec)
* handle WM_NOTIFY
*
*/
-static INT_PTR security_on_notify(WPARAM wparam, LPARAM lparam)
+static INT_PTR security_on_notify(secdlg_data *sd, WPARAM wparam, LPARAM lparam)
{
NMLISTVIEW *nm;
nm = (NMLISTVIEW *) lparam;
switch (nm->hdr.code)
{
+ case LVN_ITEMCHANGED:
+ TRACE("LVN_ITEMCHANGED (0x%lx, 0x%lx) from %p with code: %d (item: %d, uNewState: %u)\n",
+ wparam, lparam, nm->hdr.hwndFrom, nm->hdr.code, nm->iItem, nm->uNewState);
+ if ((nm->uNewState & LVIS_SELECTED) == LVIS_SELECTED) {
+ update_zone_info(sd, nm->iItem);
+ }
+ break;
+
case PSN_APPLY:
TRACE("PSN_APPLY (0x%lx, 0x%lx) from %p with code: %d\n", wparam, lparam,
nm->hdr.hwndFrom, nm->hdr.code);
@@ -308,7 +426,7 @@ INT_PTR CALLBACK security_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
switch (msg)
{
case WM_NOTIFY:
- return security_on_notify(wparam, lparam);
+ return security_on_notify(sd, wparam, lparam);
case WM_NCDESTROY:
return security_on_destroy(sd);
--
1.7.1
More information about the wine-patches
mailing list