From fd943651195a970aac2b066e3bdbb23253f73ce7 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Fri, 16 Oct 2020 21:58:05 +0200 Subject: update --- src/message/signalproxy/objects/aliasmanager.rs | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/message/signalproxy/objects/aliasmanager.rs (limited to 'src/message/signalproxy/objects/aliasmanager.rs') 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 +// } +// } -- 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/objects/aliasmanager.rs') 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