diff options
author | Jaap Versteegh <[email protected]> | 2012-07-26 18:49:35 +0200 |
---|---|---|
committer | Jaap Versteegh <[email protected]> | 2012-07-26 18:49:35 +0200 |
commit | 58aeb9344c1794551d159d6a7dafed74ac0e08e0 (patch) | |
tree | 410daba5073dfa5c2dd1c04ef9e2b3d2bdae11b1 /plugins/udisks | |
parent | dc567aaead4dc270ea7a39b0c03d10922b03baec (diff) | |
download | mate-sensors-applet-58aeb9344c1794551d159d6a7dafed74ac0e08e0.tar.bz2 mate-sensors-applet-58aeb9344c1794551d159d6a7dafed74ac0e08e0.tar.xz |
List disks by persistent id rather than device node
Diffstat (limited to 'plugins/udisks')
-rw-r--r-- | plugins/udisks/udisks-plugin.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/plugins/udisks/udisks-plugin.c b/plugins/udisks/udisks-plugin.c index 16fed3c..9763015 100644 --- a/plugins/udisks/udisks-plugin.c +++ b/plugins/udisks/udisks-plugin.c @@ -1,4 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * vim: sts=0 sw=8 ts=8 tw=78 noexpandtab * * Copyright (C) 2009 Pramod Dematagoda <[email protected]> * @@ -115,7 +116,7 @@ static void udisks_plugin_get_sensors(GList **sensors) { /* This proxy is used to get the required data in order to build * up the list of sensors */ - GValue model = {0, }, id = {0, }, smart_available = {0, }; + GValue smart_available = G_VALUE_INIT; gchar *path = (gchar *)g_ptr_array_index(paths, i); sensor_proxy = dbus_g_proxy_new_for_name(connection, @@ -130,27 +131,37 @@ static void udisks_plugin_get_sensors(GList **sensors) { "DriveAtaSmartIsAvailable", G_TYPE_INVALID, G_TYPE_VALUE, &smart_available, G_TYPE_INVALID)) { - gchar *id_str, *model_str; if (!g_value_get_boolean(&smart_available)) { - g_debug("Drive at path '%s' does not support Smart monitoring... ignoring", + g_debug("Drive at path '%s' does not support " + "Smart monitoring... ignoring", path); g_object_unref(sensor_proxy); g_free (path); continue; } + GValue model_v = G_VALUE_INIT; dbus_g_proxy_call(sensor_proxy, "Get", NULL, G_TYPE_STRING, UDISKS_BUS_NAME, G_TYPE_STRING, "DriveModel", G_TYPE_INVALID, - G_TYPE_VALUE, &model, + G_TYPE_VALUE, &model_v, G_TYPE_INVALID); + GValue dev_v = G_VALUE_INIT; dbus_g_proxy_call(sensor_proxy, "Get", NULL, G_TYPE_STRING, UDISKS_BUS_NAME, G_TYPE_STRING, "DeviceFile", G_TYPE_INVALID, - G_TYPE_VALUE, &id, + G_TYPE_VALUE, &dev_v, + G_TYPE_INVALID); + + GValue ids_v = G_VALUE_INIT; + dbus_g_proxy_call(sensor_proxy, "Get", NULL, + G_TYPE_STRING, UDISKS_BUS_NAME, + G_TYPE_STRING, "DeviceFileById", + G_TYPE_INVALID, + G_TYPE_VALUE, &ids_v, G_TYPE_INVALID); g_object_unref(sensor_proxy); @@ -184,24 +195,30 @@ static void udisks_plugin_get_sensors(GList **sensors) { info->changed = TRUE; g_hash_table_insert(devices, info->path, info); + gchar *model = g_value_get_string(&model_v); + gchar *dev = g_value_get_string(&dev_v); + GStrv ids = g_value_get_boxed(&ids_v); + + gchar *id = ids != NULL && ids[0] != NULL ? ids[0] : dev; + /* Write the sensor data */ - id_str = g_value_get_string(&id); - model_str = g_value_get_string(&model); sensors_applet_plugin_add_sensor(sensors, path, - id_str, - model_str, + id, + model, TEMP_SENSOR, FALSE, HDD_ICON, DEFAULT_GRAPH_COLOR); - g_free(id_str); - g_free(model_str); + g_strfreev(ids); + g_free(model); + g_free(dev); + g_debug("Added %s %s", path, id); } else { g_debug ("Cannot obtain data for device: %s\n" - "Error: %s\n", - path, - error->message); + "Error: %s\n", + path, + error->message); g_error_free (error); error = NULL; g_object_unref(sensor_proxy); |