]> code.citadel.org Git - citadel.git/commitdiff
Migrated all of the class definitions into one file
authorArt Cancro <ajc@citadel.org>
Mon, 8 Mar 1999 02:36:26 +0000 (02:36 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 8 Mar 1999 02:36:26 +0000 (02:36 +0000)
16 files changed:
daphne/Makefile
daphne/citclient.cpp
daphne/citclient.hpp [deleted file]
daphne/express_message.cpp
daphne/express_message.hpp [deleted file]
daphne/includes.hpp [new file with mode: 0644]
daphne/main.cpp
daphne/send_express.cpp [new file with mode: 0644]
daphne/tcp_sockets.cpp
daphne/tcp_sockets.hpp [deleted file]
daphne/testwindow.cpp
daphne/testwindow.hpp [deleted file]
daphne/userlogin.cpp
daphne/userlogin.hpp [deleted file]
daphne/who.cpp
daphne/who.hpp [deleted file]

index 57576b04f4f83879621413d5d158386a29ab28fd..9fece33dd332247f2db4d588a967bf5376808b03 100644 (file)
@@ -2,31 +2,34 @@ CFLAGS=`wx-config --cflags`
 LFLAGS=`wx-config --libs`
 
 daphne: main.o citclient.o userlogin.o testwindow.o who.o \
-       utils.o tcp_sockets.o express_message.o
+       utils.o tcp_sockets.o express_message.o send_express.o
        c++ main.o citclient.o userlogin.o testwindow.o who.o \
-       utils.o tcp_sockets.o express_message.o \
+       utils.o tcp_sockets.o express_message.o send_express.o \
        $(LFLAGS) -o daphne
 
-main.o: main.cpp
+main.o: main.cpp includes.hpp
        c++ -c $(CFLAGS) main.cpp
 
-citclient.o: citclient.cpp
+citclient.o: citclient.cpp includes.hpp
        c++ -c $(CFLAGS) citclient.cpp
 
-userlogin.o: userlogin.cpp
+userlogin.o: userlogin.cpp includes.hpp
        c++ -c $(CFLAGS) userlogin.cpp
 
-testwindow.o: testwindow.cpp
+testwindow.o: testwindow.cpp includes.hpp
        c++ -c $(CFLAGS) testwindow.cpp
 
-who.o: who.cpp
+who.o: who.cpp includes.hpp
        c++ -c $(CFLAGS) who.cpp
 
-utils.o: utils.c
+utils.o: utils.c includes.hpp
        c++ -c $(CFLAGS) utils.c
 
-tcp_sockets.o: tcp_sockets.cpp tcp_sockets.hpp
+tcp_sockets.o: tcp_sockets.cpp includes.hpp
        c++ -c $(CFLAGS) tcp_sockets.cpp
 
-express_message.o: express_message.cpp express_message.hpp
+express_message.o: express_message.cpp includes.hpp
        c++ -c $(CFLAGS) express_message.cpp
+
+send_express.o: send_express.cpp includes.hpp
+       c++ -c $(CFLAGS) send_express.cpp
index 7b0d820c6e6619f1a766c1e9daf9127f91b17103..da65682e8a4d3994c43a385be0b966be715aefaf 100644 (file)
@@ -1,11 +1,5 @@
-#include <ctype.h>
-#include <string.h>
 
-#include <wx/wx.h>
-
-#include "citclient.hpp"
-#include "express_message.hpp"
-#include "utils.h"
+#include "includes.hpp"
 
 
 //  
diff --git a/daphne/citclient.hpp b/daphne/citclient.hpp
deleted file mode 100644 (file)
index 25807b4..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <wx/socket.h>
-
-#include "tcp_sockets.hpp"
-
-class CitClient {
-public:
-       CitClient(void);
-       ~CitClient(void);
-
-       // High-level Citadel IPC methods
-       int attach(const wxString& host, const wxString& port);
-       void detach(void);
-       bool IsConnected(void);
-       int CitClient::serv_trans(
-                       wxString& command,
-                       wxString& response,
-                       wxStringList& xferbuf
-                        );
-       int CitClient::serv_trans(wxString& command, wxString& response);
-       int CitClient::serv_trans(wxString& command);
-
-       // Various things we learn about the server
-       int SessionID;
-       wxString NodeName;
-       wxString HumanNode;
-       wxString FQDN;
-       wxString ServerSoftware;
-       int ServerRev;
-       wxString GeoLocation;
-       wxString SysAdmin;
-       int ServerType;
-       wxString MorePrompt;
-       bool UseFloors;
-       int PagingLevel;
-
-private:
-       void serv_gets(wxString& buf);
-       void serv_puts(wxString buf);
-       void download_express_messages(void);
-       TCPsocket sock;
-       void CitClient::initialize_session(void);
-};
-
-
-
-
-// This is a timer that does keepalives...
-class keepalive : public wxTimer {
-public:
-        keepalive(CitClient *sock);
-private:
-       CitClient *which_sock;
-        void Notify(void);
-};
-
-
-
index 7419ef9a773ff8c171f8003dc5b4b9a50d136476..7e0d0723f23c270c6aa215aba0752dd5a6ce032c 100644 (file)
@@ -2,12 +2,7 @@
 // declarations
 // ============================================================================
 
-
-#include <wx/wx.h>
-#include <wx/listctrl.h>
-#include "citclient.hpp"
-#include "express_message.hpp"
-#include "utils.h"
+#include "includes.hpp"
 
 // ----------------------------------------------------------------------------
 // private classes
diff --git a/daphne/express_message.hpp b/daphne/express_message.hpp
deleted file mode 100644 (file)
index da896ca..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-class express_message : public wxFrame {
-public:
-       express_message(CitClient *sock, wxString sender,
-               wxString sendsys, wxStringList msg);
-private:
-       void OnButtonPressed(wxCommandEvent& whichbutton);
-       CitClient *citsock;
-       DECLARE_EVENT_TABLE()
-};
diff --git a/daphne/includes.hpp b/daphne/includes.hpp
new file mode 100644 (file)
index 0000000..8658b1f
--- /dev/null
@@ -0,0 +1,162 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <wx/wx.h>
+#include <wx/listctrl.h>
+#include <wx/socket.h>
+#include "utils.h"
+
+
+class TCPsocket {
+public:
+       TCPsocket::TCPsocket(void);
+       int attach(char *, char *);
+       void detach(void);
+       void serv_read(char *, int);
+       void serv_write(char *, int);
+       void serv_gets(char *);
+       void serv_puts(char *);
+       bool is_connected(void);
+private:
+       int serv_sock;
+       int connectsock(const char *, const char *, const char *);
+       void timeout(int);
+};
+
+
+
+
+class CitClient {
+public:
+       CitClient(void);
+       ~CitClient(void);
+
+       // High-level Citadel IPC methods
+       int attach(const wxString& host, const wxString& port);
+       void detach(void);
+       bool IsConnected(void);
+       int CitClient::serv_trans(
+                       wxString& command,
+                       wxString& response,
+                       wxStringList& xferbuf
+                        );
+       int CitClient::serv_trans(wxString& command, wxString& response);
+       int CitClient::serv_trans(wxString& command);
+
+       // Various things we learn about the server
+       int SessionID;
+       wxString NodeName;
+       wxString HumanNode;
+       wxString FQDN;
+       wxString ServerSoftware;
+       int ServerRev;
+       wxString GeoLocation;
+       wxString SysAdmin;
+       int ServerType;
+       wxString MorePrompt;
+       bool UseFloors;
+       int PagingLevel;
+
+private:
+       void serv_gets(wxString& buf);
+       void serv_puts(wxString buf);
+       void download_express_messages(void);
+       TCPsocket sock;
+       void CitClient::initialize_session(void);
+};
+
+
+
+
+// This is a timer that does keepalives...
+class keepalive : public wxTimer {
+public:
+        keepalive(CitClient *sock);
+private:
+       CitClient *which_sock;
+        void Notify(void);
+};
+
+
+
+class express_message : public wxFrame {
+public:
+       express_message(CitClient *sock, wxString sender,
+               wxString sendsys, wxStringList msg);
+private:
+       void OnButtonPressed(wxCommandEvent& whichbutton);
+       CitClient *citsock;
+       DECLARE_EVENT_TABLE()
+};
+
+
+
+
+// SendExpress is the screen for sending an express message (page).
+
+class SendExpress : public wxMDIChildFrame {
+public:
+       SendExpress(    CitClient *sock,
+                       wxMDIParentFrame *MyMDI, 
+                       wxString *touser);
+private:
+       void OnButtonPressed(wxCommandEvent& whichbutton);
+       CitClient *citsock;
+       wxMDIParentFrame *citMyMDI;
+       DECLARE_EVENT_TABLE()
+};
+// userlogin is the frame for logging in.
+class TestWindow : public wxMDIChildFrame {
+public:
+       TestWindow(CitClient *sock, wxMDIParentFrame *MyMDI);
+private:
+       wxPanel *panel;
+       wxTextCtrl *sendcmd;
+       wxTextCtrl *recvcmd;
+       wxButton *cmd_button;
+       wxButton *close_button;
+       void OnButtonPressed(wxCommandEvent& whichbutton);
+       CitClient *citsock;
+       DECLARE_EVENT_TABLE()
+};
+// userlogin is the frame for logging in.
+class UserLogin : public wxMDIChildFrame {
+public:
+       UserLogin(CitClient *sock, wxMDIParentFrame *MyMDI);
+       int do_login();
+private:
+       wxPanel *panel;
+       wxTextCtrl *username;
+       wxTextCtrl *password;
+       wxButton *login_button;
+       wxButton *newuser_button;
+       wxButton *exit_button;
+       void OnButtonPressed(wxCommandEvent& whichbutton);
+       CitClient *citsock;
+       wxMDIParentFrame *citMyMDI;
+       DECLARE_EVENT_TABLE()
+};
+// userlogin is the frame for logging in.
+class who : public wxMDIChildFrame {
+public:
+       who(CitClient *sock, wxMDIParentFrame *MyMDI);
+       int do_login();
+       void LoadWholist();
+private:
+       void OnButtonPressed(wxCommandEvent& whichbutton);
+       CitClient *citsock;
+       wxListCtrl *wholist;
+       DECLARE_EVENT_TABLE()
+};
+
+
+// This is a timer that periodically refreshes the wholist.
+class who_refresh : public wxTimer {
+public:
+       who_refresh(who *parent_who);
+private:
+       who *which_who;
+       void Notify(void);
+};
+
index a46d237df22787f648619398efe5d3744729c3b1..6778991bbaa255aef9ff4dad4d39268d58acc9a5 100644 (file)
@@ -7,14 +7,7 @@
 // declarations
 // ============================================================================
 
-
-#include <stdio.h>
-#include <wx/wx.h>
-#include <wx/socket.h>
-
-#include "citclient.hpp"
-#include "userlogin.hpp"
-#include "testwindow.hpp"
+#include "includes.hpp"
 
 // ----------------------------------------------------------------------------
 // private classes
@@ -46,6 +39,7 @@ public:
        void OnDoCmd(wxCommandEvent& event);
        void OnConnect(wxCommandEvent& event);
 private:
+       void OnUsersMenu(wxCommandEvent& cmd);
        void OnWindowMenu(wxCommandEvent& cmd);
        wxButton *do_cmd;
        // any class wishing to process wxWindows events must use this macro
@@ -63,6 +57,8 @@ enum
        IG_About,
        IG_Text,
        MENU_CONNECT,
+       UMENU_WHO,
+       UMENU_SEND_EXPRESS,
        WMENU_CASCADE,
        WMENU_TILE,
        WMENU_ARRANGE,
@@ -82,6 +78,8 @@ BEGIN_EVENT_TABLE(    MyFrame, wxMDIParentFrame)
        EVT_MENU(       IG_Quit,                MyFrame::OnQuit)
        EVT_MENU(       IG_About,               MyFrame::OnAbout)
        EVT_MENU(       MENU_CONNECT,           MyFrame::OnConnect)
+       EVT_MENU(       UMENU_WHO,              MyFrame::OnUsersMenu)
+       EVT_MENU(       UMENU_SEND_EXPRESS,     MyFrame::OnUsersMenu)
        EVT_MENU(       WMENU_CASCADE,          MyFrame::OnWindowMenu)
        EVT_MENU(       WMENU_TILE,             MyFrame::OnWindowMenu)
        EVT_MENU(       WMENU_ARRANGE,          MyFrame::OnWindowMenu)
@@ -150,6 +148,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
 
        wxMenu *menuEdit = new wxMenu;
 
+       wxMenu *menuUsers = new wxMenu;
+       menuUsers->Append(UMENU_WHO, "&Who is online?");
+       menuUsers->Append(UMENU_SEND_EXPRESS, "&Page another user");
+
        wxMenu *menuWindow = new wxMenu;
        menuWindow->Append(WMENU_CASCADE, "&Cascade");
        menuWindow->Append(WMENU_TILE, "&Tile");
@@ -164,6 +166,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
        wxMenuBar *menuBar = new wxMenuBar;
        menuBar->Append(menuFile, "&File");
        menuBar->Append(menuEdit, "&Edit");
+       menuBar->Append(menuUsers, "&Users");
        menuBar->Append(menuWindow, "&Window");
        menuBar->Append(menuHelp, "&Help");
 
@@ -176,7 +179,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
 }
 
 
-// event handlers
+// Event handlers.
+// We really could handle all menu items in one function, but that would
+// get kind of confusing, so we break it down by top-level menus.
 
 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
@@ -187,6 +192,16 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
        Close(TRUE);
 }
 
+// User menu handler
+void MyFrame::OnUsersMenu(wxCommandEvent& cmd) {
+       int id;
+       
+       id = cmd.GetId();
+       if (id == UMENU_WHO)
+               new who(citadel, this);
+       else if (id == UMENU_SEND_EXPRESS)
+               new SendExpress(citadel, this, NULL);
+}
 
 // Window menu handler
 void MyFrame::OnWindowMenu(wxCommandEvent& cmd) {
diff --git a/daphne/send_express.cpp b/daphne/send_express.cpp
new file mode 100644 (file)
index 0000000..32875f1
--- /dev/null
@@ -0,0 +1,111 @@
+// =========================================================================
+// declarations
+// =========================================================================
+
+#include "includes.hpp"
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// IDs for the controls and the menu commands
+enum
+{
+       BUTTON_SEND,
+       BUTTON_CANCEL
+};
+
+// ----------------------------------------------------------------------------
+// event tables and other macros for wxWindows
+// ----------------------------------------------------------------------------
+
+// the event tables connect the wxWindows events with the functions (event
+// handlers) which process them. It can be also done at run-time, but for the
+// simple menu events like this the static method is much simpler.
+BEGIN_EVENT_TABLE(     SendExpress, wxMDIChildFrame)
+       EVT_BUTTON(     BUTTON_SEND,            SendExpress::OnButtonPressed)
+       EVT_BUTTON(     BUTTON_CANCEL,          SendExpress::OnButtonPressed)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+
+// ----------------------------------------------------------------------------
+// the application class
+// ----------------------------------------------------------------------------
+
+// frame constructor
+SendExpress::SendExpress(      CitClient *sock,
+                               wxMDIParentFrame *MyMDI,
+                               wxString *touser)
+       : wxMDIChildFrame(MyMDI,        //parent
+                       -1,     //window id
+                       " Page another user ",
+                       wxDefaultPosition,
+                       wxDefaultSize,
+                       wxDEFAULT_FRAME_STYLE,
+                       "SendExpress"
+                       ) {
+
+       wxString sendcmd, recvcmd;
+       wxStringList xferbuf;
+
+       citsock = sock;
+       citMyMDI = MyMDI;
+
+       // set the frame icon
+       /* SetIcon(wxICON(mondrian)); */
+
+       wxButton *send_button = new wxButton(
+               this,
+               BUTTON_SEND,
+               "Send",
+               wxPoint(200,200),
+               wxSize(100,30),
+               0L,
+               wxDefaultValidator,
+               "send_button"
+               );
+
+       wxButton *cancel_button = new wxButton(
+               this,
+               BUTTON_CANCEL,
+               "Cancel",
+               wxPoint(300,300),
+               wxSize(100,30),
+               0L,
+               wxDefaultValidator,
+               "cancel_button"
+               );
+
+       wxLayoutConstraints *c1 = new wxLayoutConstraints;
+       c1->bottom.SameAs(this, wxBottom, 10);
+       c1->left.SameAs(this, wxLeft, 10);
+       c1->height.AsIs(); c1->width.AsIs();
+       send_button->SetConstraints(c1);
+
+       wxLayoutConstraints *c3 = new wxLayoutConstraints;
+       c3->bottom.SameAs(send_button, wxBottom);
+       c3->right.SameAs(this, wxRight, 10);
+       c3->height.AsIs(); c3->width.AsIs();
+       cancel_button->SetConstraints(c3);
+
+       SetAutoLayout(TRUE);
+       Show(TRUE);
+
+}
+
+
+
+void SendExpress::OnButtonPressed(wxCommandEvent& whichbutton) {
+       wxString sendbuf;
+       wxString recvbuf;
+       int r;
+
+       if (whichbutton.GetId() == BUTTON_CANCEL) {
+               delete this;
+       }
+
+}
index 41c5d2942e2c4618c3a5f9407c68cb197ff7f161..9ddcfb381f74abbf9519675a9a7978003af91ef5 100644 (file)
@@ -19,8 +19,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <errno.h>
-#include <wx/wx.h>
-#include "tcp_sockets.hpp"
+#include "includes.hpp"
 
 #ifndef INADDR_NONE
 #define INADDR_NONE 0xffffffff
diff --git a/daphne/tcp_sockets.hpp b/daphne/tcp_sockets.hpp
deleted file mode 100644 (file)
index bca0271..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-class TCPsocket {
-public:
-       TCPsocket::TCPsocket(void);
-       int attach(char *, char *);
-       void detach(void);
-       void serv_read(char *, int);
-       void serv_write(char *, int);
-       void serv_gets(char *);
-       void serv_puts(char *);
-       bool is_connected(void);
-private:
-       int serv_sock;
-       int connectsock(const char *, const char *, const char *);
-       void timeout(int);
-};
-
index b8647412ffdea635883a76b1f330adb393a51c8c..6ea98c3fb122dc161dd424fb7369d70bfad77d92 100644 (file)
@@ -2,10 +2,7 @@
 // declarations
 // ============================================================================
 
-
-#include <wx/wx.h>
-#include "citclient.hpp"
-#include "testwindow.hpp"
+#include "includes.hpp"
 
 // ----------------------------------------------------------------------------
 // private classes
diff --git a/daphne/testwindow.hpp b/daphne/testwindow.hpp
deleted file mode 100644 (file)
index a2a5ef4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// userlogin is the frame for logging in.
-class TestWindow : public wxMDIChildFrame {
-public:
-       TestWindow(CitClient *sock, wxMDIParentFrame *MyMDI);
-private:
-       wxPanel *panel;
-       wxTextCtrl *sendcmd;
-       wxTextCtrl *recvcmd;
-       wxButton *cmd_button;
-       wxButton *close_button;
-       void OnButtonPressed(wxCommandEvent& whichbutton);
-       CitClient *citsock;
-       DECLARE_EVENT_TABLE()
-};
index c869e5e71170304236f2844c3ac802b6f65dc2b4..ce861951f7581cb71cad3bc60c5481736725fa15 100644 (file)
@@ -2,13 +2,7 @@
 // declarations
 // ============================================================================
 
-
-#include <wx/wx.h>
-#include <wx/listctrl.h>
-#include "citclient.hpp"
-#include "userlogin.hpp"
-#include "who.hpp"
-#include "utils.h"
+#include "includes.hpp"
 
 // ----------------------------------------------------------------------------
 // private classes
@@ -254,7 +248,6 @@ void UserLogin::OnButtonPressed(wxCommandEvent& whichbutton) {
                                nopass.ShowModal();
                        } else {
                                // FIX do login procedure here
-                               (void)new who(citsock, citMyMDI);
                        }
                }
        }
diff --git a/daphne/userlogin.hpp b/daphne/userlogin.hpp
deleted file mode 100644 (file)
index d753f16..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// userlogin is the frame for logging in.
-class UserLogin : public wxMDIChildFrame {
-public:
-       UserLogin(CitClient *sock, wxMDIParentFrame *MyMDI);
-       int do_login();
-private:
-       wxPanel *panel;
-       wxTextCtrl *username;
-       wxTextCtrl *password;
-       wxButton *login_button;
-       wxButton *newuser_button;
-       wxButton *exit_button;
-       void OnButtonPressed(wxCommandEvent& whichbutton);
-       CitClient *citsock;
-       wxMDIParentFrame *citMyMDI;
-       DECLARE_EVENT_TABLE()
-};
index 8c59d50e433be6a73e62da8cfe3b0e9023f4cd68..dcaf7e177345f650258fabdcb820bcaf06340bc4 100644 (file)
@@ -2,12 +2,7 @@
 // declarations
 // ============================================================================
 
-
-#include <wx/wx.h>
-#include <wx/listctrl.h>
-#include "citclient.hpp"
-#include "who.hpp"
-#include "utils.h"
+#include "includes.hpp"
 
 // ----------------------------------------------------------------------------
 // private classes
diff --git a/daphne/who.hpp b/daphne/who.hpp
deleted file mode 100644 (file)
index 5d74aca..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// userlogin is the frame for logging in.
-class who : public wxMDIChildFrame {
-public:
-       who(CitClient *sock, wxMDIParentFrame *MyMDI);
-       int do_login();
-       void LoadWholist();
-private:
-       void OnButtonPressed(wxCommandEvent& whichbutton);
-       CitClient *citsock;
-       wxListCtrl *wholist;
-       DECLARE_EVENT_TABLE()
-};
-
-
-// This is a timer that periodically refreshes the wholist.
-class who_refresh : public wxTimer {
-public:
-       who_refresh(who *parent_who);
-private:
-       who *which_who;
-       void Notify(void);
-};