*** empty log message ***
authorArt Cancro <ajc@citadel.org>
Thu, 10 Mar 2005 04:51:54 +0000 (04:51 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 10 Mar 2005 04:51:54 +0000 (04:51 +0000)
webcit/Makefile.in
webcit/auth.c
webcit/setup_wizard.c [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c

index 225d91817fed9c0284637fa6675482acb4bed232..09f5f833e17acefa7e16e43798c75c2b1dfd92a2 100644 (file)
@@ -38,7 +38,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \
        calendar.o calendar_tools.o calendar_view.o event.o \
        availability.o iconbar.o crypto.o inetconf.o notes.o \
        groupdav_main.o groupdav_get.o groupdav_propfind.o \
-       groupdav_delete.o groupdav_put.o http_datestring.o \
+       groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \
        $(LIBOBJS)
        $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \
        webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \
@@ -48,7 +48,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \
        summary.o calendar.o calendar_tools.o calendar_view.o event.o \
        availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \
        groupdav_main.o groupdav_get.o groupdav_propfind.o groupdav_delete.o \
-       groupdav_put.o http_datestring.o \
+       groupdav_put.o http_datestring.o setup_wizard.o \
        $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webserver
 
 .c.o:
index a837c275f4e6884b2eeec9d2aaff8fcdbf0c1855..b7d6b64a27de109be3f0479a57012f28b06ea5a2 100644 (file)
@@ -154,15 +154,47 @@ void do_login(void)
 
 void do_welcome(void)
 {
-       char startpage[SIZ];
+       char buf[SIZ];
+       FILE *fp;
+       int i;
+
+       /*
+        * See if we have to run the first-time setup wizard
+        */
+       if (!setup_wizard) {
+               sprintf(wizard_filename, "setupwiz.%s.%s", ctdlhost, ctdlport);
+               for (i=0; i<strlen(wizard_filename); ++i) {
+                       if (    (wizard_filename[i]==' ')
+                               || (wizard_filename[i] == '/')
+                       ) {
+                               wizard_filename[i] = '_';
+                       }
+               }
+
+               fp = fopen(wizard_filename, "r");
+               if (fp != NULL) {
+                       fgets(buf, sizeof buf, fp);
+                       buf[strlen(buf)-1] = 0;
+                       fclose(fp);
+                       if (atoi(buf) != serv_info.serv_rev_level) {
+                               setup_wizard = 1;       /* already run */
+                       }
+               }
+       }
 
-       get_preference("startpage", startpage);
-       if (strlen(startpage)==0) {
-               strcpy(startpage, "/dotskip&room=_BASEROOM_");
-               set_preference("startpage", startpage);
+       if (!setup_wizard) {
+               http_redirect("/setup_wizard");
        }
 
-       http_redirect(startpage);
+       /*
+        * Go to the user's preferred start page
+        */
+       get_preference("startpage", buf);
+       if (strlen(buf)==0) {
+               strcpy(buf, "/dotskip&room=_BASEROOM_");
+               set_preference("startpage", buf);
+       }
+       http_redirect(buf);
 }
 
 
diff --git a/webcit/setup_wizard.c b/webcit/setup_wizard.c
new file mode 100644 (file)
index 0000000..47e89b8
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * First-time setup wizard
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
+#include "webcit.h"
+
+
+
+/*
+ */
+void do_setup_wizard(void)
+{
+
+       output_headers(1, 1, 2, 0, 1, 0, 0);
+
+       wprintf("<div id=\"banner\">\n");
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
+       wprintf("<IMG SRC=\"/static/users-icon.gif\" ALT=\" \" ALIGN=MIDDLE>");
+       wprintf("<SPAN CLASS=\"titlebar\">&nbsp;First time setup");
+       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\">");
+
+       wprintf("wow");
+
+       wprintf("</div>\n"
+               "<div align=center>"
+               "Click on a name to read user info.  Click on "
+               "<IMG ALIGN=MIDDLE SRC=\"/static/page.gif\" ALT=\"(p)\" "
+               "BORDER=0> to send "
+               "a page (instant message) to that user.</div>\n");
+       wDumpContent(1);
+}
+
+
index 9264b6309d41a585e9f3c7ad6552d3d29ffa1c36..be1c6a68fd1b097d6ec60aec80908a8159c147c6 100644 (file)
@@ -1354,6 +1354,8 @@ void session_loop(struct httprequest *req)
                display_inetconf();
        } else if (!strcasecmp(action, "save_inetconf")) {
                save_inetconf();
+       } else if (!strcasecmp(action, "setup_wizard")) {
+               do_setup_wizard();
        } else if (!strcasecmp(action, "diagnostics")) {
                output_headers(1, 1, 1, 0, 0, 0, 0);
 
index c7ab8d30ddcb99c036a7b5f356bd06795f5220a8..779e3da5d134292f1b225f4864ca26971ecb11b9 100644 (file)
@@ -255,7 +255,9 @@ extern char *axdefs[];
 extern char *ctdlhost, *ctdlport;
 extern char *server_cookie;
 extern int is_https;
-
+extern int setup_wizard;
+extern char wizard_filename[PATH_MAX];
+void do_setup_wizard(void);
 
 void stuff_to_cookie(char *cookie, int session,
                        char *user, char *pass, char *room);
index a25ea478ccb707ef37a03b86c07c2a58e60f165b..70078b4c61e1f74960b8a834c4362eff746adde0 100644 (file)
@@ -61,6 +61,8 @@ char *server_cookie = NULL;
 
 char *ctdlhost = DEFAULT_HOST;
 char *ctdlport = DEFAULT_PORT;
+int setup_wizard = 0;
+char wizard_filename[PATH_MAX];
 
 /*
  * This is a generic function to set up a master socket for listening on