From: Art Cancro Date: Mon, 4 Mar 2002 05:28:54 +0000 (+0000) Subject: * Wrote some skeleton code for robust vCard editing X-Git-Tag: v7.86~6521 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=b34dc3e75dc36ca22dd951adf45d07bea41d1229;p=citadel.git * Wrote some skeleton code for robust vCard editing --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index a5b827b1d..9b5083baa 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 323.7 2002/03/04 05:28:54 ajc +* Wrote some skeleton code for robust vCard editing + Revision 323.6 2002/03/03 06:58:25 ajc * Login errors displayed in red @@ -729,4 +732,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 277dd5590..0fa91a9c2 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -25,12 +25,12 @@ distclean: clean webserver: webserver.o context_loop.o tools.o \ cookie_conversion.o locate_host.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \ - roomops.o messages.o userlist.o paging.o sysmsgs.o vcard.o \ + roomops.o messages.o userlist.o paging.o sysmsgs.o vcard.o vcard_edit.o \ mime_parser.o graphics.o netconf.o siteconfig.o subst.o $(LIBOBJS) $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \ roomops.o messages.o userlist.o paging.o sysmsgs.o \ - locate_host.o siteconfig.o subst.o vcard.o \ + locate_host.o siteconfig.o subst.o vcard.o vcard_edit.o \ mime_parser.o graphics.o netconf.o \ $(LIBOBJS) $(LIBS) -o webserver strip webserver diff --git a/webcit/messages.c b/webcit/messages.c index e5a1b2a01..15e514ba3 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -391,6 +391,15 @@ void read_message(long msgnum, int is_summary) { if (strlen(vcard_partnum) > 0) { vcard_source = load_mimepart(msgnum, vcard_partnum); if (vcard_source != NULL) { + + /* FIXME this is a temporary hack to make the screen usable + * while we build it. We need a more intuitive way of getting + * in. + */ + wprintf("", + msgnum, vcard_partnum); + wprintf("(edit)"); + display_vcard(vcard_source); free(vcard_source); } diff --git a/webcit/vcard.c b/webcit/vcard.c index d5ff0b649..03a16b689 100644 --- a/webcit/vcard.c +++ b/webcit/vcard.c @@ -141,6 +141,7 @@ char *vcard_get_prop(struct vCard *v, char *propname, if (v->numprops) for (i=0; i<(v->numprops); ++i) { if ( (!strcasecmp(v->prop[i].name, propname)) + || (propname[0] == 0) || ( (!strncasecmp(v->prop[i].name, propname, strlen(propname))) && (v->prop[i].name[strlen(propname)] == ';') diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c new file mode 100644 index 000000000..9f3912bb4 --- /dev/null +++ b/webcit/vcard_edit.c @@ -0,0 +1,90 @@ +/* + * vcard_edit.c + * + * Handles editing of vCard objects. + * + * $Id$ + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "vcard.h" + + + +void edit_vcard(void) { + char buf[SIZ]; + char *serialized_vcard = NULL; + size_t total_len = 0; + size_t bytes = 0; + size_t thisblock = 0; + struct vCard *v; + int i; + char *prop; + + output_headers(1); + sprintf(buf, "OPNA %s|%s", bstr("msgnum"), bstr("partnum") ); + serv_puts(buf); + serv_gets(buf); + if (buf[0] != '2') { + wDumpContent(1); + return; + } + + total_len = atoi(&buf[4]); + serialized_vcard = malloc(total_len + 1); + while (bytes < total_len) { + thisblock = 4000; + if ((total_len - bytes) < thisblock) thisblock = total_len - bytes; + sprintf(buf, "READ %d|%d", bytes, thisblock); + serv_puts(buf); + serv_gets(buf); + if (buf[0] == '6') { + thisblock = atoi(&buf[4]); + serv_read(&serialized_vcard[bytes], thisblock); + bytes += thisblock; + } + else { + wprintf("Error: %s
\n", &buf[4]); + } + } + + serv_puts("CLOS"); + serv_gets(buf); + serialized_vcard[total_len + 1] = 0; + + v = vcard_load(serialized_vcard); + free(serialized_vcard); + + wprintf(" FIXME

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

\n"); + + i = 0; + while (prop = vcard_get_prop(v, "", 0, i++), prop != NULL) { + escputs(prop); + wprintf("
\n"); + } + + vcard_free(v); + + wDumpContent(1); +} diff --git a/webcit/webcit.c b/webcit/webcit.c index f8839f844..6020da81b 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1031,6 +1031,8 @@ void session_loop(struct httprequest *req) display_menubar(1); } else if (!strcasecmp(action, "output_mimepart")) { output_mimepart(); + } else if (!strcasecmp(action, "edit_vcard")) { + edit_vcard(); } else if (!strcasecmp(action, "diagnostics")) { output_headers(1); diff --git a/webcit/webcit.h b/webcit/webcit.h index e54372d61..5b98fb1e8 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -287,3 +287,4 @@ void remove_token(char *source, int parmnum, char separator); int decode_base64(char *dest, char *source); char *load_mimepart(long msgnum, char *partnum); int pattern2(char *search, char *patn); +void edit_vcard(void);