2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2011 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2003-2011 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()));
99 user_prefs
.AddTag(CECTag(EC_TAG_GENERAL_CHECK_NEW_VERSION
, thePrefs::GetCheckNewVersion()));
103 if (selection
& EC_PREFS_CONNECTIONS
) {
104 CECEmptyTag
connPrefs(EC_TAG_PREFS_CONNECTIONS
);
105 connPrefs
.AddTag(CECTag(EC_TAG_CONN_UL_CAP
, thePrefs::GetMaxGraphUploadRate()));
106 connPrefs
.AddTag(CECTag(EC_TAG_CONN_DL_CAP
, thePrefs::GetMaxGraphDownloadRate()));
107 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_UL
, thePrefs::GetMaxUpload()));
108 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_DL
, thePrefs::GetMaxDownload()));
109 connPrefs
.AddTag(CECTag(EC_TAG_CONN_SLOT_ALLOCATION
, thePrefs::GetSlotAllocation()));
110 connPrefs
.AddTag(CECTag(EC_TAG_CONN_TCP_PORT
, thePrefs::GetPort()));
111 connPrefs
.AddTag(CECTag(EC_TAG_CONN_UDP_PORT
, thePrefs::GetUDPPort()));
112 if (thePrefs::IsUDPDisabled()) {
113 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_UDP_DISABLE
));
115 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_FILE_SOURCES
, thePrefs::GetMaxSourcePerFile()));
116 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_CONN
, thePrefs::GetMaxConnections()));
117 if (thePrefs::DoAutoConnect()) {
118 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_AUTOCONNECT
));
120 if (thePrefs::Reconnect()) {
121 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_RECONNECT
));
123 if (thePrefs::GetNetworkED2K()) {
124 connPrefs
.AddTag(CECEmptyTag(EC_TAG_NETWORK_ED2K
));
126 if (thePrefs::GetNetworkKademlia()) {
127 connPrefs
.AddTag(CECEmptyTag(EC_TAG_NETWORK_KADEMLIA
));
132 if (selection
& EC_PREFS_MESSAGEFILTER
) {
133 CECEmptyTag
msg_prefs(EC_TAG_PREFS_MESSAGEFILTER
);
134 if (thePrefs::MustFilterMessages()) {
135 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ENABLED
));
137 if (thePrefs::IsFilterAllMessages()) {
138 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ALL
));
140 if (thePrefs::MsgOnlyFriends()) {
141 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_FRIENDS
));
143 if (thePrefs::MsgOnlySecure()) {
144 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_SECURE
));
146 if (thePrefs::IsFilterByKeywords()) {
147 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_BY_KEYWORD
));
149 msg_prefs
.AddTag(CECTag(EC_TAG_MSGFILTER_KEYWORDS
, thePrefs::GetMessageFilterString()));
153 if (selection
& EC_PREFS_REMOTECONTROLS
) {
154 CECEmptyTag
rc_prefs(EC_TAG_PREFS_REMOTECTRL
);
155 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_PORT
, thePrefs::GetWSPort()));
156 if (thePrefs::GetWSIsEnabled()) {
157 rc_prefs
.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_AUTORUN
));
159 if (!thePrefs::GetWSPass().IsEmpty()) {
161 wxCHECK2(passhash
.Decode(thePrefs::GetWSPass()), /* Do nothing. */);
162 rc_prefs
.AddTag(CECTag(EC_TAG_PASSWD_HASH
, passhash
));
164 if (thePrefs::GetWSIsLowUserEnabled()) {
165 CECEmptyTag
lowUser(EC_TAG_WEBSERVER_GUEST
);
166 if (!thePrefs::GetWSLowPass().IsEmpty()) {
168 wxCHECK2(passhash
.Decode(thePrefs::GetWSLowPass()), /* Do nothing. */);
169 lowUser
.AddTag(CECTag(EC_TAG_PASSWD_HASH
, passhash
));
171 rc_prefs
.AddTag(lowUser
);
173 if (thePrefs::GetWebUseGzip()) {
174 rc_prefs
.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_USEGZIP
));
176 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_REFRESH
, thePrefs::GetWebPageRefresh()));
177 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_TEMPLATE
, thePrefs::GetWebTemplate()));
181 if (selection
& EC_PREFS_ONLINESIG
) {
182 CECEmptyTag
online_sig(EC_TAG_PREFS_ONLINESIG
);
183 if (thePrefs::IsOnlineSignatureEnabled()) {
184 online_sig
.AddTag(CECEmptyTag(EC_TAG_ONLINESIG_ENABLED
));
189 if (selection
& EC_PREFS_SERVERS
) {
190 CECEmptyTag
srv_prefs(EC_TAG_PREFS_SERVERS
);
191 if (thePrefs::DeadServer()) {
192 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_REMOVE_DEAD
));
194 srv_prefs
.AddTag(CECTag(EC_TAG_SERVERS_DEAD_SERVER_RETRIES
, (uint16
)thePrefs::GetDeadserverRetries()));
195 if (thePrefs::AutoServerlist()) {
196 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTO_UPDATE
));
198 // Here should come the URL list...
199 if (thePrefs::AddServersFromServer()) {
200 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_SERVER
));
202 if (thePrefs::AddServersFromClient()) {
203 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_CLIENT
));
205 if (thePrefs::Score()) {
206 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_USE_SCORE_SYSTEM
));
208 if (thePrefs::GetSmartIdCheck()) {
209 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_SMART_ID_CHECK
));
211 if (thePrefs::IsSafeServerConnectEnabled()) {
212 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_SAFE_SERVER_CONNECT
));
214 if (thePrefs::AutoConnectStaticOnly()) {
215 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY
));
217 if (thePrefs::IsManualHighPrio()) {
218 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_MANUAL_HIGH_PRIO
));
220 srv_prefs
.AddTag(CECTag(EC_TAG_SERVERS_UPDATE_URL
, thePrefs::GetEd2kServersUrl()));
224 if (selection
& EC_PREFS_FILES
) {
225 CECEmptyTag
filePrefs(EC_TAG_PREFS_FILES
);
226 if (thePrefs::IsICHEnabled()) {
227 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_ICH_ENABLED
));
229 if (thePrefs::IsTrustingEveryHash()) {
230 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_AICH_TRUST
));
232 if (thePrefs::AddNewFilesPaused()) {
233 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_PAUSED
));
235 if (thePrefs::GetNewAutoDown()) {
236 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_DL_PRIO
));
238 if (thePrefs::GetPreviewPrio()) {
239 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_PREVIEW_PRIO
));
241 if (thePrefs::GetNewAutoUp()) {
242 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_UL_PRIO
));
244 if (thePrefs::StartNextFile()) {
245 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_START_NEXT_PAUSED
));
247 if (thePrefs::StartNextFileSame()) {
248 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_RESUME_SAME_CAT
));
250 if (thePrefs::GetSrcSeedsOn()) {
251 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_SAVE_SOURCES
));
253 if (thePrefs::GetExtractMetaData()) {
254 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_EXTRACT_METADATA
));
256 if (thePrefs::GetAllocFullFile()) {
257 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_ALLOC_FULL_SIZE
));
259 if (thePrefs::IsCheckDiskspaceEnabled()) {
260 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_CHECK_FREE_SPACE
));
262 filePrefs
.AddTag(CECTag(EC_TAG_FILES_MIN_FREE_SPACE
, thePrefs::GetMinFreeDiskSpaceMB()));
263 if (!thePrefs::CreateFilesSparse()) {
264 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_CREATE_NORMAL
));
269 if (selection
& EC_PREFS_DIRECTORIES
) {
270 CECEmptyTag
dirPrefs(EC_TAG_PREFS_DIRECTORIES
);
271 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_INCOMING
, thePrefs::GetIncomingDir().GetRaw()));
272 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_TEMP
, thePrefs::GetTempDir().GetRaw()));
273 uint32 sharedDirs
= theApp
->glob_prefs
->shareddir_list
.size();
274 CECTag
dirtag(EC_TAG_DIRECTORIES_SHARED
, sharedDirs
);
275 for (size_t i
= 0; i
< sharedDirs
; i
++) {
276 dirtag
.AddTag(CECTag(EC_TAG_STRING
, theApp
->glob_prefs
->shareddir_list
[i
].GetRaw()));
278 dirPrefs
.AddTag(dirtag
);
279 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_SHARE_HIDDEN
, thePrefs::ShareHiddenFiles()));
283 if (selection
& EC_PREFS_STATISTICS
) {
287 if (selection
& EC_PREFS_SECURITY
) {
288 CECEmptyTag
secPrefs(EC_TAG_PREFS_SECURITY
);
289 secPrefs
.AddTag(CECTag(EC_TAG_SECURITY_CAN_SEE_SHARES
, thePrefs::CanSeeShares()));
290 if (thePrefs::IsFilteringClients()) {
291 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_CLIENTS
));
293 if (thePrefs::IsFilteringServers()) {
294 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_SERVERS
));
296 if (thePrefs::IPFilterAutoLoad()) {
297 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_AUTO_UPDATE
));
299 secPrefs
.AddTag(CECTag(EC_TAG_IPFILTER_UPDATE_URL
, thePrefs::IPFilterURL()));
300 secPrefs
.AddTag(CECTag(EC_TAG_IPFILTER_LEVEL
, thePrefs::GetIPFilterLevel()));
301 if (thePrefs::FilterLanIPs()) {
302 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_FILTER_LAN
));
304 if (thePrefs::IsSecureIdentEnabled()) {
305 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_USE_SECIDENT
));
308 if (thePrefs::IsClientCryptLayerSupported()) {
309 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_SUPPORTED
));
311 if (thePrefs::IsClientCryptLayerRequested()) {
312 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUESTED
));
314 if (thePrefs::IsClientCryptLayerRequired()) {
315 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUIRED
));
321 if (selection
& EC_PREFS_CORETWEAKS
) {
322 CECEmptyTag
cwPrefs(EC_TAG_PREFS_CORETWEAKS
);
323 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_MAX_CONN_PER_FIVE
, thePrefs::GetMaxConperFive()));
324 if (thePrefs::GetVerbose()) {
325 cwPrefs
.AddTag(CECEmptyTag(EC_TAG_CORETW_VERBOSE
));
327 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_FILEBUFFER
, thePrefs::GetFileBufferSize()));
328 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_UL_QUEUE
, thePrefs::GetQueueSize()));
329 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT
, thePrefs::GetServerKeepAliveTimeout()));
333 if (selection
& EC_PREFS_KADEMLIA
) {
334 CECEmptyTag
kadPrefs(EC_TAG_PREFS_KADEMLIA
);
335 kadPrefs
.AddTag(CECTag(EC_TAG_KADEMLIA_UPDATE_URL
, thePrefs::GetKadNodesUrl()));
341 * Applies a boolean value from the set_preferences request
343 * @param use_tag If true, an unset variable means "leave unchanged". If false, an unset variable means false.
344 * @param thisTab The TAG that contains the TAG with a boolean value
345 * @param applyFunc The function to use for applying the value
346 * @param tagName The name of the TAG that holds the boolean value
348 void ApplyBoolean(bool use_tag
, const CECTag
*thisTab
, void (applyFunc
)(bool), int tagName
)
350 const CECTag
*boolTag
= thisTab
->GetTagByName(tagName
);
352 if (boolTag
!= NULL
) {
353 applyFunc(boolTag
->GetInt() != 0);
356 applyFunc(boolTag
!= NULL
);
361 * This will set all preferences except of categories, which are work as following:
362 * -> On remote gui they are loaded on startup, and then changed on-command
363 * -> Webserver doesn't supposed to change it.
365 void CEC_Prefs_Packet::Apply() const
367 const CECTag
*thisTab
= NULL
;
368 const CECTag
*oneTag
= NULL
;
370 if ((thisTab
= GetTagByName(EC_TAG_PREFS_GENERAL
)) != NULL
) {
371 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_NICK
)) != NULL
) {
372 thePrefs::SetUserNick(oneTag
->GetStringData());
374 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_HASH
)) != NULL
) {
375 thePrefs::SetUserHash(oneTag
->GetMD4Data());
377 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_HOST
)) != NULL
) {
378 thePrefs::SetYourHostname(oneTag
->GetStringData());
380 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_GENERAL_CHECK_NEW_VERSION
)) != NULL
) {
381 thePrefs::SetCheckNewVersion(oneTag
->GetInt() != 0);
386 // webserver doesn't transmit all boolean values
388 bool use_tag
= (GetDetailLevel() == EC_DETAIL_FULL
);
390 if ((thisTab
= GetTagByName(EC_TAG_PREFS_CONNECTIONS
)) != NULL
) {
391 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_UL_CAP
)) != NULL
) {
392 thePrefs::SetMaxGraphUploadRate(oneTag
->GetInt());
394 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_DL_CAP
)) != NULL
) {
395 thePrefs::SetMaxGraphDownloadRate(oneTag
->GetInt());
397 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_UL
)) != NULL
) {
398 thePrefs::SetMaxUpload(oneTag
->GetInt());
400 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_DL
)) != NULL
) {
401 thePrefs::SetMaxDownload(oneTag
->GetInt());
403 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_SLOT_ALLOCATION
)) != NULL
) {
404 thePrefs::SetSlotAllocation(oneTag
->GetInt());
406 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_TCP_PORT
)) != NULL
) {
407 thePrefs::SetPort(oneTag
->GetInt());
409 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_UDP_PORT
)) != NULL
) {
410 thePrefs::SetUDPPort(oneTag
->GetInt());
412 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetUDPDisable
, EC_TAG_CONN_UDP_DISABLE
);
413 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_FILE_SOURCES
)) != NULL
) {
414 thePrefs::SetMaxSourcesPerFile(oneTag
->GetInt());
416 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_CONN
)) != NULL
) {
417 thePrefs::SetMaxConnections(oneTag
->GetInt());
419 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoConnect
, EC_TAG_CONN_AUTOCONNECT
);
420 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetReconnect
, EC_TAG_CONN_RECONNECT
);
421 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNetworkED2K
, EC_TAG_NETWORK_ED2K
);
422 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNetworkKademlia
, EC_TAG_NETWORK_KADEMLIA
);
425 if ((thisTab
= GetTagByName(EC_TAG_PREFS_MESSAGEFILTER
)) != NULL
) {
426 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMustFilterMessages
, EC_TAG_MSGFILTER_ENABLED
);
427 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterAllMessages
, EC_TAG_MSGFILTER_ALL
);
428 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMsgOnlyFriends
, EC_TAG_MSGFILTER_FRIENDS
);
429 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMsgOnlySecure
, EC_TAG_MSGFILTER_SECURE
);
430 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterByKeywords
, EC_TAG_MSGFILTER_BY_KEYWORD
);
431 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_MSGFILTER_KEYWORDS
)) != NULL
) {
432 thePrefs::SetMessageFilterString(oneTag
->GetStringData());
436 if ((thisTab
= GetTagByName(EC_TAG_PREFS_REMOTECTRL
)) != NULL
) {
437 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWSIsEnabled
, EC_TAG_WEBSERVER_AUTORUN
);
438 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_PORT
)) != NULL
) {
439 thePrefs::SetWSPort(oneTag
->GetInt());
441 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_PASSWD_HASH
)) != NULL
) {
442 thePrefs::SetWSPass(oneTag
->GetMD4Data().Encode());
444 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWSIsLowUserEnabled
, EC_TAG_WEBSERVER_GUEST
);
445 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_GUEST
)) != NULL
) {
446 if ((oneTag
->GetTagByName(EC_TAG_PASSWD_HASH
)) != NULL
) {
447 thePrefs::SetWSLowPass(oneTag
->GetTagByName(EC_TAG_PASSWD_HASH
)->GetMD4Data().Encode());
450 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWebUseGzip
, EC_TAG_WEBSERVER_USEGZIP
);
451 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_REFRESH
)) != NULL
) {
452 thePrefs::SetWebPageRefresh(oneTag
->GetInt());
454 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_TEMPLATE
)) != NULL
) {
455 thePrefs::SetWebTemplate(oneTag
->GetStringData());
459 if ((thisTab
= GetTagByName(EC_TAG_PREFS_ONLINESIG
)) != NULL
) {
460 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetOnlineSignatureEnabled
, EC_TAG_ONLINESIG_ENABLED
);
463 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SERVERS
)) != NULL
) {
464 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetDeadServer
, EC_TAG_SERVERS_REMOVE_DEAD
);
465 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SERVERS_DEAD_SERVER_RETRIES
)) != NULL
) {
466 thePrefs::SetDeadserverRetries(oneTag
->GetInt());
468 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoServerlist
, EC_TAG_SERVERS_AUTO_UPDATE
);
469 // Here should come the URL list...
470 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddServersFromServer
, EC_TAG_SERVERS_ADD_FROM_SERVER
);
471 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddServersFromClient
, EC_TAG_SERVERS_ADD_FROM_CLIENT
);
472 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetScoreSystem
, EC_TAG_SERVERS_USE_SCORE_SYSTEM
);
473 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSmartIdCheck
, EC_TAG_SERVERS_SMART_ID_CHECK
);
474 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSafeServerConnectEnabled
, EC_TAG_SERVERS_SAFE_SERVER_CONNECT
);
475 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoConnectStaticOnly
, EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY
);
476 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetManualHighPrio
, EC_TAG_SERVERS_MANUAL_HIGH_PRIO
);
477 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SERVERS_UPDATE_URL
)) != NULL
) {
478 thePrefs::SetEd2kServersUrl(oneTag
->GetStringData());
482 if ((thisTab
= GetTagByName(EC_TAG_PREFS_FILES
)) != NULL
) {
483 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetICHEnabled
, EC_TAG_FILES_ICH_ENABLED
);
484 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetTrustingEveryHash
, EC_TAG_FILES_AICH_TRUST
);
485 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddNewFilesPaused
, EC_TAG_FILES_NEW_PAUSED
);
486 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNewAutoDown
, EC_TAG_FILES_NEW_AUTO_DL_PRIO
);
487 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetPreviewPrio
, EC_TAG_FILES_PREVIEW_PRIO
);
488 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNewAutoUp
, EC_TAG_FILES_NEW_AUTO_UL_PRIO
);
489 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetStartNextFile
, EC_TAG_FILES_START_NEXT_PAUSED
);
490 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetStartNextFileSame
, EC_TAG_FILES_RESUME_SAME_CAT
);
491 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSrcSeedsOn
, EC_TAG_FILES_SAVE_SOURCES
);
492 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetExtractMetaData
, EC_TAG_FILES_EXTRACT_METADATA
);
493 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAllocFullFile
, EC_TAG_FILES_ALLOC_FULL_SIZE
);
494 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetCheckDiskspaceEnabled
, EC_TAG_FILES_CHECK_FREE_SPACE
);
495 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_FILES_MIN_FREE_SPACE
)) != NULL
) {
496 thePrefs::SetMinFreeDiskSpaceMB(oneTag
->GetInt());
498 ApplyBoolean(use_tag
, thisTab
, thePrefs::CreateFilesNormal
, EC_TAG_FILES_CREATE_NORMAL
);
501 if ((thisTab
= GetTagByName(EC_TAG_PREFS_DIRECTORIES
)) != NULL
) {
502 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_INCOMING
)) != NULL
) {
503 thePrefs::SetIncomingDir(CPath(oneTag
->GetStringData()));
505 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_TEMP
)) != NULL
) {
506 thePrefs::SetTempDir(CPath(oneTag
->GetStringData()));
508 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_SHARED
)) != NULL
) {
509 theApp
->glob_prefs
->shareddir_list
.clear();
510 for (CECTag::const_iterator it
= oneTag
->begin(); it
!= oneTag
->end(); ++it
) {
511 theApp
->glob_prefs
->shareddir_list
.push_back(CPath(it
->GetStringData()));
514 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetShareHiddenFiles
, EC_TAG_DIRECTORIES_SHARE_HIDDEN
);
517 if ((thisTab
= GetTagByName(EC_TAG_PREFS_STATISTICS
)) != NULL
) {
521 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SECURITY
)) != NULL
) {
522 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SECURITY_CAN_SEE_SHARES
)) != NULL
) {
523 thePrefs::SetCanSeeShares(oneTag
->GetInt());
525 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilteringClients
, EC_TAG_IPFILTER_CLIENTS
);
526 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilteringServers
, EC_TAG_IPFILTER_SERVERS
);
527 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetIPFilterAutoLoad
, EC_TAG_IPFILTER_AUTO_UPDATE
);
528 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_IPFILTER_UPDATE_URL
)) != NULL
) {
529 thePrefs::SetIPFilterURL(oneTag
->GetStringData());
531 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_IPFILTER_LEVEL
)) != NULL
) {
532 thePrefs::SetIPFilterLevel(oneTag
->GetInt());
534 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterLanIPs
, EC_TAG_IPFILTER_FILTER_LAN
);
535 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSecureIdentEnabled
, EC_TAG_SECURITY_USE_SECIDENT
);
537 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerSupported
, EC_TAG_SECURITY_OBFUSCATION_SUPPORTED
);
538 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerRequested
, EC_TAG_SECURITY_OBFUSCATION_REQUESTED
);
539 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerRequired
, EC_TAG_SECURITY_OBFUSCATION_REQUIRED
);
542 if ((thisTab
= GetTagByName(EC_TAG_PREFS_CORETWEAKS
)) != NULL
) {
543 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_MAX_CONN_PER_FIVE
)) != NULL
) {
544 thePrefs::SetMaxConsPerFive(oneTag
->GetInt());
546 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetVerbose
, EC_TAG_CORETW_VERBOSE
);
547 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_FILEBUFFER
)) != NULL
) {
548 thePrefs::SetFileBufferSize(oneTag
->GetInt());
550 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_UL_QUEUE
)) != NULL
) {
551 thePrefs::SetQueueSize(oneTag
->GetInt());
553 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT
)) != NULL
) {
554 thePrefs::SetServerKeepAliveTimeout(oneTag
->GetInt());
558 if ((thisTab
= GetTagByName(EC_TAG_PREFS_KADEMLIA
)) != NULL
) {
559 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_KADEMLIA_UPDATE_URL
)) != NULL
) {
560 thePrefs::SetKadNodesUrl(oneTag
->GetStringData());
564 theApp
->glob_prefs
->Save();
566 // File_checked_for_headers