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
-#include <ctype.h>
-#include <string.h>
-#include <wx/wx.h>
-
-#include "citclient.hpp"
-#include "express_message.hpp"
-#include "utils.h"
+#include "includes.hpp"
//
+++ /dev/null
-#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);
-};
-
-
-
// declarations
// ============================================================================
-
-#include <wx/wx.h>
-#include <wx/listctrl.h>
-#include "citclient.hpp"
-#include "express_message.hpp"
-#include "utils.h"
+#include "includes.hpp"
// ----------------------------------------------------------------------------
// private classes
+++ /dev/null
-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()
-};
--- /dev/null
+#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);
+};
+
// 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
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
IG_About,
IG_Text,
MENU_CONNECT,
+ UMENU_WHO,
+ UMENU_SEND_EXPRESS,
WMENU_CASCADE,
WMENU_TILE,
WMENU_ARRANGE,
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)
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");
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, "&File");
menuBar->Append(menuEdit, "&Edit");
+ menuBar->Append(menuUsers, "&Users");
menuBar->Append(menuWindow, "&Window");
menuBar->Append(menuHelp, "&Help");
}
-// 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))
{
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) {
--- /dev/null
+// =========================================================================
+// 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;
+ }
+
+}
#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
+++ /dev/null
-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);
-};
-
// declarations
// ============================================================================
-
-#include <wx/wx.h>
-#include "citclient.hpp"
-#include "testwindow.hpp"
+#include "includes.hpp"
// ----------------------------------------------------------------------------
// private classes
+++ /dev/null
-// 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()
-};
// 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
nopass.ShowModal();
} else {
// FIX do login procedure here
- (void)new who(citsock, citMyMDI);
}
}
}
+++ /dev/null
-// 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()
-};
// declarations
// ============================================================================
-
-#include <wx/wx.h>
-#include <wx/listctrl.h>
-#include "citclient.hpp"
-#include "who.hpp"
-#include "utils.h"
+#include "includes.hpp"
// ----------------------------------------------------------------------------
// private classes
+++ /dev/null
-// 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);
-};