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>
This commit is contained in:
parent
7b28e38d13
commit
e3cfca7568
66
src/ical.c
66
src/ical.c
@ -59,8 +59,7 @@ typedef enum {
|
|||||||
SUMMARY,
|
SUMMARY,
|
||||||
DESCRIPTION,
|
DESCRIPTION,
|
||||||
LOCATION,
|
LOCATION,
|
||||||
COMMENT,
|
COMMENT
|
||||||
STATUS
|
|
||||||
} ical_property_e;
|
} ical_property_e;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -1194,9 +1193,6 @@ static char *ical_read_note(char *line, ical_property_e property, unsigned *nosk
|
|||||||
case COMMENT:
|
case COMMENT:
|
||||||
pname = "comment";
|
pname = "comment";
|
||||||
break;
|
break;
|
||||||
case STATUS:
|
|
||||||
pname = "status";
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
pname = "no property";
|
pname = "no property";
|
||||||
|
|
||||||
@ -1270,7 +1266,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
|||||||
struct {
|
struct {
|
||||||
llist_t exc;
|
llist_t exc;
|
||||||
ical_rpt_t *rpt;
|
ical_rpt_t *rpt;
|
||||||
char *mesg, *desc, *loc, *comm, *stat, *imp, *note;
|
char *mesg, *desc, *loc, *comm, *imp, *note;
|
||||||
time_t start, end;
|
time_t start, end;
|
||||||
long dur;
|
long dur;
|
||||||
int has_alarm;
|
int has_alarm;
|
||||||
@ -1339,9 +1335,9 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
|||||||
if (vevent.desc) {
|
if (vevent.desc) {
|
||||||
string_catf(&s, "%s", vevent.desc);
|
string_catf(&s, "%s", vevent.desc);
|
||||||
mem_free(vevent.desc);
|
mem_free(vevent.desc);
|
||||||
|
}
|
||||||
if (separator)
|
if (separator)
|
||||||
string_catf(&s, SEPARATOR);
|
string_catf(&s, SEPARATOR);
|
||||||
}
|
|
||||||
if (vevent.loc) {
|
if (vevent.loc) {
|
||||||
string_catf(&s, _("Location: %s"),
|
string_catf(&s, _("Location: %s"),
|
||||||
vevent.loc);
|
vevent.loc);
|
||||||
@ -1352,11 +1348,6 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
|||||||
vevent.comm);
|
vevent.comm);
|
||||||
mem_free(vevent.comm);
|
mem_free(vevent.comm);
|
||||||
}
|
}
|
||||||
if (vevent.stat) {
|
|
||||||
string_catf(&s, _("Status: %s"),
|
|
||||||
vevent.stat);
|
|
||||||
mem_free(vevent.stat);
|
|
||||||
}
|
|
||||||
if (vevent.imp) {
|
if (vevent.imp) {
|
||||||
string_catf(&s, ("Import: %s\n"),
|
string_catf(&s, ("Import: %s\n"),
|
||||||
vevent.imp);
|
vevent.imp);
|
||||||
@ -1369,7 +1360,7 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
|||||||
* creation fails below.
|
* creation fails below.
|
||||||
*/
|
*/
|
||||||
vevent.desc = vevent.loc = vevent.comm =
|
vevent.desc = vevent.loc = vevent.comm =
|
||||||
vevent.stat = vevent.imp = NULL;
|
vevent.imp = NULL;
|
||||||
}
|
}
|
||||||
char *msg = _("rrule does not match start day (%s).");
|
char *msg = _("rrule does not match start day (%s).");
|
||||||
switch (vevent_type) {
|
switch (vevent_type) {
|
||||||
@ -1529,8 +1520,6 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
|||||||
property = LOCATION;
|
property = LOCATION;
|
||||||
} else if (starts_with_ci(buf, "COMMENT")) {
|
} else if (starts_with_ci(buf, "COMMENT")) {
|
||||||
property = COMMENT;
|
property = COMMENT;
|
||||||
} else if (starts_with_ci(buf, "STATUS")) {
|
|
||||||
property = STATUS;
|
|
||||||
}
|
}
|
||||||
if (property) {
|
if (property) {
|
||||||
note = ical_read_note(buf, property, noskipped,
|
note = ical_read_note(buf, property, noskipped,
|
||||||
@ -1568,21 +1557,6 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
|||||||
} else
|
} else
|
||||||
vevent.comm = note;
|
vevent.comm = note;
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1601,8 +1575,6 @@ cleanup:
|
|||||||
mem_free(vevent.loc);
|
mem_free(vevent.loc);
|
||||||
if (vevent.comm)
|
if (vevent.comm)
|
||||||
mem_free(vevent.comm);
|
mem_free(vevent.comm);
|
||||||
if (vevent.stat)
|
|
||||||
mem_free(vevent.stat);
|
|
||||||
if (vevent.imp)
|
if (vevent.imp)
|
||||||
mem_free(vevent.imp);
|
mem_free(vevent.imp);
|
||||||
if (vevent.mesg)
|
if (vevent.mesg)
|
||||||
@ -1622,7 +1594,7 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
|||||||
const char *SEPARATOR = "-- \n";
|
const char *SEPARATOR = "-- \n";
|
||||||
struct string s;
|
struct string s;
|
||||||
struct {
|
struct {
|
||||||
char *mesg, *desc, *loc, *comm, *stat, *note;
|
char *mesg, *desc, *loc, *comm, *note;
|
||||||
int priority;
|
int priority;
|
||||||
int completed;
|
int completed;
|
||||||
} vtodo;
|
} vtodo;
|
||||||
@ -1654,9 +1626,9 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
|||||||
if (vtodo.desc) {
|
if (vtodo.desc) {
|
||||||
string_catf(&s, "%s", vtodo.desc);
|
string_catf(&s, "%s", vtodo.desc);
|
||||||
mem_free(vtodo.desc);
|
mem_free(vtodo.desc);
|
||||||
|
}
|
||||||
if (separator)
|
if (separator)
|
||||||
string_catf(&s, SEPARATOR);
|
string_catf(&s, SEPARATOR);
|
||||||
}
|
|
||||||
if (vtodo.loc) {
|
if (vtodo.loc) {
|
||||||
string_catf(&s, _("Location: %s"),
|
string_catf(&s, _("Location: %s"),
|
||||||
vtodo.loc);
|
vtodo.loc);
|
||||||
@ -1667,11 +1639,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
|||||||
vtodo.comm);
|
vtodo.comm);
|
||||||
mem_free(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));
|
vtodo.note = generate_note(string_buf(&s));
|
||||||
mem_free(s.buf);
|
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")) {
|
} else if (starts_with_ci(buf, "STATUS:COMPLETED")) {
|
||||||
vtodo.completed = 1;
|
vtodo.completed = 1;
|
||||||
property = STATUS;
|
|
||||||
} else if (starts_with_ci(buf, "SUMMARY")) {
|
} else if (starts_with_ci(buf, "SUMMARY")) {
|
||||||
vtodo.mesg =
|
vtodo.mesg =
|
||||||
ical_read_summary(buf, noskipped, ICAL_VTODO,
|
ical_read_summary(buf, noskipped, ICAL_VTODO,
|
||||||
@ -1705,8 +1671,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
|||||||
property = LOCATION;
|
property = LOCATION;
|
||||||
} else if (starts_with_ci(buf, "COMMENT")) {
|
} else if (starts_with_ci(buf, "COMMENT")) {
|
||||||
property = COMMENT;
|
property = COMMENT;
|
||||||
} else if (starts_with_ci(buf, "STATUS")) {
|
|
||||||
property = STATUS;
|
|
||||||
}
|
}
|
||||||
if (property) {
|
if (property) {
|
||||||
note = ical_read_note(buf, property, noskipped,
|
note = ical_read_note(buf, property, noskipped,
|
||||||
@ -1744,22 +1708,6 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
|||||||
} else
|
} else
|
||||||
vtodo.comm = note;
|
vtodo.comm = note;
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1778,8 +1726,6 @@ cleanup:
|
|||||||
mem_free(vtodo.loc);
|
mem_free(vtodo.loc);
|
||||||
if (vtodo.comm)
|
if (vtodo.comm)
|
||||||
mem_free(vtodo.comm);
|
mem_free(vtodo.comm);
|
||||||
if (vtodo.stat)
|
|
||||||
mem_free(vtodo.stat);
|
|
||||||
if (vtodo.mesg)
|
if (vtodo.mesg)
|
||||||
mem_free(vtodo.mesg);
|
mem_free(vtodo.mesg);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ TRANSP:TRANSPARENT
|
|||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
SUMMARY:On day 2
|
SUMMARY:On day 2
|
||||||
DTSTART;VALUE=DATE:20131003
|
DTSTART;VALUE=DATE:20131004
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
|
@ -66,12 +66,6 @@ END:VTODO
|
|||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20200406T221300
|
DTSTART:20200406T221300
|
||||||
DURATION:PT0H15M0S
|
DURATION:PT0H15M0S
|
||||||
SUMMARY:Invalid STATUS
|
|
||||||
STATUS:confirmed
|
|
||||||
END:VEVENT
|
|
||||||
BEGIN:VEVENT
|
|
||||||
DTSTART:20200406T221300
|
|
||||||
DURATION:PT0H15M0S
|
|
||||||
SUMMARY:LOCATION twice
|
SUMMARY:LOCATION twice
|
||||||
LOCATION:first
|
LOCATION:first
|
||||||
LOCATION:second
|
LOCATION:second
|
||||||
|
@ -19,9 +19,8 @@ END:VEVENT
|
|||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20200404T084100
|
DTSTART:20200404T084100
|
||||||
DURATION:PT1H30M0S
|
DURATION:PT1H30M0S
|
||||||
SUMMARY:No description. Comment and status
|
SUMMARY:no description\, but comment
|
||||||
COMMENT:Event without description: a comment\nstreching over\nthree lines
|
COMMENT:Event without description: a comment\nstreching over\nthree lines
|
||||||
STATUS:CONFIRMED
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
|
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
@ -42,11 +41,10 @@ END:VEVENT
|
|||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20200404T204500
|
DTSTART:20200404T204500
|
||||||
DURATION:PT1H30M0S
|
DURATION:PT1H30M0S
|
||||||
SUMMARY:description\, status\, comment and location
|
SUMMARY:description\, comment and location
|
||||||
DESCRIPTION:event with\ndescription\nstatus\ncomment\nand location
|
DESCRIPTION:event with\ndescription\ncomment\nand location
|
||||||
LOCATION: Right here
|
LOCATION: Right here
|
||||||
COMMENT:just a repetition of description:\nevent with\ndescription\nstatus\ncomment\nand location
|
COMMENT:just a repetition of description:\nevent with\ndescription\ncomment\nand location
|
||||||
STATUS:CANCELLED
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
|
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
@ -64,9 +62,8 @@ END:VTODO
|
|||||||
|
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
PRIORITY:4
|
PRIORITY:4
|
||||||
SUMMARY:Comment and status
|
SUMMARY:no description\, but comment
|
||||||
COMMENT:Todo with out description. A comment\nstreching over\nthree lines
|
COMMENT:Todo without description. A comment\nstreching over\nthree lines
|
||||||
STATUS:NEEDS-ACTION
|
|
||||||
END:VTODO
|
END:VTODO
|
||||||
|
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
@ -77,17 +74,16 @@ END:VTODO
|
|||||||
|
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
PRIORITY:6
|
PRIORITY:6
|
||||||
SUMMARY:Empty description\,but status
|
SUMMARY:Empty description
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
STATUS:COMPLETED
|
|
||||||
END:VTODO
|
END:VTODO
|
||||||
|
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
SUMMARY:todo with description\, status\, comment and location
|
SUMMARY:todo with description\, comment and location
|
||||||
DESCRIPTION:todo with\ndescription\nstatus\ncomment\nand location\,\nbut no priority
|
DESCRIPTION:todo with\ndescription\ncomment\nand location\,\nbut no priority
|
||||||
LOCATION: Right here
|
LOCATION: Right here
|
||||||
COMMENT:mostly a repetition of description:\ntodo with\ndescription\nstatus\ncomment\nand location
|
COMMENT:mostly a repetition of description:\ntodo with\ndescription\ncomment\nand location
|
||||||
STATUS:IN-PROCESS
|
STATUS:COMPLETED
|
||||||
END:VTODO
|
END:VTODO
|
||||||
|
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
|
@ -16,11 +16,12 @@ Import process report: 0023 lines read
|
|||||||
10/03/13:
|
10/03/13:
|
||||||
* All day
|
* All day
|
||||||
* On day 1
|
* On day 1
|
||||||
* On day 2
|
|
||||||
* Two days
|
* Two days
|
||||||
|
|
||||||
10/04/13:
|
10/04/13:
|
||||||
|
* On day 2
|
||||||
* Two days
|
* Two days
|
||||||
|
--
|
||||||
Import: multi-day event changed to one-day event
|
Import: multi-day event changed to one-day event
|
||||||
EOD
|
EOD
|
||||||
else
|
else
|
||||||
|
@ -21,6 +21,7 @@ Import process report: 0018 lines read
|
|||||||
UTC
|
UTC
|
||||||
- 11:00 -> 12:00
|
- 11:00 -> 12:00
|
||||||
Local time
|
Local time
|
||||||
|
--
|
||||||
Import: TZID=CET
|
Import: TZID=CET
|
||||||
EOD
|
EOD
|
||||||
else
|
else
|
||||||
|
@ -17,8 +17,8 @@ if [ "$1" = 'actual' ]; then
|
|||||||
rm -rf .calcurse || exit 1
|
rm -rf .calcurse || exit 1
|
||||||
elif [ "$1" = 'expected' ]; then
|
elif [ "$1" = 'expected' ]; then
|
||||||
cat <<EOD
|
cat <<EOD
|
||||||
Import process report: 0127 lines read
|
Import process report: 0121 lines read
|
||||||
2 apps / 0 events / 1 todo / 20 skipped
|
2 apps / 0 events / 1 todo / 19 skipped
|
||||||
VEVENT [12]: invalid or malformed event start time.
|
VEVENT [12]: invalid or malformed event start time.
|
||||||
VEVENT [17]: rrule frequency not supported.
|
VEVENT [17]: rrule frequency not supported.
|
||||||
VEVENT [23]: malformed summary line.
|
VEVENT [23]: malformed summary line.
|
||||||
@ -28,17 +28,16 @@ VEVENT [39]: line break in summary.
|
|||||||
VEVENT [44]: malformed description line.
|
VEVENT [44]: malformed description line.
|
||||||
VEVENT [50]: malformed description.
|
VEVENT [50]: malformed description.
|
||||||
VTODO [62]: malformed summary.
|
VTODO [62]: malformed summary.
|
||||||
VEVENT [66]: invalid status value.
|
VEVENT [66]: only one location allowed.
|
||||||
VEVENT [72]: only one location allowed.
|
VEVENT [73]: invalid duration.
|
||||||
VEVENT [79]: invalid duration.
|
VEVENT [78]: invalid or malformed event start time.
|
||||||
VEVENT [84]: invalid or malformed event start time.
|
VEVENT [83]: invalid end time value type.
|
||||||
VEVENT [89]: invalid end time value type.
|
VEVENT [88]: invalid until format.
|
||||||
VEVENT [94]: invalid until format.
|
VEVENT [94]: invalid exception date value type.
|
||||||
VEVENT [100]: invalid exception date value type.
|
VEVENT [101]: invalid exception.
|
||||||
VEVENT [107]: invalid exception.
|
VEVENT [108]: either end or duration.
|
||||||
VEVENT [114]: either end or duration.
|
VEVENT [114]: end must be later than start.
|
||||||
VEVENT [120]: end must be later than start.
|
VTODO [119]: The ical file seems to be malformed. The end of item was not found.
|
||||||
VTODO [125]: The ical file seems to be malformed. The end of item was not found.
|
|
||||||
101
|
101
|
||||||
EOD
|
EOD
|
||||||
else
|
else
|
||||||
|
@ -14,11 +14,10 @@ if [ "$1" = 'actual' ]; then
|
|||||||
rm -rf .calcurse || exit 1
|
rm -rf .calcurse || exit 1
|
||||||
elif [ "$1" = 'expected' ]; then
|
elif [ "$1" = 'expected' ]; then
|
||||||
cat <<EOD
|
cat <<EOD
|
||||||
Import process report: 0093 lines read
|
Import process report: 0089 lines read
|
||||||
6 apps / 0 events / 6 todos / 0 skipped
|
6 apps / 0 events / 6 todos / 0 skipped
|
||||||
todo with
|
todo with
|
||||||
description
|
description
|
||||||
status
|
|
||||||
comment
|
comment
|
||||||
and location,
|
and location,
|
||||||
but no priority
|
but no priority
|
||||||
@ -27,13 +26,10 @@ Location: Right here
|
|||||||
Comment: mostly a repetition of description:
|
Comment: mostly a repetition of description:
|
||||||
todo with
|
todo with
|
||||||
description
|
description
|
||||||
status
|
|
||||||
comment
|
comment
|
||||||
and location
|
and location
|
||||||
Status: IN-PROCESS
|
|
||||||
event with
|
event with
|
||||||
description
|
description
|
||||||
status
|
|
||||||
comment
|
comment
|
||||||
and location
|
and location
|
||||||
--
|
--
|
||||||
@ -41,18 +37,16 @@ Location: Right here
|
|||||||
Comment: just a repetition of description:
|
Comment: just a repetition of description:
|
||||||
event with
|
event with
|
||||||
description
|
description
|
||||||
status
|
|
||||||
comment
|
comment
|
||||||
and location
|
and location
|
||||||
Status: CANCELLED
|
--
|
||||||
Comment: Todo with out description. A comment
|
|
||||||
streching over
|
|
||||||
three lines
|
|
||||||
Status: NEEDS-ACTION
|
|
||||||
Comment: Event without description: a comment
|
Comment: Event without description: a comment
|
||||||
streching over
|
streching over
|
||||||
three lines
|
three lines
|
||||||
Status: CONFIRMED
|
--
|
||||||
|
Comment: Todo without description. A comment
|
||||||
|
streching over
|
||||||
|
three lines
|
||||||
event with description
|
event with description
|
||||||
and location
|
and location
|
||||||
--
|
--
|
||||||
@ -67,9 +61,6 @@ Comment: event with empty description
|
|||||||
event with one-line description
|
event with one-line description
|
||||||
todo with one-line description
|
todo with one-line description
|
||||||
|
|
||||||
--
|
|
||||||
Status: COMPLETED
|
|
||||||
|
|
||||||
EOD
|
EOD
|
||||||
else
|
else
|
||||||
./run-test "$0"
|
./run-test "$0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user