SDL_dbus.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_internal.h"
  19. #ifndef SDL_dbus_h_
  20. #define SDL_dbus_h_
  21. #ifdef HAVE_DBUS_DBUS_H
  22. #define SDL_USE_LIBDBUS 1
  23. #include <dbus/dbus.h>
  24. #ifndef DBUS_TIMEOUT_USE_DEFAULT
  25. #define DBUS_TIMEOUT_USE_DEFAULT -1
  26. #endif
  27. #ifndef DBUS_TIMEOUT_INFINITE
  28. #define DBUS_TIMEOUT_INFINITE ((int) 0x7fffffff)
  29. #endif
  30. typedef struct SDL_DBusContext
  31. {
  32. DBusConnection *session_conn;
  33. DBusConnection *system_conn;
  34. DBusConnection *(*bus_get_private)(DBusBusType, DBusError *);
  35. dbus_bool_t (*bus_register)(DBusConnection *, DBusError *);
  36. void (*bus_add_match)(DBusConnection *, const char *, DBusError *);
  37. DBusConnection *(*connection_open_private)(const char *, DBusError *);
  38. void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t);
  39. dbus_bool_t (*connection_get_is_connected)(DBusConnection *);
  40. dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction);
  41. dbus_bool_t (*connection_remove_filter)(DBusConnection *, DBusHandleMessageFunction, void *);
  42. dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *,
  43. const DBusObjectPathVTable *, void *, DBusError *);
  44. dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *);
  45. DBusMessage *(*connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *);
  46. void (*connection_close)(DBusConnection *);
  47. void (*connection_ref)(DBusConnection *);
  48. void (*connection_unref)(DBusConnection *);
  49. void (*connection_flush)(DBusConnection *);
  50. dbus_bool_t (*connection_read_write)(DBusConnection *, int);
  51. DBusDispatchStatus (*connection_dispatch)(DBusConnection *);
  52. dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *);
  53. dbus_bool_t (*message_has_path)(DBusMessage *, const char *);
  54. DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *);
  55. dbus_bool_t (*message_append_args)(DBusMessage *, int, ...);
  56. dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list);
  57. void (*message_iter_init_append)(DBusMessage *, DBusMessageIter *);
  58. dbus_bool_t (*message_iter_open_container)(DBusMessageIter *, int, const char *, DBusMessageIter *);
  59. dbus_bool_t (*message_iter_append_basic)(DBusMessageIter *, int, const void *);
  60. dbus_bool_t (*message_iter_close_container)(DBusMessageIter *, DBusMessageIter *);
  61. dbus_bool_t (*message_get_args)(DBusMessage *, DBusError *, int, ...);
  62. dbus_bool_t (*message_get_args_valist)(DBusMessage *, DBusError *, int, va_list);
  63. dbus_bool_t (*message_iter_init)(DBusMessage *, DBusMessageIter *);
  64. dbus_bool_t (*message_iter_next)(DBusMessageIter *);
  65. void (*message_iter_get_basic)(DBusMessageIter *, void *);
  66. int (*message_iter_get_arg_type)(DBusMessageIter *);
  67. void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *);
  68. void (*message_unref)(DBusMessage *);
  69. dbus_bool_t (*threads_init_default)(void);
  70. void (*error_init)(DBusError *);
  71. dbus_bool_t (*error_is_set)(const DBusError *);
  72. void (*error_free)(DBusError *);
  73. char *(*get_local_machine_id)(void);
  74. char *(*try_get_local_machine_id)(DBusError *);
  75. void (*free)(void *);
  76. void (*free_string_array)(char **);
  77. void (*shutdown)(void);
  78. } SDL_DBusContext;
  79. extern void SDL_DBus_Init(void);
  80. extern void SDL_DBus_Quit(void);
  81. extern SDL_DBusContext *SDL_DBus_GetContext(void);
  82. // These use the built-in Session connection.
  83. extern bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...);
  84. extern bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...);
  85. extern bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, int expectedtype, void *result);
  86. // These use whatever connection you like.
  87. extern bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
  88. extern bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
  89. extern bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, int expectedtype, void *result);
  90. extern void SDL_DBus_ScreensaverTickle(void);
  91. extern bool SDL_DBus_ScreensaverInhibit(bool inhibit);
  92. extern void SDL_DBus_PumpEvents(void);
  93. extern char *SDL_DBus_GetLocalMachineId(void);
  94. extern char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *files_count);
  95. #endif // HAVE_DBUS_DBUS_H
  96. #endif // SDL_dbus_h_