* Copyright (C) 2006 Rafaël Carré
* $Id$
*
- * Author: Rafaël Carré <funman at videolanorg>
+ * Authors: Rafaël Carré <funman at videolanorg>
+ * Mirsal ENNAIME <mirsal dot ennaime at gmail dot com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* DBUS IDENTIFIERS */
-#define VLC_DBUS_SERVICE "org.videolan.vlc"
-#define VLC_DBUS_INTERFACE "org.videolan.vlc"
-#define VLC_DBUS_OBJECT_PATH "/org/videolan/vlc"
+/* name registered on the session bus */
+#define VLC_MPRIS_DBUS_SERVICE "org.mpris.vlc"
+#define MPRIS_DBUS_INTERFACE "org.freedesktop.MediaPlayer"
+#define MPRIS_DBUS_ROOT_PATH "/"
+#define MPRIS_DBUS_PLAYER_PATH "/Player"
+#define MPRIS_DBUS_TRACKLIST_PATH "/TrackList"
/* MACROS */
+/* DBus related */
#define DBUS_METHOD( method_function ) \
static DBusHandlerResult method_function \
- ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
+ ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
#define DBUS_SIGNAL( signal_function ) \
static DBusHandlerResult signal_function \
#define REPLY_INIT \
DBusMessage* p_msg = dbus_message_new_method_return( p_from ); \
if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
- dbus_uint32_t i_serial = 0
#define REPLY_SEND \
- if( !dbus_connection_send( p_conn, p_msg, &i_serial ) ) \
+ if( !dbus_connection_send( p_conn, p_msg, NULL ) ) \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
dbus_connection_flush( p_conn ); \
dbus_message_unref( p_msg ); \
return DBUS_HANDLER_RESULT_HANDLED
#define SIGNAL_INIT( signal ) \
- DBusMessage *p_msg = dbus_message_new_signal( VLC_DBUS_OBJECT_PATH, \
- VLC_DBUS_INTERFACE, signal ); \
+ DBusMessage *p_msg = dbus_message_new_signal( MPRIS_DBUS_PLAYER_PATH, \
+ MPRIS_DBUS_INTERFACE, signal ); \
if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
- dbus_uint32_t i_serial = 0
#define SIGNAL_SEND \
- if( !dbus_connection_send( p_conn, p_msg, &i_serial ) ) \
- return DBUS_HANDLER_RESULT_NEED_MEMORY; \
+ if( !dbus_connection_send( p_conn, p_msg, NULL ) ) \
+ return DBUS_HANDLER_RESULT_NEED_MEMORY; \
dbus_message_unref( p_msg ); \
dbus_connection_flush( p_conn ); \
return DBUS_HANDLER_RESULT_HANDLED
#define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s )
#define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b )
-#define ADD_UINT32( i ) DBUS_ADD( DBUS_TYPE_UINT32, i )
+#define ADD_INT32( i ) DBUS_ADD( DBUS_TYPE_INT32, i )
+#define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b )
+
+/* VLC related */
+#define TEST_NEXT \
+ p_tested_item = playlist_GetNextLeaf( p_playlist, \
+ p_playlist->p_root_onelevel, p_tested_item, VLC_FALSE, VLC_FALSE );
/* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */
-const char* psz_introspection_xml_data =
+const char* psz_introspection_xml_data_root =
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
-"<node>"
+"<node>\n"
+" <node name=\"Player\"/>\n"
+" <node name=\"TrackList\"/>\n"
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <method name=\"Introspect\">\n"
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" </interface>\n"
-" <interface name=\"org.videolan.vlc\">\n"
-" <method name=\"GetPlayStatus\">\n"
+" <interface name=\"org.freedesktop.MediaPlayer\">\n"
+" <method name=\"Identity\">\n"
" <arg type=\"s\" direction=\"out\" />\n"
" </method>\n"
-" <method name=\"TogglePause\">\n"
-" <arg type=\"s\" direction=\"out\" />\n"
+" </interface>\n"
+"</node>\n"
+;
+
+const char* psz_introspection_xml_data_player =
+"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+"<node>"
+" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+" <method name=\"Introspect\">\n"
+" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
+" </method>\n"
+" </interface>\n"
+" <interface name=\"org.freedesktop.MediaPlayer\">\n"
+" <method name=\"GetStatus\">\n"
+" <arg type=\"i\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"Quit\">\n"
+" </method>\n"
+" <method name=\"Prev\">\n"
+" </method>\n"
+" <method name=\"Next\">\n"
+" </method>\n"
+" <method name=\"Stop\">\n"
+" </method>\n"
+" <method name=\"Play\">\n"
+" </method>\n"
+" <method name=\"Pause\">\n"
+" </method>\n"
+" <method name=\"Repeat\">\n"
+" <arg type=\"b\" direction=\"in\" />\n"
+" </method>\n"
+" <method name=\"VolumeSet\">\n"
+" <arg type=\"i\" direction=\"in\" />\n"
+" </method>\n"
+" <method name=\"VolumeGet\">\n"
+" <arg type=\"i\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"PositionSet\">\n"
+" <arg type=\"i\" direction=\"in\" />\n"
" </method>\n"
-" <method name=\"AddMRL\">\n"
+" <method name=\"PositionGet\">\n"
+" <arg type=\"i\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"GetMetadata\">\n"
+" <arg type=\"a{sv}\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"Disconnect\">\n"
+" </method>\n"
+" <signal name=\"TrackChange\">\n"
+" <arg type=\"a{sv}\"/>\n"
+" </signal>\n"
+" <signal name=\"StatusChange\">\n"
+" <arg type=\"i\"/>\n"
+" </signal>\n"
+" <signal name=\"CapsChange\">\n"
+" <arg type=\"i\"/>\n"
+" </signal>\n"
+" </interface>\n"
+"</node>\n"
+;
+
+const char* psz_introspection_xml_data_tracklist =
+"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
+"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+"<node>"
+" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+" <method name=\"Introspect\">\n"
+" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
+" </method>\n"
+" </interface>\n"
+" <interface name=\"org.freedesktop.MediaPlayer\">\n"
+" <method name=\"AddTrack\">\n"
" <arg type=\"s\" direction=\"in\" />\n"
" <arg type=\"b\" direction=\"in\" />\n"
" </method>\n"
-" <method name=\"Nothing\">\n"
+" <method name=\"DelTrack\">\n"
+" <arg type=\"i\" direction=\"in\" />\n"
" </method>\n"
-" <method name=\"Quit\">\n"
+" <method name=\"GetMetadata\">\n"
+" <arg type=\"i\" direction=\"in\" />\n"
+" <arg type=\"a{sv}\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"GetCurrentTrack\">\n"
+" <arg type=\"i\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"GetLength\">\n"
+" <arg type=\"i\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"Loop\">\n"
+" <arg type=\"b\" direction=\"in\" />\n"
+" </method>\n"
+" <method name=\"Random\">\n"
+" <arg type=\"b\" direction=\"in\" />\n"
" </method>\n"
" </interface>\n"
"</node>\n"
;
-/* Handling of messages received onn VLC_DBUS_OBJECT_PATH */
-DBUS_METHOD( handle_messages ); /* handler function */
-
-/* vtable passed to dbus_connection_register_object_path() */
-static DBusObjectPathVTable vlc_dbus_vtable = {
- NULL, /* Called when vtable is unregistered or its connection is freed*/
- handle_messages, /* handler function */
- NULL,
- NULL,
- NULL,
- NULL
+#define MPRIS_DBUS_ROOT_PATH "/"
+#define MPRIS_DBUS_PLAYER_PATH "/Player"
+#define MPRIS_DBUS_TRACKLIST_PATH "/TrackList"
+
+/* Handle messages reception */
+DBUS_METHOD( handle_root );
+DBUS_METHOD( handle_player );
+DBUS_METHOD( handle_tracklist );
+
+static DBusObjectPathVTable vlc_dbus_root_vtable = {
+ NULL, handle_root, /* handler function */
+ NULL, NULL, NULL, NULL
+};
+
+static DBusObjectPathVTable vlc_dbus_player_vtable = {
+ NULL, handle_player, /* handler function */
+ NULL, NULL, NULL, NULL
+};
+
+static DBusObjectPathVTable vlc_dbus_tracklist_vtable = {
+ NULL, handle_tracklist, /* handler function */
+ NULL, NULL, NULL, NULL
};