X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=8a12605f7b896a10d8f257c4c3223ed2d2c45553;hb=d159f2a1a8cf9efccb8f733d7e2452c5f7cfbf64;hp=a9a07345e708ded32c5b8338b9a7aef2b049de80;hpb=dcf8a338cfd0f7b058f4ad81e6c6eaa479839d6a;p=citadel.git diff --git a/webcit/messages.c b/webcit/messages.c index a9a07345e..8a12605f7 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -103,6 +103,11 @@ void fetchname_parsed_vcard(struct vCard *v, char *storename) { if (v->numprops) for (i=0; i<(v->numprops); ++i) { if (!strcasecmp(v->prop[i].name, "n")) { strcpy(storename, v->prop[i].value); + if ((strlen(storename)>0) && (storename[0] != ';')) { + while(storename[strlen(storename)-1] == ';') { + storename[strlen(storename)-1] = 0; + } + } } } } @@ -142,10 +147,11 @@ void display_parsed_vcard(struct vCard *v, int full) { 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) { + escputs(name); } else { wprintf(" "); @@ -206,7 +212,7 @@ void display_parsed_vcard(struct vCard *v, int full) { } else if (!strcasecmp(firsttoken, "email")) { - if (strlen(mailto) > 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 0) { escputs(buf); - wprintf("
"); + wprintf("
"); } } wprintf("\n"); @@ -364,12 +370,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(""); + if (strlen(m_subject) > 0) { + wprintf("
" + "" + "Subject: %s" + "", m_subject + ); + } + wprintf("\n"); - wprintf("\n"); - - if (strlen(m_subject) > 0) { - wprintf("\n", m_subject); - } - - wprintf("
\n"); /* begin message header table */ @@ -381,7 +388,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; } @@ -447,7 +454,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,51 +505,46 @@ void read_message(long msgnum) { wprintf("****"); } - wprintf("
\n" - "\n"); + /* start msg buttons */ + wprintf("\n", msgnum); - if (WC->is_room_aide) { - wprintf("\n", msgnum); + wprintf("\n"); - wprintf("\n", msgnum); + if (WC->is_room_aide) { + wprintf("\n" + "\n"); } - wprintf("
\n"); + wprintf("
\n"); + wprintf("\n", + msgnum); + wprintf("\n"); - wprintf("
" - "\n"); } else if (strlen(m_subject) > 0) { - wprintf("&subject=Re:%%20"); + wprintf("\n"); } - wprintf("\">Reply" - "Move" - "" - "Del" - "
\n" - "
" - "" - "Subject: %s" - "" - " 
\n"); + wprintf("\n" + "\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)) { @@ -587,9 +589,9 @@ void read_message(long msgnum) { wprintf(""); url(buf); escputs(buf); - wprintf("
\n"); + wprintf("
\n"); } - wprintf("
"); + wprintf("
"); } else /* HTML is fun, but we've got to strip it first */ @@ -599,7 +601,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")) { } } @@ -647,7 +649,8 @@ ENDBODY: wprintf("
\n"); /* end everythingamundo table */ - wprintf("
\n"); + wprintf("\n"); + wprintf("\n"); } @@ -885,8 +888,8 @@ void fetch_ab_name(long msgnum, char *namebuf) { */ int abcmp(const void *ab1, const void *ab2) { return(strcasecmp( - (((const struct addrbookent *)ab1)->ab_name), - (((const struct addrbookent *)ab2)->ab_name) + (((const struct addrbookent *)ab1)->ab_name), + (((const struct addrbookent *)ab2)->ab_name) )); } @@ -955,7 +958,7 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) { wprintf("\n"); } } - wprintf("
\n"); + wprintf("
\n"); wprintf("\n" @@ -1005,7 +1008,7 @@ int load_msg_ptrs(char *servcmd) 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")) { @@ -1037,6 +1040,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); @@ -1053,7 +1057,7 @@ void readloop(char *oper) is_summary = atoi(bstr("summary")); 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. @@ -1108,11 +1112,16 @@ void readloop(char *oper) strcpy(cmd, "MSGS ALL"); maxmsgs = 32767; } + if (WC->wc_view == VIEW_NOTES) { /* notes */ + is_notes = 1; + strcpy(cmd, "MSGS ALL"); + maxmsgs = 32767; + } nummsgs = load_msg_ptrs(cmd); if (nummsgs == 0) { - if ((!is_tasks) && (!is_calendar)) { + if ((!is_tasks) && (!is_calendar) && (!is_notes)) { if (!strcmp(oper, "readnew")) { wprintf("No new messages.\n"); } else if (!strcmp(oper, "readold")) { @@ -1134,9 +1143,11 @@ void readloop(char *oper) } } + wprintf("\n"); if (is_summary) { - wprintf("\n" - "
" + "
\n" "" "" @@ -1193,6 +1204,9 @@ void readloop(char *oper) else if (is_tasks) { display_task(WC->msgarr[a]); } + else if (is_notes) { + display_note(WC->msgarr[a]); + } else { read_message(WC->msgarr[a]); } @@ -1211,7 +1225,7 @@ void readloop(char *oper) } if (is_summary) { - wprintf("
Subject
\n"); + wprintf("\n"); } /* Bump these because although we're thinking in zero base, the user @@ -1222,10 +1236,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); @@ -1262,7 +1276,7 @@ void readloop(char *oper) oper, WC->msgarr[0]); - wprintf("
\n"); + wprintf("
\n"); } } @@ -1271,55 +1285,53 @@ void readloop(char *oper) * 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("
\n"); + wprintf(" of %d messages.", nummsgs); + + if (is_summary) { + wprintf("\n"); + } + } } if (is_summary) wprintf("\n"); @@ -1484,8 +1496,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, @@ -1510,7 +1526,7 @@ 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 @@ -1521,6 +1537,7 @@ void display_enter(void) return; } +#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." */ @@ -1536,9 +1553,15 @@ void display_enter(void) 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"); - /* Otherwise proceed normally */ - output_headers(1); sprintf(buf, "ENT0 0|%s|0|0", bstr("recp")); serv_puts(buf); serv_gets(buf); @@ -1546,7 +1569,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] ); } @@ -1554,7 +1577,7 @@ void display_enter(void) goto DONE; } if (buf[0] != '2') { - wprintf("%s
\n", &buf[4]); + wprintf("%s
\n", &buf[4]); goto DONE; } @@ -1568,42 +1591,46 @@ 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("\n"); - wprintf(""); - wprintf("
"); - wprintf("\""); + wprintf("%s
\n", buf); /* header bar */ + wprintf("\""); /* "onLoad=\"document.enterform.msgtext.focus();\" " */ - wprintf("Subject (optional):" - "Subject (optional):" + "" + wprintf("\" size=40 maxlength=70>" " " ); - wprintf("
"); - wprintf("" - " " - "
\n"); - wprintf("
\n"); + wprintf(" 0) { + wprintf("Send message"); + } else { + wprintf("Post message"); + } + wprintf("\"> " + "\n"); - wprintf("\n" - "\n" + " \n" - " \n" - " \n"); + wprintf("
\n"); /* end richedit box */ -/* - * Before we had the richedit widget, we did it this way... - * - wprintf("
\n"); - */ + /* Here comes the "do attachments" section on the bottom */ + wprintf("
\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"); /* end attachments section */ + + wprintf("\n"); + + wprintf("\n"); DONE: wDumpContent(1); } @@ -1661,12 +1691,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); } @@ -1685,16 +1715,17 @@ 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("Move this message to:
\n"); + wprintf("Move this message to:
\n"); wprintf("
\n"); wprintf("\n", @@ -1713,7 +1744,7 @@ void confirm_move_msg(void) } } wprintf("\n"); - wprintf("
\n"); + wprintf("
\n"); wprintf(""); wprintf(" "); @@ -1733,22 +1764,51 @@ 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 Reply/Move/Del etc. on *one* message. + */ +void do_stuff_to_one_msg(void) { + char *msg_oper; + + msg_oper = bstr("msg_oper"); + + if (!strcasecmp(msg_oper, "Delete")) { + delete_msg(); /* It's already been confirmed using JS */ + return; + } + if (!strcasecmp(msg_oper, "Move")) { + confirm_move_msg(); + return; + } + if (!strcasecmp(msg_oper, "Reply")) { + display_enter(); /* recp and subject already set */ + return; + } + + /* should never get here. FIXME: display an error */ + +} +/* + * 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];