mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rename gncbook and gncsession to qofbook and qofsession
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8762 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
cfdbd2e916
commit
92a2f26e52
@ -29,8 +29,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "AccountP.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "Group.h"
|
||||
#include "GroupP.h"
|
||||
#include "TransactionP.h"
|
||||
@ -45,6 +43,8 @@
|
||||
#include "kvp-util-p.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include "qofbackend.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofid-p.h"
|
||||
@ -383,7 +383,7 @@ xaccFreeAccount (Account *acc)
|
||||
void
|
||||
xaccAccountBeginEdit (Account *acc)
|
||||
{
|
||||
Backend * be;
|
||||
QofBackend * be;
|
||||
if (!acc) return;
|
||||
|
||||
acc->editlevel++;
|
||||
@ -407,7 +407,7 @@ xaccAccountBeginEdit (Account *acc)
|
||||
void
|
||||
xaccAccountCommitEdit (Account *acc)
|
||||
{
|
||||
Backend * be;
|
||||
QofBackend * be;
|
||||
|
||||
if (!acc) return;
|
||||
|
||||
@ -469,15 +469,15 @@ xaccAccountCommitEdit (Account *acc)
|
||||
be = xaccAccountGetBackend (acc);
|
||||
if (be && be->commit)
|
||||
{
|
||||
GNCBackendError errcode;
|
||||
QofBackendError errcode;
|
||||
|
||||
/* clear errors */
|
||||
do {
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
} while (ERR_BACKEND_NO_ERR != errcode);
|
||||
|
||||
(be->commit) (be, GNC_ID_ACCOUNT, acc);
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
|
||||
if (ERR_BACKEND_NO_ERR != errcode)
|
||||
{
|
||||
@ -487,17 +487,17 @@ xaccAccountCommitEdit (Account *acc)
|
||||
/* XXX hack alert FIXME implement account rollback */
|
||||
PERR (" backend asked engine to rollback, but this isn't"
|
||||
" handled yet. Return code=%d", errcode);
|
||||
err = xaccBackendGetMessage(be);
|
||||
err = qof_backend_get_message(be);
|
||||
/* g_strdup here, because err needs to be g_freed if from Backend */
|
||||
err = err ? err : g_strdup(_("Error message not available"));
|
||||
/* Translators: %d is the (internal) error number. %s is the
|
||||
* human-readable error description. */
|
||||
PWARN_GUI(_("Error occurred while saving Account:\n%d: %s"),
|
||||
xaccBackendGetError(be), err);
|
||||
qof_backend_get_error(be), err);
|
||||
|
||||
/* push error back onto the stack */
|
||||
xaccBackendSetError (be, errcode);
|
||||
xaccBackendSetMessage (be, err);
|
||||
qof_backend_set_error (be, errcode);
|
||||
qof_backend_set_message (be, err);
|
||||
g_free(err);
|
||||
}
|
||||
}
|
||||
@ -3153,7 +3153,7 @@ xaccAccountFindTransByDesc(Account *account, const char *description)
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
Backend *
|
||||
QofBackend *
|
||||
xaccAccountGetBackend (Account * acc)
|
||||
{
|
||||
if (!acc || !acc->book) return NULL;
|
||||
@ -3176,7 +3176,7 @@ account_foreach (QofBook *book, QofEntityForeachCB cb, gpointer ud)
|
||||
}
|
||||
|
||||
static QofObject account_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
QOF_OBJECT_VERSION,
|
||||
GNC_ID_ACCOUNT,
|
||||
"Account",
|
||||
NULL, /* book_begin */
|
||||
|
@ -42,11 +42,11 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "Backend.h"
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-numeric.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
|
||||
@ -211,7 +211,7 @@ gint32 xaccAccountGetVersion (Account*);
|
||||
* persistent-data storage backend associated with this account.
|
||||
*/
|
||||
|
||||
Backend * xaccAccountGetBackend (Account *account);
|
||||
QofBackend * xaccAccountGetBackend (Account *account);
|
||||
|
||||
/* Register Accounts with the engine */
|
||||
gboolean xaccAccountRegister (void);
|
||||
|
@ -29,14 +29,13 @@
|
||||
|
||||
#include "Account.h"
|
||||
#include "AccountP.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "Group.h"
|
||||
#include "GroupP.h"
|
||||
#include "TransactionP.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-numeric.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofid-p.h"
|
||||
@ -1280,7 +1279,7 @@ xaccGroupForEachAccount (AccountGroup *grp,
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
Backend *
|
||||
QofBackend *
|
||||
xaccGroupGetBackend (AccountGroup *grp)
|
||||
{
|
||||
grp = xaccGroupGetRoot (grp);
|
||||
@ -1317,7 +1316,7 @@ group_mark_clean(QofBook *book)
|
||||
|
||||
static QofObject group_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
interface_version: QOF_OBJECT_VERSION,
|
||||
name: GNC_ID_GROUP,
|
||||
type_label: "AccountGroup",
|
||||
book_begin: group_book_begin,
|
||||
|
@ -38,9 +38,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "BackendP.h"
|
||||
#include "Transaction.h"
|
||||
#include "gnc-numeric.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
|
||||
@ -100,7 +100,7 @@ void xaccSetAccountGroup (QofBook *book, AccountGroup *grp);
|
||||
* The xaccGroupGetBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with this account group.
|
||||
*/
|
||||
Backend * xaccGroupGetBackend (AccountGroup *group);
|
||||
QofBackend * xaccGroupGetBackend (AccountGroup *group);
|
||||
|
||||
gboolean xaccGroupRegister (void);
|
||||
|
||||
|
@ -10,7 +10,6 @@ AM_CFLAGS = \
|
||||
|
||||
libgncmod_engine_la_SOURCES = \
|
||||
Account.c \
|
||||
Backend.c \
|
||||
FreqSpec.c \
|
||||
Group.c \
|
||||
Period.c \
|
||||
@ -31,7 +30,6 @@ libgncmod_engine_la_SOURCES = \
|
||||
gnc-lot.c \
|
||||
gnc-numeric.c \
|
||||
gnc-pricedb.c \
|
||||
gnc-session.c \
|
||||
gnc-session-scm.c \
|
||||
gnc-trace.c \
|
||||
gncmod-engine.c \
|
||||
@ -40,19 +38,20 @@ libgncmod_engine_la_SOURCES = \
|
||||
kvp-util.c \
|
||||
md5.c \
|
||||
messages.c \
|
||||
qofbackend.c \
|
||||
qofbook.c \
|
||||
qofid.c \
|
||||
qofobject.c \
|
||||
qofquery.c \
|
||||
qofquerycore.c \
|
||||
qofqueryobject.c \
|
||||
qofobject.c
|
||||
qofsession.c
|
||||
|
||||
EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c
|
||||
|
||||
gncincludedir = ${GNC_INCLUDE_DIR}
|
||||
gncinclude_HEADERS = \
|
||||
Account.h \
|
||||
Backend.h \
|
||||
FreqSpec.h \
|
||||
GNCId.h \
|
||||
Group.h \
|
||||
@ -89,16 +88,17 @@ gncinclude_HEADERS = \
|
||||
kvp-scm.h \
|
||||
kvp-util.h \
|
||||
messages.h \
|
||||
qofbackend.h \
|
||||
qofbook.h \
|
||||
qofid.h \
|
||||
qofobject.h \
|
||||
qofquery.h \
|
||||
qofquerycore.h \
|
||||
qofqueryobject.h \
|
||||
qofobject.h
|
||||
qofsession.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
AccountP.h \
|
||||
BackendP.h \
|
||||
FreqSpecP.h \
|
||||
GroupP.h \
|
||||
QueryP.h \
|
||||
@ -111,17 +111,18 @@ noinst_HEADERS = \
|
||||
gnc-lot.h \
|
||||
gnc-lot-p.h \
|
||||
gnc-pricedb-p.h \
|
||||
gnc-session-p.h \
|
||||
kvp-util-p.h \
|
||||
md5.h \
|
||||
gw-engine.h \
|
||||
gw-kvp.h \
|
||||
qofbackend-p.h \
|
||||
qofbook-p.h \
|
||||
qofid-p.h \
|
||||
qofobject-p.h \
|
||||
qofquery-p.h \
|
||||
qofquerycore-p.h \
|
||||
qofqueryobject-p.h \
|
||||
qofobject-p.h
|
||||
qofsession-p.h
|
||||
|
||||
noinst_SCRIPTS = iso-currencies-to-c
|
||||
|
||||
|
@ -36,7 +36,6 @@ Open questions: how do we deal with the backends ???
|
||||
*/
|
||||
|
||||
#include "AccountP.h"
|
||||
#include "BackendP.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "Group.h"
|
||||
@ -44,6 +43,7 @@ Open questions: how do we deal with the backends ???
|
||||
#include "kvp-util-p.h"
|
||||
#include "Period.h"
|
||||
#include "TransactionP.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofid-p.h"
|
||||
@ -181,7 +181,7 @@ void
|
||||
gnc_book_partition (QofBook *dest_book, QofBook *src_book, Query *query)
|
||||
{
|
||||
AccountGroup *src_grp, *dst_grp;
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
time_t now;
|
||||
GList *split_list, *snode;
|
||||
|
||||
|
@ -207,7 +207,7 @@ sxtt_mark_clean(QofBook *book)
|
||||
|
||||
static QofObject sxtt_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
interface_version: QOF_OBJECT_VERSION,
|
||||
name: GNC_ID_SXTT,
|
||||
type_label: "SXTT",
|
||||
book_begin: sxtt_book_begin,
|
||||
|
@ -32,8 +32,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "AccountP.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "Group.h"
|
||||
#include "TransactionP.h"
|
||||
#include "TransLog.h"
|
||||
@ -46,6 +44,7 @@
|
||||
#include "gnc-lot.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofid-p.h"
|
||||
@ -1718,7 +1717,7 @@ xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr)
|
||||
void
|
||||
xaccTransBeginEdit (Transaction *trans)
|
||||
{
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
if (!trans) return;
|
||||
|
||||
trans->editlevel ++;
|
||||
@ -1748,7 +1747,7 @@ void
|
||||
xaccTransCommitEdit (Transaction *trans)
|
||||
{
|
||||
Split *split;
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
const char *str;
|
||||
|
||||
if (!trans) return;
|
||||
@ -1831,16 +1830,16 @@ xaccTransCommitEdit (Transaction *trans)
|
||||
be = xaccTransactionGetBackend (trans);
|
||||
if (be && be->commit)
|
||||
{
|
||||
GNCBackendError errcode;
|
||||
QofBackendError errcode;
|
||||
|
||||
/* clear errors */
|
||||
do {
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
} while (ERR_BACKEND_NO_ERR != errcode);
|
||||
|
||||
(be->commit) (be, GNC_ID_TRANS, trans);
|
||||
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
if (ERR_BACKEND_NO_ERR != errcode)
|
||||
{
|
||||
/* if the backend puked, then we must roll-back
|
||||
@ -1854,7 +1853,7 @@ xaccTransCommitEdit (Transaction *trans)
|
||||
}
|
||||
|
||||
/* push error back onto the stack */
|
||||
xaccBackendSetError (be, errcode);
|
||||
qof_backend_set_error (be, errcode);
|
||||
|
||||
xaccTransRollbackEdit (trans);
|
||||
return;
|
||||
@ -1894,7 +1893,7 @@ xaccTransCommitEdit (Transaction *trans)
|
||||
void
|
||||
xaccTransRollbackEdit (Transaction *trans)
|
||||
{
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
Transaction *orig;
|
||||
int force_it=0, mismatch=0;
|
||||
int i;
|
||||
@ -2077,16 +2076,16 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
be = xaccTransactionGetBackend (trans);
|
||||
if (be && be->rollback)
|
||||
{
|
||||
GNCBackendError errcode;
|
||||
QofBackendError errcode;
|
||||
|
||||
/* clear errors */
|
||||
do {
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
} while (ERR_BACKEND_NO_ERR != errcode);
|
||||
|
||||
(be->rollback) (be, GNC_ID_TRANS, trans);
|
||||
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
if (ERR_BACKEND_MOD_DESTROY == errcode)
|
||||
{
|
||||
/* The backend is asking us to delete this transaction.
|
||||
@ -2098,7 +2097,7 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
xaccFreeTransaction (trans);
|
||||
|
||||
/* push error back onto the stack */
|
||||
xaccBackendSetError (be, errcode);
|
||||
qof_backend_set_error (be, errcode);
|
||||
LEAVE ("deleted trans addr=%p\n", trans);
|
||||
return;
|
||||
}
|
||||
@ -2106,7 +2105,7 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
{
|
||||
PERR ("Rollback Failed. Ouch!");
|
||||
/* push error back onto the stack */
|
||||
xaccBackendSetError (be, errcode);
|
||||
qof_backend_set_error (be, errcode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3531,7 +3530,7 @@ xaccTransReverse (Transaction *trans)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
Backend *
|
||||
QofBackend *
|
||||
xaccTransactionGetBackend (Transaction *trans)
|
||||
{
|
||||
if (!trans || !trans->book) return NULL;
|
||||
@ -3562,7 +3561,7 @@ split_foreach (QofBook *book, QofEntityForeachCB fcn, gpointer user_data)
|
||||
/* hook into the gncObject registry */
|
||||
|
||||
static QofObject split_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
QOF_OBJECT_VERSION,
|
||||
GNC_ID_SPLIT,
|
||||
"Split",
|
||||
NULL, /* book_begin */
|
||||
@ -3648,7 +3647,7 @@ trans_foreach (QofBook *book, QofEntityForeachCB fcn, gpointer user_data)
|
||||
}
|
||||
|
||||
static QofObject trans_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
QOF_OBJECT_VERSION,
|
||||
GNC_ID_TRANS,
|
||||
"Transaction",
|
||||
NULL, /* book_begin */
|
||||
|
@ -50,10 +50,10 @@
|
||||
#include <time.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "gnc-engine.h" /* for typedefs */
|
||||
#include "gnc-numeric.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
|
||||
@ -255,6 +255,6 @@ gboolean xaccTransRegister (void);
|
||||
* persistent-data storage backend associated with this
|
||||
* transaction.
|
||||
*/
|
||||
Backend * xaccTransactionGetBackend (Transaction *trans);
|
||||
QofBackend * xaccTransactionGetBackend (Transaction *trans);
|
||||
|
||||
#endif /* XACC_TRANSACTION_P_H */
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "Account.h"
|
||||
#include "Backend.h"
|
||||
#include "Group.h"
|
||||
#include "engine-helpers.h"
|
||||
#include "glib-helpers.h"
|
||||
@ -2365,10 +2364,10 @@ gnc_book_to_scm (QofBook *book)
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_session_to_scm
|
||||
* qof_session_to_scm
|
||||
********************************************************************/
|
||||
SCM
|
||||
gnc_session_to_scm (GNCSession *session)
|
||||
qof_session_to_scm (QofSession *session)
|
||||
{
|
||||
static SCM session_type = SCM_UNDEFINED;
|
||||
|
||||
|
@ -29,13 +29,13 @@
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-session.h"
|
||||
#include "Account.h"
|
||||
#include "Query.h"
|
||||
#include "Transaction.h"
|
||||
#include "guid.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
Timespec gnc_transaction_get_date_posted(Transaction *t);
|
||||
Timespec gnc_transaction_get_date_entered(Transaction *t);
|
||||
@ -82,6 +82,6 @@ int gnc_numeric_p(SCM arg);
|
||||
gnc_commodity * gnc_scm_to_commodity(SCM scm);
|
||||
SCM gnc_commodity_to_scm (const gnc_commodity *commodity);
|
||||
SCM gnc_book_to_scm (QofBook *book);
|
||||
SCM gnc_session_to_scm (GNCSession *session);
|
||||
SCM qof_session_to_scm (QofSession *session);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,25 @@
|
||||
/********************************************************************\
|
||||
* gnc-be-utils.h: api for data storage backend *
|
||||
* 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, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
/*
|
||||
* gnc-be-utils.h -- GnuCash Backend Utilities
|
||||
* gnc-be-utils.h -- QOF Backend Utilities
|
||||
* common code used by objects to define begin_edit() and
|
||||
* commit_edit() functions.
|
||||
*
|
||||
@ -10,8 +30,8 @@
|
||||
#ifndef GNC_BE_UTILS_H
|
||||
#define GNC_BE_UTILS_H
|
||||
|
||||
#include "BackendP.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
|
||||
/* begin_edit helper
|
||||
@ -28,7 +48,7 @@
|
||||
*/
|
||||
|
||||
#define GNC_BEGIN_EDIT(obj,type) { \
|
||||
Backend * be; \
|
||||
QofBackend * be; \
|
||||
if (!(obj)) return; \
|
||||
\
|
||||
(obj)->editlevel++; \
|
||||
@ -95,7 +115,7 @@
|
||||
* obj: the object being committed
|
||||
* type: the type of the object
|
||||
* on_error: a function called if there is a backend error.
|
||||
* void (*on_error)(obj, GNCBackendError)
|
||||
* void (*on_error)(obj, QofBackendError)
|
||||
* on_done: a function called after the commit is complete but before
|
||||
* the object is freed. This is where you clear the "dirty"
|
||||
* flag, and perform any other operations after the commit.
|
||||
@ -104,26 +124,26 @@
|
||||
* void (*on_free)(obj)
|
||||
*/
|
||||
#define GNC_COMMIT_EDIT_PART2(obj,type,on_error,on_done,on_free) { \
|
||||
Backend * be; \
|
||||
QofBackend * be; \
|
||||
\
|
||||
/* See if there's a backend. If there is, invoke it. */ \
|
||||
be = gnc_book_get_backend ((obj)->book); \
|
||||
if (be && be->commit) \
|
||||
{ \
|
||||
GNCBackendError errcode; \
|
||||
QofBackendError errcode; \
|
||||
\
|
||||
/* clear errors */ \
|
||||
do { \
|
||||
errcode = xaccBackendGetError (be); \
|
||||
errcode = qof_backend_get_error (be); \
|
||||
} while (ERR_BACKEND_NO_ERR != errcode); \
|
||||
\
|
||||
(be->commit) (be, (type), (obj)); \
|
||||
errcode = xaccBackendGetError (be); \
|
||||
errcode = qof_backend_get_error (be); \
|
||||
if (ERR_BACKEND_NO_ERR != errcode) \
|
||||
{ \
|
||||
(obj)->do_free = FALSE; \
|
||||
(on_error)((obj), errcode); \
|
||||
xaccBackendSetError (be, errcode); \
|
||||
qof_backend_set_error (be, errcode); \
|
||||
} \
|
||||
} \
|
||||
(on_done)(obj);\
|
||||
|
@ -1126,7 +1126,7 @@ commodity_table_book_end (QofBook *book)
|
||||
*/
|
||||
static QofObject commodity_table_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
interface_version: QOF_OBJECT_VERSION,
|
||||
name: GNC_ID_COMMODITY_TABLE,
|
||||
type_label: "CommodityTable",
|
||||
book_begin: commodity_table_book_begin,
|
||||
|
@ -28,8 +28,8 @@
|
||||
@author Copyright (C) 1997-2002 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
#ifndef GNC_ENGINE_UTIL_H
|
||||
#define GNC_ENGINE_UTIL_H
|
||||
#ifndef QOF_UTIL_H
|
||||
#define QOF_UTIL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -40,18 +40,18 @@
|
||||
|
||||
/** Macros *****************************************************/
|
||||
|
||||
#define SAFE_STRCMP_REAL(fcn,da,db) { \
|
||||
if ((da) && (db)) { \
|
||||
int retval = fcn ((da), (db)); \
|
||||
/* if strings differ, return */ \
|
||||
if (retval) return retval; \
|
||||
} else \
|
||||
if ((!(da)) && (db)) { \
|
||||
return -1; \
|
||||
} else \
|
||||
if ((da) && (!(db))) { \
|
||||
return +1; \
|
||||
} \
|
||||
#define SAFE_STRCMP_REAL(fcn,da,db) { \
|
||||
if ((da) && (db)) { \
|
||||
int retval = fcn ((da), (db)); \
|
||||
/* if strings differ, return */ \
|
||||
if (retval) return retval; \
|
||||
} else \
|
||||
if ((!(da)) && (db)) { \
|
||||
return -1; \
|
||||
} else \
|
||||
if ((da) && (!(db))) { \
|
||||
return +1; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_STRCMP(da,db) SAFE_STRCMP_REAL(strcmp,(da),(db))
|
||||
@ -127,5 +127,5 @@ GCache* gnc_engine_get_string_cache(void);
|
||||
|
||||
void gnc_engine_string_cache_destroy (void);
|
||||
|
||||
#endif
|
||||
#endif /* QOF_UTIL_H */
|
||||
/** @} */
|
||||
|
@ -27,9 +27,9 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-pricedb.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
|
||||
@ -107,6 +107,6 @@ void gnc_price_set_guid (GNCPrice *p, const GUID *guid);
|
||||
/** register the pricedb object with the gncObject system */
|
||||
gboolean gnc_pricedb_register (void);
|
||||
|
||||
Backend * xaccPriceDBGetBackend (GNCPriceDB *prdb);
|
||||
QofBackend * xaccPriceDBGetBackend (GNCPriceDB *prdb);
|
||||
|
||||
#endif
|
||||
|
@ -27,13 +27,13 @@
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "BackendP.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-pricedb-p.h"
|
||||
#include "guid.h"
|
||||
#include "kvp-util.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofid-p.h"
|
||||
@ -169,7 +169,7 @@ gnc_price_begin_edit (GNCPrice *p)
|
||||
/* See if there's a backend. If there is, invoke it. */
|
||||
/* We may not be able to find the backend, so make not of that .. */
|
||||
if (p->db) {
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
be = xaccPriceDBGetBackend (p->db);
|
||||
if (be && be->begin) {
|
||||
(be->begin) (be, GNC_ID_PRICE, p);
|
||||
@ -200,14 +200,14 @@ gnc_price_commit_edit (GNCPrice *p)
|
||||
/* See if there's a backend. If there is, invoke it. */
|
||||
/* We may not be able to find the backend, so make not of that .. */
|
||||
if (p->db) {
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
be = xaccPriceDBGetBackend (p->db);
|
||||
if (be && be->commit) {
|
||||
GNCBackendError errcode;
|
||||
QofBackendError errcode;
|
||||
|
||||
/* clear errors */
|
||||
do {
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
} while (ERR_BACKEND_NO_ERR != errcode);
|
||||
|
||||
/* if we haven't been able to call begin edit before, call it now */
|
||||
@ -218,7 +218,7 @@ gnc_price_commit_edit (GNCPrice *p)
|
||||
}
|
||||
|
||||
(be->commit) (be, GNC_ID_PRICE, p);
|
||||
errcode = xaccBackendGetError (be);
|
||||
errcode = qof_backend_get_error (be);
|
||||
if (ERR_BACKEND_NO_ERR != errcode)
|
||||
{
|
||||
/* XXX hack alert FIXME implement price rollback */
|
||||
@ -226,7 +226,7 @@ gnc_price_commit_edit (GNCPrice *p)
|
||||
" handled yet. Return code=%d", errcode);
|
||||
|
||||
/* push error back onto the stack */
|
||||
xaccBackendSetError (be, errcode);
|
||||
qof_backend_set_error (be, errcode);
|
||||
}
|
||||
}
|
||||
p->not_saved = FALSE;
|
||||
@ -1914,7 +1914,7 @@ gnc_pricedb_print_contents(GNCPriceDB *db, FILE *f)
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
Backend *
|
||||
QofBackend *
|
||||
xaccPriceDBGetBackend (GNCPriceDB *prdb)
|
||||
{
|
||||
if (!prdb || !prdb->book) return NULL;
|
||||
@ -1951,7 +1951,7 @@ pricedb_mark_clean(QofBook *book)
|
||||
|
||||
static QofObject pricedb_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
interface_version: QOF_OBJECT_VERSION,
|
||||
name: GNC_ID_PRICEDB,
|
||||
type_label: "PriceDB",
|
||||
book_begin: pricedb_book_begin,
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-session.h"
|
||||
#include "qofsession.h"
|
||||
#include "gnc-session-scm.h"
|
||||
|
||||
//static short module = MOD_IO;
|
||||
@ -58,21 +58,21 @@ gnc_session_scm_gui_cb_helper (const char *message, double percent)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_scm_load (GNCSession *session)
|
||||
gnc_session_scm_load (QofSession *session)
|
||||
{
|
||||
gnc_session_load (session, gnc_session_scm_gui_cb_helper);
|
||||
qof_session_load (session, gnc_session_scm_gui_cb_helper);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_scm_save (GNCSession *session)
|
||||
gnc_session_scm_save (QofSession *session)
|
||||
{
|
||||
gnc_session_save (session, gnc_session_scm_gui_cb_helper);
|
||||
qof_session_save (session, gnc_session_scm_gui_cb_helper);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_session_scm_export (GNCSession *tmp_session, GNCSession *real_session)
|
||||
gnc_session_scm_export (QofSession *tmp_session, QofSession *real_session)
|
||||
{
|
||||
return gnc_session_export(tmp_session, real_session,
|
||||
return qof_session_export(tmp_session, real_session,
|
||||
gnc_session_scm_gui_cb_helper);
|
||||
}
|
||||
|
||||
|
@ -42,11 +42,12 @@
|
||||
#include <libguile.h>
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
void gnc_session_scm_load (GNCSession *session);
|
||||
gboolean gnc_session_scm_export (GNCSession *tmp_session,
|
||||
GNCSession *real_session);
|
||||
void gnc_session_scm_save (GNCSession *session);
|
||||
void gnc_session_scm_set_callback (SCM percentage_cb);
|
||||
void gnc_session_scm_load (QofSession *session);
|
||||
gboolean gnc_session_scm_export (QofSession *tmp_session,
|
||||
QofSession *real_session);
|
||||
void gnc_session_scm_save (QofSession *session);
|
||||
void gnc_session_scm_set_callback (SCM percentage_cb);
|
||||
|
||||
#endif /* GNC_SESSION_SCM_H */
|
||||
|
@ -1,250 +1,5 @@
|
||||
/********************************************************************\
|
||||
* gnc-session.h -- session access (connection to backend) *
|
||||
* *
|
||||
* 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, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/** @file gnc-session.h
|
||||
* @brief Encapsulates a connection to a backednd (persistent store)
|
||||
*
|
||||
* FUNCTION:
|
||||
* Encapsulates a connection to a GnuCash backend. That is, it
|
||||
* manages the connection to a persistant data store; whereas
|
||||
* the backend is the thing that performs the actual datastore
|
||||
* access.
|
||||
*
|
||||
* This class provides several important services:
|
||||
*
|
||||
* 1) It resolves and loads the appropriate backend, based on
|
||||
* the URL.
|
||||
*
|
||||
* 2) It reports backend errors (e.g. network errors, storage
|
||||
* corruption errors) through a single, backend-independent
|
||||
* API.
|
||||
*
|
||||
* 3) It reports non-error events received from the backend.
|
||||
*
|
||||
* 4) It helps manage global dataset locks. For example, for the
|
||||
* file backend, the lock prevents multiple users from editing
|
||||
* the same file at the same time, thus avoiding lost data due
|
||||
* to race conditions. Thus, an open session implies that the
|
||||
* associated file is locked.
|
||||
*
|
||||
* 5) Misc utilities, such as a search path for the file to be
|
||||
* edited, and/or other URL resolution utilities. This should
|
||||
* simplify install & maintenance problems for naive users who
|
||||
* may not have a good grasp on what a file system is, or where
|
||||
* they want to keep their data files.
|
||||
*
|
||||
* 6) In the future, this class is probably a good place to manage
|
||||
* a portion of the user authentication process, and hold user
|
||||
* credentials/cookies/keys/tokens. This is because at the
|
||||
* coarsest level, authorization can happen at the datastore
|
||||
* level: i.e. does this user even have the authority to connect
|
||||
* to and open this datastore?
|
||||
*
|
||||
* A breif note about books & sessions:
|
||||
* A book encapsulates the datasets manipulated by GnuCash. A book
|
||||
* holds the actual data. By contrast, the session mediates the
|
||||
* connection between a book (the thing that lives in virtual memory
|
||||
* in the local process) and the datastore (the place where book
|
||||
* data lives permanently, e.g., file, database).
|
||||
*
|
||||
* In the current design, a session may hold multiple books. For
|
||||
* now, exactly what this means is somewhat vague, and code in
|
||||
* various places makes some implicit assumptions: first, only
|
||||
* one book is 'current' and open for editing. Next, its assumed
|
||||
* that all of the books in a session are related in some way.
|
||||
* i.e. that they are all earlier accounting periods of the
|
||||
* currently open book. In particular, the backends probably
|
||||
* make that assumption, in order to store the different accounting
|
||||
* periods in a clump so that one can be found, given another.
|
||||
*
|
||||
*
|
||||
* HISTORY:
|
||||
* Created by Linas Vepstas December 1998
|
||||
* Copyright (c) 1998, 1999, 2001, 2002 Linas Vepstas <linas@linas.org>
|
||||
* Copyright (c) 2000 Dave Peticolas
|
||||
*/
|
||||
#include "qofsession.h"
|
||||
|
||||
#ifndef GNC_SESSION_H
|
||||
#define GNC_SESSION_H
|
||||
|
||||
#include "Backend.h"
|
||||
#include "qofbook.h"
|
||||
|
||||
/* PROTOTYPES ******************************************************/
|
||||
|
||||
typedef struct gnc_session_struct GNCSession;
|
||||
|
||||
GNCSession * gnc_session_new (void);
|
||||
void gnc_session_destroy (GNCSession *session);
|
||||
GNCSession * gnc_get_current_session (void);
|
||||
void gnc_set_current_session (GNCSession *session);
|
||||
|
||||
/** The gnc_session_swap_data () method swaps the book of
|
||||
* the two given sessions. It is useful
|
||||
* for 'Save As' type functionality. */
|
||||
void gnc_session_swap_data (GNCSession *session_1, GNCSession *session_2);
|
||||
|
||||
/** The gnc_session_begin () method begins a new session.
|
||||
* It takes as an argument the book id. The book id must be a string
|
||||
* in the form of a URI/URL.
|
||||
* In the current implementation, the following URL's are supported
|
||||
* -- File URI of the form
|
||||
* "file:/home/somewhere/somedir/file.xac"
|
||||
* The path part must be a valid path. The file-part must be
|
||||
* a valid old-style-xacc or new-style-gnucash-format file. Paths
|
||||
* may be relative or absolute. If the path is relative; that is,
|
||||
* if the argument is "file:somefile.xac" then a sequence of
|
||||
* search paths are checked for a file of this name.
|
||||
*
|
||||
* -- Postgres URI of the form
|
||||
* "postgres://hostname.com/dbname"
|
||||
* See the src/backend/postgres subdirectory for more info.
|
||||
*
|
||||
* -- RPC URI of the form rpc://hostname.com/rpcserver.
|
||||
*
|
||||
* The 'ignore_lock' argument, if set to TRUE, will cause this routine
|
||||
* to ignore any global-datastore locks (e.g. file locks) that it finds.
|
||||
* If set to FALSE, then file/database-global locks will be tested and
|
||||
* obeyed.
|
||||
*
|
||||
* If the datastore exists, can be reached (e.g over the net),
|
||||
* connected to, opened and read, and a lock can be obtained then
|
||||
* a lock will be obtained. Note that multi-user datastores
|
||||
* (e.g. the SQL backend) typically will not need to get a global
|
||||
* lock, and thus, the user will not be locked out. That's the
|
||||
* whole point of 'multi-user'.
|
||||
*
|
||||
* If the file/database doesn't exist, and the create_if_nonexistent
|
||||
* flag is set to TRUE, then the database is created.
|
||||
*
|
||||
* If an error occurs, it will be pushed onto the session error
|
||||
* stack, and that is where it should be examined.
|
||||
*/
|
||||
void gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
gboolean ignore_lock, gboolean create_if_nonexistent);
|
||||
|
||||
|
||||
/**
|
||||
* The gnc_session_load() method causes the QofBook to be made ready to
|
||||
* to use with this URL/datastore. When the URL points at a file,
|
||||
* then this routine would load the data from the file. With remote
|
||||
* backends, e.g. network or SQL, this would load only enough data
|
||||
* to make the book actually usable; it would not cause *all* of the
|
||||
* data to be loaded.
|
||||
*/
|
||||
typedef void (*GNCPercentageFunc) (const char *message, double percent);
|
||||
void gnc_session_load (GNCSession *session,
|
||||
GNCPercentageFunc percentage_func);
|
||||
gboolean gnc_session_export (GNCSession *tmp_session,
|
||||
GNCSession *real_session,
|
||||
GNCPercentageFunc percentage_func);
|
||||
|
||||
/** The gnc_session_get_error() routine can be used to obtain the reason
|
||||
* for any failure. Calling this routine returns the current error.
|
||||
*
|
||||
* The gnc_session_pop_error() routine can be used to obtain the reason
|
||||
* for any failure. Calling this routine resets the error value.
|
||||
*
|
||||
* This routine allows an implementation of multiple error values,
|
||||
* e.g. in a stack, where this routine pops the top value. The current
|
||||
* implementation has a stack that is one-deep.
|
||||
*
|
||||
* See Backend.h for a listing of returned errors.
|
||||
*/
|
||||
GNCBackendError gnc_session_get_error (GNCSession *session);
|
||||
const char * gnc_session_get_error_message(GNCSession *session);
|
||||
GNCBackendError gnc_session_pop_error (GNCSession *session);
|
||||
|
||||
|
||||
QofBook * gnc_session_get_book (GNCSession *session);
|
||||
void gnc_session_set_book (GNCSession *session, QofBook *book);
|
||||
|
||||
/** The gnc_session_get_file_path() routine returns the fully-qualified file
|
||||
* path for the session. That is, if a relative or partial filename
|
||||
* was for the session, then it had to have been fully resolved to
|
||||
* open the session. This routine returns the result of this resolution.
|
||||
* The path is always guarenteed to reside in the local file system,
|
||||
* even if the session itself was opened as a URL. (currently, the
|
||||
* filepath is derived from the url by substituting commas for
|
||||
* slashes).
|
||||
*
|
||||
* The gnc_session_get_url() routine returns the url that was opened.
|
||||
* URL's for local files take the form of
|
||||
* file:/some/where/some/file.gml
|
||||
*/
|
||||
const char * gnc_session_get_file_path (GNCSession *session);
|
||||
const char * gnc_session_get_url (GNCSession *session);
|
||||
|
||||
/**
|
||||
* The gnc_session_not_saved() subroutine will return TRUE
|
||||
* if any data in the session hasn't been saved to long-term storage.
|
||||
*/
|
||||
gboolean gnc_session_not_saved(GNCSession *session);
|
||||
|
||||
/** FIXME: This isn't as thorough as we might want it to be... */
|
||||
gboolean gnc_session_save_may_clobber_data (GNCSession *session);
|
||||
|
||||
/** The gnc_session_save() method will commit all changes that have been
|
||||
* made to the session. For the file backend, this is nothing
|
||||
* more than a write to the file of the current AccountGroup & etc.
|
||||
* For the SQL backend, this is typically a no-op (since all data
|
||||
* has already been written out to the database.
|
||||
*
|
||||
* The gnc_session_end() method will release the session lock. For the
|
||||
* file backend, it will *not* save the account group to a file. Thus,
|
||||
* this method acts as an "abort" or "rollback" primitive. However,
|
||||
* for other backends, such as the sql backend, the data would have
|
||||
* been written out before this, and so this routines wouldn't
|
||||
* roll-back anything; it would just shut the connection.
|
||||
*/
|
||||
void gnc_session_save (GNCSession *session,
|
||||
GNCPercentageFunc percentage_func);
|
||||
void gnc_session_end (GNCSession *session);
|
||||
|
||||
/** The gnc_session_events_pending() method will return TRUE if the backend
|
||||
* has pending events which must be processed to bring the engine
|
||||
* up to date with the backend.
|
||||
*
|
||||
* The gnc_session_process_events() method will process any events indicated
|
||||
* by the gnc_session_events_pending() method. It returns TRUE if the
|
||||
* engine was modified while engine events were suspended.
|
||||
*/
|
||||
gboolean gnc_session_events_pending (GNCSession *session);
|
||||
gboolean gnc_session_process_events (GNCSession *session);
|
||||
|
||||
/** The xaccResolveFilePath() routine is a utility that will accept
|
||||
* a fragmentary filename as input, and resolve it into a fully
|
||||
* qualified path in the file system, i.e. a path that begins with
|
||||
* a leading slash. First, the current working directory is
|
||||
* searched for the file. Next, the directory $HOME/.gnucash/data,
|
||||
* and finally, a list of other (configurable) paths. If the file
|
||||
* is not found, then the path $HOME/.gnucash/data is used. If
|
||||
* $HOME is not defined, then the current working directory is
|
||||
* used.
|
||||
*/
|
||||
char * xaccResolveFilePath (const char * filefrag);
|
||||
char * xaccResolveURL (const char * pathfrag);
|
||||
|
||||
/** Run the RPC Server */
|
||||
void gnc_run_rpc_server (void);
|
||||
|
||||
#endif /* GNC_SESSION_H */
|
||||
#define gnc_get_current_session qof_session_get_current_session
|
||||
#define gnc_session_get_url qof_session_get_url
|
||||
|
@ -24,10 +24,10 @@
|
||||
"#include <glib.h>\n"
|
||||
"#include <guid.h>\n"
|
||||
"#include <Query.h>\n"
|
||||
"#include <Backend.h>\n"
|
||||
"#include <Group.h>\n"
|
||||
"#include <qofbackend.h>\n"
|
||||
"#include <qofbook.h>\n"
|
||||
"#include <gnc-session.h>\n"
|
||||
"#include <qofsession.h>\n"
|
||||
"#include <gnc-session-scm.h>\n"
|
||||
"#include <gnc-engine-util.h>\n"
|
||||
"#include <gnc-event.h>\n"
|
||||
@ -101,7 +101,7 @@
|
||||
(gw:wrap-as-wct ws '<gnc:AccountGroup*> "AccountGroup*" "const AccountGroup*")
|
||||
(gw:wrap-as-wct ws '<gnc:Book*> "QofBook*" "const QofBook*")
|
||||
(gw:wrap-as-wct ws '<gnc:Lot*> "GNCLot*" "const GNCLot*")
|
||||
(gw:wrap-as-wct ws '<gnc:Session*> "GNCSession*" "const GNCSession**")
|
||||
(gw:wrap-as-wct ws '<gnc:Session*> "QofSession*" "const QofSession**")
|
||||
(gw:wrap-as-wct ws '<gnc:Split*> "Split*" "const Split*")
|
||||
(gw:wrap-as-wct ws '<gnc:Transaction*> "Transaction*" "const Transaction*")
|
||||
(gw:wrap-as-wct ws '<gnc:commodity*> "gnc_commodity*" "const gnc_commodity*")
|
||||
@ -214,7 +214,7 @@
|
||||
(gw:enum-add-value! we "CREDITLINE" 'credit-line)
|
||||
#t)
|
||||
|
||||
(let ((we (gw:wrap-enumeration ws '<gnc:BackendError> "GNCBackendError")))
|
||||
(let ((we (gw:wrap-enumeration ws '<gnc:BackendError> "QofBackendError")))
|
||||
|
||||
(gw:enum-add-value! we "ERR_BACKEND_NO_ERR" 'no-err)
|
||||
(gw:enum-add-value! we "ERR_BACKEND_NO_BACKEND" 'no-backend)
|
||||
@ -1367,20 +1367,20 @@ when no longer needed.")
|
||||
to time t.")
|
||||
|
||||
;;===========
|
||||
;; GNCSession
|
||||
;; QofSession
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:session-new
|
||||
'<gnc:Session*>
|
||||
"gnc_session_new" '()
|
||||
"qof_session_new" '()
|
||||
"Create a new session.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:session-destroy
|
||||
'<gw:void>
|
||||
"gnc_session_destroy"
|
||||
"qof_session_destroy"
|
||||
'((<gnc:Session*> session))
|
||||
"Destroy the given session.")
|
||||
|
||||
@ -1388,7 +1388,7 @@ to time t.")
|
||||
ws
|
||||
'gnc:session-get-book
|
||||
'<gnc:Book*>
|
||||
"gnc_session_get_book"
|
||||
"qof_session_get_book"
|
||||
'((<gnc:Session*> session))
|
||||
"Get the book of the given session.")
|
||||
|
||||
@ -1396,7 +1396,7 @@ to time t.")
|
||||
ws
|
||||
'gnc:session-begin
|
||||
'<gw:void>
|
||||
"gnc_session_begin"
|
||||
"qof_session_begin"
|
||||
'((<gnc:Session*> session)
|
||||
((<gw:mchars> caller-owned const) id)
|
||||
(<gw:bool> ignore-lock?)
|
||||
@ -1441,7 +1441,7 @@ argument between 0 and 100 (inclusive).")
|
||||
ws
|
||||
'gnc:session-end
|
||||
'<gw:void>
|
||||
"gnc_session_end"
|
||||
"qof_session_end"
|
||||
'((<gnc:Session*> session))
|
||||
"Indicate you're finished with the session.")
|
||||
|
||||
@ -1481,7 +1481,7 @@ argument between 0 and 100 (inclusive).")
|
||||
ws
|
||||
'gnc:session-get-error
|
||||
'<gnc:BackendError>
|
||||
"gnc_session_get_error"
|
||||
"qof_session_get_error"
|
||||
'((<gnc:Session*> session))
|
||||
"Check for a pending error.")
|
||||
|
||||
@ -1489,7 +1489,7 @@ argument between 0 and 100 (inclusive).")
|
||||
ws
|
||||
'gnc:session-get-url
|
||||
'(<gw:mchars> callee-owned const)
|
||||
"gnc_session_get_url"
|
||||
"qof_session_get_url"
|
||||
'((<gnc:Session*> session))
|
||||
"Return the URL of the opened session.")
|
||||
|
||||
@ -1497,7 +1497,7 @@ argument between 0 and 100 (inclusive).")
|
||||
ws
|
||||
'gnc:session-pop-error
|
||||
'<gnc:BackendError>
|
||||
"gnc_session_pop_error"
|
||||
"qof_session_pop_error"
|
||||
'((<gnc:Session*> session))
|
||||
"Remove an error, if any, from the error stack.")
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************\
|
||||
* Backend.h -- private api for engine Backend *
|
||||
* qofbackend-p.h -- private api for data storage backend *
|
||||
* *
|
||||
* Copyright (c) 2000, 2001 Linas Vepstas <linas@linas.org> *
|
||||
* *
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* BackendP.h
|
||||
* qofbackend-p.h
|
||||
*
|
||||
* FUNCTION:
|
||||
* Pseudo-object defining how the engine can interact with different
|
||||
@ -42,10 +42,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "Backend.h"
|
||||
#include "gnc-session.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofquery.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
/*
|
||||
* The session_begin() routine gives the backend a second initialization
|
||||
@ -168,7 +168,7 @@
|
||||
* a stack) of all the errors that have occurred.
|
||||
*
|
||||
* For support of book partitioning, use special "Book" begin_edit()
|
||||
* and commit_edit() GNC_ID types.
|
||||
* and commit_edit() QOF_ID types.
|
||||
*
|
||||
* Call the book begin() at the begining of a book partitioning. A
|
||||
* 'partitioning' is the splitting off of a chunk of the current
|
||||
@ -223,36 +223,36 @@
|
||||
*
|
||||
*/
|
||||
|
||||
struct backend_s
|
||||
struct _QofBackend
|
||||
{
|
||||
void (*session_begin) (Backend *be,
|
||||
GNCSession *session,
|
||||
void (*session_begin) (QofBackend *be,
|
||||
QofSession *session,
|
||||
const char *book_id,
|
||||
gboolean ignore_lock,
|
||||
gboolean create_if_nonexistent);
|
||||
void (*session_end) (Backend *);
|
||||
void (*destroy_backend) (Backend *);
|
||||
void (*session_end) (QofBackend *);
|
||||
void (*destroy_backend) (QofBackend *);
|
||||
|
||||
void (*load) (Backend *, QofBook *);
|
||||
void (*load) (QofBackend *, QofBook *);
|
||||
|
||||
void (*begin) (Backend *, QofIdTypeConst, gpointer);
|
||||
void (*commit) (Backend *, QofIdTypeConst, gpointer);
|
||||
void (*rollback) (Backend *, QofIdTypeConst, gpointer);
|
||||
void (*begin) (QofBackend *, QofIdTypeConst, gpointer);
|
||||
void (*commit) (QofBackend *, QofIdTypeConst, gpointer);
|
||||
void (*rollback) (QofBackend *, QofIdTypeConst, gpointer);
|
||||
|
||||
gpointer (*compile_query) (Backend *, QofQuery *);
|
||||
void (*free_query) (Backend *, gpointer);
|
||||
void (*run_query) (Backend *, gpointer);
|
||||
gpointer (*compile_query) (QofBackend *, QofQuery *);
|
||||
void (*free_query) (QofBackend *, gpointer);
|
||||
void (*run_query) (QofBackend *, gpointer);
|
||||
|
||||
void (*sync) (Backend *, QofBook *);
|
||||
void (*sync) (QofBackend *, QofBook *);
|
||||
|
||||
gint64 (*counter) (Backend *, const char *counter_name);
|
||||
gint64 (*counter) (QofBackend *, const char *counter_name);
|
||||
|
||||
gboolean (*events_pending) (Backend *be);
|
||||
gboolean (*process_events) (Backend *be);
|
||||
gboolean (*events_pending) (QofBackend *be);
|
||||
gboolean (*process_events) (QofBackend *be);
|
||||
|
||||
GNCBePercentageFunc percentage;
|
||||
QofBePercentageFunc percentage;
|
||||
|
||||
GNCBackendError last_err;
|
||||
QofBackendError last_err;
|
||||
char * error_msg;
|
||||
|
||||
/* XXX price_lookup should be removed during the redesign
|
||||
@ -260,44 +260,37 @@ struct backend_s
|
||||
* the generic query mechanism.
|
||||
*
|
||||
* Note the correct signature for this call is
|
||||
* void (*price_lookup) (Backend *, GNCPriceLookup *);
|
||||
* void (*price_lookup) (QofBackend *, GNCPriceLookup *);
|
||||
* we use gpointer to avoid an unwanted include file dependency.
|
||||
*/
|
||||
void (*price_lookup) (Backend *, gpointer);
|
||||
void (*price_lookup) (QofBackend *, gpointer);
|
||||
|
||||
/* XXX Export should really _NOT_ be here, but is left here for now.
|
||||
* I'm not sure where this should be going to. It should be
|
||||
* removed ASAP.
|
||||
*/
|
||||
void (*export) (Backend *, QofBook *);
|
||||
void (*export) (QofBackend *, QofBook *);
|
||||
};
|
||||
|
||||
/*
|
||||
* The xaccBackendSetError() routine pushes an error code onto the error
|
||||
* The qof_backend_set_error() routine pushes an error code onto the error
|
||||
* stack. (FIXME: the stack is 1 deep in current implementation).
|
||||
*
|
||||
* The xaccBackendGetError() routine pops an error code off the error
|
||||
* The qof_backend_get_error() routine pops an error code off the error
|
||||
* stack.
|
||||
*
|
||||
* The xaccBackendSetMessage() assigns a string to the backend error
|
||||
* The qof_backend_set_message() assigns a string to the backend error
|
||||
* message.
|
||||
*
|
||||
* The xaccBackendGetMessage() pops the error message string from
|
||||
* The qof_backend_get_message() pops the error message string from
|
||||
* the Backend. This string should be freed with g_free().
|
||||
*/
|
||||
|
||||
void xaccBackendSetError (Backend *be, GNCBackendError err);
|
||||
GNCBackendError xaccBackendGetError (Backend *be);
|
||||
void xaccBackendSetMessage(Backend *be, const char *format, ...);
|
||||
char * xaccBackendGetMessage(Backend *be);
|
||||
void qof_backend_set_error (QofBackend *be, QofBackendError err);
|
||||
QofBackendError qof_backend_get_error (QofBackend *be);
|
||||
void qof_backend_set_message(QofBackend *be, const char *format, ...);
|
||||
char * qof_backend_get_message(QofBackend *be);
|
||||
|
||||
/*
|
||||
* The xaccQofBookGetBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with
|
||||
* this book.
|
||||
*/
|
||||
Backend * xaccQofBookGetBackend (QofBook *book);
|
||||
|
||||
void xaccInitBackend(Backend *be);
|
||||
void qof_backend_init(QofBackend *be);
|
||||
|
||||
#endif /* QOF_BACKEND_P_H */
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************\
|
||||
* Backend.c -- utility routines for dealing with the data backend *
|
||||
* qofbackend.c -- utility routines for dealing with the data backend *
|
||||
* Copyright (C) 2000 Linas Vepstas <linas@linas.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -25,8 +25,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbackend-p.h"
|
||||
|
||||
/* static short module = MOD_ENGINE; */
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccBackendSetError (Backend *be, GNCBackendError err)
|
||||
qof_backend_set_error (QofBackend *be, QofBackendError err)
|
||||
{
|
||||
if (!be) return;
|
||||
|
||||
@ -44,10 +44,10 @@ xaccBackendSetError (Backend *be, GNCBackendError err)
|
||||
be->last_err = err;
|
||||
}
|
||||
|
||||
GNCBackendError
|
||||
xaccBackendGetError (Backend *be)
|
||||
QofBackendError
|
||||
qof_backend_get_error (QofBackend *be)
|
||||
{
|
||||
GNCBackendError err;
|
||||
QofBackendError err;
|
||||
if (!be) return ERR_BACKEND_NO_BACKEND;
|
||||
|
||||
/* use 'stack-pop' semantics */
|
||||
@ -57,7 +57,8 @@ xaccBackendGetError (Backend *be)
|
||||
}
|
||||
|
||||
void
|
||||
xaccBackendSetMessage (Backend *be, const char *format, ...) {
|
||||
qof_backend_set_message (QofBackend *be, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char * buffer;
|
||||
|
||||
@ -75,7 +76,8 @@ xaccBackendSetMessage (Backend *be, const char *format, ...) {
|
||||
|
||||
/* This should always return a valid char * */
|
||||
char *
|
||||
xaccBackendGetMessage (Backend *be) {
|
||||
qof_backend_get_message (QofBackend *be)
|
||||
{
|
||||
char * msg;
|
||||
|
||||
if (!be) return g_strdup("ERR_BACKEND_NO_BACKEND");
|
||||
@ -86,7 +88,7 @@ xaccBackendGetMessage (Backend *be) {
|
||||
* NULL. This is necessary, because the Backends don't seem to
|
||||
* have a destroy_backend function to take care if freeing stuff
|
||||
* up. The calling function should free the copy.
|
||||
* Also, this is consistent with the xaccBackendGetError() popping.
|
||||
* Also, this is consistent with the qof_backend_get_error() popping.
|
||||
*/
|
||||
|
||||
msg = be->error_msg;
|
||||
@ -97,7 +99,7 @@ xaccBackendGetMessage (Backend *be) {
|
||||
/***********************************************************************/
|
||||
/* Get a clean backend */
|
||||
void
|
||||
xaccInitBackend(Backend *be)
|
||||
qof_backend_init(QofBackend *be)
|
||||
{
|
||||
be->session_begin = NULL;
|
||||
be->session_end = NULL;
|
@ -1,4 +1,5 @@
|
||||
/********************************************************************\
|
||||
* qofbackend.h: api for data storage backend *
|
||||
* 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 *
|
||||
@ -19,8 +20,8 @@
|
||||
\********************************************************************/
|
||||
/** @addtogroup Engine
|
||||
@{ */
|
||||
/** @file Backend.h
|
||||
@brief api for engine Backend
|
||||
/** @file qofbackend.h
|
||||
@brief api for data storage Backend
|
||||
*
|
||||
The 'backend' is a pseudo-object providing an interface between the
|
||||
engine and a persistant data store (e.g. a server, a database, or
|
||||
@ -31,13 +32,13 @@
|
||||
@author Copyright (C) 2000-2001 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
#ifndef XACC_BACKEND_H
|
||||
#define XACC_BACKEND_H
|
||||
#ifndef QOF_BACKEND_H
|
||||
#define QOF_BACKEND_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/** \brief The errors that can be reported to the GUI & other front-end users
|
||||
\warning If you modify GNCBackendError, please update src/scm/gnc.gwp */
|
||||
\warning If you modify QofBackendError, please update src/scm/gnc.gwp */
|
||||
typedef enum {
|
||||
ERR_BACKEND_NO_ERR = 0,
|
||||
ERR_BACKEND_NO_BACKEND, /**< Backend * pointer was null the err routine
|
||||
@ -87,7 +88,7 @@ typedef enum {
|
||||
ERR_RPC_BAD_VERSION, /**< RPC Version Mismatch */
|
||||
ERR_RPC_FAILED, /**< Operation failed */
|
||||
ERR_RPC_NOT_ADDED, /**< object not added */
|
||||
} GNCBackendError;
|
||||
} QofBackendError;
|
||||
|
||||
/** \brief Pseudo-object providing an interface between the
|
||||
* engine and a persistant data store (e.g. a server, a database,
|
||||
@ -97,10 +98,10 @@ typedef enum {
|
||||
* engine. The backend can, however, report errors to the GUI & other
|
||||
* front-end users.
|
||||
*/
|
||||
typedef struct backend_s Backend;
|
||||
typedef struct _QofBackend QofBackend;
|
||||
|
||||
/** \brief DOCUMENT ME! */
|
||||
typedef void (*GNCBePercentageFunc) (const char *message, double percent);
|
||||
typedef void (*QofBePercentageFunc) (const char *message, double percent);
|
||||
|
||||
#endif /* XACC_BACKEND_H */
|
||||
#endif /* QOF_BACKEND_H */
|
||||
/**@}*/
|
@ -30,8 +30,8 @@
|
||||
#ifndef QOF_BOOK_P_H
|
||||
#define QOF_BOOK_P_H
|
||||
|
||||
#include "Backend.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
|
||||
@ -72,7 +72,7 @@ struct _QofBook
|
||||
* not books. So the pointer below "really shouldn't be here",
|
||||
* except that it provides a nice convenience, avoiding a lookup
|
||||
* from the session. Better solutions welcome ... */
|
||||
Backend *backend;
|
||||
QofBackend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
@ -90,7 +90,7 @@ struct _QofBook
|
||||
void qof_book_set_guid(QofBook *book, GUID guid);
|
||||
void qof_book_set_schedxactions( QofBook *book, GList *newList );
|
||||
|
||||
void qof_book_set_backend (QofBook *book, Backend *be);
|
||||
void qof_book_set_backend (QofBook *book, QofBackend *be);
|
||||
|
||||
/* The qof_book_mark_saved() routine marks the book as having been
|
||||
* saved (to a file, to a database). Used by backends to mark the
|
||||
|
@ -40,11 +40,10 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "gnc-event.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-trace.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofid-p.h"
|
||||
@ -167,8 +166,8 @@ qof_book_get_entity_table (QofBook *book)
|
||||
return book->entity_table;
|
||||
}
|
||||
|
||||
Backend *
|
||||
xaccQofBookGetBackend (QofBook *book)
|
||||
QofBackend *
|
||||
qof_book_get_backend (QofBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return book->backend;
|
||||
@ -190,20 +189,13 @@ qof_book_set_guid (QofBook *book, GUID uid)
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_set_backend (QofBook *book, Backend *be)
|
||||
qof_book_set_backend (QofBook *book, QofBackend *be)
|
||||
{
|
||||
if (!book) return;
|
||||
ENTER ("book=%p be=%p", book, be);
|
||||
book->backend = be;
|
||||
}
|
||||
|
||||
gpointer qof_book_get_backend (QofBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return (gpointer)book->backend;
|
||||
}
|
||||
|
||||
|
||||
void qof_book_kvp_changed (QofBook *book)
|
||||
{
|
||||
if (!book) return;
|
||||
@ -241,7 +233,7 @@ qof_book_get_data (QofBook *book, const char *key)
|
||||
gint64
|
||||
qof_book_get_counter (QofBook *book, const char *counter_name)
|
||||
{
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
kvp_frame *kvp;
|
||||
kvp_value *value;
|
||||
gint64 counter;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include "qofid.h"
|
||||
#include "qofbackend.h"
|
||||
#include "kvp_frame.h"
|
||||
|
||||
/** @brief Encapsulates all the information about a dataset
|
||||
@ -75,7 +76,8 @@ void qof_book_set_data (QofBook *book, const char *key, gpointer data);
|
||||
gpointer qof_book_get_data (QofBook *book, const char *key);
|
||||
|
||||
/** DOCUMENT ME! */
|
||||
gpointer qof_book_get_backend (QofBook *book);
|
||||
QofBackend *qof_book_get_backend (QofBook *book);
|
||||
void qof_book_set_backend (QofBook *book, QofBackend *);
|
||||
|
||||
/** qof_book_not_saved() will return TRUE if any
|
||||
* data in the book hasn't been saved to long-term storage.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************\
|
||||
* gncObjectP.h -- the Core Object Registration/Lookup Interface *
|
||||
* qofobject-p.h -- the private Object Registration/Lookup Interface *
|
||||
* 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 *
|
||||
@ -20,17 +20,17 @@
|
||||
\********************************************************************/
|
||||
/** @addtogroup Engine
|
||||
@{ */
|
||||
/** @file gncObject.h
|
||||
/** @file qofobject-p.h
|
||||
* @breif the Core Object Registration/Lookup Private Interface
|
||||
*
|
||||
* @author Copyright (c) 2001,2002, Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#ifndef GNC_OBJECTP_H_
|
||||
#define GNC_OBJECTP_H_
|
||||
#ifndef QOF_OBJECT_P_H_
|
||||
#define QOF_OBJECT_P_H_
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
/* Initialize the object registration subsystem */
|
||||
void qof_object_initialize (void);
|
||||
@ -44,5 +44,5 @@ void qof_object_book_end (QofBook *book);
|
||||
gboolean qof_object_is_dirty (QofBook *book);
|
||||
void qof_object_mark_clean (QofBook *book);
|
||||
|
||||
#endif /* GNC_OBJECTP_H_ */
|
||||
#endif /* QOF_OBJECT_P_H_ */
|
||||
/** @} */
|
||||
|
@ -190,7 +190,7 @@ gboolean qof_object_register (const QofObject *object)
|
||||
g_return_val_if_fail (object_is_initialized, FALSE);
|
||||
|
||||
if (!object) return FALSE;
|
||||
g_return_val_if_fail (object->interface_version == GNC_OBJECT_VERSION, FALSE);
|
||||
g_return_val_if_fail (object->interface_version == QOF_OBJECT_VERSION, FALSE);
|
||||
|
||||
if (g_list_index (object_modules, (gpointer)object) == -1)
|
||||
object_modules = g_list_prepend (object_modules, (gpointer)object);
|
||||
|
@ -35,48 +35,48 @@
|
||||
* interface. Only object modules compiled against this version
|
||||
* of the interface will load properly
|
||||
*/
|
||||
#define GNC_OBJECT_VERSION 1
|
||||
#define QOF_OBJECT_VERSION 1
|
||||
|
||||
typedef struct _QofObject QofObject;
|
||||
typedef void (*QofForeachTypeCB) (QofObject *type, gpointer user_data);
|
||||
typedef void (*QofForeachBackendTypeCB) (QofIdTypeConst type,
|
||||
gpointer backend_data,
|
||||
gpointer user_data);
|
||||
gpointer backend_data,
|
||||
gpointer user_data);
|
||||
|
||||
/* This is the Object Object descriptor */
|
||||
struct _QofObject {
|
||||
gint interface_version; /* of this object interface */
|
||||
QofIdType name; /* the Object's GNC_ID */
|
||||
const char * type_label; /* "Printable" type-label string */
|
||||
gint interface_version; /* of this object interface */
|
||||
QofIdType name; /* the Object's QOF_ID */
|
||||
const char * type_label; /* "Printable" type-label string */
|
||||
|
||||
/* book_begin is called from within the Book routines to create
|
||||
* module-specific hooks in a book whenever a book is created.
|
||||
* book_end is called when the book is being closed, to clean
|
||||
* up (and free memory).
|
||||
*/
|
||||
void (*book_begin)(QofBook *);
|
||||
void (*book_end)(QofBook *);
|
||||
void (*book_begin)(QofBook *);
|
||||
void (*book_end)(QofBook *);
|
||||
|
||||
/* Determine if there are any dirty items in this book */
|
||||
gboolean (*is_dirty)(QofBook *);
|
||||
gboolean (*is_dirty)(QofBook *);
|
||||
|
||||
/* Mark this object's book clean (for after a load) */
|
||||
void (*mark_clean)(QofBook *);
|
||||
void (*mark_clean)(QofBook *);
|
||||
|
||||
/* foreach() is used to execute a callback over each object
|
||||
* stored in the particular book
|
||||
*/
|
||||
void (*foreach)(QofBook *, QofEntityForeachCB, gpointer);
|
||||
void (*foreach)(QofBook *, QofEntityForeachCB, gpointer);
|
||||
|
||||
/* Given a particular object, return a printable string */
|
||||
const char * (*printable)(gpointer obj);
|
||||
const char * (*printable)(gpointer obj);
|
||||
|
||||
};
|
||||
|
||||
void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data);
|
||||
|
||||
void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
|
||||
QofEntityForeachCB cb, gpointer user_data);
|
||||
QofEntityForeachCB cb, gpointer user_data);
|
||||
|
||||
const char * qof_object_printable (QofIdTypeConst type_name, gpointer obj);
|
||||
|
||||
@ -97,15 +97,15 @@ const QofObject * qof_object_lookup (QofIdTypeConst type_name);
|
||||
|
||||
/** Register and lookup backend-specific data for this particular object */
|
||||
gboolean qof_object_register_backend (QofIdTypeConst type_name,
|
||||
const char *backend_name,
|
||||
gpointer be_data);
|
||||
const char *backend_name,
|
||||
gpointer be_data);
|
||||
|
||||
gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
|
||||
const char *backend_name);
|
||||
const char *backend_name);
|
||||
|
||||
void qof_object_foreach_backend (const char *backend_name,
|
||||
QofForeachBackendTypeCB cb,
|
||||
gpointer user_data);
|
||||
QofForeachBackendTypeCB cb,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* QOF_OBJECT_H_ */
|
||||
/** @} */
|
||||
|
@ -30,8 +30,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gnc-engine-util.h"
|
||||
#include "BackendP.h"
|
||||
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
@ -506,7 +506,7 @@ static void compile_terms (QofQuery *q)
|
||||
/* Now compile the backend instances */
|
||||
for (node = q->books; node; node = node->next) {
|
||||
QofBook *book = node->data;
|
||||
Backend *be = book->backend;
|
||||
QofBackend *be = book->backend;
|
||||
|
||||
if (be && be->compile_query) {
|
||||
gpointer result = (be->compile_query)(be, q);
|
||||
@ -568,7 +568,7 @@ static gboolean
|
||||
query_free_compiled (gpointer key, gpointer value, gpointer not_used)
|
||||
{
|
||||
QofBook* book = key;
|
||||
Backend* be = book->backend;
|
||||
QofBackend* be = book->backend;
|
||||
|
||||
if (be && be->free_query)
|
||||
(be->free_query)(be, value);
|
||||
@ -690,7 +690,7 @@ GList * qof_query_run (QofQuery *q)
|
||||
/* For each book */
|
||||
for (node=q->books; node; node=node->next) {
|
||||
QofBook *book = node->data;
|
||||
Backend *be = book->backend;
|
||||
QofBackend *be = book->backend;
|
||||
|
||||
/* run the query in the backend */
|
||||
if (be) {
|
||||
@ -1260,7 +1260,8 @@ gboolean qof_query_sort_get_increasing (QofQuerySort *qs)
|
||||
return qs->increasing;
|
||||
}
|
||||
|
||||
static gboolean gncQueryTermEqual (QofQueryTerm_t qt1, QofQueryTerm_t qt2)
|
||||
static gboolean
|
||||
qof_query_term_equal (QofQueryTerm_t qt1, QofQueryTerm_t qt2)
|
||||
{
|
||||
if (qt1 == qt2) return TRUE;
|
||||
if (!qt1 || !qt2) return FALSE;
|
||||
@ -1270,7 +1271,8 @@ static gboolean gncQueryTermEqual (QofQueryTerm_t qt1, QofQueryTerm_t qt2)
|
||||
return qof_query_core_predicate_equal (qt1->pdata, qt2->pdata);
|
||||
}
|
||||
|
||||
static gboolean gncQuerySortEqual (QofQuerySort* qs1, QofQuerySort* qs2)
|
||||
static gboolean
|
||||
qof_query_sort_equal (QofQuerySort* qs1, QofQuerySort* qs2)
|
||||
{
|
||||
if (qs1 == qs2) return TRUE;
|
||||
if (!qs1 || !qs2) return FALSE;
|
||||
@ -1304,15 +1306,15 @@ gboolean qof_query_equal (QofQuery *q1, QofQuery *q2)
|
||||
if (g_list_length (and1) != g_list_length (and2)) return FALSE;
|
||||
|
||||
for ( ; and1; and1 = and1->next, and2 = and2->next)
|
||||
if (!gncQueryTermEqual (and1->data, and2->data))
|
||||
if (!qof_query_term_equal (and1->data, and2->data))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gncQuerySortEqual (&(q1->primary_sort), &(q2->primary_sort)))
|
||||
if (!qof_query_sort_equal (&(q1->primary_sort), &(q2->primary_sort)))
|
||||
return FALSE;
|
||||
if (!gncQuerySortEqual (&(q1->secondary_sort), &(q2->secondary_sort)))
|
||||
if (!qof_query_sort_equal (&(q1->secondary_sort), &(q2->secondary_sort)))
|
||||
return FALSE;
|
||||
if (!gncQuerySortEqual (&(q1->tertiary_sort), &(q2->tertiary_sort)))
|
||||
if (!qof_query_sort_equal (&(q1->tertiary_sort), &(q2->tertiary_sort)))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
@ -36,7 +36,7 @@ static short module = MOD_QUERY;
|
||||
typedef void (*QueryPredDataFree) (QofQueryPredData *pdata);
|
||||
|
||||
/* A function to copy a query's predicate data */
|
||||
typedef QofQueryPredData *(*QueryPredicateCopy) (QofQueryPredData *pdata);
|
||||
typedef QofQueryPredData *(*QueryPredicateCopyFunc) (QofQueryPredData *pdata);
|
||||
|
||||
/* A function to take the object, apply the get_fcn, and return
|
||||
* a printable string. Note that this QofAccessFunc function should
|
||||
@ -48,27 +48,27 @@ typedef char * (*QueryToString) (gpointer object, QofAccessFunc get_fcn);
|
||||
|
||||
/* A function to test for equality of predicate data */
|
||||
typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
|
||||
QofQueryPredData *p2);
|
||||
QofQueryPredData *p2);
|
||||
|
||||
/* This function registers a new Core Object with the QofQuery
|
||||
* subsystem. It maps the "core_name" object to the given
|
||||
* query_predicate, predicate_copy, and predicate_data_free functions.
|
||||
*/
|
||||
static void gncQueryRegisterCoreObject (char const *type_name,
|
||||
QofQueryPredicateFunc pred,
|
||||
QofCompareFunc comp,
|
||||
QueryPredicateCopy copy,
|
||||
QueryPredDataFree pd_free,
|
||||
QueryToString to_string,
|
||||
QueryPredicateEqual pred_equal);
|
||||
static void qof_query_register_core_object (char const *type_name,
|
||||
QofQueryPredicateFunc pred,
|
||||
QofCompareFunc comp,
|
||||
QueryPredicateCopyFunc copy,
|
||||
QueryPredDataFree pd_free,
|
||||
QueryToString to_string,
|
||||
QueryPredicateEqual pred_equal);
|
||||
/* An example:
|
||||
*
|
||||
* gncQueryRegisterCoreObject (QOF_QUERYCORE_STRING, string_match_predicate,
|
||||
* string_compare_fcn, string_free_pdata,
|
||||
* string_print_fcn, pred_equal_fcn);
|
||||
* qof_query_register_core_object (QOF_QUERYCORE_STRING, string_match_predicate,
|
||||
* string_compare_fcn, string_free_pdata,
|
||||
* string_print_fcn, pred_equal_fcn);
|
||||
*/
|
||||
|
||||
static QueryPredicateCopy gncQueryCoreGetCopy (char const *type);
|
||||
static QueryPredicateCopyFunc gncQueryCoreGetCopy (char const *type);
|
||||
static QueryPredDataFree gncQueryCoreGetPredFree (char const *type);
|
||||
|
||||
/* Core Type Predicate helpers */
|
||||
@ -114,23 +114,24 @@ static GHashTable *predEqualTable = NULL;
|
||||
|
||||
#define COMPARE_ERROR -3
|
||||
#define PREDICATE_ERROR -2
|
||||
|
||||
#define VERIFY_PDATA(str) { \
|
||||
g_return_if_fail (pd != NULL); \
|
||||
g_return_if_fail (pd->type_name == str || \
|
||||
!safe_strcmp (str, pd->type_name)); \
|
||||
g_return_if_fail (pd != NULL); \
|
||||
g_return_if_fail (pd->type_name == str || \
|
||||
!safe_strcmp (str, pd->type_name)); \
|
||||
}
|
||||
#define VERIFY_PDATA_R(str) { \
|
||||
g_return_val_if_fail (pd != NULL, NULL); \
|
||||
g_return_val_if_fail (pd->type_name == str || \
|
||||
!safe_strcmp (str, pd->type_name), \
|
||||
NULL); \
|
||||
g_return_val_if_fail (pd != NULL, NULL); \
|
||||
g_return_val_if_fail (pd->type_name == str || \
|
||||
!safe_strcmp (str, pd->type_name), \
|
||||
NULL); \
|
||||
}
|
||||
#define VERIFY_PREDICATE(str) { \
|
||||
g_return_val_if_fail (get_fcn != NULL, PREDICATE_ERROR); \
|
||||
g_return_val_if_fail (pd != NULL, PREDICATE_ERROR); \
|
||||
g_return_val_if_fail (pd->type_name == str || \
|
||||
!safe_strcmp (str, pd->type_name), \
|
||||
PREDICATE_ERROR); \
|
||||
g_return_val_if_fail (get_fcn != NULL, PREDICATE_ERROR); \
|
||||
g_return_val_if_fail (pd != NULL, PREDICATE_ERROR); \
|
||||
g_return_val_if_fail (pd->type_name == str || \
|
||||
!safe_strcmp (str, pd->type_name), \
|
||||
PREDICATE_ERROR); \
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
@ -139,7 +140,7 @@ static GHashTable *predEqualTable = NULL;
|
||||
/* QOF_QUERYCORE_STRING */
|
||||
|
||||
static int string_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
query_string_t pdata = (query_string_t) pd;
|
||||
const char *s;
|
||||
@ -177,7 +178,7 @@ static int string_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int string_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
const char *s1, *s2;
|
||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
||||
@ -212,7 +213,7 @@ static QofQueryPredData *string_copy_predicate (QofQueryPredData *pd)
|
||||
VERIFY_PDATA_R (query_string_type);
|
||||
|
||||
return qof_query_string_predicate (pd->how, pdata->matchstring, pdata->options,
|
||||
pdata->is_regex);
|
||||
pdata->is_regex);
|
||||
}
|
||||
|
||||
static gboolean string_predicate_equal (QofQueryPredData *p1,
|
||||
@ -227,8 +228,8 @@ QofQueryPredData *p2)
|
||||
}
|
||||
|
||||
QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
|
||||
char *str, QofStringMatch options,
|
||||
gboolean is_regex)
|
||||
char *str, QofStringMatch options,
|
||||
gboolean is_regex)
|
||||
{
|
||||
query_string_t pdata;
|
||||
|
||||
@ -285,7 +286,7 @@ static int date_compare (Timespec ta, Timespec tb, QofDateMatch options)
|
||||
}
|
||||
|
||||
static int date_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
query_date_t pdata = (query_date_t)pd;
|
||||
Timespec objtime;
|
||||
@ -316,7 +317,7 @@ static int date_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int date_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
Timespec ta, tb;
|
||||
|
||||
@ -358,7 +359,7 @@ static gboolean date_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2
|
||||
|
||||
QofQueryPredData *
|
||||
qof_query_date_predicate (QofQueryCompare how,
|
||||
QofDateMatch options, Timespec date)
|
||||
QofDateMatch options, Timespec date)
|
||||
{
|
||||
query_date_t pdata;
|
||||
|
||||
@ -383,7 +384,7 @@ static char * date_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_NUMERIC */
|
||||
|
||||
static int numeric_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData* pd)
|
||||
QofQueryPredData* pd)
|
||||
{
|
||||
query_numeric_t pdata = (query_numeric_t)pd;
|
||||
gnc_numeric obj_val;
|
||||
@ -408,10 +409,10 @@ static int numeric_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
gnc_numeric cmp_val = gnc_numeric_create (1, 10000);
|
||||
compare =
|
||||
(gnc_numeric_compare (gnc_numeric_abs
|
||||
(gnc_numeric_sub (gnc_numeric_abs (obj_val),
|
||||
gnc_numeric_abs (pdata->amount),
|
||||
100000, GNC_RND_ROUND)),
|
||||
cmp_val) < 0);
|
||||
(gnc_numeric_sub (gnc_numeric_abs (obj_val),
|
||||
gnc_numeric_abs (pdata->amount),
|
||||
100000, GNC_RND_ROUND)),
|
||||
cmp_val) < 0);
|
||||
} else
|
||||
compare = gnc_numeric_compare (gnc_numeric_abs (obj_val), pdata->amount);
|
||||
|
||||
@ -435,7 +436,7 @@ static int numeric_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int numeric_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
gnc_numeric va, vb;
|
||||
|
||||
@ -474,8 +475,8 @@ numeric_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
|
||||
QofQueryPredData *
|
||||
qof_query_numeric_predicate (QofQueryCompare how,
|
||||
QofNumericMatch options,
|
||||
gnc_numeric value)
|
||||
QofNumericMatch options,
|
||||
gnc_numeric value)
|
||||
{
|
||||
query_numeric_t pdata;
|
||||
pdata = g_new0 (query_numeric_def, 1);
|
||||
@ -503,7 +504,7 @@ static char * debcred_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_GUID */
|
||||
|
||||
static int guid_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
query_guid_t pdata = (query_guid_t)pd;
|
||||
GList *node, *o_list;
|
||||
@ -523,9 +524,9 @@ static int guid_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
|
||||
/* See if this GUID matches the object's guid */
|
||||
for (o_list = object; o_list; o_list = o_list->next) {
|
||||
guid = ((query_guid_getter)get_fcn) (o_list->data);
|
||||
if (guid_equal (node->data, guid))
|
||||
break;
|
||||
guid = ((query_guid_getter)get_fcn) (o_list->data);
|
||||
if (guid_equal (node->data, guid))
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -533,7 +534,7 @@ static int guid_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
* a match. Therefore break out now, the match has failed.
|
||||
*/
|
||||
if (o_list == NULL)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -558,13 +559,13 @@ static int guid_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
|
||||
/* Search the predicate data for a match */
|
||||
for (node2 = pdata->guids; node2; node2 = node2->next) {
|
||||
if (guid_equal (node->data, node2->data))
|
||||
break;
|
||||
if (guid_equal (node->data, node2->data))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check to see if we found a match. If so, break now */
|
||||
if (node2 != NULL)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
g_list_free(o_list);
|
||||
@ -584,7 +585,7 @@ static int guid_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
guid = ((query_guid_getter)get_fcn) (object);
|
||||
for (node = pdata->guids; node; node = node->next) {
|
||||
if (guid_equal (node->data, guid))
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -663,7 +664,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guids)
|
||||
/* QOF_QUERYCORE_INT32 */
|
||||
|
||||
static int int32_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
gint32 val;
|
||||
query_int32_t pdata = (query_int32_t)pd;
|
||||
@ -692,7 +693,7 @@ static int int32_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int int32_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
gint32 v1, v2;
|
||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
||||
@ -750,7 +751,7 @@ static char * int32_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_INT64 */
|
||||
|
||||
static int int64_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
gint64 val;
|
||||
query_int64_t pdata = (query_int64_t)pd;
|
||||
@ -779,7 +780,7 @@ static int int64_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int int64_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
gint64 v1, v2;
|
||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
||||
@ -837,7 +838,7 @@ static char * int64_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_DOUBLE */
|
||||
|
||||
static int double_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
double val;
|
||||
query_double_t pdata = (query_double_t)pd;
|
||||
@ -866,7 +867,7 @@ static int double_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int double_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
double v1, v2;
|
||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
||||
@ -923,7 +924,7 @@ static char * double_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_BOOLEAN */
|
||||
|
||||
static int boolean_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
gboolean val;
|
||||
query_boolean_t pdata = (query_boolean_t)pd;
|
||||
@ -944,7 +945,7 @@ static int boolean_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int boolean_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
gboolean va, vb;
|
||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
||||
@ -1002,7 +1003,7 @@ static char * boolean_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_CHAR */
|
||||
|
||||
static int char_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
char c;
|
||||
query_char_t pdata = (query_char_t)pd;
|
||||
@ -1025,7 +1026,7 @@ static int char_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
}
|
||||
|
||||
static int char_compare_func (gpointer a, gpointer b, gint options,
|
||||
QofAccessFunc get_fcn)
|
||||
QofAccessFunc get_fcn)
|
||||
{
|
||||
char va, vb;
|
||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
||||
@ -1083,7 +1084,7 @@ static char * char_to_string (gpointer object, QofAccessFunc get)
|
||||
/* QOF_QUERYCORE_KVP */
|
||||
|
||||
static int kvp_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||
QofQueryPredData *pd)
|
||||
QofQueryPredData *pd)
|
||||
{
|
||||
int compare;
|
||||
kvp_frame *kvp;
|
||||
@ -1170,7 +1171,7 @@ kvp_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
|
||||
|
||||
QofQueryPredData *
|
||||
qof_query_kvp_predicate (QofQueryCompare how,
|
||||
GSList *path, const kvp_value *value)
|
||||
GSList *path, const kvp_value *value)
|
||||
{
|
||||
query_kvp_t pdata;
|
||||
GSList *node;
|
||||
@ -1197,7 +1198,7 @@ static void init_tables (void)
|
||||
char const *name;
|
||||
QofQueryPredicateFunc pred;
|
||||
QofCompareFunc comp;
|
||||
QueryPredicateCopy copy;
|
||||
QueryPredicateCopyFunc copy;
|
||||
QueryPredDataFree pd_free;
|
||||
QueryToString toString;
|
||||
QueryPredicateEqual pred_equal;
|
||||
@ -1238,19 +1239,19 @@ static void init_tables (void)
|
||||
|
||||
/* Register the known data types */
|
||||
for (i = 0; i < (sizeof(knownTypes)/sizeof(*knownTypes)); i++) {
|
||||
gncQueryRegisterCoreObject (knownTypes[i].name,
|
||||
knownTypes[i].pred,
|
||||
knownTypes[i].comp,
|
||||
knownTypes[i].copy,
|
||||
knownTypes[i].pd_free,
|
||||
knownTypes[i].toString,
|
||||
knownTypes[i].pred_equal);
|
||||
qof_query_register_core_object (knownTypes[i].name,
|
||||
knownTypes[i].pred,
|
||||
knownTypes[i].comp,
|
||||
knownTypes[i].copy,
|
||||
knownTypes[i].pd_free,
|
||||
knownTypes[i].toString,
|
||||
knownTypes[i].pred_equal);
|
||||
}
|
||||
}
|
||||
|
||||
static QueryPredicateCopy gncQueryCoreGetCopy (char const *type)
|
||||
static QueryPredicateCopyFunc gncQueryCoreGetCopy (char const *type)
|
||||
{
|
||||
QueryPredicateCopy rc;
|
||||
QueryPredicateCopyFunc rc;
|
||||
g_return_val_if_fail (type, NULL);
|
||||
rc = g_hash_table_lookup (copyTable, type);
|
||||
return rc;
|
||||
@ -1262,13 +1263,14 @@ static QueryPredDataFree gncQueryCoreGetPredFree (char const *type)
|
||||
return g_hash_table_lookup (freeTable, type);
|
||||
}
|
||||
|
||||
static void gncQueryRegisterCoreObject (char const *core_name,
|
||||
QofQueryPredicateFunc pred,
|
||||
QofCompareFunc comp,
|
||||
QueryPredicateCopy copy,
|
||||
QueryPredDataFree pd_free,
|
||||
QueryToString toString,
|
||||
QueryPredicateEqual pred_equal)
|
||||
static void
|
||||
qof_query_register_core_object (char const *core_name,
|
||||
QofQueryPredicateFunc pred,
|
||||
QofCompareFunc comp,
|
||||
QueryPredicateCopyFunc copy,
|
||||
QueryPredDataFree pd_free,
|
||||
QueryToString toString,
|
||||
QueryPredicateEqual pred_equal)
|
||||
{
|
||||
g_return_if_fail (core_name);
|
||||
g_return_if_fail (*core_name != '\0');
|
||||
@ -1354,7 +1356,7 @@ qof_query_core_predicate_free (QofQueryPredData *pdata)
|
||||
QofQueryPredData *
|
||||
qof_query_core_predicate_copy (QofQueryPredData *pdata)
|
||||
{
|
||||
QueryPredicateCopy copy;
|
||||
QueryPredicateCopyFunc copy;
|
||||
|
||||
g_return_val_if_fail (pdata, NULL);
|
||||
g_return_val_if_fail (pdata->type_name, NULL);
|
||||
@ -1363,8 +1365,9 @@ qof_query_core_predicate_copy (QofQueryPredData *pdata)
|
||||
return (copy (pdata));
|
||||
}
|
||||
|
||||
char * qof_query_core_to_string (char const *type, gpointer object,
|
||||
QofAccessFunc get)
|
||||
char *
|
||||
qof_query_core_to_string (char const *type, gpointer object,
|
||||
QofAccessFunc get)
|
||||
{
|
||||
QueryToString toString;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************\
|
||||
* gnc-session-p.h -- private functions for gnc sessions. *
|
||||
* qofsession-p.h -- private functions for QOF sessions. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -26,13 +26,13 @@
|
||||
* Copyright (c) 1998-2003 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
#ifndef GNC_SESSION_P_H
|
||||
#define GNC_SESSION_P_H
|
||||
#ifndef QOF_SESSION_P_H
|
||||
#define QOF_SESSION_P_H
|
||||
|
||||
#include "gnc-session.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
struct gnc_session_struct
|
||||
struct _QofSession
|
||||
{
|
||||
/* A book holds pointers to the various types of datasets used
|
||||
* by GnuCash. A session may have open multiple books. */
|
||||
@ -50,7 +50,7 @@ struct gnc_session_struct
|
||||
* and the backends should all be using (or making it look like)
|
||||
* there is only one stack.
|
||||
*/
|
||||
GNCBackendError last_err;
|
||||
QofBackendError last_err;
|
||||
char *error_message;
|
||||
|
||||
char *fullpath;
|
||||
@ -59,25 +59,25 @@ struct gnc_session_struct
|
||||
/* ---------------------------------------------------- */
|
||||
/* Pointer to the backend that is actually used to move data
|
||||
* between the persistant store and the local engine. */
|
||||
Backend *backend;
|
||||
QofBackend *backend;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* gnc_session_set_book() has funny semantics.
|
||||
* qof_session_set_book() has funny semantics.
|
||||
* The session stores a list of books. If you call this routine
|
||||
* with a book that is closed, then its added to the list. If
|
||||
* you call this routine with a book that is open, then the
|
||||
* old list is blown away.
|
||||
*/
|
||||
void gnc_session_set_book (GNCSession *session, QofBook *book);
|
||||
void qof_session_set_book (QofSession *session, QofBook *book);
|
||||
|
||||
Backend * gnc_session_get_backend (GNCSession *session);
|
||||
QofBackend * qof_session_get_backend (QofSession *session);
|
||||
|
||||
void gnc_session_push_error (GNCSession *session, GNCBackendError err,
|
||||
void qof_session_push_error (QofSession *session, QofBackendError err,
|
||||
const char *message);
|
||||
|
||||
Backend* gncBackendInit_file(const char *book_id, void *data);
|
||||
QofBackend* gncBackendInit_file(const char *book_id, void *data);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************\
|
||||
* gnc-sesssion.c -- session access (connection to backend) *
|
||||
* qofsesssion.c -- session access (connection to backend) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -21,10 +21,10 @@
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* gnc-session.c
|
||||
* qofsession.c
|
||||
*
|
||||
* FUNCTION:
|
||||
* Encapsulate a connection to a GnuCash backend.
|
||||
* Encapsulate a connection to a storage backend.
|
||||
*
|
||||
* HISTORY:
|
||||
* Created by Linas Vepstas December 1998
|
||||
@ -32,6 +32,13 @@
|
||||
* Copyright (c) 2000 Dave Peticolas
|
||||
*/
|
||||
|
||||
/* TODO: XXX we should probably move this resolve function to the
|
||||
* file backend. I think the idea would be to open the backend
|
||||
* and then ask it if it can contact it's storage media (disk,
|
||||
* network, server, etc.) and abort if it can't. Mal-formed
|
||||
* file URL's would be handled the same way!
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
@ -43,15 +50,15 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "gnc-event.h"
|
||||
#include "gnc-session.h"
|
||||
#include "gnc-session-p.h"
|
||||
#include "gnc-trace.h"
|
||||
#include "qofbackend-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofsession.h"
|
||||
#include "qofsession-p.h"
|
||||
|
||||
/* Some gnucash-specific code */
|
||||
#ifdef GNUCASH
|
||||
#include "gnc-module.h"
|
||||
#include "TransLog.h"
|
||||
@ -61,16 +68,16 @@
|
||||
#define xaccLogDisable()
|
||||
#endif /* GNUCASH */
|
||||
|
||||
static GNCSession * current_session = NULL;
|
||||
static QofSession * current_session = NULL;
|
||||
static short module = MOD_IO;
|
||||
|
||||
/* ====================================================================== */
|
||||
/* error handling routines */
|
||||
|
||||
static void
|
||||
gnc_session_clear_error (GNCSession *session)
|
||||
qof_session_clear_error (QofSession *session)
|
||||
{
|
||||
GNCBackendError err;
|
||||
QofBackendError err;
|
||||
|
||||
session->last_err = ERR_BACKEND_NO_ERR;
|
||||
g_free(session->error_message);
|
||||
@ -81,13 +88,13 @@ gnc_session_clear_error (GNCSession *session)
|
||||
{
|
||||
do
|
||||
{
|
||||
err = xaccBackendGetError (session->backend);
|
||||
err = qof_backend_get_error (session->backend);
|
||||
} while (ERR_BACKEND_NO_ERR != err);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_push_error (GNCSession *session, GNCBackendError err,
|
||||
qof_session_push_error (QofSession *session, QofBackendError err,
|
||||
const char *message)
|
||||
{
|
||||
if (!session) return;
|
||||
@ -98,10 +105,10 @@ gnc_session_push_error (GNCSession *session, GNCBackendError err,
|
||||
session->error_message = g_strdup (message);
|
||||
}
|
||||
|
||||
GNCBackendError
|
||||
gnc_session_get_error (GNCSession * session)
|
||||
QofBackendError
|
||||
qof_session_get_error (QofSession * session)
|
||||
{
|
||||
GNCBackendError err;
|
||||
QofBackendError err;
|
||||
|
||||
if (!session) return ERR_BACKEND_NO_BACKEND;
|
||||
|
||||
@ -114,19 +121,19 @@ gnc_session_get_error (GNCSession * session)
|
||||
/* maybe we should return a no-backend error ??? */
|
||||
if (! session->backend) return ERR_BACKEND_NO_ERR;
|
||||
|
||||
err = xaccBackendGetError (session->backend);
|
||||
err = qof_backend_get_error (session->backend);
|
||||
session->last_err = err;
|
||||
return err;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_default_error_message(GNCBackendError err)
|
||||
get_default_error_message(QofBackendError err)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_session_get_error_message(GNCSession *session)
|
||||
qof_session_get_error_message(QofSession *session)
|
||||
{
|
||||
if(!session) return "";
|
||||
if(!session->error_message)
|
||||
@ -134,15 +141,15 @@ gnc_session_get_error_message(GNCSession *session)
|
||||
return session->error_message;
|
||||
}
|
||||
|
||||
GNCBackendError
|
||||
gnc_session_pop_error (GNCSession * session)
|
||||
QofBackendError
|
||||
qof_session_pop_error (QofSession * session)
|
||||
{
|
||||
GNCBackendError err;
|
||||
QofBackendError err;
|
||||
|
||||
if (!session) return ERR_BACKEND_NO_BACKEND;
|
||||
|
||||
err = gnc_session_get_error(session);
|
||||
gnc_session_clear_error(session);
|
||||
err = qof_session_get_error(session);
|
||||
qof_session_clear_error(session);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -150,7 +157,7 @@ gnc_session_pop_error (GNCSession * session)
|
||||
/* ====================================================================== */
|
||||
|
||||
static void
|
||||
gnc_session_init (GNCSession *session)
|
||||
qof_session_init (QofSession *session)
|
||||
{
|
||||
if (!session) return;
|
||||
|
||||
@ -160,24 +167,24 @@ gnc_session_init (GNCSession *session)
|
||||
session->logpath = NULL;
|
||||
session->backend = NULL;
|
||||
|
||||
gnc_session_clear_error (session);
|
||||
qof_session_clear_error (session);
|
||||
}
|
||||
|
||||
GNCSession *
|
||||
gnc_session_new (void)
|
||||
QofSession *
|
||||
qof_session_new (void)
|
||||
{
|
||||
GNCSession *session = g_new0(GNCSession, 1);
|
||||
gnc_session_init(session);
|
||||
QofSession *session = g_new0(QofSession, 1);
|
||||
qof_session_init(session);
|
||||
return session;
|
||||
}
|
||||
|
||||
GNCSession *
|
||||
gnc_get_current_session (void)
|
||||
QofSession *
|
||||
qof_session_get_current_session (void)
|
||||
{
|
||||
if (!current_session)
|
||||
{
|
||||
gnc_engine_suspend_events ();
|
||||
current_session = gnc_session_new ();
|
||||
current_session = qof_session_new ();
|
||||
gnc_engine_resume_events ();
|
||||
}
|
||||
|
||||
@ -185,13 +192,13 @@ gnc_get_current_session (void)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_set_current_session (GNCSession *session)
|
||||
qof_session_set_current_session (QofSession *session)
|
||||
{
|
||||
current_session = session;
|
||||
}
|
||||
|
||||
QofBook *
|
||||
gnc_session_get_book (GNCSession *session)
|
||||
qof_session_get_book (QofSession *session)
|
||||
{
|
||||
GList *node;
|
||||
if (!session) return NULL;
|
||||
@ -205,7 +212,7 @@ gnc_session_get_book (GNCSession *session)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_set_book (GNCSession *session, QofBook *addbook)
|
||||
qof_session_set_book (QofSession *session, QofBook *addbook)
|
||||
{
|
||||
GList *node;
|
||||
if (!session) return;
|
||||
@ -236,22 +243,22 @@ gnc_session_set_book (GNCSession *session, QofBook *addbook)
|
||||
LEAVE (" ");
|
||||
}
|
||||
|
||||
Backend *
|
||||
gnc_session_get_backend (GNCSession *session)
|
||||
QofBackend *
|
||||
qof_session_get_backend (QofSession *session)
|
||||
{
|
||||
if (!session) return NULL;
|
||||
return session->backend;
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_session_get_file_path (GNCSession *session)
|
||||
qof_session_get_file_path (QofSession *session)
|
||||
{
|
||||
if (!session) return NULL;
|
||||
return session->fullpath;
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_session_get_url (GNCSession *session)
|
||||
qof_session_get_url (QofSession *session)
|
||||
{
|
||||
if (!session) return NULL;
|
||||
return session->book_id;
|
||||
@ -260,7 +267,7 @@ gnc_session_get_url (GNCSession *session)
|
||||
/* ====================================================================== */
|
||||
|
||||
static void
|
||||
gnc_session_int_backend_load_error(GNCSession *session,
|
||||
qof_session_int_backend_load_error(QofSession *session,
|
||||
char *message, char *dll_err)
|
||||
{
|
||||
PWARN (message, dll_err ? dll_err : "");
|
||||
@ -274,7 +281,7 @@ gnc_session_int_backend_load_error(GNCSession *session,
|
||||
g_free(session->book_id);
|
||||
session->book_id = NULL;
|
||||
|
||||
gnc_session_push_error (session, ERR_BACKEND_NO_BACKEND, NULL);
|
||||
qof_session_push_error (session, ERR_BACKEND_NO_BACKEND, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -284,10 +291,10 @@ gnc_session_int_backend_load_error(GNCSession *session,
|
||||
* use traditional dlopen calls.
|
||||
*/
|
||||
static void
|
||||
gnc_session_load_backend(GNCSession * session, char * backend_name)
|
||||
qof_session_load_backend(QofSession * session, char * backend_name)
|
||||
{
|
||||
GNCModule mod = 0;
|
||||
Backend *(* be_new_func)(void);
|
||||
QofBackend *(* be_new_func)(void);
|
||||
char * mod_name = g_strdup_printf("gnucash/backend/%s", backend_name);
|
||||
|
||||
/* FIXME : reinstate better error messages with gnc_module errors */
|
||||
@ -315,13 +322,13 @@ gnc_session_load_backend(GNCSession * session, char * backend_name)
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_session_int_backend_load_error(session, " can't find backend_new ",
|
||||
qof_session_int_backend_load_error(session, " can't find backend_new ",
|
||||
"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_session_int_backend_load_error(session,
|
||||
qof_session_int_backend_load_error(session,
|
||||
" failed to load '%s' backend",
|
||||
backend_name);
|
||||
}
|
||||
@ -333,7 +340,7 @@ gnc_session_load_backend(GNCSession * session, char * backend_name)
|
||||
#else /* GNUCASH */
|
||||
|
||||
static void
|
||||
gnc_session_load_backend(GNCSession * session, char * backend_name)
|
||||
qof_session_load_backend(QofSession * session, char * backend_name)
|
||||
{
|
||||
ENTER (" ");
|
||||
LEAVE (" ");
|
||||
@ -343,14 +350,14 @@ gnc_session_load_backend(GNCSession * session, char * backend_name)
|
||||
/* ====================================================================== */
|
||||
|
||||
static void
|
||||
gnc_session_destroy_backend (GNCSession *session)
|
||||
qof_session_destroy_backend (QofSession *session)
|
||||
{
|
||||
g_return_if_fail (session);
|
||||
|
||||
if (session->backend)
|
||||
{
|
||||
/* clear any error message */
|
||||
char * msg = xaccBackendGetMessage (session->backend);
|
||||
char * msg = qof_backend_get_message (session->backend);
|
||||
g_free (msg);
|
||||
|
||||
/* Then destroy the backend */
|
||||
@ -368,7 +375,7 @@ gnc_session_destroy_backend (GNCSession *session)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
qof_session_begin (QofSession *session, const char * book_id,
|
||||
gboolean ignore_lock, gboolean create_if_nonexistent)
|
||||
{
|
||||
if (!session) return;
|
||||
@ -378,12 +385,12 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
book_id ? book_id : "(null)");
|
||||
|
||||
/* clear the error condition of previous errors */
|
||||
gnc_session_clear_error (session);
|
||||
qof_session_clear_error (session);
|
||||
|
||||
/* check to see if this session is already open */
|
||||
if (gnc_session_get_url(session))
|
||||
if (qof_session_get_url(session))
|
||||
{
|
||||
gnc_session_push_error (session, ERR_BACKEND_LOCKED, NULL);
|
||||
qof_session_push_error (session, ERR_BACKEND_LOCKED, NULL);
|
||||
LEAVE("push error book is already open ");
|
||||
return;
|
||||
}
|
||||
@ -391,18 +398,24 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
/* seriously invalid */
|
||||
if (!book_id)
|
||||
{
|
||||
gnc_session_push_error (session, ERR_BACKEND_BAD_URL, NULL);
|
||||
qof_session_push_error (session, ERR_BACKEND_BAD_URL, NULL);
|
||||
LEAVE("push error missing book_id");
|
||||
return;
|
||||
}
|
||||
/* Store the sessionid URL */
|
||||
session->book_id = g_strdup (book_id);
|
||||
|
||||
/* XXX we should probably move this resolve function to the
|
||||
* file backend. I think the idea would be to open the backend
|
||||
* and then ask it if it can contact it's storage media (disk,
|
||||
* network, server, etc.) and abort if it can't. Mal-formed
|
||||
* file URL's would be handled the same way!
|
||||
*/
|
||||
/* ResolveURL tries to find the file in the file system. */
|
||||
session->fullpath = xaccResolveURL(book_id);
|
||||
if (!session->fullpath)
|
||||
{
|
||||
gnc_session_push_error (session, ERR_FILEIO_FILE_NOT_FOUND, NULL);
|
||||
qof_session_push_error (session, ERR_FILEIO_FILE_NOT_FOUND, NULL);
|
||||
LEAVE("push error: can't resolve file path");
|
||||
return;
|
||||
}
|
||||
@ -412,13 +425,13 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
PINFO ("logpath=%s", session->logpath ? session->logpath : "(null)");
|
||||
|
||||
/* destroy the old backend */
|
||||
gnc_session_destroy_backend(session);
|
||||
qof_session_destroy_backend(session);
|
||||
|
||||
/* check to see if this is a type we know how to handle */
|
||||
if (!g_strncasecmp(book_id, "file:", 5) ||
|
||||
*session->fullpath == '/')
|
||||
{
|
||||
gnc_session_load_backend(session, "file" );
|
||||
qof_session_load_backend(session, "file" );
|
||||
}
|
||||
#if 0
|
||||
/* load different backend based on URL. We should probably
|
||||
@ -432,11 +445,11 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
#endif
|
||||
else if (!g_strncasecmp(book_id, "postgres://", 11))
|
||||
{
|
||||
gnc_session_load_backend(session, "postgres");
|
||||
qof_session_load_backend(session, "postgres");
|
||||
}
|
||||
else if (!g_strncasecmp(book_id, "rpc://", 6))
|
||||
{
|
||||
gnc_session_load_backend(session, "rpc");
|
||||
qof_session_load_backend(session, "rpc");
|
||||
}
|
||||
|
||||
/* if there's a begin method, call that. */
|
||||
@ -446,11 +459,11 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
char * msg;
|
||||
|
||||
(session->backend->session_begin)(session->backend, session,
|
||||
gnc_session_get_url(session), ignore_lock,
|
||||
qof_session_get_url(session), ignore_lock,
|
||||
create_if_nonexistent);
|
||||
PINFO("Done running session_begin on backend");
|
||||
err = xaccBackendGetError(session->backend);
|
||||
msg = xaccBackendGetMessage(session->backend);
|
||||
err = qof_backend_get_error(session->backend);
|
||||
msg = qof_backend_get_message(session->backend);
|
||||
if (err != ERR_BACKEND_NO_ERR)
|
||||
{
|
||||
g_free(session->fullpath);
|
||||
@ -459,7 +472,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
session->logpath = NULL;
|
||||
g_free(session->book_id);
|
||||
session->book_id = NULL;
|
||||
gnc_session_push_error (session, err, msg);
|
||||
qof_session_push_error (session, err, msg);
|
||||
LEAVE("backend error %d", err);
|
||||
return;
|
||||
}
|
||||
@ -472,7 +485,7 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
/* No backend was found. That's bad. */
|
||||
if (NULL == session->backend)
|
||||
{
|
||||
gnc_session_push_error (session, ERR_BACKEND_BAD_URL, NULL);
|
||||
qof_session_push_error (session, ERR_BACKEND_BAD_URL, NULL);
|
||||
}
|
||||
LEAVE (" sess=%p book-id=%s",
|
||||
session, book_id ? book_id : "(null)");
|
||||
@ -481,19 +494,19 @@ gnc_session_begin (GNCSession *session, const char * book_id,
|
||||
/* ====================================================================== */
|
||||
|
||||
void
|
||||
gnc_session_load (GNCSession *session,
|
||||
GNCPercentageFunc percentage_func)
|
||||
qof_session_load (QofSession *session,
|
||||
QofPercentageFunc percentage_func)
|
||||
{
|
||||
QofBook *newbook;
|
||||
QofBookList *oldbooks, *node;
|
||||
Backend *be;
|
||||
GNCBackendError err;
|
||||
QofBackend *be;
|
||||
QofBackendError err;
|
||||
|
||||
if (!session) return;
|
||||
if (!gnc_session_get_url(session)) return;
|
||||
if (!qof_session_get_url(session)) return;
|
||||
|
||||
ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
ENTER ("sess=%p book_id=%s", session, qof_session_get_url(session)
|
||||
? qof_session_get_url(session) : "(null)");
|
||||
|
||||
|
||||
/* At this point, we should are supposed to have a valid book
|
||||
@ -506,7 +519,7 @@ gnc_session_load (GNCSession *session,
|
||||
|
||||
xaccLogSetBaseName(session->logpath);
|
||||
|
||||
gnc_session_clear_error (session);
|
||||
qof_session_clear_error (session);
|
||||
|
||||
/* This code should be sufficient to initialize *any* backend,
|
||||
* whether http, postgres, or anything else that might come along.
|
||||
@ -530,7 +543,7 @@ gnc_session_load (GNCSession *session,
|
||||
if (be->load)
|
||||
{
|
||||
be->load (be, newbook);
|
||||
gnc_session_push_error (session, xaccBackendGetError(be), NULL);
|
||||
qof_session_push_error (session, qof_backend_get_error(be), NULL);
|
||||
}
|
||||
|
||||
/* we just got done loading, it can't possibly be dirty !! */
|
||||
@ -539,7 +552,7 @@ gnc_session_load (GNCSession *session,
|
||||
xaccLogEnable();
|
||||
}
|
||||
|
||||
err = gnc_session_get_error(session);
|
||||
err = qof_session_get_error(session);
|
||||
if ((err != ERR_BACKEND_NO_ERR) &&
|
||||
(err != ERR_FILEIO_FILE_TOO_OLD) &&
|
||||
(err != ERR_SQL_DB_TOO_OLD))
|
||||
@ -550,7 +563,7 @@ gnc_session_load (GNCSession *session,
|
||||
qof_book_destroy (newbook);
|
||||
g_list_free (session->books);
|
||||
session->books = oldbooks;
|
||||
LEAVE("error from backend %d", gnc_session_get_error(session));
|
||||
LEAVE("error from backend %d", qof_session_get_error(session));
|
||||
xaccLogEnable();
|
||||
return;
|
||||
}
|
||||
@ -564,14 +577,14 @@ gnc_session_load (GNCSession *session,
|
||||
}
|
||||
xaccLogEnable();
|
||||
|
||||
LEAVE ("sess = %p, book_id=%s", session, gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
LEAVE ("sess = %p, book_id=%s", session, qof_session_get_url(session)
|
||||
? qof_session_get_url(session) : "(null)");
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
gboolean
|
||||
gnc_session_save_may_clobber_data (GNCSession *session)
|
||||
qof_session_save_may_clobber_data (QofSession *session)
|
||||
{
|
||||
/* FIXME: Make sure this doesn't need more sophisticated semantics
|
||||
* in the face of special file, devices, pipes, symlinks, etc. */
|
||||
@ -586,14 +599,14 @@ gnc_session_save_may_clobber_data (GNCSession *session)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
save_error_handler(Backend *be, GNCSession *session)
|
||||
save_error_handler(QofBackend *be, QofSession *session)
|
||||
{
|
||||
int err;
|
||||
err = xaccBackendGetError(be);
|
||||
err = qof_backend_get_error(be);
|
||||
|
||||
if (ERR_BACKEND_NO_ERR != err)
|
||||
{
|
||||
gnc_session_push_error (session, err, NULL);
|
||||
qof_session_push_error (session, err, NULL);
|
||||
|
||||
/* we close the backend here ... isn't this a bit harsh ??? */
|
||||
if (be->session_end)
|
||||
@ -606,18 +619,18 @@ save_error_handler(Backend *be, GNCSession *session)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_save (GNCSession *session,
|
||||
GNCPercentageFunc percentage_func)
|
||||
qof_session_save (QofSession *session,
|
||||
QofPercentageFunc percentage_func)
|
||||
{
|
||||
GList *node;
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
|
||||
if (!session) return;
|
||||
|
||||
ENTER ("sess=%p book_id=%s",
|
||||
session,
|
||||
gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
qof_session_get_url(session)
|
||||
? qof_session_get_url(session) : "(null)");
|
||||
|
||||
/* If there is a backend, and the backend is reachable
|
||||
* (i.e. we can communicate with it), then synchronize with
|
||||
@ -657,11 +670,11 @@ gnc_session_save (GNCSession *session,
|
||||
|
||||
/* If the fullpath doesn't exist, either the user failed to initialize,
|
||||
* or the lockfile was never obtained. Either way, we can't write. */
|
||||
gnc_session_clear_error (session);
|
||||
qof_session_clear_error (session);
|
||||
|
||||
if (!session->fullpath)
|
||||
{
|
||||
gnc_session_push_error (session, ERR_BACKEND_MISC, NULL);
|
||||
qof_session_push_error (session, ERR_BACKEND_MISC, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -672,20 +685,20 @@ gnc_session_save (GNCSession *session,
|
||||
/* XXX what does this function do ?? */
|
||||
|
||||
gboolean
|
||||
gnc_session_export (GNCSession *tmp_session,
|
||||
GNCSession *real_session,
|
||||
GNCPercentageFunc percentage_func)
|
||||
qof_session_export (QofSession *tmp_session,
|
||||
QofSession *real_session,
|
||||
QofPercentageFunc percentage_func)
|
||||
{
|
||||
QofBook *book;
|
||||
Backend *be;
|
||||
QofBackend *be;
|
||||
|
||||
if ((!tmp_session) || (!real_session)) return FALSE;
|
||||
|
||||
book = gnc_session_get_book (real_session);
|
||||
book = qof_session_get_book (real_session);
|
||||
ENTER ("tmp_session=%p real_session=%p book=%p book_id=%s",
|
||||
tmp_session, real_session, book,
|
||||
gnc_session_get_url(tmp_session)
|
||||
? gnc_session_get_url(tmp_session) : "(null)");
|
||||
qof_session_get_url(tmp_session)
|
||||
? qof_session_get_url(tmp_session) : "(null)");
|
||||
|
||||
/* There must be a backend or else. (It should always be the file
|
||||
* backend too.)
|
||||
@ -708,12 +721,12 @@ gnc_session_export (GNCSession *tmp_session,
|
||||
/* ====================================================================== */
|
||||
|
||||
void
|
||||
gnc_session_end (GNCSession *session)
|
||||
qof_session_end (QofSession *session)
|
||||
{
|
||||
if (!session) return;
|
||||
|
||||
ENTER ("sess=%p book_id=%s", session, gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
ENTER ("sess=%p book_id=%s", session, qof_session_get_url(session)
|
||||
? qof_session_get_url(session) : "(null)");
|
||||
|
||||
/* close down the backend first */
|
||||
if (session->backend && session->backend->session_end)
|
||||
@ -721,7 +734,7 @@ gnc_session_end (GNCSession *session)
|
||||
(session->backend->session_end)(session->backend);
|
||||
}
|
||||
|
||||
gnc_session_clear_error (session);
|
||||
qof_session_clear_error (session);
|
||||
|
||||
g_free (session->fullpath);
|
||||
session->fullpath = NULL;
|
||||
@ -732,25 +745,25 @@ gnc_session_end (GNCSession *session)
|
||||
g_free (session->book_id);
|
||||
session->book_id = NULL;
|
||||
|
||||
LEAVE ("sess=%p book_id=%s", session, gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
LEAVE ("sess=%p book_id=%s", session, qof_session_get_url(session)
|
||||
? qof_session_get_url(session) : "(null)");
|
||||
}
|
||||
|
||||
void
|
||||
gnc_session_destroy (GNCSession *session)
|
||||
qof_session_destroy (QofSession *session)
|
||||
{
|
||||
GList *node;
|
||||
if (!session) return;
|
||||
|
||||
ENTER ("sess=%p book_id=%s", session,
|
||||
gnc_session_get_url(session)
|
||||
? gnc_session_get_url(session) : "(null)");
|
||||
qof_session_get_url(session)
|
||||
? qof_session_get_url(session) : "(null)");
|
||||
|
||||
xaccLogDisable();
|
||||
gnc_session_end (session);
|
||||
qof_session_end (session);
|
||||
|
||||
/* destroy the backend */
|
||||
gnc_session_destroy_backend(session);
|
||||
qof_session_destroy_backend(session);
|
||||
|
||||
for (node=session->books; node; node=node->next)
|
||||
{
|
||||
@ -774,7 +787,7 @@ gnc_session_destroy (GNCSession *session)
|
||||
/* this call is weird. */
|
||||
|
||||
void
|
||||
gnc_session_swap_data (GNCSession *session_1, GNCSession *session_2)
|
||||
qof_session_swap_data (QofSession *session_1, QofSession *session_2)
|
||||
{
|
||||
GList *books_1, *books_2, *node;
|
||||
|
||||
@ -806,7 +819,7 @@ gnc_session_swap_data (GNCSession *session_1, GNCSession *session_2)
|
||||
/* ====================================================================== */
|
||||
|
||||
gboolean
|
||||
gnc_session_events_pending (GNCSession *session)
|
||||
qof_session_events_pending (QofSession *session)
|
||||
{
|
||||
if (!session) return FALSE;
|
||||
if (!session->backend) return FALSE;
|
||||
@ -816,7 +829,7 @@ gnc_session_events_pending (GNCSession *session)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_session_process_events (GNCSession *session)
|
||||
qof_session_process_events (QofSession *session)
|
||||
{
|
||||
if (!session) return FALSE;
|
||||
if (!session->backend) return FALSE;
|
250
src/engine/qofsession.h
Normal file
250
src/engine/qofsession.h
Normal file
@ -0,0 +1,250 @@
|
||||
/********************************************************************\
|
||||
* qofsession.h -- session access (connection to backend) *
|
||||
* *
|
||||
* 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, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/** @addtogroup Engine
|
||||
* @{ */
|
||||
/** @file qofsession.h
|
||||
* @brief Encapsulates a connection to a backednd (persistent store)
|
||||
* @author Copyright (c) 1998, 1999, 2001, 2002 Linas Vepstas <linas@linas.org>
|
||||
* @author Copyright (c) 2000 Dave Peticolas
|
||||
*
|
||||
* FUNCTION:
|
||||
* Encapsulates a connection to a storage backend. That is, it
|
||||
* manages the connection to a persistant data store; whereas
|
||||
* the backend is the thing that performs the actual datastore
|
||||
* access.
|
||||
*
|
||||
* This class provides several important services:
|
||||
*
|
||||
* 1) It resolves and loads the appropriate backend, based on
|
||||
* the URL.
|
||||
*
|
||||
* 2) It reports backend errors (e.g. network errors, storage
|
||||
* corruption errors) through a single, backend-independent
|
||||
* API.
|
||||
*
|
||||
* 3) It reports non-error events received from the backend.
|
||||
*
|
||||
* 4) It helps manage global dataset locks. For example, for the
|
||||
* file backend, the lock prevents multiple users from editing
|
||||
* the same file at the same time, thus avoiding lost data due
|
||||
* to race conditions. Thus, an open session implies that the
|
||||
* associated file is locked.
|
||||
*
|
||||
* 5) Misc utilities, such as a search path for the file to be
|
||||
* edited, and/or other URL resolution utilities. This should
|
||||
* simplify install & maintenance problems for naive users who
|
||||
* may not have a good grasp on what a file system is, or where
|
||||
* they want to keep their data files.
|
||||
*
|
||||
* 6) In the future, this class is probably a good place to manage
|
||||
* a portion of the user authentication process, and hold user
|
||||
* credentials/cookies/keys/tokens. This is because at the
|
||||
* coarsest level, authorization can happen at the datastore
|
||||
* level: i.e. does this user even have the authority to connect
|
||||
* to and open this datastore?
|
||||
*
|
||||
* A breif note about books & sessions:
|
||||
* A book encapsulates the datasets manipulated by GnuCash. A book
|
||||
* holds the actual data. By contrast, the session mediates the
|
||||
* connection between a book (the thing that lives in virtual memory
|
||||
* in the local process) and the datastore (the place where book
|
||||
* data lives permanently, e.g., file, database).
|
||||
*
|
||||
* In the current design, a session may hold multiple books. For
|
||||
* now, exactly what this means is somewhat vague, and code in
|
||||
* various places makes some implicit assumptions: first, only
|
||||
* one book is 'current' and open for editing. Next, its assumed
|
||||
* that all of the books in a session are related in some way.
|
||||
* i.e. that they are all earlier accounting periods of the
|
||||
* currently open book. In particular, the backends probably
|
||||
* make that assumption, in order to store the different accounting
|
||||
* periods in a clump so that one can be found, given another.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QOF_SESSION_H
|
||||
#define QOF_SESSION_H
|
||||
|
||||
#include "qofbackend.h"
|
||||
#include "qofbook.h"
|
||||
|
||||
/* PROTOTYPES ******************************************************/
|
||||
|
||||
typedef struct _QofSession QofSession;
|
||||
|
||||
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);
|
||||
|
||||
/** The qof_session_swap_data () method swaps the book of
|
||||
* the two given sessions. It is useful
|
||||
* for 'Save As' type functionality. */
|
||||
void qof_session_swap_data (QofSession *session_1, QofSession *session_2);
|
||||
|
||||
/** The qof_session_begin () method begins a new session.
|
||||
* It takes as an argument the book id. The book id must be a string
|
||||
* in the form of a URI/URL.
|
||||
* In the current implementation, the following URL's are supported
|
||||
* -- File URI of the form
|
||||
* "file:/home/somewhere/somedir/file.xac"
|
||||
* The path part must be a valid path. The file-part must be
|
||||
* a valid old-style-xacc or new-style-gnucash-format file. Paths
|
||||
* may be relative or absolute. If the path is relative; that is,
|
||||
* if the argument is "file:somefile.xac" then a sequence of
|
||||
* search paths are checked for a file of this name.
|
||||
*
|
||||
* -- Postgres URI of the form
|
||||
* "postgres://hostname.com/dbname"
|
||||
* See the src/backend/postgres subdirectory for more info.
|
||||
*
|
||||
* -- RPC URI of the form rpc://hostname.com/rpcserver.
|
||||
*
|
||||
* The 'ignore_lock' argument, if set to TRUE, will cause this routine
|
||||
* to ignore any global-datastore locks (e.g. file locks) that it finds.
|
||||
* If set to FALSE, then file/database-global locks will be tested and
|
||||
* obeyed.
|
||||
*
|
||||
* If the datastore exists, can be reached (e.g over the net),
|
||||
* connected to, opened and read, and a lock can be obtained then
|
||||
* a lock will be obtained. Note that multi-user datastores
|
||||
* (e.g. the SQL backend) typically will not need to get a global
|
||||
* lock, and thus, the user will not be locked out. That's the
|
||||
* whole point of 'multi-user'.
|
||||
*
|
||||
* If the file/database doesn't exist, and the create_if_nonexistent
|
||||
* flag is set to TRUE, then the database is created.
|
||||
*
|
||||
* If an error occurs, it will be pushed onto the session error
|
||||
* stack, and that is where it should be examined.
|
||||
*/
|
||||
void qof_session_begin (QofSession *session, const char * book_id,
|
||||
gboolean ignore_lock, gboolean create_if_nonexistent);
|
||||
|
||||
|
||||
/**
|
||||
* The qof_session_load() method causes the QofBook to be made ready to
|
||||
* to use with this URL/datastore. When the URL points at a file,
|
||||
* then this routine would load the data from the file. With remote
|
||||
* backends, e.g. network or SQL, this would load only enough data
|
||||
* to make the book actually usable; it would not cause *all* of the
|
||||
* data to be loaded.
|
||||
*/
|
||||
typedef void (*QofPercentageFunc) (const char *message, double percent);
|
||||
void qof_session_load (QofSession *session,
|
||||
QofPercentageFunc percentage_func);
|
||||
gboolean qof_session_export (QofSession *tmp_session,
|
||||
QofSession *real_session,
|
||||
QofPercentageFunc percentage_func);
|
||||
|
||||
/** The qof_session_get_error() routine can be used to obtain the reason
|
||||
* for any failure. Calling this routine returns the current error.
|
||||
*
|
||||
* The qof_session_pop_error() routine can be used to obtain the reason
|
||||
* for any failure. Calling this routine resets the error value.
|
||||
*
|
||||
* This routine allows an implementation of multiple error values,
|
||||
* e.g. in a stack, where this routine pops the top value. The current
|
||||
* implementation has a stack that is one-deep.
|
||||
*
|
||||
* See qofbackend.h for a listing of returned errors.
|
||||
*/
|
||||
QofBackendError qof_session_get_error (QofSession *session);
|
||||
const char * qof_session_get_error_message(QofSession *session);
|
||||
QofBackendError qof_session_pop_error (QofSession *session);
|
||||
|
||||
|
||||
QofBook * qof_session_get_book (QofSession *session);
|
||||
void qof_session_set_book (QofSession *session, QofBook *book);
|
||||
|
||||
/** The qof_session_get_file_path() routine returns the fully-qualified file
|
||||
* path for the session. That is, if a relative or partial filename
|
||||
* was for the session, then it had to have been fully resolved to
|
||||
* open the session. This routine returns the result of this resolution.
|
||||
* The path is always guarenteed to reside in the local file system,
|
||||
* even if the session itself was opened as a URL. (currently, the
|
||||
* filepath is derived from the url by substituting commas for
|
||||
* slashes).
|
||||
*
|
||||
* The qof_session_get_url() routine returns the url that was opened.
|
||||
* URL's for local files take the form of
|
||||
* file:/some/where/some/file.gml
|
||||
*/
|
||||
const char * qof_session_get_file_path (QofSession *session);
|
||||
const char * qof_session_get_url (QofSession *session);
|
||||
|
||||
/**
|
||||
* The qof_session_not_saved() subroutine will return TRUE
|
||||
* if any data in the session hasn't been saved to long-term storage.
|
||||
*/
|
||||
gboolean qof_session_not_saved(QofSession *session);
|
||||
|
||||
/** FIXME: This isn't as thorough as we might want it to be... */
|
||||
gboolean qof_session_save_may_clobber_data (QofSession *session);
|
||||
|
||||
/** The qof_session_save() method will commit all changes that have been
|
||||
* made to the session. For the file backend, this is nothing
|
||||
* more than a write to the file of the current AccountGroup & etc.
|
||||
* For the SQL backend, this is typically a no-op (since all data
|
||||
* has already been written out to the database.
|
||||
*
|
||||
* The qof_session_end() method will release the session lock. For the
|
||||
* file backend, it will *not* save the account group to a file. Thus,
|
||||
* this method acts as an "abort" or "rollback" primitive. However,
|
||||
* for other backends, such as the sql backend, the data would have
|
||||
* been written out before this, and so this routines wouldn't
|
||||
* roll-back anything; it would just shut the connection.
|
||||
*/
|
||||
void qof_session_save (QofSession *session,
|
||||
QofPercentageFunc percentage_func);
|
||||
void qof_session_end (QofSession *session);
|
||||
|
||||
/** The qof_session_events_pending() method will return TRUE if the backend
|
||||
* has pending events which must be processed to bring the engine
|
||||
* up to date with the backend.
|
||||
*
|
||||
* The qof_session_process_events() method will process any events indicated
|
||||
* by the qof_session_events_pending() method. It returns TRUE if the
|
||||
* engine was modified while engine events were suspended.
|
||||
*/
|
||||
gboolean qof_session_events_pending (QofSession *session);
|
||||
gboolean qof_session_process_events (QofSession *session);
|
||||
|
||||
/** The xaccResolveFilePath() routine is a utility that will accept
|
||||
* a fragmentary filename as input, and resolve it into a fully
|
||||
* qualified path in the file system, i.e. a path that begins with
|
||||
* a leading slash. First, the current working directory is
|
||||
* searched for the file. Next, the directory $HOME/.gnucash/data,
|
||||
* and finally, a list of other (configurable) paths. If the file
|
||||
* is not found, then the path $HOME/.gnucash/data is used. If
|
||||
* $HOME is not defined, then the current working directory is
|
||||
* used.
|
||||
*/
|
||||
char * xaccResolveFilePath (const char * filefrag);
|
||||
char * xaccResolveURL (const char * pathfrag);
|
||||
|
||||
/** Run the RPC Server */
|
||||
void gnc_run_rpc_server (void);
|
||||
|
||||
#endif /* QOF_SESSION_H */
|
||||
/** @} */
|
@ -31,7 +31,7 @@ static gint max_group_accounts = 10;
|
||||
|
||||
static kvp_value* get_random_kvp_value_depth (int type, gint depth);
|
||||
static gpointer get_random_list_element (GList *list);
|
||||
static void add_random_splits(GNCBook *book, Transaction *trn);
|
||||
static void add_random_splits(QofBook *book, Transaction *trn);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
@ -159,7 +159,7 @@ get_random_commodity_namespace(void)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_price (GNCBook *book, GNCPrice *p)
|
||||
make_random_changes_to_price (QofBook *book, GNCPrice *p)
|
||||
{
|
||||
Timespec *ts;
|
||||
char *string;
|
||||
@ -193,7 +193,7 @@ make_random_changes_to_price (GNCBook *book, GNCPrice *p)
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
get_random_price(GNCBook *book)
|
||||
get_random_price(QofBook *book)
|
||||
{
|
||||
GNCPrice *p;
|
||||
|
||||
@ -205,7 +205,7 @@ get_random_price(GNCBook *book)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_pricedb (GNCBook *book, GNCPriceDB *db)
|
||||
make_random_pricedb (QofBook *book, GNCPriceDB *db)
|
||||
{
|
||||
int num_prices;
|
||||
|
||||
@ -224,7 +224,7 @@ make_random_pricedb (GNCBook *book, GNCPriceDB *db)
|
||||
}
|
||||
|
||||
GNCPriceDB *
|
||||
get_random_pricedb(GNCBook *book)
|
||||
get_random_pricedb(QofBook *book)
|
||||
{
|
||||
GNCPriceDB *db;
|
||||
|
||||
@ -245,7 +245,7 @@ price_accumulator (GNCPrice *p, gpointer data)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_pricedb (GNCBook *book, GNCPriceDB *pdb)
|
||||
make_random_changes_to_pricedb (QofBook *book, GNCPriceDB *pdb)
|
||||
{
|
||||
GList *list = NULL;
|
||||
GList *node;
|
||||
@ -529,7 +529,7 @@ set_account_random_string(Account* act,
|
||||
}
|
||||
|
||||
static void
|
||||
account_add_subaccounts (GNCBook *book, Account *account, int depth)
|
||||
account_add_subaccounts (QofBook *book, Account *account, int depth)
|
||||
{
|
||||
int num_accounts;
|
||||
|
||||
@ -549,7 +549,7 @@ account_add_subaccounts (GNCBook *book, Account *account, int depth)
|
||||
}
|
||||
|
||||
static void
|
||||
make_random_group_depth (GNCBook *book, AccountGroup *group, int depth)
|
||||
make_random_group_depth (QofBook *book, AccountGroup *group, int depth)
|
||||
{
|
||||
int num_accounts;
|
||||
|
||||
@ -572,7 +572,7 @@ make_random_group_depth (GNCBook *book, AccountGroup *group, int depth)
|
||||
}
|
||||
|
||||
static void
|
||||
make_random_group (GNCBook *book, AccountGroup * group)
|
||||
make_random_group (QofBook *book, AccountGroup * group)
|
||||
{
|
||||
int depth;
|
||||
|
||||
@ -585,7 +585,7 @@ make_random_group (GNCBook *book, AccountGroup * group)
|
||||
}
|
||||
|
||||
AccountGroup *
|
||||
get_random_group (GNCBook *book)
|
||||
get_random_group (QofBook *book)
|
||||
{
|
||||
AccountGroup * group;
|
||||
|
||||
@ -604,7 +604,7 @@ typedef struct
|
||||
} TransInfo;
|
||||
|
||||
void
|
||||
make_random_changes_to_transaction_and_splits (GNCBook *book,
|
||||
make_random_changes_to_transaction_and_splits (QofBook *book,
|
||||
Transaction *trans,
|
||||
GList *accounts)
|
||||
{
|
||||
@ -700,7 +700,7 @@ add_trans_helper (Transaction *trans, gpointer data)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_group (GNCBook *book, AccountGroup *group)
|
||||
make_random_changes_to_group (QofBook *book, AccountGroup *group)
|
||||
{
|
||||
Account *new_account;
|
||||
Account *account;
|
||||
@ -828,7 +828,7 @@ make_random_changes_to_group (GNCBook *book, AccountGroup *group)
|
||||
}
|
||||
|
||||
Account*
|
||||
get_random_account(GNCBook *book)
|
||||
get_random_account(QofBook *book)
|
||||
{
|
||||
Account *ret;
|
||||
int tmp_int;
|
||||
@ -855,7 +855,7 @@ get_random_account(GNCBook *book)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_account (GNCBook *book, Account *account)
|
||||
make_random_changes_to_account (QofBook *book, Account *account)
|
||||
{
|
||||
int tmp_int;
|
||||
|
||||
@ -894,7 +894,7 @@ set_split_random_string(Split *spl,
|
||||
static char possible_chars[] = { NREC, CREC, YREC, FREC };
|
||||
|
||||
Split*
|
||||
get_random_split(GNCBook *book, gnc_numeric num)
|
||||
get_random_split(QofBook *book, gnc_numeric num)
|
||||
{
|
||||
Split *ret;
|
||||
gnc_numeric oneVal;
|
||||
@ -959,7 +959,7 @@ set_tran_random_string(Transaction* trn,
|
||||
}
|
||||
|
||||
static void
|
||||
add_random_splits(GNCBook *book, Transaction *trn)
|
||||
add_random_splits(QofBook *book, Transaction *trn)
|
||||
{
|
||||
gnc_numeric num = get_random_gnc_numeric();
|
||||
|
||||
@ -980,7 +980,7 @@ trn_add_ran_timespec(Transaction *trn, void (*func)(Transaction*,
|
||||
|
||||
|
||||
Transaction *
|
||||
get_random_transaction_with_currency(GNCBook *book,
|
||||
get_random_transaction_with_currency(QofBook *book,
|
||||
gnc_commodity *currency)
|
||||
{
|
||||
Transaction* ret;
|
||||
@ -1017,13 +1017,13 @@ get_random_transaction_with_currency(GNCBook *book,
|
||||
}
|
||||
|
||||
Transaction*
|
||||
get_random_transaction (GNCBook *book)
|
||||
get_random_transaction (QofBook *book)
|
||||
{
|
||||
return get_random_transaction_with_currency (book, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_transaction (GNCBook *book, Transaction *trans)
|
||||
make_random_changes_to_transaction (QofBook *book, Transaction *trans)
|
||||
{
|
||||
g_return_if_fail (trans && book);
|
||||
|
||||
@ -1095,7 +1095,7 @@ get_random_commodity_from_table (gnc_commodity_table *table)
|
||||
}
|
||||
|
||||
gnc_commodity*
|
||||
get_random_commodity (GNCBook *book)
|
||||
get_random_commodity (QofBook *book)
|
||||
{
|
||||
gnc_commodity *ret;
|
||||
gchar *name;
|
||||
@ -1523,12 +1523,12 @@ get_random_query(void)
|
||||
return q;
|
||||
}
|
||||
|
||||
GNCBook *
|
||||
QofBook *
|
||||
get_random_book (void)
|
||||
{
|
||||
GNCBook *book;
|
||||
QofBook *book;
|
||||
|
||||
book = gnc_book_new ();
|
||||
book = qof_book_new ();
|
||||
|
||||
make_random_group (book, gnc_book_get_group (book));
|
||||
make_random_pricedb (book, gnc_book_get_pricedb (book));
|
||||
@ -1536,15 +1536,15 @@ get_random_book (void)
|
||||
return book;
|
||||
}
|
||||
|
||||
GNCSession *
|
||||
QofSession *
|
||||
get_random_session (void)
|
||||
{
|
||||
GNCSession *session;
|
||||
GNCBook *book;
|
||||
QofSession *session;
|
||||
QofBook *book;
|
||||
|
||||
session = gnc_session_new ();
|
||||
session = qof_session_new ();
|
||||
|
||||
book = gnc_session_get_book (session);
|
||||
book = qof_session_get_book (session);
|
||||
|
||||
make_random_group (book, gnc_book_get_group (book));
|
||||
make_random_pricedb (book, gnc_book_get_pricedb (book));
|
||||
@ -1553,7 +1553,7 @@ get_random_session (void)
|
||||
}
|
||||
|
||||
void
|
||||
add_random_transactions_to_book (GNCBook *book, gint num_transactions)
|
||||
add_random_transactions_to_book (QofBook *book, gint num_transactions)
|
||||
{
|
||||
gnc_commodity_table *table;
|
||||
GList *accounts;
|
||||
@ -1599,7 +1599,7 @@ add_random_transactions_to_book (GNCBook *book, gint num_transactions)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_book (GNCBook *book)
|
||||
make_random_changes_to_book (QofBook *book)
|
||||
{
|
||||
g_return_if_fail (book);
|
||||
|
||||
@ -1612,11 +1612,11 @@ make_random_changes_to_book (GNCBook *book)
|
||||
}
|
||||
|
||||
void
|
||||
make_random_changes_to_session (GNCSession *session)
|
||||
make_random_changes_to_session (QofSession *session)
|
||||
{
|
||||
g_return_if_fail (session);
|
||||
|
||||
make_random_changes_to_book (gnc_session_get_book (session));
|
||||
make_random_changes_to_book (qof_session_get_book (session));
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Query.h"
|
||||
#include "gnc-book.h"
|
||||
#include "gnc-date.h"
|
||||
#include "gnc-pricedb.h"
|
||||
#include "gnc-session.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
Timespec* get_random_timespec(void);
|
||||
void random_timespec_zero_nsec (gboolean zero_nsec);
|
||||
@ -41,16 +41,16 @@ void set_max_kvp_frame_elements (gint max_kvp_frame_elements);
|
||||
void set_max_group_depth (gint max_group_depth);
|
||||
void set_max_group_accounts (gint max_group_accounts);
|
||||
|
||||
GNCPrice * get_random_price(GNCBook *book);
|
||||
void make_random_pricedb (GNCBook *book, GNCPriceDB *pdb);
|
||||
GNCPriceDB * get_random_pricedb(GNCBook *book);
|
||||
AccountGroup * get_random_group(GNCBook * book);
|
||||
Account* get_random_account(GNCBook * book);
|
||||
Split* get_random_split(GNCBook *book, gnc_numeric num);
|
||||
Transaction* get_random_transaction(GNCBook *book);
|
||||
Transaction* get_random_transaction_with_currency(GNCBook *book,
|
||||
GNCPrice * get_random_price(QofBook *book);
|
||||
void make_random_pricedb (QofBook *book, GNCPriceDB *pdb);
|
||||
GNCPriceDB * get_random_pricedb(QofBook *book);
|
||||
AccountGroup * get_random_group(QofBook * book);
|
||||
Account* get_random_account(QofBook * book);
|
||||
Split* get_random_split(QofBook *book, gnc_numeric num);
|
||||
Transaction* get_random_transaction(QofBook *book);
|
||||
Transaction* get_random_transaction_with_currency(QofBook *book,
|
||||
gnc_commodity *currency);
|
||||
gnc_commodity* get_random_commodity(GNCBook *book);
|
||||
gnc_commodity* get_random_commodity(QofBook *book);
|
||||
const char *get_random_commodity_namespace(void);
|
||||
|
||||
typedef enum
|
||||
@ -70,24 +70,24 @@ Query * make_trans_query (Transaction *trans, TestQueryTypes query_types);
|
||||
TestQueryTypes get_random_query_type (void);
|
||||
void trans_query_include_price (gboolean include_amounts);
|
||||
|
||||
GNCBook * get_random_book (void);
|
||||
GNCSession * get_random_session (void);
|
||||
QofBook * get_random_book (void);
|
||||
QofSession * get_random_session (void);
|
||||
|
||||
void add_random_transactions_to_book (GNCBook *book, gint num_transactions);
|
||||
void add_random_transactions_to_book (QofBook *book, gint num_transactions);
|
||||
|
||||
void make_random_changes_to_commodity (gnc_commodity *com);
|
||||
void make_random_changes_to_commodity_table (gnc_commodity_table *table);
|
||||
void make_random_changes_to_price (GNCBook *book, GNCPrice *price);
|
||||
void make_random_changes_to_pricedb (GNCBook *book, GNCPriceDB *pdb);
|
||||
void make_random_changes_to_price (QofBook *book, GNCPrice *price);
|
||||
void make_random_changes_to_pricedb (QofBook *book, GNCPriceDB *pdb);
|
||||
void make_random_changes_to_split (Split *split);
|
||||
void make_random_changes_to_transaction (GNCBook *book,
|
||||
void make_random_changes_to_transaction (QofBook *book,
|
||||
Transaction *trans);
|
||||
void make_random_changes_to_transaction_and_splits (GNCBook *book,
|
||||
void make_random_changes_to_transaction_and_splits (QofBook *book,
|
||||
Transaction *trans,
|
||||
GList *accounts);
|
||||
void make_random_changes_to_account (GNCBook *book, Account *account);
|
||||
void make_random_changes_to_group (GNCBook *book, AccountGroup *group);
|
||||
void make_random_changes_to_book (GNCBook *book);
|
||||
void make_random_changes_to_session (GNCSession *session);
|
||||
void make_random_changes_to_account (QofBook *book, Account *account);
|
||||
void make_random_changes_to_group (QofBook *book, AccountGroup *group);
|
||||
void make_random_changes_to_book (QofBook *book);
|
||||
void make_random_changes_to_session (QofSession *session);
|
||||
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ test_commodity(void)
|
||||
int j;
|
||||
gnc_commodity_table *tbl;
|
||||
gnc_commodity *coms[20];
|
||||
GNCBook *book;
|
||||
QofBook *book;
|
||||
|
||||
book = gnc_book_new ();
|
||||
tbl = gnc_commodity_table_new ();
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-book.h"
|
||||
|
||||
static GNCBook *book;
|
||||
static QofBook *book;
|
||||
|
||||
static void
|
||||
test_once (void)
|
||||
|
@ -22,8 +22,8 @@
|
||||
static void
|
||||
run_test (void)
|
||||
{
|
||||
GNCSession *sess;
|
||||
GNCBook *book;
|
||||
QofSession *sess;
|
||||
QofBook *book;
|
||||
AccountGroup *grp;
|
||||
|
||||
if(!gnc_module_load("gnucash/engine", 0))
|
||||
@ -36,7 +36,7 @@ run_test (void)
|
||||
/* In the first test, we will merely try to see if we can run
|
||||
* without crashing. We don't check to see if data is good. */
|
||||
sess = get_random_session ();
|
||||
book = gnc_session_get_book (sess);
|
||||
book = qof_session_get_book (sess);
|
||||
if (!book)
|
||||
{
|
||||
failure("book not created");
|
||||
|
@ -19,7 +19,7 @@ static void test_printable (const char *name, gpointer obj);
|
||||
static void test_foreach (QofBook *, const char *);
|
||||
|
||||
static QofObject bus_obj = {
|
||||
GNC_OBJECT_VERSION,
|
||||
QOF_OBJECT_VERSION,
|
||||
TEST_MODULE_NAME,
|
||||
TEST_MODULE_DESC,
|
||||
NULL, /* create */
|
||||
|
@ -26,7 +26,7 @@
|
||||
static void
|
||||
run_test (void)
|
||||
{
|
||||
GNCSession *sess;
|
||||
QofSession *sess;
|
||||
QofBook *openbook, *closedbook;
|
||||
AccountGroup *grp;
|
||||
AccountList *acclist, *anode;
|
||||
@ -45,7 +45,7 @@ run_test (void)
|
||||
}
|
||||
|
||||
sess = get_random_session ();
|
||||
openbook = gnc_session_get_book (sess);
|
||||
openbook = qof_session_get_book (sess);
|
||||
if (!openbook)
|
||||
{
|
||||
failure("book not created");
|
||||
|
@ -14,7 +14,7 @@
|
||||
static gboolean
|
||||
test_trans_query (Transaction *trans, gpointer data)
|
||||
{
|
||||
GNCBook *book = data;
|
||||
QofBook *book = data;
|
||||
GList *list;
|
||||
Query *q;
|
||||
|
||||
@ -48,19 +48,19 @@ test_trans_query (Transaction *trans, gpointer data)
|
||||
static void
|
||||
run_test (void)
|
||||
{
|
||||
GNCSession *session;
|
||||
QofSession *session;
|
||||
AccountGroup *group;
|
||||
GNCBook *book;
|
||||
QofBook *book;
|
||||
|
||||
session = get_random_session ();
|
||||
book = gnc_session_get_book (session);
|
||||
book = qof_session_get_book (session);
|
||||
group = xaccGetAccountGroup (book);
|
||||
|
||||
add_random_transactions_to_book (book, 20);
|
||||
|
||||
xaccGroupForEachTransaction (group, test_trans_query, book);
|
||||
|
||||
gnc_session_destroy (session);
|
||||
qof_session_destroy (session);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "test-stuff.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-session.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
struct test_strings_struct
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "TransLog.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-session.h"
|
||||
#include "qofsession.h"
|
||||
#include "test-engine-stuff.h"
|
||||
#include "test-stuff.h"
|
||||
#include "Transaction.h"
|
||||
@ -20,11 +20,11 @@ run_test (void)
|
||||
Account *act2;
|
||||
Split *spl;
|
||||
gnc_numeric num;
|
||||
GNCSession *session;
|
||||
GNCBook *book;
|
||||
QofSession *session;
|
||||
QofBook *book;
|
||||
|
||||
session = gnc_session_new ();
|
||||
book = gnc_session_get_book (session);
|
||||
session = qof_session_new ();
|
||||
book = qof_session_get_book (session);
|
||||
|
||||
act1 = get_random_account(book);
|
||||
if(!act1)
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "Transaction.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-session.h"
|
||||
#include "qofsession.h"
|
||||
#include "test-engine-stuff.h"
|
||||
#include "test-stuff.h"
|
||||
#include "Transaction.h"
|
||||
@ -38,11 +38,11 @@ run_test (void)
|
||||
Account *acc1, *acc2;
|
||||
Transaction *transaction, *new_trans;
|
||||
gnc_numeric old, new, result;
|
||||
GNCBook *book;
|
||||
QofBook *book;
|
||||
char *msg;
|
||||
int i;
|
||||
|
||||
book = gnc_book_new();
|
||||
book = qof_book_new();
|
||||
|
||||
acc1 = get_random_account(book);
|
||||
acc2 = get_random_account(book);
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "Transaction.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-session.h"
|
||||
#include "test-engine-stuff.h"
|
||||
#include "test-stuff.h"
|
||||
#include "Transaction.h"
|
||||
@ -38,13 +37,13 @@ run_test (void)
|
||||
Account *acc1, *acc2;
|
||||
Transaction *transaction;
|
||||
gnc_numeric old_amt, new_amt, old_val, new_val;
|
||||
GNCBook *book;
|
||||
QofBook *book;
|
||||
Timespec ts;
|
||||
time_t now;
|
||||
|
||||
char *reason = "because I can";
|
||||
|
||||
book = gnc_book_new();
|
||||
book = qof_book_new();
|
||||
|
||||
acc1 = get_random_account(book);
|
||||
acc2 = get_random_account(book);
|
||||
|
@ -13,6 +13,8 @@ foreach (@files)
|
||||
|
||||
while (<AF>)
|
||||
{
|
||||
# s/GNCBook/QofBook/g;
|
||||
|
||||
# s/GncObject_t/QofObject/g;
|
||||
# s/gncObjectLookup/qof_object_lookup/g;
|
||||
# s/gncObjectRegister/qof_object_register/g;
|
||||
@ -176,7 +178,25 @@ foreach (@files)
|
||||
# s/xaccRemoveEntity/qof_entity_remove/g;
|
||||
# s/xaccForeachEntity/qof_entity_foreach/g;
|
||||
|
||||
s/foreachObjectCB/QofEntityForeachCB/g;
|
||||
# s/foreachObjectCB/QofEntityForeachCB/g;
|
||||
s/GNC_OBJECT_VERSION/QOF_OBJECT_VERSION/g;
|
||||
|
||||
# s/GNCSession/QofSession/g;
|
||||
# s/gnc_session/qof_session/g;
|
||||
# s/GNCPercentageFunc/QofPercentageFunc/g;
|
||||
# s/gnc_get_current_session/qof_session_get_current_session/g;
|
||||
# s/gnc_set_current_session/qof_session_set_current_session/g;
|
||||
|
||||
# s/ Backend/ QofBackend/g;
|
||||
# s/\(Backend/\(QofBackend/g;
|
||||
# s/GNCBackendError/QofBackendError/g;
|
||||
# s/GNCBePercentageFunc/QofBePercentageFunc/g;
|
||||
# s/xaccBackendSetError/qof_backend_set_error/g;
|
||||
# s/xaccBackendGetError/qof_backend_get_error/g;
|
||||
# s/xaccBackendSetMessage/qof_backend_set_message/g;
|
||||
# s/xaccBackendGetMessage/qof_backend_get_message/g;
|
||||
# s/xaccInitBackend/qof_backend_init/g;
|
||||
|
||||
|
||||
print OF $_;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user