dbus.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #define VLC_MPRIS_VERSION_MAJOR 1
00027 #define VLC_MPRIS_VERSION_MINOR 0
00028
00029
00030
00031
00032 #define VLC_MPRIS_DBUS_SERVICE "org.mpris.vlc"
00033 #define MPRIS_DBUS_INTERFACE "org.freedesktop.MediaPlayer"
00034 #define MPRIS_DBUS_ROOT_PATH "/"
00035 #define MPRIS_DBUS_PLAYER_PATH "/Player"
00036 #define MPRIS_DBUS_TRACKLIST_PATH "/TrackList"
00037
00038
00039
00040 #define DBUS_METHOD( method_function ) \
00041 static DBusHandlerResult method_function \
00042 ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
00043
00044 #define DBUS_SIGNAL( signal_function ) \
00045 static DBusHandlerResult signal_function \
00046 ( DBusConnection *p_conn, void *p_data )
00047
00048 #define REPLY_INIT \
00049 DBusMessage* p_msg = dbus_message_new_method_return( p_from ); \
00050 if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
00051
00052 #define REPLY_SEND \
00053 if( !dbus_connection_send( p_conn, p_msg, NULL ) ) \
00054 return DBUS_HANDLER_RESULT_NEED_MEMORY; \
00055 dbus_connection_flush( p_conn ); \
00056 dbus_message_unref( p_msg ); \
00057 return DBUS_HANDLER_RESULT_HANDLED
00058
00059 #define SIGNAL_INIT( path, signal ) \
00060 DBusMessage *p_msg = dbus_message_new_signal( path, \
00061 MPRIS_DBUS_INTERFACE, signal ); \
00062 if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
00063
00064 #define SIGNAL_SEND \
00065 if( !dbus_connection_send( p_conn, p_msg, NULL ) ) \
00066 return DBUS_HANDLER_RESULT_NEED_MEMORY; \
00067 dbus_message_unref( p_msg ); \
00068 dbus_connection_flush( p_conn ); \
00069 return DBUS_HANDLER_RESULT_HANDLED
00070
00071 #define OUT_ARGUMENTS \
00072 DBusMessageIter args; \
00073 dbus_message_iter_init_append( p_msg, &args )
00074
00075 #define DBUS_ADD( dbus_type, value ) \
00076 if( !dbus_message_iter_append_basic( &args, dbus_type, value ) ) \
00077 return DBUS_HANDLER_RESULT_NEED_MEMORY
00078
00079 #define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s )
00080 #define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b )
00081 #define ADD_INT32( i ) DBUS_ADD( DBUS_TYPE_INT32, i )
00082 #define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b )
00083
00084
00085
00086 const char* psz_introspection_xml_data_root =
00087 "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
00088 "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
00089 "<node>\n"
00090 " <node name=\"Player\"/>\n"
00091 " <node name=\"TrackList\"/>\n"
00092 " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
00093 " <method name=\"Introspect\">\n"
00094 " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
00095 " </method>\n"
00096 " </interface>\n"
00097 " <interface name=\"org.freedesktop.MediaPlayer\">\n"
00098 " <method name=\"Identity\">\n"
00099 " <arg type=\"s\" direction=\"out\" />\n"
00100 " </method>\n"
00101 " <method name=\"MprisVersion\">\n"
00102 " <arg type=\"(qq)\" direction=\"out\" />\n"
00103 " </method>\n"
00104 " <method name=\"Quit\">\n"
00105 " </method>\n"
00106 " </interface>\n"
00107 "</node>\n"
00108 ;
00109
00110 const char* psz_introspection_xml_data_player =
00111 "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
00112 "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
00113 "<node>"
00114 " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
00115 " <method name=\"Introspect\">\n"
00116 " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
00117 " </method>\n"
00118 " </interface>\n"
00119 " <interface name=\"org.freedesktop.MediaPlayer\">\n"
00120 " <method name=\"GetStatus\">\n"
00121 " <arg type=\"(iiii)\" direction=\"out\" />\n"
00122 " </method>\n"
00123 " <method name=\"Prev\">\n"
00124 " </method>\n"
00125 " <method name=\"Next\">\n"
00126 " </method>\n"
00127 " <method name=\"Stop\">\n"
00128 " </method>\n"
00129 " <method name=\"Play\">\n"
00130 " </method>\n"
00131 " <method name=\"Pause\">\n"
00132 " </method>\n"
00133 " <method name=\"Repeat\">\n"
00134 " <arg type=\"b\" direction=\"in\" />\n"
00135 " </method>\n"
00136 " <method name=\"VolumeSet\">\n"
00137 " <arg type=\"i\" direction=\"in\" />\n"
00138 " </method>\n"
00139 " <method name=\"VolumeGet\">\n"
00140 " <arg type=\"i\" direction=\"out\" />\n"
00141 " </method>\n"
00142 " <method name=\"PositionSet\">\n"
00143 " <arg type=\"i\" direction=\"in\" />\n"
00144 " </method>\n"
00145 " <method name=\"PositionGet\">\n"
00146 " <arg type=\"i\" direction=\"out\" />\n"
00147 " </method>\n"
00148 " <method name=\"GetMetadata\">\n"
00149 " <arg type=\"a{sv}\" direction=\"out\" />\n"
00150 " </method>\n"
00151 " <method name=\"GetCaps\">\n"
00152 " <arg type=\"i\" direction=\"out\" />\n"
00153 " </method>\n"
00154 " <signal name=\"TrackChange\">\n"
00155 " <arg type=\"a{sv}\"/>\n"
00156 " </signal>\n"
00157 " <signal name=\"StatusChange\">\n"
00158 " <arg type=\"(iiii)\"/>\n"
00159 " </signal>\n"
00160 " <signal name=\"CapsChange\">\n"
00161 " <arg type=\"i\"/>\n"
00162 " </signal>\n"
00163 " </interface>\n"
00164 "</node>\n"
00165 ;
00166
00167 const char* psz_introspection_xml_data_tracklist =
00168 "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
00169 "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
00170 "<node>"
00171 " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
00172 " <method name=\"Introspect\">\n"
00173 " <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
00174 " </method>\n"
00175 " </interface>\n"
00176 " <interface name=\"org.freedesktop.MediaPlayer\">\n"
00177 " <method name=\"AddTrack\">\n"
00178 " <arg type=\"s\" direction=\"in\" />\n"
00179 " <arg type=\"b\" direction=\"in\" />\n"
00180 " <arg type=\"i\" direction=\"out\" />\n"
00181 " </method>\n"
00182 " <method name=\"DelTrack\">\n"
00183 " <arg type=\"i\" direction=\"in\" />\n"
00184 " </method>\n"
00185 " <method name=\"GetMetadata\">\n"
00186 " <arg type=\"i\" direction=\"in\" />\n"
00187 " <arg type=\"a{sv}\" direction=\"out\" />\n"
00188 " </method>\n"
00189 " <method name=\"GetCurrentTrack\">\n"
00190 " <arg type=\"i\" direction=\"out\" />\n"
00191 " </method>\n"
00192 " <method name=\"GetLength\">\n"
00193 " <arg type=\"i\" direction=\"out\" />\n"
00194 " </method>\n"
00195 " <method name=\"SetLoop\">\n"
00196 " <arg type=\"b\" direction=\"in\" />\n"
00197 " </method>\n"
00198 " <method name=\"SetRandom\">\n"
00199 " <arg type=\"b\" direction=\"in\" />\n"
00200 " </method>\n"
00201 " <signal name=\"TrackListChange\">\n"
00202 " <arg type=\"i\" />\n"
00203 " </signal>\n"
00204 " </interface>\n"
00205 "</node>\n"
00206 ;
00207
00208
00209
00210 DBUS_METHOD( handle_root );
00211 DBUS_METHOD( handle_player );
00212 DBUS_METHOD( handle_tracklist );
00213
00214 static const DBusObjectPathVTable vlc_dbus_root_vtable = {
00215 NULL, handle_root,
00216 NULL, NULL, NULL, NULL
00217 };
00218
00219 static const DBusObjectPathVTable vlc_dbus_player_vtable = {
00220 NULL, handle_player,
00221 NULL, NULL, NULL, NULL
00222 };
00223
00224 static const DBusObjectPathVTable vlc_dbus_tracklist_vtable = {
00225 NULL, handle_tracklist,
00226 NULL, NULL, NULL, NULL
00227 };
00228