bump dioxus version & icons in desktop & logging

This commit is contained in:
2024-11-11 13:43:58 -07:00
parent 30a94323b3
commit 2211be5324
17 changed files with 1073 additions and 1242 deletions
+16 -33
View File
@@ -4,6 +4,7 @@ use app::ConnectionState;
use app::STATE;
use asynchronous_codec::FramedRead;
use asynchronous_codec::FramedWrite;
use color_eyre::eyre::{bail, Error};
use dioxus::prelude::*;
use futures::select;
use futures::FutureExt as _;
@@ -11,54 +12,35 @@ use futures::SinkExt as _;
use futures::StreamExt as _;
use futures_channel::mpsc::UnboundedSender;
pub use imp::spawn;
pub use imp::Error;
use mumble_protocol::control::msgs;
use mumble_protocol::control::ControlCodec;
use mumble_protocol::control::ControlPacket;
use mumble_protocol::voice::VoicePacketPayload;
use mumble_protocol::Clientbound;
use mumble_protocol::Serverbound;
use mumble_web2_common::GuiConfig;
use once_cell::sync::Lazy;
use serde::Deserialize;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::time::Duration;
use tracing::debug;
use tracing::error;
pub mod app;
#[cfg(feature = "web")]
#[path = "imp/web.rs"]
pub mod imp;
#[cfg(feature = "desktop")]
#[path = "imp/desktop.rs"]
pub mod imp;
#[derive(Clone, Deserialize, Default)]
pub struct GuiConfig {
pub proxy_url: Option<String>,
pub cert_hash: Option<Vec<u8>>,
}
pub static CONFIG: Lazy<GuiConfig> = Lazy::new(|| imp::load_config().unwrap_or_default());
#[macro_export]
macro_rules! bail {
($($x:tt)*) => {
return Err(Error::new(format!($($x)*)))
};
}
pub async fn network_entrypoint(mut event_rx: UnboundedReceiver<Command>) {
loop {
let Some(Command::Connect { address, username }) = event_rx.next().await else {
panic!("Did not receive connect command")
panic!("did not receive connect command")
};
*STATE.server.write() = Default::default();
*STATE.status.write() = ConnectionState::Connecting;
if let Err(error) = imp::network_connect(address, username, &mut event_rx).await {
error.log();
error!("could not connect {:?}", error);
*STATE.status.write() = ConnectionState::Failed(error.to_string());
} else {
*STATE.status.write() = ConnectionState::Disconnected;
@@ -76,10 +58,10 @@ pub async fn network_loop<R: imp::ImpRead, W: imp::ImpWrite>(
spawn(async move {
while let Some(msg) = writer_recv_chan.next().await {
if !matches!(msg, ControlPacket::Ping(_) | ControlPacket::UDPTunnel(_)) {
eprintln!("sending {:#?}", msg);
debug!("sending {:#?}", msg);
}
if let Err(e) = writer.send(msg).await {
eprintln!("ERROR: {}", e);
error!("error sending message {:?}", e);
break;
}
}
@@ -91,8 +73,7 @@ pub async fn network_loop<R: imp::ImpRead, W: imp::ImpWrite>(
Some(Err(err)) => bail!("bad version packet: {err:?}"),
None => bail!("no version was recieved"),
};
println!("Got version packet");
println!("{:#?}", version);
debug!("got version packet {:#?}", version);
// Send version packet
let mut msg = msgs::Version::new();
@@ -136,28 +117,30 @@ pub async fn network_loop<R: imp::ImpRead, W: imp::ImpWrite>(
match packet {
Some(Ok(msg)) => {
if !matches!(msg, ControlPacket::UDPTunnel(_) | ControlPacket::Ping(_)) {
println!("receiving {:#?}", msg);
debug!("receiving {:#?}", msg);
}
let res = accept_packet(msg, &mut audio, &mut decoder_map);
if let Err(err) = res {
err.log();
error!("error accepting packet {:?}", err)
}
},
Some(Err(err)) => Error::from(err).log(),
Some(Err(err)) => {
error!("error receiving packet {:?}", err)
},
None => break,
}
}
command = command_future => {
command_future = event_rx.next();
if let Some(command) = &command {
println!("commanding {:#?}", command);
debug!("commanding {:#?}", command);
}
match command {
Some(Command::Disconnect) => break,
Some(command) => {
let res = accept_command(command, &mut send_chan);
if let Err(err) = res {
err.log();
error!("error accepting command {:?}", err)
}
}
None => continue,