Lines Matching defs:slot
25 #include "bus-slot.h"
35 sd_bus_slot *slot;
39 slot = malloc0(offsetof(sd_bus_slot, reply_callback) + extra);
40 if (!slot)
43 slot->n_ref = 1;
44 slot->type = type;
45 slot->bus = bus;
46 slot->floating = floating;
47 slot->userdata = userdata;
52 LIST_PREPEND(slots, bus->slots, slot);
54 return slot;
57 _public_ sd_bus_slot* sd_bus_slot_ref(sd_bus_slot *slot) {
59 if (!slot)
62 assert(slot->n_ref > 0);
64 slot->n_ref++;
65 return slot;
68 void bus_slot_disconnect(sd_bus_slot *slot) {
71 assert(slot);
73 if (!slot->bus)
76 switch (slot->type) {
80 if (slot->reply_callback.cookie != 0)
81 ordered_hashmap_remove(slot->bus->reply_callbacks, &slot->reply_callback.cookie);
83 if (slot->reply_callback.timeout != 0)
84 prioq_remove(slot->bus->reply_callbacks_prioq, &slot->reply_callback, &slot->reply_callback.prioq_idx);
89 slot->bus->filter_callbacks_modified = true;
90 LIST_REMOVE(callbacks, slot->bus->filter_callbacks, &slot->filter_callback);
95 if (slot->match_added)
96 bus_remove_match_internal(slot->bus, slot->match_callback.match_string, slot->match_callback.cookie);
98 slot->bus->match_callbacks_modified = true;
99 bus_match_remove(&slot->bus->match_callbacks, &slot->match_callback);
101 free(slot->match_callback.match_string);
107 if (slot->node_callback.node) {
108 LIST_REMOVE(callbacks, slot->node_callback.node->callbacks, &slot->node_callback);
109 slot->bus->nodes_modified = true;
111 bus_node_gc(slot->bus, slot->node_callback.node);
118 if (slot->node_enumerator.node) {
119 LIST_REMOVE(enumerators, slot->node_enumerator.node->enumerators, &slot->node_enumerator);
120 slot->bus->nodes_modified = true;
122 bus_node_gc(slot->bus, slot->node_enumerator.node);
129 if (slot->node_object_manager.node) {
130 LIST_REMOVE(object_managers, slot->node_object_manager.node->object_managers, &slot->node_object_manager);
131 slot->bus->nodes_modified = true;
133 bus_node_gc(slot->bus, slot->node_object_manager.node);
140 if (slot->node_vtable.node && slot->node_vtable.interface && slot->node_vtable.vtable) {
143 for (v = slot->node_vtable.vtable; v->type != _SD_BUS_VTABLE_END; v++) {
151 key.path = slot->node_vtable.node->path;
152 key.interface = slot->node_vtable.interface;
155 x = hashmap_remove(slot->bus->vtable_methods, &key);
163 key.path = slot->node_vtable.node->path;
164 key.interface = slot->node_vtable.interface;
168 x = hashmap_remove(slot->bus->vtable_properties, &key);
176 free(slot->node_vtable.interface);
178 if (slot->node_vtable.node) {
179 LIST_REMOVE(vtables, slot->node_vtable.node->vtables, &slot->node_vtable);
180 slot->bus->nodes_modified = true;
182 bus_node_gc(slot->bus, slot->node_vtable.node);
188 assert_not_reached("Wut? Unknown slot type?");
191 bus = slot->bus;
193 slot->type = _BUS_SLOT_INVALID;
194 slot->bus = NULL;
195 LIST_REMOVE(slots, bus->slots, slot);
197 if (!slot->floating)
201 _public_ sd_bus_slot* sd_bus_slot_unref(sd_bus_slot *slot) {
203 if (!slot)
206 assert(slot->n_ref > 0);
208 if (slot->n_ref > 1) {
209 slot->n_ref --;
213 bus_slot_disconnect(slot);
214 free(slot->description);
215 free(slot);
220 _public_ sd_bus* sd_bus_slot_get_bus(sd_bus_slot *slot) {
221 assert_return(slot, NULL);
223 return slot->bus;
226 _public_ void *sd_bus_slot_get_userdata(sd_bus_slot *slot) {
227 assert_return(slot, NULL);
229 return slot->userdata;
232 _public_ void *sd_bus_slot_set_userdata(sd_bus_slot *slot, void *userdata) {
235 assert_return(slot, NULL);
237 ret = slot->userdata;
238 slot->userdata = userdata;
243 _public_ sd_bus_message *sd_bus_slot_get_current_message(sd_bus_slot *slot) {
244 assert_return(slot, NULL);
245 assert_return(slot->type >= 0, NULL);
247 if (slot->bus->current_slot != slot)
250 return slot->bus->current_message;
253 _public_ sd_bus_message_handler_t sd_bus_slot_get_current_handler(sd_bus_slot *slot) {
254 assert_return(slot, NULL);
255 assert_return(slot->type >= 0, NULL);
257 if (slot->bus->current_slot != slot)
260 return slot->bus->current_handler;
263 _public_ void* sd_bus_slot_get_current_userdata(sd_bus_slot *slot) {
264 assert_return(slot, NULL);
265 assert_return(slot->type >= 0, NULL);
267 if (slot->bus->current_slot != slot)
270 return slot->bus->current_userdata;
273 _public_ int sd_bus_slot_set_description(sd_bus_slot *slot, const char *description) {
274 assert_return(slot, -EINVAL);
276 return free_and_strdup(&slot->description, description);
279 _public_ int sd_bus_slot_get_description(sd_bus_slot *slot, const char **description) {
280 assert_return(slot, -EINVAL);
282 assert_return(slot->description, -ENXIO);
284 *description = slot->description;