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/unique_ptr.hpp>
31 #include <settingsd/response_callback.hpp>
36 ivi::settings::service::service(std::string service_path,
37 GDBusConnection * connection,
38 event_callback const & e)
39 : connman_("net.connman.Service", // Interface
40 service_path.c_str(), // Object path
47 ivi::settings::service::connect(response_callback response)
49 call_method("Connect", response);
53 ivi::settings::service::disconnect(response_callback response)
55 call_method("Disconnect", response);
59 ivi::settings::service::call_method(char const * name,
60 response_callback response)
62 constexpr gint const timeout = 10000; // milliseconds
63 GError * error = nullptr;
65 unique_ptr<GVariant> const ret(
66 g_dbus_proxy_call_sync(connman_.proxy(),
67 name, // "Connect", "Disconect", ...
68 nullptr, // No parameters
69 G_DBUS_CALL_FLAGS_NONE,
71 nullptr, // Not cancellable
74 unique_ptr<GError> safe_error;
77 // Nothing to add to successful response.
78 response.send_response(
79 [](JsonBuilder * /* builder */) {});
81 } else if (error != nullptr) {
82 response.send_error(std::string(name) + " failed: " + error->message);
90 // indent-tabs-mode: nil