summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2020-08-21 11:12:39 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2020-08-26 07:52:08 -0400
commite3cfca7568c0481e30807a41a280752522af2838 (patch)
tree14f63cfef1477f89001e0bbe1eaba62846216a34
parent7b28e38d1307aa6c7bf4350b314dff1dc42b9731 (diff)
downloadcalcurse-e3cfca7568c0481e30807a41a280752522af2838.tar.gz
calcurse-e3cfca7568c0481e30807a41a280752522af2838.zip
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 <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/ical.c70
-rw-r--r--test/data/ical-005.ical2
-rw-r--r--test/data/ical-009.ical6
-rw-r--r--test/data/ical-012.ical26
-rwxr-xr-xtest/ical-005.sh3
-rwxr-xr-xtest/ical-007.sh1
-rwxr-xr-xtest/ical-009.sh25
-rwxr-xr-xtest/ical-012.sh19
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 <<EOD
-Import process report: 0127 lines read
-2 apps / 0 events / 1 todo / 20 skipped
+Import process report: 0121 lines read
+2 apps / 0 events / 1 todo / 19 skipped
VEVENT [12]: invalid or malformed event start time.
VEVENT [17]: rrule frequency not supported.
VEVENT [23]: malformed summary line.
@@ -28,17 +28,16 @@ VEVENT [39]: line break in summary.
VEVENT [44]: malformed description line.
VEVENT [50]: malformed description.
VTODO [62]: malformed summary.
-VEVENT [66]: invalid status value.
-VEVENT [72]: only one location allowed.
-VEVENT [79]: invalid duration.
-VEVENT [84]: invalid or malformed event start time.
-VEVENT [89]: invalid end time value type.
-VEVENT [94]: invalid until format.
-VEVENT [100]: invalid exception date value type.
-VEVENT [107]: invalid exception.
-VEVENT [114]: either end or duration.
-VEVENT [120]: end must be later than start.
-VTODO [125]: The ical file seems to be malformed. The end of item was not found.
+VEVENT [66]: only one location allowed.
+VEVENT [73]: invalid duration.
+VEVENT [78]: invalid or malformed event start time.
+VEVENT [83]: invalid end time value type.
+VEVENT [88]: invalid until format.
+VEVENT [94]: invalid exception date value type.
+VEVENT [101]: invalid exception.
+VEVENT [108]: either end or duration.
+VEVENT [114]: end must be later than start.
+VTODO [119]: The ical file seems to be malformed. The end of item was not found.
101
EOD
else
diff --git a/test/ical-012.sh b/test/ical-012.sh
index 9175db9..f4b27df 100755
--- a/test/ical-012.sh
+++ b/test/ical-012.sh
@@ -14,11 +14,10 @@ if [ "$1" = 'actual' ]; then
rm -rf .calcurse || exit 1
elif [ "$1" = 'expected' ]; then
cat <<EOD
-Import process report: 0093 lines read
+Import process report: 0089 lines read
6 apps / 0 events / 6 todos / 0 skipped
todo with
description
-status
comment
and location,
but no priority
@@ -27,13 +26,10 @@ Location: Right here
Comment: mostly a repetition of description:
todo with
description
- status
comment
and location
-Status: IN-PROCESS
event with
description
-status
comment
and location
--
@@ -41,18 +37,16 @@ Location: Right here
Comment: just a repetition of description:
event with
description
- status
comment
and location
-Status: CANCELLED
-Comment: Todo with out description. A comment
+--
+Comment: Event without description: a comment
streching over
three lines
-Status: NEEDS-ACTION
-Comment: Event without description: a comment
+--
+Comment: Todo without description. A comment
streching over
three lines
-Status: CONFIRMED
event with description
and location
--
@@ -67,9 +61,6 @@ Comment: event with empty description
event with one-line description
todo with one-line description
---
-Status: COMPLETED
-
EOD
else
./run-test "$0"