diff --git a/src/client/context.h b/src/client/context.h index bf72e2711..bc9b874d3 100644 --- a/src/client/context.h +++ b/src/client/context.h @@ -21,7 +21,6 @@ #define __PINOS_CONTEXT_H__ #include -#include #include #include diff --git a/src/client/introspect.c b/src/client/introspect.c index 9c3a04024..87defa35a 100644 --- a/src/client/introspect.c +++ b/src/client/introspect.c @@ -87,6 +87,8 @@ daemon_fill_info (PinosDaemonInfo *info, GDBusProxy *proxy) GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); info->id = proxy; + info->daemon_path = g_dbus_proxy_get_object_path (proxy); + info->change_mask = 0; SET_STRING ("UserName", user_name, 0); SET_STRING ("HostName", host_name, 1); @@ -140,6 +142,8 @@ client_fill_info (PinosClientInfo *info, GDBusProxy *proxy) GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); info->id = proxy; + info->client_path = g_dbus_proxy_get_object_path (proxy); + info->change_mask = 0; SET_STRING ("Name", name, 0); SET_PROPERTIES ("Properties", properties, 1); @@ -327,6 +331,7 @@ source_output_fill_info (PinosSourceOutputInfo *info, GDBusProxy *proxy) GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); info->id = proxy; + info->output_path = g_dbus_proxy_get_object_path (proxy); info->change_mask = 0; SET_STRING ("Client", client_path, 0); diff --git a/src/client/introspect.h b/src/client/introspect.h index fca57a7b7..97c60ac4c 100644 --- a/src/client/introspect.h +++ b/src/client/introspect.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS /** * PinosDaemonInfo: * @id: generic id of the daemon + * @daemon-path: unique path of the daemon * @change_mask: bitfield of changed fields since last call * @user_name: name of the user that started the daemon * @host_name: name of the machine the daemon is running on @@ -44,6 +45,7 @@ G_BEGIN_DECLS */ typedef struct { gpointer id; + const char *daemon_path; guint64 change_mask; const char *user_name; const char *host_name; @@ -68,6 +70,7 @@ void pinos_context_get_daemon_info (PinosContext *context, /** * PinosClientInfo: * @id: generic id of the client + * @client_path: unique path of the client * @change_mask: bitfield of changed fields since last call * @name: name of client * @properties: extra properties @@ -77,6 +80,7 @@ void pinos_context_get_daemon_info (PinosContext *context, */ typedef struct { gpointer id; + const char *client_path; guint64 change_mask; const char *name; PinosProperties *properties; @@ -189,6 +193,7 @@ typedef enum { /** * PinosSourceOutputInfo: * @id: generic id of the output + * @path: the unique path of the output * @change_mask: bitfield of changed fields since last call * @client_path: the owner client * @source_path: the source path @@ -202,6 +207,7 @@ typedef enum { */ typedef struct { gpointer id; + const char *output_path; guint64 change_mask; const char *client_path; const char *source_path; diff --git a/src/client/mainloop.h b/src/client/mainloop.h index 746b6de4c..4d9d86ad9 100644 --- a/src/client/mainloop.h +++ b/src/client/mainloop.h @@ -20,11 +20,8 @@ #ifndef __PINOS_MAIN_LOOP_H__ #define __PINOS_MAIN_LOOP_H__ -#include #include -#include "context.h" - G_BEGIN_DECLS #define PINOS_TYPE_MAIN_LOOP (pinos_main_loop_get_type ()) diff --git a/src/client/private.h b/src/client/private.h index bcd108034..5b87409d8 100644 --- a/src/client/private.h +++ b/src/client/private.h @@ -42,3 +42,15 @@ struct _PinosContextPrivate GList *sources; GList *source_outputs; }; + +void pinos_subscribe_get_proxy (PinosSubscribe *subscribe, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe, + GAsyncResult *res, + GError **error); + diff --git a/src/client/stream.h b/src/client/stream.h index f0d53a885..1799ae064 100644 --- a/src/client/stream.h +++ b/src/client/stream.h @@ -20,10 +20,9 @@ #ifndef __PINOS_STREAM_H__ #define __PINOS_STREAM_H__ -#include #include -#include "context.h" +#include G_BEGIN_DECLS diff --git a/src/client/subscribe.c b/src/client/subscribe.c index 21b721ae3..74949952d 100644 --- a/src/client/subscribe.c +++ b/src/client/subscribe.c @@ -21,6 +21,7 @@ #include "client/pinos.h" #include "client/enumtypes.h" +#include "client/private.h" struct _PinosSubscribePrivate { @@ -125,22 +126,18 @@ on_proxy_properties_changed (GDBusProxy *proxy, GVariant *value; gchar *key; GHashTable *props; + gboolean need_notify = FALSE; props = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties"); - if (props == NULL) { - props = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - g_object_set_data_full (G_OBJECT (proxy), - "pinos-changed-properties", - props, - (GDestroyNotify) g_hash_table_unref); - } g_variant_iter_init (&iter, changed_properties); while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) { if (!g_hash_table_contains (props, key)) g_hash_table_add (props, g_strdup (key)); + need_notify = TRUE; } - notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE); + if (need_notify) + notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE); } static void @@ -161,6 +158,9 @@ remove_data (PinosSubscribe *subscribe, if (data->pending) { data->removed = TRUE; } else { + GHashTable *props = g_object_get_data (G_OBJECT (data->proxy), "pinos-changed-properties"); + + g_hash_table_remove_all (props); notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE); object_data_free (data); } @@ -209,6 +209,11 @@ on_proxy_created (GObject *source_object, notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW); + g_object_set_data_full (G_OBJECT (data->proxy), + "pinos-changed-properties", + g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), + (GDestroyNotify) g_hash_table_unref); + for (walk = data->tasks; walk; walk = g_list_next (walk)) { GTask *task = walk->data; g_task_return_pointer (task, g_object_ref (data->proxy), g_object_unref); diff --git a/src/client/subscribe.h b/src/client/subscribe.h index 8e01a4327..3a6a105ac 100644 --- a/src/client/subscribe.h +++ b/src/client/subscribe.h @@ -20,7 +20,7 @@ #ifndef __PINOS_SUBSCRIBE_H__ #define __PINOS_SUBSCRIBE_H__ -#include +#include G_BEGIN_DECLS @@ -87,19 +87,6 @@ PinosSubscribe * pinos_subscribe_new (void); PinosSubscriptionState pinos_subscribe_get_state (PinosSubscribe *subscribe); GError * pinos_subscribe_get_error (PinosSubscribe *subscribe); -void pinos_subscribe_get_proxy (PinosSubscribe *subscribe, - const gchar *name, - const gchar *object_path, - const gchar *interface_name, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe, - GAsyncResult *res, - GError **error); - - - G_END_DECLS #endif /* __PINOS_SUBSCRIBE_H__ */ diff --git a/src/server/client-source.h b/src/server/client-source.h index dc7afeff2..43aa19870 100644 --- a/src/server/client-source.h +++ b/src/server/client-source.h @@ -21,7 +21,6 @@ #define __PINOS_CLIENT_SOURCE_H__ #include -#include G_BEGIN_DECLS @@ -29,7 +28,7 @@ typedef struct _PinosClientSource PinosClientSource; typedef struct _PinosClientSourceClass PinosClientSourceClass; typedef struct _PinosClientSourcePrivate PinosClientSourcePrivate; -#include "server/source.h" +#include #define PINOS_TYPE_CLIENT_SOURCE (pinos_client_source_get_type ()) #define PINOS_IS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE)) diff --git a/src/server/client.h b/src/server/client.h index b253980a0..57450121b 100644 --- a/src/server/client.h +++ b/src/server/client.h @@ -22,7 +22,7 @@ #include -#include "daemon.h" +#include G_BEGIN_DECLS diff --git a/src/server/daemon.h b/src/server/daemon.h index 0115a4af6..0c0eb7630 100644 --- a/src/server/daemon.h +++ b/src/server/daemon.h @@ -21,7 +21,6 @@ #define __PINOS_DAEMON_H__ #include -#include G_BEGIN_DECLS diff --git a/src/server/source.h b/src/server/source.h index 912f66780..cc107557c 100644 --- a/src/server/source.h +++ b/src/server/source.h @@ -21,7 +21,6 @@ #define __PINOS_SOURCE_H__ #include -#include G_BEGIN_DECLS @@ -29,8 +28,8 @@ typedef struct _PinosSource PinosSource; typedef struct _PinosSourceClass PinosSourceClass; typedef struct _PinosSourcePrivate PinosSourcePrivate; -#include "client/introspect.h" -#include "server/source-output.h" +#include +#include #define PINOS_TYPE_SOURCE (pinos_source_get_type ()) #define PINOS_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE)) diff --git a/src/tools/pinos-monitor.c b/src/tools/pinos-monitor.c index 1ab5bf89a..b447cc042 100644 --- a/src/tools/pinos-monitor.c +++ b/src/tools/pinos-monitor.c @@ -87,6 +87,7 @@ dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer userdat return FALSE; g_print ("\tid: %p\n", info->id); + g_print ("\tdaemon-path: \"%s\"\n", info->daemon_path); if (info->change_mask & (1 << 0)) g_print ("\tuser-name: \"%s\"\n", info->user_name); if (info->change_mask & (1 << 1)) @@ -110,6 +111,7 @@ dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer userdat return FALSE; g_print ("\tid: %p\n", info->id); + g_print ("\tclient-path: \"%s\"\n", info->client_path); if (info->change_mask & (1 << 0)) g_print ("\tname: \"%s\"\n", info->name); if (info->change_mask & (1 << 1)) @@ -125,16 +127,15 @@ dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer userdat return FALSE; g_print ("\tid: %p\n", info->id); + g_print ("\tsource-path: \"%s\"\n", info->source_path); if (info->change_mask & (1 << 0)) - g_print ("\tsource-path: \"%s\"\n", info->source_path); - if (info->change_mask & (1 << 1)) g_print ("\tname: \"%s\"\n", info->name); + if (info->change_mask & (1 << 1)) + print_properties (info->properties); if (info->change_mask & (1 << 2)) g_print ("\tstate: %d\n", info->state); if (info->change_mask & (1 << 3)) print_formats ("possible formats", info->possible_formats); - if (info->change_mask & (1 << 4)) - print_properties (info->properties); return TRUE; } @@ -146,6 +147,7 @@ dump_source_output_info (PinosContext *c, const PinosSourceOutputInfo *info, gpo return FALSE; g_print ("\tid: %p\n", info->id); + g_print ("\toutput-path: \"%s\"\n", info->output_path); if (info->change_mask & (1 << 0)) g_print ("\tclient-path: \"%s\"\n", info->client_path); if (info->change_mask & (1 << 1)) @@ -163,7 +165,7 @@ dump_source_output_info (PinosContext *c, const PinosSourceOutputInfo *info, gpo } static void -dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags flags) +dump_object (PinosContext *context, gpointer id, PinosSubscriptionFlags flags) { if (flags & PINOS_SUBSCRIPTION_FLAG_DAEMON) { pinos_context_get_daemon_info (context, @@ -174,7 +176,7 @@ dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags fl } else if (flags & PINOS_SUBSCRIPTION_FLAG_CLIENT) { pinos_context_get_client_info_by_id (context, - proxy, + id, PINOS_CLIENT_INFO_FLAGS_NONE, dump_client_info, NULL, @@ -182,7 +184,7 @@ dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags fl } else if (flags & PINOS_SUBSCRIPTION_FLAG_SOURCE) { pinos_context_get_source_info_by_id (context, - proxy, + id, PINOS_SOURCE_INFO_FLAGS_FORMATS, dump_source_info, NULL, @@ -190,7 +192,7 @@ dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags fl } else if (flags & PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT) { pinos_context_get_source_output_info_by_id (context, - proxy, + id, PINOS_SOURCE_OUTPUT_INFO_FLAGS_NONE, dump_source_output_info, NULL, @@ -207,17 +209,18 @@ subscription_cb (PinosContext *context, { switch (type) { case PINOS_SUBSCRIPTION_EVENT_NEW: - g_print ("added: %s\n", g_dbus_proxy_get_object_path (id)); - dump_object (context, G_DBUS_PROXY (id), flags); + g_print ("added:\n"); + dump_object (context, id, flags); break; case PINOS_SUBSCRIPTION_EVENT_CHANGE: - g_print ("changed: %s\n", g_dbus_proxy_get_object_path (id)); - dump_object (context, G_DBUS_PROXY (id), flags); + g_print ("changed:\n"); + dump_object (context, id, flags); break; case PINOS_SUBSCRIPTION_EVENT_REMOVE: - g_print ("removed: %s\n", g_dbus_proxy_get_object_path (id)); + g_print ("removed:\n"); + dump_object (context, id, flags); break; } }