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.

244 lines
11 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C M D T A B L E . H
  7. //
  8. // Contents: Command-table code -- determines which menu options are
  9. // available by the selection count, among other criteria
  10. //
  11. // Notes:
  12. //
  13. // Author: jeffspr 28 Jan 1998
  14. //
  15. //----------------------------------------------------------------------------
  16. #pragma once
  17. #include "ncperms.h"
  18. //---[ Constants ]------------------------------------------------------------
  19. #define CMIDM_SEPARATOR 0xffffffff
  20. typedef enum tagNETCON_MEDIATYPE_BM
  21. {
  22. NBM_ANY = 0xFFFFFFFF,
  23. NBM_NOMEDIATYPE = 0,
  24. NBM_MNC_WIZARD = 0x80000000,
  25. NBM_HNW_WIZARD = 0x40000000,
  26. NBM_INCOMING= 1 << NCM_NONE,
  27. NBM_DIRECT = 1 << NCM_DIRECT,
  28. NBM_ISDN = 1 << NCM_ISDN,
  29. NBM_LAN = 1 << NCM_LAN,
  30. NBM_PHONE = 1 << NCM_PHONE,
  31. NBM_TUNNEL = 1 << NCM_TUNNEL,
  32. NBM_PPPOE = 1 << NCM_PPPOE,
  33. NBM_BRIDGE = 1 << NCM_BRIDGE,
  34. NBM_SHAREDACCESSHOST_LAN = 1 << NCM_SHAREDACCESSHOST_LAN,
  35. NBM_SHAREDACCESSHOST_RAS = 1 << NCM_SHAREDACCESSHOST_RAS,
  36. NBM_ISLANTYPE = NBM_LAN | NBM_BRIDGE,
  37. NBM_ISRASTYPE = NBM_ISDN | NBM_DIRECT | NBM_PHONE | NBM_TUNNEL | NBM_PPPOE,
  38. NBM_ISCONNECTIONTYPE = NBM_ISLANTYPE | NBM_ISRASTYPE,
  39. NBM_NOTWIZARD = ~(NBM_MNC_WIZARD | NBM_HNW_WIZARD)
  40. } NETCON_MEDIATYPE_BM;
  41. typedef enum tagNETCON_STATUS_BM
  42. {
  43. NBS_ANY = 0xFFFFFFFF,
  44. NBS_NONE = 0,
  45. NBS_DISCONNECTED = 1 << NCS_DISCONNECTED,
  46. NBS_CONNECTING = 1 << NCS_CONNECTING,
  47. NBS_CONNECTED = 1 << NCS_CONNECTED,
  48. NBS_DISCONNECTING = 1 << NCS_DISCONNECTING,
  49. NBS_HARDWARE_NOT_PRESENT = 1 << NCS_HARDWARE_NOT_PRESENT,
  50. NBS_HARDWARE_DISABLED = 1 << NCS_HARDWARE_DISABLED,
  51. NBS_HARDWARE_MALFUNCTION = 1 << NCS_HARDWARE_MALFUNCTION,
  52. NBS_MEDIA_DISCONNECTED = 1 << NCS_MEDIA_DISCONNECTED,
  53. NBS_AUTHENTICATING = 1 << NCS_AUTHENTICATING,
  54. NBS_AUTHENTICATION_SUCCEEDED= 1 << NCS_AUTHENTICATION_SUCCEEDED,
  55. NBS_AUTHENTICATION_FAILED = 1 << NCS_AUTHENTICATION_FAILED,
  56. NBS_INVALID_ADDRESS = 1 << NCS_INVALID_ADDRESS,
  57. NBS_CREDENTIALS_REQUIRED = 1 << NCS_CREDENTIALS_REQUIRED,
  58. NBS_NOT_DISCONNECTED = NBS_ANY & ~NBS_DISCONNECTED,
  59. NBS_NOT_DISCONNECT = NBS_CONNECTED | NBS_MEDIA_DISCONNECTED | NBS_INVALID_ADDRESS | NBS_AUTHENTICATING | NBS_AUTHENTICATION_SUCCEEDED | NBS_AUTHENTICATION_FAILED | NBS_CREDENTIALS_REQUIRED,
  60. NBS_HW_ISSUE = NBS_HARDWARE_NOT_PRESENT | NBS_HARDWARE_DISABLED | NBS_HARDWARE_MALFUNCTION,
  61. NBS_IS_CONNECTED = NBS_CONNECTED | NBS_AUTHENTICATION_SUCCEEDED | NBS_AUTHENTICATION_FAILED | NBS_AUTHENTICATING | NBS_CREDENTIALS_REQUIRED
  62. } NETCON_STATUS_BM;
  63. const DWORD64 NBPERM_NewConnectionWizard = 1 << NCPERM_NewConnectionWizard;
  64. const DWORD64 NBPERM_Statistics = 1 << NCPERM_Statistics;
  65. const DWORD64 NBPERM_AddRemoveComponents = 1 << NCPERM_AddRemoveComponents;
  66. const DWORD64 NBPERM_RasConnect = 1 << NCPERM_RasConnect;
  67. const DWORD64 NBPERM_LanConnect = 1 << NCPERM_LanConnect;
  68. const DWORD64 NBPERM_DeleteConnection = 1 << NCPERM_DeleteConnection;
  69. const DWORD64 NBPERM_DeleteAllUserConnection = 1 << NCPERM_DeleteAllUserConnection;
  70. const DWORD64 NBPERM_RenameConnection = 1 << NCPERM_RenameConnection;
  71. const DWORD64 NBPERM_RenameMyRasConnection = 1 << NCPERM_RenameMyRasConnection;
  72. const DWORD64 NBPERM_ChangeBindState = 1 << NCPERM_ChangeBindState;
  73. const DWORD64 NBPERM_AdvancedSettings = 1 << NCPERM_AdvancedSettings;
  74. const DWORD64 NBPERM_DialupPrefs = 1 << NCPERM_DialupPrefs;
  75. const DWORD64 NBPERM_LanChangeProperties = 1 << NCPERM_LanChangeProperties;
  76. const DWORD64 NBPERM_RasChangeProperties = 1 << NCPERM_RasChangeProperties;
  77. const DWORD64 NBPERM_LanProperties = 1 << NCPERM_LanProperties;
  78. const DWORD64 NBPERM_RasMyProperties = 1 << NCPERM_RasMyProperties;
  79. const DWORD64 NBPERM_RasAllUserProperties = 1 << NCPERM_RasAllUserProperties;
  80. const DWORD64 NBPERM_ShowSharedAccessUi = 1 << NCPERM_ShowSharedAccessUi;
  81. const DWORD64 NBPERM_AllowAdvancedTCPIPConfig = 1 << NCPERM_AllowAdvancedTCPIPConfig;
  82. const DWORD64 NBPERM_OpenConnectionsFolder = 1 << NCPERM_OpenConnectionsFolder;
  83. const DWORD64 NBPERM_PersonalFirewallConfig = 1 << NCPERM_PersonalFirewallConfig;
  84. const DWORD64 NBPERM_AllowNetBridge_NLA = 1 << NCPERM_AllowNetBridge_NLA;
  85. const DWORD64 NBPERM_ICSClientApp = 1 << NCPERM_ICSClientApp;
  86. const DWORD64 NBPERM_EnDisComponentsAllUserRas = 1 << NCPERM_EnDisComponentsAllUserRas;
  87. const DWORD64 NBPERM_EnDisComponentsMyRas = 1 << NCPERM_EnDisComponentsMyRas;
  88. const DWORD64 NBPERM_ChangeMyRasProperties = 1 << NCPERM_ChangeMyRasProperties;
  89. const DWORD64 NBPERM_ChangeAllUserRasProperties = 1 << NCPERM_ChangeAllUserRasProperties;
  90. const DWORD64 NBPERM_RenameLanConnection = 1 << NCPERM_RenameLanConnection;
  91. const DWORD64 NBPERM_RenameAllUserRasConnection = 1 << NCPERM_RenameAllUserRasConnection;
  92. const DWORD64 NBPERM_IpcfgOperation = 1 << NCPERM_IpcfgOperation;
  93. const DWORD64 NBPERM_Repair = 1 << NCPERM_Repair;
  94. const DWORD64 NBPERM_Always = 0x00000000;
  95. typedef enum tagNB_MENUVALID
  96. {
  97. NCWHEN_ANYSELECT = 0xFFFFFFFF,
  98. NCWHEN_TOPLEVEL = 1,
  99. NCWHEN_ONESELECT = 2,
  100. NCWHEN_MULTISELECT = 4,
  101. NCWHEN_TOPLEVEL_DISREGARD_ITEM = 8,
  102. NCWHEN_SOMESELECT = NCWHEN_ONESELECT | NCWHEN_MULTISELECT
  103. } NB_MENUVALID;
  104. typedef enum tagNCCS_STATE
  105. {
  106. NCCS_ENABLED = 1,
  107. NCCS_DISABLED = 2,
  108. NCCS_NOTSHOWN = 3
  109. } NCCS_STATE;
  110. typedef enum tagNCCS_CHECKED_STATE
  111. {
  112. NCCS_UNCHECKED = 0,
  113. NCCS_CHECKED = 1
  114. } NCCS_CHECKED_STATE;
  115. typedef enum tagNB_REMOVEDISABLE
  116. {
  117. NB_NO_FLAGS = 0x0,
  118. NB_NEGATE_VIS_NBM_MATCH = 0x1,
  119. NB_NEGATE_VIS_NBS_MATCH = 0x2,
  120. NB_NEGATE_VIS_CHAR_MATCH = 0x4,
  121. NB_NEGATE_VIS_PERMS_MATCH = 0x8,
  122. NB_NEGATE_ACT_NBM_MATCH = 0x10,
  123. NB_NEGATE_ACT_NBS_MATCH = 0x20,
  124. NB_NEGATE_ACT_CHAR_MATCH = 0x40,
  125. NB_NEGATE_ACT_PERMS_MATCH = 0x80,
  126. NB_VERB = 0x100,
  127. NB_FLAG_ON_TOPMENU = 0x1000,
  128. NB_TOPLEVEL_PERM = 0x2000, // perms only
  129. NB_REMOVE_IF_NOT_MATCH = 0x4000, // perms only
  130. NB_REMOVE_TOPLEVEL_ITEM = 0x8000, // applies to top-level items only. WARNING: Permanent effect.
  131. // Use this only for something that cannot change inside the same user session.
  132. NB_REVERSE_TOPLEVEL_ITEM = 0x10000, // applies to top-level items only. WARNING: Permanent effect.
  133. // Use this only for something that cannot change inside the same user session.
  134. NB_NEGATE_NBM_MATCH = NB_NEGATE_VIS_NBM_MATCH | NB_NEGATE_ACT_NBM_MATCH,
  135. NB_NEGATE_NBS_MATCH = NB_NEGATE_VIS_NBS_MATCH | NB_NEGATE_ACT_NBS_MATCH,
  136. NB_NEGATE_CHAR_MATCH = NB_NEGATE_VIS_CHAR_MATCH | NB_NEGATE_ACT_CHAR_MATCH,
  137. NB_NEGATE_PERMS_MATCH = NB_NEGATE_VIS_PERMS_MATCH | NB_NEGATE_ACT_PERMS_MATCH
  138. } NB_REMOVEDISABLE;
  139. struct CMDCHKENTRY
  140. {
  141. int iCommandId; // Associated command ID
  142. bool fCurrentlyChecked; // Is this menu item already checked?
  143. bool fNewCheckState; // What's the new check state?
  144. };
  145. // If this function returns S_FALSE it's an indication it didn't change the state.
  146. typedef HRESULT (HrEnableDisableCB)(
  147. IN const CConFoldEntry& cfe,
  148. IN BOOL fMultiSelect,
  149. IN int iCommandId,
  150. OUT NCCS_STATE& nccs
  151. );
  152. // If this function returns S_FALSE it's an indication to use Default string
  153. typedef HRESULT (HrCustomMenuStringCB)(
  154. IN const CConFoldEntry& cfe,
  155. IN int iCommandId,
  156. OUT LPDWORD pdwResourceId
  157. );
  158. // Implementations of HrEnableDisableCB/HrCustomMenuStringCB
  159. //HrEnableDisableCB HrDisableForIncomingClients;
  160. HrEnableDisableCB HrCanRenameConnection;
  161. HrEnableDisableCB HrCanShowProperties;
  162. HrEnableDisableCB HrIsBridgeSupported;
  163. HrEnableDisableCB HrIsHomeNewWizardSupported;
  164. HrEnableDisableCB HrIsTroubleShootSupported;
  165. HrEnableDisableCB HrIsMediaWireless;
  166. HrEnableDisableCB HrIsNCWSupported;
  167. struct COMMANDENTRY
  168. {
  169. int iCommandId;
  170. DWORD dwDefaultPriority; // The highest item that's visible+active will be the default. 0 item will never be selected.
  171. DWORD dwValidWhen; // NB_MENUVALID flags
  172. DWORD dwFlags; // NB_REMOVEDISABLE flags (disabled unless specified in this flags - then removed).
  173. HrEnableDisableCB *pfnHrEnableDisableCB; // Callback function. Return S_FALSE to leave alone
  174. HrCustomMenuStringCB *pfnHrCustomMenuStringCB; // Callback function. Return S_FALSE/E_ to leave alone, or S_OK with a dwResourceID
  175. DWORD dwMediaTypeVisible; // NETCON_MEDIATYPE_BM flags
  176. DWORD dwMediaTypeActive; // NETCON_MEDIATYPE_BM flags
  177. DWORD dwStatusVisible; // NETCON_STATUS_BM flags
  178. DWORD dwStatusActive; // NETCON_STATUS_BM flags
  179. DWORD dwCharacteristicsVisible; // NCCF_ flags
  180. DWORD dwCharacteristicsActive; // NCCF_ flags
  181. };
  182. struct COMMANDPERMISSIONSENTRY
  183. {
  184. int iCommandId;
  185. DWORD dwMediaType;
  186. DWORD dwCharacteristicsActive;
  187. DWORD dwFlags; // NB_REMOVEDISABLE flags (disabled unless specified in this flags - then removed).
  188. DWORD64 dwPermissionsActive; // e.g. NBPERM_NewConnectionWizard - NBPERM_Always for always enabled
  189. NCPERM_APPLY_TO ncpAppliesTo;
  190. };
  191. struct SFVCOMMANDMAP
  192. {
  193. int iSFVCommandId;
  194. int iCommandId;
  195. };
  196. extern COMMANDENTRY g_cteCommandMatrix[];
  197. extern const DWORD g_cteCommandMatrixCount;
  198. //---[ Prototypes ]-----------------------------------------------------------
  199. HRESULT HrBuildMenu(IN OUT HMENU &hMenu, IN BOOL fVerbsOnly, IN PCONFOLDPIDLVEC& cfpl, IN DWORD idCmdFirst);
  200. HRESULT HrUpdateMenu(IN OUT HMENU &hMenu, IN PCONFOLDPIDLVEC& cfpl, IN DWORD idCmdFirst);
  201. HRESULT HrAssertTwoMenusEqual(IN HMENU hMenu1, IN HMENU hMenu2, IN UINT idCmdFirst, IN BOOL bIgnoreFlags, IN BOOL fPopupAsserts);
  202. HRESULT HrAssertMenuStructuresValid(IN HWND hwndOwner);
  203. HRESULT HrGetCommandState(IN const PCONFOLDPIDLVEC& cfpl, IN const DWORD dwCmdID, OUT NCCS_STATE& nccs, OUT LPDWORD dwResourceId, IN DWORD cteHint = 0xffffffff, IN DWORD dwOverrideFlag = 0);
  204. BOOL HasPermissionToRenameConnection(IN const PCONFOLDPIDL& pcfp);
  205. HRESULT HrSetConnectDisconnectMenuItem(
  206. IN const PCONFOLDPIDLVEC& apidlSelected,
  207. IN OUT HMENU hmenu,
  208. IN INT idCmdFirst);