Mercurial > audlegacy
changeset 3268:8af43e099cce trunk
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
author | Ben Tucker <ben.tucker@gmail.com> |
---|---|
date | Sat, 04 Aug 2007 01:13:08 -0700 |
parents | 21c583c5b71d |
children | 91dd21cce4a5 |
files | src/audacious/dbus-service.h src/audacious/dbus.c src/audacious/dbus.h src/audacious/mpris_player.xml |
diffstat | 4 files changed, 71 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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
--- 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
--- 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 @@ <method name="Play"> <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> </method> + <method name="Repeat"> + <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> + <arg type="b" direction="in" /> + </method> <method name="Quit"> <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> </method> <method name="Disconnect"> <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> </method> - <method name="Repeat"> - <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> - <arg type="b" direction="in" /> - </method> - <method name="GetStatus"> <arg type="i" direction="out" /> </method> - <method name="GetMetadata"> <arg type="a{sv}" direction="out" /> </method> - <method name="GetCaps"> <arg type="i" direction="out" /> </method> - <method name="VolumeSet"> <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> <arg type="i" direction="in" /> </method> - <method name="VolumeGet"> <arg type="i" direction="out" /> </method> - <method name="PositionSet"> <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> <arg type="i" direction="in" /> </method> - <method name="PositionGet"> <arg type="i" direction="out" /> </method> - <signal name="CapsChange"> - <arg type="i" /> - </signal> - <signal name="TrackChange"> <arg type="a{sv}" /> </signal> - <signal name="StatusChange"> <arg type="i" /> </signal> - - <signal name="Disconnected"> + <signal name="CapsChange"> + <arg type="i" /> </signal> + <signal name="Disconnected" /> </interface> </node>