void DNSUpdater::updateCredentials() { if (m_state == FATAL) return; Preferences pref; bool change = false; // Get DNS service information if (m_service != pref.getDynDNSService()) { m_service = pref.getDynDNSService(); change = true; } if (m_domain != pref.getDynDomainName()) { m_domain = pref.getDynDomainName(); QRegExp domain_regex("^(?:(?!\\d|-)[a-zA-Z0-9\\-]{1,63}\\.)+[a-zA-Z]{2,}$"); if (domain_regex.indexIn(m_domain) < 0) { QBtSession::instance()->addConsoleMessage(tr("Dynamic DNS error: supplied domain name is invalid."), "red"); m_lastIP.clear(); m_ipCheckTimer.stop(); m_state = INVALID_CREDS; return; } change = true; } if (m_username != pref.getDynDNSUsername()) { m_username = pref.getDynDNSUsername(); if (m_username.length() < 4) { QBtSession::instance()->addConsoleMessage(tr("Dynamic DNS error: supplied username is too short."), "red"); m_lastIP.clear(); m_ipCheckTimer.stop(); m_state = INVALID_CREDS; return; } change = true; } if (m_password != pref.getDynDNSPassword()) { m_password = pref.getDynDNSPassword(); if (m_password.length() < 4) { QBtSession::instance()->addConsoleMessage(tr("Dynamic DNS error: supplied password is too short."), "red"); m_lastIP.clear(); m_ipCheckTimer.stop(); m_state = INVALID_CREDS; return; } change = true; } if (m_state == INVALID_CREDS && change) { m_state = OK; // Try again m_ipCheckTimer.start(); checkPublicIP(); } }
QByteArray prefjson::getPreferences() { const Preferences pref; QVariantMap data; // UI data["locale"] = pref.getLocale(); // Downloads data["save_path"] = fsutils::toNativePath(pref.getSavePath()); data["temp_path_enabled"] = pref.isTempPathEnabled(); data["temp_path"] = fsutils::toNativePath(pref.getTempPath()); QVariantList l; foreach (const QString& s, pref.getScanDirs()) { l << fsutils::toNativePath(s); } data["scan_dirs"] = l; QVariantList var_list; foreach (bool b, pref.getDownloadInScanDirs()) { var_list << b; } data["download_in_scan_dirs"] = var_list; data["export_dir_enabled"] = pref.isTorrentExportEnabled(); data["export_dir"] = fsutils::toNativePath(pref.getTorrentExportDir()); data["mail_notification_enabled"] = pref.isMailNotificationEnabled(); data["mail_notification_email"] = pref.getMailNotificationEmail(); data["mail_notification_smtp"] = pref.getMailNotificationSMTP(); data["mail_notification_ssl_enabled"] = pref.getMailNotificationSMTPSSL(); data["mail_notification_auth_enabled"] = pref.getMailNotificationSMTPAuth(); data["mail_notification_username"] = pref.getMailNotificationSMTPUsername(); data["mail_notification_password"] = pref.getMailNotificationSMTPPassword(); data["autorun_enabled"] = pref.isAutoRunEnabled(); data["autorun_program"] = fsutils::toNativePath(pref.getAutoRunProgram()); data["preallocate_all"] = pref.preAllocateAllFiles(); data["queueing_enabled"] = pref.isQueueingSystemEnabled(); data["max_active_downloads"] = pref.getMaxActiveDownloads(); data["max_active_torrents"] = pref.getMaxActiveTorrents(); data["max_active_uploads"] = pref.getMaxActiveUploads(); data["dont_count_slow_torrents"] = pref.ignoreSlowTorrentsForQueueing(); data["incomplete_files_ext"] = pref.useIncompleteFilesExtension(); // Connection data["listen_port"] = pref.getSessionPort(); data["upnp"] = pref.isUPnPEnabled(); data["dl_limit"] = pref.getGlobalDownloadLimit(); data["up_limit"] = pref.getGlobalUploadLimit(); data["max_connec"] = pref.getMaxConnecs(); data["max_connec_per_torrent"] = pref.getMaxConnecsPerTorrent(); data["max_uploads_per_torrent"] = pref.getMaxUploadsPerTorrent(); data["enable_utp"] = pref.isuTPEnabled(); data["limit_utp_rate"] = pref.isuTPRateLimited(); data["limit_tcp_overhead"] = pref.includeOverheadInLimits(); data["alt_dl_limit"] = pref.getAltGlobalDownloadLimit(); data["alt_up_limit"] = pref.getAltGlobalUploadLimit(); data["scheduler_enabled"] = pref.isSchedulerEnabled(); const QTime start_time = pref.getSchedulerStartTime(); data["schedule_from_hour"] = start_time.hour(); data["schedule_from_min"] = start_time.minute(); const QTime end_time = pref.getSchedulerEndTime(); data["schedule_to_hour"] = end_time.hour(); data["schedule_to_min"] = end_time.minute(); data["scheduler_days"] = pref.getSchedulerDays(); // Bittorrent data["dht"] = pref.isDHTEnabled(); data["dhtSameAsBT"] = pref.isDHTPortSameAsBT(); data["dht_port"] = pref.getDHTPort(); data["pex"] = pref.isPeXEnabled(); data["lsd"] = pref.isLSDEnabled(); data["encryption"] = pref.getEncryptionSetting(); data["anonymous_mode"] = pref.isAnonymousModeEnabled(); // Proxy data["proxy_type"] = pref.getProxyType(); data["proxy_ip"] = pref.getProxyIp(); data["proxy_port"] = pref.getProxyPort(); data["proxy_peer_connections"] = pref.proxyPeerConnections(); data["proxy_auth_enabled"] = pref.isProxyAuthEnabled(); data["proxy_username"] = pref.getProxyUsername(); data["proxy_password"] = pref.getProxyPassword(); // IP Filter data["ip_filter_enabled"] = pref.isFilteringEnabled(); data["ip_filter_path"] = fsutils::toNativePath(pref.getFilter()); // Web UI data["web_ui_port"] = pref.getWebUiPort(); data["web_ui_username"] = pref.getWebUiUsername(); data["web_ui_password"] = pref.getWebUiPassword(); data["bypass_local_auth"] = !pref.isWebUiLocalAuthEnabled(); data["use_https"] = pref.isWebUiHttpsEnabled(); data["ssl_key"] = QString::fromLatin1(pref.getWebUiHttpsKey()); data["ssl_cert"] = QString::fromLatin1(pref.getWebUiHttpsCertificate()); // DynDns data["dyndns_enabled"] = pref.isDynDNSEnabled(); data["dyndns_service"] = pref.getDynDNSService(); data["dyndns_username"] = pref.getDynDNSUsername(); data["dyndns_password"] = pref.getDynDNSPassword(); data["dyndns_domain"] = pref.getDynDomainName(); return json::toJson(data); }