GnuCash c935c2f+
Loading...
Searching...
No Matches
qofsession.h
Go to the documentation of this file.
1/********************************************************************\
2 * qofsession.h -- session access (connection to backend) *
3 * *
4 * This program is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU General Public License as *
6 * published by the Free Software Foundation; either version 2 of *
7 * the License, or (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License*
15 * along with this program; if not, contact: *
16 * *
17 * Free Software Foundation Voice: +1-617-542-5942 *
18 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19 * Boston, MA 02110-1301, USA gnu@gnu.org *
20 * *
21\********************************************************************/
22
98#ifndef QOF_SESSION_H
99#define QOF_SESSION_H
100
101#include "qofbackend.h"
102#include "qofbook.h"
103#include "qofclass.h"
104#include "qofobject.h"
105
106#ifdef __cplusplus
107extern "C"
108{
109#endif
110
111#define QOF_MOD_SESSION "qof.session"
115/* This replaces three booleans that were passed in order: ignore_lock, create,
116 * and force. It's structured so that one can use it as a bit field with the
117 * values in the same order, i.e. ignore_lock = 1 << 2, create = 1 << 1, and
118 * force = 1.
119 */
120typedef enum
121{
122 SESSION_NORMAL_OPEN = 0, // All False
124 SESSION_NEW_STORE = 2, // False, True, False (create)
126 SESSION_NEW_OVERWRITE = 3, // False, True, True (create | force)
128 SESSION_READ_ONLY = 4, // True, False, False (ignore_lock)
130 SESSION_BREAK_LOCK = 5 // True, False, True (ignore_lock | force)
133
134/* PROTOTYPES ******************************************************/
135
136typedef struct QofSessionImpl QofSession;
137
138QofSession * qof_session_new (QofBook* book);
139void qof_session_destroy (QofSession *session);
140
144void qof_session_swap_data (QofSession *session_1, QofSession *session_2);
145
183void qof_session_begin (QofSession *session, const char * new_uri,
184 SessionOpenMode mode);
185
199typedef void (*QofPercentageFunc) (const char *message, double percent);
200void qof_session_load (QofSession *session,
201 QofPercentageFunc percentage_func);
202
208QofBackendError qof_session_get_error (QofSession *session);
209const char * qof_session_get_error_message(const QofSession *session);
210
221QofBackendError qof_session_pop_error (QofSession *session);
225QofBook * qof_session_get_book (const QofSession *session);
226
241const char * qof_session_get_file_path (const QofSession *session);
242
243const char * qof_session_get_url (const QofSession *session);
244
249/* gboolean qof_session_not_saved(const QofSession *session); <- unimplemented */
250gboolean qof_session_save_in_progress(const QofSession *session);
251
255QofBackend * qof_session_get_backend(const QofSession *session);
256
263void qof_session_save (QofSession *session,
264 QofPercentageFunc percentage_func);
265
273void qof_session_safe_save (QofSession *session,
274 QofPercentageFunc percentage_func);
275
284void qof_session_end (QofSession *session);
285
296gboolean qof_session_events_pending (const QofSession *session);
297
302gboolean qof_session_process_events (QofSession *session);
305gboolean qof_session_export (QofSession *tmp_session,
306 QofSession *real_session,
307 QofPercentageFunc percentage_func);
308
313
316void qof_session_ensure_all_data_loaded(QofSession* session);
317
318#ifdef __cplusplus
319}
320#endif
321
322#endif /* QOF_SESSION_H */
QofBackendError qof_session_pop_error(QofSession *session)
The qof_session_pop_error() routine can be used to obtain the reason for any failure.
void qof_session_swap_data(QofSession *session_1, QofSession *session_2)
The qof_session_swap_data () method swaps the book of the two given sessions.
void qof_session_save(QofSession *session, QofPercentageFunc percentage_func)
The qof_session_save() method will commit all changes that have been made to the session.
void qof_session_end(QofSession *session)
The qof_session_end() method will release the session lock.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
Definition qofbackend.h:58
gboolean qof_session_save_in_progress(const QofSession *session)
The qof_session_not_saved() subroutine will return TRUE if any data in the session hasn't been saved ...
const char * qof_session_get_file_path(const QofSession *session)
The qof_session_get_file_path() routine returns the fully-qualified file path for the session.
QofBackendError qof_session_get_error(QofSession *session)
The qof_session_get_error() routine can be used to obtain the reason for any failure.
QofBackend * qof_session_get_backend(const QofSession *session)
Returns the qof session's backend.
SessionOpenMode
Mode for opening sessions.
Definition qofsession.h:121
void qof_session_begin(QofSession *session, const char *new_uri, SessionOpenMode mode)
Begins a new session.
void qof_session_safe_save(QofSession *session, QofPercentageFunc percentage_func)
A special version of save used in the sql backend which moves the existing tables aside,...
void(* QofPercentageFunc)(const char *message, double percent)
The qof_session_load() method causes the QofBook to be made ready to to use with this URL/datastore.
Definition qofsession.h:199
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
@ SESSION_READ_ONLY
Create a new store at the URI even if a store already exists there.
Definition qofsession.h:128
@ SESSION_NEW_STORE
Open will fail if the URI doesn't exist or is locked.
Definition qofsession.h:124
@ SESSION_BREAK_LOCK
Open the session read-only, ignoring any existing lock and not creating one if the URI isn't locked.
Definition qofsession.h:130
@ SESSION_NEW_OVERWRITE
Create a new store at the URI.
Definition qofsession.h:126
API for data storage Backend.
Encapsulate all the information about a dataset.
API for registering parameters on objects.
the Core Object Registration/Lookup Interface
gboolean qof_session_events_pending(const QofSession *session)
The qof_session_events_pending() method will return TRUE if the backend has pending events which must...
gboolean qof_session_process_events(QofSession *session)
The qof_session_process_events() method will process any events indicated by the qof_session_events_p...
GList * qof_backend_get_registered_access_method_list(void)
Return a list of strings for the registered access methods.
void qof_session_ensure_all_data_loaded(QofSession *session)
Ensure all of the data is loaded from the session.
QofBook reference.
Definition qofbook-p.hpp:47