}
}
-void set_preference(char *key, char *value) {
+void set_preference(char *key, char *value, int save_to_server) {
int num_prefs;
int i;
char buf[SIZ];
free(WC->preferences);
WC->preferences = newprefs;
- save_preferences();
+ if (save_to_server) save_preferences();
+}
+
+
+
+
+/*
+ * display form for changing your preferences and settings
+ */
+void display_preferences(void)
+{
+ output_headers(1, 1, 2, 0, 0, 0, 0);
+ char buf[256];
+
+ wprintf("<div id=\"banner\">\n");
+ wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
+ wprintf("<IMG SRC=\"/static/advanpage2_48x.gif\" ALT=\" \" ALIGN=MIDDLE>");
+ wprintf("<SPAN CLASS=\"titlebar\"> Preferences and settings");
+ wprintf("</SPAN></TD><TD ALIGN=RIGHT>");
+ offer_start_page();
+ wprintf("</TD></TR></TABLE>\n");
+ wprintf("</div>\n"
+ "<div id=\"content\">\n");
+
+ wprintf("<div id=\"fix_scrollbar_bug\">"
+ "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
+
+ /* begin form */
+ wprintf("<center>\n"
+ "<form name=\"prefform\" action=\"set_preferences\" "
+ "method=\"post\">\n"
+ "<table border=0 cellspacing=5 cellpadding=5>\n");
+
+
+ get_preference("roomlistview", buf, sizeof buf);
+ wprintf("<tr><td>Room list view</td><td>");
+
+ wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"folders\"");
+ if (!strcasecmp(buf, "folders")) wprintf(" checked");
+ wprintf(">Tree (folders) view<br></input>\n");
+
+ wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"rooms\"");
+ if (!strcasecmp(buf, "rooms")) wprintf(" checked");
+ wprintf(">Table (rooms) view<br></input>\n");
+
+ wprintf("</td></tr>\n");
+
+
+ get_preference("calhourformat", buf, sizeof buf);
+ if (buf[0] == 0) strcpy(buf, "12");
+ wprintf("<tr><td>Calendar hour format</td><td>");
+
+ wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"12\"");
+ if (!strcasecmp(buf, "12")) wprintf(" checked");
+ wprintf(">12 hour (am/pm)<br></input>\n");
+
+ wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"24\"");
+ if (!strcasecmp(buf, "24")) wprintf(" checked");
+ wprintf(">24 hour<br></input>\n");
+
+ wprintf("</td></tr>\n");
+
+ wprintf("</table>\n"
+ "<input type=\"submit\" name=\"action\" value=\"Change\">"
+ " "
+ "<INPUT type=\"submit\" name=\"action\" value=\"Cancel\">\n");
+
+ wprintf("</form></center>\n");
+
+ /* end form */
+
+
+ wprintf("</td></tr></table></div>\n");
+ wDumpContent(1);
+}
+
+/*
+ * Commit new preferences and settings
+ */
+void set_preferences(void)
+{
+ if (strcmp(bstr("action"), "Change")) {
+ safestrncpy(WC->ImportantMessage,
+ "Cancelled. No settings were changed.",
+ sizeof WC->ImportantMessage);
+ display_main_menu();
+ return;
+ }
+
+ /* Set the last argument to 1 only for the final setting, so
+ * we don't send the prefs file to the server repeatedly
+ */
+ set_preference("roomlistview", bstr("roomlistview"), 0);
+ set_preference("calhourformat", bstr("calhourformat"), 1);
+
+ display_main_menu();
}