269 QGdaBackend *qgda_be;
270 GdaDataSourceInfo * source;
274 PINFO (
" gda session start");
275 qgda_be = (QGdaBackend*)be;
276 be->
fullpath = g_strdup (book_path);
277 qgda_be->gda_err = NULL;
278 if(book_path == NULL)
281 (_(
"GDA: No data source path specified."), FALSE));
282 qgda_be->error = TRUE;
291 ret = g_stat (g_get_home_dir(), &lg);
295 (_(
"GDA: Unable to locate your home directory."),
297 qgda_be->error = TRUE;
298 LEAVE (
" unable to use stat on home_dir.");
301 qgda_be->gdahome = g_strconcat (g_get_home_dir(),
"/", LIBGDA_DIR, NULL);
302 if (!S_ISDIR (lg.st_mode) || lg.st_size == 0)
303 ret = g_mkdir_with_parents (qgda_be->gdahome, 0700);
307 (_(
"GDA: Unable to create a .libgda directory "
308 "within your home directory."), FALSE));
309 qgda_be->error = TRUE;
310 LEAVE (
" unable to create '%s' 0700", qgda_be->gdahome);
314 if (qgda_be->data_source_name)
317 qgda_be->book = qof_session_get_book (session);
318 PINFO (
"name=%s", qgda_be->data_source_name);
319 PINFO (
"provider=%s", qgda_be->provider_name);
321 source = gda_config_find_data_source
322 (qgda_be->data_source_name);
323 if (!source && create_if_nonexistent)
325 DEBUG (
" no source, creating . . .");
326 created = create_data_source (qgda_be);
328 if (!source && !created)
331 (_(
"GDA: No data source found at '%s' - Try loading data "
332 "from another file and write to gda: again to create the "
333 "GDA data source."), TRUE));
334 DEBUG (
" no source but set not to create.");
335 qgda_be->error = TRUE;
339 PINFO (
" trying for a connection");
341 qgda_be->connection = gda_client_open_connection
342 (qgda_be->client_pool, qgda_be->data_source_name,
343 NULL, NULL, GDA_CONNECTION_OPTIONS_DONT_SHARE, &qgda_be->gda_err);
344 if (qgda_be->connection)
346 PINFO (
" appear to be connected.");
354 msg = g_strdup_printf (
355 _(
"GDA encountered an error '%s' using data source '%s'."),
356 qgda_be->gda_err->message, qgda_be->data_source_name);
358 PERR (
" failed to connect to GDA: '%s'", msg);
359 qgda_be->error = TRUE;
362 g_error_free (qgda_be->gda_err);
364 PERR (
"connect request failed, removing %s", qgda_be->data_source_name);
366 g_message (
"connect request failed, removing %s", qgda_be->data_source_name);
367 gda_config_remove_data_source (qgda_be->data_source_name);