diff options
-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 | ||||
-rw-r--r-- | tests/notify-upl.at | 3 |
7 files changed, 27 insertions, 26 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); diff --git a/tests/notify-upl.at b/tests/notify-upl.at index 06c26c8..ca57846 100644 --- a/tests/notify-upl.at +++ b/tests/notify-upl.at @@ -76,7 +76,8 @@ s,^-[[rwx-]]\{9\} @USER@.*file.sig$,listing of file.sig, AT_CHECK([ wydawca_init_testdirs wydawca_config wydawca.rc -cat $WD_CONFSRC/notify.rc >> wydawca.rc +mv wydawca.rc simple.rc +cat $WD_CONFSRC/notify.rc simple.rc > wydawca.rc wydawca_upload file file.directive.asc file.sig wydawca_expandmeta errtmpl experr |