[Gnucash-changes] merge changes from the backend-work-1 branch.
Linas Vepstas
linas at cvs.gnucash.org
Sun Jun 13 12:48:35 EDT 2004
Log Message:
-----------
merge changes from the backend-work-1 branch.
These changes conisted of:
-- change the backend begin()/commit() signatures to take qofinstance
instead of gpointer
-- clean up non-standard use of books by the pricedb
-- rename the gnc-be-utils.h file so that its now a part of QOF
Modified Files:
--------------
gnucash/src/backend/file:
gnc-backend-file.c
io-gncbin-r.c
io-gncxml-v1.c
io-gncxml-v2.c
gnucash/src/backend/postgres:
PostgresBackend.c
book.c
gncquery.c
price.c
putil.h
gnucash/src/business/business-core:
gncBillTerm.c
gncCustomer.c
gncEmployee.c
gncEntry.c
gncInvoice.c
gncJob.c
gncOrder.c
gncTaxTable.c
gncVendor.c
gnucash/src/engine:
Account.c
Group.h
Makefile.am
Period.c
Transaction.c
gnc-pricedb-p.h
gnc-pricedb.c
gnc-pricedb.h
qofbackend-p.h
qofbook-p.h
qofbook.c
qofbook.h
qofinstance-p.h
qofinstance.c
qofquery.h
Added Files:
-----------
gnucash/src/engine:
qof-be-utils.h
Removed Files:
-------------
gnucash/src/engine:
gnc-be-utils.h
Revision Data
-------------
Index: io-gncxml-v1.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/io-gncxml-v1.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lsrc/backend/file/io-gncxml-v1.c -Lsrc/backend/file/io-gncxml-v1.c -u -r1.30 -r1.31
--- src/backend/file/io-gncxml-v1.c
+++ src/backend/file/io-gncxml-v1.c
@@ -389,11 +389,6 @@
xaccSetAccountGroup(book, global_parse_status.account_group);
- if(global_parse_status.pricedb)
- {
- gnc_pricedb_set_db(book, global_parse_status.pricedb);
- }
-
/* Fix account and transaction commodities */
xaccGroupScrubCommodities (gnc_book_get_group(book));
Index: io-gncxml-v2.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/io-gncxml-v2.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -Lsrc/backend/file/io-gncxml-v2.c -Lsrc/backend/file/io-gncxml-v2.c -u -r1.42 -r1.43
--- src/backend/file/io-gncxml-v2.c
+++ src/backend/file/io-gncxml-v2.c
@@ -305,13 +305,7 @@
static gboolean
add_pricedb_local(sixtp_gdv2 *data, GNCPriceDB *db)
{
- QofBook *book;
-
- book = data->book;
-
/* gnc_pricedb_print_contents(db, stdout); */
- gnc_pricedb_set_db(book, db);
-
return TRUE;
}
Index: gnc-backend-file.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/gnc-backend-file.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lsrc/backend/file/gnc-backend-file.c -Lsrc/backend/file/gnc-backend-file.c -u -r1.38 -r1.39
--- src/backend/file/gnc-backend-file.c
+++ src/backend/file/gnc-backend-file.c
@@ -236,12 +236,15 @@
}
static void
-file_begin_edit (QofBackend *be, QofIdTypeConst typ, gpointer gp)
+file_begin_edit (QofBackend *be, QofInstance *inst)
{
+ if (0) build_period_filepath(0, 0);
+#if BORKEN_FOR_NOW
FileBackend *fbe = (FileBackend *) be;
QofBook *book = gp;
const char * filepath;
+ QofIdTypeConst typ = QOF_ENTITY(inst)->e_type;
if (strcmp (GNC_ID_PERIOD, typ)) return;
filepath = build_period_filepath(fbe, book);
PINFO (" ====================== book=%p filepath=%s\n", book, filepath);
@@ -257,20 +260,24 @@
* modify books that are closed (They should be treated as
* 'read-only').
*/
+#endif
}
static void
-file_rollback_edit (QofBackend *be, QofIdTypeConst typ, gpointer gp)
+file_rollback_edit (QofBackend *be, QofInstance *inst)
{
+#if BORKEN_FOR_NOW
QofBook *book = gp;
if (strcmp (GNC_ID_PERIOD, typ)) return;
PINFO ("book=%p", book);
+#endif
}
static void
-file_commit_edit (QofBackend *be, QofIdTypeConst typ, gpointer gp)
+file_commit_edit (QofBackend *be, QofInstance *inst)
{
+#if BORKEN_FOR_NOW
FileBackend *fbe = (FileBackend *) be;
QofBook *book = gp;
const char * filepath;
@@ -285,6 +292,7 @@
* there'll be the same transactions in the closed book,
* and also in the current book. */
gnc_file_be_write_to_file (fbe, fbe->primary_book, fbe->fullpath, TRUE);
+#endif
}
/* ================================================================= */
Index: io-gncbin-r.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/io-gncbin-r.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lsrc/backend/file/io-gncbin-r.c -Lsrc/backend/file/io-gncbin-r.c -u -r1.29 -r1.30
--- src/backend/file/io-gncbin-r.c
+++ src/backend/file/io-gncbin-r.c
@@ -509,10 +509,8 @@
{
GNCPriceDB *tmpdb;
- if(cvt_potential_prices_to_pricedb_and_cleanup(&tmpdb, book))
+ if(!cvt_potential_prices_to_pricedb_and_cleanup(&tmpdb, book))
{
- gnc_pricedb_set_db(book, tmpdb);
- } else {
PWARN("pricedb import failed.");
error_code = ERR_BACKEND_MISC;
gnc_pricedb_destroy(tmpdb);
Index: gncquery.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/gncquery.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lsrc/backend/postgres/gncquery.c -Lsrc/backend/postgres/gncquery.c -u -r1.34 -r1.35
--- src/backend/postgres/gncquery.c
+++ src/backend/postgres/gncquery.c
@@ -314,7 +314,7 @@
}
/* =========================================================== */
-/* Macro for QOF_QUERYCORE_STRING query types
+/* Macro for QOF_TYPE_STRING query types
* Note that postgres supports both case-sensitive and
* case-insensitve string searches, and it also supports
* regex! yahooo!
@@ -346,7 +346,7 @@
}
/* =========================================================== */
-/* Macro for QOF_QUERYCORE_NUMERIC type terms. The logic used here in the
+/* Macro for QOF_TYPE_NUMERIC type terms. The logic used here in the
* SQL exactly matches that used in the qofquery.c code. If
* that code is incorrect or has changed, then the code below is
* broken as well.
@@ -756,7 +756,7 @@
need_entry = TRUE;
need_trans_commodity = TRUE;
} else if (!safe_strcmp(pd->type_name, QOF_TYPE_GUID)) {
- if (!safe_strcmp(path->data, QOF_QUERY_PARAM_GUID))
+ if (!safe_strcmp(path->data, QOF_PARAM_GUID))
need_entry = TRUE;
else if (!safe_strcmp(path->data, SPLIT_ACCOUNT)) {
need_account = TRUE;
@@ -862,17 +862,17 @@
PINFO("term is QOF_TYPE_GUID");
- if (!safe_strcmp(path->data, QOF_QUERY_PARAM_GUID)) {
+ if (!safe_strcmp(path->data, QOF_PARAM_GUID)) {
field = "gncSplit.splitGuid";
g_assert(pdata->options != QOF_GUID_MATCH_ALL);
} else if (!safe_strcmp(path->data, SPLIT_TRANS) &&
- !safe_strcmp(path->next->data, QOF_QUERY_PARAM_GUID)) {
+ !safe_strcmp(path->next->data, QOF_PARAM_GUID)) {
field = "gncSplit.transGUID";
g_assert(pdata->options != QOF_GUID_MATCH_ALL);
} else if (!safe_strcmp(path->data, SPLIT_ACCOUNT) &&
- !safe_strcmp(path->next->data, QOF_QUERY_PARAM_GUID)) {
+ !safe_strcmp(path->next->data, QOF_PARAM_GUID)) {
field = "gncSplit.accountGUID";
g_assert(pdata->options != QOF_GUID_MATCH_ALL);
@@ -883,8 +883,8 @@
field = "gncSplit.accountGUID";
g_assert(pdata->options == QOF_GUID_MATCH_ALL);
- } else if (!safe_strcmp(path->data, QOF_QUERY_PARAM_BOOK) &&
- !safe_strcmp(path->next->data, QOF_QUERY_PARAM_GUID)) {
+ } else if (!safe_strcmp(path->data, QOF_PARAM_BOOK) &&
+ !safe_strcmp(path->next->data, QOF_PARAM_GUID)) {
/* XXX: Need to support the Book GUID? (gncAccount.bookGUID) */
field = "gncAccount.bookGUID";
g_assert(pdata->options != QOF_GUID_MATCH_ALL);
Index: price.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/price.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lsrc/backend/postgres/price.c -Lsrc/backend/postgres/price.c -u -r1.22 -r1.23
--- src/backend/postgres/price.c
+++ src/backend/postgres/price.c
@@ -462,7 +462,7 @@
void
pgend_price_begin_edit (QofBackend * bend, GNCPrice *pr)
{
- if (pr && pr->db && pr->db->dirty)
+ if (pr && pr->db && pr->db->inst.dirty)
{
PERR ("price db is unexpectedly dirty");
}
@@ -527,7 +527,7 @@
SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection);
- if (pr->db) pr->db->dirty = FALSE;
+ if (pr->db) pr->db->inst.dirty = FALSE;
LEAVE ("commited");
return;
Index: putil.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/putil.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lsrc/backend/postgres/putil.h -Lsrc/backend/postgres/putil.h -u -r1.15 -r1.16
--- src/backend/postgres/putil.h
+++ src/backend/postgres/putil.h
@@ -362,7 +362,7 @@
for (node=be->blist; node; node=node->next) \
{ \
book = node->data; \
- if (guid_equal (&book->entity.guid, &book_guid)) break; \
+ if (guid_equal (&book->inst.entity.guid, &book_guid)) break; \
book = NULL; \
} \
if (!book) return data; \
Index: book.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/book.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/backend/postgres/book.c -Lsrc/backend/postgres/book.c -u -r1.11 -r1.12
--- src/backend/postgres/book.c
+++ src/backend/postgres/book.c
@@ -97,7 +97,7 @@
if (book->idata)
{
pgendKVPDelete (be, book->idata);
- pgendKVPStore (be, book->idata, book->kvp_data);
+ pgendKVPStore (be, book->idata, book->inst.kvp_data);
}
LEAVE(" ");
}
@@ -172,7 +172,7 @@
if (0 != book->idata)
{
- book->kvp_data = pgendKVPFetch (be, book->idata, book->kvp_data);
+ book->inst.kvp_data = pgendKVPFetch (be, book->idata, book->inst.kvp_data);
}
LEAVE (" ");
@@ -200,7 +200,7 @@
for (node=blist; node; node=node->next)
{
book = node->data;
- if (guid_equal (&book->entity.guid, &guid)) break;
+ if (guid_equal (&book->inst.entity.guid, &guid)) break;
book = NULL;
}
@@ -237,7 +237,7 @@
QofBook *book = node->data;
if (0 != book->idata)
{
- book->kvp_data = pgendKVPFetch (be, book->idata, book->kvp_data);
+ book->inst.kvp_data = pgendKVPFetch (be, book->idata, book->inst.kvp_data);
}
}
Index: PostgresBackend.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/PostgresBackend.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -Lsrc/backend/postgres/PostgresBackend.c -Lsrc/backend/postgres/PostgresBackend.c -u -r1.53 -r1.54
--- src/backend/postgres/PostgresBackend.c
+++ src/backend/postgres/PostgresBackend.c
@@ -1643,20 +1643,21 @@
}
static void
-pgend_do_begin (QofBackend *bend, QofIdTypeConst type, gpointer object)
+pgend_do_begin (QofBackend *bend, QofInstance *inst)
{
PGBackend *be = (PGBackend*)bend;
+ QofIdTypeConst type = inst->entity.e_type;
ENTER ("be=%p, type=%s", bend, type);
- if (!safe_strcmp (type, GNC_ID_PERIOD))
- return pgend_book_transfer_begin (bend, object);
+ // if (!safe_strcmp (type, GNC_ID_PERIOD))
+ // return pgend_book_transfer_begin (bend, object);
switch (be->session_mode) {
case MODE_EVENT:
case MODE_POLL:
case MODE_SINGLE_UPDATE:
if (!safe_strcmp (type, GNC_ID_PRICE))
- return pgend_price_begin_edit (bend, object);
+ return pgend_price_begin_edit (bend, (GNCPrice *) inst);
case MODE_SINGLE_FILE:
case MODE_NONE:
@@ -1668,13 +1669,14 @@
}
static void
-pgend_do_commit (QofBackend *bend, QofIdTypeConst type, gpointer object)
+pgend_do_commit (QofBackend *bend, QofInstance *inst)
{
PGBackend *be = (PGBackend*)bend;
+ QofIdTypeConst type = inst->entity.e_type;
ENTER ("be=%p, type=%s", bend, type);
- if (!safe_strcmp (type, GNC_ID_PERIOD))
- return pgend_book_transfer_commit (bend, object);
+ // if (!safe_strcmp (type, GNC_ID_PERIOD))
+ // return pgend_book_transfer_commit (bend, object);
switch (be->session_mode) {
case MODE_EVENT:
@@ -1682,15 +1684,15 @@
case MODE_SINGLE_UPDATE:
if (!safe_strcmp (type, GNC_ID_TRANS)) {
- Transaction *txn = (Transaction*) object;
+ Transaction *txn = (Transaction*) inst;
return pgend_trans_commit_edit (bend, txn, txn->orig);
}
if (!safe_strcmp (type, GNC_ID_PRICE))
- return pgend_price_commit_edit (bend, object);
+ return pgend_price_commit_edit (bend, (GNCPrice *) inst);
if (!safe_strcmp (type, GNC_ID_ACCOUNT))
- return pgend_account_commit_edit (bend, object);
+ return pgend_account_commit_edit (bend, (Account *) inst);
case MODE_SINGLE_FILE:
case MODE_NONE:
@@ -1703,9 +1705,10 @@
}
static void
-pgend_do_rollback (QofBackend *bend, QofIdTypeConst type, gpointer object)
+pgend_do_rollback (QofBackend *bend, QofInstance *inst)
{
PGBackend *be = (PGBackend*)bend;
+ QofIdTypeConst type = inst->entity.e_type;
ENTER ("be=%p, type=%s", bend, type);
switch (be->session_mode) {
@@ -1713,7 +1716,7 @@
case MODE_POLL:
if (!safe_strcmp (type, GNC_ID_TRANS))
- return pgend_trans_rollback_edit (bend, object);
+ return pgend_trans_rollback_edit (bend, (Transaction *)inst);
case MODE_SINGLE_UPDATE:
case MODE_SINGLE_FILE:
Index: gncEmployee.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEmployee.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -Lsrc/business/business-core/gncEmployee.c -Lsrc/business/business-core/gncEmployee.c -u -r1.42 -r1.43
--- src/business/business-core/gncEmployee.c
+++ src/business/business-core/gncEmployee.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "guid.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -47,7 +48,6 @@
#include "gnc-commodity.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
#include "gncAddressP.h"
#include "gncBusiness.h"
@@ -349,7 +349,7 @@
void gncEmployeeBeginEdit (GncEmployee *employee)
{
- GNC_BEGIN_EDIT (&employee->inst);
+ QOF_BEGIN_EDIT (&employee->inst);
}
static inline void gncEmployeeOnError (QofInstance *employee, QofBackendError errcode)
@@ -372,8 +372,8 @@
void gncEmployeeCommitEdit (GncEmployee *employee)
{
- GNC_COMMIT_EDIT_PART1 (&employee->inst);
- GNC_COMMIT_EDIT_PART2 (&employee->inst, gncEmployeeOnError,
+ QOF_COMMIT_EDIT_PART1 (&employee->inst);
+ QOF_COMMIT_EDIT_PART2 (&employee->inst, gncEmployeeOnError,
gncEmployeeOnDone, emp_free);
}
Index: gncInvoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncInvoice.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -Lsrc/business/business-core/gncInvoice.c -Lsrc/business/business-core/gncInvoice.c -u -r1.89 -r1.90
--- src/business/business-core/gncInvoice.c
+++ src/business/business-core/gncInvoice.c
@@ -30,6 +30,7 @@
#include <glib.h>
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -49,7 +50,6 @@
#include "gnc-event-p.h"
#include "gnc-lot.h"
-#include "gnc-be-utils.h"
#include "gncBusiness.h"
#include "gncBillTermP.h"
@@ -1295,7 +1295,7 @@
void gncInvoiceBeginEdit (GncInvoice *invoice)
{
- GNC_BEGIN_EDIT (&invoice->inst);
+ QOF_BEGIN_EDIT (&invoice->inst);
}
static inline void gncInvoiceOnError (QofInstance *inst, QofBackendError errcode)
@@ -1313,8 +1313,8 @@
void gncInvoiceCommitEdit (GncInvoice *invoice)
{
- GNC_COMMIT_EDIT_PART1 (&invoice->inst);
- GNC_COMMIT_EDIT_PART2 (&invoice->inst, gncInvoiceOnError,
+ QOF_COMMIT_EDIT_PART1 (&invoice->inst);
+ QOF_COMMIT_EDIT_PART2 (&invoice->inst, gncInvoiceOnError,
gncInvoiceOnDone, invoice_free);
}
Index: gncCustomer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncCustomer.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -Lsrc/business/business-core/gncCustomer.c -Lsrc/business/business-core/gncCustomer.c -u -r1.58 -r1.59
--- src/business/business-core/gncCustomer.c
+++ src/business/business-core/gncCustomer.c
@@ -36,8 +36,8 @@
#include "gnc-commodity.h"
#include "gnc-numeric.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid-p.h"
@@ -377,7 +377,7 @@
void gncCustomerBeginEdit (GncCustomer *cust)
{
- GNC_BEGIN_EDIT (&cust->inst);
+ QOF_BEGIN_EDIT (&cust->inst);
}
static inline void gncCustomerOnError (QofInstance *inst, QofBackendError errcode)
@@ -400,8 +400,8 @@
void gncCustomerCommitEdit (GncCustomer *cust)
{
- GNC_COMMIT_EDIT_PART1 (&cust->inst);
- GNC_COMMIT_EDIT_PART2 (&cust->inst, gncCustomerOnError,
+ QOF_COMMIT_EDIT_PART1 (&cust->inst);
+ QOF_COMMIT_EDIT_PART2 (&cust->inst, gncCustomerOnError,
gncCustomerOnDone, cust_free);
}
Index: gncVendor.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncVendor.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -Lsrc/business/business-core/gncVendor.c -Lsrc/business/business-core/gncVendor.c -u -r1.47 -r1.48
--- src/business/business-core/gncVendor.c
+++ src/business/business-core/gncVendor.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "guid.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -46,7 +47,6 @@
#include "gnc-commodity.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
#include "gncAddressP.h"
#include "gncBillTermP.h"
@@ -409,7 +409,7 @@
void gncVendorBeginEdit (GncVendor *vendor)
{
- GNC_BEGIN_EDIT (&vendor->inst);
+ QOF_BEGIN_EDIT (&vendor->inst);
}
static inline void gncVendorOnError (QofInstance *vendor, QofBackendError errcode)
@@ -431,8 +431,8 @@
void gncVendorCommitEdit (GncVendor *vendor)
{
- GNC_COMMIT_EDIT_PART1 (&vendor->inst);
- GNC_COMMIT_EDIT_PART2 (&vendor->inst, gncVendorOnError,
+ QOF_COMMIT_EDIT_PART1 (&vendor->inst);
+ QOF_COMMIT_EDIT_PART2 (&vendor->inst, gncVendorOnError,
gncVendorOnDone, vendor_free);
}
Index: gncJob.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncJob.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -Lsrc/business/business-core/gncJob.c -Lsrc/business/business-core/gncJob.c -u -r1.43 -r1.44
--- src/business/business-core/gncJob.c
+++ src/business/business-core/gncJob.c
@@ -36,8 +36,8 @@
#include "gnc-engine-util.h"
#include "gnc-numeric.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofinstance.h"
@@ -271,7 +271,7 @@
void gncJobBeginEdit (GncJob *job)
{
- GNC_BEGIN_EDIT (&job->inst);
+ QOF_BEGIN_EDIT (&job->inst);
}
static void gncJobOnError (QofInstance *inst, QofBackendError errcode)
@@ -289,8 +289,8 @@
void gncJobCommitEdit (GncJob *job)
{
- GNC_COMMIT_EDIT_PART1 (&job->inst);
- GNC_COMMIT_EDIT_PART2 (&job->inst, gncJobOnError,
+ QOF_COMMIT_EDIT_PART1 (&job->inst);
+ QOF_COMMIT_EDIT_PART2 (&job->inst, gncJobOnError,
gncJobOnDone, job_free);
}
Index: gncBillTerm.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncBillTerm.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lsrc/business/business-core/gncBillTerm.c -Lsrc/business/business-core/gncBillTerm.c -u -r1.38 -r1.39
--- src/business/business-core/gncBillTerm.c
+++ src/business/business-core/gncBillTerm.c
@@ -36,9 +36,9 @@
#include "gnc-engine-util.h"
#include "qofquerycore.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
#include "kvp_frame.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -404,7 +404,7 @@
void gncBillTermBeginEdit (GncBillTerm *term)
{
- GNC_BEGIN_EDIT (&term->inst);
+ QOF_BEGIN_EDIT (&term->inst);
}
static void gncBillTermOnError (QofInstance *inst, QofBackendError errcode)
@@ -422,8 +422,8 @@
void gncBillTermCommitEdit (GncBillTerm *term)
{
- GNC_COMMIT_EDIT_PART1 (&term->inst);
- GNC_COMMIT_EDIT_PART2 (&term->inst, gncBillTermOnError,
+ QOF_COMMIT_EDIT_PART1 (&term->inst);
+ QOF_COMMIT_EDIT_PART2 (&term->inst, gncBillTermOnError,
on_done, bill_free);
}
Index: gncEntry.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEntry.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -Lsrc/business/business-core/gncEntry.c -Lsrc/business/business-core/gncEntry.c -u -r1.55 -r1.56
--- src/business/business-core/gncEntry.c
+++ src/business/business-core/gncEntry.c
@@ -34,8 +34,8 @@
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "gnc-numeric.h"
-#include "gnc-be-utils.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -1115,7 +1115,7 @@
void gncEntryBeginEdit (GncEntry *entry)
{
- GNC_BEGIN_EDIT (&entry->inst);
+ QOF_BEGIN_EDIT (&entry->inst);
}
static inline void gncEntryOnError (QofInstance *entry, QofBackendError errcode)
@@ -1133,8 +1133,8 @@
void gncEntryCommitEdit (GncEntry *entry)
{
- GNC_COMMIT_EDIT_PART1 (&entry->inst);
- GNC_COMMIT_EDIT_PART2 (&entry->inst, gncEntryOnError,
+ QOF_COMMIT_EDIT_PART1 (&entry->inst);
+ QOF_COMMIT_EDIT_PART2 (&entry->inst, gncEntryOnError,
gncEntryOnDone, entry_free);
}
Index: gncOrder.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncOrder.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -Lsrc/business/business-core/gncOrder.c -Lsrc/business/business-core/gncOrder.c -u -r1.43 -r1.44
--- src/business/business-core/gncOrder.c
+++ src/business/business-core/gncOrder.c
@@ -34,6 +34,7 @@
#include "kvp_frame.h"
#include "gnc-engine-util.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -45,7 +46,6 @@
#include "qofquerycore.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
#include "gncBusiness.h"
#include "gncEntry.h"
@@ -356,7 +356,7 @@
void gncOrderBeginEdit (GncOrder *order)
{
- GNC_BEGIN_EDIT (&order->inst);
+ QOF_BEGIN_EDIT (&order->inst);
}
static inline void gncOrderOnError (QofInstance *order, QofBackendError errcode)
@@ -374,8 +374,8 @@
void gncOrderCommitEdit (GncOrder *order)
{
- GNC_COMMIT_EDIT_PART1 (&order->inst);
- GNC_COMMIT_EDIT_PART2 (&order->inst, gncOrderOnError,
+ QOF_COMMIT_EDIT_PART1 (&order->inst);
+ QOF_COMMIT_EDIT_PART2 (&order->inst, gncOrderOnError,
gncOrderOnDone, order_free);
}
Index: gncTaxTable.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncTaxTable.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lsrc/business/business-core/gncTaxTable.c -Lsrc/business/business-core/gncTaxTable.c -u -r1.37 -r1.38
--- src/business/business-core/gncTaxTable.c
+++ src/business/business-core/gncTaxTable.c
@@ -34,8 +34,8 @@
#include "gnc-numeric.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
-#include "gnc-be-utils.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofclass.h"
#include "qofid.h"
@@ -527,7 +527,7 @@
void gncTaxTableBeginEdit (GncTaxTable *table)
{
- GNC_BEGIN_EDIT (&table->inst);
+ QOF_BEGIN_EDIT (&table->inst);
}
static inline void gncTaxTableOnError (QofInstance *inst, QofBackendError errcode)
@@ -545,8 +545,8 @@
void gncTaxTableCommitEdit (GncTaxTable *table)
{
- GNC_COMMIT_EDIT_PART1 (&table->inst);
- GNC_COMMIT_EDIT_PART2 (&table->inst, gncTaxTableOnError,
+ QOF_COMMIT_EDIT_PART1 (&table->inst);
+ QOF_COMMIT_EDIT_PART2 (&table->inst, gncTaxTableOnError,
gncTaxTableOnDone, table_free);
}
Index: qofquery.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofquery.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lsrc/engine/qofquery.h -Lsrc/engine/qofquery.h -u -r1.12 -r1.13
--- src/engine/qofquery.h
+++ src/engine/qofquery.h
@@ -109,6 +109,7 @@
#define QOF_PARAM_GUID "guid"
/** "Known" Object Parameters -- some objects might support these */
+#define QOF_PARAM_KVP "kvp"
#define QOF_PARAM_ACTIVE "active"
/* --------------------------------------------------------- */
Index: gnc-pricedb-p.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-pricedb-p.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lsrc/engine/gnc-pricedb-p.h -Lsrc/engine/gnc-pricedb-p.h -u -r1.29 -r1.30
--- src/engine/gnc-pricedb-p.h
+++ src/engine/gnc-pricedb-p.h
@@ -59,12 +59,8 @@
struct gnc_price_db_s
{
+ QofInstance inst; /* globally unique object identifier */
GHashTable *commodity_hash;
- QofBook *book; /* book holding this database and all its prices */
-
- /* 'private' object management fields */
- gint32 editlevel; /* nesting level of begin/end edit calls */
- gboolean dirty;
};
/* These structs define the kind of price lookup being done
@@ -98,12 +94,7 @@
} GNCPriceLookupHelper;
#define gnc_price_set_guid(P,G) qof_entity_set_guid(QOF_ENTITY(P),(G))
-
-void gnc_pricedb_set_db(QofBook *book, GNCPriceDB *db);
-void gnc_collection_set_pricedb(QofCollection *col, GNCPriceDB *db);
-
-
-void gnc_pricedb_mark_clean(GNCPriceDB *db);
+#define gnc_pricedb_mark_clean(db) qof_instance_mark_clean(QOF_INSTANCE(db))
void gnc_pricedb_substitute_commodity(GNCPriceDB *db,
gnc_commodity *old_c,
gnc_commodity *new_c);
Index: qofinstance.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofinstance.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lsrc/engine/qofinstance.c -Lsrc/engine/qofinstance.c -u -r1.13 -r1.14
--- src/engine/qofinstance.c
+++ src/engine/qofinstance.c
@@ -165,11 +165,11 @@
/* Make a note of where the copy came from */
gnc_kvp_bag_add (to->kvp_data, "gemini", now,
"inst_guid", &from->entity.guid,
- "book_guid", &from->book->entity.guid,
+ "book_guid", &from->book->inst.entity.guid,
NULL);
gnc_kvp_bag_add (from->kvp_data, "gemini", now,
"inst_guid", &to->entity.guid,
- "book_guid", &to->book->entity.guid,
+ "book_guid", &to->book->inst.entity.guid,
NULL);
to->dirty = TRUE;
@@ -187,7 +187,7 @@
ENTER (" ");
fr = gnc_kvp_bag_find_by_guid (src->kvp_data, "gemini",
- "book_guid", &target_book->entity.guid);
+ "book_guid", &target_book->inst.entity.guid);
twin_guid = kvp_frame_get_guid (fr, "inst_guid");
Index: Account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Account.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -Lsrc/engine/Account.c -Lsrc/engine/Account.c -u -r1.273 -r1.274
--- src/engine/Account.c
+++ src/engine/Account.c
@@ -32,7 +32,6 @@
#include "Group.h"
#include "GroupP.h"
#include "TransactionP.h"
-#include "gnc-be-utils.h"
#include "gnc-date.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
@@ -48,6 +47,7 @@
#include "qofbackend.h"
#include "qofbackend-p.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofbook-p.h"
#include "qofclass.h"
@@ -318,7 +318,7 @@
void
xaccAccountBeginEdit (Account *acc)
{
- GNC_BEGIN_EDIT (&acc->inst);
+ QOF_BEGIN_EDIT (&acc->inst);
}
static inline void noop(QofInstance *inst) {}
@@ -338,7 +338,7 @@
void
xaccAccountCommitEdit (Account *acc)
{
- GNC_COMMIT_EDIT_PART1 (&acc->inst);
+ QOF_COMMIT_EDIT_PART1 (&acc->inst);
/* If marked for deletion, get rid of subaccounts first,
* and then the splits ... */
@@ -385,7 +385,7 @@
xaccGroupInsertAccount(acc->parent, acc);
}
- GNC_COMMIT_EDIT_PART2 (&acc->inst, on_err, noop, acc_free);
+ QOF_COMMIT_EDIT_PART2 (&acc->inst, on_err, noop, acc_free);
gnc_engine_gen_event (&acc->inst.entity, GNC_EVENT_MODIFY);
}
Index: gnc-pricedb.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-pricedb.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -Lsrc/engine/gnc-pricedb.h -Lsrc/engine/gnc-pricedb.h -u -r1.42 -r1.43
--- src/engine/gnc-pricedb.h
+++ src/engine/gnc-pricedb.h
@@ -374,7 +374,7 @@
/** gnc_pricedb_dirty - return FALSE if the database has not been
modified. */
-gboolean gnc_pricedb_dirty(GNCPriceDB *db);
+#define gnc_pricedb_dirty(db) qof_instance_is_dirty(QOF_INSTANCE(db))
/** gnc_pricedb_get_num_prices - return the number of prices
in the database. */
Index: qofbook.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lsrc/engine/qofbook.h -Lsrc/engine/qofbook.h -u -r1.13 -r1.14
--- src/engine/qofbook.h
+++ src/engine/qofbook.h
@@ -99,7 +99,7 @@
* between multiple users). To store application runtime data, use
* qof_book_set_data() isntead.
*/
-KvpFrame * qof_book_get_slots (QofBook *book);
+#define qof_book_get_slots(book) qof_instance_get_slots(QOF_INSTANCE(book))
/** The qof_book_set_data() allows arbitrary pointers to structs
* to be stored in QofBook. This is the "prefered" method for
@@ -154,13 +154,6 @@
*/
gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
-/** Book parameter names */
-/**@{*/
-
-#define QOF_BOOK_KVP "qof-kvp"
-
-/**@}*/
-
/** deprecated */
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_ENTITY(X))
Index: qofbook.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -Lsrc/engine/qofbook.c -Lsrc/engine/qofbook.c -u -r1.23 -r1.24
--- src/engine/qofbook.c
+++ src/engine/qofbook.c
@@ -58,16 +58,12 @@
static void
qof_book_init (QofBook *book)
{
- QofCollection *col;
if (!book) return;
book->hash_of_collections = g_hash_table_new (g_str_hash, g_str_equal);
- col = qof_book_get_collection (book, QOF_ID_BOOK);
- qof_entity_init (&book->entity, QOF_ID_BOOK, col);
+ qof_instance_init (&book->inst, QOF_ID_BOOK, book);
- book->kvp_data = kvp_frame_new ();
-
book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
@@ -86,7 +82,7 @@
qof_book_init(book);
qof_object_book_begin (book);
- gnc_engine_gen_event (&book->entity, GNC_EVENT_CREATE);
+ gnc_engine_gen_event (&book->inst.entity, GNC_EVENT_CREATE);
LEAVE ("book=%p", book);
return book;
}
@@ -116,7 +112,7 @@
ENTER ("book=%p", book);
book->shutting_down = TRUE;
- gnc_engine_force_event (&book->entity, GNC_EVENT_DESTROY);
+ gnc_engine_force_event (&book->inst.entity, GNC_EVENT_DESTROY);
/* Call the list of finalizers, let them do thier thing.
* Do this before tearing into the rest of the book.
@@ -125,12 +121,10 @@
qof_object_book_end (book);
- kvp_frame_delete (book->kvp_data);
-
g_hash_table_destroy (book->data_table_finalizers);
g_hash_table_destroy (book->data_tables);
- qof_entity_release (&book->entity);
+ qof_instance_release (&book->inst);
g_hash_table_foreach_remove (book->hash_of_collections,
coll_destroy, NULL);
@@ -159,7 +153,7 @@
{
if (!book) return FALSE;
- return(book->dirty || qof_object_is_dirty (book));
+ return(book->inst.dirty || qof_object_is_dirty (book));
}
void
@@ -167,20 +161,13 @@
{
if (!book) return;
- book->dirty = FALSE;
+ book->inst.dirty = FALSE;
qof_object_mark_clean (book);
}
/* ====================================================================== */
/* getters */
-KvpFrame *
-qof_book_get_slots (QofBook *book)
-{
- if (!book) return NULL;
- return book->kvp_data;
-}
-
QofBackend *
qof_book_get_backend (QofBook *book)
{
@@ -209,7 +196,7 @@
void qof_book_kvp_changed (QofBook *book)
{
if (!book) return;
- book->dirty = TRUE;
+ book->inst.dirty = TRUE;
}
/* ====================================================================== */
@@ -352,8 +339,8 @@
gboolean qof_book_register (void)
{
static QofParam params[] = {
- { QOF_BOOK_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_book_get_slots, NULL },
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
+ { QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL },
{ NULL },
};
Index: gnc-pricedb.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-pricedb.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -Lsrc/engine/gnc-pricedb.c -Lsrc/engine/gnc-pricedb.c -u -r1.75 -r1.76
--- src/engine/gnc-pricedb.c
+++ src/engine/gnc-pricedb.c
@@ -27,7 +27,6 @@
#include <glib.h>
#include <string.h>
-#include "gnc-be-utils.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
@@ -37,6 +36,7 @@
#include "kvp-util.h"
#include "qofbackend-p.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofbook-p.h"
#include "qofclass.h"
@@ -154,7 +154,7 @@
void
gnc_price_begin_edit (GNCPrice *p)
{
- GNC_BEGIN_EDIT (&p->inst);
+ QOF_BEGIN_EDIT (&p->inst);
}
static inline void commit_err (QofInstance *inst, QofBackendError errcode)
@@ -167,8 +167,8 @@
void
gnc_price_commit_edit (GNCPrice *p)
{
- GNC_COMMIT_EDIT_PART1 (&p->inst);
- GNC_COMMIT_EDIT_PART2 (&p->inst, commit_err, noop, noop);
+ QOF_COMMIT_EDIT_PART1 (&p->inst);
+ QOF_COMMIT_EDIT_PART2 (&p->inst, commit_err, noop, noop);
}
/* ==================================================================== */
@@ -176,81 +176,14 @@
void
gnc_pricedb_begin_edit (GNCPriceDB *pdb)
{
- QofBackend *be;
-
- if (!pdb) return;
- pdb->editlevel++;
- if (1 < pdb->editlevel) return;
- ENTER ("pdb=%p\n", pdb);
-
- if (0 >= pdb->editlevel)
- {
- PERR ("unbalanced call - resetting (was %d)", pdb->editlevel);
- pdb->editlevel = 1;
- }
-
- /* See if there's a backend. If there is, invoke it. */
- be = xaccPriceDBGetBackend (pdb);
- if (be && be->begin)
- {
- (be->begin) (be, GNC_ID_PRICEDB, pdb);
- }
-
- LEAVE ("pdb=%p\n", pdb);
+ QOF_BEGIN_EDIT (&pdb->inst);
}
void
gnc_pricedb_commit_edit (GNCPriceDB *pdb)
{
- QofBackend *be;
- if (!pdb) return;
-
- pdb->editlevel--;
- if (0 < pdb->editlevel) return;
-
- ENTER ("pdb=%p\n", pdb);
- if (0 > pdb->editlevel)
- {
- PERR ("unbalanced call - resetting (was %d)", pdb->editlevel);
- pdb->editlevel = 0;
- }
-
- /* 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 .. */
- be = xaccPriceDBGetBackend (pdb);
- if (be && be->commit)
- {
- QofBackendError errcode;
-
- /* clear errors */
- do {
- 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 */
- if (TRUE == pdb->dirty)
- {
- if (be->begin)
- {
- (be->begin) (be, GNC_ID_PRICEDB, pdb);
- }
- }
-
- (be->commit) (be, GNC_ID_PRICEDB, pdb);
- errcode = qof_backend_get_error (be);
- if (ERR_BACKEND_NO_ERR != errcode)
- {
- /* XXX hack alert FIXME implement price rollback */
- PERR (" backend asked engine to rollback, but this isn't"
- " handled yet. Return code=%d", errcode);
-
- /* push error back onto the stack */
- qof_backend_set_error (be, errcode);
- }
- }
- pdb->dirty = FALSE;
-
- LEAVE ("pdb=%p\n", pdb);
+ QOF_COMMIT_EDIT_PART1 (&pdb->inst);
+ QOF_COMMIT_EDIT_PART2 (&pdb->inst, commit_err, noop, noop);
}
/* ==================================================================== */
@@ -270,7 +203,7 @@
remove_price (p->db, p, TRUE);
gnc_price_begin_edit (p);
p->commodity = c;
- if(p->db) p->db->dirty = TRUE;
+ if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
add_price (p->db, p);
gnc_price_unref (p);
@@ -292,7 +225,7 @@
remove_price (p->db, p, TRUE);
gnc_price_begin_edit (p);
p->currency = c;
- if(p->db) p->db->dirty = TRUE;
+ if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
add_price (p->db, p);
gnc_price_unref (p);
@@ -312,7 +245,7 @@
remove_price (p->db, p, FALSE);
gnc_price_begin_edit (p);
p->tmspec = t;
- if(p->db) p->db->dirty = TRUE;
+ if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
add_price (p->db, p);
gnc_price_unref (p);
@@ -333,7 +266,7 @@
tmp = g_cache_insert(cache, (gpointer) s);
if(p->source) g_cache_remove(cache, p->source);
p->source = tmp;
- if(p->db) p->db->dirty = TRUE;
+ if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
}
}
@@ -352,7 +285,7 @@
tmp = g_cache_insert(cache, (gpointer) type);
if(p->type) g_cache_remove(cache, p->type);
p->type = tmp;
- if(p->db) p->db->dirty = TRUE;
+ if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
}
}
@@ -365,7 +298,7 @@
{
gnc_price_begin_edit (p);
p->value = value;
- if(p->db) p->db->dirty = TRUE;
+ if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
}
}
@@ -623,10 +556,22 @@
g_return_val_if_fail (book, NULL);
+ /* There can only be one pricedb per book. So if one exits already,
+ * then use that. Warn user, they shouldn't be creating two ...
+ */
+ QofCollection *col = qof_book_get_collection (book, GNC_ID_PRICEDB);
+ result = qof_collection_get_data (col);
+ if (result)
+ {
+ PWARN ("A price database already exists for this book!");
+ return result;
+ }
+
result = g_new0(GNCPriceDB, 1);
- result->book = book;
- result->editlevel = 0;
- result->dirty = FALSE;
+ qof_instance_init (&result->inst, GNC_ID_PRICEDB, book);
+
+ qof_collection_set_data (col, result);
+
result->commodity_hash = g_hash_table_new(commodity_hash, commodity_equal);
g_return_val_if_fail (result->commodity_hash, NULL);
return result;
@@ -672,11 +617,16 @@
NULL);
g_hash_table_destroy (db->commodity_hash);
db->commodity_hash = NULL;
- db->book = NULL;
+ qof_instance_release (&db->inst);
g_free(db);
}
/* ==================================================================== */
+/* This is kind of weird, the way its done. Each collection of prices
+ * for a given commodity should get its own guid, be its own entity, etc.
+ * We really shouldn't be using the collection data. But, hey I guess its OK,
+ * yeah?
+ */
GNCPriceDB *
gnc_collection_get_pricedb(QofCollection *col)
@@ -689,50 +639,10 @@
{
QofCollection *col;
if (!book) return NULL;
- col = qof_book_get_collection (book, GNC_ID_PRICE);
+ col = qof_book_get_collection (book, GNC_ID_PRICEDB);
return gnc_collection_get_pricedb (col);
}
-void
-gnc_collection_set_pricedb(QofCollection *col, GNCPriceDB *db)
-{
- GNCPriceDB *old_db;
-
- if(!col) return;
-
- old_db = qof_collection_get_data (col);
- if (db == old_db) return;
-
- qof_collection_set_data (col, db);
- gnc_pricedb_destroy (old_db);
-}
-
-void
-gnc_pricedb_set_db(QofBook *book, GNCPriceDB *db)
-{
- QofCollection *col;
- if(!book) return;
- col = qof_book_get_collection (book, GNC_ID_PRICE);
- gnc_collection_set_pricedb (col, db);
- if (db) db->book = book;
-}
-
-/* ==================================================================== */
-
-gboolean
-gnc_pricedb_dirty(GNCPriceDB *p)
-{
- if(!p) return FALSE;
- return p->dirty;
-}
-
-void
-gnc_pricedb_mark_clean(GNCPriceDB *p)
-{
- if(!p) return;
- p->dirty = FALSE;
-}
-
/* ==================================================================== */
static gboolean
@@ -841,9 +751,7 @@
ENTER ("db=%p, pr=%p dirty=%d do-free=%d",
db, p, p->inst.dirty, p->inst.do_free);
- /* initialize the book pointer for the first time, if needed */
- if (NULL == db->book) db->book = p->inst.book;
- if (db->book != p->inst.book)
+ if (db->inst.book != p->inst.book)
{
PERR ("attempted to mix up prices across different books");
return FALSE;
@@ -897,7 +805,7 @@
if (TRUE == p->inst.dirty)
{
gnc_price_begin_edit(p);
- db->dirty = TRUE;
+ db->inst.dirty = TRUE;
gnc_price_commit_edit(p);
}
@@ -976,7 +884,7 @@
/* invoke the backend to delete this price */
gnc_price_begin_edit (p);
- db->dirty = TRUE;
+ db->inst.dirty = TRUE;
p->inst.do_free = TRUE;
gnc_price_commit_edit (p);
@@ -1001,14 +909,14 @@
ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency);
if(!db || !commodity || !currency) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_LATEST;
pl.prdb = db;
pl.commodity = commodity;
pl.currency = currency;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
@@ -1052,14 +960,14 @@
ENTER ("db=%p commodity=%p", db, commodity);
if(!db || !commodity) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_LATEST;
pl.prdb = db;
pl.commodity = commodity;
pl.currency = NULL; /* can the backend handle this??? */
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
@@ -1096,14 +1004,14 @@
ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency);
if(!db || !commodity) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_ALL;
pl.prdb = db;
pl.commodity = commodity;
pl.currency = currency;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
@@ -1142,7 +1050,7 @@
/* Convert to noon local time. */
t = timespecCanonicalDayTime(t);
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_AT_TIME;
@@ -1150,7 +1058,7 @@
pl.commodity = c;
pl.currency = currency;
pl.date = t;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
@@ -1210,7 +1118,7 @@
/* Convert to noon local time. */
t = timespecCanonicalDayTime(t);
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_AT_TIME;
@@ -1218,7 +1126,7 @@
pl.commodity = c;
pl.currency = NULL; /* can the backend handle this??? */
pl.date = t;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
@@ -1251,7 +1159,7 @@
ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
if(!db || !c || !currency) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_AT_TIME;
@@ -1259,7 +1167,7 @@
pl.commodity = c;
pl.currency = currency;
pl.date = t;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
@@ -1315,7 +1223,7 @@
ENTER ("db=%p commodity=%p", db, c);
if(!db || !c) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_AT_TIME;
@@ -1323,7 +1231,7 @@
pl.commodity = c;
pl.currency = NULL; /* can the backend handle this??? */
pl.date = t;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
@@ -1358,7 +1266,7 @@
ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
if(!db || !c || !currency) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_NEAREST_IN_TIME;
@@ -1366,7 +1274,7 @@
pl.commodity = c;
pl.currency = currency;
pl.date = t;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
@@ -1482,7 +1390,7 @@
ENTER ("db=%p commodity=%p", db, c);
if(!db || !c) return NULL;
- if (db->book && db->book->backend && db->book->backend->price_lookup)
+ if (db->inst.book->backend && db->inst.book->backend->price_lookup)
{
GNCPriceLookup pl;
pl.type = LOOKUP_NEAREST_IN_TIME;
@@ -1490,7 +1398,7 @@
pl.commodity = c;
pl.currency = NULL; /* can the backend handle this??? */
pl.date = t;
- (db->book->backend->price_lookup) (db->book->backend, &pl);
+ (db->inst.book->backend->price_lookup) (db->inst.book->backend, &pl);
}
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
@@ -1931,28 +1839,18 @@
}
/* ==================================================================== */
-
-QofBackend *
-xaccPriceDBGetBackend (GNCPriceDB *prdb)
-{
- if (!prdb || !prdb->book) return NULL;
- return prdb->book->backend;
-}
-
-/* ==================================================================== */
/* gncObject function implementation and registration */
static void
pricedb_book_begin (QofBook *book)
{
- gnc_pricedb_set_db (book, gnc_pricedb_create(book));
+ gnc_pricedb_create(book);
}
static void
pricedb_book_end (QofBook *book)
{
- /* unhook the prices */
- gnc_pricedb_set_db (book, NULL);
+ /* ????? */
}
static gboolean
Index: Transaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Transaction.c,v
retrieving revision 1.309
retrieving revision 1.310
diff -Lsrc/engine/Transaction.c -Lsrc/engine/Transaction.c -u -r1.309 -r1.310
--- src/engine/Transaction.c
+++ src/engine/Transaction.c
@@ -38,7 +38,6 @@
#include "TransactionP.h"
#include "TransLog.h"
#include "cap-gains.h"
-#include "gnc-be-utils.h"
#include "gnc-commodity.h"
#include "gnc-date.h"
#include "gnc-engine-util.h"
@@ -50,6 +49,7 @@
#include "messages.h"
#include "qofbackend-p.h"
+#include "qof-be-utils.h"
#include "qofbook.h"
#include "qofbook-p.h"
#include "qofclass.h"
@@ -1461,7 +1461,7 @@
void
xaccTransBeginEdit (Transaction *trans)
{
- GNC_BEGIN_EDIT(&trans->inst)
+ QOF_BEGIN_EDIT(&trans->inst)
if (qof_book_shutting_down(trans->inst.book))
return;
@@ -1560,7 +1560,7 @@
xaccTransCommitEdit (Transaction *trans)
{
QofBackend *be;
- GNC_COMMIT_EDIT_PART1 (&trans->inst);
+ QOF_COMMIT_EDIT_PART1 (&trans->inst);
/* We increment this for the duration of the call
* so other functions don't result in a recursive
@@ -1600,7 +1600,7 @@
if (!trans->splits) trans->inst.do_free = TRUE;
/* XXX the code below is almost identical to
- * GNC_COMMIT_EDIT_PART1 (&trans->inst);
+ * QOF_COMMIT_EDIT_PART1 (&trans->inst);
* except for the rollback bits */
/* See if there's a backend. If there is, invoke it. */
be = qof_book_get_backend (trans->inst.book);
@@ -1613,7 +1613,7 @@
errcode = qof_backend_get_error (be);
} while (ERR_BACKEND_NO_ERR != errcode);
- (be->commit) (be, GNC_ID_TRANS, trans);
+ (be->commit) (be, &(trans->inst));
errcode = qof_backend_get_error (be);
if (ERR_BACKEND_NO_ERR != errcode)
@@ -1682,7 +1682,7 @@
int i;
ENTER ("trans addr=%p\n", trans);
- GNC_COMMIT_EDIT_PART1(&trans->inst);
+ QOF_COMMIT_EDIT_PART1(&trans->inst);
/* We increment this for the duration of the call
* so other functions don't result in a recursive
@@ -1852,7 +1852,7 @@
errcode = qof_backend_get_error (be);
} while (ERR_BACKEND_NO_ERR != errcode);
- (be->rollback) (be, GNC_ID_TRANS, trans);
+ (be->rollback) (be, &(trans->inst));
errcode = qof_backend_get_error (be);
if (ERR_BACKEND_MOD_DESTROY == errcode)
Index: Group.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Group.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -Lsrc/engine/Group.h -Lsrc/engine/Group.h -u -r1.73 -r1.74
--- src/engine/Group.h
+++ src/engine/Group.h
@@ -59,7 +59,10 @@
*/
AccountGroup * xaccGetAccountGroup (QofBook *book);
-/** huh ?? */
+/**
+ * The xaccCollAccountGroup() routine will return the top-most
+ * account group associated with the indicated collection.
+ */
AccountGroup * xaccCollGetAccountGroup (QofCollection *col);
/** The xaccAccountDestroy() routine will destroy and free all
Index: qofinstance-p.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofinstance-p.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lsrc/engine/qofinstance-p.h -Lsrc/engine/qofinstance-p.h -u -r1.5 -r1.6
--- src/engine/qofinstance-p.h
+++ src/engine/qofinstance-p.h
@@ -73,7 +73,9 @@
/** In process of being destroyed */
gboolean do_free;
- /** This instance has not been saved yet */
+ /** dirty/clean flag. If dirty, then this instance has been modified,
+ * but has not yet been written out to storage (file/database)
+ */
gboolean dirty;
};
Index: qofbackend-p.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbackend-p.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lsrc/engine/qofbackend-p.h -Lsrc/engine/qofbackend-p.h -u -r1.3 -r1.4
--- src/engine/qofbackend-p.h
+++ src/engine/qofbackend-p.h
@@ -43,6 +43,7 @@
#include "qofbackend.h"
#include "qofbook.h"
+#include "qofinstance.h"
#include "qofquery.h"
#include "qofsession.h"
@@ -108,11 +109,11 @@
* to ERR_BACKEND_MOD_DESTROY from this routine, so that the
* engine can properly clean up.
*
- * The compile_query() method compiles a Gnucash query object into
+ * The compile_query() method compiles a QOF query object into
* a backend-specific data structure and returns the compiled
* query. For an SQL backend, the contents of the query object
- * need to be turned into a corresponding SQL query statement, and
- * sent to the database for evaluation.
+ * are typically turned into a corresponding SQL query statement,
+ * and sent to the database for evaluation.
*
* The free_query() method frees the data structure returned from
* compile_query()
@@ -234,9 +235,9 @@
void (*load) (QofBackend *, QofBook *);
- void (*begin) (QofBackend *, QofIdTypeConst, gpointer);
- void (*commit) (QofBackend *, QofIdTypeConst, gpointer);
- void (*rollback) (QofBackend *, QofIdTypeConst, gpointer);
+ void (*begin) (QofBackend *, QofInstance *);
+ void (*commit) (QofBackend *, QofInstance *);
+ void (*rollback) (QofBackend *, QofInstance *);
gpointer (*compile_query) (QofBackend *, QofQuery *);
void (*free_query) (QofBackend *, gpointer);
Index: Period.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Period.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lsrc/engine/Period.c -Lsrc/engine/Period.c -u -r1.59 -r1.60
--- src/engine/Period.c
+++ src/engine/Period.c
@@ -546,8 +546,8 @@
/* hack alert -- FIXME -- this should really be a merge, not a
* clobber copy, but I am too lazy to write a kvp merge routine,
* and it is not needed for the current usage. */
- kvp_frame_delete (dest_book->kvp_data);
- dest_book->kvp_data = kvp_frame_copy (src_book->kvp_data);
+ kvp_frame_delete (dest_book->inst.kvp_data);
+ dest_book->inst.kvp_data = kvp_frame_copy (src_book->inst.kvp_data);
/* Next, copy the commodity tables */
src_tbl = gnc_commodity_table_get_table (src_book);
@@ -598,11 +598,11 @@
/* Make note of the sibling books */
now = time(0);
- gnc_kvp_bag_add (src_book->kvp_data, "gemini", now,
- "book_guid", &dest_book->entity.guid,
+ gnc_kvp_bag_add (src_book->inst.kvp_data, "gemini", now,
+ "book_guid", &dest_book->inst.entity.guid,
NULL);
- gnc_kvp_bag_add (dest_book->kvp_data, "gemini", now,
- "book_guid", &src_book->entity.guid,
+ gnc_kvp_bag_add (dest_book->inst.kvp_data, "gemini", now,
+ "book_guid", &src_book->inst.entity.guid,
NULL);
LEAVE (" ");
}
@@ -693,7 +693,7 @@
xaccAccountBeginEdit (twin);
cwd = xaccAccountGetSlots (twin);
kvp_frame_set_guid (cwd, "/book/prev-acct", xaccAccountGetGUID (candidate));
- kvp_frame_set_guid (cwd, "/book/prev-book", &closed_book->entity.guid);
+ kvp_frame_set_guid (cwd, "/book/prev-book", &closed_book->inst.entity.guid);
xaccAccountSetSlots_nc (twin, twin->inst.kvp_data);
@@ -702,7 +702,7 @@
* the next book is. */
xaccAccountBeginEdit (candidate);
cwd = xaccAccountGetSlots (candidate);
- kvp_frame_set_guid (cwd, "/book/next-book", &open_book->entity.guid);
+ kvp_frame_set_guid (cwd, "/book/next-book", &open_book->inst.entity.guid);
kvp_frame_set_guid (cwd, "/book/next-acct", xaccAccountGetGUID (twin));
xaccAccountSetSlots_nc (candidate, candidate->inst.kvp_data);
@@ -760,7 +760,7 @@
/* Add KVP data showing where the balancing
* transaction came from */
cwd = xaccTransGetSlots (trans);
- kvp_frame_set_guid (cwd, "/book/closed-book", &closed_book->entity.guid);
+ kvp_frame_set_guid (cwd, "/book/closed-book", &closed_book->inst.entity.guid);
kvp_frame_set_guid (cwd, "/book/closed-acct", xaccAccountGetGUID(candidate));
xaccTransCommitEdit (trans);
@@ -805,7 +805,7 @@
be = src_book->backend;
if (be && be->begin)
{
- (*be->begin)(be, GNC_ID_PERIOD, dest_book);
+ // (*be->begin)(be, GNC_ID_PERIOD, dest_book);
}
}
@@ -816,7 +816,7 @@
be = src_book->backend;
if (be && be->commit)
{
- (*be->commit)(be, GNC_ID_PERIOD, dest_book);
+ // (*be->commit)(be, GNC_ID_PERIOD, dest_book);
}
}
@@ -870,8 +870,8 @@
/* Now add the various identifying kvp's */
/* cwd == 'current working directory' */
- exist_cwd = existing_book->kvp_data;
- partn_cwd = closing_book->kvp_data;
+ exist_cwd = existing_book->inst.kvp_data;
+ partn_cwd = closing_book->inst.kvp_data;
/* Mark the boundary date between the books */
kvp_frame_set_timespec (exist_cwd, "/book/open-date", calve_date);
@@ -883,8 +883,8 @@
kvp_frame_set_timespec (partn_cwd, "/book/log-date", ts);
/* Set up pointers to each book from the other. */
- kvp_frame_set_guid (partn_cwd, "/book/next-book", &existing_book->entity.guid);
- kvp_frame_set_guid (exist_cwd, "/book/prev-book", &closing_book->entity.guid);
+ kvp_frame_set_guid (partn_cwd, "/book/next-book", &existing_book->inst.entity.guid);
+ kvp_frame_set_guid (exist_cwd, "/book/prev-book", &closing_book->inst.entity.guid);
/* add in transactions to equity accounts that will
* hold the colsing balances */
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Makefile.am,v
retrieving revision 1.120
retrieving revision 1.121
diff -Lsrc/engine/Makefile.am -Lsrc/engine/Makefile.am -u -r1.120 -r1.121
--- src/engine/Makefile.am
+++ src/engine/Makefile.am
@@ -77,7 +77,6 @@
engine-helpers.h \
glib-helpers.h \
gnc-associate-account.h \
- gnc-be-utils.h \
gnc-book.h \
gnc-commodity.h \
gnc-date.h \
@@ -98,6 +97,7 @@
policy.h \
qof.h \
qofbackend.h \
+ qof-be-utils.h \
qofbook.h \
qofclass.h \
qofid.h \
Index: qofbook-p.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook-p.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -Lsrc/engine/qofbook-p.h -Lsrc/engine/qofbook-p.h -u -r1.8 -r1.9
--- src/engine/qofbook-p.h
+++ src/engine/qofbook-p.h
@@ -41,16 +41,13 @@
#include "qofbook.h"
#include "qofid.h"
#include "qofid-p.h"
+#include "qofinstance-p.h"
/** Book structure */
struct _QofBook
{
- QofEntity entity; /**< Unique guid for this book. */
+ QofInstance inst; /**< Unique guid for this book. */
- /** The KvpFrame provides a place for top-level data associated
- * with this book. */
- KvpFrame *kvp_data;
-
/** The entity table associates the GUIDs of all the objects
* belonging to this book, with their pointers to the respective
* objects. This allows a lookup of objects based on thier guid.
@@ -67,17 +64,14 @@
/** state flag: 'y' means 'open for editing',
* 'n' means 'book is closed'
+ * xxxxx shouldn't this be replaced by the instance editlevel ???
*/
char book_open;
- /** dirty/clean flag. If dirty, then this book has been modified,
- * but has not yet been written out to storage (file/database)
- */
- gboolean dirty;
-
/** a flag denoting whether the book is closing down, used to
* help the QOF objects shut down cleanly without maintaining
* internal consistency.
+ * XXX shouldn't this be replaced by instance->do_free ???
*/
gboolean shutting_down;
--- src/engine/gnc-be-utils.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/********************************************************************\
- * 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 at gnu.org *
- * *
-\********************************************************************/
-/*
- * gnc-be-utils.h -- QOF Backend Utilities
- * common code used by objects to define begin_edit() and
- * commit_edit() functions.
- *
- * Written by: Derek Atkins <derek at ihtfp.com>
- *
- */
-
-#ifndef GNC_BE_UTILS_H
-#define GNC_BE_UTILS_H
-
-#include "gnc-engine-util.h"
-#include "qofbackend-p.h"
-#include "qofbook.h"
-
-/* begin_edit helper
- *
- * @args:
- * inst: an instance of QofInstance
- *
- * The caller should use this macro first and then perform any other operations.
- */
-
-#define GNC_BEGIN_EDIT(inst) \
- QofBackend * be; \
- if (!(inst)) return; \
- \
- (inst)->editlevel++; \
- if (1 < (inst)->editlevel) return; \
- \
- if (0 >= (inst)->editlevel) \
- { \
- PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
- (inst)->editlevel = 1; \
- } \
- ENTER ("inst=%p", (inst)); \
- \
- /* See if there's a backend. If there is, invoke it. */ \
- be = qof_book_get_backend ((inst)->book); \
- if (be && be->begin) { \
- (be->begin) (be, (inst)->entity.e_type, (inst)); \
- } else { \
- /* We tried and failed to start transaction! */ \
- (inst)->dirty = TRUE; \
- }
-
-
-/*
- * commit_edit helpers
- *
- * The caller should call PART1 as the first thing, then
- * perform any local operations prior to calling the backend.
- * Then call PART2.
- */
-
-/*
- * part1 -- deal with the editlevel
- *
- * @args:
- * inst: an instance of QofInstance
- */
-
-#define GNC_COMMIT_EDIT_PART1(inst) { \
- if (!(inst)) return; \
- \
- (inst)->editlevel--; \
- if (0 < (inst)->editlevel) return; \
- \
- /* The pricedb sufffers from delayed update... */ \
- /* This may be setting a bad precedent for other types, I fear. */ \
- /* Other types probably really should handle begin like this. */ \
- if ((-1 == (inst)->editlevel) && (inst)->dirty) \
- { \
- QofBackend * be; \
- be = qof_book_get_backend ((inst)->book); \
- if (be && be->begin) { \
- (be->begin) (be, (inst)->entity.e_type, (inst)); \
- } \
- (inst)->editlevel = 0; \
- } \
- if (0 > (inst)->editlevel) \
- { \
- PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
- (inst)->editlevel = 0; \
- } \
- ENTER ("inst=%p, dirty=%d do-free=%d", \
- (inst), (inst)->dirty, (inst)->do_free); \
-}
-
-/*
- * part2 -- deal with the backend
- *
- * @args:
- * inst: an instance of QofInstance
- * on_error: a function called if there is a backend error.
- * void (*on_error)(inst, QofBackendError)
- * on_done: a function called after the commit is complete
- * but before the instect is freed. Perform any other
- * operations after the commit.
- * void (*on_done)(inst)
- * on_free: a function called if inst->do_free is TRUE.
- * void (*on_free)(inst)
- */
-#define GNC_COMMIT_EDIT_PART2(inst,on_error,on_done,on_free) { \
- QofBackend * be; \
- \
- /* See if there's a backend. If there is, invoke it. */ \
- be = qof_book_get_backend ((inst)->book); \
- if (be && be->commit) \
- { \
- QofBackendError errcode; \
- \
- /* clear errors */ \
- do { \
- errcode = qof_backend_get_error (be); \
- } while (ERR_BACKEND_NO_ERR != errcode); \
- \
- (be->commit) (be, (inst)->entity.e_type, (inst)); \
- errcode = qof_backend_get_error (be); \
- if (ERR_BACKEND_NO_ERR != errcode) \
- { \
- /* XXX Should perform a rollback here */ \
- (inst)->do_free = FALSE; \
- \
- /* Push error back onto the stack */ \
- qof_backend_set_error (be, errcode); \
- (on_error)((inst), errcode); \
- } \
- /* XXX the backend commit code should clear dirty!! */ \
- (inst)->dirty = FALSE; \
- } \
- (on_done)(inst); \
- \
- LEAVE ("inst=%p, dirty=%d do-free=%d", \
- (inst), (inst)->dirty, (inst)->do_free); \
- if ((inst)->do_free) { \
- (on_free)(inst); \
- return; \
- } \
-}
-
-
-#endif /* GNC_BE_UTILS_H */
More information about the gnucash-changes
mailing list