#include "prefs_common.h"
#include "prefs_filter.h"
#include "prefs_account.h"
+#include "scoring.h"
+#include "prefs_display_header.h"
#include "account.h"
#include "procmsg.h"
#include "inc.h"
#include "import.h"
+#include "manage_window.h"
#include "alertpanel.h"
#include "addressbook.h"
#include "compose.h"
#include "utils.h"
#include "gtkutils.h"
+#if USE_GPGME
+#include "rfc2015.h"
+#endif /* USE_GPGME */
+
gchar *prog_version;
+gchar *startup_dir;
gboolean debug_mode = FALSE;
static gint lock_socket = -1;
#endif
/* parse gtkrc files */
- userrc = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc",
+ userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc",
NULL);
gtk_rc_parse(userrc);
g_free(userrc);
- userrc = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
+ userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
G_DIR_SEPARATOR_S, "gtkrc", NULL);
gtk_rc_parse(userrc);
g_free(userrc);
g_free(userrc);
prog_version = PROG_VERSION;
+ startup_dir = g_get_current_dir();
parse_cmd_opt(argc, argv);
- CHDIR_RETURN_VAL_IF_FAIL(g_get_home_dir(), 1);
+ CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
/* check and create unix domain socket */
lock_socket = prohibit_duplicate_launch();
srandom((gint)time(NULL));
#if USE_GPGME
+ if (gpgme_check_engine()) { /* Also does some gpgme init */
+ rfc2015_disable_all();
+ debug_print("gpgme_engine_version:\n%s\n",
+ gpgme_get_engine_info());
+
+ if (prefs_common.gpgme_warning) {
+ AlertValue v = alertpanel_message_with_disable
+ (_("Warning"),
+ _("GnuPG is not installed properly.\n"
+ "OpenPGP support disabled."));
+ if (v & G_ALERTDISABLE) {
+ prefs_common.gpgme_warning = FALSE;
+ prefs_common_save_config();
+ }
+ }
+ }
gpgme_register_idle(idle_function_for_gpgme);
#endif
prefs_common_save_config();
prefs_filter_read_config();
prefs_filter_write_config();
+ prefs_display_header_read_config();
+ prefs_display_header_write_config();
+ prefs_scoring_read_config();
+ prefs_filtering_read_config();
gtkut_widget_init();
account_set_missing_folder();
folderview_set(folderview);
- if (cmd.receive_all)
+ inc_autocheck_timer_init(mainwin);
+
+ if (cmd.receive_all || prefs_common.chk_on_startup)
inc_all_account_mail(mainwin);
- else if (prefs_common.chk_on_startup || cmd.receive)
+ else if (cmd.receive)
inc_mail(mainwin);
else
gtk_widget_grab_focus(folderview->ctree);
}
}
+static gint get_queued_message_num(void)
+{
+ FolderItem *queue;
+
+ queue = folder_get_default_queue();
+ g_return_val_if_fail(queue != NULL, -1);
+
+ folder_item_scan(queue);
+ return queue->total;
+}
+
void app_will_exit(GtkWidget *widget, gpointer data)
{
MainWindow *mainwin = data;
_("Composing message exists. Really quit?"),
_("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
return;
+ manage_window_focus_in(mainwin->window, NULL, NULL);
+ }
+
+ if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
+ if (alertpanel(_("Queued messages"),
+ _("Some unsent messages are queued. Exit now?"),
+ _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
+ return;
+ manage_window_focus_in(mainwin->window, NULL, NULL);
}
if (prefs_common.clean_on_exit)
/* delete unix domain socket */
gdk_input_remove(lock_socket_tag);
- sock_close(lock_socket);
+ fd_close(lock_socket);
filename = get_socket_name();
unlink(filename);
gchar *path;
path = get_socket_name();
- uxsock = sock_connect_unix(path);
+ uxsock = fd_connect_unix(path);
if (uxsock < 0) {
unlink(path);
- return sock_open_unix(path);
+ return fd_open_unix(path);
}
/* remote command mode */
debug_print(_("another Sylpheed is already running.\n"));
if (cmd.receive_all)
- sock_write(uxsock, "receive_all\n", 12);
+ fd_write(uxsock, "receive_all\n", 12);
else if (cmd.receive)
- sock_write(uxsock, "receive\n", 8);
+ fd_write(uxsock, "receive\n", 8);
else if (cmd.compose) {
gchar *compose_str;
else
compose_str = g_strdup("compose\n");
- sock_write(uxsock, compose_str, strlen(compose_str));
+ fd_write(uxsock, compose_str, strlen(compose_str));
g_free(compose_str);
} else
- sock_write(uxsock, "popup\n", 6);
+ fd_write(uxsock, "popup\n", 6);
- sock_close(uxsock);
+ fd_close(uxsock);
return -1;
}
gint sock;
gchar buf[BUFFSIZE];
- sock = sock_accept(source);
- sock_read(sock, buf, sizeof(buf));
- sock_close(sock);
+ sock = fd_accept(source);
+ fd_read(sock, buf, sizeof(buf));
+ fd_close(sock);
if (!strncmp(buf, "popup", 5)){
main_window_popup(mainwin);
else
compose_new(NULL);
}
+