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.

148 lines
4.5 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: ActList.h
  4. //
  5. // Module: CMDIAL32.DLL
  6. //
  7. // Synopsis: Define the two connect action list class
  8. // CAction and CActionList
  9. //
  10. // Copyright (c) 1997-1999 Microsoft Corporation
  11. //
  12. // Author: fengsun Created 11/14/97
  13. //
  14. //+----------------------------------------------------------------------------
  15. #include <windows.h>
  16. #include "cm_misc.h"
  17. #include "conact_str.h"
  18. #include "conact.h"
  19. //
  20. // Class used
  21. //
  22. class CIni;
  23. class CAction;
  24. struct _ArgsStruct;
  25. //+---------------------------------------------------------------------------
  26. //
  27. // class CActionList
  28. //
  29. // Description: A list of CAction objects
  30. //
  31. // History: fengsun Created 11/14/97
  32. //
  33. //----------------------------------------------------------------------------
  34. class CActionList
  35. {
  36. public:
  37. CActionList();
  38. ~CActionList();
  39. BOOL Append(const CIni* piniService, LPCTSTR pszSection);
  40. void RunAutoApp(HWND hwndDlg, _ArgsStruct *pArgs); // not check return value, add as watch process
  41. BOOL RunAccordType(HWND hwndDlg, _ArgsStruct *pArgs, BOOL fStatusMsgOnFailure = TRUE, BOOL fOnError = FALSE); //No watch process, Check connection type
  42. protected:
  43. BOOL Run(HWND hwndDlg, _ArgsStruct *pArgs, BOOL fAddWatch, BOOL fStatusMsgOnFailure, BOOL fOnError);
  44. //
  45. // Since we do not have a dynamic array class, here is the simple implementation
  46. //
  47. void Add(CAction* pAction);
  48. CAction * GetAt(UINT nIndex);
  49. UINT GetSize() {return m_nNum;}
  50. CAction ** m_pActionList; // This is a list of CAction*
  51. UINT m_nNum; // number of elements in pActionList
  52. UINT m_nSize; // The memory size of the m_pActionList
  53. LPCTSTR m_pszType; // "type" of the connect action (actually, the section name)
  54. enum {GROW_BY = 10}; // the dynamic array grow
  55. };
  56. //+---------------------------------------------------------------------------
  57. //
  58. // class CAction
  59. //
  60. // Description: A single action object
  61. //
  62. // History: fengsun Created 11/14/97
  63. //
  64. //----------------------------------------------------------------------------
  65. class CAction
  66. {
  67. public:
  68. CAction(LPTSTR lpCommandLine, UINT dwFlags, LPTSTR lpDescript = NULL);
  69. ~CAction();
  70. HANDLE RunAsExe(CShellDll* pShellDll) const;
  71. HANDLE RunAsExeFromSystem(CShellDll* pShellDll, LPTSTR pszDesktop, DWORD dwLoadType);
  72. BOOL RunAsDll(HWND hWndParent, OUT DWORD& dwReturnValue, DWORD dwLoadType) const;
  73. const TCHAR* GetDescription() const {return m_pszDescription;}
  74. const TCHAR* GetProgram() const {return m_pszProgram;}
  75. void ExpandMacros(_ArgsStruct *pArgs);
  76. BOOL IsDll() const { return m_fIsDll; }
  77. void ConvertRelativePath(const CIni *piniService);
  78. void ExpandEnvironmentStringsInCommand();
  79. void ExpandEnvironmentStringsInParams();
  80. BOOL IsAllowed(_ArgsStruct *pArgs, LPDWORD lpdwLoadType);
  81. BOOL RunConnectActionForCurrentConnection(_ArgsStruct *pArgs);
  82. BOOL HasUI() const { return ((m_dwFlags & NONINTERACTIVE) ? FALSE : TRUE); }
  83. protected:
  84. BOOL GetLoadDirWithAlloc(DWORD dwLoadType, LPWSTR * ppszwPath) const;
  85. void ParseCmdLine(LPTSTR pszCmdLine);
  86. void ExpandEnvironmentStrings(LPTSTR * ppsz);
  87. //
  88. // Flags for CAction
  89. //
  90. enum { ACTION_DIALUP = 0x00000001,
  91. ACTION_DIRECT = 0x00000002
  92. };
  93. BOOL m_fIsDll; // whether the action is a dll
  94. LPTSTR m_pszProgram; // The program name or the dll name
  95. LPTSTR m_pszParams; // The parameters of the program/dll
  96. LPTSTR m_pszFunction; // The function name of the dll
  97. LPTSTR m_pszDescription; // the description
  98. UINT m_dwFlags; // a bit ORed flag
  99. #ifdef DEBUG
  100. public:
  101. void AssertValid() const;
  102. #endif
  103. };
  104. inline void CActionList::RunAutoApp(HWND hwndDlg, _ArgsStruct *pArgs)
  105. {
  106. Run(hwndDlg, pArgs, TRUE, FALSE, FALSE); //fAddWatch = TRUE, fStatusMsgOnFailure = FALSE
  107. }
  108. inline void CAction::ConvertRelativePath(const CIni *piniService)
  109. {
  110. //
  111. // Convert the relative path to full path
  112. //
  113. LPTSTR pszTmp = ::CmConvertRelativePath(piniService->GetFile(), m_pszProgram);
  114. CmFree(m_pszProgram);
  115. m_pszProgram = pszTmp;
  116. }
  117. inline void CAction::ExpandEnvironmentStringsInCommand()
  118. {
  119. CAction::ExpandEnvironmentStrings(&m_pszProgram);
  120. }
  121. inline void CAction::ExpandEnvironmentStringsInParams()
  122. {
  123. CAction::ExpandEnvironmentStrings(&m_pszParams);
  124. }