}
+/*
+ * 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; i<strlen(original_name); ++i) {
+ if (original_name[i] == ';') {
+ strcat(name, ", ");
+ }
+ else {
+ name[strlen(name)+1] = 0;
+ name[strlen(name)] = original_name[i];
+ }
+ }
+ free(original_name);
+}
+
+
+
+
/* display_vcard() calls this after parsing the textual vCard into
* our 'struct vCard' data object.
* This gets called instead of display_parsed_vcard() if we are only looking
* to extract the person's name instead of displaying the card.
*/
void fetchname_parsed_vcard(struct vCard *v, char *storename) {
- int i;
+ char *name;
strcpy(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;
- }
- }
- }
+
+ name = vcard_get_prop(v, "n", 1, 0, 0);
+ if (name != NULL) {
+ strcpy(storename, name);
+ /* vcard_n_prettyize(storename); */
}
+
}
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("<TD>");
escputs(name);
}
else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
- escputs(name);
+ strcpy(displayname, name);
+ vcard_n_prettyize(displayname);
+ escputs(displayname);
}
else {
wprintf(" ");
return;
}
- wprintf("<TABLE bgcolor=#888888>");
+ wprintf("<div align=center><table bgcolor=#aaaaaa width=50%%>");
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<num_tokens(thisname, ';'); ++j) {
- extract_token(buf, thisname, j, ';');
+ extract_token(buf, thisname, j, ';', sizeof buf);
if (!strcasecmp(buf, "encoding=quoted-printable")) {
is_qp = 1;
remove_token(thisname, j, ';');
if (!strcasecmp(firsttoken, "n")) {
if (strlen(displayname) == 0) {
strcpy(displayname, thisvalue);
+ vcard_n_prettyize(displayname);
}
}
else if (!strcasecmp(firsttoken, "fn")) {
strcpy(displayname, thisvalue);
}
+
+ /* title */
+ else if (!strcasecmp(firsttoken, "title")) {
+ strcpy(title, thisvalue);
+ }
+
+ /* organization */
+ else if (!strcasecmp(firsttoken, "org")) {
+ strcpy(org, thisvalue);
+ }
else if (!strcasecmp(firsttoken, "email")) {
if (strlen(mailto) > 0) strcat(mailto, "<br />");
if (strlen(phone) > 0) strcat(phone, "<br />");
strcat(phone, thisvalue);
for (j=0; j<num_tokens(thisname, ';'); ++j) {
- extract_token(buf, thisname, j, ';');
+ extract_token(buf, thisname, j, ';', sizeof buf);
if (!strcasecmp(buf, "tel"))
strcat(phone, "");
else if (!strcasecmp(buf, "work"))
if (pass == 2) {
wprintf("<TR><TD>Address:</TD><TD>");
for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
- extract_token(buf, thisvalue, j, ';');
+ extract_token(buf, thisvalue, j, ';', sizeof buf);
if (strlen(buf) > 0) {
escputs(buf);
- wprintf("<br />");
+ if (j<3) wprintf("<br />");
+ else wprintf(" ");
}
}
wprintf("</TD></TR>\n");
/* ignore */
}
else {
+
+ /*** Don't show extra fields. They're ugly.
if (pass == 2) {
wprintf("<TR><TD>");
escputs(thisname);
escputs(thisvalue);
wprintf("</TD></TR>\n");
}
+ ***/
}
free(thisname);
"<IMG ALIGN=CENTER SRC=\"/static/vcard.gif\">"
"<FONT SIZE=+1><B>");
escputs(displayname);
- wprintf("</B></FONT></TD></TR>\n");
+ wprintf("</B></FONT>");
+ if (strlen(title) > 0) {
+ wprintf("<div align=right>");
+ escputs(title);
+ wprintf("</div>");
+ }
+ if (strlen(org) > 0) {
+ wprintf("<div align=right>");
+ escputs(org);
+ wprintf("</div>");
+ }
+ wprintf("</TD></TR>\n");
if (strlen(phone) > 0)
wprintf("<TR><TD>Telephone:</TD><TD>%s</TD></TR>\n", phone);
}
- wprintf("</TABLE>\n");
+ wprintf("</table></div>\n");
}
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);
}
strcpy(mime_http, "");
serv_printf("MSG4 %ld", msgnum);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') {
wprintf("<STRONG>ERROR:</STRONG> %s<br />\n", &buf[4]);
return;
wprintf("<SPAN CLASS=\"message_header\">");
strcpy(m_subject, "");
- while (serv_gets(buf), strcasecmp(buf, "text")) {
+ while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
if (!strcmp(buf, "000")) {
wprintf("<I>unexpected end of message</I><br /><br />\n");
wprintf("</SPAN>\n");
}
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")) {
wprintf("&subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
- wprintf("\">Reply</a> ");
+ wprintf("\">[Reply]</a> ");
if (WC->is_room_aide) {
/* Move */
- wprintf("<a href=\"/confirm_move_msg?msgid=%ld\">Move </a>",
+ wprintf("<a href=\"/confirm_move_msg?msgid=%ld\">[Move]</a> ",
msgnum);
/* Delete */
wprintf("<a href=\"/delete_msg?msgid=%ld\" "
"onClick=\"return confirm('Delete this message?');\">"
- "Delete</a>", msgnum);
+ "[Delete]</a>", msgnum);
}
* Learn the content type
*/
strcpy(mime_content_type, "text/plain");
- while (serv_gets(buf), (strlen(buf) > 0)) {
+ while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
if (!strcmp(buf, "000")) {
wprintf("<I>unexpected end of message</I><br /><br />\n");
goto ENDBODY;
/* Boring old 80-column fixed format text gets handled this way... */
else if (!strcasecmp(mime_content_type, "text/plain")) {
- while (serv_gets(buf), strcmp(buf, "000")) {
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
else {
wprintf("I don't know how to display %s<br />\n",
mime_content_type);
- while (serv_gets(buf), strcmp(buf, "000")) { }
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
}
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("<A HREF=\"/edit_vcard?"
"msgnum=%ld&partnum=%s\">",
msgnum, vcard_partnum);
- wprintf("(edit)</A>");
+ wprintf("[edit]</A>");
}
/* In all cases, display the full card */
sprintf(buf, "MSG0 %ld|3", msgnum); /* ask for headers only with no MIME */
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
- while (serv_gets(buf), strcmp(buf, "000")) {
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
if (!strncasecmp(buf, "from=", 5)) {
strcpy(summ.from, &buf[5]);
}
sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
- while (serv_gets(buf), strcmp(buf, "000")) {
+ while (serv_getln(buf, sizeof 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")) {
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("<A HREF=\"/edit_vcard?"
"msgnum=%ld&partnum=%s\">",
msgnum, vcard_partnum);
- wprintf("(edit)</A>");
+ wprintf("[edit]</A>");
}
free(vcard_source);
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);
sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
- while (serv_gets(buf), strcmp(buf, "000")) {
+ while (serv_getln(buf, sizeof 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")) {
wprintf("<A HREF=\"/readfwd?startmsg=%ld&is_singlecard=1",
addrbook[i].ab_msgnum);
wprintf("&maxmsgs=1&summary=0&alpha=%s\">", bstr("alpha"));
+ vcard_n_prettyize(addrbook[i].ab_name);
escputs(addrbook[i].ab_name);
wprintf("</A></TD>\n");
++displayed;
nummsgs = 0;
maxload = sizeof(WC->msgarr) / sizeof(long) ;
serv_puts(servcmd);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] != '1') {
wprintf("<EM>%s</EM><br />\n", &buf[4]);
return (nummsgs);
}
- while (serv_gets(buf), strcmp(buf, "000")) {
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
if (nummsgs < maxload) {
WC->msgarr[nummsgs] = atol(buf);
++nummsgs;
strcpy(old_msgs, "");
if (is_summary) {
serv_puts("GTSN");
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
strcpy(old_msgs, &buf[4]);
}
bstr("recp"),
bstr("subject") );
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
post_mime_to_server();
if (strlen(bstr("recp")) > 0) {
sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (!strncmp(buf, "570", 3)) {
if (strlen(bstr("recp")) > 0) {
sprintf(buf, "DELE %ld", msgid);
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
wprintf("<EM>%s</EM><br />\n", &buf[4]);
wDumpContent(1);
wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
serv_puts("LKRA");
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
- while (serv_gets(buf), strcmp(buf, "000")) {
- extract(targ, buf, 0);
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ extract_token(targ, buf, 0, '|', sizeof targ);
wprintf("<OPTION>");
escputs(targ);
wprintf("\n");
if (!strcasecmp(bstr("yesno"), "Move")) {
sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
serv_puts(buf);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
wprintf("<EM>%s</EM><br />\n", &buf[4]);
} else {
wprintf("<EM>Message not moved.</EM><br />\n");
serv_puts("MSGS ALL");
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
+ if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
ptr = malloc(sizeof(struct stuff_t));
ptr->msgnum = atol(buf);
ptr->next = stuff;
if (!strcasecmp(sc, "Delete selected")) {
serv_printf("DELE %ld", stuff->msgnum);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
}
}