aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/state.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-10-29 14:54:11 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-10-29 21:27:26 +0100
commitbddf2324b1fd1c440127432cbd93ac64afc7ca85 (patch)
tree8898c591b5a5bcc7ffede8fe985f3003592514f8 /mumd/src/state.rs
parent8cd74edc6079d26746cd07838c99d3b60228b87f (diff)
downloadmum-bddf2324b1fd1c440127432cbd93ac64afc7ca85.tar.gz
refactor and dont panic without x-server
Diffstat (limited to 'mumd/src/state.rs')
-rw-r--r--mumd/src/state.rs29
1 files changed, 8 insertions, 21 deletions
diff --git a/mumd/src/state.rs b/mumd/src/state.rs
index ea0213c..ea081fc 100644
--- a/mumd/src/state.rs
+++ b/mumd/src/state.rs
@@ -4,6 +4,7 @@ pub mod user;
use crate::audio::Audio;
use crate::network::ConnectionInfo;
+use crate::notify;
use crate::state::server::Server;
use log::*;
@@ -239,12 +240,7 @@ impl State {
0
};
if let Some(channel) = self.server().unwrap().channels().get(&channel_id) {
- libnotify::Notification::new("mumd",
- Some(format!("{} connected and joined {}",
- &msg.get_name(),
- channel.name()).as_str()),
- None)
- .show().unwrap();
+ notify::send(format!("{} connected and joined {}", &msg.get_name(), channel.name()));
}
}
}
@@ -273,12 +269,10 @@ impl State {
//TODO our channel only
if let Some(channel_id) = diff.channel_id {
if let Some(channel) = self.server().unwrap().channels().get(&channel_id) {
- libnotify::Notification::new("mumd",
- Some(format!("{} moved to channel {}",
- &user.name(),
- channel.name()).as_str()),
- None)
- .show().unwrap();
+ notify::send(format!(
+ "{} moved to channel {}",
+ &user.name(),
+ channel.name()));
} else {
warn!("{} moved to invalid channel {}", &user.name(), channel_id);
}
@@ -309,10 +303,7 @@ impl State {
None
};
if let Some(notif_desc) = notif_desc {
- libnotify::Notification::new("mumd",
- notif_desc.as_str(),
- None)
- .show().unwrap();
+ notify::send(notif_desc);
}
diff
@@ -324,11 +315,7 @@ impl State {
return;
}
if let Some(user) = self.server().unwrap().users().get(&msg.get_session()) {
- libnotify::Notification::new("mumd",
- Some(format!("{} disconnected",
- &user.name()).as_str()),
- None)
- .show().unwrap();
+ notify::send(format!("{} disconnected", &user.name()));
}
self.audio().remove_client(msg.get_session());