Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
4.9 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Class: CDsCACertPage
  4. //+----------------------------------------------------------------------------
  5. //
  6. // Windows NT Directory Service Property Pages
  7. //
  8. // Microsoft Windows
  9. // Copyright (C) Microsoft Corporation, 1992 - 1999
  10. //
  11. // File: caprop.h
  12. //
  13. // Contents: CA DS object property pages
  14. //
  15. // Classes: CDsCACertPage
  16. //
  17. // History: 16-Mar-99 petesk copied from bryanwal
  18. //
  19. //-----------------------------------------------------------------------------
  20. #ifndef _CAPROP_H_
  21. #define _CAPROP_H_
  22. #include "genpage.h"
  23. #include <wincrypt.h>
  24. #include <cryptui.h>
  25. #include "certifct.h"
  26. #include <shlobj.h>
  27. #include <dsclient.h>
  28. enum {
  29. CERTCOL_ISSUED_TO = 0,
  30. CERTCOL_ISSUED_BY,
  31. CERTCOL_PURPOSES,
  32. CERTCOL_EXP_DATE
  33. };
  34. //
  35. // Purpose: property page object class for the User Certificates page.
  36. //
  37. //-----------------------------------------------------------------------------
  38. class CDsCACertPage : public CAutoDeletePropPage
  39. {
  40. public:
  41. enum { IID_DEFAULT = IDD_CACERTS };
  42. CDsCACertPage(LPWSTR wszObjectDN, UINT uIDD = IDD_CACERTS);
  43. virtual ~CDsCACertPage(void);
  44. //
  45. // Instance specific wind proc
  46. //
  47. LRESULT DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  48. private:
  49. CString m_strObjectDN;
  50. CRYPTUI_SELECTCERTIFICATE_STRUCT m_selCertStruct;
  51. HBITMAP m_hbmCert;
  52. HIMAGELIST m_hImageList;
  53. int m_nCertImageIndex;
  54. HRESULT AddListViewColumns ();
  55. HCERTSTORE m_hCertStore;
  56. public:
  57. // Overrides
  58. BOOL OnApply(void );
  59. BOOL OnInitDialog();
  60. protected:
  61. // Implementation
  62. void OnDestroy();
  63. BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  64. BOOL OnNotify(UINT idCtrl, NMHDR* pNMHDR);
  65. int MessageBox (int caption, int text, UINT flags);
  66. HRESULT AddCertToStore (PCCERT_CONTEXT pCertContext);
  67. void OnNotifyItemChanged (LPNMLISTVIEW item);
  68. void OnNotifyStateChanged (LPNMLVODSTATECHANGE pnlvo);
  69. void EnableControls ();
  70. void DisplaySystemError (DWORD dwErr, int iCaptionText);
  71. HRESULT InsertCertInList (CCertificate* pCert, int nItem);
  72. void RefreshItemInList (CCertificate * pCert, int nItem);
  73. CCertificate* GetSelectedCertificate (int& nSelItem);
  74. HRESULT PopulateListView ();
  75. HRESULT OnDeleteItemCertList (LPNMLISTVIEW pNMListView);
  76. HRESULT OnColumnClickCertList (LPNMHDR pNMHdr);
  77. HRESULT OnDblClkCertList (LPNMHDR pNMHdr);
  78. HRESULT OnClickedCopyToFile ();
  79. HRESULT OnClickedRemove();
  80. HRESULT OnClickedAddFromFile();
  81. HRESULT OnClickedAddFromStore ();
  82. HRESULT OnClickedViewCert ();
  83. };
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CCAShellExt
  86. //
  87. // Shell Extension class
  88. //
  89. class ATL_NO_VTABLE CCAShellExt :
  90. public CComObjectRootEx<CComSingleThreadModel>,
  91. public CComCoClass<CCAShellExt, &CLSID_CAShellExt>,
  92. public IShellExtInit,
  93. public IShellPropSheetExt,
  94. public IContextMenu
  95. {
  96. public:
  97. CCAShellExt()
  98. {
  99. m_Names = NULL;
  100. m_idManage = 0;
  101. m_idOpen = 0;
  102. m_idExport = 0;
  103. }
  104. ~CCAShellExt()
  105. {
  106. if(m_Names)
  107. {
  108. GlobalFree(m_Names);
  109. }
  110. }
  111. //Simple ALL 1.0 based registry entry
  112. DECLARE_REGISTRY( CCAShellExt,
  113. _T("CAPESNPN.CCAShellExt.1"),
  114. _T("CAPESNPN.CCAShellExt"),
  115. IDS_CCASHELLEXT_DESC,
  116. THREADFLAGS_APARTMENT)
  117. BEGIN_COM_MAP(CCAShellExt)
  118. COM_INTERFACE_ENTRY(IShellExtInit)
  119. COM_INTERFACE_ENTRY(IShellPropSheetExt)
  120. COM_INTERFACE_ENTRY(IContextMenu)
  121. END_COM_MAP()
  122. // IDfsShell
  123. public:
  124. // IShellExtInit Methods
  125. STDMETHOD (Initialize)
  126. (
  127. IN LPCITEMIDLIST pidlFolder, // Points to an ITEMIDLIST structure
  128. IN LPDATAOBJECT lpdobj, // Points to an IDataObject interface
  129. IN HKEY hkeyProgID // Registry key for the file object or folder type
  130. );
  131. //IShellPropSheetExt methods
  132. STDMETHODIMP AddPages
  133. (
  134. IN LPFNADDPROPSHEETPAGE lpfnAddPage,
  135. IN LPARAM lParam
  136. );
  137. STDMETHODIMP ReplacePage
  138. (
  139. IN UINT uPageID,
  140. IN LPFNADDPROPSHEETPAGE lpfnReplaceWith,
  141. IN LPARAM lParam
  142. );
  143. // IContextMenu methods
  144. STDMETHODIMP GetCommandString
  145. (
  146. UINT_PTR idCmd,
  147. UINT uFlags,
  148. UINT *pwReserved,
  149. LPSTR pszName,
  150. UINT cchMax
  151. );
  152. STDMETHODIMP InvokeCommand
  153. (
  154. LPCMINVOKECOMMANDINFO lpici
  155. );
  156. STDMETHODIMP QueryContextMenu
  157. (
  158. HMENU hmenu,
  159. UINT indexMenu,
  160. UINT idCmdFirst,
  161. UINT idCmdLast,
  162. UINT uFlags
  163. );
  164. private:
  165. STDMETHODIMP _SpawnCertServerSnapin(LPWSTR wszServiceDN);
  166. STDMETHODIMP _CRLFromDN(LPWSTR wszCDPDN, PCCRL_CONTEXT *ppCRL);
  167. STDMETHODIMP _LaunchCRLDialog(PCCRL_CONTEXT pCRL);
  168. STDMETHODIMP _OnExportCRL (PCCRL_CONTEXT pCRL);
  169. LPDSOBJECTNAMES m_Names;
  170. DWORD m_idManage;
  171. DWORD m_idOpen;
  172. DWORD m_idExport;
  173. };
  174. #endif