4 * @brief Connman-based settings plugin header.
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
28 #ifndef IVI_SETTINGS_CONNMAN_HPP
29 #define IVI_SETTINGS_CONNMAN_HPP
31 #include <settingsd/glib_traits.hpp>
32 #include <settingsd/smart_ptr.hpp>
49 * @brief Common connman-based settings functionality.
51 * This class implements functionality common to all connman-based
52 * settings, such as bluetooth, wifi, date/time, etc.
61 * @param[in] interface Connman D-Bus interface.
62 * @param[in] path Connman D-Bus object path.
64 connman(char const * interface,
70 /// The type held by the @c future containing the async result.
71 typedef smart_ptr<GVariant> future_value_type;
73 /// The @c future type returned by the @c promise.
74 typedef std::future<future_value_type> future_type;
76 /// The @c promise that provides the async result.
77 typedef std::promise<future_value_type> promise_type;
80 * Smart pointer to the @c promise that provides the async
83 typedef std::shared_ptr<promise_type> shared_promise_type;
86 * Property Name/value pair type held by the @c future
87 * containing the async result. Both values will be populated
88 * when retrieving the value from the @c PropertyChanged
91 * @note The property name is meant for internal use.
93 typedef std::pair<char const *,
94 shared_promise_type> promise_value_type;
96 /// List type for promises to be updated with async result.
97 typedef std::list<promise_value_type> promise_list_type;
100 * Set @a property to given @a value on the underlying connman
103 * @param[in] property The name of the property to be set.
104 * @param[in] value The property value to be set.
105 * @param[inout] error The error object containing information
106 * on a failed connman @c SetProperty method
109 * @returns @c nullptr on a failed call to the connman
110 * @c SetProperty method.
112 GVariant * set_property(char const * property,
117 * Get a promise that will contain the changed connman property
118 * when it becomes available. The user must obtain the value
119 * from the corresponding future object.
121 shared_promise_type get_property_changed_promise(
122 char const * property);
124 /// Get pointer to underlying GDBusProxy.
125 GDBusProxy * proxy() const { return proxy_; }
127 /// Convenience function to get D-Bus interface name.
129 interface_name() const
131 return g_dbus_proxy_get_interface_name(proxy_);
134 /// Convenience function to get D-Bus object path.
138 return g_dbus_proxy_get_object_path(proxy_);
144 * @brief Struct passed to @c ServicesChanged signal handler.
149 user_data(std::mutex & m, promise_list_type & p)
156 * References to mutex used to synchronize access to the list
161 /// List of promises to be updated with the changed services.
162 promise_list_type & promises;
167 /// The proxy used to access the Connman D-Bus API.
170 /// Mutex used to synchronize access to the promises list.
174 * List of promises that will be updated with the
175 * PropertyChanged signal results.
177 promise_list_type promises_;
179 /// User data passed to @c PropertyChanged signal handler.
182 /// PropertyChanged signal subscription ID.
183 guint subscription_id_;
191 #endif /* IVI_SETTINGS_CONNMAN_HPP */
197 // indent-tabs-mode: nil