mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-01 21:19:16 -06:00
start removing accounting-specific structures (i.e. Account, Transaction)
from the backend, and from the session; goal is a generic backend. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8567 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2b2b0cc557
commit
63519bdf21
@ -29,8 +29,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "AccountP.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "Group.h"
|
||||
#include "GroupP.h"
|
||||
#include "TransactionP.h"
|
||||
#include "gnc-book.h"
|
||||
@ -3146,6 +3148,15 @@ xaccAccountFindTransByDesc(Account *account, const char *description)
|
||||
return( trans );
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
Backend *
|
||||
xaccAccountGetBackend (Account * acc)
|
||||
{
|
||||
if (!acc || !acc->book) return NULL;
|
||||
return acc->book->backend;
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
/* gncObject function implementation and registration */
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "Backend.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-engine.h"
|
||||
@ -204,6 +205,13 @@ void xaccFreeAccount (Account *account);
|
||||
void xaccAccountSetVersion (Account*, gint32);
|
||||
gint32 xaccAccountGetVersion (Account*);
|
||||
|
||||
/*
|
||||
* The xaccGetAccountBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with this account.
|
||||
*/
|
||||
|
||||
Backend * xaccAccountGetBackend (Account *account);
|
||||
|
||||
/* Register Accounts with the engine */
|
||||
gboolean xaccAccountRegister (void);
|
||||
|
||||
|
@ -25,17 +25,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "Account.h"
|
||||
#include "AccountP.h"
|
||||
#include "BackendP.h"
|
||||
#include "Group.h"
|
||||
#include "GroupP.h"
|
||||
#include "gnc-book-p.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-pricedb.h"
|
||||
#include "gnc-pricedb-p.h"
|
||||
#include "TransactionP.h"
|
||||
#include "messages.h"
|
||||
|
||||
/* static short module = MOD_ENGINE; */
|
||||
|
||||
@ -103,40 +93,6 @@ xaccBackendGetMessage (Backend *be) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* Fetch the backend *
|
||||
\********************************************************************/
|
||||
|
||||
Backend *
|
||||
xaccAccountGetBackend (Account * acc)
|
||||
{
|
||||
if (!acc || !acc->book) return NULL;
|
||||
return acc->book->backend;
|
||||
}
|
||||
|
||||
Backend *
|
||||
xaccGroupGetBackend (AccountGroup *grp)
|
||||
{
|
||||
grp = xaccGroupGetRoot (grp);
|
||||
if (!grp || !grp->book) return NULL;
|
||||
return grp->book->backend;
|
||||
}
|
||||
|
||||
Backend *
|
||||
xaccPriceDBGetBackend (GNCPriceDB *prdb)
|
||||
{
|
||||
if (!prdb || !prdb->book) return NULL;
|
||||
return prdb->book->backend;
|
||||
}
|
||||
|
||||
Backend *
|
||||
xaccTransactionGetBackend (Transaction *trans)
|
||||
{
|
||||
if (!trans || !trans->book) return NULL;
|
||||
return trans->book->backend;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
/* Get a clean backend */
|
||||
void
|
||||
|
@ -42,12 +42,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "Backend.h"
|
||||
#include "Group.h"
|
||||
#include "Query.h"
|
||||
#include "Transaction.h"
|
||||
#include "gnc-session.h"
|
||||
|
||||
#include "gnc-pricedb.h"
|
||||
|
||||
/*
|
||||
@ -283,18 +281,11 @@ void xaccBackendSetMessage(Backend *be, const char *format, ...);
|
||||
char * xaccBackendGetMessage(Backend *be);
|
||||
|
||||
/*
|
||||
* The xaccGetAccountBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with this account.
|
||||
*
|
||||
* The xaccGetTransactionBackend() subroutine does the same, for a given
|
||||
* transaction.
|
||||
* The xaccGNCBookGetBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with
|
||||
* this book.
|
||||
*/
|
||||
|
||||
Backend * xaccAccountGetBackend (Account *account);
|
||||
Backend * xaccTransactionGetBackend (Transaction *trans);
|
||||
Backend * xaccGroupGetBackend (AccountGroup *group);
|
||||
Backend * xaccGNCBookGetBackend (GNCBook *book);
|
||||
Backend * xaccPriceDBGetBackend (GNCPriceDB *prdb);
|
||||
|
||||
void xaccInitBackend(Backend *be);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "Account.h"
|
||||
#include "AccountP.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "Group.h"
|
||||
@ -1276,6 +1277,16 @@ xaccGroupForEachAccount (AccountGroup *grp,
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
Backend *
|
||||
xaccGroupGetBackend (AccountGroup *grp)
|
||||
{
|
||||
grp = xaccGroupGetRoot (grp);
|
||||
if (!grp || !grp->book) return NULL;
|
||||
return grp->book->backend;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* gncObject function implementation and registration */
|
||||
|
||||
|
@ -90,13 +90,18 @@ void xaccGroupRemoveAccount (AccountGroup *grp, Account *account);
|
||||
|
||||
/*
|
||||
* The xaccFreeAccountGroup() subroutine will ...
|
||||
*
|
||||
*/
|
||||
void xaccFreeAccountGroup (AccountGroup *account_group);
|
||||
|
||||
/* Set the top-level group in the book */
|
||||
void xaccSetAccountGroup (GNCBook *book, AccountGroup *grp);
|
||||
|
||||
/*
|
||||
* The xaccGroupGetBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with this account group.
|
||||
*/
|
||||
Backend * xaccGroupGetBackend (AccountGroup *group);
|
||||
|
||||
gboolean xaccGroupRegister (void);
|
||||
|
||||
#endif
|
||||
|
@ -40,6 +40,7 @@ Open questions: how do we deal with the backends ???
|
||||
#include "gnc-book-p.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "Group.h"
|
||||
#include "GroupP.h"
|
||||
#include "kvp-util-p.h"
|
||||
#include "Period.h"
|
||||
@ -202,8 +203,8 @@ gnc_book_partition (GNCBook *dest_book, GNCBook *src_book, Query *query)
|
||||
/* hack alert -- FIXME -- this should really be a merge, not a
|
||||
* clobber copy, but I am too lazy to write an account-group merge
|
||||
* routine, and it is not needed for the current usage. */
|
||||
src_grp = gnc_book_get_group (src_book);
|
||||
dst_grp = gnc_book_get_group (dest_book);
|
||||
src_grp = xaccGetAccountGroup (src_book);
|
||||
dst_grp = xaccGetAccountGroup (dest_book);
|
||||
xaccAccountGroupBeginEdit (dst_grp);
|
||||
xaccAccountGroupBeginEdit (src_grp);
|
||||
xaccGroupCopyGroup (dst_grp, src_grp);
|
||||
@ -488,7 +489,7 @@ gnc_book_close_period (GNCBook *existing_book, Timespec calve_date,
|
||||
|
||||
/* add in transactions to equity accounts that will
|
||||
* hold the colsing balances */
|
||||
add_closing_balances (gnc_book_get_group(closing_book),
|
||||
add_closing_balances (xaccGetAccountGroup(closing_book),
|
||||
existing_book, closing_book,
|
||||
equity_account,
|
||||
&calve_date, &ts, memo);
|
||||
|
@ -32,7 +32,11 @@
|
||||
#ifndef GNC_SX_BOOK_H
|
||||
#define GNC_SX_BOOK_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gnc-book.h"
|
||||
#include "gnc-engine.h"
|
||||
|
||||
typedef struct xaccSchedXactionsDef SchedXactions;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "AccountP.h"
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "Group.h"
|
||||
@ -3288,6 +3289,18 @@ xaccTransGetVoidTime(const Transaction *tr)
|
||||
return void_time;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
Backend *
|
||||
xaccTransactionGetBackend (Transaction *trans)
|
||||
{
|
||||
if (!trans || !trans->book) return NULL;
|
||||
return trans->book->backend;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
/* gncObject function implementation */
|
||||
static void
|
||||
do_foreach (GNCBook *book, GNCIdType type, foreachObjectCB cb, gpointer ud)
|
||||
|
@ -45,10 +45,13 @@
|
||||
#ifndef XACC_TRANSACTION_P_H
|
||||
#define XACC_TRANSACTION_P_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "Backend.h"
|
||||
#include "gnc-book.h"
|
||||
#include "gnc-engine.h" /* for typedefs */
|
||||
#include "gnc-numeric.h"
|
||||
#include "GNCIdP.h"
|
||||
@ -247,5 +250,11 @@ gnc_commodity * xaccTransFindOldCommonCurrency (Transaction *trans,
|
||||
gboolean xaccSplitRegister (void);
|
||||
gboolean xaccTransRegister (void);
|
||||
|
||||
/*
|
||||
* The xaccTransactionGetBackend() subroutine will find the
|
||||
* persistent-data storage backend associated with this
|
||||
* transaction.
|
||||
*/
|
||||
Backend * xaccTransactionGetBackend (Transaction *trans);
|
||||
|
||||
#endif /* XACC_TRANSACTION_P_H */
|
||||
|
@ -1912,6 +1912,15 @@ gnc_pricedb_print_contents(GNCPriceDB *db, FILE *f)
|
||||
fprintf(f, "</gnc:pricedb>\n");
|
||||
}
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
Backend *
|
||||
xaccPriceDBGetBackend (GNCPriceDB *prdb)
|
||||
{
|
||||
if (!prdb || !prdb->book) return NULL;
|
||||
return prdb->book->backend;
|
||||
}
|
||||
|
||||
/* ==================================================================== */
|
||||
/* gncObject function implementation and registration */
|
||||
|
||||
|
@ -45,14 +45,12 @@
|
||||
|
||||
#include "BackendP.h"
|
||||
#include "TransLog.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-book-p.h"
|
||||
#include "gnc-date.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-session-p.h"
|
||||
#include "gnc-trace.h"
|
||||
|
||||
static GNCSession * current_session = NULL;
|
||||
static short module = MOD_IO;
|
||||
@ -517,31 +515,6 @@ gnc_session_load (GNCSession *session,
|
||||
xaccLogEnable();
|
||||
}
|
||||
|
||||
/* Technically, the following tests can never succeed, because a group
|
||||
* and pricedb is always allocated when a book is created. So even
|
||||
* if the load fails, there will be a topgroup and a pricedb. */
|
||||
if (!gnc_book_get_group (newbook))
|
||||
{
|
||||
/* Something broke, put back the old stuff */
|
||||
gnc_book_set_backend (newbook, NULL);
|
||||
gnc_book_destroy (newbook);
|
||||
g_list_free (session->books);
|
||||
session->books = oldbooks;
|
||||
PERR("topgroup NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gnc_book_get_pricedb (newbook))
|
||||
{
|
||||
/* Something broke, put back the old stuff */
|
||||
gnc_book_set_backend (newbook, NULL);
|
||||
gnc_book_destroy (newbook);
|
||||
g_list_free (session->books);
|
||||
session->books = oldbooks;
|
||||
PERR("pricedb NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
err = gnc_session_get_error(session);
|
||||
if ((err != ERR_BACKEND_NO_ERR) &&
|
||||
(err != ERR_FILEIO_FILE_TOO_OLD) &&
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <glib.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "Group.h"
|
||||
#include "GroupP.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "TransLog.h"
|
||||
|
Loading…
Reference in New Issue
Block a user