Add support for SPICE.
[virt-click.git] / main.c
diff --git a/main.c b/main.c
index 1f98c77..04c1290 100644 (file)
--- a/main.c
+++ b/main.c
@@ -49,7 +49,6 @@ main (int argc, char **argv)
   GOptionContext *context;
   GError *error = NULL;
   gboolean version = 0;
-  gchar *vnc = NULL;
   gchar **args = NULL;
   guint nr_args;
   const GOptionEntry options [] = {
@@ -57,8 +56,6 @@ main (int argc, char **argv)
       &verbose, "Enables verbose output", NULL },
     { "version", 'V', 0,  G_OPTION_ARG_NONE,
       &version, "Display version and exit", NULL },
-    { "vnc", 0, 0,  G_OPTION_ARG_STRING,
-      &vnc, "Connect to VNC server directly", NULL },
     { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
       NULL, "(click|...) [args...]" },
     { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
@@ -80,6 +77,8 @@ main (int argc, char **argv)
      "    click x y [b]                   Mouse click at (x, y), with button b"
      );
   g_option_context_add_main_entries (context, options, NULL);
+  g_option_context_add_group (context, vc_vnc_cmdline_get_option_group ());
+  g_option_context_add_group (context, vc_spice_cmdline_get_option_group ());
   g_option_context_parse (context, &argc, &argv, &error);
   if (error) {
     short_usage (argv[0], error->message);
@@ -108,8 +107,11 @@ main (int argc, char **argv)
   }
 
   /* Create VNC/SPICE/... object. */
-  if (vnc)
-    vc_vnc_setup (self, vnc);
+  if (vc_vnc_is_selected ())
+    vc_vnc_setup (self);
+  else if (vc_spice_is_selected ()) {
+    vc_spice_setup (self);
+  }
   else {
     short_usage (argv[0], "no --vnc or --spice option");
     exit (EXIT_FAILURE);