mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	introspect: add api get daemon info
This commit is contained in:
		
							parent
							
								
									31da833069
								
							
						
					
					
						commit
						191909cb05
					
				
					 2 changed files with 112 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,7 +28,83 @@
 | 
				
			||||||
#include "client/private.h"
 | 
					#include "client/private.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
 | 
					daemon_fill_info (PinosDaemonInfo *info, GDBusProxy *proxy)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GVariant *variant;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  info->id = proxy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "UserName"))) {
 | 
				
			||||||
 | 
					    info->user_name = g_variant_get_string (variant, NULL);
 | 
				
			||||||
 | 
					    g_variant_unref (variant);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    info->user_name = "Unknown";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "HostName"))) {
 | 
				
			||||||
 | 
					    info->host_name = g_variant_get_string (variant, NULL);
 | 
				
			||||||
 | 
					    g_variant_unref (variant);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    info->host_name = "Unknown";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Version"))) {
 | 
				
			||||||
 | 
					    info->version = g_variant_get_string (variant, NULL);
 | 
				
			||||||
 | 
					    g_variant_unref (variant);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    info->version = "Unknown";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Name"))) {
 | 
				
			||||||
 | 
					    info->name = g_variant_get_string (variant, NULL);
 | 
				
			||||||
 | 
					    g_variant_unref (variant);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    info->name = "Unknown";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Cookie"))) {
 | 
				
			||||||
 | 
					    info->cookie = g_variant_get_uint32 (variant);
 | 
				
			||||||
 | 
					    g_variant_unref (variant);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    info->cookie = 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  info->properties = pinos_properties_from_variant (
 | 
				
			||||||
 | 
					      g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Properties"));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					daemon_clear_info (PinosDaemonInfo *info)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (info->properties)
 | 
				
			||||||
 | 
					    pinos_properties_free (info->properties);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * pinos_context_get_daemon_info:
 | 
				
			||||||
 | 
					 * @context: a #PinosContext
 | 
				
			||||||
 | 
					 * @flags: extra flags
 | 
				
			||||||
 | 
					 * @cb: a callback
 | 
				
			||||||
 | 
					 * @cancelable: a #GCancellable
 | 
				
			||||||
 | 
					 * @user_data: user data passed to @cb
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Get the information of the daemon @context is connected to.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					pinos_context_get_daemon_info (PinosContext *context,
 | 
				
			||||||
 | 
					                               PinosDaemonInfoFlags flags,
 | 
				
			||||||
 | 
					                               PinosDaemonInfoCallback cb,
 | 
				
			||||||
 | 
					                               GCancellable *cancellable,
 | 
				
			||||||
 | 
					                               gpointer user_data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PinosDaemonInfo info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_return_if_fail (PINOS_IS_CONTEXT (context));
 | 
				
			||||||
 | 
					  g_return_if_fail (cb != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  daemon_fill_info (&info, context->priv->daemon);
 | 
				
			||||||
 | 
					  cb (context, &info, user_data);
 | 
				
			||||||
 | 
					  daemon_clear_info (&info);
 | 
				
			||||||
 | 
					  cb (context, NULL, user_data);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					client_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  GVariant *variant;
 | 
					  GVariant *variant;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,41 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
G_BEGIN_DECLS
 | 
					G_BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * PinosDeamonInfo:
 | 
				
			||||||
 | 
					 * @id: generic id of the daemon
 | 
				
			||||||
 | 
					 * @user_name: name of the user that started the daemon
 | 
				
			||||||
 | 
					 * @host_name: name of the machine the daemon is running on
 | 
				
			||||||
 | 
					 * @version: version of the daemon
 | 
				
			||||||
 | 
					 * @name: name of the daemon
 | 
				
			||||||
 | 
					 * @cookie: a random cookie for identifying this instance of Pinos
 | 
				
			||||||
 | 
					 * @properties: extra properties
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * The daemon information. Extra information can be added in later
 | 
				
			||||||
 | 
					 * versions.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					  gpointer id;
 | 
				
			||||||
 | 
					  const char *user_name;
 | 
				
			||||||
 | 
					  const char *host_name;
 | 
				
			||||||
 | 
					  const char *version;
 | 
				
			||||||
 | 
					  const char *name;
 | 
				
			||||||
 | 
					  guint32 cookie;
 | 
				
			||||||
 | 
					  PinosProperties *properties;
 | 
				
			||||||
 | 
					} PinosDaemonInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef enum {
 | 
				
			||||||
 | 
					  PINOS_DAEMON_INFO_FLAGS_NONE            = 0,
 | 
				
			||||||
 | 
					} PinosDaemonInfoFlags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef gboolean (*PinosDaemonInfoCallback)  (PinosContext *c, const PinosDaemonInfo *info, gpointer userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void            pinos_context_get_daemon_info (PinosContext *context,
 | 
				
			||||||
 | 
					                                               PinosDaemonInfoFlags flags,
 | 
				
			||||||
 | 
					                                               PinosDaemonInfoCallback cb,
 | 
				
			||||||
 | 
					                                               GCancellable *cancellable,
 | 
				
			||||||
 | 
					                                               gpointer user_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosSourceState:
 | 
					 * PinosSourceState:
 | 
				
			||||||
 * @PINOS_SOURCE_STATE_ERROR: the source is in error
 | 
					 * @PINOS_SOURCE_STATE_ERROR: the source is in error
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue