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 ProgressReporter; 19 20 class WorkerThread : public BLooper { 21 public: 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 41 private: 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 _InstallationError(status_t error); 48 status_t _MirrorIndices(const BPath& srcDirectory, 49 const BPath& targetDirectory) const; 50 status_t _CreateDefaultIndices( 51 const BPath& targetDirectory) const; 52 status_t _ProcessZipPackages(const char* sourcePath, 53 const char* targetPath, 54 ProgressReporter* reporter, 55 BList& unzipEngines); 56 57 void _SetStatusMessage(const char* status); 58 59 private: 60 class EntryFilter; 61 62 private: 63 BMessenger fOwner; 64 BDiskDeviceRoster fDDRoster; 65 BList* fPackages; 66 off_t fSpaceRequired; 67 sem_id fCancelSemaphore; 68 }; 69 70 #endif // WORKER_THREAD_H 71