Fix some bad memory stuff, add more logging.

This commit is contained in:
Jaime Thomas 2009-04-19 03:34:54 +00:00
parent 4bfe8b8d5c
commit 796fd97f90
4 changed files with 33 additions and 32 deletions

View File

@ -87,14 +87,11 @@ struct _Ecdb_Drive_Info
/* Mark this as being stale */ /* Mark this as being stale */
unsigned char fresh_info:1; unsigned char fresh_info:1;
/* Capacity */ /* Disc info */
unsigned long long capacity;
/* Disc status */
unsigned int status;
/* Disc type */
char *type; char *type;
char *disc_udi;
unsigned int status;
unsigned long long capacity;
BurnDriveInfo *tangible; BurnDriveInfo *tangible;
}; };

View File

@ -25,13 +25,9 @@ _ecdb_drive_set_capabilities(Ecdb_Drive_Info *drive,
int int
ecdb_update_drive_info(Ecdb_Drive_Info *drive, ecdb_update_drive_info(Ecdb_Drive_Info *drive,
E_Hal_Device_Get_All_Properties_Return *ret, E_Hal_Device_Get_All_Properties_Return *ret)
char *udi)
{ {
/* Assume that nothing about the physical hardware has changed */ /* Assume that the physical hardware hasn't changed */
drive->udi = udi;
/* Update the drive directories */
FREE(drive->write_speeds); FREE(drive->write_speeds);
_ecdb_drive_set_capabilities(drive, ret); _ecdb_drive_set_capabilities(drive, ret);

View File

@ -5,8 +5,7 @@
int ecdb_aquire_drive_info(E_Hal_Device_Get_All_Properties_Return *ret, 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, int ecdb_update_drive_info(Ecdb_Drive_Info *drive,
E_Hal_Device_Get_All_Properties_Return *ret, E_Hal_Device_Get_All_Properties_Return *ret);
char *udi);
void ecdb_print_drive_info(void); void ecdb_print_drive_info(void);
int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx);
void ecdb_drive_info_list_free(Eina_List *list); void ecdb_drive_info_list_free(Eina_List *list);

View File

@ -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_device_handle(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_volume_removed_cb(void *data, DBusMessage *msg); void _ecdb_hal_volume_removed_cb(void *data, DBusMessage *msg);
void _ecdb_hal_volume_added_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_cb(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_volume_handle(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); 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)) 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); dbus_error_free(error);
return; return;
} }
@ -48,12 +47,11 @@ _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error)
{ {
if (!strcmp(drive->location, str)) 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"); EINA_ERROR_PWARN("Couldn't update old drive info!\n");
} }
printf("Recreating old...\n");
ecdb_print_drive_info(); ecdb_print_drive_info();
return; return;
} }
@ -69,7 +67,6 @@ _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error)
return; return;
} }
printf("Creating new...\n");
ecdb_print_drive_info(); ecdb_print_drive_info();
/* Check to see if we have acquired all of the drives */ /* 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_message_get_args(msg, &err, DBUS_TYPE_STRING, &udi,
DBUS_TYPE_INVALID); DBUS_TYPE_INVALID);
printf("Removed: %s\n", udi);
EINA_LIST_FOREACH(em->drives, l, drive) EINA_LIST_FOREACH(em->drives, l, drive)
{ {
if (!strcmp(drive->udi, udi)) if (!strcmp(drive->disc_udi, udi))
{ {
drive->fresh_info = FALSE; drive->fresh_info = FALSE;
drive->status = 0; drive->status = 0;
@ -131,11 +127,14 @@ _ecdb_hal_volume_cb(void *data, void *reply_data, DBusError *error)
ret = reply_data; ret = reply_data;
if (!ret) if (!ret)
{
EINA_ERROR_PWARN("No DBus data!\n");
return; return;
}
if (dbus_error_is_set(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); dbus_error_free(error);
return; return;
} }
@ -158,11 +157,14 @@ _ecdb_hal_device_all_cb(void *data __UNUSED__, void *reply_data,
ret = reply_data; ret = reply_data;
if ((!ret) || (!ret->strings)) if ((!ret) || (!ret->strings))
{
EINA_ERROR_PWARN("No DBus data!\n");
return; return;
}
if (dbus_error_is_set(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); dbus_error_free(error);
return; return;
} }
@ -215,7 +217,7 @@ _ecdb_hal_unmount_cb(void *data, void *reply_data __UNUSED__, DBusError *error)
if (dbus_error_is_set(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); dbus_error_free(error);
} }
} }
@ -252,11 +254,14 @@ _ecdb_hal_volume_all_cb(void *data __UNUSED__, void *reply_data,
ret = reply_data; ret = reply_data;
if ((!ret) || (!ret->strings)) if ((!ret) || (!ret->strings))
{
EINA_ERROR_PWARN("No DBus data!\n");
return; return;
}
if (dbus_error_is_set(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); dbus_error_free(error);
return; return;
} }
@ -264,7 +269,7 @@ _ecdb_hal_volume_all_cb(void *data __UNUSED__, void *reply_data,
EINA_LIST_FOREACH(ret->strings, l, udi) EINA_LIST_FOREACH(ret->strings, l, udi)
{ {
e_hal_device_get_all_properties(em->conn, udi, _ecdb_hal_volume_handle, 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; E_Hal_Device_Get_All_Properties_Return *ret;
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
Eina_List *l; Eina_List *l;
char *udi; char *udi, *disc_udi;
int err; int err;
ret = reply_data; ret = reply_data;
disc_udi = data;
if (!ret) if ((!ret) || (!disc_udi))
{
EINA_ERROR_PWARN("No DBus data or volume data!\n");
return; return;
}
if (dbus_error_is_set(error)) 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); dbus_error_free(error);
return; return;
} }
@ -301,6 +310,7 @@ _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error)
{ {
if (!strcmp(udi, drive->udi)) if (!strcmp(udi, drive->udi))
{ {
drive->disc_udi = disc_udi;
drive->capacity = e_hal_property_uint64_get(ret, drive->capacity = e_hal_property_uint64_get(ret,
"volume.disc.capacity", NULL); "volume.disc.capacity", NULL);
@ -323,7 +333,6 @@ _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error)
} }
} }
FREE(data);
FREE(udi); FREE(udi);
} }