backend config

Derek Atkins warlord at MIT.EDU
Thu Aug 18 08:14:37 EDT 2005


You might also want another API:

  GHashTable* qof_backend_check_config(QofBackend*);

This would return a (const) HashTable from the backend object and list
all the current configuration options that the backend accepts.  This
would allow the backend to even set defaults.  Of course this means
you need some way to 'type' the configuration options.

-derek

Neil Williams <linux at codehelp.co.uk> writes:

> 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/
>
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list