X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=fddc4894851cfa85e8f62f467cf5b297a8086be2;hb=abeb8adc38f9d55fcb6cb3d076f57239b0a9a4d5;hp=fc02aa1835b7a59fdb2728df52d6f59eb2ecede7;hpb=0198a9061636b17b95f087800608ea8bcb1d59ee;p=citadel.git diff --git a/webcit/messages.c b/webcit/messages.c index fc02aa183..fddc48948 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -91,20 +91,57 @@ char buf[]; } +/* + * Turn a vCard "n" (name) field into something displayable. + */ +void vcard_n_prettyize(char *name) +{ + char *original_name; + int i; + + original_name = strdup(name); + for (i=0; i<5; ++i) { + if (strlen(original_name) > 0) { + if (original_name[strlen(original_name)-1] == ' ') { + original_name[strlen(original_name)-1] = 0; + } + if (original_name[strlen(original_name)-1] == ';') { + original_name[strlen(original_name)-1] = 0; + } + } + } + strcpy(name, ""); + for (i=0; inumprops) for (i=0; i<(v->numprops); ++i) { - if (!strcasecmp(v->prop[i].name, "n")) { - strcpy(storename, v->prop[i].value); - } + + name = vcard_get_prop(v, "n", 1, 0, 0); + if (name != NULL) { + strcpy(storename, name); + /* vcard_n_prettyize(storename); */ } + } @@ -132,20 +169,27 @@ void display_parsed_vcard(struct vCard *v, int full) { int pass; char displayname[SIZ]; + char title[SIZ]; + char org[SIZ]; char phone[SIZ]; char mailto[SIZ]; strcpy(displayname, ""); strcpy(phone, ""); strcpy(mailto, ""); + strcpy(title, ""); + strcpy(org, ""); if (!full) { wprintf(""); name = vcard_get_prop(v, "fn", 1, 0, 0); - if (name == NULL) name = vcard_get_prop(v, "n", 1, 0, 0); if (name != NULL) { - strcpy(buf, name); - escputs(buf); + escputs(name); + } + else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) { + strcpy(displayname, name); + vcard_n_prettyize(displayname); + escputs(displayname); } else { wprintf(" "); @@ -154,16 +198,16 @@ void display_parsed_vcard(struct vCard *v, int full) { return; } - wprintf(""); + wprintf("
"); for (pass=1; pass<=2; ++pass) { if (v->numprops) for (i=0; i<(v->numprops); ++i) { thisname = strdup(v->prop[i].name); - extract_token(firsttoken, thisname, 0, ';'); + extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken); for (j=0; j 0) strcat(mailto, "
"); + if (strlen(mailto) > 0) strcat(mailto, "
"); strcat(mailto, ""); } else if (!strcasecmp(firsttoken, "tel")) { - if (strlen(phone) > 0) strcat(phone, "
"); + if (strlen(phone) > 0) strcat(phone, "
"); strcat(phone, thisvalue); for (j=0; j
\n"); @@ -258,6 +314,8 @@ void display_parsed_vcard(struct vCard *v, int full) { /* ignore */ } else { + + /*** Don't show extra fields. They're ugly. if (pass == 2) { wprintf("\n"); } + ***/ } free(thisname); @@ -277,7 +336,18 @@ void display_parsed_vcard(struct vCard *v, int full) { "" ""); escputs(displayname); - wprintf("\n"); + wprintf(""); + if (strlen(title) > 0) { + wprintf("
"); + escputs(title); + wprintf("
"); + } + if (strlen(org) > 0) { + wprintf("
"); + escputs(org); + wprintf("
"); + } + wprintf("\n"); if (strlen(phone) > 0) wprintf("
\n", phone); @@ -287,7 +357,7 @@ void display_parsed_vcard(struct vCard *v, int full) { } - wprintf("
Address:"); for (j=0; j 0) { escputs(buf); - wprintf("
"); + if (j<3) wprintf("
"); + else wprintf(" "); } } wprintf("
"); escputs(thisname); @@ -265,6 +323,7 @@ void display_parsed_vcard(struct vCard *v, int full) { escputs(thisvalue); wprintf("
Telephone:%s
\n"); + wprintf("\n"); } @@ -317,9 +387,10 @@ void display_vcard(char *vcard_source, char alpha, int full, char *storename) { if (storename != NULL) { fetchname_parsed_vcard(v, storename); } - else if ( (alpha == 0) - || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) ) - || ((!isalpha(alpha)) && (!isalpha(this_alpha))) ) { + else if ( (alpha == 0) + || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) ) + || ((!isalpha(alpha)) && (!isalpha(this_alpha))) + ) { display_parsed_vcard(v, full); } @@ -364,12 +435,13 @@ void read_message(long msgnum) { serv_printf("MSG4 %ld", msgnum); serv_gets(buf); if (buf[0] != '1') { - wprintf("ERROR: %s
\n", &buf[4]); + wprintf("ERROR: %s
\n", &buf[4]); return; } /* begin everythingamundo table */ - wprintf("\n"); + wprintf("
"); - - wprintf("\n"); + if (WC->is_room_aide) { + + /* Move */ + wprintf("[Move] ", + msgnum); - if (strlen(m_subject) > 0) { - wprintf("\n", m_subject); + /* Delete */ + wprintf("" + "[Delete]", msgnum); + } - wprintf("
\n"); /* begin message header table */ @@ -381,7 +453,7 @@ void read_message(long msgnum) { while (serv_gets(buf), strcasecmp(buf, "text")) { if (!strcmp(buf, "000")) { - wprintf("unexpected end of message

\n"); + wprintf("unexpected end of message

\n"); wprintf("\n"); return; } @@ -433,10 +505,10 @@ void read_message(long msgnum) { } if (!strncasecmp(buf, "part=", 5)) { - extract(mime_filename, &buf[5], 1); - extract(mime_partnum, &buf[5], 2); - extract(mime_disposition, &buf[5], 3); - extract(mime_content_type, &buf[5], 4); + extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename); + extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum); + extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition); + extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type); mime_length = extract_int(&buf[5], 5); if (!strcasecmp(mime_disposition, "attachment")) { @@ -447,7 +519,7 @@ void read_message(long msgnum) { "TARGET=\"wc.%ld.%s\">" "\n" - "Part %s: %s (%s, %d bytes)
\n", + "Part %s: %s (%s, %d bytes)
\n", msgnum, mime_partnum, msgnum, mime_partnum, mime_partnum, mime_filename, @@ -498,52 +570,41 @@ void read_message(long msgnum) { wprintf("****"); } - wprintf("
\n" - "\n"); + wprintf(""); + if (strlen(m_subject) > 0) { + wprintf("
" + "" + "Subject: %s" + "", m_subject + ); + } + wprintf("\n"); - /*** "Read" button is now superfluous - *** - ***wprintf("\n", msgnum); - ***/ + /* start msg buttons */ + wprintf("\n", msgnum); - - if (WC->is_room_aide) { - wprintf("\n", msgnum); - - wprintf("\n", msgnum); - } + wprintf("&subject="); + if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20"); + urlescputs(m_subject); + wprintf("\">[Reply] "); - wprintf("
" - *** "Read" - *** "\n"); - wprintf("" - "Reply" - "" - "Move" - "" - "Del" - "
\n" - "
" - "" - "Subject: %s" - "" - " 
\n"); + wprintf("\n"); /* Begin body */ wprintf(" 0)) { if (!strcmp(buf, "000")) { - wprintf("unexpected end of message

\n"); + wprintf("unexpected end of message

\n"); goto ENDBODY; } if (!strncasecmp(buf, "Content-type: ", 14)) { @@ -578,19 +639,19 @@ void read_message(long msgnum) { buf[strlen(buf) - 1] = 0; if ((bq == 0) && ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) { - wprintf(""); + wprintf("
"); bq = 1; } else if ((bq == 1) && (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) { - wprintf(""); + wprintf("
"); bq = 0; } wprintf(""); url(buf); escputs(buf); - wprintf("
\n"); + wprintf("
\n"); } - wprintf("
"); + wprintf("
"); } else /* HTML is fun, but we've got to strip it first */ @@ -600,7 +661,7 @@ void read_message(long msgnum) { /* Unknown weirdness */ else { - wprintf("I don't know how to display %s
\n", + wprintf("I don't know how to display %s
\n", mime_content_type); while (serv_gets(buf), strcmp(buf, "000")) { } } @@ -617,12 +678,14 @@ void read_message(long msgnum) { if (part_source != NULL) { /* If it's my vCard I can edit it */ - if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM)) - || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) { + if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM)) + || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM)) + || (WC->wc_view == VIEW_ADDRESSBOOK) + ) { wprintf("", msgnum, vcard_partnum); - wprintf("(edit)"); + wprintf("[edit]"); } /* In all cases, display the full card */ @@ -648,11 +711,12 @@ ENDBODY: wprintf("
\n"); /* end everythingamundo table */ - wprintf("
\n"); + wprintf("\n"); + wprintf("
\n"); } -void summarize_message(long msgnum) { +void summarize_message(long msgnum, int is_new) { char buf[SIZ]; struct { @@ -666,7 +730,7 @@ void summarize_message(long msgnum) { memset(&summ, 0, sizeof(summ)); strcpy(summ.subj, "(no subject)"); - sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */ + sprintf(buf, "MSG0 %ld|3", msgnum); /* ask for headers only with no MIME */ serv_puts(buf); serv_gets(buf); if (buf[0] != '1') return; @@ -703,14 +767,22 @@ void summarize_message(long msgnum) { } } - wprintf(""); + if (is_new) wprintf(""); + wprintf("", msgnum); escputs(summ.subj); - wprintf(""); + wprintf(""); + if (is_new) wprintf(""); + wprintf(""); + if (is_new) wprintf(""); escputs(summ.from); + if (is_new) wprintf(""); wprintf(" "); + if (is_new) wprintf(""); escputs(summ.date); + if (is_new) wprintf(""); wprintf(" "); wprintf("" "" @@ -749,10 +821,10 @@ void display_addressbook(long msgnum, char alpha) { while (serv_gets(buf), strcmp(buf, "000")) { if (!strncasecmp(buf, "part=", 5)) { - extract(mime_filename, &buf[5], 1); - extract(mime_partnum, &buf[5], 2); - extract(mime_disposition, &buf[5], 3); - extract(mime_content_type, &buf[5], 4); + extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename); + extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum); + extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition); + extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type); mime_length = extract_int(&buf[5], 5); if (!strcasecmp(mime_content_type, "text/x-vcard")) { @@ -770,12 +842,14 @@ void display_addressbook(long msgnum, char alpha) { display_vcard(vcard_source, alpha, 0, NULL); /* If it's my vCard I can edit it */ - if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM)) - || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) { + if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM)) + || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM)) + || (WC->wc_view == VIEW_ADDRESSBOOK) + ) { wprintf("", msgnum, vcard_partnum); - wprintf("(edit)"); + wprintf("[edit]"); } free(vcard_source); @@ -800,7 +874,7 @@ void lastfirst_firstlast(char *namebuf) { i = num_tokens(namebuf, ' '); if (i < 2) return; - extract_token(lastname, namebuf, i-1, ' '); + extract_token(lastname, namebuf, i-1, ' ', sizeof lastname); remove_token(namebuf, i-1, ' '); strcpy(firstname, namebuf); sprintf(namebuf, "%s; %s", lastname, firstname); @@ -816,6 +890,7 @@ void fetch_ab_name(long msgnum, char *namebuf) { int mime_length; char vcard_partnum[SIZ]; char *vcard_source = NULL; + int i; struct { char date[SIZ]; @@ -838,10 +913,10 @@ void fetch_ab_name(long msgnum, char *namebuf) { while (serv_gets(buf), strcmp(buf, "000")) { if (!strncasecmp(buf, "part=", 5)) { - extract(mime_filename, &buf[5], 1); - extract(mime_partnum, &buf[5], 2); - extract(mime_disposition, &buf[5], 3); - extract(mime_content_type, &buf[5], 4); + extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename); + extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum); + extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition); + extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type); mime_length = extract_int(&buf[5], 5); if (!strcasecmp(mime_content_type, "text/x-vcard")) { @@ -863,6 +938,11 @@ void fetch_ab_name(long msgnum, char *namebuf) { } lastfirst_firstlast(namebuf); + striplt(namebuf); + for (i=0; iab_name), - (((const struct addrbookent *)ab2)->ab_name) + (((const struct addrbookent *)ab1)->ab_name), + (((const struct addrbookent *)ab2)->ab_name) )); } +/* + * Helper function for do_addrbook_view() + * Converts a name into a three-letter tab label + */ +void nametab(char *tabbuf, char *name) { + stresc(tabbuf, name, 0, 0); + tabbuf[0] = toupper(tabbuf[0]); + tabbuf[1] = tolower(tabbuf[1]); + tabbuf[2] = tolower(tabbuf[2]); + tabbuf[3] = 0; +} + + /* * Render the address book using info we gathered during the scan */ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) { int i = 0; + int displayed = 0; int bg = 0; + static int NAMESPERPAGE = 60; + int num_pages = 0; + int page = 0; + int tabfirst = 0; + char tabfirst_label[SIZ]; + int tablast = 0; + char tablast_label[SIZ]; + + if (num_ab == 0) { + wprintf("This address book is empty.\n"); + return; + } if (num_ab > 1) { qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp); } + num_pages = num_ab / NAMESPERPAGE; + + page = atoi(bstr("page")); + + wprintf("Page: "); + for (i=0; i<=num_pages; ++i) { + if (i != page) { + wprintf("", i); + } + else { + wprintf(""); + } + tabfirst = i * NAMESPERPAGE; + tablast = tabfirst + NAMESPERPAGE - 1; + if (tablast > (num_ab - 1)) tablast = (num_ab - 1); + nametab(tabfirst_label, addrbook[tabfirst].ab_name); + nametab(tablast_label, addrbook[tablast].ab_name); + wprintf("[%s - %s]", + tabfirst_label, tablast_label + ); + if (i != page) { + wprintf("\n"); + } + else { + wprintf("\n"); + } + } + wprintf("
\n"); + wprintf("\n" ); for (i=0; i 0) { - wprintf("\n"); + if ((i / NAMESPERPAGE) == page) { + + if ((displayed % 4) == 0) { + if (displayed > 0) { + wprintf("\n"); + } + bg = 1 - bg; + wprintf("", + (bg ? "DDDDDD" : "FFFFFF") + ); } - bg = 1 - bg; - wprintf("", - (bg ? "DDDDDD" : "FFFFFF") - ); + + wprintf("\n"); + ++displayed; } - - wprintf("\n"); } wprintf("
"); + + wprintf("", bstr("alpha")); + vcard_n_prettyize(addrbook[i].ab_name); + escputs(addrbook[i].ab_name); + wprintf(""); - wprintf("", bstr("alpha")); - escputs(addrbook[i].ab_name); - wprintf("
\n"); @@ -925,18 +1066,21 @@ int load_msg_ptrs(char *servcmd) { char buf[SIZ]; int nummsgs; + int maxload = 0; nummsgs = 0; + maxload = sizeof(WC->msgarr) / sizeof(long) ; serv_puts(servcmd); serv_gets(buf); if (buf[0] != '1') { - wprintf("%s
\n", &buf[4]); + wprintf("%s
\n", &buf[4]); return (nummsgs); } while (serv_gets(buf), strcmp(buf, "000")) { - WC->msgarr[nummsgs] = atol(buf); - /* FIXME check for overflow */ - ++nummsgs; + if (nummsgs < maxload) { + WC->msgarr[nummsgs] = atol(buf); + ++nummsgs; + } } return (nummsgs); } @@ -949,7 +1093,9 @@ void readloop(char *oper) { char cmd[SIZ]; char buf[SIZ]; - int a, b, i; + char old_msgs[SIZ]; + int is_new = 0; + int a, b; int nummsgs; long startmsg; int maxmsgs; @@ -959,6 +1105,7 @@ void readloop(char *oper) int is_singlecard = 0; int is_calendar = 0; int is_tasks = 0; + int is_notes = 0; int remaining_messages; int lo, hi; int lowest_displayed = (-1); @@ -967,94 +1114,85 @@ void readloop(char *oper) long pn_current = 0L; long pn_next = 0L; int bg = 0; - char alpha = 0; - char ab_alpha = 0; struct addrbookent *addrbook = NULL; int num_ab = 0; startmsg = atol(bstr("startmsg")); maxmsgs = atoi(bstr("maxmsgs")); is_summary = atoi(bstr("summary")); - if (maxmsgs == 0) maxmsgs = 20; + if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS; - output_headers(1); + output_headers(1, 1, 1, 0, 0, 0, 0); + /* When in summary mode, always show ALL messages instead of just + * new or old. Otherwise, show what the user asked for. + */ if (!strcmp(oper, "readnew")) { strcpy(cmd, "MSGS NEW"); - } else if (!strcmp(oper, "readold")) { + } + else if (!strcmp(oper, "readold")) { strcpy(cmd, "MSGS OLD"); - } else { + } + else { strcpy(cmd, "MSGS ALL"); } - /* FIXME put in the correct constant #defs */ - if ((WC->wc_view == 1) && (maxmsgs > 1)) { + if ((WC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) { is_summary = 1; strcpy(cmd, "MSGS ALL"); - maxmsgs = 32767; } - if ((WC->wc_view == 2) && (maxmsgs > 1)) { + if ((WC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) { is_addressbook = 1; strcpy(cmd, "MSGS ALL"); maxmsgs = 32767; } - is_singlecard = atoi(bstr("is_singlecard")); - - /* Display the letter indices across the top */ - if ((is_addressbook) || (is_singlecard)) { - if (strlen(bstr("alpha")) == 0) { - alpha = 'a'; - } - else { - strcpy(buf, bstr("alpha")); - alpha = buf[0]; - } + if (is_summary) { + strcpy(cmd, "MSGS ALL"); + } - for (i='1'; i<='z'; ++i) if ((i=='1')||(islower(i))) { - if ((i != alpha) || (is_singlecard)) { - wprintf("", i); - } - if (i == alpha) wprintf(""); - if (isalpha(i)) { - wprintf("%c", toupper(i)); - } - else { - wprintf("(other)"); - } - if (i == alpha) wprintf(""); - if ((i != alpha) || (is_singlecard)) { - wprintf("\n"); - } - wprintf(" "); + /* Are we doing a summary view? If so, we need to know old messages + * and new messages, so we can do that pretty boldface thing for the + * new messages. + */ + strcpy(old_msgs, ""); + if (is_summary) { + serv_puts("GTSN"); + serv_gets(buf); + if (buf[0] == '2') { + strcpy(old_msgs, &buf[4]); } - - wprintf("
\n"); } - if (WC->wc_view == 3) { /* calendar */ + is_singlecard = atoi(bstr("is_singlecard")); + + if (WC->wc_view == VIEW_CALENDAR) { /* calendar */ is_calendar = 1; strcpy(cmd, "MSGS ALL"); maxmsgs = 32767; } - if (WC->wc_view == 4) { /* tasks */ + if (WC->wc_view == VIEW_TASKS) { /* tasks */ is_tasks = 1; strcpy(cmd, "MSGS ALL"); maxmsgs = 32767; - wprintf("\n"); + wprintf("\n"); } /* Bump these because although we're thinking in zero base, the user @@ -1159,10 +1301,10 @@ void readloop(char *oper) /* If we're only looking at one message, do a prev/next thing */ if (num_displayed == 1) { - if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_singlecard)) { + if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) { - wprintf("
" - "
" + wprintf("
" + "\n" "
" "Reading #%d of %d messages.", lowest_displayed, nummsgs); @@ -1199,74 +1341,62 @@ void readloop(char *oper) oper, WC->msgarr[0]); - wprintf("
\n"); + wprintf("
\n"); } } - /* * If we're not currently looking at ALL requested * messages, then display the selector bar */ if (num_displayed > 1) { - if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_singlecard)) { - wprintf("
" - "\n" - "
" - "Reading #%d-%d of %d messages.", - lowest_displayed, highest_displayed, nummsgs); + if ((!is_tasks) && (!is_calendar) && (!is_addressbook) + && (!is_notes) && (!is_singlecard)) { - if (is_summary) { - wprintf("\n"); - } + wprintf("Reading #", lowest_displayed, highest_displayed); + wprintf(" of %d messages.", nummsgs); + + if (is_summary) { + wprintf("\n"); + } - wprintf("
\n"); } } - if (is_summary) wprintf("\n"); + wprintf("\n"); DONE: if (is_tasks) { - wprintf("" - "Add new task\n" - ); + do_tasks_view(); /* Render the task list */ } if (is_calendar) { @@ -1293,12 +1423,7 @@ void post_mime_to_server(void) { struct wc_attachment *att; char *encoded; size_t encoded_length; - int is_html = 0; - if (!strcasecmp(bstr("msg_format"), "html")) { - is_html = 1; - } - /* If there are attachments, we have to do multipart/mixed */ if (WC->first_attachment != NULL) { is_multipart = 1; @@ -1321,12 +1446,7 @@ void post_mime_to_server(void) { serv_puts("Content-type: text/html"); serv_puts(""); serv_puts("\n"); - if (is_html) { - text_to_server(bstr("msgtext"), 0); - } - else { - text_to_server(bstr("msgtext"), 1); - } + text_to_server(bstr("msgtext"), 0); serv_puts("\n"); @@ -1373,17 +1493,27 @@ void post_message(void) { char buf[SIZ]; static long dont_post = (-1L); - struct wc_attachment *att; + struct wc_attachment *att, *aptr; if (WC->upload_length > 0) { + /* There's an attachment. Save it to this struct... */ att = malloc(sizeof(struct wc_attachment)); memset(att, 0, sizeof(struct wc_attachment)); - att->next = WC->first_attachment; - WC->first_attachment = att; att->length = WC->upload_length; strcpy(att->content_type, WC->upload_content_type); strcpy(att->filename, WC->upload_filename); + att->next = NULL; + + /* And add it to the list. */ + if (WC->first_attachment == NULL) { + WC->first_attachment = att; + } + else { + aptr = WC->first_attachment; + while (aptr->next != NULL) aptr = aptr->next; + aptr->next = att; + } /* Netscape sends a simple filename, which is what we want, * but Satan's browser sends an entire pathname. Reduce @@ -1406,9 +1536,12 @@ void post_message(void) return; } - if (strcasecmp(bstr("sc"), "Save message")) { + if (!strcasecmp(bstr("sc"), "Cancel")) { sprintf(WC->ImportantMessage, "Cancelled. Message was not posted."); + } else if (!strcasecmp(bstr("attach"), "Add")) { + display_enter(); + return; } else if (atol(bstr("postseq")) == dont_post) { sprintf(WC->ImportantMessage, "Automatically cancelled because you have already " @@ -1421,8 +1554,12 @@ void post_message(void) serv_gets(buf); if (buf[0] == '4') { post_mime_to_server(); - sprintf(WC->ImportantMessage, - "Message has been posted.\n"); + if (strlen(bstr("recp")) > 0) { + sprintf(WC->ImportantMessage, "Message has been sent.\n"); + } + else { + sprintf(WC->ImportantMessage, "Message has been posted.\n"); + } dont_post = atol(bstr("postseq")); } else { sprintf(WC->ImportantMessage, @@ -1447,19 +1584,44 @@ void display_enter(void) struct wc_attachment *att; if (strlen(bstr("force_room")) > 0) { - gotoroom(bstr("force_room"), 0); + gotoroom(bstr("force_room")); } /* Are we perhaps in an address book view? If so, then an "enter * message" command really means "add new entry." */ - if (WC->wc_view == 2) { + if (WC->wc_view == VIEW_ADDRESSBOOK) { do_edit_vcard(-1, "", ""); return; } - /* Otherwise proceed normally */ - output_headers(1); +#ifdef WEBCIT_WITH_CALENDAR_SERVICE + /* Are we perhaps in a calendar view? If so, then an "enter + * message" command really means "add new calendar item." + */ + if (WC->wc_view == VIEW_CALENDAR) { + display_edit_event(); + return; + } + + /* Are we perhaps in a tasks view? If so, then an "enter + * message" command really means "add new task." + */ + if (WC->wc_view == VIEW_TASKS) { + display_edit_task(); + return; + } +#endif + + /* Otherwise proceed normally. Do a custom room banner with no navbar... */ + output_headers(1, 1, 2, 0, 0, 0, 0); + wprintf("
\n"); + embed_room_banner(NULL, navbar_none); + wprintf("
\n"); + wprintf("
\n" + "
" + "
"); + sprintf(buf, "ENT0 0|%s|0|0", bstr("recp")); serv_puts(buf); serv_gets(buf); @@ -1467,7 +1629,7 @@ void display_enter(void) if (!strncmp(buf, "570", 3)) { if (strlen(bstr("recp")) > 0) { svprintf("RECPERROR", WCS_STRING, - "%s
\n", + "%s
\n", &buf[4] ); } @@ -1475,7 +1637,7 @@ void display_enter(void) goto DONE; } if (buf[0] != '2') { - wprintf("%s
\n", &buf[4]); + wprintf("%s
\n", &buf[4]); goto DONE; } @@ -1489,43 +1651,42 @@ void display_enter(void) } strcat(&buf[strlen(buf)], " in "); stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1); - svprintf("BOXTITLE", WCS_STRING, buf); - do_template("beginbox"); - wprintf("
\n"); + /* begin message entry screen */ + // wprintf("
\n"); - wprintf("
\n"); - wprintf("\n", + wprintf("\n", bstr("recp")); - wprintf("\n", + wprintf("\n", now); - wprintf("\""); + + wprintf("%s
\n", buf); /* header bar */ + wprintf("\""); /* "onLoad=\"document.enterform.msgtext.focus();\" " */ - wprintf("Subject (optional):" - "Subject (optional):" + "" + wprintf("\" size=40 maxlength=70>" " " ); - wprintf("text \n"); - - wprintf("HTML \n"); - - wprintf("" - "
\n"); + wprintf(" 0) { + wprintf("Send message"); + } else { + wprintf("Post message"); + } + wprintf("\"> " + "\n"); - wprintf("\n" - "\n" + " \n" - " \n" - " \n"); - -/* - wprintf("
\n"); -*/ + wprintf("', '96%%', '200', true, false); \n" + "

\n"); /* Enumerate any attachments which are already in place... */ + wprintf(" Attachments: "); + wprintf(""); /* Now offer the ability to attach additional files... */ wprintf("   " "Attach file: \n  " + "SIZE=16 TYPE=\"file\">\n  " "\n"); - wprintf("\n"); - do_template("endbox"); + wprintf("\n"); + + wprintf("
\n"); DONE: wDumpContent(1); } @@ -1581,12 +1741,12 @@ void delete_msg(void) msgid = atol(bstr("msgid")); - output_headers(1); + output_headers(1, 1, 1, 0, 0, 0, 0); sprintf(buf, "DELE %ld", msgid); serv_puts(buf); serv_gets(buf); - wprintf("%s
\n", &buf[4]); + wprintf("%s
\n", &buf[4]); wDumpContent(1); } @@ -1605,18 +1765,19 @@ void confirm_move_msg(void) msgid = atol(bstr("msgid")); - output_headers(1); + output_headers(1, 1, 1, 0, 0, 0, 0); - wprintf("
"); - wprintf("Confirm move of message\n"); - wprintf("
\n"); + wprintf("
" + "
"); + wprintf("Confirm move of message\n"); + wprintf("
\n"); wprintf("
"); - wprintf("Please select the room to which you would like this message moved:
\n"); + wprintf("Move this message to:
\n"); - wprintf("
\n"); + wprintf("\n"); wprintf("\n", bstr("msgid")); @@ -1626,18 +1787,19 @@ void confirm_move_msg(void) serv_gets(buf); if (buf[0] == '1') { while (serv_gets(buf), strcmp(buf, "000")) { - extract(targ, buf, 0); + extract_token(targ, buf, 0, '|', sizeof targ); wprintf("
\n"); + wprintf("
\n"); wprintf("\n"); wDumpContent(1); @@ -1652,22 +1814,25 @@ void move_msg(void) msgid = atol(bstr("msgid")); - output_headers(1); + output_headers(1, 1, 1, 0, 0, 0, 0); if (!strcasecmp(bstr("yesno"), "Move")) { sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room")); serv_puts(buf); serv_gets(buf); - wprintf("%s
\n", &buf[4]); + wprintf("%s
\n", &buf[4]); } else { - wprintf("Message not moved.
\n"); + wprintf("Message not moved.
\n"); } wDumpContent(1); } - - +/* + * This gets called when a user selects multiple messages in a summary + * list and then clicks to perform a transformation of some sort on them + * (such as deleting them). + */ void do_stuff_to_msgs(void) { char buf[SIZ]; char sc[SIZ];