diff --git a/backend-process/src/main.rs b/backend-process/src/main.rs index bc1ab33..b9ae923 100644 --- a/backend-process/src/main.rs +++ b/backend-process/src/main.rs @@ -12,6 +12,8 @@ use crate::input_handler::{ use crate::socket::commands::IncomingCommands; use firmware_api::device; use log::{debug, error, info}; +use messaging::protos::key_config::KeyConfig; +use messaging::protos::server_config::{DisplayImage, ServerConfig}; use std::fs::File; #[derive(Clone)] @@ -160,6 +162,36 @@ fn main() { dev.clear_all_images().ok(); dev.refresh().ok(); } + IncomingCommands::RequestServerConfig => { + let brightness = db.get_stored_brightness().ok(); + let input_mappings = db.get_all_input_mappings().ok(); + let display_zone_images = db.get_all_image_mappings().ok(); + let mut server_config = ServerConfig { + ..ServerConfig::default() + }; + + if let Some(brightness) = brightness + && let Some(brightness) = brightness + { + server_config.brightness = brightness.into(); + } + + if let Some(input_mappings) = input_mappings { + server_config.key_configs = input_mappings + .iter() + .map(|input_mapping| KeyConfig::from(input_mapping.clone())) + .collect(); + } + + if let Some(display_zone_images) = display_zone_images { + server_config.display_images = display_zone_images + .iter() + .map(|image| DisplayImage::from(image.to_owned())) + .collect() + } + + server.send_current_config(server_config).ok(); + } }, Err(e) => { info!("No known command was handled: {}", e); diff --git a/backend-process/src/protobuf_conversion.rs b/backend-process/src/protobuf_conversion.rs index 61506c0..be99141 100644 --- a/backend-process/src/protobuf_conversion.rs +++ b/backend-process/src/protobuf_conversion.rs @@ -2,19 +2,90 @@ use crate::database::models::{Action, ImageMapping, InputMapping}; use enigo::Key; use firmware_api::display_zones::DisplayZones; use firmware_api::inputs::InputActions; -use firmware_api::inputs::InputActions::Unknown; use firmware_api::inputs::buttons::ButtonActions; use firmware_api::inputs::knobs::KnobActions; use firmware_api::inputs::touchscreen::TouchscreenAction; use messaging::protos; -use messaging::protos::key_config::action::Action_data; -use messaging::protos::key_config::command_action; +use protobuf::EnumOrUnknown; use std::char; use std::io::{Error, ErrorKind}; /// Util struct for mapping the protobuf key into an `Enigo` key #[derive(Debug, PartialEq)] pub struct KeyWrapper(Key); +impl KeyWrapper { + // Single source of truth for all mappings + fn get_mappings() -> &'static [(protos::keys::Key, Key)] { + &[ + (protos::keys::Key::KEY_ADD, Key::Add), + (protos::keys::Key::KEY_ALT, Key::Alt), + (protos::keys::Key::KEY_BACKSPACE, Key::Backspace), + (protos::keys::Key::KEY_CAPS_LOCK, Key::CapsLock), + (protos::keys::Key::KEY_CONTROL, Key::Control), + (protos::keys::Key::KEY_DECIMAL, Key::Decimal), + (protos::keys::Key::KEY_DELETE, Key::Delete), + (protos::keys::Key::KEY_DIVIDE, Key::Divide), + (protos::keys::Key::KEY_DOWN_ARROW, Key::DownArrow), + (protos::keys::Key::KEY_END, Key::End), + (protos::keys::Key::KEY_ESCAPE, Key::Escape), + (protos::keys::Key::KEY_F1, Key::F1), + (protos::keys::Key::KEY_F2, Key::F2), + (protos::keys::Key::KEY_F3, Key::F3), + (protos::keys::Key::KEY_F4, Key::F4), + (protos::keys::Key::KEY_F5, Key::F5), + (protos::keys::Key::KEY_F6, Key::F6), + (protos::keys::Key::KEY_F7, Key::F7), + (protos::keys::Key::KEY_F8, Key::F8), + (protos::keys::Key::KEY_F9, Key::F9), + (protos::keys::Key::KEY_F10, Key::F10), + (protos::keys::Key::KEY_F11, Key::F11), + (protos::keys::Key::KEY_F12, Key::F12), + (protos::keys::Key::KEY_F13, Key::F13), + (protos::keys::Key::KEY_F14, Key::F14), + (protos::keys::Key::KEY_F15, Key::F15), + (protos::keys::Key::KEY_F16, Key::F16), + (protos::keys::Key::KEY_F17, Key::F17), + (protos::keys::Key::KEY_F18, Key::F18), + (protos::keys::Key::KEY_F19, Key::F19), + (protos::keys::Key::KEY_F20, Key::F20), + (protos::keys::Key::KEY_HELP, Key::Help), + (protos::keys::Key::KEY_HOME, Key::Home), + (protos::keys::Key::KEY_L_CONTROL, Key::LControl), + (protos::keys::Key::KEY_LEFT_ARROW, Key::LeftArrow), + (protos::keys::Key::KEY_L_SHIFT, Key::LShift), + (protos::keys::Key::KEY_MEDIA_NEXT_TRACK, Key::MediaNextTrack), + (protos::keys::Key::KEY_MEDIA_PLAY_PAUSE, Key::MediaPlayPause), + (protos::keys::Key::KEY_MEDIA_PREV_TRACK, Key::MediaPrevTrack), + (protos::keys::Key::KEY_META, Key::Meta), + (protos::keys::Key::KEY_MULTIPLY, Key::Multiply), + (protos::keys::Key::KEY_NUMPAD0, Key::Numpad0), + (protos::keys::Key::KEY_NUMPAD1, Key::Numpad1), + (protos::keys::Key::KEY_NUMPAD2, Key::Numpad2), + (protos::keys::Key::KEY_NUMPAD3, Key::Numpad3), + (protos::keys::Key::KEY_NUMPAD4, Key::Numpad4), + (protos::keys::Key::KEY_NUMPAD5, Key::Numpad5), + (protos::keys::Key::KEY_NUMPAD6, Key::Numpad6), + (protos::keys::Key::KEY_NUMPAD7, Key::Numpad7), + (protos::keys::Key::KEY_NUMPAD8, Key::Numpad8), + (protos::keys::Key::KEY_NUMPAD9, Key::Numpad9), + (protos::keys::Key::KEY_OPTION, Key::Option), + (protos::keys::Key::KEY_PAGE_DOWN, Key::PageDown), + (protos::keys::Key::KEY_PAGE_UP, Key::PageUp), + (protos::keys::Key::KEY_R_CONTROL, Key::RControl), + (protos::keys::Key::KEY_RETURN, Key::Return), + (protos::keys::Key::KEY_RIGHT_ARROW, Key::RightArrow), + (protos::keys::Key::KEY_R_SHIFT, Key::RShift), + (protos::keys::Key::KEY_SHIFT, Key::Shift), + (protos::keys::Key::KEY_SPACE, Key::Space), + (protos::keys::Key::KEY_SUBTRACT, Key::Subtract), + (protos::keys::Key::KEY_TAB, Key::Tab), + (protos::keys::Key::KEY_UP_ARROW, Key::UpArrow), + (protos::keys::Key::KEY_VOLUME_DOWN, Key::VolumeDown), + (protos::keys::Key::KEY_VOLUME_MUTE, Key::VolumeMute), + (protos::keys::Key::KEY_VOLUME_UP, Key::VolumeUp), + ] + } +} #[derive(Debug, PartialEq)] pub struct DisplayZoneWrapper(DisplayZones); @@ -23,129 +94,260 @@ pub struct DisplayZoneWrapper(DisplayZones); #[derive(Debug, PartialEq)] pub struct InputActionWrapper(InputActions); +impl InputActionWrapper { + fn get_mappings() -> &'static [(protos::inputs::InputId, InputActions)] { + &[ + ( + protos::inputs::InputId::INPUT_ACTION_UNSPECIFIED, + InputActions::Unknown, + ), + ( + protos::inputs::InputId::BUTTON_1_PRESSED, + InputActions::Button(ButtonActions::Button1Pressed), + ), + ( + protos::inputs::InputId::BUTTON_2_PRESSED, + InputActions::Button(ButtonActions::Button2Pressed), + ), + ( + protos::inputs::InputId::BUTTON_3_PRESSED, + InputActions::Button(ButtonActions::Button3Pressed), + ), + ( + protos::inputs::InputId::BUTTON_4_PRESSED, + InputActions::Button(ButtonActions::Button4Pressed), + ), + ( + protos::inputs::InputId::BUTTON_5_PRESSED, + InputActions::Button(ButtonActions::Button5Pressed), + ), + ( + protos::inputs::InputId::BUTTON_6_PRESSED, + InputActions::Button(ButtonActions::Button6Pressed), + ), + ( + protos::inputs::InputId::BUTTON_7_PRESSED, + InputActions::Button(ButtonActions::Button7Pressed), + ), + ( + protos::inputs::InputId::BUTTON_8_PRESSED, + InputActions::Button(ButtonActions::Button8Pressed), + ), + ( + protos::inputs::InputId::BUTTON_9_PRESSED, + InputActions::Button(ButtonActions::Button9Pressed), + ), + ( + protos::inputs::InputId::BUTTON_10_PRESSED, + InputActions::Button(ButtonActions::Button10Pressed), + ), + ( + protos::inputs::InputId::BUTTON_1_RELEASED, + InputActions::Button(ButtonActions::Button1Released), + ), + ( + protos::inputs::InputId::BUTTON_2_RELEASED, + InputActions::Button(ButtonActions::Button2Released), + ), + ( + protos::inputs::InputId::BUTTON_3_RELEASED, + InputActions::Button(ButtonActions::Button3Released), + ), + ( + protos::inputs::InputId::BUTTON_4_RELEASED, + InputActions::Button(ButtonActions::Button4Released), + ), + ( + protos::inputs::InputId::BUTTON_5_RELEASED, + InputActions::Button(ButtonActions::Button5Released), + ), + ( + protos::inputs::InputId::BUTTON_6_RELEASED, + InputActions::Button(ButtonActions::Button6Released), + ), + ( + protos::inputs::InputId::BUTTON_7_RELEASED, + InputActions::Button(ButtonActions::Button7Released), + ), + ( + protos::inputs::InputId::BUTTON_8_RELEASED, + InputActions::Button(ButtonActions::Button8Released), + ), + ( + protos::inputs::InputId::BUTTON_9_RELEASED, + InputActions::Button(ButtonActions::Button9Released), + ), + ( + protos::inputs::InputId::BUTTON_10_RELEASED, + InputActions::Button(ButtonActions::Button10Released), + ), + ( + protos::inputs::InputId::KNOB_1_CLOCKWISE, + InputActions::Knob(KnobActions::Knob1Clockwise), + ), + ( + protos::inputs::InputId::KNOB_2_CLOCKWISE, + InputActions::Knob(KnobActions::Knob2Clockwise), + ), + ( + protos::inputs::InputId::KNOB_3_CLOCKWISE, + InputActions::Knob(KnobActions::Knob3Clockwise), + ), + ( + protos::inputs::InputId::KNOB_4_CLOCKWISE, + InputActions::Knob(KnobActions::Knob4Clockwise), + ), + ( + protos::inputs::InputId::KNOB_1_COUNTER_CLOCKWISE, + InputActions::Knob(KnobActions::Knob1CounterClockwise), + ), + ( + protos::inputs::InputId::KNOB_2_COUNTER_CLOCKWISE, + InputActions::Knob(KnobActions::Knob2CounterClockwise), + ), + ( + protos::inputs::InputId::KNOB_3_COUNTER_CLOCKWISE, + InputActions::Knob(KnobActions::Knob3CounterClockwise), + ), + ( + protos::inputs::InputId::KNOB_4_COUNTER_CLOCKWISE, + InputActions::Knob(KnobActions::Knob4CounterClockwise), + ), + ( + protos::inputs::InputId::KNOB_1_PRESSED, + InputActions::Knob(KnobActions::Knob1Pressed), + ), + ( + protos::inputs::InputId::KNOB_2_PRESSED, + InputActions::Knob(KnobActions::Knob2Pressed), + ), + ( + protos::inputs::InputId::KNOB_3_PRESSED, + InputActions::Knob(KnobActions::Knob3Pressed), + ), + ( + protos::inputs::InputId::KNOB_4_PRESSED, + InputActions::Knob(KnobActions::Knob4Pressed), + ), + ( + protos::inputs::InputId::TOUCHSCREEN_ZONE_1_PRESSED, + InputActions::Touchscreen(TouchscreenAction::Zone1Pressed), + ), + ( + protos::inputs::InputId::TOUCHSCREEN_ZONE_2_PRESSED, + InputActions::Touchscreen(TouchscreenAction::Zone2Pressed), + ), + ( + protos::inputs::InputId::TOUCHSCREEN_ZONE_3_PRESSED, + InputActions::Touchscreen(TouchscreenAction::Zone3Pressed), + ), + ( + protos::inputs::InputId::TOUCHSCREEN_ZONE_4_PRESSED, + InputActions::Touchscreen(TouchscreenAction::Zone4Pressed), + ), + ( + protos::inputs::InputId::TOUCHSCREEN_SWIPED_LEFT, + InputActions::Touchscreen(TouchscreenAction::SwipedLeft), + ), + ( + protos::inputs::InputId::TOUCHSCREEN_SWIPED_RIGHT, + InputActions::Touchscreen(TouchscreenAction::SwipedRight), + ), + ] + } +} + +impl From for protos::inputs::InputId { + fn from(wrapper: InputActionWrapper) -> Self { + InputActionWrapper::get_mappings() + .iter() + .find(|(_, action)| *action == wrapper.0) + .map(|(input_id, _)| *input_id) + .unwrap_or(protos::inputs::InputId::INPUT_ACTION_UNSPECIFIED) + } +} + impl From for InputActionWrapper { fn from(value: protos::inputs::InputId) -> InputActionWrapper { - match value { - protos::inputs::InputId::INPUT_ACTION_UNSPECIFIED => InputActionWrapper(Unknown), - - protos::inputs::InputId::BUTTON_1_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button1Pressed)) - } - protos::inputs::InputId::BUTTON_2_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button2Pressed)) - } - protos::inputs::InputId::BUTTON_3_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button3Pressed)) - } - protos::inputs::InputId::BUTTON_4_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button4Pressed)) - } - protos::inputs::InputId::BUTTON_5_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button5Pressed)) - } - protos::inputs::InputId::BUTTON_6_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button6Pressed)) - } - protos::inputs::InputId::BUTTON_7_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button7Pressed)) - } - protos::inputs::InputId::BUTTON_8_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button8Pressed)) - } - protos::inputs::InputId::BUTTON_9_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button9Pressed)) - } - protos::inputs::InputId::BUTTON_10_PRESSED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button10Pressed)) - } + let action = Self::get_mappings() + .iter() + .find(|(input_id, _)| *input_id == value) + .map(|(_, action)| action.clone()) + .unwrap_or(InputActions::Unknown); - protos::inputs::InputId::BUTTON_1_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button1Released)) - } - protos::inputs::InputId::BUTTON_2_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button2Released)) - } - protos::inputs::InputId::BUTTON_3_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button3Released)) - } - protos::inputs::InputId::BUTTON_4_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button4Released)) - } - protos::inputs::InputId::BUTTON_5_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button5Released)) - } - protos::inputs::InputId::BUTTON_6_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button6Released)) - } - protos::inputs::InputId::BUTTON_7_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button7Released)) - } - protos::inputs::InputId::BUTTON_8_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button8Released)) - } - protos::inputs::InputId::BUTTON_9_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button9Released)) - } - protos::inputs::InputId::BUTTON_10_RELEASED => { - InputActionWrapper(InputActions::Button(ButtonActions::Button10Released)) - } + InputActionWrapper(action) + } +} - protos::inputs::InputId::KNOB_1_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob1Clockwise)) - } - protos::inputs::InputId::KNOB_2_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob2Clockwise)) - } - protos::inputs::InputId::KNOB_3_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob3Clockwise)) - } - protos::inputs::InputId::KNOB_4_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob4Clockwise)) - } - protos::inputs::InputId::KNOB_1_COUNTER_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob1CounterClockwise)) - } - protos::inputs::InputId::KNOB_2_COUNTER_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob2CounterClockwise)) - } - protos::inputs::InputId::KNOB_3_COUNTER_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob3CounterClockwise)) - } - protos::inputs::InputId::KNOB_4_COUNTER_CLOCKWISE => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob4CounterClockwise)) - } +impl From for protos::key_config::KeyConfig { + fn from(input: InputMapping) -> Self { + protos::key_config::KeyConfig { + input_id: EnumOrUnknown::new(protos::inputs::InputId::from(InputActionWrapper( + input.input(), + ))), + actions: input + .actions() + .iter() + .map(|action| protos::key_config::Action::from(action.clone())) + .collect(), + ..protos::key_config::KeyConfig::default() + } + } +} - protos::inputs::InputId::KNOB_1_PRESSED => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob1Pressed)) - } - protos::inputs::InputId::KNOB_2_PRESSED => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob2Pressed)) - } - protos::inputs::InputId::KNOB_3_PRESSED => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob3Pressed)) - } - protos::inputs::InputId::KNOB_4_PRESSED => { - InputActionWrapper(InputActions::Knob(KnobActions::Knob4Pressed)) - } +impl From for protos::key_config::Action { + fn from(action: Action) -> Self { + protos::key_config::Action { + action_data: match action { + Action::Command(command, args) => { + Some(protos::key_config::action::Action_data::CommandAction( + protos::key_config::CommandAction { + command: Some( + protos::key_config::command_action::Command::FreeformCommand( + protos::key_config::FreeformCommand { + command, + args, + ..protos::key_config::FreeformCommand::default() + }, + ), + ), + ..protos::key_config::CommandAction::default() + }, + )) + } + Action::Key(key, modifiers) => { + Some(protos::key_config::action::Action_data::KeyAction( + protos::key_config::KeyAction { + key: EnumOrUnknown::new(protos::keys::Key::from(KeyWrapper(key))), + modifier: modifiers + .iter() + .map(|m| { + EnumOrUnknown::new(protos::keys::Key::from(KeyWrapper(*m))) + }) + .collect(), + unicode: match key { + Key::Unicode(char) => Some(u32::from(char)), + _ => None, + }, + ..protos::key_config::KeyAction::default() + }, + )) + } + Action::Noop => None, + }, + ..protos::key_config::Action::default() + } + } +} - protos::inputs::InputId::TOUCHSCREEN_ZONE_1_PRESSED => { - InputActionWrapper(InputActions::Touchscreen(TouchscreenAction::Zone1Pressed)) - } - protos::inputs::InputId::TOUCHSCREEN_ZONE_2_PRESSED => { - InputActionWrapper(InputActions::Touchscreen(TouchscreenAction::Zone2Pressed)) - } - protos::inputs::InputId::TOUCHSCREEN_ZONE_3_PRESSED => { - InputActionWrapper(InputActions::Touchscreen(TouchscreenAction::Zone3Pressed)) - } - protos::inputs::InputId::TOUCHSCREEN_ZONE_4_PRESSED => { - InputActionWrapper(InputActions::Touchscreen(TouchscreenAction::Zone4Pressed)) - } - protos::inputs::InputId::TOUCHSCREEN_SWIPED_LEFT => { - InputActionWrapper(InputActions::Touchscreen(TouchscreenAction::SwipedLeft)) - } - protos::inputs::InputId::TOUCHSCREEN_SWIPED_RIGHT => { - InputActionWrapper(InputActions::Touchscreen(TouchscreenAction::SwipedRight)) - } +impl From for protos::server_config::DisplayImage { + fn from(mapping: ImageMapping) -> Self { + protos::server_config::DisplayImage { + display_zone: EnumOrUnknown::new(protos::display_zones::DisplayZone::from( + DisplayZoneWrapper(mapping.display_zone), + )), + path: mapping.image_path, + ..protos::server_config::DisplayImage::default() } } } @@ -161,13 +363,13 @@ impl TryFrom for InputMapping { .map(|a| { match a.clone().action_data { Some(item) => match item { - Action_data::CommandAction(command) => { + protos::key_config::action::Action_data::CommandAction(command) => { if let Some(command_type) = command.command { return match command_type { - command_action::Command::FreeformCommand(command) => { + protos::key_config::command_action::Command::FreeformCommand(command) => { Action::Command(command.command, command.args) } - command_action::Command::OpenAppCommand(command) => { + protos::key_config::command_action::Command::OpenAppCommand(command) => { Action::Command( String::from("Open command"), vec![command.app_path], @@ -178,7 +380,7 @@ impl TryFrom for InputMapping { } Action::Noop } - Action_data::KeyAction(key) => { + protos::key_config::action::Action_data::KeyAction(key) => { if let Ok(key_val) = KeyWrapper::try_from(key.clone()) { return Action::Key( key_val.0, @@ -230,139 +432,121 @@ impl DisplayZoneWrapper { } } +impl DisplayZoneWrapper { + fn get_mappings() -> &'static [(protos::display_zones::DisplayZone, DisplayZones)] { + &[ + ( + protos::display_zones::DisplayZone::BUTTON_1, + DisplayZones::Button1, + ), + ( + protos::display_zones::DisplayZone::BUTTON_2, + DisplayZones::Button2, + ), + ( + protos::display_zones::DisplayZone::BUTTON_3, + DisplayZones::Button3, + ), + ( + protos::display_zones::DisplayZone::BUTTON_4, + DisplayZones::Button4, + ), + ( + protos::display_zones::DisplayZone::BUTTON_5, + DisplayZones::Button5, + ), + ( + protos::display_zones::DisplayZone::BUTTON_6, + DisplayZones::Button6, + ), + ( + protos::display_zones::DisplayZone::BUTTON_7, + DisplayZones::Button7, + ), + ( + protos::display_zones::DisplayZone::BUTTON_8, + DisplayZones::Button8, + ), + ( + protos::display_zones::DisplayZone::BUTTON_9, + DisplayZones::Button9, + ), + ( + protos::display_zones::DisplayZone::BUTTON_10, + DisplayZones::Button10, + ), + ( + protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_1, + DisplayZones::Touchscreen1, + ), + ( + protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_2, + DisplayZones::Touchscreen2, + ), + ( + protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_3, + DisplayZones::Touchscreen3, + ), + ( + protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_4, + DisplayZones::Touchscreen4, + ), + ] + } +} + +impl From for protos::display_zones::DisplayZone { + fn from(value: DisplayZoneWrapper) -> Self { + DisplayZoneWrapper::get_mappings() + .iter() + .find(|(_, zone)| *zone == value.display_zone()) + .map(|(proto_zone, _)| *proto_zone) + .unwrap_or(protos::display_zones::DisplayZone::DISPLAY_ZONE_UNSPECIFIED) // or whatever default you prefer + } +} + impl TryFrom for DisplayZoneWrapper { type Error = Error; fn try_from(value: protos::display_zones::DisplayZone) -> Result { - let value = match value { - protos::display_zones::DisplayZone::BUTTON_1 => { - DisplayZoneWrapper(DisplayZones::Button1) - } - protos::display_zones::DisplayZone::BUTTON_2 => { - DisplayZoneWrapper(DisplayZones::Button2) - } - protos::display_zones::DisplayZone::BUTTON_3 => { - DisplayZoneWrapper(DisplayZones::Button3) - } - protos::display_zones::DisplayZone::BUTTON_4 => { - DisplayZoneWrapper(DisplayZones::Button4) - } - protos::display_zones::DisplayZone::BUTTON_5 => { - DisplayZoneWrapper(DisplayZones::Button5) - } - protos::display_zones::DisplayZone::BUTTON_6 => { - DisplayZoneWrapper(DisplayZones::Button6) - } - protos::display_zones::DisplayZone::BUTTON_7 => { - DisplayZoneWrapper(DisplayZones::Button7) - } - protos::display_zones::DisplayZone::BUTTON_8 => { - DisplayZoneWrapper(DisplayZones::Button8) - } - protos::display_zones::DisplayZone::BUTTON_9 => { - DisplayZoneWrapper(DisplayZones::Button9) - } - protos::display_zones::DisplayZone::BUTTON_10 => { - DisplayZoneWrapper(DisplayZones::Button10) - } - protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_1 => { - DisplayZoneWrapper(DisplayZones::Touchscreen1) - } - protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_2 => { - DisplayZoneWrapper(DisplayZones::Touchscreen2) - } - protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_3 => { - DisplayZoneWrapper(DisplayZones::Touchscreen3) - } - protos::display_zones::DisplayZone::TOUCHSCREEN_ZONE_4 => { - DisplayZoneWrapper(DisplayZones::Touchscreen4) - } - - _ => Err(Error::new( - ErrorKind::InvalidData, - "Not a valid display zone", - ))?, - }; - - Ok(value) + Self::get_mappings() + .iter() + .find(|(proto_zone, _)| *proto_zone == value) + .map(|(_, zone)| DisplayZoneWrapper(*zone)) + .ok_or_else(|| Error::new(ErrorKind::InvalidData, "Not a valid display zone")) } } impl From for KeyWrapper { fn from(value: protos::keys::Key) -> Self { + if let Some((_, key)) = Self::get_mappings() + .iter() + .find(|(proto_key, _)| *proto_key == value) + { + return KeyWrapper(*key); + } match value { - protos::keys::Key::KEY_ADD => KeyWrapper(Key::Add), - protos::keys::Key::KEY_ALT => KeyWrapper(Key::Alt), - protos::keys::Key::KEY_BACKSPACE => KeyWrapper(Key::Backspace), - protos::keys::Key::KEY_CAPS_LOCK => KeyWrapper(Key::CapsLock), - protos::keys::Key::KEY_CONTROL => KeyWrapper(Key::Control), - protos::keys::Key::KEY_DECIMAL => KeyWrapper(Key::Decimal), - protos::keys::Key::KEY_DELETE => KeyWrapper(Key::Delete), - protos::keys::Key::KEY_DIVIDE => KeyWrapper(Key::Divide), - protos::keys::Key::KEY_DOWN_ARROW => KeyWrapper(Key::DownArrow), - protos::keys::Key::KEY_END => KeyWrapper(Key::End), - protos::keys::Key::KEY_ESCAPE => KeyWrapper(Key::Escape), - protos::keys::Key::KEY_F1 => KeyWrapper(Key::F1), - protos::keys::Key::KEY_F2 => KeyWrapper(Key::F2), - protos::keys::Key::KEY_F3 => KeyWrapper(Key::F3), - protos::keys::Key::KEY_F4 => KeyWrapper(Key::F4), - protos::keys::Key::KEY_F5 => KeyWrapper(Key::F5), - protos::keys::Key::KEY_F6 => KeyWrapper(Key::F6), - protos::keys::Key::KEY_F7 => KeyWrapper(Key::F7), - protos::keys::Key::KEY_F8 => KeyWrapper(Key::F8), - protos::keys::Key::KEY_F9 => KeyWrapper(Key::F9), - protos::keys::Key::KEY_F10 => KeyWrapper(Key::F10), - protos::keys::Key::KEY_F11 => KeyWrapper(Key::F11), - protos::keys::Key::KEY_F12 => KeyWrapper(Key::F12), - protos::keys::Key::KEY_F13 => KeyWrapper(Key::F13), - protos::keys::Key::KEY_F14 => KeyWrapper(Key::F14), - protos::keys::Key::KEY_F15 => KeyWrapper(Key::F15), - protos::keys::Key::KEY_F16 => KeyWrapper(Key::F16), - protos::keys::Key::KEY_F17 => KeyWrapper(Key::F17), - protos::keys::Key::KEY_F18 => KeyWrapper(Key::F18), - protos::keys::Key::KEY_F19 => KeyWrapper(Key::F19), - protos::keys::Key::KEY_F20 => KeyWrapper(Key::F20), - protos::keys::Key::KEY_HELP => KeyWrapper(Key::Help), - protos::keys::Key::KEY_HOME => KeyWrapper(Key::Home), - protos::keys::Key::KEY_L_CONTROL => KeyWrapper(Key::LControl), - protos::keys::Key::KEY_LEFT_ARROW => KeyWrapper(Key::LeftArrow), - protos::keys::Key::KEY_L_SHIFT => KeyWrapper(Key::LShift), - protos::keys::Key::KEY_MEDIA_NEXT_TRACK => KeyWrapper(Key::MediaNextTrack), - protos::keys::Key::KEY_MEDIA_PLAY_PAUSE => KeyWrapper(Key::MediaPlayPause), - protos::keys::Key::KEY_MEDIA_PREV_TRACK => KeyWrapper(Key::MediaPrevTrack), - protos::keys::Key::KEY_META => KeyWrapper(Key::Meta), - protos::keys::Key::KEY_MULTIPLY => KeyWrapper(Key::Multiply), - protos::keys::Key::KEY_NUMPAD0 => KeyWrapper(Key::Numpad0), - protos::keys::Key::KEY_NUMPAD1 => KeyWrapper(Key::Numpad1), - protos::keys::Key::KEY_NUMPAD2 => KeyWrapper(Key::Numpad2), - protos::keys::Key::KEY_NUMPAD3 => KeyWrapper(Key::Numpad3), - protos::keys::Key::KEY_NUMPAD4 => KeyWrapper(Key::Numpad4), - protos::keys::Key::KEY_NUMPAD5 => KeyWrapper(Key::Numpad5), - protos::keys::Key::KEY_NUMPAD6 => KeyWrapper(Key::Numpad6), - protos::keys::Key::KEY_NUMPAD7 => KeyWrapper(Key::Numpad7), - protos::keys::Key::KEY_NUMPAD8 => KeyWrapper(Key::Numpad8), - protos::keys::Key::KEY_NUMPAD9 => KeyWrapper(Key::Numpad9), - protos::keys::Key::KEY_OPTION => KeyWrapper(Key::Option), - protos::keys::Key::KEY_PAGE_DOWN => KeyWrapper(Key::PageDown), - protos::keys::Key::KEY_PAGE_UP => KeyWrapper(Key::PageUp), - protos::keys::Key::KEY_R_CONTROL => KeyWrapper(Key::RControl), - protos::keys::Key::KEY_RETURN => KeyWrapper(Key::Return), - protos::keys::Key::KEY_RIGHT_ARROW => KeyWrapper(Key::RightArrow), - protos::keys::Key::KEY_R_SHIFT => KeyWrapper(Key::RShift), - protos::keys::Key::KEY_SHIFT => KeyWrapper(Key::Shift), - protos::keys::Key::KEY_SPACE => KeyWrapper(Key::Space), - protos::keys::Key::KEY_SUBTRACT => KeyWrapper(Key::Subtract), - protos::keys::Key::KEY_TAB => KeyWrapper(Key::Tab), - protos::keys::Key::KEY_UP_ARROW => KeyWrapper(Key::UpArrow), - protos::keys::Key::KEY_VOLUME_DOWN => KeyWrapper(Key::VolumeDown), - protos::keys::Key::KEY_VOLUME_MUTE => KeyWrapper(Key::VolumeMute), - protos::keys::Key::KEY_VOLUME_UP => KeyWrapper(Key::VolumeUp), protos::keys::Key::KEY_UNICODE => KeyWrapper(Key::Unicode(char::default())), protos::keys::Key::KEY_OTHER => KeyWrapper(Key::Other(u32::default())), _ => KeyWrapper(Key::Other(u32::default())), } } } +impl From for protos::keys::Key { + fn from(wrapper: KeyWrapper) -> Self { + if let Some((proto_key, _)) = KeyWrapper::get_mappings() + .iter() + .find(|(_, key)| *key == wrapper.0) + { + return *proto_key; + } + match wrapper.0 { + Key::Unicode(_) => protos::keys::Key::KEY_UNICODE, + Key::Other(_) => protos::keys::Key::KEY_OTHER, + _ => protos::keys::Key::KEY_OTHER, + } + } +} impl TryFrom for KeyWrapper { type Error = String; @@ -398,7 +582,7 @@ impl TryFrom for KeyWrapper { #[cfg(test)] mod tests { use super::*; - use firmware_api::inputs::InputActions::Knob; + use firmware_api::inputs::InputActions::{Knob, Unknown}; use messaging::protos::key_config::FreeformCommand; #[test] @@ -443,7 +627,7 @@ mod tests { fn create_proto_fixture( proto_input_id: protos::inputs::InputId, - action_data: Vec, + action_data: Vec, ) -> protos::key_config::KeyConfig { protos::key_config::KeyConfig { input_id: protobuf::EnumOrUnknown::new(proto_input_id), @@ -461,10 +645,12 @@ mod tests { fn converts_mapping_into_model() { let proto = create_proto_fixture( protos::inputs::InputId::KNOB_1_CLOCKWISE, - vec![Action_data::KeyAction(protos::key_config::KeyAction { - key: protos::keys::Key::KEY_ADD.into(), - ..protos::key_config::KeyAction::default() - })], + vec![protos::key_config::action::Action_data::KeyAction( + protos::key_config::KeyAction { + key: protos::keys::Key::KEY_ADD.into(), + ..protos::key_config::KeyAction::default() + }, + )], ); assert_eq!( @@ -481,18 +667,24 @@ mod tests { let proto = create_proto_fixture( protos::inputs::InputId::INPUT_ACTION_UNSPECIFIED, vec![ - Action_data::KeyAction(protos::key_config::KeyAction { + protos::key_config::action::Action_data::KeyAction(protos::key_config::KeyAction { key: protos::keys::Key::KEY_ADD.into(), ..protos::key_config::KeyAction::default() }), - Action_data::CommandAction(protos::key_config::CommandAction { - command: Some(command_action::Command::FreeformCommand(FreeformCommand { - command: String::from("command"), - args: vec![String::from("arg1"), String::from("arg2")], - ..FreeformCommand::default() - })), - ..protos::key_config::CommandAction::default() - }), + protos::key_config::action::Action_data::CommandAction( + protos::key_config::CommandAction { + command: Some( + protos::key_config::command_action::Command::FreeformCommand( + FreeformCommand { + command: String::from("command"), + args: vec![String::from("arg1"), String::from("arg2")], + ..FreeformCommand::default() + }, + ), + ), + ..protos::key_config::CommandAction::default() + }, + ), ], ); diff --git a/backend-process/src/socket/commands.rs b/backend-process/src/socket/commands.rs index b512788..a4b430e 100644 --- a/backend-process/src/socket/commands.rs +++ b/backend-process/src/socket/commands.rs @@ -9,4 +9,5 @@ pub enum IncomingCommands { ClearAllDisplayZoneImages, SetBootLogo(String), SetBrightness(u8), + RequestServerConfig, } diff --git a/backend-process/src/socket/connection.rs b/backend-process/src/socket/connection.rs index 470ec42..0bedd32 100644 --- a/backend-process/src/socket/connection.rs +++ b/backend-process/src/socket/connection.rs @@ -3,10 +3,11 @@ use crate::database::operations::Operations; use crate::input_handler::InputMapping; use crate::protobuf_conversion::DisplayZoneWrapper; use crate::socket::commands::IncomingCommands; +use messaging::protos::server_config::ServerConfig; use messaging::protos::top_level::TopLevel; use messaging::protos::top_level::top_level::Command; use messaging::socket; -use messaging::socket::MessageReceiver; +use messaging::socket::{MessageReceiver, MessageSender}; use protobuf::Message; use std::io::{Error, ErrorKind}; @@ -26,6 +27,13 @@ impl<'a> ServerHandler<'a> { }) } + /// Given a `ServerConfig`, will broadcast the config to the connected clients, which + /// will have to read and parse this + pub fn send_current_config(&mut self, config: ServerConfig) -> Result<(), Error> { + let bytes = config.write_to_bytes()?; + self.server.send_message(bytes.as_slice()) + } + /// Checks if there is a message from the connected clients. /// /// It will either: @@ -105,6 +113,9 @@ impl<'a> ServerHandler<'a> { )); } } + Command::RequestServerConfig(_) => { + return Ok(IncomingCommands::RequestServerConfig); + } _ => {} }, None => { diff --git a/config-frontend/src/main.rs b/config-frontend/src/main.rs index d87f61a..b12ade5 100644 --- a/config-frontend/src/main.rs +++ b/config-frontend/src/main.rs @@ -136,7 +136,11 @@ fn update(application_state: &mut LaunchpadConfigApp, message: Messages) -> Task }, Messages::RemoveAction(index) => { - if index < application_state.current_input_sequence.len() { + if application_state + .current_input_sequence + .get(index) + .is_some() + { application_state.current_input_sequence.remove(index); } } diff --git a/messaging/build.rs b/messaging/build.rs index 9d1441f..45e269d 100644 --- a/messaging/build.rs +++ b/messaging/build.rs @@ -11,10 +11,12 @@ fn main() { .includes(["protobufs"]) // Inputs must reside in some of include paths. .input("protobufs/top_level.proto") + .input("protobufs/server_config.proto") .input("protobufs/commands/key_config.proto") .input("protobufs/commands/boot_logo.proto") .input("protobufs/commands/brightness.proto") .input("protobufs/commands/display_zone_image.proto") + .input("protobufs/commands/server_request.proto") .input("protobufs/commands/common/keys.proto") .input("protobufs/commands/common/inputs.proto") .input("protobufs/commands/common/display_zones.proto") diff --git a/messaging/examples/client_sending_key_config_to_server.rs b/messaging/examples/client_sending_key_config_to_server.rs index 2ddee73..55321a1 100644 --- a/messaging/examples/client_sending_key_config_to_server.rs +++ b/messaging/examples/client_sending_key_config_to_server.rs @@ -40,6 +40,7 @@ fn main() { println!("4. Set brightness"); println!("5. Clear all key images"); println!("6. Clear single key image"); + println!("6. Request current server config"); io::stdin().read_line(&mut buffer).unwrap(); let mut handler = ClientWrapper::new(client); @@ -106,6 +107,11 @@ fn main() { 6 => handler .clear_display_zone_image(DisplayZone::BUTTON_2) .unwrap(), + 7 => { + handler.request_server_config().unwrap(); + let result = handler.check_for_server_config().unwrap(); + println!("{:?}", result); + } _ => { panic!("Out of range of options!") } diff --git a/messaging/protobufs/commands/config_state.proto b/messaging/protobufs/commands/config_state.proto new file mode 100644 index 0000000..a574e57 --- /dev/null +++ b/messaging/protobufs/commands/config_state.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package config_state; + +message RequestConfigState {} + +message CurrentConfigState { + uint32 brightness = 1; +} diff --git a/messaging/protobufs/commands/server_request.proto b/messaging/protobufs/commands/server_request.proto new file mode 100644 index 0000000..877fc65 --- /dev/null +++ b/messaging/protobufs/commands/server_request.proto @@ -0,0 +1,6 @@ +syntax = "proto3"; + +package server_request; + +message RequestServerConfig {} + diff --git a/messaging/protobufs/server_config.proto b/messaging/protobufs/server_config.proto new file mode 100644 index 0000000..5201db5 --- /dev/null +++ b/messaging/protobufs/server_config.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +import "commands/key_config.proto"; +import "commands/common/display_zones.proto"; + +message DisplayImage { + DisplayZone display_zone = 1; + string path = 2; +} + +message ServerConfig { + repeated key_config.KeyConfig key_configs = 1; + repeated DisplayImage display_images = 2; + uint32 brightness = 3; +} \ No newline at end of file diff --git a/messaging/protobufs/top_level.proto b/messaging/protobufs/top_level.proto index f7130ab..4782757 100644 --- a/messaging/protobufs/top_level.proto +++ b/messaging/protobufs/top_level.proto @@ -4,6 +4,7 @@ import 'commands/boot_logo.proto'; import 'commands/display_zone_image.proto'; import 'commands/brightness.proto'; import 'commands/key_config.proto'; +import 'commands/server_request.proto'; message TopLevel { oneof command { @@ -13,5 +14,6 @@ message TopLevel { display_zone_image.ClearAllDisplayZoneImages clear_all_display_zone_images_command = 4; brightness.SetBrightness set_brightness_command = 5; boot_logo.SetBootLogo set_boot_logo_command = 6; + server_request.RequestServerConfig request_server_config = 7; } } \ No newline at end of file diff --git a/messaging/src/client_wrapper.rs b/messaging/src/client_wrapper.rs index f129d81..6c42341 100644 --- a/messaging/src/client_wrapper.rs +++ b/messaging/src/client_wrapper.rs @@ -6,10 +6,12 @@ use crate::protos::display_zone_image::{ use crate::protos::display_zones::DisplayZone; use crate::protos::inputs::InputId; use crate::protos::key_config::{Action, KeyConfig}; +use crate::protos::server_config::ServerConfig; +use crate::protos::server_request::RequestServerConfig; use crate::protos::top_level::TopLevel; use crate::protos::top_level::top_level::Command; use crate::socket; -use crate::socket::MessageSender; +use crate::socket::{MessageReceiver, MessageSender}; use protobuf::{EnumOrUnknown, Message}; use std::io::Error; @@ -55,6 +57,10 @@ pub trait ClientCommands { /// /// * `display_zone` - the specific area/zone of the display to clear fn clear_display_zone_image(&mut self, display_zone: DisplayZone) -> Result<(), Error>; + /// Sends a request for the server to produce a config message + fn request_server_config(&mut self) -> Result<(), Error>; + /// _Blocking_ call for checking if the server has sent the config + fn check_for_server_config(&mut self) -> Result; } /// To be used by any client that wants to communicate with the server @@ -141,6 +147,21 @@ impl ClientCommands for ClientWrapper { .as_slice(), ) } + + fn request_server_config(&mut self) -> Result<(), Error> { + self.client.send_message( + create_command(Command::RequestServerConfig(RequestServerConfig { + ..RequestServerConfig::default() + })) + .write_to_bytes()? + .as_slice(), + ) + } + + fn check_for_server_config(&mut self) -> Result { + let message = self.client.read_message()?; + Ok(ServerConfig::parse_from_bytes(message.as_slice())?) + } } fn create_command(command: Command) -> TopLevel { diff --git a/messaging/src/protos/mod.rs b/messaging/src/protos/mod.rs index 5322b0c..c90c68a 100644 --- a/messaging/src/protos/mod.rs +++ b/messaging/src/protos/mod.rs @@ -7,4 +7,6 @@ pub mod display_zones; pub mod inputs; pub mod key_config; pub mod keys; +pub mod server_config; +pub mod server_request; pub mod top_level; diff --git a/messaging/src/protos/server_config.rs b/messaging/src/protos/server_config.rs new file mode 100644 index 0000000..d5fbcc0 --- /dev/null +++ b/messaging/src/protos/server_config.rs @@ -0,0 +1,367 @@ +// This file is generated by rust-protobuf 3.7.2. Do not edit +// .proto file is parsed by protoc 31.1 +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `server_config.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_7_2; + +// @@protoc_insertion_point(message:DisplayImage) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct DisplayImage { + // message fields + // @@protoc_insertion_point(field:DisplayImage.display_zone) + pub display_zone: ::protobuf::EnumOrUnknown, + // @@protoc_insertion_point(field:DisplayImage.path) + pub path: ::std::string::String, + // special fields + // @@protoc_insertion_point(special_field:DisplayImage.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a DisplayImage { + fn default() -> &'a DisplayImage { + ::default_instance() + } +} + +impl DisplayImage { + pub fn new() -> DisplayImage { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "display_zone", + |m: &DisplayImage| { &m.display_zone }, + |m: &mut DisplayImage| { &mut m.display_zone }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "path", + |m: &DisplayImage| { &m.path }, + |m: &mut DisplayImage| { &mut m.path }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "DisplayImage", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for DisplayImage { + const NAME: &'static str = "DisplayImage"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.display_zone = is.read_enum_or_unknown()?; + }, + 18 => { + self.path = is.read_string()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if self.display_zone != ::protobuf::EnumOrUnknown::new(super::display_zones::DisplayZone::DISPLAY_ZONE_UNSPECIFIED) { + my_size += ::protobuf::rt::int32_size(1, self.display_zone.value()); + } + if !self.path.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.path); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if self.display_zone != ::protobuf::EnumOrUnknown::new(super::display_zones::DisplayZone::DISPLAY_ZONE_UNSPECIFIED) { + os.write_enum(1, ::protobuf::EnumOrUnknown::value(&self.display_zone))?; + } + if !self.path.is_empty() { + os.write_string(2, &self.path)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> DisplayImage { + DisplayImage::new() + } + + fn clear(&mut self) { + self.display_zone = ::protobuf::EnumOrUnknown::new(super::display_zones::DisplayZone::DISPLAY_ZONE_UNSPECIFIED); + self.path.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static DisplayImage { + static instance: DisplayImage = DisplayImage { + display_zone: ::protobuf::EnumOrUnknown::from_i32(0), + path: ::std::string::String::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for DisplayImage { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("DisplayImage").unwrap()).clone() + } +} + +impl ::std::fmt::Display for DisplayImage { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for DisplayImage { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:ServerConfig) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct ServerConfig { + // message fields + // @@protoc_insertion_point(field:ServerConfig.key_configs) + pub key_configs: ::std::vec::Vec, + // @@protoc_insertion_point(field:ServerConfig.display_images) + pub display_images: ::std::vec::Vec, + // @@protoc_insertion_point(field:ServerConfig.brightness) + pub brightness: u32, + // special fields + // @@protoc_insertion_point(special_field:ServerConfig.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a ServerConfig { + fn default() -> &'a ServerConfig { + ::default_instance() + } +} + +impl ServerConfig { + pub fn new() -> ServerConfig { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "key_configs", + |m: &ServerConfig| { &m.key_configs }, + |m: &mut ServerConfig| { &mut m.key_configs }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "display_images", + |m: &ServerConfig| { &m.display_images }, + |m: &mut ServerConfig| { &mut m.display_images }, + )); + fields.push(::protobuf::reflect::rt::v2::make_simpler_field_accessor::<_, _>( + "brightness", + |m: &ServerConfig| { &m.brightness }, + |m: &mut ServerConfig| { &mut m.brightness }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "ServerConfig", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for ServerConfig { + const NAME: &'static str = "ServerConfig"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.key_configs.push(is.read_message()?); + }, + 18 => { + self.display_images.push(is.read_message()?); + }, + 24 => { + self.brightness = is.read_uint32()?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.key_configs { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + for value in &self.display_images { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if self.brightness != 0 { + my_size += ::protobuf::rt::uint32_size(3, self.brightness); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.key_configs { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + for v in &self.display_images { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + }; + if self.brightness != 0 { + os.write_uint32(3, self.brightness)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> ServerConfig { + ServerConfig::new() + } + + fn clear(&mut self) { + self.key_configs.clear(); + self.display_images.clear(); + self.brightness = 0; + self.special_fields.clear(); + } + + fn default_instance() -> &'static ServerConfig { + static instance: ServerConfig = ServerConfig { + key_configs: ::std::vec::Vec::new(), + display_images: ::std::vec::Vec::new(), + brightness: 0, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for ServerConfig { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("ServerConfig").unwrap()).clone() + } +} + +impl ::std::fmt::Display for ServerConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ServerConfig { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x13server_config.proto\x1a\x19commands/key_config.proto\x1a#commands/\ + common/display_zones.proto\"S\n\x0cDisplayImage\x12/\n\x0cdisplay_zone\ + \x18\x01\x20\x01(\x0e2\x0c.DisplayZoneR\x0bdisplayZone\x12\x12\n\x04path\ + \x18\x02\x20\x01(\tR\x04path\"\x9c\x01\n\x0cServerConfig\x126\n\x0bkey_c\ + onfigs\x18\x01\x20\x03(\x0b2\x15.key_config.KeyConfigR\nkeyConfigs\x124\ + \n\x0edisplay_images\x18\x02\x20\x03(\x0b2\r.DisplayImageR\rdisplayImage\ + s\x12\x1e\n\nbrightness\x18\x03\x20\x01(\rR\nbrightnessb\x06proto3\ +"; + +/// `FileDescriptorProto` object which was a source for this generated file +fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); + file_descriptor_proto_lazy.get(|| { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() + }) +} + +/// `FileDescriptor` object which allows dynamic access to files +pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { + static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); + static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); + file_descriptor.get(|| { + let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { + let mut deps = ::std::vec::Vec::with_capacity(2); + deps.push(super::key_config::file_descriptor().clone()); + deps.push(super::display_zones::file_descriptor().clone()); + let mut messages = ::std::vec::Vec::with_capacity(2); + messages.push(DisplayImage::generated_message_descriptor_data()); + messages.push(ServerConfig::generated_message_descriptor_data()); + let mut enums = ::std::vec::Vec::with_capacity(0); + ::protobuf::reflect::GeneratedFileDescriptor::new_generated( + file_descriptor_proto(), + deps, + messages, + enums, + ) + }); + ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) + }) +} diff --git a/messaging/src/protos/server_request.rs b/messaging/src/protos/server_request.rs new file mode 100644 index 0000000..fc6f0df --- /dev/null +++ b/messaging/src/protos/server_request.rs @@ -0,0 +1,162 @@ +// This file is generated by rust-protobuf 3.7.2. Do not edit +// .proto file is parsed by protoc 31.1 +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `commands/server_request.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_7_2; + +// @@protoc_insertion_point(message:server_request.RequestServerConfig) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct RequestServerConfig { + // special fields + // @@protoc_insertion_point(special_field:server_request.RequestServerConfig.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a RequestServerConfig { + fn default() -> &'a RequestServerConfig { + ::default_instance() + } +} + +impl RequestServerConfig { + pub fn new() -> RequestServerConfig { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(0); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "RequestServerConfig", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for RequestServerConfig { + const NAME: &'static str = "RequestServerConfig"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> RequestServerConfig { + RequestServerConfig::new() + } + + fn clear(&mut self) { + self.special_fields.clear(); + } + + fn default_instance() -> &'static RequestServerConfig { + static instance: RequestServerConfig = RequestServerConfig { + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for RequestServerConfig { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("RequestServerConfig").unwrap()).clone() + } +} + +impl ::std::fmt::Display for RequestServerConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for RequestServerConfig { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1dcommands/server_request.proto\x12\x0eserver_request\"\x15\n\x13Req\ + uestServerConfigb\x06proto3\ +"; + +/// `FileDescriptorProto` object which was a source for this generated file +fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); + file_descriptor_proto_lazy.get(|| { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() + }) +} + +/// `FileDescriptor` object which allows dynamic access to files +pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { + static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); + static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); + file_descriptor.get(|| { + let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { + let mut deps = ::std::vec::Vec::with_capacity(0); + let mut messages = ::std::vec::Vec::with_capacity(1); + messages.push(RequestServerConfig::generated_message_descriptor_data()); + let mut enums = ::std::vec::Vec::with_capacity(0); + ::protobuf::reflect::GeneratedFileDescriptor::new_generated( + file_descriptor_proto(), + deps, + messages, + enums, + ) + }); + ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) + }) +} diff --git a/messaging/src/protos/top_level.rs b/messaging/src/protos/top_level.rs index 1af4f4a..31f6b75 100644 --- a/messaging/src/protos/top_level.rs +++ b/messaging/src/protos/top_level.rs @@ -339,8 +339,57 @@ impl TopLevel { } } + // .server_request.RequestServerConfig request_server_config = 7; + + pub fn request_server_config(&self) -> &super::server_request::RequestServerConfig { + match self.command { + ::std::option::Option::Some(top_level::Command::RequestServerConfig(ref v)) => v, + _ => ::default_instance(), + } + } + + pub fn clear_request_server_config(&mut self) { + self.command = ::std::option::Option::None; + } + + pub fn has_request_server_config(&self) -> bool { + match self.command { + ::std::option::Option::Some(top_level::Command::RequestServerConfig(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_request_server_config(&mut self, v: super::server_request::RequestServerConfig) { + self.command = ::std::option::Option::Some(top_level::Command::RequestServerConfig(v)) + } + + // Mutable pointer to the field. + pub fn mut_request_server_config(&mut self) -> &mut super::server_request::RequestServerConfig { + if let ::std::option::Option::Some(top_level::Command::RequestServerConfig(_)) = self.command { + } else { + self.command = ::std::option::Option::Some(top_level::Command::RequestServerConfig(super::server_request::RequestServerConfig::new())); + } + match self.command { + ::std::option::Option::Some(top_level::Command::RequestServerConfig(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_request_server_config(&mut self) -> super::server_request::RequestServerConfig { + if self.has_request_server_config() { + match self.command.take() { + ::std::option::Option::Some(top_level::Command::RequestServerConfig(v)) => v, + _ => panic!(), + } + } else { + super::server_request::RequestServerConfig::new() + } + } + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(6); + let mut fields = ::std::vec::Vec::with_capacity(7); let mut oneofs = ::std::vec::Vec::with_capacity(1); fields.push(::protobuf::reflect::rt::v2::make_oneof_message_has_get_mut_set_accessor::<_, super::key_config::KeyConfig>( "key_config_command", @@ -384,6 +433,13 @@ impl TopLevel { TopLevel::mut_set_boot_logo_command, TopLevel::set_set_boot_logo_command, )); + fields.push(::protobuf::reflect::rt::v2::make_oneof_message_has_get_mut_set_accessor::<_, super::server_request::RequestServerConfig>( + "request_server_config", + TopLevel::has_request_server_config, + TopLevel::request_server_config, + TopLevel::mut_request_server_config, + TopLevel::set_request_server_config, + )); oneofs.push(top_level::Command::generated_oneof_descriptor_data()); ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( "TopLevel", @@ -421,6 +477,9 @@ impl ::protobuf::Message for TopLevel { 50 => { self.command = ::std::option::Option::Some(top_level::Command::SetBootLogoCommand(is.read_message()?)); }, + 58 => { + self.command = ::std::option::Option::Some(top_level::Command::RequestServerConfig(is.read_message()?)); + }, tag => { ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; }, @@ -459,6 +518,10 @@ impl ::protobuf::Message for TopLevel { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; }, + &top_level::Command::RequestServerConfig(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }, }; } my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); @@ -487,6 +550,9 @@ impl ::protobuf::Message for TopLevel { &top_level::Command::SetBootLogoCommand(ref v) => { ::protobuf::rt::write_message_field_with_cached_size(6, v, os)?; }, + &top_level::Command::RequestServerConfig(ref v) => { + ::protobuf::rt::write_message_field_with_cached_size(7, v, os)?; + }, }; } os.write_unknown_fields(self.special_fields.unknown_fields())?; @@ -512,6 +578,7 @@ impl ::protobuf::Message for TopLevel { self.command = ::std::option::Option::None; self.command = ::std::option::Option::None; self.command = ::std::option::Option::None; + self.command = ::std::option::Option::None; self.special_fields.clear(); } @@ -560,6 +627,8 @@ pub mod top_level { SetBrightnessCommand(super::super::brightness::SetBrightness), // @@protoc_insertion_point(oneof_field:TopLevel.set_boot_logo_command) SetBootLogoCommand(super::super::boot_logo::SetBootLogo), + // @@protoc_insertion_point(oneof_field:TopLevel.request_server_config) + RequestServerConfig(super::super::server_request::RequestServerConfig), } impl ::protobuf::Oneof for Command { @@ -582,18 +651,20 @@ pub mod top_level { static file_descriptor_proto_data: &'static [u8] = b"\ \n\x0ftop_level.proto\x1a\x18commands/boot_logo.proto\x1a!commands/displ\ ay_zone_image.proto\x1a\x19commands/brightness.proto\x1a\x19commands/key\ - _config.proto\"\xe3\x04\n\x08TopLevel\x12E\n\x12key_config_command\x18\ - \x01\x20\x01(\x0b2\x15.key_config.KeyConfigH\0R\x10keyConfigCommand\x12m\ - \n\x1eset_display_zone_image_command\x18\x02\x20\x01(\x0b2'.display_zone\ - _image.SetDisplayZoneImageH\0R\x1asetDisplayZoneImageCommand\x12s\n\x20c\ - lear_display_zone_image_command\x18\x03\x20\x01(\x0b2).display_zone_imag\ - e.ClearDisplayZoneImageH\0R\x1cclearDisplayZoneImageCommand\x12\x80\x01\ - \n%clear_all_display_zone_images_command\x18\x04\x20\x01(\x0b2-.display_\ - zone_image.ClearAllDisplayZoneImagesH\0R\x20clearAllDisplayZoneImagesCom\ - mand\x12Q\n\x16set_brightness_command\x18\x05\x20\x01(\x0b2\x19.brightne\ - ss.SetBrightnessH\0R\x14setBrightnessCommand\x12K\n\x15set_boot_logo_com\ - mand\x18\x06\x20\x01(\x0b2\x16.boot_logo.SetBootLogoH\0R\x12setBootLogoC\ - ommandB\t\n\x07commandb\x06proto3\ + _config.proto\x1a\x1dcommands/server_request.proto\"\xbe\x05\n\x08TopLev\ + el\x12E\n\x12key_config_command\x18\x01\x20\x01(\x0b2\x15.key_config.Key\ + ConfigH\0R\x10keyConfigCommand\x12m\n\x1eset_display_zone_image_command\ + \x18\x02\x20\x01(\x0b2'.display_zone_image.SetDisplayZoneImageH\0R\x1ase\ + tDisplayZoneImageCommand\x12s\n\x20clear_display_zone_image_command\x18\ + \x03\x20\x01(\x0b2).display_zone_image.ClearDisplayZoneImageH\0R\x1cclea\ + rDisplayZoneImageCommand\x12\x80\x01\n%clear_all_display_zone_images_com\ + mand\x18\x04\x20\x01(\x0b2-.display_zone_image.ClearAllDisplayZoneImages\ + H\0R\x20clearAllDisplayZoneImagesCommand\x12Q\n\x16set_brightness_comman\ + d\x18\x05\x20\x01(\x0b2\x19.brightness.SetBrightnessH\0R\x14setBrightnes\ + sCommand\x12K\n\x15set_boot_logo_command\x18\x06\x20\x01(\x0b2\x16.boot_\ + logo.SetBootLogoH\0R\x12setBootLogoCommand\x12Y\n\x15request_server_conf\ + ig\x18\x07\x20\x01(\x0b2#.server_request.RequestServerConfigH\0R\x13requ\ + estServerConfigB\t\n\x07commandb\x06proto3\ "; /// `FileDescriptorProto` object which was a source for this generated file @@ -610,11 +681,12 @@ pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); file_descriptor.get(|| { let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { - let mut deps = ::std::vec::Vec::with_capacity(4); + let mut deps = ::std::vec::Vec::with_capacity(5); deps.push(super::boot_logo::file_descriptor().clone()); deps.push(super::display_zone_image::file_descriptor().clone()); deps.push(super::brightness::file_descriptor().clone()); deps.push(super::key_config::file_descriptor().clone()); + deps.push(super::server_request::file_descriptor().clone()); let mut messages = ::std::vec::Vec::with_capacity(1); messages.push(TopLevel::generated_message_descriptor_data()); let mut enums = ::std::vec::Vec::with_capacity(0);