repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / ui / MainWindow.h
blob6f7d95c18a0fcf8b654aff5f9a562c23a7121b73
1 /*
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.
6 */
7 #ifndef MAIN_WINDOW_H
8 #define MAIN_WINDOW_H
10 #include <Window.h>
12 #include "Model.h"
13 #include "PackageAction.h"
14 #include "PackageActionHandler.h"
15 #include "PackageInfoListener.h"
18 class BCardLayout;
19 class BMenu;
20 class BMenuItem;
21 class BSplitView;
22 class FeaturedPackagesView;
23 class FilterView;
24 class PackageActionsView;
25 class PackageInfoView;
26 class PackageListView;
27 class ScreenshotWindow;
28 class WorkStatusView;
31 enum {
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 {
43 public:
44 MainWindow(const BMessage& settings);
45 MainWindow(const BMessage& settings,
46 const PackageInfoRef& package);
47 virtual ~MainWindow();
49 // BWindow interface
50 virtual bool QuitRequested();
51 virtual void MessageReceived(BMessage* message);
53 void StoreSettings(BMessage& message) const;
55 private:
56 // PackageInfoListener
57 virtual void PackageChanged(
58 const PackageInfoEvent& event);
60 private:
61 // PackageActionHandler
62 virtual status_t SchedulePackageActions(
63 PackageActionList& list);
64 virtual Model* GetModel();
66 private:
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();
75 void _AdoptModel();
77 void _AdoptPackage(const PackageInfoRef& package);
78 void _ClearPackage();
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,
90 const char* message);
92 void _OpenLoginWindow(
93 const BMessage& onSuccessMessage);
94 void _UpdateAuthorization();
95 void _RatePackage();
96 void _ShowScreenshot();
98 private:
99 FilterView* fFilterView;
100 BCardLayout* fListLayout;
101 FeaturedPackagesView* fFeaturedPackagesView;
102 PackageListView* fPackageListView;
103 PackageInfoView* fPackageInfoView;
104 BSplitView* fSplitView;
105 WorkStatusView* fWorkStatusView;
107 ScreenshotWindow* fScreenshotWindow;
109 BMenu* fUserMenu;
110 BMenuItem* fLogInItem;
111 BMenuItem* fLogOutItem;
113 BMenuItem* fShowFeaturedPackagesItem;
114 BMenuItem* fShowAvailablePackagesItem;
115 BMenuItem* fShowInstalledPackagesItem;
116 BMenuItem* fShowDevelopPackagesItem;
117 BMenuItem* fShowSourcePackagesItem;
119 Model fModel;
120 ModelListenerRef fModelListener;
121 PackageList fVisiblePackages;
123 bool fTerminating;
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