aboutsummaryrefslogtreecommitdiff
path: root/src/message/signalproxy
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2023-12-19 15:34:35 +0100
committerMax Audron <audron@cocaine.farm>2023-12-19 15:34:35 +0100
commit6bb42bc259f6418bb41fefc83a28bdb5df9ecde3 (patch)
treef619a42ea0c0e7e5064b51919ead6e0552950a2e /src/message/signalproxy
parentremove old statetracker gui (diff)
implement bufferviewmanager/config init
Diffstat (limited to '')
-rw-r--r--src/message/signalproxy/objects/bufferviewmanager.rs26
-rw-r--r--src/message/signalproxy/objects/mod.rs6
2 files changed, 27 insertions, 5 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<i32, BufferViewConfig>,
+ pub buffer_view_configs: HashMap<i32, Option<BufferViewConfig>>,
}
// 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))
>Use BufferId in VariantTobias Deiminger-2/+33 2025-02-25Add BufferId as Rust typeTobias Deiminger-0/+39 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 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 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