Upstream tarball 20080304
[amule.git] / src / Preferences.h
blob65b9e82a7fda22063a53757eb62d17c85fe82b58
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 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
30 #include "Color.h" // Needed for COLORREF
32 #include <wx/arrstr.h> // Needed for wxArrayString
33 #include <common/Path.h> // Needed for CPath
35 #include <map>
37 #include "Proxy.h"
39 class CPreferences;
40 class wxConfigBase;
41 class wxWindow;
44 enum EViewSharedFilesAccess{
45 vsfaEverybody = 0,
46 vsfaFriends = 1,
47 vsfaNobody = 2
50 struct Category_Struct
52 CPath path;
53 wxString title;
54 wxString comment;
55 uint32 color;
56 uint8 prio;
60 /**
61 * Base-class for automatically loading and saving of preferences.
63 * The purpose of this class is to perform two tasks:
64 * 1) To load and save a variable using wxConfig
65 * 2) If nescecarry, to syncronize it with a widget
67 * This pure-virtual class servers as the base of all the Cfg types
68 * defined below, and exposes the entire interface.
70 * Please note that for reasons of simplicity these classes dont provide
71 * direct access to the variables they maintain, as there is no real need
72 * for this.
74 * To create a sub-class you need only provide the Load/Save functionality,
75 * as it is given that not all variables have a widget assosiated.
77 class Cfg_Base
79 public:
80 /**
81 * Constructor.
83 * @param keyname This is the keyname under which the variable is to be saved.
85 Cfg_Base( const wxString& keyname )
86 : m_key( keyname ),
87 m_changed( false )
90 /**
91 * Destructor.
93 virtual ~Cfg_Base() {}
95 /**
96 * This function loads the assosiated variable from the provided config object.
98 virtual void LoadFromFile(wxConfigBase* cfg) = 0;
99 /**
100 * This function saves the assosiated variable to the provided config object.
102 virtual void SaveToFile(wxConfigBase* cfg) = 0;
105 * Syncs the variable with the contents of the widget.
107 * @return True of success, false otherwise.
109 virtual bool TransferFromWindow() { return false; }
111 * Syncs the widget with the contents of the variable.
113 * @return True of success, false otherwise.
115 virtual bool TransferToWindow() { return false; }
118 * Connects a widget with the specified ID to the Cfg object.
120 * @param id The ID of the widget.
121 * @param parent A pointer to the widgets parent, to speed up searches.
122 * @return True on success, false otherwise.
124 * This function only makes sense for Cfg-classes that have the capability
125 * to interact with a widget, see Cfg_Tmpl::ConnectToWidget().
127 virtual bool ConnectToWidget( int WXUNUSED(id), wxWindow* WXUNUSED(parent) = NULL ) { return false; }
130 * Gets the key assosiated with Cfg object.
132 * @return The config-key of this object.
134 virtual const wxString& GetKey() { return m_key; }
138 * Specifies if the variable has changed since the TransferFromWindow() call.
140 * @return True if the variable has changed, false otherwise.
142 virtual bool HasChanged() { return m_changed; }
145 protected:
147 * Sets the changed status.
149 * @param changed The new status.
151 virtual void SetChanged( bool changed )
153 m_changed = changed;
156 private:
158 //! The Config-key under which to save the variable
159 wxString m_key;
161 //! The changed-status of the variable
162 bool m_changed;
167 const int cntStatColors = 15;
170 //! This typedef is a shortcut similar to the theApp shortcut, but uses :: instead of .
171 //! It only allows access to static preference functions, however this is to be desired anyway.
172 typedef CPreferences thePrefs;
175 class CPreferences
177 public:
178 friend class PrefsUnifiedDlg;
180 CPreferences();
181 ~CPreferences();
183 void Save();
184 void SaveCats();
185 void ReloadSharedFolders();
187 static bool Score() { return s_scorsystem; }
188 static void SetScoreSystem(bool val) { s_scorsystem = val; }
189 static bool Reconnect() { return s_reconnect; }
190 static void SetReconnect(bool val) { s_reconnect = val; }
191 static bool DeadServer() { return s_deadserver; }
192 static void SetDeadServer(bool val) { s_deadserver = val; }
193 static const wxString& GetUserNick() { return s_nick; }
194 static void SetUserNick(const wxString& nick) { s_nick = nick; }
196 static const wxString& GetAddress() { return s_Addr; }
197 static uint16 GetPort() { return s_port; }
198 static void SetPort(uint16 val);
199 static uint16 GetUDPPort() { return s_udpport; }
200 static uint16 GetEffectiveUDPPort() { return s_UDPDisable ? 0 : s_udpport; }
201 static void SetUDPPort(uint16 val) { s_udpport = val; }
202 static bool IsUDPDisabled() { return s_UDPDisable; }
203 static void SetUDPDisable(bool val) { s_UDPDisable = val; }
204 static const CPath& GetIncomingDir() { return s_incomingdir; }
205 static void SetIncomingDir(const CPath& dir){ s_incomingdir = dir; }
206 static const CPath& GetTempDir() { return s_tempdir; }
207 static void SetTempDir(const CPath& dir) { s_tempdir = dir; }
208 static const CMD4Hash& GetUserHash() { return s_userhash; }
209 static void SetUserHash(const CMD4Hash& h) { s_userhash = h; }
210 static uint16 GetMaxUpload() { return s_maxupload; }
211 static uint16 GetSlotAllocation() { return s_slotallocation; }
212 static bool IsICHEnabled() { return s_ICH; }
213 static void SetICHEnabled(bool val) { s_ICH = val; }
214 static bool IsTrustingEveryHash() { return s_AICHTrustEveryHash; }
215 static void SetTrustingEveryHash(bool val) { s_AICHTrustEveryHash = val; }
216 static bool AutoServerlist() { return s_autoserverlist; }
217 static void SetAutoServerlist(bool val) { s_autoserverlist = val; }
218 static bool DoMinToTray() { return s_mintotray; }
219 static void SetMinToTray(bool val) { s_mintotray = val; }
220 static bool UseTrayIcon() { return s_trayiconenabled; }
221 static void SetUseTrayIcon(bool val) { s_trayiconenabled = val; }
222 static bool DoAutoConnect() { return s_autoconnect; }
223 static void SetAutoConnect(bool inautoconnect)
224 {s_autoconnect = inautoconnect; }
225 static bool AddServersFromServer() { return s_addserversfromserver; }
226 static void SetAddServersFromServer(bool val) { s_addserversfromserver = val; }
227 static bool AddServersFromClient() { return s_addserversfromclient; }
228 static void SetAddServersFromClient(bool val) { s_addserversfromclient = val; }
229 static uint16 GetTrafficOMeterInterval() { return s_trafficOMeterInterval; }
230 static void SetTrafficOMeterInterval(uint16 in)
231 { s_trafficOMeterInterval = in; }
232 static uint16 GetStatsInterval() { return s_statsInterval;}
233 static void SetStatsInterval(uint16 in) { s_statsInterval = in; }
234 static void Add2TotalDownloaded(uint64 in) { s_totalDownloadedBytes += in; }
235 static void Add2TotalUploaded(uint64 in) { s_totalUploadedBytes += in; }
236 static uint64 GetTotalDownloaded() { return s_totalDownloadedBytes; }
237 static uint64 GetTotalUploaded() { return s_totalUploadedBytes; }
238 static bool IsConfirmExitEnabled() { return s_confirmExit; }
239 static bool FilterLanIPs() { return s_filterLanIP; }
240 static void SetFilterLanIPs(bool val) { s_filterLanIP = val; }
241 static bool ParanoidFilter() { return s_paranoidfilter; }
242 static void SetParanoidFilter(bool val) { s_paranoidfilter = val; }
243 static bool IsOnlineSignatureEnabled() { return s_onlineSig; }
244 static void SetOnlineSignatureEnabled(bool val) { s_onlineSig = val; }
245 static uint32 GetMaxGraphUploadRate() { return s_maxGraphUploadRate; }
246 static uint32 GetMaxGraphDownloadRate() { return s_maxGraphDownloadRate; }
247 static void SetMaxGraphUploadRate(uint32 in){ s_maxGraphUploadRate=in; }
248 static void SetMaxGraphDownloadRate(uint32 in)
249 { s_maxGraphDownloadRate = in; }
251 static uint16 GetMaxDownload() { return s_maxdownload; }
252 static uint16 GetMaxConnections() { return s_maxconnections; }
253 static uint16 GetMaxSourcePerFile() { return s_maxsourceperfile; }
254 static uint16 GetMaxSourcePerFileSoft() {
255 uint16 temp = (uint16)(s_maxsourceperfile*0.9);
256 if( temp > 1000 ) return 1000;
257 return temp; }
258 static uint16 GetMaxSourcePerFileUDP() {
259 uint16 temp = (uint16)(s_maxsourceperfile*0.75);
260 if( temp > 100 ) return 100;
261 return temp; }
262 static uint16 GetDeadserverRetries() { return s_deadserverretries; }
263 static void SetDeadserverRetries(uint16 val) { s_deadserverretries = val; }
264 static uint32 GetServerKeepAliveTimeout() { return s_dwServerKeepAliveTimeoutMins*60000; }
265 static void SetServerKeepAliveTimeout(uint32 val) { s_dwServerKeepAliveTimeoutMins = val/60000; }
267 static const wxString& GetLanguageID() { return s_languageID; }
268 static void SetLanguageID(const wxString& new_id) { s_languageID = new_id; }
269 static uint8 CanSeeShares() { return s_iSeeShares; }
270 static void SetCanSeeShares(uint8 val) { s_iSeeShares = val; }
272 static uint8 GetStatsMax() { return s_statsMax; }
273 static bool UseFlatBar() { return (s_depth3D==0); }
274 static uint8 GetStatsAverageMinutes() { return s_statsAverageMinutes; }
275 static void SetStatsAverageMinutes(uint8 in){ s_statsAverageMinutes = in; }
277 static bool GetStartMinimized() { return s_startMinimized; }
278 static void SetStartMinimized(bool instartMinimized)
279 { s_startMinimized = instartMinimized;}
280 static bool GetSmartIdCheck() { return s_smartidcheck; }
281 static void SetSmartIdCheck( bool in_smartidcheck )
282 { s_smartidcheck = in_smartidcheck; }
283 static uint8 GetSmartIdState() { return s_smartidstate; }
284 static void SetSmartIdState( uint8 in_smartidstate )
285 { s_smartidstate = in_smartidstate; }
286 static bool GetVerbose() { return s_bVerbose; }
287 static void SetVerbose(bool val) { s_bVerbose = val; }
288 static bool GetPreviewPrio() { return s_bpreviewprio; }
289 static void SetPreviewPrio(bool in) { s_bpreviewprio = in; }
290 static bool TransferFullChunks() { return s_btransferfullchunks; }
291 static void SetTransferFullChunks( bool m_bintransferfullchunks )
292 {s_btransferfullchunks = m_bintransferfullchunks; }
293 static bool StartNextFile() { return s_bstartnextfile; }
294 static bool StartNextFileSame() { return s_bstartnextfilesame; }
295 static void SetStartNextFile(bool val) { s_bstartnextfile = val; }
296 static void SetStartNextFileSame(bool val) { s_bstartnextfilesame = val; }
297 static bool ShowOverhead() { return s_bshowoverhead; }
298 static void SetNewAutoUp(bool m_bInUAP) { s_bUAP = m_bInUAP; }
299 static bool GetNewAutoUp() { return s_bUAP; }
300 static void SetNewAutoDown(bool m_bInDAP) { s_bDAP = m_bInDAP; }
301 static bool GetNewAutoDown() { return s_bDAP; }
303 static const wxString& GetVideoPlayer() { return s_VideoPlayer; }
305 static uint32 GetFileBufferSize() { return s_iFileBufferSize*15000; }
306 static void SetFileBufferSize(uint32 val) { s_iFileBufferSize = val/15000; }
307 static uint32 GetQueueSize() { return s_iQueueSize*100; }
308 static void SetQueueSize(uint32 val) { s_iQueueSize = val/100; }
310 static uint8 Get3DDepth() { return s_depth3D;}
311 static bool AddNewFilesPaused() { return s_addnewfilespaused; }
312 static void SetAddNewFilesPaused(bool val) { s_addnewfilespaused = val; }
314 static void SetMaxConsPerFive(int in) { s_MaxConperFive=in; }
316 static uint16 GetMaxConperFive() { return s_MaxConperFive; }
317 static uint16 GetDefaultMaxConperFive();
319 static bool IsSafeServerConnectEnabled() { return s_safeServerConnect; }
320 static void SetSafeServerConnectEnabled(bool val) { s_safeServerConnect = val; }
321 static bool IsMoviePreviewBackup() { return s_moviePreviewBackup; }
323 static bool IsCheckDiskspaceEnabled() { return s_checkDiskspace; }
324 static void SetCheckDiskspaceEnabled(bool val) { s_checkDiskspace = val; }
325 static uint32 GetMinFreeDiskSpace() { return s_uMinFreeDiskSpace; }
326 static void SetMinFreeDiskSpace(uint32 val) { s_uMinFreeDiskSpace = val; }
328 static const wxString& GetYourHostname() { return s_yourHostname; }
329 static void SetYourHostname(const wxString& s) { s_yourHostname = s; }
331 static void SetMaxUpload(uint16 in);
332 static void SetMaxDownload(uint16 in);
333 static void SetSlotAllocation(uint16 in) { s_slotallocation = in; };
335 typedef std::vector<CPath> PathList;
336 PathList shareddir_list;
338 wxArrayString adresses_list;
340 static bool AutoConnectStaticOnly() { return s_autoconnectstaticonly; }
341 static void SetAutoConnectStaticOnly(bool val) { s_autoconnectstaticonly = val; }
342 static bool GetUPnPEnabled() { return s_UPnPEnabled; }
343 static void SetUPnPEnabled(bool val) { s_UPnPEnabled = val; }
344 static bool GetUPnPECEnabled() { return s_UPnPECEnabled; }
345 static void SetUPnPECEnabled(bool val) { s_UPnPECEnabled = val; }
346 static bool GetUPnPWebServerEnabled() { return s_UPnPWebServerEnabled; }
347 static void SetUPnPWebServerEnabled(bool val){ s_UPnPWebServerEnabled = val; }
348 static uint16 GetUPnPTCPPort() { return s_UPnPTCPPort; }
349 static void SetUPnPTCPPort(uint16 val) { s_UPnPTCPPort = val; }
350 static bool IsManualHighPrio() { return s_bmanualhighprio; }
351 static void SetManualHighPrio(bool val) { s_bmanualhighprio = val; }
352 void LoadCats();
353 static const wxString& GetDateTimeFormat() { return s_datetimeformat; }
354 // Download Categories
355 uint32 AddCat(Category_Struct* cat);
356 void RemoveCat(size_t index);
357 uint32 GetCatCount();
358 Category_Struct* GetCategory(size_t index);
359 const CPath& GetCatPath(uint8 index);
360 uint32 GetCatColor(size_t index);
361 Category_Struct *CreateCategory(const wxString& name, const CPath& path,
362 const wxString& comment, uint32 color, uint8 prio);
363 void UpdateCategory(uint8 cat, const wxString& name, const CPath& path,
364 const wxString& comment, uint32 color, uint8 prio);
366 static uint32 GetAllcatType() { return s_allcatType; }
367 static void SetAllcatType(uint32 in) { s_allcatType = in; }
368 static bool ShowAllNotCats() { return s_showAllNotCats; }
370 // WebServer
371 static uint16 GetWSPort() { return s_nWebPort; }
372 static void SetWSPort(uint16 uPort) { s_nWebPort=uPort; }
373 static uint16 GetWebUPnPTCPPort() { return s_nWebUPnPTCPPort; }
374 static void SetWebUPnPTCPPort(uint16 val) { s_nWebUPnPTCPPort = val; }
375 static const wxString& GetWSPass() { return s_sWebPassword; }
376 static void SetWSPass(const wxString& pass) { s_sWebPassword = pass; }
377 static bool GetWSIsEnabled() { return s_bWebEnabled; }
378 static void SetWSIsEnabled(bool bEnable) { s_bWebEnabled=bEnable; }
379 static bool GetWebUseGzip() { return s_bWebUseGzip; }
380 static void SetWebUseGzip(bool bUse) { s_bWebUseGzip=bUse; }
381 static uint32 GetWebPageRefresh() { return s_nWebPageRefresh; }
382 static void SetWebPageRefresh(uint32 nRefresh) { s_nWebPageRefresh=nRefresh; }
383 static bool GetWSIsLowUserEnabled() { return s_bWebLowEnabled; }
384 static void SetWSIsLowUserEnabled(bool in) { s_bWebLowEnabled=in; }
385 static const wxString& GetWSLowPass() { return s_sWebLowPassword; }
386 static void SetWSLowPass(const wxString& pass) { s_sWebLowPassword = pass; }
387 static const wxString& GetWebTemplate() { return s_WebTemplate; }
388 static void SetWebTemplate(const wxString& val) { s_WebTemplate = val; }
390 static void SetMaxSourcesPerFile(uint16 in) { s_maxsourceperfile=in;}
391 static void SetMaxConnections(uint16 in) { s_maxconnections =in;}
393 static bool ShowCatTabInfos() { return s_showCatTabInfos; }
394 static void ShowCatTabInfos(bool in) { s_showCatTabInfos=in; }
396 // Sources Dropping Tweaks
397 static bool DropNoNeededSources() { return s_NoNeededSources > 0; }
398 static bool SwapNoNeededSources() { return s_NoNeededSources == 2; }
399 static uint8 GetNoNeededSources() { return s_NoNeededSources; }
400 static void SetNoNeededSources(uint8 val) { s_NoNeededSources = val; }
401 static bool DropFullQueueSources() { return s_DropFullQueueSources; }
402 static void SetDropFullQueueSources(bool val) { s_DropFullQueueSources = val; }
403 static bool DropHighQueueRankingSources() { return s_DropHighQueueRankingSources; }
404 static void SetDropHighQueueRankingSources(bool val) { s_DropHighQueueRankingSources = val; }
405 static uint32 HighQueueRanking() { return s_HighQueueRanking; }
406 static void SetHighQueueRanking(uint32 val) { s_HighQueueRanking = val; }
407 static uint32 GetAutoDropTimer() { return s_AutoDropTimer; }
408 static void SetAutoDropTimer(uint32 val) { s_AutoDropTimer = val; }
410 // External Connections
411 static bool AcceptExternalConnections() { return s_AcceptExternalConnections; }
412 static void EnableExternalConnections( bool val ) { s_AcceptExternalConnections = val; }
413 static const wxString& GetECAddress() { return s_ECAddr; }
414 static uint32 ECPort() { return s_ECPort; }
415 static void SetECPort(uint32 val) { s_ECPort = val; }
416 static const wxString& ECPassword() { return s_ECPassword; }
417 static void SetECPass(const wxString& pass) { s_ECPassword = pass; }
418 // Fast ED2K Links Handler Toggling
419 static bool GetFED2KLH() { return s_FastED2KLinksHandler; }
421 // Ip filter
422 static bool IsFilteringClients() { return s_IPFilterClients; }
423 static void SetFilteringClients(bool val) { s_IPFilterClients = val; }
424 static bool IsFilteringServers() { return s_IPFilterServers; }
425 static void SetFilteringServers(bool val) { s_IPFilterServers = val; }
426 static uint8 GetIPFilterLevel() { return s_filterlevel;}
427 static void SetIPFilterLevel(uint8 level);
428 static bool IPFilterAutoLoad() { return s_IPFilterAutoLoad; }
429 static void SetIPFilterAutoLoad(bool val) { s_IPFilterAutoLoad = val; }
430 static const wxString& IPFilterURL() { return s_IPFilterURL; }
431 static void SetIPFilterURL(const wxString& url) { s_IPFilterURL = url; }
432 static bool UseIPFilterSystem() { return s_IPFilterSys; }
433 static void SetIPFilterSystem(bool val) { s_IPFilterSys = val; }
435 // Source seeds On/Off
436 static bool GetSrcSeedsOn() { return s_UseSrcSeeds; }
437 static void SetSrcSeedsOn(bool val) { s_UseSrcSeeds = val; }
439 static bool IsSecureIdentEnabled() { return s_SecIdent; }
440 static void SetSecureIdentEnabled(bool val) { s_SecIdent = val; }
442 static bool GetExtractMetaData() { return s_ExtractMetaData; }
443 static void SetExtractMetaData(bool val) { s_ExtractMetaData = val; }
445 static bool ShowProgBar() { return s_ProgBar; }
446 static bool ShowPercent() { return s_Percent; }
448 static bool GetAllocFullPart() { return s_AllocFullPart; };
449 static void SetAllocFullPart(bool val) { s_AllocFullPart = val; }
450 static bool GetAllocFullChunk() { return s_AllocFullChunk; };
451 static void SetAllocFullChunk(bool val) { s_AllocFullChunk = val; }
453 static wxString GetBrowser();
455 static const wxString& GetSkin() { return s_Skin; }
457 static bool UseSkins() { return s_UseSkinFiles; }
459 static bool VerticalToolbar() { return s_ToolbarOrientation; }
461 static bool ShowPartFileNumber() { return s_ShowPartFileNumber; }
463 static const CPath& GetOSDir() { return s_OSDirectory; }
464 static uint16 GetOSUpdate() { return s_OSUpdate; }
466 static uint8 GetToolTipDelay() { return s_iToolDelayTime; }
468 static void UnsetAutoServerStart();
469 static void CheckUlDlRatio();
471 static void BuildItemList( const wxString& appdir );
472 static void EraseItemList();
474 static void LoadAllItems(wxConfigBase* cfg);
475 static void SaveAllItems(wxConfigBase* cfg);
477 static bool GetShowRatesOnTitle() { return s_ShowRatesOnTitle; }
479 // Message Filters
481 static bool MustFilterMessages() { return s_MustFilterMessages; }
482 static void SetMustFilterMessages(bool val) { s_MustFilterMessages = val; }
483 static bool IsFilterAllMessages() { return s_FilterAllMessages; }
484 static void SetFilterAllMessages(bool val) { s_FilterAllMessages = val; }
485 static bool MsgOnlyFriends() { return s_msgonlyfriends;}
486 static void SetMsgOnlyFriends(bool val) { s_msgonlyfriends = val; }
487 static bool MsgOnlySecure() { return s_msgsecure;}
488 static void SetMsgOnlySecure(bool val) { s_msgsecure = val; }
489 static bool IsFilterByKeywords() { return s_FilterSomeMessages; }
490 static void SetFilterByKeywords(bool val) { s_FilterSomeMessages = val; }
491 static const wxString& GetMessageFilterString() { return s_MessageFilterString; }
492 static void SetMessageFilterString(const wxString& val) { s_MessageFilterString = val; }
493 static bool IsMessageFiltered(const wxString& message);
495 static bool FilterComments() { return s_FilterComments; }
496 static void SetFilterComments(bool val) { s_FilterComments = val; }
497 static const wxString& GetCommentFilterString() { return s_CommentFilterString; }
498 static void SetCommentFilterString(const wxString& val) { s_CommentFilterString = val; }
499 static bool IsCommentFiltered(const wxString& comment);
501 // Can't have it return a reference, will need a pointer later.
502 static const CProxyData *GetProxyData() { return &s_ProxyData; }
504 // Hidden files
506 static bool ShareHiddenFiles() { return s_ShareHiddenFiles; }
508 static bool AutoSortDownload() { return s_AutoSortDownload; }
510 // Version check
512 static bool CheckNewVersion() { return s_NewVersionCheck; }
514 // Networks
515 static bool GetNetworkKademlia() { return s_ConnectToKad; }
516 static void SetNetworkKademlia(bool val) { s_ConnectToKad = val; }
517 static bool GetNetworkED2K() { return s_ConnectToED2K; }
518 static void SetNetworkED2K(bool val) { s_ConnectToED2K = val; }
520 // Statistics
521 static unsigned GetMaxClientVersions() { return s_maxClientVersions; }
523 // Dropping slow sources
524 static bool GetDropSlowSources() { return s_DropSlowSources; }
526 // server.met and nodes.dat urls
527 static const wxString& GetKadNodesUrl() { return s_KadURL; }
528 static void SetKadNodesUrl(const wxString& url) { s_KadURL = url; }
530 static const wxString& GetEd2kServersUrl() { return s_Ed2kURL; }
531 static void SetEd2kServersUrl(const wxString& url) { s_Ed2kURL = url; }
533 // Crypt
534 static bool IsClientCryptLayerSupported() {return s_IsClientCryptLayerSupported;}
535 static bool IsClientCryptLayerRequested() {return IsClientCryptLayerSupported() && s_bCryptLayerRequested;}
536 static bool IsClientCryptLayerRequired() {return IsClientCryptLayerRequested() && s_IsClientCryptLayerRequired;}
537 static bool IsClientCryptLayerRequiredStrict() {return false;} // not even incoming test connections will be answered
538 static bool IsServerCryptLayerUDPEnabled() {return IsClientCryptLayerSupported();}
539 static bool IsServerCryptLayerTCPRequested() {return IsClientCryptLayerRequested();}
540 static bool IsServerCryptLayerTCPRequired() {return IsClientCryptLayerRequired();}
541 static uint32 GetKadUDPKey() {return s_dwKadUDPKey;}
542 static uint8 GetCryptTCPPaddingLength() {return s_byCryptTCPPaddingLength;}
544 static void SetClientCryptLayerSupported(bool v) {s_IsClientCryptLayerSupported = v;}
545 static void SetClientCryptLayerRequested(bool v) {s_bCryptLayerRequested = v; }
546 static void SetClientCryptLayerRequired(bool v) {s_IsClientCryptLayerRequired = v;}
548 protected:
549 static int32 GetRecommendedMaxConnections();
551 //! Temporary storage for statistic-colors.
552 static COLORREF s_colors[cntStatColors];
553 //! Reference for checking if the colors has changed.
554 static COLORREF s_colors_ref[cntStatColors];
556 typedef std::vector<Cfg_Base*> CFGList;
557 typedef std::map<int, Cfg_Base*> CFGMap;
558 typedef std::vector<Category_Struct*> CatList;
561 static CFGMap s_CfgList;
562 static CFGList s_MiscList;
563 CatList m_CatList;
565 private:
566 void LoadPreferences();
567 void SavePreferences();
569 protected:
570 ////////////// USER
571 static wxString s_nick;
573 static CMD4Hash s_userhash;
575 ////////////// CONNECTION
576 static uint16 s_maxupload;
577 static uint16 s_maxdownload;
578 static uint16 s_slotallocation;
579 static wxString s_Addr;
580 static uint16 s_port;
581 static uint16 s_udpport;
582 static bool s_UDPDisable;
583 static uint16 s_maxconnections;
584 static bool s_reconnect;
585 static bool s_autoconnect;
586 static bool s_autoconnectstaticonly;
587 static bool s_UPnPEnabled;
588 static bool s_UPnPECEnabled;
589 static bool s_UPnPWebServerEnabled;
590 static uint16 s_UPnPTCPPort;
592 ////////////// PROXY
593 static CProxyData s_ProxyData;
595 ////////////// SERVERS
596 static bool s_autoserverlist;
597 static bool s_deadserver;
599 ////////////// FILES
600 static CPath s_incomingdir;
601 static CPath s_tempdir;
602 static bool s_ICH;
603 static bool s_AICHTrustEveryHash;
605 ////////////// GUI
606 static uint8 s_depth3D;
608 static bool s_scorsystem;
609 static bool s_mintotray;
610 static bool s_trayiconenabled;
611 static bool s_addnewfilespaused;
612 static bool s_addserversfromserver;
613 static bool s_addserversfromclient;
614 static uint16 s_maxsourceperfile;
615 static uint16 s_trafficOMeterInterval;
616 static uint16 s_statsInterval;
617 static uint32 s_maxGraphDownloadRate;
618 static uint32 s_maxGraphUploadRate;
619 static bool s_confirmExit;
622 static bool s_filterLanIP;
623 static bool s_paranoidfilter;
624 static bool s_onlineSig;
626 static uint64 s_totalDownloadedBytes;
627 static uint64 s_totalUploadedBytes;
628 static wxString s_languageID;
629 static uint8 s_iSeeShares; // 0=everybody 1=friends only 2=noone
630 static uint8 s_iToolDelayTime; // tooltip delay time in seconds
631 static uint8 s_splitterbarPosition;
632 static uint16 s_deadserverretries;
633 static uint32 s_dwServerKeepAliveTimeoutMins;
635 static uint8 s_statsMax;
636 static uint8 s_statsAverageMinutes;
638 static bool s_bpreviewprio;
639 static bool s_smartidcheck;
640 static uint8 s_smartidstate;
641 static bool s_safeServerConnect;
642 static bool s_startMinimized;
643 static uint16 s_MaxConperFive;
644 static bool s_checkDiskspace;
645 static uint32 s_uMinFreeDiskSpace;
646 static wxString s_yourHostname;
647 static bool s_bVerbose;
648 static bool s_bmanualhighprio;
649 static bool s_btransferfullchunks;
650 static bool s_bstartnextfile;
651 static bool s_bstartnextfilesame;
652 static bool s_bshowoverhead;
653 static bool s_bDAP;
654 static bool s_bUAP;
655 static bool s_bDisableKnownClientList;
656 static bool s_bDisableQueueList;
658 static bool s_ShowRatesOnTitle;
660 static wxString s_VideoPlayer;
661 static bool s_moviePreviewBackup;
662 static bool s_indicateratings;
663 static bool s_showAllNotCats;
665 static bool s_msgonlyfriends;
666 static bool s_msgsecure;
668 static uint8 s_iFileBufferSize;
669 static uint8 s_iQueueSize;
671 static uint16 s_maxmsgsessions;
672 static wxString s_datetimeformat;
674 static bool s_ToolbarOrientation;
675 static bool s_ShowPartFileNumber;
677 // Web Server [kuchin]
678 static wxString s_sWebPassword;
679 static wxString s_sWebLowPassword;
680 static uint16 s_nWebPort;
681 static uint16 s_nWebUPnPTCPPort;
682 static bool s_bWebEnabled;
683 static bool s_bWebUseGzip;
684 static uint32 s_nWebPageRefresh;
685 static bool s_bWebLowEnabled;
686 static wxString s_WebTemplate;
688 static bool s_showCatTabInfos;
689 static uint32 s_allcatType;
691 // Madcat - Sources Dropping Tweaks
692 static uint8 s_NoNeededSources; // 0: Keep, 1: Drop, 2:Swap
693 static bool s_DropFullQueueSources;
694 static bool s_DropHighQueueRankingSources;
695 static uint32 s_HighQueueRanking;
696 static uint32 s_AutoDropTimer;
698 // Kry - external connections
699 static bool s_AcceptExternalConnections;
700 static wxString s_ECAddr;
701 static uint32 s_ECPort;
702 static wxString s_ECPassword;
704 // Kry - IPFilter
705 static bool s_IPFilterClients;
706 static bool s_IPFilterServers;
707 static uint8 s_filterlevel;
708 static bool s_IPFilterAutoLoad;
709 static wxString s_IPFilterURL;
710 static bool s_IPFilterSys;
712 // Kry - Source seeds on/off
713 static bool s_UseSrcSeeds;
715 static bool s_ProgBar;
716 static bool s_Percent;
718 static bool s_SecIdent;
720 static bool s_ExtractMetaData;
722 static bool s_AllocFullPart;
723 static bool s_AllocFullChunk;
725 static uint16 s_Browser;
726 static wxString s_CustomBrowser;
727 static bool s_BrowserTab; // Jacobo221 - Open in tabs if possible
729 static CPath s_OSDirectory;
730 static uint16 s_OSUpdate;
732 static wxString s_Skin;
733 static bool s_UseSkinFiles;
735 static bool s_FastED2KLinksHandler; // Madcat - Toggle Fast ED2K Links Handler
737 // Message Filtering
738 static bool s_MustFilterMessages;
739 static wxString s_MessageFilterString;
740 static bool s_FilterAllMessages;
741 static bool s_FilterSomeMessages;
743 static bool s_FilterComments;
744 static wxString s_CommentFilterString;
747 // Hidden files sharing
748 static bool s_ShareHiddenFiles;
750 static bool s_AutoSortDownload;
752 // Version check
753 static bool s_NewVersionCheck;
755 // Kad
756 static bool s_ConnectToKad;
757 static bool s_ConnectToED2K;
759 // Statistics
760 static unsigned s_maxClientVersions; // 0 = unlimited
762 // Drop slow sources if needed
763 static bool s_DropSlowSources;
765 static wxString s_Ed2kURL;
766 static wxString s_KadURL;
768 // Crypt
769 static bool s_IsClientCryptLayerSupported;
770 static bool s_IsClientCryptLayerRequired;
771 static bool s_bCryptLayerRequested;
772 static uint32 s_dwKadUDPKey;
773 static uint8 s_byCryptTCPPaddingLength;
777 #endif // PREFERENCES_H
778 // File_checked_for_headers