diff --git a/src/application.rs b/src/application.rs index 5a99cab..c6e59c1 100644 --- a/src/application.rs +++ b/src/application.rs @@ -25,6 +25,8 @@ mod imp { window.present(); let mpris = crate::Mpris::new(&window); + let mpris_player = crate::mpris::Player::new(); + glib::spawn_future_local(async { // run this in glib's main loop let conn = zbus::connection::Builder::session() @@ -34,6 +36,8 @@ mod imp { .expect("could not register name in session bus") .serve_at("/org/mpris/MediaPlayer2", mpris) .expect("could not serve mpris") + .serve_at("/org/mpris/MediaPlayer2", mpris_player) + .expect("could not serve mpris player") .build() .await .expect("could not build dbus connection"); diff --git a/src/mpris/player.rs b/src/mpris/player.rs index 7282e96..3e6dba8 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -1,27 +1,147 @@ -mod ffi { - use gtk::glib; +use zbus::object_server::SignalEmitter; +use zbus::zvariant::{ObjectPath, Value}; - #[repr(C)] - pub struct AudreyMprisPlayer { - parent_instance: glib::gobject_ffi::GObject, - } +pub struct Player {} - #[repr(C)] - pub struct AudreyMprisClassPlayer { - parent_class: glib::gobject_ffi::GObjectClass, - } - - extern "C" { - pub fn audrey_mpris_player_get_type() -> glib::ffi::GType; +impl Player { + pub fn new() -> Self { + Self {} } } -use gtk::glib; +#[zbus::interface(name = "org.mpris.MediaPlayer2.Player")] +impl Player { + fn next(&self) { + todo!() + } -glib::wrapper! { - pub struct Player(Object); + fn previous(&self) { + todo!() + } - match fn { - type_ => || ffi::audrey_mpris_player_get_type(), + fn pause(&self) { + todo!() + } + + fn play_pause(&self) { + todo!() + } + + fn stop(&self) { + todo!() + } + + fn play(&self) { + todo!() + } + + fn seek(&self, _offset: i64) { + todo!() + } + + fn set_position(&self, _track_id: ObjectPath<'_>, _position: i64) { + todo!() + } + + fn open_uri(&self, _s: &str) { + todo!() + } + + #[zbus(signal)] + async fn seeked(signal_emitter: &SignalEmitter<'_>, position: i64) -> zbus::Result<()>; + + #[zbus(property)] + fn playback_status(&self) -> String { + "Stopped".into() // TODO + } + + #[zbus(property)] + fn loop_status(&self) -> String { + "None".into() // TODO + } + + #[zbus(property)] + fn set_loop_status(&self, _loop_status: &str) { + todo!() + } + + #[zbus(property)] + fn playback_rate(&self) -> f64 { + 1.0 + } + + #[zbus(property)] + fn set_playback_rate(&self, _playback_rate: f64) { + todo!() + } + + #[zbus(property)] + fn shuffle(&self) -> zbus::fdo::Result { + Err(zbus::fdo::Error::NotSupported("Shuffle".into())) + } + + #[zbus(property)] + fn set_shuffle(&self, _shuffle: bool) { + todo!() + } + + #[zbus(property)] + fn metadata(&self) -> Vec<(String, Value)> { + vec![] // TODO + } + + #[zbus(property)] + fn volume(&self) -> f64 { + 1.0 // TODO + } + + #[zbus(property)] + fn set_volume(&self, _volume: f64) { + todo!() + } + + #[zbus(property(emits_changed_signal = "false"))] + fn position(&self) -> i64 { + 0 // TODO + } + + #[zbus(property)] + fn minimum_rate(&self) -> f64 { + 1.0 + } + + #[zbus(property)] + fn maximum_rate(&self) -> f64 { + 1.0 + } + + #[zbus(property)] + fn can_go_next(&self) -> bool { + false // TODO + } + + #[zbus(property)] + fn can_go_previous(&self) -> bool { + false // TODO + } + + #[zbus(property)] + fn can_play(&self) -> bool { + false // TODO + } + + #[zbus(property)] + fn can_pause(&self) -> bool { + false // TODO + } + + #[zbus(property)] + fn can_seek(&self) -> bool { + false // TODO + } + + #[zbus(property(emits_changed_signal = "const"))] + fn can_control(&self) -> bool { + false // TODO } }