diff --git a/src/apps/installer/CopyEngine.cpp b/src/apps/installer/CopyEngine.cpp index 186883496a..5bdbf0f2ac 100644 --- a/src/apps/installer/CopyEngine.cpp +++ b/src/apps/installer/CopyEngine.cpp @@ -5,9 +5,32 @@ #include "CopyEngine.h" #include "InstallerWindow.h" -#include +#include +#include #include +class SourceVisitor : public BDiskDeviceVisitor +{ +public: + SourceVisitor(BMenu *menu); + virtual bool Visit(BDiskDevice *device); + virtual bool Visit(BPartition *partition, int32 level); +private: + BMenu *fMenu; +}; + + +class TargetVisitor : public BDiskDeviceVisitor +{ +public: + TargetVisitor(BMenu *menu); + virtual bool Visit(BDiskDevice *device); + virtual bool Visit(BPartition *partition, int32 level); +private: + BMenu *fMenu; +}; + + CopyEngine::CopyEngine(InstallerWindow *window) : BLooper("copy_engine"), fWindow(window) @@ -52,34 +75,77 @@ CopyEngine::Start() void -CopyEngine::ScanDisksPartitions(BMenu *srcMenu, BMenu *dstMenu) +CopyEngine::ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu) { - /*BDiskDeviceRoster roster; BDiskDevice device; - roster.VisitEachDevice(this, &device); + BPartition *partition = NULL; - BPartition *partition; - roster.VisitEachPartition(this, &device, &partition);*/ + printf("ScanDisksPartitions partitions begin\n"); + SourceVisitor srcVisitor(srcMenu); + fDDRoster.VisitEachMountedPartition(&srcVisitor, &device, &partition); + + printf("ScanDisksPartitions partitions begin\n"); + TargetVisitor targetVisitor(targetMenu); + fDDRoster.VisitEachPartition(&targetVisitor, &device, &partition); } -bool -CopyEngine::Visit(BDiskDevice *device) +SourceVisitor::SourceVisitor(BMenu *menu) + : fMenu(menu) { +} + +bool +SourceVisitor::Visit(BDiskDevice *device) +{ + if (!device->Type() || strcmp(device->Type(), kPartitionTypeBFS)!=0) + return false; BPath path; if (device->GetPath(&path)==B_OK) - printf("CopyEngine::Visit(BDiskDevice *) : %s\n", path.Path()); + printf("SourceVisitor::Visit(BDiskDevice *) : %s\n", path.Path()); return false; } bool -CopyEngine::Visit(BPartition *partition, int32 level) +SourceVisitor::Visit(BPartition *partition, int32 level) { + if (!partition->Type() || strcmp(partition->Type(), kPartitionTypeBFS)!=0) + return false; BPath path; - if (partition->GetPath(&path)==B_OK) - printf("CopyEngine::Visit(BPartition *) : %s\n", path.Path()); - printf("CopyEngine::Visit(BPartition *) : %s\n", partition->Name()); + if (partition->GetPath(&path)==B_OK) + printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path()); + printf("SourceVisitor::Visit(BPartition *) : %s\n", partition->Name()); return false; } + +TargetVisitor::TargetVisitor(BMenu *menu) + : fMenu(menu) +{ +} + + +bool +TargetVisitor::Visit(BDiskDevice *device) +{ + if (device->IsReadOnly()) + return false; + BPath path; + if (device->GetPath(&path)==B_OK) + printf("TargetVisitor::Visit(BDiskDevice *) : %s\n", path.Path()); + return false; +} + + +bool +TargetVisitor::Visit(BPartition *partition, int32 level) +{ + if (partition->IsReadOnly()) + return false; + BPath path; + if (partition->GetPath(&path)==B_OK) + printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path()); + printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->Name()); + return false; +} diff --git a/src/apps/installer/CopyEngine.h b/src/apps/installer/CopyEngine.h index 21d8e80aac..927bedd1f8 100644 --- a/src/apps/installer/CopyEngine.h +++ b/src/apps/installer/CopyEngine.h @@ -6,8 +6,8 @@ #ifndef _CopyEngine_h #define _CopyEngine_h -#include #include +#include #include #include #include @@ -15,18 +15,17 @@ class InstallerWindow; -class CopyEngine : public BLooper/*, BDiskDeviceVisitor*/ { +class CopyEngine : public BLooper { public: CopyEngine(InstallerWindow *window); void Start(); - void ScanDisksPartitions(BMenu *srcMenu, BMenu *dstMenu); + void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); - virtual bool Visit(BDiskDevice *device); - virtual bool Visit(BPartition *partition, int32 level); private: void LaunchInitScript(BVolume *volume); void LaunchFinishScript(BVolume *volume); InstallerWindow *fWindow; + BDiskDeviceRoster fDDRoster; }; #endif /* _CopyEngine_h */ diff --git a/src/apps/installer/InstallerCopyLoopControl.cpp b/src/apps/installer/InstallerCopyLoopControl.cpp index 572817a6a2..fc52016f38 100644 --- a/src/apps/installer/InstallerCopyLoopControl.cpp +++ b/src/apps/installer/InstallerCopyLoopControl.cpp @@ -7,7 +7,7 @@ /* copied from libtracker, because beos loader doesn't seem to find them correctly in libtracker.so */ -BPrivate::CopyLoopControl::~CopyLoopControl() +/*BPrivate::CopyLoopControl::~CopyLoopControl() { } @@ -35,7 +35,7 @@ bool BPrivate::CopyLoopControl::PreserveAttribute(const char*) { return false; -} +}*/ InstallerCopyLoopControl::InstallerCopyLoopControl(InstallerWindow *window) : fWindow(window)