dbus-server.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
  2. /* dbus-server.h DBusServer object
  3. *
  4. * Copyright (C) 2002, 2003 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. #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
  24. #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
  25. #endif
  26. #ifndef DBUS_SERVER_H
  27. #define DBUS_SERVER_H
  28. #include <dbus/dbus-errors.h>
  29. #include <dbus/dbus-macros.h>
  30. #include <dbus/dbus-message.h>
  31. #include <dbus/dbus-connection.h>
  32. #include <dbus/dbus-protocol.h>
  33. DBUS_BEGIN_DECLS
  34. /**
  35. * @addtogroup DBusServer
  36. * @{
  37. */
  38. typedef struct DBusServer DBusServer;
  39. /** Called when a new connection to the server is available. Must reference and save the new
  40. * connection, or close the new connection. Set with dbus_server_set_new_connection_function().
  41. */
  42. typedef void (* DBusNewConnectionFunction) (DBusServer *server,
  43. DBusConnection *new_connection,
  44. void *data);
  45. DBUS_EXPORT
  46. DBusServer* dbus_server_listen (const char *address,
  47. DBusError *error);
  48. DBUS_EXPORT
  49. DBusServer* dbus_server_ref (DBusServer *server);
  50. DBUS_EXPORT
  51. void dbus_server_unref (DBusServer *server);
  52. DBUS_EXPORT
  53. void dbus_server_disconnect (DBusServer *server);
  54. DBUS_EXPORT
  55. dbus_bool_t dbus_server_get_is_connected (DBusServer *server);
  56. DBUS_EXPORT
  57. char* dbus_server_get_address (DBusServer *server);
  58. DBUS_EXPORT
  59. char* dbus_server_get_id (DBusServer *server);
  60. DBUS_EXPORT
  61. void dbus_server_set_new_connection_function (DBusServer *server,
  62. DBusNewConnectionFunction function,
  63. void *data,
  64. DBusFreeFunction free_data_function);
  65. DBUS_EXPORT
  66. dbus_bool_t dbus_server_set_watch_functions (DBusServer *server,
  67. DBusAddWatchFunction add_function,
  68. DBusRemoveWatchFunction remove_function,
  69. DBusWatchToggledFunction toggled_function,
  70. void *data,
  71. DBusFreeFunction free_data_function);
  72. DBUS_EXPORT
  73. dbus_bool_t dbus_server_set_timeout_functions (DBusServer *server,
  74. DBusAddTimeoutFunction add_function,
  75. DBusRemoveTimeoutFunction remove_function,
  76. DBusTimeoutToggledFunction toggled_function,
  77. void *data,
  78. DBusFreeFunction free_data_function);
  79. DBUS_EXPORT
  80. dbus_bool_t dbus_server_set_auth_mechanisms (DBusServer *server,
  81. const char **mechanisms);
  82. DBUS_EXPORT
  83. dbus_bool_t dbus_server_allocate_data_slot (dbus_int32_t *slot_p);
  84. DBUS_EXPORT
  85. void dbus_server_free_data_slot (dbus_int32_t *slot_p);
  86. DBUS_EXPORT
  87. dbus_bool_t dbus_server_set_data (DBusServer *server,
  88. int slot,
  89. void *data,
  90. DBusFreeFunction free_data_func);
  91. DBUS_EXPORT
  92. void* dbus_server_get_data (DBusServer *server,
  93. int slot);
  94. /**
  95. * Clear a variable or struct member that contains a #DBusServer.
  96. * If it does not contain #NULL, the server that was previously
  97. * there is unreferenced with dbus_server_unref().
  98. *
  99. * This is very similar to dbus_clear_connection(): see that function
  100. * for more details.
  101. *
  102. * @param pointer_to_server A pointer to a variable or struct member.
  103. * pointer_to_server must not be #NULL, but *pointer_to_server
  104. * may be #NULL.
  105. */
  106. static inline void
  107. dbus_clear_server (DBusServer **pointer_to_server)
  108. {
  109. _dbus_clear_pointer_impl (DBusServer, pointer_to_server, dbus_server_unref);
  110. }
  111. /** @} */
  112. DBUS_END_DECLS
  113. #endif /* DBUS_SERVER_H */