X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fvcard_edit.c;h=2a77b7c38f967bdfc7f5d1f81d73886667b43183;hb=44c30618e25ce2eb103b87e84e10dcd51dad0879;hp=1eec8b339a13bc04d86523a5d1847c988bd070c8;hpb=6ddcd59c0dff99062b7c3cdbcd8bdbc2f28563cb;p=citadel.git diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 1eec8b339..2a77b7c38 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -1,37 +1,22 @@ /* - * 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 +/** + * \defgroup vCardEdit Handles on-screen editing of vCard objects. + * \ingroup WebFrontend + */ +/*@{*/ #include "webcit.h" #include "vcard.h" - -/* Edit the vCard component of a MIME message. Supply the message number +/** + * \brief Edit the vCard component of a MIME message. + * Supply the message number * and MIME part number to fetch. Or, specify -1 for the message number * to start with a blank card. + * \param msgnum number of the item on the citadel server + * \param partnum what??? + * \param return_to where to go back in the browser after edit ???? */ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { char buf[SIZ]; @@ -40,24 +25,28 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { struct vCard *v; int i; char *key, *value; - char whatuser[SIZ]; - - 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 hometel[SIZ]; - char worktel[SIZ]; - char inetemail[SIZ]; + char whatuser[256]; + + char lastname[256]; + char firstname[256]; + char middlename[256]; + char prefix[256]; + char suffix[256]; + char pobox[256]; + char extadr[256]; + char street[256]; + char city[256]; + char state[256]; + char zipcode[256]; + char country[256]; + char hometel[256]; + char worktel[256]; + char primary_inetemail[256]; + char other_inetemail[SIZ]; char extrafields[SIZ]; + char fullname[256]; + char title[256]; + char org[256]; lastname[0] = 0; firstname[0] = 0; @@ -73,24 +62,25 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { country[0] = 0; hometel[0] = 0; worktel[0] = 0; - inetemail[0] = 0; + primary_inetemail[0] = 0; + other_inetemail[0] = 0; + title[0] = 0; + org[0] = 0; extrafields[0] = 0; - output_headers(3); - - strcpy(whatuser, ""); + safestrncpy(whatuser, "", sizeof whatuser); if (msgnum >= 0) { sprintf(buf, "MSG0 %ld|1", msgnum); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '1') { - wDumpContent(1); + convenience_page("770000", _("Error"), &buf[4]); return; } - while (serv_gets(buf), strcmp(buf, "000")) { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { if (!strncasecmp(buf, "from=", 5)) { - strcpy(whatuser, &buf[5]); + safestrncpy(whatuser, &buf[5], sizeof whatuser); } else if (!strncasecmp(buf, "node=", 5)) { strcat(whatuser, " @ "); @@ -100,20 +90,20 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { sprintf(buf, "OPNA %ld|%s", msgnum, partnum); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { - wDumpContent(1); + convenience_page("770000", "Error", &buf[4]); return; } total_len = atoi(&buf[4]); - serialized_vcard = malloc(total_len + 1); + serialized_vcard = malloc(total_len + 2); read_server_binary(serialized_vcard, total_len); serv_puts("CLOS"); - serv_gets(buf); - serialized_vcard[total_len + 1] = 0; + serv_getln(buf, sizeof buf); + serialized_vcard[total_len] = 0; v = vcard_load(serialized_vcard); free(serialized_vcard); @@ -124,36 +114,53 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { 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, ';'); + extract_token(lastname, value, 0, ';', sizeof lastname); + extract_token(firstname, value, 1, ';', sizeof firstname); + extract_token(middlename, value, 2, ';', sizeof middlename); + extract_token(prefix, value, 3, ';', sizeof prefix); + extract_token(suffix, value, 4, ';', sizeof suffix); + } + + else if (!strcasecmp(key, "fn")) { + safestrncpy(fullname, value, sizeof fullname); + } + + else if (!strcasecmp(key, "title")) { + safestrncpy(title, value, sizeof title); + } + + else if (!strcasecmp(key, "org")) { + safestrncpy(org, value, sizeof org); } 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, ';'); + extract_token(pobox, value, 0, ';', sizeof pobox); + extract_token(extadr, value, 1, ';', sizeof extadr); + extract_token(street, value, 2, ';', sizeof street); + extract_token(city, value, 3, ';', sizeof city); + extract_token(state, value, 4, ';', sizeof state); + extract_token(zipcode, value, 5, ';', sizeof zipcode); + extract_token(country, value, 6, ';', sizeof country); } else if (!strcasecmp(key, "tel;home")) { - extract_token(hometel, value, 0, ';'); + extract_token(hometel, value, 0, ';', sizeof hometel); } else if (!strcasecmp(key, "tel;work")) { - extract_token(worktel, value, 0, ';'); + extract_token(worktel, value, 0, ';', sizeof worktel); } else if (!strcasecmp(key, "email;internet")) { - if (inetemail[0] != 0) { - strcat(inetemail, "\n"); + if (primary_inetemail[0] == 0) { + safestrncpy(primary_inetemail, value, sizeof primary_inetemail); + } + else { + if (other_inetemail[0] != 0) { + strcat(other_inetemail, "\n"); + } + strcat(other_inetemail, value); } - strcat(inetemail, value); } else { @@ -168,22 +175,32 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { vcard_free(v); } - /* Display the form */ - do_template("beginbox_nt"); - wprintf("
\n"); - wprintf("

" - "Contact information for "); - escputs(whatuser); - wprintf("

\n"); + /** Display the form */ + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n" + "
" + "" + ""); + wprintf(_("Edit contact information")); + wprintf("" + "
\n" + "
\n
\n" + ); + + wprintf("\n"); + wprintf("
" + "
\n"); wprintf("" - "" - "" - "" - "" - "\n"); + "" + "" + "" + "" + "\n", + _("Prefix"), _("First"), _("Middle"), _("Last"), _("Suffix") + ); wprintf("", + "VALUE=\"%s\" MAXLENGTH=\"5\" SIZE=\"5\">", prefix); wprintf("", @@ -195,54 +212,112 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { "VALUE=\"%s\" MAXLENGTH=\"29\">", lastname); wprintf("
PrefixFirstMiddleLastSuffix
%s%s%s%s%s
\n", + "VALUE=\"%s\" MAXLENGTH=\"10\" SIZE=\"10\">
\n", suffix); - wprintf("" - "\n", + wprintf("
PO box (optional):
"); + wprintf("\n", country); + wprintf("
"); + + wprintf(_("Display name:")); + wprintf("
" + "

\n", + fullname + ); + + wprintf(_("Title:")); + wprintf("
" + "

\n", + title + ); + + wprintf(_("Organization:")); + wprintf("
" + "

\n", + org + ); + + wprintf("
"); + + wprintf(""); + wprintf("\n", pobox); - wprintf("" - "\n", + wprintf("\n", extadr); - wprintf("" - "\n", + wprintf("\n", street); - wprintf("" - "\n", city); - wprintf(" State: " + wprintf("\n", state); - wprintf(" ZIP code: " + wprintf("\n", + "VALUE=\"%s\" MAXLENGTH=\"10\">\n", zipcode); - wprintf("" - "
"); + wprintf(_("PO box:")); + wprintf("" + "
Address line 1:
"); + wprintf(_("Address:")); + wprintf("" + "
Address line 2:
" + "
City:\n", + wprintf("
"); + wprintf(_("City:")); + wprintf("" + "
"); + wprintf(_("State:")); + wprintf("" "\n", + "VALUE=\"%s\" MAXLENGTH=\"2\">
"); + wprintf(_("ZIP code:")); + wprintf("" "
Country:
\n", + wprintf("
"); + wprintf(_("Country:")); + wprintf("" + "
\n"); - wprintf("" + wprintf("
Home telephone:
\n"); + + wprintf("" "\n", + "VALUE=\"%s\" MAXLENGTH=\"29\">\n", hometel); - wprintf("" + wprintf("" "
"); + wprintf(_("Home telephone:")); + wprintf("
Work telephone:"); + wprintf(_("Work telephone:")); + wprintf("
\n", worktel); - wprintf("
Internet e-mail addresses:
" - "For addresses in the Citadel directory, " - "the topmost address will be used in outgoing mail." - "
" - "

\n"); + wprintf(""); + wprintf("
"); + + wprintf("" + "
"); + wprintf(_("Primary Internet e-mail address")); + wprintf("
" + "
" + "
"); + wprintf(_("Internet e-mail aliases")); + wprintf("
" + "
\n"); + + wprintf("
\n"); wprintf("\n"); wprintf("
\n" - "" + "" " " - "" - "
\n" + "" + "\n", + _("Save changes"), + _("Cancel") ); - do_template("endbox"); + wprintf("
\n"); wDumpContent(1); } - +/** + * \brief commit the edits to the citadel server + */ void edit_vcard(void) { long msgnum; char *partnum; @@ -276,19 +355,21 @@ void edit_vcard(void) { - +/** + * \brief parse edited vcard from the browser + */ void submit_vcard(void) { char buf[SIZ]; int i; - if (strcmp(bstr("sc"), "OK")) { + if (strlen(bstr("ok_button")) == 0) { readloop("readnew"); return; } sprintf(buf, "ENT0 1|||4||"); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '4') { edit_vcard(); return; @@ -303,6 +384,9 @@ void submit_vcard(void) { bstr("middlename"), bstr("prefix"), bstr("suffix") ); + serv_printf("title:%s", bstr("title") ); + serv_printf("fn:%s", bstr("fullname") ); + serv_printf("org:%s", bstr("org") ); serv_printf("adr:%s;%s;%s;%s;%s;%s;%s", bstr("pobox"), bstr("extadr"), @@ -313,9 +397,10 @@ void submit_vcard(void) { bstr("country") ); serv_printf("tel;home:%s", bstr("hometel") ); serv_printf("tel;work:%s", bstr("worktel") ); - - for (i=0; i 0) { serv_printf("email;internet:%s", buf); } @@ -325,13 +410,17 @@ void submit_vcard(void) { serv_puts("end:vcard"); serv_puts("000"); - if (!strcmp(bstr("return_to"), "/select_user_to_edit")) { + if (!strcmp(bstr("return_to"), "select_user_to_edit")) { select_user_to_edit(NULL, NULL); } - else if (!strcmp(bstr("return_to"), "/do_welcome")) { + else if (!strcmp(bstr("return_to"), "do_welcome")) { do_welcome(); } else { readloop("readnew"); } } + + + +/*@}*/