r17444 - gnucash/trunk - Merge gda-dev2 branch into trunk.

Phil Longstaff plongstaff at cvs.gnucash.org
Fri Aug 1 12:02:09 EDT 2008


Author: plongstaff
Date: 2008-08-01 12:02:07 -0400 (Fri, 01 Aug 2008)
New Revision: 17444
Trac: http://svn.gnucash.org/trac/changeset/17444

Added:
   gnucash/trunk/DBI_STATUS
   gnucash/trunk/packaging/win32/libgda-3.1.2-patch.diff
   gnucash/trunk/packaging/win32/libgda-3.1.2-patch2.diff
   gnucash/trunk/src/backend/dbi/
   gnucash/trunk/src/backend/file/gncmod-backend-xml.c
   gnucash/trunk/src/backend/sql/
   gnucash/trunk/src/bin/gnucash-gdb.in
   gnucash/trunk/src/business/business-core/file/gncmod-business-backend-xml.c
   gnucash/trunk/src/business/business-core/sql/
   gnucash/trunk/src/gnome-utils/dialog-database-connection.c
   gnucash/trunk/src/gnome-utils/dialog-database-connection.h
   gnucash/trunk/src/gnome-utils/glade/dialog-database-connection.glade
   gnucash/trunk/src/valgrind-glib.supp
   gnucash/trunk/src/valgrind-libfontconfig.supp
   gnucash/trunk/src/valgrind-libgda.supp
   gnucash/trunk/src/valgrind-libguile.supp
Modified:
   gnucash/trunk/configure.in
   gnucash/trunk/lib/libqof/qof/gnc-date.c
   gnucash/trunk/lib/libqof/qof/qofinstance.c
   gnucash/trunk/lib/libqof/qof/qofsession.c
   gnucash/trunk/lib/libqof/qof/qofsession.h
   gnucash/trunk/packaging/win32/Makefile.am
   gnucash/trunk/packaging/win32/defaults.sh
   gnucash/trunk/packaging/win32/dist.sh
   gnucash/trunk/packaging/win32/install.sh
   gnucash/trunk/src/backend/Makefile.am
   gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
   gnucash/trunk/src/backend/dbi/test/
   gnucash/trunk/src/backend/file/Makefile.am
   gnucash/trunk/src/backend/file/gnc-account-xml-v2.c
   gnucash/trunk/src/backend/file/gnc-backend-file.c
   gnucash/trunk/src/backend/file/gnc-backend-file.h
   gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
   gnucash/trunk/src/backend/file/test/Makefile.am
   gnucash/trunk/src/backend/file/test/test-load-backend.c
   gnucash/trunk/src/backend/file/test/test-load-xml2.c
   gnucash/trunk/src/backend/postgres/test/Makefile.am
   gnucash/trunk/src/backend/sql/test/
   gnucash/trunk/src/bin/
   gnucash/trunk/src/bin/Makefile.am
   gnucash/trunk/src/bin/gnucash-valgrind.in
   gnucash/trunk/src/bin/gnucash.in
   gnucash/trunk/src/business/business-core/Makefile.am
   gnucash/trunk/src/business/business-core/file/Makefile.am
   gnucash/trunk/src/business/business-core/gncAddress.c
   gnucash/trunk/src/business/business-core/gncAddressP.h
   gnucash/trunk/src/business/business-core/gncBillTerm.c
   gnucash/trunk/src/business/business-core/gncBillTerm.h
   gnucash/trunk/src/business/business-core/gncBillTermP.h
   gnucash/trunk/src/business/business-core/gncCustomer.c
   gnucash/trunk/src/business/business-core/gncCustomer.h
   gnucash/trunk/src/business/business-core/gncEmployee.c
   gnucash/trunk/src/business/business-core/gncEmployee.h
   gnucash/trunk/src/business/business-core/gncEntry.c
   gnucash/trunk/src/business/business-core/gncEntry.h
   gnucash/trunk/src/business/business-core/gncInvoice.c
   gnucash/trunk/src/business/business-core/gncInvoice.h
   gnucash/trunk/src/business/business-core/gncJob.c
   gnucash/trunk/src/business/business-core/gncJob.h
   gnucash/trunk/src/business/business-core/gncOrder.c
   gnucash/trunk/src/business/business-core/gncOrder.h
   gnucash/trunk/src/business/business-core/gncOwner.c
   gnucash/trunk/src/business/business-core/gncOwner.h
   gnucash/trunk/src/business/business-core/gncTaxTable.c
   gnucash/trunk/src/business/business-core/gncTaxTable.h
   gnucash/trunk/src/business/business-core/gncTaxTableP.h
   gnucash/trunk/src/business/business-core/gncVendor.c
   gnucash/trunk/src/business/business-core/gncVendor.h
   gnucash/trunk/src/business/business-gnome/business-gnome.scm
   gnucash/trunk/src/business/business-gnome/dialog-billterms.c
   gnucash/trunk/src/engine/Account.c
   gnucash/trunk/src/engine/SX-book.c
   gnucash/trunk/src/engine/SX-book.h
   gnucash/trunk/src/engine/SchedXaction.c
   gnucash/trunk/src/engine/Split.c
   gnucash/trunk/src/engine/Split.h
   gnucash/trunk/src/engine/gnc-book.h
   gnucash/trunk/src/engine/gnc-budget.c
   gnucash/trunk/src/engine/gnc-budget.h
   gnucash/trunk/src/engine/gnc-commodity.c
   gnucash/trunk/src/engine/gnc-engine.c
   gnucash/trunk/src/engine/gnc-filepath-utils.c
   gnucash/trunk/src/engine/gnc-lot.c
   gnucash/trunk/src/engine/gnc-lot.h
   gnucash/trunk/src/experimental/cgi-bin/Makefile.am
   gnucash/trunk/src/gnc-ui.h
   gnucash/trunk/src/gnome-utils/Makefile.am
   gnucash/trunk/src/gnome-utils/glade/Makefile.am
   gnucash/trunk/src/gnome-utils/gnc-file.c
   gnucash/trunk/src/gnome-utils/gnc-file.h
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/gnome-utils/test/Makefile.am
   gnucash/trunk/src/gnome/Makefile.am
   gnucash/trunk/src/gnome/dialog-price-editor.c
   gnucash/trunk/src/gnome/dialog-sx-editor.c
   gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
   gnucash/trunk/src/gnome/lot-viewer.c
   gnucash/trunk/src/gnome/ui/gnc-plugin-basic-commands-ui.xml
   gnucash/trunk/src/import-export/qif-io-core/test/Makefile.am
   gnucash/trunk/src/import-export/test/Makefile.am
   gnucash/trunk/src/report/report-gnome/test/Makefile.am
   gnucash/trunk/src/report/stylesheets/test/Makefile.am
   gnucash/trunk/src/valgrind-gdk.supp
   gnucash/trunk/src/valgrind-gnucash.supp
Log:
Merge gda-dev2 branch into trunk.

This introduces the dbi backend and the --enable-dbi configure option.



Added: gnucash/trunk/DBI_STATUS
===================================================================
--- gnucash/trunk/DBI_STATUS	                        (rev 0)
+++ gnucash/trunk/DBI_STATUS	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,25 @@
+Status of the DBI backend.
+
+Code for all standard and business objects has been written.  The following
+bugs/issues are known.
+
+* Initial save performance is better than it used to be, but is still slow.
+For example, saving my file with ~8000 transactions and ~21000 splits takes
+13 minutes to an sqlite db.
+* Foreign key definitions should be used for referential integrity.
+* (Maybe) Keep an 'old values' table for each main table.  When a record is
+updated, copy the old record to the 'old values' table first to keep track of
+any changes.
+* Use prepared statements
+* Use cursor-based data models when reading from the db for better performance
+* Write automated tests
+* Write doxygen comment headers
+* Don't need a log file
+* Certain dialogs create an object when opened and update it as they go along.
+This can result in trying to save invalid objects:
+	- Price editor (new price has no commodity or currency)
+	- New invoice
+* Need transactions to group updates to multiple objects
+* Possibly mark commodities that are in the db so that they don't need to be
+queried every time.
+* The sqlite db file is *much* larger than the gzipped XML file.

Modified: gnucash/trunk/configure.in
===================================================================
--- gnucash/trunk/configure.in	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/configure.in	2008-08-01 16:02:07 UTC (rev 17444)
@@ -604,6 +604,55 @@
 AC_SUBST(QOF_LIB_DIR)
 AC_SUBST(QOF_XML_DIR)
 
+AC_DEFINE(QOF_DISABLE_DEPRECATED,1, [Don't use deprecated qof functions])
+
+### -----------------------
+### LIBGDA
+#AC_ARG_ENABLE(gda, 
+#  [AS_HELP_STRING([--enable-gda],[build with the libgda backend])],
+#  [case "${enableval}" in
+#     yes) want_gda=true ;;
+#     no)  want_gda=false ;;
+#     *) want_gda=false ;;
+#   esac],
+#   [want_gda=false])
+#if test x${want_gda} = xtrue
+#then
+#  PKG_CHECK_MODULES(LIBGDA, libgda-4.0 >= 3.99.2, [GDA_DIR=gda])
+#fi
+#AC_SUBST(GDA_DIR)
+#AC_SUBST(LIBGDA_CFLAGS)
+#AC_SUBST(LIBGDA_LIBS)
+
+### ----------------------
+### LIBDBI
+AC_ARG_ENABLE(dbi,
+  [AS_HELP_STRING([--enable-dbi],[build with the libdbi backend])],
+  [case "${enableval}" in
+     yes) want_dbi=true ;;
+     no)  want_dbi=false ;;
+     *) want_dbi=false ;;
+   esac],
+   [want_dbi=false])
+if test x${want_dbi} = xtrue
+then
+  AC_CHECK_HEADERS(dbi/dbi.h)
+  if test "x$ac_cv_header_dbi_dbi_h" != xno; then
+    AC_ARG_WITH( dbi-dbd-dir,
+      [AS_HELP_STRING([--with-dbi-dbd-dir=PATH],[specify location of libdbi drivers @<:@default=/usr/lib/dbd@:>@])],
+      GNC_DBD_DIR="$with_dbi_dbd_dir",
+      GNC_DBD_DIR="/usr/lib/dbd")
+
+    LIBDBI_LIBS=-ldbi
+    DBI_DIR=dbi
+  else
+    AC_MSG_ERROR( Unable to find dbi/dbi.h )
+  fi
+fi
+AC_SUBST(LIBDBI_LIBS)
+AC_SUBST(DBI_DIR)
+AC_SUBST(GNC_DBD_DIR)
+
 ### --------------------------------------------------------------------------
 ### Variables
 ### Set up all the initial variable values...
@@ -654,94 +703,6 @@
 
 
 ### --------------------------------------------------------------------------
-### SQL
-# Check to see if the user wants to have Postgres support
-#
-# hack alert ... we should use 'pg_config --includedir' and
-# 'pg_config --libdir' to find paths; unfortunately pg_config itself
-# is hard to find :-(
-
-AC_ARG_ENABLE( sql,
-  [  --enable-sql                 compile with sql support],
-  [
-    PG_CONFIG=`which pg_config`
-
-    if test "x$PG_CONFIG" = "x" ; then
-        PG_CONFIG="/usr/lib/postgresql/bin/pg_config"
-    fi
-
-    if test "x$enableval" != "xno" ; then
-
-      PGSQL_CFLAGS=`${PG_CONFIG} --includedir`
-      if test "x$PGSQL_CFLAGS" != x; then
-	PGSQL_CFLAGS="-I${PGSQL_CFLAGS}"
-      fi
-
-      AS_SCRUB_INCLUDE(PGSQL_CFLAGS)
-# XXX Fixme: CPPFLAGS are saved but CFLAGS are altered later on and not restored.
-      saved_CPPFLAGS="${CPPFLAGS}"
-      saved_CFLAGS="${CFLAGS}"
-      CPPFLAGS="${CPPFLAGS} ${PGSQL_CFLAGS}"
-      AC_CHECK_HEADERS(pgsql/libpq-fe.h postgresql/libpq-fe.h libpq-fe.h)
-      if test "x$ac_cv_header_pgsql_libpq_fe_h$ac_cv_header_postgresql_libpq_fe_h$ac_cv_header_libpq_fe_h" = xnonono; then
-         AC_MSG_ERROR([Cannot find PostgreSQL headers; won't build sql backend]) 
-      else 
-        master_dirs="/usr/include /usr/local/include"
-        if test "x$ac_cv_header_pgsql_libpq_fe_h" != xno; then
-          for dir in $master_dirs; do
-              if test -f "$dir/pgsql/libpq-fe.h"; then
-                  CFLAGS="${CFLAGS} -I$dir/pgsql"
-                  break
-	      fi
-          done
-        elif test "x$ac_cv_header_postgresql_libpq_fe_h" != xno; then
-          for dir in $master_dirs; do
-              if test -f "$dir/postgresql/libpq-fe.h"; then
-                  CFLAGS="${CFLAGS} -I$dir/postgresql"
-                  break
-              fi
-          done
-	fi
-
-	AS_SCRUB_INCLUDE(CFLAGS)
-        
-        PGSQL_LIBS=`${PG_CONFIG} --libdir`
-        if test "x$PGSQL_LIBS" != x; then
-	  PGSQL_LIBS="-L${PGSQL_LIBS}"
-        fi
-
-        saved_LIBS="$LIBS"
- 	LIBS="${PGSQL_LIBS} -lpq $LIBS"
-        AC_MSG_CHECKING(for libpq)
-        AC_TRY_LINK(
-          [
-	    #include <libpq-fe.h>
-	  ],
-          [
-             PQconnectdb("asdf");
-          ],
-          [
-            AC_MSG_RESULT(yes)
-            SQL_DIR=postgres
-          ],
-          [
-            AC_MSG_ERROR([Cannot find PostgreSQL libraries; will not build sql backend]) 
-          ]
-        )
-        LIBS="$saved_LIBS"
-      fi
-      CPPFLAGS="$saved_CPPFLAGS"
-      CFLAGS="$saved_CFLAGS"
-    fi
-  ]
-)
-
-AC_SUBST(PGSQL_CFLAGS)
-AC_SUBST(PGSQL_LIBS)
-AC_SUBST(SQL_DIR)
-
-
-### --------------------------------------------------------------------------
 ### RPC has been removed in gnucash 1.9.0
 
 ### --------------------------------------------------------------------------
@@ -1497,12 +1458,16 @@
           src/app-utils/Makefile
           src/app-utils/test/Makefile
           src/backend/Makefile
+		  src/backend/dbi/Makefile
+		  src/backend/dbi/test/Makefile
           src/backend/file/Makefile
           src/backend/file/test/Makefile
           src/backend/file/test/test-files/Makefile
           src/backend/file/test/test-files/xml2/Makefile
           src/backend/postgres/Makefile
           src/backend/postgres/test/Makefile
+		  src/backend/sql/Makefile
+		  src/backend/sql/test/Makefile
           src/bin/Makefile
           src/bin/overrides/Makefile
           src/bin/test/Makefile
@@ -1587,6 +1552,7 @@
           src/test-core/Makefile
           src/business/Makefile
           src/business/business-core/Makefile
+          src/business/business-core/sql/Makefile
           src/business/business-core/test/Makefile
           src/business/business-core/file/Makefile
           src/business/business-utils/Makefile
@@ -1611,9 +1577,12 @@
 output_qof_lib_dir=`eval eval eval echo $QOF_LIB_DIR`
 output_qof_xml_dir=`eval eval eval echo $QOF_XML_DIR`
 
-if test x${SQL_DIR} != x; then
-components="$components sql"
+if test x${DBI_DIR} != x; then
+components="$components dbi"
 fi
+if test x${GDA_DIR} != x; then
+components="$components gda"
+fi
 if test x${OFX_DIR} != x; then
 components="$components ofx"
 fi

Modified: gnucash/trunk/lib/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/gnc-date.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/lib/libqof/qof/gnc-date.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1052,7 +1052,7 @@
 
   /* Timezone format can be +hh or +hhmm or +hh.mm (or -) (or not present) */
   str += strcspn (str, "+-");
-  if (str)
+  if (*str)
   {
     buf[0] = str[0];
     buf[1] = str[1];

Modified: gnucash/trunk/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofinstance.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/lib/libqof/qof/qofinstance.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -970,11 +970,11 @@
         /* XXX the backend commit code should clear dirty!! */
         priv->dirty = FALSE;
     }
-    if (dirty && qof_get_alt_dirty_mode() && 
-        !(priv->infant && priv->do_free)) {
-      qof_collection_mark_dirty(priv->collection);
-      qof_book_mark_dirty(priv->book);
-    }
+//    if (dirty && qof_get_alt_dirty_mode() && 
+//        !(priv->infant && priv->do_free)) {
+//      qof_collection_mark_dirty(priv->collection);
+//      qof_book_mark_dirty(priv->book);
+//    }
     priv->infant = FALSE;
 
     if (priv->do_free) {

Modified: gnucash/trunk/lib/libqof/qof/qofsession.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofsession.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/lib/libqof/qof/qofsession.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -63,6 +63,20 @@
 	provider_list = g_slist_append (provider_list, prov);
 }
 
+GList*
+qof_backend_get_registered_access_method_list(void)
+{
+	GList* list = NULL;
+	GSList* node;
+
+	for( node = provider_list; node != NULL; node = node->next ) {
+		QofBackendProvider *prov = node->data;
+		list = g_list_append( list, (gchar*)prov->access_method );
+	}
+
+	return list;
+}
+
 /* ====================================================================== */
 
 /* hook routines */

Modified: gnucash/trunk/lib/libqof/qof/qofsession.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofsession.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/lib/libqof/qof/qofsession.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -436,5 +436,10 @@
                              QofSession *real_session,
                              QofPercentageFunc percentage_func);
 
+/** Return a list of strings for the registered access methods. The owner is
+ *  responsible for freeing the list but not the strings.
+ */
+GList* qof_backend_get_registered_access_method_list(void);
+
 #endif /* QOF_SESSION_H */
 /** @} */

Modified: gnucash/trunk/packaging/win32/Makefile.am
===================================================================
--- gnucash/trunk/packaging/win32/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/packaging/win32/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -9,6 +9,8 @@
   install-fq-mods.bat \
   libofx-0.8.3-patch.diff \
   opensp-1.5.2-patch.diff \
+  libgda-3.1.2-patch.diff \
+  libgda-3.1.2-patch2.diff \
   pi.sh \
   Greek-4-5.1.11.isl \
   reset.sh

Modified: gnucash/trunk/packaging/win32/defaults.sh
===================================================================
--- gnucash/trunk/packaging/win32/defaults.sh	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/packaging/win32/defaults.sh	2008-08-01 16:02:07 UTC (rev 17444)
@@ -262,6 +262,11 @@
 # If set to yes, download Qt from http://www.trolltech.com/developer/downloads/qt/windows,
 # install it and set QTDIR in custom.sh, like "QTDIR=/c/Qt/4.2.3".
 
+set_default LIBGDA_URL "http://ftp.acc.umu.se/pub/GNOME/sources/libgda/3.1/libgda-3.1.2.tar.gz"
+set_default LIBGDA_DIR $GLOBAL_DIR\\libgda
+set_default LIBGDA_PATCH `pwd`/libgda-3.1.2-patch.diff
+set_default LIBGDA_PATCH2 `pwd`/libgda-3.1.2-patch2.diff
+
 set_default DOCBOOK_XSL_URL "$SF_MIRROR/docbook/docbook-xsl-1.72.0.zip"
 set_default UPDATE_DOCS yes
 set_default DOCS_REV "HEAD"
@@ -305,6 +310,7 @@
 add_step inst_gwenhywfar
 add_step inst_ktoblzcheck
 add_step inst_aqbanking
+add_step inst_libgda
 ##
 if [ "$CROSS_COMPILE" != "yes" ]; then
  add_step inst_inno

Modified: gnucash/trunk/packaging/win32/dist.sh
===================================================================
--- gnucash/trunk/packaging/win32/dist.sh	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/packaging/win32/dist.sh	2008-08-01 16:02:07 UTC (rev 17444)
@@ -34,6 +34,7 @@
     _LIBOFX_UDIR=`unix_path $LIBOFX_DIR`
     _GWENHYWFAR_UDIR=`unix_path $GWENHYWFAR_DIR`
     _AQBANKING_UDIR=`unix_path $AQBANKING_DIR`
+    _LIBGDA_UDIR=`unix_path $LIBGDA_DIR`
     _GNUCASH_UDIR=`unix_path $GNUCASH_DIR`
     _REPOS_UDIR=`unix_path $REPOS_DIR`
     _BUILD_UDIR=`unix_path $BUILD_DIR`
@@ -171,6 +172,14 @@
     cp -a ${_AQBANKING_UDIR}/share/locale ${DIST_UDIR}/lib
 }
 
+function dist_libgda() {
+    setup Libgda
+    cp -a ${_LIBGDA_UDIR}/bin/* ${DIST_UDIR}/bin
+    cp -a ${_LIBGDA_UDIR}/lib/libgda-3.0 ${DIST_UDIR}/lib
+    cp -a ${_LIBGDA_UDIR}/share/libgda-3.0 ${DIST_UDIR}/share
+    cp -a ${_LIBGDA_UDIR}/share/locale ${DIST_UDIR}/lib
+}
+
 function dist_gnucash() {
     setup GnuCash
     mkdir -p $DIST_UDIR/bin
@@ -245,6 +254,7 @@
 dist_libofx
 dist_gwenhywfar
 dist_aqbanking
+dist_libgda
 dist_gnucash
 finish
 qpopd

Modified: gnucash/trunk/packaging/win32/install.sh
===================================================================
--- gnucash/trunk/packaging/win32/install.sh	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/packaging/win32/install.sh	2008-08-01 16:02:07 UTC (rev 17444)
@@ -929,6 +929,33 @@
     fi
 }
 
+function inst_libgda() {
+    setup LibGDA
+    _LIBGDA_UDIR=`unix_path ${LIBGDA_DIR}`
+    add_to_env ${_LIBGDA_UDIR}/bin PATH
+    add_to_env ${_LIBGDA_UDIR}/lib/pkgconfig PKG_CONFIG_PATH
+    if quiet ${PKG_CONFIG} --exists libgda-3.0
+    then
+        echo "Libgda already installed. skipping."
+    else
+        wget_unpacked $LIBGDA_URL $DOWNLOAD_DIR $TMP_DIR
+        assert_one_dir $TMP_UDIR/libgda-*
+        qpushd $TMP_UDIR/libgda-*
+            #patch to ignore vfs, as libgda uses depriciated header
+            patch libgda/gda-data-model-dir.c $LIBGDA_PATCH
+            #patch to use g_setenv instead of setenv (bug #510739)
+            patch tools/gda-sql.c $LIBGDA_PATCH2
+            ./configure  \
+                --prefix=${_LIBGDA_UDIR} \
+                CPPFLAGS="${REGEX_CPPFLAGS} ${GNOME_CPPFLAGS}" \
+                LDFLAGS="${REGEX_LDFLAGS} ${GNOME_LDFLAGS} -lintl"
+            make
+            make install
+        qpopd
+        ${PKG_CONFIG} --exists libgda-3.0 || die "Libgda not installed correctly"
+    fi
+}
+
 function svn_up() {
     mkdir -p $_REPOS_UDIR
     qpushd $REPOS_DIR
@@ -992,7 +1019,7 @@
         qpushd src/bin
             rm gnucash
             make PATH_SEPARATOR=";" \
-                bindir="${_INSTALL_UDIR}/bin:${_INSTALL_UDIR}/lib:${_INSTALL_UDIR}/lib/gnucash:${_GOFFICE_UDIR}/bin:${_LIBGSF_UDIR}/bin:${_PCRE_UDIR}/bin:${_GNOME_UDIR}/bin:${_LIBXML2_UDIR}/bin:${_GUILE_UDIR}/bin:${_REGEX_UDIR}/bin:${_AUTOTOOLS_UDIR}/bin:${AQBANKING_UPATH}:${_LIBOFX_UDIR}/bin:${_OPENSP_UDIR}/bin" \
+                bindir="${_INSTALL_UDIR}/bin:${_INSTALL_UDIR}/lib:${_INSTALL_UDIR}/lib/gnucash:${_GOFFICE_UDIR}/bin:${_LIBGSF_UDIR}/bin:${_PCRE_UDIR}/bin:${_GNOME_UDIR}/bin:${_LIBXML2_UDIR}/bin:${_GUILE_UDIR}/bin:${_REGEX_UDIR}/bin:${_AUTOTOOLS_UDIR}/bin:${AQBANKING_UPATH}:${_LIBOFX_UDIR}/bin:${_OPENSP_UDIR}/bin:${LIBGDA_DIR}/bin" \
                 gnucash
         qpopd
 
@@ -1035,7 +1062,7 @@
     # Create a startup script that works without the msys shell
     qpushd $_INSTALL_UDIR/bin
         echo "setlocal" > gnucash.bat
-        echo "set PATH=${INSTALL_DIR}\\bin;${INSTALL_DIR}\\lib;${INSTALL_DIR}\\lib\\gnucash;${GOFFICE_DIR}\\bin;${LIBGSF_DIR}\\bin;${PCRE_DIR}\\bin;${GNOME_DIR}\\bin;${LIBXML2_DIR}\\bin;${GUILE_DIR}\\bin;${REGEX_DIR}\\bin;${AUTOTOOLS_DIR}\\bin;${AQBANKING_PATH};${LIBOFX_DIR}\\bin;${OPENSP_DIR}\\bin;%PATH%" >> gnucash.bat
+        echo "set PATH=${INSTALL_DIR}\\bin;${INSTALL_DIR}\\lib;${INSTALL_DIR}\\lib\\gnucash;${GOFFICE_DIR}\\bin;${LIBGSF_DIR}\\bin;${PCRE_DIR}\\bin;${GNOME_DIR}\\bin;${LIBXML2_DIR}\\bin;${GUILE_DIR}\\bin;${REGEX_DIR}\\bin;${AUTOTOOLS_DIR}\\bin;${AQBANKING_PATH};${LIBOFX_DIR}\\bin;${OPENSP_DIR}\\bin;${LIBGDA_DIR}\\bin;%PATH%" > gnucash.bat
         echo "set GUILE_WARN_DEPRECATED=no" >> gnucash.bat
         echo "set GNC_MODULE_PATH=${INSTALL_DIR}\\lib\\gnucash" >> gnucash.bat
         echo "set GUILE_LOAD_PATH=${INSTALL_DIR}\\share\\gnucash\\guile-modules;${INSTALL_DIR}\\share\\gnucash\\scm;%GUILE_LOAD_PATH%" >> gnucash.bat

Copied: gnucash/trunk/packaging/win32/libgda-3.1.2-patch.diff (from rev 17438, gnucash/branches/gda-dev2/packaging/win32/libgda-3.1.2-patch.diff)
===================================================================
--- gnucash/trunk/packaging/win32/libgda-3.1.2-patch.diff	                        (rev 0)
+++ gnucash/trunk/packaging/win32/libgda-3.1.2-patch.diff	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,4 @@
+31c31
+< #include <libgnomevfs/gnome-vfs-mime.h>
+---
+> #undef HAVE_GNOMEVFS

Copied: gnucash/trunk/packaging/win32/libgda-3.1.2-patch2.diff (from rev 17438, gnucash/branches/gda-dev2/packaging/win32/libgda-3.1.2-patch2.diff)
===================================================================
--- gnucash/trunk/packaging/win32/libgda-3.1.2-patch2.diff	                        (rev 0)
+++ gnucash/trunk/packaging/win32/libgda-3.1.2-patch2.diff	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,6 @@
+880,881c880,881
+< 		setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
+< 		setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+---
+> 		g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
+> 		g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);

Modified: gnucash/trunk/src/backend/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,3 +1,3 @@
 
-SUBDIRS = file ${SQL_DIR}
-DIST_SUBDIRS = file postgres
+SUBDIRS = file sql ${SQL_DIR} ${GDA_DIR} ${DBI_DIR}
+DIST_SUBDIRS = file sql ${SQL_DIR} ${GDA_DIR} ${DBI_DIR}

Copied: gnucash/trunk/src/backend/dbi (from rev 17438, gnucash/branches/gda-dev2/src/backend/dbi)


Property changes on: gnucash/trunk/src/backend/dbi
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in
.libs
.deps



Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.c	2008-07-30 01:08:07 UTC (rev 17438)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -540,6 +540,7 @@
 {
 	FILE* f;
 	gchar buf[50];
+	gint chars_read;
 
 	// BAD if the path is null
 	g_return_val_if_fail( path != NULL, FALSE );
@@ -553,7 +554,7 @@
 	}
 
 	// OK if file has the correct header
-	fread( buf, sizeof(buf), 1, f );
+	chars_read = fread( buf, sizeof(buf), 1, f );
 	fclose( f );
 	if( g_str_has_prefix( buf, "SQLite format 3" ) ) {
 		PINFO( "has SQLite format string -> DBI" );

Modified: gnucash/trunk/src/backend/file/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/file/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,8 +1,8 @@
 SUBDIRS = . test
 
 # Now a shared library AND a GModule
-lib_LTLIBRARIES = libgnc-backend-file-utils.la
-pkglib_LTLIBRARIES = libgncmod-backend-file.la
+lib_LTLIBRARIES = libgnc-backend-xml-utils.la
+pkglib_LTLIBRARIES = libgncmod-backend-xml.la
 
 AM_CFLAGS = \
   -I.. -I../.. \
@@ -16,7 +16,7 @@
   ${GLIB_CFLAGS} \
   ${GCONF_CFLAGS}
 
-libgnc_backend_file_utils_la_SOURCES = \
+libgnc_backend_xml_utils_la_SOURCES = \
   gnc-account-xml-v2.c \
   gnc-book-xml-v2.c \
   gnc-budget-xml-v2.c \
@@ -39,7 +39,7 @@
   sixtp-utils.c \
   sixtp.c
 
-libgncmod_backend_file_la_SOURCES = \
+libgncmod_backend_xml_la_SOURCES = \
   gnc-backend-file.c
 
 noinst_HEADERS = \
@@ -58,18 +58,18 @@
   sixtp-stack.h \
   sixtp-utils.h
 
-libgnc_backend_file_utils_la_LIBADD = \
+libgnc_backend_xml_utils_la_LIBADD = \
    ${GLIB_LIBS} ${GCONF_LIBS} ${LIBXML2_LIBS} \
    ${top_builddir}/src/engine/libgncmod-engine.la \
    ${top_builddir}/src/core-utils/libgnc-core-utils.la \
    ${QOF_LIBS}
 
-libgncmod_backend_file_la_LDFLAGS = -module -avoid-version
-libgncmod_backend_file_la_LIBADD = \
+libgncmod_backend_xml_la_LDFLAGS = -module -avoid-version
+libgncmod_backend_xml_la_LIBADD = \
    ${GLIB_LIBS} ${GCONF_LIBS} ${LIBXML2_LIBS} \
    ${top_builddir}/src/engine/libgncmod-engine.la \
    ${top_builddir}/src/core-utils/libgnc-core-utils.la \
-   libgnc-backend-file-utils.la \
+   libgnc-backend-xml-utils.la \
    ${QOF_LIBS}
 
-INCLUDES = -DG_LOG_DOMAIN=\"gnc.backend.file\"
+INCLUDES = -DG_LOG_DOMAIN=\"gnc.backend.xml\"

Modified: gnucash/trunk/src/backend/file/gnc-account-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-account-xml-v2.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/gnc-account-xml-v2.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -219,7 +219,8 @@
     struct account_pdata *pdata = act_pdata;
     gnc_commodity *ref;
 
-    ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
+//    ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
+    ref = dom_tree_to_commodity_ref(node, pdata->book);
     xaccAccountSetCommodity(pdata->account, ref);
 
     return TRUE;

Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,5 +1,5 @@
 /********************************************************************
- * gnc-backend-file.c: load and save data to files                  *
+ * gnc-backend-xml.c: load and save data to XML files               *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -18,8 +18,8 @@
  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
  * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
 \********************************************************************/
-/** @file gnc-backend-file.c
- *  @brief load and save data to files 
+/** @file gnc-backend-xml.c
+ *  @brief load and save data to XML files 
  *  @author Copyright (c) 2000 Gnumatic Inc.
  *  @author Copyright (c) 2002 Derek Atkins <warlord at MIT.EDU>
  *  @author Copyright (c) 2003 Linas Vepstas <linas at linas.org>
@@ -453,6 +453,12 @@
 	FILE *t;
 
 	if (!path) { return FALSE; }
+
+	// Since this can be called with "xml:" as a prefix, remove it if it exists
+	if( g_str_has_prefix( path, "xml:" ) ) {
+	    path += 4;
+	}
+
 	if (0 == safe_strcmp(path, QOF_STDOUT)) { return FALSE; }
 	t = g_fopen(path, "r");
 	if(!t) { PINFO (" new file"); return TRUE; }
@@ -462,7 +468,7 @@
 	if (sbuf.st_size == 0)    { PINFO (" empty file"); return TRUE; }
 	if(gnc_is_xml_data_file_v2(path, NULL)) { return TRUE; } 
 	else if(gnc_is_xml_data_file(path))     { return TRUE; } 
-	PINFO (" %s is not a gnc file", path);
+	PINFO (" %s is not a gnc XML file", path);
 	return FALSE;
 }	
 
@@ -854,6 +860,11 @@
 static void
 file_commit_edit (QofBackend *be, QofInstance *inst)
 {
+    if (qof_instance_get_dirty(inst) && qof_get_alt_dirty_mode() && 
+        !(qof_instance_get_infant(inst) && qof_instance_get_destroying(inst))) {
+      qof_collection_mark_dirty(qof_instance_get_collection(inst));
+      qof_book_mark_dirty(qof_instance_get_book(inst));
+    }
 #if BORKEN_FOR_NOW
     FileBackend *fbe = (FileBackend *) be;
     QofBook *book = gp;
@@ -1070,6 +1081,15 @@
         prov->provider_free = gnc_provider_free;
         prov->check_data_type = gnc_determine_file_type;
         qof_backend_register_provider (prov);
+
+        prov = g_new0 (QofBackendProvider, 1);
+        prov->provider_name = "GnuCash File Backend Version 2";
+        prov->access_method = "xml";
+        prov->partial_book_supported = FALSE;
+        prov->backend_new = gnc_backend_new;
+        prov->provider_free = gnc_provider_free;
+        prov->check_data_type = gnc_determine_file_type;
+        qof_backend_register_provider (prov);
 }
 
 /* ========================== END OF FILE ===================== */

Modified: gnucash/trunk/src/backend/file/gnc-backend-file.h
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,5 +1,5 @@
 /********************************************************************
- * gnc-backend-file.h: load and save data to files                  *
+ * gnc-backend-xml.h: load and save data to XML files               *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -28,8 +28,8 @@
  * restoring data to/from an ordinary Unix filesystem file.
  */
 
-#ifndef GNC_BACKEND_FILE_H_
-#define GNC_BACKEND_FILE_H_
+#ifndef GNC_BACKEND_XML_H_
+#define GNC_BACKEND_XML_H_
 
 #include "qof.h"
 #include <gmodule.h>
@@ -59,4 +59,4 @@
 G_MODULE_EXPORT void
 qof_backend_module_init(void);
 
-#endif /* GNC_BACKEND_FILE_H_ */
+#endif /* GNC_BACKEND_XML_H_ */

Modified: gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -787,6 +787,13 @@
                    pre-7/11/2001-CIT-change SX template Account was parsed [but
                    incorrectly]. */
                 if ( xaccAccountGetCommodity( acc ) == NULL ) {
+#if 1
+						gnc_commodity_table* table;
+
+						table = gnc_commodity_table_get_table( txd->book );
+						com = gnc_commodity_table_lookup( table,
+												"template", "template" );
+#else
                         /* FIXME: This should first look in the table of the
                            book, maybe? The right thing happens [WRT file
                            load/save] if we just _new all the time, but it
@@ -798,6 +805,7 @@
                                                  "template", "template",
                                                  "template", "template",
                                                  1 );
+#endif
                         xaccAccountSetCommodity( acc, com );
                 }
 

Copied: gnucash/trunk/src/backend/file/gncmod-backend-xml.c (from rev 17438, gnucash/branches/gda-dev2/src/backend/file/gncmod-backend-xml.c)
===================================================================
--- gnucash/trunk/src/backend/file/gncmod-backend-xml.c	                        (rev 0)
+++ gnucash/trunk/src/backend/file/gncmod-backend-xml.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,65 @@
+/*********************************************************************
+ * gncmod-file-backend.c
+ * module definition/initialization for the file backend module
+ *
+ * Copyright (c) 2001 Linux Developers Group, Inc.
+ *********************************************************************/
+
+#include <stdio.h>
+#include <gmodule.h>
+/* #include <glib-gobject.h> */
+
+#include "gnc-module.h"
+#include "gnc-module-api.h"
+
+GNC_MODULE_API_DECL(libgncmod_backend_file)
+
+/* version of the gnc module system interface we require */
+int libgnc_backend_file_utils_gnc_module_system_interface = 0;
+
+/* module versioning uses libtool semantics. */
+int libgncmod_backend_file_gnc_module_current  = 0;
+int libgncmod_backend_file_gnc_module_revision = 0;
+int libgncmod_backend_file_gnc_module_age      = 0;
+
+static GNCModule engine;
+
+
+char *
+libgncmod_backend_file_gnc_module_path(void)
+{
+  return g_strdup("gnucash/backend/file");
+}
+
+char *
+libgncmod_backend_file_gnc_module_description(void)
+{
+  return g_strdup("The binary and XML (v1 and v2) backends for GnuCash");
+}
+
+int
+libgncmod_backend_file_gnc_module_init(int refcount)
+{
+  engine = gnc_module_load("gnucash/engine", 0);
+  if(!engine) return FALSE;
+
+  /* Need to initialize g-type engine for gconf */
+  if (refcount == 0)
+    g_type_init();
+
+  return TRUE;
+}
+
+int
+libgncmod_backend_file_gnc_module_end(int refcount)
+{
+  int unload = TRUE;
+
+  if (engine)
+    unload = libgnc_backend_file_utils_gnc_module_unload(engine);
+
+  if (refcount == 0)
+    engine = NULL;
+
+  return unload;
+}

Modified: gnucash/trunk/src/backend/file/test/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/file/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,3 +1,4 @@
+#
 SUBDIRS = test-files
 
 test_date_converting_SOURCES = \
@@ -27,7 +28,7 @@
   ${top_srcdir}/src/backend/file/sixtp-to-dom-parser.c \
   test-kvp-frames.c
 
-# the file backend is now a GModule - this test does
+# the xml backend is now a GModule - this test does
 # not load it as a module and cannot link to it
 # and remain portable.
 
@@ -249,4 +250,4 @@
   test-real-data.sh \
   test-xml2-is-file.c
 
-INCLUDES = -DG_LOG_DOMAIN=\"gnc.backend.file\"
+INCLUDES = -DG_LOG_DOMAIN=\"gnc.backend.xml\"

Modified: gnucash/trunk/src/backend/file/test/test-load-backend.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-load-backend.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/test/test-load-backend.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -30,7 +30,7 @@
 #include "cashobjects.h"
 #include "test-stuff.h"
 
-#define GNC_LIB_NAME "gncmod-backend-file"
+#define GNC_LIB_NAME "gncmod-backend-xml"
 
 int main (int argc, char ** argv)
 {
@@ -38,7 +38,7 @@
     cashobjects_register();
     do_test(
         qof_load_backend_library ("../.libs/", GNC_LIB_NAME),
-        " loading gnc-backend-file GModule failed");
+        " loading gnc-backend-xml GModule failed");
     print_test_results();
     qof_close();
     exit(get_rv());

Modified: gnucash/trunk/src/backend/file/test/test-load-xml2.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-load-xml2.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/file/test/test-load-xml2.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -47,7 +47,7 @@
 #include "test-engine-stuff.h"
 #include "test-file-stuff.h"
 
-#define GNC_LIB_NAME "gncmod-backend-file"
+#define GNC_LIB_NAME "gncmod-backend-xml"
 
 static void
 remove_files_pattern(const char *begining, const char *ending)
@@ -112,7 +112,7 @@
     qof_init();
     cashobjects_register();
     do_test(qof_load_backend_library ("../.libs/", GNC_LIB_NAME),
-            " loading gnc-backend-file GModule failed");
+            " loading gnc-backend-xml GModule failed");
 
     if (!location)
     {

Modified: gnucash/trunk/src/backend/postgres/test/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/postgres/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/backend/postgres/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -7,7 +7,7 @@
   --gnc-module-dir ${top_builddir}/src/gnc-module \
   --gnc-module-dir ${top_builddir}/src/engine \
   --guile-load-dir ${top_srcdir}/src/engine \
-  --gnc-module-dir ${top_builddir}/src/backend/file \
+  --gnc-module-dir ${top_builddir}/src/backend/xml \
   --gnc-module-dir ${top_builddir}/src/backend/postgres
 
 TESTS_ENVIRONMENT := \

Copied: gnucash/trunk/src/backend/sql (from rev 17438, gnucash/branches/gda-dev2/src/backend/sql)


Property changes on: gnucash/trunk/src/backend/sql
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in
.deps
.libs
*.lo




Property changes on: gnucash/trunk/src/bin
___________________________________________________________________
Name: svn:ignore
   - .deps
.libs
*.diff
*.diffs
*.patch
*.log
*.xac.*.xac
Makefile
Makefile.in
gnucash
gnucash-bin
gnucash-env
gnucash-make-guids
gnucash-run-script
gnucash-valgrind
strsub
update-gnucash-gconf
semantic.cache
i18n.h
TAGS
*.exe

   + .deps
.libs
*.diff
*.diffs
*.patch
*.log
*.xac.*.xac
Makefile
Makefile.in
gnucash
gnucash-bin
gnucash-gdb
gnucash-env
gnucash-make-guids
gnucash-run-script
gnucash-valgrind
strsub
update-gnucash-gconf
semantic.cache
i18n.h
TAGS
*.exe


Modified: gnucash/trunk/src/bin/Makefile.am
===================================================================
--- gnucash/trunk/src/bin/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/bin/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -32,6 +32,7 @@
 	rm -f $@.tmp
 	sed < $< > $@.tmp \
 	    -e 's#@-BIN_DIR-@#${bindir}#g' \
+		-e 's#@-GNC_DBD_DIR-@#${GNC_DBD_DIR}#g' \
 	    -e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \
 	    -e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \
             -e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \
@@ -40,10 +41,24 @@
 	mv $@.tmp $@
 	chmod u+x $@
 
+gnucash-gdb: gnucash-gdb.in ${top_builddir}/config.status Makefile
+	rm -f $@.tmp
+	sed < $< > $@.tmp \
+	    -e 's#@-BIN_DIR-@#${bindir}#g' \
+		-e 's#@-GNC_DBD_DIR-@#${GNC_DBD_DIR}#g' \
+	    -e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \
+	    -e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \
+            -e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \
+            -e 's#@-GNC_PKGLIB_INSTALLDIR-@#${pkglibdir}#g' \
+	    -e "s#@-TOP_SRC_DIR-@#`pwd`/${top_srcdir}#g"
+	mv $@.tmp $@
+	chmod u+x $@
+
 gnucash-valgrind: gnucash-valgrind.in ${top_builddir}/config.status Makefile
 	rm -f $@.tmp
 	sed < $< > $@.tmp \
 	    -e 's#@-BIN_DIR-@#${bindir}#g' \
+		-e 's#@-GNC_DBD_DIR-@#${GNC_DBD_DIR}#g' \
 	    -e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \
 	    -e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \
             -e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \
@@ -52,7 +67,7 @@
 	mv $@.tmp $@
 	chmod u+x $@
 
-CLEANFILES = $(BUILT_SOURCES) gnucash gnucash-valgrind
+CLEANFILES = $(BUILT_SOURCES) gnucash gnucash-valgrind gnucash-gdb
 
 # We handle gnucash scripts in a somewhat unexpected way, but we do
 # this so that a user who doesn't necessarily have the right
@@ -71,13 +86,13 @@
 # by these top-level "common" scripts.
 gnc_common_scripts = gnucash-env gnucash-make-guids
 
-bin_SCRIPTS = ${gnc_common_scripts} update-gnucash-gconf gnucash gnucash-valgrind
+bin_SCRIPTS = ${gnc_common_scripts} update-gnucash-gconf gnucash gnucash-valgrind gnucash-gdb
 
 # if you change gncoverridedir, make sure you change ./overrides/Makefile.am too.
 gncoverridesdir = ${GNC_LIBEXECDIR}/overrides
 
 EXTRA_DIST = generate-gnc-script update-gnucash-gconf.in \
-	gnucash.in gnucash-valgrind.in
+	gnucash.in gnucash-valgrind.in gnucash-gdb.in
 
 ## Gnucash scripts -- real code is in overrides, these just get you there.
 ${gnc_common_scripts}: generate-gnc-script ${top_builddir}/config.status

Copied: gnucash/trunk/src/bin/gnucash-gdb.in (from rev 17438, gnucash/branches/gda-dev2/src/bin/gnucash-gdb.in)
===================================================================
--- gnucash/trunk/src/bin/gnucash-gdb.in	                        (rev 0)
+++ gnucash/trunk/src/bin/gnucash-gdb.in	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+PATH="@-BIN_DIR-@:${PATH}"
+export PATH
+
+GUILE_WARN_DEPRECATED="no"
+export GUILE_WARN_DEPRECATED
+
+GNC_MODULE_PATH="@-GNC_PKGLIB_INSTALLDIR-@:${GNC_MODULE_PATH}"
+
+EXTRA_PATH="${EXTRA_PATH}:@-GNC_GUILE_MODULE_DIR-@"
+EXTRA_PATH="${EXTRA_PATH}:@-GNC_SCM_INSTALL_DIR-@"
+GUILE_LOAD_PATH="${EXTRA_PATH}:${GUILE_LOAD_PATH}"
+
+EXTRA_LIBS="${GNC_MODULE_PATH}"
+EXTRA_LIBS="${EXTRA_LIBS}:@-GNC_LIB_INSTALLDIR-@"
+EXTRA_LIBS="${EXTRA_LIBS}:@-GNC_PKGLIB_INSTALLDIR-@"
+
+LD_LIBRARY_PATH="${EXTRA_LIBS}:${LD_LIBRARY_PATH}"
+TOP_SRC_DIR="@-TOP_SRC_DIR-@"
+GNC_DBD_DIR="@-GNC_DBD_DIR-@"
+
+export GNC_MODULE_PATH
+export GUILE_LOAD_PATH
+export LD_LIBRARY_PATH
+export GNC_DBD_DIR
+
+#
+# Other potentially useful options, particularly for valgrind-2.x:
+# --tool=memcheck --trace-children=yes
+#
+exec gdb gnucash-bin "$@"

Modified: gnucash/trunk/src/bin/gnucash-valgrind.in
===================================================================
--- gnucash/trunk/src/bin/gnucash-valgrind.in	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/bin/gnucash-valgrind.in	2008-08-01 16:02:07 UTC (rev 17444)
@@ -18,19 +18,25 @@
 
 LD_LIBRARY_PATH="${EXTRA_LIBS}:${LD_LIBRARY_PATH}"
 TOP_SRC_DIR="@-TOP_SRC_DIR-@"
+GNC_DBD_DIR="@-GNC_DBD_DIR-@"
 
 export GNC_MODULE_PATH
 export GUILE_LOAD_PATH
 export LD_LIBRARY_PATH
+export GNC_DBD_DIR
 
 #
 # Other potentially useful options, particularly for valgrind-2.x:
 # --tool=memcheck --trace-children=yes
 #
 exec valgrind -v \
-    --suppressions=${TOP_SRC_DIR}/src/valgrind-gnucash.supp  \
+    --suppressions=${TOP_SRC_DIR}/src/valgrind-gnucash.supp \
+    --suppressions=${TOP_SRC_DIR}/src/valgrind-glib.supp \
+    --suppressions=${TOP_SRC_DIR}/src/valgrind-libfontconfig.supp \
+    --suppressions=${TOP_SRC_DIR}/src/valgrind-libgda.supp \
+    --suppressions=${TOP_SRC_DIR}/src/valgrind-libguile.supp \
+	--num-callers=25 \
     --error-limit=no \
-    --tool=callgrind \
-    --instr-atstart=no \
-    --collect-atstart=no \
+    --tool=memcheck \
+	--leak-check=full \
     gnucash-bin "$@"

Modified: gnucash/trunk/src/bin/gnucash.in
===================================================================
--- gnucash/trunk/src/bin/gnucash.in	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/bin/gnucash.in	2008-08-01 16:02:07 UTC (rev 17444)
@@ -18,10 +18,12 @@
 
 LD_LIBRARY_PATH="${EXTRA_LIBS}@-PATH_SEPARATOR-@${LD_LIBRARY_PATH}"
 DYLD_LIBRARY_PATH="${EXTRA_LIBS}@-PATH_SEPARATOR-@${DYLD_LIBRARY_PATH}"
+GNC_DBD_DIR="@-GNC_DBD_DIR-@"
 
 export GNC_MODULE_PATH
 export GUILE_LOAD_PATH
 export LD_LIBRARY_PATH
 export DYLD_LIBRARY_PATH
+export GNC_DBD_DIR
 
 exec gnucash-bin "$@"

Modified: gnucash/trunk/src/business/business-core/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-core/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,4 +1,4 @@
-SUBDIRS = . test file
+SUBDIRS = . sql test file
 
 pkglib_LTLIBRARIES = libgncmod-business-core.la
 

Modified: gnucash/trunk/src/business/business-core/file/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-core/file/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/file/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,6 +1,6 @@
 SUBDIRS = .
 
-pkglib_LTLIBRARIES = libgncmod-business-backend-file.la
+pkglib_LTLIBRARIES = libgncmod-business-backend-xml.la
 
 AM_CFLAGS = \
   -I${top_srcdir}/src \
@@ -13,8 +13,8 @@
   ${QOF_CFLAGS} \
   ${GLIB_CFLAGS}
 
-libgncmod_business_backend_file_la_SOURCES = \
-  gncmod-business-backend-file.c \
+libgncmod_business_backend_xml_la_SOURCES = \
+  gncmod-business-backend-xml.c \
   gnc-address-xml-v2.c \
   gnc-bill-term-xml-v2.c \
   gnc-customer-xml-v2.c \
@@ -41,11 +41,11 @@
   gnc-vendor-xml-v2.h \
   xml-helpers.h
 
-libgncmod_business_backend_file_la_LDFLAGS = -module -avoid-version
+libgncmod_business_backend_xml_la_LDFLAGS = -module -avoid-version
 
-libgncmod_business_backend_file_la_LIBADD = \
+libgncmod_business_backend_xml_la_LIBADD = \
   ${top_builddir}/src/business/business-core/libgncmod-business-core.la \
-  ${top_builddir}/src/backend/file/libgnc-backend-file-utils.la \
+  ${top_builddir}/src/backend/file/libgnc-backend-xml-utils.la \
   ${top_builddir}/src/engine/libgncmod-engine.la \
   ${top_builddir}/src/gnc-module/libgnc-module.la \
   ${LIBXML2_LIBS} \

Copied: gnucash/trunk/src/business/business-core/file/gncmod-business-backend-xml.c (from rev 17438, gnucash/branches/gda-dev2/src/business/business-core/file/gncmod-business-backend-xml.c)
===================================================================
--- gnucash/trunk/src/business/business-core/file/gncmod-business-backend-xml.c	                        (rev 0)
+++ gnucash/trunk/src/business/business-core/file/gncmod-business-backend-xml.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,112 @@
+/*********************************************************************
+ * gncmod-business-backend-file.c
+ * module definition/initialization for the file backend module
+ *
+ * Copyright (c) 2002 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ *
+ *********************************************************************/
+
+#include "config.h"
+#include <gmodule.h>
+
+#include "gnc-module.h"
+#include "gnc-module-api.h"
+#include "gnc-engine.h"
+#include "io-gncxml-v2.h"
+
+#include "gnc-address-xml-v2.h"
+#include "gnc-bill-term-xml-v2.h"
+#include "gnc-customer-xml-v2.h"
+#include "gnc-employee-xml-v2.h"
+#include "gnc-entry-xml-v2.h"
+#include "gnc-invoice-xml-v2.h"
+#include "gnc-job-xml-v2.h"
+#include "gnc-order-xml-v2.h"
+#include "gnc-owner-xml-v2.h"
+#include "gnc-tax-table-xml-v2.h"
+#include "gnc-vendor-xml-v2.h"
+
+GNC_MODULE_API_DECL(libgncmod_business_backend_xml)
+
+/* version of the gnc module system interface we require */
+int libgncmod_business_backend_xml_gnc_module_system_interface = 0;
+
+/* module versioning uses libtool semantics. */
+int libgncmod_business_backend_xml_gnc_module_current  = 0;
+int libgncmod_business_backend_xml_gnc_module_revision = 0;
+int libgncmod_business_backend_xml_gnc_module_age      = 0;
+
+static GNCModule bus_core;
+static GNCModule file;
+
+
+char *
+libgncmod_business_backend_xml_gnc_module_path(void)
+{
+  return g_strdup("gnucash/business-core-xml");
+}
+
+char *
+libgncmod_business_backend_xml_gnc_module_description(void)
+{
+  return g_strdup("The XML (v2) parsers for GnuCash business objects");
+}
+
+int
+libgncmod_business_backend_xml_gnc_module_init(int refcount)
+{
+  if(!gnc_engine_is_initialized()) { return FALSE; }
+
+  bus_core = gnc_module_load("gnucash/business-core", 0);
+  if(!bus_core) return FALSE;
+
+  if (refcount == 0) {
+    /* Initialize our pointers into the backend subsystem */
+    gnc_address_xml_initialize ();
+    gnc_billterm_xml_initialize ();
+    gnc_customer_xml_initialize ();
+    gnc_employee_xml_initialize ();
+    gnc_entry_xml_initialize ();
+    gnc_invoice_xml_initialize ();
+    gnc_job_xml_initialize ();
+    gnc_order_xml_initialize ();
+    gnc_owner_xml_initialize ();
+    gnc_taxtable_xml_initialize ();
+    gnc_vendor_xml_initialize ();
+  }
+
+  return TRUE;
+}
+
+int
+libgncmod_business_backend_xml_gnc_module_end(int refcount)
+{
+  int unload = TRUE;
+
+  if (bus_core)
+    unload = gnc_module_unload(bus_core);
+
+  if (refcount == 0) {
+    bus_core = NULL;
+    file = NULL;
+  }
+
+  return unload;
+}

Modified: gnucash/trunk/src/business/business-core/gncAddress.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncAddress.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncAddress.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -127,7 +127,7 @@
 }
 
 static QofInstance*
-qofAddressGetOwner(GncAddress *addr)
+qofAddressGetOwner(const GncAddress *addr)
 {
 
 	if(!addr) { return NULL; }
@@ -135,7 +135,7 @@
 }
 
 GncAddress * 
-gncCloneAddress (GncAddress *from, QofInstance *new_parent, QofBook *book)
+gncCloneAddress (const GncAddress *from, QofInstance *new_parent, QofBook *book)
 {
   GncAddress *addr;
 

Modified: gnucash/trunk/src/business/business-core/gncAddressP.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncAddressP.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncAddressP.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -33,7 +33,7 @@
 gboolean gncAddressRegister (void);
 
 /** Make a copy of the address, setting the parent to 'new_parent' */
-GncAddress * gncCloneAddress (GncAddress *from, QofInstance *new_parent, QofBook *book);
+GncAddress * gncCloneAddress (const GncAddress *from, QofInstance *new_parent, QofBook *book);
 
 
 #endif /* GNC_ADDRESSP_H_ */

Modified: gnucash/trunk/src/business/business-core/gncBillTerm.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncBillTerm.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncBillTerm.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -367,7 +367,9 @@
   if (parent)
     gncBillTermAddChild(parent, term);
   term->refcount = 0;
-  gncBillTermMakeInvisible (term);
+  if( parent != NULL ) {
+    gncBillTermMakeInvisible (term);
+  }
   gncBillTermCommitEdit (term);
 }
 
@@ -467,19 +469,19 @@
   return bi->terms;
 }
 
-const char *gncBillTermGetName (GncBillTerm *term)
+const char *gncBillTermGetName (const GncBillTerm *term)
 {
   if (!term) return NULL;
   return term->name;
 }
 
-const char *gncBillTermGetDescription (GncBillTerm *term)
+const char *gncBillTermGetDescription (const GncBillTerm *term)
 {
   if (!term) return NULL;
   return term->desc;
 }
 
-GncBillTermType gncBillTermGetType (GncBillTerm *term)
+GncBillTermType gncBillTermGetType (const GncBillTerm *term)
 {
   if (!term) return 0;
   return term->type;
@@ -489,37 +491,37 @@
 AS_STRING_FUNC(GncBillTermType, ENUM_TERMS_TYPE)
 
 static
-const char* qofBillTermGetType (GncBillTerm *term)
+const char* qofBillTermGetType (const GncBillTerm *term)
 {
 	if (!term) { return NULL; }
 	return GncBillTermTypeasString(term->type);
 }
 
-gint gncBillTermGetDueDays (GncBillTerm *term)
+gint gncBillTermGetDueDays (const GncBillTerm *term)
 {
   if (!term) return 0;
   return term->due_days;
 }
 
-gint gncBillTermGetDiscountDays (GncBillTerm *term)
+gint gncBillTermGetDiscountDays (const GncBillTerm *term)
 {
   if (!term) return 0;
   return term->disc_days;
 }
 
-gnc_numeric gncBillTermGetDiscount (GncBillTerm *term)
+gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term)
 {
   if (!term) return gnc_numeric_zero ();
   return term->discount;
 }
 
-gint gncBillTermGetCutoff (GncBillTerm *term)
+gint gncBillTermGetCutoff (const GncBillTerm *term)
 {
   if (!term) return 0;
   return term->cutoff;
 }
 
-static GncBillTerm *gncBillTermCopy (GncBillTerm *term)
+static GncBillTerm *gncBillTermCopy (const GncBillTerm *term)
 {
   GncBillTerm *t;
 
@@ -557,25 +559,25 @@
   return child;
 }
 
-GncBillTerm *gncBillTermGetParent (GncBillTerm *term)
+GncBillTerm *gncBillTermGetParent (const GncBillTerm *term)
 {
   if (!term) return NULL;
   return term->parent;
 }
 
-gint64 gncBillTermGetRefcount (GncBillTerm *term)
+gint64 gncBillTermGetRefcount (const GncBillTerm *term)
 {
   if (!term) return 0;
   return term->refcount;
 }
 
-gboolean gncBillTermGetInvisible (GncBillTerm *term)
+gboolean gncBillTermGetInvisible (const GncBillTerm *term)
 {
   if (!term) return FALSE;
   return term->invisible;
 }
 
-int gncBillTermCompare (GncBillTerm *a, GncBillTerm *b)
+int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b)
 {
   int ret;
 
@@ -589,7 +591,7 @@
   return safe_strcmp (a->desc, b->desc);
 }
 
-gboolean gncBillTermIsDirty (GncBillTerm *term)
+gboolean gncBillTermIsDirty (const GncBillTerm *term)
 {
   if (!term) return FALSE;
   return qof_instance_get_dirty_flag(term);
@@ -605,7 +607,7 @@
  * XXX explain this, the logic is totally opaque to me.
  */
 static void
-compute_monthyear (GncBillTerm *term, Timespec post_date,
+compute_monthyear (const GncBillTerm *term, Timespec post_date,
                    int *month, int *year)
 {
   int iday, imonth, iyear;
@@ -638,7 +640,7 @@
 /* XXX explain this, the logic is totally opaque to me. */
 
 static Timespec
-compute_time (GncBillTerm *term, Timespec post_date, int days)
+compute_time (const GncBillTerm *term, Timespec post_date, int days)
 {
   Timespec res = post_date;
   int day, month, year;
@@ -659,7 +661,7 @@
 }
 
 Timespec
-gncBillTermComputeDueDate (GncBillTerm *term, Timespec post_date)
+gncBillTermComputeDueDate (const GncBillTerm *term, Timespec post_date)
 {
   Timespec res = post_date;
   if (!term) return res;
@@ -668,7 +670,7 @@
 }
 
 Timespec
-gncBillTermComputeDiscountDate (GncBillTerm *term, Timespec post_date)
+gncBillTermComputeDiscountDate (const GncBillTerm *term, Timespec post_date)
 {
   Timespec res = post_date;
   if (!term) return res;

Modified: gnucash/trunk/src/business/business-core/gncBillTerm.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncBillTerm.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncBillTerm.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -124,30 +124,30 @@
 GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
 GList * gncBillTermGetTerms (QofBook *book);
 
-const char *gncBillTermGetName (GncBillTerm *term);
-const char *gncBillTermGetDescription (GncBillTerm *term);
-GncBillTermType gncBillTermGetType (GncBillTerm *term);
-gint gncBillTermGetDueDays (GncBillTerm *term);
-gint gncBillTermGetDiscountDays (GncBillTerm *term);
-gnc_numeric gncBillTermGetDiscount (GncBillTerm *term);
-gint gncBillTermGetCutoff (GncBillTerm *term);
+const char *gncBillTermGetName (const GncBillTerm *term);
+const char *gncBillTermGetDescription (const GncBillTerm *term);
+GncBillTermType gncBillTermGetType (const GncBillTerm *term);
+gint gncBillTermGetDueDays (const GncBillTerm *term);
+gint gncBillTermGetDiscountDays (const GncBillTerm *term);
+gnc_numeric gncBillTermGetDiscount (const GncBillTerm *term);
+gint gncBillTermGetCutoff (const GncBillTerm *term);
 
-gboolean gncBillTermIsDirty (GncBillTerm *term);
+gboolean gncBillTermIsDirty (const GncBillTerm *term);
 
-GncBillTerm *gncBillTermGetParent (GncBillTerm *term);
+GncBillTerm *gncBillTermGetParent (const GncBillTerm *term);
 GncBillTerm *gncBillTermReturnChild (GncBillTerm *term, gboolean make_new);
 #define gncBillTermGetChild(t) gncBillTermReturnChild((t),FALSE)
-gint64 gncBillTermGetRefcount (GncBillTerm *term);
+gint64 gncBillTermGetRefcount (const GncBillTerm *term);
 /** @} */
 
-int gncBillTermCompare (GncBillTerm *a, GncBillTerm *b);
+int gncBillTermCompare (const GncBillTerm *a, const GncBillTerm *b);
 
 /********************************************************/
 /* functions to compute dates from Bill Terms           */
 
 /* Compute the due date and discount dates from the post date */
-Timespec gncBillTermComputeDueDate (GncBillTerm *term, Timespec post_date);
-Timespec gncBillTermComputeDiscountDate (GncBillTerm *term, Timespec post_date);
+Timespec gncBillTermComputeDueDate (const GncBillTerm *term, Timespec post_date);
+Timespec gncBillTermComputeDiscountDate (const GncBillTerm *term, Timespec post_date);
 
 /* deprecated */
 #define gncBillTermGetGUID(x) qof_instance_get_guid (QOF_INSTANCE(x))

Modified: gnucash/trunk/src/business/business-core/gncBillTermP.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncBillTermP.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncBillTermP.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -38,7 +38,7 @@
 void gncBillTermSetRefcount (GncBillTerm *term, gint64 refcount);
 void gncBillTermMakeInvisible (GncBillTerm *term);
 
-gboolean gncBillTermGetInvisible (GncBillTerm *term);
+gboolean gncBillTermGetInvisible (const GncBillTerm *term);
 
 /** The gncCloneBillTerm() routine makes a copy of the indicated
  *  bill term, placing it in the indicated book.  It copies

Modified: gnucash/trunk/src/business/business-core/gncCustomer.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncCustomer.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncCustomer.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -418,19 +418,19 @@
 /* ============================================================== */
 /* Get Functions */
 
-const char * gncCustomerGetID (GncCustomer *cust)
+const char * gncCustomerGetID (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->id;
 }
 
-const char * gncCustomerGetName (GncCustomer *cust)
+const char * gncCustomerGetName (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->name;
 }
 
-GncAddress * gncCustomerGetAddr (GncCustomer *cust)
+GncAddress * gncCustomerGetAddr (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->addr;
@@ -470,67 +470,67 @@
 	gncCustomerCommitEdit(cust);
 }
 
-GncAddress * gncCustomerGetShipAddr (GncCustomer *cust)
+GncAddress * gncCustomerGetShipAddr (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->shipaddr;
 }
 
-const char * gncCustomerGetNotes (GncCustomer *cust)
+const char * gncCustomerGetNotes (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->notes;
 }
 
-GncBillTerm * gncCustomerGetTerms (GncCustomer *cust)
+GncBillTerm * gncCustomerGetTerms (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->terms;
 }
 
-GncTaxIncluded gncCustomerGetTaxIncluded (GncCustomer *cust)
+GncTaxIncluded gncCustomerGetTaxIncluded (const GncCustomer *cust)
 {
   if (!cust) return GNC_TAXINCLUDED_USEGLOBAL;
   return cust->taxincluded;
 }
 
-gnc_commodity * gncCustomerGetCurrency (GncCustomer *cust)
+gnc_commodity * gncCustomerGetCurrency (const GncCustomer *cust)
 {
   if (!cust) return NULL;
   return cust->currency;
 }
 
-gboolean gncCustomerGetActive (GncCustomer *cust)
+gboolean gncCustomerGetActive (const GncCustomer *cust)
 {
   if (!cust) return FALSE;
   return cust->active;
 }
 
-gnc_numeric gncCustomerGetDiscount (GncCustomer *cust)
+gnc_numeric gncCustomerGetDiscount (const GncCustomer *cust)
 {
   if (!cust) return gnc_numeric_zero();
   return cust->discount;
 }
 
-gnc_numeric gncCustomerGetCredit (GncCustomer *cust)
+gnc_numeric gncCustomerGetCredit (const GncCustomer *cust)
 {
   if (!cust) return gnc_numeric_zero();
   return cust->credit;
 }
 
-gboolean gncCustomerGetTaxTableOverride (GncCustomer *customer)
+gboolean gncCustomerGetTaxTableOverride (const GncCustomer *customer)
 {
   if (!customer) return FALSE;
   return customer->taxtable_override;
 }
 
-GncTaxTable* gncCustomerGetTaxTable (GncCustomer *customer)
+GncTaxTable* gncCustomerGetTaxTable (const GncCustomer *customer)
 {
   if (!customer) return NULL;
   return customer->taxtable;
 }
 
-GList * gncCustomerGetJoblist (GncCustomer *cust, gboolean show_all)
+GList * gncCustomerGetJoblist (const GncCustomer *cust, gboolean show_all)
 {
   if (!cust) return NULL;
 
@@ -557,7 +557,7 @@
 
 /* Other functions */
 
-int gncCustomerCompare (GncCustomer *a, GncCustomer *b)
+int gncCustomerCompare (const GncCustomer *a, const GncCustomer *b)
 {
   if (!a && !b) return 0;
   if (!a && b) return 1;

Modified: gnucash/trunk/src/business/business-core/gncCustomer.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncCustomer.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncCustomer.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -118,26 +118,26 @@
 #define gncCustomerLookup(book,guid)    \
        QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_CUSTOMER, GncCustomer)
 
-const char * gncCustomerGetID (GncCustomer *customer);
-const char * gncCustomerGetName (GncCustomer *customer);
-GncAddress * gncCustomerGetAddr (GncCustomer *customer);
-GncAddress * gncCustomerGetShipAddr (GncCustomer *customer);
-const char * gncCustomerGetNotes (GncCustomer *customer);
-GncBillTerm * gncCustomerGetTerms (GncCustomer *customer);
-GncTaxIncluded gncCustomerGetTaxIncluded (GncCustomer *customer);
-gboolean gncCustomerGetActive (GncCustomer *customer);
-gnc_numeric gncCustomerGetDiscount (GncCustomer *customer);
-gnc_numeric gncCustomerGetCredit (GncCustomer *customer);
-gnc_commodity * gncCustomerGetCurrency (GncCustomer *customer);
+const char * gncCustomerGetID (const GncCustomer *customer);
+const char * gncCustomerGetName (const GncCustomer *customer);
+GncAddress * gncCustomerGetAddr (const GncCustomer *customer);
+GncAddress * gncCustomerGetShipAddr (const GncCustomer *customer);
+const char * gncCustomerGetNotes (const GncCustomer *customer);
+GncBillTerm * gncCustomerGetTerms (const GncCustomer *customer);
+GncTaxIncluded gncCustomerGetTaxIncluded (const GncCustomer *customer);
+gboolean gncCustomerGetActive (const GncCustomer *customer);
+gnc_numeric gncCustomerGetDiscount (const GncCustomer *customer);
+gnc_numeric gncCustomerGetCredit (const GncCustomer *customer);
+gnc_commodity * gncCustomerGetCurrency (const GncCustomer *customer);
 
-gboolean gncCustomerGetTaxTableOverride (GncCustomer *customer);
-GncTaxTable* gncCustomerGetTaxTable (GncCustomer *customer);
+gboolean gncCustomerGetTaxTableOverride (const GncCustomer *customer);
+GncTaxTable* gncCustomerGetTaxTable (const GncCustomer *customer);
 
-GList * gncCustomerGetJoblist (GncCustomer *customer, gboolean show_all);
+GList * gncCustomerGetJoblist (const GncCustomer *customer, gboolean show_all);
 /** @} */
 
 gboolean gncCustomerIsDirty (GncCustomer *customer);
-int gncCustomerCompare (GncCustomer *a, GncCustomer *b);
+int gncCustomerCompare (const GncCustomer *a, const GncCustomer *b);
 
 #define CUSTOMER_ID			"id"
 #define CUSTOMER_NAME		"name"

Modified: gnucash/trunk/src/business/business-core/gncEmployee.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncEmployee.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncEmployee.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -299,67 +299,67 @@
 
 /* ============================================================== */
 /* Get Functions */
-const char * gncEmployeeGetID (GncEmployee *employee)
+const char * gncEmployeeGetID (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->id;
 }
 
-const char * gncEmployeeGetUsername (GncEmployee *employee)
+const char * gncEmployeeGetUsername (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->username;
 }
 
-GncAddress * gncEmployeeGetAddr (GncEmployee *employee)
+GncAddress * gncEmployeeGetAddr (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->addr;
 }
 
-const char * gncEmployeeGetLanguage (GncEmployee *employee)
+const char * gncEmployeeGetLanguage (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->language;
 }
 
-const char * gncEmployeeGetAcl (GncEmployee *employee)
+const char * gncEmployeeGetAcl (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->acl;
 }
 
-gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee)
+gnc_numeric gncEmployeeGetWorkday (const GncEmployee *employee)
 {
   if (!employee) return gnc_numeric_zero();
   return employee->workday;
 }
 
-gnc_numeric gncEmployeeGetRate (GncEmployee *employee)
+gnc_numeric gncEmployeeGetRate (const GncEmployee *employee)
 {
   if (!employee) return gnc_numeric_zero();
   return employee->rate;
 }
 
-gnc_commodity * gncEmployeeGetCurrency (GncEmployee *employee)
+gnc_commodity * gncEmployeeGetCurrency (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->currency;
 }
 
-gboolean gncEmployeeGetActive (GncEmployee *employee)
+gboolean gncEmployeeGetActive (const GncEmployee *employee)
 {
   if (!employee) return FALSE;
   return employee->active;
 }
 
-Account * gncEmployeeGetCCard (GncEmployee *employee)
+Account * gncEmployeeGetCCard (const GncEmployee *employee)
 {
   if (!employee) return NULL;
   return employee->ccard_acc;
 }
 
-gboolean gncEmployeeIsDirty (GncEmployee *employee)
+gboolean gncEmployeeIsDirty (const GncEmployee *employee)
 {
   if (!employee) return FALSE;
   return (qof_instance_get_dirty_flag(employee)
@@ -399,7 +399,7 @@
 /* ============================================================== */
 /* Other functions */
 
-int gncEmployeeCompare (GncEmployee *a, GncEmployee *b)
+int gncEmployeeCompare (const GncEmployee *a, const GncEmployee *b)
 {
   if (!a && !b) return 0;
   if (!a && b) return 1;

Modified: gnucash/trunk/src/business/business-core/gncEmployee.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncEmployee.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncEmployee.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -59,7 +59,7 @@
 void gncEmployeeDestroy (GncEmployee *employee);
 void gncEmployeeBeginEdit (GncEmployee *employee);
 void gncEmployeeCommitEdit (GncEmployee *employee);
-int gncEmployeeCompare (GncEmployee *a, GncEmployee *b);
+int gncEmployeeCompare (const GncEmployee *a, const GncEmployee *b);
 /** @} */
 
 /** @name Set Functions 
@@ -80,16 +80,16 @@
 /** @name Get Functions 
  @{ */
 QofBook * gncEmployeeGetBook (GncEmployee *employee);
-const char * gncEmployeeGetID (GncEmployee *employee);
-const char * gncEmployeeGetUsername (GncEmployee *employee);
-GncAddress * gncEmployeeGetAddr (GncEmployee *employee);
-const char * gncEmployeeGetLanguage (GncEmployee *employee);
-const char * gncEmployeeGetAcl (GncEmployee *employee);
-gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee);
-gnc_numeric gncEmployeeGetRate (GncEmployee *employee);
-gnc_commodity * gncEmployeeGetCurrency (GncEmployee *employee);
-gboolean gncEmployeeGetActive (GncEmployee *employee);
-Account * gncEmployeeGetCCard (GncEmployee *employee);
+const char * gncEmployeeGetID (const GncEmployee *employee);
+const char * gncEmployeeGetUsername (const GncEmployee *employee);
+GncAddress * gncEmployeeGetAddr (const GncEmployee *employee);
+const char * gncEmployeeGetLanguage (const GncEmployee *employee);
+const char * gncEmployeeGetAcl (const GncEmployee *employee);
+gnc_numeric gncEmployeeGetWorkday (const GncEmployee *employee);
+gnc_numeric gncEmployeeGetRate (const GncEmployee *employee);
+gnc_commodity * gncEmployeeGetCurrency (const GncEmployee *employee);
+gboolean gncEmployeeGetActive (const GncEmployee *employee);
+Account * gncEmployeeGetCCard (const GncEmployee *employee);
 /** @} */
 
 
@@ -102,7 +102,7 @@
 #define gncEmployeeLookup(book,guid)    \
        QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_EMPLOYEE, GncEmployee)
 
-gboolean gncEmployeeIsDirty (GncEmployee *employee);
+gboolean gncEmployeeIsDirty (const GncEmployee *employee);
 
 #define EMPLOYEE_ID			"id"
 #define EMPLOYEE_USERNAME	"username"

Modified: gnucash/trunk/src/business/business-core/gncEntry.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncEntry.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncEntry.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -658,39 +658,39 @@
 /* ================================================================ */
 /* Get Functions */
 
-Timespec gncEntryGetDate (GncEntry *entry)
+Timespec gncEntryGetDate (const GncEntry *entry)
 {
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!entry) return ts;
   return entry->date;
 }
 
-Timespec gncEntryGetDateEntered (GncEntry *entry)
+Timespec gncEntryGetDateEntered (const GncEntry *entry)
 {
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!entry) return ts;
   return entry->date_entered;
 }
 
-const char * gncEntryGetDescription (GncEntry *entry)
+const char * gncEntryGetDescription (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->desc;
 }
 
-const char * gncEntryGetAction (GncEntry *entry)
+const char * gncEntryGetAction (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->action;
 }
 
-const char * gncEntryGetNotes (GncEntry *entry)
+const char * gncEntryGetNotes (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->notes;
 }
 
-gnc_numeric gncEntryGetQuantity (GncEntry *entry)
+gnc_numeric gncEntryGetQuantity (const GncEntry *entry)
 {
   if (!entry) return gnc_numeric_zero();
   return entry->quantity;
@@ -698,37 +698,37 @@
 
 /* Customer Invoice */
 
-Account * gncEntryGetInvAccount (GncEntry *entry)
+Account * gncEntryGetInvAccount (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->i_account;
 }
 
-gnc_numeric gncEntryGetInvPrice (GncEntry *entry)
+gnc_numeric gncEntryGetInvPrice (const GncEntry *entry)
 {
   if (!entry) return gnc_numeric_zero();
   return entry->i_price;
 }
 
-gnc_numeric gncEntryGetInvDiscount (GncEntry *entry)
+gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry)
 {
   if (!entry) return gnc_numeric_zero();
   return entry->i_discount;
 }
 
-GncAmountType gncEntryGetInvDiscountType (GncEntry *entry)
+GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry)
 {
   if (!entry) return 0;
   return entry->i_disc_type;
 }
 
-GncDiscountHow gncEntryGetInvDiscountHow (GncEntry *entry)
+GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry)
 {
   if (!entry) return 0;
   return entry->i_disc_how;
 }
 
-char* qofEntryGetInvDiscType (GncEntry *entry)
+char* qofEntryGetInvDiscType (const GncEntry *entry)
 {
 	char *type_string;
 
@@ -737,7 +737,7 @@
 	return type_string;
 }
 
-char* qofEntryGetInvDiscHow (GncEntry *entry)
+char* qofEntryGetInvDiscHow (const GncEntry *entry)
 {
 	char *type_string;
 
@@ -746,19 +746,19 @@
 	return type_string;
 }
 
-gboolean gncEntryGetInvTaxable (GncEntry *entry)
+gboolean gncEntryGetInvTaxable (const GncEntry *entry)
 {
   if (!entry) return FALSE;
   return entry->i_taxable;
 }
 
-gboolean gncEntryGetInvTaxIncluded (GncEntry *entry)
+gboolean gncEntryGetInvTaxIncluded (const GncEntry *entry)
 {
   if (!entry) return FALSE;
   return entry->i_taxincluded;
 }
 
-GncTaxTable * gncEntryGetInvTaxTable (GncEntry *entry)
+GncTaxTable * gncEntryGetInvTaxTable (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->i_tax_table;
@@ -766,37 +766,37 @@
 
 /* vendor bills */
 
-Account * gncEntryGetBillAccount (GncEntry *entry)
+Account * gncEntryGetBillAccount (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->b_account;
 }
 
-gnc_numeric gncEntryGetBillPrice (GncEntry *entry)
+gnc_numeric gncEntryGetBillPrice (const GncEntry *entry)
 {
   if (!entry) return gnc_numeric_zero();
   return entry->b_price;
 }
 
-gboolean gncEntryGetBillTaxable (GncEntry *entry)
+gboolean gncEntryGetBillTaxable (const GncEntry *entry)
 {
   if (!entry) return FALSE;
   return entry->b_taxable;
 }
 
-gboolean gncEntryGetBillTaxIncluded (GncEntry *entry)
+gboolean gncEntryGetBillTaxIncluded (const GncEntry *entry)
 {
   if (!entry) return FALSE;
   return entry->b_taxincluded;
 }
 
-GncTaxTable * gncEntryGetBillTaxTable (GncEntry *entry)
+GncTaxTable * gncEntryGetBillTaxTable (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->b_tax_table;
 }
 
-gboolean gncEntryGetBillable (GncEntry *entry)
+gboolean gncEntryGetBillable (const GncEntry *entry)
 {
   if (!entry) return FALSE;
   return entry->billable;
@@ -808,25 +808,25 @@
   return &entry->billto;
 }
 
-GncEntryPaymentType gncEntryGetBillPayment (GncEntry* entry)
+GncEntryPaymentType gncEntryGetBillPayment (const GncEntry* entry)
 {
   if (!entry) return 0;
   return entry->b_payment;
 }
 
-GncInvoice * gncEntryGetInvoice (GncEntry *entry)
+GncInvoice * gncEntryGetInvoice (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->invoice;
 }
 
-GncInvoice * gncEntryGetBill (GncEntry *entry)
+GncInvoice * gncEntryGetBill (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->bill;
 }
 
-GncOrder * gncEntryGetOrder (GncEntry *entry)
+GncOrder * gncEntryGetOrder (const GncEntry *entry)
 {
   if (!entry) return NULL;
   return entry->order;
@@ -867,7 +867,7 @@
  * to let a consumer know how much they saved.
  */
 void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
-			   GncTaxTable *tax_table, gboolean tax_included,
+			   const GncTaxTable *tax_table, gboolean tax_included,
 			   gnc_numeric discount, GncAmountType discount_type,
 			   GncDiscountHow discount_how, int SCU,
 			   gnc_numeric *value, gnc_numeric *discount_value,
@@ -1044,7 +1044,7 @@
 }
 
 static int
-get_entry_commodity_denom (GncEntry *entry)
+get_entry_commodity_denom (const GncEntry *entry)
 {
   gnc_commodity *c;
   if (!entry)
@@ -1178,7 +1178,7 @@
 }
 
 /* XXXX this exsitnace of this routine is just wrong */
-gboolean gncEntryIsOpen (GncEntry *entry)
+gboolean gncEntryIsOpen (const GncEntry *entry)
 {
   if (!entry) return FALSE;
   return (qof_instance_get_editlevel(entry) > 0);
@@ -1211,7 +1211,7 @@
 			 gncEntryOnDone, entry_free);
 }
 
-int gncEntryCompare (GncEntry *a, GncEntry *b)
+int gncEntryCompare (const GncEntry *a, const GncEntry *b)
 {
   int compare;
 

Modified: gnucash/trunk/src/business/business-core/gncEntry.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncEntry.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncEntry.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -135,39 +135,39 @@
 /* GET FUNCTIONS */
 /** @name Generic (shared) data 
  @{ */
-Timespec gncEntryGetDate (GncEntry *entry);
-Timespec gncEntryGetDateEntered (GncEntry *entry);
-const char * gncEntryGetDescription (GncEntry *entry);
-const char * gncEntryGetAction (GncEntry *entry);
-const char * gncEntryGetNotes (GncEntry *notes);
-gnc_numeric gncEntryGetQuantity (GncEntry *entry);
+Timespec gncEntryGetDate (const GncEntry *entry);
+Timespec gncEntryGetDateEntered (const GncEntry *entry);
+const char * gncEntryGetDescription (const GncEntry *entry);
+const char * gncEntryGetAction (const GncEntry *entry);
+const char * gncEntryGetNotes (const GncEntry *notes);
+gnc_numeric gncEntryGetQuantity (const GncEntry *entry);
 /** @} */
 
 /** @name Customer Invoices 
  @{ */
-Account * gncEntryGetInvAccount (GncEntry *entry);
-gnc_numeric gncEntryGetInvPrice (GncEntry *entry);
-gnc_numeric gncEntryGetInvDiscount (GncEntry *entry);
-GncAmountType gncEntryGetInvDiscountType (GncEntry *entry);
-GncDiscountHow gncEntryGetInvDiscountHow (GncEntry *entry);
-char* qofEntryGetInvDiscType (GncEntry *entry);
-char* qofEntryGetInvDiscHow (GncEntry *entry);
-gboolean gncEntryGetInvTaxable (GncEntry *entry);
-gboolean gncEntryGetInvTaxIncluded (GncEntry *entry);
-GncTaxTable * gncEntryGetInvTaxTable (GncEntry *entry);
+Account * gncEntryGetInvAccount (const GncEntry *entry);
+gnc_numeric gncEntryGetInvPrice (const GncEntry *entry);
+gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry);
+GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry);
+GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry);
+char* qofEntryGetInvDiscType (const GncEntry *entry);
+char* qofEntryGetInvDiscHow (const GncEntry *entry);
+gboolean gncEntryGetInvTaxable (const GncEntry *entry);
+gboolean gncEntryGetInvTaxIncluded (const GncEntry *entry);
+GncTaxTable * gncEntryGetInvTaxTable (const GncEntry *entry);
 /** @} */
 
 /** @name Vendor Bills (and Employee Expenses) 
  @{ */
-Account * gncEntryGetBillAccount (GncEntry *entry);
-gnc_numeric gncEntryGetBillPrice (GncEntry *entry);
-gboolean gncEntryGetBillTaxable (GncEntry *entry);
-gboolean gncEntryGetBillTaxIncluded (GncEntry *entry);
-GncTaxTable * gncEntryGetBillTaxTable (GncEntry *entry);
-gboolean gncEntryGetBillable (GncEntry *entry);
+Account * gncEntryGetBillAccount (const GncEntry *entry);
+gnc_numeric gncEntryGetBillPrice (const GncEntry *entry);
+gboolean gncEntryGetBillTaxable (const GncEntry *entry);
+gboolean gncEntryGetBillTaxIncluded (const GncEntry *entry);
+GncTaxTable * gncEntryGetBillTaxTable (const GncEntry *entry);
+gboolean gncEntryGetBillable (const GncEntry *entry);
 GncOwner *gncEntryGetBillTo (GncEntry *entry);
 
-GncEntryPaymentType gncEntryGetBillPayment (GncEntry* entry);
+GncEntryPaymentType gncEntryGetBillPayment (const GncEntry* entry);
 /** @} */
 
 void gncEntryCopy (const GncEntry *src, GncEntry *dest);
@@ -201,7 +201,7 @@
 		       GList **tax_values);
 
 void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
-			   GncTaxTable *tax_table, gboolean tax_included,
+			   const GncTaxTable *tax_table, gboolean tax_included,
 			   gnc_numeric discount, GncAmountType discount_type,
 			   GncDiscountHow discount_how, int SCU,
 			   /* return values */
@@ -210,9 +210,9 @@
 
 /** @} */
 
-GncOrder * gncEntryGetOrder (GncEntry *entry);
-GncInvoice * gncEntryGetInvoice (GncEntry *entry);
-GncInvoice * gncEntryGetBill (GncEntry *entry);
+GncOrder * gncEntryGetOrder (const GncEntry *entry);
+GncInvoice * gncEntryGetInvoice (const GncEntry *entry);
+GncInvoice * gncEntryGetBill (const GncEntry *entry);
 
 /** Return a pointer to the instance gncEntry that is identified
  *  by the guid, and is residing in the book. Returns NULL if the 
@@ -223,10 +223,10 @@
 #define gncEntryLookup(book,guid)    \
        QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_ENTRY, GncEntry)
 
-gboolean gncEntryIsOpen (GncEntry *entry);
+gboolean gncEntryIsOpen (const GncEntry *entry);
 void gncEntryBeginEdit (GncEntry *entry);
 void gncEntryCommitEdit (GncEntry *entry);
-int gncEntryCompare (GncEntry *a, GncEntry *b);
+int gncEntryCompare (const GncEntry *a, const GncEntry *b);
 
 #define ENTRY_DATE			"date"
 #define ENTRY_DATE_ENTERED 	"date-entered"

Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -469,7 +469,7 @@
 /* ================================================================== */
 /* Get Functions */
 
-const char * gncInvoiceGetID (GncInvoice *invoice)
+const char * gncInvoiceGetID (const GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->id;
@@ -501,21 +501,21 @@
 	return QOF_INSTANCE(billto);
 }
 
-Timespec gncInvoiceGetDateOpened (GncInvoice *invoice)
+Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice)
 {
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!invoice) return ts;
   return invoice->date_opened;
 }
 
-Timespec gncInvoiceGetDatePosted (GncInvoice *invoice)
+Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice)
 {
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!invoice) return ts;
   return invoice->date_posted;
 }
 
-Timespec gncInvoiceGetDateDue (GncInvoice *invoice)
+Timespec gncInvoiceGetDateDue (const GncInvoice *invoice)
 {
   Transaction *txn;
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
@@ -525,19 +525,19 @@
   return xaccTransRetDateDueTS (txn);
 }
 
-GncBillTerm * gncInvoiceGetTerms (GncInvoice *invoice)
+GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice)
 {
-  if (!invoice) return 0;
+  if (!invoice) return NULL;
   return invoice->terms;
 }
 
-const char * gncInvoiceGetBillingID (GncInvoice *invoice)
+const char * gncInvoiceGetBillingID (const GncInvoice *invoice)
 {
-  if (!invoice) return 0;
+  if (!invoice) return NULL;
   return invoice->billing_id;
 }
 
-const char * gncInvoiceGetNotes (GncInvoice *invoice)
+const char * gncInvoiceGetNotes (const GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->notes;
@@ -629,7 +629,7 @@
   }
 }
 
-gnc_commodity * gncInvoiceGetCurrency (GncInvoice *invoice)
+gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->currency;
@@ -641,32 +641,32 @@
   return &invoice->billto;
 }
 
-GNCLot * gncInvoiceGetPostedLot (GncInvoice *invoice)
+GNCLot * gncInvoiceGetPostedLot (const GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->posted_lot;
 }
 
-Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice)
+Transaction * gncInvoiceGetPostedTxn (const GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->posted_txn;
 }
 
-Account * gncInvoiceGetPostedAcc (GncInvoice *invoice)
+Account * gncInvoiceGetPostedAcc (const GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->posted_acc;
 }
 
-gboolean gncInvoiceGetActive (GncInvoice *invoice)
+gboolean gncInvoiceGetActive (const GncInvoice *invoice)
 {
   if (!invoice) return FALSE;
   return invoice->active;
 }
 
 
-gnc_numeric gncInvoiceGetToChargeAmount (GncInvoice *invoice)
+gnc_numeric gncInvoiceGetToChargeAmount (const GncInvoice *invoice)
 {
   if (!invoice) return gnc_numeric_zero();
   return invoice->to_charge_amount;
@@ -724,7 +724,7 @@
 }
 
 static GncJob*
-qofInvoiceGetJob (GncInvoice *invoice)
+qofInvoiceGetJob (const GncInvoice *invoice)
 {
 	if(!invoice) { return NULL; }
 	return invoice->job;
@@ -806,7 +806,7 @@
 }
 
 GncInvoice * 
-gncInvoiceGetInvoiceFromTxn (Transaction *txn)
+gncInvoiceGetInvoiceFromTxn (const Transaction *txn)
 {
   KvpFrame *kvp;
   KvpValue *value;
@@ -1454,20 +1454,20 @@
   return txn;    
 }
 
-static gboolean gncInvoiceDateExists (Timespec *date)
+static gboolean gncInvoiceDateExists (const Timespec *date)
 {
   g_return_val_if_fail (date, FALSE);
   if (date->tv_sec || date->tv_nsec) return TRUE;
   return FALSE;
 }
 
-gboolean gncInvoiceIsPosted (GncInvoice *invoice)
+gboolean gncInvoiceIsPosted (const GncInvoice *invoice)
 {
   if (!invoice) return FALSE;
   return gncInvoiceDateExists (&(invoice->date_posted));
 }
 
-gboolean gncInvoiceIsPaid (GncInvoice *invoice)
+gboolean gncInvoiceIsPaid (const GncInvoice *invoice)
 {
   if (!invoice) return FALSE;
   if (!invoice->posted_lot) return FALSE;
@@ -1501,7 +1501,7 @@
 			 gncInvoiceOnDone, invoice_free);
 }
 
-int gncInvoiceCompare (GncInvoice *a, GncInvoice *b)
+int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b)
 {
   int compare;
 

Modified: gnucash/trunk/src/business/business-core/gncInvoice.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncInvoice.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -97,23 +97,23 @@
 
 /** @name Get Functions 
  @{ */
-const char * gncInvoiceGetID (GncInvoice *invoice);
+const char * gncInvoiceGetID (const GncInvoice *invoice);
 GncOwner * gncInvoiceGetOwner (GncInvoice *invoice);
-Timespec gncInvoiceGetDateOpened (GncInvoice *invoice);
-Timespec gncInvoiceGetDatePosted (GncInvoice *invoice);
-Timespec gncInvoiceGetDateDue (GncInvoice *invoice);
-GncBillTerm * gncInvoiceGetTerms (GncInvoice *invoice);
-const char * gncInvoiceGetBillingID (GncInvoice *invoice);
-const char * gncInvoiceGetNotes (GncInvoice *invoice);
+Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice);
+Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice);
+Timespec gncInvoiceGetDateDue (const GncInvoice *invoice);
+GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
+const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
+const char * gncInvoiceGetNotes (const GncInvoice *invoice);
 const char * gncInvoiceGetType (GncInvoice *invoice); 
-gnc_commodity * gncInvoiceGetCurrency (GncInvoice *invoice);
+gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice);
 GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice);
-gnc_numeric gncInvoiceGetToChargeAmount (GncInvoice *invoice);
-gboolean gncInvoiceGetActive (GncInvoice *invoice);
+gnc_numeric gncInvoiceGetToChargeAmount (const GncInvoice *invoice);
+gboolean gncInvoiceGetActive (const GncInvoice *invoice);
 
-GNCLot * gncInvoiceGetPostedLot (GncInvoice *invoice);
-Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice);
-Account * gncInvoiceGetPostedAcc (GncInvoice *invoice);
+GNCLot * gncInvoiceGetPostedLot (const GncInvoice *invoice);
+Transaction * gncInvoiceGetPostedTxn (const GncInvoice *invoice);
+Account * gncInvoiceGetPostedAcc (const GncInvoice *invoice);
 /** @} */
 
 /** return the "total" amount of the invoice */
@@ -165,7 +165,7 @@
 
 
 /** Given a transaction, find and return the Invoice */
-GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn);
+GncInvoice * gncInvoiceGetInvoiceFromTxn (const Transaction *txn);
 
 /** Given a LOT, find and return the Invoice attached to the lot */
 GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot);
@@ -181,9 +181,9 @@
 
 void gncInvoiceBeginEdit (GncInvoice *invoice);
 void gncInvoiceCommitEdit (GncInvoice *invoice);
-int gncInvoiceCompare (GncInvoice *a, GncInvoice *b);
-gboolean gncInvoiceIsPosted (GncInvoice *invoice);
-gboolean gncInvoiceIsPaid (GncInvoice *invoice);
+int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b);
+gboolean gncInvoiceIsPosted (const GncInvoice *invoice);
+gboolean gncInvoiceIsPaid (const GncInvoice *invoice);
 
 #define INVOICE_ID	"id"
 #define INVOICE_OWNER	"owner"

Modified: gnucash/trunk/src/business/business-core/gncJob.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncJob.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncJob.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -307,19 +307,19 @@
 /* ================================================================== */
 /* Get Functions */
 
-const char * gncJobGetID (GncJob *job)
+const char * gncJobGetID (const GncJob *job)
 {
   if (!job) return NULL;
   return job->id;
 }
 
-const char * gncJobGetName (GncJob *job)
+const char * gncJobGetName (const GncJob *job)
 {
   if (!job) return NULL;
   return job->name;
 }
 
-const char * gncJobGetReference (GncJob *job)
+const char * gncJobGetReference (const GncJob *job)
 {
   if (!job) return NULL;
   return job->desc;
@@ -331,7 +331,7 @@
   return &(job->owner);
 }
 
-gboolean gncJobGetActive (GncJob *job)
+gboolean gncJobGetActive (const GncJob *job)
 {
   if (!job) return FALSE;
   return job->active;

Modified: gnucash/trunk/src/business/business-core/gncJob.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncJob.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncJob.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -76,13 +76,13 @@
 @{
 */
 
-const char * gncJobGetID (GncJob *job);
-const char * gncJobGetName (GncJob *job);
-const char * gncJobGetReference (GncJob *job);
+const char * gncJobGetID (const GncJob *job);
+const char * gncJobGetName (const GncJob *job);
+const char * gncJobGetReference (const GncJob *job);
 GncOwner * gncJobGetOwner (GncJob *job);
 
 /** @} */
-gboolean gncJobGetActive (GncJob *job);
+gboolean gncJobGetActive (const GncJob *job);
 
 /** Return a pointer to the instance gncJob that is identified
  *  by the guid, and is residing in the book. Returns NULL if the

Modified: gnucash/trunk/src/business/business-core/gncOrder.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncOrder.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncOrder.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -293,7 +293,7 @@
 
 /* Get Functions */
 
-const char * gncOrderGetID (GncOrder *order)
+const char * gncOrderGetID (const GncOrder *order)
 {
   if (!order) return NULL;
   return order->id;
@@ -305,33 +305,33 @@
   return &order->owner;
 }
 
-Timespec gncOrderGetDateOpened (GncOrder *order)
+Timespec gncOrderGetDateOpened (const GncOrder *order)
 {
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!order) return ts;
   return order->opened;
 }
 
-Timespec gncOrderGetDateClosed (GncOrder *order)
+Timespec gncOrderGetDateClosed (const GncOrder *order)
 {
   Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
   if (!order) return ts;
   return order->closed;
 }
 
-const char * gncOrderGetNotes (GncOrder *order)
+const char * gncOrderGetNotes (const GncOrder *order)
 {
   if (!order) return NULL;
   return order->notes;
 }
 
-const char * gncOrderGetReference (GncOrder *order)
+const char * gncOrderGetReference (const GncOrder *order)
 {
   if (!order) return NULL;
   return order->reference;
 }
 
-gboolean gncOrderGetActive (GncOrder *order)
+gboolean gncOrderGetActive (const GncOrder *order)
 {
   if (!order) return FALSE;
   return order->active;
@@ -344,7 +344,7 @@
   return order->entries;
 }
 
-gboolean gncOrderIsClosed (GncOrder *order)
+gboolean gncOrderIsClosed (const GncOrder *order)
 {
   if (!order) return FALSE;
   if (order->closed.tv_sec || order->closed.tv_nsec) return TRUE;
@@ -378,7 +378,7 @@
 			 gncOrderOnDone, order_free);
 }
 
-int gncOrderCompare (GncOrder *a, GncOrder *b)
+int gncOrderCompare (const GncOrder *a, const GncOrder *b)
 {
   int compare;
 

Modified: gnucash/trunk/src/business/business-core/gncOrder.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncOrder.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncOrder.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -78,22 +78,22 @@
 
 /* Get Functions */
 
-const char * gncOrderGetID (GncOrder *order);
+const char * gncOrderGetID (const GncOrder *order);
 GncOwner * gncOrderGetOwner (GncOrder *order);
-Timespec gncOrderGetDateOpened (GncOrder *order);
-Timespec gncOrderGetDateClosed (GncOrder *order);
-const char * gncOrderGetNotes (GncOrder *order);
-const char * gncOrderGetReference (GncOrder *order);
-gboolean gncOrderGetActive (GncOrder *order);
+Timespec gncOrderGetDateOpened (const GncOrder *order);
+Timespec gncOrderGetDateClosed (const GncOrder *order);
+const char * gncOrderGetNotes (const GncOrder *order);
+const char * gncOrderGetReference (const GncOrder *order);
+gboolean gncOrderGetActive (const GncOrder *order);
 
 /* Get the list Entries */
 GList * gncOrderGetEntries (GncOrder *order);
 
 void gncOrderBeginEdit (GncOrder *order);
 void gncOrderCommitEdit (GncOrder *order);
-int gncOrderCompare (GncOrder *a, GncOrder *b);
+int gncOrderCompare (const GncOrder *a, const GncOrder *b);
 
-gboolean gncOrderIsClosed (GncOrder *order);
+gboolean gncOrderIsClosed (const GncOrder *order);
 
 /** Return a pointer to the instance gncOrder that is identified
  *  by the guid, and is residing in the book. Returns NULL if the 

Modified: gnucash/trunk/src/business/business-core/gncOwner.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncOwner.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncOwner.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -103,7 +103,7 @@
 }
 
 QofIdType
-qofOwnerGetType(GncOwner *owner)
+qofOwnerGetType(const GncOwner *owner)
 {
 	QofIdType type;
 
@@ -139,7 +139,7 @@
 }
 
 QofInstance*
-qofOwnerGetOwner (GncOwner *owner)
+qofOwnerGetOwner (const GncOwner *owner)
 {
 	QofInstance *ent;
 
@@ -234,7 +234,7 @@
   return owner->owner.employee;
 }
 
-gnc_commodity * gncOwnerGetCurrency (GncOwner *owner)
+gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner)
 {
   if (!owner) return NULL;
   switch (owner->type) {
@@ -297,7 +297,7 @@
   return (a->owner.undefined == b->owner.undefined);
 }
 
-const char * gncOwnerGetName (GncOwner *owner)
+const char * gncOwnerGetName (const GncOwner *owner)
 {
   if (!owner) return NULL;
   switch (owner->type) {
@@ -316,7 +316,7 @@
   }
 }
 
-const GUID * gncOwnerGetGUID (GncOwner *owner)
+const GUID * gncOwnerGetGUID (const GncOwner *owner)
 {
   if (!owner) return NULL;
 
@@ -393,7 +393,7 @@
   return gncOwnerGetGUID (owner);
 }
 
-void gncOwnerAttachToLot (GncOwner *owner, GNCLot *lot)
+void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot)
 {
   KvpFrame *kvp;
   KvpValue *value;
@@ -458,7 +458,7 @@
   return (owner->owner.undefined != NULL);
 }
 
-gboolean gncOwnerIsValid (GncOwner *owner)
+gboolean gncOwnerIsValid (const GncOwner *owner)
 {
   if (!owner) return FALSE;
   return (owner->owner.undefined != NULL);

Modified: gnucash/trunk/src/business/business-core/gncOwner.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncOwner.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncOwner.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -61,9 +61,9 @@
 @{
 */
 /** return the type for the collection. */
-QofIdType qofOwnerGetType(GncOwner *owner);
+QofIdType qofOwnerGetType(const GncOwner *owner);
 /** return the owner itself as an entity. */
-QofInstance* qofOwnerGetOwner (GncOwner *owner);
+QofInstance* qofOwnerGetOwner (const GncOwner *owner);
 /** set the owner from the entity. */
 void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
 
@@ -112,14 +112,14 @@
 gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
 int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
 
-const char * gncOwnerGetName (GncOwner *owner);
-gnc_commodity * gncOwnerGetCurrency (GncOwner *owner);
+const char * gncOwnerGetName (const GncOwner *owner);
+gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner);
 
 /** Get the GUID of the immediate owner */
-const GUID * gncOwnerGetGUID (GncOwner *owner);
+const GUID * gncOwnerGetGUID (const GncOwner *owner);
 GUID gncOwnerRetGUID (GncOwner *owner);
 
-gboolean gncOwnerIsValid (GncOwner *owner);
+gboolean gncOwnerIsValid (const GncOwner *owner);
 
 /**
  * Get the "parent" Owner or GUID thereof.  The "parent" owner
@@ -129,7 +129,7 @@
 const GUID * gncOwnerGetEndGUID (GncOwner *owner);
 
 /** attach an owner to a lot */
-void gncOwnerAttachToLot (GncOwner *owner, GNCLot *lot);
+void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot);
 
 /** Get the owner from the lot.  If an owner is found in the lot,
  * fill in "owner" and return TRUE.  Otherwise return FALSE.

Modified: gnucash/trunk/src/business/business-core/gncTaxTable.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncTaxTable.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncTaxTable.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -66,7 +66,7 @@
   GList *         tables;          /* visible tables */
 };
 
-static GncTaxTableEntry * CloneTaxEntry (GncTaxTableEntry*, QofBook *);
+static GncTaxTableEntry * CloneTaxEntry (const GncTaxTableEntry*, QofBook *);
 
 static QofLogModule log_module = GNC_MOD_BUSINESS;
 
@@ -194,7 +194,7 @@
 }
 
 static inline void
-gncTaxTableRemoveChild (GncTaxTable *table, GncTaxTable *child)
+gncTaxTableRemoveChild (GncTaxTable *table, const GncTaxTable *child)
 {
   g_return_if_fail(table);
   g_return_if_fail(child);
@@ -291,7 +291,7 @@
 }
 
 GncTaxTable *
-gncTaxTableObtainTwin (GncTaxTable *from, QofBook *book)
+gncTaxTableObtainTwin (const GncTaxTable *from, QofBook *book)
 {
   GncTaxTable *table;
   if (!from) return NULL;
@@ -370,7 +370,7 @@
  *  we set it above, when cloning the table).
  */
 static GncTaxTableEntry * 
-CloneTaxEntry (GncTaxTableEntry*from, QofBook *book)
+CloneTaxEntry (const GncTaxTableEntry*from, QofBook *book)
 {
   QofInstance *acc;
   GncTaxTableEntry *entry;
@@ -575,13 +575,13 @@
   return bi->tables;
 }
 
-const char *gncTaxTableGetName (GncTaxTable *table)
+const char *gncTaxTableGetName (const GncTaxTable *table)
 {
   if (!table) return NULL;
   return table->name;
 }
 
-static GncTaxTableEntry *gncTaxTableEntryCopy (GncTaxTableEntry *entry)
+static GncTaxTableEntry *gncTaxTableEntryCopy (const GncTaxTableEntry *entry)
 {
   GncTaxTableEntry *e;
   if (!entry) return NULL;
@@ -594,7 +594,7 @@
   return e;
 }
 
-static GncTaxTable *gncTaxTableCopy (GncTaxTable *table)
+static GncTaxTable *gncTaxTableCopy (const GncTaxTable *table)
 {
   GncTaxTable *t;
   GList *list;
@@ -626,57 +626,63 @@
   return child;
 }
 
-GncTaxTable *gncTaxTableGetParent (GncTaxTable *table)
+GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table)
 {
   if (!table) return NULL;
   return table->parent;
 }
 
-GList *gncTaxTableGetEntries (GncTaxTable *table)
+GList *gncTaxTableGetEntries (const GncTaxTable *table)
 {
   if (!table) return NULL;
   return table->entries;
 }
 
-gint64 gncTaxTableGetRefcount (GncTaxTable *table)
+gint64 gncTaxTableGetRefcount (const GncTaxTable *table)
 {
   if (!table) return 0;
   return table->refcount;
 }
 
-Timespec gncTaxTableLastModified (GncTaxTable *table)
+Timespec gncTaxTableLastModified (const GncTaxTable *table)
 {
   Timespec ts = { 0 , 0 };
   if (!table) return ts;
   return table->modtime;
 }
 
-gboolean gncTaxTableGetInvisible (GncTaxTable *table)
+gboolean gncTaxTableGetInvisible (const GncTaxTable *table)
 {
   if (!table) return FALSE;
   return table->invisible;
 }
 
-Account * gncTaxTableEntryGetAccount (GncTaxTableEntry *entry)
+Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry)
 {
   if (!entry) return NULL;
   return entry->account;
 }
 
-GncAmountType gncTaxTableEntryGetType (GncTaxTableEntry *entry)
+GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry)
 {
   if (!entry) return 0;
   return entry->type;
 }
 
-gnc_numeric gncTaxTableEntryGetAmount (GncTaxTableEntry *entry)
+gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry)
 {
   if (!entry) return gnc_numeric_zero();
   return entry->amount;
 }
 
-int gncTaxTableEntryCompare (GncTaxTableEntry *a, GncTaxTableEntry *b)
+GncTaxTable* gncTaxTableEntryGetTable( const GncTaxTableEntry* entry )
 {
+  if (!entry) return NULL;
+  return entry->table;
+}
+
+int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b)
+{
   char *name_a, *name_b;
   int retval;
 
@@ -696,7 +702,7 @@
   return gnc_numeric_compare (a->amount, b->amount);
 }
 
-int gncTaxTableCompare (GncTaxTable *a, GncTaxTable *b)
+int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b)
 {
   if (!a && !b) return 0;
   if (!a) return -1;

Modified: gnucash/trunk/src/business/business-core/gncTaxTable.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncTaxTable.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncTaxTable.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -149,21 +149,21 @@
 
 GList * gncTaxTableGetTables (QofBook *book);
 
-const char *gncTaxTableGetName (GncTaxTable *table);
-GncTaxTable *gncTaxTableGetParent (GncTaxTable *table);
+const char *gncTaxTableGetName (const GncTaxTable *table);
+GncTaxTable *gncTaxTableGetParent (const GncTaxTable *table);
 GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
 #define gncTaxTableGetChild(t) gncTaxTableReturnChild((t),FALSE)
-GList *gncTaxTableGetEntries (GncTaxTable *table);
-gint64 gncTaxTableGetRefcount (GncTaxTable *table);
-Timespec gncTaxTableLastModified (GncTaxTable *table);
+GList *gncTaxTableGetEntries (const GncTaxTable *table);
+gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
+Timespec gncTaxTableLastModified (const GncTaxTable *table);
 
-Account * gncTaxTableEntryGetAccount (GncTaxTableEntry *entry);
-GncAmountType gncTaxTableEntryGetType (GncTaxTableEntry *entry);
-gnc_numeric gncTaxTableEntryGetAmount (GncTaxTableEntry *entry);
+Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
+GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
+gnc_numeric gncTaxTableEntryGetAmount (const GncTaxTableEntry *entry);
 /** @} */
 
-int gncTaxTableCompare (GncTaxTable *a, GncTaxTable *b);
-int gncTaxTableEntryCompare (GncTaxTableEntry *a, GncTaxTableEntry *b);
+int gncTaxTableCompare (const GncTaxTable *a, const GncTaxTable *b);
+int gncTaxTableEntryCompare (const GncTaxTableEntry *a, const GncTaxTableEntry *b);
 
 /************************************************/
 

Modified: gnucash/trunk/src/business/business-core/gncTaxTableP.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncTaxTableP.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncTaxTableP.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -38,7 +38,7 @@
 void gncTaxTableSetRefcount (GncTaxTable *table, gint64 refcount);
 void gncTaxTableMakeInvisible (GncTaxTable *table);
 
-gboolean gncTaxTableGetInvisible (GncTaxTable *table);
+gboolean gncTaxTableGetInvisible (const GncTaxTable *table);
 
 /** The gncCloneTaxTable() routine makes a copy of the indicated
  *  tax table, placing it in the indicated book.  It copies
@@ -61,8 +61,10 @@
  * it from the other Get routines, which work in fundamentally
  * different ways.
  */
-GncTaxTable * gncTaxTableObtainTwin (GncTaxTable *from, QofBook *book);
+GncTaxTable * gncTaxTableObtainTwin (const GncTaxTable *from, QofBook *book);
 
+GncTaxTable* gncTaxTableEntryGetTable( const GncTaxTableEntry* entry );
+
 #define gncTaxTableSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
 
 #endif /* GNC_TAXTABLEP_H_ */

Modified: gnucash/trunk/src/business/business-core/gncVendor.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncVendor.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncVendor.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -346,68 +346,68 @@
 /* ============================================================== */
 /* Get Functions */
 
-const char * gncVendorGetID (GncVendor *vendor)
+const char * gncVendorGetID (const GncVendor *vendor)
 {
   if (!vendor) return NULL;
   return vendor->id;
 }
 
-const char * gncVendorGetName (GncVendor *vendor)
+const char * gncVendorGetName (const GncVendor *vendor)
 {
   if (!vendor) return NULL;
   return vendor->name;
 }
 
-GncAddress * gncVendorGetAddr (GncVendor *vendor)
+GncAddress * gncVendorGetAddr (const GncVendor *vendor)
 {
   if (!vendor) return NULL;
   return vendor->addr;
 }
 
-const char * gncVendorGetNotes (GncVendor *vendor)
+const char * gncVendorGetNotes (const GncVendor *vendor)
 {
   if (!vendor) return NULL;
   return vendor->notes;
 }
 
-GncBillTerm * gncVendorGetTerms (GncVendor *vendor)
+GncBillTerm * gncVendorGetTerms (const GncVendor *vendor)
 {
   if (!vendor) return 0;
   return vendor->terms;
 }
 
-GncTaxIncluded gncVendorGetTaxIncluded (GncVendor *vendor)
+GncTaxIncluded gncVendorGetTaxIncluded (const GncVendor *vendor)
 {
   if (!vendor) return GNC_TAXINCLUDED_USEGLOBAL;
   return vendor->taxincluded;
 }
 
-gnc_commodity * gncVendorGetCurrency (GncVendor *vendor)
+gnc_commodity * gncVendorGetCurrency (const GncVendor *vendor)
 {
   if (!vendor) return NULL;
   return vendor->currency;
 }
 
-gboolean gncVendorGetActive (GncVendor *vendor)
+gboolean gncVendorGetActive (const GncVendor *vendor)
 {
   if (!vendor) return FALSE;
   return vendor->active;
 }
 
-gboolean gncVendorGetTaxTableOverride (GncVendor *vendor)
+gboolean gncVendorGetTaxTableOverride (const GncVendor *vendor)
 {
   if (!vendor) return FALSE;
   return vendor->taxtable_override;
 }
 
-GncTaxTable* gncVendorGetTaxTable (GncVendor *vendor)
+GncTaxTable* gncVendorGetTaxTable (const GncVendor *vendor)
 {
   if (!vendor) return NULL;
   return vendor->taxtable;
 }
 
 static const char*
-qofVendorGetTaxIncluded(GncVendor *vendor)
+qofVendorGetTaxIncluded(const GncVendor *vendor)
 {
 	return gncTaxIncludedTypeToString(vendor->taxincluded);
 }
@@ -475,7 +475,7 @@
 /* ============================================================== */
 /* Other functions */
 
-int gncVendorCompare (GncVendor *a, GncVendor *b)
+int gncVendorCompare (const GncVendor *a, const GncVendor *b)
 {
   if (!a && !b) return 0;
   if (!a && b) return 1;
@@ -484,7 +484,7 @@
   return(strcmp(a->name, b->name));
 }
 
-GList * gncVendorGetJoblist (GncVendor *vendor, gboolean show_all)
+GList * gncVendorGetJoblist (const GncVendor *vendor, gboolean show_all)
 {
   if (!vendor) return NULL;
 
@@ -501,7 +501,7 @@
   }
 }
 
-gboolean gncVendorIsDirty (GncVendor *vendor)
+gboolean gncVendorIsDirty (const GncVendor *vendor)
 {
   if (!vendor) return FALSE;
   return (qof_instance_get_dirty_flag(vendor)

Modified: gnucash/trunk/src/business/business-core/gncVendor.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncVendor.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-core/gncVendor.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -86,25 +86,25 @@
 @{
 */
 
-const char * gncVendorGetID (GncVendor *vendor);
-const char * gncVendorGetName (GncVendor *vendor);
-GncAddress * gncVendorGetAddr (GncVendor *vendor);
-const char * gncVendorGetNotes (GncVendor *vendor);
-GncBillTerm * gncVendorGetTerms (GncVendor *vendor);
-GncTaxIncluded gncVendorGetTaxIncluded (GncVendor *vendor);
-gnc_commodity * gncVendorGetCurrency (GncVendor *vendor);
-gboolean gncVendorGetActive (GncVendor *vendor);
+const char * gncVendorGetID (const GncVendor *vendor);
+const char * gncVendorGetName (const GncVendor *vendor);
+GncAddress * gncVendorGetAddr (const GncVendor *vendor);
+const char * gncVendorGetNotes (const GncVendor *vendor);
+GncBillTerm * gncVendorGetTerms (const GncVendor *vendor);
+GncTaxIncluded gncVendorGetTaxIncluded (const GncVendor *vendor);
+gnc_commodity * gncVendorGetCurrency (const GncVendor *vendor);
+gboolean gncVendorGetActive (const GncVendor *vendor);
 
-gboolean gncVendorGetTaxTableOverride (GncVendor *vendor);
-GncTaxTable* gncVendorGetTaxTable (GncVendor *vendor);
+gboolean gncVendorGetTaxTableOverride (const GncVendor *vendor);
+GncTaxTable* gncVendorGetTaxTable (const GncVendor *vendor);
 
 /** @} */
 /** XXX should be renamed to RetJobList to be consistent with
  * other usage, since caller must free the copied list 
  */
-GList * gncVendorGetJoblist (GncVendor *vendor, gboolean show_all);
-gboolean gncVendorIsDirty (GncVendor *vendor);
-int gncVendorCompare (GncVendor *a, GncVendor *b);
+GList * gncVendorGetJoblist (const GncVendor *vendor, gboolean show_all);
+gboolean gncVendorIsDirty (const GncVendor *vendor);
+int gncVendorCompare (const GncVendor *a, const GncVendor *b);
 
 /** Return a pointer to the instance gncVendor that is identified
  *  by the guid, and is residing in the book. Returns NULL if the 

Copied: gnucash/trunk/src/business/business-core/sql (from rev 17438, gnucash/branches/gda-dev2/src/business/business-core/sql)


Property changes on: gnucash/trunk/src/business/business-core/sql
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in
.libs
.deps


Modified: gnucash/trunk/src/business/business-gnome/business-gnome.scm
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome.scm	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-gnome/business-gnome.scm	2008-08-01 16:02:07 UTC (rev 17444)
@@ -5,7 +5,8 @@
 (gnc:module-load "gnucash/business-core" 0)
 (gnc:module-load "gnucash/business-utils" 0)
 (gnc:module-load "gnucash/gnome-search" 0)
-(gnc:module-load "gnucash/business-core-file" 0)
+(gnc:module-load "gnucash/business-core-xml" 0)
+(gnc:module-load "gnucash/business-core-sql" 0)
 (gnc:module-load "gnucash/dialog-tax-table" 0)
 
 (gnc:module-load "gnucash/report/report-gnome" 0)

Modified: gnucash/trunk/src/business/business-gnome/dialog-billterms.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-billterms.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/business/business-gnome/dialog-billterms.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -161,7 +161,7 @@
 
 static void
 get_numeric (GtkWidget *widget, GncBillTerm *term,
-	     gnc_numeric (*func)(GncBillTerm *))
+	     gnc_numeric (*func)(const GncBillTerm *))
 {
   gnc_numeric val;
   gdouble fl;
@@ -183,7 +183,7 @@
 
 static void
 get_int (GtkWidget *widget, GncBillTerm *term,
-	     gint (*func)(GncBillTerm *))
+	     gint (*func)(const GncBillTerm *))
 {
   gint val;
 

Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/Account.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -78,6 +78,9 @@
   PROP_TAX_RELATED,
   PROP_TAX_CODE,
   PROP_TAX_SOURCE,
+
+  PROP_HIDDEN,
+  PROP_PLACEHOLDER,
 };
 
 typedef struct AccountPrivate
@@ -347,6 +350,12 @@
 	    g_value_set_string(value,
 			       xaccAccountGetTaxUSPayerNameSource(account));
 	    break;
+	case PROP_HIDDEN:
+		g_value_set_boolean(value, xaccAccountGetHidden(account));
+		break;
+	case PROP_PLACEHOLDER:
+		g_value_set_boolean(value, xaccAccountGetPlaceholder(account));
+		break;
 	default:
 	    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 	    break;
@@ -389,6 +398,9 @@
 	case PROP_COMMODITY_SCU:
 	    xaccAccountSetCommoditySCU(account, g_value_get_int(value));
 	    break;
+	case PROP_NON_STD_SCU:
+		xaccAccountSetNonStdSCU(account, g_value_get_boolean(value));
+		break;
 	case PROP_SORT_DIRTY:
 	    gnc_account_set_sort_dirty(account);
 	    break;
@@ -422,6 +434,12 @@
 	case PROP_TAX_SOURCE:
 	    xaccAccountSetTaxUSPayerNameSource(account,
 					       g_value_get_string(value));
+	case PROP_HIDDEN:
+		xaccAccountSetHidden(account, g_value_get_boolean(value));
+		break;
+	case PROP_PLACEHOLDER:
+		xaccAccountSetPlaceholder(account, g_value_get_boolean(value));
+		break;
 	default:
 	    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 	    break;
@@ -547,7 +565,7 @@
          PROP_NON_STD_SCU,
          g_param_spec_boolean ("non-std-scu",
                                "Non-std SCU",
-                               "TRUE id the account SCU doesn't match "
+                               "TRUE if the account SCU doesn't match "
                                "the commodity SCU.  This indicates a case "
                                "where the two were accidentally set to "
                                "mismatched values in older versions of "
@@ -718,6 +736,16 @@
                               "This is an unknown tax related field.",
                               NULL,
                               G_PARAM_READWRITE));
+
+    g_object_class_install_property
+        (gobject_class,
+         PROP_HIDDEN,
+         g_param_spec_boolean ("hidden",
+                               "Hidden",
+                               "Whether the account should be hidden in the  "
+			       "account tree.",
+                               FALSE,
+                               G_PARAM_READWRITE));
 }
 
 static void

Modified: gnucash/trunk/src/engine/SX-book.c
===================================================================
--- gnucash/trunk/src/engine/SX-book.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/SX-book.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -61,7 +61,7 @@
 }
 
 Account *
-gnc_book_get_template_root( QofBook *book )
+gnc_book_get_template_root( const QofBook *book )
 {
   QofCollection *col;
   if (!book) return NULL;
@@ -113,12 +113,12 @@
 {
   Account *root;
 
-  root = xaccMallocAccount(book);
-  xaccAccountBeginEdit(root);
-  xaccAccountSetType(root, ACCT_TYPE_ROOT);
-  xaccAccountCommitEdit(root);
-  gnc_book_set_template_root (book, root);
-}
+  	root = xaccMallocAccount(book);
+  	xaccAccountBeginEdit(root);
+  	xaccAccountSetType(root, ACCT_TYPE_ROOT);
+  	xaccAccountCommitEdit(root);
+  	gnc_book_set_template_root (book, root);
+  }
 
 static void 
 sxtg_book_end (QofBook *book)

Modified: gnucash/trunk/src/engine/SX-book.h
===================================================================
--- gnucash/trunk/src/engine/SX-book.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/SX-book.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -80,7 +80,7 @@
 void gnc_sxes_del_sx(SchedXactions* sxes, SchedXaction* sx);
 
 /** Returns the template group from the book. **/
-Account *gnc_book_get_template_root(QofBook *book);
+Account *gnc_book_get_template_root(const QofBook *book);
 
 /** @return The list of SXes which reference the given Account. Caller should free this list. **/
 GList* gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct);

Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/SchedXaction.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -88,13 +88,14 @@
    /* create a new template account for our splits */
    sx->template_acct = xaccMallocAccount(book);
    guid = qof_instance_get_guid( sx );
+   xaccAccountBeginEdit( sx->template_acct );
    xaccAccountSetName( sx->template_acct, guid_to_string( guid ));
    xaccAccountSetCommodity
      (sx->template_acct,
-      gnc_commodity_new( book,
-                         "template", "template",
-                         "template", "template", 1 ) );
+	  gnc_commodity_table_lookup( gnc_commodity_table_get_table(book),
+	  					"template", "template") );
    xaccAccountSetType( sx->template_acct, ACCT_TYPE_BANK );
+   xaccAccountCommitEdit( sx->template_acct );
    ra = gnc_book_get_template_root( book );
    gnc_account_append_child( ra, sx->template_acct );
 }

Modified: gnucash/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/Split.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1527,6 +1527,15 @@
    return split ? split->lot : NULL;
 }
 
+void
+xaccSplitSetLot(Split* split, GNCLot* lot)
+{
+   xaccTransBeginEdit (split->parent);
+   split->lot = lot;
+   qof_instance_set_dirty(QOF_INSTANCE(split));
+   xaccTransCommitEdit(split->parent);
+}
+
 const char *
 xaccSplitGetMemo (const Split *split)
 {

Modified: gnucash/trunk/src/engine/Split.h
===================================================================
--- gnucash/trunk/src/engine/Split.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/Split.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -130,7 +130,10 @@
  * belongs to, or NULL if it doesn't belong to any. */
 GNCLot *      xaccSplitGetLot (const Split *split);
 
+/** Assigns the split to a specific Lot */
+void xaccSplitSetLot(Split* split, GNCLot* lot);
 
+
 /** Returns the KvpFrame slots of this split for direct editing. 
  *
  * Split slots are used to store arbitrary strings, numbers, and

Modified: gnucash/trunk/src/engine/gnc-book.h
===================================================================
--- gnucash/trunk/src/engine/gnc-book.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-book.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -12,6 +12,3 @@
 #define gnc_book_get_backend qof_book_get_backend
 #define gnc_book_get_entity_table qof_book_get_entity_table
 #define gnc_book_get_counter qof_book_get_counter
-#define gnc_book_x qof_book_x
-#define gnc_book_x qof_book_x
-#define gnc_book_x qof_book_x

Modified: gnucash/trunk/src/engine/gnc-budget.c
===================================================================
--- gnucash/trunk/src/engine/gnc-budget.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-budget.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -39,38 +39,196 @@
 
 static QofLogModule log_module = GNC_MOD_ENGINE;
 
-struct gnc_budget_private{
-    QofInstance inst;
+enum {
+  PROP_0,
+  PROP_NAME,
+  PROP_DESCRIPTION,
+  PROP_NUM_PERIODS,
+  PROP_RECURRENCE,
+};
 
+struct budget_s
+{
+  QofInstance inst;
+};
+
+typedef struct {
+    QofInstanceClass parent_class;
+} BudgetClass;
+
+typedef struct BudgetPrivate {
+    /* The name is an arbitrary string assigned by the user. */
     gchar* name;
+
+	/* The description is an arbitrary string assigned by the user. */
     gchar* description;
+
+	/* Recurrence (period info) for the budget */
     Recurrence recurrence;
+
+	/* Number of periods */
     guint  num_periods;
-};
+} BudgetPrivate;
 
+#define GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_BUDGET, BudgetPrivate))
+
 struct _GncBudgetClass
 {
   QofInstanceClass parent_class;
 };
 
 /* GObject Initialization */
-QOF_GOBJECT_IMPL(gnc_budget, GncBudget, QOF_TYPE_INSTANCE);
+G_DEFINE_TYPE(GncBudget, gnc_budget, QOF_TYPE_INSTANCE)
 
 static void
 gnc_budget_init(GncBudget* budget)
 {
+    BudgetPrivate* priv;
+    GDate date;
+
+	priv = GET_PRIVATE(budget);
+	priv->name = CACHE_INSERT(_("Unnamed Budget"));
+	priv->description = CACHE_INSERT("");
+
+	priv->num_periods = 12;
+    g_date_set_time_t(&date, time(NULL));
+    g_date_subtract_days(&date, g_date_get_day(&date)-1);
+    recurrenceSet(&priv->recurrence, 1, PERIOD_MONTH, &date);
 }
 
 static void
-gnc_budget_dispose_real (GObject *budgetp)
+gnc_budget_dispose (GObject *budgetp)
 {
+    G_OBJECT_CLASS(gnc_budget_parent_class)->dispose(budgetp);
 }
 
 static void
-gnc_budget_finalize_real(GObject* budgetp)
+gnc_budget_finalize(GObject* budgetp)
 {
+    G_OBJECT_CLASS(gnc_budget_parent_class)->finalize(budgetp);
 }
 
+static void
+gnc_budget_get_property( GObject* object,
+						guint prop_id,
+						GValue* value,
+						GParamSpec* pspec)
+{
+    GncBudget* budget;
+	BudgetPrivate* priv;
+
+	g_return_if_fail(GNC_IS_BUDGET(object));
+
+	budget = GNC_BUDGET(object);
+	priv = GET_PRIVATE(budget);
+	switch( prop_id ) {
+	case PROP_NAME:
+		g_value_set_string(value, priv->name);
+		break;
+	case PROP_DESCRIPTION:
+		g_value_set_string(value, priv->description);
+		break;
+	case PROP_NUM_PERIODS:
+		g_value_set_uint(value, priv->num_periods);
+		break;
+	case PROP_RECURRENCE:
+		/* TODO: Make this a BOXED type */
+		g_value_set_pointer(value, &priv->recurrence);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+gnc_budget_set_property( GObject* object,
+						guint prop_id,
+						const GValue* value,
+						GParamSpec* pspec)
+{
+    GncBudget* budget;
+
+	g_return_if_fail(GNC_IS_BUDGET(object));
+
+	budget = GNC_BUDGET(object);
+	switch( prop_id ) {
+	case PROP_NAME:
+		gnc_budget_set_name(budget, g_value_get_string(value));
+		break;
+	case PROP_DESCRIPTION:
+		gnc_budget_set_description(budget, g_value_get_string(value));
+		break;
+	case PROP_NUM_PERIODS:
+		gnc_budget_set_num_periods(budget, g_value_get_uint(value));
+		break;
+	case PROP_RECURRENCE:
+		gnc_budget_set_recurrence(budget, g_value_get_pointer(value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+gnc_budget_class_init(GncBudgetClass* klass)
+{
+    GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+
+	gobject_class->dispose = gnc_budget_dispose;
+	gobject_class->finalize = gnc_budget_finalize;
+	gobject_class->get_property = gnc_budget_get_property;
+	gobject_class->set_property = gnc_budget_set_property;
+
+	g_type_class_add_private(klass, sizeof(BudgetPrivate));
+
+	g_object_class_install_property(
+		gobject_class,
+		PROP_NAME,
+		g_param_spec_string( "name",
+							"Budget Name",
+							"The name is an arbitrary string "
+							"assigned by the user.  It is intended "
+							"to be a short, 5 to 30 character long string "
+							"that is displayed by the GUI as the "
+							"budget mnemonic",
+							NULL,
+							G_PARAM_READWRITE));
+
+	g_object_class_install_property(
+		gobject_class,
+		PROP_DESCRIPTION,
+		g_param_spec_string( "description",
+							"Budget Description",
+							"The description is an arbitrary string "
+							"assigned by the user.  It is intended "
+							"to be a longer, 1-5 sentence description of "
+							"what the budget is all about.",
+							NULL,
+							G_PARAM_READWRITE));
+
+	g_object_class_install_property(
+		gobject_class,
+		PROP_NUM_PERIODS,
+		g_param_spec_uint( "num-periods",
+							"Number of Periods",
+							"The number of periods for this budget.",
+							0,
+							G_MAXUINT32,
+							12,
+							G_PARAM_READWRITE));
+
+	g_object_class_install_property(
+		gobject_class,
+		PROP_RECURRENCE,
+		g_param_spec_pointer( "recurrence",
+							"Budget Recurrence",
+							"about.",
+							G_PARAM_READWRITE));
+}
+
 static void commit_err (QofInstance *inst, QofBackendError errcode)
 {
   PERR ("Failed to commit: %d", errcode);
@@ -79,19 +237,23 @@
 static void
 gnc_budget_free(QofInstance *inst)
 {
-    GncBudget *budget = GNC_BUDGET(inst);
-    if (budget == NULL)
+    GncBudget *budget;
+	BudgetPrivate* priv;
+
+    if (inst == NULL)
         return;
+    g_return_if_fail(GNC_IS_BUDGET(inst));
 
-    g_return_if_fail(GNC_IS_BUDGET(budget));
+	budget = GNC_BUDGET(inst);
+	priv = GET_PRIVATE(budget);
 
     /* We first send the message that this object is about to be
      * destroyed so that any GUI elements can remove it before it is
      * actually gone. */
     qof_event_gen( &budget->inst, QOF_EVENT_DESTROY, NULL);
 
-    CACHE_REMOVE(budget->name);
-    CACHE_REMOVE(budget->description);
+    CACHE_REMOVE(priv->name);
+    CACHE_REMOVE(priv->description);
 
     /* qof_instance_release (&budget->inst); */
     g_object_unref(budget);
@@ -117,23 +279,13 @@
 gnc_budget_new(QofBook *book)
 {
     GncBudget* budget;
-    GDate date;
+
     g_return_val_if_fail(book, NULL);
 
     ENTER(" ");
     budget = g_object_new(GNC_TYPE_BUDGET, NULL);
     qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book);
 
-    g_date_set_time_t(&date, time(NULL));
-    g_date_subtract_days(&date, g_date_get_day(&date)-1);
-    recurrenceSet(&budget->recurrence, 1, PERIOD_MONTH, &date);
-
-	gnc_budget_begin_edit(budget);
-    gnc_budget_set_name(budget, _("Unnamed Budget"));
-    gnc_budget_set_description(budget, "");
-    gnc_budget_set_num_periods(budget, 12);
-	gnc_budget_commit_edit(budget);
-
     qof_event_gen( &budget->inst, QOF_EVENT_CREATE , NULL);
 
     LEAVE(" ");
@@ -153,10 +305,15 @@
 void
 gnc_budget_set_name(GncBudget* budget, const gchar* name)
 {
+	BudgetPrivate* priv;
+
     g_return_if_fail(GNC_IS_BUDGET(budget) && name);
 
+	priv = GET_PRIVATE(budget);
+	if( name == priv->name ) return;
+
     gnc_budget_begin_edit(budget);
-    CACHE_REPLACE(budget->name, name);
+    CACHE_REPLACE(priv->name, name);
     qof_instance_set_dirty(&budget->inst);
     gnc_budget_commit_edit(budget);
 
@@ -167,17 +324,21 @@
 gnc_budget_get_name(GncBudget* budget)
 {
     g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL);
-    return budget->name;
+    return GET_PRIVATE(budget)->name;
 }
 
 void
 gnc_budget_set_description(GncBudget* budget, const gchar* description)
 {
+	BudgetPrivate* priv;
+
     g_return_if_fail(GNC_IS_BUDGET(budget));
     g_return_if_fail(description);
 
+	priv = GET_PRIVATE(budget);
+	if( description == priv->description ) return;
     gnc_budget_begin_edit(budget);
-    CACHE_REPLACE(budget->description, description);
+    CACHE_REPLACE(priv->description, description);
     qof_instance_set_dirty(&budget->inst);
     gnc_budget_commit_edit(budget);
 
@@ -188,15 +349,19 @@
 gnc_budget_get_description(GncBudget* budget)
 {
     g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL);
-    return budget->description;
+    return GET_PRIVATE(budget)->description;
 }
 
 void
 gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r)
 {
+	BudgetPrivate* priv;
+
     g_return_if_fail(budget && r);
+	priv = GET_PRIVATE(budget);
+
     gnc_budget_begin_edit(budget);
-    budget->recurrence = *r;
+    priv->recurrence = *r;
     qof_instance_set_dirty(&budget->inst);
     gnc_budget_commit_edit(budget);
 
@@ -207,7 +372,7 @@
 gnc_budget_get_recurrence(GncBudget *budget)
 {
     g_return_val_if_fail(budget, NULL);
-    return (&budget->recurrence);
+    return (&GET_PRIVATE(budget)->recurrence);
 }
 
 const GUID*
@@ -221,10 +386,15 @@
 void
 gnc_budget_set_num_periods(GncBudget* budget, guint num_periods)
 {
+	BudgetPrivate* priv;
+
     g_return_if_fail(GNC_IS_BUDGET(budget));
 
+	priv = GET_PRIVATE(budget);
+	if( priv->num_periods == num_periods ) return;
+
     gnc_budget_begin_edit(budget);
-    budget->num_periods = num_periods;
+    priv->num_periods = num_periods;
     qof_instance_set_dirty(&budget->inst);
     gnc_budget_commit_edit(budget);
 
@@ -235,7 +405,7 @@
 gnc_budget_get_num_periods(GncBudget* budget)
 {
     g_return_val_if_fail(GNC_IS_BUDGET(budget), 0);
-    return budget->num_periods;
+    return GET_PRIVATE(budget)->num_periods;
 }
 
 #define BUF_SIZE (10 + GUID_ENCODING_LENGTH + \
@@ -370,7 +540,7 @@
 {
     Timespec ts;
     timespecFromTime_t(
-        &ts,  recurrenceGetPeriodTime(&budget->recurrence, period_num, FALSE));
+        &ts,  recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, FALSE));
     return ts;
 }
 
@@ -380,7 +550,7 @@
 {
     // FIXME: maybe zero is not best error return val.
     g_return_val_if_fail(GNC_IS_BUDGET(budget) && acc, gnc_numeric_zero());
-    return recurrenceGetAccountPeriodValue(&budget->recurrence, 
+    return recurrenceGetAccountPeriodValue(&GET_PRIVATE(budget)->recurrence, 
                                            acc, period_num);
 }
 
@@ -441,11 +611,11 @@
 
 /* Static wrapper getters for the recurrence params */
 static PeriodType gnc_budget_get_rec_pt(const GncBudget *bgt) 
-{ return recurrenceGetPeriodType(&(bgt->recurrence)); }
+{ return recurrenceGetPeriodType(&(GET_PRIVATE(bgt)->recurrence)); }
 static guint gnc_budget_get_rec_mult(const GncBudget *bgt) 
-{ return recurrenceGetMultiplier(&(bgt->recurrence)); }
+{ return recurrenceGetMultiplier(&(GET_PRIVATE(bgt)->recurrence)); }
 static GDate gnc_budget_get_rec_date(const GncBudget *bgt) 
-{ return recurrenceGetDate(&(bgt->recurrence)); }
+{ return recurrenceGetDate(&(GET_PRIVATE(bgt)->recurrence)); }
 
 /* Register ourselves with the engine. */
 gboolean gnc_budget_register (void)

Modified: gnucash/trunk/src/engine/gnc-budget.h
===================================================================
--- gnucash/trunk/src/engine/gnc-budget.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-budget.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -67,7 +67,7 @@
 #include <glib.h>
 
 /** The budget data.*/
-typedef struct gnc_budget_private GncBudget;
+typedef struct budget_s GncBudget;
 typedef struct _GncBudgetClass GncBudgetClass;
 
 #include "qof.h"

Modified: gnucash/trunk/src/engine/gnc-commodity.c
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-commodity.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -44,10 +44,27 @@
  * of the smallest-transactional-units of the currency are there
  * in a 'unitname' unit. */ 
 
+enum {
+  PROP_0,
+  PROP_NAMESPACE,
+  PROP_FULL_NAME,
+  PROP_MNEMONIC,
+  PROP_PRINTNAME,
+  PROP_CUSIP,
+  PROP_FRACTION,
+  PROP_UNIQUE_NAME,
+  PROP_QUOTE_FLAG,
+  PROP_QUOTE_SOURCE,
+  PROP_QUOTE_TZ,
+};
+
 struct gnc_commodity_s 
 { 
   QofInstance inst;
+};
 
+typedef struct CommodityPrivate
+{
   gnc_commodity_namespace *namespace;
 
   char    * fullname;  
@@ -65,13 +82,18 @@
   /* the number of accounts using this commodity - this field is not
    * persisted */
   int       usage_count;
-};
+} CommodityPrivate;
 
+#define GET_PRIVATE(o) \
+    (G_TYPE_INSTANCE_GET_PRIVATE((o), GNC_TYPE_COMMODITY, CommodityPrivate))
+
 struct _GncCommodityClass
 {
   QofInstanceClass parent_class;
 };
 
+static void commodity_free(gnc_commodity * cm);
+
 struct gnc_commodity_namespace_s 
 {
   QofInstance inst;
@@ -498,11 +520,17 @@
 
 static void noop (QofInstance *inst) {}
 
+static void
+comm_free(QofInstance* inst)
+{
+	commodity_free( GNC_COMMODITY(inst) );
+}
+
 void
 gnc_commodity_commit_edit (gnc_commodity *cm)
 {
   if (!qof_commit_edit (QOF_INSTANCE(cm))) return;
-  qof_commit_edit_part2 (&cm->inst, commit_err, noop, noop);
+  qof_commit_edit_part2 (&cm->inst, commit_err, noop, comm_free);
 }
 
 /********************************************************************
@@ -517,44 +545,247 @@
 }
 
 static void
-reset_printname(gnc_commodity *com)
+reset_printname(CommodityPrivate *priv)
 {
-    g_free(com->printname);
-    com->printname = g_strdup_printf("%s (%s)",
-                                     com->mnemonic ? com->mnemonic : "",
-                                     com->fullname ? com->fullname : "");
+    g_free(priv->printname);
+    priv->printname = g_strdup_printf("%s (%s)",
+                                     priv->mnemonic ? priv->mnemonic : "",
+                                     priv->fullname ? priv->fullname : "");
 }
 
 static void
-reset_unique_name(gnc_commodity *com)
+reset_unique_name(CommodityPrivate *priv)
 {
     gnc_commodity_namespace *ns;
 
-    g_free(com->unique_name);
-    ns = com->namespace;
-    com->unique_name = g_strdup_printf("%s::%s",
+    g_free(priv->unique_name);
+    ns = priv->namespace;
+    priv->unique_name = g_strdup_printf("%s::%s",
                                        ns ? ns->name : "",
-                                       com->mnemonic ? com->mnemonic : "");
+                                       priv->mnemonic ? priv->mnemonic : "");
 }
 
 /* GObject Initialization */
-QOF_GOBJECT_IMPL(gnc_commodity, gnc_commodity, QOF_TYPE_INSTANCE);
+G_DEFINE_TYPE(gnc_commodity, gnc_commodity, QOF_TYPE_INSTANCE);
 
 static void
 gnc_commodity_init(gnc_commodity* com)
 {
+  CommodityPrivate* priv;
+
+  priv = GET_PRIVATE(com);
+  
+  priv->namespace = NULL;
+  priv->fullname = CACHE_INSERT("");
+  priv->mnemonic = CACHE_INSERT("");
+  priv->cusip = CACHE_INSERT("");
+  priv->fraction = 10000;
+  priv->mark = 0;
+  priv->quote_flag = 0;
+  priv->quote_source = NULL;
+  priv->quote_tz = CACHE_INSERT("");
+
+  reset_printname(priv);
+  reset_unique_name(priv);
 }
 
 static void
-gnc_commodity_dispose_real (GObject *nsp)
+gnc_commodity_dispose(GObject *comp)
 {
+    G_OBJECT_CLASS(gnc_commodity_parent_class)->dispose(comp);
 }
 
 static void
-gnc_commodity_finalize_real(GObject* comp)
+gnc_commodity_finalize(GObject* comp)
 {
+    G_OBJECT_CLASS(gnc_commodity_parent_class)->finalize(comp);
 }
 
+static void
+gnc_commodity_get_property (GObject         *object,
+			  guint            prop_id,
+			  GValue          *value,
+			  GParamSpec      *pspec)
+{
+    gnc_commodity *commodity;
+	CommodityPrivate* priv;
+
+    g_return_if_fail(GNC_IS_COMMODITY(object));
+
+    commodity = GNC_COMMODITY(object);
+	priv = GET_PRIVATE(commodity);
+    switch (prop_id) {
+    case PROP_NAMESPACE:
+  		g_value_set_object(value, priv->namespace);
+		break;
+    case PROP_FULL_NAME:
+  		g_value_set_string(value, priv->fullname);
+		break;
+    case PROP_MNEMONIC:
+  		g_value_set_string(value, priv->mnemonic);
+		break;
+    case PROP_PRINTNAME:
+  		g_value_set_string(value, priv->printname);
+		break;
+    case PROP_CUSIP:
+  		g_value_set_string(value, priv->cusip);
+		break;
+    case PROP_FRACTION:
+		g_value_set_int(value, priv->fraction);
+		break;
+    case PROP_UNIQUE_NAME:
+  		g_value_set_string(value, priv->unique_name);
+		break;
+    case PROP_QUOTE_FLAG:
+		g_value_set_boolean(value, priv->quote_flag);
+		break;
+    case PROP_QUOTE_SOURCE:
+  		g_value_set_pointer(value, priv->quote_source);
+		break;
+    case PROP_QUOTE_TZ:
+  		g_value_set_string(value, priv->quote_tz);
+		break;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+	    break;
+    }
+}
+
+static void
+gnc_commodity_set_property (GObject         *object,
+			  guint            prop_id,
+			  const GValue    *value,
+			  GParamSpec      *pspec)
+{
+    gnc_commodity *commodity;
+    gnc_numeric *number;
+
+    g_return_if_fail(GNC_IS_COMMODITY(object));
+
+    commodity = GNC_COMMODITY(object);
+
+    switch (prop_id) {
+    case PROP_NAMESPACE:
+  		gnc_commodity_set_namespace(commodity, g_value_get_object(value));
+		break;
+    case PROP_FULL_NAME:
+  		gnc_commodity_set_fullname(commodity, g_value_get_string(value));
+		break;
+    case PROP_MNEMONIC:
+  		gnc_commodity_set_mnemonic(commodity, g_value_get_string(value));
+		break;
+    case PROP_CUSIP:
+  		gnc_commodity_set_cusip(commodity, g_value_get_string(value));
+		break;
+    case PROP_FRACTION:
+		gnc_commodity_set_fraction(commodity, g_value_get_int(value));
+		break;
+    case PROP_QUOTE_FLAG:
+		gnc_commodity_set_quote_flag(commodity, g_value_get_boolean(value));
+		break;
+    case PROP_QUOTE_SOURCE:
+  		gnc_commodity_set_quote_source(commodity, g_value_get_pointer(value));
+		break;
+    case PROP_QUOTE_TZ:
+  		gnc_commodity_set_quote_tz(commodity, g_value_get_string(value));
+		break;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+	    break;
+    }    
+}
+static void
+gnc_commodity_class_init(struct _GncCommodityClass* klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+
+    gobject_class->dispose = gnc_commodity_dispose;
+    gobject_class->finalize = gnc_commodity_finalize;
+    gobject_class->set_property = gnc_commodity_set_property;
+    gobject_class->get_property = gnc_commodity_get_property;
+
+	g_type_class_add_private(klass, sizeof(CommodityPrivate));
+
+    g_object_class_install_property(gobject_class,
+         				PROP_NAMESPACE,
+         				g_param_spec_object ("namespace",
+                              		"Namespace",
+                              		"The namespace field denotes the "
+                              		"namespace for this commodity, either "
+                              		"a currency or symbol from a quote source.",
+                              		GNC_TYPE_COMMODITY_NAMESPACE,
+                              		G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_FULL_NAME,
+	 					g_param_spec_string ("fullname",
+			      					"Full Commodity Name",
+			      					"The fullname is the official full name of"
+									"the currency.",
+			      					NULL,
+			      					G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_MNEMONIC,
+	 					g_param_spec_string ("mnemonic",
+			      					"Commodity Mnemonic",
+			      					"The mnemonic is the official abbreviated"
+									"designation for the currency.",
+			      					NULL,
+			      					G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_PRINTNAME,
+	 					g_param_spec_string ("printname",
+			      					"Commodity Print Name",
+			      					"Printable form of the commodity name.",
+			      					NULL,
+			      					G_PARAM_READABLE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_CUSIP,
+	 					g_param_spec_string ("cusip",
+			      					"Commodity CUSIP Code",
+			      					"?????",
+			      					NULL,
+			      					G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_FRACTION,
+	 					g_param_spec_int ("fraction",
+			   						"Fraction",
+			   						"The fraction is the number of sub-units that "
+									"the basic commodity can be divided into.",
+			   						1,
+			   						1000000,
+			   						1,
+			   						G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_UNIQUE_NAME,
+	 					g_param_spec_string ("unique-name",
+			      					"Commodity Unique Name",
+			      					"Unique form of the commodity name which combines "
+									"the namespace name and the commodity name.",
+			      					NULL,
+			      					G_PARAM_READABLE));
+    g_object_class_install_property(gobject_class,
+         				PROP_QUOTE_FLAG,
+         				g_param_spec_boolean ("quote_flag",
+                               		"Quote Flag",
+                               		"TRUE if prices are to be downloaded for this "
+							   		"commodity from a quote source.",
+                               		FALSE,
+                               		G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+						PROP_QUOTE_SOURCE,
+						g_param_spec_pointer("quote-source",
+									"Quote Source",
+									"The quote source from which prices are downloaded.",
+									G_PARAM_READWRITE));
+    g_object_class_install_property(gobject_class,
+	 					PROP_QUOTE_TZ,
+	 					g_param_spec_string ("quote-tz",
+			      					"Commodity Quote Timezone",
+			      					"?????",
+			      					NULL,
+			      					G_PARAM_READWRITE));
+}
+
 gnc_commodity *
 gnc_commodity_new(QofBook *book, const char * fullname, 
                   const char * namespace, const char * mnemonic, 
@@ -564,28 +795,21 @@
   gnc_commodity_table *table;
 
   qof_instance_init_data (&retval->inst, GNC_ID_COMMODITY, book);
-  table = gnc_commodity_table_get_table(book);
-  if (namespace) {
-    retval->namespace = gnc_commodity_table_find_namespace(table, namespace);
-    if (!retval->namespace)
-      retval->namespace = gnc_commodity_table_add_namespace(table, namespace, book);
-  } else {
-    retval->namespace = NULL;
+  gnc_commodity_begin_edit(retval);
+
+  if( namespace != NULL ) {
+  	gnc_commodity_set_namespace(retval, namespace);
+  	if (gnc_commodity_namespace_is_iso(namespace)) {
+    	gnc_commodity_set_quote_source(retval,
+					gnc_quote_source_lookup_by_internal("currency") );
+	}
   }
-  
-  retval->fullname = CACHE_INSERT(fullname);
-  retval->mnemonic = CACHE_INSERT(mnemonic);
-  retval->cusip = CACHE_INSERT(cusip);
-  retval->fraction = fraction;
-  retval->mark = 0;
-  retval->quote_flag = 0;
-  retval->quote_source = NULL;
-  retval->quote_tz = CACHE_INSERT("");
+  gnc_commodity_set_fullname(retval, fullname);
+  gnc_commodity_set_mnemonic(retval, mnemonic);
+  gnc_commodity_set_cusip(retval, cusip);
+  gnc_commodity_set_fraction(retval, fraction);
+  gnc_commodity_commit_edit(retval);
 
-  reset_printname(retval);
-  reset_unique_name(retval);
-  if (gnc_commodity_namespace_is_iso(namespace))
-    retval->quote_source = gnc_quote_source_lookup_by_internal("currency");
   qof_event_gen (&retval->inst, QOF_EVENT_CREATE, NULL);
 
   return retval;
@@ -596,46 +820,49 @@
  * gnc_commodity_destroy
  ********************************************************************/
 
-void
-gnc_commodity_destroy(gnc_commodity * cm)
+static void
+commodity_free(gnc_commodity * cm)
 {
   QofBook *book;
   gnc_commodity_table *table;
+  CommodityPrivate* priv;
+
   if(!cm) return;
 
   book = qof_instance_get_book(&cm->inst);
   table = gnc_commodity_table_get_table(book);
   gnc_commodity_table_remove(table, cm);
+  priv = GET_PRIVATE(cm);
 
   qof_event_gen (&cm->inst, QOF_EVENT_DESTROY, NULL);
 
   /* Set at creation */
-  CACHE_REMOVE (cm->fullname);
-  CACHE_REMOVE (cm->cusip);
-  CACHE_REMOVE (cm->mnemonic);
-  CACHE_REMOVE (cm->quote_tz);
-  cm->namespace = NULL;
+  CACHE_REMOVE (priv->fullname);
+  CACHE_REMOVE (priv->cusip);
+  CACHE_REMOVE (priv->mnemonic);
+  CACHE_REMOVE (priv->quote_tz);
+  priv->namespace = NULL;
 
   /* Set through accessor functions */
-  cm->quote_source = NULL;
+  priv->quote_source = NULL;
 
   /* Automatically generated */
-  g_free(cm->printname);
-  cm->printname = NULL;
+  g_free(priv->printname);
+  priv->printname = NULL;
 
-  g_free(cm->unique_name);
-  cm->unique_name = NULL;
+  g_free(priv->unique_name);
+  priv->unique_name = NULL;
 
-  cm->mark = 0;
+  priv->mark = 0;
 
 #ifdef ACCOUNTS_CLEANED_UP
   /* Account objects are not actually cleaned up when a book is closed (in fact
    * a memory leak), but commodities are, so in currently this warning gets hit
    * quite frequently.  Disable the check until cleaning up of accounts objects
    * on close is implemented.  */
-  if(cm->usage_count != 0) {
+  if(priv->usage_count != 0) {
       PWARN("Destroying commodity (%p) with non-zero usage_count (%d).", cm,
-              cm->usage_count);
+              priv->usage_count);
   }
 #endif
 
@@ -644,43 +871,61 @@
 }
 
 void
+gnc_commodity_destroy(gnc_commodity * cm)
+{
+  gnc_commodity_begin_edit(cm);
+  qof_instance_set_destroying(cm, TRUE);
+  gnc_commodity_commit_edit(cm);
+}
+
+void
 gnc_commodity_copy(gnc_commodity * dest, const gnc_commodity *src)
 {
-  gnc_commodity_set_fullname (dest, src->fullname);
-  dest->namespace = src->namespace;
-  gnc_commodity_set_fraction (dest, src->fraction);
-  gnc_commodity_set_cusip (dest, src->cusip);
-  gnc_commodity_set_quote_flag (dest, src->quote_flag);
+  CommodityPrivate* src_priv = GET_PRIVATE(src);
+  CommodityPrivate* dest_priv = GET_PRIVATE(dest);
+
+  gnc_commodity_set_fullname (dest, src_priv->fullname);
+  dest_priv->namespace = src_priv->namespace;
+  gnc_commodity_set_fraction (dest, src_priv->fraction);
+  gnc_commodity_set_cusip (dest, src_priv->cusip);
+  gnc_commodity_set_quote_flag (dest, src_priv->quote_flag);
   gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src));
-  gnc_commodity_set_quote_tz (dest, src->quote_tz);
+  gnc_commodity_set_quote_tz (dest, src_priv->quote_tz);
   kvp_frame_delete (dest->inst.kvp_data);
   dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data);
+  kvp_frame_delete (dest->inst.kvp_data);
+  dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data);
 }
 
 gnc_commodity *
 gnc_commodity_clone(const gnc_commodity *src, QofBook *dest_book)
 {
+  CommodityPrivate* src_priv;
+  CommodityPrivate* dest_priv;
+
   gnc_commodity * dest = g_object_new(GNC_TYPE_COMMODITY, NULL);
   qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book);
+  src_priv = GET_PRIVATE(src);
+  dest_priv = GET_PRIVATE(dest);
 
-  dest->fullname = CACHE_INSERT(src->fullname);
-  dest->mnemonic = CACHE_INSERT(src->mnemonic);
-  dest->cusip = CACHE_INSERT(src->cusip);
-  dest->quote_tz = CACHE_INSERT(src->quote_tz);
+  dest_priv->fullname = CACHE_INSERT(src_priv->fullname);
+  dest_priv->mnemonic = CACHE_INSERT(src_priv->mnemonic);
+  dest_priv->cusip = CACHE_INSERT(src_priv->cusip);
+  dest_priv->quote_tz = CACHE_INSERT(src_priv->quote_tz);
 
-  dest->namespace = src->namespace;
+  dest_priv->namespace = src_priv->namespace;
 
-  dest->mark = 0;
-  dest->fraction = src->fraction;
-  dest->quote_flag = src->quote_flag;
+  dest_priv->mark = 0;
+  dest_priv->fraction = src_priv->fraction;
+  dest_priv->quote_flag = src_priv->quote_flag;
 
   gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src));
 
   kvp_frame_delete (dest->inst.kvp_data);
   dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data);
 
-  reset_printname(dest);
-  reset_unique_name(dest);
+  reset_printname(dest_priv);
+  reset_unique_name(dest_priv);
 
   return dest;
 }
@@ -693,7 +938,7 @@
 gnc_commodity_get_mnemonic(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return cm->mnemonic;
+  return GET_PRIVATE(cm)->mnemonic;
 }
 
 /********************************************************************
@@ -704,7 +949,7 @@
 gnc_commodity_get_printname(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return cm->printname;
+  return GET_PRIVATE(cm)->printname;
 }
 
 
@@ -716,25 +961,29 @@
 gnc_commodity_get_namespace(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return gnc_commodity_namespace_get_name(cm->namespace);
+  return gnc_commodity_namespace_get_name(GET_PRIVATE(cm)->namespace);
 }
 
 const char *
 gnc_commodity_get_namespace_compat(const gnc_commodity * cm) 
 {
-  if (!cm || !cm->namespace) return NULL;
-  if (cm->namespace->iso4217) {
+  CommodityPrivate* priv;
+
+  if (!cm) return NULL;
+  priv = GET_PRIVATE(cm);
+  if(!priv->namespace) return NULL;
+  if (priv->namespace->iso4217) {
     /* Data files are still written with ISO4217. */
     return GNC_COMMODITY_NS_ISO;
   }
-  return gnc_commodity_namespace_get_name(cm->namespace);
+  return gnc_commodity_namespace_get_name(priv->namespace);
 }
 
 gnc_commodity_namespace *
 gnc_commodity_get_namespace_ds(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return cm->namespace;
+  return GET_PRIVATE(cm)->namespace;
 }
 
 /********************************************************************
@@ -745,7 +994,7 @@
 gnc_commodity_get_fullname(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return cm->fullname;
+  return GET_PRIVATE(cm)->fullname;
 }
 
 
@@ -757,7 +1006,7 @@
 gnc_commodity_get_unique_name(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return cm->unique_name;
+  return GET_PRIVATE(cm)->unique_name;
 }
 
 
@@ -769,7 +1018,7 @@
 gnc_commodity_get_cusip(const gnc_commodity * cm) 
 {
   if(!cm) return NULL;
-  return cm->cusip;
+  return GET_PRIVATE(cm)->cusip;
 }
 
 /********************************************************************
@@ -780,7 +1029,7 @@
 gnc_commodity_get_fraction(const gnc_commodity * cm) 
 {
   if(!cm) return 0;
-  return cm->fraction;
+  return GET_PRIVATE(cm)->fraction;
 }
 
 /********************************************************************
@@ -791,7 +1040,7 @@
 gnc_commodity_get_mark(const gnc_commodity * cm) 
 {
   if(!cm) return 0;
-  return cm->mark;
+  return GET_PRIVATE(cm)->mark;
 }
 
 /********************************************************************
@@ -817,7 +1066,7 @@
 gnc_commodity_get_quote_flag(const gnc_commodity *cm)
 {
   if(!cm) return FALSE;
-  return (cm->quote_flag);
+  return (GET_PRIVATE(cm)->quote_flag);
 }
 
 /********************************************************************
@@ -827,10 +1076,13 @@
 gnc_quote_source*
 gnc_commodity_get_quote_source(const gnc_commodity *cm)
 {
+  CommodityPrivate* priv;
+
   if(!cm) return NULL;
-  if (!cm->quote_source && gnc_commodity_is_iso(cm))
+  priv = GET_PRIVATE(cm);
+  if (!priv->quote_source && gnc_commodity_is_iso(cm))
     return &currency_quote_source;
-  return cm->quote_source;
+  return priv->quote_source;
 }
 
 gnc_quote_source*
@@ -850,7 +1102,7 @@
 gnc_commodity_get_quote_tz(const gnc_commodity *cm) 
 {
   if(!cm) return NULL;
-  return cm->quote_tz;
+  return GET_PRIVATE(cm)->quote_tz;
 }
 
 /********************************************************************
@@ -860,16 +1112,19 @@
 void
 gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic) 
 {
+  CommodityPrivate* priv;
+
   if(!cm) return;
-  if(cm->mnemonic == mnemonic) return;
+  priv = GET_PRIVATE(cm);
+  if(priv->mnemonic == mnemonic) return;
 
   gnc_commodity_begin_edit(cm);
-  CACHE_REMOVE (cm->mnemonic);
-  cm->mnemonic = CACHE_INSERT(mnemonic);
+  CACHE_REMOVE (priv->mnemonic);
+  priv->mnemonic = CACHE_INSERT(mnemonic);
 
   mark_commodity_dirty (cm);
-  reset_printname(cm);
-  reset_unique_name(cm);
+  reset_printname(priv);
+  reset_unique_name(priv);
   gnc_commodity_commit_edit(cm);
 }
 
@@ -883,21 +1138,23 @@
   QofBook *book;
   gnc_commodity_table *table;
   gnc_commodity_namespace *nsp;
+  CommodityPrivate* priv;
 
   if(!cm) return;
+  priv = GET_PRIVATE(cm);
   book = qof_instance_get_book (&cm->inst);
   table = gnc_commodity_table_get_table(book);
   nsp = gnc_commodity_table_add_namespace(table, namespace, book);
-  if (cm->namespace == nsp)
+  if (priv->namespace == nsp)
     return;
 
   gnc_commodity_begin_edit(cm);
-  cm->namespace = nsp;
+  priv->namespace = nsp;
   if (nsp->iso4217)
-    cm->quote_source = gnc_quote_source_lookup_by_internal("currency");
+    priv->quote_source = gnc_quote_source_lookup_by_internal("currency");
   mark_commodity_dirty(cm);
-  reset_printname(cm);
-  reset_unique_name(cm);
+  reset_printname(priv);
+  reset_unique_name(priv);
   gnc_commodity_commit_edit(cm);
 }
 
@@ -908,15 +1165,18 @@
 void
 gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname) 
 {
+  CommodityPrivate* priv;
+
   if(!cm) return;
-  if(cm->fullname == fullname) return;
+  priv = GET_PRIVATE(cm);
+  if(priv->fullname == fullname) return;
 
-  CACHE_REMOVE (cm->fullname);
-  cm->fullname = CACHE_INSERT (fullname);
+  CACHE_REMOVE (priv->fullname);
+  priv->fullname = CACHE_INSERT (fullname);
 
   gnc_commodity_begin_edit(cm);
   mark_commodity_dirty(cm);
-  reset_printname(cm);
+  reset_printname(priv);
   gnc_commodity_commit_edit(cm);
 }
 
@@ -928,12 +1188,16 @@
 gnc_commodity_set_cusip(gnc_commodity * cm, 
 			const char * cusip) 
 {
+  CommodityPrivate* priv;
+
   if(!cm) return;
-  if(cm->cusip == cusip) return;
 
+  priv = GET_PRIVATE(cm);
+  if(priv->cusip == cusip) return;
+
   gnc_commodity_begin_edit(cm);
-  CACHE_REMOVE (cm->cusip);
-  cm->cusip = CACHE_INSERT (cusip);
+  CACHE_REMOVE (priv->cusip);
+  priv->cusip = CACHE_INSERT (cusip);
   mark_commodity_dirty(cm);
   gnc_commodity_commit_edit(cm);
 }
@@ -947,7 +1211,7 @@
 {
   if(!cm) return;
   gnc_commodity_begin_edit(cm);
-  cm->fraction = fraction;
+  GET_PRIVATE(cm)->fraction = fraction;
   mark_commodity_dirty(cm);
   gnc_commodity_commit_edit(cm);
 }
@@ -960,7 +1224,7 @@
 gnc_commodity_set_mark(gnc_commodity * cm, gint16 mark) 
 {
   if(!cm) return;
-  cm->mark = mark;
+  GET_PRIVATE(cm)->mark = mark;
 }
 
 /********************************************************************
@@ -993,6 +1257,8 @@
 void
 gnc_commodity_user_set_quote_flag(gnc_commodity *cm, const gboolean flag)
 {
+  CommodityPrivate* priv;
+
   ENTER ("(cm=%p, flag=%d)", cm, flag);
 
   if(!cm) {
@@ -1000,6 +1266,7 @@
     return;
   }
 
+  priv = GET_PRIVATE(cm);
   gnc_commodity_begin_edit(cm);
   gnc_commodity_set_quote_flag(cm, flag);
   if(gnc_commodity_is_iso(cm)) {
@@ -1011,7 +1278,7 @@
      * accounts using this currency OR flag is TRUE and there are accounts
      * using this currency; otherwise disable auto quote control */
     gnc_commodity_set_auto_quote_control_flag(cm,
-        (!flag && (cm->usage_count == 0)) || (flag && (cm->usage_count != 0)));
+        (!flag && (priv->usage_count == 0)) || (flag && (priv->usage_count != 0)));
   }
   gnc_commodity_commit_edit(cm);
   LEAVE("");
@@ -1028,7 +1295,7 @@
 
   if(!cm) return;
   gnc_commodity_begin_edit(cm);
-  cm->quote_flag = flag;
+  GET_PRIVATE(cm)->quote_flag = flag;
   mark_commodity_dirty(cm);
   gnc_commodity_commit_edit(cm);
   LEAVE(" ");
@@ -1045,7 +1312,7 @@
 
   if(!cm) return;
   gnc_commodity_begin_edit(cm);
-  cm->quote_source = src;
+  GET_PRIVATE(cm)->quote_source = src;
   mark_commodity_dirty(cm);
   gnc_commodity_commit_edit(cm);
   LEAVE(" ");
@@ -1058,13 +1325,19 @@
 void
 gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz) 
 {
+  CommodityPrivate* priv;
+
   ENTER ("(cm=%p, tz=%s)", cm, tz ? tz : "(null)");
 
-  if(!cm || tz == cm->quote_tz) return;
+  if(!cm) return;
+  
+  priv = GET_PRIVATE(cm);
 
+  if(tz == priv->quote_tz) return;
+
   gnc_commodity_begin_edit(cm);
-  CACHE_REMOVE (cm->quote_tz);
-  cm->quote_tz = CACHE_INSERT (tz);
+  CACHE_REMOVE (priv->quote_tz);
+  priv->quote_tz = CACHE_INSERT (tz);
   mark_commodity_dirty(cm);
   gnc_commodity_commit_edit(cm);
   LEAVE(" ");
@@ -1078,6 +1351,7 @@
 gnc_commodity_increment_usage_count(gnc_commodity *cm)
 {
   const char *str;
+  CommodityPrivate* priv;
 
   ENTER("(cm=%p)", cm);
 
@@ -1086,7 +1360,9 @@
     return;
   }
 
-  if((cm->usage_count == 0) && !cm->quote_flag
+  priv = GET_PRIVATE(cm);
+
+  if((priv->usage_count == 0) && !priv->quote_flag
       && gnc_commodity_get_auto_quote_control_flag(cm)
       && gnc_commodity_is_iso(cm)) {
     /* compatability hack - Gnucash 1.8 gets currency quotes when a
@@ -1097,8 +1373,8 @@
         gnc_commodity_get_default_quote_source(cm));
     gnc_commodity_commit_edit(cm);
   }
-  cm->usage_count++;
-  LEAVE("(usage_count=%d)", cm->usage_count);
+  priv->usage_count++;
+  LEAVE("(usage_count=%d)", priv->usage_count);
 }
 
 /********************************************************************
@@ -1109,6 +1385,7 @@
 gnc_commodity_decrement_usage_count(gnc_commodity *cm)
 {
   const char *str;
+  CommodityPrivate* priv;
 
   ENTER("(cm=%p)", cm);
 
@@ -1117,21 +1394,23 @@
     return;
   }
 
-  if(cm->usage_count == 0) {
+  priv = GET_PRIVATE(cm);
+
+  if(priv->usage_count == 0) {
     PWARN("usage_count already zero");
     LEAVE("");
     return;
   }
 
-  cm->usage_count--;
-  if((cm->usage_count == 0) && cm->quote_flag
+  priv->usage_count--;
+  if((priv->usage_count == 0) && priv->quote_flag
       && gnc_commodity_get_auto_quote_control_flag(cm)
       && gnc_commodity_is_iso(cm)) {
     /* if this is a currency with auto quote control enabled and no more
      * accounts reference this currency, disable quote retrieval */
     gnc_commodity_set_quote_flag(cm, FALSE);
   }
-  LEAVE("(usage_count=%d)", cm->usage_count);
+  LEAVE("(usage_count=%d)", priv->usage_count);
 }
 
 /********************************************************************\
@@ -1146,16 +1425,25 @@
 gboolean
 gnc_commodity_equiv(const gnc_commodity * a, const gnc_commodity * b) 
 {
+  CommodityPrivate* priv_a;
+  CommodityPrivate* priv_b;
+
   if(a == b) return TRUE;
   if(!a || !b) return FALSE;
-  if(a->namespace != b->namespace) return FALSE;
-  if(safe_strcmp(a->mnemonic, b->mnemonic) != 0) return FALSE;
+
+  priv_a = GET_PRIVATE(a);
+  priv_b = GET_PRIVATE(b);
+  if(priv_a->namespace != priv_b->namespace) return FALSE;
+  if(safe_strcmp(priv_a->mnemonic, priv_b->mnemonic) != 0) return FALSE;
   return TRUE;
 }
 
 gboolean
 gnc_commodity_equal(const gnc_commodity * a, const gnc_commodity * b)
 {
+  CommodityPrivate* priv_a;
+  CommodityPrivate* priv_b;
+
   if (a == b) return TRUE;
 
   if (!a || !b)
@@ -1164,35 +1452,38 @@
     return FALSE;
   }
 
-  if (a->namespace != b->namespace)
+  priv_a = GET_PRIVATE(a);
+  priv_b = GET_PRIVATE(b);
+
+  if (priv_a->namespace != priv_b->namespace)
   {
     DEBUG ("namespaces differ: %p(%s) vs %p(%s)",
-	   a->namespace, gnc_commodity_namespace_get_name(a->namespace),
-	   b->namespace, gnc_commodity_namespace_get_name(b->namespace));
+	   priv_a->namespace, gnc_commodity_namespace_get_name(priv_a->namespace),
+	   priv_b->namespace, gnc_commodity_namespace_get_name(priv_b->namespace));
     return FALSE;
   }
 
-  if (safe_strcmp(a->mnemonic, b->mnemonic) != 0)
+  if (safe_strcmp(priv_a->mnemonic, priv_b->mnemonic) != 0)
   {
-    DEBUG ("mnemonics differ: %s vs %s", a->mnemonic, b->mnemonic);
+    DEBUG ("mnemonics differ: %s vs %s", priv_a->mnemonic, priv_b->mnemonic);
     return FALSE;
   }
 
-  if (safe_strcmp(a->fullname, b->fullname) != 0)
+  if (safe_strcmp(priv_a->fullname, priv_b->fullname) != 0)
   {
-    DEBUG ("fullnames differ: %s vs %s", a->fullname, b->fullname);
+    DEBUG ("fullnames differ: %s vs %s", priv_a->fullname, priv_b->fullname);
     return FALSE;
   }
 
-  if (safe_strcmp(a->cusip, b->cusip) != 0)
+  if (safe_strcmp(priv_a->cusip, priv_b->cusip) != 0)
   {
-    DEBUG ("cusips differ: %s vs %s", a->cusip, b->cusip);
+    DEBUG ("cusips differ: %s vs %s", priv_a->cusip, priv_b->cusip);
     return FALSE;
   }
 
-  if (a->fraction != b->fraction)
+  if (priv_a->fraction != priv_b->fraction)
   {
-    DEBUG ("fractions differ: %d vs %d", a->fraction, b->fraction);
+    DEBUG ("fractions differ: %d vs %d", priv_a->fraction, priv_b->fraction);
     return FALSE;
   }
 
@@ -1435,16 +1726,19 @@
   gnc_commodity_namespace * nsp = NULL;
   gnc_commodity *c;
   const char *ns_name;
+  CommodityPrivate* priv;
   QofBook *book;
 
   if (!table) return NULL;
   if (!comm) return NULL;
 
+  priv = GET_PRIVATE(comm);
+
   ENTER ("(table=%p, comm=%p) %s %s", table, comm,
-         (comm->mnemonic == NULL ? "(null)" : comm->mnemonic),
-         (comm->fullname == NULL ? "(null)" : comm->fullname));
-  ns_name = gnc_commodity_namespace_get_name(comm->namespace);
-  c = gnc_commodity_table_lookup (table, ns_name, comm->mnemonic);
+         (priv->mnemonic == NULL ? "(null)" : priv->mnemonic),
+         (priv->fullname == NULL ? "(null)" : priv->fullname));
+  ns_name = gnc_commodity_namespace_get_name(priv->namespace);
+  c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic);
 
   if (c) 
   {
@@ -1462,10 +1756,10 @@
   book = qof_instance_get_book (&comm->inst);
   nsp = gnc_commodity_table_add_namespace(table, ns_name, book);
 
-  PINFO ("insert %p %s into nsp=%p %s", comm->mnemonic, comm->mnemonic,
+  PINFO ("insert %p %s into nsp=%p %s", priv->mnemonic, priv->mnemonic,
          nsp->cm_table, nsp->name);
   g_hash_table_insert(nsp->cm_table, 
-                      CACHE_INSERT(comm->mnemonic),
+                      CACHE_INSERT(priv->mnemonic),
                       (gpointer)comm);
   nsp->cm_list = g_list_append(nsp->cm_list, comm);
 
@@ -1485,13 +1779,15 @@
 {
   gnc_commodity_namespace * nsp;
   gnc_commodity *c;
+  CommodityPrivate* priv;
   const char *ns_name;
 
   if (!table) return;
   if (!comm) return;
 
-  ns_name = gnc_commodity_namespace_get_name(comm->namespace);
-  c = gnc_commodity_table_lookup (table, ns_name, comm->mnemonic);
+  priv = GET_PRIVATE(comm);
+  ns_name = gnc_commodity_namespace_get_name(priv->namespace);
+  c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic);
   if (c != comm) return;
 
   qof_event_gen (&comm->inst, QOF_EVENT_REMOVE, NULL);
@@ -1500,7 +1796,7 @@
   if (!nsp) return;
 
   nsp->cm_list = g_list_remove(nsp->cm_list, comm);
-  g_hash_table_remove (nsp->cm_table, comm->mnemonic);
+  g_hash_table_remove (nsp->cm_table, priv->mnemonic);
   /* XXX minor mem leak, should remove the key as well */
 }
 
@@ -1582,8 +1878,13 @@
 gboolean
 gnc_commodity_is_iso(const gnc_commodity * cm)
 {
-  if (!cm || !cm->namespace) return FALSE;
-  return cm->namespace->iso4217;
+  CommodityPrivate* priv;
+
+  if (!cm) return FALSE;
+
+  priv = GET_PRIVATE(cm);
+  if( !priv->namespace) return FALSE;
+  return priv->namespace->iso4217;
 }
 
 gboolean
@@ -1592,7 +1893,7 @@
     const char *ns_name;
     if (!cm) return FALSE;
 
-    ns_name = gnc_commodity_namespace_get_name(cm->namespace);
+    ns_name = gnc_commodity_namespace_get_name(GET_PRIVATE(cm)->namespace);
     return (!safe_strcmp(ns_name, GNC_COMMODITY_NS_LEGACY) ||
             !safe_strcmp(ns_name, GNC_COMMODITY_NS_CURRENCY));
 }
@@ -1627,10 +1928,11 @@
 get_quotables_helper1(gpointer key, gpointer value, gpointer data) 
 {
   gnc_commodity *comm = value; 
+  CommodityPrivate* priv = GET_PRIVATE(comm);
   GList ** l = data;
 
-  if (!comm->quote_flag ||
-      !comm->quote_source || !comm->quote_source->supported)
+  if (!priv->quote_flag ||
+      !priv->quote_source || !priv->quote_source->supported)
     return;
   *l = g_list_prepend(*l, value);
 }
@@ -1639,9 +1941,10 @@
 get_quotables_helper2 (gnc_commodity *comm, gpointer data)
 {
   GList ** l = data;
+  CommodityPrivate* priv = GET_PRIVATE(comm);
 
-  if (!comm->quote_flag ||
-      !comm->quote_source || !comm->quote_source->supported)
+  if (!priv->quote_flag ||
+      !priv->quote_source || !priv->quote_source->supported)
     return TRUE;
   *l = g_list_prepend(*l, comm);
   return TRUE;
@@ -1963,6 +2266,7 @@
 gnc_commodity_table_add_default_data(gnc_commodity_table *table, QofBook *book)
 {
   QofCollection *col;
+  gnc_commodity* c;
 
   ENTER ("table=%p", table);
   gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_AMEX, book);
@@ -1970,6 +2274,9 @@
   gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_NASDAQ, book);
   gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_EUREX, book);
   gnc_commodity_table_add_namespace(table, GNC_COMMODITY_NS_MUTUAL, book);
+  gnc_commodity_table_add_namespace(table, "template", book);
+  c = gnc_commodity_new(book, "template", "template", "template", "template", 1);
+  gnc_commodity_table_insert(table, c);
 
   #include "iso-4217-currencies.c"
 

Modified: gnucash/trunk/src/engine/gnc-engine.c
===================================================================
--- gnucash/trunk/src/engine/gnc-engine.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-engine.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -36,7 +36,7 @@
 #include "gnc-pricedb-p.h"
 
 /** gnc file backend library name */
-#define GNC_LIB_NAME "gncmod-backend-file"
+#define GNC_LIB_NAME "gncmod-backend-xml"
 
 /* gnc-backend-file location */
 #include "gnc-path.h"
@@ -76,11 +76,11 @@
     const gchar* lib;
     gboolean required;
   } libs[] = {
-    { GNC_LIB_NAME, TRUE },
-#ifdef SQL_DIR
-    /* shouldn't the PG gnc-module do this instead of US doing it? */
-    { "gnc-backend-postgres", FALSE },
+#if defined( HAVE_DBI_DBI_H )
+    { "gncmod-backend-dbi", TRUE },
 #endif
+//    { "gncmod-backend-gda", TRUE },
+    { "gncmod-backend-xml", TRUE },
     { NULL, FALSE } }, *lib;
   gnc_engine_init_hook_t hook;
   GList * cur;

Modified: gnucash/trunk/src/engine/gnc-filepath-utils.c
===================================================================
--- gnucash/trunk/src/engine/gnc-filepath-utils.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-filepath-utils.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -205,6 +205,10 @@
       LEAVE("filefrag is file uri");
       return g_strdup(filefrag + 5);
   }
+  if( g_ascii_strncasecmp( filefrag, "xml:", 4 ) == 0 ) {
+  	  LEAVE( "filefrag is xml file uri" );
+	  return g_strdup( filefrag + 4);
+  }
 
   /* get conservative on the length so that sprintf(getpid()) works ... */
   /* strlen ("/.LCK") + sprintf (%x%d) */
@@ -281,6 +285,9 @@
 char * 
 xaccResolveURL (const char * pathfrag)
 {
+  GList* list;
+  GList* node;
+
   /* seriously invalid */
   if (!pathfrag) return NULL;
 
@@ -292,15 +299,34 @@
    */
 
   if (!g_ascii_strncasecmp (pathfrag, "http://", 7)      ||
-      !g_ascii_strncasecmp (pathfrag, "https://", 8)     ||
-      !g_ascii_strncasecmp (pathfrag, "postgres://", 11))
+      !g_ascii_strncasecmp (pathfrag, "https://", 8))
   {
     return g_strdup(pathfrag);
   }
 
+  /* Check the URL against the list of registered access methods */
+  list = qof_backend_get_registered_access_method_list();
+  for( node = list; node != NULL; node = node->next ) {
+  	const gchar* access_method = node->data;
+	if( strcmp( access_method, "file" ) != 0 &&
+			strcmp( access_method, "xml" ) != 0 ) {
+		gchar s[30];
+		sprintf( s, "%s://", access_method );
+		if( !g_ascii_strncasecmp( pathfrag, s, strlen(s) ) ) {
+			g_list_free(list);
+    		return g_strdup(pathfrag);
+		}
+	}
+  }
+  g_list_free(list);
+
+  /* "file:" and "xml:" are handled specially */
   if (!g_ascii_strncasecmp (pathfrag, "file:", 5)) {
     return (xaccResolveFilePath (pathfrag));
   }
+  if (!g_ascii_strncasecmp (pathfrag, "xml:", 4)) {
+    return (g_strdup_printf( "xml:%s", xaccResolveFilePath (pathfrag)) );
+  }
 
   return (xaccResolveFilePath (pathfrag));
 }

Modified: gnucash/trunk/src/engine/gnc-lot.c
===================================================================
--- gnucash/trunk/src/engine/gnc-lot.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-lot.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -99,8 +99,8 @@
    return lot;
 }
 
-void 
-gnc_lot_destroy (GNCLot *lot)
+static void
+gnc_lot_free(GNCLot* lot)
 {
    GList *node;
    if (!lot) return;
@@ -122,6 +122,16 @@
    g_object_unref (lot);
 }
 
+void 
+gnc_lot_destroy (GNCLot *lot)
+{
+   if (!lot) return;
+   
+   gnc_lot_begin_edit(lot);
+   qof_instance_set_destroying(lot, TRUE);
+   gnc_lot_commit_edit(lot);
+}
+
 /* ============================================================= */
 
 void
@@ -135,13 +145,20 @@
   PERR ("Failed to commit: %d", errcode);
 }
 
+static void lot_free(QofInstance* inst)
+{
+	GNCLot* lot = GNC_LOT(inst);
+
+	gnc_lot_free(lot);
+}
+
 static void noop (QofInstance *inst) {}
 
 void
 gnc_lot_commit_edit (GNCLot *lot)
 {
   if (!qof_commit_edit (QOF_INSTANCE(lot))) return;
-  qof_commit_edit_part2 (&lot->inst, commit_err, noop, noop);
+  qof_commit_edit_part2 (&lot->inst, commit_err, noop, lot_free);
 }
 
 /* ============================================================= */
@@ -356,7 +373,7 @@
    {
       gnc_lot_remove_split (split->lot, split);
    }
-   split->lot = lot;
+   xaccSplitSetLot(split, lot);
 
    lot->splits = g_list_append (lot->splits, split);
 
@@ -377,7 +394,7 @@
    gnc_lot_begin_edit(lot);
    qof_instance_set_dirty(QOF_INSTANCE(lot));
    lot->splits = g_list_remove (lot->splits, split);
-   split->lot = NULL;
+   xaccSplitSetLot(split, NULL);
    lot->is_closed = -1;   /* force an is-closed computation */
 
    if (NULL == lot->splits)

Modified: gnucash/trunk/src/engine/gnc-lot.h
===================================================================
--- gnucash/trunk/src/engine/gnc-lot.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/engine/gnc-lot.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -92,7 +92,7 @@
  *    that *all* splits in a lot must also be in the same account.
  *    Note that this routine adds the split unconditionally, with
  *    no regard for the accounting policy.  To enforce a particular
- *    accounting polciy, use the xaccSplitAssignToLot() routine 
+ *    accounting policy, use the xaccSplitAssignToLot() routine 
  *    instead.
  */
 void gnc_lot_add_split (GNCLot *, Split *);

Modified: gnucash/trunk/src/experimental/cgi-bin/Makefile.am
===================================================================
--- gnucash/trunk/src/experimental/cgi-bin/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/experimental/cgi-bin/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -5,7 +5,7 @@
 
 AM_CFLAGS = \
 	-I../../engine -I${srcdir}/../../engine \
-	-I../../backend/file -I${srcdir}/../../backend/file \
+	-I../../backend/xml -I${srcdir}/../../backend/xml \
 	${GLIB_CFLAGS}
 
 LDADD = 			\

Modified: gnucash/trunk/src/gnc-ui.h
===================================================================
--- gnucash/trunk/src/gnc-ui.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnc-ui.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -111,7 +111,7 @@
   GNC_PRICE_NEW,
 } GNCPriceEditType;
 
-GNCPrice* gnc_price_edit_dialog (gncUIWidget parent, QofSession *session,
+void gnc_price_edit_dialog (gncUIWidget parent, QofSession *session,
 				 GNCPrice *price, GNCPriceEditType type);
 GNCPrice* gnc_price_edit_by_guid (GtkWidget * parent, const GUID * guid);
 void     gnc_prices_dialog (gncUIWidget parent);

Modified: gnucash/trunk/src/gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -10,7 +10,7 @@
   ${top_builddir}/src/report/report-system/libgncmod-report-system.la \
   ${top_builddir}/src/gnome-search/libgncmod-gnome-search.la \
   ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
-  ${top_builddir}/src/backend/file/libgnc-backend-file-utils.la \
+  ${top_builddir}/src/backend/file/libgnc-backend-xml-utils.la \
   ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
   ${top_builddir}/src/engine/libgncmod-engine.la \
   ${top_builddir}/src/calculation/libgncmod-calculation.la \

Modified: gnucash/trunk/src/gnome/dialog-price-editor.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-price-editor.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome/dialog-price-editor.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -121,9 +121,9 @@
   gnc_numeric value;
   Timespec date;
 
-  if (pedit_dialog->price)
+  commodity = gnc_price_get_commodity (pedit_dialog->price);
+  if (commodity)
   {
-    commodity = gnc_price_get_commodity (pedit_dialog->price);
     currency = gnc_price_get_currency (pedit_dialog->price);
     date = gnc_price_get_time (pedit_dialog->price);
     source = gnc_price_get_source (pedit_dialog->price);
@@ -132,11 +132,10 @@
   }
   else
   {
-    commodity = NULL;
     currency = gnc_default_currency ();
     date.tv_sec = time (NULL);
     date.tv_nsec = 0;
-    source = "";
+    source = "user:price-editor";
     type = "";
     value = gnc_numeric_zero ();
   }
@@ -384,22 +383,6 @@
 }
 
 static void
-gnc_price_new_price_init (GNCPrice *price)
-{
-  Timespec date;
-
-  gnc_price_begin_edit (price);
-
-  gnc_price_set_source (price, "user:price-editor");
-  date.tv_sec = time (NULL);
-  date.tv_nsec = 0;
-  gnc_price_set_time (price, date);
-
-  gnc_price_commit_edit (price);
-  
-}
-
-static void
 close_handler (gpointer user_data)
 {
   PriceEditDialog *pedit_dialog = user_data;
@@ -436,7 +419,7 @@
  * Args:   parent  - the parent of the window to be created         *
  * Return: nothing                                                  *
 \********************************************************************/
-GNCPrice *
+void
 gnc_price_edit_dialog (GtkWidget * parent,
 		       QofSession *session,
 		       GNCPrice * price,
@@ -448,7 +431,7 @@
   if ((type == GNC_PRICE_EDIT) &&
       (gnc_forall_gui_components (DIALOG_PRICE_EDIT_CM_CLASS,
 				  show_handler, price)))
-      return(price);
+      return;
 
   pedit_dialog = g_new0 (PriceEditDialog, 1);
   gnc_price_pedit_dialog_create (parent, pedit_dialog, session);
@@ -461,7 +444,7 @@
     } else {
       price = gnc_price_create (pedit_dialog->book);
     }
-    gnc_price_new_price_init(price);
+
     pedit_dialog->new = TRUE;
     /* New price will only have one ref, this dialog. */
     break;
@@ -473,16 +456,12 @@
 
   pedit_dialog->price = price;
   price_to_gui(pedit_dialog);
-
   component_id = gnc_register_gui_component (DIALOG_PRICE_EDIT_CM_CLASS,
                                              refresh_handler, close_handler,
                                              pedit_dialog);
   gnc_gui_component_set_session (component_id, pedit_dialog->session);
-
   gtk_widget_grab_focus (pedit_dialog->commodity_edit);
-
   gtk_widget_show (pedit_dialog->dialog);
-  return(price);
 }
 
 /********************************************************************\
@@ -503,5 +482,6 @@
   if (price == NULL)
     return(NULL);
 
-  return(gnc_price_edit_dialog(parent, session, price, GNC_PRICE_EDIT));
+  gnc_price_edit_dialog(parent, session, price, GNC_PRICE_EDIT);
+  return price;
 }

Modified: gnucash/trunk/src/gnome/dialog-sx-editor.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-sx-editor.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome/dialog-sx-editor.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -862,6 +862,8 @@
 static void
 gnc_sxed_save_sx( GncSxEditorDialog *sxed )
 {
+	gnc_sx_begin_edit( sxed->sx );
+
     /* name */
     {
         char *name;
@@ -963,6 +965,8 @@
         /* now that we have it, set the start date */
         xaccSchedXactionSetStartDate( sxed->sx, &gdate );
     }
+
+	gnc_sx_commit_edit( sxed->sx );
 }
 
 static void

Modified: gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -41,6 +41,7 @@
 
 #include "dialog-book-close.h"
 #include "dialog-chart-export.h"
+#include "dialog-database-connection.h"
 #include "dialog-fincalc.h"
 #include "dialog-find-transactions.h"
 #include "dialog-sx-since-last-run.h"
@@ -67,6 +68,7 @@
 /* Command callbacks */
 static void gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data);
+static void gnc_main_window_cmd_file_db_connection (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_file_qsf_import (GtkAction *action, GncMainWindowActionData *data);
@@ -101,6 +103,9 @@
   { "FileOpenAction", GTK_STOCK_OPEN, N_("_Open..."), NULL,
     N_("Open an existing GnuCash file"),
     G_CALLBACK (gnc_main_window_cmd_file_open) },
+  { "FileDatabaseConnectionAction", NULL, N_("_Database Connection"), NULL,
+    N_("Connect to a database"),
+    G_CALLBACK (gnc_main_window_cmd_file_db_connection) },
   { "FileSaveAction", GTK_STOCK_SAVE, N_("_Save"), "<control>s",
     N_("Save the current file"),
     G_CALLBACK (gnc_main_window_cmd_file_save) },
@@ -333,6 +338,17 @@
 }
 
 static void
+gnc_main_window_cmd_file_db_connection (GtkAction *action, GncMainWindowActionData *data)
+{
+  g_return_if_fail (data != NULL);
+
+  if (!gnc_main_window_all_finish_pending())
+    return;
+
+  gnc_ui_database_connection();
+}
+
+static void
 gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data)
 {
   g_return_if_fail (data != NULL);

Modified: gnucash/trunk/src/gnome/lot-viewer.c
===================================================================
--- gnucash/trunk/src/gnome/lot-viewer.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome/lot-viewer.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -221,6 +221,8 @@
 
    if (lot)
    {
+	  gnc_lot_begin_edit(lot);
+
       /* Get the title, save_the_title */
       str = gtk_entry_get_text (lv->title_entry);
       gnc_lot_set_title (lot, str);
@@ -229,6 +231,8 @@
       notes = xxxgtk_textview_get_text (lv->lot_notes);
       gnc_lot_set_notes (lot, notes);
       g_free(notes);
+
+	  gnc_lot_commit_edit(lot);
    }
 }
 

Modified: gnucash/trunk/src/gnome/ui/gnc-plugin-basic-commands-ui.xml
===================================================================
--- gnucash/trunk/src/gnome/ui/gnc-plugin-basic-commands-ui.xml	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome/ui/gnc-plugin-basic-commands-ui.xml	2008-08-01 16:02:07 UTC (rev 17444)
@@ -14,6 +14,7 @@
       <placeholder name="FileSavePlaceholder">
         <menuitem name="FileSave" action="FileSaveAction"/>
         <menuitem name="FileSaveAs" action="FileSaveAsAction"/>
+		<menuitem name="FileDatabaseConnection" action="FileDatabaseConnectionAction"/>
       </placeholder>
       <menu name="FileExport" action="FileExportAction">
         <menuitem name="FileExportAccounts" action="FileExportAccountsAction"/>

Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome-utils/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -20,7 +20,8 @@
   ${GTKHTML_CFLAGS} \
   ${GUILE_INCS} \
   ${QOF_CFLAGS} \
-  ${GOFFICE_CFLAGS}
+  ${GOFFICE_CFLAGS} \
+  ${LIBGDA_CFLAGS}
 
 libgncmod_gnome_utils_la_SOURCES = \
   QuickFill.c \
@@ -29,6 +30,7 @@
   dialog-account.c \
   dialog-book-close.c \
   dialog-commodity.c \
+  dialog-database-connection.c \
   dialog-options.c \
   dialog-preferences.c \
   dialog-query-list.c \
@@ -103,6 +105,7 @@
   dialog-account.h \
   dialog-book-close.h \
   dialog-commodity.h \
+  dialog-database-connection.h \
   dialog-preferences.h \
   dialog-options.h \
   dialog-query-list.h \
@@ -178,7 +181,7 @@
   ${top_builddir}/src/core-utils/libgnc-core-utils.la \
   ${top_builddir}/src/gnc-module/libgnc-module.la \
   ${top_builddir}/src/engine/libgncmod-engine.la \
-  ${top_builddir}/src/backend/file/libgnc-backend-file-utils.la \
+  ${top_builddir}/src/backend/file/libgnc-backend-xml-utils.la \
   ${top_builddir}/src/calculation/libgncmod-calculation.la \
   ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
   $(top_builddir)/lib/libc/libc-missing.la \

Copied: gnucash/trunk/src/gnome-utils/dialog-database-connection.c (from rev 17438, gnucash/branches/gda-dev2/src/gnome-utils/dialog-database-connection.c)
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-database-connection.c	                        (rev 0)
+++ gnucash/trunk/src/gnome-utils/dialog-database-connection.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,155 @@
+/********************************************************************\
+ * dialog-database-connection.c -- dialog for opening a connection  *
+ *                        to a libgda database, either predefined   *
+ *                        in ~/.libgda/config or explicit using     *
+ *                        provider and database.                    *
+ *                                                                  *
+ * Copyright (C) 2007-8 Phil Longstaff (plongstaff at rogers.com)      *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <glade/glade.h>
+
+#include "gnc-ui.h"
+#include "dialog-utils.h"
+#include "dialog-database-connection.h"
+#include "gnc-file.h"
+#include "gnc-session.h"
+
+static QofLogModule log_module = GNC_MOD_GUI;
+
+void gnc_database_connection_response_cb( GtkDialog *, gint, GtkDialog * );
+#define PB_LOAD_RESPONSE 1000
+#define PB_SAVE_RESPONSE 1001
+
+struct DatabaseConnectionWindow
+{
+  /* Parts of the dialog */
+  GtkWidget* dialog;
+  GtkWidget* rb_mysql;
+  GtkWidget* rb_postgresql;
+  GtkWidget* tf_host;
+  GtkWidget* tf_database;
+  GtkWidget* tf_username;
+  GtkWidget* tf_password;
+};
+
+static gchar*
+geturl( struct DatabaseConnectionWindow* dcw )
+{
+	gchar* url;
+	const gchar* host;
+	const gchar* database;
+	const gchar* username;
+	const gchar* password;
+	const gchar* type;
+
+	host = gtk_entry_get_text( GTK_ENTRY(dcw->tf_host) );
+	database = gtk_entry_get_text( GTK_ENTRY(dcw->tf_database) );
+	username = gtk_entry_get_text( GTK_ENTRY(dcw->tf_username) );
+	password = gtk_entry_get_text( GTK_ENTRY(dcw->tf_password) );
+
+	if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(dcw->rb_mysql) ) ) {
+		type = "mysql";
+	} else {
+		type = "postgres";
+	}
+	url = g_strdup_printf( "%s://%s:%s:%s:%s",
+							type, host, database, username, password );
+
+	return url;
+}
+
+void
+gnc_database_connection_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
+{
+    struct DatabaseConnectionWindow* dcw;
+
+    g_return_if_fail( dialog != NULL );
+
+    dcw = g_object_get_data( G_OBJECT(dialog), "DatabaseConnectionWindow" );
+    g_return_if_fail(dcw);
+
+    switch( response ) {
+    case GTK_RESPONSE_HELP:
+        gnc_gnome_help( HF_HELP, HL_GLOBPREFS );
+        break;
+  
+    case PB_LOAD_RESPONSE:
+		gnc_file_open_file( geturl( dcw ) );
+		break;
+
+    case PB_SAVE_RESPONSE:
+		gnc_file_do_save_as( geturl( dcw ) );
+		break;
+
+	case GTK_RESPONSE_CANCEL:
+		break;
+
+    default:
+        PERR( "Invalid response" );
+        break;
+    }
+
+	if( response != GTK_RESPONSE_HELP ) {
+        gtk_widget_destroy( GTK_WIDGET(dialog) );
+	}
+}
+
+void gnc_ui_database_connection( void )
+{
+    struct DatabaseConnectionWindow *dcw;
+    GladeXML* xml;
+    GtkWidget* box;
+	GList* ds_node;
+
+    dcw = g_new0(struct DatabaseConnectionWindow, 1);
+    g_return_if_fail(dcw);
+
+    /* Open the dialog */
+    xml = gnc_glade_xml_new( "dialog-database-connection.glade", "Database Connection" );
+    dcw->dialog = glade_xml_get_widget( xml, "Database Connection" );
+
+    dcw->rb_mysql = glade_xml_get_widget( xml, "rb_mysql" );
+    dcw->rb_postgresql = glade_xml_get_widget( xml, "rb_postgresql" );
+    dcw->tf_host = glade_xml_get_widget( xml, "tf_host" );
+	gtk_entry_set_text( GTK_ENTRY(dcw->tf_host), "localhost" );
+    dcw->tf_database = glade_xml_get_widget( xml, "tf_database" );
+	gtk_entry_set_text( GTK_ENTRY(dcw->tf_database), "gnucash" );
+    dcw->tf_username = glade_xml_get_widget( xml, "tf_username" );
+    dcw->tf_password = glade_xml_get_widget( xml, "tf_password" );
+
+    /* Autoconnect signals */
+    glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func,
+				    					dcw->dialog );
+
+    /* Clean up the xml data structure when the dialog is destroyed */
+    g_object_set_data_full( G_OBJECT(dcw->dialog), "dialog-database-connection.glade",
+			 				xml, g_object_unref );
+    g_object_set_data_full( G_OBJECT(dcw->dialog), "DatabaseConnectionWindow", dcw,
+			 				g_free );
+
+    /* Run the dialog */
+    gtk_widget_show_all( dcw->dialog );
+}
+

Copied: gnucash/trunk/src/gnome-utils/dialog-database-connection.h (from rev 17438, gnucash/branches/gda-dev2/src/gnome-utils/dialog-database-connection.h)
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-database-connection.h	                        (rev 0)
+++ gnucash/trunk/src/gnome-utils/dialog-database-connection.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,46 @@
+/********************************************************************\
+ * dialog-database-connection.h -- dialog for opening a connection  *
+ *                        to a libgda database, either predefined   *
+ *                        in ~/.libgda/config or explicit using     *
+ *                        provider and database.                    *
+ *                                                                  *
+ * Copyright (C) 2007-8 Phil Longstaff (plongstaff at rogers.com)      *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef DIALOG_DATABASE_CONNECTION_H
+#define DIALOG_DATABASE_CONNECTION_H
+
+/** @addtogroup GUI
+    @{ */
+/** @file dialog-database-connection.h
+ *
+ *  This file contains the functions to present a GUI to select
+ *  a database connection.
+ */
+
+/** Create and run the dialog to close the book.
+ *
+ */
+void gnc_ui_database_connection( void );
+
+
+/** @} */
+
+#endif /* DIALOG_DATABASE_CONNECTION_H */

Modified: gnucash/trunk/src/gnome-utils/glade/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/glade/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome-utils/glade/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -2,6 +2,7 @@
 glade_DATA = \
   commodity.glade \
   dialog-book-close.glade \
+  dialog-database-connection.glade \
   dialog-query-list.glade \
   dialog-reset-warnings.glade \
   druid-provider-multifile.glade \

Copied: gnucash/trunk/src/gnome-utils/glade/dialog-database-connection.glade (from rev 17438, gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-database-connection.glade)
===================================================================
--- gnucash/trunk/src/gnome-utils/glade/dialog-database-connection.glade	                        (rev 0)
+++ gnucash/trunk/src/gnome-utils/glade/dialog-database-connection.glade	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <widget class="GtkDialog" id="Database Connection">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">Database Connection</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <signal name="response" handler="gnc_database_connection_response_cb"/>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <child>
+          <widget class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <child>
+              <widget class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <child>
+                  <widget class="GtkRadioButton" id="rb_mysql">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">MySQL</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="rb_postgresql">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">PostgreSQL</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">rb_mysql</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkTable" id="table1">
+                <property name="visible">True</property>
+                <property name="n_rows">4</property>
+                <property name="n_columns">2</property>
+                <child>
+                  <widget class="GtkEntry" id="tf_password">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_username">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_database">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_host">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label4">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">password</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">username</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">database</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">host</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="pb_help">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-help</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-11</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="pb_cancel">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="pb_load">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label" translatable="yes">_Load</property>
+                <property name="use_underline">True</property>
+                <property name="response_id">1000</property>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="pb_save">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label" translatable="yes">_Save</property>
+                <property name="use_underline">True</property>
+                <property name="response_id">1001</property>
+              </widget>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>

Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1034,6 +1034,24 @@
   g_free(default_dir);
   if (!filename) return;
 
+  gnc_file_do_save_as( filename );
+
+  LEAVE (" ");
+}
+
+void
+gnc_file_do_save_as (const char* filename)
+{
+  QofSession *new_session;
+  QofSession *session;
+  char *default_dir = NULL;        /* Default to last open */
+  char *last;
+  char *newfile;
+  const char *oldfile;
+  QofBackendError io_err = ERR_BACKEND_NO_ERR;
+
+  ENTER(" ");
+
   /* Check to see if the user specified the same file as the current
    * file. If so, then just do that, instead of the below, which
    * assumes a truly new name was given. */

Modified: gnucash/trunk/src/gnome-utils/gnc-file.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.h	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome-utils/gnc-file.h	2008-08-01 16:02:07 UTC (rev 17444)
@@ -127,6 +127,7 @@
 gboolean gnc_file_open (void);
 void gnc_file_save (void);
 void gnc_file_save_as (void);
+void gnc_file_do_save_as(const char* filename);
 
 /** Tell the user about errors in the backends
 

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1203,6 +1203,9 @@
  *  window title and the title of the "Window" menu item associated
  *  with the window.
  *
+ *  As a side-effect, the save action is set sensitive iff the book
+ *  is dirty.
+ *
  *  @param window The window whose title should be generated.
  *
  *  @return The title for the window.  It is the callers
@@ -1218,13 +1221,23 @@
   QofBook *book;
   const gchar *filename = NULL, *dirty = "";
   gchar *title, *ptr;
+  GtkAction* action;
 
+  /* The save action is sensitive iff the book is dirty */
+  action = gnc_main_window_find_action (window, "FileSaveAction");
+  if (action != NULL) {
+  	gtk_action_set_sensitive(action, FALSE);
+  }
   if (gnc_current_session_exist()) {
       filename = gnc_session_get_url (gnc_get_current_session ());
       book = gnc_get_current_book();
-      if (qof_instance_is_dirty(QOF_INSTANCE(book)))
-	dirty = "*";
- }
+      if (qof_instance_is_dirty(QOF_INSTANCE(book))) {
+		dirty = "*";
+		if (action != NULL) {
+		  gtk_action_set_sensitive(action, TRUE);
+		}
+	  }
+  }
 
   if (!filename)
     filename = _("<no file>");

Modified: gnucash/trunk/src/gnome-utils/test/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/gnome-utils/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -17,7 +17,7 @@
   --library-dir    ${top_builddir}/src/core-utils \
   --library-dir    ${top_builddir}/src/gnc-module \
   --library-dir    ${top_builddir}/src/engine \
-  --library-dir    ${top_builddir}/src/backend/file \
+  --library-dir    ${top_builddir}/src/backend/xml \
   --library-dir    ${top_builddir}/src/calculation \
   --library-dir    ${top_builddir}/src/app-utils \
   --library-dir    ${top_builddir}/src/gnome-utils

Modified: gnucash/trunk/src/import-export/qif-io-core/test/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/qif-io-core/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/import-export/qif-io-core/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -10,7 +10,7 @@
   --gnc-module-dir ${top_builddir}/src/engine \
   --gnc-module-dir ${top_builddir}/src/app-utils \
   --gnc-module-dir ${top_builddir}/src/calculation \
-  --gnc-module-dir ${top_builddir}/src/backend/file \
+  --gnc-module-dir ${top_builddir}/src/backend/xml \
   --gnc-module-dir ${top_builddir}/src/import-export/qif-io-core \
   --guile-load-dir ${top_srcdir}/src/import-export/qif-io-core/test \
   --guile-load-dir ${top_srcdir}/lib \

Modified: gnucash/trunk/src/import-export/test/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/import-export/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -29,7 +29,7 @@
   --library-dir    ${top_builddir}/src/core-utils \
   --library-dir    ${top_builddir}/src/gnc-module \
   --library-dir    ${top_builddir}/src/engine \
-  --library-dir    ${top_builddir}/src/backend/file \
+  --library-dir    ${top_builddir}/src/backend/xml \
   --library-dir    ${top_builddir}/src/calculation \
   --library-dir    ${top_builddir}/src/app-utils \
   --library-dir    ${top_builddir}/src/gnome-utils \

Modified: gnucash/trunk/src/report/report-gnome/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/report-gnome/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/report/report-gnome/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -12,7 +12,7 @@
   --library-dir    ${top_builddir}/src/core-utils \
   --library-dir    ${top_builddir}/src/gnc-module \
   --library-dir    ${top_builddir}/src/engine \
-  --library-dir    ${top_builddir}/src/backend/file \
+  --library-dir    ${top_builddir}/src/backend/xml \
   --library-dir    ${top_builddir}/src/calculation \
   --library-dir    ${top_builddir}/src/app-utils \
   --library-dir    ${top_builddir}/src/gnome-utils \

Modified: gnucash/trunk/src/report/stylesheets/test/Makefile.am
===================================================================
--- gnucash/trunk/src/report/stylesheets/test/Makefile.am	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/report/stylesheets/test/Makefile.am	2008-08-01 16:02:07 UTC (rev 17444)
@@ -10,7 +10,7 @@
   --library-dir    ${top_builddir}/src/core-utils \
   --library-dir    ${top_builddir}/src/gnc-module \
   --library-dir    ${top_builddir}/src/engine \
-  --library-dir    ${top_builddir}/src/backend/file \
+  --library-dir    ${top_builddir}/src/backend/xml \
   --library-dir    ${top_builddir}/src/calculation \
   --library-dir    ${top_builddir}/src/app-utils \
   --library-dir    ${top_builddir}/src/gnome-utils \

Modified: gnucash/trunk/src/valgrind-gdk.supp
===================================================================
--- gnucash/trunk/src/valgrind-gdk.supp	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/valgrind-gdk.supp	2008-08-01 16:02:07 UTC (rev 17444)
@@ -1,4 +1,31 @@
 {
+	qtcurve Cond
+	Memcheck:Cond
+	obj:/usr/lib/kde3/plugins/styles/qtcurve.so
+	fun:drawArrow
+	obj:/usr/lib/gtk-2.0/*/engines/libqtengine.so
+	fun:gtk_paint_arrow
+}
+{
+	qtcurve Cond #2
+	Memcheck:Cond
+	obj:/usr/lib/libkdefx.so*
+	obj:/usr/lib/kde3/plugins/styles/qtcurve.so
+	fun:drawArrow
+	obj:/usr/lib/gtk-2.0/*/engines/libqtengine.so
+	fun:gtk_paint_arrow
+}
+{
+	qtcurve Cond #3
+	Memcheck:Cond
+	obj:/usr/lib/libqt-mt.so*
+	obj:/usr/lib/libkdefx.so*
+	obj:/usr/lib/kde3/plugins/styles/qtcurve.so
+	fun:drawArrow
+	obj:/usr/lib/gtk-2.0/*/engines/libqtengine.so
+	fun:gtk_paint_arrow
+}
+{
    <insert some suppression name here>
    Memcheck:Leak
    fun:malloc

Copied: gnucash/trunk/src/valgrind-glib.supp (from rev 17438, gnucash/branches/gda-dev2/src/valgrind-glib.supp)
===================================================================
--- gnucash/trunk/src/valgrind-glib.supp	                        (rev 0)
+++ gnucash/trunk/src/valgrind-glib.supp	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,91 @@
+
+# FILE: valgrind-gnucash.supp
+#
+# FUNCTION: This file is a valgrind 'suppression' file, used to 
+#     get valgrind to not report certain errors that we aren't 
+#     interested in.
+#
+#     valgrind is a memory allocation debugging tool.  See the
+#     file ./HACKING for instructions on how to run gnucash with
+#     valgrind
+#
+# HISTORY: created aug 2003 linas vepstas
+
+
+##----------------------------------------------------------------------##
+
+# Format of this file is:
+# {
+#     name_of_suppression
+#     skin_name:supp_kind
+#     (optional extra info for some suppression types)
+#     caller0 name, or /name/of/so/file.so
+#     caller1 name, or ditto
+#     (optionally: caller2 name)
+#     (optionally: caller3 name)
+#  }
+#
+# For memcheck, the supp_kinds are:
+#
+#     Param Value1 Value2 Value4 Value8 Value16
+#     Free Addr1 Addr2 Addr4 Addr8 Addr16
+#     Cond (previously known as Value0)
+#     Leak
+#
+# and the optional extra info is:
+#     if Param: name of system call param
+#     if Free: name of free-ing fn)
+
+{
+	g_thread_init Leak
+	Memcheck:Leak
+	fun:memalign
+	fun:posix_memalign
+	obj:/usr/lib/libglib-2.0.so.0.1600.3
+	fun:g_slice_alloc
+	fun:g_array_sized_new
+	fun:g_array_new
+	fun:g_static_private_set
+	fun:g_get_filename_charsets
+}
+{
+	g_get_tmp_dir leak
+	Memcheck:Leak
+	fun:malloc
+	obj:/lib/tls/i686/cmov/libc-2.7.so
+	fun:__nss_database_lookup
+	obj:*
+	obj:*
+	fun:getpwnam_r
+	obj:*libglib-2.0*
+	fun:g_get_tmp_dir
+}
+{
+	g_option_context_parse leak
+	Memcheck:Leak
+	fun:calloc
+	fun:g_malloc0
+	obj:*libgobject*
+	obj:*libgobject*
+	fun:g_type_init_with_debug_flags
+	fun:g_type_init
+	fun:gdk_pre_parse_libgtk_only
+	obj:*libgtk-x11-2.0*
+	fun:g_option_context_parse
+}
+{
+    g_child_watch_add lean
+	Memcheck:Leak
+	fun:calloc (vg_replace_malloc.c:397)
+	obj:*
+	fun:_dl_allocate_tls
+	fun:pthread_create*
+	obj:*libgthread-2.0*
+	fun:g_thread_create_full
+	obj:*libglib-2.0*
+	fun:g_child_watch_source_new
+	fun:g_child_watch_add_full
+	fun:g_child_watch_add
+}
+
+# ##----------------------------------------------------------------------##

Modified: gnucash/trunk/src/valgrind-gnucash.supp
===================================================================
--- gnucash/trunk/src/valgrind-gnucash.supp	2008-07-31 07:56:05 UTC (rev 17443)
+++ gnucash/trunk/src/valgrind-gnucash.supp	2008-08-01 16:02:07 UTC (rev 17444)
@@ -37,25 +37,75 @@
 #     if Free: name of free-ing fn)
 
 {
-   libguile.so(Cond)
-   Memcheck:Cond
-   obj:*libguile.so.*
+	libld-2.7(Addr4)
+	Memcheck:Addr4
+	obj:/lib/ld-2.7.so
+	obj:/lib/ld-2.7.so
 }
-
 {
-   libguile.so(Value4)
-   Memcheck:Value4
-   obj:*libguile.so*
+	libld-2.7(Addr4 #2)
+	Memcheck:Addr4
+	obj:/lib/ld-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libc-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libc-2.7.so
 }
-
 {
+	libld-2.7(Addr4 #3)
+	Memcheck:Addr4
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libc-2.7.so
+	fun:_dl_sym
+}
+{
+	libld-2.7(Addr4 #4)
+	Memcheck:Addr4
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libdl-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libdl-2.7.so
+}
+{
+	libld-2.7(Cond)
+	Memcheck:Cond
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libc-2.7.so
+	fun:_dl_sym
+}
+{
+	libld-2.7(Cond #2)
+	Memcheck:Cond
+	obj:/lib/ld-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libc-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libc-2.7.so
+}
+{
+	libld-2.7(Cond #3)
+	Memcheck:Cond
+	obj:/lib/ld-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libdl-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libdl-2.7.so
+}
+{
+	libld-2.7(Cond #4)
+	Memcheck:Cond
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libdl-2.7.so
+	obj:/lib/ld-2.7.so
+	obj:/lib/tls/i686/cmov/libdl-2.7.so
+}
+{
    libglib-1.2.so.0(Value4)
    Memcheck:Value4
    fun:g_hash_table_lookup
    fun:g_hash_table_insert
    fun:g_hash_table_lookup_extended
 }
-
 {
    write(buf) Param
    Memcheck:Param
@@ -63,9 +113,8 @@
    obj:/lib/libpthread-2.5.so
    fun:_X11TransWrite
 }
-
 {
-   <insert a suppression name here>
+   writev(vector) ORBit Param #1
    Memcheck:Param
    writev(vector[...])
    fun:do_writev
@@ -74,9 +123,8 @@
    fun:link_connection_writev
    fun:giop_send_buffer_write
 }
-
 {
-   <insert a suppression name here>
+   writev(vector) ORBit Param #2
    Memcheck:Param
    writev(vector[...])
    fun:do_writev
@@ -84,18 +132,16 @@
    fun:link_connection_writev
    fun:giop_send_buffer_write
 }
-
+#{
+#   pthread_mutex_lock PThread
+#   core:PThread
+#   fun:pthread_mutex_lock
+#   fun:_IO_flockfile
+#   fun:pango_read_line
+#   fun:pango_find_map
+#}
 {
-   <insert a suppression name here>
-   core:PThread
-   fun:pthread_mutex_lock
-   fun:_IO_flockfile
-   fun:pango_read_line
-   fun:pango_find_map
-}
-
-{
-   <insert a suppression name here>
+   writev(vector) X11 Param
    Memcheck:Param
    writev(vector[...])
    fun:writev
@@ -103,65 +149,32 @@
    fun:_X11TransWritev
    fun:_XSend
 }
-
-
 {
-   <insert a suppression name here>
+   register_state Leak
    Memcheck:Leak
    fun:malloc
-   obj:/usr/lib/libguile.so.12.3.0
-   obj:/usr/lib/libguile.so.12.3.0
-   obj:/usr/lib/libguile.so.12.3.0
-}
-{
-   <insert a suppression name here>
-   Memcheck:Leak
-   fun:realloc
-   fun:scm_make_port_type
-   fun:scm_init_vports
-   obj:/usr/lib/libguile.so.12.3.0
-}
-{
-   <insert a suppression name here>
-   Memcheck:Leak
-   fun:realloc
-   obj:/usr/lib/libguile.so.12.3.0
-   fun:scm_gc_for_newcell
-   fun:scm_acons
-}
-
-{
-   <insert a suppression name here>
-   Memcheck:Leak
-   fun:malloc
    fun:register_state
    fun:create_cd_newstate
    fun:re_compile_internal
 }
-
-
-
 {
-   <insert a suppression name here>
+   poptGetContext Leak
    Memcheck:Leak
    fun:*
    fun:poptGetContext
    fun:gnome_program_preinit
    obj:/usr/lib/libgnome-2.so.0.800.0
 }
-
-
 {
-   <insert a suppression name here>
+   IceAddConnectionWatch Leak
    Memcheck:Leak
    fun:malloc
    fun:IceAddConnectionWatch
    fun:gnome_ice_init
    obj:/usr/lib/libgnomeui-2.so.0.800.0
 }
-
 {
-   <insert a suppression name here>
+   CORBA_string_dup Leak
    Memcheck:Leak
    fun:malloc
    fun:g_malloc
@@ -169,7 +182,7 @@
    fun:CORBA_string_dup
 }
 {
-   <insert a suppression name here>
+   iconv_open Leak
    Memcheck:Leak
    fun:malloc
    fun:__gconv_open
@@ -177,7 +190,7 @@
    obj:/usr/lib/libglib-2.0.so.0.400.8
 }
 {
-   <insert a suppression name here>
+   openaux Leak
    Memcheck:Leak
    fun:malloc
    fun:_dl_map_object_from_fd
@@ -185,7 +198,7 @@
    fun:openaux
 }
 {
-   <insert a suppression name here>
+   FcInitLoadConfigAndFonts Leak
    Memcheck:Leak
    fun:malloc
    fun:FcFontSetCreate
@@ -193,23 +206,22 @@
    fun:FcInitLoadConfigAndFonts
 }
 {
-   <insert a suppression name here>
+   libfontconfig.so Leak
    Memcheck:Leak
    fun:malloc
    fun:*
    obj:/usr/lib/libfontconfig.so.1.0.4
 }
 {
-   <insert a suppression name here>
+   XftInitFtLibrary Leak
    Memcheck:Leak
    fun:malloc
    fun:FT_New_Memory
    fun:FT_Init_FreeType
    fun:XftInitFtLibrary
 }
-
 {
-   <insert a suppression name here>
+   _XftDisplayInfoGet Leak
    Memcheck:Leak
    fun:malloc
    fun:XRenderFindDisplay
@@ -217,32 +229,31 @@
    fun:_XftDisplayInfoGet
 }
 {
-   <insert a suppression name here>
+   libXft Leak
    Memcheck:Leak
    fun:malloc
    obj:/usr/X11R6/lib/libXft.so.2.1.2
 }
-
 {
-   <insert a suppression name here>
+   /usr/bin/esd calloc Leak
    Memcheck:Leak
    fun:calloc
    obj:/usr/bin/esd
 }
 {
-   <insert a suppression name here>
+   /usr/bin/esd malloc Leak
    Memcheck:Leak
    fun:malloc
    obj:/usr/bin/esd
 }
 {
-   <insert a suppression name here>
+   /lib/libasound Leak
    Memcheck:Leak
    fun:malloc
    obj:/lib/libasound.so.2.0.0
 }
 {
-   <insert a suppression name here>
+   esd_open_sound Leak
    Memcheck:Leak
    fun:malloc
    fun:esd_get_socket_dirname
@@ -250,7 +261,7 @@
    fun:esd_open_sound
 }
 {
-   <insert a suppression name here>
+   snd_pcm_open Leak
    Memcheck:Leak
    fun:calloc
    fun:snd_config_update_r
@@ -258,7 +269,7 @@
    fun:snd_pcm_open
 }
 {
-   <insert a suppression name here>
+   snd_output_stdio_attach Leak
    Memcheck:Leak
    fun:calloc
    fun:snd_output_stdio_attach
@@ -266,20 +277,18 @@
    obj:/usr/bin/esd
 }
 {
-   <insert a suppression name here>
+   esd_get_socket_name Leak
    Memcheck:Leak
    fun:malloc
    fun:esd_get_socket_name
    fun:esd_open_sound
    obj:/usr/lib/libgnome-2.so.0.800.0
 }
-
 {
-   <insert a suppression name here>
+   /lib/libcrypto realloc Leak
    Memcheck:Leak
    fun:realloc
    obj:/lib/libcrypto.so.0.9.7a
 }
 
-
 # ##----------------------------------------------------------------------##

Copied: gnucash/trunk/src/valgrind-libfontconfig.supp (from rev 17438, gnucash/branches/gda-dev2/src/valgrind-libfontconfig.supp)
===================================================================
--- gnucash/trunk/src/valgrind-libfontconfig.supp	                        (rev 0)
+++ gnucash/trunk/src/valgrind-libfontconfig.supp	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,57 @@
+# FILE: valgrind-libfontconfig.supp
+#
+# FUNCTION: This file is a valgrind 'suppression' file, used to 
+#     get valgrind to not report certain errors that we aren't 
+#     interested in.
+#
+#     valgrind is a memory allocation debugging tool.  See the
+#     file ./HACKING for instructions on how to run gnucash with
+#     valgrind
+#
+# HISTORY: created aug 2003 linas vepstas
+
+
+##----------------------------------------------------------------------##
+
+# Format of this file is:
+# {
+#     name_of_suppression
+#     skin_name:supp_kind
+#     (optional extra info for some suppression types)
+#     caller0 name, or /name/of/so/file.so
+#     caller1 name, or ditto
+#     (optionally: caller2 name)
+#     (optionally: caller3 name)
+#  }
+#
+# For memcheck, the supp_kinds are:
+#
+#     Param Value1 Value2 Value4 Value8 Value16
+#     Free Addr1 Addr2 Addr4 Addr8 Addr16
+#     Cond (previously known as Value0)
+#     Leak
+#
+# and the optional extra info is:
+#     if Param: name of system call param
+#     if Free: name of free-ing fn)
+
+{
+	libfontconfig realloc Leak
+	Memcheck:Leak
+	fun:realloc
+	obj:/usr/lib/libfontconfig.so.1.3.0
+}
+{
+	libfontconfig malloc Leak #1
+	Memcheck:Leak
+	fun:malloc
+	obj:/usr/lib/libfontconfig.so.1.3.0
+}
+{
+	libfontconfig malloc Leak #2
+	fun:malloc
+	fun:FcStrCopy
+}
+
+
+# ##----------------------------------------------------------------------##

Copied: gnucash/trunk/src/valgrind-libgda.supp (from rev 17438, gnucash/branches/gda-dev2/src/valgrind-libgda.supp)
===================================================================
--- gnucash/trunk/src/valgrind-libgda.supp	                        (rev 0)
+++ gnucash/trunk/src/valgrind-libgda.supp	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,51 @@
+
+# FILE: valgrind-gnucash.supp
+#
+# FUNCTION: This file is a valgrind 'suppression' file, used to 
+#     get valgrind to not report certain errors that we aren't 
+#     interested in.
+#
+#     valgrind is a memory allocation debugging tool.  See the
+#     file ./HACKING for instructions on how to run gnucash with
+#     valgrind
+#
+# HISTORY: created aug 2003 linas vepstas
+
+
+##----------------------------------------------------------------------##
+
+# Format of this file is:
+# {
+#     name_of_suppression
+#     skin_name:supp_kind
+#     (optional extra info for some suppression types)
+#     caller0 name, or /name/of/so/file.so
+#     caller1 name, or ditto
+#     (optionally: caller2 name)
+#     (optionally: caller3 name)
+#  }
+#
+# For memcheck, the supp_kinds are:
+#
+#     Param Value1 Value2 Value4 Value8 Value16
+#     Free Addr1 Addr2 Addr4 Addr8 Addr16
+#     Cond (previously known as Value0)
+#     Leak
+#
+# and the optional extra info is:
+#     if Param: name of system call param
+#     if Free: name of free-ing fn)
+
+{
+	libgda permanant memory for gda_paramlist_dtd
+	Memcheck:Leak
+	fun:malloc
+	fun:xmlStrndup
+	fun:xmlStrdup
+	fun:xmlNewDtd
+	fun:xmlSAXParseDTD
+	fun:xmlParseDTD
+	fun:gda_init
+}
+
+# ##----------------------------------------------------------------------##

Copied: gnucash/trunk/src/valgrind-libguile.supp (from rev 17438, gnucash/branches/gda-dev2/src/valgrind-libguile.supp)
===================================================================
--- gnucash/trunk/src/valgrind-libguile.supp	                        (rev 0)
+++ gnucash/trunk/src/valgrind-libguile.supp	2008-08-01 16:02:07 UTC (rev 17444)
@@ -0,0 +1,91 @@
+
+# FILE: valgrind-gnucash.supp
+#
+# FUNCTION: This file is a valgrind 'suppression' file, used to 
+#     get valgrind to not report certain errors that we aren't 
+#     interested in.
+#
+#     valgrind is a memory allocation debugging tool.  See the
+#     file ./HACKING for instructions on how to run gnucash with
+#     valgrind
+#
+# HISTORY: created aug 2003 linas vepstas
+
+
+##----------------------------------------------------------------------##
+
+# Format of this file is:
+# {
+#     name_of_suppression
+#     skin_name:supp_kind
+#     (optional extra info for some suppression types)
+#     caller0 name, or /name/of/so/file.so
+#     caller1 name, or ditto
+#     (optionally: caller2 name)
+#     (optionally: caller3 name)
+#  }
+#
+# For memcheck, the supp_kinds are:
+#
+#     Param Value1 Value2 Value4 Value8 Value16
+#     Free Addr1 Addr2 Addr4 Addr8 Addr16
+#     Cond (previously known as Value0)
+#     Leak
+#
+# and the optional extra info is:
+#     if Param: name of system call param
+#     if Free: name of free-ing fn)
+
+{
+   libguile.so(Cond)
+   Memcheck:Cond
+   obj:*libguile.so.*
+}
+{
+   libguile.so(Value4)
+   Memcheck:Value4
+   obj:*libguile.so*
+}
+{
+   libguile.so(Leak)
+   Memcheck:Leak
+   fun:malloc
+   obj:*libguile.so*
+   obj:*libguile.so*
+   obj:*libguile.so*
+}
+{
+   scm_make_port_type Leak
+   Memcheck:Leak
+   fun:realloc
+   fun:scm_make_port_type
+   fun:scm_init_vports
+   obj:*libguile.so*
+}
+{
+   scm_gc_for_newcell Leak
+   Memcheck:Leak
+   fun:malloc
+   obj:*libguile.so*
+   fun:scm_gc_for_newcell
+   fun:scm_acons
+}
+{
+	scm_dynamic_link leak
+	Memcheck:Leak
+	fun:malloc
+	obj:*libguile-ltdl*
+	obj:*libguile-ltdl*
+	obj:*libguile-ltdl*
+	fun:scm_lt_dlopenext
+	fun:scm_dynamic_link
+}
+{
+	scm_deval leak
+	Memcheck:Leak
+	fun:malloc
+	fun:_wrap_*
+	fun:scm_deval
+}
+
+# ##----------------------------------------------------------------------##



More information about the gnucash-changes mailing list