2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "ServerListCtrl.h" // Interface declarations
28 #include <common/MenuIDs.h>
31 #include <wx/stattext.h>
32 #include <wx/msgdlg.h>
33 #include <wx/settings.h>
35 #include "amule.h" // Needed for theApp
36 #include "DownloadQueue.h" // Needed for CDownloadQueue
37 #ifdef ENABLE_IP2COUNTRY
38 #include "IP2Country.h" // Needed for IP2Country
39 #include "amuleDlg.h" // Needed for IP2Country
41 #include "ServerList.h" // Needed for CServerList
42 #include "ServerConnect.h" // Needed for CServerConnect
43 #include "Server.h" // Needed for CServer and SRV_PR_*
45 #include <common/Format.h> // Needed for CFormat
46 #include <common/TextFile.h> // Needed for CTextFile
49 #define CMuleColour(x) (wxSystemSettings::GetColour(x))
52 BEGIN_EVENT_TABLE(CServerListCtrl
,CMuleListCtrl
)
53 EVT_LIST_ITEM_RIGHT_CLICK( -1, CServerListCtrl::OnItemRightClicked
)
54 EVT_LIST_ITEM_ACTIVATED( -1, CServerListCtrl::OnItemActivated
)
56 EVT_MENU( MP_PRIOLOW
, CServerListCtrl::OnPriorityChange
)
57 EVT_MENU( MP_PRIONORMAL
, CServerListCtrl::OnPriorityChange
)
58 EVT_MENU( MP_PRIOHIGH
, CServerListCtrl::OnPriorityChange
)
60 EVT_MENU( MP_ADDTOSTATIC
, CServerListCtrl::OnStaticChange
)
61 EVT_MENU( MP_REMOVEFROMSTATIC
, CServerListCtrl::OnStaticChange
)
63 EVT_MENU( MP_CONNECTTO
, CServerListCtrl::OnConnectToServer
)
65 EVT_MENU( MP_REMOVE
, CServerListCtrl::OnRemoveServers
)
66 EVT_MENU( MP_REMOVEALL
, CServerListCtrl::OnRemoveServers
)
68 EVT_MENU( MP_GETED2KLINK
, CServerListCtrl::OnGetED2kURL
)
70 EVT_CHAR( CServerListCtrl::OnKeyPressed
)
75 CServerListCtrl::CServerListCtrl( wxWindow
*parent
, wxWindowID winid
, const wxPoint
& pos
, const wxSize
& size
,
76 long style
, const wxValidator
& validator
, const wxString
& name
)
77 : CMuleListCtrl( parent
, winid
, pos
, size
, style
, validator
, name
)
79 // Setting the sorter function.
80 SetSortFunc( SortProc
);
82 // Set the table-name (for loading and saving preferences).
83 SetTableName( wxT("Server") );
87 InsertColumn( COLUMN_SERVER_NAME
, _("Server Name"), wxLIST_FORMAT_LEFT
, 150, wxT("N") );
88 InsertColumn( COLUMN_SERVER_ADDR
, _("Address"), wxLIST_FORMAT_LEFT
, 140, wxT("A") );
89 InsertColumn( COLUMN_SERVER_PORT
, _("Port"), wxLIST_FORMAT_LEFT
, 25, wxT("P") );
90 InsertColumn( COLUMN_SERVER_DESC
, _("Description"), wxLIST_FORMAT_LEFT
, 150, wxT("D") );
91 InsertColumn( COLUMN_SERVER_PING
, _("Ping"), wxLIST_FORMAT_LEFT
, 25, wxT("p") );
92 InsertColumn( COLUMN_SERVER_USERS
, _("Users"), wxLIST_FORMAT_LEFT
, 40, wxT("U") );
93 InsertColumn( COLUMN_SERVER_FILES
, _("Files"), wxLIST_FORMAT_LEFT
, 45, wxT("F") );
94 InsertColumn( COLUMN_SERVER_PRIO
, _("Priority"), wxLIST_FORMAT_LEFT
, 60, wxT("r") );
95 InsertColumn( COLUMN_SERVER_FAILS
, _("Failed"), wxLIST_FORMAT_LEFT
, 40, wxT("f") );
96 InsertColumn( COLUMN_SERVER_STATIC
, _("Static"), wxLIST_FORMAT_LEFT
, 40, wxT("S") );
97 InsertColumn( COLUMN_SERVER_VERSION
, _("Version"), wxLIST_FORMAT_LEFT
, 80, wxT("V") );
99 InsertColumn( COLUMN_SERVER_TCPFLAGS
, wxT("TCP Flags"), wxLIST_FORMAT_LEFT
, 80, wxT("t") );
100 InsertColumn( COLUMN_SERVER_UDPFLAGS
, wxT("UDP Flags"), wxLIST_FORMAT_LEFT
, 80, wxT("u") );
108 wxString
CServerListCtrl::GetOldColumnOrder() const
110 return wxT("N,A,P,D,p,U,F,r,f,S,V,t,u");
114 CServerListCtrl::~CServerListCtrl()
119 void CServerListCtrl::AddServer( CServer
* toadd
)
121 // RefreshServer will add the server.
122 // This also means that we have simple duplicity checking. ;)
123 RefreshServer( toadd
);
129 void CServerListCtrl::RemoveServer(CServer
* server
)
131 long result
= FindItem(-1, reinterpret_cast<wxUIntPtr
>(server
));
132 if ( result
!= -1 ) {
139 void CServerListCtrl::RemoveAllServers(int state
)
141 int pos
= GetNextItem( -1, wxLIST_NEXT_ALL
, state
);
142 bool connected
= theApp
->IsConnectedED2K() ||
143 theApp
->serverconnect
->IsConnecting();
145 while ( pos
!= -1 ) {
146 CServer
* server
= (CServer
*)GetItemData(pos
);
148 if (reinterpret_cast<wxUIntPtr
>(server
) == m_connected
&& connected
) {
149 wxMessageBox(_("You are connected to a server you are trying to delete. Please disconnect first. The server was NOT deleted."), _("Info"), wxOK
, this);
151 } else if (server
->IsStaticMember()) {
152 const wxString name
= (!server
->GetListName() ? wxString(_("(Unknown name)")) : server
->GetListName());
154 if (wxMessageBox(CFormat(_("Are you sure you want to delete the static server %s")) % name
, _("Cancel"), wxICON_QUESTION
| wxYES_NO
, this) == wxYES
) {
155 SetStaticServer(server
, false);
157 theApp
->serverlist
->RemoveServer( server
);
163 theApp
->serverlist
->RemoveServer( server
);
166 pos
= GetNextItem(pos
- 1, wxLIST_NEXT_ALL
, state
);
173 void CServerListCtrl::RefreshServer( CServer
* server
)
175 // Cant really refresh a NULL server
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
);
188 item
.SetId( itemnr
);
189 item
.SetBackgroundColour(CMuleColour(wxSYS_COLOUR_LISTBOX
));
194 #ifdef ENABLE_IP2COUNTRY
195 // Get the country name
196 if (theApp
->amuledlg
->m_IP2Country
->IsEnabled()) {
197 const CountryData
& countrydata
= theApp
->amuledlg
->m_IP2Country
->GetCountryData(server
->GetFullIP());
198 serverName
<< countrydata
.Name
;
199 serverName
<< wxT(" - ");
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 wxString::Format(wxT("%u"), server
->GetPort()));
209 SetItem( itemnr
, COLUMN_SERVER_PORT
,
210 wxString::Format(wxT("%u ("),
211 server
->GetPort()) + server
->GetAuxPortsList() + wxT(")") );
213 SetItem( itemnr
, COLUMN_SERVER_DESC
, server
->GetDescription() );
215 if ( server
->GetPing() ) {
216 SetItem( itemnr
, COLUMN_SERVER_PING
,
217 CastSecondsToHM(server
->GetPing()/1000, server
->GetPing() % 1000 ) );
219 SetItem( itemnr
, COLUMN_SERVER_PING
, wxEmptyString
);
222 if ( server
->GetUsers() ) {
223 SetItem( itemnr
, COLUMN_SERVER_USERS
,
224 wxString::Format( wxT("%u"), server
->GetUsers() ) );
226 SetItem( itemnr
, COLUMN_SERVER_USERS
, wxEmptyString
);
229 if ( server
->GetFiles() ) {
230 SetItem( itemnr
, COLUMN_SERVER_FILES
,
231 wxString::Format( wxT("%u"), server
->GetFiles() ) );
233 SetItem( itemnr
, COLUMN_SERVER_FILES
, wxEmptyString
);
236 switch ( server
->GetPreferences() ) {
237 case SRV_PR_LOW
: SetItem(itemnr
, COLUMN_SERVER_PRIO
, _("Low")); break;
238 case SRV_PR_NORMAL
: SetItem(itemnr
, COLUMN_SERVER_PRIO
, _("Normal")); break;
239 case SRV_PR_HIGH
: SetItem(itemnr
, COLUMN_SERVER_PRIO
, _("High") ); break;
240 default: SetItem(itemnr
, COLUMN_SERVER_PRIO
, wxT("---")); // this should never happen
243 SetItem( itemnr
, COLUMN_SERVER_FAILS
, wxString::Format( wxT("%u"),server
->GetFailedCount() ) );
244 SetItem( itemnr
, COLUMN_SERVER_STATIC
, ( server
->IsStaticMember() ? _("Yes") : _("No") ) );
245 SetItem( itemnr
, COLUMN_SERVER_VERSION
, server
->GetVersion() );
250 if (server
->GetTCPFlags() & SRV_TCPFLG_COMPRESSION
) {
253 if (server
->GetTCPFlags() & SRV_TCPFLG_NEWTAGS
) {
256 if (server
->GetTCPFlags() & SRV_TCPFLG_UNICODE
) {
259 if (server
->GetTCPFlags() & SRV_TCPFLG_RELATEDSEARCH
) {
262 if (server
->GetTCPFlags() & SRV_TCPFLG_TYPETAGINTEGER
) {
265 if (server
->GetTCPFlags() & SRV_TCPFLG_LARGEFILES
) {
268 if (server
->GetTCPFlags() & SRV_TCPFLG_TCPOBFUSCATION
) {
272 SetItem( itemnr
, COLUMN_SERVER_TCPFLAGS
, flags
);
275 flags
= wxEmptyString
;
276 if (server
->GetUDPFlags() & SRV_UDPFLG_EXT_GETSOURCES
) {
279 if (server
->GetUDPFlags() & SRV_UDPFLG_EXT_GETFILES
) {
282 if (server
->GetUDPFlags() & SRV_UDPFLG_NEWTAGS
) {
285 if (server
->GetUDPFlags() & SRV_UDPFLG_UNICODE
) {
288 if (server
->GetUDPFlags() & SRV_UDPFLG_EXT_GETSOURCES2
) {
291 if (server
->GetUDPFlags() & SRV_UDPFLG_LARGEFILES
) {
294 if (server
->GetUDPFlags() & SRV_UDPFLG_UDPOBFUSCATION
) {
297 if (server
->GetUDPFlags() & SRV_UDPFLG_TCPOBFUSCATION
) {
300 SetItem( itemnr
, COLUMN_SERVER_UDPFLAGS
, flags
);
304 // Deletions of items causes rather large ammount of flicker, so to
305 // avoid this, we resort the list to ensure correct ordering.
306 if (!IsItemSorted(itemnr
)) {
312 void CServerListCtrl::HighlightServer( const CServer
* server
, bool highlight
)
314 // Unset the old highlighted server if we are going to set a new one
315 if ( m_connected
&& highlight
) {
316 // A recursive call to do the real work.
317 HighlightServer( (CServer
*)m_connected
, false );
322 long itemnr
= FindItem( -1, reinterpret_cast<wxUIntPtr
>(server
) );
325 item
.SetId( itemnr
);
327 if ( GetItem( item
) ) {
328 wxFont font
= GetFont();
331 font
.SetWeight( wxBOLD
);
333 m_connected
= reinterpret_cast<wxUIntPtr
>(server
);
336 item
.SetFont( font
);
343 //#warning Kry TODO: Dude, this gotta be moved to core
344 bool CServerListCtrl::SetStaticServer( CServer
* server
, bool isStatic
)
346 server
->SetIsStaticMember( isStatic
);
347 RefreshServer( server
);
349 wxString filename
= theApp
->ConfigDir
+ wxT("staticservers.dat");
352 if (!file
.Open(filename
, CTextFile::write
)) {
353 AddLogLineM( false, CFormat( _("Failed to open '%s'") ) % filename
);
357 for (int i
= 0; i
< GetItemCount(); ++i
) {
358 server
= reinterpret_cast<CServer
*>(GetItemData(i
));
360 if (server
->IsStaticMember()) {
361 file
.WriteLine(CFormat(wxT("%s:%u,%u,%s"))
362 % server
->GetAddress() % server
->GetPort()
363 % server
->GetPreferences() % server
->GetListName());
371 void CServerListCtrl::ShowServerCount()
373 wxStaticText
* label
= CastByName( wxT("serverListLabel"), GetParent(), wxStaticText
);
376 label
->SetLabel( wxString::Format( _("Servers (%i)"), GetItemCount() ) );
377 label
->GetParent()->Layout();
382 void CServerListCtrl::OnItemActivated( wxListEvent
& event
)
384 // Unselect all items but the activated one
385 long item
= GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
386 while ( item
> -1 ) {
387 SetItemState( item
, 0, wxLIST_STATE_SELECTED
);
389 item
= GetNextItem( item
, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
392 SetItemState( event
.GetIndex(), wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
394 wxCommandEvent nulEvt
;
395 OnConnectToServer( nulEvt
);
399 void CServerListCtrl::OnItemRightClicked(wxListEvent
& event
)
401 // Check if clicked item is selected. If not, unselect all and select it.
402 long index
= CheckSelection(event
);
404 bool enable_reconnect
= false;
405 bool enable_static_on
= false;
406 bool enable_static_off
= false;
408 // Gather information on the selected items
409 while ( index
> -1 ) {
410 CServer
* server
= (CServer
*)GetItemData( index
);
412 // The current server is selected, so we might display the reconnect option
413 if ( reinterpret_cast<wxUIntPtr
>(server
) == m_connected
)
414 enable_reconnect
= true;
416 // We want to know which options should be enabled, either one or both
417 enable_static_on
|= !server
->IsStaticMember();
418 enable_static_off
|= server
->IsStaticMember();
420 index
= GetNextItem( index
, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
424 wxMenu
* serverMenu
= new wxMenu(_("Server"));
425 wxMenu
* serverPrioMenu
= new wxMenu();
426 serverPrioMenu
->Append( MP_PRIOLOW
, _("Low") );
427 serverPrioMenu
->Append( MP_PRIONORMAL
, _("Normal") );
428 serverPrioMenu
->Append( MP_PRIOHIGH
, _("High") );
429 serverMenu
->Append( MP_CONNECTTO
, _("Connect to server") );
430 serverMenu
->Append( 12345, _("Priority"), serverPrioMenu
);
432 serverMenu
->AppendSeparator();
434 if (GetSelectedItemCount() == 1) {
435 serverMenu
->Append( MP_ADDTOSTATIC
, _("Mark server as static") );
436 serverMenu
->Append( MP_REMOVEFROMSTATIC
, _("Mark server as non-static") );
438 serverMenu
->Append( MP_ADDTOSTATIC
, _("Mark servers as static") );
439 serverMenu
->Append( MP_REMOVEFROMSTATIC
, _("Mark servers as non-static") );
442 serverMenu
->AppendSeparator();
444 if (GetSelectedItemCount() == 1) {
445 serverMenu
->Append( MP_REMOVE
, _("Remove server") );
447 serverMenu
->Append( MP_REMOVE
, _("Remove servers") );
449 serverMenu
->Append( MP_REMOVEALL
, _("Remove all servers") );
451 serverMenu
->AppendSeparator();
453 if (GetSelectedItemCount() == 1) {
454 serverMenu
->Append( MP_GETED2KLINK
, _("Copy eD2k link to clipboard") );
456 serverMenu
->Append( MP_GETED2KLINK
, _("Copy eD2k links to clipboard") );
459 serverMenu
->Enable( MP_REMOVEFROMSTATIC
, enable_static_off
);
460 serverMenu
->Enable( MP_ADDTOSTATIC
, enable_static_on
);
462 if ( GetSelectedItemCount() == 1 ) {
463 if ( enable_reconnect
)
464 serverMenu
->SetLabel( MP_CONNECTTO
, _("Reconnect to server") );
466 serverMenu
->Enable( MP_CONNECTTO
, false );
470 PopupMenu( serverMenu
, event
.GetPoint() );
474 void CServerListCtrl::OnPriorityChange( wxCommandEvent
& event
)
478 switch ( event
.GetId() ) {
479 case MP_PRIOLOW
: priority
= SRV_PR_LOW
; break;
480 case MP_PRIONORMAL
: priority
= SRV_PR_NORMAL
; break;
481 case MP_PRIOHIGH
: priority
= SRV_PR_HIGH
; break;
488 ItemDataList items
= GetSelectedItems();
490 for ( unsigned int i
= 0; i
< items
.size(); ++i
) {
491 CServer
* server
= (CServer
*)items
[ i
];
493 server
->SetPreference( priority
);
494 RefreshServer( server
);
499 void CServerListCtrl::OnStaticChange( wxCommandEvent
& event
)
501 bool isStatic
= ( event
.GetId() == MP_ADDTOSTATIC
);
503 ItemDataList items
= GetSelectedItems();
505 for ( unsigned int i
= 0; i
< items
.size(); ++i
) {
506 CServer
* server
= (CServer
*)items
[ i
];
508 // Only update items that have the wrong setting
509 if ( server
->IsStaticMember() != isStatic
) {
510 if ( !SetStaticServer( server
, isStatic
) ) {
516 server
->SetIsStaticMember( isStatic
);
517 RefreshServer( server
);
523 void CServerListCtrl::OnConnectToServer( wxCommandEvent
& WXUNUSED(event
) )
525 int item
= GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
528 if ( theApp
->IsConnectedED2K() ) {
529 theApp
->serverconnect
->Disconnect();
532 theApp
->serverconnect
->ConnectToServer( (CServer
*)GetItemData( item
) );
537 void CServerListCtrl::OnGetED2kURL( wxCommandEvent
& WXUNUSED(event
) )
539 int pos
= GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
543 while ( pos
!= -1 ) {
544 CServer
* server
= (CServer
*)GetItemData(pos
);
546 URL
+= wxT("ed2k://|server|") + server
->GetFullIP() + wxString::Format(wxT("|%d|"), server
->GetPort()) + wxT("/\n");
548 pos
= GetNextItem( pos
, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
553 theApp
->CopyTextToClipboard( URL
);
557 void CServerListCtrl::OnRemoveServers( wxCommandEvent
& event
)
559 if ( event
.GetId() == MP_REMOVEALL
) {
560 if ( GetItemCount() ) {
561 wxString question
= _("Are you sure that you wish to delete all servers?");
563 if ( wxMessageBox( question
, _("Cancel"), wxICON_QUESTION
| wxYES_NO
, this) == wxYES
) {
564 if ( theApp
->serverconnect
->IsConnecting() ) {
565 theApp
->downloadqueue
->StopUDPRequests();
566 theApp
->serverconnect
->StopConnectionTry();
567 theApp
->serverconnect
->Disconnect();
570 RemoveAllServers(wxLIST_STATE_DONTCARE
);
573 } else if ( event
.GetId() == MP_REMOVE
) {
574 if ( GetSelectedItemCount() ) {
576 if (GetSelectedItemCount() == 1) {
577 question
= _("Are you sure that you wish to delete the selected server?");
579 question
= _("Are you sure that you wish to delete the selected servers?");
582 if ( wxMessageBox( question
, _("Cancel"), wxICON_QUESTION
| wxYES_NO
, this) == wxYES
) {
583 RemoveAllServers(wxLIST_STATE_SELECTED
);
590 void CServerListCtrl::OnKeyPressed( wxKeyEvent
& event
)
592 // Check if delete was pressed
593 if ((event
.GetKeyCode() == WXK_DELETE
) || (event
.GetKeyCode() == WXK_NUMPAD_DELETE
)) {
595 evt
.SetId( MP_REMOVE
);
596 OnRemoveServers( evt
);
603 int CServerListCtrl::SortProc(wxUIntPtr item1
, wxUIntPtr item2
, long sortData
)
605 CServer
* server1
= (CServer
*)item1
;
606 CServer
* server2
= (CServer
*)item2
;
608 int mode
= (sortData
& CMuleListCtrl::SORT_DES
) ? -1 : 1;
610 switch (sortData
& CMuleListCtrl::COLUMN_MASK
) {
611 // Sort by server-name
612 case COLUMN_SERVER_NAME
:
613 return mode
* server1
->GetListName().CmpNoCase(server2
->GetListName());
616 case COLUMN_SERVER_ADDR
:
618 if ( server1
->HasDynIP() && server2
->HasDynIP()) {
619 return mode
* server1
->GetDynIP().CmpNoCase( server2
->GetDynIP() );
620 } else if (server1
->HasDynIP()) {
622 } else if (server2
->HasDynIP()) {
625 uint32 a
= wxUINT32_SWAP_ALWAYS(server1
->GetIP());
626 uint32 b
= wxUINT32_SWAP_ALWAYS(server2
->GetIP());
627 return mode
* CmpAny(a
, b
);
631 case COLUMN_SERVER_PORT
: return mode
* CmpAny( server1
->GetPort(), server2
->GetPort() );
632 // Sort by description
633 case COLUMN_SERVER_DESC
: return mode
* server1
->GetDescription().CmpNoCase( server2
->GetDescription() );
635 // The -1 ensures that a value of zero (no ping known) is sorted last.
636 case COLUMN_SERVER_PING
: return mode
* CmpAny( server1
->GetPing() - 1, server2
->GetPing() -1 );
637 // Sort by user-count
638 case COLUMN_SERVER_USERS
: return mode
* CmpAny( server1
->GetUsers(), server2
->GetUsers() );
639 // Sort by file-count
640 case COLUMN_SERVER_FILES
: return mode
* CmpAny( server1
->GetFiles(), server2
->GetFiles() );
642 case COLUMN_SERVER_PRIO
:
644 uint32 srv_pr1
= server1
->GetPreferences();
645 uint32 srv_pr2
= server2
->GetPreferences();
647 case SRV_PR_HIGH
: srv_pr1
= SRV_PR_MAX
; break;
648 case SRV_PR_NORMAL
: srv_pr1
= SRV_PR_MID
; break;
649 case SRV_PR_LOW
: srv_pr1
= SRV_PR_MIN
; break;
653 case SRV_PR_HIGH
: srv_pr2
= SRV_PR_MAX
; break;
654 case SRV_PR_NORMAL
: srv_pr2
= SRV_PR_MID
; break;
655 case SRV_PR_LOW
: srv_pr2
= SRV_PR_MIN
; break;
658 return mode
* CmpAny( srv_pr1
, srv_pr2
);
660 // Sort by failure-count
661 case COLUMN_SERVER_FAILS
: return mode
* CmpAny( server1
->GetFailedCount(), server2
->GetFailedCount() );
662 // Sort by static servers
663 case COLUMN_SERVER_STATIC
:
665 return mode
* CmpAny( server2
->IsStaticMember(), server1
->IsStaticMember() );
668 case COLUMN_SERVER_VERSION
: return mode
* FuzzyStrCmp(server1
->GetVersion(), server2
->GetVersion());
674 // File_checked_for_headers