Upstream tarball 9613
[amule.git] / src / Preferences.h
blob52b617a88b99a096b107219d40eb7acadb1f553b
1 //
2 // This file is part of the aMule Project.
3 //
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 )
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.
20 //
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 PREFERENCES_H
27 #define PREFERENCES_H
29 #include "MD4Hash.h" // Needed for CMD4Hash
31 #include <wx/arrstr.h> // Needed for wxArrayString
33 #include <map>
35 #include "Proxy.h"
36 #include "OtherStructs.h"
38 class CPreferences;
39 class wxConfigBase;
40 class wxWindow;
42 enum EViewSharedFilesAccess{
43 vsfaEverybody = 0,
44 vsfaFriends = 1,
45 vsfaNobody = 2
48 /**
49 * Base-class for automatically loading and saving of preferences.
51 * The purpose of this class is to perform two tasks:
52 * 1) To load and save a variable using wxConfig
53 * 2) If nescecarry, to syncronize it with a widget
55 * This pure-virtual class servers as the base of all the Cfg types
56 * defined below, and exposes the entire interface.
58 * Please note that for reasons of simplicity these classes dont provide
59 * direct access to the variables they maintain, as there is no real need
60 * for this.
62 * To create a sub-class you need only provide the Load/Save functionality,
63 * as it is given that not all variables have a widget assosiated.
65 class Cfg_Base
67 public:
68 /**
69 * Constructor.
71 * @param keyname This is the keyname under which the variable is to be saved.
73 Cfg_Base( const wxString& keyname )
74 : m_key( keyname ),
75 m_changed( false )
78 /**
79 * Destructor.
81 virtual ~Cfg_Base() {}
83 /**
84 * This function loads the assosiated variable from the provided config object.
86 virtual void LoadFromFile(wxConfigBase* cfg) = 0;
87 /**
88 * This function saves the assosiated variable to the provided config object.
90 virtual void SaveToFile(wxConfigBase* cfg) = 0;
92 /**
93 * Syncs the variable with the contents of the widget.
95 * @return True of success, false otherwise.
97 virtual bool TransferFromWindow() { return false; }
98 /**
99 * Syncs the widget with the contents of the variable.
101 * @return True of success, false otherwise.
103 virtual bool TransferToWindow() { return false; }
106 * Connects a widget with the specified ID to the Cfg object.
108 * @param id The ID of the widget.
109 * @param parent A pointer to the widgets parent, to speed up searches.
110 * @return True on success, false otherwise.
112 * This function only makes sense for Cfg-classes that have the capability
113 * to interact with a widget, see Cfg_Tmpl::ConnectToWidget().
115 virtual bool ConnectToWidget( int WXUNUSED(id), wxWindow* WXUNUSED(parent) = NULL ) { return false; }
118 * Gets the key assosiated with Cfg object.
120 * @return The config-key of this object.
122 virtual const wxString& GetKey() { return m_key; }
126 * Specifies if the variable has changed since the TransferFromWindow() call.
128 * @return True if the variable has changed, false otherwise.
130 virtual bool HasChanged() { return m_changed; }
133 protected:
135 * Sets the changed status.
137 * @param changed The new status.
139 virtual void SetChanged( bool changed )
141 m_changed = changed;
144 private:
146 //! The Config-key under which to save the variable
147 wxString m_key;
149 //! The changed-status of the variable
150 bool m_changed;
155 const int cntStatColors = 15;
158 //! This typedef is a shortcut similar to the theApp shortcut, but uses :: instead of .
159 //! It only allows access to static preference functions, however this is to be desired anyway.
160 typedef CPreferences thePrefs;
163 class CPreferences
165 public:
166 friend class PrefsUnifiedDlg;
168 CPreferences();
169 ~CPreferences();
171 void Save();
172 void SaveCats();
173 void ReloadSharedFolders();
175 static bool Score() { return s_scorsystem; }
176 static void SetScoreSystem(bool val) { s_scorsystem = val; }
177 static bool Reconnect() { return s_reconnect; }
178 static void SetReconnect(bool val) { s_reconnect = val; }
179 static bool DeadServer() { return s_deadserver; }
180 static void SetDeadServer(bool val) { s_deadserver = val; }
181 static const wxString& GetUserNick() { return s_nick; }
182 static void SetUserNick(const wxString& nick) { s_nick = nick; }
184 static const wxString& GetAddress() { return s_Addr; }
185 static uint16 GetPort() { return s_port; }
186 static void SetPort(uint16 val);
187 static uint16 GetUDPPort() { return s_udpport; }
188 static uint16 GetEffectiveUDPPort() { return s_UDPEnable ? s_udpport : 0; }
189 static void SetUDPPort(uint16 val) { s_udpport = val; }
190 static bool IsUDPDisabled() { return !s_UDPEnable; }
191 static void SetUDPDisable(bool val) { s_UDPEnable = !val; }
192 static const CPath& GetIncomingDir() { return s_incomingdir; }
193 static void SetIncomingDir(const CPath& dir){ s_incomingdir = dir; }
194 static const CPath& GetTempDir() { return s_tempdir; }
195 static void SetTempDir(const CPath& dir) { s_tempdir = dir; }
196 static const CMD4Hash& GetUserHash() { return s_userhash; }
197 static void SetUserHash(const CMD4Hash& h) { s_userhash = h; }
198 static uint16 GetMaxUpload() { return s_maxupload; }
199 static uint16 GetSlotAllocation() { return s_slotallocation; }
200 static bool IsICHEnabled() { return s_ICH; }
201 static void SetICHEnabled(bool val) { s_ICH = val; }
202 static bool IsTrustingEveryHash() { return s_AICHTrustEveryHash; }
203 static void SetTrustingEveryHash(bool val) { s_AICHTrustEveryHash = val; }
204 static bool AutoServerlist() { return s_autoserverlist; }
205 static void SetAutoServerlist(bool val) { s_autoserverlist = val; }
206 static bool DoMinToTray() { return s_mintotray; }
207 static void SetMinToTray(bool val) { s_mintotray = val; }
208 static bool UseTrayIcon() { return s_trayiconenabled; }
209 static void SetUseTrayIcon(bool val) { s_trayiconenabled = val; }
210 static bool DoAutoConnect() { return s_autoconnect; }
211 static void SetAutoConnect(bool inautoconnect)
212 {s_autoconnect = inautoconnect; }
213 static bool AddServersFromServer() { return s_addserversfromserver; }
214 static void SetAddServersFromServer(bool val) { s_addserversfromserver = val; }
215 static bool AddServersFromClient() { return s_addserversfromclient; }
216 static void SetAddServersFromClient(bool val) { s_addserversfromclient = val; }
217 static uint16 GetTrafficOMeterInterval() { return s_trafficOMeterInterval; }
218 static void SetTrafficOMeterInterval(uint16 in)
219 { s_trafficOMeterInterval = in; }
220 static uint16 GetStatsInterval() { return s_statsInterval;}
221 static void SetStatsInterval(uint16 in) { s_statsInterval = in; }
222 static void Add2TotalDownloaded(uint64 in) { s_totalDownloadedBytes += in; }
223 static void Add2TotalUploaded(uint64 in) { s_totalUploadedBytes += in; }
224 static uint64 GetTotalDownloaded() { return s_totalDownloadedBytes; }
225 static uint64 GetTotalUploaded() { return s_totalUploadedBytes; }
226 static bool IsConfirmExitEnabled() { return s_confirmExit; }
227 static bool FilterLanIPs() { return s_filterLanIP; }
228 static void SetFilterLanIPs(bool val) { s_filterLanIP = val; }
229 static bool ParanoidFilter() { return s_paranoidfilter; }
230 static void SetParanoidFilter(bool val) { s_paranoidfilter = val; }
231 static bool IsOnlineSignatureEnabled() { return s_onlineSig; }
232 static void SetOnlineSignatureEnabled(bool val) { s_onlineSig = val; }
233 static uint32 GetMaxGraphUploadRate() { return s_maxGraphUploadRate; }
234 static uint32 GetMaxGraphDownloadRate() { return s_maxGraphDownloadRate; }
235 static void SetMaxGraphUploadRate(uint32 in){ s_maxGraphUploadRate=in; }
236 static void SetMaxGraphDownloadRate(uint32 in)
237 { s_maxGraphDownloadRate = in; }
239 static uint16 GetMaxDownload() { return s_maxdownload; }
240 static uint16 GetMaxConnections() { return s_maxconnections; }
241 static uint16 GetMaxSourcePerFile() { return s_maxsourceperfile; }
242 static uint16 GetMaxSourcePerFileSoft() {
243 uint16 temp = (uint16)(s_maxsourceperfile*0.9);
244 if( temp > 1000 ) return 1000;
245 return temp; }
246 static uint16 GetMaxSourcePerFileUDP() {
247 uint16 temp = (uint16)(s_maxsourceperfile*0.75);
248 if( temp > 100 ) return 100;
249 return temp; }
250 static uint16 GetDeadserverRetries() { return s_deadserverretries; }
251 static void SetDeadserverRetries(uint16 val) { s_deadserverretries = val; }
252 static uint32 GetServerKeepAliveTimeout() { return s_dwServerKeepAliveTimeoutMins*60000; }
253 static void SetServerKeepAliveTimeout(uint32 val) { s_dwServerKeepAliveTimeoutMins = val/60000; }
255 static const wxString& GetLanguageID() { return s_languageID; }
256 static void SetLanguageID(const wxString& new_id) { s_languageID = new_id; }
257 static uint8 CanSeeShares() { return s_iSeeShares; }
258 static void SetCanSeeShares(uint8 val) { s_iSeeShares = val; }
260 static uint8 GetStatsMax() { return s_statsMax; }
261 static bool UseFlatBar() { return (s_depth3D==0); }
262 static uint8 GetStatsAverageMinutes() { return s_statsAverageMinutes; }
263 static void SetStatsAverageMinutes(uint8 in){ s_statsAverageMinutes = in; }
265 static bool GetStartMinimized() { return s_startMinimized; }
266 static void SetStartMinimized(bool instartMinimized)
267 { s_startMinimized = instartMinimized;}
268 static bool GetSmartIdCheck() { return s_smartidcheck; }
269 static void SetSmartIdCheck( bool in_smartidcheck )
270 { s_smartidcheck = in_smartidcheck; }
271 static uint8 GetSmartIdState() { return s_smartidstate; }
272 static void SetSmartIdState( uint8 in_smartidstate )
273 { s_smartidstate = in_smartidstate; }
274 static bool GetVerbose() { return s_bVerbose; }
275 static void SetVerbose(bool val) { s_bVerbose = val; }
276 static bool GetPreviewPrio() { return s_bpreviewprio; }
277 static void SetPreviewPrio(bool in) { s_bpreviewprio = in; }
278 static bool TransferFullChunks() { return s_btransferfullchunks; }
279 static void SetTransferFullChunks( bool m_bintransferfullchunks )
280 {s_btransferfullchunks = m_bintransferfullchunks; }
281 static bool StartNextFile() { return s_bstartnextfile; }
282 static bool StartNextFileSame() { return s_bstartnextfilesame; }
283 static void SetStartNextFile(bool val) { s_bstartnextfile = val; }
284 static void SetStartNextFileSame(bool val) { s_bstartnextfilesame = val; }
285 static bool ShowOverhead() { return s_bshowoverhead; }
286 static void SetNewAutoUp(bool m_bInUAP) { s_bUAP = m_bInUAP; }
287 static bool GetNewAutoUp() { return s_bUAP; }
288 static void SetNewAutoDown(bool m_bInDAP) { s_bDAP = m_bInDAP; }
289 static bool GetNewAutoDown() { return s_bDAP; }
291 static const wxString& GetVideoPlayer() { return s_VideoPlayer; }
293 static uint32 GetFileBufferSize() { return s_iFileBufferSize*15000; }
294 static void SetFileBufferSize(uint32 val) { s_iFileBufferSize = val/15000; }
295 static uint32 GetQueueSize() { return s_iQueueSize*100; }
296 static void SetQueueSize(uint32 val) { s_iQueueSize = val/100; }
298 static uint8 Get3DDepth() { return s_depth3D;}
299 static bool AddNewFilesPaused() { return s_addnewfilespaused; }
300 static void SetAddNewFilesPaused(bool val) { s_addnewfilespaused = val; }
302 static void SetMaxConsPerFive(int in) { s_MaxConperFive=in; }
304 static uint16 GetMaxConperFive() { return s_MaxConperFive; }
305 static uint16 GetDefaultMaxConperFive();
307 static bool IsSafeServerConnectEnabled() { return s_safeServerConnect; }
308 static void SetSafeServerConnectEnabled(bool val) { s_safeServerConnect = val; }
309 static bool IsMoviePreviewBackup() { return s_moviePreviewBackup; }
311 static bool IsCheckDiskspaceEnabled() { return s_checkDiskspace; }
312 static void SetCheckDiskspaceEnabled(bool val) { s_checkDiskspace = val; }
313 static uint32 GetMinFreeDiskSpaceMB() { return s_uMinFreeDiskSpace; }
314 static uint64 GetMinFreeDiskSpace() { return s_uMinFreeDiskSpace * 1048576ull; }
315 static void SetMinFreeDiskSpaceMB(uint32 val) { s_uMinFreeDiskSpace = val; }
317 static const wxString& GetYourHostname() { return s_yourHostname; }
318 static void SetYourHostname(const wxString& s) { s_yourHostname = s; }
320 static void SetMaxUpload(uint16 in);
321 static void SetMaxDownload(uint16 in);
322 static void SetSlotAllocation(uint16 in) { s_slotallocation = in; };
324 typedef std::vector<CPath> PathList;
325 PathList shareddir_list;
327 wxArrayString adresses_list;
329 static bool AutoConnectStaticOnly() { return s_autoconnectstaticonly; }
330 static void SetAutoConnectStaticOnly(bool val) { s_autoconnectstaticonly = val; }
331 static bool GetUPnPEnabled() { return s_UPnPEnabled; }
332 static void SetUPnPEnabled(bool val) { s_UPnPEnabled = val; }
333 static bool GetUPnPECEnabled() { return s_UPnPECEnabled; }
334 static void SetUPnPECEnabled(bool val) { s_UPnPECEnabled = val; }
335 static bool GetUPnPWebServerEnabled() { return s_UPnPWebServerEnabled; }
336 static void SetUPnPWebServerEnabled(bool val){ s_UPnPWebServerEnabled = val; }
337 static uint16 GetUPnPTCPPort() { return s_UPnPTCPPort; }
338 static void SetUPnPTCPPort(uint16 val) { s_UPnPTCPPort = val; }
339 static bool IsManualHighPrio() { return s_bmanualhighprio; }
340 static void SetManualHighPrio(bool val) { s_bmanualhighprio = val; }
341 void LoadCats();
342 static const wxString& GetDateTimeFormat() { return s_datetimeformat; }
343 // Download Categories
344 uint32 AddCat(Category_Struct* cat);
345 void RemoveCat(size_t index);
346 uint32 GetCatCount();
347 Category_Struct* GetCategory(size_t index);
348 const CPath& GetCatPath(uint8 index);
349 uint32 GetCatColor(size_t index);
350 Category_Struct *CreateCategory(const wxString& name, const CPath& path,
351 const wxString& comment, uint32 color, uint8 prio);
352 void UpdateCategory(uint8 cat, const wxString& name, const CPath& path,
353 const wxString& comment, uint32 color, uint8 prio);
355 static uint32 GetAllcatType() { return s_allcatType; }
356 static void SetAllcatType(uint32 in) { s_allcatType = in; }
357 static bool ShowAllNotCats() { return s_showAllNotCats; }
359 // WebServer
360 static uint16 GetWSPort() { return s_nWebPort; }
361 static void SetWSPort(uint16 uPort) { s_nWebPort=uPort; }
362 static uint16 GetWebUPnPTCPPort() { return s_nWebUPnPTCPPort; }
363 static void SetWebUPnPTCPPort(uint16 val) { s_nWebUPnPTCPPort = val; }
364 static const wxString& GetWSPass() { return s_sWebPassword; }
365 static void SetWSPass(const wxString& pass) { s_sWebPassword = pass; }
366 static bool GetWSIsEnabled() { return s_bWebEnabled; }
367 static void SetWSIsEnabled(bool bEnable) { s_bWebEnabled=bEnable; }
368 static bool GetWebUseGzip() { return s_bWebUseGzip; }
369 static void SetWebUseGzip(bool bUse) { s_bWebUseGzip=bUse; }
370 static uint32 GetWebPageRefresh() { return s_nWebPageRefresh; }
371 static void SetWebPageRefresh(uint32 nRefresh) { s_nWebPageRefresh=nRefresh; }
372 static bool GetWSIsLowUserEnabled() { return s_bWebLowEnabled; }
373 static void SetWSIsLowUserEnabled(bool in) { s_bWebLowEnabled=in; }
374 static const wxString& GetWSLowPass() { return s_sWebLowPassword; }
375 static void SetWSLowPass(const wxString& pass) { s_sWebLowPassword = pass; }
376 static const wxString& GetWebTemplate() { return s_WebTemplate; }
377 static void SetWebTemplate(const wxString& val) { s_WebTemplate = val; }
379 static void SetMaxSourcesPerFile(uint16 in) { s_maxsourceperfile=in;}
380 static void SetMaxConnections(uint16 in) { s_maxconnections =in;}
382 static bool ShowCatTabInfos() { return s_showCatTabInfos; }
383 static void ShowCatTabInfos(bool in) { s_showCatTabInfos=in; }
385 // Sources Dropping Tweaks
386 static bool DropNoNeededSources() { return s_NoNeededSources > 0; }
387 static bool SwapNoNeededSources() { return s_NoNeededSources == 2; }
388 static uint8 GetNoNeededSources() { return s_NoNeededSources; }
389 static void SetNoNeededSources(uint8 val) { s_NoNeededSources = val; }
390 static bool DropFullQueueSources() { return s_DropFullQueueSources; }
391 static void SetDropFullQueueSources(bool val) { s_DropFullQueueSources = val; }
392 static bool DropHighQueueRankingSources() { return s_DropHighQueueRankingSources; }
393 static void SetDropHighQueueRankingSources(bool val) { s_DropHighQueueRankingSources = val; }
394 static uint32 HighQueueRanking() { return s_HighQueueRanking; }
395 static void SetHighQueueRanking(uint32 val) { s_HighQueueRanking = val; }
396 static uint32 GetAutoDropTimer() { return s_AutoDropTimer; }
397 static void SetAutoDropTimer(uint32 val) { s_AutoDropTimer = val; }
399 // External Connections
400 static bool AcceptExternalConnections() { return s_AcceptExternalConnections; }
401 static void EnableExternalConnections( bool val ) { s_AcceptExternalConnections = val; }
402 static const wxString& GetECAddress() { return s_ECAddr; }
403 static uint32 ECPort() { return s_ECPort; }
404 static void SetECPort(uint32 val) { s_ECPort = val; }
405 static const wxString& ECPassword() { return s_ECPassword; }
406 static void SetECPass(const wxString& pass) { s_ECPassword = pass; }
407 // Fast ED2K Links Handler Toggling
408 static bool GetFED2KLH() { return s_FastED2KLinksHandler; }
410 // Ip filter
411 static bool IsFilteringClients() { return s_IPFilterClients; }
412 static void SetFilteringClients(bool val) { s_IPFilterClients = val; }
413 static bool IsFilteringServers() { return s_IPFilterServers; }
414 static void SetFilteringServers(bool val) { s_IPFilterServers = val; }
415 static uint8 GetIPFilterLevel() { return s_filterlevel;}
416 static void SetIPFilterLevel(uint8 level);
417 static bool IPFilterAutoLoad() { return s_IPFilterAutoLoad; }
418 static void SetIPFilterAutoLoad(bool val) { s_IPFilterAutoLoad = val; }
419 static const wxString& IPFilterURL() { return s_IPFilterURL; }
420 static void SetIPFilterURL(const wxString& url) { s_IPFilterURL = url; }
421 static bool UseIPFilterSystem() { return s_IPFilterSys; }
422 static void SetIPFilterSystem(bool val) { s_IPFilterSys = val; }
424 // Source seeds On/Off
425 static bool GetSrcSeedsOn() { return s_UseSrcSeeds; }
426 static void SetSrcSeedsOn(bool val) { s_UseSrcSeeds = val; }
428 static bool IsSecureIdentEnabled() { return s_SecIdent; }
429 static void SetSecureIdentEnabled(bool val) { s_SecIdent = val; }
431 static bool GetExtractMetaData() { return s_ExtractMetaData; }
432 static void SetExtractMetaData(bool val) { s_ExtractMetaData = val; }
434 static bool ShowProgBar() { return s_ProgBar; }
435 static bool ShowPercent() { return s_Percent; }
437 static bool GetAllocFullFile() { return s_allocFullFile; };
438 static void SetAllocFullFile(bool val) { s_allocFullFile = val; }
440 static wxString GetBrowser();
442 static const wxString& GetSkin() { return s_Skin; }
444 static bool VerticalToolbar() { return s_ToolbarOrientation; }
446 static const CPath& GetOSDir() { return s_OSDirectory; }
447 static uint16 GetOSUpdate() { return s_OSUpdate; }
449 static uint8 GetToolTipDelay() { return s_iToolDelayTime; }
451 static void UnsetAutoServerStart();
452 static void CheckUlDlRatio();
454 static void BuildItemList( const wxString& appdir );
455 static void EraseItemList();
457 static void LoadAllItems(wxConfigBase* cfg);
458 static void SaveAllItems(wxConfigBase* cfg);
460 static uint8_t GetShowRatesOnTitle() { return s_showRatesOnTitle; }
461 static void SetShowRatesOnTitle(uint8_t val) { s_showRatesOnTitle = val; }
463 // Message Filters
465 static bool MustFilterMessages() { return s_MustFilterMessages; }
466 static void SetMustFilterMessages(bool val) { s_MustFilterMessages = val; }
467 static bool IsFilterAllMessages() { return s_FilterAllMessages; }
468 static void SetFilterAllMessages(bool val) { s_FilterAllMessages = val; }
469 static bool MsgOnlyFriends() { return s_msgonlyfriends;}
470 static void SetMsgOnlyFriends(bool val) { s_msgonlyfriends = val; }
471 static bool MsgOnlySecure() { return s_msgsecure;}
472 static void SetMsgOnlySecure(bool val) { s_msgsecure = val; }
473 static bool IsFilterByKeywords() { return s_FilterSomeMessages; }
474 static void SetFilterByKeywords(bool val) { s_FilterSomeMessages = val; }
475 static const wxString& GetMessageFilterString() { return s_MessageFilterString; }
476 static void SetMessageFilterString(const wxString& val) { s_MessageFilterString = val; }
477 static bool IsMessageFiltered(const wxString& message);
478 static bool ShowMessagesInLog() { return s_ShowMessagesInLog; }
479 static bool IsAdvancedSpamfilterEnabled() { return s_IsAdvancedSpamfilterEnabled;}
480 static bool IsChatCaptchaEnabled() { return IsAdvancedSpamfilterEnabled() && s_IsChatCaptchaEnabled; }
482 static bool FilterComments() { return s_FilterComments; }
483 static void SetFilterComments(bool val) { s_FilterComments = val; }
484 static const wxString& GetCommentFilterString() { return s_CommentFilterString; }
485 static void SetCommentFilterString(const wxString& val) { s_CommentFilterString = val; }
486 static bool IsCommentFiltered(const wxString& comment);
488 // Can't have it return a reference, will need a pointer later.
489 static const CProxyData *GetProxyData() { return &s_ProxyData; }
491 // Hidden files
493 static bool ShareHiddenFiles() { return s_ShareHiddenFiles; }
495 static bool AutoSortDownload() { return s_AutoSortDownload; }
497 // Version check
499 static bool CheckNewVersion() { return s_NewVersionCheck; }
501 // Networks
502 static bool GetNetworkKademlia() { return s_ConnectToKad; }
503 static void SetNetworkKademlia(bool val) { s_ConnectToKad = val; }
504 static bool GetNetworkED2K() { return s_ConnectToED2K; }
505 static void SetNetworkED2K(bool val) { s_ConnectToED2K = val; }
507 // Statistics
508 static unsigned GetMaxClientVersions() { return s_maxClientVersions; }
510 // Dropping slow sources
511 static bool GetDropSlowSources() { return s_DropSlowSources; }
513 // server.met and nodes.dat urls
514 static const wxString& GetKadNodesUrl() { return s_KadURL; }
515 static void SetKadNodesUrl(const wxString& url) { s_KadURL = url; }
517 static const wxString& GetEd2kServersUrl() { return s_Ed2kURL; }
518 static void SetEd2kServersUrl(const wxString& url) { s_Ed2kURL = url; }
520 // Crypt
521 static bool IsClientCryptLayerSupported() {return s_IsClientCryptLayerSupported;}
522 static bool IsClientCryptLayerRequested() {return IsClientCryptLayerSupported() && s_bCryptLayerRequested;}
523 static bool IsClientCryptLayerRequired() {return IsClientCryptLayerRequested() && s_IsClientCryptLayerRequired;}
524 static bool IsClientCryptLayerRequiredStrict() {return false;} // not even incoming test connections will be answered
525 static bool IsServerCryptLayerUDPEnabled() {return IsClientCryptLayerSupported();}
526 static bool IsServerCryptLayerTCPRequested() {return IsClientCryptLayerRequested();}
527 static bool IsServerCryptLayerTCPRequired() {return IsClientCryptLayerRequired();}
528 static uint32 GetKadUDPKey() {return s_dwKadUDPKey;}
529 static uint8 GetCryptTCPPaddingLength() {return s_byCryptTCPPaddingLength;}
531 static void SetClientCryptLayerSupported(bool v) {s_IsClientCryptLayerSupported = v;}
532 static void SetClientCryptLayerRequested(bool v) {s_bCryptLayerRequested = v; }
533 static void SetClientCryptLayerRequired(bool v) {s_IsClientCryptLayerRequired = v;}
535 // GeoIP
536 static bool IsGeoIPEnabled() {return s_GeoIPEnabled;}
537 static void SetGeoIPEnabled(bool v) {s_GeoIPEnabled = v;}
538 static const wxString& GetGeoIPUpdateUrl() {return s_GeoIPUpdateUrl;}
540 protected:
541 static int32 GetRecommendedMaxConnections();
543 //! Temporary storage for statistic-colors.
544 static unsigned long s_colors[cntStatColors];
545 //! Reference for checking if the colors has changed.
546 static unsigned long s_colors_ref[cntStatColors];
548 typedef std::vector<Cfg_Base*> CFGList;
549 typedef std::map<int, Cfg_Base*> CFGMap;
550 typedef std::vector<Category_Struct*> CatList;
553 static CFGMap s_CfgList;
554 static CFGList s_MiscList;
555 CatList m_CatList;
557 private:
558 void LoadPreferences();
559 void SavePreferences();
561 protected:
562 ////////////// USER
563 static wxString s_nick;
565 static CMD4Hash s_userhash;
567 ////////////// CONNECTION
568 static uint16 s_maxupload;
569 static uint16 s_maxdownload;
570 static uint16 s_slotallocation;
571 static wxString s_Addr;
572 static uint16 s_port;
573 static uint16 s_udpport;
574 static bool s_UDPEnable;
575 static uint16 s_maxconnections;
576 static bool s_reconnect;
577 static bool s_autoconnect;
578 static bool s_autoconnectstaticonly;
579 static bool s_UPnPEnabled;
580 static bool s_UPnPECEnabled;
581 static bool s_UPnPWebServerEnabled;
582 static uint16 s_UPnPTCPPort;
584 ////////////// PROXY
585 static CProxyData s_ProxyData;
587 ////////////// SERVERS
588 static bool s_autoserverlist;
589 static bool s_deadserver;
591 ////////////// FILES
592 static CPath s_incomingdir;
593 static CPath s_tempdir;
594 static bool s_ICH;
595 static bool s_AICHTrustEveryHash;
597 ////////////// GUI
598 static uint8 s_depth3D;
600 static bool s_scorsystem;
601 static bool s_mintotray;
602 static bool s_trayiconenabled;
603 static bool s_addnewfilespaused;
604 static bool s_addserversfromserver;
605 static bool s_addserversfromclient;
606 static uint16 s_maxsourceperfile;
607 static uint16 s_trafficOMeterInterval;
608 static uint16 s_statsInterval;
609 static uint32 s_maxGraphDownloadRate;
610 static uint32 s_maxGraphUploadRate;
611 static bool s_confirmExit;
614 static bool s_filterLanIP;
615 static bool s_paranoidfilter;
616 static bool s_onlineSig;
618 static uint64 s_totalDownloadedBytes;
619 static uint64 s_totalUploadedBytes;
620 static wxString s_languageID;
621 static uint8 s_iSeeShares; // 0=everybody 1=friends only 2=noone
622 static uint8 s_iToolDelayTime; // tooltip delay time in seconds
623 static uint8 s_splitterbarPosition;
624 static uint16 s_deadserverretries;
625 static uint32 s_dwServerKeepAliveTimeoutMins;
627 static uint8 s_statsMax;
628 static uint8 s_statsAverageMinutes;
630 static bool s_bpreviewprio;
631 static bool s_smartidcheck;
632 static uint8 s_smartidstate;
633 static bool s_safeServerConnect;
634 static bool s_startMinimized;
635 static uint16 s_MaxConperFive;
636 static bool s_checkDiskspace;
637 static uint32 s_uMinFreeDiskSpace;
638 static wxString s_yourHostname;
639 static bool s_bVerbose;
640 static bool s_bmanualhighprio;
641 static bool s_btransferfullchunks;
642 static bool s_bstartnextfile;
643 static bool s_bstartnextfilesame;
644 static bool s_bshowoverhead;
645 static bool s_bDAP;
646 static bool s_bUAP;
648 static uint8_t s_showRatesOnTitle; // 0=no, 1=after app name, 2=before app name
650 static wxString s_VideoPlayer;
651 static bool s_moviePreviewBackup;
652 static bool s_showAllNotCats;
654 static bool s_msgonlyfriends;
655 static bool s_msgsecure;
657 static uint8 s_iFileBufferSize;
658 static uint8 s_iQueueSize;
660 static wxString s_datetimeformat;
662 static bool s_ToolbarOrientation;
664 // Web Server [kuchin]
665 static wxString s_sWebPassword;
666 static wxString s_sWebLowPassword;
667 static uint16 s_nWebPort;
668 static uint16 s_nWebUPnPTCPPort;
669 static bool s_bWebEnabled;
670 static bool s_bWebUseGzip;
671 static uint32 s_nWebPageRefresh;
672 static bool s_bWebLowEnabled;
673 static wxString s_WebTemplate;
675 static bool s_showCatTabInfos;
676 static uint32 s_allcatType;
678 // Madcat - Sources Dropping Tweaks
679 static uint8 s_NoNeededSources; // 0: Keep, 1: Drop, 2:Swap
680 static bool s_DropFullQueueSources;
681 static bool s_DropHighQueueRankingSources;
682 static uint32 s_HighQueueRanking;
683 static uint32 s_AutoDropTimer;
685 // Kry - external connections
686 static bool s_AcceptExternalConnections;
687 static wxString s_ECAddr;
688 static uint32 s_ECPort;
689 static wxString s_ECPassword;
691 // Kry - IPFilter
692 static bool s_IPFilterClients;
693 static bool s_IPFilterServers;
694 static uint8 s_filterlevel;
695 static bool s_IPFilterAutoLoad;
696 static wxString s_IPFilterURL;
697 static bool s_IPFilterSys;
699 // Kry - Source seeds on/off
700 static bool s_UseSrcSeeds;
702 static bool s_ProgBar;
703 static bool s_Percent;
705 static bool s_SecIdent;
707 static bool s_ExtractMetaData;
709 static bool s_allocFullFile;
711 static wxString s_CustomBrowser;
712 static bool s_BrowserTab; // Jacobo221 - Open in tabs if possible
714 static CPath s_OSDirectory;
715 static uint16 s_OSUpdate;
717 static wxString s_Skin;
719 static bool s_FastED2KLinksHandler; // Madcat - Toggle Fast ED2K Links Handler
721 // Message Filtering
722 static bool s_MustFilterMessages;
723 static wxString s_MessageFilterString;
724 static bool s_FilterAllMessages;
725 static bool s_FilterSomeMessages;
726 static bool s_ShowMessagesInLog;
727 static bool s_IsAdvancedSpamfilterEnabled;
728 static bool s_IsChatCaptchaEnabled;
730 static bool s_FilterComments;
731 static wxString s_CommentFilterString;
734 // Hidden files sharing
735 static bool s_ShareHiddenFiles;
737 static bool s_AutoSortDownload;
739 // Version check
740 static bool s_NewVersionCheck;
742 // Kad
743 static bool s_ConnectToKad;
744 static bool s_ConnectToED2K;
746 // Statistics
747 static unsigned s_maxClientVersions; // 0 = unlimited
749 // Drop slow sources if needed
750 static bool s_DropSlowSources;
752 static wxString s_Ed2kURL;
753 static wxString s_KadURL;
755 // Crypt
756 static bool s_IsClientCryptLayerSupported;
757 static bool s_IsClientCryptLayerRequired;
758 static bool s_bCryptLayerRequested;
759 static uint32 s_dwKadUDPKey;
760 static uint8 s_byCryptTCPPaddingLength;
762 // GeoIP
763 static bool s_GeoIPEnabled;
764 static wxString s_GeoIPUpdateUrl;
768 #endif // PREFERENCES_H
769 // File_checked_for_headers