X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device-src%2Fproperty.h;h=1e296e1dd4b487e0aa3a216d1d866a57b14eff63;hb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;hp=8138a05a2ace7662f7949c4ff60c232b57191e9e;hpb=94a044f90357edefa6f4ae9f0b1d5885b0e34aee;p=debian%2Famanda diff --git a/device-src/property.h b/device-src/property.h index 8138a05..1e296e1 100644 --- a/device-src/property.h +++ b/device-src/property.h @@ -1,20 +1,20 @@ /* - * Copyright (c) 2005 Zmanda, Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1 as - * published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but + * Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * Contact information: Zmanda Inc., 505 N Mathlida Ave, Suite 120 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com */ @@ -37,7 +37,7 @@ typedef enum { } PropertyPhaseFlags; #define PROPERTY_PHASE_MASK (PROPERTY_PHASE_MAX-1) -#define PROPERTY_PHASE_SHIFT (PROPERTY_PHASE_MASK/2) +#define PROPERTY_PHASE_SHIFT 8 typedef enum { PROPERTY_ACCESS_GET_BEFORE_START = (PROPERTY_PHASE_BEFORE_START), @@ -63,13 +63,37 @@ typedef enum { #define PROPERTY_ACCESS_GET_MASK (PROPERTY_PHASE_MASK) #define PROPERTY_ACCESS_SET_MASK (PROPERTY_PHASE_MASK << PROPERTY_PHASE_SHIFT) +/* Some properties can only be occasionally (or unreliably) detected, so + * this enum allows the user to override the detected or default + * setting. Surety indicates a level of confidence in the value, while + * source describes how we found out about it. */ +typedef enum { + /* Support is not based on conclusive evidence. */ + PROPERTY_SURETY_BAD, + /* Support is based on conclusive evidence. */ + PROPERTY_SURETY_GOOD, +} PropertySurety; -/* This structure is usually statically allocated. - * It holds information about a property that is common to all devices of - * a given type. */ +typedef enum { + /* property is from default setting. */ + PROPERTY_SOURCE_DEFAULT, + /* property is from device query. */ + PROPERTY_SOURCE_DETECTED, + /* property is from user override (configuration). */ + PROPERTY_SOURCE_USER, +} PropertySource; + +/***** + * Initialization + */ -typedef int DevicePropertyId; +/* This should be called exactly once from device_api_init(). */ +extern void device_property_init(void); +/* This structure is usually statically allocated. It holds information about + * a property that is common across all devices. + */ +typedef guint DevicePropertyId; typedef struct { DevicePropertyId ID; /* Set by device_property_register() */ GType type; @@ -77,24 +101,55 @@ typedef struct { const char *description; } DevicePropertyBase; -/* This structure is usually held inside a Device object. It holds - * information about a property that is specific to the device/medium - * in question. */ -typedef struct { - const DevicePropertyBase *base; - PropertyAccessFlags access; -} DeviceProperty; - /* Registers a new property and returns its ID. This function takes ownership - * of its argument; it must not be freed later. */ + * of its argument; it must not be freed later. It should be called from a + * device driver's registration function. */ extern DevicePropertyId device_property_register(DevicePropertyBase*); -/* This should be called exactly once from device_api_init(). */ -extern void device_property_init(void); +/* Does the same thing, but fills in a new DevicePropertyBase with the given + * values first, and does not return the ID. This is more convenient for + * device-specific properties. */ +extern void device_property_fill_and_register( + DevicePropertyBase * base, + GType type, + const char * name, + const char * desc); /* Gets a DevicePropertyBase from its ID. */ -extern const DevicePropertyBase* device_property_get_by_id(DevicePropertyId); -extern const DevicePropertyBase* device_property_get_by_name(const char*); +DevicePropertyBase* device_property_get_by_id(DevicePropertyId); +DevicePropertyBase* device_property_get_by_name(const char*); + +/***** + * Class-level Property Information + */ + +/* This structure is held inside a Device object. It holds information about a + * property that is specific to the device driver, but not to a specific + * instance of the driver. */ +struct Device; /* forward declaration */ +typedef gboolean (*PropertySetFn)( + struct Device *self, + DevicePropertyBase *base, + GValue *val, + PropertySurety surety, + PropertySource source); +typedef gboolean (*PropertyGetFn)( + struct Device *self, + DevicePropertyBase *base, + GValue *val, + PropertySurety *surety, + PropertySource *source); + +typedef struct { + DevicePropertyBase *base; + PropertyAccessFlags access; + PropertySetFn setter; + PropertyGetFn getter; +} DeviceProperty; + +/***** + * Property-specific Types, etc. + */ /* Standard property value types here. * Important: see property.c for the other half of type declarations.*/ @@ -106,11 +161,6 @@ typedef enum { #define CONCURRENCY_PARADIGM_TYPE concurrency_paradigm_get_type() GType concurrency_paradigm_get_type (void); -typedef enum { - STREAMING_REQUIREMENT_NONE, - STREAMING_REQUIREMENT_DESIRED, - STREAMING_REQUIREMENT_REQUIRED -} StreamingRequirement; #define STREAMING_REQUIREMENT_TYPE streaming_requirement_get_type() GType streaming_requirement_get_type (void); @@ -123,61 +173,6 @@ typedef enum { #define MEDIA_ACCESS_MODE_TYPE media_access_mode_get_type() GType media_access_mode_get_type (void); -/* This one is not a Glibified enum */ -typedef enum { - SIZE_ACCURACY_UNKNOWN, - SIZE_ACCURACY_ESTIMATE, - SIZE_ACCURACY_REAL -} SizeAccuracy; - -/* But SizeAccuracy does apear in this Glibified (gBoxed) struct. */ -typedef struct { - SizeAccuracy accuracy; - guint64 bytes; -} QualifiedSize; -#define QUALIFIED_SIZE_TYPE qualified_size_get_type() -GType qualified_size_get_type (void); - -/* Some features can only be occasionally (or unreliably) detected, so - this enum allows the user to override the detected or default - setting. */ -typedef enum { - /* Feature support status. (exactly one of these is set) */ - /* Feature is supported & will be used */ - FEATURE_STATUS_ENABLED = (1 << 0), - /* Features will not be used. */ - FEATURE_STATUS_DISABLED = (1 << 1), - - /* Feature support confidence. (exactly one of these is set). */ - /* Support is not based on conclusive evidence. */ - FEATURE_SURETY_BAD = (1 << 2), - /* Support is based on conclusive evidence. */ - FEATURE_SURETY_GOOD = (1 << 3), - - /* Source of this information. (exactly one of these is set). */ - /* Source of status is from default setting. */ - FEATURE_SOURCE_DEFAULT = (1 << 4), - /* Source of status is from device query. */ - FEATURE_SOURCE_DETECTED = (1 << 5), - /* Source of status is from user override. */ - FEATURE_SOURCE_USER = (1 << 6), - - FEATURE_SUPPORT_FLAGS_MAX = (1 << 7) -} FeatureSupportFlags; - -#define FEATURE_SUPPORT_FLAGS_MASK (FEATURE_SUPPORT_FLAGS_MAX-1) -#define FEATURE_SUPPORT_FLAGS_STATUS_MASK (FEATURE_STATUS_ENABLED | \ - FEATURE_STATUS_DISABLED) -#define FEATURE_SUPPORT_FLAGS_SURETY_MASK (FEATURE_SURETY_BAD | \ - FEATURE_SURETY_GOOD) -#define FEATURE_SUPPORT_FLAGS_SOURCE_MASK (FEATURE_SOURCE_DEFAULT | \ - FEATURE_SOURCE_DETECTED | \ - FEATURE_SOURCE_USER) -/* Checks that mutually exclusive flags are not set. */ -gboolean feature_support_flags_is_valid(FeatureSupportFlags); -#define FEATURE_SUPPORT_FLAGS_TYPE feature_support_get_type() -GType feature_support_get_type (void); - /* Standard property definitions follow. See also property.c. */ /* Value is a ConcurrencyParadigm */ @@ -185,6 +180,11 @@ extern DevicePropertyBase device_property_concurrency; #define PROPERTY_CONCURRENCY (device_property_concurrency.ID) /* Value is a StreamingRequirement */ +typedef enum { + STREAMING_REQUIREMENT_NONE, + STREAMING_REQUIREMENT_DESIRED, + STREAMING_REQUIREMENT_REQUIRED +} StreamingRequirement; extern DevicePropertyBase device_property_streaming; #define PROPERTY_STREAMING (device_property_streaming.ID) @@ -197,16 +197,22 @@ extern DevicePropertyBase device_property_compression; extern DevicePropertyBase device_property_compression_rate; #define PROPERTY_COMPRESSION_RATE (device_property_compression_rate.ID) -/* Value is a gint, where a negative number indicates variable block size. */ +/* Value is a gint; gives the write block size. */ extern DevicePropertyBase device_property_block_size; #define PROPERTY_BLOCK_SIZE (device_property_block_size.ID) -/* Value is a guint. */ +/* Read-only. Value is a guint. */ extern DevicePropertyBase device_property_min_block_size; extern DevicePropertyBase device_property_max_block_size; #define PROPERTY_MIN_BLOCK_SIZE (device_property_min_block_size.ID) #define PROPERTY_MAX_BLOCK_SIZE (device_property_max_block_size.ID) +/* Value is a guint; gives the minimum buffer size for reads. Only + * the tape device implements this, but it corresponds to the tapetype + * readblocksize parameter, so it's a global property*/ +extern DevicePropertyBase device_property_read_block_size; +#define PROPERTY_READ_BLOCK_SIZE (device_property_read_block_size.ID) + /* Value is a gboolean. */ extern DevicePropertyBase device_property_appendable; #define PROPERTY_APPENDABLE (device_property_appendable.ID) @@ -217,15 +223,15 @@ extern DevicePropertyBase device_property_canonical_name; /* Value is MediaAccessMode. */ extern DevicePropertyBase device_property_medium_access_type; -#define PROPERTY_MEDIUM_TYPE (device_property_medium_access_type.ID) +#define PROPERTY_MEDIUM_ACCESS_TYPE (device_property_medium_access_type.ID) /* Value is a gboolean. */ extern DevicePropertyBase device_property_partial_deletion; #define PROPERTY_PARTIAL_DELETION (device_property_partial_deletion.ID) -/* Value is a QualifiedSize, though the accuracy may be SIZE_ACCURACY_NONE. */ -extern DevicePropertyBase device_property_free_space; -#define PROPERTY_FREE_SPACE (device_property_free_space.ID) +/* Value is a gboolean. */ +extern DevicePropertyBase device_property_full_deletion; +#define PROPERTY_FULL_DELETION (device_property_full_deletion.ID) /* Value is a guint64. On devices that support it, this property will limit the total amount of data written to a volume; attempts to @@ -234,54 +240,17 @@ extern DevicePropertyBase device_property_free_space; extern DevicePropertyBase device_property_max_volume_usage; #define PROPERTY_MAX_VOLUME_USAGE (device_property_max_volume_usage.ID) -/* Tape device properties. These properties do not exist on non-linear - devices. All of them have a value type of FeatureSupportFlags. */ -extern DevicePropertyBase device_property_fsf; -#define PROPERTY_FSF (device_property_fsf.ID) - -extern DevicePropertyBase device_property_bsf; -#define PROPERTY_BSF (device_property_bsf.ID) - -extern DevicePropertyBase device_property_fsr; -#define PROPERTY_FSR (device_property_fsr.ID) - -extern DevicePropertyBase device_property_bsr; -#define PROPERTY_BSR (device_property_bsr.ID) - -/* Is EOM supported? Must be able to read file number afterwards as - well. */ -extern DevicePropertyBase device_property_eom; -#define PROPERTY_EOM (device_property_eom.ID) - -/* Is it necessary to perform a BSF after EOM? */ -extern DevicePropertyBase device_property_bsf_after_eom; -#define PROPERTY_BSF_AFTER_EOM (device_property_bsf_after_eom.ID) - -/* How many filemarks to write at EOD? (Default is 2). - * This property is a G_TYPE_UINT, but can only really be set to 1 or 2. */ -extern DevicePropertyBase device_property_final_filemarks; -#define PROPERTY_FINAL_FILEMARKS (device_property_final_filemarks.ID) - -/* What buffer size is used for reading? */ -extern DevicePropertyBase device_property_read_buffer_size; -#define PROPERTY_READ_BUFFER_SIZE (device_property_read_buffer_size.ID) - -/* Authentication information for Amazon S3. Both of these are strings. */ -extern DevicePropertyBase device_property_s3_secret_key; -extern DevicePropertyBase device_property_s3_access_key; -#define PROPERTY_S3_SECRET_KEY (device_property_s3_secret_key.ID) -#define PROPERTY_S3_ACCESS_KEY (device_property_s3_access_key.ID) - -#ifdef WANT_DEVPAY -/* Same, but for S3 with DevPay. This directory can be relative to the - * config director, or absolute. */ -extern DevicePropertyBase device_property_s3_user_token; -#define PROPERTY_S3_USER_TOKEN (device_property_s3_user_token.ID) -#endif - /* Should the device produce verbose output? Value is a gboolean. Not - * recognized by all devices. */ + * present in all devices. */ extern DevicePropertyBase device_property_verbose; #define PROPERTY_VERBOSE (device_property_verbose.ID) +/* A comment for the use of the user. */ +extern DevicePropertyBase device_property_comment; +#define PROPERTY_COMMENT (device_property_comment.ID) + +/* Does this device support LEOM? */ +extern DevicePropertyBase device_property_leom; +#define PROPERTY_LEOM (device_property_leom.ID) + #endif