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
));
48 AddTag(CECTag(EC_TAG_CATEGORY_TITLE
, cat
->title
));
52 CEC_Category_Tag::CEC_Category_Tag(uint32 cat_index
, wxString name
, wxString path
,
53 wxString comment
, uint32 color
, uint8 prio
) : CECTag(EC_TAG_CATEGORY
, cat_index
)
55 AddTag(CECTag(EC_TAG_CATEGORY_PATH
, path
));
56 AddTag(CECTag(EC_TAG_CATEGORY_COMMENT
, comment
));
57 AddTag(CECTag(EC_TAG_CATEGORY_COLOR
, color
));
58 AddTag(CECTag(EC_TAG_CATEGORY_PRIO
, prio
));
59 AddTag(CECTag(EC_TAG_CATEGORY_TITLE
, name
));
62 bool CEC_Category_Tag::Apply()
64 bool ret
= theApp
->glob_prefs
->UpdateCategory(GetInt(), Name(), CPath(Path()), Comment(), Color(), Prio());
66 GetTagByName(EC_TAG_CATEGORY_PATH
)->SetStringData(theApp
->glob_prefs
->GetCatPath(GetInt()).GetRaw());
71 bool CEC_Category_Tag::Create()
73 Category_Struct
* category
= NULL
;
74 bool ret
= theApp
->glob_prefs
->CreateCategory(category
, Name(), CPath(Path()), Comment(), Color(), Prio());
76 GetTagByName(EC_TAG_CATEGORY_PATH
)->SetStringData(theApp
->glob_prefs
->GetCatPath(
77 theApp
->glob_prefs
->GetCatCount() - 1).GetRaw());
82 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
)
84 if (selection
& EC_PREFS_CATEGORIES
) {
85 if (theApp
->glob_prefs
->GetCatCount() > 1) {
86 CECEmptyTag
cats(EC_TAG_PREFS_CATEGORIES
);
87 for (unsigned int i
= 0; i
< theApp
->glob_prefs
->GetCatCount(); ++i
) {
88 CEC_Category_Tag
catTag(i
, cat_details
);
95 if (selection
& EC_PREFS_GENERAL
) {
96 CECEmptyTag
user_prefs(EC_TAG_PREFS_GENERAL
);
97 user_prefs
.AddTag(CECTag(EC_TAG_USER_NICK
, thePrefs::GetUserNick()));
98 user_prefs
.AddTag(CECTag(EC_TAG_USER_HASH
, thePrefs::GetUserHash()));
99 user_prefs
.AddTag(CECTag(EC_TAG_USER_HOST
, thePrefs::GetYourHostname()));
100 user_prefs
.AddTag(CECTag(EC_TAG_GENERAL_CHECK_NEW_VERSION
, thePrefs::GetCheckNewVersion()));
104 if (selection
& EC_PREFS_CONNECTIONS
) {
105 CECEmptyTag
connPrefs(EC_TAG_PREFS_CONNECTIONS
);
106 connPrefs
.AddTag(CECTag(EC_TAG_CONN_UL_CAP
, thePrefs::GetMaxGraphUploadRate()));
107 connPrefs
.AddTag(CECTag(EC_TAG_CONN_DL_CAP
, thePrefs::GetMaxGraphDownloadRate()));
108 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_UL
, thePrefs::GetMaxUpload()));
109 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_DL
, thePrefs::GetMaxDownload()));
110 connPrefs
.AddTag(CECTag(EC_TAG_CONN_SLOT_ALLOCATION
, thePrefs::GetSlotAllocation()));
111 connPrefs
.AddTag(CECTag(EC_TAG_CONN_TCP_PORT
, thePrefs::GetPort()));
112 connPrefs
.AddTag(CECTag(EC_TAG_CONN_UDP_PORT
, thePrefs::GetUDPPort()));
113 if (thePrefs::IsUDPDisabled()) {
114 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_UDP_DISABLE
));
116 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_FILE_SOURCES
, thePrefs::GetMaxSourcePerFile()));
117 connPrefs
.AddTag(CECTag(EC_TAG_CONN_MAX_CONN
, thePrefs::GetMaxConnections()));
118 if (thePrefs::DoAutoConnect()) {
119 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_AUTOCONNECT
));
121 if (thePrefs::Reconnect()) {
122 connPrefs
.AddTag(CECEmptyTag(EC_TAG_CONN_RECONNECT
));
124 if (thePrefs::GetNetworkED2K()) {
125 connPrefs
.AddTag(CECEmptyTag(EC_TAG_NETWORK_ED2K
));
127 if (thePrefs::GetNetworkKademlia()) {
128 connPrefs
.AddTag(CECEmptyTag(EC_TAG_NETWORK_KADEMLIA
));
133 if (selection
& EC_PREFS_MESSAGEFILTER
) {
134 CECEmptyTag
msg_prefs(EC_TAG_PREFS_MESSAGEFILTER
);
135 if (thePrefs::MustFilterMessages()) {
136 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ENABLED
));
138 if (thePrefs::IsFilterAllMessages()) {
139 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ALL
));
141 if (thePrefs::MsgOnlyFriends()) {
142 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_FRIENDS
));
144 if (thePrefs::MsgOnlySecure()) {
145 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_SECURE
));
147 if (thePrefs::IsFilterByKeywords()) {
148 msg_prefs
.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_BY_KEYWORD
));
150 msg_prefs
.AddTag(CECTag(EC_TAG_MSGFILTER_KEYWORDS
, thePrefs::GetMessageFilterString()));
154 if (selection
& EC_PREFS_REMOTECONTROLS
) {
155 CECEmptyTag
rc_prefs(EC_TAG_PREFS_REMOTECTRL
);
156 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_PORT
, thePrefs::GetWSPort()));
157 if (thePrefs::GetWSIsEnabled()) {
158 rc_prefs
.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_AUTORUN
));
160 if (!thePrefs::GetWSPass().IsEmpty()) {
162 wxCHECK2(passhash
.Decode(thePrefs::GetWSPass()), /* Do nothing. */);
163 rc_prefs
.AddTag(CECTag(EC_TAG_PASSWD_HASH
, passhash
));
165 if (thePrefs::GetWSIsLowUserEnabled()) {
166 CECEmptyTag
lowUser(EC_TAG_WEBSERVER_GUEST
);
167 if (!thePrefs::GetWSLowPass().IsEmpty()) {
169 wxCHECK2(passhash
.Decode(thePrefs::GetWSLowPass()), /* Do nothing. */);
170 lowUser
.AddTag(CECTag(EC_TAG_PASSWD_HASH
, passhash
));
172 rc_prefs
.AddTag(lowUser
);
174 if (thePrefs::GetWebUseGzip()) {
175 rc_prefs
.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_USEGZIP
));
177 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_REFRESH
, thePrefs::GetWebPageRefresh()));
178 rc_prefs
.AddTag(CECTag(EC_TAG_WEBSERVER_TEMPLATE
, thePrefs::GetWebTemplate()));
182 if (selection
& EC_PREFS_ONLINESIG
) {
183 CECEmptyTag
online_sig(EC_TAG_PREFS_ONLINESIG
);
184 if (thePrefs::IsOnlineSignatureEnabled()) {
185 online_sig
.AddTag(CECEmptyTag(EC_TAG_ONLINESIG_ENABLED
));
190 if (selection
& EC_PREFS_SERVERS
) {
191 CECEmptyTag
srv_prefs(EC_TAG_PREFS_SERVERS
);
192 if (thePrefs::DeadServer()) {
193 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_REMOVE_DEAD
));
195 srv_prefs
.AddTag(CECTag(EC_TAG_SERVERS_DEAD_SERVER_RETRIES
, (uint16
)thePrefs::GetDeadserverRetries()));
196 if (thePrefs::AutoServerlist()) {
197 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTO_UPDATE
));
199 // Here should come the URL list...
200 if (thePrefs::AddServersFromServer()) {
201 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_SERVER
));
203 if (thePrefs::AddServersFromClient()) {
204 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_CLIENT
));
206 if (thePrefs::Score()) {
207 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_USE_SCORE_SYSTEM
));
209 if (thePrefs::GetSmartIdCheck()) {
210 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_SMART_ID_CHECK
));
212 if (thePrefs::IsSafeServerConnectEnabled()) {
213 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_SAFE_SERVER_CONNECT
));
215 if (thePrefs::AutoConnectStaticOnly()) {
216 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY
));
218 if (thePrefs::IsManualHighPrio()) {
219 srv_prefs
.AddTag(CECEmptyTag(EC_TAG_SERVERS_MANUAL_HIGH_PRIO
));
221 srv_prefs
.AddTag(CECTag(EC_TAG_SERVERS_UPDATE_URL
, thePrefs::GetEd2kServersUrl()));
225 if (selection
& EC_PREFS_FILES
) {
226 CECEmptyTag
filePrefs(EC_TAG_PREFS_FILES
);
227 if (thePrefs::IsICHEnabled()) {
228 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_ICH_ENABLED
));
230 if (thePrefs::IsTrustingEveryHash()) {
231 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_AICH_TRUST
));
233 if (thePrefs::AddNewFilesPaused()) {
234 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_PAUSED
));
236 if (thePrefs::GetNewAutoDown()) {
237 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_DL_PRIO
));
239 if (thePrefs::GetPreviewPrio()) {
240 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_PREVIEW_PRIO
));
242 if (thePrefs::GetNewAutoUp()) {
243 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_UL_PRIO
));
245 if (thePrefs::StartNextFile()) {
246 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_START_NEXT_PAUSED
));
248 if (thePrefs::StartNextFileSame()) {
249 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_RESUME_SAME_CAT
));
251 if (thePrefs::GetSrcSeedsOn()) {
252 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_SAVE_SOURCES
));
254 if (thePrefs::GetExtractMetaData()) {
255 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_EXTRACT_METADATA
));
257 if (thePrefs::GetAllocFullFile()) {
258 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_ALLOC_FULL_SIZE
));
260 if (thePrefs::IsCheckDiskspaceEnabled()) {
261 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_CHECK_FREE_SPACE
));
263 filePrefs
.AddTag(CECTag(EC_TAG_FILES_MIN_FREE_SPACE
, thePrefs::GetMinFreeDiskSpaceMB()));
264 if (!thePrefs::CreateFilesSparse()) {
265 filePrefs
.AddTag(CECEmptyTag(EC_TAG_FILES_CREATE_NORMAL
));
270 if (selection
& EC_PREFS_DIRECTORIES
) {
271 CECEmptyTag
dirPrefs(EC_TAG_PREFS_DIRECTORIES
);
272 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_INCOMING
, thePrefs::GetIncomingDir().GetRaw()));
273 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_TEMP
, thePrefs::GetTempDir().GetRaw()));
274 uint32 sharedDirs
= theApp
->glob_prefs
->shareddir_list
.size();
275 CECTag
dirtag(EC_TAG_DIRECTORIES_SHARED
, sharedDirs
);
276 for (size_t i
= 0; i
< sharedDirs
; i
++) {
277 dirtag
.AddTag(CECTag(EC_TAG_STRING
, theApp
->glob_prefs
->shareddir_list
[i
].GetRaw()));
279 dirPrefs
.AddTag(dirtag
);
280 dirPrefs
.AddTag(CECTag(EC_TAG_DIRECTORIES_SHARE_HIDDEN
, thePrefs::ShareHiddenFiles()));
284 if (selection
& EC_PREFS_STATISTICS
) {
288 if (selection
& EC_PREFS_SECURITY
) {
289 CECEmptyTag
secPrefs(EC_TAG_PREFS_SECURITY
);
290 secPrefs
.AddTag(CECTag(EC_TAG_SECURITY_CAN_SEE_SHARES
, thePrefs::CanSeeShares()));
291 if (thePrefs::IsFilteringClients()) {
292 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_CLIENTS
));
294 if (thePrefs::IsFilteringServers()) {
295 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_SERVERS
));
297 if (thePrefs::IPFilterAutoLoad()) {
298 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_AUTO_UPDATE
));
300 secPrefs
.AddTag(CECTag(EC_TAG_IPFILTER_UPDATE_URL
, thePrefs::IPFilterURL()));
301 secPrefs
.AddTag(CECTag(EC_TAG_IPFILTER_LEVEL
, thePrefs::GetIPFilterLevel()));
302 if (thePrefs::FilterLanIPs()) {
303 secPrefs
.AddTag(CECEmptyTag(EC_TAG_IPFILTER_FILTER_LAN
));
305 if (thePrefs::IsSecureIdentEnabled()) {
306 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_USE_SECIDENT
));
309 if (thePrefs::IsClientCryptLayerSupported()) {
310 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_SUPPORTED
));
312 if (thePrefs::IsClientCryptLayerRequested()) {
313 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUESTED
));
315 if (thePrefs::IsClientCryptLayerRequired()) {
316 secPrefs
.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUIRED
));
322 if (selection
& EC_PREFS_CORETWEAKS
) {
323 CECEmptyTag
cwPrefs(EC_TAG_PREFS_CORETWEAKS
);
324 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_MAX_CONN_PER_FIVE
, thePrefs::GetMaxConperFive()));
325 if (thePrefs::GetVerbose()) {
326 cwPrefs
.AddTag(CECEmptyTag(EC_TAG_CORETW_VERBOSE
));
328 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_FILEBUFFER
, thePrefs::GetFileBufferSize()));
329 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_UL_QUEUE
, thePrefs::GetQueueSize()));
330 cwPrefs
.AddTag(CECTag(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT
, thePrefs::GetServerKeepAliveTimeout()));
334 if (selection
& EC_PREFS_KADEMLIA
) {
335 CECEmptyTag
kadPrefs(EC_TAG_PREFS_KADEMLIA
);
336 kadPrefs
.AddTag(CECTag(EC_TAG_KADEMLIA_UPDATE_URL
, thePrefs::GetKadNodesUrl()));
342 * Applies a boolean value from the set_preferences request
344 * @param use_tag If true, an unset variable means "leave unchanged". If false, an unset variable means false.
345 * @param thisTab The TAG that contains the TAG with a boolean value
346 * @param applyFunc The function to use for applying the value
347 * @param tagName The name of the TAG that holds the boolean value
349 static void ApplyBoolean(bool use_tag
, const CECTag
*thisTab
, void (applyFunc
)(bool), int tagName
)
351 const CECTag
*boolTag
= thisTab
->GetTagByName(tagName
);
353 if (boolTag
!= NULL
) {
354 applyFunc(boolTag
->GetInt() != 0);
357 applyFunc(boolTag
!= NULL
);
362 * This will set all preferences except of categories, which are work as following:
363 * -> On remote gui they are loaded on startup, and then changed on-command
364 * -> Webserver doesn't supposed to change it.
366 void CEC_Prefs_Packet::Apply() const
368 const CECTag
*thisTab
= NULL
;
369 const CECTag
*oneTag
= NULL
;
371 if ((thisTab
= GetTagByName(EC_TAG_PREFS_GENERAL
)) != NULL
) {
372 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_NICK
)) != NULL
) {
373 thePrefs::SetUserNick(oneTag
->GetStringData());
375 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_HASH
)) != NULL
) {
376 thePrefs::SetUserHash(oneTag
->GetMD4Data());
378 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_USER_HOST
)) != NULL
) {
379 thePrefs::SetYourHostname(oneTag
->GetStringData());
381 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_GENERAL_CHECK_NEW_VERSION
)) != NULL
) {
382 thePrefs::SetCheckNewVersion(oneTag
->GetInt() != 0);
387 // webserver doesn't transmit all boolean values
389 bool use_tag
= (GetDetailLevel() == EC_DETAIL_FULL
);
391 if ((thisTab
= GetTagByName(EC_TAG_PREFS_CONNECTIONS
)) != NULL
) {
392 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_UL_CAP
)) != NULL
) {
393 thePrefs::SetMaxGraphUploadRate(oneTag
->GetInt());
395 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_DL_CAP
)) != NULL
) {
396 thePrefs::SetMaxGraphDownloadRate(oneTag
->GetInt());
398 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_UL
)) != NULL
) {
399 thePrefs::SetMaxUpload(oneTag
->GetInt());
401 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_DL
)) != NULL
) {
402 thePrefs::SetMaxDownload(oneTag
->GetInt());
404 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_SLOT_ALLOCATION
)) != NULL
) {
405 thePrefs::SetSlotAllocation(oneTag
->GetInt());
407 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_TCP_PORT
)) != NULL
) {
408 thePrefs::SetPort(oneTag
->GetInt());
410 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_UDP_PORT
)) != NULL
) {
411 thePrefs::SetUDPPort(oneTag
->GetInt());
413 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetUDPDisable
, EC_TAG_CONN_UDP_DISABLE
);
414 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_FILE_SOURCES
)) != NULL
) {
415 thePrefs::SetMaxSourcesPerFile(oneTag
->GetInt());
417 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CONN_MAX_CONN
)) != NULL
) {
418 thePrefs::SetMaxConnections(oneTag
->GetInt());
420 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoConnect
, EC_TAG_CONN_AUTOCONNECT
);
421 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetReconnect
, EC_TAG_CONN_RECONNECT
);
422 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNetworkED2K
, EC_TAG_NETWORK_ED2K
);
423 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNetworkKademlia
, EC_TAG_NETWORK_KADEMLIA
);
426 if ((thisTab
= GetTagByName(EC_TAG_PREFS_MESSAGEFILTER
)) != NULL
) {
427 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMustFilterMessages
, EC_TAG_MSGFILTER_ENABLED
);
428 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterAllMessages
, EC_TAG_MSGFILTER_ALL
);
429 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMsgOnlyFriends
, EC_TAG_MSGFILTER_FRIENDS
);
430 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetMsgOnlySecure
, EC_TAG_MSGFILTER_SECURE
);
431 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterByKeywords
, EC_TAG_MSGFILTER_BY_KEYWORD
);
432 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_MSGFILTER_KEYWORDS
)) != NULL
) {
433 thePrefs::SetMessageFilterString(oneTag
->GetStringData());
437 if ((thisTab
= GetTagByName(EC_TAG_PREFS_REMOTECTRL
)) != NULL
) {
438 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWSIsEnabled
, EC_TAG_WEBSERVER_AUTORUN
);
439 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_PORT
)) != NULL
) {
440 thePrefs::SetWSPort(oneTag
->GetInt());
442 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_PASSWD_HASH
)) != NULL
) {
443 thePrefs::SetWSPass(oneTag
->GetMD4Data().Encode());
445 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWSIsLowUserEnabled
, EC_TAG_WEBSERVER_GUEST
);
446 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_GUEST
)) != NULL
) {
447 if ((oneTag
->GetTagByName(EC_TAG_PASSWD_HASH
)) != NULL
) {
448 thePrefs::SetWSLowPass(oneTag
->GetTagByName(EC_TAG_PASSWD_HASH
)->GetMD4Data().Encode());
451 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetWebUseGzip
, EC_TAG_WEBSERVER_USEGZIP
);
452 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_REFRESH
)) != NULL
) {
453 thePrefs::SetWebPageRefresh(oneTag
->GetInt());
455 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_WEBSERVER_TEMPLATE
)) != NULL
) {
456 thePrefs::SetWebTemplate(oneTag
->GetStringData());
460 if ((thisTab
= GetTagByName(EC_TAG_PREFS_ONLINESIG
)) != NULL
) {
461 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetOnlineSignatureEnabled
, EC_TAG_ONLINESIG_ENABLED
);
464 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SERVERS
)) != NULL
) {
465 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetDeadServer
, EC_TAG_SERVERS_REMOVE_DEAD
);
466 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SERVERS_DEAD_SERVER_RETRIES
)) != NULL
) {
467 thePrefs::SetDeadserverRetries(oneTag
->GetInt());
469 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoServerlist
, EC_TAG_SERVERS_AUTO_UPDATE
);
470 // Here should come the URL list...
471 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddServersFromServer
, EC_TAG_SERVERS_ADD_FROM_SERVER
);
472 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddServersFromClient
, EC_TAG_SERVERS_ADD_FROM_CLIENT
);
473 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetScoreSystem
, EC_TAG_SERVERS_USE_SCORE_SYSTEM
);
474 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSmartIdCheck
, EC_TAG_SERVERS_SMART_ID_CHECK
);
475 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSafeServerConnectEnabled
, EC_TAG_SERVERS_SAFE_SERVER_CONNECT
);
476 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAutoConnectStaticOnly
, EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY
);
477 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetManualHighPrio
, EC_TAG_SERVERS_MANUAL_HIGH_PRIO
);
478 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SERVERS_UPDATE_URL
)) != NULL
) {
479 thePrefs::SetEd2kServersUrl(oneTag
->GetStringData());
483 if ((thisTab
= GetTagByName(EC_TAG_PREFS_FILES
)) != NULL
) {
484 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetICHEnabled
, EC_TAG_FILES_ICH_ENABLED
);
485 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetTrustingEveryHash
, EC_TAG_FILES_AICH_TRUST
);
486 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAddNewFilesPaused
, EC_TAG_FILES_NEW_PAUSED
);
487 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNewAutoDown
, EC_TAG_FILES_NEW_AUTO_DL_PRIO
);
488 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetPreviewPrio
, EC_TAG_FILES_PREVIEW_PRIO
);
489 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetNewAutoUp
, EC_TAG_FILES_NEW_AUTO_UL_PRIO
);
490 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetStartNextFile
, EC_TAG_FILES_START_NEXT_PAUSED
);
491 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetStartNextFileSame
, EC_TAG_FILES_RESUME_SAME_CAT
);
492 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSrcSeedsOn
, EC_TAG_FILES_SAVE_SOURCES
);
493 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetExtractMetaData
, EC_TAG_FILES_EXTRACT_METADATA
);
494 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetAllocFullFile
, EC_TAG_FILES_ALLOC_FULL_SIZE
);
495 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetCheckDiskspaceEnabled
, EC_TAG_FILES_CHECK_FREE_SPACE
);
496 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_FILES_MIN_FREE_SPACE
)) != NULL
) {
497 thePrefs::SetMinFreeDiskSpaceMB(oneTag
->GetInt());
499 ApplyBoolean(use_tag
, thisTab
, thePrefs::CreateFilesNormal
, EC_TAG_FILES_CREATE_NORMAL
);
502 if ((thisTab
= GetTagByName(EC_TAG_PREFS_DIRECTORIES
)) != NULL
) {
503 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_INCOMING
)) != NULL
) {
504 thePrefs::SetIncomingDir(CPath(oneTag
->GetStringData()));
506 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_TEMP
)) != NULL
) {
507 thePrefs::SetTempDir(CPath(oneTag
->GetStringData()));
509 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_DIRECTORIES_SHARED
)) != NULL
) {
510 theApp
->glob_prefs
->shareddir_list
.clear();
511 for (CECTag::const_iterator it
= oneTag
->begin(); it
!= oneTag
->end(); ++it
) {
512 theApp
->glob_prefs
->shareddir_list
.push_back(CPath(it
->GetStringData()));
515 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetShareHiddenFiles
, EC_TAG_DIRECTORIES_SHARE_HIDDEN
);
518 if ((thisTab
= GetTagByName(EC_TAG_PREFS_STATISTICS
)) != NULL
) {
522 if ((thisTab
= GetTagByName(EC_TAG_PREFS_SECURITY
)) != NULL
) {
523 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_SECURITY_CAN_SEE_SHARES
)) != NULL
) {
524 thePrefs::SetCanSeeShares(oneTag
->GetInt());
526 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilteringClients
, EC_TAG_IPFILTER_CLIENTS
);
527 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilteringServers
, EC_TAG_IPFILTER_SERVERS
);
528 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetIPFilterAutoLoad
, EC_TAG_IPFILTER_AUTO_UPDATE
);
529 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_IPFILTER_UPDATE_URL
)) != NULL
) {
530 thePrefs::SetIPFilterURL(oneTag
->GetStringData());
532 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_IPFILTER_LEVEL
)) != NULL
) {
533 thePrefs::SetIPFilterLevel(oneTag
->GetInt());
535 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetFilterLanIPs
, EC_TAG_IPFILTER_FILTER_LAN
);
536 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetSecureIdentEnabled
, EC_TAG_SECURITY_USE_SECIDENT
);
538 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerSupported
, EC_TAG_SECURITY_OBFUSCATION_SUPPORTED
);
539 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerRequested
, EC_TAG_SECURITY_OBFUSCATION_REQUESTED
);
540 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetClientCryptLayerRequired
, EC_TAG_SECURITY_OBFUSCATION_REQUIRED
);
543 if ((thisTab
= GetTagByName(EC_TAG_PREFS_CORETWEAKS
)) != NULL
) {
544 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_MAX_CONN_PER_FIVE
)) != NULL
) {
545 thePrefs::SetMaxConsPerFive(oneTag
->GetInt());
547 ApplyBoolean(use_tag
, thisTab
, thePrefs::SetVerbose
, EC_TAG_CORETW_VERBOSE
);
548 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_FILEBUFFER
)) != NULL
) {
549 thePrefs::SetFileBufferSize(oneTag
->GetInt());
551 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_UL_QUEUE
)) != NULL
) {
552 thePrefs::SetQueueSize(oneTag
->GetInt());
554 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT
)) != NULL
) {
555 thePrefs::SetServerKeepAliveTimeout(oneTag
->GetInt());
559 if ((thisTab
= GetTagByName(EC_TAG_PREFS_KADEMLIA
)) != NULL
) {
560 if ((oneTag
= thisTab
->GetTagByName(EC_TAG_KADEMLIA_UPDATE_URL
)) != NULL
) {
561 thePrefs::SetKadNodesUrl(oneTag
->GetStringData());
565 theApp
->glob_prefs
->Save();
567 // File_checked_for_headers