pidgin/pidgin

Wayland screenshare review feedback from QuLogic
release-2.x.y
2020-04-07, David Woodhouse
8c751a7fa2dd
Parents 87d96850a2d7
Children bf800190c67e
Wayland screenshare review feedback from QuLogic
--- a/pidgin/gtkrequest.c Sun Apr 05 23:44:51 2020 +0100
+++ b/pidgin/gtkrequest.c Tue Apr 07 21:02:55 2020 +0100
@@ -38,6 +38,9 @@
#include "gtkblist.h"
#ifdef USE_VV
#include "media-gst.h"
+#ifdef HAVE_GIOUNIX
+#include <gio/gunixfdlist.h>
+#endif
#endif
#include <gdk/gdkkeysyms.h>
@@ -83,12 +86,12 @@
struct
{
#ifdef HAVE_GIOUNIX
+ GDBusConnection *dbus_connection;
+#endif
GCancellable *cancellable;
- GDBusConnection *dbus_connection;
gchar *session_path;
guint signal_id;
guint32 node_id;
-#endif
} screenshare;
@@ -1721,17 +1724,11 @@
#ifdef USE_VV
#ifdef HAVE_GIOUNIX
-#include <gio/gunixfdlist.h>
static gboolean portal_failed;
static void screenshare_cancel_cb(GtkWidget *button, PidginRequestData *data);
-static void portal_cancel_cb(PidginRequestData *data)
-{
- screenshare_cancel_cb(NULL, data);
-}
-
static void portal_fallback(PidginRequestData *data)
{
purple_debug_info("pidgin", "Fallback from XDP portal screenshare\n");
@@ -1741,7 +1738,7 @@
pidgin_auto_parent_window(data->dialog);
gtk_widget_show_all(data->dialog);
} else {
- portal_cancel_cb(data);
+ screenshare_cancel_cb(NULL, data);
}
}
@@ -1767,9 +1764,19 @@
static gchar *portal_request_path(GDBusConnection *dc, GVariantBuilder *b)
{
const gchar *bus_name = g_dbus_connection_get_unique_name(dc);
- gchar *dot, *request_str = g_strdup_printf("u%u", portal_request_nr++);
- gchar *request_path = g_strdup_printf("/org/freedesktop/portal/desktop/request/%s/%s",
- bus_name + 1, request_str);
+ gchar *dot, *request_str;
+ gchar *request_path;
+
+ request_str = g_strdup_printf("u%u", portal_request_nr++);
+ if (!request_str)
+ return NULL;
+
+ request_path = g_strdup_printf("/org/freedesktop/portal/desktop/request/%s/%s",
+ bus_name + 1, request_str);
+ if (!request_path) {
+ g_free(request_str);
+ return NULL;
+ }
g_variant_builder_add(b, "{sv}", "handle_token", g_variant_new_take_string(request_str));
@@ -1787,13 +1794,21 @@
GVariantBuilder b;
gchar *request_path;
- if (data->u.screenshare.signal_id)
+ if (data->u.screenshare.signal_id) {
g_dbus_connection_signal_unsubscribe(data->u.screenshare.dbus_connection,
data->u.screenshare.signal_id);
+ }
if (!opts)
opts = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
request_path = portal_request_path(data->u.screenshare.dbus_connection, opts);
+ if (!request_path) {
+ g_variant_builder_unref(opts);
+ purple_notify_error(NULL, _("Screen share error"),
+ _("Error creating screencast request"), NULL);
+ screenshare_cancel_cb(NULL, data);
+ }
data->u.screenshare.signal_id = g_dbus_connection_signal_subscribe(data->u.screenshare.dbus_connection,
"org.freedesktop.portal.Desktop",
@@ -1868,7 +1883,7 @@
purple_notify_error(NULL, _("Screen share error"),
_("OpenPipeWireRemote request failed"), error->message);
g_clear_error(&error);
- portal_cancel_cb(data);
+ screenshare_cancel_cb(NULL, data);
return;
}
l = g_dbus_message_get_unix_fd_list(msg);
@@ -1876,7 +1891,7 @@
purple_debug_info("pidgin", "OpenPipeWireRemote request failed to yield a file descriptor\n");
purple_notify_error(NULL, _("Screen share error"), _("OpenPipeWireRemote request failed"),
_("No file descriptor found"));
- portal_cancel_cb(data);
+ screenshare_cancel_cb(NULL, data);
return;
}
pipewire_fd = g_unix_fd_list_get(l, 0, NULL);
@@ -1940,7 +1955,7 @@
purple_debug_info("pidgin", "Screencast Start call returned %d\n", code);
purple_notify_error(NULL, _("Screen share error"),
_("Screencast \"Start\" failed"), NULL);
- portal_cancel_cb(data);
+ screenshare_cancel_cb(NULL, data);
return;
}
@@ -1961,7 +1976,7 @@
purple_debug_info("pidgin", "Screencast SelectSources call returned %d\n", code);
purple_notify_error(NULL, _("Screen share error"),
_("Screencast \"SelectSources\" failed"), NULL);
- portal_cancel_cb(data);
+ screenshare_cancel_cb(NULL, data);
return;
}
@@ -1983,7 +1998,7 @@
purple_debug_info("pidgin", "Screencast CreateSession call returned %d\n", code);
purple_notify_error(NULL, _("Screen share error"),
_("Screencast \"CreateSession\" failed."), NULL);
- portal_cancel_cb(data);
+ screenshare_cancel_cb(NULL, data);
return;
}