UDisksBlock * udisks_client_get_block_for_dev (UDisksClient *client, dev_t block_device_number) { UDisksBlock *ret = NULL; GList *l, *object_proxies = NULL; g_return_val_if_fail (UDISKS_IS_CLIENT (client), NULL); object_proxies = g_dbus_object_manager_get_objects (client->object_manager); for (l = object_proxies; l != NULL; l = l->next) { UDisksObject *object = UDISKS_OBJECT (l->data); UDisksBlock *block; block = udisks_object_get_block (object); if (block == NULL) continue; if (udisks_block_get_device_number (block) == block_device_number) { ret = block; goto out; } g_object_unref (block); } out: g_list_foreach (object_proxies, (GFunc) g_object_unref, NULL); g_list_free (object_proxies); return ret; }
/** * udisks_client_get_drive_info: * @client: A #UDisksClient. * @drive: A #UDisksDrive. * @out_name: (out) (allow-none): Return location for name or %NULL. * @out_description: (out) (allow-none): Return location for description or %NULL. * @out_drive_icon: (out) (allow-none): Return location for icon representing the drive or %NULL. * @out_media_description: (out) (allow-none): Return location for description of the media or %NULL. * @out_media_icon: (out) (allow-none): Return location for icon representing the media or %NULL. * * Gets information about a #UDisksDrive object that is suitable to * present in an user interface. The returned strings are localized. * * Deprecated: 2.1: Use udisks_client_get_object_info() instead. */ void udisks_client_get_drive_info (UDisksClient *client, UDisksDrive *drive, gchar **out_name, gchar **out_description, GIcon **out_icon, gchar **out_media_description, GIcon **out_media_icon) { UDisksObjectInfo *info; g_return_if_fail (UDISKS_IS_CLIENT (client)); g_return_if_fail (UDISKS_IS_DRIVE (drive)); info = udisks_object_info_new (NULL); udisks_client_get_object_info_for_drive (client, drive, NULL, info); if (out_name != NULL) *out_name = g_strdup (info->name); if (out_description != NULL) *out_description = g_strdup (info->description); if (out_icon != NULL) *out_icon = _g_object_ref0 (info->icon); if (out_media_description != NULL) *out_media_description = g_strdup (info->media_description); if (out_media_icon != NULL) *out_media_icon = _g_object_ref0 (info->media_icon); g_object_unref (info); }
UDisksManager * udisks_client_get_manager (UDisksClient *client) { UDisksManager *ret = NULL; GDBusObject *obj; g_return_val_if_fail (UDISKS_IS_CLIENT (client), NULL); obj = g_dbus_object_manager_get_object (client->object_manager, "/org/freedesktop/UDisks2/Manager"); if (obj == NULL) goto out; ret = udisks_object_peek_manager (UDISKS_OBJECT (obj)); g_object_unref (obj); out: return ret; }
void udisks_client_queue_changed (UDisksClient *client) { g_return_if_fail (UDISKS_IS_CLIENT (client)); if (client->changed_timeout_source != NULL) goto out; client->changed_timeout_source = g_timeout_source_new (100); g_source_set_callback (client->changed_timeout_source, (GSourceFunc) on_changed_timeout, client, NULL); /* destroy notify */ g_source_attach (client->changed_timeout_source, client->context); g_source_unref (client->changed_timeout_source); out: ; }
GDBusObjectManager * udisks_client_get_object_manager (UDisksClient *client) { g_return_val_if_fail (UDISKS_IS_CLIENT (client), NULL); return client->object_manager; }
/** * udisks_client_get_object_info: * @client: A #UDisksClient. * @object: A #UDisksObject. * * Gets information about a #UDisksObject instance that is suitable to * present in an user interface. Information is returned in the * #UDisksObjectInfo object and is localized. * * Returns: (transfer full): A #UDisksObjectInfo instance that should be freed with g_object_unref(). * * Since: 2.1 */ UDisksObjectInfo * udisks_client_get_object_info (UDisksClient *client, UDisksObject *object) { UDisksObjectInfo *ret = NULL; UDisksDrive *drive = NULL; UDisksBlock *block = NULL; UDisksPartition *partition = NULL; UDisksMDRaid *mdraid = NULL; UDisksLoop *loop = NULL; g_return_val_if_fail (UDISKS_IS_CLIENT (client), NULL); g_return_val_if_fail (UDISKS_IS_OBJECT (object), NULL); ret = udisks_object_info_new (object); drive = udisks_object_get_drive (object); block = udisks_object_get_block (object); loop = udisks_object_get_loop (object); partition = udisks_object_get_partition (object); mdraid = udisks_object_get_mdraid (object); if (drive != NULL) { udisks_client_get_object_info_for_drive (client, drive, NULL, ret); } else if (mdraid != NULL) { udisks_client_get_object_info_for_mdraid (client, mdraid, NULL, ret); } else if (block != NULL) { drive = udisks_client_get_drive_for_block (client, block); if (drive != NULL) { udisks_client_get_object_info_for_drive (client, drive, partition, ret); goto out; } mdraid = udisks_client_get_mdraid_for_block (client, block); if (mdraid != NULL) { udisks_client_get_object_info_for_mdraid (client, mdraid, partition, ret); goto out; } if (loop != NULL) udisks_client_get_object_info_for_loop (client, loop, block, partition, ret); else udisks_client_get_object_info_for_block (client, block, partition, ret); } out: g_clear_object (&loop); g_clear_object (&mdraid); g_clear_object (&partition); g_clear_object (&block); g_clear_object (&drive); #if 0 /* for debugging */ g_print ("%s -> dd='%s', md='%s', ol='%s' and di='%s', mi='%s' sk='%s'\n", g_dbus_object_get_object_path (G_DBUS_OBJECT (object)), ret->description, ret->media_description, ret->one_liner, ret->icon == NULL ? "" : g_icon_to_string (ret->icon), ret->media_icon == NULL ? "" : g_icon_to_string (ret->media_icon), ret->sort_key); #endif return ret; }