Move entity tables from sessions to books.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6018 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-11-24 12:10:42 +00:00
parent 277282f25c
commit 860adf103c
120 changed files with 899 additions and 951 deletions

View File

@ -233,7 +233,7 @@ gnc_cm_event_handler (GUID *entity,
add_event (&changes, entity, event_type, TRUE);
id_type = xaccGUIDType (entity, gnc_get_current_session ());
id_type = xaccGUIDType (entity, gnc_get_current_book ());
switch (id_type)
{
case GNC_ID_TRANS:

View File

@ -32,15 +32,21 @@
#include <stdio.h>
#include <string.h>
#include "Transaction.h"
#include "global-options.h"
#include "Account.h"
#include "gnc-book.h"
#include "gnc-component-manager.h"
#include "gnc-engine-util.h"
#include "gnc-engine.h"
#include "gnc-euro.h"
#include "gnc-module.h"
#include "gnc-session.h"
#include "gnc-ui-util.h"
#include "Group.h"
#include "messages.h"
#include "Transaction.h"
static short module = MOD_GUI;
@ -804,7 +810,7 @@ Account *
gnc_find_or_create_equity_account (AccountGroup *group,
GNCEquityType equity_type,
gnc_commodity *currency,
GNCSession *session)
GNCBook *book)
{
Account *parent;
Account *account;
@ -870,7 +876,7 @@ gnc_find_or_create_equity_account (AccountGroup *group,
if (parent && xaccAccountGetType (parent) != EQUITY)
parent == NULL;
account = xaccMallocAccount (session);
account = xaccMallocAccount (book);
xaccAccountBeginEdit (account);
@ -898,7 +904,7 @@ gboolean
gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
time_t date,
GNCSession *session)
GNCBook *book)
{
Account *equity_account;
Transaction *trans;
@ -913,14 +919,14 @@ gnc_account_create_opening_balance (Account *account,
gnc_find_or_create_equity_account (xaccAccountGetRoot (account),
EQUITY_OPENING_BALANCE,
xaccAccountGetCommodity (account),
session);
book);
if (!equity_account)
return FALSE;
xaccAccountBeginEdit (account);
xaccAccountBeginEdit (equity_account);
trans = xaccMallocTransaction (session);
trans = xaccMallocTransaction (book);
xaccTransBeginEdit (trans);
@ -928,7 +934,7 @@ gnc_account_create_opening_balance (Account *account,
xaccTransSetDateSecs (trans, date);
xaccTransSetDescription (trans, _("Opening Balance"));
split = xaccMallocSplit (session);
split = xaccMallocSplit (book);
xaccTransAppendSplit (trans, split);
xaccAccountInsertSplit (account, split);
@ -938,7 +944,7 @@ gnc_account_create_opening_balance (Account *account,
balance = gnc_numeric_neg (balance);
split = xaccMallocSplit (session);
split = xaccMallocSplit (book);
xaccTransAppendSplit (trans, split);
xaccAccountInsertSplit (equity_account, split);

View File

@ -28,6 +28,9 @@
#include <glib.h>
#include <locale.h>
#include "Account.h"
#include "gnc-engine.h"
#include "Group.h"
#include "gnc-session.h"
@ -98,11 +101,11 @@ typedef enum
Account * gnc_find_or_create_equity_account (AccountGroup *group,
GNCEquityType equity_type,
gnc_commodity *currency,
GNCSession *session);
GNCBook *book);
gboolean gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
time_t date,
GNCSession *session);
GNCBook *book);
char * gnc_account_get_full_name (Account *account);

View File

@ -399,7 +399,7 @@ gnc_copy_split(Split *split, gboolean use_cut_semantics)
\********************************************************************/
void
gnc_copy_split_scm_onto_split(SCM split_scm, Split *split,
GNCSession *session)
GNCBook * book)
{
static SCM split_type = SCM_UNDEFINED;
SCM result;
@ -412,7 +412,7 @@ gnc_copy_split_scm_onto_split(SCM split_scm, Split *split,
if (split == NULL)
return;
g_return_if_fail (session);
g_return_if_fail (book);
func = gh_eval_str("gnc:split-scm?");
if (!gh_procedure_p(func))
@ -434,7 +434,7 @@ gnc_copy_split_scm_onto_split(SCM split_scm, Split *split,
arg = gw_wcp_assimilate_ptr(split, split_type);
gh_call3(func, split_scm, arg, gnc_session_to_scm (session));
gh_call3(func, split_scm, arg, gnc_book_to_scm (book));
}
@ -773,10 +773,10 @@ gnc_copy_trans(Transaction *trans, gboolean use_cut_semantics)
\********************************************************************/
void
gnc_copy_trans_scm_onto_trans(SCM trans_scm, Transaction *trans,
gboolean do_commit, GNCSession *session)
gboolean do_commit, GNCBook *book)
{
gnc_copy_trans_scm_onto_trans_swap_accounts(trans_scm, trans, NULL, NULL,
do_commit, session);
do_commit, book);
}
@ -799,7 +799,7 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
const GUID *guid_1,
const GUID *guid_2,
gboolean do_commit,
GNCSession *session)
GNCBook *book)
{
static SCM trans_type = SCM_UNDEFINED;
SCM result;
@ -812,7 +812,7 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
if (trans == NULL)
return;
g_return_if_fail (session);
g_return_if_fail (book);
func = gh_eval_str("gnc:transaction-scm?");
if (!gh_procedure_p(func))
@ -841,7 +841,7 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
commit = gh_bool2scm(do_commit);
args = gh_cons(gnc_session_to_scm (session), args);
args = gh_cons(gnc_book_to_scm (book), args);
args = gh_cons(commit, args);
args = gh_cons(SCM_EOL, args);
args = gh_cons(arg, args);
@ -857,7 +857,7 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
SCM commit;
char *guid_str;
args = gh_cons(gnc_session_to_scm (session), args);
args = gh_cons(gnc_book_to_scm (book), args);
commit = gh_bool2scm(do_commit);

View File

@ -55,7 +55,7 @@ gboolean gnc_is_trans_scm(SCM scm);
SCM gnc_copy_split(Split *split, gboolean use_cut_semantics);
void gnc_copy_split_scm_onto_split(SCM split_scm, Split *split,
GNCSession *session);
GNCBook *book);
void gnc_split_scm_set_account(SCM split_scm, Account *account);
void gnc_split_scm_set_memo(SCM split_scm, const char *memo);
@ -71,13 +71,13 @@ gnc_numeric gnc_split_scm_get_value(SCM split_scm);
SCM gnc_copy_trans(Transaction *trans, gboolean use_cut_semantics);
void gnc_copy_trans_scm_onto_trans(SCM trans_scm, Transaction *trans,
gboolean do_commit, GNCSession *session);
gboolean do_commit, GNCBook *book);
void gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
Transaction *trans,
const GUID *guid_1,
const GUID *guid_2,
gboolean do_commit,
GNCSession *session);
GNCBook *book);
void gnc_trans_scm_set_date(SCM trans_scm, Timespec *ts);
void gnc_trans_scm_set_num(SCM trans_scm, const char *num);

View File

@ -487,7 +487,7 @@
(define (convert-to-account item)
(if (string? item)
(gnc:account-lookup item (gnc:get-current-session))
(gnc:account-lookup item (gnc:get-current-book))
item))
(let* ((option (map convert-to-guid (default-getter)))
@ -511,7 +511,7 @@
(set! account-list
(filter (lambda (x) (if (string? x)
(gnc:account-lookup
x (gnc:get-current-session))
x (gnc:get-current-book))
x)) account-list))
(let* ((result (validator account-list))
(valid (car result))

View File

@ -126,7 +126,7 @@ gnc_account_dom_tree_create(Account *act)
struct account_pdata
{
Account *account;
GNCSession *session;
GNCBook *book;
};
static gboolean
@ -212,7 +212,7 @@ account_currency_handler (xmlNodePtr node, gpointer act_pdata)
gnc_commodity *ref;
ref = dom_tree_to_commodity_ref_no_engine(node);
DxaccAccountSetCurrency(pdata->account, ref, pdata->session);
DxaccAccountSetCurrency(pdata->account, ref, pdata->book);
return TRUE;
}
@ -236,7 +236,7 @@ account_security_handler (xmlNodePtr node, gpointer act_pdata)
gnc_commodity *ref;
ref = dom_tree_to_commodity_ref_no_engine(node);
DxaccAccountSetSecurity(pdata->account, ref, pdata->session);
DxaccAccountSetSecurity(pdata->account, ref, pdata->book);
return TRUE;
}
@ -277,7 +277,7 @@ account_parent_handler (xmlNodePtr node, gpointer act_pdata)
gid = dom_tree_to_guid(node);
g_return_val_if_fail(gid, FALSE);
parent = xaccAccountLookup(gid, pdata->session);
parent = xaccAccountLookup(gid, pdata->book);
if (!parent)
{
g_free (gid);
@ -335,7 +335,7 @@ gnc_account_end_handler(gpointer data_for_children,
xmlNodePtr achild;
xmlNodePtr tree = (xmlNodePtr)data_for_children;
gxpf_data *gdata = (gxpf_data*)global_data;
GNCSession *session = gdata->sessiondata;
GNCBook *book = gdata->bookdata;
successful = TRUE;
@ -353,7 +353,7 @@ gnc_account_end_handler(gpointer data_for_children,
g_return_val_if_fail(tree, FALSE);
acc = dom_tree_to_account(tree, session);
acc = dom_tree_to_account(tree, book);
if(acc != NULL)
{
gdata->cb(tag, gdata->parsedata, acc);
@ -371,17 +371,17 @@ gnc_account_end_handler(gpointer data_for_children,
}
Account*
dom_tree_to_account (xmlNodePtr node, GNCSession * session)
dom_tree_to_account (xmlNodePtr node, GNCBook *book)
{
struct account_pdata act_pdata;
Account *accToRet;
gboolean successful;
accToRet = xaccMallocAccount(session);
accToRet = xaccMallocAccount(book);
xaccAccountBeginEdit(accToRet);
act_pdata.account = accToRet;
act_pdata.session = session;
act_pdata.book = book;
successful = dom_tree_generic_parse (node, account_handlers_v2,
&act_pdata);

View File

@ -124,7 +124,7 @@ file_load_file(Backend *be)
}
static void
file_book_load (Backend *be)
file_book_load (Backend *be, GNCBook *book)
{
if (!file_load_file(be))
{

View File

@ -122,7 +122,7 @@ struct uiFreqTypeTuple uiFreqTypeStrs[] = {
typedef struct
{
FreqSpec *fs; /* FreqSpec we're parsing into. */
GNCSession *session; /* Session we're loading into. */
GNCBook *book; /* Book we're loading into. */
/* fields used in the union of unions... :) */
GDate once_day; /* once */
@ -138,7 +138,7 @@ fspd_init( fsParseData *fspd )
{
fspd->fs = NULL;
fspd->list = NULL;
fspd->session = NULL;
fspd->book = NULL;
fspd->interval
= fspd->offset
= fspd->day
@ -398,7 +398,7 @@ fs_subelement_handler( xmlNodePtr node, gpointer data )
fsParseData *fspd = data;
FreqSpec *fs;
gboolean successful;
fs = dom_tree_to_freqSpec( node, fspd->session );
fs = dom_tree_to_freqSpec( node, fspd->book );
if ( fs == NULL )
return FALSE;
fspd->list = g_list_append( fspd->list, fs );
@ -558,7 +558,7 @@ gnc_freqSpec_end_handler(gpointer data_for_children,
sixtp_gdv2 *globaldata = (sixtp_gdv2*)global_data;
fspd_init( &fspd );
fspd.session = globaldata->session;
fspd.book = globaldata->book;
/* this won't actually get invoked [FreqSpecs aren't top-level
elements]; see dom_tree_to_freqSpec(), below. */
@ -570,7 +570,7 @@ gnc_freqSpec_end_handler(gpointer data_for_children,
g_return_val_if_fail( tree, FALSE );
fspd.fs = xaccFreqSpecMalloc(globaldata->session);
fspd.fs = xaccFreqSpecMalloc(globaldata->book);
successful = dom_tree_generic_parse( tree, fs_dom_handlers, &fspd );
if (!successful) {
xmlElemDump( stdout, NULL, tree );
@ -589,15 +589,15 @@ gnc_freqSpec_sixtp_parser_create(void)
}
FreqSpec*
dom_tree_to_freqSpec(xmlNodePtr node, GNCSession *session)
dom_tree_to_freqSpec(xmlNodePtr node, GNCBook *book)
{
gboolean successful;
fsParseData fspd;
fspd_init( &fspd );
fspd.session = session;
fspd.book = book;
fspd.fs = xaccFreqSpecMalloc(session);
fspd.fs = xaccFreqSpecMalloc(book);
successful = dom_tree_generic_parse( node, fs_dom_handlers, &fspd );
if ( !successful ) {
xmlElemDump(stdout, NULL, node);

View File

@ -87,7 +87,7 @@ static short module = MOD_ENGINE;
*/
static gboolean
price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, GNCSession *session)
price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, GNCBook *book)
{
if(!p || !sub_node) return FALSE;
@ -98,11 +98,11 @@ price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, GNCSession *session)
gnc_price_set_guid(p, c);
g_free(c);
} else if(safe_strcmp("price:commodity", sub_node->name) == 0) {
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, session);
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, book);
if(!c) return FALSE;
gnc_price_set_commodity(p, c);
} else if(safe_strcmp("price:currency", sub_node->name) == 0) {
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, session);
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, book);
if(!c) return FALSE;
gnc_price_set_currency(p, c);
} else if(safe_strcmp("price:time", sub_node->name) == 0) {
@ -144,7 +144,7 @@ price_parse_xml_end_handler(gpointer data_for_children,
xmlNodePtr child;
GNCPrice *p = NULL;
gxpf_data *gdata = global_data;
GNCSession *session = gdata->sessiondata;
GNCBook *book = gdata->bookdata;
/* we haven't been handed the *top* level node yet... */
if(parent_data) return TRUE;
@ -156,7 +156,7 @@ price_parse_xml_end_handler(gpointer data_for_children,
if(price_xml->prev) { ok = FALSE; goto cleanup_and_exit; }
if(!price_xml->xmlChildrenNode) { ok = FALSE; goto cleanup_and_exit; }
p = gnc_price_create(session);
p = gnc_price_create(book);
if(!p) { ok = FALSE; goto cleanup_and_exit; }
for(child = price_xml->xmlChildrenNode; child; child = child->next) {
@ -165,7 +165,7 @@ price_parse_xml_end_handler(gpointer data_for_children,
case XML_TEXT_NODE:
break;
case XML_ELEMENT_NODE:
if(!price_parse_xml_sub_node(p, child, session)) {
if(!price_parse_xml_sub_node(p, child, book)) {
ok = FALSE;
goto cleanup_and_exit;
}

View File

@ -26,6 +26,9 @@
#include <glib.h>
#include <string.h>
#include "Group.h"
#include "SchedXactionP.h"
#include "gnc-xml-helper.h"
#include "gnc-engine-util.h"
@ -42,7 +45,6 @@
#include "io-gncxml-gen.h"
#include "sixtp-dom-parsers.h"
#include "SchedXactionP.h"
static short module = MOD_SX;
@ -216,7 +218,7 @@ gnc_schedXaction_dom_tree_create(SchedXaction *sx)
struct sx_pdata
{
SchedXaction *sx;
GNCSession *session;
GNCBook *book;
};
static
@ -358,7 +360,7 @@ sx_freqspec_handler( xmlNodePtr node, gpointer sx_pdata )
g_return_val_if_fail( node, FALSE );
fs = dom_tree_to_freqSpec( node, pdata->session );
fs = dom_tree_to_freqSpec( node, pdata->book );
xaccSchedXactionSetFreqSpec( sx, fs );
return TRUE;
@ -395,7 +397,7 @@ sx_templ_acct_handler( xmlNodePtr node, gpointer sx_pdata)
return FALSE;
}
sx->template_acct = xaccAccountLookup(templ_acct_guid, pdata->session);
sx->template_acct = xaccAccountLookup(templ_acct_guid, pdata->book);
g_free(templ_acct_guid);
return TRUE;
@ -469,7 +471,7 @@ gnc_schedXaction_end_handler(gpointer data_for_children,
g_return_val_if_fail( tree, FALSE );
sx = xaccSchedXactionMalloc( gdata->sessiondata );
sx = xaccSchedXactionMalloc( gdata->bookdata );
/* FIXME: this should be removed somewhere near 1.8 release time. */
{
@ -482,7 +484,7 @@ gnc_schedXaction_end_handler(gpointer data_for_children,
}
sx_pdata.sx = sx;
sx_pdata.session = gdata->sessiondata;
sx_pdata.book = gdata->bookdata;
successful = dom_tree_generic_parse( tree, sx_dom_handlers, &sx_pdata );
@ -502,7 +504,7 @@ gnc_schedXaction_end_handler(gpointer data_for_children,
sixtp_gdv2 *sixdata = gdata->parsedata;
GNCBook *book;
book = gnc_session_get_book (sixdata->session);
book = sixdata->book;
/* We're dealing with a pre-200107<near-end-of-month> rgmerk
change re: storing template accounts. */
@ -558,7 +560,7 @@ tt_act_handler( xmlNodePtr node, gpointer data )
Account *acc;
gnc_commodity *com;
acc = dom_tree_to_account(node, txd->session);
acc = dom_tree_to_account(node, txd->book);
if ( acc == NULL ) {
return FALSE;
@ -594,7 +596,7 @@ tt_trn_handler( xmlNodePtr node, gpointer data )
gnc_template_xaction_data *txd = data;
Transaction *trn;
trn = dom_tree_to_transaction( node, txd->session );
trn = dom_tree_to_transaction( node, txd->book );
if ( trn == NULL ) {
return FALSE;
@ -626,11 +628,11 @@ gnc_template_transaction_end_handler(gpointer data_for_children,
xmlNodePtr achild;
xmlNodePtr tree = data_for_children;
gxpf_data *gdata = global_data;
GNCSession *session = gdata->sessiondata;
GNCBook *book = gdata->bookdata;
GList *n;
gnc_template_xaction_data txd;
txd.session = session;
txd.book = book;
txd.accts = NULL;
txd.transactions = NULL;

View File

@ -312,13 +312,13 @@ struct dom_tree_handler spl_dom_handlers[] =
};
Split*
dom_tree_to_split(xmlNodePtr node, GNCSession *session)
dom_tree_to_split(xmlNodePtr node, GNCBook *book)
{
Split *ret;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
ret = xaccMallocSplit(session);
ret = xaccMallocSplit(book);
g_return_val_if_fail(ret, NULL);
/* this isn't going to work in a testing setup */
@ -338,7 +338,7 @@ dom_tree_to_split(xmlNodePtr node, GNCSession *session)
struct trans_pdata
{
Transaction *trans;
GNCSession *session;
GNCBook *book;
};
static gboolean
@ -476,7 +476,7 @@ trn_splits_handler(xmlNodePtr node, gpointer trans_pdata)
return FALSE;
}
spl = dom_tree_to_split(mark, pdata->session);
spl = dom_tree_to_split(mark, pdata->book);
if(spl)
{
@ -529,7 +529,7 @@ gnc_transaction_end_handler(gpointer data_for_children,
g_return_val_if_fail(tree, FALSE);
trn = dom_tree_to_transaction(tree, gdata->sessiondata);
trn = dom_tree_to_transaction(tree, gdata->bookdata);
if(trn != NULL)
{
gdata->cb(tag, gdata->parsedata, trn);
@ -542,21 +542,21 @@ gnc_transaction_end_handler(gpointer data_for_children,
}
Transaction *
dom_tree_to_transaction( xmlNodePtr node, GNCSession *session )
dom_tree_to_transaction( xmlNodePtr node, GNCBook *book )
{
Transaction *trn;
gboolean successful;
struct trans_pdata pdata;
g_return_val_if_fail(node, NULL);
g_return_val_if_fail(session, NULL);
g_return_val_if_fail(book, NULL);
trn = xaccMallocTransaction(session);
trn = xaccMallocTransaction(book);
g_return_val_if_fail(trn, NULL);
xaccTransBeginEdit(trn);
pdata.trans = trn;
pdata.session = session;
pdata.book = book;
successful = dom_tree_generic_parse(node, trn_dom_handlers, &pdata);

View File

@ -29,8 +29,8 @@
#include "FreqSpec.h"
#include "SchedXaction.h"
#include "gnc-engine.h"
#include "gnc-pricedb.h"
#include "gnc-session.h"
#include "gnc-xml-helper.h"
#include "sixtp.h"
@ -44,7 +44,7 @@ xmlNodePtr gnc_transaction_dom_tree_create(Transaction *com);
sixtp* gnc_transaction_sixtp_parser_create(void);
xmlNodePtr split_to_dom_tree(const gchar *tag, Split *spl);
Split* dom_tree_to_split(xmlNodePtr node, GNCSession *session);
Split* dom_tree_to_split(xmlNodePtr node, GNCBook *book);
xmlNodePtr gnc_pricedb_dom_tree_create(GNCPriceDB *db);
sixtp* gnc_pricedb_sixtp_parser_create(void);

View File

@ -89,18 +89,17 @@ gnc_destroy_example_account(GncExampleAccount *gea)
static void
clear_up_account_commodity_session(
GNCSession *session, Account *act,
gnc_commodity * (*getter) (Account *account, GNCSession *session),
void (*setter) (Account *account, gnc_commodity *comm,
GNCSession *session))
GNCBook *book, Account *act,
gnc_commodity * (*getter) (Account *account, GNCBook *book),
void (*setter) (Account *account, gnc_commodity *comm, GNCBook *book))
{
gnc_commodity_table *tbl;
gnc_commodity *gcom;
gnc_commodity *com;
tbl = gnc_book_get_commodity_table (gnc_session_get_book (session));
tbl = gnc_book_get_commodity_table (book);
com = getter (act, session);
com = getter (act, book);
if(!com)
{
return;
@ -125,7 +124,7 @@ clear_up_account_commodity_session(
else
{
gnc_commodity_destroy(com);
setter(act, gcom, session);
setter(act, gcom, book);
}
}
@ -171,12 +170,12 @@ add_account_local(GncExampleAccount *gea, Account *act)
{
gnc_commodity_table *table;
table = gnc_book_get_commodity_table (gnc_session_get_book (gea->session));
table = gnc_book_get_commodity_table (gea->book);
clear_up_account_commodity_session(gea->session, act,
clear_up_account_commodity_session(gea->book, act,
DxaccAccountGetCurrency,
DxaccAccountSetCurrency);
clear_up_account_commodity_session(gea->session, act,
clear_up_account_commodity_session(gea->book, act,
DxaccAccountGetSecurity,
DxaccAccountSetSecurity);
@ -184,7 +183,7 @@ add_account_local(GncExampleAccount *gea, Account *act)
xaccAccountGetCommodity,
xaccAccountSetCommodity);
xaccAccountScrubCommodity (act, gea->session);
xaccAccountScrubCommodity (act, gea->book);
if (!xaccAccountGetParent(act))
{
@ -293,19 +292,19 @@ gnc_titse_sixtp_parser_create(void)
GncExampleAccount*
gnc_read_example_account(GNCSession *session, const gchar *filename)
gnc_read_example_account(GNCBook *book, const gchar *filename)
{
GncExampleAccount *gea;
sixtp *top_parser;
sixtp *main_parser;
g_return_val_if_fail (session != NULL, NULL);
g_return_val_if_fail (book != NULL, NULL);
gea = g_new0(GncExampleAccount, 1);
gea->session = session;
gea->book = book;
gea->filename = g_strdup(filename);
gea->group = xaccMallocAccountGroup(session);
gea->group = xaccMallocAccountGroup(book);
top_parser = sixtp_new();
main_parser = sixtp_new();
@ -330,7 +329,7 @@ gnc_read_example_account(GNCSession *session, const gchar *filename)
}
if(!gnc_xml_parse_file(top_parser, filename,
generic_callback, gea, session))
generic_callback, gea, book))
{
sixtp_destroy(top_parser);
xaccLogEnable ();
@ -417,7 +416,7 @@ is_directory(const gchar *filename)
}
GSList*
gnc_load_example_account_list(GNCSession *session, const char *dirname)
gnc_load_example_account_list(GNCBook *book, const char *dirname)
{
GSList *ret;
DIR *dir;
@ -440,7 +439,7 @@ gnc_load_example_account_list(GNCSession *session, const char *dirname)
if(!is_directory(filename))
{
gea = gnc_read_example_account(session, filename);
gea = gnc_read_example_account(book, filename);
if(gea == NULL)
{

View File

@ -28,13 +28,13 @@
#include <glib.h>
#include "sixtp.h"
#include "gnc-session.h"
#include "gnc-engine.h"
struct GncExampleAccount_struct
{
gchar *title;
gchar *filename;
GNCSession *session;
GNCBook *book;
AccountGroup *group;
gchar *short_description;
gchar *long_description;
@ -45,14 +45,14 @@ void gnc_destroy_example_account(GncExampleAccount *gea);
gboolean gnc_write_example_account(GncExampleAccount *gea,
const gchar *filename);
GncExampleAccount *gnc_read_example_account(GNCSession *session,
GncExampleAccount *gnc_read_example_account(GNCBook *book,
const gchar *filename);
gboolean gnc_is_xml_data_file_v2(const gchar *filename);
void gnc_free_example_account_list(GSList *list);
GSList* gnc_load_example_account_list(GNCSession *session,
GSList* gnc_load_example_account_list(GNCBook *book,
const char *dirname);
gboolean gnc_is_example_account_xml(const gchar *name);

View File

@ -2,7 +2,7 @@
* io-gncbin.c -- read and write (old format) binary datafile *
* (GnuCash/X-Accountant) *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997-2000 Linas Vepstas <linas@linas.org> *
* Copyright (C) 1997-2001 Linas Vepstas <linas@linas.org> *
* Copyright (C) 1999-2000 Rob Browning *
* *
* This program is free software; you can redistribute it and/or *
@ -198,7 +198,7 @@ mark_potential_quote(Split *s, double price, double quantity)
static gboolean
cvt_potential_prices_to_pricedb_and_cleanup(GNCPriceDB **prices,
GNCSession *session)
GNCBook *book)
{
GSList *item = potential_quotes;
@ -217,14 +217,14 @@ cvt_potential_prices_to_pricedb_and_cleanup(GNCPriceDB **prices,
(acct_type == CURRENCY)) {
/* this is a quote -- file it in the db and kill the split */
Transaction *txn = xaccSplitGetParent(q->split);
GNCPrice *price = gnc_price_create(session);
GNCPrice *price = gnc_price_create(book);
Timespec time = xaccTransRetDatePostedTS(txn);
gnc_price_begin_edit(price);
gnc_price_set_commodity(price,
DxaccAccountGetSecurity(split_acct, session));
DxaccAccountGetSecurity(split_acct, book));
gnc_price_set_currency(price,
DxaccAccountGetCurrency(split_acct, session));
DxaccAccountGetCurrency(split_acct, book));
gnc_price_set_time(price, time);
gnc_price_set_source(price, "old-file-import");
gnc_price_set_type(price, "unknown");
@ -250,15 +250,15 @@ cvt_potential_prices_to_pricedb_and_cleanup(GNCPriceDB **prices,
}
/** PROTOTYPES ******************************************************/
static Account *locateAccount (int acc_id, GNCSession *session);
static Account *locateAccount (int acc_id, GNCBook *book);
static AccountGroup *readGroup( GNCSession *, int fd, Account *, int token );
static Account *readAccount( GNCSession *session, int fd,
static AccountGroup *readGroup( GNCBook *, int fd, Account *, int token );
static Account *readAccount( GNCBook *book, int fd,
AccountGroup *, int token );
static gboolean readAccInfo( int fd, Account *, int token );
static Transaction *readTransaction( GNCSession *session,
static Transaction *readTransaction( GNCBook *book,
int fd, Account *, int token );
static Split *readSplit( GNCSession *session, int fd, int token );
static Split *readSplit( GNCBook *book, int fd, int token );
static char *readString( int fd, int token );
static time_t readDMYDate( int fd, int token );
static int readTSDate( int fd, Timespec *, int token );
@ -372,12 +372,12 @@ xaccFlipLongLong (gint64 val)
********************************************************************/
static gnc_commodity *
gnc_commodity_import_legacy(GNCSession *session, const char * currency_name)
gnc_commodity_import_legacy(GNCBook *book, const char * currency_name)
{
gnc_commodity_table *table;
gnc_commodity * old = NULL;
table = gnc_book_get_commodity_table (gnc_session_get_book (session));
table = gnc_book_get_commodity_table (book);
g_return_val_if_fail (table != NULL, NULL);
@ -412,15 +412,12 @@ gnc_commodity_import_legacy(GNCSession *session, const char * currency_name)
* Return: the struct with the program data in it *
\********************************************************************/
static gboolean
gnc_load_financials_from_fd(GNCSession *session, int fd)
gnc_load_financials_from_fd(GNCBook *book, int fd)
{
int err=0;
int token=0;
int num_unclaimed;
AccountGroup *grp = 0x0;
GNCBook *book;
book = gnc_session_get_book (session);
maingrp = 0x0;
error_code = ERR_BACKEND_NO_ERR;
@ -476,8 +473,8 @@ gnc_load_financials_from_fd(GNCSession *session, int fd)
/* disable logging during load; otherwise its just a mess */
xaccLogDisable();
holder = xaccMallocAccountGroup(session);
grp = readGroup (session, fd, NULL, token);
holder = xaccMallocAccountGroup(book);
grp = readGroup (book, fd, NULL, token);
/* the number of unclaimed accounts should be zero if the
* read succeeded. But just in case of a very unlikely
@ -488,7 +485,7 @@ gnc_load_financials_from_fd(GNCSession *session, int fd)
error_code = ERR_FILEIO_FILE_BAD_READ;
/* create a lost account, put the missing accounts there */
acc = xaccMallocAccount(session);
acc = xaccMallocAccount(book);
xaccAccountBeginEdit (acc);
xaccAccountSetName (acc, _("Lost Accounts"));
acc -> children = holder;
@ -507,7 +504,7 @@ gnc_load_financials_from_fd(GNCSession *session, int fd)
{
GNCPriceDB *tmpdb;
if(cvt_potential_prices_to_pricedb_and_cleanup(&tmpdb, session))
if(cvt_potential_prices_to_pricedb_and_cleanup(&tmpdb, book))
{
GNCPriceDB *db = gnc_book_get_pricedb(book);
gnc_book_set_pricedb(book, tmpdb);
@ -561,7 +558,7 @@ gnc_session_load_from_binfile(GNCSession *session)
return;
}
if (!gnc_load_financials_from_fd(session, fd))
if (!gnc_load_financials_from_fd(gnc_session_get_book(session), fd))
return;
close(fd);
@ -575,12 +572,12 @@ gnc_session_load_from_binfile(GNCSession *session)
* Return: the struct with the program data in it *
\********************************************************************/
static AccountGroup *
readGroup (GNCSession *session, int fd, Account *aparent, int token)
readGroup (GNCBook *book, int fd, Account *aparent, int token)
{
int numAcc;
int err=0;
int i;
AccountGroup *grp = xaccMallocAccountGroup(session);
AccountGroup *grp = xaccMallocAccountGroup(book);
ENTER (" ");
@ -602,7 +599,7 @@ readGroup (GNCSession *session, int fd, Account *aparent, int token)
/* read in the accounts */
for( i=0; i<numAcc; i++ )
{
Account * acc = readAccount( session, fd, grp, token );
Account * acc = readAccount( book, fd, grp, token );
if( NULL == acc ) {
PERR("Short group read: \n"
"\texpected %d, got %d accounts\n",numAcc,i);
@ -623,14 +620,14 @@ readGroup (GNCSession *session, int fd, Account *aparent, int token)
* readAccount *
* reads in the data for an account from the datafile *
* *
* Args: session - the session *
* Args: book - the session *
* fd - the filedescriptor of the data file *
* acc - the account structure to be filled in *
* token - the datafile version *
* Return: error value, 0 if OK, else -1 *
\********************************************************************/
static Account *
readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
readAccount( GNCBook *book, int fd, AccountGroup *grp, int token )
{
int err=0;
int i;
@ -647,11 +644,11 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
err = read( fd, &accID, sizeof(int) );
if( err != sizeof(int) ) { return NULL; }
XACC_FLIP_INT (accID);
acc = locateAccount (accID, session);
acc = locateAccount (accID, book);
/* locateAccountAlways should always accounts that are open for
editing in this situation */
} else {
acc = xaccMallocAccount(session);
acc = xaccMallocAccount(book);
xaccGroupInsertAccount (holder, acc);
xaccAccountBeginEdit (acc);
}
@ -721,8 +718,8 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
if( NULL == tmp ) return NULL;
PINFO ("currency is %s", tmp);
currency = gnc_commodity_import_legacy(session, tmp);
DxaccAccountSetCurrency (acc, currency, session);
currency = gnc_commodity_import_legacy(book, tmp);
DxaccAccountSetCurrency (acc, currency, book);
if(tmp) free (tmp);
@ -746,15 +743,15 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
}
PINFO ("security is %s", tmp);
security = gnc_commodity_import_legacy(session, tmp);
DxaccAccountSetSecurity (acc, security, session);
security = gnc_commodity_import_legacy(book, tmp);
DxaccAccountSetSecurity (acc, security, book);
if(tmp) free (tmp);
}
else {
/* set the default currency when importing old files */
currency = gnc_commodity_import_legacy(session, DEFAULT_CURRENCY);
DxaccAccountSetCurrency (acc, currency, session);
currency = gnc_commodity_import_legacy(book, DEFAULT_CURRENCY);
DxaccAccountSetCurrency (acc, currency, book);
}
/* aux account info first appears in version ten files */
@ -772,7 +769,7 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
/* read the transactions */
for( i=0; i<numTrans; i++ ) {
Transaction *trans;
trans = readTransaction(session, fd, acc, token );
trans = readTransaction(book, fd, acc, token );
if(trans == NULL ) {
PERR ("Short Transaction Read: \n"
"\texpected %d got %d transactions \n", numTrans, i);
@ -798,7 +795,7 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
}
XACC_FLIP_INT (numGrps);
if (numGrps) {
readGroup (session, fd, acc, token);
readGroup (book, fd, acc, token);
}
}
@ -824,7 +821,7 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
*/
static Account *
locateAccount (int acc_id, GNCSession *session)
locateAccount (int acc_id, GNCBook *book)
{
Account * acc;
/* negative account ids denote no account */
@ -842,7 +839,7 @@ locateAccount (int acc_id, GNCSession *session)
/* if neither, then it does not yet exist. Create it.
* Put it in the drunk tank. */
acc = xaccMallocAccount (session);
acc = xaccMallocAccount (book);
xaccAccountBeginEdit(acc);
g_hash_table_insert(ids_to_unfinished_accounts,
(gpointer) acc_id,
@ -926,7 +923,7 @@ xaccTransSetAction (Transaction *trans, const char *action)
\********************************************************************/
static Transaction *
readTransaction(GNCSession *session, int fd, Account *acc, int revision)
readTransaction(GNCBook *book, int fd, Account *acc, int revision)
{
int err=0;
int acc_id;
@ -942,7 +939,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
ENTER (" ");
/* create a transaction structure */
trans = xaccMallocTransaction(session);
trans = xaccMallocTransaction(book);
xaccTransBeginEdit (trans);
tmp = readString( fd, revision );
@ -1089,9 +1086,9 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
/* The code below really wants to assume that there are a pair
* of splits in every transaction, so make it so.
*/
s = xaccMallocSplit (session);
s = xaccMallocSplit (book);
xaccTransAppendSplit (trans, s);
s = xaccMallocSplit (session);
s = xaccMallocSplit (book);
xaccTransAppendSplit (trans, s);
s = xaccTransGetSplit (trans, 0);
@ -1181,7 +1178,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
}
XACC_FLIP_INT (acc_id);
DEBUG ("credit %d\n", acc_id);
peer_acc = locateAccount (acc_id, session);
peer_acc = locateAccount (acc_id, book);
/* insert the split part of the transaction into
* the credited account */
@ -1201,7 +1198,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
}
XACC_FLIP_INT (acc_id);
DEBUG ("debit %d\n", acc_id);
peer_acc = locateAccount (acc_id, session);
peer_acc = locateAccount (acc_id, book);
if (peer_acc) {
Split *s0 = xaccTransGetSplit (trans, 0);
Split *s1 = xaccTransGetSplit (trans, 1);
@ -1223,7 +1220,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
/* Version 5 files included a split that immediately
* followed the transaction, before the destination splits.
* Later versions don't have this. */
Split *split = readSplit (session, fd, revision);
Split *split = readSplit (book, fd, revision);
xaccTransAppendSplit(trans, split);
}
@ -1237,7 +1234,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
}
XACC_FLIP_INT (numSplits);
for (i = 0; i < numSplits; i++) {
Split *split = readSplit(session, fd, revision);
Split *split = readSplit(book, fd, revision);
xaccTransAppendSplit(trans, split);
if(!notes) {
@ -1262,7 +1259,7 @@ readTransaction(GNCSession *session, int fd, Account *acc, int revision)
\********************************************************************/
static Split *
readSplit ( GNCSession *session, int fd, int token )
readSplit ( GNCBook *book, int fd, int token )
{
Account *peer_acc;
Split *split;
@ -1275,7 +1272,7 @@ readSplit ( GNCSession *session, int fd, int token )
ENTER (" ");
/* create a split structure */
split = xaccMallocSplit(session);
split = xaccMallocSplit(book);
tmp = readString( fd, token );
if( NULL == tmp )
@ -1394,7 +1391,7 @@ readSplit ( GNCSession *session, int fd, int token )
}
XACC_FLIP_INT (acc_id);
DEBUG ("account id %d", acc_id);
peer_acc = locateAccount (acc_id, session);
peer_acc = locateAccount (acc_id, book);
xaccAccountInsertSplit (peer_acc, split);
mark_potential_quote(split, share_price, num_shares);

View File

@ -29,14 +29,14 @@
gboolean
gnc_xml_parse_file(sixtp *top_parser, const char *filename,
gxpf_callback callback, gpointer parsedata,
gpointer sessiondata)
gpointer bookdata)
{
gpointer parse_result = NULL;
gxpf_data gpdata;
gpdata.cb = callback;
gpdata.parsedata = parsedata;
gpdata.sessiondata = sessiondata;
gpdata.bookdata = bookdata;
return sixtp_parse_file(top_parser, filename,
NULL, &gpdata, &parse_result);

View File

@ -35,7 +35,7 @@ struct gxpf_data_struct
{
gxpf_callback cb;
gpointer parsedata;
gpointer sessiondata;
gpointer bookdata;
};
typedef struct gxpf_data_struct gxpf_data;
@ -43,6 +43,6 @@ typedef struct gxpf_data_struct gxpf_data;
gboolean
gnc_xml_parse_file(sixtp *top_parser, const char *filename,
gxpf_callback callback, gpointer parsedata,
gpointer sessiondata);
gpointer bookdata);
#endif /* IO_GNCXML_GEN_H */

View File

@ -90,8 +90,8 @@ typedef struct {
after we see the file version. */
sixtp *gnc_parser;
/* The session */
GNCSession *session;
/* The book */
GNCBook *book;
/* The account group */
AccountGroup *account_group;
@ -357,11 +357,11 @@ gnc_session_load_from_xml_file(GNCSession *session)
const gchar *filename;
GNCBook *book;
global_parse_status.session = session;
g_return_val_if_fail(session, FALSE);
book = gnc_session_get_book (session);
global_parse_status.book = book;
g_return_val_if_fail(session, FALSE);
g_return_val_if_fail(book, FALSE);
filename = gnc_session_get_file_path(session);
@ -408,7 +408,7 @@ gnc_session_load_from_xml_file(GNCSession *session)
}
/* Fix account and transaction commodities */
xaccGroupScrubCommodities (gnc_book_get_group(book), session);
xaccGroupScrubCommodities (gnc_book_get_group(book), book);
/* Fix split amount/value */
xaccGroupScrubSplits (gnc_book_get_group(book));
@ -1128,7 +1128,7 @@ ledger_data_start_handler(GSList* sibling_data, gpointer parent_data,
/* disable logging during load; otherwise its just a mess */
xaccLogDisable();
ag = xaccMallocAccountGroup(pstatus->session);
ag = xaccMallocAccountGroup(pstatus->book);
g_return_val_if_fail(ag, FALSE);
@ -1328,7 +1328,7 @@ account_restore_start_handler(GSList* sibling_data,
gchar **attrs)
{
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Account *acc = xaccMallocAccount(pstatus->session);
Account *acc = xaccMallocAccount(pstatus->book);
g_return_val_if_fail(acc, FALSE);
xaccAccountBeginEdit(acc);
@ -1398,15 +1398,15 @@ account_restore_after_child_handler(gpointer data_for_children,
else if(strcmp(child_result->tag, "currency") == 0) {
gnc_commodity *com = (gnc_commodity *) child_result->data;
g_return_val_if_fail(com, FALSE);
if(DxaccAccountGetCurrency(a, pstatus->session)) return FALSE;
DxaccAccountSetCurrency(a, com, pstatus->session);
if(DxaccAccountGetCurrency(a, pstatus->book)) return FALSE;
DxaccAccountSetCurrency(a, com, pstatus->book);
/* let the normal child_result handler clean up com */
}
else if(strcmp(child_result->tag, "security") == 0) {
gnc_commodity *com = (gnc_commodity *) child_result->data;
g_return_val_if_fail(com, FALSE);
if(DxaccAccountGetSecurity(a, pstatus->session)) return FALSE;
DxaccAccountSetSecurity(a, com, pstatus->session);
if(DxaccAccountGetSecurity(a, pstatus->book)) return FALSE;
DxaccAccountSetSecurity(a, com, pstatus->book);
/* let the normal child_result handler clean up com */
}
@ -1504,7 +1504,8 @@ acc_restore_guid_end_handler(gpointer data_for_children,
g_return_val_if_fail(ok, FALSE);
if(xaccAccountLookup(&gid, pstatus->session)) {
if(xaccAccountLookup(&gid, pstatus->book))
{
return(FALSE);
}
@ -1718,7 +1719,7 @@ acc_restore_parent_end_handler(gpointer data_for_children,
/* otherwise this must be a good result - use it */
gid = *((GUID *) child_result->data);
parent = xaccAccountLookup(&gid, pstatus->session);
parent = xaccAccountLookup(&gid, pstatus->book);
g_return_val_if_fail(parent, FALSE);
@ -1947,8 +1948,7 @@ commodity_restore_end_handler(gpointer data_for_children,
{
gnc_commodity_table *ctab;
ctab = gnc_book_get_commodity_table
(gnc_session_get_book (pstatus->session));
ctab = gnc_book_get_commodity_table (pstatus->book);
if(ctab)
{
@ -2113,8 +2113,7 @@ generic_gnc_commodity_lookup_end_handler(gpointer data_for_children,
gnc_commodity_table *table;
gnc_commodity *com;
table = gnc_book_get_commodity_table
(gnc_session_get_book (pstatus->session));
table = gnc_book_get_commodity_table (pstatus->book);
com = gnc_commodity_table_lookup(table, cpi->namespace, cpi->id);
@ -2762,7 +2761,7 @@ txn_restore_start_handler(GSList* sibling_data, gpointer parent_data,
gpointer *result, const gchar *tag, gchar **attrs)
{
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Transaction *trans = xaccMallocTransaction(pstatus->session);
Transaction *trans = xaccMallocTransaction(pstatus->book);
g_return_val_if_fail(trans, FALSE);
@ -2885,7 +2884,8 @@ txn_restore_guid_end_handler(gpointer data_for_children,
g_return_val_if_fail(ok, FALSE);
if(xaccTransLookup(&gid, pstatus->session)) {
if(xaccTransLookup(&gid, pstatus->book))
{
return(FALSE);
}
@ -3068,7 +3068,7 @@ txn_restore_split_start_handler(GSList* sibling_data, gpointer parent_data,
const gchar *tag, gchar **attrs)
{
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Split *s = xaccMallocSplit(pstatus->session);
Split *s = xaccMallocSplit(pstatus->book);
g_return_val_if_fail(s, FALSE);
*data_for_children = s;
return(TRUE);
@ -3194,7 +3194,8 @@ txn_restore_split_guid_end_handler(gpointer data_for_children,
g_return_val_if_fail(ok, FALSE);
if(xaccSplitLookup(&gid, pstatus->session)) {
if(xaccSplitLookup(&gid, pstatus->book))
{
return(FALSE);
}
@ -3402,7 +3403,7 @@ txn_restore_split_account_end_handler(gpointer data_for_children,
g_return_val_if_fail(ok, FALSE);
acct = xaccAccountLookup(&gid, pstatus->session);
acct = xaccAccountLookup(&gid, pstatus->book);
g_return_val_if_fail(acct, FALSE);
xaccAccountInsertSplit(acct, s);
@ -3563,7 +3564,7 @@ gnc_transaction_parser_new(void)
*/
static gboolean
price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, GNCSession *session)
price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, GNCBook *book)
{
if(!p || !sub_node) return FALSE;
@ -3575,11 +3576,11 @@ price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node, GNCSession *session)
gnc_price_set_guid(p, c);
g_free(c);
} else if(safe_strcmp("price:commodity", sub_node->name) == 0) {
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, session);
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, book);
if(!c) return FALSE;
gnc_price_set_commodity(p, c);
} else if(safe_strcmp("price:currency", sub_node->name) == 0) {
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, session);
gnc_commodity *c = dom_tree_to_commodity_ref(sub_node, book);
if(!c) return FALSE;
gnc_price_set_currency(p, c);
} else if(safe_strcmp("price:time", sub_node->name) == 0) {
@ -3632,26 +3633,28 @@ price_parse_xml_end_handler(gpointer data_for_children,
if(price_xml->prev) { ok = FALSE; goto cleanup_and_exit; }
if(!price_xml->xmlChildrenNode) { ok = FALSE; goto cleanup_and_exit; }
p = gnc_price_create(pstatus->session);
p = gnc_price_create(pstatus->book);
if(!p) { ok = FALSE; goto cleanup_and_exit; }
for(child = price_xml->xmlChildrenNode; child; child = child->next) {
for(child = price_xml->xmlChildrenNode; child; child = child->next)
{
switch(child->type) {
case XML_COMMENT_NODE:
case XML_TEXT_NODE:
break;
case XML_ELEMENT_NODE:
if(!price_parse_xml_sub_node(p, child, pstatus->session)) {
case XML_COMMENT_NODE:
case XML_TEXT_NODE:
break;
case XML_ELEMENT_NODE:
if(!price_parse_xml_sub_node(p, child, pstatus->book))
{
ok = FALSE;
goto cleanup_and_exit;
}
break;
default:
PERR("Unknown node type (%d) while parsing gnc-price xml.", child->type);
child = NULL;
ok = FALSE;
goto cleanup_and_exit;
}
break;
default:
PERR("Unknown node type (%d) while parsing gnc-price xml.", child->type);
child = NULL;
ok = FALSE;
goto cleanup_and_exit;
break;
break;
}
}

View File

@ -59,10 +59,9 @@ run_callback(sixtp_gdv2 *data, const char *type)
static void
clear_up_account_commodity_session(
GNCSession *session, Account *act,
gnc_commodity * (*getter) (Account *account, GNCSession *session),
void (*setter) (Account *account, gnc_commodity *comm,
GNCSession *session),
GNCBook *book, Account *act,
gnc_commodity * (*getter) (Account *account, GNCBook *book),
void (*setter) (Account *account, gnc_commodity *comm, GNCBook *book),
int (*scu_getter) (Account *account),
void (*scu_setter) (Account *account, int scu))
{
@ -71,9 +70,9 @@ clear_up_account_commodity_session(
gnc_commodity *com;
int old_scu;
tbl = gnc_book_get_commodity_table (gnc_session_get_book (session));
tbl = gnc_book_get_commodity_table (book);
com = getter (act, session);
com = getter (act, book);
if (scu_getter)
old_scu = scu_getter(act);
@ -101,7 +100,7 @@ clear_up_account_commodity_session(
else
{
gnc_commodity_destroy(com);
setter(act, gcom, session);
setter(act, gcom, book);
if (old_scu != 0 && scu_setter)
scu_setter(act, old_scu);
}
@ -190,19 +189,17 @@ clear_up_transaction_commodity(
static gboolean
add_account_local(sixtp_gdv2 *data, Account *act)
{
GNCBook *book;
gnc_commodity_table *table;
book = gnc_session_get_book (data->session);
table = gnc_book_get_commodity_table (book);
table = gnc_book_get_commodity_table (data->book);
clear_up_account_commodity_session(data->session, act,
clear_up_account_commodity_session(data->book, act,
DxaccAccountGetCurrency,
DxaccAccountSetCurrency,
DxaccAccountGetCurrencySCU,
DxaccAccountSetCurrencySCU);
clear_up_account_commodity_session(data->session, act,
clear_up_account_commodity_session(data->book, act,
DxaccAccountGetSecurity,
DxaccAccountSetSecurity,
NULL, NULL);
@ -213,11 +210,11 @@ add_account_local(sixtp_gdv2 *data, Account *act)
xaccAccountGetCommoditySCU,
xaccAccountSetCommoditySCU);
xaccAccountScrubCommodity (act, data->session);
xaccAccountScrubCommodity (act, data->book);
if(!xaccAccountGetParent(act))
{
xaccGroupInsertAccount(gnc_book_get_group(book), act);
xaccGroupInsertAccount(gnc_book_get_group(data->book), act);
}
data->counter.accounts_loaded++;
run_callback(data, "account");
@ -228,11 +225,9 @@ add_account_local(sixtp_gdv2 *data, Account *act)
static gboolean
add_commodity_local(sixtp_gdv2 *data, gnc_commodity *com)
{
GNCBook *book;
gnc_commodity_table *table;
book = gnc_session_get_book (data->session);
table = gnc_book_get_commodity_table (book);
table = gnc_book_get_commodity_table (data->book);
gnc_commodity_table_insert(table, com);
@ -245,19 +240,17 @@ add_commodity_local(sixtp_gdv2 *data, gnc_commodity *com)
static gboolean
add_transaction_local(sixtp_gdv2 *data, Transaction *trn)
{
GNCBook *book;
gnc_commodity_table *table;
Split *spl;
int i;
book = gnc_session_get_book (data->session);
table = gnc_book_get_commodity_table (book);
table = gnc_book_get_commodity_table (data->book);
clear_up_transaction_commodity(table, trn,
xaccTransGetCurrency,
xaccTransSetCurrency);
xaccTransScrubCurrency (trn, data->session);
xaccTransScrubCurrency (trn, data->book);
for(i = 0, spl = xaccTransGetSplit(trn, i);
spl;
@ -275,14 +268,11 @@ static gboolean
add_schedXaction_local(sixtp_gdv2 *data, SchedXaction *sx)
{
GList *list;
GNCBook *book;
book = gnc_session_get_book (data->session);
list = gnc_book_get_schedxactions (book);
list = gnc_book_get_schedxactions (data->book);
list = g_list_append(list, sx);
gnc_book_set_schedxactions(book, list);
gnc_book_set_schedxactions(data->book, list);
return TRUE;
}
@ -296,7 +286,7 @@ add_template_transaction_local( sixtp_gdv2 *data,
AccountGroup *acctGroup = NULL;
GNCBook *book;
book = gnc_session_get_book (data->session);
book = data->book;
/* expect a struct of: */
/* . template accounts. */
@ -333,7 +323,7 @@ add_pricedb_local(sixtp_gdv2 *data, GNCPriceDB *db)
{
GNCBook *book;
book = gnc_session_get_book (data->session);
book = data->book;
if (gnc_book_get_pricedb(book))
{
@ -488,7 +478,7 @@ gnc_session_load_from_xml_file_v2(
book = gnc_session_get_book (session);
gd->session = session;
gd->book = book;
gd->counter.accounts_loaded = 0;
gd->counter.accounts_total = 0;
gd->counter.commodities_loaded = 0;
@ -531,7 +521,7 @@ gnc_session_load_from_xml_file_v2(
xaccLogDisable ();
if(!gnc_xml_parse_file(top_parser, gnc_session_get_file_path(session),
generic_callback, gd, session))
generic_callback, gd, book))
{
sixtp_destroy(top_parser);
xaccLogEnable ();
@ -553,7 +543,7 @@ gnc_session_load_from_xml_file_v2(
gnc_pricedb_mark_clean (gnc_book_get_pricedb (book));
/* Fix account and transaction commodities */
xaccGroupScrubCommodities (gnc_book_get_group(book), session);
xaccGroupScrubCommodities (gnc_book_get_group(book), book);
/* Fix split amount/value */
xaccGroupScrubSplits (gnc_book_get_group(book));

View File

@ -33,10 +33,11 @@
#include <glib.h>
#include "gnc-session.h"
#include "Account.h"
#include "Transaction.h"
#include "gnc-book.h"
#include "gnc-commodity.h"
#include "gnc-engine.h"
#include "gnc-pricedb.h"
#include "SchedXaction.h"
@ -60,7 +61,7 @@ typedef struct
typedef struct
{
GNCSession *session;
GNCBook *book;
load_counter counter;
void (*countCallback)(const char *type, load_counter counter);
} sixtp_gdv2;
@ -75,7 +76,7 @@ typedef struct
{
GList *accts;
GList *transactions;
GNCSession *session;
GNCBook *book;
} gnc_template_xaction_data;
/* read in an account group from a file */

View File

@ -719,7 +719,7 @@ dom_tree_to_commodity_ref_no_engine(xmlNodePtr node)
}
gnc_commodity*
dom_tree_to_commodity_ref(xmlNodePtr node, GNCSession *session)
dom_tree_to_commodity_ref(xmlNodePtr node, GNCBook *book)
{
gnc_commodity *daref;
gnc_commodity *ret;
@ -727,7 +727,7 @@ dom_tree_to_commodity_ref(xmlNodePtr node, GNCSession *session)
daref = dom_tree_to_commodity_ref_no_engine(node);
table = gnc_book_get_commodity_table (gnc_session_get_book (session));
table = gnc_book_get_commodity_table (book);
g_return_val_if_fail (table != NULL, NULL);

View File

@ -32,7 +32,8 @@
#include "date.h"
#include "gnc-commodity.h"
#include "gnc-session.h"
#include "gnc-book.h"
#include "kvp_frame.h"
#include "GNCId.h"
@ -40,10 +41,10 @@
GUID* dom_tree_to_guid(xmlNodePtr node);
gnc_commodity* dom_tree_to_commodity_ref(xmlNodePtr node, GNCSession *session);
gnc_commodity* dom_tree_to_commodity_ref(xmlNodePtr node, GNCBook *book);
gnc_commodity *dom_tree_to_commodity_ref_no_engine(xmlNodePtr node);
FreqSpec* dom_tree_to_freqSpec( xmlNodePtr node, GNCSession *session );
FreqSpec* dom_tree_to_freqSpec( xmlNodePtr node, GNCBook *book);
Timespec* dom_tree_to_timespec(xmlNodePtr node);
GDate* dom_tree_to_gdate(xmlNodePtr node);
@ -67,8 +68,8 @@ kvp_value* dom_tree_to_frame_kvp_value(xmlNodePtr node);
gboolean dom_tree_to_integer(xmlNodePtr node, gint64 *daint);
Account* dom_tree_to_account(xmlNodePtr node, GNCSession *session);
Transaction* dom_tree_to_transaction(xmlNodePtr node, GNCSession *session);
Account* dom_tree_to_account(xmlNodePtr node, GNCBook *book);
Transaction* dom_tree_to_transaction(xmlNodePtr node, GNCBook *book);
struct dom_tree_handler
{

View File

@ -304,7 +304,7 @@ grab_file_doc(const char *filename)
static void
test_load_file(const char *filename, gxpf_callback cb,
sixtp *parser, const char *parser_tag,
GNCSession *session)
GNCBook *book)
{
xmlNodePtr node;
sixtp *main_parser;
@ -338,7 +338,7 @@ test_load_file(const char *filename, gxpf_callback cb,
return;
}
if(!gnc_xml_parse_file(top_parser, filename, cb, node->childs, session))
if(!gnc_xml_parse_file(top_parser, filename, cb, node->childs, book))
{
failure_args("failure to parse file", __FILE__, __LINE__,
"%s", filename);
@ -350,7 +350,7 @@ test_load_file(const char *filename, gxpf_callback cb,
void
test_files_in_dir(int argc, char **argv, gxpf_callback cb,
sixtp *parser, const char *parser_tag,
GNCSession *session)
GNCBook *book)
{
int count;
@ -366,7 +366,7 @@ test_files_in_dir(int argc, char **argv, gxpf_callback cb,
{
if(!S_ISDIR(file_info.st_mode))
{
test_load_file(to_open, cb, parser, parser_tag, session);
test_load_file(to_open, cb, parser, parser_tag, book);
}
}
}

View File

@ -11,7 +11,7 @@
#include "date.h"
#include "gnc-commodity.h"
#include "gnc-session.h"
#include "gnc-engine.h"
#include "gnc-xml-helper.h"
#include "guid.h"
#include "io-gncxml-gen.h"
@ -42,6 +42,6 @@ gboolean equals_node_val_vs_int(xmlNodePtr node, gint64 val);
void
test_files_in_dir(int argc, char **argv, gxpf_callback cb,
sixtp *parser, const char *parser_tag,
GNCSession *session);
GNCBook *book);
#endif

View File

@ -23,11 +23,11 @@
static const gchar *da_ending = ".gnucash-xea";
static void
test_load_file(GNCSession *session, const char *filename)
test_load_file(GNCBook *book, const char *filename)
{
GncExampleAccount *gea;
gea = gnc_read_example_account(session, filename);
gea = gnc_read_example_account(book, filename);
if(gea != NULL)
{
@ -47,12 +47,12 @@ guile_main(int argc, char **argv)
const char *location = "../../../../accounts/C";
GSList *list = NULL;
DIR *ea_dir;
GNCSession *session;
GNCBook *book;
gnc_module_system_init();
gnc_module_load("gnucash/engine", 0);
session = gnc_session_new ();
book = gnc_book_new ();
if((ea_dir = opendir(location)) == NULL)
{
@ -77,7 +77,7 @@ guile_main(int argc, char **argv)
{
if(!S_ISDIR(file_info.st_mode))
{
test_load_file(session, to_open);
test_load_file(book, to_open);
}
}
g_free(to_open);
@ -87,7 +87,7 @@ guile_main(int argc, char **argv)
closedir(ea_dir);
{
list = gnc_load_example_account_list(session, location);
list = gnc_load_example_account_list(book, location);
do_test(list != NULL, "gnc_load_example_account_list");

View File

@ -9,6 +9,7 @@
#include <string.h>
#include "Backend.h"
#include "Group.h"
#include "TransLog.h"
#include "gnc-session.h"
#include "gnc-engine.h"

View File

@ -25,7 +25,7 @@
#include "Scrub.h"
#include "gnc-book.h"
static GNCSession *session;
static GNCBook *book;
static gchar*
node_and_account_equal(xmlNodePtr node, Account *act)
@ -101,7 +101,7 @@ node_and_account_equal(xmlNodePtr node, Account *act)
else if(safe_strcmp(mark->name, "act:currency") == 0)
{
if(!equals_node_val_vs_commodity(
mark, DxaccAccountGetCurrency(act, session)))
mark, DxaccAccountGetCurrency(act, book)))
{
return g_strdup("currencies differ");
}
@ -124,7 +124,7 @@ node_and_account_equal(xmlNodePtr node, Account *act)
else if(safe_strcmp(mark->name, "act:security") == 0)
{
if(!equals_node_val_vs_commodity(
mark, DxaccAccountGetSecurity(act, session)))
mark, DxaccAccountGetSecurity(act, book)))
{
return g_strdup("securities differ");
}
@ -204,7 +204,7 @@ test_add_account(const char *tag, gpointer globaldata, gpointer data)
com = xaccAccountGetCommodity (account);
t = gnc_book_get_commodity_table (gnc_session_get_book (session));
t = gnc_book_get_commodity_table (book);
new_com = gnc_commodity_table_lookup (t,
gnc_commodity_get_namespace (com),
@ -272,7 +272,7 @@ test_account(int i, Account *test_act)
parser = gnc_account_sixtp_parser_create();
if(!gnc_xml_parse_file(parser, filename1, test_add_account,
&data, session))
&data, book))
{
failure_args("gnc_xml_parse_file returned FALSE",
__FILE__, __LINE__, "%d", i);
@ -297,7 +297,7 @@ test_generation(void)
{
Account *ran_act;
ran_act = get_random_account(session);
ran_act = get_random_account(book);
test_account(i, ran_act);
@ -308,7 +308,7 @@ test_generation(void)
/* empty some things. */
Account *act;
act = get_random_account(session);
act = get_random_account(book);
xaccAccountSetCode(act, "");
xaccAccountSetDescription(act, "");
@ -337,9 +337,6 @@ test_generation(void)
}
static GNCBook *bk;
static gboolean
test_real_account(const char *tag, gpointer global_data, gpointer data)
{
@ -348,7 +345,7 @@ test_real_account(const char *tag, gpointer global_data, gpointer data)
if(!xaccAccountGetParent(act))
{
xaccGroupInsertAccount(gnc_book_get_group(bk), act);
xaccGroupInsertAccount(gnc_book_get_group(book), act);
}
msg = node_and_account_equal((xmlNodePtr)global_data, act);
@ -365,14 +362,13 @@ guile_main(int argc, char **argv)
gnc_module_system_init();
gnc_module_load("gnucash/engine", 0);
session = gnc_session_new ();
book = gnc_book_new ();
if(argc > 1)
{
bk = gnc_session_get_book (session);
test_files_in_dir(argc, argv, test_real_account,
gnc_account_sixtp_parser_create(),
"gnc:account", session);
"gnc:account", book);
}
else
{

View File

@ -24,7 +24,7 @@
#include "Account.h"
static GNCSession *session;
static GNCBook *book;
static gchar*
node_and_commodity_equal(xmlNodePtr node, const gnc_commodity *com)
@ -151,7 +151,7 @@ test_generation(void)
int fd;
gchar *compare_msg;
ran_com = get_random_commodity(session);
ran_com = get_random_commodity(book);
test_node = gnc_commodity_dom_tree_create(ran_com);
if(!test_node)
@ -195,7 +195,7 @@ test_generation(void)
parser = gnc_commodity_sixtp_parser_create();
if(!gnc_xml_parse_file(parser, filename1, test_add_commodity,
(gpointer)&data, session))
(gpointer)&data, book))
{
failure_args("gnc_xml_parse_file returned FALSE",
__FILE__, __LINE__, "%d", i);
@ -229,13 +229,13 @@ guile_main(int argc, char **argv)
gnc_module_system_init();
gnc_module_load("gnucash/engine", 0);
session = gnc_session_new ();
book = gnc_book_new ();
if(argc > 1)
{
test_files_in_dir(argc, argv, test_real_commodity,
gnc_commodity_sixtp_parser_create(),
"gnc:commodity", session);
"gnc:commodity", book);
}
else
{

View File

@ -91,7 +91,8 @@ test_db (int i, GNCPriceDB *db)
__FILE__, __LINE__, "%d", i);
}
else if (!gnc_xml_parse_file (parser, filename1, test_add_pricedb,
(gpointer)&data, session))
(gpointer)&data,
gnc_session_get_book (session)))
{
failure_args ("gnc_xml_parse_file returned FALSE",
__FILE__, __LINE__, "%d", i);
@ -112,7 +113,7 @@ test_generation (void)
{
GNCPriceDB *db;
db = get_random_pricedb (session);
db = get_random_pricedb (gnc_session_get_book (session));
if (gnc_pricedb_get_num_prices (db))
test_db (i, db);

View File

@ -29,7 +29,7 @@
#include "Transaction.h"
#include "GNCIdP.h"
static GNCSession *session;
static GNCBook *book;
static xmlNodePtr
find_appropriate_node(xmlNodePtr node, Split *spl)
@ -330,7 +330,7 @@ test_transaction(void)
FILE *cmp_file;
int fd;
ran_trn = get_random_transaction(session);
ran_trn = get_random_transaction(book);
com = xaccTransGetCurrency (ran_trn);
@ -380,7 +380,7 @@ test_transaction(void)
parser = gnc_transaction_sixtp_parser_create();
if(!gnc_xml_parse_file(parser, filename1, test_add_transaction,
(gpointer)&data, session))
(gpointer)&data, book))
{
failure_args("gnc_xml_parse_file returned FALSE",
__FILE__, __LINE__, "%d", i);
@ -420,13 +420,13 @@ guile_main(int argc, char **argv)
xaccLogDisable();
session = gnc_session_new ();
book = gnc_book_new ();
if(argc > 1)
{
test_files_in_dir(argc, argv, test_real_transaction,
gnc_transaction_sixtp_parser_create(),
"gnc:transaction", session);
"gnc:transaction", book);
}
else
{

View File

@ -139,8 +139,7 @@ AccountGroup *
pgendGetTopGroup (PGBackend *be)
{
if (!be) return NULL;
return gnc_book_get_group (gnc_session_get_book (be->session));
return gnc_book_get_group (be->book);
}
/* ============================================================= */
@ -149,13 +148,13 @@ pgendGetTopGroup (PGBackend *be)
*/
gnc_commodity *
gnc_string_to_commodity (const char *str, GNCSession *session)
gnc_string_to_commodity (const char *str, GNCBook *book)
{
gnc_commodity_table *comtab;
gnc_commodity *com;
char *space, *name;
comtab = gnc_book_get_commodity_table (gnc_session_get_book (session));
comtab = gnc_book_get_commodity_table (book);
space = g_strdup(str);
name = strchr (space, ':');
@ -307,7 +306,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* use markers to avoid redundant traversals of transactions we've
* already checked recently. */
trans = xaccTransLookup (&trans_guid, be->session);
trans = xaccTransLookup (&trans_guid, be->book);
if (NULL != trans)
{
if (0 != trans->marker)
@ -327,7 +326,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
}
else
{
trans = xaccMallocTransaction(be->session);
trans = xaccMallocTransaction(be->book);
xaccTransBeginEdit (trans);
xaccTransSetGUID (trans, &trans_guid);
}
@ -341,7 +340,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
trans->idata = atoi(DB_GET_VAL("iguid",j));
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->session);
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->book);
xaccTransSetCurrency (trans, currency);
trans->marker = 1;
@ -540,7 +539,7 @@ pgendRunQuery (Backend *bend, Query *q)
/* first thing we do is convert the gnc-engine query into
* an sql string. */
sq = sqlQuery_new();
sql_query_string = sqlQuery_build (sq, q, be->session);
sql_query_string = sqlQuery_build (sq, q, be->book);
topgroup = pgendGetTopGroup (be);
@ -1231,6 +1230,8 @@ pgend_book_load_poll (Backend *bend)
if (!be) return;
be->book = gnc_session_get_book (be->session);
grp = pgendGetTopGroup (be);
/* don't send events to GUI, don't accept callbacks to backend */
@ -1263,6 +1264,8 @@ pgend_book_load_single (Backend *bend)
if (!be) return;
be->book = gnc_session_get_book (be->session);
grp = pgendGetTopGroup (be);
/* don't send events to GUI, don't accept callbacks to backend */
@ -1288,18 +1291,18 @@ static void
pgend_price_load_single (Backend *bend)
{
PGBackend *be = (PGBackend *)bend;
GNCBook *book;
GNCPriceDB *db;
if (!be) return;
be->book = gnc_session_get_book (be->session);
/* don't send events to GUI, don't accept callbacks to backend */
gnc_engine_suspend_events();
pgendDisable(be);
be->version_check = (guint32) time(0);
book = gnc_session_get_book (be->session);
db = gnc_book_get_pricedb (book);
db = gnc_book_get_pricedb (be->book);
pgendGetAllPrices (be, db);
@ -1356,6 +1359,7 @@ pgend_session_begin (Backend *backend,
pgendInit (be);
be->session = session;
be->book = gnc_session_get_book(session);
/* Parse the sessionid for the hostname, port number and db name.
* The expected URL format is
@ -2050,7 +2054,7 @@ pgendInit (PGBackend *be)
}
be->ipath_max = 0;
be->session = NULL;
be->book = NULL;
}
/* ============================================================= */

View File

@ -107,8 +107,9 @@ struct _pgend {
int path_cache_size;
int ipath_max;
/* enginge data caches */
/* engine data caches */
GNCSession *session;
GNCBook *book;
};
/*

View File

@ -253,10 +253,10 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
PINFO ("account GUID=%s", DB_GET_VAL("accountGUID",j));
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
acc = xaccAccountLookup (&guid, be->session);
acc = xaccAccountLookup (&guid, be->book);
if (!acc)
{
acc = xaccMallocAccount(be->session);
acc = xaccMallocAccount(be->book);
xaccAccountBeginEdit(acc);
xaccAccountSetGUID(acc, &guid);
}
@ -271,7 +271,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
xaccAccountSetType(acc, xaccAccountStringToEnum(DB_GET_VAL("type",j)));
xaccAccountSetCommodity(acc,
gnc_string_to_commodity (DB_GET_VAL("commodity",j),
be->session));
be->book));
xaccAccountSetVersion(acc, atoi(DB_GET_VAL("version",j)));
acc->idata = atoi(DB_GET_VAL("iguid",j));
@ -289,10 +289,10 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
{
/* if we haven't restored the parent account, create
* an empty holder for it */
parent = xaccAccountLookup (&guid, be->session);
parent = xaccAccountLookup (&guid, be->book);
if (!parent)
{
parent = xaccMallocAccount(be->session);
parent = xaccMallocAccount(be->book);
xaccAccountBeginEdit(parent);
xaccAccountSetGUID(parent, &guid);
}
@ -321,7 +321,7 @@ pgendGetAllAccounts (PGBackend *be, AccountGroup *topgrp)
if (!topgrp)
{
topgrp = xaccMallocAccountGroup(be->session);
topgrp = xaccMallocAccountGroup(be->book);
}
/* Get them ALL */
@ -361,7 +361,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
pgendDisable(be);
/* first, see if we already have such an account */
acc = xaccAccountLookup (acct_guid, be->session);
acc = xaccAccountLookup (acct_guid, be->book);
if (!acc)
{
engine_data_is_newer = -1;
@ -394,7 +394,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
SEND_QUERY (be,be->buff, 0);
pgendGetResults (be, get_account_cb, pgendGetTopGroup (be));
acc = xaccAccountLookup (acct_guid, be->session);
acc = xaccAccountLookup (acct_guid, be->book);
/* restore any kvp data associated with the transaction and splits */
if (acc->idata)
{

View File

@ -86,7 +86,7 @@ pgendAccountRecomputeAllCheckpoints (PGBackend *be, const GUID *acct_guid)
ENTER("be=%p", be);
guid_string = guid_to_string (acct_guid);
acc = xaccAccountLookup (acct_guid, be->session);
acc = xaccAccountLookup (acct_guid, be->book);
commodity_name =
gnc_commodity_get_unique_name (xaccAccountGetCommodity(acc));

View File

@ -265,7 +265,7 @@ pgendProcessEvents (Backend *bend)
GNCIdType local_obj_type;
/* lets see if the local cache has this item in it */
local_obj_type = xaccGUIDType (&(ev->guid), be->session);
local_obj_type = xaccGUIDType (&(ev->guid), be->book);
if ((local_obj_type != GNC_ID_NONE) && (local_obj_type != ev->obj_type))
{
PERR ("ouch! object type mismatch, local=%d, event=%d",
@ -297,7 +297,7 @@ pgendProcessEvents (Backend *bend)
xaccGroupMarkSaved (pgendGetTopGroup (be));
break;
case GNC_EVENT_DESTROY: {
Account * acc = xaccAccountLookup (&(ev->guid), be->session);
Account * acc = xaccAccountLookup (&(ev->guid), be->book);
xaccAccountBeginEdit (acc);
xaccAccountDestroy (acc);
xaccGroupMarkSaved (pgendGetTopGroup (be));
@ -327,7 +327,7 @@ pgendProcessEvents (Backend *bend)
break;
case GNC_EVENT_DESTROY: {
Transaction *trans = xaccTransLookup (&(ev->guid),
be->session);
be->book);
xaccTransBeginEdit (trans);
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);
@ -352,7 +352,7 @@ pgendProcessEvents (Backend *bend)
}
/* get the local type again, since we created guid above */
local_obj_type = xaccGUIDType (&(ev->guid), be->session);
local_obj_type = xaccGUIDType (&(ev->guid), be->book);
if (GNC_ID_NONE != local_obj_type)
{
gnc_engine_generate_event (&(ev->guid), local_obj_type);

View File

@ -759,7 +759,7 @@ sqlQuery_kvp_build (sqlQuery *sq, KVPPredicateData *kpd)
*/
const char *
sqlQuery_build (sqlQuery *sq, Query *q, GNCSession *session)
sqlQuery_build (sqlQuery *sq, Query *q, GNCBook *book)
{
GList *il, *jl, *qterms, *andterms;
QueryTerm *qt;
@ -774,7 +774,7 @@ sqlQuery_build (sqlQuery *sq, Query *q, GNCSession *session)
gboolean need_entry = FALSE;
sort_type_t sorter;
if (!sq || !q || !session) return NULL;
if (!sq || !q || !book) return NULL;
/* Determine whether the query will need to reference certain
* tables. See note above for details. */

View File

@ -53,7 +53,7 @@ sqlQuery *sqlQuery_new(void);
void sql_Query_destroy (sqlQuery *);
/* convert a gnc query to an sql query */
const char *sqlQuery_build (sqlQuery *, Query *, GNCSession *);
const char *sqlQuery_build (sqlQuery *, Query *, GNCBook *);
#endif /* GNC_QUERY_H */

View File

@ -87,7 +87,7 @@ pgendGetAllCommodities (PGBackend *be)
ENTER ("be=%p, conn=%p", be, be->connection);
comtab = gnc_book_get_commodity_table (gnc_session_get_book (be->session));
comtab = gnc_book_get_commodity_table (be->book);
if (!comtab) {
PERR ("can't get commodity table");
return;
@ -181,7 +181,7 @@ pgendStorePriceDBNoLock (PGBackend *be, GNCPriceDB *prdb)
{
gnc_commodity_table *comtab;
comtab = gnc_book_get_commodity_table (gnc_session_get_book (be->session));
comtab = gnc_book_get_commodity_table (be->book);
/* clear the marks on commodities -- we use this to mark
* the thing as 'already stored', avoiding redundant stores */
@ -238,11 +238,11 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* first, lets see if we've already got this one */
string_to_guid (DB_GET_VAL ("priceGuid", j), &guid);
pr = gnc_price_lookup (&guid, be->session);
pr = gnc_price_lookup (&guid, be->book);
if (!pr)
{
pr = gnc_price_create(be->session);
pr = gnc_price_create(be->book);
gnc_price_begin_edit (pr);
gnc_price_set_guid (pr, &guid);
not_found = 1;
@ -266,10 +266,10 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
}
gnc_price_set_version (pr, sql_vers);
modity = gnc_string_to_commodity (DB_GET_VAL("commodity",j), be->session);
modity = gnc_string_to_commodity (DB_GET_VAL("commodity",j), be->book);
gnc_price_set_commodity (pr, modity);
modity = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->session);
modity = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->book);
gnc_price_set_currency (pr, modity);
ts = gnc_iso8601_to_timespec_local (DB_GET_VAL("time",j));

View File

@ -66,7 +66,7 @@ gpointer pgendGetResults (PGBackend *be,
/* The gnc_string_to_commodity() routine finds the commodity by
* parsing a string of the form NAMESPACE::MNEMONIC
*/
gnc_commodity * gnc_string_to_commodity (const char *str, GNCSession *session);
gnc_commodity * gnc_string_to_commodity (const char *str, GNCBook *book);
/* hack alert -- calling PQFinish() is quite harsh, since all
* subsequent sql queries will fail. On the other hand, killing

View File

@ -9,6 +9,7 @@
#include "Backend.h"
#include "PostgresBackend.h"
#include "TransLog.h"
#include "gnc-book.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "gnc-module.h"
@ -474,10 +475,10 @@ test_raw_query (GNCSession *session, Query *q)
g_return_val_if_fail (session && q, FALSE);
be = (PGBackend *) session->backend;
be = (PGBackend *) gnc_session_get_backend(session);
sq = sqlQuery_new();
sql_query_string = sqlQuery_build (sq, q, session);
sql_query_string = sqlQuery_build (sq, q, gnc_session_get_book(session));
#if 0
fputs (sql_query_string, stderr);
@ -624,7 +625,7 @@ test_mode (const char *db_name, const char *mode,
session = get_random_session ();
add_random_transactions_to_session (session, 20);
add_random_transactions_to_book (gnc_session_get_book(session), 20);
if (!save_db_file (session, db_name, "single-update"))
return FALSE;

View File

@ -115,7 +115,7 @@ delete_list_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* If the database has splits that the engine doesn't,
* collect 'em up & we'll have to delete em */
if (NULL == xaccSplitLookup (&guid, be->session))
if (NULL == xaccSplitLookup (&guid, be->book))
{
DeleteTransInfo *dti;
@ -458,10 +458,10 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
s = xaccSplitLookup (&guid, be->session);
s = xaccSplitLookup (&guid, be->book);
if (!s)
{
s = xaccMallocSplit(be->session);
s = xaccMallocSplit(be->book);
xaccSplitSetGUID(s, &guid);
}
@ -479,7 +479,7 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
/* next, find the account that this split goes into */
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
acc = xaccAccountLookup (&guid, be->session);
acc = xaccAccountLookup (&guid, be->book);
if (!acc)
{
PERR ("account not found, will delete this split\n"
@ -581,10 +581,10 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
pgendDisable(be);
/* first, see if we already have such a transaction */
trans = xaccTransLookup (trans_guid, be->session);
trans = xaccTransLookup (trans_guid, be->book);
if (!trans)
{
trans = xaccMallocTransaction(be->session);
trans = xaccMallocTransaction(be->book);
do_set_guid=TRUE;
engine_data_is_newer = -1;
}
@ -686,7 +686,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
xaccTransSetDateEnteredTS (trans, &ts);
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j),
be->session);
be->book);
xaccTransSetCurrency (trans, currency);
trans->idata = atoi(DB_GET_VAL("iguid",j));
}

View File

@ -65,7 +65,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* first, see if we already have such a transaction */
string_to_guid (DB_GET_VAL("transGUID",j), &trans_guid);
trans = xaccTransLookup (&trans_guid, be->session);
trans = xaccTransLookup (&trans_guid, be->book);
if (trans)
{
/* If transaction already exists, determine whose data is
@ -85,7 +85,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
}
else
{
trans = xaccMallocTransaction(be->session);
trans = xaccMallocTransaction(be->book);
xaccTransBeginEdit (trans);
xaccTransSetGUID (trans, &trans_guid);
}
@ -99,7 +99,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
trans->idata = atoi (DB_GET_VAL("iguid",j));
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->session);
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->book);
xaccTransSetCurrency (trans, currency);
@ -132,10 +132,10 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
s = xaccSplitLookup (&guid, be->session);
s = xaccSplitLookup (&guid, be->book);
if (!s)
{
s = xaccMallocSplit(be->session);
s = xaccMallocSplit(be->book);
xaccSplitSetGUID(s, &guid);
}
@ -151,7 +151,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("transGUID",j), &guid);
trans = xaccTransLookup (&guid, be->session);
trans = xaccTransLookup (&guid, be->book);
if (!trans)
{
PERR ("trans not found, will delete this split\n"
@ -170,7 +170,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* next, find the account that this split goes into */
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
acc = xaccAccountLookup (&guid, be->session);
acc = xaccAccountLookup (&guid, be->book);
if (!acc)
{
PERR ("account not found, will delete this split\n"

View File

@ -19,19 +19,19 @@ static GList *business_modules = NULL;
struct _gncBusiness {
GHashTable * objects;
GNCSession * session;
GNCBook * book;
};
GncBusiness *gncBusinessCreate (GNCSession *session)
GncBusiness *gncBusinessCreate (GNCBook *book)
{
GncBusiness *bus;
GList *iter;
if (!session) return NULL;
if (!book) return NULL;
bus = g_new0 (GncBusiness, 1);
bus->objects = g_hash_table_new (g_str_hash, g_str_equal);
bus->session = session;
bus->book = book;
/* Populate the objects hash table with hash tables for
* each of the business objects.
@ -54,11 +54,11 @@ void gncBusinessDestroy (GncBusiness *bus)
g_free (bus);
}
GNCSession * gncBusinessGetSession (const GncBusiness *bus)
GNCBook * gncBusinessGetBook (const GncBusiness *bus)
{
if (!bus) return NULL;
return bus->session;
return bus->book;
}
gpointer

View File

@ -7,7 +7,7 @@
#ifndef GNC_BUSINESS_H_
#define GNC_BUSINESS_H_
#include "gnc-session.h"
#include "gnc-book.h"
/* Defines the version of the core business object registration
* interface. Only business modules compiled against this version
@ -29,11 +29,11 @@ struct _gncBusinessObject {
};
/* Create and Destroy the Gnc Business subsystem state */
GncBusiness *gncBusinessCreate (GNCSession *session);
GncBusiness *gncBusinessCreate (GNCBook *book);
void gncBusinessDestroy (GncBusiness *business);
/* Return the GNC Session from the Business Object */
GNCSession * gncBusinessGetSession (const GncBusiness *bus);
GNCBook * gncBusinessGetBook (const GncBusiness *bus);
/* Obtain an object from the type and GUID */
gpointer gncBusinessLookupGUID (GncBusiness *business, const char *type_name,

View File

@ -369,7 +369,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Transaction *txn;
GList *item, *iter;
GList *splitinfo = NULL;
GNCSession *session;
GNCBook *book;
gnc_numeric total;
gnc_commodity *commonCommodity = NULL;
struct acct_val {
@ -379,8 +379,8 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
if (!invoice || !acc) return NULL;
/* XXX: Need to obtain the session */
txn = xaccMallocTransaction (session);
/* XXX: Need to obtain the book */
txn = xaccMallocTransaction (book);
xaccTransBeginEdit (txn);
/* Figure out the common currency */
@ -457,7 +457,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Split *split;
acc_val = iter->data;
split = xaccMallocSplit (session);
split = xaccMallocSplit (book);
/* set action and memo? */
xaccSplitSetBaseValue (split, acc_val->val, commonCommodity);
@ -469,7 +469,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
/* Now create the Posted split (which is negative -- it's a credit) */
{
Split *split = xaccMallocSplit (session);
Split *split = xaccMallocSplit (book);
/* Set action/memo */
xaccSplitSetBaseValue (split, gnc_numeric_neg (total), commonCommodity);
xaccAccountBeginEdit (acc);
@ -500,7 +500,7 @@ GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn)
if (!value) return NULL;
guid = kvp_value_get_guid (value);
/* XXX: Need to get GNCSession from Transaction */
/* XXX: Need to get GNCBook from Transaction */
/* XXX: lookup invoice from session/guid */
return gncBusinessLookupGUID (business, GNC_INVOICE_MODULE_NAME, guid);

View File

@ -92,7 +92,7 @@
'gnc:business-create
'<gnc:GncBusiness*>
"gncBusinessCreate"
'((<gnc:Session*> session))
'((<gnc:Book*> book))
"Return a newly-created GncBusiness state object.")
(gw:wrap-function

View File

@ -20,7 +20,7 @@ test_address (void)
GncBusiness *bus;
GncAddress *address;
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
/* Test creation/destruction */
{

View File

@ -48,12 +48,12 @@ static void test_business (void)
{
bus = gncBusinessCreate (NULL);
do_test (bus == NULL, "business create NULL");
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
do_test (bus != NULL, "business create non-NULL");
do_test (gncBusinessGetSession (NULL) == NULL,
do_test (gncBusinessGetBook (NULL) == NULL,
"business get session NULL");
do_test (gncBusinessGetSession (bus) == (GNCSession *)1,
do_test (gncBusinessGetBook (bus) == (GNCBook *)1,
"business get session");
gncBusinessDestroy (bus);
@ -66,7 +66,7 @@ static void test_business (void)
gpointer ptr, res;
GHashTable *ht;
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
do_test (gncBusinessEntityTable (NULL, NULL) == NULL,
"business entity table NULL NULL");
do_test (gncBusinessEntityTable (NULL, TEST_MODULE_NAME) == NULL,

View File

@ -38,7 +38,7 @@ test_customer (void)
GncBusiness *bus;
GncCustomer *customer;
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
/* Test creation/destruction */
{

View File

@ -38,7 +38,7 @@ test_employee (void)
GncBusiness *bus;
GncEmployee *employee;
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
/* Test creation/destruction */
{

View File

@ -38,7 +38,7 @@ test_job (void)
GncBusiness *bus;
GncJob *job;
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
/* Test creation/destruction */
{

View File

@ -38,7 +38,7 @@ test_vendor (void)
GncBusiness *bus;
GncVendor *vendor;
bus = gncBusinessCreate ((GNCSession *)1);
bus = gncBusinessCreate ((GNCBook *)1);
/* Test creation/destruction */
{

View File

@ -34,10 +34,10 @@
#include "TransactionP.h"
#include "date.h"
#include "gnc-book.h"
#include "gnc-book-p.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "gnc-session-p.h"
#include "kvp_frame.h"
#include "messages.h"
@ -70,7 +70,7 @@ mark_account (Account *account)
\********************************************************************/
static void
xaccInitAccount (Account * acc, GNCSession *session)
xaccInitAccount (Account * acc, GNCBook *book)
{
acc->parent = NULL;
acc->children = NULL;
@ -105,9 +105,9 @@ xaccInitAccount (Account * acc, GNCSession *session)
acc->core_dirty = FALSE;
acc->do_free = FALSE;
acc->entity_table = gnc_session_get_entity_table (session);
acc->entity_table = gnc_book_get_entity_table (book);
xaccGUIDNew(&acc->guid, session);
xaccGUIDNew(&acc->guid, book);
xaccStoreEntity(acc->entity_table, acc, &acc->guid, GNC_ID_ACCOUNT);
LEAVE ("account=%p\n", acc);
}
@ -116,15 +116,15 @@ xaccInitAccount (Account * acc, GNCSession *session)
\********************************************************************/
Account *
xaccMallocAccount (GNCSession *session)
xaccMallocAccount (GNCBook *book)
{
Account *acc;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
acc = g_new (Account, 1);
xaccInitAccount (acc, session);
xaccInitAccount (acc, book);
gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE);
@ -132,11 +132,11 @@ xaccMallocAccount (GNCSession *session)
}
Account *
xaccCloneAccountSimple(const Account *from, GNCSession *session)
xaccCloneAccountSimple(const Account *from, GNCBook *book)
{
Account *ret;
ret = xaccMallocAccount (session);
ret = xaccMallocAccount (book);
g_return_val_if_fail (ret, NULL);
@ -700,19 +700,18 @@ xaccAccountSetGUID (Account *account, const GUID *guid)
\********************************************************************/
Account *
xaccAccountLookup (const GUID *guid, GNCSession *session)
xaccAccountLookup (const GUID *guid, GNCBook *book)
{
if (!guid) return NULL;
g_return_val_if_fail (session, NULL);
return xaccLookupEntity (gnc_session_get_entity_table (session),
if (!guid || !book) return NULL;
return xaccLookupEntity (gnc_book_get_entity_table (book),
guid, GNC_ID_ACCOUNT);
}
Account *
xaccAccountLookupDirect (GUID guid, GNCSession *session)
xaccAccountLookupDirect (GUID guid, GNCBook *book)
{
g_return_val_if_fail (session, NULL);
return xaccLookupEntity (gnc_session_get_entity_table (session),
if (!book) return NULL;
return xaccLookupEntity (gnc_book_get_entity_table (book),
&guid, GNC_ID_ACCOUNT);
}
@ -822,7 +821,7 @@ xaccAccountInsertSplit (Account *acc, Split *split)
if (!acc) return;
if (!split) return;
/* check for session mix-up */
/* check for book mix-up */
g_return_if_fail (acc->entity_table == split->entity_table);
trans = xaccSplitGetParent (split);
@ -1292,14 +1291,14 @@ xaccAccountGetCommoditySCU (Account * acc) {
void
DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency,
GNCSession *session)
GNCBook *book)
{
const char *string;
gnc_commodity *commodity;
if ((!acc) || (!currency)) return;
g_return_if_fail (session);
g_return_if_fail (book);
xaccAccountBeginEdit(acc);
string = gnc_commodity_get_unique_name (currency);
@ -1309,25 +1308,23 @@ DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency,
acc->core_dirty = TRUE;
xaccAccountCommitEdit(acc);
commodity = DxaccAccountGetCurrency (acc, session);
commodity = DxaccAccountGetCurrency (acc, book);
if (!commodity)
{
GNCBook * book = gnc_session_get_book (session);
gnc_commodity_table_insert (gnc_book_get_commodity_table (book), currency);
}
}
void
DxaccAccountSetSecurity (Account *acc, gnc_commodity * security,
GNCSession *session)
GNCBook *book)
{
const char *string;
gnc_commodity *commodity;
if ((!acc) || (!security)) return;
g_return_if_fail (session);
g_return_if_fail (book);
xaccAccountBeginEdit(acc);
string = gnc_commodity_get_unique_name (security);
@ -1337,11 +1334,9 @@ DxaccAccountSetSecurity (Account *acc, gnc_commodity * security,
acc->core_dirty = TRUE;
xaccAccountCommitEdit(acc);
commodity = DxaccAccountGetSecurity (acc, session);
commodity = DxaccAccountGetSecurity (acc, book);
if (!commodity)
{
GNCBook * book = gnc_session_get_book (session);
gnc_commodity_table_insert (gnc_book_get_commodity_table (book), security);
}
}
@ -1505,16 +1500,15 @@ xaccAccountGetNotes (Account *acc)
}
gnc_commodity *
DxaccAccountGetCurrency (Account *acc, GNCSession *session)
DxaccAccountGetCurrency (Account *acc, GNCBook *book)
{
kvp_value *v;
const char *s;
GNCBook *book;
gnc_commodity_table *table;
if (!acc) return NULL;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
v = kvp_frame_get_slot(acc->kvp_data, "old-currency");
if (!v) return NULL;
@ -1522,8 +1516,6 @@ DxaccAccountGetCurrency (Account *acc, GNCSession *session)
s = kvp_value_get_string (v);
if (!s) return NULL;
book = gnc_session_get_book (session);
table = gnc_book_get_commodity_table (book);
return gnc_commodity_table_lookup_unique (table, s);
@ -1538,16 +1530,13 @@ xaccAccountGetCommodity (Account *acc)
}
gnc_commodity *
DxaccAccountGetSecurity (Account *acc, GNCSession *session)
DxaccAccountGetSecurity (Account *acc, GNCBook *book)
{
kvp_value *v;
const char *s;
GNCBook *book;
gnc_commodity_table *table;
if (!acc) return NULL;
g_return_val_if_fail (session, NULL);
if (!acc || !book) return NULL;
v = kvp_frame_get_slot(acc->kvp_data, "old-security");
if (!v) return NULL;
@ -1555,8 +1544,6 @@ DxaccAccountGetSecurity (Account *acc, GNCSession *session)
s = kvp_value_get_string (v);
if (!s) return NULL;
book = gnc_session_get_book (session);
table = gnc_book_get_commodity_table (book);
return gnc_commodity_table_lookup_unique (table, s);

View File

@ -25,14 +25,14 @@
#ifndef XACC_ACCOUNT_H
#define XACC_ACCOUNT_H
#include "gnc-book.h"
#include "GNCId.h"
#include "Transaction.h"
#include "gnc-engine.h"
#include "kvp_frame.h"
/** PROTOTYPES ******************************************************/
/** ENUMS ******************************************************/
/*
* The account types are used to determine how the transaction data
* in the account is displayed. These values can be safely changed
@ -101,6 +101,7 @@ typedef enum
CREDITLINE = 14, /* line of credit */
} GNCAccountType;
/* ------------------ */
const char * xaccAccountGetTypeStr (GNCAccountType type); /* GUI names */
/* Conversion routines for the account types to/from strings.
@ -115,9 +116,7 @@ GNCAccountType xaccAccountStringToEnum (const char* str);
gboolean xaccAccountTypesCompatible (GNCAccountType parent_type,
GNCAccountType child_type);
/* Compare two accounts for equality - this is a deep compare. */
gboolean xaccAccountEqual(Account *a, Account* b, gboolean check_guids);
/** PROTOTYPES ******************************************************/
/*
* The xaccAccountBeginEdit() and xaccAccountCommitEdit() subroutines
* provide a two-phase-commit wrapper for account updates.
@ -127,8 +126,8 @@ gboolean xaccAccountEqual(Account *a, Account* b, gboolean check_guids);
* account. The account should have been opened for editing
* (by calling xaccAccountBeginEdit()) before calling this routine.
*/
Account * xaccMallocAccount (GNCSession *session);
Account * xaccCloneAccountSimple(const Account *from, GNCSession *session);
Account * xaccMallocAccount (GNCBook *book);
Account * xaccCloneAccountSimple(const Account *from, GNCBook *book);
void xaccAccountBeginEdit (Account *account);
void xaccAccountCommitEdit (Account *account);
void xaccAccountDestroy (Account *account);
@ -136,6 +135,7 @@ void xaccAccountDestroy (Account *account);
kvp_frame * xaccAccountGetSlots (Account *account);
void xaccAccountSetSlots_nc(Account *account, kvp_frame *frame);
/* ------------------ */
/*
* The xaccAccountGetGUID() subroutine will return the
* globally unique id associated with that account.
@ -150,9 +150,17 @@ void xaccAccountSetSlots_nc(Account *account, kvp_frame *frame);
*/
const GUID * xaccAccountGetGUID (Account *account);
GUID xaccAccountReturnGUID (Account *account);
Account * xaccAccountLookup (const GUID *guid, GNCSession *session);
Account * xaccAccountLookupDirect (GUID guid, GNCSession *session);
Account * xaccAccountLookup (const GUID *guid, GNCBook *book);
Account * xaccAccountLookupDirect (GUID guid, GNCBook *book);
GNCBook * xaccAccountGetBook (Account *account);
/* ------------------ */
/* Compare two accounts for equality - this is a deep compare. */
gboolean xaccAccountEqual(Account *a, Account* b, gboolean check_guids);
/* ------------------ */
/*
* The xaccAccountInsertSplit() method will insert the indicated
* split into the indicated account. If the split already
@ -217,13 +225,13 @@ void xaccAccountSetCommoditySCU (Account *account, int frac);
*/
/* these two funcs take control of their gnc_commodity args. Don't free */
void DxaccAccountSetCurrency (Account *account, gnc_commodity *currency,
GNCSession *session);
GNCBook *book);
void DxaccAccountSetSecurity (Account *account, gnc_commodity *security,
GNCSession *session);
GNCBook *book);
gnc_commodity * DxaccAccountGetCurrency (Account *account,
GNCSession *session);
GNCBook *book);
gnc_commodity * DxaccAccountGetSecurity (Account *account,
GNCSession *session);
GNCBook *book);
void DxaccAccountSetCurrencySCU (Account *account, int frac);
int DxaccAccountGetCurrencySCU (Account *account);

View File

@ -154,7 +154,7 @@ struct account_s
/* The xaccAccountLookupEntityTable() routine is like xaccAccountLookup
* but accepts and entity table instead of a session. */
* but accepts and entity table instead of a book. */
Account * xaccAccountLookupEntityTable (const GUID *guid,
GNCEntityTable *entity_table);

View File

@ -84,12 +84,12 @@
#include <langinfo.h>
#endif
#include "date.h"
#include "FreqSpecP.h"
#include "GNCIdP.h"
#include "date.h"
#include "gnc-book-p.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "gnc-session-p.h"
#include "messages.h"
/* I have done this to prevent compiler warnings...
@ -172,14 +172,14 @@ get_abbrev_month_name(guint month)
**/
static void
xaccFreqSpecInit( FreqSpec *fs, GNCSession *session )
xaccFreqSpecInit( FreqSpec *fs, GNCBook *book )
{
g_return_if_fail( fs );
g_return_if_fail (session);
g_return_if_fail (book);
fs->entity_table = gnc_session_get_entity_table (session);
fs->entity_table = gnc_book_get_entity_table (book);
xaccGUIDNew( &fs->guid, session );
xaccGUIDNew( &fs->guid, book );
xaccStoreEntity( fs->entity_table, fs, &fs->guid, GNC_ID_FREQSPEC );
fs->type = INVALID;
@ -189,14 +189,14 @@ xaccFreqSpecInit( FreqSpec *fs, GNCSession *session )
}
FreqSpec*
xaccFreqSpecMalloc(GNCSession *session)
xaccFreqSpecMalloc(GNCBook *book)
{
FreqSpec *fs;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
fs = g_new0(FreqSpec, 1);
xaccFreqSpecInit( fs, session );
xaccFreqSpecInit( fs, book );
/* FIXME:event */
gnc_engine_generate_event( &fs->guid, GNC_EVENT_CREATE );
return fs;

View File

@ -85,7 +85,7 @@ typedef struct gncp_freq_spec FreqSpec;
/**
* Allocates memory for a FreqSpec and initializes it.
**/
FreqSpec* xaccFreqSpecMalloc(GNCSession *session);
FreqSpec* xaccFreqSpecMalloc(GNCBook *book);
/**
* destroys any private data belonging to the FreqSpec.

View File

@ -28,7 +28,7 @@
#include "GNCIdP.h"
#include "gnc-engine-util.h"
#include "gnc-session-p.h"
#include "gnc-book-p.h"
/** #defines ********************************************************/
@ -207,10 +207,10 @@ xaccGUIDTypeEntityTable (const GUID * guid, GNCEntityTable *entity_table)
}
GNCIdType
xaccGUIDType (const GUID * guid, GNCSession *session)
xaccGUIDType (const GUID * guid, GNCBook *book)
{
return xaccGUIDTypeEntityTable (guid,
gnc_session_get_entity_table (session));
gnc_book_get_entity_table (book));
}
void
@ -233,9 +233,9 @@ xaccGUIDNewEntityTable (GUID *guid, GNCEntityTable *entity_table)
}
void
xaccGUIDNew (GUID *guid, GNCSession *session)
xaccGUIDNew (GUID *guid, GNCBook *book)
{
xaccGUIDNewEntityTable (guid, gnc_session_get_entity_table (session));
xaccGUIDNewEntityTable (guid, gnc_book_get_entity_table (book));
}
const GUID *

View File

@ -60,7 +60,7 @@ typedef enum
/* Return the type of an identifier. */
GNCIdType xaccGUIDType (const GUID * guid, GNCSession *session);
GNCIdType xaccGUIDType (const GUID * guid, GNCBook *book);
/* Returns a GUID which is guaranteed to never reference any entity. */
const GUID * xaccGUIDNULL (void);

View File

@ -41,8 +41,15 @@ void xaccEntityTableDestroy (GNCEntityTable *table);
/* Generate a new id. This function is guaranteed to return an id that
* is unique within the scope of all GnuCash entities being managed by
* the current invocation of GnuCash. GnuCash routines should always
* use this function and not guid_new! */
void xaccGUIDNew (GUID *guid, GNCSession *session);
* use this function and not guid_new!
*
* When considered over all possible instances of gnucash, the odds of
* this routine returning a non-unique id are still astronomically small.
* If you had a gazzillion computers computing new ids, for the entire
* age of teh universe, you'd still have a one-in-a-million chance of
* coming up with a duplicate. 2^128 is a really really big number.
*/
void xaccGUIDNew (GUID *guid, GNCBook *book);
void xaccGUIDNewEntityTable (GUID *guid, GNCEntityTable *entity_table);
/* Lookup an entity given an id and a type. If there is no entity

View File

@ -34,10 +34,10 @@
#include "Group.h"
#include "GroupP.h"
#include "TransactionP.h"
#include "gnc-book-p.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "gnc-numeric.h"
#include "gnc-session-p.h"
static short module = MOD_ENGINE;
@ -83,11 +83,11 @@ xaccMallocAccountGroupEntityTable (GNCEntityTable *entity_table)
}
AccountGroup *
xaccMallocAccountGroup (GNCSession *session)
xaccMallocAccountGroup (GNCBook *book)
{
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
return xaccMallocAccountGroupEntityTable
(gnc_session_get_entity_table (session));
(gnc_book_get_entity_table (book));
}
/********************************************************************\

View File

@ -29,12 +29,16 @@
#include "Account.h"
#include "GNCId.h"
#include "gnc-book.h"
#include "gnc-engine.h"
/** PROTOTYPES ******************************************************/
AccountGroup *xaccMallocAccountGroup (GNCSession *session);
AccountGroup *xaccMallocAccountGroup (GNCBook *book);
void xaccFreeAccountGroup (AccountGroup *account_group);
GNCBook * xaccGroupGetBook (AccountGroup *group);
void xaccAccountGroupBeginEdit (AccountGroup *grp);
void xaccAccountGroupCommitEdit (AccountGroup *grp);

View File

@ -27,14 +27,14 @@
#include <string.h>
#include "FreqSpec.h"
#include "GNCIdP.h"
#include "GNCId.h"
#include "SX-ttinfo.h"
#include "SchedXactionP.h"
#include "TransactionP.h"
#include "date.h"
#include "gnc-book-p.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "gnc-session-p.h"
#include "guid.h"
#include "messages.h"
@ -47,19 +47,16 @@ void sxprivtransactionListMapDelete( gpointer data, gpointer user_data );
static void
xaccSchedXactionInit( SchedXaction *sx, GNCSession *session)
xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
{
GNCBook *book;
AccountGroup *ag;
char *name;
sx->entity_table = gnc_session_get_entity_table (session);
sx->entity_table = gnc_book_get_entity_table (book);
sx->freq = xaccFreqSpecMalloc(session);
sx->freq = xaccFreqSpecMalloc(book);
book = gnc_session_get_book (session);
xaccGUIDNew( &sx->guid, session );
xaccGUIDNew( &sx->guid, book );
xaccStoreEntity( sx->entity_table, sx,
&sx->guid, GNC_ID_SCHEDXACTION );
g_date_clear( &sx->last_date, 1 );
@ -75,7 +72,7 @@ xaccSchedXactionInit( SchedXaction *sx, GNCSession *session)
sx->dirty = TRUE;
/* create a new template account for our splits */
sx->template_acct = xaccMallocAccount(session);
sx->template_acct = xaccMallocAccount(book);
name = guid_to_string( &sx->guid );
xaccAccountSetName( sx->template_acct, name );
xaccAccountSetCommodity
@ -89,14 +86,14 @@ xaccSchedXactionInit( SchedXaction *sx, GNCSession *session)
}
SchedXaction*
xaccSchedXactionMalloc(GNCSession *session)
xaccSchedXactionMalloc(GNCBook *book)
{
SchedXaction *sx;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
sx = g_new0( SchedXaction, 1 );
xaccSchedXactionInit( sx, session );
xaccSchedXactionInit( sx, book );
gnc_engine_generate_event( &sx->guid, GNC_EVENT_CREATE );
return sx;
@ -531,14 +528,14 @@ xaccSchedXactionIsDirty(SchedXaction *sx)
static Split *
pack_split_info (TTSplitInfo *s_info, Account *parent_acct,
Transaction *parent_trans, GNCSession *session)
Transaction *parent_trans, GNCBook *book)
{
Split *split;
kvp_frame *split_frame, *sx_frame;
kvp_value *tmp_value;
const GUID *acc_guid;
split = xaccMallocSplit(session);
split = xaccMallocSplit(book);
xaccSplitSetMemo(split,
gnc_ttsplitinfo_get_memo(s_info));
@ -591,7 +588,7 @@ pack_split_info (TTSplitInfo *s_info, Account *parent_acct,
void
xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
GNCSession *session)
GNCBook *book)
{
Transaction *new_trans;
TTInfo *tti;
@ -599,7 +596,7 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
Split *new_split;
GList *split_list;
g_return_if_fail (session);
g_return_if_fail (book);
/* delete any old transactions, if there are any */
delete_template_trans( sx );
@ -608,7 +605,7 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
{
tti = t_t_list->data;
new_trans = xaccMallocTransaction(session);
new_trans = xaccMallocTransaction(book);
xaccTransBeginEdit(new_trans);
@ -626,7 +623,7 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
{
s_info = split_list->data;
new_split = pack_split_info(s_info, sx->template_acct,
new_trans, session);
new_trans, book);
xaccTransAppendSplit(new_trans, new_split);
}
xaccTransCommitEdit(new_trans);

View File

@ -31,7 +31,7 @@
#include "FreqSpec.h"
#include "date.h"
#include "kvp_frame.h"
#include "gnc-book.h"
#include "gnc-engine.h"
/*
* #defines for kvp_frame strings
@ -53,7 +53,7 @@ typedef struct gncp_SchedXaction SchedXaction;
/**
* Creates and initializes a scheduled transaction.
**/
SchedXaction *xaccSchedXactionMalloc(GNCSession *session);
SchedXaction *xaccSchedXactionMalloc(GNCBook *book);
/*
* returns true if the scheduled transaction is dirty and needs to
@ -197,6 +197,6 @@ GDate xaccSchedXactionGetInstanceAfter( SchedXaction *sx,
* the edit dialog doesn't use this mechanism. Maybe it should
*/
void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
GNCSession *session);
GNCBook *book);
#endif /* XACC_SCHEDXACTION_H */

View File

@ -51,20 +51,17 @@
static short module = MOD_SCRUB;
static Account * GetOrMakeAccount (AccountGroup *root, Transaction *trans,
const char *name_root, GNCSession *session);
const char *name_root, GNCBook *book);
/* ================================================================ */
void
xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session)
xaccGroupScrubOrphans (AccountGroup *grp, GNCBook *book)
{
GList *list;
GList *node;
g_return_if_fail (session);
if (!grp)
return;
if (!grp || !book) return;
list = xaccGroupGetAccountList (grp);
@ -72,32 +69,26 @@ xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session)
{
Account *account = node->data;
xaccAccountTreeScrubOrphans (account, session);
xaccAccountTreeScrubOrphans (account, book);
}
}
void
xaccAccountTreeScrubOrphans (Account *acc, GNCSession *session)
xaccAccountTreeScrubOrphans (Account *acc, GNCBook *book)
{
g_return_if_fail (session);
if (!acc || !book) return;
if (!acc)
return;
xaccGroupScrubOrphans (xaccAccountGetChildren(acc), session);
xaccAccountScrubOrphans (acc, session);
xaccGroupScrubOrphans (xaccAccountGetChildren(acc), book);
xaccAccountScrubOrphans (acc, book);
}
void
xaccAccountScrubOrphans (Account *acc, GNCSession *session)
xaccAccountScrubOrphans (Account *acc, GNCBook *book)
{
GList *node;
const char *str;
g_return_if_fail (session);
if (!acc)
return;
if (!acc || !book) return;
str = xaccAccountGetName (acc);
str = str ? str : "(null)";
@ -109,20 +100,17 @@ xaccAccountScrubOrphans (Account *acc, GNCSession *session)
xaccTransScrubOrphans (xaccSplitGetParent (split),
xaccAccountGetRoot (acc),
session);
book);
}
}
void
xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
GNCSession *session)
GNCBook *book)
{
GList *node;
g_return_if_fail (session);
if (!trans)
return;
if (!trans || !book) return;
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
@ -136,7 +124,7 @@ xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
DEBUG ("Found an orphan \n");
orph = GetOrMakeAccount (root, trans, _("Orphan"), session);
orph = GetOrMakeAccount (root, trans, _("Orphan"), book);
if (!orph)
continue;
@ -258,14 +246,12 @@ xaccSplitScrub (Split *split)
/* ================================================================ */
void
xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session)
xaccGroupScrubImbalance (AccountGroup *grp, GNCBook *book)
{
GList *list;
GList *node;
g_return_if_fail (session);
if (!grp) return;
if (!grp || !book) return;
list = xaccGroupGetAccountList (grp);
@ -273,29 +259,26 @@ xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session)
{
Account *account = node->data;
xaccAccountTreeScrubImbalance (account, session);
xaccAccountTreeScrubImbalance (account, book);
}
}
void
xaccAccountTreeScrubImbalance (Account *acc, GNCSession *session)
xaccAccountTreeScrubImbalance (Account *acc, GNCBook *book)
{
g_return_if_fail (session);
g_return_if_fail (book);
xaccGroupScrubImbalance (xaccAccountGetChildren(acc), session);
xaccAccountScrubImbalance (acc, session);
xaccGroupScrubImbalance (xaccAccountGetChildren(acc), book);
xaccAccountScrubImbalance (acc, book);
}
void
xaccAccountScrubImbalance (Account *acc, GNCSession *session)
xaccAccountScrubImbalance (Account *acc, GNCBook *book)
{
GList *node;
const char *str;
g_return_if_fail (session);
if (!acc)
return;
if (!acc || !book) return;
str = xaccAccountGetName(acc);
str = str ? str : "(null)";
@ -306,21 +289,18 @@ xaccAccountScrubImbalance (Account *acc, GNCSession *session)
Split *split = node->data;
Transaction *trans = xaccSplitGetParent(split);
xaccTransScrubImbalance (trans, xaccAccountGetRoot (acc), NULL, session);
xaccTransScrubImbalance (trans, xaccAccountGetRoot (acc), NULL, book);
}
}
void
xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
Account *parent, GNCSession *session)
Account *parent, GNCBook *book)
{
Split *balance_split = NULL;
gnc_numeric imbalance;
g_return_if_fail (session);
if (!trans)
return;
if (!trans || !book) return;
xaccTransScrubSplits (trans);
@ -333,7 +313,7 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
return;
if (!parent)
account = GetOrMakeAccount (root, trans, _("Imbalance"), session);
account = GetOrMakeAccount (root, trans, _("Imbalance"), book);
else
account = parent;
@ -354,7 +334,7 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
/* put split into account before setting split value */
if (!balance_split)
{
balance_split = xaccMallocSplit (session);
balance_split = xaccMallocSplit (book);
xaccAccountBeginEdit (account);
xaccAccountInsertSplit (account, balance_split);
@ -409,18 +389,16 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
/* ================================================================ */
void
xaccTransScrubCurrency (Transaction *trans, GNCSession *session)
xaccTransScrubCurrency (Transaction *trans, GNCBook *book)
{
gnc_commodity *currency;
if (!trans) return;
g_return_if_fail (session);
if (!trans || !book) return;
currency = xaccTransGetCurrency (trans);
if (currency) return;
currency = xaccTransFindOldCommonCurrency (trans, session);
currency = xaccTransFindOldCommonCurrency (trans, book);
if (currency)
{
xaccTransBeginEdit (trans);
@ -436,25 +414,23 @@ xaccTransScrubCurrency (Transaction *trans, GNCSession *session)
/* ================================================================ */
void
xaccAccountScrubCommodity (Account *account, GNCSession *session)
xaccAccountScrubCommodity (Account *account, GNCBook *book)
{
gnc_commodity *commodity;
if (!account) return;
g_return_if_fail (session);
if (!account || !book) return;
commodity = xaccAccountGetCommodity (account);
if (commodity) return;
commodity = DxaccAccountGetSecurity (account, session);
commodity = DxaccAccountGetSecurity (account, book);
if (commodity)
{
xaccAccountSetCommodity (account, commodity);
return;
}
commodity = DxaccAccountGetCurrency (account, session);
commodity = DxaccAccountGetCurrency (account, book);
if (commodity)
{
xaccAccountSetCommodity (account, commodity);
@ -469,9 +445,9 @@ xaccAccountScrubCommodity (Account *account, GNCSession *session)
static gboolean
scrub_trans_currency_helper (Transaction *t, gpointer data)
{
GNCSession *session = data;
GNCBook *book = data;
xaccTransScrubCurrency (t, session);
xaccTransScrubCurrency (t, book);
return TRUE;
}
@ -479,27 +455,25 @@ scrub_trans_currency_helper (Transaction *t, gpointer data)
static gpointer
scrub_account_commodity_helper (Account *account, gpointer data)
{
GNCSession *session = data;
GNCBook *book = data;
xaccAccountScrubCommodity (account, session);
xaccAccountScrubCommodity (account, book);
xaccAccountDeleteOldData (account);
return NULL;
}
void
xaccGroupScrubCommodities (AccountGroup *group, GNCSession *session)
xaccGroupScrubCommodities (AccountGroup *group, GNCBook *book)
{
if (!group) return;
g_return_if_fail (session != NULL);
if (!group || !book) return;
xaccAccountGroupBeginEdit (group);
xaccGroupForEachTransaction (group, scrub_trans_currency_helper, session);
xaccGroupForEachTransaction (group, scrub_trans_currency_helper, book);
xaccGroupForEachAccount (group, scrub_account_commodity_helper,
session, TRUE);
book, TRUE);
xaccAccountGroupCommitEdit (group);
}
@ -508,7 +482,7 @@ xaccGroupScrubCommodities (AccountGroup *group, GNCSession *session)
static Account *
GetOrMakeAccount (AccountGroup *root, Transaction *trans,
const char *name_root, GNCSession *session)
const char *name_root, GNCBook *book)
{
gnc_commodity * currency;
char * accname;
@ -533,7 +507,7 @@ GetOrMakeAccount (AccountGroup *root, Transaction *trans,
if (acc == NULL)
{
/* guess not. We'll have to build one */
acc = xaccMallocAccount (session);
acc = xaccMallocAccount (book);
xaccAccountBeginEdit (acc);
xaccAccountSetName (acc, accname);
xaccAccountSetCommodity (acc, currency);

View File

@ -59,10 +59,10 @@
* child accounts of this group.
*/
void xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
GNCSession *session);
void xaccAccountScrubOrphans (Account *acc, GNCSession *session);
void xaccAccountTreeScrubOrphans (Account *acc, GNCSession *session);
void xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session);
GNCBook *book);
void xaccAccountScrubOrphans (Account *acc, GNCBook *book);
void xaccAccountTreeScrubOrphans (Account *acc, GNCBook *book);
void xaccGroupScrubOrphans (AccountGroup *grp, GNCBook *book);
/* The ScrubSplit methods ensure that splits with the same commodity
* and command currency have the same amount and value.
@ -79,22 +79,22 @@ void xaccGroupScrubSplits (AccountGroup *group);
* account.
*/
void xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
Account *parent, GNCSession *session);
void xaccAccountScrubImbalance (Account *acc, GNCSession *session);
void xaccAccountTreeScrubImbalance (Account *acc, GNCSession *session);
void xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session);
Account *parent, GNCBook *book);
void xaccAccountScrubImbalance (Account *acc, GNCBook *book);
void xaccAccountTreeScrubImbalance (Account *acc, GNCBook *book);
void xaccGroupScrubImbalance (AccountGroup *grp, GNCBook *book);
/* The xaccTransScrubCurrency method fixes transactions without a
* common_currency by using the old account currency and security
* fields of the parent accounts of the transaction's splits. */
void xaccTransScrubCurrency (Transaction *trans, GNCSession *session);
void xaccTransScrubCurrency (Transaction *trans, GNCBook *book);
/* The xaccAccountScrubCommodity method fixed accounts without
* a commodity by using the old account currency and security. */
void xaccAccountScrubCommodity (Account *account, GNCSession *session);
void xaccAccountScrubCommodity (Account *account, GNCBook *book);
/* The xaccGroupScrubCommodities will scrub the currency/commodity
* of all accounts & transactions in the group. */
void xaccGroupScrubCommodities (AccountGroup *group, GNCSession *session);
void xaccGroupScrubCommodities (AccountGroup *group, GNCBook *book);
#endif /* XACC_SCRUB_H */

View File

@ -38,11 +38,11 @@
#include "TransactionP.h"
#include "TransLog.h"
#include "date.h"
#include "gnc-book-p.h"
#include "gnc-commodity.h"
#include "gnc-engine-util.h"
#include "gnc-engine.h"
#include "gnc-event-p.h"
#include "gnc-session-p.h"
#include "messages.h"
@ -139,10 +139,10 @@ xaccMallocSplitEntityTable (GNCEntityTable *entity_table)
}
Split *
xaccMallocSplit(GNCSession *session)
xaccMallocSplit(GNCBook *book)
{
g_return_val_if_fail (session, NULL);
return xaccMallocSplitEntityTable (gnc_session_get_entity_table (session));
g_return_val_if_fail (book, NULL);
return xaccMallocSplitEntityTable (gnc_book_get_entity_table (book));
}
/********************************************************************\
@ -500,11 +500,10 @@ xaccSplitLookupEntityTable (const GUID *guid, GNCEntityTable *entity_table)
}
Split *
xaccSplitLookup (const GUID *guid, GNCSession *session)
xaccSplitLookup (const GUID *guid, GNCBook *book)
{
if (!guid) return NULL;
g_return_val_if_fail (session, NULL);
return xaccLookupEntity(gnc_session_get_entity_table (session),
if (!guid || !book) return NULL;
return xaccLookupEntity(gnc_book_get_entity_table (book),
guid, GNC_ID_SPLIT);
}
@ -761,7 +760,7 @@ xaccSplitGetReconciledBalance (Split *s) {
\********************************************************************/
static void
xaccInitTransaction (Transaction * trans, GNCSession *session)
xaccInitTransaction (Transaction * trans, GNCBook *book)
{
/* Fill in some sane defaults */
trans->num = g_cache_insert(gnc_engine_get_string_cache(), "");
@ -786,9 +785,9 @@ xaccInitTransaction (Transaction * trans, GNCSession *session)
trans->kvp_data = kvp_frame_new();
trans->idata = 0;
trans->entity_table = gnc_session_get_entity_table (session);
trans->entity_table = gnc_book_get_entity_table (book);
xaccGUIDNew (&trans->guid, session);
xaccGUIDNew (&trans->guid, book);
xaccStoreEntity (trans->entity_table, trans, &trans->guid, GNC_ID_TRANS);
}
@ -796,11 +795,11 @@ xaccInitTransaction (Transaction * trans, GNCSession *session)
\********************************************************************/
Transaction *
xaccMallocTransaction (GNCSession *session)
xaccMallocTransaction (GNCBook *book)
{
Transaction *trans = g_new(Transaction, 1);
xaccInitTransaction (trans, session);
xaccInitTransaction (trans, book);
gnc_engine_generate_event (&trans->guid, GNC_EVENT_CREATE);
@ -1129,11 +1128,10 @@ xaccTransLookupEntityTable (const GUID *guid,
}
Transaction *
xaccTransLookup (const GUID *guid, GNCSession *session)
xaccTransLookup (const GUID *guid, GNCBook *book)
{
if (!guid) return NULL;
g_return_val_if_fail (session, NULL);
return xaccLookupEntity (gnc_session_get_entity_table (session),
if (!guid || !book) return NULL;
return xaccLookupEntity (gnc_book_get_entity_table (book),
guid, GNC_ID_TRANS);
}
@ -1358,16 +1356,14 @@ xaccTransGetImbalance (Transaction * trans)
\********************************************************************/
static gnc_commodity *
FindCommonExclSCurrency (GList *splits,
FindCommonExclSCurrency (SplitList *splits,
gnc_commodity * ra, gnc_commodity * rb,
Split *excl_split,
GNCSession *session)
GNCBook *book)
{
GList *node;
if (!splits) return NULL;
g_return_val_if_fail (session, NULL);
if (!splits || !book) return NULL;
for (node = splits; node; node = node->next)
{
@ -1387,8 +1383,8 @@ FindCommonExclSCurrency (GList *splits,
else if (xaccSplitGetAccount(s) == NULL)
continue;
sa = DxaccAccountGetCurrency (xaccSplitGetAccount(s), session);
sb = DxaccAccountGetSecurity (xaccSplitGetAccount(s), session);
sa = DxaccAccountGetCurrency (xaccSplitGetAccount(s), book);
sb = DxaccAccountGetSecurity (xaccSplitGetAccount(s), book);
if (ra && rb) {
int aa = !gnc_commodity_equiv(ra,sa);
@ -1427,13 +1423,13 @@ FindCommonExclSCurrency (GList *splits,
*/
static gnc_commodity *
FindCommonCurrency (GList *splits, gnc_commodity * ra, gnc_commodity * rb,
GNCSession *session)
GNCBook *book)
{
return FindCommonExclSCurrency(splits, ra, rb, NULL, session);
return FindCommonExclSCurrency(splits, ra, rb, NULL, book);
}
gnc_commodity *
xaccTransFindOldCommonCurrency (Transaction *trans, GNCSession *session)
xaccTransFindOldCommonCurrency (Transaction *trans, GNCBook *book)
{
gnc_commodity *ra, *rb, *retval;
Split *split;
@ -1442,16 +1438,16 @@ xaccTransFindOldCommonCurrency (Transaction *trans, GNCSession *session)
if (trans->splits == NULL) return NULL;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
split = trans->splits->data;
if (xaccSplitGetAccount(split) == NULL) return NULL;
ra = DxaccAccountGetCurrency (xaccSplitGetAccount(split), session);
rb = DxaccAccountGetSecurity (xaccSplitGetAccount(split), session);
ra = DxaccAccountGetCurrency (xaccSplitGetAccount(split), book);
rb = DxaccAccountGetSecurity (xaccSplitGetAccount(split), book);
retval = FindCommonCurrency (trans->splits, ra, rb, session);
retval = FindCommonCurrency (trans->splits, ra, rb, book);
/* compare this value to what we think should be the 'right' value */
if (!trans->common_currency)

View File

@ -1,7 +1,7 @@
/********************************************************************\
* Transaction.h -- api for transactions & splits (journal entries) *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997, 1998, 1999, 2000 Linas Vepstas *
* Copyright (C) 1997-2001 Linas Vepstas <linas@linas.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -41,15 +41,6 @@
#define NREC 'n' /* not reconciled or cleared */
#define VREC 'v' /* split is void */
/** STRUCTS *********************************************************/
typedef struct account_s Account;
typedef struct account_group_s AccountGroup;
typedef struct split_s Split;
typedef struct transaction_s Transaction;
typedef GList AccountList;
typedef GList SplitList;
/** PROTOTYPES ******************************************************/
@ -78,7 +69,7 @@ int xaccConfigGetForceDoubleEntry (void);
* Once created, it is usually unsafe to merely "free" this memory;
* the xaccTransDestroy() method should be called.
*/
Transaction * xaccMallocTransaction (GNCSession *session);
Transaction * xaccMallocTransaction (GNCBook *book);
gboolean xaccTransEqual(const Transaction *ta,
const Transaction *tb,
@ -132,7 +123,7 @@ gboolean xaccTransIsOpen (Transaction *trans);
*/
const GUID * xaccTransGetGUID (Transaction *trans);
GUID xaccTransReturnGUID (Transaction *trans);
Transaction * xaccTransLookup (const GUID *guid, GNCSession *session);
Transaction * xaccTransLookup (const GUID *guid, GNCBook *book);
/* Transaction slots are used to store arbitrary strings, numbers, and
@ -245,7 +236,7 @@ void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr);
gnc_numeric xaccTransGetImbalance (Transaction * trans);
/* ------------- splits --------------- */
Split * xaccMallocSplit (GNCSession *session);
Split * xaccMallocSplit (GNCBook *book);
gboolean xaccSplitEqual(const Split *sa, const Split *sb,
gboolean check_guids,
@ -270,7 +261,7 @@ void xaccSplitSetSlots_nc(Split *s, kvp_frame *frm);
*/
const GUID * xaccSplitGetGUID (Split *split);
GUID xaccSplitReturnGUID (Split *split);
Split * xaccSplitLookup (const GUID *guid, GNCSession *session);
Split * xaccSplitLookup (const GUID *guid, GNCBook *book);
/* The memo is an arbitrary string associated with a split.
* Users typically type in free form text from the GUI.

View File

@ -244,6 +244,6 @@ gint32 xaccTransGetVersion (Transaction*);
* transaction have in common, using the old currency/security fields
* of the split accounts. */
gnc_commodity * xaccTransFindOldCommonCurrency (Transaction *trans,
GNCSession *session);
GNCBook *book);
#endif /* XACC_TRANSACTION_P_H */

View File

@ -28,7 +28,9 @@
#include <libguile.h>
#include <string.h>
#include "Account.h"
#include "Backend.h"
#include "Group.h"
#include "Query.h"
#include "date.h"
#include "engine-helpers.h"

View File

@ -110,7 +110,7 @@
;; scheme split. Not all values are copied. The reconcile
;; status and date are not copied. The C split's guid is,
;; of course, unchanged.
(define (gnc:split-scm-onto-split split-scm split session)
(define (gnc:split-scm-onto-split split-scm split book)
(if (not split)
#f
(begin
@ -124,7 +124,7 @@
(if value (gnc:split-set-value split value)))
(let ((account (gnc:account-lookup
(gnc:split-scm-get-account-guid split-scm)
session)))
book)))
(if account
(begin
(gnc:account-begin-edit account)
@ -241,7 +241,7 @@
;; guid-mapping must be an alist, mapping guids to guids. This list is
;; used to use alternate account guids when creating splits.
(define (gnc:transaction-scm-onto-transaction trans-scm trans guid-mapping
commit? session)
commit? book)
(if (not trans)
#f
(begin
@ -273,14 +273,14 @@
;; order as in the original transaction. This is important.
(let loop ((split-scms (gnc:transaction-scm-get-split-scms trans-scm)))
(if (pair? split-scms)
(let* ((new-split (gnc:split-create session))
(let* ((new-split (gnc:split-create book))
(split-scm (car split-scms))
(old-guid (gnc:split-scm-get-account-guid split-scm))
(new-guid (assoc-ref guid-mapping old-guid)))
(if (not new-guid)
(set! new-guid old-guid))
(gnc:split-scm-set-account-guid split-scm new-guid)
(gnc:split-scm-onto-split split-scm new-split session)
(gnc:split-scm-onto-split split-scm new-split book)
(gnc:split-scm-set-account-guid split-scm old-guid)
(gnc:transaction-append-split trans new-split)
(loop (cdr split-scms)))))

View File

@ -24,12 +24,14 @@
* HISTORY:
* Created 2001 by Rob Browning
* Copyright (c) 2001 Rob Browning
* Copyright (c) 2001 Linas Vepstas <linas@linas.org>
*/
#ifndef GNC_BOOK_P_H
#define GNC_BOOK_P_H
#include "BackendP.h"
#include "GNCIdP.h"
#include "DateUtils.h"
#include "TransLog.h"
#include "gnc-book.h"
@ -39,6 +41,12 @@
struct gnc_book_struct
{
/* The entity table associates the GUIDs of all the objects
* created in the session with their respective objects
* (pointer addresses) */
GNCEntityTable *entity_table;
/* Pointers to top-level data structures */
AccountGroup *topgroup;
GNCPriceDB *pricedb;
@ -48,6 +56,10 @@ struct gnc_book_struct
gnc_commodity_table *commodity_table;
/* To be technically correct, backends belong to sessions and
* 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;
};
@ -57,6 +69,8 @@ void gnc_book_set_pricedb(GNCBook *book, GNCPriceDB *db);
void gnc_book_set_backend (GNCBook *book, Backend *be);
GNCEntityTable * gnc_book_get_entity_table (GNCBook *book);
/*
* used by backends to mark the notsaved as FALSE just after
* loading. Do not use otherwise!

View File

@ -63,18 +63,19 @@ static short module = MOD_IO;
/* ---------------------------------------------------------------------- */
static void
gnc_book_init (GNCBook *book, GNCSession *session)
gnc_book_init (GNCBook *book)
{
Account *template_acct;
if (!book) return;
book->topgroup = xaccMallocAccountGroup(session);
book->entity_table = xaccEntityTableNew ();
book->topgroup = xaccMallocAccountGroup(book);
book->pricedb = gnc_pricedb_create();
book->sched_xactions = NULL;
book->sx_notsaved = FALSE;
book->template_group = xaccMallocAccountGroup(session);
book->template_group = xaccMallocAccountGroup(book);
/* FIXME: the gnc_engine_commodity_table_new() routine invokes
* guile/scheme to load the default list of currencies. This
@ -87,20 +88,27 @@ gnc_book_init (GNCBook *book, GNCSession *session)
}
GNCBook *
gnc_book_new (GNCSession *session)
gnc_book_new (void)
{
GNCBook *book;
g_return_val_if_fail (session, NULL);
book = g_new0(GNCBook, 1);
gnc_book_init(book, session);
gnc_book_init(book);
return book;
}
/* ---------------------------------------------------------------------- */
GNCEntityTable *
gnc_book_get_entity_table (GNCBook *book)
{
if (!book) return NULL;
return book->entity_table;
}
/* ---------------------------------------------------------------------- */
gnc_commodity_table *
gnc_book_get_commodity_table(GNCBook *book)
{
@ -311,6 +319,9 @@ gnc_book_destroy (GNCBook *book)
/* FIXME: destroy SX data members here, too */
xaccEntityTableDestroy (book->entity_table);
book->entity_table = NULL;
xaccLogEnable();
g_free (book);

View File

@ -29,7 +29,7 @@
*
* HISTORY:
* Created by Linas Vepstas December 1998
* Copyright (c) 1998, 1999 Linas Vepstas
* Copyright (c) 1998, 1999, 2001 Linas Vepstas <linas@linas.org>
* Copyright (c) 2000 Dave Peticolas
*/
@ -38,27 +38,16 @@
#include "gnc-engine.h"
#include "gnc-pricedb.h"
#include "Backend.h"
#include "Group.h"
/** TYPES **********************************************************/
struct gnc_book_struct;
typedef struct gnc_book_struct GNCBook;
/** PROTOTYPES ******************************************************/
GNCBook * gnc_book_new (GNCSession *session);
GNCBook * gnc_book_new (void);
void gnc_book_destroy (GNCBook *book);
AccountGroup *gnc_book_get_group (GNCBook *book);
void gnc_book_set_group(GNCBook *book, AccountGroup *group);
GNCPriceDB *gnc_book_get_pricedb (GNCBook *book);
GNCBook * xaccGroupGetBook (AccountGroup *group);
GNCBook * xaccAccountGetBook (Account *account);
guint gnc_book_count_transactions(GNCBook *book);
gnc_commodity_table* gnc_book_get_commodity_table(GNCBook *book);

View File

@ -1,6 +1,7 @@
/********************************************************************
* gnc-engine.h -- top-level include file for Gnucash Engine *
* Copyright 2000 Bill Gribble <grib@billgribble.com> *
* Copyright 2001 Linas Vepstas <linas@linas.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -24,11 +25,23 @@
#ifndef GNC_ENGINE_H
#define GNC_ENGINE_H
#include <glib.h>
#include "gnc-commodity.h"
/** TYPES **********************************************************/
typedef struct account_s Account;
typedef struct account_group_s AccountGroup;
typedef struct split_s Split;
typedef struct transaction_s Transaction;
typedef struct gnc_book_struct GNCBook;
typedef struct gnc_session_struct GNCSession;
typedef GList AccountList;
typedef GList SplitList;
typedef void (* gnc_engine_init_hook_t)(int, char **);

View File

@ -30,9 +30,9 @@
#include "GNCIdP.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "gnc-book-p.h"
#include "gnc-event-p.h"
#include "gnc-pricedb-p.h"
#include "gnc-session-p.h"
#include "guid.h"
/* This static indicates the debugging module that this .o belongs to. */
@ -47,11 +47,11 @@ static gboolean remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup);
/* allocation */
GNCPrice *
gnc_price_create (GNCSession *session)
gnc_price_create (GNCBook *book)
{
GNCPrice *p;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
p = g_new0(GNCPrice, 1);
@ -62,9 +62,9 @@ gnc_price_create (GNCSession *session)
p->version = 0;
p->version_check = 0;
p->entity_table = gnc_session_get_entity_table (session);
p->entity_table = gnc_book_get_entity_table (book);
xaccGUIDNew (&p->guid, session);
xaccGUIDNew (&p->guid, book);
xaccStoreEntity (p->entity_table, p, &p->guid, GNC_ID_PRICE);
gnc_engine_generate_event (&p->guid, GNC_EVENT_CREATE);
@ -115,18 +115,18 @@ gnc_price_unref(GNCPrice *p)
/* ==================================================================== */
GNCPrice *
gnc_price_clone (GNCPrice* p, GNCSession *session)
gnc_price_clone (GNCPrice* p, GNCBook *book)
{
/* the clone doesn't belong to a PriceDB */
GNCPrice *new_p;
ENTER ("pr=%p", p);
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (book, NULL);
if(!p) return NULL;
new_p = gnc_price_create(session);
new_p = gnc_price_create(book);
if(!new_p) return NULL;
new_p->version = p->version;
@ -370,11 +370,11 @@ gnc_price_set_version(GNCPrice *p, gint32 vers)
/* getters */
GNCPrice *
gnc_price_lookup (const GUID *guid, GNCSession *session)
gnc_price_lookup (const GUID *guid, GNCBook *book)
{
if (!guid) return NULL;
g_return_val_if_fail (session, NULL);
return xaccLookupEntity (gnc_session_get_entity_table (session),
g_return_val_if_fail (book, NULL);
return xaccLookupEntity (gnc_book_get_entity_table (book),
guid, GNC_ID_PRICE);
}

View File

@ -116,12 +116,12 @@ typedef struct gnc_price_lookup_s GNCPriceLookup;
/* gnc_price_create - returns a newly allocated and initialized price
with a reference count of 1. */
GNCPrice *gnc_price_create(GNCSession *session);
GNCPrice *gnc_price_create(GNCBook *book);
/* gnc_price_clone - returns a newly allocated price that's a
content-wise duplicate of the given price, p. The returned clone
will have a reference count of 1. */
GNCPrice *gnc_price_clone(GNCPrice* p, GNCSession *session);
GNCPrice *gnc_price_clone(GNCPrice* p, GNCBook *book);
/*********************/
/* memory management */
@ -163,7 +163,7 @@ void gnc_price_set_version(GNCPrice *p, gint32 versn);
/* As mentioned above all of the getters return data that's internal
to the GNCPrice, not copies, so don't free these values. */
GNCPrice * gnc_price_lookup (const GUID *guid, GNCSession *session);
GNCPrice * gnc_price_lookup (const GUID *guid, GNCBook *book);
const GUID * gnc_price_get_guid (GNCPrice *p);
gnc_commodity * gnc_price_get_commodity(GNCPrice *p);
gnc_commodity * gnc_price_get_currency(GNCPrice *p);

View File

@ -40,11 +40,6 @@ struct gnc_session_struct
/* The book is the cache for the underlying gnucash dataset. */
GNCBook *book;
/* The entity table associates the GUIDs of all the objects
* created in the session with their respective objects
* (pointer addresses) */
GNCEntityTable *entity_table;
/* the requested book id, in the form or a URI, such as
* file:/some/where, or sql:server.host.com:555
*/
@ -63,20 +58,15 @@ struct gnc_session_struct
char *fullpath;
char *logpath;
/* kvp database for per-session data for user code */
kvp_frame * kvp_data;
/* ---------------------------------------------------- */
/* This struct member applies for network, rpc and SQL i/o */
/* It is not currently used for file i/o, but it should be. */
/* Pointer to the backend that is actually used to move data
* between the persistant store and the local engine. */
Backend *backend;
};
void gnc_session_set_book (GNCSession *session, GNCBook *book);
GNCEntityTable *gnc_session_get_entity_table (GNCSession *session);
Backend * gnc_session_get_backend (GNCSession *session);
/*

View File

@ -119,15 +119,12 @@ gnc_session_init (GNCSession *session)
{
if (!session) return;
session->entity_table = xaccEntityTableNew ();
session->book = gnc_book_new (session);
session->book = gnc_book_new ();
session->book_id = NULL;
session->fullpath = NULL;
session->logpath = NULL;
session->backend = NULL;
session->kvp_data = kvp_frame_new ();
gnc_session_clear_error (session);
}
@ -162,20 +159,6 @@ gnc_session_set_book (GNCSession *session, GNCBook *book)
gnc_book_set_backend (book, session->backend);
}
kvp_frame *
gnc_session_get_slots (GNCSession *session)
{
if (!session) return NULL;
return session->kvp_data;
}
GNCEntityTable *
gnc_session_get_entity_table (GNCSession *session)
{
if (!session) return NULL;
return session->entity_table;
}
Backend *
gnc_session_get_backend (GNCSession *session)
{
@ -382,7 +365,7 @@ gnc_session_load (GNCSession *session)
xaccLogDisable();
gnc_book_destroy (session->book);
session->book = gnc_book_new (session);
session->book = gnc_book_new ();
xaccLogSetBaseName(session->logpath);
xaccLogEnable();
@ -604,12 +587,6 @@ gnc_session_destroy (GNCSession *session)
gnc_book_destroy (session->book);
session->book = NULL;
xaccEntityTableDestroy (session->entity_table);
session->entity_table = NULL;
kvp_frame_delete (session->kvp_data);
session->kvp_data = NULL;
xaccLogEnable();
g_free (session);
@ -621,27 +598,15 @@ void
gnc_session_swap_data (GNCSession *session_1, GNCSession *session_2)
{
GNCBook *book_1, *book_2;
GNCEntityTable *entity_table_1, *entity_table_2;
kvp_frame *kvp_1, *kvp_2;
if (session_1 == session_2) return;
if (!session_1 || !session_2) return;
book_1 = session_1->book;
entity_table_1 = session_1->entity_table;
kvp_1 = session_1->kvp_data;
book_2 = session_2->book;
entity_table_2 = session_2->entity_table;
kvp_2 = session_2->kvp_data;
session_1->book = book_2;
session_1->entity_table = entity_table_2;
session_1->kvp_data = kvp_2;
session_2->book = book_1;
session_2->entity_table = entity_table_1;
session_2->kvp_data = kvp_1;
gnc_book_set_backend (book_1, session_2->backend);
gnc_book_set_backend (book_2, session_1->backend);

View File

@ -69,7 +69,7 @@
#ifndef GNC_SESSION_H
#define GNC_SESSION_H
#include "gnc-book.h"
#include "Backend.h"
#include "gnc-engine.h"
/** PROTOTYPES ******************************************************/
@ -77,8 +77,8 @@
GNCSession * gnc_session_new (void);
void gnc_session_destroy (GNCSession *session);
/* The gnc_session_swap_data () method swaps the book and
* entity tables of the two given sessions. It is useful
/* 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);
@ -153,9 +153,6 @@ GNCBackendError gnc_session_pop_error (GNCSession *session);
GNCBook * gnc_session_get_book (GNCSession *session);
void gnc_session_set_book (GNCSession *session, GNCBook *book);
/* Return the kvp data for the session */
kvp_frame * gnc_session_get_slots (GNCSession *session);
/* 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

View File

@ -313,6 +313,8 @@
"#include <guid.h>\n"
"#include <Query.h>\n"
"#include <Backend.h>\n"
"#include <Group.h>\n"
"#include <gnc-book.h>\n"
"#include <gnc-session.h>\n"
"#include <gnc-engine-util.h>\n"
"#include <date.h>\n"
@ -899,7 +901,7 @@ number of nanoseconds.")
'gnc:malloc-account
'<gnc:Account*>
"xaccMallocAccount"
'((<gnc:Session*> session))
'((<gnc:Book*> book))
"Allocate a new account structure.")
(gw:wrap-function
@ -1034,7 +1036,7 @@ description of the nature of a particular account.")
'gnc:account-lookup
'<gnc:Account*>
"xaccAccountLookupDirect"
'((<gnc:guid-scm> guid) (<gnc:Session*> session))
'((<gnc:guid-scm> guid) (<gnc:Book*> book))
"Lookup the account with GUID guid.")
(gw:wrap-function
@ -1207,7 +1209,7 @@ children to this account.")
'gnc:malloc-account-group
'<gnc:AccountGroup*>
"xaccMallocAccountGroup"
'((<gnc:Session*> session))
'((<gnc:Book*> book))
"Create a new account group.")
(gw:wrap-function
@ -1356,7 +1358,7 @@ when no longer needed.")
'gnc:price-create
'<gnc:Price*>
"gnc_price_create"
'((<gnc:Session*> session))
'((<gnc:Book*> book))
"Create and return a new price.")
(gw:wrap-function
@ -1495,7 +1497,7 @@ when no longer needed.")
"Lookup a price at time t.")
;;===========
;; GNCBook
;; GNCSession
(gw:wrap-function
mod
@ -1717,7 +1719,7 @@ of having a parent transaction with which one is working...")
'gnc:transaction-create
'<gnc:Transaction*>
"xaccMallocTransaction"
'((<gnc:Session*> session>))
'((<gnc:Book*> book>))
"Create a Transaction structure")
(gw:wrap-function
@ -1725,7 +1727,7 @@ of having a parent transaction with which one is working...")
'gnc:split-create
'<gnc:Split*>
"xaccMallocSplit"
'((<gnc:Session*> session>>))
'((<gnc:Book*> book>>))
"Create a Split structure")
(gw:wrap-function

View File

@ -11,6 +11,7 @@
#include <unistd.h>
#include "date.h"
#include "Group.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "test-engine-stuff.h"
@ -27,7 +28,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(GNCSession *session, Transaction *trn);
static void add_random_splits(GNCBook *book, Transaction *trn);
/***********************************************************************/
@ -155,20 +156,20 @@ get_random_commodity_namespace(void)
}
void
make_random_changes_to_price (GNCSession *session, GNCPrice *p)
make_random_changes_to_price (GNCBook *book, GNCPrice *p)
{
Timespec *ts;
char *string;
gnc_commodity *c;
g_return_if_fail (session && p);
g_return_if_fail (book && p);
gnc_price_begin_edit (p);
c = get_random_commodity (session);
c = get_random_commodity (book);
gnc_price_set_commodity (p, c);
c = get_random_commodity (session);
c = get_random_commodity (book);
gnc_price_set_currency (p, c);
ts = get_random_timespec ();
@ -189,19 +190,19 @@ make_random_changes_to_price (GNCSession *session, GNCPrice *p)
}
GNCPrice *
get_random_price(GNCSession *session)
get_random_price(GNCBook *book)
{
GNCPrice *p;
p = gnc_price_create (session);
p = gnc_price_create (book);
make_random_changes_to_price (session, p);
make_random_changes_to_price (book, p);
return p;
}
void
make_random_pricedb (GNCSession *session, GNCPriceDB *db)
make_random_pricedb (GNCBook *book, GNCPriceDB *db)
{
int num_prices;
@ -211,7 +212,7 @@ make_random_pricedb (GNCSession *session, GNCPriceDB *db)
{
GNCPrice *p;
p = get_random_price (session);
p = get_random_price (book);
gnc_pricedb_add_price (db, p);
@ -220,12 +221,12 @@ make_random_pricedb (GNCSession *session, GNCPriceDB *db)
}
GNCPriceDB *
get_random_pricedb(GNCSession *session)
get_random_pricedb(GNCBook *book)
{
GNCPriceDB *db;
db = gnc_pricedb_create ();
make_random_pricedb (session, db);
make_random_pricedb (book, db);
return db;
}
@ -241,7 +242,7 @@ price_accumulator (GNCPrice *p, gpointer data)
}
void
make_random_changes_to_pricedb (GNCSession *session, GNCPriceDB *pdb)
make_random_changes_to_pricedb (GNCBook *book, GNCPriceDB *pdb)
{
GList *list = NULL;
GList *node;
@ -262,7 +263,7 @@ make_random_changes_to_pricedb (GNCSession *session, GNCPriceDB *pdb)
case 1:
case 2: /* Change */
make_random_changes_to_price (session, p);
make_random_changes_to_price (book, p);
break;
default: /* nothing */
@ -278,7 +279,7 @@ make_random_changes_to_pricedb (GNCSession *session, GNCPriceDB *pdb)
while (i--)
{
GNCPrice *p = get_random_price (session);
GNCPrice *p = get_random_price (book);
gnc_pricedb_add_price (pdb, p);
@ -525,7 +526,7 @@ set_account_random_string(Account* act,
}
static void
account_add_subaccounts (GNCSession *session, Account *account, int depth)
account_add_subaccounts (GNCBook *book, Account *account, int depth)
{
int num_accounts;
@ -536,16 +537,16 @@ account_add_subaccounts (GNCSession *session, Account *account, int depth)
while (num_accounts-- > 0)
{
Account *sub = get_random_account (session);
Account *sub = get_random_account (book);
xaccAccountInsertSubAccount (account, sub);
account_add_subaccounts (session, sub, depth - 1);
account_add_subaccounts (book, sub, depth - 1);
}
}
static AccountGroup *
get_random_group_depth(GNCSession *session, int depth)
get_random_group_depth(GNCBook *book, int depth)
{
AccountGroup *group;
int num_accounts;
@ -553,30 +554,30 @@ get_random_group_depth(GNCSession *session, int depth)
if (depth <= 0)
return NULL;
group = xaccMallocAccountGroup (session);
group = xaccMallocAccountGroup (book);
num_accounts = get_random_int_in_range (1, max_group_accounts);
while (num_accounts-- > 0)
{
Account *account = get_random_account (session);
Account *account = get_random_account (book);
xaccGroupInsertAccount (group, account);
account_add_subaccounts (session, account, depth - 1);
account_add_subaccounts (book, account, depth - 1);
}
return group;
}
AccountGroup *
get_random_group (GNCSession *session)
get_random_group (GNCBook *book)
{
int depth;
depth = get_random_int_in_range (1, max_group_depth);
return get_random_group_depth (session, depth);
return get_random_group_depth (book, depth);
}
typedef struct
@ -585,7 +586,7 @@ typedef struct
} TransInfo;
static void
change_trans_helper (GNCSession *session, Transaction *trans, GList *accounts)
change_trans_helper (GNCBook *book, Transaction *trans, GList *accounts)
{
GList *splits;
GList *node;
@ -593,7 +594,7 @@ change_trans_helper (GNCSession *session, Transaction *trans, GList *accounts)
xaccTransBeginEdit (trans);
make_random_changes_to_transaction (session, trans);
make_random_changes_to_transaction (book, trans);
switch (get_random_int_in_range (0, 3))
{
@ -608,7 +609,7 @@ change_trans_helper (GNCSession *session, Transaction *trans, GList *accounts)
xaccSplitDestroy (split);
} while (split);
add_random_splits (session, trans);
add_random_splits (book, trans);
/* fall through */
@ -675,7 +676,7 @@ add_trans_helper (Transaction *trans, gpointer data)
}
void
make_random_changes_to_group (GNCSession *session, AccountGroup *group)
make_random_changes_to_group (GNCBook *book, AccountGroup *group)
{
Account *new_account;
Account *account;
@ -684,12 +685,12 @@ make_random_changes_to_group (GNCSession *session, AccountGroup *group)
GList *splits;
GList *node;
g_return_if_fail (group && session);
g_return_if_fail (group && book);
accounts = xaccGroupGetSubAccounts (group);
/* Add a new account */
new_account = get_random_account (session);
new_account = get_random_account (book);
if (get_random_boolean ())
xaccGroupInsertAccount (group, new_account);
@ -704,7 +705,7 @@ make_random_changes_to_group (GNCSession *session, AccountGroup *group)
accounts = xaccGroupGetSubAccounts (group);
/* Add some new transactions */
add_random_transactions_to_session (session, get_random_int_in_range (1, 6));
add_random_transactions_to_book (book, get_random_int_in_range (1, 6));
/* Mess with the accounts */
for (node = accounts; node; node = node->next)
@ -712,7 +713,7 @@ make_random_changes_to_group (GNCSession *session, AccountGroup *group)
Account *account = node->data;
if (get_random_boolean ())
make_random_changes_to_account (session, account);
make_random_changes_to_account (book, account);
}
/* Mess with the transactions & splits */
@ -722,12 +723,12 @@ make_random_changes_to_group (GNCSession *session, AccountGroup *group)
for (node = transes; node; node = node->next)
{
TransInfo *ti = node->data;
Transaction *trans = xaccTransLookup (&ti->guid, session);
Transaction *trans = xaccTransLookup (&ti->guid, book);
if (!trans)
continue;
change_trans_helper (session, trans, accounts);
change_trans_helper (book, trans, accounts);
}
for (node = transes; node; node = node->next)
@ -802,12 +803,12 @@ make_random_changes_to_group (GNCSession *session, AccountGroup *group)
}
Account*
get_random_account(GNCSession *session)
get_random_account(GNCBook *book)
{
Account *ret;
int tmp_int;
ret = xaccMallocAccount(session);
ret = xaccMallocAccount(book);
xaccAccountBeginEdit(ret);
@ -819,7 +820,7 @@ get_random_account(GNCSession *session)
set_account_random_string(ret, xaccAccountSetCode);
set_account_random_string(ret, xaccAccountSetDescription);
xaccAccountSetCommodity(ret, get_random_commodity(session));
xaccAccountSetCommodity(ret, get_random_commodity(book));
xaccAccountSetSlots_nc(ret, get_random_kvp_frame());
@ -829,7 +830,7 @@ get_random_account(GNCSession *session)
}
void
make_random_changes_to_account (GNCSession *session, Account *account)
make_random_changes_to_account (GNCBook *book, Account *account)
{
int tmp_int;
@ -845,7 +846,7 @@ make_random_changes_to_account (GNCSession *session, Account *account)
set_account_random_string (account, xaccAccountSetCode);
set_account_random_string (account, xaccAccountSetDescription);
xaccAccountSetCommodity (account, get_random_commodity(session));
xaccAccountSetCommodity (account, get_random_commodity(book));
xaccAccountSetSlots_nc (account, get_random_kvp_frame());
@ -868,12 +869,12 @@ set_split_random_string(Split *spl,
static char possible_chars[] = { NREC, CREC, YREC, FREC };
Split*
get_random_split(GNCSession *session, gnc_numeric num)
get_random_split(GNCBook *book, gnc_numeric num)
{
Split *ret;
gnc_numeric oneVal;
ret = xaccMallocSplit(session);
ret = xaccMallocSplit(book);
set_split_random_string(ret, xaccSplitSetMemo);
set_split_random_string(ret, xaccSplitSetAction);
@ -939,12 +940,12 @@ set_tran_random_string(Transaction* trn,
}
static void
add_random_splits(GNCSession *session, Transaction *trn)
add_random_splits(GNCBook *book, Transaction *trn)
{
gnc_numeric num = get_random_gnc_numeric();
xaccTransAppendSplit(trn, get_random_split(session, num));
xaccTransAppendSplit(trn, get_random_split(session, gnc_numeric_neg(num)));
xaccTransAppendSplit(trn, get_random_split(book, num));
xaccTransAppendSplit(trn, get_random_split(book, gnc_numeric_neg(num)));
}
static void
@ -960,18 +961,18 @@ trn_add_ran_timespec(Transaction *trn, void (*func)(Transaction*,
Transaction *
get_random_transaction_with_currency(GNCSession *session,
get_random_transaction_with_currency(GNCBook *book,
gnc_commodity *currency)
{
Transaction* ret;
ret = xaccMallocTransaction(session);
ret = xaccMallocTransaction(book);
xaccTransBeginEdit(ret);
xaccTransSetCurrency (ret,
currency ? currency :
get_random_commodity (session));
get_random_commodity (book));
set_tran_random_string(ret, xaccTransSetNum);
@ -982,7 +983,7 @@ get_random_transaction_with_currency(GNCSession *session,
xaccTransSetSlots_nc(ret, get_random_kvp_frame());
add_random_splits(session, ret);
add_random_splits(book, ret);
if (get_random_int_in_range (1, 10) == 1)
{
@ -997,25 +998,25 @@ get_random_transaction_with_currency(GNCSession *session,
}
Transaction*
get_random_transaction (GNCSession *session)
get_random_transaction (GNCBook *book)
{
return get_random_transaction_with_currency (session, NULL);
return get_random_transaction_with_currency (book, NULL);
}
void
make_random_changes_to_transaction (GNCSession *session, Transaction *trans)
make_random_changes_to_transaction (GNCBook *book, Transaction *trans)
{
GList *list;
GList *node;
g_return_if_fail (trans && session);
g_return_if_fail (trans && book);
if (xaccTransGetVoidStatus (trans))
return;
xaccTransBeginEdit (trans);
xaccTransSetCurrency (trans, get_random_commodity (session));
xaccTransSetCurrency (trans, get_random_commodity (book));
set_tran_random_string (trans, xaccTransSetNum);
@ -1075,7 +1076,7 @@ get_random_commodity_from_table (gnc_commodity_table *table)
}
gnc_commodity*
get_random_commodity (GNCSession *session)
get_random_commodity (GNCBook *book)
{
gnc_commodity *ret;
gchar *name;
@ -1085,7 +1086,7 @@ get_random_commodity (GNCSession *session)
int ran_int;
gnc_commodity_table *table;
table = gnc_book_get_commodity_table (gnc_session_get_book (session));
table = gnc_book_get_commodity_table (book);
#if 0
if (table &&
@ -1435,15 +1436,15 @@ get_random_query(void)
}
GNCBook *
get_random_book (GNCSession *session)
get_random_book (void)
{
GNCBook *book;
book = gnc_book_new (session);
book = gnc_book_new ();
gnc_book_set_group (book, get_random_group (session));
gnc_book_set_group (book, get_random_group (book));
make_random_pricedb (session, gnc_book_get_pricedb (book));
make_random_pricedb (book, gnc_book_get_pricedb (book));
return book;
}
@ -1458,26 +1459,23 @@ get_random_session (void)
book = gnc_session_get_book (session);
gnc_book_set_group (book, get_random_group (session));
gnc_book_set_group (book, get_random_group (book));
make_random_pricedb (session, gnc_book_get_pricedb (book));
make_random_pricedb (book, gnc_book_get_pricedb (book));
return session;
}
void
add_random_transactions_to_session (GNCSession *session, gint num_transactions)
add_random_transactions_to_book (GNCBook *book, gint num_transactions)
{
gnc_commodity_table *table;
GList *accounts;
gint num_accounts;
GNCBook *book;
if (num_transactions <= 0) return;
g_return_if_fail (session);
book = gnc_session_get_book (session);
g_return_if_fail (book);
accounts = xaccGroupGetSubAccounts (gnc_book_get_group (book));
@ -1485,7 +1483,7 @@ add_random_transactions_to_session (GNCSession *session, gint num_transactions)
num_accounts = g_list_length (accounts);
table = gnc_book_get_commodity_table (gnc_session_get_book (session));
table = gnc_book_get_commodity_table (book);
while (num_transactions--)
{
@ -1496,7 +1494,7 @@ add_random_transactions_to_session (GNCSession *session, gint num_transactions)
com = get_random_commodity_from_table (table);
trans = get_random_transaction_with_currency (session, com);
trans = get_random_transaction_with_currency (book, com);
xaccTransBeginEdit (trans);
@ -1515,12 +1513,12 @@ add_random_transactions_to_session (GNCSession *session, gint num_transactions)
}
void
make_random_changes_to_book (GNCSession *session, GNCBook *book)
make_random_changes_to_book (GNCBook *book)
{
g_return_if_fail (session && book);
g_return_if_fail (book);
make_random_changes_to_group (session, gnc_book_get_group (book));
make_random_changes_to_pricedb (session, gnc_book_get_pricedb (book));
make_random_changes_to_group (book, gnc_book_get_group (book));
make_random_changes_to_pricedb (book, gnc_book_get_pricedb (book));
#if 0
make_random_changes_to_commodity_table (gnc_book_get_commodity_table (book));
@ -1532,7 +1530,7 @@ make_random_changes_to_session (GNCSession *session)
{
g_return_if_fail (session);
make_random_changes_to_book (session, gnc_session_get_book (session));
make_random_changes_to_book (gnc_session_get_book (session));
}
typedef struct

View File

@ -40,16 +40,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(GNCSession *session);
void make_random_pricedb (GNCSession *session, GNCPriceDB *pdb);
GNCPriceDB * get_random_pricedb(GNCSession *session);
AccountGroup * get_random_group(GNCSession * session);
Account* get_random_account(GNCSession * session);
Split* get_random_split(GNCSession *session, gnc_numeric num);
Transaction* get_random_transaction(GNCSession *session);
Transaction* get_random_transaction_with_currency(GNCSession *session,
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,
gnc_commodity *currency);
gnc_commodity* get_random_commodity(GNCSession *session);
gnc_commodity* get_random_commodity(GNCBook *book);
const char *get_random_commodity_namespace(void);
typedef enum
@ -68,22 +68,21 @@ 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 (GNCSession *session);
GNCBook * get_random_book (void);
GNCSession * get_random_session (void);
void add_random_transactions_to_session (GNCSession *session,
gint num_transactions);
void add_random_transactions_to_book (GNCBook *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 (GNCSession *session, GNCPrice *price);
void make_random_changes_to_pricedb (GNCSession *session, GNCPriceDB *pdb);
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_split (Split *split);
void make_random_changes_to_transaction (GNCSession *session,
void make_random_changes_to_transaction (GNCBook *book,
Transaction *trans);
void make_random_changes_to_account (GNCSession *session, Account *account);
void make_random_changes_to_group (GNCSession *session, AccountGroup *group);
void make_random_changes_to_book (GNCSession *session, GNCBook *book);
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);
#endif

View File

@ -105,9 +105,9 @@ test_commodity(void)
int j;
gnc_commodity_table *tbl;
gnc_commodity *coms[20];
GNCSession *session;
GNCBook *book;
session = gnc_session_new ();
book = gnc_book_new ();
tbl = gnc_commodity_table_new ();
do_test(gnc_commodity_table_get_size(tbl) == 0,
@ -115,7 +115,7 @@ test_commodity(void)
for(i = 0; i < 20; i++)
{
coms[i] = get_random_commodity(session);
coms[i] = get_random_commodity(book);
do_test(
gnc_commodity_table_insert(tbl, coms[i]) != NULL,

View File

@ -8,8 +8,9 @@
(gnc:module-load "gnucash/engine" 0)
(let* ((session (gnc:session-new))
(group (gnc:malloc-account-group session))
(acct (gnc:malloc-account session)))
(book (gnc:session-get-book session))
(group (gnc:malloc-account-group book))
(acct (gnc:malloc-account book)))
(gnc:account-begin-edit acct)
(gnc:account-set-name acct "foo")
(gnc:account-commit-edit acct)

View File

@ -16,9 +16,9 @@
#include "GNCIdP.h"
#include "gnc-engine.h"
#include "gnc-module.h"
#include "gnc-session.h"
#include "gnc-book.h"
static GNCSession *session;
static GNCBook *book;
static void
test_once (void)
@ -27,7 +27,7 @@ test_once (void)
guint32 i, start_julian;
GDate date1, date2, next_date;
fs = xaccFreqSpecMalloc(session);
fs = xaccFreqSpecMalloc(book);
for( start_julian = 1; start_julian < 1000; ++start_julian ) {
g_date_set_julian( &date1, start_julian );
@ -53,7 +53,7 @@ test_daily (void)
FreqSpec *fs;
GDate date1, date2, next_date;
fs = xaccFreqSpecMalloc(session);
fs = xaccFreqSpecMalloc(book);
g_date_set_dmy( &date1, 1, 1, 2000 );
@ -101,7 +101,7 @@ test_weekly (void)
FreqSpec *fs;
GDate date1, date2, next_date;
fs = xaccFreqSpecMalloc(session);
fs = xaccFreqSpecMalloc(book);
/* Use this to test any specific cases which fail,
* for easy access in the debugger. */
@ -161,7 +161,7 @@ test_monthly (void)
FreqSpec *fs;
GDate date0, date1, date2, next_date;
fs = xaccFreqSpecMalloc(session);
fs = xaccFreqSpecMalloc(book);
/* Use this to test any specific cases which fail,
* for easy access in the debugger. */
@ -234,7 +234,7 @@ test_month_relative (void)
FreqSpec *fs;
GDate date0, date1, date2, next_date;
fs = xaccFreqSpecMalloc(session);
fs = xaccFreqSpecMalloc(book);
/* Use this to test any specific cases which fail,
* for easy access in the debugger. */
@ -349,7 +349,7 @@ test_composite (void)
FreqSpec *fs, *fs2;
GDate date0, date1, date2, next_date;
fs = xaccFreqSpecMalloc(session);
fs = xaccFreqSpecMalloc(book);
/* Use this to test any specific cases which fail,
* for easy access in the debugger. */
@ -371,17 +371,17 @@ test_composite (void)
xaccFreqSpecSetComposite( fs );
fs2 = xaccFreqSpecMalloc(session);
fs2 = xaccFreqSpecMalloc(book);
g_date_set_dmy( &date0, 29, 3, 2001 ); /* Wednesday */
xaccFreqSpecSetWeekly( fs2, &date0, 2 );
xaccFreqSpecCompositeAdd( fs, fs2 );
fs2 = xaccFreqSpecMalloc(session);
fs2 = xaccFreqSpecMalloc(book);
g_date_set_dmy( &date0, 3, 4, 2001 ); /* Tuesday */
xaccFreqSpecSetWeekly( fs2, &date0, 2 );
xaccFreqSpecCompositeAdd( fs, fs2 );
fs2 = xaccFreqSpecMalloc(session);
fs2 = xaccFreqSpecMalloc(book);
g_date_set_dmy( &date0, 7, 4, 2001 ); /* Saturday */
xaccFreqSpecSetWeekly( fs2, &date0, 2 );
xaccFreqSpecCompositeAdd( fs, fs2 );
@ -535,7 +535,7 @@ guile_main( int argc, char* argv[] )
set_success_print(TRUE);
#endif
session = gnc_session_new ();
book = gnc_book_new ();
test_once();
@ -549,7 +549,7 @@ guile_main( int argc, char* argv[] )
test_composite();
gnc_session_destroy (session);
gnc_book_destroy (book);
print_test_results();
exit (get_rv());

View File

@ -2,6 +2,7 @@
#include <glib.h>
#include <guile/gh.h>
#include "Group.h"
#include "GNCIdP.h"
#include "TransLog.h"
#include "gnc-book.h"
@ -40,16 +41,20 @@ group_has_book (AccountGroup *group, GNCBook *book)
static void
run_test (void)
{
GNCSession *session;
AccountGroup *group1;
AccountGroup *group2;
Account *account1;
Account *account2;
GNCBook *book;
session = gnc_session_new ();
book = gnc_book_new ();
if (!book)
{
failure("book not created");
exit(get_rv());
}
group1 = get_random_group (session);
group1 = get_random_group (book);
if(!group1)
{
failure("group1 not created");
@ -62,13 +67,6 @@ run_test (void)
exit(get_rv());
}
book = gnc_book_new (session);
if (!book)
{
failure("book not created");
exit(get_rv());
}
gnc_book_set_group (book, group1);
if (!group_has_book (group1, book))
{
@ -76,7 +74,7 @@ run_test (void)
exit(get_rv());
}
group2 = get_random_group (session);
group2 = get_random_group (book);
if(!group2)
{
failure("group2 not created");
@ -97,7 +95,7 @@ run_test (void)
exit(get_rv());
}
account1 = get_random_account (session);
account1 = get_random_account (book);
if(!account1)
{
failure("account1 not created");
@ -111,7 +109,7 @@ run_test (void)
exit(get_rv());
}
account2 = get_random_account (session);
account2 = get_random_account (book);
if(!account2)
{
failure("account2 not created");

View File

@ -2,8 +2,9 @@
#include <glib.h>
#include <guile/gh.h>
#include "TransLog.h"
#include "Group.h"
#include "Transaction.h"
#include "TransLog.h"
#include "gnc-engine.h"
#include "gnc-module.h"
#include "gnc-session.h"
@ -13,13 +14,11 @@
static gboolean
test_trans_query (Transaction *trans, gpointer data)
{
GNCSession *session = data;
AccountGroup *group;
GNCBook *book;
GNCBook *book = data;
GList *list;
Query *q;
book = gnc_session_get_book (session);
group = gnc_book_get_group (book);
q = make_trans_query (trans, ALL_QT);
@ -28,7 +27,9 @@ test_trans_query (Transaction *trans, gpointer data)
list = xaccQueryGetTransactions (q, QUERY_MATCH_ANY);
if (g_list_length (list) != 1)
{
failure ("number of matching transactions not 1");
failure_args ("test number returned", __FILE__, __LINE__,
"number of matching transactions %d not 1",
g_list_length (list));
return FALSE;
}
@ -55,9 +56,9 @@ run_test (void)
book = gnc_session_get_book (session);
group = gnc_book_get_group (book);
add_random_transactions_to_session (session, 20);
add_random_transactions_to_book (book, 20);
xaccGroupForEachTransaction (group, test_trans_query, session);
xaccGroupForEachTransaction (group, test_trans_query, book);
gnc_session_destroy (session);
}

View File

@ -37,17 +37,19 @@ run_test (void)
Split *spl;
gnc_numeric num;
GNCSession *session;
GNCBook *book;
session = gnc_session_new ();
book = gnc_session_get_book (session);
act1 = get_random_account(session);
act1 = get_random_account(book);
if(!act1)
{
failure("act1 not created");
return;
}
act2 = get_random_account(session);
act2 = get_random_account(book);
if(!act2)
{
failure("act2 not created");
@ -55,7 +57,7 @@ run_test (void)
}
num = get_random_gnc_numeric();
spl = get_random_split(session, num);
spl = get_random_split(book, num);
if(!spl)
{
failure("spl not created");

View File

@ -41,16 +41,16 @@ run_test (void)
Transaction *transaction;
gnc_numeric old_amt, new_amt, new_kvp_amt, old_val, new_val, new_kvp_val;
int rval;
GNCSession *session;
GNCBook *book;
Timespec ts;
time_t now;
char *reason = "because I can";
session = gnc_session_new();
book = gnc_book_new();
acc1 = get_random_account(session);
acc2 = get_random_account(session);
acc1 = get_random_account(book);
acc2 = get_random_account(book);
if (!acc1 || !acc2)
{
@ -59,7 +59,7 @@ run_test (void)
do
{
transaction = get_random_transaction (session);
transaction = get_random_transaction (book);
if (xaccTransGetVoidStatus (transaction))
{
xaccTransBeginEdit (transaction);

View File

@ -369,7 +369,7 @@ gnc_account_tree_refresh(GNCAccountTree * tree)
gtk_clist_clear(clist);
root_account = xaccAccountLookup (&tree->root_account,
gnc_get_current_session ());
gnc_get_current_book ());
gnc_account_tree_fill (tree, expanded_accounts,
gnc_account_tree_insert_row (tree, NULL, NULL,

View File

@ -646,7 +646,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate )
for ( i=1; i<6; i++ ) {
*gd2 = *gd;
g_date_add_days( gd2, i );
tmpFS = xaccFreqSpecMalloc(gnc_get_current_session ());
tmpFS = xaccFreqSpecMalloc(gnc_get_current_book ());
xaccFreqSpecSetWeekly( tmpFS, gd2, tmpInt );
xaccFreqSpecCompositeAdd( fs, tmpFS );
}
@ -674,7 +674,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate )
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ) {
tmpFS = xaccFreqSpecMalloc
(gnc_get_current_session ());
(gnc_get_current_book ());
xaccFreqSpecSetUIType( tmpFS, uift );
/* struct-copy is expected to work, here */
/* [wish we didn't have to know about the GDate implementation...] */
@ -706,7 +706,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate )
o = glade_xml_get_widget( gf->gxml, "semimonthly_first" );
day = gnc_option_menu_get_active( GTK_WIDGET(o) )+1;
tmpFS = xaccFreqSpecMalloc(gnc_get_current_session ());
tmpFS = xaccFreqSpecMalloc(gnc_get_current_book ());
tmpTm = g_new0( struct tm, 1 );
g_date_to_struct_tm( gd, tmpTm );
if ( day >= tmpTm->tm_mday ) {
@ -723,7 +723,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate )
o = glade_xml_get_widget( gf->gxml, "semimonthly_second" );
day = gnc_option_menu_get_active( GTK_WIDGET(o) )+1;
tmpFS = xaccFreqSpecMalloc(gnc_get_current_session ());
tmpFS = xaccFreqSpecMalloc(gnc_get_current_book ());
tmpTimeT = gnome_date_edit_get_date( gf->startDate );
gd = g_date_new();
g_date_set_time( gd, tmpTimeT );
@ -838,7 +838,7 @@ update_cal( GNCFrequency *gf, GtkCalendar *cal )
FreqSpec *fs;
gnc_suspend_gui_refresh();
fs = xaccFreqSpecMalloc(gnc_get_current_session ());
fs = xaccFreqSpecMalloc(gnc_get_current_book ());
gnc_frequency_save_state( gf, fs, NULL );
mark_calendar( cal, fs );
xaccFreqSpecFree( fs );

View File

@ -596,7 +596,7 @@ add_clicked (GtkWidget *widget, gpointer data)
if (pdb_dialog->price)
gnc_price_unref (pdb_dialog->price);
pdb_dialog->price = gnc_price_create (gnc_get_current_session ());
pdb_dialog->price = gnc_price_create (gnc_get_current_book ());
pdb_dialog->new = TRUE;
pdb_dialog->changed = TRUE;
@ -615,20 +615,20 @@ static void
get_quotes_clicked (GtkWidget *widget, gpointer data)
{
PricesDialog *pdb_dialog = data;
GNCSession *session = gnc_get_current_session ();
GNCBook *book = gnc_get_current_book ();
SCM quotes_func;
SCM session_scm;
SCM book_scm;
quotes_func = gh_eval_str ("gnc:session-add-quotes");
quotes_func = gh_eval_str ("gnc:book-add-quotes");
if (!gh_procedure_p (quotes_func))
return;
session_scm = gnc_session_to_scm (session);
if (gh_scm2bool (gh_not (session_scm)))
book_scm = gnc_book_to_scm (book);
if (gh_scm2bool (gh_not (book_scm)))
return;
gnc_set_busy_cursor (NULL, TRUE);
gh_call1 (quotes_func, session_scm);
gh_call1 (quotes_func, book_scm);
gnc_unset_busy_cursor (NULL);
gnc_gui_refresh_all ();

View File

@ -1209,7 +1209,7 @@ new_button_clicked( GtkButton *b, gpointer d )
FreqSpec *fs;
GDate *gd;
SchedXaction *tmpSX =
xaccSchedXactionMalloc( gnc_get_current_session ());
xaccSchedXactionMalloc( gnc_get_current_book ());
SchedXactionEditorDialog *sxed;
/* Give decent initial FreqSpec for SX */

View File

@ -224,7 +224,7 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti)
tt_list = g_list_append(tt_list, tti);
xaccSchedXactionSetTemplateTrans(sxfti->sx, tt_list,
gnc_get_current_session ());
gnc_get_current_book ());
return 0;
}
@ -249,7 +249,7 @@ sxftd_update_fs( SXFromTransInfo *sxfti, GDate *date, FreqSpec *fs )
break;
case FREQ_WEEKLY:
tmpfs = xaccFreqSpecMalloc(gnc_get_current_session ());
tmpfs = xaccFreqSpecMalloc(gnc_get_current_book ());
xaccFreqSpecSetComposite(fs);
xaccFreqSpecSetWeekly(tmpfs, date, 1);
xaccFreqSpecSetUIType(fs, UIFREQ_WEEKLY);
@ -307,7 +307,7 @@ sxftd_init( SXFromTransInfo *sxfti )
/* compute good initial date. */
start_tt = xaccTransGetDate( sxfti->trans );
g_date_set_time( &date, start_tt );
fs = xaccFreqSpecMalloc( gnc_get_current_session() );
fs = xaccFreqSpecMalloc( gnc_get_current_book() );
sxftd_update_fs( sxfti, &date, fs );
xaccFreqSpecGetNextInstance( fs, &date, &nextDate );
@ -358,7 +358,7 @@ sxftd_compute_sx(SXFromTransInfo *sxfti)
w = glade_xml_get_widget( sxfti->gxml, SXFTD_START_DATE_EDIT );
g_date_set_time( &date, gnome_date_edit_get_date( GNOME_DATE_EDIT(w) ) );
fs = xaccFreqSpecMalloc(gnc_get_current_session ());
fs = xaccFreqSpecMalloc(gnc_get_current_book ());
sxftd_update_fs( sxfti, &date, fs );
if (sxftd_errno == 0)
{
@ -446,7 +446,7 @@ sxftd_freq_option_changed( GtkWidget *w, gpointer user_data )
tmp_tt = xaccTransGetDate( sxfti->trans );
g_date_set_time( &date, tmp_tt );
fs = xaccFreqSpecMalloc( gnc_get_current_session() );
fs = xaccFreqSpecMalloc( gnc_get_current_book() );
sxftd_update_fs( sxfti, &date, fs );
xaccFreqSpecGetNextInstance( fs, &date, &nextDate );
@ -506,7 +506,7 @@ gnc_sx_create_from_trans(Transaction *trans)
sxfti->trans = trans;
sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_session ());
sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ());
if ( (errno = sxftd_init( sxfti )) < 0 ) {
PERR( "Error in sxftd_init: %d", errno );

View File

@ -1422,7 +1422,7 @@ create_each_transaction_helper( Transaction *t, void *d )
createUD = (createData*)d;
tct = createUD->tct;
newT = xaccMallocTransaction(gnc_get_current_session ());
newT = xaccMallocTransaction(gnc_get_current_book ());
xaccTransBeginEdit( newT );
/* the action and description/memo are in the template */
gnc_copy_trans_onto_trans( t, newT, FALSE, FALSE );
@ -1468,7 +1468,7 @@ create_each_transaction_helper( Transaction *t, void *d )
}
acct_guid = kvp_value_get_guid( kvp_val );
acct = xaccAccountLookup( acct_guid,
gnc_get_current_session ());
gnc_get_current_book ());
#if 0
DEBUG( "Got account with name \"%s\"",
xaccAccountGetName( acct ) );

View File

@ -1112,7 +1112,7 @@ gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
gnc_suspend_gui_refresh ();
/* Create the transaction */
trans = xaccMallocTransaction(gnc_get_current_session ());
trans = xaccMallocTransaction(gnc_get_current_book ());
xaccTransBeginEdit(trans);
@ -1126,11 +1126,11 @@ gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
xaccTransSetDescription(trans, string);
/* create from split */
from_split = xaccMallocSplit(gnc_get_current_session ());
from_split = xaccMallocSplit(gnc_get_current_book ());
xaccTransAppendSplit(trans, from_split);
/* create to split */
to_split = xaccMallocSplit(gnc_get_current_session ());
to_split = xaccMallocSplit(gnc_get_current_book ());
xaccTransAppendSplit(trans, to_split);
xaccAccountBeginEdit(from_account);

View File

@ -356,7 +356,7 @@ on_choose_account_types_prepare (GnomeDruidPage *gnomedruidpage,
gchar *locale_dir = gnc_get_ea_locale_dir (GNC_ACCOUNTS_DIR);
gnc_suspend_gui_refresh ();
list = gnc_load_example_account_list (gnc_get_current_session (),
list = gnc_load_example_account_list (gnc_get_current_book (),
locale_dir);
gnc_resume_gui_refresh ();
@ -567,7 +567,7 @@ clone_account (const Account* from, gnc_commodity *com)
{
Account *ret;
ret = xaccCloneAccountSimple (from, gnc_get_current_session ());
ret = xaccCloneAccountSimple (from, gnc_get_current_book ());
xaccAccountSetCommodity (ret, com);
@ -639,7 +639,7 @@ hierarchy_merge_groups (GSList *dalist)
{
GSList *mark;
gnc_commodity *com;
AccountGroup *ret = xaccMallocAccountGroup (gnc_get_current_session ());
AccountGroup *ret = xaccMallocAccountGroup (gnc_get_current_book ());
com = gnc_general_select_get_selected (get_commodity_editor ());
@ -821,7 +821,7 @@ starting_balance_helper (Account *account, gpointer data)
balance = get_final_balance (account);
if (!gnc_numeric_zero_p (balance))
gnc_account_create_opening_balance (account, balance, time (NULL),
gnc_get_current_session ());
gnc_get_current_book ());
return NULL;
}

View File

@ -26,6 +26,7 @@
#include <gnome.h>
#include "Group.h"
#include "Transaction.h"
#include "dialog-utils.h"
#include "druid-utils.h"
#include "global-options.h"
@ -173,7 +174,7 @@ refresh_details_page (StockSplitInfo *info)
GNCPrintAmountInfo print_info;
Account *account;
account = xaccAccountLookup (&info->account, gnc_get_current_session ());
account = xaccAccountLookup (&info->account, gnc_get_current_book ());
g_return_if_fail (account != NULL);
@ -197,7 +198,7 @@ account_next (GnomeDruidPage *druidpage,
StockSplitInfo *info = user_data;
Account *account;
account = xaccAccountLookup (&info->account, gnc_get_current_session ());
account = xaccAccountLookup (&info->account, gnc_get_current_book ());
g_return_val_if_fail (account != NULL, TRUE);
@ -357,7 +358,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
Split *split;
time_t date;
account = xaccAccountLookup (&info->account, gnc_get_current_session ());
account = xaccAccountLookup (&info->account, gnc_get_current_book ());
g_return_if_fail (account != NULL);
amount = gnc_amount_edit_get_amount
@ -366,7 +367,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
gnc_suspend_gui_refresh ();
trans = xaccMallocTransaction (gnc_get_current_session ());
trans = xaccMallocTransaction (gnc_get_current_book ());
xaccTransBeginEdit (trans);
@ -382,7 +383,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
xaccTransSetDescription (trans, description);
}
split = xaccMallocSplit (gnc_get_current_session ());
split = xaccMallocSplit (gnc_get_current_book ());
xaccAccountBeginEdit (account);
account_commits = g_list_prepend (NULL, account);
@ -409,7 +410,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
ts.tv_sec = date;
ts.tv_nsec = 0;
price = gnc_price_create (gnc_get_current_session ());
price = gnc_price_create (gnc_get_current_book ());
gnc_price_begin_edit (price);
gnc_price_set_commodity (price, xaccAccountGetCommodity (account));
@ -441,7 +442,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
account = gnc_account_tree_get_current_account
(GNC_ACCOUNT_TREE (info->asset_tree));
split = xaccMallocSplit (gnc_get_current_session ());
split = xaccMallocSplit (gnc_get_current_book ());
xaccAccountBeginEdit (account);
account_commits = g_list_prepend (account_commits, account);
@ -460,7 +461,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
account = gnc_account_tree_get_current_account
(GNC_ACCOUNT_TREE (info->income_tree));
split = xaccMallocSplit (gnc_get_current_session ());
split = xaccMallocSplit (gnc_get_current_book ());
xaccAccountBeginEdit (account);
account_commits = g_list_prepend (account_commits, account);
@ -499,7 +500,7 @@ account_currency_filter (Account *account, gpointer user_data)
{
StockSplitInfo *info = user_data;
Account *split_account = xaccAccountLookup (&info->account,
gnc_get_current_session ());
gnc_get_current_book ());
if (!account)
return FALSE;
@ -677,8 +678,8 @@ refresh_handler (GHashTable *changes, gpointer user_data)
GtkWidget *page;
GladeXML *xml;
id_type = xaccGUIDType (&info->account, gnc_get_current_session ());
old_account = xaccAccountLookup (&info->account, gnc_get_current_session ());
id_type = xaccGUIDType (&info->account, gnc_get_current_book ());
old_account = xaccAccountLookup (&info->account, gnc_get_current_book ());
if (fill_account_list (info, old_account) == 0)
{
@ -686,7 +687,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
return;
}
new_account = xaccAccountLookup (&info->account, gnc_get_current_session ());
new_account = xaccAccountLookup (&info->account, gnc_get_current_book ());
if (id_type == GNC_ID_NULL || old_account == new_account)
return;

Some files were not shown because too many files have changed in this diff Show More