xref: /haiku/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.h (revision 125b262675217084e0c59014b4a98f724f1c4fb3)
1 /*
2  * Copyright 2019-2020, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef TO_LATEST_USER_USAGE_CONDITIONS_WINDOW_H
6 #define TO_LATEST_USER_USAGE_CONDITIONS_WINDOW_H
7 
8 #include <Locker.h>
9 #include <Messenger.h>
10 #include <Window.h>
11 
12 #include "BarberPole.h"
13 #include "HaikuDepotConstants.h"
14 #include "UserDetail.h"
15 #include "UserUsageConditions.h"
16 
17 class BButton;
18 class BCheckBox;
19 class TextView;
20 class LinkView;
21 class Model;
22 
23 
24 class ToLatestUserUsageConditionsWindow : public BWindow {
25 public:
26 								ToLatestUserUsageConditionsWindow(
27 									BWindow* parent,
28 									Model& model, const UserDetail& userDetail);
29 	virtual						~ToLatestUserUsageConditionsWindow();
30 
31 	virtual	void				MessageReceived(BMessage* message);
32 	virtual	bool				QuitRequested();
33 
34 private:
35 			void				_EnableMutableControls();
36 			void				_InitUiControls();
37 
38 			void				_DisplayData(const UserUsageConditions&
39 									userUsageConditions);
40 			void				_HandleViewUserUsageConditions();
41 			void				_HandleLogout();
42 			void				_HandleAgree();
43 			void				_HandleAgreeFailed();
44 
45 			void				_SetWorkerThread(thread_id thread);
46 			void				_SetWorkerThreadLocked(thread_id thread);
47 
48 			void				_FetchData();
49 	static	int32				_FetchDataThreadEntry(void* data);
50 			void				_FetchDataPerform();
51 			void				_NotifyFetchProblem();
52 
53 			void				_Agree();
54 	static	int32				_AgreeThreadEntry(void* data);
55 			void				_AgreePerform();
56 
57 private:
58 			UserUsageConditions	fUserUsageConditions;
59 			Model&				fModel;
60 			UserDetail			fUserDetail;
61 
62 			TextView*			fMessageTextView;
63 			BButton*			fLogoutButton;
64 			BButton*			fAgreeButton;
65 			BCheckBox*			fConfirmMinimumAgeCheckBox;
66 			BCheckBox*			fConfirmUserUsageConditionsCheckBox;
67 			LinkView*			fUserUsageConditionsLink;
68 			BarberPole*			fWorkerIndicator;
69 
70 			BLocker				fLock;
71 			thread_id			fWorkerThread;
72 			bool				fQuitRequestedDuringWorkerThread;
73 			bool				fMutableControlsEnabled;
74 };
75 
76 
77 #endif // TO_LATEST_USER_USAGE_CONDITIONS_WINDOW_H
78