3 #include <wx/wx.h> // General-purpose wxWin header
4 #include <wx/listctrl.h>
5 #include <wx/socket.h> // TCP socket client
7 #include <wx/imaglist.h>
8 #include <wx/treectrl.h>
9 #include <wx/toolbar.h>
10 #include <wx/tokenzr.h> // For the string tokenizer
11 #include <wx/thread.h> // No threads, but we need wxCriticalSection
12 #include <wx/wxhtml.h> // Vaclav Slavik's HTML display widget
15 #define DEFAULT_HOST "uncnsrd.mt-kisco.ny.us"
16 #define DEFAULT_PORT "504"
19 // Room flags (from ipcdef.h in the main Citadel distribution)
21 #define QR_PERMANENT 1 /* Room does not purge */
22 #define QR_INUSE 2 /* Set if in use, clear if avail */
23 #define QR_PRIVATE 4 /* Set for any type of private room */
24 #define QR_PASSWORDED 8 /* Set if there's a password too */
25 #define QR_GUESSNAME 16 /* Set if it's a guessname room */
26 #define QR_DIRECTORY 32 /* Directory room */
27 #define QR_UPLOAD 64 /* Allowed to upload */
28 #define QR_DOWNLOAD 128 /* Allowed to download */
29 #define QR_VISDIR 256 /* Visible directory */
30 #define QR_ANONONLY 512 /* Anonymous-Only room */
31 #define QR_ANONOPT 1024 /* Anonymous-Option room */
32 #define QR_NETWORK 2048 /* Shared network room */
33 #define QR_PREFONLY 4096 /* Preferred status needed to enter */
34 #define QR_READONLY 8192 /* Aide status required to post */
35 #define QR_MAILBOX 16384 /* Set if this is a private mailbox */
40 // CitClient represents an application-level connection to a Citadel server.
46 // Citadel session-layer commands
47 int attach(wxString host, wxString port);
49 bool IsConnected(void);
50 int CitClient::serv_trans(
56 int CitClient::serv_trans(
61 int CitClient::serv_trans(wxString& command, wxString& response);
62 int CitClient::serv_trans(wxString& command);
64 // Citadel presentation-layer commands
65 bool CitClient::GotoRoom(wxString roomname, wxString password,
66 wxString& server_response);
68 // Various things we learn about the server ...
73 wxString ServerSoftware;
82 // ... and about the user ...
87 // Stuff we have to keep track of ...
91 wxSocketClient *sock; // transport layer
92 wxCriticalSection Critter;
93 void serv_gets(wxString& buf); // session layer
94 void serv_puts(wxString buf); // session layer
95 void reconnect_session(void); // session layer
96 void download_express_messages(void); // presentation layer
97 void initialize_session(void); // presentation layer
105 // This is a timer that does keepalives...
106 class keepalive : public wxTimer {
108 keepalive(CitClient *sock);
110 CitClient *which_sock;
115 // Receive an express message (page)
116 class express_message : public wxFrame {
118 express_message(CitClient *sock, wxString sender,
119 wxString sendsys, wxString msg);
121 void OnButtonPressed(wxCommandEvent& whichbutton);
124 DECLARE_EVENT_TABLE()
130 // SendExpress is the screen for sending an express message (page).
132 class SendExpress : public wxMDIChildFrame {
134 SendExpress( CitClient *sock,
135 wxMDIParentFrame *MyMDI,
138 void OnButtonPressed(wxCommandEvent& whichbutton);
140 wxMDIParentFrame *citMyMDI;
142 wxTextCtrl *TheMessage;
143 DECLARE_EVENT_TABLE()
147 // Preferences for the application.
149 class Preferences : public wxMDIChildFrame {
151 Preferences( CitClient *sock,
152 wxMDIParentFrame *MyMDI);
154 void OnButtonPressed(wxCommandEvent& whichbutton);
156 wxMDIParentFrame *citMyMDI;
157 wxTextCtrl *server_host, *server_port;
158 wxCheckBox *server_autoconnect;
159 DECLARE_EVENT_TABLE()
164 class Hosts : public wxMDIChildFrame {
166 Hosts( CitClient *sock,
167 wxMDIParentFrame *MyMDI);
169 void OnButtonPressed(wxCommandEvent& whichbutton);
171 wxMDIParentFrame *citMyMDI;
172 wxTextCtrl *server_host, *server_port;
173 wxCheckBox *server_autoconnect;
174 DECLARE_EVENT_TABLE()
178 class TestWindow : public wxMDIChildFrame {
180 TestWindow(CitClient *sock, wxMDIParentFrame *MyMDI);
186 wxButton *cmd_button;
187 wxButton *close_button;
188 void OnButtonPressed(wxCommandEvent& whichbutton);
190 DECLARE_EVENT_TABLE()
194 class ChatWindow : public wxMDIChildFrame {
196 ChatWindow(CitClient *sock, wxMDIParentFrame *MyMDI);
202 wxButton *cmd_button;
203 wxButton *close_button;
204 void OnButtonPressed(wxCommandEvent& whichbutton);
206 DECLARE_EVENT_TABLE()
211 // userlogin is the frame for logging in.
212 class UserLogin : public wxMDIChildFrame {
214 UserLogin(CitClient *sock, wxMDIParentFrame *MyMDI);
218 wxTextCtrl *username;
219 wxTextCtrl *password;
220 wxButton *login_button;
221 wxButton *newuser_button;
222 wxButton *exit_button;
223 void OnButtonPressed(wxCommandEvent& whichbutton);
224 void UserLogin::BeginSession(wxString serv_response);
226 wxMDIParentFrame *citMyMDI;
227 DECLARE_EVENT_TABLE()
232 class who : public wxMDIChildFrame {
234 who(CitClient *sock, wxMDIParentFrame *MyMDI);
238 void OnButtonPressed(wxCommandEvent& whichbutton);
241 DECLARE_EVENT_TABLE()
245 // This is a timer that periodically refreshes the wholist.
246 class who_refresh : public wxTimer {
248 who_refresh(who *parent_who);
255 // Global server properties
257 class ServProps : public wxMDIChildFrame {
259 ServProps( CitClient *sock,
260 wxMDIParentFrame *MyMDI,
261 wxString WhichPanel);
262 void ChangePanel(wxString WhichPanel);
264 void OnButtonPressed(wxCommandEvent& whichbutton);
266 wxMDIParentFrame *citMyMDI;
267 wxPanel *identity_panel, *network_panel, *security_panel;
268 wxString ServerConfigStrings[20];
269 void LoadServerConfigStrings(void);
270 void SaveServerConfigStrings(void);
271 DECLARE_EVENT_TABLE()
276 // The ever-present tree of floors and rooms
278 class RoomTree : public wxTreeCtrl {
280 RoomTree(wxMDIParentFrame *parent, CitClient *sock);
281 void LoadRoomList(void);
282 wxString GetNextRoom(void);
284 wxTreeItemId GetNextRoomId(void);
285 void InitTreeIcons(void);
286 void OnDoubleClick(wxTreeEvent& evt);
288 wxMDIParentFrame *citMyMDI;
289 wxTreeItemId floorboards[MAXFLOORS];
290 wxImageList *TreeIcons;
291 wxTreeItemId march_next;
292 ServProps *CurrServProps;
293 DECLARE_EVENT_TABLE()
298 // A window representing an open room.
299 class RoomView : public wxMDIChildFrame {
301 RoomView(CitClient *sock, wxMDIParentFrame *MyMDI, wxString roomname);
303 void OnButtonPressed(wxCommandEvent& whichbutton);
305 void do_readloop(wxString readcmd);
306 wxMDIParentFrame *citMyMDI;
307 wxHtmlWindow *message_window;
309 wxButton *close_button;
311 unsigned int RoomFlags;
312 unsigned int new_messages;
313 unsigned int total_messages;
315 DECLARE_EVENT_TABLE()
319 class SelectUser : public wxPanel {
321 SelectUser(CitClient *, wxWindow *, wxString,
322 wxString, unsigned int, wxTextCtrl *);
324 void OnButtonPressed(wxCommandEvent& whichbutton);
325 void AddLocalUsers(wxTreeCtrl *, CitClient *);
326 wxButton select_button;
327 wxButton cancel_button;
329 wxTextCtrl *target_textctrl;
331 DECLARE_EVENT_TABLE()
336 class EnterMessage : public wxMDIChildFrame {
338 EnterMessage(CitClient *sock,
339 wxMDIParentFrame *MyMDI,
340 wxString roomname, unsigned int roomflags);
342 void OnCancel(wxCommandEvent& whichbutton);
343 void OnSave(wxCommandEvent& whichbutton);
344 void OnFind(wxCommandEvent& whichbutton);
346 wxMDIParentFrame *citMyMDI;
350 wxTextCtrl *TheMessage;
351 SelectUser *finduser_panel;
352 DECLARE_EVENT_TABLE()
360 // A message. (This is not a GUI class; it's used for internal
364 CitMessage(CitClient *sock, wxString getmsg_cmd, wxString inRoom);
377 // Stuff from utils.cpp
379 void extract(wxString& outputbuf, wxString inputbuf, int parmnum);
380 int extract_int(wxString inputbuf, int parmnum);
381 void load_roomlist(RoomTree *tree, CitClient *citsock);
382 void variformat_to_html(wxString& outputbuf,
384 bool add_header_and_footer);
385 wxString generate_html_header(CitMessage *, wxString, wxString);
395 extern wxMDIParentFrame *BigMDI;
396 extern RoomTree *RoomList;
397 extern CitClient *citadel;
398 extern wxConfig *ini;