r15578 - gnucash/branches/gobject-engine-dev - Begin Work on GncAccount object. Modifications (for now) to: QofInstance, QofBook, QofBackend
Daniel Espinosa
esodan at cvs.gnucash.org
Tue Feb 13 20:24:26 EST 2007
Author: esodan
Date: 2007-02-13 20:24:23 -0500 (Tue, 13 Feb 2007)
New Revision: 15578
Trac: http://svn.gnucash.org/trac/changeset/15578
Modified:
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject-p.h
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c
gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h
gnucash/branches/gobject-engine-dev/src/backend/file/gnc-backend-file.c
gnucash/branches/gobject-engine-dev/src/backend/postgres/PostgresBackend.c
gnucash/branches/gobject-engine-dev/src/engine/Account.c
gnucash/branches/gobject-engine-dev/src/engine/Account.h
gnucash/branches/gobject-engine-dev/src/engine/AccountP.h
gnucash/branches/gobject-engine-dev/src/engine/Split.c
gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c
Log:
Begin Work on GncAccount object. Modifications (for now) to: QofInstance, QofBook, QofBackend
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -295,9 +295,9 @@
void (*load) (QofBackend *, QofBook *);
- void (*begin) (QofBackend *, QofInstance *);
- void (*commit) (QofBackend *, QofInstance *);
- void (*rollback) (QofBackend *, QofInstance *);
+ void (*begin) (QofBackend *, QofInstance *, GError**);
+ void (*commit) (QofBackend *, QofInstance *, GError**);
+ void (*rollback) (QofBackend *, QofInstance *, GError**);
gpointer (*compile_query) (QofBackend *, QofQuery *);
void (*free_query) (QofBackend *, gpointer);
@@ -329,9 +329,6 @@
*/
gboolean (*save_may_clobber_data) (QofBackend *);
- QofBackendError last_err;
- char * error_msg;
-
KvpFrame* backend_configuration;
gint config_count;
/** Each backend resolves a fully-qualified file path.
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -33,6 +33,14 @@
#include "qof.h"
#include "qofbackend-p.h"
+GQuark qof_backend_error_quark (void)
+{
+ static GQuark quark;
+ if (!quark)
+ quark = g_quark_from_static_string ("qof_backend_error");
+ return quark;
+}
+
static QofLogModule log_module = QOF_MOD_BACKEND;
#define QOF_CONFIG_DESC "desc"
@@ -72,6 +80,11 @@
* error handling *
\********************************************************************/
+
+/*
+ THE ERROR HANDLING WILL BE USING GERROR, THIS FUNCTIONS ARE DEPRECATED
+*/
+
void
qof_backend_set_error (QofBackend *be, QofBackendError err)
{
@@ -175,11 +188,11 @@
}
void
-qof_backend_run_begin(QofBackend *be, QofInstance *inst)
+qof_backend_run_begin(QofBackend *be, QofInstance *inst, GError *error)
{
if(!be || !inst) { return; }
if(!be->begin) { return; }
- (be->begin) (be, inst);
+ (be->begin) (be, inst, error);
}
gboolean
@@ -190,11 +203,11 @@
}
void
-qof_backend_run_commit(QofBackend *be, QofInstance *inst)
+qof_backend_run_commit(QofBackend *be, QofInstance *inst, GError *error)
{
if(!be || !inst) { return; }
if(!be->commit) { return; }
- (be->commit) (be, inst);
+ (be->commit) (be, inst, error);
}
/* =========== Backend Configuration ================ */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -48,10 +48,14 @@
#define QOF_MOD_BACKEND "qof-backend"
+extern GQuark qof_backend_error_quark (void);
+#define QOF_BACKEND_ERROR qof_backend_error_quark ()
+
/** \brief The errors that can be reported to the GUI & other front-end users
* \warning (GnuCash) If you modify QofBackendError, please update
* src/engine/gw-engine-spec.scm
*/
+
typedef enum {
ERR_BACKEND_NO_ERR = 0,
ERR_BACKEND_NO_HANDLER, /**< no backend handler found for this access method (ENOSYS) */
@@ -137,6 +141,7 @@
ERR_RPC_BAD_VERSION, /**< RPC Version Mismatch */
ERR_RPC_FAILED, /**< Operation failed */
ERR_RPC_NOT_ADDED, /**< object not added */
+ QOF_BACKEND_UNBALANCED_CALL_ERROR
} QofBackendError;
/**
@@ -169,11 +174,11 @@
used when QOF is built as a library. */
//@{
-void qof_backend_run_begin(QofBackend *be, QofInstance *inst);
+void qof_backend_run_begin(QofBackend *be, QofInstance *inst, GError **error);
gboolean qof_backend_begin_exists(QofBackend *be);
-void qof_backend_run_commit(QofBackend *be, QofInstance *inst);
+void qof_backend_run_commit(QofBackend *be, QofInstance *inst, GError **error);
gboolean qof_backend_commit_exists(QofBackend *be);
//@}
@@ -181,11 +186,12 @@
/** The qof_backend_set_error() routine pushes an error code onto the error
* stack. (FIXME: the stack is 1 deep in current implementation).
*/
-void qof_backend_set_error (QofBackend *be, QofBackendError err);
+//void qof_backend_set_error (QofBackend *be, QofBackendError err);
/** The qof_backend_get_error() routine pops an error code off the error stack.
+ YOU NEED TO PASS A GError* pointer to get the errors in each call
*/
-QofBackendError qof_backend_get_error (QofBackend *be);
+//QofBackendError qof_backend_get_error (QofBackend *be);
/** @name Backend Configuration using KVP
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -56,11 +56,6 @@
/* Register books with the engine */
gboolean qof_book_register (void);
-/** @deprecated use qof_entity_set_guid instead but only in
-backends (when reading the GUID from the data source). */
-#define qof_book_set_guid(book,guid) \
- qof_entity_set_guid(QOF_ENTITY(book), guid)
-
/* @} */
/* @} */
/* @} */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -341,7 +341,7 @@
{
gboolean was_dirty;
- if (!book) return;
+ g_return_if_fail (QOF_IS_BOOK(book));
was_dirty = book->inst.dirty;
book->inst.dirty = TRUE;
@@ -502,6 +502,10 @@
iter->fn (col, iter->data);
}
+/** Invoke the indicated callback on each collection in the book. */
+typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
+void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
+
void
qof_book_foreach_collection (const QofBook *book,
QofCollectionForeachCB cb, gpointer user_data)
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -35,6 +35,7 @@
*
* @author Copyright (c) 1998, 1999, 2001, 2003 Linas Vepstas <linas at linas.org>
* @author Copyright (c) 2000 Dave Peticolas
+ * @author Copyright (c) 2007 Daniel Espinosa Ortiz <esodan at gmail.com>
*/
#ifndef QOF_BOOK_H
@@ -85,7 +86,7 @@
/** Register the book object with the QOF object system. */
-gboolean qof_book_register (void);
+//gboolean qof_book_register (void);
/** Allocate, initialise and return a new QofBook. Books contain references
* to all of the top-level object containers. */
@@ -93,7 +94,8 @@
/** End any editing sessions associated with book, and free all memory
associated with it. */
-void qof_book_destroy (QofBook *book);
+//void qof_book_destroy (QofBook *book);
+#define qof_book_destroy (b) g_object_unref (b)
/** Close a book to editing.
@@ -121,8 +123,14 @@
typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
+/** Callback type for qof_instance_foreach */
+typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
+
void qof_book_foreach (const QofBook *book, GType type, QofInstanceForeachCB func, gpointer data);
+/* Deprecated */
+#define qof_object_foreach(type, book, cb, data) qof_book_foreach (book, type, cb, data)
+
/** Return The kvp data for the book.
* Note that the book KVP data is persistent, and is stored/retrieved
* from the file/database. Thus, the book KVP is the correct place to
@@ -177,7 +185,8 @@
* modified. It can be used by frontend when the used has made a
* change at the book level.
*/
-void qof_book_mark_dirty(QofBook *book);
+//void qof_book_mark_dirty(QofBook *book);
+#define qof_book_mark_dirty(b) qof_instance_set_dirty (QOF_INSTANCE (b), TRUE)
/** This debugging function can be used to traverse the book structure
* and all subsidiary structures, printing out which structures
@@ -190,8 +199,10 @@
/** Set the function to call when a book transitions from clean to
* dirty, or vice versa.
+
+ * TODO: TOBE IMPLEMENTED AS A SIGNAL, AND ATTACHED THE CB TO THIS EVENT
*/
-void qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data);
+void qof_book_set_dirty_cb (QofBook *book, QofBookDirtyCB cb, gpointer user_data);
/** Call this function when you change the book kvp, to make sure the book
* is marked 'dirty'. */
@@ -214,9 +225,8 @@
QofInstance qof_book_get_object (QofBook *book, GType type, GUID *guid);
-/** deprecated */
-#define qof_book_get_guid(X) qof_instance_get_guid (QOF_INSTANCE(X))
+
#endif /* QOF_BOOK_H */
/** @} */
/** @} */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -86,6 +86,7 @@
enum _QofInstanceSignalType {
/* Signals */
+ COMMITED,
LAST_SIGNAL
};
@@ -146,6 +147,14 @@
G_PARAM_CONSTRUCT_ONLY)));
/* Create signals here:*/
+
+ qof_instance_signals[COMMITED] =
+ g_signal_new ("commited",
+ GNC_TYPE_INSTANCE,
+ G_SIGNAL_RUN_LAST,
+ NULL, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0, NULL);
}
@@ -214,6 +223,9 @@
obj = QOF_INSTANCE(object);
switch (property_id) {
+ case PROP_BOOK:
+ g_value_set_object (value, obj->priv->book);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARNinst->priv = g_new0 (QofInstancePrivate, 1);
@@ -290,33 +302,29 @@
QofInstance*
-qof_instance_create (QofIdType type, QofBook *book)
+qof_instance_create (GType type, QofBook *book)
{
QofInstance *inst;
- inst = QOF_INSTANCE (g_object_new (QOF_TYPE_INSTANCE, "book", book, NULL));
+ inst = QOF_INSTANCE (g_object_new (type, "book", book, NULL));
return inst;
}
void
-qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
+qof_instance_destroy (QofInstance *inst)
{
-
+ qof_instance_begin_edit (inst);
+ qof_instance_commit_edit (inst);
+ g_object_unref (G_OBJECT (inst));
}
-void
-qof_instance_release (QofInstance *inst)
-{
-
-}
-
const GUID *
qof_instance_get_guid (const QofInstance *inst)
{
g_return_value_if_fail (QOF_IS_INSTANCE(inst), NULL);
-
+
return inst->priv->guid;
}
@@ -519,4 +527,104 @@
{
instance->editlevel = editlevel;
}
+
+const char* qof_instance_printable (QofInstance *inst)
+{
+ g_return_if_fail (QOF_IS_INSTANCE (inst));
+
+ if (QOF_INSTANCE_GET_CLASS (inst)->printable)
+ (QOF_INSTANCE_GET_CLASS (inst)->printable) (inst);
+ else
+ g_warning ("%s() method not supported\n", __FUNCTION__);
+}
+
+gboolean
+qof_instance_begin_edit (QofInstance *inst, GError **error)
+{
+ QofBackend * be;
+
+ g_return_val_if_fail (QOF_IS_INSTANCE (inst),FALSE);
+
+ inst->priv->editlevel++;
+
+ g_return_val_if_fail (1 < inst->priv->editlevel), FALSE);
+
+ if (0 >= inst->editlevel)
+ inst->editlevel = 1;
+
+ be = qof_book_get_backend (inst->priv->book);
+
+ if (QOF_IS_BACKEND (be) && qof_backend_begin_exists(be))
+ qof_backend_run_begin (be, inst, error);
+ else
+ inst->priv->dirty = TRUE;
+
+ return TRUE;
+}
+
+gboolean
+qof_instance_commit_edit (QofInstance *inst, GError **error)
+{
+ QofBackend * be;
+ gboolean dirty;
+
+ g_return_val_if_fail(QOF_IS_INSTANCE(inst), FALSE);
+
+ inst->priv->editlevel--;
+
+ dirty = inst->dirty;
+
+ if (0 < inst->priv->editlevel) return FALSE;
+
+ if ((0 == inst->priv->editlevel) && inst->priv->dirty)
+ {
+ be = qof_book_get_backend (inst->priv->book);
+
+ if (be && qof_backend_commit_exists(be)) {
+
+ qof_backend_run_commit(be, inst, &error);
+
+ if (error) {
+ /* XXX Should perform a rollback here */
+ inst->do_free = FALSE;
+
+ return FALSE;
+ }
+ /* XXX the backend commit code should clear dirty!! */
+ inst->dirty = FALSE;
+
+ }
+ }
+
+ if (dirty && qof_get_alt_dirty_mode() &&
+ !(inst->priv->infant && inst->priv->do_free)) {
+ /* TODO: mark the book dirty using the QofBook API instead the Collection API
+ may be qof_book_mark_dirty (QofBook, GType) the you will mark the book and the
+ collection with that GType
+ */
+ qof_collection_mark_dirty(qof_book_get_collection(inst->priv->book, G_TYPE_OBJECT(inst)));
+ qof_book_mark_dirty(inst->priv->book);
+ }
+
+ inst->infant = FALSE;
+
+ if (0 > inst->priv->editlevel) {
+
+ PERR ("unbalanced call - resetting (was %d)", inst->priv->editlevel);
+
+ inst->priv->editlevel = 0;
+ if (error)
+ {
+ g_set_error (error, QOF_BACKEND_ERROR, QOF_BACKEND_UNBALANCED_CALL_ERROR,
+ "unbalanced call - EditLevel set to 0 (last value %d)", inst->priv->editlevel);
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+
/* ========================== END OF FILE ======================= */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -65,7 +65,9 @@
GObjectClass parent_class;
/* virtual table */
void (*foreach) (const QofCollection *, QofEntityForeachCB, gpointer);
- const char * (*printable) (gpointer instance);
+ const char * (*to_string) (gpointer instance);
+ void (*commit) (QofInstance* instance);
+ void
/* Add Signal Functions Here */
};
@@ -87,6 +89,7 @@
/** Return the pointer to the kvp_data */
KvpFrame* qof_instance_get_slots (const QofInstance *);
+
/** Return the last time this instance was modified. If QofInstances
* are used with the QofObject storage backends, then the instance
* update times are reserved for use by the backend, for managing
@@ -120,8 +123,12 @@
void qof_instance_mark_free(QofInstance *inst);
-QofInstance* qof_instance_create (QofIdType type, QofBook *book);
+QofInstance* qof_instance_create (GType type, QofBook *book);
+void qof_instance_destroy (QofInstance *inst);
+
+#define qof_instance_release(instance) qof_instance_destroy(instance)
+
/** Pair things up. This routine inserts a kvp value into each instance
* containing the guid of the other. In this way, if one has one of the
* pair, one can always find the other by looking up it's guid. Typically,
@@ -157,15 +164,15 @@
#define qof_object_new_instance (type, book) g_object_new (type, "book", book, NULL)
-/** Callback type for qof_instance_foreach */
-typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
+const char * qof_instance_to_string (QofInstance *instance);
-#define qof_object_foreach (type, book, cb, data) qof_book_foreach_collection (book, type, cb, data)
+#define qof_object_printable (type, instance) qof_instance_to_string (instance)
+gboolean qof_instance_begin_edit (QofInstance *inst, GError *error);
-const char * (*printable) (gpointer instance);
-int (*version_cmp) (gpointer instance_left, gpointer instance_right);
+gboolean qof_instance_commit_edit(QofInstance *inst, GError *error);
+gboolean qof_instance_destroy (QofInstance *inst);
/* @} */
/* @} */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject-p.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject-p.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -34,7 +34,6 @@
#define QOF_OBJECT_P_H_
#include "qofbook.h"
-#include "qofobject.h"
/** To be called from within the book */
void qof_object_book_begin (QofBook *book);
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -227,101 +227,7 @@
/* Entity edit and commit utilities */
/* =================================================================== */
-gboolean
-qof_begin_edit(QofInstance *inst)
-{
- QofBackend * be;
- if (!inst) return FALSE;
- inst->editlevel++;
- if (1 < inst->editlevel) return FALSE;
- if (0 >= inst->editlevel)
- inst->editlevel = 1;
-
- be = qof_book_get_backend (inst->book);
- if (be && qof_backend_begin_exists(be))
- qof_backend_run_begin(be, inst);
- else
- inst->dirty = TRUE;
-
- return TRUE;
-}
-
-gboolean qof_commit_edit(QofInstance *inst)
-{
- QofBackend * be;
-
- if (!inst) return FALSE;
- inst->editlevel--;
- if (0 < inst->editlevel) return FALSE;
-
- if ((0 == inst->editlevel) && inst->dirty)
- {
- be = qof_book_get_backend (inst->book);
- if (be && qof_backend_commit_exists(be)) {
- qof_backend_run_commit(be, inst);
- }
- }
- if (0 > inst->editlevel) {
- PERR ("unbalanced call - resetting (was %d)", inst->editlevel);
- inst->editlevel = 0;
- }
- return TRUE;
-}
-
-
-gboolean
-qof_commit_edit_part2(QofInstance *inst,
- void (*on_error)(QofInstance *, QofBackendError),
- void (*on_done)(QofInstance *),
- void (*on_free)(QofInstance *))
-{
- QofBackend * be;
- gboolean dirty = inst->dirty;
-
- /* See if there's a backend. If there is, invoke it. */
- be = qof_book_get_backend(inst->book);
- if (be && qof_backend_commit_exists(be)) {
- QofBackendError errcode;
-
- /* clear errors */
- do {
- errcode = qof_backend_get_error(be);
- } while (ERR_BACKEND_NO_ERR != errcode);
-
- qof_backend_run_commit(be, inst);
- errcode = qof_backend_get_error(be);
- if (ERR_BACKEND_NO_ERR != errcode) {
- /* XXX Should perform a rollback here */
- inst->do_free = FALSE;
-
- /* Push error back onto the stack */
- qof_backend_set_error (be, errcode);
- if (on_error)
- on_error(inst, errcode);
- return FALSE;
- }
- /* XXX the backend commit code should clear dirty!! */
- inst->dirty = FALSE;
- }
- if (dirty && qof_get_alt_dirty_mode() &&
- !(inst->infant && inst->do_free)) {
- qof_collection_mark_dirty(inst->entity.collection);
- qof_book_mark_dirty(inst->book);
- }
- inst->infant = FALSE;
-
- if (inst->do_free) {
- if (on_free)
- on_free(inst);
- return TRUE;
- }
-
- if (on_done)
- on_done(inst);
- return TRUE;
-}
-
/* =================================================================== */
/* The QOF string cache */
/* =================================================================== */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -297,98 +297,11 @@
#define QOF_CACHE_NEW(void) qof_util_string_cache_insert("")
-/** begin_edit helper
- *
- * @param inst: an instance of QofInstance
- *
- * The caller should use this macro first and then perform any other operations.
-
- Uses newly created functions to allow the macro to be used
- when QOF is linked as a library. qofbackend-p.h is a private header.
- */
+#define qof_begin_edit(inst) qof_instance_begin_edit (QOF_INSTANCE(inst), NULL)
-#define QOF_BEGIN_EDIT(inst) \
- if (!(inst)) return; \
- \
- (inst)->editlevel++; \
- if (1 < (inst)->editlevel) return; \
- \
- if (0 >= (inst)->editlevel) \
- { \
- PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
- (inst)->editlevel = 1; \
- } \
- ENTER ("(inst=%p)", (inst)); \
- \
- /* See if there's a backend. If there is, invoke it. */ \
- { \
- QofBackend * be; \
- be = qof_book_get_backend ((inst)->book); \
- if (be && qof_backend_begin_exists(be)) { \
- qof_backend_run_begin(be, (inst)); \
- } else { \
- /* We tried and failed to start transaction! */ \
- (inst)->dirty = TRUE; \
- } \
- } \
- LEAVE (" ");
+#define qof_commit_edit(inst) qof_instance_commit_edit (QOF_INSTANCE(inst), NULL)
-/** \brief function version of QOF_BEGIN_EDIT
-
-The macro cannot be used in a function that returns a value,
-this function can be used instead.
-*/
-gboolean qof_begin_edit(QofInstance *inst);
-
/**
- * commit_edit helpers
- *
- * The caller should call PART1 as the first thing, then
- * perform any local operations prior to calling the backend.
- * Then call PART2.
- */
-
-/**
- * part1 -- deal with the editlevel
- *
- * @param inst: an instance of QofInstance
- */
-
-#define QOF_COMMIT_EDIT_PART1(inst) { \
- if (!(inst)) return; \
- \
- (inst)->editlevel--; \
- if (0 < (inst)->editlevel) return; \
- \
- /* The pricedb suffers from delayed update... */ \
- /* This may be setting a bad precedent for other types, I fear. */ \
- /* Other types probably really should handle begin like this. */ \
- if ((0 == (inst)->editlevel) && (inst)->dirty) \
- { \
- QofBackend * be; \
- be = qof_book_get_backend ((inst)->book); \
- if (be && qof_backend_commit_exists(be)) { \
- qof_backend_run_commit(be, (inst)); \
- } \
- (inst)->editlevel = 0; \
- } \
- if (0 > (inst)->editlevel) \
- { \
- PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
- (inst)->editlevel = 0; \
- } \
- ENTER ("(inst=%p) dirty=%d do-free=%d", \
- (inst), (inst)->dirty, (inst)->do_free); \
-}
-
-/** \brief function version of QOF_COMMIT_EDIT_PART1
-
-The macro cannot be used in a function that returns a value,
-this function can be used instead. Only Part1 is implemented.
-*/
-gboolean qof_commit_edit(QofInstance *inst);
-
-/**
* part2 -- deal with the backend
*
* @param inst: an instance of QofInstance
Modified: gnucash/branches/gobject-engine-dev/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/backend/file/gnc-backend-file.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/backend/file/gnc-backend-file.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -796,7 +796,7 @@
}
static void
-file_begin_edit (QofBackend *be, QofInstance *inst)
+file_begin_edit (QofBackend *be, QofInstance *inst, GError **error)
{
if (0) build_period_filepath(0, 0);
#if BORKEN_FOR_NOW
@@ -824,7 +824,7 @@
}
static void
-file_rollback_edit (QofBackend *be, QofInstance *inst)
+file_rollback_edit (QofBackend *be, QofInstance *inst, GError **error)
{
#if BORKEN_FOR_NOW
QofBook *book = gp;
@@ -835,7 +835,7 @@
}
static void
-file_commit_edit (QofBackend *be, QofInstance *inst)
+file_commit_edit (QofBackend *be, QofInstance *inst, GError **error)
{
#if BORKEN_FOR_NOW
FileBackend *fbe = (FileBackend *) be;
Modified: gnucash/branches/gobject-engine-dev/src/backend/postgres/PostgresBackend.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/backend/postgres/PostgresBackend.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/backend/postgres/PostgresBackend.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -1630,7 +1630,7 @@
}
static void
-pgend_do_begin (QofBackend *bend, QofInstance *inst)
+pgend_do_begin (QofBackend *bend, QofInstance *inst, GError **error)
{
PGBackend *be = (PGBackend*)bend;
QofIdTypeConst type = inst->entity.e_type;
@@ -1656,7 +1656,7 @@
}
static void
-pgend_do_commit (QofBackend *bend, QofInstance *inst)
+pgend_do_commit (QofBackend *bend, QofInstance *inst, GError **error)
{
PGBackend *be = (PGBackend*)bend;
QofIdTypeConst type = inst->entity.e_type;
@@ -1692,7 +1692,7 @@
}
static void
-pgend_do_rollback (QofBackend *bend, QofInstance *inst)
+pgend_do_rollback (QofBackend *bend, QofInstance *inst, GError **error)
{
PGBackend *be = (PGBackend*)bend;
QofIdTypeConst type = inst->entity.e_type;
Modified: gnucash/branches/gobject-engine-dev/src/engine/Account.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Account.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/engine/Account.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -42,20 +42,99 @@
static QofLogModule log_module = GNC_MOD_ACCOUNT;
+static gulong commit_event_handler = 0;
+
+static void gnc_account_bring_uptodate (GncAccount *acc);
/* GObject declarations */
-static void gnc_account_class_init(AccountClass *klass);
-static void gnc_account_init(Account *sp);
+static void gnc_account_class_init(GncAccountClass *klass);
+static void gnc_account_init(GncAccount *sp);
static void gnc_account_finalize(GObject *object);
-struct _AccountPrivate {
- /* Private Members */
+/** \struct Account */
+struct _GncAccountPrivate
+{
+
+ /* The accountName is an arbitrary string assigned by the user.
+ * It is intended to a short, 5 to 30 character long string that
+ * is displayed by the GUI as the account mnemonic.
+ */
+ char *accountName;
+
+ /* The accountCode is an arbitrary string assigned by the user.
+ * It is intended to be reporting code that is a synonym for the
+ * accountName. Typically, it will be a numeric value that follows
+ * the numbering assignments commonly used by accountants, such
+ * as 100, 200 or 600 for top-level accounts, and 101, 102.. etc.
+ * for detail accounts.
+ */
+ char *accountCode;
+
+ /* The description is an arbitrary string assigned by the user.
+ * It is intended to be a longer, 1-5 sentence description of what
+ * this account is all about.
+ */
+ char *description;
+
+ /* The type field is the account type, picked from the enumerated
+ * list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
+ * ACCT_TYPE_CREDIT, ACCT_TYPE_INCOME, etc. Its intended use is to
+ * be a hint to the GUI as to how to display and format the
+ * transaction data.
+ */
+ GNCAccountType type;
+
+ /*
+ * The commodity field denotes the kind of 'stuff' stored
+ * in this account. The 'amount' field of a split indicates
+ * how much of the 'stuff' there is.
+ */
+ gnc_commodity * commodity;
+ int commodity_scu;
+ gboolean non_standard_scu;
+
+ /* The parent and children pointers are used to implement an account
+ * hierarchy, of accounts that have sub-accounts ("detail accounts").
+ */
+ AccountGroup *parent; /* back-pointer to parent */
+ AccountGroup *children; /* pointer to sub-accounts */
+
+ /* protected data, cached parameters */
+ gnc_numeric starting_balance;
+ gnc_numeric starting_cleared_balance;
+ gnc_numeric starting_reconciled_balance;
+
+ gnc_numeric balance;
+ gnc_numeric cleared_balance;
+ gnc_numeric reconciled_balance;
+
+ /* version number, used for tracking multiuser updates */
+ gint32 version;
+ guint32 version_check; /* data aging timestamp */
+
+ SplitList *splits; /* list of split pointers */
+ LotList *lots; /* list of lot pointers */
+
+ /* Cached pointer to policy method */
+ GNCPolicy *policy;
+
+ gboolean balance_dirty; /* balances in splits incorrect */
+ gboolean sort_dirty; /* sort order of splits is bad */
+
+ /* The "mark" flag can be used by the user to mark this account
+ * in any way desired. Handy for specialty traversals of the
+ * account tree. */
+ short mark;
+
+ /* -------------------------------------------------------------- */
+ /* Backend private expansion data */
+ guint32 idata; /* used by the sql backend for kvp management */
};
-typedef struct _AccountSignal AccountSignal;
-typedef enum _AccountSignalType AccountSignalType;
+typedef struct _GncAccountSignal GncAccountSignal;
+typedef enum _GncAccountSignalType GncAccountSignalType;
-enum _AccountSignalType {
+enum _GncAccountSignalType {
/* Signals */
LAST_SIGNAL
};
@@ -66,8 +145,8 @@
PROP_0
};
-struct _AccountSignal {
- Account *object;
+struct _GncAccountSignal {
+ GncAccount *object;
};
static guint gnc_account_signals[LAST_SIGNAL] = { 0 };
@@ -80,13 +159,13 @@
if(type == 0) {
static const GTypeInfo our_info = {
- sizeof (AccountClass),
+ sizeof (GncAccountClass),
NULL,
NULL,
(GClassInitFunc)gnc_account_class_init,
NULL,
NULL,
- sizeof (Account),
+ sizeof (GncAccount),
0,
(GInstanceInitFunc)gnc_account_init,
};
@@ -99,7 +178,7 @@
}
static void
-gnc_account_class_init(AccountClass *klass)
+gnc_account_class_init(GncAccountClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -111,21 +190,113 @@
/* Install properties */
/* Create signals here:*/
+
+
}
static void
-gnc_account_init(Account *obj)
+gnc_account_init(GncAccount *obj)
{
/* Initialize private members, etc. */
+ acc->priv = g_new0 (GncAccountPrivate, 1);
+
+ acc->priv->parent = NULL;
+ acc->priv->children = NULL;
+
+ acc->priv->balance = gnc_numeric_zero();
+ acc->priv->cleared_balance = gnc_numeric_zero();
+ acc->priv->reconciled_balance = gnc_numeric_zero();
+
+ acc->priv->starting_balance = gnc_numeric_zero();
+ acc->priv->starting_cleared_balance = gnc_numeric_zero();
+ acc->priv->starting_reconciled_balance = gnc_numeric_zero();
+
+ acc->priv->type = ACCT_TYPE_NONE;
+
+ acc->priv->accountName = NULL;
+ acc->priv->accountCode = NULL;
+ acc->priv->description = NULL;
+
+ acc->priv->idata = 0;
+
+ acc->priv->commodity = NULL;
+ acc->priv->commodity_scu = 0;
+ acc->priv->non_standard_scu = FALSE;
+
+ acc->priv->splits = NULL;
+ acc->priv->lots = NULL;
+ acc->priv->policy = xaccGetFIFOPolicy();
+
+ acc->priv->version = 0;
+ acc->priv->version_check = 0;
+ acc->priv->balance_dirty = FALSE;
+ acc->priv->sort_dirty = FALSE;
+
+ commit_event_handler = g_signal_connect (obj, "commit", G_CALLBACK (gnc_account_bring_uptodate), obj, NULL);
}
static void
gnc_account_finalize(GObject *object)
{
+
+ GList *lp, *slist;
+ QofCollection *col;
+
+ /* First, recursively free children */
+ xaccFreeAccountGroup (acc);
+ acc->priv->children = NULL;
+
+ PINFO ("freeing splits for account %p (%s)",
+ acc, acc->priv->accountName ? acc->priv->accountName : "(null)");
+
+ slist = g_list_copy (acc->priv->splits);
+
+ for (lp = slist; lp; lp = lp->next)
+ {
+ Split *s;
+ s = lp->data;
+ gnc_split_destroy ((GncSplit*) s);
+ }
+
+ g_list_free(slist);
+
+ if (!qof_book_shutting_down(qof_instance_get_book (QOF_INSTANCE (acc)))) {
+ col = qof_instance_get_collection (QOF_INSTANCE(acc));
+ qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
+ }
+
+ for (lp = acc->priv->lots; lp; lp = lp->next)
+ {
+ GNCLot *lot = lp->data;
+ gnc_lot_destroy (lot);
+ }
+ g_list_free (acc->priv->lots);
+ acc->priv->lots = NULL;
+
+ xaccGroupRemoveAccount(acc->priv->parent, acc);
+
+ if (acc->priv->accountName) g_free (acc->priv->accountName);
+ if (acc->priv->accountCode) g_free (acc->priv->accountCode);
+ if (acc->priv->description) g_free (acc->priv->description);
+
+ acc->priv->commodity = NULL;
+ acc->priv->parent = NULL;
+ acc->priv->children = NULL;
+
+ acc->priv->balance = gnc_numeric_zero();
+ acc->priv->cleared_balance = gnc_numeric_zero();
+ acc->priv->reconciled_balance = gnc_numeric_zero();
+
+ acc->priv->type = ACCT_TYPE_NONE;
+ acc->priv->commodity = NULL;
+
+ acc->priv->version = 0;
+ acc->priv->balance_dirty = FALSE;
+ acc->priv->sort_dirty = FALSE;
+
+ g_signal_handler_disconnect (object, commit_event_handler);
- /* Free private members, etc. */
-
G_OBJECT_CLASS(parent_class)->finalize(object);
}
@@ -135,7 +306,7 @@
const GValue *value,
GParamSpec *pspec)
{
- Account *obj;
+ GncAccount *obj;
obj = GNC_ACCOUNT (object);
switch (param_id) {
@@ -152,7 +323,7 @@
GValue *value,
GParamSpec *pspec)
{
- Account *obj;
+ GncAccount *obj;
obj = GNC_ACCOUNT(object);
@@ -171,16 +342,6 @@
gunichar account_uc_separator = ':';
/********************************************************************\
- * Because I can't use C++ for this project, doesn't mean that I *
- * can't pretend to! These functions perform actions on the *
- * account data structure, in order to encapsulate the knowledge *
- * of the internals of the Account in one file. *
-\********************************************************************/
-
-static void xaccAccountBringUpToDate (Account *acc);
-
-
-/********************************************************************\
* gnc_get_account_separator *
* returns the current account separator character *
* *
@@ -220,84 +381,44 @@
/********************************************************************\
\********************************************************************/
-G_INLINE_FUNC void mark_account (Account *acc);
+G_INLINE_FUNC void mark_account (GncAccount *acc);
void
-mark_account (Account *acc)
+mark_account (GncAccount *acc)
{
- if (acc->parent) acc->parent->saved = FALSE;
- qof_instance_set_dirty(&acc->inst);
+ if (acc->priv->parent) acc->priv->parent->saved = FALSE;
+ qof_instance_set_dirty(QOF_INSTANCE (acc));
}
/********************************************************************\
\********************************************************************/
-static void
-xaccInitAccount (Account * acc, QofBook *book)
-{
- ENTER ("book=%p\n", book);
- qof_instance_init (&acc->inst, GNC_ID_ACCOUNT, book);
- acc->parent = NULL;
- acc->children = NULL;
-
- acc->balance = gnc_numeric_zero();
- acc->cleared_balance = gnc_numeric_zero();
- acc->reconciled_balance = gnc_numeric_zero();
-
- acc->starting_balance = gnc_numeric_zero();
- acc->starting_cleared_balance = gnc_numeric_zero();
- acc->starting_reconciled_balance = gnc_numeric_zero();
-
- acc->type = ACCT_TYPE_NONE;
-
- acc->accountName = CACHE_INSERT("");
- acc->accountCode = CACHE_INSERT("");
- acc->description = CACHE_INSERT("");
-
- acc->idata = 0;
-
- acc->commodity = NULL;
- acc->commodity_scu = 0;
- acc->non_standard_scu = FALSE;
-
- acc->splits = NULL;
- acc->lots = NULL;
- acc->policy = xaccGetFIFOPolicy();
-
- acc->version = 0;
- acc->version_check = 0;
- acc->balance_dirty = FALSE;
- acc->sort_dirty = FALSE;
-
- LEAVE ("account=%p\n", acc);
-}
-
/********************************************************************\
\********************************************************************/
-Account *
-xaccMallocAccount (QofBook *book)
+GncAccount *
+gnc_account_new (QofBook *book)
{
- Account *acc;
+ GncAccount *acc;
g_return_val_if_fail (book, NULL);
- acc = g_new (Account, 1);
- xaccInitAccount (acc, book);
+ acc = GNC_ACCOUNT (g_object_new (GNC_TYPE_ACCOUNT, "book", book, NULL));
+
qof_event_gen (&acc->inst.entity, QOF_EVENT_CREATE, NULL);
return acc;
}
-static Account *
-xaccCloneAccountCommon(const Account *from, QofBook *book)
+static GncAccount *
+xaccCloneAccountCommon(const GncAccount *from, QofBook *book)
{
- Account *ret;
+ GncAccount *ret;
if (!from || !book) return NULL;
ENTER (" ");
- ret = g_new (Account, 1);
+ ret = GNC_ACCOUNT (g_object_new (GNC_TYPE_ACCOUNT, "book", book, NULL));
g_return_val_if_fail (ret, NULL);
xaccInitAccount (ret, book);
@@ -325,138 +446,28 @@
return ret;
}
-Account *
-xaccCloneAccount (const Account *from, QofBook *book)
+GncAccount *
+xaccCloneAccount (const GncAccount *from, QofBook *book)
{
- Account *ret = xaccCloneAccountCommon(from, book);
+ GncAccount *ret = xaccCloneAccountCommon(from, book);
qof_instance_gemini (&ret->inst, (QofInstance *) &from->inst);
g_assert (ret ==
- (Account*) qof_instance_lookup_twin (QOF_INSTANCE(from), book));
+ (GncAccount*) qof_instance_lookup_twin (QOF_INSTANCE(from), book));
return ret;
}
-Account *
-xaccCloneAccountSimple (const Account *from, QofBook *book)
+GncAccount *
+xaccCloneAccountSimple (const GncAccount *from, QofBook *book)
{
- Account *ret = xaccCloneAccountCommon(from, book);
+ GncAccount *ret = xaccCloneAccountCommon(from, book);
qof_instance_set_dirty(&ret->inst);
return ret;
}
/********************************************************************\
-\********************************************************************/
-
-void
-xaccFreeAccount (Account *acc)
-{
- GList *lp;
-
- if (!acc) return;
-
- qof_event_gen (&acc->inst.entity, QOF_EVENT_DESTROY, NULL);
-
- if (acc->children)
- {
- PERR (" instead of calling xaccFreeAccount(), please call \n"
- " xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
-
- /* First, recursively free children */
- xaccFreeAccountGroup (acc->children);
- acc->children = NULL;
- }
-
- /* remove lots -- although these should be gone by now. */
- if (acc->lots)
- {
- PERR (" instead of calling xaccFreeAccount(), please call \n"
- " xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
-
- for (lp=acc->lots; lp; lp=lp->next)
- {
- GNCLot *lot = lp->data;
- gnc_lot_destroy (lot);
- }
- g_list_free (acc->lots);
- acc->lots = NULL;
- }
-
- /* Next, clean up the splits */
- /* NB there shouldn't be any splits by now ... they should
- * have been all been freed by CommitEdit(). We can remove this
- * check once we know the warning isn't occurring any more. */
- if (acc->splits)
- {
- GList *slist;
- PERR (" instead of calling xaccFreeAccount(), please call \n"
- " xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
-
- acc->inst.editlevel = 0;
-
- slist = g_list_copy(acc->splits);
- for (lp = slist; lp; lp = lp->next) {
- Split *s = (Split *) lp->data;
- g_assert(xaccSplitGetAccount(s) == acc);
- xaccSplitDestroy (s);
- }
- g_list_free(slist);
- g_assert(acc->splits == NULL);
- }
-
- CACHE_REPLACE(acc->accountName, NULL);
- CACHE_REPLACE(acc->accountCode, NULL);
- CACHE_REPLACE(acc->description, NULL);
-
- /* zero out values, just in case stray
- * pointers are pointing here. */
-
- acc->commodity = NULL;
- acc->parent = NULL;
- acc->children = NULL;
-
- acc->balance = gnc_numeric_zero();
- acc->cleared_balance = gnc_numeric_zero();
- acc->reconciled_balance = gnc_numeric_zero();
-
- acc->type = ACCT_TYPE_NONE;
- acc->commodity = NULL;
-
- acc->version = 0;
- acc->balance_dirty = FALSE;
- acc->sort_dirty = FALSE;
-
- qof_instance_release (&acc->inst);
- //g_free(acc);
-}
-
-/********************************************************************\
* transactional routines
\********************************************************************/
-
-void
-xaccAccountBeginEdit (Account *acc)
-{
- g_return_if_fail(acc);
- qof_begin_edit(&acc->inst);
-}
-
-static void on_done(QofInstance *inst)
-{
- /* old event style */
- qof_event_gen (&inst->entity, QOF_EVENT_MODIFY, NULL);
-}
-
-static void on_err (QofInstance *inst, QofBackendError errcode)
-{
- PERR("commit error: %d", errcode);
-}
-
-static void acc_free (QofInstance *inst)
-{
- Account *acc = (Account *) inst;
- xaccGroupRemoveAccount(acc->parent, acc);
- xaccFreeAccount(acc);
-}
-
+/*TODO: Move this code */
static void
destroy_pending_splits_for_account(QofEntity *ent, gpointer acc)
{
@@ -468,96 +479,34 @@
xaccSplitDestroy(split);
}
-void
-xaccAccountCommitEdit (Account *acc)
-{
- g_return_if_fail(acc);
- if (!qof_commit_edit(&acc->inst)) return;
- /* If marked for deletion, get rid of subaccounts first,
- * and then the splits ... */
- if (acc->inst.do_free)
- {
- GList *lp, *slist;
- QofCollection *col;
-
- acc->inst.editlevel++;
-
- /* First, recursively free children */
- xaccFreeAccountGroup (acc->children);
- acc->children = NULL;
-
- PINFO ("freeing splits for account %p (%s)",
- acc, acc->accountName ? acc->accountName : "(null)");
-
- slist = g_list_copy(acc->splits);
- for (lp = slist; lp; lp = lp->next)
- {
- Split *s = lp->data;
- xaccSplitDestroy (s);
- }
- g_list_free(slist);
- /* It turns out there's a case where this assertion does not hold:
- When the user tries to delete an Imbalance account, while also
- deleting all the splits in it. The splits will just get
- recreated and put right back into the same account!
-
- g_assert(acc->splits == NULL || qof_book_shutting_down(acc->inst.book));
- */
-
- if (!qof_book_shutting_down(acc->inst.book)) {
- col = qof_book_get_collection(acc->inst.book, GNC_ID_TRANS);
- qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
- }
-
- /* the lots should be empty by now */
- for (lp = acc->lots; lp; lp = lp->next)
- {
- GNCLot *lot = lp->data;
- gnc_lot_destroy (lot);
- }
- g_list_free (acc->lots);
- acc->lots = NULL;
-
- qof_instance_set_dirty(&acc->inst);
- acc->inst.editlevel--;
- }
- else
- {
- xaccAccountBringUpToDate(acc);
- }
-
- qof_commit_edit_part2(&acc->inst, on_err, on_done, acc_free);
-}
-
void
-xaccAccountDestroy (Account *acc)
+gnc_account_destroy (GncAccount *acc)
{
- if (!acc) return;
- acc->inst.do_free = TRUE;
-
- xaccAccountCommitEdit (acc);
+ qof_instance_mark_free (QOF_INSTANCE (acc));
+ qof_instance_destroy (QOF_INSTANCE (acc));
+ qof_event_gen (&acc->inst.entity, QOF_EVENT_DESTROY, NULL);
}
void
-xaccAccountSetVersion (Account *acc, gint32 vers)
+xaccAccountSetVersion (GncAccount *acc, gint32 vers)
{
if (!acc) return;
- acc->version = vers;
+ acc->priv->version = vers;
}
gint32
-xaccAccountGetVersion (const Account *acc)
+xaccAccountGetVersion (const GncAccount *acc)
{
if (!acc) return 0;
- return (acc->version);
+ return (acc->priv->version);
}
/********************************************************************\
\********************************************************************/
gboolean
-xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids)
+xaccAccountEqual(const GncAccount *aa, const GncAccount *ab, gboolean check_guids)
{
if(!aa && !ab) return TRUE;
@@ -769,19 +718,20 @@
/********************************************************************\
\********************************************************************/
void
-xaccAccountSortSplits (Account *acc, gboolean force)
+xaccAccountSortSplits (GncAccount *acc, gboolean force)
{
- if (!acc || !acc->sort_dirty || (!force && acc->inst.editlevel > 0)) return;
+ if (!acc || !acc->priv->sort_dirty || (!force && qof_instance_get_edit_level (QOF_INSTANCE (acc) > 0)) return;
- acc->splits = g_list_sort(acc->splits, (GCompareFunc)xaccSplitDateOrder);
- acc->sort_dirty = FALSE;
- acc->balance_dirty = TRUE;
+ acc->priv->splits = g_list_sort(acc->priv->splits, (GCompareFunc)xaccSplitDateOrder);
+ acc->priv->sort_dirty = FALSE;
+ acc->priv->balance_dirty = TRUE;
}
+/* TODO: Call this function as callback when an event commit is emitted */
static void
-xaccAccountBringUpToDate(Account *acc)
+gnc_account_bring_uptodate (GncAccount *acc)
{
- if (!acc) return;
+ g_return_if_fail (GNC_IS_ACCOUNT (acc));
/* if a re-sort happens here, then everything will update, so the
cost basis and balance calls are no-ops */
@@ -792,49 +742,21 @@
/********************************************************************\
\********************************************************************/
-void
-xaccAccountSetGUID (Account *acc, const GUID *guid)
-{
- if (!acc || !guid) return;
-
- /* XXX this looks fishy and weird to me ... */
- PINFO("acct=%p", acc);
- xaccAccountBeginEdit (acc);
- qof_entity_set_guid (&acc->inst.entity, guid);
- qof_instance_set_dirty(&acc->inst);
- xaccAccountCommitEdit (acc);
-}
-
-/********************************************************************\
-\********************************************************************/
-
-Account *
-xaccAccountLookup (const GUID *guid, QofBook *book)
-{
- QofCollection *col;
- if (!guid || !book) return NULL;
- col = qof_book_get_collection (book, GNC_ID_ACCOUNT);
- return (Account *) qof_collection_lookup_entity (col, guid);
-}
-
-/********************************************************************\
-\********************************************************************/
-
short
-xaccAccountGetMark (const Account *acc)
+xaccAccountGetMark (const GncAccount *acc)
{
- return acc ? acc->mark : 0;
+ return acc ? acc->priv->mark : 0;
}
void
-xaccAccountSetMark (Account *acc, short m)
+xaccAccountSetMark (GncAccount *acc, short m)
{
if (acc)
- acc->mark = m;
+ acc->priv->mark = m;
}
void
-xaccClearMark (Account *acc, short val)
+xaccClearMark (GncAccount *acc, short val)
{
AccountGroup *topgrp;
@@ -850,7 +772,7 @@
for (node = list; node; node = node->next)
{
- Account *account = node->data;
+ GncAccount *account = node->data;
xaccClearMarkDown (account, val);
}
@@ -860,14 +782,14 @@
}
void
-xaccClearMarkDown (Account *acc, short val)
+xaccClearMarkDown (GncAccount *acc, short val)
{
AccountGroup *children;
if (!acc) return;
- acc->mark = val;
+ acc->priv->mark = val;
- children = acc->children;
+ children = acc->priv->children;
if (children)
{
GList *list;
@@ -877,7 +799,7 @@
for (node = list; node; node = node->next)
{
- Account *account = node->data;
+ GncAccount *account = node->data;
xaccClearMarkDown (account, val);
}
@@ -896,7 +818,7 @@
for (node = list; node; node = node->next)
{
- Account *account = node->data;
+ GncAccount *account = node->data;
xaccClearMarkDown (account, val);
}
@@ -906,19 +828,19 @@
\********************************************************************/
void
-xaccAccountRemoveLot (Account *acc, GNCLot *lot)
+xaccAccountRemoveLot (GncAccount *acc, GNCLot *lot)
{
- if (!acc || !lot || !acc->lots) return;
+ if (!acc || !lot || !acc->priv->lots) return;
ENTER ("(acc=%p, lot=%p)", acc, lot);
- acc->lots = g_list_remove (acc->lots, lot);
+ acc->priv->lots = g_list_remove (acc->priv->lots, lot);
LEAVE ("(acc=%p, lot=%p)", acc, lot);
}
void
-xaccAccountInsertLot (Account *acc, GNCLot *lot)
+xaccAccountInsertLot (GncAccount *acc, GNCLot *lot)
{
- Account * old_acc = NULL;
+ GncAccount * old_acc = NULL;
if (!acc || !lot || lot->account == acc) return;
ENTER ("(acc=%p, lot=%p)", acc, lot);
@@ -927,10 +849,10 @@
/* pull it out of the old account */
if (lot->account) {
old_acc = lot->account;
- old_acc->lots = g_list_remove (old_acc->lots, lot);
+ old_acc->priv->lots = g_list_remove (old_acc->priv->lots, lot);
}
- acc->lots = g_list_prepend (acc->lots, lot);
+ acc->priv->lots = g_list_prepend (acc->priv->lots, lot);
lot->account = acc;
/* Don't move the splits to the new account. The caller will do this
@@ -950,7 +872,7 @@
}
static void
-xaccPostSplitMove (Split *split, Account *accto)
+xaccPostSplitMove (Split *split, GncAccount *accto)
{
Transaction *trans;
@@ -961,7 +883,7 @@
}
void
-xaccAccountMoveAllSplits (Account *accfrom, Account *accto)
+xaccAccountMoveAllSplits (GncAccount *accfrom, GncAccount *accto)
{
/* Handle special cases. */
if (!accfrom || !accto || !accfrom->splits || accfrom == accto) return;
@@ -1031,7 +953,7 @@
\********************************************************************/
void
-xaccAccountRecomputeBalance (Account * acc)
+xaccAccountRecomputeBalance (GncAccount * acc)
{
gnc_numeric balance;
gnc_numeric cleared_balance;
@@ -1040,18 +962,18 @@
GList *lp;
if (NULL == acc) return;
- if (acc->inst.editlevel > 0) return;
- if (!acc->balance_dirty) return;
- if (acc->inst.do_free) return;
- if (qof_book_shutting_down(acc->inst.book)) return;
+ if (qof_instance_get_edit_level (QOF_INSTANCE (acc)) > 0) return;
+ if (!acc->priv->balance_dirty) return;
+ if (qof_instance_do_free(QOF_INSTANCE (acc))) return;
+ if (qof_book_shutting_down(qof_instance_get_book(QOF_INSTANCE (acc)))) return;
- balance = acc->starting_balance;
- cleared_balance = acc->starting_cleared_balance;
- reconciled_balance = acc->starting_reconciled_balance;
+ balance = acc->priv->starting_balance;
+ cleared_balance = acc->priv->starting_cleared_balance;
+ reconciled_balance = acc->priv->starting_reconciled_balance;
PINFO ("acct=%s starting baln=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT,
- acc->accountName, balance.num, balance.denom);
- for(lp = acc->splits; lp; lp = lp->next)
+ acc->priv->accountName, balance.num, balance.denom);
+ for(lp = acc->priv->splits; lp; lp = lp->next)
{
Split *split = (Split *) lp->data;
gnc_numeric amt = xaccSplitGetAmount (split);
@@ -1077,11 +999,11 @@
last_split = split;
}
- acc->balance = balance;
- acc->cleared_balance = cleared_balance;
- acc->reconciled_balance = reconciled_balance;
+ acc->priv->balance = balance;
+ acc->priv->cleared_balance = cleared_balance;
+ acc->priv->reconciled_balance = reconciled_balance;
- acc->balance_dirty = FALSE;
+ acc->priv->balance_dirty = FALSE;
}
@@ -1089,18 +1011,18 @@
\********************************************************************/
void
-xaccAccountSetStartingBalance(Account *acc,
+xaccAccountSetStartingBalance(GncAccount *acc,
const gnc_numeric start_baln,
const gnc_numeric start_cleared_baln,
const gnc_numeric start_reconciled_baln)
{
if (!acc) return;
- acc->starting_balance = start_baln;
- acc->starting_cleared_balance = start_cleared_baln;
- acc->starting_reconciled_balance = start_reconciled_baln;
+ acc->priv->starting_balance = start_baln;
+ acc->priv->starting_cleared_balance = start_cleared_baln;
+ acc->priv->starting_reconciled_balance = start_reconciled_baln;
- acc->balance_dirty = TRUE;
+ acc->priv->balance_dirty = TRUE;
}
/********************************************************************\
@@ -1120,7 +1042,7 @@
int
-xaccAccountOrder (const Account **aa, const Account **ab)
+xaccAccountOrder (const GncAccount **aa, const GncAccount **ab)
{
char *da, *db;
char *endptr = NULL;
@@ -1182,113 +1104,125 @@
\********************************************************************/
void
-xaccAccountSetType (Account *acc, GNCAccountType tip)
+xaccAccountSetType (GncAccount *acc, GNCAccountType tip)
{
/* refuse invalid account types, and don't bother if not new type. */
- if (!acc || NUM_ACCOUNT_TYPES <= tip || acc->type == tip) return;
+ if (!acc || NUM_ACCOUNT_TYPES <= tip || acc->priv->type == tip) return;
xaccAccountBeginEdit(acc);
- acc->type = tip;
- acc->balance_dirty = TRUE; /* new type may affect balance computation */
+ acc->priv->type = tip;
+ acc->priv->balance_dirty = TRUE; /* new type may affect balance computation */
mark_account(acc);
xaccAccountCommitEdit(acc);
}
void
-xaccAccountSetName (Account *acc, const char *str)
+xaccAccountSetName (GncAccount *acc, const char *str)
{
- if (!acc || !str || str == acc->accountName) return;
+ if (!acc || !str || str == acc->priv->accountName) return;
- xaccAccountBeginEdit(acc);
- CACHE_REPLACE(acc->accountName, str);
+ qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
+
+ if(acc->priv->accountName) g_free(acc->priv->accountName);
+
+ acc->priv->accountName = g_strdup (str);
+
mark_account (acc);
- xaccAccountCommitEdit(acc);
+ qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
}
void
-xaccAccountSetCode (Account *acc, const char *str)
+xaccAccountSetCode (GncAccount *acc, const char *str)
{
if (!acc || !str || str == acc->accountCode) return;
- xaccAccountBeginEdit(acc);
- CACHE_REPLACE(acc->accountCode, str);
+ qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
+
+ if(acc->priv->accountCode) g_free(acc->priv->accountCode);
+
+ acc->priv->accountCode = g_strdup (str);
+
mark_account (acc);
- xaccAccountCommitEdit(acc);
+ qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
}
void
-xaccAccountSetDescription (Account *acc, const char *str)
+xaccAccountSetDescription (GncAccount *acc, const char *str)
{
if (!acc || !str || str == acc->description) return;
- xaccAccountBeginEdit(acc);
- CACHE_REPLACE(acc->description, str);
+ qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
+
+ if(acc->priv->description) g_free(acc->priv->description);
+
+ acc->priv->description = g_strdup (str);
+
mark_account (acc);
- xaccAccountCommitEdit(acc);
+ qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
}
static void
-qofAccountSetParent (Account *acc, QofEntity *parent)
+qofAccountSetParent (GncAccount *acc, QofEntity *parent)
{
- Account *parent_acc;
+ GncAccount *parent_acc;
if (!acc || !parent) return;
- parent_acc = (Account*)parent;
- xaccAccountBeginEdit(acc);
- xaccAccountBeginEdit(parent_acc);
+ parent_acc = (GncAccount*)parent;
+ qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
+ qof_instance_begin_edit (QOF_INSTANCE (parent_acc), NULL);
xaccAccountInsertSubAccount(parent_acc, acc);
mark_account (parent_acc);
mark_account (acc);
- xaccAccountCommitEdit(acc);
- xaccAccountCommitEdit(parent_acc);
+ qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
+ qof_instance_commit_edit (QOF_INSTANCE (parent_acc), NULL);
}
void
-xaccAccountSetNotes (Account *acc, const char *str)
+xaccAccountSetNotes (GncAccount *acc, const char *str)
{
if (!acc) return;
- xaccAccountBeginEdit(acc);
+ qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
if (str) {
gchar *tmp = g_strstrip(g_strdup(str));
- kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes",
+ kvp_frame_set_slot_nc(qof_instance_get_slots (QOF_INSTANCE (acc)), "notes",
strlen(tmp) ? kvp_value_new_string(tmp) : NULL);
g_free(tmp);
} else {
- kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes", NULL);
+ kvp_frame_set_slot_nc(qof_instance_get_slots (QOF_INSTANCE (acc)), "notes", NULL);
}
mark_account(acc);
- xaccAccountCommitEdit(acc);
+ qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
}
void
-xaccAccountSetCommodity (Account * acc, gnc_commodity * com)
+xaccAccountSetCommodity (GncAccount * acc, gnc_commodity * com)
{
GList *lp;
if (!acc || !com || com == acc->commodity) return;
- xaccAccountBeginEdit(acc);
+ qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
- acc->commodity = com;
- acc->commodity_scu = gnc_commodity_get_fraction(com);
- acc->non_standard_scu = FALSE;
+ acc->priv->commodity = com;
+ acc->priv->commodity_scu = gnc_commodity_get_fraction(com);
+ acc->priv->non_standard_scu = FALSE;
/* iterate over splits */
- for (lp = acc->splits; lp; lp = lp->next)
+ for (lp = acc->priv->splits; lp; lp = lp->next)
{
Split *s = (Split *) lp->data;
Transaction *trans = xaccSplitGetParent (s);
- xaccTransBeginEdit (trans);
+ qof_instance_begin_edit (QOF_INSTANCE (trans), NULL);xaccTransBeginEdit (trans);
xaccSplitSetAmount (s, xaccSplitGetAmount(s));
xaccTransCommitEdit (trans);
}
- acc->sort_dirty = TRUE; /* Not needed. */
- acc->balance_dirty = TRUE;
+ acc->priv->sort_dirty = TRUE; /* Not needed. */
+ acc->priv->balance_dirty = TRUE;
mark_account (acc);
if (gnc_commodity_is_iso(com)) {
@@ -1298,7 +1232,7 @@
gnc_commodity_set_quote_source(com,
gnc_commodity_get_default_quote_source(com));
}
- xaccAccountCommitEdit(acc);
+ qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
}
/*
@@ -1308,12 +1242,12 @@
* to mismatched values in the past.
*/
void
-xaccAccountSetCommoditySCU (Account *acc, int scu)
+xaccAccountSetCommoditySCU (GncAccount *acc, int scu)
{
if (!acc) return;
xaccAccountBeginEdit(acc);
- acc->commodity_scu = scu;
+ acc->priv->commodity_scu = scu;
if (scu != gnc_commodity_get_fraction(acc->commodity))
acc->non_standard_scu = TRUE;
mark_account(acc);
@@ -1321,13 +1255,13 @@
}
int
-xaccAccountGetCommoditySCUi (const Account * acc)
+xaccAccountGetCommoditySCUi (const GncAccount * acc)
{
return acc ? acc->commodity_scu : 0;
}
int
-xaccAccountGetCommoditySCU (const Account * acc)
+xaccAccountGetCommoditySCU (const GncAccount * acc)
{
if (!acc) return 0;
@@ -1337,7 +1271,7 @@
}
void
-xaccAccountSetNonStdSCU (Account *acc, gboolean flag)
+xaccAccountSetNonStdSCU (GncAccount *acc, gboolean flag)
{
if (!acc || acc->non_standard_scu == flag) return;
@@ -1348,7 +1282,7 @@
}
gboolean
-xaccAccountGetNonStdSCU (const Account * acc)
+xaccAccountGetNonStdSCU (const GncAccount * acc)
{
return acc ? acc->non_standard_scu : 0;
}
@@ -1358,7 +1292,7 @@
/* below follow the old, deprecated currency/security routines. */
void
-DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency)
+DxaccAccountSetCurrency (GncAccount * acc, gnc_commodity * currency)
{
const char *string;
gnc_commodity *commodity;
@@ -1383,57 +1317,57 @@
\********************************************************************/
AccountGroup *
-xaccAccountGetChildren (const Account *acc)
+xaccAccountGetChildren (const GncAccount *acc)
{
return acc ? acc->children : NULL;
}
AccountGroup *
-xaccAccountGetParent (const Account *acc)
+xaccAccountGetParent (const GncAccount *acc)
{
return acc ? acc->parent : NULL;
}
-Account *
-xaccAccountGetParentAccount (const Account * acc)
+GncAccount *
+xaccAccountGetParentAccount (const GncAccount * acc)
{
return acc ? xaccGroupGetParentAccount(acc->parent) : NULL;
}
GList *
-xaccAccountGetDescendants (const Account *acc)
+xaccAccountGetDescendants (const GncAccount *acc)
{
return acc ? xaccGroupGetSubAccounts(acc->children) : NULL;
}
GNCAccountType
-xaccAccountGetType (const Account *acc)
+xaccAccountGetType (const GncAccount *acc)
{
return acc ? acc->type : ACCT_TYPE_NONE;
}
static const char*
-qofAccountGetTypeString (const Account *acc)
+qofAccountGetTypeString (const GncAccount *acc)
{
return acc ? xaccAccountTypeEnumAsString(acc->type) : NULL;
}
static void
-qofAccountSetType (Account *acc, const char *type_string)
+qofAccountSetType (GncAccount *acc, const char *type_string)
{
xaccAccountSetType(acc, xaccAccountStringToEnum(type_string));
}
const char *
-xaccAccountGetName (const Account *acc)
+xaccAccountGetName (const GncAccount *acc)
{
return acc ? acc->accountName : NULL;
}
char *
-xaccAccountGetFullName(const Account *account)
+xaccAccountGetFullName(const GncAccount *account)
{
- const Account *a;
+ const GncAccount *a;
char *fullname;
gchar **names;
int level;
@@ -1462,25 +1396,25 @@
}
const char *
-xaccAccountGetCode (const Account *acc)
+xaccAccountGetCode (const GncAccount *acc)
{
return acc ? acc->accountCode : NULL;
}
const char *
-xaccAccountGetDescription (const Account *acc)
+xaccAccountGetDescription (const GncAccount *acc)
{
return acc ? acc->description : NULL;
}
const char *
-xaccAccountGetNotes (const Account *acc)
+xaccAccountGetNotes (const GncAccount *acc)
{
return acc ? kvp_frame_get_string(acc->inst.kvp_data, "notes") : NULL;
}
gnc_commodity *
-DxaccAccountGetCurrency (const Account *acc)
+DxaccAccountGetCurrency (const GncAccount *acc)
{
KvpValue *v;
const char *s;
@@ -1500,31 +1434,31 @@
}
gnc_commodity *
-xaccAccountGetCommodity (const Account *acc)
+xaccAccountGetCommodity (const GncAccount *acc)
{
return acc ? acc->commodity : NULL;
}
gnc_numeric
-xaccAccountGetBalance (const Account *acc)
+xaccAccountGetBalance (const GncAccount *acc)
{
return acc ? acc->balance : gnc_numeric_zero();
}
gnc_numeric
-xaccAccountGetClearedBalance (const Account *acc)
+xaccAccountGetClearedBalance (const GncAccount *acc)
{
return acc ? acc->cleared_balance : gnc_numeric_zero();
}
gnc_numeric
-xaccAccountGetReconciledBalance (const Account *acc)
+xaccAccountGetReconciledBalance (const GncAccount *acc)
{
return acc ? acc->reconciled_balance : gnc_numeric_zero();
}
gnc_numeric
-xaccAccountGetProjectedMinimumBalance (const Account *acc)
+xaccAccountGetProjectedMinimumBalance (const GncAccount *acc)
{
GList *node;
time_t today;
@@ -1558,7 +1492,7 @@
\********************************************************************/
gnc_numeric
-xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)
+xaccAccountGetBalanceAsOfDate (GncAccount *acc, time_t date)
{
/* Ideally this could use xaccAccountForEachSplit, but
* it doesn't exist yet and I'm uncertain of exactly how
@@ -1633,7 +1567,7 @@
* one that walks from the tail of the split list.
*/
gnc_numeric
-xaccAccountGetPresentBalance (const Account *acc)
+xaccAccountGetPresentBalance (const GncAccount *acc)
{
GList *node;
time_t today;
@@ -1663,7 +1597,7 @@
* Convert a balance from one currency to another.
*/
gnc_numeric
-xaccAccountConvertBalanceToCurrency(const Account *acc, /* for book */
+xaccAccountConvertBalanceToCurrency(const GncAccount *acc, /* for book */
gnc_numeric balance,
const gnc_commodity *balance_currency,
const gnc_commodity *new_currency)
@@ -1689,7 +1623,7 @@
* a given date.
*/
gnc_numeric
-xaccAccountConvertBalanceToCurrencyAsOfDate(const Account *acc, /* for book */
+xaccAccountConvertBalanceToCurrencyAsOfDate(const GncAccount *acc, /* for book */
gnc_numeric balance,
gnc_commodity *balance_currency,
gnc_commodity *new_currency,
@@ -1721,7 +1655,7 @@
* currency.
*/
static gnc_numeric
-xaccAccountGetXxxBalanceInCurrency (const Account *acc,
+xaccAccountGetXxxBalanceInCurrency (const GncAccount *acc,
xaccGetBalanceFn fn,
const gnc_commodity *report_currency)
{
@@ -1736,7 +1670,7 @@
}
static gnc_numeric
-xaccAccountGetXxxBalanceAsOfDateInCurrency(Account *acc, time_t date,
+xaccAccountGetXxxBalanceAsOfDateInCurrency(GncAccount *acc, time_t date,
xaccGetBalanceAsOfDateFn fn,
const gnc_commodity *report_commodity)
{
@@ -1764,7 +1698,7 @@
* values of all these accounts.
*/
static gpointer
-xaccAccountBalanceHelper (Account *acc, gpointer data)
+xaccAccountBalanceHelper (GncAccount *acc, gpointer data)
{
CurrencyBalance *cb = data;
gnc_numeric balance;
@@ -1778,7 +1712,7 @@
return NULL;
}
static gpointer
-xaccAccountBalanceAsOfDateHelper (Account *acc, gpointer data)
+xaccAccountBalanceAsOfDateHelper (GncAccount *acc, gpointer data)
{
CurrencyBalance *cb = data;
gnc_numeric balance;
@@ -1806,7 +1740,7 @@
* If 'include_children' is FALSE, this function doesn't recurse at all.
*/
static gnc_numeric
-xaccAccountGetXxxBalanceInCurrencyRecursive (const Account *acc,
+xaccAccountGetXxxBalanceInCurrencyRecursive (const GncAccount *acc,
xaccGetBalanceFn fn,
const gnc_commodity *report_commodity,
gboolean include_children)
@@ -1834,7 +1768,7 @@
static gnc_numeric
xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive (
- Account *acc, time_t date, xaccGetBalanceAsOfDateFn fn,
+ GncAccount *acc, time_t date, xaccGetBalanceAsOfDateFn fn,
gnc_commodity *report_commodity, gboolean include_children)
{
gnc_numeric balance;
@@ -1860,7 +1794,7 @@
}
gnc_numeric
-xaccAccountGetBalanceInCurrency (const Account *acc,
+xaccAccountGetBalanceInCurrency (const GncAccount *acc,
const gnc_commodity *report_commodity,
gboolean include_children)
{
@@ -1873,7 +1807,7 @@
gnc_numeric
-xaccAccountGetClearedBalanceInCurrency (const Account *acc,
+xaccAccountGetClearedBalanceInCurrency (const GncAccount *acc,
const gnc_commodity *report_commodity,
gboolean include_children)
{
@@ -1884,7 +1818,7 @@
gnc_numeric
-xaccAccountGetReconciledBalanceInCurrency (const Account *acc,
+xaccAccountGetReconciledBalanceInCurrency (const GncAccount *acc,
const gnc_commodity *report_commodity,
gboolean include_children)
{
@@ -1894,7 +1828,7 @@
}
gnc_numeric
-xaccAccountGetPresentBalanceInCurrency (const Account *acc,
+xaccAccountGetPresentBalanceInCurrency (const GncAccount *acc,
const gnc_commodity *report_commodity,
gboolean include_children)
{
@@ -1905,7 +1839,7 @@
gnc_numeric
xaccAccountGetProjectedMinimumBalanceInCurrency (
- const Account *acc,
+ const GncAccount *acc,
const gnc_commodity *report_commodity,
gboolean include_children)
{
@@ -1916,7 +1850,7 @@
gnc_numeric
xaccAccountGetBalanceAsOfDateInCurrency(
- Account *acc, time_t date, gnc_commodity *report_commodity,
+ GncAccount *acc, time_t date, gnc_commodity *report_commodity,
gboolean include_children)
{
return xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive (
@@ -1925,7 +1859,7 @@
}
gnc_numeric
-xaccAccountGetBalanceChangeForPeriod (Account *acc, time_t t1, time_t t2, gboolean recurse)
+xaccAccountGetBalanceChangeForPeriod (GncAccount *acc, time_t t1, time_t t2, gboolean recurse)
{
gnc_numeric b1, b2;
@@ -1939,19 +1873,19 @@
\********************************************************************/
SplitList *
-xaccAccountGetSplitList (const Account *acc)
+xaccAccountGetSplitList (const GncAccount *acc)
{
return acc ? acc->splits : NULL;
}
LotList *
-xaccAccountGetLotList (const Account *acc)
+xaccAccountGetLotList (const GncAccount *acc)
{
return acc ? acc->lots : NULL;
}
LotList *
-xaccAccountFindOpenLots (const Account *acc,
+xaccAccountFindOpenLots (const GncAccount *acc,
gboolean (*match_func)(GNCLot *lot,
gpointer user_data),
gpointer user_data, GCompareFunc sort_func)
@@ -1984,7 +1918,7 @@
}
gpointer
-xaccAccountForEachLot(const Account *acc,
+xaccAccountForEachLot(const GncAccount *acc,
gpointer (*proc)(GNCLot *lot, void *data), void *data)
{
LotList *node;
@@ -2004,13 +1938,13 @@
/* These functions use interchange gint64 and gboolean. Is that right? */
gboolean
-xaccAccountGetTaxRelated (const Account *acc)
+xaccAccountGetTaxRelated (const GncAccount *acc)
{
return acc ? kvp_frame_get_gint64(acc->inst.kvp_data, "tax-related") : FALSE;
}
void
-xaccAccountSetTaxRelated (Account *acc, gboolean tax_related)
+xaccAccountSetTaxRelated (GncAccount *acc, gboolean tax_related)
{
KvpValue *new_value;
@@ -2029,13 +1963,13 @@
}
const char *
-xaccAccountGetTaxUSCode (const Account *acc)
+xaccAccountGetTaxUSCode (const GncAccount *acc)
{
return acc ? kvp_frame_get_string(acc->inst.kvp_data, "tax-US/code") : NULL;
}
void
-xaccAccountSetTaxUSCode (Account *acc, const char *code)
+xaccAccountSetTaxUSCode (GncAccount *acc, const char *code)
{
if (!acc) return;
@@ -2046,14 +1980,14 @@
}
const char *
-xaccAccountGetTaxUSPayerNameSource (const Account *acc)
+xaccAccountGetTaxUSPayerNameSource (const GncAccount *acc)
{
return acc ? kvp_frame_get_string(acc->inst.kvp_data,
"tax-US/payer-name-source") : NULL;
}
void
-xaccAccountSetTaxUSPayerNameSource (Account *acc, const char *source)
+xaccAccountSetTaxUSPayerNameSource (GncAccount *acc, const char *source)
{
if (!acc) return;
@@ -2068,7 +2002,7 @@
\********************************************************************/
gboolean
-xaccAccountGetPlaceholder (const Account *acc)
+xaccAccountGetPlaceholder (const GncAccount *acc)
{
const char *str;
if (!acc) return FALSE;
@@ -2078,7 +2012,7 @@
}
void
-xaccAccountSetPlaceholder (Account *acc, gboolean val)
+xaccAccountSetPlaceholder (GncAccount *acc, gboolean val)
{
if (!acc) return;
@@ -2090,7 +2024,7 @@
}
GNCPlaceholderType
-xaccAccountGetDescendantPlaceholder (const Account *acc)
+xaccAccountGetDescendantPlaceholder (const GncAccount *acc)
{
GList *descendants, *node;
GNCPlaceholderType ret = PLACEHOLDER_NONE;
@@ -2100,7 +2034,7 @@
descendants = xaccGroupGetSubAccounts(acc->children);
for (node = descendants; node; node = node->next)
- if (xaccAccountGetPlaceholder((Account *) node->data)) {
+ if (xaccAccountGetPlaceholder((GncAccount *) node->data)) {
ret = PLACEHOLDER_CHILD;
break;
}
@@ -2113,7 +2047,7 @@
\********************************************************************/
gboolean
-xaccAccountGetHidden (const Account *acc)
+xaccAccountGetHidden (const GncAccount *acc)
{
const char *str;
if (!acc) return FALSE;
@@ -2123,7 +2057,7 @@
}
void
-xaccAccountSetHidden (Account *acc, gboolean val)
+xaccAccountSetHidden (GncAccount *acc, gboolean val)
{
if (!acc) return;
@@ -2135,7 +2069,7 @@
}
gboolean
-xaccAccountIsHidden (const Account *acc)
+xaccAccountIsHidden (const GncAccount *acc)
{
if (!acc)
return FALSE;
@@ -2153,9 +2087,9 @@
\********************************************************************/
gboolean
-xaccAccountHasAncestor (const Account *acc, const Account * ancestor)
+xaccAccountHasAncestor (const GncAccount *acc, const GncAccount * ancestor)
{
- const Account *parent = acc;
+ const GncAccount *parent = acc;
if (!acc || !ancestor) return FALSE;
@@ -2361,7 +2295,7 @@
}
gboolean
-xaccAccountIsPriced(const Account *acc)
+xaccAccountIsPriced(const GncAccount *acc)
{
if (!acc) return FALSE;
@@ -2373,7 +2307,7 @@
\********************************************************************/
gboolean
-xaccAccountGetReconcileLastDate (const Account *acc, time_t *last_date)
+xaccAccountGetReconcileLastDate (const GncAccount *acc, time_t *last_date)
{
KvpValue *v;
@@ -2394,7 +2328,7 @@
\********************************************************************/
void
-xaccAccountSetReconcileLastDate (Account *acc, time_t last_date)
+xaccAccountSetReconcileLastDate (GncAccount *acc, time_t last_date)
{
if (!acc) return;
@@ -2409,7 +2343,7 @@
\********************************************************************/
gboolean
-xaccAccountGetReconcileLastInterval (const Account *acc,
+xaccAccountGetReconcileLastInterval (const GncAccount *acc,
int *months, int *days)
{
KvpValue *v1, *v2;
@@ -2435,7 +2369,7 @@
\********************************************************************/
void
-xaccAccountSetReconcileLastInterval (Account *acc, int months, int days)
+xaccAccountSetReconcileLastInterval (GncAccount *acc, int months, int days)
{
KvpFrame *frame;
if (!acc) return;
@@ -2457,7 +2391,7 @@
\********************************************************************/
gboolean
-xaccAccountGetReconcilePostponeDate (const Account *acc, time_t *postpone_date)
+xaccAccountGetReconcilePostponeDate (const GncAccount *acc, time_t *postpone_date)
{
KvpValue *v;
@@ -2477,7 +2411,7 @@
\********************************************************************/
void
-xaccAccountSetReconcilePostponeDate (Account *acc, time_t postpone_date)
+xaccAccountSetReconcilePostponeDate (GncAccount *acc, time_t postpone_date)
{
if (!acc) return;
@@ -2494,7 +2428,7 @@
\********************************************************************/
gboolean
-xaccAccountGetReconcilePostponeBalance (const Account *acc,
+xaccAccountGetReconcilePostponeBalance (const GncAccount *acc,
gnc_numeric *balance)
{
KvpValue *v;
@@ -2516,7 +2450,7 @@
\********************************************************************/
void
-xaccAccountSetReconcilePostponeBalance (Account *acc, gnc_numeric balance)
+xaccAccountSetReconcilePostponeBalance (GncAccount *acc, gnc_numeric balance)
{
if (!acc) return;
@@ -2532,7 +2466,7 @@
\********************************************************************/
void
-xaccAccountClearReconcilePostpone (Account *acc)
+xaccAccountClearReconcilePostpone (GncAccount *acc)
{
if (!acc) return;
@@ -2550,7 +2484,7 @@
* If it is not defined for the account, return the default value.
*/
gboolean
-xaccAccountGetAutoInterestXfer (const Account *acc, gboolean default_value)
+xaccAccountGetAutoInterestXfer (const GncAccount *acc, gboolean default_value)
{
const char *str = NULL;
if (!acc) return default_value;
@@ -2564,7 +2498,7 @@
\********************************************************************/
void
-xaccAccountSetAutoInterestXfer (Account *acc, gboolean option)
+xaccAccountSetAutoInterestXfer (GncAccount *acc, gboolean option)
{
if (!acc) return;
@@ -2581,7 +2515,7 @@
\********************************************************************/
const char *
-xaccAccountGetLastNum (const Account *acc)
+xaccAccountGetLastNum (const GncAccount *acc)
{
return acc ? kvp_frame_get_string(acc->inst.kvp_data, "last-num") : NULL;
}
@@ -2590,7 +2524,7 @@
\********************************************************************/
void
-xaccAccountSetLastNum (Account *acc, const char *num)
+xaccAccountSetLastNum (GncAccount *acc, const char *num)
{
if (!acc) return;
@@ -2604,7 +2538,7 @@
\********************************************************************/
void
-dxaccAccountSetPriceSrc(Account *acc, const char *src)
+dxaccAccountSetPriceSrc(GncAccount *acc, const char *src)
{
if (!acc) return;
@@ -2624,7 +2558,7 @@
\********************************************************************/
const char*
-dxaccAccountGetPriceSrc(const Account *acc)
+dxaccAccountGetPriceSrc(const GncAccount *acc)
{
if(!acc) return NULL;
@@ -2640,7 +2574,7 @@
\********************************************************************/
void
-dxaccAccountSetQuoteTZ(Account *acc, const char *tz)
+dxaccAccountSetQuoteTZ(GncAccount *acc, const char *tz)
{
if (!acc) return;
@@ -2659,7 +2593,7 @@
\********************************************************************/
const char*
-dxaccAccountGetQuoteTZ(const Account *acc)
+dxaccAccountGetQuoteTZ(const GncAccount *acc)
{
if (!acc) return NULL;
@@ -2674,7 +2608,7 @@
\********************************************************************/
void
-xaccAccountSetReconcileChildrenStatus(Account *acc, gboolean status)
+xaccAccountSetReconcileChildrenStatus(GncAccount *acc, gboolean status)
{
if (!acc) return;
@@ -2691,7 +2625,7 @@
\********************************************************************/
gboolean
-xaccAccountGetReconcileChildrenStatus(const Account *acc)
+xaccAccountGetReconcileChildrenStatus(const GncAccount *acc)
{
/* access the account's kvp-data for status and return that, if no value
* is found then we can assume not to include the children, that being
@@ -2705,7 +2639,7 @@
\********************************************************************/
gint
-xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc,
+xaccAccountForEachTransaction(const GncAccount *acc, TransactionCallback proc,
void *data)
{
if (!acc || !proc) return 0;
@@ -2722,7 +2656,7 @@
* passed.
*/
static void
-finder_help_function(const Account *acc, const char *description,
+finder_help_function(const GncAccount *acc, const char *description,
Split **split, Transaction **trans )
{
GList *slp;
@@ -2751,7 +2685,7 @@
}
Split *
-xaccAccountFindSplitByDesc(const Account *acc, const char *description)
+xaccAccountFindSplitByDesc(const GncAccount *acc, const char *description)
{
Split *split;
@@ -2766,7 +2700,7 @@
* auto-filling in registers with a default leading account. The
* dest_trans is a transaction used for currency checking. */
Transaction *
-xaccAccountFindTransByDesc(const Account *acc, const char *description)
+xaccAccountFindTransByDesc(const GncAccount *acc, const char *description)
{
Transaction *trans;
@@ -2781,7 +2715,7 @@
static QofObject account_object_def = {
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_ACCOUNT,
- type_label: "Account",
+ type_label: "GncAccount",
create: (gpointer)xaccMallocAccount,
book_begin: NULL,
book_end: NULL,
Modified: gnucash/branches/gobject-engine-dev/src/engine/Account.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Account.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/engine/Account.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -58,10 +58,18 @@
#define GNC_ACCOUNT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ACCOUNT, AccountClass))
-typedef struct _AccountClass AccountClass;
-typedef struct _Account Account;
+typedef struct _GncAccountClass GncAccountClass;
+typedef struct _GncAccount GncAccount;
+typedef struct _GncAccountPrivate GncAccountPrivate;
-struct _AccountClass {
+typedef GncAccount GncAccount; // Backward compatibility
+
+struct _GncAccount {
+ QofInstance inst;
+ GncAccountPrivate *priv;
+};
+
+struct _GncAccountClass {
QofInstanceClass parent_class;
/* virtual table */
@@ -75,11 +83,11 @@
typedef gnc_numeric (*xaccGetBalanceFn)( const Account *account );
typedef gnc_numeric (*xaccGetBalanceInCurrencyFn) (
- const Account *account, const gnc_commodity *report_commodity,
+ const GncAccount *account, const gnc_commodity *report_commodity,
gboolean include_children);
typedef gnc_numeric (*xaccGetBalanceAsOfDateFn) (
- Account *account, time_t date);
+ GncAccount *account, time_t date);
/** The account types are used to determine how the transaction data
* in the account is displayed. These values can be safely changed
@@ -162,15 +170,17 @@
@{ */
/** Constructor */
-Account * xaccMallocAccount (QofBook *book);
+GncAccount * gnc_account_new (QofBook *book);
+#define xaccMallocAccount(book) gnc_account_new(book)
+
/** The xaccCloneAccount() does the same as xaccCloneAccountSimple(),
* except that it also also places a pair of GUID-pointers
* of each account to the other, in the other's kvp slot.
* The guid pointers are stored under the under the kvp
* path "gemini".
*/
-Account * xaccCloneAccount (const Account *from, QofBook *book);
+GncAccount * xaccCloneAccount (const GncAccount *from, QofBook *book);
/** The xaccCloneAccountSimple() routine makes a simple copy of the
* indicated account, placing it in the indicated book. It copies
@@ -182,23 +192,24 @@
* Note that this routines does *NOT* use the 'gemini' kvp value
* to indicate where it was copied from.
*/
-Account * xaccCloneAccountSimple (const Account *from, QofBook *book);
+GncAccount * xaccCloneAccountSimple (const GncAccount *from, QofBook *book);
/** The xaccAccountBeginEdit() subroutine is the first phase of
* a two-phase-commit wrapper for account updates. */
-void xaccAccountBeginEdit (Account *account);
+#define xaccAccountBeginEdit(account) qof_instance_begin_edit(QOF_INSTANCE(account))
/** ThexaccAccountCommitEdit() subroutine is the second phase of
* a two-phase-commit wrapper for account updates. */
-void xaccAccountCommitEdit (Account *account);
+#define xaccAccountCommitEdit(account) qof_instance_commit_edit(QOF_INSTANCE(account))
/** The xaccAccountDestroy() routine can be used to get rid of an
* account. The account should have been opened for editing
* (by calling xaccAccountBeginEdit()) before calling this routine.*/
-void xaccAccountDestroy (Account *account);
+void gnc_account_destroy (GncAccount *account);
+#define xaccAccountDestroy(account) gnc_account_destroy(account)
/** Compare two accounts for equality - this is a deep compare. */
-gboolean xaccAccountEqual(const Account *a, const Account* b,
+gboolean xaccAccountEqual(const GncAccount *a, const GncAccount* b,
gboolean check_guids);
/** The xaccAccountOrder() subroutine defines a sorting order
@@ -209,7 +220,7 @@
* the account codes are compared, and if these are equal, then
* account types, and, if these are equal, the account names.
*/
-int xaccAccountOrder (const Account **account_1, const Account **account_2);
+int xaccAccountOrder (const GncAccount **account_1, const GncAccount **account_2);
/** @} */
@@ -234,7 +245,7 @@
/** The xaccAccountLookup() subroutine will return the
* account associated with the given id, or NULL
* if there is no such account. */
-Account * xaccAccountLookup (const GUID *guid, QofBook *book);
+#define xaccAccountLookup (guid, book) qof_book_get_object (book, GNC_TYPE_ACCOUNT, guid)
#define xaccAccountLookupDirect(g,b) xaccAccountLookup(&(g),b)
/** @} */
@@ -245,32 +256,32 @@
@{ */
/** Set the account's type */
-void xaccAccountSetType (Account *account, GNCAccountType);
+void xaccAccountSetType (GncAccount *account, GNCAccountType);
/** Set the account's name */
-void xaccAccountSetName (Account *account, const char *name);
+void xaccAccountSetName (GncAccount *account, const char *name);
/** Set the account's accounting code */
-void xaccAccountSetCode (Account *account, const char *code);
+void xaccAccountSetCode (GncAccount *account, const char *code);
/** Set the account's description */
-void xaccAccountSetDescription (Account *account, const char *desc);
+void xaccAccountSetDescription (GncAccount *account, const char *desc);
/** Set the account's notes */
-void xaccAccountSetNotes (Account *account, const char *notes);
-/** Set the last num field of an Account */
-void xaccAccountSetLastNum (Account *account, const char *num);
+void xaccAccountSetNotes (GncAccount *account, const char *notes);
+/** Set the last num field of an GncAccount */
+void xaccAccountSetLastNum (GncAccount *account, const char *num);
/** Get the account's type */
-GNCAccountType xaccAccountGetType (const Account *account);
+GNCAccountType xaccAccountGetType (const GncAccount *account);
/** Is the account a stock, mutual fund or currency? */
-gboolean xaccAccountIsPriced(const Account *acc);
+gboolean xaccAccountIsPriced(const GncAccount *acc);
/** Get the account's name */
-const char * xaccAccountGetName (const Account *account);
+const char * xaccAccountGetName (const GncAccount *account);
/** Get the account's accounting code */
-const char * xaccAccountGetCode (const Account *account);
+const char * xaccAccountGetCode (const GncAccount *account);
/** Get the account's description */
-const char * xaccAccountGetDescription (const Account *account);
+const char * xaccAccountGetDescription (const GncAccount *account);
/** Get the account's notes */
-const char * xaccAccountGetNotes (const Account *account);
-/** Get the last num field of an Account */
-const char * xaccAccountGetLastNum (const Account *account);
+const char * xaccAccountGetNotes (const GncAccount *account);
+/** Get the last num field of an GncAccount */
+const char * xaccAccountGetLastNum (const GncAccount *account);
/** The xaccAccountGetFullName routine returns the fully qualified name
* of the account using the given separator char. The name must be
@@ -285,7 +296,7 @@
* hack alert -- since it breaks the rule of string allocation, maybe this
* routine should not be in this library, but some utility library?
*/
-char * xaccAccountGetFullName (const Account *account);
+char * xaccAccountGetFullName (const GncAccount *account);
/** Set a string that identifies the Finance::Quote backend that
* should be used to retrieve online prices. See price-quotes.scm
@@ -293,26 +304,26 @@
*
* @deprecated Price quote information is now stored on the
* commodity, not the account. */
-void dxaccAccountSetPriceSrc (Account *account, const char *src);
+void dxaccAccountSetPriceSrc (GncAccount *account, const char *src);
/** Get a string that identifies the Finance::Quote backend that
* should be used to retrieve online prices. See price-quotes.scm
* for more information.
*
* @deprecated Price quote information is now stored on the
* commodity, not the account. */
-const char * dxaccAccountGetPriceSrc (const Account *account);
+const char * dxaccAccountGetPriceSrc (const GncAccount *account);
/** Returns a per-account flag: Prior to reconciling an account which
charges or pays interest, this flag tells whether to prompt the
user to enter a transaction for the interest charge or
payment. This per-account flag overrides the global preference. */
-gboolean xaccAccountGetAutoInterestXfer (const Account *account,
+gboolean xaccAccountGetAutoInterestXfer (const GncAccount *account,
gboolean default_value);
/** Sets a per-account flag: Prior to reconciling an account which
charges or pays interest, this flag tells whether to prompt the
user to enter a transaction for the interest charge or
payment. This per-account flag overrides the global preference. */
-void xaccAccountSetAutoInterestXfer (Account *account, gboolean value);
+void xaccAccountSetAutoInterestXfer (GncAccount *account, gboolean value);
/** @} */
/** @name Account Commodity setters/getters
@@ -347,13 +358,13 @@
*/
/** Set the account's commodity */
-void xaccAccountSetCommodity (Account *account, gnc_commodity *comm);
+void xaccAccountSetCommodity (GncAccount *account, gnc_commodity *comm);
/** @deprecated do not use */
#define DxaccAccountSetSecurity xaccAccountSetCommodity
/** Get the account's commodity */
-gnc_commodity * xaccAccountGetCommodity (const Account *account);
+gnc_commodity * xaccAccountGetCommodity (const GncAccount *account);
/** @deprecated do not use */
#define DxaccAccountGetSecurity xaccAccountGetCommodity
@@ -362,27 +373,27 @@
* set for the account, that is returned; else the default SCU for
* the account commodity is returned.
*/
-int xaccAccountGetCommoditySCU (const Account *account);
+int xaccAccountGetCommoditySCU (const GncAccount *account);
/** Return the 'internal' SCU setting. This returns the over-ride
* SCU for the account (which might not be set, and might be zero). */
-int xaccAccountGetCommoditySCUi (const Account *account);
+int xaccAccountGetCommoditySCUi (const GncAccount *account);
/** Set the SCU for the account. Normally, this routine is not
* required, as the default SCU for an account is given by its
* commodity.
*/
-void xaccAccountSetCommoditySCU (Account *account, int frac);
+void xaccAccountSetCommoditySCU (GncAccount *account, int frac);
/** @deprecated -- do not use for future development */
#define xaccAccountSetCommoditySCUandFlag xaccAccountSetCommoditySCU
/** Set the flag indicating that this account uses a non-standard SCU. */
-void xaccAccountSetNonStdSCU (Account *account, gboolean flag);
+void xaccAccountSetNonStdSCU (GncAccount *account, gboolean flag);
/** Return boolean, indicating whether this account uses a
* non-standard SCU. */
-gboolean xaccAccountGetNonStdSCU (const Account *account);
+gboolean xaccAccountGetNonStdSCU (const GncAccount *account);
/**@}*/
@@ -391,17 +402,17 @@
*/
/** Get the current balance of the account, which may include future
splits */
-gnc_numeric xaccAccountGetBalance (const Account *account);
+gnc_numeric xaccAccountGetBalance (const GncAccount *account);
/** Get the current balance of the account, only including cleared
transactions */
-gnc_numeric xaccAccountGetClearedBalance (const Account *account);
+gnc_numeric xaccAccountGetClearedBalance (const GncAccount *account);
/** Get the current balance of the account, only including reconciled
transactions */
-gnc_numeric xaccAccountGetReconciledBalance (const Account *account);
-gnc_numeric xaccAccountGetPresentBalance (const Account *account);
-gnc_numeric xaccAccountGetProjectedMinimumBalance (const Account *account);
+gnc_numeric xaccAccountGetReconciledBalance (const GncAccount *account);
+gnc_numeric xaccAccountGetPresentBalance (const GncAccount *account);
+gnc_numeric xaccAccountGetProjectedMinimumBalance (const GncAccount *account);
/** Get the balance of the account as of the date specified */
-gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account,
+gnc_numeric xaccAccountGetBalanceAsOfDate (GncAccount *account,
time_t date);
/* These two functions convert a given balance from one commodity to
@@ -414,50 +425,50 @@
probably some better place for them, but where? gnc-commodity.h?
*/
gnc_numeric xaccAccountConvertBalanceToCurrency(
- const Account *account, /* for book */
+ const GncAccount *account, /* for book */
gnc_numeric balance,
const gnc_commodity *balance_currency,
const gnc_commodity *new_currency);
gnc_numeric xaccAccountConvertBalanceToCurrencyAsOfDate(
- const Account *account, /* for book */
+ const GncAccount *account, /* for book */
gnc_numeric balance, gnc_commodity *balance_currency,
gnc_commodity *new_currency, time_t date);
/* These functions get some type of balance in the desired commodity.
'report_commodity' may be NULL to use the account's commodity. */
gnc_numeric xaccAccountGetBalanceInCurrency (
- const Account *account, const gnc_commodity *report_commodity,
+ const GncAccount *account, const gnc_commodity *report_commodity,
gboolean include_children);
gnc_numeric xaccAccountGetClearedBalanceInCurrency (
- const Account *account, const gnc_commodity *report_commodity,
+ const GncAccount *account, const gnc_commodity *report_commodity,
gboolean include_children);
gnc_numeric xaccAccountGetReconciledBalanceInCurrency (
- const Account *account, const gnc_commodity *report_commodity,
+ const GncAccount *account, const gnc_commodity *report_commodity,
gboolean include_children);
gnc_numeric xaccAccountGetPresentBalanceInCurrency (
- const Account *account, const gnc_commodity *report_commodity,
+ const GncAccount *account, const gnc_commodity *report_commodity,
gboolean include_children);
gnc_numeric xaccAccountGetProjectedMinimumBalanceInCurrency (
- const Account *account, const gnc_commodity *report_commodity,
+ const GncAccount *account, const gnc_commodity *report_commodity,
gboolean include_children);
/* This function gets the balance as of the given date in the desired
commodity. */
gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency(
- Account *account, time_t date, gnc_commodity *report_commodity,
+ GncAccount *account, time_t date, gnc_commodity *report_commodity,
gboolean include_children);
gnc_numeric xaccAccountGetBalanceChangeForPeriod (
- Account *acc, time_t date1, time_t date2, gboolean recurse);
+ GncAccount *acc, time_t date1, time_t date2, gboolean recurse);
/** @} */
-/** @name Account Children and Parents.
+/** @name GncAccount Children and Parents.
* The set of accounts is represented as a doubly-linked tree, so that given
* any account, both its parent and its children can be easily found.
* To make the management of sets of accounts easier, an account does not
- * directly point at its children, but rather at an 'Account Group' that
+ * directly point at its children, but rather at an 'GncAccount Group' that
* stores the children. At the top of the tree heirarchy lies a single
* root node, the root account group.
*
@@ -468,11 +479,11 @@
/** This routine returns the group holding the set of subaccounts
* for this account. */
-AccountGroup * xaccAccountGetChildren (const Account *account);
+AccountGroup * xaccAccountGetChildren (const GncAccount *account);
/** This routine returns the group which contains this account.
*/
-AccountGroup * xaccAccountGetParent (const Account *account);
+AccountGroup * xaccAccountGetParent (const GncAccount *account);
/** This routine returns the parent of the group that is the parent
* of this account. It is equivalent to the nested call
@@ -480,7 +491,7 @@
* Note that if the account is in the root group node, then its
* parent will be NULL.
*/
-Account * xaccAccountGetParentAccount (const Account *account);
+GncAccount * xaccAccountGetParentAccount (const GncAccount *account);
/** This routine returns a flat list of all of the accounts
* that are descendents of this account. This includes not
@@ -491,20 +502,20 @@
* The returned list should be freed with g_list_free() when
* no longer needed.
*/
-GList * xaccAccountGetDescendants (const Account *account);
+GList * xaccAccountGetDescendants (const GncAccount *account);
/** DOCUMENT ME! */
-void xaccAccountSetReconcileChildrenStatus(Account *account, gboolean status);
+void xaccAccountSetReconcileChildrenStatus(GncAccount *account, gboolean status);
/** DOCUMENT ME! */
-gboolean xaccAccountGetReconcileChildrenStatus(const Account *account);
+gboolean xaccAccountGetReconcileChildrenStatus(const GncAccount *account);
/** Returns true if the account is 'ancestor' or has 'ancestor' as an
* ancestor. An ancestor account may be the accounts parent, its
* parent's parent, its parent's parent's parent, etc. Returns false
* if either one is NULL.
*/
-gboolean xaccAccountHasAncestor(const Account *acc, const Account *ancestor);
+gboolean xaccAccountHasAncestor(const GncAccount *acc, const GncAccount *ancestor);
#define xaccAccountGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X))
@@ -560,7 +571,7 @@
/* ------------------ */
-/** @name Account split/transaction list management
+/** @name GncAccount split/transaction list management
@{
*/
/** The xaccAccountInsertSplit() method will insert the indicated
@@ -576,11 +587,11 @@
* structure. Note that some routines (such as xaccAccountRemoveSplit())
* modify this list directly, and could leave you with a corrupted
* pointer. */
-SplitList* xaccAccountGetSplitList (const Account *account);
+SplitList* xaccAccountGetSplitList (const GncAccount *account);
/** The xaccAccountMoveAllSplits() routine reassigns each of the splits
* in accfrom to accto. */
-void xaccAccountMoveAllSplits (Account *accfrom, Account *accto);
+void xaccAccountMoveAllSplits (GncAccount *accfrom, GncAccount *accto);
/** The xaccAccountForEachTransaction() routine will traverse all of
the transactions in the given 'account' and call the callback
@@ -606,23 +617,23 @@
it will not traverse transactions present only in the remote
database.
*/
-gint xaccAccountForEachTransaction(const Account *account,
+gint xaccAccountForEachTransaction(const GncAccount *account,
TransactionCallback proc,
void *data);
/** Returns a pointer to the transaction, not a copy. */
-Transaction * xaccAccountFindTransByDesc(const Account *account,
+Transaction * xaccAccountFindTransByDesc(const GncAccount *account,
const char *description);
/** Returns a pointer to the split, not a copy. */
-Split * xaccAccountFindSplitByDesc(const Account *account,
+Split * xaccAccountFindSplitByDesc(const GncAccount *account,
const char *description);
/*@}*/
/* ------------------ */
-/** @name Account lots
+/** @name GncAccount lots
@{
*/
/** The xaccAccountInsertLot() method will register the indicated lot
@@ -630,8 +641,8 @@
* belong to this account. If the lot is already in another account,
* the lot, and all of the splits in it, will be moved from that
* account to this account. */
-void xaccAccountInsertLot (Account *, GNCLot *);
-void xaccAccountRemoveLot (Account *, GNCLot *);
+void xaccAccountInsertLot (GncAccount *, GNCLot *);
+void xaccAccountRemoveLot (GncAccount *, GNCLot *);
/** The xaccAccountGetLotList() routine returns a pointer to the GList of
* the lots in this account.
@@ -640,7 +651,7 @@
* structure. Note that some routines (such as xaccAccountRemoveLot())
* modify this list directly, and could leave you with a corrupted
* pointer. */
-LotList* xaccAccountGetLotList (const Account *account);
+LotList* xaccAccountGetLotList (const GncAccount *account);
/** The xaccAccountForEachLot() method will apply the function 'proc'
* to each lot in the account. If 'proc' returns a non-NULL value,
@@ -649,7 +660,7 @@
* the Lots will be traversed.
*/
gpointer xaccAccountForEachLot(
- const Account *acc,
+ const GncAccount *acc,
gpointer (*proc)(GNCLot *lot, gpointer user_data), gpointer user_data);
@@ -658,7 +669,7 @@
* If sort_func is NULL, then the returned list has no particular order.
* The caller must free to returned list.
*/
-LotList * xaccAccountFindOpenLots (const Account *acc,
+LotList * xaccAccountFindOpenLots (const GncAccount *acc,
gboolean (*match_func)(GNCLot *lot,
gpointer user_data),
gpointer user_data, GCompareFunc sort_func);
@@ -666,37 +677,37 @@
/** @} */
/* ------------------ */
-/** @name Account Reconciliation information getters/setters
+/** @name GncAccount Reconciliation information getters/setters
@{
*/
/** DOCUMENT ME! */
-gboolean xaccAccountGetReconcileLastDate (const Account *account,
+gboolean xaccAccountGetReconcileLastDate (const GncAccount *account,
time_t *last_date);
/** DOCUMENT ME! */
-void xaccAccountSetReconcileLastDate (Account *account, time_t last_date);
+void xaccAccountSetReconcileLastDate (GncAccount *account, time_t last_date);
/** DOCUMENT ME! */
-gboolean xaccAccountGetReconcileLastInterval (const Account *account,
+gboolean xaccAccountGetReconcileLastInterval (const GncAccount *account,
int *months, int *days);
/** DOCUMENT ME! */
-void xaccAccountSetReconcileLastInterval (Account *account,
+void xaccAccountSetReconcileLastInterval (GncAccount *account,
int months, int days);
/** DOCUMENT ME! */
-gboolean xaccAccountGetReconcilePostponeDate (const Account *account,
+gboolean xaccAccountGetReconcilePostponeDate (const GncAccount *account,
time_t *postpone_date);
/** DOCUMENT ME! */
-void xaccAccountSetReconcilePostponeDate (Account *account,
+void xaccAccountSetReconcilePostponeDate (GncAccount *account,
time_t postpone_date);
/** DOCUMENT ME! */
-gboolean xaccAccountGetReconcilePostponeBalance (const Account *account,
+gboolean xaccAccountGetReconcilePostponeBalance (const GncAccount *account,
gnc_numeric *balance);
/** DOCUMENT ME! */
-void xaccAccountSetReconcilePostponeBalance (Account *account,
+void xaccAccountSetReconcilePostponeBalance (GncAccount *account,
gnc_numeric balance);
/** DOCUMENT ME! */
-void xaccAccountClearReconcilePostpone (Account *account);
+void xaccAccountClearReconcilePostpone (GncAccount *account);
/** @} */
@@ -708,7 +719,7 @@
PLACEHOLDER_CHILD,
} GNCPlaceholderType;
-/** @name Account Placeholder flag
+/** @name GncAccount Placeholder flag
@{
*/
@@ -718,7 +729,7 @@
* @param acc The account whose flag should be retrieved.
*
* @return The current state of the account's "placeholder" flag. */
-gboolean xaccAccountGetPlaceholder (const Account *account);
+gboolean xaccAccountGetPlaceholder (const GncAccount *account);
/** Set the "placeholder" flag for an account. If this flag is set
* then the account may not be modified by the user.
@@ -726,17 +737,17 @@
* @param acc The account whose flag should be retrieved.
*
* @param val The new state for the account's "placeholder" flag. */
-void xaccAccountSetPlaceholder (Account *account, gboolean option);
+void xaccAccountSetPlaceholder (GncAccount *account, gboolean option);
/** Returns PLACEHOLDER_NONE if account is NULL or neither account nor
* any descendent of account is a placeholder. If account is a
* placeholder, returns PLACEHOLDER_THIS. Otherwise, if any
* descendant of account is a placeholder, return PLACEHOLDER_CHILD.
*/
-GNCPlaceholderType xaccAccountGetDescendantPlaceholder(const Account *account);
+GNCPlaceholderType xaccAccountGetDescendantPlaceholder(const GncAccount *account);
/** @} */
-/** @name Account Hidden flag
+/** @name GncAccount Hidden flag
@{
*/
@@ -747,7 +758,7 @@
* @param acc The account whose flag should be retrieved.
*
* @return The current state of the account's "hidden" flag. */
-gboolean xaccAccountGetHidden (const Account *acc);
+gboolean xaccAccountGetHidden (const GncAccount *acc);
/** Set the "hidden" flag for an account. If this flag is set then
* the account (and any children) will be hidden from the user unless
@@ -756,7 +767,7 @@
* @param acc The account whose flag should be retrieved.
*
* @param val The new state for the account's "hidden" flag. */
-void xaccAccountSetHidden (Account *acc, gboolean val);
+void xaccAccountSetHidden (GncAccount *acc, gboolean val);
/** Should this account be "hidden". If this flag is set for this
* account (or any parent account) then the account should be hidden
@@ -767,29 +778,29 @@
* @param acc The account whose flag should be retrieved.
*
* @return Whether or not this account should be "hidden". */
-gboolean xaccAccountIsHidden (const Account *acc);
+gboolean xaccAccountIsHidden (const GncAccount *acc);
/** @} */
-/** @name Account Tax related getters/setters
+/** @name GncAccount Tax related getters/setters
@{
*/
/** DOCUMENT ME! */
-gboolean xaccAccountGetTaxRelated (const Account *account);
+gboolean xaccAccountGetTaxRelated (const GncAccount *account);
/** DOCUMENT ME! */
-void xaccAccountSetTaxRelated (Account *account, gboolean tax_related);
+void xaccAccountSetTaxRelated (GncAccount *account, gboolean tax_related);
/** DOCUMENT ME! */
-const char * xaccAccountGetTaxUSCode (const Account *account);
+const char * xaccAccountGetTaxUSCode (const GncAccount *account);
/** DOCUMENT ME! */
-void xaccAccountSetTaxUSCode (Account *account, const char *code);
+void xaccAccountSetTaxUSCode (GncAccount *account, const char *code);
/** DOCUMENT ME! */
-const char * xaccAccountGetTaxUSPayerNameSource (const Account *account);
+const char * xaccAccountGetTaxUSPayerNameSource (const GncAccount *account);
/** DOCUMENT ME! */
-void xaccAccountSetTaxUSPayerNameSource (Account *account, const char *source);
+void xaccAccountSetTaxUSPayerNameSource (GncAccount *account, const char *source);
/** @} */
-/** @name Account marking
+/** @name GncAccount marking
@{
*/
/** Set a mark on the account. The meaning of this mark is
@@ -798,18 +809,18 @@
* over the account tree. The mark is *not* stored in the database/file
* format. When accounts are newly created, the mark is set to zero.
*/
-void xaccAccountSetMark (Account *account, short mark);
+void xaccAccountSetMark (GncAccount *account, short mark);
/** Get the mark set by xaccAccountSetMark */
-short xaccAccountGetMark (const Account *account);
+short xaccAccountGetMark (const GncAccount *account);
/** The xaccClearMark will find the topmost group, and clear the mark in
* the entire group tree. */
-void xaccClearMark (Account *account, short val);
+void xaccClearMark (GncAccount *account, short val);
/** The xaccClearMarkDown will clear the mark only in this and in
* sub-accounts.*/
-void xaccClearMarkDown (Account *account, short val);
+void xaccClearMarkDown (GncAccount *account, short val);
/** Will clear the mark for all the accounts of the AccountGroup .*/
void xaccClearMarkDownGr (AccountGroup *group, short val);
/** @} */
@@ -824,12 +835,12 @@
* it.
*
* These two funcs take control of their gnc_commodity args. Don't free */
-void DxaccAccountSetCurrency (Account *account, gnc_commodity *currency);
+void DxaccAccountSetCurrency (GncAccount *account, gnc_commodity *currency);
/** @deprecated The current API associates only one thing with an
* account: the 'commodity'. Use xaccAccountGetCommodity() to fetch
* it. */
-gnc_commodity * DxaccAccountGetCurrency (const Account *account);
+gnc_commodity * DxaccAccountGetCurrency (const GncAccount *account);
/** Set the timezone to be used when interpreting the results from a
* given Finance::Quote backend. Unfortunately, the upstream sources
@@ -838,18 +849,18 @@
* @deprecated Price quote information is now stored on the
* commodity, not the account. */
-void dxaccAccountSetQuoteTZ (Account *account, const char *tz);
+void dxaccAccountSetQuoteTZ (GncAccount *account, const char *tz);
/** Get the timezone to be used when interpreting the results from a
* given Finance::Quote backend. Unfortunately, the upstream sources
* don't label their output, so the user has to specify this bit.
*
* @deprecated Price quote information is now stored on the
* commodity, not the account. */
-const char * dxaccAccountGetQuoteTZ (const Account *account);
+const char * dxaccAccountGetQuoteTZ (const GncAccount *account);
/** @} */
-/** @name Account parameter names
+/** @name GncAccount parameter names
@{
*/
#define ACCOUNT_KVP "kvp"
Modified: gnucash/branches/gobject-engine-dev/src/engine/AccountP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/AccountP.h 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/engine/AccountP.h 2007-02-14 01:24:23 UTC (rev 15578)
@@ -52,87 +52,7 @@
* No one outside of the engine should ever include this file.
*/
-/** \struct Account */
-struct _Account
-{
- QofInstance inst;
- /* The accountName is an arbitrary string assigned by the user.
- * It is intended to a short, 5 to 30 character long string that
- * is displayed by the GUI as the account mnemonic.
- */
- char *accountName;
-
- /* The accountCode is an arbitrary string assigned by the user.
- * It is intended to be reporting code that is a synonym for the
- * accountName. Typically, it will be a numeric value that follows
- * the numbering assignments commonly used by accountants, such
- * as 100, 200 or 600 for top-level accounts, and 101, 102.. etc.
- * for detail accounts.
- */
- char *accountCode;
-
- /* The description is an arbitrary string assigned by the user.
- * It is intended to be a longer, 1-5 sentence description of what
- * this account is all about.
- */
- char *description;
-
- /* The type field is the account type, picked from the enumerated
- * list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
- * ACCT_TYPE_CREDIT, ACCT_TYPE_INCOME, etc. Its intended use is to
- * be a hint to the GUI as to how to display and format the
- * transaction data.
- */
- GNCAccountType type;
-
- /*
- * The commodity field denotes the kind of 'stuff' stored
- * in this account. The 'amount' field of a split indicates
- * how much of the 'stuff' there is.
- */
- gnc_commodity * commodity;
- int commodity_scu;
- gboolean non_standard_scu;
-
- /* The parent and children pointers are used to implement an account
- * hierarchy, of accounts that have sub-accounts ("detail accounts").
- */
- AccountGroup *parent; /* back-pointer to parent */
- AccountGroup *children; /* pointer to sub-accounts */
-
- /* protected data, cached parameters */
- gnc_numeric starting_balance;
- gnc_numeric starting_cleared_balance;
- gnc_numeric starting_reconciled_balance;
-
- gnc_numeric balance;
- gnc_numeric cleared_balance;
- gnc_numeric reconciled_balance;
-
- /* version number, used for tracking multiuser updates */
- gint32 version;
- guint32 version_check; /* data aging timestamp */
-
- SplitList *splits; /* list of split pointers */
- LotList *lots; /* list of lot pointers */
-
- /* Cached pointer to policy method */
- GNCPolicy *policy;
-
- gboolean balance_dirty; /* balances in splits incorrect */
- gboolean sort_dirty; /* sort order of splits is bad */
-
- /* The "mark" flag can be used by the user to mark this account
- * in any way desired. Handy for specialty traversals of the
- * account tree. */
- short mark;
-
- /* -------------------------------------------------------------- */
- /* Backend private expansion data */
- guint32 idata; /* used by the sql backend for kvp management */
-};
-
/* The xaccAccountSortSplits() routine will resort the account's
* splits if the sort is dirty. If 'force' is true, the account
* is sorted even if the editlevel is not zero.
Modified: gnucash/branches/gobject-engine-dev/src/engine/Split.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Split.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/engine/Split.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -686,7 +686,7 @@
original and new transactions, for the _next_ begin/commit cycle. */
s->orig_acc = s->acc;
s->orig_parent = s->parent;
- qof_instance_mark_clean(QOF_INSTANCE(s));
+ qof_instance_mark_clean (QOF_INSTANCE(s));
/* This is because Splits don't call qof_commit_edit(). */
qof_instance_set_dirty(QOF_INSTANCE(s->parent));
Modified: gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c 2007-02-14 01:01:01 UTC (rev 15577)
+++ gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c 2007-02-14 01:24:23 UTC (rev 15578)
@@ -1240,6 +1240,7 @@
g_return_if_fail(session);
book = qof_session_get_book(session);
+ /* TODO: attach a callback to the set dirty event */
qof_book_set_dirty_cb(book, gnc_main_window_book_dirty_cb, NULL);
}
More information about the gnucash-changes
mailing list