From c63d5e6db9bbf50ebd73a297905bd436774ea974 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 26 Sep 2020 13:05:32 +0200 Subject: split signalproxy.rs --- src/message/signalproxy/heartbeat.rs | 65 +++++++++++++++++++ src/message/signalproxy/initdata.rs | 41 ++++++++++++ src/message/signalproxy/initrequest.rs | 37 +++++++++++ src/message/signalproxy/mod.rs | 110 +++++++++++++++++++++++++++++++++ src/message/signalproxy/rpccall.rs | 38 ++++++++++++ src/message/signalproxy/syncmessage.rs | 44 +++++++++++++ 6 files changed, 335 insertions(+) create mode 100644 src/message/signalproxy/heartbeat.rs create mode 100644 src/message/signalproxy/initdata.rs create mode 100644 src/message/signalproxy/initrequest.rs create mode 100644 src/message/signalproxy/mod.rs create mode 100644 src/message/signalproxy/rpccall.rs create mode 100644 src/message/signalproxy/syncmessage.rs (limited to 'src/message/signalproxy') diff --git a/src/message/signalproxy/heartbeat.rs b/src/message/signalproxy/heartbeat.rs new file mode 100644 index 0000000..46bfd51 --- /dev/null +++ b/src/message/signalproxy/heartbeat.rs @@ -0,0 +1,65 @@ +use crate::message::MessageType; +use crate::primitive::{DateTime, Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct HeartBeat { + timestamp: DateTime, +} + +impl Serialize for HeartBeat { + fn serialize(&self) -> Result, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::HeartBeat as i32)); + res.push(Variant::DateTime(self.timestamp.clone())); + + res.serialize() + } +} + +impl Deserialize for HeartBeat { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + timestamp: match_variant!(res.remove(0), Variant::DateTime), + }, + )) + } +} + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct HeartBeatReply { + timestamp: DateTime, +} + +impl Serialize for HeartBeatReply { + fn serialize(&self) -> Result, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::HeartBeatReply as i32)); + res.push(Variant::DateTime(self.timestamp.clone())); + + res.serialize() + } +} + +impl Deserialize for HeartBeatReply { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + timestamp: match_variant!(res.remove(0), Variant::DateTime), + }, + )) + } +} diff --git a/src/message/signalproxy/initdata.rs b/src/message/signalproxy/initdata.rs new file mode 100644 index 0000000..e4fb077 --- /dev/null +++ b/src/message/signalproxy/initdata.rs @@ -0,0 +1,41 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct InitData { + class_name: String, + object_name: String, + init_data: VariantList, +} + +impl Serialize for InitData { + fn serialize(&self) -> Result, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::InitData as i32)); + res.push(Variant::StringUTF8(self.class_name.clone())); + res.push(Variant::StringUTF8(self.object_name.clone())); + + res.append(&mut self.init_data.clone()); + + res.serialize() + } +} + +impl Deserialize for InitData { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + class_name: match_variant!(res.remove(0), Variant::StringUTF8), + object_name: match_variant!(res.remove(0), Variant::StringUTF8), + init_data: res, + }, + )) + } +} diff --git a/src/message/signalproxy/initrequest.rs b/src/message/signalproxy/initrequest.rs new file mode 100644 index 0000000..def314a --- /dev/null +++ b/src/message/signalproxy/initrequest.rs @@ -0,0 +1,37 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct InitRequest { + class_name: String, + object_name: String, +} + +impl Serialize for InitRequest { + fn serialize(&self) -> Result, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::InitRequest as i32)); + res.push(Variant::StringUTF8(self.class_name.clone())); + res.push(Variant::StringUTF8(self.object_name.clone())); + + res.serialize() + } +} + +impl Deserialize for InitRequest { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + class_name: match_variant!(res.remove(0), Variant::StringUTF8), + object_name: match_variant!(res.remove(0), Variant::StringUTF8), + }, + )) + } +} diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs new file mode 100644 index 0000000..b0fd9ea --- /dev/null +++ b/src/message/signalproxy/mod.rs @@ -0,0 +1,110 @@ +use crate::{Deserialize, Serialize}; + +mod heartbeat; +mod initdata; +mod initrequest; +mod rpccall; +mod syncmessage; + +pub use heartbeat::*; +pub use initdata::*; +pub use initrequest::*; +pub use rpccall::*; +pub use syncmessage::*; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub enum Message { + /// Bidirectional + SyncMessage(SyncMessage), + /// Bidirectional + RpcCall(RpcCall), + InitRequest(InitRequest), + InitData(InitData), + /// Bidirectional + HeartBeat(HeartBeat), + /// Bidirectional + HeartBeatReply(HeartBeatReply), +} + +impl Serialize for Message { + fn serialize(&self) -> Result, failure::Error> { + match &self { + Message::SyncMessage(value) => value.serialize(), + Message::RpcCall(value) => value.serialize(), + Message::InitRequest(value) => value.serialize(), + Message::InitData(value) => value.serialize(), + Message::HeartBeat(value) => value.serialize(), + Message::HeartBeatReply(value) => value.serialize(), + } + } +} + +impl Deserialize for Message { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (_, message_type) = i32::parse(&b[9..13])?; + + match MessageType::from(message_type) { + MessageType::SyncMessage => { + let (size, res) = SyncMessage::parse(&b)?; + + Ok((size, Message::SyncMessage(res))) + } + MessageType::RpcCall => { + let (size, res) = RpcCall::parse(&b)?; + + Ok((size, Message::RpcCall(res))) + } + MessageType::InitRequest => { + let (size, res) = InitRequest::parse(&b)?; + + Ok((size, Message::InitRequest(res))) + } + MessageType::InitData => { + let (size, res) = InitData::parse(&b)?; + + Ok((size, Message::InitData(res))) + } + MessageType::HeartBeat => { + let (size, res) = HeartBeat::parse(&b)?; + + Ok((size, Message::HeartBeat(res))) + } + MessageType::HeartBeatReply => { + let (size, res) = HeartBeatReply::parse(&b)?; + + Ok((size, Message::HeartBeatReply(res))) + } + } + } +} + +/// Type of an SignalProxy Message +/// The first element in the VariantList that is received +#[repr(i32)] +#[derive(Copy, Clone, Debug, std::cmp::PartialEq)] +pub enum MessageType { + /// Bidirectional + SyncMessage = 0x00000001, + /// Bidirectional + RpcCall = 0x00000002, + InitRequest = 0x00000003, + InitData = 0x00000004, + /// Bidirectional + HeartBeat = 0x00000005, + /// Bidirectional + HeartBeatReply = 0x00000006, +} + +impl From for MessageType { + fn from(val: i32) -> Self { + match val { + 0x00000001 => MessageType::SyncMessage, + 0x00000002 => MessageType::RpcCall, + 0x00000003 => MessageType::InitRequest, + 0x00000004 => MessageType::InitData, + 0x00000005 => MessageType::HeartBeat, + 0x00000006 => MessageType::HeartBeatReply, + _ => unimplemented!(), + } + } +} diff --git a/src/message/signalproxy/rpccall.rs b/src/message/signalproxy/rpccall.rs new file mode 100644 index 0000000..748b226 --- /dev/null +++ b/src/message/signalproxy/rpccall.rs @@ -0,0 +1,38 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct RpcCall { + slot_name: String, + params: VariantList, +} + +impl Serialize for RpcCall { + fn serialize(&self) -> Result, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::RpcCall as i32)); + res.push(Variant::StringUTF8(self.slot_name.clone())); + + res.append(&mut self.params.clone()); + + res.serialize() + } +} + +impl Deserialize for RpcCall { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + slot_name: match_variant!(res.remove(0), Variant::StringUTF8), + params: res, + }, + )) + } +} diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs new file mode 100644 index 0000000..fe69cf1 --- /dev/null +++ b/src/message/signalproxy/syncmessage.rs @@ -0,0 +1,44 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct SyncMessage { + class_name: String, + object_name: String, + slot_name: String, + params: VariantList, +} + +impl Serialize for SyncMessage { + fn serialize(&self) -> Result, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::SyncMessage as i32)); + res.push(Variant::StringUTF8(self.class_name.clone())); + res.push(Variant::StringUTF8(self.object_name.clone())); + res.push(Variant::StringUTF8(self.slot_name.clone())); + + res.append(&mut self.params.clone()); + + res.serialize() + } +} + +impl Deserialize for SyncMessage { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + class_name: match_variant!(res.remove(0), Variant::StringUTF8), + object_name: match_variant!(res.remove(0), Variant::StringUTF8), + slot_name: match_variant!(res.remove(0), Variant::StringUTF8), + params: res, + }, + )) + } +} -- cgit v1.2.3 From fd943651195a970aac2b066e3bdbb23253f73ce7 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Fri, 16 Oct 2020 21:58:05 +0200 Subject: update --- .gitignore | 1 + Cargo.lock | 1111 --------------------- Cargo.toml | 4 - examples/client.rs | 386 ------- src/bin/quassel-client.rs | 37 - src/client/mod.rs | 30 +- src/lib.rs | 2 + src/message/signalproxy/mod.rs | 14 + src/message/signalproxy/objects/aliasmanager.rs | 46 + src/message/signalproxy/objects/backlogmanager.rs | 161 +++ src/message/signalproxy/objects/mod.rs | 6 + src/message/signalproxy/rpccall.rs | 45 +- src/message/signalproxy/syncmessage.rs | 2 + src/session/mod.rs | 2 + 14 files changed, 294 insertions(+), 1553 deletions(-) delete mode 100644 Cargo.lock delete mode 100644 examples/client.rs delete mode 100644 src/bin/quassel-client.rs create mode 100644 src/message/signalproxy/objects/aliasmanager.rs create mode 100644 src/message/signalproxy/objects/backlogmanager.rs create mode 100644 src/message/signalproxy/objects/mod.rs create mode 100644 src/session/mod.rs (limited to 'src/message/signalproxy') diff --git a/.gitignore b/.gitignore index 53eaa21..aa085cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +Cargo.lock /target **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 57ed5b7..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,1111 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" - -[[package]] -name = "arc-swap" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62" - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "backtrace" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "base-x" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bumpalo" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] -name = "bytes" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" - -[[package]] -name = "cc" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "core-foundation" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" - -[[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - -[[package]] -name = "either" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" - -[[package]] -name = "failure" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "flate2" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" -dependencies = [ - "cfg-if", - "crc32fast", - "futures 0.1.29", - "libc", - "miniz_oxide", - "tokio-io", -] - -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - -[[package]] -name = "futures" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" - -[[package]] -name = "futures-executor" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" - -[[package]] -name = "futures-macro" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" - -[[package]] -name = "futures-task" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" - -[[package]] -name = "futures-util" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hermit-abi" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15" -dependencies = [ - "libc", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" - -[[package]] -name = "libquassel" -version = "0.1.0" -dependencies = [ - "byteorder", - "bytes 0.5.4", - "either", - "failure", - "flate2", - "futures 0.3.4", - "futures-util", - "log", - "native-tls", - "time", - "tokio", - "tokio-test", - "tokio-tls", - "tokio-util", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "miniz_oxide" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" -dependencies = [ - "adler32", -] - -[[package]] -name = "mio" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.1", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" -dependencies = [ - "log", - "mio", - "miow 0.3.3", - "winapi 0.3.8", -] - -[[package]] -name = "mio-uds" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "miow" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -dependencies = [ - "socket2", - "winapi 0.3.8", -] - -[[package]] -name = "native-tls" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.8", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "openssl" -version = "0.10.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7717097d810a0f2e2323f9e5d11e71608355e24828410b55b9d4f18aa5f9a5d8" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "proc-macro-hack" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" - -[[package]] -name = "proc-macro-nested" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" - -[[package]] -name = "proc-macro2" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "remove_dir_all" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -dependencies = [ - "winapi 0.3.8", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" - -[[package]] -name = "schannel" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19" -dependencies = [ - "lazy_static", - "winapi 0.3.8", -] - -[[package]] -name = "security-framework" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f331b9025654145cd425b9ded0caf8f5ae0df80d418b326e2dc1c3dc5eb0620" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" - -[[package]] -name = "serde_derive" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - -[[package]] -name = "signal-hook-registry" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" -dependencies = [ - "arc-swap", - "libc", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "socket2" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.8", -] - -[[package]] -name = "standback" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e4b8c631c998468961a9ea159f064c5c8499b95b5e4a34b77849d45949d540" - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - -[[package]] -name = "syn" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.8", -] - -[[package]] -name = "time" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6b5580a7510e7f3c6f199c1cd448515063f7056f026fe42e930c11d97c83e83" -dependencies = [ - "cfg-if", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi 0.3.8", -] - -[[package]] -name = "time-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ae9b6e9f095bc105e183e3cd493d72579be3181ad4004fceb01adbe9eecab2d" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", -] - -[[package]] -name = "tokio" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d9c43f1bb96970e153bcbae39a65e249ccb942bd9d36dbdf086024920417c9c" -dependencies = [ - "bytes 0.5.4", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "libc", - "memchr", - "mio", - "mio-named-pipes", - "mio-uds", - "num_cpus", - "pin-project-lite", - "signal-hook-registry", - "slab", - "tokio-macros", - "winapi 0.3.8", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", -] - -[[package]] -name = "tokio-macros" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-test" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0049c119b6d505c4447f5c64873636c7af6c75ab0d45fd9f618d82acb8016d" -dependencies = [ - "bytes 0.5.4", - "futures-core", - "tokio", -] - -[[package]] -name = "tokio-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" -dependencies = [ - "bytes 0.5.4", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "vcpkg" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" - -[[package]] -name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasm-bindgen" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/Cargo.toml b/Cargo.toml index 3052afc..2b6ccaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,3 @@ flate2 = { version = "1.0", features = ["tokio"] } tokio = { version = "0.2", features = ["full"] } tokio-util = { version = "0.2", features = ["codec"] } tokio-test = { version = "0.2" } - -[[bin]] -name = "quassel-client" -required-features = ["client"] diff --git a/examples/client.rs b/examples/client.rs deleted file mode 100644 index 082719f..0000000 --- a/examples/client.rs +++ /dev/null @@ -1,386 +0,0 @@ -use failure::Error; - -extern crate libquassel; - -extern crate tokio; -extern crate pretty_env_logger; - -use libquassel::primitive::*; -use libquassel::message::*; -use libquassel::client::*; - -use tokio::io::{AsyncRead, AsyncWrite}; -use core::marker::Unpin; -use futures::SinkExt; -use std::future::Future; - -use log::*; - -// struct Client { -// stream: Frame, -// } - -#[tokio::main] -async fn main() -> Result<(), Error> { - pretty_env_logger::init(); - - let username = std::env::args().nth(1).expect("no username given"); - let password = std::env::args().nth(2).expect("no password given"); - - - let mut client = Client::>::connect_tls( - "cocaine.farm", - 4242, - true, - User { - name: username, - password, - }, - ).await.unwrap(); - - client.run().await; - - Ok(()) -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // let funcs = Funcs { - // init: InitFuncs { - // client_init_ack, - // client_init_reject, - // client_login_ack, - // client_login_reject, - // session_init - // }, - // message: MessageFuncs { - // sync_message, - // rpc_call, - // init_request, - // init_data, - // heart_beat, - // heart_beat_reply - // } - // }; - -// async fn client_init_ack(client: &mut Client, item: VariantMap) { -// use libquassel::{HandshakeSerialize, HandshakeDeserialize}; -// -// info!(target: "init", "Initialization successfull"); -// info!(target: "login", "Starting Login"); -// let login = ClientLogin {user: client.user.name.clone(), password: client.user.password.clone()}; -// client.stream.send(login.serialize().unwrap()).await.unwrap(); -// } -// -// async fn client_init_reject(client: Client, item: VariantMap) { -// error!(target: "init", "Initialization failed: {:?}", item); -// } -// -// async fn client_login_ack(client: Client, item: VariantMap) { -// info!(target: "login", "Login successfull"); -// } -// -// async fn client_login_reject(client: Client, item: VariantMap) { -// error!(target: "login", "Login failed: {:?}", item); -// } -// -// async fn session_init(client: &mut Client, item: VariantMap) { -// info!(target: "login", "Session Initialization finished. Switching to Connected state"); -// client.state = ClientState::Connected; -// } -// -// async fn sync_message(client: Client, item: SyncMessage) { unimplemented!() } -// async fn rpc_call(client: Client, item: RpcCall) { unimplemented!() } -// async fn init_request(client: Client, item: InitRequest) { unimplemented!() } -// async fn init_data(client: Client, item: InitData) { unimplemented!() } -// async fn heart_beat(client: Client, item: HeartBeat) { unimplemented!() } -// async fn heart_beat_reply(client: Client, item: HeartBeatReply) { unimplemented!() } - -// //use std::io::BufWriter; -// use std::result::Result; -// use std::vec::Vec; -// -// use tokio::io::{AsyncRead, AsyncWrite}; -// use core::marker::Unpin; -// use tokio::net::TcpStream; -// use tokio::prelude::*; -// -// use native_tls::TlsConnector; -// -// use tokio_tls; -// use tokio_tls::TlsStream; -// use tokio_util::codec::Framed; -// use futures_util::stream::StreamExt; -// use futures::SinkExt; -// use std::future::Future; -// -// use crate::frame::QuasselCodec; -// -// use failure::Error; -// -// use log::{trace, debug, info, error}; -// -// use crate::message::*; -// use crate::primitive::*; -// -// extern crate log; -// -// pub struct Client -// where -// T: 'static + AsyncRead + AsyncWrite + Unpin, -// { -// pub stream: Framed, -// pub tls: bool, -// pub compression: bool, -// pub state: ClientState, -// pub user: User, -// } -// -// pub struct User { -// pub name: String, -// pub password: String, -// } -// -// pub enum ClientState { -// Handshake, -// Connected, -// } -// -// impl Client { -// pub async fn run(&mut self) { -// use crate::primitive::StringList; -// use crate::message::ClientInit; -// use crate::HandshakeSerialize; -// -// info!(target: "init", "Setting Features"); -// -// let mut features = StringList::new(); -// features.push("SynchronizedMarkerLine".to_string()); -// features.push("Authenticators".to_string()); -// features.push("ExtendedFeatures".to_string()); -// features.push("BufferActivitySync".to_string()); -// let client_init = ClientInit { -// client_version:String::from("Rust 0.0.0"), -// client_date: String::from("1579009211"), -// feature_list: features, -// client_features: 0x00008000, -// }; -// -// self.stream.send(client_init.serialize().unwrap()).await.unwrap(); -// -// // Start event loop -// while let Some(msg) = self.stream.next().await { -// let msg = msg.unwrap(); -// match self.state { -// ClientState::Handshake => handle_login_message(self, &msg).await.unwrap(), -// ClientState::Connected => handle_message(self, &msg).await.unwrap(), -// } -// }; -// } -// -// pub async fn connect( -// address: &'static str, -// port: u64, -// compression: bool, -// user: User, -// funcs: Funcs -// ) -> Result, Error> { -// let mut stream = TcpStream::connect(format!("{}:{}", address, port)).await?; -// -// info!(target: "init", "Establishing Connection"); -// let connack = init(&mut stream, false, compression).await?; -// -// debug!(target: "init", "{:?}", connack); -// -// let codec = QuasselCodec::builder() -// .compression(compression) -// .new_codec(); -// -// let framed_stream = Framed::new(stream, codec); -// -// info!(target: "init", "Established Connection"); -// -// return Ok(Client { -// stream: framed_stream, -// tls: false, -// compression, -// state: ClientState::Handshake, -// user, -// funcs, -// }); -// } -// -// pub async fn connect_tls( -// address: &'static str, -// port: u64, -// compression: bool, -// user: User, -// funcs: Funcs, impl Future> -// ) -> Result, impl Future>, Error> { -// let mut stream: TcpStream = TcpStream::connect(format!("{}:{}", address, port)).await?; -// -// info!(target: "init", "Establishing Connection"); -// let connack = init(&mut stream, true, compression).await?; -// -// debug!(target: "init", "{:?}", connack); -// -// let codec = QuasselCodec::builder() -// .compression(compression) -// .new_codec(); -// -// let tls_connector = tokio_tls::TlsConnector::from(TlsConnector::builder().build().unwrap()); -// -// let tls_stream = tls_connector.connect(address, stream).await?; -// -// let framed_stream = Framed::new(tls_stream, codec); -// -// info!(target: "init", "Established Connection"); -// -// return Ok(Client { -// stream: framed_stream, -// tls: true, -// compression, -// state: ClientState::Handshake, -// user, -// funcs, -// }); -// } -// -// } -// -// pub async fn handle_login_message(client: &mut Client, buf: &[u8]) -> Result<(), Error> { -// use crate::{HandshakeSerialize, HandshakeDeserialize}; -// use crate::message::ClientLogin; -// use crate::primitive::{VariantMap, Variant}; -// -// trace!(target: "message", "Received bytes: {:x?}", buf); -// let (_, res) = VariantMap::parse(buf)?; -// debug!(target: "init", "Received Messsage: {:#?}", res); -// -// let msgtype = match_variant!(&res["MsgType"], Variant::String); -// match msgtype.as_str() { -// "ClientInitAck" => { -// info!(target: "init", "Initialization successfull"); -// info!(target: "login", "Starting Login"); -// let login = ClientLogin {user: client.user.name.clone(), password: client.user.password.clone()}; -// client.stream.send(login.serialize()?).await?; -// }, -// "ClientInitReject" => { -// error!(target: "init", "Initialization failed: {:?}", res); -// }, -// "ClientLoginAck" => { -// info!(target: "login", "Login successfull"); -// }, -// "SessionInit" => { -// info!(target: "login", "Session Initialization finished. Switching to Connected state"); -// client.state = ClientState::Connected; -// } -// "ClientLoginReject" => { -// error!(target: "login", "Login failed: {:?}", res); -// }, -// _ => { -// error!(target: "client", "Error: WrongMsgType: {:#?}", res); -// } -// } -// -// return Ok(()); -// } -// -// pub async fn handle_message(client: &mut Client, buf: &[u8]) -> Result<(), Error> { -// use crate::message::Message; -// use crate::primitive::VariantList; -// use crate::Deserialize; -// use crate::Serialize; -// -// trace!(target: "message", "Received bytes: {:x?}", buf); -// let (_, res) = Message::parse(buf)?; -// debug!(target: "init", "Received Messsage: {:#?}", res); -// -// match res { -// Message::SyncMessage(_) => {} -// Message::RpcCall(_) => {} -// Message::InitRequest(_) => {} -// Message::InitData(_) => {} -// Message::HeartBeat(_) => {} -// Message::HeartBeatReply(_) => {} -// } -// -// return Ok(()); -// } -// -// pub struct Funcs -// where -// T: 'static + AsyncRead + AsyncWrite + Unpin, -// F: std::future::Future, -// { -// pub init: InitFuncs, -// pub message: MessageFuncs, -// } -// -// pub struct InitFuncs -// where -// T: 'static + AsyncRead + AsyncWrite + Unpin, -// F: std::future::Future, -// { -// pub client_init_ack: fn(&mut Client, VariantMap) -> F, -// pub client_init_reject: fn(Client, VariantMap) -> F, -// pub client_login_ack: fn(Client, VariantMap) -> F, -// pub client_login_reject: fn(Client, VariantMap) -> F, -// pub session_init: fn(&mut Client, VariantMap) -> F, -// } -// -// pub struct MessageFuncs -// where -// T: 'static + AsyncRead + AsyncWrite + Unpin, -// F: std::future::Future, -// { -// pub sync_message: fn(Client, SyncMessage) -> F, -// pub rpc_call: fn(Client, RpcCall) -> F, -// pub init_request: fn(Client, InitRequest) -> F, -// pub init_data: fn(Client, InitData) -> F, -// pub heart_beat: fn(Client, HeartBeat) -> F, -// pub heart_beat_reply: fn(Client, HeartBeatReply) -> F, -// } diff --git a/src/bin/quassel-client.rs b/src/bin/quassel-client.rs deleted file mode 100644 index 233d3ae..0000000 --- a/src/bin/quassel-client.rs +++ /dev/null @@ -1,37 +0,0 @@ -use failure::Error; - -extern crate libquassel; -use libquassel::client; - -extern crate tokio; -extern crate pretty_env_logger; - -#[tokio::main] -async fn main() -> Result<(), Error> { - pretty_env_logger::init(); - -// let mut client = client::Client::::connect( -// "cocaine.farm", -// 4242, -// true, -// ).await.unwrap(); - - let username = std::env::args().nth(1).expect("no username given"); - let password = std::env::args().nth(2).expect("no password given"); - - - let mut client = client::Client::>::connect_tls( - "cocaine.farm", - 4242, - true, - client::User { - name: username, - password: password, - } - ).await.unwrap(); - - client.run().await; -// client.login("audron", "audron", client_init); - - Ok(()) -} // the stream is closed here diff --git a/src/client/mod.rs b/src/client/mod.rs index 9f0d66c..1b6139f 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -31,6 +31,11 @@ pub struct Client { pub compression: bool, pub state: ClientState, pub user: User, + pub funcs: Funcs, +} + +pub struct Funcs { + pub rpc_call: crate::message::RpcCallClient, } pub struct User { @@ -75,7 +80,7 @@ impl Client { }; } - pub async fn connect(address: &'static str, port: u64, compression: bool, user: User) -> Result, Error> { + pub async fn connect(address: &'static str, port: u64, compression: bool, user: User, funcs: Funcs) -> Result, Error> { let mut stream = TcpStream::connect(format!("{}:{}", address, port)).await?; info!(target: "init", "Establishing Connection"); @@ -97,10 +102,11 @@ impl Client { compression, state: ClientState::Handshake, user, + funcs, }); } - pub async fn connect_tls(address: &'static str, port: u64, compression: bool, user: User) -> Result>, Error> { + pub async fn connect_tls(address: &'static str, port: u64, compression: bool, user: User, funcs: Funcs) -> Result>, Error> { let mut stream: TcpStream = TcpStream::connect(format!("{}:{}", address, port)).await?; info!(target: "init", "Establishing Connection"); @@ -126,6 +132,7 @@ impl Client { compression, state: ClientState::Handshake, user, + funcs, }); } @@ -171,7 +178,7 @@ pub async fn handle_login_message(client: &mu pub async fn handle_message(client: &mut Client, buf: &[u8]) -> Result<(), Error> { use crate::message::Message; - use crate::primitive::VariantList; + use crate::primitive::{VariantList, Variant}; use crate::Deserialize; use crate::Serialize; @@ -179,6 +186,23 @@ pub async fn handle_message(client: &mut Clie let (_, res) = Message::parse(buf)?; debug!(target: "init", "Received Messsage: {:#?}", res); + match res { + Message::SyncMessage(_) => {} + Message::RpcCall(msg) => { + match msg.slot_name.as_str() { + "2displayMsg(Message)" => { + (client.funcs.rpc_call.display_message)(match_variant!(msg.params[0], Variant::Message)); + }, + _ => {}, + } + + } + Message::InitRequest(_) => {} + Message::InitData(_) => {} + Message::HeartBeat(_) => {} + Message::HeartBeatReply(_) => {} + } + return Ok(()); } diff --git a/src/lib.rs b/src/lib.rs index 215dcfc..a11ccf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,8 @@ extern crate failure; pub mod message; pub mod primitive; +pub mod session; + #[allow(dead_code)] pub mod error; diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs index b0fd9ea..b69c6b0 100644 --- a/src/message/signalproxy/mod.rs +++ b/src/message/signalproxy/mod.rs @@ -3,6 +3,7 @@ use crate::{Deserialize, Serialize}; mod heartbeat; mod initdata; mod initrequest; +mod objects; mod rpccall; mod syncmessage; @@ -26,6 +27,19 @@ pub enum Message { HeartBeatReply(HeartBeatReply), } +// impl Message { +// fn act(&self) { +// match &self { +// Message::SyncMessage(value) => value.serialize(), +// Message::RpcCall(value) => value.serialize(), +// Message::InitRequest(value) => value.serialize(), +// Message::InitData(value) => value.serialize(), +// Message::HeartBeat(value) => value.serialize(), +// Message::HeartBeatReply(value) => value.serialize(), +// } +// } +// } + impl Serialize for Message { fn serialize(&self) -> Result, failure::Error> { match &self { diff --git a/src/message/signalproxy/objects/aliasmanager.rs b/src/message/signalproxy/objects/aliasmanager.rs new file mode 100644 index 0000000..7e9cfca --- /dev/null +++ b/src/message/signalproxy/objects/aliasmanager.rs @@ -0,0 +1,46 @@ +use crate::primitive::{Variant, VariantMap}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct AliasManager { + pub aliases: Vec, +} + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct Alias { + name: String, + expansion: String, +} + +// impl AliasManager { +// /// Client to Server +// /// +// /// Replaces all properties of the object with the content of the +// /// "properties" parameter. This parameter is in network representation. +// /// +// fn request_update(self: Self, properties: VariantMap) { +// self.update(properties); +// } +// +// /// Server to Client +// fn add_alias(self: Self, name: String, expansion: String) { +// self.aliases.push(Alias { name, expansion }); +// } +// +// /// Server to Client +// /// +// /// Replaces all properties of the object with the content of the +// /// "properties" parameter. This parameter is in network representation. +// /// +// fn update(self: Self, properties: VariantMap) { +// let mut alias: Vec = Vec::new(); +// +// // for (i, name) in match_variant!(properties[&"Aliases".to_string()], Variant::String) { +// // alias.push(Alias { +// // name, +// // expansion: match_variant!(properties["Aliases"], Variant::String)["expansions"][i], +// // }) +// // } +// +// self.aliases = alias +// } +// } diff --git a/src/message/signalproxy/objects/backlogmanager.rs b/src/message/signalproxy/objects/backlogmanager.rs new file mode 100644 index 0000000..86a7f61 --- /dev/null +++ b/src/message/signalproxy/objects/backlogmanager.rs @@ -0,0 +1,161 @@ +// interface BacklogManager { +// +// +// // C->S calls +// +// /** +// * Loads backlog for `bufferId`, starting at message `first`, up to `last` +// * (plus `additional` more messages after `last`) but at most `limit` +// * messages total. +// */ +// requestBacklog(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int) +// /** +// * Same as `requestBacklog`, but only messages of a certain message `type` +// * with certain `flags` set. +// */ +// requestBacklogFiltered(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int) +// /** +// * Same as `requestBacklog`, but applied to all buffers. +// */ +// requestBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int) +// /** +// * Same as `requestBacklogFiltered`, but applied to all buffers. +// */ +// requestBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int) +// +// +// // S->C calls +// +// /** +// * The response to `requestBacklog`, with the messages encoded as QVariants +// * in the `messages` parameter. +// */ +// receiveBacklog(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList) +// /** +// * The response to `requestBacklogFiltered`, with the messages encoded as +// * QVariants in the `messages` parameter. +// */ +// receiveBacklogFiltered(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList) +// /** +// * The response to `requestBacklogAll`, with the messages encoded as +// * QVariants in the `messages` parameter. +// */ +// receiveBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList) +// /** +// * The response to `requestBacklogAllFiltered`, with the messages encoded as +// * QVariants in the `messages` parameter. +// */ +// receiveBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList) +// } + +use crate::primitive::VariantList; + +/// Receive and Request Backlog +/// All "request" functions are Client to Server and all "receive" functions are Server to Client +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct BacklogManager {} + +impl BacklogManager { + /// Loads backlog for `bufferId`, starting at message `first`, up to `last` + /// (plus `additional` more messages after `last`) but at most `limit` + /// messages total. + fn requestBacklog( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + ) { + unimplemented!() + } + + /// Same as `requestBacklog`, but only messages of a certain message `type` + /// with certain `flags` set. + fn requestBacklogFiltered( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + ) { + unimplemented!() + } + + /// Same as `requestBacklog`, but applied to all buffers. + fn requestBacklogAll(self: Self, first: u32, last: u32, limit: u32, additional: u32) { + unimplemented!() + } + + /// Same as `requestBacklogFiltered`, but applied to all buffers. + fn requestBacklogAllFiltered( + self: Self, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + ) { + unimplemented!() + } + + /// The response to `requestBacklog`, with the messages encoded as Variants + /// in the `messages` parameter. + fn receiveBacklog( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + messages: VariantList, + ) { + unimplemented!() + } + + /// The response to `requestBacklogFiltered`, with the messages encoded as + /// Variants in the `messages` parameter. + fn receiveBacklogFiltered( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + messages: VariantList, + ) { + unimplemented!() + } + + /// Same as `receiveBacklog`, but applied to all buffers. + fn receiveBacklogAll( + self: Self, + first: u32, + last: u32, + limit: u32, + additional: u32, + messages: VariantList, + ) { + unimplemented!() + } + + /// Same as `receiveBacklogFiltered`, but applied to all buffers. + fn receiveBacklogAllFiltered( + self: Self, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + messages: VariantList, + ) { + unimplemented!() + } +} diff --git a/src/message/signalproxy/objects/mod.rs b/src/message/signalproxy/objects/mod.rs new file mode 100644 index 0000000..14dc42f --- /dev/null +++ b/src/message/signalproxy/objects/mod.rs @@ -0,0 +1,6 @@ +mod aliasmanager; +mod backlogmanager; + +pub trait Act { + fn act(self: Self); +} diff --git a/src/message/signalproxy/rpccall.rs b/src/message/signalproxy/rpccall.rs index 748b226..2eac86d 100644 --- a/src/message/signalproxy/rpccall.rs +++ b/src/message/signalproxy/rpccall.rs @@ -1,21 +1,36 @@ use crate::message::MessageType; +use crate::primitive::Message; use crate::primitive::{Variant, VariantList}; use crate::{Deserialize, Serialize}; #[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct RpcCall { - slot_name: String, - params: VariantList, +pub enum RpcCall { + DisplayMessage(DisplayMessage), } +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct DisplayMessage { + pub message: Message, +} + +// #[derive(Clone, Debug, std::cmp::PartialEq)] +// pub struct RpcCall { +// pub slot_name: String, +// pub params: VariantList, +// } + impl Serialize for RpcCall { fn serialize(&self) -> Result, failure::Error> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::RpcCall as i32)); - res.push(Variant::StringUTF8(self.slot_name.clone())); - res.append(&mut self.params.clone()); + match self { + RpcCall::DisplayMessage(msg) => { + res.push(Variant::StringUTF8("2displayMsg(Message)".to_string())); + res.push(Variant::Message(msg.message.clone())); + } + } res.serialize() } @@ -27,12 +42,18 @@ impl Deserialize for RpcCall { res.remove(0); - Ok(( - size, - Self { - slot_name: match_variant!(res.remove(0), Variant::StringUTF8), - params: res, - }, - )) + let rpc = match_variant!(res.remove(0), Variant::StringUTF8); + + match rpc.as_str() { + "2displayMsg(Message)" => { + return Ok(( + size, + RpcCall::DisplayMessage(DisplayMessage { + message: match_variant!(res.remove(0), Variant::Message), + }), + )) + } + _ => unimplemented!(), + } } } diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs index fe69cf1..737f3e0 100644 --- a/src/message/signalproxy/syncmessage.rs +++ b/src/message/signalproxy/syncmessage.rs @@ -10,6 +10,8 @@ pub struct SyncMessage { params: VariantList, } +// impl Act for SyncMessage {} + impl Serialize for SyncMessage { fn serialize(&self) -> Result, failure::Error> { let mut res = VariantList::new(); diff --git a/src/session/mod.rs b/src/session/mod.rs new file mode 100644 index 0000000..67045c9 --- /dev/null +++ b/src/session/mod.rs @@ -0,0 +1,2 @@ +/// The Session Trait is the main point of entry and implements the basic logic +pub trait Session {} -- cgit v1.2.3 From 13734288dbc63c48af0b8f75f0453f0d30b750a7 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 2 Jan 2021 19:57:06 +0100 Subject: rework handshakemessage parsing --- src/message/handshake/clientinit.rs | 30 +++---- src/message/handshake/clientinitack.rs | 46 +++++------ src/message/handshake/clientinitreject.rs | 28 ++----- src/message/handshake/clientlogin.rs | 26 ++---- src/message/handshake/clientloginack.rs | 2 +- src/message/handshake/clientloginreject.rs | 26 ++---- src/message/handshake/init.rs | 10 ++- src/message/handshake/mod.rs | 46 +++++++++++ src/message/handshake/sessioninit.rs | 84 ++++++++++++-------- src/message/signalproxy/objects/identity.rs | 119 ++++++++++++++++++++++++++++ src/primitive/datetime.rs | 2 +- 11 files changed, 278 insertions(+), 141 deletions(-) create mode 100644 src/message/signalproxy/objects/identity.rs (limited to 'src/message/signalproxy') diff --git a/src/message/handshake/clientinit.rs b/src/message/handshake/clientinit.rs index 17ec9a1..d21d6aa 100644 --- a/src/message/handshake/clientinit.rs +++ b/src/message/handshake/clientinit.rs @@ -1,6 +1,5 @@ -use crate::error::ProtocolError; use crate::primitive::{StringList, Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; @@ -32,7 +31,7 @@ use failure::Error; /// | -- | EcdsaCertfpKeys | ECDSA keys for CertFP in identities | /// | -- | LongMessageId | 64-bit IDs for messages | /// | -- | SyncedCoreInfo | CoreInfo dynamically updated using signals | -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientInit { /// Version of the client pub client_version: String, @@ -68,24 +67,13 @@ impl HandshakeSerialize for ClientInit { } } -impl HandshakeDeserialize for ClientInit { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientInit" { - return Ok(( - len, - Self { - client_version: match_variant!(values["ClientVersion"], Variant::String), - client_date: match_variant!(values["ClientDate"], Variant::String), - feature_list: match_variant!(values["FeatureList"], Variant::StringList), - client_features: match_variant!(values["Features"], Variant::u32), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From for ClientInit { + fn from(input: VariantMap) -> Self { + ClientInit { + client_version: match_variant!(input.get("ClientVersion").unwrap(), Variant::String), + client_date: match_variant!(input.get("ClientDate").unwrap(), Variant::String), + client_features: match_variant!(input.get("Features").unwrap(), Variant::u32), + feature_list: match_variant!(input.get("FeatureList").unwrap(), Variant::StringList), } } } diff --git a/src/message/handshake/clientinitack.rs b/src/message/handshake/clientinitack.rs index 637b989..f881113 100644 --- a/src/message/handshake/clientinitack.rs +++ b/src/message/handshake/clientinitack.rs @@ -1,11 +1,10 @@ -use crate::error::ProtocolError; -use crate::primitive::{StringList, Variant, VariantList, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::primitive::{Variant, VariantList, VariantMap}; +use crate::HandshakeSerialize; use failure::Error; /// ClientInitAck is received when the initialization was successfull -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientInitAck { /// Flags of supported legacy features pub core_features: u32, @@ -16,7 +15,7 @@ pub struct ClientInitAck { /// List of VariantMaps of info on available authenticators pub authenticators: VariantList, /// List of supported extended features - pub feature_list: StringList, + pub feature_list: Vec, } impl HandshakeSerialize for ClientInitAck { @@ -47,28 +46,21 @@ impl HandshakeSerialize for ClientInitAck { } } -impl HandshakeDeserialize for ClientInitAck { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientInitAck" { - return Ok(( - len, - Self { - core_features: 0x00008000, - core_configured: match_variant!(values["Configured"], Variant::bool), - storage_backends: match_variant!( - values["StorageBackends"], - Variant::VariantList - ), - authenticators: match_variant!(values["Authenticators"], Variant::VariantList), - feature_list: match_variant!(values["FeatureList"], Variant::StringList), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From for ClientInitAck { + fn from(input: VariantMap) -> Self { + ClientInitAck { + // TODO make this compatible with older clients + core_features: 0, + core_configured: match_variant!(input.get("Configured").unwrap(), Variant::bool), + storage_backends: match_variant!( + input.get("StorageBackends").unwrap(), + Variant::VariantList + ), + authenticators: match_variant!( + input.get("Authenticators").unwrap(), + Variant::VariantList + ), + feature_list: match_variant!(input.get("FeatureList").unwrap(), Variant::StringList), } } } diff --git a/src/message/handshake/clientinitreject.rs b/src/message/handshake/clientinitreject.rs index 06960b7..d93413d 100644 --- a/src/message/handshake/clientinitreject.rs +++ b/src/message/handshake/clientinitreject.rs @@ -1,14 +1,13 @@ -use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; /// ClientInitReject is received when the initialization fails -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientInitReject { /// String with an error message of what went wrong - pub error_string: String, + pub error: String, } impl HandshakeSerialize for ClientInitReject { @@ -20,27 +19,16 @@ impl HandshakeSerialize for ClientInitReject { ); values.insert( "ErrorString".to_string(), - Variant::String(self.error_string.clone()), + Variant::String(self.error.clone()), ); return HandshakeSerialize::serialize(&values); } } -impl HandshakeDeserialize for ClientInitReject { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientInitReject" { - return Ok(( - len, - Self { - error_string: match_variant!(values["ErrorString"], Variant::String), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From for ClientInitReject { + fn from(input: VariantMap) -> Self { + ClientInitReject { + error: match_variant!(input.get("ErrorString").unwrap(), Variant::String), } } } diff --git a/src/message/handshake/clientlogin.rs b/src/message/handshake/clientlogin.rs index 769245b..dffd996 100644 --- a/src/message/handshake/clientlogin.rs +++ b/src/message/handshake/clientlogin.rs @@ -1,12 +1,11 @@ -use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; /// Login to the core with user data /// username and password are transmitted in plain text -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientLogin { pub user: String, pub password: String, @@ -28,22 +27,11 @@ impl HandshakeSerialize for ClientLogin { } } -impl HandshakeDeserialize for ClientLogin { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientLogin" { - return Ok(( - len, - Self { - user: match_variant!(values["User"], Variant::String), - password: match_variant!(values["Password"], Variant::String), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From for ClientLogin { + fn from(input: VariantMap) -> Self { + ClientLogin { + user: match_variant!(input.get("User").unwrap(), Variant::String), + password: match_variant!(input.get("Password").unwrap(), Variant::String), } } } diff --git a/src/message/handshake/clientloginack.rs b/src/message/handshake/clientloginack.rs index 674d307..e385a81 100644 --- a/src/message/handshake/clientloginack.rs +++ b/src/message/handshake/clientloginack.rs @@ -6,7 +6,7 @@ use failure::Error; /// ClientLoginAck is received after the client has successfully logged in /// it has no fields -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientLoginAck; impl HandshakeSerialize for ClientLoginAck { diff --git a/src/message/handshake/clientloginreject.rs b/src/message/handshake/clientloginreject.rs index e8380d6..0c0fc85 100644 --- a/src/message/handshake/clientloginreject.rs +++ b/src/message/handshake/clientloginreject.rs @@ -1,14 +1,13 @@ -use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; /// ClientLoginReject is received after the client failed to login /// It contains an error message as String -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientLoginReject { - error: String, + pub error: String, } impl HandshakeSerialize for ClientLoginReject { @@ -26,21 +25,10 @@ impl HandshakeSerialize for ClientLoginReject { } } -impl HandshakeDeserialize for ClientLoginReject { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientLogin" { - return Ok(( - len, - Self { - error: match_variant!(values["ErrorString"], Variant::String), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From for ClientLoginReject { + fn from(input: VariantMap) -> Self { + ClientLoginReject { + error: match_variant!(input.get("ErrorString").unwrap(), Variant::String), } } } diff --git a/src/message/handshake/init.rs b/src/message/handshake/init.rs index e4c0fa9..860df8a 100644 --- a/src/message/handshake/init.rs +++ b/src/message/handshake/init.rs @@ -37,7 +37,15 @@ impl Init { handshake |= 0x02; } - return handshake.serialize().unwrap(); + // Select Protocol 2: Datastream + + let mut init: Vec = vec![]; + + // Add handshake and protocol to our buffer + init.extend(handshake.serialize().unwrap()); + init.extend(crate::message::Protocol::Datastream.serialize()); + + return init; } pub fn parse(buf: &[u8]) -> Self { diff --git a/src/message/handshake/mod.rs b/src/message/handshake/mod.rs index 9b3bcee..9885012 100644 --- a/src/message/handshake/mod.rs +++ b/src/message/handshake/mod.rs @@ -21,3 +21,49 @@ pub use init::*; pub use protocol::*; pub use sessioninit::*; pub use types::*; + +use crate::primitive::{Variant, VariantMap}; +use crate::{HandshakeDeserialize, HandshakeSerialize}; + +#[derive(Debug, Clone)] +pub enum HandshakeMessage { + ClientInit(ClientInit), + ClientInitAck(ClientInitAck), + ClientInitReject(ClientInitReject), + ClientLogin(ClientLogin), + ClientLoginAck, + ClientLoginReject(ClientLoginReject), + SessionInit(SessionInit), +} + +impl HandshakeSerialize for HandshakeMessage { + fn serialize(&self) -> Result, failure::Error> { + match self { + HandshakeMessage::ClientInit(inner) => inner.serialize(), + HandshakeMessage::ClientInitAck(inner) => inner.serialize(), + HandshakeMessage::ClientInitReject(inner) => inner.serialize(), + HandshakeMessage::ClientLogin(inner) => inner.serialize(), + HandshakeMessage::ClientLoginAck => ClientLoginAck.serialize(), + HandshakeMessage::ClientLoginReject(inner) => inner.serialize(), + HandshakeMessage::SessionInit(inner) => inner.serialize(), + } + } +} + +impl HandshakeDeserialize for HandshakeMessage { + fn parse(b: &[u8]) -> Result<(usize, Self), failure::Error> { + let (size, res) = VariantMap::parse(b)?; + + let msgtype = match_variant!(&res["MsgType"], Variant::String); + match msgtype.as_str() { + "ClientInit" => Ok((size, HandshakeMessage::ClientInit(res.into()))), + "ClientInitAck" => Ok((size, HandshakeMessage::ClientInitAck(res.into()))), + "ClientInitReject" => Ok((size, HandshakeMessage::ClientInitReject(res.into()))), + "ClientLogin" => Ok((size, HandshakeMessage::ClientLogin(res.into()))), + "ClientLoginAck" => Ok((size, HandshakeMessage::ClientLoginAck)), + "ClientLoginReject" => Ok((size, HandshakeMessage::ClientLoginReject(res.into()))), + "SessionInit" => Ok((size, HandshakeMessage::SessionInit(res.into()))), + _ => unimplemented!(), + } + } +} diff --git a/src/message/handshake/sessioninit.rs b/src/message/handshake/sessioninit.rs index eca4c10..d1b4b90 100644 --- a/src/message/handshake/sessioninit.rs +++ b/src/message/handshake/sessioninit.rs @@ -1,61 +1,81 @@ -use crate::error::ProtocolError; -use crate::primitive::{Variant, VariantList, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::message::objects::Identity; +use crate::primitive::{BufferInfo, Variant, VariantMap}; +use crate::HandshakeSerialize; use failure::Error; /// SessionInit is received along with ClientLoginAck to initialize that user Session // TODO Replace with proper types -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct SessionInit { /// List of all configured identities - identities: VariantList, + pub identities: Vec, /// List of all existing buffers - buffers: VariantList, + pub buffers: Vec, /// Ids of all networks - network_ids: VariantList, + pub network_ids: Vec, +} + +impl From for SessionInit { + fn from(input: VariantMap) -> Self { + let state = match_variant!(input.get("SessionState").unwrap(), Variant::VariantMap); + SessionInit { + identities: match_variant!(state.get("Identities").unwrap(), Variant::VariantList) + .iter() + .map(|ident| Identity::from(match_variant!(ident, Variant::VariantMap))) + .collect(), + buffers: match_variant!(state.get("BufferInfos").unwrap(), Variant::VariantList) + .iter() + .map(|buffer| match buffer { + Variant::BufferInfo(buffer) => buffer.clone(), + _ => unimplemented!(), + }) + .collect(), + network_ids: match_variant!(state.get("NetworkIds").unwrap(), Variant::VariantList) + .iter() + .map(|network| match network { + Variant::i32(network) => network.clone(), + _ => unimplemented!(), + }) + .collect(), + } + } } impl HandshakeSerialize for SessionInit { fn serialize(&self) -> Result, Error> { - let mut values: VariantMap = VariantMap::with_capacity(1); + let mut values: VariantMap = VariantMap::with_capacity(4); values.insert( "MsgType".to_string(), Variant::String("SessionInit".to_string()), ); values.insert( "Identities".to_string(), - Variant::VariantList(self.identities.clone()), + Variant::VariantList( + self.identities + .iter() + .map(|ident| Variant::VariantMap(ident.clone().into())) + .collect(), + ), ); values.insert( "BufferInfos".to_string(), - Variant::VariantList(self.buffers.clone()), + Variant::VariantList( + self.buffers + .iter() + .map(|buffer| Variant::BufferInfo(buffer.clone())) + .collect(), + ), ); values.insert( "NetworkIds".to_string(), - Variant::VariantList(self.network_ids.clone()), + Variant::VariantList( + self.network_ids + .iter() + .map(|id| Variant::i32(id.clone())) + .collect(), + ), ); return HandshakeSerialize::serialize(&values); } } - -impl HandshakeDeserialize for SessionInit { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientLogin" { - return Ok(( - len, - Self { - identities: match_variant!(values["Identities"], Variant::VariantList), - buffers: match_variant!(values["BufferInfos"], Variant::VariantList), - network_ids: match_variant!(values["NetworkIds"], Variant::VariantList), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); - } - } -} diff --git a/src/message/signalproxy/objects/identity.rs b/src/message/signalproxy/objects/identity.rs new file mode 100644 index 0000000..a710e5d --- /dev/null +++ b/src/message/signalproxy/objects/identity.rs @@ -0,0 +1,119 @@ +use crate::primitive::{Variant, VariantMap}; + +#[derive(Debug, Clone)] +pub struct Identity { + identity_id: i32, + identity_name: String, + real_name: String, + nicks: Vec, + away_nick: String, + away_nick_enabled: bool, + away_reason: String, + away_reason_enabled: bool, + auto_away_enabled: bool, + auto_away_time: i32, + auto_away_reason: String, + auto_away_reason_enabled: bool, + detach_away_enabled: bool, + detach_away_reason: String, + detach_away_reason_enabled: bool, + ident: String, + kick_reason: String, + part_reason: String, + quit_reason: String, +} + +impl From for Identity { + fn from(input: VariantMap) -> Self { + Identity { + identity_id: match_variant!(input.get("identityId").unwrap(), Variant::i32), + identity_name: match_variant!(input.get("identityName").unwrap(), Variant::String), + real_name: match_variant!(input.get("realName").unwrap(), Variant::String), + nicks: match_variant!(input.get("nicks").unwrap(), Variant::StringList), + away_nick: match_variant!(input.get("awayNick").unwrap(), Variant::String), + away_nick_enabled: match_variant!(input.get("awayNickEnabled").unwrap(), Variant::bool), + away_reason: match_variant!(input.get("awayReason").unwrap(), Variant::String), + away_reason_enabled: match_variant!( + input.get("awayReasonEnabled").unwrap(), + Variant::bool + ), + auto_away_enabled: match_variant!(input.get("autoAwayEnabled").unwrap(), Variant::bool), + auto_away_time: match_variant!(input.get("autoAwayTime").unwrap(), Variant::i32), + auto_away_reason: match_variant!(input.get("autoAwayReason").unwrap(), Variant::String), + auto_away_reason_enabled: match_variant!( + input.get("autoAwayReasonEnabled").unwrap(), + Variant::bool + ), + detach_away_enabled: match_variant!( + input.get("detachAwayEnabled").unwrap(), + Variant::bool + ), + detach_away_reason: match_variant!( + input.get("detachAwayReason").unwrap(), + Variant::String + ), + detach_away_reason_enabled: match_variant!( + input.get("detachAwayReasonEnabled").unwrap(), + Variant::bool + ), + ident: match_variant!(input.get("ident").unwrap(), Variant::String), + kick_reason: match_variant!(input.get("kickReason").unwrap(), Variant::String), + part_reason: match_variant!(input.get("partReason").unwrap(), Variant::String), + quit_reason: match_variant!(input.get("quitReason").unwrap(), Variant::String), + } + } +} + +impl Into> for Identity { + fn into(self) -> VariantMap { + let mut res = VariantMap::with_capacity(19); + + res.insert("identityId".to_string(), Variant::i32(self.identity_id)); + res.insert( + "identityName".to_string(), + Variant::String(self.identity_name), + ); + res.insert("realName".to_string(), Variant::String(self.real_name)); + res.insert("nicks".to_string(), Variant::StringList(self.nicks)); + res.insert("awayNick".to_string(), Variant::String(self.away_nick)); + res.insert( + "awayNickEnabled".to_string(), + Variant::bool(self.away_nick_enabled), + ); + res.insert("awayReason".to_string(), Variant::String(self.away_reason)); + res.insert( + "awayReasonEnabled".to_string(), + Variant::bool(self.away_reason_enabled), + ); + res.insert( + "autoAwayEnabled".to_string(), + Variant::bool(self.auto_away_enabled), + ); + res.insert( + "autoAwayTime".to_string(), + Variant::i32(self.auto_away_time), + ); + res.insert( + "autoAwayReason".to_string(), + Variant::String(self.auto_away_reason), + ); + res.insert( + "detachAwayEnabled".to_string(), + Variant::bool(self.detach_away_enabled), + ); + res.insert( + "detachAwayReason".to_string(), + Variant::String(self.detach_away_reason), + ); + res.insert( + "detachAwayReasonEnabled".to_string(), + Variant::bool(self.detach_away_reason_enabled), + ); + res.insert("ident".to_string(), Variant::String(self.ident)); + res.insert("kickReason".to_string(), Variant::String(self.kick_reason)); + res.insert("partReason".to_string(), Variant::String(self.part_reason)); + res.insert("quitReason".to_string(), Variant::String(self.quit_reason)); + + res + } +} diff --git a/src/primitive/datetime.rs b/src/primitive/datetime.rs index cbcdd51..f3ace1d 100644 --- a/src/primitive/datetime.rs +++ b/src/primitive/datetime.rs @@ -79,7 +79,7 @@ impl Deserialize for OffsetDateTime { let offset: UtcOffset; match zone { TimeSpec::LocalUnknown | TimeSpec::LocalStandard | TimeSpec::LocalDST => { - offset = UtcOffset::current_local_offset() + offset = UtcOffset::try_current_local_offset()? } TimeSpec::UTC => offset = UtcOffset::UTC, TimeSpec::OffsetFromUTC => { -- cgit v1.2.3 From 16d12e4fa250889dfbad480fa502178b7e8b1cfa Mon Sep 17 00:00:00 2001 From: Max Audron Date: Mon, 4 Jan 2021 18:24:00 +0100 Subject: add more signalproxy objects --- src/message/signalproxy/initrequest.rs | 8 +-- src/message/signalproxy/mod.rs | 2 +- src/message/signalproxy/objects/aliasmanager.rs | 66 +++++++++++----------- src/message/signalproxy/objects/buffersyncer.rs | 74 +++++++++++++++++++++++++ src/message/signalproxy/objects/mod.rs | 10 +++- 5 files changed, 120 insertions(+), 40 deletions(-) create mode 100644 src/message/signalproxy/objects/buffersyncer.rs (limited to 'src/message/signalproxy') diff --git a/src/message/signalproxy/initrequest.rs b/src/message/signalproxy/initrequest.rs index def314a..59eee2d 100644 --- a/src/message/signalproxy/initrequest.rs +++ b/src/message/signalproxy/initrequest.rs @@ -4,8 +4,8 @@ use crate::{Deserialize, Serialize}; #[derive(Clone, Debug, std::cmp::PartialEq)] pub struct InitRequest { - class_name: String, - object_name: String, + pub class_name: String, + pub object_name: String, } impl Serialize for InitRequest { @@ -13,8 +13,8 @@ impl Serialize for InitRequest { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::InitRequest as i32)); - res.push(Variant::StringUTF8(self.class_name.clone())); - res.push(Variant::StringUTF8(self.object_name.clone())); + res.push(Variant::ByteArray(self.class_name.clone())); + res.push(Variant::ByteArray(self.object_name.clone())); res.serialize() } diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs index b69c6b0..4e99fb0 100644 --- a/src/message/signalproxy/mod.rs +++ b/src/message/signalproxy/mod.rs @@ -3,7 +3,7 @@ use crate::{Deserialize, Serialize}; mod heartbeat; mod initdata; mod initrequest; -mod objects; +pub mod objects; mod rpccall; mod syncmessage; diff --git a/src/message/signalproxy/objects/aliasmanager.rs b/src/message/signalproxy/objects/aliasmanager.rs index 7e9cfca..828caaa 100644 --- a/src/message/signalproxy/objects/aliasmanager.rs +++ b/src/message/signalproxy/objects/aliasmanager.rs @@ -11,36 +11,36 @@ pub struct Alias { expansion: String, } -// impl AliasManager { -// /// Client to Server -// /// -// /// Replaces all properties of the object with the content of the -// /// "properties" parameter. This parameter is in network representation. -// /// -// fn request_update(self: Self, properties: VariantMap) { -// self.update(properties); -// } -// -// /// Server to Client -// fn add_alias(self: Self, name: String, expansion: String) { -// self.aliases.push(Alias { name, expansion }); -// } -// -// /// Server to Client -// /// -// /// Replaces all properties of the object with the content of the -// /// "properties" parameter. This parameter is in network representation. -// /// -// fn update(self: Self, properties: VariantMap) { -// let mut alias: Vec = Vec::new(); -// -// // for (i, name) in match_variant!(properties[&"Aliases".to_string()], Variant::String) { -// // alias.push(Alias { -// // name, -// // expansion: match_variant!(properties["Aliases"], Variant::String)["expansions"][i], -// // }) -// // } -// -// self.aliases = alias -// } -// } +impl AliasManager { + /// Client to Server + /// + /// Replaces all properties of the object with the content of the + /// "properties" parameter. This parameter is in network representation. + /// + fn request_update(self: &mut Self, properties: VariantMap) { + self.update(properties); + } + + /// Server to Client + fn add_alias(self: &mut Self, name: String, expansion: String) { + self.aliases.push(Alias { name, expansion }); + } + + /// Server to Client + /// + /// Replaces all properties of the object with the content of the + /// "properties" parameter. This parameter is in network representation. + /// + fn update(self: &mut Self, properties: VariantMap) { + let mut alias: Vec = Vec::new(); + + // for (i, name) in match_variant!(properties[&"Aliases".to_string()], Variant::String) { + // alias.push(Alias { + // name, + // expansion: match_variant!(properties["Aliases"], Variant::String)["expansions"][i], + // }) + // } + + self.aliases = alias + } +} diff --git a/src/message/signalproxy/objects/buffersyncer.rs b/src/message/signalproxy/objects/buffersyncer.rs new file mode 100644 index 0000000..7ee4ca5 --- /dev/null +++ b/src/message/signalproxy/objects/buffersyncer.rs @@ -0,0 +1,74 @@ +use crate::message::signalproxy::MessageType; +use std::collections::HashMap; + +// use default_macro::default; +// #[default(crate::message::signalproxy::objects::BufferSyncerClient)] +pub struct BufferSyncer { + pub activities: HashMap, + pub highlight_counts: HashMap, + pub last_seen_msg: HashMap, + pub marker_line: HashMap, +} + +pub trait BufferSyncerServer { + fn activities(self: &Self) -> &HashMap; + fn activities_mut(self: &mut Self) -> &mut HashMap; + + fn highlight_counts(self: &Self) -> &HashMap; + fn highlight_counts_mut(self: &mut Self) -> &mut HashMap; + + fn last_seen_msg(self: &Self) -> &HashMap; + fn last_seen_msg_mut(self: &mut Self) -> &mut HashMap; + + fn marker_line(self: &Self) -> &HashMap; + fn marker_line_mut(self: &mut Self) -> &mut HashMap; + + fn request_mark_buffer_as_read(buffer: u32); + fn request_merge_buffers_permanently(buffer1: u32, buffer2: u32); + fn request_purge_buffer_ids(); + fn request_remove_buffer(buffer: u32); + fn request_rename_buffer(buffer: u32, new_name: String); + + fn request_set_last_seen_msg(self: &mut Self, buffer: u32, msgid: u32) { + self.last_seen_msg_mut().insert(buffer, msgid); + } + + fn request_set_marker_line(self: &mut Self, buffer: u32, msgid: u32) { + self.marker_line_mut().insert(buffer, msgid); + } +} + +pub trait BufferSyncerClient { + fn activities(self: &Self) -> &HashMap; + fn activities_mut(self: &mut Self) -> &mut HashMap; + + fn highlight_counts(self: &Self) -> &HashMap; + fn highlight_counts_mut(self: &mut Self) -> &mut HashMap; + + fn last_seen_msg(self: &Self) -> &HashMap; + fn last_seen_msg_mut(self: &mut Self) -> &mut HashMap; + + fn marker_line(self: &Self) -> &HashMap; + fn marker_line_mut(self: &mut Self) -> &mut HashMap; + + fn mark_buffer_as_read(buffer: u32); + fn merge_buffers_permanently(buffer1: u32, buffer2: u32); + fn remove_buffer(buffer: u32); + fn rename_buffer(buffer: u32, new_name: String); + + fn set_buffer_activity(self: &mut Self, buffer: u32, activity: MessageType) { + self.activities_mut().insert(buffer, activity); + } + + fn set_highlight_count(self: &mut Self, buffer: u32, count: u32) { + self.highlight_counts_mut().insert(buffer, count); + } + + fn set_last_seen_msg(self: &mut Self, buffer: u32, msgid: u32) { + self.last_seen_msg_mut().insert(buffer, msgid); + } + + fn set_marker_line(self: &mut Self, buffer: u32, msgid: u32) { + self.marker_line_mut().insert(buffer, msgid); + } +} diff --git a/src/message/signalproxy/objects/mod.rs b/src/message/signalproxy/objects/mod.rs index 14dc42f..a84f6fa 100644 --- a/src/message/signalproxy/objects/mod.rs +++ b/src/message/signalproxy/objects/mod.rs @@ -1,5 +1,11 @@ -mod aliasmanager; -mod backlogmanager; +// mod aliasmanager; +// mod backlogmanager; + +mod buffersyncer; +mod identity; + +pub use buffersyncer::*; +pub use identity::*; pub trait Act { fn act(self: Self); -- cgit v1.2.3