+
+
+/**
+ * \brief commit the edits to the citadel server
+ */
+void edit_vcard(void) {
+ long msgnum;
+ char *partnum;
+
+ msgnum = lbstr("msgnum");
+ partnum = bstr("partnum");
+ do_edit_vcard(msgnum, partnum, "", NULL);
+}
+
+
+
+/**
+ * \brief parse edited vcard from the browser
+ */
+void submit_vcard(void) {
+ struct vCard *v;
+ char *serialized_vcard;
+ char buf[SIZ];
+ int i;
+
+ if (!havebstr("ok_button")) {
+ readloop("readnew");
+ return;
+ }
+
+ if (havebstr("force_room")) {
+ gotoroom(bstr("force_room"));
+ }
+
+ sprintf(buf, "ENT0 1|||4||");
+ serv_puts(buf);
+ serv_getln(buf, sizeof buf);
+ if (buf[0] != '4') {
+ edit_vcard();
+ return;
+ }
+
+ /** Make a vCard structure out of the data supplied in the form */
+
+ snprintf(buf, sizeof buf, "begin:vcard\r\n%s\r\nend:vcard\r\n",
+ bstr("extrafields")
+ );
+ v = vcard_load(buf); /** Start with the extra fields */
+ if (v == NULL) {
+ safestrncpy(WC->ImportantMessage,
+ _("An error has occurred."),
+ sizeof WC->ImportantMessage
+ );
+ edit_vcard();
+ return;
+ }
+
+ snprintf(buf, sizeof buf, "%s;%s;%s;%s;%s",
+ bstr("lastname"),
+ bstr("firstname"),
+ bstr("middlename"),
+ bstr("prefix"),
+ bstr("suffix") );
+ vcard_add_prop(v, "n", buf);
+
+ vcard_add_prop(v, "title", bstr("title"));
+ vcard_add_prop(v, "fn", bstr("fullname"));
+ vcard_add_prop(v, "org", bstr("org"));
+
+ snprintf(buf, sizeof buf, "%s;%s;%s;%s;%s;%s;%s",
+ bstr("pobox"),
+ bstr("extadr"),
+ bstr("street"),
+ bstr("city"),
+ bstr("state"),
+ bstr("zipcode"),
+ bstr("country") );
+ vcard_add_prop(v, "adr", buf);
+
+ vcard_add_prop(v, "tel;home", bstr("hometel"));
+ vcard_add_prop(v, "tel;work", bstr("worktel"));
+ vcard_add_prop(v, "tel;fax", bstr("faxtel"));
+ vcard_add_prop(v, "tel;cell", bstr("mobiletel"));
+ vcard_add_prop(v, "email;internet", bstr("primary_inetemail"));
+
+ for (i=0; i<num_tokens(bstr("other_inetemail"), '\n'); ++i) {
+ extract_token(buf, bstr("other_inetemail"), i, '\n', sizeof buf);
+ if (!IsEmptyStr(buf)) {
+ vcard_add_prop(v, "email;internet", buf);
+ }
+ }
+
+ serialized_vcard = vcard_serialize(v);
+ vcard_free(v);
+ if (serialized_vcard == NULL) {
+ safestrncpy(WC->ImportantMessage,
+ _("An error has occurred."),
+ sizeof WC->ImportantMessage
+ );
+ edit_vcard();
+ return;
+ }
+
+ serv_puts("Content-type: text/x-vcard; charset=UTF-8");
+ serv_puts("");
+ serv_printf("%s\r\n", serialized_vcard);
+ serv_puts("000");
+ free(serialized_vcard);
+
+ if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
+ select_user_to_edit(NULL, NULL);
+ }
+ else if (!strcmp(bstr("return_to"), "do_welcome")) {
+ do_welcome();
+ }
+ else {
+ readloop("readnew");
+ }
+}
+
+
+
+/*@}*/