Upstream tarball 20080405
[amule.git] / src / kademlia / kademlia / Prefs.h
blobca3e4818d8cb6ce5fed81ecfbf85903f26286cad
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2008 Angel Vidal (Kry) ( kry@amule.org )
5 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2003 Barry Dunne (http://www.emule-project.net)
7 //
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 // Note To Mods //
29 Please do not change anything here and release it..
30 There is going to be a new forum created just for the Kademlia side of the client..
31 If you feel there is an error or a way to improve something, please
32 post it in the forum first and let us look at it.. If it is a real improvement,
33 it will be added to the offical client.. Changing something without knowing
34 what all it does can cause great harm to the network if released in mass form..
35 Any mod that changes anything within the Kademlia side will not be allowed to advertise
36 there client on the eMule forum..
39 #ifndef __PREFS_H__
40 #define __PREFS_H__
42 #include "../utils/UInt128.h"
43 #include <time.h>
45 ////////////////////////////////////////
46 namespace Kademlia {
47 ////////////////////////////////////////
49 class CPrefs
51 public:
52 CPrefs();
53 ~CPrefs();
55 void SetKadID(const CUInt128 &id) {m_clientID = id;}
56 const CUInt128& GetKadID() const {return m_clientID;}
58 void SetClientHash(const CUInt128 &id) {m_clientHash = id;}
59 const CUInt128& GetClientHash() const {return m_clientHash;}
61 uint32 GetIPAddress() const {return m_ip;}
62 void SetIPAddress(uint32 val);
64 bool GetRecheckIP() const {return (m_recheckip<4);}
65 void SetRecheckIP() {m_recheckip = 0; SetFirewalled();}
66 void IncRecheckIP() {m_recheckip++;}
68 bool HasHadContact() const;
69 void SetLastContact() {m_lastContact = time(NULL);}
70 bool HasLostConnection() const;
71 uint32 GetLastContact() const {return m_lastContact;}
73 bool GetFirewalled() const;
74 void SetFirewalled();
75 void IncFirewalled();
77 uint8 GetTotalFile() const {return m_totalFile;}
78 void SetTotalFile(uint8 val) {m_totalFile = val;}
80 uint8 GetTotalStoreSrc() const {return m_totalStoreSrc;}
81 void SetTotalStoreSrc(uint8 val) {m_totalStoreSrc = val;}
83 uint8 GetTotalStoreKey() const {return m_totalStoreKey;}
84 void SetTotalStoreKey(uint8 val) {m_totalStoreKey = val;}
86 uint8 GetTotalSource() const {return m_totalSource;}
87 void SetTotalSource(uint8 val) {m_totalSource = val;}
89 uint8 GetTotalNotes() const {return m_totalNotes;}
90 void SetTotalNotes(uint8 val) {m_totalNotes = val;}
92 uint8 GetTotalStoreNotes() const {return m_totalStoreNotes;}
93 void SetTotalStoreNotes(uint8 val) {m_totalStoreNotes = val;}
95 uint32 GetKademliaUsers() const {return m_kademliaUsers;}
96 void SetKademliaUsers(uint32 val) {m_kademliaUsers = val;}
98 size_t GetKademliaFiles() const {return m_kademliaFiles;}
99 void SetKademliaFiles();
101 bool GetPublish() const {return m_Publish;}
102 void SetPublish(bool val) {m_Publish = val;}
104 bool GetFindBuddy();
105 void SetFindBuddy(bool val = true) {m_findBuddy = val;}
107 private:
108 wxString m_filename;
110 time_t m_lastContact;
111 CUInt128 m_clientID;
112 CUInt128 m_clientHash;
113 uint32 m_ip;
114 uint32 m_ipLast;
115 uint32 m_recheckip;
116 uint32 m_firewalled;
117 uint32 m_kademliaUsers;
118 size_t m_kademliaFiles;
119 uint8 m_totalFile;
120 uint8 m_totalStoreSrc;
121 uint8 m_totalStoreKey;
122 uint8 m_totalSource;
123 uint8 m_totalNotes;
124 uint8 m_totalStoreNotes;
125 bool m_Publish;
126 bool m_findBuddy;
127 bool m_lastFirewallState;
129 void Init(const wxString& filename);
130 void Reset();
131 void SetDefaults();
132 void ReadFile();
133 void WriteFile();
136 } // End namespace
138 #endif //__PREFS_H__
139 // File_checked_for_headers