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