diff options
Diffstat (limited to 'pith')
-rw-r--r-- | pith/handle.h | 8 | ||||
-rw-r--r-- | pith/ical.c | 345 | ||||
-rw-r--r-- | pith/icaltype.h | 4 | ||||
-rw-r--r-- | pith/mailview.c | 319 | ||||
-rw-r--r-- | pith/send.c | 14 |
5 files changed, 363 insertions, 327 deletions
diff --git a/pith/handle.h b/pith/handle.h index 265c4cc3..53878e45 100644 --- a/pith/handle.h +++ b/pith/handle.h @@ -22,7 +22,7 @@ #include "../pith/msgno.h" #include "../pith/atttype.h" #include "../pith/util.h" - +#include "../pith/icaltype.h" typedef struct screen_position_list { Pos where; @@ -35,7 +35,7 @@ typedef struct screen_position_list { */ typedef struct handle_s { int key; /* tag number embedded in text */ - enum {URL, Attach, Folder, Function, IMG} type; + enum {URL, iCal, Attach, Folder, Function, IMG} type; unsigned force_display:1; /* Don't ask before launching */ unsigned using_is_used:1; /* bit below is being used */ unsigned is_used:1; /* if not, remove it from list */ @@ -54,6 +54,10 @@ typedef struct handle_s { } img; /* stuff to describe img */ ATTACH_S *attach; /* Attachment struct for this handle */ struct { + ATTACH_S *attach; /* full Calendar entry */ + int depth; /* which event to display */ + } ical; + struct { int index; /* folder's place in context's list */ CONTEXT_S *context; /* description of folders */ } f; /* stuff to describe Folder handle */ diff --git a/pith/ical.c b/pith/ical.c index dee78f58..59e8c42c 100644 --- a/pith/ical.c +++ b/pith/ical.c @@ -381,6 +381,7 @@ ical_free_vevent(void **veventpv) ical_free_prop(&(*veventp)->prop, event_prop, EvUnknown); if((*veventp)->uk_prop) ical_free_gencline((void **) &(*veventp)->uk_prop); if((*veventp)->valarm) ical_free_valarm((void **) &(*veventp)->valarm); + if((*veventp)->next) ical_free_vevent((void **) &(*veventp)->next); fs_give(veventpv); } @@ -518,6 +519,10 @@ char *ical_unfold_line(char *line) j += 3; /* get past white space */ continue; } + case '\n': if(ical_wspace(line[j+1])){ + j += 2; /* get past white space */ + continue; + } default : line[i++] = line[j++]; } line[i] = '\0'; @@ -834,8 +839,17 @@ ical_parse_vcalendar(char **text) if(vcal->comp[ical_comp[i].pos] == NULL) vcal->comp[ical_comp[i].pos] = v; - else - (ical_comp[i].give)(&v); + else{ + if((vcal->method && vcal->method->value + && strucmp(vcal->method->value, "PUBLISH")) + || struncmp(ical_comp[i].comp, "VEVENT", 6)) + (ical_comp[i].give)(&v); + else{ + VEVENT_S *vevent = (VEVENT_S *) vcal->comp[VEvent]; + for(; vevent && vevent->next; vevent = vevent->next); + vevent->next = v; + } + } } else { v = (void *) ical_parse_unknown_comp(&s, 0); if(vcal->uk_comp == NULL) @@ -2154,7 +2168,7 @@ ical_get_tzid(ICAL_PARAMETER_S *param) VEVENT_SUMMARY_S * ical_vevent_summary(VCALENDAR_S *vcal) { - VEVENT_SUMMARY_S *rv; + VEVENT_SUMMARY_S *rv, *vsummary= NULL; ICLINE_S *method; VEVENT_S *vevent; GEN_ICLINE_S *gicl; @@ -2164,29 +2178,33 @@ ical_vevent_summary(VCALENDAR_S *vcal) if(vcal == NULL) return NULL; method = vcal->method; - vevent = (VEVENT_S *) vcal->comp[VEvent]; + vevent = (VEVENT_S *) vcal->comp[VEvent]; if(vevent == NULL || vevent->prop == NULL) return NULL; - rv = fs_get(sizeof(VEVENT_SUMMARY_S)); - memset((void *) rv, 0, sizeof(VEVENT_SUMMARY_S)); + for(vevent = (VEVENT_S *) vcal->comp[VEvent]; + vevent != NULL && vevent->prop != NULL; + vevent = vevent->next, rv = rv->next){ + + rv = fs_get(sizeof(VEVENT_SUMMARY_S)); + memset((void *) rv, 0, sizeof(VEVENT_SUMMARY_S)); - if(method != NULL && !strucmp(method->value, "CANCEL")) - rv->cancel++; + if(method != NULL && !strucmp(method->value, "CANCEL")) + rv->cancel++; - if((icl = (ICLINE_S *) vevent->prop[EvPriority]) != NULL) - rv->priority = atoi(icl->value); + if((icl = (ICLINE_S *) vevent->prop[EvPriority]) != NULL) + rv->priority = atoi(icl->value); - if((icl = (ICLINE_S *) vevent->prop[EvSummary]) != NULL) - rv->summary = cpystr(icl->value ? icl->value : _("No Summary")); + if((icl = (ICLINE_S *) vevent->prop[EvSummary]) != NULL) + rv->summary = cpystr(icl->value ? icl->value : _("No Summary")); - if((icl = (ICLINE_S *) vevent->prop[EvClass]) != NULL) - rv->class = cpystr(icl->value ? icl->value : _("PUBLIC")); - else - rv->class = cpystr(_("PUBLIC")); + if((icl = (ICLINE_S *) vevent->prop[EvClass]) != NULL) + rv->class = cpystr(icl->value ? icl->value : _("PUBLIC")); + else + rv->class = cpystr(_("PUBLIC")); - if((icl = (ICLINE_S *) vevent->prop[EvOrganizer]) != NULL){ + if((icl = (ICLINE_S *) vevent->prop[EvOrganizer]) != NULL){ char *cn, *sender, *address; ICAL_PARAMETER_S *param; @@ -2212,22 +2230,22 @@ ical_vevent_summary(VCALENDAR_S *vcal) address ? address : _("Unknown address")); rv->organizer = cpystr(tmp_20k_buf); } - } /* end of if(organizer) */ - - if((icl = (ICLINE_S *) vevent->prop[EvLocation]) != NULL) - rv->location = cpystr(icl->value ? icl->value : _("Location undisclosed")); - - if((icl = (ICLINE_S *) vevent->prop[EvDtstart]) != NULL){ - struct tm ic_date; - char tmp[200], *tzid; - int icd; /* ical date return value */ - - memset((void *)&ic_date, 0, sizeof(struct tm)); - icd = ical_parse_date(icl->value, &ic_date); - tzid = ical_get_tzid(icl->param); - if(icd >= 0){ - ic_date.tm_wday = ical_day_of_week(ic_date); - switch(icd){ + } /* end of if(organizer) */ + + if((icl = (ICLINE_S *) vevent->prop[EvLocation]) != NULL) + rv->location = cpystr(icl->value ? icl->value : _("Location undisclosed")); + + if((icl = (ICLINE_S *) vevent->prop[EvDtstart]) != NULL){ + struct tm ic_date; + char tmp[200], *tzid; + int icd; /* ical date return value */ + + memset((void *)&ic_date, 0, sizeof(struct tm)); + icd = ical_parse_date(icl->value, &ic_date); + tzid = ical_get_tzid(icl->param); + if(icd >= 0){ + ic_date.tm_wday = ical_day_of_week(ic_date); + switch(icd){ case 0: /* DATE-TIME */ ical_date_time(tmp, sizeof(tmp), &ic_date); break; @@ -2239,129 +2257,129 @@ ical_vevent_summary(VCALENDAR_S *vcal) break; default: alpine_panic("Unhandled ical date format"); break; - } - } - else{ - strncpy(tmp, _("Error while parsing event date"), sizeof(tmp)); - tmp[sizeof(tmp) - 1] = '\0'; - } + } + } + else{ + strncpy(tmp, _("Error while parsing event date"), sizeof(tmp)); + tmp[sizeof(tmp) - 1] = '\0'; + } - if(icl->value == NULL) - rv->evstart = cpystr(_("Unknown Start Date")); - else{ - size_t len = strlen(tmp) + 1; + if(icl->value == NULL) + rv->evstart = cpystr(_("Unknown Start Date")); + else{ + size_t len = strlen(tmp) + 1; - if(tzid != NULL) - len += strlen(tzid) + 3; /* 3 = strlen(" ()") */ + if(tzid != NULL) + len += strlen(tzid) + 3; /* 3 = strlen(" ()") */ - rv->evstart = fs_get(len*sizeof(char)); - snprintf(rv->evstart, len, "%s%s%s%s", tmp, + rv->evstart = fs_get(len*sizeof(char)); + snprintf(rv->evstart, len, "%s%s%s%s", tmp, tzid != NULL ? " (" : "", tzid != NULL ? tzid : "", tzid != NULL ? ")" : ""); - rv->evstart[len-1] = '\0'; - } - if(tzid) - fs_give((void **)&tzid); - } /* end of if dtstart */ - - if((icl = (ICLINE_S *) vevent->prop[EvDuration]) != NULL){ - int i, done = 0; - ICAL_DURATION_S ic_d, icd2; - if(ical_parse_duration(icl->value, &ic_d) == 0){ - char tmp[MAILTMPLEN+1]; - - for(i = 1, icd2 = ic_d; icd2.next != NULL; icd2 = *icd2.next, i++); - rv->duration = fs_get((i+1)*sizeof(char *)); - i = 0; - - do { - tmp[0] = '\0'; - - if(ic_d.weeks > 0) - utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), + rv->evstart[len-1] = '\0'; + } + if(tzid) + fs_give((void **)&tzid); + } /* end of if dtstart */ + + if((icl = (ICLINE_S *) vevent->prop[EvDuration]) != NULL){ + int i, done = 0; + ICAL_DURATION_S ic_d, icd2; + if(ical_parse_duration(icl->value, &ic_d) == 0){ + char tmp[MAILTMPLEN+1]; + + for(i = 1, icd2 = ic_d; icd2.next != NULL; icd2 = *icd2.next, i++); + rv->duration = fs_get((i+1)*sizeof(char *)); + i = 0; + + do { + tmp[0] = '\0'; + + if(ic_d.weeks > 0) + utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), "%d %s ", ic_d.weeks, ic_d.weeks == 1 ? _("week") : _("weeks")); - if(ic_d.days > 0) - utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), + if(ic_d.days > 0) + utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), "%d %s ", ic_d.days, ic_d.days == 1 ? _("day") : _("days")); - if(ic_d.hours > 0) - utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), + if(ic_d.hours > 0) + utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), "%d %s ", ic_d.hours, ic_d.hours == 1 ? _("hour") : _("hours")); - if(ic_d.minutes > 0) - utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), + if(ic_d.minutes > 0) + utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), "%d %s ", ic_d.minutes, ic_d.minutes == 1 ? _("minute") : _("minutes")); - if(ic_d.seconds > 0) - utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), + if(ic_d.seconds > 0) + utf8_snprintf(tmp+strlen(tmp), MAILTMPLEN - strlen(tmp), "%d %s ", ic_d.seconds, ic_d.seconds == 1 ? _("second") : _("seconds")); - tmp[MAILTMPLEN] = '\0'; - rv->duration[i++] = cpystr(tmp); - - if(ic_d.next != NULL) - ic_d = *ic_d.next; - else - done++; - } while (done == 0); - rv->duration[i] = NULL; - } - } /* end of DURATION */ - else if((icl = (ICLINE_S *) vevent->prop[EvDtend]) != NULL){ - struct tm ic_date; - char tmp[200], *tzid; - int icd; - - memset((void *)&ic_date, 0, sizeof(struct tm)); - icd = ical_parse_date(icl->value, &ic_date); - tzid = ical_get_tzid(icl->param); - if(icd >= 0){ - ic_date.tm_wday = ical_day_of_week(ic_date); - switch(icd){ - case 0: /* DATE-TIME */ - ical_date_time(tmp, sizeof(tmp), &ic_date); - break; - case 1: /* DATE */ - our_strftime(tmp, sizeof(tmp), "%a %x", &ic_date); - break; - case 2: /* DATE-TIME in GMT, Bug: add adjust to time zone */ - our_strftime(tmp, sizeof(tmp), "%a %x %I:%M %p", &ic_date); - break; - default: alpine_panic("Unhandled ical date format"); - break; - } - } - else{ - strncpy(tmp, _("Error while parsing event date"), sizeof(tmp)); - tmp[sizeof(tmp) - 1] = '\0'; - } + tmp[MAILTMPLEN] = '\0'; + rv->duration[i++] = cpystr(tmp); + + if(ic_d.next != NULL) + ic_d = *ic_d.next; + else + done++; + } while (done == 0); + rv->duration[i] = NULL; + } + } /* end of DURATION */ + else if((icl = (ICLINE_S *) vevent->prop[EvDtend]) != NULL){ + struct tm ic_date; + char tmp[200], *tzid; + int icd; + + memset((void *)&ic_date, 0, sizeof(struct tm)); + icd = ical_parse_date(icl->value, &ic_date); + tzid = ical_get_tzid(icl->param); + if(icd >= 0){ + ic_date.tm_wday = ical_day_of_week(ic_date); + switch(icd){ + case 0: /* DATE-TIME */ + ical_date_time(tmp, sizeof(tmp), &ic_date); + break; + case 1: /* DATE */ + our_strftime(tmp, sizeof(tmp), "%a %x", &ic_date); + break; + case 2: /* DATE-TIME in GMT, Bug: add adjust to time zone */ + our_strftime(tmp, sizeof(tmp), "%a %x %I:%M %p", &ic_date); + break; + default: alpine_panic("Unhandled ical date format"); + break; + } + } + else{ + strncpy(tmp, _("Error while parsing event date"), sizeof(tmp)); + tmp[sizeof(tmp) - 1] = '\0'; + } - if(icl->value == NULL) - rv->evend = cpystr(_("Unknown End Date")); - else{ - size_t len = strlen(tmp) + 1; + if(icl->value == NULL) + rv->evend = cpystr(_("Unknown End Date")); + else{ + size_t len = strlen(tmp) + 1; - if(tzid != NULL) - len += strlen(tzid) + 3; /* 3 = strlen(" ()") */ + if(tzid != NULL) + len += strlen(tzid) + 3; /* 3 = strlen(" ()") */ - rv->evend = fs_get(len*sizeof(char)); - snprintf(rv->evend, len, "%s%s%s%s", tmp, + rv->evend = fs_get(len*sizeof(char)); + snprintf(rv->evend, len, "%s%s%s%s", tmp, tzid != NULL ? " (" : "", tzid != NULL ? tzid : "", tzid != NULL ? ")" : ""); - rv->evend[len-1] = '\0'; - } - if(tzid) - fs_give((void **)&tzid); - } /* end of if dtend */ - - if((icl = (ICLINE_S *) vevent->prop[EvDtstamp]) != NULL){ - struct tm ic_date; - char tmp[200], *tzid; - int icd; - - memset((void *)&ic_date, 0, sizeof(struct tm)); - icd = ical_parse_date(icl->value, &ic_date); - tzid = ical_get_tzid(icl->param); - if(icd >= 0){ + rv->evend[len-1] = '\0'; + } + if(tzid) + fs_give((void **)&tzid); + } /* end of if dtend */ + + if((icl = (ICLINE_S *) vevent->prop[EvDtstamp]) != NULL){ + struct tm ic_date; + char tmp[200], *tzid; + int icd; + + memset((void *)&ic_date, 0, sizeof(struct tm)); + icd = ical_parse_date(icl->value, &ic_date); + tzid = ical_get_tzid(icl->param); + if(icd >= 0){ ic_date.tm_wday = ical_day_of_week(ic_date); switch(icd){ case 0: /* DATE-TIME */ @@ -2376,29 +2394,29 @@ ical_vevent_summary(VCALENDAR_S *vcal) default: alpine_panic("Unhandled ical date format"); break; } - } - else{ + } + else{ strncpy(tmp, _("Error while parsing event date"), sizeof(tmp)); tmp[sizeof(tmp) - 1] = '\0'; - } - if(icl->value == NULL) - rv->dtstamp = cpystr(_("Unknown when event was scheduled")); - else{ - size_t len = strlen(tmp) + 1; + } + if(icl->value == NULL) + rv->dtstamp = cpystr(_("Unknown when event was scheduled")); + else{ + size_t len = strlen(tmp) + 1; - if(tzid != NULL) + if(tzid != NULL) len += strlen(tzid) + 3; /* 3 = strlen(" ()") */ - rv->dtstamp = fs_get(len*sizeof(char)); - snprintf(rv->dtstamp, len, "%s%s%s%s", tmp, + rv->dtstamp = fs_get(len*sizeof(char)); + snprintf(rv->dtstamp, len, "%s%s%s%s", tmp, tzid != NULL ? " (" : "", tzid != NULL ? tzid : "", tzid != NULL ? ")" : ""); - rv->dtstamp[len-1] = '\0'; - } - } /* end of if dtstamp */ + rv->dtstamp[len-1] = '\0'; + } + } /* end of if dtstamp */ - if((gicl = (GEN_ICLINE_S *) vevent->prop[EvAttendee]) != NULL){ + if((gicl = (GEN_ICLINE_S *) vevent->prop[EvAttendee]) != NULL){ int nattendees, i; for(nattendees = 0; gicl != NULL; gicl = gicl->next, nattendees++); @@ -2459,15 +2477,15 @@ ical_vevent_summary(VCALENDAR_S *vcal) rv->attendee[i] = cpystr(tmp_20k_buf); } rv->attendee[i] = NULL; - } /* end of ATTENDEES */ + } /* end of ATTENDEES */ - if((icl = (ICLINE_S *) vevent->prop[EvDescription]) != NULL){ + if((icl = (ICLINE_S *) vevent->prop[EvDescription]) != NULL){ char *s, *t, *u, *v; int i, escaped; if(icl->value == NULL){ free_vevent_summary(&rv); - return NULL; + return vsummary; } v = cpystr(icl->value); /* process a copy of icl->value */ @@ -2478,7 +2496,7 @@ ical_vevent_summary(VCALENDAR_S *vcal) if(!(*s == '\\' || *s == ',' || *s == 'n' || *s == 'N' || *s == ';')){ free_vevent_summary(&rv); fs_give((void **)&v); - return NULL; + return vsummary; } escaped = 0; continue; @@ -2519,9 +2537,17 @@ ical_vevent_summary(VCALENDAR_S *vcal) rv->description[i++] = cpystr(ical_decode(s, vcal->encoding)); rv->description[i] = NULL; fs_give((void **)&v); - } /* end of if(description) */ - - return rv; + } /* end of if(description) */ + /* last instruction of the loop */ + if(vsummary == NULL) + vsummary = rv; + else{ + VEVENT_SUMMARY_S *vesy; + for(vesy = vsummary; vesy && vesy->next; vesy = vesy->next); + vesy->next = rv; + } + } /* end of "for" loop */ + return vsummary; } void @@ -2553,6 +2579,7 @@ free_vevent_summary(VEVENT_SUMMARY_S **vesy) fs_give((void **) &(*vesy)->description[i]); fs_give((void **) &(*vesy)->description); } + if((*vesy)->next) free_vevent_summary(&(*vesy)->next); fs_give((void **) vesy); } diff --git a/pith/icaltype.h b/pith/icaltype.h index d0670037..0ccea92d 100644 --- a/pith/icaltype.h +++ b/pith/icaltype.h @@ -129,7 +129,8 @@ typedef struct vevent_s { #endif /* if 0 */ void **prop; /* the properties of an event component */ GEN_ICLINE_S *uk_prop; /* unknown values */ - VALARM_S *valarm; /* possible valarm */ + VALARM_S *valarm; /* possible valarm */ + struct vevent_s *next; /* calendar of method publish has many events */ } VEVENT_S; typedef struct vtodo_s { @@ -443,6 +444,7 @@ typedef struct vevent_summary_s { char **duration; char **attendee; unsigned char **description; + struct vevent_summary_s *next; } VEVENT_SUMMARY_S; typedef enum {VCalendar = 0, VTimeZone, VEvent, VTodo, VJournal, diff --git a/pith/mailview.c b/pith/mailview.c index 39fcfff6..c438371c 100644 --- a/pith/mailview.c +++ b/pith/mailview.c @@ -224,90 +224,90 @@ void format_calendar_vevent(VCALENDAR_S *vcal, ATTACH_S *a, HANDLE_S **handlesp, int flgs, int width, gf_io_t pc, int cflags) { int avail, m1, m2, hwid, i, partwid, padwid; - int s1, s2, dwid; + int s1, s2, dwid, minkey; int *margin; char padding[1024]; - VEVENT_SUMMARY_S *vesy; /* vevent summary */ + VEVENT_SUMMARY_S *vesy, *vesummary; /* vevent summary */ - vesy = ical_vevent_summary(vcal); + vesummary = vesy = ical_vevent_summary(vcal); if(vesy == NULL) return; if((cflags & FC_SUMMARY) && (cflags & FC_FULL)) cflags |= ~FC_FULL; - avail = width; - margin = (cflags & FC_FULL) ? NULL + minkey = -1; /* initialize to something negative */ + + for(; vesy != NULL ; vesy = vesy->next){ + avail = width; + margin = (cflags & FC_FULL) ? NULL : (flgs & FM_NOINDENT) ? NULL : format_view_margin(); - m1 = MAX(MIN(margin ? margin[0] : 0, avail), 0); - avail -= m1; + m1 = MAX(MIN(margin ? margin[0] : 0, avail), 0); + avail -= m1; - m2 = MAX(MIN(margin ? margin[1] : 0, avail), 0); - avail -= m2; + m2 = MAX(MIN(margin ? margin[1] : 0, avail), 0); + avail -= m2; - hwid = MAX(avail, 0); - padwid = 0; + hwid = MAX(avail, 0); + padwid = 0; - if(ps_global->atmts[1].description == NULL){ -// && (!ps_global->atmts[0].body -// || (ps_global->atmts[0].body->type == TYPETEXT))){ - avail = width - m1 -2; + if(ps_global->atmts[1].description == NULL){ + avail = width - m1 -2; - dwid = MAX(MIN(40, avail), 0); + dwid = MAX(MIN(40, avail), 0); - snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s%s", m1, m1, "", + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s%s", m1, m1, "", repeat_char(dwid, '-')); - if(!gf_puts(tmp_20k_buf, pc) || !gf_puts(NEWLINE, pc)) + if(!gf_puts(tmp_20k_buf, pc) || !gf_puts(NEWLINE, pc)) return; - } + } - if(cflags & FC_SUMMARY){ - i = utf8_width(_("Calendar Entry:")); - partwid = MIN(i, hwid); - if(m1 > 0){ + if(cflags & FC_SUMMARY){ + i = utf8_width(_("Calendar Entry:")); + partwid = MIN(i, hwid); + if(m1 > 0){ snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s", m1, m1, ""); if(!gf_puts(tmp_20k_buf, pc)) return; - } + } - utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%-*.*w%*.*s", + utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%-*.*w%*.*s", partwid, partwid, _("Calendar Entry:"), padwid, padwid, ""); if(!gf_puts(tmp_20k_buf, pc) || !gf_puts(NEWLINE, pc)) return; - } - else - partwid = 0; - - if(m1 > 0){ - snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s", m1, m1, ""); - if(!gf_puts(tmp_20k_buf, pc)) - return; - } + } + else + partwid = 0; - avail = width - m1 - m2; + if(m1 > 0){ + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s", m1, m1, ""); + if(!gf_puts(tmp_20k_buf, pc)) + return; + } - s1 = MAX(MIN(1, avail), 0); - avail -= s1; + avail = width - m1 - m2; - dwid = MAX(MIN(1, avail), 0); - avail -= dwid; + s1 = MAX(MIN(1, avail), 0); + avail -= s1; - s2 = MAX(MIN(1, avail), 0); - avail -= s2; + dwid = MAX(MIN(1, avail), 0); + avail -= dwid; + s2 = MAX(MIN(1, avail), 0); + avail -= s2; - if(cflags & FC_SUMMARY) - utf8_snprintf(padding, sizeof(padding), "%*.*s%*.*w%*.*s", + if(cflags & FC_SUMMARY) + utf8_snprintf(padding, sizeof(padding), "%*.*s%*.*w%*.*s", s1, s1, "", dwid, dwid, "", s2, s2, ""); - else - padding[0] = '\0'; + else + padding[0] = '\0'; - if(vesy->cancel){ + if(vesy->cancel){ utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s", padding, _("This event was cancelled!")); if((*pc)(TAG_EMBED) && (*pc)(TAG_BOLDON)){ @@ -316,60 +316,60 @@ format_calendar_vevent(VCALENDAR_S *vcal, ATTACH_S *a, HANDLE_S **handlesp, int (*pc)(TAG_EMBED); (*pc)(TAG_BOLDOFF); } - } + } - if(vesy->organizer){ - if(vesy->sender != NULL){ - utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", + if(vesy->organizer){ + if(vesy->sender != NULL){ + utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", padding, _("Sent-by: "), vesy->sender); - gf_puts(tmp_20k_buf, pc); - gf_puts(NEWLINE, pc); - } - - utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", - padding, _("Organizer: "), vesy->organizer); - gf_puts(tmp_20k_buf, pc); - gf_puts(NEWLINE, pc); - } /* end of if(organizer) */ - - if(vesy->location){ - ical_remove_escapes(&vesy->location); - utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", + gf_puts(tmp_20k_buf, pc); + gf_puts(NEWLINE, pc); + } + + utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", + padding, _("Organizer: "), vesy->organizer); + gf_puts(tmp_20k_buf, pc); + gf_puts(NEWLINE, pc); + } /* end of if(organizer) */ + + if(vesy->location){ + ical_remove_escapes(&vesy->location); + utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", padding, _("Location: "), vesy->location); - gf_puts(tmp_20k_buf, pc); - gf_puts(NEWLINE, pc); - } /* end of if location */ + gf_puts(tmp_20k_buf, pc); + gf_puts(NEWLINE, pc); + } /* end of if location */ - if(vesy->evstart){ - utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", + if(vesy->evstart){ + utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", padding, _("Start Date: "), vesy->evstart); - gf_puts(tmp_20k_buf, pc); - gf_puts(NEWLINE, pc); - } /* end of if dtstart */ + gf_puts(tmp_20k_buf, pc); + gf_puts(NEWLINE, pc); + } /* end of if dtstart */ - if(vesy->duration){ - int i; + if(vesy->duration){ + int i; - for(i = 0; vesy->duration[i] != NULL; i++){ + for(i = 0; vesy->duration[i] != NULL; i++){ utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", padding, _("Duration: "), vesy->duration[i]); gf_puts(tmp_20k_buf, pc); gf_puts(NEWLINE, pc); - } - } /* end of DURATION */ - else if(vesy->evend){ + } + } /* end of DURATION */ + else if(vesy->evend){ utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s%s", padding, _("End Date: "), vesy->evend); gf_puts(tmp_20k_buf, pc); gf_puts(NEWLINE, pc); - } else { /* end of if dtend */ + } else { /* end of if dtend */ utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%s", padding, _("No duration nor end time found for this event")); gf_puts(tmp_20k_buf, pc); gf_puts(NEWLINE, pc); - } /* end of else for if (duration) and if (dtend) */ + } /* end of else for if (duration) and if (dtend) */ - if(vesy->attendee){ + if(vesy->attendee){ #define MAX_DISPLAYED 3 int i; @@ -383,109 +383,114 @@ format_calendar_vevent(VCALENDAR_S *vcal, ATTACH_S *a, HANDLE_S **handlesp, int gf_puts(tmp_20k_buf, pc); gf_puts(NEWLINE, pc); } - if(cflags & FC_SUMMARY){ - COLOR_PAIR *lastc = NULL; - char numbuf[50]; - int thisdescwid; - COLOR_PAIR *hdrcolor = NULL; + } /* end of ATTENDEES */ - if((flgs & FM_DISPLAY) - && !(flgs & FM_NOCOLOR) - && pico_usingcolor() - && ps_global->VAR_HEADER_GENERAL_FORE_COLOR - && ps_global->VAR_HEADER_GENERAL_BACK_COLOR - && ps_global->VAR_NORM_FORE_COLOR - && ps_global->VAR_NORM_BACK_COLOR - && (colorcmp(ps_global->VAR_HEADER_GENERAL_FORE_COLOR, + + if(cflags & FC_SUMMARY){ + COLOR_PAIR *lastc = NULL; + char numbuf[50]; + int thisdescwid; + COLOR_PAIR *hdrcolor = NULL; + + if((flgs & FM_DISPLAY) + && !(flgs & FM_NOCOLOR) + && pico_usingcolor() + && ps_global->VAR_HEADER_GENERAL_FORE_COLOR + && ps_global->VAR_HEADER_GENERAL_BACK_COLOR + && ps_global->VAR_NORM_FORE_COLOR + && ps_global->VAR_NORM_BACK_COLOR + && (colorcmp(ps_global->VAR_HEADER_GENERAL_FORE_COLOR, ps_global->VAR_NORM_FORE_COLOR) || colorcmp(ps_global->VAR_HEADER_GENERAL_BACK_COLOR, - ps_global->VAR_NORM_BACK_COLOR))){ + ps_global->VAR_NORM_BACK_COLOR))){ - if((hdrcolor = new_color_pair(ps_global->VAR_HEADER_GENERAL_FORE_COLOR, + if((hdrcolor = new_color_pair(ps_global->VAR_HEADER_GENERAL_FORE_COLOR, ps_global->VAR_HEADER_GENERAL_BACK_COLOR)) != NULL){ - if(!pico_is_good_colorpair(hdrcolor)) - free_color_pair(&hdrcolor); - } + if(!pico_is_good_colorpair(hdrcolor)) + free_color_pair(&hdrcolor); } + } - if(!(!hdrcolor || embed_color(hdrcolor, pc))) - return; - - gf_puts(padding, pc); - utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "[%s]", _("More Details")); - - if(handlesp){ - char buf[16], color[64]; - int l; - HANDLE_S *h; - - h = new_handle(handlesp); - h->type = Attach; - h->h.attach = a; - - snprintf(buf, sizeof(buf), "%d", h->key); - buf[sizeof(buf)-1] = '\0'; - - if(!(flgs & FM_NOCOLOR) - && handle_start_color(color, sizeof(color), &l, 1)){ - lastc = get_cur_embedded_color(); - if(!gf_nputs(color, (long) l, pc)) - return; - } - else if(F_OFF(F_SLCTBL_ITEM_NOBOLD, ps_global) + if(!(!hdrcolor || embed_color(hdrcolor, pc))) + return; + + gf_puts(padding, pc); + utf8_snprintf(tmp_20k_buf, SIZEOF_20KBUF, "[%s]", _("More Details")); + + if(handlesp){ + char buf[16], color[64]; + int l; + HANDLE_S *h; + + h = new_handle(handlesp); + if(minkey < 0) minkey = h->key; + h->type = iCal; + h->h.ical.attach = a; + h->h.ical.depth = h->key - minkey; + + snprintf(buf, sizeof(buf), "%d", h->key); + buf[sizeof(buf)-1] = '\0'; + + if(!(flgs & FM_NOCOLOR) + && handle_start_color(color, sizeof(color), &l, 1)){ + lastc = get_cur_embedded_color(); + if(!gf_nputs(color, (long) l, pc)) + return; + } + else if(F_OFF(F_SLCTBL_ITEM_NOBOLD, ps_global) && (!((*pc)(TAG_EMBED) && (*pc)(TAG_BOLDON)))) return; - if(!((*pc)(TAG_EMBED) && (*pc)(TAG_HANDLE) + if(!((*pc)(TAG_EMBED) && (*pc)(TAG_HANDLE) && (*pc)(strlen(buf)) && gf_puts(buf, pc))) return; - } else - tmp_20k_buf[0] = '\0'; - - if(!format_env_puts(tmp_20k_buf, pc)) - return; - - if(handlesp){ - if(lastc){ - if(F_OFF(F_SLCTBL_ITEM_NOBOLD, ps_global)){ - if(!((*pc)(TAG_EMBED) && (*pc)(TAG_BOLDOFF))) - return; - } + } else + tmp_20k_buf[0] = '\0'; - if(!embed_color(lastc, pc)) - return; + if(!format_env_puts(tmp_20k_buf, pc)) + return; - free_color_pair(&lastc); - } - else if(!((*pc)(TAG_EMBED) && (*pc)(TAG_BOLDOFF))) - return; + if(handlesp){ + if(lastc){ + if(F_OFF(F_SLCTBL_ITEM_NOBOLD, ps_global)){ + if(!((*pc)(TAG_EMBED) && (*pc)(TAG_BOLDOFF))) + return; + } - if(!((*pc)(TAG_EMBED) && (*pc)(TAG_INVOFF))) - return; - } + if(!embed_color(lastc, pc)) + return; - if(padwid > 0){ - snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s", padwid, padwid, ""); - if(!gf_puts(tmp_20k_buf, pc)) + free_color_pair(&lastc); + } + else if(!((*pc)(TAG_EMBED) && (*pc)(TAG_BOLDOFF))) return; - } - if(!gf_puts(NEWLINE, pc)) + if(!((*pc)(TAG_EMBED) && (*pc)(TAG_INVOFF))) return; } - } /* end of ATTENDEES */ - free_vevent_summary(&vesy); + if(padwid > 0){ + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s", padwid, padwid, ""); + if(!gf_puts(tmp_20k_buf, pc)) + return; + } - avail = width - m1 -2; + if(!gf_puts(NEWLINE, pc)) + return; + } + avail = width - m1 -2; - dwid = MAX(MIN(40, avail), 0); - avail -= dwid; + dwid = MAX(MIN(40, avail), 0); + avail -= dwid; - snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s%s", m1, m1, "", + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s%s", m1, m1, "", repeat_char(dwid, '-')); - gf_puts(tmp_20k_buf, pc); + gf_puts(tmp_20k_buf, pc); + if(vesy->next) + gf_puts(NEWLINE, pc); + } + free_vevent_summary(&vesummary); } int diff --git a/pith/send.c b/pith/send.c index 8be908c2..460f6a24 100644 --- a/pith/send.c +++ b/pith/send.c @@ -1226,10 +1226,12 @@ pine_new_env(ENVELOPE *outgoing, char **fccp, char ***tobufpp, PINEFIELD *custom for(i=0; i < stdcnt; i++, pf++){ pf->name = cpystr(pf_template[i].name); - if(i == N_SENDER && F_ON(F_USE_SENDER_NOT_X, ps_global)) + if(i == N_SENDER && F_ON(F_USE_SENDER_NOT_X, ps_global)){ /* slide string over so it is Sender instead of X-X-Sender */ - for(p=pf->name; *(p+1); p++) - *p = *(p+4); + for(p=pf->name+4; *p != '\0'; p++) + *(p-4) = *p; + *(p-4) = '\0'; + } pf->type = pf_template[i].type; pf->canedit = pf_template[i].canedit; @@ -4279,7 +4281,6 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s) int add_trailing_crlf; LOC_2022_JP ljp; gf_io_t gc; - void *table = NULL; dprint((4, "-- pine_rfc822_output_body: %d\n", body ? body->type : 0)); @@ -4364,7 +4365,7 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s) gf_line_test_opt(translate_utf8_to_2022_jp,&ljp)); } else{ - table = utf8_rmap(charset); + void *table = utf8_rmap(charset); if(table){ gf_link_filter(gf_convert_utf8_charset, @@ -4411,9 +4412,6 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s) display_message('x'); } - if(table) - fs_give((void **)&table); - gf_clear_so_readc(bodyso); if(encode_error || !l_flush_net(TRUE)) |