1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Contains constructs defined in[`KEMailSettings`][header] header
//!
//! [header]: https://api.kde.org/frameworks/kconfig/html/classKEMailSettings.html

use cpp::{cpp, cpp_class};
use qttypes::{QString, QStringList};

cpp! {{
    #include <KEMailSettings>
}}

#[repr(C)]
pub enum Setting {
    ClientProgram,
    ClientTerminal,
    RealName,
    EmailAddress,
    ReplyToAddress,
    Organization,
    OutServer,
    OutServerLogin,
    OutServerPass,
}

cpp_class!(pub unsafe struct KEMailSettings as "KEMailSettings");

impl KEMailSettings {
    /// Returns the name of the default profile.
    pub fn default_profile_name(&self) -> QString {
        cpp!(unsafe [self as "const KEMailSettings*"] -> QString as "QString" {
            return self->defaultProfileName();
        })
    }

    /// Get one of the predefined "basic" settings.
    /// # Parameters
    /// * `s` = the setting to get
    pub fn get_setting(&self, s: Setting) -> QString {
        cpp!(unsafe [self as "const KEMailSettings*", s as "KEMailSettings::Setting"] -> QString as "QString" {
            return self->getSetting(s);
        })
    }

    /// List of profiles available.
    pub fn profiles(&self) -> QStringList {
        cpp!(unsafe [self as "const KEMailSettings*"] -> QStringList as "QStringList" {
            return self->profiles();
        })
    }

    /// Sets a new default.
    pub fn set_default(&mut self, def: QString) {
        cpp!(unsafe [self as "KEMailSettings*", def as "QString"] {
            self->setDefault(def);
        })
    }

    /// Change the current profile.
    /// # Parameters
    /// * `v` = 	the name of the new profile
    pub fn set_profile(&mut self, v: QString) {
        cpp!(unsafe [self as "KEMailSettings*", v as "QString"] {
            self->setProfile(v);
        })
    }

    /// Set one of the predefined "basic" settings.
    /// # Parameters
    /// * `s` = the setting to set
    /// * `v` = 	the new value of the setting, or `QString::default()` to unset
    pub fn set_setting(&mut self, s: Setting, v: QString) {
        cpp!(unsafe [self as "KEMailSettings*",s as "KEMailSettings::Setting", v as "QString"] {
            self->setSetting(s, v);
        })
    }
}