diff options
| author | Max Audron <audron@cocaine.farm> | 2021-12-02 18:40:38 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2021-12-02 18:44:46 +0100 |
| commit | 459944eaa35223f2094a9f61c04dea48e58b6367 (patch) | |
| tree | 713c339d865788dcf402bf3196fc2bce7d910cd7 | |
| parent | upgrade to rust 2021 edition (diff) | |
add certmanager impl
| -rw-r--r-- | src/message/signalproxy/objects/certmanager.rs | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/src/message/signalproxy/objects/certmanager.rs b/src/message/signalproxy/objects/certmanager.rs index d105fcf..c82d06c 100644 --- a/src/message/signalproxy/objects/certmanager.rs +++ b/src/message/signalproxy/objects/certmanager.rs @@ -1,26 +1,50 @@ -use libquassel_derive::NetworkList; +use libquassel_derive::{NetworkList, NetworkMap}; -#[derive(Debug, Clone, PartialEq, NetworkList)] +use crate::message::Syncable; +#[allow(unused_imports)] +use crate::primitive::Variant; + +#[derive(Debug, Clone, PartialEq, NetworkList, NetworkMap)] pub struct CertManager { #[network(rename = "sslKey", variant = "ByteArray")] pub ssl_key: String, #[network(rename = "sslCert", variant = "ByteArray")] pub ssl_cert: String, - // // C->S calls - - // /** - // * Replaces all properties of the object with the content of the - // * "properties" parameter. This parameter is in network representation. - // */ - // requestUpdate(properties: QVariantMap) - - // // S->C calls - - // setSslCert(encoded: QByteBuffer | null) - // setSslKey(encoded: QByteBuffer | null) - // /** - // * Replaces all properties of the object with the content of the - // * "properties" parameter. This parameter is in network representation. - // */ - // update(properties: QVariantMap) +} + +impl CertManager { + pub fn set_ssl_cert(&mut self, cert: String) { + #[cfg(feature = "server")] + self.send_sync("setSslCert", vec![Variant::ByteArray(cert.clone())]); + + self.ssl_cert = cert; + } + + pub fn set_ssl_key(&mut self, key: String) { + #[cfg(feature = "server")] + self.send_sync("setSslKey", vec![Variant::ByteArray(key.clone())]); + + self.ssl_key = key; + } +} + +#[cfg(feature = "client")] +impl crate::message::StatefulSyncableClient for CertManager { + fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) + where + Self: Sized, + { + match msg.slot_name.as_str() { + "setSslCert" => self.set_ssl_cert(get_param!(msg)), + "setSslKey" => self.set_ssl_key(get_param!(msg)), + _ => (), + } + } +} + +#[cfg(feature = "server")] +impl crate::message::StatefulSyncableServer for CertManager {} + +impl Syncable for CertManager { + const CLASS: &'static str = "CertManager"; } |
