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>
41 #ifdef HAVE_STARTUP_NOTIFICATION
42 # define SN_API_NOT_YET_FROZEN
43 # include <libsn/sn-launchee.h>
44 # include <gdk/gdkx.h>
49 #include "mainwindow.h"
50 #include "folderview.h"
51 #include "image_viewer.h"
52 #include "summaryview.h"
53 #include "prefs_common.h"
54 #include "prefs_account.h"
55 #include "prefs_actions.h"
56 #include "prefs_ext_prog.h"
57 #include "prefs_fonts.h"
58 #include "prefs_image_viewer.h"
59 #include "prefs_message.h"
60 #include "prefs_receive.h"
61 #include "prefs_msg_colors.h"
62 #include "prefs_quote.h"
63 #include "prefs_spelling.h"
64 #include "prefs_summaries.h"
65 #include "prefs_themes.h"
66 #include "prefs_other.h"
67 #include "prefs_send.h"
68 #include "prefs_wrapping.h"
69 #include "prefs_compose_writing.h"
70 #include "prefs_display_header.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "addressbook.h"
86 #include "prefs_toolbar.h"
106 #ifdef HAVE_STARTUP_NOTIFICATION
107 static SnLauncheeContext *sn_context = NULL;
108 static SnDisplay *sn_display = NULL;
111 static gint lock_socket = -1;
112 static gint lock_socket_tag = 0;
116 ONLINE_MODE_DONT_CHANGE,
121 static struct RemoteCmd {
123 gboolean receive_all;
125 const gchar *compose_mailto;
126 GPtrArray *attach_files;
128 gboolean status_full;
129 GPtrArray *status_folders;
130 GPtrArray *status_full_folders;
137 static void parse_cmd_opt(int argc, char *argv[]);
139 static gint prohibit_duplicate_launch (void);
140 static gchar * get_crashfile_name (void);
141 static gint lock_socket_remove (void);
142 static void lock_socket_input_cb (gpointer data,
144 GdkInputCondition condition);
148 gchar *get_socket_name (void);
151 static void open_compose_new (const gchar *address,
152 GPtrArray *attach_files);
154 static void send_queue (void);
155 static void initial_processing (FolderItem *item, gpointer data);
156 static void quit_signal_handler (int sig);
157 static void install_basic_sighandlers (void);
158 static void exit_sylpheed (MainWindow *mainwin);
160 #define MAKE_DIR_IF_NOT_EXIST(dir) \
162 if (!is_dir_exist(dir)) { \
163 if (is_file_exist(dir)) { \
165 (_("File `%s' already exists.\n" \
166 "Can't create folder."), \
170 if (make_dir(dir) < 0) \
175 static MainWindow *static_mainwindow;
177 #ifdef HAVE_STARTUP_NOTIFICATION
178 static void sn_error_trap_push(SnDisplay *display, Display *xdisplay)
180 gdk_error_trap_push();
183 static void sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
185 gdk_error_trap_pop();
188 static void startup_notification_complete(gboolean with_window)
191 GtkWidget *hack = NULL;
194 /* this is needed to make the startup notification leave,
195 * if we have been launched from a menu.
196 * We have to display a window, so let it be very little */
197 hack = gtk_window_new(GTK_WINDOW_POPUP);
198 gtk_widget_set_uposition(hack, 0, 0);
199 gtk_widget_set_size_request(hack, 1, 1);
200 gtk_widget_show(hack);
203 xdisplay = GDK_DISPLAY();
204 sn_display = sn_display_new(xdisplay,
207 sn_context = sn_launchee_context_new_from_environment(sn_display,
208 DefaultScreen(xdisplay));
210 if (sn_context != NULL)
212 sn_launchee_context_complete(sn_context);
213 sn_launchee_context_unref(sn_context);
214 sn_display_unref(sn_display);
217 #endif /* HAVE_STARTUP_NOTIFICATION */
219 void sylpheed_gtk_idle(void)
221 while(gtk_events_pending())
222 gtk_main_iteration();
225 int main(int argc, char *argv[])
229 FolderView *folderview;
231 if (!sylpheed_init(&argc, &argv)) {
235 prog_version = PROG_VERSION;
237 argv0 = g_strdup(argv[0]);
240 parse_cmd_opt(argc, argv);
245 gtk_init(&argc, &argv);
246 crash_main(cmd.crash_params);
249 crash_install_handlers();
251 install_basic_sighandlers();
253 /* check and create unix domain socket */
254 lock_socket = prohibit_duplicate_launch();
255 if (lock_socket < 0) {
256 #ifdef HAVE_STARTUP_NOTIFICATION
257 if(gtk_init_check(&argc, &argv))
258 startup_notification_complete(TRUE);
263 if (cmd.status || cmd.status_full) {
264 puts("0 Sylpheed not running.");
265 lock_socket_remove();
270 /* gdk_threads_init(); */
273 gtk_init(&argc, &argv);
276 gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
277 gtk_widget_set_default_visual(gdk_rgb_get_visual());
279 if (!g_thread_supported())
280 g_error(_("g_thread is not supported by glib.\n"));
282 /* parse gtkrc files */
283 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc-2.0",
285 gtk_rc_parse(userrc);
287 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
288 G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
289 gtk_rc_parse(userrc);
291 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
292 gtk_rc_parse(userrc);
295 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
296 gtk_accel_map_load (userrc);
299 gtk_settings_set_long_property(gtk_settings_get_default(),
300 "gtk-can-change-accels",
301 (glong)TRUE, "XProperty");
303 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
305 MAKE_DIR_IF_NOT_EXIST(RC_DIR);
306 MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
307 MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
308 MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
309 MAKE_DIR_IF_NOT_EXIST(get_tmp_dir());
310 MAKE_DIR_IF_NOT_EXIST(RC_DIR G_DIR_SEPARATOR_S "uidl");
312 set_log_file(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log");
314 folder_system_init();
315 prefs_common_read_config();
319 prefs_ext_prog_init();
320 prefs_wrapping_init();
321 prefs_compose_writing_init();
322 prefs_msg_colors_init();
324 prefs_image_viewer_init();
326 prefs_summaries_init();
327 prefs_message_init();
329 prefs_receive_init();
332 gtkaspell_checkers_init();
333 prefs_spelling_init();
336 sock_set_io_timeout(prefs_common.io_timeout_secs);
338 prefs_actions_read_config();
339 prefs_display_header_read_config();
340 /* prefs_filtering_read_config(); */
341 addressbook_read_file();
342 renderer_read_config();
346 folderview_initialize();
351 mainwin = main_window_create
352 (prefs_common.sep_folder | prefs_common.sep_msg << 1);
353 folderview = mainwin->folderview;
355 /* register the callback of unix domain socket input */
356 lock_socket_tag = gdk_input_add(lock_socket,
357 GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
358 lock_socket_input_cb,
361 prefs_account_init();
362 account_read_config_all();
364 if (folder_read_list() < 0) {
365 if (!run_wizard(mainwin, TRUE))
370 if (!account_get_list()) {
371 if (!run_wizard(mainwin, FALSE))
373 account_read_config_all();
374 if(!account_get_list())
375 exit_sylpheed(mainwin);
378 account_set_missing_folder();
379 folder_set_missing_folders();
380 folderview_set(folderview);
382 prefs_matcher_read_config();
384 /* make one all-folder processing before using sylpheed */
385 main_window_cursor_wait(mainwin);
386 folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
387 main_window_cursor_normal(mainwin);
389 /* if Sylpheed crashed, rebuild caches */
390 if (!cmd.crash && is_file_exist(get_crashfile_name())) {
391 debug_print("Sylpheed crashed, checking for new messages in local folders\n");
392 folderview_check_new(NULL);
394 /* make the crash-indicator file */
395 str_write_to_file("foo", get_crashfile_name());
397 addressbook_read_file();
399 inc_autocheck_timer_init(mainwin);
401 /* ignore SIGPIPE signal for preventing sudden death of program */
402 signal(SIGPIPE, SIG_IGN);
404 if (cmd.online_mode == ONLINE_MODE_OFFLINE)
405 main_window_toggle_work_offline(mainwin, TRUE);
406 if (cmd.online_mode == ONLINE_MODE_ONLINE)
407 main_window_toggle_work_offline(mainwin, FALSE);
409 if (cmd.status_folders) {
410 g_ptr_array_free(cmd.status_folders, TRUE);
411 cmd.status_folders = NULL;
413 if (cmd.status_full_folders) {
414 g_ptr_array_free(cmd.status_full_folders, TRUE);
415 cmd.status_full_folders = NULL;
418 sylpheed_register_idle_function(sylpheed_gtk_idle);
420 prefs_toolbar_init();
422 plugin_load_all("GTK2");
424 static_mainwindow = mainwin;
426 #ifdef HAVE_STARTUP_NOTIFICATION
427 startup_notification_complete(FALSE);
431 inc_all_account_mail(mainwin, FALSE,
432 prefs_common.newmail_notify_manu);
433 else if (prefs_common.chk_on_startup)
434 inc_all_account_mail(mainwin, TRUE,
435 prefs_common.newmail_notify_manu);
436 else if (cmd.receive)
437 inc_mail(mainwin, prefs_common.newmail_notify_manu);
439 gtk_widget_grab_focus(folderview->ctree);
442 open_compose_new(cmd.compose_mailto, cmd.attach_files);
443 if (cmd.attach_files) {
444 ptr_array_free_strings(cmd.attach_files);
445 g_ptr_array_free(cmd.attach_files, TRUE);
446 cmd.attach_files = NULL;
453 exit_sylpheed(mainwin);
458 static void save_all_caches(FolderItem *item, gpointer data)
462 folder_item_write_cache(item);
465 static void exit_sylpheed(MainWindow *mainwin)
469 debug_print("shutting down\n");
471 inc_autocheck_timer_remove();
473 if (prefs_common.clean_on_exit)
474 main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
476 /* save prefs for opened folder */
477 if(mainwin->folderview->opened)
481 item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
482 summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
485 /* save all state before exiting */
487 folder_func_to_all_folders(save_all_caches, NULL);
489 main_window_get_size(mainwin);
490 main_window_get_position(mainwin);
491 prefs_common_write_config();
492 account_write_config_all();
493 addressbook_export_to_file();
495 filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
496 gtk_accel_map_save(filename);
499 /* delete temporary files */
500 remove_all_files(get_tmp_dir());
501 remove_all_files(get_mime_tmp_dir());
505 /* delete crashfile */
507 unlink(get_crashfile_name());
509 lock_socket_remove();
511 main_window_destroy(mainwin);
513 plugin_unload_all("GTK2");
515 prefs_toolbar_done();
517 addressbook_destroy();
521 prefs_ext_prog_done();
522 prefs_wrapping_done();
523 prefs_compose_writing_done();
524 prefs_msg_colors_done();
525 prefs_image_viewer_done();
528 prefs_summaries_done();
529 prefs_message_done();
531 prefs_receive_done();
534 prefs_spelling_done();
535 gtkaspell_checkers_quit();
541 static void parse_cmd_opt(int argc, char *argv[])
545 for (i = 1; i < argc; i++) {
546 if (!strncmp(argv[i], "--receive-all", 13))
547 cmd.receive_all = TRUE;
548 else if (!strncmp(argv[i], "--receive", 9))
550 else if (!strncmp(argv[i], "--compose", 9)) {
551 const gchar *p = argv[i + 1];
554 cmd.compose_mailto = NULL;
555 if (p && *p != '\0' && *p != '-') {
556 if (!strncmp(p, "mailto:", 7))
557 cmd.compose_mailto = p + 7;
559 cmd.compose_mailto = p;
562 } else if (!strncmp(argv[i], "--attach", 8)) {
563 const gchar *p = argv[i + 1];
566 while (p && *p != '\0' && *p != '-') {
567 if (!cmd.attach_files)
568 cmd.attach_files = g_ptr_array_new();
569 if (*p != G_DIR_SEPARATOR)
570 file = g_strconcat(sylpheed_get_startup_dir(),
575 g_ptr_array_add(cmd.attach_files, file);
579 } else if (!strncmp(argv[i], "--send", 6)) {
581 } else if (!strncmp(argv[i], "--version", 9)) {
582 puts("Sylpheed version " VERSION);
584 } else if (!strncmp(argv[i], "--status-full", 13)) {
585 const gchar *p = argv[i + 1];
587 cmd.status_full = TRUE;
588 while (p && *p != '\0' && *p != '-') {
589 if (!cmd.status_full_folders)
590 cmd.status_full_folders =
592 g_ptr_array_add(cmd.status_full_folders,
597 } else if (!strncmp(argv[i], "--status", 8)) {
598 const gchar *p = argv[i + 1];
601 while (p && *p != '\0' && *p != '-') {
602 if (!cmd.status_folders)
603 cmd.status_folders = g_ptr_array_new();
604 g_ptr_array_add(cmd.status_folders,
609 } else if (!strncmp(argv[i], "--online", 8)) {
610 cmd.online_mode = ONLINE_MODE_ONLINE;
611 } else if (!strncmp(argv[i], "--offline", 9)) {
612 cmd.online_mode = ONLINE_MODE_OFFLINE;
613 } else if (!strncmp(argv[i], "--help", 6)) {
614 gchar *base = g_path_get_basename(argv[0]);
615 g_print(_("Usage: %s [OPTION]...\n"), base);
617 g_print("%s\n", _(" --compose [address] open composition window"));
618 g_print("%s\n", _(" --attach file1 [file2]...\n"
619 " open composition window with specified files\n"
621 g_print("%s\n", _(" --receive receive new messages"));
622 g_print("%s\n", _(" --receive-all receive new messages of all accounts"));
623 g_print("%s\n", _(" --send send all queued messages"));
624 g_print("%s\n", _(" --status [folder]... show the total number of messages"));
625 g_print("%s\n", _(" --status-full [folder]...\n"
626 " show the status of each folder"));
627 g_print("%s\n", _(" --online switch to online mode"));
628 g_print("%s\n", _(" --offline switch to offline mode"));
629 g_print("%s\n", _(" --debug debug mode"));
630 g_print("%s\n", _(" --help display this help and exit"));
631 g_print("%s\n", _(" --version output version information and exit"));
632 g_print("%s\n", _(" --config-dir output configuration directory"));
636 } else if (!strncmp(argv[i], "--crash", 7)) {
638 cmd.crash_params = g_strdup(argv[i + 1]);
640 } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
647 if (cmd.attach_files && cmd.compose == FALSE) {
649 cmd.compose_mailto = NULL;
653 static gint get_queued_message_num(void)
657 queue = folder_get_default_queue();
658 if (!queue) return -1;
660 folder_item_scan(queue);
661 return queue->total_msgs;
664 static void initial_processing(FolderItem *item, gpointer data)
666 MainWindow *mainwin = (MainWindow *)data;
669 g_return_if_fail(item);
670 buf = g_strdup_printf(_("Processing (%s)..."),
673 : _("top level folder"));
674 debug_print("%s\n", buf);
678 if (item->prefs->enable_processing)
679 folder_item_apply_processing(item);
681 debug_print("done.\n");
682 STATUSBAR_POP(mainwin);
685 static void draft_all_messages(void)
687 GList *compose_list = NULL;
689 while ((compose_list = compose_get_compose_list()) != NULL) {
690 Compose *c = (Compose*)compose_list->data;
695 gboolean clean_quit(gpointer data)
697 static gboolean firstrun = TRUE;
703 /*!< Good idea to have the main window stored in a
704 * static variable so we can check that variable
705 * to see if we're really allowed to do things
706 * that actually the spawner is supposed to
707 * do (like: sending mail, composing messages).
708 * Because, really, if we're the spawnee, and
709 * we touch GTK stuff, we're hosed. See the
712 /* FIXME: Use something else to signal that we're
713 * in the original spawner, and not in a spawned
715 if (!static_mainwindow)
718 draft_all_messages();
720 exit_sylpheed(static_mainwindow);
726 void app_will_exit(GtkWidget *widget, gpointer data)
728 MainWindow *mainwin = data;
730 if (compose_get_compose_list()) {
731 gint val = alertpanel(_("Really quit?"),
732 _("Composing message exists."),
733 _("Draft them"), _("Discard them"), _("Don't quit"));
737 case G_ALERTALTERNATE:
740 draft_all_messages();
743 manage_window_focus_in(mainwin->window, NULL, NULL);
746 if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
747 if (alertpanel(_("Queued messages"),
748 _("Some unsent messages are queued. Exit now?"),
749 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
752 manage_window_focus_in(mainwin->window, NULL, NULL);
758 * CLAWS: want this public so crash dialog can delete the
764 gchar *get_socket_name(void)
766 static gchar *filename = NULL;
768 if (filename == NULL) {
769 filename = g_strdup_printf("%s%csylpheed-%d",
770 g_get_tmp_dir(), G_DIR_SEPARATOR,
777 static gchar *get_crashfile_name(void)
779 static gchar *filename = NULL;
781 if (filename == NULL) {
782 filename = g_strdup_printf("%s%csylpheed-crashed",
783 get_tmp_dir(), G_DIR_SEPARATOR);
789 static gint prohibit_duplicate_launch(void)
794 path = get_socket_name();
795 uxsock = fd_connect_unix(path);
798 return fd_open_unix(path);
801 /* remote command mode */
803 debug_print("another Sylpheed is already running.\n");
806 fd_write_all(uxsock, "receive_all\n", 12);
807 else if (cmd.receive)
808 fd_write_all(uxsock, "receive\n", 8);
809 else if (cmd.compose && cmd.attach_files) {
810 gchar *str, *compose_str;
813 if (cmd.compose_mailto)
814 compose_str = g_strdup_printf("compose_attach %s\n",
817 compose_str = g_strdup("compose_attach\n");
819 fd_write_all(uxsock, compose_str, strlen(compose_str));
822 for (i = 0; i < cmd.attach_files->len; i++) {
823 str = g_ptr_array_index(cmd.attach_files, i);
824 fd_write_all(uxsock, str, strlen(str));
825 fd_write_all(uxsock, "\n", 1);
828 fd_write_all(uxsock, ".\n", 2);
829 } else if (cmd.compose) {
832 if (cmd.compose_mailto)
833 compose_str = g_strdup_printf
834 ("compose %s\n", cmd.compose_mailto);
836 compose_str = g_strdup("compose\n");
838 fd_write_all(uxsock, compose_str, strlen(compose_str));
840 } else if (cmd.send) {
841 fd_write_all(uxsock, "send\n", 5);
842 } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
843 fd_write(uxsock, "online\n", 6);
844 } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
845 fd_write(uxsock, "offline\n", 7);
846 } else if (cmd.status || cmd.status_full) {
849 const gchar *command;
853 command = cmd.status_full ? "status-full\n" : "status\n";
854 folders = cmd.status_full ? cmd.status_full_folders :
857 fd_write_all(uxsock, command, strlen(command));
858 for (i = 0; folders && i < folders->len; ++i) {
859 folder = g_ptr_array_index(folders, i);
860 fd_write_all(uxsock, folder, strlen(folder));
861 fd_write_all(uxsock, "\n", 1);
863 fd_write_all(uxsock, ".\n", 2);
865 fd_gets(uxsock, buf, sizeof(buf));
866 if (!strncmp(buf, ".\n", 2)) break;
870 fd_write_all(uxsock, "popup\n", 6);
876 static gint lock_socket_remove(void)
880 if (lock_socket < 0) return -1;
882 if (lock_socket_tag > 0)
883 gdk_input_remove(lock_socket_tag);
884 fd_close(lock_socket);
885 filename = get_socket_name();
891 static GPtrArray *get_folder_item_list(gint sock)
895 GPtrArray *folders = NULL;
898 fd_gets(sock, buf, sizeof(buf));
899 if (!strncmp(buf, ".\n", 2)) break;
901 if (!folders) folders = g_ptr_array_new();
902 item = folder_find_item_from_identifier(buf);
904 g_ptr_array_add(folders, item);
906 g_warning("no such folder: %s\n", buf);
912 static void lock_socket_input_cb(gpointer data,
914 GdkInputCondition condition)
916 MainWindow *mainwin = (MainWindow *)data;
920 sock = fd_accept(source);
921 fd_gets(sock, buf, sizeof(buf));
923 if (!strncmp(buf, "popup", 5)) {
924 main_window_popup(mainwin);
925 } else if (!strncmp(buf, "receive_all", 11)) {
926 inc_all_account_mail(mainwin, FALSE,
927 prefs_common.newmail_notify_manu);
928 } else if (!strncmp(buf, "receive", 7)) {
929 inc_mail(mainwin, prefs_common.newmail_notify_manu);
930 } else if (!strncmp(buf, "compose_attach", 14)) {
934 mailto = g_strdup(buf + strlen("compose_attach") + 1);
935 files = g_ptr_array_new();
936 while (fd_gets(sock, buf, sizeof(buf)) > 0) {
937 if (buf[0] == '.' && buf[1] == '\n') break;
939 g_ptr_array_add(files, g_strdup(buf));
941 open_compose_new(mailto, files);
942 ptr_array_free_strings(files);
943 g_ptr_array_free(files, TRUE);
945 } else if (!strncmp(buf, "compose", 7)) {
946 open_compose_new(buf + strlen("compose") + 1, NULL);
947 } else if (!strncmp(buf, "send", 4)) {
949 } else if (!strncmp(buf, "online", 6)) {
950 main_window_toggle_work_offline(mainwin, FALSE);
951 } else if (!strncmp(buf, "offline", 7)) {
952 main_window_toggle_work_offline(mainwin, TRUE);
953 } else if (!strncmp(buf, "status-full", 11) ||
954 !strncmp(buf, "status", 6)) {
958 folders = get_folder_item_list(sock);
959 status = folder_get_status
960 (folders, !strncmp(buf, "status-full", 11));
961 fd_write_all(sock, status, strlen(status));
962 fd_write_all(sock, ".\n", 2);
964 if (folders) g_ptr_array_free(folders, TRUE);
970 static void open_compose_new(const gchar *address, GPtrArray *attach_files)
975 Xstrdup_a(addr, address, return);
979 compose_new(NULL, addr, attach_files);
982 static void send_queue(void)
986 for (list = folder_get_list(); list != NULL; list = list->next) {
987 Folder *folder = list->data;
990 gint res = procmsg_send_queue
991 (folder->queue, prefs_common.savemsg);
994 alertpanel_error(_("Some errors occurred while sending queued messages."));
996 folder_item_scan(folder->queue);
1001 static void quit_signal_handler(int sig)
1003 debug_print("Quitting on signal %d\n", sig);
1005 g_timeout_add(0, clean_quit, NULL);
1008 static void install_basic_sighandlers()
1011 struct sigaction act;
1016 sigaddset(&mask, SIGTERM);
1019 sigaddset(&mask, SIGINT);
1022 sigaddset(&mask, SIGHUP);
1025 act.sa_handler = quit_signal_handler;
1030 sigaction(SIGTERM, &act, 0);
1033 sigaction(SIGINT, &act, 0);
1036 sigaction(SIGHUP, &act, 0);
1039 sigprocmask(SIG_UNBLOCK, &mask, 0);