mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
support dc_get|set_config("media_quality")
This commit is contained in:
@@ -382,6 +382,14 @@ char* dc_get_blobdir (const dc_context_t* context);
|
|||||||
* >=1=seconds, after which messages are deleted automatically from the server.
|
* >=1=seconds, after which messages are deleted automatically from the server.
|
||||||
* "Saved messages" are deleted from the server as well as
|
* "Saved messages" are deleted from the server as well as
|
||||||
* emails matching the `show_emails` settings above, the UI should clearly point that out.
|
* 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().
|
* 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_ACCEPTED_CONTACTS 1
|
||||||
#define DC_SHOW_EMAILS_ALL 2
|
#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")
|
* Values for dc_get|set_config("key_gen_type")
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ pub enum Config {
|
|||||||
#[strum(props(default = "0"))] // also change ShowEmails.default() on changes
|
#[strum(props(default = "0"))] // also change ShowEmails.default() on changes
|
||||||
ShowEmails,
|
ShowEmails,
|
||||||
|
|
||||||
|
#[strum(props(default = "0"))] // also change MediaQuality.default() on changes
|
||||||
|
MediaQuality,
|
||||||
|
|
||||||
#[strum(props(default = "0"))]
|
#[strum(props(default = "0"))]
|
||||||
KeyGenType,
|
KeyGenType,
|
||||||
|
|
||||||
@@ -248,9 +251,11 @@ mod tests {
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::string::ToString;
|
use std::string::ToString;
|
||||||
|
|
||||||
|
use crate::constants;
|
||||||
use crate::constants::AVATAR_SIZE;
|
use crate::constants::AVATAR_SIZE;
|
||||||
use crate::test_utils::*;
|
use crate::test_utils::*;
|
||||||
use image::GenericImageView;
|
use image::GenericImageView;
|
||||||
|
use num_traits::FromPrimitive;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
@@ -346,4 +351,21 @@ mod tests {
|
|||||||
let avatar_cfg = t.ctx.get_config(Config::Selfavatar);
|
let avatar_cfg = t.ctx.get_config(Config::Selfavatar);
|
||||||
assert_eq!(avatar_cfg, avatar_blob.to_str().map(|s| s.to_string()));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)]
|
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum KeyGenType {
|
pub enum KeyGenType {
|
||||||
|
|||||||
Reference in New Issue
Block a user