mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove unused partial book handling.
This commit is contained in:
parent
cf78eecdfa
commit
3abf8b47f6
@ -445,7 +445,6 @@ src/libqof/qof/qofmath128.c
|
||||
src/libqof/qof/qofobject.c
|
||||
src/libqof/qof/qofquery.c
|
||||
src/libqof/qof/qofquerycore.c
|
||||
src/libqof/qof/qofreference.c
|
||||
src/libqof/qof/qofsession.c
|
||||
src/libqof/qof/qof-string-cache.c
|
||||
src/libqof/qof/qofutil.c
|
||||
|
@ -1919,7 +1919,6 @@ gnc_module_init_backend_dbi(void)
|
||||
|
||||
prov->provider_name = "GnuCash Libdbi (SQLITE3) Backend";
|
||||
prov->access_method = FILE_URI_TYPE;
|
||||
prov->partial_book_supported = FALSE;
|
||||
prov->backend_new = gnc_dbi_backend_sqlite3_new;
|
||||
prov->provider_free = gnc_dbi_provider_free;
|
||||
prov->check_data_type = gnc_dbi_check_sqlite3_file;
|
||||
@ -1930,7 +1929,6 @@ gnc_module_init_backend_dbi(void)
|
||||
|
||||
prov->provider_name = "GnuCash Libdbi (SQLITE3) Backend";
|
||||
prov->access_method = SQLITE3_URI_TYPE;
|
||||
prov->partial_book_supported = FALSE;
|
||||
prov->backend_new = gnc_dbi_backend_sqlite3_new;
|
||||
prov->provider_free = gnc_dbi_provider_free;
|
||||
prov->check_data_type = gnc_dbi_check_sqlite3_file;
|
||||
@ -1944,7 +1942,6 @@ gnc_module_init_backend_dbi(void)
|
||||
|
||||
prov->provider_name = "GnuCash Libdbi (MYSQL) Backend";
|
||||
prov->access_method = "mysql";
|
||||
prov->partial_book_supported = FALSE;
|
||||
prov->backend_new = gnc_dbi_backend_mysql_new;
|
||||
prov->provider_free = gnc_dbi_provider_free;
|
||||
prov->check_data_type = NULL;
|
||||
@ -1958,7 +1955,6 @@ gnc_module_init_backend_dbi(void)
|
||||
|
||||
prov->provider_name = "GnuCash Libdbi (POSTGRESQL) Backend";
|
||||
prov->access_method = "postgres";
|
||||
prov->partial_book_supported = FALSE;
|
||||
prov->backend_new = gnc_dbi_backend_postgres_new;
|
||||
prov->provider_free = gnc_dbi_provider_free;
|
||||
prov->check_data_type = NULL;
|
||||
|
@ -1302,7 +1302,6 @@ gnc_module_init_backend_xml(void)
|
||||
prov = g_new0 (QofBackendProvider, 1);
|
||||
prov->provider_name = "GnuCash File Backend Version 2";
|
||||
prov->access_method = "file";
|
||||
prov->partial_book_supported = FALSE;
|
||||
prov->backend_new = gnc_backend_new;
|
||||
prov->provider_free = gnc_provider_free;
|
||||
prov->check_data_type = gnc_determine_file_type;
|
||||
@ -1311,7 +1310,6 @@ gnc_module_init_backend_xml(void)
|
||||
prov = g_new0 (QofBackendProvider, 1);
|
||||
prov->provider_name = "GnuCash File Backend Version 2";
|
||||
prov->access_method = "xml";
|
||||
prov->partial_book_supported = FALSE;
|
||||
prov->backend_new = gnc_backend_new;
|
||||
prov->provider_free = gnc_provider_free;
|
||||
prov->check_data_type = gnc_determine_file_type;
|
||||
|
@ -33,7 +33,6 @@ libgnc_qof_la_SOURCES = \
|
||||
qofobject.c \
|
||||
qofquery.c \
|
||||
qofquerycore.c \
|
||||
qofreference.c \
|
||||
qofsession.c \
|
||||
qof-string-cache.c \
|
||||
qofutil.c
|
||||
@ -64,7 +63,6 @@ qofinclude_HEADERS = \
|
||||
qofobject.h \
|
||||
qofquery.h \
|
||||
qofquerycore.h \
|
||||
qofreference.h \
|
||||
qofsession.h \
|
||||
qof-string-cache.h \
|
||||
qofutil.h \
|
||||
|
@ -93,7 +93,6 @@
|
||||
#include "qofquerycore.h"
|
||||
#include "qofsession.h"
|
||||
#include "qofchoice.h"
|
||||
#include "qofreference.h"
|
||||
#include "qof-string-cache.h"
|
||||
|
||||
#endif /* QOF_H_ */
|
||||
|
@ -247,14 +247,6 @@ struct QofBackendProvider_s
|
||||
/*@ observer @*/
|
||||
const char * access_method;
|
||||
|
||||
/** \brief Partial QofBook handler
|
||||
|
||||
TRUE if the backend handles external references
|
||||
to entities outside this book and can save a QofBook that
|
||||
does not contain any specific QOF objects.
|
||||
*/
|
||||
gboolean partial_book_supported;
|
||||
|
||||
/** Return a new, fully initialized backend.
|
||||
*
|
||||
* If the backend supports configuration, all configuration options
|
||||
|
@ -1,179 +0,0 @@
|
||||
/***************************************************************************
|
||||
* qofreference.c
|
||||
*
|
||||
* Mon Feb 13 21:06:44 2006
|
||||
* Copyright 2006 Neil Williams
|
||||
* linux@codehelp.co.uk
|
||||
****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
#include "qofreference.h"
|
||||
|
||||
static void
|
||||
entity_set_reference_cb(QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
void (*reference_setter) (QofInstance*, QofInstance*);
|
||||
void (*choice_setter) (QofInstance*, QofInstance*);
|
||||
void (*collect_setter)(QofInstance*, QofCollection*);
|
||||
QofInstanceReference *ref;
|
||||
GList *book_ref_list;
|
||||
QofCollection *coll;
|
||||
QofIdType type;
|
||||
QofInstance *reference;
|
||||
QofBook *partial_book;
|
||||
|
||||
partial_book = (QofBook*)user_data;
|
||||
g_return_if_fail(partial_book && ent);
|
||||
reference = NULL;
|
||||
coll = NULL;
|
||||
book_ref_list = qof_book_get_data(partial_book, ENTITYREFERENCE);
|
||||
while (book_ref_list)
|
||||
{
|
||||
ref = (QofInstanceReference*)book_ref_list->data;
|
||||
if (0 == guid_compare(ref->ref_guid, qof_instance_get_guid(ent)))
|
||||
{
|
||||
/* avoid setting the entity's own guid as a reference. */
|
||||
book_ref_list = g_list_next(book_ref_list);
|
||||
continue;
|
||||
}
|
||||
if (qof_object_is_choice(ent->e_type))
|
||||
{
|
||||
type = ref->choice_type;
|
||||
}
|
||||
type = ref->param->param_type;
|
||||
coll = qof_book_get_collection(partial_book, type);
|
||||
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
|
||||
reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
|
||||
if ((reference) && (reference_setter))
|
||||
{
|
||||
qof_begin_edit((QofInstance*)ent);
|
||||
qof_begin_edit((QofInstance*)reference);
|
||||
reference_setter(ent, reference);
|
||||
qof_commit_edit((QofInstance*)ent);
|
||||
qof_commit_edit((QofInstance*)reference);
|
||||
}
|
||||
/* collect and choice handling */
|
||||
collect_setter = (void(*)(QofInstance*, QofCollection*))ref->param->param_setfcn;
|
||||
choice_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
|
||||
if ((0 == g_strcmp0(ref->param->param_type, QOF_TYPE_COLLECT)) &&
|
||||
(0 == guid_compare(qof_instance_get_guid(ent), ref->ent_guid)) &&
|
||||
(0 == g_strcmp0(ref->type, ent->e_type)))
|
||||
{
|
||||
QofCollection *temp_col;
|
||||
char cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
|
||||
temp_col = ref->param->param_getfcn(ent, ref->param);
|
||||
coll = qof_book_get_collection(partial_book,
|
||||
qof_collection_get_type(temp_col));
|
||||
guid_to_string_buff(ref->ref_guid, cm_sa);
|
||||
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
|
||||
if (reference)
|
||||
{
|
||||
qof_collection_add_entity(temp_col, reference);
|
||||
qof_begin_edit((QofInstance*)ent);
|
||||
qof_begin_edit((QofInstance*)reference);
|
||||
if (collect_setter)
|
||||
{
|
||||
collect_setter(ent, temp_col);
|
||||
}
|
||||
qof_commit_edit((QofInstance*)ent);
|
||||
qof_commit_edit((QofInstance*)reference);
|
||||
qof_collection_destroy(temp_col);
|
||||
}
|
||||
}
|
||||
if (0 == g_strcmp0(ref->param->param_type, QOF_TYPE_CHOICE))
|
||||
{
|
||||
coll = qof_book_get_collection(partial_book, ref->type);
|
||||
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
|
||||
qof_begin_edit((QofInstance*)ent);
|
||||
qof_begin_edit((QofInstance*)reference);
|
||||
if (choice_setter)
|
||||
{
|
||||
choice_setter(ent, reference);
|
||||
}
|
||||
qof_commit_edit((QofInstance*)ent);
|
||||
qof_commit_edit((QofInstance*)reference);
|
||||
}
|
||||
book_ref_list = g_list_next(book_ref_list);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_each_type(QofObject *obj, gpointer user_data)
|
||||
{
|
||||
QofBook *book;
|
||||
|
||||
book = (QofBook*)user_data;
|
||||
qof_object_foreach(obj->e_type, book, entity_set_reference_cb, book);
|
||||
}
|
||||
|
||||
static QofInstanceReference*
|
||||
create_reference(QofInstance *ent, const QofParam *param)
|
||||
{
|
||||
QofInstanceReference *reference;
|
||||
QofInstance *ref_ent;
|
||||
const GncGUID *cm_guid;
|
||||
char cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
gchar *cm_string;
|
||||
|
||||
g_return_val_if_fail(ent, NULL);
|
||||
ref_ent = QOF_INSTANCE(param->param_getfcn(ent, param));
|
||||
if (!ref_ent)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
reference = g_new0(QofInstanceReference, 1);
|
||||
reference->type = ent->e_type;
|
||||
reference->ref_guid = g_new(GncGUID, 1);
|
||||
reference->ent_guid = qof_instance_get_guid(ent);
|
||||
if (qof_object_is_choice(ent->e_type))
|
||||
{
|
||||
reference->choice_type = ref_ent->e_type;
|
||||
}
|
||||
reference->param = param;
|
||||
cm_guid = qof_instance_get_guid(ref_ent);
|
||||
guid_to_string_buff(cm_guid, cm_sa);
|
||||
cm_string = g_strdup(cm_sa);
|
||||
if (TRUE == string_to_guid(cm_string, reference->ref_guid))
|
||||
{
|
||||
g_free(cm_string);
|
||||
return reference;
|
||||
}
|
||||
g_free(cm_string);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QofInstanceReference*
|
||||
qof_instance_get_reference_from(QofInstance *ent, const QofParam *param)
|
||||
{
|
||||
g_return_val_if_fail(param, NULL);
|
||||
param = qof_class_get_parameter(ent->e_type, param->param_name);
|
||||
g_return_val_if_fail(0 != g_strcmp0(param->param_type, QOF_TYPE_COLLECT), NULL);
|
||||
return create_reference(ent, param);
|
||||
}
|
||||
|
||||
void qof_book_set_references(QofBook *book)
|
||||
{
|
||||
gboolean partial;
|
||||
|
||||
partial =
|
||||
(gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
|
||||
g_return_if_fail(partial);
|
||||
qof_object_foreach_type(set_each_type, book);
|
||||
}
|
@ -1,200 +0,0 @@
|
||||
/***************************************************************************
|
||||
* qofreference.h
|
||||
*
|
||||
* Mon Feb 13 21:07:06 2006
|
||||
* Copyright 2006 Neil Williams
|
||||
* linux@codehelp.co.uk
|
||||
****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _QOFREFERENCE_H
|
||||
#define _QOFREFERENCE_H
|
||||
|
||||
/** \addtogroup Reference
|
||||
|
||||
Partial book is a QofBook that lacks at least one of the key elements of a fully
|
||||
structured (complete) book:
|
||||
- Self-contained: All relationships between entities are satisfied within
|
||||
the book itself;
|
||||
- Containing specific entities that provide an external structure to the
|
||||
data within the book.
|
||||
|
||||
Partial books are useful for query results, selective export and data mining
|
||||
but need to be merged back into standard books. It is not supported to construct
|
||||
a partial book and then convert the same book to a standard book.
|
||||
|
||||
Different backends have different requirements for a complete book - some
|
||||
(like gnucash) are highly customised to that application - however all complete
|
||||
QofBooks must be self-contained, only a partial book uses QofInstanceReference.
|
||||
|
||||
To retain the relationships between entities, including between a partial and
|
||||
a complete book, QofInstanceReference data is stored in the QofBook. This data
|
||||
should be read by backends that support partial books so that the exported
|
||||
data contains the GncGUID and QofIdType of the referenced entity. Even if that
|
||||
entity does not then exist within the partial book, it can be located when
|
||||
the partial book is merged back into the original, complete, book. (Remember
|
||||
that given the GncGUID and QofIdType of any QofInstance it is possible to uniquely
|
||||
identify that entity in another book.)
|
||||
|
||||
Entities in partial books may need to refer to the entities that remain within
|
||||
the partial book. Once all the entities you want are in the partial book,
|
||||
call qof_book_set_references to restore as many references as possible. Each
|
||||
object type is checked in turn, each entity of that type and then each
|
||||
parameter that can relate to another entity. Any references that cannot be
|
||||
found are left unset - depending on the object these may be undefined or NULL.
|
||||
(It is advisable to set all QOF parameters to either a default value or NULL
|
||||
in the create: routine for the object but QOF has no way of guaranteeing this.)
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
/** \file qofreference.h
|
||||
\brief Dealing with relationships between entities in partial books.
|
||||
\author Copyright (c) 2006 Neil Williams <linux@codehelp.co.uk>
|
||||
*/
|
||||
|
||||
#include "qof.h"
|
||||
|
||||
/** @name Using a partial QofBook.
|
||||
|
||||
Part of the handling for partial books requires a storage mechanism for
|
||||
references to entities that are not within reach of the partial book.
|
||||
This requires a GList in the book data to contain the reference
|
||||
QofIdType and GncGUID so that when the book is written out, the
|
||||
reference can be included. See ::qof_book_get_data.
|
||||
|
||||
When the file is imported back in, the list needs to be rebuilt.
|
||||
The QSF backend rebuilds the references by linking to real entities.
|
||||
Other backends can process the list in similar ways.
|
||||
|
||||
The list stores the QofInstanceReference to the referenced entity -
|
||||
a struct that contains the GncGUID and the QofIdType of the referenced
|
||||
entity as well as the parameter used to obtain the reference.
|
||||
|
||||
Partial books need to be differentiated in the backend, the
|
||||
flag in the book data is used by qof_session_save to prevent a partial
|
||||
book being saved using a backend that requires a full book. Forcing this
|
||||
flag would cause data loss so always merge a partial book with the complete
|
||||
book (even if that book is initially empty) before trying to save the data
|
||||
using a backend that does not support partial books.
|
||||
|
||||
@{ */
|
||||
|
||||
|
||||
/** \brief External references in a partial QofBook.
|
||||
|
||||
For use by any session that deals with partial QofBooks.
|
||||
It is used by the entity copy functions and by the QSF backend.
|
||||
Creates a GList stored in the Book hashtable to contain
|
||||
repeated references for a single entity.
|
||||
*/
|
||||
typedef struct qof_instance_reference
|
||||
{
|
||||
QofIdType choice_type;/**< Used when the reference is a QOF_TYPE_CHOICE type
|
||||
- stores the actual type of the reference from the list of available choices. */
|
||||
QofIdType type; /**< The type of the original entity -
|
||||
use the param->param_type to obtain the type of the reference entity.
|
||||
For a QOF_TYPE_COLLECT, obtain the collection and get the type from that. */
|
||||
GncGUID *ref_guid; /**< The GncGUID of the REFERENCE entity */
|
||||
const QofParam *param; /**< The parameter of the original entity to use
|
||||
to get or set the reference. */
|
||||
const GncGUID *ent_guid; /**< The GncGUID of the original entity. */
|
||||
} QofInstanceReference;
|
||||
|
||||
/** Used as the key value for the QofBook data hash.
|
||||
*
|
||||
* Retrieved later by QSF (or any other suitable backend) to
|
||||
* rebuild the references from the QofInstanceReference struct
|
||||
* that contains the QofIdType and GncGUID of the referenced entity
|
||||
* of the original QofBook as well as the parameter data and the
|
||||
* GncGUID of the original entity.
|
||||
* */
|
||||
#define ENTITYREFERENCE "QofInstanceReference"
|
||||
|
||||
/** \brief Flag indicating a partial QofBook.
|
||||
|
||||
When set in the book data with a gboolean value of TRUE,
|
||||
the flag denotes that only a backend that supports partial
|
||||
books can be used to save this session.
|
||||
*/
|
||||
|
||||
#define PARTIAL_QOFBOOK "PartialQofBook"
|
||||
|
||||
/** \brief Read QofInstanceReference data for this book and set values.
|
||||
|
||||
@param book The partial book containing the referenceList
|
||||
|
||||
The referenceList is a GList of QofInstanceReference structures that contain
|
||||
the GncGUID of each end of a reference. e.g. where one entity refers to another.
|
||||
|
||||
The referenceList is used in partial books to store relationships between
|
||||
entities when the entities themselves might not exist in the partial book.
|
||||
|
||||
If the book is not marked as a partial book, an assertion error is generated.
|
||||
|
||||
This routine tries to lookup each entity in the referenceList for the
|
||||
book and then tries to lookup the reference - to find the child entity that
|
||||
was originally linked to this parent. The child entity is then set in the
|
||||
parent so that it can be located as normal.
|
||||
|
||||
If the child entity does not exist in this partial book, the parent entity
|
||||
is not updated. The referenceList is unchanged (in case the child is added
|
||||
later).
|
||||
|
||||
*/
|
||||
void qof_book_set_references(QofBook *book);
|
||||
|
||||
/** \brief Get a reference from this entity to another entity.
|
||||
|
||||
\note Only to be used in situations where the QofParam has already
|
||||
been checked \b NOT to be QOF_TYPE_COLLECT or other known QOF types
|
||||
because this function expects to return a single reference and
|
||||
a collect parameter would need to return a list of references, other
|
||||
parameters would not return a viable QofInstance. (A string cannot be
|
||||
cast to an entity.)
|
||||
|
||||
Used in the preparation of a partial QofBook when the known entity
|
||||
(the one currently being copied into the partial book) refers to
|
||||
any other entity, usually as a parent or child.
|
||||
The routine calls the param_getfcn of the supplied parameter,
|
||||
which must return an object (QofInstance*), not a known QOF data type, to
|
||||
retrieve the referenced entity and therefore the GncGUID. The GncGUID of
|
||||
both entities are stored in the reference which then needs to be added
|
||||
to the reference list which is added to the partial book data hash.
|
||||
The reference itself is used to preserve the relationship
|
||||
between entities within and outside the partial book.
|
||||
|
||||
See also ::qof_class_get_referenceList to obtain the list of
|
||||
parameters that provide references to the known entity whilst
|
||||
excluding parameters that return known QOF data types.
|
||||
|
||||
Note that even if the referenced entity \b exists in the partial
|
||||
book (or will exist later), a reference must still be obtained and
|
||||
added to the reference list for the book itself. This maintains
|
||||
the integrity of the partial book during sequential copy operations.
|
||||
|
||||
@param ent The known entity.
|
||||
@param param The parameter to use to get the referenced entity.
|
||||
|
||||
@return FALSE on error, otherwise a pointer to the QofInstanceReference.
|
||||
*/
|
||||
QofInstanceReference*
|
||||
qof_instance_get_reference_from(QofInstance *ent, const QofParam *param);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
#endif /* _QOFREFERENCE_H */
|
@ -626,7 +626,6 @@ qof_session_save (QofSession *session,
|
||||
QofPercentageFunc percentage_func)
|
||||
{
|
||||
QofBackend *be;
|
||||
gboolean partial, change_backend;
|
||||
QofBackendProvider *prov;
|
||||
GSList *p;
|
||||
QofBook *book;
|
||||
@ -639,100 +638,9 @@ qof_session_save (QofSession *session,
|
||||
goto leave;
|
||||
ENTER ("sess=%p book_id=%s",
|
||||
session, session->book_id ? session->book_id : "(null)");
|
||||
/* Partial book handling. */
|
||||
book = qof_session_get_book(session);
|
||||
partial = (gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
|
||||
change_backend = FALSE;
|
||||
msg = g_strdup_printf(" ");
|
||||
book_id = g_strdup(session->book_id);
|
||||
if (partial == TRUE)
|
||||
{
|
||||
if (session->backend && session->backend->provider)
|
||||
{
|
||||
prov = session->backend->provider;
|
||||
if (TRUE == prov->partial_book_supported)
|
||||
{
|
||||
/* if current backend supports partial, leave alone. */
|
||||
change_backend = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
change_backend = TRUE;
|
||||
}
|
||||
}
|
||||
/* If provider is undefined, assume partial not supported. */
|
||||
else
|
||||
{
|
||||
change_backend = TRUE;
|
||||
}
|
||||
}
|
||||
if (change_backend == TRUE)
|
||||
{
|
||||
qof_session_destroy_backend(session);
|
||||
if (!qof_providers_initialized)
|
||||
{
|
||||
qof_providers_initialized = TRUE;
|
||||
}
|
||||
p = provider_list;
|
||||
while (p != NULL)
|
||||
{
|
||||
prov = p->data;
|
||||
if (TRUE == prov->partial_book_supported)
|
||||
{
|
||||
/** \todo check the access_method too, not in scope here, yet. */
|
||||
/* if((TRUE == prov->partial_book_supported) &&
|
||||
(0 == g_ascii_strcasecmp (access_method, prov->access_method)))
|
||||
{*/
|
||||
if (NULL == prov->backend_new) continue;
|
||||
/* Use the providers creation callback */
|
||||
session->backend = (*(prov->backend_new))();
|
||||
session->backend->provider = prov;
|
||||
if (session->backend->session_begin)
|
||||
{
|
||||
/* Call begin - backend has been changed,
|
||||
so make sure a file can be written,
|
||||
use ignore_lock and force create */
|
||||
g_free(session->book_id);
|
||||
session->book_id = NULL;
|
||||
(session->backend->session_begin)(session->backend, session,
|
||||
book_id, TRUE, TRUE, TRUE);
|
||||
PINFO("Done running session_begin on changed backend");
|
||||
err = qof_backend_get_error(session->backend);
|
||||
msg = qof_backend_get_message(session->backend);
|
||||
if (err != ERR_BACKEND_NO_ERR)
|
||||
{
|
||||
g_free(session->book_id);
|
||||
session->book_id = NULL;
|
||||
qof_session_push_error (session, err, msg);
|
||||
LEAVE("changed backend error %d", err);
|
||||
goto leave;
|
||||
}
|
||||
if (msg != NULL)
|
||||
{
|
||||
PWARN("%s", msg);
|
||||
g_free(msg);
|
||||
msg = NULL;
|
||||
}
|
||||
}
|
||||
/* Tell the book about the backend that they'll be using. */
|
||||
qof_book_set_backend (session->book, session->backend);
|
||||
p = NULL;
|
||||
}
|
||||
if (p)
|
||||
{
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
if (!session->backend)
|
||||
{
|
||||
if (ERR_BACKEND_NO_ERR != qof_session_get_error(session))
|
||||
{
|
||||
msg = g_strdup_printf("failed to load backend");
|
||||
qof_session_push_error(session, ERR_BACKEND_NO_HANDLER, msg);
|
||||
}
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
/* If there is a backend, and the backend is reachable
|
||||
* (i.e. we can communicate with it), then synchronize with
|
||||
* the backend. If we cannot contact the backend (e.g.
|
||||
|
Loading…
Reference in New Issue
Block a user