/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ *
*/
#ifdef HAVE_CONFIG_H
vals[0].length = strlen(g_get_user_name()?g_get_user_name():"");
vals[0].value = g_strdup(g_get_user_name()?g_get_user_name():"");
sc_client_set_value (mainwin, SmUserID, SmARRAY8, 1, vals);
+
+ g_free(vals);
}
}
}
session_stats.forwarded = 0;
session_stats.time_started = time(NULL);
}
-
+
int main(int argc, char *argv[])
{
#ifdef HAVE_DBUS_GLIB
"gtk-theme-name",
"MS-Windows",
"XProperty");
+ gtk_settings_set_long_property(gtk_settings_get_default(),
+ "gtk-auto-mnemonics",
+ TRUE,
+ "XProperty");
#endif
#ifdef HAVE_NETWORKMANAGER_SUPPORT
if(mainwin->folderview->opened) {
FolderItem *item;
- item = gtk_cmctree_node_get_row_data(GTK_CMCTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
- summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
- prefs_common.last_opened_folder = folder_item_get_identifier(item);
+ item = gtk_cmctree_node_get_row_data(
+ GTK_CMCTREE(mainwin->folderview->ctree),
+ mainwin->folderview->opened);
+ if (item) {
+ summary_save_prefs_to_folderitem(
+ mainwin->folderview->summaryview, item);
+ prefs_common.last_opened_folder =
+ folder_item_get_identifier(item);
+ }
}
/* save all state before exiting */
g_string_append_c(headers, '&');
g_string_append(headers, tmp);
g_string_append_c(headers, '=');
-#if GLIB_CHECK_VERSION(2,16,0)
g_string_append_uri_escaped(headers, v, NULL, TRUE);
-#else
- G_STRING_APPEND_ENCODED_URI(headers, v);
-#endif
}
g_free(tmp);
}
g_free(to);
g_string_append(body, "?body=");
while (fgets(fb, sizeof(fb), fp)) {
-#if GLIB_CHECK_VERSION(2,16,0)
g_string_append_uri_escaped(body, fb, NULL, TRUE);
-#else
- G_STRING_APPEND_ENCODED_URI(body, fb);
-#endif
}
if (!isstdin)
fclose(fp);
static gboolean draft_all_messages(void)
{
- GList *compose_list = NULL;
+ const GList *compose_list = NULL;
compose_clear_exit_drafts();
compose_list = compose_get_compose_list();
gchar *claws_get_socket_name(void)
{
static gchar *filename = NULL;
- const gchar *socket_dir = NULL;
+ gchar *socket_dir = NULL;
gchar md5sum[33];
if (filename == NULL) {
struct stat st;
+ gint stat_ok;
+
socket_dir = g_strdup_printf("%s%cclaws-mail-%d",
g_get_tmp_dir(), G_DIR_SEPARATOR,
#if HAVE_GETUID
#else
0);
#endif
- if (stat(socket_dir, &st) < 0 && errno != ENOENT) {
+ stat_ok = stat(socket_dir, &st);
+ if (stat_ok < 0 && errno != ENOENT) {
g_print("Error stat'ing socket_dir %s: %s\n",
- socket_dir, strerror(errno));
- } else if (S_ISSOCK(st.st_mode)) {
+ socket_dir, g_strerror(errno));
+ } else if (stat_ok == 0 && S_ISSOCK(st.st_mode)) {
/* old versions used a sock in $TMPDIR/claws-mail-$UID */
debug_print("Using legacy socket %s\n", socket_dir);
filename = g_strdup(socket_dir);
if (!is_dir_exist(socket_dir) && make_dir(socket_dir) < 0) {
g_print("Error creating socket_dir %s: %s\n",
- socket_dir, strerror(errno));
+ socket_dir, g_strerror(errno));
}
md5_hex_digest(md5sum, get_rc_dir());
filename = g_strdup_printf("%s%c%s", socket_dir, G_DIR_SEPARATOR,
md5sum);
+ g_free(socket_dir);
debug_print("Using control socket %s\n", filename);
}
lock_fd = g_open(socket_lock, O_RDWR|O_CREAT, 0);
if (lock_fd < 0) {
debug_print("Couldn't open %s: %s (%d)\n", socket_lock,
- strerror(errno), errno);
+ g_strerror(errno), errno);
g_free(socket_lock);
return -1;
}
if (flock(lock_fd, LOCK_EX) < 0) {
debug_print("Couldn't lock %s: %s (%d)\n", socket_lock,
- strerror(errno), errno);
+ g_strerror(errno), errno);
close(lock_fd);
g_free(socket_lock);
return -1;
ret = fd_open_unix(path);
#if HAVE_FLOCK
flock(lock_fd, LOCK_UN);
+ close(lock_fd);
claws_unlink(socket_lock);
g_free(socket_lock);
#endif
}
fd_write_all(uxsock, ".\n", 2);
for (;;) {
- fd_gets(uxsock, buf, sizeof(buf));
+ fd_gets(uxsock, buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) break;
fputs(buf, stdout);
}
gchar buf[BUFSIZ];
fd_write(uxsock, "statistics\n", 11);
for (;;) {
- fd_gets(uxsock, buf, sizeof(buf));
+ fd_gets(uxsock, buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) break;
fputs(buf, stdout);
}
fd_write_all(uxsock, str, strlen(str));
g_free(str);
for (;;) {
- fd_gets(uxsock, buf, sizeof(buf));
+ fd_gets(uxsock, buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) break;
fputs(buf, stdout);
}
gchar buf[BUFSIZ];
fd_write_all(uxsock, "get_display\n", 12);
memset(buf, 0, sizeof(buf));
- fd_gets(uxsock, buf, sizeof(buf));
+ fd_gets(uxsock, buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (strcmp2(buf, x_display)) {
g_print("Claws Mail is already running on display %s.\n",
buf);
GPtrArray *folders = NULL;
for (;;) {
- fd_gets(sock, buf, sizeof(buf));
+ fd_gets(sock, buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, ".\n", 2)) {
break;
}
gchar buf[BUFFSIZE];
sock = fd_accept(source);
- fd_gets(sock, buf, sizeof(buf));
+ if (sock < 0)
+ return;
+
+ fd_gets(sock, buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
if (!strncmp(buf, "popup", 5)) {
main_window_popup(mainwin);
gchar *mailto;
mailto = g_strdup(buf + strlen("compose_attach") + 1);
- while (fd_gets(sock, buf, sizeof(buf)) > 0) {
+ while (fd_gets(sock, buf, sizeof(buf) - 1) > 0) {
+ buf[sizeof(buf) - 1] = '\0';
strretchomp(buf);
if (!strcmp2(buf, "."))
break;
folder_name = g_strdup(buf+7);
strretchomp(folder_name);
- if (fd_gets(sock, buf, sizeof(buf)) <= 0)
+ if (fd_gets(sock, buf, sizeof(buf) - 1) <= 0)
goto search_exit;
+ buf[sizeof(buf) - 1] = '\0';
switch (toupper(buf[0])) {
case 'S': searchType = ADVANCED_SEARCH_SUBJECT; break;
case 'E': searchType = ADVANCED_SEARCH_EXTENDED; break;
}
- if (fd_gets(sock, buf, sizeof(buf)) <= 0)
+ if (fd_gets(sock, buf, sizeof(buf) - 1) <= 0)
goto search_exit;
+ buf[sizeof(buf) - 1] = '\0';
request = g_strdup(buf);
strretchomp(request);
recursive = TRUE;
- if (fd_gets(sock, buf, sizeof(buf)) > 0)
+ if (fd_gets(sock, buf, sizeof(buf) - 1) > 0)
recursive = buf[0] != '0';
+ buf[sizeof(buf) - 1] = '\0';
+
debug_print("search: %s %i %s %i\n", folder_name, searchType, request, recursive);
- if (folder_name)
- folderItem = folder_find_item_from_identifier(folder_name);
+ folderItem = folder_find_item_from_identifier(folder_name);
- if (folder_name && folderItem == NULL) {
+ if (folderItem == NULL) {
debug_print("Unknown folder item : '%s', searching folder\n",folder_name);
Folder* folder = folder_find_from_path(folder_name);
if (folder != NULL)
mem_notify_fd = g_open("/dev/mem_notify", O_RDONLY|O_NONBLOCK, 0);
if (mem_notify_fd == -1) {
debug_print("/dev/mem_notify not available (%s)\n",
- strerror(errno));
+ g_strerror(errno));
return;
}