]> code.citadel.org Git - citadel.git/blobdiff - citadel/textclient/client_chat.c
User Biography display: remove call, do through templates directly.
[citadel.git] / citadel / textclient / client_chat.c
index 590d8b4c96445498a679a3b6331576f35722f2bd..760ce5934abb7880c36d45c38dff2e0c537b3943 100644 (file)
@@ -1,24 +1,15 @@
 /*
- * $Id$
+ * front end for multiuser chat
  *
- * front end for chat mode
- * (the "single process" version - no more fork() anymore)
+ * Copyright (c) 1987-2012 by the citadel.org team
  *
- * Copyright (c) 1987-2010 by the citadel.org team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -64,9 +55,6 @@
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 extern char temp[];
-void ctdl_getline(char *, int);
-
-
 char last_paged[SIZ] = "";
 
 void chatmode(CtdlIPC *ipc)
@@ -98,18 +86,25 @@ void chatmode(CtdlIPC *ipc)
        strcpy(wbuf, "");
        strcpy(last_user, ""); 
        color(BRIGHT_YELLOW);
-       sln_printf_if("\n");
-       sln_printf("> ");
+       scr_printf("\n");
+       scr_printf("> ");
        send_complete_line = 0;
 
        while (1) {
-               sln_flush();
+               scr_flush();
                FD_ZERO(&rfds);
                FD_SET(0, &rfds);
                tv.tv_sec = 1;
                tv.tv_usec = 0;
                retval = select(1, &rfds, NULL, NULL, &tv);
 
+               if (retval < 0) {
+                       color(BRIGHT_WHITE);
+                       scr_printf("Server gone Exiting chat mode\n");
+                       scr_flush();
+                       return;
+               }
+
                /* If there's data from the keyboard... */
                if (FD_ISSET(0, &rfds)) {
                        ch = scr_getc(SCR_BLOCK);
@@ -118,10 +113,10 @@ void chatmode(CtdlIPC *ipc)
                        } else if ((ch == 8) || (ch == 127)) {
                                if (!IsEmptyStr(wbuf)) {
                                        wbuf[strlen(wbuf) - 1] = 0;
-                                       sln_printf("%c %c", 8, 8);
+                                       scr_printf("%c %c", 8, 8);
                                }
                        } else {
-                               sln_putc(ch);
+                               scr_putc(ch);
                                wbuf[strlen(wbuf) + 1] = 0;
                                wbuf[strlen(wbuf)] = ch;
                        }
@@ -134,8 +129,8 @@ void chatmode(CtdlIPC *ipc)
                                CtdlIPC_chat_send(ipc, "RCHT exit");
                                CtdlIPC_chat_recv(ipc, response);       /* don't care about the result */
                                color(BRIGHT_WHITE);
-                               sln_printf("\rExiting chat mode\n");
-                               sln_flush();
+                               scr_printf("\rExiting chat mode\n");
+                               scr_flush();
                                return;
                        }
 
@@ -186,7 +181,7 @@ void chatmode(CtdlIPC *ipc)
                        seq = extract_int(&response[4], 0);
                        extract_token(c_user, &response[4], 2, '|', sizeof c_user);
                        while (CtdlIPC_chat_recv(ipc, c_text), strcmp(c_text, "000")) {
-                               sln_printf("\r%79s\r", "");
+                               scr_printf("\r%79s\r", "");
                                if (!strcmp(c_user, fullname)) {
                                        color(BRIGHT_YELLOW);
                                } else if (!strcmp(c_user, ":")) {
@@ -205,7 +200,7 @@ void chatmode(CtdlIPC *ipc)
                                        strcat(buf, " ");
                                }
                                if (strcmp(c_user, last_user)) {
-                                       sln_printf("\r%79s\n", "");
+                                       scr_printf("\r%79s\n", "");
                                        strcpy(last_user, c_user);
                                }
                                scr_printf("\r%s\n", buf);
@@ -213,8 +208,8 @@ void chatmode(CtdlIPC *ipc)
                        }
                }
                color(BRIGHT_YELLOW);
-               sln_printf("\r> %s", wbuf);
-               sln_flush();
+               scr_printf("\r> %s", wbuf);
+               scr_flush();
                strcpy(buf, "");
        }
 }