Leaked source code of windows server 2003
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.

1806 lines
60 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: ContextMenu.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "dsutil.h"
  12. #include "ContextMenu.h"
  13. #include "dsfilter.h"
  14. #include "resource.h"
  15. #include "query.h"
  16. /////////////////////////////////////////////////////////////////////
  17. // Language independent IDs for known context menu items
  18. // WARNING : these should NEVER be changed
  19. // the whole point of having these is so that other
  20. // developers can rely on them being the same no matter
  21. // what language or version they use. The context menus
  22. // can change but their IDs should not
  23. //
  24. //
  25. #define CMID_GEN_TASK_SELECT_FOREST L"_DSADMIN_SELECT_FOREST"
  26. #define CMID_GEN_TASK_SELECT_DOMAIN L"_DSADMIN_SELECT_DOMAIN"
  27. #define CMID_GEN_TASK_SELECT_DC L"_DSADMIN_SELECT_DC"
  28. #define CMID_GEN_TASK_EDIT_FSMO L"_DSADMIN_EDIT_FSMO"
  29. #define CMID_GEN_TASK_RAISE_VERSION L"_DSADMIN_GEN_RAISE_VERSION"
  30. #define CMID_VIEW_SERVICES_NODE L"_DSADMIN_VIEW_SERVICES"
  31. #define CMID_VIEW_COMPUTER_HACK L"_DSADMIN_VIEW_COMPUTERS_AS_CONTAINERS"
  32. #define CMID_VIEW_ADVANCED L"_DSADMIN_VIEW_ADVANCED"
  33. #define CMID_IMPORT_QUERY L"_DSADMIN_IMPORT_QUERY"
  34. #define CMID_NEW_QUERY_FOLDER L"_DSADMIN_NEW_QUERY"
  35. #define CMID_NEW_FAVORITES_FOLDER L"_DSADMIN_NEW_FAVORITES"
  36. #define CMID_EDIT_QUERY L"_DSADMIN_EDIT_QUERY"
  37. #define CMID_EXPORT_QUERY L"_DSADMIN_EXPORT_QUERY"
  38. #define CMID_VIEW_FILTER_OPTIONS L"_DSADMIN_VIEW_FILTER"
  39. #define CMID_DS_OBJECT_FIND L"_DSADMIN_FIND"
  40. #define CMID_GEN_TASK_RUN_KCC L"_DSADMIN_RUN_KCC"
  41. #define CMID_GEN_TASK_MOVE L"_DSADMIN_MOVE"
  42. // Schema version containing the adminMultiselectPropertyPages attribute
  43. #define SCHEMA_VERSION_WITH_MULTISELECT_PROPPAGES 15
  44. void CContextMenuVerbs::LoadStandardVerbs(IConsoleVerb* pConsoleVerb,
  45. BOOL bScope,
  46. BOOL bSelect,
  47. CUINode* pUINode,
  48. CInternalFormatCracker& ifc,
  49. LPDATAOBJECT pDataObject)
  50. {
  51. if (!bSelect || pUINode == NULL)
  52. {
  53. return;
  54. }
  55. if (pConsoleVerb)
  56. {
  57. if (bScope)
  58. {
  59. //
  60. // Item is in scope pane. Therefore it is a container.
  61. //
  62. pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  63. }
  64. else
  65. {
  66. //
  67. // Item is in result pane. Make properties the default verb.
  68. //
  69. pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  70. }
  71. //
  72. // Verbs supported by all items, except root
  73. //
  74. if (pDataObject != NULL && ifc.GetCookieCount() > 1)
  75. {
  76. //
  77. // multiple selection
  78. //
  79. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, TRUE);
  80. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, FALSE);
  81. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, TRUE);
  82. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, FALSE);
  83. if (pUINode->IsSnapinRoot() ||
  84. (pUINode->GetParent() && pUINode->GetParent()->IsSnapinRoot()))
  85. {
  86. // Everything should be disabled if we are looking at children of
  87. // the root
  88. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, TRUE);
  89. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, FALSE);
  90. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  91. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, FALSE);
  92. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, TRUE);
  93. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, FALSE);
  94. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, TRUE);
  95. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, FALSE);
  96. }
  97. else
  98. {
  99. //
  100. // Can delete
  101. //
  102. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, FALSE);
  103. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, TRUE);
  104. //
  105. // Properties - multiselect properties are only available for
  106. // schema version 15 or greater
  107. //
  108. UINT schemaVersion = m_pComponentData->GetBasePathsInfo()->GetSchemaVersion();
  109. TRACE(L"Schema version = %d\n", schemaVersion);
  110. if (schemaVersion >= SCHEMA_VERSION_WITH_MULTISELECT_PROPPAGES)
  111. {
  112. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, FALSE);
  113. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
  114. }
  115. else
  116. {
  117. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  118. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, FALSE);
  119. }
  120. //
  121. // Can cut
  122. //
  123. // NOTICE: we use the same logic as the delete verb: we
  124. // always allow cut, even though the single items in the
  125. // multiple selection might have Cut turned off.
  126. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, FALSE);
  127. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, TRUE);
  128. //
  129. // Can copy
  130. //
  131. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, TRUE);
  132. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, FALSE);
  133. }
  134. }
  135. else // single selection
  136. {
  137. BOOL bEnable = FALSE;
  138. BOOL bHide = TRUE;
  139. //
  140. // Properties
  141. //
  142. bEnable = pUINode->ArePropertiesAllowed(m_pComponentData, &bHide);
  143. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, bHide);
  144. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, bEnable);
  145. //
  146. // Rename
  147. //
  148. bEnable = pUINode->IsRenameAllowed(m_pComponentData, &bHide);
  149. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, bHide);
  150. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, bEnable);
  151. //
  152. // Delete
  153. //
  154. bEnable = pUINode->IsDeleteAllowed(m_pComponentData, &bHide);
  155. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, bHide);
  156. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, bEnable);
  157. //
  158. // Refresh
  159. //
  160. bEnable = pUINode->IsRefreshAllowed(m_pComponentData, &bHide);
  161. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, bHide);
  162. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, bEnable);
  163. //
  164. // Cut
  165. //
  166. bEnable = pUINode->IsCutAllowed(m_pComponentData, &bHide);
  167. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, bHide);
  168. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, bEnable);
  169. //
  170. // Copy
  171. //
  172. bEnable = pUINode->IsCopyAllowed(m_pComponentData, &bHide);
  173. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, bHide);
  174. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, bEnable);
  175. //
  176. // Paste
  177. //
  178. bEnable = pUINode->IsPasteAllowed(m_pComponentData, &bHide);
  179. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, HIDDEN, bHide);
  180. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, ENABLED, bEnable);
  181. //
  182. // Print
  183. //
  184. bEnable = pUINode->IsPrintAllowed(m_pComponentData, &bHide);
  185. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, HIDDEN, bHide);
  186. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, ENABLED, bEnable);
  187. }
  188. }
  189. }
  190. HRESULT CContextMenuVerbs::DSLoadAndAddMenuItem(IContextMenuCallback2* pIContextMenuCallback,
  191. UINT nResourceID, // contains text and status text seperated by '\n'
  192. long lCommandID,
  193. long lInsertionPointID,
  194. long fFlags,
  195. PCWSTR pszLanguageIndependentID,
  196. long fSpecialFlags)
  197. {
  198. ASSERT( pIContextMenuCallback != NULL );
  199. // load the resource
  200. CString strText;
  201. strText.LoadString( nResourceID );
  202. ASSERT( !strText.IsEmpty() );
  203. // split the resource into the menu text and status text
  204. CString strStatusText;
  205. int iSeparator = strText.Find(_T('\n'));
  206. if (0 > iSeparator)
  207. {
  208. ASSERT( FALSE );
  209. strStatusText = strText;
  210. }
  211. else
  212. {
  213. strStatusText = strText.Right( strText.GetLength()-(iSeparator+1) );
  214. strText = strText.Left( iSeparator );
  215. }
  216. // add the menu item
  217. USES_CONVERSION;
  218. CONTEXTMENUITEM2 contextmenuitem;
  219. ::ZeroMemory( &contextmenuitem, sizeof(contextmenuitem) );
  220. contextmenuitem.strName = T2OLE(const_cast<LPTSTR>((LPCTSTR)strText));
  221. contextmenuitem.strStatusBarText = T2OLE(const_cast<LPTSTR>((LPCTSTR)strStatusText));
  222. contextmenuitem.lCommandID = lCommandID;
  223. contextmenuitem.lInsertionPointID = lInsertionPointID;
  224. contextmenuitem.fFlags = fFlags;
  225. contextmenuitem.fSpecialFlags = ((fFlags & MF_POPUP) ? CCM_SPECIAL_SUBMENU : 0L) | fSpecialFlags;
  226. contextmenuitem.strLanguageIndependentName = const_cast<PWSTR>(pszLanguageIndependentID);
  227. HRESULT hr = pIContextMenuCallback->AddItem( &contextmenuitem );
  228. ASSERT(hr == S_OK);
  229. return hr;
  230. }
  231. /////////////////////////////////////////////////////////////////////////////
  232. // CSnapinRootMenuVerbs
  233. //
  234. HRESULT CSnapinRootMenuVerbs::LoadTopMenu(IContextMenuCallback2* pContextMenuCallback,
  235. CUINode*)
  236. {
  237. TRACE(_T("CSnapinRootMenuVerbs::LoadTopMenu()\n"));
  238. HRESULT hr = S_OK;
  239. UINT nMenuItem = 0;
  240. PCWSTR pszLIID = NULL;
  241. if (m_pComponentData->QuerySnapinType() == SNAPINTYPE_SITE)
  242. {
  243. nMenuItem = IDM_GEN_TASK_SELECT_FOREST;
  244. pszLIID = CMID_GEN_TASK_SELECT_FOREST;
  245. }
  246. else
  247. {
  248. nMenuItem = IDM_GEN_TASK_SELECT_DOMAIN;
  249. pszLIID = CMID_GEN_TASK_SELECT_DOMAIN;
  250. }
  251. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  252. nMenuItem,
  253. nMenuItem,
  254. CCM_INSERTIONPOINTID_PRIMARY_TOP,
  255. 0,
  256. pszLIID);
  257. ASSERT(SUCCEEDED(hr));
  258. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  259. IDM_GEN_TASK_SELECT_DC,
  260. IDM_GEN_TASK_SELECT_DC,
  261. CCM_INSERTIONPOINTID_PRIMARY_TOP,
  262. 0,
  263. pszLIID);
  264. ASSERT(SUCCEEDED(hr));
  265. return hr;
  266. }
  267. HRESULT CSnapinRootMenuVerbs::LoadTaskMenu(IContextMenuCallback2* pContextMenuCallback,
  268. CUINode*)
  269. {
  270. TRACE(_T("CSnapinRootMenuVerbs::LoadTaskMenu()\n"));
  271. HRESULT hr = S_OK;
  272. UINT nMenuItem = 0;
  273. PWSTR pszLIID = NULL;
  274. if (m_pComponentData->QuerySnapinType() == SNAPINTYPE_SITE)
  275. {
  276. nMenuItem = IDM_GEN_TASK_SELECT_FOREST;
  277. pszLIID = CMID_GEN_TASK_SELECT_FOREST;
  278. }
  279. else
  280. {
  281. nMenuItem = IDM_GEN_TASK_SELECT_DOMAIN;
  282. pszLIID = CMID_GEN_TASK_SELECT_DOMAIN;
  283. }
  284. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  285. nMenuItem,
  286. nMenuItem,
  287. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  288. 0,
  289. pszLIID);
  290. ASSERT(SUCCEEDED(hr));
  291. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  292. IDM_GEN_TASK_SELECT_DC,
  293. IDM_GEN_TASK_SELECT_DC,
  294. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  295. 0,
  296. pszLIID);
  297. ASSERT(SUCCEEDED(hr));
  298. if (m_pComponentData->QuerySnapinType() != SNAPINTYPE_SITE &&
  299. m_pComponentData->GetBasePathsInfo()->IsInitialized())
  300. {
  301. //
  302. // Load Operations Masters... menu
  303. //
  304. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  305. IDM_GEN_TASK_EDIT_FSMO,
  306. IDM_GEN_TASK_EDIT_FSMO,
  307. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  308. 0,
  309. CMID_GEN_TASK_EDIT_FSMO);
  310. ASSERT(SUCCEEDED(hr));
  311. //
  312. // Load Raise Domain Version... menu item.
  313. //
  314. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  315. IDM_GEN_TASK_RAISE_VERSION,
  316. IDM_GEN_TASK_RAISE_VERSION,
  317. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  318. 0,
  319. CMID_GEN_TASK_RAISE_VERSION);
  320. ASSERT(SUCCEEDED(hr));
  321. }
  322. return hr;
  323. }
  324. HRESULT CSnapinRootMenuVerbs::LoadViewMenu(IContextMenuCallback2* pContextMenuCallback,
  325. CUINode*)
  326. {
  327. HRESULT hr = S_OK;
  328. if (m_pComponentData->QuerySnapinType() == SNAPINTYPE_SITE)
  329. {
  330. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  331. IDM_VIEW_SERVICES_NODE,
  332. IDM_VIEW_SERVICES_NODE,
  333. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  334. m_pComponentData->ViewServicesNode()? MF_CHECKED : 0,
  335. CMID_VIEW_SERVICES_NODE);
  336. ASSERT(SUCCEEDED(hr));
  337. }
  338. else
  339. {
  340. //
  341. // AD U&G
  342. //
  343. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  344. IDM_VIEW_COMPUTER_HACK,
  345. IDM_VIEW_COMPUTER_HACK,
  346. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  347. m_pComponentData->ExpandComputers()? MF_CHECKED : 0,
  348. CMID_VIEW_COMPUTER_HACK);
  349. ASSERT(SUCCEEDED(hr));
  350. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  351. IDM_VIEW_ADVANCED,
  352. IDM_VIEW_ADVANCED,
  353. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  354. m_pComponentData->GetQueryFilter()->IsAdvancedView()? MF_CHECKED : 0,
  355. CMID_VIEW_ADVANCED);
  356. ASSERT(SUCCEEDED(hr));
  357. if (m_pComponentData->QuerySnapinType() != SNAPINTYPE_SITE &&
  358. m_pComponentData->GetBasePathsInfo()->IsInitialized())
  359. {
  360. //
  361. // Load Raise Domain Version... menu item.
  362. //
  363. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  364. IDM_GEN_TASK_RAISE_VERSION,
  365. IDM_GEN_TASK_RAISE_VERSION,
  366. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  367. 0,
  368. CMID_GEN_TASK_RAISE_VERSION);
  369. ASSERT(SUCCEEDED(hr));
  370. }
  371. if (m_pComponentData->IsPrimarySnapin())
  372. {
  373. //
  374. // Insert these if running as a primary snapin and not an extension
  375. //
  376. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  377. IDM_VIEW_FILTER_OPTIONS,
  378. IDM_VIEW_FILTER_OPTIONS,
  379. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  380. 0,
  381. CMID_VIEW_FILTER_OPTIONS);
  382. ASSERT(SUCCEEDED(hr));
  383. }
  384. }
  385. return hr;
  386. }
  387. /////////////////////////////////////////////////////////////////////////////
  388. // CFavoritesFolderMenuVerbs
  389. //
  390. void CFavoritesFolderMenuVerbs::LoadStandardVerbs(IConsoleVerb* pConsoleVerb,
  391. BOOL bScope,
  392. BOOL bSelect,
  393. CUINode* pUINode,
  394. CInternalFormatCracker& ifc,
  395. LPDATAOBJECT pDataObject)
  396. {
  397. if (!bSelect || pUINode == NULL)
  398. {
  399. return;
  400. }
  401. if (pConsoleVerb)
  402. {
  403. if (bScope)
  404. {
  405. //
  406. // Item is in scope pane. Therefore it is a container.
  407. //
  408. pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  409. }
  410. else
  411. {
  412. //
  413. // Item is in result pane. Make properties the default verb.
  414. //
  415. pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  416. }
  417. //
  418. // Verbs supported by all items, except root
  419. //
  420. if (pDataObject != NULL && ifc.GetCookieCount() > 1)
  421. {
  422. //
  423. // multiple selection
  424. //
  425. if (pUINode->IsSnapinRoot() ||
  426. (pUINode->GetParent() && pUINode->GetParent()->IsSnapinRoot()))
  427. {
  428. // Everything should be disabled if we are looking at children of
  429. // the root
  430. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, TRUE);
  431. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, FALSE);
  432. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  433. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, FALSE);
  434. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, TRUE);
  435. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, FALSE);
  436. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, TRUE);
  437. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, FALSE);
  438. }
  439. else
  440. {
  441. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, TRUE);
  442. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, FALSE);
  443. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, TRUE);
  444. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, FALSE);
  445. //
  446. // Can delete
  447. //
  448. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, FALSE);
  449. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, TRUE);
  450. //
  451. // Properties
  452. //
  453. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  454. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, FALSE);
  455. //
  456. // Can cut
  457. //
  458. // NOTICE: we use the same logic as the delete verb: we
  459. // always allow cut, even though the single items in the
  460. // multiple selection might have Cut turned off.
  461. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, FALSE);
  462. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, TRUE);
  463. //
  464. // Can copy
  465. //
  466. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, FALSE);
  467. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, TRUE);
  468. }
  469. }
  470. else // single selection
  471. {
  472. BOOL bEnable = FALSE;
  473. BOOL bHide = TRUE;
  474. //
  475. // Properties
  476. //
  477. bEnable = pUINode->ArePropertiesAllowed(m_pComponentData, &bHide);
  478. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, bHide);
  479. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, bEnable);
  480. //
  481. // Rename
  482. //
  483. bEnable = pUINode->IsRenameAllowed(m_pComponentData, &bHide);
  484. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, bHide);
  485. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, bEnable);
  486. //
  487. // Delete
  488. //
  489. bEnable = pUINode->IsDeleteAllowed(m_pComponentData, &bHide);
  490. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, bHide);
  491. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, bEnable);
  492. //
  493. // Refresh
  494. //
  495. bEnable = pUINode->IsRefreshAllowed(m_pComponentData, &bHide);
  496. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, bHide);
  497. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, bEnable);
  498. //
  499. // Paste
  500. //
  501. bEnable = pUINode->IsPasteAllowed(m_pComponentData, &bHide);
  502. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, HIDDEN, bHide);
  503. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, ENABLED, bEnable);
  504. //
  505. // Cut
  506. //
  507. bEnable = pUINode->IsCutAllowed(m_pComponentData, &bHide);
  508. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, bHide);
  509. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, bEnable);
  510. //
  511. // Copy
  512. //
  513. bEnable = pUINode->IsCopyAllowed(m_pComponentData, &bHide);
  514. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, bHide);
  515. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, bEnable);
  516. //
  517. // Print
  518. //
  519. bEnable = pUINode->IsPrintAllowed(m_pComponentData, &bHide);
  520. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, HIDDEN, bHide);
  521. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, ENABLED, bEnable);
  522. }
  523. }
  524. }
  525. HRESULT CFavoritesFolderMenuVerbs::LoadTopMenu(IContextMenuCallback2* pContextMenuCallback,
  526. CUINode*)
  527. {
  528. HRESULT hr = S_OK;
  529. long flags = 0;
  530. if (!m_pComponentData->GetBasePathsInfo()->IsInitialized())
  531. {
  532. flags |= MF_GRAYED;
  533. }
  534. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  535. IDM_IMPORT_QUERY,
  536. IDM_IMPORT_QUERY,
  537. CCM_INSERTIONPOINTID_PRIMARY_TOP,
  538. flags,
  539. CMID_IMPORT_QUERY);
  540. ASSERT(SUCCEEDED(hr));
  541. return hr;
  542. }
  543. HRESULT CFavoritesFolderMenuVerbs::LoadTaskMenu(IContextMenuCallback2* pContextMenuCallback,
  544. CUINode*)
  545. {
  546. HRESULT hr = S_OK;
  547. long flags = 0;
  548. if (!m_pComponentData->GetBasePathsInfo()->IsInitialized())
  549. {
  550. flags |= MF_GRAYED;
  551. }
  552. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  553. IDM_IMPORT_QUERY,
  554. IDM_IMPORT_QUERY,
  555. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  556. flags,
  557. CMID_IMPORT_QUERY);
  558. ASSERT(SUCCEEDED(hr));
  559. return hr;
  560. }
  561. HRESULT CFavoritesFolderMenuVerbs::LoadNewMenu(IContextMenuCallback2* pContextMenuCallback,
  562. IShellExtInit*,
  563. LPDATAOBJECT,
  564. CUINode*,
  565. long*)
  566. {
  567. HRESULT hr = S_OK;
  568. long flags = 0;
  569. if (!m_pComponentData->GetBasePathsInfo()->IsInitialized())
  570. {
  571. flags |= MF_GRAYED;
  572. }
  573. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  574. IDM_NEW_QUERY_FOLDER,
  575. IDM_NEW_QUERY_FOLDER,
  576. CCM_INSERTIONPOINTID_PRIMARY_NEW,
  577. flags,
  578. CMID_NEW_QUERY_FOLDER);
  579. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  580. IDM_NEW_FAVORITES_FOLDER,
  581. IDM_NEW_FAVORITES_FOLDER,
  582. CCM_INSERTIONPOINTID_PRIMARY_NEW,
  583. 0,
  584. CMID_NEW_FAVORITES_FOLDER);
  585. return hr;
  586. }
  587. HRESULT CFavoritesFolderMenuVerbs::LoadViewMenu(IContextMenuCallback2* pContextMenuCallback,
  588. CUINode*)
  589. {
  590. HRESULT hr = S_OK;
  591. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  592. IDM_VIEW_ADVANCED,
  593. IDM_VIEW_ADVANCED,
  594. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  595. m_pComponentData->GetQueryFilter()->IsAdvancedView()? MF_CHECKED : 0,
  596. CMID_VIEW_ADVANCED);
  597. ASSERT(SUCCEEDED(hr));
  598. return hr;
  599. }
  600. /////////////////////////////////////////////////////////////////////////////
  601. // CSavedQueryMenuVerbs
  602. //
  603. void CSavedQueryMenuVerbs::LoadStandardVerbs(IConsoleVerb* pConsoleVerb,
  604. BOOL bScope,
  605. BOOL bSelect,
  606. CUINode* pUINode,
  607. CInternalFormatCracker& ifc,
  608. LPDATAOBJECT pDataObject)
  609. {
  610. if (!bSelect || pUINode == NULL)
  611. {
  612. return;
  613. }
  614. if (pConsoleVerb)
  615. {
  616. if (bScope)
  617. {
  618. //
  619. // Item is in scope pane. Therefore it is a container.
  620. //
  621. pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  622. }
  623. else
  624. {
  625. //
  626. // Item is in result pane. Make properties the default verb.
  627. //
  628. pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  629. }
  630. //
  631. // Verbs supported by all items, except root
  632. //
  633. if (pDataObject != NULL && ifc.GetCookieCount() > 1)
  634. {
  635. //
  636. // multiple selection
  637. //
  638. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, TRUE);
  639. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, FALSE);
  640. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, TRUE);
  641. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, FALSE);
  642. //
  643. // Can delete
  644. //
  645. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, FALSE);
  646. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, TRUE);
  647. //
  648. // Properties
  649. //
  650. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  651. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, FALSE);
  652. //
  653. // Can cut
  654. //
  655. // NOTICE: we use the same logic as the delete verb: we
  656. // always allow cut, even though the single items in the
  657. // multiple selection might have Cut turned off.
  658. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, FALSE);
  659. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, TRUE);
  660. //
  661. // Can copy
  662. //
  663. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, FALSE);
  664. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, TRUE);
  665. }
  666. else // single selection
  667. {
  668. BOOL bEnable = FALSE;
  669. BOOL bHide = TRUE;
  670. //
  671. // Properties
  672. //
  673. bEnable = pUINode->ArePropertiesAllowed(m_pComponentData, &bHide);
  674. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, bHide);
  675. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, bEnable);
  676. //
  677. // Rename
  678. //
  679. bEnable = pUINode->IsRenameAllowed(m_pComponentData, &bHide);
  680. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, bHide);
  681. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, bEnable);
  682. //
  683. // Delete
  684. //
  685. bEnable = pUINode->IsDeleteAllowed(m_pComponentData, &bHide);
  686. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, bHide);
  687. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, bEnable);
  688. //
  689. // Refresh
  690. //
  691. bEnable = pUINode->IsRefreshAllowed(m_pComponentData, &bHide);
  692. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, bHide);
  693. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, bEnable);
  694. //
  695. // Cut
  696. //
  697. bEnable = pUINode->IsCutAllowed(m_pComponentData, &bHide);
  698. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, bHide);
  699. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, bEnable);
  700. //
  701. // Copy
  702. //
  703. bEnable = pUINode->IsCopyAllowed(m_pComponentData, &bHide);
  704. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, bHide);
  705. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, bEnable);
  706. //
  707. // Paste
  708. //
  709. bEnable = pUINode->IsPasteAllowed(m_pComponentData, &bHide);
  710. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, HIDDEN, bHide);
  711. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, ENABLED, bEnable);
  712. //
  713. // Cut
  714. //
  715. bEnable = pUINode->IsCutAllowed(m_pComponentData, &bHide);
  716. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, bHide);
  717. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, bEnable);
  718. //
  719. // Print
  720. //
  721. bEnable = pUINode->IsPrintAllowed(m_pComponentData, &bHide);
  722. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, HIDDEN, bHide);
  723. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, ENABLED, bEnable);
  724. }
  725. }
  726. }
  727. HRESULT CSavedQueryMenuVerbs::LoadTopMenu(IContextMenuCallback2* pContextMenuCallback,
  728. CUINode*)
  729. {
  730. HRESULT hr = S_OK;
  731. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  732. IDM_EDIT_QUERY,
  733. IDM_EDIT_QUERY,
  734. CCM_INSERTIONPOINTID_PRIMARY_TOP,
  735. 0,
  736. CMID_EDIT_QUERY);
  737. ASSERT(SUCCEEDED(hr));
  738. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  739. IDM_EXPORT_QUERY,
  740. IDM_EXPORT_QUERY,
  741. CCM_INSERTIONPOINTID_PRIMARY_TOP,
  742. 0,
  743. CMID_EXPORT_QUERY);
  744. ASSERT(SUCCEEDED(hr));
  745. return hr;
  746. }
  747. HRESULT CSavedQueryMenuVerbs::LoadTaskMenu(IContextMenuCallback2* pContextMenuCallback,
  748. CUINode*)
  749. {
  750. HRESULT hr = S_OK;
  751. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  752. IDM_EDIT_QUERY,
  753. IDM_EDIT_QUERY,
  754. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  755. 0,
  756. CMID_EDIT_QUERY);
  757. ASSERT(SUCCEEDED(hr));
  758. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  759. IDM_EXPORT_QUERY,
  760. IDM_EXPORT_QUERY,
  761. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  762. 0,
  763. CMID_EXPORT_QUERY);
  764. ASSERT(SUCCEEDED(hr));
  765. return hr;
  766. }
  767. HRESULT CSavedQueryMenuVerbs::LoadViewMenu(IContextMenuCallback2* pContextMenuCallback,
  768. CUINode*)
  769. {
  770. HRESULT hr = S_OK;
  771. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  772. IDM_VIEW_ADVANCED,
  773. IDM_VIEW_ADVANCED,
  774. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  775. m_pComponentData->GetQueryFilter()->IsAdvancedView()? MF_CHECKED : 0,
  776. CMID_VIEW_ADVANCED);
  777. ASSERT(SUCCEEDED(hr));
  778. return hr;
  779. }
  780. /////////////////////////////////////////////////////////////////////////////
  781. // CDSContextMenuVerbs
  782. //
  783. HRESULT CDSContextMenuVerbs::LoadNewMenu(IContextMenuCallback2* pContextMenuCallback,
  784. IShellExtInit* pShlInit,
  785. LPDATAOBJECT pDataObject,
  786. CUINode* pUINode,
  787. long *pInsertionAllowed)
  788. {
  789. HRESULT hr = S_OK;
  790. UINT cChildCount = 0;
  791. UINT index;
  792. if (pUINode == NULL)
  793. {
  794. ASSERT(FALSE);
  795. return E_INVALIDARG;
  796. }
  797. CDSCookie* pCookie = NULL;
  798. ASSERT(IS_CLASS(pUINode, DS_UI_NODE));
  799. pCookie = GetDSCookieFromUINode(pUINode);
  800. ASSERT(pCookie != NULL);
  801. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  802. TRACE(_T("CDSComponentData::_LoadNewMenu (on %s)\n"), pCookie->GetName());
  803. CWaitCursor cwait;
  804. WCHAR ** ppChildren;
  805. ppChildren = pCookie->GetChildList();
  806. if (ppChildren == NULL)
  807. {
  808. m_pComponentData->FillInChildList (pCookie);
  809. ppChildren = pCookie->GetChildList();
  810. }
  811. ///////////////////////////////////////////////////////////
  812. // get common menu items from DS and merge.
  813. //
  814. HMENU hDSMenu = CreatePopupMenu();
  815. if (hDSMenu == NULL)
  816. {
  817. TRACE(_T("Failed to CreatePopupMenu() in CDSContextMenuVerbs::LoadNewMenu()"));
  818. ASSERT(FALSE);
  819. return GetLastError();
  820. }
  821. BOOL fRet = TRUE;
  822. hr = pShlInit->Initialize(NULL, pDataObject, 0);
  823. if (FAILED(hr))
  824. {
  825. TRACE(TEXT("pShlInit->Initialize failed, hr: 0x%x\n"), hr);
  826. }
  827. else
  828. {
  829. IContextMenu * pICM= NULL;
  830. hr = pShlInit->QueryInterface(IID_IContextMenu, (void **)&pICM);
  831. if (FAILED(hr))
  832. {
  833. TRACE(TEXT("pShlInit->QI for IID_IContextMenu failed, hr: 0x%x\n"), hr);
  834. }
  835. else
  836. {
  837. //
  838. // NOTE: QueryContextMenu returns with the HRESULT with the severity set as normal
  839. // for success and failure but the facility is zero and the code is the
  840. // count of the menu items added
  841. //
  842. hr = pICM->QueryContextMenu (hDSMenu, 0, MENU_MERGE_BASE, MENU_MERGE_LIMIT, NULL);
  843. if ((SUCCEEDED(hr)) && (HRESULT_CODE(hr) > 0))
  844. {
  845. UINT cItems = GetMenuItemCount (hDSMenu);
  846. MENUITEMINFO miiItem;
  847. miiItem.cbSize = sizeof(MENUITEMINFO);
  848. WCHAR szBuffer[MAX_PATH];
  849. for (index = 0; index < cItems; index++)
  850. {
  851. miiItem.fMask = MIIM_TYPE | MIIM_DATA | MIIM_ID | MIIM_SUBMENU | MIIM_STATE;
  852. WCHAR * pszString = new WCHAR[MAX_PATH];
  853. miiItem.dwTypeData = pszString;
  854. miiItem.cch = MAX_PATH;
  855. fRet = GetMenuItemInfo (hDSMenu, index, TRUE, &miiItem);
  856. if (fRet)
  857. {
  858. //
  859. // got item back, add it to MMC context menu
  860. //
  861. CONTEXTMENUITEM2 ctiItem;
  862. ::ZeroMemory( &ctiItem, sizeof(CONTEXTMENUITEM2) );
  863. hr = pICM->GetCommandString (miiItem.wID - MENU_MERGE_BASE,
  864. GCS_HELPTEXT,
  865. NULL,
  866. (char *)szBuffer,
  867. MAX_PATH);
  868. ctiItem.strName = miiItem.dwTypeData;
  869. ctiItem.strStatusBarText = szBuffer;
  870. ctiItem.lCommandID = miiItem.wID;
  871. if (miiItem.fState == MFS_GRAYED)
  872. {
  873. ctiItem.fFlags = MF_GRAYED;
  874. }
  875. else
  876. {
  877. ctiItem.fFlags = 0;
  878. }
  879. ctiItem.fSpecialFlags = 0;
  880. //
  881. // Now try to get a language independent identifier
  882. //
  883. WCHAR szLanguageIndependentID[MAX_PATH];
  884. ::ZeroMemory( szLanguageIndependentID, sizeof(WCHAR) * MAX_PATH);
  885. hr = pICM->GetCommandString(miiItem.wID - MENU_MERGE_BASE,
  886. GCS_VERBW,
  887. NULL,
  888. (char*)szLanguageIndependentID,
  889. MAX_PATH);
  890. if (SUCCEEDED(hr) &&
  891. szLanguageIndependentID &&
  892. szLanguageIndependentID[0] != 0)
  893. {
  894. ctiItem.strLanguageIndependentName = szLanguageIndependentID;
  895. //
  896. // Add the menu item to the Top of the MMC menu
  897. //
  898. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP)
  899. {
  900. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  901. hr = pContextMenuCallback->AddItem( &ctiItem );
  902. ASSERT(SUCCEEDED(hr));
  903. }
  904. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TASK)
  905. {
  906. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  907. hr = pContextMenuCallback->AddItem(&ctiItem );
  908. ASSERT(SUCCEEDED(hr));
  909. }
  910. }
  911. else
  912. {
  913. CComPtr<IContextMenuCallback> spOldCallback;
  914. hr = pContextMenuCallback->QueryInterface(IID_IContextMenuCallback, (void**)&spOldCallback);
  915. if (SUCCEEDED(hr))
  916. {
  917. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TASK)
  918. {
  919. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  920. hr = spOldCallback->AddItem((CONTEXTMENUITEM*)&ctiItem);
  921. ASSERT(SUCCEEDED(hr));
  922. }
  923. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP)
  924. {
  925. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  926. hr = spOldCallback->AddItem((CONTEXTMENUITEM*)&ctiItem);
  927. ASSERT(SUCCEEDED(hr));
  928. }
  929. }
  930. }
  931. }
  932. delete[] pszString;
  933. }
  934. }
  935. }
  936. if (pICM)
  937. {
  938. pICM->Release();
  939. }
  940. }
  941. DestroyMenu(hDSMenu);
  942. ///////////////////////////////////////////////////////////
  943. // Insert the New menu items
  944. cChildCount = pCookie->GetChildCount();
  945. if (cChildCount != 0)
  946. {
  947. for (index = 0; index < cChildCount; index++)
  948. {
  949. CString strItem, strStatus;
  950. strItem = ppChildren[index];
  951. strStatus.LoadString(IDS_CREATEOBJ);
  952. UINT fFlags = 0;
  953. CONTEXTMENUITEM2 contextmenuitem;
  954. WCHAR wszFriendlyName[120];
  955. //
  956. // get localized name for class
  957. //
  958. hr = m_pComponentData->GetBasePathsInfo()->GetFriendlyClassName(ppChildren[index],
  959. wszFriendlyName,
  960. sizeof(wszFriendlyName)/sizeof(WCHAR));
  961. if (SUCCEEDED(hr))
  962. {
  963. strItem = (CString)wszFriendlyName;
  964. }
  965. else
  966. {
  967. strItem = ppChildren[index];
  968. }
  969. ::ZeroMemory( &contextmenuitem, sizeof(contextmenuitem) );
  970. contextmenuitem.strName = T2OLE(const_cast<LPTSTR>((LPCTSTR)strItem));
  971. contextmenuitem.strStatusBarText = T2OLE(const_cast<LPTSTR>((LPCTSTR)strStatus));
  972. contextmenuitem.lCommandID = IDM_NEW_OBJECT_BASE + index;
  973. contextmenuitem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
  974. contextmenuitem.fFlags = fFlags;
  975. contextmenuitem.fSpecialFlags = ((fFlags & MF_POPUP) ? CCM_SPECIAL_SUBMENU : 0L);
  976. contextmenuitem.strLanguageIndependentName = ppChildren[index];
  977. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_NEW)
  978. {
  979. hr = pContextMenuCallback->AddItem( &contextmenuitem );
  980. ASSERT(SUCCEEDED(hr));
  981. }
  982. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP)
  983. {
  984. int nID = InsertAtTopContextMenu(pCookie->GetClass(), ppChildren[index]);
  985. if (0 != nID)
  986. {
  987. CString cstrNewObject;
  988. cstrNewObject.LoadString(nID);
  989. contextmenuitem.strName = T2OLE(const_cast<LPTSTR>((LPCTSTR)cstrNewObject));
  990. contextmenuitem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  991. hr = pContextMenuCallback->AddItem( &contextmenuitem );
  992. ASSERT(SUCCEEDED(hr));
  993. }
  994. }
  995. }
  996. }
  997. return hr;
  998. }
  999. int CDSContextMenuVerbs::InsertAtTopContextMenu(LPCWSTR pwszParentClass, LPCWSTR pwszChildClass)
  1000. {
  1001. int nID = 0;
  1002. if (!wcscmp(pwszParentClass, L"subnetContainer"))
  1003. {
  1004. if (!wcscmp(pwszChildClass, L"subnet"))
  1005. {
  1006. nID = IDS_NEW_SUBNET;
  1007. }
  1008. }
  1009. else if (!wcscmp(pwszParentClass, L"nTDSDSA"))
  1010. {
  1011. if (!wcscmp(pwszChildClass, L"nTDSConnection"))
  1012. {
  1013. nID = IDS_NEW_NTDSCONNECTION;
  1014. }
  1015. }
  1016. else if (!wcscmp(pwszParentClass, L"interSiteTransport"))
  1017. {
  1018. if (!wcscmp(pwszChildClass, L"siteLink"))
  1019. {
  1020. nID = IDS_NEW_SITELINK;
  1021. }
  1022. else if (!wcscmp(pwszChildClass, L"siteLinkBridge"))
  1023. {
  1024. nID = IDS_NEW_SITELINKBRIDGE;
  1025. }
  1026. }
  1027. else if (!wcscmp(pwszParentClass, L"sitesContainer"))
  1028. {
  1029. if (!wcscmp(pwszChildClass, L"site"))
  1030. {
  1031. nID = IDS_NEW_SITE;
  1032. }
  1033. }
  1034. return nID;
  1035. }
  1036. HRESULT CDSContextMenuVerbs::LoadViewMenu(IContextMenuCallback2* pContextMenuCallback,
  1037. CUINode*)
  1038. {
  1039. HRESULT hr = S_OK;
  1040. if ( m_pComponentData->IsPrimarySnapin())
  1041. {
  1042. //
  1043. // Insert these if running as a primary snapin and not an extension
  1044. //
  1045. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1046. IDM_VIEW_FILTER_OPTIONS,
  1047. IDM_VIEW_FILTER_OPTIONS,
  1048. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  1049. 0,
  1050. CMID_VIEW_FILTER_OPTIONS);
  1051. }
  1052. return hr;
  1053. }
  1054. HRESULT CDSContextMenuVerbs::LoadMenuExtensions(IContextMenuCallback2* piCMenuCallback,
  1055. IShellExtInit* pShlInit,
  1056. LPDATAOBJECT pDataObject,
  1057. CUINode*)
  1058. {
  1059. UINT index = 0;
  1060. HRESULT hr = S_OK;
  1061. ///////////////////////////////////////////////////////////
  1062. // get common menu items from DS and merge.
  1063. HMENU hDSMenu = CreatePopupMenu();
  1064. if (hDSMenu == NULL)
  1065. {
  1066. TRACE(_T("Failed to CreatePopupMenu() in CDSContextMenuVerbs::LoadMenuExtensions()"));
  1067. ASSERT(FALSE);
  1068. return GetLastError();
  1069. }
  1070. BOOL fRet = TRUE;
  1071. CInternalFormatCracker ObjCracker;
  1072. LPDATAOBJECT pDO = NULL;
  1073. pDO = ObjCracker.ExtractMultiSelect (pDataObject);
  1074. if (pDO == NULL)
  1075. {
  1076. pDO = pDataObject;
  1077. }
  1078. hr = pShlInit->Initialize(NULL, pDO, 0);
  1079. if (FAILED(hr))
  1080. {
  1081. TRACE(TEXT("pShlInit->Initialize failed, hr: 0x%x\n"), hr);
  1082. }
  1083. else
  1084. {
  1085. IContextMenu * pICM= NULL;
  1086. hr = pShlInit->QueryInterface(IID_IContextMenu, (void **)&pICM);
  1087. if (FAILED(hr))
  1088. {
  1089. TRACE(TEXT("pShlInit->QI for IID_IContextMenu failed, hr: 0x%x\n"), hr);
  1090. }
  1091. else
  1092. {
  1093. //
  1094. // NOTE: QueryContextMenu returns with the HRESULT with the severity set as normal
  1095. // for success and failure but the facility is zero and the code is the
  1096. // count of the menu items added
  1097. //
  1098. hr = pICM->QueryContextMenu (hDSMenu, 0, MENU_MERGE_BASE, MENU_MERGE_LIMIT, NULL);
  1099. if ((SUCCEEDED(hr)) && (HRESULT_CODE(hr) > 0))
  1100. {
  1101. UINT cItems = GetMenuItemCount (hDSMenu);
  1102. MENUITEMINFO miiItem;
  1103. miiItem.cbSize = sizeof(MENUITEMINFO);
  1104. WCHAR szBuffer[MAX_PATH];
  1105. for (index = 0; index < cItems; index++)
  1106. {
  1107. miiItem.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
  1108. WCHAR * pszString = new WCHAR[MAX_PATH];
  1109. miiItem.dwTypeData = pszString;
  1110. miiItem.cch = MAX_PATH;
  1111. fRet = GetMenuItemInfo (hDSMenu, index, TRUE, &miiItem);
  1112. if (fRet)
  1113. {
  1114. // got item back, add it to MMC context menu
  1115. CONTEXTMENUITEM2 ctiItem;
  1116. ::ZeroMemory( &ctiItem, sizeof(CONTEXTMENUITEM2) );
  1117. hr = pICM->GetCommandString (miiItem.wID - MENU_MERGE_BASE,
  1118. GCS_HELPTEXT,
  1119. NULL,
  1120. (char *)szBuffer,
  1121. MAX_PATH);
  1122. ctiItem.strName = miiItem.dwTypeData;
  1123. ctiItem.strStatusBarText = szBuffer;
  1124. ctiItem.lCommandID = miiItem.wID;
  1125. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  1126. if (miiItem.fState == MF_GRAYED)
  1127. {
  1128. ctiItem.fFlags = MF_GRAYED;
  1129. }
  1130. else
  1131. {
  1132. ctiItem.fFlags = 0;
  1133. }
  1134. ctiItem.fSpecialFlags = 0;
  1135. //
  1136. // Now try to retrieve the language independent ID
  1137. //
  1138. WCHAR szLanguageIndependentID[MAX_PATH];
  1139. ::ZeroMemory( szLanguageIndependentID, sizeof(WCHAR) * MAX_PATH);
  1140. hr = pICM->GetCommandString(miiItem.wID - MENU_MERGE_BASE,
  1141. GCS_VERBW,
  1142. NULL,
  1143. (char*)szLanguageIndependentID,
  1144. MAX_PATH);
  1145. if (SUCCEEDED(hr) &&
  1146. szLanguageIndependentID &&
  1147. szLanguageIndependentID[0] != 0)
  1148. {
  1149. ctiItem.strLanguageIndependentName = szLanguageIndependentID;
  1150. hr = piCMenuCallback->AddItem( &ctiItem );
  1151. ASSERT(SUCCEEDED(hr));
  1152. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  1153. hr = piCMenuCallback->AddItem( &ctiItem );
  1154. }
  1155. else
  1156. {
  1157. CComPtr<IContextMenuCallback> spOldCallback;
  1158. hr = piCMenuCallback->QueryInterface(IID_IContextMenuCallback, (void**)&spOldCallback);
  1159. if (SUCCEEDED(hr))
  1160. {
  1161. hr = spOldCallback->AddItem( (CONTEXTMENUITEM*)&ctiItem );
  1162. ASSERT(SUCCEEDED(hr));
  1163. ctiItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  1164. hr = spOldCallback->AddItem( (CONTEXTMENUITEM*)&ctiItem );
  1165. }
  1166. ASSERT(SUCCEEDED(hr));
  1167. }
  1168. }
  1169. delete[] pszString;
  1170. }
  1171. }
  1172. }
  1173. if (pICM)
  1174. {
  1175. pICM->Release();
  1176. }
  1177. }
  1178. DestroyMenu(hDSMenu);
  1179. ///////////////////////////////////////////////////////////
  1180. return hr;
  1181. }
  1182. ///////////////////////////////////////////////////////////////////
  1183. // CDSAdminContextMenuVerbs
  1184. //
  1185. void CDSAdminContextMenuVerbs::LoadStandardVerbs(IConsoleVerb* pConsoleVerb,
  1186. BOOL bScope,
  1187. BOOL bSelect,
  1188. CUINode* pUINode,
  1189. CInternalFormatCracker& ifc,
  1190. LPDATAOBJECT pDataObject)
  1191. {
  1192. CContextMenuVerbs::LoadStandardVerbs(pConsoleVerb, bScope, bSelect, pUINode, ifc, pDataObject);
  1193. }
  1194. HRESULT CDSAdminContextMenuVerbs::LoadTopMenu(IContextMenuCallback2* pContextMenuCallback,
  1195. CUINode* pUINode)
  1196. {
  1197. HRESULT hr = S_OK;
  1198. hr = LoadTopTaskHelper(pContextMenuCallback, pUINode, CCM_INSERTIONPOINTID_PRIMARY_TOP);
  1199. return hr;
  1200. }
  1201. HRESULT CDSAdminContextMenuVerbs::LoadTaskMenu(IContextMenuCallback2* pContextMenuCallback,
  1202. CUINode* pUINode)
  1203. {
  1204. HRESULT hr = S_OK;
  1205. hr = LoadTopTaskHelper(pContextMenuCallback, pUINode, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  1206. return hr;
  1207. }
  1208. HRESULT CDSAdminContextMenuVerbs::LoadTopTaskHelper(IContextMenuCallback2* pContextMenuCallback,
  1209. CUINode* pUINode,
  1210. int insertionPoint)
  1211. {
  1212. TRACE(_T("CDSAdminContextMenuVerbs::LoadTopTaskHelper()\n"));
  1213. HRESULT hr = S_OK;
  1214. ASSERT(IS_CLASS(pUINode, DS_UI_NODE));
  1215. if (pUINode->IsContainer())
  1216. {
  1217. //
  1218. // Load Find menu
  1219. //
  1220. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1221. IDM_DS_OBJECT_FIND,
  1222. IDM_DS_OBJECT_FIND,
  1223. insertionPoint,
  1224. 0,
  1225. CMID_DS_OBJECT_FIND);
  1226. ASSERT(SUCCEEDED(hr));
  1227. }
  1228. CDSCookie* pCookie = NULL;
  1229. pCookie = GetDSCookieFromUINode(pUINode);
  1230. if (pCookie == NULL)
  1231. {
  1232. ASSERT(FALSE);
  1233. return E_FAIL;
  1234. }
  1235. CString szClass;
  1236. szClass = pCookie->GetClass();
  1237. if (szClass == L"domainDNS")
  1238. {
  1239. //
  1240. // Load Connect to Domain... menu
  1241. //
  1242. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1243. IDM_GEN_TASK_SELECT_DOMAIN,
  1244. IDM_GEN_TASK_SELECT_DOMAIN,
  1245. insertionPoint,
  1246. 0,
  1247. CMID_GEN_TASK_SELECT_DOMAIN);
  1248. ASSERT( SUCCEEDED(hr) );
  1249. //
  1250. // Load Connect to Domain Controller... menu
  1251. //
  1252. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1253. IDM_GEN_TASK_SELECT_DC,
  1254. IDM_GEN_TASK_SELECT_DC,
  1255. insertionPoint,
  1256. 0,
  1257. CMID_GEN_TASK_SELECT_DC);
  1258. ASSERT( SUCCEEDED(hr) );
  1259. //
  1260. // Load Raise Domain Version... menu item.
  1261. //
  1262. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1263. IDM_GEN_TASK_RAISE_VERSION,
  1264. IDM_GEN_TASK_RAISE_VERSION,
  1265. insertionPoint,
  1266. 0,
  1267. CMID_GEN_TASK_RAISE_VERSION);
  1268. ASSERT(SUCCEEDED(hr));
  1269. if (m_pComponentData->GetBasePathsInfo()->IsInitialized())
  1270. {
  1271. //
  1272. // Load Operations Masters... menu
  1273. //
  1274. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1275. IDM_GEN_TASK_EDIT_FSMO,
  1276. IDM_GEN_TASK_EDIT_FSMO,
  1277. insertionPoint,
  1278. 0,
  1279. CMID_GEN_TASK_EDIT_FSMO);
  1280. ASSERT(SUCCEEDED(hr));
  1281. }
  1282. }
  1283. return hr;
  1284. }
  1285. HRESULT CDSAdminContextMenuVerbs::LoadViewMenu(IContextMenuCallback2* pContextMenuCallback,
  1286. CUINode* pUINode)
  1287. {
  1288. HRESULT hr = S_OK;
  1289. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1290. IDM_VIEW_COMPUTER_HACK,
  1291. IDM_VIEW_COMPUTER_HACK,
  1292. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  1293. m_pComponentData->ExpandComputers()? MF_CHECKED : 0,
  1294. CMID_VIEW_COMPUTER_HACK);
  1295. ASSERT(SUCCEEDED(hr));
  1296. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1297. IDM_VIEW_ADVANCED,
  1298. IDM_VIEW_ADVANCED,
  1299. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  1300. m_pComponentData->GetQueryFilter()->IsAdvancedView()? MF_CHECKED : 0,
  1301. CMID_VIEW_ADVANCED);
  1302. ASSERT(SUCCEEDED(hr));
  1303. hr = CDSContextMenuVerbs::LoadViewMenu(pContextMenuCallback, pUINode);
  1304. ASSERT(SUCCEEDED(hr));
  1305. return hr;
  1306. }
  1307. ///////////////////////////////////////////////////////////////////
  1308. // CSARContextMenuVerbs
  1309. //
  1310. void CSARContextMenuVerbs::LoadStandardVerbs(IConsoleVerb* pConsoleVerb,
  1311. BOOL bScope,
  1312. BOOL bSelect,
  1313. CUINode* pUINode,
  1314. CInternalFormatCracker& ifc,
  1315. LPDATAOBJECT pDataObject)
  1316. {
  1317. ASSERT(IS_CLASS(pUINode, DS_UI_NODE));
  1318. CDSCookie* pCookie = NULL;
  1319. pCookie = GetDSCookieFromUINode(pUINode);
  1320. CString szClass;
  1321. szClass = pCookie->GetClass();
  1322. if (!bSelect || pUINode == NULL)
  1323. {
  1324. return;
  1325. }
  1326. if (pConsoleVerb)
  1327. {
  1328. if (bScope)
  1329. {
  1330. //
  1331. // Item is in scope pane. Therefore it is a container.
  1332. //
  1333. pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  1334. }
  1335. else
  1336. {
  1337. //
  1338. // Item is in result pane. Make properties the default verb.
  1339. //
  1340. pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  1341. }
  1342. //
  1343. // Verbs supported by all items, except root
  1344. //
  1345. if (pDataObject != NULL && ifc.GetCookieCount() > 1)
  1346. {
  1347. //
  1348. // multiple selection
  1349. //
  1350. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, TRUE);
  1351. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, FALSE);
  1352. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, TRUE);
  1353. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, FALSE);
  1354. //
  1355. // Can delete
  1356. //
  1357. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, FALSE);
  1358. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, TRUE);
  1359. //
  1360. // Properties - multiselect properties are only available for
  1361. // schema version 15 or greater
  1362. //
  1363. UINT schemaVersion = m_pComponentData->GetBasePathsInfo()->GetSchemaVersion();
  1364. TRACE(L"Schema version = %d\n", schemaVersion);
  1365. if (schemaVersion >= SCHEMA_VERSION_WITH_MULTISELECT_PROPPAGES)
  1366. {
  1367. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, FALSE);
  1368. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
  1369. }
  1370. else
  1371. {
  1372. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, TRUE);
  1373. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, FALSE);
  1374. }
  1375. //
  1376. // Can cut
  1377. //
  1378. // NOTICE: we are only allowing servers to be moved and since
  1379. // servers are the only things in a serversContainer we enable
  1380. // cut on multiselect only if the parent is a serversContainer
  1381. //
  1382. if (szClass.CompareNoCase(L"server"))
  1383. {
  1384. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, TRUE);
  1385. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, FALSE);
  1386. }
  1387. else
  1388. {
  1389. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, FALSE);
  1390. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, TRUE);
  1391. }
  1392. //
  1393. // Can copy
  1394. //
  1395. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, TRUE);
  1396. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, FALSE);
  1397. }
  1398. else // single selection
  1399. {
  1400. BOOL bEnable = FALSE;
  1401. BOOL bHide = TRUE;
  1402. //
  1403. // Properties
  1404. //
  1405. bEnable = pUINode->ArePropertiesAllowed(m_pComponentData, &bHide);
  1406. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, HIDDEN, bHide);
  1407. pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, bEnable);
  1408. //
  1409. // Rename
  1410. //
  1411. bEnable = pUINode->IsRenameAllowed(m_pComponentData, &bHide);
  1412. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, HIDDEN, bHide);
  1413. pConsoleVerb->SetVerbState(MMC_VERB_RENAME, ENABLED, bEnable);
  1414. //
  1415. // Delete
  1416. //
  1417. bEnable = pUINode->IsDeleteAllowed(m_pComponentData, &bHide);
  1418. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, HIDDEN, bHide);
  1419. pConsoleVerb->SetVerbState(MMC_VERB_DELETE, ENABLED, bEnable);
  1420. //
  1421. // Refresh
  1422. //
  1423. bEnable = pUINode->IsRefreshAllowed(m_pComponentData, &bHide);
  1424. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, HIDDEN, bHide);
  1425. pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, bEnable);
  1426. //
  1427. // Cut
  1428. //
  1429. bEnable = pUINode->IsCutAllowed(m_pComponentData, &bHide);
  1430. pConsoleVerb->SetVerbState(MMC_VERB_CUT, HIDDEN, bHide);
  1431. pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, bEnable);
  1432. //
  1433. // Copy
  1434. //
  1435. bEnable = pUINode->IsCopyAllowed(m_pComponentData, &bHide);
  1436. pConsoleVerb->SetVerbState(MMC_VERB_COPY, HIDDEN, bHide);
  1437. pConsoleVerb->SetVerbState(MMC_VERB_COPY, ENABLED, bEnable);
  1438. //
  1439. // Paste
  1440. //
  1441. bEnable = pUINode->IsPasteAllowed(m_pComponentData, &bHide);
  1442. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, HIDDEN, bHide);
  1443. pConsoleVerb->SetVerbState(MMC_VERB_PASTE, ENABLED, bEnable);
  1444. //
  1445. // Print
  1446. //
  1447. bEnable = pUINode->IsPrintAllowed(m_pComponentData, &bHide);
  1448. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, HIDDEN, bHide);
  1449. pConsoleVerb->SetVerbState(MMC_VERB_PRINT, ENABLED, bEnable);
  1450. }
  1451. }
  1452. }
  1453. HRESULT CSARContextMenuVerbs::LoadTopMenu(IContextMenuCallback2* pContextMenuCallback,
  1454. CUINode* pUINode)
  1455. {
  1456. HRESULT hr = S_OK;
  1457. hr = CDSContextMenuVerbs::LoadTopMenu(pContextMenuCallback, pUINode);
  1458. ASSERT(SUCCEEDED(hr));
  1459. hr = LoadTopTaskHelper(pContextMenuCallback, pUINode, CCM_INSERTIONPOINTID_PRIMARY_TOP);
  1460. return hr;
  1461. }
  1462. HRESULT CSARContextMenuVerbs::LoadTaskMenu(IContextMenuCallback2* pContextMenuCallback,
  1463. CUINode* pUINode)
  1464. {
  1465. HRESULT hr = S_OK;
  1466. hr = CDSContextMenuVerbs::LoadTaskMenu(pContextMenuCallback, pUINode);
  1467. ASSERT(SUCCEEDED(hr));
  1468. hr = LoadTopTaskHelper(pContextMenuCallback, pUINode, CCM_INSERTIONPOINTID_PRIMARY_TASK);
  1469. ASSERT(SUCCEEDED(hr));
  1470. ASSERT(IS_CLASS(pUINode, DS_UI_NODE));
  1471. CDSCookie* pCookie = NULL;
  1472. pCookie = GetDSCookieFromUINode(pUINode);
  1473. CString szClass;
  1474. szClass = pCookie->GetClass();
  1475. if (szClass == L"nTDSDSA")
  1476. {
  1477. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1478. IDM_GEN_TASK_RUN_KCC,
  1479. IDM_GEN_TASK_RUN_KCC,
  1480. CCM_INSERTIONPOINTID_PRIMARY_TASK,
  1481. 0,
  1482. CMID_GEN_TASK_RUN_KCC);
  1483. ASSERT(SUCCEEDED(hr));
  1484. }
  1485. return hr;
  1486. }
  1487. HRESULT CSARContextMenuVerbs::LoadTopTaskHelper(IContextMenuCallback2* pContextMenuCallback,
  1488. CUINode* pUINode,
  1489. int insertionPoint)
  1490. {
  1491. HRESULT hr = S_OK;
  1492. CDSCookie* pCookie = NULL;
  1493. ASSERT(IS_CLASS(pUINode, DS_UI_NODE));
  1494. pCookie = GetDSCookieFromUINode(pUINode);
  1495. if (pCookie == NULL)
  1496. {
  1497. ASSERT(FALSE);
  1498. return E_FAIL;
  1499. }
  1500. CString szClass;
  1501. szClass = pCookie->GetClass();
  1502. if ((szClass == L"domainOrganizationalUnit") ||
  1503. (szClass == L"domainLocality"))
  1504. {
  1505. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1506. IDM_GEN_TASK_SELECT_FOREST,
  1507. IDM_GEN_TASK_SELECT_FOREST,
  1508. insertionPoint,
  1509. 0,
  1510. CMID_GEN_TASK_SELECT_FOREST);
  1511. ASSERT(SUCCEEDED(hr));
  1512. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1513. IDM_GEN_TASK_SELECT_DC,
  1514. IDM_GEN_TASK_SELECT_DC,
  1515. insertionPoint,
  1516. 0,
  1517. CMID_GEN_TASK_SELECT_DC);
  1518. ASSERT( SUCCEEDED(hr) );
  1519. }
  1520. int iSystemFlags = pCookie->GetSystemFlags();
  1521. if ( iSystemFlags & (FLAG_CONFIG_ALLOW_MOVE | FLAG_CONFIG_ALLOW_LIMITED_MOVE) )
  1522. {
  1523. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1524. IDM_GEN_TASK_MOVE,
  1525. IDM_GEN_TASK_MOVE,
  1526. insertionPoint,
  1527. 0,
  1528. CMID_GEN_TASK_MOVE);
  1529. ASSERT( SUCCEEDED(hr) );
  1530. }
  1531. return hr;
  1532. }
  1533. HRESULT CSARContextMenuVerbs::LoadViewMenu(IContextMenuCallback2* pContextMenuCallback,
  1534. CUINode* pUINode)
  1535. {
  1536. HRESULT hr = S_OK;
  1537. hr = CDSContextMenuVerbs::LoadViewMenu(pContextMenuCallback, pUINode);
  1538. ASSERT(SUCCEEDED(hr));
  1539. /* View->Services Node should only be on the root
  1540. hr = DSLoadAndAddMenuItem( pContextMenuCallback,
  1541. IDM_VIEW_SERVICES_NODE,
  1542. IDM_VIEW_SERVICES_NODE,
  1543. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  1544. m_pComponentData->ViewServicesNode()? MF_CHECKED : 0,
  1545. CMID_VIEW_SERVICES_NODE);
  1546. ASSERT(SUCCEEDED(hr));
  1547. */
  1548. return hr;
  1549. }
  1550. HRESULT CSARContextMenuVerbs::LoadMainMenu(IContextMenuCallback2* piCMenuCallback,
  1551. LPDATAOBJECT,
  1552. CUINode* pUINode)
  1553. {
  1554. HRESULT hr = S_OK;
  1555. ASSERT(IS_CLASS(pUINode, DS_UI_NODE));
  1556. CDSCookie* pCookie = GetDSCookieFromUINode(pUINode);
  1557. ASSERT(pCookie != NULL);
  1558. int iSystemFlags = pCookie->GetSystemFlags();
  1559. if ( iSystemFlags & (FLAG_CONFIG_ALLOW_MOVE | FLAG_CONFIG_ALLOW_LIMITED_MOVE) )
  1560. {
  1561. hr = DSLoadAndAddMenuItem( piCMenuCallback,
  1562. IDM_GEN_TASK_MOVE,
  1563. IDM_GEN_TASK_MOVE,
  1564. CCM_INSERTIONPOINTID_PRIMARY_TOP,
  1565. 0,
  1566. CMID_GEN_TASK_MOVE);
  1567. }
  1568. return hr;
  1569. }