diff options
Diffstat (limited to 'rcm-server-main.c')
-rw-r--r-- | rcm-server-main.c | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/rcm-server-main.c b/rcm-server-main.c index 33ef8a7..5cb5ebe 100644 --- a/rcm-server-main.c +++ b/rcm-server-main.c @@ -20,14 +20,14 @@ #include "rcm-server-lirc.h" #include "rcm-server-kdb.h" -static struct device * +static struct rc_device * find_device_by_path(struct manager *mgr, const char *path) { - struct device *dev; + struct rc_device *rcdev; - list_for_each_entry(dev, &mgr->devices, list) - if (!strcmp(dev->path, path)) - return dev; + list_for_each_entry(rcdev, &mgr->rc_devs, list) + if (!strcmp(rcdev->path, path)) + return rcdev; return NULL; } @@ -38,26 +38,26 @@ property_get(sd_bus *bus, const char *path, const char *interface, sd_bus_error *error) { struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; - dev = find_device_by_path(mgr, path); - if (!dev) { + rcdev = find_device_by_path(mgr, path); + if (!rcdev) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); return -EINVAL; } if (!strcmp(property, "SysName")) - return sd_bus_message_append(reply, "s", dev->name); + return sd_bus_message_append(reply, "s", rcdev->name); else if (!strcmp(property, "Description")) - return sd_bus_message_append(reply, "s", dev->input_name); + return sd_bus_message_append(reply, "s", rcdev->input_name); else if (!strcmp(property, "DriverName")) - return sd_bus_message_append(reply, "s", dev->driver_name); + return sd_bus_message_append(reply, "s", rcdev->driver_name); else if (!strcmp(property, "KernelKeymapName")) - return sd_bus_message_append(reply, "s", dev->keymap_name); + return sd_bus_message_append(reply, "s", rcdev->keymap_name); else if (!strcmp(property, "HardwareType")) return sd_bus_message_append(reply, "s", "ir"); else if (!strcmp(property, "Error")) - return sd_bus_message_append(reply, "s", dev->error); + return sd_bus_message_append(reply, "s", rcdev->error); sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidProperty", "Sorry, invalid property"); return -EINVAL; @@ -216,20 +216,20 @@ method_getkernelmappings(sd_bus_message *m, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; unsigned protocol_numeric; uint64_t scancode; struct linux_input_keycode *lik; unsigned i = 0; int r; - dev = find_device_by_path(mgr, sd_bus_message_get_path(m)); - if (!dev) { + rcdev = find_device_by_path(mgr, sd_bus_message_get_path(m)); + if (!rcdev) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); return -EINVAL; } - if (dev->evdev_fd < 0) { + if (rcdev->evdev_fd < 0) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.EvdevError", "Evdev device not available"); r = -EINVAL; goto out; @@ -243,7 +243,7 @@ method_getkernelmappings(sd_bus_message *m, void *userdata, sd_bus_error *error) if (r < 0) goto out; - while ((r = evdev_get_mapping(dev, i, &protocol_numeric, &scancode, &lik)) > 0) { + while ((r = evdev_get_mapping(rcdev, i, &protocol_numeric, &scancode, &lik)) > 0) { r = sd_bus_message_append(reply, "a{sv}", 3, "protocol", "s", rc_protocols[protocol_numeric], "scancode", "t", scancode, @@ -276,20 +276,20 @@ method_setkernelmappings(sd_bus_message *m, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; unsigned protocol; uint64_t scancode; struct linux_input_keycode *keycode; int r; - dev = find_device_by_path(mgr, sd_bus_message_get_path(m)); - if (!dev) { + rcdev = find_device_by_path(mgr, sd_bus_message_get_path(m)); + if (!rcdev) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); r = -EINVAL; goto out; } - if (dev->evdev_fd < 0) { + if (rcdev->evdev_fd < 0) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.EvdevError", "Evdev device not available"); r = -EINVAL; goto out; @@ -303,7 +303,7 @@ method_setkernelmappings(sd_bus_message *m, void *userdata, sd_bus_error *error) printf("%s kernel mapping %s:0x%08lx:%s\n", keycode ? "Setting" : "Unsetting", rc_protocols[protocol], scancode, keycode ? keycode->name : "<na>"); - evdev_set_mapping(dev, protocol, scancode, keycode); + evdev_set_mapping(rcdev, protocol, scancode, keycode); } if (r < 0) @@ -324,12 +324,12 @@ method_listkeymaps(sd_bus_message *m, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; struct keymap *keymap; int r; - dev = find_device_by_path(mgr, sd_bus_message_get_path(m)); - if (!dev) { + rcdev = find_device_by_path(mgr, sd_bus_message_get_path(m)); + if (!rcdev) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); return -EINVAL; } @@ -342,8 +342,8 @@ method_listkeymaps(sd_bus_message *m, void *userdata, sd_bus_error *error) if (r < 0) goto out; - list_for_each_entry(keymap, &dev->keymaps, list) { - printf("Listing keymaps for %s: %s\n", dev->name, keymap->name); + list_for_each_entry(keymap, &rcdev->keymaps, list) { + printf("Listing keymaps for %s: %s\n", rcdev->name, keymap->name); r = sd_bus_message_append(reply, "s", keymap->id); if (r < 0) goto out; @@ -368,14 +368,14 @@ method_getkeymap(sd_bus_message *m, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; struct keymap *keymap; const char *id; int r; unsigned i; - dev = find_device_by_path(mgr, sd_bus_message_get_path(m)); - if (!dev) { + rcdev = find_device_by_path(mgr, sd_bus_message_get_path(m)); + if (!rcdev) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); return -EINVAL; } @@ -386,7 +386,7 @@ method_getkeymap(sd_bus_message *m, void *userdata, sd_bus_error *error) return r; } - keymap = find_keymap_by_id(dev, id); + keymap = find_keymap_by_id(rcdev, id); if (!keymap) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidKeymap", "Sorry, unknown keymap"); return -EINVAL; @@ -726,7 +726,7 @@ static int method_setkeymap(sd_bus_message *m, void *userdata, sd_bus_error *error) { struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; struct keymap *old_keymap; struct keymap *new_keymap; const char *id; @@ -734,15 +734,15 @@ method_setkeymap(sd_bus_message *m, void *userdata, sd_bus_error *error) uint16_t cols, rows; int r; - dev = find_device_by_path(mgr, sd_bus_message_get_path(m)); - if (!dev) + rcdev = find_device_by_path(mgr, sd_bus_message_get_path(m)); + if (!rcdev) return sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); r = method_setkeymap_parse_dbus_msg(m, NULL, &id, &keycode_count, &cols, &rows); if (r < 0) goto out; - old_keymap = find_keymap_by_id(dev, id); + old_keymap = find_keymap_by_id(rcdev, id); if (!old_keymap) return sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidKeymap", "Sorry, unknown keymap"); @@ -788,7 +788,7 @@ method_transmit(sd_bus_message *m, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; struct manager *mgr = userdata; - struct device *dev; + struct rc_device *rcdev; const void *v; size_t l; int r; @@ -796,8 +796,8 @@ method_transmit(sd_bus_message *m, void *userdata, sd_bus_error *error) size_t count; printf("Transmit method called\n"); - dev = find_device_by_path(mgr, sd_bus_message_get_path(m)); - if (!dev) { + rcdev = find_device_by_path(mgr, sd_bus_message_get_path(m)); + if (!rcdev) { sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidDevice", "Sorry, invalid device"); return -EINVAL; } @@ -812,8 +812,7 @@ method_transmit(sd_bus_message *m, void *userdata, sd_bus_error *error) values = v; count = l / sizeof(uint32_t); - lirc_write(dev->lirc_fd, values, count); - + lirc_write(rcdev->lirc_fd, values, count); return sd_bus_reply_method_return(m, NULL); @@ -846,18 +845,18 @@ enumerator(sd_bus *bus, const char *path, void *userdata, char ***retnodes, sd_b { _cleanup_strv_free_ char **nodes = NULL; struct manager *mgr = userdata; - struct device *device; + struct rc_device *rcdev; int i = 0; if (!path) return 0; - nodes = zmalloc((mgr->num_devices + 1) * sizeof(char *)); + nodes = zmalloc((mgr->num_rc_devs + 1) * sizeof(char *)); if (!nodes) return -ENOMEM; - list_for_each_entry(device, &mgr->devices, list) { - nodes[i] = strdup(device->path); + list_for_each_entry(rcdev, &mgr->rc_devs, list) { + nodes[i] = strdup(rcdev->path); if (!nodes[i]) return -ENOMEM; i++; @@ -881,9 +880,9 @@ free_manager(struct manager *mgr) { sd_event_unref(mgr->event); udev_close(mgr); - while (!list_empty(&mgr->devices)) { - struct device *dev = list_first_entry(&mgr->devices, typeof(*dev), list); - device_free(dev); + while (!list_empty(&mgr->rc_devs)) { + struct rc_device *rcdev = list_first_entry(&mgr->rc_devs, typeof(*rcdev), list); + rc_device_free(rcdev); } free(mgr); } @@ -926,7 +925,7 @@ main(int argc, char **argv) fprintf(stderr, "Failed to allocate memory: %m\n"); goto finish; } - list_init(&mgr->devices); + list_init(&mgr->rc_devs); r = sd_event_default(&mgr->event); if (r < 0) { |