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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ b215ee8)
// DO NOT EDIT

use Certificate;
use SignatureStatus;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use libc;
use std::mem;
use std::ptr;

glib_wrapper! {
    /// An object containing useful information about a signature.
    ///
    /// # Implements
    ///
    /// [`SignatureExt`](trait.SignatureExt.html)
    pub struct Signature(Object<ffi::GMimeSignature, ffi::GMimeSignatureClass>);

    match fn {
        get_type => || ffi::g_mime_signature_get_type(),
    }
}

impl Signature {
    /// Creates a new `Signature` object.
    ///
    /// # Returns
    ///
    /// a new `Signature` object.
    pub fn new() -> Signature {
        unsafe {
            from_glib_full(ffi::g_mime_signature_new())
        }
    }
}

impl Default for Signature {
    fn default() -> Self {
        Self::new()
    }
}

/// Trait containing all `Signature` methods.
///
/// # Implementors
///
/// [`Signature`](struct.Signature.html)
pub trait SignatureExt {
    /// Get the signature's certificate.
    ///
    /// # Returns
    ///
    /// the signature's certificate.
    fn get_certificate(&self) -> Option<Certificate>;

    /// Get the creation date of the signature.
    ///
    /// # Returns
    ///
    /// the creation date of the signature or %-1 if unknown.
    fn get_created(&self) -> libc::c_long;

    /// Get the expiration date of the signature.
    ///
    /// # Returns
    ///
    /// the expiration date of the signature or %-1 if unknown.
    fn get_expires(&self) -> libc::c_long;

    /// Get the signature status as a bitfield of `SignatureStatus` flags.
    ///
    /// # Returns
    ///
    /// the signature status.
    fn get_status(&self) -> SignatureStatus;

    /// Set the signature's certificate.
    /// ## `cert`
    /// a `Certificate`
    fn set_certificate(&self, cert: &Certificate);

    /// Set the creation date of the signature.
    /// ## `created`
    /// creation date
    fn set_created(&self, created: libc::c_long);

    /// Set the expiration date of the signature.
    /// ## `expires`
    /// expiration date
    fn set_expires(&self, expires: libc::c_long);

    /// Set the status on the signature.
    /// ## `status`
    /// a `SignatureStatus`
    fn set_status(&self, status: SignatureStatus);
}

impl<O: IsA<Signature>> SignatureExt for O {
    fn get_certificate(&self) -> Option<Certificate> {
        unsafe {
            from_glib_none(ffi::g_mime_signature_get_certificate(self.to_glib_none().0))
        }
    }

    fn get_created(&self) -> libc::c_long {
        unsafe {
            ffi::g_mime_signature_get_created(self.to_glib_none().0)
        }
    }

    fn get_expires(&self) -> libc::c_long {
        unsafe {
            ffi::g_mime_signature_get_expires(self.to_glib_none().0)
        }
    }

    fn get_status(&self) -> SignatureStatus {
        unsafe {
            from_glib(ffi::g_mime_signature_get_status(self.to_glib_none().0))
        }
    }

    fn set_certificate(&self, cert: &Certificate) {
        unsafe {
            ffi::g_mime_signature_set_certificate(self.to_glib_none().0, cert.to_glib_none().0);
        }
    }

    fn set_created(&self, created: libc::c_long) {
        unsafe {
            ffi::g_mime_signature_set_created(self.to_glib_none().0, created);
        }
    }

    fn set_expires(&self, expires: libc::c_long) {
        unsafe {
            ffi::g_mime_signature_set_expires(self.to_glib_none().0, expires);
        }
    }

    fn set_status(&self, status: SignatureStatus) {
        unsafe {
            ffi::g_mime_signature_set_status(self.to_glib_none().0, status.to_glib());
        }
    }
}