1 /* 2 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved. 3 * Distributed under the terms of the MIT/X11 license. 4 * 5 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software 6 * as long as it is accompanied by it's documentation and this copyright notice. 7 * The software comes with no warranty, etc. 8 */ 9 #ifndef SCANNER_H 10 #define SCANNER_H 11 12 13 #include <string> 14 15 #include <Looper.h> 16 #include <Message.h> 17 #include <Messenger.h> 18 #include <Volume.h> 19 20 #include "Snapshot.h" 21 22 23 class BDirectory; 24 25 using std::string; 26 27 28 class Scanner: public BLooper { 29 public: 30 Scanner(BVolume* volume, BHandler* handler); 31 virtual ~Scanner(); 32 33 virtual void MessageReceived(BMessage* message); 34 35 VolumeSnapshot* Snapshot() const 36 { return fBusy ? NULL : fSnapshot; } 37 void Refresh(FileInfo* startInfo = NULL); 38 bool IsBusy() const 39 { return fBusy; } 40 const char* Task() const 41 { return fTask.c_str(); } 42 float Progress() const 43 { return min_c(100.0, fProgress); } 44 FileInfo* CurrentDir() const 45 { return fBusy ? NULL : fSnapshot->currentDir; } 46 void ChangeDir(FileInfo* info) 47 { fSnapshot->currentDir = info; } 48 void SetDesiredPath(string &path); 49 dev_t Device() const 50 { return fVolume->Device(); } 51 void RequestQuit(); 52 53 private: 54 void _RunScan(FileInfo *startInfo); 55 FileInfo* _GetFileInfo(BDirectory* dir, FileInfo* parent); 56 void _ChangeToDesired(); 57 58 BMessenger fListener; 59 BMessage fDoneMessage; 60 BMessage fProgressMessage; 61 62 BVolume* fVolume; 63 off_t fVolumeBytesInUse; 64 off_t fVolumeBytesScanned; 65 float fProgress; 66 float fLastReport; 67 VolumeSnapshot* fSnapshot; 68 string fDesiredPath; 69 string fTask; 70 bool fBusy; 71 bool fQuitRequested; 72 }; 73 74 #endif // SCANNER_H 75