diff options
Diffstat (limited to 'plugins/connman/service.cpp')
-rw-r--r-- | plugins/connman/service.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/plugins/connman/service.cpp b/plugins/connman/service.cpp index 463b191..8d25157 100644 --- a/plugins/connman/service.cpp +++ b/plugins/connman/service.cpp @@ -30,7 +30,7 @@ #include <settingsd/unique_ptr.hpp> #include <settingsd/response_callback.hpp> -#include <chrono> +#include <cstring> ivi::settings::service::service(std::string service_path, @@ -44,14 +44,47 @@ ivi::settings::service::service(std::string service_path, } void -ivi::settings::service::connect(response_callback response) +ivi::settings::service::handle_request(char const * name, + JsonReader * reader, + response_callback & response) +{ + if (name != nullptr) { + if (strcmp(name, "connect") == 0) + connect(reader, response); + else if (strcmp(name, "disconnect") == 0) + disconnect(reader, response); + else { + response.send_error( + std::string("Unrecognized connman service request name: ") + + name); + } + } +} + +void +ivi::settings::service::connect(JsonReader * /* reader */, + response_callback response) { call_method("Connect", response); } void -ivi::settings::service::disconnect(response_callback response) +ivi::settings::service::disconnect(JsonReader * reader, + response_callback response) { + bool null = false; + // The value is the second array element. + if (json_reader_read_element(reader, 1)) { + null = json_reader_get_null_value(reader); + } + json_reader_end_element(reader); + + if (!null) { + response.send_error( + "connman::service::disconnect parameter is not null."); + return; + } + call_method("Disconnect", response); } |