MCPcopy Create free account
hub / github.com/amule-project/amule / OnBnClickedAddserver

Method OnBnClickedAddserver

src/ServerWnd.cpp:117–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116
117void 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
158void CServerWnd::OnBnClickedUpdateservermetfromurl(wxCommandEvent& WXUNUSED(evt))

Callers

nothing calls this directly

Calls 12

StrToULongFunction · 0.85
SetListNameMethod · 0.80
RefreshServerMethod · 0.80
GetValueMethod · 0.45
IsEmptyMethod · 0.45
AddServerMethod · 0.45
ClearMethod · 0.45
GetServerByAddressMethod · 0.45
GetPortMethod · 0.45
GetIPMethod · 0.45
GetServerByIPTCPMethod · 0.45
SaveServerMetMethod · 0.45

Tested by

no test coverage detected