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.

288 lines
13 KiB

  1. #ifndef _DESKSTAT_H_
  2. #define _DESKSTAT_H_
  3. #include "mshtml.h"
  4. // NOTE: This is NOT a IE4COMPONENTA struct, it is a IE4COMPONENTT struct.
  5. // Note: This is the old COMPONENTA structure used in IE4. It is kept here for compatibility.
  6. typedef struct _tagIE4COMPONENTA
  7. {
  8. DWORD dwSize;
  9. DWORD dwID; //Don't make this DWORD_PTR. The public version of this struct uses DWORD here.
  10. int iComponentType;
  11. BOOL fChecked;
  12. BOOL fDirty;
  13. BOOL fNoScroll;
  14. COMPPOS cpPos;
  15. TCHAR szFriendlyName[MAX_PATH];
  16. TCHAR szSource[INTERNET_MAX_URL_LENGTH];
  17. TCHAR szSubscribedURL[INTERNET_MAX_URL_LENGTH];
  18. } IE4COMPONENTA;
  19. typedef IE4COMPONENTA *LPIE4COMPONENTA;
  20. typedef const IE4COMPONENTA *LPCIE4COMPONENTA;
  21. // NOTE: This is NOT a COMPONENTA struct, it is a COMPONENTT struct.
  22. // Note: This is the new NT5 COMPONENT structure. The old component structure is kept at the
  23. // begining of this struct and the new fields are added at the end. The dwSize field is used to
  24. // distinguish between the old and new structures.
  25. //
  26. typedef struct _tagCOMPONENTA
  27. {
  28. DWORD dwSize;
  29. DWORD dwID; //Don't make this DWORD_PTR. The public version of this struct uses DWORD here.
  30. int iComponentType;
  31. BOOL fChecked;
  32. BOOL fDirty;
  33. BOOL fNoScroll;
  34. COMPPOS cpPos;
  35. TCHAR szFriendlyName[MAX_PATH];
  36. TCHAR szSource[INTERNET_MAX_URL_LENGTH];
  37. TCHAR szSubscribedURL[INTERNET_MAX_URL_LENGTH];
  38. // Add the new fields below this point. Everything above must exactly match the
  39. // old IE4COMPONENTA structure for compatibility.
  40. DWORD dwCurItemState;
  41. COMPSTATEINFO csiOriginal;
  42. COMPSTATEINFO csiRestored;
  43. } COMPONENTA;
  44. typedef COMPONENTA *LPCOMPONENTA;
  45. typedef const COMPONENTA *LPCCOMPONENTA;
  46. typedef struct _tagTAGENTRYA
  47. {
  48. LPCSTR pszTag;
  49. BOOL fSkipPast;
  50. } TAGENTRYA;
  51. typedef struct _tagTAGENTRYW
  52. {
  53. LPCWSTR pwszTag;
  54. BOOL fSkipPast;
  55. } TAGENTRYW;
  56. #define c_wszNULL (L"")
  57. //The following are the possible values for _iCharset field of CReadFileObj
  58. #define ANSI_HTML_CHARSET 1
  59. #define UNICODE_HTML_CHARSET 2
  60. //
  61. // The following class implements a uniform way to read chars from an ANSI or UNICODE file.
  62. //
  63. class CReadFileObj
  64. {
  65. friend class CActiveDesktop;
  66. private:
  67. HANDLE _hFile; //File handle
  68. int _iCharset; //ANSI_HTML_CHARSET or UNICODE_HTML_CHARSET
  69. public:
  70. //Constructor
  71. CReadFileObj(LPCTSTR lpszFileName);
  72. //Destructor
  73. ~CReadFileObj();
  74. //Reads the given number of ansi characters, if an ansi file.
  75. HRESULT FileReadCharsA(LPSTR lpszBuff, UINT uiCharsToRead, UINT *puiCharsActuallyRead);
  76. //Reads the given number of UNICODE characters, if a UNICODE file.
  77. HRESULT FileReadCharsW(LPWSTR lpwszBuff, UINT uiCharsToRead, UINT *puiCharsActuallyRead);
  78. //Reads the given number of characters, and convert them if necessary to ANSI or UNICODE based on destCharset.
  79. HRESULT FileReadAndConvertChars(int iDestCharset, LPWSTR lpwszBuff, UINT uiCharsToRead, UINT *puiCharsActuallyRead, UINT *puiCharsConverted);
  80. //Seeks to a given character offset (not byte offset).
  81. HRESULT FileSeekChars(LONG lCharOffset, DWORD dwOrigin);
  82. //Gets the offset of the current file pointer from the begining of the file.
  83. HRESULT FileGetCurCharOffset(LONG *plCharOffset);
  84. };
  85. interface IShellImageDataFactory;
  86. class CActiveDesktop : public IActiveDesktop, IActiveDesktopP, IADesktopP2, IPropertyBag
  87. {
  88. public:
  89. // *** IUnknown ***
  90. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);
  91. virtual STDMETHODIMP_(ULONG) AddRef(void);
  92. virtual STDMETHODIMP_(ULONG) Release(void);
  93. // *** IActiveDesktop ***
  94. virtual STDMETHODIMP ApplyChanges(DWORD dwFlags);
  95. virtual STDMETHODIMP GetWallpaper(LPWSTR pwszWallpaper, UINT cchWallpaper, DWORD dwReserved);
  96. virtual STDMETHODIMP SetWallpaper(LPCWSTR pwszWallpaper, DWORD dwReserved);
  97. virtual STDMETHODIMP GetWallpaperOptions(LPWALLPAPEROPT pwpo, DWORD dwReserved);
  98. virtual STDMETHODIMP SetWallpaperOptions(LPCWALLPAPEROPT pwpo, DWORD dwReserved);
  99. virtual STDMETHODIMP GetPattern(LPWSTR pwszPattern, UINT cchPattern, DWORD dwReserved);
  100. virtual STDMETHODIMP SetPattern(LPCWSTR pszPattern, DWORD dwReserved);
  101. virtual STDMETHODIMP GetDesktopItemOptions(LPCOMPONENTSOPT pco, DWORD dwReserved);
  102. virtual STDMETHODIMP SetDesktopItemOptions(LPCCOMPONENTSOPT pco, DWORD dwReserved);
  103. virtual STDMETHODIMP AddDesktopItem(LPCCOMPONENT pcomp, DWORD dwReserved);
  104. virtual STDMETHODIMP AddDesktopItemWithUI(HWND hwnd, LPCOMPONENT pcomp, DWORD dwReserved);
  105. virtual STDMETHODIMP ModifyDesktopItem(LPCCOMPONENT pcomp, DWORD dwFlags);
  106. virtual STDMETHODIMP RemoveDesktopItem(LPCCOMPONENT pcomp, DWORD dwReserved);
  107. virtual STDMETHODIMP GetDesktopItemCount(LPINT lpiCount, DWORD dwReserved);
  108. virtual STDMETHODIMP GetDesktopItem(int nComponent, LPCOMPONENT pcomp, DWORD dwReserved);
  109. virtual STDMETHODIMP GetDesktopItemByID(ULONG_PTR dwID, LPCOMPONENT pcomp, DWORD dwReserved);
  110. virtual STDMETHODIMP GenerateDesktopItemHtml(LPCWSTR pwszFileName, LPCOMPONENT pcomp, DWORD dwReserved);
  111. virtual STDMETHODIMP AddUrl(HWND hwnd, LPCWSTR pszSource, LPCOMPONENT pcomp, DWORD dwFlags);
  112. virtual STDMETHODIMP GetDesktopItemBySource(LPCWSTR pszSource, LPCOMPONENT pcomp, DWORD dwReserved);
  113. // *** IActiveDesktopP ***
  114. virtual STDMETHODIMP SetSafeMode(DWORD dwFlags);
  115. virtual STDMETHODIMP EnsureUpdateHTML(void);
  116. virtual STDMETHODIMP SetScheme(LPCWSTR pwszSchemeName, DWORD dwFlags);
  117. virtual STDMETHODIMP GetScheme(LPWSTR pwszSchemeName, LPDWORD lpdwcchBuffer, DWORD dwFlags);
  118. // *** IADesktopP2 ***
  119. virtual STDMETHODIMP ReReadWallpaper(void);
  120. virtual STDMETHODIMP GetADObjectFlags(LPDWORD lpdwFlags, DWORD dwMask);
  121. virtual STDMETHODIMP UpdateAllDesktopSubscriptions();
  122. virtual STDMETHODIMP MakeDynamicChanges(IOleObject *pOleObj);
  123. // *** IPropertyBag ***
  124. virtual STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog);
  125. virtual STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar);
  126. //Some Ansi versions of the methods for Internal Use
  127. BOOL AddComponentPrivate(COMPONENTA *pcomp, DWORD dwID);
  128. BOOL UpdateComponentPrivate(int iIndex, COMPONENTA *pcomp);
  129. BOOL RemoveComponentPrivate(int iIndex, COMPONENTA *pcomp);
  130. BOOL GetComponentPrivate(int nComponent, COMPONENTA *pcomp);
  131. CActiveDesktop();
  132. protected:
  133. DWORD _cRef;
  134. DWORD _dwNextID;
  135. HDSA _hdsaComponent;
  136. TCHAR _szSelectedWallpaper[MAX_PATH];
  137. TCHAR _szSelectedWallpaperConverted[MAX_PATH];
  138. TCHAR _szBackupWallpaper[MAX_PATH];
  139. TCHAR _szSelectedPattern[MAX_PATH];
  140. LPTSTR _pszScheme;
  141. WALLPAPEROPT _wpo;
  142. COMPONENTSOPT _co;
  143. HANDLE _hFileHtml; //File handle of desktop.htt
  144. CReadFileObj* _pReadFileObjHtmlBkgd; //Object used to read the background html wallpaper
  145. int _iDestFileCharset; //Whether the dest file desktop.htt is ANSI or UNICODE.
  146. // used for the temp wallpaper
  147. LPWSTR _pszWallpaperInUse; // If using a temp file, keep the name in use so we don't stomp it while the user is previewing other files.
  148. FILETIME _ftLastWrite; // The date that the original file was last written to.
  149. LPTSTR _pszOrigLastApplied; // Same as _pszOriginalFile except it doesn't change until apply is pressed.
  150. // put the BOOLs together
  151. BOOL _fDirty;
  152. BOOL _fWallpaperDirty;
  153. BOOL _fWallpaperChangedDuringInit;
  154. BOOL _fPatternDirty;
  155. BOOL _fSingleItem;
  156. BOOL _fInitialized;
  157. BOOL _fNeedBodyEnd;
  158. BOOL _fNoDeskMovr;
  159. BOOL _fBackgroundHtml;
  160. IStream *_pStream; //To generate individual components.
  161. BOOL _fUseDynamicHtml; //Indicates if Dynamic Html can be used to make changes.
  162. BOOL _fPolicyForWPName; // A policy exists for the wallpaper to be used.
  163. BOOL _fPolicyForWPStyle; // A policy exists for the wallpaper style to be used.
  164. BOOL _fIgnoreAddRemovePolicies; //If this is set, ignore the policy to add remove items.
  165. ~CActiveDesktop();
  166. int _FindComponentIndexByID(DWORD dwID);
  167. int _FindComponentBySource(LPTSTR lpszSource, COMPONENTA *pComp);
  168. int _FindComponentBySrcUrl(LPTSTR lpszSrcUrl, COMPONENTA *pComp);
  169. void _ReadComponent(HKEY hkey, LPCTSTR pszComp);
  170. void _SortAndRationalize(void);
  171. void _ReadComponents(BOOL fActiveDesktop);
  172. BOOL _ReadWallpaper(BOOL fActiveDesktop);
  173. void _ReadPattern(void);
  174. void _Initialize(void);
  175. void _SaveComponent(HKEY hkey, int iIndex, COMPONENTA *pcomp);
  176. void _SaveComponents(void);
  177. void _SaveWallpaper(void);
  178. void _SavePattern(DWORD dwFlags);
  179. void _SaveSettings(DWORD dwFlags);
  180. void _GenerateHtmlHeader(void);
  181. void _GenerateHtmlPicture(COMPONENTA *pcomp);
  182. void _GenerateHtmlDoc(COMPONENTA *pcomp);
  183. void _GenerateHtmlSite(COMPONENTA *pcomp);
  184. void _GenerateHtmlControl(COMPONENTA *pcomp);
  185. void _GenerateHtmlComponent(COMPONENTA *pcomp);
  186. void _GenerateHtmlFooter(void);
  187. void _GenerateHtml(void);
  188. void _WriteHtmlFromString(LPCTSTR psz);
  189. void _WriteHtmlFromId(UINT uid);
  190. void _WriteHtmlFromIdF(UINT uid, ...);
  191. void _WriteHtmlFromFile(LPCTSTR pszContents);
  192. void _WriteHtmlFromReadFileObj(CReadFileObj *pReadFileObj, int iOffsetStart, int iOffsetEnd);
  193. void _WriteResizeable(COMPONENTA *pcomp);
  194. void _WriteHtmlW(LPCWSTR pwstr, UINT cchToWrite, UINT *pcchWritten);
  195. int _ScanTagEntriesA(CReadFileObj *pReadFileObj, int iOffsetStart, TAGENTRYA *pte, int cte);
  196. int _ScanTagEntriesW(CReadFileObj *pReadFileObj, int iOffsetStart, TAGENTRYW *pte, int cte);
  197. int _ScanForTagA(CReadFileObj *pReadFileObj, int iOffsetStart, LPCSTR pwszTag);
  198. int _ScanForTagW(CReadFileObj *pReadFileObj, int iOffsetStart, LPCWSTR pwszTag);
  199. void _ParseAnsiInputHtmlFile(LPTSTR szSelectedWallpaper, int *piOffsetBase, int *piOffsetComp);
  200. HRESULT _CopyComponent(COMPONENTA *pCompDest, COMPONENTA *pCompSrc, DWORD dwFlags);
  201. HRESULT _ConvertFileToTempBitmap(IN LPWSTR pszFile, IN int cchSize);
  202. HRESULT _SaveTempWallpaperSettings(void);
  203. private:
  204. HRESULT _AddDTIWithUIPrivateA(HWND hwnd, LPCCOMPONENT pComp, DWORD dwFlags);
  205. BOOL _IsDisplayInSafeMode(void);
  206. // The following are used for manipulating ActiveDesktop using Dynamic HTML.
  207. HRESULT _InsertNewDesktopItems(IHTMLDocument2 *pDoc);
  208. HRESULT _UpdateDesktopItemHtmlElements(IHTMLDocument2 *pDoc);
  209. HRESULT _UpdateHtmlElement(IHTMLElement *pElem);
  210. BOOL _UpdateIdOfElement(IHTMLElement *pElem, LPCOMPONENTA lpCompA);
  211. void _UpdateStyleOfElement(IHTMLElement *pElem, LPCOMPONENTA lpCompA);
  212. void _GenerateHtmlBStrForComp(COMPONENTA *pComp, BSTR *pbstr);
  213. };
  214. extern IActiveDesktop *g_pActiveDesk;
  215. int GetIntFromSubkey(HKEY hKey, LPCTSTR lpszValueName, int iDefault);
  216. int GetIntFromReg(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszNameValue, int iDefault);
  217. BOOL GetStringFromReg(HKEY hkey, LPCTSTR lpszSubkey, LPCTSTR lpszValueName, LPTSTR lpszValue, DWORD cchSizeofValueBuff);
  218. STDAPI CActiveDesktop_InternalCreateInstance(LPUNKNOWN * ppunk, REFIID riid);
  219. HRESULT GetPerUserFileName(LPTSTR pszOutputFileName, DWORD dwSize, LPTSTR pszPartialFileName);
  220. STDAPI CDeskHtmlProp_RegUnReg(BOOL bReg);
  221. //Function to convert components in either direction.
  222. void ConvertCompStruct(COMPONENTA *pCompDest, COMPONENTA *pCompSrc, BOOL fPubToPriv);
  223. void SetStateInfo(COMPSTATEINFO *pCompStateInfo, COMPPOS *pCompPos, DWORD dwItemState);
  224. #define MultiCompToWideComp(MultiComp, WideComp) ConvertCompStruct((COMPONENTA *)WideComp, MultiComp, FALSE)
  225. #define WideCompToMultiComp(WideComp, MultiComp) ConvertCompStruct(MultiComp, (COMPONENTA *)WideComp, TRUE)
  226. #define COMPONENT_TOP_WINDOWLESS (COMPONENT_TOP / 2)
  227. #define IsWindowLessComponent(pcomp) (((pcomp)->iComponentType == COMP_TYPE_PICTURE) || ((pcomp)->iComponentType == COMP_TYPE_HTMLDOC))
  228. #define COMPONENT_DEFAULT_WIDTH ((DWORD)-1)
  229. #define COMPONENT_DEFAULT_HEIGHT ((DWORD)-1)
  230. #define DESKMOVR_FILENAME TEXT("\\Web\\DeskMovr.htt")
  231. #define DESKTOPHTML_FILENAME TEXT("\\Microsoft\\Internet Explorer\\Desktop.htt")
  232. #define PATTERN_FILENAME TEXT("\\Microsoft\\Internet Explorer\\Pattern.bmp")
  233. #define SAVE_PATTERN_NAME 0x00000001
  234. #define GENERATE_PATTERN_FILE 0x00000002
  235. //Property names
  236. #define c_wszPropName_TSPerfBGPolicy L"TSConnectEvent"
  237. #define c_wszPropName_IgnorePolicies L"IgnorePolicies"
  238. #define SZ_REGKEY_ACTDESKTOP_TSPERFPOLICY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Remote")
  239. #define SZ_REGVALUE_ACTDESKTOP_TSPERFPOLICY TEXT("ActiveDesktop")
  240. #define SZ_REGVDATE_ACTDESKTOP_TSPERFPOLICY TEXT("Force Blank")
  241. #define REGSTR_PATH_WP_POLICY REGSTR_PATH_POLICIES TEXT("\\") REGSTR_KEY_SYSTEM
  242. BOOL ReadPolicyForWallpaper(LPTSTR lpszPolicyForWallpaper, DWORD dwSizeofBuff);
  243. BOOL ReadPolicyForWPStyle(LPDWORD lpdwStyle);
  244. #endif // _DESKSTAT_H_