2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
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
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.
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
28 #include <ec/cpp/ECTag.h> // Needed for CECTag
29 #include <ec/cpp/ECSpecialTags.h> // Needed for special EC tag creator classes
31 #include "Preferences.h"
34 CEC_Category_Tag::CEC_Category_Tag(uint32 cat_index
, EC_DETAIL_LEVEL detail_level
) : CECTag(EC_TAG_CATEGORY
, cat_index
)
36 Category_Struct
*cat
= theApp
->glob_prefs
->GetCategory(cat_index
);
37 switch (detail_level
) {
38 case EC_DETAIL_UPDATE
:
39 case EC_DETAIL_INC_UPDATE
:
42 AddTag(CECTag(EC_TAG_CATEGORY_PATH
, cat
->path
.GetRaw()));
43 AddTag(CECTag(EC_TAG_CATEGORY_COMMENT
, cat
->comment
));
44 AddTag(CECTag(EC_TAG_CATEGORY_COLOR
, (uint32
)cat
->color
));
45 AddTag(CECTag(EC_TAG_CATEGORY_PRIO
, cat
->prio
));
47 AddTag(CECTag(EC_TAG_CATEGORY_TITLE
, cat
->title
));
51 CEC_Category_Tag::CEC_Category_Tag(uint32 cat_index
, wxString name
, wxString path
,
52 wxString comment
, uint32 color
, uint8 prio
) : CECTag(EC_TAG_CATEGORY
, cat_index
)
54 AddTag(CECTag(EC_TAG_CATEGORY_PATH
, path
));
55 AddTag(CECTag(EC_TAG_CATEGORY_COMMENT
, comment
));
56 AddTag(CECTag(EC_TAG_CATEGORY_COLOR
, color
));
57 AddTag(CECTag(EC_TAG_CATEGORY_PRIO
, prio
));
58 AddTag(CECTag(EC_TAG_CATEGORY_TITLE
, name
));
61 bool CEC_Category_Tag::Apply()
63 bool ret
= theApp
->glob_prefs
->UpdateCategory(GetInt(), Name(), CPath(Path()), Comment(), Color(), Prio());
65 GetTagByName(EC_TAG_CATEGORY_PATH
)->SetStringData(theApp
->glob_prefs
->GetCatPath(GetInt()).GetRaw());
70 bool CEC_Category_Tag::Create()
72 Category_Struct
* category
= NULL
;
73 bool ret
= theApp
->glob_prefs
->CreateCategory(category
, Name(), CPath(Path()), Comment(), Color(), Prio());
75 GetTagByName(EC_TAG_CATEGORY_PATH
)->SetStringData(theApp
->glob_prefs
->GetCatPath(
76 theApp
->glob_prefs
->GetCatCount() - 1).GetRaw());
81 CEC_Prefs_Packet::CEC_Prefs_Packet(uint32 selection
, EC_DETAIL_LEVEL pref_details
, EC_DETAIL_LEVEL cat_details
) : CECPacket(EC_OP_SET_PREFERENCES
, pref_details
)
83 if (selection
& EC_PREFS_CATEGORIES
) {
84 if (theApp
->glob_prefs
->GetCatCount() > 1) {
85 CECEmptyTag
cats(EC_TAG_PREFS_CATEGORIES
);
86 for (unsigned int i
= 0; i
< theApp
->glob_prefs
->GetCatCount(); ++i
) {
87 CEC_Category_Tag
catTag(i
, cat_details
);
94 if (selection
& EC_PREFS_GENERAL
) {
95 CECEmptyTag
user_prefs(EC_TAG_PREFS_GENERAL
);
96 user_prefs
.AddTag(CECTag(EC_TAG_USER_NICK
, thePrefs::GetUserNick()));
97 user_prefs
.AddTag(CECTag(EC_TAG_USER_HASH
, thePrefs::GetUserHash()));
98 user_prefs
.AddTag(CECTag(EC_TAG_USER_HOST
, thePrefs::GetYourHostname()));
102 if (selection
& EC_PREFS_CONNECTIONS
) {
103 CECEmptyTag
connPrefs(EC_TAG_PREFS_CONNECTIONS
);
104 connPrefs
.AddTag(CECTag(EC_TAG_CONN_UL_CAP
, thePrefs::GetMaxGraphUploadRate()));
105 connPrefs
.AddTag(CECTag(EC_TAG_CONN_DL_CAP
, thePrefs::GetMaxGraphDownloadRate()));
106 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_UL
, thePrefs::GetMaxUpload()));
107 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_DL
, thePrefs::GetMaxDownload()));
108 connPrefs
.AddTag(CECTag(EC_TAG_CONN_SLOT_ALLOCATION
, thePrefs::GetSlotAllocation()));
109 connPrefs
.AddTag(CECTag(EC_TAG_CONN_TCP_PORT
, thePrefs::GetPort()));
110 connPrefs
.AddTag(CECTag(EC_TAG_CONN_UDP_PORT
, thePrefs::GetUDPPort()));
111 if (thePrefs::IsUDPDisabled()) {
112 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_UDP_DISABLE
));
114 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_FILE_SOURCES
, thePrefs::GetMaxSourcePerFile()));
115 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_CONN
, thePrefs::GetMaxConnections()));
116 if (thePrefs::DoAutoConnect()) {
117 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_AUTOCONNECT
));
119 if (thePrefs::Reconnect()) {
120 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_RECONNECT
));
122 if (thePrefs::GetNetworkED2K()) {
123 connPrefs
.AddTag(CECEmptyTag(EC_TAG_NETWORK_ED2K
));
125 if (thePrefs::GetNetworkKademlia()) {
126 connPrefs
.AddTag(CECEmptyTag(EC_TAG_NETWORK_KADEMLIA
));
131 if (selection
& EC_PREFS_MESSAGEFILTER
) {
132 CECEmptyTag
msg_prefs(EC_TAG_PREFS_MESSAGEFILTER
);
133 if (thePrefs::MustFilterMessages()) {
134 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ENABLED
));
136 if (thePrefs::IsFilterAllMessages()) {
137 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ALL
));
139 if (thePrefs::MsgOnlyFriends()) {
140 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_FRIENDS
));
142 if (thePrefs::MsgOnlySecure()) {
143 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_SECURE
));
145 if (thePrefs::IsFilterByKeywords()) {
146 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_BY_KEYWORD
));
148 msg_prefs
.AddTag(CECTag(EC_TAG_MSGFILTER_KEYWORDS
, thePrefs::GetMessageFilterString()));
152 if (selection
& EC_PREFS_REMOTECONTROLS
) {
153 CECEmptyTag
rc_prefs(EC_TAG_PREFS_REMOTECTRL
);
154 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_PORT
, thePrefs::GetWSPort()));
155 if (thePrefs::GetWSIsEnabled()) {
156 rc_prefs
.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_AUTORUN
));
158 if (!thePrefs::GetWSPass().IsEmpty()) {
160 wxCHECK2(passhash
.Decode(thePrefs::GetWSPass()), /* Do nothing. */);
161 rc_prefs
.AddTag(CECTag(EC_TAG_PASSWD_HASH
, passhash
));
163 if (thePrefs::GetWSIsLowUserEnabled()) {
164 CECEmptyTag
lowUser(EC_TAG_WEBSERVER_GUEST
);
165 if (!thePrefs::GetWSLowPass().IsEmpty()) {
167 wxCHECK2(passhash
.Decode(thePrefs::GetWSLowPass()), /* Do nothing. */);
168 lowUser
.AddTag(CECTag(EC_TAG_PASSWD_HASH
, passhash
));
170 rc_prefs
.AddTag(lowUser
);
172 if (thePrefs::GetWebUseGzip()) {
173 rc_prefs
.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_USEGZIP
));
175 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_REFRESH
, thePrefs::GetWebPageRefresh()));
176 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_TEMPLATE
, thePrefs::GetWebTemplate()));
180 if (selection
& EC_PREFS_ONLINESIG
) {
181 CECEmptyTag
online_sig(EC_TAG_PREFS_ONLINESIG
);
182 if (thePrefs::IsOnlineSignatureEnabled()) {
183 online_sig
.AddTag(CECEmptyTag(EC_TAG_ONLINESIG_ENABLED
));
188 if (selection
& EC_PREFS_SERVERS
) {
189 CECEmptyTag
srv_prefs(EC_TAG_PREFS_SERVERS
);
190 if (thePrefs::DeadServer()) {
191 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_REMOVE_DEAD
));
193 srv_prefs
.AddTag(CECTag(EC_TAG_SERVERS_DEAD_SERVER_RETRIES
, (uint16
)thePrefs::GetDeadserverRetries()));
194 if (thePrefs::AutoServerlist()) {
195 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTO_UPDATE
));
197 // Here should come the URL list...
198 if (thePrefs::AddServersFromServer()) {
199 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_SERVER
));
201 if (thePrefs::AddServersFromClient()) {
202 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_CLIENT
));
204 if (thePrefs::Score()) {
205 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_USE_SCORE_SYSTEM
));
207 if (thePrefs::GetSmartIdCheck()) {
208 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_SMART_ID_CHECK
));
210 if (thePrefs::IsSafeServerConnectEnabled()) {
211 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_SAFE_SERVER_CONNECT
));
213 if (thePrefs::AutoConnectStaticOnly()) {
214 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY
));
216 if (thePrefs::IsManualHighPrio()) {
217 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_MANUAL_HIGH_PRIO
));
219 srv_prefs
.AddTag(CECTag(EC_TAG_SERVERS_UPDATE_URL
, thePrefs::GetEd2kServersUrl()));
223 if (selection
& EC_PREFS_FILES
) {
224 CECEmptyTag
filePrefs(EC_TAG_PREFS_FILES
);
225 if (thePrefs::IsICHEnabled()) {
226 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_ICH_ENABLED
));
228 if (thePrefs::IsTrustingEveryHash()) {
229 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_AICH_TRUST
));
231 if (thePrefs::AddNewFilesPaused()) {
232 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_PAUSED
));
234 if (thePrefs::GetNewAutoDown()) {
235 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_DL_PRIO
));
237 if (thePrefs::GetPreviewPrio()) {
238 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_PREVIEW_PRIO
));
240 if (thePrefs::GetNewAutoUp()) {
241 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_UL_PRIO
));
243 if (thePrefs::TransferFullChunks()) {
244 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_UL_FULL_CHUNKS
));
246 if (thePrefs::StartNextFile()) {
247 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_START_NEXT_PAUSED
));
249 if (thePrefs::StartNextFileSame()) {
250 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_RESUME_SAME_CAT
));
252 if (thePrefs::GetSrcSeedsOn()) {
253 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_SAVE_SOURCES
));
255 if (thePrefs::GetExtractMetaData()) {
256 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_EXTRACT_METADATA
));
258 if (thePrefs::GetAllocFullFile()) {
259 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_ALLOC_FULL_SIZE
));
261 if (thePrefs::IsCheckDiskspaceEnabled()) {
262 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_CHECK_FREE_SPACE
));
264 filePrefs
.AddTag(CECTag(EC_TAG_FILES_MIN_FREE_SPACE
, thePrefs::GetMinFreeDiskSpaceMB()));
268 if (selection
& EC_PREFS_SRCDROP
) {
269 CECEmptyTag
srcdrop(EC_TAG_PREFS_SRCDROP
);
270 srcdrop
.AddTag(CECTag(EC_TAG_SRCDROP_NONEEDED
, (uint8
)thePrefs::GetNoNeededSources()));
271 if (thePrefs::DropFullQueueSources()) {
272 srcdrop
.AddTag(CECEmptyTag(EC_TAG_SRCDROP_DROP_FQS
));
274 if (thePrefs::DropHighQueueRankingSources()) {
275 srcdrop
.AddTag(CECEmptyTag(EC_TAG_SRCDROP_DROP_HQRS
));
277 srcdrop
.AddTag(CECTag(EC_TAG_SRCDROP_HQRS_VALUE
, (uint16
)thePrefs::HighQueueRanking()));
278 srcdrop
.AddTag(CECTag(EC_TAG_SRCDROP_AUTODROP_TIMER
, (uint16
)thePrefs::GetAutoDropTimer()));
282 if (selection
& EC_PREFS_DIRECTORIES
) {
283 CECEmptyTag
dirPrefs(EC_TAG_PREFS_DIRECTORIES
);
284 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_INCOMING
, thePrefs::GetIncomingDir().GetRaw()));
285 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_TEMP
, thePrefs::GetTempDir().GetRaw()));
286 uint32 sharedDirs
= theApp
->glob_prefs
->shareddir_list
.size();
287 CECTag
dirtag(EC_TAG_DIRECTORIES_SHARED
, sharedDirs
);
288 for (size_t i
= 0; i
< sharedDirs
; i
++) {
289 dirtag
.AddTag(CECTag(EC_TAG_STRING
, theApp
->glob_prefs
->shareddir_list
[i
].GetRaw()));
291 dirPrefs
.AddTag(dirtag
);
292 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_SHARE_HIDDEN
, thePrefs::ShareHiddenFiles()));
296 if (selection
& EC_PREFS_STATISTICS
) {
300 if (selection
& EC_PREFS_SECURITY
) {
301 CECEmptyTag
secPrefs(EC_TAG_PREFS_SECURITY
);
302 secPrefs
.AddTag(CECTag(EC_TAG_SECURITY_CAN_SEE_SHARES
, thePrefs::CanSeeShares()));
303 if (thePrefs::IsFilteringClients()) {
304 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_CLIENTS
));
306 if (thePrefs::IsFilteringServers()) {
307 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_SERVERS
));
309 if (thePrefs::IPFilterAutoLoad()) {
310 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_AUTO_UPDATE
));
312 secPrefs
.AddTag(CECTag(EC_TAG_IPFILTER_UPDATE_URL
, thePrefs::IPFilterURL()));
313 secPrefs
.AddTag(CECTag(EC_TAG_IPFILTER_LEVEL
, thePrefs::GetIPFilterLevel()));
314 if (thePrefs::FilterLanIPs()) {
315 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_FILTER_LAN
));
317 if (thePrefs::IsSecureIdentEnabled()) {
318 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_USE_SECIDENT
));
321 if (thePrefs::IsClientCryptLayerSupported()) {
322 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_SUPPORTED
));
324 if (thePrefs::IsClientCryptLayerRequested()) {
325 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUESTED
));
327 if (thePrefs::IsClientCryptLayerRequired()) {
328 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUIRED
));
334 if (selection
& EC_PREFS_CORETWEAKS
) {
335 CECEmptyTag
cwPrefs(EC_TAG_PREFS_CORETWEAKS
);
336 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_MAX_CONN_PER_FIVE
, thePrefs::GetMaxConperFive()));
337 if (thePrefs::GetVerbose()) {
338 cwPrefs
.AddTag(CECEmptyTag(EC_TAG_CORETW_VERBOSE
));
340 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_FILEBUFFER
, thePrefs::GetFileBufferSize()));
341 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_UL_QUEUE
, thePrefs::GetQueueSize()));
342 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT
, thePrefs::GetServerKeepAliveTimeout()));
346 if (selection
& EC_PREFS_KADEMLIA
) {
347 CECEmptyTag
kadPrefs(EC_TAG_PREFS_KADEMLIA
);
348 kadPrefs
.AddTag(CECTag(EC_TAG_KADEMLIA_UPDATE_URL
, thePrefs::GetKadNodesUrl()));
354 * Applies a boolean value from the set_preferences request
356 * @param use_tag If true, an unset variable means "leave unchanged". If false, an unset variable means false.
357 * @param thisTab The TAG that contains the TAG with a boolean value
358 * @param applyFunc The function to use for applying the value
359 * @param tagName The name of the TAG that holds the boolean value
361 void ApplyBoolean(bool use_tag
, const CECTag
*thisTab
, void (applyFunc
)(bool), int tagName
)
363 const CECTag
*boolTag
= thisTab
->GetTagByName(tagName
);
365 if (boolTag
!= NULL
) {
366 applyFunc(boolTag
->GetInt() != 0);
369 applyFunc(boolTag
!= NULL
);
374 * This will set all preferences except of categories, which are work as following:
375 * -> On remote gui they are loaded on startup, and then changed on-command
376 * -> Webserver doesn't supposed to change it.
378 void CEC_Prefs_Packet::Apply()
380 const CECTag
*thisTab
= NULL
;
381 const CECTag
*oneTag
= NULL
;
383 if ((thisTab
= GetTagByName(EC_TAG_PREFS_GENERAL
)) != NULL
) {
384 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_NICK
)) != NULL
) {
385 thePrefs::SetUserNick(oneTag
->GetStringData());
387 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_HASH
)) != NULL
) {
388 thePrefs::SetUserHash(oneTag
->GetMD4Data());
390 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_HOST
)) != NULL
) {
391 thePrefs::SetYourHostname(oneTag
->GetStringData());
396 // webserver doesn't transmit all boolean values
398 bool use_tag
= (GetDetailLevel() == EC_DETAIL_FULL
);
400 if ((thisTab
= GetTagByName(EC_TAG_PREFS_CONNECTIONS
)) != NULL
) {
401 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_UL_CAP
)) != NULL
) {
402 thePrefs::SetMaxGraphUploadRate(oneTag
->GetInt());
404 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_DL_CAP
)) != NULL
) {
405 thePrefs::SetMaxGraphDownloadRate(oneTag
->GetInt());
407 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_UL
)) != NULL
) {
408 thePrefs::SetMaxUpload(oneTag
->GetInt());
410 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_DL
)) != NULL
) {
411 thePrefs::SetMaxDownload(oneTag
->GetInt());
413 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_SLOT_ALLOCATION
)) != NULL
) {
414 thePrefs::SetSlotAllocation(oneTag
->GetInt());
416 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_TCP_PORT
)) != NULL
) {
417 thePrefs::SetPort(oneTag
->GetInt());
419 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_UDP_PORT
)) != NULL
) {
420 thePrefs::SetUDPPort(oneTag
->GetInt());
422 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetUDPDisable
, EC_TAG_CONN_UDP_DISABLE
);
423 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_FILE_SOURCES
)) != NULL
) {
424 thePrefs::SetMaxSourcesPerFile(oneTag
->GetInt());
426 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_CONN
)) != NULL
) {
427 thePrefs::SetMaxConnections(oneTag
->GetInt());
429 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoConnect
, EC_TAG_CONN_AUTOCONNECT
);
430 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetReconnect
, EC_TAG_CONN_RECONNECT
);
431 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNetworkED2K
, EC_TAG_NETWORK_ED2K
);
432 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNetworkKademlia
, EC_TAG_NETWORK_KADEMLIA
);
435 if ((thisTab
= GetTagByName(EC_TAG_PREFS_MESSAGEFILTER
)) != NULL
) {
436 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMustFilterMessages
, EC_TAG_MSGFILTER_ENABLED
);
437 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterAllMessages
, EC_TAG_MSGFILTER_ALL
);
438 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMsgOnlyFriends
, EC_TAG_MSGFILTER_FRIENDS
);
439 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMsgOnlySecure
, EC_TAG_MSGFILTER_SECURE
);
440 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterByKeywords
, EC_TAG_MSGFILTER_BY_KEYWORD
);
441 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_MSGFILTER_KEYWORDS
)) != NULL
) {
442 thePrefs::SetMessageFilterString(oneTag
->GetStringData());
446 if ((thisTab
= GetTagByName(EC_TAG_PREFS_REMOTECTRL
)) != NULL
) {
447 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWSIsEnabled
, EC_TAG_WEBSERVER_AUTORUN
);
448 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_PORT
)) != NULL
) {
449 thePrefs::SetWSPort(oneTag
->GetInt());
451 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_PASSWD_HASH
)) != NULL
) {
452 thePrefs::SetWSPass(oneTag
->GetMD4Data().Encode());
454 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWSIsLowUserEnabled
, EC_TAG_WEBSERVER_GUEST
);
455 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_GUEST
)) != NULL
) {
456 if ((oneTag
->GetTagByName(EC_TAG_PASSWD_HASH
)) != NULL
) {
457 thePrefs::SetWSLowPass(oneTag
->GetTagByName(EC_TAG_PASSWD_HASH
)->GetMD4Data().Encode());
460 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWebUseGzip
, EC_TAG_WEBSERVER_USEGZIP
);
461 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_REFRESH
)) != NULL
) {
462 thePrefs::SetWebPageRefresh(oneTag
->GetInt());
464 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_TEMPLATE
)) != NULL
) {
465 thePrefs::SetWebTemplate(oneTag
->GetStringData());
469 if ((thisTab
= GetTagByName(EC_TAG_PREFS_ONLINESIG
)) != NULL
) {
470 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetOnlineSignatureEnabled
, EC_TAG_ONLINESIG_ENABLED
);
473 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SERVERS
)) != NULL
) {
474 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetDeadServer
, EC_TAG_SERVERS_REMOVE_DEAD
);
475 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SERVERS_DEAD_SERVER_RETRIES
)) != NULL
) {
476 thePrefs::SetDeadserverRetries(oneTag
->GetInt());
478 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoServerlist
, EC_TAG_SERVERS_AUTO_UPDATE
);
479 // Here should come the URL list...
480 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddServersFromServer
, EC_TAG_SERVERS_ADD_FROM_SERVER
);
481 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddServersFromClient
, EC_TAG_SERVERS_ADD_FROM_CLIENT
);
482 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetScoreSystem
, EC_TAG_SERVERS_USE_SCORE_SYSTEM
);
483 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSmartIdCheck
, EC_TAG_SERVERS_SMART_ID_CHECK
);
484 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSafeServerConnectEnabled
, EC_TAG_SERVERS_SAFE_SERVER_CONNECT
);
485 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoConnectStaticOnly
, EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY
);
486 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetManualHighPrio
, EC_TAG_SERVERS_MANUAL_HIGH_PRIO
);
487 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SERVERS_UPDATE_URL
)) != NULL
) {
488 thePrefs::SetEd2kServersUrl(oneTag
->GetStringData());
492 if ((thisTab
= GetTagByName(EC_TAG_PREFS_FILES
)) != NULL
) {
493 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetICHEnabled
, EC_TAG_FILES_ICH_ENABLED
);
494 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetTrustingEveryHash
, EC_TAG_FILES_AICH_TRUST
);
495 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddNewFilesPaused
, EC_TAG_FILES_NEW_PAUSED
);
496 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNewAutoDown
, EC_TAG_FILES_NEW_AUTO_DL_PRIO
);
497 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetPreviewPrio
, EC_TAG_FILES_PREVIEW_PRIO
);
498 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNewAutoUp
, EC_TAG_FILES_NEW_AUTO_UL_PRIO
);
499 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetTransferFullChunks
, EC_TAG_FILES_UL_FULL_CHUNKS
);
500 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetStartNextFile
, EC_TAG_FILES_START_NEXT_PAUSED
);
501 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetStartNextFileSame
, EC_TAG_FILES_RESUME_SAME_CAT
);
502 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSrcSeedsOn
, EC_TAG_FILES_SAVE_SOURCES
);
503 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetExtractMetaData
, EC_TAG_FILES_EXTRACT_METADATA
);
504 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAllocFullFile
, EC_TAG_FILES_ALLOC_FULL_SIZE
);
505 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetCheckDiskspaceEnabled
, EC_TAG_FILES_CHECK_FREE_SPACE
);
506 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_FILES_MIN_FREE_SPACE
)) != NULL
) {
507 thePrefs::SetMinFreeDiskSpaceMB(oneTag
->GetInt());
511 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SRCDROP
)) != NULL
) {
512 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SRCDROP_NONEEDED
)) != NULL
) {
513 thePrefs::SetNoNeededSources(oneTag
->GetInt());
515 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetDropFullQueueSources
, EC_TAG_SRCDROP_DROP_FQS
);
516 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetDropHighQueueRankingSources
, EC_TAG_SRCDROP_DROP_HQRS
);
517 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SRCDROP_HQRS_VALUE
)) != NULL
) {
518 thePrefs::SetHighQueueRanking(oneTag
->GetInt());
520 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SRCDROP_AUTODROP_TIMER
)) != NULL
) {
521 thePrefs::SetAutoDropTimer(oneTag
->GetInt());
525 if ((thisTab
= GetTagByName(EC_TAG_PREFS_DIRECTORIES
)) != NULL
) {
526 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_INCOMING
)) != NULL
) {
527 thePrefs::SetIncomingDir(CPath(oneTag
->GetStringData()));
529 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_TEMP
)) != NULL
) {
530 thePrefs::SetTempDir(CPath(oneTag
->GetStringData()));
532 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_SHARED
)) != NULL
) {
533 theApp
->glob_prefs
->shareddir_list
.clear();
534 for (unsigned int i
= 0; i
< oneTag
->GetTagCount(); i
++) {
535 const CECTag
*dirTag
= oneTag
->GetTagByIndex(i
);
536 theApp
->glob_prefs
->shareddir_list
.push_back(CPath(dirTag
->GetStringData()));
539 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetShareHiddenFiles
, EC_TAG_DIRECTORIES_SHARE_HIDDEN
);
542 if ((thisTab
= GetTagByName(EC_TAG_PREFS_STATISTICS
)) != NULL
) {
546 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SECURITY
)) != NULL
) {
547 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SECURITY_CAN_SEE_SHARES
)) != NULL
) {
548 thePrefs::SetCanSeeShares(oneTag
->GetInt());
550 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilteringClients
, EC_TAG_IPFILTER_CLIENTS
);
551 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilteringServers
, EC_TAG_IPFILTER_SERVERS
);
552 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetIPFilterAutoLoad
, EC_TAG_IPFILTER_AUTO_UPDATE
);
553 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_IPFILTER_UPDATE_URL
)) != NULL
) {
554 thePrefs::SetIPFilterURL(oneTag
->GetStringData());
556 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_IPFILTER_LEVEL
)) != NULL
) {
557 thePrefs::SetIPFilterLevel(oneTag
->GetInt());
559 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterLanIPs
, EC_TAG_IPFILTER_FILTER_LAN
);
560 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSecureIdentEnabled
, EC_TAG_SECURITY_USE_SECIDENT
);
562 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerSupported
, EC_TAG_SECURITY_OBFUSCATION_SUPPORTED
);
563 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerRequested
, EC_TAG_SECURITY_OBFUSCATION_REQUESTED
);
564 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerRequired
, EC_TAG_SECURITY_OBFUSCATION_REQUIRED
);
567 if ((thisTab
= GetTagByName(EC_TAG_PREFS_CORETWEAKS
)) != NULL
) {
568 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_MAX_CONN_PER_FIVE
)) != NULL
) {
569 thePrefs::SetMaxConsPerFive(oneTag
->GetInt());
571 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetVerbose
, EC_TAG_CORETW_VERBOSE
);
572 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_FILEBUFFER
)) != NULL
) {
573 thePrefs::SetFileBufferSize(oneTag
->GetInt());
575 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_UL_QUEUE
)) != NULL
) {
576 thePrefs::SetQueueSize(oneTag
->GetInt());
578 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT
)) != NULL
) {
579 thePrefs::SetServerKeepAliveTimeout(oneTag
->GetInt());
583 if ((thisTab
= GetTagByName(EC_TAG_PREFS_KADEMLIA
)) != NULL
) {
584 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_KADEMLIA_UPDATE_URL
)) != NULL
) {
585 thePrefs::SetKadNodesUrl(oneTag
->GetStringData());
589 theApp
->glob_prefs
->Save();
591 // File_checked_for_headers