Improve speed of category tab title updates
[amule.git] / src / ECSpecialMuleTags.cpp
blob1b9dcb110c7db4973913f30c733b90940079581d
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
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"
32 #include "amule.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:
40 case EC_DETAIL_WEB:
41 case EC_DETAIL_FULL:
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));
46 case EC_DETAIL_CMD:
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());
64 if (!ret) {
65 GetTagByName(EC_TAG_CATEGORY_PATH)->SetStringData(theApp->glob_prefs->GetCatPath(GetInt()).GetRaw());
67 return ret;
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());
74 if (!ret) {
75 GetTagByName(EC_TAG_CATEGORY_PATH)->SetStringData(theApp->glob_prefs->GetCatPath(
76 theApp->glob_prefs->GetCatCount() - 1).GetRaw());
78 return ret;
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);
88 cats.AddTag(catTag);
90 AddTag(cats);
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()));
100 AddTag(user_prefs);
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));
129 AddTag(connPrefs);
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()));
150 AddTag(msg_prefs);
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()) {
160 CMD4Hash passhash;
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()) {
167 CMD4Hash passhash;
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()));
178 AddTag(rc_prefs);
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));
186 AddTag(online_sig);
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()));
221 AddTag(srv_prefs);
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 AddTag(filePrefs);
266 if (selection & EC_PREFS_SRCDROP) {
267 CECEmptyTag srcdrop(EC_TAG_PREFS_SRCDROP);
268 srcdrop.AddTag(CECTag(EC_TAG_SRCDROP_NONEEDED, (uint8)thePrefs::GetNoNeededSources()));
269 if (thePrefs::DropFullQueueSources()) {
270 srcdrop.AddTag(CECEmptyTag(EC_TAG_SRCDROP_DROP_FQS));
272 if (thePrefs::DropHighQueueRankingSources()) {
273 srcdrop.AddTag(CECEmptyTag(EC_TAG_SRCDROP_DROP_HQRS));
275 srcdrop.AddTag(CECTag(EC_TAG_SRCDROP_HQRS_VALUE, (uint16)thePrefs::HighQueueRanking()));
276 srcdrop.AddTag(CECTag(EC_TAG_SRCDROP_AUTODROP_TIMER, (uint16)thePrefs::GetAutoDropTimer()));
277 AddTag(srcdrop);
280 if (selection & EC_PREFS_DIRECTORIES) {
281 CECEmptyTag dirPrefs(EC_TAG_PREFS_DIRECTORIES);
282 dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_INCOMING, thePrefs::GetIncomingDir().GetRaw()));
283 dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_TEMP, thePrefs::GetTempDir().GetRaw()));
284 uint32 sharedDirs = theApp->glob_prefs->shareddir_list.size();
285 CECTag dirtag(EC_TAG_DIRECTORIES_SHARED, sharedDirs);
286 for (size_t i = 0; i < sharedDirs; i++) {
287 dirtag.AddTag(CECTag(EC_TAG_STRING, theApp->glob_prefs->shareddir_list[i].GetRaw()));
289 dirPrefs.AddTag(dirtag);
290 dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_SHARE_HIDDEN, thePrefs::ShareHiddenFiles()));
291 AddTag(dirPrefs);
294 if (selection & EC_PREFS_STATISTICS) {
295 //#warning TODO
298 if (selection & EC_PREFS_SECURITY) {
299 CECEmptyTag secPrefs(EC_TAG_PREFS_SECURITY);
300 secPrefs.AddTag(CECTag(EC_TAG_SECURITY_CAN_SEE_SHARES, thePrefs::CanSeeShares()));
301 if (thePrefs::IsFilteringClients()) {
302 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_CLIENTS));
304 if (thePrefs::IsFilteringServers()) {
305 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_SERVERS));
307 if (thePrefs::IPFilterAutoLoad()) {
308 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_AUTO_UPDATE));
310 secPrefs.AddTag(CECTag(EC_TAG_IPFILTER_UPDATE_URL, thePrefs::IPFilterURL()));
311 secPrefs.AddTag(CECTag(EC_TAG_IPFILTER_LEVEL, thePrefs::GetIPFilterLevel()));
312 if (thePrefs::FilterLanIPs()) {
313 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_FILTER_LAN));
315 if (thePrefs::IsSecureIdentEnabled()) {
316 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_USE_SECIDENT));
319 if (thePrefs::IsClientCryptLayerSupported()) {
320 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_SUPPORTED));
322 if (thePrefs::IsClientCryptLayerRequested()) {
323 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUESTED));
325 if (thePrefs::IsClientCryptLayerRequired()) {
326 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUIRED));
329 AddTag(secPrefs);
332 if (selection & EC_PREFS_CORETWEAKS) {
333 CECEmptyTag cwPrefs(EC_TAG_PREFS_CORETWEAKS);
334 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_MAX_CONN_PER_FIVE, thePrefs::GetMaxConperFive()));
335 if (thePrefs::GetVerbose()) {
336 cwPrefs.AddTag(CECEmptyTag(EC_TAG_CORETW_VERBOSE));
338 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_FILEBUFFER, thePrefs::GetFileBufferSize()));
339 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_UL_QUEUE, thePrefs::GetQueueSize()));
340 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT, thePrefs::GetServerKeepAliveTimeout()));
341 AddTag(cwPrefs);
344 if (selection & EC_PREFS_KADEMLIA) {
345 CECEmptyTag kadPrefs(EC_TAG_PREFS_KADEMLIA);
346 kadPrefs.AddTag(CECTag(EC_TAG_KADEMLIA_UPDATE_URL, thePrefs::GetKadNodesUrl()));
347 AddTag(kadPrefs);
352 * Applies a boolean value from the set_preferences request
354 * @param use_tag If true, an unset variable means "leave unchanged". If false, an unset variable means false.
355 * @param thisTab The TAG that contains the TAG with a boolean value
356 * @param applyFunc The function to use for applying the value
357 * @param tagName The name of the TAG that holds the boolean value
359 void ApplyBoolean(bool use_tag, const CECTag *thisTab, void (applyFunc)(bool), int tagName)
361 const CECTag *boolTag = thisTab->GetTagByName(tagName);
362 if (use_tag) {
363 if (boolTag != NULL) {
364 applyFunc(boolTag->GetInt() != 0);
366 } else {
367 applyFunc(boolTag != NULL);
372 * This will set all preferences except of categories, which are work as following:
373 * -> On remote gui they are loaded on startup, and then changed on-command
374 * -> Webserver doesn't supposed to change it.
376 void CEC_Prefs_Packet::Apply()
378 const CECTag *thisTab = NULL;
379 const CECTag *oneTag = NULL;
381 if ((thisTab = GetTagByName(EC_TAG_PREFS_GENERAL)) != NULL) {
382 if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_NICK)) != NULL) {
383 thePrefs::SetUserNick(oneTag->GetStringData());
385 if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_HASH)) != NULL) {
386 thePrefs::SetUserHash(oneTag->GetMD4Data());
388 if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_HOST)) != NULL) {
389 thePrefs::SetYourHostname(oneTag->GetStringData());
391 if ((oneTag = thisTab->GetTagByName(EC_TAG_GENERAL_CHECK_NEW_VERSION)) != NULL) {
392 thePrefs::SetCheckNewVersion(oneTag->GetInt() != 0);
397 // webserver doesn't transmit all boolean values
399 bool use_tag = (GetDetailLevel() == EC_DETAIL_FULL);
401 if ((thisTab = GetTagByName(EC_TAG_PREFS_CONNECTIONS)) != NULL) {
402 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_UL_CAP)) != NULL) {
403 thePrefs::SetMaxGraphUploadRate(oneTag->GetInt());
405 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_DL_CAP)) != NULL) {
406 thePrefs::SetMaxGraphDownloadRate(oneTag->GetInt());
408 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_UL)) != NULL) {
409 thePrefs::SetMaxUpload(oneTag->GetInt());
411 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_DL)) != NULL) {
412 thePrefs::SetMaxDownload(oneTag->GetInt());
414 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_SLOT_ALLOCATION)) != NULL) {
415 thePrefs::SetSlotAllocation(oneTag->GetInt());
417 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_TCP_PORT)) != NULL) {
418 thePrefs::SetPort(oneTag->GetInt());
420 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_UDP_PORT)) != NULL) {
421 thePrefs::SetUDPPort(oneTag->GetInt());
423 ApplyBoolean(use_tag, thisTab, thePrefs::SetUDPDisable, EC_TAG_CONN_UDP_DISABLE);
424 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_FILE_SOURCES)) != NULL) {
425 thePrefs::SetMaxSourcesPerFile(oneTag->GetInt());
427 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_CONN)) != NULL) {
428 thePrefs::SetMaxConnections(oneTag->GetInt());
430 ApplyBoolean(use_tag, thisTab, thePrefs::SetAutoConnect, EC_TAG_CONN_AUTOCONNECT);
431 ApplyBoolean(use_tag, thisTab, thePrefs::SetReconnect, EC_TAG_CONN_RECONNECT);
432 ApplyBoolean(use_tag, thisTab, thePrefs::SetNetworkED2K, EC_TAG_NETWORK_ED2K);
433 ApplyBoolean(use_tag, thisTab, thePrefs::SetNetworkKademlia, EC_TAG_NETWORK_KADEMLIA);
436 if ((thisTab = GetTagByName(EC_TAG_PREFS_MESSAGEFILTER)) != NULL) {
437 ApplyBoolean(use_tag, thisTab, thePrefs::SetMustFilterMessages, EC_TAG_MSGFILTER_ENABLED);
438 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterAllMessages, EC_TAG_MSGFILTER_ALL);
439 ApplyBoolean(use_tag, thisTab, thePrefs::SetMsgOnlyFriends, EC_TAG_MSGFILTER_FRIENDS);
440 ApplyBoolean(use_tag, thisTab, thePrefs::SetMsgOnlySecure, EC_TAG_MSGFILTER_SECURE);
441 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterByKeywords, EC_TAG_MSGFILTER_BY_KEYWORD);
442 if ((oneTag = thisTab->GetTagByName(EC_TAG_MSGFILTER_KEYWORDS)) != NULL) {
443 thePrefs::SetMessageFilterString(oneTag->GetStringData());
447 if ((thisTab = GetTagByName(EC_TAG_PREFS_REMOTECTRL)) != NULL) {
448 ApplyBoolean(use_tag, thisTab, thePrefs::SetWSIsEnabled, EC_TAG_WEBSERVER_AUTORUN);
449 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_PORT)) != NULL) {
450 thePrefs::SetWSPort(oneTag->GetInt());
452 if ((oneTag = thisTab->GetTagByName(EC_TAG_PASSWD_HASH)) != NULL) {
453 thePrefs::SetWSPass(oneTag->GetMD4Data().Encode());
455 ApplyBoolean(use_tag, thisTab, thePrefs::SetWSIsLowUserEnabled, EC_TAG_WEBSERVER_GUEST);
456 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_GUEST)) != NULL) {
457 if ((oneTag->GetTagByName(EC_TAG_PASSWD_HASH)) != NULL) {
458 thePrefs::SetWSLowPass(oneTag->GetTagByName(EC_TAG_PASSWD_HASH)->GetMD4Data().Encode());
461 ApplyBoolean(use_tag, thisTab, thePrefs::SetWebUseGzip, EC_TAG_WEBSERVER_USEGZIP);
462 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_REFRESH)) != NULL) {
463 thePrefs::SetWebPageRefresh(oneTag->GetInt());
465 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_TEMPLATE)) != NULL) {
466 thePrefs::SetWebTemplate(oneTag->GetStringData());
470 if ((thisTab = GetTagByName(EC_TAG_PREFS_ONLINESIG)) != NULL) {
471 ApplyBoolean(use_tag, thisTab, thePrefs::SetOnlineSignatureEnabled, EC_TAG_ONLINESIG_ENABLED);
474 if ((thisTab = GetTagByName(EC_TAG_PREFS_SERVERS)) != NULL) {
475 ApplyBoolean(use_tag, thisTab, thePrefs::SetDeadServer, EC_TAG_SERVERS_REMOVE_DEAD);
476 if ((oneTag = thisTab->GetTagByName(EC_TAG_SERVERS_DEAD_SERVER_RETRIES)) != NULL) {
477 thePrefs::SetDeadserverRetries(oneTag->GetInt());
479 ApplyBoolean(use_tag, thisTab, thePrefs::SetAutoServerlist, EC_TAG_SERVERS_AUTO_UPDATE);
480 // Here should come the URL list...
481 ApplyBoolean(use_tag, thisTab, thePrefs::SetAddServersFromServer, EC_TAG_SERVERS_ADD_FROM_SERVER);
482 ApplyBoolean(use_tag, thisTab, thePrefs::SetAddServersFromClient, EC_TAG_SERVERS_ADD_FROM_CLIENT);
483 ApplyBoolean(use_tag, thisTab, thePrefs::SetScoreSystem, EC_TAG_SERVERS_USE_SCORE_SYSTEM);
484 ApplyBoolean(use_tag, thisTab, thePrefs::SetSmartIdCheck, EC_TAG_SERVERS_SMART_ID_CHECK);
485 ApplyBoolean(use_tag, thisTab, thePrefs::SetSafeServerConnectEnabled, EC_TAG_SERVERS_SAFE_SERVER_CONNECT);
486 ApplyBoolean(use_tag, thisTab, thePrefs::SetAutoConnectStaticOnly, EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY);
487 ApplyBoolean(use_tag, thisTab, thePrefs::SetManualHighPrio, EC_TAG_SERVERS_MANUAL_HIGH_PRIO);
488 if ((oneTag = thisTab->GetTagByName(EC_TAG_SERVERS_UPDATE_URL)) != NULL) {
489 thePrefs::SetEd2kServersUrl(oneTag->GetStringData());
493 if ((thisTab = GetTagByName(EC_TAG_PREFS_FILES)) != NULL) {
494 ApplyBoolean(use_tag, thisTab, thePrefs::SetICHEnabled, EC_TAG_FILES_ICH_ENABLED);
495 ApplyBoolean(use_tag, thisTab, thePrefs::SetTrustingEveryHash, EC_TAG_FILES_AICH_TRUST);
496 ApplyBoolean(use_tag, thisTab, thePrefs::SetAddNewFilesPaused, EC_TAG_FILES_NEW_PAUSED);
497 ApplyBoolean(use_tag, thisTab, thePrefs::SetNewAutoDown, EC_TAG_FILES_NEW_AUTO_DL_PRIO);
498 ApplyBoolean(use_tag, thisTab, thePrefs::SetPreviewPrio, EC_TAG_FILES_PREVIEW_PRIO);
499 ApplyBoolean(use_tag, thisTab, thePrefs::SetNewAutoUp, EC_TAG_FILES_NEW_AUTO_UL_PRIO);
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 (CECTag::const_iterator it = oneTag->begin(); it != oneTag->end(); it++) {
535 theApp->glob_prefs->shareddir_list.push_back(CPath(it->GetStringData()));
538 ApplyBoolean(use_tag, thisTab, thePrefs::SetShareHiddenFiles, EC_TAG_DIRECTORIES_SHARE_HIDDEN);
541 if ((thisTab = GetTagByName(EC_TAG_PREFS_STATISTICS)) != NULL) {
542 //#warning TODO
545 if ((thisTab = GetTagByName(EC_TAG_PREFS_SECURITY)) != NULL) {
546 if ((oneTag = thisTab->GetTagByName(EC_TAG_SECURITY_CAN_SEE_SHARES)) != NULL) {
547 thePrefs::SetCanSeeShares(oneTag->GetInt());
549 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilteringClients, EC_TAG_IPFILTER_CLIENTS);
550 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilteringServers, EC_TAG_IPFILTER_SERVERS);
551 ApplyBoolean(use_tag, thisTab, thePrefs::SetIPFilterAutoLoad, EC_TAG_IPFILTER_AUTO_UPDATE);
552 if ((oneTag = thisTab->GetTagByName(EC_TAG_IPFILTER_UPDATE_URL)) != NULL) {
553 thePrefs::SetIPFilterURL(oneTag->GetStringData());
555 if ((oneTag = thisTab->GetTagByName(EC_TAG_IPFILTER_LEVEL)) != NULL) {
556 thePrefs::SetIPFilterLevel(oneTag->GetInt());
558 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterLanIPs, EC_TAG_IPFILTER_FILTER_LAN);
559 ApplyBoolean(use_tag, thisTab, thePrefs::SetSecureIdentEnabled, EC_TAG_SECURITY_USE_SECIDENT);
561 ApplyBoolean(use_tag, thisTab, thePrefs::SetClientCryptLayerSupported, EC_TAG_SECURITY_OBFUSCATION_SUPPORTED);
562 ApplyBoolean(use_tag, thisTab, thePrefs::SetClientCryptLayerRequested, EC_TAG_SECURITY_OBFUSCATION_REQUESTED);
563 ApplyBoolean(use_tag, thisTab, thePrefs::SetClientCryptLayerRequired, EC_TAG_SECURITY_OBFUSCATION_REQUIRED);
566 if ((thisTab = GetTagByName(EC_TAG_PREFS_CORETWEAKS)) != NULL) {
567 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_MAX_CONN_PER_FIVE)) != NULL) {
568 thePrefs::SetMaxConsPerFive(oneTag->GetInt());
570 ApplyBoolean(use_tag, thisTab, thePrefs::SetVerbose, EC_TAG_CORETW_VERBOSE);
571 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_FILEBUFFER)) != NULL) {
572 thePrefs::SetFileBufferSize(oneTag->GetInt());
574 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_UL_QUEUE)) != NULL) {
575 thePrefs::SetQueueSize(oneTag->GetInt());
577 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT)) != NULL) {
578 thePrefs::SetServerKeepAliveTimeout(oneTag->GetInt());
582 if ((thisTab = GetTagByName(EC_TAG_PREFS_KADEMLIA)) != NULL) {
583 if ((oneTag = thisTab->GetTagByName(EC_TAG_KADEMLIA_UPDATE_URL)) != NULL) {
584 thePrefs::SetKadNodesUrl(oneTag->GetStringData());
588 theApp->glob_prefs->Save();
590 // File_checked_for_headers