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"
93 #include "imap-thread.h"
95 #include "stock_pixmap.h"
110 #ifdef HAVE_STARTUP_NOTIFICATION
111 static SnLauncheeContext *sn_context = NULL;
112 static SnDisplay *sn_display = NULL;
115 static gint lock_socket = -1;
116 static gint lock_socket_tag = 0;
120 ONLINE_MODE_DONT_CHANGE,
125 static struct RemoteCmd {
127 gboolean receive_all;
129 const gchar *compose_mailto;
130 GPtrArray *attach_files;
132 gboolean status_full;
133 GPtrArray *status_folders;
134 GPtrArray *status_full_folders;
141 static void parse_cmd_opt(int argc, char *argv[]);
143 static gint prohibit_duplicate_launch (void);
144 static gchar * get_crashfile_name (void);
145 static gint lock_socket_remove (void);
146 static void lock_socket_input_cb (gpointer data,
148 GdkInputCondition condition);
152 gchar *get_socket_name (void);
155 static void open_compose_new (const gchar *address,
156 GPtrArray *attach_files);
158 static void send_queue (void);
159 static void initial_processing (FolderItem *item, gpointer data);
160 static void quit_signal_handler (int sig);
161 static void install_basic_sighandlers (void);
162 static void exit_sylpheed (MainWindow *mainwin);
164 #define MAKE_DIR_IF_NOT_EXIST(dir) \
166 if (!is_dir_exist(dir)) { \
167 if (is_file_exist(dir)) { \
169 (_("File '%s' already exists.\n" \
170 "Can't create folder."), \
174 if (make_dir(dir) < 0) \
179 static MainWindow *static_mainwindow;
181 #ifdef HAVE_STARTUP_NOTIFICATION
182 static void sn_error_trap_push(SnDisplay *display, Display *xdisplay)
184 gdk_error_trap_push();
187 static void sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
189 gdk_error_trap_pop();
192 static void startup_notification_complete(gboolean with_window)
195 GtkWidget *hack = NULL;
198 /* this is needed to make the startup notification leave,
199 * if we have been launched from a menu.
200 * We have to display a window, so let it be very little */
201 hack = gtk_window_new(GTK_WINDOW_POPUP);
202 gtk_widget_set_uposition(hack, 0, 0);
203 gtk_widget_set_size_request(hack, 1, 1);
204 gtk_widget_show(hack);
207 xdisplay = GDK_DISPLAY();
208 sn_display = sn_display_new(xdisplay,
211 sn_context = sn_launchee_context_new_from_environment(sn_display,
212 DefaultScreen(xdisplay));
214 if (sn_context != NULL)
216 sn_launchee_context_complete(sn_context);
217 sn_launchee_context_unref(sn_context);
218 sn_display_unref(sn_display);
221 #endif /* HAVE_STARTUP_NOTIFICATION */
223 void sylpheed_gtk_idle(void)
225 while(gtk_events_pending())
226 gtk_main_iteration();
229 int main(int argc, char *argv[])
233 FolderView *folderview;
236 if (!sylpheed_init(&argc, &argv)) {
240 prog_version = PROG_VERSION;
242 argv0 = g_strdup(argv[0]);
245 parse_cmd_opt(argc, argv);
250 gtk_init(&argc, &argv);
251 crash_main(cmd.crash_params);
254 crash_install_handlers();
256 install_basic_sighandlers();
258 /* check and create unix domain socket */
259 lock_socket = prohibit_duplicate_launch();
260 if (lock_socket < 0) {
261 #ifdef HAVE_STARTUP_NOTIFICATION
262 if(gtk_init_check(&argc, &argv))
263 startup_notification_complete(TRUE);
268 if (cmd.status || cmd.status_full) {
269 puts("0 Sylpheed not running.");
270 lock_socket_remove();
275 /* gdk_threads_init(); */
278 gtk_init(&argc, &argv);
281 gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
282 gtk_widget_set_default_visual(gdk_rgb_get_visual());
284 if (!g_thread_supported())
285 g_error(_("g_thread is not supported by glib.\n"));
287 /* parse gtkrc files */
288 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc-2.0",
290 gtk_rc_parse(userrc);
292 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
293 G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
294 gtk_rc_parse(userrc);
296 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
297 gtk_rc_parse(userrc);
300 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
301 gtk_accel_map_load (userrc);
304 gtk_settings_set_long_property(gtk_settings_get_default(),
305 "gtk-can-change-accels",
306 (glong)TRUE, "XProperty");
308 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
310 MAKE_DIR_IF_NOT_EXIST(RC_DIR);
311 MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
312 MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
313 MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
314 MAKE_DIR_IF_NOT_EXIST(get_tmp_dir());
315 MAKE_DIR_IF_NOT_EXIST(RC_DIR G_DIR_SEPARATOR_S "uidl");
317 set_log_file(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log");
319 folder_system_init();
320 prefs_common_read_config();
324 prefs_ext_prog_init();
325 prefs_wrapping_init();
326 prefs_compose_writing_init();
327 prefs_msg_colors_init();
329 prefs_image_viewer_init();
331 prefs_summaries_init();
332 prefs_message_init();
334 prefs_receive_init();
337 gtkaspell_checkers_init();
338 prefs_spelling_init();
341 sock_set_io_timeout(prefs_common.io_timeout_secs);
343 imap_main_set_timeout(prefs_common.io_timeout_secs);
345 prefs_actions_read_config();
346 prefs_display_header_read_config();
347 /* prefs_filtering_read_config(); */
348 addressbook_read_file();
349 renderer_read_config();
352 stock_pixbuf_gdk(NULL, STOCK_PIXMAP_SYLPHEED_ICON, &icon);
353 gtk_window_set_default_icon(icon);
355 folderview_initialize();
360 mainwin = main_window_create
361 (prefs_common.sep_folder | prefs_common.sep_msg << 1);
362 folderview = mainwin->folderview;
364 /* register the callback of unix domain socket input */
365 lock_socket_tag = gdk_input_add(lock_socket,
366 GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
367 lock_socket_input_cb,
370 prefs_account_init();
371 account_read_config_all();
373 if (folder_read_list() < 0) {
374 if (!run_wizard(mainwin, TRUE))
379 if (!account_get_list()) {
380 if (!run_wizard(mainwin, FALSE))
382 account_read_config_all();
383 if(!account_get_list())
384 exit_sylpheed(mainwin);
390 account_set_missing_folder();
391 folder_set_missing_folders();
392 folderview_set(folderview);
394 prefs_matcher_read_config();
396 /* make one all-folder processing before using sylpheed */
397 main_window_cursor_wait(mainwin);
398 folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
399 main_window_cursor_normal(mainwin);
401 /* if Sylpheed crashed, rebuild caches */
402 if (!cmd.crash && is_file_exist(get_crashfile_name())) {
403 debug_print("Sylpheed crashed, checking for new messages in local folders\n");
404 folderview_check_new(NULL);
405 folder_clean_cache_memory_force();
407 /* make the crash-indicator file */
408 str_write_to_file("foo", get_crashfile_name());
410 addressbook_read_file();
412 inc_autocheck_timer_init(mainwin);
414 /* ignore SIGPIPE signal for preventing sudden death of program */
415 signal(SIGPIPE, SIG_IGN);
417 if (cmd.online_mode == ONLINE_MODE_OFFLINE)
418 main_window_toggle_work_offline(mainwin, TRUE);
419 if (cmd.online_mode == ONLINE_MODE_ONLINE)
420 main_window_toggle_work_offline(mainwin, FALSE);
422 if (cmd.status_folders) {
423 g_ptr_array_free(cmd.status_folders, TRUE);
424 cmd.status_folders = NULL;
426 if (cmd.status_full_folders) {
427 g_ptr_array_free(cmd.status_full_folders, TRUE);
428 cmd.status_full_folders = NULL;
431 sylpheed_register_idle_function(sylpheed_gtk_idle);
433 prefs_toolbar_init();
435 plugin_load_all("GTK2");
437 static_mainwindow = mainwin;
439 #ifdef HAVE_STARTUP_NOTIFICATION
440 startup_notification_complete(FALSE);
444 inc_all_account_mail(mainwin, FALSE,
445 prefs_common.newmail_notify_manu);
446 else if (prefs_common.chk_on_startup)
447 inc_all_account_mail(mainwin, TRUE,
448 prefs_common.newmail_notify_manu);
449 else if (cmd.receive)
450 inc_mail(mainwin, prefs_common.newmail_notify_manu);
452 gtk_widget_grab_focus(folderview->ctree);
455 open_compose_new(cmd.compose_mailto, cmd.attach_files);
456 if (cmd.attach_files) {
457 ptr_array_free_strings(cmd.attach_files);
458 g_ptr_array_free(cmd.attach_files, TRUE);
459 cmd.attach_files = NULL;
466 exit_sylpheed(mainwin);
471 static void save_all_caches(FolderItem *item, gpointer data)
475 folder_item_write_cache(item);
478 static void exit_sylpheed(MainWindow *mainwin)
482 debug_print("shutting down\n");
483 inc_autocheck_timer_remove();
485 if (prefs_common.clean_on_exit)
486 main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
488 /* save prefs for opened folder */
489 if(mainwin->folderview->opened)
493 item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
494 summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
497 /* save all state before exiting */
499 folder_func_to_all_folders(save_all_caches, NULL);
501 main_window_get_size(mainwin);
502 main_window_get_position(mainwin);
503 prefs_common_write_config();
504 account_write_config_all();
505 addressbook_export_to_file();
507 filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
508 gtk_accel_map_save(filename);
511 /* delete temporary files */
512 remove_all_files(get_tmp_dir());
513 remove_all_files(get_mime_tmp_dir());
520 /* delete crashfile */
522 unlink(get_crashfile_name());
524 lock_socket_remove();
526 main_window_destroy(mainwin);
528 plugin_unload_all("GTK2");
530 prefs_toolbar_done();
532 addressbook_destroy();
536 prefs_ext_prog_done();
537 prefs_wrapping_done();
538 prefs_compose_writing_done();
539 prefs_msg_colors_done();
540 prefs_image_viewer_done();
543 prefs_summaries_done();
544 prefs_message_done();
546 prefs_receive_done();
549 prefs_spelling_done();
550 gtkaspell_checkers_quit();
556 static void parse_cmd_opt(int argc, char *argv[])
560 for (i = 1; i < argc; i++) {
561 if (!strncmp(argv[i], "--receive-all", 13))
562 cmd.receive_all = TRUE;
563 else if (!strncmp(argv[i], "--receive", 9))
565 else if (!strncmp(argv[i], "--compose", 9)) {
566 const gchar *p = argv[i + 1];
569 cmd.compose_mailto = NULL;
570 if (p && *p != '\0' && *p != '-') {
571 if (!strncmp(p, "mailto:", 7))
572 cmd.compose_mailto = p + 7;
574 cmd.compose_mailto = p;
577 } else if (!strncmp(argv[i], "--attach", 8)) {
578 const gchar *p = argv[i + 1];
581 while (p && *p != '\0' && *p != '-') {
582 if (!cmd.attach_files)
583 cmd.attach_files = g_ptr_array_new();
584 if (*p != G_DIR_SEPARATOR)
585 file = g_strconcat(sylpheed_get_startup_dir(),
590 g_ptr_array_add(cmd.attach_files, file);
594 } else if (!strncmp(argv[i], "--send", 6)) {
596 } else if (!strncmp(argv[i], "--version", 9)) {
597 puts("Sylpheed version " VERSION);
599 } else if (!strncmp(argv[i], "--status-full", 13)) {
600 const gchar *p = argv[i + 1];
602 cmd.status_full = TRUE;
603 while (p && *p != '\0' && *p != '-') {
604 if (!cmd.status_full_folders)
605 cmd.status_full_folders =
607 g_ptr_array_add(cmd.status_full_folders,
612 } else if (!strncmp(argv[i], "--status", 8)) {
613 const gchar *p = argv[i + 1];
616 while (p && *p != '\0' && *p != '-') {
617 if (!cmd.status_folders)
618 cmd.status_folders = g_ptr_array_new();
619 g_ptr_array_add(cmd.status_folders,
624 } else if (!strncmp(argv[i], "--online", 8)) {
625 cmd.online_mode = ONLINE_MODE_ONLINE;
626 } else if (!strncmp(argv[i], "--offline", 9)) {
627 cmd.online_mode = ONLINE_MODE_OFFLINE;
628 } else if (!strncmp(argv[i], "--help", 6)) {
629 gchar *base = g_path_get_basename(argv[0]);
630 g_print(_("Usage: %s [OPTION]...\n"), base);
632 g_print("%s\n", _(" --compose [address] open composition window"));
633 g_print("%s\n", _(" --attach file1 [file2]...\n"
634 " open composition window with specified files\n"
636 g_print("%s\n", _(" --receive receive new messages"));
637 g_print("%s\n", _(" --receive-all receive new messages of all accounts"));
638 g_print("%s\n", _(" --send send all queued messages"));
639 g_print("%s\n", _(" --status [folder]... show the total number of messages"));
640 g_print("%s\n", _(" --status-full [folder]...\n"
641 " show the status of each folder"));
642 g_print("%s\n", _(" --online switch to online mode"));
643 g_print("%s\n", _(" --offline switch to offline mode"));
644 g_print("%s\n", _(" --debug debug mode"));
645 g_print("%s\n", _(" --help display this help and exit"));
646 g_print("%s\n", _(" --version output version information and exit"));
647 g_print("%s\n", _(" --config-dir output configuration directory"));
651 } else if (!strncmp(argv[i], "--crash", 7)) {
653 cmd.crash_params = g_strdup(argv[i + 1]);
655 } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
662 if (cmd.attach_files && cmd.compose == FALSE) {
664 cmd.compose_mailto = NULL;
668 static gint get_queued_message_num(void)
672 queue = folder_get_default_queue();
673 if (!queue) return -1;
675 folder_item_scan(queue);
676 return queue->total_msgs;
679 static void initial_processing(FolderItem *item, gpointer data)
681 MainWindow *mainwin = (MainWindow *)data;
684 g_return_if_fail(item);
685 buf = g_strdup_printf(_("Processing (%s)..."),
688 : _("top level folder"));
689 debug_print("%s\n", buf);
693 if (item->prefs->enable_processing)
694 folder_item_apply_processing(item);
696 debug_print("done.\n");
697 STATUSBAR_POP(mainwin);
700 static void draft_all_messages(void)
702 GList *compose_list = NULL;
704 while ((compose_list = compose_get_compose_list()) != NULL) {
705 Compose *c = (Compose*)compose_list->data;
710 gboolean clean_quit(gpointer data)
712 static gboolean firstrun = TRUE;
718 /*!< Good idea to have the main window stored in a
719 * static variable so we can check that variable
720 * to see if we're really allowed to do things
721 * that actually the spawner is supposed to
722 * do (like: sending mail, composing messages).
723 * Because, really, if we're the spawnee, and
724 * we touch GTK stuff, we're hosed. See the
727 /* FIXME: Use something else to signal that we're
728 * in the original spawner, and not in a spawned
730 if (!static_mainwindow)
733 draft_all_messages();
735 exit_sylpheed(static_mainwindow);
741 void app_will_exit(GtkWidget *widget, gpointer data)
743 MainWindow *mainwin = data;
745 if (compose_get_compose_list()) {
746 gint val = alertpanel(_("Really quit?"),
747 _("Composing message exists."),
748 _("Draft them"), _("Discard them"), _("Don't quit"));
752 case G_ALERTALTERNATE:
755 draft_all_messages();
758 manage_window_focus_in(mainwin->window, NULL, NULL);
761 if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
762 if (alertpanel(_("Queued messages"),
763 _("Some unsent messages are queued. Exit now?"),
764 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
767 manage_window_focus_in(mainwin->window, NULL, NULL);
773 * CLAWS: want this public so crash dialog can delete the
779 gchar *get_socket_name(void)
781 static gchar *filename = NULL;
783 if (filename == NULL) {
784 filename = g_strdup_printf("%s%csylpheed-%d",
785 g_get_tmp_dir(), G_DIR_SEPARATOR,
792 static gchar *get_crashfile_name(void)
794 static gchar *filename = NULL;
796 if (filename == NULL) {
797 filename = g_strdup_printf("%s%csylpheed-crashed",
798 get_tmp_dir(), G_DIR_SEPARATOR);
804 static gint prohibit_duplicate_launch(void)
809 path = get_socket_name();
810 uxsock = fd_connect_unix(path);
813 return fd_open_unix(path);
816 /* remote command mode */
818 debug_print("another Sylpheed is already running.\n");
821 fd_write_all(uxsock, "receive_all\n", 12);
822 else if (cmd.receive)
823 fd_write_all(uxsock, "receive\n", 8);
824 else if (cmd.compose && cmd.attach_files) {
825 gchar *str, *compose_str;
828 if (cmd.compose_mailto)
829 compose_str = g_strdup_printf("compose_attach %s\n",
832 compose_str = g_strdup("compose_attach\n");
834 fd_write_all(uxsock, compose_str, strlen(compose_str));
837 for (i = 0; i < cmd.attach_files->len; i++) {
838 str = g_ptr_array_index(cmd.attach_files, i);
839 fd_write_all(uxsock, str, strlen(str));
840 fd_write_all(uxsock, "\n", 1);
843 fd_write_all(uxsock, ".\n", 2);
844 } else if (cmd.compose) {
847 if (cmd.compose_mailto)
848 compose_str = g_strdup_printf
849 ("compose %s\n", cmd.compose_mailto);
851 compose_str = g_strdup("compose\n");
853 fd_write_all(uxsock, compose_str, strlen(compose_str));
855 } else if (cmd.send) {
856 fd_write_all(uxsock, "send\n", 5);
857 } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
858 fd_write(uxsock, "online\n", 6);
859 } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
860 fd_write(uxsock, "offline\n", 7);
861 } else if (cmd.status || cmd.status_full) {
864 const gchar *command;
868 command = cmd.status_full ? "status-full\n" : "status\n";
869 folders = cmd.status_full ? cmd.status_full_folders :
872 fd_write_all(uxsock, command, strlen(command));
873 for (i = 0; folders && i < folders->len; ++i) {
874 folder = g_ptr_array_index(folders, i);
875 fd_write_all(uxsock, folder, strlen(folder));
876 fd_write_all(uxsock, "\n", 1);
878 fd_write_all(uxsock, ".\n", 2);
880 fd_gets(uxsock, buf, sizeof(buf));
881 if (!strncmp(buf, ".\n", 2)) break;
885 fd_write_all(uxsock, "popup\n", 6);
891 static gint lock_socket_remove(void)
895 if (lock_socket < 0) return -1;
897 if (lock_socket_tag > 0)
898 gdk_input_remove(lock_socket_tag);
899 fd_close(lock_socket);
900 filename = get_socket_name();
906 static GPtrArray *get_folder_item_list(gint sock)
910 GPtrArray *folders = NULL;
913 fd_gets(sock, buf, sizeof(buf));
914 if (!strncmp(buf, ".\n", 2)) break;
916 if (!folders) folders = g_ptr_array_new();
917 item = folder_find_item_from_identifier(buf);
919 g_ptr_array_add(folders, item);
921 g_warning("no such folder: %s\n", buf);
927 static void lock_socket_input_cb(gpointer data,
929 GdkInputCondition condition)
931 MainWindow *mainwin = (MainWindow *)data;
935 sock = fd_accept(source);
936 fd_gets(sock, buf, sizeof(buf));
938 if (!strncmp(buf, "popup", 5)) {
939 main_window_popup(mainwin);
940 } else if (!strncmp(buf, "receive_all", 11)) {
941 inc_all_account_mail(mainwin, FALSE,
942 prefs_common.newmail_notify_manu);
943 } else if (!strncmp(buf, "receive", 7)) {
944 inc_mail(mainwin, prefs_common.newmail_notify_manu);
945 } else if (!strncmp(buf, "compose_attach", 14)) {
949 mailto = g_strdup(buf + strlen("compose_attach") + 1);
950 files = g_ptr_array_new();
951 while (fd_gets(sock, buf, sizeof(buf)) > 0) {
952 if (buf[0] == '.' && buf[1] == '\n') break;
954 g_ptr_array_add(files, g_strdup(buf));
956 open_compose_new(mailto, files);
957 ptr_array_free_strings(files);
958 g_ptr_array_free(files, TRUE);
960 } else if (!strncmp(buf, "compose", 7)) {
961 open_compose_new(buf + strlen("compose") + 1, NULL);
962 } else if (!strncmp(buf, "send", 4)) {
964 } else if (!strncmp(buf, "online", 6)) {
965 main_window_toggle_work_offline(mainwin, FALSE);
966 } else if (!strncmp(buf, "offline", 7)) {
967 main_window_toggle_work_offline(mainwin, TRUE);
968 } else if (!strncmp(buf, "status-full", 11) ||
969 !strncmp(buf, "status", 6)) {
973 folders = get_folder_item_list(sock);
974 status = folder_get_status
975 (folders, !strncmp(buf, "status-full", 11));
976 fd_write_all(sock, status, strlen(status));
977 fd_write_all(sock, ".\n", 2);
979 if (folders) g_ptr_array_free(folders, TRUE);
985 static void open_compose_new(const gchar *address, GPtrArray *attach_files)
990 Xstrdup_a(addr, address, return);
994 compose_new(NULL, addr, attach_files);
997 static void send_queue(void)
1001 for (list = folder_get_list(); list != NULL; list = list->next) {
1002 Folder *folder = list->data;
1004 if (folder->queue) {
1005 gint res = procmsg_send_queue
1006 (folder->queue, prefs_common.savemsg);
1009 alertpanel_error(_("Some errors occurred while sending queued messages."));
1011 folder_item_scan(folder->queue);
1016 static void quit_signal_handler(int sig)
1018 debug_print("Quitting on signal %d\n", sig);
1020 g_timeout_add(0, clean_quit, NULL);
1023 static void install_basic_sighandlers()
1026 struct sigaction act;
1031 sigaddset(&mask, SIGTERM);
1034 sigaddset(&mask, SIGINT);
1037 sigaddset(&mask, SIGHUP);
1040 act.sa_handler = quit_signal_handler;
1045 sigaction(SIGTERM, &act, 0);
1048 sigaction(SIGINT, &act, 0);
1051 sigaction(SIGHUP, &act, 0);
1054 sigprocmask(SIG_UNBLOCK, &mask, 0);