From: Art Cancro Date: Thu, 9 May 2002 03:53:56 +0000 (+0000) Subject: * Began working on address book view X-Git-Tag: v7.86~6412 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=60ca3ee4ed186529bd85ed48d74e42a931f4a051;p=citadel.git * Began working on address book view --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index c41e280c2..66b3eb100 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 323.31 2002/05/09 03:53:56 ajc +* Began working on address book view + Revision 323.30 2002/05/08 03:38:58 ajc * Preferences framework @@ -806,4 +809,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 30a41e41b..e979beeb8 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -286,7 +286,6 @@ void context_loop(int sock) } - /* * See if there's an existing session open with the desired ID */ diff --git a/webcit/messages.c b/webcit/messages.c index e949d12a5..bf44814d9 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -82,19 +82,13 @@ char buf[]; } - - -/* - * Experimental output type of thing +/* display_vcard() calls this after parsing the textual vCard into + * our 'struct vCard' data object. */ -void display_vcard(char *vcard_source) { +void display_parsed_vcard(struct vCard *v) { int i, j; - struct vCard *v; char buf[SIZ]; - v = vcard_load(vcard_source); - if (v == NULL) return; - wprintf(""); if (v->numprops) for (i=0; i<(v->numprops); ++i) { if (!strcasecmp(v->prop[i].name, "n")) { @@ -144,8 +138,36 @@ void display_vcard(char *vcard_source) { wprintf("\n"); } } - wprintf("
\n"); +} + + + +/* + * Experimental output type of thing + */ +void display_vcard(char *vcard_source, char alpha) { + struct vCard *v; + char *name; + char buf[SIZ]; + char this_alpha = 0; + + v = vcard_load(vcard_source); + if (v == NULL) return; + + name = vcard_get_prop(v, "n", 1, 0, 0); + if (name != NULL) { + strcpy(buf, name); + this_alpha = buf[0]; + } + + if ( (alpha == 0) + || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) ) + || ((!isalpha(alpha)) && (!isalpha(this_alpha))) ) { + + display_parsed_vcard(v); + + } vcard_free(v); } @@ -399,7 +421,7 @@ void read_message(long msgnum) { } /* In all cases, display it */ - display_vcard(vcard_source); + display_vcard(vcard_source, 0); free(vcard_source); } } @@ -476,6 +498,70 @@ void summarize_message(long msgnum) { +void display_addressbook(long msgnum, char alpha) { + char buf[SIZ]; + char mime_partnum[SIZ]; + char mime_filename[SIZ]; + char mime_content_type[SIZ]; + char mime_disposition[SIZ]; + int mime_length; + char vcard_partnum[SIZ]; + char *vcard_source = NULL; + + struct { + char date[SIZ]; + char from[SIZ]; + char to[SIZ]; + char subj[SIZ]; + int hasattachments; + } summ; + + memset(&summ, 0, sizeof(summ)); + strcpy(summ.subj, "(no subject)"); + + sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */ + serv_puts(buf); + serv_gets(buf); + if (buf[0] != '1') return; + + while (serv_gets(buf), strcmp(buf, "000")) { + if (!strncasecmp(buf, "part=", 5)) { + extract(mime_filename, &buf[5], 1); + extract(mime_partnum, &buf[5], 2); + extract(mime_disposition, &buf[5], 3); + extract(mime_content_type, &buf[5], 4); + mime_length = extract_int(&buf[5], 5); + + if (!strcasecmp(mime_content_type, "text/x-vcard")) { + strcpy(vcard_partnum, mime_partnum); + } + + } + } + + if (strlen(vcard_partnum) > 0) { + vcard_source = load_mimepart(msgnum, vcard_partnum); + if (vcard_source != NULL) { + + /* If it's my vCard I can edit it */ + if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM)) + || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) { + wprintf("", + msgnum, vcard_partnum); + wprintf("(edit)"); + } + + /* In all cases, display it */ + display_vcard(vcard_source, alpha); + free(vcard_source); + } + } + +} + + + /* * load message pointers from the server */ @@ -506,12 +592,14 @@ char *servcmd; void readloop(char *oper) { char cmd[SIZ]; - int a, b; + char buf[SIZ]; + int a, b, i; int nummsgs; long startmsg; int maxmsgs; int num_displayed = 0; int is_summary = 0; + int is_addressbook = 0; int remaining_messages; int lo, hi; int lowest_displayed = (-1); @@ -520,6 +608,7 @@ void readloop(char *oper) long pn_current = 0L; long pn_next = 0L; int bg = 0; + char alpha = 0; startmsg = atol(bstr("startmsg")); maxmsgs = atoi(bstr("maxmsgs")); @@ -540,6 +629,31 @@ void readloop(char *oper) if ((WC->wc_view == 1) && (maxmsgs > 1)) { is_summary = 1; strcpy(cmd, "MSGS ALL"); + maxmsgs = 32767; + } + if ((WC->wc_view == 2) && (maxmsgs > 1)) { + is_addressbook = 1; + strcpy(cmd, "MSGS ALL"); + maxmsgs = 32767; + if (bstr("alpha") == NULL) { + alpha = 'A'; + } + else { + strcpy(buf, bstr("alpha")); + alpha = buf[0]; + } + + for (i='A'; i<='Z'; ++i) { + if (i == alpha) wprintf("" + "%c\n", i); + else { + wprintf("" + "%c\n", i, i); + } + wprintf(" "); + } + wprintf("(other)\n"); + wprintf("
\n"); } nummsgs = load_msg_ptrs(cmd); @@ -593,6 +707,9 @@ void readloop(char *oper) summarize_message(WC->msgarr[a]); wprintf("\n"); } + else if (is_addressbook) { + display_addressbook(WC->msgarr[a], alpha); + } else { read_message(WC->msgarr[a]); } diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index af5df8bad..f497730b9 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -280,10 +280,8 @@ void submit_vcard(void) { } sprintf(buf, "ENT0 1|||4||"); - fprintf(stderr, "%s\n", buf); serv_puts(buf); serv_gets(buf); - fprintf(stderr, "%s\n", buf); if (buf[0] != '4') { edit_vcard(); return; diff --git a/webcit/webcit.c b/webcit/webcit.c index b93114efa..97dec65b0 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -29,6 +29,7 @@ #include #include #include "webcit.h" +#include "webserver.h" #include "mime_parser.h" /* @@ -435,7 +436,7 @@ void output_static(char *what) fstat(fileno(fp), &statbuf); bytes = statbuf.st_size; - fprintf(stderr, "Static: %s, %ld bytes\n", what, bytes); + lprintf(3, "Static: %s, %ld bytes\n", what, bytes); wprintf("Content-length: %ld\n", (long) bytes); wprintf("\n"); bigbuffer = malloc(bytes); @@ -462,7 +463,7 @@ void output_image() off_t thisblock; off_t accomplished = 0L; - + lprintf(5, "output_image() called\n"); serv_printf("OIMG %s|%s", bstr("name"), bstr("parm")); serv_gets(buf); if (buf[0] == '2') { @@ -682,12 +683,12 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, char *encoding, void *userdata) { - fprintf(stderr, "UPLOAD HANDLER CALLED\n"); - fprintf(stderr, " name = %s\n", name); - fprintf(stderr, "filename = %s\n", filename); - fprintf(stderr, "encoding = %s\n", encoding); - fprintf(stderr, " type = %s\n", cbtype); - fprintf(stderr, " length = %ld\n", (long)length); + lprintf(5, "UPLOAD HANDLER CALLED\n"); + lprintf(5, " name = %s\n", name); + lprintf(5, "filename = %s\n", filename); + lprintf(5, "encoding = %s\n", encoding); + lprintf(5, " type = %s\n", cbtype); + lprintf(5, " length = %ld\n", (long)length); if (length > 0) { WC->upload = malloc(length); @@ -696,7 +697,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, memcpy(WC->upload, content, length); } else { - fprintf(stderr, "malloc() failed: %s\n", + lprintf(9, "malloc() failed: %s\n", strerror(errno)); } } @@ -768,7 +769,7 @@ void session_loop(struct httprequest *req) } if (ContentLength > 0) { - fprintf(stderr, "Content length: %d\n", ContentLength); + lprintf(5, "Content length: %d\n", ContentLength); content = malloc(ContentLength + 1); memset(content, 0, ContentLength+1); BytesRead = 0;