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
17class BButton;
18class BCheckBox;
19class TextView;
20class LinkView;
21class Model;
22
23
24class ToLatestUserUsageConditionsWindow : public BWindow {
25public:
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
34private:
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
57private:
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