dbus-proxy.h (5545B)
1 /* 2 * 3 * Wireless daemon for Linux 4 * 5 * Copyright (C) 2017-2019 Intel Corporation. All rights reserved. 6 * Copyright (C) 2023, Locus Robotics 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 */ 23 24 #include <stdio.h> 25 26 struct proxy_interface; 27 28 #define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter" 29 #define IWD_ACCESS_POINT_INTERFACE "net.connman.iwd.AccessPoint" 30 #define IWD_AD_HOC_INTERFACE "net.connman.iwd.AdHoc" 31 #define IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager" 32 #define IWD_DEVICE_INTERFACE "net.connman.iwd.Device" 33 #define IWD_KNOWN_NETWORK_INTREFACE "net.connman.iwd.KnownNetwork" 34 #define IWD_NETWORK_INTERFACE "net.connman.iwd.Network" 35 #define IWD_WSC_INTERFACE "net.connman.iwd.SimpleConfiguration" 36 #define IWD_STATION_INTERFACE "net.connman.iwd.Station" 37 #define IWD_STATION_DIAGNOSTIC_INTERFACE "net.connman.iwd.StationDiagnostic" 38 #define IWD_STATION_DEBUG_INTERFACE "net.connman.iwd.StationDebug" 39 #define IWD_AP_DIAGNOSTIC_INTERFACE "net.connman.iwd.AccessPointDiagnostic" 40 #define IWD_DAEMON_INTERFACE "net.connman.iwd.Daemon" 41 #define IWD_DPP_INTERFACE "net.connman.iwd.DeviceProvisioning" 42 #define IWD_DPP_PKEX_INTERFACE \ 43 "net.connman.iwd.SharedCodeDeviceProvisioning" 44 #define IWD_BSS_INTERFACE "net.connman.iwd.BasicServiceSet" 45 46 typedef bool (*proxy_property_match_func_t) (const void *a, const void *b); 47 48 struct proxy_interface_property { 49 const char *name; 50 const char *type; 51 void (*update)(void *data, struct l_dbus_message_iter *variant); 52 const char *(*tostr)(const void *data); 53 const bool is_read_write; 54 bool (*append)(struct l_dbus_message_builder *builder, 55 const char *value_str); 56 const char **options; 57 }; 58 59 struct proxy_interface_type_ops { 60 void *(*create)(void); 61 void (*destroy)(void *data); 62 const char *(*identity)(void *data); 63 void (*display)(const char *margin, const void *data); 64 }; 65 66 struct proxy_interface_type { 67 const char *interface; 68 const struct proxy_interface_property *properties; 69 const struct proxy_interface_type_ops *ops; 70 }; 71 72 char *proxy_property_completion( 73 const struct proxy_interface_property *properties, 74 const char *text, int state); 75 76 bool proxy_property_set(const struct proxy_interface *proxy, const char *name, 77 const char *value_str, l_dbus_message_func_t callback); 78 79 struct proxy_interface *proxy_interface_find(const char *interface, 80 const char *path); 81 82 struct l_queue *proxy_interface_find_all(const char *interface, 83 proxy_property_match_func_t function, 84 const void *value); 85 86 bool proxy_interface_is_same(const struct proxy_interface *a, 87 const struct proxy_interface *b); 88 89 bool dbus_message_has_error(struct l_dbus_message *message); 90 91 bool proxy_interface_method_call(const struct proxy_interface *proxy, 92 const char *name, const char *signature, 93 l_dbus_message_func_t callback, ...); 94 95 void proxy_properties_display(const struct proxy_interface *proxy, 96 const char *caption, const char *margin, 97 unsigned int name_column_width, 98 unsigned int value_column_width); 99 void proxy_properties_display_inline(const struct proxy_interface *proxy, 100 const char *margin, 101 unsigned int name_column_width, 102 unsigned int value_column_width); 103 void proxy_properties_display_header(const char *caption, const char *margin, 104 unsigned int name_column_width, 105 unsigned int value_column_width); 106 107 char *proxy_property_str_completion(const struct proxy_interface_type *type, 108 proxy_property_match_func_t function, 109 const char *property_name, 110 const void *value, int state, 111 const char *extra_interface); 112 113 void *proxy_interface_get_data(const struct proxy_interface *proxy); 114 const char *proxy_interface_get_interface(const struct proxy_interface *proxy); 115 const char *proxy_interface_get_path(const struct proxy_interface *proxy); 116 const char *proxy_interface_get_identity_str( 117 const struct proxy_interface *proxy); 118 119 void proxy_interface_display_list(const char *interface); 120 121 void proxy_interface_type_register( 122 const struct proxy_interface_type *interface_type); 123 void proxy_interface_type_unregister( 124 const struct proxy_interface_type *interface_type); 125 126 struct l_dbus *dbus_get_bus(void); 127 128 struct interface_type_desc { 129 const char *interface; 130 int (*init)(void); 131 void (*exit)(void); 132 } __attribute__((aligned(8))); 133 134 #define INTERFACE_TYPE(interface, init, exit) \ 135 _Pragma("GCC diagnostic push") \ 136 _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ 137 static struct interface_type_desc __interface_type_ ## interface\ 138 __attribute__((used, retain, section("__interface"), \ 139 aligned(8))) = { \ 140 #interface, init, exit \ 141 }; \ 142 _Pragma("GCC diagnostic pop") 143 144 bool dbus_proxy_init(void); 145 bool dbus_proxy_exit(void);