X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=123c894602f681d00ffb3ee84d602b5e2d47e150;hb=f6f51307f975c67d86448d5b456f9650dc36d773;hp=d6b96e426e72e7096250f4635fb4aed4ecec08a9;hpb=ac4f337758baa19f662e16be316fdcf006e3d4ef;p=citadel.git diff --git a/webcit/messages.c b/webcit/messages.c index d6b96e426..123c89460 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)) { @@ -577,19 +579,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 */ @@ -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,11 +649,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 { @@ -702,14 +705,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("" "" @@ -815,6 +826,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]; @@ -862,6 +874,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")); + escputs(addrbook[i].ab_name); + wprintf(""); - wprintf("", bstr("alpha")); - escputs(addrbook[i].ab_name); - wprintf("
\n"); @@ -931,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")) { @@ -951,7 +1028,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; @@ -961,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); @@ -969,8 +1049,6 @@ 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; @@ -979,20 +1057,24 @@ 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. + */ 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"); } if ((WC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) { is_summary = 1; strcpy(cmd, "MSGS ALL"); - /* maxmsgs = 32767; */ } if ((WC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) { @@ -1001,39 +1083,25 @@ void readloop(char *oper) 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"); } + is_singlecard = atoi(bstr("is_singlecard")); + if (WC->wc_view == VIEW_CALENDAR) { /* calendar */ is_calendar = 1; strcpy(cmd, "MSGS ALL"); @@ -1043,20 +1111,23 @@ void readloop(char *oper) 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 @@ -1161,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); @@ -1201,74 +1276,69 @@ void readloop(char *oper) oper, WC->msgarr[0]); - wprintf("
\n"); + wprintf("
\n"); } } - finished = time(NULL); /* * 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("
\n"); + wprintf(" of %d messages.", nummsgs); + + if (is_summary) { + wprintf("\n"); + } + } } if (is_summary) wprintf("\n"); DONE: if (is_tasks) { - wprintf("" - "Add new task\n" - ); + do_tasks_view(); /* Render the task list */ } if (is_calendar) { @@ -1426,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, @@ -1452,19 +1526,42 @@ 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); @@ -1472,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] ); } @@ -1480,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; } @@ -1494,35 +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("\""); + + wprintf("%s
\n", buf); /* header bar */ + wprintf("\""); /* "onLoad=\"document.enterform.msgtext.focus();\" " */ - wprintf("Subject (optional):" - "Subject (optional):" + "" + wprintf("\" size=40 maxlength=70>" " " ); - wprintf("" - "
\n"); + wprintf(" 0) { + wprintf("Send message"); + } else { + wprintf("Post message"); + } + wprintf("\"> " + "\n"); + + /* begin richedit box */ + 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); } @@ -1580,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); } @@ -1604,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("Please select the room to which you would like this message moved:
\n"); + wprintf("Move this message to:
\n"); wprintf("
\n"); wprintf("\n", @@ -1632,9 +1744,10 @@ void confirm_move_msg(void) } } wprintf("\n"); - wprintf("
\n"); + wprintf("
\n"); wprintf(""); + wprintf(" "); wprintf(""); wprintf("
\n"); @@ -1651,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];