From mones at claws-mail.org Tue Aug 4 10:54:03 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Tue, 4 Aug 2020 10:54:03 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-2-g5cc88aae7 Message-ID: <20200804085403.E257C40352@claws-mail.org> The branch, master has been updated via 5cc88aae7217d6ea385a580a30dc79ea0c91c27f (commit) from aecf6d5c2d0a0dff8d30749fd1e97ef893816c25 (commit) Summary of changes: src/plugins/spamassassin/spamassassin_gtk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) - Log ----------------------------------------------------------------- commit 5cc88aae7217d6ea385a580a30dc79ea0c91c27f Author: Ricardo Mones Date: Tue Aug 4 10:47:15 2020 +0200 Harmonise GUI maximum value with libspamc's one …and now SpamAssassin plugin can handle messages up to 256 Mb. diff --git a/src/plugins/spamassassin/spamassassin_gtk.c b/src/plugins/spamassassin/spamassassin_gtk.c index b88a33293..ad7ad2ca1 100644 --- a/src/plugins/spamassassin/spamassassin_gtk.c +++ b/src/plugins/spamassassin/spamassassin_gtk.c @@ -41,6 +41,9 @@ #include "menu.h" #include "addressbook.h" #include "combobox.h" +#include "libspamc.h" + +#define SA_MAX_SIZE_KB (SPAMC_MAX_MESSAGE_LEN / 1024) struct SpamAssassinPage { @@ -375,7 +378,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page, gtk_widget_show(max_size_label); gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_label, FALSE, FALSE, 0); - max_size_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(250, 0, 10000, 10, 10, 0)); + max_size_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(250, 0, SA_MAX_SIZE_KB, 10, 10, 0)); max_size_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(max_size_spinbtn_adj), 1, 0); gtk_widget_show(max_size_spinbtn); gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_spinbtn, FALSE, FALSE, 0); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From mones at claws-mail.org Tue Aug 4 10:54:51 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Tue, 4 Aug 2020 10:54:51 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-979-g720331b93 Message-ID: <20200804085453.21F9740157@claws-mail.org> The branch, gtk3 has been updated via 720331b93cf12526f4be335e67c4ef75005a55ea (commit) from bb087f25bc5cfe986cefb2578e31f302490de093 (commit) Summary of changes: src/plugins/spamassassin/spamassassin_gtk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) - Log ----------------------------------------------------------------- commit 720331b93cf12526f4be335e67c4ef75005a55ea Author: Ricardo Mones Date: Tue Aug 4 10:47:15 2020 +0200 Harmonise GUI maximum value with libspamc's one …and now SpamAssassin plugin can handle messages up to 256 Mb. diff --git a/src/plugins/spamassassin/spamassassin_gtk.c b/src/plugins/spamassassin/spamassassin_gtk.c index fbe318bd4..2e3f0a6ce 100644 --- a/src/plugins/spamassassin/spamassassin_gtk.c +++ b/src/plugins/spamassassin/spamassassin_gtk.c @@ -41,6 +41,9 @@ #include "menu.h" #include "addressbook.h" #include "combobox.h" +#include "libspamc.h" + +#define SA_MAX_SIZE_KB (SPAMC_MAX_MESSAGE_LEN / 1024) struct SpamAssassinPage { @@ -367,7 +370,7 @@ static void spamassassin_create_widget_func(PrefsPage * _page, gtk_widget_show(max_size_label); gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_label, FALSE, FALSE, 0); - max_size_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(250, 0, 10000, 10, 10, 0)); + max_size_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(250, 0, SA_MAX_SIZE_KB, 10, 10, 0)); max_size_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(max_size_spinbtn_adj), 1, 0); gtk_widget_show(max_size_spinbtn); gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_spinbtn, FALSE, FALSE, 0); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Tue Aug 11 13:13:06 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Tue, 11 Aug 2020 13:13:06 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-980-g3ba140dd7 Message-ID: <20200811111306.9DAE6403B1@claws-mail.org> The branch, gtk3 has been updated via 3ba140dd7068c4388999a6b5ffdd76c76f89cd4f (commit) from 720331b93cf12526f4be335e67c4ef75005a55ea (commit) Summary of changes: src/addrgather.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) - Log ----------------------------------------------------------------- commit 3ba140dd7068c4388999a6b5ffdd76c76f89cd4f Author: paul Date: Tue Aug 11 12:13:00 2020 +0100 expand vertically to show results of the collection diff --git a/src/addrgather.c b/src/addrgather.c index 5a1ce8849..e6d381b8a 100644 --- a/src/addrgather.c +++ b/src/addrgather.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 2002-2019 the Claws Mail team and Match Grun + * Copyright (C) 2002-2020 the Claws Mail team and Match Grun * * 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 @@ -472,6 +472,7 @@ static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) { gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_widget_set_vexpand(GTK_WIDGET(scrollwin), TRUE); /* Treeview */ model = GTK_TREE_MODEL(gtk_list_store_new(N_ADDRGATHER_COLS, ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Mon Aug 17 11:47:32 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Mon, 17 Aug 2020 11:47:32 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-3-g4099289a7 Message-ID: <20200817094732.4C37C40281@claws-mail.org> The branch, master has been updated via 4099289a72d9007c4b054babd6eabe915add5a31 (commit) from 5cc88aae7217d6ea385a580a30dc79ea0c91c27f (commit) Summary of changes: src/gtk/gtkutils.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) - Log ----------------------------------------------------------------- commit 4099289a72d9007c4b054babd6eabe915add5a31 Author: Paul Date: Mon Aug 17 10:47:25 2020 +0100 improve image display, particularly for large images, especially if taller than they are wide diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c index 4eea7fb31..f09d5a84f 100644 --- a/src/gtk/gtkutils.c +++ b/src/gtk/gtkutils.c @@ -1750,32 +1750,6 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width, } } - w = gdk_pixbuf_get_width(pixbuf); - h = gdk_pixbuf_get_height(pixbuf); - - if (angle == 90 || angle == 270) { - avail_height = box_width; - avail_width = box_height; - } else { - avail_width = box_width; - avail_height = box_height; - } - - /* Scale first */ - if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) { - if (w > avail_width) { - h = (avail_width * h) / w; - w = avail_width; - } - if (h > avail_height) { - w = (avail_height * w) / h; - h = avail_height; - } - t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, - w, h, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); - pixbuf = t_pixbuf; - } /* Rotate if needed */ if (angle != 0) { @@ -1798,6 +1772,23 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width, pixbuf = t_pixbuf; } + w = gdk_pixbuf_get_width(pixbuf); + h = gdk_pixbuf_get_height(pixbuf); + + avail_width = box_width; + avail_height = box_height; + + if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) { + if (w > avail_width || h > avail_height) { + h = (avail_width * h) / w; + w = avail_width; + } + t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, + w, h, GDK_INTERP_BILINEAR); + g_object_unref(pixbuf); + pixbuf = t_pixbuf; + } + return pixbuf; } ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Mon Aug 17 11:48:28 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Mon, 17 Aug 2020 11:48:28 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-981-gee631db42 Message-ID: <20200817094828.4E4034021F@claws-mail.org> The branch, gtk3 has been updated via ee631db42de5a198fbb0516fae6ba51a08843747 (commit) from 3ba140dd7068c4388999a6b5ffdd76c76f89cd4f (commit) Summary of changes: src/gtk/gtkutils.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) - Log ----------------------------------------------------------------- commit ee631db42de5a198fbb0516fae6ba51a08843747 Author: Paul Date: Mon Aug 17 10:47:25 2020 +0100 improve image display, particularly for large images, especially if taller than they are wide diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c index b6109be01..4f0544560 100644 --- a/src/gtk/gtkutils.c +++ b/src/gtk/gtkutils.c @@ -1777,32 +1777,6 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width, } } - w = gdk_pixbuf_get_width(pixbuf); - h = gdk_pixbuf_get_height(pixbuf); - - if (angle == 90 || angle == 270) { - avail_height = box_width; - avail_width = box_height; - } else { - avail_width = box_width; - avail_height = box_height; - } - - /* Scale first */ - if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) { - if (w > avail_width) { - h = (avail_width * h) / w; - w = avail_width; - } - if (h > avail_height) { - w = (avail_height * w) / h; - h = avail_height; - } - t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, - w, h, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); - pixbuf = t_pixbuf; - } /* Rotate if needed */ if (angle != 0) { @@ -1825,6 +1799,23 @@ GdkPixbuf *claws_load_pixbuf_fitting(GdkPixbuf *src_pixbuf, int box_width, pixbuf = t_pixbuf; } + w = gdk_pixbuf_get_width(pixbuf); + h = gdk_pixbuf_get_height(pixbuf); + + avail_width = box_width; + avail_height = box_height; + + if (box_width != -1 && box_height != -1 && avail_width - 100 > 0) { + if (w > avail_width || h > avail_height) { + h = (avail_width * h) / w; + w = avail_width; + } + t_pixbuf = gdk_pixbuf_scale_simple(pixbuf, + w, h, GDK_INTERP_BILINEAR); + g_object_unref(pixbuf); + pixbuf = t_pixbuf; + } + return pixbuf; } ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Mon Aug 17 12:47:40 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Mon, 17 Aug 2020 12:47:40 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-982-g20caa23f6 Message-ID: <20200817104740.785484016C@claws-mail.org> The branch, gtk3 has been updated via 20caa23f6dad39ecdca12ab22140e4f8bb84dd94 (commit) from ee631db42de5a198fbb0516fae6ba51a08843747 (commit) Summary of changes: src/wizard.c | 1 + 1 file changed, 1 insertion(+) - Log ----------------------------------------------------------------- commit 20caa23f6dad39ecdca12ab22140e4f8bb84dd94 Author: paul Date: Mon Aug 17 11:47:33 2020 +0100 set gtk_window_set_default_size() on wizard. fixes bug 4345, 'setup wizard requires two clicks on Next|Cancel' diff --git a/src/wizard.c b/src/wizard.c index 765203956..0d779608b 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -1814,6 +1814,7 @@ gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) { _("_Cancel"), CANCEL, NULL); gtk_window_set_position(GTK_WINDOW(wizard->window), GTK_WIN_POS_CENTER); + gtk_window_set_default_size(GTK_WINDOW(wizard->window), 390, 420); g_signal_connect(wizard->window, "response", G_CALLBACK(wizard_response_cb), wizard); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Mon Aug 17 14:13:03 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Mon, 17 Aug 2020 14:13:03 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-983-gc342456b8 Message-ID: <20200817121304.0C6194021F@claws-mail.org> The branch, gtk3 has been updated via c342456b81c5889cbfaf02527a977b329cad0245 (commit) from 20caa23f6dad39ecdca12ab22140e4f8bb84dd94 (commit) Summary of changes: src/summaryview.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) - Log ----------------------------------------------------------------- commit c342456b81c5889cbfaf02527a977b329cad0245 Author: paul Date: Mon Aug 17 13:12:58 2020 +0100 fix bug 4197, 'Vertical icon-bar for parts of the message disappears when the window is too small' diff --git a/src/summaryview.c b/src/summaryview.c index 437b63c52..f72bfe103 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto * * 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 @@ -2646,6 +2646,9 @@ static void summary_status_show(SummaryView *summaryview) toolbar_main_set_sensitive(summaryview->mainwin); return; } + gtk_label_set_ellipsize(GTK_LABEL(summaryview->statlabel_folder), PANGO_ELLIPSIZE_END); + gtk_label_set_ellipsize(GTK_LABEL(summaryview->statlabel_select), PANGO_ELLIPSIZE_END); + gtk_label_set_ellipsize(GTK_LABEL(summaryview->statlabel_msgs), PANGO_ELLIPSIZE_START); rowlist = GTK_CMCLIST(summaryview->ctree)->selection; for (cur = rowlist; cur != NULL && cur->data != NULL; cur = cur->next) { ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Wed Aug 19 08:56:29 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Wed, 19 Aug 2020 08:56:29 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-4-g4c9d15b4b Message-ID: <20200819065629.D23BD40281@claws-mail.org> The branch, master has been updated via 4c9d15b4b37cdc57edfa16df550a0a881a156153 (commit) from 4099289a72d9007c4b054babd6eabe915add5a31 (commit) Summary of changes: AUTHORS | 2 +- src/common/utils.c | 37 ++++++++++++++++++++++++++++++------- src/common/utils.h | 3 ++- src/gtk/authors.h | 1 + 4 files changed, 34 insertions(+), 9 deletions(-) - Log ----------------------------------------------------------------- commit 4c9d15b4b37cdc57edfa16df550a0a881a156153 Author: Paul Date: Wed Aug 19 07:56:23 2020 +0100 fix bugs 4373, 'attach mailto URI double free' and 4374, ' insert mailto URI misses checks' patch by Alvar Penning diff --git a/AUTHORS b/AUTHORS index 5299b1381..7d9f066f3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -332,4 +332,4 @@ contributors (in addition to the above; based on Changelog) Jakub Kiciński Jean Delvare Damian Poddebniak - + Alvar Penning diff --git a/src/common/utils.c b/src/common/utils.c index 87575671a..848f0ce86 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Hiroyuki Yamamoto & The Claws Mail Team + * Copyright (C) 1999-2020 The Claws Mail Team and Hiroyuki Yamamoto * * 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 @@ -1486,11 +1486,28 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, } else if (body && !*body && !g_ascii_strcasecmp(field, "body")) { *body = decode_uri_gdup(value); } else if (body && !*body && !g_ascii_strcasecmp(field, "insert")) { + int i = 0; gchar *tmp = decode_uri_gdup(value); - if (!g_file_get_contents(tmp, body, NULL, NULL)) { - g_warning("couldn't set insert file '%s' in body", value); + + for (; forbidden_uris[i]; i++) { + if (strstr(tmp, forbidden_uris[i])) { + g_print("Refusing to insert '%s', potential private data leak\n", + tmp); + g_free(tmp); + tmp = NULL; + break; + } + } + + if (tmp) { + if (!is_file_entry_regular(tmp)) { + g_warning("Refusing to insert '%s', not a regular file\n", tmp); + } else if (!g_file_get_contents(tmp, body, NULL, NULL)) { + g_warning("couldn't set insert file '%s' in body", value); + } + + g_free(tmp); } - g_free(tmp); } else if (attach && !g_ascii_strcasecmp(field, "attach")) { int i = 0; gchar *tmp = decode_uri_gdup(value); @@ -1504,6 +1521,7 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, tmp); g_free(tmp); g_free(my_att); + tmp = NULL; break; } } @@ -1514,9 +1532,6 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, my_att[num_attach-1] = tmp; my_att[num_attach] = NULL; *attach = my_att; - g_free(tmp); - } else { - g_free(my_att); } } else if (inreplyto && !*inreplyto && !g_ascii_strcasecmp(field, "in-reply-to")) { @@ -2047,6 +2062,14 @@ gboolean is_file_entry_exist(const gchar *file) return g_file_test(file, G_FILE_TEST_EXISTS); } +gboolean is_file_entry_regular(const gchar *file) +{ + if (file == NULL) + return FALSE; + + return g_file_test(file, G_FILE_TEST_IS_REGULAR); +} + gboolean dirent_is_regular_file(struct dirent *d) { #if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE) diff --git a/src/common/utils.h b/src/common/utils.h index 47563b2a1..9816c4efc 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team + * Copyright (C) 1999-2020 The Claws Mail Team and Hiroyuki Yamamoto * * 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 @@ -413,6 +413,7 @@ gboolean file_exist (const gchar *file, gboolean is_relative_filename (const gchar *file); gboolean is_dir_exist (const gchar *dir); gboolean is_file_entry_exist (const gchar *file); +gboolean is_file_entry_regular(const gchar *file); gboolean dirent_is_regular_file (struct dirent *d); #define is_file_exist(file) file_exist(file, FALSE) diff --git a/src/gtk/authors.h b/src/gtk/authors.h index d8c06432f..7e4557047 100644 --- a/src/gtk/authors.h +++ b/src/gtk/authors.h @@ -253,6 +253,7 @@ static char *CONTRIBS_LIST[] = { "Thomas Orgis", "Reza Pakdel", "Richard Palo", +"Alvar Penning", "Damian Poddebniak", "Marcel Pol", "Martin Pool", ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Wed Aug 19 08:58:15 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Wed, 19 Aug 2020 08:58:15 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-984-g0e783b857 Message-ID: <20200819065819.9C7E640397@claws-mail.org> The branch, gtk3 has been updated via 0e783b85770c8281264bb28fddecdd9b5e30a28d (commit) from c342456b81c5889cbfaf02527a977b329cad0245 (commit) Summary of changes: AUTHORS | 2 +- src/common/utils.c | 37 ++++++++++++++++++++++++++++++------- src/common/utils.h | 3 ++- src/gtk/authors.h | 1 + 4 files changed, 34 insertions(+), 9 deletions(-) - Log ----------------------------------------------------------------- commit 0e783b85770c8281264bb28fddecdd9b5e30a28d Author: Paul Date: Wed Aug 19 07:56:23 2020 +0100 fix bugs 4373, 'attach mailto URI double free' and 4374, ' insert mailto URI misses checks' patch by Alvar Penning diff --git a/AUTHORS b/AUTHORS index 4cad95a62..db40bf799 100644 --- a/AUTHORS +++ b/AUTHORS @@ -333,4 +333,4 @@ contributors (in addition to the above; based on Changelog) Jean Delvare Raphael Michel Damian Poddebniak - + Alvar Penning diff --git a/src/common/utils.c b/src/common/utils.c index 87575671a..848f0ce86 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Hiroyuki Yamamoto & The Claws Mail Team + * Copyright (C) 1999-2020 The Claws Mail Team and Hiroyuki Yamamoto * * 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 @@ -1486,11 +1486,28 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, } else if (body && !*body && !g_ascii_strcasecmp(field, "body")) { *body = decode_uri_gdup(value); } else if (body && !*body && !g_ascii_strcasecmp(field, "insert")) { + int i = 0; gchar *tmp = decode_uri_gdup(value); - if (!g_file_get_contents(tmp, body, NULL, NULL)) { - g_warning("couldn't set insert file '%s' in body", value); + + for (; forbidden_uris[i]; i++) { + if (strstr(tmp, forbidden_uris[i])) { + g_print("Refusing to insert '%s', potential private data leak\n", + tmp); + g_free(tmp); + tmp = NULL; + break; + } + } + + if (tmp) { + if (!is_file_entry_regular(tmp)) { + g_warning("Refusing to insert '%s', not a regular file\n", tmp); + } else if (!g_file_get_contents(tmp, body, NULL, NULL)) { + g_warning("couldn't set insert file '%s' in body", value); + } + + g_free(tmp); } - g_free(tmp); } else if (attach && !g_ascii_strcasecmp(field, "attach")) { int i = 0; gchar *tmp = decode_uri_gdup(value); @@ -1504,6 +1521,7 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, tmp); g_free(tmp); g_free(my_att); + tmp = NULL; break; } } @@ -1514,9 +1532,6 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, my_att[num_attach-1] = tmp; my_att[num_attach] = NULL; *attach = my_att; - g_free(tmp); - } else { - g_free(my_att); } } else if (inreplyto && !*inreplyto && !g_ascii_strcasecmp(field, "in-reply-to")) { @@ -2047,6 +2062,14 @@ gboolean is_file_entry_exist(const gchar *file) return g_file_test(file, G_FILE_TEST_EXISTS); } +gboolean is_file_entry_regular(const gchar *file) +{ + if (file == NULL) + return FALSE; + + return g_file_test(file, G_FILE_TEST_IS_REGULAR); +} + gboolean dirent_is_regular_file(struct dirent *d) { #if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE) diff --git a/src/common/utils.h b/src/common/utils.h index 47563b2a1..9816c4efc 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team + * Copyright (C) 1999-2020 The Claws Mail Team and Hiroyuki Yamamoto * * 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 @@ -413,6 +413,7 @@ gboolean file_exist (const gchar *file, gboolean is_relative_filename (const gchar *file); gboolean is_dir_exist (const gchar *dir); gboolean is_file_entry_exist (const gchar *file); +gboolean is_file_entry_regular(const gchar *file); gboolean dirent_is_regular_file (struct dirent *d); #define is_file_exist(file) file_exist(file, FALSE) diff --git a/src/gtk/authors.h b/src/gtk/authors.h index ae782c404..50f295125 100644 --- a/src/gtk/authors.h +++ b/src/gtk/authors.h @@ -254,6 +254,7 @@ static char *CONTRIBS_LIST[] = { "Thomas Orgis", "Reza Pakdel", "Richard Palo", +"Alvar Penning", "Damian Poddebniak", "Marcel Pol", "Martin Pool", ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From wwp at claws-mail.org Wed Aug 19 10:26:50 2020 From: wwp at claws-mail.org (wwp at claws-mail.org) Date: Wed, 19 Aug 2020 10:26:50 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-5-g1d95a1db5 Message-ID: <20200819082650.683724029A@claws-mail.org> The branch, master has been updated via 1d95a1db55b51c085f32cb368172c3c1b7420265 (commit) from 4c9d15b4b37cdc57edfa16df550a0a881a156153 (commit) Summary of changes: src/account.c | 6 ++++++ 1 file changed, 6 insertions(+) - Log ----------------------------------------------------------------- commit 1d95a1db55b51c085f32cb368172c3c1b7420265 Author: wwp Date: Wed Aug 19 10:23:55 2020 +0200 Add missing SSL settings copy when cloning accounts. diff --git a/src/account.c b/src/account.c index d3d7d8241..a8d8375f6 100644 --- a/src/account.c +++ b/src/account.c @@ -944,7 +944,13 @@ static void account_clone(GtkWidget *widget, gpointer data) ACP_FASSIGN(ssl_imap); ACP_FASSIGN(ssl_nntp); ACP_FASSIGN(ssl_smtp); + ACP_FASSIGN(ssl_certs_auto_accept); ACP_FASSIGN(use_nonblocking_ssl); + ACP_FASSIGN(use_tls_sni); + ACP_FASSIGN(in_ssl_client_cert_file); + ACP_FASSIGN(in_ssl_client_cert_pass); + ACP_FASSIGN(out_ssl_client_cert_file); + ACP_FASSIGN(out_ssl_client_cert_pass); /* receive */ ACP_FASSIGN(use_apop_auth); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Wed Aug 19 10:39:21 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Wed, 19 Aug 2020 10:39:21 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-985-gcab0ae3c9 Message-ID: <20200819083921.433CD40157@claws-mail.org> The branch, gtk3 has been updated via cab0ae3c97ec4842a4e97d5def4f855b0eac8e23 (commit) from 0e783b85770c8281264bb28fddecdd9b5e30a28d (commit) Summary of changes: src/account.c | 6 ++++++ 1 file changed, 6 insertions(+) - Log ----------------------------------------------------------------- commit cab0ae3c97ec4842a4e97d5def4f855b0eac8e23 Author: wwp Date: Wed Aug 19 10:23:55 2020 +0200 Add missing SSL settings copy when cloning accounts. diff --git a/src/account.c b/src/account.c index b54aefedd..209a1b04a 100644 --- a/src/account.c +++ b/src/account.c @@ -944,7 +944,13 @@ static void account_clone(GtkWidget *widget, gpointer data) ACP_FASSIGN(ssl_imap); ACP_FASSIGN(ssl_nntp); ACP_FASSIGN(ssl_smtp); + ACP_FASSIGN(ssl_certs_auto_accept); ACP_FASSIGN(use_nonblocking_ssl); + ACP_FASSIGN(use_tls_sni); + ACP_FASSIGN(in_ssl_client_cert_file); + ACP_FASSIGN(in_ssl_client_cert_pass); + ACP_FASSIGN(out_ssl_client_cert_file); + ACP_FASSIGN(out_ssl_client_cert_pass); /* receive */ ACP_FASSIGN(use_apop_auth); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From wwp at claws-mail.org Wed Aug 19 10:59:29 2020 From: wwp at claws-mail.org (wwp at claws-mail.org) Date: Wed, 19 Aug 2020 10:59:29 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-6-ga1c0649aa Message-ID: <20200819085930.1321D401BB@claws-mail.org> The branch, master has been updated via a1c0649aa197dc53df4e15f9342f7faeb2efd496 (commit) from 1d95a1db55b51c085f32cb368172c3c1b7420265 (commit) Summary of changes: doc/man/claws-mail.1 | 156 ++++++++++-------- src/common/claws.c | 2 +- src/main.c | 435 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 350 insertions(+), 243 deletions(-) - Log ----------------------------------------------------------------- commit a1c0649aa197dc53df4e15f9342f7faeb2efd496 Author: wwp Date: Wed Aug 19 10:57:11 2020 +0200 Fix parsing of command-line arguments: - matching substrings won't work anymore (--receive-al won't match --receive),, I'm not sure at all this was intentional, - fix and enhancement handling of mandatory and optional arguments to options (and fix their representation in --help), - fix sub-arguments not being properly eaten by parser, then being parsed twice, - -d is now an alias to --debug, - avoid hardcoding strings length (fd_write, fd_write_all, strncmp), this is prone to error, - more comprehensive error messages, - man page content updates and fixes, format fixes and enhancements. diff --git a/doc/man/claws-mail.1 b/doc/man/claws-mail.1 index 81b2bfab4..4c8b2c2d8 100644 --- a/doc/man/claws-mail.1 +++ b/doc/man/claws-mail.1 @@ -6,7 +6,7 @@ Claws Mail \- a GTK+ based fast email and news client .SH "SYNOPSIS" .B claws\-mail -.RI [ options ] +.RI [ options ]... .SH "DESCRIPTION" .TP @@ -99,9 +99,9 @@ This list is not complete. .br \fB \-\-subscribe\fR uri .br -\fB \-\-attach file1 [file2]...\fR +\fB \-\-attach\fR file1 [file2]...\fR .br -\fB \-\-insert file1 [file2]...\fR +\fB \-\-insert\fR file1 [file2]...\fR .br \fB \-\-receive\fR .br @@ -111,19 +111,23 @@ This list is not complete. .br \fB \-\-cancel\-sending\fR .br +\fB \-\-search\fR folder type request [recursive] +.br \fB \-\-send\fR .br \fB \-\-status\fR .br -\fB \-\-status folder[/subfolder]\fR +\fB \-\-status\fR folder[/subfolder] .br \fB \-\-status\-full\fR .br +\fB \-\-status\-full\fR folder[/subfolder] +.br \fB \-\-statistics\fR .br \fB \-\-reset-statistics\fR .br -\fB \-\-select [#mh/mailbox/]folder[/msg|/msgid]\fR +\fB \-\-select\fR [#mh/mailbox/]folder[/msg|/msgid], a file:// uri or an absolute path .br \fB \-\-online\fR .br @@ -143,121 +147,121 @@ This list is not complete. .br \fB \-\-config\-dir\fR .br -\fB \-\-alternate\-config\-dir directory\fR +\fB \-\-alternate\-config\-dir\fR directory .br -\fB \-\-geometry WxH+X+Y\fR +\fB \-\-geometry\fR [WxH][+X+Y] .SH "FILES" .LP .TP -$HOME/Mail +\fB$HOME/Mail\fR Default directory for mail storage. .TP -$PREFIX/share/claws\-mail +\fB$PREFIX/share/claws\-mail\fR Global program directory. .TP -$PREFIX/share/claws\-mail/manual +\fB$PREFIX/share/claws\-mail/manual\fR Manual files in HTML, PDF, PostScript and plain text format. .TP -$PREFIX/share/claws\-mail/themes +\fB$PREFIX/share/claws\-mail/themes\fR Global themes directory. .TP -$PREFIX/lib/claws\-mail/plugins +\fB$PREFIX/lib/claws\-mail/plugins\fR Directory for plugins. .TP -$PREFIX/include/claws\-mail +\fB$PREFIX/include/claws\-mail\fR Directory for header files. .TP -$HOME/.claws\-mail +\fB$HOME/.claws\-mail\fR Default directory for user's configuration files directory. .TP -$HOME/.claws\-mail/addrbook/* +\fB$HOME/.claws\-mail/addrbook/*\fR Addressbook files. .TP -$HOME/.claws\-mail/autofaces/* +\fB$HOME/.claws\-mail/autofaces/*\fR Automatic Faces and X\-Faces files for accounts. .TP -$HOME/.claws\-mail/certs/* +\fB$HOME/.claws\-mail/certs/*\fR SSL certificates received from mail servers. .TP -$HOME/.claws\-mail/tagsdb +\fB$HOME/.claws\-mail/tagsdb\fR Tags directory. .TP -$HOME/.claws\-mail/templates +\fB$HOME/.claws\-mail/templates\fR User\-defined templates directory. .TP -$HOME/.claws\-mail/themes +\fB$HOME/.claws\-mail/themes\fR User's themes directory. .TP -$HOME/.claws\-mail/accountrc +\fB$HOME/.claws\-mail/accountrc\fR Configuration for account(s). .TP -$HOME/.claws\-mail/actionsrc +\fB$HOME/.claws\-mail/actionsrc\fR User\-defined custom actions. .TP -$HOME/.claws\-mail/addrbook/attributesrc +\fB$HOME/.claws\-mail/addrbook/attributesrc\fR User\-defined address book custom attributes. .TP -$HOME/.claws\-mail/claws.log +\fB$HOME/.claws\-mail/claws.log\fR Claws Mail logfile. .TP -$HOME/.claws\-mail/clawsrc +\fB$HOME/.claws\-mail/clawsrc\fR Main configuration file. .TP -$HOME/.claws\-mail/command_history +\fB$HOME/.claws\-mail/command_history\fR User\-specified commands. .TP -$HOME/.claws\-mail/customheaderrc +\fB$HOME/.claws\-mail/customheaderrc\fR Configuration for custom headers for sending mail. .TP -$HOME/.claws\-mail/dispheaderrc +\fB$HOME/.claws\-mail/dispheaderrc\fR Configuration for custom display of headers in message view. .TP -$HOME/.claws\-mail/extraheaderrc +\fB$HOME/.claws\-mail/extraheaderrc\fR Editable extra headers to be added to compose window combobox. .TP -$HOME/.claws\-mail/folderitemrc +\fB$HOME/.claws\-mail/folderitemrc\fR All folders' attributes. .TP -$HOME/.claws\-mail/folderlist.xml +\fB$HOME/.claws\-mail/folderlist.xml\fR Folder hierarchy listing. .TP -$HOME/.claws\-mail/gtkrc-2.0 +\fB$HOME/.claws\-mail/gtkrc-2.0\fR Optional GTK+ settings to be load on startup. .TP -$HOME/.claws\-mail/matcherrc +\fB$HOME/.claws\-mail/matcherrc\fR Filtering and Processing function configuration. .TP -$HOME/.claws\-mail/menurc +\fB$HOME/.claws\-mail/menurc\fR Menu shortcut\-key configuration. .TP -$HOME/.claws\-mail/messagesearch_history +\fB$HOME/.claws\-mail/messagesearch_history\fR User\-specified searches in message bodies. .TP -$HOME/.claws\-mail/quicksearch_history +\fB$HOME/.claws\-mail/quicksearch_history\fR User\-specified quick\-search list. .TP -$HOME/.claws\-mail/messagesearch_history +\fB$HOME/.claws\-mail/messagesearch_history\fR User\-specified searches in message bodies. .TP -$HOME/.claws\-mail/summary*_history +\fB$HOME/.claws\-mail/summary*_history\fR User\-specified searches in message list. .TP -$HOME/.claws\-mail/passwordstorerc +\fB$HOME/.claws\-mail/passwordstorerc\fR User saved passwords. .TP -$HOME/.claws\-mail/tagsrc +\fB$HOME/.claws\-mail/tagsrc\fR User\-specified tag list. .TP -$HOME/.claws\-mail/toolbar*.xml +\fB$HOME/.claws\-mail/toolbar*.xml\fR User\-defined custom toolbars. .TP -%TEMP%\\claws\-win32.log -(Windows only) Claws Mail output file when \-\-debug is enabled. If +\fB%TEMP%\\claws\-win32.log \fI(Windows only)\fR +Claws Mail output file when \-\-debug is enabled. If %TEMP% is not set it defaults to windows directory (usually C:\\Windows) or C:\\ if windows directory is not available. .TP -(Windows only) %APPDATA%\\Claws\-mail\\claws.log +\fB %APPDATA%\\Claws\-mail\\claws.log \fI(Windows only)\fR Claws Mail log file. .SH "EXAMPLES" @@ -268,30 +272,30 @@ claws\-mail .LP Alternatively you can run it with the following options: .TP -\fB\-\-compose [address]\fR +\fB\-\-compose\fR [address] To open a Compose window. .TP -\fB\-\-compose\-from\-file file +\fB\-\-compose\fR "mailto:\fI%t\fR?subject=\fI%s\fR&cc=\fI%c\fR&body=\fI%b\fR" +This syntax can be used in web\-browsers and CLI to open a pre\-populated +Compose window. Possible fields after the destination recipient are: subject, +from, cc, bcc, in\-reply\-to, body, insert (insert a file in body part, needs +an absolute path), attach (attach a file, needs an absolute path, see also: +\-\-attach). +.TP +\fB\-\-compose\-from\-file\fR file Open composition window with data from the given file. Use \- as file name for reading from standard input. Content format: headers first (To: header required) until an empty line is found, then mail body until end of file. .TP -\fB\-\-subscribe [uri]\fR +\fB\-\-subscribe\fR uri Subscribe to the given URI if possible. .TP -\fB\-\-attach file1 [file2]...\fR +\fB\-\-attach\fR file1 [file2]... Open composition window with specified files attached. .TP -\fB\-\-insert file1 [file2]...\fR +\fB\-\-insert\fR file1 [file2]... Open composition window with specified files inserted. .TP -\fB\-\-compose\fR "mailto:\fI%t\fR?subject=\fI%s\fR&cc=\fI%c\fR&body=\fI%b\fR" -This syntax can be used in web\-browsers and CLI to open a pre\-populated -Compose window. Possible fields after the destination recipient are: subject, -from, cc, bcc, in\-reply\-to, body, insert (insert a file in body part, needs -an absolute path), attach (attach a file, needs an absolute path, see also: -\-\-attach). -.TP \fB\-\-receive\fR Receive new messages. .TP @@ -304,6 +308,18 @@ Cancel receiving of messages. \fB\-\-cancel\-sending\fR Cancel sending of messages. .TP +\fB\-\-search\fR folder type request [recursive] +.br +Searches mail: +.br +folder ex.: "#mh/Mailbox/inbox" or "Mail" +.br +type: s[ubject],f[rom],t[o],e[xtended],m[ixed] or g: tag +.br +request: search string +.br +recursive: false if arg. starts with 0, n, N, f or F +.TP \fB\-\-send\fR .br Send all queued messages. @@ -313,7 +329,7 @@ Show the total number of messages: .br [new][unread][unread answers to marked][total] .TP -\fB\-\-status folder[/subfolder]\fR +\fB\-\-status\fR folder[/subfolder] Show the total number of messages in the specified folder: .br [new][unread][unread answers to marked][total] @@ -323,6 +339,11 @@ Show the total number of messages per folder: .br [new][unread][unread answers to marked][total] .TP +\fB\-\-status\-full\fR folder[/subfolder] +Show the total number of messages int the specified folder: +.br +[new][unread][unread answers to marked][total] +.TP \fB\-\-statistics\fR .br Show session statistics. @@ -331,8 +352,15 @@ Show session statistics. .br Reset session statistics. .TP -\fB\-\-select [#mh/mailbox/]folder[/msg|/msgid]\fR -On startup, jumps to the specified folder/message. +\fB\-\-select\fR #mh/Mailbox/inbox/123 +.RS 0 +.br +\fB\-\-select\fR file://home/johndoe/Mail/inbox/123 +.br +\fB\-\-select\fR /home/johndoe/Mail/inbox/123 +.RS +On startup, jump to the specified folder/message. +.RE .TP \fB\-\-online\fR Start Claws Mail in (or switch to, if already running) online mode. @@ -340,9 +368,6 @@ Start Claws Mail in (or switch to, if already running) online mode. \fB\-\-offline\fR Start Claws Mail in (or switch to, if already running) offline mode. .TP -\fB\-\-help\fR -Display the help message and exit. -.TP \fB\-\-exit\fR Exit Claws Mail. .TP @@ -354,6 +379,9 @@ section). \fB\-\-toggle-debug\fR Toggle debug mode of the running Claws Mail instance. .TP +\fB\-\-help\fR +Display the help message and exit. +.TP \fB\-\-version\fR Display version number and exit. .TP @@ -363,10 +391,10 @@ Display version number and compiled\-in features then exit. \fB\-\-config\-dir\fR Display the CONFIG\-DIR and exit. .TP -\fB\-\-alternate\-config\-dir [dir]\fR +\fB\-\-alternate\-config\-dir\fR dir Start Claws Mail with the configuration stored in the [dir] directory. .TP -\fB\-\-geometry WxH+X+Y\fR +\fB\-\-geometry\fR [WxH][+X+Y] Set initial X geometry of main window. .SH "ENVIRONMENT" diff --git a/src/common/claws.c b/src/common/claws.c index f7d568369..013a6ecc4 100644 --- a/src/common/claws.c +++ b/src/common/claws.c @@ -63,7 +63,7 @@ static void parse_parameter(int *argc, char ***argv) cm_return_if_fail(argv != NULL); for (i = 1; i < *argc;) { - if (strcmp("--debug", (*argv)[i]) == 0) { + if ((strcmp("--debug", (*argv)[i]) == 0) || (strcmp("-d", (*argv)[i]) == 0)) { debug_set_mode(TRUE); (*argv)[i] = NULL; diff --git a/src/main.c b/src/main.c index 8e2f2948c..00fbe4f6e 100644 --- a/src/main.c +++ b/src/main.c @@ -257,6 +257,11 @@ static void networkmanager_state_change_cb(DBusGProxy *proxy, gchar *dev, } \ } +#define STRNCMP(S1, S2) (strncmp((S1), (S2), sizeof((S2)) - 1)) + +#define FD_WRITE(S) fd_write(sock, (S), strlen((S))) +#define FD_WRITE_ALL(S) fd_write(sock, (S), strlen((S))) + static MainWindow *static_mainwindow; static gboolean emergency_exit = FALSE; @@ -471,7 +476,7 @@ static int migrate_common_rc(const gchar *old_rc, const gchar *new_rc) } debug_print("replacing %s with %s\n", old_plugin_path, new_plugin_path); while (claws_fgets(buf, sizeof(buf), oldfp)) { - if (strncmp(buf, old_plugin_path, strlen(old_plugin_path))) { + if (STRNCMP(buf, old_plugin_path)) { err |= (claws_fputs(buf, newfp) == EOF); } else { debug_print("->replacing %s\n", buf); @@ -1850,85 +1855,118 @@ static GString * parse_cmd_compose_from_file(const gchar *fn) #undef G_PRINT_EXIT +static void parse_cmd_opt_error(char *errstr, char* optstr) +{ + gchar tmp[BUFSIZ]; + + cm_return_if_fail(errstr != NULL); + cm_return_if_fail(optstr != NULL); + + g_snprintf(tmp, sizeof(tmp), errstr, optstr); + g_print(_("%s. Try -h or --help for usage.\n"), tmp); + exit(1); +} + static void parse_cmd_opt(int argc, char *argv[]) { AttachInfo *ainfo; gint i; for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], "--receive-all", 13)) { + if (!strcmp(argv[i], "--receive-all")) { cmd.receive_all = TRUE; - } else if (!strncmp(argv[i], "--receive", 9)) { + } else if (!strcmp(argv[i], "--receive")) { cmd.receive = TRUE; - } else if (!strncmp(argv[i], "--cancel-receiving", 18)) { + } else if (!strcmp(argv[i], "--cancel-receiving")) { cmd.cancel_receiving = TRUE; - } else if (!strncmp(argv[i], "--cancel-sending", 16)) { + } else if (!strcmp(argv[i], "--cancel-sending")) { cmd.cancel_sending = TRUE; - } else if (!strncmp(argv[i], "--compose-from-file", 19)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; + } else if (!strcmp(argv[i], "--compose-from-file")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; - GString *mailto = parse_cmd_compose_from_file(p); - cmd.compose = TRUE; - cmd.compose_mailto = mailto->str; - i++; - } else if (!strncmp(argv[i], "--compose", 9)) { + GString *mailto = parse_cmd_compose_from_file(p); + cmd.compose = TRUE; + cmd.compose_mailto = mailto->str; + i++; + } else { + parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--compose")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.compose = TRUE; cmd.compose_mailto = NULL; if (p && *p != '\0' && *p != '-') { - if (!strncmp(p, "mailto:", 7)) { + if (!STRNCMP(p, "mailto:")) { cmd.compose_mailto = p + 7; } else { cmd.compose_mailto = p; } i++; } - } else if (!strncmp(argv[i], "--subscribe", 11)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; - if (p && *p != '\0' && *p != '-') { - cmd.subscribe = TRUE; - cmd.subscribe_uri = p; + } else if (!strcmp(argv[i], "--subscribe")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; + if (p && *p != '\0' && *p != '-') { + cmd.subscribe = TRUE; + cmd.subscribe_uri = p; + } else { + parse_cmd_opt_error(_("Missing or empty uri argument for option %s"), argv[i]); + } + } else { + parse_cmd_opt_error(_("Missing uri argument for option %s"), argv[i]); } - } else if (!strncmp(argv[i], "--attach", 8) || !strncmp(argv[i], "--insert", 8)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; - gchar *file = NULL; - gboolean insert = !strncmp(argv[i], "--insert", 8); - - while (p && *p != '\0' && *p != '-') { - if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) { - if (!is_file_exist(file)) { - g_free(file); - file = NULL; + } else if (!strcmp(argv[i], "--attach") || + !strcmp(argv[i], "--insert")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; + gint ii = i; + gchar *file = NULL; + gboolean insert = !strcmp(argv[i], "--insert"); + + while (p && *p != '\0' && *p != '-') { + if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) { + if (!is_file_exist(file)) { + g_free(file); + file = NULL; + } + } + if (file == NULL && *p != G_DIR_SEPARATOR) { + file = g_strconcat(claws_get_startup_dir(), + G_DIR_SEPARATOR_S, + p, NULL); + } else if (file == NULL) { + file = g_strdup(p); } - } - if (file == NULL && *p != G_DIR_SEPARATOR) { - file = g_strconcat(claws_get_startup_dir(), - G_DIR_SEPARATOR_S, - p, NULL); - } else if (file == NULL) { - file = g_strdup(p); - } - ainfo = g_new0(AttachInfo, 1); - ainfo->file = file; - ainfo->insert = insert; - cmd.attach_files = g_list_append(cmd.attach_files, ainfo); - i++; - p = (i+1 < argc)?argv[i+1]:NULL; + ainfo = g_new0(AttachInfo, 1); + ainfo->file = file; + ainfo->insert = insert; + cmd.attach_files = g_list_append(cmd.attach_files, ainfo); + ii++; + p = (ii+1 < argc)?argv[ii+1]:NULL; + } + if (ii==i) { + parse_cmd_opt_error(_("Missing at least one non-empty file argument for option %s"), argv[i]); + } else { + i=ii; + } + } else { + parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]); } - } else if (!strncmp(argv[i], "--send", 6)) { + } else if (!strcmp(argv[i], "--send")) { cmd.send = TRUE; - } else if (!strncmp(argv[i], "--version-full", 14) || - !strncmp(argv[i], "-V", 2)) { + } else if (!strcmp(argv[i], "--version-full") || + !strcmp(argv[i], "-V")) { g_print("Claws Mail version " VERSION_GIT_FULL "\n"); main_dump_features_list(FALSE); exit(0); - } else if (!strncmp(argv[i], "--version", 9) || - !strncmp(argv[i], "-v", 2)) { + } else if (!strcmp(argv[i], "--version") || + !strcmp(argv[i], "-v")) { g_print("Claws Mail version " VERSION "\n"); exit(0); - } else if (!strncmp(argv[i], "--status-full", 13)) { + } else if (!strcmp(argv[i], "--status-full")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.status_full = TRUE; @@ -1942,7 +1980,7 @@ static void parse_cmd_opt(int argc, char *argv[]) i++; p = (i+1 < argc)?argv[i+1]:NULL; } - } else if (!strncmp(argv[i], "--status", 8)) { + } else if (!strcmp(argv[i], "--status")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.status = TRUE; @@ -1954,28 +1992,52 @@ static void parse_cmd_opt(int argc, char *argv[]) i++; p = (i+1 < argc)?argv[i+1]:NULL; } - } else if (!strncmp(argv[i], "--search", 8)) { - cmd.search_folder = (i+1 < argc)?argv[i+1]:NULL; - cmd.search_type = (i+2 < argc)?argv[i+2]:NULL; - cmd.search_request = (i+3 < argc)?argv[i+3]:NULL; - const char* rec = (i+4 < argc)?argv[i+4]:NULL; - cmd.search_recursive = TRUE; - if (rec && (tolower(*rec)=='n' || tolower(*rec)=='f' || *rec=='0')) - cmd.search_recursive = FALSE; - if (cmd.search_folder && cmd.search_type && cmd.search_request) - cmd.search = TRUE; - } else if (!strncmp(argv[i], "--online", 8)) { + } else if (!strcmp(argv[i], "--search")) { + if (i+3 < argc) { /* 3 first arguments are mandatory */ + const char* p; + /* only set search parameters if they are valid */ + p = argv[i+1]; + cmd.search_folder = (p && *p != '\0' && *p != '-')?p:NULL; + p = argv[i+2]; + cmd.search_type = (p && *p != '\0' && *p != '-')?p:NULL; + p = argv[i+3]; + cmd.search_request = (p && *p != '\0' && *p != '-')?p:NULL; + p = (i+4 < argc)?argv[i+4]:NULL; + const char* rec = (p && *p != '\0' && *p != '-')?p:NULL; + cmd.search_recursive = TRUE; + if (rec) { + i++; + if (tolower(*rec)=='n' || tolower(*rec)=='f' || *rec=='0') + cmd.search_recursive = FALSE; + } + if (cmd.search_folder && cmd.search_type && cmd.search_request) { + cmd.search = TRUE; + i+=3; + } + } else { + switch (argc-i-1) { + case 0: + parse_cmd_opt_error(_("Missing folder, type and request arguments for option %s"), argv[i]); + break; + case 1: + parse_cmd_opt_error(_("Missing type and request arguments for option %s"), argv[i]); + break; + case 2: + parse_cmd_opt_error(_("Missing request argument for option %s"), argv[i]); + } + } + } else if (!strcmp(argv[i], "--online")) { cmd.online_mode = ONLINE_MODE_ONLINE; - } else if (!strncmp(argv[i], "--offline", 9)) { + } else if (!strcmp(argv[i], "--offline")) { cmd.online_mode = ONLINE_MODE_OFFLINE; - } else if (!strncmp(argv[i], "--toggle-debug", 14)) { + } else if (!strcmp(argv[i], "--toggle-debug")) { cmd.debug = TRUE; - } else if (!strncmp(argv[i], "--statistics", 12)) { + } else if (!strcmp(argv[i], "--statistics")) { cmd.statistics = TRUE; - } else if (!strncmp(argv[i], "--reset-statistics", 18)) { + } else if (!strcmp(argv[i], "--reset-statistics")) { cmd.reset_statistics = TRUE; - } else if (!strncmp(argv[i], "--help", 6) || - !strncmp(argv[i], "-h", 2)) { + } else if (!strcmp(argv[i], "--help") || + !strcmp(argv[i], "-h")) { gchar *base = g_path_get_basename(argv[0]); g_print(_("Usage: %s [OPTION]...\n"), base); @@ -2009,12 +2071,12 @@ static void parse_cmd_opt(int argc, char *argv[]) " show the status of each folder")); g_print("%s\n", _(" --statistics show session statistics")); g_print("%s\n", _(" --reset-statistics reset session statistics")); - g_print("%s\n", _(" --select folder[/msg] jumps to the specified folder/message\n" - " folder is a folder id like 'folder/sub_folder'")); + g_print("%s\n", _(" --select folder[/msg] jump to the specified folder/message\n" + " folder is a folder id like 'folder/sub_folder', a file:// uri or an absolute path")); g_print("%s\n", _(" --online switch to online mode")); g_print("%s\n", _(" --offline switch to offline mode")); g_print("%s\n", _(" --exit --quit -q exit Claws Mail")); - g_print("%s\n", _(" --debug debug mode")); + g_print("%s\n", _(" --debug -d debug mode")); g_print("%s\n", _(" --toggle-debug toggle debug mode")); g_print("%s\n", _(" --help -h display this help and exit")); g_print("%s\n", _(" --version -v output version information and exit")); @@ -2022,46 +2084,62 @@ static void parse_cmd_opt(int argc, char *argv[]) g_print("%s\n", _(" --config-dir output configuration directory")); g_print("%s\n", _(" --alternate-config-dir directory\n" " use specified configuration directory")); - g_print("%s\n", _(" --geometry -geometry WxH+X+Y\n" + g_print("%s\n", _(" --geometry -geometry [WxH][+X+Y]\n" " set geometry for main window")); g_free(base); exit(1); - } else if (!strncmp(argv[i], "--crash", 7)) { + } else if (!strcmp(argv[i], "--crash")) { cmd.crash = TRUE; cmd.crash_params = g_strdup((i+1 < argc)?argv[i+1]:NULL); i++; - } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) { + } else if (!strcmp(argv[i], "--config-dir")) { g_print(RC_DIR "\n"); exit(0); - } else if (!strncmp(argv[i], "--alternate-config-dir", sizeof "--alternate-config-dir" - 1) && i+1 < argc) { - set_rc_dir(argv[i+1]); - } else if (!strncmp(argv[i], "--geometry", sizeof "--geometry" - 1) - || !strncmp(argv[i], "-geometry", sizeof "-geometry" - 1)) { - cmd.geometry = (i+1 < argc)? argv[i+1]: NULL; - } else if (!strncmp(argv[i], "--exit", 6) || - !strncmp(argv[i], "--quit", 6) || - !strncmp(argv[i], "-q", 2)) { + } else if (!strcmp(argv[i], "--alternate-config-dir")) { + if (i+1 < argc) { + set_rc_dir(argv[i+1]); + i++; + } else { + parse_cmd_opt_error(_("Missing directory argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--geometry") || + !strcmp(argv[i], "-geometry")) { + if (i+1 < argc) { + cmd.geometry = argv[i+1]; + i++; + } else { + parse_cmd_opt_error(_("Missing geometry argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--exit") || + !strcmp(argv[i], "--quit") || + !strcmp(argv[i], "-q")) { cmd.exit = TRUE; - } else if (!strncmp(argv[i], "--select", 8) && i+1 < argc) { - cmd.target = argv[i+1]; + } else if (!strcmp(argv[i], "--select")) { + if (i+1 < argc) { + cmd.target = argv[i+1]; + i++; + } else { + parse_cmd_opt_error(_("Missing folder argument for option %s"), argv[i]); + } } else if (i == 1 && argc == 2) { /* only one parameter. Do something intelligent about it */ - if ((strstr(argv[i], "@")||!strncmp(argv[i], "mailto:", 7)) && !strstr(argv[i], "://")) { + if ((strstr(argv[i], "@") || !STRNCMP(argv[i], "mailto:")) && !strstr(argv[i], "://")) { const gchar *p = argv[i]; cmd.compose = TRUE; cmd.compose_mailto = NULL; if (p && *p != '\0' && *p != '-') { - if (!strncmp(p, "mailto:", 7)) { + if (!STRNCMP(p, "mailto:")) { cmd.compose_mailto = p + 7; } else { cmd.compose_mailto = p; } } - } else if (!strncmp(argv[i], "file://", 7)) { + } else if (!STRNCMP(argv[i], "file://")) { cmd.target = argv[i]; - } else if (!strncmp(argv[i], "?attach=file://", strlen("?attach=file://"))) { + } else if (!STRNCMP(argv[i], "?attach=file://")) { + /* Thunar support as per 3.3.0cvs19 */ cmd.compose = TRUE; cmd.compose_mailto = argv[i]; } else if (strstr(argv[i], "://")) { @@ -2074,11 +2152,12 @@ static void parse_cmd_opt(int argc, char *argv[]) /* gtk debug */ } else if (is_dir_exist(argv[i]) || is_file_exist(argv[i])) { cmd.target = argv[i]; - } else { - g_print(_("Unknown option. Try -h or --help for usage.\n")); - exit(1); - } - } + } else { + parse_cmd_opt_error(_("Unknown option %s"), argv[i]); + } + } else { + parse_cmd_opt_error(_("Unknown option %s"), argv[i]); + } } if (cmd.attach_files && cmd.compose == FALSE) { @@ -2274,19 +2353,19 @@ static gchar *get_crashfile_name(void) static gint prohibit_duplicate_launch(void) { - gint uxsock; + gint sock; GList *curr; #ifdef G_OS_UNIX gchar *path; path = claws_get_socket_name(); /* Try to connect to the control socket */ - uxsock = fd_connect_unix(path); + sock = fd_connect_unix(path); if (x_display == NULL) x_display = g_strdup(g_getenv("DISPLAY")); - if (uxsock < 0) { + if (sock < 0) { gint ret; #if HAVE_FLOCK gchar *socket_lock; @@ -2336,14 +2415,14 @@ static gint prohibit_duplicate_launch(void) return -1; } if (GetLastError() != ERROR_ALREADY_EXISTS) { - uxsock = fd_open_inet(50216); - if (uxsock < 0) + sock = fd_open_inet(50216); + if (sock < 0) return 0; - return uxsock; + return sock; } - uxsock = fd_connect_inet(50216); - if (uxsock < 0) + sock = fd_connect_inet(50216); + if (sock < 0) return -1; #endif /* remote command mode */ @@ -2351,13 +2430,13 @@ static gint prohibit_duplicate_launch(void) debug_print("another Claws Mail instance is already running.\n"); if (cmd.receive_all) { - fd_write_all(uxsock, "receive_all\n", 12); + FD_WRITE_ALL("receive_all\n"); } else if (cmd.receive) { - fd_write_all(uxsock, "receive\n", 8); + FD_WRITE_ALL("receive\n"); } else if (cmd.cancel_receiving) { - fd_write_all(uxsock, "cancel_receiving\n", 17); + FD_WRITE_ALL("cancel_receiving\n"); } else if (cmd.cancel_sending) { - fd_write_all(uxsock, "cancel_sending\n", 15); + FD_WRITE_ALL("cancel_sending\n"); } else if (cmd.compose && cmd.attach_files) { gchar *str, *compose_str; @@ -2368,20 +2447,20 @@ static gint prohibit_duplicate_launch(void) compose_str = g_strdup("compose_attach\n"); } - fd_write_all(uxsock, compose_str, strlen(compose_str)); + FD_WRITE_ALL(compose_str); g_free(compose_str); for (curr = cmd.attach_files; curr != NULL ; curr = curr->next) { str = (gchar *) ((AttachInfo *)curr->data)->file; if (((AttachInfo *)curr->data)->insert) - fd_write_all(uxsock, "insert ", strlen("insert ")); + FD_WRITE_ALL("insert "); else - fd_write_all(uxsock, "attach ", strlen("attach ")); - fd_write_all(uxsock, str, strlen(str)); - fd_write_all(uxsock, "\n", 1); + FD_WRITE_ALL("attach "); + FD_WRITE_ALL(str); + FD_WRITE_ALL("\n"); } - fd_write_all(uxsock, ".\n", 2); + FD_WRITE_ALL(".\n"); } else if (cmd.compose) { gchar *compose_str; @@ -2392,20 +2471,20 @@ static gint prohibit_duplicate_launch(void) compose_str = g_strdup("compose\n"); } - fd_write_all(uxsock, compose_str, strlen(compose_str)); + FD_WRITE_ALL(compose_str); g_free(compose_str); } else if (cmd.subscribe) { gchar *str = g_strdup_printf("subscribe %s\n", cmd.subscribe_uri); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); } else if (cmd.send) { - fd_write_all(uxsock, "send\n", 5); + FD_WRITE_ALL("send\n"); } else if (cmd.online_mode == ONLINE_MODE_ONLINE) { - fd_write(uxsock, "online\n", 7); + FD_WRITE("online\n"); } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) { - fd_write(uxsock, "offline\n", 8); + FD_WRITE("offline\n"); } else if (cmd.debug) { - fd_write(uxsock, "debug\n", 6); + FD_WRITE("debug\n"); } else if (cmd.status || cmd.status_full) { gchar buf[BUFFSIZE]; gint i; @@ -2417,41 +2496,41 @@ static gint prohibit_duplicate_launch(void) folders = cmd.status_full ? cmd.status_full_folders : cmd.status_folders; - fd_write_all(uxsock, command, strlen(command)); + FD_WRITE_ALL(command); for (i = 0; folders && i < folders->len; ++i) { folder = g_ptr_array_index(folders, i); - fd_write_all(uxsock, folder, strlen(folder)); - fd_write_all(uxsock, "\n", 1); + FD_WRITE_ALL(folder); + FD_WRITE_ALL("\n"); } - fd_write_all(uxsock, ".\n", 2); + FD_WRITE_ALL(".\n"); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; 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_WRITE_ALL("exit\n"); } else if (cmd.statistics) { gchar buf[BUFSIZ]; - fd_write(uxsock, "statistics\n", 11); + FD_WRITE("statistics\n"); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; 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_WRITE("reset_statistics\n"); } else if (cmd.target) { gchar *str = g_strdup_printf("select %s\n", cmd.target); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); } else if (cmd.search) { gchar buf[BUFFSIZE]; @@ -2459,12 +2538,12 @@ static gint prohibit_duplicate_launch(void) g_strdup_printf("search %s\n%s\n%s\n%c\n", cmd.search_folder, cmd.search_type, cmd.search_request, (cmd.search_recursive==TRUE)?'1':'0'); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; if (claws_fputs(buf, stdout) == EOF) { g_warning("writing to stdout failed."); break; @@ -2473,24 +2552,24 @@ static gint prohibit_duplicate_launch(void) } else { #ifdef G_OS_UNIX gchar buf[BUFSIZ]; - fd_write_all(uxsock, "get_display\n", 12); + FD_WRITE_ALL("get_display\n"); memset(buf, 0, sizeof(buf)); - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; if (g_strcmp0(buf, x_display)) { g_print("Claws Mail is already running on display %s.\n", buf); } else { - fd_close(uxsock); - uxsock = fd_connect_unix(path); - fd_write_all(uxsock, "popup\n", 6); + fd_close(sock); + sock = fd_connect_unix(path); + FD_WRITE_ALL("popup\n"); } #else - fd_write_all(uxsock, "popup\n", 6); + FD_WRITE_ALL("popup\n"); #endif } - fd_close(uxsock); + fd_close(sock); return -1; } @@ -2528,7 +2607,7 @@ static GPtrArray *get_folder_item_list(gint sock) for (;;) { fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) { + if (!STRNCMP(buf, ".\n")) { break; } strretchomp(buf); @@ -2561,23 +2640,23 @@ static void lock_socket_input_cb(gpointer data, fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, "popup", 5)) { + if (!STRNCMP(buf, "popup")) { main_window_popup(mainwin); #ifdef G_OS_UNIX - } else if (!strncmp(buf, "get_display", 11)) { - fd_write_all(sock, x_display, strlen(x_display)); + } else if (!STRNCMP(buf, "get_display")) { + FD_WRITE_ALL(x_display); #endif - } else if (!strncmp(buf, "receive_all", 11)) { + } else if (!STRNCMP(buf, "receive_all")) { inc_all_account_mail(mainwin, FALSE, FALSE, prefs_common.newmail_notify_manu); - } else if (!strncmp(buf, "receive", 7)) { + } else if (!STRNCMP(buf, "receive")) { inc_mail(mainwin, prefs_common.newmail_notify_manu); - } else if (!strncmp(buf, "cancel_receiving", 16)) { + } else if (!STRNCMP(buf, "cancel_receiving")) { inc_cancel_all(); imap_cancel_all(); - } else if (!strncmp(buf, "cancel_sending", 14)) { + } else if (!STRNCMP(buf, "cancel_sending")) { send_cancel(); - } else if (!strncmp(buf, "compose_attach", 14)) { + } else if (!STRNCMP(buf, "compose_attach")) { GList *files = NULL, *curr; AttachInfo *ainfo; gchar *mailto; @@ -2591,7 +2670,7 @@ static void lock_socket_input_cb(gpointer data, ainfo = g_new0(AttachInfo, 1); ainfo->file = g_strdup(strstr(buf, " ") + 1); - ainfo->insert = !strncmp(buf, "insert ", 7); + ainfo->insert = !STRNCMP(buf, "insert "); files = g_list_append(files, ainfo); } open_compose_new(mailto, files); @@ -2605,36 +2684,36 @@ static void lock_socket_input_cb(gpointer data, } g_list_free(files); g_free(mailto); - } else if (!strncmp(buf, "compose", 7)) { + } else if (!STRNCMP(buf, "compose")) { open_compose_new(buf + strlen("compose") + 1, NULL); - } else if (!strncmp(buf, "subscribe", 9)) { + } else if (!STRNCMP(buf, "subscribe")) { main_window_popup(mainwin); folder_subscribe(buf + strlen("subscribe") + 1); - } else if (!strncmp(buf, "send", 4)) { + } else if (!STRNCMP(buf, "send")) { send_queue(); - } else if (!strncmp(buf, "online", 6)) { + } else if (!STRNCMP(buf, "online")) { main_window_toggle_work_offline(mainwin, FALSE, FALSE); - } else if (!strncmp(buf, "offline", 7)) { + } else if (!STRNCMP(buf, "offline")) { main_window_toggle_work_offline(mainwin, TRUE, FALSE); - } else if (!strncmp(buf, "debug", 5)) { + } else if (!STRNCMP(buf, "debug")) { debug_set_mode(debug_get_mode() ? FALSE : TRUE); - } else if (!strncmp(buf, "status-full", 11) || - !strncmp(buf, "status", 6)) { + } else if (!STRNCMP(buf, "status-full") || + !STRNCMP(buf, "status")) { gchar *status; GPtrArray *folders; folders = get_folder_item_list(sock); status = folder_get_status - (folders, !strncmp(buf, "status-full", 11)); - fd_write_all(sock, status, strlen(status)); - fd_write_all(sock, ".\n", 2); + (folders, !STRNCMP(buf, "status-full")); + FD_WRITE_ALL(status); + FD_WRITE_ALL(".\n"); g_free(status); if (folders) g_ptr_array_free(folders, TRUE); - } else if (!strncmp(buf, "statistics", 10)) { + } else if (!STRNCMP(buf, "statistics")) { gchar tmp[BUFSIZ]; g_snprintf(tmp, sizeof(tmp), _("Session statistics\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); if (prefs_common.date_format) { struct tm *lt; @@ -2648,46 +2727,46 @@ static void lock_socket_input_cb(gpointer data, } else g_snprintf(tmp, sizeof(tmp), _("Started: %s\n"), ctime(&session_stats.time_started)); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL("\n"); g_snprintf(tmp, sizeof(tmp), _("Incoming traffic\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Received messages: %d\n"), session_stats.received); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL("\n"); g_snprintf(tmp, sizeof(tmp), _("Outgoing traffic\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("New/redirected messages: %d\n"), session_stats.sent); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Replied messages: %d\n"), session_stats.replied); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Forwarded messages: %d\n"), session_stats.forwarded); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Total outgoing messages: %d\n"), (session_stats.sent + session_stats.replied + session_stats.forwarded)); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, ".\n", 2); - } else if (!strncmp(buf, "reset_statistics", 16)) { + FD_WRITE_ALL(".\n"); + } else if (!STRNCMP(buf, "reset_statistics")) { reset_statistics(); - } else if (!strncmp(buf, "select ", 7)) { + } else if (!STRNCMP(buf, "select ")) { const gchar *target = buf+7; mainwindow_jump_to(target, TRUE); - } else if (!strncmp(buf, "search ", 7)) { + } else if (!STRNCMP(buf, "search ")) { FolderItem* folderItem = NULL; GSList *messages = NULL; gchar *folder_name = NULL; @@ -2753,11 +2832,11 @@ static void lock_socket_input_cb(gpointer data, for (cur = messages; cur != NULL; cur = cur->next) { MsgInfo* msg = (MsgInfo *)cur->data; gchar *file = procmsg_get_message_file_path(msg); - fd_write_all(sock, file, strlen(file)); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL(file); + FD_WRITE_ALL("\n"); g_free(file); } - fd_write_all(sock, ".\n", 2); + FD_WRITE_ALL(".\n"); search_exit: g_free(folder_name); @@ -2765,7 +2844,7 @@ search_exit: advsearch_free(search); if (messages != NULL) procmsg_msg_list_free(messages); - } else if (!strncmp(buf, "exit", 4)) { + } else if (!STRNCMP(buf, "exit")) { if (prefs_common.clean_on_exit && !prefs_common.ask_on_clean) { procmsg_empty_all_trash(); } ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From wwp at claws-mail.org Wed Aug 19 11:07:48 2020 From: wwp at claws-mail.org (wwp at claws-mail.org) Date: Wed, 19 Aug 2020 11:07:48 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-986-ged21971b5 Message-ID: <20200819090748.40AD4401BB@claws-mail.org> The branch, gtk3 has been updated via ed21971b562361efd1d35081e7fd203c2edae3fc (commit) from cab0ae3c97ec4842a4e97d5def4f855b0eac8e23 (commit) Summary of changes: doc/man/claws-mail.1 | 156 ++++++++++-------- src/common/claws.c | 2 +- src/main.c | 435 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 350 insertions(+), 243 deletions(-) - Log ----------------------------------------------------------------- commit ed21971b562361efd1d35081e7fd203c2edae3fc Author: wwp Date: Wed Aug 19 10:57:11 2020 +0200 Fix parsing of command-line arguments: - matching substrings won't work anymore (--receive-al won't match --receive),, I'm not sure at all this was intentional, - fix and enhancement handling of mandatory and optional arguments to options (and fix their representation in --help), - fix sub-arguments not being properly eaten by parser, then being parsed twice, - -d is now an alias to --debug, - avoid hardcoding strings length (fd_write, fd_write_all, strncmp), this is prone to error, - more comprehensive error messages, - man page content updates and fixes, format fixes and enhancements. diff --git a/doc/man/claws-mail.1 b/doc/man/claws-mail.1 index 81b2bfab4..4c8b2c2d8 100644 --- a/doc/man/claws-mail.1 +++ b/doc/man/claws-mail.1 @@ -6,7 +6,7 @@ Claws Mail \- a GTK+ based fast email and news client .SH "SYNOPSIS" .B claws\-mail -.RI [ options ] +.RI [ options ]... .SH "DESCRIPTION" .TP @@ -99,9 +99,9 @@ This list is not complete. .br \fB \-\-subscribe\fR uri .br -\fB \-\-attach file1 [file2]...\fR +\fB \-\-attach\fR file1 [file2]...\fR .br -\fB \-\-insert file1 [file2]...\fR +\fB \-\-insert\fR file1 [file2]...\fR .br \fB \-\-receive\fR .br @@ -111,19 +111,23 @@ This list is not complete. .br \fB \-\-cancel\-sending\fR .br +\fB \-\-search\fR folder type request [recursive] +.br \fB \-\-send\fR .br \fB \-\-status\fR .br -\fB \-\-status folder[/subfolder]\fR +\fB \-\-status\fR folder[/subfolder] .br \fB \-\-status\-full\fR .br +\fB \-\-status\-full\fR folder[/subfolder] +.br \fB \-\-statistics\fR .br \fB \-\-reset-statistics\fR .br -\fB \-\-select [#mh/mailbox/]folder[/msg|/msgid]\fR +\fB \-\-select\fR [#mh/mailbox/]folder[/msg|/msgid], a file:// uri or an absolute path .br \fB \-\-online\fR .br @@ -143,121 +147,121 @@ This list is not complete. .br \fB \-\-config\-dir\fR .br -\fB \-\-alternate\-config\-dir directory\fR +\fB \-\-alternate\-config\-dir\fR directory .br -\fB \-\-geometry WxH+X+Y\fR +\fB \-\-geometry\fR [WxH][+X+Y] .SH "FILES" .LP .TP -$HOME/Mail +\fB$HOME/Mail\fR Default directory for mail storage. .TP -$PREFIX/share/claws\-mail +\fB$PREFIX/share/claws\-mail\fR Global program directory. .TP -$PREFIX/share/claws\-mail/manual +\fB$PREFIX/share/claws\-mail/manual\fR Manual files in HTML, PDF, PostScript and plain text format. .TP -$PREFIX/share/claws\-mail/themes +\fB$PREFIX/share/claws\-mail/themes\fR Global themes directory. .TP -$PREFIX/lib/claws\-mail/plugins +\fB$PREFIX/lib/claws\-mail/plugins\fR Directory for plugins. .TP -$PREFIX/include/claws\-mail +\fB$PREFIX/include/claws\-mail\fR Directory for header files. .TP -$HOME/.claws\-mail +\fB$HOME/.claws\-mail\fR Default directory for user's configuration files directory. .TP -$HOME/.claws\-mail/addrbook/* +\fB$HOME/.claws\-mail/addrbook/*\fR Addressbook files. .TP -$HOME/.claws\-mail/autofaces/* +\fB$HOME/.claws\-mail/autofaces/*\fR Automatic Faces and X\-Faces files for accounts. .TP -$HOME/.claws\-mail/certs/* +\fB$HOME/.claws\-mail/certs/*\fR SSL certificates received from mail servers. .TP -$HOME/.claws\-mail/tagsdb +\fB$HOME/.claws\-mail/tagsdb\fR Tags directory. .TP -$HOME/.claws\-mail/templates +\fB$HOME/.claws\-mail/templates\fR User\-defined templates directory. .TP -$HOME/.claws\-mail/themes +\fB$HOME/.claws\-mail/themes\fR User's themes directory. .TP -$HOME/.claws\-mail/accountrc +\fB$HOME/.claws\-mail/accountrc\fR Configuration for account(s). .TP -$HOME/.claws\-mail/actionsrc +\fB$HOME/.claws\-mail/actionsrc\fR User\-defined custom actions. .TP -$HOME/.claws\-mail/addrbook/attributesrc +\fB$HOME/.claws\-mail/addrbook/attributesrc\fR User\-defined address book custom attributes. .TP -$HOME/.claws\-mail/claws.log +\fB$HOME/.claws\-mail/claws.log\fR Claws Mail logfile. .TP -$HOME/.claws\-mail/clawsrc +\fB$HOME/.claws\-mail/clawsrc\fR Main configuration file. .TP -$HOME/.claws\-mail/command_history +\fB$HOME/.claws\-mail/command_history\fR User\-specified commands. .TP -$HOME/.claws\-mail/customheaderrc +\fB$HOME/.claws\-mail/customheaderrc\fR Configuration for custom headers for sending mail. .TP -$HOME/.claws\-mail/dispheaderrc +\fB$HOME/.claws\-mail/dispheaderrc\fR Configuration for custom display of headers in message view. .TP -$HOME/.claws\-mail/extraheaderrc +\fB$HOME/.claws\-mail/extraheaderrc\fR Editable extra headers to be added to compose window combobox. .TP -$HOME/.claws\-mail/folderitemrc +\fB$HOME/.claws\-mail/folderitemrc\fR All folders' attributes. .TP -$HOME/.claws\-mail/folderlist.xml +\fB$HOME/.claws\-mail/folderlist.xml\fR Folder hierarchy listing. .TP -$HOME/.claws\-mail/gtkrc-2.0 +\fB$HOME/.claws\-mail/gtkrc-2.0\fR Optional GTK+ settings to be load on startup. .TP -$HOME/.claws\-mail/matcherrc +\fB$HOME/.claws\-mail/matcherrc\fR Filtering and Processing function configuration. .TP -$HOME/.claws\-mail/menurc +\fB$HOME/.claws\-mail/menurc\fR Menu shortcut\-key configuration. .TP -$HOME/.claws\-mail/messagesearch_history +\fB$HOME/.claws\-mail/messagesearch_history\fR User\-specified searches in message bodies. .TP -$HOME/.claws\-mail/quicksearch_history +\fB$HOME/.claws\-mail/quicksearch_history\fR User\-specified quick\-search list. .TP -$HOME/.claws\-mail/messagesearch_history +\fB$HOME/.claws\-mail/messagesearch_history\fR User\-specified searches in message bodies. .TP -$HOME/.claws\-mail/summary*_history +\fB$HOME/.claws\-mail/summary*_history\fR User\-specified searches in message list. .TP -$HOME/.claws\-mail/passwordstorerc +\fB$HOME/.claws\-mail/passwordstorerc\fR User saved passwords. .TP -$HOME/.claws\-mail/tagsrc +\fB$HOME/.claws\-mail/tagsrc\fR User\-specified tag list. .TP -$HOME/.claws\-mail/toolbar*.xml +\fB$HOME/.claws\-mail/toolbar*.xml\fR User\-defined custom toolbars. .TP -%TEMP%\\claws\-win32.log -(Windows only) Claws Mail output file when \-\-debug is enabled. If +\fB%TEMP%\\claws\-win32.log \fI(Windows only)\fR +Claws Mail output file when \-\-debug is enabled. If %TEMP% is not set it defaults to windows directory (usually C:\\Windows) or C:\\ if windows directory is not available. .TP -(Windows only) %APPDATA%\\Claws\-mail\\claws.log +\fB %APPDATA%\\Claws\-mail\\claws.log \fI(Windows only)\fR Claws Mail log file. .SH "EXAMPLES" @@ -268,30 +272,30 @@ claws\-mail .LP Alternatively you can run it with the following options: .TP -\fB\-\-compose [address]\fR +\fB\-\-compose\fR [address] To open a Compose window. .TP -\fB\-\-compose\-from\-file file +\fB\-\-compose\fR "mailto:\fI%t\fR?subject=\fI%s\fR&cc=\fI%c\fR&body=\fI%b\fR" +This syntax can be used in web\-browsers and CLI to open a pre\-populated +Compose window. Possible fields after the destination recipient are: subject, +from, cc, bcc, in\-reply\-to, body, insert (insert a file in body part, needs +an absolute path), attach (attach a file, needs an absolute path, see also: +\-\-attach). +.TP +\fB\-\-compose\-from\-file\fR file Open composition window with data from the given file. Use \- as file name for reading from standard input. Content format: headers first (To: header required) until an empty line is found, then mail body until end of file. .TP -\fB\-\-subscribe [uri]\fR +\fB\-\-subscribe\fR uri Subscribe to the given URI if possible. .TP -\fB\-\-attach file1 [file2]...\fR +\fB\-\-attach\fR file1 [file2]... Open composition window with specified files attached. .TP -\fB\-\-insert file1 [file2]...\fR +\fB\-\-insert\fR file1 [file2]... Open composition window with specified files inserted. .TP -\fB\-\-compose\fR "mailto:\fI%t\fR?subject=\fI%s\fR&cc=\fI%c\fR&body=\fI%b\fR" -This syntax can be used in web\-browsers and CLI to open a pre\-populated -Compose window. Possible fields after the destination recipient are: subject, -from, cc, bcc, in\-reply\-to, body, insert (insert a file in body part, needs -an absolute path), attach (attach a file, needs an absolute path, see also: -\-\-attach). -.TP \fB\-\-receive\fR Receive new messages. .TP @@ -304,6 +308,18 @@ Cancel receiving of messages. \fB\-\-cancel\-sending\fR Cancel sending of messages. .TP +\fB\-\-search\fR folder type request [recursive] +.br +Searches mail: +.br +folder ex.: "#mh/Mailbox/inbox" or "Mail" +.br +type: s[ubject],f[rom],t[o],e[xtended],m[ixed] or g: tag +.br +request: search string +.br +recursive: false if arg. starts with 0, n, N, f or F +.TP \fB\-\-send\fR .br Send all queued messages. @@ -313,7 +329,7 @@ Show the total number of messages: .br [new][unread][unread answers to marked][total] .TP -\fB\-\-status folder[/subfolder]\fR +\fB\-\-status\fR folder[/subfolder] Show the total number of messages in the specified folder: .br [new][unread][unread answers to marked][total] @@ -323,6 +339,11 @@ Show the total number of messages per folder: .br [new][unread][unread answers to marked][total] .TP +\fB\-\-status\-full\fR folder[/subfolder] +Show the total number of messages int the specified folder: +.br +[new][unread][unread answers to marked][total] +.TP \fB\-\-statistics\fR .br Show session statistics. @@ -331,8 +352,15 @@ Show session statistics. .br Reset session statistics. .TP -\fB\-\-select [#mh/mailbox/]folder[/msg|/msgid]\fR -On startup, jumps to the specified folder/message. +\fB\-\-select\fR #mh/Mailbox/inbox/123 +.RS 0 +.br +\fB\-\-select\fR file://home/johndoe/Mail/inbox/123 +.br +\fB\-\-select\fR /home/johndoe/Mail/inbox/123 +.RS +On startup, jump to the specified folder/message. +.RE .TP \fB\-\-online\fR Start Claws Mail in (or switch to, if already running) online mode. @@ -340,9 +368,6 @@ Start Claws Mail in (or switch to, if already running) online mode. \fB\-\-offline\fR Start Claws Mail in (or switch to, if already running) offline mode. .TP -\fB\-\-help\fR -Display the help message and exit. -.TP \fB\-\-exit\fR Exit Claws Mail. .TP @@ -354,6 +379,9 @@ section). \fB\-\-toggle-debug\fR Toggle debug mode of the running Claws Mail instance. .TP +\fB\-\-help\fR +Display the help message and exit. +.TP \fB\-\-version\fR Display version number and exit. .TP @@ -363,10 +391,10 @@ Display version number and compiled\-in features then exit. \fB\-\-config\-dir\fR Display the CONFIG\-DIR and exit. .TP -\fB\-\-alternate\-config\-dir [dir]\fR +\fB\-\-alternate\-config\-dir\fR dir Start Claws Mail with the configuration stored in the [dir] directory. .TP -\fB\-\-geometry WxH+X+Y\fR +\fB\-\-geometry\fR [WxH][+X+Y] Set initial X geometry of main window. .SH "ENVIRONMENT" diff --git a/src/common/claws.c b/src/common/claws.c index fa5eb6f1c..c46823bc5 100644 --- a/src/common/claws.c +++ b/src/common/claws.c @@ -63,7 +63,7 @@ static void parse_parameter(int *argc, char ***argv) cm_return_if_fail(argv != NULL); for (i = 1; i < *argc;) { - if (strcmp("--debug", (*argv)[i]) == 0) { + if ((strcmp("--debug", (*argv)[i]) == 0) || (strcmp("-d", (*argv)[i]) == 0)) { debug_set_mode(TRUE); (*argv)[i] = NULL; diff --git a/src/main.c b/src/main.c index 6dfabdfc3..a4cea0161 100644 --- a/src/main.c +++ b/src/main.c @@ -257,6 +257,11 @@ static void networkmanager_state_change_cb(DBusGProxy *proxy, gchar *dev, } \ } +#define STRNCMP(S1, S2) (strncmp((S1), (S2), sizeof((S2)) - 1)) + +#define FD_WRITE(S) fd_write(sock, (S), strlen((S))) +#define FD_WRITE_ALL(S) fd_write(sock, (S), strlen((S))) + static MainWindow *static_mainwindow; static gboolean emergency_exit = FALSE; @@ -471,7 +476,7 @@ static int migrate_common_rc(const gchar *old_rc, const gchar *new_rc) } debug_print("replacing %s with %s\n", old_plugin_path, new_plugin_path); while (claws_fgets(buf, sizeof(buf), oldfp)) { - if (strncmp(buf, old_plugin_path, strlen(old_plugin_path))) { + if (STRNCMP(buf, old_plugin_path)) { err |= (claws_fputs(buf, newfp) == EOF); } else { debug_print("->replacing %s\n", buf); @@ -1844,85 +1849,118 @@ static GString * parse_cmd_compose_from_file(const gchar *fn) #undef G_PRINT_EXIT +static void parse_cmd_opt_error(char *errstr, char* optstr) +{ + gchar tmp[BUFSIZ]; + + cm_return_if_fail(errstr != NULL); + cm_return_if_fail(optstr != NULL); + + g_snprintf(tmp, sizeof(tmp), errstr, optstr); + g_print(_("%s. Try -h or --help for usage.\n"), tmp); + exit(1); +} + static void parse_cmd_opt(int argc, char *argv[]) { AttachInfo *ainfo; gint i; for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], "--receive-all", 13)) { + if (!strcmp(argv[i], "--receive-all")) { cmd.receive_all = TRUE; - } else if (!strncmp(argv[i], "--receive", 9)) { + } else if (!strcmp(argv[i], "--receive")) { cmd.receive = TRUE; - } else if (!strncmp(argv[i], "--cancel-receiving", 18)) { + } else if (!strcmp(argv[i], "--cancel-receiving")) { cmd.cancel_receiving = TRUE; - } else if (!strncmp(argv[i], "--cancel-sending", 16)) { + } else if (!strcmp(argv[i], "--cancel-sending")) { cmd.cancel_sending = TRUE; - } else if (!strncmp(argv[i], "--compose-from-file", 19)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; + } else if (!strcmp(argv[i], "--compose-from-file")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; - GString *mailto = parse_cmd_compose_from_file(p); - cmd.compose = TRUE; - cmd.compose_mailto = mailto->str; - i++; - } else if (!strncmp(argv[i], "--compose", 9)) { + GString *mailto = parse_cmd_compose_from_file(p); + cmd.compose = TRUE; + cmd.compose_mailto = mailto->str; + i++; + } else { + parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--compose")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.compose = TRUE; cmd.compose_mailto = NULL; if (p && *p != '\0' && *p != '-') { - if (!strncmp(p, "mailto:", 7)) { + if (!STRNCMP(p, "mailto:")) { cmd.compose_mailto = p + 7; } else { cmd.compose_mailto = p; } i++; } - } else if (!strncmp(argv[i], "--subscribe", 11)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; - if (p && *p != '\0' && *p != '-') { - cmd.subscribe = TRUE; - cmd.subscribe_uri = p; + } else if (!strcmp(argv[i], "--subscribe")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; + if (p && *p != '\0' && *p != '-') { + cmd.subscribe = TRUE; + cmd.subscribe_uri = p; + } else { + parse_cmd_opt_error(_("Missing or empty uri argument for option %s"), argv[i]); + } + } else { + parse_cmd_opt_error(_("Missing uri argument for option %s"), argv[i]); } - } else if (!strncmp(argv[i], "--attach", 8) || !strncmp(argv[i], "--insert", 8)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; - gchar *file = NULL; - gboolean insert = !strncmp(argv[i], "--insert", 8); - - while (p && *p != '\0' && *p != '-') { - if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) { - if (!is_file_exist(file)) { - g_free(file); - file = NULL; + } else if (!strcmp(argv[i], "--attach") || + !strcmp(argv[i], "--insert")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; + gint ii = i; + gchar *file = NULL; + gboolean insert = !strcmp(argv[i], "--insert"); + + while (p && *p != '\0' && *p != '-') { + if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) { + if (!is_file_exist(file)) { + g_free(file); + file = NULL; + } + } + if (file == NULL && *p != G_DIR_SEPARATOR) { + file = g_strconcat(claws_get_startup_dir(), + G_DIR_SEPARATOR_S, + p, NULL); + } else if (file == NULL) { + file = g_strdup(p); } - } - if (file == NULL && *p != G_DIR_SEPARATOR) { - file = g_strconcat(claws_get_startup_dir(), - G_DIR_SEPARATOR_S, - p, NULL); - } else if (file == NULL) { - file = g_strdup(p); - } - ainfo = g_new0(AttachInfo, 1); - ainfo->file = file; - ainfo->insert = insert; - cmd.attach_files = g_list_append(cmd.attach_files, ainfo); - i++; - p = (i+1 < argc)?argv[i+1]:NULL; + ainfo = g_new0(AttachInfo, 1); + ainfo->file = file; + ainfo->insert = insert; + cmd.attach_files = g_list_append(cmd.attach_files, ainfo); + ii++; + p = (ii+1 < argc)?argv[ii+1]:NULL; + } + if (ii==i) { + parse_cmd_opt_error(_("Missing at least one non-empty file argument for option %s"), argv[i]); + } else { + i=ii; + } + } else { + parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]); } - } else if (!strncmp(argv[i], "--send", 6)) { + } else if (!strcmp(argv[i], "--send")) { cmd.send = TRUE; - } else if (!strncmp(argv[i], "--version-full", 14) || - !strncmp(argv[i], "-V", 2)) { + } else if (!strcmp(argv[i], "--version-full") || + !strcmp(argv[i], "-V")) { g_print("Claws Mail version " VERSION_GIT_FULL "\n"); main_dump_features_list(FALSE); exit(0); - } else if (!strncmp(argv[i], "--version", 9) || - !strncmp(argv[i], "-v", 2)) { + } else if (!strcmp(argv[i], "--version") || + !strcmp(argv[i], "-v")) { g_print("Claws Mail version " VERSION "\n"); exit(0); - } else if (!strncmp(argv[i], "--status-full", 13)) { + } else if (!strcmp(argv[i], "--status-full")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.status_full = TRUE; @@ -1936,7 +1974,7 @@ static void parse_cmd_opt(int argc, char *argv[]) i++; p = (i+1 < argc)?argv[i+1]:NULL; } - } else if (!strncmp(argv[i], "--status", 8)) { + } else if (!strcmp(argv[i], "--status")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.status = TRUE; @@ -1948,28 +1986,52 @@ static void parse_cmd_opt(int argc, char *argv[]) i++; p = (i+1 < argc)?argv[i+1]:NULL; } - } else if (!strncmp(argv[i], "--search", 8)) { - cmd.search_folder = (i+1 < argc)?argv[i+1]:NULL; - cmd.search_type = (i+2 < argc)?argv[i+2]:NULL; - cmd.search_request = (i+3 < argc)?argv[i+3]:NULL; - const char* rec = (i+4 < argc)?argv[i+4]:NULL; - cmd.search_recursive = TRUE; - if (rec && (tolower(*rec)=='n' || tolower(*rec)=='f' || *rec=='0')) - cmd.search_recursive = FALSE; - if (cmd.search_folder && cmd.search_type && cmd.search_request) - cmd.search = TRUE; - } else if (!strncmp(argv[i], "--online", 8)) { + } else if (!strcmp(argv[i], "--search")) { + if (i+3 < argc) { /* 3 first arguments are mandatory */ + const char* p; + /* only set search parameters if they are valid */ + p = argv[i+1]; + cmd.search_folder = (p && *p != '\0' && *p != '-')?p:NULL; + p = argv[i+2]; + cmd.search_type = (p && *p != '\0' && *p != '-')?p:NULL; + p = argv[i+3]; + cmd.search_request = (p && *p != '\0' && *p != '-')?p:NULL; + p = (i+4 < argc)?argv[i+4]:NULL; + const char* rec = (p && *p != '\0' && *p != '-')?p:NULL; + cmd.search_recursive = TRUE; + if (rec) { + i++; + if (tolower(*rec)=='n' || tolower(*rec)=='f' || *rec=='0') + cmd.search_recursive = FALSE; + } + if (cmd.search_folder && cmd.search_type && cmd.search_request) { + cmd.search = TRUE; + i+=3; + } + } else { + switch (argc-i-1) { + case 0: + parse_cmd_opt_error(_("Missing folder, type and request arguments for option %s"), argv[i]); + break; + case 1: + parse_cmd_opt_error(_("Missing type and request arguments for option %s"), argv[i]); + break; + case 2: + parse_cmd_opt_error(_("Missing request argument for option %s"), argv[i]); + } + } + } else if (!strcmp(argv[i], "--online")) { cmd.online_mode = ONLINE_MODE_ONLINE; - } else if (!strncmp(argv[i], "--offline", 9)) { + } else if (!strcmp(argv[i], "--offline")) { cmd.online_mode = ONLINE_MODE_OFFLINE; - } else if (!strncmp(argv[i], "--toggle-debug", 14)) { + } else if (!strcmp(argv[i], "--toggle-debug")) { cmd.debug = TRUE; - } else if (!strncmp(argv[i], "--statistics", 12)) { + } else if (!strcmp(argv[i], "--statistics")) { cmd.statistics = TRUE; - } else if (!strncmp(argv[i], "--reset-statistics", 18)) { + } else if (!strcmp(argv[i], "--reset-statistics")) { cmd.reset_statistics = TRUE; - } else if (!strncmp(argv[i], "--help", 6) || - !strncmp(argv[i], "-h", 2)) { + } else if (!strcmp(argv[i], "--help") || + !strcmp(argv[i], "-h")) { gchar *base = g_path_get_basename(argv[0]); g_print(_("Usage: %s [OPTION]...\n"), base); @@ -2003,12 +2065,12 @@ static void parse_cmd_opt(int argc, char *argv[]) " show the status of each folder")); g_print("%s\n", _(" --statistics show session statistics")); g_print("%s\n", _(" --reset-statistics reset session statistics")); - g_print("%s\n", _(" --select folder[/msg] jumps to the specified folder/message\n" - " folder is a folder id like 'folder/sub_folder'")); + g_print("%s\n", _(" --select folder[/msg] jump to the specified folder/message\n" + " folder is a folder id like 'folder/sub_folder', a file:// uri or an absolute path")); g_print("%s\n", _(" --online switch to online mode")); g_print("%s\n", _(" --offline switch to offline mode")); g_print("%s\n", _(" --exit --quit -q exit Claws Mail")); - g_print("%s\n", _(" --debug debug mode")); + g_print("%s\n", _(" --debug -d debug mode")); g_print("%s\n", _(" --toggle-debug toggle debug mode")); g_print("%s\n", _(" --help -h display this help and exit")); g_print("%s\n", _(" --version -v output version information and exit")); @@ -2016,46 +2078,62 @@ static void parse_cmd_opt(int argc, char *argv[]) g_print("%s\n", _(" --config-dir output configuration directory")); g_print("%s\n", _(" --alternate-config-dir directory\n" " use specified configuration directory")); - g_print("%s\n", _(" --geometry -geometry WxH+X+Y\n" + g_print("%s\n", _(" --geometry -geometry [WxH][+X+Y]\n" " set geometry for main window")); g_free(base); exit(1); - } else if (!strncmp(argv[i], "--crash", 7)) { + } else if (!strcmp(argv[i], "--crash")) { cmd.crash = TRUE; cmd.crash_params = g_strdup((i+1 < argc)?argv[i+1]:NULL); i++; - } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) { + } else if (!strcmp(argv[i], "--config-dir")) { g_print(RC_DIR "\n"); exit(0); - } else if (!strncmp(argv[i], "--alternate-config-dir", sizeof "--alternate-config-dir" - 1) && i+1 < argc) { - set_rc_dir(argv[i+1]); - } else if (!strncmp(argv[i], "--geometry", sizeof "--geometry" - 1) - || !strncmp(argv[i], "-geometry", sizeof "-geometry" - 1)) { - cmd.geometry = (i+1 < argc)? argv[i+1]: NULL; - } else if (!strncmp(argv[i], "--exit", 6) || - !strncmp(argv[i], "--quit", 6) || - !strncmp(argv[i], "-q", 2)) { + } else if (!strcmp(argv[i], "--alternate-config-dir")) { + if (i+1 < argc) { + set_rc_dir(argv[i+1]); + i++; + } else { + parse_cmd_opt_error(_("Missing directory argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--geometry") || + !strcmp(argv[i], "-geometry")) { + if (i+1 < argc) { + cmd.geometry = argv[i+1]; + i++; + } else { + parse_cmd_opt_error(_("Missing geometry argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--exit") || + !strcmp(argv[i], "--quit") || + !strcmp(argv[i], "-q")) { cmd.exit = TRUE; - } else if (!strncmp(argv[i], "--select", 8) && i+1 < argc) { - cmd.target = argv[i+1]; + } else if (!strcmp(argv[i], "--select")) { + if (i+1 < argc) { + cmd.target = argv[i+1]; + i++; + } else { + parse_cmd_opt_error(_("Missing folder argument for option %s"), argv[i]); + } } else if (i == 1 && argc == 2) { /* only one parameter. Do something intelligent about it */ - if ((strstr(argv[i], "@")||!strncmp(argv[i], "mailto:", 7)) && !strstr(argv[i], "://")) { + if ((strstr(argv[i], "@") || !STRNCMP(argv[i], "mailto:")) && !strstr(argv[i], "://")) { const gchar *p = argv[i]; cmd.compose = TRUE; cmd.compose_mailto = NULL; if (p && *p != '\0' && *p != '-') { - if (!strncmp(p, "mailto:", 7)) { + if (!STRNCMP(p, "mailto:")) { cmd.compose_mailto = p + 7; } else { cmd.compose_mailto = p; } } - } else if (!strncmp(argv[i], "file://", 7)) { + } else if (!STRNCMP(argv[i], "file://")) { cmd.target = argv[i]; - } else if (!strncmp(argv[i], "?attach=file://", strlen("?attach=file://"))) { + } else if (!STRNCMP(argv[i], "?attach=file://")) { + /* Thunar support as per 3.3.0cvs19 */ cmd.compose = TRUE; cmd.compose_mailto = argv[i]; } else if (strstr(argv[i], "://")) { @@ -2068,11 +2146,12 @@ static void parse_cmd_opt(int argc, char *argv[]) /* gtk debug */ } else if (is_dir_exist(argv[i]) || is_file_exist(argv[i])) { cmd.target = argv[i]; - } else { - g_print(_("Unknown option. Try -h or --help for usage.\n")); - exit(1); - } - } + } else { + parse_cmd_opt_error(_("Unknown option %s"), argv[i]); + } + } else { + parse_cmd_opt_error(_("Unknown option %s"), argv[i]); + } } if (cmd.attach_files && cmd.compose == FALSE) { @@ -2268,19 +2347,19 @@ static gchar *get_crashfile_name(void) static gint prohibit_duplicate_launch(void) { - gint uxsock; + gint sock; GList *curr; #ifdef G_OS_UNIX gchar *path; path = claws_get_socket_name(); /* Try to connect to the control socket */ - uxsock = fd_connect_unix(path); + sock = fd_connect_unix(path); if (x_display == NULL) x_display = g_strdup(g_getenv("DISPLAY")); - if (uxsock < 0) { + if (sock < 0) { gint ret; #if HAVE_FLOCK gchar *socket_lock; @@ -2330,14 +2409,14 @@ static gint prohibit_duplicate_launch(void) return -1; } if (GetLastError() != ERROR_ALREADY_EXISTS) { - uxsock = fd_open_inet(50216); - if (uxsock < 0) + sock = fd_open_inet(50216); + if (sock < 0) return 0; - return uxsock; + return sock; } - uxsock = fd_connect_inet(50216); - if (uxsock < 0) + sock = fd_connect_inet(50216); + if (sock < 0) return -1; #endif /* remote command mode */ @@ -2345,13 +2424,13 @@ static gint prohibit_duplicate_launch(void) debug_print("another Claws Mail instance is already running.\n"); if (cmd.receive_all) { - fd_write_all(uxsock, "receive_all\n", 12); + FD_WRITE_ALL("receive_all\n"); } else if (cmd.receive) { - fd_write_all(uxsock, "receive\n", 8); + FD_WRITE_ALL("receive\n"); } else if (cmd.cancel_receiving) { - fd_write_all(uxsock, "cancel_receiving\n", 17); + FD_WRITE_ALL("cancel_receiving\n"); } else if (cmd.cancel_sending) { - fd_write_all(uxsock, "cancel_sending\n", 15); + FD_WRITE_ALL("cancel_sending\n"); } else if (cmd.compose && cmd.attach_files) { gchar *str, *compose_str; @@ -2362,20 +2441,20 @@ static gint prohibit_duplicate_launch(void) compose_str = g_strdup("compose_attach\n"); } - fd_write_all(uxsock, compose_str, strlen(compose_str)); + FD_WRITE_ALL(compose_str); g_free(compose_str); for (curr = cmd.attach_files; curr != NULL ; curr = curr->next) { str = (gchar *) ((AttachInfo *)curr->data)->file; if (((AttachInfo *)curr->data)->insert) - fd_write_all(uxsock, "insert ", strlen("insert ")); + FD_WRITE_ALL("insert "); else - fd_write_all(uxsock, "attach ", strlen("attach ")); - fd_write_all(uxsock, str, strlen(str)); - fd_write_all(uxsock, "\n", 1); + FD_WRITE_ALL("attach "); + FD_WRITE_ALL(str); + FD_WRITE_ALL("\n"); } - fd_write_all(uxsock, ".\n", 2); + FD_WRITE_ALL(".\n"); } else if (cmd.compose) { gchar *compose_str; @@ -2386,20 +2465,20 @@ static gint prohibit_duplicate_launch(void) compose_str = g_strdup("compose\n"); } - fd_write_all(uxsock, compose_str, strlen(compose_str)); + FD_WRITE_ALL(compose_str); g_free(compose_str); } else if (cmd.subscribe) { gchar *str = g_strdup_printf("subscribe %s\n", cmd.subscribe_uri); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); } else if (cmd.send) { - fd_write_all(uxsock, "send\n", 5); + FD_WRITE_ALL("send\n"); } else if (cmd.online_mode == ONLINE_MODE_ONLINE) { - fd_write(uxsock, "online\n", 7); + FD_WRITE("online\n"); } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) { - fd_write(uxsock, "offline\n", 8); + FD_WRITE("offline\n"); } else if (cmd.debug) { - fd_write(uxsock, "debug\n", 6); + FD_WRITE("debug\n"); } else if (cmd.status || cmd.status_full) { gchar buf[BUFFSIZE]; gint i; @@ -2411,41 +2490,41 @@ static gint prohibit_duplicate_launch(void) folders = cmd.status_full ? cmd.status_full_folders : cmd.status_folders; - fd_write_all(uxsock, command, strlen(command)); + FD_WRITE_ALL(command); for (i = 0; folders && i < folders->len; ++i) { folder = g_ptr_array_index(folders, i); - fd_write_all(uxsock, folder, strlen(folder)); - fd_write_all(uxsock, "\n", 1); + FD_WRITE_ALL(folder); + FD_WRITE_ALL("\n"); } - fd_write_all(uxsock, ".\n", 2); + FD_WRITE_ALL(".\n"); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; 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_WRITE_ALL("exit\n"); } else if (cmd.statistics) { gchar buf[BUFSIZ]; - fd_write(uxsock, "statistics\n", 11); + FD_WRITE("statistics\n"); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; 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_WRITE("reset_statistics\n"); } else if (cmd.target) { gchar *str = g_strdup_printf("select %s\n", cmd.target); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); } else if (cmd.search) { gchar buf[BUFFSIZE]; @@ -2453,12 +2532,12 @@ static gint prohibit_duplicate_launch(void) g_strdup_printf("search %s\n%s\n%s\n%c\n", cmd.search_folder, cmd.search_type, cmd.search_request, (cmd.search_recursive==TRUE)?'1':'0'); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; if (claws_fputs(buf, stdout) == EOF) { g_warning("writing to stdout failed."); break; @@ -2467,24 +2546,24 @@ static gint prohibit_duplicate_launch(void) } else { #ifdef G_OS_UNIX gchar buf[BUFSIZ]; - fd_write_all(uxsock, "get_display\n", 12); + FD_WRITE_ALL("get_display\n"); memset(buf, 0, sizeof(buf)); - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; if (g_strcmp0(buf, x_display)) { g_print("Claws Mail is already running on display %s.\n", buf); } else { - fd_close(uxsock); - uxsock = fd_connect_unix(path); - fd_write_all(uxsock, "popup\n", 6); + fd_close(sock); + sock = fd_connect_unix(path); + FD_WRITE_ALL("popup\n"); } #else - fd_write_all(uxsock, "popup\n", 6); + FD_WRITE_ALL("popup\n"); #endif } - fd_close(uxsock); + fd_close(sock); return -1; } @@ -2522,7 +2601,7 @@ static GPtrArray *get_folder_item_list(gint sock) for (;;) { fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) { + if (!STRNCMP(buf, ".\n")) { break; } strretchomp(buf); @@ -2555,23 +2634,23 @@ static void lock_socket_input_cb(gpointer data, fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, "popup", 5)) { + if (!STRNCMP(buf, "popup")) { main_window_popup(mainwin); #ifdef G_OS_UNIX - } else if (!strncmp(buf, "get_display", 11)) { - fd_write_all(sock, x_display, strlen(x_display)); + } else if (!STRNCMP(buf, "get_display")) { + FD_WRITE_ALL(x_display); #endif - } else if (!strncmp(buf, "receive_all", 11)) { + } else if (!STRNCMP(buf, "receive_all")) { inc_all_account_mail(mainwin, FALSE, FALSE, prefs_common.newmail_notify_manu); - } else if (!strncmp(buf, "receive", 7)) { + } else if (!STRNCMP(buf, "receive")) { inc_mail(mainwin, prefs_common.newmail_notify_manu); - } else if (!strncmp(buf, "cancel_receiving", 16)) { + } else if (!STRNCMP(buf, "cancel_receiving")) { inc_cancel_all(); imap_cancel_all(); - } else if (!strncmp(buf, "cancel_sending", 14)) { + } else if (!STRNCMP(buf, "cancel_sending")) { send_cancel(); - } else if (!strncmp(buf, "compose_attach", 14)) { + } else if (!STRNCMP(buf, "compose_attach")) { GList *files = NULL, *curr; AttachInfo *ainfo; gchar *mailto; @@ -2585,7 +2664,7 @@ static void lock_socket_input_cb(gpointer data, ainfo = g_new0(AttachInfo, 1); ainfo->file = g_strdup(strstr(buf, " ") + 1); - ainfo->insert = !strncmp(buf, "insert ", 7); + ainfo->insert = !STRNCMP(buf, "insert "); files = g_list_append(files, ainfo); } open_compose_new(mailto, files); @@ -2599,36 +2678,36 @@ static void lock_socket_input_cb(gpointer data, } g_list_free(files); g_free(mailto); - } else if (!strncmp(buf, "compose", 7)) { + } else if (!STRNCMP(buf, "compose")) { open_compose_new(buf + strlen("compose") + 1, NULL); - } else if (!strncmp(buf, "subscribe", 9)) { + } else if (!STRNCMP(buf, "subscribe")) { main_window_popup(mainwin); folder_subscribe(buf + strlen("subscribe") + 1); - } else if (!strncmp(buf, "send", 4)) { + } else if (!STRNCMP(buf, "send")) { send_queue(); - } else if (!strncmp(buf, "online", 6)) { + } else if (!STRNCMP(buf, "online")) { main_window_toggle_work_offline(mainwin, FALSE, FALSE); - } else if (!strncmp(buf, "offline", 7)) { + } else if (!STRNCMP(buf, "offline")) { main_window_toggle_work_offline(mainwin, TRUE, FALSE); - } else if (!strncmp(buf, "debug", 5)) { + } else if (!STRNCMP(buf, "debug")) { debug_set_mode(debug_get_mode() ? FALSE : TRUE); - } else if (!strncmp(buf, "status-full", 11) || - !strncmp(buf, "status", 6)) { + } else if (!STRNCMP(buf, "status-full") || + !STRNCMP(buf, "status")) { gchar *status; GPtrArray *folders; folders = get_folder_item_list(sock); status = folder_get_status - (folders, !strncmp(buf, "status-full", 11)); - fd_write_all(sock, status, strlen(status)); - fd_write_all(sock, ".\n", 2); + (folders, !STRNCMP(buf, "status-full")); + FD_WRITE_ALL(status); + FD_WRITE_ALL(".\n"); g_free(status); if (folders) g_ptr_array_free(folders, TRUE); - } else if (!strncmp(buf, "statistics", 10)) { + } else if (!STRNCMP(buf, "statistics")) { gchar tmp[BUFSIZ]; g_snprintf(tmp, sizeof(tmp), _("Session statistics\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); if (prefs_common.date_format) { struct tm *lt; @@ -2642,46 +2721,46 @@ static void lock_socket_input_cb(gpointer data, } else g_snprintf(tmp, sizeof(tmp), _("Started: %s\n"), ctime(&session_stats.time_started)); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL("\n"); g_snprintf(tmp, sizeof(tmp), _("Incoming traffic\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Received messages: %d\n"), session_stats.received); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL("\n"); g_snprintf(tmp, sizeof(tmp), _("Outgoing traffic\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("New/redirected messages: %d\n"), session_stats.sent); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Replied messages: %d\n"), session_stats.replied); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Forwarded messages: %d\n"), session_stats.forwarded); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Total outgoing messages: %d\n"), (session_stats.sent + session_stats.replied + session_stats.forwarded)); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, ".\n", 2); - } else if (!strncmp(buf, "reset_statistics", 16)) { + FD_WRITE_ALL(".\n"); + } else if (!STRNCMP(buf, "reset_statistics")) { reset_statistics(); - } else if (!strncmp(buf, "select ", 7)) { + } else if (!STRNCMP(buf, "select ")) { const gchar *target = buf+7; mainwindow_jump_to(target, TRUE); - } else if (!strncmp(buf, "search ", 7)) { + } else if (!STRNCMP(buf, "search ")) { FolderItem* folderItem = NULL; GSList *messages = NULL; gchar *folder_name = NULL; @@ -2747,11 +2826,11 @@ static void lock_socket_input_cb(gpointer data, for (cur = messages; cur != NULL; cur = cur->next) { MsgInfo* msg = (MsgInfo *)cur->data; gchar *file = procmsg_get_message_file_path(msg); - fd_write_all(sock, file, strlen(file)); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL(file); + FD_WRITE_ALL("\n"); g_free(file); } - fd_write_all(sock, ".\n", 2); + FD_WRITE_ALL(".\n"); search_exit: g_free(folder_name); @@ -2759,7 +2838,7 @@ search_exit: advsearch_free(search); if (messages != NULL) procmsg_msg_list_free(messages); - } else if (!strncmp(buf, "exit", 4)) { + } else if (!STRNCMP(buf, "exit")) { if (prefs_common.clean_on_exit && !prefs_common.ask_on_clean) { procmsg_empty_all_trash(); } ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Wed Aug 19 14:56:03 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Wed, 19 Aug 2020 14:56:03 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-7-g460365d08 Message-ID: <20200819125603.3C7D740281@claws-mail.org> The branch, master has been updated via 460365d085aa234c13db292afb62f7267ef5265f (commit) from a1c0649aa197dc53df4e15f9342f7faeb2efd496 (commit) Summary of changes: src/addressbook.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) - Log ----------------------------------------------------------------- commit 460365d085aa234c13db292afb62f7267ef5265f Author: Paul Date: Wed Aug 19 13:55:57 2020 +0100 remove inappropriate and unnecessary Help button from menu diff --git a/src/addressbook.c b/src/addressbook.c index eeba15707..523fc6445 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -1,6 +1,6 @@ /* - * 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-2020 the Claws Mail team and Hiroyuki Yamamoto * * 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 @@ -405,7 +405,6 @@ static GtkActionEntry addressbook_entries[] = {"Book", NULL, N_("_Book"), NULL, NULL, NULL }, {"Edit", NULL, N_("_Edit"), NULL, NULL, NULL }, {"Tools", NULL, N_("_Tools"), NULL, NULL, NULL }, - {"Help", NULL, N_("_Help"), NULL, NULL, NULL }, /* Book menu */ {"Book/NewBook", NULL, N_("New _Book"), "B", NULL, G_CALLBACK(addressbook_new_book_cb) }, @@ -454,10 +453,6 @@ static GtkActionEntry addressbook_entries[] = /* {"Tools/---", NULL, "---", NULL, NULL, NULL },*/ {"Tools/FindDuplicates", NULL, N_("Find duplicates..."), NULL, NULL, G_CALLBACK(addressbook_find_duplicates_cb) }, {"Tools/EditAttrs", NULL, N_("Edit custom attributes..."), NULL, NULL, G_CALLBACK(addressbook_edit_custom_attr_cb) }, - -/* Help menu */ - {"Help/About", NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_show_cb) }, - }; static GtkActionEntry addressbook_tree_popup_entries[] = @@ -947,7 +942,6 @@ static void addressbook_create(void) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Book", "Book", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Tools", "Tools", GTK_UI_MANAGER_MENU) - MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Help", "Help", GTK_UI_MANAGER_MENU) /* Book menu */ MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "NewBook", "Book/NewBook", GTK_UI_MANAGER_MENUITEM) @@ -993,9 +987,6 @@ static void addressbook_create(void) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Tools", "FindDuplicates", "Tools/FindDuplicates", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Tools", "EditAttrs", "Tools/EditAttrs", GTK_UI_MANAGER_MENUITEM) -/* Help menu */ - MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM) - gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager)); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Wed Aug 19 15:00:16 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Wed, 19 Aug 2020 15:00:16 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-990-g55ae9699a Message-ID: <20200819130016.8B4484029A@claws-mail.org> The branch, gtk3 has been updated via 55ae9699a6bbe2508edddb49c92353ac9fba83d1 (commit) via bdab46298af5bbbc53bb7d726987bba1f7ab762d (commit) via da9daafab6be0ca44c1b25656a752fca6d459d6c (commit) via 4727ce71f6d50dfbb1624953d666f37027867b9a (commit) from ed21971b562361efd1d35081e7fd203c2edae3fc (commit) Summary of changes: src/addressbook.c | 16 +++------------- src/editaddress.c | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) - Log ----------------------------------------------------------------- commit 55ae9699a6bbe2508edddb49c92353ac9fba83d1 Author: paul Date: Wed Aug 19 14:00:10 2020 +0100 allow user to both shrink and expand addrbook window and edit window diff --git a/src/addressbook.c b/src/addressbook.c index 6d74246bc..a86b70d2a 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -1002,7 +1002,6 @@ static void addressbook_create(void) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ctree_swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_widget_set_size_request(ctree_swin, COL_FOLDER_WIDTH + 20, -1); /* Address index */ ctree = gtk_sctree_new_with_titles(N_INDEX_COLS, 0, index_titles); @@ -1317,7 +1316,7 @@ static void addressbook_create(void) gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry, GDK_HINT_MIN_SIZE); - gtk_widget_set_size_request(window, prefs_common.addressbookwin_width, + gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.addressbookwin_width, prefs_common.addressbookwin_height); #ifdef G_OS_WIN32 gtk_window_move(GTK_WINDOW(window), 48, 48); diff --git a/src/editaddress.c b/src/editaddress.c index eeb8f225c..237dae91d 100644 --- a/src/editaddress.c +++ b/src/editaddress.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2019 Hiroyuki Yamamoto and the Claws Mail team + * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto * * 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 @@ -877,7 +877,7 @@ static void addressbook_edit_person_dialog_create( gboolean *cancelled ) { gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry, GDK_HINT_MIN_SIZE); - gtk_widget_set_size_request(window, prefs_common.addressbookeditpersonwin_width, + gtk_window_set_default_size(window, prefs_common.addressbookeditpersonwin_width, prefs_common.addressbookeditpersonwin_height); personeditdlg.container = window; commit bdab46298af5bbbc53bb7d726987bba1f7ab762d Author: Paul Date: Wed Aug 19 13:55:57 2020 +0100 remove inappropriate and unnecessary Help button from menu diff --git a/src/addressbook.c b/src/addressbook.c index ed547def6..6d74246bc 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -1,6 +1,6 @@ /* - * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto + * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto * * 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 @@ -405,7 +405,6 @@ static GtkActionEntry addressbook_entries[] = {"Book", NULL, N_("_Book"), NULL, NULL, NULL }, {"Edit", NULL, N_("_Edit"), NULL, NULL, NULL }, {"Tools", NULL, N_("_Tools"), NULL, NULL, NULL }, - {"Help", NULL, N_("_Help"), NULL, NULL, NULL }, /* Book menu */ {"Book/NewBook", NULL, N_("New _Book"), "B", NULL, G_CALLBACK(addressbook_new_book_cb) }, @@ -454,10 +453,6 @@ static GtkActionEntry addressbook_entries[] = /* {"Tools/---", NULL, "---", NULL, NULL, NULL },*/ {"Tools/FindDuplicates", NULL, N_("Find duplicates..."), NULL, NULL, G_CALLBACK(addressbook_find_duplicates_cb) }, {"Tools/EditAttrs", NULL, N_("Edit custom attributes..."), NULL, NULL, G_CALLBACK(addressbook_edit_custom_attr_cb) }, - -/* Help menu */ - {"Help/About", NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_show_cb) }, - }; static GtkActionEntry addressbook_tree_popup_entries[] = @@ -947,7 +942,6 @@ static void addressbook_create(void) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Book", "Book", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Tools", "Tools", GTK_UI_MANAGER_MENU) - MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu", "Help", "Help", GTK_UI_MANAGER_MENU) /* Book menu */ MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "NewBook", "Book/NewBook", GTK_UI_MANAGER_MENUITEM) @@ -993,9 +987,6 @@ static void addressbook_create(void) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Tools", "FindDuplicates", "Tools/FindDuplicates", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Tools", "EditAttrs", "Tools/EditAttrs", GTK_UI_MANAGER_MENUITEM) -/* Help menu */ - MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM) - gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager)); commit da9daafab6be0ca44c1b25656a752fca6d459d6c Merge: 4727ce71f ed21971b5 Author: paul Date: Wed Aug 19 10:08:24 2020 +0100 Merge branch 'gtk2' of ssh+git://git.claws-mail.org/home/git/claws into gtk3 commit 4727ce71f6d50dfbb1624953d666f37027867b9a Author: wwp Date: Wed Aug 19 10:57:11 2020 +0200 Fix parsing of command-line arguments: - matching substrings won't work anymore (--receive-al won't match --receive),, I'm not sure at all this was intentional, - fix and enhancement handling of mandatory and optional arguments to options (and fix their representation in --help), - fix sub-arguments not being properly eaten by parser, then being parsed twice, - -d is now an alias to --debug, - avoid hardcoding strings length (fd_write, fd_write_all, strncmp), this is prone to error, - more comprehensive error messages, - man page content updates and fixes, format fixes and enhancements. diff --git a/doc/man/claws-mail.1 b/doc/man/claws-mail.1 index 81b2bfab4..4c8b2c2d8 100644 --- a/doc/man/claws-mail.1 +++ b/doc/man/claws-mail.1 @@ -6,7 +6,7 @@ Claws Mail \- a GTK+ based fast email and news client .SH "SYNOPSIS" .B claws\-mail -.RI [ options ] +.RI [ options ]... .SH "DESCRIPTION" .TP @@ -99,9 +99,9 @@ This list is not complete. .br \fB \-\-subscribe\fR uri .br -\fB \-\-attach file1 [file2]...\fR +\fB \-\-attach\fR file1 [file2]...\fR .br -\fB \-\-insert file1 [file2]...\fR +\fB \-\-insert\fR file1 [file2]...\fR .br \fB \-\-receive\fR .br @@ -111,19 +111,23 @@ This list is not complete. .br \fB \-\-cancel\-sending\fR .br +\fB \-\-search\fR folder type request [recursive] +.br \fB \-\-send\fR .br \fB \-\-status\fR .br -\fB \-\-status folder[/subfolder]\fR +\fB \-\-status\fR folder[/subfolder] .br \fB \-\-status\-full\fR .br +\fB \-\-status\-full\fR folder[/subfolder] +.br \fB \-\-statistics\fR .br \fB \-\-reset-statistics\fR .br -\fB \-\-select [#mh/mailbox/]folder[/msg|/msgid]\fR +\fB \-\-select\fR [#mh/mailbox/]folder[/msg|/msgid], a file:// uri or an absolute path .br \fB \-\-online\fR .br @@ -143,121 +147,121 @@ This list is not complete. .br \fB \-\-config\-dir\fR .br -\fB \-\-alternate\-config\-dir directory\fR +\fB \-\-alternate\-config\-dir\fR directory .br -\fB \-\-geometry WxH+X+Y\fR +\fB \-\-geometry\fR [WxH][+X+Y] .SH "FILES" .LP .TP -$HOME/Mail +\fB$HOME/Mail\fR Default directory for mail storage. .TP -$PREFIX/share/claws\-mail +\fB$PREFIX/share/claws\-mail\fR Global program directory. .TP -$PREFIX/share/claws\-mail/manual +\fB$PREFIX/share/claws\-mail/manual\fR Manual files in HTML, PDF, PostScript and plain text format. .TP -$PREFIX/share/claws\-mail/themes +\fB$PREFIX/share/claws\-mail/themes\fR Global themes directory. .TP -$PREFIX/lib/claws\-mail/plugins +\fB$PREFIX/lib/claws\-mail/plugins\fR Directory for plugins. .TP -$PREFIX/include/claws\-mail +\fB$PREFIX/include/claws\-mail\fR Directory for header files. .TP -$HOME/.claws\-mail +\fB$HOME/.claws\-mail\fR Default directory for user's configuration files directory. .TP -$HOME/.claws\-mail/addrbook/* +\fB$HOME/.claws\-mail/addrbook/*\fR Addressbook files. .TP -$HOME/.claws\-mail/autofaces/* +\fB$HOME/.claws\-mail/autofaces/*\fR Automatic Faces and X\-Faces files for accounts. .TP -$HOME/.claws\-mail/certs/* +\fB$HOME/.claws\-mail/certs/*\fR SSL certificates received from mail servers. .TP -$HOME/.claws\-mail/tagsdb +\fB$HOME/.claws\-mail/tagsdb\fR Tags directory. .TP -$HOME/.claws\-mail/templates +\fB$HOME/.claws\-mail/templates\fR User\-defined templates directory. .TP -$HOME/.claws\-mail/themes +\fB$HOME/.claws\-mail/themes\fR User's themes directory. .TP -$HOME/.claws\-mail/accountrc +\fB$HOME/.claws\-mail/accountrc\fR Configuration for account(s). .TP -$HOME/.claws\-mail/actionsrc +\fB$HOME/.claws\-mail/actionsrc\fR User\-defined custom actions. .TP -$HOME/.claws\-mail/addrbook/attributesrc +\fB$HOME/.claws\-mail/addrbook/attributesrc\fR User\-defined address book custom attributes. .TP -$HOME/.claws\-mail/claws.log +\fB$HOME/.claws\-mail/claws.log\fR Claws Mail logfile. .TP -$HOME/.claws\-mail/clawsrc +\fB$HOME/.claws\-mail/clawsrc\fR Main configuration file. .TP -$HOME/.claws\-mail/command_history +\fB$HOME/.claws\-mail/command_history\fR User\-specified commands. .TP -$HOME/.claws\-mail/customheaderrc +\fB$HOME/.claws\-mail/customheaderrc\fR Configuration for custom headers for sending mail. .TP -$HOME/.claws\-mail/dispheaderrc +\fB$HOME/.claws\-mail/dispheaderrc\fR Configuration for custom display of headers in message view. .TP -$HOME/.claws\-mail/extraheaderrc +\fB$HOME/.claws\-mail/extraheaderrc\fR Editable extra headers to be added to compose window combobox. .TP -$HOME/.claws\-mail/folderitemrc +\fB$HOME/.claws\-mail/folderitemrc\fR All folders' attributes. .TP -$HOME/.claws\-mail/folderlist.xml +\fB$HOME/.claws\-mail/folderlist.xml\fR Folder hierarchy listing. .TP -$HOME/.claws\-mail/gtkrc-2.0 +\fB$HOME/.claws\-mail/gtkrc-2.0\fR Optional GTK+ settings to be load on startup. .TP -$HOME/.claws\-mail/matcherrc +\fB$HOME/.claws\-mail/matcherrc\fR Filtering and Processing function configuration. .TP -$HOME/.claws\-mail/menurc +\fB$HOME/.claws\-mail/menurc\fR Menu shortcut\-key configuration. .TP -$HOME/.claws\-mail/messagesearch_history +\fB$HOME/.claws\-mail/messagesearch_history\fR User\-specified searches in message bodies. .TP -$HOME/.claws\-mail/quicksearch_history +\fB$HOME/.claws\-mail/quicksearch_history\fR User\-specified quick\-search list. .TP -$HOME/.claws\-mail/messagesearch_history +\fB$HOME/.claws\-mail/messagesearch_history\fR User\-specified searches in message bodies. .TP -$HOME/.claws\-mail/summary*_history +\fB$HOME/.claws\-mail/summary*_history\fR User\-specified searches in message list. .TP -$HOME/.claws\-mail/passwordstorerc +\fB$HOME/.claws\-mail/passwordstorerc\fR User saved passwords. .TP -$HOME/.claws\-mail/tagsrc +\fB$HOME/.claws\-mail/tagsrc\fR User\-specified tag list. .TP -$HOME/.claws\-mail/toolbar*.xml +\fB$HOME/.claws\-mail/toolbar*.xml\fR User\-defined custom toolbars. .TP -%TEMP%\\claws\-win32.log -(Windows only) Claws Mail output file when \-\-debug is enabled. If +\fB%TEMP%\\claws\-win32.log \fI(Windows only)\fR +Claws Mail output file when \-\-debug is enabled. If %TEMP% is not set it defaults to windows directory (usually C:\\Windows) or C:\\ if windows directory is not available. .TP -(Windows only) %APPDATA%\\Claws\-mail\\claws.log +\fB %APPDATA%\\Claws\-mail\\claws.log \fI(Windows only)\fR Claws Mail log file. .SH "EXAMPLES" @@ -268,30 +272,30 @@ claws\-mail .LP Alternatively you can run it with the following options: .TP -\fB\-\-compose [address]\fR +\fB\-\-compose\fR [address] To open a Compose window. .TP -\fB\-\-compose\-from\-file file +\fB\-\-compose\fR "mailto:\fI%t\fR?subject=\fI%s\fR&cc=\fI%c\fR&body=\fI%b\fR" +This syntax can be used in web\-browsers and CLI to open a pre\-populated +Compose window. Possible fields after the destination recipient are: subject, +from, cc, bcc, in\-reply\-to, body, insert (insert a file in body part, needs +an absolute path), attach (attach a file, needs an absolute path, see also: +\-\-attach). +.TP +\fB\-\-compose\-from\-file\fR file Open composition window with data from the given file. Use \- as file name for reading from standard input. Content format: headers first (To: header required) until an empty line is found, then mail body until end of file. .TP -\fB\-\-subscribe [uri]\fR +\fB\-\-subscribe\fR uri Subscribe to the given URI if possible. .TP -\fB\-\-attach file1 [file2]...\fR +\fB\-\-attach\fR file1 [file2]... Open composition window with specified files attached. .TP -\fB\-\-insert file1 [file2]...\fR +\fB\-\-insert\fR file1 [file2]... Open composition window with specified files inserted. .TP -\fB\-\-compose\fR "mailto:\fI%t\fR?subject=\fI%s\fR&cc=\fI%c\fR&body=\fI%b\fR" -This syntax can be used in web\-browsers and CLI to open a pre\-populated -Compose window. Possible fields after the destination recipient are: subject, -from, cc, bcc, in\-reply\-to, body, insert (insert a file in body part, needs -an absolute path), attach (attach a file, needs an absolute path, see also: -\-\-attach). -.TP \fB\-\-receive\fR Receive new messages. .TP @@ -304,6 +308,18 @@ Cancel receiving of messages. \fB\-\-cancel\-sending\fR Cancel sending of messages. .TP +\fB\-\-search\fR folder type request [recursive] +.br +Searches mail: +.br +folder ex.: "#mh/Mailbox/inbox" or "Mail" +.br +type: s[ubject],f[rom],t[o],e[xtended],m[ixed] or g: tag +.br +request: search string +.br +recursive: false if arg. starts with 0, n, N, f or F +.TP \fB\-\-send\fR .br Send all queued messages. @@ -313,7 +329,7 @@ Show the total number of messages: .br [new][unread][unread answers to marked][total] .TP -\fB\-\-status folder[/subfolder]\fR +\fB\-\-status\fR folder[/subfolder] Show the total number of messages in the specified folder: .br [new][unread][unread answers to marked][total] @@ -323,6 +339,11 @@ Show the total number of messages per folder: .br [new][unread][unread answers to marked][total] .TP +\fB\-\-status\-full\fR folder[/subfolder] +Show the total number of messages int the specified folder: +.br +[new][unread][unread answers to marked][total] +.TP \fB\-\-statistics\fR .br Show session statistics. @@ -331,8 +352,15 @@ Show session statistics. .br Reset session statistics. .TP -\fB\-\-select [#mh/mailbox/]folder[/msg|/msgid]\fR -On startup, jumps to the specified folder/message. +\fB\-\-select\fR #mh/Mailbox/inbox/123 +.RS 0 +.br +\fB\-\-select\fR file://home/johndoe/Mail/inbox/123 +.br +\fB\-\-select\fR /home/johndoe/Mail/inbox/123 +.RS +On startup, jump to the specified folder/message. +.RE .TP \fB\-\-online\fR Start Claws Mail in (or switch to, if already running) online mode. @@ -340,9 +368,6 @@ Start Claws Mail in (or switch to, if already running) online mode. \fB\-\-offline\fR Start Claws Mail in (or switch to, if already running) offline mode. .TP -\fB\-\-help\fR -Display the help message and exit. -.TP \fB\-\-exit\fR Exit Claws Mail. .TP @@ -354,6 +379,9 @@ section). \fB\-\-toggle-debug\fR Toggle debug mode of the running Claws Mail instance. .TP +\fB\-\-help\fR +Display the help message and exit. +.TP \fB\-\-version\fR Display version number and exit. .TP @@ -363,10 +391,10 @@ Display version number and compiled\-in features then exit. \fB\-\-config\-dir\fR Display the CONFIG\-DIR and exit. .TP -\fB\-\-alternate\-config\-dir [dir]\fR +\fB\-\-alternate\-config\-dir\fR dir Start Claws Mail with the configuration stored in the [dir] directory. .TP -\fB\-\-geometry WxH+X+Y\fR +\fB\-\-geometry\fR [WxH][+X+Y] Set initial X geometry of main window. .SH "ENVIRONMENT" diff --git a/src/common/claws.c b/src/common/claws.c index fa5eb6f1c..c46823bc5 100644 --- a/src/common/claws.c +++ b/src/common/claws.c @@ -63,7 +63,7 @@ static void parse_parameter(int *argc, char ***argv) cm_return_if_fail(argv != NULL); for (i = 1; i < *argc;) { - if (strcmp("--debug", (*argv)[i]) == 0) { + if ((strcmp("--debug", (*argv)[i]) == 0) || (strcmp("-d", (*argv)[i]) == 0)) { debug_set_mode(TRUE); (*argv)[i] = NULL; diff --git a/src/main.c b/src/main.c index 6dfabdfc3..a4cea0161 100644 --- a/src/main.c +++ b/src/main.c @@ -257,6 +257,11 @@ static void networkmanager_state_change_cb(DBusGProxy *proxy, gchar *dev, } \ } +#define STRNCMP(S1, S2) (strncmp((S1), (S2), sizeof((S2)) - 1)) + +#define FD_WRITE(S) fd_write(sock, (S), strlen((S))) +#define FD_WRITE_ALL(S) fd_write(sock, (S), strlen((S))) + static MainWindow *static_mainwindow; static gboolean emergency_exit = FALSE; @@ -471,7 +476,7 @@ static int migrate_common_rc(const gchar *old_rc, const gchar *new_rc) } debug_print("replacing %s with %s\n", old_plugin_path, new_plugin_path); while (claws_fgets(buf, sizeof(buf), oldfp)) { - if (strncmp(buf, old_plugin_path, strlen(old_plugin_path))) { + if (STRNCMP(buf, old_plugin_path)) { err |= (claws_fputs(buf, newfp) == EOF); } else { debug_print("->replacing %s\n", buf); @@ -1844,85 +1849,118 @@ static GString * parse_cmd_compose_from_file(const gchar *fn) #undef G_PRINT_EXIT +static void parse_cmd_opt_error(char *errstr, char* optstr) +{ + gchar tmp[BUFSIZ]; + + cm_return_if_fail(errstr != NULL); + cm_return_if_fail(optstr != NULL); + + g_snprintf(tmp, sizeof(tmp), errstr, optstr); + g_print(_("%s. Try -h or --help for usage.\n"), tmp); + exit(1); +} + static void parse_cmd_opt(int argc, char *argv[]) { AttachInfo *ainfo; gint i; for (i = 1; i < argc; i++) { - if (!strncmp(argv[i], "--receive-all", 13)) { + if (!strcmp(argv[i], "--receive-all")) { cmd.receive_all = TRUE; - } else if (!strncmp(argv[i], "--receive", 9)) { + } else if (!strcmp(argv[i], "--receive")) { cmd.receive = TRUE; - } else if (!strncmp(argv[i], "--cancel-receiving", 18)) { + } else if (!strcmp(argv[i], "--cancel-receiving")) { cmd.cancel_receiving = TRUE; - } else if (!strncmp(argv[i], "--cancel-sending", 16)) { + } else if (!strcmp(argv[i], "--cancel-sending")) { cmd.cancel_sending = TRUE; - } else if (!strncmp(argv[i], "--compose-from-file", 19)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; + } else if (!strcmp(argv[i], "--compose-from-file")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; - GString *mailto = parse_cmd_compose_from_file(p); - cmd.compose = TRUE; - cmd.compose_mailto = mailto->str; - i++; - } else if (!strncmp(argv[i], "--compose", 9)) { + GString *mailto = parse_cmd_compose_from_file(p); + cmd.compose = TRUE; + cmd.compose_mailto = mailto->str; + i++; + } else { + parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--compose")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.compose = TRUE; cmd.compose_mailto = NULL; if (p && *p != '\0' && *p != '-') { - if (!strncmp(p, "mailto:", 7)) { + if (!STRNCMP(p, "mailto:")) { cmd.compose_mailto = p + 7; } else { cmd.compose_mailto = p; } i++; } - } else if (!strncmp(argv[i], "--subscribe", 11)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; - if (p && *p != '\0' && *p != '-') { - cmd.subscribe = TRUE; - cmd.subscribe_uri = p; + } else if (!strcmp(argv[i], "--subscribe")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; + if (p && *p != '\0' && *p != '-') { + cmd.subscribe = TRUE; + cmd.subscribe_uri = p; + } else { + parse_cmd_opt_error(_("Missing or empty uri argument for option %s"), argv[i]); + } + } else { + parse_cmd_opt_error(_("Missing uri argument for option %s"), argv[i]); } - } else if (!strncmp(argv[i], "--attach", 8) || !strncmp(argv[i], "--insert", 8)) { - const gchar *p = (i+1 < argc)?argv[i+1]:NULL; - gchar *file = NULL; - gboolean insert = !strncmp(argv[i], "--insert", 8); - - while (p && *p != '\0' && *p != '-') { - if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) { - if (!is_file_exist(file)) { - g_free(file); - file = NULL; + } else if (!strcmp(argv[i], "--attach") || + !strcmp(argv[i], "--insert")) { + if (i+1 < argc) { + const gchar *p = argv[i+1]; + gint ii = i; + gchar *file = NULL; + gboolean insert = !strcmp(argv[i], "--insert"); + + while (p && *p != '\0' && *p != '-') { + if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) { + if (!is_file_exist(file)) { + g_free(file); + file = NULL; + } + } + if (file == NULL && *p != G_DIR_SEPARATOR) { + file = g_strconcat(claws_get_startup_dir(), + G_DIR_SEPARATOR_S, + p, NULL); + } else if (file == NULL) { + file = g_strdup(p); } - } - if (file == NULL && *p != G_DIR_SEPARATOR) { - file = g_strconcat(claws_get_startup_dir(), - G_DIR_SEPARATOR_S, - p, NULL); - } else if (file == NULL) { - file = g_strdup(p); - } - ainfo = g_new0(AttachInfo, 1); - ainfo->file = file; - ainfo->insert = insert; - cmd.attach_files = g_list_append(cmd.attach_files, ainfo); - i++; - p = (i+1 < argc)?argv[i+1]:NULL; + ainfo = g_new0(AttachInfo, 1); + ainfo->file = file; + ainfo->insert = insert; + cmd.attach_files = g_list_append(cmd.attach_files, ainfo); + ii++; + p = (ii+1 < argc)?argv[ii+1]:NULL; + } + if (ii==i) { + parse_cmd_opt_error(_("Missing at least one non-empty file argument for option %s"), argv[i]); + } else { + i=ii; + } + } else { + parse_cmd_opt_error(_("Missing file argument for option %s"), argv[i]); } - } else if (!strncmp(argv[i], "--send", 6)) { + } else if (!strcmp(argv[i], "--send")) { cmd.send = TRUE; - } else if (!strncmp(argv[i], "--version-full", 14) || - !strncmp(argv[i], "-V", 2)) { + } else if (!strcmp(argv[i], "--version-full") || + !strcmp(argv[i], "-V")) { g_print("Claws Mail version " VERSION_GIT_FULL "\n"); main_dump_features_list(FALSE); exit(0); - } else if (!strncmp(argv[i], "--version", 9) || - !strncmp(argv[i], "-v", 2)) { + } else if (!strcmp(argv[i], "--version") || + !strcmp(argv[i], "-v")) { g_print("Claws Mail version " VERSION "\n"); exit(0); - } else if (!strncmp(argv[i], "--status-full", 13)) { + } else if (!strcmp(argv[i], "--status-full")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.status_full = TRUE; @@ -1936,7 +1974,7 @@ static void parse_cmd_opt(int argc, char *argv[]) i++; p = (i+1 < argc)?argv[i+1]:NULL; } - } else if (!strncmp(argv[i], "--status", 8)) { + } else if (!strcmp(argv[i], "--status")) { const gchar *p = (i+1 < argc)?argv[i+1]:NULL; cmd.status = TRUE; @@ -1948,28 +1986,52 @@ static void parse_cmd_opt(int argc, char *argv[]) i++; p = (i+1 < argc)?argv[i+1]:NULL; } - } else if (!strncmp(argv[i], "--search", 8)) { - cmd.search_folder = (i+1 < argc)?argv[i+1]:NULL; - cmd.search_type = (i+2 < argc)?argv[i+2]:NULL; - cmd.search_request = (i+3 < argc)?argv[i+3]:NULL; - const char* rec = (i+4 < argc)?argv[i+4]:NULL; - cmd.search_recursive = TRUE; - if (rec && (tolower(*rec)=='n' || tolower(*rec)=='f' || *rec=='0')) - cmd.search_recursive = FALSE; - if (cmd.search_folder && cmd.search_type && cmd.search_request) - cmd.search = TRUE; - } else if (!strncmp(argv[i], "--online", 8)) { + } else if (!strcmp(argv[i], "--search")) { + if (i+3 < argc) { /* 3 first arguments are mandatory */ + const char* p; + /* only set search parameters if they are valid */ + p = argv[i+1]; + cmd.search_folder = (p && *p != '\0' && *p != '-')?p:NULL; + p = argv[i+2]; + cmd.search_type = (p && *p != '\0' && *p != '-')?p:NULL; + p = argv[i+3]; + cmd.search_request = (p && *p != '\0' && *p != '-')?p:NULL; + p = (i+4 < argc)?argv[i+4]:NULL; + const char* rec = (p && *p != '\0' && *p != '-')?p:NULL; + cmd.search_recursive = TRUE; + if (rec) { + i++; + if (tolower(*rec)=='n' || tolower(*rec)=='f' || *rec=='0') + cmd.search_recursive = FALSE; + } + if (cmd.search_folder && cmd.search_type && cmd.search_request) { + cmd.search = TRUE; + i+=3; + } + } else { + switch (argc-i-1) { + case 0: + parse_cmd_opt_error(_("Missing folder, type and request arguments for option %s"), argv[i]); + break; + case 1: + parse_cmd_opt_error(_("Missing type and request arguments for option %s"), argv[i]); + break; + case 2: + parse_cmd_opt_error(_("Missing request argument for option %s"), argv[i]); + } + } + } else if (!strcmp(argv[i], "--online")) { cmd.online_mode = ONLINE_MODE_ONLINE; - } else if (!strncmp(argv[i], "--offline", 9)) { + } else if (!strcmp(argv[i], "--offline")) { cmd.online_mode = ONLINE_MODE_OFFLINE; - } else if (!strncmp(argv[i], "--toggle-debug", 14)) { + } else if (!strcmp(argv[i], "--toggle-debug")) { cmd.debug = TRUE; - } else if (!strncmp(argv[i], "--statistics", 12)) { + } else if (!strcmp(argv[i], "--statistics")) { cmd.statistics = TRUE; - } else if (!strncmp(argv[i], "--reset-statistics", 18)) { + } else if (!strcmp(argv[i], "--reset-statistics")) { cmd.reset_statistics = TRUE; - } else if (!strncmp(argv[i], "--help", 6) || - !strncmp(argv[i], "-h", 2)) { + } else if (!strcmp(argv[i], "--help") || + !strcmp(argv[i], "-h")) { gchar *base = g_path_get_basename(argv[0]); g_print(_("Usage: %s [OPTION]...\n"), base); @@ -2003,12 +2065,12 @@ static void parse_cmd_opt(int argc, char *argv[]) " show the status of each folder")); g_print("%s\n", _(" --statistics show session statistics")); g_print("%s\n", _(" --reset-statistics reset session statistics")); - g_print("%s\n", _(" --select folder[/msg] jumps to the specified folder/message\n" - " folder is a folder id like 'folder/sub_folder'")); + g_print("%s\n", _(" --select folder[/msg] jump to the specified folder/message\n" + " folder is a folder id like 'folder/sub_folder', a file:// uri or an absolute path")); g_print("%s\n", _(" --online switch to online mode")); g_print("%s\n", _(" --offline switch to offline mode")); g_print("%s\n", _(" --exit --quit -q exit Claws Mail")); - g_print("%s\n", _(" --debug debug mode")); + g_print("%s\n", _(" --debug -d debug mode")); g_print("%s\n", _(" --toggle-debug toggle debug mode")); g_print("%s\n", _(" --help -h display this help and exit")); g_print("%s\n", _(" --version -v output version information and exit")); @@ -2016,46 +2078,62 @@ static void parse_cmd_opt(int argc, char *argv[]) g_print("%s\n", _(" --config-dir output configuration directory")); g_print("%s\n", _(" --alternate-config-dir directory\n" " use specified configuration directory")); - g_print("%s\n", _(" --geometry -geometry WxH+X+Y\n" + g_print("%s\n", _(" --geometry -geometry [WxH][+X+Y]\n" " set geometry for main window")); g_free(base); exit(1); - } else if (!strncmp(argv[i], "--crash", 7)) { + } else if (!strcmp(argv[i], "--crash")) { cmd.crash = TRUE; cmd.crash_params = g_strdup((i+1 < argc)?argv[i+1]:NULL); i++; - } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) { + } else if (!strcmp(argv[i], "--config-dir")) { g_print(RC_DIR "\n"); exit(0); - } else if (!strncmp(argv[i], "--alternate-config-dir", sizeof "--alternate-config-dir" - 1) && i+1 < argc) { - set_rc_dir(argv[i+1]); - } else if (!strncmp(argv[i], "--geometry", sizeof "--geometry" - 1) - || !strncmp(argv[i], "-geometry", sizeof "-geometry" - 1)) { - cmd.geometry = (i+1 < argc)? argv[i+1]: NULL; - } else if (!strncmp(argv[i], "--exit", 6) || - !strncmp(argv[i], "--quit", 6) || - !strncmp(argv[i], "-q", 2)) { + } else if (!strcmp(argv[i], "--alternate-config-dir")) { + if (i+1 < argc) { + set_rc_dir(argv[i+1]); + i++; + } else { + parse_cmd_opt_error(_("Missing directory argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--geometry") || + !strcmp(argv[i], "-geometry")) { + if (i+1 < argc) { + cmd.geometry = argv[i+1]; + i++; + } else { + parse_cmd_opt_error(_("Missing geometry argument for option %s"), argv[i]); + } + } else if (!strcmp(argv[i], "--exit") || + !strcmp(argv[i], "--quit") || + !strcmp(argv[i], "-q")) { cmd.exit = TRUE; - } else if (!strncmp(argv[i], "--select", 8) && i+1 < argc) { - cmd.target = argv[i+1]; + } else if (!strcmp(argv[i], "--select")) { + if (i+1 < argc) { + cmd.target = argv[i+1]; + i++; + } else { + parse_cmd_opt_error(_("Missing folder argument for option %s"), argv[i]); + } } else if (i == 1 && argc == 2) { /* only one parameter. Do something intelligent about it */ - if ((strstr(argv[i], "@")||!strncmp(argv[i], "mailto:", 7)) && !strstr(argv[i], "://")) { + if ((strstr(argv[i], "@") || !STRNCMP(argv[i], "mailto:")) && !strstr(argv[i], "://")) { const gchar *p = argv[i]; cmd.compose = TRUE; cmd.compose_mailto = NULL; if (p && *p != '\0' && *p != '-') { - if (!strncmp(p, "mailto:", 7)) { + if (!STRNCMP(p, "mailto:")) { cmd.compose_mailto = p + 7; } else { cmd.compose_mailto = p; } } - } else if (!strncmp(argv[i], "file://", 7)) { + } else if (!STRNCMP(argv[i], "file://")) { cmd.target = argv[i]; - } else if (!strncmp(argv[i], "?attach=file://", strlen("?attach=file://"))) { + } else if (!STRNCMP(argv[i], "?attach=file://")) { + /* Thunar support as per 3.3.0cvs19 */ cmd.compose = TRUE; cmd.compose_mailto = argv[i]; } else if (strstr(argv[i], "://")) { @@ -2068,11 +2146,12 @@ static void parse_cmd_opt(int argc, char *argv[]) /* gtk debug */ } else if (is_dir_exist(argv[i]) || is_file_exist(argv[i])) { cmd.target = argv[i]; - } else { - g_print(_("Unknown option. Try -h or --help for usage.\n")); - exit(1); - } - } + } else { + parse_cmd_opt_error(_("Unknown option %s"), argv[i]); + } + } else { + parse_cmd_opt_error(_("Unknown option %s"), argv[i]); + } } if (cmd.attach_files && cmd.compose == FALSE) { @@ -2268,19 +2347,19 @@ static gchar *get_crashfile_name(void) static gint prohibit_duplicate_launch(void) { - gint uxsock; + gint sock; GList *curr; #ifdef G_OS_UNIX gchar *path; path = claws_get_socket_name(); /* Try to connect to the control socket */ - uxsock = fd_connect_unix(path); + sock = fd_connect_unix(path); if (x_display == NULL) x_display = g_strdup(g_getenv("DISPLAY")); - if (uxsock < 0) { + if (sock < 0) { gint ret; #if HAVE_FLOCK gchar *socket_lock; @@ -2330,14 +2409,14 @@ static gint prohibit_duplicate_launch(void) return -1; } if (GetLastError() != ERROR_ALREADY_EXISTS) { - uxsock = fd_open_inet(50216); - if (uxsock < 0) + sock = fd_open_inet(50216); + if (sock < 0) return 0; - return uxsock; + return sock; } - uxsock = fd_connect_inet(50216); - if (uxsock < 0) + sock = fd_connect_inet(50216); + if (sock < 0) return -1; #endif /* remote command mode */ @@ -2345,13 +2424,13 @@ static gint prohibit_duplicate_launch(void) debug_print("another Claws Mail instance is already running.\n"); if (cmd.receive_all) { - fd_write_all(uxsock, "receive_all\n", 12); + FD_WRITE_ALL("receive_all\n"); } else if (cmd.receive) { - fd_write_all(uxsock, "receive\n", 8); + FD_WRITE_ALL("receive\n"); } else if (cmd.cancel_receiving) { - fd_write_all(uxsock, "cancel_receiving\n", 17); + FD_WRITE_ALL("cancel_receiving\n"); } else if (cmd.cancel_sending) { - fd_write_all(uxsock, "cancel_sending\n", 15); + FD_WRITE_ALL("cancel_sending\n"); } else if (cmd.compose && cmd.attach_files) { gchar *str, *compose_str; @@ -2362,20 +2441,20 @@ static gint prohibit_duplicate_launch(void) compose_str = g_strdup("compose_attach\n"); } - fd_write_all(uxsock, compose_str, strlen(compose_str)); + FD_WRITE_ALL(compose_str); g_free(compose_str); for (curr = cmd.attach_files; curr != NULL ; curr = curr->next) { str = (gchar *) ((AttachInfo *)curr->data)->file; if (((AttachInfo *)curr->data)->insert) - fd_write_all(uxsock, "insert ", strlen("insert ")); + FD_WRITE_ALL("insert "); else - fd_write_all(uxsock, "attach ", strlen("attach ")); - fd_write_all(uxsock, str, strlen(str)); - fd_write_all(uxsock, "\n", 1); + FD_WRITE_ALL("attach "); + FD_WRITE_ALL(str); + FD_WRITE_ALL("\n"); } - fd_write_all(uxsock, ".\n", 2); + FD_WRITE_ALL(".\n"); } else if (cmd.compose) { gchar *compose_str; @@ -2386,20 +2465,20 @@ static gint prohibit_duplicate_launch(void) compose_str = g_strdup("compose\n"); } - fd_write_all(uxsock, compose_str, strlen(compose_str)); + FD_WRITE_ALL(compose_str); g_free(compose_str); } else if (cmd.subscribe) { gchar *str = g_strdup_printf("subscribe %s\n", cmd.subscribe_uri); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); } else if (cmd.send) { - fd_write_all(uxsock, "send\n", 5); + FD_WRITE_ALL("send\n"); } else if (cmd.online_mode == ONLINE_MODE_ONLINE) { - fd_write(uxsock, "online\n", 7); + FD_WRITE("online\n"); } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) { - fd_write(uxsock, "offline\n", 8); + FD_WRITE("offline\n"); } else if (cmd.debug) { - fd_write(uxsock, "debug\n", 6); + FD_WRITE("debug\n"); } else if (cmd.status || cmd.status_full) { gchar buf[BUFFSIZE]; gint i; @@ -2411,41 +2490,41 @@ static gint prohibit_duplicate_launch(void) folders = cmd.status_full ? cmd.status_full_folders : cmd.status_folders; - fd_write_all(uxsock, command, strlen(command)); + FD_WRITE_ALL(command); for (i = 0; folders && i < folders->len; ++i) { folder = g_ptr_array_index(folders, i); - fd_write_all(uxsock, folder, strlen(folder)); - fd_write_all(uxsock, "\n", 1); + FD_WRITE_ALL(folder); + FD_WRITE_ALL("\n"); } - fd_write_all(uxsock, ".\n", 2); + FD_WRITE_ALL(".\n"); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; 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_WRITE_ALL("exit\n"); } else if (cmd.statistics) { gchar buf[BUFSIZ]; - fd_write(uxsock, "statistics\n", 11); + FD_WRITE("statistics\n"); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; 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_WRITE("reset_statistics\n"); } else if (cmd.target) { gchar *str = g_strdup_printf("select %s\n", cmd.target); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); } else if (cmd.search) { gchar buf[BUFFSIZE]; @@ -2453,12 +2532,12 @@ static gint prohibit_duplicate_launch(void) g_strdup_printf("search %s\n%s\n%s\n%c\n", cmd.search_folder, cmd.search_type, cmd.search_request, (cmd.search_recursive==TRUE)?'1':'0'); - fd_write_all(uxsock, str, strlen(str)); + FD_WRITE_ALL(str); g_free(str); for (;;) { - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) break; + if (!STRNCMP(buf, ".\n")) break; if (claws_fputs(buf, stdout) == EOF) { g_warning("writing to stdout failed."); break; @@ -2467,24 +2546,24 @@ static gint prohibit_duplicate_launch(void) } else { #ifdef G_OS_UNIX gchar buf[BUFSIZ]; - fd_write_all(uxsock, "get_display\n", 12); + FD_WRITE_ALL("get_display\n"); memset(buf, 0, sizeof(buf)); - fd_gets(uxsock, buf, sizeof(buf) - 1); + fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; if (g_strcmp0(buf, x_display)) { g_print("Claws Mail is already running on display %s.\n", buf); } else { - fd_close(uxsock); - uxsock = fd_connect_unix(path); - fd_write_all(uxsock, "popup\n", 6); + fd_close(sock); + sock = fd_connect_unix(path); + FD_WRITE_ALL("popup\n"); } #else - fd_write_all(uxsock, "popup\n", 6); + FD_WRITE_ALL("popup\n"); #endif } - fd_close(uxsock); + fd_close(sock); return -1; } @@ -2522,7 +2601,7 @@ static GPtrArray *get_folder_item_list(gint sock) for (;;) { fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, ".\n", 2)) { + if (!STRNCMP(buf, ".\n")) { break; } strretchomp(buf); @@ -2555,23 +2634,23 @@ static void lock_socket_input_cb(gpointer data, fd_gets(sock, buf, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; - if (!strncmp(buf, "popup", 5)) { + if (!STRNCMP(buf, "popup")) { main_window_popup(mainwin); #ifdef G_OS_UNIX - } else if (!strncmp(buf, "get_display", 11)) { - fd_write_all(sock, x_display, strlen(x_display)); + } else if (!STRNCMP(buf, "get_display")) { + FD_WRITE_ALL(x_display); #endif - } else if (!strncmp(buf, "receive_all", 11)) { + } else if (!STRNCMP(buf, "receive_all")) { inc_all_account_mail(mainwin, FALSE, FALSE, prefs_common.newmail_notify_manu); - } else if (!strncmp(buf, "receive", 7)) { + } else if (!STRNCMP(buf, "receive")) { inc_mail(mainwin, prefs_common.newmail_notify_manu); - } else if (!strncmp(buf, "cancel_receiving", 16)) { + } else if (!STRNCMP(buf, "cancel_receiving")) { inc_cancel_all(); imap_cancel_all(); - } else if (!strncmp(buf, "cancel_sending", 14)) { + } else if (!STRNCMP(buf, "cancel_sending")) { send_cancel(); - } else if (!strncmp(buf, "compose_attach", 14)) { + } else if (!STRNCMP(buf, "compose_attach")) { GList *files = NULL, *curr; AttachInfo *ainfo; gchar *mailto; @@ -2585,7 +2664,7 @@ static void lock_socket_input_cb(gpointer data, ainfo = g_new0(AttachInfo, 1); ainfo->file = g_strdup(strstr(buf, " ") + 1); - ainfo->insert = !strncmp(buf, "insert ", 7); + ainfo->insert = !STRNCMP(buf, "insert "); files = g_list_append(files, ainfo); } open_compose_new(mailto, files); @@ -2599,36 +2678,36 @@ static void lock_socket_input_cb(gpointer data, } g_list_free(files); g_free(mailto); - } else if (!strncmp(buf, "compose", 7)) { + } else if (!STRNCMP(buf, "compose")) { open_compose_new(buf + strlen("compose") + 1, NULL); - } else if (!strncmp(buf, "subscribe", 9)) { + } else if (!STRNCMP(buf, "subscribe")) { main_window_popup(mainwin); folder_subscribe(buf + strlen("subscribe") + 1); - } else if (!strncmp(buf, "send", 4)) { + } else if (!STRNCMP(buf, "send")) { send_queue(); - } else if (!strncmp(buf, "online", 6)) { + } else if (!STRNCMP(buf, "online")) { main_window_toggle_work_offline(mainwin, FALSE, FALSE); - } else if (!strncmp(buf, "offline", 7)) { + } else if (!STRNCMP(buf, "offline")) { main_window_toggle_work_offline(mainwin, TRUE, FALSE); - } else if (!strncmp(buf, "debug", 5)) { + } else if (!STRNCMP(buf, "debug")) { debug_set_mode(debug_get_mode() ? FALSE : TRUE); - } else if (!strncmp(buf, "status-full", 11) || - !strncmp(buf, "status", 6)) { + } else if (!STRNCMP(buf, "status-full") || + !STRNCMP(buf, "status")) { gchar *status; GPtrArray *folders; folders = get_folder_item_list(sock); status = folder_get_status - (folders, !strncmp(buf, "status-full", 11)); - fd_write_all(sock, status, strlen(status)); - fd_write_all(sock, ".\n", 2); + (folders, !STRNCMP(buf, "status-full")); + FD_WRITE_ALL(status); + FD_WRITE_ALL(".\n"); g_free(status); if (folders) g_ptr_array_free(folders, TRUE); - } else if (!strncmp(buf, "statistics", 10)) { + } else if (!STRNCMP(buf, "statistics")) { gchar tmp[BUFSIZ]; g_snprintf(tmp, sizeof(tmp), _("Session statistics\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); if (prefs_common.date_format) { struct tm *lt; @@ -2642,46 +2721,46 @@ static void lock_socket_input_cb(gpointer data, } else g_snprintf(tmp, sizeof(tmp), _("Started: %s\n"), ctime(&session_stats.time_started)); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL("\n"); g_snprintf(tmp, sizeof(tmp), _("Incoming traffic\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Received messages: %d\n"), session_stats.received); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL("\n"); g_snprintf(tmp, sizeof(tmp), _("Outgoing traffic\n")); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("New/redirected messages: %d\n"), session_stats.sent); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Replied messages: %d\n"), session_stats.replied); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Forwarded messages: %d\n"), session_stats.forwarded); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); g_snprintf(tmp, sizeof(tmp), _("Total outgoing messages: %d\n"), (session_stats.sent + session_stats.replied + session_stats.forwarded)); - fd_write_all(sock, tmp, strlen(tmp)); + FD_WRITE_ALL(tmp); - fd_write_all(sock, ".\n", 2); - } else if (!strncmp(buf, "reset_statistics", 16)) { + FD_WRITE_ALL(".\n"); + } else if (!STRNCMP(buf, "reset_statistics")) { reset_statistics(); - } else if (!strncmp(buf, "select ", 7)) { + } else if (!STRNCMP(buf, "select ")) { const gchar *target = buf+7; mainwindow_jump_to(target, TRUE); - } else if (!strncmp(buf, "search ", 7)) { + } else if (!STRNCMP(buf, "search ")) { FolderItem* folderItem = NULL; GSList *messages = NULL; gchar *folder_name = NULL; @@ -2747,11 +2826,11 @@ static void lock_socket_input_cb(gpointer data, for (cur = messages; cur != NULL; cur = cur->next) { MsgInfo* msg = (MsgInfo *)cur->data; gchar *file = procmsg_get_message_file_path(msg); - fd_write_all(sock, file, strlen(file)); - fd_write_all(sock, "\n", 1); + FD_WRITE_ALL(file); + FD_WRITE_ALL("\n"); g_free(file); } - fd_write_all(sock, ".\n", 2); + FD_WRITE_ALL(".\n"); search_exit: g_free(folder_name); @@ -2759,7 +2838,7 @@ search_exit: advsearch_free(search); if (messages != NULL) procmsg_msg_list_free(messages); - } else if (!strncmp(buf, "exit", 4)) { + } else if (!STRNCMP(buf, "exit")) { if (prefs_common.clean_on_exit && !prefs_common.ask_on_clean) { procmsg_empty_all_trash(); } ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From paul at claws-mail.org Thu Aug 20 10:04:29 2020 From: paul at claws-mail.org (paul at claws-mail.org) Date: Thu, 20 Aug 2020 10:04:29 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-991-gb3158641e Message-ID: <20200820080429.7A91A4014E@claws-mail.org> The branch, gtk3 has been updated via b3158641ec7b6351b94a7e17cf06f4c84374ab89 (commit) from 55ae9699a6bbe2508edddb49c92353ac9fba83d1 (commit) Summary of changes: src/account.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) - Log ----------------------------------------------------------------- commit b3158641ec7b6351b94a7e17cf06f4c84374ab89 Author: paul Date: Thu Aug 20 09:04:23 2020 +0100 allow the Edit Accounts window to be shrunk diff --git a/src/account.c b/src/account.c index 209a1b04a..b7045d84c 100644 --- a/src/account.c +++ b/src/account.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto * * 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 @@ -753,8 +753,7 @@ static void account_edit_create(void) "in the order given, the checkbox indicates which accounts " "will be included. Bold text indicates the default account.")); gtk_widget_show (label); - gtk_widget_set_size_request(GTK_WIDGET(label), - prefs_common.accountswin_width-8, -1); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From mones at claws-mail.org Fri Aug 21 17:09:47 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Fri, 21 Aug 2020 17:09:47 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-8-g62ec17880 Message-ID: <20200821150947.B63AD4018A@claws-mail.org> The branch, master has been updated via 62ec17880c8103147869e46efc0c54f7197473aa (commit) from 460365d085aa234c13db292afb62f7267ef5265f (commit) Summary of changes: src/plugins/libravatar/libravatar.c | 2 +- src/plugins/libravatar/libravatar_image.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) - Log ----------------------------------------------------------------- commit 62ec17880c8103147869e46efc0c54f7197473aa Author: Ricardo Mones Date: Fri Aug 21 17:08:50 2020 +0200 Restore behaviour of missing image mode "None" Server defaults to a predefined image so it never "fails" unless requested. That image is hiding failures and Face/X-Face default handling was never triggered, so to avoid detecting such image (which is prone to future error): - Force a 404 error from server if not found - Detect also HTTP errors on curl call Also: - Handle less-than-minimum files like errors and made it misses too diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c index dee85bba0..1ec1bec5b 100644 --- a/src/plugins/libravatar/libravatar.c +++ b/src/plugins/libravatar/libravatar.c @@ -208,7 +208,7 @@ static gchar *libravatar_url_for_md5(const gchar *base, const gchar *md5) g_free(escaped); return url; } else if (libravatarprefs.default_mode == DEF_MODE_NONE) { - return g_strdup_printf("%s/%s?s=%u", + return g_strdup_printf("%s/%s?s=%u&d=404", base, md5, AVATAR_SIZE); } diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c index 6d0fdac76..4b0bf5643 100644 --- a/src/plugins/libravatar/libravatar_image.c +++ b/src/plugins/libravatar/libravatar_image.c @@ -110,27 +110,28 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha curl_easy_setopt(curl, CURLOPT_MAXREDIRS, maxredirs); } curl_easy_setopt(curl, CURLOPT_FILE, file); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); /* fail on HTTP error */ debug_print("retrieving URL to file: %s -> %s\n", url, filename); res = curl_easy_perform(curl); if (res != CURLE_OK) { - debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res)); + debug_print("curl_easy_perfom failed: %s\n", curl_easy_strerror(res)); unlink(filename); claws_fclose(file); + missing_add_md5(libravatarmisses, md5); } else { filesize = ftell(file); claws_safe_fclose(file); - if (filesize < MIN_PNG_SIZE) + if (filesize < MIN_PNG_SIZE) { debug_print("not enough data for an avatar image: %ld bytes\n", filesize); - else + missing_add_md5(libravatarmisses, md5); + } else { image = image_pixbuf_from_filename(filename); + } - if (!libravatarprefs.cache_icons || filesize == 0) { + if (!libravatarprefs.cache_icons || filesize < MIN_PNG_SIZE) { if (g_unlink(filename) < 0) g_warning("failed to delete cache file '%s'", filename); } - - if (filesize == 0) - missing_add_md5(libravatarmisses, md5); } curl_easy_cleanup(curl); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From mones at claws-mail.org Fri Aug 21 17:10:32 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Fri, 21 Aug 2020 17:10:32 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-992-gbe06120af Message-ID: <20200821151032.242FA40164@claws-mail.org> The branch, gtk3 has been updated via be06120afc05caee7b08815321b2217eeca7618e (commit) from b3158641ec7b6351b94a7e17cf06f4c84374ab89 (commit) Summary of changes: src/plugins/libravatar/libravatar.c | 2 +- src/plugins/libravatar/libravatar_image.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) - Log ----------------------------------------------------------------- commit be06120afc05caee7b08815321b2217eeca7618e Author: Ricardo Mones Date: Fri Aug 21 17:08:50 2020 +0200 Restore behaviour of missing image mode "None" Server defaults to a predefined image so it never "fails" unless requested. That image is hiding failures and Face/X-Face default handling was never triggered, so to avoid detecting such image (which is prone to future error): - Force a 404 error from server if not found - Detect also HTTP errors on curl call Also: - Handle less-than-minimum files like errors and made it misses too diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c index 0b14c6709..5e12b223a 100644 --- a/src/plugins/libravatar/libravatar.c +++ b/src/plugins/libravatar/libravatar.c @@ -208,7 +208,7 @@ static gchar *libravatar_url_for_md5(const gchar *base, const gchar *md5) g_free(escaped); return url; } else if (libravatarprefs.default_mode == DEF_MODE_NONE) { - return g_strdup_printf("%s/%s?s=%u", + return g_strdup_printf("%s/%s?s=%u&d=404", base, md5, AVATAR_SIZE); } diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c index 6d0fdac76..4b0bf5643 100644 --- a/src/plugins/libravatar/libravatar_image.c +++ b/src/plugins/libravatar/libravatar_image.c @@ -110,27 +110,28 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha curl_easy_setopt(curl, CURLOPT_MAXREDIRS, maxredirs); } curl_easy_setopt(curl, CURLOPT_FILE, file); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); /* fail on HTTP error */ debug_print("retrieving URL to file: %s -> %s\n", url, filename); res = curl_easy_perform(curl); if (res != CURLE_OK) { - debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res)); + debug_print("curl_easy_perfom failed: %s\n", curl_easy_strerror(res)); unlink(filename); claws_fclose(file); + missing_add_md5(libravatarmisses, md5); } else { filesize = ftell(file); claws_safe_fclose(file); - if (filesize < MIN_PNG_SIZE) + if (filesize < MIN_PNG_SIZE) { debug_print("not enough data for an avatar image: %ld bytes\n", filesize); - else + missing_add_md5(libravatarmisses, md5); + } else { image = image_pixbuf_from_filename(filename); + } - if (!libravatarprefs.cache_icons || filesize == 0) { + if (!libravatarprefs.cache_icons || filesize < MIN_PNG_SIZE) { if (g_unlink(filename) < 0) g_warning("failed to delete cache file '%s'", filename); } - - if (filesize == 0) - missing_add_md5(libravatarmisses, md5); } curl_easy_cleanup(curl); ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From mones at claws-mail.org Fri Aug 21 18:30:46 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Fri, 21 Aug 2020 18:30:46 +0200 (CEST) Subject: [Commits] [SCM] claws branch, master, updated. 3.17.6-9-g40bb4034e Message-ID: <20200821163046.BC36E40164@claws-mail.org> The branch, master has been updated via 40bb4034e4d657f279713f61cd5ca873a90a0489 (commit) from 62ec17880c8103147869e46efc0c54f7197473aa (commit) Summary of changes: src/plugins/libravatar/libravatar.c | 4 +++- src/plugins/libravatar/libravatar_prefs.c | 12 ++++++++++-- src/plugins/libravatar/libravatar_prefs.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) - Log ----------------------------------------------------------------- commit 40bb4034e4d657f279713f61cd5ca873a90a0489 Author: Ricardo Mones Date: Fri Aug 21 18:30:27 2020 +0200 Add new styles supported: Robohash and Pagan Amazing how much of these can be written, isn't it? :) diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c index 1ec1bec5b..75ec065ff 100644 --- a/src/plugins/libravatar/libravatar.c +++ b/src/plugins/libravatar/libravatar.c @@ -46,7 +46,9 @@ static const char *def_mode[] = { "identicon", "monsterid", "wavatar", - "retro" + "retro", + "robohash", + "pagan" }; static gulong update_hook_id = HOOK_NONE; diff --git a/src/plugins/libravatar/libravatar_prefs.c b/src/plugins/libravatar/libravatar_prefs.c index 3a097001b..4538477e8 100644 --- a/src/plugins/libravatar/libravatar_prefs.c +++ b/src/plugins/libravatar/libravatar_prefs.c @@ -37,8 +37,8 @@ #include "alertpanel.h" #define PREFS_BLOCK_NAME "Libravatar" -#define NUM_DEF_BUTTONS 7 -#define CUSTOM_URL_BUTTON_INDEX 6 +#define NUM_DEF_BUTTONS 9 +#define CUSTOM_URL_BUTTON_INDEX 8 /* cache interval goes from 1 hour to 30 days */ #define INTERVAL_MIN_H 1.0 #define INTERVAL_MAX_H 720.0 @@ -301,6 +301,8 @@ static const guint radio_value[] = { DEF_MODE_MONSTERID, DEF_MODE_WAVATAR, DEF_MODE_RETRO, + DEF_MODE_ROBOHASH, + DEF_MODE_PAGAN, DEF_MODE_URL }; @@ -316,6 +318,8 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page) _("MonsterID"), _("Wavatar"), _("Retro"), + _("Robohash"), + _("Pagan"), _("Custom URL") }; gchar *radio_hint[] = { @@ -325,6 +329,8 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page) _("A generated full-body monster"), _("A generated almost unique face"), _("A generated 8-bit arcade-style pixelated image"), + _("A generated robotic character"), + _("A generated retro adventure game character"), _("Redirect to a user provided URL") }; @@ -439,6 +445,8 @@ static GtkWidget *p_create_frame_network(struct LibravatarPrefsPage *page) │ ( ) MonsterID │ │ ( ) Wavatar │ │ ( ) Retro │ + │ ( ) Robohash │ + │ ( ) Pagan │ │ ( ) Custom URL [___________________________________] │ └──────────────────────────────────────────────────────┘ ┌─Network──────────────────────────────────────────────┐ diff --git a/src/plugins/libravatar/libravatar_prefs.h b/src/plugins/libravatar/libravatar_prefs.h index 2e4cb93c3..f6445358b 100644 --- a/src/plugins/libravatar/libravatar_prefs.h +++ b/src/plugins/libravatar/libravatar_prefs.h @@ -34,6 +34,8 @@ enum DEF_MODE_MONSTERID = 13, DEF_MODE_WAVATAR = 14, DEF_MODE_RETRO = 15, + DEF_MODE_ROBOHASH = 16, + DEF_MODE_PAGAN = 17 }; struct _LibravatarPrefs ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From mones at claws-mail.org Fri Aug 21 18:31:23 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Fri, 21 Aug 2020 18:31:23 +0200 (CEST) Subject: [Commits] [SCM] claws branch, gtk3, updated. 3.16.0-993-gfa9de1494 Message-ID: <20200821163123.ADA12401BB@claws-mail.org> The branch, gtk3 has been updated via fa9de149482e3df257a5271815fad7f5453f17b7 (commit) from be06120afc05caee7b08815321b2217eeca7618e (commit) Summary of changes: src/plugins/libravatar/libravatar.c | 4 +++- src/plugins/libravatar/libravatar_prefs.c | 12 ++++++++++-- src/plugins/libravatar/libravatar_prefs.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) - Log ----------------------------------------------------------------- commit fa9de149482e3df257a5271815fad7f5453f17b7 Author: Ricardo Mones Date: Fri Aug 21 18:30:27 2020 +0200 Add new styles supported: Robohash and Pagan Amazing how much of these can be written, isn't it? :) diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c index 5e12b223a..265f30b92 100644 --- a/src/plugins/libravatar/libravatar.c +++ b/src/plugins/libravatar/libravatar.c @@ -46,7 +46,9 @@ static const char *def_mode[] = { "identicon", "monsterid", "wavatar", - "retro" + "retro", + "robohash", + "pagan" }; static gulong update_hook_id = HOOK_NONE; diff --git a/src/plugins/libravatar/libravatar_prefs.c b/src/plugins/libravatar/libravatar_prefs.c index 5e8717323..23b2993f1 100644 --- a/src/plugins/libravatar/libravatar_prefs.c +++ b/src/plugins/libravatar/libravatar_prefs.c @@ -37,8 +37,8 @@ #include "alertpanel.h" #define PREFS_BLOCK_NAME "Libravatar" -#define NUM_DEF_BUTTONS 7 -#define CUSTOM_URL_BUTTON_INDEX 6 +#define NUM_DEF_BUTTONS 9 +#define CUSTOM_URL_BUTTON_INDEX 8 /* cache interval goes from 1 hour to 30 days */ #define INTERVAL_MIN_H 1.0 #define INTERVAL_MAX_H 720.0 @@ -301,6 +301,8 @@ static const guint radio_value[] = { DEF_MODE_MONSTERID, DEF_MODE_WAVATAR, DEF_MODE_RETRO, + DEF_MODE_ROBOHASH, + DEF_MODE_PAGAN, DEF_MODE_URL }; @@ -316,6 +318,8 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page) _("MonsterID"), _("Wavatar"), _("Retro"), + _("Robohash"), + _("Pagan"), _("Custom URL") }; gchar *radio_hint[] = { @@ -325,6 +329,8 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page) _("A generated full-body monster"), _("A generated almost unique face"), _("A generated 8-bit arcade-style pixelated image"), + _("A generated robotic character"), + _("A generated retro adventure game character"), _("Redirect to a user provided URL") }; @@ -440,6 +446,8 @@ static GtkWidget *p_create_frame_network(struct LibravatarPrefsPage *page) │ ( ) MonsterID │ │ ( ) Wavatar │ │ ( ) Retro │ + │ ( ) Robohash │ + │ ( ) Pagan │ │ ( ) Custom URL [___________________________________] │ └──────────────────────────────────────────────────────┘ ┌─Network──────────────────────────────────────────────┐ diff --git a/src/plugins/libravatar/libravatar_prefs.h b/src/plugins/libravatar/libravatar_prefs.h index 2e4cb93c3..f6445358b 100644 --- a/src/plugins/libravatar/libravatar_prefs.h +++ b/src/plugins/libravatar/libravatar_prefs.h @@ -34,6 +34,8 @@ enum DEF_MODE_MONSTERID = 13, DEF_MODE_WAVATAR = 14, DEF_MODE_RETRO = 15, + DEF_MODE_ROBOHASH = 16, + DEF_MODE_PAGAN = 17 }; struct _LibravatarPrefs ----------------------------------------------------------------------- hooks/post-receive -- Claws Mail From mones at claws-mail.org Mon Aug 31 20:22:24 2020 From: mones at claws-mail.org (mones at claws-mail.org) Date: Mon, 31 Aug 2020 20:22:24 +0200 (CEST) Subject: [Commits] [SCM] clawsker branch, master, updated. 1.3.1-6-g5deec78 Message-ID: <20200831182225.1FC8B40258@claws-mail.org> The branch, master has been updated via 5deec78bc49cbdcda23597f611f6f67fa6516845 (commit) from 363371d2d8e1ce45b57bd5e35bb61d0fb1515392 (commit) Summary of changes: clawsker | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) - Log ----------------------------------------------------------------- commit 5deec78bc49cbdcda23597f611f6f67fa6516845 Author: Ricardo Mones Date: Mon Aug 31 20:22:06 2020 +0200 Redirect hidden prefs for Libravatar plugin diff --git a/clawsker b/clawsker index 09cb114..f986f04 100755 --- a/clawsker +++ b/clawsker @@ -222,6 +222,13 @@ sub _ { h_plu_gpg_alimit => _('Limits the number of addresses obtained from keyring through autocompletion. Use 0 to get all matches.'), l_plu_lav_burl => _('Base URL'), h_plu_lav_burl => _('This is the URL where avatar requests are sent. You can use the one of your own libravatar server, if available.'), + l_plu_lav_maxr => _('Default redirects'), + h_plu_lav_maxr => _('Maximum default value for HTTP redirects, if enabled'), + l_plu_lav_maxrmm => _('Mistery man redirects'), + h_plu_lav_maxrmm => _('Maximum value for HTTP redirects when using "Mistery man" mode.'), + l_plu_lav_maxrurl => _('Custom URL redirects'), + h_plu_lav_maxrurl => _('Maximum value for HTTP redirects when using a custom URL'), + l_plu_prl_flvb => _('Log level'), h_plu_prl_flvb => _('Verbosity level of log, accumulative.'), l_plu_prl_none => _('None'), @@ -2055,6 +2062,33 @@ sub new_accounts_page() { 'http://cdn.libravatar.org/avatar', 'Libravatar', ], + lav_maxr => [ + 'max_redirects', + $xl::s{l_plu_lav_maxr}, + $xl::s{h_plu_lav_maxr}, + 'int,1,100', + '3.17.5.23', + '3', + 'Libravatar', + ], + lav_maxrmm => [ + 'max_redirects_mm', + $xl::s{l_plu_lav_maxrmm}, + $xl::s{h_plu_lav_maxrmm}, + 'int,1,100', + '3.17.5.23', + '5', + 'Libravatar', + ], + lav_maxrurl => [ + 'max_redirects_url', + $xl::s{l_plu_lav_maxrurl}, + $xl::s{h_plu_lav_maxrurl}, + 'int,1,100', + '3.17.5.23', + '7', + 'Libravatar', + ], # perl prl_flvb => [ 'filter_log_verbosity', @@ -2080,9 +2114,12 @@ sub new_plugins_page() { new_text_box_for_int (\%pr::plu, 'msv_winw', $PLHPVALUE{'ManageSieve'}), new_text_box_for_int (\%pr::plu, 'msv_winh', $PLHPVALUE{'ManageSieve'}) ], - 'Libravatar' => [ - new_text_box_for_nchar (\%pr::plu, 'lav_burl', $PLHPVALUE{'Libravatar'}) - ], + 'Libravatar' => [new_grid_pack (2, 4, [ + [ new_text_box_for_nchar (\%pr::plu, 'lav_burl', $PLHPVALUE{'Libravatar'}) ], + [ new_text_box_for_int (\%pr::plu, 'lav_maxr', $PLHPVALUE{'Libravatar'}) ], + [ new_text_box_for_int (\%pr::plu, 'lav_maxrmm', $PLHPVALUE{'Libravatar'}) ], + [ new_text_box_for_int (\%pr::plu, 'lav_maxrurl', $PLHPVALUE{'Libravatar'}) ] + ])], 'PerlPlugin' => [ new_selection_box_for (\%pr::plu, 'prl_flvb', $PLHPVALUE{'PerlPlugin'}) ] ----------------------------------------------------------------------- hooks/post-receive -- Hidden preferences editor for Claws Mail