Upstream tarball 20080928
[amule.git] / src / Preferences.h
blobc5b531b38a10231fcef2f944f1b092948bacc8c9
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; }
480 static bool FilterComments() { return s_FilterComments; }
481 static void SetFilterComments(bool val) { s_FilterComments = val; }
482 static const wxString& GetCommentFilterString() { return s_CommentFilterString; }
483 static void SetCommentFilterString(const wxString& val) { s_CommentFilterString = val; }
484 static bool IsCommentFiltered(const wxString& comment);
486 // Can't have it return a reference, will need a pointer later.
487 static const CProxyData *GetProxyData() { return &s_ProxyData; }
489 // Hidden files
491 static bool ShareHiddenFiles() { return s_ShareHiddenFiles; }
493 static bool AutoSortDownload() { return s_AutoSortDownload; }
495 // Version check
497 static bool CheckNewVersion() { return s_NewVersionCheck; }
499 // Networks
500 static bool GetNetworkKademlia() { return s_ConnectToKad; }
501 static void SetNetworkKademlia(bool val) { s_ConnectToKad = val; }
502 static bool GetNetworkED2K() { return s_ConnectToED2K; }
503 static void SetNetworkED2K(bool val) { s_ConnectToED2K = val; }
505 // Statistics
506 static unsigned GetMaxClientVersions() { return s_maxClientVersions; }
508 // Dropping slow sources
509 static bool GetDropSlowSources() { return s_DropSlowSources; }
511 // server.met and nodes.dat urls
512 static const wxString& GetKadNodesUrl() { return s_KadURL; }
513 static void SetKadNodesUrl(const wxString& url) { s_KadURL = url; }
515 static const wxString& GetEd2kServersUrl() { return s_Ed2kURL; }
516 static void SetEd2kServersUrl(const wxString& url) { s_Ed2kURL = url; }
518 // Crypt
519 static bool IsClientCryptLayerSupported() {return s_IsClientCryptLayerSupported;}
520 static bool IsClientCryptLayerRequested() {return IsClientCryptLayerSupported() && s_bCryptLayerRequested;}
521 static bool IsClientCryptLayerRequired() {return IsClientCryptLayerRequested() && s_IsClientCryptLayerRequired;}
522 static bool IsClientCryptLayerRequiredStrict() {return false;} // not even incoming test connections will be answered
523 static bool IsServerCryptLayerUDPEnabled() {return IsClientCryptLayerSupported();}
524 static bool IsServerCryptLayerTCPRequested() {return IsClientCryptLayerRequested();}
525 static bool IsServerCryptLayerTCPRequired() {return IsClientCryptLayerRequired();}
526 static uint32 GetKadUDPKey() {return s_dwKadUDPKey;}
527 static uint8 GetCryptTCPPaddingLength() {return s_byCryptTCPPaddingLength;}
529 static void SetClientCryptLayerSupported(bool v) {s_IsClientCryptLayerSupported = v;}
530 static void SetClientCryptLayerRequested(bool v) {s_bCryptLayerRequested = v; }
531 static void SetClientCryptLayerRequired(bool v) {s_IsClientCryptLayerRequired = v;}
533 // GeoIP
534 static bool IsGeoIPEnabled() {return s_GeoIPEnabled;}
535 static void SetGeoIPEnabled(bool v) {s_GeoIPEnabled = v;}
536 static const wxString& GetGeoIPUpdateUrl() {return s_GeoIPUpdateUrl;}
538 protected:
539 static int32 GetRecommendedMaxConnections();
541 //! Temporary storage for statistic-colors.
542 static unsigned long s_colors[cntStatColors];
543 //! Reference for checking if the colors has changed.
544 static unsigned long s_colors_ref[cntStatColors];
546 typedef std::vector<Cfg_Base*> CFGList;
547 typedef std::map<int, Cfg_Base*> CFGMap;
548 typedef std::vector<Category_Struct*> CatList;
551 static CFGMap s_CfgList;
552 static CFGList s_MiscList;
553 CatList m_CatList;
555 private:
556 void LoadPreferences();
557 void SavePreferences();
559 protected:
560 ////////////// USER
561 static wxString s_nick;
563 static CMD4Hash s_userhash;
565 ////////////// CONNECTION
566 static uint16 s_maxupload;
567 static uint16 s_maxdownload;
568 static uint16 s_slotallocation;
569 static wxString s_Addr;
570 static uint16 s_port;
571 static uint16 s_udpport;
572 static bool s_UDPEnable;
573 static uint16 s_maxconnections;
574 static bool s_reconnect;
575 static bool s_autoconnect;
576 static bool s_autoconnectstaticonly;
577 static bool s_UPnPEnabled;
578 static bool s_UPnPECEnabled;
579 static bool s_UPnPWebServerEnabled;
580 static uint16 s_UPnPTCPPort;
582 ////////////// PROXY
583 static CProxyData s_ProxyData;
585 ////////////// SERVERS
586 static bool s_autoserverlist;
587 static bool s_deadserver;
589 ////////////// FILES
590 static CPath s_incomingdir;
591 static CPath s_tempdir;
592 static bool s_ICH;
593 static bool s_AICHTrustEveryHash;
595 ////////////// GUI
596 static uint8 s_depth3D;
598 static bool s_scorsystem;
599 static bool s_mintotray;
600 static bool s_trayiconenabled;
601 static bool s_addnewfilespaused;
602 static bool s_addserversfromserver;
603 static bool s_addserversfromclient;
604 static uint16 s_maxsourceperfile;
605 static uint16 s_trafficOMeterInterval;
606 static uint16 s_statsInterval;
607 static uint32 s_maxGraphDownloadRate;
608 static uint32 s_maxGraphUploadRate;
609 static bool s_confirmExit;
612 static bool s_filterLanIP;
613 static bool s_paranoidfilter;
614 static bool s_onlineSig;
616 static uint64 s_totalDownloadedBytes;
617 static uint64 s_totalUploadedBytes;
618 static wxString s_languageID;
619 static uint8 s_iSeeShares; // 0=everybody 1=friends only 2=noone
620 static uint8 s_iToolDelayTime; // tooltip delay time in seconds
621 static uint8 s_splitterbarPosition;
622 static uint16 s_deadserverretries;
623 static uint32 s_dwServerKeepAliveTimeoutMins;
625 static uint8 s_statsMax;
626 static uint8 s_statsAverageMinutes;
628 static bool s_bpreviewprio;
629 static bool s_smartidcheck;
630 static uint8 s_smartidstate;
631 static bool s_safeServerConnect;
632 static bool s_startMinimized;
633 static uint16 s_MaxConperFive;
634 static bool s_checkDiskspace;
635 static uint32 s_uMinFreeDiskSpace;
636 static wxString s_yourHostname;
637 static bool s_bVerbose;
638 static bool s_bmanualhighprio;
639 static bool s_btransferfullchunks;
640 static bool s_bstartnextfile;
641 static bool s_bstartnextfilesame;
642 static bool s_bshowoverhead;
643 static bool s_bDAP;
644 static bool s_bUAP;
646 static uint8_t s_showRatesOnTitle; // 0=no, 1=after app name, 2=before app name
648 static wxString s_VideoPlayer;
649 static bool s_moviePreviewBackup;
650 static bool s_showAllNotCats;
652 static bool s_msgonlyfriends;
653 static bool s_msgsecure;
655 static uint8 s_iFileBufferSize;
656 static uint8 s_iQueueSize;
658 static wxString s_datetimeformat;
660 static bool s_ToolbarOrientation;
662 // Web Server [kuchin]
663 static wxString s_sWebPassword;
664 static wxString s_sWebLowPassword;
665 static uint16 s_nWebPort;
666 static uint16 s_nWebUPnPTCPPort;
667 static bool s_bWebEnabled;
668 static bool s_bWebUseGzip;
669 static uint32 s_nWebPageRefresh;
670 static bool s_bWebLowEnabled;
671 static wxString s_WebTemplate;
673 static bool s_showCatTabInfos;
674 static uint32 s_allcatType;
676 // Madcat - Sources Dropping Tweaks
677 static uint8 s_NoNeededSources; // 0: Keep, 1: Drop, 2:Swap
678 static bool s_DropFullQueueSources;
679 static bool s_DropHighQueueRankingSources;
680 static uint32 s_HighQueueRanking;
681 static uint32 s_AutoDropTimer;
683 // Kry - external connections
684 static bool s_AcceptExternalConnections;
685 static wxString s_ECAddr;
686 static uint32 s_ECPort;
687 static wxString s_ECPassword;
689 // Kry - IPFilter
690 static bool s_IPFilterClients;
691 static bool s_IPFilterServers;
692 static uint8 s_filterlevel;
693 static bool s_IPFilterAutoLoad;
694 static wxString s_IPFilterURL;
695 static bool s_IPFilterSys;
697 // Kry - Source seeds on/off
698 static bool s_UseSrcSeeds;
700 static bool s_ProgBar;
701 static bool s_Percent;
703 static bool s_SecIdent;
705 static bool s_ExtractMetaData;
707 static bool s_allocFullFile;
709 static wxString s_CustomBrowser;
710 static bool s_BrowserTab; // Jacobo221 - Open in tabs if possible
712 static CPath s_OSDirectory;
713 static uint16 s_OSUpdate;
715 static wxString s_Skin;
717 static bool s_FastED2KLinksHandler; // Madcat - Toggle Fast ED2K Links Handler
719 // Message Filtering
720 static bool s_MustFilterMessages;
721 static wxString s_MessageFilterString;
722 static bool s_FilterAllMessages;
723 static bool s_FilterSomeMessages;
724 static bool s_ShowMessagesInLog;
726 static bool s_FilterComments;
727 static wxString s_CommentFilterString;
730 // Hidden files sharing
731 static bool s_ShareHiddenFiles;
733 static bool s_AutoSortDownload;
735 // Version check
736 static bool s_NewVersionCheck;
738 // Kad
739 static bool s_ConnectToKad;
740 static bool s_ConnectToED2K;
742 // Statistics
743 static unsigned s_maxClientVersions; // 0 = unlimited
745 // Drop slow sources if needed
746 static bool s_DropSlowSources;
748 static wxString s_Ed2kURL;
749 static wxString s_KadURL;
751 // Crypt
752 static bool s_IsClientCryptLayerSupported;
753 static bool s_IsClientCryptLayerRequired;
754 static bool s_bCryptLayerRequested;
755 static uint32 s_dwKadUDPKey;
756 static uint8 s_byCryptTCPPaddingLength;
758 // GeoIP
759 static bool s_GeoIPEnabled;
760 static wxString s_GeoIPUpdateUrl;
764 #endif // PREFERENCES_H
765 // File_checked_for_headers