| 1719 } |
1722 } |
| 1720 |
1723 |
| 1721 #ifdef USE_VV |
1724 #ifdef USE_VV |
| 1722 |
1725 |
| 1723 #ifdef HAVE_GIOUNIX |
1726 #ifdef HAVE_GIOUNIX |
| 1724 #include <gio/gunixfdlist.h> |
|
| 1725 |
1727 |
| 1726 static gboolean portal_failed; |
1728 static gboolean portal_failed; |
| 1727 |
1729 |
| 1728 static void screenshare_cancel_cb(GtkWidget *button, PidginRequestData *data); |
1730 static void screenshare_cancel_cb(GtkWidget *button, PidginRequestData *data); |
| 1729 |
|
| 1730 static void portal_cancel_cb(PidginRequestData *data) |
|
| 1731 { |
|
| 1732 screenshare_cancel_cb(NULL, data); |
|
| 1733 } |
|
| 1734 |
1731 |
| 1735 static void portal_fallback(PidginRequestData *data) |
1732 static void portal_fallback(PidginRequestData *data) |
| 1736 { |
1733 { |
| 1737 purple_debug_info("pidgin", "Fallback from XDP portal screenshare\n"); |
1734 purple_debug_info("pidgin", "Fallback from XDP portal screenshare\n"); |
| 1738 portal_failed = TRUE; |
1735 portal_failed = TRUE; |
| 1739 |
1736 |
| 1740 if (data->dialog) { |
1737 if (data->dialog) { |
| 1741 pidgin_auto_parent_window(data->dialog); |
1738 pidgin_auto_parent_window(data->dialog); |
| 1742 gtk_widget_show_all(data->dialog); |
1739 gtk_widget_show_all(data->dialog); |
| 1743 } else { |
1740 } else { |
| 1744 portal_cancel_cb(data); |
1741 screenshare_cancel_cb(NULL, data); |
| 1745 } |
1742 } |
| 1746 } |
1743 } |
| 1747 |
1744 |
| 1748 static void request_completed_cb(GObject *object, GAsyncResult *res, gpointer _data) |
1745 static void request_completed_cb(GObject *object, GAsyncResult *res, gpointer _data) |
| 1749 { |
1746 { |
| 1765 static guint portal_session_nr, portal_request_nr; |
1762 static guint portal_session_nr, portal_request_nr; |
| 1766 |
1763 |
| 1767 static gchar *portal_request_path(GDBusConnection *dc, GVariantBuilder *b) |
1764 static gchar *portal_request_path(GDBusConnection *dc, GVariantBuilder *b) |
| 1768 { |
1765 { |
| 1769 const gchar *bus_name = g_dbus_connection_get_unique_name(dc); |
1766 const gchar *bus_name = g_dbus_connection_get_unique_name(dc); |
| 1770 gchar *dot, *request_str = g_strdup_printf("u%u", portal_request_nr++); |
1767 gchar *dot, *request_str; |
| 1771 gchar *request_path = g_strdup_printf("/org/freedesktop/portal/desktop/request/%s/%s", |
1768 gchar *request_path; |
| 1772 bus_name + 1, request_str); |
1769 |
| |
1770 request_str = g_strdup_printf("u%u", portal_request_nr++); |
| |
1771 if (!request_str) |
| |
1772 return NULL; |
| |
1773 |
| |
1774 request_path = g_strdup_printf("/org/freedesktop/portal/desktop/request/%s/%s", |
| |
1775 bus_name + 1, request_str); |
| |
1776 if (!request_path) { |
| |
1777 g_free(request_str); |
| |
1778 return NULL; |
| |
1779 } |
| 1773 |
1780 |
| 1774 g_variant_builder_add(b, "{sv}", "handle_token", g_variant_new_take_string(request_str)); |
1781 g_variant_builder_add(b, "{sv}", "handle_token", g_variant_new_take_string(request_str)); |
| 1775 |
1782 |
| 1776 dot = request_path; |
1783 dot = request_path; |
| 1777 while ((dot = strchr(dot, '.'))) |
1784 while ((dot = strchr(dot, '.'))) |
| 1785 { |
1792 { |
| 1786 GDBusMessage *msg; |
1793 GDBusMessage *msg; |
| 1787 GVariantBuilder b; |
1794 GVariantBuilder b; |
| 1788 gchar *request_path; |
1795 gchar *request_path; |
| 1789 |
1796 |
| 1790 if (data->u.screenshare.signal_id) |
1797 if (data->u.screenshare.signal_id) { |
| 1791 g_dbus_connection_signal_unsubscribe(data->u.screenshare.dbus_connection, |
1798 g_dbus_connection_signal_unsubscribe(data->u.screenshare.dbus_connection, |
| 1792 data->u.screenshare.signal_id); |
1799 data->u.screenshare.signal_id); |
| |
1800 } |
| 1793 |
1801 |
| 1794 if (!opts) |
1802 if (!opts) |
| 1795 opts = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); |
1803 opts = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); |
| |
1804 |
| 1796 request_path = portal_request_path(data->u.screenshare.dbus_connection, opts); |
1805 request_path = portal_request_path(data->u.screenshare.dbus_connection, opts); |
| |
1806 if (!request_path) { |
| |
1807 g_variant_builder_unref(opts); |
| |
1808 purple_notify_error(NULL, _("Screen share error"), |
| |
1809 _("Error creating screencast request"), NULL); |
| |
1810 screenshare_cancel_cb(NULL, data); |
| |
1811 } |
| 1797 |
1812 |
| 1798 data->u.screenshare.signal_id = g_dbus_connection_signal_subscribe(data->u.screenshare.dbus_connection, |
1813 data->u.screenshare.signal_id = g_dbus_connection_signal_subscribe(data->u.screenshare.dbus_connection, |
| 1799 "org.freedesktop.portal.Desktop", |
1814 "org.freedesktop.portal.Desktop", |
| 1800 "org.freedesktop.portal.Request", |
1815 "org.freedesktop.portal.Request", |
| 1801 "Response", request_path, NULL, 0, |
1816 "Response", request_path, NULL, 0, |
| 1866 if (!msg || g_dbus_message_to_gerror(msg, &error)) { |
1881 if (!msg || g_dbus_message_to_gerror(msg, &error)) { |
| 1867 purple_debug_info("pidgin", "OpenPipeWireRemote request failed: %s\n", error->message); |
1882 purple_debug_info("pidgin", "OpenPipeWireRemote request failed: %s\n", error->message); |
| 1868 purple_notify_error(NULL, _("Screen share error"), |
1883 purple_notify_error(NULL, _("Screen share error"), |
| 1869 _("OpenPipeWireRemote request failed"), error->message); |
1884 _("OpenPipeWireRemote request failed"), error->message); |
| 1870 g_clear_error(&error); |
1885 g_clear_error(&error); |
| 1871 portal_cancel_cb(data); |
1886 screenshare_cancel_cb(NULL, data); |
| 1872 return; |
1887 return; |
| 1873 } |
1888 } |
| 1874 l = g_dbus_message_get_unix_fd_list(msg); |
1889 l = g_dbus_message_get_unix_fd_list(msg); |
| 1875 if (!l) { |
1890 if (!l) { |
| 1876 purple_debug_info("pidgin", "OpenPipeWireRemote request failed to yield a file descriptor\n"); |
1891 purple_debug_info("pidgin", "OpenPipeWireRemote request failed to yield a file descriptor\n"); |
| 1877 purple_notify_error(NULL, _("Screen share error"), _("OpenPipeWireRemote request failed"), |
1892 purple_notify_error(NULL, _("Screen share error"), _("OpenPipeWireRemote request failed"), |
| 1878 _("No file descriptor found")); |
1893 _("No file descriptor found")); |
| 1879 portal_cancel_cb(data); |
1894 screenshare_cancel_cb(NULL, data); |
| 1880 return; |
1895 return; |
| 1881 } |
1896 } |
| 1882 pipewire_fd = g_unix_fd_list_get(l, 0, NULL); |
1897 pipewire_fd = g_unix_fd_list_get(l, 0, NULL); |
| 1883 |
1898 |
| 1884 if (data->cbs[0] != NULL) { |
1899 if (data->cbs[0] != NULL) { |
| 1938 if (code || !g_variant_lookup(args, "streams", "@a(ua{sv})", &streams) || |
1953 if (code || !g_variant_lookup(args, "streams", "@a(ua{sv})", &streams) || |
| 1939 g_variant_n_children(streams) != 1) { |
1954 g_variant_n_children(streams) != 1) { |
| 1940 purple_debug_info("pidgin", "Screencast Start call returned %d\n", code); |
1955 purple_debug_info("pidgin", "Screencast Start call returned %d\n", code); |
| 1941 purple_notify_error(NULL, _("Screen share error"), |
1956 purple_notify_error(NULL, _("Screen share error"), |
| 1942 _("Screencast \"Start\" failed"), NULL); |
1957 _("Screencast \"Start\" failed"), NULL); |
| 1943 portal_cancel_cb(data); |
1958 screenshare_cancel_cb(NULL, data); |
| 1944 return; |
1959 return; |
| 1945 } |
1960 } |
| 1946 |
1961 |
| 1947 g_variant_get_child(streams, 0, "(u@a{sv})", &data->u.screenshare.node_id, NULL); |
1962 g_variant_get_child(streams, 0, "(u@a{sv})", &data->u.screenshare.node_id, NULL); |
| 1948 |
1963 |
| 1959 g_variant_get(params, "(u@a{sv})", &code, NULL); |
1974 g_variant_get(params, "(u@a{sv})", &code, NULL); |
| 1960 if (code) { |
1975 if (code) { |
| 1961 purple_debug_info("pidgin", "Screencast SelectSources call returned %d\n", code); |
1976 purple_debug_info("pidgin", "Screencast SelectSources call returned %d\n", code); |
| 1962 purple_notify_error(NULL, _("Screen share error"), |
1977 purple_notify_error(NULL, _("Screen share error"), |
| 1963 _("Screencast \"SelectSources\" failed"), NULL); |
1978 _("Screencast \"SelectSources\" failed"), NULL); |
| 1964 portal_cancel_cb(data); |
1979 screenshare_cancel_cb(NULL, data); |
| 1965 return; |
1980 return; |
| 1966 } |
1981 } |
| 1967 |
1982 |
| 1968 screen_cast_call(data, "Start", "", NULL, started_cb); |
1983 screen_cast_call(data, "Start", "", NULL, started_cb); |
| 1969 } |
1984 } |
| 1981 if (code || !g_variant_lookup(args, "session_handle", "s", |
1996 if (code || !g_variant_lookup(args, "session_handle", "s", |
| 1982 &data->u.screenshare.session_path)) { |
1997 &data->u.screenshare.session_path)) { |
| 1983 purple_debug_info("pidgin", "Screencast CreateSession call returned %d\n", code); |
1998 purple_debug_info("pidgin", "Screencast CreateSession call returned %d\n", code); |
| 1984 purple_notify_error(NULL, _("Screen share error"), |
1999 purple_notify_error(NULL, _("Screen share error"), |
| 1985 _("Screencast \"CreateSession\" failed."), NULL); |
2000 _("Screencast \"CreateSession\" failed."), NULL); |
| 1986 portal_cancel_cb(data); |
2001 screenshare_cancel_cb(NULL, data); |
| 1987 return; |
2002 return; |
| 1988 } |
2003 } |
| 1989 |
2004 |
| 1990 g_variant_builder_init(&opts, G_VARIANT_TYPE("a{sv}")); |
2005 g_variant_builder_init(&opts, G_VARIANT_TYPE("a{sv}")); |
| 1991 g_variant_builder_add(&opts, "{sv}", "multiple", g_variant_new_boolean(FALSE)); |
2006 g_variant_builder_add(&opts, "{sv}", "multiple", g_variant_new_boolean(FALSE)); |