dbus.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. #define TYPE_DBUS_DISPLAY "dbus-display"
  56. OBJECT_DECLARE_SIMPLE_TYPE(DBusDisplay, DBUS_DISPLAY)
  57. void dbus_display_notifier_add(Notifier *notifier);
  58. #define DBUS_DISPLAY_TYPE_CONSOLE dbus_display_console_get_type()
  59. G_DECLARE_FINAL_TYPE(DBusDisplayConsole,
  60. dbus_display_console,
  61. DBUS_DISPLAY,
  62. CONSOLE,
  63. GDBusObjectSkeleton)
  64. DBusDisplayConsole *
  65. dbus_display_console_new(DBusDisplay *display, QemuConsole *con);
  66. int
  67. dbus_display_console_get_index(DBusDisplayConsole *ddc);
  68. extern const DisplayChangeListenerOps dbus_console_dcl_ops;
  69. #define DBUS_DISPLAY_TYPE_LISTENER dbus_display_listener_get_type()
  70. G_DECLARE_FINAL_TYPE(DBusDisplayListener,
  71. dbus_display_listener,
  72. DBUS_DISPLAY,
  73. LISTENER,
  74. GObject)
  75. DBusDisplayListener *
  76. dbus_display_listener_new(const char *bus_name,
  77. GDBusConnection *conn,
  78. DBusDisplayConsole *console);
  79. DBusDisplayConsole *
  80. dbus_display_listener_get_console(DBusDisplayListener *ddl);
  81. const char *
  82. dbus_display_listener_get_bus_name(DBusDisplayListener *ddl);
  83. extern const DisplayChangeListenerOps dbus_gl_dcl_ops;
  84. extern const DisplayChangeListenerOps dbus_dcl_ops;
  85. #define TYPE_CHARDEV_DBUS "chardev-dbus"
  86. typedef struct DBusChardevClass {
  87. SocketChardevClass parent_class;
  88. void (*parent_chr_be_event)(Chardev *s, QEMUChrEvent event);
  89. } DBusChardevClass;
  90. DECLARE_CLASS_CHECKERS(DBusChardevClass, DBUS_CHARDEV,
  91. TYPE_CHARDEV_DBUS)
  92. typedef struct DBusChardev {
  93. SocketChardev parent;
  94. bool exported;
  95. QemuDBusDisplay1Chardev *iface;
  96. } DBusChardev;
  97. DECLARE_INSTANCE_CHECKER(DBusChardev, DBUS_CHARDEV, TYPE_CHARDEV_DBUS)
  98. #define CHARDEV_IS_DBUS(chr) \
  99. object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_DBUS)
  100. typedef enum {
  101. DBUS_DISPLAY_CHARDEV_OPEN,
  102. DBUS_DISPLAY_CHARDEV_CLOSE,
  103. } DBusDisplayEventType;
  104. typedef struct DBusDisplayEvent {
  105. DBusDisplayEventType type;
  106. union {
  107. DBusChardev *chardev;
  108. };
  109. } DBusDisplayEvent;
  110. void dbus_display_notify(DBusDisplayEvent *event);
  111. void dbus_chardev_init(DBusDisplay *dpy);
  112. void dbus_clipboard_init(DBusDisplay *dpy);
  113. #endif /* UI_DBUS_H */