2003-02-01 01:05:09 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// This software is part of the OpenBeOS distribution and is covered
|
|
|
|
// by the OpenBeOS license.
|
|
|
|
//---------------------------------------------------------------------
|
2003-02-01 00:17:20 +03:00
|
|
|
|
|
|
|
#ifndef _DISK_DEVICE_ROSTER_H
|
|
|
|
#define _DISK_DEVICE_ROSTER_H
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
#include <image.h>
|
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
#include <DiskDeviceVisitor.h>
|
2003-02-01 21:12:03 +03:00
|
|
|
#include <Messenger.h>
|
2003-02-01 00:17:20 +03:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
class BDirectory;
|
2003-02-01 00:17:20 +03:00
|
|
|
class BDiskDevice;
|
2003-02-23 02:50:14 +03:00
|
|
|
class BDiskScannerPartitionAddOn;
|
2003-02-01 00:17:20 +03:00
|
|
|
class BPartition;
|
|
|
|
class BSession;
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
class AddOnImage;
|
|
|
|
}
|
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
// watchable events
|
|
|
|
enum {
|
|
|
|
B_DEVICE_REQUEST_MOUNT_POINT = 0x01, // mount point changes
|
|
|
|
B_DEVICE_REQUEST_MOUNTING = 0x02, // mounting/unmounting
|
|
|
|
B_DEVICE_REQUEST_PARTITION = 0x04, // partition changes (initial.)
|
|
|
|
B_DEVICE_REQUEST_SESSION = 0x08, // session changes (partitioning)
|
|
|
|
B_DEVICE_REQUEST_DEVICE = 0x10, // device changes (media changes)
|
|
|
|
B_DEVICE_REQUEST_DEVICE_LIST = 0x20, // device additions/removals
|
|
|
|
B_DEVICE_REQUEST_ALL = 0xff, // all events
|
|
|
|
};
|
|
|
|
|
|
|
|
// notification message "what" field
|
|
|
|
// TODO: move to app/AppDefs.h
|
|
|
|
enum {
|
|
|
|
B_DEVICE_UPDATE = 'DUPD'
|
|
|
|
};
|
|
|
|
|
|
|
|
// notification message "event" field values
|
|
|
|
enum {
|
|
|
|
B_DEVICE_MOUNT_POINT_MOVED, // mount point moved/renamed
|
|
|
|
B_DEVICE_PARTITION_MOUNTED, // partition mounted
|
|
|
|
B_DEVICE_PARTITION_UNMOUNTED, // partition unmounted
|
|
|
|
B_DEVICE_PARTITION_CHANGED, // partition changed, e.g. initialized
|
|
|
|
// or resized
|
|
|
|
B_DEVICE_PARTITION_ADDED, // partition added
|
|
|
|
B_DEVICE_PARTITION_REMOVED, // partition removed
|
2003-02-15 02:12:47 +03:00
|
|
|
B_DEVICE_SESSION_ADDED, // session added
|
|
|
|
B_DEVICE_SESSION_REMOVED, // session removed
|
2003-02-01 00:17:20 +03:00
|
|
|
B_DEVICE_MEDIA_CHANGED, // media changed
|
|
|
|
B_DEVICE_ADDED, // device added
|
|
|
|
B_DEVICE_REMOVED // device removed
|
|
|
|
};
|
|
|
|
|
2003-02-15 02:12:47 +03:00
|
|
|
// notification message "cause" field values
|
|
|
|
enum {
|
|
|
|
// helpful causes
|
|
|
|
B_DEVICE_CAUSE_MEDIA_CHANGED,
|
|
|
|
B_DEVICE_CAUSE_FORMATTED,
|
|
|
|
B_DEVICE_CAUSE_PARTITIONED,
|
|
|
|
B_DEVICE_CAUSE_INITIALIZED,
|
|
|
|
// unknown cause
|
|
|
|
B_DEVICE_CAUSE_UNKNOWN,
|
|
|
|
// for internal use only (e.g.: partition added, because device added)
|
|
|
|
B_DEVICE_CAUSE_PARENT_CHANGED,
|
|
|
|
};
|
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
class BDiskDeviceRoster {
|
|
|
|
public:
|
|
|
|
BDiskDeviceRoster();
|
|
|
|
~BDiskDeviceRoster();
|
|
|
|
|
|
|
|
status_t GetNextDevice(BDiskDevice *device);
|
|
|
|
status_t Rewind();
|
|
|
|
|
|
|
|
bool VisitEachDevice(BDiskDeviceVisitor *visitor,
|
|
|
|
BDiskDevice *device = NULL);
|
2003-02-09 02:34:47 +03:00
|
|
|
bool VisitEachSession(BDiskDeviceVisitor *visitor,
|
|
|
|
BDiskDevice *device = NULL,
|
|
|
|
BSession **session = NULL);
|
2003-02-01 00:17:20 +03:00
|
|
|
bool VisitEachPartition(BDiskDeviceVisitor *visitor,
|
|
|
|
BDiskDevice *device = NULL,
|
|
|
|
BPartition **partition = NULL);
|
|
|
|
bool Traverse(BDiskDeviceVisitor *visitor);
|
|
|
|
|
|
|
|
bool VisitEachMountedPartition(BDiskDeviceVisitor *visitor,
|
|
|
|
BDiskDevice *device = NULL,
|
|
|
|
BPartition **partition = NULL);
|
|
|
|
bool VisitEachMountablePartition(BDiskDeviceVisitor *visitor,
|
|
|
|
BDiskDevice *device = NULL,
|
|
|
|
BPartition **partition = NULL);
|
|
|
|
bool VisitEachInitializablePartition(BDiskDeviceVisitor *visitor,
|
|
|
|
BDiskDevice *device = NULL,
|
|
|
|
BPartition **partition = NULL);
|
|
|
|
|
2003-02-01 01:05:09 +03:00
|
|
|
|
|
|
|
status_t GetDeviceWithID(int32 id, BDiskDevice *device) const;
|
|
|
|
status_t GetSessionWithID(int32 id, BDiskDevice *device,
|
|
|
|
BSession **session) const;
|
|
|
|
status_t GetPartitionWithID(int32 id, BDiskDevice *device,
|
|
|
|
BPartition **partition) const;
|
2003-02-01 00:17:20 +03:00
|
|
|
|
|
|
|
status_t StartWatching(BMessenger target,
|
|
|
|
uint32 eventMask = B_DEVICE_REQUEST_ALL);
|
|
|
|
status_t StopWatching(BMessenger target);
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
// partition and FS add-ons
|
|
|
|
status_t GetNextPartitioningSystem(char *shortName, char *longName = NULL);
|
|
|
|
status_t GetNextFileSystem(char *shortName, char *longName = NULL);
|
|
|
|
status_t RewindPartitiningSystems();
|
|
|
|
status_t RewindFileSystems();
|
|
|
|
|
2003-02-09 02:34:47 +03:00
|
|
|
private:
|
|
|
|
status_t _GetObjectWithID(const char *fieldName, int32 id,
|
|
|
|
BDiskDevice *device) const;
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
// TODO: Introduce iterators instead of these functions.
|
|
|
|
|
|
|
|
static status_t _GetNextAddOn(BDirectory **directory, int32 *index,
|
|
|
|
const char *subdir,
|
|
|
|
BPrivate::AddOnImage *image);
|
|
|
|
static status_t _GetNextAddOn(BDirectory *directory,
|
|
|
|
BPrivate::AddOnImage *image);
|
|
|
|
static status_t _GetNextAddOnDir(BPath *path, int32 *index,
|
|
|
|
const char *subdir);
|
|
|
|
static status_t _GetNextAddOnDir(BDirectory **directory, int32 *index,
|
|
|
|
const char *subdir);
|
|
|
|
|
|
|
|
static status_t _LoadPartitionAddOn(const char *partitioningSystem,
|
|
|
|
BPrivate::AddOnImage *image,
|
|
|
|
BDiskScannerPartitionAddOn **addOn);
|
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
private:
|
2003-02-23 02:50:14 +03:00
|
|
|
friend class BSession;
|
|
|
|
|
2003-02-08 03:39:38 +03:00
|
|
|
BMessenger fManager;
|
|
|
|
int32 fCookie;
|
2003-02-23 02:50:14 +03:00
|
|
|
BDirectory *fPartitionAddOnDir;
|
|
|
|
BDirectory *fFSAddOnDir;
|
|
|
|
int32 fPartitionAddOnDirIndex;
|
|
|
|
int32 fFSAddOnDirIndex;
|
2003-02-01 00:17:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _DISK_DEVICE_ROSTER_H
|