2 * @file connman_manager.cpp
4 * @brief Connman Manager operations.
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 "connman_manager.hpp"
28 #include "signal_callback.hpp"
30 #include <settingsd/glib_traits.hpp>
31 #include <settingsd/smart_ptr.hpp>
36 ivi::settings::connman_manager::connman_manager(
37 event_callback const & e)
38 : connman_("net.connman.Manager", // Interface
43 g_dbus_connection_signal_subscribe(
44 g_dbus_proxy_get_connection(G_DBUS_PROXY(connman_.proxy())),
46 connman_.interface_name(),
48 connman_.object_path(),
50 G_DBUS_SIGNAL_FLAGS_NONE,
57 ivi::settings::connman_manager::~connman_manager()
59 g_dbus_connection_signal_unsubscribe(
60 g_dbus_proxy_get_connection(G_DBUS_PROXY(connman_.proxy())),
65 ivi::settings::connman_manager::get_properties(
66 std::string const & technology,
67 GError *& error) const
69 constexpr gint const timeout = 5000; // milliseconds
71 smart_ptr<GVariant> const dictionary(
72 g_dbus_proxy_call_sync(connman_.proxy(),
74 nullptr, // No parameters
75 G_DBUS_CALL_FLAGS_NONE,
77 nullptr, // Not cancellable
80 if (dictionary != nullptr) {
81 GVariantIter * i = nullptr;
82 g_variant_get(dictionary.get(), "(a(oa{sv}))", &i);
83 smart_ptr<GVariantIter> const safe_i(i);
85 for (smart_ptr<GVariant> child(g_variant_iter_next_value(i));
87 child.reset(g_variant_iter_next_value(i))) {
89 // The object path is the first tuple element.
90 smart_ptr<GVariant> const tmp(
91 g_variant_get_child_value(child.get(), 0));
94 g_variant_get_string(tmp.get(), nullptr);
96 // The technology is found at end the object path,
97 // e.g. "/net/connman/technology/wifi" for the wifi.
98 char const * tech = strrchr(object, '/');
100 if (tech != nullptr) {
101 ++tech; // Skip the found '/'.
103 if (technology == tech) {
104 // The property dictionary is the second tuple element.
105 return g_variant_get_child_value(child.get(), 1);
115 ivi::settings::connman_manager::get_services(GError *& error) const
117 constexpr gint const timeout = 5000; // milliseconds
119 return g_dbus_proxy_call_sync(connman_.proxy(),
121 nullptr, // No parameters
122 G_DBUS_CALL_FLAGS_NONE,
124 nullptr, // Not cancellable
132 // indent-tabs-mode: nil