GnuCash  5.6-150-g038405b370+
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
107 extern "C"
108 {
109 #endif
110 
111 #define QOF_MOD_SESSION "qof.session"
112 
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  */
120 typedef 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 
136 typedef struct QofSessionImpl QofSession;
137 
138 QofSession * qof_session_new (QofBook* book);
139 void qof_session_destroy (QofSession *session);
140 
144 void qof_session_swap_data (QofSession *session_1, QofSession *session_2);
145 
183 void qof_session_begin (QofSession *session, const char * new_uri,
184  SessionOpenMode mode);
185 
199 typedef void (*QofPercentageFunc) (const char *message, double percent);
200 void qof_session_load (QofSession *session,
201  QofPercentageFunc percentage_func);
202 
208 QofBackendError qof_session_get_error (QofSession *session);
209 const char * qof_session_get_error_message(const QofSession *session);
210 
221 QofBackendError qof_session_pop_error (QofSession *session);
225 QofBook * qof_session_get_book (const QofSession *session);
226 
241 const char * qof_session_get_file_path (const QofSession *session);
242 
243 const char * qof_session_get_url (const QofSession *session);
244 
249 /* gboolean qof_session_not_saved(const QofSession *session); <- unimplemented */
250 gboolean qof_session_save_in_progress(const QofSession *session);
251 
255 QofBackend * qof_session_get_backend(const QofSession *session);
256 
263 void qof_session_save (QofSession *session,
264  QofPercentageFunc percentage_func);
265 
273 void qof_session_safe_save (QofSession *session,
274  QofPercentageFunc percentage_func);
275 
284 void qof_session_end (QofSession *session);
285 
296 gboolean qof_session_events_pending (const QofSession *session);
297 
302 gboolean qof_session_process_events (QofSession *session);
305 gboolean qof_session_export (QofSession *tmp_session,
306  QofSession *real_session,
307  QofPercentageFunc percentage_func);
308 
313 
316 void qof_session_ensure_all_data_loaded(QofSession* session);
317 
318 #ifdef __cplusplus
319 }
320 #endif
321 
322 #endif /* QOF_SESSION_H */
323 
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.
Definition: qofsession.cpp:625
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&#39;t been saved ...
Definition: qofsession.cpp:640
API for data storage Backend.
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
QofBackendError
The errors that can be reported to the GUI & other front-end users.
Definition: qofbackend.h:57
the Core Object Registration/Lookup Interface
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...
Definition: qofsession.cpp:633
void qof_session_begin(QofSession *session, const char *new_uri, SessionOpenMode mode)
Begins a new session.
Definition: qofsession.cpp:610
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...
Definition: qofsession.cpp:662
Create a new store at the URI.
Definition: qofsession.h:126
Open the session read-only, ignoring any existing lock and not creating one if the URI isn&#39;t locked...
Definition: qofsession.h:130
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...
Definition: qofsession.cpp:581
Create a new store at the URI even if a store already exists there.
Definition: qofsession.h:128
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
Definition: qofsession.cpp:574
QofBackendError qof_session_pop_error(QofSession *session)
The qof_session_pop_error() routine can be used to obtain the reason for any failure.
Definition: qofsession.cpp:567
QofBackendError qof_session_get_error(QofSession *session)
The qof_session_get_error() routine can be used to obtain the reason for any failure.
Definition: qofsession.cpp:728
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.
Definition: qofsession.cpp:654
Encapsulate all the information about a dataset.
API for registering parameters on objects.
SessionOpenMode
Mode for opening sessions.
Definition: qofsession.h:120
gboolean qof_session_process_events(QofSession *session)
The qof_session_process_events() method will process any events indicated by the qof_session_events_p...
Definition: qofsession.cpp:669
void qof_session_ensure_all_data_loaded(QofSession *session)
Ensure all of the data is loaded from the session.
Definition: qofsession.cpp:589
GList * qof_backend_get_registered_access_method_list(void)
Return a list of strings for the registered access methods.
Definition: qofsession.cpp:103
void qof_session_end(QofSession *session)
The qof_session_end() method will release the session lock.
Definition: qofsession.cpp:647
QofBackend * qof_session_get_backend(const QofSession *session)
Returns the qof session&#39;s backend.
Definition: qofsession.cpp:603
Open will fail if the URI doesn&#39;t exist or is locked.
Definition: qofsession.h:124