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
16class BList;
17class BMenu;
18class ProgressReporter;
19
20class WorkerThread : public BLooper {
21public:
22								WorkerThread(const BMessenger& owner);
23
24	virtual	void				MessageReceived(BMessage* message);
25
26			void				ScanDisksPartitions(BMenu* srcMenu,
27									BMenu* dstMenu);
28
29			void				SetPackagesList(BList* list);
30			void				SetSpaceRequired(off_t bytes)
31									{ fSpaceRequired = bytes; };
32
33			bool				Cancel();
34			void				SetLock(sem_id cancelSemaphore)
35									{ fCancelSemaphore = cancelSemaphore; }
36
37			void				StartInstall(partition_id sourcePartitionID,
38									partition_id targetPartitionID);
39			void				WriteBootSector(BMenu* dstMenu);
40
41private:
42			status_t			_WriteBootSector(BPath& path);
43			status_t			_LaunchFinishScript(BPath& path);
44
45			status_t			_PerformInstall(partition_id sourcePartitionID,
46									partition_id targetPartitionID);
47			status_t			_PrepareCleanInstall(
48									const BPath& targetDirectory) const;
49			status_t			_InstallationError(status_t error);
50			status_t			_MirrorIndices(const BPath& srcDirectory,
51									const BPath& targetDirectory) const;
52			status_t			_CreateDefaultIndices(
53									const BPath& targetDirectory) const;
54			status_t			_ProcessZipPackages(const char* sourcePath,
55									const char* targetPath,
56									ProgressReporter* reporter,
57									BList& unzipEngines);
58
59			void				_SetStatusMessage(const char* status);
60
61private:
62			class EntryFilter;
63
64private:
65			BMessenger			fOwner;
66			BDiskDeviceRoster	fDDRoster;
67			BList*				fPackages;
68			off_t				fSpaceRequired;
69			sem_id				fCancelSemaphore;
70};
71
72#endif // WORKER_THREAD_H
73