Upstream tarball 10143
[amule.git] / src / ECSpecialMuleTags.cpp
blob0537ecdc0f46f984b138fbca62adf3b1101b079b
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::TransferFullChunks()) {
245 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_UL_FULL_CHUNKS));
247 if (thePrefs::StartNextFile()) {
248 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_START_NEXT_PAUSED));
250 if (thePrefs::StartNextFileSame()) {
251 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_RESUME_SAME_CAT));
253 if (thePrefs::GetSrcSeedsOn()) {
254 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_SAVE_SOURCES));
256 if (thePrefs::GetExtractMetaData()) {
257 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_EXTRACT_METADATA));
259 if (thePrefs::GetAllocFullFile()) {
260 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_ALLOC_FULL_SIZE));
262 if (thePrefs::IsCheckDiskspaceEnabled()) {
263 filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_CHECK_FREE_SPACE));
265 filePrefs.AddTag(CECTag(EC_TAG_FILES_MIN_FREE_SPACE, thePrefs::GetMinFreeDiskSpaceMB()));
266 AddTag(filePrefs);
269 if (selection & EC_PREFS_SRCDROP) {
270 CECEmptyTag srcdrop(EC_TAG_PREFS_SRCDROP);
271 srcdrop.AddTag(CECTag(EC_TAG_SRCDROP_NONEEDED, (uint8)thePrefs::GetNoNeededSources()));
272 if (thePrefs::DropFullQueueSources()) {
273 srcdrop.AddTag(CECEmptyTag(EC_TAG_SRCDROP_DROP_FQS));
275 if (thePrefs::DropHighQueueRankingSources()) {
276 srcdrop.AddTag(CECEmptyTag(EC_TAG_SRCDROP_DROP_HQRS));
278 srcdrop.AddTag(CECTag(EC_TAG_SRCDROP_HQRS_VALUE, (uint16)thePrefs::HighQueueRanking()));
279 srcdrop.AddTag(CECTag(EC_TAG_SRCDROP_AUTODROP_TIMER, (uint16)thePrefs::GetAutoDropTimer()));
280 AddTag(srcdrop);
283 if (selection & EC_PREFS_DIRECTORIES) {
284 CECEmptyTag dirPrefs(EC_TAG_PREFS_DIRECTORIES);
285 dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_INCOMING, thePrefs::GetIncomingDir().GetRaw()));
286 dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_TEMP, thePrefs::GetTempDir().GetRaw()));
287 uint32 sharedDirs = theApp->glob_prefs->shareddir_list.size();
288 CECTag dirtag(EC_TAG_DIRECTORIES_SHARED, sharedDirs);
289 for (size_t i = 0; i < sharedDirs; i++) {
290 dirtag.AddTag(CECTag(EC_TAG_STRING, theApp->glob_prefs->shareddir_list[i].GetRaw()));
292 dirPrefs.AddTag(dirtag);
293 dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_SHARE_HIDDEN, thePrefs::ShareHiddenFiles()));
294 AddTag(dirPrefs);
297 if (selection & EC_PREFS_STATISTICS) {
298 //#warning TODO
301 if (selection & EC_PREFS_SECURITY) {
302 CECEmptyTag secPrefs(EC_TAG_PREFS_SECURITY);
303 secPrefs.AddTag(CECTag(EC_TAG_SECURITY_CAN_SEE_SHARES, thePrefs::CanSeeShares()));
304 if (thePrefs::IsFilteringClients()) {
305 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_CLIENTS));
307 if (thePrefs::IsFilteringServers()) {
308 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_SERVERS));
310 if (thePrefs::IPFilterAutoLoad()) {
311 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_AUTO_UPDATE));
313 secPrefs.AddTag(CECTag(EC_TAG_IPFILTER_UPDATE_URL, thePrefs::IPFilterURL()));
314 secPrefs.AddTag(CECTag(EC_TAG_IPFILTER_LEVEL, thePrefs::GetIPFilterLevel()));
315 if (thePrefs::FilterLanIPs()) {
316 secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_FILTER_LAN));
318 if (thePrefs::IsSecureIdentEnabled()) {
319 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_USE_SECIDENT));
322 if (thePrefs::IsClientCryptLayerSupported()) {
323 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_SUPPORTED));
325 if (thePrefs::IsClientCryptLayerRequested()) {
326 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUESTED));
328 if (thePrefs::IsClientCryptLayerRequired()) {
329 secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUIRED));
332 AddTag(secPrefs);
335 if (selection & EC_PREFS_CORETWEAKS) {
336 CECEmptyTag cwPrefs(EC_TAG_PREFS_CORETWEAKS);
337 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_MAX_CONN_PER_FIVE, thePrefs::GetMaxConperFive()));
338 if (thePrefs::GetVerbose()) {
339 cwPrefs.AddTag(CECEmptyTag(EC_TAG_CORETW_VERBOSE));
341 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_FILEBUFFER, thePrefs::GetFileBufferSize()));
342 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_UL_QUEUE, thePrefs::GetQueueSize()));
343 cwPrefs.AddTag(CECTag(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT, thePrefs::GetServerKeepAliveTimeout()));
344 AddTag(cwPrefs);
347 if (selection & EC_PREFS_KADEMLIA) {
348 CECEmptyTag kadPrefs(EC_TAG_PREFS_KADEMLIA);
349 kadPrefs.AddTag(CECTag(EC_TAG_KADEMLIA_UPDATE_URL, thePrefs::GetKadNodesUrl()));
350 AddTag(kadPrefs);
355 * Applies a boolean value from the set_preferences request
357 * @param use_tag If true, an unset variable means "leave unchanged". If false, an unset variable means false.
358 * @param thisTab The TAG that contains the TAG with a boolean value
359 * @param applyFunc The function to use for applying the value
360 * @param tagName The name of the TAG that holds the boolean value
362 void ApplyBoolean(bool use_tag, const CECTag *thisTab, void (applyFunc)(bool), int tagName)
364 const CECTag *boolTag = thisTab->GetTagByName(tagName);
365 if (use_tag) {
366 if (boolTag != NULL) {
367 applyFunc(boolTag->GetInt() != 0);
369 } else {
370 applyFunc(boolTag != NULL);
375 * This will set all preferences except of categories, which are work as following:
376 * -> On remote gui they are loaded on startup, and then changed on-command
377 * -> Webserver doesn't supposed to change it.
379 void CEC_Prefs_Packet::Apply()
381 const CECTag *thisTab = NULL;
382 const CECTag *oneTag = NULL;
384 if ((thisTab = GetTagByName(EC_TAG_PREFS_GENERAL)) != NULL) {
385 if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_NICK)) != NULL) {
386 thePrefs::SetUserNick(oneTag->GetStringData());
388 if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_HASH)) != NULL) {
389 thePrefs::SetUserHash(oneTag->GetMD4Data());
391 if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_HOST)) != NULL) {
392 thePrefs::SetYourHostname(oneTag->GetStringData());
394 if ((oneTag = thisTab->GetTagByName(EC_TAG_GENERAL_CHECK_NEW_VERSION)) != NULL) {
395 thePrefs::SetCheckNewVersion(oneTag->GetInt() != 0);
400 // webserver doesn't transmit all boolean values
402 bool use_tag = (GetDetailLevel() == EC_DETAIL_FULL);
404 if ((thisTab = GetTagByName(EC_TAG_PREFS_CONNECTIONS)) != NULL) {
405 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_UL_CAP)) != NULL) {
406 thePrefs::SetMaxGraphUploadRate(oneTag->GetInt());
408 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_DL_CAP)) != NULL) {
409 thePrefs::SetMaxGraphDownloadRate(oneTag->GetInt());
411 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_UL)) != NULL) {
412 thePrefs::SetMaxUpload(oneTag->GetInt());
414 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_DL)) != NULL) {
415 thePrefs::SetMaxDownload(oneTag->GetInt());
417 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_SLOT_ALLOCATION)) != NULL) {
418 thePrefs::SetSlotAllocation(oneTag->GetInt());
420 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_TCP_PORT)) != NULL) {
421 thePrefs::SetPort(oneTag->GetInt());
423 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_UDP_PORT)) != NULL) {
424 thePrefs::SetUDPPort(oneTag->GetInt());
426 ApplyBoolean(use_tag, thisTab, thePrefs::SetUDPDisable, EC_TAG_CONN_UDP_DISABLE);
427 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_FILE_SOURCES)) != NULL) {
428 thePrefs::SetMaxSourcesPerFile(oneTag->GetInt());
430 if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_CONN)) != NULL) {
431 thePrefs::SetMaxConnections(oneTag->GetInt());
433 ApplyBoolean(use_tag, thisTab, thePrefs::SetAutoConnect, EC_TAG_CONN_AUTOCONNECT);
434 ApplyBoolean(use_tag, thisTab, thePrefs::SetReconnect, EC_TAG_CONN_RECONNECT);
435 ApplyBoolean(use_tag, thisTab, thePrefs::SetNetworkED2K, EC_TAG_NETWORK_ED2K);
436 ApplyBoolean(use_tag, thisTab, thePrefs::SetNetworkKademlia, EC_TAG_NETWORK_KADEMLIA);
439 if ((thisTab = GetTagByName(EC_TAG_PREFS_MESSAGEFILTER)) != NULL) {
440 ApplyBoolean(use_tag, thisTab, thePrefs::SetMustFilterMessages, EC_TAG_MSGFILTER_ENABLED);
441 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterAllMessages, EC_TAG_MSGFILTER_ALL);
442 ApplyBoolean(use_tag, thisTab, thePrefs::SetMsgOnlyFriends, EC_TAG_MSGFILTER_FRIENDS);
443 ApplyBoolean(use_tag, thisTab, thePrefs::SetMsgOnlySecure, EC_TAG_MSGFILTER_SECURE);
444 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterByKeywords, EC_TAG_MSGFILTER_BY_KEYWORD);
445 if ((oneTag = thisTab->GetTagByName(EC_TAG_MSGFILTER_KEYWORDS)) != NULL) {
446 thePrefs::SetMessageFilterString(oneTag->GetStringData());
450 if ((thisTab = GetTagByName(EC_TAG_PREFS_REMOTECTRL)) != NULL) {
451 ApplyBoolean(use_tag, thisTab, thePrefs::SetWSIsEnabled, EC_TAG_WEBSERVER_AUTORUN);
452 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_PORT)) != NULL) {
453 thePrefs::SetWSPort(oneTag->GetInt());
455 if ((oneTag = thisTab->GetTagByName(EC_TAG_PASSWD_HASH)) != NULL) {
456 thePrefs::SetWSPass(oneTag->GetMD4Data().Encode());
458 ApplyBoolean(use_tag, thisTab, thePrefs::SetWSIsLowUserEnabled, EC_TAG_WEBSERVER_GUEST);
459 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_GUEST)) != NULL) {
460 if ((oneTag->GetTagByName(EC_TAG_PASSWD_HASH)) != NULL) {
461 thePrefs::SetWSLowPass(oneTag->GetTagByName(EC_TAG_PASSWD_HASH)->GetMD4Data().Encode());
464 ApplyBoolean(use_tag, thisTab, thePrefs::SetWebUseGzip, EC_TAG_WEBSERVER_USEGZIP);
465 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_REFRESH)) != NULL) {
466 thePrefs::SetWebPageRefresh(oneTag->GetInt());
468 if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_TEMPLATE)) != NULL) {
469 thePrefs::SetWebTemplate(oneTag->GetStringData());
473 if ((thisTab = GetTagByName(EC_TAG_PREFS_ONLINESIG)) != NULL) {
474 ApplyBoolean(use_tag, thisTab, thePrefs::SetOnlineSignatureEnabled, EC_TAG_ONLINESIG_ENABLED);
477 if ((thisTab = GetTagByName(EC_TAG_PREFS_SERVERS)) != NULL) {
478 ApplyBoolean(use_tag, thisTab, thePrefs::SetDeadServer, EC_TAG_SERVERS_REMOVE_DEAD);
479 if ((oneTag = thisTab->GetTagByName(EC_TAG_SERVERS_DEAD_SERVER_RETRIES)) != NULL) {
480 thePrefs::SetDeadserverRetries(oneTag->GetInt());
482 ApplyBoolean(use_tag, thisTab, thePrefs::SetAutoServerlist, EC_TAG_SERVERS_AUTO_UPDATE);
483 // Here should come the URL list...
484 ApplyBoolean(use_tag, thisTab, thePrefs::SetAddServersFromServer, EC_TAG_SERVERS_ADD_FROM_SERVER);
485 ApplyBoolean(use_tag, thisTab, thePrefs::SetAddServersFromClient, EC_TAG_SERVERS_ADD_FROM_CLIENT);
486 ApplyBoolean(use_tag, thisTab, thePrefs::SetScoreSystem, EC_TAG_SERVERS_USE_SCORE_SYSTEM);
487 ApplyBoolean(use_tag, thisTab, thePrefs::SetSmartIdCheck, EC_TAG_SERVERS_SMART_ID_CHECK);
488 ApplyBoolean(use_tag, thisTab, thePrefs::SetSafeServerConnectEnabled, EC_TAG_SERVERS_SAFE_SERVER_CONNECT);
489 ApplyBoolean(use_tag, thisTab, thePrefs::SetAutoConnectStaticOnly, EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY);
490 ApplyBoolean(use_tag, thisTab, thePrefs::SetManualHighPrio, EC_TAG_SERVERS_MANUAL_HIGH_PRIO);
491 if ((oneTag = thisTab->GetTagByName(EC_TAG_SERVERS_UPDATE_URL)) != NULL) {
492 thePrefs::SetEd2kServersUrl(oneTag->GetStringData());
496 if ((thisTab = GetTagByName(EC_TAG_PREFS_FILES)) != NULL) {
497 ApplyBoolean(use_tag, thisTab, thePrefs::SetICHEnabled, EC_TAG_FILES_ICH_ENABLED);
498 ApplyBoolean(use_tag, thisTab, thePrefs::SetTrustingEveryHash, EC_TAG_FILES_AICH_TRUST);
499 ApplyBoolean(use_tag, thisTab, thePrefs::SetAddNewFilesPaused, EC_TAG_FILES_NEW_PAUSED);
500 ApplyBoolean(use_tag, thisTab, thePrefs::SetNewAutoDown, EC_TAG_FILES_NEW_AUTO_DL_PRIO);
501 ApplyBoolean(use_tag, thisTab, thePrefs::SetPreviewPrio, EC_TAG_FILES_PREVIEW_PRIO);
502 ApplyBoolean(use_tag, thisTab, thePrefs::SetNewAutoUp, EC_TAG_FILES_NEW_AUTO_UL_PRIO);
503 ApplyBoolean(use_tag, thisTab, thePrefs::SetTransferFullChunks, EC_TAG_FILES_UL_FULL_CHUNKS);
504 ApplyBoolean(use_tag, thisTab, thePrefs::SetStartNextFile, EC_TAG_FILES_START_NEXT_PAUSED);
505 ApplyBoolean(use_tag, thisTab, thePrefs::SetStartNextFileSame, EC_TAG_FILES_RESUME_SAME_CAT);
506 ApplyBoolean(use_tag, thisTab, thePrefs::SetSrcSeedsOn, EC_TAG_FILES_SAVE_SOURCES);
507 ApplyBoolean(use_tag, thisTab, thePrefs::SetExtractMetaData, EC_TAG_FILES_EXTRACT_METADATA);
508 ApplyBoolean(use_tag, thisTab, thePrefs::SetAllocFullFile, EC_TAG_FILES_ALLOC_FULL_SIZE);
509 ApplyBoolean(use_tag, thisTab, thePrefs::SetCheckDiskspaceEnabled, EC_TAG_FILES_CHECK_FREE_SPACE);
510 if ((oneTag = thisTab->GetTagByName(EC_TAG_FILES_MIN_FREE_SPACE)) != NULL) {
511 thePrefs::SetMinFreeDiskSpaceMB(oneTag->GetInt());
515 if ((thisTab = GetTagByName(EC_TAG_PREFS_SRCDROP)) != NULL) {
516 if ((oneTag = thisTab->GetTagByName(EC_TAG_SRCDROP_NONEEDED)) != NULL) {
517 thePrefs::SetNoNeededSources(oneTag->GetInt());
519 ApplyBoolean(use_tag, thisTab, thePrefs::SetDropFullQueueSources, EC_TAG_SRCDROP_DROP_FQS);
520 ApplyBoolean(use_tag, thisTab, thePrefs::SetDropHighQueueRankingSources, EC_TAG_SRCDROP_DROP_HQRS);
521 if ((oneTag = thisTab->GetTagByName(EC_TAG_SRCDROP_HQRS_VALUE)) != NULL) {
522 thePrefs::SetHighQueueRanking(oneTag->GetInt());
524 if ((oneTag = thisTab->GetTagByName(EC_TAG_SRCDROP_AUTODROP_TIMER)) != NULL) {
525 thePrefs::SetAutoDropTimer(oneTag->GetInt());
529 if ((thisTab = GetTagByName(EC_TAG_PREFS_DIRECTORIES)) != NULL) {
530 if ((oneTag = thisTab->GetTagByName(EC_TAG_DIRECTORIES_INCOMING)) != NULL) {
531 thePrefs::SetIncomingDir(CPath(oneTag->GetStringData()));
533 if ((oneTag = thisTab->GetTagByName(EC_TAG_DIRECTORIES_TEMP)) != NULL) {
534 thePrefs::SetTempDir(CPath(oneTag->GetStringData()));
536 if ((oneTag = thisTab->GetTagByName(EC_TAG_DIRECTORIES_SHARED)) != NULL) {
537 theApp->glob_prefs->shareddir_list.clear();
538 for (CECTag::const_iterator it = oneTag->begin(); it != oneTag->end(); it++) {
539 theApp->glob_prefs->shareddir_list.push_back(CPath(it->GetStringData()));
542 ApplyBoolean(use_tag, thisTab, thePrefs::SetShareHiddenFiles, EC_TAG_DIRECTORIES_SHARE_HIDDEN);
545 if ((thisTab = GetTagByName(EC_TAG_PREFS_STATISTICS)) != NULL) {
546 //#warning TODO
549 if ((thisTab = GetTagByName(EC_TAG_PREFS_SECURITY)) != NULL) {
550 if ((oneTag = thisTab->GetTagByName(EC_TAG_SECURITY_CAN_SEE_SHARES)) != NULL) {
551 thePrefs::SetCanSeeShares(oneTag->GetInt());
553 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilteringClients, EC_TAG_IPFILTER_CLIENTS);
554 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilteringServers, EC_TAG_IPFILTER_SERVERS);
555 ApplyBoolean(use_tag, thisTab, thePrefs::SetIPFilterAutoLoad, EC_TAG_IPFILTER_AUTO_UPDATE);
556 if ((oneTag = thisTab->GetTagByName(EC_TAG_IPFILTER_UPDATE_URL)) != NULL) {
557 thePrefs::SetIPFilterURL(oneTag->GetStringData());
559 if ((oneTag = thisTab->GetTagByName(EC_TAG_IPFILTER_LEVEL)) != NULL) {
560 thePrefs::SetIPFilterLevel(oneTag->GetInt());
562 ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterLanIPs, EC_TAG_IPFILTER_FILTER_LAN);
563 ApplyBoolean(use_tag, thisTab, thePrefs::SetSecureIdentEnabled, EC_TAG_SECURITY_USE_SECIDENT);
565 ApplyBoolean(use_tag, thisTab, thePrefs::SetClientCryptLayerSupported, EC_TAG_SECURITY_OBFUSCATION_SUPPORTED);
566 ApplyBoolean(use_tag, thisTab, thePrefs::SetClientCryptLayerRequested, EC_TAG_SECURITY_OBFUSCATION_REQUESTED);
567 ApplyBoolean(use_tag, thisTab, thePrefs::SetClientCryptLayerRequired, EC_TAG_SECURITY_OBFUSCATION_REQUIRED);
570 if ((thisTab = GetTagByName(EC_TAG_PREFS_CORETWEAKS)) != NULL) {
571 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_MAX_CONN_PER_FIVE)) != NULL) {
572 thePrefs::SetMaxConsPerFive(oneTag->GetInt());
574 ApplyBoolean(use_tag, thisTab, thePrefs::SetVerbose, EC_TAG_CORETW_VERBOSE);
575 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_FILEBUFFER)) != NULL) {
576 thePrefs::SetFileBufferSize(oneTag->GetInt());
578 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_UL_QUEUE)) != NULL) {
579 thePrefs::SetQueueSize(oneTag->GetInt());
581 if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT)) != NULL) {
582 thePrefs::SetServerKeepAliveTimeout(oneTag->GetInt());
586 if ((thisTab = GetTagByName(EC_TAG_PREFS_KADEMLIA)) != NULL) {
587 if ((oneTag = thisTab->GetTagByName(EC_TAG_KADEMLIA_UPDATE_URL)) != NULL) {
588 thePrefs::SetKadNodesUrl(oneTag->GetStringData());
592 theApp->glob_prefs->Save();
594 // File_checked_for_headers