From 88677ca45a8db8f182178ef66f908e5e699f2f8c Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Sun, 19 Apr 2009 03:34:54 +0000 Subject: [PATCH] Fix some bad memory stuff, add more logging. --- ecdb/trunk/src/ecdb_common.h | 11 ++++------ ecdb/trunk/src/ecdb_drives.c | 8 ++----- ecdb/trunk/src/ecdb_drives.h | 5 ++--- ecdb/trunk/src/ecdb_hal.c | 41 ++++++++++++++++++++++-------------- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/ecdb/trunk/src/ecdb_common.h b/ecdb/trunk/src/ecdb_common.h index c285884..b070f58 100644 --- a/ecdb/trunk/src/ecdb_common.h +++ b/ecdb/trunk/src/ecdb_common.h @@ -87,14 +87,11 @@ struct _Ecdb_Drive_Info /* Mark this as being stale */ unsigned char fresh_info:1; - /* Capacity */ - unsigned long long capacity; - - /* Disc status */ - unsigned int status; - - /* Disc type */ + /* Disc info */ char *type; + char *disc_udi; + unsigned int status; + unsigned long long capacity; BurnDriveInfo *tangible; }; diff --git a/ecdb/trunk/src/ecdb_drives.c b/ecdb/trunk/src/ecdb_drives.c index aa9f490..6f090c6 100644 --- a/ecdb/trunk/src/ecdb_drives.c +++ b/ecdb/trunk/src/ecdb_drives.c @@ -25,13 +25,9 @@ _ecdb_drive_set_capabilities(Ecdb_Drive_Info *drive, int ecdb_update_drive_info(Ecdb_Drive_Info *drive, - E_Hal_Device_Get_All_Properties_Return *ret, - char *udi) + E_Hal_Device_Get_All_Properties_Return *ret) { - /* Assume that nothing about the physical hardware has changed */ - drive->udi = udi; - - /* Update the drive directories */ + /* Assume that the physical hardware hasn't changed */ FREE(drive->write_speeds); _ecdb_drive_set_capabilities(drive, ret); diff --git a/ecdb/trunk/src/ecdb_drives.h b/ecdb/trunk/src/ecdb_drives.h index 25e2c1a..f829c94 100644 --- a/ecdb/trunk/src/ecdb_drives.h +++ b/ecdb/trunk/src/ecdb_drives.h @@ -3,10 +3,9 @@ #define ECDB_DRIVES_H int ecdb_aquire_drive_info(E_Hal_Device_Get_All_Properties_Return *ret, - char *mnt, char *udi); + char *mnt, char *udi); int ecdb_update_drive_info(Ecdb_Drive_Info *drive, - E_Hal_Device_Get_All_Properties_Return *ret, - char *udi); + E_Hal_Device_Get_All_Properties_Return *ret); void ecdb_print_drive_info(void); int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); void ecdb_drive_info_list_free(Eina_List *list); diff --git a/ecdb/trunk/src/ecdb_hal.c b/ecdb/trunk/src/ecdb_hal.c index aac0141..297b43e 100644 --- a/ecdb/trunk/src/ecdb_hal.c +++ b/ecdb/trunk/src/ecdb_hal.c @@ -6,7 +6,6 @@ void _ecdb_hal_volume_all_cb(void *data, void *reply_data, DBusError *error); void _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error); void _ecdb_hal_volume_removed_cb(void *data, DBusMessage *msg); void _ecdb_hal_volume_added_cb(void *data, DBusMessage *msg); -void _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error); void _ecdb_hal_volume_cb(void *data, void *reply_data, DBusError *error); void _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error); void _ecdb_hal_unmount_cb(void *data, void *reply_data, DBusError *error); @@ -32,7 +31,7 @@ _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error) if (dbus_error_is_set(error)) { - /* XXX Handle this here */ + EINA_ERROR_PWARN("DBus error: %s %s\n", error->name, error->message); dbus_error_free(error); return; } @@ -48,12 +47,11 @@ _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error) { if (!strcmp(drive->location, str)) { - if (!ecdb_update_drive_info(drive, ret, udi)) + if (!ecdb_update_drive_info(drive, ret)) { EINA_ERROR_PWARN("Couldn't update old drive info!\n"); } - printf("Recreating old...\n"); ecdb_print_drive_info(); return; } @@ -69,7 +67,6 @@ _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error) return; } - printf("Creating new...\n"); ecdb_print_drive_info(); /* Check to see if we have acquired all of the drives */ @@ -93,10 +90,9 @@ _ecdb_hal_volume_removed_cb(void *data __UNUSED__, DBusMessage *msg) dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi, DBUS_TYPE_INVALID); - printf("Removed: %s\n", udi); EINA_LIST_FOREACH(em->drives, l, drive) { - if (!strcmp(drive->udi, udi)) + if (!strcmp(drive->disc_udi, udi)) { drive->fresh_info = FALSE; drive->status = 0; @@ -131,11 +127,14 @@ _ecdb_hal_volume_cb(void *data, void *reply_data, DBusError *error) ret = reply_data; if (!ret) + { + EINA_ERROR_PWARN("No DBus data!\n"); return; + } if (dbus_error_is_set(error)) { - /* XXX Handle this here */ + EINA_ERROR_PWARN("DBus error: %s %s\n", error->name, error->message); dbus_error_free(error); return; } @@ -158,11 +157,14 @@ _ecdb_hal_device_all_cb(void *data __UNUSED__, void *reply_data, ret = reply_data; if ((!ret) || (!ret->strings)) + { + EINA_ERROR_PWARN("No DBus data!\n"); return; + } if (dbus_error_is_set(error)) { - /* XXX Handle this here */ + EINA_ERROR_PWARN("DBus error: %s %s\n", error->name, error->message); dbus_error_free(error); return; } @@ -215,7 +217,7 @@ _ecdb_hal_unmount_cb(void *data, void *reply_data __UNUSED__, DBusError *error) if (dbus_error_is_set(error)) { - EINA_ERROR_PWARN("Cannot unmount volume!\n"); + EINA_ERROR_PWARN("Unmount Error: %s %s\n", error->name, error->message); dbus_error_free(error); } } @@ -252,11 +254,14 @@ _ecdb_hal_volume_all_cb(void *data __UNUSED__, void *reply_data, ret = reply_data; if ((!ret) || (!ret->strings)) + { + EINA_ERROR_PWARN("No DBus data!\n"); return; + } if (dbus_error_is_set(error)) { - /* XXX Handle this here */ + EINA_ERROR_PWARN("DBus error: %s %s\n", error->name, error->message); dbus_error_free(error); return; } @@ -264,7 +269,7 @@ _ecdb_hal_volume_all_cb(void *data __UNUSED__, void *reply_data, EINA_LIST_FOREACH(ret->strings, l, udi) { e_hal_device_get_all_properties(em->conn, udi, _ecdb_hal_volume_handle, - NULL); + (void *)strdup(udi)); } } @@ -274,17 +279,21 @@ _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error) E_Hal_Device_Get_All_Properties_Return *ret; Ecdb_Drive_Info *drive; Eina_List *l; - char *udi; + char *udi, *disc_udi; int err; ret = reply_data; + disc_udi = data; - if (!ret) + if ((!ret) || (!disc_udi)) + { + EINA_ERROR_PWARN("No DBus data or volume data!\n"); return; + } if (dbus_error_is_set(error)) { - /* XXX Handle this better */ + EINA_ERROR_PWARN("DBus error: %s %s\n", error->name, error->message); dbus_error_free(error); return; } @@ -301,6 +310,7 @@ _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error) { if (!strcmp(udi, drive->udi)) { + drive->disc_udi = disc_udi; drive->capacity = e_hal_property_uint64_get(ret, "volume.disc.capacity", NULL); @@ -323,7 +333,6 @@ _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error) } } - FREE(data); FREE(udi); }