1 // 2 // This file is part of the aMule Project. 3 // 4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5 // Copyright (c) 2002-2011 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. 10 // 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. 15 // 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 24 // 25 26 #ifndef PREFERENCES_H 27 #define PREFERENCES_H 28 29 #include "MD4Hash.h" // Needed for CMD4Hash 30 31 #include <wx/arrstr.h> // Needed for wxArrayString 32 33 #include <map> 34 35 #include "Proxy.h" 36 #include "OtherStructs.h" 37 38 #include <common/ClientVersion.h> // Needed for __SVN__ 39 40 class CPreferences; 41 class wxConfigBase; 42 class wxWindow; 43 44 enum EViewSharedFilesAccess { 45 vsfaEverybody = 0, 46 vsfaFriends = 1, 47 vsfaNobody = 2 48 }; 49 50 enum AllCategoryFilter { 51 acfAll = 0, 52 acfAllOthers, 53 acfIncomplete, 54 acfCompleted, 55 acfWaiting, 56 acfDownloading, 57 acfErroneous, 58 acfPaused, 59 acfStopped, 60 acfVideo, 61 acfAudio, 62 acfArchive, 63 acfCDImages, 64 acfPictures, 65 acfText, 66 acfActive 67 }; 68 69 /** 70 * Base-class for automatically loading and saving of preferences. 71 * 72 * The purpose of this class is to perform two tasks: 73 * 1) To load and save a variable using wxConfig 74 * 2) If nescecarry, to syncronize it with a widget 75 * 76 * This pure-virtual class servers as the base of all the Cfg types 77 * defined below, and exposes the entire interface. 78 * 79 * Please note that for reasons of simplicity these classes dont provide 80 * direct access to the variables they maintain, as there is no real need 81 * for this. 82 * 83 * To create a sub-class you need only provide the Load/Save functionality, 84 * as it is given that not all variables have a widget assosiated. 85 */ 86 class Cfg_Base 87 { 88 public: 89 /** 90 * Constructor. 91 * 92 * @param keyname This is the keyname under which the variable is to be saved. 93 */ Cfg_Base(const wxString & keyname)94 Cfg_Base( const wxString& keyname ) 95 : m_key( keyname ), 96 m_changed( false ) 97 {} 98 99 /** 100 * Destructor. 101 */ ~Cfg_Base()102 virtual ~Cfg_Base() {} 103 104 /** 105 * This function loads the assosiated variable from the provided config object. 106 */ 107 virtual void LoadFromFile(wxConfigBase* cfg) = 0; 108 /** 109 * This function saves the assosiated variable to the provided config object. 110 */ 111 virtual void SaveToFile(wxConfigBase* cfg) = 0; 112 113 /** 114 * Syncs the variable with the contents of the widget. 115 * 116 * @return True of success, false otherwise. 117 */ TransferFromWindow()118 virtual bool TransferFromWindow() { return false; } 119 /** 120 * Syncs the widget with the contents of the variable. 121 * 122 * @return True of success, false otherwise. 123 */ TransferToWindow()124 virtual bool TransferToWindow() { return false; } 125 126 /** 127 * Connects a widget with the specified ID to the Cfg object. 128 * 129 * @param id The ID of the widget. 130 * @param parent A pointer to the widgets parent, to speed up searches. 131 * @return True on success, false otherwise. 132 * 133 * This function only makes sense for Cfg-classes that have the capability 134 * to interact with a widget, see Cfg_Tmpl::ConnectToWidget(). 135 */ WXUNUSED(id)136 virtual bool ConnectToWidget( int WXUNUSED(id), wxWindow* WXUNUSED(parent) = NULL ) { return false; } 137 138 /** 139 * Gets the key assosiated with Cfg object. 140 * 141 * @return The config-key of this object. 142 */ GetKey()143 virtual const wxString& GetKey() { return m_key; } 144 145 146 /** 147 * Specifies if the variable has changed since the TransferFromWindow() call. 148 * 149 * @return True if the variable has changed, false otherwise. 150 */ HasChanged()151 virtual bool HasChanged() { return m_changed; } 152 153 154 protected: 155 /** 156 * Sets the changed status. 157 * 158 * @param changed The new status. 159 */ SetChanged(bool changed)160 virtual void SetChanged( bool changed ) 161 { 162 m_changed = changed; 163 }; 164 165 private: 166 167 //! The Config-key under which to save the variable 168 wxString m_key; 169 170 //! The changed-status of the variable 171 bool m_changed; 172 }; 173 174 175 class Cfg_Lang_Base { 176 public: 177 virtual void UpdateChoice(int pos); 178 }; 179 180 const int cntStatColors = 15; 181 182 183 //! This typedef is a shortcut similar to the theApp shortcut, but uses :: instead of . 184 //! It only allows access to static preference functions, however this is to be desired anyway. 185 typedef CPreferences thePrefs; 186 187 188 class CPreferences 189 { 190 public: 191 friend class PrefsUnifiedDlg; 192 193 CPreferences(); 194 ~CPreferences(); 195 196 void Save(); 197 void SaveCats(); 198 void ReloadSharedFolders(); 199 GetConfigDir()200 static const wxString& GetConfigDir() { return s_configDir; } SetConfigDir(const wxString & dir)201 static void SetConfigDir(const wxString& dir) { s_configDir = dir; } 202 Score()203 static bool Score() { return s_scorsystem; } SetScoreSystem(bool val)204 static void SetScoreSystem(bool val) { s_scorsystem = val; } Reconnect()205 static bool Reconnect() { return s_reconnect; } SetReconnect(bool val)206 static void SetReconnect(bool val) { s_reconnect = val; } DeadServer()207 static bool DeadServer() { return s_deadserver; } SetDeadServer(bool val)208 static void SetDeadServer(bool val) { s_deadserver = val; } GetUserNick()209 static const wxString& GetUserNick() { return s_nick; } SetUserNick(const wxString & nick)210 static void SetUserNick(const wxString& nick) { s_nick = nick; } GetCfgLang()211 static Cfg_Lang_Base * GetCfgLang() { return s_cfgLang; } 212 GetAddress()213 static const wxString& GetAddress() { return s_Addr; } GetPort()214 static uint16 GetPort() { return s_port; } 215 static void SetPort(uint16 val); GetUDPPort()216 static uint16 GetUDPPort() { return s_udpport; } GetEffectiveUDPPort()217 static uint16 GetEffectiveUDPPort() { return s_UDPEnable ? s_udpport : 0; } SetUDPPort(uint16 val)218 static void SetUDPPort(uint16 val) { s_udpport = val; } IsUDPDisabled()219 static bool IsUDPDisabled() { return !s_UDPEnable; } SetUDPDisable(bool val)220 static void SetUDPDisable(bool val) { s_UDPEnable = !val; } GetIncomingDir()221 static const CPath& GetIncomingDir() { return s_incomingdir; } SetIncomingDir(const CPath & dir)222 static void SetIncomingDir(const CPath& dir){ s_incomingdir = dir; } GetTempDir()223 static const CPath& GetTempDir() { return s_tempdir; } SetTempDir(const CPath & dir)224 static void SetTempDir(const CPath& dir) { s_tempdir = dir; } GetUserHash()225 static const CMD4Hash& GetUserHash() { return s_userhash; } SetUserHash(const CMD4Hash & h)226 static void SetUserHash(const CMD4Hash& h) { s_userhash = h; } GetMaxUpload()227 static uint16 GetMaxUpload() { return s_maxupload; } GetSlotAllocation()228 static uint16 GetSlotAllocation() { return s_slotallocation; } IsICHEnabled()229 static bool IsICHEnabled() { return s_ICH; } SetICHEnabled(bool val)230 static void SetICHEnabled(bool val) { s_ICH = val; } IsTrustingEveryHash()231 static bool IsTrustingEveryHash() { return s_AICHTrustEveryHash; } SetTrustingEveryHash(bool val)232 static void SetTrustingEveryHash(bool val) { s_AICHTrustEveryHash = val; } AutoServerlist()233 static bool AutoServerlist() { return s_autoserverlist; } SetAutoServerlist(bool val)234 static void SetAutoServerlist(bool val) { s_autoserverlist = val; } DoMinToTray()235 static bool DoMinToTray() { return s_mintotray; } SetMinToTray(bool val)236 static void SetMinToTray(bool val) { s_mintotray = val; } UseTrayIcon()237 static bool UseTrayIcon() { return s_trayiconenabled; } SetUseTrayIcon(bool val)238 static void SetUseTrayIcon(bool val) { s_trayiconenabled = val; } HideOnClose()239 static bool HideOnClose() { return s_hideonclose; } SetHideOnClose(bool val)240 static void SetHideOnClose(bool val) { s_hideonclose = val; } DoAutoConnect()241 static bool DoAutoConnect() { return s_autoconnect; } SetAutoConnect(bool inautoconnect)242 static void SetAutoConnect(bool inautoconnect) 243 {s_autoconnect = inautoconnect; } AddServersFromServer()244 static bool AddServersFromServer() { return s_addserversfromserver; } SetAddServersFromServer(bool val)245 static void SetAddServersFromServer(bool val) { s_addserversfromserver = val; } AddServersFromClient()246 static bool AddServersFromClient() { return s_addserversfromclient; } SetAddServersFromClient(bool val)247 static void SetAddServersFromClient(bool val) { s_addserversfromclient = val; } GetTrafficOMeterInterval()248 static uint16 GetTrafficOMeterInterval() { return s_trafficOMeterInterval; } SetTrafficOMeterInterval(uint16 in)249 static void SetTrafficOMeterInterval(uint16 in) 250 { s_trafficOMeterInterval = in; } GetStatsInterval()251 static uint16 GetStatsInterval() { return s_statsInterval;} SetStatsInterval(uint16 in)252 static void SetStatsInterval(uint16 in) { s_statsInterval = in; } IsConfirmExitEnabled()253 static bool IsConfirmExitEnabled() { return s_confirmExit; } FilterLanIPs()254 static bool FilterLanIPs() { return s_filterLanIP; } SetFilterLanIPs(bool val)255 static void SetFilterLanIPs(bool val) { s_filterLanIP = val; } ParanoidFilter()256 static bool ParanoidFilter() { return s_paranoidfilter; } SetParanoidFilter(bool val)257 static void SetParanoidFilter(bool val) { s_paranoidfilter = val; } IsOnlineSignatureEnabled()258 static bool IsOnlineSignatureEnabled() { return s_onlineSig; } SetOnlineSignatureEnabled(bool val)259 static void SetOnlineSignatureEnabled(bool val) { s_onlineSig = val; } GetMaxGraphUploadRate()260 static uint32 GetMaxGraphUploadRate() { return s_maxGraphUploadRate; } GetMaxGraphDownloadRate()261 static uint32 GetMaxGraphDownloadRate() { return s_maxGraphDownloadRate; } SetMaxGraphUploadRate(uint32 in)262 static void SetMaxGraphUploadRate(uint32 in){ s_maxGraphUploadRate=in; } SetMaxGraphDownloadRate(uint32 in)263 static void SetMaxGraphDownloadRate(uint32 in) 264 { s_maxGraphDownloadRate = in; } 265 GetMaxDownload()266 static uint16 GetMaxDownload() { return s_maxdownload; } GetMaxConnections()267 static uint16 GetMaxConnections() { return s_maxconnections; } GetMaxSourcePerFile()268 static uint16 GetMaxSourcePerFile() { return s_maxsourceperfile; } GetMaxSourcePerFileSoft()269 static uint16 GetMaxSourcePerFileSoft() { 270 uint16 temp = (uint16)(s_maxsourceperfile*0.9); 271 if( temp > 1000 ) return 1000; 272 return temp; } GetMaxSourcePerFileUDP()273 static uint16 GetMaxSourcePerFileUDP() { 274 uint16 temp = (uint16)(s_maxsourceperfile*0.75); 275 if( temp > 100 ) return 100; 276 return temp; } GetDeadserverRetries()277 static uint16 GetDeadserverRetries() { return s_deadserverretries; } SetDeadserverRetries(uint16 val)278 static void SetDeadserverRetries(uint16 val) { s_deadserverretries = val; } GetServerKeepAliveTimeout()279 static uint32 GetServerKeepAliveTimeout() { return s_dwServerKeepAliveTimeoutMins*60000; } SetServerKeepAliveTimeout(uint32 val)280 static void SetServerKeepAliveTimeout(uint32 val) { s_dwServerKeepAliveTimeoutMins = val/60000; } 281 GetLanguageID()282 static const wxString& GetLanguageID() { return s_languageID; } SetLanguageID(const wxString & new_id)283 static void SetLanguageID(const wxString& new_id) { s_languageID = new_id; } CanSeeShares()284 static uint8 CanSeeShares() { return s_iSeeShares; } SetCanSeeShares(uint8 val)285 static void SetCanSeeShares(uint8 val) { s_iSeeShares = val; } 286 GetStatsMax()287 static uint8 GetStatsMax() { return s_statsMax; } UseFlatBar()288 static bool UseFlatBar() { return (s_depth3D==0); } GetStatsAverageMinutes()289 static uint8 GetStatsAverageMinutes() { return s_statsAverageMinutes; } SetStatsAverageMinutes(uint8 in)290 static void SetStatsAverageMinutes(uint8 in){ s_statsAverageMinutes = in; } 291 GetStartMinimized()292 static bool GetStartMinimized() { return s_startMinimized; } SetStartMinimized(bool instartMinimized)293 static void SetStartMinimized(bool instartMinimized) 294 { s_startMinimized = instartMinimized;} GetSmartIdCheck()295 static bool GetSmartIdCheck() { return s_smartidcheck; } SetSmartIdCheck(bool in_smartidcheck)296 static void SetSmartIdCheck( bool in_smartidcheck ) 297 { s_smartidcheck = in_smartidcheck; } GetSmartIdState()298 static uint8 GetSmartIdState() { return s_smartidstate; } SetSmartIdState(uint8 in_smartidstate)299 static void SetSmartIdState( uint8 in_smartidstate ) 300 { s_smartidstate = in_smartidstate; } GetVerbose()301 static bool GetVerbose() { return s_bVerbose; } SetVerbose(bool val)302 static void SetVerbose(bool val) { s_bVerbose = val; } GetVerboseLogfile()303 static bool GetVerboseLogfile() { return s_bVerboseLogfile; } SetVerboseLogfile(bool val)304 static void SetVerboseLogfile(bool val) { s_bVerboseLogfile = val; } GetPreviewPrio()305 static bool GetPreviewPrio() { return s_bpreviewprio; } SetPreviewPrio(bool in)306 static void SetPreviewPrio(bool in) { s_bpreviewprio = in; } StartNextFile()307 static bool StartNextFile() { return s_bstartnextfile; } StartNextFileSame()308 static bool StartNextFileSame() { return s_bstartnextfilesame; } StartNextFileAlpha()309 static bool StartNextFileAlpha() { return s_bstartnextfilealpha; } SetStartNextFile(bool val)310 static void SetStartNextFile(bool val) { s_bstartnextfile = val; } SetStartNextFileSame(bool val)311 static void SetStartNextFileSame(bool val) { s_bstartnextfilesame = val; } SetStartNextFileAlpha(bool val)312 static void SetStartNextFileAlpha(bool val) { s_bstartnextfilealpha = val; } ShowOverhead()313 static bool ShowOverhead() { return s_bshowoverhead; } SetNewAutoUp(bool m_bInUAP)314 static void SetNewAutoUp(bool m_bInUAP) { s_bUAP = m_bInUAP; } GetNewAutoUp()315 static bool GetNewAutoUp() { return s_bUAP; } SetNewAutoDown(bool m_bInDAP)316 static void SetNewAutoDown(bool m_bInDAP) { s_bDAP = m_bInDAP; } GetNewAutoDown()317 static bool GetNewAutoDown() { return s_bDAP; } 318 GetVideoPlayer()319 static const wxString& GetVideoPlayer() { return s_VideoPlayer; } 320 GetFileBufferSize()321 static uint32 GetFileBufferSize() { return s_iFileBufferSize*15000; } SetFileBufferSize(uint32 val)322 static void SetFileBufferSize(uint32 val) { s_iFileBufferSize = val/15000; } GetQueueSize()323 static uint32 GetQueueSize() { return s_iQueueSize*100; } SetQueueSize(uint32 val)324 static void SetQueueSize(uint32 val) { s_iQueueSize = val/100; } 325 Get3DDepth()326 static uint8 Get3DDepth() { return s_depth3D;} AddNewFilesPaused()327 static bool AddNewFilesPaused() { return s_addnewfilespaused; } SetAddNewFilesPaused(bool val)328 static void SetAddNewFilesPaused(bool val) { s_addnewfilespaused = val; } 329 SetMaxConsPerFive(int in)330 static void SetMaxConsPerFive(int in) { s_MaxConperFive=in; } 331 GetMaxConperFive()332 static uint16 GetMaxConperFive() { return s_MaxConperFive; } 333 static uint16 GetDefaultMaxConperFive(); 334 IsSafeServerConnectEnabled()335 static bool IsSafeServerConnectEnabled() { return s_safeServerConnect; } SetSafeServerConnectEnabled(bool val)336 static void SetSafeServerConnectEnabled(bool val) { s_safeServerConnect = val; } 337 IsCheckDiskspaceEnabled()338 static bool IsCheckDiskspaceEnabled() { return s_checkDiskspace; } SetCheckDiskspaceEnabled(bool val)339 static void SetCheckDiskspaceEnabled(bool val) { s_checkDiskspace = val; } GetMinFreeDiskSpaceMB()340 static uint32 GetMinFreeDiskSpaceMB() { return s_uMinFreeDiskSpace; } GetMinFreeDiskSpace()341 static uint64 GetMinFreeDiskSpace() { return s_uMinFreeDiskSpace * 1048576ull; } SetMinFreeDiskSpaceMB(uint32 val)342 static void SetMinFreeDiskSpaceMB(uint32 val) { s_uMinFreeDiskSpace = val; } 343 GetYourHostname()344 static const wxString& GetYourHostname() { return s_yourHostname; } SetYourHostname(const wxString & s)345 static void SetYourHostname(const wxString& s) { s_yourHostname = s; } 346 347 static void SetMaxUpload(uint16 in); 348 static void SetMaxDownload(uint16 in); SetSlotAllocation(uint16 in)349 static void SetSlotAllocation(uint16 in) { s_slotallocation = (in >= 1) ? in : 1; }; 350 351 typedef std::vector<CPath> PathList; 352 PathList shareddir_list; 353 354 wxArrayString adresses_list; 355 AutoConnectStaticOnly()356 static bool AutoConnectStaticOnly() { return s_autoconnectstaticonly; } SetAutoConnectStaticOnly(bool val)357 static void SetAutoConnectStaticOnly(bool val) { s_autoconnectstaticonly = val; } GetUPnPEnabled()358 static bool GetUPnPEnabled() { return s_UPnPEnabled; } SetUPnPEnabled(bool val)359 static void SetUPnPEnabled(bool val) { s_UPnPEnabled = val; } GetUPnPECEnabled()360 static bool GetUPnPECEnabled() { return s_UPnPECEnabled; } SetUPnPECEnabled(bool val)361 static void SetUPnPECEnabled(bool val) { s_UPnPECEnabled = val; } GetUPnPWebServerEnabled()362 static bool GetUPnPWebServerEnabled() { return s_UPnPWebServerEnabled; } SetUPnPWebServerEnabled(bool val)363 static void SetUPnPWebServerEnabled(bool val){ s_UPnPWebServerEnabled = val; } GetUPnPTCPPort()364 static uint16 GetUPnPTCPPort() { return s_UPnPTCPPort; } SetUPnPTCPPort(uint16 val)365 static void SetUPnPTCPPort(uint16 val) { s_UPnPTCPPort = val; } IsManualHighPrio()366 static bool IsManualHighPrio() { return s_bmanualhighprio; } SetManualHighPrio(bool val)367 static void SetManualHighPrio(bool val) { s_bmanualhighprio = val; } 368 void LoadCats(); GetDateTimeFormat()369 static const wxString& GetDateTimeFormat() { return s_datetimeformat; } 370 // Download Categories 371 uint32 AddCat(Category_Struct* cat); 372 void RemoveCat(size_t index); 373 uint32 GetCatCount(); 374 Category_Struct* GetCategory(size_t index); 375 const CPath& GetCatPath(uint8 index); 376 uint32 GetCatColor(size_t index); 377 bool CreateCategory(Category_Struct *& category, const wxString& name, const CPath& path, 378 const wxString& comment, uint32 color, uint8 prio); 379 bool UpdateCategory(uint8 cat, const wxString& name, const CPath& path, 380 const wxString& comment, uint32 color, uint8 prio); 381 GetAllcatFilter()382 static AllCategoryFilter GetAllcatFilter() { return s_allcatFilter; } SetAllcatFilter(AllCategoryFilter in)383 static void SetAllcatFilter(AllCategoryFilter in) { s_allcatFilter = in; } 384 ShowAllNotCats()385 static bool ShowAllNotCats() { return s_showAllNotCats; } 386 387 // WebServer GetWSPort()388 static uint16 GetWSPort() { return s_nWebPort; } SetWSPort(uint16 uPort)389 static void SetWSPort(uint16 uPort) { s_nWebPort=uPort; } GetWebUPnPTCPPort()390 static uint16 GetWebUPnPTCPPort() { return s_nWebUPnPTCPPort; } SetWebUPnPTCPPort(uint16 val)391 static void SetWebUPnPTCPPort(uint16 val) { s_nWebUPnPTCPPort = val; } GetWSPass()392 static const wxString& GetWSPass() { return s_sWebPassword; } SetWSPass(const wxString & pass)393 static void SetWSPass(const wxString& pass) { s_sWebPassword = pass; } GetWSPath()394 static const wxString& GetWSPath() { return s_sWebPath; } SetWSPath(const wxString & path)395 static void SetWSPath(const wxString& path) { s_sWebPath = path; } GetWSIsEnabled()396 static bool GetWSIsEnabled() { return s_bWebEnabled; } SetWSIsEnabled(bool bEnable)397 static void SetWSIsEnabled(bool bEnable) { s_bWebEnabled=bEnable; } GetWebUseGzip()398 static bool GetWebUseGzip() { return s_bWebUseGzip; } SetWebUseGzip(bool bUse)399 static void SetWebUseGzip(bool bUse) { s_bWebUseGzip=bUse; } GetWebPageRefresh()400 static uint32 GetWebPageRefresh() { return s_nWebPageRefresh; } SetWebPageRefresh(uint32 nRefresh)401 static void SetWebPageRefresh(uint32 nRefresh) { s_nWebPageRefresh=nRefresh; } GetWSIsLowUserEnabled()402 static bool GetWSIsLowUserEnabled() { return s_bWebLowEnabled; } SetWSIsLowUserEnabled(bool in)403 static void SetWSIsLowUserEnabled(bool in) { s_bWebLowEnabled=in; } GetWSLowPass()404 static const wxString& GetWSLowPass() { return s_sWebLowPassword; } SetWSLowPass(const wxString & pass)405 static void SetWSLowPass(const wxString& pass) { s_sWebLowPassword = pass; } GetWebTemplate()406 static const wxString& GetWebTemplate() { return s_WebTemplate; } SetWebTemplate(const wxString & val)407 static void SetWebTemplate(const wxString& val) { s_WebTemplate = val; } 408 SetMaxSourcesPerFile(uint16 in)409 static void SetMaxSourcesPerFile(uint16 in) { s_maxsourceperfile=in;} SetMaxConnections(uint16 in)410 static void SetMaxConnections(uint16 in) { s_maxconnections =in;} 411 ShowCatTabInfos()412 static bool ShowCatTabInfos() { return s_showCatTabInfos; } ShowCatTabInfos(bool in)413 static void ShowCatTabInfos(bool in) { s_showCatTabInfos=in; } 414 415 // External Connections AcceptExternalConnections()416 static bool AcceptExternalConnections() { return s_AcceptExternalConnections; } EnableExternalConnections(bool val)417 static void EnableExternalConnections( bool val ) { s_AcceptExternalConnections = val; } GetECAddress()418 static const wxString& GetECAddress() { return s_ECAddr; } ECPort()419 static uint32 ECPort() { return s_ECPort; } SetECPort(uint32 val)420 static void SetECPort(uint32 val) { s_ECPort = val; } ECPassword()421 static const wxString& ECPassword() { return s_ECPassword; } SetECPass(const wxString & pass)422 static void SetECPass(const wxString& pass) { s_ECPassword = pass; } IsTransmitOnlyUploadingClients()423 static bool IsTransmitOnlyUploadingClients() { return s_TransmitOnlyUploadingClients; } 424 425 // Fast ED2K Links Handler Toggling GetFED2KLH()426 static bool GetFED2KLH() { return s_FastED2KLinksHandler; } 427 428 // Ip filter IsFilteringClients()429 static bool IsFilteringClients() { return s_IPFilterClients; } 430 static void SetFilteringClients(bool val); IsFilteringServers()431 static bool IsFilteringServers() { return s_IPFilterServers; } 432 static void SetFilteringServers(bool val); GetIPFilterLevel()433 static uint8 GetIPFilterLevel() { return s_filterlevel;} 434 static void SetIPFilterLevel(uint8 level); IPFilterAutoLoad()435 static bool IPFilterAutoLoad() { return s_IPFilterAutoLoad; } SetIPFilterAutoLoad(bool val)436 static void SetIPFilterAutoLoad(bool val) { s_IPFilterAutoLoad = val; } IPFilterURL()437 static const wxString& IPFilterURL() { return s_IPFilterURL; } SetIPFilterURL(const wxString & url)438 static void SetIPFilterURL(const wxString& url) { s_IPFilterURL = url; } UseIPFilterSystem()439 static bool UseIPFilterSystem() { return s_IPFilterSys; } SetIPFilterSystem(bool val)440 static void SetIPFilterSystem(bool val) { s_IPFilterSys = val; } 441 442 // Source seeds On/Off GetSrcSeedsOn()443 static bool GetSrcSeedsOn() { return s_UseSrcSeeds; } SetSrcSeedsOn(bool val)444 static void SetSrcSeedsOn(bool val) { s_UseSrcSeeds = val; } 445 IsSecureIdentEnabled()446 static bool IsSecureIdentEnabled() { return s_SecIdent; } SetSecureIdentEnabled(bool val)447 static void SetSecureIdentEnabled(bool val) { s_SecIdent = val; } 448 GetExtractMetaData()449 static bool GetExtractMetaData() { return s_ExtractMetaData; } SetExtractMetaData(bool val)450 static void SetExtractMetaData(bool val) { s_ExtractMetaData = val; } 451 ShowProgBar()452 static bool ShowProgBar() { return s_ProgBar; } ShowPercent()453 static bool ShowPercent() { return s_Percent; } 454 GetAllocFullFile()455 static bool GetAllocFullFile() { return s_allocFullFile; }; SetAllocFullFile(bool val)456 static void SetAllocFullFile(bool val) { s_allocFullFile = val; } 457 CreateFilesSparse()458 static bool CreateFilesSparse() { return s_createFilesSparse; } 459 // Beware! This function reverts the value it gets, that's why the name is also different! 460 // In EC we send/receive the reverted value, that's the reason for a reverse setter. CreateFilesNormal(bool val)461 static void CreateFilesNormal(bool val) { s_createFilesSparse = !val; } 462 463 static wxString GetBrowser(); 464 GetSkin()465 static const wxString& GetSkin() { return s_Skin; } 466 VerticalToolbar()467 static bool VerticalToolbar() { return s_ToolbarOrientation; } 468 GetOSDir()469 static const CPath& GetOSDir() { return s_OSDirectory; } GetOSUpdate()470 static uint16 GetOSUpdate() { return s_OSUpdate; } 471 GetToolTipDelay()472 static uint8 GetToolTipDelay() { return s_iToolDelayTime; } 473 474 static void UnsetAutoServerStart(); 475 static void CheckUlDlRatio(); 476 477 static void BuildItemList( const wxString& appdir ); 478 static void EraseItemList(); 479 480 static void LoadAllItems(wxConfigBase* cfg); 481 static void SaveAllItems(wxConfigBase* cfg); 482 483 #ifndef __SVN__ ShowVersionOnTitle()484 static bool ShowVersionOnTitle() { return s_showVersionOnTitle; } 485 #else ShowVersionOnTitle()486 static bool ShowVersionOnTitle() { return true; } 487 #endif GetShowRatesOnTitle()488 static uint8_t GetShowRatesOnTitle() { return s_showRatesOnTitle; } SetShowRatesOnTitle(uint8_t val)489 static void SetShowRatesOnTitle(uint8_t val) { s_showRatesOnTitle = val; } 490 491 // Message Filters 492 MustFilterMessages()493 static bool MustFilterMessages() { return s_MustFilterMessages; } SetMustFilterMessages(bool val)494 static void SetMustFilterMessages(bool val) { s_MustFilterMessages = val; } IsFilterAllMessages()495 static bool IsFilterAllMessages() { return s_FilterAllMessages; } SetFilterAllMessages(bool val)496 static void SetFilterAllMessages(bool val) { s_FilterAllMessages = val; } MsgOnlyFriends()497 static bool MsgOnlyFriends() { return s_msgonlyfriends;} SetMsgOnlyFriends(bool val)498 static void SetMsgOnlyFriends(bool val) { s_msgonlyfriends = val; } MsgOnlySecure()499 static bool MsgOnlySecure() { return s_msgsecure;} SetMsgOnlySecure(bool val)500 static void SetMsgOnlySecure(bool val) { s_msgsecure = val; } IsFilterByKeywords()501 static bool IsFilterByKeywords() { return s_FilterSomeMessages; } SetFilterByKeywords(bool val)502 static void SetFilterByKeywords(bool val) { s_FilterSomeMessages = val; } GetMessageFilterString()503 static const wxString& GetMessageFilterString() { return s_MessageFilterString; } SetMessageFilterString(const wxString & val)504 static void SetMessageFilterString(const wxString& val) { s_MessageFilterString = val; } 505 static bool IsMessageFiltered(const wxString& message); ShowMessagesInLog()506 static bool ShowMessagesInLog() { return s_ShowMessagesInLog; } IsAdvancedSpamfilterEnabled()507 static bool IsAdvancedSpamfilterEnabled() { return s_IsAdvancedSpamfilterEnabled;} IsChatCaptchaEnabled()508 static bool IsChatCaptchaEnabled() { return IsAdvancedSpamfilterEnabled() && s_IsChatCaptchaEnabled; } 509 FilterComments()510 static bool FilterComments() { return s_FilterComments; } SetFilterComments(bool val)511 static void SetFilterComments(bool val) { s_FilterComments = val; } GetCommentFilterString()512 static const wxString& GetCommentFilterString() { return s_CommentFilterString; } SetCommentFilterString(const wxString & val)513 static void SetCommentFilterString(const wxString& val) { s_CommentFilterString = val; } 514 static bool IsCommentFiltered(const wxString& comment); 515 516 // Can't have it return a reference, will need a pointer later. GetProxyData()517 static const CProxyData *GetProxyData() { return &s_ProxyData; } 518 519 // Hidden files 520 ShareHiddenFiles()521 static bool ShareHiddenFiles() { return s_ShareHiddenFiles; } SetShareHiddenFiles(bool val)522 static void SetShareHiddenFiles(bool val) { s_ShareHiddenFiles = val; } 523 AutoSortDownload()524 static bool AutoSortDownload() { return s_AutoSortDownload; } AutoSortDownload(bool val)525 static bool AutoSortDownload(bool val) { bool tmp = s_AutoSortDownload; s_AutoSortDownload = val; return tmp; } 526 527 // Version check 528 GetCheckNewVersion()529 static bool GetCheckNewVersion() { return s_NewVersionCheck; } SetCheckNewVersion(bool val)530 static void SetCheckNewVersion(bool val) { s_NewVersionCheck = val; } 531 532 // Networks GetNetworkKademlia()533 static bool GetNetworkKademlia() { return s_ConnectToKad; } SetNetworkKademlia(bool val)534 static void SetNetworkKademlia(bool val) { s_ConnectToKad = val; } GetNetworkED2K()535 static bool GetNetworkED2K() { return s_ConnectToED2K; } SetNetworkED2K(bool val)536 static void SetNetworkED2K(bool val) { s_ConnectToED2K = val; } 537 538 // Statistics GetMaxClientVersions()539 static unsigned GetMaxClientVersions() { return s_maxClientVersions; } 540 541 // Dropping slow sources GetDropSlowSources()542 static bool GetDropSlowSources() { return s_DropSlowSources; } 543 544 // server.met and nodes.dat urls GetKadNodesUrl()545 static const wxString& GetKadNodesUrl() { return s_KadURL; } SetKadNodesUrl(const wxString & url)546 static void SetKadNodesUrl(const wxString& url) { s_KadURL = url; } 547 GetEd2kServersUrl()548 static const wxString& GetEd2kServersUrl() { return s_Ed2kURL; } SetEd2kServersUrl(const wxString & url)549 static void SetEd2kServersUrl(const wxString& url) { s_Ed2kURL = url; } 550 551 // Crypt IsClientCryptLayerSupported()552 static bool IsClientCryptLayerSupported() {return s_IsClientCryptLayerSupported;} IsClientCryptLayerRequested()553 static bool IsClientCryptLayerRequested() {return IsClientCryptLayerSupported() && s_bCryptLayerRequested;} IsClientCryptLayerRequired()554 static bool IsClientCryptLayerRequired() {return IsClientCryptLayerRequested() && s_IsClientCryptLayerRequired;} IsClientCryptLayerRequiredStrict()555 static bool IsClientCryptLayerRequiredStrict() {return false;} // not even incoming test connections will be answered IsServerCryptLayerUDPEnabled()556 static bool IsServerCryptLayerUDPEnabled() {return IsClientCryptLayerSupported();} IsServerCryptLayerTCPRequested()557 static bool IsServerCryptLayerTCPRequested() {return IsClientCryptLayerRequested();} IsServerCryptLayerTCPRequired()558 static bool IsServerCryptLayerTCPRequired() {return IsClientCryptLayerRequired();} GetKadUDPKey()559 static uint32 GetKadUDPKey() {return s_dwKadUDPKey;} GetCryptTCPPaddingLength()560 static uint8 GetCryptTCPPaddingLength() {return s_byCryptTCPPaddingLength;} 561 SetClientCryptLayerSupported(bool v)562 static void SetClientCryptLayerSupported(bool v) {s_IsClientCryptLayerSupported = v;} SetClientCryptLayerRequested(bool v)563 static void SetClientCryptLayerRequested(bool v) {s_bCryptLayerRequested = v; } SetClientCryptLayerRequired(bool v)564 static void SetClientCryptLayerRequired(bool v) {s_IsClientCryptLayerRequired = v;} 565 566 // GeoIP IsGeoIPEnabled()567 static bool IsGeoIPEnabled() {return s_GeoIPEnabled;} SetGeoIPEnabled(bool v)568 static void SetGeoIPEnabled(bool v) {s_GeoIPEnabled = v;} GetGeoIPUpdateUrl()569 static const wxString& GetGeoIPUpdateUrl() {return s_GeoIPUpdateUrl;} 570 571 // Stats server GetStatsServerName()572 static const wxString& GetStatsServerName() {return s_StatsServerName;} GetStatsServerURL()573 static const wxString& GetStatsServerURL() {return s_StatsServerURL;} 574 575 // HTTP download 576 static wxString GetLastHTTPDownloadURL(uint8 t); 577 static void SetLastHTTPDownloadURL(uint8 t, const wxString& val); 578 579 // Sleep GetPreventSleepWhileDownloading()580 static bool GetPreventSleepWhileDownloading() { return s_preventSleepWhileDownloading; } SetPreventSleepWhileDownloading(bool status)581 static void SetPreventSleepWhileDownloading(bool status) { s_preventSleepWhileDownloading = status; } 582 protected: 583 static int32 GetRecommendedMaxConnections(); 584 585 //! Temporary storage for statistic-colors. 586 static unsigned long s_colors[cntStatColors]; 587 //! Reference for checking if the colors has changed. 588 static unsigned long s_colors_ref[cntStatColors]; 589 590 typedef std::vector<Cfg_Base*> CFGList; 591 typedef std::map<int, Cfg_Base*> CFGMap; 592 typedef std::vector<Category_Struct*> CatList; 593 594 595 static CFGMap s_CfgList; 596 static CFGList s_MiscList; 597 CatList m_CatList; 598 599 private: 600 void LoadPreferences(); 601 void SavePreferences(); 602 603 protected: 604 static wxString s_configDir; 605 606 ////////////// USER 607 static wxString s_nick; 608 609 static CMD4Hash s_userhash; 610 611 static Cfg_Lang_Base * s_cfgLang; 612 613 ////////////// CONNECTION 614 static uint16 s_maxupload; 615 static uint16 s_maxdownload; 616 static uint16 s_slotallocation; 617 static wxString s_Addr; 618 static uint16 s_port; 619 static uint16 s_udpport; 620 static bool s_UDPEnable; 621 static uint16 s_maxconnections; 622 static bool s_reconnect; 623 static bool s_autoconnect; 624 static bool s_autoconnectstaticonly; 625 static bool s_UPnPEnabled; 626 static bool s_UPnPECEnabled; 627 static bool s_UPnPWebServerEnabled; 628 static uint16 s_UPnPTCPPort; 629 630 ////////////// PROXY 631 static CProxyData s_ProxyData; 632 633 ////////////// SERVERS 634 static bool s_autoserverlist; 635 static bool s_deadserver; 636 637 ////////////// FILES 638 static CPath s_incomingdir; 639 static CPath s_tempdir; 640 static bool s_ICH; 641 static bool s_AICHTrustEveryHash; 642 643 ////////////// GUI 644 static uint8 s_depth3D; 645 646 static bool s_scorsystem; 647 static bool s_hideonclose; 648 static bool s_mintotray; 649 static bool s_trayiconenabled; 650 static bool s_addnewfilespaused; 651 static bool s_addserversfromserver; 652 static bool s_addserversfromclient; 653 static uint16 s_maxsourceperfile; 654 static uint16 s_trafficOMeterInterval; 655 static uint16 s_statsInterval; 656 static uint32 s_maxGraphDownloadRate; 657 static uint32 s_maxGraphUploadRate; 658 static bool s_confirmExit; 659 660 661 static bool s_filterLanIP; 662 static bool s_paranoidfilter; 663 static bool s_onlineSig; 664 665 static wxString s_languageID; 666 static uint8 s_iSeeShares; // 0=everybody 1=friends only 2=noone 667 static uint8 s_iToolDelayTime; // tooltip delay time in seconds 668 static uint8 s_splitterbarPosition; 669 static uint16 s_deadserverretries; 670 static uint32 s_dwServerKeepAliveTimeoutMins; 671 672 static uint8 s_statsMax; 673 static uint8 s_statsAverageMinutes; 674 675 static bool s_bpreviewprio; 676 static bool s_smartidcheck; 677 static uint8 s_smartidstate; 678 static bool s_safeServerConnect; 679 static bool s_startMinimized; 680 static uint16 s_MaxConperFive; 681 static bool s_checkDiskspace; 682 static uint32 s_uMinFreeDiskSpace; 683 static wxString s_yourHostname; 684 static bool s_bVerbose; 685 static bool s_bVerboseLogfile; 686 static bool s_bmanualhighprio; 687 static bool s_bstartnextfile; 688 static bool s_bstartnextfilesame; 689 static bool s_bstartnextfilealpha; 690 static bool s_bshowoverhead; 691 static bool s_bDAP; 692 static bool s_bUAP; 693 694 #ifndef __SVN__ 695 static bool s_showVersionOnTitle; 696 #endif 697 static uint8_t s_showRatesOnTitle; // 0=no, 1=after app name, 2=before app name 698 699 static wxString s_VideoPlayer; 700 static bool s_showAllNotCats; 701 702 static bool s_msgonlyfriends; 703 static bool s_msgsecure; 704 705 static uint8 s_iFileBufferSize; 706 static uint8 s_iQueueSize; 707 708 static wxString s_datetimeformat; 709 710 static bool s_ToolbarOrientation; 711 712 // Web Server [kuchin] 713 static wxString s_sWebPassword; 714 static wxString s_sWebPath; 715 static wxString s_sWebLowPassword; 716 static uint16 s_nWebPort; 717 static uint16 s_nWebUPnPTCPPort; 718 static bool s_bWebEnabled; 719 static bool s_bWebUseGzip; 720 static uint32 s_nWebPageRefresh; 721 static bool s_bWebLowEnabled; 722 static wxString s_WebTemplate; 723 724 static bool s_showCatTabInfos; 725 static AllCategoryFilter s_allcatFilter; 726 727 // Kry - external connections 728 static bool s_AcceptExternalConnections; 729 static wxString s_ECAddr; 730 static uint32 s_ECPort; 731 static wxString s_ECPassword; 732 static bool s_TransmitOnlyUploadingClients; 733 734 // Kry - IPFilter 735 static bool s_IPFilterClients; 736 static bool s_IPFilterServers; 737 static uint8 s_filterlevel; 738 static bool s_IPFilterAutoLoad; 739 static wxString s_IPFilterURL; 740 static bool s_IPFilterSys; 741 742 // Kry - Source seeds on/off 743 static bool s_UseSrcSeeds; 744 745 static bool s_ProgBar; 746 static bool s_Percent; 747 748 static bool s_SecIdent; 749 750 static bool s_ExtractMetaData; 751 752 static bool s_allocFullFile; 753 static bool s_createFilesSparse; 754 755 static wxString s_CustomBrowser; 756 static bool s_BrowserTab; // Jacobo221 - Open in tabs if possible 757 758 static CPath s_OSDirectory; 759 static uint16 s_OSUpdate; 760 761 static wxString s_Skin; 762 763 static bool s_FastED2KLinksHandler; // Madcat - Toggle Fast ED2K Links Handler 764 765 // Message Filtering 766 static bool s_MustFilterMessages; 767 static wxString s_MessageFilterString; 768 static bool s_FilterAllMessages; 769 static bool s_FilterSomeMessages; 770 static bool s_ShowMessagesInLog; 771 static bool s_IsAdvancedSpamfilterEnabled; 772 static bool s_IsChatCaptchaEnabled; 773 774 static bool s_FilterComments; 775 static wxString s_CommentFilterString; 776 777 778 // Hidden files sharing 779 static bool s_ShareHiddenFiles; 780 781 static bool s_AutoSortDownload; 782 783 // Version check 784 static bool s_NewVersionCheck; 785 786 // Kad 787 static bool s_ConnectToKad; 788 static bool s_ConnectToED2K; 789 790 // Statistics 791 static unsigned s_maxClientVersions; // 0 = unlimited 792 793 // Drop slow sources if needed 794 static bool s_DropSlowSources; 795 796 static wxString s_Ed2kURL; 797 static wxString s_KadURL; 798 799 // Crypt 800 static bool s_IsClientCryptLayerSupported; 801 static bool s_IsClientCryptLayerRequired; 802 static bool s_bCryptLayerRequested; 803 static uint32 s_dwKadUDPKey; 804 static uint8 s_byCryptTCPPaddingLength; 805 806 // GeoIP 807 static bool s_GeoIPEnabled; 808 static wxString s_GeoIPUpdateUrl; 809 810 // Sleep vetoing 811 static bool s_preventSleepWhileDownloading; 812 813 // Stats server 814 static wxString s_StatsServerName; 815 static wxString s_StatsServerURL; 816 }; 817 818 819 #endif // PREFERENCES_H 820 // File_checked_for_headers 821