#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <signal.h>
+#ifdef G_OS_UNIX
+# include <signal.h>
+#endif
#include "wizard.h"
#ifdef HAVE_STARTUP_NOTIFICATION
# define SN_API_NOT_YET_FROZEN
crash_install_handlers();
#endif
install_basic_sighandlers();
+ sock_init();
- /* check and create unix domain socket */
+ /* check and create unix domain socket for remote operation */
+#ifdef G_OS_UNIX
lock_socket = prohibit_duplicate_launch();
if (lock_socket < 0) {
#ifdef HAVE_STARTUP_NOTIFICATION
lock_socket_remove();
return 0;
}
-
+#endif
g_thread_init(NULL);
/* gdk_threads_init(); */
remove_all_files(get_tmp_dir());
remove_all_files(get_mime_tmp_dir());
- if (is_file_exist(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log")) {
- if (rename(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log",
- RC_DIR G_DIR_SEPARATOR_S "sylpheed.log.bak") < 0)
+ if (is_file_exist("sylpheed.log")) {
+ if (rename_force("sylpheed.log", "sylpheed.log.bak") < 0)
FILE_OP_ERROR("sylpheed.log", "rename");
}
- set_log_file(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log");
+ set_log_file("sylpheed.log");
+
+ CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
folder_system_init();
prefs_common_read_config();
folderview = mainwin->folderview;
/* register the callback of unix domain socket input */
+#ifdef G_OS_UNIX
lock_socket_tag = gdk_input_add(lock_socket,
GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
lock_socket_input_cb,
mainwin);
+#endif
prefs_account_init();
account_read_config_all();
inc_autocheck_timer_init(mainwin);
/* ignore SIGPIPE signal for preventing sudden death of program */
+#ifdef G_OS_UNIX
signal(SIGPIPE, SIG_IGN);
-
+#endif
if (cmd.online_mode == ONLINE_MODE_OFFLINE)
main_window_toggle_work_offline(mainwin, TRUE);
if (cmd.online_mode == ONLINE_MODE_ONLINE)
#endif
/* delete crashfile */
if (!cmd.crash)
- unlink(get_crashfile_name());
+ g_unlink(get_crashfile_name());
lock_socket_remove();
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
}
+
+ sock_cleanup();
+
gtk_main_quit();
}
if (filename == NULL) {
filename = g_strdup_printf("%s%csylpheed-%d",
g_get_tmp_dir(), G_DIR_SEPARATOR,
+#if HAVE_GETUID
getuid());
+#else
+ 0);
+#endif
}
return filename;
path = get_socket_name();
uxsock = fd_connect_unix(path);
if (uxsock < 0) {
- unlink(path);
+ g_unlink(path);
return fd_open_unix(path);
}
static gint lock_socket_remove(void)
{
+#ifdef G_OS_UNIX
gchar *filename;
if (lock_socket < 0) return -1;
gdk_input_remove(lock_socket_tag);
fd_close(lock_socket);
filename = get_socket_name();
- unlink(filename);
+ g_unlink(filename);
+#endif
return 0;
}