diff options
Diffstat (limited to '')
| -rw-r--r-- | pkgs/by-name/mp/mpdpopm/src/config.rs | 112 | ||||
| -rw-r--r-- | pkgs/by-name/mp/mpdpopm/src/lib.rs | 4 |
2 files changed, 2 insertions, 114 deletions
diff --git a/pkgs/by-name/mp/mpdpopm/src/config.rs b/pkgs/by-name/mp/mpdpopm/src/config.rs index b4fe3c53..13a1891b 100644 --- a/pkgs/by-name/mp/mpdpopm/src/config.rs +++ b/pkgs/by-name/mp/mpdpopm/src/config.rs @@ -142,9 +142,6 @@ pub struct Config { /// The interval, in milliseconds, at which to poll `mpd' for the current state pub poll_interval_ms: u64, - - /// Channel to setup for assorted commands-- channel names must satisfy "[-a-zA-Z-9_.:]+" - pub commands_chan: String, } impl Default for Config { @@ -162,7 +159,6 @@ impl Config { local_music_dir: [PREFIX, "Music"].iter().collect(), played_thresh: 0.6, poll_interval_ms: 5000, - commands_chan: String::from("unwoundstack.com:commands"), }) } } @@ -176,111 +172,3 @@ pub fn from_str(text: &str) -> Result<Config> { }; Ok(cfg) } - -#[cfg(test)] -mod test { - use super::*; - - #[test] - #[ignore = "We changed the config format to json"] - fn test_from_str() { - let cfg = Config::default(); - assert_eq!(cfg.commands_chan, String::from("unwoundstack.com:commands")); - - assert_eq!( - serde_json::to_string(&cfg).unwrap(), - format!( - r#"((version . "1") (log . "{}/log/mppopmd.log") (conn TCP (host . "localhost") (port . 6600)) (local_music_dir . "{}/Music") (playcount_sticker . "unwoundstack.com:playcount") (lastplayed_sticker . "unwoundstack.com:lastplayed") (played_thresh . 0.6) (poll_interval_ms . 5000) (commands_chan . "unwoundstack.com:commands") (playcount_command . "") (playcount_command_args) (rating_sticker . "unwoundstack.com:rating") (ratings_command . "") (ratings_command_args) (gen_cmds))"#, - LOCALSTATEDIR, PREFIX - ) - ); - - let cfg: Config = serde_json::from_str( - r#" -((version . "1") - (log . "/usr/local/var/log/mppopmd.log") - (conn TCP (host . "localhost") (port . 6600)) - (local_music_dir . "/usr/local/Music") - (playcount_sticker . "unwoundstack.com:playcount") - (lastplayed_sticker . "unwoundstack.com:lastplayed") - (played_thresh . 0.6) - (poll_interval_ms . 5000) - (commands_chan . "unwoundstack.com:commands") - (playcount_command . "") - (playcount_command_args) - (rating_sticker . "unwoundstack.com:rating") - (ratings_command . "") - (ratings_command_args) - (gen_cmds)) -"#, - ) - .unwrap(); - assert_eq!(cfg._version, String::from("1")); - - let cfg: Config = serde_json::from_str( - r#" -((version . "1") - (log . "/usr/local/var/log/mppopmd.log") - (conn Local (path . "/home/mgh/var/run/mpd/mpd.sock")) - (local_music_dir . "/usr/local/Music") - (playcount_sticker . "unwoundstack.com:playcount") - (lastplayed_sticker . "unwoundstack.com:lastplayed") - (played_thresh . 0.6) - (poll_interval_ms . 5000) - (commands_chan . "unwoundstack.com:commands") - (playcount_command . "") - (playcount_command_args) - (rating_sticker . "unwoundstack.com:rating") - (ratings_command . "") - (ratings_command_args) - (gen_cmds)) -"#, - ) - .unwrap(); - assert_eq!(cfg._version, String::from("1")); - assert_eq!( - cfg.conn, - Connection::Local { - path: PathBuf::from("/home/mgh/var/run/mpd/mpd.sock") - } - ); - - // Test fallback to "v0" of the config struct - let cfg = from_str(r#" -((log . "/home/mgh/var/log/mppopmd.log") - (host . "192.168.1.14") - (port . 6600) - (local_music_dir . "/space/mp3") - (playcount_sticker . "unwoundstack.com:playcount") - (lastplayed_sticker . "unwoundstack.com:lastplayed") - (played_thresh . 0.6) - (poll_interval_ms . 5000) - (playcount_command . "/usr/local/bin/scribbu") - (playcount_command_args . ("popm" "-v" "-a" "-f" "-o" "sp1ff@pobox.com" "-C" "%playcount" "%full-file")) - (commands_chan . "unwoundstack.com:commands") - (rating_sticker . "unwoundstack.com:rating") - (ratings_command . "/usr/local/bin/scribbu") - (ratings_command_args . ("popm" "-v" "-a" "-f" "-o" "sp1ff@pobox.com" "-r" "%rating" "%full-file")) - (gen_cmds . - (((name . "set-genre") - (formal_parameters . (Literal Track)) - (default_after . 1) - (cmd . "/usr/local/bin/scribbu") - (args . ("genre" "-a" "-C" "-g" "%1" "%full-file")) - (update . TrackOnly)) - ((name . "set-xtag") - (formal_parameters . (Literal Track)) - (default_after . 1) - (cmd . "/usr/local/bin/scribbu") - (args . ("xtag" "-A" "-o" "sp1ff@pobox.com" "-T" "%1" "%full-file")) - (update . TrackOnly)) - ((name . "merge-xtag") - (formal_parameters . (Literal Track)) - (default_after . 1) - (cmd . "/usr/local/bin/scribbu") - (args . ("xtag" "-m" "-o" "sp1ff@pobox.com" "-T" "%1" "%full-file")) - (update . TrackOnly))))) -"#).unwrap(); - assert_eq!(cfg.log, PathBuf::from("/home/mgh/var/log/mppopmd.log")); - } -} diff --git a/pkgs/by-name/mp/mpdpopm/src/lib.rs b/pkgs/by-name/mp/mpdpopm/src/lib.rs index cc2765dc..6cc47807 100644 --- a/pkgs/by-name/mp/mpdpopm/src/lib.rs +++ b/pkgs/by-name/mp/mpdpopm/src/lib.rs @@ -53,7 +53,7 @@ pub mod filters { use crate::{ clients::{Client, IdleClient, IdleSubSystem}, config::{Config, Connection}, - messanges::MessageQueue, + messanges::{COMMAND_CHANNEL, MessageQueue}, playcounts::PlayState, }; @@ -96,7 +96,7 @@ pub async fn mpdpopm(cfg: Config) -> std::result::Result<(), Error> { let mut mqueue = MessageQueue::new(); idle_client - .subscribe(&cfg.commands_chan) + .subscribe(COMMAND_CHANNEL) .await .context("Failed to subscribe to idle_client")?; |
