xref: /haiku/src/apps/haikudepot/ui/UserUsageConditionsWindow.h (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
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 USER_USAGE_CONDITIONS_WINDOW_H
6 #define USER_USAGE_CONDITIONS_WINDOW_H
7 
8 #include <Locker.h>
9 #include <Messenger.h>
10 #include <Window.h>
11 
12 #include "HaikuDepotConstants.h"
13 #include "PackageInfo.h"
14 #include "UserDetail.h"
15 #include "UserUsageConditions.h"
16 
17 
18 class BarberPole;
19 class TextView;
20 class BStringView;
21 class MarkupTextView;
22 class Model;
23 
24 
25 class UserUsageConditionsWindow : public BWindow {
26 public:
27 								UserUsageConditionsWindow(Model& model,
28 									UserUsageConditions& userUsageConditions);
29 								UserUsageConditionsWindow(Model& model,
30 									UserUsageConditionsSelectionMode mode);
31 	virtual						~UserUsageConditionsWindow();
32 
33 	virtual	void				MessageReceived(BMessage* message);
34 	virtual bool				QuitRequested();
35 
36 private:
37 	void						_InitUiControls();
38 
39 	static const BString		_VersionText(const BString& code);
40 	static const BString		_MinimumAgeText(uint8 minimumAge);
41 	static const BString		_IntroductionTextForMode(
42 									UserUsageConditionsSelectionMode mode,
43 									const UserDetail& userDetail);
44 
45 	void						_DisplayData(const UserDetail& userDetail,
46 									const UserUsageConditions&
47 									userUsageConditions);
48 
49 	void						_FetchData();
50 	void						_SetWorkerThread(thread_id thread);
51 	static int32				_FetchDataThreadEntry(void* data);
52 	void						_FetchDataPerform();
53 	status_t					_FetchUserUsageConditionsCodePerform(
54 									UserDetail& userDetail, BString& code);
55 	status_t					_FetchUserUsageConditionsCodeForUserPerform(
56 									UserDetail& userDetail, BString& code);
57 	void						_NotifyFetchProblem();
58 
59 private:
60 			UserUsageConditionsSelectionMode
61 								fMode;
62 			MarkupTextView*		fCopyView;
63 			Model&				fModel;
64 			BStringView*		fAgeNoteStringView;
65 			BStringView*		fVersionStringView;
66 			TextView*			fIntroductionTextView;
67 			BarberPole*			fWorkerIndicator;
68 			thread_id			fWorkerThread;
69 };
70 
71 
72 #endif // USER_USAGE_CONDITIONS_WINDOW_H
73