From e3cfca7568c0481e30807a41a280752522af2838 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Fri, 21 Aug 2020 11:12:39 +0200 Subject: Update use of note file for import Removes the parts of commit 'Extend use of note file for ical import' that relate to STATUS. The STATUS property is (partly) supported for todos already. Corrects insertion of a separator: always insert it before imported properties (also when there is no description). Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/ical.c | 70 ++++++------------------------------------------- test/data/ical-005.ical | 2 +- test/data/ical-009.ical | 6 ----- test/data/ical-012.ical | 26 ++++++++---------- test/ical-005.sh | 3 ++- test/ical-007.sh | 1 + test/ical-009.sh | 25 +++++++++--------- test/ical-012.sh | 19 ++++---------- 8 files changed, 40 insertions(+), 112 deletions(-) diff --git a/src/ical.c b/src/ical.c index 2946412..806ba30 100644 --- a/src/ical.c +++ b/src/ical.c @@ -59,8 +59,7 @@ typedef enum { SUMMARY, DESCRIPTION, LOCATION, - COMMENT, - STATUS + COMMENT } ical_property_e; typedef struct { @@ -1194,9 +1193,6 @@ static char *ical_read_note(char *line, ical_property_e property, unsigned *nosk case COMMENT: pname = "comment"; break; - case STATUS: - pname = "status"; - break; default: pname = "no property"; @@ -1270,7 +1266,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, struct { llist_t exc; ical_rpt_t *rpt; - char *mesg, *desc, *loc, *comm, *stat, *imp, *note; + char *mesg, *desc, *loc, *comm, *imp, *note; time_t start, end; long dur; int has_alarm; @@ -1339,9 +1335,9 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, if (vevent.desc) { string_catf(&s, "%s", vevent.desc); mem_free(vevent.desc); - if (separator) - string_catf(&s, SEPARATOR); } + if (separator) + string_catf(&s, SEPARATOR); if (vevent.loc) { string_catf(&s, _("Location: %s"), vevent.loc); @@ -1352,11 +1348,6 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, vevent.comm); mem_free(vevent.comm); } - if (vevent.stat) { - string_catf(&s, _("Status: %s"), - vevent.stat); - mem_free(vevent.stat); - } if (vevent.imp) { string_catf(&s, ("Import: %s\n"), vevent.imp); @@ -1369,7 +1360,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, * creation fails below. */ vevent.desc = vevent.loc = vevent.comm = - vevent.stat = vevent.imp = NULL; + vevent.imp = NULL; } char *msg = _("rrule does not match start day (%s)."); switch (vevent_type) { @@ -1529,8 +1520,6 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, property = LOCATION; } else if (starts_with_ci(buf, "COMMENT")) { property = COMMENT; - } else if (starts_with_ci(buf, "STATUS")) { - property = STATUS; } if (property) { note = ical_read_note(buf, property, noskipped, @@ -1568,21 +1557,6 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, } else vevent.comm = note; break; - case STATUS: - if (vevent.stat) { - ical_log(log, ICAL_VEVENT, ITEMLINE, - _("only one status allowed.")); - goto skip; - } - if (!(starts_with(note, "TENTATIVE") || - starts_with(note, "CONFIRMED") || - starts_with(note, "CANCELLED"))) { - ical_log(log, ICAL_VEVENT, ITEMLINE, - _("invalid status value.")); - goto skip; - } - vevent.stat = note; - break; default: break; } @@ -1601,8 +1575,6 @@ cleanup: mem_free(vevent.loc); if (vevent.comm) mem_free(vevent.comm); - if (vevent.stat) - mem_free(vevent.stat); if (vevent.imp) mem_free(vevent.imp); if (vevent.mesg) @@ -1622,7 +1594,7 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped, const char *SEPARATOR = "-- \n"; struct string s; struct { - char *mesg, *desc, *loc, *comm, *stat, *note; + char *mesg, *desc, *loc, *comm, *note; int priority; int completed; } vtodo; @@ -1654,9 +1626,9 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped, if (vtodo.desc) { string_catf(&s, "%s", vtodo.desc); mem_free(vtodo.desc); - if (separator) - string_catf(&s, SEPARATOR); } + if (separator) + string_catf(&s, SEPARATOR); if (vtodo.loc) { string_catf(&s, _("Location: %s"), vtodo.loc); @@ -1667,11 +1639,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped, vtodo.comm); mem_free(vtodo.comm); } - if (vtodo.stat) { - string_catf(&s, _("Status: %s"), - vtodo.stat); - mem_free(vtodo.stat); - } vtodo.note = generate_note(string_buf(&s)); mem_free(s.buf); } @@ -1690,7 +1657,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped, } } else if (starts_with_ci(buf, "STATUS:COMPLETED")) { vtodo.completed = 1; - property = STATUS; } else if (starts_with_ci(buf, "SUMMARY")) { vtodo.mesg = ical_read_summary(buf, noskipped, ICAL_VTODO, @@ -1705,8 +1671,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped, property = LOCATION; } else if (starts_with_ci(buf, "COMMENT")) { property = COMMENT; - } else if (starts_with_ci(buf, "STATUS")) { - property = STATUS; } if (property) { note = ical_read_note(buf, property, noskipped, @@ -1744,22 +1708,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped, } else vtodo.comm = note; break; - case STATUS: - if (vtodo.stat) { - ical_log(log, ICAL_VTODO, ITEMLINE, - _("only one status allowed.")); - goto skip; - } - if (!(starts_with(note, "NEEDS-ACTION") || - starts_with(note, "COMPLETED") || - starts_with(note, "IN-PROCESS") || - starts_with(note, "CANCELLED"))) { - ical_log(log, ICAL_VTODO, ITEMLINE, - _("invalid status value.")); - goto skip; - } - vtodo.stat = note; - break; default: break; } @@ -1778,8 +1726,6 @@ cleanup: mem_free(vtodo.loc); if (vtodo.comm) mem_free(vtodo.comm); - if (vtodo.stat) - mem_free(vtodo.stat); if (vtodo.mesg) mem_free(vtodo.mesg); } diff --git a/test/data/ical-005.ical b/test/data/ical-005.ical index 5f20f48..e417779 100644 --- a/test/data/ical-005.ical +++ b/test/data/ical-005.ical @@ -18,6 +18,6 @@ TRANSP:TRANSPARENT END:VEVENT BEGIN:VEVENT SUMMARY:On day 2 -DTSTART;VALUE=DATE:20131003 +DTSTART;VALUE=DATE:20131004 END:VEVENT END:VCALENDAR diff --git a/test/data/ical-009.ical b/test/data/ical-009.ical index b5a6575..3495223 100644 --- a/test/data/ical-009.ical +++ b/test/data/ical-009.ical @@ -66,12 +66,6 @@ END:VTODO BEGIN:VEVENT DTSTART:20200406T221300 DURATION:PT0H15M0S -SUMMARY:Invalid STATUS -STATUS:confirmed -END:VEVENT -BEGIN:VEVENT -DTSTART:20200406T221300 -DURATION:PT0H15M0S SUMMARY:LOCATION twice LOCATION:first LOCATION:second diff --git a/test/data/ical-012.ical b/test/data/ical-012.ical index 09385fb..05604af 100644 --- a/test/data/ical-012.ical +++ b/test/data/ical-012.ical @@ -19,9 +19,8 @@ END:VEVENT BEGIN:VEVENT DTSTART:20200404T084100 DURATION:PT1H30M0S -SUMMARY:No description. Comment and status +SUMMARY:no description\, but comment COMMENT:Event without description: a comment\nstreching over\nthree lines -STATUS:CONFIRMED END:VEVENT BEGIN:VEVENT @@ -42,11 +41,10 @@ END:VEVENT BEGIN:VEVENT DTSTART:20200404T204500 DURATION:PT1H30M0S -SUMMARY:description\, status\, comment and location -DESCRIPTION:event with\ndescription\nstatus\ncomment\nand location +SUMMARY:description\, comment and location +DESCRIPTION:event with\ndescription\ncomment\nand location LOCATION: Right here -COMMENT:just a repetition of description:\nevent with\ndescription\nstatus\ncomment\nand location -STATUS:CANCELLED +COMMENT:just a repetition of description:\nevent with\ndescription\ncomment\nand location END:VEVENT BEGIN:VTODO @@ -64,9 +62,8 @@ END:VTODO BEGIN:VTODO PRIORITY:4 -SUMMARY:Comment and status -COMMENT:Todo with out description. A comment\nstreching over\nthree lines -STATUS:NEEDS-ACTION +SUMMARY:no description\, but comment +COMMENT:Todo without description. A comment\nstreching over\nthree lines END:VTODO BEGIN:VTODO @@ -77,17 +74,16 @@ END:VTODO BEGIN:VTODO PRIORITY:6 -SUMMARY:Empty description\,but status +SUMMARY:Empty description DESCRIPTION: -STATUS:COMPLETED END:VTODO BEGIN:VTODO -SUMMARY:todo with description\, status\, comment and location -DESCRIPTION:todo with\ndescription\nstatus\ncomment\nand location\,\nbut no priority +SUMMARY:todo with description\, comment and location +DESCRIPTION:todo with\ndescription\ncomment\nand location\,\nbut no priority LOCATION: Right here -COMMENT:mostly a repetition of description:\ntodo with\ndescription\nstatus\ncomment\nand location -STATUS:IN-PROCESS +COMMENT:mostly a repetition of description:\ntodo with\ndescription\ncomment\nand location +STATUS:COMPLETED END:VTODO END:VCALENDAR diff --git a/test/ical-005.sh b/test/ical-005.sh index a73b90f..5d38301 100755 --- a/test/ical-005.sh +++ b/test/ical-005.sh @@ -16,11 +16,12 @@ Import process report: 0023 lines read 10/03/13: * All day * On day 1 - * On day 2 * Two days 10/04/13: + * On day 2 * Two days +-- Import: multi-day event changed to one-day event EOD else diff --git a/test/ical-007.sh b/test/ical-007.sh index da5002c..59b7bf8 100755 --- a/test/ical-007.sh +++ b/test/ical-007.sh @@ -21,6 +21,7 @@ Import process report: 0018 lines read UTC - 11:00 -> 12:00 Local time +-- Import: TZID=CET EOD else diff --git a/test/ical-009.sh b/test/ical-009.sh index f397044..9015323 100755 --- a/test/ical-009.sh +++ b/test/ical-009.sh @@ -17,8 +17,8 @@ if [ "$1" = 'actual' ]; then rm -rf .calcurse || exit 1 elif [ "$1" = 'expected' ]; then cat <