From 6bb42bc259f6418bb41fefc83a28bdb5df9ecde3 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Tue, 19 Dec 2023 15:34:35 +0100 Subject: implement bufferviewmanager/config init --- .../signalproxy/objects/bufferviewmanager.rs | 26 +++++++++++++++++++--- src/message/signalproxy/objects/mod.rs | 6 +++-- src/session/mod.rs | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/message/signalproxy/objects/bufferviewmanager.rs b/src/message/signalproxy/objects/bufferviewmanager.rs index 0ea30f7..50265dc 100644 --- a/src/message/signalproxy/objects/bufferviewmanager.rs +++ b/src/message/signalproxy/objects/bufferviewmanager.rs @@ -15,7 +15,7 @@ use super::BufferViewConfig; #[derive(Debug, Clone, PartialEq, Default)] pub struct BufferViewManager { - pub buffer_view_configs: HashMap, + pub buffer_view_configs: HashMap>, } // TODO initialize the BufferViewConfigs from somewhere @@ -67,6 +67,14 @@ impl BufferViewManager { #[cfg(feature = "server")] sync!("deleteBufferViewConfig", [id]) } + + pub fn init_buffer_view_config(&mut self, config: BufferViewConfig) { + if let Some(stored) = self.buffer_view_configs.get_mut(&config.buffer_view_id) { + *stored = Some(config); + } else { + self.buffer_view_configs.insert(config.buffer_view_id, Some(config)); + } + } } #[cfg(feature = "client")] @@ -137,10 +145,22 @@ impl super::NetworkList for BufferViewManager { return res; } - fn from_network_list(_input: &mut VariantList) -> Self { + fn from_network_list(input: &mut VariantList) -> Self { + let mut i = input.iter(); + i.position(|x| *x == Variant::ByteArray(String::from("BufferViewIds"))) + .expect(format!("failed to get field BufferViewIds").as_str()); + + let ids = match i.next().expect("failed to get next field") { + libquassel::primitive::Variant::VariantList(var) => var.clone(), + _ => panic!("network::list::from: wrong variant type"), + }; + // TODO Somehow do the initrequests for all the IDs we get here Self { - buffer_view_configs: HashMap::new(), + buffer_view_configs: ids + .into_iter() + .map(|id| (i32::try_from(id).unwrap(), Option::None)) + .collect(), } } } diff --git a/src/message/signalproxy/objects/mod.rs b/src/message/signalproxy/objects/mod.rs index 521a591..5ef746a 100644 --- a/src/message/signalproxy/objects/mod.rs +++ b/src/message/signalproxy/objects/mod.rs @@ -91,7 +91,7 @@ impl Types { } } - pub fn from_network(class_name: &str, _object_name: &str, input: &mut VariantList) -> Self { + pub fn from_network(class_name: &str, object_name: &str, input: &mut VariantList) -> Self { debug!( "converting {} from network object: {:#?}", class_name, input @@ -100,7 +100,9 @@ impl Types { "AliasManager" => Types::AliasManager(AliasManager::from_network_list(input)), "BufferSyncer" => Types::BufferSyncer(BufferSyncer::from_network_list(input)), "BufferViewConfig" => { - Types::BufferViewConfig(BufferViewConfig::from_network_list(input)) + let mut config = BufferViewConfig::from_network_list(input); + config.buffer_view_id = object_name.parse().unwrap(); + Types::BufferViewConfig(config) } "BufferViewManager" => { Types::BufferViewManager(BufferViewManager::from_network_list(input)) diff --git a/src/session/mod.rs b/src/session/mod.rs index 531f4f0..c2bfcd5 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -126,7 +126,7 @@ pub trait SessionManager { match data.init_data { Types::AliasManager(data) => self.alias_manager().init(data), Types::BufferSyncer(data) => self.buffer_syncer().init(data), - Types::BufferViewConfig(_) => (), + Types::BufferViewConfig(data) => self.buffer_view_manager().init_buffer_view_config(data), Types::BufferViewManager(data) => self.buffer_view_manager().init(data), Types::CoreData(data) => self.core_info().set_core_data(data), Types::HighlightRuleManager(data) => self.highlight_rule_manager().init(data), -- cgit v1.2.3 -22 14:19:31 +0100'>9 daysadd more git remotesmasterMax Audron-0/+13 9 daysadd error for unkown sync message slot_nameMax Audron-43/+51 9 daysNetworkList and signalproxy objects error handlingMax Audron-504/+693 10 daysSyncable trait error handlingMax Audron-91/+152 10 dayshandshare and signalproxy/rpccall error handlingMax Audron-91/+165 10 daysuse ProtocolError for From deriveMax Audron-7/+7 10 daysclean up clippy lintsMax Audron-259/+242 10 daysreplace all match_variant instances with try_intoMax Audron-134/+111 the match_variant macro was unclear, unreadable and no longer needed as we have automaticly derived from implementations for all Variant enum fields now 2025-07-27remove old readme.orgMax Audron-35/+0 2025-07-27temporarly fix nested network repr parsing for variant typesMax Audron-39/+39 2025-07-27fix sessioninit message wrongly using NetworkMap to convert a fieldMax Audron-4/+5 2025-03-03update roadmapMax Audron-2/+10 2025-03-01implement rpc callsMax Audron-64/+762 2025-03-01add UserType implementation for required signalproxy objectsMax Audron-13/+131 2025-03-01remove old quassel attributes from derive macrosMax Audron-37/+36 this was used across the different derive macros and already replace by macro specific network and setter attributes. 2025-02-27extend docs and reorganize filesMax Audron-1281/+321 2025-02-26implement NetworkId UserTypeMax Audron-108/+196 2025-02-26implement IdentityIdMax Audron-8/+79 2025-02-26refactor variant deserializationMax Audron-123/+59 2025-02-26refactor deserialize and serializevariant traitMax Audron-90/+80 move stuff around a bit to sepperate it out for deserializevariant 2025-02-26refactor variant serialization codeMax Audron-256/+405 Factored out a lot of the serialization of variants into trait's that have auto impl so code duplication is much reduced 2025-02-26add MsgId and BufferId to objects where neededMax Audron-141/+157 some objects where still handling BufferId or MsgId as their raw types which lead to errors now that the Types are properly parsed in the varinats 2025-02-25enable transparent repr for msgid and bufferidMax Audron-0/+2 2025-02-25Implement BacklogManagerTobias Deiminger-59/+113 2025-02-25Use BufferId in BufferInfoTobias Deiminger-10/+11 2025-02-25Use BufferId in VariantTobias Deiminger-2/+33 2025-02-25Add BufferId as Rust typeTobias Deiminger-0/+39 Up to now it was represented as i32. If we introduce a newtype for it, we can handle it idiomatically as dedicated Variant::BufferId variant (instead of having it mashed into Variant::UserType). 2025-02-25Use MsgId in MessageTobias Deiminger-18/+6 2025-02-25Use MsgId in VariantTobias Deiminger-20/+37 2025-02-25Add MsgId as Rust typeTobias Deiminger-0/+56 Up to now it was handled implicitely in Variant::UserType. Making it an explicit type allows to centralize the i32/i64 cfg dependency and to use the type for arguments in signalproxy::objects functions. 2025-02-24added session manager comments and log messageMax Audron-1/+3 2025-02-23add identity syncable to SessionManagerMax Audron-1/+8 2025-02-23add syncables for IrcUserMax Audron-2/+53 2025-02-23move network config to it's own file and impl it's syncMax Audron-23/+84 2025-02-23add basic network syncablesMax Audron-39/+420 2025-02-23clean up unused_import and unused_variables a bitMax Audron-2/+8 2025-02-23fix server feature errorsMax Audron-28/+23 2025-02-23fix ircchannel and maplist network representationMax Audron-154/+137 2025-02-22replace deprecated failure crate with thiserrorMax Audron-278/+194 this changes the public API in that all our methods now return a proper ProtocolError crate. Needed change anyways to properly deal with all our errors in the long run. Will still need to do a pass through the crate to remove all existing unwraps where it makes sense. 2025-02-22update dependencies and fix errorsMax Audron-508/+332 2025-02-22update flakeMax Audron-94/+117 2024-05-22add todos to readmeMax Audron-16/+35