From ce81c0fa6362f0092f40eab1cddf0a6339c473c5 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Tue, 4 Jun 2019 09:34:45 +0200 Subject: Refactor function calls: recurrence parameters as a single argument The recurrence parameters are type, frequency, until date and exception list (in RFC 5545 parlance FREQ, INTERVAL, UNTIL and EXDATE's). When these are passed in a function call, the argument list becomes long and not very readable. When support for extended recurrence rules is implemented, the number of recurrence parameters increases, and function signatures must be amended. Solution: The "struct rpt" is extended with the exception list; any future recurrence parameters are added here. A pointer to this structure replaces the recurrence parameters in function calls. Note: Each recurrent event and appoinment instance has (a pointer to) a "struct rpt" and in addition an exception list. The latter is retained to avoid the derived changes, and the exception list in the structure is initialized to an empty list when the recurrent instance is created. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/ui-day.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/ui-day.c') diff --git a/src/ui-day.c b/src/ui-day.c index 7d571fc..cb038d1 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -975,16 +975,20 @@ void ui_day_item_repeat(void) /* Set the selected APP item. */ struct day_item d = empty_day; + struct rpt rpt; + rpt.type = type; + rpt.freq = freq; + rpt.until = until; + LLIST_INIT(&rpt.exc); if (p->type == EVNT) { struct event *ev = p->item.ev; d.item.rev = recur_event_new(ev->mesg, ev->note, ev->day, - ev->id, type, freq, until, NULL); + ev->id, &rpt); } else if (p->type == APPT) { struct apoint *apt = p->item.apt; d.item.rapt = ra = recur_apoint_new(apt->mesg, apt->note, apt->start, apt->dur, - apt->state, type, freq, - until, NULL); + apt->state, &rpt); if (notify_bar()) notify_check_repeated(ra); } else { -- cgit v1.2.3