[Commits] [SCM] claws branch, master, updated. 3.9.0-168-ge02c1b6
mones at claws-mail.org
mones at claws-mail.org
Fri Apr 5 01:14:50 CEST 2013
The branch master of project "claws" (Claws Mail) has been updated
via e02c1b684adc6b9b2a6a3f855418165bf885af51 (commit)
via a10e28992076c2f28de3ed842f31192aa29ffec9 (commit)
via a700fea56f5835856150bbd19b6936d1fc019638 (commit)
from 4bdc5af65d7a1d03557a2ea5f7c928384630cdf2 (commit)
- Log -----------------------------------------------------------------
commit e02c1b684adc6b9b2a6a3f855418165bf885af51
Author: Ricardo Mones <ricardo at mones.org>
Date: Thu Apr 4 01:31:57 2013 +0200
Ensure available fallback folder for NewMail log
Fixes bug #2859 "Newmail plugin doesn't work if Mail folder
not present when it is loaded."
Also included:
* Show current log file name in plugin description.
* Remove log file name limit of 255 bytes.
diff --git a/src/plugins/newmail/newmail.c b/src/plugins/newmail/newmail.c
index e3d7bfd..268e3e8 100644
--- a/src/plugins/newmail/newmail.c
+++ b/src/plugins/newmail/newmail.c
@@ -37,11 +37,15 @@
#include "plugin.h"
+#define LOG_NAME "NewLog"
+#define DEFAULT_DIR "Mail"
+
static guint hook_id;
static FILE *NewLog = NULL;
static char *LogName = NULL;
static int truncLog = 1;
+static char *pluginDesc = NULL;
static gchar *defstr (gchar *s)
{
@@ -84,8 +88,15 @@ gboolean plugin_done (void)
if (NewLog) {
(void)fclose (NewLog);
NewLog = NULL;
+ }
+ if (LogName) {
+ g_free(LogName);
LogName = NULL;
}
+ if (pluginDesc) {
+ g_free(pluginDesc);
+ pluginDesc = NULL;
+ }
hooks_unregister_hook (MAIL_POSTFILTERING_HOOKLIST, hook_id);
debug_print ("Newmail plugin unloaded\n");
@@ -107,28 +118,32 @@ gint plugin_init (gchar **error)
if (!NewLog) {
auto char *mode = truncLog ? "w" : "a";
if (!LogName) {
- auto size_t l;
- auto char name[260];
- (void)snprintf (name, 256, "%s/Mail/NewLog", getenv ("HOME"));
- l = strlen (name);
- if (l > 255 || !(LogName = (char *)malloc (l + 1))) {
- *error = g_strdup (_("Cannot load plugin NewMail\n"
- "$HOME is too long\n"));
+ LogName = g_strconcat(getenv ("HOME"), G_DIR_SEPARATOR_S, DEFAULT_DIR,
+ G_DIR_SEPARATOR_S, LOG_NAME, NULL);
+ }
+ if (!(NewLog = fopen (LogName, mode))) {
+ debug_print ("Failed to open default log %s\n", LogName);
+ /* try fallback location */
+ g_free(LogName);
+ LogName = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, LOG_NAME, NULL);
+ if (!(NewLog = fopen (LogName, mode))) {
+ debug_print ("Failed to open fallback log %s\n", LogName);
+ *error = g_strdup_printf(_("Could not open log file %s: %s\n"),
+ LogName, sys_errlist[errno]);
plugin_done ();
return (-1);
}
- (void)strcpy (LogName, name);
- }
- if (!(NewLog = fopen (LogName, mode))) {
- *error = g_strdup (sys_errlist[errno]);
- plugin_done ();
- return (-1);
}
setbuf (NewLog, NULL);
}
debug_print ("Newmail plugin loaded\n"
"Message header summaries written to %s\n", LogName);
+ if (pluginDesc == NULL)
+ pluginDesc = g_strdup_printf(
+ _("This plugin writes a header summary to a log file for each "
+ "mail received after sorting.\n\n"
+ "Default is ~/Mail/NewLog\n\nCurrent log is %s"), LogName);
return (0);
} /* plugin_init */
@@ -139,9 +154,7 @@ const gchar *plugin_name (void)
const gchar *plugin_desc (void)
{
- return _("This Plugin writes a header summary to a log file for each "
- "mail received after sorting.\n\n"
- "Default is ~/Mail/NewLog");
+ return pluginDesc;
} /* plugin_desc */
const gchar *plugin_type (void)
commit a10e28992076c2f28de3ed842f31192aa29ffec9
Author: Ricardo Mones <ricardo at mones.org>
Date: Thu Apr 4 01:02:42 2013 +0200
Fix indentation
diff --git a/src/plugins/newmail/newmail.c b/src/plugins/newmail/newmail.c
index 92ec0c2..e3d7bfd 100644
--- a/src/plugins/newmail/newmail.c
+++ b/src/plugins/newmail/newmail.c
@@ -4,7 +4,7 @@
* Copyright (C) 2005-2005 H.Merijn Brand and the Claws Mail Team
*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 the Claws Mail Team
+ * Copyright (C) 1999-2013 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
@@ -45,52 +45,52 @@ static int truncLog = 1;
static gchar *defstr (gchar *s)
{
- return s ? s : "(null)";
- } /* defstr */
+ return s ? s : "(null)";
+} /* defstr */
gboolean newmail_hook (gpointer source, gpointer data)
{
- auto MsgInfo *msginfo = (MsgInfo *)source;
- auto FolderItem *tof;
-
- if (!msginfo) return (FALSE);
-
- tof = msginfo->folder;
- (void)fprintf (NewLog, "---\n"
- "Date:\t%s\n"
- "Subject:\t%s\n"
- "From:\t%s\n"
- "To:\t%s\n"
- "Cc:\t%s\n"
- "Size:\t%jd\n"
- "Path:\t%s\n"
- "Message:\t%d\n"
- "Folder:\t%s\n",
- defstr (msginfo->date),
- defstr (msginfo->subject),
- defstr (msginfo->from),
- defstr (msginfo->to),
- defstr (msginfo->cc),
- (intmax_t) msginfo->size,
- defstr (procmsg_get_message_file_path (msginfo)),
- msginfo->msgnum,
- tof ? defstr (tof->name) : "(null)");
-
- return (FALSE);
- } /* newmail_hook */
+ auto MsgInfo *msginfo = (MsgInfo *)source;
+ auto FolderItem *tof;
+
+ if (!msginfo) return (FALSE);
+
+ tof = msginfo->folder;
+ (void)fprintf (NewLog, "---\n"
+ "Date:\t%s\n"
+ "Subject:\t%s\n"
+ "From:\t%s\n"
+ "To:\t%s\n"
+ "Cc:\t%s\n"
+ "Size:\t%jd\n"
+ "Path:\t%s\n"
+ "Message:\t%d\n"
+ "Folder:\t%s\n",
+ defstr (msginfo->date),
+ defstr (msginfo->subject),
+ defstr (msginfo->from),
+ defstr (msginfo->to),
+ defstr (msginfo->cc),
+ (intmax_t) msginfo->size,
+ defstr (procmsg_get_message_file_path (msginfo)),
+ msginfo->msgnum,
+ tof ? defstr (tof->name) : "(null)");
+
+ return (FALSE);
+} /* newmail_hook */
gboolean plugin_done (void)
{
- if (NewLog) {
- (void)fclose (NewLog);
- NewLog = NULL;
- LogName = NULL;
+ if (NewLog) {
+ (void)fclose (NewLog);
+ NewLog = NULL;
+ LogName = NULL;
}
- hooks_unregister_hook (MAIL_POSTFILTERING_HOOKLIST, hook_id);
+ hooks_unregister_hook (MAIL_POSTFILTERING_HOOKLIST, hook_id);
- debug_print ("Newmail plugin unloaded\n");
- return TRUE;
- } /* plugin_done */
+ debug_print ("Newmail plugin unloaded\n");
+ return TRUE;
+} /* plugin_done */
gint plugin_init (gchar **error)
{
@@ -99,65 +99,65 @@ gint plugin_init (gchar **error)
return -1;
hook_id = hooks_register_hook (MAIL_POSTFILTERING_HOOKLIST, newmail_hook, NULL);
- if (hook_id == -1) {
+ if (hook_id == -1) {
*error = g_strdup (_("Failed to register newmail hook"));
return (-1);
}
- if (!NewLog) {
- auto char *mode = truncLog ? "w" : "a";
- if (!LogName) {
- auto size_t l;
- auto char name[260];
- (void)snprintf (name, 256, "%s/Mail/NewLog", getenv ("HOME"));
- l = strlen (name);
- if (l > 255 || !(LogName = (char *)malloc (l + 1))) {
- *error = g_strdup (_("Cannot load plugin NewMail\n"
+ if (!NewLog) {
+ auto char *mode = truncLog ? "w" : "a";
+ if (!LogName) {
+ auto size_t l;
+ auto char name[260];
+ (void)snprintf (name, 256, "%s/Mail/NewLog", getenv ("HOME"));
+ l = strlen (name);
+ if (l > 255 || !(LogName = (char *)malloc (l + 1))) {
+ *error = g_strdup (_("Cannot load plugin NewMail\n"
"$HOME is too long\n"));
- plugin_done ();
- return (-1);
+ plugin_done ();
+ return (-1);
+ }
+ (void)strcpy (LogName, name);
+ }
+ if (!(NewLog = fopen (LogName, mode))) {
+ *error = g_strdup (sys_errlist[errno]);
+ plugin_done ();
+ return (-1);
}
- (void)strcpy (LogName, name);
- }
- if (!(NewLog = fopen (LogName, mode))) {
- *error = g_strdup (sys_errlist[errno]);
- plugin_done ();
- return (-1);
- }
- setbuf (NewLog, NULL);
+ setbuf (NewLog, NULL);
}
- debug_print ("Newmail plugin loaded\n"
+ debug_print ("Newmail plugin loaded\n"
"Message header summaries written to %s\n", LogName);
- return (0);
- } /* plugin_init */
+ return (0);
+} /* plugin_init */
const gchar *plugin_name (void)
{
return _("NewMail");
- } /* plugin_name */
+} /* plugin_name */
const gchar *plugin_desc (void)
{
return _("This Plugin writes a header summary to a log file for each "
"mail received after sorting.\n\n"
"Default is ~/Mail/NewLog");
- } /* plugin_desc */
+} /* plugin_desc */
const gchar *plugin_type (void)
{
return ("Common");
- } /* plugin_type */
+} /* plugin_type */
const gchar *plugin_licence (void)
{
return ("GPL3+");
- } /* plugin_licence */
+} /* plugin_licence */
const gchar *plugin_version (void)
{
return (VERSION);
- } /* plugin_version */
+} /* plugin_version */
struct PluginFeature *plugin_provides(void)
{
commit a700fea56f5835856150bbd19b6936d1fc019638
Author: Ricardo Mones <ricardo at mones.org>
Date: Thu Apr 4 00:51:04 2013 +0200
Use debug_print for debug info
diff --git a/src/plugins/newmail/newmail.c b/src/plugins/newmail/newmail.c
index 8d7c40e..92ec0c2 100644
--- a/src/plugins/newmail/newmail.c
+++ b/src/plugins/newmail/newmail.c
@@ -88,7 +88,7 @@ gboolean plugin_done (void)
}
hooks_unregister_hook (MAIL_POSTFILTERING_HOOKLIST, hook_id);
- printf (_("Newmail plugin unloaded\n"));
+ debug_print ("Newmail plugin unloaded\n");
return TRUE;
} /* plugin_done */
@@ -127,8 +127,8 @@ gint plugin_init (gchar **error)
setbuf (NewLog, NULL);
}
- printf (_("Newmail plugin loaded\n"
- "Message header summaries written to %s\n"), LogName);
+ debug_print ("Newmail plugin loaded\n"
+ "Message header summaries written to %s\n", LogName);
return (0);
} /* plugin_init */
-----------------------------------------------------------------------
Summary of changes:
src/plugins/newmail/newmail.c | 157 ++++++++++++++++++++++-------------------
1 files changed, 85 insertions(+), 72 deletions(-)
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list