# HG changeset patch # User Ben Tucker # Date 1186215188 25200 # Node ID 8af43e099ccea4336889c4b606d391d427b774e6 # Parent 21c583c5b71d7e11962e7fe00a3c5732f2c4b61a Added function prototypes for Disconnect and GetMetadata methods, and a prototype for the Disconnected signal. Modified the MPRIS functions so that they complete their task directly instead of calling the legacy DBus functions. Implemented the /TrackList GetLength, DelTrack, and Random methods diff -r 21c583c5b71d -r 8af43e099cce src/audacious/dbus-service.h --- a/src/audacious/dbus-service.h Fri Aug 03 17:47:07 2007 -0700 +++ b/src/audacious/dbus-service.h Sat Aug 04 01:13:08 2007 -0700 @@ -51,10 +51,13 @@ gboolean mpris_player_pause(MprisPlayer *obj, GError **error); gboolean mpris_player_stop(MprisPlayer *obj, GError **error); gboolean mpris_player_play(MprisPlayer *obj, GError **error); +gboolean mpris_player_repeat(MprisPlayer *obj, gboolean rpt, GError **error); gboolean mpris_player_quit(MprisPlayer *obj, GError **error); -gboolean mpris_player_repeat(MprisPlayer *obj, gboolean rpt, GError **error); +gboolean mpris_player_disconnect(MprisPlayer *obj, GError **error); gboolean mpris_player_get_status(MprisPlayer *obj, gint *status, GError **error); +gboolean mpris_player_get_metadata(MprisTrackList *obj, gint pos, + GHashTable *metadata, GError **error); gboolean mpris_player_get_caps(MprisPlayer *obj, gint *capabilities, GError **error); gboolean mpris_player_volume_set(MprisPlayer *obj, gint vol, GError **error); @@ -64,21 +67,23 @@ gboolean mpris_player_position_get(MprisPlayer *obj, gint *pos, GError **error); enum { - CAPS_CHANGE_SIG, TRACK_CHANGE_SIG, STATUS_CHANGE_SIG, + CAPS_CHANGE_SIG, + DISCONNECTED, LAST_SIG }; -gboolean mpris_player_emit_caps_change(MprisPlayer *obj, GError **error); gboolean mpris_player_emit_track_change(MprisPlayer *obj, GError **error); gboolean mpris_player_emit_status_change(MprisPlayer *obj, GError **error); +gboolean mpris_player_emit_caps_change(MprisPlayer *obj, GError **error); +gboolean mpris_player_emit_disconnected(MprisPlayer *obj, GError **error); // MPRIS /TrackList gboolean mpris_tracklist_get_metadata(MprisTrackList *obj, gint pos, GHashTable *metadata, GError **error); gboolean mpris_tracklist_get_current_track(MprisTrackList *obj, gint *pos, GError **error); -gboolean mpris_tracklist_get_length(MprisTrackList *obj, gint *pos, +gboolean mpris_tracklist_get_length(MprisTrackList *obj, gint *length, GError **error); gboolean mpris_tracklist_add_track(MprisTrackList *obj, gchar *uri, gboolean play, GError **error); diff -r 21c583c5b71d -r 8af43e099cce src/audacious/dbus.c --- a/src/audacious/dbus.c Fri Aug 03 17:47:07 2007 -0700 +++ b/src/audacious/dbus.c Sat Aug 04 01:13:08 2007 -0700 @@ -175,32 +175,54 @@ // MPRIS /Player gboolean mpris_player_next(MprisPlayer *obj, GError **error) { - return audacious_rc_advance(obj, error); + playlist_next(playlist_get_active()); + return TRUE; } gboolean mpris_player_prev(MprisPlayer *obj, GError **error) { - return audacious_rc_reverse(obj, error); + playlist_prev(playlist_get_active()); + return TRUE; } gboolean mpris_player_pause(MprisPlayer *obj, GError **error) { - return audacious_rc_pause(obj, error); + playback_pause(); + return TRUE; } gboolean mpris_player_stop(MprisPlayer *obj, GError **error) { - return audacious_rc_stop(obj, error); + ip_data.stop = TRUE; + playback_stop(); + ip_data.stop = FALSE; + mainwin_clear_song_info(); + return TRUE; } gboolean mpris_player_play(MprisPlayer *obj, GError **error) { - return audacious_rc_play(obj, error); -} -gboolean mpris_player_quit(MprisPlayer *obj, GError **error) { - return audacious_rc_quit(obj, error); + if (playback_get_paused()) + playback_pause(); + else if (playlist_get_length(playlist_get_active())) + playback_initiate(); + else + mainwin_eject_pushed(); + return TRUE; } gboolean mpris_player_repeat(MprisPlayer *obj, gboolean rpt, GError **error) { mainwin_repeat_pushed(rpt); mainwin_set_noplaylistadvance(rpt); return TRUE; } +gboolean mpris_player_quit(MprisPlayer *obj, GError **error) { + // TODO: emit disconnected signal + mainwin_quit_cb(); + return TRUE; +} +gboolean mpris_player_disconnect(MprisPlayer *obj, GError **error) { + return FALSE; +} gboolean mpris_player_get_status(MprisPlayer *obj, gint *status, GError **error) { return FALSE; } +gboolean mpris_player_get_metadata(MprisTrackList *obj, gint pos, + GHashTable *metadata, GError **error) { + return FALSE; +} gboolean mpris_player_get_caps(MprisPlayer *obj, gint *capabilities, GError **error) { return FALSE; @@ -236,6 +258,11 @@ return TRUE; } +gboolean mpris_player_emit_disconnected(MprisPlayer *obj, GError **error) { + g_signal_emit(obj, signals[DISCONNECTED], 0, NULL); + return TRUE; +} + // MPRIS /TrackList gboolean mpris_tracklist_get_metadata(MprisTrackList *obj, gint pos, GHashTable *metadata, GError **error) { @@ -243,11 +270,13 @@ } gboolean mpris_tracklist_get_current_track(MprisTrackList *obj, gint *pos, GError **error) { - return audacious_rc_position(obj, pos, error); + *pos = playlist_get_position(playlist_get_active()); + return TRUE; } -gboolean mpris_tracklist_get_length(MprisTrackList *obj, gint *pos, +gboolean mpris_tracklist_get_length(MprisTrackList *obj, gint *length, GError **error) { - return FALSE; + *length = playlist_get_length(playlist_get_active()); + return TRUE; } gboolean mpris_tracklist_add_track(MprisTrackList *obj, gchar *uri, gboolean play, GError **error) { @@ -261,7 +290,8 @@ } gboolean mpris_tracklist_del_track(MprisTrackList *obj, gint pos, GError **error) { - return FALSE; + playlist_delete_index(playlist_get_active(), pos); + return TRUE; } gboolean mpris_tracklist_loop(MprisTrackList *obj, gboolean loop, GError **error) { @@ -269,7 +299,8 @@ } gboolean mpris_tracklist_random(MprisTrackList *obj, gboolean random, GError **error) { - return FALSE; + mainwin_shuffle_pushed(!cfg.shuffle); + return TRUE; } // Audacious General Information diff -r 21c583c5b71d -r 8af43e099cce src/audacious/dbus.h --- a/src/audacious/dbus.h Fri Aug 03 17:47:07 2007 -0700 +++ b/src/audacious/dbus.h Sat Aug 04 01:13:08 2007 -0700 @@ -30,4 +30,15 @@ #define AUDACIOUS_DBUS_PATH_MPRIS_PLAYER "/Player" #define AUDACIOUS_DBUS_PATH_MPRIS_TRACKLIST "/TrackList" +#define NONE = 0 +#define CAN_GO_NEXT = 1 << 0 +#define CAN_GO_PREV = 1 << 1 +#define CAN_PAUSE = 1 << 2 +#define CAN_PLAY = 1 << 3 +#define CAN_SEEK = 1 << 4 +#define CAN_RESTORE_CONTEXT = 1 << 5 +#define CAN_PROVIDE_METADATA = 1 << 6 +#define PROVIDES_TIMING = 1 << 7 + + #endif // !_AUDDBUS_H diff -r 21c583c5b71d -r 8af43e099cce src/audacious/mpris_player.xml --- a/src/audacious/mpris_player.xml Fri Aug 03 17:47:07 2007 -0700 +++ b/src/audacious/mpris_player.xml Sat Aug 04 01:13:08 2007 -0700 @@ -35,60 +35,49 @@ + + + + - - - - - - - - - - - - - - - - - - + + +