[Commits] [SCM] claws branch, master, updated. 4.2.0-91-g2c1eaa1af

mones at claws-mail.org mones at claws-mail.org
Sun May 12 19:20:33 UTC 2024


The branch, master has been updated
       via  2c1eaa1afc9669cf4fc62f7741e67dadb5919ce6 (commit)
      from  59d1aa181639275f8bd221d8e105b29b5b1fadba (commit)

Summary of changes:
 claws-mail.desktop   | 15 +++++++++++++--
 doc/man/claws-mail.1 |  4 +++-
 src/import.c         | 14 +++++++++-----
 src/import.h         |  5 ++---
 src/main.c           | 22 +++++++++++++++++++++-
 src/mainwindow.c     | 13 ++++++++++++-
 src/mainwindow.h     |  4 +++-
 7 files changed, 63 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit 2c1eaa1afc9669cf4fc62f7741e67dadb5919ce6
Author: Ricardo Mones <ricardo at mones.org>
Date:   Sun May 12 01:30:36 2024 +0200

    Import mboxes from command line

diff --git a/claws-mail.desktop b/claws-mail.desktop
index a50b33b89..f50ead92e 100644
--- a/claws-mail.desktop
+++ b/claws-mail.desktop
@@ -44,10 +44,10 @@ Comment[tr]=GTK temelli hafif ve hızlı bir E-posta İstemcisi
 Terminal=false
 Type=Application
 StartupNotify=true
-MimeType=x-scheme-handler/mailto;
+MimeType=application/mbox;x-scheme-handler/mailto;
 X-Info=Claws Mail
 
-Actions=GetMail;ComposeMail;SendFile;
+Actions=GetMail;ComposeMail;SendFile;ImportMbox;
 
 [Desktop Action GetMail]
 Exec=claws-mail --receive-all
@@ -84,3 +84,14 @@ Name[pl]=Wyślij plik...
 Name[pt]=Enviar ficheiro...
 Name[ru]=Отправить файл...
 Name[tr]=Ekli e-posta yaz...
+
+[Desktop Action ImportMbox]
+Exec=claws-mail --import-mbox %f
+Name=Import mbox file...
+Name[ca]=Importar arxiu mbox...
+Name[es]=Importar fichero mbox...
+Name[fr]=Importer un fichier mbox...
+Name[he]=ייבוא קובץ mbox...
+Name[pt]=Importar ficheiro mbox...
+Name[ru]=Импорт mbox файла...
+Name[tr]=mbox dosyasını içe aktar...
diff --git a/doc/man/claws-mail.1 b/doc/man/claws-mail.1
index 70f484804..e7a488f76 100644
--- a/doc/man/claws-mail.1
+++ b/doc/man/claws-mail.1
@@ -1,4 +1,4 @@
-.TH "CLAWS MAIL" "1" "March 17, 2022" "The Claws Mail team" "User Manuals"
+.TH "CLAWS MAIL" "1" "February 17, 2024" "The Claws Mail team" "User Manuals"
 
 .SH "NAME"
 .LP
@@ -103,6 +103,8 @@ This list is not complete.
 .br
 \fB \-\-insert\fR file1 [file2]...\fR
 .br
+\fB \-\-import-mbox\fR file\fR
+.br
 \fB \-\-receive\fR
 .br
 \fB \-\-receive\-all\fR
diff --git a/src/import.c b/src/import.c
index 1a250981e..b0c66373c 100644
--- a/src/import.c
+++ b/src/import.c
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2022 the Claws Mail team and Hiroyuki Yamamoto
+ * Copyright (C) 1999-2024 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
@@ -58,7 +58,7 @@ static void import_destsel_cb(GtkWidget *widget, gpointer data);
 static gint delete_event(GtkWidget *widget, GdkEventAny *event, gpointer data);
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data);
 
-gint import_mbox(FolderItem *default_dest)
+gint import_mbox(FolderItem *default_dest, const gchar* mbox_file)
 /* return values: -2 skipped/cancelled, -1 error, 0 OK */
 {
 	gchar *dest_id = NULL;
@@ -85,7 +85,10 @@ gint import_mbox(FolderItem *default_dest)
 	} else {
 		gtk_entry_set_text(GTK_ENTRY(dest_entry), "");
 	}
-	gtk_entry_set_text(GTK_ENTRY(file_entry), "");
+	if (mbox_file)
+		gtk_entry_set_text(GTK_ENTRY(file_entry), mbox_file);
+	else
+		gtk_entry_set_text(GTK_ENTRY(file_entry), "");
 	gtk_widget_grab_focus(file_entry);
 
 	manage_window_set_transient(GTK_WINDOW(window));
@@ -110,6 +113,7 @@ static void import_create(void)
 
 	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "import");
 	gtk_window_set_title(GTK_WINDOW(window), _("Import mbox file"));
+	gtk_window_set_modal(GTK_WINDOW(window), TRUE);
 	gtk_container_set_border_width(GTK_CONTAINER(window), 5);
 	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
 	gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
@@ -237,13 +241,13 @@ static void import_ok_cb(GtkWidget *widget, gpointer data)
 
 	g_free(mbox);
 
-	if (gtk_main_level() > 1)
+	if (gtk_main_level() > 0)
 		gtk_main_quit();
 }
 
 static void import_cancel_cb(GtkWidget *widget, gpointer data)
 {
-	if (gtk_main_level() > 1)
+	if (gtk_main_level() > 0)
 		gtk_main_quit();
 }
 
diff --git a/src/import.h b/src/import.h
index 5c43eeed8..33eb733c8 100644
--- a/src/import.h
+++ b/src/import.h
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2024 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 #ifndef __IMPORT_H__
@@ -24,6 +23,6 @@
 
 #include "folder.h"
 
-gint import_mbox(FolderItem *default_dest);
+gint import_mbox(FolderItem *default_dest, const gchar* mbox_file);
 
 #endif /* __IMPORT_H__ */
diff --git a/src/main.c b/src/main.c
index 4e4f446ef..6fd750298 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2023 the Claws Mail team and Hiroyuki Yamamoto
+ * Copyright (C) 1999-2024 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
@@ -205,6 +205,7 @@ static struct RemoteCmd {
 	const gchar *target;
 	gboolean debug;
 	const gchar *geometry;
+	const gchar *import_mbox;
 } cmd;
 
 SessionStats session_stats;
@@ -1506,6 +1507,10 @@ int main(int argc, char *argv[])
 	folderview_thaw(mainwin->folderview);
 	main_window_cursor_normal(mainwin);
 
+	if (cmd.import_mbox) {
+		mainwindow_import_mbox(cmd.import_mbox);
+	}
+
 	if (!cmd.target && prefs_common.goto_folder_on_startup &&
 	    folder_find_item_from_identifier(prefs_common.startup_folder) != NULL &&
 	    !claws_crashed()) {
@@ -1995,6 +2000,7 @@ static void parse_cmd_opt(int argc, char *argv[])
  			g_print("%s\n", _("  --reset-statistics     reset session statistics"));
 			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", _("  --import-mbox file     import the specified mbox file\n"));
 			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"));
@@ -2044,6 +2050,13 @@ static void parse_cmd_opt(int argc, char *argv[])
 		    } else {
                 parse_cmd_opt_error(_("Missing folder argument for option %s"), argv[i]);
 			}
+		} else if (!strcmp(argv[i], "--import-mbox")) {
+			if (i+1 < argc) {
+				cmd.import_mbox = argv[i+1];
+				i++;
+			} else {
+				parse_cmd_opt_error(_("Missing file 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:")) && !strstr(argv[i], "://")) {
@@ -2448,6 +2461,10 @@ static gint prohibit_duplicate_launch(int *argc, char ***argv)
 		gchar *str = g_strdup_printf("select %s\n", cmd.target);
 		CM_FD_WRITE_ALL(str);
 		g_free(str);
+	} else if (cmd.import_mbox) {
+		gchar *str = g_strdup_printf("import %s\n", cmd.import_mbox);
+		CM_FD_WRITE_ALL(str);
+		g_free(str);
 	} else if (cmd.search) {
 		gchar buf[BUFFSIZE];
 		gchar *str =
@@ -2701,6 +2718,9 @@ static void lock_socket_input_cb(gpointer data,
 	} else if (!STRNCMP(buf, "select ")) {
 		const gchar *target = buf+7;
 		mainwindow_jump_to(target, TRUE);
+	} else if (!STRNCMP(buf, "import ")) {
+		const gchar *mbox_file = buf + 7;
+		mainwindow_import_mbox(mbox_file);
 	} else if (!STRNCMP(buf, "search ")) {
 		FolderItem* folderItem = NULL;
 		GSList *messages = NULL;
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 4473b8004..c1857f8c5 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -3938,7 +3938,7 @@ static void import_mbox_cb(GtkAction *action, gpointer data)
 {
 	MainWindow *mainwin = (MainWindow *)data;
 	/* only notify if import has failed */
-	if (import_mbox(mainwin->summaryview->folder_item) == -1) {
+	if (import_mbox(mainwin->summaryview->folder_item, NULL) == -1) {
 		alertpanel_error(_("Mbox import has failed."));
 	}
 }
@@ -5576,3 +5576,14 @@ static void goto_prev_part_cb(GtkAction *action, gpointer data)
 	&&  mainwin->messageview->mimeview)
 		mimeview_select_prev_part(mainwin->messageview->mimeview);
 }
+
+void mainwindow_import_mbox(const gchar* mbox_file)
+{
+	MainWindow *mainwin = mainwindow_get_mainwindow();
+
+	strcrlftrunc((gchar *) mbox_file);
+	/* only notify if import has failed */
+	if (import_mbox(mainwin->summaryview->folder_item, mbox_file) == -1) {
+		alertpanel_error(_("Mbox import has failed."));
+	}
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 566f1077e..2b2ec3caf 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- *  Copyright (C) 1999-2023 the Claws Mail team and Hiroyuki Yamamoto
+ * Copyright (C) 1999-2024 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
@@ -227,4 +227,6 @@ void mainwindow_reset_paned		      (GtkPaned *paned);
 void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModifierType modifier,
 				  GClosure *closure, GtkMenuItem *item);
 
+void mainwindow_import_mbox(const gchar* mbox_file);
+
 #endif /* __MAINWINDOW_H__ */

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list