Blame SOURCES/0054-remote-viewer-remove-spice-controller.patch

34c786
From cfcf554c54965761772afe10fba950e5f2fed536 Mon Sep 17 00:00:00 2001
34c786
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
34c786
Date: Fri, 23 Jun 2017 17:25:07 +0200
34c786
Subject: [PATCH] remote-viewer: remove --spice-controller
34c786
MIME-Version: 1.0
34c786
Content-Type: text/plain; charset=UTF-8
34c786
Content-Transfer-Encoding: 8bit
34c786
34c786
spice controller interface is being removed from spice-gtk.
34c786
34c786
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
34c786
Reviewed-by: Victor Toso <victortoso@redhat.com>
34c786
Signed-off-by: Victor Toso <victortoso@redhat.com>
34c786
---
34c786
 configure.ac                        |   3 +-
34c786
 data/Makefile.am                    |   1 -
34c786
 data/spice-xpi-client-remote-viewer |   6 -
34c786
 data/virt-viewer.wxs.in             |  11 -
34c786
 man/remote-viewer.pod               |   6 -
34c786
 src/Makefile.am                     |   2 -
34c786
 src/remote-viewer.c                 | 448 +---------------------------
34c786
 7 files changed, 5 insertions(+), 472 deletions(-)
34c786
 delete mode 100644 data/spice-xpi-client-remote-viewer
34c786
34c786
diff --git a/configure.ac b/configure.ac
34c786
index 6ed5f8a..abdbdaf 100644
34c786
--- a/configure.ac
34c786
+++ b/configure.ac
34c786
@@ -159,13 +159,12 @@ AC_ARG_WITH([spice-gtk],
34c786
 AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
34c786
       [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
34c786
                          spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
34c786
-                         spice-controller spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
34c786
+                         spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
34c786
                         [with_spice_gtk=yes], [with_spice_gtk=no])])
34c786
 
34c786
 AS_IF([test "x$with_spice_gtk" = "xyes"],
34c786
       [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
34c786
                                      spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED])]
34c786
-      [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
34c786
       [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= $SPICE_PROTOCOL_REQUIRED])]
34c786
       [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
34c786
 )
34c786
diff --git a/data/Makefile.am b/data/Makefile.am
34c786
index 55718d9..54be2b1 100644
34c786
--- a/data/Makefile.am
34c786
+++ b/data/Makefile.am
34c786
@@ -3,7 +3,6 @@ CLEANFILES =
34c786
 MANUFACTURER = Virt Manager Project
34c786
 
34c786
 EXTRA_DIST =					\
34c786
-	spice-xpi-client-remote-viewer		\
34c786
 	virt-viewer.wxs.in			\
34c786
 	$(NULL)
34c786
 
34c786
diff --git a/data/spice-xpi-client-remote-viewer b/data/spice-xpi-client-remote-viewer
34c786
deleted file mode 100644
34c786
index 3109c66..0000000
34c786
--- a/data/spice-xpi-client-remote-viewer
34c786
+++ /dev/null
34c786
@@ -1,6 +0,0 @@
34c786
-#!/bin/sh
34c786
-
34c786
-logger -t spice "starting remote-viewer --spice-controller $@..."
34c786
-env | logger -t spice
34c786
-exec remote-viewer --spice-controller "$@" 2>&1 | logger -t spice
34c786
-logger -t spice "remote-viewer execution failed"
34c786
diff --git a/data/virt-viewer.wxs.in b/data/virt-viewer.wxs.in
34c786
index 9838265..2047720 100644
34c786
--- a/data/virt-viewer.wxs.in
34c786
+++ b/data/virt-viewer.wxs.in
34c786
@@ -55,16 +55,6 @@
34c786
     <Condition Message="VirtViewer is already installed.">NOT NEWERVERSIONDETECTED</Condition>
34c786
 
34c786
     <DirectoryRef Id="TARGETDIR">
34c786
-      <Component Id="CRegistryEntries" Guid="*">
34c786
-        <RegistryKey Root='HKLM' Key='Software\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{96190E9D-6FBB-64DB-9095-29F6FDE0B897}'>
34c786
-          <RegistryValue Type='string' Name='AppPath' Value='[INSTALLDIR]\bin'/>
34c786
-          <RegistryValue Type='string' Name='AppName' Value='remote-viewer.exe'/>
34c786
-          <RegistryValue Type='integer' Name='Policy' Value='3'/>
34c786
-        </RegistryKey>
34c786
-        <RegistryKey Root='HKLM' Key='Software\spice-space.org\spicex'>
34c786
-          <RegistryValue Type='string' Name='client' Value='[INSTALLDIR]\bin\remote-viewer.exe --spice-controller'/>
34c786
-        </RegistryKey>
34c786
-      </Component>
34c786
       <Component Id="CProgIds" Guid="89D6F46D-9C5E-4D65-8456-58FC361E553E">
34c786
         <ProgId Id='VirtViewer.vvfile' Description='VirtViewer connection file'>
34c786
           <Extension Id='vv' ContentType='application/x-virt-viewer'>
34c786
@@ -129,7 +119,6 @@
34c786
       <ComponentGroupRef Id="CG.virt-viewer"/>
34c786
       <ComponentRef Id="CDepsFile"/>
34c786
       <ComponentRef Id="CShortcut"/>
34c786
-      <ComponentRef Id="CRegistryEntries"/>
34c786
       <ComponentRef Id="CProgIds"/>
34c786
       <ComponentRef Id="CHwdataUSB"/>
34c786
     </Feature>
34c786
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
34c786
index 560f73f..e26aee7 100644
34c786
--- a/man/remote-viewer.pod
34c786
+++ b/man/remote-viewer.pod
34c786
@@ -55,12 +55,6 @@ CONFIGURATION section below.
34c786
 
34c786
 Set the window title to B<TITLE>
34c786
 
34c786
-=item --spice-controller
34c786
-
34c786
-Use the SPICE controller to initialize the connection with the SPICE
34c786
-server. This option is used by the SPICE browser addons to allow web
34c786
-page to start a client.
34c786
-
34c786
 =item --debug
34c786
 
34c786
 Print debugging information
34c786
diff --git a/src/Makefile.am b/src/Makefile.am
34c786
index b3eea67..6f2b7a1 100644
34c786
--- a/src/Makefile.am
34c786
+++ b/src/Makefile.am
34c786
@@ -180,11 +180,9 @@ remote_viewer_SOURCES =				\
34c786
 	$(NULL)
34c786
 remote_viewer_LDFLAGS =				\
34c786
 	$(COMMON_LIBS)				\
34c786
-	$(SPICE_CONTROLLER_LIBS)		\
34c786
 	$(NULL)
34c786
 remote_viewer_CFLAGS =				\
34c786
 	$(COMMON_CFLAGS) 			\
34c786
-	$(SPICE_CONTROLLER_CFLAGS)		\
34c786
 	$(NULL)
34c786
 remote_viewer_LDADD = \
34c786
 	libvirt-viewer-util.la \
34c786
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
34c786
index 429f38c..a920aa0 100644
34c786
--- a/src/remote-viewer.c
34c786
+++ b/src/remote-viewer.c
34c786
@@ -36,7 +36,6 @@
34c786
 #endif
34c786
 
34c786
 #ifdef HAVE_SPICE_GTK
34c786
-#include <spice-controller.h>
34c786
 #include "virt-viewer-session-spice.h"
34c786
 #endif
34c786
 
34c786
@@ -53,10 +52,6 @@
34c786
 #endif
34c786
 
34c786
 struct _RemoteViewerPrivate {
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-    SpiceCtrlController *controller;
34c786
-    SpiceCtrlForeignMenu *ctrl_foreign_menu;
34c786
-#endif
34c786
 #ifdef HAVE_OVIRT
34c786
     OvirtForeignMenu *ovirt_foreign_menu;
34c786
 #endif
34c786
@@ -82,33 +77,15 @@ static OvirtVm * choose_vm(GtkWindow *main_window,
34c786
 #endif
34c786
 
34c786
 static gboolean remote_viewer_start(VirtViewerApp *self, GError **error);
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
34c786
-static void remote_viewer_window_added(GtkApplication *app, GtkWindow *w);
34c786
-static void spice_foreign_menu_updated(RemoteViewer *self);
34c786
-static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, GParamSpec *pspec, RemoteViewer *self);
34c786
-#endif
34c786
 
34c786
 static void
34c786
 remote_viewer_dispose (GObject *object)
34c786
 {
34c786
-#if defined(HAVE_SPICE_GTK) || defined(HAVE_OVIRT)
34c786
+#if defined(HAVE_OVIRT)
34c786
     RemoteViewer *self = REMOTE_VIEWER(object);
34c786
     RemoteViewerPrivate *priv = self->priv;
34c786
 #endif
34c786
 
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-    if (priv->controller) {
34c786
-        g_object_unref(priv->controller);
34c786
-        priv->controller = NULL;
34c786
-    }
34c786
-
34c786
-    if (priv->ctrl_foreign_menu) {
34c786
-        g_object_unref(priv->ctrl_foreign_menu);
34c786
-        priv->ctrl_foreign_menu = NULL;
34c786
-    }
34c786
-#endif
34c786
-
34c786
 #ifdef HAVE_OVIRT
34c786
     if (priv->ovirt_foreign_menu) {
34c786
         g_object_unref(priv->ovirt_foreign_menu);
34c786
@@ -136,7 +113,6 @@ remote_viewer_deactivated(VirtViewerApp *app, gboolean connect_error)
34c786
 
34c786
 static gchar **opt_args = NULL;
34c786
 static char *opt_title = NULL;
34c786
-static gboolean opt_controller = FALSE;
34c786
 
34c786
 static void
34c786
 remote_viewer_add_option_entries(VirtViewerApp *self, GOptionContext *context, GOptionGroup *group)
34c786
@@ -144,10 +120,6 @@ remote_viewer_add_option_entries(VirtViewerApp *self, GOptionContext *context, G
34c786
     static const GOptionEntry options[] = {
34c786
         { "title", 't', 0, G_OPTION_ARG_STRING, &opt_title,
34c786
           N_("Set window title"), NULL },
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-        { "spice-controller", '\0', 0, G_OPTION_ARG_NONE, &opt_controller,
34c786
-          N_("Open connection using Spice controller communication"), NULL },
34c786
-#endif
34c786
         { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &opt_args,
34c786
           NULL, "URI|VV-FILE" },
34c786
         { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
34c786
@@ -188,27 +160,7 @@ remote_viewer_local_command_line (GApplication   *gapp,
34c786
         g_object_set(app, "guri", opt_args[0], NULL);
34c786
     }
34c786
 
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-    if (opt_controller) {
34c786
-        if (opt_args) {
34c786
-            g_printerr(_("\nError: extra arguments given while using Spice controller\n\n"));
34c786
-            ret = TRUE;
34c786
-            *status = 1;
34c786
-            goto end;
34c786
-        }
34c786
-
34c786
-        self->priv->controller = spice_ctrl_controller_new();
34c786
-        self->priv->ctrl_foreign_menu = spice_ctrl_foreign_menu_new();
34c786
-
34c786
-        g_object_set(self, "guest-name", "defined by Spice controller", NULL);
34c786
-
34c786
-        g_signal_connect(self->priv->ctrl_foreign_menu, "notify::title",
34c786
-                         G_CALLBACK(foreign_menu_title_changed),
34c786
-                         self);
34c786
-    }
34c786
-#endif
34c786
-
34c786
-    if (opt_title && !opt_controller)
34c786
+    if (opt_title)
34c786
         g_object_set(app, "title", opt_title, NULL);
34c786
 
34c786
 end:
34c786
@@ -245,7 +197,6 @@ static void
34c786
 remote_viewer_class_init (RemoteViewerClass *klass)
34c786
 {
34c786
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
34c786
-    GtkApplicationClass *gtk_app_class = GTK_APPLICATION_CLASS(klass);
34c786
     VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
34c786
     GApplicationClass *g_app_class = G_APPLICATION_CLASS(klass);
34c786
 
34c786
@@ -259,12 +210,6 @@ remote_viewer_class_init (RemoteViewerClass *klass)
34c786
     app_class->start = remote_viewer_start;
34c786
     app_class->deactivated = remote_viewer_deactivated;
34c786
     app_class->add_option_entries = remote_viewer_add_option_entries;
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-    app_class->activate = remote_viewer_activate;
34c786
-    gtk_app_class->window_added = remote_viewer_window_added;
34c786
-#else
34c786
-    (void) gtk_app_class;
34c786
-#endif
34c786
 
34c786
 #ifdef HAVE_OVIRT
34c786
     g_object_class_install_property(object_class,
34c786
@@ -292,217 +237,7 @@ remote_viewer_new(void)
34c786
                         NULL);
34c786
 }
34c786
 
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-static void
34c786
-foreign_menu_title_changed(SpiceCtrlForeignMenu *menu G_GNUC_UNUSED,
34c786
-                           GParamSpec *pspec G_GNUC_UNUSED,
34c786
-                           RemoteViewer *self)
34c786
-{
34c786
-    gboolean has_focus;
34c786
-
34c786
-    g_object_get(G_OBJECT(self), "has-focus", &has_focus, NULL);
34c786
-    /* FIXME: use a proper "new client connected" event
34c786
-    ** a foreign menu client set the title when connecting,
34c786
-    ** inform of focus state at that time.
34c786
-    */
34c786
-    spice_ctrl_foreign_menu_app_activated_msg(self->priv->ctrl_foreign_menu, has_focus);
34c786
-
34c786
-    /* update menu title */
34c786
-    spice_foreign_menu_updated(self);
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_do_connect(SpiceCtrlController *ctrl G_GNUC_UNUSED,
34c786
-                      VirtViewerApp *self)
34c786
-{
34c786
-    GError *error = NULL;
34c786
-
34c786
-    if (!virt_viewer_app_initial_connect(self, &error)) {
34c786
-        const gchar *msg = error ? error->message :
34c786
-            _("Failed to initiate connection");
34c786
-        virt_viewer_app_simple_message_dialog(self, msg);
34c786
-        g_clear_error(&error);
34c786
-    }
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_show(SpiceCtrlController *ctrl G_GNUC_UNUSED, RemoteViewer *self)
34c786
-{
34c786
-    virt_viewer_app_show_display(VIRT_VIEWER_APP(self));
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_hide(SpiceCtrlController *ctrl G_GNUC_UNUSED, RemoteViewer *self)
34c786
-{
34c786
-    virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Display disabled by controller"));
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_menuitem_activate_cb(GtkMenuItem *mi, GObject *ctrl)
34c786
-{
34c786
-    SpiceCtrlMenuItem *menuitem = g_object_get_data(G_OBJECT(mi), "spice-menuitem");
34c786
-
34c786
-    g_return_if_fail(menuitem != NULL);
34c786
-    if (gtk_menu_item_get_submenu(mi))
34c786
-        return;
34c786
-
34c786
-    if (SPICE_CTRL_IS_CONTROLLER(ctrl))
34c786
-        spice_ctrl_controller_menu_item_click_msg(SPICE_CTRL_CONTROLLER(ctrl), menuitem->id);
34c786
-    else if (SPICE_CTRL_IS_FOREIGN_MENU(ctrl))
34c786
-        spice_ctrl_foreign_menu_menu_item_click_msg(SPICE_CTRL_FOREIGN_MENU(ctrl), menuitem->id);
34c786
-}
34c786
-
34c786
-static GtkWidget *
34c786
-ctrlmenu_to_gtkmenu (RemoteViewer *self, SpiceCtrlMenu *ctrlmenu, GObject *ctrl)
34c786
-{
34c786
-    GList *l;
34c786
-    GtkWidget *menu = gtk_menu_new();
34c786
-    guint n = 0;
34c786
-
34c786
-    for (l = ctrlmenu->items; l != NULL; l = l->next) {
34c786
-        SpiceCtrlMenuItem *menuitem = l->data;
34c786
-        GtkWidget *item;
34c786
-        char *s;
34c786
-        if (menuitem->text == NULL) {
34c786
-            g_warn_if_reached();
34c786
-            continue;
34c786
-        }
34c786
-
34c786
-        for (s = menuitem->text; *s; s++)
34c786
-            if (*s == '&')
34c786
-                *s = '_';
34c786
-
34c786
-        if (g_str_equal(menuitem->text, "-")) {
34c786
-            item = gtk_separator_menu_item_new();
34c786
-        } else if (menuitem->flags & CONTROLLER_MENU_FLAGS_CHECKED) {
34c786
-            item = gtk_check_menu_item_new_with_mnemonic(menuitem->text);
34c786
-            g_object_set(item, "active", TRUE, NULL);
34c786
-        } else {
34c786
-            item = gtk_menu_item_new_with_mnemonic(menuitem->text);
34c786
-        }
34c786
-
34c786
-        if (menuitem->flags & (CONTROLLER_MENU_FLAGS_GRAYED | CONTROLLER_MENU_FLAGS_DISABLED))
34c786
-            gtk_widget_set_sensitive(item, FALSE);
34c786
-
34c786
-        g_object_set_data_full(G_OBJECT(item), "spice-menuitem",
34c786
-                               g_object_ref(menuitem), g_object_unref);
34c786
-        g_signal_connect(item, "activate", G_CALLBACK(spice_menuitem_activate_cb), ctrl);
34c786
-        gtk_menu_attach(GTK_MENU (menu), item, 0, 1, n, n + 1);
34c786
-        n += 1;
34c786
-
34c786
-        if (menuitem->submenu) {
34c786
-            gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
34c786
-                                      ctrlmenu_to_gtkmenu(self, menuitem->submenu, ctrl));
34c786
-        }
34c786
-    }
34c786
-
34c786
-    if (n == 0) {
34c786
-        g_object_ref_sink(menu);
34c786
-        g_object_unref(menu);
34c786
-        menu = NULL;
34c786
-    }
34c786
-
34c786
-    gtk_widget_show_all(menu);
34c786
-    return menu;
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_menu_update(RemoteViewer *self, VirtViewerWindow *win)
34c786
-{
34c786
-    GtkWidget *menuitem = g_object_get_data(G_OBJECT(win), "spice-menu");
34c786
-    SpiceCtrlMenu *menu;
34c786
-
34c786
-    if (self->priv->controller == NULL)
34c786
-        return;
34c786
-
34c786
-    if (menuitem != NULL)
34c786
-        gtk_widget_destroy(menuitem);
34c786
-
34c786
-    {
34c786
-        GtkMenuShell *shell = GTK_MENU_SHELL(gtk_builder_get_object(virt_viewer_window_get_builder(win), "top-menu"));
34c786
-        menuitem = gtk_menu_item_new_with_label("Spice");
34c786
-        gtk_menu_shell_append(shell, menuitem);
34c786
-        g_object_set_data(G_OBJECT(win), "spice-menu", menuitem);
34c786
-    }
34c786
-
34c786
-    g_object_get(self->priv->controller, "menu", &menu, NULL);
34c786
-    if (menu == NULL || g_list_length(menu->items) == 0) {
34c786
-        gtk_widget_set_visible(menuitem, FALSE);
34c786
-    } else {
34c786
-        gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
34c786
-            ctrlmenu_to_gtkmenu(self, menu, G_OBJECT(self->priv->controller)));
34c786
-        gtk_widget_set_visible(menuitem, TRUE);
34c786
-    }
34c786
-
34c786
-    if (menu != NULL)
34c786
-        g_object_unref(menu);
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_menu_update_each(gpointer value,
34c786
-                       gpointer user_data)
34c786
-{
34c786
-    spice_menu_update(REMOTE_VIEWER(user_data), VIRT_VIEWER_WINDOW(value));
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_menu_updated(RemoteViewer *self)
34c786
-{
34c786
-    GList *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
34c786
-
34c786
-    g_debug("Spice controller menu updated");
34c786
-
34c786
-    g_list_foreach(windows, spice_menu_update_each, self);
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_foreign_menu_update(RemoteViewer *self, VirtViewerWindow *win)
34c786
-{
34c786
-    GtkWidget *menuitem = g_object_get_data(G_OBJECT(win), "foreign-menu");
34c786
-    SpiceCtrlMenu *menu;
34c786
-
34c786
-    if (self->priv->ctrl_foreign_menu == NULL)
34c786
-        return;
34c786
-
34c786
-    if (menuitem != NULL)
34c786
-        gtk_widget_destroy(menuitem);
34c786
-
34c786
-    {
34c786
-        GtkMenuShell *shell = GTK_MENU_SHELL(gtk_builder_get_object(virt_viewer_window_get_builder(win), "top-menu"));
34c786
-        const gchar *title = spice_ctrl_foreign_menu_get_title(self->priv->ctrl_foreign_menu);
34c786
-        menuitem = gtk_menu_item_new_with_label(title);
34c786
-        gtk_menu_shell_append(shell, menuitem);
34c786
-        g_object_set_data(G_OBJECT(win), "foreign-menu", menuitem);
34c786
-    }
34c786
-
34c786
-    g_object_get(self->priv->ctrl_foreign_menu, "menu", &menu, NULL);
34c786
-    if (menu == NULL || g_list_length(menu->items) == 0) {
34c786
-        gtk_widget_set_visible(menuitem, FALSE);
34c786
-    } else {
34c786
-        gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
34c786
-            ctrlmenu_to_gtkmenu(self, menu, G_OBJECT(self->priv->ctrl_foreign_menu)));
34c786
-        gtk_widget_set_visible(menuitem, TRUE);
34c786
-    }
34c786
-    g_object_unref(menu);
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_foreign_menu_update_each(gpointer value,
34c786
-                               gpointer user_data)
34c786
-{
34c786
-    spice_foreign_menu_update(REMOTE_VIEWER(user_data), VIRT_VIEWER_WINDOW(value));
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_foreign_menu_updated(RemoteViewer *self)
34c786
-{
34c786
-    GList *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
34c786
-
34c786
-    g_debug("Spice foreign menu updated");
34c786
-
34c786
-    g_list_foreach(windows, spice_foreign_menu_update_each, self);
34c786
-}
34c786
-
34c786
+#if defined(HAVE_SPICE_GTK) && defined(HAVE_OVIRT)
34c786
 static SpiceSession *
34c786
 remote_viewer_get_spice_session(RemoteViewer *self)
34c786
 {
34c786
@@ -518,158 +253,6 @@ remote_viewer_get_spice_session(RemoteViewer *self)
34c786
 
34c786
     return session;
34c786
 }
34c786
-
34c786
-static void
34c786
-app_notified(VirtViewerApp *app,
34c786
-             GParamSpec *pspec,
34c786
-             RemoteViewer *self)
34c786
-{
34c786
-    GValue value = G_VALUE_INIT;
34c786
-
34c786
-    g_value_init(&value, pspec->value_type);
34c786
-    g_object_get_property(G_OBJECT(app), pspec->name, &value);
34c786
-
34c786
-    if (g_str_equal(pspec->name, "has-focus")) {
34c786
-        if (self->priv->ctrl_foreign_menu)
34c786
-            spice_ctrl_foreign_menu_app_activated_msg(self->priv->ctrl_foreign_menu, g_value_get_boolean(&value));
34c786
-    }
34c786
-
34c786
-    g_value_unset(&value);
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_notified(SpiceCtrlController *ctrl,
34c786
-                    GParamSpec *pspec,
34c786
-                    RemoteViewer *self)
34c786
-{
34c786
-    SpiceSession *session = remote_viewer_get_spice_session(self);
34c786
-    GValue value = G_VALUE_INIT;
34c786
-    VirtViewerApp *app = VIRT_VIEWER_APP(self);
34c786
-
34c786
-    g_return_if_fail(session != NULL);
34c786
-
34c786
-    g_value_init(&value, pspec->value_type);
34c786
-    g_object_get_property(G_OBJECT(ctrl), pspec->name, &value);
34c786
-
34c786
-    if (g_str_equal(pspec->name, "host") ||
34c786
-        g_str_equal(pspec->name, "port") ||
34c786
-        g_str_equal(pspec->name, "password") ||
34c786
-        g_str_equal(pspec->name, "ca-file") ||
34c786
-        g_str_equal(pspec->name, "enable-smartcard") ||
34c786
-        g_str_equal(pspec->name, "color-depth") ||
34c786
-        g_str_equal(pspec->name, "disable-effects") ||
34c786
-        g_str_equal(pspec->name, "enable-usbredir") ||
34c786
-        g_str_equal(pspec->name, "secure-channels") ||
34c786
-        g_str_equal(pspec->name, "proxy")) {
34c786
-        g_object_set_property(G_OBJECT(session), pspec->name, &value);
34c786
-    } else if (g_str_equal(pspec->name, "sport")) {
34c786
-        g_object_set_property(G_OBJECT(session), "tls-port", &value);
34c786
-    } else if (g_str_equal(pspec->name, "tls-ciphers")) {
34c786
-        g_object_set_property(G_OBJECT(session), "ciphers", &value);
34c786
-    } else if (g_str_equal(pspec->name, "host-subject")) {
34c786
-        g_object_set_property(G_OBJECT(session), "cert-subject", &value);
34c786
-    } else if (g_str_equal(pspec->name, "enable-usb-autoshare")) {
34c786
-        VirtViewerSession *vsession = NULL;
34c786
-
34c786
-        g_object_get(self, "session", &vsession, NULL);
34c786
-        g_object_set_property(G_OBJECT(vsession), "auto-usbredir", &value);
34c786
-        g_object_unref(G_OBJECT(vsession));
34c786
-    } else if (g_str_equal(pspec->name, "usb-filter")) {
34c786
-        SpiceUsbDeviceManager *manager;
34c786
-        manager = spice_usb_device_manager_get(session, NULL);
34c786
-        if (manager != NULL) {
34c786
-            g_object_set_property(G_OBJECT(manager),
34c786
-                                  "auto-connect-filter",
34c786
-                                  &value);
34c786
-        }
34c786
-    } else if (g_str_equal(pspec->name, "title")) {
34c786
-        g_object_set(app, "title", g_value_get_string(&value), NULL);
34c786
-    } else if (g_str_equal(pspec->name, "display-flags")) {
34c786
-        guint flags = g_value_get_uint(&value);
34c786
-        gboolean fullscreen = !!(flags & CONTROLLER_SET_FULL_SCREEN);
34c786
-        g_object_set(G_OBJECT(self), "fullscreen", fullscreen, NULL);
34c786
-    } else if (g_str_equal(pspec->name, "menu")) {
34c786
-        spice_ctrl_menu_updated(self);
34c786
-    } else if (g_str_equal(pspec->name, "hotkeys")) {
34c786
-        virt_viewer_app_set_hotkeys(app, g_value_get_string(&value));
34c786
-    } else {
34c786
-        gchar *content = g_strdup_value_contents(&value);
34c786
-
34c786
-        g_debug("unimplemented property: %s=%s", pspec->name, content);
34c786
-        g_free(content);
34c786
-    }
34c786
-
34c786
-    g_object_unref(session);
34c786
-    g_value_unset(&value);
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_foreign_menu_notified(SpiceCtrlForeignMenu *ctrl_foreign_menu G_GNUC_UNUSED,
34c786
-                                 GParamSpec *pspec,
34c786
-                                 RemoteViewer *self)
34c786
-{
34c786
-    if (g_str_equal(pspec->name, "menu")) {
34c786
-        spice_foreign_menu_updated(self);
34c786
-    }
34c786
-}
34c786
-
34c786
-static void
34c786
-spice_ctrl_listen_async_cb(GObject *object,
34c786
-                           GAsyncResult *res,
34c786
-                           gpointer user_data)
34c786
-{
34c786
-    GError *error = NULL;
34c786
-    VirtViewerApp *app = VIRT_VIEWER_APP(user_data);
34c786
-
34c786
-    if (SPICE_CTRL_IS_CONTROLLER(object))
34c786
-        spice_ctrl_controller_listen_finish(SPICE_CTRL_CONTROLLER(object), res, &error);
34c786
-    else if (SPICE_CTRL_IS_FOREIGN_MENU(object)) {
34c786
-        spice_ctrl_foreign_menu_listen_finish(SPICE_CTRL_FOREIGN_MENU(object), res, &error);
34c786
-    } else
34c786
-        g_warn_if_reached();
34c786
-
34c786
-    if (error != NULL) {
34c786
-        virt_viewer_app_simple_message_dialog(app,
34c786
-                                              _("Controller connection failed: %s"),
34c786
-                                              error->message);
34c786
-        g_clear_error(&error);
34c786
-        exit(EXIT_FAILURE); /* TODO: make start async? */
34c786
-    }
34c786
-}
34c786
-
34c786
-
34c786
-static gboolean
34c786
-remote_viewer_activate(VirtViewerApp *app, GError **error)
34c786
-{
34c786
-    RemoteViewer *self;
34c786
-    gboolean ret = FALSE;
34c786
-
34c786
-    g_return_val_if_fail(REMOTE_VIEWER_IS(app), FALSE);
34c786
-
34c786
-    self = REMOTE_VIEWER(app);
34c786
-
34c786
-    if (self->priv->controller) {
34c786
-        SpiceSession *session = remote_viewer_get_spice_session(self);
34c786
-        ret = spice_session_connect(session);
34c786
-        g_object_unref(session);
34c786
-    } else {
34c786
-        ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->activate(app, error);
34c786
-    }
34c786
-
34c786
-    return ret;
34c786
-}
34c786
-
34c786
-static void
34c786
-remote_viewer_window_added(GtkApplication *app,
34c786
-                           GtkWindow *w)
34c786
-{
34c786
-    VirtViewerWindow *win = VIRT_VIEWER_WINDOW(
34c786
-                                g_object_get_data(G_OBJECT(w), "virt-viewer-window"));
34c786
-    spice_menu_update(REMOTE_VIEWER(app), win);
34c786
-    spice_foreign_menu_update(REMOTE_VIEWER(app), win);
34c786
-
34c786
-    GTK_APPLICATION_CLASS(remote_viewer_parent_class)->window_added(app, w);
34c786
-}
34c786
 #endif
34c786
 
34c786
 #ifdef HAVE_OVIRT
34c786
@@ -1101,29 +684,8 @@ remote_viewer_start(VirtViewerApp *app, GError **err)
34c786
     gchar *type = NULL;
34c786
     GError *error = NULL;
34c786
 
34c786
-#ifdef HAVE_SPICE_GTK
34c786
-    g_signal_connect(app, "notify", G_CALLBACK(app_notified), self);
34c786
-
34c786
-    if (priv->controller) {
34c786
-        if (!virt_viewer_app_create_session(app, "spice", &error)) {
34c786
-            g_debug("Couldn't create a Spice session");
34c786
-            goto cleanup;
34c786
-        }
34c786
-
34c786
-        g_signal_connect(priv->controller, "notify", G_CALLBACK(spice_ctrl_notified), self);
34c786
-        g_signal_connect(priv->controller, "do_connect", G_CALLBACK(spice_ctrl_do_connect), self);
34c786
-        g_signal_connect(priv->controller, "show", G_CALLBACK(spice_ctrl_show), self);
34c786
-        g_signal_connect(priv->controller, "hide", G_CALLBACK(spice_ctrl_hide), self);
34c786
-
34c786
-        spice_ctrl_controller_listen(priv->controller, NULL, spice_ctrl_listen_async_cb, self);
34c786
-
34c786
-        g_signal_connect(priv->ctrl_foreign_menu, "notify", G_CALLBACK(spice_ctrl_foreign_menu_notified), self);
34c786
-        spice_ctrl_foreign_menu_listen(priv->ctrl_foreign_menu, NULL, spice_ctrl_listen_async_cb, self);
34c786
-
34c786
-        virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Setting up Spice session..."));
34c786
-    } else {
34c786
-#endif
34c786
 retry_dialog:
34c786
+    {
34c786
         if (priv->open_recent_dialog) {
34c786
             VirtViewerWindow *main_window = virt_viewer_app_get_main_window(app);
34c786
             if (!remote_viewer_connect_dialog(virt_viewer_window_get_window(main_window), &guri)) {
34c786
@@ -1193,9 +755,7 @@ retry_dialog:
34c786
             }
34c786
             goto cleanup;
34c786
         }
34c786
-#ifdef HAVE_SPICE_GTK
34c786
     }
34c786
-#endif
34c786
 
34c786
     ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, &error);
34c786
 
34c786
-- 
34c786
2.17.1
34c786