| 171 | |
| 172 | |
| 173 | void CServerListCtrl::RefreshServer( CServer* server ) |
| 174 | { |
| 175 | // Can't really refresh a NULL server |
| 176 | if (!server) { |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | wxUIntPtr ptr = reinterpret_cast<wxUIntPtr>(server); |
| 181 | long itemnr = FindItem( -1, ptr ); |
| 182 | if ( itemnr == -1 ) { |
| 183 | // We are not at the sure that the server isn't in the list, so we can re-add |
| 184 | itemnr = InsertItem( GetInsertPos( ptr ), server->GetListName() ); |
| 185 | SetItemPtrData( itemnr, ptr ); |
| 186 | |
| 187 | wxListItem item; |
| 188 | item.SetId( itemnr ); |
| 189 | item.SetBackgroundColour(CMuleColour(wxSYS_COLOUR_LISTBOX)); |
| 190 | SetItem( item ); |
| 191 | } |
| 192 | |
| 193 | wxString serverName; |
| 194 | #ifdef ENABLE_IP2COUNTRY |
| 195 | // Get the country name |
| 196 | if (theApp->amuledlg->m_IP2Country->IsEnabled() && thePrefs::IsGeoIPEnabled()) { |
| 197 | const CountryData& countrydata = theApp->amuledlg->m_IP2Country->GetCountryData(server->GetFullIP()); |
| 198 | serverName << countrydata.Name; |
| 199 | serverName << " - "; |
| 200 | } |
| 201 | #endif // ENABLE_IP2COUNTRY |
| 202 | serverName << server->GetListName(); |
| 203 | SetItem(itemnr, COLUMN_SERVER_NAME, serverName); |
| 204 | SetItem(itemnr, COLUMN_SERVER_ADDR, server->GetAddress()); |
| 205 | if (server->GetAuxPortsList().IsEmpty()) { |
| 206 | SetItem( itemnr, COLUMN_SERVER_PORT, |
| 207 | CFormat("%u") % server->GetPort()); |
| 208 | } else { |
| 209 | SetItem( itemnr, COLUMN_SERVER_PORT, |
| 210 | CFormat("%u (%s)") % server->GetPort() % server->GetAuxPortsList()); |
| 211 | } |
| 212 | SetItem( itemnr, COLUMN_SERVER_DESC, server->GetDescription() ); |
| 213 | |
| 214 | if ( server->GetPing() ) { |
| 215 | SetItem( itemnr, COLUMN_SERVER_PING, |
| 216 | CastSecondsToHM(server->GetPing()/1000, server->GetPing() % 1000 ) ); |
| 217 | } else { |
| 218 | SetItem( itemnr, COLUMN_SERVER_PING, "" ); |
| 219 | } |
| 220 | |
| 221 | if ( server->GetUsers() ) { |
| 222 | SetItem( itemnr, COLUMN_SERVER_USERS, |
| 223 | CFormat("%u") % server->GetUsers()); |
| 224 | } else { |
| 225 | SetItem( itemnr, COLUMN_SERVER_USERS, "" ); |
| 226 | } |
| 227 | |
| 228 | if ( server->GetFiles() ) { |
| 229 | SetItem( itemnr, COLUMN_SERVER_FILES, |
| 230 | CFormat("%u") % server->GetFiles()); |
no test coverage detected