TcoreUdev *tcore_udev_new(Server *s, const gchar **subsystems) { TcoreUdev *udev; udev = calloc(sizeof(struct tcore_udev_type), 1); if (!udev) return NULL; if (!subsystems) { subsystems = _default_subsystems; } udev->server = s; udev->client = g_udev_client_new(subsystems); if (!udev->client) { free(udev); return NULL; } g_signal_connect(udev->client, "uevent", G_CALLBACK(_on_uevent), udev); udev->enumer = g_udev_enumerator_new(udev->client); return udev; }
gboolean ubiquity_webcam_available (void) { GUdevEnumerator *enumerator; GUdevClient *client; GList *devices; guint length; const gchar *const subsystems[] = {NULL}; client = g_udev_client_new (subsystems); enumerator = g_udev_enumerator_new (client); g_udev_enumerator_add_match_property (enumerator, "ID_V4L_CAPABILITIES", ":capture:"); devices = g_udev_enumerator_execute (enumerator); length = g_list_length (devices); g_list_free_full (devices, g_object_unref); return length > 0; }
void nm_atm_manager_query_devices (NMAtmManager *self) { NMAtmManagerPrivate *priv = NM_ATM_MANAGER_GET_PRIVATE (self); GUdevEnumerator *enumerator; GList *devices, *iter; g_return_if_fail (NM_IS_ATM_MANAGER (self)); enumerator = g_udev_enumerator_new (priv->client); g_udev_enumerator_add_match_subsystem (enumerator, "atm"); g_udev_enumerator_add_match_is_initialized (enumerator); devices = g_udev_enumerator_execute (enumerator); for (iter = devices; iter; iter = g_list_next (iter)) { adsl_add (self, G_UDEV_DEVICE (iter->data)); g_object_unref (G_UDEV_DEVICE (iter->data)); } g_list_free (devices); g_object_unref (enumerator); }