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.

142 lines
5.5 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: customaction.h
  4. //
  5. // Module: CMAK.EXE
  6. //
  7. // Synopsis: Header file for the CustomActionList and CustomActionListEnumerator
  8. // classes used by CMAK to handle its custom actions.
  9. //
  10. // Copyright (c) 2000 Microsoft Corporation
  11. //
  12. // Author: quintinb Created 02/26/00
  13. //
  14. //+----------------------------------------------------------------------------
  15. #include "conact.h"
  16. //
  17. // We display the flags to the user in a different order than the flags were created. Thus we have to arrays to
  18. // map between the display order and the actual order and vice versa.
  19. //
  20. const int c_iExecutionIndexToFlagsMap[c_iNumCustomActionExecutionStates] = {ALL_CONNECTIONS, ALL_DIALUP, ALL_TUNNEL, DIRECT_ONLY, DIALUP_ONLY};
  21. const int c_iExecutionFlagsToIndexMap[c_iNumCustomActionExecutionStates] = {0, 3, 1, 4, 2};
  22. //
  23. // Enum for Connect Action Types
  24. //
  25. const int c_iNumCustomActionTypes = 9;
  26. enum CustomActionTypes
  27. {
  28. PREINIT = 0,
  29. PRECONNECT = 1,
  30. PREDIAL = 2,
  31. PRETUNNEL = 3,
  32. ONCONNECT = 4,
  33. ONINTCONNECT = 5,
  34. ONDISCONNECT = 6,
  35. ONCANCEL = 7,
  36. ONERROR = 8,
  37. ALL = -1
  38. };
  39. struct CustomActionListItem
  40. {
  41. TCHAR szDescription[MAX_PATH+1];
  42. TCHAR szProgram[MAX_PATH+1];
  43. TCHAR szFunctionName[MAX_PATH+1];
  44. LPTSTR pszParameters;
  45. BOOL bIncludeBinary;
  46. BOOL bBuiltInAction;
  47. BOOL bTempDescription;
  48. CustomActionTypes Type;
  49. DWORD dwFlags;
  50. CustomActionListItem* Next;
  51. };
  52. class CustomActionList
  53. {
  54. //
  55. // This enumerator class is used to enumerate
  56. // the data in the Custom Action List class.
  57. // This allows the enumerator to have access to
  58. // the private data of CustomActionList but
  59. // controls how the user of this class accesses
  60. // that data.
  61. //
  62. friend class CustomActionListEnumerator;
  63. private:
  64. //
  65. // Array of Linked lists to hold the custom actions
  66. //
  67. CustomActionListItem* m_CustomActionHash[c_iNumCustomActionTypes];
  68. //
  69. // Array of string pointers to hold the custom action type strings, plus
  70. // the special All type string pointer.
  71. //
  72. TCHAR* m_ActionTypeStrings[c_iNumCustomActionTypes];
  73. TCHAR* m_pszAllTypeString;
  74. //
  75. // Array of string pointers to hold the CMS section names for each type
  76. // of custom action. Note that these strings are const TCHAR* const and
  77. // shouldn't be free-ed.
  78. //
  79. TCHAR* m_ActionSectionStrings[c_iNumCustomActionTypes];
  80. //
  81. // Array of string pointers to hold the custom action execution state
  82. // strings. These are added to the combo box on the Add/Edit custom
  83. // action dialog to allow the user to pick when a custom action is
  84. // executed
  85. //
  86. TCHAR* m_ExecutionStrings[c_iNumCustomActionExecutionStates];
  87. //
  88. // Functions internal to the class
  89. //
  90. HRESULT ParseCustomActionString(LPTSTR pszStringToParse, CustomActionListItem* pCustomAction, TCHAR* pszShortServiceName);
  91. HRESULT Find(HINSTANCE hInstance, LPCTSTR pszDescription, CustomActionTypes Type, CustomActionListItem** ppItem, CustomActionListItem** ppFollower);
  92. HRESULT EnsureActionTypeStringsLoaded(HINSTANCE hInstance);
  93. BOOL IsCmDl(CustomActionListItem* pItem);
  94. public:
  95. CustomActionList();
  96. ~CustomActionList();
  97. HRESULT ReadCustomActionsFromCms(HINSTANCE hInstance, TCHAR* pszCmsFile, TCHAR* pszShortServiceName);
  98. HRESULT WriteCustomActionsToCms(TCHAR* pszCmsFile, TCHAR* pszShortServiceName, BOOL bUseTunneling);
  99. HRESULT Add(HINSTANCE hInstance, CustomActionListItem* pCustomAction, LPCTSTR pszShortServiceName);
  100. HRESULT Edit(HINSTANCE hInstance, CustomActionListItem* pOldCustomAction, CustomActionListItem* pNewCustomAction, LPCTSTR pszShortServiceName);
  101. HRESULT GetExistingActionData(HINSTANCE hInstance, LPCTSTR pszDescription, CustomActionTypes Type, CustomActionListItem** ppCustomAction);
  102. HRESULT Delete(HINSTANCE hInstance, TCHAR* pszDescription, CustomActionTypes Type);
  103. HRESULT MoveUp(HINSTANCE hInstance, TCHAR* pszDescription, CustomActionTypes Type);
  104. HRESULT MoveDown(HINSTANCE hInstance, TCHAR* pszDescription, CustomActionTypes Type);
  105. HRESULT AddCustomActionTypesToComboBox(HWND hDlg, UINT uCtrlId, HINSTANCE hInstance, BOOL bUseTunneling, BOOL bAddAll);
  106. HRESULT AddCustomActionsToListView(HWND hListView, HINSTANCE hInstance, CustomActionTypes Type, BOOL bUseTunneling, int iItemToSelect, BOOL bTypeInSecondCol);
  107. HRESULT GetTypeFromTypeString(HINSTANCE hInstance, TCHAR* pszTypeString, CustomActionTypes* pType);
  108. HRESULT GetTypeStringFromType(HINSTANCE hInstance, CustomActionTypes Type, TCHAR** ppszTypeString);
  109. HRESULT AddExecutionTypesToComboBox(HWND hDlg, UINT uCtrlId, HINSTANCE hInstance, BOOL bUseTunneling);
  110. HRESULT MapIndexToFlags(int iIndex, DWORD* pdwFlags);
  111. HRESULT MapFlagsToIndex(DWORD dwFlags, int* piIndex);
  112. HRESULT FillInTempDescription(CustomActionListItem* pCustomAction);
  113. HRESULT GetListPositionAndBuiltInState(HINSTANCE hInstance, CustomActionListItem* pItem, BOOL* pbFirstInList, BOOL* pbLastInList, BOOL *pIsBuiltIn);
  114. HRESULT AddOrRemoveCmdl(HINSTANCE hInstance, BOOL bAddCmdl, BOOL bForVpn);
  115. };
  116. class CustomActionListEnumerator
  117. {
  118. private:
  119. int m_iCurrentList;
  120. CustomActionListItem* m_pCurrentListItem;
  121. CustomActionList* m_pActionList;
  122. public:
  123. CustomActionListEnumerator(CustomActionList* pActionListToWorkFrom);
  124. // ~CustomActionListEnumerator(); // currently not needed
  125. void Reset();
  126. HRESULT GetNextIncludedProgram(TCHAR* pszProgram, DWORD dwBufferSize);
  127. };