[QOF-devel] Re: QofBackend / QofSession changes in next commit.

Neil Williams linux at codehelp.co.uk
Fri Sep 2 08:50:33 EDT 2005

On Friday 02 September 2005 8:59 am, Christian Stimming wrote:
> If yes, then I would like to hear where you are now going to put the
> backend configuration option documentation and translation

I'm thinking of this method:

Automake generates a header file in each backend that includes two paths, the 
path to the installed .la file to find the library itself and a path to the 
installed XML file to retrieve the config. The header will then be installed 
with all the others for configure to locate via pkg-config etc.

(The .la is used to provide platform-independence - we should never have been 
using *.so directly).

On my system, this header defines (for cashutil):
#define GNC_LIB_DIR "/opt/garfield/cashutil/lib"
#define GNC_XML_DIR "/opt/garfield/cashutil/share/xml/cashutil"
#define GNC_LIB_NAME "libgnc-backend-file.la"
#define GNC_LIB_INIT "gnc_provider_init"

(the cashutil reference will be changed once cashutil is within the gnucash 
CVS tree). There will be a similar header for QSF using QOF_LIB_DIR etc.

On an installed gnucash system I'd expect:
#define GNC_LIB_DIR "/usr/lib"
#define GNC_XML_DIR "/usr/share/xml/gnucash"
#define GNC_LIB_NAME "libgnc-backend-file.la"
#define GNC_LIB_INIT "gnc_provider_init"

This means that applications that compile with known backends will be serviced 
by a single #include that defines the two paths and the application simply 
uses the define to provide platform independence and opt-style installation.

#include <qof.h>           // for QSF macros and qof itself
#include "gncla-dir.h"    // for the gnc backend macros.
int main () {

pilotqof will be able to find qofla-dir.h via #include <qof.h> and can 
therefore find the QSF backend and config. The other defines allow the 
library to be loaded.

GnuCash will need to know where the GNC backend is installed (as it will be 
shared with cashutil) and will also pick up the location of QSF via #include 
<qof.h>. So GnuCash uses two such header files, gncla-dir.h (which automake 
generates from src/backend/gncla-dir.h.in) and qofla-dir.h (from <qof.h>).

The XML includes the name of the backend which will be used to determine the 
default backend, if the application uses that feature.

The configuration options can be modified without recompiling code for a 
generic option dialog because once you have the location of the XML file it 
can be loaded and used to parse the KvpFrame.

<?xml version="1.0" encoding="UTF-8"?>
<qofconfig xmlns="http://qof.sourceforge.net/" >
  <backend name="GnuCash Backend Version 2">
        <option type="gint64" name="file_retention_days" />
        <option type="boolean" name="file_compression" />

The KvpFrame returned by
KvpFrame* qof_backend_get_config(QofBackend *be);
is created using:

#define GNC_BE_DAYS "file_retention_days"
#define GNC_BE_ZIP  "file_compression"
#define CONFIG_DESC "/desc"
#define CONFIG_TIP  "/tip"

static KvpFrame*
gnc_file_be_get_config(QofBackend *be)
	const char *retention_days_desc = _("Number of days to retain old files");
	const char *retention_days_tip = _("GnuCash keeps backups of old files, "
		"this setting dictates how long each is kept");
	const char *use_compression_desc = _("Compress output files?");
	const char *use_compression_tip = _("GnuCash can save data files with 
		"Enable this option to compress your data file. ");

	if(!be) { return NULL; }
	if(!kvp_frame_is_empty(be->backend_configuration)) {
		be->backend_configuration = kvp_frame_new();
		GNC_BE_DAYS, (gint64)file_retention_days);
		GNC_BE_DAYS CONFIG_DESC, retention_days_desc);
		GNC_BE_DAYS CONFIG_TIP, retention_days_tip);
	if(file_compression) {
	else {
		GNC_BE_ZIP CONFIG_DESC, use_compression_desc);
		GNC_BE_ZIP CONFIG_TIP, use_compression_tip);
	return be->backend_configuration;

All this is in the next commit.


Neil Williams

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20050902/0daed183/attachment.bin

More information about the gnucash-devel mailing list