コード例 #1
0
ファイル: preferences.cpp プロジェクト: ankurjain41282/gobby
// 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")))
{
}
コード例 #2
0
/**
 * infinoted_options_new:
 * @config_files: A %NULL-terminated error of config filenames.
 * @argc: Pointer to command line argument count, or %NULL.
 * @argv: Pointer to command line argument vector, or %NULL.
 * @error: Location to store error information, if any.
 *
 * Creates a new #InfinotedOptions structure that contains options infinoted
 * is supposed to start with. Command line options always overwrite config
 * file options.
 *
 * The config files are loaded in order, which means that config files at the
 * back of the array overwrite options of config files in front of the array.
 * Config files are not required to exist. If a given config file does not
 * exist, it is simply ignored.
 *
 * Returns: A new #InfinotedOptions, or %NULL in case of error.
 * Free with infinoted_options_free().
 */
InfinotedOptions*
infinoted_options_new(const gchar* const* config_files,
                      int* argc,
                      char*** argv,
                      GError** error)
{
  InfinotedOptions* options;

  options = g_slice_new(InfinotedOptions);

  /* Default options */
  options->key_file = NULL;
  options->certificate_file = NULL;
  options->certificate_chain_file = NULL;
  options->create_key = FALSE;
  options->create_certificate = FALSE;
  options->port = inf_protocol_get_default_port();
  options->security_policy = INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS;
  options->root_directory =
    g_build_filename(g_get_home_dir(), ".infinote", NULL);
  options->autosave_interval = 0;
  options->password = NULL;
#ifdef LIBINFINITY_HAVE_PAM
  options->pam_service = NULL;
  options->pam_allowed_users = NULL;
  options->pam_allowed_groups = NULL;
#endif /* LIBINFINITY_HAVE_PAM */
  options->sync_directory = NULL;
  options->sync_interval = 0;

#ifdef LIBINFINITY_HAVE_LIBDAEMON
  options->daemonize = FALSE;
#endif

  if(!infinoted_options_load(options, config_files, argc, argv, error))
  {
    infinoted_options_free(options);
    return NULL;
  }

  return options;
}
コード例 #3
0
int
main(int argc,
     char* argv[])
{
    InfTestMassJoin massjoin;
    GError* error;
    int i;
    gchar* name;

    error = NULL;
    if(!inf_init(&error))
    {
        fprintf(stderr, "%s\n", error->message);
        return -1;
    }

    massjoin.io = INF_IO(inf_standalone_io_new());
    massjoin.joiners = NULL;

    for(i = 0; i < 128; ++i)
    {
        name = g_strdup_printf("MassJoin%03d", i);

        inf_test_mass_join_connect(
            &massjoin,
            "127.0.0.1",
            inf_protocol_get_default_port(),
            "Test",
            name
        );

        g_free(name);
        //g_usleep(100000);
    }

    inf_standalone_io_loop(INF_STANDALONE_IO(massjoin.io));
    return 0;
}
コード例 #4
0
int
main(int argc, char* argv[])
{
  InfTestBrowser test;
  InfIpAddress* address;
  InfCommunicationManager* manager;
  InfTcpConnection* tcp_conn;
  GError* error;

  gnutls_global_init();
  g_type_init();

  test.io = inf_standalone_io_new();
#ifndef G_OS_WIN32
  test.input_fd = STDIN_FILENO;
#endif
  address = inf_ip_address_new_loopback4();

  error = NULL;
  tcp_conn =
    inf_tcp_connection_new_and_open(INF_IO(test.io), address, inf_protocol_get_default_port(), &error);

  inf_ip_address_free(address);

  if(tcp_conn == NULL)
  {
    fprintf(stderr, "Could not open TCP connection: %s\n", error->message);
    g_error_free(error);
  }
  else
  {
    test.conn = inf_xmpp_connection_new(
      tcp_conn,
      INF_XMPP_CONNECTION_CLIENT,
      NULL,
      "localhost",
      INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS,
      NULL,
      NULL,
      NULL
    );

    g_object_unref(G_OBJECT(tcp_conn));

    manager = inf_communication_manager_new();
    test.browser = INF_BROWSER(
      infc_browser_new(
        INF_IO(test.io),
        manager,
        INF_XML_CONNECTION(test.conn)
      )
    );

    g_signal_connect_after(
      G_OBJECT(test.browser),
      "notify::status",
      G_CALLBACK(inf_test_browser_notify_status_cb),
      &test
    );

    g_signal_connect(
      G_OBJECT(test.browser),
      "error",
      G_CALLBACK(inf_test_browser_error_cb),
      &test
    );

    inf_standalone_io_loop(test.io);
    g_object_unref(G_OBJECT(manager));
    g_object_unref(G_OBJECT(test.browser));

    /* TODO: Wait until the XMPP connection is in status closed */
    g_object_unref(G_OBJECT(test.conn));
  }

  g_object_unref(G_OBJECT(test.io));
  return 0;
}