]> code.citadel.org Git - citadel.git/blobdiff - citadel/textclient/citadel.c
Removed err_* and sln_* functions; replaced all calls with scr_* functions.
[citadel.git] / citadel / textclient / citadel.c
index 7e5ef874a2351bf2233c80e1a4b657bdce81c01f..f96c64fe20c60580fbfd6ca7be8bc9d9d6791cc3 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * Main source module for the client program.
  *
  * Copyright (c) 1987-2009 by the citadel.org team
@@ -73,8 +71,8 @@
 
 #define IFEXPERT if (userflags&US_EXPERT)
 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
-#define IFAIDE if (axlevel>=6)
-#define IFNAIDE if (axlevel<6)
+#define IFAIDE if (axlevel>=AxAideU)
+#define IFNAIDE if (axlevel<AxAideU)
 
 int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2);
 
@@ -92,12 +90,13 @@ int screenwidth;
 int screenheight;
 unsigned room_flags;
 unsigned room_flags2;
+int entmsg_ok = 0;
 char room_name[ROOMNAMELEN];
 char *uglist[UGLISTLEN]; /* size of the ungoto list */
 long uglistlsn[UGLISTLEN]; /* current read position for all the ungoto's. Not going to make any friends with this one. */
 int uglistsize = 0;
 char is_mail = 0;              /* nonzero when we're in a mail room */
-char axlevel = 0;              /* access level */
+char axlevel = AxDeleted;              /* access level */
 char is_room_aide = 0;         /* boolean flag, 1 if room aide */
 int timescalled;
 int posted;
@@ -470,6 +469,19 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
        from_floor = curr_floor;
        curr_floor = room->RRfloor;
 
+       /* Determine, based on the room's default view, whether an <E>nter message
+        * command will be valid here.
+        */
+       switch(room->RRdefaultview) {
+               case VIEW_BBS:
+               case VIEW_MAILBOX:
+                                       entmsg_ok = 1;
+                                       break;
+               default:
+                                       entmsg_ok = 0;
+                                       break;
+       }
+
        remove_march(room_name, 0);
        if (!strcasecmp(towhere, "_BASEROOM_"))
                remove_march(towhere, 0);
@@ -522,8 +534,6 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
                        rv = system(rc_gotmail_cmd);
                }
        }
-       status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location,
-                       room_name, secure, newmailcount);
        free(room);
 }
 
@@ -1073,7 +1083,7 @@ void check_screen_dims(void)
        if (have_xterm) {       /* dynamically size screen if on an xterm */
                if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
                        if (xwinsz.height)
-                               screenheight = is_curses_enabled() ? (int)xwinsz.height - 1 : (int) xwinsz.height;
+                               screenheight = (int) xwinsz.height;
                        if (xwinsz.width)
                                screenwidth = (int) xwinsz.width;
                }
@@ -1393,8 +1403,8 @@ int shift(int argc, char **argv, int start, int count) {
 }
 
 static void statusHook(char *s) {
-       sln_printf(s);
-       sln_flush();
+       scr_printf(s);
+       scr_flush();
 }
 
 /*
@@ -1446,15 +1456,15 @@ int main(int argc, char **argv)
        eCrash_Init(&params);
 #endif 
        setIPCDeathHook(screen_delete);
-       setIPCErrorPrintf(err_printf);
+       setIPCErrorPrintf(scr_printf);
        setCryptoStatusHook(statusHook);
        
        /* Permissions sanity check - don't run citadel setuid/setgid */
        if (getuid() != geteuid()) {
-               err_printf("Please do not run citadel setuid!\n");
+               scr_printf("Please do not run citadel setuid!\n");
                logoff(NULL, 3);
        } else if (getgid() != getegid()) {
-               err_printf("Please do not run citadel setgid!\n");
+               scr_printf("Please do not run citadel setgid!\n");
                logoff(NULL, 3);
        }
 
@@ -1554,14 +1564,18 @@ int main(int argc, char **argv)
        newprompt("Connect to (return for local server): ", hostbuf, 64);
 #endif
 
-       sln_printf("Attaching to server... \r");
-       sln_flush();
+       scr_printf("Attaching to server...\n");
        ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
        if (!ipc) {
                screen_delete();
                error_printf("Can't connect: %s\n", strerror(errno));
                logoff(NULL, 3);
        }
+
+       if (!(ipc->isLocal)) {
+               scr_printf("Connected to %s [%s].\n", ipc->ip_hostname, ipc->ip_address);
+       }
+
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
        CtdlIPC_SetNetworkStatusCallback(ipc, wait_indicator);
 #endif
@@ -1611,9 +1625,6 @@ int main(int argc, char **argv)
                   ipc->ServInfo.site_location);
        scr_flush();
 
-       status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location, NULL,
-                   secure, -1);
-
        screenwidth = 80;       /* default screen dimensions */
        screenheight = 24;
        
@@ -1666,6 +1677,12 @@ int main(int argc, char **argv)
                mcmd = 29;
                goto TERMN8;
        }
+
+       /* FIXME this is a stupid way to do guest mode but it's a reasonable test harness FIXME */
+       if ( (ipc->ServInfo.guest_logins) && (!strcasecmp(fullname, "guest")) ) {
+               goto PWOK;
+       }
+
        /* sign on to the server */
        r = CtdlIPCTryLogin(ipc, fullname, aaa);
        if (r / 100 != 3)
@@ -1677,12 +1694,19 @@ int main(int argc, char **argv)
        } else {
                newprompt("\rPlease enter your password: ", password, -19);
        }
-       strproc(password);
 
        if (*nonce) {
                r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
+               if (r / 100 != 2) {
+                       strproc(password);
+                       r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
+               }
        } else {
                r = CtdlIPCTryPassword(ipc, password, aaa);
+               if (r / 100 != 2) {
+                       strproc(password);
+                       r = CtdlIPCTryPassword(ipc, password, aaa);
+               }
        }
        
        if (r / 100 == 2) {
@@ -1755,7 +1779,7 @@ NEWUSR:   if (IsEmptyStr(rc_password)) {
                                rv = system(rc_gotmail_cmd);
                        }
                }
-               if ((axlevel >= 6) && (chek.needvalid > 0)) {
+               if ((axlevel >= AxAideU) && (chek.needvalid > 0)) {
                        scr_printf("*** Users need validation\n");
                }
                if (chek.needregis > 0) {
@@ -2094,21 +2118,6 @@ NEWUSR:  if (IsEmptyStr(rc_password)) {
                                chatmode(ipc);
                                break;
 
-                       case 2:
-                               if (ipc->isLocal) {
-                                       screen_reset();
-                                       stty_ctdl(SB_RESTORE);
-                                       snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
-                                                "exec ./subsystem %ld %d %d", fullname,
-                                                usernum, screenwidth, axlevel);
-                                       ka_system(aaa);
-                                       stty_ctdl(SB_NO_INTR);
-                                       screen_set();
-                               } else {
-                                       scr_printf("*** Can't run doors when server is not local.\n");
-                               }
-                               break;
-
                        case 17:
                                who_is_online(ipc, 0);
                                break;
@@ -2328,7 +2337,7 @@ TERMN8:   scr_printf("%s logged out.", fullname);
                remove_march(marchptr->march_name, 0);
        }
        if (mcmd == 30) {
-               sln_printf("\n\nType 'off' to disconnect, or next user...\n");
+               scr_printf("\n\nType 'off' to disconnect, or next user...\n");
        }
        CtdlIPCLogout(ipc);
        if ((mcmd == 29) || (mcmd == 15)) {