From f98c4d84b24698187102bcc3660246b2a1acb23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 21 Oct 2020 01:41:34 +0200 Subject: update user state in mumd --- mumlib/src/state.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'mumlib/src') diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index ef25a79..b6b4039 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -1,3 +1,4 @@ +use mumble_protocol::control::msgs; use serde::export::Formatter; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -116,7 +117,7 @@ impl<'a> Iterator for UsersIter<'a> { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct User { - pub comment: Option, + pub comment: Option, //TODO not option, empty string instead pub hash: Option, pub name: String, pub priority_speaker: bool, @@ -148,6 +149,8 @@ pub struct UserDiff { pub self_deaf: Option, // by self pub mute: Option, // by admin pub deaf: Option, // by admin + + pub channel_id: Option, } impl UserDiff { @@ -155,3 +158,43 @@ impl UserDiff { UserDiff::default() } } + +impl From for UserDiff { + fn from(mut msg: msgs::UserState) -> Self { + let mut ud = UserDiff::new(); + if msg.has_comment() { + ud.comment = Some(msg.take_comment()); + } + if msg.has_hash() { + ud.hash = Some(msg.take_hash()); + } + if msg.has_name() { + ud.name = Some(msg.take_name()); + } + if msg.has_priority_speaker() { + ud.priority_speaker = Some(msg.get_priority_speaker()); + } + if msg.has_recording() { + ud.recording = Some(msg.get_recording()); + } + if msg.has_suppress() { + ud.suppress = Some(msg.get_suppress()); + } + if msg.has_self_mute() { + ud.self_mute = Some(msg.get_self_mute()); + } + if msg.has_self_deaf() { + ud.self_deaf = Some(msg.get_self_deaf()); + } + if msg.has_mute() { + ud.mute = Some(msg.get_mute()); + } + if msg.has_deaf() { + ud.deaf = Some(msg.get_deaf()); + } + if msg.has_channel_id() { + ud.channel_id = Some(msg.get_channel_id()); + } + ud + } +} -- cgit v1.2.1