* Wrote some skeleton code for robust vCard editing
authorArt Cancro <ajc@citadel.org>
Mon, 4 Mar 2002 05:28:54 +0000 (05:28 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 4 Mar 2002 05:28:54 +0000 (05:28 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/messages.c
webcit/vcard.c
webcit/vcard_edit.c [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h

index a5b827b1dabd5eaea4d6f7f70864e07fa90c9aa5..9b5083baac9dc457004e5dd42ab9c08165680c91 100644 (file)
@@ -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 <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 277dd55906567e1ea8d1370611dbc01000fa398b..0fa91a9c225e78c617dd7b3da49ff92b03596e02 100644 (file)
@@ -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
index e5a1b2a0173ecfbb1e29172de2b0ffa04ef6c0b7..15e514ba3a0b932278c8eeb9ed2da3af042bda7e 100644 (file)
@@ -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("<A HREF=\"/edit_vcard?msgnum=%ld&partnum=%s\">",
+                               msgnum, vcard_partnum);
+                       wprintf("(edit)</A>");
+
                        display_vcard(vcard_source);
                        free(vcard_source);
                }
index d5ff0b64902eda260857d8c10ae227601004e244..03a16b689d196c5851ec29d8156131b4bbe772ad 100644 (file)
@@ -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 (file)
index 0000000..9f3912b
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * vcard_edit.c
+ *
+ * Handles editing of vCard objects.
+ *
+ * $Id$
+ */
+
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
+#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<BR>\n", &buf[4]);
+               }
+       }
+
+       serv_puts("CLOS");
+       serv_gets(buf);
+       serialized_vcard[total_len + 1] = 0;
+
+       v = vcard_load(serialized_vcard);
+       free(serialized_vcard);
+
+       wprintf("<BLINK>   FIXME    </BLINK><BR><BR>\n"
+               "This needs to be implemented as an editable form.<BR><BR>\n");
+
+       i = 0;
+       while (prop = vcard_get_prop(v, "", 0, i++), prop != NULL) {
+               escputs(prop);
+               wprintf("<BR>\n");
+       }
+       
+       vcard_free(v);
+        
+       wDumpContent(1);
+}
index f8839f8444d6049a7dd4f5456e29e2a4beea1757..6020da81bca3b40c2533e22e5913722f133b2be7 100644 (file)
@@ -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);
 
index e54372d6171566a4c8fc22520461f11f5231d32f..5b98fb1e8b87dcf5a4c2a96bbe779753f86c63ff 100644 (file)
@@ -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);