From e739ac98b3d4ec499ac0221bb990b077947e9dd5 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 20 Feb 2004 06:07:06 +0000 Subject: [PATCH] * Replaced the Java chat with a new system based on IFRAME's and JavaScript --- webcit/ChangeLog | 4 + webcit/context_loop.c | 4 +- webcit/paging.c | 262 +++++++++++++++++++++++++--- webcit/static/MultiUserChat102.java | 169 +++++++++--------- webcit/static/wcCitServer.java | 182 ++++++++++--------- webcit/static/wcCitUtil.java | 24 +-- webcit/static/wcchat.java | 38 ++-- webcit/webcit.c | 4 + webcit/webcit.h | 9 +- 9 files changed, 470 insertions(+), 226 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index c233a8f00..657881e21 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 505.1 2004/02/20 06:07:06 ajc +* Replaced the Java chat with a new system based on IFRAME's and JavaScript + Revision 505.0 2004/02/19 03:32:50 ajc * THIS IS 5.05 @@ -1666,3 +1669,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 0b2f7f471..3e3302a1b 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -102,6 +102,7 @@ BREAKOUT: pthread_mutex_unlock(&SessionListMutex); if (session_to_kill != NULL) { pthread_mutex_lock(&session_to_kill->SessionMutex); close(session_to_kill->serv_sock); + close(session_to_kill->chat_sock); if (session_to_kill->preferences != NULL) { free(session_to_kill->preferences); } @@ -338,7 +339,6 @@ void context_loop(int sock) || (!strncasecmp(buf, "/do_welcome", 11)) || (!strncasecmp(buf, "/page_popup", 11)) || (!strncasecmp(buf, "/page_user", 10)) /* Sometimes this is wrong */ - || (!strncasecmp(buf, "/display_page", 13)) /* Sometimes this is wrong */ || (!strncasecmp(buf, "/listsub", 8)) || (!strncasecmp(buf, "/freebusy", 9)) || (!strncasecmp(buf, "/termquit", 9)) ) { @@ -370,6 +370,8 @@ void context_loop(int sock) TheSession = (struct wcsession *) malloc(sizeof(struct wcsession)); memset(TheSession, 0, sizeof(struct wcsession)); + TheSession->serv_sock = (-1); + TheSession->chat_sock = (-1); TheSession->wc_session = GenerateSessionID(); pthread_mutex_init(&TheSession->SessionMutex, NULL); diff --git a/webcit/paging.c b/webcit/paging.c index aeaf7aab5..92b735180 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -115,28 +116,22 @@ void do_chat(void) output_headers(1); - wprintf("
"); - wprintf("Real-time chat\n"); - wprintf("
\n"); - - if (!strcasecmp(ctdlhost, "uds")) { - wprintf("Sorry ... chat is not available here.
\n"); - } - else { - wprintf("A chat window should be appearing on your screen "); - wprintf("momentarily. When you're "); - wprintf("done, type /quit to exit. You can also "); - wprintf("type /help for more commands.\n"); - - wprintf("\n"); - wprintf("\n", WC->wc_username); - wprintf("\n", WC->wc_password); - wprintf("\n", WC->wc_roomname); - wprintf("

Oops!

Looks like your browser doesn't support Java, "); - wprintf("so you won't be able to access Chat. Sorry.\n"); - wprintf("
\n"); - } + wprintf("
" + "Real-time chat\n" + "
\n" + "\n" + "
\n" + "\n" + ); wDumpContent(1); } @@ -178,3 +173,226 @@ void page_popup(void) } + +/* + * Support function for chat -- make sure the chat socket is connected + * and in chat mode. + */ +int setup_chat_socket(void) { + char buf[SIZ]; + int i; + int good_chatmode = 0; + + if (WC->chat_sock < 0) { + + for (i=0; ichatlines[i], ""); + } + + if (!strcasecmp(ctdlhost, "uds")) { + /* unix domain socket */ + sprintf(buf, "%s/citadel.socket", ctdlport); + WC->chat_sock = uds_connectsock(buf); + } + else { + /* tcp socket */ + WC->chat_sock = tcp_connectsock(ctdlhost, ctdlport); + } + + if (WC->chat_sock < 0) { + return(errno); + } + + /* Temporarily swap the serv and chat sockets during chat talk */ + i = WC->serv_sock; + WC->serv_sock = WC->chat_sock; + WC->chat_sock = i; + + serv_gets(buf); + if (buf[0] == '2') { + serv_printf("USER %s", WC->wc_username); + serv_gets(buf); + if (buf[0] == '3') { + serv_printf("PASS %s", WC->wc_password); + serv_gets(buf); + if (buf[0] == '2') { + serv_printf("GOTO %s", WC->wc_roomname); + serv_gets(buf); + if (buf[0] == '2') { + serv_puts("CHAT"); + serv_gets(buf); + if (buf[0] == '8') { + good_chatmode = 1; + } + } + } + } + } + + /* Unswap the sockets. */ + i = WC->serv_sock; + WC->serv_sock = WC->chat_sock; + WC->chat_sock = i; + + if (!good_chatmode) close(WC->serv_sock); + + } + return(0); +} + + + +/* + * receiving side of the chat window + */ +void chat_recv(void) { + int i; + char name[SIZ]; + char text[SIZ]; + struct pollfd pf; + int got_data = 0; + int end_chat_now = 0; + + output_headers(0); + + wprintf("Content-type: text/html\n"); + wprintf("\n"); + wprintf("\n" + "\n" + "\n" + "\n" + "" + ); + + if (setup_chat_socket() != 0) { + wprintf("Error setting up chat socket\n"); + wDumpContent(0); + return; + } + + /* + * See if there is any chat data waiting. + */ + do { + got_data = 0; + pf.fd = WC->chat_sock; + pf.events = POLLIN; + pf.revents = 0; + if (poll(&pf, 1, 1) > 0) if (pf.revents & POLLIN) { + ++got_data; + + for (i=0; ichatlines[i], WC->chatlines[i+1]); + } + + /* Temporarily swap the serv and chat sockets during chat talk */ + i = WC->serv_sock; + WC->serv_sock = WC->chat_sock; + WC->chat_sock = i; + + serv_gets(WC->chatlines[CHATLINES-1]); + if (!strcmp(WC->chatlines[CHATLINES-1], "000")) { + end_chat_now = 1; + strcpy(WC->chatlines[CHATLINES-1], ":|exiting chat mode"); + } + + /* Unswap the sockets. */ + i = WC->serv_sock; + WC->serv_sock = WC->chat_sock; + WC->chat_sock = i; + } + } while ( (got_data) && (!end_chat_now) ); + + /* + * Display appropriately. + */ + for (i=0; ichatlines[i]) > 0) { + extract(name, WC->chatlines[i], 0); + extract(text, WC->chatlines[i], 1); + if (!strcasecmp(name, WC->wc_username)) { + wprintf(""); + } + else if (!strcmp(name, ":")) { + wprintf(""); + } + else { + wprintf(""); + } + escputs(name); + wprintf(": "); + escputs(text); + wprintf("
\n"); + } + } + + if (end_chat_now) { + close(WC->chat_sock); + WC->chat_sock = (-1); + wprintf("\n"); + } + + wprintf("\n"); + wDumpContent(0); +} + + +/* + * sending side of the chat window + */ +void chat_send(void) { + int i; + char send_this[SIZ]; + + output_headers(0); + wprintf("Content-type: text/html\n"); + wprintf("\n"); + wprintf("" + "" + ); + + if (bstr("send_this") != NULL) { + strcpy(send_this, bstr("send_this")); + } + else { + strcpy(send_this, ""); + } + + if (bstr("sendbutton") != NULL) { + + if (!strcasecmp(bstr("sendbutton"), "Exit")) { + strcpy(send_this, "/quit"); + } + + if (setup_chat_socket() != 0) { + wprintf("Error setting up chat socket\n"); + wDumpContent(0); + return; + } + + /* Temporarily swap the serv and chat sockets during chat talk */ + i = WC->serv_sock; + WC->serv_sock = WC->chat_sock; + WC->chat_sock = i; + + serv_puts(send_this); + + /* Unswap the sockets. */ + i = WC->serv_sock; + WC->serv_sock = WC->chat_sock; + WC->chat_sock = i; + + } + + wprintf("Send: "); + wprintf("
\n"); + wprintf("\n"); + wprintf("\n"); + wprintf("\n"); + wprintf("
\n"); + + wprintf("\n"); + wDumpContent(0); +} + + diff --git a/webcit/static/MultiUserChat102.java b/webcit/static/MultiUserChat102.java index fe620bad4..2a120c754 100644 --- a/webcit/static/MultiUserChat102.java +++ b/webcit/static/MultiUserChat102.java @@ -24,37 +24,37 @@ class ReceiveChat extends Thread { String MyName; StringTokenizer ST; MultiUserChat102 ParentMUC; - Label[] Linez = new Label[25]; + Label[] Linez = new Label[25]; int a; - - ReceiveChat(MultiUserChat102 muc, Panel t, wcCitServer s, String n) { + + ReceiveChat(MultiUserChat102 muc, Panel t, wcCitServer s, + String n) { TheArea = t; serv = s; MyName = n; ParentMUC = muc; serv.AddClientThread(this); - TheArea.setLayout(new GridLayout(25,1)); + TheArea.setLayout(new GridLayout(25, 1)); - for (a=0; a<25; ++a) { + for (a = 0; a < 25; ++a) { Linez[a] = new Label(" "); Linez[a].setBackground(Color.black); Linez[a].setForeground(Color.black); TheArea.add(Linez[a]); - } - - TheArea.validate(); + } TheArea.validate(); - } + } private void ScrollIt(String TheNewLine, Color NewLineColor) { - for (a=0; a<24; ++a) { - Linez[a].setText(Linez[a+1].getText()); - Linez[a].setForeground(Linez[a+1].getForeground()); - } + for (a = 0; a < 24; ++a) { + Linez[a].setText(Linez[a + 1].getText()); + Linez[a].setForeground(Linez[a + 1]. + getForeground()); + } Linez[24].setText(TheNewLine); Linez[24].setForeground(NewLineColor); - } + } public void run() { @@ -62,7 +62,7 @@ class ReceiveChat extends Thread { int a; LastLineUser = " "; - while(true) { + while (true) { boof = serv.ServGets(); if (boof.equals("000")) { @@ -70,83 +70,82 @@ class ReceiveChat extends Thread { ParentMUC.dispose(); stop(); destroy(); - } + } ST = new StringTokenizer(boof, "|"); if (ST.hasMoreTokens()) { cUser = ST.nextToken(); - } - else { + } else { cUser = ":"; - } + } if (ST.hasMoreTokens()) { cText = ST.nextToken(); - } - else { + } else { cText = " "; - } + } if (!cText.startsWith("NOOP")) { if (!LastLineUser.equals(cUser)) { ScrollIt("", Color.black); ThisLine = cUser + ": "; - } - else { -ThisLine = " ".substring(0, cUser.length()+2); - } + } else { + ThisLine = + " ". + substring(0, + cUser.length() + 2); + } ThisLine = ThisLine + cText; UserColor = Color.green; if (cUser.equals(":")) { UserColor = Color.red; - } + } if (cUser.equalsIgnoreCase(MyName)) { UserColor = Color.yellow; - } + } ScrollIt(ThisLine, UserColor); LastLineUser = cUser; - } } } - } +} -public class MultiUserChat102 - extends Frame { -wcCitServer serv; -ReceiveChat MyReceive; -Panel AllUsers; -TextField SendBox; -wcchat ParentApplet; +public class MultiUserChat102 extends Frame { + wcCitServer serv; + ReceiveChat MyReceive; + Panel AllUsers; + TextField SendBox; + wcchat ParentApplet; -MultiUserChat102(wcCitServer PrimaryServ, wcchat P) { - super ("Multiuser Chat"); - String boof; + MultiUserChat102(wcCitServer PrimaryServ, wcchat P) { + super("Multiuser Chat"); - /* Set up a new server connection as a piggyback to the first. */ - serv = PrimaryServ; - ParentApplet = P; + String boof; - resize(600,400); - setLayout(new BorderLayout()); + /* Set up a new server connection as a piggyback to the first. */ + serv = PrimaryServ; + ParentApplet = P; - boof = "This is the buffer before the chat command."; - serv.ServPuts("CHAT"); - boof = serv.ServGets(); + resize(600, 400); + setLayout(new BorderLayout()); - if (boof.charAt(0) != '8') { - add("Center", new Label("ERROR: " + boof) ); - show(); + boof = "This is the buffer before the chat command."; + serv.ServPuts("CHAT"); + boof = serv.ServGets(); + + if (boof.charAt(0) != '8') { + add("Center", new Label("ERROR: " + boof)); + show(); } - else { - DoChat(PrimaryServ.GetUserName()); + else { + DoChat(PrimaryServ.GetUserName()); } } @@ -155,44 +154,54 @@ MultiUserChat102(wcCitServer PrimaryServ, wcchat P) { /* * Do the actual chat stuff */ -private void DoChat(String MyName) { - String boof; + private void DoChat(String MyName) { + String boof; - SendBox = new TextField(80); + SendBox = new TextField(80); - AllUsers = new Panel(); + AllUsers = new Panel(); - add("Center", AllUsers); - add("South", SendBox); - show(); + add("Center", AllUsers); + add("South", SendBox); + show(); - MyReceive = new ReceiveChat(this, AllUsers, serv, MyName); - MyReceive.start(); + MyReceive = new ReceiveChat(this, AllUsers, serv, MyName); + MyReceive.start(); - SendBox.requestFocus(); + SendBox.requestFocus(); } -public boolean handleEvent(Event evt) { - int LastSpace; + public boolean handleEvent(Event evt) { + int LastSpace; - if ( (evt.target == SendBox) && (evt.id == Event.ACTION_EVENT) ) { - serv.ServPuts(SendBox.getText()); - SendBox.setText(""); + if ((evt.target == SendBox) + && (evt.id == Event.ACTION_EVENT)) { + serv.ServPuts(SendBox.getText()); + SendBox.setText(""); } - else if (evt.target == SendBox) { - if ( SendBox.getText().length() + serv.GetUserName().length() > 78 ) { - LastSpace = SendBox.getText().lastIndexOf(' '); - if (LastSpace < 0) { - serv.ServPuts(SendBox.getText()); - SendBox.setText(""); - } - else { - serv.ServPuts(SendBox.getText().substring(0,LastSpace)); - SendBox.setText(SendBox.getText().substring(LastSpace)); - if (SendBox.getText().charAt(0) == ' ') { - SendBox.setText(SendBox.getText().substring(1)); + else if (evt.target == SendBox) { + if (SendBox.getText().length() + + serv.GetUserName().length() > 78) { + LastSpace = + SendBox.getText().lastIndexOf(' '); + if (LastSpace < 0) { + serv.ServPuts(SendBox.getText()); + SendBox.setText(""); + } else { + serv.ServPuts(SendBox.getText(). + substring(0, + LastSpace)); + SendBox.setText(SendBox.getText(). + substring + (LastSpace)); + if (SendBox.getText().charAt(0) == + ' ') { + SendBox.setText(SendBox. + getText(). + substring + (1)); } } } diff --git a/webcit/static/wcCitServer.java b/webcit/static/wcCitServer.java index dff93252f..6cf9c3175 100644 --- a/webcit/static/wcCitServer.java +++ b/webcit/static/wcCitServer.java @@ -21,45 +21,44 @@ import java.util.*; */ class wcKeepAlive extends Thread { - wcCitServer serv; /* Pointer to server connection class */ + wcCitServer serv; /* Pointer to server connection class */ boolean FullKeepAlives; /* TRUE for full keepalives, FALSE for half keepalives */ - wcKeepAlive() { - } - - public void PointToServer(wcCitServer which_serv, boolean WhatKindOfKeepAlives) { + wcKeepAlive() { + } public void PointToServer(wcCitServer which_serv, + boolean WhatKindOfKeepAlives) { serv = which_serv; serv.AddClientThread(this); FullKeepAlives = WhatKindOfKeepAlives; - } + } public void run() { String buf; - while(true) { + while (true) { /* Sleep for sixty seconds between keepalives. */ try { sleep(60000); - } - catch (InterruptedException e) { - } + } + catch(InterruptedException e) { + } /* Full keepalives - send a NOOP, wait for a reply, then retrieve * express messages if the server said there are any. */ if (FullKeepAlives) { buf = serv.ServTrans("NOOP") + " "; - } + } /* Half keepalives - blindly send a NOOP and we're done. */ else { serv.ServPuts("NOOP"); - } - } + } - } +} + /* @@ -82,48 +81,46 @@ public class wcCitServer { public void SetTransBuf(String bufstring) { TransBuf = bufstring; - } - - public String GetTransBuf() { + } public String GetTransBuf() { return TransBuf; - } + } /* attach to the server */ - private void BuildConnection(String ServerHost, int ServerPort, boolean WhichKA) { + private void BuildConnection(String ServerHost, int ServerPort, + boolean WhichKA) { String buf; try { sock = new Socket(ServerHost, ServerPort); - ofp = new - DataOutputStream(sock.getOutputStream()); - ifp = new - DataInputStream(sock.getInputStream()); - } + ofp = new DataOutputStream(sock.getOutputStream()); + ifp = new DataInputStream(sock.getInputStream()); + } catch(UnknownHostException e) { System.out.println(e); - } + } catch(IOException e) { System.out.println(e); - } + } /* Connection established. At this point, this function * has the server connection all to itself, so we can do * whatever we want with it. */ - - /* Get the 'server ready' message */ + + /* Get the 'server ready' message */ buf = ServGets(); /* Identify the client software to the server */ ServTrans("IDEN 0|5|001|Cit/UX Java Client|"); - + /* Download various information about the server */ SetTransBuf(""); buf = ServTrans("INFO"); - StringTokenizer InfoST = new StringTokenizer(TransBuf,"\n"); + StringTokenizer InfoST = + new StringTokenizer(TransBuf, "\n"); while (InfoST.hasMoreTokens()) { ServerInfo.addElement(InfoST.nextToken()); - } + } /* At this point, all server accesses must cooperate with @@ -134,14 +131,14 @@ public class wcCitServer { ka.PointToServer(this, WhichKA); ka.start(); - } + } /* * Attach to server command for the primary socket */ public void AttachToServer(String ServerHost, int ServerPort) { - + /* Connect to the server */ /* NOTE ... we've changed the primary connection keepalives to HALF because we're using the * primary connection to jump right into a chat window. @@ -153,7 +150,7 @@ public class wcCitServer { */ PrimaryServerHost = ServerHost; PrimaryServerPort = ServerPort; - } + } /* @@ -161,25 +158,26 @@ public class wcCitServer { */ public String GetServerHost() { return PrimaryServerHost; - } + } - public int GetServerPort() { + public int GetServerPort() { return PrimaryServerPort; - } + } /* * Set up a piggyback connection */ - public void Piggyback(wcCitServer PrimaryServ, boolean KeepAliveType) { + public void Piggyback(wcCitServer PrimaryServ, + boolean KeepAliveType) { PrimaryServerHost = PrimaryServ.GetServerHost(); PrimaryServerPort = PrimaryServ.GetServerPort(); PrimaryServerUser = PrimaryServ.GetUserName(); PrimaryServerPassword = PrimaryServ.GetPassword(); BuildConnection(PrimaryServerHost, PrimaryServerPort, KeepAliveType); - - } + + } @@ -187,28 +185,27 @@ public class wcCitServer { public String ServInfo(int index) { String retbuf; if (index >= ServerInfo.size()) { - return(""); - } - else { + return (""); + } else { retbuf = ServerInfo.elementAt(index).toString(); - return(retbuf); - } + return (retbuf); } + } /* read a line from the server */ public String ServGets() { - + String buf = ""; try { buf = ifp.readLine(); - } + } catch(IOException e) { System.out.println(e); - } - return buf; } + return buf; + } /* write a line to the server */ @@ -216,41 +213,41 @@ public class wcCitServer { try { ofp.writeBytes(buf + "\n"); - } + } catch(IOException e) { System.out.println(e); - } } + } /* lock the server connection so other threads don't screw us up */ public synchronized void BeginTrans() { - while(in_trans) { + while (in_trans) { try { - System.out.println("-sleeping-"); /* trace */ + System.out.println("-sleeping-"); /* trace */ Thread.sleep(100); - } - catch (InterruptedException e) { - } } + catch(InterruptedException e) { + } + } in_trans = true; - } + } /* release the lock */ public void EndTrans() { in_trans = false; - } + } /* perform an autonomous server transaction */ public String ServTrans(String ServCmd) { - String buf; + String buf; BeginTrans(); buf = DataTrans(ServCmd); EndTrans(); return buf; - } + } /* perform a non-autonomous server transaction */ public String DataTrans(String ServCmd) { @@ -260,51 +257,52 @@ public class wcCitServer { /* perform the transaction */ - System.out.println(">"+ServCmd); /* trace */ + System.out.println(">" + ServCmd); /* trace */ ServPuts(ServCmd); buf = ServGets(); - System.out.println("<"+buf); /* trace */ + System.out.println("<" + buf); /* trace */ - try { - if (buf.startsWith("4")) { - ofp.writeBytes(TransBuf); - if (!TransBuf.endsWith("\n")) { - ofp.writeBytes("\n"); + try { + if (buf.startsWith("4")) { + ofp.writeBytes(TransBuf); + if (!TransBuf.endsWith("\n")) { + ofp.writeBytes("\n"); } - ofp.writeBytes("000"); - TransBuf = ""; + ofp.writeBytes("000"); + TransBuf = ""; } - if (buf.startsWith("1")) { - TransBuf = ""; - inbuf = ""; - do { - inbuf = ServGets(); - if (!TransBuf.equals("")) { - TransBuf = TransBuf + "\n"; + if (buf.startsWith("1")) { + TransBuf = ""; + inbuf = ""; + do { + inbuf = ServGets(); + if (!TransBuf.equals("")) { + TransBuf = TransBuf + "\n"; } - if (!inbuf.equals("000")) { - TransBuf = TransBuf + inbuf; + if (!inbuf.equals("000")) { + TransBuf = + TransBuf + inbuf; } } while (!inbuf.equals("000")); } - } - catch(IOException e) { - System.out.println(e); } - - return(buf); + catch(IOException e) { + System.out.println(e); } + return (buf); + } + public void AddClientThread(Thread ct) { ClientThreads.addElement(ct); System.out.println("--new thread registered--"); - } + } public void RemoveClientThread(Thread ct) { ClientThreads.removeElement(ct); System.out.println("--thread removed--"); - } + } @@ -314,22 +312,20 @@ public class wcCitServer { */ public void SetUserName(String U) { PrimaryServerUser = U; - } - + } + public void SetPassword(String P) { PrimaryServerPassword = P; - } + } public String GetUserName() { return PrimaryServerUser; - } + } public String GetPassword() { return PrimaryServerPassword; - } - - - } + +} diff --git a/webcit/static/wcCitUtil.java b/webcit/static/wcCitUtil.java index 4e34deb52..7d1646324 100644 --- a/webcit/static/wcCitUtil.java +++ b/webcit/static/wcCitUtil.java @@ -9,19 +9,19 @@ import java.util.*; public class wcCitUtil extends Object { -public static String Extract(String SourceString, int ParmNum) { - StringTokenizer toks; - String buf; - int pos; + public static String Extract(String SourceString, int ParmNum) { + StringTokenizer toks; + String buf; + int pos; - pos = 0; - toks = new StringTokenizer(SourceString, "|"); - while (toks.hasMoreTokens()) { - buf = toks.nextToken(); - if (pos == ParmNum) return buf; - ++pos; - } - return ""; + pos = 0; + toks = new StringTokenizer(SourceString, "|"); + while (toks.hasMoreTokens()) { + buf = toks.nextToken(); + if (pos == ParmNum) + return buf; + ++pos; + } return ""; } } diff --git a/webcit/static/wcchat.java b/webcit/static/wcchat.java index 184a9aa6e..ea2c305ea 100644 --- a/webcit/static/wcchat.java +++ b/webcit/static/wcchat.java @@ -10,9 +10,9 @@ import java.applet.*; public class wcchat extends Applet { -String ServerHost = "uncnsrd.mt-kisco.ny.us"; -int ServerPort = 504; - + String ServerHost = "uncensored.citadel.org"; + int ServerPort = 504; + public void init() { /* Unless overridden, the Citadel server is expected to be @@ -21,24 +21,24 @@ int ServerPort = 504; */ if (getDocumentBase() != null) { ServerHost = getDocumentBase().getHost(); - } + } /* The 'host' parameter tells the client to look somewhere other * than the applet host for the Citadel server. - */ - if (getParameter("host") != null) { + */ if (getParameter("host") != null) { ServerHost = getParameter("host"); - } + } /* The 'port' parameter tells the client to look on a * nonstandard port for the Citadel server. */ if (getParameter("port") != null) { - ServerPort = Integer.parseInt(getParameter("port")); - } - + ServerPort = + Integer.parseInt(getParameter("port")); } + } + public void start() { wcCitServer serv = new wcCitServer(); String buf = null; @@ -46,16 +46,22 @@ int ServerPort = 504; serv.AttachToServer(ServerHost, ServerPort); buf = serv.ServTrans("USER " + getParameter("username")); if (buf.charAt(0) == '3') { - buf = serv.ServTrans("PASS "+getParameter("password")); + buf = + serv.ServTrans("PASS " + + getParameter("password")); if (buf.charAt(0) == '2') { - serv.SetUserName(wcCitUtil.Extract(buf.substring(4), 0)); - buf = serv.ServTrans("GOTO "+getParameter("roomname")); + serv.SetUserName(wcCitUtil. + Extract(buf.substring(4), + 0)); + buf = + serv.ServTrans("GOTO " + + getParameter + ("roomname")); new MultiUserChat102(serv, this); - } } - else { + } else { System.out.println("ooops..."); - } } + } } diff --git a/webcit/webcit.c b/webcit/webcit.c index a4363adc5..e388d799d 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1123,6 +1123,10 @@ void session_loop(struct httprequest *req) edit_me(); } else if (!strcasecmp(action, "display_siteconfig")) { display_siteconfig(); + } else if (!strcasecmp(action, "chat_recv")) { + chat_recv(); + } else if (!strcasecmp(action, "chat_send")) { + chat_send(); } else if (!strcasecmp(action, "page_popup")) { page_popup(); } else if (!strcasecmp(action, "siteconfig")) { diff --git a/webcit/webcit.h b/webcit/webcit.h index 94413e6d1..b9d261bd0 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -25,10 +25,10 @@ #define SLEEPING 180 /* TCP connection timeout */ #define WEBCIT_TIMEOUT 900 /* WebCit session timeout */ #define PORT_NUM 2000 /* port number to listen on */ -#define SERVER "WebCit v5.05" /* who's in da house */ +#define SERVER "WebCit v5.04" /* who's in da house */ #define DEVELOPER_ID 0 #define CLIENT_ID 4 -#define CLIENT_VERSION 505 /* This version of WebCit */ +#define CLIENT_VERSION 504 /* This version of WebCit */ #define MINIMUM_CIT_VERSION 611 /* min required Citadel vers */ #define DEFAULT_HOST "localhost" /* Default Citadel server */ #define DEFAULT_PORT "504" @@ -163,6 +163,7 @@ struct wc_attachment { char *data; }; +#define CHATLINES 8 /* * One of these is kept for each active Citadel session. @@ -181,6 +182,7 @@ struct wcsession { int is_room_aide; int http_sock; int serv_sock; + int chat_sock; unsigned room_flags; int wc_view; int wc_default_view; @@ -218,6 +220,7 @@ struct wcsession { char ImportantMessage[SIZ]; int outside_frameset_allowed; /* nonzero if current req is allowed * outside of the main frameset */ + char chatlines[CHATLINES][SIZ]; }; #define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|') @@ -343,6 +346,8 @@ void fmt_time(char *buf, time_t thetime); void httpdate(char *buf, time_t thetime); void end_webcit_session(void); void page_popup(void); +void chat_recv(void); +void chat_send(void); void http_redirect(char *); void clear_local_substs(void); void svprintf(char *keyname, int keytype, const char *format,...); -- 2.39.2