From 46e046f21042ec84af55e98516a92e6960ee0af5 Mon Sep 17 00:00:00 2001 From: limuy Date: Fri, 30 Aug 2024 15:57:53 +0800 Subject: [PATCH 1/4] fix typos --- .github/workflows/typos.yml | 21 ++ README.md | 4 +- SECURITY.md | 6 +- desktop/src/app.rs | 20 +- desktop/src/app/backend.rs | 179 ++++++++++-------- desktop/src/app/client.rs | 102 +++++----- desktop/src/app/lua.rs | 14 +- desktop/src/app/server.rs | 108 +++++------ desktop/src/app/ui/client.rs | 18 +- .../client_actions/audio_recording.rs | 36 ++-- .../message_instances/message_display.rs | 6 +- .../message_instances/message_main.rs | 24 +-- .../ui/client_ui/widgets/emoji_tray/emoji.rs | 4 +- .../widgets/message_tray/message_tray_main.rs | 26 +-- desktop/src/app/ui/register.rs | 22 ++- desktop/src/app/ui/server.rs | 4 +- desktop/src/main.rs | 2 +- mobile/build_info.Matthias_build | 1 + mobile/src/app.rs | 18 +- mobile/src/app/backend.rs | 140 +++++++------- mobile/src/app/client.rs | 100 +++++----- mobile/src/app/lua.rs | 14 +- mobile/src/app/server.rs | 108 +++++------ mobile/src/app/ui/client.rs | 16 +- .../message_instances/message_display.rs | 6 +- .../message_instances/message_main.rs | 8 +- .../ui/client_ui/widgets/emoji_tray/emoji.rs | 4 +- .../widgets/message_tray/message_tray_main.rs | 20 +- mobile/src/app/ui/register.rs | 2 +- mobile/src/app/ui/server.rs | 4 +- mobile/src/main.rs | 2 +- 31 files changed, 541 insertions(+), 498 deletions(-) create mode 100644 .github/workflows/typos.yml create mode 100644 mobile/build_info.Matthias_build diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 0000000..b38fe57 --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,21 @@ +name: typos + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: typos-action + uses: crate-ci/typos@master + with: + files: . diff --git a/README.md b/README.md index 121056c..e4b90a0 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ _________________________________________________________ - Navigate to `desktop/Installer` in the project folder, and open up the Matthias.sln file. - Click on build on the top menu bar and click Build Solution (Or use the `ctrl+shift+b` key combination) - After building go to `desktop/Installer/MatthiasSetup/Release/` and you will find two files: - - One containing the dependencies (Smaller file size) - - One containing the application itself (Bigger file size) + - One containingg the dependencies (Smaller file size) + - One containingg the application itself (Bigger file size) ## Community Feel free to chat in the official [Matthias discord server](https://discord.gg/66KFkByMGa)! diff --git a/SECURITY.md b/SECURITY.md index 92d80ca..1cf873a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,12 +1,14 @@ # Security Policy ## Supported Versions -Only the latest verison of the application will recive security updates, as I am not going to maintain older versions of the app. + +Only the latest version of the application will receive security updates, as I am not going to maintain older versions of the app. ## Reporting a Vulnerability + Write an accurate description of what this vulnerability is capable of. Write an accurate step-by-step tutorial on how to replicate/exploit a bug in the app. ## Report outcomes -If the vulnerability report is accepted, a fix for it will most likely be present in the next quickfix/version. +If the vulnerability report is accepted, a fix for it will most likely be present in the next quickfix/version. diff --git a/desktop/src/app.rs b/desktop/src/app.rs index 67e8688..11d754a 100644 --- a/desktop/src/app.rs +++ b/desktop/src/app.rs @@ -111,7 +111,7 @@ impl eframe::App for backend::Application Some(sep_idx) => { let (address, password) = link.split_at(sep_idx); - //Leave out parts of the password which are artifically added to the argmuent + //Leave out parts of the password which are artificially added to the argmuent let password = &password[1..password.len() - 1]; //Connect to server @@ -273,8 +273,8 @@ impl eframe::App for backend::Application }; }); - //Connection reciver - match self.connection_reciver.try_recv() { + //Connection receiver + match self.connection_receiver.try_recv() { Ok(connection) => { if let Some(connection) = connection { //Modify client_connection @@ -303,10 +303,10 @@ impl eframe::App for backend::Application } } else { - // A race condition will occur if we connected succesfully after getting a connection error (request timed out) + // A race condition will occur if we connected successfully after getting a connection error (request timed out) // So we check if we have already made the connection before actually modifying the value based on the timed out request if !matches!(self.client_connection.state, ConnectionState::Connected(_)) { - //If we recived a None it means we have an error + //If we received a None it means we have an error self.client_connection.state = ConnectionState::Error; self.disconnect_from_server(); } @@ -318,7 +318,7 @@ impl eframe::App for backend::Application } //Voip instance listener - match self.voip_connection_reciver.try_recv() { + match self.voip_connection_receiver.try_recv() { Ok(voip) => { self.client_ui.voip = Some(voip.clone()); @@ -476,7 +476,7 @@ impl backend::Application }); ui.horizontal(|ui| { - ui.label("Microphone volume precentage"); + ui.label("Microphone volume percentage"); self.client_ui .microphone_volume .fetch_update( @@ -512,10 +512,10 @@ impl backend::Application let user_information = self.opened_user_information.clone(); - //Reset all messages and everything else + //Reset all messages and everythingg else self.client_ui.incoming_messages = ServerMaster::default(); - //Forget all imaes so the cahced imges will be deleted + //Forget all imaes so the cached imges will be deleted ctx.forget_all_images(); let toasts = self.toasts.clone(); @@ -837,7 +837,7 @@ pub fn read_extensions_dir() -> anyhow::Result> for entry in fs::read_dir(format!("{}\\matthias\\extensions", env!("APPDATA")))? { let dir_entry = entry.map_err(|err| Error::msg(err.to_string()))?; - //If the file doesnt have an extension, then we can ingore it + //If the file doesnt have an extension, then we can ignore it if let Some(extension) = dir_entry.path().extension() { //If the file is a lua file if extension.to_string_lossy() == "lua" { diff --git a/desktop/src/app/backend.rs b/desktop/src/app/backend.rs index d724cea..d326e7f 100644 --- a/desktop/src/app/backend.rs +++ b/desktop/src/app/backend.rs @@ -2,7 +2,8 @@ use super::{ client::{connect_to_server, ServerReply}, lua::{Extension, LuaOutput}, read_extensions_dir, - server::SharedFields, ui::register::create_dynamic_image_from_bytes, + server::SharedFields, + ui::register::create_dynamic_image_from_bytes, }; use aes_gcm::{ aead::{generic_array::GenericArray, Aead, KeyInit}, @@ -99,7 +100,7 @@ pub struct Application #[serde(skip)] /// This is used to store the connected client profile /// The field get modified by the server_main function (When a server is started this is passed in and is later modified by the server) - /// This might seem very similar to ```self.client_ui.incoming_msg.connected_clients_profile```, but that field is only modifed when connecting to a server, so when we start a server but dont connect to it, we wont have the fields + /// This might seem very similar to ```self.client_ui.incoming_msg.connected_clients_profile```, but that field is only modified when connecting to a server, so when we start a server but dont connect to it, we wont have the fields /// This field gets directly modified by the server thread pub server_connected_clients_profile: Arc>, @@ -166,7 +167,7 @@ pub struct Application /* Client main */ - //We can skip this entry of the table since, we implement Totable separetly + //We can skip this entry of the table since, we implement Totable separately #[table(skip)] pub client_ui: Client, @@ -183,14 +184,14 @@ pub struct Application /// Server connection /// This channel hosts a Client connection and the sync message sent by the server in a String format #[serde(skip)] - pub connection_reciver: Arc>>, + pub connection_receiver: Arc>>, #[serde(skip)] pub connection_sender: mpsc::Sender>, /// Voip (UdpSocket) maker /// When a successful ```Voip``` instance is created it is sent over from the async thread #[serde(skip)] - pub voip_connection_reciver: Arc>, + pub voip_connection_receiver: Arc>, #[serde(skip)] pub voip_connection_sender: mpsc::Sender, @@ -207,8 +208,8 @@ pub struct Application pub voip_video_thread: Option<()>, #[serde(skip)] - /// This is what the main thread uses to recive messages from the sync thread - pub server_output_reciver: Arc>>, + /// This is what the main thread uses to receive messages from the sync thread + pub server_output_receiver: Arc>>, #[serde(skip)] /// This is what the sync thread uses to send messages to the main thread @@ -235,12 +236,12 @@ impl Default for Application let (audio_bytes_tx, audio_bytes_rx) = mpsc::channel::>(); - let (connection_sender, connection_reciver) = + let (connection_sender, connection_receiver) = mpsc::channel::>(); - let (server_output_sender, server_output_reciver) = mpsc::channel::>(); + let (server_output_sender, server_output_receiver) = mpsc::channel::>(); - let (voip_connection_sender, voip_connection_reciver) = mpsc::channel::(); + let (voip_connection_sender, voip_connection_receiver) = mpsc::channel::(); Self { voip_video_thread: None, @@ -282,7 +283,7 @@ impl Default for Application settings_window: false, //This default value will get overwritten when crating the new server, so we can pass in the token to the thread - //Also, the shutdown reciver is unnecessary in this context because we never use it, I too lazy to delete a few lines instead of writing this whole paragraph >:D + //Also, the shutdown receiver is unnecessary in this context because we never use it, I too lazy to delete a few lines instead of writing this whole paragraph >:D server_shutdown_token: CancellationToken::new(), //thread communication for audio recording @@ -311,17 +312,17 @@ impl Default for Application //Server connection connection_sender, - connection_reciver: Arc::new(connection_reciver), + connection_receiver: Arc::new(connection_receiver), //data sync drx: Arc::new(drx), dtx: Arc::new(dtx), server_sender_thread: None, - server_output_reciver: Arc::new(server_output_reciver), + server_output_receiver: Arc::new(server_output_receiver), server_output_sender, - voip_connection_reciver: Arc::new(voip_connection_reciver), + voip_connection_receiver: Arc::new(voip_connection_receiver), voip_connection_sender, autosync_shutdown_token: CancellationToken::new(), @@ -647,7 +648,7 @@ fn set_lua_functions( //Include emoji image header file include!(concat!(env!("OUT_DIR"), "\\emoji_header.rs")); -//Define a deafult for the discriminant +//Define a default for the discriminant impl Default for EmojiTypesDiscriminants { fn default() -> Self @@ -769,7 +770,7 @@ pub struct Client ///This checks if the text editor is open or not pub usr_msg_expanded: bool, - ///This is the full address of the destionation a message is supposed to be sent to + ///This is the full address of the destination a message is supposed to be sent to pub send_on_ip: String, ///self.send_on_ip encoded into base64, this is supposedly for ease of use, I dont know why its even here @@ -800,7 +801,7 @@ pub struct Client #[table(save)] pub message_buffer: String, - ///Incoming messages, this is the whole packet which get sent to all the clients, this cointains all the messages, and the info about them + ///Incoming messages, this is the whole packet which get sent to all the clients, this contains all the messages, and the info about them #[serde(skip)] #[table(save)] pub incoming_messages: ServerMaster, @@ -828,7 +829,7 @@ pub struct Client #[serde(skip)] pub voip: Option, - /// This entry contains the volume precentage of the microphone, this is modified in the settings + /// This entry contains the volume percentage of the microphone, this is modified in the settings pub microphone_volume: Arc, } @@ -938,26 +939,42 @@ pub struct Register /// This entry hold all the temp stuff for creating a profile pub image: ProfileImage, - pub selected_image_path: Option, } -impl Default for Register { - fn default() -> Self { - let default_image = create_dynamic_image_from_bytes(include_bytes!("../../../assets/icons/stock-user-icon.png")).unwrap(); +impl Default for Register +{ + fn default() -> Self + { + let default_image = create_dynamic_image_from_bytes(include_bytes!( + "../../../assets/icons/stock-user-icon.png" + )) + .unwrap(); let mut large_pfp = BufWriter::new(Cursor::new(Vec::new())); let mut small_pfp = BufWriter::new(Cursor::new(Vec::new())); default_image .resize(256, 256, image::imageops::FilterType::CatmullRom) - .write_to(&mut large_pfp, ImageOutputFormat::Png).unwrap(); + .write_to(&mut large_pfp, ImageOutputFormat::Png) + .unwrap(); default_image .resize(64, 64, image::imageops::FilterType::CatmullRom) - .write_to(&mut small_pfp, ImageOutputFormat::Png).unwrap(); + .write_to(&mut small_pfp, ImageOutputFormat::Png) + .unwrap(); - Self { username: String::new(), password: String::new(), gender: None, birth_date: NaiveDate::default(), full_name: String::new(), small_profile_picture: small_pfp.into_inner().unwrap().into_inner(), normal_profile_picture: large_pfp.into_inner().unwrap().into_inner(), image: ProfileImage::default(), selected_image_path: None } + Self { + username: String::new(), + password: String::new(), + gender: None, + birth_date: NaiveDate::default(), + full_name: String::new(), + small_profile_picture: small_pfp.into_inner().unwrap().into_inner(), + normal_profile_picture: large_pfp.into_inner().unwrap().into_inner(), + image: ProfileImage::default(), + selected_image_path: None, + } } } @@ -966,7 +983,7 @@ impl Default for Register { pub struct ProfileImage { #[serde(skip)] -/// This entry contains the selected image's path + /// This entry contains the selected image's path /// If this is None this means the user hasnt selected a profile picture and when registering we should insert the default profile picture pub image_path: Option, @@ -994,7 +1011,7 @@ impl Default for ProfileImage } /// The clients profile, this struct should be sent at a server connection -/// It hold everything which needs to be displayed when viewing someone's profile +/// It hold everythingg which needs to be displayed when viewing someone's profile /// This struct might look similar too ```Register```, but that one contains more information, and is only made to control the ui /// This struct is sent to the server upon successful connection /// If you are searching for the uuid in this struct, please note that most of the times this struct is used in a hashmap where the key is the uuid @@ -1066,13 +1083,13 @@ pub struct ClientNormalMessage // Used for syncing or connecting & disconnecting #[derive(Default, serde::Serialize, serde::Deserialize, Debug, Clone)] -pub struct ClientSnycMessage +pub struct ClientSyncMessage { /// If its None its used for syncing, false: disconnecting, true: connecting /// If you have already registered the client with the server then the true value will be ignored pub sync_attribute: Option, - /// This is used to tell the server how many messages it has to send, if its a None it will automaticly sync all messages + /// This is used to tell the server how many messages it has to send, if its a None it will automatically sync all messages /// This value is ignored if the `sync_attribute` field is Some(_) pub client_message_counter: Option, @@ -1166,7 +1183,7 @@ pub enum ClientMessageType NormalMessage(ClientNormalMessage), ///Used for syncing with client and server - SyncMessage(ClientSnycMessage), + SyncMessage(ClientSyncMessage), Reaction(ReactionType), @@ -1320,7 +1337,7 @@ impl ClientMessage { ClientMessage { replying_to: None, - message_type: ClientMessageType::SyncMessage(ClientSnycMessage { + message_type: ClientMessageType::SyncMessage(ClientSyncMessage { sync_attribute: None, password: password.to_string(), //This value is not ignored in this context @@ -1344,7 +1361,7 @@ impl ClientMessage { ClientMessage { replying_to: None, - message_type: ClientMessageType::SyncMessage(ClientSnycMessage { + message_type: ClientMessageType::SyncMessage(ClientSyncMessage { sync_attribute: Some(ConnectionType::Connect(profile)), password, //If its used for connecting / disconnecting this value is ignored @@ -1358,7 +1375,7 @@ impl ClientMessage } /// If its None its used for syncing, false: disconnecting, true: connecting - /// Please note that its doesnt really matter what we pass in the author becuase the server identifies us based on our ip address + /// Please note that its doesnt really matter what we pass in the author because the server identifies us based on our ip address pub fn construct_disconnection_msg( password: String, author: String, @@ -1367,7 +1384,7 @@ impl ClientMessage { ClientMessage { replying_to: None, - message_type: ClientMessageType::SyncMessage(ClientSnycMessage { + message_type: ClientMessageType::SyncMessage(ClientSyncMessage { sync_attribute: Some(ConnectionType::Disconnect), password, //If its used for connecting / disconnecting this value is ignored @@ -1538,7 +1555,7 @@ impl ClientConnection profile, ); - //Ping server to recive custom uuid, and to also get if server ip is valid + //Ping server to receive custom uuid, and to also get if server ip is valid let client_handle = tokio::net::TcpStream::connect(ip).await?; /*We could return this, this is what the server is supposed to return, when a new user is connected */ @@ -1593,7 +1610,7 @@ impl ClientConnection self.state = ConnectionState::default(); } - /// This function is used to __DISCONNECT__ from a server, with this the ```ClientConnection``` instance is destoryed (reset to its default values) + /// This function is used to __DISCONNECT__ from a server, with this the ```ClientConnection``` instance is destroyed (reset to its default values) pub async fn disconnect( &mut self, author: String, @@ -1648,7 +1665,7 @@ impl ConnectionPair let message_bytes = message_string.as_bytes(); - //Send message lenght to server + //Send message length to server writer .write_all(&(message_bytes.len() as u32).to_be_bytes()) .await?; @@ -1691,8 +1708,8 @@ impl Debug for ConnectionState /* Server. . . - Are used to convert clinet sent messages into a server message, so it can be sent back; - Therefor theyre smaller in size + Are used to convert client sent messages into a server message, so it can be sent back; + Therefor they're smaller in size */ /* @@ -1705,7 +1722,7 @@ impl Debug for ConnectionState */ -///This is what the server sends back (pushes to message vector), when reciving a file +///This is what the server sends back (pushes to message vector), when receiving a file #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerFileUpload { @@ -1733,7 +1750,7 @@ pub enum ServerReplyType Client(ServerClientReply), } -/// This struct holds everything important so the client can save and handle client profiles +/// This struct holds everythingg important so the client can save and handle client profiles #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] pub struct ServerClientReply { @@ -1781,7 +1798,7 @@ pub struct ServerAudioReply pub audio_idx: u64, } -///This is what the server sends back (pushes to message vector), when reciving a normal message +///This is what the server sends back (pushes to message vector), when receiving a normal message #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerNormalMessage { @@ -1799,7 +1816,7 @@ pub struct ServerAudioUpload pub file_name: String, } -///This is what gets sent to a client basicly, and they have to ask for the file when the ui containin this gets rendered +///This is what gets sent to a client basically, and they have to ask for the file when the ui containing this gets rendered #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerImageUpload { @@ -1818,7 +1835,7 @@ pub struct ServerMessageEdit pub new_message: Option, } -/// This struct contains all the necesarily information for the client to update its own message list's reactions +/// This struct contains all the necessarily information for the client to update its own message list's reactions #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerMessageReaction { @@ -1913,12 +1930,12 @@ impl ServerOutput serde_json::to_string(self).unwrap_or_default() } - /// This function converts a client message to a ServerOutput, which gets sent to all the clients (Its basicly a simplified client message) + /// This function converts a client message to a ServerOutput, which gets sent to all the clients (Its basically a simplified client message) pub fn convert_clientmsg_to_servermsg( normal_msg: ClientMessage, // The signature is used to ask bytes from the server, for example in a image message this signature will be used to get the image's byte signature: String, - //Automaticly generated enum by strum + //Automatically generated enum by strum upload_type: ServerMessageTypeDiscriminants, uuid: String, username: String, @@ -2025,7 +2042,7 @@ impl ServerOutput ServerMessageReaction { reaction_type: ReactionType::Add(ClientReaction { emoji_name: message.emoji_name, uuid: message.uuid, message_index: message.message_index }) } }, //The client will decrement its emoji counter - //If the index is 0 the client will automaticly remove that emoji entry + //If the index is 0 the client will automatically remove that emoji entry ReactionType::Remove(message) => { ServerMessageReaction { reaction_type: ReactionType::Remove(ClientReaction { emoji_name: message.emoji_name, uuid: message.uuid, message_index: message.message_index }) } }, @@ -2044,11 +2061,11 @@ impl ServerOutput } /// Used to put all the messages into 1 big pack (Bundling All the ServerOutput-s), Main packet, this gets to all the clients -/// This message type is only used when a client is connecting an has to do a full sync (sending everything to the client all the messages reactions, etc) +/// This message type is only used when a client is connecting an has to do a full sync (sending everythingg to the client all the messages reactions, etc) #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default)] pub struct ServerMaster { - ///All of the messages recived from the server + ///All of the messages received from the server pub message_list: Vec, ///All of the messages' reactions are @@ -2141,11 +2158,11 @@ impl ClientLastSeenMessage #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] pub enum ClientVoipRequest { - /// A voip a call will be automaticly issued if there is no ongoing call - /// The inner value of conncect is the port the Client ```UdpScoket``` is opened on + /// A voip a call will be automatically issued if there is no ongoing call + /// The inner value of conncect is the port the Client ```UdpSocket``` is opened on Connect(u16), - /// The voip call will automaticly stop once there are no connected clients + /// The voip call will automatically stop once there are no connected clients Disconnect, /// The client has enabled video @@ -2198,7 +2215,7 @@ pub enum ServerVoipRequest ConnectionClosed(ServerVoipClose), } -/// This struct contains all the infomation important for the non connected clients +/// This struct contains all the information important for the non connected clients #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerVoipStart { @@ -2233,8 +2250,8 @@ pub struct ServerVoip /// This field contains all the connected client's ```uuid``` with their ```SocketAddr``` pub connected_clients: Arc>, - /// This field contains a ```HashMap``` which pairs the SocketAddr to the client's listening thread's sender (So that the reciver thread can recive the ```Vec``` sent by the sender) - /// The secound part of the tuple is for shutting down the client manager thread, if they disconnect + /// This field contains a ```HashMap``` which pairs the SocketAddr to the client's listening thread's sender (So that the receiver thread can receive the ```Vec``` sent by the sender) + /// The second part of the tuple is for shutting down the client manager thread, if they disconnect pub connected_client_thread_channels: Arc>>, CancellationToken)>>, @@ -2270,7 +2287,7 @@ impl ServerVoip Ok(()) } - /// Remove the ```SocketAddr``` to the ```UDP``` server's destiantions + /// Remove the ```SocketAddr``` to the ```UDP``` server's destinations pub fn disconnect(&self, uuid: String) -> anyhow::Result<()> { let (_, removed_address) = self @@ -2315,7 +2332,7 @@ impl UdpMessageType #[derive(Clone)] pub struct Voip { - /// The clients socket, which theyre listening on for packets (audio, image) + /// The clients socket, which they're listening on for packets (audio, image) pub socket: Arc, /// This handle is used to take pictures with the host's camera @@ -2334,7 +2351,7 @@ pub struct Voip impl Voip { - /// This function creates a new ```Voip``` instance containing a ```UdpSocket``` and an authentication from the server + /// This function creates a new ```Voip``` instance containingg a ```UdpSocket``` and an authentication from the server /// Note that this doesnt contain the camera_handle, if you want to add it use the ```add_video_handle()``` function pub async fn new() -> anyhow::Result { @@ -2420,7 +2437,7 @@ impl Voip } /// This function sends the audio and the uuid in one message, this packet is encrypted (The audio's bytes is appended to the uuid's) - /// Any lenght of audio can be sent because the header is included with the packet + /// Any length of audio can be sent because the header is included with the packet pub async fn send_audio( &self, uuid: String, @@ -2438,7 +2455,7 @@ impl Voip } /// This function sends bytes on the UdpSocket the instance contains - /// The bytes passed to this function are automaticly encrypted by the provided encrytion key + /// The bytes passed to this function are automatically encrypted by the provided encryption key /// Message type appends a set isize to the message so that the server can identify each message async fn send_bytes( &self, @@ -2453,23 +2470,23 @@ impl Voip //Encrypt message let mut encrypted_message = encrypt_aes256_bytes(&bytes, encryption_key)?; - //Get message lenght - let mut message_lenght_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); + //Get message length + let mut message_length_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); - //Append message to message lenght - message_lenght_in_bytes.append(&mut encrypted_message); + //Append message to message length + message_length_in_bytes.append(&mut encrypted_message); - //Check for packet lenght overflow - let bytes_lenght = message_lenght_in_bytes.len(); + //Check for packet length overflow + let bytes_length = message_length_in_bytes.len(); - if bytes_lenght > 65535 { + if bytes_length > 65535 { bail!(format!( - "Udp packet lenght overflow, with lenght of {bytes_lenght}" + "Udp packet length overflow, with length of {bytes_length}" )) } //Send bytes - self.socket.send(&message_lenght_in_bytes).await?; + self.socket.send(&message_length_in_bytes).await?; Ok(()) } @@ -2520,7 +2537,7 @@ impl Voip /// __Image message contents:__ /// - ```[len - 64..]``` = Contains the hash (sha256 hash) of the image part we are sending /// - ```[..len - 64]``` = Contains the image part we are sending (JPEG image) - /// - **The hash lenght is 64 bytes.** + /// - **The hash length is 64 bytes.** /// - **The identificator is 64 bytes.** /// - **The uuid is 36 bytes.** async fn send_image_parts( @@ -2671,7 +2688,7 @@ pub struct ScrollToMessage pub messages: Vec, pub index: usize, - /// This a quick fix for the reponses being invalidated, this bool is set to true when the scroll area it is the 2nd iteration of the painting + /// This a quick fix for the responses being invalidated, this bool is set to true when the scroll area it is the 2nd iteration of the painting /// this means that the scroll area already has stick to bottom turned off pub can_scroll: bool, } @@ -2758,7 +2775,7 @@ pub fn ipv6_get() -> Result /// Account management /// This might look similar to ```ClientProfile``` -/// struct containing a new user's info, when serialized / deserialized it gets encrypted or decrypted +/// struct containingg a new user's info, when serialized / deserialized it gets encrypted or decrypted #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default, ToTable)] pub struct UserInformation { @@ -2807,13 +2824,13 @@ impl UserInformation } } - /// Automaticly check hash with argon2 encrypted password (from the file) + /// Automatically check hash with argon2 encrypted password (from the file) pub fn verify_password(&self, password: String) -> bool { pass_hash_match(password, self.password.clone()) } - /// This serializer function automaticly encrypts the struct with the *encrypt_aes256* fn to string + /// This serializer function automatically encrypts the struct with the *encrypt_aes256* fn to string pub fn serialize(&self) -> anyhow::Result { //Hash password so it can be used to encrypt a file @@ -2823,7 +2840,7 @@ impl UserInformation encrypt_aes256(serde_json::to_string(&self)?, &encryption_key) } - /// This deserializer function automaticly decrypts the string the *encrypt_aes256* fn to Self + /// This deserializer function automatically decrypts the string the *encrypt_aes256* fn to Self pub fn deserialize(serialized_struct: &str, password: String) -> anyhow::Result { let hashed_password = sha256::digest(password); @@ -2874,7 +2891,7 @@ pub fn decrypt_aes256(string_to_be_decrypted: &str, key: &[u8]) -> anyhow::Resul let key = Key::::from_slice(key); let cipher = Aes256Gcm::new(key); - + let plaintext = cipher .decrypt(&GenericArray::clone_from_slice(&nonce), ciphertext.as_ref()) .map_err(|_| Error::msg("Invalid password!"))?; @@ -3094,9 +3111,9 @@ where } } -/// This function fetches the incoming full message's lenght (it reads the 4 bytes and creates an u32 number from them, which it returns) +/// This function fetches the incoming full message's length (it reads the 4 bytes and creates an u32 number from them, which it returns) /// afaik this function blocks until it can read the first 4 bytes out of the ```reader``` -pub async fn fetch_incoming_message_lenght(reader: &mut T) -> anyhow::Result +pub async fn fetch_incoming_message_length(reader: &mut T) -> anyhow::Result where T: AsyncReadExt + Unpin + AsyncRead, { @@ -3199,7 +3216,7 @@ pub fn parse_incoming_message(rhs: String) -> Vec //The regexes we use to capture important information let regexes = vec![ //This regex captures newlines - //It doesnt matter when we scan for newlines as theyre not affected by anything + //It doesnt matter when we scan for newlines as they're not affected by anything ( MessageDisplayDiscriminants::NewLine, Regex::new(r"\n").unwrap(), @@ -3352,7 +3369,7 @@ fn filter_string( regexes: &Vec<(MessageDisplayDiscriminants, Regex)>, ) -> Vec { - //We clone the message we need to examine, this value will be modifed by the regexes (Deleting the captured information) + //We clone the message we need to examine, this value will be modified by the regexes (Deleting the captured information) let mut match_message_part = message_part.clone(); //We back up all the matches from the string into this buffer @@ -3470,7 +3487,7 @@ pub enum MessageDisplay #[derive(PartialEq)] pub struct EmojiDisplay { - /// The name of the emoji wanting to be displayed, we make sure to load in all the emojies into the egui buffer when theyre displayed + /// The name of the emoji wanting to be displayed, we make sure to load in all the emojies into the egui buffer when they're displayed pub name: String, } diff --git a/desktop/src/app/client.rs b/desktop/src/app/client.rs index 4c94335..93ff8b2 100644 --- a/desktop/src/app/client.rs +++ b/desktop/src/app/client.rs @@ -29,11 +29,11 @@ pub const UUID_BYTE_OFFSET: usize = 64 + 36; /// This value is the start of the identificator bytes, the end is the end of the message itself pub const IDENTIFICATOR_BYTE_OFFSET: usize = 64; -/// This is the byte lenght of the uuid's text representation (utf8) -pub const UUID_STRING_BYTE_LENGHT: usize = 36; +/// This is the byte length of the uuid's text representation (utf8) +pub const UUID_STRING_BYTE_LENGTH: usize = 36; -use super::backend::{fetch_incoming_message_lenght, get_image_header}; -pub const VOIP_PACKET_BUFFER_LENGHT_MS: usize = 35; +use super::backend::{fetch_incoming_message_length, get_image_header}; +pub const VOIP_PACKET_BUFFER_LENGTH_MS: usize = 35; use image::ImageOutputFormat; use std::{ @@ -58,7 +58,7 @@ pub async fn connect_to_server( let message_bytes = message_as_string.as_bytes(); - //Send message lenght to server + //Send message length to server connection .write_all(&(message_bytes.len() as u32).to_be_bytes()) .await?; @@ -66,11 +66,11 @@ pub async fn connect_to_server( //Send message to server connection.write_all(message_bytes).await?; - //Read the server reply lenght + //Read the server reply length //blocks here for unknown reason - let msg_len = fetch_incoming_message_lenght(&mut connection).await?; + let msg_len = fetch_incoming_message_length(&mut connection).await?; - //Create buffer with said lenght + //Create buffer with said length let mut msg_buffer = vec![0; msg_len as usize]; //Read the server reply @@ -90,10 +90,10 @@ impl ServerReply { let reader = &mut *self.reader.lock().await; - // Read the server reply lenght - let msg_len = fetch_incoming_message_lenght(reader).await?; + // Read the server reply length + let msg_len = fetch_incoming_message_length(reader).await?; - //Create buffer with said lenght + //Create buffer with said length let mut msg_buffer = vec![0; msg_len as usize]; //Read the server reply @@ -129,8 +129,8 @@ impl Application let voice_recording_shutdown = self.voip_video_shutdown_token.clone(); self.voip_thread.get_or_insert_with(|| { - let reciver_socket_part = voip.socket.clone(); - let microphone_precentage = self.client_ui.microphone_volume.clone(); + let receiver_socket_part = voip.socket.clone(); + let microphone_percentage = self.client_ui.microphone_volume.clone(); let (tx, rx) = mpsc::channel::<()>(); @@ -140,21 +140,21 @@ impl Application //Sender thread tokio::spawn(async move { - //This variable is notifed when the Mutex is set to true, when the audio_buffer lenght reaches ```VOIP_PACKET_BUFFER_LENGHT``` and is resetted when the packet is sent + //This variable is notified when the Mutex is set to true, when the audio_buffer length reaches ```VOIP_PACKET_BUFFER_LENGTH``` and is reset when the packet is sent let voip_audio_buffer: Arc>> = Arc::new(std::sync::Mutex::new(VecDeque::new())); - //Conect socket to destination + //Connect socket to destination voip.socket.connect(destination).await.unwrap(); //Start audio recorder - let recording_handle = record_audio_with_interrupt(rx, microphone_precentage, voip_audio_buffer.clone(), enable_microphone.clone()).unwrap(); + let recording_handle = record_audio_with_interrupt(rx, microphone_percentage, voip_audio_buffer.clone(), enable_microphone.clone()).unwrap(); - //We can just send it becasue we have already set the default destination address + //We can just send it because we have already set the default destination address loop { select! { //Wait until we should send the buffer //Record 35ms of audio, send it to the server - _ = tokio::time::sleep(Duration::from_millis(VOIP_PACKET_BUFFER_LENGHT_MS as u64)) => { + _ = tokio::time::sleep(Duration::from_millis(VOIP_PACKET_BUFFER_LENGTH_MS as u64)) => { //We create this scope to tell the compiler the recording handle wont be sent across any awaits let playbackable_audio: Vec = { //Lock handle @@ -163,7 +163,7 @@ impl Application let playbackable_audio: Vec = create_wav_file( recording_handle.clone().into() ); - //Clear out buffer, make the capacity remain (We creted this VecDeque with said default capacity) + //Clear out buffer, make the capacity remain (We created this VecDeque with said default capacity) recording_handle.clear(); //Return wav bytes playbackable_audio @@ -194,7 +194,7 @@ impl Application let image_buffer = voip_image.image_buffer.clone(); - //Reciver thread + //Receiver thread tokio::spawn(async move { let ctx_clone = ctx.clone(); //Listen on socket, play audio @@ -205,9 +205,9 @@ impl Application break; }, - //Recive bytes - _recived_bytes_count = async { - match recive_server_relay(reciver_socket_part.clone(), &decryption_key, sink.clone(), image_buffer.clone(), &ctx_clone).await { + //Receive bytes + _received_bytes_count = async { + match receive_server_relay(receiver_socket_part.clone(), &decryption_key, sink.clone(), image_buffer.clone(), &ctx_clone).await { Ok(_) => (), Err(err) => { tracing::error!("{}", err); @@ -263,12 +263,12 @@ impl Application } } - ///This functions is used for clients to recive messages from the server (this doesnt not check validity of the order of the messages, altough this may not be needed as tcp takes care of this) + ///This functions is used for clients to receive messages from the server (this doesnt not check validity of the order of the messages, although this may not be needed as tcp takes care of this) pub fn client_recv(&mut self, ctx: &egui::Context) { //This should only run when the connection is valid if let ConnectionState::Connected(connection_pair) = self.client_connection.state.clone() { - self.server_sender_thread.get_or_insert_with(|| { + self.server_sender_thread.get_or_insert({ //Clone so we can move it into the closure let sender = self.server_output_sender.clone(); @@ -297,14 +297,14 @@ impl Application }; select! { - //Recive input from main thread to shutdown + //Receive input from main thread to shutdown _ = shutdown_token.cancelled() => { break; }, reply = ServerReply::wait_for_response(server_reply_handle) => { match reply { - //If we have a reponse from the server + //If we have a response from the server Ok(response) => { //Check for special cases like server disconnecting if response == "Server disconnecting from client." { @@ -313,14 +313,14 @@ impl Application //Request repaint context_clone.request_repaint(); - //Send to reciver - sender_clone.send(Some(response)).expect("Error occured when trying to send message, after reciving message from client"); + //Send to receiver + sender_clone.send(Some(response)).expect("Error occurred when trying to send message, after receiving message from client"); }, Err(err) => { tracing::error!("{}", err); - eprintln!("client.rs\nError occured when the client tried to recive a message from the server: {err}"); - eprintln!("Early end of file error is a normal occurence after disconnecting"); + eprintln!("client.rs\nError occurred when the client tried to receive a message from the server: {err}"); + eprintln!("Early end of file error is a normal occurrence after disconnecting"); //Avoid panicking when trying to display a Notification //This is very rare but can still happen display_error_message(err, toasts); @@ -362,7 +362,7 @@ impl Application inner.last_seen_message_index = Some(index); //We only send a sync packet if we need to - //We only have to send the sync message, since in the other thread we are reciving every message sent to us + //We only have to send the sync message, since in the other thread we are receiving every message sent to us match connection_pair.send_message(message.clone()).await { Ok(_) => {}, Err(err) => { @@ -389,9 +389,9 @@ impl Application }); }); - //Try to recive the threads messages + //Try to receive the threads messages //Get sent to the channel to be displayed, if the connections errors out, do nothing lol cuz its prolly cuz the sender hadnt done anything - match self.server_output_reciver.try_recv() { + match self.server_output_receiver.try_recv() { Ok(msg) => { //show messages if let Some(message) = msg { @@ -752,7 +752,7 @@ impl Application self.server_sender_thread = None; //Then the thread got an error, we should reset the state - tracing::error!("Client reciver or sync thread panicked"); + tracing::error!("Client receiver or sync thread panicked"); } }, Err(_err) => { @@ -778,19 +778,19 @@ impl Application //Callback self.client_ui.extension.event_call_extensions( - crate::app::lua::EventCall::OnChatRecive, + crate::app::lua::EventCall::OnChatReceive, &self.lua, Some(message._struct_into_string()), ); } } -/// Recives packets on the given UdpSocket, messages are decrypted with the decrpytion key -/// Automaticly appends the decrypted audio bytes to the ```Sink``` if its an uadio packet -/// I might rework this function so that we can see whos talking based on uuid -async fn recive_server_relay( +/// Receives packets on the given UdpSocket, messages are decrypted with the decrpytion key +/// Automatically appends the decrypted audio bytes to the ```Sink``` if its an uadio packet +/// I might rework this function so that we can see who is talking based on uuid +async fn receive_server_relay( //Socket this function is Listening on - reciver_socket_part: Arc, + receiver_socket_part: Arc, //Decryption key decryption_key: &[u8], //The sink its appending the bytes to @@ -804,20 +804,20 @@ async fn recive_server_relay( //Create buffer for header, this is the size of the maximum udp packet so no error will appear let mut header_buf = vec![0; 65536]; - //Recive header size - reciver_socket_part + //Receive header size + receiver_socket_part .peek_from(&mut header_buf) .await .unwrap(); - //Get message lenght - let header_lenght = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); + //Get message length + let header_length = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); - //Create body according to message size indicated by the header, make sure to add 4 to the byte lenght because we peeked the ehader thus we didnt remove the bytes from the buffer - let mut body_buf = vec![0; (header_lenght + 4) as usize]; + //Create body according to message size indicated by the header, make sure to add 4 to the byte length because we peeked the ehader thus we didnt remove the bytes from the buffer + let mut body_buf = vec![0; (header_length + 4) as usize]; - //Recive the whole message - reciver_socket_part.recv(&mut body_buf).await.unwrap(); + //Receive the whole message + receiver_socket_part.recv(&mut body_buf).await.unwrap(); //Decrypt message let mut decrypted_bytes = decrypt_aes256_bytes( @@ -833,7 +833,7 @@ async fn recive_server_relay( //The generated uuids are always a set amount of bytes, so we can safely extract them, and we know that the the left over bytes are audio let uuid = String::from_utf8( decrypted_bytes - .drain(decrypted_bytes.len() - UUID_STRING_BYTE_LENGHT..) + .drain(decrypted_bytes.len() - UUID_STRING_BYTE_LENGTH..) .collect(), )?; @@ -841,7 +841,7 @@ async fn recive_server_relay( uuid::Uuid::parse_str(&uuid) .map_err(|err| anyhow::Error::msg(format!("Error: {}, in uuid {}", err, uuid)))?; - //Play recived bytes + //Play received bytes sink.append(rodio::Decoder::new(BufReader::new(Cursor::new( decrypted_bytes, )))?); diff --git a/desktop/src/app/lua.rs b/desktop/src/app/lua.rs index d2d2ede..e298389 100644 --- a/desktop/src/app/lua.rs +++ b/desktop/src/app/lua.rs @@ -106,7 +106,7 @@ pub enum LuaOutput /// Standard output from the lua runtime Standard(String), - /// Displays useful information like a file got modifed (This message will only be added from the rust runtime, for example when saving a file) + /// Displays useful information like a file got modified (This message will only be added from the rust runtime, for example when saving a file) Info(String), } @@ -117,7 +117,7 @@ pub struct Extension pub extension_list: Vec, #[serde(skip)] - /// This list contins all the output from the extensions, panics are logged and stdouts are also logged here as Standard() + /// This list contains all the output from the extensions, panics are logged and stdouts are also logged here as Standard() pub output: Arc>>, pub output_rect: Rect, @@ -131,7 +131,7 @@ pub struct Extension pub enum EventCall { /// Triggered when sending a message - /// If this Event is invoked the function will recive what the user has sent, this is optional to "recive" + /// If this Event is invoked the function will receive what the user has sent, this is optional to "receive" /// ``` lua /// function OnChatSend(message) /// --Do anything with the message @@ -142,10 +142,10 @@ pub enum EventCall /// ``` OnChatSend, - /// Triggered when reciving a message - OnChatRecive, + /// Triggered when receiving a message + OnChatReceive, - /// Triggered when reciving a message from the server + /// Triggered when receiving a message from the server /// This is unused and will be reused for something else in the future #[allow(dead_code)] OnServerChatReceive, @@ -153,7 +153,7 @@ pub enum EventCall /// Triggered when sending a group voice call request OnCallSend, - /// Triggered when reciving a group voice call, + /// Triggered when receiving a group voice call, OnCallReceive, /// Triggered every draw of the ui diff --git a/desktop/src/app/server.rs b/desktop/src/app/server.rs index 316b7b7..719adda 100644 --- a/desktop/src/app/server.rs +++ b/desktop/src/app/server.rs @@ -16,7 +16,7 @@ use indexmap::IndexMap; use tokio_util::sync::CancellationToken; use super::backend::{ - encrypt, encrypt_aes256, fetch_incoming_message_lenght, ClientLastSeenMessage, + encrypt, encrypt_aes256, fetch_incoming_message_length, ClientLastSeenMessage, ClientMessageType, ClientProfile, ConnectedClient, ConnectionType, MessageReaction, Reaction, ReactionType, ServerClientReply, ServerMessageType, ServerMessageTypeDiscriminants::{ @@ -115,7 +115,7 @@ pub struct SharedFields pub async fn server_main( port: String, password: String, - //This signals all the client recivers to be shut down + //This signals all the client receivers to be shut down cancellation_token: CancellationToken, connected_clients_profile_list: Arc>, //We pass in ctx so we can request repaint when someone connects @@ -156,7 +156,7 @@ pub async fn server_main( } }; - //split client stream, so we will be able to store these seperately + //split client stream, so we will be able to store these separately let (reader, writer) = stream.into_split(); //We need to clone here too, to pass it into the listener thread @@ -256,7 +256,7 @@ fn spawn_client_reader( break; } - msg = recive_message(reader.clone()) => { + msg = receive_message(reader.clone()) => { msg? } }; @@ -281,11 +281,11 @@ fn spawn_client_reader( } #[inline] -async fn recive_message(reader: Arc>) -> Result +async fn receive_message(reader: Arc>) -> Result { let mut reader = reader.lock().await; - let incoming_message_len = fetch_incoming_message_lenght(&mut *reader).await?; + let incoming_message_len = fetch_incoming_message_length(&mut *reader).await?; let mut message_buffer: Vec = vec![0; incoming_message_len as usize]; @@ -326,15 +326,15 @@ async fn sync_message_with_clients( //Encrypt string let encrypted_string = encrypt_aes256(server_master_string, &key).unwrap(); - //Send message lenght - let message_lenght = TryInto::::try_into(encrypted_string.as_bytes().len())?; + //Send message length + let message_length = TryInto::::try_into(encrypted_string.as_bytes().len())?; for client in connected_clients_locked.iter_mut() { if let Some(client_handle) = &mut client.handle { let mut client_handle = client_handle.lock().await; client_handle - .write_all(&message_lenght.to_be_bytes()) + .write_all(&message_length.to_be_bytes()) .await?; //Send actual message @@ -353,7 +353,7 @@ where { let message_bytes = message.as_bytes(); - //Send message lenght + //Send message length writer .write_all(&(message_bytes.len() as u32).to_be_bytes()) .await?; @@ -369,7 +369,7 @@ pub fn create_client_voip_manager( voip: ServerVoip, shutdown_token: CancellationToken, key: [u8; 32], - mut reciver: Receiver>, + mut receiver: Receiver>, #[allow(unused_variables)] listening_to: SocketAddr, uuid: String, ) @@ -393,13 +393,13 @@ pub fn create_client_voip_manager( break; }, - //recive_message lenght by reading its first 4 bytes - recived_bytes = reciver.recv() => { - if let Some(recived_bytes) = recived_bytes { + //receive_message length by reading its first 4 bytes + received_bytes = receiver.recv() => { + if let Some(received_bytes) = received_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(); + // PACKET LENGTH MESSAGE MSG TYPE + let mut decrypted_bytes = decrypt_aes256_bytes(&received_bytes, &key).unwrap(); let message_type_bytes: Vec = decrypted_bytes.drain(decrypted_bytes.len() - 4..).collect(); @@ -436,13 +436,13 @@ pub fn create_client_voip_manager( let mut encrypted_packet = encrypt_aes256_bytes(&decrypted_bytes, &key).unwrap(); //Get encrypted packet size - let mut message_lenght_header = (encrypted_packet.len() as u32).to_be_bytes().to_vec(); + let mut message_length_header = (encrypted_packet.len() as u32).to_be_bytes().to_vec(); //Append message to header - message_lenght_header.append(&mut encrypted_packet); + message_length_header.append(&mut encrypted_packet); - //Send the header indicating message lenght and send the whole message appended to it - socket.send_to(&message_lenght_header, connected_socket_addr).await.unwrap(); + //Send the header indicating message length and send the whole message appended to it + socket.send_to(&message_length_header, connected_socket_addr).await.unwrap(); } }); } @@ -567,23 +567,23 @@ async fn send_bytes( //Encrypt message let mut encrypted_message = encrypt_aes256_bytes(&bytes, encryption_key)?; - //Get message lenght - let mut message_lenght_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); + //Get message length + let mut message_length_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); - //Append message to message lenght - message_lenght_in_bytes.append(&mut encrypted_message); + //Append message to message length + message_length_in_bytes.append(&mut encrypted_message); - //Check for packet lenght overflow - let bytes_lenght = message_lenght_in_bytes.len(); + //Check for packet length overflow + let bytes_length = message_length_in_bytes.len(); - if bytes_lenght > 65536 { + if bytes_length > 65536 { bail!(format!( - "Udp packet lenght overflow, with lenght of {bytes_lenght}" + "Udp packet length overflow, with length of {bytes_length}" )) } //Send bytes - socket.send_to(&message_lenght_in_bytes, send_to).await?; + socket.send_to(&message_length_in_bytes, send_to).await?; Ok(()) } @@ -594,7 +594,7 @@ async fn send_bytes( /// - ```[len - 64 - 36.. len - 64]``` = Contains the UUID of the author who has sent the message /// - ```[..len - 64 - 64 - 36]``` = Contains the image part we are sending (JPEG image) /// - ```[len - 64..]``` = Contains the identificator of the part we are sending -/// - **The hash lenght is 64 bytes.** +/// - **The hash length is 64 bytes.** /// - **The identificator is 64 bytes.** /// - **The uuid is 36 bytes.** async fn send_image_parts( @@ -639,7 +639,7 @@ async fn send_image_parts( impl MessageService { /// The result returned by this function may be a real error, or an error constructed on purpose so that the thread call this function gets shut down. - /// When experiening errors, make sure to check the error message as it may be on purpose + /// When experiencing errors, make sure to check the error message as it may be on purpose #[inline] async fn message_main( &mut self, @@ -653,7 +653,7 @@ impl MessageService let req: ClientMessage = req_result.unwrap(); //If its a Client reaction or a message edit we shouldnt allocate more MessageReactions, since those are not actual messages - //HOWEVER, if theyre client connection or disconnection messages a reaction should be allocated because people can react to those + //HOWEVER, if their client connection or disconnection messages a reaction should be allocated because people can react to those if !(matches!(&req.message_type, ClientReaction(_)) || matches!(&req.message_type, MessageEdit(_)) || { @@ -887,20 +887,20 @@ impl MessageService //Wait until we get a new message or until the thread token gets cancelled select! { - //Wait until we recive a new message - //Recive header size + //Wait until we receive a new message + //Receive header size _ = socket.peek_from(&mut header_buf) => { - //Get message lenght - let header_lenght = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); + //Get message length + let header_length = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); - //Create body according to message size indicated by the header, make sure to add 4 to the byte lenght because we peeked the header thus we didnt remove the bytes from the buffer - let mut body_buf = vec![0; header_lenght as usize + 4]; + //Create body according to message size indicated by the header, make sure to add 4 to the byte length because we peeked the header thus we didnt remove the bytes from the buffer + let mut body_buf = vec![0; header_length as usize + 4]; match socket.recv_from(&mut body_buf).await { Ok((_, socket_addr)) => { match connected_clients.get(&socket_addr) { Some(client) => { - //We send everythin from the 4th byte since that is the part of the header + //We send everythingg from the 4th byte since that is the part of the header //We dont care about the result since it will panic when the thread is shut down let _ = client.0.send(body_buf[4..].to_vec()).await; }, @@ -931,7 +931,7 @@ impl MessageService .get(&socket_addr) .is_none() { - let (sender, reciver) = mpsc::channel::>(255); + let (sender, receiver) = mpsc::channel::>(255); //Create cancellation token for client let client_manager_cancellation_token = @@ -942,7 +942,7 @@ impl MessageService voip.clone(), client_manager_cancellation_token.clone(), self.decryption_key, - reciver, + receiver, socket_addr, req.uuid.clone(), ); @@ -1161,7 +1161,7 @@ impl MessageService match &req.message_type { FileRequestType(_) => unreachable!(), FileUpload(inner) => { - //We should match the upload type more specificly + //We should match the upload type more specifically match inner.extension.clone().unwrap_or_default().as_str() { "png" | "jpeg" | "bmp" | "tiff" | "webp" | "gif" | "jpg" => Image, "wav" | "mp3" | "m4a" => Audio, @@ -1350,8 +1350,8 @@ impl MessageService )); } - /// This function returns a message containing a full sync (all the messages etc) - /// It reutrns a ```ServerMaster``` converted to an encrypted string + /// This function returns a message containingg a full sync (all the messages etc) + /// It returns a ```ServerMaster``` converted to an encrypted string async fn full_sync_client(&self) -> anyhow::Result { //Construct reply @@ -1420,9 +1420,9 @@ impl MessageService } }; } - async fn recive_file(&self, request: ClientMessage, req: &ClientFileUploadStruct) + async fn receive_file(&self, request: ClientMessage, req: &ClientFileUploadStruct) { - //We should retrive the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it + //We should retrieve the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it let file_author = self .connected_clients_profile .lock() @@ -1491,9 +1491,9 @@ impl MessageService { fs::read(&*self.image_list.get(&signature).unwrap()).unwrap_or_default() } - async fn recive_image(&self, req: ClientMessage, img: &ClientFileUploadStruct) + async fn receive_image(&self, req: ClientMessage, img: &ClientFileUploadStruct) { - //We should retrive the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it + //We should retrieve the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it let file_author = self .connected_clients_profile .lock() @@ -1549,9 +1549,9 @@ impl MessageService }, } } - async fn recive_audio(&self, req: ClientMessage, audio: &ClientFileUploadStruct) + async fn receive_audio(&self, req: ClientMessage, audio: &ClientFileUploadStruct) { - //We should retrive the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it + //We should retrieve the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it let file_author = self .connected_clients_profile .lock() @@ -1678,14 +1678,14 @@ impl MessageService //Create server folder, so we will have a place to put our uploads let _ = fs::create_dir(format!("{}\\matthias\\Server", env!("APPDATA"))); - //Pattern match on upload tpye so we know how to handle the specific request + //Pattern match on upload type 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 + self.receive_image(req, upload_type).await }, - "wav" | "mp3" | "m4a" => self.recive_audio(req, upload_type).await, + "wav" | "mp3" | "m4a" => self.receive_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, + _ => self.receive_file(req, upload_type).await, } } diff --git a/desktop/src/app/ui/client.rs b/desktop/src/app/ui/client.rs index 2d1d7e3..fa96998 100644 --- a/desktop/src/app/ui/client.rs +++ b/desktop/src/app/ui/client.rs @@ -100,7 +100,7 @@ impl Application ))); if disconnect_button.clicked() { - //Disable camera if it exists before everything else + //Disable camera if it exists before everythingg else if voip.camera_handle_is_open.load(Relaxed) { self.disable_camera(voip); } @@ -353,7 +353,7 @@ impl Application ); }); - //We have to render the message area after everything else, because then we will be using the area whats left of the ui + //We have to render the message area after everythingg else, because then we will be using the area whats left of the ui //msg_area egui::CentralPanel::default().show(ctx, |ui| { //Drop file warning @@ -476,7 +476,7 @@ impl Application }); ui.separator(); - //For the has_search logic to work and for the rust compiler not to underline everything + //For the has_search logic to work and for the rust compiler not to underline everythingg egui::ScrollArea::new([true, true]).auto_shrink([false, true]).show(ui, |ui|{ ui.allocate_ui(ui.available_size(), |ui|{ let mut has_search = false; @@ -563,7 +563,7 @@ impl Application let group = ui.group(|ui|{ ui.label(RichText::from(message.author.to_string()).size(self.font_size / 1.3).color(Color32::WHITE)); - //This button shouldnt actually do anything becuase when this message group gets clicked it throws you to the message + //This button shouldnt actually do anything because when this message group gets clicked it throws you to the message if ui.small_button(inner_message.file_name.to_string()).clicked() { self.client_ui.scroll_to_message_index = Some(index) }; @@ -578,12 +578,12 @@ impl Application has_search = true; } - /* Inner value shouldnt actaully be used since its only used for asking for a file, and to stay compact i wont implement image displaying in search mode */ + /* Inner value shouldnt actually be used since its only used for asking for a file, and to stay compact i wont implement image displaying in search mode */ if let ServerMessageType::Image( _ ) = &message.message_type { let group = ui.group(|ui|{ ui.label(RichText::from(message.author.to_string()).size(self.font_size / 1.3).color(Color32::WHITE)); - //This button shouldnt actually do anything becuase when this message group gets clicked it throws you to the message + //This button shouldnt actually do anything because when this message group gets clicked it throws you to the message if ui.small_button("Image").clicked() { self.client_ui.scroll_to_message_index = Some(index) }; @@ -602,7 +602,7 @@ impl Application let group = ui.group(|ui|{ ui.label(RichText::from(message.author.to_string()).size(self.font_size / 1.3).color(Color32::WHITE)); - //This button shouldnt actually do anything becuase when this message group gets clicked it throws you to the message + //This button shouldnt actually do anything because when this message group gets clicked it throws you to the message if ui.small_button("Audio").clicked() { self.client_ui.scroll_to_message_index = Some(index) }; @@ -661,7 +661,7 @@ impl Application }); }); - //Server reciver + //Server receiver self.client_recv(ctx); //Client voip thread managemant @@ -687,7 +687,7 @@ impl Application //Convert idx to usize let index = index as usize; - //Check if the request was unsuccesful, so we can reset the states + //Check if the request was unsuccessful, so we can reset the states if sink.is_none() { //Reset state self.client_ui.audio_playback.settings_list[index].is_loading = false; diff --git a/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs b/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs index a0131d3..ef3c476 100644 --- a/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs +++ b/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs @@ -18,11 +18,11 @@ use std::{ time::Duration, }; -pub const VOIP_PACKET_BUFFER_LENGHT_MS: usize = 35; +pub const VOIP_PACKET_BUFFER_LENGTH_MS: usize = 35; pub const SAMPLE_RATE: usize = 48000; -pub const STEREO_PACKET_BUFFER_LENGHT: usize = - SAMPLE_RATE * 2 * VOIP_PACKET_BUFFER_LENGHT_MS / 1000; +pub const STEREO_PACKET_BUFFER_LENGTH: usize = + SAMPLE_RATE * 2 * VOIP_PACKET_BUFFER_LENGTH_MS / 1000; struct Opt { @@ -50,11 +50,11 @@ impl Default for Opt } } -/// This function records audio for the passed in duration, then it reutrns the recorded bytes wrapped in a result -/// The amplification precentage is the precent the microphone's volume should be present, this is later turned into a multiplier +/// This function records audio for the passed in duration, then it returns the recorded bytes wrapped in a result +/// The amplification percentage is the percent the microphone's volume should be present, this is later turned into a multiplier pub fn record_audio_for_set_duration( dur: Duration, - amplification_precentage: f32, + amplification_percentage: f32, ) -> anyhow::Result> { let opt = Opt::default(); @@ -86,7 +86,7 @@ pub fn record_audio_for_set_duration( let stream = device.build_input_stream( &config.into(), move |data, _: &_| { - write_input_data::(data, wav_buffer.clone(), amplification_precentage / 100.) + write_input_data::(data, wav_buffer.clone(), amplification_percentage / 100.) }, err_fn, None, @@ -102,10 +102,10 @@ pub fn record_audio_for_set_duration( } /// This function returns a handle to a `queue` of bytes (```Arc>>```), while spawning a thread which constantly writes the incoming audio into the buffer -/// This `queue` or `buffer` gets updated from left to right, the new element always pushes back all the elements behind it, if the value's index reaches ```idx > queue_lenght```, it gets dropped. +/// This `queue` or `buffer` gets updated from left to right, the new element always pushes back all the elements behind it, if the value's index reaches ```idx > queue_length```, it gets dropped. pub fn record_audio_with_interrupt( interrupt: Receiver<()>, - amplification_precentage: Arc, + amplification_percentage: Arc, buffer_handle: Arc>>, should_record: Arc, ) -> anyhow::Result>>> @@ -128,7 +128,7 @@ pub fn record_audio_with_interrupt( if !write_input_data_to_buffer_with_set_len::( data, buffer_handle.clone(), - amplification_precentage.load(Relaxed) as f32 / 100., + amplification_percentage.load(Relaxed) as f32 / 100., should_record.clone(), ) { //Quit the thread, stop recording @@ -170,11 +170,11 @@ fn get_recording_device() -> Result<(Device, SupportedStreamConfig), Error> Ok((device, config)) } -/// This function records audio on a different thread, until the reciver recives something, then the recorded buffer is returned -/// The amplification precentage is the precent the microphone's volume should be present, this is later turned into a multiplier +/// This function records audio on a different thread, until the receiver receives something, then the recorded buffer is returned +/// The amplification percentage is the percent the microphone's volume should be present, this is later turned into a multiplier pub fn audio_recording_with_recv( receiver: mpsc::Receiver, - amplification_precentage: f32, + amplification_percentage: f32, ) -> anyhow::Result> { let (device, config) = get_recording_device()?; @@ -190,7 +190,7 @@ pub fn audio_recording_with_recv( let stream = device.build_input_stream( &config.into(), move |data, _: &_| { - write_input_data::(data, wav_buffer.clone(), amplification_precentage / 100.) + write_input_data::(data, wav_buffer.clone(), amplification_percentage / 100.) }, err_fn, None, @@ -230,7 +230,7 @@ fn wav_spec_from_config(config: &cpal::SupportedStreamConfig) -> hound::WavSpec } } -/// This function creates a wav foramtted audio file, containing the samples provided to this function +/// This function creates a wav foramtted audio file, containingg the samples provided to this function pub fn create_wav_file(samples: Vec) -> Vec { let writer = Arc::new(Mutex::new(Vec::new())); @@ -254,7 +254,7 @@ pub fn create_wav_file(samples: Vec) -> Vec buf.into_inner().to_vec() } -/// This function creates a wav foramtted audio file, containing the samples provided to this function +/// This function creates a wav foramtted audio file, containingg the samples provided to this function /// This function doesnt work properly pub fn create_opus_file(mut samples: Vec) -> Vec { @@ -265,7 +265,7 @@ pub fn create_opus_file(mut samples: Vec) -> Vec ) .unwrap(); - samples.resize(STEREO_PACKET_BUFFER_LENGHT, 0.); + samples.resize(STEREO_PACKET_BUFFER_LENGTH, 0.); opus_encoder .encode_vec_float(&samples, 512) @@ -288,7 +288,7 @@ where writer.lock().unwrap().append(&mut inp_vec); } -/// This function writes the multiplied (by the ```amplification_multiplier```) samples to the ```buffer_handle```, and keeps the buffer the lenght of ```len``` +/// This function writes the multiplied (by the ```amplification_multiplier```) samples to the ```buffer_handle```, and keeps the buffer the length of ```len``` /// It will notify the Condvar if the buffer_handle's len reaches ```len``` fn write_input_data_to_buffer_with_set_len( input: &[T], 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 2868ffa..bdb6bb3 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 @@ -176,7 +176,7 @@ impl Application ClientMessage::construct_image_request_msg(picture.signature.clone(), uuid); let connection = self.client_connection.clone(); tokio::spawn(async move { - //We only have to send the message it will get recived in a diff place + //We only have to send the message it will get received in a diff place connection.clone().send_message(message).await.unwrap(); }); } @@ -403,7 +403,7 @@ impl Application .get(server_voip_event.uuid.as_str()) { Some(profile) => profile, - //If we dont have the profile we ask for it then return to avoid panicing + //If we dont have the profile we ask for it then return to avoid panicking None => { self.request_client(server_voip_event.uuid.to_string()); @@ -430,7 +430,7 @@ impl Application .get(server_voip_event.uuid.as_str()) { Some(profile) => profile, - //If we dont have the profile we ask for it then return to avoid panicing + //If we dont have the profile we ask for it then return to avoid panicking None => { self.request_client(server_voip_event.uuid.to_string()); diff --git a/desktop/src/app/ui/client_ui/message_instances/message_main.rs b/desktop/src/app/ui/client_ui/message_instances/message_main.rs index 1d7d7a7..240ea9e 100644 --- a/desktop/src/app/ui/client_ui/message_instances/message_main.rs +++ b/desktop/src/app/ui/client_ui/message_instances/message_main.rs @@ -94,9 +94,9 @@ impl Application ) { //The inner ui's response - let mut message_reponse: Option = None; + let mut message_response: Option = None; - let mut reply_area_reponse: Option = None; + let mut reply_area_response: Option = None; //Emoji tray pops up when right clicking on a message let message_group = ui.group(|ui| { @@ -168,7 +168,7 @@ impl Application ); }); - reply_area_reponse = Some(reply_button_area.response.clone()); + reply_area_response = Some(reply_button_area.response.clone()); if ui .interact( @@ -197,7 +197,7 @@ impl Application }); //IMPORTANT: Each of these functions have logic inside them for displaying - message_reponse = Some( + message_response = Some( ui.push_id(iter_index, |ui| { self.message_display(item, ui, ctx, iter_index) }) @@ -219,7 +219,7 @@ impl Application egui::ScrollArea::horizontal() .id_source( - /* Autoassign id's to interated scroll widgets */ ui.next_auto_id(), + /* Autoassign id's to integrated scroll widgets */ ui.next_auto_id(), ) .max_height(self.font_size) .show(ui, |ui| { @@ -308,17 +308,17 @@ impl Application } }); - if let Some(inner_message_reponse) = message_reponse { - let mut response = inner_message_reponse.union(message_group.response); + if let Some(inner_message_response) = message_response { + let mut response = inner_message_response.union(message_group.response); - if let Some(reply_response) = reply_area_reponse { + if let Some(reply_response) = reply_area_response { response = reply_response.union(response); - //Back up reponse of message group, so we can scroll to it later if the user thinks like it + //Back up response of message group, so we can scroll to it later if the user thinks like it message_instances.push(response.clone()); } else { - //Back up reponse of message group, so we can scroll to it later if the user thinks like it + //Back up response of message group, so we can scroll to it later if the user thinks like it message_instances.push(response.clone()); } @@ -326,7 +326,7 @@ impl Application let profile_menu_button = ui.menu_button("Profile", |ui| { //Check if the message was sent by the server, create a custom profile for it if item.uuid == SERVER_UUID { - //Add verification or somthing like that + //Add verification or something like that ui.allocate_ui(vec2(ui.available_width(), 25.), |ui| { ui.horizontal_centered(|ui| { ui.label("This message was sent by the host server"); @@ -413,7 +413,7 @@ impl Application if item.uuid == self.opened_user_information.uuid && item.message_type != ServerMessageType::Deleted { - //We should only display the `edit` button if its anormal message thus its editable + //We should only display the `edit` button if its abnormal message thus its editable if let ServerMessageType::Normal(inner) = &item.message_type { if ui .add(Button::image_and_text( diff --git a/desktop/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs b/desktop/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs index cec57d3..9e734a6 100644 --- a/desktop/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs +++ b/desktop/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs @@ -24,7 +24,7 @@ impl ToString for EmojiTypes impl backend::Application { - /// We return the name of the emoji selected, if none was selected in that frame we reutrn None + /// We return the name of the emoji selected, if none was selected in that frame we return None pub fn draw_emoji_selector(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) -> Option { @@ -242,7 +242,7 @@ impl backend::Application } } -/// This will display the emoji under the given name, if it is not found in the egui image buffer it will automaticly load it +/// This will display the emoji under the given name, if it is not found in the egui image buffer it will automatically load it pub fn display_emoji(ctx: &egui::Context, emoji_name: &str, ui: &mut egui::Ui) -> Option { match ctx.try_load_bytes(&format!("bytes://{}", emoji_name)) { diff --git a/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs b/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs index 5ed7bca..7df7dea 100644 --- a/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs +++ b/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs @@ -49,7 +49,7 @@ impl Application { ctx.input_mut(|reader| { //Check if this key was pressed - //We will not consume this key since its not sure we can acually edit the message + //We will not consume this key since its not sure we can actually edit the message if reader.key_pressed(Key::ArrowUp) { //Iter over all the messages so we will get the latest message sent by us for (idx, message) in self @@ -150,15 +150,15 @@ impl Application //We will reconstruct the buffer let mut split = user_message_clone.split('@').collect::>(); - //We just pattern match for the sake of never panicing, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) + //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last_mut() { - //If the last slice of the string (split by @) doesnt contain any spaces we can paint everything else + //If the last slice of the string (split by @) doesnt contain any spaces we can paint everythingg else if !last.contains(' ') { //Set this var true if the @ menu is being displayed; //* self.get_connected_users function MUST be called before showing the text input widget, so this way we can actually consume the ArrowUp and Down keys self.client_ui.display_user_list = self.get_connected_users(ctx); - //Consume input when we are diplaying the user list + //Consume input when we are displaying the user list if self.client_ui.display_user_list { ctx.input_mut(|reader| { //Clone var to avoid error @@ -203,7 +203,7 @@ impl Application *buffer = &formatted_string; - //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz theyre not present when concating a normal vec (constructed from a string, split by @s) + //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz they're not present when concatenating a normal vec (constructed from a string, split by @s) let split_concat = split.join("@"); //Set the buffer to the concatenated vector, append the @ to the 0th index @@ -230,9 +230,9 @@ impl Application let split_clone = split.clone(); - //We just pattern match for the sake of never panicing, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) + //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last() { - //If the last slice of the string (split by :) doesnt contain any spaces we can paint everything else + //If the last slice of the string (split by :) doesnt contain any spaces we can paint everythingg else if !last.contains(' ') && !last.is_empty() && split_clone.len() > 1 { let matched_emojis = self.get_emojis(ctx, last.to_string()); @@ -242,7 +242,7 @@ impl Application return; } - //Consume input when we are diplaying the user list + //Consume input when we are displaying the user list ctx.input_mut(|reader| { //Clone var to avoid error let user_message_clone = self.client_ui.message_buffer.clone(); @@ -262,7 +262,7 @@ impl Application *last = &formatted_string; - //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz theyre not present when concating a normal vec (constructed from a string, split by @s) + //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz they're not present when concatenating a normal vec (constructed from a string, split by @s) let split_concat = split.join(":"); //Set the buffer to the concatenated vector, append the @ to the 0th index @@ -448,7 +448,7 @@ impl Application .size(self.font_size) .color(Color32::RED), ); - //Display lenght + //Display length ui.label( RichText::from(format!( "{}s", @@ -480,13 +480,13 @@ impl Application //Move into thread let audio_bytes_sender = self.audio_bytes_tx.clone(); - let microphone_precentage = + let microphone_percentage = self.client_ui.microphone_volume.clone(); tokio::spawn(async move { let bytes = audio_recording_with_recv( rx, - microphone_precentage + microphone_percentage .load(std::sync::atomic::Ordering::Relaxed) as f32, ) @@ -697,7 +697,7 @@ impl Application self.client_ui.emojis_display_rect = Some(emoji_group.response.rect); - //if there are no matched emojis we return to, avoid panicing cuz of the clamping, and to avoid consuming inputs + //if there are no matched emojis we return to, avoid panicking cuz of the clamping, and to avoid consuming inputs if matched_emojis.is_empty() { return; } diff --git a/desktop/src/app/ui/register.rs b/desktop/src/app/ui/register.rs index 7bb81de..9c475fa 100644 --- a/desktop/src/app/ui/register.rs +++ b/desktop/src/app/ui/register.rs @@ -155,7 +155,7 @@ impl Application //Draw background ui.painter().rect_filled( - Rect::everything_right_of(ui.available_width()), + Rect::everythingg_right_of(ui.available_width()), 0., Color32::from_black_alpha(160), ); @@ -233,13 +233,12 @@ impl Application .order(egui::Order::Background) .constrain_to(image_bounds) .show(ctx, |ui| { - if let Some(image_path) = self.register.image.image_path.clone() { + if let Some(image_path) = self.register.image.image_path.clone() + { let allocated_img = ui.allocate_ui( vec2(image.width() as f32, image.height() as f32), |ui| { - if let Ok(read_bytes) = - fs::read(image_path) - { + if let Ok(read_bytes) = fs::read(image_path) { ui.add(Image::from_bytes( "bytes://register_image", read_bytes, @@ -247,7 +246,8 @@ impl Application } }, ); - self.register.image.image_rect = allocated_img.response.rect; + self.register.image.image_rect = + allocated_img.response.rect; } }); } @@ -268,15 +268,16 @@ impl Application display_error_message(err, self.toasts.clone()); }, } - + self.register.image.image_path = app_data_path; - + ctx.forget_image("bytes://register_image"); } } if !(self.register.normal_profile_picture.is_empty() - && self.register.small_profile_picture.is_empty()) // self.register.image.image_path.is_none() + && self.register.small_profile_picture.is_empty()) + // self.register.image.image_path.is_none() { //Display profile picure preview ui.horizontal_centered(|ui| { @@ -394,7 +395,8 @@ fn read_image(app_data_path: &PathBuf) -> anyhow::Result Ok(image_reader) } -pub fn create_dynamic_image_from_bytes(bytes: &[u8]) -> anyhow::Result { +pub fn create_dynamic_image_from_bytes(bytes: &[u8]) -> anyhow::Result +{ let image_reader = ImageReader::new(Cursor::new(bytes)) .with_guessed_format()? .decode()?; diff --git a/desktop/src/app/ui/server.rs b/desktop/src/app/ui/server.rs index 4cf2132..10331b2 100644 --- a/desktop/src/app/ui/server.rs +++ b/desktop/src/app/ui/server.rs @@ -41,7 +41,7 @@ impl Application let connected_clients: std::sync::Arc> = self.server_connected_clients_profile.clone(); - let shared_fileds_clone = self.client_ui.shared_fields.clone(); + let shared_fields_clone = self.client_ui.shared_fields.clone(); //Move context so we can request_repaint let ctx = ctx.clone(); @@ -61,7 +61,7 @@ impl Application Ok(shared_fields) => { //Assign shared fields tokio::spawn(async move { - *shared_fileds_clone.lock().unwrap() = + *shared_fields_clone.lock().unwrap() = shared_fields.lock().await.clone(); }); }, diff --git a/desktop/src/main.rs b/desktop/src/main.rs index 803dedc..2adfd72 100644 --- a/desktop/src/main.rs +++ b/desktop/src/main.rs @@ -53,7 +53,7 @@ async fn main() -> eframe::Result<()> .unwrap(); //Display error message - display_panic_message(format!("A panic! has occured the error is logged in %appdata%. Please send the generated file or this message to the developer!\nPanic: \n{:?}\nLocation: \n{:?}", { + display_panic_message(format!("A panic! has occurred the error is logged in %appdata%. Please send the generated file or this message to the developer!\nPanic: \n{:?}\nLocation: \n{:?}", { match info.payload().downcast_ref::<&str>() { Some(msg) => msg, None => { diff --git a/mobile/build_info.Matthias_build b/mobile/build_info.Matthias_build new file mode 100644 index 0000000..bd9230f --- /dev/null +++ b/mobile/build_info.Matthias_build @@ -0,0 +1 @@ +2024.08.30. 08:54 \ No newline at end of file diff --git a/mobile/src/app.rs b/mobile/src/app.rs index 7d862b9..8b09382 100644 --- a/mobile/src/app.rs +++ b/mobile/src/app.rs @@ -273,8 +273,8 @@ impl eframe::App for backend::Application }; }); - //Connection reciver - match self.connection_reciver.try_recv() { + //Connection receiver + match self.connection_receiver.try_recv() { Ok(connection) => { if let Some(connection) = connection { //Modify client_connection @@ -303,10 +303,10 @@ impl eframe::App for backend::Application } } else { - // A race condition will occur if we connected succesfully after getting a connection error (request timed out) + // A race condition will occur if we connected successfully after getting a connection error (request timed out) // So we check if we have already made the connection before actually modifying the value based on the timed out request if !matches!(self.client_connection.state, ConnectionState::Connected(_)) { - //If we recived a None it means we have an error + //If we received a None it means we have an error self.client_connection.state = ConnectionState::Error; } } @@ -317,7 +317,7 @@ impl eframe::App for backend::Application } //Voip instance listener - // match self.voip_connection_reciver.try_recv() { + // match self.voip_connection_receiver.try_recv() { // Ok(voip) => { // self.client_ui.voip = Some(voip.clone()); @@ -478,7 +478,7 @@ impl backend::Application }); ui.horizontal(|ui| { - ui.label("Microphone volume precentage"); + ui.label("Microphone volume percentage"); ui.add(Slider::new( &mut *self.client_ui.microphone_volume.lock().unwrap(), 50.0..=500.0, @@ -506,10 +506,10 @@ impl backend::Application let user_information = self.opened_user_information.clone(); - //Reset all messages and everything else + //Reset all messages and everythingg else self.client_ui.incoming_messages = ServerMaster::default(); - //Forget all imaes so the cahced imges will be deleted + //Forget all imaes so the cached imges will be deleted ctx.forget_all_images(); let toasts = self.toasts.clone(); @@ -828,7 +828,7 @@ pub fn read_extensions_dir() -> anyhow::Result> for entry in fs::read_dir(format!("{}\\matthias\\extensions", env!("APPDATA")))? { let dir_entry = entry.map_err(|err| Error::msg(err.to_string()))?; - //If the file doesnt have an extension, then we can ingore it + //If the file doesnt have an extension, then we can ignore it if let Some(extension) = dir_entry.path().extension() { //If the file is a lua file if extension.to_string_lossy() == "lua" { diff --git a/mobile/src/app/backend.rs b/mobile/src/app/backend.rs index d0f8fbd..03cd68a 100644 --- a/mobile/src/app/backend.rs +++ b/mobile/src/app/backend.rs @@ -97,7 +97,7 @@ pub struct Application #[serde(skip)] /// This is used to store the connected client profile /// The field get modified by the server_main function (When a server is started this is passed in and is later modified by the server) - /// This might seem very similar to ```self.client_ui.incoming_msg.connected_clients_profile```, but that field is only modifed when connecting to a server, so when we start a server but dont connect to it, we wont have the fields + /// This might seem very similar to ```self.client_ui.incoming_msg.connected_clients_profile```, but that field is only modified when connecting to a server, so when we start a server but dont connect to it, we wont have the fields /// This field gets directly modified by the server thread pub server_connected_clients_profile: Arc>, @@ -164,7 +164,7 @@ pub struct Application /* Client main */ - //We can skip this entry of the table since, we implement Totable separetly + //We can skip this entry of the table since, we implement Totable separately #[table(skip)] pub client_ui: Client, @@ -181,14 +181,14 @@ pub struct Application /// Server connection /// This channel hosts a Client connection and the sync message sent by the server in a String format #[serde(skip)] - pub connection_reciver: Arc>>, + pub connection_receiver: Arc>>, #[serde(skip)] pub connection_sender: mpsc::Sender>, /// Voip (UdpSocket) maker /// When a successful ```Voip``` instance is created it is sent over from the async thread // #[serde(skip)] - // pub voip_connection_reciver: Arc>, + // pub voip_connection_receiver: Arc>, // #[serde(skip)] // pub voip_connection_sender: mpsc::Sender, @@ -205,8 +205,8 @@ pub struct Application pub voip_video_thread: Option<()>, #[serde(skip)] - /// This is what the main thread uses to recive messages from the sync thread - pub server_output_reciver: Arc>>, + /// This is what the main thread uses to receive messages from the sync thread + pub server_output_receiver: Arc>>, #[serde(skip)] /// This is what the sync thread uses to send messages to the main thread @@ -233,12 +233,12 @@ impl Default for Application let (audio_bytes_tx, audio_bytes_rx) = mpsc::channel::>(); - let (connection_sender, connection_reciver) = + let (connection_sender, connection_receiver) = mpsc::channel::>(); - let (server_output_sender, server_output_reciver) = mpsc::channel::>(); + let (server_output_sender, server_output_receiver) = mpsc::channel::>(); - // let (voip_connection_sender, voip_connection_reciver) = mpsc::channel::(); + // let (voip_connection_sender, voip_connection_receiver) = mpsc::channel::(); Self { voip_video_thread: None, @@ -280,7 +280,7 @@ impl Default for Application settings_window: false, //This default value will get overwritten when crating the new server, so we can pass in the token to the thread - //Also, the shutdown reciver is unnecessary in this context because we never use it, I too lazy to delete a few lines instead of writing this whole paragraph >:D + //Also, the shutdown receiver is unnecessary in this context because we never use it, I too lazy to delete a few lines instead of writing this whole paragraph >:D server_shutdown_token: CancellationToken::new(), //thread communication for audio recording @@ -309,17 +309,17 @@ impl Default for Application //Server connection connection_sender, - connection_reciver: Arc::new(connection_reciver), + connection_receiver: Arc::new(connection_receiver), //data sync drx: Arc::new(drx), dtx: Arc::new(dtx), server_sender_thread: None, - server_output_reciver: Arc::new(server_output_reciver), + server_output_receiver: Arc::new(server_output_receiver), server_output_sender, - // voip_connection_reciver: Arc::new(voip_connection_reciver), + // voip_connection_receiver: Arc::new(voip_connection_receiver), // voip_connection_sender, autosync_shutdown_token: CancellationToken::new(), server_connected_clients_profile: Arc::new(DashMap::new()), @@ -644,7 +644,7 @@ fn set_lua_functions( //Include emoji image header file include!(concat!(env!("OUT_DIR"), "\\emoji_header.rs")); -//Define a deafult for the discriminant +//Define a default for the discriminant impl Default for EmojiTypesDiscriminants { fn default() -> Self @@ -766,7 +766,7 @@ pub struct Client ///This checks if the text editor is open or not pub usr_msg_expanded: bool, - ///This is the full address of the destionation a message is supposed to be sent to + ///This is the full address of the destination a message is supposed to be sent to pub send_on_ip: String, ///self.send_on_ip encoded into base64, this is supposedly for ease of use, I dont know why its even here @@ -800,7 +800,7 @@ pub struct Client #[table(save)] pub message_buffer: String, - ///Incoming messages, this is the whole packet which get sent to all the clients, this cointains all the messages, and the info about them + ///Incoming messages, this is the whole packet which get sent to all the clients, this contains all the messages, and the info about them #[serde(skip)] #[table(save)] pub incoming_messages: ServerMaster, @@ -827,7 +827,7 @@ pub struct Client // #[serde(skip)] // pub voip: Option, - /// This entry contains the volume precentage of the microphone, this is modified in the settings + /// This entry contains the volume percentage of the microphone, this is modified in the settings pub microphone_volume: Arc>, } @@ -971,7 +971,7 @@ impl Default for ProfileImage } /// The clients profile, this struct should be sent at a server connection -/// It hold everything which needs to be displayed when viewing someone's profile +/// It hold everythingg which needs to be displayed when viewing someone's profile /// This struct might look similar too ```Register```, but that one contains more information, and is only made to control the ui /// This struct is sent to the server upon successful connection /// If you are searching for the uuid in this struct, please note that most of the times this struct is used in a hashmap where the key is the uuid @@ -1043,13 +1043,13 @@ pub struct ClientNormalMessage // Used for syncing or connecting & disconnecting #[derive(Default, serde::Serialize, serde::Deserialize, Debug, Clone)] -pub struct ClientSnycMessage +pub struct ClientSyncMessage { /// If its None its used for syncing, false: disconnecting, true: connecting /// If you have already registered the client with the server then the true value will be ignored pub sync_attribute: Option, - /// This is used to tell the server how many messages it has to send, if its a None it will automaticly sync all messages + /// This is used to tell the server how many messages it has to send, if its a None it will automatically sync all messages /// This value is ignored if the `sync_attribute` field is Some(_) pub client_message_counter: Option, @@ -1141,7 +1141,7 @@ pub enum ClientMessageType NormalMessage(ClientNormalMessage), ///Used for syncing with client and server - SyncMessage(ClientSnycMessage), + SyncMessage(ClientSyncMessage), Reaction(ReactionType), @@ -1295,7 +1295,7 @@ impl ClientMessage { ClientMessage { replying_to: None, - message_type: ClientMessageType::SyncMessage(ClientSnycMessage { + message_type: ClientMessageType::SyncMessage(ClientSyncMessage { sync_attribute: None, password: password.to_string(), //This value is not ignored in this context @@ -1319,7 +1319,7 @@ impl ClientMessage { ClientMessage { replying_to: None, - message_type: ClientMessageType::SyncMessage(ClientSnycMessage { + message_type: ClientMessageType::SyncMessage(ClientSyncMessage { sync_attribute: Some(ConnectionType::Connect(profile)), password, //If its used for connecting / disconnecting this value is ignored @@ -1333,7 +1333,7 @@ impl ClientMessage } /// If its None its used for syncing, false: disconnecting, true: connecting - /// Please note that its doesnt really matter what we pass in the author becuase the server identifies us based on our ip address + /// Please note that its doesnt really matter what we pass in the author because the server identifies us based on our ip address pub fn construct_disconnection_msg( password: String, author: String, @@ -1342,7 +1342,7 @@ impl ClientMessage { ClientMessage { replying_to: None, - message_type: ClientMessageType::SyncMessage(ClientSnycMessage { + message_type: ClientMessageType::SyncMessage(ClientSyncMessage { sync_attribute: Some(ConnectionType::Disconnect), password, //If its used for connecting / disconnecting this value is ignored @@ -1503,7 +1503,7 @@ impl ClientConnection profile, ); - //Ping server to recive custom uuid, and to also get if server ip is valid + //Ping server to receive custom uuid, and to also get if server ip is valid let client_handle = tokio::net::TcpStream::connect(ip).await?; /*We could return this, this is what the server is supposed to return, when a new user is connected */ @@ -1558,7 +1558,7 @@ impl ClientConnection self.state = ConnectionState::default(); } - /// This function is used to __DISCONNECT__ from a server, with this the ```ClientConnection``` instance is destoryed (reset to its default values) + /// This function is used to __DISCONNECT__ from a server, with this the ```ClientConnection``` instance is destroyed (reset to its default values) pub async fn disconnect( &mut self, author: String, @@ -1613,7 +1613,7 @@ impl ConnectionPair let message_bytes = message_string.as_bytes(); - //Send message lenght to server + //Send message length to server writer .write_all(&(message_bytes.len() as u32).to_be_bytes()) .await?; @@ -1656,8 +1656,8 @@ impl Debug for ConnectionState /* Server. . . - Are used to convert clinet sent messages into a server message, so it can be sent back; - Therefor theyre smaller in size + Are used to convert client sent messages into a server message, so it can be sent back; + Therefor they're smaller in size */ /* @@ -1670,7 +1670,7 @@ impl Debug for ConnectionState */ -///This is what the server sends back (pushes to message vector), when reciving a file +///This is what the server sends back (pushes to message vector), when receiving a file #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerFileUpload { @@ -1698,7 +1698,7 @@ pub enum ServerReplyType Client(ServerClientReply), } -/// This struct holds everything important so the client can save and handle client profiles +/// This struct holds everythingg important so the client can save and handle client profiles #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] pub struct ServerClientReply { @@ -1743,7 +1743,7 @@ pub struct ServerAudioReply pub file_name: String, } -///This is what the server sends back (pushes to message vector), when reciving a normal message +///This is what the server sends back (pushes to message vector), when receiving a normal message #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerNormalMessage { @@ -1761,7 +1761,7 @@ pub struct ServerAudioUpload pub file_name: String, } -///This is what gets sent to a client basicly, and they have to ask for the file when the ui containin this gets rendered +///This is what gets sent to a client basically, and they have to ask for the file when the ui containing this gets rendered #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerImageUpload { @@ -1780,7 +1780,7 @@ pub struct ServerMessageEdit pub new_message: Option, } -/// This struct contains all the necesarily information for the client to update its own message list's reactions +/// This struct contains all the necessarily information for the client to update its own message list's reactions #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerMessageReaction { @@ -1874,12 +1874,12 @@ impl ServerOutput serde_json::to_string(self).unwrap_or_default() } - /// This function converts a client message to a ServerOutput, which gets sent to all the clients (Its basicly a simplified client message) + /// This function converts a client message to a ServerOutput, which gets sent to all the clients (Its basically a simplified client message) pub fn convert_clientmsg_to_servermsg( normal_msg: ClientMessage, // The signature is used to ask bytes from the server, for example in a image message this signature will be used to get the image's byte signature: String, - //Automaticly generated enum by strum + //Automatically generated enum by strum upload_type: ServerMessageTypeDiscriminants, uuid: String, username: String, @@ -1968,7 +1968,7 @@ impl ServerOutput ServerMessageReaction { reaction_type: ReactionType::Add(ClientReaction { emoji_name: message.emoji_name, uuid: message.uuid, message_index: message.message_index }) } }, //The client will decrement its emoji counter - //If the index is 0 the client will automaticly remove that emoji entry + //If the index is 0 the client will automatically remove that emoji entry ReactionType::Remove(message) => { ServerMessageReaction { reaction_type: ReactionType::Remove(ClientReaction { emoji_name: message.emoji_name, uuid: message.uuid, message_index: message.message_index }) } }, @@ -1987,11 +1987,11 @@ impl ServerOutput } /// Used to put all the messages into 1 big pack (Bundling All the ServerOutput-s), Main packet, this gets to all the clients -/// This message type is only used when a client is connecting an has to do a full sync (sending everything to the client all the messages reactions, etc) +/// This message type is only used when a client is connecting an has to do a full sync (sending everythingg to the client all the messages reactions, etc) #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default)] pub struct ServerMaster { - ///All of the messages recived from the server + ///All of the messages received from the server pub message_list: Vec, ///All of the messages' reactions are @@ -2084,11 +2084,11 @@ impl ClientLastSeenMessage #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] pub enum ClientVoipRequest { - /// A voip a call will be automaticly issued if there is no ongoing call - /// The inner value of conncect is the port the Client ```UdpScoket``` is opened on + /// A voip a call will be automatically issued if there is no ongoing call + /// The inner value of conncect is the port the Client ```UdpSocket``` is opened on Connect(u16), - /// The voip call will automaticly stop once there are no connected clients + /// The voip call will automatically stop once there are no connected clients Disconnect, } @@ -2119,7 +2119,7 @@ pub enum ServerVoipRequest ConnectionClosed(ServerVoipClose), } -/// This struct contains all the infomation important for the non connected clients +/// This struct contains all the information important for the non connected clients #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)] pub struct ServerVoipStart { @@ -2154,8 +2154,8 @@ pub struct ServerVoip /// This field contains all the connected client's ```uuid``` with their ```SocketAddr``` pub connected_clients: Arc>, - /// This field contains a ```HashMap``` which pairs the SocketAddr to the client's listening thread's sender (So that the reciver thread can recive the ```Vec``` sent by the sender) - /// The secound part of the tuple is for shutting down the client manager thread, if they disconnect + /// This field contains a ```HashMap``` which pairs the SocketAddr to the client's listening thread's sender (So that the receiver thread can receive the ```Vec``` sent by the sender) + /// The second part of the tuple is for shutting down the client manager thread, if they disconnect pub connected_client_thread_channels: Arc>>, CancellationToken)>>, @@ -2191,7 +2191,7 @@ impl ServerVoip Ok(()) } - /// Remove the ```SocketAddr``` to the ```UDP``` server's destiantions + /// Remove the ```SocketAddr``` to the ```UDP``` server's destinations pub fn disconnect(&self, uuid: String) -> anyhow::Result<()> { self.connected_clients @@ -2232,7 +2232,7 @@ impl UdpMessageType // #[derive(Clone)] // pub struct Voip // { -// /// The clients socket, which theyre listening on for packets (audio, image) +// /// The clients socket, which they're listening on for packets (audio, image) // pub socket: Arc, // /// This handle is used to take pictures with the host's camera @@ -2248,7 +2248,7 @@ impl UdpMessageType // impl Voip // { -// /// This function creates a new ```Voip``` instance containing a ```UdpSocket``` and an authentication from the server +// /// This function creates a new ```Voip``` instance containingg a ```UdpSocket``` and an authentication from the server // /// Note that this doesnt contain the camera_handle, if you want to add it use the ```add_video_handle()``` function // pub async fn new() -> anyhow::Result // { @@ -2336,7 +2336,7 @@ impl UdpMessageType // } // /// This function sends the audio and the uuid in one message, this packet is encrypted (The audio's bytes is appended to the uuid's) -// /// Any lenght of audio can be sent because the header is included with the packet +// /// Any length of audio can be sent because the header is included with the packet // pub async fn send_audio( // &self, // uuid: String, @@ -2354,7 +2354,7 @@ impl UdpMessageType // } // /// This function sends bytes on the UdpSocket the instance contains -// /// The bytes passed to this function are automaticly encrypted by the provided encrytion key +// /// The bytes passed to this function are automatically encrypted by the provided encryption key // /// Message type appends a set isize to the message so that the server can identify each message // async fn send_bytes( // &self, @@ -2369,23 +2369,23 @@ impl UdpMessageType // //Encrypt message // let mut encrypted_message = encrypt_aes256_bytes(&bytes, encryption_key)?; -// //Get message lenght -// let mut message_lenght_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); +// //Get message length +// let mut message_length_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); -// //Append message to message lenght -// message_lenght_in_bytes.append(&mut encrypted_message); +// //Append message to message length +// message_length_in_bytes.append(&mut encrypted_message); -// //Check for packet lenght overflow -// let bytes_lenght = message_lenght_in_bytes.len(); +// //Check for packet length overflow +// let bytes_length = message_length_in_bytes.len(); -// if bytes_lenght > 65535 { +// if bytes_length > 65535 { // bail!(format!( -// "Udp packet lenght overflow, with lenght of {bytes_lenght}" +// "Udp packet length overflow, with length of {bytes_length}" // )) // } // //Send bytes -// self.socket.send(&message_lenght_in_bytes).await?; +// self.socket.send(&message_length_in_bytes).await?; // Ok(()) // } @@ -2436,7 +2436,7 @@ impl UdpMessageType // /// __Image message contents:__ // /// - ```[len - 64..]``` = Contains the hash (sha256 hash) of the image part we are sending // /// - ```[..len - 64]``` = Contains the image part we are sending (JPEG image) -// /// - **The hash lenght is 64 bytes.** +// /// - **The hash length is 64 bytes.** // /// - **The identificator is 64 bytes.** // /// - **The uuid is 36 bytes.** // async fn send_image_parts( @@ -2666,7 +2666,7 @@ pub fn ipv6_get() -> Result /// Account management /// This might look similar to ```ClientProfile``` -/// struct containing a new user's info, when serialized / deserialized it gets encrypted or decrypted +/// struct containingg a new user's info, when serialized / deserialized it gets encrypted or decrypted #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default, ToTable)] pub struct UserInformation { @@ -2715,13 +2715,13 @@ impl UserInformation } } - /// Automaticly check hash with argon2 encrypted password (from the file) + /// Automatically check hash with argon2 encrypted password (from the file) pub fn verify_password(&self, password: String) -> bool { pass_hash_match(password, self.password.clone()) } - /// This serializer function automaticly encrypts the struct with the *encrypt_aes256* fn to string + /// This serializer function automatically encrypts the struct with the *encrypt_aes256* fn to string pub fn serialize(&self) -> anyhow::Result { //Hash password so it can be used to encrypt a file @@ -2731,7 +2731,7 @@ impl UserInformation encrypt_aes256(serde_json::to_string(&self)?, &encryption_key) } - /// This deserializer function automaticly decrypts the string the *encrypt_aes256* fn to Self + /// This deserializer function automatically decrypts the string the *encrypt_aes256* fn to Self pub fn deserialize(serialized_struct: &str, password: String) -> anyhow::Result { let hashed_password = sha256::digest(password); @@ -2993,9 +2993,9 @@ where } } -/// This function fetches the incoming full message's lenght (it reads the 4 bytes and creates an u32 number from them, which it returns) +/// This function fetches the incoming full message's length (it reads the 4 bytes and creates an u32 number from them, which it returns) /// afaik this function blocks until it can read the first 4 bytes out of the ```reader``` -pub async fn fetch_incoming_message_lenght(reader: &mut T) -> anyhow::Result +pub async fn fetch_incoming_message_length(reader: &mut T) -> anyhow::Result where T: AsyncReadExt + Unpin + AsyncRead, { @@ -3098,7 +3098,7 @@ pub fn parse_incoming_message(rhs: String) -> Vec //The regexes we use to capture important information let regexes = vec![ //This regex captures newlines - //It doesnt matter when we scan for newlines as theyre not affected by anything + //It doesnt matter when we scan for newlines as they're not affected by anything ( MessageDisplayDiscriminants::NewLine, Regex::new(r"\n").unwrap(), @@ -3251,7 +3251,7 @@ fn filter_string( regexes: &Vec<(MessageDisplayDiscriminants, Regex)>, ) -> Vec { - //We clone the message we need to examine, this value will be modifed by the regexes (Deleting the captured information) + //We clone the message we need to examine, this value will be modified by the regexes (Deleting the captured information) let mut match_message_part = message_part.clone(); //We back up all the matches from the string into this buffer @@ -3369,7 +3369,7 @@ pub enum MessageDisplay #[derive(PartialEq)] pub struct EmojiDisplay { - /// The name of the emoji wanting to be displayed, we make sure to load in all the emojies into the egui buffer when theyre displayed + /// The name of the emoji wanting to be displayed, we make sure to load in all the emojies into the egui buffer when they're displayed pub name: String, } diff --git a/mobile/src/app/client.rs b/mobile/src/app/client.rs index 6255c7c..136c8c3 100644 --- a/mobile/src/app/client.rs +++ b/mobile/src/app/client.rs @@ -28,11 +28,11 @@ pub const UUID_BYTE_OFFSET: usize = 64 + 36; /// This value is the start of the identificator bytes, the end is the end of the message itself pub const IDENTIFICATOR_BYTE_OFFSET: usize = 64; -/// This is the byte lenght of the uuid's text representation (utf8) -pub const UUID_STRING_BYTE_LENGHT: usize = 36; +/// This is the byte length of the uuid's text representation (utf8) +pub const UUID_STRING_BYTE_LENGTH: usize = 36; -use super::backend::{fetch_incoming_message_lenght, get_image_header}; -pub const VOIP_PACKET_BUFFER_LENGHT_MS: usize = 35; +use super::backend::{fetch_incoming_message_length, get_image_header}; +pub const VOIP_PACKET_BUFFER_LENGTH_MS: usize = 35; use std::io::{BufReader, Cursor}; @@ -48,7 +48,7 @@ pub async fn connect_to_server( let message_bytes = message_as_string.as_bytes(); - //Send message lenght to server + //Send message length to server connection .write_all(&(message_bytes.len() as u32).to_be_bytes()) .await?; @@ -56,11 +56,11 @@ pub async fn connect_to_server( //Send message to server connection.write_all(message_bytes).await?; - //Read the server reply lenght + //Read the server reply length //blocks here for unknown reason - let msg_len = fetch_incoming_message_lenght(&mut connection).await?; + let msg_len = fetch_incoming_message_length(&mut connection).await?; - //Create buffer with said lenght + //Create buffer with said length let mut msg_buffer = vec![0; msg_len as usize]; //Read the server reply @@ -80,10 +80,10 @@ impl ServerReply { let reader = &mut *self.reader.lock().await; - // Read the server reply lenght - let msg_len = fetch_incoming_message_lenght(reader).await?; + // Read the server reply length + let msg_len = fetch_incoming_message_length(reader).await?; - //Create buffer with said lenght + //Create buffer with said length let mut msg_buffer = vec![0; msg_len as usize]; //Read the server reply @@ -116,8 +116,8 @@ impl Application // let voice_recording_shutdown = self.voip_video_shutdown_token.clone(); // self.voip_thread.get_or_insert_with(|| { - // let reciver_socket_part = voip.socket.clone(); - // let microphone_precentage = self.client_ui.microphone_volume.clone(); + // let receiver_socket_part = voip.socket.clone(); + // let microphone_percentage = self.client_ui.microphone_volume.clone(); // let (tx, rx) = mpsc::channel::<()>(); @@ -127,21 +127,21 @@ impl Application // //Sender thread // tokio::spawn(async move { - // //This variable is notifed when the Mutex is set to true, when the audio_buffer lenght reaches ```VOIP_PACKET_BUFFER_LENGHT``` and is resetted when the packet is sent + // //This variable is notified when the Mutex is set to true, when the audio_buffer length reaches ```VOIP_PACKET_BUFFER_LENGTH``` and is reset when the packet is sent // let voip_audio_buffer: Arc>> = Arc::new(std::sync::Mutex::new(VecDeque::new())); - // //Conect socket to destination + // //Connect socket to destination // voip.socket.connect(destination).await.unwrap(); // //Start audio recorder - // let recording_handle = record_audio_with_interrupt(rx, *microphone_precentage.lock().unwrap(), voip_audio_buffer.clone(), enable_microphone.clone()).unwrap(); + // let recording_handle = record_audio_with_interrupt(rx, *microphone_percentage.lock().unwrap(), voip_audio_buffer.clone(), enable_microphone.clone()).unwrap(); - // //We can just send it becasue we have already set the default destination address + // //We can just send it because we have already set the default destination address // loop { // select! { // //Wait until we should send the buffer // //Record 35ms of audio, send it to the server - // _ = tokio::time::sleep(Duration::from_millis(VOIP_PACKET_BUFFER_LENGHT_MS as u64)) => { + // _ = tokio::time::sleep(Duration::from_millis(VOIP_PACKET_BUFFER_LENGTH_MS as u64)) => { // //We create this scope to tell the compiler the recording handle wont be sent across any awaits // let playbackable_audio: Vec = { // //Lock handle @@ -150,7 +150,7 @@ impl Application // let playbackable_audio: Vec = create_wav_file( // recording_handle.clone().into() // ); - // //Clear out buffer, make the capacity remain (We creted this VecDeque with said default capacity) + // //Clear out buffer, make the capacity remain (We created this VecDeque with said default capacity) // recording_handle.clear(); // //Return wav bytes // playbackable_audio @@ -177,7 +177,7 @@ impl Application // let sink = Arc::new(rodio::Sink::try_new(&self.client_ui.audio_playback.stream_handle).unwrap()); // let decryption_key = self.client_connection.client_secret.clone(); - // //Reciver thread + // //Receiver thread // tokio::spawn(async move { // let ctx_clone = ctx.clone(); @@ -192,9 +192,9 @@ impl Application // break; // }, - // //Recive bytes - // _recived_bytes_count = async { - // match recive_server_relay(reciver_socket_part.clone(), &decryption_key, sink.clone(), image_buffer.clone(), &ctx_clone).await { + // //Receive bytes + // _received_bytes_count = async { + // match receive_server_relay(receiver_socket_part.clone(), &decryption_key, sink.clone(), image_buffer.clone(), &ctx_clone).await { // Ok(_) => (), // Err(err) => { // tracing::error!("{}", err); @@ -251,7 +251,7 @@ impl Application // } // } - ///This functions is used for clients to recive messages from the server (this doesnt not check validity of the order of the messages, altough this may not be needed as tcp takes care of this) + ///This functions is used for clients to receive messages from the server (this doesnt not check validity of the order of the messages, although this may not be needed as tcp takes care of this) pub fn client_recv(&mut self, ctx: &egui::Context) { //This should only run when the connection is valid @@ -285,14 +285,14 @@ impl Application }; select! { - //Recive input from main thread to shutdown + //Receive input from main thread to shutdown _ = shutdown_token.cancelled() => { break; }, reply = ServerReply::wait_for_response(server_reply_handle) => { match reply { - //If we have a reponse from the server + //If we have a response from the server Ok(response) => { //Check for special cases like server disconnecting if response == "Server disconnecting from client." { @@ -301,14 +301,14 @@ impl Application //Request repaint context_clone.request_repaint(); - //Send to reciver - sender_clone.send(Some(response)).expect("Error occured when trying to send message, after reciving message from client"); + //Send to receiver + sender_clone.send(Some(response)).expect("Error occurred when trying to send message, after receiving message from client"); }, Err(err) => { tracing::error!("{}", err); - eprintln!("client.rs\nError occured when the client tried to recive a message from the server: {err}"); - eprintln!("Early end of file error is a normal occurence after disconnecting"); + eprintln!("client.rs\nError occurred when the client tried to receive a message from the server: {err}"); + eprintln!("Early end of file error is a normal occurrence after disconnecting"); //Avoid panicking when trying to display a Notification //This is very rare but can still happen display_error_message(err, toasts); @@ -355,7 +355,7 @@ impl Application inner.last_seen_message_index = Some(index); //We only send a sync packet if we need to - //We only have to send the sync message, since in the other thread we are reciving every message sent to us + //We only have to send the sync message, since in the other thread we are receiving every message sent to us match connection_pair.send_message(message.clone()).await { Ok(_) => {}, Err(err) => { @@ -376,9 +376,9 @@ impl Application }); }); - //Try to recive the threads messages + //Try to receive the threads messages //Get sent to the channel to be displayed, if the connections errors out, do nothing lol cuz its prolly cuz the sender hadnt done anything - match self.server_output_reciver.try_recv() { + match self.server_output_receiver.try_recv() { Ok(msg) => { //show messages if let Some(message) = msg { @@ -562,7 +562,7 @@ impl Application //Callback self.client_ui.extension.event_call_extensions( - crate::app::lua::EventCall::OnChatRecive, + crate::app::lua::EventCall::OnChatReceive, &self.lua, Some(msg.message._struct_into_string()), ); @@ -715,7 +715,7 @@ impl Application // wtf? investigate //Then the thread got an error, we should reset the state - tracing::error!("Client reciver or sync thread panicked"); + tracing::error!("Client receiver or sync thread panicked"); } }, Err(_err) => { @@ -726,12 +726,12 @@ impl Application } } -/// Recives packets on the given UdpSocket, messages are decrypted with the decrpytion key -/// Automaticly appends the decrypted audio bytes to the ```Sink``` if its an uadio packet -/// I might rework this function so that we can see whos talking based on uuid -async fn recive_server_relay( +/// Receives packets on the given UdpSocket, messages are decrypted with the decrpytion key +/// Automatically appends the decrypted audio bytes to the ```Sink``` if its an uadio packet +/// I might rework this function so that we can see who is talking based on uuid +async fn receive_server_relay( //Socket this function is Listening on - reciver_socket_part: Arc, + receiver_socket_part: Arc, //Decryption key decryption_key: &[u8], //The sink its appending the bytes to @@ -745,20 +745,20 @@ async fn recive_server_relay( //Create buffer for header, this is the size of the maximum udp packet so no error will appear let mut header_buf = vec![0; 65536]; - //Recive header size - reciver_socket_part + //Receive header size + receiver_socket_part .peek_from(&mut header_buf) .await .unwrap(); - //Get message lenght - let header_lenght = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); + //Get message length + let header_length = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); - //Create body according to message size indicated by the header, make sure to add 4 to the byte lenght because we peeked the ehader thus we didnt remove the bytes from the buffer - let mut body_buf = vec![0; (header_lenght + 4) as usize]; + //Create body according to message size indicated by the header, make sure to add 4 to the byte length because we peeked the ehader thus we didnt remove the bytes from the buffer + let mut body_buf = vec![0; (header_length + 4) as usize]; - //Recive the whole message - reciver_socket_part.recv(&mut body_buf).await.unwrap(); + //Receive the whole message + receiver_socket_part.recv(&mut body_buf).await.unwrap(); //Decrypt message let mut decrypted_bytes = decrypt_aes256_bytes( @@ -774,7 +774,7 @@ async fn recive_server_relay( //The generated uuids are always a set amount of bytes, so we can safely extract them, and we know that the the left over bytes are audio let uuid = String::from_utf8( decrypted_bytes - .drain(decrypted_bytes.len() - UUID_STRING_BYTE_LENGHT..) + .drain(decrypted_bytes.len() - UUID_STRING_BYTE_LENGTH..) .collect(), )?; @@ -782,7 +782,7 @@ async fn recive_server_relay( uuid::Uuid::parse_str(&uuid) .map_err(|err| anyhow::Error::msg(format!("Error: {}, in uuid {}", err, uuid)))?; - //Play recived bytes + //Play received bytes sink.append(rodio::Decoder::new(BufReader::new(Cursor::new( decrypted_bytes, )))?); diff --git a/mobile/src/app/lua.rs b/mobile/src/app/lua.rs index d2d2ede..e298389 100644 --- a/mobile/src/app/lua.rs +++ b/mobile/src/app/lua.rs @@ -106,7 +106,7 @@ pub enum LuaOutput /// Standard output from the lua runtime Standard(String), - /// Displays useful information like a file got modifed (This message will only be added from the rust runtime, for example when saving a file) + /// Displays useful information like a file got modified (This message will only be added from the rust runtime, for example when saving a file) Info(String), } @@ -117,7 +117,7 @@ pub struct Extension pub extension_list: Vec, #[serde(skip)] - /// This list contins all the output from the extensions, panics are logged and stdouts are also logged here as Standard() + /// This list contains all the output from the extensions, panics are logged and stdouts are also logged here as Standard() pub output: Arc>>, pub output_rect: Rect, @@ -131,7 +131,7 @@ pub struct Extension pub enum EventCall { /// Triggered when sending a message - /// If this Event is invoked the function will recive what the user has sent, this is optional to "recive" + /// If this Event is invoked the function will receive what the user has sent, this is optional to "receive" /// ``` lua /// function OnChatSend(message) /// --Do anything with the message @@ -142,10 +142,10 @@ pub enum EventCall /// ``` OnChatSend, - /// Triggered when reciving a message - OnChatRecive, + /// Triggered when receiving a message + OnChatReceive, - /// Triggered when reciving a message from the server + /// Triggered when receiving a message from the server /// This is unused and will be reused for something else in the future #[allow(dead_code)] OnServerChatReceive, @@ -153,7 +153,7 @@ pub enum EventCall /// Triggered when sending a group voice call request OnCallSend, - /// Triggered when reciving a group voice call, + /// Triggered when receiving a group voice call, OnCallReceive, /// Triggered every draw of the ui diff --git a/mobile/src/app/server.rs b/mobile/src/app/server.rs index 6294524..c7d45f1 100644 --- a/mobile/src/app/server.rs +++ b/mobile/src/app/server.rs @@ -16,7 +16,7 @@ use indexmap::IndexMap; use tokio_util::sync::CancellationToken; use super::backend::{ - encrypt, encrypt_aes256, fetch_incoming_message_lenght, ClientLastSeenMessage, + encrypt, encrypt_aes256, fetch_incoming_message_length, ClientLastSeenMessage, ClientMessageType, ClientProfile, ConnectedClient, ConnectionType, MessageReaction, Reaction, ReactionType, ServerClientReply, ServerMessageType, ServerMessageTypeDiscriminants::{ @@ -115,7 +115,7 @@ pub struct SharedFields pub async fn server_main( port: String, password: String, - //This signals all the client recivers to be shut down + //This signals all the client receivers to be shut down cancellation_token: CancellationToken, connected_clients_profile_list: Arc>, //We pass in ctx so we can request repaint when someone connects @@ -156,7 +156,7 @@ pub async fn server_main( } }; - //split client stream, so we will be able to store these seperately + //split client stream, so we will be able to store these separately let (reader, writer) = stream.into_split(); //We need to clone here too, to pass it into the listener thread @@ -249,7 +249,7 @@ fn spawn_client_reader( break; } - msg = recive_message(reader.clone()) => { + msg = receive_message(reader.clone()) => { msg? } }; @@ -274,11 +274,11 @@ fn spawn_client_reader( } #[inline] -async fn recive_message(reader: Arc>) -> Result +async fn receive_message(reader: Arc>) -> Result { let mut reader = reader.lock().await; - let incoming_message_len = fetch_incoming_message_lenght(&mut *reader).await?; + let incoming_message_len = fetch_incoming_message_length(&mut *reader).await?; let mut message_buffer: Vec = vec![0; incoming_message_len as usize]; @@ -319,15 +319,15 @@ async fn sync_message_with_clients( //Encrypt string let encrypted_string = encrypt_aes256(server_master_string, &key).unwrap(); - //Send message lenght - let message_lenght = TryInto::::try_into(encrypted_string.as_bytes().len())?; + //Send message length + let message_length = TryInto::::try_into(encrypted_string.as_bytes().len())?; for client in connected_clients_locked.iter_mut() { if let Some(client_handle) = &mut client.handle { let mut client_handle = client_handle.lock().await; client_handle - .write_all(&message_lenght.to_be_bytes()) + .write_all(&message_length.to_be_bytes()) .await?; //Send actual message @@ -346,7 +346,7 @@ where { let message_bytes = message.as_bytes(); - //Send message lenght + //Send message length writer .write_all(&(message_bytes.len() as u32).to_be_bytes()) .await?; @@ -362,7 +362,7 @@ pub fn create_client_voip_manager( voip: ServerVoip, shutdown_token: CancellationToken, key: [u8; 32], - mut reciver: Receiver>, + mut receiver: Receiver>, #[allow(unused_variables)] listening_to: SocketAddr, uuid: String, ) @@ -386,14 +386,14 @@ pub fn create_client_voip_manager( break; }, - //recive_message lenght by reading its first 4 bytes - recived_bytes = reciver.recv() => { - let recived_bytes = recived_bytes.unwrap(); + //receive_message length by reading its first 4 bytes + received_bytes = receiver.recv() => { + let received_bytes = received_bytes.unwrap(); //Decrypt message // [. . . . . .4][4 . . . . len - 4][len - 4..] - // PACKET LENGHT MESSAGE MSG TYPE - let mut decrypted_bytes = decrypt_aes256_bytes(&recived_bytes, &key).unwrap(); + // PACKET LENGTH MESSAGE MSG TYPE + let mut decrypted_bytes = decrypt_aes256_bytes(&received_bytes, &key).unwrap(); let message_type_bytes: Vec = decrypted_bytes.drain(decrypted_bytes.len() - 4..).collect(); @@ -430,13 +430,13 @@ pub fn create_client_voip_manager( let mut encrypted_packet = encrypt_aes256_bytes(&decrypted_bytes, &key).unwrap(); //Get encrypted packet size - let mut message_lenght_header = (encrypted_packet.len() as u32).to_be_bytes().to_vec(); + let mut message_length_header = (encrypted_packet.len() as u32).to_be_bytes().to_vec(); //Append message to header - message_lenght_header.append(&mut encrypted_packet); + message_length_header.append(&mut encrypted_packet); - //Send the header indicating message lenght and send the whole message appended to it - socket.send_to(&message_lenght_header, connected_socket_addr).await.unwrap(); + //Send the header indicating message length and send the whole message appended to it + socket.send_to(&message_length_header, connected_socket_addr).await.unwrap(); } }); } @@ -565,23 +565,23 @@ async fn send_bytes( //Encrypt message let mut encrypted_message = encrypt_aes256_bytes(&bytes, encryption_key)?; - //Get message lenght - let mut message_lenght_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); + //Get message length + let mut message_length_in_bytes = (encrypted_message.len() as u32).to_be_bytes().to_vec(); - //Append message to message lenght - message_lenght_in_bytes.append(&mut encrypted_message); + //Append message to message length + message_length_in_bytes.append(&mut encrypted_message); - //Check for packet lenght overflow - let bytes_lenght = message_lenght_in_bytes.len(); + //Check for packet length overflow + let bytes_length = message_length_in_bytes.len(); - if bytes_lenght > 65536 { + if bytes_length > 65536 { bail!(format!( - "Udp packet lenght overflow, with lenght of {bytes_lenght}" + "Udp packet length overflow, with length of {bytes_length}" )) } //Send bytes - socket.send_to(&message_lenght_in_bytes, send_to).await?; + socket.send_to(&message_length_in_bytes, send_to).await?; Ok(()) } @@ -591,7 +591,7 @@ async fn send_bytes( /// - ```[len - 64 - 36.. len - 64]``` = Contains the UUID of the author who has sent the message /// - ```[..len - 64 - 64 - 36]``` = Contains the image part we are sending (JPEG image) /// - ```[len - 64..]``` = Contains the identificator of the part we are sending -/// - **The hash lenght is 64 bytes.** +/// - **The hash length is 64 bytes.** /// - **The identificator is 64 bytes.** /// - **The uuid is 36 bytes.** async fn send_image_parts( @@ -636,7 +636,7 @@ async fn send_image_parts( impl MessageService { /// The result returned by this function may be a real error, or an error constructed on purpose so that the thread call this function gets shut down. - /// When experiening errors, make sure to check the error message as it may be on purpose + /// When experiencing errors, make sure to check the error message as it may be on purpose #[inline] async fn message_main( &mut self, @@ -650,7 +650,7 @@ impl MessageService let req: ClientMessage = req_result.unwrap(); //If its a Client reaction or a message edit we shouldnt allocate more MessageReactions, since those are not actual messages - //HOWEVER, if theyre client connection or disconnection messages a reaction should be allocated because people can react to those + //HOWEVER, if they're client connection or disconnection messages a reaction should be allocated because people can react to those if !(matches!(&req.message_type, ClientReaction(_)) || matches!(&req.message_type, MessageEdit(_)) || { @@ -884,20 +884,20 @@ impl MessageService //Wait until we get a new message or until the thread token gets cancelled select! { - //Wait until we recive a new message - //Recive header size + //Wait until we receive a new message + //Receive header size _ = socket.peek_from(&mut header_buf) => { - //Get message lenght - let header_lenght = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); + //Get message length + let header_length = u32::from_be_bytes(header_buf[..4].try_into().unwrap()); - //Create body according to message size indicated by the header, make sure to add 4 to the byte lenght because we peeked the header thus we didnt remove the bytes from the buffer - let mut body_buf = vec![0; header_lenght as usize + 4]; + //Create body according to message size indicated by the header, make sure to add 4 to the byte length because we peeked the header thus we didnt remove the bytes from the buffer + let mut body_buf = vec![0; header_length as usize + 4]; match socket.recv_from(&mut body_buf).await { Ok((_, socket_addr)) => { match connected_clients.get(&socket_addr) { Some(client) => { - //We send everythin from the 4th byte since that is the part of the header + //We send everything from the 4th byte since that is the part of the header //We dont care about the result since it will panic when the thread is shut down let _ = client.0.send(body_buf[4..].to_vec()).await; }, @@ -928,7 +928,7 @@ impl MessageService .get(&socket_addr) .is_none() { - let (sender, reciver) = mpsc::channel::>(255); + let (sender, receiver) = mpsc::channel::>(255); //Create cancellation token for client let client_manager_cancellation_token = @@ -939,7 +939,7 @@ impl MessageService voip.clone(), client_manager_cancellation_token.clone(), self.decryption_key, - reciver, + receiver, socket_addr, req.uuid.clone(), ); @@ -1142,7 +1142,7 @@ impl MessageService match &req.message_type { FileRequestType(_) => unreachable!(), FileUpload(inner) => { - //We should match the upload type more specificly + //We should match the upload type more specifically match inner.extension.clone().unwrap_or_default().as_str() { "png" | "jpeg" | "bmp" | "tiff" | "webp" => Image, "wav" | "mp3" | "m4a" => Audio, @@ -1331,8 +1331,8 @@ impl MessageService )); } - /// This function returns a message containing a full sync (all the messages etc) - /// It reutrns a ```ServerMaster``` converted to an encrypted string + /// This function returns a message containingg a full sync (all the messages etc) + /// It returns a ```ServerMaster``` converted to an encrypted string async fn full_sync_client(&self) -> anyhow::Result { //Construct reply @@ -1401,9 +1401,9 @@ impl MessageService } }; } - async fn recive_file(&self, request: ClientMessage, req: &ClientFileUploadStruct) + async fn receive_file(&self, request: ClientMessage, req: &ClientFileUploadStruct) { - //We should retrive the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it + //We should retrieve the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it let file_author = self .connected_clients_profile .lock() @@ -1472,9 +1472,9 @@ impl MessageService { fs::read(&*self.image_list.get(&signature).unwrap()).unwrap_or_default() } - async fn recive_image(&self, req: ClientMessage, img: &ClientFileUploadStruct) + async fn receive_image(&self, req: ClientMessage, img: &ClientFileUploadStruct) { - //We should retrive the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it + //We should retrieve the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it let file_author = self .connected_clients_profile .lock() @@ -1530,9 +1530,9 @@ impl MessageService }, } } - async fn recive_audio(&self, req: ClientMessage, audio: &ClientFileUploadStruct) + async fn receive_audio(&self, req: ClientMessage, audio: &ClientFileUploadStruct) { - //We should retrive the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it + //We should retrieve the username of the cient who has sent this, we clone it so that the mutex is dropped, thus allowing other threads to lock it let file_author = self .connected_clients_profile .lock() @@ -1658,12 +1658,12 @@ impl MessageService //Create server folder, so we will have a place to put our uploads let _ = fs::create_dir(format!("{}\\matthias\\Server", env!("APPDATA"))); - //Pattern match on upload tpye so we know how to handle the specific request + //Pattern match on upload type so we know how to handle the specific request match upload_type.extension.clone().unwrap_or_default().as_str() { - "png" | "jpeg" | "bmp" | "tiff" | "webp" => self.recive_image(req, upload_type).await, - "wav" | "mp3" | "m4a" => self.recive_audio(req, upload_type).await, + "png" | "jpeg" | "bmp" | "tiff" | "webp" => self.receive_image(req, upload_type).await, + "wav" | "mp3" | "m4a" => self.receive_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, + _ => self.receive_file(req, upload_type).await, } } diff --git a/mobile/src/app/ui/client.rs b/mobile/src/app/ui/client.rs index a619085..9024228 100644 --- a/mobile/src/app/ui/client.rs +++ b/mobile/src/app/ui/client.rs @@ -187,7 +187,7 @@ impl Application ); }); - //We have to render the message area after everything else, because then we will be using the area whats left of the ui + //We have to render the message area after everythingg else, because then we will be using the area whats left of the ui //msg_area egui::CentralPanel::default().show(ctx, |ui| { //Drop file warning @@ -310,7 +310,7 @@ impl Application }); ui.separator(); - //For the has_search logic to work and for the rust compiler not to underline everything + //For the has_search logic to work and for the rust compiler not to underline everythingg egui::ScrollArea::new([true, true]).auto_shrink([false, true]).show(ui, |ui|{ ui.allocate_ui(ui.available_size(), |ui|{ let mut has_search = false; @@ -397,7 +397,7 @@ impl Application let group = ui.group(|ui|{ ui.label(RichText::from(message.author.to_string()).size(self.font_size / 1.3).color(Color32::WHITE)); - //This button shouldnt actually do anything becuase when this message group gets clicked it throws you to the message + //This button shouldnt actually do anything because when this message group gets clicked it throws you to the message if ui.small_button(inner_message.file_name.to_string()).clicked() { self.client_ui.scroll_to_message_index = Some(index) }; @@ -412,12 +412,12 @@ impl Application has_search = true; } - /* Inner value shouldnt actaully be used since its only used for asking for a file, and to stay compact i wont implement image displaying in search mode */ + /* Inner value shouldnt actually be used since its only used for asking for a file, and to stay compact i wont implement image displaying in search mode */ if let ServerMessageType::Image( _ ) = &message.message_type { let group = ui.group(|ui|{ ui.label(RichText::from(message.author.to_string()).size(self.font_size / 1.3).color(Color32::WHITE)); - //This button shouldnt actually do anything becuase when this message group gets clicked it throws you to the message + //This button shouldnt actually do anything because when this message group gets clicked it throws you to the message if ui.small_button("Image").clicked() { self.client_ui.scroll_to_message_index = Some(index) }; @@ -436,7 +436,7 @@ impl Application let group = ui.group(|ui|{ ui.label(RichText::from(message.author.to_string()).size(self.font_size / 1.3).color(Color32::WHITE)); - //This button shouldnt actually do anything becuase when this message group gets clicked it throws you to the message + //This button shouldnt actually do anything because when this message group gets clicked it throws you to the message if ui.small_button("Audio").clicked() { self.client_ui.scroll_to_message_index = Some(index) }; @@ -495,7 +495,7 @@ impl Application }); }); - //Server reciver + //Server receiver self.client_recv(ctx); //Client voip thread managemant @@ -518,7 +518,7 @@ impl Application match self.audio_save_rx.try_recv() { Ok((sink, cursor, index, path_to_audio)) => { - //Check if the request was unsuccesful, so we can reset the states + //Check if the request was unsuccessful, so we can reset the states if sink.is_none() { //Reset state self.client_ui.audio_playback.settings_list[index].is_loading = false; diff --git a/mobile/src/app/ui/client_ui/message_instances/message_display.rs b/mobile/src/app/ui/client_ui/message_instances/message_display.rs index b25e146..90613cf 100644 --- a/mobile/src/app/ui/client_ui/message_instances/message_display.rs +++ b/mobile/src/app/ui/client_ui/message_instances/message_display.rs @@ -115,7 +115,7 @@ impl Application ClientMessage::construct_image_request_msg(picture.signature.clone(), uuid); let connection = self.client_connection.clone(); tokio::spawn(async move { - //We only have to send the message it will get recived in a diff place + //We only have to send the message it will get received in a diff place connection.clone().send_message(message).await.unwrap(); }); } @@ -370,7 +370,7 @@ impl Application .get(client_uuid.as_str()) { Some(profile) => profile, - //If we dont have the profile we ask for it then return to avoid panicing + //If we dont have the profile we ask for it then return to avoid panicking None => { self.request_client(client_uuid.to_string()); @@ -396,7 +396,7 @@ impl Application .get(client_uuid.as_str()) { Some(profile) => profile, - //If we dont have the profile we ask for it then return to avoid panicing + //If we dont have the profile we ask for it then return to avoid panicking None => { self.request_client(client_uuid.to_string()); diff --git a/mobile/src/app/ui/client_ui/message_instances/message_main.rs b/mobile/src/app/ui/client_ui/message_instances/message_main.rs index 21d2b6f..36ac1a1 100644 --- a/mobile/src/app/ui/client_ui/message_instances/message_main.rs +++ b/mobile/src/app/ui/client_ui/message_instances/message_main.rs @@ -196,7 +196,7 @@ impl Application egui::ScrollArea::horizontal() .id_source( - /* Autoassign id's to interated scroll widgets */ ui.next_auto_id(), + /* Autoassign id's to integrated scroll widgets */ ui.next_auto_id(), ) .max_height(self.font_size) .show(ui, |ui| { @@ -285,14 +285,14 @@ impl Application } }); - //Back up reponse of message group, so we can scroll to it later if the user thinks like it + //Back up response of message group, so we can scroll to it later if the user thinks like it message_instances.push(message_group.response.clone()); message_group.response.context_menu(|ui| { let profile_menu_button = ui.menu_button("Profile", |ui| { //Check if the message was sent by the server, create a custom profile for it if item.uuid == SERVER_UUID { - //Add verification or somthing like that + //Add verification or something like that ui.allocate_ui(vec2(ui.available_width(), 25.), |ui| { ui.horizontal_centered(|ui| { ui.label("This message was sent by the host server"); @@ -379,7 +379,7 @@ impl Application if item.uuid == self.opened_user_information.uuid && item.message_type != ServerMessageType::Deleted { - //We should only display the `edit` button if its anormal message thus its editable + //We should only display the `edit` button if its abnormal message thus its editable if let ServerMessageType::Normal(inner) = &item.message_type { if ui .add(Button::image_and_text( diff --git a/mobile/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs b/mobile/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs index cec57d3..9e734a6 100644 --- a/mobile/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs +++ b/mobile/src/app/ui/client_ui/widgets/emoji_tray/emoji.rs @@ -24,7 +24,7 @@ impl ToString for EmojiTypes impl backend::Application { - /// We return the name of the emoji selected, if none was selected in that frame we reutrn None + /// We return the name of the emoji selected, if none was selected in that frame we return None pub fn draw_emoji_selector(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) -> Option { @@ -242,7 +242,7 @@ impl backend::Application } } -/// This will display the emoji under the given name, if it is not found in the egui image buffer it will automaticly load it +/// This will display the emoji under the given name, if it is not found in the egui image buffer it will automatically load it pub fn display_emoji(ctx: &egui::Context, emoji_name: &str, ui: &mut egui::Ui) -> Option { match ctx.try_load_bytes(&format!("bytes://{}", emoji_name)) { diff --git a/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs b/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs index bfab48d..c0c8742 100644 --- a/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs +++ b/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs @@ -44,7 +44,7 @@ impl Application { ctx.input_mut(|reader| { //Check if this key was pressed - //We will not consume this key since its not sure we can acually edit the message + //We will not consume this key since its not sure we can actually edit the message if reader.key_pressed(Key::ArrowUp) { //Iter over all the messages so we will get the latest message sent by us for (idx, message) in self @@ -145,15 +145,15 @@ impl Application //We will reconstruct the buffer let mut split = user_message_clone.split('@').collect::>(); - //We just pattern match for the sake of never panicing, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) + //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last_mut() { - //If the last slice of the string (split by @) doesnt contain any spaces we can paint everything else + //If the last slice of the string (split by @) doesnt contain any spaces we can paint everythingg else if !last.contains(' ') { //Set this var true if the @ menu is being displayed; //* self.get_connected_users function MUST be called before showing the text input widget, so this way we can actually consume the ArrowUp and Down keys self.client_ui.display_user_list = self.get_connected_users(ctx); - //Consume input when we are diplaying the user list + //Consume input when we are displaying the user list if self.client_ui.display_user_list { ctx.input_mut(|reader| { //Clone var to avoid error @@ -198,7 +198,7 @@ impl Application *buffer = &formatted_string; - //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz theyre not present when concating a normal vec (constructed from a string, split by @s) + //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz they're not present when concatenating a normal vec (constructed from a string, split by @s) let split_concat = split.join("@"); //Set the buffer to the concatenated vector, append the @ to the 0th index @@ -225,9 +225,9 @@ impl Application let split_clone = split.clone(); - //We just pattern match for the sake of never panicing, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) + //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last() { - //If the last slice of the string (split by :) doesnt contain any spaces we can paint everything else + //If the last slice of the string (split by :) doesnt contain any spaces we can paint everythingg else if !last.contains(' ') && !last.is_empty() && split_clone.len() > 1 { let matched_emojis = self.get_emojis(ctx, last.to_string()); @@ -237,7 +237,7 @@ impl Application return; } - //Consume input when we are diplaying the user list + //Consume input when we are displaying the user list ctx.input_mut(|reader| { //Clone var to avoid error let user_message_clone = self.client_ui.message_buffer.clone(); @@ -257,7 +257,7 @@ impl Application *last = &formatted_string; - //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz theyre not present when concating a normal vec (constructed from a string, split by @s) + //Concat the vector after modifying it, we know that every piece of string is split by a '@' so we can join them all by one, therefor avoiding deleting previous @s cuz they're not present when concatenating a normal vec (constructed from a string, split by @s) let split_concat = split.join(":"); //Set the buffer to the concatenated vector, append the @ to the 0th index @@ -607,7 +607,7 @@ impl Application self.client_ui.emojis_display_rect = Some(emoji_group.response.rect); - //if there are no matched emojis we return to, avoid panicing cuz of the clamping, and to avoid consuming inputs + //if there are no matched emojis we return to, avoid panicking cuz of the clamping, and to avoid consuming inputs if matched_emojis.is_empty() { return; } diff --git a/mobile/src/app/ui/register.rs b/mobile/src/app/ui/register.rs index 58dbd16..013a1ec 100644 --- a/mobile/src/app/ui/register.rs +++ b/mobile/src/app/ui/register.rs @@ -158,7 +158,7 @@ impl Application //Draw background ui.painter().rect_filled( - Rect::everything_right_of(ui.available_width()), + Rect::everythingg_right_of(ui.available_width()), 0., Color32::from_black_alpha(160), ); diff --git a/mobile/src/app/ui/server.rs b/mobile/src/app/ui/server.rs index 4cf2132..10331b2 100644 --- a/mobile/src/app/ui/server.rs +++ b/mobile/src/app/ui/server.rs @@ -41,7 +41,7 @@ impl Application let connected_clients: std::sync::Arc> = self.server_connected_clients_profile.clone(); - let shared_fileds_clone = self.client_ui.shared_fields.clone(); + let shared_fields_clone = self.client_ui.shared_fields.clone(); //Move context so we can request_repaint let ctx = ctx.clone(); @@ -61,7 +61,7 @@ impl Application Ok(shared_fields) => { //Assign shared fields tokio::spawn(async move { - *shared_fileds_clone.lock().unwrap() = + *shared_fields_clone.lock().unwrap() = shared_fields.lock().await.clone(); }); }, diff --git a/mobile/src/main.rs b/mobile/src/main.rs index eedbb98..ff6ebba 100644 --- a/mobile/src/main.rs +++ b/mobile/src/main.rs @@ -43,7 +43,7 @@ async fn main() -> eframe::Result<()> .unwrap(); //Display error message - display_panic_message(format!("A panic! has occured the error is logged in %appdata%. Please send the generated file or this message to the developer!\nPanic: \n{:?}\nLocation: \n{:?}", { + display_panic_message(format!("A panic! has occurred the error is logged in %appdata%. Please send the generated file or this message to the developer!\nPanic: \n{:?}\nLocation: \n{:?}", { match info.payload().downcast_ref::<&str>() { Some(msg) => msg, None => { From 5c087079f2b6811fe83da73c319d5ef4f1a93ea3 Mon Sep 17 00:00:00 2001 From: limuy Date: Fri, 30 Aug 2024 15:58:02 +0800 Subject: [PATCH 2/4] add typos ci --- .github/workflows/typos.yml | 2 +- _typos.toml | 5 +++++ mobile/build_info.Matthias_build | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 _typos.toml diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml index b38fe57..2d32ace 100644 --- a/.github/workflows/typos.yml +++ b/.github/workflows/typos.yml @@ -10,7 +10,7 @@ env: CARGO_TERM_COLOR: always jobs: - build: + check: runs-on: ubuntu-latest steps: diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..f822c3b --- /dev/null +++ b/_typos.toml @@ -0,0 +1,5 @@ +[default.extend-words] +caf = "caf" + +[files] +extend-exclude = ["*.vdproj"] diff --git a/mobile/build_info.Matthias_build b/mobile/build_info.Matthias_build index bd9230f..c4f2e8a 100644 --- a/mobile/build_info.Matthias_build +++ b/mobile/build_info.Matthias_build @@ -1 +1 @@ -2024.08.30. 08:54 \ No newline at end of file +2024.08.30. 08:59 \ No newline at end of file From 900bc8db3dc201471e771af3681c04232f52d48a Mon Sep 17 00:00:00 2001 From: limuy Date: Sat, 31 Aug 2024 00:41:26 +0800 Subject: [PATCH 3/4] fix "containingg" typo --- README.md | 54 ++++++++++++------- desktop/src/app/backend.rs | 4 +- desktop/src/app/server.rs | 2 +- .../client_actions/audio_recording.rs | 4 +- mobile/build_info.Matthias_build | 2 +- mobile/src/app/backend.rs | 4 +- mobile/src/app/server.rs | 2 +- 7 files changed, 45 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e4b90a0..42cd7ed 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,76 @@ # Matthias + A (soon to be) multiplatform self-hosted chat application built completely in Rust. + ## Features -| Features | Desktop | Mobile | -| -------- | ------- | ------- | -| Encrypted messages ensuring security | ✅ | ✅ | -| Backend which doesn't rely on any central provider | ✅ | ✅ | -| Customizable profiles | ✅ | ✅ | -| Text, audio, image, file messages, and images | ✅ | ✅ | -| Custom emojis | ✅ | ✅ | -| Intuitive user interface | ✅ | ✅ | -| Experimental MD (Markdown) support | ✅ | ✅ | -| Voice calls | ✅ | ❌ | -| Extensive lua (using luajit) API with documentation at [Gitbook](https://matthias.gitbook.io/) with external libs available | ✅ | ❌ | -| Custom connection urls (If the app is installed through the installer) This allows the user to connect to a server with just a link | ✅ | ❌ | + +| Features | Desktop | Mobile | +| ----------------------------------------------------------------------------------------------------------------------------------- | ------- | ------ | +| Encrypted messages ensuring security | ✅ | ✅ | +| Backend which doesn't rely on any central provider | ✅ | ✅ | +| Customizable profiles | ✅ | ✅ | +| Text, audio, image, file messages, and images | ✅ | ✅ | +| Custom emojis | ✅ | ✅ | +| Intuitive user interface | ✅ | ✅ | +| Experimental MD (Markdown) support | ✅ | ✅ | +| Voice calls | ✅ | ❌ | +| Extensive lua (using luajit) API with documentation at [Gitbook](https://matthias.gitbook.io/) with external libs available | ✅ | ❌ | +| Custom connection urls (If the app is installed through the installer) This allows the user to connect to a server with just a link | ✅ | ❌ | **Disclaimer: The application has never been security audited, and has known flaws.** ### Additional Features (For desktop only): + - Windows installer (Using a Visual Studio project) # Children repositories (Crates/Repos created for the purpose of showcasing/improving Matthias) + - [Wincam](https://github.com/marci1175/wincam) (Used to capture images from the host's camera) - [Protocol Showcase](https://github.com/marci1175/matthias-tokio-protocol/tree/master) (Used to showcase Matthias's TCP protocol) - [mLua proc macro](https://github.com/marci1175/mlua_proc_macro) (Used in creating the lua API) -_________________________________________________________ -__All this__ with great performance, due to the project being multi-threaded, using async calls with egui, and many more! +--- + +**All this** with great performance, due to the project being multi-threaded, using async calls with egui, and many more! I have also tried to make my codebase futureproof by implementing custom automatizations (Example: code generating for emojis) and custom proc macros. -_________________________________________________________ + +--- ## How to compile: + - First, you must have the Rust compiler installed on your computer with all of its dependencies. - The next step is to download the source code of this project. (whether that be git cloning or downloading it from github's website) -- Navigate to the source folder and run ```cargo r --release``` (Or without --release for debugging) +- Navigate to the source folder and run `cargo r --release` (Or without --release for debugging) - Please note that some features may not be available when running the application after compilation (For links to work you must "install" the application through the installer provided) + ### How to create an installer (Note: You must have the Visual Studio installed for this): + - Navigate to `desktop/Installer` in the project folder, and open up the Matthias.sln file. - Click on build on the top menu bar and click Build Solution (Or use the `ctrl+shift+b` key combination) - After building go to `desktop/Installer/MatthiasSetup/Release/` and you will find two files: - - One containingg the dependencies (Smaller file size) - - One containingg the application itself (Bigger file size) + - One containing the dependencies (Smaller file size) + - One containing the application itself (Bigger file size) ## Community + Feel free to chat in the official [Matthias discord server](https://discord.gg/66KFkByMGa)! ## Preview + ### Lua API + ![lua api](https://github.com/marci1175/Matthias/blob/813d91dec618beca08e85f9c09e7acb1d977c03d/.github/assets/luaapi.png) + ### Messages + ![Messages](https://github.com/marci1175/Matthias/blob/813d91dec618beca08e85f9c09e7acb1d977c03d/.github/assets/messages.png) + ### Register page + ![Register page](https://github.com/marci1175/Matthias/blob/813d91dec618beca08e85f9c09e7acb1d977c03d/.github/assets/register.png) **When wanting to install both, start by opening up the smaller file (Dependency installer), it will automatically open up the application installer.** # Legacy + - The predecessor of Matthias was [ChatApp](https://github.com/marci1175/ChatApp) diff --git a/desktop/src/app/backend.rs b/desktop/src/app/backend.rs index d326e7f..25dc61d 100644 --- a/desktop/src/app/backend.rs +++ b/desktop/src/app/backend.rs @@ -2351,7 +2351,7 @@ pub struct Voip impl Voip { - /// This function creates a new ```Voip``` instance containingg a ```UdpSocket``` and an authentication from the server + /// This function creates a new ```Voip``` instance containing a ```UdpSocket``` and an authentication from the server /// Note that this doesnt contain the camera_handle, if you want to add it use the ```add_video_handle()``` function pub async fn new() -> anyhow::Result { @@ -2775,7 +2775,7 @@ pub fn ipv6_get() -> Result /// Account management /// This might look similar to ```ClientProfile``` -/// struct containingg a new user's info, when serialized / deserialized it gets encrypted or decrypted +/// struct containing a new user's info, when serialized / deserialized it gets encrypted or decrypted #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default, ToTable)] pub struct UserInformation { diff --git a/desktop/src/app/server.rs b/desktop/src/app/server.rs index 719adda..17ffeb1 100644 --- a/desktop/src/app/server.rs +++ b/desktop/src/app/server.rs @@ -1350,7 +1350,7 @@ impl MessageService )); } - /// This function returns a message containingg a full sync (all the messages etc) + /// This function returns a message containing a full sync (all the messages etc) /// It returns a ```ServerMaster``` converted to an encrypted string async fn full_sync_client(&self) -> anyhow::Result { diff --git a/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs b/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs index ef3c476..385ec64 100644 --- a/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs +++ b/desktop/src/app/ui/client_ui/client_actions/audio_recording.rs @@ -230,7 +230,7 @@ fn wav_spec_from_config(config: &cpal::SupportedStreamConfig) -> hound::WavSpec } } -/// This function creates a wav foramtted audio file, containingg the samples provided to this function +/// This function creates a wav foramtted audio file, containing the samples provided to this function pub fn create_wav_file(samples: Vec) -> Vec { let writer = Arc::new(Mutex::new(Vec::new())); @@ -254,7 +254,7 @@ pub fn create_wav_file(samples: Vec) -> Vec buf.into_inner().to_vec() } -/// This function creates a wav foramtted audio file, containingg the samples provided to this function +/// This function creates a wav foramtted audio file, containing the samples provided to this function /// This function doesnt work properly pub fn create_opus_file(mut samples: Vec) -> Vec { diff --git a/mobile/build_info.Matthias_build b/mobile/build_info.Matthias_build index c4f2e8a..bbf051e 100644 --- a/mobile/build_info.Matthias_build +++ b/mobile/build_info.Matthias_build @@ -1 +1 @@ -2024.08.30. 08:59 \ No newline at end of file +2024.08.30. 17:40 \ No newline at end of file diff --git a/mobile/src/app/backend.rs b/mobile/src/app/backend.rs index 03cd68a..11144ab 100644 --- a/mobile/src/app/backend.rs +++ b/mobile/src/app/backend.rs @@ -2248,7 +2248,7 @@ impl UdpMessageType // impl Voip // { -// /// This function creates a new ```Voip``` instance containingg a ```UdpSocket``` and an authentication from the server +// /// This function creates a new ```Voip``` instance containing a ```UdpSocket``` and an authentication from the server // /// Note that this doesnt contain the camera_handle, if you want to add it use the ```add_video_handle()``` function // pub async fn new() -> anyhow::Result // { @@ -2666,7 +2666,7 @@ pub fn ipv6_get() -> Result /// Account management /// This might look similar to ```ClientProfile``` -/// struct containingg a new user's info, when serialized / deserialized it gets encrypted or decrypted +/// struct containing a new user's info, when serialized / deserialized it gets encrypted or decrypted #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default, ToTable)] pub struct UserInformation { diff --git a/mobile/src/app/server.rs b/mobile/src/app/server.rs index c7d45f1..a208657 100644 --- a/mobile/src/app/server.rs +++ b/mobile/src/app/server.rs @@ -1331,7 +1331,7 @@ impl MessageService )); } - /// This function returns a message containingg a full sync (all the messages etc) + /// This function returns a message containing a full sync (all the messages etc) /// It returns a ```ServerMaster``` converted to an encrypted string async fn full_sync_client(&self) -> anyhow::Result { From ffaaa63d0de2c13187fc8d5a766aa3071293e96d Mon Sep 17 00:00:00 2001 From: limuy Date: Sat, 31 Aug 2024 22:42:47 +0800 Subject: [PATCH 4/4] Fix "everythingg" and "abnormal" typos --- desktop/src/app.rs | 2 +- desktop/src/app/backend.rs | 6 +++--- desktop/src/app/server.rs | 2 +- desktop/src/app/ui/client.rs | 6 +++--- .../src/app/ui/client_ui/message_instances/message_main.rs | 2 +- .../ui/client_ui/widgets/message_tray/message_tray_main.rs | 4 ++-- desktop/src/app/ui/register.rs | 2 +- mobile/src/app.rs | 2 +- mobile/src/app/backend.rs | 6 +++--- mobile/src/app/ui/client.rs | 4 ++-- .../src/app/ui/client_ui/message_instances/message_main.rs | 2 +- .../ui/client_ui/widgets/message_tray/message_tray_main.rs | 4 ++-- mobile/src/app/ui/register.rs | 2 +- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/desktop/src/app.rs b/desktop/src/app.rs index 11d754a..de00709 100644 --- a/desktop/src/app.rs +++ b/desktop/src/app.rs @@ -512,7 +512,7 @@ impl backend::Application let user_information = self.opened_user_information.clone(); - //Reset all messages and everythingg else + //Reset all messages and everything else self.client_ui.incoming_messages = ServerMaster::default(); //Forget all imaes so the cached imges will be deleted diff --git a/desktop/src/app/backend.rs b/desktop/src/app/backend.rs index 25dc61d..c20e9e1 100644 --- a/desktop/src/app/backend.rs +++ b/desktop/src/app/backend.rs @@ -1011,7 +1011,7 @@ impl Default for ProfileImage } /// The clients profile, this struct should be sent at a server connection -/// It hold everythingg which needs to be displayed when viewing someone's profile +/// It hold everything which needs to be displayed when viewing someone's profile /// This struct might look similar too ```Register```, but that one contains more information, and is only made to control the ui /// This struct is sent to the server upon successful connection /// If you are searching for the uuid in this struct, please note that most of the times this struct is used in a hashmap where the key is the uuid @@ -1750,7 +1750,7 @@ pub enum ServerReplyType Client(ServerClientReply), } -/// This struct holds everythingg important so the client can save and handle client profiles +/// This struct holds everything important so the client can save and handle client profiles #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] pub struct ServerClientReply { @@ -2061,7 +2061,7 @@ impl ServerOutput } /// Used to put all the messages into 1 big pack (Bundling All the ServerOutput-s), Main packet, this gets to all the clients -/// This message type is only used when a client is connecting an has to do a full sync (sending everythingg to the client all the messages reactions, etc) +/// This message type is only used when a client is connecting an has to do a full sync (sending everything to the client all the messages reactions, etc) #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default)] pub struct ServerMaster { diff --git a/desktop/src/app/server.rs b/desktop/src/app/server.rs index 17ffeb1..d1c108d 100644 --- a/desktop/src/app/server.rs +++ b/desktop/src/app/server.rs @@ -900,7 +900,7 @@ impl MessageService Ok((_, socket_addr)) => { match connected_clients.get(&socket_addr) { Some(client) => { - //We send everythingg from the 4th byte since that is the part of the header + //We send everything from the 4th byte since that is the part of the header //We dont care about the result since it will panic when the thread is shut down let _ = client.0.send(body_buf[4..].to_vec()).await; }, diff --git a/desktop/src/app/ui/client.rs b/desktop/src/app/ui/client.rs index fa96998..509ed46 100644 --- a/desktop/src/app/ui/client.rs +++ b/desktop/src/app/ui/client.rs @@ -100,7 +100,7 @@ impl Application ))); if disconnect_button.clicked() { - //Disable camera if it exists before everythingg else + //Disable camera if it exists before everything else if voip.camera_handle_is_open.load(Relaxed) { self.disable_camera(voip); } @@ -353,7 +353,7 @@ impl Application ); }); - //We have to render the message area after everythingg else, because then we will be using the area whats left of the ui + //We have to render the message area after everything else, because then we will be using the area whats left of the ui //msg_area egui::CentralPanel::default().show(ctx, |ui| { //Drop file warning @@ -476,7 +476,7 @@ impl Application }); ui.separator(); - //For the has_search logic to work and for the rust compiler not to underline everythingg + //For the has_search logic to work and for the rust compiler not to underline everything egui::ScrollArea::new([true, true]).auto_shrink([false, true]).show(ui, |ui|{ ui.allocate_ui(ui.available_size(), |ui|{ let mut has_search = false; diff --git a/desktop/src/app/ui/client_ui/message_instances/message_main.rs b/desktop/src/app/ui/client_ui/message_instances/message_main.rs index 240ea9e..728d798 100644 --- a/desktop/src/app/ui/client_ui/message_instances/message_main.rs +++ b/desktop/src/app/ui/client_ui/message_instances/message_main.rs @@ -413,7 +413,7 @@ impl Application if item.uuid == self.opened_user_information.uuid && item.message_type != ServerMessageType::Deleted { - //We should only display the `edit` button if its abnormal message thus its editable + //We should only display the `edit` button if its a normal message thus its editable if let ServerMessageType::Normal(inner) = &item.message_type { if ui .add(Button::image_and_text( diff --git a/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs b/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs index 7df7dea..2777907 100644 --- a/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs +++ b/desktop/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs @@ -152,7 +152,7 @@ impl Application //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last_mut() { - //If the last slice of the string (split by @) doesnt contain any spaces we can paint everythingg else + //If the last slice of the string (split by @) doesnt contain any spaces we can paint everything else if !last.contains(' ') { //Set this var true if the @ menu is being displayed; //* self.get_connected_users function MUST be called before showing the text input widget, so this way we can actually consume the ArrowUp and Down keys @@ -232,7 +232,7 @@ impl Application //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last() { - //If the last slice of the string (split by :) doesnt contain any spaces we can paint everythingg else + //If the last slice of the string (split by :) doesnt contain any spaces we can paint everything else if !last.contains(' ') && !last.is_empty() && split_clone.len() > 1 { let matched_emojis = self.get_emojis(ctx, last.to_string()); diff --git a/desktop/src/app/ui/register.rs b/desktop/src/app/ui/register.rs index 9c475fa..e627a06 100644 --- a/desktop/src/app/ui/register.rs +++ b/desktop/src/app/ui/register.rs @@ -155,7 +155,7 @@ impl Application //Draw background ui.painter().rect_filled( - Rect::everythingg_right_of(ui.available_width()), + Rect::everything_right_of(ui.available_width()), 0., Color32::from_black_alpha(160), ); diff --git a/mobile/src/app.rs b/mobile/src/app.rs index 8b09382..0aa5844 100644 --- a/mobile/src/app.rs +++ b/mobile/src/app.rs @@ -506,7 +506,7 @@ impl backend::Application let user_information = self.opened_user_information.clone(); - //Reset all messages and everythingg else + //Reset all messages and everything else self.client_ui.incoming_messages = ServerMaster::default(); //Forget all imaes so the cached imges will be deleted diff --git a/mobile/src/app/backend.rs b/mobile/src/app/backend.rs index 11144ab..76672e9 100644 --- a/mobile/src/app/backend.rs +++ b/mobile/src/app/backend.rs @@ -971,7 +971,7 @@ impl Default for ProfileImage } /// The clients profile, this struct should be sent at a server connection -/// It hold everythingg which needs to be displayed when viewing someone's profile +/// It hold everything which needs to be displayed when viewing someone's profile /// This struct might look similar too ```Register```, but that one contains more information, and is only made to control the ui /// This struct is sent to the server upon successful connection /// If you are searching for the uuid in this struct, please note that most of the times this struct is used in a hashmap where the key is the uuid @@ -1698,7 +1698,7 @@ pub enum ServerReplyType Client(ServerClientReply), } -/// This struct holds everythingg important so the client can save and handle client profiles +/// This struct holds everything important so the client can save and handle client profiles #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] pub struct ServerClientReply { @@ -1987,7 +1987,7 @@ impl ServerOutput } /// Used to put all the messages into 1 big pack (Bundling All the ServerOutput-s), Main packet, this gets to all the clients -/// This message type is only used when a client is connecting an has to do a full sync (sending everythingg to the client all the messages reactions, etc) +/// This message type is only used when a client is connecting an has to do a full sync (sending everything to the client all the messages reactions, etc) #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default)] pub struct ServerMaster { diff --git a/mobile/src/app/ui/client.rs b/mobile/src/app/ui/client.rs index 9024228..63a2cd9 100644 --- a/mobile/src/app/ui/client.rs +++ b/mobile/src/app/ui/client.rs @@ -187,7 +187,7 @@ impl Application ); }); - //We have to render the message area after everythingg else, because then we will be using the area whats left of the ui + //We have to render the message area after everything else, because then we will be using the area whats left of the ui //msg_area egui::CentralPanel::default().show(ctx, |ui| { //Drop file warning @@ -310,7 +310,7 @@ impl Application }); ui.separator(); - //For the has_search logic to work and for the rust compiler not to underline everythingg + //For the has_search logic to work and for the rust compiler not to underline everything egui::ScrollArea::new([true, true]).auto_shrink([false, true]).show(ui, |ui|{ ui.allocate_ui(ui.available_size(), |ui|{ let mut has_search = false; diff --git a/mobile/src/app/ui/client_ui/message_instances/message_main.rs b/mobile/src/app/ui/client_ui/message_instances/message_main.rs index 36ac1a1..5d72b01 100644 --- a/mobile/src/app/ui/client_ui/message_instances/message_main.rs +++ b/mobile/src/app/ui/client_ui/message_instances/message_main.rs @@ -379,7 +379,7 @@ impl Application if item.uuid == self.opened_user_information.uuid && item.message_type != ServerMessageType::Deleted { - //We should only display the `edit` button if its abnormal message thus its editable + //We should only display the `edit` button if its a normal message thus its editable if let ServerMessageType::Normal(inner) = &item.message_type { if ui .add(Button::image_and_text( diff --git a/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs b/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs index c0c8742..f2bc117 100644 --- a/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs +++ b/mobile/src/app/ui/client_ui/widgets/message_tray/message_tray_main.rs @@ -147,7 +147,7 @@ impl Application //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last_mut() { - //If the last slice of the string (split by @) doesnt contain any spaces we can paint everythingg else + //If the last slice of the string (split by @) doesnt contain any spaces we can paint everything else if !last.contains(' ') { //Set this var true if the @ menu is being displayed; //* self.get_connected_users function MUST be called before showing the text input widget, so this way we can actually consume the ArrowUp and Down keys @@ -227,7 +227,7 @@ impl Application //We just pattern match for the sake of never panicking, if we called .unwrap() on this it would still (im 99% sure) work, and its still nicer than (...).get(.len() - 1) if let Some(last) = split.last() { - //If the last slice of the string (split by :) doesnt contain any spaces we can paint everythingg else + //If the last slice of the string (split by :) doesnt contain any spaces we can paint everything else if !last.contains(' ') && !last.is_empty() && split_clone.len() > 1 { let matched_emojis = self.get_emojis(ctx, last.to_string()); diff --git a/mobile/src/app/ui/register.rs b/mobile/src/app/ui/register.rs index 013a1ec..58dbd16 100644 --- a/mobile/src/app/ui/register.rs +++ b/mobile/src/app/ui/register.rs @@ -158,7 +158,7 @@ impl Application //Draw background ui.painter().rect_filled( - Rect::everythingg_right_of(ui.available_width()), + Rect::everything_right_of(ui.available_width()), 0., Color32::from_black_alpha(160), );