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.

281 lines
6.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000
  6. //
  7. // File: cpaction.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __CONTROLPANEL_ACTION_H
  11. #define __CONTROLPANEL_ACTION_H
  12. #include "cputil.h"
  13. #include "cpnamespc.h"
  14. namespace CPL {
  15. //
  16. // Restriction function must return an HRESULT with the following semantics.
  17. //
  18. // S_FALSE - Action not restricted.
  19. // S_OK - Action restricted.
  20. // Failure - Cannot determine.
  21. //
  22. typedef HRESULT (*PFNRESTRICT)(ICplNamespace *pns);
  23. class IRestrict
  24. {
  25. public:
  26. virtual ~IRestrict(void) { }
  27. virtual HRESULT IsRestricted(ICplNamespace *pns) const = 0;
  28. };
  29. class CRestrictFunc : public IRestrict
  30. {
  31. public:
  32. CRestrictFunc(PFNRESTRICT pfnRestrict)
  33. : m_pfnRestrict(pfnRestrict) { }
  34. HRESULT IsRestricted(ICplNamespace *pns) const
  35. { return (*m_pfnRestrict)(pns); }
  36. private:
  37. PFNRESTRICT m_pfnRestrict;
  38. };
  39. class CRestrictApplet : public IRestrict
  40. {
  41. public:
  42. CRestrictApplet(LPCWSTR pszFile, LPCWSTR pszApplet)
  43. : m_pszFile(pszFile),
  44. m_pszApplet(pszApplet) { }
  45. HRESULT IsRestricted(ICplNamespace *pns) const;
  46. private:
  47. LPCWSTR m_pszFile;
  48. LPCWSTR m_pszApplet;
  49. };
  50. //
  51. // Class IAction abstractly represents an action to perform.
  52. //
  53. // The intent is to associate an action object with a particular link
  54. // object in the Control Panel UI. This decoupling makes it easy to
  55. // change the action associated with a link. It also allows us to
  56. // easily associate an action with multiple links as well as a
  57. // 'restriction' with a particular action. As a result of this
  58. // Link->Action->Restriction relationship, we can hide a link if it's
  59. // action is restricted. The link needs to know only about the
  60. // action and nothing about the restriction.
  61. //
  62. class IAction
  63. {
  64. public:
  65. virtual HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const = 0;
  66. virtual HRESULT IsRestricted(ICplNamespace *pns) const = 0;
  67. };
  68. class CAction : public IAction
  69. {
  70. public:
  71. CAction(const IRestrict *pRestrict = NULL);
  72. HRESULT IsRestricted(ICplNamespace *pns) const;
  73. private:
  74. const IRestrict *m_pRestrict;
  75. };
  76. class COpenCplCategory : public CAction
  77. {
  78. public:
  79. explicit COpenCplCategory(eCPCAT eCategory, const IRestrict *pRestrict = NULL);
  80. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  81. private:
  82. eCPCAT m_eCategory;
  83. };
  84. //
  85. // This class is similar to COpenCplCategory except that it first checks to see if
  86. // the category has only one CPL applet and no tasks. If this is the case,
  87. // the action is automatically forwarded to the single CPL applet. The initial
  88. // requirement for this is to support the addition of keymgr.cpl to the "User Accounts"
  89. // category, however keymgr may not be present on all SKUs. Therefore, when keymgr
  90. // is present, we will display the category page containing both the User Accounts CPL
  91. // and the KeyMgr CPL. If User Accounts CPL is the only CPL in this category, we simply
  92. // launch it.
  93. //
  94. class COpenCplCategory2 : public CAction
  95. {
  96. public:
  97. explicit COpenCplCategory2(eCPCAT eCategory, const IAction *pDefAction, const IRestrict *pRestrict = NULL);
  98. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  99. private:
  100. eCPCAT m_eCategory;
  101. const IAction *m_pDefAction;
  102. HRESULT _ExecuteActionOnSingleCplApplet(HWND hwndParent, IUnknown *punkSite, bool *pbOpenCategory) const;
  103. };
  104. class COpenUserMgrApplet : public CAction
  105. {
  106. public:
  107. explicit COpenUserMgrApplet(const IRestrict *pRestrict = NULL);
  108. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  109. };
  110. class COpenCplApplet : public CAction
  111. {
  112. public:
  113. explicit COpenCplApplet(LPCWSTR pszApplet, const IRestrict *pRestrict = NULL);
  114. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  115. private:
  116. LPCWSTR m_pszApplet;
  117. };
  118. class COpenDeskCpl : public CAction
  119. {
  120. public:
  121. explicit COpenDeskCpl(eDESKCPLTAB eCplTab, const IRestrict *pRestrict = NULL);
  122. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  123. private:
  124. eDESKCPLTAB m_eCplTab;
  125. };
  126. class CShellExecute : public CAction
  127. {
  128. public:
  129. explicit CShellExecute(LPCWSTR pszExe, LPCWSTR pszArgs = NULL, const IRestrict *pRestrict = NULL);
  130. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  131. private:
  132. LPCWSTR m_pszExe;
  133. LPCWSTR m_pszArgs;
  134. };
  135. class CRunDll32 : public CAction
  136. {
  137. public:
  138. explicit CRunDll32(LPCWSTR pszArgs, const IRestrict *pRestrict = NULL);
  139. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  140. private:
  141. LPCWSTR m_pszArgs;
  142. };
  143. enum eDISKUTILS {
  144. eDISKUTIL_BACKUP,
  145. eDISKUTIL_DEFRAG,
  146. eDISKUTIL_CLEANUP,
  147. eDISKUTIL_NUMUTILS
  148. };
  149. class CExecDiskUtil : public CAction
  150. {
  151. public:
  152. explicit CExecDiskUtil(eDISKUTILS util, const IRestrict *pRestrict = NULL);
  153. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  154. private:
  155. eDISKUTILS m_eUtil;
  156. static HRESULT _RemoveDriveLetterFmtSpec(LPTSTR pszCmdLine);
  157. };
  158. class CNavigateURL : public CAction
  159. {
  160. public:
  161. explicit CNavigateURL(LPCWSTR pszURL, const IRestrict *pRestrict = NULL);
  162. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  163. private:
  164. LPCWSTR m_pszURL;
  165. };
  166. class COpenTroubleshooter : public CAction
  167. {
  168. public:
  169. explicit COpenTroubleshooter(LPCWSTR pszTs, const IRestrict *pRestrict = NULL);
  170. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  171. private:
  172. LPCWSTR m_pszTs;
  173. };
  174. class COpenCplView : public CAction
  175. {
  176. public:
  177. explicit COpenCplView(eCPVIEWTYPE eViewType, const IRestrict *pRestrict = NULL);
  178. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  179. private:
  180. eCPVIEWTYPE m_eViewType;
  181. HRESULT _SetFolderBarricadeStatus(void) const;
  182. };
  183. class CTrayCommand : public CAction
  184. {
  185. public:
  186. explicit CTrayCommand(UINT idm, const IRestrict *pRestrict = NULL);
  187. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  188. private:
  189. UINT m_idm;
  190. };
  191. class CAddPrinter : public CAction
  192. {
  193. public:
  194. explicit CAddPrinter(const IRestrict *pRestrict = NULL);
  195. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  196. };
  197. class CActionNYI : public CAction
  198. {
  199. public:
  200. explicit CActionNYI(LPCWSTR pszText);
  201. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  202. private:
  203. LPCWSTR m_pszText;
  204. };
  205. } // namespace CPL
  206. #endif // __CONTROLPANEL_ACTION_H