/*
* $Id$
*/
-/**
- * \defgroup vCardEdit Handles on-screen editing of vCard objects.
- * \ingroup VCards
- */
-/*@{*/
+
#include "webcit.h"
-#include "vcard.h"
-/**
- * \brief Edit the vCard component of a MIME message.
+/*
+ * 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) {
+void do_edit_vcard(long msgnum, char *partnum, char *return_to, char *force_room) {
char buf[SIZ];
char *serialized_vcard = NULL;
size_t total_len = 0;
char country[256];
char hometel[256];
char worktel[256];
+ char faxtel[256];
+ char mobiletel[256];
char primary_inetemail[256];
char other_inetemail[SIZ];
char extrafields[SIZ];
country[0] = 0;
hometel[0] = 0;
worktel[0] = 0;
+ faxtel[0] = 0;
+ mobiletel[0] = 0;
primary_inetemail[0] = 0;
other_inetemail[0] = 0;
title[0] = 0;
safestrncpy(org, value, sizeof org);
}
- else if (!strcasecmp(key, "adr")) {
+ else if ( (!strcasecmp(key, "adr")) || (!strncasecmp(key, "adr;", 4)) ) {
extract_token(pobox, value, 0, ';', sizeof pobox);
extract_token(extadr, value, 1, ';', sizeof extadr);
extract_token(street, value, 2, ';', sizeof street);
extract_token(country, value, 6, ';', sizeof country);
}
- else if (!strcasecmp(key, "tel;home")) {
+ else if ( (!strcasecmp(key, "tel;home")) || (!strcasecmp(key, "tel;type=home")) ) {
extract_token(hometel, value, 0, ';', sizeof hometel);
}
- else if (!strcasecmp(key, "tel;work")) {
+ else if ( (!strcasecmp(key, "tel;work")) || (!strcasecmp(key, "tel;type=work")) ) {
extract_token(worktel, value, 0, ';', sizeof worktel);
}
- else if (!strcasecmp(key, "email;internet")) {
+ else if ( (!strcasecmp(key, "tel;fax")) || (!strcasecmp(key, "tel;type=fax")) ) {
+ extract_token(faxtel, value, 0, ';', sizeof faxtel);
+ }
+
+ else if ( (!strcasecmp(key, "tel;cell")) || (!strcasecmp(key, "tel;type=cell")) ) {
+ extract_token(mobiletel, value, 0, ';', sizeof mobiletel);
+ }
+
+ else if ( (!strcasecmp(key, "email;internet"))
+ || (!strcasecmp(key, "email;type=internet")) ) {
if (primary_inetemail[0] == 0) {
safestrncpy(primary_inetemail, value, sizeof primary_inetemail);
}
}
/** Display the form */
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n"
- "<table class=\"vcard_edit_banner\"><tr><td>"
- "<span class=\"titlebar\">"
- "<img src=\"static/savecontact_48x.gif\">");
- wprintf(_("Edit contact information"));
- wprintf("</span>"
- "</td></tr></table>\n"
- "</div>\n<div id=\"content\">\n"
- );
+ output_headers(1, 1, 1, 0, 0, 0);
+
+ svput("BOXTITLE", WCS_STRING, _("Edit contact information"));
+ do_template("beginbox", NULL);
wprintf("<form method=\"POST\" action=\"submit_vcard\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+
+ if (force_room != NULL) {
+ wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
+ escputs(force_room);
+ wprintf("\">\n");
+ }
+
wprintf("<div class=\"fix_scrollbar_bug\">"
"<table class=\"vcard_edit_background\"><tr><td>\n");
wprintf(_("Work telephone:"));
wprintf("</td>"
"<td><input type=\"text\" name=\"worktel\" "
- "value=\"%s\" maxlength=\"29\"></td></tr></table>\n",
+ "value=\"%s\" maxlength=\"29\"></td></tr>\n",
worktel);
+ wprintf("<tr><td>");
+ wprintf(_("Mobile telephone:"));
+ wprintf("</td>"
+ "<td><input type=\"text\" name=\"mobiletel\" "
+ "value=\"%s\" maxlength=\"29\"></td>\n",
+ mobiletel);
+ wprintf("<td>");
+ wprintf(_("Fax number:"));
+ wprintf("</td>"
+ "<td><input type=\"text\" name=\"faxtel\" "
+ "value=\"%s\" maxlength=\"29\"></td></tr></table>\n",
+ faxtel);
wprintf("<table class=\"vcard_edit_background_alt\">");
wprintf("<tr><td>");
urlescputs(return_to);
wprintf("\">\n");
- wprintf("<center>\n"
+ wprintf("<div class=\"buttons\">\n"
"<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
" "
"<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
- "</center></form>\n",
+ "</div></form>\n",
_("Save changes"),
_("Cancel")
);
- wprintf("</td></tr></table></div>\n");
+ wprintf("</td></tr></table>\n");
+ do_template("endbox", NULL);
wDumpContent(1);
}
/**
- * \brief commit the edits to the citadel server
+ * commit the edits to the citadel server
*/
void edit_vcard(void) {
long msgnum;
char *partnum;
- msgnum = atol(bstr("msgnum"));
+ msgnum = lbstr("msgnum");
partnum = bstr("partnum");
- do_edit_vcard(msgnum, partnum, "");
+ do_edit_vcard(msgnum, partnum, "", NULL);
}
/**
- * \brief parse edited vcard from the browser
+ * parse edited vcard from the browser
*/
void submit_vcard(void) {
struct vCard *v;
char buf[SIZ];
int i;
- if (IsEmptyStr(bstr("ok_button"))) {
+ 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);
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) {
-/*@}*/
+void
+InitModule_VCARD
+(void)
+{
+ WebcitAddUrlHandler(HKEY("edit_vcard"), edit_vcard, 0);
+ WebcitAddUrlHandler(HKEY("submit_vcard"), submit_vcard, 0);
+}
+