diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 10154b71a..5bc9f3112 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -382,6 +382,14 @@ char* dc_get_blobdir (const dc_context_t* context); * >=1=seconds, after which messages are deleted automatically from the server. * "Saved messages" are deleted from the server as well as * emails matching the `show_emails` settings above, the UI should clearly point that out. + * - `media_quality` = DC_MEDIA_QUALITY_BALANCED (0) = + * good outgoing images/videos/voice quality at reasonable sizes (default) + * DC_MEDIA_QUALITY_WORSE (1) + * allow worse images/videos/voice quality to gain smaller sizes, + * suitable for providers or areas known to have a bad connection. + * In contrast to other options, the implementation of this option is currently up to the UIs; + * this may change in future, however, + * having the option in the core allows provider-specific-defaults already today. * * If you want to retrieve a value, use dc_get_config(). * @@ -4492,6 +4500,14 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot); #define DC_SHOW_EMAILS_ACCEPTED_CONTACTS 1 #define DC_SHOW_EMAILS_ALL 2 + +/* + * Values for dc_get|set_config("media_quality") + */ +#define DC_MEDIA_QUALITY_BALANCED 0 +#define DC_MEDIA_QUALITY_WORSE 1 + + /* * Values for dc_get|set_config("key_gen_type") */ diff --git a/src/config.rs b/src/config.rs index 203bdab0a..7abf10b2f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,6 +65,9 @@ pub enum Config { #[strum(props(default = "0"))] // also change ShowEmails.default() on changes ShowEmails, + #[strum(props(default = "0"))] // also change MediaQuality.default() on changes + MediaQuality, + #[strum(props(default = "0"))] KeyGenType, @@ -248,9 +251,11 @@ mod tests { use std::str::FromStr; use std::string::ToString; + use crate::constants; use crate::constants::AVATAR_SIZE; use crate::test_utils::*; use image::GenericImageView; + use num_traits::FromPrimitive; use std::fs::File; use std::io::Write; @@ -346,4 +351,21 @@ mod tests { let avatar_cfg = t.ctx.get_config(Config::Selfavatar); assert_eq!(avatar_cfg, avatar_blob.to_str().map(|s| s.to_string())); } + + #[test] + fn test_media_quality_config_option() { + let t = dummy_context(); + let media_quality = t.ctx.get_config_int(Config::MediaQuality); + assert_eq!(media_quality, 0); + let media_quality = constants::MediaQuality::from_i32(media_quality).unwrap_or_default(); + assert_eq!(media_quality, constants::MediaQuality::Balanced); + + t.ctx.set_config(Config::MediaQuality, Some("1")).unwrap(); + + let media_quality = t.ctx.get_config_int(Config::MediaQuality); + assert_eq!(media_quality, 1); + assert_eq!(constants::MediaQuality::Worse as i32, 1); + let media_quality = constants::MediaQuality::from_i32(media_quality).unwrap_or_default(); + assert_eq!(media_quality, constants::MediaQuality::Worse); + } } diff --git a/src/constants.rs b/src/constants.rs index 64ce2cd59..dbdad54db 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -57,6 +57,19 @@ impl Default for ShowEmails { } } +#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] +#[repr(u8)] +pub enum MediaQuality { + Balanced = 0, + Worse = 1, +} + +impl Default for MediaQuality { + fn default() -> Self { + MediaQuality::Balanced // also change Config.MediaQuality props(default) on changes + } +} + #[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] #[repr(u8)] pub enum KeyGenType {