backend config
Neil Williams
linux at codehelp.co.uk
Thu Aug 18 06:57:26 EDT 2005
To remove GConf and thereby Gtk from the backends, I've got a possible new
method in QofBackend:
In QOF (public API):
/** \brief Load configuration options specific to this backend.
\param be The backend to configure.
\param config A hash table with specific keys that this backend
will recognise. Each backend needs to document their own config
keys and acceptable values.
The hash table remains the property of the caller and should
be freed / destroyed once the data is loaded in the backend.
*/
void qof_backend_load_config (QofBackend *be, GHashTable *config);
plus a new member of QofBackend:
* To support configuration options from the frontend, the backend
* can be passed a GHashTable - according to the allowed options
* for that backend, using load_config(). Configuration can be
* updated at any point - it is up to the frontend to load the
* data in time for whatever the backend needs to do. e.g. an
* option to save a new book in a compressed format need not be
* loaded until the backend is about to save. The option to open
* a compressed format needs to be loaded between backend_new and
* session_begin(). If the configuration is updated by the user,
* the frontend should call load_config again to update the backend.
void (*load_config) (QofBackend *, GHashTable *);
Not sure which is the best header for these:
#define GNC_BE_DAYS "file_retention_days"
#define GNC_BE_ZIP "file_compression"
in gnc-backend-file.c
void
gnc_file_be_set_config(QofBackend *be, GHashTable *config)
{
FileBackend *fbe;
fbe = (FileBackend*)be;
file_compression = (gboolean)g_hash_table_lookup(config, GNC_BE_ZIP);
file_retention_days = (int)g_hash_table_lookup(config, GNC_BE_DAYS);
}
All that will be internal to the backend library and QOF - this is all that
would need to be done in the frontend:
In core-utils or app-utils or wherever is most appropriate, you'd create a
hash table.
GHashTable *be_config;
QofBackend *be;
be = qof_book_get_backend(book);
be_config = g_hash_table_new(g_int_hash, g_int_equal);
g_hash_table_insert(be_config, GNC_BE_DAYS, file_retention_days);
g_hash_table_insert(be_config, GNC_BE_ZIP, file_compression);
qof_backend_load_config(be, be_config);
g_hash_table_destroy(be_config);
Or a function that can be called again and again using a static hash table
maybe, defined in one of the core-utils files. Updating any value would
simply mean inserting the new value with the same key.
Would that work for you, David?
This is part of the move away from the current backend module and into a
loadable backend library like QSF using QofBackendProvider.
--
Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/
-------------- 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/20050818/d81c769b/attachment.bin
More information about the gnucash-devel
mailing list