diff options
Diffstat (limited to 'src/dkp-device-list.c')
-rw-r--r-- | src/dkp-device-list.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/dkp-device-list.c b/src/dkp-device-list.c index fee7bc8..d6d5591 100644 --- a/src/dkp-device-list.c +++ b/src/dkp-device-list.c @@ -27,6 +27,7 @@ #include "egg-debug.h" +#include "dkp-native.h" #include "dkp-device-list.h" static void dkp_device_list_class_init (DkpDeviceListClass *klass); @@ -38,7 +39,7 @@ static void dkp_device_list_finalize (GObject *object); struct DkpDeviceListPrivate { GPtrArray *array; - GHashTable *map_native_path_to_object; + GHashTable *map_native_path_to_device; }; G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT) @@ -46,42 +47,42 @@ G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT) /** * dkp_device_list_lookup: * - * Convert a %GUdevDevice into a %GObject -- we use the native path + * Convert a native %GObject into a %DkpDevice -- we use the native path * to look these up as it's the only thing they share. **/ GObject * -dkp_device_list_lookup (DkpDeviceList *list, GUdevDevice *device) +dkp_device_list_lookup (DkpDeviceList *list, GObject *native) { - GObject *object; + GObject *device; const gchar *native_path; g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), NULL); /* does device exist in db? */ - native_path = g_udev_device_get_sysfs_path (device); - object = g_hash_table_lookup (list->priv->map_native_path_to_object, native_path); - return object; + native_path = dkp_native_get_native_path (native); + device = g_hash_table_lookup (list->priv->map_native_path_to_device, native_path); + return device; } /** * dkp_device_list_insert: * - * Insert a %GUdevDevice device and it's mapping to a backing %GObject + * Insert a %GObject device and it's mapping to a backing %DkpDevice * into a list of devices. **/ gboolean -dkp_device_list_insert (DkpDeviceList *list, GUdevDevice *device, GObject *object) +dkp_device_list_insert (DkpDeviceList *list, GObject *native, GObject *device) { const gchar *native_path; g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE); + g_return_val_if_fail (native != NULL, FALSE); g_return_val_if_fail (device != NULL, FALSE); - g_return_val_if_fail (object != NULL, FALSE); - native_path = g_udev_device_get_sysfs_path (device); - g_hash_table_insert (list->priv->map_native_path_to_object, - g_strdup (native_path), object); - g_ptr_array_add (list->priv->array, g_object_ref (object)); + native_path = dkp_native_get_native_path (native); + g_hash_table_insert (list->priv->map_native_path_to_device, + g_strdup (native_path), device); + g_ptr_array_add (list->priv->array, g_object_ref (device)); egg_debug ("added %s", native_path); return TRUE; } @@ -103,23 +104,23 @@ dkp_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data) * dkp_device_list_remove: **/ gboolean -dkp_device_list_remove (DkpDeviceList *list, GObject *object) +dkp_device_list_remove (DkpDeviceList *list, GObject *device) { g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE); - g_return_val_if_fail (object != NULL, FALSE); + g_return_val_if_fail (device != NULL, FALSE); /* remove the device from the db */ - g_hash_table_foreach_remove (list->priv->map_native_path_to_object, - dkp_device_list_remove_cb, object); - g_ptr_array_remove (list->priv->array, object); - g_object_unref (object); + g_hash_table_foreach_remove (list->priv->map_native_path_to_device, + dkp_device_list_remove_cb, device); + g_ptr_array_remove (list->priv->array, device); + g_object_unref (device); return TRUE; } /** * dkp_device_list_get_array: * - * This is quick to iterate when we don't have GUdevDevice's to resolve + * This is quick to iterate when we don't have GObject's to resolve **/ const GPtrArray * dkp_device_list_get_array (DkpDeviceList *list) @@ -149,7 +150,7 @@ dkp_device_list_init (DkpDeviceList *list) { list->priv = DKP_DEVICE_LIST_GET_PRIVATE (list); list->priv->array = g_ptr_array_new (); - list->priv->map_native_path_to_object = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + list->priv->map_native_path_to_device = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); } /** @@ -167,7 +168,7 @@ dkp_device_list_finalize (GObject *object) g_ptr_array_foreach (list->priv->array, (GFunc) g_object_unref, NULL); g_ptr_array_free (list->priv->array, TRUE); - g_hash_table_unref (list->priv->map_native_path_to_object); + g_hash_table_unref (list->priv->map_native_path_to_device); G_OBJECT_CLASS (dkp_device_list_parent_class)->finalize (object); } |