Hello, I'd like to store a number of WMS servers in ~/.viking/viking.prefs. It is going to look like this:
wms.servers.1.name=Landsat wms.servers.1.baseurl=http://onearth.jpl.nasa.gov/wms.cgi?styles=& wms.servers.1.layers=global_mosaic wms.servers.1.srs=EPSG:4326 wms.servers.2.name=localhost soviet military rasters wms.servers.2.baseurl=http://localhost/sovmil? The problem is that preferences_load_from_file() refuses to insert into hash any keys/vals that are not yet known: if ( preferences_load_parse_param(buf, &key, &val ) ) { // if it's not in there, ignore it oldval = g_hash_table_lookup ( values, key ); if ( ! oldval ) { g_free(key); continue; } The WMS layer can't know number of configured servers in viking.prefs at startup, thus the default values aren't in hash. Actually "default values" isn't applicable to a list of servers of unknown size. I suggest the following way to extend preferences facility: 1) The groups_names GPtrArray will now point not to gchars, but to smth like struct { gchar *name; VikLayerTypedParamData * (*taste)(const gchar *key, const gchar *val); } The taste() function may be NULL. 2) a_preferences_register_group() is extended by one parameter - taste function. Modules may provide taste() function via a_preferences_register_group() or may provide NULL. 3) Whenever the preferences_load_from_file() encounters an unknown param, it checks whether its namespace matches any of known groups. If matching group found, and it has taste method, then the method is called. If it returns a non-NULL VikLayerTypedParamData pointer then options is recognized and of a known type, and it is inserted into hash. Any opinions? -- Totus tuus, Glebius. GLEB-RIPE ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/