Update Wiki URL
[amule.git] / src / ServerList.h
blobb1b7624d6f35a6407ad3a6dd7b507854b1b1d565
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
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
9 // respective authors.
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 #ifndef SERVERLIST_H
27 #define SERVERLIST_H
29 #include "ObservableQueue.h"
31 class CServer;
32 class CPacket;
34 class CServerList : public CObservableQueue<CServer*>
36 friend class CServerListCtrl;
38 public:
39 CServerList();
40 ~CServerList();
41 bool Init();
42 bool AddServer(CServer* in_server, bool fromUser = false);
43 void RemoveServer(CServer* in_server);
44 void RemoveAllServers();
45 void RemoveDeadServers();
46 bool LoadServerMet(const CPath& path);
47 bool SaveServerMet();
48 void ServerStats();
49 void ResetServerPos() {m_serverpos = m_servers.begin();}
50 CServer* GetNextServer(bool bOnlyObfuscated = false);
51 size_t GetServerCount() {return m_servers.size();}
52 CServer* GetServerByAddress(const wxString& address, uint16 port) const;
53 CServer* GetServerByIP(uint32 nIP) const;
54 CServer* GetServerByIPTCP(uint32 nIP, uint16 nPort) const;
55 CServer* GetServerByIPUDP(uint32 nIP, uint16 nUDPPort, bool bObfuscationPorts = true) const;
56 CServer* GetServerByECID(uint32 ecid) const;
57 void GetStatus(uint32 &failed, uint32 &user, uint32 &file, uint32 &tuser, uint32 &tfile, float &occ);
58 void GetUserFileStatus( uint32 &user, uint32 &file);
59 bool IsInitialized() const { return m_initialized; }
60 void Sort();
61 void UpdateServerMetFromURL(const wxString& strURL);
62 bool DownloadFinished(uint32 result);
63 void AutoDownloadFinished(uint32 result);
64 uint32 GetAvgFile() const;
66 std::vector<const CServer*> CopySnapshot() const;
68 /** Refilters all servers though the IPFilter. */
69 void FilterServers();
71 void CheckForExpiredUDPKeys();
73 /**
74 * Marks the specified server as static or not.
76 * @param The server to be marked or unmarked as static.
77 * @param The new static state.
79 * Other than setting the static setting of the specified server, it
80 * also adds or removes the server from the static-list file.
82 void SetStaticServer(CServer* server, bool isStatic);
83 void SetServerPrio(CServer* server, uint32 prio);
85 private:
86 virtual void ObserverAdded( ObserverType* );
87 void AutoUpdate();
88 CServer* GetNextStatServer();
90 wxString m_staticServersConfig;
91 void LoadStaticServers();
92 void SaveStaticServers();
93 uint8 current_url_index;
95 typedef std::list<CServer*> CInternalList;
96 CInternalList m_servers;
97 CInternalList::const_iterator m_serverpos;
98 CInternalList::const_iterator m_statserverpos;
100 uint32 m_nLastED2KServerLinkCheck;// emanuelw(20030924) added
101 wxString m_URLUpdate;
102 bool m_initialized;
105 #endif // SERVERLIST_H
106 // File_checked_for_headers