<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 27, 2017 at 1:54 PM Frediano Ziglio <<a href="mailto:fziglio@redhat.com">fziglio@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">><br>
> Hi,<br>
><br>
> On Wed, Sep 27, 2017 at 10:33:33AM +0000, Frediano Ziglio wrote:<br>
> > ><br>
> > > From: Victor Toso <<a href="mailto:me@victortoso.com" target="_blank">me@victortoso.com</a>><br>
> > ><br>
> > > As we already depend on glib, let's remove code that glib can take<br>
> > > care of. In this case, we don't need to handle commandline parsing<br>
> > > ourselves.<br>
> > ><br>
> > > In regard the global variables:<br>
> > ><br>
> > > * static const char * -> static gchar * [only paths]<br>
> > >Â Â path variables: portdev, fx_dir, vdagentd_socket<br>
> > ><br>
> > > * static int -> static gboolean<br>
> > >Â Â flags: debug, do_daemonize, x11_sync, fx_open_dir<br>
> > ><br>
> > > Since fx_open_dir is gboolean, the dir is by default not opened,<br>
> > > using option "-o" forces it to open.<br>
> > ><br>
> ><br>
> > This -o change breaks compatibility with former versions.<br>
><br>
> Well, it was -o 0|1 which is basically boolean too. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Another mention-before-release or do you think we need to keep it?<br>
><br>
<br>
As any deprecation one release announcement, 2 removal.<br>
I would avoid adding the long option (--file-xfer-open-dir) with 0/1,<br>
keep the argument for "-o" only and then remove the "-o" as deprecated.<br>
<br></blockquote><div>Agreed, I'll add the optional argument 0|1 back and use the short version "-o" only.</div><div><br></div><div>Jakub</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> ><br>
> > > Signed-off-by: Victor Toso <<a href="mailto:victortoso@redhat.com" target="_blank">victortoso@redhat.com</a>><br>
> > > ---<br>
> > >Â src/vdagent/vdagent.c | 122<br>
> > >Â +++++++++++++++++++++++++-------------------------<br>
> > >Â 1 file changed, 62 insertions(+), 60 deletions(-)<br>
> > ><br>
> > > diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c<br>
> > > index cc4dac1..51a7618 100644<br>
> > > --- a/src/vdagent/vdagent.c<br>
> > > +++ b/src/vdagent/vdagent.c<br>
> > > @@ -44,17 +44,46 @@<br>
> > >Â #include "x11.h"<br>
> > >Â #include "file-xfers.h"<br>
> > ><br>
> > > -static const char *portdev = DEFAULT_VIRTIO_PORT_PATH;<br>
> > > -static const char *vdagentd_socket = VDAGENTD_SOCKET;<br>
> > > -static int debug = 0;<br>
> > > -static const char *fx_dir = NULL;<br>
> > > -static int fx_open_dir = -1;<br>
> > >Â static struct vdagent_x11 *x11 = NULL;<br>
> > >Â static struct vdagent_file_xfers *vdagent_file_xfers = NULL;<br>
> > >Â static struct udscs_connection *client = NULL;<br>
> > >Â static int quit = 0;<br>
> > >Â static int version_mismatch = 0;<br>
> > ><br>
> > > +/* Command line options */<br>
> > > +static gboolean debug = FALSE;<br>
> > > +static gboolean x11_sync = FALSE;<br>
> > > +static gboolean fx_open_dir = FALSE;<br>
> > > +static gboolean do_daemonize = TRUE;<br>
> > > +static gchar *fx_dir = NULL;<br>
> > > +static gchar *portdev = NULL;<br>
> > > +static gchar *vdagentd_socket = NULL;<br>
> > > +<br>
> > > +static GOptionEntry entries[] = {<br>
> > > +Â Â { "debug", 'd', 0,<br>
> > > +Â Â Â Â G_OPTION_ARG_NONE, &debug,<br>
> > > +Â Â Â Â "Enable debug", NULL },<br>
> > > +Â Â { "virtio-serial-port-path", 's', 0,<br>
> > > +Â Â Â G_OPTION_ARG_STRING, &portdev,<br>
> > > +Â Â Â "Set virtio-serial path ("Â DEFAULT_VIRTIO_PORT_PATH ")", NULL },<br>
> > > +Â Â { "vdagentd-socket", 'S', 0, G_OPTION_ARG_STRING,<br>
> > > +Â Â Â Â &vdagentd_socket,<br>
> > > +Â Â Â Â "Set spice-vdagentd socket (" VDAGENTD_SOCKET ")", NULL },<br>
> > > +Â Â { "foreground", 'x', G_OPTION_FLAG_REVERSE,<br>
> > > +Â Â Â Â G_OPTION_ARG_NONE, &do_daemonize,<br>
> > > +Â Â Â Â "Do not daemonize the agent", NULL },<br>
> > > +Â Â { "file-xfer-save-dir", 'f', 0,<br>
> > > +Â Â Â G_OPTION_ARG_STRING, &fx_dir,<br>
> > > +Â Â Â "Set directory to file transfers files", NULL},<br>
> > > +Â Â { "file-xfer-open-dir", 'o', 0,<br>
> > > +Â Â Â Â G_OPTION_ARG_NONE, &fx_open_dir,<br>
> > > +Â Â Â Â "Open directory after completing file transfer", NULL },<br>
> > > +Â Â { "x11-abort-on-error", 'y', 0,<br>
> > > +Â Â Â G_OPTION_ARG_NONE, &x11_sync,<br>
> > > +Â Â Â "Aborts on errors from X11", NULL },<br>
> > > +Â Â { NULL }<br>
> > > +};<br>
> > > +<br>
> > >Â /**<br>
> > >Â Â * xfer_get_download_directory<br>
> > >Â Â *<br>
> > > @@ -96,9 +125,6 @@ static gboolean vdagent_init_file_xfer(void)<br>
> > >Â Â Â Â Â return FALSE;<br>
> > >Â Â Â }<br>
> > ><br>
> > > -Â Â if (fx_open_dir == -1)<br>
> > > -Â Â Â Â fx_open_dir = !vdagent_x11_has_icons_on_desktop(x11);<br>
> > > -<br>
> > >Â Â Â vdagent_file_xfers = vdagent_file_xfers_create(client, xfer_dir,<br>
> > >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fx_open_dir, debug);<br>
> > >Â Â Â return (vdagent_file_xfers != NULL);<br>
> > > @@ -210,22 +236,6 @@ static int client_setup(int reconnect)<br>
> > >Â Â Â return client == NULL;<br>
> > >Â }<br>
> > ><br>
> > > -static void usage(FILE *fp)<br>
> > > -{<br>
> > > -Â Â fprintf(fp,<br>
> > > -Â Â Â "Usage: spice-vdagent [OPTIONS]\n\n"<br>
> > > -Â Â Â "Spice guest agent X11 session agent, version %s.\n\n"<br>
> > > -Â Â Â "Options:\n"<br>
> > > -   " -h                print this text\n"<br>
> > > -   " -d                log debug messages\n"<br>
> > > -Â Â Â "Â -s <port>Â Â Â Â Â Â Â Â Â Â Â Â Â set virtio serial port\n"<br>
> > > -Â Â Â "Â -S <filename>Â Â Â Â Â Â Â Â Â Â Â set udcs socket\n"<br>
> > > -   " -x                don't daemonize\n"<br>
> > > -Â Â Â "Â -f <dir>Â Â Â Â Â Â Â Â Â Â Â Â Â file xfer save dir\n"<br>
> > > -Â Â Â "Â -o <0|1>Â Â Â Â Â Â Â Â Â Â Â Â Â open dir on file xfer<br>
> > > completion\n",<br>
> > > -Â Â Â VERSION);<br>
> > > -}<br>
> > > -<br>
> > >Â static void quit_handler(int sig)<br>
> > >Â {<br>
> > >Â Â Â quit = 1;<br>
> > > @@ -289,45 +299,33 @@ static int file_test(const char *path)<br>
> > >Â int main(int argc, char *argv[])<br>
> > >Â {<br>
> > >Â Â Â fd_set readfds, writefds;<br>
> > > -Â Â int c, n, nfds, x11_fd;<br>
> > > -Â Â int do_daemonize = 1;<br>
> > > +Â Â int n, nfds, x11_fd;<br>
> > >Â Â Â int parent_socket = 0;<br>
> > > -Â Â int x11_sync = 0;<br>
> > >Â Â Â struct sigaction act;<br>
> > > +Â Â GOptionContext *context;<br>
> > > +Â Â GError *error = NULL;<br>
> > > +<br>
> > > +Â Â context = g_option_context_new(NULL);<br>
> > > +Â Â g_option_context_add_main_entries(context, entries, NULL);<br>
> > > +Â Â g_option_context_set_summary(context,<br>
> > > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "\tSpice session guest agent: X11\n"<br>
> > > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "\tVersion: " VERSION);<br>
> > > +Â Â g_option_context_parse(context, &argc, &argv, &error);<br>
> > > +Â Â g_option_context_free(context);<br>
> > > +<br>
> > > +Â Â if (error != NULL) {<br>
> > > +Â Â Â Â g_printerr("Invalid arguments, %s\n", error->message);<br>
> > > +Â Â Â Â g_clear_error(&error);<br>
> > > +Â Â Â Â return -1;<br>
> > > +Â Â }<br>
> > ><br>
> > > -Â Â for (;;) {<br>
> > > -Â Â Â Â if (-1 == (c = getopt(argc, argv, "-dxhys:f:o:S:")))<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â switch (c) {<br>
> > > -Â Â Â Â case 'd':<br>
> > > -Â Â Â Â Â Â debug++;<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â case 's':<br>
> > > -Â Â Â Â Â Â portdev = optarg;<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â case 'x':<br>
> > > -Â Â Â Â Â Â do_daemonize = 0;<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â case 'y':<br>
> > > -Â Â Â Â Â Â x11_sync = 1;<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â case 'h':<br>
> > > -Â Â Â Â Â Â usage(stdout);<br>
> > > -Â Â Â Â Â Â return 0;<br>
> > > -Â Â Â Â case 'f':<br>
> > > -Â Â Â Â Â Â fx_dir = optarg;<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â case 'o':<br>
> > > -Â Â Â Â Â Â fx_open_dir = atoi(optarg);<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â case 'S':<br>
> > > -Â Â Â Â Â Â vdagentd_socket = optarg;<br>
> > > -Â Â Â Â Â Â break;<br>
> > > -Â Â Â Â default:<br>
> > > -Â Â Â Â Â Â fputs("\n", stderr);<br>
> > > -Â Â Â Â Â Â usage(stderr);<br>
> > > -Â Â Â Â Â Â return 1;<br>
> > > -Â Â Â Â }<br>
> > > +Â Â /* Set default path value if none was set */<br>
> > > +Â Â if (portdev == NULL) {<br>
> > > +Â Â Â Â portdev = g_strdup(DEFAULT_VIRTIO_PORT_PATH);<br>
> > > +Â Â }<br>
> > > +<br>
> > > +Â Â if (vdagentd_socket == NULL) {<br>
> > > +Â Â Â Â vdagentd_socket = g_strdup(VDAGENTD_SOCKET);<br>
> > >Â Â Â }<br>
> > ><br>
> > >Â Â Â memset(&act, 0, sizeof(act));<br>
> > > @@ -405,5 +403,9 @@ reconnect:<br>
> > >Â Â Â if (!quit && do_daemonize)<br>
> > >Â Â Â Â Â goto reconnect;<br>
> > ><br>
> > > +Â Â g_free(fx_dir);<br>
> > > +Â Â g_free(portdev);<br>
> > > +Â Â g_free(vdagentd_socket);<br>
> > > +<br>
> > >Â Â Â return 0;<br>
> > >Â }<br>
> ><br>
> > Frediano<br>
<br>
</blockquote></div></div>