diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2008-11-24 11:06:26 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2008-11-24 11:06:26 +0100 |
| commit | e91aa6d32b6eeba311b37b4139f6bf3eaf20cf26 (patch) | |
| tree | 0f3599142e185a4087d8b8d68e519c0ed653f4db /hald-addon-generic-backlight.c | |
| parent | 8a6c3c55a7b5ff2042ad6973ddd7ab73236de047 (diff) | |
Adapting code copy to work with the right dbus (laptop_panel) interface
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'hald-addon-generic-backlight.c')
| -rw-r--r-- | hald-addon-generic-backlight.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/hald-addon-generic-backlight.c b/hald-addon-generic-backlight.c index 537ab69..09ab668 100644 --- a/hald-addon-generic-backlight.c +++ b/hald-addon-generic-backlight.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | * | 2 | * |
| 3 | * addon-generic-kbd-backlight.c: | 3 | * addon-generic-backlight.c: |
| 4 | * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se> | 4 | * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se> |
| 5 | * | 5 | * |
| 6 | * Based on addon-generic-backlight.c: | 6 | * Based on upstream addon-generic-backlight.c: |
| 7 | * Copyright (C) 2008 Danny Kukawka <danny.kukawka@web.de> | 7 | * Copyright (C) 2008 Danny Kukawka <danny.kukawka@web.de> |
| 8 | * | 8 | * |
| 9 | * Licensed under the Academic Free License version 2.1 | 9 | * Licensed under the Academic Free License version 2.1 |
| @@ -36,7 +36,7 @@ | |||
| 36 | #include "dbus-abi.h" | 36 | #include "dbus-abi.h" |
| 37 | #include "hal-abi.h" | 37 | #include "hal-abi.h" |
| 38 | 38 | ||
| 39 | #define HAL_PROPERTY "org.freedesktop.Hal.Device.KeyboardBacklight" | 39 | #define HAL_PROPERTY "org.freedesktop.Hal.Device.LaptopPanel" |
| 40 | 40 | ||
| 41 | static const char prop_name[] = HAL_PROPERTY; | 41 | static const char prop_name[] = HAL_PROPERTY; |
| 42 | static const char prop_invalid[] = HAL_PROPERTY ".Invalid"; | 42 | static const char prop_invalid[] = HAL_PROPERTY ".Invalid"; |
| @@ -51,14 +51,14 @@ static char sysfs_path[512]; | |||
| 51 | static int levels; | 51 | static int levels; |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | * Get keyboard backlight level | 54 | * Get LCD backlight level |
| 55 | * | 55 | * |
| 56 | * Tries to read from the specified sysfs device, and if successful, | 56 | * Tries to read from the specified sysfs device, and if successful, |
| 57 | * updates the internal keyboard backlight state. Warns if the device | 57 | * updates the internal LCD backlight state. Warns if the device |
| 58 | * cannot be opened or be read from. Always returns the last succesful | 58 | * cannot be opened or be read from. Always returns the last succesful |
| 59 | * read. | 59 | * read. |
| 60 | */ | 60 | */ |
| 61 | static int get_kbd_backlight() | 61 | static int get_lcd_backlight() |
| 62 | { | 62 | { |
| 63 | static int level; | 63 | static int level; |
| 64 | int fd; | 64 | int fd; |
| @@ -81,12 +81,12 @@ static int get_kbd_backlight() | |||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | /** | 83 | /** |
| 84 | * Set keyboard backlight level | 84 | * Set LCD backlight level |
| 85 | * | 85 | * |
| 86 | * Warns if the device cannot be opened or be written to. | 86 | * Warns if the device cannot be opened or be written to. |
| 87 | * Returns bytes written on success, negative value on failure. | 87 | * Returns bytes written on success, negative value on failure. |
| 88 | */ | 88 | */ |
| 89 | static int set_kbd_backlight(int level) | 89 | static int set_lcd_backlight(int level) |
| 90 | { | 90 | { |
| 91 | int fd, ret; | 91 | int fd, ret; |
| 92 | char buf[64]; | 92 | char buf[64]; |
| @@ -107,8 +107,8 @@ static int set_kbd_backlight(int level) | |||
| 107 | return ret; | 107 | return ret; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | /* DBus set keyboard backlight level */ | 110 | /* DBus set LCD backlight level */ |
| 111 | static struct DBusMessage *dbus_get_kbd_backlight(struct DBusMessage *msg) | 111 | static struct DBusMessage *dbus_get_lcd_backlight(struct DBusMessage *msg) |
| 112 | { | 112 | { |
| 113 | struct DBusError err; | 113 | struct DBusError err; |
| 114 | struct DBusMessage *reply; | 114 | struct DBusMessage *reply; |
| @@ -119,7 +119,7 @@ static struct DBusMessage *dbus_get_kbd_backlight(struct DBusMessage *msg) | |||
| 119 | return dbus_message_new_error(msg, prop_invalid, | 119 | return dbus_message_new_error(msg, prop_invalid, |
| 120 | "Invalid message"); | 120 | "Invalid message"); |
| 121 | 121 | ||
| 122 | level = get_kbd_backlight(); | 122 | level = get_lcd_backlight(); |
| 123 | 123 | ||
| 124 | reply = dbus_message_new_method_return(msg); | 124 | reply = dbus_message_new_method_return(msg); |
| 125 | if (reply) | 125 | if (reply) |
| @@ -129,8 +129,8 @@ static struct DBusMessage *dbus_get_kbd_backlight(struct DBusMessage *msg) | |||
| 129 | return reply; | 129 | return reply; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | /* DBus set keyboard backlight level */ | 132 | /* DBus set LCD backlight level */ |
| 133 | static struct DBusMessage *dbus_set_kbd_backlight(struct DBusMessage *msg) | 133 | static struct DBusMessage *dbus_set_lcd_backlight(struct DBusMessage *msg) |
| 134 | { | 134 | { |
| 135 | struct DBusError err; | 135 | struct DBusError err; |
| 136 | int level; | 136 | int level; |
| @@ -145,7 +145,7 @@ static struct DBusMessage *dbus_set_kbd_backlight(struct DBusMessage *msg) | |||
| 145 | return dbus_message_new_error(msg, prop_invalid, | 145 | return dbus_message_new_error(msg, prop_invalid, |
| 146 | "Brightness level is invalid"); | 146 | "Brightness level is invalid"); |
| 147 | 147 | ||
| 148 | set_kbd_backlight(level); | 148 | set_lcd_backlight(level); |
| 149 | 149 | ||
| 150 | return dbus_message_new_method_return(msg); | 150 | return dbus_message_new_method_return(msg); |
| 151 | } | 151 | } |
| @@ -158,9 +158,9 @@ static DBusHandlerResult filter_function(struct DBusConnection *connection, | |||
| 158 | struct DBusMessage *reply = NULL; | 158 | struct DBusMessage *reply = NULL; |
| 159 | 159 | ||
| 160 | if (dbus_message_is_method_call(message, prop_name, prop_get)) | 160 | if (dbus_message_is_method_call(message, prop_name, prop_get)) |
| 161 | reply = dbus_get_kbd_backlight(message); | 161 | reply = dbus_get_lcd_backlight(message); |
| 162 | else if (dbus_message_is_method_call(message, prop_name, prop_set)) | 162 | else if (dbus_message_is_method_call(message, prop_name, prop_set)) |
| 163 | reply = dbus_set_kbd_backlight(message); | 163 | reply = dbus_set_lcd_backlight(message); |
| 164 | 164 | ||
| 165 | if (reply) { | 165 | if (reply) { |
| 166 | dbus_connection_send(connection, reply, NULL); | 166 | dbus_connection_send(connection, reply, NULL); |
| @@ -177,7 +177,7 @@ int main(int argc, char *argv[]) | |||
| 177 | 177 | ||
| 178 | char *udi = getenv("UDI"); | 178 | char *udi = getenv("UDI"); |
| 179 | char *path = getenv("HAL_PROP_LINUX_SYSFS_PATH"); | 179 | char *path = getenv("HAL_PROP_LINUX_SYSFS_PATH"); |
| 180 | char *level_str = getenv("HAL_PROP_KEYBOARD_BACKLIGHT_NUM_LEVELS"); | 180 | char *level_str = getenv("HAL_PROP_LAPTOP_PANEL_NUM_LEVELS"); |
| 181 | 181 | ||
| 182 | setup_logger(); | 182 | setup_logger(); |
| 183 | 183 | ||
| @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) | |||
| 190 | return -2; | 190 | return -2; |
| 191 | } | 191 | } |
| 192 | if (level_str == NULL) { | 192 | if (level_str == NULL) { |
| 193 | HAL_ERROR(("No keyboard_backlight.num_levels defined")); | 193 | HAL_ERROR(("No laptop_panel.num_levels defined")); |
| 194 | return -2; | 194 | return -2; |
| 195 | } | 195 | } |
| 196 | 196 | ||
