Juan Lang : cryptui: Apply changes to enabled usages in response to applying the edit cert properties dialog .

Alexandre Julliard julliard at winehq.org
Fri Dec 19 11:19:26 CST 2008


Module: wine
Branch: master
Commit: 11e770169677b7d92d7440617f27a0b4356d1ef0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=11e770169677b7d92d7440617f27a0b4356d1ef0

Author: Juan Lang <juan.lang at gmail.com>
Date:   Thu Dec 18 14:07:33 2008 -0800

cryptui: Apply changes to enabled usages in response to applying the edit cert properties dialog.

---

 dlls/cryptui/main.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c
index 2c0d453..c90bd34 100644
--- a/dlls/cryptui/main.c
+++ b/dlls/cryptui/main.c
@@ -2021,7 +2021,55 @@ static void apply_general_changes(HWND hwnd)
      sizeof(buf) / sizeof(buf[0]), (LPARAM)buf);
     set_cert_string_property(data->pCertViewInfo->pCertContext,
      CERT_DESCRIPTION_PROP_ID, buf);
-    FIXME("apply usage state\n");
+    if (IsDlgButtonChecked(hwnd, IDC_ENABLE_ALL_PURPOSES))
+    {
+        /* Setting a NULL usage removes the enhanced key usage property. */
+        CertSetEnhancedKeyUsage(data->pCertViewInfo->pCertContext, NULL);
+    }
+    else if (IsDlgButtonChecked(hwnd, IDC_DISABLE_ALL_PURPOSES))
+    {
+        CERT_ENHKEY_USAGE usage = { 0, NULL };
+
+        CertSetEnhancedKeyUsage(data->pCertViewInfo->pCertContext, &usage);
+    }
+    else if (IsDlgButtonChecked(hwnd, IDC_ENABLE_SELECTED_PURPOSES))
+    {
+        HWND lv = GetDlgItem(hwnd, IDC_CERTIFICATE_USAGES);
+        CERT_ENHKEY_USAGE usage = { 0, NULL };
+        int purposes = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0), i;
+        LVITEMW item;
+
+        item.mask = LVIF_STATE | LVIF_PARAM;
+        item.iSubItem = 0;
+        item.stateMask = LVIS_STATEIMAGEMASK;
+        for (i = 0; i < purposes; i++)
+        {
+            item.iItem = i;
+            if (SendMessageW(lv, LVM_GETITEMW, 0, (LPARAM)&item))
+            {
+                int state = item.state >> 12;
+
+                if (state == CheckBitmapIndexChecked)
+                {
+                    CRYPT_OID_INFO *info = (CRYPT_OID_INFO *)item.lParam;
+
+                    if (usage.cUsageIdentifier)
+                        usage.rgpszUsageIdentifier =
+                         HeapReAlloc(GetProcessHeap(), 0,
+                         usage.rgpszUsageIdentifier,
+                         (usage.cUsageIdentifier + 1) * sizeof(LPSTR));
+                    else
+                        usage.rgpszUsageIdentifier =
+                         HeapAlloc(GetProcessHeap(), 0, sizeof(LPSTR));
+                    if (usage.rgpszUsageIdentifier)
+                        usage.rgpszUsageIdentifier[usage.cUsageIdentifier++] =
+                         (LPSTR)info->pszOID;
+                }
+            }
+        }
+        CertSetEnhancedKeyUsage(data->pCertViewInfo->pCertContext, &usage);
+        HeapFree(GetProcessHeap(), 0, usage.rgpszUsageIdentifier);
+    }
     if (data->pfPropertiesChanged)
         *data->pfPropertiesChanged = TRUE;
 }




More information about the wine-cvs mailing list