1 /******************************************************************
3 * Copyright 2015 Intel Corporation All Rights Reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 ******************************************************************/
19 #ifndef CA_BLE_LINUX_UTILS_H
20 #define CA_BLE_LINUX_UTILS_H
26 * Proxy retrieval filter function type.
28 * A function that implements this interface may be passed to
29 * @c CAGetBlueZManagedObjectProxies() to filter proxies to be added
30 * to the returned list.
32 * @return @c true if the proxy should be added to the proxy list,
35 typedef bool(*CALEProxyFilter)(GDBusProxy * proxy);
38 * Get information for all BlueZ managed objects with a given
41 * @param[out] proxies List containing @a proxies (@c GDBusProxy)
42 * for all found BlueZ objects that match the
43 * given D-Bus @a interface.
44 * @param[in] interface D-Bus interface of BlueZ object for which a
45 * proxy will be created.
46 * @param[in] context BLE Linux adapter context.
47 * @param[in] filter Filter function used to determine whether or
48 * not a proxy retrieved from the BlueZ
49 * @c ObjectManager should be added to the
50 * returned @a proxies list.
52 * @return @c true if objects were found.
54 bool CAGetBlueZManagedObjectProxies(GList ** proxies,
55 char const * interface,
56 CALEContext * context,
57 CALEProxyFilter filter);
61 * Get the proxy to a object that implements the given D-Bus
64 * @param[in] tuple A D-Bus tuple that contains the D-Bus object
65 * path and corresponding dictionary of
66 * properties, i.e. with the format specifier
68 * @param[in] interface The D-Bus interface in which we're
69 * interested. A @c GDBusProxy object will be
70 * create using the properties found in the
71 * dictionary item whose key matches this
73 * @param[in] manager The D-Bus object manager that contains the
74 * information about the object in question.
76 GDBusProxy * CAGetBlueZInterfaceProxy(GVariant * tuple,
77 char const * interface,
78 GDBusObjectManager * object_manager);
81 * Set @a property on BlueZ object to given @a value.
83 * Using the @c org.freedesktop.DBus.Properties.Set() method
84 * implemented by BlueZ objects, set the desired @a property on the
85 * object pointed to by @a proxy to the given @a value.
87 * @param[in] proxy D-Bus proxy to the BlueZ object.
88 * @param[in] interface Interface name of the object on which the
89 * property is being set.
90 * @param[in] property Property name.
91 * @param[in] value Property value. Ownership is transferred from
94 bool CASetBlueZObjectProperty(GDBusProxy * proxy,
95 char const * interface,
96 char const * property,
100 * D-Bus skeleton propery name/value pair.
102 * This name value pair will be used when constructing the property
103 * dictionary embedded in
104 * @c org.freedesktop.DBus.ObjectManager.GetManagedObjects() results.
106 typedef struct _CADBusSkeletonProperty
109 char const * const name;
114 * @c Ownership is transferred to the function this variant passed
117 GVariant * const value;
118 } CADBusSkeletonProperty;
121 * Construct property dictionary suitable for place in ObjectManager
124 * @param[in] interface_name The name of the interface to which the
125 * properties correspond.
126 * @param[in] properties Array of property name/value pairs.
127 * Ownership of the value variant will be
128 * transferred to this function.
129 * @param[in] count Number of elements in the @a properties
132 * @return A variant of the form a{sa{sv}}, suitable for use in the
134 * @c org.freedesktop.DBus.ObjectManager.GetManagedObjects()
135 * or @c org.freedesktop.DBus.Properties.GetAll() method
138 * @note Ownership of the returned @c GVariant is transferred to the
141 GVariant * CAMakePropertyDictionary(
142 char const * interface_name,
143 CADBusSkeletonProperty const * properties,
147 #endif // CA_BLE_LINUX_UTILS_H