Exemple #1
0
static void getagpslatlon()
{
    GConfClient *clint = NULL;
    double d;
    char c[100];
    GConfValue *gcv = NULL;

    g_type_init();

    strcpy(c, "/system/osso/supl/");
    strcat(c, "pos_latitude");
    clint = gconf_client_get_default();
    gcv = gconf_client_get_without_default(clint, c, NULL);
    d = 0.0;
    if (gcv) {
        d = gconf_value_get_float(gcv);
        gconf_value_free(gcv);
    }
    g_object_unref(clint);
    gpst.llat = (int) (d * 1000000.0);

    strcpy(c, "/system/osso/supl/");
    strcat(c, "pos_longitude");
    clint = gconf_client_get_default();
    gcv = gconf_client_get_without_default(clint, c, NULL);
    d = 0.0;
    if (gcv) {
        d = gconf_value_get_float(gcv);
        gconf_value_free(gcv);
    }
    g_object_unref(clint);
    gpst.llon = (int) (d * 1000000.0);
}
Exemple #2
0
void
load_settings()
{
	  GConfClient* gcClient = NULL;
	  GConfValue* val = NULL;
	  gdouble sport;

	  gcClient = gconf_client_get_default();
	  g_assert(GCONF_IS_CLIENT(gcClient));

	  gchar *port_path = g_strconcat(config->GC_ROOT, "port", NULL);
	  val = gconf_client_get_without_default(gcClient, port_path, NULL);
	  if (val == NULL) {
		  g_warning("Unable to read server port value\n");
	  } else {
		  if (val->type == GCONF_VALUE_STRING) {
			  settings->server_port = g_strndup(gconf_value_get_string(val),STRING_MAX_SIZE - 1);

			  sport = g_ascii_strtod(settings->server_port, NULL);
			  if( (sport < 1024) || (sport > 32766) )
			  {
					GtkWidget *failDialog = gtk_message_dialog_new(NULL,
				     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
				     		GTK_BUTTONS_OK,
				     		"Bad server port value.\nServer port must be between 1024 and 32766.\nDefaulting to 8080.");
					gtk_dialog_run (GTK_DIALOG (failDialog));
					gtk_widget_destroy (failDialog);
					settings->server_port = "8080";
			  }

		  } else {
			  g_warning("Bad server port value set\n");
		  }
	  }

	  gchar *update_path = g_strconcat(config->GC_ROOT, "update", NULL);
	  val = gconf_client_get_without_default(gcClient, update_path, NULL);
	  if (val == NULL) {
		  g_warning("Unable to read update interval value\n");
	  } else {
		  if (val->type == GCONF_VALUE_INT) {
			  settings->update_interval = gconf_value_get_int(val);
		  } else {
			  g_warning("Bad update interval set\n");
		  }
	  }

	  /*
	  gconf_value_free(val);
	  val = NULL;
	*/
}
gboolean
eel_gconf_is_default (const char *key)
{
	gboolean result;
	GConfValue *value;
	GError *error = NULL;
	
	g_return_val_if_fail (key != NULL, FALSE);
	
	value = gconf_client_get_without_default  (eel_gconf_client_get_global (), key, &error);

	if (eel_gconf_handle_error (&error)) {
		if (value != NULL) {
			gconf_value_free (value);
		}
		return FALSE;
	}

	result = (value == NULL);

	if (value != NULL) {
		gconf_value_free (value);
	}

	
	return result;
}
gboolean dasher_app_settings_get_free_long(DasherAppSettings *pSelf, const gchar *szName, gint &iValue) {
#ifdef WITH_GCONF
  DasherAppSettingsPrivate *pPrivate = (DasherAppSettingsPrivate *)(pSelf->private_data);

  gchar szFullName[256];
      
  strncpy(szFullName, "/apps/dasher4/", 256);
  strncat(szFullName, szName, 255 - strlen(szFullName));

  GConfValue *pGConfValue;
  GError *pGConfError = NULL;

  pGConfValue = gconf_client_get_without_default(pPrivate->pGConfClient, szFullName, &pGConfError);
      
  if(pGConfValue) {
    iValue = gconf_value_get_int(pGConfValue);
    gconf_value_free(pGConfValue);
    return true;
  }
  else {
    return false;
  }
#else
  return false;
#endif
}
Exemple #5
0
bool CGnomeSettingsStore::LoadSetting(const std::string &Key, std::string *Value) {
  std::string keypath(GCONF_KEY_ROOT);
  keypath += Key;

  GError *the_error = NULL;

  GConfValue *got_value = gconf_client_get_without_default(the_gconf_client, keypath.c_str(), &the_error);

  if(got_value == NULL) {
    return false;
  }

  *Value = gconf_value_get_string(got_value);
  gconf_value_free(got_value);

  return true;
}
/*
 * The font rendering details dialog
 */
static void
dpi_load (GConfClient   *client,
	  GtkSpinButton *spinner)
{
  GConfValue *value;
  gdouble dpi;

  value = gconf_client_get_without_default (client, FONT_DPI_KEY, NULL);

  if (value) {
    dpi = gconf_value_get_float (value);
    gconf_value_free (value);
  } else
    dpi = get_dpi_from_x_server ();

  if (dpi < DPI_LOW_REASONABLE_VALUE)
    dpi = DPI_LOW_REASONABLE_VALUE;

  in_change = TRUE;
  gtk_spin_button_set_value (spinner, dpi);
  in_change = FALSE;
}
Exemple #7
0
static void checkgconf(char *key, char *val)
{
    char c[256];
    const char *c1 = NULL;
    GConfClient *clint = NULL;
    GConfValue *gcv = NULL;

    *val = 0;
    g_type_init();
    clint = gconf_client_get_default();
    strcpy(c, mypath);
    strcat(c, key);
    gcv = gconf_client_get_without_default(clint, c, NULL);
    if (gcv) {
        c1 = gconf_value_get_string(gcv);
        if (c1)
            strcpy(val, c1);
        gconf_value_free(gcv);
    }
    g_object_unref(clint);
    //    fprintf(stderr, "%s [%s]=[%s]\n", mypath, key, val);
}
Exemple #8
0
gint gm_pref_store_get_int_with_default(GmPrefStore * store, const gchar * key, gint default_value)
{

    gint value = 0;

    if (store == NULL)
        return default_value;

#if HAVE_GSETTINGS
    value = g_settings_get_int(store->settings, key);
#else
#ifdef HAVE_GCONF

    gchar *full_key;
    GConfValue *gcvalue;

    full_key = g_strdup_printf("/apps/%s/preferences/%s", store->context, key);

    gcvalue = gconf_client_get_without_default(store->gconf, full_key, NULL);
    if (gcvalue) {
        value = gconf_client_get_int(store->gconf, full_key, NULL);
        gconf_value_free(gcvalue);
    } else {
        value = default_value;
    }
    g_free(full_key);

#else

    if (g_key_file_has_key(store->keyfile, store->context, key, NULL)) {
        value = g_key_file_get_integer(store->keyfile, store->context, key, NULL);
    } else {
        value = default_value;
    }

#endif
#endif
    return value;
}
Exemple #9
0
static GVariant *
gconf_settings_backend_read (GSettingsBackend   *backend,
                             const gchar        *key,
                             const GVariantType *expected_type,
                             gboolean            default_value)
{
  GConfSettingsBackend *gconf = GCONF_SETTINGS_BACKEND (backend);
  GConfValue *gconf_value;
  GVariant *value;

  gconf_value = gconf_client_get_without_default (gconf->priv->client,
                                                  key, NULL);
  if (gconf_value == NULL)
    return NULL;

  value = gconf_settings_backend_gconf_value_to_gvariant (gconf_value, expected_type);
  gconf_value_free (gconf_value);

  if (value != NULL)
    g_variant_ref_sink (value);

  return value;
}
Exemple #10
0
static gboolean
handle_file (const gchar *filename)
{
  GKeyFile *keyfile;
  GConfClient *client;
  GConfValue *value;
  gint i, j;
  gchar *gconf_key;
  gchar **groups;
  gchar **keys;
  GVariantBuilder *builder;
  GVariant *v;
  const gchar *s;
  gchar *str;
  gint ii;
  GSList *list, *l;
  GSettingsSchemaSource *source;
  GSettingsSchema *schema;
  GSettings *settings;
  GError *error;

  keyfile = g_key_file_new ();

  error = NULL;
  if (!g_key_file_load_from_file (keyfile, filename, 0, &error))
    {
      if (verbose)
        g_printerr ("%s: %s\n", filename, error->message);
      g_error_free (error);

      g_key_file_free (keyfile);

      return FALSE;
    }

  client = get_writable_client ();
  source = g_settings_schema_source_get_default ();

  groups = g_key_file_get_groups (keyfile, NULL);
  for (i = 0; groups[i]; i++)
    {
      gchar **schema_path;

      schema_path = g_strsplit (groups[i], ":", 2);

      schema = g_settings_schema_source_lookup (source, schema_path[0], TRUE);
      if (schema == NULL)
        {
          if (verbose)
            {
              g_print ("Schema '%s' not found, skipping\n", schema_path[0]);
            }

          g_strfreev (schema_path);
          continue;
        }

      g_settings_schema_unref (schema);

      if (verbose)
        {
          g_print ("Collecting settings for schema '%s'\n", schema_path[0]);
          if (schema_path[1])
            g_print ("for storage at '%s'\n", schema_path[1]);
        }

      if (schema_path[1] != NULL)
        settings = g_settings_new_with_path (schema_path[0], schema_path[1]);
      else
        settings = g_settings_new (schema_path[0]);

      g_settings_delay (settings);

      error = NULL;
      if ((keys = g_key_file_get_keys (keyfile, groups[i], NULL, &error)) == NULL)
        {
          g_printerr ("%s", error->message);
          g_error_free (error);

          continue;
        }

      for (j = 0; keys[j]; j++)
        {
          if (strchr (keys[j], '/') != 0)
            {
              g_printerr ("Key '%s' contains a '/'\n", keys[j]);

              continue;
            }

          error = NULL;
          if ((gconf_key = g_key_file_get_string (keyfile, groups[i], keys[j], &error)) ==  NULL)
            {
              g_printerr ("%s", error->message);
              g_error_free (error);

              continue;
            }

          error = NULL;
          if ((value = gconf_client_get_without_default (client, gconf_key, &error)) == NULL)
            {
              if (error)
                {
                  g_printerr ("Failed to get GConf key '%s': %s\n",
                              gconf_key, error->message);
                  g_error_free (error);
                }
              else
                {
                  if (verbose)
                    g_print ("Skipping GConf key '%s', no user value\n",
                             gconf_key);
                }

              g_free (gconf_key);

              continue;
            }

          switch (value->type)
            {
            case GCONF_VALUE_STRING:
              if (dry_run)
                g_print ("Set key '%s' to string '%s'\n", keys[j],
                         gconf_value_get_string (value));
              else
                g_settings_set (settings, keys[j], "s",
                                gconf_value_get_string (value));
              break;

            case GCONF_VALUE_INT:
              if (dry_run)
                g_print ("Set key '%s' to integer '%d'\n",
                         keys[j], gconf_value_get_int (value));
              else
                {
                  GVariant *range;
                  gchar *type;

                  range = g_settings_get_range (settings, keys[j]);
                  g_variant_get (range, "(&sv)", &type, NULL);

                  if (strcmp (type, "enum") == 0)
                    g_settings_set_enum (settings, keys[j], gconf_value_get_int (value));
                  else if (strcmp (type, "flags") == 0)
                    g_settings_set_flags (settings, keys[j], gconf_value_get_int (value));
                  else if (type_uint32 (settings, keys[j]))
                    g_settings_set (settings, keys[j], "u",
                                    gconf_value_get_int (value));
                  else
                    g_settings_set (settings, keys[j], "i",
                                    gconf_value_get_int (value));

                  g_variant_unref (range);
                }
              break;

            case GCONF_VALUE_BOOL:
              if (dry_run)
                g_print ("Set key '%s' to boolean '%d'\n",
                         keys[j], gconf_value_get_bool (value));
              else
                g_settings_set (settings, keys[j], "b",
                                gconf_value_get_bool (value));
              break;

            case GCONF_VALUE_FLOAT:
              if (dry_run)
                g_print ("Set key '%s' to double '%g'\n",
                         keys[j], gconf_value_get_float (value));
              else
                g_settings_set (settings, keys[j], "d",
                                gconf_value_get_float (value));
              break;

            case GCONF_VALUE_LIST:
              switch (gconf_value_get_list_type (value))
                {
                case GCONF_VALUE_STRING:
                  builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
                  list = gconf_value_get_list (value);
                  if (list != NULL)
                    {
                      for (l = list; l; l = l->next)
                        {
                          GConfValue *lv = l->data;
                          s = gconf_value_get_string (lv);
                          g_variant_builder_add (builder, "s", s);
                        }
                      v = g_variant_new ("as", builder);
                    }
                  else
                    v = g_variant_new_array (G_VARIANT_TYPE_STRING, NULL, 0);
                  g_variant_ref_sink (v);

                  if (dry_run)
                    {
                      str = g_variant_print (v, FALSE);
                      g_print ("Set key '%s' to a list of strings: %s\n",
                               keys[j], str);
                      g_free (str);
                    }
                  else
                    g_settings_set_value (settings, keys[j], v);

                  g_variant_unref (v);
                  g_variant_builder_unref (builder);
                  break;

                case GCONF_VALUE_INT:
                  builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
                  list = gconf_value_get_list (value);
                  if (list != NULL)
                    {
                      for (l = list; l; l = l->next)
                        {
                          GConfValue *lv = l->data;
                          ii = gconf_value_get_int (lv);
                          g_variant_builder_add (builder, "i", ii);
                        }
                      v = g_variant_new ("ai", builder);
                    }
                  else
                    v = g_variant_new_array (G_VARIANT_TYPE_INT32, NULL, 0);
                  g_variant_ref_sink (v);

                  if (dry_run)
                    {
                      str = g_variant_print (v, FALSE);
                      g_print ("Set key '%s' to a list of integers: %s\n",
                               keys[j], str);
                      g_free (str);
                    }
                  else
                    g_settings_set_value (settings, keys[j], v);

                  g_variant_unref (v);
                  g_variant_builder_unref (builder);
                  break;

                default:
                  g_printerr ("Keys of type 'list of %s' not handled yet\n",
                              gconf_value_type_to_string (gconf_value_get_list_type (value)));
                  break;
                }
              break;

            default:
              g_printerr ("Keys of type %s not handled yet\n",
                          gconf_value_type_to_string (value->type));
              break;
            }

          gconf_value_free (value);
          g_free (gconf_key);
        }

      g_strfreev (keys);

      if (!dry_run)
        g_settings_apply (settings);

      g_object_unref (settings);
      g_strfreev (schema_path);
    }

  g_strfreev (groups);

  g_object_unref (client);

  return TRUE;
}
static void dasher_app_settings_load(DasherAppSettings *pSelf) { 
#ifdef WITH_GCONF
  DasherAppSettingsPrivate *pPrivate = (DasherAppSettingsPrivate *)(pSelf->private_data);

  GError *pGConfError = NULL;
  GConfValue *pGConfValue;
 
  for(int i(0); i < NUM_OF_APP_BPS; ++i ) {
    if(app_boolparamtable[i].persistent) {
      gchar szName[256];
    
      strncpy(szName, "/apps/dasher4/", 256);
      strncat(szName,  app_boolparamtable[i].regName, 255 - strlen( szName ));

      pGConfValue = gconf_client_get_without_default(pPrivate->pGConfClient, szName, &pGConfError);
      
      if(pGConfValue) {
	app_boolparamtable[i].value = gconf_value_get_bool(pGConfValue);

	gconf_value_free(pGConfValue);
      }
    }
  }

  for(int i(0); i < NUM_OF_APP_LPS; ++i ) {
    if(app_longparamtable[i].persistent) {
      gchar szName[256];
    
      strncpy(szName, "/apps/dasher4/", 256);
      strncat(szName,  app_longparamtable[i].regName, 255 - strlen( szName ));

      pGConfValue = gconf_client_get_without_default(pPrivate->pGConfClient, szName, &pGConfError);
      
      if(pGConfValue) {
	app_longparamtable[i].value = gconf_value_get_int(pGConfValue);

	gconf_value_free(pGConfValue);
      }
    }
  }

  for(int i(0); i < NUM_OF_APP_SPS; ++i ) {
    if(app_stringparamtable[i].persistent) {
      gchar szName[256];
    
      strncpy(szName, "/apps/dasher4/", 256);
      strncat(szName,  app_stringparamtable[i].regName, 255 - strlen( szName ));

      pGConfValue = gconf_client_get_without_default(pPrivate->pGConfClient, szName, &pGConfError);
      
      if(pGConfValue) {
	delete[] app_stringparamtable[i].value;

	const gchar *szValue(gconf_value_get_string(pGConfValue));

	gchar *szNew;
	szNew = new gchar[strlen(szValue) + 1];
	strcpy(szNew, szValue);
	
	app_stringparamtable[i].value = szNew;
	gconf_value_free(pGConfValue);
      }
    }
  }
#endif
}