| 115 | |
| 116 | |
| 117 | void CServerWnd::OnBnClickedAddserver(wxCommandEvent& WXUNUSED(evt)) |
| 118 | { |
| 119 | wxString servername = CastChild( IDC_SERVERNAME, wxTextCtrl )->GetValue(); |
| 120 | wxString serveraddr = CastChild( IDC_IPADDRESS, wxTextCtrl )->GetValue(); |
| 121 | long port = StrToULong( CastChild( IDC_SPORT, wxTextCtrl )->GetValue() ); |
| 122 | |
| 123 | if ( serveraddr.IsEmpty() ) { |
| 124 | AddLogLineC(_("Server not added: No IP or hostname specified.")); |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | if ( port <= 0 || port > 65535 ) { |
| 129 | AddLogLineC(_("Server not added: Invalid server-port specified.")); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | CServer* toadd = new CServer( port, serveraddr ); |
| 134 | toadd->SetListName( servername.IsEmpty() ? serveraddr : servername ); |
| 135 | |
| 136 | if ( theApp->AddServer( toadd, true ) ) { |
| 137 | CastChild( IDC_SERVERNAME, wxTextCtrl )->Clear(); |
| 138 | CastChild( IDC_IPADDRESS, wxTextCtrl )->Clear(); |
| 139 | CastChild( IDC_SPORT, wxTextCtrl )->Clear(); |
| 140 | } else { |
| 141 | CServer* update = theApp->serverlist->GetServerByAddress(toadd->GetAddress(), toadd->GetPort()); |
| 142 | // See note on CServerList::AddServer |
| 143 | if (update == NULL && toadd->GetIP() != 0) { |
| 144 | update = theApp->serverlist->GetServerByIPTCP(toadd->GetIP(), toadd->GetPort()); |
| 145 | } |
| 146 | |
| 147 | if ( update ) { |
| 148 | update->SetListName(toadd->GetListName()); |
| 149 | serverlistctrl->RefreshServer(update); |
| 150 | } |
| 151 | delete toadd; |
| 152 | } |
| 153 | |
| 154 | theApp->serverlist->SaveServerMet(); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | void CServerWnd::OnBnClickedUpdateservermetfromurl(wxCommandEvent& WXUNUSED(evt)) |
nothing calls this directly
no test coverage detected