Skip to content

Commit

Permalink
finak
Browse files Browse the repository at this point in the history
  • Loading branch information
marci1175 committed Aug 20, 2024
1 parent c2e658e commit aa4c3c9
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 35 deletions.
Binary file modified desktop/Installer/.vs/Matthias/v17/.suo
Binary file not shown.
Binary file modified desktop/Installer/MatthiasSetup/Release/MatthiasSetup.msi
Binary file not shown.
2 changes: 1 addition & 1 deletion desktop/build_info.matthias_build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.08.20. 22:07
2024.08.20. 22:32
4 changes: 4 additions & 0 deletions desktop/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
},
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion desktop/src/app/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/app/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
}
Expand Down
17 changes: 13 additions & 4 deletions desktop/src/app/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() => {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -540,6 +546,7 @@ pub fn create_client_voip_manager(
};
}
}
}
},
}
}
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion desktop/src/app/ui/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
88 changes: 61 additions & 27 deletions desktop/src/app/ui/client_ui/message_instances/message_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
});

Expand Down Expand Up @@ -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(),
)
}
},
Expand Down Expand Up @@ -415,11 +463,7 @@ impl Application
}
}

pub fn image_overlay_draw(
&mut self,
ctx: &Context,
image_bytes: Vec<u8>,
)
pub fn image_overlay_draw(&mut self, ctx: &Context, image_bytes: Vec<u8>)
{
Area::new("large_image_display".into())
.movable(false)
Expand All @@ -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);
}
});
));
});
});

Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion mobile/build_info.matthias_build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.08.20. 22:07
2024.08.20. 22:32

0 comments on commit aa4c3c9

Please sign in to comment.