From 2968d1e168d7cdf24d413793c55b6d0d833c7411 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 5 Mar 2002 05:05:09 +0000 Subject: [PATCH] * More vCard editing stuff --- webcit/ChangeLog | 4 ++ webcit/static/vcard.gif | Bin 0 -> 1807 bytes webcit/vcard.c | 16 ++++-- webcit/vcard.h | 2 +- webcit/vcard_edit.c | 122 +++++++++++++++++++++++++++++++++++++--- 5 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 webcit/static/vcard.gif diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 9b5083baa..dcc1a6c92 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 323.8 2002/03/05 05:05:06 ajc +* More vCard editing stuff + Revision 323.7 2002/03/04 05:28:54 ajc * Wrote some skeleton code for robust vCard editing @@ -732,3 +735,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/static/vcard.gif b/webcit/static/vcard.gif new file mode 100644 index 0000000000000000000000000000000000000000..d696d671b882f119d8959887751390e2267581ef GIT binary patch literal 1807 zcmbu8`&Z0)7{{McCdN5TNUhtBXd8U0-=CDqSI&qa$z|djoYG?=m%nAH`;+r zxG-*r)F_6~*oj!kfrC*Sr9qrXRAU-re1I22BXK_*ixC0w;}E{u?=6z{6AGK{R}r;# zqlN2s??kKJ4sitghC;~>EpB4x5W;q8{5jy2&^+9!37`TX4cc_SXLz6` z)v!m_OSN#TC9P<`(sho%)iUz#Ay?NiTT{RkkTk+0Ch3CGkhrI>uQqYR#?;%%eFqMA zduLfOYrA8^)5U!ag|ke3R2!zu&aEzS8a~J^2+~%~H3jWG=(SC02udS;C#i~3KVUp|30JG|1MDCmsR|-0wxlhlS@&3(|ak*8`Zpj;}U;aIz z@?f@RzxVGRkrylXv^Leg+`qo~jy~e1yukB$YIugSY)Mp3WTkP3tygu|!U-4Z%>xEc z37ETKuZw3_+s6l4>zCfy9%edSt0*|c9Yl|=6p|y?7 z--V_GqQuQ`NTbN*F9>)?)3-Pj|~OLfy8t*p`IrWDG0 z4;gqPQa3E-q*2>hzEY{}M_(*g^|U`u_8t||{HwvOb4HE6y^fsK@WxFcyWQo}OLYnB zLQD=$n`_T%FEzWb)R=5VrN-7zHAm+uFQ<5<&y2IkGLCJVo%NgVk2l}xf7!(s(e>%^ zq4in3dxcSZsr~qv)Sjr0u|Kmbs`G|7-3|}kXPPID$w*Zs4N!B-|9&-`0&4Xr+U)6mMQ zQ|Amz*BzR8;C_7izI+$QTa!ziLJA7KtHQb(&a_3dOqcEp?jQ5dXZm?wSAUlGYt@ zSIgBti*jUBo<2@=7}mHpX=p&prnLq|LvF3tMn25)B%x?q!9SUq4}xDG5B12t{wgl? z#{IU6Pe2Zn3fyvF;L zsg+A(9|dJbx2M0G_Mz)-;nXAFYI;tT2YWw!6rI!H7Vzb*nsTqz4fTW1H*_7ZS{$rV zOOJw0rLXcT3-q5S^k0@9c|@_W#c`{1-Je0bSJmh%dIss`F=OJB=c>Rnwy@tc)q0mx is;+6~Klsjx^WDEnll6(8e&|@U+S9h|L!g@y{Qd)%99E(L literal 0 HcmV?d00001 diff --git a/webcit/vcard.c b/webcit/vcard.c index 03a16b689..362dbe6b6 100644 --- a/webcit/vcard.c +++ b/webcit/vcard.c @@ -128,14 +128,15 @@ struct vCard *vcard_load(char *vtext) { /* - * Fetch the value of a particular key + * Fetch the value of a particular key. * If is_partial is set to 1, a partial match is ok (for example, - * a key of "tel;home" will satisfy a search for "tel") + * a key of "tel;home" will satisfy a search for "tel"). * Set "instance" to a value higher than 0 to return subsequent instances - * of the same key + * of the same key. + * Set "get_propname" to nonzero to fetch the property name instead of value. */ char *vcard_get_prop(struct vCard *v, char *propname, - int is_partial, int instance) { + int is_partial, int instance, int get_propname) { int i; int found_instance = 0; @@ -147,7 +148,12 @@ char *vcard_get_prop(struct vCard *v, char *propname, && (v->prop[i].name[strlen(propname)] == ';') && (is_partial) ) ) { if (instance == found_instance++) { - return(v->prop[i].value); + if (get_propname) { + return(v->prop[i].name); + } + else { + return(v->prop[i].value); + } } } } diff --git a/webcit/vcard.h b/webcit/vcard.h index 743efa990..aae58eb3c 100644 --- a/webcit/vcard.h +++ b/webcit/vcard.h @@ -29,5 +29,5 @@ struct vCard *vcard_load(char *); void vcard_free(struct vCard *); void vcard_set_prop(struct vCard *v, char *name, char *value, int append); char *vcard_get_prop(struct vCard *v, char *propname, int is_partial, - int instance); + int instance, int return_propname); char *vcard_serialize(struct vCard *); diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 9f3912bb4..12f15cbe7 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -6,7 +6,6 @@ * $Id$ */ - #include #include #include @@ -39,7 +38,35 @@ void edit_vcard(void) { size_t thisblock = 0; struct vCard *v; int i; - char *prop; + char *key, *value; + + char lastname[SIZ]; + char firstname[SIZ]; + char middlename[SIZ]; + char prefix[SIZ]; + char suffix[SIZ]; + char pobox[SIZ]; + char extadr[SIZ]; + char street[SIZ]; + char city[SIZ]; + char state[SIZ]; + char zipcode[SIZ]; + char country[SIZ]; + char extrafields[SIZ]; + + lastname[0] = 0; + firstname[0] = 0; + middlename[0] = 0; + prefix[0] = 0; + suffix[0] = 0; + pobox[0] = 0; + extadr[0] = 0; + street[0] = 0; + city[0] = 0; + state[0] = 0; + zipcode[0] = 0; + country[0] = 0; + extrafields[0] = 0; output_headers(1); sprintf(buf, "OPNA %s|%s", bstr("msgnum"), bstr("partnum") ); @@ -75,16 +102,95 @@ void edit_vcard(void) { v = vcard_load(serialized_vcard); free(serialized_vcard); - wprintf(" FIXME

\n" - "This needs to be implemented as an editable form.

\n"); - + /* Populate the variables for our form */ i = 0; - while (prop = vcard_get_prop(v, "", 0, i++), prop != NULL) { - escputs(prop); - wprintf("
\n"); + while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) { + value = vcard_get_prop(v, "", 0, i++, 0); + + if (!strcasecmp(key, "n")) { + extract_token(lastname, value, 0, ';'); + extract_token(firstname, value, 1, ';'); + extract_token(middlename, value, 2, ';'); + extract_token(prefix, value, 3, ';'); + extract_token(suffix, value, 4, ';'); + } + + else if (!strcasecmp(key, "adr")) { + extract_token(pobox, value, 0, ';'); + extract_token(extadr, value, 1, ';'); + extract_token(street, value, 2, ';'); + extract_token(city, value, 3, ';'); + extract_token(state, value, 4, ';'); + extract_token(zipcode, value, 5, ';'); + extract_token(country, value, 6, ';'); + } + + else { + strcat(extrafields, key); + strcat(extrafields, ":"); + strcat(extrafields, value); + strcat(extrafields, "\n"); + } + } vcard_free(v); + + /* Display the form */ + wprintf("
\n"); + wprintf("

" + "Contact information for FIXME

\n"); + + wprintf("Last name: " + "
\n", + lastname); + wprintf("First name: " + "
\n", + firstname); + wprintf("Prefix: " + "
\n", + prefix); + wprintf("Suffix: " + "

\n", + suffix); + + wprintf("" + "\n", + pobox); + wprintf("" + "\n", + extadr); + wprintf("" + "\n", + street); + wprintf("" + "\n", + zipcode); + wprintf("" + "
Address - PO box; optional:
Street:
 
City:\n", + city); + wprintf(" State: " + "\n", + state); + wprintf(" ZIP code: " + "
Country:
\n", + country); + + wprintf("
\n"); + wDumpContent(1); } -- 2.39.2