1 #include <wx/wx.h> // General-purpose wxWin header
2 #include <wx/listctrl.h>
3 #include <wx/socket.h> // TCP socket client
5 #include <wx/imaglist.h>
6 #include <wx/treectrl.h>
7 #include <wx/toolbar.h>
8 #include <wx/tokenzr.h> // For the string tokenizer
9 #include <wx/thread.h> // No threads, but we need wxCriticalSection
10 #include <wx/wxhtml.h> // Vaclav Slavik's HTML display widget
13 #define DEFAULT_HOST "uncnsrd.mt-kisco.ny.us"
14 #define DEFAULT_PORT "504"
17 // Room flags (from ipcdef.h in the main Citadel distribution)
19 #define QR_PERMANENT 1 /* Room does not purge */
20 #define QR_INUSE 2 /* Set if in use, clear if avail */
21 #define QR_PRIVATE 4 /* Set for any type of private room */
22 #define QR_PASSWORDED 8 /* Set if there's a password too */
23 #define QR_GUESSNAME 16 /* Set if it's a guessname room */
24 #define QR_DIRECTORY 32 /* Directory room */
25 #define QR_UPLOAD 64 /* Allowed to upload */
26 #define QR_DOWNLOAD 128 /* Allowed to download */
27 #define QR_VISDIR 256 /* Visible directory */
28 #define QR_ANONONLY 512 /* Anonymous-Only room */
29 #define QR_ANONOPT 1024 /* Anonymous-Option room */
30 #define QR_NETWORK 2048 /* Shared network room */
31 #define QR_PREFONLY 4096 /* Preferred status needed to enter */
32 #define QR_READONLY 8192 /* Aide status required to post */
33 #define QR_MAILBOX 16384 /* Set if this is a private mailbox */
38 // CitClient represents an application-level connection to a Citadel server.
44 // Citadel session-layer commands
45 int attach(wxString host, wxString port);
47 bool IsConnected(void);
48 int CitClient::serv_trans(
54 int CitClient::serv_trans(
59 int CitClient::serv_trans(wxString& command, wxString& response);
60 int CitClient::serv_trans(wxString& command);
62 // Citadel presentation-layer commands
63 bool CitClient::GotoRoom(wxString roomname, wxString password,
64 wxString& server_response);
66 // Various things we learn about the server ...
71 wxString ServerSoftware;
80 // ... and about the user ...
85 // Stuff we have to keep track of ...
89 wxSocketClient *sock; // transport layer
90 wxCriticalSection Critter;
91 void serv_gets(wxString& buf); // session layer
92 void serv_puts(wxString buf); // session layer
93 void reconnect_session(void); // session layer
94 void download_express_messages(void); // presentation layer
95 void initialize_session(void); // presentation layer
103 // This is a timer that does keepalives...
104 class keepalive : public wxTimer {
106 keepalive(CitClient *sock);
108 CitClient *which_sock;
113 // Receive an express message (page)
114 class express_message : public wxFrame {
116 express_message(CitClient *sock, wxString sender,
117 wxString sendsys, wxString msg);
119 void OnButtonPressed(wxCommandEvent& whichbutton);
122 DECLARE_EVENT_TABLE()
128 // SendExpress is the screen for sending an express message (page).
130 class SendExpress : public wxMDIChildFrame {
132 SendExpress( CitClient *sock,
133 wxMDIParentFrame *MyMDI,
136 void OnButtonPressed(wxCommandEvent& whichbutton);
138 wxMDIParentFrame *citMyMDI;
140 wxTextCtrl *TheMessage;
141 DECLARE_EVENT_TABLE()
145 // Preferences for the application.
147 class Preferences : public wxMDIChildFrame {
149 Preferences( CitClient *sock,
150 wxMDIParentFrame *MyMDI);
152 void OnButtonPressed(wxCommandEvent& whichbutton);
154 wxMDIParentFrame *citMyMDI;
155 wxTextCtrl *server_host, *server_port;
156 wxCheckBox *server_autoconnect;
157 DECLARE_EVENT_TABLE()
163 class TestWindow : public wxMDIChildFrame {
165 TestWindow(CitClient *sock, wxMDIParentFrame *MyMDI);
171 wxButton *cmd_button;
172 wxButton *close_button;
173 void OnButtonPressed(wxCommandEvent& whichbutton);
175 DECLARE_EVENT_TABLE()
181 // userlogin is the frame for logging in.
182 class UserLogin : public wxMDIChildFrame {
184 UserLogin(CitClient *sock, wxMDIParentFrame *MyMDI);
188 wxTextCtrl *username;
189 wxTextCtrl *password;
190 wxButton *login_button;
191 wxButton *newuser_button;
192 wxButton *exit_button;
193 void OnButtonPressed(wxCommandEvent& whichbutton);
194 void UserLogin::BeginSession(wxString serv_response);
196 wxMDIParentFrame *citMyMDI;
197 DECLARE_EVENT_TABLE()
202 class who : public wxMDIChildFrame {
204 who(CitClient *sock, wxMDIParentFrame *MyMDI);
208 void OnButtonPressed(wxCommandEvent& whichbutton);
211 DECLARE_EVENT_TABLE()
215 // This is a timer that periodically refreshes the wholist.
216 class who_refresh : public wxTimer {
218 who_refresh(who *parent_who);
226 // Global server properties
228 class ServProps : public wxMDIChildFrame {
230 ServProps( CitClient *sock,
231 wxMDIParentFrame *MyMDI,
232 wxString WhichPanel);
233 void ChangePanel(wxString WhichPanel);
235 void OnButtonPressed(wxCommandEvent& whichbutton);
237 wxMDIParentFrame *citMyMDI;
238 wxPanel *identity_panel, *network_panel, *security_panel;
239 wxString ServerConfigStrings[20];
240 void LoadServerConfigStrings(void);
241 void SaveServerConfigStrings(void);
242 DECLARE_EVENT_TABLE()
247 // The ever-present tree of floors and rooms
249 class RoomTree : public wxTreeCtrl {
251 RoomTree(wxMDIParentFrame *parent, CitClient *sock);
252 void LoadRoomList(void);
253 wxString GetNextRoom(void);
255 wxTreeItemId GetNextRoomId(void);
256 void InitTreeIcons(void);
257 void OnDoubleClick(wxTreeEvent& evt);
259 wxMDIParentFrame *citMyMDI;
260 wxTreeItemId floorboards[MAXFLOORS];
261 wxImageList *TreeIcons;
262 wxTreeItemId march_next;
263 ServProps *CurrServProps;
264 DECLARE_EVENT_TABLE()
269 // A window representing an open room.
270 class RoomView : public wxMDIChildFrame {
272 RoomView(CitClient *sock, wxMDIParentFrame *MyMDI, wxString roomname);
274 void OnButtonPressed(wxCommandEvent& whichbutton);
276 void do_readloop(wxString readcmd);
277 wxMDIParentFrame *citMyMDI;
278 wxHtmlWindow *message_window;
280 wxButton *close_button;
282 unsigned int RoomFlags;
283 unsigned int new_messages;
284 unsigned int total_messages;
286 DECLARE_EVENT_TABLE()
290 class SelectUser : public wxPanel {
292 SelectUser(CitClient *, wxWindow *, wxString,
293 wxString, unsigned int, wxTextCtrl *);
295 void OnButtonPressed(wxCommandEvent& whichbutton);
296 void AddLocalUsers(wxTreeCtrl *, CitClient *);
297 wxButton select_button;
298 wxButton cancel_button;
300 wxTextCtrl *target_textctrl;
302 DECLARE_EVENT_TABLE()
307 class EnterMessage : public wxMDIChildFrame {
309 EnterMessage(CitClient *sock, wxMDIParentFrame *MyMDI,
310 wxString roomname, unsigned int roomflags);
312 void OnCancel(wxCommandEvent& whichbutton);
313 void OnSave(wxCommandEvent& whichbutton);
314 void OnFind(wxCommandEvent& whichbutton);
316 wxMDIParentFrame *citMyMDI;
320 wxTextCtrl *TheMessage;
321 SelectUser *finduser_panel;
322 DECLARE_EVENT_TABLE()
330 // A message. (This is not a GUI class; it's used for internal
334 CitMessage(CitClient *sock, wxString getmsg_cmd, wxString inRoom);
347 // Stuff from utils.cpp
349 void extract(wxString& outputbuf, wxString inputbuf, int parmnum);
350 int extract_int(wxString inputbuf, int parmnum);
351 void load_roomlist(RoomTree *tree, CitClient *citsock);
352 void variformat_to_html(wxString& outputbuf,
354 bool add_header_and_footer);
355 wxString generate_html_header(CitMessage *, wxString, wxString);
365 extern wxMDIParentFrame *BigMDI;
366 extern RoomTree *RoomList;
367 extern CitClient *citadel;
368 extern wxConfig *ini;