dbus.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * QEMU DBus display
  3. *
  4. * Copyright (c) 2021 Marc-André Lureau <marcandre.lureau@redhat.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #ifndef UI_DBUS_H
  25. #define UI_DBUS_H
  26. #include "chardev/char-socket.h"
  27. #include "qemu/dbus.h"
  28. #include "qom/object.h"
  29. #include "ui/console.h"
  30. #include "ui/clipboard.h"
  31. #include "ui/dbus-display1.h"
  32. typedef struct DBusClipboardRequest {
  33. GDBusMethodInvocation *invocation;
  34. QemuClipboardType type;
  35. guint timeout_id;
  36. } DBusClipboardRequest;
  37. struct DBusDisplay {
  38. Object parent;
  39. DisplayGLMode gl_mode;
  40. bool p2p;
  41. char *dbus_addr;
  42. char *audiodev;
  43. DisplayGLCtx glctx;
  44. GDBusConnection *bus;
  45. GDBusObjectManagerServer *server;
  46. QemuDBusDisplay1VM *iface;
  47. GPtrArray *consoles;
  48. GCancellable *add_client_cancellable;
  49. QemuClipboardPeer clipboard_peer;
  50. QemuDBusDisplay1Clipboard *clipboard;
  51. QemuDBusDisplay1Clipboard *clipboard_proxy;
  52. DBusClipboardRequest clipboard_request[QEMU_CLIPBOARD_SELECTION__COUNT];
  53. Notifier notifier;
  54. };
  55. #ifdef WIN32
  56. bool
  57. dbus_win32_import_socket(GDBusMethodInvocation *invocation,
  58. GVariant *arg_listener, int *socket);
  59. #endif
  60. #define TYPE_DBUS_DISPLAY "dbus-display"
  61. OBJECT_DECLARE_SIMPLE_TYPE(DBusDisplay, DBUS_DISPLAY)
  62. void dbus_display_notifier_add(Notifier *notifier);
  63. #define DBUS_DISPLAY_TYPE_CONSOLE dbus_display_console_get_type()
  64. G_DECLARE_FINAL_TYPE(DBusDisplayConsole,
  65. dbus_display_console,
  66. DBUS_DISPLAY,
  67. CONSOLE,
  68. GDBusObjectSkeleton)
  69. DBusDisplayConsole *
  70. dbus_display_console_new(DBusDisplay *display, QemuConsole *con);
  71. int
  72. dbus_display_console_get_index(DBusDisplayConsole *ddc);
  73. extern const DisplayChangeListenerOps dbus_console_dcl_ops;
  74. #define DBUS_DISPLAY_TYPE_LISTENER dbus_display_listener_get_type()
  75. G_DECLARE_FINAL_TYPE(DBusDisplayListener,
  76. dbus_display_listener,
  77. DBUS_DISPLAY,
  78. LISTENER,
  79. GObject)
  80. DBusDisplayListener *
  81. dbus_display_listener_new(const char *bus_name,
  82. GDBusConnection *conn,
  83. DBusDisplayConsole *console);
  84. DBusDisplayConsole *
  85. dbus_display_listener_get_console(DBusDisplayListener *ddl);
  86. const char *
  87. dbus_display_listener_get_bus_name(DBusDisplayListener *ddl);
  88. extern const DisplayChangeListenerOps dbus_gl_dcl_ops;
  89. extern const DisplayChangeListenerOps dbus_dcl_ops;
  90. #define TYPE_CHARDEV_DBUS "chardev-dbus"
  91. typedef struct DBusChardevClass {
  92. SocketChardevClass parent_class;
  93. void (*parent_chr_be_event)(Chardev *s, QEMUChrEvent event);
  94. } DBusChardevClass;
  95. DECLARE_CLASS_CHECKERS(DBusChardevClass, DBUS_CHARDEV,
  96. TYPE_CHARDEV_DBUS)
  97. typedef struct DBusChardev {
  98. SocketChardev parent;
  99. bool exported;
  100. QemuDBusDisplay1Chardev *iface;
  101. } DBusChardev;
  102. DECLARE_INSTANCE_CHECKER(DBusChardev, DBUS_CHARDEV, TYPE_CHARDEV_DBUS)
  103. #define CHARDEV_IS_DBUS(chr) \
  104. object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_DBUS)
  105. typedef enum {
  106. DBUS_DISPLAY_CHARDEV_OPEN,
  107. DBUS_DISPLAY_CHARDEV_CLOSE,
  108. } DBusDisplayEventType;
  109. typedef struct DBusDisplayEvent {
  110. DBusDisplayEventType type;
  111. union {
  112. DBusChardev *chardev;
  113. };
  114. } DBusDisplayEvent;
  115. void dbus_display_notify(DBusDisplayEvent *event);
  116. void dbus_chardev_init(DBusDisplay *dpy);
  117. void dbus_clipboard_init(DBusDisplay *dpy);
  118. #endif /* UI_DBUS_H */