2 * Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
3 * Copyright 2013, Rene Gollent <rene@gollent.com>.
4 * Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
5 * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
6 * All rights reserved. Distributed under the terms of the MIT License.
13 #include "BulkLoadStateMachine.h"
15 #include "PackageAction.h"
16 #include "PackageActionHandler.h"
17 #include "PackageInfoListener.h"
24 class FeaturedPackagesView
;
26 class PackageActionsView
;
27 class PackageInfoView
;
28 class PackageListView
;
29 class ScreenshotWindow
;
34 MSG_MAIN_WINDOW_CLOSED
= 'mwcl',
35 MSG_PACKAGE_SELECTED
= 'pkgs',
36 MSG_PACKAGE_WORKER_BUSY
= 'pkwb',
37 MSG_PACKAGE_WORKER_IDLE
= 'pkwi',
38 MSG_ADD_VISIBLE_PACKAGES
= 'avpk',
39 MSG_UPDATE_SELECTED_PACKAGE
= 'uspk',
43 class MainWindow
: public BWindow
, private PackageInfoListener
,
44 private PackageActionHandler
{
46 MainWindow(const BMessage
& settings
);
47 MainWindow(const BMessage
& settings
,
48 const PackageInfoRef
& package
);
49 virtual ~MainWindow();
52 virtual bool QuitRequested();
53 virtual void MessageReceived(BMessage
* message
);
55 void StoreSettings(BMessage
& message
) const;
58 // PackageInfoListener
59 virtual void PackageChanged(
60 const PackageInfoEvent
& event
);
63 // PackageActionHandler
64 virtual status_t
SchedulePackageActions(
65 PackageActionList
& list
);
66 virtual Model
* GetModel();
69 void _BuildMenu(BMenuBar
* menuBar
);
70 void _BuildUserMenu(BMenuBar
* menuBar
);
72 void _RestoreUserName(const BMessage
& settings
);
73 const char* _WindowFrameName() const;
74 void _RestoreWindowFrame(const BMessage
& settings
);
76 void _InitWorkerThreads();
79 void _AdoptPackage(const PackageInfoRef
& package
);
82 void _RefreshRepositories(bool force
);
83 void _RefreshPackageList(bool force
);
85 void _StartRefreshWorker(bool force
= false);
86 static status_t
_RefreshModelThreadWorker(void* arg
);
87 static status_t
_PackageActionWorker(void* arg
);
88 static status_t
_PopulatePackageWorker(void* arg
);
89 static status_t
_PackagesToShowWorker(void* arg
);
91 void _NotifyUser(const char* title
,
94 void _OpenLoginWindow(
95 const BMessage
& onSuccessMessage
);
96 void _UpdateAuthorization();
98 void _ShowScreenshot();
101 FilterView
* fFilterView
;
102 BCardLayout
* fListLayout
;
103 FeaturedPackagesView
* fFeaturedPackagesView
;
104 PackageListView
* fPackageListView
;
105 PackageInfoView
* fPackageInfoView
;
106 BSplitView
* fSplitView
;
107 WorkStatusView
* fWorkStatusView
;
109 ScreenshotWindow
* fScreenshotWindow
;
112 BMenuItem
* fLogInItem
;
113 BMenuItem
* fLogOutItem
;
115 BMenuItem
* fShowFeaturedPackagesItem
;
116 BMenuItem
* fShowAvailablePackagesItem
;
117 BMenuItem
* fShowInstalledPackagesItem
;
118 BMenuItem
* fShowDevelopPackagesItem
;
119 BMenuItem
* fShowSourcePackagesItem
;
122 ModelListenerRef fModelListener
;
123 PackageList fVisiblePackages
;
125 fBulkLoadStateMachine
;
128 bool fSinglePackageMode
;
129 thread_id fModelWorker
;
131 thread_id fPendingActionsWorker
;
132 PackageActionList fPendingActions
;
133 BLocker fPendingActionsLock
;
134 sem_id fPendingActionsSem
;
136 thread_id fPopulatePackageWorker
;
137 PackageInfoRef fPackageToPopulate
;
138 BLocker fPackageToPopulateLock
;
139 sem_id fPackageToPopulateSem
;
141 thread_id fShowPackagesWorker
;
142 PackageList fPackagesToShowList
;
143 int32 fPackagesToShowListID
;
144 // atomic, counted up whenever fPackagesToShowList is refilled
145 BLocker fPackagesToShowListLock
;
146 sem_id fNewPackagesToShowSem
;
147 sem_id fShowPackagesAcknowledgeSem
;
150 #endif // MAIN_WINDOW_H