Copyright (c) 2000 Dave Peticolas
Copyright (c) 2005 Neil Williams <linux@codehelp.co.uk>
Definition in file qofsession.h.
#include "qofbackend.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofobject.h"
Go to the source code of this file.
Data Structures | |
| struct | qof_entity_reference |
| External references in a partial QofBook. More... | |
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 GUID 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 hash table in similar ways. The list stores the QofEntityReference to the referenced entity - a struct that contains the GUID 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. | |
| #define | ENTITYREFERENCE "QofEntityReference" |
| #define | PARTIAL_QOFBOOK "PartialQofBook" |
| Flag indicating a partial QofBook. | |
| typedef qof_entity_reference | QofEntityReference |
| External references in a partial QofBook. | |
| QofEntityReference * | qof_entity_get_reference_from (QofEntity *ent, const QofParam *param) |
| Get a reference from this entity to another entity. | |
| void | qof_session_update_reference_list (QofSession *session, QofEntityReference *reference) |
| Adds a new reference to the partial book data hash. | |
Session Errors | |
| QofBackendError | qof_session_get_error (QofSession *session) |
| const char * | qof_session_get_error_message (QofSession *session) |
| QofBackendError | qof_session_pop_error (QofSession *session) |
Copying entities between sessions. | |
| Only certain backends can cope with selective copying of entities and only fully defined QOF entities can be copied between sessions - see the QOF Serialisation Format (QSF) documentation (qsf_write_file) for more information. The recommended backend for the new session is QSF or a future SQL backend. Using any of these entity copy functions sets a flag in the backend that this is now a partial QofBook. When you save a session containing a partial QofBook, the session will check that the backend is able to handle the partial book. If not, the backend will be replaced by one that can handle partial books, preferably one using the same access_method. Currently, this means that a book using the GnuCash XML v2 file backend will be switched to QSF. Copied entities are identical to the source entity, all parameters defined with QofAccessFunc and QofSetterFunc in QOF are copied and the GUID of the original QofEntity is set in the new entity. Sessions containing copied entities are intended for use as mechanisms for data export. It is acceptable to add entities to new_session in batches. Note that any of these calls will fail if an entity already exists in new_session with the same GUID as any entity to be copied.
To merge a whole QofBook or where there is any possibility of collisions or requirement for user intervention, see Merging QofBook structures | |
| gboolean | qof_entity_copy_to_session (QofSession *new_session, QofEntity *original) |
| Copy a single QofEntity to another session. | |
| gboolean | qof_entity_copy_list (QofSession *new_session, GList *entity_list) |
| Copy a GList of entities to another session. | |
| gboolean | qof_entity_copy_coll (QofSession *new_session, QofCollection *entity_coll) |
| Copy a QofCollection of entities. | |
| gboolean | qof_entity_copy_coll_r (QofSession *new_session, QofCollection *coll) |
| Recursively copy a collection of entities to a session. | |
| gboolean | qof_entity_copy_one_r (QofSession *new_session, QofEntity *ent) |
| Recursively copy a single entity to a new session. | |
Event Handling | |
| gboolean | qof_session_events_pending (QofSession *session) |
| gboolean | qof_session_process_events (QofSession *session) |
Defines | |
| #define | QOF_MOD_SESSION "qof-session" |
| #define | QOF_STDOUT "file:" |
| Allow session data to be printed to stdout. | |
Typedefs | |
| typedef _QofSession | QofSession |
| typedef void(* | QofPercentageFunc )(const char *message, double percent) |
Functions | |
| QofSession * | qof_session_new (void) |
| void | qof_session_destroy (QofSession *session) |
| QofSession * | qof_session_get_current_session (void) |
| void | qof_session_set_current_session (QofSession *session) |
| void | qof_session_swap_data (QofSession *session_1, QofSession *session_2) |
| void | qof_session_begin (QofSession *session, const char *book_id, gboolean ignore_lock, gboolean create_if_nonexistent) |
| void | qof_session_load (QofSession *session, QofPercentageFunc percentage_func) |
| void | qof_session_add_book (QofSession *session, QofBook *book) |
| QofBook * | qof_session_get_book (QofSession *session) |
| const char * | qof_session_get_file_path (QofSession *session) |
| const char * | qof_session_get_url (QofSession *session) |
| gboolean | qof_session_not_saved (QofSession *session) |
| gboolean | qof_session_save_may_clobber_data (QofSession *session) |
| void | qof_session_save (QofSession *session, QofPercentageFunc percentage_func) |
| void | qof_session_end (QofSession *session) |
| void | qof_session_add_close_hook (GFunc fn, gpointer data) |
| void | qof_session_call_close_hooks (QofSession *session) |
1.4.5