|
QOF 0.8.4
|
Public interface of qof-backend-gda. More...
#include "config.h"#include <glib.h>#include <glib/gstdio.h>#include <libintl.h>#include <libgda/libgda.h>#include "qof.h"#include "qof-gda.h"#include "qofsql-p.h"Go to the source code of this file.
Defines | |
| #define | _(String) dgettext (GETTEXT_PACKAGE, String) |
| #define | ACCESS_METHOD "gda" |
| #define | LIBGDA_DIR ".qofgda" |
| #define | GDA_DBNAME "gda-database-name" |
| #define | GDA_USERNAME "gda-username" |
| #define | GDA_PASSWORD "gda-password" |
| #define | GDA_DATASOURCE "qof-gda-source" |
| #define | ONLY_DEBUG 1 |
Functions | |
| static gboolean | qgda_determine_file_type (const gchar *path) |
| static void | qgda_modify (QofBackend *be, QofInstance *inst) |
| static void | create_tables (QofObject *obj, gpointer user_data) |
| static gboolean | create_data_source (QGdaBackend *qgda_be) |
| static void | qgda_session_begin (QofBackend *be, QofSession *session, const gchar *book_path, gboolean ignore_lock, gboolean create_if_nonexistent) |
| static void | load_entities (gpointer value, gpointer user_data) |
| static void | qgda_class_foreach (QofObject *obj, gpointer data) |
| static void | qgda_db_load (QofBackend *be, QofBook *book) |
| static void | qgda_check_entity (QofEntity *ent, gpointer data) |
| static void | qgda_write_foreach (QofObject *obj, gpointer data) |
| static void | qgda_write_db (QofBackend *be, QofBook *book) |
| static void | qgda_session_end (QofBackend *be) |
| static void | qgda_destroy_backend (QofBackend *be) |
| static void | option_cb (QofBackendOption *option, gpointer data) |
| static void | load_config (QofBackend *be, KvpFrame *config) |
| static KvpFrame * | get_config (QofBackend *be) |
| static QofBackend * | qgda_backend_new (void) |
| static void | qgda_provider_free (QofBackendProvider *prov) |
| void | qof_gda_provider_init (void) |
| Initialises the libgda2 QOF backend. | |
Variables | |
| static QofLogModule | log_module = "qof-backend-gda" |
Public interface of qof-backend-gda.
Definition in file qof-gda.c.
| static void qgda_session_begin | ( | QofBackend * | be, |
| QofSession * | session, | ||
| const gchar * | book_path, | ||
| gboolean | ignore_lock, | ||
| gboolean | create_if_nonexistent | ||
| ) | [static] |
Definition at line 265 of file qof-gda.c.
{
QGdaBackend *qgda_be;
GdaDataSourceInfo * source;
gboolean created;
/* cannot use ignore_lock */
PINFO (" gda session start");
qgda_be = (QGdaBackend*)be;
be->fullpath = g_strdup (book_path);
qgda_be->gda_err = NULL;
if(book_path == NULL)
{
qof_error_set_be (be, qof_error_register
(_("GDA: No data source path specified."), FALSE));
qgda_be->error = TRUE;
LEAVE (" bad URL");
return;
}
/* check/create the ~/.libgda location. */
{
struct stat lg;
gint ret;
ret = g_stat (g_get_home_dir(), &lg);
if (ret)
{
qof_error_set_be (be, qof_error_register
(_("GDA: Unable to locate your home directory."),
FALSE));
qgda_be->error = TRUE;
LEAVE (" unable to use stat on home_dir.");
return;
}
qgda_be->gdahome = g_strconcat (g_get_home_dir(), "/", LIBGDA_DIR, NULL);
if (!S_ISDIR (lg.st_mode) || lg.st_size == 0)
ret = g_mkdir_with_parents (qgda_be->gdahome, 0700);
if (ret)
{
qof_error_set_be (be, qof_error_register
(_("GDA: Unable to create a .libgda directory "
"within your home directory."), FALSE));
qgda_be->error = TRUE;
LEAVE (" unable to create '%s' 0700", qgda_be->gdahome);
return;
}
}
if (qgda_be->data_source_name)
{
/* check data source */
qgda_be->book = qof_session_get_book (session);
PINFO ("name=%s", qgda_be->data_source_name);
PINFO ("provider=%s", qgda_be->provider_name);
created = FALSE;
source = gda_config_find_data_source
(qgda_be->data_source_name);
if (!source && create_if_nonexistent)
{
DEBUG (" no source, creating . . .");
created = create_data_source (qgda_be);
}
if (!source && !created)
{
qof_error_set_be (be, qof_error_register
(_("GDA: No data source found at '%s' - Try loading data "
"from another file and write to gda: again to create the "
"GDA data source."), TRUE));
DEBUG (" no source but set not to create.");
qgda_be->error = TRUE;
return;
}
}
PINFO (" trying for a connection");
/* use the username and password that created the source */
qgda_be->connection = gda_client_open_connection
(qgda_be->client_pool, qgda_be->data_source_name,
NULL, NULL, GDA_CONNECTION_OPTIONS_DONT_SHARE, &qgda_be->gda_err);
if (qgda_be->connection)
{
PINFO (" appear to be connected.");
/* create tables per QofObject */
qof_object_foreach_type (create_tables, qgda_be);
}
else
{
gchar * msg;
msg = g_strdup_printf (
_("GDA encountered an error '%s' using data source '%s'."),
qgda_be->gda_err->message, qgda_be->data_source_name);
qof_error_set_be (be, qof_error_register (msg, FALSE));
PERR (" failed to connect to GDA: '%s'", msg);
qgda_be->error = TRUE;
g_message (msg);
g_free (msg);
g_error_free (qgda_be->gda_err);
#ifdef ONLY_DEBUG
PERR ("connect request failed, removing %s", qgda_be->data_source_name);
g_message ("connect request failed, removing %s", qgda_be->data_source_name);
gda_config_remove_data_source (qgda_be->data_source_name);
#endif
}
}
1.7.4