2 * Copyright (c) 1996-2012 by the citadel.org team
4 * This program is open source software. You can redistribute it and/or
5 * modify it under the terms of the GNU General Public License, version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
14 #include "webserver.h"
17 CtxType CTX_VCARD = CTX_NONE;
18 long VCEnumCounter = 0;
20 typedef enum _VCStrEnum {
28 Base64BinaryAttachment,
31 typedef struct vcField vcField;
39 vcField VCStr_Ns [] = {
40 {{HKEY("last")}, FlatString, NULL, 0},
41 {{HKEY("first")}, FlatString, NULL, 0},
42 {{HKEY("middle")}, FlatString, NULL, 0},
43 {{HKEY("prefix")}, FlatString, NULL, 0},
44 {{HKEY("suffix")}, FlatString, NULL, 0},
45 {{HKEY("")}, TerminateList, NULL, 0}
48 vcField VCStr_Addrs [] = {
49 {{HKEY("POBox")}, FlatString, NULL, 0},
50 {{HKEY("address")}, FlatString, NULL, 0},
51 {{HKEY("address2")}, FlatString, NULL, 0},
52 {{HKEY("city")}, FlatString, NULL, 0},
53 {{HKEY("state")}, FlatString, NULL, 0},
54 {{HKEY("zip")}, FlatString, NULL, 0},
55 {{HKEY("country")}, FlatString, NULL, 0},
56 {{HKEY("")}, TerminateList, NULL, 0}
60 {{HKEY("n")}, StringCluster, VCStr_Ns, 0}, /* N is name, but only if there's no FN already there */
61 {{HKEY("fn")}, FlatString, NULL, 0}, /* FN (full name) is a true 'display name' field */
62 {{HKEY("title")}, FlatString, NULL, 0}, /* title */
63 {{HKEY("org")}, FlatString, NULL, 0}, /* organization */
64 {{HKEY("email")}, EmailAddr, NULL, 0},
65 {{HKEY("tel")}, PhoneNumber, NULL, 0},
66 {{HKEY("adr")}, StringCluster, VCStr_Addrs, 0},
67 {{HKEY("photo")}, Base64BinaryAttachment, NULL, 0},
68 {{HKEY("version")}, Number, NULL, 0},
69 {{HKEY("rev")}, Number, NULL, 0},
70 {{HKEY("label")}, FlatString, NULL, 0},
71 {{HKEY("uid")}, FlatString, NULL, 0},
72 {{HKEY("tel;home")}, PhoneNumber, NULL, 0},
73 {{HKEY("tel;work")}, PhoneNumber, NULL, 0},
74 {{HKEY("tel;fax")}, PhoneNumber, NULL, 0},
75 {{HKEY("tel;cell")}, PhoneNumber, NULL, 0},
76 {{HKEY("email;internet")}, EmailAddr, NULL, 0},
77 {{HKEY("")}, TerminateList, NULL, 0}
82 {HKEY("n")}, /* N is name, but only if there's no FN already there */
83 {HKEY("fn")}, /* FN (full name) is a true 'display name' field */
84 {HKEY("title")}, /* title */
85 {HKEY("org")}, /* organization */
100 HashList *DefineToToken = NULL;
101 HashList *VCTokenToDefine = NULL;
102 HashList *vcNames = NULL; /* todo: fill with the name strings */
103 void RegisterVCardToken(vcField* vf, StrBuf *name, int inTokenCount)
105 RegisterTokenParamDefine(SKEY(name), vf->cval);
106 Put(DefineToToken, LKEY(vf->cval), vf, reference_free_handler);
107 syslog(LOG_DEBUG, "Token: %s -> %d, %d",
114 void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int layer)
117 while (vf[i].STR.len > 0) {
118 StrBuf *subStr = NewStrBuf();
119 vf[i].cval = (*enumCounter) ++;
120 StrBufAppendBuf(subStr, BaseStr, 0);
121 if (StrLength(subStr) > 0) {
122 StrBufAppendBufPlain(subStr, HKEY("."), 0);
124 StrBufAppendBufPlain(subStr, CKEY(vf[i].STR), 0);
126 Put(VCTokenToDefine, CKEY(vf[i].STR), &vf[i], reference_free_handler);
128 switch (vf[i].Type) {
133 autoRegisterTokens(enumCounter, vf[i].Sub, subStr, 1);
148 case Base64BinaryAttachment:
153 RegisterVCardToken(&vf[i], subStr, i);
158 int preeval_vcard_item(WCTemplateToken *Token)
160 WCTemplputParams TPP;
161 WCTemplputParams *TP;
163 StrBuf *Target = NULL;
165 memset(&TPP, 0, sizeof(WCTemplputParams));
168 searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
169 if (searchFieldNo >= VCEnumCounter) {
170 LogTemplateError(NULL, "VCardItem", ERR_PARM1, TP,
177 void tmpl_vcard_item(StrBuf *Target, WCTemplputParams *TP)
180 long searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
181 HashList *vc = (HashList*) CTX(CTX_VCARD);
182 if (GetHash(vc, LKEY(searchFieldNo), &vItem) && (vItem != NULL)) {
183 StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
187 int preeval_vcard_name_str(WCTemplateToken *Token)
189 WCTemplputParams TPP;
190 WCTemplputParams *TP;
192 StrBuf *Target = NULL;
194 memset(&TPP, 0, sizeof(WCTemplputParams));
197 searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
198 if (searchFieldNo >= VCEnumCounter) {
199 LogTemplateError(NULL, "VCardName", ERR_PARM1, TP,
206 void tmpl_vcard_name_str(StrBuf *Target, WCTemplputParams *TP)
209 long searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
210 /* todo: get descriptive string for this vcard type */
211 if (GetHash(vcNames, LKEY(searchFieldNo), &vItem) && (vItem != NULL)) {
212 StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
218 * Record compare function for sorting address book indices
220 int abcmp(const void *ab1, const void *ab2) {
222 (((const addrbookent *)ab1)->ab_name),
223 (((const addrbookent *)ab2)->ab_name)
229 * Helper function for do_addrbook_view()
230 * Converts a name into a three-letter tab label
232 void nametab(char *tabbuf, long len, char *name) {
233 stresc(tabbuf, len, name, 0, 0);
234 tabbuf[0] = toupper(tabbuf[0]);
235 tabbuf[1] = tolower(tabbuf[1]);
236 tabbuf[2] = tolower(tabbuf[2]);
242 * If it's an old "Firstname Lastname" style record, try to convert it.
244 void lastfirst_firstlast(char *namebuf) {
249 if (namebuf == NULL) return;
250 if (strchr(namebuf, ';') != NULL) return;
252 i = num_tokens(namebuf, ' ');
255 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
256 remove_token(namebuf, i-1, ' ');
257 strcpy(firstname, namebuf);
258 sprintf(namebuf, "%s; %s", lastname, firstname);
263 wc_mime_attachment *load_vcard(message_summary *Msg)
266 StrBuf *FoundCharset = NewStrBuf();
271 wc_mime_attachment *Mime;
272 wc_mime_attachment *VCMime = NULL;
274 Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
275 memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
276 Msg->MsgBody->msgnum = Msg->msgnum;
278 load_message(Msg, FoundCharset, &Error);
280 FreeStrBuf(&FoundCharset);
281 /* look up the vcard... */
282 it = GetNewHashPos(Msg->AllAttach, 0);
283 while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
286 Mime = (wc_mime_attachment*) vMime;
287 if ((strcmp(ChrPtr(Mime->ContentType),
288 "text/x-vcard") == 0) ||
289 (strcmp(ChrPtr(Mime->ContentType),
300 if (VCMime->Data == NULL)
301 MimeLoadData(VCMime);
306 * fetch the display name off a vCard
308 void fetch_ab_name(message_summary *Msg, char **namebuf) {
311 wc_mime_attachment *VCMime = NULL;
313 if (namebuf == NULL) return;
315 VCMime = load_vcard(Msg);
319 /* Grab the name off the card */
320 display_vcard(WC->WBuf, VCMime, 0, 0, namebuf, Msg->msgnum);
322 if (*namebuf != NULL) {
323 lastfirst_firstlast(*namebuf);
325 len = strlen(*namebuf);
326 for (i=0; i<len; ++i) {
327 if ((*namebuf)[i] != ';') return;
330 (*namebuf) = strdup(_("(no name)"));
333 (*namebuf) = strdup(_("(no name)"));
340 * Turn a vCard "n" (name) field into something displayable.
342 void vcard_n_prettyize(char *name)
347 original_name = strdup(name);
348 len = strlen(original_name);
349 for (i=0; i<5; ++i) {
351 if (original_name[len-1] == ' ') {
352 original_name[--len] = 0;
354 if (original_name[len-1] == ';') {
355 original_name[--len] = 0;
361 for (i=0; i<len; ++i) {
362 if (original_name[i] == ';') {
367 name[j++] = original_name[i];
378 * preparse a vcard name
379 * display_vcard() calls this after parsing the textual vCard into
380 * our 'struct vCard' data object.
381 * This gets called instead of display_parsed_vcard() if we are only looking
382 * to extract the person's name instead of displaying the card.
384 void fetchname_parsed_vcard(struct vCard *v, char **storename) {
394 name = vcard_get_prop(v, "n", 1, 0, 0);
397 prop = vcard_get_prop(v, "n", 1, 0, 1);
398 n = num_tokens(prop, ';');
400 for (j=0; j<n; ++j) {
401 extract_token(buf, prop, j, ';', sizeof buf);
402 if (!strcasecmp(buf, "encoding=quoted-printable")) {
405 if (!strcasecmp(buf, "encoding=base64")) {
410 /* %ff can become 6 bytes in utf8 */
411 *storename = malloc(len * 2 + 3);
412 j = CtdlDecodeQuotedPrintable(
418 /* ff will become one byte.. */
419 *storename = malloc(len + 50);
429 *storename = malloc(len + 3); /* \0 + eventualy missing ', '*/
430 memcpy(*storename, name, len + 1);
432 /* vcard_n_prettyize(storename); */
441 * display_vcard() calls this after parsing the textual vCard into
442 * our 'struct vCard' data object.
444 * Set 'full' to nonzero to display the full card, otherwise it will only
445 * show a summary line.
447 * This code is a bit ugly, so perhaps an explanation is due: we do this
448 * in two passes through the vCard fields. On the first pass, we process
449 * fields we understand, and then render them in a pretty fashion at the
450 * end. Then we make a second pass, outputting all the fields we don't
451 * understand in a simple two-column name/value format.
452 * v the vCard to display
453 * full display all items of the vcard?
454 * msgnum Citadel message pointer
456 void display_parsed_vcard(StrBuf *Target, struct vCard *v, int full, wc_mime_attachment *Mime)
463 char *thisname, *thisvalue;
464 char firsttoken[SIZ];
473 strcpy(fullname, "");
480 StrBufAppendPrintf(Target, "<td>");
481 name = vcard_get_prop(v, "fn", 1, 0, 0);
483 StrEscAppend(Target, NULL, name, 0, 0);
485 else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
486 strcpy(fullname, name);
487 vcard_n_prettyize(fullname);
488 StrEscAppend(Target, NULL, fullname, 0, 0);
491 StrBufAppendPrintf(Target, " ");
493 StrBufAppendPrintf(Target, "</td>");
497 StrBufAppendPrintf(Target, "<div align=\"center\">"
498 "<table bgcolor=\"#aaaaaa\" width=\"50%%\">");
499 for (pass=1; pass<=2; ++pass) {
501 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
503 thisname = strdup(v->prop[i].name);
504 extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
506 for (j=0; j<num_tokens(thisname, ';'); ++j) {
507 extract_token(buf, thisname, j, ';', sizeof buf);
508 if (!strcasecmp(buf, "encoding=quoted-printable")) {
510 remove_token(thisname, j, ';');
512 if (!strcasecmp(buf, "encoding=base64")) {
514 remove_token(thisname, j, ';');
518 len = strlen(v->prop[i].value);
519 /* if we have some untagged QP, detect it here. */
520 if (!is_qp && (strstr(v->prop[i].value, "=?")!=NULL))
521 utf8ify_rfc822_string(&v->prop[i].value);
524 /* %ff can become 6 bytes in utf8 */
525 thisvalue = malloc(len * 2 + 3);
526 j = CtdlDecodeQuotedPrintable(
527 thisvalue, v->prop[i].value,
532 /* ff will become one byte.. */
533 thisvalue = malloc(len + 50);
535 thisvalue, v->prop[i].value,
536 strlen(v->prop[i].value) );
539 thisvalue = strdup(v->prop[i].value);
542 /* Various fields we may encounter ***/
544 /* N is name, but only if there's no FN already there */
545 if (!strcasecmp(firsttoken, "n")) {
546 if (IsEmptyStr(fullname)) {
547 strcpy(fullname, thisvalue);
548 vcard_n_prettyize(fullname);
552 /* FN (full name) is a true 'display name' field */
553 else if (!strcasecmp(firsttoken, "fn")) {
554 strcpy(fullname, thisvalue);
558 else if (!strcasecmp(firsttoken, "title")) {
559 strcpy(title, thisvalue);
563 else if (!strcasecmp(firsttoken, "org")) {
564 strcpy(org, thisvalue);
567 else if (!strcasecmp(firsttoken, "email")) {
569 if (!IsEmptyStr(mailto)) strcat(mailto, "<br>");
571 "<a href=\"display_enter"
572 "?force_room=_MAIL_?recp=");
574 len = strlen(mailto);
575 urlesc(&mailto[len], SIZ - len, "\"");
576 len = strlen(mailto);
577 urlesc(&mailto[len], SIZ - len, fullname);
578 len = strlen(mailto);
579 urlesc(&mailto[len], SIZ - len, "\" <");
580 len = strlen(mailto);
581 urlesc(&mailto[len], SIZ - len, thisvalue);
582 len = strlen(mailto);
583 urlesc(&mailto[len], SIZ - len, ">");
585 strcat(mailto, "\">");
586 len = strlen(mailto);
587 stresc(mailto+len, SIZ - len, thisvalue, 1, 1);
588 strcat(mailto, "</A>");
590 else if (!strcasecmp(firsttoken, "tel")) {
591 if (!IsEmptyStr(phone)) strcat(phone, "<br>");
592 strcat(phone, thisvalue);
593 for (j=0; j<num_tokens(thisname, ';'); ++j) {
594 extract_token(buf, thisname, j, ';', sizeof buf);
595 if (!strcasecmp(buf, "tel"))
597 else if (!strcasecmp(buf, "work"))
598 strcat(phone, _(" (work)"));
599 else if (!strcasecmp(buf, "home"))
600 strcat(phone, _(" (home)"));
601 else if (!strcasecmp(buf, "cell"))
602 strcat(phone, _(" (cell)"));
610 else if (!strcasecmp(firsttoken, "adr")) {
612 StrBufAppendPrintf(Target, "<tr><td>");
613 StrBufAppendPrintf(Target, _("Address:"));
614 StrBufAppendPrintf(Target, "</td><td>");
615 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
616 extract_token(buf, thisvalue, j, ';', sizeof buf);
617 if (!IsEmptyStr(buf)) {
618 StrEscAppend(Target, NULL, buf, 0, 0);
619 if (j<3) StrBufAppendPrintf(Target, "<br>");
620 else StrBufAppendPrintf(Target, " ");
623 StrBufAppendPrintf(Target, "</td></tr>\n");
626 /* else if (!strcasecmp(firsttoken, "photo") && full && pass == 2) {
627 // Only output on second pass
628 StrBufAppendPrintf(Target, "<tr><td>");
629 StrBufAppendPrintf(Target, _("Photo:"));
630 StrBufAppendPrintf(Target, "</td><td>");
631 StrBufAppendPrintf(Target, "<img src=\"/vcardphoto/%ld/\" alt=\"Contact photo\"/>",msgnum);
632 StrBufAppendPrintf(Target, "</td></tr>\n");
634 else if (!strcasecmp(firsttoken, "version")) {
637 else if (!strcasecmp(firsttoken, "rev")) {
640 else if (!strcasecmp(firsttoken, "label")) {
645 /*** Don't show extra fields. They're ugly.
647 StrBufAppendPrintf(Target, "<TR><TD>");
648 StrEscAppend(Target, NULL, thisname, 0, 0);
649 StrBufAppendPrintf(Target, "</TD><TD>");
650 StrEscAppend(Target, NULL, thisvalue, 0, 0);
651 StrBufAppendPrintf(Target, "</TD></TR>\n");
661 StrBufAppendPrintf(Target, "<tr bgcolor=\"#aaaaaa\">"
662 "<td colspan=2 bgcolor=\"#ffffff\">"
663 "<img align=\"center\" src=\"static/webcit_icons/essen/32x32/contact.png\">"
664 "<font size=\"+1\"><b>");
665 StrEscAppend(Target, NULL, fullname, 0, 0);
666 StrBufAppendPrintf(Target, "</b></font>");
667 if (!IsEmptyStr(title)) {
668 StrBufAppendPrintf(Target, "<div align=\"right>\"");
669 StrEscAppend(Target, NULL, title, 0, 0);
670 StrBufAppendPrintf(Target, "</div>");
672 if (!IsEmptyStr(org)) {
673 StrBufAppendPrintf(Target, "<div align=\"right\">");
674 StrEscAppend(Target, NULL, org, 0, 0);
675 StrBufAppendPrintf(Target, "</div>");
677 StrBufAppendPrintf(Target, "</td></tr>\n");
679 if (!IsEmptyStr(phone)) {
680 StrBufAppendPrintf(Target, "<tr><td>");
681 StrBufAppendPrintf(Target, _("Telephone:"));
682 StrBufAppendPrintf(Target, "</td><td>%s</td></tr>\n", phone);
684 if (!IsEmptyStr(mailto)) {
685 StrBufAppendPrintf(Target, "<tr><td>");
686 StrBufAppendPrintf(Target, _("E-mail:"));
687 StrBufAppendPrintf(Target, "</td><td>%s</td></tr>\n", mailto);
693 StrBufAppendPrintf(Target, "</table></div>\n");
697 void PutVcardItem(vcField *thisField, HashList *thisVC, StrBuf *ThisFieldStr, int is_qp, StrBuf *Swap)
699 /* if we have some untagged QP, detect it here. */
700 if (is_qp || (strstr(ChrPtr(ThisFieldStr), "=?")!=NULL)){
702 StrBuf_RFC822_to_Utf8(Swap, ThisFieldStr, NULL, NULL); /* default charset, current charset */
708 Put(thisVC, LKEY(thisField->cval), ThisFieldStr, HFreeStrBuf);
712 * display_vcard() calls this after parsing the textual vCard into
713 * our 'struct vCard' data object.
715 * Set 'full' to nonzero to display the full card, otherwise it will only
716 * show a summary line.
718 * This code is a bit ugly, so perhaps an explanation is due: we do this
719 * in two passes through the vCard fields. On the first pass, we process
720 * fields we understand, and then render them in a pretty fashion at the
721 * end. Then we make a second pass, outputting all the fields we don't
722 * understand in a simple two-column name/value format.
723 * v the vCard to display
724 * full display all items of the vcard?
725 * msgnum Citadel message pointer
727 void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, int full, wc_mime_attachment *Mime)
732 char buf[20]; //SIZ];
736 StrBuf *thisname = NULL;
737 char firsttoken[20]; ///SIZ];
743 thisVC = NewHash(1, lFlathash);
745 thisname = NewStrBuf();
746 thisVCToken = NewStrBufPlain(NULL, 63);
747 for (i=0; i<(v->numprops); ++i) {
748 FlushStrBuf(thisVCToken);
751 syslog(LOG_DEBUG, "i: %d oneprop: %s - value: %s", i, v->prop[i].name, v->prop[i].value);
752 StrBufPlain(thisname, v->prop[i].name, -1);
753 StrBufLowerCase(thisname);
755 /*len = */extract_token(firsttoken, ChrPtr(thisname), 0, ';', sizeof firsttoken);
756 ntokens = num_tokens(ChrPtr(thisname), ';');
757 for (j=0, k=0; j < ntokens && k < 10; ++j) {
760 len = extract_token(buf, ChrPtr(thisname), j, ';', sizeof buf);
761 if (!strcasecmp(buf, "encoding=quoted-printable")) {
763 /* remove_token(thisname, j, ';');*/
765 else if (!strcasecmp(buf, "encoding=base64")) {
767 /* remove_token(thisname, j, ';');*/
770 if (StrLength(thisVCToken) > 0) {
771 StrBufAppendBufPlain(thisVCToken, HKEY(";"), 0);
773 StrBufAppendBufPlain(thisVCToken, buf, len, 0);
775 if (GetHash(VCToEnum, buf, len, &V))
779 Put(VC, IKEY(evc), Val, HFreeStrBuf);
781 syslog(LOG_DEBUG, "[%ul] -> k: %d %s - %s", evc, k, buf, VCStr[evc[k]].Key);
790 if ((StrLength(thisVCToken) > 0) &&
791 GetHash(VCTokenToDefine, SKEY(thisVCToken), &vField) &&
793 vcField *thisField = (vcField *)vField;
794 StrBuf *ThisFieldStr = NULL;
795 syslog(LOG_DEBUG, "got this token: %s, found: %s", ChrPtr(thisVCToken), thisField->STR.Key);
796 switch (thisField->Type) {
797 case StringCluster: {
799 const char *Pos = NULL;
801 StrBuf *thisArray = NewStrBufPlain(v->prop[i].value, -1);
802 StrBuf *Buf = NewStrBufPlain(NULL, StrLength(thisArray));
803 while (thisField->Sub[i].STR.len > 0) {
804 StrBufExtract_NextToken(thisArray, Buf, &Pos, ';');
805 ThisFieldStr = NewStrBufDup(Buf);
807 PutVcardItem(&thisField->Sub[i], thisVC, ThisFieldStr, is_qp, Swap);
818 /* copy over the payload into a StrBuf */
819 ThisFieldStr = NewStrBufPlain(v->prop[i].value, -1);
820 PutVcardItem(thisField, thisVC, ThisFieldStr, is_qp, Swap);
823 case Base64BinaryAttachment:
829 /* copy over the payload into a StrBuf */
830 Val = NewStrBufPlain(v->prop[i].value, -1);
832 /* if we have some untagged QP, detect it here. */
833 if (is_qp || (strstr(v->prop[i].value, "=?")!=NULL)){
835 StrBuf_RFC822_to_Utf8(Swap, Val, NULL, NULL); /* default charset, current charset */
842 StrBufDecodeBase64(Val);
846 syslog(LOG_DEBUG, "-> firsttoken: %s thisname: %s Value: [%s][%s]",
851 if (GetHash(VCToEnum, firsttoken, strlen(firsttoken), &V))
854 Put(VC, IKEY(evc), Val, HFreeStrBuf);
855 syslog(LOG_DEBUG, "[%ul]\n", evc);
859 syslog(LOG_DEBUG, "[]\n");
861 TODO: check for layer II
864 long max = num_tokens(thisname, ';');
865 firsttoken[len] = '_';
867 for (j = 0; j < max; j++) {
870 extract_token(buf, thisname, j, ';', sizeof (buf));
871 if (!strcasecmp(buf, "tel"))
873 else if (!strcasecmp(buf, "work"))
874 strcat(phone, _(" (work)"));
875 else if (!strcasecmp(buf, "home"))
876 strcat(phone, _(" (home)"));
877 else if (!strcasecmp(buf, "cell"))
878 strcat(phone, _(" (cell)"));
897 WCTemplputParams *TP = NULL;
898 WCTemplputParams SubTP;
900 StackContext(TP, &SubTP, thisVC, CTX_VCARD, 0, NULL);
902 DoTemplate(HKEY("test_vcard"), Target, &SubTP);
904 UnStackContext(&SubTP);
906 printf("%s\n", ChrPtr(Target));
907 FreeStrBuf(&thisVCToken);
908 DeleteHash(&thisVC);/// todo
911 void tmplput_VCARD_ITEM(StrBuf *Target, WCTemplputParams *TP)
913 HashList *VC = CTX(CTX_VCARD);
917 evc = GetTemplateTokenNumber(Target, TP, 0, -1);
920 if (GetHash(VC, IKEY(evc), &vStr))
922 StrBufAppendTemplate(Target, TP,
930 void new_vcard (StrBuf *Target, struct vCard *v, int full, wc_mime_attachment *Mime)
933 WCTemplputParams SubTP;
935 memset(&SubTP, 0, sizeof(WCTemplputParams));
938 VC = NewHash(0, Flathash);
939 parse_vcard(Target, v, VC, full, Mime);
941 SubTP.Filter.ContextType = CTX_VCARD;
944 DoTemplate(HKEY("test_vcard"), Target, &SubTP);
951 * Display a textual vCard
952 * (Converts to a vCard object and then calls the actual display function)
953 * Set 'full' to nonzero to display the whole card instead of a one-liner.
954 * Or, if "storename" is non-NULL, just store the person's name in that
955 * buffer instead of displaying the card at all.
957 * vcard_source the buffer containing the vcard text
958 * alpha Display only if name begins with this letter of the alphabet
959 * full Display the full vCard (otherwise just the display name)
960 * storename If not NULL, also store the display name here
961 * msgnum Citadel message pointer
963 void display_vcard(StrBuf *Target,
964 wc_mime_attachment *Mime,
976 v = VCardLoad(Mime->Data);
978 if (v == NULL) return;
980 name = vcard_get_prop(v, "n", 1, 0, 0);
982 Buf = NewStrBufPlain(name, -1);
983 Buf2 = NewStrBufPlain(NULL, StrLength(Buf));
984 StrBuf_RFC822_to_Utf8(Buf2, Buf, WC->DefaultCharset, NULL);
985 this_alpha = ChrPtr(Buf)[0];
990 if (storename != NULL) {
991 fetchname_parsed_vcard(v, storename);
993 else if ((alpha == 0) ||
994 ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha))) ||
995 ((!isalpha(alpha)) && (!isalpha(this_alpha)))
1000 new_vcard (Target, v, full, Mime);
1002 display_parsed_vcard(Target, v, full, Mime);
1012 * Render the address book using info we gathered during the scan
1014 * addrbook the addressbook to render
1015 * num_ab the number of the addressbook
1017 void do_addrbook_view(addrbookent *addrbook, int num_ab) {
1021 static int NAMESPERPAGE = 60;
1024 char tabfirst_label[64];
1026 char tablast_label[64];
1027 char this_tablabel[64];
1032 wc_printf("<br><br><br><div align=\"center\"><i>");
1033 wc_printf(_("This address book is empty."));
1034 wc_printf("</i></div>\n");
1039 qsort(addrbook, num_ab, sizeof(addrbookent), abcmp);
1042 num_pages = (num_ab / NAMESPERPAGE) + 1;
1044 tablabels = malloc(num_pages * sizeof (char *));
1045 if (tablabels == NULL) {
1046 wc_printf("<br><br><br><div align=\"center\"><i>");
1047 wc_printf(_("An internal error has occurred."));
1048 wc_printf("</i></div>\n");
1052 for (i=0; i<num_pages; ++i) {
1053 tabfirst = i * NAMESPERPAGE;
1054 tablast = tabfirst + NAMESPERPAGE - 1;
1055 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
1056 nametab(tabfirst_label, 64, addrbook[tabfirst].ab_name);
1057 nametab(tablast_label, 64, addrbook[tablast].ab_name);
1058 sprintf(this_tablabel, "%s - %s", tabfirst_label, tablast_label);
1059 tablabels[i] = strdup(this_tablabel);
1062 tabbed_dialog(num_pages, tablabels);
1065 for (i=0; i<num_ab; ++i) {
1067 if ((i / NAMESPERPAGE) != page) { /* New tab */
1068 page = (i / NAMESPERPAGE);
1070 wc_printf("</tr></table>\n");
1071 end_tab(page-1, num_pages);
1073 begin_tab(page, num_pages);
1074 wc_printf("<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%%\">\n");
1078 if ((displayed % 4) == 0) {
1079 if (displayed > 0) {
1080 wc_printf("</tr>\n");
1083 wc_printf("<tr bgcolor=\"#%s\">",
1084 (bg ? "dddddd" : "ffffff")
1090 wc_printf("<a href=\"readfwd?startmsg=%ld?is_singlecard=1",
1091 addrbook[i].ab_msgnum);
1092 wc_printf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
1093 vcard_n_prettyize(addrbook[i].ab_name);
1094 escputs(addrbook[i].ab_name);
1095 wc_printf("</a></td>\n");
1099 /* Placeholders for empty columns at end */
1100 if ((num_ab % 4) != 0) {
1101 for (i=0; i<(4-(num_ab % 4)); ++i) {
1102 wc_printf("<td> </td>");
1106 wc_printf("</tr></table>\n");
1107 end_tab((num_pages-1), num_pages);
1109 begin_tab(num_pages, num_pages);
1110 /* FIXME there ought to be something here */
1111 end_tab(num_pages, num_pages);
1113 for (i=0; i<num_pages; ++i) {
1123 * Edit the vCard component of a MIME message.
1124 * Supply the message number
1125 * and MIME part number to fetch. Or, specify -1 for the message number
1126 * to start with a blank card.
1128 void do_edit_vcard(long msgnum, char *partnum,
1129 message_summary *VCMsg,
1130 wc_mime_attachment *VCAtt,
1131 const char *return_to,
1132 const char *force_room) {
1133 wcsession *WCC = WC;
1134 message_summary *Msg = NULL;
1135 wc_mime_attachment *VCMime = NULL;
1142 char firstname[256];
1143 char middlename[256];
1156 char mobiletel[256];
1157 char primary_inetemail[256];
1158 char other_inetemail[SIZ];
1159 char extrafields[SIZ];
1180 primary_inetemail[0] = 0;
1181 other_inetemail[0] = 0;
1187 safestrncpy(whatuser, "", sizeof whatuser);
1189 if ((msgnum >= 0) ||
1190 ((VCMsg != NULL) && (VCAtt != NULL)))
1192 if ((VCMsg == NULL) && (VCAtt == NULL)) {
1194 Msg = (message_summary *) malloc(sizeof(message_summary));
1195 memset(Msg, 0, sizeof(message_summary));
1196 Msg->msgnum = msgnum;
1197 VCMime = load_vcard(Msg);
1198 if (VCMime == NULL) {
1199 convenience_page("770000", _("Error"), "");///TODO: important message
1200 DestroyMessageSummary(Msg);
1204 v = VCardLoad(VCMime->Data);
1207 v = VCardLoad(VCAtt->Data);
1210 /* Populate the variables for our form */
1212 while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) {
1213 char prp[256]; /* property name */
1214 char prm[256]; /* parameters */
1216 value = vcard_get_prop(v, "", 0, i++, 0);
1219 extract_token(prp, key, 0, ';', sizeof prp);
1220 safestrncpy(prm, key, sizeof prm);
1221 remove_token(prm, 0, ';');
1223 if (!strcasecmp(prp, "n")) {
1224 extract_token(lastname, value, 0, ';', sizeof lastname);
1225 extract_token(firstname, value, 1, ';', sizeof firstname);
1226 extract_token(middlename, value, 2, ';', sizeof middlename);
1227 extract_token(prefix, value, 3, ';', sizeof prefix);
1228 extract_token(suffix, value, 4, ';', sizeof suffix);
1231 else if (!strcasecmp(prp, "fn")) {
1232 safestrncpy(fullname, value, sizeof fullname);
1235 else if (!strcasecmp(prp, "title")) {
1236 safestrncpy(title, value, sizeof title);
1239 else if (!strcasecmp(prp, "org")) {
1240 safestrncpy(org, value, sizeof org);
1243 else if (!strcasecmp(prp, "adr")) {
1244 extract_token(pobox, value, 0, ';', sizeof pobox);
1245 extract_token(extadr, value, 1, ';', sizeof extadr);
1246 extract_token(street, value, 2, ';', sizeof street);
1247 extract_token(city, value, 3, ';', sizeof city);
1248 extract_token(state, value, 4, ';', sizeof state);
1249 extract_token(zipcode, value, 5, ';', sizeof zipcode);
1250 extract_token(country, value, 6, ';', sizeof country);
1253 else if (!strcasecmp(prp, "tel")) {
1255 if (bmstrcasestr(prm, "home")) {
1256 extract_token(hometel, value, 0, ';', sizeof hometel);
1258 else if (bmstrcasestr(prm, "work")) {
1259 extract_token(worktel, value, 0, ';', sizeof worktel);
1261 else if (bmstrcasestr(prm, "fax")) {
1262 extract_token(faxtel, value, 0, ';', sizeof faxtel);
1264 else if (bmstrcasestr(prm, "cell")) {
1265 extract_token(mobiletel, value, 0, ';', sizeof mobiletel);
1267 else { /* Missing or unknown type; put it in the home phone */
1268 extract_token(hometel, value, 0, ';', sizeof hometel);
1272 else if ( (!strcasecmp(prp, "email")) && (bmstrcasestr(prm, "internet")) ) {
1273 if (primary_inetemail[0] == 0) {
1274 safestrncpy(primary_inetemail, value, sizeof primary_inetemail);
1277 if (other_inetemail[0] != 0) {
1278 strcat(other_inetemail, "\n");
1280 strcat(other_inetemail, value);
1284 /* Unrecognized properties are preserved here so we don't discard them
1285 * just because the vCard was edited with WebCit.
1288 strcat(extrafields, key);
1289 strcat(extrafields, ":");
1290 strcat(extrafields, value);
1291 strcat(extrafields, "\n");
1299 /* Display the form */
1300 output_headers(1, 1, 1, 0, 0, 0);
1302 do_template("box_begin_1");
1303 StrBufAppendBufPlain(WC->WBuf, _("Edit contact information"), -1, 0);
1304 do_template("box_begin_2");
1306 wc_printf("<form method=\"POST\" action=\"submit_vcard\">\n");
1307 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1309 if (force_room != NULL) {
1310 wc_printf("<input type=\"hidden\" name=\"force_room\" value=\"");
1311 escputs(force_room);
1316 wc_printf("<input type=\"hidden\" name=\"go\" value=\"");
1317 StrEscAppend(WCC->WBuf, WCC->CurRoom.name, NULL, 0, 0);
1321 wc_printf("<table class=\"vcard_edit_background\"><tr><td>\n");
1323 wc_printf("<table border=\"0\"><tr>"
1328 "<td>%s</td></tr>\n",
1329 _("Prefix"), _("First Name"), _("Middle Name"), _("Last Name"), _("Suffix")
1331 wc_printf("<tr><td><input type=\"text\" name=\"prefix\" "
1332 "value=\"%s\" maxlength=\"5\" size=\"5\"></td>",
1334 wc_printf("<td><input type=\"text\" name=\"firstname\" "
1335 "value=\"%s\" maxlength=\"29\"></td>",
1337 wc_printf("<td><input type=\"text\" name=\"middlename\" "
1338 "value=\"%s\" maxlength=\"29\"></td>",
1340 wc_printf("<td><input type=\"text\" name=\"lastname\" "
1341 "value=\"%s\" maxlength=\"29\"></td>",
1343 wc_printf("<td><input type=\"text\" name=\"suffix\" "
1344 "value=\"%s\" maxlength=\"10\" size=\"10\"></td></tr></table>\n",
1347 wc_printf("<table class=\"vcard_edit_background_alt\">");
1348 wc_printf("<tr><td>");
1350 wc_printf(_("Display name:"));
1352 "<input type=\"text\" name=\"fullname\" "
1353 "value=\"%s\" maxlength=\"40\"><br><br>\n",
1357 wc_printf(_("Title:"));
1359 "<input type=\"text\" name=\"title\" "
1360 "value=\"%s\" maxlength=\"40\"><br><br>\n",
1364 wc_printf(_("Organization:"));
1366 "<input type=\"text\" name=\"org\" "
1367 "value=\"%s\" maxlength=\"40\"><br><br>\n",
1371 wc_printf("</td><td>");
1373 wc_printf("<table border=\"0\">");
1374 wc_printf("<tr><td>");
1375 wc_printf(_("PO box:"));
1376 wc_printf("</td><td>"
1377 "<input type=\"text\" name=\"pobox\" "
1378 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
1380 wc_printf("<tr><td>");
1381 wc_printf(_("Address:"));
1382 wc_printf("</td><td>"
1383 "<input type=\"text\" name=\"extadr\" "
1384 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
1386 wc_printf("<tr><td> </td><td>"
1387 "<input type=\"text\" name=\"street\" "
1388 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
1390 wc_printf("<tr><td>");
1391 wc_printf(_("City:"));
1392 wc_printf("</td><td>"
1393 "<input type=\"text\" name=\"city\" "
1394 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
1396 wc_printf("<tr><td>");
1397 wc_printf(_("State:"));
1398 wc_printf("</td><td>"
1399 "<input type=\"text\" name=\"state\" "
1400 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
1402 wc_printf("<tr><td>");
1403 wc_printf(_("ZIP code:"));
1404 wc_printf("</td><td>"
1405 "<input type=\"text\" name=\"zipcode\" "
1406 "value=\"%s\" maxlength=\"10\"></td></tr>\n",
1408 wc_printf("<tr><td>");
1409 wc_printf(_("Country:"));
1410 wc_printf("</td><td>"
1411 "<input type=\"text\" name=\"country\" "
1412 "value=\"%s\" maxlength=\"29\" width=\"5\"></td></tr>\n",
1414 wc_printf("</table>\n");
1416 wc_printf("</table>\n");
1418 wc_printf("<table border=0><tr><td>");
1419 wc_printf(_("Home telephone:"));
1421 "<td><input type=\"text\" name=\"hometel\" "
1422 "value=\"%s\" maxlength=\"29\"></td>\n",
1425 wc_printf(_("Work telephone:"));
1427 "<td><input type=\"text\" name=\"worktel\" "
1428 "value=\"%s\" maxlength=\"29\"></td></tr>\n",
1430 wc_printf("<tr><td>");
1431 wc_printf(_("Mobile telephone:"));
1433 "<td><input type=\"text\" name=\"mobiletel\" "
1434 "value=\"%s\" maxlength=\"29\"></td>\n",
1437 wc_printf(_("Fax number:"));
1439 "<td><input type=\"text\" name=\"faxtel\" "
1440 "value=\"%s\" maxlength=\"29\"></td></tr></table>\n",
1443 wc_printf("<table class=\"vcard_edit_background_alt\">");
1444 wc_printf("<tr><td>");
1446 wc_printf("<table border=0><TR>"
1448 wc_printf(_("Primary Internet e-mail address"));
1450 "<input type=\"text\" name=\"primary_inetemail\" "
1451 "size=40 maxlength=60 value=\"");
1452 escputs(primary_inetemail);
1454 "</td><td valign=top>");
1455 wc_printf(_("Internet e-mail aliases"));
1457 "<textarea name=\"other_inetemail\" rows=5 cols=40 width=40>");
1458 escputs(other_inetemail);
1459 wc_printf("</textarea></td></tr></table>\n");
1461 wc_printf("</td></tr></table>\n");
1463 wc_printf("<input type=\"hidden\" name=\"extrafields\" value=\"");
1464 escputs(extrafields);
1467 wc_printf("<input type=\"hidden\" name=\"return_to\" value=\"");
1471 wc_printf("<div class=\"buttons\">\n"
1472 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
1474 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
1480 wc_printf("</td></tr></table>\n");
1481 do_template("box_end");
1484 DestroyMessageSummary(Msg);
1490 * commit the edits to the citadel server
1492 void edit_vcard(void) {
1496 msgnum = lbstr("msgnum");
1497 partnum = bstr("partnum");
1498 do_edit_vcard(msgnum, partnum, NULL, NULL, "", NULL);
1504 * parse edited vcard from the browser
1506 void submit_vcard(void) {
1508 char *serialized_vcard;
1511 const StrBuf *ForceRoom;
1514 if (!havebstr("ok_button")) {
1515 readloop(readnew, eUseDefault);
1519 if (havebstr("force_room")) {
1520 ForceRoom = sbstr("force_room");
1521 if (gotoroom(ForceRoom) != 200) {
1522 AppendImportantMessage(_("Unable to enter the room to save your message"), -1);
1523 AppendImportantMessage(HKEY(": "));
1524 AppendImportantMessage(SKEY(ForceRoom));
1525 AppendImportantMessage(HKEY("; "));
1526 AppendImportantMessage(_("Aborting."), -1);
1528 if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
1529 select_user_to_edit(NULL);
1531 else if (!strcmp(bstr("return_to"), "do_welcome")) {
1534 else if (!IsEmptyStr(bstr("return_to"))) {
1535 http_redirect(bstr("return_to"));
1538 readloop(readnew, eUseDefault);
1545 serv_write(HKEY("ENT0 1|||4\n"));
1546 if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4))
1552 /* Make a vCard structure out of the data supplied in the form */
1553 StrBufPrintf(Buf, "begin:vcard\r\n%s\r\nend:vcard\r\n",
1556 v = VCardLoad(Buf); /* Start with the extra fields */
1558 AppendImportantMessage(_("An error has occurred."), -1);
1564 snprintf(buf, sizeof buf, "%s;%s;%s;%s;%s",
1570 vcard_add_prop(v, "n", buf);
1572 vcard_add_prop(v, "title", bstr("title"));
1573 vcard_add_prop(v, "fn", bstr("fullname"));
1574 vcard_add_prop(v, "org", bstr("org"));
1576 snprintf(buf, sizeof buf, "%s;%s;%s;%s;%s;%s;%s",
1584 vcard_add_prop(v, "adr", buf);
1586 vcard_add_prop(v, "tel;home", bstr("hometel"));
1587 vcard_add_prop(v, "tel;work", bstr("worktel"));
1588 vcard_add_prop(v, "tel;fax", bstr("faxtel"));
1589 vcard_add_prop(v, "tel;cell", bstr("mobiletel"));
1590 vcard_add_prop(v, "email;internet", bstr("primary_inetemail"));
1592 for (i=0; i<num_tokens(bstr("other_inetemail"), '\n'); ++i) {
1593 extract_token(buf, bstr("other_inetemail"), i, '\n', sizeof buf);
1594 if (!IsEmptyStr(buf)) {
1595 vcard_add_prop(v, "email;internet", buf);
1599 serialized_vcard = vcard_serialize(v);
1601 if (serialized_vcard == NULL) {
1602 AppendImportantMessage(_("An error has occurred."), -1);
1608 serv_write(HKEY("Content-type: text/x-vcard; charset=UTF-8\n"));
1609 serv_write(HKEY("\n"));
1610 serv_printf("%s\r\n", serialized_vcard);
1611 serv_write(HKEY("000\n"));
1612 free(serialized_vcard);
1614 if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
1615 select_user_to_edit(NULL);
1617 else if (!strcmp(bstr("return_to"), "do_welcome")) {
1620 else if (!IsEmptyStr(bstr("return_to"))) {
1621 http_redirect(bstr("return_to"));
1624 readloop(readnew, eUseDefault);
1632 * Extract an embedded photo from a vCard for display on the client
1634 void display_vcard_photo_img(void)
1640 const char *contentType;
1641 wcsession *WCC = WC;
1643 msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
1645 vcard = load_mimepart(msgnum,"1");
1646 v = VCardLoad(vcard);
1648 photosrc = vcard_get_prop(v, "PHOTO", 1,0,0);
1649 FlushStrBuf(WCC->WBuf);
1650 StrBufAppendBufPlain(WCC->WBuf, photosrc, -1, 0);
1651 if (StrBufDecodeBase64(WCC->WBuf) <= 0) {
1652 FlushStrBuf(WCC->WBuf);
1654 hprintf("HTTP/1.1 500 %s\n","Unable to get photo");
1655 output_headers(0, 0, 0, 0, 0, 0);
1656 hprintf("Content-Type: text/plain\r\n");
1658 wc_printf(_("Could Not decode vcard photo\n"));
1662 contentType = GuessMimeType(ChrPtr(WCC->WBuf), StrLength(WCC->WBuf));
1663 http_transmit_thing(contentType, 0);
1668 typedef struct _vcardview_struct {
1670 addrbookent *addrbook;
1675 int vcard_GetParamsGetServerCall(SharedMessageStatus *Stat,
1676 void **ViewSpecific,
1683 vcardview_struct *VS;
1685 VS = (vcardview_struct*) malloc (sizeof(vcardview_struct));
1686 memset(VS, 0, sizeof(vcardview_struct));
1687 *ViewSpecific = (void*)VS;
1689 VS->is_singlecard = ibstr("is_singlecard");
1690 if (VS->is_singlecard != 1) {
1691 if (oper == do_search) {
1692 snprintf(cmd, len, "MSGS SEARCH|%s", bstr("query"));
1695 strcpy(cmd, "MSGS ALL");
1697 Stat->maxmsgs = 9999999;
1702 int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
1703 void **ViewSpecific,
1704 message_summary* Msg,
1708 vcardview_struct *VS;
1711 VS = (vcardview_struct*) *ViewSpecific;
1714 fetch_ab_name(Msg, &ab_name);
1715 if (ab_name == NULL)
1718 VS->addrbook = realloc(VS->addrbook,
1719 (sizeof(addrbookent) * VS->num_ab) );
1720 safestrncpy(VS->addrbook[VS->num_ab-1].ab_name, ab_name,
1721 sizeof(VS->addrbook[VS->num_ab-1].ab_name));
1722 VS->addrbook[VS->num_ab-1].ab_msgnum = Msg->msgnum;
1728 int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
1731 vcardview_struct *VS;
1733 VS = (vcardview_struct*) *ViewSpecific;
1734 if (VS->is_singlecard)
1735 read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime);
1737 do_addrbook_view(VS->addrbook, VS->num_ab); /* Render the address book */
1741 int vcard_Cleanup(void **ViewSpecific)
1743 vcardview_struct *VS;
1745 VS = (vcardview_struct*) *ViewSpecific;
1748 (VS->addrbook != NULL))
1756 ServerStartModule_VCARD
1759 ///VCToEnum = NewHash(0, NULL);
1764 ServerShutdownModule_VCARD
1767 /// DeleteHash(&VCToEnum);
1774 RegisterCTX(CTX_VCARD);
1775 RegisterReadLoopHandlerset(
1777 vcard_GetParamsGetServerCall,
1781 vcard_LoadMsgFromServer,
1782 vcard_RenderView_or_Tail,
1784 WebcitAddUrlHandler(HKEY("edit_vcard"), "", 0, edit_vcard, 0);
1785 WebcitAddUrlHandler(HKEY("submit_vcard"), "", 0, submit_vcard, 0);
1786 WebcitAddUrlHandler(HKEY("vcardphoto"), "", 0, display_vcard_photo_img, NEED_URL);
1788 Put(VCToEnum, HKEY("n"), (void*)VC_n, reference_free_handler);
1789 Put(VCToEnum, HKEY("fn"), (void*)VC_fn, reference_free_handler);
1790 Put(VCToEnum, HKEY("title"), (void*)VC_title, reference_free_handler);
1791 Put(VCToEnum, HKEY("org"), (void*)VC_org, reference_free_handler);
1792 Put(VCToEnum, HKEY("email"), (void*)VC_email, reference_free_handler);
1793 Put(VCToEnum, HKEY("tel"), (void*)VC_tel, reference_free_handler);
1794 Put(VCToEnum, HKEY("work"), (void*)VC_work, reference_free_handler);
1795 Put(VCToEnum, HKEY("home"), (void*)VC_home, reference_free_handler);
1796 Put(VCToEnum, HKEY("cell"), (void*)VC_cell, reference_free_handler);
1797 Put(VCToEnum, HKEY("adr"), (void*)VC_adr, reference_free_handler);
1798 Put(VCToEnum, HKEY("photo"), (void*)VC_photo, reference_free_handler);
1799 Put(VCToEnum, HKEY("version"), (void*)VC_version, reference_free_handler);
1800 Put(VCToEnum, HKEY("rev"), (void*)VC_rev, reference_free_handler);
1801 Put(VCToEnum, HKEY("label"), (void*)VC_label, reference_free_handler);
1804 RegisterNamespace("VC", 1, 2, tmplput_VCARD_ITEM, NULL, CTX_VCARD);
1806 REGISTERTokenParamDefine(VC_n);
1807 REGISTERTokenParamDefine(VC_fn);
1808 REGISTERTokenParamDefine(VC_title);
1809 REGISTERTokenParamDefine(VC_org);
1810 REGISTERTokenParamDefine(VC_email);
1811 REGISTERTokenParamDefine(VC_tel);
1812 REGISTERTokenParamDefine(VC_work);
1813 REGISTERTokenParamDefine(VC_home);
1814 REGISTERTokenParamDefine(VC_cell);
1815 REGISTERTokenParamDefine(VC_adr);
1816 REGISTERTokenParamDefine(VC_photo);
1817 REGISTERTokenParamDefine(VC_version);
1818 REGISTERTokenParamDefine(VC_rev);
1819 REGISTERTokenParamDefine(VC_label);
1823 StrBuf *Prefix = NewStrBufPlain(HKEY("VC:"));
1824 DefineToToken = NewHash(1, lFlathash);
1825 VCTokenToDefine = NewHash(1, NULL);
1826 autoRegisterTokens(&VCEnumCounter, VCStrE, Prefix, 0);
1827 FreeStrBuf(&Prefix);
1829 RegisterCTX(CTX_VCARD);
1830 RegisterNamespace("VC:ITEM", 2, 2, tmpl_vcard_item, preeval_vcard_item, CTX_VCARD);
1831 RegisterNamespace("VC:NAME", 1, 1, tmpl_vcard_name_str, preeval_vcard_name_str, CTX_VCARD);