From d8c269f66a4a5a17155bec5e2cb5ad97f3ba00fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 30 Mar 2021 11:27:10 +0200 Subject: rename notify -> notifications Notify is already taken, see https://lib.rs/crates/notify. --- mumd/src/main.rs | 4 ++-- mumd/src/notifications.rs | 24 ++++++++++++++++++++++++ mumd/src/notify.rs | 24 ------------------------ mumd/src/state.rs | 10 +++++----- 4 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 mumd/src/notifications.rs delete mode 100644 mumd/src/notify.rs diff --git a/mumd/src/main.rs b/mumd/src/main.rs index 42be3f8..cd53d4a 100644 --- a/mumd/src/main.rs +++ b/mumd/src/main.rs @@ -3,7 +3,7 @@ mod client; mod command; mod error; mod network; -mod notify; +mod notifications; mod state; use crate::state::State; @@ -24,7 +24,7 @@ async fn main() { } setup_logger(std::io::stderr(), true); - notify::init(); + notifications::init(); // check if another instance is live let connection = UnixStream::connect(mumlib::SOCKET_PATH).await; diff --git a/mumd/src/notifications.rs b/mumd/src/notifications.rs new file mode 100644 index 0000000..e52b909 --- /dev/null +++ b/mumd/src/notifications.rs @@ -0,0 +1,24 @@ +use log::*; + +pub fn init() { + #[cfg(feature = "notifications")] + if libnotify::init("mumd").is_err() { + warn!("Unable to initialize notifications"); + } +} + +#[cfg(feature = "notifications")] +pub fn send(msg: String) -> Option { + match libnotify::Notification::new("mumd", Some(msg.as_str()), None).show() { + Ok(_) => Some(true), + Err(_) => { + warn!("Unable to send notification"); + Some(false) + } + } +} + +#[cfg(not(feature = "notifications"))] +pub fn send(_: String) -> Option { + None +} diff --git a/mumd/src/notify.rs b/mumd/src/notify.rs deleted file mode 100644 index e52b909..0000000 --- a/mumd/src/notify.rs +++ /dev/null @@ -1,24 +0,0 @@ -use log::*; - -pub fn init() { - #[cfg(feature = "notifications")] - if libnotify::init("mumd").is_err() { - warn!("Unable to initialize notifications"); - } -} - -#[cfg(feature = "notifications")] -pub fn send(msg: String) -> Option { - match libnotify::Notification::new("mumd", Some(msg.as_str()), None).show() { - Ok(_) => Some(true), - Err(_) => { - warn!("Unable to send notification"); - Some(false) - } - } -} - -#[cfg(not(feature = "notifications"))] -pub fn send(_: String) -> Option { - None -} diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 858441a..9202e9f 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -6,7 +6,7 @@ use crate::audio::{Audio, NotificationEvents}; use crate::error::StateError; use crate::network::{ConnectionInfo, VoiceStreamType}; use crate::network::tcp::{TcpEvent, TcpEventData}; -use crate::notify; +use crate::notifications; use crate::state::server::Server; use log::*; @@ -463,7 +463,7 @@ impl State { == self.get_users_channel(self.server().unwrap().session_id().unwrap()) { if let Some(channel) = self.server().unwrap().channels().get(&channel_id) { - notify::send(format!( + notifications::send(format!( "{} connected and joined {}", &msg.get_name(), channel.name() @@ -516,7 +516,7 @@ impl State { self.get_users_channel(self.server().unwrap().session_id().unwrap()); if from_channel == this_channel || to_channel == this_channel { if let Some(channel) = self.server().unwrap().channels().get(&to_channel) { - notify::send(format!( + notifications::send(format!( "{} moved to channel {}", user.name(), channel.name() @@ -545,7 +545,7 @@ impl State { s += if deaf { " deafened" } else { " undeafened" }; } s += " themselves"; - notify::send(s); + notifications::send(s); } } } @@ -561,7 +561,7 @@ impl State { if this_channel == other_channel { self.audio.play_effect(NotificationEvents::UserDisconnected); if let Some(user) = self.server().unwrap().users().get(&msg.get_session()) { - notify::send(format!("{} disconnected", &user.name())); + notifications::send(format!("{} disconnected", &user.name())); } } -- cgit v1.2.1