1 // =========================================================================
3 // =========================================================================
5 #include "includes.hpp"
7 // ----------------------------------------------------------------------------
9 // ----------------------------------------------------------------------------
11 // IDs for the controls and the menu commands
17 // ----------------------------------------------------------------------------
18 // event tables and other macros for wxWindows
19 // ----------------------------------------------------------------------------
21 BEGIN_EVENT_TABLE(ServProps, wxMDIChildFrame)
22 EVT_BUTTON(BUTTON_SAVE, ServProps::OnButtonPressed)
23 EVT_BUTTON(BUTTON_CANCEL, ServProps::OnButtonPressed)
26 // ============================================================================
28 // ============================================================================
31 ServProps::ServProps(CitClient * sock,
32 wxMDIParentFrame * MyMDI,
34 :wxMDIChildFrame(MyMDI, //parent
36 " Server properties ",
39 wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL,
50 /* SetIcon(wxICON(mondrian)); */
52 wxButton *save_button = new wxButton(
63 wxButton *cancel_button = new wxButton(
74 wxLayoutConstraints *c1 = new wxLayoutConstraints;
75 c1->bottom.SameAs(this, wxBottom, 5);
76 c1->left.SameAs(this, wxLeft, 10);
79 save_button->SetConstraints(c1);
81 wxLayoutConstraints *c3 = new wxLayoutConstraints;
82 c3->bottom.SameAs(save_button, wxBottom);
83 c3->right.SameAs(this, wxRight, 10);
86 cancel_button->SetConstraints(c3);
88 identity_panel = new wxPanel(this, -1);
89 network_panel = new wxPanel(this, -1);
90 security_panel = new wxPanel(this, -1);
92 wxLayoutConstraints *c4 = new wxLayoutConstraints;
93 c4->top.SameAs(this, wxTop);
94 c4->left.SameAs(this, wxLeft);
95 c4->right.SameAs(this, wxRight);
96 c4->bottom.Above(cancel_button, -5);
98 wxLayoutConstraints *c41 = new wxLayoutConstraints;
99 memcpy(c41, c4, sizeof(wxLayoutConstraints));
101 wxLayoutConstraints *c42 = new wxLayoutConstraints;
102 memcpy(c42, c4, sizeof(wxLayoutConstraints));
104 identity_panel->SetConstraints(c4);
105 network_panel->SetConstraints(c41);
106 security_panel->SetConstraints(c42);
108 wxStaticText *ip_label = new wxStaticText(
109 identity_panel, -1, "Server identity");
110 wxStaticText *np_label = new wxStaticText(
111 network_panel, -1, "Network presence");
112 wxStaticText *sp_label = new wxStaticText(
113 security_panel, -1, "Global security settings");
115 wxLayoutConstraints *c5 = new wxLayoutConstraints;
116 c5->top.SameAs(network_panel, wxTop, 3);
117 c5->left.SameAs(network_panel, wxLeft, 3);
118 c5->right.SameAs(network_panel, wxRight, 3);
121 ip_label->SetConstraints(c5);
122 //np_label->SetConstraints(c5);
123 //sp_label->SetConstraints(c5);
127 LoadServerConfigStrings();
130 ChangePanel(WhichPanel);
134 void ServProps::ChangePanel(wxString WhichPanel)
136 identity_panel->Show(!WhichPanel.CmpNoCase("Identity") ? TRUE : FALSE);
137 network_panel->Show(!WhichPanel.CmpNoCase("Network") ? TRUE : FALSE);
138 security_panel->Show(!WhichPanel.CmpNoCase("Security") ? TRUE : FALSE);
144 void ServProps::OnButtonPressed(wxCommandEvent & whichbutton)
146 switch (whichbutton.GetId()) {
151 SaveServerConfigStrings();
158 void ServProps::LoadServerConfigStrings()
161 wxString sendcmd, recvcmd, xferbuf;
164 ServerConfigStrings[i].Empty();
166 // Make the window go away if this command fails.
167 // Most likely we mistakenly got here without first checking for
168 // the proper access level.
169 sendcmd = "CONF get";
170 if (citsock->serv_trans(sendcmd, recvcmd, xferbuf) != 1)
173 wxStringTokenizer *cl = new wxStringTokenizer(xferbuf, "\n", FALSE);
175 while ((i<20) && (cl->HasMoreTokens())) {
176 ServerConfigStrings[i++] = cl->NextToken();
181 void ServProps::SaveServerConfigStrings()
184 wxString sendcmd, recvcmd, xferbuf;
187 for (i=0; i<20; ++i) {
188 xferbuf += ServerConfigStrings[i];
192 sendcmd = "CONF set";
193 if (citsock->serv_trans(sendcmd, recvcmd, xferbuf) != 4) {
194 wxMessageDialog errmsg(this,
197 wxOK | wxCENTRE | wxICON_INFORMATION,