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 BTextView; 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 static float _ExpectedIntroductionTextHeight( 45 BTextView* introductionTextView); 46 47 void _DisplayData(const UserDetail& userDetail, 48 const UserUsageConditions& 49 userUsageConditions); 50 51 void _FetchData(); 52 void _SetWorkerThread(thread_id thread); 53 static int32 _FetchDataThreadEntry(void* data); 54 void _FetchDataPerform(); 55 status_t _FetchUserUsageConditionsCodePerform( 56 UserDetail& userDetail, BString& code); 57 status_t _FetchUserUsageConditionsCodeForUserPerform( 58 UserDetail& userDetail, BString& code); 59 void _NotifyFetchProblem(); 60 61 private: 62 UserUsageConditionsSelectionMode 63 fMode; 64 MarkupTextView* fCopyView; 65 Model& fModel; 66 BStringView* fAgeNoteStringView; 67 BStringView* fVersionStringView; 68 BTextView* fIntroductionTextView; 69 BarberPole* fWorkerIndicator; 70 thread_id fWorkerThread; 71 }; 72 73 74 #endif // USER_USAGE_CONDITIONS_WINDOW_H 75