diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-21 12:53:43 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-21 12:53:43 +0200 |
commit | 12fd740c530106f4a74c5ff2c6ce6d0ea305ab70 (patch) | |
tree | 6064e3770a3fa4210443cfc9f8cd390b932aee94 /src | |
parent | 62758ace16e756050f15b81e66ee5ab3bdd062ab (diff) | |
download | wydawca-12fd740c530106f4a74c5ff2c6ce6d0ea305ab70.tar.gz wydawca-12fd740c530106f4a74c5ff2c6ce6d0ea305ab70.tar.bz2 |
Implement per-directory notifications
* src/config.c (default_notification): New static.
(cb_notify_event): Explicitly link new notification to the chain.
(directory_kw): New keyword "notify-event".
(cb_directory): Use previously defined global notifications.
* src/mail.c (register_notification): Remove.
(notify): Tak a list of notifications to run as an argument.
* src/directive.c, src/gpg.c, src/verify.c: Update calls to notify.
* src/wydawca.h (struct directory_pair.notification): New member.
* tests/notify-upl.at: Define notifications before the directory pair in
the configuration file.
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 20 | ||||
-rw-r--r-- | src/directive.c | 2 | ||||
-rw-r--r-- | src/gpg.c | 4 | ||||
-rw-r--r-- | src/mail.c | 17 | ||||
-rw-r--r-- | src/verify.c | 2 | ||||
-rw-r--r-- | src/wydawca.h | 5 |
6 files changed, 25 insertions, 25 deletions
diff --git a/src/config.c b/src/config.c index d2b0154..61cf324 100644 --- a/src/config.c +++ b/src/config.c @@ -27,6 +27,7 @@ static struct archive_descr default_archive_descr = { }; static struct access_method *default_access_method[access_method_count]; +static struct notification *default_notification = NULL; /* safe_file_name: convert a file name possibly containig relative @@ -896,9 +897,12 @@ cb_notify_event (enum gconf_callback_command cmd, if (!ntf->msg) gconf_error (locus, 0, _("missing message definition")); else - /* FIXME: check ev and tgt? */ - register_notification (ntf); - free (ntf); + { + struct notification **p = (struct notification **) varptr; + ntf->next = *p; + *p = ntf; + /* FIXME: check ev and tgt? */ + } break; case gconf_callback_set_value: @@ -1101,6 +1105,10 @@ static struct gconf_keyword directory_kw[] = { { "archive", N_("type: string"), N_("Set up archivation"), gconf_type_section, NULL, offsetof(struct directory_pair, archive), cb_archive, NULL, archive_kw }, + { "notify-event", NULL, N_("Configure notification"), + gconf_type_section, NULL, offsetof(struct directory_pair, notification), + cb_notify_event, NULL, notify_event_kw }, + { NULL } }; @@ -1164,6 +1172,9 @@ cb_directory (enum gconf_callback_command cmd, gconf_error (locus, 0, _("Sorry, method type `external' is not yet supported")); } + + if (!dpair->notification) + dpair->notification = default_notification; register_directory_pair (dpair); free (dpair); @@ -1219,7 +1230,8 @@ static struct gconf_keyword wydawca_kw[] = { gconf_type_section, NULL, 0, NULL, NULL, mail_statistics_kw }, { "notify-event", NULL, N_("Configure notification"), - gconf_type_section, NULL, 0, cb_notify_event, NULL, notify_event_kw }, + gconf_type_section, &default_notification, 0, + cb_notify_event, NULL, notify_event_kw }, { "access-method", N_("ident"), N_("Define access method"), gconf_type_section, default_access_method, 0, diff --git a/src/directive.c b/src/directive.c index ed28cc5..8f18f60 100644 --- a/src/directive.c +++ b/src/directive.c @@ -400,6 +400,6 @@ process_directives (struct file_triplet *trp, struct directory_pair *dpair) free (relative_dir); UPDATE_STATS (STAT_TRIPLET_SUCCESS); - notify (trp, ev_success); + notify (dpair->notification, trp, ev_success); return 0; } @@ -237,7 +237,7 @@ verify_directive_signature (struct file_triplet *trp, if (!gpg_sig_ok_p (ctx, result->signatures)) { UPDATE_STATS (STAT_BAD_SIGNATURE); - notify (trp, ev_bad_directive_signature); + notify (dpair->notification, trp, ev_bad_directive_signature); rc = 1; } } @@ -293,7 +293,7 @@ verify_detached_signature (struct file_triplet *trp, case exec_fail: UPDATE_STATS (STAT_BAD_SIGNATURE); logmsg (LOG_ERR, "BAD detached signature for %s", trp->name); - notify (trp, ev_bad_detached_signature); + notify (dpair->notification, trp, ev_bad_detached_signature); break; case exec_error: @@ -198,20 +198,6 @@ resolve_message_template (const char *name) return name; } - -static struct notification *notification_list; - -void -register_notification (const struct notification *notif) -{ - struct notification *newp = xmalloc (sizeof *newp); - newp->ev = notif->ev; - newp->tgt = notif->tgt; - newp->msg = notif->msg; - newp->next = notification_list; - notification_list = newp; -} - void mail_stats () @@ -394,7 +380,8 @@ do_notify (struct file_triplet *trp, enum notification_event ev, } void -notify (struct file_triplet *trp, enum notification_event ev) +notify (struct notification *notification_list, + struct file_triplet *trp, enum notification_event ev) { struct notification *p; diff --git a/src/verify.c b/src/verify.c index 2839f25..d8fc408 100644 --- a/src/verify.c +++ b/src/verify.c @@ -135,7 +135,7 @@ check_access_rights (struct file_triplet *trp, struct directory_pair *dpair, UPDATE_STATS (STAT_ACCESS_VIOLATIONS); logmsg (LOG_ERR, "%s: %s has no rights on %s", trp->name, user, trp->project); - notify (trp, ev_bad_ownership); + notify (dpair->notification, trp, ev_bad_ownership); return 1; } diff --git a/src/wydawca.h b/src/wydawca.h index 152d914..893e334 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -134,6 +134,7 @@ struct directory_pair after this amount of time */ struct access_method *access_method[access_method_count]; struct archive_descr archive; /* Archivation data */ + struct notification *notification; }; @@ -225,10 +226,10 @@ struct notification const char *msg; }; -void register_notification (const struct notification *notif); void register_message_template (const char *name, const char *text); -void notify (struct file_triplet *, enum notification_event); +void notify (struct notification *, + struct file_triplet *, enum notification_event); const char *notification_event_str (enum notification_event evt); const char *notification_target_str (enum notification_target tgt); |