* Added two new ways to retrieve an icon from a device:

- B_GET_ICON_NAME: returns the name of an icon. This will then be read from
    a predefined location on disk (not yet implemented). This would also allow
    to add specifiers like "-boot", or "-fat|bfs|ntfs|...", and have special
    icons for those.
  - B_GET_VECTOR_ICON: retrieves the vector icon of a device, if any.
* get_device_icon(BBitmap*, ...) now supports other color spaces than B_CMAP8.
* Added get_device_icon(), BPartition::GetIcon(), and BVolume::GetIcon()
  variants that can also retrieve the icon data directly (like
  BNodeInfo::GetIcon()).
* Reenabled the previous BPartition::GetIcon(), based on a patch by
  Justin O'Dell - this fixes #1391.
* Tracker's MountMenu class now uses B_RGBA32 icons, instead of B_CMAP8.
* Added vector icon to scsi_disk, and scsi_cd. The former doesn't have any
  special removable icon, though.
* Header cleanup, added/updated license, whitespace cleanup.
* Marked deprecated/obsolete driver ioctls in Drivers.h.
* Removed OpenBeOS namespace in the headers I touched that still had them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27001 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-08-17 11:27:07 +00:00
parent 9ad1415ecb
commit 06ba3f0acb
10 changed files with 464 additions and 308 deletions
+58 -98
View File
@@ -1,46 +1,46 @@
/*
* Copyright 2002-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _DRIVERS_DRIVERS_H
#define _DRIVERS_DRIVERS_H
#include <BeBuild.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <SupportDefs.h>
#include <BeBuild.h>
#include <Select.h>
#include <SupportDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ---
these hooks are how the kernel accesses the device
--- */
typedef status_t (*device_open_hook) (const char *name, uint32 flags, void **cookie);
typedef status_t (*device_close_hook) (void *cookie);
typedef status_t (*device_free_hook) (void *cookie);
typedef status_t (*device_control_hook) (void *cookie, uint32 op, void *data,
size_t len);
typedef status_t (*device_read_hook) (void *cookie, off_t position, void *data,
size_t *numBytes);
typedef status_t (*device_write_hook) (void *cookie, off_t position,
const void *data, size_t *numBytes);
typedef status_t (*device_select_hook) (void *cookie, uint8 event, uint32 ref,
selectsync *sync);
typedef status_t (*device_deselect_hook) (void *cookie, uint8 event,
selectsync *sync);
typedef status_t (*device_read_pages_hook)(void *cookie, off_t position, const iovec *vec,
size_t count, size_t *_numBytes);
typedef status_t (*device_write_pages_hook) (void *cookie, off_t position, const iovec *vec,
size_t count, size_t *_numBytes);
/* These hooks are how the kernel accesses legacy devices */
typedef status_t (*device_open_hook)(const char *name, uint32 flags,
void **cookie);
typedef status_t (*device_close_hook)(void *cookie);
typedef status_t (*device_free_hook)(void *cookie);
typedef status_t (*device_control_hook)(void *cookie, uint32 op, void *data,
size_t len);
typedef status_t (*device_read_hook)(void *cookie, off_t position, void *data,
size_t *numBytes);
typedef status_t (*device_write_hook)(void *cookie, off_t position,
const void *data, size_t *numBytes);
typedef status_t (*device_select_hook)(void *cookie, uint8 event, uint32 ref,
selectsync *sync);
typedef status_t (*device_deselect_hook)(void *cookie, uint8 event,
selectsync *sync);
typedef status_t (*device_read_pages_hook)(void *cookie, off_t position,
const iovec *vec, size_t count, size_t *_numBytes);
typedef status_t (*device_write_pages_hook)(void *cookie, off_t position,
const iovec *vec, size_t count, size_t *_numBytes);
#define B_CUR_DRIVER_API_VERSION 2
/* ---
the device_hooks structure is a descriptor for the device, giving its
entry points.
--- */
/* Legacy driver device hooks */
typedef struct {
device_open_hook open; /* called to open the device */
device_close_hook close; /* called to close the device */
@@ -50,55 +50,43 @@ typedef struct {
device_write_hook write; /* writes to the device */
device_select_hook select; /* start select */
device_deselect_hook deselect; /* stop select */
device_read_pages_hook read_pages; /* scatter-gather physical read from the device */
device_write_pages_hook write_pages; /* scatter-gather physical write to the device */
device_read_pages_hook read_pages;
/* scatter-gather physical read from the device */
device_write_pages_hook write_pages;
/* scatter-gather physical write to the device */
} device_hooks;
/* Driver functions needed to be exported by legacy drivers */
status_t init_hardware(void);
const char **publish_devices(void);
device_hooks *find_device(const char *name);
const char** publish_devices(void);
device_hooks* find_device(const char* name);
status_t init_driver(void);
void uninit_driver(void);
void uninit_driver(void);
extern int32 api_version;
enum {
B_GET_DEVICE_SIZE = 1, /* get # bytes */
/* returns size_t in *data */
B_SET_DEVICE_SIZE, /* set # bytes */
/* passed size_t in *data */
B_GET_DEVICE_SIZE = 1, /* get # bytes - returns size_t in *data */
B_SET_DEVICE_SIZE, /* set # bytes - passes size_t in *data */
B_SET_NONBLOCKING_IO, /* set to non-blocking i/o */
B_SET_BLOCKING_IO, /* set to blocking i/o */
B_GET_READ_STATUS, /* check if can read w/o blocking */
/* returns bool in *data */
/* returns bool in *data */
B_GET_WRITE_STATUS, /* check if can write w/o blocking */
/* returns bool in *data */
/* returns bool in *data */
B_GET_GEOMETRY, /* get info about device geometry */
/* returns struct geometry in *data */
B_GET_DRIVER_FOR_DEVICE, /* get the path of the executable serving that device */
/* returns struct geometry in *data */
B_GET_DRIVER_FOR_DEVICE, /* get the path of the executable serving */
/* that device */
B_GET_PARTITION_INFO, /* get info about a device partition */
/* returns struct partition_info in *data */
B_SET_PARTITION, /* create a user-defined partition */
/* returns struct partition_info in *data */
B_SET_PARTITION, /* obsolete, will be removed */
B_FORMAT_DEVICE, /* low-level device format */
B_EJECT_DEVICE, /* eject the media if supported */
B_GET_ICON, /* return device icon (see struct below) */
B_GET_BIOS_GEOMETRY, /* get info about device geometry */
/* as reported by the bios */
/* returns struct geometry in *data */
B_GET_MEDIA_STATUS, /* get status of media. */
/* return status_t in *data: */
/* B_NO_ERROR: media ready */
@@ -109,21 +97,18 @@ enum {
/* B_DEV_MEDIA_CHANGE_REQUESTED: user */
/* pressed button on drive */
/* B_DEV_DOOR_OPEN: door open */
B_LOAD_MEDIA, /* load the media if supported */
B_GET_BIOS_DRIVE_ID, /* get bios id for this device */
B_SET_UNINTERRUPTABLE_IO, /* prevent cntl-C from interrupting i/o */
B_SET_INTERRUPTABLE_IO, /* allow cntl-C to interrupt i/o */
B_FLUSH_DRIVE_CACHE, /* flush drive cache */
B_GET_PATH_FOR_DEVICE, /* get the absolute path of the device */
B_GET_ICON_NAME, /* get an icon name identifier */
B_GET_VECTOR_ICON, /* retrieves the device's vector icon */
B_GET_NEXT_OPEN_DEVICE = 1000, /* iterate through open devices */
B_ADD_FIXED_DRIVER, /* private */
B_REMOVE_FIXED_DRIVER, /* private */
B_GET_NEXT_OPEN_DEVICE = 1000, /* obsolete, will be removed */
B_ADD_FIXED_DRIVER, /* obsolete, will be removed */
B_REMOVE_FIXED_DRIVER, /* obsolete, will be removed */
B_AUDIO_DRIVER_BASE = 8000, /* base for codes in audio_driver.h */
B_MIDI_DRIVER_BASE = 8100, /* base for codes in midi_driver.h */
@@ -133,10 +118,7 @@ enum {
B_DEVICE_OP_CODES_END = 9999 /* end of Be-defined contol id's */
};
/* ---
geometry structure for the B_GET_GEOMETRY opcode
--- */
/* B_GET_GEOMETRY data structure */
typedef struct {
uint32 bytes_per_sector; /* sector size in bytes */
uint32 sectors_per_track; /* # sectors per track */
@@ -148,12 +130,6 @@ typedef struct {
bool write_once; /* non-zero if write-once */
} device_geometry;
/* ---
Be-defined device types returned by B_GET_GEOMETRY. Use these if it makes
sense for your device.
--- */
enum {
B_DISK = 0, /* Hard disks, floppy disks, etc. */
B_TAPE, /* Tape drives */
@@ -168,10 +144,7 @@ enum {
};
/* ---
partition_info structure used by B_GET_PARTITION_INFO and B_SET_PARTITION
--- */
/* B_GET_PARTITION_INFO data structure */
typedef struct {
off_t offset; /* offset (in bytes) */
off_t size; /* size (in bytes) */
@@ -181,30 +154,17 @@ typedef struct {
char device[256]; /* path to the physical device */
} partition_info;
/* ---
driver_path structure returned by the B_GET_DRIVER_FOR_DEVICE
--- */
/* B_GET_DRIVER_FOR_DEVICE data structure */
typedef char driver_path[256];
/* ---
open_device_iterator structure used by the B_GET_NEXT_OPEN_DEVICE opcode
--- */
/* B_GET_ICON, and B_GET_VECTOR_ICON data structure */
typedef struct {
uint32 cookie; /* must be set to 0 before iterating */
char device[256]; /* device path */
} open_device_iterator;
/* ---
icon structure for the B_GET_ICON opcode
--- */
typedef struct {
int32 icon_size; /* icon size requested */
void *icon_data; /* where to put 'em (usually BBitmap->Bits()) */
int32 icon_size;
/* B_GET_VECTOR_ICON: size of the data buffer in icon_data */
/* B_GET_ICON: size of the icon in pixels */
void *icon_data;
} device_icon;
+24 -33
View File
@@ -1,37 +1,18 @@
/*
* Copyright 2004-2006, Haiku Inc. All Rights Reserved.
/*
* Copyright 2004-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
/*!
\file Mime.h
Mime type C functions interface declarations.
*/
#ifndef _MIME_H
#define _MIME_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <sys/types.h>
#include <SupportDefs.h>
#include <StorageDefs.h>
// C functions
#ifdef __cplusplus
extern "C" {
#endif
int update_mime_info(const char *path, int recursive, int synchronous,
int force);
status_t create_app_meta_mime(const char *path, int recursive, int synchronous,
int force);
status_t get_device_icon(const char *dev, void *icon, int32 size);
static const uint32 B_MIME_STRING_TYPE = 'MIMS';
static const uint32 B_MIME_STRING_TYPE = 'MIMS';
enum icon_size {
B_LARGE_ICON = 32,
@@ -45,22 +26,32 @@ enum {
B_UPDATE_MIME_INFO_FORCE_UPDATE_ALL = 2,
};
// C functions
#ifdef __cplusplus
}
extern "C" {
#endif
// Haiku only!
int update_mime_info(const char* path, int recursive, int synchronous,
int force);
status_t create_app_meta_mime(const char* path, int recursive, int synchronous,
int force);
status_t get_device_icon(const char* device, void* icon, int32 size);
#ifdef __cplusplus
}
// C++ functions, Haiku only!
class BBitmap;
status_t get_device_icon(const char *dev, BBitmap *icon, icon_size which);
status_t get_device_icon(const char* device, BBitmap* icon, icon_size which);
status_t get_device_icon(const char* device, uint8** _data, size_t* _size,
type_code* _type);
#endif
// include the C++ API
#ifdef __cplusplus
#include <MimeType.h>
#endif
// include MimeType.h for convenience
# include <MimeType.h>
#endif // __cplusplus
#endif // _MIME_H
+43 -57
View File
@@ -1,18 +1,11 @@
// ----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// File Name: Directory.cpp
//
// Description: BVolume class
// ----------------------------------------------------------------------
/*!
\file Volume.h
BVolume interface declarations.
*/
/*
* Copyright 2002-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _VOLUME_H
#define _VOLUME_H
#include <sys/types.h>
#include <fs_info.h>
@@ -20,67 +13,60 @@
#include <StorageDefs.h>
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BDirectory;
class BBitmap;
class BVolume {
public:
BVolume();
BVolume(dev_t dev);
BVolume(const BVolume &vol);
virtual ~BVolume();
BVolume();
BVolume(dev_t device);
BVolume(const BVolume& volume);
virtual ~BVolume();
status_t InitCheck() const;
status_t SetTo(dev_t dev);
void Unset();
status_t InitCheck() const;
status_t SetTo(dev_t device);
void Unset();
dev_t Device() const;
dev_t Device() const;
status_t GetRootDirectory(BDirectory *directory) const;
status_t GetRootDirectory(BDirectory* directory) const;
off_t Capacity() const;
off_t FreeBytes() const;
off_t Capacity() const;
off_t FreeBytes() const;
status_t GetName(char *name) const;
status_t SetName(const char *name);
status_t GetName(char* name) const;
status_t SetName(const char* name);
status_t GetIcon(BBitmap *icon, icon_size which) const;
status_t GetIcon(BBitmap* icon, icon_size which) const;
status_t GetIcon(uint8** _data, size_t* _size,
type_code* _type) const;
bool IsRemovable() const;
bool IsReadOnly() const;
bool IsPersistent() const;
bool IsShared() const;
bool KnowsMime() const;
bool KnowsAttr() const;
bool KnowsQuery() const;
bool IsRemovable() const;
bool IsReadOnly() const;
bool IsPersistent() const;
bool IsShared() const;
bool KnowsMime() const;
bool KnowsAttr() const;
bool KnowsQuery() const;
bool operator==(const BVolume &volume) const;
bool operator!=(const BVolume &volume) const;
BVolume &operator=(const BVolume &volume);
bool operator==(const BVolume& volume) const;
bool operator!=(const BVolume& volume) const;
BVolume& operator=(const BVolume& volume);
private:
// friend class BVolumeRoster;
virtual void _TurnUpTheVolume1();
virtual void _TurnUpTheVolume2();
virtual void _TurnUpTheVolume3();
virtual void _TurnUpTheVolume4();
virtual void _TurnUpTheVolume5();
virtual void _TurnUpTheVolume6();
virtual void _TurnUpTheVolume7();
virtual void _TurnUpTheVolume8();
virtual void _TurnUpTheVolume1();
virtual void _TurnUpTheVolume2();
virtual void _TurnUpTheVolume3();
virtual void _TurnUpTheVolume4();
virtual void _TurnUpTheVolume5();
virtual void _TurnUpTheVolume6();
virtual void _TurnUpTheVolume7();
virtual void _TurnUpTheVolume8();
dev_t fDevice;
status_t fCStatus;
int32 _reserved[8];
dev_t fDevice;
status_t fCStatus;
int32 _reserved[8];
};
#ifdef USE_OPENBEOS_NAMESPACE
} // namespace OpenBeOS
#endif
#endif // _VOLUME_H
+12 -10
View File
@@ -38,7 +38,7 @@ public:
uint32 BlockSize() const;
int32 Index() const; // 0 for devices
uint32 Status() const;
bool ContainsFileSystem() const;
bool ContainsPartitioningSystem() const;
@@ -47,8 +47,8 @@ public:
bool IsMounted() const;
bool IsBusy() const;
uint32 Flags() const;
uint32 Flags() const;
const char* Name() const;
const char* ContentName() const;
const char* Type() const; // See DiskDeviceTypes.h
@@ -58,10 +58,12 @@ public:
const char* ContentParameters() const;
status_t GetDiskSystem(BDiskSystem* diskSystem) const;
virtual status_t GetPath(BPath* path) const;
status_t GetVolume(BVolume* volume) const;
status_t GetIcon(BBitmap* icon, icon_size which) const;
status_t GetIcon(uint8** _data, size_t* _size,
type_code* _type) const;
status_t GetMountPoint(BPath* mountPoint) const;
dev_t Mount(const char* mountPoint = NULL,
@@ -80,7 +82,7 @@ public:
status_t GetPartitioningInfo(
BPartitioningInfo* info) const;
BPartition* VisitEachChild(BDiskDeviceVisitor* visitor)
const;
virtual BPartition* VisitEachDescendant(
@@ -90,7 +92,7 @@ public:
bool CanDefragment(bool* whileMounted = NULL) const;
status_t Defragment() const;
bool CanRepair(bool checkOnly,
bool* whileMounted = NULL) const;
status_t Repair(bool checkOnly) const;
@@ -149,14 +151,14 @@ public:
bool CanInitialize(const char* diskSystem) const;
status_t GetInitializationParameterEditor(
const char* system,
const char* system,
BDiskDeviceParameterEditor** editor) const;
status_t ValidateInitialize(const char* diskSystem,
BString* name, const char* parameters);
status_t Initialize(const char* diskSystem,
const char* name, const char* parameters);
status_t Uninitialize();
// Modification of child partitions
bool CanCreateChild() const;
@@ -170,10 +172,10 @@ public:
const char* type, const char* name,
const char* parameters,
BPartition** child = NULL);
bool CanDeleteChild(int32 index) const;
status_t DeleteChild(int32 index);
private:
class Delegate;