예제 #1
0
string config_handler::get_config_file() { 

  if( config_file == "" ) {
    if( get_config_file_path() != "" ) config_file += get_config_file_path();
    else                               config_file += utils::get_base_dir();
    
    if( get_config_file_name() != "" ) config_file += get_config_file_name();
    else                               config_file += "config"; // TODO - make default
  }    
  
  return config_file; 
}
예제 #2
0
static svn_error_t *
test_has_section_case_sensitive(const svn_test_opts_t *opts,
                                apr_pool_t *pool)
{
  svn_config_t *cfg;
  const char *cfg_file;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, TRUE, FALSE, pool));

  if (! svn_config_has_section(cfg, "section1"))
    return fail(pool, "Failed to find section1");

  if (svn_config_has_section(cfg, "SECTION1"))
    return fail(pool, "Returned true on missing section");

  if (! svn_config_has_section(cfg, "UpperCaseSection"))
    return fail(pool, "Failed to find UpperCaseSection");

  if (svn_config_has_section(cfg, "uppercasesection"))
    return fail(pool, "Returned true on missing section");

  if (svn_config_has_section(cfg, "notthere"))
    return fail(pool, "Returned true on missing section");

  return SVN_NO_ERROR;
}
예제 #3
0
static svn_error_t *
test_read_only_mode(const svn_test_opts_t *opts,
                    apr_pool_t *pool)
{
  svn_config_t *cfg;
  svn_config_t *cfg2;
  const char *cfg_file;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, TRUE, FALSE, pool));

  /* setting CFG to r/o mode shall toggle the r/o mode and expand values */

  SVN_TEST_ASSERT(!svn_config__is_read_only(cfg));
  SVN_TEST_ASSERT(!svn_config__is_expanded(cfg, "section1", "i"));

  svn_config__set_read_only(cfg, pool);

  SVN_TEST_ASSERT(svn_config__is_read_only(cfg));
  SVN_TEST_ASSERT(svn_config__is_expanded(cfg, "section1", "i"));

  /* copies should be r/w with values */

  SVN_ERR(svn_config_dup(&cfg2, cfg, pool));
  SVN_TEST_ASSERT(!svn_config__is_read_only(cfg2));

  return SVN_NO_ERROR;
}
예제 #4
0
static svn_error_t *
test_expand(const svn_test_opts_t *opts,
            apr_pool_t *pool)
{
  svn_config_t *cfg;
  const char *cfg_file, *val;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, TRUE, FALSE, pool));

  /* Get expanded "g" which requires expanding "c". */
  svn_config_get(cfg, &val, "section1", "g", NULL);

  /* Get expanded "c". */
  svn_config_get(cfg, &val, "section1", "c", NULL);

  /* With pool debugging enabled this ensures that the expanded value
     of "c" was not created in a temporary pool when expanding "g". */
  SVN_TEST_STRING_ASSERT(val, "bar");

  /* Get expanded "j" and "k" which have cyclic definitions.
   * They must return empty values. */
  svn_config_get(cfg, &val, "section1", "j", NULL);
  SVN_TEST_STRING_ASSERT(val, "");
  svn_config_get(cfg, &val, "section1", "k", NULL);
  SVN_TEST_STRING_ASSERT(val, "");

  /* Get expanded "l" which depends on a cyclic definition.
   * So, it also considered "undefined" and will be normalized to "". */
  svn_config_get(cfg, &val, "section1", "l", NULL);
  SVN_TEST_STRING_ASSERT(val, "");

  return SVN_NO_ERROR;
}
예제 #5
0
static svn_error_t *
test_boolean_retrieval(const svn_test_opts_t *opts,
                       apr_pool_t *pool)
{
  svn_config_t *cfg;
  int i;
  const char *cfg_file;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, FALSE, FALSE, pool));

  for (i = 0; true_keys[i] != NULL; i++)
    {
      svn_boolean_t value;
      SVN_ERR(svn_config_get_bool(cfg, &value, "booleans", true_keys[i],
                                  FALSE));
      if (!value)
        return fail(pool, "Value of option '%s' is not true", true_keys[i]);
    }

  for (i = 0; false_keys[i] != NULL; i++)
    {
      svn_boolean_t value;
      SVN_ERR(svn_config_get_bool(cfg, &value, "booleans", false_keys[i],
                                  TRUE));
      if (value)
        return fail(pool, "Value of option '%s' is not true", false_keys[i]);
    }

  {
    svn_error_t *err;
    svn_boolean_t value;

    svn_error_clear((err = svn_config_get_bool(cfg, &value,
                                               "booleans", "bad_true",
                                               TRUE)));
    if (!err)
      return fail(pool, "No error on bad truth value");

    svn_error_clear((err = svn_config_get_bool(cfg, &value,
                                               "booleans", "bad_false",
                                               FALSE)));
    if (!err)
      return fail(pool, "No error on bad truth value");
  }

  {
    svn_boolean_t value;
    SVN_ERR(svn_config_get_server_setting_bool(cfg, &value, "server group",
                                               "setting", FALSE));
    if (value)
      return svn_error_create(SVN_ERR_TEST_FAILED, SVN_NO_ERROR,
                              "Expected a svn_config_get_server_setting_bool()"
                              "to return FALSE, but it returned TRUE");
  }

  return SVN_NO_ERROR;
}
예제 #6
0
/* Display the path of the default configuration file when `-p` is not used */
void
display_default_config_file (void)
{
  char *path = get_config_file_path ();

  if (!path) {
    fprintf (stdout, "No default config file found.\n");
    fprintf (stdout, "You may specify one with `-p /path/goaccess.conf`\n");
  } else {
    fprintf (stdout, "%s\n", path);
    free (path);
  }
}
예제 #7
0
파일: commons.c 프로젝트: allinurl/goaccess
/* Display the path of the default configuration file when `-p` is not used */
void
display_default_config_file (void)
{
  char *path = get_config_file_path ();

  if (!path) {
    fprintf (stdout, "%s\n", ERR_NODEF_CONF_FILE);
    fprintf (stdout, "%s `-p /path/goaccess.conf`\n", ERR_NODEF_CONF_FILE_DESC);
  } else {
    fprintf (stdout, "%s\n", path);
    free (path);
  }
}
예제 #8
0
void config_handler::print() {
  //
  // Display internal settings set from reading steering
  //
  string mn = "print:";
  string def = "<default>";

  int w1=30; //arbitrary spacing size that makes formatting look pretty for data names
  int w2=30; //arbitrary spacing size that makes formatting look pretty for data options

  
  cout<<cn<<mn<<" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
      <<"\n"<<setw(w1)<<"DEBUG: "                       <<setw(w2)<<(debug? "ON":"OFF")
      <<"\n"<<setw(w1)<<"RUN IN BACKGROUND: "           <<setw(w2)<<(get_background()? "ON":"OFF")
      <<"\n"<<setw(w1)<<"SIMULATION: "                  <<setw(w2)<<(get_simulate()? "ON":"OFF")
      <<"\n"<<setw(w1)<<"FILTER FIRST: "                <<setw(w2)<<(get_filter()? "ON":"OFF")
      <<"\n"<<setw(w1)<<"SAVE RECORDINGS: "             <<setw(w2)<<(get_save_rec()? "ON":"OFF")
      <<"\n"<<setw(w1)<<"HUMAN READABLE OUTPUT: "       <<setw(w2)<<(get_output_formatted()? "ON":"OFF")
      <<"\n"<<setw(w1)<<"Output Type ID: "              <<setw(w2)<<"\""<<get_output_type_id()<<"\""
      <<"\n"<<setw(w1)<<"RPi Latitude: "                <<setw(w2)<<"\""<<get_latitude()<<"\""
      <<"\n"<<setw(w1)<<"RPi Longitude: "               <<setw(w2)<<"\""<<get_longitude()<<"\""
      <<"\n"<<setw(w1)<<"RPi ID: "                      <<setw(w2)<<"\""<<get_rpid()<<"\""
      <<"\n"<<setw(w1)<<"Simulation Data Dir: "         <<setw(w2)<<"\""<<get_simulate_dir()<<"\""
      <<"\n"<<setw(w1)<<"Config Path: "                 <<setw(w2)<<"\""<<get_config_file_path()<<"\""
      <<"\n"<<setw(w1)<<"Config Name: "                 <<setw(w2)<<"\""<<get_config_file_name()<<"\""
      <<"\n"<<setw(w1)<<"Config File: "                 <<setw(w2)<<"\""<<get_config_file()<<"\""
      <<"\n"<<setw(w1)<<"Final Feature Format: "        <<setw(w2)<<"\""<<get_final_feature_format()<<"\""
      <<"\n"<<setw(w1)<<"Filter Vector Path: "          <<setw(w2)<<"\""<<get_fv_filter_path()<<"\""
      <<"\n"<<setw(w1)<<"Filter Vector Name: "          <<setw(w2)<<"\""<<get_fv_filter_name()<<"\""
      <<"\n"<<setw(w1)<<"Filter Vector File: "          <<setw(w2)<<"\""<<get_fv_filter()<<"\""
      <<"\n"<<setw(w1)<<"Feature Vector Path: "         <<setw(w2)<<"\""<<get_fv_file_path()<<"\""
      <<"\n"<<setw(w1)<<"Feature Vector Name: "         <<setw(w2)<<"\""<<get_fv_file_name()<<"\""
      <<"\n"<<setw(w1)<<"Feature Vector File: "         <<setw(w2)<<"\""<<get_fv_file()<<"\""
      <<"\n"<<setw(w1)<<"Analysis File(s) Path: "       <<setw(w2)<<"\""<<get_analysis_location()<<"\""
      <<"\n"<<setw(w1)<<"Data File(s) Path: "           <<setw(w2)<<"\""<<get_data_location()<<"\""
      <<"\n"<<setw(w1)<<"Media Location File Path: "    <<setw(w2)<<"\""<<get_media_location()<<"\""
      <<"\n"<<setw(w1)<<"Recording Extention: "         <<setw(w2)<<"\""<<get_rec_extention()<<"\""
      <<"\n"<<setw(w1)<<"Recording File Name Prefix: "  <<setw(w2)<<"\""<<get_rec_file_name_prefix()<<"\""
      <<"\n"<<setw(w1)<<"Recording Rate: "              <<setw(w2)<<"\""<<get_samp_rate()<<"\""
      <<"\n"<<setw(w1)<<"Recording Duration: "          <<setw(w2)<<"\""<<get_rec_duration()<<"\""
      <<"\n"<<setw(w1)<<"Recording Number: "            <<setw(w2)<<"\""<<get_rec_number()<<"\""<<endl;
  cout<<cn<<mn<<" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;            
  
  return;
}
예제 #9
0
static svn_error_t *
test_text_retrieval(const svn_test_opts_t *opts,
                    apr_pool_t *pool)
{
  svn_config_t *cfg;
  int i;
  const char *cfg_file;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, FALSE, FALSE, pool));

  /* Test values retrieved from our ConfigParser instance against
     values retrieved using svn_config. */
  for (i = 0; config_keys[i] != NULL; i++)
    {
      const char *key, *py_val, *c_val;

      key = config_keys[i];
      py_val = config_values[i];
      svn_config_get(cfg, &c_val, "section1", key, "default value");
#if 0
      printf("Testing expected value '%s' against '%s' for "
             "option '%s'\n", py_val, c_val, key);
#endif
      /* Fail iff one value is null, or the strings don't match. */
      if ((c_val == NULL) != (py_val == NULL)
          || (c_val != NULL && py_val != NULL && strcmp(c_val, py_val) != 0))
        return fail(pool, "Expected value '%s' not equal to '%s' for "
                    "option '%s'", py_val, c_val, key);
    }

  {
    const char *value = svn_config_get_server_setting(cfg, "server group",
                                                      "setting", "default");
    if (value == NULL || strcmp(value, "default") != 0)
      return svn_error_create(SVN_ERR_TEST_FAILED, SVN_NO_ERROR,
                              "Expected a svn_config_get_server_setting()"
                              "to return 'default'");
  }

  return SVN_NO_ERROR;
}
예제 #10
0
void remember_no_welcome_screen_option()
{
    // enable no_welcome_screen option in command line options config file!
    char* cfg_file_path = get_config_file_path();
    FILE* gtypistrc = fopen(cfg_file_path, "a+");
    if (gtypistrc == NULL)
    {
        fatal_error( _("Error reading/writing config file!"), NULL );
    }
    int no_welcome_screen_option_found = FALSE;
    size_t len = 0;
    char* line = NULL;

    while (getline(&line, &len, gtypistrc) != -1)
    {
        /* remove control chars (newline, CR) at end of line */
        int idx = len;
        while (idx >= 0 && line[idx] < 0x20)
        {
            line[idx] = '\0';
            idx--;
        }

        if (strcmp(line, "no-welcome-screen") == 0)
        {
            no_welcome_screen_option_found = TRUE;
        }
    }
    if (!no_welcome_screen_option_found) 
    {
        /* append "no-welcome-screen" option */
        fprintf(gtypistrc, "no-welcome-screen\n");
    }
    fclose(gtypistrc);
    if (line)
    {
        free(line);
        line = NULL;
    }
    free(cfg_file_path);
}
예제 #11
0
static svn_error_t *
test_stream_interface(const svn_test_opts_t *opts,
                      apr_pool_t *pool)
{
  svn_config_t *cfg;
  const char *cfg_file;
  svn_stream_t *stream;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_stream_open_readonly(&stream, cfg_file, pool, pool));

  SVN_ERR(svn_config_parse(&cfg, stream, TRUE, TRUE, pool));

  /* nominal test to make sure cfg is populated with something since
   * svn_config_parse will happily return an empty cfg if the stream is
   * empty. */
  if (! svn_config_has_section(cfg, "section1"))
    return fail(pool, "Failed to find section1");

  return SVN_NO_ERROR;
}
예제 #12
0
config_handler::config_handler( string fpath, string fname = "" )
{
  string mn = "config_handler:"; 
  cout<<mn<<" Constructor started for file \""<<fname<<"\"."<<endl;

  debug = true;
  init();


  if( fpath == "" ) fpath = utils::get_home_dir();
  if( fname == "" ) utils::get_base( fpath );
  if( fname == "" ) fname = "cirainbow.conf";

  // make sure default or custom config file is found
  // User coice, home directory "cirainbow.conf", local directory "sound_settings.conf"
  if( utils::is_file_readable( utils::pathify(fpath) + fname ) == false ) {

    cout<<cn<<mn<<" Initial config file not accesable at: \""<<utils::pathify(fpath)+fname<<"\"."<<endl;
    fpath = utils::get_base_dir();
    fname = "sound_settings.conf";
  }

  //cout<<cn<<mn<<" Config file here: \""<<utils::pathify(fpath)+fname<<"\"."<<endl; //TEST
  //exit( 0 ); //TEST


  set_config_file_path( fpath );
  set_config_file_name( fname );

  string configFile = get_config_file_path() + get_config_file_name();
  set_config_file( configFile );

  cout<<cn<<mn<<" Config file here: \""<<get_config_file()<<"\"."<<endl;


  read_config( configFile );


  cout<<cn<<mn<<" Constructor finished for file \""<<fname<<"\"."<<endl;
}
예제 #13
0
static svn_error_t *
test_has_option_case_sensitive(const svn_test_opts_t *opts,
                               apr_pool_t *pool)
{
  svn_config_t *cfg;
  const char *cfg_file;
  apr_int64_t value;
  int i;

  static struct test_dataset {
    const char *option;
    apr_int64_t value;
  } const test_data[] = {
    { "a", 1 },
    { "A", 2 },
    { "B", 3 },
    { "b", 4 }
  };
  static const int test_data_size = sizeof(test_data)/sizeof(*test_data);

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, TRUE, TRUE, pool));

  for (i = 0; i < test_data_size; ++i)
    {
      SVN_ERR(svn_config_get_int64(cfg, &value, "case-sensitive-option",
                                   test_data[i].option, -1));
      if (test_data[i].value != value)
        return fail(pool,
                    apr_psprintf(pool,
                                 "case-sensitive-option.%s != %"
                                 APR_INT64_T_FMT" but %"APR_INT64_T_FMT,
                                 test_data[i].option,
                                 test_data[i].value,
                                 value));
    }

  return SVN_NO_ERROR;
}
예제 #14
0
static svn_error_t *
test_expand(const svn_test_opts_t *opts,
            apr_pool_t *pool)
{
  svn_config_t *cfg;
  const char *cfg_file, *val;

  SVN_ERR(get_config_file_path(&cfg_file, opts, pool));
  SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, TRUE, FALSE, pool));

  /* Get expanded "g" which requires expanding "c". */
  svn_config_get(cfg, &val, "section1", "g", NULL);

  /* Get expanded "c". */
  svn_config_get(cfg, &val, "section1", "c", NULL);

  /* With pool debugging enabled this ensures that the expanded value
     of "c" was not created in a temporary pool when expanding "g". */
  SVN_TEST_STRING_ASSERT(val, "bar");

  return SVN_NO_ERROR;
}
예제 #15
0
파일: common.c 프로젝트: AOSC-Dev/gnome-mpv
/* This only supports migrating from v0.5's config file */
gboolean migrate_config(gmpv_handle *ctx)
{
	gchar *config_file = get_config_file_path();
	gboolean result = FALSE;

	if(g_file_test(config_file, G_FILE_TEST_EXISTS))
	{
		const gchar *key_list[] = {	"csd-enable",
						"dark-theme-enable",
						"mpv-input-config-enable",
						"mpv-config-enable",
						"mpv-input-config-file",
						"mpv-config-file",
						"mpv-options",
						NULL };

		GSettingsBackend *backend;
		GSettings *keyfile_settings;
		GSettings *default_settings;
		const gchar **iter;

		backend = g_keyfile_settings_backend_new
				(	config_file,
					"/org/gnome-mpv/gnome-mpv/",
					"main" );

		keyfile_settings = g_settings_new_with_backend(	CONFIG_ROOT,
								backend );

		default_settings = g_settings_new(CONFIG_ROOT);
		iter = key_list;

		while(*iter)
		{
			GVariant *value;

			value = g_settings_get_value(keyfile_settings, *iter);

			g_settings_set_value(default_settings, *iter, value);

			iter++;

			g_variant_unref(value);
		}

		g_object_unref(backend);
		g_object_unref(keyfile_settings);
		g_object_unref(default_settings);

		/* Rename the old config file */
		gchar *backup_config_file = g_strconcat(	config_file,
								".bak",
								NULL );

		GFile *src = g_file_new_for_path(config_file);
		GFile *dest = g_file_new_for_path(backup_config_file);

		result = g_file_move(	src,
					dest,
					G_FILE_COPY_NONE,
					NULL,
					NULL,
					NULL,
					NULL );

		g_free(backup_config_file);
		g_object_unref(src);
		g_object_unref(dest);
	}

	g_free(config_file);

	return result;
}
예제 #16
0
/* parses configuration file to feed getopt_long */
int
parse_conf_file (int *argc, char ***argv)
{
  char line[MAX_LINE_CONF + 1];
  char *path = NULL, *val, *opt, *p;
  FILE *file;
  int i;
  size_t idx;

  /* assumes program name is on argv[0], though, it is not guaranteed */
  append_to_argv (&nargc, &nargv, xstrdup ((char *) *argv[0]));

  /* determine which config file to open, default or custom */
  path = get_config_file_path ();
  if (path == NULL)
    return ENOENT;

  /* could not open conf file, if so prompt conf dialog */
  if ((file = fopen (path, "r")) == NULL) {
    free (path);
    return ENOENT;
  }

  while (fgets (line, sizeof line, file) != NULL) {
    if (line[0] == '\n' || line[0] == '\r' || line[0] == '#')
      continue;

    /* key */
    idx = strcspn (line, " \t");
    if (strlen (line) == idx)
      FATAL ("Malformed config key at line: %s", line);

    line[idx] = '\0';

    /* make old config options backwards compatible by
     * substituting underscores with dashes */
    while ((p = strpbrk (line, "_")) != NULL)
      *p = '-';

    /* Ignore the following options when reading the config file */
    if (in_ignore_cmd_opts (line))
      continue;

    /* value */
    val = line + (idx + 1);
    idx = strspn (val, " \t");
    if (strlen (line) == idx)
      FATAL ("Malformed config value at line: %s", line);
    val = val + idx;
    val = trim_str (val);

    if (strcmp ("false", val) == 0)
      continue;

    /* set it as command line options */
    opt = xmalloc (snprintf (NULL, 0, "--%s", line) + 1);
    sprintf (opt, "--%s", line);

    append_to_argv (&nargc, &nargv, opt);
    if (strcmp ("true", val) != 0)
      append_to_argv (&nargc, &nargv, xstrdup (val));
  }

  /* give priority to command line arguments */
  for (i = 1; i < *argc; i++)
    append_to_argv (&nargc, &nargv, xstrdup ((char *) (*argv)[i]));

  *argc = nargc;
  *argv = (char **) nargv;

  fclose (file);

  if (conf.iconfigfile == NULL)
    conf.iconfigfile = xstrdup (path);

  free (path);
  return 0;
}
예제 #17
0
파일: main.c 프로젝트: gnarula/gnome-mpv
static void app_startup_handler(GApplication *app, gpointer data)
{
	gmpv_handle *ctx = data;
	const gchar *vid_area_style = ".gmpv-vid-area{background-color: black}";
	GSettingsBackend *config_backend;
	GtkCssProvider *style_provider;
	gboolean css_loaded;
	gboolean use_opengl;
	gboolean config_migrated;
	gboolean mpvinput_enable;
	gboolean csd_enable;
	gboolean dark_theme_enable;
	gchar *config_file;
	gchar *mpvinput;

	setlocale(LC_NUMERIC, "C");
	g_set_application_name(_("GNOME MPV"));
	gtk_window_set_default_icon_name(ICON_NAME);

	bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);

	config_file = get_config_file_path();

	config_backend = g_keyfile_settings_backend_new
				(	config_file,
					CONFIG_ROOT_PATH,
					CONFIG_ROOT_GROUP );

	use_opengl = get_use_opengl();

	ctx->mpv_ctx = mpv_create();
	ctx->files = NULL;
	ctx->opengl_ctx = NULL;
	ctx->opengl_ready = FALSE;
	ctx->paused = TRUE;
	ctx->loaded = FALSE;
	ctx->new_file = TRUE;
	ctx->sub_visible = TRUE;
	ctx->init_load = TRUE;
	ctx->playlist_move_dest = -1;
	ctx->log_level_list = NULL;
	ctx->keybind_list = NULL;
	ctx->config = g_settings_new_with_backend(APP_ID, config_backend);
	ctx->app = GTK_APPLICATION(app);
	ctx->gui = MAIN_WINDOW(main_window_new(ctx->app, use_opengl));
	ctx->fs_control = NULL;
	ctx->playlist_store = PLAYLIST_WIDGET(ctx->gui->playlist)->list_store;

	config_migrated = migrate_config(ctx);
	style_provider = gtk_css_provider_new();

	css_loaded = gtk_css_provider_load_from_data
			(style_provider, vid_area_style, -1, NULL);

	if(!css_loaded)
	{
		g_warning ("Failed to apply background color css");
	}

	gtk_style_context_add_provider_for_screen
		(	gtk_window_get_screen(GTK_WINDOW(ctx->gui)),
			GTK_STYLE_PROVIDER(style_provider),
			GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );

	g_object_unref(style_provider);

	csd_enable = g_settings_get_boolean
				(ctx->config, "csd-enable");

	dark_theme_enable = g_settings_get_boolean
				(ctx->config, "dark-theme-enable");

	mpvinput_enable = g_settings_get_boolean
				(ctx->config, "mpv-input-config-enable");

	mpvinput = g_settings_get_string
				(ctx->config, "mpv-input-config-file");

	if(csd_enable)
	{
		gtk_application_set_app_menu
			(ctx->app, G_MENU_MODEL(build_app_menu()));

		main_window_enable_csd(ctx->gui);
	}
	else
	{
		gtk_application_set_app_menu
			(ctx->app, NULL);

		gtk_application_set_menubar
			(ctx->app, G_MENU_MODEL(build_full_menu()));
	}

	gtk_widget_show_all(GTK_WIDGET(ctx->gui));

	if(csd_enable)
	{
		control_box_set_fullscreen_btn_visible
			(CONTROL_BOX(ctx->gui->control_box), FALSE);
	}

	control_box_set_chapter_enabled
		(CONTROL_BOX(ctx->gui->control_box), FALSE);

	if(!main_window_get_use_opengl(ctx->gui))
	{
		ctx->vid_area_wid = get_xid(ctx->gui->vid_area);
	}

	g_assert(	main_window_get_use_opengl(ctx->gui) ||
			ctx->vid_area_wid != -1 );

	main_window_load_state(ctx->gui);
	setup_accelerators(ctx);
	setup_dnd_targets(ctx);
	actionctl_map_actions(ctx);
	connect_signals(ctx);
	load_keybind(ctx, mpvinput_enable?mpvinput:NULL, FALSE);
	mpris_init(ctx);
	media_keys_init(ctx);

	g_object_set(	ctx->gui->settings,
			"gtk-application-prefer-dark-theme",
			dark_theme_enable,
			NULL );

	g_timeout_add(	SEEK_BAR_UPDATE_INTERVAL,
			(GSourceFunc)update_seek_bar,
			ctx );

	if(config_migrated)
	{
		GtkWidget *dialog
			= gtk_message_dialog_new
				(	GTK_WINDOW(ctx->gui),
					GTK_DIALOG_DESTROY_WITH_PARENT,
					GTK_MESSAGE_INFO,
					GTK_BUTTONS_OK,
					_("Your configuration file has been "
					"moved to the new location at %s."),
					config_file );

		gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
	}

	g_free(config_file);
	g_free(mpvinput);
}
예제 #18
0
파일: main.c 프로젝트: endlessm/eos-updater
int
main (int argc, char **argv)
{
  g_autoptr(EosUpdater) proxy = NULL;
  g_autoptr(GError) error = NULL;
  guint update_interval_days, randomized_delay_days;
  g_autoptr(GOptionContext) context = NULL;

  GOptionEntry entries[] = {
    { "force-update", 0, 0, G_OPTION_ARG_NONE, &force_update, "Force an update", NULL },
    { "from-volume", 0, 0, G_OPTION_ARG_STRING, &volume_path, "Poll for updates from the volume", "PATH" },
    { NULL }
  };
  GBusType bus_type = G_BUS_TYPE_SYSTEM;
  gint dbus_timeout;

  setlocale (LC_ALL, "");

  context = g_option_context_new ("— Endless OS Automatic Updater");
  g_option_context_add_main_entries (context, entries, NULL);
  g_option_context_set_summary (context,
                                "Automatically poll for, fetch and apply "
                                "updates in the background. This drives the "
                                "state changes in the eos-updater service.");

  if (!g_option_context_parse (context, &argc, &argv, &error))
    {
      warning (EOS_UPDATER_INVALID_ARGS_MSGID,
               "Error parsing command line arguments: %s",
               error->message);
      return EXIT_INVALID_ARGUMENTS;
    }

  if (!read_config_file (get_config_file_path (),
                         &update_interval_days, &randomized_delay_days))
    return EXIT_BAD_CONFIGURATION;

  if (volume_path == NULL && !is_online ())
    return EXIT_OK;

  /* Always force an update if running with --from-volume; it doesn’t make
   * sense not to. */
  if (volume_path != NULL)
    force_update = TRUE;

  if (!force_update) {
    if (!is_time_to_update (update_interval_days, randomized_delay_days)) {
      info (EOS_UPDATER_NOT_TIME_MSGID,
            "Less than %s since last update. Exiting",
            INTERVAL_KEY);
      return EXIT_OK;
    }
  }

  main_loop = g_main_loop_new (NULL, FALSE);

  if (should_listen_on_session_bus ())
    bus_type = G_BUS_TYPE_SESSION;
  proxy = eos_updater_proxy_new_for_bus_sync (bus_type,
                     G_DBUS_PROXY_FLAGS_NONE,
                     "com.endlessm.Updater",
                     "/com/endlessm/Updater",
                     NULL,
                     &error);

  if (error) {
    warning (EOS_UPDATER_DAEMON_ERROR_MSGID,
             "Error getting EOS updater object: %s",
             error->message);
    should_exit_failure = TRUE;
    goto out;
  }

  dbus_timeout = get_dbus_timeout ();
  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), dbus_timeout);

  g_signal_connect (proxy, "notify::state",
                    G_CALLBACK (on_state_changed_notify), NULL);
  g_signal_connect (proxy, "notify::g-name-owner",
                    (GCallback) on_name_owner_changed, NULL);

  g_idle_add (initial_poll_idle_func, proxy);
  g_main_loop_run (main_loop);

out:
  g_main_loop_unref (main_loop);
  g_free (volume_path);

  if (should_exit_failure) /* All paths setting this print an error message */
    return EXIT_FAILED;

  /* Update the stamp file since all configured steps have succeeded. */
  update_stamp_file ((guint64) g_get_real_time () / G_USEC_PER_SEC,
                     update_interval_days, randomized_delay_days);
  info (EOS_UPDATER_SUCCESS_MSGID,
        "Updater finished successfully");

  return EXIT_OK;
}
예제 #19
0
void config_handler::init() {

  //  const std::string MyClass::valid = "something else again";

  const string DEF_CONFIG_NAME  = "cirainbow.conf";
  const string DEF_FILTER_NAME  = "featureplan_filter";
  const string DEF_FEATURE_NAME = "featureplan";
  const string DEF_REC_PREFIX   = "rec_";
  const string DEF_REC_EXT      = ".wav";
  const string DEF_FINAL_FORMAT = "WRAPPED";
  const string DEF_LAT          = "0.0000 N";
  const string DEF_LON          = "0.0000 W";
  const string DEF_RPID         = "-1";
  const int    DEF_SOUND_ID     = 0; // TODO - What should this be by default?

  const string DEF_DATA_DIR     = "data/";
  const string DEF_ANALYSIS_DIR = "analysis/";
  const string DEF_MEDIA_DIR    = "media/";



  cn = " config_handler::";
  set_config_file_path ( utils::get_home_dir() );
  set_config_file_name ( DEF_CONFIG_NAME ); // TODO - make hardcoded elsewhere 
  set_config_file      ( get_config_file_path() + get_config_file_name() ); 

  set_fv_filter_path   ( utils::get_base_dir() ); 
  set_fv_filter_name   ( DEF_FILTER_NAME ); 
  set_fv_filter        ( get_fv_filter_path() + get_fv_filter_name() ); 
  
  set_fv_file_path     ( utils::get_base_dir() ); 
  set_fv_file_name     ( DEF_FEATURE_NAME ); 
  set_fv_file          ( get_fv_file_path() + get_fv_file_name() ); 
  
  //  set_data_location       ( utils::get_base_dir() + DEF_DATA_DIR ); //TODO - make hardcoded elsewhere
  //  set_analysis_location   ( utils::get_base_dir() + DEF_ANALYSIS_DIR ); // TODO - make hardcoded elsewhere 
  set_data_location       ( utils::get_home_dir() + DEF_DATA_DIR );
  set_analysis_location   ( utils::get_base_dir() + DEF_ANALYSIS_DIR );

  set_rec_file_name_prefix( DEF_REC_PREFIX ); // TODO - make hardcoded elsewhere 
  set_media_location      ( get_data_location() + DEF_MEDIA_DIR ); // TODO - make hardcoded elsewhere 
  set_rec_extention       ( DEF_REC_EXT ); // TODO - make hardcoded elsewhere 
  
  set_samp_rate    ( -1 ); 
  set_rec_number   ( -1 ); 
  set_rec_duration ( -1 ); 

  set_latitude( DEF_LAT ); // TODO - make hardcoded elsewhere 
  set_longitude( DEF_LON ); // TODO - make hardcoded elsewhere 
  set_rpid( DEF_RPID );

  set_final_feature_format( DEF_FINAL_FORMAT ); //Foramts: WRAPPED, FILES
  set_output_type_id( DEF_SOUND_ID ); //Numeric represetning the type of data this is. TODO - WHAT SHOULD THIS BE?

  set_simulate( false ); //simulate a run (dont actually do one).
  set_simulate_dir( "" ); //default sim data dir

  set_background( false ); //run in forground by default
  set_filter( false ); //filtering is ONLY done if requested
  set_analysis( false ); //feature extraction only done if user wants it
  set_save_rec( true ); //Always save recordings by default
  set_output_formatted( true ); //It makes sense to always format output

  return;
}