Trim trailing white spaces.
[geeqie.git] / src / remote.c
index ebfa8b9..b5f47eb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
 #include "remote.h"
 
 #include "collect.h"
-#include "debug.h"
 #include "filedata.h"
 #include "img-view.h"
 #include "layout.h"
 #include "layout_image.h"
+#include "misc.h"
 #include "slideshow.h"
 #include "ui_fileops.h"
+#include "rcfile.h"
 
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <signal.h>
@@ -47,7 +47,7 @@ static gint remote_client_send(RemoteConnection *rc, const gchar *text);
 typedef struct _RemoteClient RemoteClient;
 struct _RemoteClient {
        gint fd;
-       gint channel_id;
+       guint channel_id; /* event source id */
        RemoteConnection *rc;
 };
 
@@ -61,18 +61,17 @@ static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition conditi
 {
        RemoteClient *client = data;
        RemoteConnection *rc;
+       GIOStatus status = G_IO_STATUS_NORMAL;
 
        rc = client->rc;
 
        if (condition & G_IO_IN)
                {
-               GList *queue = NULL;
-               GList *work;
                gchar *buffer = NULL;
                GError *error = NULL;
-               guint termpos;
+               gsize termpos;
 
-               while (g_io_channel_read_line(source, &buffer, NULL, &termpos, &error) == G_IO_STATUS_NORMAL)
+               while ((status = g_io_channel_read_line(source, &buffer, NULL, &termpos, &error)) == G_IO_STATUS_NORMAL)
                        {
                        if (buffer)
                                {
@@ -80,12 +79,11 @@ static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition conditi
 
                                if (strlen(buffer) > 0)
                                        {
-                                       queue = g_list_append(queue, buffer);
-                                       }
-                               else
-                                       {
-                                       g_free(buffer);
+                                       if (rc->read_func) rc->read_func(rc, buffer, source, rc->read_data);
+                                       g_io_channel_write_chars(source, "\n", -1, NULL, NULL); /* empty line finishes the command */
+                                       g_io_channel_flush(source, NULL);
                                        }
+                               g_free(buffer);
 
                                buffer = NULL;
                                }
@@ -93,24 +91,12 @@ static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition conditi
 
                if (error)
                        {
-                       printf("error reading socket: %s\n", error->message);
+                       log_printf("error reading socket: %s\n", error->message);
                        g_error_free(error);
                        }
-
-               work = queue;
-               while (work)
-                       {
-                       gchar *command = work->data;
-                       work = work->next;
-
-                       if (rc->read_func) rc->read_func(rc, command, rc->read_data);
-                       g_free(command);
-                       }
-
-               g_list_free(queue);
                }
 
-       if (condition & G_IO_HUP)
+       if (condition & G_IO_HUP || status == G_IO_STATUS_EOF || status == G_IO_STATUS_ERROR)
                {
                rc->clients = g_list_remove(rc->clients, client);
 
@@ -125,14 +111,14 @@ static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition conditi
        return TRUE;
 }
 
-static void remote_server_client_add(RemoteConnection *rc, int fd)
+static void remote_server_client_add(RemoteConnection *rc, gint fd)
 {
        RemoteClient *client;
        GIOChannel *channel;
 
        if (g_list_length(rc->clients) > SERVER_MAX_CLIENTS)
                {
-               printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS);
+               log_printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS);
                close(fd);
                return;
                }
@@ -167,13 +153,13 @@ static void remote_server_clients_close(RemoteConnection *rc)
 static gboolean remote_server_read_cb(GIOChannel *source, GIOCondition condition, gpointer data)
 {
        RemoteConnection *rc = data;
-       int fd;
-       unsigned int alen;
+       gint fd;
+       guint alen;
 
        fd = accept(rc->fd, NULL, &alen);
        if (fd == -1)
                {
-               printf("error accepting socket: %s\n", strerror(errno));
+               log_printf("error accepting socket: %s\n", strerror(errno));
                return TRUE;
                }
 
@@ -182,7 +168,7 @@ static gboolean remote_server_read_cb(GIOChannel *source, GIOCondition condition
        return TRUE;
 }
 
-static gint remote_server_exists(const gchar *path)
+static gboolean remote_server_exists(const gchar *path)
 {
        RemoteConnection *rc;
 
@@ -202,12 +188,12 @@ static RemoteConnection *remote_server_open(const gchar *path)
        RemoteConnection *rc;
        struct sockaddr_un addr;
        gint sun_path_len;
-       int fd;
+       gint fd;
        GIOChannel *channel;
 
        if (remote_server_exists(path))
                {
-               printf("Address already in use: %s\n", path);
+               log_printf("Address already in use: %s\n", path);
                return NULL;
                }
 
@@ -220,22 +206,20 @@ static RemoteConnection *remote_server_open(const gchar *path)
        if (bind(fd, &addr, sizeof(addr)) == -1 ||
            listen(fd, REMOTE_SERVER_BACKLOG) == -1)
                {
-               printf("error subscribing to socket: %s\n", strerror(errno));
+               log_printf("error subscribing to socket: %s\n", strerror(errno));
                close(fd);
                return NULL;
                }
 
        rc = g_new0(RemoteConnection, 1);
+       
        rc->server = TRUE;
        rc->fd = fd;
        rc->path = g_strdup(path);
 
-       rc->read_func = NULL;
-       rc->read_data = NULL;
-
-       rc->clients = NULL;
-
        channel = g_io_channel_unix_new(rc->fd);
+       g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
+       
        rc->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN,
                                             remote_server_read_cb, rc, NULL);
        g_io_channel_unref(channel);
@@ -258,7 +242,7 @@ static RemoteConnection *remote_client_open(const gchar *path)
        struct stat st;
        struct sockaddr_un addr;
        gint sun_path_len;
-       int fd;
+       gint fd;
 
        if (stat(path, &st) != 0 || !S_ISSOCK(st.st_mode)) return NULL;
 
@@ -280,23 +264,22 @@ static RemoteConnection *remote_client_open(const gchar *path)
        rc->fd = fd;
        rc->path = g_strdup(path);
 
-       /* this might fix the freezes on freebsd, solaris, etc. - completely untested */
-       remote_client_send(rc, "\n");
-
        return rc;
 }
 
 static sig_atomic_t sigpipe_occured = FALSE;
 
-static void sighandler_sigpipe(int sig)
+static void sighandler_sigpipe(gint sig)
 {
        sigpipe_occured = TRUE;
 }
 
-static gint remote_client_send(RemoteConnection *rc, const gchar *text)
+static gboolean remote_client_send(RemoteConnection *rc, const gchar *text)
 {
        struct sigaction new_action, old_action;
-       gint ret = FALSE;
+       gboolean ret = FALSE;
+       GError *error = NULL;
+       GIOChannel *channel;
 
        if (!rc || rc->server) return FALSE;
        if (!text) return TRUE;
@@ -310,17 +293,16 @@ static gint remote_client_send(RemoteConnection *rc, const gchar *text)
        /* setup our signal handler */
        sigaction(SIGPIPE, &new_action, &old_action);
 
-       if (write(rc->fd, text, strlen(text)) == -1 ||
-           write(rc->fd, "\n", 1) == -1)
+       channel = g_io_channel_unix_new(rc->fd);
+
+       g_io_channel_write_chars(channel, text, -1, NULL, &error);
+       g_io_channel_write_chars(channel, "\n", -1, NULL, &error);
+       g_io_channel_flush(channel, &error);
+
+       if (error)
                {
-               if (sigpipe_occured)
-                       {
-                       printf("SIGPIPE writing to socket: %s\n", rc->path);
-                       }
-               else
-                       {
-                       printf("error writing to socket: %s\n", strerror(errno));
-                       }
+               log_printf("error reading socket: %s\n", error->message);
+               g_error_free(error);
                ret = FALSE;;
                }
        else
@@ -328,9 +310,39 @@ static gint remote_client_send(RemoteConnection *rc, const gchar *text)
                ret = TRUE;
                }
 
+       if (ret)
+               {
+               gchar *buffer = NULL;
+               gsize termpos;
+               while (g_io_channel_read_line(channel, &buffer, NULL, &termpos, &error) == G_IO_STATUS_NORMAL)
+                       {
+                       if (buffer)
+                               {
+                               if (buffer[0] == '\n') /* empty line finishes the command */
+                                       {
+                                       g_free(buffer);
+                                       fflush(stdout);
+                                       break;
+                                       }
+                               buffer[termpos] = '\0';
+                               printf("%s\n", buffer);
+                               g_free(buffer);
+                               buffer = NULL;
+                               }
+                       }
+
+               if (error)
+                       {
+                       log_printf("error reading socket: %s\n", error->message);
+                       g_error_free(error);
+                       ret = FALSE;
+                       }
+               }
+               
+
        /* restore the original signal handler */
        sigaction(SIGPIPE, &old_action, NULL);
-
+       g_io_channel_unref(channel);
        return ret;
 }
 
@@ -361,72 +373,73 @@ void remote_close(RemoteConnection *rc)
  *-----------------------------------------------------------------------------
  */
 
-static void gr_image_next(const gchar *text, gpointer data)
+static void gr_image_next(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_next(NULL);
 }
 
-static void gr_image_prev(const gchar *text, gpointer data)
+static void gr_image_prev(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_prev(NULL);
 }
 
-static void gr_image_first(const gchar *text, gpointer data)
+static void gr_image_first(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_first(NULL);
 }
 
-static void gr_image_last(const gchar *text, gpointer data)
+static void gr_image_last(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_last(NULL);
 }
 
-static void gr_fullscreen_toggle(const gchar *text, gpointer data)
+static void gr_fullscreen_toggle(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_full_screen_toggle(NULL);
 }
 
-static void gr_fullscreen_start(const gchar *text, gpointer data)
+static void gr_fullscreen_start(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_full_screen_start(NULL);
 }
 
-static void gr_fullscreen_stop(const gchar *text, gpointer data)
+static void gr_fullscreen_stop(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_full_screen_stop(NULL);
 }
 
-static void gr_slideshow_start_rec(const gchar *text, gpointer data)
+static void gr_slideshow_start_rec(const gchar *text, GIOChannel *channel, gpointer data)
 {
        GList *list;
-
-       list = filelist_recursive(text);
+       FileData *dir_fd = file_data_new_dir(text);
+       list = filelist_recursive(dir_fd);
+       file_data_unref(dir_fd);
        if (!list) return;
 //printf("length: %d\n", g_list_length(list));
        layout_image_slideshow_stop(NULL);
        layout_image_slideshow_start_from_list(NULL, list);
 }
 
-static void gr_slideshow_toggle(const gchar *text, gpointer data)
+static void gr_slideshow_toggle(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_slideshow_toggle(NULL);
 }
 
-static void gr_slideshow_start(const gchar *text, gpointer data)
+static void gr_slideshow_start(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_slideshow_start(NULL);
 }
 
-static void gr_slideshow_stop(const gchar *text, gpointer data)
+static void gr_slideshow_stop(const gchar *text, GIOChannel *channel, gpointer data)
 {
        layout_image_slideshow_stop(NULL);
 }
 
-static void gr_slideshow_delay(const gchar *text, gpointer data)
+static void gr_slideshow_delay(const gchar *text, GIOChannel *channel, gpointer data)
 {
        gdouble n;
 
-       n = strtod(text, NULL);
+       n = g_ascii_strtod(text, NULL);
        if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS)
                {
                printf_term("Remote slideshow delay out of range (%.1f to %.1f)\n",
@@ -436,10 +449,10 @@ static void gr_slideshow_delay(const gchar *text, gpointer data)
        options->slideshow.delay = (gint)(n * 10.0 + 0.01);
 }
 
-static void gr_tools_show(const gchar *text, gpointer data)
+static void gr_tools_show(const gchar *text, GIOChannel *channel, gpointer data)
 {
-       gint popped;
-       gint hidden;
+       gboolean popped;
+       gboolean hidden;
 
        if (layout_tools_float_get(NULL, &popped, &hidden) && hidden)
                {
@@ -447,10 +460,10 @@ static void gr_tools_show(const gchar *text, gpointer data)
                }
 }
 
-static void gr_tools_hide(const gchar *text, gpointer data)
+static void gr_tools_hide(const gchar *text, GIOChannel *channel, gpointer data)
 {
-       gint popped;
-       gint hidden;
+       gboolean popped;
+       gboolean hidden;
 
        if (layout_tools_float_get(NULL, &popped, &hidden) && !hidden)
                {
@@ -458,14 +471,14 @@ static void gr_tools_hide(const gchar *text, gpointer data)
                }
 }
 
-static gint gr_quit_idle_cb(gpointer data)
+static gboolean gr_quit_idle_cb(gpointer data)
 {
        exit_program();
 
        return FALSE;
 }
 
-static void gr_quit(const gchar *text, gpointer data)
+static void gr_quit(const gchar *text, GIOChannel *channel, gpointer data)
 {
        /* schedule exit when idle, if done from within a
         * remote handler remote_close will crash
@@ -473,13 +486,13 @@ static void gr_quit(const gchar *text, gpointer data)
        g_idle_add(gr_quit_idle_cb, NULL);
 }
 
-static void gr_file_load(const gchar *text, gpointer data)
+static void gr_file_load(const gchar *text, GIOChannel *channel, gpointer data)
 {
        gchar *filename = expand_tilde(text);
 
        if (isfile(filename))
                {
-               if (file_extension_match(filename, ".gqv"))
+               if (file_extension_match(filename, GQ_COLLECTION_EXT))
                        {
                        collection_window_new(filename);
                        }
@@ -494,21 +507,73 @@ static void gr_file_load(const gchar *text, gpointer data)
                }
        else
                {
-               printf("remote sent filename that does not exist:\"%s\"\n", filename);
+               log_printf("remote sent filename that does not exist:\"%s\"\n", filename);
+               }
+
+       g_free(filename);
+}
+
+static void gr_config_load(const gchar *text, GIOChannel *channel, gpointer data)
+{
+       gchar *filename = expand_tilde(text);
+
+       if (isfile(filename))
+               {
+               load_config_from_file(filename, FALSE);
+               }
+       else
+               {
+               log_printf("remote sent filename that does not exist:\"%s\"\n", filename);
                }
 
        g_free(filename);
 }
 
-static void gr_file_view(const gchar *text, gpointer data)
+static void gr_get_sidecars(const gchar *text, GIOChannel *channel, gpointer data)
 {
        gchar *filename = expand_tilde(text);
+       FileData *fd = file_data_new_group(filename);
+       
+       GList *work;
+       if (fd->parent) fd = fd->parent;
+
+       g_io_channel_write_chars(channel, fd->path, -1, NULL, NULL);
+       g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
+
+       work = fd->sidecar_files;
 
-       view_window_new(file_data_new_simple(filename));
+       while (work)
+               {
+               fd = work->data;
+               work = work->next;
+               g_io_channel_write_chars(channel, fd->path, -1, NULL, NULL);
+               g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
+               }
        g_free(filename);
 }
 
-static void gr_list_clear(const gchar *text, gpointer data)
+static void gr_get_destination(const gchar *text, GIOChannel *channel, gpointer data)
+{
+       gchar *filename = expand_tilde(text);
+       FileData *fd = file_data_new_group(filename);
+       
+       if (fd->change && fd->change->dest)
+               {
+               g_io_channel_write_chars(channel, fd->change->dest, -1, NULL, NULL);
+               g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
+               }
+       g_free(filename);
+}
+
+static void gr_file_view(const gchar *text, GIOChannel *channel, gpointer data)
+{
+       gchar *filename = expand_tilde(text);
+
+       view_window_new(file_data_new_group(filename));
+       g_free(filename);
+}
+
+static void gr_list_clear(const gchar *text, GIOChannel *channel, gpointer data)
 {
        RemoteData *remote_data = data;
 
@@ -517,12 +582,12 @@ static void gr_list_clear(const gchar *text, gpointer data)
                collection_unref(remote_data->command_collection);
                remote_data->command_collection = NULL;
                }
-}              
+}
 
-static void gr_list_add(const gchar *text, gpointer data)
+static void gr_list_add(const gchar *text, GIOChannel *channel, gpointer data)
 {
        RemoteData *remote_data = data;
-       gint new = TRUE;
+       gboolean new = TRUE;
 
        if (!remote_data->command_collection)
                {
@@ -542,14 +607,14 @@ static void gr_list_add(const gchar *text, gpointer data)
                new = (!collection_get_first(remote_data->command_collection));
                }
 
-       if (collection_add(remote_data->command_collection, file_data_new_simple(text), FALSE) && new)
+       if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
                {
                layout_image_set_collection(NULL, remote_data->command_collection,
                                            collection_get_first(remote_data->command_collection));
                }
 }
 
-static void gr_raise(const gchar *text, gpointer data)
+static void gr_raise(const gchar *text, GIOChannel *channel, gpointer data)
 {
        LayoutWindow *lw = NULL;
 
@@ -563,9 +628,9 @@ typedef struct _RemoteCommandEntry RemoteCommandEntry;
 struct _RemoteCommandEntry {
        gchar *opt_s;
        gchar *opt_l;
-       void (*func)(const gchar *text, gpointer data);
-       gint needs_extra;
-       gint prefer_command_line;
+       void (*func)(const gchar *text, GIOChannel *channel, gpointer data);
+       gboolean needs_extra;
+       gboolean prefer_command_line;
        gchar *description;
 };
 
@@ -581,11 +646,14 @@ static RemoteCommandEntry remote_commands[] = {
        { "-s", "--slideshow",          gr_slideshow_toggle,    FALSE, TRUE,  N_("toggle slide show") },
        { "-ss","--slideshow-start",    gr_slideshow_start,     FALSE, FALSE, N_("start slide show") },
        { "-sS","--slideshow-stop",     gr_slideshow_stop,      FALSE, FALSE, N_("stop slide show") },
-       { "-sr","--slideshow-recurse",  gr_slideshow_start_rec, TRUE,  FALSE, N_("start recursive slide show") },
+       { NULL, "--slideshow-recurse:", gr_slideshow_start_rec, TRUE,  FALSE, N_("start recursive slide show") },
        { "-d", "--delay=",             gr_slideshow_delay,     TRUE,  FALSE, N_("set slide show delay in seconds") },
        { "+t", "--tools-show",         gr_tools_show,          FALSE, TRUE,  N_("show tools") },
        { "-t", "--tools-hide",         gr_tools_hide,          FALSE, TRUE,  N_("hide tools") },
        { "-q", "--quit",               gr_quit,                FALSE, FALSE, N_("quit") },
+       { NULL, "--config-load:",       gr_config_load,         TRUE,  FALSE, N_("load config file") },
+       { NULL, "--get-sidecars:",      gr_get_sidecars,        TRUE,  FALSE, N_("get list of sidecars of the given file") },
+       { NULL, "--get-destination:",   gr_get_destination,     TRUE,  FALSE, N_("get destination path for the given file") },
        { NULL, "file:",                gr_file_load,           TRUE,  FALSE, N_("open file") },
        { NULL, "view:",                gr_file_view,           TRUE,  FALSE, N_("open file in new window") },
        { NULL, "--list-clear",         gr_list_clear,          FALSE, FALSE, NULL },
@@ -596,7 +664,7 @@ static RemoteCommandEntry remote_commands[] = {
 
 static RemoteCommandEntry *remote_command_find(const gchar *text, const gchar **offset)
 {
-       gint match = FALSE;
+       gboolean match = FALSE;
        gint i;
 
        i = 0;
@@ -633,7 +701,7 @@ static RemoteCommandEntry *remote_command_find(const gchar *text, const gchar **
        return NULL;
 }
 
-static void remote_cb(RemoteConnection *rc, const gchar *text, gpointer data)
+static void remote_cb(RemoteConnection *rc, const gchar *text, GIOChannel *channel, gpointer data)
 {
        RemoteCommandEntry *entry;
        const gchar *offset;
@@ -641,11 +709,11 @@ static void remote_cb(RemoteConnection *rc, const gchar *text, gpointer data)
        entry = remote_command_find(text, &offset);
        if (entry && entry->func)
                {
-               entry->func(offset, data);
+               entry->func(offset, channel, data);
                }
        else
                {
-               printf("unknown remote command:%s\n", text);
+               log_printf("unknown remote command:%s\n", text);
                }
 }
 
@@ -668,9 +736,10 @@ void remote_help(void)
                        }
                i++;
                }
+       printf_term(N_("\n  All other command line parameters are used as plain files if they exists.\n"));
 }
 
-GList *remote_build_list(GList *list, int argc, char *argv[], GList **errors)
+GList *remote_build_list(GList *list, gint argc, gchar *argv[], GList **errors)
 {
        gint i;
 
@@ -684,7 +753,7 @@ GList *remote_build_list(GList *list, int argc, char *argv[], GList **errors)
                        {
                        list = g_list_append(list, argv[i]);
                        }
-               else if (errors)
+               else if (errors && !isfile(argv[i]))
                        {
                        *errors = g_list_append(*errors, argv[i]);
                        }
@@ -694,21 +763,28 @@ GList *remote_build_list(GList *list, int argc, char *argv[], GList **errors)
        return list;
 }
 
+/**
+ * \param arg_exec Binary (argv0)
+ * \param remote_list Evaluated and recognized remote commands
+ * \param path The current path
+ * \param cmd_list List of all non collections in Path
+ * \param collection_list List of all collections in argv
+ */
 void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path,
                    GList *cmd_list, GList *collection_list)
 {
        RemoteConnection *rc;
-       gint started = FALSE;
+       gboolean started = FALSE;
        gchar *buf;
 
-       buf = g_strconcat(homedir(), "/", GQ_RC_DIR, "/.command", NULL);
+       buf = g_build_filename(get_rc_dir(), ".command", NULL);
        rc = remote_client_open(buf);
        if (!rc)
                {
                GString *command;
                GList *work;
                gint retry_count = 12;
-               gint blank = FALSE;
+               gboolean blank = FALSE;
 
                printf_term(_("Remote %s not running, starting..."), GQ_APPNAME);
 
@@ -743,7 +819,7 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
                if (get_debug_level()) g_string_append(command, " --debug");
 
                g_string_append(command, " &");
-               system(command->str);
+               runcmd(command->str);
                g_string_free(command, TRUE);
 
                while (!rc && retry_count > 0)
@@ -764,8 +840,8 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
                {
                GList *work;
                const gchar *prefix;
-               gint use_path = TRUE;
-               gint sent = FALSE;
+               gboolean use_path = TRUE;
+               gboolean sent = FALSE;
 
                work = remote_list;
                while (work)
@@ -862,3 +938,4 @@ RemoteConnection *remote_server_init(gchar *path, CollectionData *command_collec
        remote_server_subscribe(remote_connection, remote_cb, remote_data);
        return remote_connection;
 }
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */