libgda r3351 - in trunk: . libgda providers/jdbc tools
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgda r3351 - in trunk: . libgda providers/jdbc tools
- Date: Sat, 14 Mar 2009 20:58:50 +0000 (UTC)
Author: vivien
Date: Sat Mar 14 20:58:50 2009
New Revision: 3351
URL: http://svn.gnome.org/viewvc/libgda?rev=3351&view=rev
Log:
2009-03-14 Vivien Malerba <malerba gnome-db org>
* libgda/gda-config.c:
* tools/gda-sql.c:
* providers/jdbc/jni-wrapper.c: use the XDG Base Directory Specification to
get the directory where to store the defined data sources and fall back to
$HOME/.libgda if the directory does not exist
* tools/tools-input.c: store history file in $XDG_CACHE_HOME from
the XDG Base Directory Specification
Modified:
trunk/ChangeLog
trunk/libgda/gda-config.c
trunk/providers/jdbc/jni-wrapper.c
trunk/tools/gda-sql.c
trunk/tools/tools-input.c
Modified: trunk/libgda/gda-config.c
==============================================================================
--- trunk/libgda/gda-config.c (original)
+++ trunk/libgda/gda-config.c Sat Mar 14 20:58:50 2009
@@ -221,7 +221,7 @@
object_class->set_property = gda_config_set_property;
object_class->get_property = gda_config_get_property;
- /* To translators: DSN stands for Data Source Name, it's a named connection string defined in ~/.libgda/config */
+ /* To translators: DSN stands for Data Source Name, it's a named connection string defined in $XDG_DATA_HOME/libgda/config */
g_object_class_install_property (object_class, PROP_USER_FILE,
g_param_spec_string ("user-filename", NULL,
"File to use for per-user DSN list",
@@ -476,20 +476,29 @@
/* define user and system dirs. if not already defined */
if (!user_file_set) {
- if (g_get_home_dir ()) {
- gchar *confdir, *conffile;
- gboolean setup_ok = TRUE;
- confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".libgda", NULL);
- conffile = g_build_filename (g_get_home_dir (), ".libgda", "config", NULL);
-
- if (!g_file_test (confdir, G_FILE_TEST_EXISTS)) {
- if (g_mkdir (confdir, 0700))
- {
- setup_ok = FALSE;
- g_warning (_("Error creating user specific "
- "configuration directory '%s'"),
- confdir);
- }
+ gchar *confdir, *conffile;
+ gboolean setup_ok = TRUE;
+ confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "libgda", NULL);
+ conffile = g_build_filename (confdir, "config", NULL);
+
+ if (!g_file_test (confdir, G_FILE_TEST_EXISTS)) {
+ gchar *old_path;
+ old_path = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".libgda", NULL);
+ if (g_file_test (old_path, G_FILE_TEST_EXISTS)) {
+ /* using $HOME/.libgda because it exists */
+ g_free (confdir);
+ confdir = old_path;
+ g_free (conffile);
+ conffile = g_build_filename (confdir, "config", NULL);
+ }
+ else {
+ g_free (old_path);
+ if (g_mkdir (confdir, 0700)) {
+ setup_ok = FALSE;
+ g_warning (_("Error creating user specific "
+ "configuration directory '%s'"),
+ confdir);
+ }
if (setup_ok) {
gchar *str;
gchar *full_file;
@@ -533,7 +542,7 @@
g_free (str);
}
}
- else if (!g_file_test (confdir, G_FILE_TEST_IS_DIR)) {
+ if (!g_file_test (confdir, G_FILE_TEST_IS_DIR)) {
setup_ok = FALSE;
g_warning (_("User specific "
"configuration directory '%s' exists and is not a directory"),
@@ -546,6 +555,10 @@
else
g_free (conffile);
}
+ else {
+ g_free (confdir);
+ unique_instance->priv->user_file = conffile;
+ }
}
if (!system_file_set)
unique_instance->priv->system_file = gda_gbr_get_file_path (GDA_ETC_DIR,
Modified: trunk/providers/jdbc/jni-wrapper.c
==============================================================================
--- trunk/providers/jdbc/jni-wrapper.c (original)
+++ trunk/providers/jdbc/jni-wrapper.c Sat Mar 14 20:58:50 2009
@@ -92,7 +92,11 @@
}
gchar * confdir;
- confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".libgda", NULL);
+ confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "libgda", NULL);
+ if (!g_file_test (confdir, G_FILE_TEST_EXISTS)) {
+ g_free (confdir);
+ confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".libgda", NULL);
+ }
classpath = locate_jars (classpath, confdir);
g_free (confdir);
Modified: trunk/tools/gda-sql.c
==============================================================================
--- trunk/tools/gda-sql.c (original)
+++ trunk/tools/gda-sql.c Sat Mar 14 20:58:50 2009
@@ -1386,10 +1386,17 @@
if (info) {
gchar *filename;
-#define LIBGDA_USER_CONFIG_DIR G_DIR_SEPARATOR_S ".libgda"
+ gchar *confdir;
+
+ confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "libgda", NULL);
+ if (!g_file_test (confdir, G_FILE_TEST_EXISTS)) {
+ g_free (confdir);
+ confdir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".libgda", NULL);
+ }
filename = g_strdup_printf ("%s%sgda-sql-%s.db",
- g_get_home_dir (), LIBGDA_USER_CONFIG_DIR G_DIR_SEPARATOR_S,
+ confdir, G_DIR_SEPARATOR_S,
info->name);
+ g_free (confdir);
if (! g_file_test (filename, G_FILE_TEST_EXISTS))
update_store = TRUE;
store = gda_meta_store_new_with_file (filename);
Modified: trunk/tools/tools-input.c
==============================================================================
--- trunk/tools/tools-input.c (original)
+++ trunk/tools/tools-input.c Sat Mar 14 20:58:50 2009
@@ -21,6 +21,7 @@
#include "tools-input.h"
#include <glib/gi18n-lib.h>
+#include <glib/gstdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@@ -38,10 +39,10 @@
#endif
#define HISTORY_ENV_NAME "GDA_SQL_HISTFILE"
-#define HISTORY_FILE ".gdasql_history"
+#define HISTORY_FILE "gdasql_history"
#ifdef HAVE_HISTORY
static gboolean history_init_done = FALSE;
-const gchar *history_file = NULL;
+gchar *history_file = NULL;
#endif
/**
@@ -261,11 +262,23 @@
}
history_file = g_strdup (getenv (HISTORY_ENV_NAME));
}
- else
- history_file = g_build_filename (g_get_home_dir (), HISTORY_FILE, NULL);
- using_history ();
- read_history (history_file);
- history_init_done = TRUE;
+ else {
+ gchar *cache_dir;
+ cache_dir = g_build_filename (g_get_user_cache_dir (), "libgda", NULL);
+ history_file = g_build_filename (cache_dir, HISTORY_FILE, NULL);
+ if (!g_file_test (cache_dir, G_FILE_TEST_EXISTS)) {
+ if (g_mkdir (cache_dir, 0700)) {
+ g_free (history_file);
+ history_file = NULL;
+ }
+ }
+ g_free (cache_dir);
+ }
+ if (history_file) {
+ using_history ();
+ read_history (history_file);
+ history_init_done = TRUE;
+ }
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]