From 3112266f448e582b06d46034748fc80d71e4d7b1 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 2 Feb 2018 16:08:20 +0900 Subject: Add getListMainSources function This function gets the source list registered in AudioManager. Change-Id: I630200b8aaba1f6049773d183904086277624121 Signed-off-by: Kazumasa Mitsunari --- src/dbus/audio_manager_interface.c | 194 +++++++++++++++++++++++++++++++++++++ src/dbus/audio_manager_interface.h | 30 ++++++ src/dbus/command_interface.xml | 6 +- 3 files changed, 229 insertions(+), 1 deletion(-) (limited to 'src/dbus') diff --git a/src/dbus/audio_manager_interface.c b/src/dbus/audio_manager_interface.c index c276d70..15ad786 100644 --- a/src/dbus/audio_manager_interface.c +++ b/src/dbus/audio_manager_interface.c @@ -542,6 +542,48 @@ static const _ExtendedGDBusMethodInfo _audiomanager_commandinterface_method_info FALSE }; +static const _ExtendedGDBusArgInfo _audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_result = +{ + { + -1, + (gchar *) "result", + (gchar *) "n", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo _audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_listMainSources = +{ + { + -1, + (gchar *) "listMainSources", + (gchar *) "a(qs(nn)q)", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo * const _audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_pointers[] = +{ + &_audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_result, + &_audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_listMainSources, + NULL +}; + +static const _ExtendedGDBusMethodInfo _audiomanager_commandinterface_method_info_get_list_main_sources = +{ + { + -1, + (gchar *) "GetListMainSources", + NULL, + (GDBusArgInfo **) &_audiomanager_commandinterface_method_info_get_list_main_sources_OUT_ARG_pointers, + NULL + }, + "handle-get-list-main-sources", + FALSE +}; + static const _ExtendedGDBusMethodInfo * const _audiomanager_commandinterface_method_info_pointers[] = { &_audiomanager_commandinterface_method_info_connect, @@ -551,6 +593,7 @@ static const _ExtendedGDBusMethodInfo * const _audiomanager_commandinterface_met &_audiomanager_commandinterface_method_info_set_sink_mute_state, &_audiomanager_commandinterface_method_info_get_list_main_connections, &_audiomanager_commandinterface_method_info_get_list_main_sinks, + &_audiomanager_commandinterface_method_info_get_list_main_sources, NULL }; @@ -827,6 +870,7 @@ audiomanager_commandinterface_override_properties (GObjectClass *klass, guint pr * @handle_disconnect: Handler for the #AudiomanagerCommandinterface::handle-disconnect signal. * @handle_get_list_main_connections: Handler for the #AudiomanagerCommandinterface::handle-get-list-main-connections signal. * @handle_get_list_main_sinks: Handler for the #AudiomanagerCommandinterface::handle-get-list-main-sinks signal. + * @handle_get_list_main_sources: Handler for the #AudiomanagerCommandinterface::handle-get-list-main-sources signal. * @handle_set_sink_mute_state: Handler for the #AudiomanagerCommandinterface::handle-set-sink-mute-state signal. * @handle_set_volume: Handler for the #AudiomanagerCommandinterface::handle-set-volume signal. * @handle_volume_step: Handler for the #AudiomanagerCommandinterface::handle-volume-step signal. @@ -1010,6 +1054,28 @@ audiomanager_commandinterface_default_init (AudiomanagerCommandinterfaceIface *i 1, G_TYPE_DBUS_METHOD_INVOCATION); + /** + * AudiomanagerCommandinterface::handle-get-list-main-sources: + * @object: A #AudiomanagerCommandinterface. + * @invocation: A #GDBusMethodInvocation. + * + * Signal emitted when a remote caller is invoking the GetListMainSources() D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call audiomanager_commandinterface_complete_get_list_main_sources() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-get-list-main-sources", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AudiomanagerCommandinterfaceIface, handle_get_list_main_sources), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 1, + G_TYPE_DBUS_METHOD_INVOCATION); + /* GObject signals for received D-Bus signals: */ /** * AudiomanagerCommandinterface::new-main-connection: @@ -1984,6 +2050,110 @@ _out: return _ret != NULL; } +/** + * audiomanager_commandinterface_call_get_list_main_sources: + * @proxy: A #AudiomanagerCommandinterfaceProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the GetListMainSources() D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call audiomanager_commandinterface_call_get_list_main_sources_finish() to get the result of the operation. + * + * See audiomanager_commandinterface_call_get_list_main_sources_sync() for the synchronous, blocking version of this method. + */ +void +audiomanager_commandinterface_call_get_list_main_sources ( + AudiomanagerCommandinterface *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "GetListMainSources", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * audiomanager_commandinterface_call_get_list_main_sources_finish: + * @proxy: A #AudiomanagerCommandinterfaceProxy. + * @out_result: (out): Return location for return parameter or %NULL to ignore. + * @out_listMainSources: (out): Return location for return parameter or %NULL to ignore. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to audiomanager_commandinterface_call_get_list_main_sources(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with audiomanager_commandinterface_call_get_list_main_sources(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +audiomanager_commandinterface_call_get_list_main_sources_finish ( + AudiomanagerCommandinterface *proxy, + gint16 *out_result, + GVariant **out_listMainSources, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "(n@a(qs(nn)q))", + out_result, + out_listMainSources); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * audiomanager_commandinterface_call_get_list_main_sources_sync: + * @proxy: A #AudiomanagerCommandinterfaceProxy. + * @out_result: (out): Return location for return parameter or %NULL to ignore. + * @out_listMainSources: (out): Return location for return parameter or %NULL to ignore. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the GetListMainSources() D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See audiomanager_commandinterface_call_get_list_main_sources() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +audiomanager_commandinterface_call_get_list_main_sources_sync ( + AudiomanagerCommandinterface *proxy, + gint16 *out_result, + GVariant **out_listMainSources, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "GetListMainSources", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "(n@a(qs(nn)q))", + out_result, + out_listMainSources); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + /** * audiomanager_commandinterface_complete_connect: * @object: A #AudiomanagerCommandinterface. @@ -2140,6 +2310,30 @@ audiomanager_commandinterface_complete_get_list_main_sinks ( listMainSinks)); } +/** + * audiomanager_commandinterface_complete_get_list_main_sources: + * @object: A #AudiomanagerCommandinterface. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * @result: Parameter to return. + * @listMainSources: Parameter to return. + * + * Helper function used in service implementations to finish handling invocations of the GetListMainSources() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +audiomanager_commandinterface_complete_get_list_main_sources ( + AudiomanagerCommandinterface *object, + GDBusMethodInvocation *invocation, + gint16 result, + GVariant *listMainSources) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("(n@a(qs(nn)q))", + result, + listMainSources)); +} + /* ------------------------------------------------------------------------ */ /** diff --git a/src/dbus/audio_manager_interface.h b/src/dbus/audio_manager_interface.h index c2568f1..f43bceb 100644 --- a/src/dbus/audio_manager_interface.h +++ b/src/dbus/audio_manager_interface.h @@ -48,6 +48,10 @@ struct _AudiomanagerCommandinterfaceIface AudiomanagerCommandinterface *object, GDBusMethodInvocation *invocation); + gboolean (*handle_get_list_main_sources) ( + AudiomanagerCommandinterface *object, + GDBusMethodInvocation *invocation); + gboolean (*handle_set_sink_mute_state) ( AudiomanagerCommandinterface *object, GDBusMethodInvocation *invocation, @@ -140,6 +144,12 @@ void audiomanager_commandinterface_complete_get_list_main_sinks ( gint16 result, GVariant *listMainSinks); +void audiomanager_commandinterface_complete_get_list_main_sources ( + AudiomanagerCommandinterface *object, + GDBusMethodInvocation *invocation, + gint16 result, + GVariant *listMainSources); + /* D-Bus signal emissions functions: */ @@ -323,6 +333,26 @@ gboolean audiomanager_commandinterface_call_get_list_main_sinks_sync ( GCancellable *cancellable, GError **error); +void audiomanager_commandinterface_call_get_list_main_sources ( + AudiomanagerCommandinterface *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean audiomanager_commandinterface_call_get_list_main_sources_finish ( + AudiomanagerCommandinterface *proxy, + gint16 *out_result, + GVariant **out_listMainSources, + GAsyncResult *res, + GError **error); + +gboolean audiomanager_commandinterface_call_get_list_main_sources_sync ( + AudiomanagerCommandinterface *proxy, + gint16 *out_result, + GVariant **out_listMainSources, + GCancellable *cancellable, + GError **error); + /* ---- */ diff --git a/src/dbus/command_interface.xml b/src/dbus/command_interface.xml index e33d7fb..2be9ba2 100644 --- a/src/dbus/command_interface.xml +++ b/src/dbus/command_interface.xml @@ -32,9 +32,13 @@ - + + + + + -- cgit 1.2.3-korg