Work on moving entity tables into sessions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5467 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/g2-gog-integ
Dave Peticolas 25 years ago
parent 97b19d1878
commit c672e1960c

@ -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();
p = gnc_price_create(session);
if(!p) { ok = FALSE; goto cleanup_and_exit; }
for(child = price_xml->xmlChildrenNode; child; child = child->next) {

@ -217,7 +217,7 @@ 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();
GNCPrice *price = gnc_price_create(session);
Timespec time = xaccTransRetDatePostedTS(txn);
gnc_price_begin_edit(price);

@ -3627,7 +3627,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();
p = gnc_price_create(pstatus->session);
if(!p) { ok = FALSE; goto cleanup_and_exit; }
for(child = price_xml->xmlChildrenNode; child; child = child->next) {

@ -240,7 +240,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
if (!pr)
{
pr = gnc_price_create();
pr = gnc_price_create(be->session);
gnc_price_begin_edit (pr);
gnc_price_set_guid (pr, &guid);
not_found = 1;

@ -30,7 +30,8 @@
#include "BackendP.h"
#include "gnc-pricedb.h"
struct _GNCPrice {
struct gnc_price_s
{
/* 'public' data fields */
GUID guid; /* globally unique price id */
GNCPriceDB *db;
@ -52,7 +53,8 @@ struct _GNCPrice {
struct _GNCPriceDB {
struct gnc_price_db_s
{
GHashTable *commodity_hash;
Backend *backend;
gboolean dirty;
@ -72,7 +74,8 @@ typedef enum {
} PriceLookupType;
struct _GNCPriceLookup {
struct gnc_price_lookup_s
{
PriceLookupType type;
GNCPriceDB *prdb;
gnc_commodity *commodity;

@ -49,19 +49,25 @@ static gboolean remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup);
/* allocation */
GNCPrice *
gnc_price_create(void)
gnc_price_create (GNCSession *session)
{
GNCPrice *p = g_new0(GNCPrice, 1);
ENTER(" ");
GNCPrice *p;
g_return_val_if_fail (session, NULL);
p = g_new0(GNCPrice, 1);
p->refcount = 1;
p->editlevel = 0;
p->not_saved = FALSE;
p->do_free = FALSE;
p->version = 0;
p->version_check = 0;
xaccGUIDNew (&p->guid);
xaccStoreEntity(p, &p->guid, GNC_ID_PRICE);
gnc_engine_generate_event (&p->guid, GNC_EVENT_CREATE);
return p;
}
@ -109,14 +115,18 @@ gnc_price_unref(GNCPrice *p)
/* ==================================================================== */
GNCPrice *
gnc_price_clone(GNCPrice* p)
gnc_price_clone (GNCPrice* p, GNCSession *session)
{
/* the clone doesn't belong to a PriceDB */
GNCPrice *new_p;
ENTER ("pr=%p", p);
g_return_val_if_fail (session, NULL);
if(!p) return NULL;
new_p = gnc_price_create();
new_p = gnc_price_create(session);
if(!new_p) return NULL;
new_p->version = p->version;

@ -25,8 +25,9 @@
#define GNC_PRICEDB_H
#include "date.h"
#include "gnc-numeric.h"
#include "gnc-commodity.h"
#include "gnc-numeric.h"
#include "gnc-engine.h"
#include "guid.h"
#include <stdio.h>
@ -107,20 +108,20 @@
*/
typedef struct _GNCPrice GNCPrice;
typedef struct _GNCPriceLookup GNCPriceLookup;
typedef struct gnc_price_s GNCPrice;
typedef struct gnc_price_lookup_s GNCPriceLookup;
/****************/
/* constructors */
/* gnc_price_create - returns a newly allocated and initialized price
with a reference count of 1. */
GNCPrice *gnc_price_create(void);
GNCPrice *gnc_price_create(GNCSession *session);
/* 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);
GNCPrice *gnc_price_clone(GNCPrice* p, GNCSession *session);
/*********************/
/* memory management */
@ -213,7 +214,7 @@ gboolean gnc_price_list_equal(GList *prices1, GList *prices2);
*/
typedef struct _GNCPriceDB GNCPriceDB;
typedef struct gnc_price_db_s GNCPriceDB;
/* gnc_pricedb_create - create a new pricedb. Normally you won't need

@ -1313,9 +1313,9 @@ when no longer needed.")
'gnc:price-create
'<gnc:Price*>
"gnc_price_create"
'()
'((<gnc:Session*> session))
"Create and return a new price.")
(gw:wrap-function
mod
'gnc:price-unref

@ -131,7 +131,7 @@ get_random_price(GNCSession *session)
char *string;
gnc_commodity *c;
p = gnc_price_create ();
p = gnc_price_create (session);
c = get_random_commodity (session);
gnc_price_set_commodity (p, c);

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

@ -829,7 +829,7 @@ new_button_clicked( GtkButton *b, gpointer d )
{
SchedXactionDialog *sxd;
SchedXaction *tmpSX =
xaccSchedXactionMalloc( gnc_get_current_book ());
xaccSchedXactionMalloc( gnc_get_current_session ());
SchedXactionEditorDialog *sxed;
sxd = (SchedXactionDialog*)d;

@ -409,7 +409,7 @@ stock_split_finish (GnomeDruidPage *druidpage,
ts.tv_sec = date;
ts.tv_nsec = 0;
price = gnc_price_create ();
price = gnc_price_create (gnc_get_current_session ());
gnc_price_begin_edit (price);
gnc_price_set_commodity (price, xaccAccountGetCommodity (account));

@ -292,7 +292,7 @@
get-quotes
kill-quoter)))
(define (gnc:book-add-quotes book)
(define (gnc:session-add-quotes session)
(define (find-quotables group)
;; Return a list of accounts for whose commodities we should get
@ -551,7 +551,7 @@
(if (not (and commodity currency gnc-time price price-type))
(string-append
currency-str ":" (gnc:commodity-get-mnemonic commodity))
(let ((gnc-price (gnc:price-create)))
(let ((gnc-price (gnc:price-create session)))
(if (not gnc-price)
(string-append
currency-str ":" (gnc:commodity-get-mnemonic commodity))
@ -575,7 +575,8 @@
;; FIXME: uses of gnc:warn in here need to be cleaned up. Right
;; now, they'll result in funny formatting.
(let* ((group (gnc:book-get-group book))
(let* ((book (gnc:session-get-book session))
(group (gnc:book-get-group book))
(quotables (and group (find-quotables group)))
(fq-call-data (and quotables (accounts->fq-call-data quotables)))
(fq-calls (and fq-call-data
@ -693,8 +694,7 @@ Run 'update-finance-quote' as root to install them.") "\n")))
(define (gnc:add-quotes-to-book-at-url url)
(let* ((session (gnc:url->loaded-session url #f #f))
(book (gnc:session-get-book session))
(quote-ok? (and book (gnc:book-add-quotes book))))
(quote-ok? (and session (gnc:session-add-quotes session))))
(if (not quote-ok?) (gnc:msg "book-add-quotes failed"))
(and session (gnc:session-save session))
@ -703,7 +703,7 @@ Run 'update-finance-quote' as root to install them.") "\n")))
(gnc:session-get-error session) #f)))
(set! quote-ok? #f))
(if (not quote-ok?)
(gnc:msg "book-save failed " (gnc:session-get-error session)))
(gnc:msg "session-save failed " (gnc:session-get-error session)))
(and session (gnc:session-destroy session))
quote-ok?))

Loading…
Cancel
Save