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 * All rights reserved. Distributed under the terms of the MIT License.
13 #include "PackageAction.h"
14 #include "PackageActionHandler.h"
15 #include "PackageInfoListener.h"
22 class FeaturedPackagesView
;
24 class PackageActionsView
;
25 class PackageInfoView
;
26 class PackageListView
;
27 class ScreenshotWindow
;
32 MSG_MAIN_WINDOW_CLOSED
= 'mwcl',
33 MSG_PACKAGE_SELECTED
= 'pkgs',
34 MSG_PACKAGE_WORKER_BUSY
= 'pkwb',
35 MSG_PACKAGE_WORKER_IDLE
= 'pkwi',
36 MSG_ADD_VISIBLE_PACKAGES
= 'avpk',
37 MSG_UPDATE_SELECTED_PACKAGE
= 'uspk',
41 class MainWindow
: public BWindow
, private PackageInfoListener
,
42 private PackageActionHandler
{
44 MainWindow(const BMessage
& settings
);
45 MainWindow(const BMessage
& settings
,
46 const PackageInfoRef
& package
);
47 virtual ~MainWindow();
50 virtual bool QuitRequested();
51 virtual void MessageReceived(BMessage
* message
);
53 void StoreSettings(BMessage
& message
) const;
56 // PackageInfoListener
57 virtual void PackageChanged(
58 const PackageInfoEvent
& event
);
61 // PackageActionHandler
62 virtual status_t
SchedulePackageActions(
63 PackageActionList
& list
);
64 virtual Model
* GetModel();
67 void _BuildMenu(BMenuBar
* menuBar
);
68 void _BuildUserMenu(BMenuBar
* menuBar
);
70 void _RestoreUserName(const BMessage
& settings
);
71 const char* _WindowFrameName() const;
72 void _RestoreWindowFrame(const BMessage
& settings
);
74 void _InitWorkerThreads();
77 void _AdoptPackage(const PackageInfoRef
& package
);
80 void _RefreshRepositories(bool force
);
81 void _RefreshPackageList(bool force
);
83 void _StartRefreshWorker(bool force
= false);
84 static status_t
_RefreshModelThreadWorker(void* arg
);
85 static status_t
_PackageActionWorker(void* arg
);
86 static status_t
_PopulatePackageWorker(void* arg
);
87 static status_t
_PackagesToShowWorker(void* arg
);
89 void _NotifyUser(const char* title
,
92 void _OpenLoginWindow(
93 const BMessage
& onSuccessMessage
);
94 void _UpdateAuthorization();
96 void _ShowScreenshot();
99 FilterView
* fFilterView
;
100 BCardLayout
* fListLayout
;
101 FeaturedPackagesView
* fFeaturedPackagesView
;
102 PackageListView
* fPackageListView
;
103 PackageInfoView
* fPackageInfoView
;
104 BSplitView
* fSplitView
;
105 WorkStatusView
* fWorkStatusView
;
107 ScreenshotWindow
* fScreenshotWindow
;
110 BMenuItem
* fLogInItem
;
111 BMenuItem
* fLogOutItem
;
113 BMenuItem
* fShowFeaturedPackagesItem
;
114 BMenuItem
* fShowAvailablePackagesItem
;
115 BMenuItem
* fShowInstalledPackagesItem
;
116 BMenuItem
* fShowDevelopPackagesItem
;
117 BMenuItem
* fShowSourcePackagesItem
;
120 ModelListenerRef fModelListener
;
121 PackageList fVisiblePackages
;
124 bool fSinglePackageMode
;
125 thread_id fModelWorker
;
127 thread_id fPendingActionsWorker
;
128 PackageActionList fPendingActions
;
129 BLocker fPendingActionsLock
;
130 sem_id fPendingActionsSem
;
132 thread_id fPopulatePackageWorker
;
133 PackageInfoRef fPackageToPopulate
;
134 BLocker fPackageToPopulateLock
;
135 sem_id fPackageToPopulateSem
;
137 thread_id fShowPackagesWorker
;
138 PackageList fPackagesToShowList
;
139 int32 fPackagesToShowListID
;
140 // atomic, counted up whenever fPackagesToShowList is refilled
141 BLocker fPackagesToShowListLock
;
142 sem_id fNewPackagesToShowSem
;
143 sem_id fShowPackagesAcknowledgeSem
;
146 #endif // MAIN_WINDOW_H