diff --git a/desktop/Installer/.vs/Matthias/v17/.suo b/desktop/Installer/.vs/Matthias/v17/.suo index 08043228..948159f9 100644 Binary files a/desktop/Installer/.vs/Matthias/v17/.suo and b/desktop/Installer/.vs/Matthias/v17/.suo differ diff --git a/desktop/Installer/MatthiasSetup/Release/MatthiasSetup.msi b/desktop/Installer/MatthiasSetup/Release/MatthiasSetup.msi index ecec899a..70818c96 100644 Binary files a/desktop/Installer/MatthiasSetup/Release/MatthiasSetup.msi and b/desktop/Installer/MatthiasSetup/Release/MatthiasSetup.msi differ diff --git a/desktop/build_info.matthias_build b/desktop/build_info.matthias_build index 2587f257..9a9848cb 100644 --- a/desktop/build_info.matthias_build +++ b/desktop/build_info.matthias_build @@ -1 +1 @@ -2024.08.20. 22:07 \ No newline at end of file +2024.08.20. 22:32 \ No newline at end of file diff --git a/desktop/src/app.rs b/desktop/src/app.rs index 08e2e94f..436e4816 100644 --- a/desktop/src/app.rs +++ b/desktop/src/app.rs @@ -309,6 +309,7 @@ impl eframe::App for backend::Application if !matches!(self.client_connection.state, ConnectionState::Connected(_)) { //If we recived a None it means we have an error self.client_connection.state = ConnectionState::Error; + self.disconnect_from_server(); } } }, @@ -569,6 +570,9 @@ impl backend::Application //Shut down threadsa nad reset state self.reset_client_connection(); + self.voip_shutdown_token.cancel(); + self.voip_video_shutdown_token.cancel(); + //Disconnect from server tokio::task::spawn(async move { match connection.disconnect(username, password, uuid).await { diff --git a/desktop/src/app/backend.rs b/desktop/src/app/backend.rs index 3256a116..7916299a 100644 --- a/desktop/src/app/backend.rs +++ b/desktop/src/app/backend.rs @@ -2250,10 +2250,14 @@ impl ServerVoip /// Remove the ```SocketAddr``` to the ```UDP``` server's destiantions pub fn disconnect(&self, uuid: String) -> anyhow::Result<()> { - self.connected_clients + let (_, removed_address) = self + .connected_clients .remove(&uuid) .ok_or_else(|| anyhow::Error::msg("Client was not connected"))?; + self.connected_client_thread_channels + .remove(&removed_address); + Ok(()) } } diff --git a/desktop/src/app/client.rs b/desktop/src/app/client.rs index dfc2b2e7..4c94335c 100644 --- a/desktop/src/app/client.rs +++ b/desktop/src/app/client.rs @@ -737,6 +737,10 @@ impl Application //Assuming the connection is faulty we reset state self.reset_client_connection(); + + //Try to dsiconnect from the server + self.disconnect_from_server(); + self.client_connection.reset_state(); }, } diff --git a/desktop/src/app/server.rs b/desktop/src/app/server.rs index 5c57b583..316b7b77 100644 --- a/desktop/src/app/server.rs +++ b/desktop/src/app/server.rs @@ -209,6 +209,13 @@ pub async fn server_main( } } } + + let voip = message_service_lock.voip.clone(); + if let Some(voip) = voip { + for banned_uuid in message_service_lock.shared_fields.lock().await.banned_uuids.lock().await.iter() { + voip.disconnect(banned_uuid.to_string()).unwrap_or_default(); + } + } }, _ = cancellation_child_clone.cancelled() => { @@ -388,9 +395,8 @@ pub fn create_client_voip_manager( //recive_message lenght by reading its first 4 bytes recived_bytes = reciver.recv() => { - let recived_bytes = recived_bytes.unwrap(); - - //Decrypt message + if let Some(recived_bytes) = recived_bytes { + //Decrypt message // [. . . . . .4][4 . . . . len - 4][len - 4..] // PACKET LENGHT MESSAGE MSG TYPE let mut decrypted_bytes = decrypt_aes256_bytes(&recived_bytes, &key).unwrap(); @@ -540,6 +546,7 @@ pub fn create_client_voip_manager( }; } } + } }, } } @@ -1673,7 +1680,9 @@ impl MessageService //Pattern match on upload tpye so we know how to handle the specific request match upload_type.extension.clone().unwrap_or_default().as_str() { - "png" | "jpeg" | "bmp" | "tiff" | "webp" | "gif" | "jpg" => self.recive_image(req, upload_type).await, + "png" | "jpeg" | "bmp" | "tiff" | "webp" | "gif" | "jpg" => { + self.recive_image(req, upload_type).await + }, "wav" | "mp3" | "m4a" => self.recive_audio(req, upload_type).await, //Define file types and how should the server handle them based on extension, NOTICE: ENSURE CLIENT COMPATIBILITY _ => self.recive_file(req, upload_type).await, diff --git a/desktop/src/app/ui/client.rs b/desktop/src/app/ui/client.rs index 143555d9..2d1d7e3e 100644 --- a/desktop/src/app/ui/client.rs +++ b/desktop/src/app/ui/client.rs @@ -164,7 +164,11 @@ impl Application }); //Lua callback - self.client_ui.extension.event_call_extensions(crate::app::lua::EventCall::OnCallSend, &self.lua, None); + self.client_ui.extension.event_call_extensions( + crate::app::lua::EventCall::OnCallSend, + &self.lua, + None, + ); } call_button.on_hover_text("Start a group call"); diff --git a/desktop/src/app/ui/client_ui/message_instances/message_display.rs b/desktop/src/app/ui/client_ui/message_instances/message_display.rs index bb58663b..2868ffa3 100644 --- a/desktop/src/app/ui/client_ui/message_instances/message_display.rs +++ b/desktop/src/app/ui/client_ui/message_instances/message_display.rs @@ -97,12 +97,62 @@ impl Application image_widget.context_menu(|ui| { if ui.button("Save").clicked() { - //always name the file ".png", NOTE: USE WRITE FILE BECAUSE WRITE IMAGE IS AUTOMATIC WITHOUT ASKING THE USER - let image_save = ServerFileReply { - bytes: bytes.to_vec(), - file_name: PathBuf::from("image.png"), - }; - let _ = crate::app::backend::write_file(image_save); + if let Ok(format) = image::guess_format(&bytes) { + let type_name = match format { + image::ImageFormat::Png => { + "Png" + }, + image::ImageFormat::Jpeg => { + "Jpeg" + }, + image::ImageFormat::Gif => { + "Gif" + }, + image::ImageFormat::WebP => { + "WebP" + }, + image::ImageFormat::Pnm => { + "Pnm" + }, + image::ImageFormat::Tiff => { + "Tiff" + }, + image::ImageFormat::Tga => { + "Tga" + }, + image::ImageFormat::Dds => { + "Dds" + }, + image::ImageFormat::Bmp => { + "Bmp" + }, + image::ImageFormat::Ico => { + "Ico" + }, + image::ImageFormat::Hdr => { + "Hdr" + }, + image::ImageFormat::OpenExr => { + "OpenExr" + }, + image::ImageFormat::Farbfeld => { + "Farbfeld" + }, + image::ImageFormat::Avif => { + "Avif" + }, + image::ImageFormat::Qoi => { + "Qoi" + }, + _ => todo!(), + }; + + let image_save = ServerFileReply { + bytes: bytes.to_vec(), + file_name: PathBuf::from(format!("image.{}",type_name.to_lowercase())), + }; + let _ = crate::app::backend::write_file(image_save); + } } }); @@ -213,10 +263,8 @@ impl Application fs::read(&path_to_audio).unwrap_or_default(); sink.append( - Decoder::new(PlaybackCursor::new( - file_stream_to_be_read, - )) - .unwrap(), + Decoder::new(PlaybackCursor::new(file_stream_to_be_read)) + .unwrap(), ) } }, @@ -415,11 +463,7 @@ impl Application } } - pub fn image_overlay_draw( - &mut self, - ctx: &Context, - image_bytes: Vec, - ) + pub fn image_overlay_draw(&mut self, ctx: &Context, image_bytes: Vec) { Area::new("large_image_display".into()) .movable(false) @@ -428,17 +472,7 @@ impl Application ui.allocate_ui(ctx.used_size() / 2., |ui| { ui.add(egui::widgets::Image::from_uri( "bytes://large_image_display", - )) /*Add the same context menu as before*/ - .context_menu(|ui| { - if ui.button("Save").clicked() { - //always name the file ".png" - let image_save = ServerFileReply { - bytes: image_bytes.clone(), - file_name: PathBuf::from(".png"), - }; - let _ = write_file(image_save); - } - }); + )); }); }); @@ -461,7 +495,7 @@ impl Application }) }); - Area::new("image_bg".into()) + Area::new("image_bg".into()) .movable(false) .anchor(Align2::CENTER_CENTER, vec2(0., 0.)) .default_size(ctx.used_size()) diff --git a/mobile/build_info.matthias_build b/mobile/build_info.matthias_build index 2587f257..9a9848cb 100644 --- a/mobile/build_info.matthias_build +++ b/mobile/build_info.matthias_build @@ -1 +1 @@ -2024.08.20. 22:07 \ No newline at end of file +2024.08.20. 22:32 \ No newline at end of file