X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcontrol%2Fdbus.h;h=4b681b2756102d61661a84f6561a487f8392cfb9;hb=6ee1e193fd896ab9a4729fde14f009d9ce629815;hp=0acf53dd7961725d24b7b69ebf60be7c3d6fdc18;hpb=5593777b3f5a3fbf9c710870646d35bf3d543cc1;p=vlc diff --git a/modules/control/dbus.h b/modules/control/dbus.h index 0acf53dd79..4b681b2756 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 @@ -23,15 +24,19 @@ /* 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 \ @@ -40,24 +45,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 @@ -72,36 +75,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_UINT16( i ) DBUS_ADD( DBUS_TYPE_UINT16, 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 = "\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" @@ -111,32 +125,101 @@ 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" +" \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" ; -/* 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 };