diff options
author | Steve Zesch <[email protected]> | 2012-11-22 14:20:39 -0800 |
---|---|---|
committer | Steve Zesch <[email protected]> | 2012-11-22 14:20:39 -0800 |
commit | 5a584a07fe8ea0507d4bfe5c1b98f052f0001042 (patch) | |
tree | fd232d283db15d5ade3605b9d276a80eea326a07 | |
parent | a39bbde3774a32bca86eb18654c1c0a880dc507a (diff) | |
parent | d3263c4135e55df4ceba1d609045ff680016054b (diff) | |
download | mate-sensors-applet-5a584a07fe8ea0507d4bfe5c1b98f052f0001042.tar.bz2 mate-sensors-applet-5a584a07fe8ea0507d4bfe5c1b98f052f0001042.tar.xz |
Merge pull request #3 from jrversteegh/udisks_by_id
Udisks by id rather than device node
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | plugins/udisks/udisks-plugin.c | 54 |
2 files changed, 46 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac index 5398f1d..4210b3b 100644 --- a/configure.ac +++ b/configure.ac @@ -103,9 +103,10 @@ LIBMATENOTIFY_CFLAGS= LIBMATENOTIFY_LIBS= # enable support even if not specifically asked for -AC_ARG_ENABLE(libmatenotify, [ --enable-libmatenotify enable libmatenotify support], [ - enable_libmatenotify=$enableval], [ - enable_libmatenotify="yes" +AC_ARG_ENABLE(libmatenotify, +[ --enable-libmatenotify Enable libmatenotify support], [ + enable_libmatenotify=$enableval], [ + enable_libmatenotify="yes" ]) if test "x$enable_libmatenotify" = "xno" @@ -167,7 +168,7 @@ AC_SUBST(LIBSENSORS_LIBS) # do nvidia by default if available AC_ARG_WITH(nvidia, -[ --with-nvidia[=DIR] use nvidia in DIR],[ +[ --with-nvidia[=DIR] use nvidia in DIR],[ if test "$withval" != "no" -a "$withval" != "yes"; then NVIDIA_DIR=$withval CFLAGS="${CFLAGS} -I${NVIDIA_DIR}/include" @@ -181,7 +182,7 @@ if test "$with_nvidia" = "no"; then echo "Disabling nvidia support" else AC_ARG_WITH(x11, - [ --with-x11[=DIR] use x11 in DIR],[ + [ --with-x11[=DIR] use x11 in DIR],[ if test "$withval" != "no" -a "$withval" != "yes"; then X11_DIR=$withval CFLAGS="${CFLAGS} -I${X11_DIR}/include" @@ -215,8 +216,9 @@ AM_CONDITIONAL(NVIDIA, test -n "$NVIDIA_LIBS") AC_SUBST(NVIDIA_CFLAGS) AC_SUBST(NVIDIA_LIBS) -AC_ARG_WITH(aticonfig, [ - --with-aticonfig[=PATH] use aticonfig provided by PATH], [ +AC_ARG_WITH(aticonfig, +[ --with-aticonfig[=PATH] use aticonfig plugin with optional binary provided + by PATH], [ if test "$withval" != "no" -a "$withval" != "yes"; then aticonfig_exe=$withval else diff --git a/plugins/udisks/udisks-plugin.c b/plugins/udisks/udisks-plugin.c index 4995f08..77d066f 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]> * @@ -39,6 +40,7 @@ */ typedef struct _DevInfo{ gchar *path; + gchar *id; gboolean changed; gdouble temp; DBusGProxy *sensor_proxy; @@ -115,7 +117,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 +132,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); @@ -170,38 +182,46 @@ static void udisks_plugin_get_sensors(GList **sensors) { G_CALLBACK(udisks_changed_signal_cb), path, NULL); + + 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; + info = g_malloc(sizeof(DevInfo)); if (devices == NULL) { devices = g_hash_table_new(g_str_hash, g_str_equal); } + info->id = g_strdup(id); info->path = g_strdup(path); info->sensor_proxy = sensor_proxy; /* Set the device status changed as TRUE because we need * to get the initial temperature reading */ info->changed = TRUE; - g_hash_table_insert(devices, info->path, info); + g_hash_table_insert(devices, info->id, info); /* 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, + "Disk Temperature", + 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); @@ -243,7 +263,7 @@ static gdouble udisks_plugin_get_sensor_value(const gchar *path, GValue smart_time = { 0, }; sensor_proxy = dbus_g_proxy_new_for_name(connection, UDISKS_BUS_NAME, - path, + info->path, UDISKS_PROPERTIES_INTERFACE); if (!dbus_g_proxy_call(sensor_proxy, "Get", error, G_TYPE_STRING, UDISKS_BUS_NAME, |