* 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:
@@ -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
@@ -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
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -27,6 +27,31 @@
|
||||
#endif
|
||||
|
||||
|
||||
static const uint8 kCDIcon[] = {
|
||||
0x6e, 0x63, 0x69, 0x66, 0x05, 0x05, 0x00, 0x02, 0x03, 0x06, 0x05, 0xb8,
|
||||
0x12, 0xa5, 0xbe, 0x03, 0xe1, 0x3d, 0xe7, 0x84, 0xb8, 0x02, 0x10, 0x49,
|
||||
0xf7, 0x9f, 0x49, 0xed, 0xd8, 0x00, 0xf1, 0xf1, 0xf1, 0x36, 0xd9, 0xdd,
|
||||
0xf4, 0x8a, 0x99, 0x96, 0xb9, 0xb4, 0xb8, 0xbe, 0xdb, 0xff, 0xf4, 0xf4,
|
||||
0xf4, 0x04, 0xeb, 0xd0, 0x02, 0x00, 0x06, 0x02, 0x3c, 0x92, 0xc0, 0x38,
|
||||
0x8f, 0x5f, 0xb8, 0x54, 0x50, 0x3c, 0x57, 0x63, 0x48, 0xd8, 0xdf, 0x48,
|
||||
0x89, 0x5b, 0x00, 0x41, 0x37, 0xa9, 0xff, 0xb9, 0xb9, 0xb9, 0x04, 0x01,
|
||||
0x7e, 0x04, 0x02, 0x04, 0x3f, 0x2c, 0x4e, 0x2c, 0x30, 0x2c, 0x22, 0x40,
|
||||
0x22, 0x34, 0x22, 0x4c, 0x3f, 0x54, 0x30, 0x54, 0x4e, 0x54, 0x5c, 0x40,
|
||||
0x5c, 0x4c, 0x5c, 0x34, 0x02, 0x04, 0x3f, 0x3a, 0x43, 0x3a, 0x3b, 0x3a,
|
||||
0x39, 0x3e, 0x39, 0x3c, 0x39, 0x40, 0x3f, 0x42, 0x3b, 0x42, 0x43, 0x42,
|
||||
0x45, 0x3e, 0x45, 0x40, 0x45, 0x3c, 0x02, 0x04, 0x4b, 0x3e, 0x4b, 0x3a,
|
||||
0x4b, 0x42, 0x3f, 0x46, 0x47, 0x46, 0x37, 0x46, 0x33, 0x3e, 0x33, 0x42,
|
||||
0x33, 0x3a, 0x3f, 0xbb, 0xf7, 0x37, 0xbb, 0xf7, 0x47, 0xbb, 0xf7, 0x02,
|
||||
0x04, 0x40, 0x2a, 0x54, 0x2a, 0x50, 0x2c, 0x5c, 0x40, 0x5c, 0x34, 0x5c,
|
||||
0x4c, 0x40, 0x56, 0x50, 0x54, 0x54, 0x56, 0x60, 0x40, 0x60, 0x4c, 0x60,
|
||||
0x34, 0x06, 0x0a, 0x04, 0x01, 0x03, 0x00, 0x0a, 0x00, 0x02, 0x00, 0x01,
|
||||
0x18, 0x15, 0xff, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x00, 0x02, 0x00,
|
||||
0x01, 0x18, 0x00, 0x15, 0x01, 0x17, 0x86, 0x00, 0x04, 0x0a, 0x01, 0x02,
|
||||
0x00, 0x02, 0x00, 0x0a, 0x02, 0x02, 0x02, 0x01, 0x00, 0x0a, 0x03, 0x01,
|
||||
0x02, 0x10, 0x01, 0x17, 0x82, 0x00, 0x04
|
||||
};
|
||||
|
||||
|
||||
static scsi_periph_interface *sSCSIPeripheral;
|
||||
static device_manager_info *sDeviceManager;
|
||||
|
||||
@@ -714,6 +739,27 @@ cd_ioctl(void* cookie, uint32 op, void* buffer, size_t length)
|
||||
return user_memcpy(buffer, &geometry, sizeof(device_geometry));
|
||||
}
|
||||
|
||||
case B_GET_ICON_NAME:
|
||||
return user_strlcpy((char*)buffer, "device-cd", B_FILE_NAME_LENGTH);
|
||||
|
||||
case B_GET_VECTOR_ICON:
|
||||
{
|
||||
device_icon iconData;
|
||||
if (length != sizeof(device_icon))
|
||||
return B_BAD_VALUE;
|
||||
if (user_memcpy(&iconData, buffer, sizeof(device_icon)) != B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
if (iconData.icon_size >= (int32)sizeof(kCDIcon)) {
|
||||
if (user_memcpy(iconData.icon_data, kCDIcon,
|
||||
sizeof(kCDIcon)) != B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
|
||||
iconData.icon_size = sizeof(kCDIcon);
|
||||
return user_memcpy(buffer, &iconData, sizeof(device_icon));
|
||||
}
|
||||
|
||||
case B_GET_ICON:
|
||||
return sSCSIPeripheral->get_icon(icon_type_cd,
|
||||
(device_icon *)buffer);
|
||||
|
||||
@@ -29,6 +29,33 @@
|
||||
#endif
|
||||
|
||||
|
||||
static const uint8 kDriveIcon[] = {
|
||||
0x6e, 0x63, 0x69, 0x66, 0x08, 0x03, 0x01, 0x00, 0x00, 0x02, 0x00, 0x16,
|
||||
0x02, 0x3c, 0xc7, 0xee, 0x38, 0x9b, 0xc0, 0xba, 0x16, 0x57, 0x3e, 0x39,
|
||||
0xb0, 0x49, 0x77, 0xc8, 0x42, 0xad, 0xc7, 0x00, 0xff, 0xff, 0xd3, 0x02,
|
||||
0x00, 0x06, 0x02, 0x3c, 0x96, 0x32, 0x3a, 0x4d, 0x3f, 0xba, 0xfc, 0x01,
|
||||
0x3d, 0x5a, 0x97, 0x4b, 0x57, 0xa5, 0x49, 0x84, 0x4d, 0x00, 0x47, 0x47,
|
||||
0x47, 0xff, 0xa5, 0xa0, 0xa0, 0x02, 0x00, 0x16, 0x02, 0xbc, 0x59, 0x2f,
|
||||
0xbb, 0x29, 0xa7, 0x3c, 0x0c, 0xe4, 0xbd, 0x0b, 0x7c, 0x48, 0x92, 0xc0,
|
||||
0x4b, 0x79, 0x66, 0x00, 0x7d, 0xff, 0xd4, 0x02, 0x00, 0x06, 0x02, 0x38,
|
||||
0xdb, 0xb4, 0x39, 0x97, 0x33, 0xbc, 0x4a, 0x33, 0x3b, 0xa5, 0x42, 0x48,
|
||||
0x6e, 0x66, 0x49, 0xee, 0x7b, 0x00, 0x59, 0x67, 0x56, 0xff, 0xeb, 0xb2,
|
||||
0xb2, 0x03, 0xa7, 0xff, 0x00, 0x03, 0xff, 0x00, 0x00, 0x04, 0x01, 0x80,
|
||||
0x07, 0x0a, 0x06, 0x22, 0x3c, 0x22, 0x49, 0x44, 0x5b, 0x5a, 0x3e, 0x5a,
|
||||
0x31, 0x39, 0x25, 0x0a, 0x04, 0x22, 0x3c, 0x44, 0x4b, 0x5a, 0x31, 0x39,
|
||||
0x25, 0x0a, 0x04, 0x44, 0x4b, 0x44, 0x5b, 0x5a, 0x3e, 0x5a, 0x31, 0x0a,
|
||||
0x04, 0x22, 0x3c, 0x22, 0x49, 0x44, 0x5b, 0x44, 0x4b, 0x08, 0x02, 0x27,
|
||||
0x43, 0xb8, 0x14, 0xc1, 0xf1, 0x08, 0x02, 0x26, 0x43, 0x29, 0x44, 0x0a,
|
||||
0x05, 0x44, 0x5d, 0x49, 0x5d, 0x60, 0x3e, 0x5a, 0x3b, 0x5b, 0x3f, 0x08,
|
||||
0x0a, 0x07, 0x01, 0x06, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x10, 0x01, 0x17,
|
||||
0x84, 0x00, 0x04, 0x0a, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x02, 0x01, 0x02,
|
||||
0x00, 0x0a, 0x03, 0x01, 0x03, 0x00, 0x0a, 0x04, 0x01, 0x04, 0x10, 0x01,
|
||||
0x17, 0x85, 0x20, 0x04, 0x0a, 0x06, 0x01, 0x05, 0x30, 0x24, 0xb3, 0x99,
|
||||
0x01, 0x17, 0x82, 0x00, 0x04, 0x0a, 0x05, 0x01, 0x05, 0x30, 0x20, 0xb2,
|
||||
0xe6, 0x01, 0x17, 0x82, 0x00, 0x04
|
||||
};
|
||||
|
||||
|
||||
static scsi_periph_interface* sSCSIPeripheral;
|
||||
static device_manager_info* sDeviceManager;
|
||||
|
||||
@@ -318,6 +345,30 @@ das_ioctl(void* cookie, uint32 op, void* buffer, size_t length)
|
||||
return user_memcpy(buffer, &geometry, sizeof(device_geometry));
|
||||
}
|
||||
|
||||
case B_GET_ICON_NAME:
|
||||
// TODO: take device type into account!
|
||||
return user_strlcpy((char*)buffer, "device-harddisk",
|
||||
B_FILE_NAME_LENGTH);
|
||||
|
||||
case B_GET_VECTOR_ICON:
|
||||
{
|
||||
// TODO: take device type into account!
|
||||
device_icon iconData;
|
||||
if (length != sizeof(device_icon))
|
||||
return B_BAD_VALUE;
|
||||
if (user_memcpy(&iconData, buffer, sizeof(device_icon)) != B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
if (iconData.icon_size >= (int32)sizeof(kDriveIcon)) {
|
||||
if (user_memcpy(iconData.icon_data, kDriveIcon,
|
||||
sizeof(kDriveIcon)) != B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
|
||||
iconData.icon_size = sizeof(kDriveIcon);
|
||||
return user_memcpy(buffer, &iconData, sizeof(device_icon));
|
||||
}
|
||||
|
||||
case B_GET_ICON:
|
||||
return sSCSIPeripheral->get_icon(info->removable
|
||||
? icon_type_floppy : icon_type_disk, (device_icon *)buffer);
|
||||
|
||||
+130
-51
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku Inc.
|
||||
* Copyright 2002-2008, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Tyler Dauwalder
|
||||
* Ingo Weinhold, [email protected]
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -12,11 +13,18 @@
|
||||
Mime type C functions implementation.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <new>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <fs_attr.h>
|
||||
#include <fs_info.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Drivers.h>
|
||||
#include <Entry.h>
|
||||
#include <IconUtils.h>
|
||||
#include <Mime.h>
|
||||
#include <MimeType.h>
|
||||
#include <mime/database_access.h>
|
||||
@@ -25,9 +33,6 @@
|
||||
#include <Roster.h>
|
||||
#include <RosterPrivate.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
enum {
|
||||
@@ -42,7 +47,7 @@ do_mime_update(int32 what, const char *path, int recursive,
|
||||
{
|
||||
BEntry root;
|
||||
entry_ref ref;
|
||||
|
||||
|
||||
status_t err = root.SetTo(path ? path : "/");
|
||||
if (!err)
|
||||
err = root.GetRef(&ref);
|
||||
@@ -50,7 +55,7 @@ do_mime_update(int32 what, const char *path, int recursive,
|
||||
BMessage msg(what);
|
||||
BMessage reply;
|
||||
status_t result;
|
||||
|
||||
|
||||
// Build and send the message, read the reply
|
||||
if (!err)
|
||||
err = msg.AddRef("entry", &ref);
|
||||
@@ -60,13 +65,13 @@ do_mime_update(int32 what, const char *path, int recursive,
|
||||
err = msg.AddBool("synchronous", synchronous);
|
||||
if (!err)
|
||||
err = msg.AddInt32("force", force);
|
||||
if (!err)
|
||||
if (!err)
|
||||
err = BRoster::Private().SendTo(&msg, &reply, true);
|
||||
if (!err)
|
||||
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||
if (!err)
|
||||
err = reply.FindInt32("result", &result);
|
||||
if (!err)
|
||||
if (!err)
|
||||
err = result;
|
||||
}
|
||||
return err;
|
||||
@@ -106,7 +111,7 @@ update_mime_info(const char *path, int recursive, int synchronous, int force)
|
||||
recursive = true;
|
||||
|
||||
return do_mime_update(B_REG_MIME_UPDATE_MIME_INFO, path, recursive,
|
||||
synchronous, force);
|
||||
synchronous, force);
|
||||
}
|
||||
|
||||
// create_app_meta_mime
|
||||
@@ -139,50 +144,44 @@ create_app_meta_mime(const char *path, int recursive, int synchronous,
|
||||
synchronous, force);
|
||||
}
|
||||
|
||||
// get_device_icon
|
||||
|
||||
/*! Retrieves an icon associated with a given device.
|
||||
\param dev The path to the device.
|
||||
\param icon A pointer to a buffer the icon data shall be written to.
|
||||
\param size The size of the icon. Currently the sizes 16 (small, i.e
|
||||
\c B_MINI_ICON) and 32 (large, i.e. \c B_LARGE_ICON) are
|
||||
supported.
|
||||
|
||||
|
||||
\todo The mounted directories for volumes can also have META:X:STD_ICON
|
||||
attributes. Should those attributes override the icon returned
|
||||
by ioctl(,B_GET_ICON,)?
|
||||
|
||||
|
||||
\return
|
||||
- \c B_OK: Everything went fine.
|
||||
- An error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
get_device_icon(const char *dev, void *icon, int32 size)
|
||||
get_device_icon(const char *device, void *icon, int32 size)
|
||||
{
|
||||
status_t err = dev && icon && (size == B_LARGE_ICON || size == B_MINI_ICON)
|
||||
? B_OK : B_BAD_VALUE;
|
||||
if (device == NULL || icon == NULL
|
||||
|| (size != B_LARGE_ICON && size != B_MINI_ICON))
|
||||
return B_BAD_VALUE;
|
||||
|
||||
int fd = -1;
|
||||
int fd = open(device, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return errno;
|
||||
|
||||
if (!err) {
|
||||
fd = open(dev, O_RDONLY);
|
||||
err = fd != -1 ? B_OK : B_BAD_VALUE;
|
||||
device_icon iconData = {size, icon};
|
||||
if (ioctl(fd, B_GET_ICON, &iconData) != 0) {
|
||||
close(fd);
|
||||
return errno;
|
||||
}
|
||||
if (!err) {
|
||||
device_icon iconData = { size, icon };
|
||||
err = ioctl(fd, B_GET_ICON, &iconData);
|
||||
}
|
||||
if (fd != -1) {
|
||||
// If the file descriptor was open()ed, we need to close it
|
||||
// regardless. Only if we haven't yet encountered any errors
|
||||
// do we make note close()'s return value, however.
|
||||
status_t error = close(fd);
|
||||
if (!err)
|
||||
err = error;
|
||||
}
|
||||
return err;
|
||||
|
||||
close(fd);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// get_device_icon
|
||||
|
||||
/*! Retrieves an icon associated with a given device.
|
||||
\param dev The path to the device.
|
||||
\param icon A pointer to a pre-allocated BBitmap of the correct dimension
|
||||
@@ -190,38 +189,118 @@ get_device_icon(const char *dev, void *icon, int32 size)
|
||||
large icon).
|
||||
\param which Specifies the size of the icon to be retrieved:
|
||||
\c B_MINI_ICON for the mini and \c B_LARGE_ICON for the large icon.
|
||||
|
||||
|
||||
\todo The mounted directories for volumes can also have META:X:STD_ICON
|
||||
attributes. Should those attributes override the icon returned
|
||||
by ioctl(,B_GET_ICON,)?
|
||||
|
||||
|
||||
\return
|
||||
- \c B_OK: Everything went fine.
|
||||
- An error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
get_device_icon(const char *dev, BBitmap *icon, icon_size which)
|
||||
get_device_icon(const char *device, BBitmap *icon, icon_size which)
|
||||
{
|
||||
// check parameters
|
||||
status_t error = (dev && icon ? B_OK : B_BAD_VALUE);
|
||||
if (device == NULL || icon == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BRect rect;
|
||||
if (error == B_OK) {
|
||||
if (which == B_MINI_ICON)
|
||||
rect.Set(0, 0, 15, 15);
|
||||
else if (which == B_LARGE_ICON)
|
||||
rect.Set(0, 0, 31, 31);
|
||||
else
|
||||
error = B_BAD_VALUE;
|
||||
if (which == B_MINI_ICON)
|
||||
rect.Set(0, 0, 15, 15);
|
||||
else if (which == B_LARGE_ICON)
|
||||
rect.Set(0, 0, 31, 31);
|
||||
else
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (icon->Bounds() != rect)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
uint8* data;
|
||||
size_t size;
|
||||
type_code type;
|
||||
status_t status = get_device_icon(device, &data, &size, &type);
|
||||
if (status == B_OK) {
|
||||
status = BIconUtils::GetVectorIcon(data, size, icon);
|
||||
delete[] data;
|
||||
return status;
|
||||
}
|
||||
|
||||
// Vector icon was not available, try old one
|
||||
|
||||
// check whether icon size and bitmap dimensions do match
|
||||
if (error == B_OK
|
||||
&& (icon->Bounds() != rect || icon->ColorSpace() != B_CMAP8)) {
|
||||
error = B_BAD_VALUE;
|
||||
if (icon->Bounds() != rect || icon->ColorSpace() != B_CMAP8)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
void* iconData = icon->Bits();
|
||||
size_t iconSize = icon->BitsLength();
|
||||
|
||||
if (icon->ColorSpace() != B_CMAP8) {
|
||||
iconSize = (size_t)which * (size_t)which;
|
||||
iconData = malloc(iconSize);
|
||||
if (iconData == NULL)
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
// TODO: support bitmap with other color spaces!
|
||||
|
||||
// get the icon
|
||||
if (error == B_OK)
|
||||
error = get_device_icon(dev, icon->Bits(), which);
|
||||
return error;
|
||||
status = get_device_icon(device, iconData, which);
|
||||
if (status == B_OK && iconData != icon->Bits())
|
||||
icon->SetBits(iconData, iconSize, 0, B_CMAP8);
|
||||
|
||||
if (iconData != icon->Bits())
|
||||
free(iconData);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_device_icon(const char *device, uint8** _data, size_t* _size,
|
||||
type_code* _type)
|
||||
{
|
||||
if (device == NULL || _data == NULL || _size == NULL || _type == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
int fd = open(device, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return errno;
|
||||
|
||||
// TODO: support B_GET_ICON_NAME!
|
||||
#if 0
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
if (ioctl(fd, B_GET_ICON_NAME, name) == 0) {
|
||||
close(fd);
|
||||
return B_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8 data[8192];
|
||||
device_icon iconData = {sizeof(data), data};
|
||||
status_t status = ioctl(fd, B_GET_VECTOR_ICON, &iconData,
|
||||
sizeof(device_icon));
|
||||
if (status != 0)
|
||||
status = errno;
|
||||
|
||||
if (status == B_OK) {
|
||||
*_data = new(std::nothrow) uint8[iconData.icon_size];
|
||||
if (*_data == NULL)
|
||||
status = B_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (status == B_OK) {
|
||||
if (iconData.icon_size > (int32)sizeof(data)) {
|
||||
iconData.icon_data = *_data;
|
||||
status = ioctl(fd, B_GET_VECTOR_ICON, &iconData,
|
||||
sizeof(device_icon));
|
||||
if (status != 0)
|
||||
status = errno;
|
||||
} else
|
||||
memcpy(*_data, data, iconData.icon_size);
|
||||
|
||||
*_size = iconData.icon_size;
|
||||
*_type = B_VECTOR_ICON_TYPE;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return status;
|
||||
}
|
||||
|
||||
+49
-37
@@ -1,11 +1,12 @@
|
||||
// ----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// File Name: Volume.cpp
|
||||
//
|
||||
// Description: BVolume class
|
||||
// ----------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2002-2008, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Tyler Dauwalder
|
||||
* Ingo Weinhold
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file Volume.h
|
||||
BVolume implementation.
|
||||
@@ -25,17 +26,14 @@
|
||||
#include <syscalls.h>
|
||||
|
||||
#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
|
||||
#include <fs_interface.h>
|
||||
# include <fs_interface.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class BVolume
|
||||
\brief Represents a disk volume
|
||||
|
||||
|
||||
Provides an interface for querying information about a volume.
|
||||
|
||||
The class is a simple wrapper for a \c dev_t and the function
|
||||
@@ -44,7 +42,7 @@ namespace OpenBeOS {
|
||||
|
||||
\author Vincent Dominguez
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
|
||||
@@ -115,7 +113,7 @@ BVolume::~BVolume()
|
||||
*/
|
||||
status_t
|
||||
BVolume::InitCheck(void) const
|
||||
{
|
||||
{
|
||||
return fCStatus;
|
||||
}
|
||||
|
||||
@@ -140,7 +138,7 @@ BVolume::SetTo(dev_t device)
|
||||
error = errno;
|
||||
}
|
||||
// set the new value
|
||||
if (error == B_OK)
|
||||
if (error == B_OK)
|
||||
fDevice = device;
|
||||
// set the init status variable
|
||||
fCStatus = error;
|
||||
@@ -163,7 +161,7 @@ BVolume::Unset()
|
||||
or -1, if the object is not properly initialized.
|
||||
*/
|
||||
dev_t
|
||||
BVolume::Device() const
|
||||
BVolume::Device() const
|
||||
{
|
||||
return fDevice;
|
||||
}
|
||||
@@ -334,18 +332,36 @@ status_t
|
||||
BVolume::GetIcon(BBitmap *icon, icon_size which) const
|
||||
{
|
||||
// check initialization
|
||||
status_t error = (InitCheck() == B_OK ? B_OK : B_BAD_VALUE);
|
||||
// get FS stat
|
||||
if (InitCheck() != B_OK)
|
||||
return B_NO_INIT;
|
||||
|
||||
// get FS stat for the device name
|
||||
fs_info info;
|
||||
if (error == B_OK && fs_stat_dev(fDevice, &info) != 0)
|
||||
error = errno;
|
||||
if (fs_stat_dev(fDevice, &info) != 0)
|
||||
return errno;
|
||||
|
||||
// get the icon
|
||||
if (error == B_OK)
|
||||
error = get_device_icon(info.device_name, icon, which);
|
||||
return error;
|
||||
return get_device_icon(info.device_name, icon, which);
|
||||
}
|
||||
|
||||
// IsRemovable
|
||||
|
||||
status_t
|
||||
BVolume::GetIcon(uint8** _data, size_t* _size, type_code* _type) const
|
||||
{
|
||||
// check initialization
|
||||
if (InitCheck() != B_OK)
|
||||
return B_NO_INIT;
|
||||
|
||||
// get FS stat for the device name
|
||||
fs_info info;
|
||||
if (fs_stat_dev(fDevice, &info) != 0)
|
||||
return errno;
|
||||
|
||||
// get the icon
|
||||
return get_device_icon(info.device_name, _data, _size, _type);
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Returns whether the volume is removable.
|
||||
\return \c true, when the object is properly initialized and the
|
||||
referred to volume is removable, \c false otherwise.
|
||||
@@ -516,16 +532,12 @@ BVolume::operator=(const BVolume &volume)
|
||||
}
|
||||
|
||||
|
||||
// FBC
|
||||
void BVolume::_TurnUpTheVolume1() {}
|
||||
void BVolume::_TurnUpTheVolume2() {}
|
||||
void BVolume::_TurnUpTheVolume3() {}
|
||||
void BVolume::_TurnUpTheVolume4() {}
|
||||
void BVolume::_TurnUpTheVolume5() {}
|
||||
void BVolume::_TurnUpTheVolume6() {}
|
||||
void BVolume::_TurnUpTheVolume7() {}
|
||||
// FBC
|
||||
void BVolume::_TurnUpTheVolume1() {}
|
||||
void BVolume::_TurnUpTheVolume2() {}
|
||||
void BVolume::_TurnUpTheVolume3() {}
|
||||
void BVolume::_TurnUpTheVolume4() {}
|
||||
void BVolume::_TurnUpTheVolume5() {}
|
||||
void BVolume::_TurnUpTheVolume6() {}
|
||||
void BVolume::_TurnUpTheVolume7() {}
|
||||
void BVolume::_TurnUpTheVolume8() {}
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -384,29 +384,58 @@ BPartition::GetVolume(BVolume* volume) const
|
||||
status_t
|
||||
BPartition::GetIcon(BBitmap* icon, icon_size which) const
|
||||
{
|
||||
/*
|
||||
status_t error = (icon ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
if (IsMounted()) {
|
||||
// mounted: get the icon from the volume
|
||||
BVolume volume;
|
||||
error = GetVolume(&volume);
|
||||
if (icon == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
status_t error;
|
||||
|
||||
if (IsMounted()) {
|
||||
// mounted: get the icon from the volume
|
||||
BVolume volume;
|
||||
error = GetVolume(&volume);
|
||||
if (error == B_OK)
|
||||
error = volume.GetIcon(icon, which);
|
||||
} else {
|
||||
// not mounted: retrieve the icon ourselves
|
||||
if (BDiskDevice* device = Device()) {
|
||||
BPath path;
|
||||
error = device->GetPath(&path);
|
||||
// get the icon
|
||||
if (error == B_OK)
|
||||
error = volume.GetIcon(icon, which);
|
||||
} else {
|
||||
// not mounted: retrieve the icon ourselves
|
||||
if (BDiskDevice* device = Device()) {
|
||||
// get the icon
|
||||
if (error == B_OK)
|
||||
error = get_device_icon(device->Path(), icon, which);
|
||||
} else
|
||||
error = B_ERROR;
|
||||
}
|
||||
error = get_device_icon(path.Path(), icon, which);
|
||||
} else
|
||||
error = B_ERROR;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPartition::GetIcon(uint8** _data, size_t* _size, type_code* _type) const
|
||||
{
|
||||
if (_data == NULL || _size == NULL || _type == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
status_t error;
|
||||
|
||||
if (IsMounted()) {
|
||||
// mounted: get the icon from the volume
|
||||
BVolume volume;
|
||||
error = GetVolume(&volume);
|
||||
if (error == B_OK)
|
||||
error = volume.GetIcon(_data, _size, _type);
|
||||
} else {
|
||||
// not mounted: retrieve the icon ourselves
|
||||
if (BDiskDevice* device = Device()) {
|
||||
BPath path;
|
||||
error = device->GetPath(&path);
|
||||
// get the icon
|
||||
if (error == B_OK)
|
||||
error = get_device_icon(path.Path(), _data, _size, _type);
|
||||
} else
|
||||
error = B_ERROR;
|
||||
}
|
||||
return error;
|
||||
*/
|
||||
// not implemented
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1168,7 +1197,7 @@ BPartition::CanCreateChild() const
|
||||
|
||||
// GetChildCreationParameterEditor
|
||||
status_t
|
||||
BPartition::GetChildCreationParameterEditor(const char* type,
|
||||
BPartition::GetChildCreationParameterEditor(const char* type,
|
||||
BDiskDeviceParameterEditor** editor) const
|
||||
{
|
||||
if (!fDelegate)
|
||||
|
||||
@@ -126,7 +126,7 @@ AddMenuItemVisitor::Visit(BPartition *partition, int32 level)
|
||||
|
||||
// get icon
|
||||
BBitmap *icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1),
|
||||
B_CMAP8);
|
||||
B_RGBA32);
|
||||
if (partition->GetIcon(icon, B_MINI_ICON) != B_OK) {
|
||||
delete icon;
|
||||
icon = NULL;
|
||||
|
||||
Reference in New Issue
Block a user