4 * @brief Connman service request handling.
6 * @author Ossama Othman @<ossama.othman@@intel.com@>
9 * Copyright 2013 Intel Corporation All Rights Reserved.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation;
14 * version 2.1 of the License.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301 USA
27 #include "service.hpp"
29 #include <settingsd/glib_traits.hpp>
30 #include <settingsd/smart_ptr.hpp>
31 #include <settingsd/response_callback.hpp>
36 ivi::settings::service::service(std::string service_path)
37 : connman_("net.connman.Service", // Interface
38 service_path.c_str()) // Object path
43 ivi::settings::service::connect(response_callback response)
45 call_method("Connect", response);
49 ivi::settings::service::disconnect(response_callback response)
51 call_method("Disconnect", response);
55 ivi::settings::service::call_method(char const * name,
56 response_callback response)
58 constexpr gint const timeout = 10000; // milliseconds
59 GError * error = nullptr;
61 smart_ptr<GVariant> const ret(
62 g_dbus_proxy_call_sync(connman_.proxy(),
63 name, // "Connect", "Disconect", ...
64 nullptr, // No parameters
65 G_DBUS_CALL_FLAGS_NONE,
67 nullptr, // Not cancellable
70 smart_ptr<GError> safe_error;
73 // Nothing to add to successful response.
74 response.send_response(
75 [](JsonBuilder * /* builder */) {});
77 } else if (error != nullptr) {
78 response.send_error(std::string(name) + " failed: " + error->message);
86 // indent-tabs-mode: nil