Ejemplo n.º 1
0
QString prefjson::getPreferences()
{
  const Preferences pref;
  JsonDict data;
  // UI
  data.add("locale", pref.getLocale());
  // Downloads
  data.add("save_path", pref.getSavePath());
  data.add("temp_path_enabled", pref.isTempPathEnabled());
  data.add("temp_path", pref.getTempPath());
  data.add("scan_dirs", pref.getScanDirs());
  QVariantList var_list;
  foreach (bool b, pref.getDownloadInScanDirs()) {
    var_list << b;
  }
  data.add("download_in_scan_dirs", var_list);
  data.add("export_dir_enabled", pref.isTorrentExportEnabled());
  data.add("export_dir", pref.getTorrentExportDir());
  data.add("mail_notification_enabled", pref.isMailNotificationEnabled());
  data.add("mail_notification_email", pref.getMailNotificationEmail());
  data.add("mail_notification_smtp", pref.getMailNotificationSMTP());
  data.add("mail_notification_ssl_enabled", pref.getMailNotificationSMTPSSL());
  data.add("mail_notification_auth_enabled", pref.getMailNotificationSMTPAuth());
  data.add("mail_notification_username", pref.getMailNotificationSMTPUsername());
  data.add("mail_notification_password", pref.getMailNotificationSMTPPassword());
  data.add("autorun_enabled", pref.isAutoRunEnabled());
  data.add("autorun_program", pref.getAutoRunProgram());
  data.add("preallocate_all", pref.preAllocateAllFiles());
  data.add("queueing_enabled", pref.isQueueingSystemEnabled());
  data.add("max_active_downloads", pref.getMaxActiveDownloads());
  data.add("max_active_torrents", pref.getMaxActiveTorrents());
  data.add("max_active_uploads", pref.getMaxActiveUploads());
  data.add("dont_count_slow_torrents", pref.ignoreSlowTorrentsForQueueing());
  data.add("incomplete_files_ext", pref.useIncompleteFilesExtension());
  // Connection
  data.add("listen_port", pref.getSessionPort());
  data.add("upnp", pref.isUPnPEnabled());
  data.add("dl_limit", pref.getGlobalDownloadLimit());
  data.add("up_limit", pref.getGlobalUploadLimit());
  data.add("max_connec", pref.getMaxConnecs());
  data.add("max_connec_per_torrent", pref.getMaxConnecsPerTorrent());
  data.add("max_uploads_per_torrent", pref.getMaxUploadsPerTorrent());
  data.add("enable_utp", pref.isuTPEnabled());
  data.add("limit_utp_rate", pref.isuTPRateLimited());
  data.add("limit_tcp_overhead", pref.includeOverheadInLimits());
  data.add("alt_dl_limit", pref.getAltGlobalDownloadLimit());
  data.add("alt_up_limit", pref.getAltGlobalUploadLimit());
  data.add("scheduler_enabled", pref.isSchedulerEnabled());
  const QTime start_time = pref.getSchedulerStartTime();
  data.add("schedule_from_hour", start_time.hour());
  data.add("schedule_from_min", start_time.minute());
  const QTime end_time = pref.getSchedulerEndTime();
  data.add("schedule_to_hour", end_time.hour());
  data.add("schedule_to_min", end_time.minute());
  data.add("scheduler_days", pref.getSchedulerDays());
  // Bittorrent
  data.add("dht", pref.isDHTEnabled());
  data.add("dhtSameAsBT", pref.isDHTPortSameAsBT());
  data.add("dht_port", pref.getDHTPort());
  data.add("pex", pref.isPeXEnabled());
  data.add("lsd", pref.isLSDEnabled());
  data.add("encryption", pref.getEncryptionSetting());
  data.add("anonymous_mode", pref.isAnonymousModeEnabled());
  // Proxy
  data.add("proxy_type", pref.getProxyType());
  data.add("proxy_ip", pref.getProxyIp());
  data.add("proxy_port", pref.getProxyPort());
  data.add("proxy_peer_connections", pref.proxyPeerConnections());
  data.add("proxy_auth_enabled", pref.isProxyAuthEnabled());
  data.add("proxy_username", pref.getProxyUsername());
  data.add("proxy_password", pref.getProxyPassword());
  // IP Filter
  data.add("ip_filter_enabled", pref.isFilteringEnabled());
  data.add("ip_filter_path", pref.getFilter());
  // Web UI
  data.add("web_ui_port", pref.getWebUiPort());
  data.add("web_ui_username", pref.getWebUiUsername());
  data.add("web_ui_password", pref.getWebUiPassword());
  data.add("bypass_local_auth", !pref.isWebUiLocalAuthEnabled());
  data.add("use_https", pref.isWebUiHttpsEnabled());
  data.add("ssl_key", QString::fromAscii(pref.getWebUiHttpsKey()));
  data.add("ssl_cert", QString::fromAscii(pref.getWebUiHttpsCertificate()));
  // DynDns
  data.add("dyndns_enabled", pref.isDynDNSEnabled());
  data.add("dyndns_service", pref.getDynDNSService());
  data.add("dyndns_username", pref.getDynDNSUsername());
  data.add("dyndns_password", pref.getDynDNSPassword());
  data.add("dyndns_domain", pref.getDynDomainName());

  return data.toString();
}
Ejemplo n.º 2
0
void JsonList::append(const JsonDict& dict)
{
  m_items.append(dict.toString());
  m_dirty = true;
}