+2008-11-05 [colin] 3.6.1cvs18
+
+ * src/action.c
+ * src/main.c
+ * src/mainwindow.c
+ * src/common/socket.c
+ * src/common/socket.h
+ * src/gtk/gtkutils.c
+ * src/gtk/gtkutils.h
+ w32: Implement single launch (lock
+ socket); always put debug log to
+ the rc_dir; fix Start menu update
+ after registering as default Mail
+ app
+
2008-11-05 [colin] 3.6.1cvs17
* src/mainwindow.c
( cvs diff -u -r 1.274.2.285 -r 1.274.2.286 src/mainwindow.c; cvs diff -u -r 1.83.2.146 -r 1.83.2.147 src/mimeview.c; cvs diff -u -r 1.204.2.181 -r 1.204.2.182 src/prefs_common.c; cvs diff -u -r 1.103.2.116 -r 1.103.2.117 src/prefs_common.h; cvs diff -u -r 1.3.2.23 -r 1.3.2.24 src/prefs_ext_prog.c; cvs diff -u -r 1.49.2.118 -r 1.49.2.119 src/procmime.c; cvs diff -u -r 1.96.2.209 -r 1.96.2.210 src/textview.c; cvs diff -u -r 1.36.2.153 -r 1.36.2.154 src/common/utils.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/common/w32_reg.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/common/w32lib.h; ) > 3.6.1cvs15.patchset
( cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/common/w32_reg.c; ) > 3.6.1cvs16.patchset
( cvs diff -u -r 1.274.2.286 -r 1.274.2.287 src/mainwindow.c; ) > 3.6.1cvs17.patchset
+( cvs diff -u -r 1.12.2.54 -r 1.12.2.55 src/action.c; cvs diff -u -r 1.115.2.214 -r 1.115.2.215 src/main.c; cvs diff -u -r 1.274.2.287 -r 1.274.2.288 src/mainwindow.c; cvs diff -u -r 1.13.2.40 -r 1.13.2.41 src/common/socket.c; cvs diff -u -r 1.13.2.21 -r 1.13.2.22 src/common/socket.h; cvs diff -u -r 1.5.2.84 -r 1.5.2.85 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.46 -r 1.4.2.47 src/gtk/gtkutils.h; ) > 3.6.1cvs18.patchset
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=17
+EXTRA_VERSION=18
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
child_info->tag_status =
claws_input_add(child_info->chld_status,
GDK_INPUT_READ,
- catch_status, child_info);
+ catch_status, child_info,
+ FALSE);
}
create_io_dialog(children);
child_info->chld_status = chld_status[0];
child_info->tag_in = -1;
child_info->tag_out = claws_input_add(chld_out[0], GDK_INPUT_READ,
- catch_output, child_info);
+ catch_output, child_info, FALSE);
child_info->tag_err = claws_input_add(chld_err[0], GDK_INPUT_READ,
- catch_output, child_info);
+ catch_output, child_info, FALSE);
if (!(children->action_type &
(ACTION_PIPE_IN | ACTION_PIPE_OUT | ACTION_INSERT)))
child_info->tag_in = claws_input_add(child_info->chld_in,
GDK_INPUT_WRITE,
- catch_input, children);
+ catch_input, children, FALSE);
}
static gint delete_io_dialog_cb(GtkWidget *w, GdkEvent *e, gpointer data)
# ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS
# endif
+# include "w32lib.h"
#else
# if HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif /*G_OS_UNIX*/
}
+#ifdef G_OS_WIN32
+#define SOCKET_IS_VALID(s) ((s) != INVALID_SOCKET)
+#else
+#define SOCKET_IS_VALID(s) TRUE
+#endif
/* Due to the fact that socket under Windows are not represented by
standard file descriptors, we sometimes need to check whether a
#endif
}
+gint fd_connect_inet(gushort port)
+{
+ gint sock;
+ struct sockaddr_in addr;
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (!SOCKET_IS_VALID(sock)) {
+#ifdef G_OS_WIN32
+ debug_print("fd_connect_inet(): socket() failed: %d\n",
+ WSAGetLastError());
+#else
+ perror("fd_connect_inet(): socket");
+#endif
+ return -1;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(port);
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+ if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ fd_close(sock);
+ return -1;
+ }
+
+ return sock;
+}
+gint fd_open_inet(gushort port)
+{
+ gint sock;
+ struct sockaddr_in addr;
+ gint val;
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (!SOCKET_IS_VALID(sock)) {
+#ifdef G_OS_WIN32
+ g_warning("fd_open_inet(): socket() failed: %d\n",
+ WSAGetLastError());
+#else
+ perror("fd_open_inet(): socket");
+#endif
+ return -1;
+ }
+
+ val = 1;
+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&val,
+ sizeof(val)) < 0) {
+ perror("setsockopt");
+ fd_close(sock);
+ return -1;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(port);
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+ if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ perror("bind");
+ fd_close(sock);
+ return -1;
+ }
+
+ if (listen(sock, 1) < 0) {
+ perror("listen");
+ fd_close(sock);
+ return -1;
+ }
+
+ return sock;
+}
gint fd_connect_unix(const gchar *path)
{
gint fd_open_unix (const gchar *path);
gint fd_accept (gint sock);
+gint fd_connect_inet(gushort port);
+gint fd_open_inet(gushort port);
+
gint fd_write (gint sock, const gchar *buf, gint len);
gint fd_write_all (gint sock, const gchar *buf, gint len);
gint fd_gets (gint sock, gchar *buf, gint len);
claws_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
- gpointer data)
+ gpointer data,
+ gboolean is_sock)
{
guint result;
ClawsIOClosure *closure = g_new (ClawsIOClosure, 1);
#ifndef G_OS_WIN32
channel = g_io_channel_unix_new (source);
#else
- channel = g_io_channel_win32_new_fd(source);
+ if (is_sock)
+ channel = g_io_channel_win32_new_socket(source);
+ else
+ channel = g_io_channel_win32_new_fd(source);
#endif
result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond,
claws_io_invoke,
GtkUIManager *gtkut_create_ui_manager(void);
GtkUIManager *gtkut_ui_manager(void);
-#ifdef G_OS_UNIX
gint
claws_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
- gpointer data);
-#endif
+ gpointer data,
+ gboolean is_sock);
#if GTK_CHECK_VERSION(2,12,0)
#define CLAWS_TIP_DECL() {}
#define CLAWS_SET_TIP(widget,tip) { \
static void win32_open_log(void)
{
- if (is_file_exist("claws-win32.log")) {
- if (rename_force("claws-win32.log", "claws-win32.log.bak") < 0)
- FILE_OP_ERROR("claws-win32.log", "rename");
+ gchar *logfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "claws-win32.log", NULL);
+ gchar *oldlogfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "claws-win32.log.bak", NULL);
+
+ if (is_file_exist(logfile)) {
+ if (rename_force(logfile, oldlogfile) < 0)
+ FILE_OP_ERROR(logfile, "rename");
}
- win32_debug_fp = g_fopen("claws-win32.log", "w");
+ win32_debug_fp = g_fopen(logfile, "w");
+ g_free(logfile);
+ g_free(oldlogfile);
if (win32_debug_fp)
{
g_set_print_handler(win32_print_stdout);
sock_init();
/* 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
if (cmd.exit)
return 0;
-#endif
if (!g_thread_supported())
g_thread_init(NULL);
folder_item_update_freeze();
/* register the callback of unix domain socket input */
-#ifdef G_OS_UNIX
lock_socket_tag = claws_input_add(lock_socket,
GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
lock_socket_input_cb,
- mainwin);
-#endif
+ mainwin, TRUE);
prefs_account_init();
} else if (!strncmp(argv[i], "--receive", 9)) {
cmd.receive = TRUE;
} else if (!strncmp(argv[i], "--compose", 9)) {
- const gchar *p = argv[i + 1];
+ const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
cmd.compose = TRUE;
cmd.compose_mailto = NULL;
i++;
}
} else if (!strncmp(argv[i], "--subscribe", 11)) {
- const gchar *p = argv[i + 1];
+ const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
if (p && *p != '\0' && *p != '-') {
cmd.subscribe = TRUE;
cmd.subscribe_uri = p;
}
} else if (!strncmp(argv[i], "--attach", 8)) {
- const gchar *p = argv[i + 1];
+ const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
gchar *file = NULL;
while (p && *p != '\0' && *p != '-') {
}
g_ptr_array_add(cmd.attach_files, file);
i++;
- p = argv[i + 1];
+ p = (i+1 < argc)?argv[i+1]:NULL;
}
} else if (!strncmp(argv[i], "--send", 6)) {
cmd.send = TRUE;
g_print("Claws Mail version " VERSION "\n");
exit(0);
} else if (!strncmp(argv[i], "--status-full", 13)) {
- const gchar *p = argv[i + 1];
+ const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
cmd.status_full = TRUE;
while (p && *p != '\0' && *p != '-') {
g_ptr_array_add(cmd.status_full_folders,
g_strdup(p));
i++;
- p = argv[i + 1];
+ p = (i+1 < argc)?argv[i+1]:NULL;
}
} else if (!strncmp(argv[i], "--status", 8)) {
- const gchar *p = argv[i + 1];
+ const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
cmd.status = TRUE;
while (p && *p != '\0' && *p != '-') {
g_ptr_array_add(cmd.status_folders,
g_strdup(p));
i++;
- p = argv[i + 1];
+ p = (i+1 < argc)?argv[i+1]:NULL;
}
} else if (!strncmp(argv[i], "--online", 8)) {
cmd.online_mode = ONLINE_MODE_ONLINE;
exit(1);
} else if (!strncmp(argv[i], "--crash", 7)) {
cmd.crash = TRUE;
- cmd.crash_params = g_strdup(argv[i + 1]);
+ cmd.crash_params = g_strdup((i+1 < argc)?argv[i+1]:NULL);
i++;
} else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
g_print(RC_DIR "\n");
static gint prohibit_duplicate_launch(void)
{
gint uxsock;
+#ifdef G_OS_UNIX
gchar *path;
path = claws_get_socket_name();
claws_unlink(path);
return fd_open_unix(path);
}
-
+#else
+ HANDLE hmutex;
+
+ hmutex = CreateMutexA(NULL, FALSE, "ClawsMail");
+ if (!hmutex) {
+ debug_print("cannot create Mutex\n");
+ return -1;
+ }
+ if (GetLastError() != ERROR_ALREADY_EXISTS) {
+ uxsock = fd_open_inet(50216);
+ if (uxsock < 0)
+ return 0;
+ return uxsock;
+ }
+
+ uxsock = fd_connect_inet(50216);
+ if (uxsock < 0)
+ return -1;
+#endif
/* remote command mode */
debug_print("another Claws Mail instance is already running.\n");
fd_write_all(uxsock, str, strlen(str));
g_free(str);
} else {
+#ifndef G_OS_WIN32
gchar buf[BUFSIZ];
fd_write_all(uxsock, "get_display\n", 12);
memset(buf, 0, sizeof(buf));
uxsock = fd_connect_unix(path);
fd_write_all(uxsock, "popup\n", 6);
}
+#else
+ fd_write_all(uxsock, "popup\n", 6);
+#endif
}
fd_close(uxsock);
{
#ifdef G_OS_UNIX
gchar *filename;
-
+#endif
if (lock_socket < 0) {
return -1;
}
g_source_remove(lock_socket_tag);
}
fd_close(lock_socket);
+
+#ifdef G_OS_UNIX
filename = claws_get_socket_name();
claws_unlink(filename);
#endif
#include "imap.h"
#include "socket.h"
#include "printing.h"
+#ifdef G_OS_WIN32
+#include "w32lib.h"
+#endif
#define AC_LABEL_WIDTH 240
"", binary_compose);
if (!r) {
+ SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Software\\Clients\\Mail");
alertpanel_notice(_("Claws Mail has been registered as default client."));
} else {
alertpanel_error(_("Can not register as default client: impossible to write to the registry."));