9 * \brief Record compare function for sorting address book indices
10 * \param ab1 adressbook one
11 * \param ab2 adressbook two
13 int abcmp(const void *ab1, const void *ab2) {
15 (((const addrbookent *)ab1)->ab_name),
16 (((const addrbookent *)ab2)->ab_name)
22 * \brief Helper function for do_addrbook_view()
23 * Converts a name into a three-letter tab label
24 * \param tabbuf the tabbuffer to add name to
25 * \param name the name to add to the tabbuffer
27 void nametab(char *tabbuf, long len, char *name) {
28 stresc(tabbuf, len, name, 0, 0);
29 tabbuf[0] = toupper(tabbuf[0]);
30 tabbuf[1] = tolower(tabbuf[1]);
31 tabbuf[2] = tolower(tabbuf[2]);
38 * \brief Turn a vCard "n" (name) field into something displayable.
39 * \param name the name field to convert
41 void vcard_n_prettyize(char *name)
46 original_name = strdup(name);
47 len = strlen(original_name);
50 if (original_name[len-1] == ' ') {
51 original_name[--len] = 0;
53 if (original_name[len-1] == ';') {
54 original_name[--len] = 0;
60 for (i=0; i<len; ++i) {
61 if (original_name[i] == ';') {
66 name[j++] = original_name[i];
77 * \brief preparse a vcard name
78 * display_vcard() calls this after parsing the textual vCard into
79 * our 'struct vCard' data object.
80 * This gets called instead of display_parsed_vcard() if we are only looking
81 * to extract the person's name instead of displaying the card.
82 * \param v the vcard to retrieve the name from
83 * \param storename where to put the name at
85 void fetchname_parsed_vcard(struct vCard *v, char *storename) {
88 strcpy(storename, "");
90 name = vcard_get_prop(v, "n", 1, 0, 0);
92 strcpy(storename, name);
93 /* vcard_n_prettyize(storename); */
101 * \brief html print a vcard
102 * display_vcard() calls this after parsing the textual vCard into
103 * our 'struct vCard' data object.
105 * Set 'full' to nonzero to display the full card, otherwise it will only
106 * show a summary line.
108 * This code is a bit ugly, so perhaps an explanation is due: we do this
109 * in two passes through the vCard fields. On the first pass, we process
110 * fields we understand, and then render them in a pretty fashion at the
111 * end. Then we make a second pass, outputting all the fields we don't
112 * understand in a simple two-column name/value format.
113 * \param v the vCard to display
114 * \param full display all items of the vcard?
115 * \param msgnum Citadel message pointer
117 void display_parsed_vcard(StrBuf *Target, struct vCard *v, int full, long msgnum) {
123 char *thisname, *thisvalue;
124 char firsttoken[SIZ];
133 strcpy(fullname, "");
140 StrBufAppendPrintf(Target, "<TD>");
141 name = vcard_get_prop(v, "fn", 1, 0, 0);
143 StrEscAppend(Target, NULL, name, 0, 0);
145 else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
146 strcpy(fullname, name);
147 vcard_n_prettyize(fullname);
148 StrEscAppend(Target, NULL, fullname, 0, 0);
151 StrBufAppendPrintf(Target, " ");
153 StrBufAppendPrintf(Target, "</TD>");
157 StrBufAppendPrintf(Target, "<div align=center>"
158 "<table bgcolor=#aaaaaa width=50%%>");
159 for (pass=1; pass<=2; ++pass) {
161 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
163 thisname = strdup(v->prop[i].name);
164 extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
166 for (j=0; j<num_tokens(thisname, ';'); ++j) {
167 extract_token(buf, thisname, j, ';', sizeof buf);
168 if (!strcasecmp(buf, "encoding=quoted-printable")) {
170 remove_token(thisname, j, ';');
172 if (!strcasecmp(buf, "encoding=base64")) {
174 remove_token(thisname, j, ';');
178 len = strlen(v->prop[i].value);
179 /* if we have some untagged QP, detect it here. */
180 if (!is_qp && (strstr(v->prop[i].value, "=?")!=NULL))
181 utf8ify_rfc822_string(v->prop[i].value);
184 // %ff can become 6 bytes in utf8
185 thisvalue = malloc(len * 2 + 3);
186 j = CtdlDecodeQuotedPrintable(
187 thisvalue, v->prop[i].value,
192 // ff will become one byte..
193 thisvalue = malloc(len + 50);
195 thisvalue, v->prop[i].value,
196 strlen(v->prop[i].value) );
199 thisvalue = strdup(v->prop[i].value);
202 /** Various fields we may encounter ***/
204 /** N is name, but only if there's no FN already there */
205 if (!strcasecmp(firsttoken, "n")) {
206 if (IsEmptyStr(fullname)) {
207 strcpy(fullname, thisvalue);
208 vcard_n_prettyize(fullname);
212 /** FN (full name) is a true 'display name' field */
213 else if (!strcasecmp(firsttoken, "fn")) {
214 strcpy(fullname, thisvalue);
218 else if (!strcasecmp(firsttoken, "title")) {
219 strcpy(title, thisvalue);
223 else if (!strcasecmp(firsttoken, "org")) {
224 strcpy(org, thisvalue);
227 else if (!strcasecmp(firsttoken, "email")) {
229 if (!IsEmptyStr(mailto)) strcat(mailto, "<br />");
231 "<a href=\"display_enter"
232 "?force_room=_MAIL_?recp=");
234 len = strlen(mailto);
235 urlesc(&mailto[len], SIZ - len, "\"");
236 len = strlen(mailto);
237 urlesc(&mailto[len], SIZ - len, fullname);
238 len = strlen(mailto);
239 urlesc(&mailto[len], SIZ - len, "\" <");
240 len = strlen(mailto);
241 urlesc(&mailto[len], SIZ - len, thisvalue);
242 len = strlen(mailto);
243 urlesc(&mailto[len], SIZ - len, ">");
245 strcat(mailto, "\">");
246 len = strlen(mailto);
247 stresc(mailto+len, SIZ - len, thisvalue, 1, 1);
248 strcat(mailto, "</A>");
250 else if (!strcasecmp(firsttoken, "tel")) {
251 if (!IsEmptyStr(phone)) strcat(phone, "<br />");
252 strcat(phone, thisvalue);
253 for (j=0; j<num_tokens(thisname, ';'); ++j) {
254 extract_token(buf, thisname, j, ';', sizeof buf);
255 if (!strcasecmp(buf, "tel"))
257 else if (!strcasecmp(buf, "work"))
258 strcat(phone, _(" (work)"));
259 else if (!strcasecmp(buf, "home"))
260 strcat(phone, _(" (home)"));
261 else if (!strcasecmp(buf, "cell"))
262 strcat(phone, _(" (cell)"));
270 else if (!strcasecmp(firsttoken, "adr")) {
272 StrBufAppendPrintf(Target, "<TR><TD>");
273 StrBufAppendPrintf(Target, _("Address:"));
274 StrBufAppendPrintf(Target, "</TD><TD>");
275 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
276 extract_token(buf, thisvalue, j, ';', sizeof buf);
277 if (!IsEmptyStr(buf)) {
278 StrEscAppend(Target, NULL, buf, 0, 0);
279 if (j<3) StrBufAppendPrintf(Target, "<br />");
280 else StrBufAppendPrintf(Target, " ");
283 StrBufAppendPrintf(Target, "</TD></TR>\n");
286 /* else if (!strcasecmp(firsttoken, "photo") && full && pass == 2) {
287 // Only output on second pass
288 StrBufAppendPrintf(Target, "<tr><td>");
289 StrBufAppendPrintf(Target, _("Photo:"));
290 StrBufAppendPrintf(Target, "</td><td>");
291 StrBufAppendPrintf(Target, "<img src=\"/vcardphoto/%ld/\" alt=\"Contact photo\"/>",msgnum);
292 StrBufAppendPrintf(Target, "</td></tr>\n");
294 else if (!strcasecmp(firsttoken, "version")) {
297 else if (!strcasecmp(firsttoken, "rev")) {
300 else if (!strcasecmp(firsttoken, "label")) {
305 /*** Don't show extra fields. They're ugly.
307 StrBufAppendPrintf(Target, "<TR><TD>");
308 StrEscAppend(Target, NULL, thisname, 0, 0);
309 StrBufAppendPrintf(Target, "</TD><TD>");
310 StrEscAppend(Target, NULL, thisvalue, 0, 0);
311 StrBufAppendPrintf(Target, "</TD></TR>\n");
321 StrBufAppendPrintf(Target, "<TR BGCOLOR=\"#AAAAAA\">"
322 "<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
323 "<IMG ALIGN=CENTER src=\"static/viewcontacts_48x.gif\">"
324 "<FONT SIZE=+1><B>");
325 StrEscAppend(Target, NULL, fullname, 0, 0);
326 StrBufAppendPrintf(Target, "</B></FONT>");
327 if (!IsEmptyStr(title)) {
328 StrBufAppendPrintf(Target, "<div align=right>");
329 StrEscAppend(Target, NULL, title, 0, 0);
330 StrBufAppendPrintf(Target, "</div>");
332 if (!IsEmptyStr(org)) {
333 StrBufAppendPrintf(Target, "<div align=right>");
334 StrEscAppend(Target, NULL, org, 0, 0);
335 StrBufAppendPrintf(Target, "</div>");
337 StrBufAppendPrintf(Target, "</TD></TR>\n");
339 if (!IsEmptyStr(phone)) {
340 StrBufAppendPrintf(Target, "<tr><td>");
341 StrBufAppendPrintf(Target, _("Telephone:"));
342 StrBufAppendPrintf(Target, "</td><td>%s</td></tr>\n", phone);
344 if (!IsEmptyStr(mailto)) {
345 StrBufAppendPrintf(Target, "<tr><td>");
346 StrBufAppendPrintf(Target, _("E-mail:"));
347 StrBufAppendPrintf(Target, "</td><td>%s</td></tr>\n", mailto);
353 StrBufAppendPrintf(Target, "</table></div>\n");
359 * \brief Display a textual vCard
360 * (Converts to a vCard object and then calls the actual display function)
361 * Set 'full' to nonzero to display the whole card instead of a one-liner.
362 * Or, if "storename" is non-NULL, just store the person's name in that
363 * buffer instead of displaying the card at all.
364 * \param vcard_source the buffer containing the vcard text
365 * \param alpha what???
366 * \param full should we usse all lines?
367 * \param storename where to store???
368 * \param msgnum Citadel message pointer
370 void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int full, char *storename,
377 v = vcard_load((char*)vcard_source); ///TODO
379 if (v == NULL) return;
381 name = vcard_get_prop(v, "n", 1, 0, 0);
383 utf8ify_rfc822_string(name);
388 if (storename != NULL) {
389 fetchname_parsed_vcard(v, storename);
391 else if ( (alpha == 0)
392 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
393 || ((!isalpha(alpha)) && (!isalpha(this_alpha)))
395 display_parsed_vcard(Target, v, full,msgnum);
404 * \brief Render the address book using info we gathered during the scan
405 * \param addrbook the addressbook to render
406 * \param num_ab the number of the addressbook
408 void do_addrbook_view(addrbookent *addrbook, int num_ab) {
412 static int NAMESPERPAGE = 60;
415 char tabfirst_label[64];
417 char tablast_label[64];
418 char this_tablabel[64];
423 wprintf("<br /><br /><br /><div align=\"center\"><i>");
424 wprintf(_("This address book is empty."));
425 wprintf("</i></div>\n");
430 qsort(addrbook, num_ab, sizeof(addrbookent), abcmp);
433 num_pages = (num_ab / NAMESPERPAGE) + 1;
435 tablabels = malloc(num_pages * sizeof (char *));
436 if (tablabels == NULL) {
437 wprintf("<br /><br /><br /><div align=\"center\"><i>");
438 wprintf(_("An internal error has occurred."));
439 wprintf("</i></div>\n");
443 for (i=0; i<num_pages; ++i) {
444 tabfirst = i * NAMESPERPAGE;
445 tablast = tabfirst + NAMESPERPAGE - 1;
446 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
447 nametab(tabfirst_label, 64, addrbook[tabfirst].ab_name);
448 nametab(tablast_label, 64, addrbook[tablast].ab_name);
449 sprintf(this_tablabel, "%s - %s", tabfirst_label, tablast_label);
450 tablabels[i] = strdup(this_tablabel);
453 tabbed_dialog(num_pages, tablabels);
456 for (i=0; i<num_ab; ++i) {
458 if ((i / NAMESPERPAGE) != page) { /* New tab */
459 page = (i / NAMESPERPAGE);
461 wprintf("</tr></table>\n");
462 end_tab(page-1, num_pages);
464 begin_tab(page, num_pages);
465 wprintf("<table border=0 cellspacing=0 cellpadding=3 width=100%%>\n");
469 if ((displayed % 4) == 0) {
474 wprintf("<tr bgcolor=\"#%s\">",
475 (bg ? "DDDDDD" : "FFFFFF")
481 wprintf("<a href=\"readfwd?startmsg=%ld?is_singlecard=1",
482 addrbook[i].ab_msgnum);
483 wprintf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
484 vcard_n_prettyize(addrbook[i].ab_name);
485 escputs(addrbook[i].ab_name);
486 wprintf("</a></td>\n");
490 /* Placeholders for empty columns at end */
491 if ((num_ab % 4) != 0) {
492 for (i=0; i<(4-(num_ab % 4)); ++i) {
493 wprintf("<td> </td>");
497 wprintf("</tr></table>\n");
498 end_tab((num_pages-1), num_pages);
500 begin_tab(num_pages, num_pages);
501 /* FIXME there ought to be something here */
502 end_tab(num_pages, num_pages);
504 for (i=0; i<num_pages; ++i) {
514 * Edit the vCard component of a MIME message.
515 * Supply the message number
516 * and MIME part number to fetch. Or, specify -1 for the message number
517 * to start with a blank card.
519 void do_edit_vcard(long msgnum, char *partnum, char *return_to, char *force_room) {
521 char *serialized_vcard = NULL;
522 size_t total_len = 0;
530 char middlename[256];
544 char primary_inetemail[256];
545 char other_inetemail[SIZ];
546 char extrafields[SIZ];
567 primary_inetemail[0] = 0;
568 other_inetemail[0] = 0;
574 safestrncpy(whatuser, "", sizeof whatuser);
577 sprintf(buf, "MSG0 %ld|1", msgnum);
579 serv_getln(buf, sizeof buf);
581 convenience_page("770000", _("Error"), &buf[4]);
584 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
585 if (!strncasecmp(buf, "from=", 5)) {
586 safestrncpy(whatuser, &buf[5], sizeof whatuser);
588 else if (!strncasecmp(buf, "node=", 5)) {
589 strcat(whatuser, " @ ");
590 strcat(whatuser, &buf[5]);
594 sprintf(buf, "DLAT %ld|%s", msgnum, partnum);
596 serv_getln(buf, sizeof buf);
598 convenience_page("770000", "Error", &buf[4]);
602 total_len = atoi(&buf[4]);
603 serialized_vcard = malloc(total_len + 2);
605 serv_read(serialized_vcard, total_len);
606 serialized_vcard[total_len] = 0;
608 v = vcard_load(serialized_vcard);
609 free(serialized_vcard);
611 /* Populate the variables for our form */
613 while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) {
614 value = vcard_get_prop(v, "", 0, i++, 0);
616 if (!strcasecmp(key, "n")) {
617 extract_token(lastname, value, 0, ';', sizeof lastname);
618 extract_token(firstname, value, 1, ';', sizeof firstname);
619 extract_token(middlename, value, 2, ';', sizeof middlename);
620 extract_token(prefix, value, 3, ';', sizeof prefix);
621 extract_token(suffix, value, 4, ';', sizeof suffix);
624 else if (!strcasecmp(key, "fn")) {
625 safestrncpy(fullname, value, sizeof fullname);
628 else if (!strcasecmp(key, "title")) {
629 safestrncpy(title, value, sizeof title);
632 else if (!strcasecmp(key, "org")) {
633 safestrncpy(org, value, sizeof org);
636 else if ( (!strcasecmp(key, "adr")) || (!strncasecmp(key, "adr;", 4)) ) {
637 extract_token(pobox, value, 0, ';', sizeof pobox);
638 extract_token(extadr, value, 1, ';', sizeof extadr);
639 extract_token(street, value, 2, ';', sizeof street);
640 extract_token(city, value, 3, ';', sizeof city);
641 extract_token(state, value, 4, ';', sizeof state);
642 extract_token(zipcode, value, 5, ';', sizeof zipcode);
643 extract_token(country, value, 6, ';', sizeof country);
646 else if ( (!strcasecmp(key, "tel;home")) || (!strcasecmp(key, "tel;type=home")) ) {
647 extract_token(hometel, value, 0, ';', sizeof hometel);
650 else if ( (!strcasecmp(key, "tel;work")) || (!strcasecmp(key, "tel;type=work")) ) {
651 extract_token(worktel, value, 0, ';', sizeof worktel);
654 else if ( (!strcasecmp(key, "tel;fax")) || (!strcasecmp(key, "tel;type=fax")) ) {
655 extract_token(faxtel, value, 0, ';', sizeof faxtel);
658 else if ( (!strcasecmp(key, "tel;cell")) || (!strcasecmp(key, "tel;type=cell")) ) {
659 extract_token(mobiletel, value, 0, ';', sizeof mobiletel);
662 else if ( (!strcasecmp(key, "email;internet"))
663 || (!strcasecmp(key, "email;type=internet")) ) {
664 if (primary_inetemail[0] == 0) {
665 safestrncpy(primary_inetemail, value, sizeof primary_inetemail);
668 if (other_inetemail[0] != 0) {
669 strcat(other_inetemail, "\n");
671 strcat(other_inetemail, value);
676 strcat(extrafields, key);
677 strcat(extrafields, ":");
678 strcat(extrafields, value);
679 strcat(extrafields, "\n");
687 /** Display the form */
688 output_headers(1, 1, 1, 0, 0, 0);
690 svput("BOXTITLE", WCS_STRING, _("Edit contact information"));
691 do_template("beginboxx", NULL);
693 wprintf("<form method=\"POST\" action=\"submit_vcard\">\n");
694 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
696 if (force_room != NULL) {
697 wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
702 wprintf("<div class=\"fix_scrollbar_bug\">"
703 "<table class=\"vcard_edit_background\"><tr><td>\n");
705 wprintf("<table border=0><tr>"
710 "<td>%s</td></tr>\n",
711 _("Prefix"), _("First"), _("Middle"), _("Last"), _("Suffix")
713 wprintf("<tr><td><input type=\"text\" name=\"prefix\" "
714 "value=\"%s\" maxlength=\"5\" size=\"5\"></td>",
716 wprintf("<td><input type=\"text\" name=\"firstname\" "
717 "value=\"%s\" maxlength=\"29\"></td>",
719 wprintf("<td><input type=\"text\" name=\"middlename\" "
720 "value=\"%s\" maxlength=\"29\"></td>",
722 wprintf("<td><input type=\"text\" name=\"lastname\" "
723 "value=\"%s\" maxlength=\"29\"></td>",
725 wprintf("<td><input type=\"text\" name=\"suffix\" "
726 "value=\"%s\" maxlength=\"10\" size=\"10\"></td></tr></table>\n",
729 wprintf("<table class=\"vcard_edit_background_alt\">");
732 wprintf(_("Display name:"));
734 "<input type=\"text\" name=\"fullname\" "
735 "value=\"%s\" maxlength=\"40\"><br><br>\n",
739 wprintf(_("Title:"));
741 "<input type=\"text\" name=\"title\" "
742 "value=\"%s\" maxlength=\"40\"><br><br>\n",
746 wprintf(_("Organization:"));
748 "<input type=\"text\" name=\"org\" "
749 "value=\"%s\" maxlength=\"40\"><br><br>\n",
753 wprintf("</td><td>");
755 wprintf("<table border=0>");
757 wprintf(_("PO box:"));
759 "<input type=\"text\" name=\"pobox\" "
760 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
763 wprintf(_("Address:"));
765 "<input type=\"text\" name=\"extadr\" "
766 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
768 wprintf("<tr><td> </td><td>"
769 "<input type=\"text\" name=\"street\" "
770 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
775 "<input type=\"text\" name=\"city\" "
776 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
779 wprintf(_("State:"));
781 "<input type=\"text\" name=\"state\" "
782 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
785 wprintf(_("ZIP code:"));
787 "<input type=\"text\" name=\"zipcode\" "
788 "value=\"%s\" maxlength=\"10\"></td></tr>\n",
791 wprintf(_("Country:"));
793 "<input type=\"text\" name=\"country\" "
794 "value=\"%s\" maxlength=\"29\" width=\"5\"></td></tr>\n",
796 wprintf("</table>\n");
798 wprintf("</table>\n");
800 wprintf("<table border=0><tr><td>");
801 wprintf(_("Home telephone:"));
803 "<td><input type=\"text\" name=\"hometel\" "
804 "value=\"%s\" maxlength=\"29\"></td>\n",
807 wprintf(_("Work telephone:"));
809 "<td><input type=\"text\" name=\"worktel\" "
810 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
813 wprintf(_("Mobile telephone:"));
815 "<td><input type=\"text\" name=\"mobiletel\" "
816 "value=\"%s\" maxlength=\"29\"></td>\n",
819 wprintf(_("Fax number:"));
821 "<td><input type=\"text\" name=\"faxtel\" "
822 "value=\"%s\" maxlength=\"29\"></td></tr></table>\n",
825 wprintf("<table class=\"vcard_edit_background_alt\">");
828 wprintf("<table border=0><TR>"
830 wprintf(_("Primary Internet e-mail address"));
832 "<input type=\"text\" name=\"primary_inetemail\" "
833 "size=40 maxlength=60 value=\"");
834 escputs(primary_inetemail);
836 "</td><td valign=top>");
837 wprintf(_("Internet e-mail aliases"));
839 "<textarea name=\"other_inetemail\" rows=5 cols=40 width=40>");
840 escputs(other_inetemail);
841 wprintf("</textarea></td></tr></table>\n");
843 wprintf("</td></tr></table>\n");
845 wprintf("<input type=\"hidden\" name=\"extrafields\" value=\"");
846 escputs(extrafields);
849 wprintf("<input type=\"hidden\" name=\"return_to\" value=\"");
850 urlescputs(return_to);
853 wprintf("<div class=\"buttons\">\n"
854 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
856 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
862 wprintf("</td></tr></table>\n");
863 do_template("endbox", NULL);
869 * commit the edits to the citadel server
871 void edit_vcard(void) {
875 msgnum = lbstr("msgnum");
876 partnum = bstr("partnum");
877 do_edit_vcard(msgnum, partnum, "", NULL);
883 * parse edited vcard from the browser
885 void submit_vcard(void) {
887 char *serialized_vcard;
891 if (!havebstr("ok_button")) {
896 if (havebstr("force_room")) {
897 gotoroom(bstr("force_room"));
900 sprintf(buf, "ENT0 1|||4||");
902 serv_getln(buf, sizeof buf);
908 /** Make a vCard structure out of the data supplied in the form */
910 snprintf(buf, sizeof buf, "begin:vcard\r\n%s\r\nend:vcard\r\n",
913 v = vcard_load(buf); /** Start with the extra fields */
915 safestrncpy(WC->ImportantMessage,
916 _("An error has occurred."),
917 sizeof WC->ImportantMessage
923 snprintf(buf, sizeof buf, "%s;%s;%s;%s;%s",
929 vcard_add_prop(v, "n", buf);
931 vcard_add_prop(v, "title", bstr("title"));
932 vcard_add_prop(v, "fn", bstr("fullname"));
933 vcard_add_prop(v, "org", bstr("org"));
935 snprintf(buf, sizeof buf, "%s;%s;%s;%s;%s;%s;%s",
943 vcard_add_prop(v, "adr", buf);
945 vcard_add_prop(v, "tel;home", bstr("hometel"));
946 vcard_add_prop(v, "tel;work", bstr("worktel"));
947 vcard_add_prop(v, "tel;fax", bstr("faxtel"));
948 vcard_add_prop(v, "tel;cell", bstr("mobiletel"));
949 vcard_add_prop(v, "email;internet", bstr("primary_inetemail"));
951 for (i=0; i<num_tokens(bstr("other_inetemail"), '\n'); ++i) {
952 extract_token(buf, bstr("other_inetemail"), i, '\n', sizeof buf);
953 if (!IsEmptyStr(buf)) {
954 vcard_add_prop(v, "email;internet", buf);
958 serialized_vcard = vcard_serialize(v);
960 if (serialized_vcard == NULL) {
961 safestrncpy(WC->ImportantMessage,
962 _("An error has occurred."),
963 sizeof WC->ImportantMessage
969 serv_puts("Content-type: text/x-vcard; charset=UTF-8");
971 serv_printf("%s\r\n", serialized_vcard);
973 free(serialized_vcard);
975 if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
976 select_user_to_edit(NULL, NULL);
978 else if (!strcmp(bstr("return_to"), "do_welcome")) {
992 WebcitAddUrlHandler(HKEY("edit_vcard"), edit_vcard, 0);
993 WebcitAddUrlHandler(HKEY("submit_vcard"), submit_vcard, 0);