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.

304 lines
7.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. protected:
  116. LPCWSTR m_pszApplet;
  117. };
  118. //
  119. // Minor extension of COpenCplApplet that assumes the applet is in
  120. // %SystemRoot%\System32 directory.
  121. //
  122. class COpenCplAppletSysDir : public COpenCplApplet
  123. {
  124. public:
  125. explicit COpenCplAppletSysDir(LPCWSTR pszApplet, const IRestrict *pRestrict = NULL);
  126. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  127. };
  128. class COpenDeskCpl : public CAction
  129. {
  130. public:
  131. explicit COpenDeskCpl(eDESKCPLTAB eCplTab, const IRestrict *pRestrict = NULL);
  132. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  133. private:
  134. eDESKCPLTAB m_eCplTab;
  135. };
  136. class CShellExecute : public CAction
  137. {
  138. public:
  139. explicit CShellExecute(LPCWSTR pszExe, LPCWSTR pszArgs = NULL, const IRestrict *pRestrict = NULL);
  140. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  141. protected:
  142. LPCWSTR m_pszExe;
  143. LPCWSTR m_pszArgs;
  144. };
  145. //
  146. // Minor extension of CShellExecute that assumes the EXE is in
  147. // %SystemRoot%\System32 directory.
  148. //
  149. class CShellExecuteSysDir : public CShellExecute
  150. {
  151. public:
  152. explicit CShellExecuteSysDir(LPCWSTR pszExe, LPCWSTR pszArgs = NULL, const IRestrict *pRestrict = NULL);
  153. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  154. };
  155. class CRunDll32 : public CAction
  156. {
  157. public:
  158. explicit CRunDll32(LPCWSTR pszArgs, const IRestrict *pRestrict = NULL);
  159. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  160. private:
  161. LPCWSTR m_pszArgs;
  162. };
  163. enum eDISKUTILS {
  164. eDISKUTIL_BACKUP,
  165. eDISKUTIL_DEFRAG,
  166. eDISKUTIL_CLEANUP,
  167. eDISKUTIL_NUMUTILS
  168. };
  169. class CExecDiskUtil : public CAction
  170. {
  171. public:
  172. explicit CExecDiskUtil(eDISKUTILS util, const IRestrict *pRestrict = NULL);
  173. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  174. private:
  175. eDISKUTILS m_eUtil;
  176. static HRESULT _RemoveDriveLetterFmtSpec(LPTSTR pszCmdLine);
  177. };
  178. class CNavigateURL : public CAction
  179. {
  180. public:
  181. explicit CNavigateURL(LPCWSTR pszURL, const IRestrict *pRestrict = NULL);
  182. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  183. private:
  184. LPCWSTR m_pszURL;
  185. };
  186. class COpenTroubleshooter : public CAction
  187. {
  188. public:
  189. explicit COpenTroubleshooter(LPCWSTR pszTs, const IRestrict *pRestrict = NULL);
  190. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  191. private:
  192. LPCWSTR m_pszTs;
  193. };
  194. class COpenCplView : public CAction
  195. {
  196. public:
  197. explicit COpenCplView(eCPVIEWTYPE eViewType, const IRestrict *pRestrict = NULL);
  198. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  199. private:
  200. eCPVIEWTYPE m_eViewType;
  201. HRESULT _SetFolderBarricadeStatus(void) const;
  202. };
  203. class CTrayCommand : public CAction
  204. {
  205. public:
  206. explicit CTrayCommand(UINT idm, const IRestrict *pRestrict = NULL);
  207. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  208. private:
  209. UINT m_idm;
  210. };
  211. class CAddPrinter : public CAction
  212. {
  213. public:
  214. explicit CAddPrinter(const IRestrict *pRestrict = NULL);
  215. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  216. };
  217. class CActionNYI : public CAction
  218. {
  219. public:
  220. explicit CActionNYI(LPCWSTR pszText);
  221. HRESULT Execute(HWND hwndParent, IUnknown *punkSite) const;
  222. private:
  223. LPCWSTR m_pszText;
  224. };
  225. } // namespace CPL
  226. #endif // __CONTROLPANEL_ACTION_H