diff options
author | Evgeniy Alexeev <e.alekseev@k-soft-spb.ru> | 2022-10-10 17:07:45 +0300 |
---|---|---|
committer | Evgeniy Alexeev <e.alekseev@k-soft-spb.ru> | 2022-10-10 17:07:45 +0300 |
commit | 21c36beefd0304a600a2f781a60559f647d569fb (patch) | |
tree | e2862ee2d9f3f807487601319055ce726fdd00ad /src/d_bus_commands.c | |
parent | b6f6416fa4dfbff9c677c4491fb42c5d3adb9d44 (diff) | |
download | sila-shell-21c36beefd0304a600a2f781a60559f647d569fb.tar.xz |
Begin to add variant type
Diffstat (limited to 'src/d_bus_commands.c')
-rw-r--r-- | src/d_bus_commands.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/d_bus_commands.c b/src/d_bus_commands.c index c7878a6..5cb5767 100644 --- a/src/d_bus_commands.c +++ b/src/d_bus_commands.c @@ -3,6 +3,7 @@ #include <errno.h> #include "d_bus_commands.h" +#include <d_bus_variant.h> void print_command_help(const universal_command_t* cmds) { @@ -43,20 +44,32 @@ const string_quadruple_t* get_dbus_command_interface(int cmd, const command_dbus return NULL; } -const char* get_dbus_command_member(int cmd, const command_dbus_member_t* values) + +const dbus_value_variant_t* get_dbus_command_member(int cmd, const command_dbus_member_t* values) { - for(const command_dbus_member_t* current = values; current->member!=NULL; current++) + for(const command_dbus_member_t* current = values; current->member.type != NULL; current++) { - if(current->command == cmd)return current->member; + if(current->command == cmd)return &(current->member); + } + return NULL; +} + + +const char* get_dbus_command_member_string(int cmd, const command_dbus_member_t* values) +{ + for(const command_dbus_member_t* current = values; current->member.type != NULL; current++) + { + if(current->command == cmd)return dbus_variant_get_string(&(current->member)); } return NULL; } const command_dbus_member_t* get_dbus_command_by_member(const char* member, const command_dbus_member_t* values) { - for(const command_dbus_member_t* current = values; current->member!=NULL; current++) + for(const command_dbus_member_t* current = values; current->member.type != NULL; current++) { - if(strcmp(member, current->member) == 0 )return current; + + if(strcmp(member, dbus_variant_get_string(¤t->member)) == 0 )return current; } return NULL; } @@ -72,7 +85,7 @@ int com_dbus_property( char *arg, const universal_command_t* commands, const com const string_quadruple_t* dbus_power_interface = get_dbus_command_interface(cmd, paths); if(!dbus_power_interface) return -EOPNOTSUPP; - const char* property_val = get_dbus_command_member(cmd, values); + const char* property_val = get_dbus_command_member_string(cmd, values); if(!property_val) return -EOPNOTSUPP; return dbus_set_property_string(dbus_power_interface, property_val); |