summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2010-01-02 20:37:49 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2010-01-02 20:38:13 (GMT)
commite113d685f81852992a08b5dabab93dd97f0fee59 (patch) (side-by-side diff)
tree7bf55540c9aa51f80e8f0c38d33a8b2a6da25d42
parentc44f0f83448b426935e9aeb07c5d761299144d14 (diff)
downloadwydawca-e113d685f81852992a08b5dabab93dd97f0fee59.tar.gz
wydawca-e113d685f81852992a08b5dabab93dd97f0fee59.tar.bz2
New email-related meta-variables.
These variables make it possible to avoid setting `recipient' statement in `notify' blocks, instead specifying recipients directly in the message headers and using the default recipient setting, which is `read'. * src/mail.c (expand_email_admin) (expand_email_owner): New functions. * src/triplet.c (triplet_processor): Remove the triplet if process_directives returns !0. (expand_email_user): New function. (triplet_meta): New keywords email:user (not to be confused with user:email), email:admin and email:owner. * src/wydawca.h (expand_email_admin) (expand_email_owner): New functions. * NEWS, doc/wydawca.texi: Updated.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--NEWS17
-rw-r--r--doc/wydawca.texi11
-rw-r--r--src/mail.c45
-rw-r--r--src/triplet.c19
-rw-r--r--src/wydawca.h3
5 files changed, 94 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index bbceb00..588a3d2 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,23 @@ The new keyword `check-script' defines a shell script to
verify the submitted tarball. See the documentation, section
4.12 "Distribution Verification", for details.
+* New meta-variables
+
+ email:admin Full email address of the systems administrator.
+ email:owner Full email address of the project administrator.
+ email:user Full email address of the user who did the upload.
+
+Note: `email:user' is not to be confused with `user:email'. The latter
+is expanded to email address only, while the former yields full email
+address, i.e. an address with a personal part, e.g.:
+
+ "Ty Coon" <ty@coon.org>
+
+* New meta-construct
+
+The special construct $-, when used in message texts, causes removal
+of the character following it. Its intended use is primarily to
+remove the following newline character (like dnl in m4).
Version 2.0, 2009-12-22
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index e9e63be..581004b 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -2599,6 +2599,17 @@ $@{triplet:ls:dir@}
@item user:real-name @tab Real name of the user who uploaded the triplet.
@kwindex user:email
@item user:email @tab Email of the user who uploaded the triplet.
+@kwindex email:admin
+@item email:admin @tab Full@footnote{@dfn{Full} here means
+an email address with eventual personal part}. email address of the systems
+administrator, as set by the @samp{admin-address}
+(@pxref{notification,,admin-address}).
+@kwindex email:owner
+@item email:owner @tab Full email address of the project
+administrator (@dfn{owner}).
+@kwindex email:user
+@item email:user @tab Full email address of the user who did
+the upload. Not to be confused with @samp{user:email}.
@kwindex check:result
@item check:result @tab Code returned by external checker, in
decimal. @xref{verification,,check:result}, for a detailed description.
diff --git a/src/mail.c b/src/mail.c
index 3328850..39dfe08 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -685,3 +685,48 @@ notify (struct notification *notification_list,
do_notify (trp, ev, p);
/* FIXME */
}
+
+const char *
+expand_email_admin (struct metadef *def, void *data)
+{
+ size_t size;
+ if (mu_address_to_string (admin_address, NULL, 0, &size) == 0)
+ {
+ size++;
+ def->storage = xmalloc (size);
+ mu_address_to_string (admin_address, def->storage, size, NULL);
+ def->value = def->storage;
+ }
+ else
+ def->value = "";
+ return def->value;
+}
+
+const char *
+expand_email_owner (struct metadef *def, void *data)
+{
+ struct file_triplet *trp = data;
+ mu_address_t addr;
+ const char *errp;
+ size_t size;
+
+ addr = get_recipient (trp->spool->dictionary[project_owner_dict],
+ trp, &errp);
+ if (!addr)
+ {
+ logmsg (LOG_ERR, _("cannot get email of the %s's owner: %s"),
+ trp->project, gettext (errp));
+ def->value = "";
+ }
+ else if (mu_address_to_string (addr, NULL, 0, &size) == 0)
+ {
+ size++;
+ def->storage = xmalloc (size);
+ mu_address_to_string (addr, def->storage, size, NULL);
+ def->value = def->storage;
+ mu_address_destroy (&addr);
+ }
+ else
+ def->value = "";
+ return def->value;
+}
diff --git a/src/triplet.c b/src/triplet.c
index 7f6ac68..0744daa 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -193,7 +193,8 @@ triplet_processor (void *data, void *proc_data)
case triplet_complete:
if (debug_level)
logmsg (LOG_DEBUG, _("processing triplet `%s'"), trp->name);
- process_directives (trp, spool);
+ if (process_directives (trp, spool))
+ remove_triplet (trp);
return true;
case triplet_incomplete:
@@ -515,6 +516,19 @@ expand_user_email (struct metadef *def, void *data)
}
static const char *
+expand_email_user (struct metadef *def, void *data)
+{
+ struct file_triplet *trp = data;
+ if (trp->uploader)
+ {
+ asprintf (&def->storage, "\"%s\" <%s>",
+ trp->uploader->realname, trp->uploader->email);
+ def->value = def->storage;
+ }
+ return def->value;
+}
+
+static const char *
expand_report (struct metadef *def, void *data)
{
return report_string;
@@ -626,6 +640,9 @@ struct metadef triplet_meta[] = {
{ "user:name", NULL, expand_user_name, NULL },
{ "user:real-name", NULL, expand_user_real_name, NULL },
{ "user:email", NULL, expand_user_email, NULL },
+ { "email:user", NULL, expand_email_user, NULL },
+ { "email:admin", NULL, expand_email_admin, NULL },
+ { "email:owner", NULL, expand_email_owner, NULL },
{ "report", NULL, expand_report, NULL },
{ "comment", NULL, expand_comment, NULL },
DECL_FULL_TIMER(wydawca),
diff --git a/src/wydawca.h b/src/wydawca.h
index af24e47..54ecf00 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -312,6 +312,9 @@ char *meta_expand_string (const char *string, struct metadef *def, void *data,
struct dictionary *dict, void *handle);
void meta_free (struct metadef *def);
+const char *expand_email_admin (struct metadef *def, void *data);
+const char *expand_email_owner (struct metadef *def, void *data);
+
/* Global variables */
extern uid_t wydawca_uid;

Return to:

Send suggestions and report system problems to the System administrator.