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.

1900 lines
79 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2001.
  5. //
  6. // File: L E G A C Y M E N U S . C P P
  7. //
  8. // Contents: Legacy menu implementation for debug purposes
  9. // This is used to double check the new command handler
  10. // implementation against the new one.
  11. //
  12. // Most of the code from the previous cmdhandler.cpp has been
  13. // moved to this file.
  14. //
  15. // Notes:
  16. //
  17. // Author: deonb 8 Feb 2001
  18. //
  19. //----------------------------------------------------------------------------
  20. #include "pch.h"
  21. #pragma hdrstop
  22. #ifdef DBG // Make sure this is not called in release mode.
  23. #include "foldinc.h" // Standard shell\folder includes
  24. #include "foldres.h" // Folder resource IDs
  25. #include "nsres.h"
  26. #include "cmdtable.h"
  27. #include "ncperms.h" // For checking User's rights on actions/menu items
  28. #include "cfutils.h"
  29. #include "oncommand.h"
  30. #include "hnetcfg.h"
  31. #include "legacymenus.h"
  32. #include "nsclsid.h"
  33. #define TRACESTRLEN 65535
  34. //---[ Prototypes ]-----------------------------------------------------------
  35. VOID DoMenuItemExceptionLoop(
  36. const PCONFOLDPIDLVEC& apidlSelected);
  37. VOID DoMenuItemCheckLoop(VOID);
  38. bool FEnableConnectDisconnectMenuItem(
  39. const PCONFOLDPIDL& pcfp,
  40. int iCommandId);
  41. HRESULT HrEnableOrDisableMenuItems(
  42. HWND hwnd,
  43. const PCONFOLDPIDLVEC& apidlSelected,
  44. HMENU hmenu,
  45. UINT idCmdFirst);
  46. BOOL IsBridgeInstalled(
  47. VOID);
  48. struct ContextMenuEntry
  49. {
  50. WIZARD wizWizard;
  51. NETCON_MEDIATYPE ncm;
  52. BOOL fInbound;
  53. BOOL fIsDefault; // 1 if currently the default. 0 otherwise.
  54. NETCON_STATUS ncs;
  55. INT iMenu;
  56. INT iVerbMenu; // This flag is set if the context menu is for a shortcut object.
  57. INT iDefaultCmd;
  58. };
  59. static const ContextMenuEntry c_CMEArray[] =
  60. {
  61. //wizWizard
  62. // | ncm
  63. // | | fInbound?
  64. // | | | fIsDefault?
  65. // | | | | Status (ncs)
  66. // | | | | | iMenu
  67. // | | | | | | iVerbMenu
  68. // | | | | | | | iDefaultCmd
  69. // | | | | | | | |
  70. // v v v v v v v v
  71. // wizard
  72. { WIZARD_MNC, NCM_NONE, 0, 0, (NETCON_STATUS)0, MENU_WIZARD, MENU_WIZARD_V, CMIDM_NEW_CONNECTION },
  73. // incoming w/ no clients
  74. { WIZARD_NOT_WIZARD, NCM_NONE, 1, 0, NCS_DISCONNECTED, MENU_INCOM_DISCON, MENU_INCOM_DISCON_V, CMIDM_PROPERTIES },
  75. // Note: Temporary hack for CM connections
  76. // DEONB: ISSUE: Removing hack for CM connections. This doesn't appear to be used anymore.
  77. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 0, NCS_DISCONNECTED, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  78. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 0, NCS_CONNECTED, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  79. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  80. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  81. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 0, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  82. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 1, NCS_CONNECTED, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  83. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 1, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  84. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 1, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  85. // { WIZARD_NOT_WIZARD, NCM_NONE, 0, 1, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  86. // lan
  87. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_DISCONNECTED, MENU_LAN_DISCON ,MENU_LAN_DISCON_V,CMIDM_ENABLE },
  88. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_CONNECTED, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  89. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_DISCONNECTING, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  90. // DEONB: ISSUE: What on earth is an incoming LAN card???
  91. // { WIZARD_NOT_WIZARD, NCM_LAN, 1, 0, NCS_CONNECTED, MENU_LAN_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  92. // { WIZARD_NOT_WIZARD, NCM_LAN, 1, 0, NCS_DISCONNECTING, MENU_LAN_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  93. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_MEDIA_DISCONNECTED, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_PROPERTIES },
  94. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_INVALID_ADDRESS, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  95. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_LAN_UNAVAIL, MENU_LAN_UNAVAIL_V, CMIDM_PROPERTIES },
  96. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_LAN_UNAVAIL, MENU_LAN_UNAVAIL_V, CMIDM_PROPERTIES },
  97. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_HARDWARE_DISABLED, MENU_LAN_UNAVAIL, MENU_LAN_UNAVAIL_V, CMIDM_PROPERTIES },
  98. // dialup
  99. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_DISCONNECTED, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  100. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_CONNECTING, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  101. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_CONNECTED, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  102. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_DISCONNECTING, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  103. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  104. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  105. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  106. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_DISCONNECTED, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  107. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_CONNECTING, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  108. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_CONNECTED, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  109. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_DISCONNECTING, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  110. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  111. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  112. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  113. // dialup inbound
  114. { WIZARD_NOT_WIZARD, NCM_PHONE, 1, 0, NCS_CONNECTED, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  115. { WIZARD_NOT_WIZARD, NCM_PHONE, 1, 0, NCS_DISCONNECTING, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  116. // isdn
  117. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_DISCONNECTED, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  118. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_CONNECTING, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  119. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_CONNECTED, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  120. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_DISCONNECTING, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  121. { WIZARD_NOT_WIZARD, NCM_ISDN, 1, 0, NCS_CONNECTED, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  122. { WIZARD_NOT_WIZARD, NCM_ISDN, 1, 0, NCS_DISCONNECTING, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  123. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  124. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  125. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  126. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_DISCONNECTED, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  127. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_CONNECTING, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  128. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_CONNECTED, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  129. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_DISCONNECTING, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  130. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  131. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  132. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  133. // tunnel
  134. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_DISCONNECTED, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  135. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_CONNECTING, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  136. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_CONNECTED, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  137. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_DISCONNECTING, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  138. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 1, 0, NCS_CONNECTED, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  139. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 1, 0, NCS_DISCONNECTING, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  140. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  141. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  142. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  143. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_DISCONNECTED, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  144. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_CONNECTING, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  145. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_CONNECTED, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  146. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_DISCONNECTING, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  147. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  148. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  149. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  150. // direct connect
  151. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_DISCONNECTED, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  152. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_CONNECTING, MENU_DIAL_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  153. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_CONNECTED, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  154. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_DISCONNECTING, MENU_DIAL_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  155. { WIZARD_NOT_WIZARD, NCM_DIRECT, 1, 0, NCS_CONNECTED, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  156. { WIZARD_NOT_WIZARD, NCM_DIRECT, 1, 0, NCS_DISCONNECTING, MENU_INCOM_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  157. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  158. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  159. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL, MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES },
  160. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_DISCONNECTED, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  161. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_CONNECTING, MENU_DIAL_DISCON_UNSET,MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  162. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_CONNECTED, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  163. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_DISCONNECTING, MENU_DIAL_CON_UNSET,MENU_DIAL_CON_V, CMIDM_STATUS },
  164. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_HARDWARE_NOT_PRESENT, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  165. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_HARDWARE_MALFUNCTION, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  166. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_HARDWARE_DISABLED, MENU_DIAL_UNAVAIL_UNSET,MENU_DIAL_UNAVAIL_V, CMIDM_PROPERTIES},
  167. // bridge - largely the same as lan
  168. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_DISCONNECTED, MENU_LAN_DISCON, MENU_LAN_DISCON_V, CMIDM_ENABLE },
  169. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_CONNECTING, MENU_LAN_DISCON, MENU_LAN_DISCON_V, CMIDM_ENABLE },
  170. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_CONNECTED, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  171. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_DISCONNECTING, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  172. // DEONB: ISSUE: What on earth is an incoming bridge???
  173. // { WIZARD_NOT_WIZARD, NCM_BRIDGE, 1, 0, NCS_CONNECTED, MENU_LAN_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  174. // { WIZARD_NOT_WIZARD, NCM_BRIDGE, 1, 0, NCS_DISCONNECTING, MENU_LAN_CON, MENU_INCOM_CON_V, CMIDM_STATUS },
  175. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_MEDIA_DISCONNECTED, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_PROPERTIES },
  176. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_INVALID_ADDRESS, MENU_LAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  177. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_HARDWARE_NOT_PRESENT, MENU_LAN_UNAVAIL, MENU_LAN_UNAVAIL_V, CMIDM_PROPERTIES },
  178. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_HARDWARE_MALFUNCTION, MENU_LAN_UNAVAIL, MENU_LAN_UNAVAIL_V, CMIDM_PROPERTIES },
  179. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_HARDWARE_DISABLED, MENU_LAN_UNAVAIL, MENU_LAN_UNAVAIL_V, CMIDM_PROPERTIES },
  180. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS, 0, 0, NCS_DISCONNECTED, MENU_SARAS_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  181. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS, 0, 0, NCS_CONNECTING, MENU_SARAS_DISCON, MENU_DIAL_DISCON_V, CMIDM_CONNECT },
  182. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS, 0, 0, NCS_CONNECTED, MENU_SARAS_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  183. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS, 0, 0, NCS_DISCONNECTING, MENU_SARAS_CON, MENU_DIAL_CON_V, CMIDM_STATUS },
  184. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS, 0, 0, NCS_HARDWARE_DISABLED, MENU_SARAS_DISCON, MENU_SARAS_DISCON, CMIDM_PROPERTIES },
  185. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_LAN, 0, 0, NCS_DISCONNECTED, MENU_SALAN_DISCON, MENU_LAN_DISCON_V, CMIDM_ENABLE },
  186. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_LAN, 0, 0, NCS_CONNECTED, MENU_SALAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  187. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_LAN, 0, 0, NCS_DISCONNECTING, MENU_SALAN_CON, MENU_LAN_CON_V, CMIDM_STATUS },
  188. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_LAN, 0, 0, NCS_HARDWARE_DISABLED, MENU_SALAN_DISCON, MENU_SALAN_DISCON, CMIDM_PROPERTIES },
  189. };
  190. const DWORD g_dwContextMenuEntryCount = celems(c_CMEArray);
  191. COMMANDTABLEENTRY g_cteFolderCommands[] =
  192. {
  193. // command id
  194. // | valid when 0 items selected
  195. // | | valid when only wizard selected
  196. // | | | valid when multiple items selected
  197. // | | | | command is currently enabled
  198. // | | | | | new state (temp)
  199. // | | | | | |
  200. // | | | | | |
  201. // | | | | | |
  202. // | | | | | |
  203. // v v v v v v
  204. //
  205. { CMIDM_NEW_CONNECTION, true, true, true, true, true },
  206. { CMIDM_CONNECT, false, false, false, true, true },
  207. { CMIDM_ENABLE, false, false, false, true, true },
  208. { CMIDM_DISCONNECT, false, false, false, true, true },
  209. { CMIDM_DISABLE, false, false, false, true, true },
  210. { CMIDM_STATUS, false, false, false, true, true },
  211. { CMIDM_CREATE_BRIDGE, true, false, true, true, true },
  212. { CMIDM_ADD_TO_BRIDGE, false, false, true, true, true },
  213. { CMIDM_REMOVE_FROM_BRIDGE, false, false, true, true, true },
  214. { CMIDM_CREATE_SHORTCUT, false, true, false, true, true },
  215. { SFVIDM_FILE_LINK, false, true, false, true, true },
  216. { CMIDM_DELETE, false, false, true, true, true },
  217. { SFVIDM_FILE_DELETE, false, false, true, true, true },
  218. { CMIDM_RENAME, false, false, false, true, true },
  219. { CMIDM_PROPERTIES, false, false, false, true, true },
  220. { SFVIDM_FILE_PROPERTIES, false, false, false, true, true },
  221. { CMIDM_CREATE_COPY, false, false, false, true, true },
  222. { SFVIDM_FILE_RENAME, false, false, false, true, true },
  223. { CMIDM_SET_DEFAULT, false, false, false, true, true },
  224. { CMIDM_UNSET_DEFAULT, false, false, false, true, true },
  225. { CMIDM_FIX, false, false, false, true, true },
  226. { CMIDM_CONMENU_ADVANCED_CONFIG, true, true, false, true, true },
  227. { CMIDM_CONMENU_CREATE_BRIDGE, true, false, true, true, true },
  228. { CMIDM_CONMENU_DIALUP_PREFS, true, true, true, true, true },
  229. { CMIDM_CONMENU_NETWORK_ID, true, true, true, true, true },
  230. { CMIDM_CONMENU_OPTIONALCOMPONENTS, true, true, true, true, true },
  231. { CMIDM_CONMENU_OPERATOR_ASSIST, true, true, true, true, true },
  232. { CMIDM_ARRANGE_BY_NAME, true, true, true, true, true },
  233. { CMIDM_ARRANGE_BY_TYPE, true, true, true, true, true },
  234. { CMIDM_ARRANGE_BY_STATUS, true, true, true, true, true },
  235. { CMIDM_ARRANGE_BY_OWNER, true, true, true, true, true },
  236. { CMIDM_ARRANGE_BY_PHONEORHOSTADDRESS, true, true, true, true, true, },
  237. { CMIDM_ARRANGE_BY_DEVICE_NAME, true, true, true, true, true }
  238. };
  239. const DWORD g_nFolderCommandCount = celems(g_cteFolderCommands);
  240. //+---------------------------------------------------------------------------
  241. //
  242. // Member: HrBuildMenuOldWay
  243. //
  244. // Purpose: Adds menu items to the specified menu. The menu items should
  245. // be inserted in the menu at the position specified by
  246. // indexMenu, and their menu item identifiers must be between
  247. // the idCmdFirst and idCmdLast parameter values.
  248. //
  249. // Arguments:
  250. // hmenu [in out] Handle to the menu. The handler should specify this
  251. // handle when adding menu items
  252. // cfpl [in] List of selected PIDLS
  253. // hwndOwner [in] Window owner of the menu
  254. // cmt [in] Menu type (CMT_OBJECT or CMT_BACKGROUND)
  255. // indexMenu [in] Zero-based position at which to insert the first
  256. // menu item.
  257. // idCmdFirst [in] Min value the handler can specify for a menu item
  258. // idCmdLast [in] Max value the handler can specify for a menu item
  259. // fVerbsOnly [in] Verb only required
  260. //
  261. // Returns:
  262. //
  263. // Author: deonb 8 Feb 2001
  264. //
  265. // Notes:
  266. //
  267. HRESULT HrBuildMenuOldWay(IN OUT HMENU hmenu, IN PCONFOLDPIDLVEC& cfpl, IN HWND hwndOwner, IN CMENU_TYPE cmt, IN UINT indexMenu, IN DWORD idCmdFirst, IN UINT idCmdLast, IN BOOL fVerbsOnly)
  268. {
  269. TraceFileFunc(ttidMenus);
  270. HRESULT hr = S_OK;
  271. INT iMenuResourceId = 0;
  272. INT iPopupResourceId = 0;
  273. QCMINFO qcm = {hmenu, indexMenu, idCmdFirst, idCmdLast};
  274. INT iDefaultCmd = 0;
  275. BOOL fValidMenu = FALSE;
  276. const PCONFOLDPIDL& pcfp = cfpl[0];
  277. DWORD dwLoop = 0;
  278. for (dwLoop = 0; (dwLoop < g_dwContextMenuEntryCount) && !fValidMenu; dwLoop++)
  279. {
  280. if (c_CMEArray[dwLoop].wizWizard == pcfp->wizWizard)
  281. {
  282. if (pcfp->wizWizard != WIZARD_NOT_WIZARD)
  283. {
  284. fValidMenu = TRUE;
  285. }
  286. else
  287. {
  288. // If the mediatype is the same
  289. //
  290. if (pcfp->ncm == c_CMEArray[dwLoop].ncm)
  291. {
  292. // If the presence of the NCCF_INCOMING_ONLY characteristic (demoted to 0 | 1),
  293. // matches the inbound flag
  294. //
  295. if ((!!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY)) ==
  296. c_CMEArray[dwLoop].fInbound)
  297. {
  298. // If not the wizard, then we need to check the state of the connection
  299. // as well.
  300. //
  301. if (pcfp->ncs == c_CMEArray[dwLoop].ncs)
  302. {
  303. if ((!!(pcfp->dwCharacteristics & NCCF_DEFAULT)) == c_CMEArray[dwLoop].fIsDefault)
  304. {
  305. fValidMenu = TRUE;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. if (fValidMenu)
  313. {
  314. iPopupResourceId = 0;
  315. if (fVerbsOnly)
  316. {
  317. iMenuResourceId = c_CMEArray[dwLoop].iVerbMenu;
  318. }
  319. else
  320. {
  321. iMenuResourceId = c_CMEArray[dwLoop].iMenu;
  322. }
  323. iDefaultCmd = c_CMEArray[dwLoop].iDefaultCmd;
  324. }
  325. }
  326. if (fValidMenu)
  327. {
  328. MergeMenu(_Module.GetResourceInstance(),
  329. iMenuResourceId,
  330. iPopupResourceId,
  331. (LPQCMINFO)&qcm);
  332. // Enable/Disable the menu items as appropriate. Ignore the return from this
  333. // as we're getting it for debugging purposes only.
  334. //
  335. hr = HrEnableOrDisableMenuItems(
  336. hwndOwner,
  337. cfpl,
  338. hmenu,
  339. idCmdFirst);
  340. if (CMT_OBJECT == cmt)
  341. {
  342. // $$REVIEW: Find out why I'm only doing this for CMT_OBJECT instead of for background.
  343. // Pre-icomtextm|mb combine, mb had this commented out.
  344. //
  345. SetMenuDefaultItem(hmenu, idCmdFirst + iDefaultCmd, FALSE);
  346. }
  347. hr = ResultFromShort(qcm.idCmdFirst - idCmdFirst);
  348. }
  349. else
  350. {
  351. hr = E_FAIL;
  352. }
  353. return hr;
  354. }
  355. static const ContextMenuEntry c_BadBadLegacyImplementationsToIgnore[] =
  356. {
  357. //wizWizard
  358. // | ncm
  359. // | | fInbound?
  360. // | | | fIsDefault?
  361. // | | | | Status (ncs)
  362. // | | | | |
  363. // v v v v v
  364. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  365. { WIZARD_NOT_WIZARD, NCM_LAN, 1, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  366. { WIZARD_NOT_WIZARD, NCM_LAN, 0, 0, NCS_DISCONNECTED, 0,0,0}, // Disabled "Status" menu item is also default.
  367. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS,0,0, NCS_CONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  368. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_RAS,0,0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  369. { WIZARD_NOT_WIZARD, NCM_SHAREDACCESSHOST_LAN,0,0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  370. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  371. { WIZARD_NOT_WIZARD, NCM_BRIDGE, 0, 0, NCS_CONNECTING, 0,0,0}, // Disabled "Enable" menu item is also default.
  372. // Connection manager
  373. { WIZARD_NOT_WIZARD, NCM_NONE, 0, 0, NCS_DISCONNECTED, 0,0,0}, // Disabled "Connect" menu item is also default.
  374. { WIZARD_NOT_WIZARD, NCM_ISDN, 1, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  375. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  376. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  377. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  378. { WIZARD_NOT_WIZARD, NCM_ISDN, 0, 1, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  379. { WIZARD_NOT_WIZARD, NCM_DIRECT, 1, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  380. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  381. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  382. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  383. { WIZARD_NOT_WIZARD, NCM_DIRECT, 0, 1, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  384. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 1, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  385. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  386. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  387. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  388. { WIZARD_NOT_WIZARD, NCM_TUNNEL, 0, 1, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  389. { WIZARD_NOT_WIZARD, NCM_PHONE, 1, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  390. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  391. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_CONNECTING, 0,0,0}, // Disabled "Connect" menu item is also default.
  392. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 0, NCS_DISCONNECTING, 0,0,0}, // Disabled "Status" menu item is also default.
  393. { WIZARD_NOT_WIZARD, NCM_PHONE, 0, 1, NCS_DISCONNECTING, 0,0,0} // Disabled "Status" menu item is also default.
  394. };
  395. const DWORD g_dwBadBadLegacyImplementationsToIgnoreCount = celems(c_BadBadLegacyImplementationsToIgnore);
  396. //+---------------------------------------------------------------------------
  397. //
  398. // Member: IsBadBadLegacyImplementation
  399. //
  400. // Purpose: Checks against the list of known bad legacy implementations
  401. // This is just for the Status field, which we can ignore
  402. //
  403. // Arguments:
  404. // [in] cme Context Menu Entry
  405. //
  406. // Returns:
  407. // none
  408. //
  409. // Author: deonb 8 Feb 2001
  410. //
  411. // Notes:
  412. //
  413. BOOL IsBadBadLegacyImplementation(const ContextMenuEntry& cme)
  414. {
  415. for (int x = 0; x < g_dwBadBadLegacyImplementationsToIgnoreCount; x++)
  416. {
  417. const ContextMenuEntry& bbliti = c_BadBadLegacyImplementationsToIgnore[x];
  418. if ( (cme.wizWizard == bbliti.wizWizard) &&
  419. (cme.fInbound == bbliti.fInbound) &&
  420. (cme.fIsDefault == bbliti.fIsDefault) &&
  421. (cme.ncs == bbliti.ncs) &&
  422. (cme.ncm == bbliti.ncm) )
  423. {
  424. return TRUE;
  425. }
  426. }
  427. return FALSE;
  428. }
  429. //+---------------------------------------------------------------------------
  430. //
  431. // Member: GetMenuAsString
  432. //
  433. // Purpose: Gets the commands on a menu as a string.
  434. //
  435. // Arguments:
  436. // [in] hMenu Menu
  437. // [out] szMenu Menu as a string
  438. //
  439. // Returns:
  440. // none
  441. //
  442. // Author: deonb 8 Feb 2001
  443. //
  444. // Notes:
  445. //
  446. void GetHMenuAsString(HMENU hMenu, LPSTR lpszMenu)
  447. {
  448. int cMenuItems = GetMenuItemCount(hMenu);
  449. Assert(lpszMenu);
  450. if (!cMenuItems)
  451. {
  452. strcpy(lpszMenu, "<empty>");
  453. return;
  454. }
  455. LPWSTR szTmp = new WCHAR[TRACESTRLEN];
  456. LPSTR szTmp2 = lpszMenu;
  457. DWORD dwLen = 0;
  458. for (int x = 0; x < cMenuItems; x++)
  459. {
  460. UINT nMenuID = GetMenuItemID(hMenu, x);
  461. GetMenuStringW(hMenu, nMenuID, szTmp, TRACESTRLEN, MF_BYCOMMAND );
  462. UINT uiState = GetMenuState(hMenu, nMenuID, MF_BYCOMMAND );
  463. WCHAR szExtra[MAX_PATH] = {L'\0'};
  464. if (MF_CHECKED & uiState)
  465. {
  466. wcscat(szExtra, L"MF_CHECKED ");
  467. }
  468. if (MF_DISABLED & uiState)
  469. {
  470. wcscat(szExtra, L"MF_DISABLED ");
  471. }
  472. if (MF_GRAYED & uiState)
  473. {
  474. wcscat(szExtra, L"MF_GRAYED ");
  475. }
  476. if (MF_HILITE & uiState)
  477. {
  478. wcscat(szExtra, L"MF_HILITE ");
  479. }
  480. if (MF_MENUBARBREAK & uiState)
  481. {
  482. wcscat(szExtra, L"MF_MENUBARBREAK ");
  483. }
  484. if (MF_MENUBREAK & uiState)
  485. {
  486. wcscat(szExtra, L"MF_MENUBREAK ");
  487. }
  488. if (MF_OWNERDRAW & uiState)
  489. {
  490. wcscat(szExtra, L"MF_OWNERDRAW ");
  491. }
  492. if (MF_POPUP & uiState)
  493. {
  494. wcscat(szExtra, L"MF_POPUP ");
  495. }
  496. if (MF_SEPARATOR & uiState)
  497. {
  498. wcscat(szExtra, L"MF_SEPARATOR ");
  499. }
  500. if (MF_DEFAULT & uiState)
  501. {
  502. wcscat(szExtra, L"MF_DEFAULT ");
  503. }
  504. dwLen = sprintf(szTmp2, "\r\n %d. %S=%x (State:%08x = %S)", x+1, szTmp, nMenuID, uiState, szExtra);
  505. szTmp2 += dwLen;
  506. }
  507. AssertSz( (dwLen*2) < TRACESTRLEN, "Buffer overrun");
  508. delete[] szTmp;
  509. }
  510. //+---------------------------------------------------------------------------
  511. //
  512. // Member: TraceMenu
  513. //
  514. // Purpose: Trace the commands on a menu to the trace window.
  515. //
  516. // Arguments:
  517. // [in] hmenu Menu to be traced
  518. //
  519. // Returns:
  520. // none
  521. //
  522. // Author: deonb 8 Feb 2001
  523. //
  524. // Notes:
  525. //
  526. void TraceMenu(TRACETAGID ttId, HMENU hMenu)
  527. {
  528. LPSTR szMenu = new CHAR[TRACESTRLEN];
  529. GetHMenuAsString(hMenu, szMenu);
  530. TraceTag(ttId, "%s", szMenu);
  531. delete [] szMenu;
  532. }
  533. #define TRACEMENUS(ttid, hMenu1, hMenu2) \
  534. TraceTag(ttid, "Menu not identical to previous implementation: OLD:"); \
  535. TraceMenu(ttid, hMenu1); \
  536. TraceTag(ttid, "=== vs. NEW: === "); \
  537. TraceMenu(ttid, hMenu2);
  538. //+---------------------------------------------------------------------------
  539. //
  540. // Member: HrAssertTwoMenusEqual
  541. //
  542. // Purpose: Asserts that 2 menus are equal by comparing.
  543. // 1. Number of items
  544. // 2. CmdID of each item
  545. // 3. State flags of each item
  546. // 4. String of each item
  547. //
  548. // Arguments:
  549. // none
  550. //
  551. // Returns:
  552. // S_OK is succeeded
  553. // E_FAIL if not
  554. //
  555. // Author: deonb 8 Feb 2001
  556. //
  557. // Notes: Asserts on failure
  558. //
  559. HRESULT HrAssertTwoMenusEqual(HMENU hMenu1, HMENU hMenu2, UINT idCmdFirst, BOOL bIgnoreFlags, BOOL fPopupAsserts)
  560. {
  561. TraceFileFunc(ttidMenus);
  562. TRACETAGID ttid = fPopupAsserts ? ttidError : ttidMenus;
  563. LPSTR szErr = new CHAR[TRACESTRLEN];
  564. int cMenuItems = GetMenuItemCount(hMenu1);
  565. if (cMenuItems != GetMenuItemCount(hMenu2))
  566. {
  567. TRACEMENUS(ttid, hMenu1, hMenu2);
  568. sprintf(szErr, "Two menus don't have the same number of items");
  569. TraceTag(ttidError, szErr);
  570. if (fPopupAsserts)
  571. {
  572. AssertSz(FALSE, szErr);
  573. }
  574. delete[] szErr;
  575. return E_FAIL;
  576. }
  577. for (int x = 0; x < cMenuItems; x++)
  578. {
  579. UINT nMenuID1 = GetMenuItemID(hMenu1, x);
  580. UINT nMenuID2 = GetMenuItemID(hMenu2, x);
  581. if (nMenuID1 != nMenuID2)
  582. {
  583. if (!(((nMenuID1-idCmdFirst == CMIDM_CREATE_BRIDGE) || (nMenuID2-idCmdFirst == CMIDM_CREATE_BRIDGE)) &&
  584. ((nMenuID1-idCmdFirst == CMIDM_ADD_TO_BRIDGE) || (nMenuID2-idCmdFirst == CMIDM_ADD_TO_BRIDGE)) )) // These are equivalent between old & new.
  585. {
  586. TRACEMENUS(ttid, hMenu1, hMenu2);
  587. sprintf(szErr, "Two menus don't have the same nMenuID for item %d", x+1);
  588. TraceTag(ttidError, szErr);
  589. if (fPopupAsserts)
  590. {
  591. AssertSz(FALSE, szErr);
  592. }
  593. delete[] szErr;
  594. return E_FAIL;
  595. }
  596. }
  597. WCHAR szMenu1[8192];
  598. WCHAR szMenu2[8192];
  599. GetMenuString(hMenu1, nMenuID1, szMenu1, 8192, MF_BYCOMMAND );
  600. GetMenuString(hMenu2, nMenuID2, szMenu2, 8192, MF_BYCOMMAND );
  601. if (wcscmp(szMenu1, szMenu2))
  602. {
  603. TRACEMENUS(ttid, hMenu1, hMenu2);
  604. sprintf(szErr, "Two menus don't have the same strings for item %d (%S vs %S)", x+1, szMenu1, szMenu2);
  605. TraceTag(ttidError, szErr);
  606. if (fPopupAsserts)
  607. {
  608. AssertSz(FALSE, szErr);
  609. }
  610. delete[] szErr;
  611. return E_FAIL;
  612. }
  613. UINT uiState1;
  614. UINT uiState2;
  615. uiState1 = GetMenuState( hMenu1, nMenuID1, MF_BYCOMMAND );
  616. uiState2 = GetMenuState( hMenu2, nMenuID2, MF_BYCOMMAND );
  617. if (bIgnoreFlags) // Ignore Default Flags
  618. {
  619. uiState1 &= ~MF_DEFAULT;
  620. uiState2 &= ~MF_DEFAULT;
  621. }
  622. if (uiState1 != uiState2)
  623. {
  624. TRACEMENUS(ttid, hMenu1, hMenu2);
  625. sprintf(szErr, "Two menus don't have the same state for item %d (%S) ... %08x vs %08x", x+1, szMenu1, uiState1, uiState2);
  626. TraceTag(ttidError, szErr);
  627. if (fPopupAsserts)
  628. {
  629. AssertSz(FALSE, szErr);
  630. }
  631. delete[] szErr;
  632. return E_FAIL;
  633. }
  634. }
  635. delete[] szErr;
  636. return S_OK;
  637. }
  638. //+---------------------------------------------------------------------------
  639. //
  640. // Member: HrAssertIntegrityAgainstOldMatrix
  641. //
  642. // Purpose: Asserts the integrity of the Command Matrix by comparing it
  643. // with the old implementation
  644. //
  645. // Arguments:
  646. // none
  647. //
  648. // Returns:
  649. // S_OK is succeeded
  650. // E_FAIL if not
  651. //
  652. // Author: deonb 8 Feb 2001
  653. //
  654. // Notes: Asserts on failure
  655. //
  656. HRESULT HrAssertIntegrityAgainstOldMatrix()
  657. {
  658. TraceFileFunc(ttidMenus);
  659. HRESULT hr = S_OK;
  660. CHAR szErr[8192];
  661. for (DWORD x = 0; x < g_cteCommandMatrixCount; x++)
  662. {
  663. const COMMANDENTRY& cte = g_cteCommandMatrix[x];
  664. if (CMIDM_SEPARATOR == cte.iCommandId)
  665. {
  666. continue;
  667. }
  668. if (NCWHEN_TOPLEVEL == cte.dwValidWhen)
  669. {
  670. continue; // new commands we didn't have previously
  671. }
  672. if (CMIDM_HOMENET_WIZARD == cte.iCommandId)
  673. {
  674. continue; // new commands we didn't have previously
  675. }
  676. if ( (CMIDM_WZCDLG_SHOW == cte.iCommandId) )
  677. {
  678. continue;
  679. }
  680. // Check that the ValidWhen flags match the ones from g_cteFolderCommands
  681. BOOL bMatch = FALSE;
  682. for (DWORD y = 0; y < g_nFolderCommandCount; y++)
  683. {
  684. COMMANDTABLEENTRY ctecmp = g_cteFolderCommands[y];
  685. if (cte.iCommandId == ctecmp.iCommandId)
  686. {
  687. bMatch = TRUE;
  688. if (ctecmp.fValidOnMultiple != (!!(cte.dwValidWhen & NCWHEN_MULTISELECT)))
  689. {
  690. if (cte.iCommandId != CMIDM_FIX) // We know fix is broken in legacy implementation.
  691. {
  692. sprintf(szErr, "New (row %d) and old (row %d) multiselect fields are inconsistent", x+1, y+1);
  693. AssertSz(FALSE, szErr);
  694. hr = E_FAIL;
  695. }
  696. }
  697. // We can check for Visible only since Active is always a subset of visible (enforced by HrAssertCommandMatrixIntegrity)
  698. if (ctecmp.fValidOnWizardOnly != (!!(cte.dwMediaTypeVisible & NBM_MNC_WIZARD)))
  699. {
  700. sprintf(szErr, "New (row %d) and old (row %d) wizard select fields are inconsistent", x+1, y+1);
  701. AssertSz(FALSE, szErr);
  702. hr = E_FAIL;
  703. }
  704. if (ctecmp.fValidOnZero != (!!(cte.dwValidWhen & NCWHEN_TOPLEVEL)))
  705. {
  706. sprintf(szErr, "New (row %d) and old (row %d) Zero select fields are inconsistent", x+1, y+1);
  707. AssertSz(FALSE, szErr);
  708. hr = E_FAIL;
  709. }
  710. }
  711. }
  712. if (!bMatch)
  713. {
  714. sprintf(szErr, "Could not find corresponding entry for (row %d) in old table", x+1);
  715. AssertSz(FALSE, szErr);
  716. hr = E_FAIL;
  717. }
  718. }
  719. return hr;
  720. }
  721. //+---------------------------------------------------------------------------
  722. //
  723. // Member: HrAssertMenuAgainstOldImplementation
  724. //
  725. // Purpose: Asserts the integrity of a menu by comparing the old and
  726. // new implementations
  727. //
  728. // Arguments:
  729. // none
  730. //
  731. // Returns:
  732. // S_OK is succeeded
  733. // E_FAIL if not
  734. //
  735. // Author: deonb 8 Feb 2001
  736. //
  737. // Notes: Asserts on failure
  738. //
  739. HRESULT HrAssertMenuAgainstOldImplementation(HWND hwndOwner, WIZARD wizWizard, NETCON_STATUS ncs, NETCON_MEDIATYPE ncm, DWORD nccf, LPDWORD pdwFailCount, LPDWORD pdwSucceedCount, DWORD dwPermOutside, DWORD dwPerm)
  740. {
  741. CConFoldEntry cfe;
  742. PCONFOLDPIDL pcfp;
  743. BYTE blob[MAX_PATH];
  744. HRESULT hr = cfe.HrInitData(
  745. wizWizard,
  746. ncm,
  747. NCSM_NONE,
  748. ncs,
  749. &CLSID_ConnectionFolder, // Bogus - but doesn't matter - as long as it's not NULL.
  750. &CLSID_ConnectionFolder, // Bogus - but doesn't matter - as long as it's not NULL.
  751. nccf,
  752. blob,
  753. MAX_PATH,
  754. L"Test PIDL",
  755. NULL,
  756. NULL);
  757. if (SUCCEEDED(hr))
  758. {
  759. hr = cfe.ConvertToPidl(pcfp);
  760. }
  761. if (SUCCEEDED(hr))
  762. {
  763. PCONFOLDPIDLVEC pcfpVec;
  764. pcfpVec.push_back(pcfp);
  765. UINT idCmdFirst = 1234;
  766. UINT idCmdLast = idCmdFirst+1000;
  767. BOOL fVerbsOnly = FALSE;
  768. HMENU hMenu1 = CreateMenu();
  769. HMENU hMenu2 = CreateMenu();
  770. if ( (hMenu1) && (hMenu2) )
  771. {
  772. hr = HrBuildMenuOldWay(hMenu1, pcfpVec, hwndOwner, CMT_OBJECT, 0, idCmdFirst, idCmdLast, fVerbsOnly);
  773. if (SUCCEEDED(hr))
  774. {
  775. hr = HrBuildMenu(hMenu2, fVerbsOnly, pcfpVec, idCmdFirst);
  776. if (SUCCEEDED(hr))
  777. {
  778. BOOL bIgnoreFlags = TRUE;
  779. hr = HrAssertTwoMenusEqual(hMenu1, hMenu2, idCmdFirst, bIgnoreFlags, FALSE);
  780. if (FAILED(hr))
  781. {
  782. TraceTag(ttidMenus, " + PIDL of failed menu compare:");
  783. TraceTag(ttidMenus, " + wizWizard = %d\r\n", cfe.GetWizard());
  784. TraceTag(ttidMenus, " + ncm = %d [%s]\r\n", cfe.GetNetConMediaType(), DbgNcm(cfe.GetNetConMediaType()));
  785. TraceTag(ttidMenus, " + ncs = %d [%s]\r\n", cfe.GetNetConStatus(), DbgNcs(cfe.GetNetConStatus()));
  786. TraceTag(ttidMenus, " + Characteristics = %08x [%s]\r\n", cfe.GetCharacteristics(), DbgNccf(cfe.GetCharacteristics()));
  787. TraceTag(ttidMenus, " + Permissions = %d (%d & %d)\r\n", g_dwDbgPermissionsFail, dwPermOutside-1, dwPerm-1);
  788. *pdwFailCount++;
  789. }
  790. else
  791. {
  792. *pdwSucceedCount++;
  793. }
  794. }
  795. }
  796. DestroyMenu(hMenu1);
  797. DestroyMenu(hMenu2);
  798. hr = S_OK;
  799. }
  800. }
  801. TraceHr(ttidError, FAL, hr, FALSE, "HrAssertMenuAgainstOldImplementation");
  802. return hr;
  803. }
  804. extern ULONG g_dwDbgWin2kPoliciesSet;
  805. //+---------------------------------------------------------------------------
  806. //
  807. // Member: HrAssertAllLegacyMenusAgainstNew
  808. //
  809. // Purpose: Loads each of the menus from the old Command Matrix, and
  810. // Compare with the newer menus
  811. //
  812. // Arguments:
  813. // [in] hwndOwner Owner window
  814. //
  815. // Returns:
  816. // S_OK is succeeded
  817. // E_FAIL if not
  818. //
  819. // Author: deonb 8 Feb 2001
  820. //
  821. // Notes: Asserts on failure
  822. //
  823. HRESULT HrAssertAllLegacyMenusAgainstNew(HWND hwndOwner)
  824. {
  825. TraceFileFunc(ttidMenus);
  826. HRESULT hr = S_OK;
  827. DWORD dwFailCount = 0;
  828. DWORD dwSucceedCount = 0;
  829. DWORD dwIgnoredCount = 0;
  830. CHAR szErr[8192];
  831. const dwHighestPermissionToCheck = NCPERM_Repair+1; // 0;
  832. TraceTag(ttidMenus, "Asserting all Menus against their Legacy implementation. This may take a while...");
  833. DWORD dwCurrentCount = 0;
  834. DWORD dwTotalCount = 12 * (g_dwContextMenuEntryCount * (1 + ((dwHighestPermissionToCheck+1)*dwHighestPermissionToCheck/2))); // Sum of a series
  835. // + ((1 + g_dwContextMenuEntryCount)*(g_dwContextMenuEntryCount))/2; // Multi-select items (sum of series)
  836. DWORD dwFrequency = dwTotalCount / 200;
  837. dwFrequency = dwFrequency ? dwFrequency : 1;
  838. // 0xFFFFFFFF to NCPERM_Repair inclusive.
  839. g_dwDbgWin2kPoliciesSet = 1;
  840. for (int i = 0; i <= 1; i++, g_dwDbgWin2kPoliciesSet--)
  841. {
  842. for (DWORD dwPermOutside = 0; dwPermOutside <= dwHighestPermissionToCheck; dwPermOutside++)
  843. {
  844. for (DWORD dwPerm = dwPermOutside; dwPerm <= dwHighestPermissionToCheck; dwPerm++)
  845. {
  846. if (dwPerm == dwPermOutside)
  847. {
  848. if (0 == dwPerm) // 0,0 is interesting - otherwise x,x is dup of x,0 (A | B == A | 0 if A==B)
  849. {
  850. g_dwDbgPermissionsFail = 0xFFFFFFFF;
  851. }
  852. else
  853. {
  854. continue;
  855. }
  856. }
  857. else
  858. {
  859. if (dwPermOutside)
  860. {
  861. g_dwDbgPermissionsFail = (1 << (dwPermOutside-1));
  862. }
  863. else
  864. {
  865. g_dwDbgPermissionsFail = 0;
  866. }
  867. if (dwPerm)
  868. {
  869. g_dwDbgPermissionsFail |= (1 << (dwPerm-1));
  870. }
  871. }
  872. for (DWORD x = 0; x < g_dwContextMenuEntryCount; x++)
  873. {
  874. for (int dwInc = 1; dwInc<= 6; dwInc++) // we compare 6 menus at a time
  875. {
  876. if ( (dwCurrentCount % dwFrequency) == 0)
  877. {
  878. TraceTag(ttidMenus, "%d%% done with menu assertions (%d of %d menus compared. Currently using permissions: %08x)", static_cast<DWORD>( (100 * dwCurrentCount) / dwTotalCount), dwCurrentCount, dwTotalCount, g_dwDbgPermissionsFail);
  879. }
  880. dwCurrentCount++;
  881. }
  882. const ContextMenuEntry& cme = c_CMEArray[x];
  883. DWORD dwCharacteristics = 0;
  884. if (cme.fInbound)
  885. {
  886. dwCharacteristics |= NCCF_INCOMING_ONLY;
  887. }
  888. if (cme.fIsDefault)
  889. {
  890. dwCharacteristics |= NCCF_DEFAULT;
  891. }
  892. Sleep(0); // Yield to kernel
  893. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  894. dwCharacteristics |= NCCF_ALLOW_RENAME;
  895. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  896. if (IsMediaLocalType(cme.ncm))
  897. {
  898. dwCharacteristics |= NCCF_BRIDGED;
  899. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  900. dwCharacteristics |= NCCF_FIREWALLED;
  901. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  902. }
  903. else
  904. {
  905. dwCharacteristics |= NCCF_ALL_USERS;
  906. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  907. dwCharacteristics |= NCCF_ALLOW_REMOVAL;
  908. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  909. }
  910. Sleep(0); // Yield to kernel
  911. dwCharacteristics |= NCCF_SHARED;
  912. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  913. dwCharacteristics |= NCCF_FIREWALLED;
  914. HrAssertMenuAgainstOldImplementation(hwndOwner, cme.wizWizard, cme.ncs, cme.ncm, dwCharacteristics, &dwFailCount, &dwSucceedCount, dwPermOutside, dwPerm);
  915. }
  916. }
  917. }
  918. }
  919. g_dwDbgWin2kPoliciesSet = 0xFFFFFFFF; // retore to original value
  920. g_dwDbgPermissionsFail = 0xFFFFFFFF; // retore to original value
  921. // Now, compare multiple items selected menus:
  922. // ***** THIS TEST IS NOT USEFUL. THE LEGACY IMPLEMENTATION SUCKS. COMMENTING OUT FOR NOW *****
  923. // for (DWORD x = 0; x < g_dwContextMenuEntryCount; x++)
  924. // {
  925. // for (DWORD y = x; y < g_dwContextMenuEntryCount; y++)
  926. // {
  927. // if ( (dwCurrentCount % dwFrequency) == 0)
  928. // {
  929. // TraceTag(ttidError, "%d%% done with menu assertions (%d of %d menus compared). Currently multi-comparing %d and %d", static_cast<DWORD>( (100 * dwCurrentCount) / dwTotalCount), dwCurrentCount, dwTotalCount, x, y);
  930. // }
  931. // dwCurrentCount++;
  932. //
  933. // const ContextMenuEntry& cme1 = c_CMEArray[x];
  934. // const ContextMenuEntry& cme2 = c_CMEArray[y];
  935. //
  936. // DWORD dwCharacteristics1 = 0;
  937. // DWORD dwCharacteristics2 = 0;
  938. // if (cme1.fInbound)
  939. // {
  940. // dwCharacteristics1 |= NCCF_INCOMING_ONLY;
  941. // }
  942. // if (cme2.fInbound)
  943. // {
  944. // dwCharacteristics2 |= NCCF_INCOMING_ONLY;
  945. // }
  946. //
  947. // if (cme1.fIsDefault)
  948. // {
  949. // dwCharacteristics1 |= NCCF_DEFAULT;
  950. // }
  951. // if (cme2.fIsDefault)
  952. // {
  953. // dwCharacteristics2 |= NCCF_DEFAULT;
  954. // }
  955. //
  956. // CConFoldEntry cfe1, cfe2;
  957. // PCONFOLDPIDL pcfp1, pcfp2;
  958. //
  959. // BYTE blob[MAX_PATH];
  960. //
  961. // hr = cfe1.HrInitData(
  962. // cme1.wizWizard, cme1.ncm, cme1.ncs, NCS_AUTHENTICATION_SUCCEEDED, &CLSID_ConnectionFolder, &CLSID_ConnectionFolder,
  963. // dwCharacteristics1, blob, MAX_PATH, L"Test PIDL", NULL, NULL);
  964. //
  965. // hr = cfe2.HrInitData(
  966. // cme2.wizWizard, cme2.ncm, cme2.ncs, NCS_AUTHENTICATION_SUCCEEDED, &CLSID_ConnectionFolder, &CLSID_ConnectionFolder,
  967. // dwCharacteristics2, blob, MAX_PATH, L"Test PIDL", NULL, NULL);
  968. //
  969. // if (SUCCEEDED(hr))
  970. // {
  971. // hr = cfe1.ConvertToPidl(pcfp1);
  972. // if (SUCCEEDED(hr))
  973. // {
  974. // hr = cfe2.ConvertToPidl(pcfp2);
  975. // }
  976. // }
  977. //
  978. // if (SUCCEEDED(hr))
  979. // {
  980. // PCONFOLDPIDLVEC pcfpVec;
  981. // pcfpVec.push_back(pcfp1);
  982. // pcfpVec.push_back(pcfp2);
  983. //
  984. // UINT idCmdFirst = 1234;
  985. // UINT idCmdLast = idCmdFirst+1000;
  986. // BOOL fVerbsOnly = FALSE;
  987. //
  988. // HMENU hMenu1 = CreateMenu();
  989. // HMENU hMenu2 = CreateMenu();
  990. // if ( (hMenu1) && (hMenu2) )
  991. // {
  992. // hr = HrBuildMenuOldWay(hMenu1, pcfpVec, hwndOwner, CMT_OBJECT, 0, idCmdFirst, idCmdLast, fVerbsOnly);
  993. //
  994. // if (SUCCEEDED(hr))
  995. // {
  996. // hr = HrBuildMenu(hMenu2, fVerbsOnly, pcfpVec, idCmdFirst);
  997. //
  998. // if (SUCCEEDED(hr))
  999. // {
  1000. // BOOL bIgnoreFlags = TRUE;
  1001. // // Ignore Default flag for multi-compare. The entire legacy implementation is wrong).
  1002. //
  1003. // hr = HrAssertTwoMenusEqual(hMenu1, hMenu2, idCmdFirst, bIgnoreFlags, FALSE);
  1004. // if (FAILED(hr))
  1005. // {
  1006. // TraceTag(ttidError, " + PIDL of failed multi-menu compare:");
  1007. // TraceTag(ttidError, " + PIDL 1:");
  1008. // TraceTag(ttidError, " + wizWizard = %d\r\n", cfe1.GetWizard());
  1009. // TraceTag(ttidError, " + ncm = %d [%s]\r\n", cfe1.GetNetConMediaType(), DBG_NCMAMES[cfe1.GetNetConMediaType()]);
  1010. // TraceTag(ttidError, " + ncs = %d [%s]\r\n", cfe1.GetNetConStatus(), DBG_NCSNAMES[cfe1.GetNetConStatus()]);
  1011. // TraceTag(ttidError, " + Characteristics = %08x\r\n", cfe1.GetCharacteristics());
  1012. // TraceTag(ttidError, " + Permissions = %d\r\n", g_dwDbgPermissionsFail);
  1013. // TraceTag(ttidError, " + PIDL 2:");
  1014. // TraceTag(ttidError, " + wizWizard = %d\r\n", cfe2.GetWizard());
  1015. // TraceTag(ttidError, " + ncm = %d [%s]\r\n", cfe2.GetNetConMediaType(), DBG_NCMAMES[cfe2.GetNetConMediaType()]);
  1016. // TraceTag(ttidError, " + ncs = %d [%s]\r\n", cfe2.GetNetConStatus(), DBG_NCSNAMES[cfe2.GetNetConStatus()]);
  1017. // TraceTag(ttidError, " + Characteristics = %08x\r\n", cfe2.GetCharacteristics());
  1018. // TraceTag(ttidError, " + Permissions = %d\r\n", g_dwDbgPermissionsFail);
  1019. // dwFailCount++;
  1020. // }
  1021. // else
  1022. // {
  1023. // dwSucceedCount++;
  1024. // }
  1025. // }
  1026. // }
  1027. //
  1028. // DestroyMenu(hMenu1);
  1029. // DestroyMenu(hMenu2);
  1030. // hr = S_OK;
  1031. // }
  1032. // }
  1033. //
  1034. // TraceHr(ttidError, FAL, hr, FALSE, "HrAssertAllLegacyMenusAgainstNew");
  1035. // }
  1036. // }
  1037. TraceTag(ttidMenus, "Number of FAILED menu compares: %d", dwFailCount);
  1038. TraceTag(ttidMenus, "Number of SUCCEEDED menu compares: %d", dwSucceedCount);
  1039. TraceTag(ttidMenus, "Number of ITEMS in menu array : %d", (g_dwContextMenuEntryCount + 1) * dwHighestPermissionToCheck);
  1040. sprintf(szErr, "%d of %d menus did not initialize consistend with the old way. (%d initialized correctly. %d was partially ignored due to known bad old implementation)", dwFailCount, dwTotalCount, dwSucceedCount, dwIgnoredCount);
  1041. AssertSz(FALSE, szErr);
  1042. return S_OK;
  1043. }
  1044. COMMANDCHECKENTRY g_cceFolderCommands[] =
  1045. {
  1046. // command id
  1047. // currently checked
  1048. // | new check state
  1049. // | |
  1050. // v v
  1051. { CMIDM_CONMENU_OPERATOR_ASSIST, false, false }
  1052. };
  1053. const DWORD g_nFolderCommandCheckCount = celems(g_cceFolderCommands);
  1054. //+---------------------------------------------------------------------------
  1055. //
  1056. // Function: HrEnableOrDisableMenuItems
  1057. //
  1058. // Purpose: Enable, disable, and or check/uncheck menu items depending
  1059. // on the current selection count, as well as exceptions for
  1060. // the type and state of the connections themselves
  1061. //
  1062. // Arguments:
  1063. // hwnd [in] Our window handle
  1064. // apidlSelected [in] Currently selected objects
  1065. // cPidl [in] Number selected
  1066. // hmenu [in] Our command menu handle
  1067. // idCmdFirst [in] First valid command
  1068. //
  1069. // Returns:
  1070. //
  1071. // Author: jeffspr 2 Feb 1998
  1072. //
  1073. // Notes:
  1074. //
  1075. HRESULT HrEnableOrDisableMenuItems(
  1076. HWND hwnd,
  1077. const PCONFOLDPIDLVEC& apidlSelected,
  1078. HMENU hmenu,
  1079. UINT idCmdFirst)
  1080. {
  1081. HRESULT hr = S_OK;
  1082. DWORD dwLoop = 0;
  1083. RefreshAllPermission();
  1084. // Loop through, and set the new state, based on the selection
  1085. // count compared to the flags for 0-select and multi-select
  1086. //
  1087. for (dwLoop = 0; dwLoop < g_nFolderCommandCount; dwLoop++)
  1088. {
  1089. // If nothing is selected, then check the current state, and
  1090. // if different, adjust
  1091. //
  1092. if (apidlSelected.size() == 0)
  1093. {
  1094. g_cteFolderCommands[dwLoop].fNewState =
  1095. g_cteFolderCommands[dwLoop].fValidOnZero;
  1096. }
  1097. else
  1098. {
  1099. // If singly-selected, then by default, we're always on.
  1100. //
  1101. if (apidlSelected.size() == 1)
  1102. {
  1103. CONFOLDENTRY ccfe;
  1104. // Special case this where one item is selected, but it's the
  1105. // wizard. Use the fValidOnWizardOnly element here.
  1106. //
  1107. hr = apidlSelected[0].ConvertToConFoldEntry(ccfe);
  1108. if (SUCCEEDED(hr))
  1109. {
  1110. if (ccfe.GetWizard())
  1111. {
  1112. g_cteFolderCommands[dwLoop].fNewState =
  1113. g_cteFolderCommands[dwLoop].fValidOnWizardOnly;
  1114. }
  1115. else
  1116. {
  1117. g_cteFolderCommands[dwLoop].fNewState = true;
  1118. }
  1119. }
  1120. }
  1121. else
  1122. {
  1123. // Multi-selected
  1124. //
  1125. g_cteFolderCommands[dwLoop].fNewState =
  1126. g_cteFolderCommands[dwLoop].fValidOnMultiple;
  1127. }
  1128. }
  1129. }
  1130. // Check for various menu item exceptions. Removed from this
  1131. // function for readability's sake.
  1132. //
  1133. DoMenuItemExceptionLoop(apidlSelected);
  1134. // Do the check/uncheck loop.
  1135. //
  1136. DoMenuItemCheckLoop();
  1137. // Update bridge menu item
  1138. // Check to see if it's a LAN connection. If so, disable
  1139. // Loop through the array again, and do the actual EnableMenuItem
  1140. // calls based on the new state compared to the current state.
  1141. // Update the current state as well
  1142. //
  1143. for (dwLoop = 0; dwLoop < g_nFolderCommandCount; dwLoop++)
  1144. {
  1145. #ifdef SHELL_CACHING_MENU_STATE
  1146. // The shell is now enabling these for every call. If they switch
  1147. // to a cached mechanism, change the #define above
  1148. if (g_cteFolderCommands[dwLoop].fNewState !=
  1149. g_cteFolderCommands[dwLoop].fCurrentlyValid)
  1150. #endif
  1151. {
  1152. DWORD dwCommandId = 0;
  1153. switch(g_cteFolderCommands[dwLoop].iCommandId)
  1154. {
  1155. case SFVIDM_FILE_DELETE:
  1156. case SFVIDM_FILE_RENAME:
  1157. case SFVIDM_FILE_LINK:
  1158. case SFVIDM_FILE_PROPERTIES:
  1159. dwCommandId = g_cteFolderCommands[dwLoop].iCommandId;
  1160. break;
  1161. default:
  1162. dwCommandId = g_cteFolderCommands[dwLoop].iCommandId +
  1163. idCmdFirst - CMIDM_FIRST;
  1164. break;
  1165. }
  1166. // Enable or disable the menu item, as appopriate
  1167. //
  1168. EnableMenuItem(
  1169. hmenu,
  1170. dwCommandId,
  1171. g_cteFolderCommands[dwLoop].fNewState ?
  1172. MF_ENABLED | MF_BYCOMMAND : // enable
  1173. MF_GRAYED | MF_BYCOMMAND); // disable
  1174. // Set the state to reflect the enabling/graying
  1175. //
  1176. g_cteFolderCommands[dwLoop].fCurrentlyValid =
  1177. g_cteFolderCommands[dwLoop].fNewState;
  1178. }
  1179. }
  1180. // Loop through the checkmark-able command list, and mark the menu
  1181. // items appropriately
  1182. //
  1183. for (dwLoop = 0; dwLoop < g_nFolderCommandCheckCount; dwLoop++)
  1184. {
  1185. #ifdef SHELL_CACHING_MENU_STATE
  1186. if (g_cceFolderCommands[dwLoop].fCurrentlyChecked !=
  1187. g_cceFolderCommands[dwLoop].fNewCheckState)
  1188. #endif
  1189. {
  1190. DWORD dwCommandId = 0;
  1191. // If we re-add defview menu items that need to be checked/unchecked,
  1192. // the code below will take care of it for us. Note that we
  1193. // don't add the idCmdFirst + CMIDM_FIRST as we do with our own
  1194. // commands
  1195. // switch(g_cceFolderCommands[dwLoop].iCommandId)
  1196. // {
  1197. // case SFVIDM_ARRANGE_AUTO:
  1198. // dwCommandId = g_cceFolderCommands[dwLoop].iCommandId;
  1199. // break;
  1200. // default:
  1201. // dwCommandId = g_cceFolderCommands[dwLoop].iCommandId +
  1202. // idCmdFirst - CMIDM_FIRST;
  1203. // break;
  1204. dwCommandId = g_cceFolderCommands[dwLoop].iCommandId +
  1205. idCmdFirst - CMIDM_FIRST;
  1206. // Check or uncheck the item, as appropriate
  1207. //
  1208. CheckMenuItem(
  1209. hmenu,
  1210. dwCommandId,
  1211. g_cceFolderCommands[dwLoop].fNewCheckState ?
  1212. MF_CHECKED | MF_BYCOMMAND : // checked
  1213. MF_UNCHECKED | MF_BYCOMMAND); // unchecked
  1214. // Set the state to reflect the checking/unchecking
  1215. //
  1216. g_cceFolderCommands[dwLoop].fCurrentlyChecked =
  1217. g_cceFolderCommands[dwLoop].fNewCheckState;
  1218. }
  1219. }
  1220. //special handling for the "Create Bridge" menu item
  1221. //check whether "Create Bridge" exist in the menu
  1222. BOOL fBgMenuExist = (-1 != GetMenuState(hmenu,
  1223. CMIDM_CREATE_BRIDGE + idCmdFirst - CMIDM_FIRST,
  1224. MF_BYCOMMAND));
  1225. BOOL fBgCoMenuExist = (-1 != GetMenuState(hmenu,
  1226. CMIDM_CONMENU_CREATE_BRIDGE + idCmdFirst - CMIDM_FIRST,
  1227. MF_BYCOMMAND));
  1228. if (fBgMenuExist || fBgCoMenuExist)
  1229. {
  1230. BOOL fRemoveBrdgMenu = FALSE;
  1231. #ifdef _WIN64
  1232. // Homenet technologies are not available at all on IA64
  1233. fRemoveBrdgMenu = TRUE;
  1234. #else
  1235. // If the machine is Advanced server or data center, delete the bridge menu item
  1236. OSVERSIONINFOEXW verInfo = {0};
  1237. ULONGLONG ConditionMask = 0;
  1238. verInfo.dwOSVersionInfoSize = sizeof(verInfo);
  1239. verInfo.wSuiteMask = VER_SUITE_ENTERPRISE;
  1240. verInfo.wProductType = VER_NT_SERVER;
  1241. VER_SET_CONDITION(ConditionMask, VER_PRODUCT_TYPE, VER_GREATER_EQUAL);
  1242. VER_SET_CONDITION(ConditionMask, VER_SUITENAME, VER_AND);
  1243. fRemoveBrdgMenu = !!(VerifyVersionInfo(&verInfo,
  1244. VER_PRODUCT_TYPE | VER_SUITENAME,
  1245. ConditionMask));
  1246. #endif
  1247. if (fRemoveBrdgMenu)
  1248. {
  1249. if (fBgMenuExist)
  1250. {
  1251. DeleteMenu(hmenu,
  1252. CMIDM_CREATE_BRIDGE + idCmdFirst - CMIDM_FIRST,
  1253. MF_BYCOMMAND);
  1254. }
  1255. if (fBgCoMenuExist)
  1256. {
  1257. DeleteMenu(hmenu,
  1258. CMIDM_CONMENU_CREATE_BRIDGE + idCmdFirst - CMIDM_FIRST,
  1259. MF_BYCOMMAND);
  1260. }
  1261. }
  1262. else if (IsBridgeInstalled()) // REVIEW can we cache this somehow
  1263. {
  1264. //if the bridge is already installed, modify the menu item string
  1265. MENUITEMINFO MenuItemInfo = {sizeof(MenuItemInfo)};
  1266. MenuItemInfo.fMask = MIIM_STRING;
  1267. MenuItemInfo.fType = MFT_STRING;
  1268. MenuItemInfo.dwTypeData = const_cast<LPWSTR>(SzLoadIds(IDS_CMIDM_ADD_TO_BRIDGE));
  1269. if (fBgMenuExist)
  1270. SetMenuItemInfo(hmenu,
  1271. CMIDM_CREATE_BRIDGE + idCmdFirst - CMIDM_FIRST,
  1272. FALSE,
  1273. &MenuItemInfo);
  1274. if (fBgCoMenuExist)
  1275. {
  1276. MenuItemInfo.fMask = MIIM_STATE;
  1277. MenuItemInfo.fState = MFS_DISABLED;
  1278. SetMenuItemInfo(hmenu,
  1279. CMIDM_CONMENU_CREATE_BRIDGE + idCmdFirst - CMIDM_FIRST,
  1280. FALSE,
  1281. &MenuItemInfo);
  1282. }
  1283. }
  1284. }
  1285. TraceHr(ttidError, FAL, hr, FALSE, "HrEnableOrDisableMenuItems");
  1286. return hr;
  1287. }
  1288. //+---------------------------------------------------------------------------
  1289. //
  1290. // Function: FEnableConnectDisconnectMenuItem
  1291. //
  1292. // Purpose: Enable or disable the connect/disconnect menu item
  1293. // depending on permissions and the current state of the
  1294. // connection (already connected, disconnected, in the state
  1295. // of connecting, etc.)
  1296. //
  1297. // Arguments:
  1298. // pcfp [in] Our pidl
  1299. // iCommandId [in] CMIDM_CONNECT, CMIDM_ENABLE, CMIDM_DISABLE, or CMIDM_DISCONNECT
  1300. //
  1301. // Returns:
  1302. //
  1303. // Author: jeffspr 8 Apr 1999
  1304. //
  1305. // Notes:
  1306. //
  1307. bool FEnableConnectDisconnectMenuItem(const PCONFOLDPIDL& pcfp, int iCommandId)
  1308. {
  1309. bool fEnableAction = false;
  1310. BOOL fPermissionsValid = false;
  1311. Assert(!pcfp.empty());
  1312. Assert(iCommandId == CMIDM_CONNECT || iCommandId == CMIDM_DISCONNECT || iCommandId == CMIDM_ENABLE || iCommandId == CMIDM_DISABLE);
  1313. // Make the permissions check based on media type
  1314. //
  1315. switch(pcfp->ncm )
  1316. {
  1317. case NCM_BRIDGE:
  1318. fPermissionsValid = FHasPermissionFromCache(NCPERM_AllowNetBridge_NLA);
  1319. break;
  1320. case NCM_SHAREDACCESSHOST_LAN:
  1321. case NCM_SHAREDACCESSHOST_RAS:
  1322. fPermissionsValid = FHasPermissionFromCache(NCPERM_ShowSharedAccessUi);
  1323. break;
  1324. case NCM_LAN:
  1325. fPermissionsValid = FHasPermissionFromCache(NCPERM_LanConnect);
  1326. break;
  1327. case NCM_DIRECT:
  1328. case NCM_ISDN:
  1329. case NCM_PHONE:
  1330. case NCM_TUNNEL:
  1331. fPermissionsValid = FHasPermissionFromCache(NCPERM_RasConnect);
  1332. break;
  1333. case NCM_NONE:
  1334. // No media-type, no connect
  1335. fPermissionsValid = FALSE;
  1336. break;
  1337. default:
  1338. AssertSz(FALSE, "Need to add a switch for this connection type in the menuing code");
  1339. break;
  1340. }
  1341. if (fPermissionsValid)
  1342. {
  1343. switch(pcfp->ncs)
  1344. {
  1345. case NCS_CONNECTING:
  1346. if (iCommandId == CMIDM_CONNECT || iCommandId == CMIDM_ENABLE)
  1347. {
  1348. if (!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY))
  1349. {
  1350. fEnableAction = false;
  1351. }
  1352. }
  1353. break;
  1354. case NCS_DISCONNECTED:
  1355. // Don't check for activating because the
  1356. // default command "Connect" will be disabled.
  1357. // The code currently handles attempts to connect
  1358. // to a connected/ing connection.
  1359. //
  1360. if (iCommandId == CMIDM_CONNECT || iCommandId == CMIDM_ENABLE)
  1361. {
  1362. if (!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY))
  1363. {
  1364. fEnableAction = true;
  1365. }
  1366. }
  1367. break;
  1368. case NCS_DISCONNECTING:
  1369. if (iCommandId == CMIDM_DISCONNECT || iCommandId == CMIDM_DISABLE)
  1370. {
  1371. fEnableAction = false;
  1372. }
  1373. break;
  1374. case NCS_CONNECTED:
  1375. case NCS_MEDIA_DISCONNECTED:
  1376. case NCS_INVALID_ADDRESS:
  1377. if (iCommandId == CMIDM_DISCONNECT || iCommandId == CMIDM_DISABLE)
  1378. {
  1379. fEnableAction = true;
  1380. }
  1381. break;
  1382. case NCS_HARDWARE_NOT_PRESENT:
  1383. case NCS_HARDWARE_DISABLED:
  1384. case NCS_HARDWARE_MALFUNCTION:
  1385. // Certainly don't support connect/disconnect actions here.
  1386. break;
  1387. default:
  1388. AssertSz(FALSE, "Who invented a new connection state, and when can I horsewhip them?");
  1389. break;
  1390. }
  1391. }
  1392. return (fEnableAction);
  1393. }
  1394. //+---------------------------------------------------------------------------
  1395. //
  1396. // Function: DoMenuItemExceptionLoop
  1397. //
  1398. // Purpose: Check for various menu item exceptions.
  1399. //
  1400. // Arguments:
  1401. // apidlSelected [in] Selected items
  1402. // cPidl [in] Count of selected items
  1403. //
  1404. // Returns:
  1405. //
  1406. // Author: jeffspr 26 Feb 1998
  1407. //
  1408. // Notes:
  1409. //
  1410. VOID DoMenuItemExceptionLoop(const PCONFOLDPIDLVEC& apidlSelected)
  1411. {
  1412. DWORD dwLoop = 0;
  1413. PCONFOLDPIDLVEC::const_iterator iterObjectLoop;
  1414. bool fEnableDelete = false;
  1415. bool fEnableStatus = false;
  1416. bool fEnableRename = false;
  1417. bool fEnableShortcut = false;
  1418. bool fEnableConnect = false;
  1419. bool fEnableDisconnect = false;
  1420. bool fEnableCreateCopy = false;
  1421. bool fEnableProperties = false;
  1422. bool fEnableCreateBridge = true;
  1423. bool fEnableFix = true;
  1424. // Loop through each of the selected objects
  1425. //
  1426. for (iterObjectLoop = apidlSelected.begin(); iterObjectLoop != apidlSelected.end(); iterObjectLoop++)
  1427. {
  1428. // Validate the pidls
  1429. //
  1430. const PCONFOLDPIDL& pcfp = *iterObjectLoop;
  1431. if ( pcfp.empty() )
  1432. {
  1433. AssertSz(FALSE, "Bogus pidl array in DoMenuItemExceptionLoop (status)");
  1434. }
  1435. else
  1436. {
  1437. BOOL fActivating = FALSE;
  1438. CONFOLDENTRY cfEmpty;
  1439. (VOID) HrCheckForActivation(pcfp, cfEmpty, &fActivating);
  1440. // Loop through the commands
  1441. //
  1442. for (dwLoop = 0; dwLoop < g_nFolderCommandCount; dwLoop++)
  1443. {
  1444. // Only allow items to be changed to ENABLED states when they're
  1445. // previously DISABLED
  1446. //
  1447. if (g_cteFolderCommands[dwLoop].fNewState)
  1448. {
  1449. int iCommandId = g_cteFolderCommands[dwLoop].iCommandId;
  1450. switch(iCommandId)
  1451. {
  1452. // For status, verify that at least ONE of the entries is connected.
  1453. // If not, then we don't allow status.
  1454. //
  1455. case CMIDM_STATUS:
  1456. if ( ( fIsConnectedStatus(pcfp->ncs) || (pcfp->ncs == NCS_INVALID_ADDRESS) ) &&
  1457. FHasPermissionFromCache(NCPERM_Statistics))
  1458. {
  1459. // Raid #379459: If logged on as non-admin, disable status
  1460. if (!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY) ||
  1461. FIsUserAdmin())
  1462. {
  1463. fEnableStatus = true;
  1464. }
  1465. }
  1466. break;
  1467. case CMIDM_CREATE_SHORTCUT:
  1468. case SFVIDM_FILE_LINK:
  1469. if (!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY))
  1470. {
  1471. fEnableShortcut = true;
  1472. }
  1473. break;
  1474. // For delete, verify that at least ONE of the entries has removeable
  1475. // flag set. If not, then disable the command
  1476. //
  1477. case CMIDM_DELETE:
  1478. case SFVIDM_FILE_DELETE:
  1479. if (pcfp->dwCharacteristics & NCCF_ALLOW_REMOVAL)
  1480. {
  1481. // Note: Need to convert this back to using
  1482. // the DeleteAllUserConnection when that functionality
  1483. // is added to the System.ADM file.
  1484. //
  1485. if (FHasPermissionFromCache(NCPERM_DeleteConnection))
  1486. {
  1487. if (!(pcfp->dwCharacteristics & NCCF_ALL_USERS) ||
  1488. ((pcfp->dwCharacteristics & NCCF_ALL_USERS) &&
  1489. FHasPermissionFromCache(NCPERM_DeleteAllUserConnection)))
  1490. {
  1491. fEnableDelete = true;
  1492. }
  1493. }
  1494. }
  1495. break;
  1496. // For rename, verify that at least ONE of the entries has the rename
  1497. // flag set. If not, then disable the command
  1498. //
  1499. case CMIDM_RENAME:
  1500. case SFVIDM_FILE_RENAME:
  1501. if (pcfp->dwCharacteristics & NCCF_ALLOW_RENAME)
  1502. {
  1503. if (HasPermissionToRenameConnection(pcfp))
  1504. {
  1505. fEnableRename = true;
  1506. }
  1507. }
  1508. break;
  1509. // For duplicate, verify that at least ONE of the entries
  1510. // has the duplicate flag set and that the user can create
  1511. // new connections. If not, then disable the command.
  1512. //
  1513. case CMIDM_CREATE_COPY:
  1514. if ((pcfp->dwCharacteristics & NCCF_ALLOW_DUPLICATION) &&
  1515. FHasPermissionFromCache(NCPERM_NewConnectionWizard))
  1516. {
  1517. // In all cases except when the connection is an
  1518. // all user connection and the user does NOT have
  1519. // permissions to view all user properties, we'll
  1520. // allow it to be enabled.
  1521. //
  1522. if ((!(pcfp->dwCharacteristics & NCCF_ALL_USERS)) ||
  1523. (FHasPermissionFromCache(NCPERM_RasAllUserProperties)))
  1524. {
  1525. fEnableCreateCopy = true;
  1526. }
  1527. }
  1528. break;
  1529. case CMIDM_CONNECT:
  1530. case CMIDM_ENABLE:
  1531. // Raid #379459: If logged on as non-admin, disable connect
  1532. if (!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY) ||
  1533. FIsUserAdmin())
  1534. {
  1535. fEnableConnect = FEnableConnectDisconnectMenuItem(pcfp, CMIDM_CONNECT);
  1536. }
  1537. break;
  1538. case CMIDM_DISCONNECT:
  1539. case CMIDM_DISABLE:
  1540. // Raid #379459: If logged on as non-admin, disable disconnect
  1541. if (!(pcfp->dwCharacteristics & NCCF_INCOMING_ONLY) ||
  1542. FIsUserAdmin())
  1543. {
  1544. fEnableDisconnect = FEnableConnectDisconnectMenuItem(pcfp, CMIDM_DISCONNECT);
  1545. }
  1546. break;
  1547. case CMIDM_FIX:
  1548. fEnableFix = ((NCS_INVALID_ADDRESS == pcfp->ncs || fIsConnectedStatus(pcfp->ncs) ) &&
  1549. FHasPermission(NCPERM_Repair));
  1550. break;
  1551. case CMIDM_PROPERTIES:
  1552. case SFVIDM_FILE_PROPERTIES:
  1553. // Raid #379459: If logged on as non-admin, disable properties
  1554. // We only enable if this is not a LAN connection, or the user has the correct
  1555. // permissions. That way we don't accidentally give user that doesn't have permission
  1556. // the ability to do something they shouldn't, either in the case of a call failing or an
  1557. // unforeseen error occuring.
  1558. if (IsMediaRASType(pcfp->ncm))
  1559. {
  1560. fEnableProperties = (TRUE == ((pcfp->dwCharacteristics & NCCF_ALL_USERS) ?
  1561. (FHasPermission(NCPERM_RasAllUserProperties)) :
  1562. (FHasPermission(NCPERM_RasMyProperties))));
  1563. }
  1564. else // This is a lan connection.
  1565. {
  1566. fEnableProperties = true;
  1567. }
  1568. case CMIDM_CREATE_BRIDGE:
  1569. case CMIDM_CONMENU_CREATE_BRIDGE:
  1570. if((NCCF_BRIDGED | NCCF_FIREWALLED | NCCF_SHARED) & pcfp->dwCharacteristics || NCM_LAN != pcfp->ncm || !FHasPermission(NCPERM_AllowNetBridge_NLA))
  1571. {
  1572. fEnableCreateBridge = false;
  1573. }
  1574. break;
  1575. default:
  1576. break;
  1577. }
  1578. }
  1579. }
  1580. }
  1581. // Loop through the commands, and disable the commands, if appropriate
  1582. //
  1583. for (dwLoop = 0; dwLoop < g_nFolderCommandCount; dwLoop++)
  1584. {
  1585. switch(g_cteFolderCommands[dwLoop].iCommandId)
  1586. {
  1587. case CMIDM_RENAME:
  1588. case SFVIDM_FILE_RENAME:
  1589. g_cteFolderCommands[dwLoop].fNewState = fEnableRename;
  1590. break;
  1591. case CMIDM_DELETE:
  1592. case SFVIDM_FILE_DELETE:
  1593. g_cteFolderCommands[dwLoop].fNewState = fEnableDelete;
  1594. break;
  1595. case CMIDM_STATUS:
  1596. g_cteFolderCommands[dwLoop].fNewState = fEnableStatus;
  1597. break;
  1598. case CMIDM_CREATE_SHORTCUT:
  1599. case SFVIDM_FILE_LINK:
  1600. g_cteFolderCommands[dwLoop].fNewState = fEnableShortcut;
  1601. break;
  1602. case CMIDM_CONNECT:
  1603. case CMIDM_ENABLE:
  1604. g_cteFolderCommands[dwLoop].fNewState = fEnableConnect;
  1605. break;
  1606. case CMIDM_DISCONNECT:
  1607. case CMIDM_DISABLE:
  1608. g_cteFolderCommands[dwLoop].fNewState = fEnableDisconnect;
  1609. break;
  1610. case CMIDM_FIX:
  1611. g_cteFolderCommands[dwLoop].fNewState = fEnableFix;
  1612. break;
  1613. case CMIDM_CREATE_COPY:
  1614. g_cteFolderCommands[dwLoop].fNewState = fEnableCreateCopy;
  1615. break;
  1616. case CMIDM_PROPERTIES:
  1617. case SFVIDM_FILE_PROPERTIES:
  1618. g_cteFolderCommands[dwLoop].fNewState = fEnableProperties;
  1619. break;
  1620. case CMIDM_CREATE_BRIDGE:
  1621. case CMIDM_CONMENU_CREATE_BRIDGE:
  1622. g_cteFolderCommands[dwLoop].fNewState = fEnableCreateBridge;
  1623. break;
  1624. default:
  1625. break;
  1626. }
  1627. }
  1628. }
  1629. // Process commands whose state is not controlled by selection
  1630. //
  1631. for (dwLoop = 0; dwLoop < g_nFolderCommandCount; dwLoop++)
  1632. {
  1633. // Only allow items to be changed to ENABLED states when they're
  1634. // previously DISABLED
  1635. //
  1636. switch(g_cteFolderCommands[dwLoop].iCommandId)
  1637. {
  1638. case CMIDM_NEW_CONNECTION:
  1639. if (!FHasPermissionFromCache(NCPERM_NewConnectionWizard))
  1640. {
  1641. g_cteFolderCommands[dwLoop].fNewState = false;
  1642. }
  1643. break;
  1644. case CMIDM_CONMENU_ADVANCED_CONFIG:
  1645. if (!FHasPermissionFromCache(NCPERM_AdvancedSettings))
  1646. {
  1647. g_cteFolderCommands[dwLoop].fNewState = false;
  1648. }
  1649. break;
  1650. case CMIDM_CONMENU_OPTIONALCOMPONENTS:
  1651. if (!FHasPermissionFromCache(NCPERM_AddRemoveComponents))
  1652. {
  1653. g_cteFolderCommands[dwLoop].fNewState = false;
  1654. }
  1655. break;
  1656. case CMIDM_CONMENU_DIALUP_PREFS:
  1657. if (!FHasPermissionFromCache(NCPERM_DialupPrefs))
  1658. {
  1659. g_cteFolderCommands[dwLoop].fNewState = false;
  1660. }
  1661. default:
  1662. break;
  1663. }
  1664. }
  1665. }
  1666. //+---------------------------------------------------------------------------
  1667. //
  1668. // Function: DoMenuItemCheckLoop
  1669. //
  1670. // Purpose: Walk through the list of checkmark-able commands and get
  1671. // their values.
  1672. //
  1673. // Arguments:
  1674. // None
  1675. //
  1676. // Returns:
  1677. //
  1678. // Author: jeffspr 26 Feb 1998
  1679. //
  1680. // Notes:
  1681. //
  1682. VOID DoMenuItemCheckLoop(VOID)
  1683. {
  1684. DWORD dwLoop = 0;
  1685. for (; dwLoop < g_nFolderCommandCheckCount; dwLoop++)
  1686. {
  1687. switch(g_cceFolderCommands[dwLoop].iCommandId)
  1688. {
  1689. // We used to check SFVIDM_AUTO_ARRANGE, but we no longer force it on.
  1690. //
  1691. case CMIDM_CONMENU_OPERATOR_ASSIST:
  1692. g_cceFolderCommands[dwLoop].fNewCheckState = g_fOperatorAssistEnabled;
  1693. break;
  1694. default:
  1695. break;
  1696. }
  1697. }
  1698. }
  1699. #endif