diff --git a/modules/module-standard-event-source.c b/modules/module-standard-event-source.c index f89fc00b..3260949a 100644 --- a/modules/module-standard-event-source.c +++ b/modules/module-standard-event-source.c @@ -69,6 +69,7 @@ struct _WpStandardEventSource WpEventHook *rescan_done_hook; gboolean rescan_scheduled[N_RESCAN_CONTEXTS]; gint n_oms_installed; + WpCollectionManager *cm; }; static guint signals[N_SIGNALS] = {0}; @@ -310,6 +311,26 @@ wp_standard_event_source_schedule_rescan (WpStandardEventSource *self, } } +static void +on_global_collected (WpObjectManager *om, WpGlobalProxy *global, + const gchar *collection_name, WpStandardEventSource *self) +{ + g_autoptr (WpProperties) properties = wp_properties_new_empty (); + wp_properties_set (properties, "event.subject.collection", collection_name); + + wp_standard_event_source_push_event (self, "collected", global, properties); +} + +static void +on_global_dropped (WpObjectManager *om, WpGlobalProxy *global, + const gchar *collection_name, WpStandardEventSource *self) +{ + g_autoptr (WpProperties) properties = wp_properties_new_empty (); + wp_properties_set (properties, "event.subject.collection", collection_name); + + wp_standard_event_source_push_event (self, "dropped", global, properties); +} + static void on_metadata_changed (WpMetadata *obj, guint32 subject, const gchar *key, const gchar *spa_type, const gchar *value, @@ -409,6 +430,15 @@ wp_standard_event_source_enable (WpPlugin * plugin, WpTransition * transition) wp_event_dispatcher_get_instance (core); g_return_if_fail (dispatcher); + /* Get the collection manager if any */ + self->cm = wp_collection_manager_find (core, NULL); + if (self->cm) { + g_signal_connect_object (self->cm, "global-collected", + G_CALLBACK (on_global_collected), self, 0); + g_signal_connect_object (self->cm, "global-dropped", + G_CALLBACK (on_global_dropped), self, 0); + } + /* install object managers */ self->n_oms_installed = 0; for (gint i = 0; i < N_OBJECT_TYPES; i++) { @@ -451,6 +481,8 @@ wp_standard_event_source_disable (WpPlugin * plugin) if (dispatcher) wp_event_dispatcher_unregister_hook (dispatcher, self->rescan_done_hook); g_clear_object (&self->rescan_done_hook); + + g_clear_object (&self->cm); } static void