2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2005 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <glib/gi18n.h>
28 #include <gtk/gtkmain.h>
29 #include <gtk/gtkrc.h>
38 #include <sys/types.h>
43 #ifdef HAVE_STARTUP_NOTIFICATION
44 # define SN_API_NOT_YET_FROZEN
45 # include <libsn/sn-launchee.h>
46 # include <gdk/gdkx.h>
51 #include "mainwindow.h"
52 #include "folderview.h"
53 #include "image_viewer.h"
54 #include "summaryview.h"
55 #include "prefs_common.h"
56 #include "prefs_account.h"
57 #include "prefs_actions.h"
58 #include "prefs_ext_prog.h"
59 #include "prefs_fonts.h"
60 #include "prefs_image_viewer.h"
61 #include "prefs_message.h"
62 #include "prefs_receive.h"
63 #include "prefs_msg_colors.h"
64 #include "prefs_quote.h"
65 #include "prefs_spelling.h"
66 #include "prefs_summaries.h"
67 #include "prefs_themes.h"
68 #include "prefs_other.h"
69 #include "prefs_send.h"
70 #include "prefs_wrapping.h"
71 #include "prefs_compose_writing.h"
72 #include "prefs_display_header.h"
77 #include "manage_window.h"
78 #include "alertpanel.h"
79 #include "statusbar.h"
80 #include "addressbook.h"
88 #include "prefs_toolbar.h"
95 #include "imap-thread.h"
97 #include "stock_pixmap.h"
112 #ifdef HAVE_STARTUP_NOTIFICATION
113 static SnLauncheeContext *sn_context = NULL;
114 static SnDisplay *sn_display = NULL;
117 static gint lock_socket = -1;
118 static gint lock_socket_tag = 0;
122 ONLINE_MODE_DONT_CHANGE,
127 static struct RemoteCmd {
129 gboolean receive_all;
131 const gchar *compose_mailto;
132 GPtrArray *attach_files;
134 gboolean status_full;
135 GPtrArray *status_folders;
136 GPtrArray *status_full_folders;
143 static void parse_cmd_opt(int argc, char *argv[]);
145 static gint prohibit_duplicate_launch (void);
146 static gchar * get_crashfile_name (void);
147 static gint lock_socket_remove (void);
148 static void lock_socket_input_cb (gpointer data,
150 GdkInputCondition condition);
154 gchar *get_socket_name (void);
157 static void open_compose_new (const gchar *address,
158 GPtrArray *attach_files);
160 static void send_queue (void);
161 static void initial_processing (FolderItem *item, gpointer data);
162 static void quit_signal_handler (int sig);
163 static void install_basic_sighandlers (void);
164 static void exit_sylpheed (MainWindow *mainwin);
166 #define MAKE_DIR_IF_NOT_EXIST(dir) \
168 if (!is_dir_exist(dir)) { \
169 if (is_file_exist(dir)) { \
171 (_("File '%s' already exists.\n" \
172 "Can't create folder."), \
176 if (make_dir(dir) < 0) \
181 static MainWindow *static_mainwindow;
183 #ifdef HAVE_STARTUP_NOTIFICATION
184 static void sn_error_trap_push(SnDisplay *display, Display *xdisplay)
186 gdk_error_trap_push();
189 static void sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
191 gdk_error_trap_pop();
194 static void startup_notification_complete(gboolean with_window)
197 GtkWidget *hack = NULL;
200 /* this is needed to make the startup notification leave,
201 * if we have been launched from a menu.
202 * We have to display a window, so let it be very little */
203 hack = gtk_window_new(GTK_WINDOW_POPUP);
204 gtk_widget_set_uposition(hack, 0, 0);
205 gtk_widget_set_size_request(hack, 1, 1);
206 gtk_widget_show(hack);
209 xdisplay = GDK_DISPLAY();
210 sn_display = sn_display_new(xdisplay,
213 sn_context = sn_launchee_context_new_from_environment(sn_display,
214 DefaultScreen(xdisplay));
216 if (sn_context != NULL)
218 sn_launchee_context_complete(sn_context);
219 sn_launchee_context_unref(sn_context);
220 sn_display_unref(sn_display);
223 #endif /* HAVE_STARTUP_NOTIFICATION */
225 void sylpheed_gtk_idle(void)
227 while(gtk_events_pending())
228 gtk_main_iteration();
231 int main(int argc, char *argv[])
235 FolderView *folderview;
238 if (!sylpheed_init(&argc, &argv)) {
242 prog_version = PROG_VERSION;
244 argv0 = g_strdup(argv[0]);
247 parse_cmd_opt(argc, argv);
252 gtk_init(&argc, &argv);
253 crash_main(cmd.crash_params);
256 crash_install_handlers();
258 install_basic_sighandlers();
261 /* check and create unix domain socket for remote operation */
263 lock_socket = prohibit_duplicate_launch();
264 if (lock_socket < 0) {
265 #ifdef HAVE_STARTUP_NOTIFICATION
266 if(gtk_init_check(&argc, &argv))
267 startup_notification_complete(TRUE);
272 if (cmd.status || cmd.status_full) {
273 puts("0 Sylpheed not running.");
274 lock_socket_remove();
279 /* gdk_threads_init(); */
282 gtk_init(&argc, &argv);
285 gtk_widget_set_default_colormap(gdk_rgb_get_colormap());
286 gtk_widget_set_default_visual(gdk_rgb_get_visual());
288 if (!g_thread_supported())
289 g_error(_("g_thread is not supported by glib.\n"));
291 /* parse gtkrc files */
292 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc-2.0",
294 gtk_rc_parse(userrc);
296 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
297 G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
298 gtk_rc_parse(userrc);
300 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
301 gtk_rc_parse(userrc);
304 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
305 gtk_accel_map_load (userrc);
308 gtk_settings_set_long_property(gtk_settings_get_default(),
309 "gtk-can-change-accels",
310 (glong)TRUE, "XProperty");
312 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
314 MAKE_DIR_IF_NOT_EXIST(RC_DIR);
315 MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
316 MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
317 MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
318 MAKE_DIR_IF_NOT_EXIST(get_tmp_dir());
319 MAKE_DIR_IF_NOT_EXIST(RC_DIR G_DIR_SEPARATOR_S "uidl");
321 /* remove temporary files */
322 remove_all_files(get_tmp_dir());
323 remove_all_files(get_mime_tmp_dir());
325 if (is_file_exist("sylpheed.log")) {
326 if (rename_force("sylpheed.log", "sylpheed.log.bak") < 0)
327 FILE_OP_ERROR("sylpheed.log", "rename");
329 set_log_file("sylpheed.log");
331 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
333 folder_system_init();
334 prefs_common_read_config();
338 prefs_ext_prog_init();
339 prefs_wrapping_init();
340 prefs_compose_writing_init();
341 prefs_msg_colors_init();
343 prefs_image_viewer_init();
345 prefs_summaries_init();
346 prefs_message_init();
348 prefs_receive_init();
351 gtkaspell_checkers_init();
352 prefs_spelling_init();
355 sock_set_io_timeout(prefs_common.io_timeout_secs);
357 imap_main_set_timeout(prefs_common.io_timeout_secs);
359 prefs_actions_read_config();
360 prefs_display_header_read_config();
361 /* prefs_filtering_read_config(); */
362 addressbook_read_file();
363 renderer_read_config();
366 stock_pixbuf_gdk(NULL, STOCK_PIXMAP_SYLPHEED_ICON, &icon);
367 gtk_window_set_default_icon(icon);
369 folderview_initialize();
374 mainwin = main_window_create
375 (prefs_common.sep_folder | prefs_common.sep_msg << 1);
376 folderview = mainwin->folderview;
378 /* register the callback of unix domain socket input */
380 lock_socket_tag = gdk_input_add(lock_socket,
381 GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
382 lock_socket_input_cb,
386 prefs_account_init();
387 account_read_config_all();
389 if (folder_read_list() < 0) {
390 if (!run_wizard(mainwin, TRUE))
395 if (!account_get_list()) {
396 if (!run_wizard(mainwin, FALSE))
398 account_read_config_all();
399 if(!account_get_list())
400 exit_sylpheed(mainwin);
406 account_set_missing_folder();
407 folder_set_missing_folders();
408 folderview_set(folderview);
410 prefs_matcher_read_config();
412 /* make one all-folder processing before using sylpheed */
413 main_window_cursor_wait(mainwin);
414 folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
415 main_window_cursor_normal(mainwin);
417 /* if Sylpheed crashed, rebuild caches */
418 if (!cmd.crash && is_file_exist(get_crashfile_name())) {
419 debug_print("Sylpheed crashed, checking for new messages in local folders\n");
420 folderview_check_new(NULL);
421 folder_clean_cache_memory_force();
423 /* make the crash-indicator file */
424 str_write_to_file("foo", get_crashfile_name());
426 addressbook_read_file();
428 inc_autocheck_timer_init(mainwin);
430 /* ignore SIGPIPE signal for preventing sudden death of program */
432 signal(SIGPIPE, SIG_IGN);
434 if (cmd.online_mode == ONLINE_MODE_OFFLINE)
435 main_window_toggle_work_offline(mainwin, TRUE);
436 if (cmd.online_mode == ONLINE_MODE_ONLINE)
437 main_window_toggle_work_offline(mainwin, FALSE);
439 if (cmd.status_folders) {
440 g_ptr_array_free(cmd.status_folders, TRUE);
441 cmd.status_folders = NULL;
443 if (cmd.status_full_folders) {
444 g_ptr_array_free(cmd.status_full_folders, TRUE);
445 cmd.status_full_folders = NULL;
448 sylpheed_register_idle_function(sylpheed_gtk_idle);
450 prefs_toolbar_init();
452 plugin_load_all("GTK2");
454 static_mainwindow = mainwin;
456 #ifdef HAVE_STARTUP_NOTIFICATION
457 startup_notification_complete(FALSE);
461 inc_all_account_mail(mainwin, FALSE,
462 prefs_common.newmail_notify_manu);
463 else if (prefs_common.chk_on_startup)
464 inc_all_account_mail(mainwin, TRUE,
465 prefs_common.newmail_notify_manu);
466 else if (cmd.receive)
467 inc_mail(mainwin, prefs_common.newmail_notify_manu);
469 gtk_widget_grab_focus(folderview->ctree);
472 open_compose_new(cmd.compose_mailto, cmd.attach_files);
473 if (cmd.attach_files) {
474 ptr_array_free_strings(cmd.attach_files);
475 g_ptr_array_free(cmd.attach_files, TRUE);
476 cmd.attach_files = NULL;
483 exit_sylpheed(mainwin);
488 static void save_all_caches(FolderItem *item, gpointer data)
492 folder_item_write_cache(item);
495 static void exit_sylpheed(MainWindow *mainwin)
499 debug_print("shutting down\n");
500 inc_autocheck_timer_remove();
502 if (prefs_common.clean_on_exit)
503 main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
505 /* save prefs for opened folder */
506 if(mainwin->folderview->opened)
510 item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
511 summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
514 /* save all state before exiting */
516 folder_func_to_all_folders(save_all_caches, NULL);
518 main_window_get_size(mainwin);
519 main_window_get_position(mainwin);
520 prefs_common_write_config();
521 account_write_config_all();
522 addressbook_export_to_file();
524 filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
525 gtk_accel_map_save(filename);
528 /* delete temporary files */
529 remove_all_files(get_tmp_dir());
530 remove_all_files(get_mime_tmp_dir());
537 /* delete crashfile */
539 g_unlink(get_crashfile_name());
541 lock_socket_remove();
543 main_window_destroy(mainwin);
545 plugin_unload_all("GTK2");
547 prefs_toolbar_done();
549 addressbook_destroy();
553 prefs_ext_prog_done();
554 prefs_wrapping_done();
555 prefs_compose_writing_done();
556 prefs_msg_colors_done();
557 prefs_image_viewer_done();
560 prefs_summaries_done();
561 prefs_message_done();
563 prefs_receive_done();
566 prefs_spelling_done();
567 gtkaspell_checkers_quit();
573 static void parse_cmd_opt(int argc, char *argv[])
577 for (i = 1; i < argc; i++) {
578 if (!strncmp(argv[i], "--receive-all", 13))
579 cmd.receive_all = TRUE;
580 else if (!strncmp(argv[i], "--receive", 9))
582 else if (!strncmp(argv[i], "--compose", 9)) {
583 const gchar *p = argv[i + 1];
586 cmd.compose_mailto = NULL;
587 if (p && *p != '\0' && *p != '-') {
588 if (!strncmp(p, "mailto:", 7))
589 cmd.compose_mailto = p + 7;
591 cmd.compose_mailto = p;
594 } else if (!strncmp(argv[i], "--attach", 8)) {
595 const gchar *p = argv[i + 1];
598 while (p && *p != '\0' && *p != '-') {
599 if (!cmd.attach_files)
600 cmd.attach_files = g_ptr_array_new();
601 if (*p != G_DIR_SEPARATOR)
602 file = g_strconcat(sylpheed_get_startup_dir(),
607 g_ptr_array_add(cmd.attach_files, file);
611 } else if (!strncmp(argv[i], "--send", 6)) {
613 } else if (!strncmp(argv[i], "--version", 9)) {
614 puts("Sylpheed version " VERSION);
616 } else if (!strncmp(argv[i], "--status-full", 13)) {
617 const gchar *p = argv[i + 1];
619 cmd.status_full = TRUE;
620 while (p && *p != '\0' && *p != '-') {
621 if (!cmd.status_full_folders)
622 cmd.status_full_folders =
624 g_ptr_array_add(cmd.status_full_folders,
629 } else if (!strncmp(argv[i], "--status", 8)) {
630 const gchar *p = argv[i + 1];
633 while (p && *p != '\0' && *p != '-') {
634 if (!cmd.status_folders)
635 cmd.status_folders = g_ptr_array_new();
636 g_ptr_array_add(cmd.status_folders,
641 } else if (!strncmp(argv[i], "--online", 8)) {
642 cmd.online_mode = ONLINE_MODE_ONLINE;
643 } else if (!strncmp(argv[i], "--offline", 9)) {
644 cmd.online_mode = ONLINE_MODE_OFFLINE;
645 } else if (!strncmp(argv[i], "--help", 6)) {
646 gchar *base = g_path_get_basename(argv[0]);
647 g_print(_("Usage: %s [OPTION]...\n"), base);
649 g_print("%s\n", _(" --compose [address] open composition window"));
650 g_print("%s\n", _(" --attach file1 [file2]...\n"
651 " open composition window with specified files\n"
653 g_print("%s\n", _(" --receive receive new messages"));
654 g_print("%s\n", _(" --receive-all receive new messages of all accounts"));
655 g_print("%s\n", _(" --send send all queued messages"));
656 g_print("%s\n", _(" --status [folder]... show the total number of messages"));
657 g_print("%s\n", _(" --status-full [folder]...\n"
658 " show the status of each folder"));
659 g_print("%s\n", _(" --online switch to online mode"));
660 g_print("%s\n", _(" --offline switch to offline mode"));
661 g_print("%s\n", _(" --debug debug mode"));
662 g_print("%s\n", _(" --help display this help and exit"));
663 g_print("%s\n", _(" --version output version information and exit"));
664 g_print("%s\n", _(" --config-dir output configuration directory"));
668 } else if (!strncmp(argv[i], "--crash", 7)) {
670 cmd.crash_params = g_strdup(argv[i + 1]);
672 } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
679 if (cmd.attach_files && cmd.compose == FALSE) {
681 cmd.compose_mailto = NULL;
685 static gint get_queued_message_num(void)
689 queue = folder_get_default_queue();
690 if (!queue) return -1;
692 folder_item_scan(queue);
693 return queue->total_msgs;
696 static void initial_processing(FolderItem *item, gpointer data)
698 MainWindow *mainwin = (MainWindow *)data;
701 g_return_if_fail(item);
702 buf = g_strdup_printf(_("Processing (%s)..."),
705 : _("top level folder"));
706 debug_print("%s\n", buf);
710 if (item->prefs->enable_processing)
711 folder_item_apply_processing(item);
713 debug_print("done.\n");
714 STATUSBAR_POP(mainwin);
717 static void draft_all_messages(void)
719 GList *compose_list = NULL;
721 while ((compose_list = compose_get_compose_list()) != NULL) {
722 Compose *c = (Compose*)compose_list->data;
727 gboolean clean_quit(gpointer data)
729 static gboolean firstrun = TRUE;
735 /*!< Good idea to have the main window stored in a
736 * static variable so we can check that variable
737 * to see if we're really allowed to do things
738 * that actually the spawner is supposed to
739 * do (like: sending mail, composing messages).
740 * Because, really, if we're the spawnee, and
741 * we touch GTK stuff, we're hosed. See the
744 /* FIXME: Use something else to signal that we're
745 * in the original spawner, and not in a spawned
747 if (!static_mainwindow)
750 draft_all_messages();
752 exit_sylpheed(static_mainwindow);
758 void app_will_exit(GtkWidget *widget, gpointer data)
760 MainWindow *mainwin = data;
762 if (compose_get_compose_list()) {
763 gint val = alertpanel(_("Really quit?"),
764 _("Composing message exists."),
765 _("Draft them"), _("Discard them"), _("Don't quit"));
769 case G_ALERTALTERNATE:
772 draft_all_messages();
775 manage_window_focus_in(mainwin->window, NULL, NULL);
778 if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
779 if (alertpanel(_("Queued messages"),
780 _("Some unsent messages are queued. Exit now?"),
781 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
784 manage_window_focus_in(mainwin->window, NULL, NULL);
793 * CLAWS: want this public so crash dialog can delete the
799 gchar *get_socket_name(void)
801 static gchar *filename = NULL;
803 if (filename == NULL) {
804 filename = g_strdup_printf("%s%csylpheed-%d",
805 g_get_tmp_dir(), G_DIR_SEPARATOR,
816 static gchar *get_crashfile_name(void)
818 static gchar *filename = NULL;
820 if (filename == NULL) {
821 filename = g_strdup_printf("%s%csylpheed-crashed",
822 get_tmp_dir(), G_DIR_SEPARATOR);
828 static gint prohibit_duplicate_launch(void)
833 path = get_socket_name();
834 uxsock = fd_connect_unix(path);
837 return fd_open_unix(path);
840 /* remote command mode */
842 debug_print("another Sylpheed is already running.\n");
845 fd_write_all(uxsock, "receive_all\n", 12);
846 else if (cmd.receive)
847 fd_write_all(uxsock, "receive\n", 8);
848 else if (cmd.compose && cmd.attach_files) {
849 gchar *str, *compose_str;
852 if (cmd.compose_mailto)
853 compose_str = g_strdup_printf("compose_attach %s\n",
856 compose_str = g_strdup("compose_attach\n");
858 fd_write_all(uxsock, compose_str, strlen(compose_str));
861 for (i = 0; i < cmd.attach_files->len; i++) {
862 str = g_ptr_array_index(cmd.attach_files, i);
863 fd_write_all(uxsock, str, strlen(str));
864 fd_write_all(uxsock, "\n", 1);
867 fd_write_all(uxsock, ".\n", 2);
868 } else if (cmd.compose) {
871 if (cmd.compose_mailto)
872 compose_str = g_strdup_printf
873 ("compose %s\n", cmd.compose_mailto);
875 compose_str = g_strdup("compose\n");
877 fd_write_all(uxsock, compose_str, strlen(compose_str));
879 } else if (cmd.send) {
880 fd_write_all(uxsock, "send\n", 5);
881 } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
882 fd_write(uxsock, "online\n", 6);
883 } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
884 fd_write(uxsock, "offline\n", 7);
885 } else if (cmd.status || cmd.status_full) {
888 const gchar *command;
892 command = cmd.status_full ? "status-full\n" : "status\n";
893 folders = cmd.status_full ? cmd.status_full_folders :
896 fd_write_all(uxsock, command, strlen(command));
897 for (i = 0; folders && i < folders->len; ++i) {
898 folder = g_ptr_array_index(folders, i);
899 fd_write_all(uxsock, folder, strlen(folder));
900 fd_write_all(uxsock, "\n", 1);
902 fd_write_all(uxsock, ".\n", 2);
904 fd_gets(uxsock, buf, sizeof(buf));
905 if (!strncmp(buf, ".\n", 2)) break;
909 fd_write_all(uxsock, "popup\n", 6);
915 static gint lock_socket_remove(void)
920 if (lock_socket < 0) return -1;
922 if (lock_socket_tag > 0)
923 gdk_input_remove(lock_socket_tag);
924 fd_close(lock_socket);
925 filename = get_socket_name();
932 static GPtrArray *get_folder_item_list(gint sock)
936 GPtrArray *folders = NULL;
939 fd_gets(sock, buf, sizeof(buf));
940 if (!strncmp(buf, ".\n", 2)) break;
942 if (!folders) folders = g_ptr_array_new();
943 item = folder_find_item_from_identifier(buf);
945 g_ptr_array_add(folders, item);
947 g_warning("no such folder: %s\n", buf);
953 static void lock_socket_input_cb(gpointer data,
955 GdkInputCondition condition)
957 MainWindow *mainwin = (MainWindow *)data;
961 sock = fd_accept(source);
962 fd_gets(sock, buf, sizeof(buf));
964 if (!strncmp(buf, "popup", 5)) {
965 main_window_popup(mainwin);
966 } else if (!strncmp(buf, "receive_all", 11)) {
967 inc_all_account_mail(mainwin, FALSE,
968 prefs_common.newmail_notify_manu);
969 } else if (!strncmp(buf, "receive", 7)) {
970 inc_mail(mainwin, prefs_common.newmail_notify_manu);
971 } else if (!strncmp(buf, "compose_attach", 14)) {
975 mailto = g_strdup(buf + strlen("compose_attach") + 1);
976 files = g_ptr_array_new();
977 while (fd_gets(sock, buf, sizeof(buf)) > 0) {
978 if (buf[0] == '.' && buf[1] == '\n') break;
980 g_ptr_array_add(files, g_strdup(buf));
982 open_compose_new(mailto, files);
983 ptr_array_free_strings(files);
984 g_ptr_array_free(files, TRUE);
986 } else if (!strncmp(buf, "compose", 7)) {
987 open_compose_new(buf + strlen("compose") + 1, NULL);
988 } else if (!strncmp(buf, "send", 4)) {
990 } else if (!strncmp(buf, "online", 6)) {
991 main_window_toggle_work_offline(mainwin, FALSE);
992 } else if (!strncmp(buf, "offline", 7)) {
993 main_window_toggle_work_offline(mainwin, TRUE);
994 } else if (!strncmp(buf, "status-full", 11) ||
995 !strncmp(buf, "status", 6)) {
999 folders = get_folder_item_list(sock);
1000 status = folder_get_status
1001 (folders, !strncmp(buf, "status-full", 11));
1002 fd_write_all(sock, status, strlen(status));
1003 fd_write_all(sock, ".\n", 2);
1005 if (folders) g_ptr_array_free(folders, TRUE);
1011 static void open_compose_new(const gchar *address, GPtrArray *attach_files)
1016 Xstrdup_a(addr, address, return);
1020 compose_new(NULL, addr, attach_files);
1023 static void send_queue(void)
1027 for (list = folder_get_list(); list != NULL; list = list->next) {
1028 Folder *folder = list->data;
1030 if (folder->queue) {
1031 gint res = procmsg_send_queue
1032 (folder->queue, prefs_common.savemsg);
1035 alertpanel_error(_("Some errors occurred while sending queued messages."));
1037 folder_item_scan(folder->queue);
1042 static void quit_signal_handler(int sig)
1044 debug_print("Quitting on signal %d\n", sig);
1046 g_timeout_add(0, clean_quit, NULL);
1049 static void install_basic_sighandlers()
1052 struct sigaction act;
1057 sigaddset(&mask, SIGTERM);
1060 sigaddset(&mask, SIGINT);
1063 sigaddset(&mask, SIGHUP);
1066 act.sa_handler = quit_signal_handler;
1071 sigaction(SIGTERM, &act, 0);
1074 sigaction(SIGINT, &act, 0);
1077 sigaction(SIGHUP, &act, 0);
1080 sigprocmask(SIG_UNBLOCK, &mask, 0);