Atlas - SDL_dbus.h
Home / ext / SDL / src / core / linux Lines: 1 | Size: 8413 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2026 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21 22#include "SDL_internal.h" 23 24#ifndef SDL_dbus_h_ 25#define SDL_dbus_h_ 26 27#ifdef HAVE_DBUS_DBUS_H 28#define SDL_USE_LIBDBUS 1 29#include <dbus/dbus.h> 30 31#include "../../SDL_list.h" 32#include "../../SDL_menu.h" 33 34#ifndef DBUS_TIMEOUT_USE_DEFAULT 35#define DBUS_TIMEOUT_USE_DEFAULT -1 36#endif 37#ifndef DBUS_TIMEOUT_INFINITE 38#define DBUS_TIMEOUT_INFINITE ((int)0x7fffffff) 39#endif 40#ifndef DBUS_TYPE_UNIX_FD 41#define DBUS_TYPE_UNIX_FD ((int)'h') 42#endif 43#ifndef DBUS_ERROR_UNKNOWN_PROPERTY 44#define DBUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" 45#endif 46 47typedef struct SDL_DBusContext 48{ 49 DBusConnection *session_conn; 50 DBusConnection *system_conn; 51 52 DBusConnection *(*bus_get_private)(DBusBusType, DBusError *); 53 dbus_bool_t (*bus_register)(DBusConnection *, DBusError *); 54 void (*bus_add_match)(DBusConnection *, const char *, DBusError *); 55 void (*bus_remove_match)(DBusConnection *, const char *, DBusError *); 56 const char *(*bus_get_unique_name)(DBusConnection *); 57 DBusConnection *(*connection_open_private)(const char *, DBusError *); 58 void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t); 59 dbus_bool_t (*connection_get_is_connected)(DBusConnection *); 60 dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction); 61 dbus_bool_t (*connection_remove_filter)(DBusConnection *, DBusHandleMessageFunction, void *); 62 dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *, 63 const DBusObjectPathVTable *, void *, DBusError *); 64 dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *); 65 DBusMessage *(*connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *); 66 void (*connection_close)(DBusConnection *); 67 void (*connection_ref)(DBusConnection *); 68 void (*connection_unref)(DBusConnection *); 69 void (*connection_flush)(DBusConnection *); 70 dbus_bool_t (*connection_read_write)(DBusConnection *, int); 71 dbus_bool_t (*connection_read_write_dispatch)(DBusConnection *, int); 72 DBusDispatchStatus (*connection_dispatch)(DBusConnection *); 73 dbus_bool_t (*type_is_fixed)(int); 74 dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *); 75 dbus_bool_t (*message_has_path)(DBusMessage *, const char *); 76 DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *); 77 DBusMessage *(*message_new_signal)(const char *, const char *, const char *); 78 void (*message_set_no_reply)(DBusMessage *, dbus_bool_t); 79 dbus_bool_t (*message_append_args)(DBusMessage *, int, ...); 80 dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list); 81 void (*message_iter_init_append)(DBusMessage *, DBusMessageIter *); 82 dbus_bool_t (*message_iter_open_container)(DBusMessageIter *, int, const char *, DBusMessageIter *); 83 dbus_bool_t (*message_iter_append_basic)(DBusMessageIter *, int, const void *); 84 dbus_bool_t (*message_iter_close_container)(DBusMessageIter *, DBusMessageIter *); 85 dbus_bool_t (*message_get_args)(DBusMessage *, DBusError *, int, ...); 86 dbus_bool_t (*message_get_args_valist)(DBusMessage *, DBusError *, int, va_list); 87 dbus_bool_t (*message_iter_init)(DBusMessage *, DBusMessageIter *); 88 dbus_bool_t (*message_iter_next)(DBusMessageIter *); 89 void (*message_iter_get_basic)(DBusMessageIter *, void *); 90 int (*message_iter_get_arg_type)(DBusMessageIter *); 91 void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *); 92 void (*message_unref)(DBusMessage *); 93 dbus_bool_t (*threads_init_default)(void); 94 void (*error_init)(DBusError *); 95 dbus_bool_t (*error_is_set)(const DBusError *); 96 dbus_bool_t (*error_has_name)(const DBusError *, const char *); 97 void (*error_free)(DBusError *); 98 char *(*get_local_machine_id)(void); 99 char *(*try_get_local_machine_id)(DBusError *); 100 void (*free)(void *); 101 void (*free_string_array)(char **); 102 void (*shutdown)(void); 103 104 /* New symbols for SNI and menu export */ 105 int (*bus_request_name)(DBusConnection *, const char *, unsigned int, DBusError *); 106 dbus_bool_t (*message_is_method_call)(DBusMessage *, const char *, const char *); 107 DBusMessage *(*message_new_error)(DBusMessage *, const char *, const char *); 108 DBusMessage *(*message_new_method_return)(DBusMessage *); 109 dbus_bool_t (*message_iter_append_fixed_array)(DBusMessageIter *, int, const void *, int); 110 void (*message_iter_get_fixed_array)(DBusMessageIter *, void *, int *); 111 dbus_bool_t (*connection_unregister_object_path)(DBusConnection *, const char *); 112 dbus_bool_t (*connection_get_object_path_data)(DBusConnection *, const char *, void **); 113} SDL_DBusContext; 114 115extern void SDL_DBus_Init(void); 116extern void SDL_DBus_Quit(void); 117extern SDL_DBusContext *SDL_DBus_GetContext(void); 118 119// These use the built-in Session connection. 120extern bool SDL_DBus_CallMethod(DBusMessage **save_reply, const char *node, const char *path, const char *interface, const char *method, ...); 121extern bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...); 122// save_reply must be non-NULL if it's a string property 123extern bool SDL_DBus_QueryProperty(DBusMessage **save_reply, const char *node, const char *path, const char *interface, const char *property, int expectedtype, void *result); 124 125// These use whatever connection you like. 126extern bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, DBusMessage **save_reply, const char *node, const char *path, const char *interface, const char *method, ...); 127extern bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...); 128// save_reply must be non-NULL if it's a string property 129extern bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, DBusMessage **save_reply, const char *node, const char *path, const char *interface, const char *property, int expectedtype, void *result); 130 131// Used to free any reply returned from SDL_DBus_CallMethod() and SDL_DBus_QueryProperty() 132extern void SDL_DBus_FreeReply(DBusMessage **saved_reply); 133 134extern void SDL_DBus_ScreensaverTickle(void); 135extern bool SDL_DBus_ScreensaverInhibit(bool inhibit); 136 137extern bool SDL_DBus_OpenURI(const char *uri, const char *window_id, const char *activation_token); 138 139extern void SDL_DBus_PumpEvents(void); 140extern char *SDL_DBus_GetLocalMachineId(void); 141 142extern char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *files_count); 143 144extern int SDL_DBus_CameraPortalRequestAccess(void); 145 146// Menu export functions 147#define SDL_DBUS_UPDATE_MENU_FLAGS_NONE 0 148extern SDL_MenuItem *SDL_DBus_CreateMenuItem(void); 149extern const char *SDL_DBus_ExportMenu(SDL_DBusContext *ctx, DBusConnection *conn, SDL_ListNode *menu); 150extern void SDL_DBus_UpdateMenu(SDL_DBusContext *ctx, DBusConnection *conn, SDL_ListNode *menu, const char *path, void (*cb)(SDL_ListNode *, const char *, void *), void *cbdata, unsigned char flags); 151extern void SDL_DBus_RegisterMenuOpenCallback(SDL_ListNode *menu, bool (*cb)(SDL_ListNode *, void *), void *cbdata); 152extern void SDL_DBus_TransferMenuItemProperties(SDL_MenuItem *src, SDL_MenuItem *dst); 153extern void SDL_DBus_RetractMenu(SDL_DBusContext *ctx, DBusConnection *conn, const char **path); 154 155#endif // HAVE_DBUS_DBUS_H 156 157#endif // SDL_dbus_h_ 158[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.