示例#1
0
void Gobby::InitialDialog::on_response(int id)
{
	m_preferences->user.name = m_name_entry->get_text();
	m_preferences->user.hue = m_color_button->get_hue();
	m_preferences->user.allow_remote_access =
		m_remote_allow_connections->get_active();
	m_preferences->user.require_password =
		m_remote_require_password->get_active();
	m_preferences->user.password =
		m_remote_password_entry->get_text();
	m_preferences->security.authentication_enabled = true;
	if(m_remote_auth_self->get_active())
	{
		// The certificate generator takes care of its own:
		new InitialCertGenerator(
			*m_cert_manager, *m_status_bar,
			config_filename("key.pem"),
			config_filename("cert.pem"));
	}
	else
	{
		m_preferences->security.certificate_file =
			m_remote_auth_external_certfile->get_filename();
		m_preferences->security.key_file =
			m_remote_auth_external_keyfile->get_filename();
	}

	hide();
}
示例#2
0
int main(int argc, char *argv[]) {

    gengetopt_args_info args;
    if( cmdline_parser( argc, argv, &args ) != 0 ){
        exit(1);
    }

    QApplication a(argc, argv);
    MainWindow w;
    if( args.no_gui_arg > 0  ) {
        w.hide();
        QString config_filename(args.config_arg);
        QString paths_filename(args.paths_arg);
        QString log_filename(args.log_arg);
        QString weight_filename(args.weight_arg);
        std::cout << "loading " << config_filename.toStdString() << std::endl;
        if(w.planPath(config_filename, paths_filename, weight_filename, log_filename )) {
            std::cout << "dumping weight to " << weight_filename.toStdString() << std::endl;
            std::cout << "saving to " << paths_filename.toStdString() << std::endl;
            std::cout << "logging to " << log_filename.toStdString() << std::endl;
        }
        return 0;
    }

    w.show();
    return a.exec();
}
示例#3
0
// TODO: Support direct enum config storage via context specialization for
// enums.
Gobby::Preferences::User::User(Config::ParentEntry& entry):
	name(entry.get_value<Glib::ustring>("name", Glib::get_user_name())),
	hue(entry.get_value<double>("hue", Glib::Rand().get_double())),
	alpha(entry.get_value<double>("alpha", 1.0)),
	show_remote_cursors(entry.get_value<bool>(
		"show-remote-cursors", true)),
	show_remote_selections(entry.get_value<bool>(
		"show-remote-selections", true)),
	show_remote_current_lines(entry.get_value<bool>(
		"show-remote-current-lines", true)),
	show_remote_cursor_positions(entry.get_value<bool>(
		"show-remote-cursor-positions", true)),
	allow_remote_access(entry.get_value<bool>(
		"allow-remote-access", true)),
	require_password(entry.get_value<bool>(
		"require-password", false)),
	password(entry.get_value<std::string>(
		"password")),
	port(entry.get_value<unsigned int>(
		"port", inf_protocol_get_default_port())),
	keep_local_documents(entry.get_value<bool>(
		"keep-local-documents", true)),
	host_directory(entry.get_value<std::string>("host-directory",
		config_filename("local-documents")))
{
}
示例#4
0
void Gobby::CertificateManager::set_dh_params(gnutls_dh_params_t dh_params)
{
	gnutls_dh_params_t old_dh_params = m_dh_params;

	GError* error = NULL;
	std::string filename = config_filename("dh_params.pem");
	inf_cert_util_write_dh_params(dh_params, filename.c_str(), &error);

	if(error != NULL)
	{
		g_warning(
			_("Failed to write Diffie-Hellman parameters "
			  "to \"%s\": %s"),
			filename.c_str(),
			error->message);
		g_error_free(error);
	}

	m_dh_params = dh_params;

	make_credentials();

	// TODO: Note that the credentials do only store a pointer to the
	// DH params, so we cannot just delete the DH params here, since the
	// old credentials might still be in use.
	// For the moment we don't let this happen -- in principle it should
	// not happen; once we have valid DH params at one point we don't
	// need to change them again.
	// For the future maybe it could make sense to store the DH params
	// in the InfCertificateCredentials struct, so that their lifetime
	// is coupled.
	g_assert(old_dh_params == NULL);
}
示例#5
0
CFUSETPROC(pull_rule, architectures) {
	CFSETPROCVAR(pull_rule, this);
	retvalue r;

	this->architectures_set = true;
	r = config_getsplitatoms(iter, "Architectures",
			at_architecture,
			&this->architectures_from,
			&this->architectures_into);
	if (r == RET_NOTHING) {
		fprintf(stderr,
"Warning parsing %s, line %u: an empty Architectures field\n"
"causes the whole rule to do nothing.\n",
				config_filename(iter),
				config_markerline(iter));
	}
	return r;
}
示例#6
0
void Gobby::CertificateManager::load_dh_params()
{
	const std::string filename = config_filename("dh_params.pem");

	GError* error = NULL;
	gnutls_dh_params_t dh_params =
		inf_cert_util_read_dh_params(filename.c_str(), &error);

	if(error != NULL)
	{
		if(error->domain != G_FILE_ERROR ||
		   error->code != G_FILE_ERROR_NOENT)
		{
			g_warning(_("Failed to read Diffie-Hellman "
			            "parameters: %s"),
			          error->message);
		}

		g_error_free(error);
	}

	if(dh_params != NULL)
		set_dh_params(dh_params);
}
示例#7
0
Gobby::Browser::Browser(Gtk::Window& parent,
                        StatusBar& status_bar,
                        ConnectionManager& connection_manager):
	m_parent(parent),
	m_status_bar(status_bar),
	m_connection_manager(connection_manager),

	m_expander(_("_Direct Connection"), true),
	m_hbox(false, 6),
	m_label_hostname(_("Host Name:")),
	m_entry_hostname(config_filename("recent_hosts"), 5)
{
	m_label_hostname.show();
	m_entry_hostname.get_entry()->signal_activate().connect(
		sigc::mem_fun(*this, &Browser::on_hostname_activate));
	m_entry_hostname.show();

	m_hbox.pack_start(m_label_hostname, Gtk::PACK_SHRINK);
	m_hbox.pack_start(m_entry_hostname, Gtk::PACK_EXPAND_WIDGET);
	m_hbox.show();

	m_expander.add(m_hbox);
	m_expander.show();
	m_expander.property_expanded().signal_changed().connect(
		sigc::mem_fun(*this, &Browser::on_expanded_changed));

	m_browser_store = inf_gtk_browser_store_new(
		connection_manager.get_io(),
		connection_manager.get_communication_manager());
	
	m_sort_model = inf_gtk_browser_model_sort_new(
		INF_GTK_BROWSER_MODEL(m_browser_store));
	gtk_tree_sortable_set_default_sort_func(
		GTK_TREE_SORTABLE(m_sort_model), compare_func, NULL, NULL);

	if(m_connection_manager.get_discovery() != NULL)
	{
		inf_gtk_browser_store_add_discovery(
			m_browser_store,
			m_connection_manager.get_discovery());
	}

	Glib::ustring known_hosts_file = config_filename("known_hosts");

	m_cert_checker = inf_gtk_certificate_manager_new(
		parent.gobj(), m_connection_manager.get_xmpp_manager(),
		known_hosts_file.c_str());

	m_browser_view =
		INF_GTK_BROWSER_VIEW(
			inf_gtk_browser_view_new_with_model(
				INF_GTK_BROWSER_MODEL(m_sort_model)));

	gtk_widget_show(GTK_WIDGET(m_browser_view));
	gtk_container_add(GTK_CONTAINER(m_scroll.gobj()),
	                  GTK_WIDGET(m_browser_view));
	m_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	m_scroll.set_shadow_type(Gtk::SHADOW_IN);
	m_scroll.show();

	g_signal_connect(
		m_browser_store,
		"set-browser",
		G_CALLBACK(&on_set_browser_static),
		this
	);

	g_signal_connect(
		m_browser_view,
		"activate",
		G_CALLBACK(&on_activate_static),
		this
	);

	set_spacing(6);
	pack_start(m_scroll, Gtk::PACK_EXPAND_WIDGET);
	pack_start(m_expander, Gtk::PACK_SHRINK);

	init_accessibility();

	set_focus_child(m_expander);
}
示例#8
0
// TODO: check for scripts in confdir early...
retvalue exportmode_set(struct exportmode *mode, struct configiterator *iter) {
    retvalue r;
    char *word;

    r = config_getword(iter, &word);
    if (RET_WAS_ERROR(r))
        return r;
    if (r == RET_NOTHING) {
        fprintf(stderr,
                "Error parsing %s, line %u, column %u: Unexpected end of field!\n"
                "Filename to use for index files (Packages, Sources, ...) missing.\n",
                config_filename(iter),
                config_markerline(iter), config_markercolumn(iter));
        return RET_ERROR_MISSING;
    }
    assert (word[0] != '\0');

    if (word[0] == '.') {
        free(word);
        fprintf(stderr,
                "Error parsing %s, line %u, column %u: filename for index files expected!\n",
                config_filename(iter),
                config_markerline(iter), config_markercolumn(iter));
        return RET_ERROR;
    }

    free(mode->filename);
    mode->filename = word;

    r = config_getword(iter, &word);
    if (RET_WAS_ERROR(r))
        return r;
    if (r == RET_NOTHING)
        word = NULL;
    if (r != RET_NOTHING && word[0] != '.') {
        assert (word[0] != '\0');
        free(mode->release);
        mode->release = word;
        r = config_getword(iter, &word);
        if (RET_WAS_ERROR(r))
            return r;
    }
    if (r == RET_NOTHING) {
        fprintf(stderr,
                "Error parsing %s, line %u, column %u: Unexpected end of field!\n"
                "Compression identifiers ('.', '.gz' or '.bz2') missing.\n",
                config_filename(iter),
                config_markerline(iter), config_markercolumn(iter));
        return RET_ERROR;
    }
    if (word[0] != '.') {
        fprintf(stderr,
                "Error parsing %s, line %u, column %u:\n"
                "Compression extension ('.', '.gz' or '.bz2') expected.\n",
                config_filename(iter),
                config_markerline(iter), config_markercolumn(iter));
        free(word);
        return RET_ERROR;
    }
    mode->compressions = 0;
    while (r != RET_NOTHING && word[0] == '.') {
        if (word[1] == '\0')
            mode->compressions |= IC_FLAG(ic_uncompressed);
        else if (word[1] == 'g' && word[2] == 'z' &&
                 word[3] == '\0')
            mode->compressions |= IC_FLAG(ic_gzip);
#ifdef HAVE_LIBBZ2
        else if (word[1] == 'b' && word[2] == 'z' && word[3] == '2' &&
                 word[4] == '\0')
            mode->compressions |= IC_FLAG(ic_bzip2);
#endif
        else {
            fprintf(stderr,
                    "Error parsing %s, line %u, column %u:\n"
                    "Unsupported compression extension '%s'!\n",
                    config_filename(iter),
                    config_markerline(iter),
                    config_markercolumn(iter),
                    word);
            free(word);
            return RET_ERROR;
        }
        free(word);
        r = config_getword(iter, &word);
        if (RET_WAS_ERROR(r))
            return r;
    }
    while (r != RET_NOTHING) {
        if (word[0] == '.') {
            fprintf(stderr,
                    "Error parsing %s, line %u, column %u:\n"
                    "Scripts starting with dot are forbidden to avoid ambiguity ('%s')!\n"
                    "Try to put all compressions first and then all scripts to avoid this.\n",
                    config_filename(iter),
                    config_markerline(iter),
                    config_markercolumn(iter),
                    word);
            free(word);
            return RET_ERROR;
        } else {
            char *fullfilename = configfile_expandname(word, word);
            if (FAILEDTOALLOC(fullfilename))
                return RET_ERROR_OOM;
            r = strlist_add(&mode->hooks, fullfilename);
            if (RET_WAS_ERROR(r))
                return r;
        }
        r = config_getword(iter, &word);
        if (RET_WAS_ERROR(r))
            return r;
    }
    return RET_OK;
}
示例#9
0
retvalue tracking_parse(struct distribution *d, struct configiterator *iter) {
	enum trackingflags { tf_keep, tf_all, tf_minimal,
		tf_includechanges, tf_includebyhand, tf_includelogs,
		tf_keepsources,
		tf_needsources, tf_embargoalls,
		tf_COUNT /* must be last */
	};
	static const struct constant trackingflags[] = {
		{"keep",	tf_keep},
		{"all",		tf_all},
		{"minimal",	tf_minimal},
		{"includechanges",	tf_includechanges},
		{"includelogs",		tf_includelogs},
		{"includebyhand",	tf_includebyhand},
		{"keepsources",		tf_keepsources},
		{"needsources",		tf_needsources},
		{"embargoalls",		tf_embargoalls},
		{NULL,		-1}
	};
	bool flags[tf_COUNT];
	retvalue r;
	int modecount;

	assert (d->tracking == dt_NONE);
	memset(flags, 0, sizeof(flags));
	r = config_getflags(iter, "Tracking", trackingflags, flags,
			IGNORABLE(unknownfield), "");
	assert (r != RET_NOTHING);
	if (RET_WAS_ERROR(r))
		return r;
	modecount = flags[tf_keep]?1:0 + flags[tf_minimal]?1:0 + flags[tf_all]?1:0;
	if (modecount > 1) {
		fprintf(stderr,
"Error parsing config file %s, line %u:\n"
"Only one of 'keep','all' or 'minimal' can be in one Tracking header.\n",
			config_filename(iter), config_line(iter));
		return RET_ERROR;
	}
	if (modecount < 1) {
		fprintf(stderr,
"Error parsing config file %s, line %u, column %u:\n"
"Tracking mode ('keep','all' or 'minimal') expected.\n",
			config_filename(iter), config_line(iter),
			config_column(iter));
		return RET_ERROR;
	}
	if (flags[tf_keep])
		d->tracking = dt_KEEP;
	else if (flags[tf_minimal])
		d->tracking = dt_MINIMAL;
	else
		d->tracking = dt_ALL;

	d->trackingoptions.includechanges = flags[tf_includechanges];
	d->trackingoptions.includebyhand = flags[tf_includebyhand];
	d->trackingoptions.includelogs = flags[tf_includelogs];
	d->trackingoptions.keepsources = flags[tf_keepsources];
	d->trackingoptions.needsources = flags[tf_needsources];
	if (flags[tf_needsources])
		fprintf(stderr,
"Warning parsing config file %s, line %u:\n"
"'needsources' ignored as not yet supported.\n",
			config_filename(iter), config_line(iter));
	d->trackingoptions.embargoalls = flags[tf_embargoalls];
	if (flags[tf_embargoalls])
		fprintf(stderr,
"Warning parsing config file %s, line %u:\n"
"'embargoall' ignored as not yet supported.\n",
			config_filename(iter), config_line(iter));
	return RET_OK;
}