char *user_token;
char *bucket_location;
+ char *storage_class;
char *ca_info;
static DevicePropertyBase device_property_s3_bucket_location;
#define PROPERTY_S3_BUCKET_LOCATION (device_property_s3_bucket_location.ID)
+/* Storage class */
+static DevicePropertyBase device_property_s3_storage_class;
+#define PROPERTY_S3_STORAGE_CLASS (device_property_s3_storage_class.ID)
+
/* Path to certificate authority certificate */
static DevicePropertyBase device_property_ssl_ca_info;
#define PROPERTY_SSL_CA_INFO (device_property_ssl_ca_info.ID)
DevicePropertyBase *base, GValue *val,
PropertySurety surety, PropertySource source);
+static gboolean s3_device_set_storage_class_fn(Device *self,
+ DevicePropertyBase *base, GValue *val,
+ PropertySurety surety, PropertySource source);
+
static gboolean s3_device_set_ca_info_fn(Device *self,
DevicePropertyBase *base, GValue *val,
PropertySurety surety, PropertySource source);
device_property_fill_and_register(&device_property_s3_bucket_location,
G_TYPE_STRING, "s3_bucket_location",
"Location constraint for buckets on Amazon S3");
+ device_property_fill_and_register(&device_property_s3_storage_class,
+ G_TYPE_STRING, "s3_storage_class",
+ "Storage class as specified by Amazon (STANDARD or REDUCED_REDUNDANCY)");
device_property_fill_and_register(&device_property_ssl_ca_info,
G_TYPE_STRING, "ssl_ca_info",
"Path to certificate authority certificate");
&response, PROPERTY_SURETY_GOOD, PROPERTY_SOURCE_DETECTED);
g_value_unset(&response);
+ g_value_init(&response, G_TYPE_BOOLEAN);
+ g_value_set_boolean(&response, TRUE); /* well, there *is* no EOM on S3 .. */
+ device_set_simple_property(dself, PROPERTY_LEOM,
+ &response, PROPERTY_SURETY_GOOD, PROPERTY_SOURCE_DETECTED);
+ g_value_unset(&response);
+
g_value_init(&response, G_TYPE_BOOLEAN);
g_value_set_boolean(&response, FALSE);
device_set_simple_property(dself, PROPERTY_COMPRESSION,
device_simple_property_get_fn,
s3_device_set_bucket_location_fn);
+ device_class_register_property(device_class, PROPERTY_S3_STORAGE_CLASS,
+ PROPERTY_ACCESS_GET_MASK | PROPERTY_ACCESS_SET_BEFORE_START,
+ device_simple_property_get_fn,
+ s3_device_set_storage_class_fn);
+
device_class_register_property(device_class, PROPERTY_SSL_CA_INFO,
PROPERTY_ACCESS_GET_MASK | PROPERTY_ACCESS_SET_BEFORE_START,
device_simple_property_get_fn,
}
amfree(self->bucket_location);
- self->bucket_location = g_value_dup_string(val);
+ self->bucket_location = str_val;
device_clear_volume_details(p_self);
return device_simple_property_set_fn(p_self, base, val, surety, source);
}
static gboolean
-s3_device_set_ca_info_fn(Device *p_self, DevicePropertyBase *base,
+s3_device_set_storage_class_fn(Device *p_self, DevicePropertyBase *base,
GValue *val, PropertySurety surety, PropertySource source)
{
S3Device *self = S3_DEVICE(p_self);
+ char *str_val = g_value_dup_string(val);
- if (!self->use_ssl) {
- device_set_error(p_self, stralloc(_(
- "Path to certificate authority certificate can not be "
- "set if SSL/TLS is not being used.")),
- DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
- }
+ amfree(self->storage_class);
+ self->storage_class = str_val;
+ device_clear_volume_details(p_self);
+
+ return device_simple_property_set_fn(p_self, base, val, surety, source);
+}
+
+static gboolean
+s3_device_set_ca_info_fn(Device *p_self, DevicePropertyBase *base,
+ GValue *val, PropertySurety surety, PropertySource source)
+{
+ S3Device *self = S3_DEVICE(p_self);
amfree(self->ca_info);
self->ca_info = g_value_dup_string(val);
if(self->secret_key) g_free(self->secret_key);
if(self->user_token) g_free(self->user_token);
if(self->bucket_location) g_free(self->bucket_location);
+ if(self->storage_class) g_free(self->storage_class);
if(self->ca_info) g_free(self->ca_info);
}
return FALSE;
}
+ if (!self->use_ssl && self->ca_info) {
+ amfree(self->ca_info);
+ }
+
self->s3 = s3_open(self->access_key, self->secret_key, self->user_token,
- self->bucket_location, self->ca_info);
+ self->bucket_location, self->storage_class, self->ca_info);
if (self->s3 == NULL) {
device_set_error(d_self,
stralloc(_("Internal error creating S3 handle")),
static gboolean
s3_device_finish (Device * pself) {
- if (device_in_error(pself)) return FALSE;
-
/* we're not in a file anymore */
pself->access_mode = ACCESS_NULL;
+ if (device_in_error(pself)) return FALSE;
+
return TRUE;
}