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.

243 lines
8.7 KiB

  1. #ifndef _TRAYREG_H
  2. #define _TRAYREG_H
  3. #include "dpa.h"
  4. #define SZ_TRAYNOTIFY_REGKEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\TrayNotify")
  5. #define SZ_EXPLORER_REGKEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer")
  6. #define SZ_AUTOTRAY_REGVALUE TEXT("EnableAutoTray")
  7. #define SZ_ITEMSTREAMS_REGVALUE TEXT("IconStreams")
  8. #define SZ_ICONSTREAMS_REGVALUE TEXT("PastIconsStream")
  9. #define SZ_INFOTIP_REGVALUE TEXT("BalloonTip")
  10. #define SZ_ICON_COUNTDOWN_VALUE TEXT("TrayIconResidentInterval")
  11. #define SZ_ICONCLEANUP_VALUE TEXT("Icon Cleanup Time")
  12. #define SZ_ICONDEMOTE_TIMER_TICK_VALUE TEXT("IconDemoteTimerTick")
  13. #define SZ_INFOTIP_TIMER_TICK_VALUE TEXT("InfoTipTimerTick")
  14. // Parameters to control the aging algorithm
  15. #ifdef FULL_DEBUG
  16. #define TT_ICON_COUNTDOWN_INTERVAL 15000
  17. #else
  18. #define TT_ICON_COUNTDOWN_INTERVAL 3600000 // 1 hour
  19. #endif
  20. #define TT_ICONCLEANUP_INTERVAL 6 // 6 months
  21. #define TT_ICON_COUNTDOWN_INCREMENT 8*60*60*1000 // 8 hours
  22. // Show the Chevron info tip 5 times, once per session for the first 5 sessions, or
  23. // until the user clicks on the balloon, whichever comes first.
  24. #define MAX_CHEVRON_INFOTIP_SHOWN 5
  25. // Flags decide which user tracking timer to use - the balloon tips or the icons
  26. #define TF_ICONDEMOTE_TIMER 1
  27. #define TF_INFOTIP_TIMER 2
  28. // What is the timer interval for the UserEventTimer for each of the timer cases ?
  29. // Once every 5 minutes, for the tray items...
  30. #define UET_ICONDEMOTE_TIMER_TICK_INTERVAL 300000
  31. // Once every 5 seconds, for balloon tips...
  32. #define UET_INFOTIP_TIMER_TICK_INTERVAL 5000
  33. //
  34. // header for persistent streams storing the tray notify info
  35. //
  36. typedef struct tagTNPersistStreamHeader
  37. {
  38. DWORD dwSize; // Size of the header structure..
  39. DWORD dwVersion; // Version number for the header
  40. DWORD dwSignature; // Signature to identify this version of the header
  41. DWORD cIcons; // Number of Icons that have been stored in the stream
  42. DWORD dwOffset; // Offset to the start of the first icondata in the stream
  43. } TNPersistStreamHeader;
  44. #define INVALID_IMAGE_INDEX -1
  45. typedef struct tagTNPersistStreamData
  46. {
  47. TCHAR szExeName[MAX_PATH];
  48. UINT uID;
  49. BOOL bDemoted;
  50. DWORD dwUserPref;
  51. WORD wYear;
  52. WORD wMonth;
  53. TCHAR szIconText[MAX_PATH];
  54. UINT uNumSeconds;
  55. BOOL bStartupIcon;
  56. INT nImageIndex; // Index of the image in the Past Items image list.
  57. GUID guidItem;
  58. } TNPersistStreamData;
  59. typedef struct tagTNPersistentIconStreamHeader
  60. {
  61. DWORD dwSize; // Size of the header structure
  62. DWORD dwVersion; // Version number of the header
  63. DWORD dwSignature; // This signature must be the same as TNPersistStreamHeader.dwSignature
  64. DWORD cIcons; // Number of icons stored in the stream
  65. DWORD dwOffset; // Offset into the first item in the stream
  66. } TNPersistentIconStreamHeader;
  67. #define TNH_VERSION_ONE 1
  68. #define TNH_VERSION_TWO 2
  69. #define TNH_VERSION_THREE 3
  70. #define TNH_VERSION_FOUR 4
  71. #define TNH_VERSION_FIVE 5
  72. #define TNH_SIGNATURE 0x00010001
  73. class CNotificationItem;
  74. class CTrayItem;
  75. // Any client asking the TrayNotify class for an item passes these flags as one of the
  76. // parameters to the callback functions...
  77. typedef enum TRAYCBARG
  78. {
  79. TRAYCBARG_PTI,
  80. TRAYCBARG_HICON,
  81. TRAYCBARG_ALL
  82. } TRAYCBARG;
  83. typedef struct TRAYCBRET
  84. {
  85. CTrayItem * pti;
  86. HICON hIcon;
  87. } TRAYCBRET;
  88. typedef BOOL (CALLBACK * PFNTRAYNOTIFYCALLBACK)(INT_PTR nIndex, void *pCallbackData,
  89. TRAYCBARG trayCallbackArg, TRAYCBRET *pOutData);
  90. class CTrayItemRegistry
  91. {
  92. public:
  93. CTrayItemRegistry() : _himlPastItemsIconList(NULL) { }
  94. ~CTrayItemRegistry() { }
  95. void InitRegistryValues(UINT uIconListFlags);
  96. void InitTrayItemStream(DWORD dwStreamMode, PFNTRAYNOTIFYCALLBACK pfnTrayNotifyCB, void *pCBData);
  97. BOOL GetTrayItem(INT_PTR nIndex, CNotificationItem * pni, BOOL * pbStat);
  98. BOOL AddToPastItems(CTrayItem * pti, HICON hIcon);
  99. void IncChevronInfoTipShownInRegistry(BOOL bUserClickedInfoTip = FALSE);
  100. BOOL SetIsAutoTrayEnabledInRegistry(BOOL bAutoTray);
  101. BOOL SetPastItemPreference(LPNOTIFYITEM pNotifyItem);
  102. INT_PTR CheckAndRestorePersistentIconSettings(CTrayItem *pti, LPTSTR pszIconToolTip, HICON hIcon);
  103. void DeletePastItem(INT_PTR nIndex);
  104. int DoesIconExistFromPreviousSession(CTrayItem * pti, LPTSTR pszIconToolTip, HICON hIcon);
  105. void Delete()
  106. {
  107. _dpaPersistentItemInfo.DestroyCallback(_DestroyIconInfoCB, NULL);
  108. _DestroyPastItemsIconList();
  109. }
  110. int _AddPastIcon(int nImageIndex, HICON hIcon)
  111. {
  112. if (_himlPastItemsIconList && hIcon)
  113. return ImageList_ReplaceIcon(_himlPastItemsIconList, nImageIndex, hIcon);
  114. return INVALID_IMAGE_INDEX;
  115. }
  116. UINT GetTimerTickInterval(int nTimerFlag);
  117. public:
  118. BOOL ShouldChevronInfoTipBeShown()
  119. {
  120. return _bShowChevronInfoTip;
  121. }
  122. // Is the "Auto" tray been disabled by policy ?
  123. BOOL IsNoAutoTrayPolicyEnabled() const
  124. {
  125. return _fNoAutoTrayPolicyEnabled;
  126. }
  127. // If not, has the user turned off the "auto" tray policy ?
  128. BOOL IsAutoTrayEnabledByUser() const
  129. {
  130. return _fAutoTrayEnabledByUser;
  131. }
  132. BOOL IsAutoTrayEnabled()
  133. {
  134. return (!_fNoAutoTrayPolicyEnabled && _fAutoTrayEnabledByUser);
  135. }
  136. public:
  137. ULONG _uPrimaryCountdown;
  138. private:
  139. static int _DestroyIconInfoCB(TNPersistStreamData * pData, LPVOID pData2);
  140. HRESULT _LoadTrayItemStream(IStream *pstm, PFNTRAYNOTIFYCALLBACK pfnTrayNotifyCB, void *pCBData);
  141. HRESULT _SaveTrayItemStream(IStream *pstm, PFNTRAYNOTIFYCALLBACK pfnTrayNotifyCB, void *pCBData);
  142. BOOL _FillPersistData(TNPersistStreamData * ptnPersistData, CTrayItem * pti, HICON hIcon);
  143. BOOL _IsAutoTrayEnabledInRegistry();
  144. void _QueryRegValue(HKEY hkey, LPTSTR pszValue, ULONG* puVal, ULONG uDefault, DWORD dwValSize);
  145. void _RestorePersistentIconSettings(TNPersistStreamData * ptnpd, CTrayItem * pti);
  146. BOOL _IsValidStreamHeaderVersion(DWORD dwVersion)
  147. {
  148. return ( (dwVersion == TNH_VERSION_FOUR) || (dwVersion == TNH_VERSION_FIVE) );
  149. }
  150. UINT_PTR _SizeOfPersistStreamData(DWORD dwVersion);
  151. inline void _DestroyPastItemsIconList()
  152. {
  153. if (_himlPastItemsIconList)
  154. {
  155. ImageList_Destroy(_himlPastItemsIconList);
  156. _himlPastItemsIconList = NULL;
  157. }
  158. }
  159. BOOL _IsIconLastUseValid(WORD wYear, WORD wMonth);
  160. BOOL _SaveIconsToRegStream();
  161. BOOL _LoadIconsFromRegStream(DWORD dwItemStreamSignature);
  162. void UpdateImageIndices(INT_PTR nDeletedImageIndex);
  163. //
  164. // Persistent Icon information...
  165. //
  166. CDPA<TNPersistStreamData> _dpaPersistentItemInfo;
  167. DWORD _dwTimesChevronInfoTipShown;
  168. BOOL _bShowChevronInfoTip;
  169. ULONG _uValidLastUseTimePeriod;
  170. // We store this policy in a local cache, since we do not support settings
  171. // changes during the session. At logon, the settings are renewed, and if the
  172. // settings change during the session, they dont take effect, until the user
  173. // has logged off and logged back on to a different session.
  174. // This policy states that the tray should function like the Windows 2000 tray,
  175. // and disables all "smart" functionality like aging, and advanced balloon
  176. // tips.
  177. BOOL _fNoAutoTrayPolicyEnabled;
  178. // This variable dictates the current setting of the tray, since the user is
  179. // allowed to specify if he wants the Windows 2000 tray, or the Whistler
  180. // auto-tray.
  181. BOOL _fAutoTrayEnabledByUser;
  182. HIMAGELIST _himlPastItemsIconList;
  183. ULONG _uIconDemoteTimerTickInterval;
  184. ULONG _uInfoTipTimerTickInterval;
  185. };
  186. #endif // _TRAYREG_H