xref: /haiku/src/apps/installer/WorkerThread.h (revision a085e81e62d7a860f809b4fb7c7bf5654c396985)
1 /*
2  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2005, Jérôme DUVAL.
4  * All rights reserved. Distributed under the terms of the MIT License.
5  */
6 #ifndef WORKER_THREAD_H
7 #define WORKER_THREAD_H
8 
9 #include <DiskDevice.h>
10 #include <DiskDeviceRoster.h>
11 #include <Looper.h>
12 #include <Messenger.h>
13 #include <Partition.h>
14 #include <Volume.h>
15 
16 class BList;
17 class BMenu;
18 class InstallerWindow;
19 class ProgressReporter;
20 
21 class WorkerThread : public BLooper {
22 public:
23 								WorkerThread(InstallerWindow* window);
24 
25 	virtual	void				MessageReceived(BMessage* message);
26 
27 			void				ScanDisksPartitions(BMenu* srcMenu,
28 									BMenu* dstMenu);
29 
30 			void				SetPackagesList(BList* list);
31 			void				SetSpaceRequired(off_t bytes)
32 									{ fSpaceRequired = bytes; };
33 
34 			bool				Cancel();
35 			void				SetLock(sem_id cancelSemaphore)
36 									{ fCancelSemaphore = cancelSemaphore; }
37 
38 			void				StartInstall();
39 			void				WriteBootSector(BMenu* dstMenu);
40 
41 private:
42 			void				_LaunchInitScript(BPath& path);
43 			void				_LaunchFinishScript(BPath& path);
44 
45 			void				_PerformInstall(BMenu* srcMenu,
46 									BMenu* dstMenu);
47 			status_t			_MirrorIndices(const BPath& srcDirectory,
48 									const BPath& targetDirectory) const;
49 			status_t			_CreateDefaultIndices(
50 									const BPath& targetDirectory) const;
51 			status_t			_ProcessZipPackages(const char* sourcePath,
52 									const char* targetPath,
53 									ProgressReporter* reporter,
54 									BList& unzipEngines);
55 
56 			void				_SetStatusMessage(const char* status);
57 
58 			InstallerWindow*	fWindow;
59 			BDiskDeviceRoster	fDDRoster;
60 			BList*				fPackages;
61 			off_t				fSpaceRequired;
62 			sem_id				fCancelSemaphore;
63 };
64 
65 #endif // WORKER_THREAD_H
66