2 * Copyright (C) 2004 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "cache_maint.h"
31 #include "layout_image.h"
33 #include "slideshow.h"
34 #include "ui_fileops.h"
37 #include <sys/socket.h>
43 #define SERVER_MAX_CLIENTS 8
45 #define REMOTE_SERVER_BACKLOG 4
49 #define UNIX_PATH_MAX 108
53 static RemoteConnection *remote_client_open(const gchar *path);
54 static gint remote_client_send(RemoteConnection *rc, const gchar *text);
55 static void gr_raise(const gchar *text, GIOChannel *channel, gpointer data);
58 typedef struct _RemoteClient RemoteClient;
59 struct _RemoteClient {
61 guint channel_id; /* event source id */
65 typedef struct _RemoteData RemoteData;
67 CollectionData *command_collection;
71 static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition condition, gpointer data)
73 RemoteClient *client = data;
75 GIOStatus status = G_IO_STATUS_NORMAL;
79 if (condition & G_IO_IN)
85 while ((status = g_io_channel_read_line(source, &buffer, NULL, &termpos, &error)) == G_IO_STATUS_NORMAL)
89 buffer[termpos] = '\0';
91 if (strlen(buffer) > 0)
93 if (rc->read_func) rc->read_func(rc, buffer, source, rc->read_data);
94 g_io_channel_write_chars(source, "\n", -1, NULL, NULL); /* empty line finishes the command */
95 g_io_channel_flush(source, NULL);
105 log_printf("error reading socket: %s\n", error->message);
110 if (condition & G_IO_HUP || status == G_IO_STATUS_EOF || status == G_IO_STATUS_ERROR)
112 rc->clients = g_list_remove(rc->clients, client);
114 DEBUG_1("HUP detected, closing client.");
115 DEBUG_1("client count %d", g_list_length(rc->clients));
117 g_source_remove(client->channel_id);
125 static void remote_server_client_add(RemoteConnection *rc, gint fd)
127 RemoteClient *client;
130 if (g_list_length(rc->clients) > SERVER_MAX_CLIENTS)
132 log_printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS);
137 client = g_new0(RemoteClient, 1);
141 channel = g_io_channel_unix_new(fd);
142 client->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_HUP,
143 remote_server_client_cb, client, NULL);
144 g_io_channel_unref(channel);
146 rc->clients = g_list_append(rc->clients, client);
147 DEBUG_1("client count %d", g_list_length(rc->clients));
150 static void remote_server_clients_close(RemoteConnection *rc)
154 RemoteClient *client = rc->clients->data;
156 rc->clients = g_list_remove(rc->clients, client);
158 g_source_remove(client->channel_id);
164 static gboolean remote_server_read_cb(GIOChannel *source, GIOCondition condition, gpointer data)
166 RemoteConnection *rc = data;
170 fd = accept(rc->fd, NULL, &alen);
173 log_printf("error accepting socket: %s\n", strerror(errno));
177 remote_server_client_add(rc, fd);
182 static gboolean remote_server_exists(const gchar *path)
184 RemoteConnection *rc;
186 /* verify server up */
187 rc = remote_client_open(path);
192 /* unable to connect, remove socket file to free up address */
197 static RemoteConnection *remote_server_open(const gchar *path)
199 RemoteConnection *rc;
200 struct sockaddr_un addr;
205 if (remote_server_exists(path))
207 log_printf("Address already in use: %s\n", path);
211 fd = socket(PF_UNIX, SOCK_STREAM, 0);
212 if (fd == -1) return NULL;
214 addr.sun_family = AF_UNIX;
215 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX);
216 strncpy(addr.sun_path, path, sun_path_len);
217 if (bind(fd, &addr, sizeof(addr)) == -1 ||
218 listen(fd, REMOTE_SERVER_BACKLOG) == -1)
220 log_printf("error subscribing to socket: %s\n", strerror(errno));
225 rc = g_new0(RemoteConnection, 1);
229 rc->path = g_strdup(path);
231 channel = g_io_channel_unix_new(rc->fd);
232 g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
234 rc->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN,
235 remote_server_read_cb, rc, NULL);
236 g_io_channel_unref(channel);
241 static void remote_server_subscribe(RemoteConnection *rc, RemoteReadFunc *func, gpointer data)
243 if (!rc || !rc->server) return;
245 rc->read_func = func;
246 rc->read_data = data;
250 static RemoteConnection *remote_client_open(const gchar *path)
252 RemoteConnection *rc;
254 struct sockaddr_un addr;
258 if (stat(path, &st) != 0 || !S_ISSOCK(st.st_mode)) return NULL;
260 fd = socket(PF_UNIX, SOCK_STREAM, 0);
261 if (fd == -1) return NULL;
263 addr.sun_family = AF_UNIX;
264 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX);
265 strncpy(addr.sun_path, path, sun_path_len);
266 if (connect(fd, &addr, sizeof(addr)) == -1)
268 DEBUG_1("error connecting to socket: %s", strerror(errno));
273 rc = g_new0(RemoteConnection, 1);
276 rc->path = g_strdup(path);
281 static sig_atomic_t sigpipe_occured = FALSE;
283 static void sighandler_sigpipe(gint sig)
285 sigpipe_occured = TRUE;
288 static gboolean remote_client_send(RemoteConnection *rc, const gchar *text)
290 struct sigaction new_action, old_action;
291 gboolean ret = FALSE;
292 GError *error = NULL;
295 if (!rc || rc->server) return FALSE;
296 if (!text) return TRUE;
298 sigpipe_occured = FALSE;
300 new_action.sa_handler = sighandler_sigpipe;
301 sigemptyset(&new_action.sa_mask);
302 new_action.sa_flags = 0;
304 /* setup our signal handler */
305 sigaction(SIGPIPE, &new_action, &old_action);
307 channel = g_io_channel_unix_new(rc->fd);
309 g_io_channel_write_chars(channel, text, -1, NULL, &error);
310 g_io_channel_write_chars(channel, "\n", -1, NULL, &error);
311 g_io_channel_flush(channel, &error);
315 log_printf("error reading socket: %s\n", error->message);
326 gchar *buffer = NULL;
328 while (g_io_channel_read_line(channel, &buffer, NULL, &termpos, &error) == G_IO_STATUS_NORMAL)
332 if (buffer[0] == '\n') /* empty line finishes the command */
338 buffer[termpos] = '\0';
339 printf("%s\n", buffer);
347 log_printf("error reading socket: %s\n", error->message);
354 /* restore the original signal handler */
355 sigaction(SIGPIPE, &old_action, NULL);
356 g_io_channel_unref(channel);
360 void remote_close(RemoteConnection *rc)
366 remote_server_clients_close(rc);
368 g_source_remove(rc->channel_id);
373 g_free(rc->read_data);
382 *-----------------------------------------------------------------------------
384 *-----------------------------------------------------------------------------
387 static void gr_image_next(const gchar *text, GIOChannel *channel, gpointer data)
389 layout_image_next(NULL);
392 static void gr_image_prev(const gchar *text, GIOChannel *channel, gpointer data)
394 layout_image_prev(NULL);
397 static void gr_image_first(const gchar *text, GIOChannel *channel, gpointer data)
399 layout_image_first(NULL);
402 static void gr_image_last(const gchar *text, GIOChannel *channel, gpointer data)
404 layout_image_last(NULL);
407 static void gr_fullscreen_toggle(const gchar *text, GIOChannel *channel, gpointer data)
409 layout_image_full_screen_toggle(NULL);
412 static void gr_fullscreen_start(const gchar *text, GIOChannel *channel, gpointer data)
414 layout_image_full_screen_start(NULL);
417 static void gr_fullscreen_stop(const gchar *text, GIOChannel *channel, gpointer data)
419 layout_image_full_screen_stop(NULL);
422 static void gr_slideshow_start_rec(const gchar *text, GIOChannel *channel, gpointer data)
425 FileData *dir_fd = file_data_new_dir(text);
426 list = filelist_recursive(dir_fd);
427 file_data_unref(dir_fd);
429 //printf("length: %d\n", g_list_length(list));
430 layout_image_slideshow_stop(NULL);
431 layout_image_slideshow_start_from_list(NULL, list);
434 static void gr_cache_thumb(const gchar *text, GIOChannel *channel, gpointer data)
436 if (!g_strcmp0(text, "clear"))
437 cache_maintain_home_remote(FALSE, TRUE);
438 else if (!g_strcmp0(text, "clean"))
439 cache_maintain_home_remote(FALSE, FALSE);
442 static void gr_cache_shared(const gchar *text, GIOChannel *channel, gpointer data)
444 if (!g_strcmp0(text, "clear"))
445 cache_manager_standard_process_remote(TRUE);
446 else if (!g_strcmp0(text, "clean"))
447 cache_manager_standard_process_remote(FALSE);
450 static void gr_cache_metadata(const gchar *text, GIOChannel *channel, gpointer data)
452 cache_maintain_home_remote(TRUE, FALSE);
455 static void gr_cache_render(const gchar *text, GIOChannel *channel, gpointer data)
457 cache_manager_render_remote(text, FALSE, FALSE);
460 static void gr_cache_render_recurse(const gchar *text, GIOChannel *channel, gpointer data)
462 cache_manager_render_remote(text, TRUE, FALSE);
465 static void gr_cache_render_standard(const gchar *text, GIOChannel *channel, gpointer data)
467 if(options->thumbnails.spec_standard)
468 cache_manager_render_remote(text, FALSE, TRUE);
471 static void gr_cache_render_standard_recurse(const gchar *text, GIOChannel *channel, gpointer data)
473 if(options->thumbnails.spec_standard)
474 cache_manager_render_remote(text, TRUE, TRUE);
477 static void gr_slideshow_toggle(const gchar *text, GIOChannel *channel, gpointer data)
479 layout_image_slideshow_toggle(NULL);
482 static void gr_slideshow_start(const gchar *text, GIOChannel *channel, gpointer data)
484 layout_image_slideshow_start(NULL);
487 static void gr_slideshow_stop(const gchar *text, GIOChannel *channel, gpointer data)
489 layout_image_slideshow_stop(NULL);
492 static void gr_slideshow_delay(const gchar *text, GIOChannel *channel, gpointer data)
496 n = g_ascii_strtod(text, NULL);
497 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS)
499 printf_term("Remote slideshow delay out of range (%.1f to %.1f)\n",
500 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS);
503 options->slideshow.delay = (gint)(n * 10.0 + 0.01);
506 static void gr_tools_show(const gchar *text, GIOChannel *channel, gpointer data)
511 if (layout_tools_float_get(NULL, &popped, &hidden) && hidden)
513 layout_tools_float_set(NULL, popped, FALSE);
517 static void gr_tools_hide(const gchar *text, GIOChannel *channel, gpointer data)
522 if (layout_tools_float_get(NULL, &popped, &hidden) && !hidden)
524 layout_tools_float_set(NULL, popped, TRUE);
528 static gboolean gr_quit_idle_cb(gpointer data)
535 static void gr_quit(const gchar *text, GIOChannel *channel, gpointer data)
537 /* schedule exit when idle, if done from within a
538 * remote handler remote_close will crash
540 g_idle_add(gr_quit_idle_cb, NULL);
543 static void gr_file_load_no_raise(const gchar *text, GIOChannel *channel, gpointer data)
545 gchar *filename = expand_tilde(text);
547 if (isfile(filename))
549 if (file_extension_match(filename, GQ_COLLECTION_EXT))
551 collection_window_new(filename);
555 layout_set_path(NULL, filename);
558 else if (isdir(filename))
560 layout_set_path(NULL, filename);
564 log_printf("remote sent filename that does not exist:\"%s\"\n", filename);
565 layout_set_path(NULL, homedir());
571 static void gr_file_load(const gchar *text, GIOChannel *channel, gpointer data)
573 gr_file_load_no_raise(text, channel, data);
575 gr_raise(text, channel, data);
578 static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data)
580 LayoutWindow *lw = NULL; /* NULL to force layout_valid() to do some magic */
581 if (!layout_valid(&lw)) return;
582 if (image_get_path(lw->image))
584 g_io_channel_write_chars(channel, image_get_path(lw->image), -1, NULL, NULL);
585 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
589 static void gr_config_load(const gchar *text, GIOChannel *channel, gpointer data)
591 gchar *filename = expand_tilde(text);
593 if (isfile(filename))
595 load_config_from_file(filename, FALSE);
599 log_printf("remote sent filename that does not exist:\"%s\"\n", filename);
600 layout_set_path(NULL, homedir());
606 static void gr_get_sidecars(const gchar *text, GIOChannel *channel, gpointer data)
608 gchar *filename = expand_tilde(text);
609 FileData *fd = file_data_new_group(filename);
612 if (fd->parent) fd = fd->parent;
614 g_io_channel_write_chars(channel, fd->path, -1, NULL, NULL);
615 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
617 work = fd->sidecar_files;
623 g_io_channel_write_chars(channel, fd->path, -1, NULL, NULL);
624 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
629 static void gr_get_destination(const gchar *text, GIOChannel *channel, gpointer data)
631 gchar *filename = expand_tilde(text);
632 FileData *fd = file_data_new_group(filename);
634 if (fd->change && fd->change->dest)
636 g_io_channel_write_chars(channel, fd->change->dest, -1, NULL, NULL);
637 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
642 static void gr_file_view(const gchar *text, GIOChannel *channel, gpointer data)
644 gchar *filename = expand_tilde(text);
646 view_window_new(file_data_new_group(filename));
650 static void gr_list_clear(const gchar *text, GIOChannel *channel, gpointer data)
652 RemoteData *remote_data = data;
654 if (remote_data->command_collection)
656 collection_unref(remote_data->command_collection);
657 remote_data->command_collection = NULL;
661 static void gr_list_add(const gchar *text, GIOChannel *channel, gpointer data)
663 RemoteData *remote_data = data;
666 if (!remote_data->command_collection)
670 cd = collection_new("");
675 cd->name = g_strdup(_("Command line"));
677 remote_data->command_collection = cd;
681 new = (!collection_get_first(remote_data->command_collection));
684 if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
686 layout_image_set_collection(NULL, remote_data->command_collection,
687 collection_get_first(remote_data->command_collection));
691 static void gr_raise(const gchar *text, GIOChannel *channel, gpointer data)
693 LayoutWindow *lw = NULL;
695 if (layout_valid(&lw))
697 gtk_window_present(GTK_WINDOW(lw->window));
701 typedef struct _RemoteCommandEntry RemoteCommandEntry;
702 struct _RemoteCommandEntry {
705 void (*func)(const gchar *text, GIOChannel *channel, gpointer data);
706 gboolean needs_extra;
707 gboolean prefer_command_line;
712 static RemoteCommandEntry remote_commands[] = {
713 /* short, long callback, extra, prefer, parameter, description */
714 { "-n", "--next", gr_image_next, FALSE, FALSE, NULL, N_("next image") },
715 { "-b", "--back", gr_image_prev, FALSE, FALSE, NULL, N_("previous image") },
716 { NULL, "--first", gr_image_first, FALSE, FALSE, NULL, N_("first image") },
717 { NULL, "--last", gr_image_last, FALSE, FALSE, NULL, N_("last image") },
718 { "-f", "--fullscreen", gr_fullscreen_toggle, FALSE, TRUE, NULL, N_("toggle full screen") },
719 { "-fs","--fullscreen-start", gr_fullscreen_start, FALSE, FALSE, NULL, N_("start full screen") },
720 { "-fS","--fullscreen-stop", gr_fullscreen_stop, FALSE, FALSE, NULL, N_("stop full screen") },
721 { "-s", "--slideshow", gr_slideshow_toggle, FALSE, TRUE, NULL, N_("toggle slide show") },
722 { "-ss","--slideshow-start", gr_slideshow_start, FALSE, FALSE, NULL, N_("start slide show") },
723 { "-sS","--slideshow-stop", gr_slideshow_stop, FALSE, FALSE, NULL, N_("stop slide show") },
724 { NULL, "--slideshow-recurse:", gr_slideshow_start_rec, TRUE, FALSE, N_("<FOLDER>"), N_("start recursive slide show in FOLDER") },
725 { "-d", "--delay=", gr_slideshow_delay, TRUE, FALSE, N_("<[N][.M]>"), N_("set slide show delay to N.M seconds") },
726 { "+t", "--tools-show", gr_tools_show, FALSE, TRUE, NULL, N_("show tools") },
727 { "-t", "--tools-hide", gr_tools_hide, FALSE, TRUE, NULL, N_("hide tools") },
728 { "-q", "--quit", gr_quit, FALSE, FALSE, NULL, N_("quit") },
729 { NULL, "--config-load:", gr_config_load, TRUE, FALSE, N_("<FILE>"), N_("load configuration from FILE") },
730 { NULL, "--get-sidecars:", gr_get_sidecars, TRUE, FALSE, N_("<FILE>"), N_("get list of sidecars of FILE") },
731 { NULL, "--get-destination:", gr_get_destination, TRUE, FALSE, N_("<FILE>"), N_("get destination path of FILE") },
732 { NULL, "file:", gr_file_load, TRUE, FALSE, N_("<FILE>"), N_("open FILE, bring Geeqie window to the top") },
733 { NULL, "File:", gr_file_load_no_raise, TRUE, FALSE, N_("<FILE>"), N_("open FILE, do not bring Geeqie window to the top") },
734 { NULL, "--tell", gr_file_tell, FALSE, FALSE, NULL, N_("print filename of current image") },
735 { NULL, "view:", gr_file_view, TRUE, FALSE, N_("<FILE>"), N_("open FILE in new window") },
736 { NULL, "--list-clear", gr_list_clear, FALSE, FALSE, NULL, N_("clear command line collection list") },
737 { NULL, "--list-add:", gr_list_add, TRUE, FALSE, N_("<FILE>"), N_("add FILE to command line collection list") },
738 { NULL, "raise", gr_raise, FALSE, FALSE, NULL, N_("bring the Geeqie window to the top") },
739 { "-ct:", "--cache-thumbs:", gr_cache_thumb, TRUE, FALSE, N_("clear|clean"), N_("clear or clean thumbnail cache") },
740 { "-cs:", "--cache-shared:", gr_cache_shared, TRUE, FALSE, N_("clear|clean"), N_("clear or clean shared thumbnail cache") },
741 { "-cm","--cache-metadata", gr_cache_metadata, FALSE, FALSE, NULL, N_(" clean the metadata cache") },
742 { "-cr:", "--cache-render:", gr_cache_render, TRUE, FALSE, N_("<folder> "), N_(" render thumbnails") },
743 { "-crr:", "--cache-render-recurse:", gr_cache_render_recurse, TRUE, FALSE, N_("<folder> "), N_("render thumbnails recursively") },
744 { "-crs:", "--cache-render-shared:", gr_cache_render_standard, TRUE, FALSE, N_("<folder> "), N_(" render thumbnails (see Help)") },
745 { "-crsr:", "--cache-render-shared-recurse:", gr_cache_render_standard_recurse, TRUE, FALSE, N_("<folder>"), N_(" render thumbnails recursively (see Help)") },
746 { NULL, NULL, NULL, FALSE, FALSE, NULL, NULL }
749 static RemoteCommandEntry *remote_command_find(const gchar *text, const gchar **offset)
751 gboolean match = FALSE;
755 while (!match && remote_commands[i].func != NULL)
757 if (remote_commands[i].needs_extra)
759 if (remote_commands[i].opt_s &&
760 strncmp(remote_commands[i].opt_s, text, strlen(remote_commands[i].opt_s)) == 0)
762 if (offset) *offset = text + strlen(remote_commands[i].opt_s);
763 return &remote_commands[i];
765 else if (remote_commands[i].opt_l &&
766 strncmp(remote_commands[i].opt_l, text, strlen(remote_commands[i].opt_l)) == 0)
768 if (offset) *offset = text + strlen(remote_commands[i].opt_l);
769 return &remote_commands[i];
774 if ((remote_commands[i].opt_s && strcmp(remote_commands[i].opt_s, text) == 0) ||
775 (remote_commands[i].opt_l && strcmp(remote_commands[i].opt_l, text) == 0))
777 if (offset) *offset = text;
778 return &remote_commands[i];
788 static void remote_cb(RemoteConnection *rc, const gchar *text, GIOChannel *channel, gpointer data)
790 RemoteCommandEntry *entry;
793 entry = remote_command_find(text, &offset);
794 if (entry && entry->func)
796 entry->func(offset, channel, data);
800 log_printf("unknown remote command:%s\n", text);
804 void remote_help(void)
810 print_term(_("Remote command list:\n"));
813 while (remote_commands[i].func != NULL)
815 if (remote_commands[i].description)
817 s_opt_param = g_strconcat(remote_commands[i].opt_s, remote_commands[i].parameter, NULL);
818 l_opt_param = g_strconcat(remote_commands[i].opt_l, remote_commands[i].parameter, NULL);
819 printf_term(" %-11s%-1s %-30s%-s\n",
820 (remote_commands[i].opt_s) ? s_opt_param : "",
821 (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ",
822 (remote_commands[i].opt_l) ? l_opt_param : "",
823 _(remote_commands[i].description));
829 printf_term(N_("\n All other command line parameters are used as plain files if they exists.\n"));
832 GList *remote_build_list(GList *list, gint argc, gchar *argv[], GList **errors)
839 RemoteCommandEntry *entry;
841 entry = remote_command_find(argv[i], NULL);
844 list = g_list_append(list, argv[i]);
846 else if (errors && !isfile(argv[i]))
848 *errors = g_list_append(*errors, argv[i]);
857 * \param arg_exec Binary (argv0)
858 * \param remote_list Evaluated and recognized remote commands
859 * \param path The current path
860 * \param cmd_list List of all non collections in Path
861 * \param collection_list List of all collections in argv
863 void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path,
864 GList *cmd_list, GList *collection_list)
866 RemoteConnection *rc;
867 gboolean started = FALSE;
870 buf = g_build_filename(get_rc_dir(), ".command", NULL);
871 rc = remote_client_open(buf);
876 gint retry_count = 12;
877 gboolean blank = FALSE;
879 printf_term(_("Remote %s not running, starting..."), GQ_APPNAME);
881 command = g_string_new(arg_exec);
887 RemoteCommandEntry *entry;
892 entry = remote_command_find(text, NULL);
895 if (entry->prefer_command_line)
897 remote_list = g_list_remove(remote_list, text);
898 g_string_append(command, " ");
899 g_string_append(command, text);
901 if (entry->opt_l && strcmp(entry->opt_l, "file:") == 0)
908 if (blank || cmd_list || path) g_string_append(command, " --blank");
909 if (get_debug_level()) g_string_append(command, " --debug");
911 g_string_append(command, " &");
912 runcmd(command->str);
913 g_string_free(command, TRUE);
915 while (!rc && retry_count > 0)
917 usleep((retry_count > 10) ? 500000 : 1000000);
918 rc = remote_client_open(buf);
919 if (!rc) print_term(".");
933 gboolean use_path = TRUE;
934 gboolean sent = FALSE;
940 RemoteCommandEntry *entry;
945 entry = remote_command_find(text, NULL);
948 strcmp(entry->opt_l, "file:") == 0) use_path = FALSE;
950 remote_client_send(rc, text);
955 if (cmd_list && cmd_list->next)
957 prefix = "--list-add:";
958 remote_client_send(rc, "--list-clear");
974 text = g_strconcat(prefix, fd->path, NULL);
975 remote_client_send(rc, text);
981 if (path && !cmd_list && use_path)
985 text = g_strdup_printf("file:%s", path);
986 remote_client_send(rc, text);
992 work = collection_list;
1001 text = g_strdup_printf("file:%s", name);
1002 remote_client_send(rc, text);
1008 if (!started && !sent)
1010 remote_client_send(rc, "raise");
1015 print_term(_("Remote not available\n"));
1021 RemoteConnection *remote_server_init(gchar *path, CollectionData *command_collection)
1023 RemoteConnection *remote_connection = remote_server_open(path);
1024 RemoteData *remote_data = g_new(RemoteData, 1);
1026 remote_data->command_collection = command_collection;
1028 remote_server_subscribe(remote_connection, remote_cb, remote_data);
1029 return remote_connection;
1031 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */