diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-07-26 16:38:53 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-07-26 16:38:53 +0100 |
commit | e3b36473ed5400c60f4f08b8cc88bc4e384f3b32 (patch) | |
tree | a902feacc2a57396b8624dc0c9490d0625f9ed83 | |
parent | bdfda68f33615dd7f24b35f425c44c9ef63a1675 (diff) | |
download | ayatana-indicator-session-e3b36473ed5400c60f4f08b8cc88bc4e384f3b32.tar.gz ayatana-indicator-session-e3b36473ed5400c60f4f08b8cc88bc4e384f3b32.tar.bz2 ayatana-indicator-session-e3b36473ed5400c60f4f08b8cc88bc4e384f3b32.zip |
research trace for devices in udev
-rw-r--r-- | src/sane_rules.h | 0 | ||||
-rw-r--r-- | src/udev-mgr.c | 42 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/sane_rules.h b/src/sane_rules.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/sane_rules.h diff --git a/src/udev-mgr.c b/src/udev-mgr.c index e100f16..4dde1b8 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -20,6 +20,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "udev-mgr.h" #include <gudev/gudev.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdarg.h> + static void udevice_mgr_device_list_iterator (gpointer data, gpointer userdata); static void udev_mgr_uevent_cb (GUdevClient *client, @@ -87,8 +92,43 @@ static void udev_mgr_uevent_cb (GUdevClient *client, GUdevDevice *device, gpointer user_data) { - g_debug ("just received a UEVENT with an action : %s", action); g_return_if_fail (UDEV_IS_MGR (user_data)); + + g_debug ("just received a UEVENT with an action : %s", action); + + const gchar* vendor; + const gchar* product; + const gchar* number; + + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + product = g_udev_device_get_property (device, "ID_MODEL_ID"); + number = g_udev_device_get_number (device); + g_debug ("device vendor id %s and product id of %s and number of %s", + g_strdup(vendor), + g_strdup(product), + g_strdup(number)); + + const gchar *const *list; + const gchar *const *iter; + char propstr[500]; + guint32 namelen = 0, i; + + list = g_udev_device_get_property_keys(device); + + for (iter = list; iter && *iter; iter++) { + if (strlen(*iter) > namelen) + namelen = strlen(*iter); + } + namelen++; + + for (iter = list; iter && *iter; iter++) { + strcpy(propstr, *iter); + strcat(propstr, ":"); + for (i = 0; i < namelen - strlen(*iter); i++) + strcat(propstr, " "); + strcat(propstr, g_udev_device_get_property(device, *iter)); + g_debug("%s", propstr); + } } |