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.

287 lines
9.8 KiB

  1. // logon.h
  2. //
  3. #if !defined(LOGON__Logon_h__INCLUDED)
  4. #define LOGON__Logon_h__INCLUDED
  5. #pragma once
  6. //#define ANIMATE_FLAG
  7. // Forward declarations
  8. class LogonAccount;
  9. #ifdef GADGET_ENABLE_GDIPLUS
  10. enum EFadeDirection;
  11. #endif
  12. #define MAX_FLAG_FRAMES 1
  13. #define FLAG_ANIMATION_COUNT 1
  14. class LogonFrame: public HWNDElement, public IElementListener
  15. {
  16. public:
  17. static HRESULT Create(OUT Element** ppElement); // Required for ClassInfo (always fails)
  18. static HRESULT Create(HWND hParent, BOOL fDblBuffer, UINT nCreate, OUT Element** ppElement);
  19. // Generic events
  20. virtual void OnEvent(Event* pEvent);
  21. // System events
  22. virtual void OnInput(InputEvent* pEvent);
  23. virtual void OnPropertyChanged(PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  24. virtual Element* GetAdjacent(Element* peFrom, int iNavDir, NavReference const* pnr, bool bKeyable);
  25. // Frame Callbacks
  26. HRESULT OnLogUserOn(LogonAccount* pla);
  27. HRESULT OnPower();
  28. HRESULT OnUndock();
  29. HRESULT OnTreeReady(Parser* pParser);
  30. // Listener impl
  31. virtual void OnListenerAttach(Element* peFrom) { peFrom; }
  32. virtual void OnListenerDetach(Element* peFrom) { peFrom; }
  33. virtual bool OnListenedPropertyChanging(Element* peFrom, PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew) { peFrom; ppi; iIndex; pvOld; pvNew; return true; }
  34. virtual void OnListenedPropertyChanged(Element* peFrom, PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  35. virtual void OnListenedInput(Element* peFrom, InputEvent* pInput) { peFrom; pInput; }
  36. virtual void OnListenedEvent(Element* peFrom, Event* pEvent) { peFrom; pEvent; }
  37. // Operations
  38. static int PointToPixel(int nPoint) { return MulDiv(nPoint, _nDPI, 72); }
  39. HINSTANCE GetHInstance() { return _pParser->GetHInstance(); }
  40. void HideAccountPanel() { _peRightPanel->SetLayoutPos(LP_None); _peLeftPanel->RemoveLocalValue(WidthProp);}
  41. void ShowAccountPanel() { _peRightPanel->SetLayoutPos(BLP_Left); _peLeftPanel->SetWidth(380);}
  42. void HideLogoArea() { _peLogoArea->SetLayoutPos(LP_None); }
  43. void ShowLogoArea() { _peLogoArea->SetLayoutPos(BLP_Client); }
  44. void HideWelcomeArea() { _peMsgArea->SetLayoutPos(LP_None); }
  45. void ShowWelcomeArea() { _peMsgArea->SetLayoutPos(BLP_Client); }
  46. void HidePowerButton() { _pbPower->SetVisible(false); }
  47. void ShowPowerButton() { _pbPower->SetVisible(true); }
  48. void SetPowerButtonLabel(LPCWSTR psz) { Element* pe = _pbPower->FindDescendent(StrToID(L"label")); if (pe) pe->SetContentString(psz); }
  49. void InsertUndockButton() { _pbUndock->SetLayoutPos(BLP_Top); }
  50. void RemoveUndockButton() { _pbUndock->SetLayoutPos(LP_None); }
  51. void HideUndockButton() { _pbUndock->SetVisible(false); }
  52. void ShowUndockButton() { _pbUndock->SetVisible(true); }
  53. void SetUndockButtonLabel(LPCWSTR psz) { Element* pe = _pbUndock->FindDescendent(StrToID(L"label")); if (pe) pe->SetContentString(psz); }
  54. void SetStatus(LPCWSTR psz) { if (psz){ _peHelp->SetContentString(psz);}}
  55. void SetTitle(UINT uRCID);
  56. void SetTitle(LPCWSTR pszTitle);
  57. void SetButtonLabels();
  58. HRESULT AddAccount(LPCWSTR pszPicture, BOOL fPicRes, LPCWSTR pszName, LPCWSTR pszUsername, LPCWSTR pszHint, BOOL fPwdNeeded, BOOL fLoggedOn, OUT LogonAccount **ppla);
  59. NativeHWNDHost* GetNativeHost() {return _pnhh;}
  60. void SetNativeHost(NativeHWNDHost *pnhh) {_pnhh = pnhh;}
  61. void UpdateUserStatus(BOOL fRefreshAll = false);
  62. LogonAccount* FindNamedUser(LPCWSTR pszUsername);
  63. void SelectUser(LPCWSTR pszUsername);
  64. void ResetUserList();
  65. void Resize(BOOL fWorkArea);
  66. void SetAnimations(BOOL fAnimations);
  67. void ResetTheme();
  68. BOOL UserListAvailable() {return _fListAvailable;}
  69. void SetUserListAvailable(BOOL fListAvailable) {_fListAvailable = fListAvailable;}
  70. // ClassInfo accessors (static and virtual instance-based)
  71. static IClassInfo* Class;
  72. virtual IClassInfo* GetClassInfo() { return Class; }
  73. static HRESULT Register();
  74. // state management
  75. void SetState(UINT uNewState) {_nAppState = uNewState;}
  76. UINT GetState() {return _nAppState;}
  77. BOOL IsPreStatusLock() {return _fPreStatusLock;}
  78. void EnterPreStatusMode(BOOL fLock);
  79. void EnterLogonMode(BOOL fUnLock);
  80. void EnterPostStatusMode();
  81. void EnterHideMode();
  82. void EnterDoneMode();
  83. LRESULT InteractiveLogonRequest(LPCWSTR pszUsername, LPCWSTR pszPassword);
  84. void NextFlagAnimate(DWORD dwFrame);
  85. #ifdef GADGET_ENABLE_GDIPLUS
  86. // Animations / Effects
  87. HRESULT FxStartup();
  88. #endif
  89. LogonFrame() { }
  90. virtual ~LogonFrame();
  91. HRESULT Initialize(HWND hParent, BOOL fDblBuffer, UINT nCreate);
  92. #ifdef GADGET_ENABLE_GDIPLUS
  93. // Animations / Effects
  94. HRESULT FxFadeAccounts(EFadeDirection dir, float flCommonDelay = 0.0f);
  95. HRESULT FxLogUserOn(LogonAccount * pla);
  96. static void CALLBACK OnLoginCenterStage(GMA_ACTIONINFO * pmai);
  97. #endif
  98. // References to key descendents
  99. Selector* _peAccountList;
  100. ScrollViewer* _peViewer;
  101. Element* _peRightPanel;
  102. Element* _peLeftPanel;
  103. Button* _pbPower;
  104. Button* _pbUndock;
  105. Element* _peHelp;
  106. Element* _peOptions;
  107. Element* _peMsgArea;
  108. Element* _peLogoArea;
  109. private:
  110. LogonAccount* InternalFindNamedUser(LPCWSTR pszUsername);
  111. static int _nDPI;
  112. Parser* _pParser;
  113. BOOL _fListAvailable;
  114. BOOL _fPreStatusLock;
  115. HWND _hwndNotification;
  116. UINT _nStatusID;
  117. UINT _nAppState;
  118. NativeHWNDHost *_pnhh;
  119. Value* _pvHotList;
  120. Value* _pvList;
  121. HDC _hdcAnimation;
  122. HBITMAP _hbmpFlags;
  123. DWORD _dwFlagFrame;
  124. UINT _nColorDepth;
  125. };
  126. class LogonAccountList: public Selector
  127. {
  128. public:
  129. static HRESULT Create(OUT Element** ppElement); // Required for ClassInfo
  130. // System events
  131. virtual void OnPropertyChanged(PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  132. // ClassInfo accessors (static and virtual instance-based)
  133. static IClassInfo* Class;
  134. virtual IClassInfo* GetClassInfo() { return Class; }
  135. static HRESULT Register();
  136. LogonAccountList() { }
  137. virtual ~LogonAccountList() { }
  138. HRESULT Initialize() { return Selector::Initialize(); }
  139. #ifdef GADGET_ENABLE_GDIPLUS
  140. // Animations / Effects
  141. HRESULT FxMouseWithin(EFadeDirection dir);
  142. #endif
  143. };
  144. // LogonState property enum
  145. #define LS_Pending 0
  146. #define LS_Granted 1
  147. #define LS_Denied 2
  148. #define LAS_Initialized 0
  149. #define LAS_PreStatus 1
  150. #define LAS_Logon 2
  151. #define LAS_PostStatus 3
  152. #define LAS_Hide 4
  153. #define LAS_Done 5
  154. #define LASS_Email 0
  155. #define LASS_LoggedOn 1
  156. class LogonAccount: public Button
  157. {
  158. public:
  159. static HRESULT Create(OUT Element** ppElement); // Required for ClassInfo
  160. // Generic events
  161. virtual void OnEvent(Event* pEvent);
  162. // System events
  163. virtual void OnInput(InputEvent* pEvent);
  164. virtual void OnPropertyChanged(PropertyInfo* ppi, int iIndex, Value* pvOld, Value* pvNew);
  165. // Account Callbacks
  166. void OnAuthenticatedUser();
  167. BOOL OnAuthenticateUser(LPCWSTR pszInPassword = NULL);
  168. void OnHintSelect();
  169. void OnStatusSelect(UINT nLine);
  170. HRESULT OnTreeReady(LPCWSTR pszPicture, BOOL fPicRes, LPCWSTR pszName, LPCWSTR pszUsername, LPCWSTR pszHint, BOOL fPwdNeeded, BOOL fLoggedOn, HINSTANCE hInst);
  171. // Operations
  172. static void InitPasswordPanel(Element* pePwdPanel, Edit* pePwdEdit, Button* pbPwdInfo, Element* peKbdIcon) { _pePwdPanel = pePwdPanel; _pePwdEdit = pePwdEdit; _pbPwdInfo = pbPwdInfo; _peKbdIcon = peKbdIcon;}
  173. HRESULT InsertPasswordPanel();
  174. HRESULT RemovePasswordPanel();
  175. void InsertStatus(UINT nLine) { _pbStatus[nLine]->SetLayoutPos(BLP_Top); }
  176. void RemoveStatus(UINT nLine) { _pbStatus[nLine]->SetLayoutPos(LP_None); }
  177. void HideStatus(UINT nLine) { _pbStatus[nLine]->SetVisible(false); }
  178. void ShowStatus(UINT nLine) { _pbStatus[nLine]->SetVisible(true); }
  179. void SetStatus(UINT nLine, LPCWSTR psz);
  180. void DisableStatus(UINT nLine) { _pbStatus[nLine]->SetEnabled(false); }
  181. void ShowPasswordIncorrectMessage();
  182. void UpdateNotifications(BOOL fUpdateEverything);
  183. void AppRunningTip();
  184. void UnreadMailTip();
  185. BOOL IsPasswordBlank();
  186. #ifdef GADGET_ENABLE_GDIPLUS
  187. void ShowEdit();
  188. void HideEdit();
  189. #endif
  190. // Cached atoms for quicker identification
  191. static ATOM idPwdGo;
  192. static ATOM idPwdInfo;
  193. // Property definitions
  194. static PropertyInfo* LogonStateProp;
  195. // Quick property accessors
  196. int GetLogonState() DUIQuickGetter(int, GetInt(), LogonState, Specified)
  197. HRESULT SetLogonState(int v) DUIQuickSetter(CreateInt(v), LogonState)
  198. void SetRunningApps(DWORD dwRunningApps) {_dwRunningApps = dwRunningApps;}
  199. void SetUnreadMail(DWORD dwUnreadMail) {_dwUnreadMail = dwUnreadMail;}
  200. LPCWSTR GetUsername() {return _pvUsername->GetString();}
  201. static LogonAccount* GetCandidate() { return _peCandidate; }
  202. static void ClearCandidate() { _peCandidate = NULL; }
  203. static void SetKeyboardIcon(HICON hIcon);
  204. // ClassInfo accessors (static and virtual instance-based)
  205. static IClassInfo* Class;
  206. virtual IClassInfo* GetClassInfo() { return Class; }
  207. static HRESULT Register();
  208. #ifdef GADGET_ENABLE_GDIPLUS
  209. // Animations / Effects
  210. HRESULT FxLogUserOn();
  211. #endif
  212. LogonAccount() { }
  213. virtual ~LogonAccount();
  214. HRESULT Initialize();
  215. #ifdef GADGET_ENABLE_GDIPLUS
  216. // Animations / Effects
  217. HRESULT FxMouseWithin(EFadeDirection dir);
  218. #endif
  219. // References to key descendents
  220. Button* _pbStatus[2];
  221. static Element* _pePwdPanel;
  222. static Edit* _pePwdEdit;
  223. static Button* _pbPwdInfo;
  224. static Element* _peKbdIcon;
  225. static LogonAccount* _peCandidate;
  226. Value* _pvUsername;
  227. Value* _pvHint;
  228. BOOL _fPwdNeeded;
  229. BOOL _fLoggedOn;
  230. BOOL _fHasPwdPanel;
  231. DWORD _dwUnreadMail;
  232. DWORD _dwRunningApps;
  233. };
  234. void CALLBACK LogonParseError(LPCWSTR pszError, LPCWSTR pszToken, int dLine);
  235. #endif // LOGON__Logon_h__INCLUDED