static gint lock_socket = -1;
static gint lock_socket_tag = 0;
+#ifdef G_OS_UNIX
static gchar *x_display = NULL;
+#endif
typedef enum
{
ONLINE_MODE_DONT_CHANGE,
{
gboolean autochk = GPOINTER_TO_INT(data);
- inc_all_account_mail(static_mainwindow, autochk,
+ if (!sc_starting) {
+ inc_all_account_mail(static_mainwindow, autochk, FALSE,
prefs_common.newmail_notify_manu);
- if (sc_starting) {
+ } else {
+ inc_all_account_mail(static_mainwindow, FALSE,
+ prefs_common.chk_on_startup,
+ prefs_common.newmail_notify_manu);
sc_starting = FALSE;
main_window_set_menu_sensitive(static_mainwindow);
toolbar_main_set_sensitive(static_mainwindow);
NULL, &client_id,
256, error_string_ret);
+ /* From https://www.x.org/releases/X11R7.7/doc/libSM/SMlib.txt:
+ * If SmcOpenConnection succeeds, it returns an opaque connection
+ * pointer of type SmcConn and the client_id_ret argument contains
+ * the client ID to be used for this session. The client_id_ret
+ * should be freed with a call to free when no longer needed. On
+ * failure, SmcOpenConnection returns NULL, and the reason for
+ * failure is returned in error_string_ret. */
+ if (mainwin->smc_conn != NULL)
+ g_free(client_id);
+
if (error_string_ret[0] || mainwin->smc_conn == NULL)
g_warning ("While connecting to session manager: %s.",
error_string_ret);
static void win32_open_log(void)
{
- gchar *logfile = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, "claws-win32.log", NULL);
- gchar *oldlogfile = g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, "claws-win32.log.bak", NULL);
+ gchar *logfile = win32_debug_log_path();
+ gchar *oldlogfile = g_strconcat(logfile, ".bak", NULL);
if (is_file_exist(logfile)) {
if (rename_force(logfile, oldlogfile) < 0)
folder_item_update_freeze();
}
/* make the crash-indicator file */
- str_write_to_file("foo", get_crashfile_name(), FALSE);
+ if (str_write_to_file("foo", get_crashfile_name(), FALSE) < 0) {
+ g_warning("Can't create the crash-indicator file.");
+ }
inc_autocheck_timer_init(mainwin);
if (prefs_common.last_opened_folder != NULL)
g_free(prefs_common.last_opened_folder);
prefs_common.last_opened_folder =
+ !prefs_common.goto_last_folder_on_startup ? NULL :
folder_item_get_identifier(item);
}
" use - as file name for reading from standard input;\n"
" content format: headers first (To: required) until an\n"
" empty line, then mail body until end of file."));
- g_print("%s\n", _(" --subscribe [uri] subscribe to the given URI if possible"));
+ g_print("%s\n", _(" --subscribe uri subscribe to the given URI if possible"));
g_print("%s\n", _(" --attach file1 [file2]...\n"
" open composition window with specified files\n"
" attached"));
g_print("%s\n", _(" --version -v output version information and exit"));
g_print("%s\n", _(" --version-full -V output version and built-in features information and exit"));
g_print("%s\n", _(" --config-dir output configuration directory"));
- g_print("%s\n", _(" --alternate-config-dir [dir]\n"
+ g_print("%s\n", _(" --alternate-config-dir directory\n"
" use specified configuration directory"));
g_print("%s\n", _(" --geometry -geometry WxH+X+Y\n"
" set geometry for main window"));
} else if (is_dir_exist(argv[i]) || is_file_exist(argv[i])) {
cmd.target = argv[i];
} else {
- g_print(_("Unknown option\n"));
+ g_print(_("Unknown option. Try -h or --help for usage.\n"));
exit(1);
}
}
} else if (cmd.send) {
fd_write_all(uxsock, "send\n", 5);
} else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
- fd_write(uxsock, "online\n", 6);
+ fd_write(uxsock, "online\n", 7);
} else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
- fd_write(uxsock, "offline\n", 7);
+ fd_write(uxsock, "offline\n", 8);
} else if (cmd.debug) {
- fd_write(uxsock, "debug\n", 7);
+ fd_write(uxsock, "debug\n", 6);
} else if (cmd.status || cmd.status_full) {
gchar buf[BUFFSIZE];
gint i;
fd_gets(uxsock, buf, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) break;
- claws_fputs(buf, stdout);
+ if (claws_fputs(buf, stdout) == EOF) {
+ g_warning("writing to stdout failed.");
+ break;
+ }
}
} else if (cmd.exit) {
fd_write_all(uxsock, "exit\n", 5);
fd_gets(uxsock, buf, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) break;
- claws_fputs(buf, stdout);
+ if (claws_fputs(buf, stdout) == EOF) {
+ g_warning("writing to stdout failed.");
+ break;
+ }
}
} else if (cmd.reset_statistics) {
fd_write(uxsock, "reset_statistics\n", 17);
fd_gets(uxsock, buf, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) break;
- claws_fputs(buf, stdout);
+ if (claws_fputs(buf, stdout) == EOF) {
+ g_warning("writing to stdout failed.");
+ break;
+ }
}
} else {
-#ifndef G_OS_WIN32
+#ifdef G_OS_UNIX
gchar buf[BUFSIZ];
fd_write_all(uxsock, "get_display\n", 12);
memset(buf, 0, sizeof(buf));
fd_gets(uxsock, buf, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
- if (strcmp2(buf, x_display)) {
+ if (g_strcmp0(buf, x_display)) {
g_print("Claws Mail is already running on display %s.\n",
buf);
} else {
if (!strncmp(buf, "popup", 5)) {
main_window_popup(mainwin);
+#ifdef G_OS_UNIX
} else if (!strncmp(buf, "get_display", 11)) {
fd_write_all(sock, x_display, strlen(x_display));
+#endif
} else if (!strncmp(buf, "receive_all", 11)) {
- inc_all_account_mail(mainwin, FALSE,
+ inc_all_account_mail(mainwin, FALSE, FALSE,
prefs_common.newmail_notify_manu);
} else if (!strncmp(buf, "receive", 7)) {
inc_mail(mainwin, prefs_common.newmail_notify_manu);
while (fd_gets(sock, buf, sizeof(buf) - 1) > 0) {
buf[sizeof(buf) - 1] = '\0';
strretchomp(buf);
- if (!strcmp2(buf, "."))
+ if (!g_strcmp0(buf, "."))
break;
ainfo = g_new0(AttachInfo, 1);