| File: | rootdir/src/ECSpecialMuleTags.cpp |
| Warning: | line 518, column 7 Although the value stored to 'thisTab' is used in the enclosing expression, the value is never actually read from 'thisTab' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | // |
| 2 | // This file is part of the aMule Project. |
| 3 | // |
| 4 | // Copyright (c) 2003-2011 Angel Vidal ( kry@amule.org ) |
| 5 | // Copyright (c) 2003-2011 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. |
| 10 | // |
| 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. |
| 15 | // |
| 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 |
| 24 | // |
| 25 | |
| 26 | |
| 27 | |
| 28 | #include <ec/cpp/ECTag.h> // Needed for CECTag |
| 29 | #include <ec/cpp/ECSpecialTags.h> // Needed for special EC tag creator classes |
| 30 | |
| 31 | #include "Preferences.h" |
| 32 | #include "amule.h" |
| 33 | |
| 34 | CEC_Category_Tag::CEC_Category_Tag(uint32 cat_index, EC_DETAIL_LEVEL detail_level) : CECTag(EC_TAG_CATEGORY, cat_index) |
| 35 | { |
| 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 | /* fall through */ |
| 47 | case EC_DETAIL_CMD: |
| 48 | AddTag(CECTag(EC_TAG_CATEGORY_TITLE, cat->title)); |
| 49 | } |
| 50 | } |
| 51 | |
| 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) |
| 54 | { |
| 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)); |
| 60 | } |
| 61 | |
| 62 | bool CEC_Category_Tag::Apply() |
| 63 | { |
| 64 | bool ret = theApp->glob_prefs->UpdateCategory(GetInt(), Name(), CPath(Path()), Comment(), Color(), Prio()); |
| 65 | if (!ret) { |
| 66 | GetTagByName(EC_TAG_CATEGORY_PATH)->SetStringData(theApp->glob_prefs->GetCatPath(GetInt()).GetRaw()); |
| 67 | } |
| 68 | return ret; |
| 69 | } |
| 70 | |
| 71 | bool CEC_Category_Tag::Create() |
| 72 | { |
| 73 | Category_Struct * category = NULL__null; |
| 74 | bool ret = theApp->glob_prefs->CreateCategory(category, Name(), CPath(Path()), Comment(), Color(), Prio()); |
| 75 | if (!ret) { |
| 76 | GetTagByName(EC_TAG_CATEGORY_PATH)->SetStringData(theApp->glob_prefs->GetCatPath( |
| 77 | theApp->glob_prefs->GetCatCount() - 1).GetRaw()); |
| 78 | } |
| 79 | return ret; |
| 80 | } |
| 81 | |
| 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) |
| 83 | { |
| 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); |
| 89 | cats.AddTag(catTag); |
| 90 | } |
| 91 | AddTag(cats); |
| 92 | } |
| 93 | } |
| 94 | |
| 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())); |
| 101 | AddTag(user_prefs); |
| 102 | } |
| 103 | |
| 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)); |
| 115 | } |
| 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)); |
| 120 | } |
| 121 | if (thePrefs::Reconnect()) { |
| 122 | connPrefs.AddTag(CECEmptyTag(EC_TAG_CONN_RECONNECT)); |
| 123 | } |
| 124 | if (thePrefs::GetNetworkED2K()) { |
| 125 | connPrefs.AddTag(CECEmptyTag(EC_TAG_NETWORK_ED2K)); |
| 126 | } |
| 127 | if (thePrefs::GetNetworkKademlia()) { |
| 128 | connPrefs.AddTag(CECEmptyTag(EC_TAG_NETWORK_KADEMLIA)); |
| 129 | } |
| 130 | AddTag(connPrefs); |
| 131 | } |
| 132 | |
| 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)); |
| 137 | } |
| 138 | if (thePrefs::IsFilterAllMessages()) { |
| 139 | msg_prefs.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_ALL)); |
| 140 | } |
| 141 | if (thePrefs::MsgOnlyFriends()) { |
| 142 | msg_prefs.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_FRIENDS)); |
| 143 | } |
| 144 | if (thePrefs::MsgOnlySecure()) { |
| 145 | msg_prefs.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_SECURE)); |
| 146 | } |
| 147 | if (thePrefs::IsFilterByKeywords()) { |
| 148 | msg_prefs.AddTag(CECEmptyTag(EC_TAG_MSGFILTER_BY_KEYWORD)); |
| 149 | } |
| 150 | msg_prefs.AddTag(CECTag(EC_TAG_MSGFILTER_KEYWORDS, thePrefs::GetMessageFilterString())); |
| 151 | AddTag(msg_prefs); |
| 152 | } |
| 153 | |
| 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)); |
| 159 | } |
| 160 | if (!thePrefs::GetWSPass().IsEmpty()) { |
| 161 | CMD4Hash passhash; |
| 162 | wxCHECK2(passhash.Decode(thePrefs::GetWSPass()), /* Do nothing. */)if ( passhash.Decode(thePrefs::GetWSPass()) ) {} else { do { if ( wxTheAssertHandler && (wxOnAssert("ECSpecialMuleTags.cpp" , 162, __FUNCTION__, "\"passhash.Decode(thePrefs::GetWSPass())\"" , (const char*)__null), wxTrapInAssert) ) { wxTrapInAssert = false ; asm volatile ("int $3"); } } while ( (void)0, 0 ); ; } struct wxDummyCheckStruct162; |
| 163 | rc_prefs.AddTag(CECTag(EC_TAG_PASSWD_HASH, passhash)); |
| 164 | } |
| 165 | if (thePrefs::GetWSIsLowUserEnabled()) { |
| 166 | CECEmptyTag lowUser(EC_TAG_WEBSERVER_GUEST); |
| 167 | if (!thePrefs::GetWSLowPass().IsEmpty()) { |
| 168 | CMD4Hash passhash; |
| 169 | wxCHECK2(passhash.Decode(thePrefs::GetWSLowPass()), /* Do nothing. */)if ( passhash.Decode(thePrefs::GetWSLowPass()) ) {} else { do { if ( wxTheAssertHandler && (wxOnAssert("ECSpecialMuleTags.cpp" , 169, __FUNCTION__, "\"passhash.Decode(thePrefs::GetWSLowPass())\"" , (const char*)__null), wxTrapInAssert) ) { wxTrapInAssert = false ; asm volatile ("int $3"); } } while ( (void)0, 0 ); ; } struct wxDummyCheckStruct169; |
| 170 | lowUser.AddTag(CECTag(EC_TAG_PASSWD_HASH, passhash)); |
| 171 | } |
| 172 | rc_prefs.AddTag(lowUser); |
| 173 | } |
| 174 | if (thePrefs::GetWebUseGzip()) { |
| 175 | rc_prefs.AddTag(CECEmptyTag(EC_TAG_WEBSERVER_USEGZIP)); |
| 176 | } |
| 177 | rc_prefs.AddTag(CECTag(EC_TAG_WEBSERVER_REFRESH, thePrefs::GetWebPageRefresh())); |
| 178 | rc_prefs.AddTag(CECTag(EC_TAG_WEBSERVER_TEMPLATE, thePrefs::GetWebTemplate())); |
| 179 | AddTag(rc_prefs); |
| 180 | } |
| 181 | |
| 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)); |
| 186 | } |
| 187 | AddTag(online_sig); |
| 188 | } |
| 189 | |
| 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)); |
| 194 | } |
| 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)); |
| 198 | } |
| 199 | // Here should come the URL list... |
| 200 | if (thePrefs::AddServersFromServer()) { |
| 201 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_SERVER)); |
| 202 | } |
| 203 | if (thePrefs::AddServersFromClient()) { |
| 204 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_ADD_FROM_CLIENT)); |
| 205 | } |
| 206 | if (thePrefs::Score()) { |
| 207 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_USE_SCORE_SYSTEM)); |
| 208 | } |
| 209 | if (thePrefs::GetSmartIdCheck()) { |
| 210 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_SMART_ID_CHECK)); |
| 211 | } |
| 212 | if (thePrefs::IsSafeServerConnectEnabled()) { |
| 213 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_SAFE_SERVER_CONNECT)); |
| 214 | } |
| 215 | if (thePrefs::AutoConnectStaticOnly()) { |
| 216 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_AUTOCONN_STATIC_ONLY)); |
| 217 | } |
| 218 | if (thePrefs::IsManualHighPrio()) { |
| 219 | srv_prefs.AddTag(CECEmptyTag(EC_TAG_SERVERS_MANUAL_HIGH_PRIO)); |
| 220 | } |
| 221 | srv_prefs.AddTag(CECTag(EC_TAG_SERVERS_UPDATE_URL, thePrefs::GetEd2kServersUrl())); |
| 222 | AddTag(srv_prefs); |
| 223 | } |
| 224 | |
| 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)); |
| 229 | } |
| 230 | if (thePrefs::IsTrustingEveryHash()) { |
| 231 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_AICH_TRUST)); |
| 232 | } |
| 233 | if (thePrefs::AddNewFilesPaused()) { |
| 234 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_PAUSED)); |
| 235 | } |
| 236 | if (thePrefs::GetNewAutoDown()) { |
| 237 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_DL_PRIO)); |
| 238 | } |
| 239 | if (thePrefs::GetPreviewPrio()) { |
| 240 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_PREVIEW_PRIO)); |
| 241 | } |
| 242 | if (thePrefs::GetNewAutoUp()) { |
| 243 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_NEW_AUTO_UL_PRIO)); |
| 244 | } |
| 245 | if (thePrefs::StartNextFile()) { |
| 246 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_START_NEXT_PAUSED)); |
| 247 | } |
| 248 | if (thePrefs::StartNextFileSame()) { |
| 249 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_RESUME_SAME_CAT)); |
| 250 | } |
| 251 | if (thePrefs::GetSrcSeedsOn()) { |
| 252 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_SAVE_SOURCES)); |
| 253 | } |
| 254 | if (thePrefs::GetExtractMetaData()) { |
| 255 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_EXTRACT_METADATA)); |
| 256 | } |
| 257 | if (thePrefs::GetAllocFullFile()) { |
| 258 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_ALLOC_FULL_SIZE)); |
| 259 | } |
| 260 | if (thePrefs::IsCheckDiskspaceEnabled()) { |
| 261 | filePrefs.AddTag(CECEmptyTag(EC_TAG_FILES_CHECK_FREE_SPACE)); |
| 262 | } |
| 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)); |
| 266 | } |
| 267 | AddTag(filePrefs); |
| 268 | } |
| 269 | |
| 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())); |
| 278 | } |
| 279 | dirPrefs.AddTag(dirtag); |
| 280 | dirPrefs.AddTag(CECTag(EC_TAG_DIRECTORIES_SHARE_HIDDEN, thePrefs::ShareHiddenFiles())); |
| 281 | AddTag(dirPrefs); |
| 282 | } |
| 283 | |
| 284 | if (selection & EC_PREFS_STATISTICS) { |
| 285 | //#warning TODO |
| 286 | } |
| 287 | |
| 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)); |
| 293 | } |
| 294 | if (thePrefs::IsFilteringServers()) { |
| 295 | secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_SERVERS)); |
| 296 | } |
| 297 | if (thePrefs::IPFilterAutoLoad()) { |
| 298 | secPrefs.AddTag(CECEmptyTag(EC_TAG_IPFILTER_AUTO_UPDATE)); |
| 299 | } |
| 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)); |
| 304 | } |
| 305 | if (thePrefs::IsSecureIdentEnabled()) { |
| 306 | secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_USE_SECIDENT)); |
| 307 | } |
| 308 | |
| 309 | if (thePrefs::IsClientCryptLayerSupported()) { |
| 310 | secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_SUPPORTED)); |
| 311 | } |
| 312 | if (thePrefs::IsClientCryptLayerRequested()) { |
| 313 | secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUESTED)); |
| 314 | } |
| 315 | if (thePrefs::IsClientCryptLayerRequired()) { |
| 316 | secPrefs.AddTag(CECEmptyTag(EC_TAG_SECURITY_OBFUSCATION_REQUIRED)); |
| 317 | } |
| 318 | |
| 319 | AddTag(secPrefs); |
| 320 | } |
| 321 | |
| 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)); |
| 327 | } |
| 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())); |
| 331 | AddTag(cwPrefs); |
| 332 | } |
| 333 | |
| 334 | if (selection & EC_PREFS_KADEMLIA) { |
| 335 | CECEmptyTag kadPrefs(EC_TAG_PREFS_KADEMLIA); |
| 336 | kadPrefs.AddTag(CECTag(EC_TAG_KADEMLIA_UPDATE_URL, thePrefs::GetKadNodesUrl())); |
| 337 | AddTag(kadPrefs); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Applies a boolean value from the set_preferences request |
| 343 | * |
| 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 |
| 348 | */ |
| 349 | static void ApplyBoolean(bool use_tag, const CECTag *thisTab, void (applyFunc)(bool), int tagName) |
| 350 | { |
| 351 | const CECTag *boolTag = thisTab->GetTagByName(tagName); |
| 352 | if (use_tag) { |
| 353 | if (boolTag != NULL__null) { |
| 354 | applyFunc(boolTag->GetInt() != 0); |
| 355 | } |
| 356 | } else { |
| 357 | applyFunc(boolTag != NULL__null); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /* |
| 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. |
| 365 | */ |
| 366 | void CEC_Prefs_Packet::Apply() const |
| 367 | { |
| 368 | const CECTag *thisTab = NULL__null; |
| 369 | const CECTag *oneTag = NULL__null; |
| 370 | |
| 371 | if ((thisTab = GetTagByName(EC_TAG_PREFS_GENERAL)) != NULL__null) { |
| 372 | if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_NICK)) != NULL__null) { |
| 373 | thePrefs::SetUserNick(oneTag->GetStringData()); |
| 374 | } |
| 375 | if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_HASH)) != NULL__null) { |
| 376 | thePrefs::SetUserHash(oneTag->GetMD4Data()); |
| 377 | } |
| 378 | if ((oneTag = thisTab->GetTagByName(EC_TAG_USER_HOST)) != NULL__null) { |
| 379 | thePrefs::SetYourHostname(oneTag->GetStringData()); |
| 380 | } |
| 381 | if ((oneTag = thisTab->GetTagByName(EC_TAG_GENERAL_CHECK_NEW_VERSION)) != NULL__null) { |
| 382 | thePrefs::SetCheckNewVersion(oneTag->GetInt() != 0); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | // |
| 387 | // webserver doesn't transmit all boolean values |
| 388 | // |
| 389 | bool use_tag = (GetDetailLevel() == EC_DETAIL_FULL); |
| 390 | |
| 391 | if ((thisTab = GetTagByName(EC_TAG_PREFS_CONNECTIONS)) != NULL__null) { |
| 392 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_UL_CAP)) != NULL__null) { |
| 393 | thePrefs::SetMaxGraphUploadRate(oneTag->GetInt()); |
| 394 | } |
| 395 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_DL_CAP)) != NULL__null) { |
| 396 | thePrefs::SetMaxGraphDownloadRate(oneTag->GetInt()); |
| 397 | } |
| 398 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_UL)) != NULL__null) { |
| 399 | thePrefs::SetMaxUpload(oneTag->GetInt()); |
| 400 | } |
| 401 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_DL)) != NULL__null) { |
| 402 | thePrefs::SetMaxDownload(oneTag->GetInt()); |
| 403 | } |
| 404 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_SLOT_ALLOCATION)) != NULL__null) { |
| 405 | thePrefs::SetSlotAllocation(oneTag->GetInt()); |
| 406 | } |
| 407 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_TCP_PORT)) != NULL__null) { |
| 408 | thePrefs::SetPort(oneTag->GetInt()); |
| 409 | } |
| 410 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_UDP_PORT)) != NULL__null) { |
| 411 | thePrefs::SetUDPPort(oneTag->GetInt()); |
| 412 | } |
| 413 | ApplyBoolean(use_tag, thisTab, thePrefs::SetUDPDisable, EC_TAG_CONN_UDP_DISABLE); |
| 414 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_FILE_SOURCES)) != NULL__null) { |
| 415 | thePrefs::SetMaxSourcesPerFile(oneTag->GetInt()); |
| 416 | } |
| 417 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CONN_MAX_CONN)) != NULL__null) { |
| 418 | thePrefs::SetMaxConnections(oneTag->GetInt()); |
| 419 | } |
| 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); |
| 424 | } |
| 425 | |
| 426 | if ((thisTab = GetTagByName(EC_TAG_PREFS_MESSAGEFILTER)) != NULL__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__null) { |
| 433 | thePrefs::SetMessageFilterString(oneTag->GetStringData()); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | if ((thisTab = GetTagByName(EC_TAG_PREFS_REMOTECTRL)) != NULL__null) { |
| 438 | ApplyBoolean(use_tag, thisTab, thePrefs::SetWSIsEnabled, EC_TAG_WEBSERVER_AUTORUN); |
| 439 | if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_PORT)) != NULL__null) { |
| 440 | thePrefs::SetWSPort(oneTag->GetInt()); |
| 441 | } |
| 442 | if ((oneTag = thisTab->GetTagByName(EC_TAG_PASSWD_HASH)) != NULL__null) { |
| 443 | thePrefs::SetWSPass(oneTag->GetMD4Data().Encode()); |
| 444 | } |
| 445 | ApplyBoolean(use_tag, thisTab, thePrefs::SetWSIsLowUserEnabled, EC_TAG_WEBSERVER_GUEST); |
| 446 | if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_GUEST)) != NULL__null) { |
| 447 | if ((oneTag->GetTagByName(EC_TAG_PASSWD_HASH)) != NULL__null) { |
| 448 | thePrefs::SetWSLowPass(oneTag->GetTagByName(EC_TAG_PASSWD_HASH)->GetMD4Data().Encode()); |
| 449 | } |
| 450 | } |
| 451 | ApplyBoolean(use_tag, thisTab, thePrefs::SetWebUseGzip, EC_TAG_WEBSERVER_USEGZIP); |
| 452 | if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_REFRESH)) != NULL__null) { |
| 453 | thePrefs::SetWebPageRefresh(oneTag->GetInt()); |
| 454 | } |
| 455 | if ((oneTag = thisTab->GetTagByName(EC_TAG_WEBSERVER_TEMPLATE)) != NULL__null) { |
| 456 | thePrefs::SetWebTemplate(oneTag->GetStringData()); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | if ((thisTab = GetTagByName(EC_TAG_PREFS_ONLINESIG)) != NULL__null) { |
| 461 | ApplyBoolean(use_tag, thisTab, thePrefs::SetOnlineSignatureEnabled, EC_TAG_ONLINESIG_ENABLED); |
| 462 | } |
| 463 | |
| 464 | if ((thisTab = GetTagByName(EC_TAG_PREFS_SERVERS)) != NULL__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__null) { |
| 467 | thePrefs::SetDeadserverRetries(oneTag->GetInt()); |
| 468 | } |
| 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__null) { |
| 479 | thePrefs::SetEd2kServersUrl(oneTag->GetStringData()); |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | if ((thisTab = GetTagByName(EC_TAG_PREFS_FILES)) != NULL__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__null) { |
| 497 | thePrefs::SetMinFreeDiskSpaceMB(oneTag->GetInt()); |
| 498 | } |
| 499 | ApplyBoolean(use_tag, thisTab, thePrefs::CreateFilesNormal, EC_TAG_FILES_CREATE_NORMAL); |
| 500 | } |
| 501 | |
| 502 | if ((thisTab = GetTagByName(EC_TAG_PREFS_DIRECTORIES)) != NULL__null) { |
| 503 | if ((oneTag = thisTab->GetTagByName(EC_TAG_DIRECTORIES_INCOMING)) != NULL__null) { |
| 504 | thePrefs::SetIncomingDir(CPath(oneTag->GetStringData())); |
| 505 | } |
| 506 | if ((oneTag = thisTab->GetTagByName(EC_TAG_DIRECTORIES_TEMP)) != NULL__null) { |
| 507 | thePrefs::SetTempDir(CPath(oneTag->GetStringData())); |
| 508 | } |
| 509 | if ((oneTag = thisTab->GetTagByName(EC_TAG_DIRECTORIES_SHARED)) != NULL__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())); |
| 513 | } |
| 514 | } |
| 515 | ApplyBoolean(use_tag, thisTab, thePrefs::SetShareHiddenFiles, EC_TAG_DIRECTORIES_SHARE_HIDDEN); |
| 516 | } |
| 517 | |
| 518 | if ((thisTab = GetTagByName(EC_TAG_PREFS_STATISTICS)) != NULL__null) { |
Although the value stored to 'thisTab' is used in the enclosing expression, the value is never actually read from 'thisTab' | |
| 519 | //#warning TODO |
| 520 | } |
| 521 | |
| 522 | if ((thisTab = GetTagByName(EC_TAG_PREFS_SECURITY)) != NULL__null) { |
| 523 | if ((oneTag = thisTab->GetTagByName(EC_TAG_SECURITY_CAN_SEE_SHARES)) != NULL__null) { |
| 524 | thePrefs::SetCanSeeShares(oneTag->GetInt()); |
| 525 | } |
| 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__null) { |
| 530 | thePrefs::SetIPFilterURL(oneTag->GetStringData()); |
| 531 | } |
| 532 | if ((oneTag = thisTab->GetTagByName(EC_TAG_IPFILTER_LEVEL)) != NULL__null) { |
| 533 | thePrefs::SetIPFilterLevel(oneTag->GetInt()); |
| 534 | } |
| 535 | ApplyBoolean(use_tag, thisTab, thePrefs::SetFilterLanIPs, EC_TAG_IPFILTER_FILTER_LAN); |
| 536 | ApplyBoolean(use_tag, thisTab, thePrefs::SetSecureIdentEnabled, EC_TAG_SECURITY_USE_SECIDENT); |
| 537 | |
| 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); |
| 541 | } |
| 542 | |
| 543 | if ((thisTab = GetTagByName(EC_TAG_PREFS_CORETWEAKS)) != NULL__null) { |
| 544 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_MAX_CONN_PER_FIVE)) != NULL__null) { |
| 545 | thePrefs::SetMaxConsPerFive(oneTag->GetInt()); |
| 546 | } |
| 547 | ApplyBoolean(use_tag, thisTab, thePrefs::SetVerbose, EC_TAG_CORETW_VERBOSE); |
| 548 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_FILEBUFFER)) != NULL__null) { |
| 549 | thePrefs::SetFileBufferSize(oneTag->GetInt()); |
| 550 | } |
| 551 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_UL_QUEUE)) != NULL__null) { |
| 552 | thePrefs::SetQueueSize(oneTag->GetInt()); |
| 553 | } |
| 554 | if ((oneTag = thisTab->GetTagByName(EC_TAG_CORETW_SRV_KEEPALIVE_TIMEOUT)) != NULL__null) { |
| 555 | thePrefs::SetServerKeepAliveTimeout(oneTag->GetInt()); |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | if ((thisTab = GetTagByName(EC_TAG_PREFS_KADEMLIA)) != NULL__null) { |
| 560 | if ((oneTag = thisTab->GetTagByName(EC_TAG_KADEMLIA_UPDATE_URL)) != NULL__null) { |
| 561 | thePrefs::SetKadNodesUrl(oneTag->GetStringData()); |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | theApp->glob_prefs->Save(); |
| 566 | } |
| 567 | // File_checked_for_headers |