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.

1427 lines
46 KiB

  1. //+---------------------------------------------------------------------------
  2. /////////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Microsoft Windows
  5. // Copyright (C) Microsoft Corporation, 1997-2001.
  6. //
  7. // File: ComponentDataMenus.cpp
  8. //
  9. // Contents: Implementation of menu stuff CCertMgrComponentData
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "stdafx.h"
  13. USE_HANDLE_MACROS ("CERTMGR (compdata.cpp)")
  14. #include <gpedit.h>
  15. #include "compdata.h"
  16. #include "dataobj.h"
  17. #include "cookie.h"
  18. #include "Certifct.h"
  19. #ifdef _DEBUG
  20. #ifndef ALPHA
  21. #define new DEBUG_NEW
  22. #endif
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. ///////////////////////////////////////////////////////////////////////////////
  27. // IExtendContextMenu implementation
  28. //
  29. STDMETHODIMP CCertMgrComponentData::AddMenuItems (LPDATAOBJECT pDataObject,
  30. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  31. long *pInsertionAllowed)
  32. {
  33. HRESULT hr = S_OK;
  34. // Don't add any menu items if the computer is known not to be valid.
  35. if ( !m_fInvalidComputer )
  36. {
  37. _TRACE (1, L"Entering CCertMgrComponentData::AddMenuItems\n");
  38. BOOL bIsFileView = !m_szFileName.IsEmpty ();
  39. CCertMgrCookie* pCookie = 0;
  40. LPDATAOBJECT pMSDO = ExtractMultiSelect (pDataObject);
  41. m_bMultipleObjectsSelected = false;
  42. if ( pMSDO )
  43. {
  44. m_bMultipleObjectsSelected = true;
  45. CCertMgrDataObject* pDO = reinterpret_cast <CCertMgrDataObject*>(pMSDO);
  46. ASSERT (pDO);
  47. if ( pDO )
  48. {
  49. // Get first cookie - all items should be the same?
  50. // Is this a valid assumption?
  51. // TODO: Verify
  52. pDO->Reset();
  53. if ( pDO->Next(1, reinterpret_cast<MMC_COOKIE*>(&pCookie), NULL) == S_FALSE )
  54. return S_FALSE;
  55. }
  56. else
  57. return E_UNEXPECTED;
  58. }
  59. else
  60. pCookie = ConvertCookie (pDataObject);
  61. ASSERT (pCookie);
  62. if ( !pCookie )
  63. return E_UNEXPECTED;
  64. CertificateManagerObjectType objType = pCookie->m_objecttype;
  65. // Don't add menu items if this is a serialized file
  66. if ( *pInsertionAllowed & CCM_INSERTIONALLOWED_TOP )
  67. {
  68. switch (objType)
  69. {
  70. case CERTMGR_CERTIFICATE:
  71. if ( !m_bMultipleObjectsSelected )
  72. {
  73. CCertificate* pCert = reinterpret_cast <CCertificate*> (pCookie);
  74. ASSERT (pCert);
  75. if ( pCert )
  76. {
  77. hr = AddOpenMenuItem (pContextMenuCallback,
  78. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  79. }
  80. else
  81. hr = E_FAIL;
  82. }
  83. break;
  84. case CERTMGR_CRL:
  85. if ( !m_bMultipleObjectsSelected )
  86. hr = AddCRLOpenMenuItem (pContextMenuCallback,
  87. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  88. break;
  89. case CERTMGR_CTL:
  90. if ( !m_bMultipleObjectsSelected )
  91. hr = AddCTLOpenMenuItem (pContextMenuCallback,
  92. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  93. break;
  94. case CERTMGR_SNAPIN:
  95. if ( CERT_SYSTEM_STORE_CURRENT_USER != m_dwLocationPersist )
  96. {
  97. hr = AddChangeComputerMenuItem (pContextMenuCallback,
  98. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  99. }
  100. // fall through
  101. case CERTMGR_PHYS_STORE:
  102. case CERTMGR_USAGE:
  103. case CERTMGR_LOG_STORE:
  104. ASSERT (!m_bMultipleObjectsSelected);
  105. hr = AddFindMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TOP);
  106. break;
  107. case CERTMGR_LOG_STORE_RSOP:
  108. break;
  109. case CERTMGR_PKP_AUTOENROLLMENT_COMPUTER_SETTINGS:
  110. case CERTMGR_PKP_AUTOENROLLMENT_USER_SETTINGS:
  111. break;
  112. case CERTMGR_LOG_STORE_GPE:
  113. ASSERT (!m_bMultipleObjectsSelected);
  114. {
  115. CCertStoreGPE* pStore = reinterpret_cast <CCertStoreGPE*>
  116. (pCookie);
  117. ASSERT (pStore);
  118. if ( pStore )
  119. {
  120. switch (pStore->GetStoreType ())
  121. {
  122. case TRUST_STORE:
  123. case ROOT_STORE:
  124. if ( pStore->GetStoreHandle () )
  125. {
  126. hr = AddImportMenuItem (pContextMenuCallback,
  127. pStore->IsReadOnly (),
  128. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  129. pStore->Close ();
  130. }
  131. break;
  132. case EFS_STORE:
  133. if ( pStore->GetStoreHandle () )
  134. {
  135. hr = AddAddDomainEncryptedRecoveryAgentMenuItem (
  136. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TOP,
  137. pStore->IsReadOnly () );
  138. if ( !m_bMachineIsStandAlone )
  139. {
  140. hr = AddCreateDomainEncryptedRecoveryAgentMenuItem (
  141. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TOP,
  142. pStore->IsReadOnly () );
  143. }
  144. pStore->Close ();
  145. }
  146. else if ( pStore->IsNullEFSPolicy () )
  147. {
  148. hr = AddAddDomainEncryptedRecoveryAgentMenuItem (
  149. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TOP,
  150. pStore->IsReadOnly () );
  151. if ( !m_bMachineIsStandAlone )
  152. {
  153. hr = AddCreateDomainEncryptedRecoveryAgentMenuItem (
  154. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TOP,
  155. pStore->IsReadOnly () );
  156. }
  157. pStore->Close ();
  158. }
  159. break;
  160. default:
  161. break;
  162. }
  163. }
  164. }
  165. break;
  166. case CERTMGR_CRL_CONTAINER:
  167. case CERTMGR_CTL_CONTAINER:
  168. case CERTMGR_CERT_CONTAINER:
  169. ASSERT (!m_bMultipleObjectsSelected);
  170. break;
  171. case CERTMGR_SAFER_COMPUTER_LEVEL:
  172. case CERTMGR_SAFER_USER_LEVEL:
  173. if ( m_pGPEInformation )
  174. {
  175. CSaferLevel* pLevel = reinterpret_cast <CSaferLevel*>
  176. (pCookie);
  177. ASSERT (pLevel);
  178. if ( pLevel )
  179. {
  180. // RAID#265590 Safer Windows: "Set as default" menu
  181. // item is enabled in the context menu of a security
  182. // level when the security level is already the default.
  183. if ( ( SAFER_LEVELID_DISALLOWED == pLevel->GetLevel () ||
  184. SAFER_LEVELID_FULLYTRUSTED == pLevel->GetLevel () )
  185. && !pLevel->IsDefault () )
  186. {
  187. hr = AddSaferLevelSetAsDefaultMenuItem (pContextMenuCallback,
  188. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  189. }
  190. }
  191. }
  192. break;
  193. case CERTMGR_SAFER_COMPUTER_ENTRIES:
  194. case CERTMGR_SAFER_USER_ENTRIES:
  195. if ( m_pGPEInformation )
  196. hr = AddSaferNewEntryMenuItems (pContextMenuCallback,
  197. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  198. break;
  199. case CERTMGR_SAFER_COMPUTER_ROOT:
  200. case CERTMGR_SAFER_USER_ROOT:
  201. {
  202. CSaferRootCookie* pSaferRootCookie = dynamic_cast <CSaferRootCookie*> (pCookie);
  203. if ( pSaferRootCookie )
  204. {
  205. if ( !pSaferRootCookie->m_bCreateSaferNodes && !m_bIsRSOP)
  206. hr = AddSaferCreateNewPolicyMenuItems (pContextMenuCallback,
  207. CCM_INSERTIONPOINTID_PRIMARY_TOP);
  208. }
  209. }
  210. break;
  211. default:
  212. break;
  213. }
  214. }
  215. if ( *pInsertionAllowed & CCM_INSERTIONALLOWED_NEW )
  216. {
  217. if ( CERTMGR_LOG_STORE_GPE == objType )
  218. {
  219. ASSERT (!m_bMultipleObjectsSelected);
  220. CCertStoreGPE* pStore = reinterpret_cast <CCertStoreGPE*>
  221. (pCookie);
  222. ASSERT (pStore);
  223. if ( pStore && pStore->GetStoreHandle () )
  224. {
  225. switch (pStore->GetStoreType ())
  226. {
  227. case TRUST_STORE:
  228. hr = AddCTLNewMenuItem (pContextMenuCallback,
  229. CCM_INSERTIONPOINTID_PRIMARY_NEW, pStore->IsReadOnly ());
  230. break;
  231. case ACRS_STORE:
  232. hr = AddACRSNewMenuItem (pContextMenuCallback,
  233. CCM_INSERTIONPOINTID_PRIMARY_NEW, pStore->IsReadOnly ());
  234. break;
  235. case EFS_STORE:
  236. hr = AddAddDomainEncryptedRecoveryAgentMenuItem (
  237. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_NEW,
  238. pStore->IsReadOnly ());
  239. break;
  240. default:
  241. break;
  242. }
  243. pStore->Close ();
  244. }
  245. }
  246. }
  247. if ( *pInsertionAllowed & CCM_INSERTIONALLOWED_TASK )
  248. {
  249. switch (objType)
  250. {
  251. case CERTMGR_CERTIFICATE:
  252. if ( !m_bIsRSOP )
  253. {
  254. CCertificate* pCert =
  255. reinterpret_cast <CCertificate*> (pCookie);
  256. ASSERT (pCert);
  257. if ( pCert && pCert->GetCertStore () )
  258. {
  259. hr = AddCertificateTaskMenuItems (
  260. pContextMenuCallback,
  261. (pCert->GetStoreType () == MY_STORE),
  262. pCert->GetCertStore ()->IsReadOnly (),
  263. pCert);
  264. }
  265. }
  266. break;
  267. case CERTMGR_CRL:
  268. if ( !m_bMultipleObjectsSelected )
  269. {
  270. AddCRLOpenMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  271. if ( !m_bIsRSOP )
  272. AddCRLExportMenuItem (pContextMenuCallback);
  273. }
  274. break;
  275. case CERTMGR_AUTO_CERT_REQUEST:
  276. if ( !m_bMultipleObjectsSelected && !m_bIsRSOP )
  277. {
  278. CAutoCertRequest* pAutoCert =
  279. reinterpret_cast <CAutoCertRequest*> (pCookie);
  280. ASSERT (pAutoCert);
  281. if ( pAutoCert )
  282. {
  283. hr = AddACRTaskMenuItems (pContextMenuCallback,
  284. pAutoCert->GetCertStore ().IsReadOnly ());
  285. }
  286. }
  287. break;
  288. case CERTMGR_CTL:
  289. if ( !m_bIsRSOP )
  290. {
  291. CCTL* pCTL =
  292. reinterpret_cast <CCTL*> (pCookie);
  293. ASSERT (pCTL);
  294. if ( pCTL )
  295. {
  296. hr = AddCTLTaskMenuItems (pContextMenuCallback,
  297. pCTL->GetCertStore ().IsReadOnly ());
  298. }
  299. }
  300. break;
  301. case CERTMGR_SNAPIN:
  302. ASSERT (!m_bMultipleObjectsSelected);
  303. hr = AddFindMenuItem (pContextMenuCallback,
  304. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  305. if ( SUCCEEDED (hr) &&
  306. CERT_SYSTEM_STORE_CURRENT_USER != m_dwLocationPersist )
  307. {
  308. hr = AddChangeComputerMenuItem (pContextMenuCallback,
  309. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  310. }
  311. // must be targetting current user OR LOCAL machine, must be joined to domain
  312. if( SUCCEEDED (hr) &&
  313. !m_bMachineIsStandAlone &&
  314. ((CERT_SYSTEM_STORE_CURRENT_USER == m_dwLocationPersist) || (CERT_SYSTEM_STORE_LOCAL_MACHINE == m_dwLocationPersist)) &&
  315. IsLocalComputername (m_strMachineNamePersist))
  316. {
  317. hr = AddPulseAutoEnrollMenuItem(pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  318. }
  319. break;
  320. case CERTMGR_USAGE:
  321. ASSERT (!m_bMultipleObjectsSelected);
  322. hr = AddFindMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  323. if ( !bIsFileView )
  324. {
  325. // Bug 254166 Certificate snapin: options which permit remote machine enrollment/renewal must be removed
  326. if ( IsLocalComputername (m_strMachineNamePersist) && !m_bIsRSOP )
  327. {
  328. hr = AddSeparator (pContextMenuCallback);
  329. // NOTE: New certs will be added only to MY store.
  330. hr = AddEnrollMenuItem (pContextMenuCallback, FALSE);
  331. if ( SUCCEEDED (hr) )
  332. {
  333. hr = AddImportMenuItem (pContextMenuCallback, false,
  334. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  335. }
  336. }
  337. }
  338. break;
  339. case CERTMGR_PHYS_STORE:
  340. ASSERT (!m_bMultipleObjectsSelected);
  341. hr = AddFindMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  342. if ( !bIsFileView && !m_bIsRSOP)
  343. {
  344. hr = AddSeparator (pContextMenuCallback);
  345. {
  346. CCertStore* pStore =
  347. reinterpret_cast <CCertStore*> (pCookie);
  348. ASSERT (pStore);
  349. if ( pStore && pStore->GetStoreHandle () )
  350. {
  351. // Bug 254166 Certificate snapin: options which permit remote machine enrollment/renewal must be removed
  352. if ( pStore->GetStoreType () == MY_STORE &&
  353. IsLocalComputername (m_szManagedComputer) )
  354. {
  355. hr = AddEnrollMenuItem (pContextMenuCallback,
  356. pStore->IsReadOnly ());
  357. }
  358. if ( SUCCEEDED (hr) )
  359. hr = AddImportMenuItem (pContextMenuCallback,
  360. pStore->IsReadOnly (),
  361. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  362. pStore->Close ();
  363. }
  364. }
  365. hr = AddExportStoreMenuItem (pContextMenuCallback);
  366. }
  367. break;
  368. case CERTMGR_LOG_STORE:
  369. ASSERT (!m_bMultipleObjectsSelected);
  370. hr = AddFindMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  371. if ( !bIsFileView && !m_bIsRSOP )
  372. {
  373. hr = AddSeparator (pContextMenuCallback);
  374. {
  375. CCertStore* pStore =
  376. reinterpret_cast <CCertStore*> (pCookie);
  377. ASSERT (pStore);
  378. if ( pStore && pStore->GetStoreHandle () )
  379. {
  380. // Bug 254166 Certificate snapin: options which permit remote machine enrollment/renewal must be removed
  381. if ( pStore->GetStoreType () == MY_STORE &&
  382. IsLocalComputername (m_szManagedComputer) )
  383. {
  384. hr = AddEnrollMenuItem (pContextMenuCallback,
  385. pStore->IsReadOnly ());
  386. }
  387. hr = AddImportMenuItem (pContextMenuCallback,
  388. pStore->IsReadOnly (),
  389. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  390. pStore->Close ();
  391. }
  392. }
  393. }
  394. break;
  395. case CERTMGR_LOG_STORE_RSOP:
  396. break;
  397. case CERTMGR_PKP_AUTOENROLLMENT_COMPUTER_SETTINGS:
  398. case CERTMGR_PKP_AUTOENROLLMENT_USER_SETTINGS:
  399. break;
  400. case CERTMGR_LOG_STORE_GPE:
  401. ASSERT (!m_bMultipleObjectsSelected);
  402. {
  403. CCertStoreGPE* pStore = reinterpret_cast <CCertStoreGPE*>
  404. (pCookie);
  405. ASSERT (pStore);
  406. if ( pStore )
  407. {
  408. switch (pStore->GetStoreType ())
  409. {
  410. case TRUST_STORE:
  411. case ROOT_STORE:
  412. if ( pStore->GetStoreHandle () && !m_bIsRSOP )
  413. {
  414. hr = AddImportMenuItem (pContextMenuCallback,
  415. pStore->IsReadOnly (),
  416. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  417. pStore->Close ();
  418. }
  419. break;
  420. case EFS_STORE:
  421. if ( pStore->GetStoreHandle () )
  422. {
  423. hr = AddAddDomainEncryptedRecoveryAgentMenuItem (
  424. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK,
  425. pStore->IsReadOnly () );
  426. if ( !m_bMachineIsStandAlone )
  427. {
  428. hr = AddCreateDomainEncryptedRecoveryAgentMenuItem (
  429. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK,
  430. pStore->IsReadOnly () );
  431. }
  432. hr = AddDeletePolicyMenuItem (pContextMenuCallback,
  433. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  434. pStore->Close ();
  435. }
  436. else if ( pStore->IsNullEFSPolicy () )
  437. {
  438. hr = AddAddDomainEncryptedRecoveryAgentMenuItem (
  439. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK,
  440. pStore->IsReadOnly () );
  441. if ( !m_bMachineIsStandAlone )
  442. {
  443. hr = AddCreateDomainEncryptedRecoveryAgentMenuItem (
  444. pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK,
  445. pStore->IsReadOnly () );
  446. }
  447. hr = AddInitPolicyMenuItem (pContextMenuCallback,
  448. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  449. pStore->Close ();
  450. }
  451. break;
  452. default:
  453. break;
  454. }
  455. }
  456. }
  457. break;
  458. case CERTMGR_CRL_CONTAINER:
  459. ASSERT (!m_bMultipleObjectsSelected);
  460. break;
  461. case CERTMGR_CTL_CONTAINER:
  462. ASSERT (!m_bMultipleObjectsSelected);
  463. if ( !bIsFileView && !m_bIsRSOP )
  464. {
  465. CContainerCookie* pCont =
  466. reinterpret_cast <CContainerCookie*> (pCookie);
  467. ASSERT (pCont);
  468. if ( pCont )
  469. {
  470. hr = AddImportMenuItem (pContextMenuCallback,
  471. pCont->GetCertStore ().IsReadOnly (),
  472. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  473. }
  474. }
  475. break;
  476. case CERTMGR_CERT_CONTAINER:
  477. ASSERT (!m_bMultipleObjectsSelected);
  478. if ( !bIsFileView && !m_bIsRSOP )
  479. {
  480. CContainerCookie* pContainer =
  481. reinterpret_cast <CContainerCookie*> (pCookie);
  482. ASSERT (pContainer);
  483. if ( pContainer )
  484. {
  485. // Bug 254166 Certificate snapin: options which permit remote machine enrollment/renewal must be removed
  486. if ( pContainer->GetStoreType () == MY_STORE &&
  487. IsLocalComputername (m_szManagedComputer) )
  488. {
  489. hr = AddEnrollMenuItem (pContextMenuCallback,
  490. pContainer->GetCertStore ().IsReadOnly ());
  491. }
  492. hr = AddImportMenuItem (pContextMenuCallback,
  493. pContainer->GetCertStore ().IsReadOnly (),
  494. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  495. }
  496. }
  497. break;
  498. case CERTMGR_SAFER_COMPUTER_LEVEL:
  499. case CERTMGR_SAFER_USER_LEVEL:
  500. if ( m_pGPEInformation )
  501. {
  502. CSaferLevel* pLevel = reinterpret_cast <CSaferLevel*>
  503. (pCookie);
  504. ASSERT (pLevel);
  505. if ( pLevel )
  506. {
  507. // RAID#265590 Safer Windows: "Set as default" menu
  508. // item is enabled in the context menu of a security
  509. // level when the security level is already the default.
  510. if ( (SAFER_LEVELID_DISALLOWED == pLevel->GetLevel () ||
  511. SAFER_LEVELID_FULLYTRUSTED == pLevel->GetLevel ())
  512. && !pLevel->IsDefault () )
  513. {
  514. hr = AddSaferLevelSetAsDefaultMenuItem (pContextMenuCallback,
  515. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  516. }
  517. }
  518. }
  519. break;
  520. case CERTMGR_SAFER_COMPUTER_ENTRIES:
  521. case CERTMGR_SAFER_USER_ENTRIES:
  522. if ( m_pGPEInformation )
  523. hr = AddSaferNewEntryMenuItems (pContextMenuCallback,
  524. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  525. break;
  526. case CERTMGR_SAFER_COMPUTER_ROOT:
  527. case CERTMGR_SAFER_USER_ROOT:
  528. {
  529. CSaferRootCookie* pSaferRootCookie = dynamic_cast <CSaferRootCookie*> (pCookie);
  530. if ( pSaferRootCookie )
  531. {
  532. if ( !pSaferRootCookie->m_bCreateSaferNodes && !m_bIsRSOP)
  533. hr = AddSaferCreateNewPolicyMenuItems (pContextMenuCallback,
  534. CCM_INSERTIONPOINTID_PRIMARY_TASK);
  535. }
  536. }
  537. break;
  538. default:
  539. break;
  540. }
  541. }
  542. if ( *pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW )
  543. {
  544. switch (objType)
  545. {
  546. case CERTMGR_CERTIFICATE:
  547. case CERTMGR_CRL:
  548. case CERTMGR_CTL:
  549. case CERTMGR_AUTO_CERT_REQUEST:
  550. break;
  551. case CERTMGR_SNAPIN:
  552. case CERTMGR_PHYS_STORE:
  553. case CERTMGR_USAGE:
  554. case CERTMGR_LOG_STORE:
  555. ASSERT (!m_bMultipleObjectsSelected);
  556. hr = AddOptionsMenuItem (pContextMenuCallback);
  557. break;
  558. default:
  559. break;
  560. }
  561. }
  562. _TRACE (-1, L"Leaving CCertMgrComponentData::AddMenuItems: 0x%x\n", hr);
  563. }
  564. return hr;
  565. }
  566. HRESULT CCertMgrComponentData::AddACRSNewMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID, bool bIsReadOnly)
  567. {
  568. _TRACE (1, L"Entering CCertMgrComponentData::AddACRSNewMenuItem\n");
  569. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  570. ASSERT (pContextMenuCallback);
  571. HRESULT hr = S_OK;
  572. CONTEXTMENUITEM menuItem;
  573. CString szMenu;
  574. CString szHint;
  575. // unchanging settings
  576. ::ZeroMemory (&menuItem, sizeof (menuItem));
  577. menuItem.lInsertionPointID = lInsertionPointID;
  578. menuItem.fFlags = 0;
  579. VERIFY (szMenu.LoadString (IDS_NEW_AUTO_CERT_REQUEST));
  580. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  581. VERIFY (szHint.LoadString (IDS_NEW_AUTO_CERT_REQUEST_HINT));
  582. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  583. menuItem.lCommandID = IDM_NEW_ACRS;
  584. if ( bIsReadOnly )
  585. menuItem.fFlags = MF_GRAYED;
  586. hr = pContextMenuCallback->AddItem (&menuItem);
  587. ASSERT (SUCCEEDED (hr));
  588. _TRACE (-1, L"Leaving CCertMgrComponentData::AddACRSNewMenuItem: 0x%x\n", hr);
  589. return hr;
  590. }
  591. HRESULT CCertMgrComponentData::AddCertificateTaskMenuItems (
  592. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  593. const bool bIsMyStore,
  594. bool bIsReadOnly,
  595. CCertificate* /*pCert*/)
  596. {
  597. _TRACE (1, L"Entering CCertMgrComponentData::AddCertificateTaskMenuItems\n");
  598. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  599. ASSERT (pContextMenuCallback);
  600. HRESULT hr = S_OK;
  601. CONTEXTMENUITEM menuItem;
  602. CString szMenu;
  603. CString szHint;
  604. // unchanging settings
  605. ::ZeroMemory (&menuItem, sizeof (menuItem));
  606. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  607. menuItem.fFlags = 0;
  608. menuItem.fSpecialFlags = 0;
  609. if ( !m_bMultipleObjectsSelected )
  610. {
  611. AddOpenMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  612. AddSeparator (pContextMenuCallback);
  613. if ( m_szFileName.IsEmpty () )
  614. {
  615. // Bug 254166 Certificate snapin: options which permit remote machine enrollment/renewal must be removed
  616. if ( bIsMyStore &&
  617. CERT_SYSTEM_STORE_SERVICES != m_dwLocationPersist &&
  618. IsLocalComputername (m_szManagedComputer) )
  619. {
  620. VERIFY (szMenu.LoadString (IDS_ENROLL_CERT_WITH_NEW_KEY));
  621. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  622. VERIFY (szHint.LoadString (IDS_ENROLL_CERT_WITH_NEW_KEY_HINT));
  623. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  624. menuItem.lCommandID = IDM_ENROLL_NEW_CERT_NEW_KEY;
  625. if ( bIsReadOnly )
  626. menuItem.fFlags = MF_GRAYED;
  627. hr = pContextMenuCallback->AddItem (&menuItem);
  628. ASSERT (SUCCEEDED (hr));
  629. VERIFY (szMenu.LoadString (IDS_ENROLL_CERT_WITH_SAME_KEY));
  630. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  631. VERIFY (szHint.LoadString (IDS_ENROLL_CERT_WITH_SAME_KEY_HINT));
  632. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  633. menuItem.lCommandID = IDM_ENROLL_NEW_CERT_SAME_KEY;
  634. if ( bIsReadOnly )
  635. menuItem.fFlags = MF_GRAYED;
  636. hr = pContextMenuCallback->AddItem (&menuItem);
  637. ASSERT (SUCCEEDED (hr));
  638. VERIFY (szMenu.LoadString (IDS_RENEW_NEW_KEY));
  639. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  640. VERIFY (szHint.LoadString (IDS_RENEW_NEW_KEY_HINT));
  641. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  642. menuItem.lCommandID = IDM_TASK_RENEW_NEW_KEY;
  643. if ( bIsReadOnly )
  644. menuItem.fFlags = MF_GRAYED;
  645. hr = pContextMenuCallback->AddItem (&menuItem);
  646. ASSERT (SUCCEEDED (hr));
  647. VERIFY (szMenu.LoadString (IDS_RENEW_SAME_KEY));
  648. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  649. VERIFY (szHint.LoadString (IDS_RENEW_SAME_KEY_HINT));
  650. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  651. menuItem.lCommandID = IDM_TASK_RENEW_SAME_KEY;
  652. if ( bIsReadOnly )
  653. menuItem.fFlags = MF_GRAYED;
  654. hr = pContextMenuCallback->AddItem (&menuItem);
  655. ASSERT (SUCCEEDED (hr));
  656. }
  657. }
  658. }
  659. hr = AddExportMenuItem (pContextMenuCallback);
  660. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCertificateTaskMenuItems: 0x%x\n", hr);
  661. return hr;
  662. }
  663. HRESULT CCertMgrComponentData::AddCTLTaskMenuItems (LPCONTEXTMENUCALLBACK pContextMenuCallback, bool bIsReadOnly)
  664. {
  665. _TRACE (1, L"Entering CCertMgrComponentData::AddCTLTaskMenuItems\n");
  666. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  667. ASSERT (pContextMenuCallback);
  668. HRESULT hr = S_OK;
  669. CONTEXTMENUITEM menuItem;
  670. CString szMenu;
  671. CString szHint;
  672. // unchanging settings
  673. ::ZeroMemory (&menuItem, sizeof (menuItem));
  674. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  675. menuItem.fFlags = 0;
  676. menuItem.fSpecialFlags = 0;
  677. if ( !m_bMultipleObjectsSelected )
  678. AddCTLOpenMenuItem (pContextMenuCallback, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  679. hr = AddCTLExportMenuItem (pContextMenuCallback);
  680. if ( !m_bMultipleObjectsSelected )
  681. {
  682. VERIFY (szMenu.LoadString (IDS_EDIT));
  683. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  684. VERIFY (szHint.LoadString (IDS_CTL_EDIT_HINT));
  685. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  686. menuItem.lCommandID = IDM_CTL_EDIT;
  687. if ( bIsReadOnly )
  688. menuItem.fFlags = MF_GRAYED;
  689. hr = pContextMenuCallback->AddItem (&menuItem);
  690. ASSERT (SUCCEEDED (hr));
  691. }
  692. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCTLTaskMenuItems: 0x%x\n", hr);
  693. return hr;
  694. }
  695. HRESULT CCertMgrComponentData::AddACRTaskMenuItems (LPCONTEXTMENUCALLBACK pContextMenuCallback, bool bIsReadOnly)
  696. {
  697. _TRACE (1, L"Entering CCertMgrComponentData::AddACRTaskMenuItems\n");
  698. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  699. ASSERT (pContextMenuCallback);
  700. HRESULT hr = S_OK;
  701. CONTEXTMENUITEM menuItem;
  702. CString szMenu;
  703. CString szHint;
  704. // unchanging settings
  705. ::ZeroMemory (&menuItem, sizeof (menuItem));
  706. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  707. menuItem.fFlags = 0;
  708. menuItem.fSpecialFlags = 0;
  709. VERIFY (szMenu.LoadString (IDS_EDIT));
  710. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  711. VERIFY (szHint.LoadString (IDS_ACR_EDIT_HINT));
  712. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  713. menuItem.lCommandID = IDM_EDIT_ACRS;
  714. if ( bIsReadOnly )
  715. menuItem.fFlags = MF_GRAYED;
  716. hr = pContextMenuCallback->AddItem (&menuItem);
  717. ASSERT (SUCCEEDED (hr));
  718. _TRACE (-1, L"Leaving CCertMgrComponentData::AddACRTaskMenuItems: 0x%x\n", hr);
  719. return hr;
  720. }
  721. HRESULT CCertMgrComponentData::AddEnrollMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, bool bIsReadOnly)
  722. {
  723. _TRACE (1, L"Entering CCertMgrComponentData::AddEnrollMenuItem\n");
  724. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  725. ASSERT (pContextMenuCallback);
  726. HRESULT hr = S_OK;
  727. if ( CERT_SYSTEM_STORE_SERVICES != m_dwLocationPersist )
  728. {
  729. CONTEXTMENUITEM menuItem;
  730. CString szMenu;
  731. CString szHint;
  732. ::ZeroMemory (&menuItem, sizeof (menuItem));
  733. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  734. menuItem.fFlags = 0;
  735. menuItem.fSpecialFlags = 0;
  736. VERIFY (szMenu.LoadString (IDS_ENROLL_NEW_CERT));
  737. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  738. VERIFY (szHint.LoadString (IDS_ENROLL_NEW_CERT_HINT));
  739. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  740. menuItem.lCommandID = IDM_ENROLL_NEW_CERT;
  741. if ( bIsReadOnly )
  742. menuItem.fFlags = MF_GRAYED;
  743. hr = pContextMenuCallback->AddItem (&menuItem);
  744. ASSERT (SUCCEEDED (hr));
  745. }
  746. _TRACE (-1, L"Leaving CCertMgrComponentData::AddEnrollMenuItem: 0x%x\n", hr);
  747. return hr;
  748. }
  749. HRESULT CCertMgrComponentData::AddFindMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  750. {
  751. _TRACE (1, L"Entering CCertMgrComponentData::AddFindMenuItem\n");
  752. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  753. ASSERT (pContextMenuCallback);
  754. HRESULT hr = S_OK;
  755. CONTEXTMENUITEM menuItem;
  756. CString szMenu;
  757. CString szHint;
  758. // unchanging settings
  759. ::ZeroMemory (&menuItem, sizeof (menuItem));
  760. menuItem.lInsertionPointID = lInsertionPointID;
  761. menuItem.fFlags = 0;
  762. menuItem.fSpecialFlags = 0;
  763. VERIFY (szMenu.LoadString (IDS_FIND));
  764. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  765. VERIFY (szHint.LoadString (IDS_FIND_HINT));
  766. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  767. if ( CCM_INSERTIONPOINTID_PRIMARY_TOP == lInsertionPointID )
  768. menuItem.lCommandID = IDM_TOP_FIND;
  769. else
  770. menuItem.lCommandID = IDM_TASK_FIND;
  771. hr = pContextMenuCallback->AddItem (&menuItem);
  772. ASSERT (SUCCEEDED (hr));
  773. _TRACE (-1, L"Leaving CCertMgrComponentData::AddFindMenuItem: 0x%x\n", hr);
  774. return hr;
  775. }
  776. HRESULT CCertMgrComponentData::AddPulseAutoEnrollMenuItem(LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  777. {
  778. _TRACE (1, L"Entering CCertMgrComponentData::AddPulseAutoEnrollMenuItem\n");
  779. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  780. ASSERT (pContextMenuCallback);
  781. HRESULT hr = S_OK;
  782. CONTEXTMENUITEM menuItem;
  783. CString szMenu;
  784. CString szHint;
  785. // unchanging settings
  786. ::ZeroMemory (&menuItem, sizeof (menuItem));
  787. menuItem.lInsertionPointID = lInsertionPointID;
  788. menuItem.fFlags = 0;
  789. menuItem.fSpecialFlags = 0;
  790. VERIFY (szMenu.LoadString (IDS_PULSEAUTOENROLL));
  791. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  792. VERIFY (szHint.LoadString (IDS_PULSEAUTOENROLL_HINT));
  793. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  794. menuItem.lCommandID = IDM_TASK_PULSEAUTOENROLL;
  795. hr = pContextMenuCallback->AddItem (&menuItem);
  796. ASSERT (SUCCEEDED (hr));
  797. _TRACE (-1, L"Leaving CCertMgrComponentData::AddPulseAutoEnrollMenuItem: 0x%x\n", hr);
  798. return hr;
  799. }
  800. HRESULT CCertMgrComponentData::AddChangeComputerMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  801. {
  802. _TRACE (1, L"Entering CCertMgrComponentData::AddChangeComputerMenuItem\n");
  803. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  804. ASSERT (pContextMenuCallback);
  805. HRESULT hr = S_OK;
  806. CONTEXTMENUITEM menuItem;
  807. CString szMenu;
  808. CString szHint;
  809. // unchanging settings
  810. ::ZeroMemory (&menuItem, sizeof (menuItem));
  811. menuItem.lInsertionPointID = lInsertionPointID;
  812. menuItem.fFlags = 0;
  813. menuItem.fSpecialFlags = 0;
  814. VERIFY (szMenu.LoadString (IDS_CHANGE_COMPUTER));
  815. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  816. VERIFY (szHint.LoadString (IDS_CHANGE_COMPUTER_HINT));
  817. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  818. if ( CCM_INSERTIONPOINTID_PRIMARY_TOP == lInsertionPointID )
  819. menuItem.lCommandID = IDM_TOP_CHANGE_COMPUTER;
  820. else
  821. menuItem.lCommandID = IDM_TASK_CHANGE_COMPUTER;
  822. hr = pContextMenuCallback->AddItem (&menuItem);
  823. ASSERT (SUCCEEDED (hr));
  824. _TRACE (-1, L"Leaving CCertMgrComponentData::AddChangeComputerMenuItem: 0x%x\n", hr);
  825. return hr;
  826. }
  827. HRESULT CCertMgrComponentData::AddSeparator (LPCONTEXTMENUCALLBACK pContextMenuCallback)
  828. {
  829. _TRACE (1, L"Entering CCertMgrComponentData::AddSeparator\n");
  830. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  831. ASSERT (pContextMenuCallback);
  832. CONTEXTMENUITEM menuItem;
  833. ::ZeroMemory (&menuItem, sizeof (menuItem));
  834. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  835. menuItem.fSpecialFlags = 0;
  836. menuItem.strName = _T ("Separator"); // Dummy name
  837. menuItem.strStatusBarText = _T ("Separator");// Dummy status text
  838. menuItem.lCommandID = ID_SEPARATOR; // Command ID
  839. menuItem.fFlags = MF_SEPARATOR; // most important the flag
  840. HRESULT hr = pContextMenuCallback->AddItem (&menuItem);
  841. _TRACE (-1, L"Leaving CCertMgrComponentData::AddSeparator: 0x%x\n", hr);
  842. return hr;
  843. }
  844. HRESULT CCertMgrComponentData::AddImportMenuItem (
  845. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  846. bool bIsReadOnly,
  847. LONG lInsertionPointID)
  848. {
  849. _TRACE (1, L"Entering CCertMgrComponentData::AddImportMenuItem\n");
  850. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  851. ASSERT (pContextMenuCallback);
  852. HRESULT hr = S_OK;
  853. CONTEXTMENUITEM menuItem;
  854. CString szMenu;
  855. CString szHint;
  856. ::ZeroMemory (&menuItem, sizeof (menuItem));
  857. menuItem.lInsertionPointID = lInsertionPointID;
  858. menuItem.fFlags = 0;
  859. menuItem.fSpecialFlags = 0;
  860. VERIFY (szMenu.LoadString (IDS_IMPORT));
  861. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  862. VERIFY (szHint.LoadString (IDS_IMPORT_HINT));
  863. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  864. menuItem.lCommandID = IDM_TASK_IMPORT;
  865. if ( bIsReadOnly )
  866. menuItem.fFlags = MF_GRAYED;
  867. hr = pContextMenuCallback->AddItem (&menuItem);
  868. ASSERT (SUCCEEDED (hr));
  869. _TRACE (-1, L"Leaving CCertMgrComponentData::AddImportMenuItem: 0x%x\n", hr);
  870. return hr;
  871. }
  872. HRESULT CCertMgrComponentData::AddExportStoreMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback)
  873. {
  874. _TRACE (1, L"Entering CCertMgrComponentData::AddExportStoreMenuItem\n");
  875. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  876. ASSERT (pContextMenuCallback);
  877. HRESULT hr = S_OK;
  878. CONTEXTMENUITEM menuItem;
  879. CString szMenu;
  880. CString szHint;
  881. // unchanging settings
  882. ::ZeroMemory (&menuItem, sizeof (menuItem));
  883. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  884. menuItem.fFlags = 0;
  885. menuItem.fSpecialFlags = 0;
  886. VERIFY (szMenu.LoadString (IDS_EXPORT_STORE));
  887. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  888. VERIFY (szHint.LoadString (IDS_EXPORT_STORE_HINT));
  889. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  890. menuItem.lCommandID = IDM_TASK_EXPORT_STORE;
  891. hr = pContextMenuCallback->AddItem (&menuItem);
  892. ASSERT (SUCCEEDED (hr));
  893. _TRACE (-1, L"Leaving CCertMgrComponentData::AddExportStoreMenuItem: 0x%x\n", hr);
  894. return hr;
  895. }
  896. HRESULT CCertMgrComponentData::AddExportMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback)
  897. {
  898. _TRACE (1, L"Entering CCertMgrComponentData::AddExportMenuItem\n");
  899. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  900. ASSERT (pContextMenuCallback);
  901. HRESULT hr = S_OK;
  902. CONTEXTMENUITEM menuItem;
  903. CString szMenu;
  904. CString szHint;
  905. // unchanging settings
  906. ::ZeroMemory (&menuItem, sizeof (menuItem));
  907. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  908. menuItem.fFlags = 0;
  909. menuItem.fSpecialFlags = 0;
  910. VERIFY (szMenu.LoadString (IDS_EXPORT));
  911. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  912. VERIFY (szHint.LoadString (IDS_EXPORT_HINT));
  913. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  914. menuItem.lCommandID = IDM_TASK_EXPORT;
  915. hr = pContextMenuCallback->AddItem (&menuItem);
  916. ASSERT (SUCCEEDED (hr));
  917. _TRACE (-1, L"Leaving CCertMgrComponentData::AddExportMenuItem: 0x%x\n", hr);
  918. return hr;
  919. }
  920. HRESULT CCertMgrComponentData::AddCTLExportMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback)
  921. {
  922. _TRACE (1, L"Entering CCertMgrComponentData::AddCTLExportMenuItem\n");
  923. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  924. ASSERT (pContextMenuCallback);
  925. HRESULT hr = S_OK;
  926. CONTEXTMENUITEM menuItem;
  927. CString szMenu;
  928. CString szHint;
  929. // unchanging settings
  930. ::ZeroMemory (&menuItem, sizeof (menuItem));
  931. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  932. menuItem.fFlags = 0;
  933. menuItem.fSpecialFlags = 0;
  934. VERIFY (szMenu.LoadString (IDS_EXPORT));
  935. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  936. VERIFY (szHint.LoadString (IDS_CTL_EXPORT_HINT));
  937. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  938. menuItem.lCommandID = IDM_TASK_CTL_EXPORT;
  939. hr = pContextMenuCallback->AddItem (&menuItem);
  940. ASSERT (SUCCEEDED (hr));
  941. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCTLExportMenuItem: 0x%x\n", hr);
  942. return hr;
  943. }
  944. HRESULT CCertMgrComponentData::AddCRLExportMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback)
  945. {
  946. _TRACE (1, L"Entering CCertMgrComponentData::AddCRLExportMenuItem\n");
  947. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  948. ASSERT (pContextMenuCallback);
  949. HRESULT hr = S_OK;
  950. CONTEXTMENUITEM menuItem;
  951. CString szMenu;
  952. CString szHint;
  953. // unchanging settings
  954. ::ZeroMemory (&menuItem, sizeof (menuItem));
  955. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  956. menuItem.fFlags = 0;
  957. menuItem.fSpecialFlags = 0;
  958. VERIFY (szMenu.LoadString (IDS_EXPORT));
  959. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  960. VERIFY (szHint.LoadString (IDS_CRL_EXPORT_HINT));
  961. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  962. menuItem.lCommandID = IDM_TASK_CRL_EXPORT;
  963. hr = pContextMenuCallback->AddItem (&menuItem);
  964. ASSERT (SUCCEEDED (hr));
  965. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCRLExportMenuItem: 0x%x\n", hr);
  966. return hr;
  967. }
  968. HRESULT CCertMgrComponentData::AddOpenMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  969. {
  970. _TRACE (1, L"Entering CCertMgrComponentData::AddOpenMenuItem\n");
  971. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  972. ASSERT (pContextMenuCallback);
  973. HRESULT hr = S_OK;
  974. CONTEXTMENUITEM menuItem;
  975. CString szMenu;
  976. CString szHint;
  977. // unchanging settings
  978. ::ZeroMemory (&menuItem, sizeof (menuItem));
  979. menuItem.lInsertionPointID = lInsertionPointID;
  980. menuItem.fFlags = 0;
  981. VERIFY (szMenu.LoadString (IDS_VIEW));
  982. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  983. VERIFY (szHint.LoadString (IDS_VIEW_HINT));
  984. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  985. menuItem.lCommandID = (CCM_INSERTIONPOINTID_PRIMARY_TOP == lInsertionPointID)
  986. ? IDM_OPEN : IDM_TASK_OPEN;
  987. menuItem.fSpecialFlags = CCM_SPECIAL_DEFAULT_ITEM;
  988. hr = pContextMenuCallback->AddItem (&menuItem);
  989. ASSERT (SUCCEEDED (hr));
  990. _TRACE (-1, L"Leaving CCertMgrComponentData::AddOpenMenuItem: 0x%x\n", hr);
  991. return hr;
  992. }
  993. HRESULT CCertMgrComponentData::AddCTLOpenMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  994. {
  995. _TRACE (1, L"Entering CCertMgrComponentData::AddCTLOpenMenuItem\n");
  996. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  997. ASSERT (pContextMenuCallback);
  998. HRESULT hr = S_OK;
  999. CONTEXTMENUITEM menuItem;
  1000. CString szMenu;
  1001. CString szHint;
  1002. // unchanging settings
  1003. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1004. menuItem.lInsertionPointID = lInsertionPointID;
  1005. menuItem.fFlags = 0;
  1006. VERIFY (szMenu.LoadString (IDS_VIEW));
  1007. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1008. VERIFY (szHint.LoadString (IDS_CTL_VIEW_HINT));
  1009. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1010. menuItem.lCommandID = (CCM_INSERTIONPOINTID_PRIMARY_TOP == lInsertionPointID)
  1011. ? IDM_OPEN : IDM_TASK_OPEN;
  1012. menuItem.fSpecialFlags = CCM_SPECIAL_DEFAULT_ITEM;
  1013. hr = pContextMenuCallback->AddItem (&menuItem);
  1014. ASSERT (SUCCEEDED (hr));
  1015. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCTLOpenMenuItem: 0x%x\n", hr);
  1016. return hr;
  1017. }
  1018. HRESULT CCertMgrComponentData::AddCRLOpenMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  1019. {
  1020. _TRACE (1, L"Entering CCertMgrComponentData::AddCRLOpenMenuItem\n");
  1021. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1022. ASSERT (pContextMenuCallback);
  1023. HRESULT hr = S_OK;
  1024. CONTEXTMENUITEM menuItem;
  1025. CString szMenu;
  1026. CString szHint;
  1027. // unchanging settings
  1028. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1029. menuItem.lInsertionPointID = lInsertionPointID;
  1030. menuItem.fFlags = 0;
  1031. VERIFY (szMenu.LoadString (IDS_VIEW));
  1032. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1033. VERIFY (szHint.LoadString (IDS_CRL_VIEW_HINT));
  1034. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1035. menuItem.lCommandID = (CCM_INSERTIONPOINTID_PRIMARY_TOP == lInsertionPointID)
  1036. ? IDM_OPEN : IDM_TASK_OPEN;
  1037. menuItem.fSpecialFlags = CCM_SPECIAL_DEFAULT_ITEM;
  1038. hr = pContextMenuCallback->AddItem (&menuItem);
  1039. ASSERT (SUCCEEDED (hr));
  1040. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCRLOpenMenuItem: 0x%x\n", hr);
  1041. return hr;
  1042. }
  1043. HRESULT CCertMgrComponentData::AddAddDomainEncryptedRecoveryAgentMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID, bool bIsReadOnly)
  1044. {
  1045. _TRACE (1, L"Entering CCertMgrComponentData::AddAddDomainEncryptedRecoveryAgentMenuItem\n");
  1046. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1047. ASSERT (pContextMenuCallback);
  1048. HRESULT hr = S_OK;
  1049. CONTEXTMENUITEM menuItem;
  1050. CString szMenu;
  1051. CString szHint;
  1052. // unchanging settings
  1053. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1054. menuItem.lInsertionPointID = lInsertionPointID;
  1055. menuItem.fFlags = 0;
  1056. if ( lInsertionPointID == CCM_INSERTIONPOINTID_PRIMARY_TOP )
  1057. {
  1058. VERIFY (szMenu.LoadString (IDS_ADD_DATA_RECOVERY_AGENT));
  1059. menuItem.lCommandID = IDM_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT;
  1060. }
  1061. else if ( lInsertionPointID == CCM_INSERTIONPOINTID_PRIMARY_TASK )
  1062. {
  1063. VERIFY (szMenu.LoadString (IDS_ADD_DATA_RECOVERY_AGENT));
  1064. menuItem.lCommandID = IDM_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT1;
  1065. }
  1066. else if ( lInsertionPointID == CCM_INSERTIONPOINTID_PRIMARY_NEW )
  1067. {
  1068. VERIFY (szMenu.LoadString (IDS_ENCRYPTED_RECOVERY_AGENT));
  1069. menuItem.lCommandID = IDM_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT2;
  1070. }
  1071. else
  1072. {
  1073. ASSERT (0);
  1074. return E_UNEXPECTED;
  1075. }
  1076. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1077. VERIFY (szHint.LoadString (IDS_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT_HINT));
  1078. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1079. if ( bIsReadOnly )
  1080. menuItem.fFlags = MF_GRAYED;
  1081. hr = pContextMenuCallback->AddItem (&menuItem);
  1082. ASSERT (SUCCEEDED (hr));
  1083. _TRACE (-1, L"Leaving CCertMgrComponentData::AddAddDomainEncryptedRecoveryAgentMenuItem: 0x%x\n", hr);
  1084. return hr;
  1085. }
  1086. HRESULT CCertMgrComponentData::AddCreateDomainEncryptedRecoveryAgentMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID, bool bIsReadOnly)
  1087. {
  1088. _TRACE (1, L"Entering CCertMgrComponentData::AddCreateDomainEncryptedRecoveryAgentMenuItem\n");
  1089. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1090. ASSERT (pContextMenuCallback);
  1091. HRESULT hr = S_OK;
  1092. CONTEXTMENUITEM menuItem;
  1093. CString szMenu;
  1094. CString szHint;
  1095. // unchanging settings
  1096. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1097. menuItem.lInsertionPointID = lInsertionPointID;
  1098. menuItem.fFlags = 0;
  1099. VERIFY (szMenu.LoadString (IDS_CREATE));
  1100. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1101. VERIFY (szHint.LoadString (IDS_CREATE_DOMAIN_ENCRYPTED_RECOVERY_AGENT_HINT));
  1102. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1103. menuItem.lCommandID = IDM_CREATE_DOMAIN_ENCRYPTED_RECOVERY_AGENT;
  1104. if ( bIsReadOnly )
  1105. menuItem.fFlags = MF_GRAYED;
  1106. hr = pContextMenuCallback->AddItem (&menuItem);
  1107. ASSERT (SUCCEEDED (hr));
  1108. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCreateDomainEncryptedRecoveryAgentMenuItem: 0x%x\n", hr);
  1109. return hr;
  1110. }
  1111. HRESULT CCertMgrComponentData::AddInitPolicyMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  1112. {
  1113. _TRACE (1, L"Entering CCertMgrComponentData::AddInitPolicyMenuItem\n");
  1114. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1115. ASSERT (pContextMenuCallback);
  1116. HRESULT hr = S_OK;
  1117. CONTEXTMENUITEM menuItem;
  1118. CString szMenu;
  1119. CString szHint;
  1120. // unchanging settings
  1121. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1122. menuItem.lInsertionPointID = lInsertionPointID;
  1123. menuItem.fFlags = 0;
  1124. VERIFY (szMenu.LoadString (IDS_INIT_POLICY));
  1125. menuItem.lCommandID = IDM_INIT_POLICY;
  1126. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1127. VERIFY (szHint.LoadString (IDS_INIT_POLICY_HINT));
  1128. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1129. hr = pContextMenuCallback->AddItem (&menuItem);
  1130. ASSERT (SUCCEEDED (hr));
  1131. _TRACE (-1, L"Leaving CCertMgrComponentData::AddInitPolicyMenuItem: 0x%x\n", hr);
  1132. return hr;
  1133. }
  1134. HRESULT CCertMgrComponentData::AddDeletePolicyMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback, LONG lInsertionPointID)
  1135. {
  1136. _TRACE (1, L"Entering CCertMgrComponentData::AddDeletePolicyMenuItem\n");
  1137. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1138. ASSERT (pContextMenuCallback);
  1139. HRESULT hr = S_OK;
  1140. CONTEXTMENUITEM menuItem;
  1141. CString szMenu;
  1142. CString szHint;
  1143. // unchanging settings
  1144. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1145. menuItem.lInsertionPointID = lInsertionPointID;
  1146. menuItem.fFlags = 0;
  1147. if ( lInsertionPointID == CCM_INSERTIONPOINTID_PRIMARY_TOP )
  1148. {
  1149. VERIFY (szMenu.LoadString (IDS_DEL_POLICY));
  1150. menuItem.lCommandID = IDM_DEL_POLICY;
  1151. }
  1152. else if ( lInsertionPointID == CCM_INSERTIONPOINTID_PRIMARY_TASK )
  1153. {
  1154. VERIFY (szMenu.LoadString (IDS_DEL_POLICY));
  1155. menuItem.lCommandID = IDM_DEL_POLICY1;
  1156. }
  1157. else
  1158. {
  1159. ASSERT (0);
  1160. return E_UNEXPECTED;
  1161. }
  1162. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1163. VERIFY (szHint.LoadString (IDS_DEL_POLICY_HINT));
  1164. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1165. hr = pContextMenuCallback->AddItem (&menuItem);
  1166. ASSERT (SUCCEEDED (hr));
  1167. _TRACE (-1, L"Leaving CCertMgrComponentData::AddDeletePolicyMenuItem: 0x%x\n", hr);
  1168. return hr;
  1169. }
  1170. HRESULT CCertMgrComponentData::AddCTLNewMenuItem (LPCONTEXTMENUCALLBACK pContextMenuCallback,
  1171. LONG lInsertionPointID, bool bIsReadOnly)
  1172. {
  1173. _TRACE (1, L"Entering CCertMgrComponentData::AddCTLNewMenuItem\n");
  1174. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1175. ASSERT (pContextMenuCallback);
  1176. HRESULT hr = S_OK;
  1177. CONTEXTMENUITEM menuItem;
  1178. CString szMenu;
  1179. CString szHint;
  1180. // unchanging settings
  1181. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1182. menuItem.lInsertionPointID = lInsertionPointID;
  1183. menuItem.fFlags = 0;
  1184. VERIFY (szMenu.LoadString (IDS_NEW_CTL));
  1185. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1186. VERIFY (szHint.LoadString (IDS_NEW_CTL_HINT));
  1187. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1188. menuItem.lCommandID = IDM_NEW_CTL;
  1189. if ( bIsReadOnly )
  1190. menuItem.fFlags = MF_GRAYED;
  1191. hr = pContextMenuCallback->AddItem (&menuItem);
  1192. ASSERT (SUCCEEDED (hr));
  1193. _TRACE (-1, L"Leaving CCertMgrComponentData::AddCTLNewMenuItem: 0x%x\n", hr);
  1194. return hr;
  1195. }
  1196. HRESULT CCertMgrComponentData::AddSaferCreateNewPolicyMenuItems (
  1197. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  1198. LONG lInsertionPointID)
  1199. {
  1200. _TRACE (1, L"Entering CCertMgrComponentData::AddSaferCreateNewPolicyMenuItems\n");
  1201. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1202. ASSERT (pContextMenuCallback);
  1203. HRESULT hr = S_OK;
  1204. CONTEXTMENUITEM menuItem;
  1205. CString szMenu;
  1206. CString szHint;
  1207. // unchanging settings
  1208. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1209. menuItem.lInsertionPointID = lInsertionPointID;
  1210. menuItem.fFlags = 0;
  1211. VERIFY (szMenu.LoadString (IDS_NEW_SAFER_POLICY));
  1212. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1213. VERIFY (szHint.LoadString (IDS_NEW_SAFER_POLICY_HINT));
  1214. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1215. menuItem.lCommandID = CCM_INSERTIONPOINTID_PRIMARY_TOP == lInsertionPointID ?
  1216. IDM_TOP_CREATE_NEW_SAFER_POLICY : IDM_TASK_CREATE_NEW_SAFER_POLICY;
  1217. hr = pContextMenuCallback->AddItem (&menuItem);
  1218. ASSERT (SUCCEEDED (hr));
  1219. _TRACE (-1, L"Leaving CCertMgrComponentData::AddSaferCreateNewPolicyMenuItems: 0x%x\n", hr);
  1220. return hr;
  1221. }
  1222. HRESULT CCertMgrComponentData::AddOptionsMenuItem(LPCONTEXTMENUCALLBACK pContextMenuCallback)
  1223. {
  1224. _TRACE (1, L"Entering CCertMgrComponentData::AddOptionsMenuItem\n");
  1225. AFX_MANAGE_STATE (AfxGetStaticModuleState ());
  1226. ASSERT (pContextMenuCallback);
  1227. HRESULT hr = S_OK;
  1228. CONTEXTMENUITEM menuItem;
  1229. CString szMenu;
  1230. CString szHint;
  1231. // unchanging settings
  1232. ::ZeroMemory (&menuItem, sizeof (menuItem));
  1233. menuItem.fFlags = 0;
  1234. menuItem.fSpecialFlags = 0;
  1235. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  1236. VERIFY (szMenu.LoadString (IDS_OPTIONS));
  1237. menuItem.strName = (PWSTR) (PCWSTR) szMenu;
  1238. VERIFY (szHint.LoadString (IDS_OPTIONS_HINT));
  1239. menuItem.strStatusBarText = (PWSTR) (PCWSTR) szHint;
  1240. menuItem.lCommandID = IDM_OPTIONS;
  1241. hr = pContextMenuCallback->AddItem (&menuItem);
  1242. ASSERT (SUCCEEDED (hr));
  1243. _TRACE (-1, L"LeavingLeaving CCertMgrComponentData::AddOptionsMenuItem: 0x%x\n", hr);
  1244. return hr;
  1245. }