X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcontrol%2Fdbus.h;h=40dfde1037f465e62c30887eff8239f948df7df9;hb=4e9597b800d1140dfab1cf33c3df8c608d58878f;hp=7f629705b17e2a54a366be84e64fae806f566916;hpb=e77b5163a51dde46815bea3ae41537525498d4c4;p=vlc diff --git a/modules/control/dbus.h b/modules/control/dbus.h index 7f629705b1..40dfde1037 100644 --- a/modules/control/dbus.h +++ b/modules/control/dbus.h @@ -4,7 +4,8 @@ * Copyright (C) 2006 Rafaël Carré * $Id$ * - * Author: Rafaël Carré + * Authors: Rafaël Carré + * Mirsal ENNAIME * * 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 @@ -21,11 +22,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +/* MPRIS VERSION */ +#define VLC_MPRIS_VERSION_MAJOR 1 +#define VLC_MPRIS_VERSION_MINOR 0 + +/* DBUS IDENTIFIERS */ + +/* 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 */ #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 \ @@ -34,24 +48,22 @@ #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 @@ -66,36 +78,47 @@ #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 ) /* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */ -const char* psz_introspection_xml_data = +const char* psz_introspection_xml_data_root = "\n" -"" +"\n" +" \n" +" \n" " \n" " \n" " \n" " \n" " \n" -" \n" -" \n" -" \n" -" \n" -" \n" +" \n" +" \n" " \n" " \n" -" \n" -" \n" +" \n" +" \n" " \n" -" \n" -" \n" -" \n" +" \n" " \n" -" \n" +" \n" +"\n" +; + +const char* psz_introspection_xml_data_player = +"\n" +"" +" \n" +" \n" +" \n" " \n" -" \n" +" \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" @@ -103,20 +126,106 @@ const char* psz_introspection_xml_data = " \n" " \n" " \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +; + +const char* psz_introspection_xml_data_tracklist = +"\n" +"" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" " \n" "\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 };