Commit 0576031003
Unsigned
Layout: unified · split
src/config.rs +10 −12
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | use crate::{MatrixServer, Servers}; |
| 2 | use weechat::config::{Conf, ConfigSection, ConfigSectionSettings}; | |
| 3 | use weechat::{OptionChanged, Weechat}; | |
| 2 | use weechat::config::{ | |
| 3 | Conf, ConfigSection, ConfigSectionSettings, OptionChanged, | |
| 4 | }; | |
| 5 | use weechat::Weechat; | |
| 4 | 6 | |
| 5 | 7 | use std::cell::{Ref, RefCell, RefMut}; |
| 6 | 8 | use std::rc::{Rc, Weak}; |
| @@ -48,10 +50,9 @@ impl Config { | ||
| 48 | 50 | let server_section_options = ConfigSectionSettings::new("server") |
| 49 | 51 | .set_write_callback(server_write_cb) |
| 50 | 52 | .set_read_callback( |
| 51 | move |weechat, _config, section, option_name, _value| { | |
| 53 | move |weechat, _config, section, option_name, value| { | |
| 52 | 54 | let config = weak_config.clone(); |
| 53 | 55 | let servers = servers.clone(); |
| 54 | weechat.print("Hello server read cb"); | |
| 55 | 56 | |
| 56 | 57 | if option_name.is_empty() { |
| 57 | 58 | return OptionChanged::Error; |
| @@ -60,15 +61,12 @@ impl Config { | ||
| 60 | 61 | let option_args: Vec<&str> = |
| 61 | 62 | option_name.splitn(2, '.').collect(); |
| 62 | 63 | |
| 63 | weechat | |
| 64 | .print(&format!("Hello option args {:?}", option_args)); | |
| 65 | ||
| 66 | 64 | if option_args.len() != 2 { |
| 67 | 65 | return OptionChanged::Error; |
| 68 | 66 | } |
| 69 | 67 | |
| 70 | 68 | let server_name = option_args[0]; |
| 71 | let option_name = option_args[1]; | |
| 69 | let option = option_args[1]; | |
| 72 | 70 | |
| 73 | 71 | { |
| 74 | 72 | let servers = servers.upgrade(); |
| @@ -91,10 +89,10 @@ impl Config { | ||
| 91 | 89 | |
| 92 | 90 | let option = section.search_option(option_name); |
| 93 | 91 | |
| 94 | match option { | |
| 95 | // TODO instead of resetting set the option with the value. | |
| 96 | Some(o) => o.reset(true), | |
| 97 | None => OptionChanged::Error, | |
| 92 | if let Some(o) = option { | |
| 93 | o.set(value, true) | |
| 94 | } else { | |
| 95 | OptionChanged::NotFound | |
| 98 | 96 | } |
| 99 | 97 | }, |
| 100 | 98 | ); |
src/server.rs +10 −9
| @@ -19,7 +19,9 @@ use matrix_nio::{ | ||
| 19 | 19 | AsyncClient, AsyncClientConfig, SyncSettings, |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | use weechat::config::{BooleanOptionSettings, ConfigSection}; | |
| 22 | use weechat::config::{ | |
| 23 | BooleanOptionSettings, ConfigSection, IntegerOptionSettings, | |
| 24 | }; | |
| 23 | 25 | use weechat::Weechat; |
| 24 | 26 | |
| 25 | 27 | use crate::executor::spawn_weechat; |
| @@ -145,19 +147,18 @@ impl InnerServer { | ||
| 145 | 147 | weechat.print("Hello"); |
| 146 | 148 | }); |
| 147 | 149 | |
| 148 | // let server_buffer = IntegerOptionSettings::new(format!( | |
| 149 | // "{}.server_buffer", | |
| 150 | // self.name() | |
| 151 | // )) | |
| 152 | // .string_values(vec!["independent", "merged"]); | |
| 150 | let server_buffer = IntegerOptionSettings::new(format!( | |
| 151 | "{}.server_buffer", | |
| 152 | self.server_name | |
| 153 | )); | |
| 153 | 154 | |
| 154 | 155 | let autoconnect = server_section |
| 155 | 156 | .new_boolean_option(autoconnect) |
| 156 | 157 | .expect("Can't create autoconnect option"); |
| 157 | 158 | |
| 158 | // let autoconnect = server_section | |
| 159 | // .new_integer_option(server_buffer) | |
| 160 | // .expect("Can't create autoconnect option"); | |
| 159 | let server_buffer = server_section | |
| 160 | .new_integer_option(server_buffer) | |
| 161 | .expect("Can't create autoconnect option"); | |
| 161 | 162 | } |
| 162 | 163 | |
| 163 | 164 | pub(crate) fn get_or_create_room( |