UDCell ummul (UCell a, UCell b) /* unsigned multiply, mixed precision */ { UDCell res; UCell m,ul,lu,uu; res.lo = a*b; /*ll = LH(a)*LH(b); dead code */ ul = UH(a)*LH(b); lu = LH(a)*UH(b); uu = UH(a)*UH(b); m = ul+lu; res.hi = (uu + L2U(m<ul) /* the carry of ul+lu */ + UH(m) + (res.lo<L2U(m)) /* the carry of ll+L2U(m) */ ); return res; }
void Settings_window::save_settings(void) { // Client --> { Private::Client& client = priv->client; Client_settings& client_settings = this->client_settings; // GUI --> { Private::Gui& gui = client.gui; Gui_settings& gui_settings = client_settings.gui; // Misc --> { Private::Gui_misc& misc = gui.misc; gui_settings.show_speed_in_window_title = misc.show_speed_in_window_title->get_active(); gui_settings.show_zero_values = misc.show_zero_values->get_active(); gui_settings.compact_details_tab = misc.compact_details_tab->get_active(); gui_settings.update_interval = misc.gui_update_interval->get_value(); gui_settings.max_log_lines = misc.max_log_lines->get_value(); gui_settings.show_tray_icon = misc.show_tray_icon->get_active(); gui_settings.hide_app_to_tray_at_startup = misc.hide_app_to_tray_at_startup->get_active(); gui_settings.minimize_to_tray = misc.minimize_to_tray->get_active(); gui_settings.close_to_tray = misc.close_to_tray->get_active(); gui_settings.download_completed_notification = misc.download_completed_notification->get_active(); gui_settings.all_downloads_completed_notification = misc.all_downloads_completed_notification->get_active(); } // Misc <-- // Status bar --> { Private::Status_bar& bar = gui.status_bar; Status_bar_settings& bar_settings = gui_settings.main_window.status_bar; bar_settings.download_speed = bar.download_speed->get_active(); bar_settings.download_payload_speed = bar.download_payload_speed->get_active(); bar_settings.upload_speed = bar.upload_speed->get_active(); bar_settings.upload_payload_speed = bar.upload_payload_speed->get_active(); bar_settings.download = bar.download->get_active(); bar_settings.payload_download = bar.payload_download->get_active(); bar_settings.upload = bar.upload->get_active(); bar_settings.payload_upload = bar.payload_upload->get_active(); bar_settings.share_ratio = bar.share_ratio->get_active(); bar_settings.failed = bar.failed->get_active(); bar_settings.redundant = bar.redundant->get_active(); } // Status bar <-- } // GUI <-- // Main --> this->client_settings.gui.show_add_torrent_dialog = this->show_add_torrent_dialog.get_active(); this->client_settings.user.start_torrent_on_adding = this->start_torrent_on_adding_check_button.get_active(); this->client_settings.user.download_to = L2U(this->download_to_button.get_filename()); if(this->copy_finished_to_check_button.get_active()) this->client_settings.user.copy_finished_to = L2U(this->copy_finished_to_button.get_filename()); else this->client_settings.user.copy_finished_to = ""; this->client_settings.user.open_command = this->open_command.get_text(); if(m::is_empty_string(this->client_settings.user.open_command)) this->client_settings.user.open_command = ""; // Main <-- } // Client <-- // Daemon --> { Daemon_settings& settings = this->daemon_settings; // Network --> // Misc --> { Private::Network_misc& misc = priv->daemon.network.misc; settings.listen_random_port = misc.random_port->get_active(); settings.listen_ports_range = std::pair<int, int>( misc.from_port->get_value(), misc.to_port->get_value()); settings.dht = misc.dht->get_active(); settings.lsd = misc.lsd->get_active(); settings.upnp = misc.upnp->get_active(); settings.natpmp = misc.natpmp->get_active(); settings.smart_ban = misc.smart_ban->get_active(); settings.pex = misc.pex->get_active(); settings.download_rate_limit = misc.download_rate_limit->get_value(); settings.upload_rate_limit = misc.upload_rate_limit->get_value(); settings.max_uploads = misc.max_uploads->get_value(); settings.max_connections = misc.max_connections->get_value(); settings.ignore_limits_on_local_network = misc.ignore_limits_on_local_network->get_active(); settings.use_max_announce_interval = misc.use_max_announce_interval->get_active(); settings.max_announce_interval = misc.max_announce_interval->get_value() * 60; } // Misc <-- // IP filter --> settings.ip_filter_enabled = priv->daemon.network.ip_filter->get_enabled(); settings.ip_filter = priv->daemon.network.ip_filter->get(); // IP filter <-- // Network <-- // Automation --> // Torrents auto load --> { Daemon_settings::Torrents_auto_load& auto_load = settings.torrents_auto_load; Private::Auto_load& load = priv->daemon.automation.load; auto_load.is = load.is->get_active(); auto_load.from = L2U(load.from->get_filename()); auto_load.to = L2U(load.to->get_filename()); auto_load.copy = load.copy->get_active(); auto_load.copy_to = L2U(load.copy_to->get_filename()); auto_load.delete_loaded = load.delete_loaded->get_active(); } // Torrents auto load <-- // Torrents auto clean --> { Daemon_settings::Auto_clean& auto_clean = settings.torrents_auto_clean; Private::Auto_clean& clean = priv->daemon.automation.clean; auto_clean.max_seeding_time = clean.max_seeding_time->get_value() * 60; auto_clean.max_seeding_time_type = clean.max_seeding_time_type; auto_clean.max_ratio = clean.max_ratio->get_value(); auto_clean.max_ratio_type = clean.max_ratio_type; auto_clean.max_seeding_torrents = clean.max_seeding_torrents->get_value(); auto_clean.max_seeding_torrents_type = clean.max_seeding_torrents_type; } // Torrents auto clean <-- // Automation <-- } // Daemon <-- }
void Client_cmd_options::parse(int argc, char *argv[]) { bool show_version = false; Glib::OptionContext cmd_parser(_("torrent_path")); if(is_gui_mode()) { // Добавляем опции GTK Gtk::Main::add_gtk_option_group(cmd_parser); } // Добавляем свои опции --> Glib::OptionGroup entries_group("main", _("Main options")); // only_pass --> Glib::OptionEntry version_entry; version_entry.set_long_name("version"); version_entry.set_flags( version_entry.get_flags() | Glib::OptionEntry::FLAG_NO_ARG ); version_entry.set_description(_("Show program version")); entries_group.add_entry(version_entry, show_version); // only_pass <-- // config_path --> // TODO: // Когда путь передается как --config ~/dir, то все нормально - // ~ раскрывается оболочкой. Но если путь передается как // --config=~/dir, то ~ не раскрывается, и не понятно, что с // ней делать - раскрывать самому - а вдруг пользователь // действительно захотел использовать директорию, содержащую ~ // в имени. Вообщем на досуге надо подумать, как лучше это // обойти. Glib::OptionEntry config_path_entry; config_path_entry.set_long_name("config"); config_path_entry.set_flags(Glib::OptionEntry::FLAG_FILENAME); config_path_entry.set_description(__("Configuration directory path (default: ~/%1)", DEFAULT_CONFIG_DIR_NAME)); config_path_entry.set_arg_description(_("DIRECTORY")); entries_group.add_entry_filename(config_path_entry, this->config_path); // config_path <-- // download_rate_limit --> Glib::OptionEntry download_rate_limit_entry; download_rate_limit_entry.set_long_name("download-rate-limit"); download_rate_limit_entry.set_description(_("Set download rate limit (KB/s)")); download_rate_limit_entry.set_arg_description(_("SPEED")); entries_group.add_entry(download_rate_limit_entry, this->download_rate_limit); // download_rate_limit <-- // upload_rate_limit --> Glib::OptionEntry upload_rate_limit_entry; upload_rate_limit_entry.set_long_name("upload-rate-limit"); upload_rate_limit_entry.set_description(_("Set upload rate limit (KB/s)")); upload_rate_limit_entry.set_arg_description(_("SPEED")); entries_group.add_entry(upload_rate_limit_entry, this->upload_rate_limit); // upload_rate_limit <-- // max_uploads --> Glib::OptionEntry max_uploads_entry; max_uploads_entry.set_long_name("max-uploads"); max_uploads_entry.set_description(_("Set maximum uploads")); max_uploads_entry.set_arg_description(_("NUMBER")); entries_group.add_entry(max_uploads_entry, this->max_uploads); // max_uploads <-- // max_connections --> Glib::OptionEntry max_connections_entry; max_connections_entry.set_long_name("max-connections"); max_connections_entry.set_description(_("Set maximum connections")); max_connections_entry.set_arg_description(_("NUMBER")); entries_group.add_entry(max_connections_entry, this->max_connections); // max_connections <-- // start --> Glib::ustring start_string; Glib::OptionEntry start_entry; start_entry.set_long_name("start"); start_entry.set_description(_("Start torrents")); start_entry.set_arg_description(_("{all,downloads,uploads}")); entries_group.add_entry(start_entry, start_string); // start <-- // stop --> Glib::ustring stop_string; Glib::OptionEntry stop_entry; stop_entry.set_long_name("stop"); stop_entry.set_description(_("Stop torrents")); stop_entry.set_arg_description(_("{all,downloads,uploads}")); entries_group.add_entry(stop_entry, stop_string); // start <-- // only_pass --> Glib::OptionEntry only_pass_entry; only_pass_entry.set_short_name('o'); only_pass_entry.set_long_name("only-pass"); only_pass_entry.set_flags( only_pass_entry.get_flags() | Glib::OptionEntry::FLAG_NO_ARG ); only_pass_entry.set_description(__("Only pass commands to already running %1 instance. Does not start new instance if it is not running yet", APP_NAME)); entries_group.add_entry(only_pass_entry, this->only_pass); // only_pass <-- // Шаблон // --> //Glib::OptionEntry _entry; //_entry.set_long_name(""); //_entry.set_description(_("")); //entries_group.add_entry(_entry, this->); // <-- cmd_parser.set_main_group(entries_group); // Добавляем свои опции <-- // Парсим полученные опции --> try { cmd_parser.parse(argc, argv); } catch(Glib::OptionError& e) { M_THROW(EE(e)); } // Парсим полученные опции <-- // Если необходимо отобразить версию программы --> if(show_version) { std::cout << APP_NAME << " " << APP_VERSION_STRING << std::endl; std::cout << m::get_copyright_string(_("Dmitry Konishchev"), APP_YEAR) << std::endl; exit(EXIT_SUCCESS); } // Если необходимо отобразить версию программы <-- // Проверяем полученные значения --> // download_rate_limit this->greater_or_equal_check("download_rate_limit", this->invalid_speed_value, this->download_rate_limit); // upload_rate_limit this->greater_or_equal_check("upload_rate_limit", this->invalid_speed_value, this->upload_rate_limit); // max_uploads this->greater_or_equal_check("max_uploads", this->invalid_number_value, this->max_uploads); // max_connections this->greater_or_equal_check("max_connections", this->invalid_number_value, this->max_connections); // start this->start_stop_check("start", start_string, &this->start); // stop this->start_stop_check("stop", stop_string, &this->stop); // Проверяем полученные значения <-- // Все оставшиеся аргументы - файлы торрентов for(int i = 1; i < argc; i++) { std::string arg = L2U(argv[i]); if(m::lt::is_magnet_uri(arg)) this->torrents_paths.push_back(arg); else { try { this->torrents_paths.push_back(Path(arg).absolute()); } catch(m::Exception& e) { MLIB_W( __("Error while processing torrent '%1'", L2U(argv[i])), __("Can't get '%1' absolute path: %2.", L2U(argv[i]), EE(e)) ); } } } }