D-Bus: dbus-server.c Source File

D-Bus 1.12.6

dbus-server.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-server.c DBusServer object
3 *
4 * Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program 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
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23
24 #include <config.h>
25 #include "dbus-server.h"
26 #include "dbus-server-unix.h"
27 #include "dbus-server-socket.h"
28 #include "dbus-string.h"
29 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
30 #include "dbus-server-debug-pipe.h"
31 #endif
32 #include "dbus-address.h"
33 #include "dbus-protocol.h"
34
56 #ifndef _dbus_server_trace_ref
57 void
58 _dbus_server_trace_ref (DBusServer *server,
59 int old_refcount,
60 int new_refcount,
61 const char *why)
62 {
63 static int enabled = -1;
64
65 _dbus_trace_ref ("DBusServer", server, old_refcount, new_refcount, why,
66 "DBUS_SERVER_TRACE", &enabled);
67 }
68 #endif
69
70 /* this is a little fragile since it assumes the address doesn't
71 * already have a guid, but it shouldn't
72 */
73 static char*
74 copy_address_with_guid_appended (const DBusString *address,
75 const DBusString *guid_hex)
76 {
77 DBusString with_guid;
78 char *retval;
79
80 if (!_dbus_string_init (&with_guid))
81 return NULL;
82
83 if (!_dbus_string_copy (address, 0, &with_guid,
84 _dbus_string_get_length (&with_guid)) ||
85 !_dbus_string_append (&with_guid, ",guid=") ||
86 !_dbus_string_copy (guid_hex, 0,
87 &with_guid, _dbus_string_get_length (&with_guid)))
88 {
89 _dbus_string_free (&with_guid);
90 return NULL;
91 }
92
93 retval = NULL;
94 _dbus_string_steal_data (&with_guid, &retval);
95
96 _dbus_string_free (&with_guid);
97
98 return retval; /* may be NULL if steal_data failed */
99 }
100
111 dbus_bool_t
112 _dbus_server_init_base (DBusServer *server,
113 const DBusServerVTable *vtable,
114 const DBusString *address,
115 DBusError *error)
116 {
117 server->vtable = vtable;
118
119 #ifdef DBUS_DISABLE_ASSERT
120 _dbus_atomic_inc (&server->refcount);
121 #else
122 {
123 dbus_int32_t old_refcount = _dbus_atomic_inc (&server->refcount);
124
125 _dbus_assert (old_refcount == 0);
126 }
127 #endif
128
129 server->address = NULL;
130 server->watches = NULL;
131 server->timeouts = NULL;
132 server->published_address = FALSE;
133
134 if (!_dbus_string_init (&server->guid_hex))
135 {
136 _DBUS_SET_OOM (error);
137 return FALSE;
138 }
139
140 if (!_dbus_generate_uuid (&server->guid, error))
141 goto failed;
142
143 if (!_dbus_uuid_encode (&server->guid, &server->guid_hex))
144 goto oom;
145
146 server->address = copy_address_with_guid_appended (address,
147 &server->guid_hex);
148 if (server->address == NULL)
149 goto oom;
150
151 _dbus_rmutex_new_at_location (&server->mutex);
152 if (server->mutex == NULL)
153 goto oom;
154
155 server->watches = _dbus_watch_list_new ();
156 if (server->watches == NULL)
157 goto oom;
158
159 server->timeouts = _dbus_timeout_list_new ();
160 if (server->timeouts == NULL)
161 goto oom;
162
163 _dbus_data_slot_list_init (&server->slot_list);
164
165 _dbus_verbose ("Initialized server on address %s\n", server->address);
166
167 return TRUE;
168
169 oom:
170 _DBUS_SET_OOM (error);
171 failed:
172 _dbus_rmutex_free_at_location (&server->mutex);
173 server->mutex = NULL;
174 if (server->watches)
175 {
176 _dbus_watch_list_free (server->watches);
177 server->watches = NULL;
178 }
179 if (server->timeouts)
180 {
181 _dbus_timeout_list_free (server->timeouts);
182 server->timeouts = NULL;
183 }
184 if (server->address)
185 {
186 dbus_free (server->address);
187 server->address = NULL;
188 }
189 _dbus_string_free (&server->guid_hex);
190
191 return FALSE;
192 }
193
200 void
201 _dbus_server_finalize_base (DBusServer *server)
202 {
203 /* We don't have the lock, but nobody should be accessing
204 * concurrently since they don't have a ref
205 */
206 #ifndef DBUS_DISABLE_CHECKS
207 _dbus_assert (!server->have_server_lock);
208 #endif
209 _dbus_assert (server->disconnected);
210
211 /* calls out to application code... */
212 _dbus_data_slot_list_free (&server->slot_list);
213
214 dbus_server_set_new_connection_function (server, NULL, NULL, NULL);
215
216 _dbus_watch_list_free (server->watches);
217 _dbus_timeout_list_free (server->timeouts);
218
219 _dbus_rmutex_free_at_location (&server->mutex);
220
221 dbus_free (server->address);
222
223 dbus_free_string_array (server->auth_mechanisms);
224
225 _dbus_string_free (&server->guid_hex);
226 }
227
228
230 typedef dbus_bool_t (* DBusWatchAddFunction) (DBusWatchList *list,
231 DBusWatch *watch);
233 typedef void (* DBusWatchRemoveFunction) (DBusWatchList *list,
234 DBusWatch *watch);
236 typedef void (* DBusWatchToggleFunction) (DBusWatchList *list,
237 DBusWatch *watch,
238 dbus_bool_t enabled);
239
240 static dbus_bool_t
241 protected_change_watch (DBusServer *server,
242 DBusWatch *watch,
243 DBusWatchAddFunction add_function,
244 DBusWatchRemoveFunction remove_function,
245 DBusWatchToggleFunction toggle_function,
246 dbus_bool_t enabled)
247 {
248 DBusWatchList *watches;
249 dbus_bool_t retval;
250
251 HAVE_LOCK_CHECK (server);
252
253 /* This isn't really safe or reasonable; a better pattern is the "do
254 * everything, then drop lock and call out" one; but it has to be
255 * propagated up through all callers
256 */
257
258 watches = server->watches;
259 if (watches)
260 {
261 server->watches = NULL;
262 _dbus_server_ref_unlocked (server);
263 SERVER_UNLOCK (server);
264
265 if (add_function)
266 retval = (* add_function) (watches, watch);
267 else if (remove_function)
268 {
269 retval = TRUE;
270 (* remove_function) (watches, watch);
271 }
272 else
273 {
274 retval = TRUE;
275 (* toggle_function) (watches, watch, enabled);
276 }
277
278 SERVER_LOCK (server);
279 server->watches = watches;
280 _dbus_server_unref_unlocked (server);
281
282 return retval;
283 }
284 else
285 return FALSE;
286 }
287
295 dbus_bool_t
296 _dbus_server_add_watch (DBusServer *server,
297 DBusWatch *watch)
298 {
299 HAVE_LOCK_CHECK (server);
300 return protected_change_watch (server, watch,
301 _dbus_watch_list_add_watch,
302 NULL, NULL, FALSE);
303 }
304
311 void
312 _dbus_server_remove_watch (DBusServer *server,
313 DBusWatch *watch)
314 {
315 HAVE_LOCK_CHECK (server);
316 protected_change_watch (server, watch,
317 NULL,
318 _dbus_watch_list_remove_watch,
319 NULL, FALSE);
320 }
321
329 void
330 _dbus_server_toggle_all_watches (DBusServer *server,
331 dbus_bool_t enabled)
332 {
333 _dbus_watch_list_toggle_all_watches (server->watches, enabled);
334 }
335
337 typedef dbus_bool_t (* DBusTimeoutAddFunction) (DBusTimeoutList *list,
338 DBusTimeout *timeout);
340 typedef void (* DBusTimeoutRemoveFunction) (DBusTimeoutList *list,
341 DBusTimeout *timeout);
343 typedef void (* DBusTimeoutToggleFunction) (DBusTimeoutList *list,
344 DBusTimeout *timeout,
345 dbus_bool_t enabled);
346
347
348 static dbus_bool_t
349 protected_change_timeout (DBusServer *server,
350 DBusTimeout *timeout,
351 DBusTimeoutAddFunction add_function,
352 DBusTimeoutRemoveFunction remove_function,
353 DBusTimeoutToggleFunction toggle_function,
354 dbus_bool_t enabled)
355 {
356 DBusTimeoutList *timeouts;
357 dbus_bool_t retval;
358
359 HAVE_LOCK_CHECK (server);
360
361 /* This isn't really safe or reasonable; a better pattern is the "do everything, then
362 * drop lock and call out" one; but it has to be propagated up through all callers
363 */
364
365 timeouts = server->timeouts;
366 if (timeouts)
367 {
368 server->timeouts = NULL;
369 _dbus_server_ref_unlocked (server);
370 SERVER_UNLOCK (server);
371
372 if (add_function)
373 retval = (* add_function) (timeouts, timeout);
374 else if (remove_function)
375 {
376 retval = TRUE;
377 (* remove_function) (timeouts, timeout);
378 }
379 else
380 {
381 retval = TRUE;
382 (* toggle_function) (timeouts, timeout, enabled);
383 }
384
385 SERVER_LOCK (server);
386 server->timeouts = timeouts;
387 _dbus_server_unref_unlocked (server);
388
389 return retval;
390 }
391 else
392 return FALSE;
393 }
394
404 dbus_bool_t
405 _dbus_server_add_timeout (DBusServer *server,
406 DBusTimeout *timeout)
407 {
408 return protected_change_timeout (server, timeout,
409 _dbus_timeout_list_add_timeout,
410 NULL, NULL, FALSE);
411 }
412
419 void
420 _dbus_server_remove_timeout (DBusServer *server,
421 DBusTimeout *timeout)
422 {
423 protected_change_timeout (server, timeout,
424 NULL,
425 _dbus_timeout_list_remove_timeout,
426 NULL, FALSE);
427 }
428
438 void
439 _dbus_server_toggle_timeout (DBusServer *server,
440 DBusTimeout *timeout,
441 dbus_bool_t enabled)
442 {
443 protected_change_timeout (server, timeout,
444 NULL, NULL,
445 _dbus_timeout_list_toggle_timeout,
446 enabled);
447 }
448
449
455 void
456 _dbus_server_ref_unlocked (DBusServer *server)
457 {
458 dbus_int32_t old_refcount;
459
460 _dbus_assert (server != NULL);
461 HAVE_LOCK_CHECK (server);
462
463 old_refcount = _dbus_atomic_inc (&server->refcount);
464 _dbus_assert (old_refcount > 0);
465 _dbus_server_trace_ref (server, old_refcount, old_refcount + 1,
466 "ref_unlocked");
467 }
468
474 void
475 _dbus_server_unref_unlocked (DBusServer *server)
476 {
477 dbus_int32_t old_refcount;
478
479 /* Keep this in sync with dbus_server_unref */
480
481 _dbus_assert (server != NULL);
482
483 HAVE_LOCK_CHECK (server);
484
485 old_refcount = _dbus_atomic_dec (&server->refcount);
486 _dbus_assert (old_refcount > 0);
487
488 _dbus_server_trace_ref (server, old_refcount, old_refcount - 1,
489 "unref_unlocked");
490
491 if (old_refcount == 1)
492 {
493 _dbus_assert (server->disconnected);
494
495 SERVER_UNLOCK (server);
496
497 _dbus_assert (server->vtable->finalize != NULL);
498
499 (* server->vtable->finalize) (server);
500 }
501 }
502
524 static const struct {
525 DBusServerListenResult (* func) (DBusAddressEntry *entry,
526 DBusServer **server_p,
527 DBusError *error);
528 } listen_funcs[] = {
529 { _dbus_server_listen_socket }
530 , { _dbus_server_listen_platform_specific }
531 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
532 , { _dbus_server_listen_debug_pipe }
533 #endif
534 };
535
556 DBusServer*
557 dbus_server_listen (const char *address,
558 DBusError *error)
559 {
560 DBusServer *server;
561 DBusAddressEntry **entries;
562 int len, i;
563 DBusError first_connect_error = DBUS_ERROR_INIT;
564 dbus_bool_t handled_once;
565
566 _dbus_return_val_if_fail (address != NULL, NULL);
567 _dbus_return_val_if_error_is_set (error, NULL);
568
569 if (!dbus_parse_address (address, &entries, &len, error))
570 return NULL;
571
572 server = NULL;
573 handled_once = FALSE;
574
575 for (i = 0; i < len; i++)
576 {
577 int j;
578
579 for (j = 0; j < (int) _DBUS_N_ELEMENTS (listen_funcs); ++j)
580 {
581 DBusServerListenResult result;
582 DBusError tmp_error = DBUS_ERROR_INIT;
583
584 result = (* listen_funcs[j].func) (entries[i],
585 &server,
586 &tmp_error);
587
588 if (result == DBUS_SERVER_LISTEN_OK)
589 {
590 _dbus_assert (server != NULL);
591 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
592 handled_once = TRUE;
593 goto out;
594 }
595 else if (result == DBUS_SERVER_LISTEN_ADDRESS_ALREADY_USED)
596 {
597 _dbus_assert (server == NULL);
598 dbus_set_error (error,
599 DBUS_ERROR_ADDRESS_IN_USE,
600 "Address '%s' already used",
601 dbus_address_entry_get_method (entries[0]));
602 handled_once = TRUE;
603 goto out;
604 }
605 else if (result == DBUS_SERVER_LISTEN_BAD_ADDRESS)
606 {
607 _dbus_assert (server == NULL);
608 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
609 dbus_move_error (&tmp_error, error);
610 handled_once = TRUE;
611 goto out;
612 }
613 else if (result == DBUS_SERVER_LISTEN_NOT_HANDLED)
614 {
615 _dbus_assert (server == NULL);
616 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
617
618 /* keep trying addresses */
619 }
620 else if (result == DBUS_SERVER_LISTEN_DID_NOT_CONNECT)
621 {
622 _dbus_assert (server == NULL);
623 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
624 if (!dbus_error_is_set (&first_connect_error))
625 dbus_move_error (&tmp_error, &first_connect_error);
626 else
627 dbus_error_free (&tmp_error);
628
629 handled_once = TRUE;
630
631 /* keep trying addresses */
632 }
633 }
634
635 _dbus_assert (server == NULL);
636 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
637 }
638
639 out:
640
641 if (!handled_once)
642 {
643 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
644 if (len > 0)
645 dbus_set_error (error,
646 DBUS_ERROR_BAD_ADDRESS,
647 "Unknown address type '%s'",
648 dbus_address_entry_get_method (entries[0]));
649 else
650 dbus_set_error (error,
651 DBUS_ERROR_BAD_ADDRESS,
652 "Empty address '%s'",
653 address);
654 }
655
656 dbus_address_entries_free (entries);
657
658 if (server == NULL)
659 {
660 _dbus_assert (error == NULL || dbus_error_is_set (&first_connect_error) ||
661 dbus_error_is_set (error));
662
663 if (error && dbus_error_is_set (error))
664 {
665 /* already set the error */
666 }
667 else
668 {
669 /* didn't set the error but either error should be
670 * NULL or first_connect_error should be set.
671 */
672 _dbus_assert (error == NULL || dbus_error_is_set (&first_connect_error));
673 dbus_move_error (&first_connect_error, error);
674 }
675
676 _DBUS_ASSERT_ERROR_IS_CLEAR (&first_connect_error); /* be sure we freed it */
677 _DBUS_ASSERT_ERROR_IS_SET (error);
678
679 return NULL;
680 }
681 else
682 {
683 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
684 return server;
685 }
686 }
687
694 DBusServer *
695 dbus_server_ref (DBusServer *server)
696 {
697 dbus_int32_t old_refcount;
698
699 _dbus_return_val_if_fail (server != NULL, NULL);
700
701 old_refcount = _dbus_atomic_inc (&server->refcount);
702
703 #ifndef DBUS_DISABLE_CHECKS
704 if (_DBUS_UNLIKELY (old_refcount <= 0))
705 {
706 _dbus_atomic_dec (&server->refcount);
707 _dbus_warn_return_if_fail (_DBUS_FUNCTION_NAME, "old_refcount > 0",
708 __FILE__, __LINE__);
709 return NULL;
710 }
711 #endif
712
713 _dbus_server_trace_ref (server, old_refcount, old_refcount + 1, "ref");
714
715 return server;
716 }
717
726 void
727 dbus_server_unref (DBusServer *server)
728 {
729 dbus_int32_t old_refcount;
730
731 /* keep this in sync with unref_unlocked */
732
733 _dbus_return_if_fail (server != NULL);
734
735 old_refcount = _dbus_atomic_dec (&server->refcount);
736
737 #ifndef DBUS_DISABLE_CHECKS
738 if (_DBUS_UNLIKELY (old_refcount <= 0))
739 {
740 /* undo side-effect first
741 * please do not try to simplify the code here by using
742 * _dbus_atomic_get(), why we don't use it is
743 * because it issues another atomic operation even though
744 * DBUS_DISABLE_CHECKS defined.
745 * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303
746 */
747 _dbus_atomic_inc (&server->refcount);
748 _dbus_warn_return_if_fail (_DBUS_FUNCTION_NAME, "old_refcount > 0",
749 __FILE__, __LINE__);
750 return;
751 }
752 #endif
753
754 _dbus_server_trace_ref (server, old_refcount, old_refcount - 1, "unref");
755
756 if (old_refcount == 1)
757 {
758 /* lock not held! */
759 _dbus_assert (server->disconnected);
760
761 _dbus_assert (server->vtable->finalize != NULL);
762
763 (* server->vtable->finalize) (server);
764 }
765 }
766
767 void
768 _dbus_server_disconnect_unlocked (DBusServer *server)
769 {
770 _dbus_assert (server->vtable->disconnect != NULL);
771
772 if (!server->disconnected)
773 {
774 /* this has to be first so recursive calls to disconnect don't happen */
775 server->disconnected = TRUE;
776
777 (* server->vtable->disconnect) (server);
778 }
779 }
780
789 void
790 dbus_server_disconnect (DBusServer *server)
791 {
792 _dbus_return_if_fail (server != NULL);
793
794 dbus_server_ref (server);
795 SERVER_LOCK (server);
796
797 _dbus_server_disconnect_unlocked (server);
798
799 SERVER_UNLOCK (server);
800 dbus_server_unref (server);
801 }
802
808 dbus_bool_t
809 dbus_server_get_is_connected (DBusServer *server)
810 {
811 dbus_bool_t retval;
812
813 _dbus_return_val_if_fail (server != NULL, FALSE);
814
815 SERVER_LOCK (server);
816 retval = !server->disconnected;
817 SERVER_UNLOCK (server);
818
819 return retval;
820 }
821
829 char*
830 dbus_server_get_address (DBusServer *server)
831 {
832 char *retval;
833
834 _dbus_return_val_if_fail (server != NULL, NULL);
835
836 SERVER_LOCK (server);
837 retval = _dbus_strdup (server->address);
838 SERVER_UNLOCK (server);
839
840 return retval;
841 }
842
865 char*
866 dbus_server_get_id (DBusServer *server)
867 {
868 char *retval;
869
870 _dbus_return_val_if_fail (server != NULL, NULL);
871
872 SERVER_LOCK (server);
873 retval = NULL;
874 _dbus_string_copy_data (&server->guid_hex, &retval);
875 SERVER_UNLOCK (server);
876
877 return retval;
878 }
879
900 void
901 dbus_server_set_new_connection_function (DBusServer *server,
902 DBusNewConnectionFunction function,
903 void *data,
904 DBusFreeFunction free_data_function)
905 {
906 DBusFreeFunction old_free_function;
907 void *old_data;
908
909 _dbus_return_if_fail (server != NULL);
910
911 SERVER_LOCK (server);
912 old_free_function = server->new_connection_free_data_function;
913 old_data = server->new_connection_data;
914
915 server->new_connection_function = function;
916 server->new_connection_data = data;
917 server->new_connection_free_data_function = free_data_function;
918 SERVER_UNLOCK (server);
919
920 if (old_free_function != NULL)
921 (* old_free_function) (old_data);
922 }
923
940 dbus_bool_t
941 dbus_server_set_watch_functions (DBusServer *server,
942 DBusAddWatchFunction add_function,
943 DBusRemoveWatchFunction remove_function,
944 DBusWatchToggledFunction toggled_function,
945 void *data,
946 DBusFreeFunction free_data_function)
947 {
948 dbus_bool_t result;
949 DBusWatchList *watches;
950
951 _dbus_return_val_if_fail (server != NULL, FALSE);
952
953 SERVER_LOCK (server);
954 watches = server->watches;
955 server->watches = NULL;
956 if (watches)
957 {
958 SERVER_UNLOCK (server);
959 result = _dbus_watch_list_set_functions (watches,
960 add_function,
961 remove_function,
962 toggled_function,
963 data,
964 free_data_function);
965 SERVER_LOCK (server);
966 }
967 else
968 {
969 _dbus_warn_check_failed ("Re-entrant call to %s", _DBUS_FUNCTION_NAME);
970 result = FALSE;
971 }
972 server->watches = watches;
973 SERVER_UNLOCK (server);
974
975 return result;
976 }
977
993 dbus_bool_t
994 dbus_server_set_timeout_functions (DBusServer *server,
995 DBusAddTimeoutFunction add_function,
996 DBusRemoveTimeoutFunction remove_function,
997 DBusTimeoutToggledFunction toggled_function,
998 void *data,
999 DBusFreeFunction free_data_function)
1000 {
1001 dbus_bool_t result;
1002 DBusTimeoutList *timeouts;
1003
1004 _dbus_return_val_if_fail (server != NULL, FALSE);
1005
1006 SERVER_LOCK (server);
1007 timeouts = server->timeouts;
1008 server->timeouts = NULL;
1009 if (timeouts)
1010 {
1011 SERVER_UNLOCK (server);
1012 result = _dbus_timeout_list_set_functions (timeouts,
1013 add_function,
1014 remove_function,
1015 toggled_function,
1016 data,
1017 free_data_function);
1018 SERVER_LOCK (server);
1019 }
1020 else
1021 {
1022 _dbus_warn_check_failed ("Re-entrant call to %s", _DBUS_FUNCTION_NAME);
1023 result = FALSE;
1024 }
1025 server->timeouts = timeouts;
1026 SERVER_UNLOCK (server);
1027
1028 return result;
1029 }
1030
1044 dbus_bool_t
1045 dbus_server_set_auth_mechanisms (DBusServer *server,
1046 const char **mechanisms)
1047 {
1048 char **copy;
1049
1050 _dbus_return_val_if_fail (server != NULL, FALSE);
1051
1052 SERVER_LOCK (server);
1053
1054 if (mechanisms != NULL)
1055 {
1056 copy = _dbus_dup_string_array (mechanisms);
1057 if (copy == NULL)
1058 {
1059 SERVER_UNLOCK (server);
1060 return FALSE;
1061 }
1062 }
1063 else
1064 copy = NULL;
1065
1066 dbus_free_string_array (server->auth_mechanisms);
1067 server->auth_mechanisms = copy;
1068
1069 SERVER_UNLOCK (server);
1070
1071 return TRUE;
1072 }
1073
1074 static DBusDataSlotAllocator slot_allocator =
1075 _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (server_slots));
1076
1091 dbus_bool_t
1092 dbus_server_allocate_data_slot (dbus_int32_t *slot_p)
1093 {
1094 return _dbus_data_slot_allocator_alloc (&slot_allocator,
1095 slot_p);
1096 }
1097
1109 void
1110 dbus_server_free_data_slot (dbus_int32_t *slot_p)
1111 {
1112 _dbus_return_if_fail (*slot_p >= 0);
1113
1114 _dbus_data_slot_allocator_free (&slot_allocator, slot_p);
1115 }
1116
1130 dbus_bool_t
1131 dbus_server_set_data (DBusServer *server,
1132 int slot,
1133 void *data,
1134 DBusFreeFunction free_data_func)
1135 {
1136 DBusFreeFunction old_free_func;
1137 void *old_data;
1138 dbus_bool_t retval;
1139
1140 _dbus_return_val_if_fail (server != NULL, FALSE);
1141
1142 SERVER_LOCK (server);
1143
1144 retval = _dbus_data_slot_list_set (&slot_allocator,
1145 &server->slot_list,
1146 slot, data, free_data_func,
1147 &old_free_func, &old_data);
1148
1149
1150 SERVER_UNLOCK (server);
1151
1152 if (retval)
1153 {
1154 /* Do the actual free outside the server lock */
1155 if (old_free_func)
1156 (* old_free_func) (old_data);
1157 }
1158
1159 return retval;
1160 }
1161
1170 void*
1171 dbus_server_get_data (DBusServer *server,
1172 int slot)
1173 {
1174 void *res;
1175
1176 _dbus_return_val_if_fail (server != NULL, NULL);
1177
1178 SERVER_LOCK (server);
1179
1180 res = _dbus_data_slot_list_get (&slot_allocator,
1181 &server->slot_list,
1182 slot);
1183
1184 SERVER_UNLOCK (server);
1185
1186 return res;
1187 }
1188
1191 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
1192 #include "dbus-test.h"
1193 #include <string.h>
1194
1195 dbus_bool_t
1196 _dbus_server_test (void)
1197 {
1198 const char *valid_addresses[] = {
1199 "tcp:port=1234",
1200 "tcp:host=localhost,port=1234",
1201 "tcp:host=localhost,port=1234;tcp:port=5678",
1202 #ifdef DBUS_UNIX
1203 "unix:path=./boogie",
1204 "tcp:port=1234;unix:path=./boogie",
1205 #endif
1206 };
1207
1208 DBusServer *server;
1209 int i;
1210
1211 for (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++)
1212 {
1213 DBusError error = DBUS_ERROR_INIT;
1214 char *address;
1215 char *id;
1216
1217 server = dbus_server_listen (valid_addresses[i], &error);
1218 if (server == NULL)
1219 {
1220 _dbus_warn ("server listen error: %s: %s", error.name, error.message);
1221 dbus_error_free (&error);
1222 _dbus_assert_not_reached ("Failed to listen for valid address.");
1223 }
1224
1225 id = dbus_server_get_id (server);
1226 _dbus_assert (id != NULL);
1227 address = dbus_server_get_address (server);
1228 _dbus_assert (address != NULL);
1229
1230 if (strstr (address, id) == NULL)
1231 {
1232 _dbus_warn ("server id '%s' is not in the server address '%s'",
1233 id, address);
1234 _dbus_assert_not_reached ("bad server id or address");
1235 }
1236
1237 dbus_free (id);
1238 dbus_free (address);
1239
1240 dbus_server_disconnect (server);
1241 dbus_server_unref (server);
1242 }
1243
1244 return TRUE;
1245 }
1246
1247 #endif /* DBUS_ENABLE_EMBEDDED_TESTS */
_dbus_string_append
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
Definition: dbus-string.c:935
DBusTimeout
Internals of DBusTimeout.
Definition: dbus-timeout.c:40
dbus_server_free_data_slot
void dbus_server_free_data_slot(dbus_int32_t *slot_p)
Deallocates a global ID for server data slots.
Definition: dbus-server.c:1110
_dbus_uuid_encode
dbus_bool_t _dbus_uuid_encode(const DBusGUID *uuid, DBusString *encoded)
Hex-encode a UUID.
Definition: dbus-internals.c:703
_dbus_server_add_watch
dbus_bool_t _dbus_server_add_watch(DBusServer *server, DBusWatch *watch)
Adds a watch for this server, chaining out to application-provided watch handlers.
Definition: dbus-server.c:296
DBusError::message
const char * message
public error message field
Definition: dbus-errors.h:51
DBusWatch
Implementation of DBusWatch.
Definition: dbus-watch.c:40
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition: dbus-memory.h:64
_dbus_timeout_list_set_functions
dbus_bool_t _dbus_timeout_list_set_functions(DBusTimeoutList *timeout_list, DBusAddTimeoutFunction add_function, DBusRemoveTimeoutFunction remove_function, DBusTimeoutToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the timeout functions.
Definition: dbus-timeout.c:243
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:702
DBusServerVTable::disconnect
void(* disconnect)(DBusServer *server)
Disconnect this server.
Definition: dbus-server-protected.h:48
DBusServer::disconnected
unsigned int disconnected
TRUE if we are disconnected.
Definition: dbus-server-protected.h:87
DBusWatchToggledFunction
void(* DBusWatchToggledFunction)(DBusWatch *watch, void *data)
Called when dbus_watch_get_enabled() may return a different value than it did before.
Definition: dbus-connection.h:98
dbus_server_set_data
dbus_bool_t dbus_server_set_data(DBusServer *server, int slot, void *data, DBusFreeFunction free_data_func)
Stores a pointer on a DBusServer, along with an optional function to be used for freeing the data whe...
Definition: dbus-server.c:1131
_dbus_timeout_list_free
void _dbus_timeout_list_free(DBusTimeoutList *timeout_list)
Frees a DBusTimeoutList.
Definition: dbus-timeout.c:215
_dbus_generate_uuid
dbus_bool_t _dbus_generate_uuid(DBusGUID *uuid, DBusError *error)
Generates a new UUID.
Definition: dbus-internals.c:667
DBusServer
Internals of DBusServer object.
Definition: dbus-server-protected.h:56
_dbus_timeout_list_new
DBusTimeoutList * _dbus_timeout_list_new(void)
Creates a new timeout list.
Definition: dbus-timeout.c:198
_dbus_assert
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Definition: dbus-internals.h:152
DBUS_ERROR_INIT
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack.
Definition: dbus-errors.h:62
dbus_address_entry_get_method
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry.
Definition: dbus-address.c:227
_dbus_warn_check_failed
void _dbus_warn_check_failed(const char *format,...)
Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...
Definition: dbus-internals.c:262
dbus_error_free
void dbus_error_free(DBusError *error)
Frees an error that&#39;s been set (or just initialized), then reinitializes the error as in dbus_error_i...
Definition: dbus-errors.c:211
_dbus_watch_list_free
void _dbus_watch_list_free(DBusWatchList *watch_list)
Frees a DBusWatchList.
Definition: dbus-watch.c:249
dbus_address_entries_free
void dbus_address_entries_free(DBusAddressEntry **entries)
Frees a NULL-terminated array of address entries.
Definition: dbus-address.c:189
_dbus_rmutex_new_at_location
void _dbus_rmutex_new_at_location(DBusRMutex **location_p)
Creates a new mutex or creates a no-op mutex if threads are not initialized.
Definition: dbus-threads.c:53
DBusTimeoutToggleFunction
void(* DBusTimeoutToggleFunction)(DBusTimeoutList *list, DBusTimeout *timeout, dbus_bool_t enabled)
Function to be called in protected_change_timeout() with refcount held.
Definition: dbus-server.c:343
_dbus_watch_list_new
DBusWatchList * _dbus_watch_list_new(void)
Creates a new watch list.
Definition: dbus-watch.c:232
_dbus_string_init
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition: dbus-string.c:175
_dbus_server_ref_unlocked
void _dbus_server_ref_unlocked(DBusServer *server)
Like dbus_server_ref() but does not acquire the lock (must already be held)
Definition: dbus-server.c:456
_dbus_string_copy
dbus_bool_t _dbus_string_copy(const DBusString *source, int start, DBusString *dest, int insert_at)
Like _dbus_string_move(), but does not delete the section of the source string that&#39;s copied to the d...
Definition: dbus-string.c:1283
DBusNewConnectionFunction
void(* DBusNewConnectionFunction)(DBusServer *server, DBusConnection *new_connection, void *data)
Called when a new connection to the server is available.
Definition: dbus-server.h:48
_dbus_server_listen_platform_specific
DBusServerListenResult _dbus_server_listen_platform_specific(DBusAddressEntry *entry, DBusServer **server_p, DBusError *error)
Tries to interpret the address entry in a platform-specific way, creating a platform-specific server ...
Definition: dbus-server-unix.c:54
DBusServer::new_connection_function
DBusNewConnectionFunction new_connection_function
Callback to invoke when a new connection is created.
Definition: dbus-server-protected.h:76
DBusServer::auth_mechanisms
char ** auth_mechanisms
Array of allowed authentication mechanisms.
Definition: dbus-server-protected.h:85
DBusRemoveTimeoutFunction
void(* DBusRemoveTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus no longer needs a timeout to be monitored by the main loop.
Definition: dbus-connection.h:124
_dbus_watch_list_set_functions
dbus_bool_t _dbus_watch_list_set_functions(DBusWatchList *watch_list, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the watch functions.
Definition: dbus-watch.c:296
DBusServer::vtable
const DBusServerVTable * vtable
Virtual methods for this instance.
Definition: dbus-server-protected.h:59
DBusWatchToggleFunction
void(* DBusWatchToggleFunction)(DBusWatchList *list, DBusWatch *watch, dbus_bool_t enabled)
Function to be called in protected_change_watch() with refcount held.
Definition: dbus-server.c:236
DBusServerVTable::finalize
void(* finalize)(DBusServer *server)
The finalize method must free the server.
Definition: dbus-server-protected.h:45
DBusServer::mutex
DBusRMutex * mutex
Lock on the server object.
Definition: dbus-server-protected.h:60
dbus_server_listen
DBusServer * dbus_server_listen(const char *address, DBusError *error)
Listens for new connections on the given address.
Definition: dbus-server.c:557
_dbus_timeout_list_add_timeout
dbus_bool_t _dbus_timeout_list_add_timeout(DBusTimeoutList *timeout_list, DBusTimeout *timeout)
Adds a new timeout to the timeout list, invoking the application DBusAddTimeoutFunction if appropriat...
Definition: dbus-timeout.c:314
_dbus_server_toggle_timeout
void _dbus_server_toggle_timeout(DBusServer *server, DBusTimeout *timeout, dbus_bool_t enabled)
Toggles a timeout and notifies app via server&#39;s DBusTimeoutToggledFunction if available.
Definition: dbus-server.c:439
_dbus_string_copy_data
dbus_bool_t _dbus_string_copy_data(const DBusString *str, char **data_return)
Copies the data from the string into a char*.
Definition: dbus-string.c:672
DBusString
Definition: dbus-string.h:42
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
_dbus_server_unref_unlocked
void _dbus_server_unref_unlocked(DBusServer *server)
Like dbus_server_unref() but does not acquire the lock (must already be held)
Definition: dbus-server.c:475
DBusServer::refcount
DBusAtomic refcount
Reference count.
Definition: dbus-server-protected.h:58
DBusAddTimeoutFunction
dbus_bool_t(* DBusAddTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus needs a new timeout to be monitored by the main loop.
Definition: dbus-connection.h:111
_dbus_warn
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
Definition: dbus-internals.c:230
DBusTimeoutAddFunction
dbus_bool_t(* DBusTimeoutAddFunction)(DBusTimeoutList *list, DBusTimeout *timeout)
Function to be called in protected_change_timeout() with refcount held.
Definition: dbus-server.c:337
DBusServer::timeouts
DBusTimeoutList * timeouts
Our timeouts.
Definition: dbus-server-protected.h:67
_dbus_atomic_inc
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
Definition: dbus-sysdeps-unix.c:2754
dbus_server_ref
DBusServer * dbus_server_ref(DBusServer *server)
Increments the reference count of a DBusServer.
Definition: dbus-server.c:695
_dbus_data_slot_list_set
dbus_bool_t _dbus_data_slot_list_set(DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot, void *data, DBusFreeFunction free_data_func, DBusFreeFunction *old_free_func, void **old_data)
Stores a pointer in the data slot list, along with an optional function to be used for freeing the da...
Definition: dbus-dataslot.c:221
DBusAddressEntry
Internals of DBusAddressEntry.
Definition: dbus-address.c:43
_dbus_watch_list_toggle_all_watches
void _dbus_watch_list_toggle_all_watches(DBusWatchList *watch_list, dbus_bool_t enabled)
Sets all watches to the given enabled state, invoking the application&#39;s DBusWatchToggledFunction if a...
Definition: dbus-watch.c:473
_dbus_server_remove_watch
void _dbus_server_remove_watch(DBusServer *server, DBusWatch *watch)
Removes a watch previously added with _dbus_server_remove_watch().
Definition: dbus-server.c:312
dbus_server_allocate_data_slot
dbus_bool_t dbus_server_allocate_data_slot(dbus_int32_t *slot_p)
Allocates an integer ID to be used for storing application-specific data on any DBusServer.
Definition: dbus-server.c:1092
DBusError
Object representing an exception.
Definition: dbus-errors.h:48
dbus_server_set_new_connection_function
void dbus_server_set_new_connection_function(DBusServer *server, DBusNewConnectionFunction function, void *data, DBusFreeFunction free_data_function)
Sets a function to be used for handling new connections.
Definition: dbus-server.c:901
DBUS_ERROR_BAD_ADDRESS
#define DBUS_ERROR_BAD_ADDRESS
A D-Bus bus address was malformed.
Definition: dbus-protocol.h:367
dbus_set_error
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
Definition: dbus-errors.c:354
dbus_server_get_data
void * dbus_server_get_data(DBusServer *server, int slot)
Retrieves data previously set with dbus_server_set_data().
Definition: dbus-server.c:1171
dbus_server_disconnect
void dbus_server_disconnect(DBusServer *server)
Releases the server&#39;s address and stops listening for new clients.
Definition: dbus-server.c:790
_dbus_server_remove_timeout
void _dbus_server_remove_timeout(DBusServer *server, DBusTimeout *timeout)
Removes a timeout previously added with _dbus_server_add_timeout().
Definition: dbus-server.c:420
_dbus_server_finalize_base
void _dbus_server_finalize_base(DBusServer *server)
Finalizes the members of the DBusServer base class.
Definition: dbus-server.c:201
_DBUS_N_ELEMENTS
#define _DBUS_N_ELEMENTS(array)
Computes the number of elements in a fixed-size array using sizeof().
Definition: dbus-internals.h:188
DBusServerVTable
Virtual table to be implemented by all server "subclasses".
Definition: dbus-server-protected.h:43
DBusServer::watches
DBusWatchList * watches
Our watches.
Definition: dbus-server-protected.h:66
dbus_server_unref
void dbus_server_unref(DBusServer *server)
Decrements the reference count of a DBusServer.
Definition: dbus-server.c:727
_dbus_timeout_list_toggle_timeout
void _dbus_timeout_list_toggle_timeout(DBusTimeoutList *timeout_list, DBusTimeout *timeout, dbus_bool_t enabled)
Sets a timeout to the given enabled state, invoking the application&#39;s DBusTimeoutToggledFunction if a...
Definition: dbus-timeout.c:366
DBUS_ERROR_ADDRESS_IN_USE
#define DBUS_ERROR_ADDRESS_IN_USE
Can&#39;t bind a socket since its address is in use (i.e.
Definition: dbus-protocol.h:387
_dbus_string_free
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
Definition: dbus-string.c:259
_dbus_dup_string_array
char ** _dbus_dup_string_array(const char **array)
Duplicates a string array.
Definition: dbus-internals.c:587
DBusServer::slot_list
DBusDataSlotList slot_list
Data stored by allocated integer ID.
Definition: dbus-server-protected.h:74
_dbus_data_slot_list_get
void * _dbus_data_slot_list_get(DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot)
Retrieves data previously set with _dbus_data_slot_list_set_data().
Definition: dbus-dataslot.c:285
DBusTimeoutToggledFunction
void(* DBusTimeoutToggledFunction)(DBusTimeout *timeout, void *data)
Called when dbus_timeout_get_enabled() may return a different value than it did before.
Definition: dbus-connection.h:118
TRUE
#define TRUE
Expands to "1".
_dbus_data_slot_list_init
void _dbus_data_slot_list_init(DBusDataSlotList *list)
Initializes a slot list.
Definition: dbus-dataslot.c:197
_dbus_assert_not_reached
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
Definition: dbus-internals.h:163
DBusServer::address
char * address
Address this server is listening on.
Definition: dbus-server-protected.h:69
_dbus_watch_list_add_watch
dbus_bool_t _dbus_watch_list_add_watch(DBusWatchList *watch_list, DBusWatch *watch)
Adds a new watch to the watch list, invoking the application DBusAddWatchFunction if appropriate...
Definition: dbus-watch.c:382
DBusServer::published_address
dbus_bool_t published_address
flag which indicates that server has published its bus address.
Definition: dbus-server-protected.h:70
dbus_move_error
void dbus_move_error(DBusError *src, DBusError *dest)
Moves an error src into dest, freeing src and overwriting dest.
Definition: dbus-errors.c:279
DBusError::name
const char * name
public error name field
Definition: dbus-errors.h:50
DBusAddWatchFunction
dbus_bool_t(* DBusAddWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus needs a new watch to be monitored by the main loop.
Definition: dbus-connection.h:92
DBusRemoveWatchFunction
void(* DBusRemoveWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus no longer needs a watch to be monitored by the main loop.
Definition: dbus-connection.h:104
DBusServer::new_connection_free_data_function
DBusFreeFunction new_connection_free_data_function
Callback to invoke to free new_connection_data when server is finalized or data is replaced...
Definition: dbus-server-protected.h:80
DBusWatchList
DBusWatchList implementation details.
Definition: dbus-watch.c:214
DBusServer::new_connection_data
void * new_connection_data
Data for new connection callback.
Definition: dbus-server-protected.h:78
DBusDataSlotAllocator
An allocator that tracks a set of slot IDs.
Definition: dbus-dataslot.h:55
dbus_server_set_auth_mechanisms
dbus_bool_t dbus_server_set_auth_mechanisms(DBusServer *server, const char **mechanisms)
Sets the authentication mechanisms that this server offers to clients, as a NULL-terminated array of ...
Definition: dbus-server.c:1045
dbus_server_get_is_connected
dbus_bool_t dbus_server_get_is_connected(DBusServer *server)
Returns TRUE if the server is still listening for new connections.
Definition: dbus-server.c:809
_dbus_server_listen_socket
DBusServerListenResult _dbus_server_listen_socket(DBusAddressEntry *entry, DBusServer **server_p, DBusError *error)
Tries to interpret the address entry for various socket-related addresses (well, currently only tcp a...
Definition: dbus-server-socket.c:554
_dbus_watch_list_remove_watch
void _dbus_watch_list_remove_watch(DBusWatchList *watch_list, DBusWatch *watch)
Removes a watch from the watch list, invoking the application&#39;s DBusRemoveWatchFunction if appropriat...
Definition: dbus-watch.c:415
_dbus_timeout_list_remove_timeout
void _dbus_timeout_list_remove_timeout(DBusTimeoutList *timeout_list, DBusTimeout *timeout)
Removes a timeout from the timeout list, invoking the application&#39;s DBusRemoveTimeoutFunction if appr...
Definition: dbus-timeout.c:344
DBusTimeoutRemoveFunction
void(* DBusTimeoutRemoveFunction)(DBusTimeoutList *list, DBusTimeout *timeout)
Function to be called in protected_change_timeout() with refcount held.
Definition: dbus-server.c:340
_dbus_atomic_dec
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
Definition: dbus-sysdeps-unix.c:2777
_dbus_server_init_base
dbus_bool_t _dbus_server_init_base(DBusServer *server, const DBusServerVTable *vtable, const DBusString *address, DBusError *error)
Initializes the members of the DBusServer base class.
Definition: dbus-server.c:112
dbus_free_string_array
void dbus_free_string_array(char **str_array)
Frees a NULL-terminated array of strings.
Definition: dbus-memory.c:750
_dbus_rmutex_free_at_location
void _dbus_rmutex_free_at_location(DBusRMutex **location_p)
Frees a DBusRMutex; does nothing if passed a NULL pointer.
Definition: dbus-threads.c:94
DBusServer::have_server_lock
unsigned int have_server_lock
Does someone have the server mutex locked.
Definition: dbus-server-protected.h:90
DBusServer::guid_hex
DBusString guid_hex
Hex-encoded version of GUID.
Definition: dbus-server-protected.h:64
DBusWatchAddFunction
dbus_bool_t(* DBusWatchAddFunction)(DBusWatchList *list, DBusWatch *watch)
Function to be called in protected_change_watch() with refcount held.
Definition: dbus-server.c:230
FALSE
#define FALSE
Expands to "0".
_dbus_server_toggle_all_watches
void _dbus_server_toggle_all_watches(DBusServer *server, dbus_bool_t enabled)
Toggles all watch and notifies app via server&#39;s DBusWatchToggledFunction if available.
Definition: dbus-server.c:330
DBusWatchRemoveFunction
void(* DBusWatchRemoveFunction)(DBusWatchList *list, DBusWatch *watch)
Function to be called in protected_change_watch() with refcount held.
Definition: dbus-server.c:233
_DBUS_LOCK_NAME
#define _DBUS_LOCK_NAME(name)
Expands to name of a global lock variable.
Definition: dbus-internals.h:371
dbus_server_get_address
char * dbus_server_get_address(DBusServer *server)
Returns the address of the server, as a newly-allocated string which must be freed by the caller...
Definition: dbus-server.c:830
_dbus_string_steal_data
dbus_bool_t _dbus_string_steal_data(DBusString *str, char **data_return)
Like _dbus_string_get_data(), but removes the gotten data from the original string.
Definition: dbus-string.c:641
dbus_server_set_watch_functions
dbus_bool_t dbus_server_set_watch_functions(DBusServer *server, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the watch functions for the server.
Definition: dbus-server.c:941
dbus_server_set_timeout_functions
dbus_bool_t dbus_server_set_timeout_functions(DBusServer *server, DBusAddTimeoutFunction add_function, DBusRemoveTimeoutFunction remove_function, DBusTimeoutToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the timeout functions for the server.
Definition: dbus-server.c:994
_dbus_server_add_timeout
dbus_bool_t _dbus_server_add_timeout(DBusServer *server, DBusTimeout *timeout)
Adds a timeout for this server, chaining out to application-provided timeout handlers.
Definition: dbus-server.c:405
_dbus_data_slot_allocator_alloc
dbus_bool_t _dbus_data_slot_allocator_alloc(DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
Allocates an integer ID to be used for storing data in a DBusDataSlotList.
Definition: dbus-dataslot.c:69
dbus_int32_t
int dbus_int32_t
A 32-bit signed integer on all platforms.
Definition: dbus-arch-deps.h:42
_dbus_strdup
char * _dbus_strdup(const char *str)
Duplicates a string.
Definition: dbus-internals.c:536
DBusServer::guid
DBusGUID guid
Globally unique ID of server.
Definition: dbus-server-protected.h:62
_dbus_data_slot_allocator_free
void _dbus_data_slot_allocator_free(DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
Deallocates an ID previously allocated with _dbus_data_slot_allocator_alloc().
Definition: dbus-dataslot.c:154
dbus_error_is_set
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
Definition: dbus-errors.c:329
DBusTimeoutList
DBusTimeoutList implementation details.
Definition: dbus-timeout.c:180
dbus_parse_address
dbus_bool_t dbus_parse_address(const char *address, DBusAddressEntry ***entry_result, int *array_len, DBusError *error)
Parses an address string of the form:
Definition: dbus-address.c:363
dbus_server_get_id
char * dbus_server_get_id(DBusServer *server)
Returns the unique ID of the server, as a newly-allocated string which must be freed by the caller...
Definition: dbus-server.c:866
_dbus_data_slot_list_free
void _dbus_data_slot_list_free(DBusDataSlotList *list)
Frees the data slot list and all data slots contained in it, calling application-provided free functi...
Definition: dbus-dataslot.c:340